@edge-base/server 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin-build/_app/immutable/assets/21.x9OgMBdi.css +1 -0
- package/admin-build/_app/immutable/assets/TableSqlTab.BHquaMBM.css +1 -0
- package/admin-build/_app/immutable/chunks/{DOxNYcs9.js → 9Ch6RgcX.js} +1 -1
- package/admin-build/_app/immutable/chunks/B-pVQkKM.js +1 -0
- package/admin-build/_app/immutable/chunks/{eFQHTGwA.js → B0HRJ657.js} +1 -1
- package/admin-build/_app/immutable/chunks/B2bEC_Hm.js +1 -0
- package/admin-build/_app/immutable/chunks/{CwROoZK0.js → B8s_s9QY.js} +1 -1
- package/admin-build/_app/immutable/chunks/{CY1F93Wv.js → BOSBsYO8.js} +1 -1
- package/admin-build/_app/immutable/chunks/{ehbppgYb.js → Bb0e0sAP.js} +1 -1
- package/admin-build/_app/immutable/chunks/{glwixJlP.js → BdTBlfLy.js} +1 -1
- package/admin-build/_app/immutable/chunks/{DoPXzH7F.js → Bn2NtlTj.js} +1 -1
- package/admin-build/_app/immutable/chunks/BvukSxhJ.js +128 -0
- package/admin-build/_app/immutable/chunks/BwxFS5FL.js +2 -0
- package/admin-build/_app/immutable/chunks/{Cs0GwzJA.js → C72lTcG0.js} +1 -1
- package/admin-build/_app/immutable/chunks/{BmRjiP5k.js → C8s55wKu.js} +1 -1
- package/admin-build/_app/immutable/chunks/{BK8YUsyH.js → CBVE2cdU.js} +1 -1
- package/admin-build/_app/immutable/chunks/{Ga6XaOJm.js → CF95mcQY.js} +1 -1
- package/admin-build/_app/immutable/chunks/CGgVJi7f.js +1 -0
- package/admin-build/_app/immutable/chunks/{NuUjtcO2.js → CYatlt7w.js} +1 -1
- package/admin-build/_app/immutable/chunks/{CLHXYVje.js → CnWwy2Sf.js} +1 -1
- package/admin-build/_app/immutable/chunks/{C6puvcoR.js → CoI6jjbg.js} +2 -2
- package/admin-build/_app/immutable/chunks/{B8vJP3wz.js → Cp8V0Xy2.js} +1 -1
- package/admin-build/_app/immutable/chunks/{p-WBlAu3.js → D8o7yzcA.js} +1 -1
- package/admin-build/_app/immutable/chunks/{BR_fL5Yv.js → DEELgv7K.js} +1 -1
- package/admin-build/_app/immutable/chunks/{7f08Id8e.js → DHWOQ9Ui.js} +1 -1
- package/admin-build/_app/immutable/chunks/{Bh56EfQ_.js → DILS_-VJ.js} +1 -1
- package/admin-build/_app/immutable/chunks/{BF8I5XXQ.js → DTmaM1M6.js} +1 -1
- package/admin-build/_app/immutable/chunks/{DYDZ2Kma.js → DroeC-Do.js} +1 -1
- package/admin-build/_app/immutable/chunks/{Br0qug7_.js → DskOoVLT.js} +1 -1
- package/admin-build/_app/immutable/chunks/{7B47DvSx.js → Dt4vL4Df.js} +1 -1
- package/admin-build/_app/immutable/chunks/{D5h5A1cc.js → DtZk82gG.js} +2 -2
- package/admin-build/_app/immutable/chunks/{C4D51vTW.js → F9_4wRrd.js} +1 -1
- package/admin-build/_app/immutable/chunks/{BhjcOf7X.js → I0AZRbV2.js} +1 -1
- package/admin-build/_app/immutable/chunks/{BMMOfNi6.js → MKsm6wXE.js} +1 -1
- package/admin-build/_app/immutable/chunks/WtDa8jKW.js +1 -0
- package/admin-build/_app/immutable/chunks/XmteHKH_.js +1 -0
- package/admin-build/_app/immutable/chunks/{UUazaC_N.js → Y22E1hJM.js} +1 -1
- package/admin-build/_app/immutable/chunks/{vApWTCBs.js → Z41NK6i6.js} +1 -1
- package/admin-build/_app/immutable/chunks/{DrQSgw-f.js → _teD5ji5.js} +1 -1
- package/admin-build/_app/immutable/chunks/{MdeqaOQx.js → gtu8uwJD.js} +1 -1
- package/admin-build/_app/immutable/chunks/{DnyL7Zq-.js → m9eWh0Cd.js} +1 -1
- package/admin-build/_app/immutable/chunks/{C0LrJucL.js → v2HHbTgy.js} +1 -1
- package/admin-build/_app/immutable/entry/app.Dh4eYd90.js +2 -0
- package/admin-build/_app/immutable/entry/start.DjnjDre4.js +1 -0
- package/admin-build/_app/immutable/nodes/{0.B13aXl3s.js → 0._kCczuod.js} +1 -1
- package/admin-build/_app/immutable/nodes/{1.we4dgVtx.js → 1.C8vaAzdV.js} +1 -1
- package/admin-build/_app/immutable/nodes/{10.hrAvOhgI.js → 10.TsbpWcyB.js} +1 -1
- package/admin-build/_app/immutable/nodes/{11.BZM_Cbjk.js → 11.DbwjQWdP.js} +1 -1
- package/admin-build/_app/immutable/nodes/{12.pfrTdfHj.js → 12.BMCb3LcM.js} +1 -1
- package/admin-build/_app/immutable/nodes/{13.BvR9UoZX.js → 13.CTXx-p7a.js} +1 -1
- package/admin-build/_app/immutable/nodes/{14.BCE_g1DT.js → 14.BW1Sfg3E.js} +1 -1
- package/admin-build/_app/immutable/nodes/{15.DZrUjo5V.js → 15.DAKEfLVF.js} +1 -1
- package/admin-build/_app/immutable/nodes/{16.B_K_CGU4.js → 16.BZHOIVRq.js} +1 -1
- package/admin-build/_app/immutable/nodes/{17.D7RlNUbd.js → 17.DcntvsXi.js} +1 -1
- package/admin-build/_app/immutable/nodes/{18.dw9OGxA1.js → 18.Badw-bZ2.js} +1 -1
- package/admin-build/_app/immutable/nodes/{19.B_K_CGU4.js → 19.BZHOIVRq.js} +1 -1
- package/admin-build/_app/immutable/nodes/2.Bn3R2oDm.js +1 -0
- package/admin-build/_app/immutable/nodes/{20.Bij6g6xR.js → 20.DDTfgFOS.js} +1 -1
- package/admin-build/_app/immutable/nodes/21.BbdBT511.js +1 -0
- package/admin-build/_app/immutable/nodes/{22.wLPyRbDg.js → 22.DLaL76VE.js} +1 -1
- package/admin-build/_app/immutable/nodes/{23.DnjIdPPl.js → 23.D1tjWuvB.js} +1 -1
- package/admin-build/_app/immutable/nodes/{24.PhJEmwPf.js → 24.8cwANb8Q.js} +1 -1
- package/admin-build/_app/immutable/nodes/{25.HUYuEeiI.js → 25.DCU-ztvR.js} +1 -1
- package/admin-build/_app/immutable/nodes/{26.CtrQ3jI5.js → 26.CuHUfaEI.js} +1 -1
- package/admin-build/_app/immutable/nodes/{27.CMM8T90I.js → 27.fOpy2ckO.js} +1 -1
- package/admin-build/_app/immutable/nodes/{28.CH6XAnHt.js → 28.DWB877rH.js} +1 -1
- package/admin-build/_app/immutable/nodes/{29.Bos0u5_B.js → 29.D9hvrxFP.js} +1 -1
- package/admin-build/_app/immutable/nodes/{3.BPnU2jxx.js → 3.BJG5UaW0.js} +1 -1
- package/admin-build/_app/immutable/nodes/{30.ScIH1W0H.js → 30.52Okvb4S.js} +1 -1
- package/admin-build/_app/immutable/nodes/{31.CXHVAiwb.js → 31.B2rKWEXY.js} +1 -1
- package/admin-build/_app/immutable/nodes/{4.BY6Ri1gh.js → 4.BMrPKdZ6.js} +1 -1
- package/admin-build/_app/immutable/nodes/{5.D0tPp_Kt.js → 5.BHBRNfgt.js} +1 -1
- package/admin-build/_app/immutable/nodes/{6.BuWVNVH1.js → 6.Uq3G0mmd.js} +1 -1
- package/admin-build/_app/immutable/nodes/{7.B26-qam0.js → 7.BS-ss8zw.js} +1 -1
- package/admin-build/_app/immutable/nodes/{8.CdDKHsMK.js → 8.5bzwkzMM.js} +1 -1
- package/admin-build/_app/immutable/nodes/{9.BSo7a28L.js → 9.BA61CCFG.js} +1 -1
- package/admin-build/_app/version.json +1 -1
- package/admin-build/favicon.svg +3 -2
- package/admin-build/index.html +17 -16
- package/package.json +2 -2
- package/admin-build/_app/immutable/assets/21.Dz2RJ56c.css +0 -1
- package/admin-build/_app/immutable/chunks/BOjkBtym.js +0 -1
- package/admin-build/_app/immutable/chunks/CB8xN3_t.js +0 -1
- package/admin-build/_app/immutable/chunks/CxbRue-5.js +0 -1
- package/admin-build/_app/immutable/chunks/CyqB6g-D.js +0 -1
- package/admin-build/_app/immutable/entry/app.BcgNsUX3.js +0 -2
- package/admin-build/_app/immutable/entry/start.otAJzcqZ.js +0 -1
- package/admin-build/_app/immutable/nodes/2.BKoKrw1i.js +0 -1
- package/admin-build/_app/immutable/nodes/21.DyYxtUDl.js +0 -128
|
@@ -7,4 +7,4 @@ let _s=[],Go=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,
|
|
|
7
7
|
`;this.styleTag.textContent=o;let l=e.head||e;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var ie={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},ai={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},wh=typeof navigator<"u"&&/Mac/.test(navigator.platform),kh=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var tt=0;tt<10;tt++)ie[48+tt]=ie[96+tt]=String(tt);for(var tt=1;tt<=24;tt++)ie[tt+111]="F"+tt;for(var tt=65;tt<=90;tt++)ie[tt]=String.fromCharCode(tt+32),ai[tt]=String.fromCharCode(tt);for(var Bs in ie)ai.hasOwnProperty(Bs)||(ai[Bs]=ie[Bs]);function vh(n){var t=wh&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||kh&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",e=!t&&n.key||(n.shiftKey?ai:ie)[n.keyCode]||n.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}let ot=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},hn=typeof document<"u"?document:{documentElement:{style:{}}};const fn=/Edge\/(\d+)/.exec(ot.userAgent),ul=/MSIE \d/.test(ot.userAgent),cn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ot.userAgent),ms=!!(ul||cn||fn),Mr=!ms&&/gecko\/(\d+)/i.test(ot.userAgent),Os=!ms&&/Chrome\/(\d+)/.exec(ot.userAgent),Sh="webkitFontSmoothing"in hn.documentElement.style,un=!ms&&/Apple Computer/.test(ot.vendor),Tr=un&&(/Mobile\/\w+/.test(ot.userAgent)||ot.maxTouchPoints>2);var S={mac:Tr||/Mac/.test(ot.platform),windows:/Win/.test(ot.platform),linux:/Linux|X11/.test(ot.platform),ie:ms,ie_version:ul?hn.documentMode||6:cn?+cn[1]:fn?+fn[1]:0,gecko:Mr,gecko_version:Mr?+(/Firefox\/(\d+)/.exec(ot.userAgent)||[0,0])[1]:0,chrome:!!Os,chrome_version:Os?+Os[1]:0,ios:Tr,android:/Android\b/.test(ot.userAgent),webkit_version:Sh?+(/\bAppleWebKit\/(\d+)/.exec(ot.userAgent)||[0,0])[1]:0,safari:un,safari_version:un?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ot.userAgent)||[0,0])[1]:0,tabSize:hn.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Hn(n,t){for(let e in n)e=="class"&&t.class?t.class+=" "+n.class:e=="style"&&t.style?t.style+=";"+n.style:t[e]=n[e];return t}const Xi=Object.create(null);function zn(n,t,e){if(n==t)return!0;n||(n=Xi),t||(t=Xi);let i=Object.keys(n),s=Object.keys(t);if(i.length-0!=s.length-0)return!1;for(let r of i)if(r!=e&&(s.indexOf(r)==-1||n[r]!==t[r]))return!1;return!0}function Ch(n,t){for(let e=n.attributes.length-1;e>=0;e--){let i=n.attributes[e].name;t[i]==null&&n.removeAttribute(i)}for(let e in t){let i=t[e];e=="style"?n.style.cssText=i:n.getAttribute(e)!=i&&n.setAttribute(e,i)}}function Br(n,t,e){let i=!1;if(t)for(let s in t)e&&s in e||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(e)for(let s in e)t&&t[s]==e[s]||(i=!0,s=="style"?n.style.cssText=e[s]:n.setAttribute(s,e[s]));return i}function Ah(n){let t=Object.create(null);for(let e=0;e<n.attributes.length;e++){let i=n.attributes[e];t[i.name]=i.value}return t}class ze{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}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var kt=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(kt||(kt={}));class K extends te{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 bi(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ge(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:r,end:o}=dl(t,e);i=(r?e?-3e8:-1:5e8)-1,s=(o?e?2e8:1:-6e8)+1}return new ge(t,i,s,e,t.widget||null,!0)}static line(t){return new yi(t)}static set(t,e=!1){return N.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}K.none=N.empty;class bi extends K{constructor(t){let{start:e,end:i}=dl(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?Hn(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||Xi}eq(t){return this==t||t instanceof bi&&this.tagName==t.tagName&&zn(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}bi.prototype.point=!1;class yi extends K{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof yi&&this.spec.class==t.spec.class&&zn(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}yi.prototype.mapMode=lt.TrackBefore;yi.prototype.point=!0;class ge extends K{constructor(t,e,i,s,r,o){super(e,i,r,t),this.block=s,this.isReplace=o,this.mapMode=s?e<=0?lt.TrackBefore:lt.TrackAfter:lt.TrackDel}get type(){return this.startSide!=this.endSide?kt.WidgetRange:this.startSide<=0?kt.WidgetBefore:kt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof ge&&Mh(this.widget,t.widget)&&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 new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}ge.prototype.point=!0;function dl(n,t=!1){let{inclusiveStart:e,inclusiveEnd:i}=n;return e==null&&(e=n.inclusive),i==null&&(i=n.inclusive),{start:e??t,end:i??t}}function Mh(n,t){return n==t||!!(n&&t&&n.compare(t))}function Te(n,t,e,i=0){let s=e.length-1;s>=0&&e[s]+i>=n?e[s]=Math.max(e[s],t):e.push(n,t)}class hi extends te{constructor(t,e){super(),this.tagName=t,this.attributes=e}eq(t){return t==this||t instanceof hi&&this.tagName==t.tagName&&zn(this.attributes,t.attributes)}static create(t){return new hi(t.tagName,t.attributes||Xi)}static set(t,e=!1){return N.of(t,e)}}hi.prototype.startSide=hi.prototype.endSide=-1;function fi(n){let t;return n.nodeType==11?t=n.getSelection?n:n.ownerDocument:t=n,t.getSelection()}function dn(n,t){return t?n==t||n.contains(t.nodeType!=1?t.parentNode:t):!1}function ei(n,t){if(!t.anchorNode)return!1;try{return dn(n,t.anchorNode)}catch{return!1}}function ii(n){return n.nodeType==3?ui(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function si(n,t,e,i){return e?Or(n,t,e,i,-1)||Or(n,t,e,i,1):!1}function se(n){for(var t=0;;t++)if(n=n.previousSibling,!n)return t}function Qi(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function Or(n,t,e,i,s){for(;;){if(n==e&&t==i)return!0;if(t==(s<0?0:Gt(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;t=se(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[t+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;t=s<0?Gt(n):0}else return!1}}function Gt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ci(n,t){let e=t?n.left:n.right;return{left:e,right:e,top:n.top,bottom:n.bottom}}function Th(n){let t=n.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function pl(n,t){let e=t.width/n.offsetWidth,i=t.height/n.offsetHeight;return(e>.995&&e<1.005||!isFinite(e)||Math.abs(t.width-n.offsetWidth)<1)&&(e=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(t.height-n.offsetHeight)<1)&&(i=1),{scaleX:e,scaleY:i}}function Bh(n,t,e,i,s,r,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let f=n,c=!1;f&&!c;)if(f.nodeType==1){let u,d=f==a.body,p=1,g=1;if(d)u=Th(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(f).position)&&(c=!0),f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let x=f.getBoundingClientRect();({scaleX:p,scaleY:g}=pl(f,x)),u={left:x.left,right:x.left+f.clientWidth*p,top:x.top,bottom:x.top+f.clientHeight*g}}let m=0,b=0;if(s=="nearest")t.top<u.top?(b=t.top-(u.top+o),e>0&&t.bottom>u.bottom+b&&(b=t.bottom-u.bottom+o)):t.bottom>u.bottom&&(b=t.bottom-u.bottom+o,e<0&&t.top-b<u.top&&(b=t.top-(u.top+o)));else{let x=t.bottom-t.top,v=u.bottom-u.top;b=(s=="center"&&x<=v?t.top+x/2-v/2:s=="start"||s=="center"&&e<0?t.top-o:t.bottom-v+o)-u.top}if(i=="nearest"?t.left<u.left?(m=t.left-(u.left+r),e>0&&t.right>u.right+m&&(m=t.right-u.right+r)):t.right>u.right&&(m=t.right-u.right+r,e<0&&t.left<u.left+m&&(m=t.left-(u.left+r))):m=(i=="center"?t.left+(t.right-t.left)/2-(u.right-u.left)/2:i=="start"==l?t.left-r:t.right-(u.right-u.left)+r)-u.left,m||b)if(d)h.scrollBy(m,b);else{let x=0,v=0;if(b){let T=f.scrollTop;f.scrollTop+=b/g,v=(f.scrollTop-T)*g}if(m){let T=f.scrollLeft;f.scrollLeft+=m/p,x=(f.scrollLeft-T)*p}t={left:t.left-x,top:t.top-v,right:t.right-x,bottom:t.bottom-v},x&&Math.abs(x-m)<1&&(i="nearest"),v&&Math.abs(v-b)<1&&(s="nearest")}if(d)break;(t.top<u.top||t.bottom>u.bottom||t.left<u.left||t.right>u.right)&&(t={left:Math.max(t.left,u.left),right:Math.min(t.right,u.right),top:Math.max(t.top,u.top),bottom:Math.min(t.bottom,u.bottom)}),f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function gl(n,t=!0){let e=n.ownerDocument,i=null,s=null;for(let r=n.parentNode;r&&!(r==e.body||(!t||i)&&s);)if(r.nodeType==1)!s&&r.scrollHeight>r.clientHeight&&(s=r),t&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:s}}class Oh{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){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Gt(e):0),i,Math.min(t.focusOffset,i?Gt(i):0))}set(t,e,i,s){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=s}}let fe=null;S.safari&&S.safari_version>=26&&(fe=!1);function ml(n){if(n.setActive)return n.setActive();if(fe)return n.focus(fe);let t=[];for(let e=n;e&&(t.push(e,e.scrollTop,e.scrollLeft),e!=e.ownerDocument);e=e.parentNode);if(n.focus(fe==null?{get preventScroll(){return fe={preventScroll:!0},!0}}:void 0),!fe){fe=!1;for(let e=0;e<t.length;){let i=t[e++],s=t[e++],r=t[e++];i.scrollTop!=s&&(i.scrollTop=s),i.scrollLeft!=r&&(i.scrollLeft=r)}}}let Dr;function ui(n,t,e=t){let i=Dr||(Dr=document.createRange());return i.setEnd(n,e),i.setStart(n,t),i}function Be(n,t,e,i){let s={key:t,code:t,keyCode:e,which:e,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,n.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,n.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function Dh(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Ph(n,t){let e=t.focusNode,i=t.focusOffset;if(!e||t.anchorNode!=e||t.anchorOffset!=i)return!1;for(i=Math.min(i,Gt(e));;)if(i){if(e.nodeType!=1)return!1;let s=e.childNodes[i-1];s.contentEditable=="false"?i--:(e=s,i=Gt(e))}else{if(e==n)return!0;i=se(e),e=e.parentNode}}function bl(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function yl(n,t){for(let e=n,i=t;;){if(e.nodeType==3&&i>0)return{node:e,offset:i};if(e.nodeType==1&&i>0){if(e.contentEditable=="false")return null;e=e.childNodes[i-1],i=Gt(e)}else if(e.parentNode&&!Qi(e))i=se(e),e=e.parentNode;else return null}}function xl(n,t){for(let e=n,i=t;;){if(e.nodeType==3&&i<e.nodeValue.length)return{node:e,offset:i};if(e.nodeType==1&&i<e.childNodes.length){if(e.contentEditable=="false")return null;e=e.childNodes[i],i=0}else if(e.parentNode&&!Qi(e))i=se(e)+1,e=e.parentNode;else return null}}class At{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new At(t.parentNode,se(t),e)}static after(t,e){return new At(t.parentNode,se(t)+1,e)}}var G=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(G||(G={}));const me=G.LTR,Kn=G.RTL;function wl(n){let t=[];for(let e=0;e<n.length;e++)t.push(1<<+n[e]);return t}const Ih=wl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Lh=wl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),pn=Object.create(null),Pt=[];for(let n of["()","[]","{}"]){let t=n.charCodeAt(0),e=n.charCodeAt(1);pn[t]=e,pn[e]=-t}function kl(n){return n<=247?Ih[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?Lh[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}const Rh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ft{get dir(){return this.level%2?Kn:me}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,s){let r=-1;for(let o=0;o<t.length;o++){let l=t[o];if(l.from<=e&&l.to>=e){if(l.level==i)return o;(r<0||(s!=0?s<0?l.from<e:l.to>e:t[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function vl(n,t){if(n.length!=t.length)return!1;for(let e=0;e<n.length;e++){let i=n[e],s=t[e];if(i.from!=s.from||i.to!=s.to||i.direction!=s.direction||!vl(i.inner,s.inner))return!1}return!0}const W=[];function Eh(n,t,e,i,s){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:t,l=r<i.length?i[r].from:e,a=r?256:s;for(let h=o,f=a,c=a;h<l;h++){let u=kl(n.charCodeAt(h));u==512?u=f:u==8&&c==4&&(u=16),W[h]=u==4?2:u,u&7&&(c=u),f=u}for(let h=o,f=a,c=a;h<l;h++){let u=W[h];if(u==128)h<l-1&&f==W[h+1]&&f&24?u=W[h]=f:W[h]=256;else if(u==64){let d=h+1;for(;d<l&&W[d]==64;)d++;let p=h&&f==8||d<e&&W[d]==8?c==1?1:8:256;for(let g=h;g<d;g++)W[g]=p;h=d-1}else u==8&&c==1&&(W[h]=1);f=u,u&7&&(c=u)}}}function Nh(n,t,e,i,s){let r=s==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:t,f=o<i.length?i[o].from:e;for(let c=h,u,d,p;c<f;c++)if(d=pn[u=n.charCodeAt(c)])if(d<0){for(let g=l-3;g>=0;g-=3)if(Pt[g+1]==-d){let m=Pt[g+2],b=m&2?s:m&4?m&1?r:s:0;b&&(W[c]=W[Pt[g]]=b),l=g;break}}else{if(Pt.length==189)break;Pt[l++]=c,Pt[l++]=u,Pt[l++]=a}else if((p=W[c])==2||p==1){let g=p==s;a=g?0:1;for(let m=l-3;m>=0;m-=3){let b=Pt[m+2];if(b&2)break;if(g)Pt[m+2]|=2;else{if(b&4)break;Pt[m+2]|=4}}}}}function Fh(n,t,e,i){for(let s=0,r=i;s<=e.length;s++){let o=s?e[s-1].to:n,l=s<e.length?e[s].from:t;for(let a=o;a<l;){let h=W[a];if(h==256){let f=a+1;for(;;)if(f==l){if(s==e.length)break;f=e[s++].to,l=s<e.length?e[s].from:t}else if(W[f]==256)f++;else break;let c=r==1,u=(f<t?W[f]:i)==1,d=c==u?c?1:2:i;for(let p=f,g=s,m=g?e[g-1].to:n;p>a;)p==m&&(p=e[--g].from,m=g?e[g-1].to:n),W[--p]=d;a=f}else r=h,a++}}}function gn(n,t,e,i,s,r,o){let l=i%2?2:1;if(i%2==s%2)for(let a=t,h=0;a<e;){let f=!0,c=!1;if(h==r.length||a<r[h].from){let g=W[a];g!=l&&(f=!1,c=g==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;t:for(;;)if(h<r.length&&p==r[h].from){if(c)break t;let g=r[h];if(!f)for(let m=g.to,b=h+1;;){if(m==e)break t;if(b<r.length&&r[b].from==m)m=r[b++].to;else{if(W[m]==l)break t;break}}if(h++,u)u.push(g);else{g.from>a&&o.push(new Ft(a,g.from,d));let m=g.direction==me!=!(d%2);mn(n,m?i+1:i,s,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==e||(f?W[p]!=l:W[p]==l))break;p++}u?gn(n,a,p,i+1,s,u,o):a<p&&o.push(new Ft(a,p,d)),a=p}else for(let a=e,h=r.length;a>t;){let f=!0,c=!1;if(!h||a>r[h-1].to){let g=W[a-1];g!=l&&(f=!1,c=g==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;t:for(;;)if(h&&p==r[h-1].to){if(c)break t;let g=r[--h];if(!f)for(let m=g.from,b=h;;){if(m==t)break t;if(b&&r[b-1].to==m)m=r[--b].from;else{if(W[m-1]==l)break t;break}}if(u)u.push(g);else{g.to<a&&o.push(new Ft(g.to,a,d));let m=g.direction==me!=!(d%2);mn(n,m?i+1:i,s,g.inner,g.from,g.to,o),a=g.from}p=g.from}else{if(p==t||(f?W[p-1]!=l:W[p-1]==l))break;p--}u?gn(n,p,a,i+1,s,u,o):p<a&&o.push(new Ft(p,a,d)),a=p}}function mn(n,t,e,i,s,r,o){let l=t%2?2:1;Eh(n,s,r,i,l),Nh(n,s,r,i,l),Fh(s,r,i,l),gn(n,s,r,t,e,i,o)}function Wh(n,t,e){if(!n)return[new Ft(0,0,t==Kn?1:0)];if(t==me&&!e.length&&!Rh.test(n))return Sl(n.length);if(e.length)for(;n.length>W.length;)W[W.length]=256;let i=[],s=t==me?0:1;return mn(n,s,s,e,0,n.length,i),i}function Sl(n){return[new Ft(0,n,0)]}let Cl="";function Vh(n,t,e,i,s){var r;let o=i.head-n.from,l=Ft.find(t,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=t[l],h=a.side(s,e);if(o==h){let u=l+=s?1:-1;if(u<0||u>=t.length)return null;a=t[l=u],o=a.side(!s,e),h=a.side(s,e)}let f=st(n.text,o,a.forward(s,e));(f<a.from||f>a.to)&&(f=h),Cl=n.text.slice(Math.min(o,f),Math.max(o,f));let c=l==(s?t.length-1:0)?null:t[l+(s?1:-1)];return c&&f==h&&c.level+(s?0:1)<a.level?w.cursor(c.side(!s,e)+n.from,c.forward(s,e)?1:-1,c.level):w.cursor(f+n.from,a.forward(s,e)?-1:1,a.level)}function Hh(n,t,e){for(let i=t;i<e;i++){let s=kl(n.charCodeAt(i));if(s==1)return me;if(s==2||s==4)return Kn}return me}const Al=B.define(),Ml=B.define(),Tl=B.define(),Bl=B.define(),bn=B.define(),Ol=B.define(),Dl=B.define(),$n=B.define(),qn=B.define(),Pl=B.define({combine:n=>n.some(t=>t)}),zh=B.define({combine:n=>n.some(t=>t)}),Il=B.define();class Oe{constructor(t,e="nearest",i="nearest",s=5,r=5,o=!1){this.range=t,this.y=e,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(t){return t.empty?this:new Oe(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new Oe(w.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Bi=z.define({map:(n,t)=>n.map(t)}),Ll=z.define();function gt(n,t,e){let i=n.facet(Bl);i.length?i[0](t):window.onerror&&window.onerror(String(t),e,void 0,void 0,t)||(e?console.error(e+":",t):console.error(t))}const Kt=B.define({combine:n=>n.length?n[0]:!0});let Kh=0;const ve=B.define({combine(n){return n.filter((t,e)=>{for(let i=0;i<e;i++)if(n[i].plugin==t.plugin)return!1;return!0})}});class Vt{constructor(t,e,i,s,r){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=s,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(ve.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(ve.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:s,provide:r,decorations:o}=e||{};return new Vt(Kh++,t,i,s,l=>{let a=[];return o&&a.push(bs.of(h=>{let f=h.plugin(l);return f?o(f):K.none})),r&&a.push(r(l)),a})}static fromClass(t,e){return Vt.define((i,s)=>new t(i,s),e)}}class Ds{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}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(i){if(gt(e.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){gt(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(i){gt(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Rl=B.define(),jn=B.define(),bs=B.define(),El=B.define(),Un=B.define(),xi=B.define(),Nl=B.define();function Pr(n,t){let e=n.state.facet(Nl);if(!e.length)return e;let i=e.map(r=>r instanceof Function?r(n):r),s=[];return N.spans(i,t.from,t.to,{point(){},span(r,o,l,a){let h=r-t.from,f=o-t.from,c=s;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=Hh(t.text,h,f)),a>0&&c.length&&(p=c[c.length-1]).to==h&&p.direction==d)p.to=f,c=p.inner;else{let g={from:h,to:f,direction:d,inner:[]};c.push(g),c=g.inner}}}}),s}const Fl=B.define();function Gn(n){let t=0,e=0,i=0,s=0;for(let r of n.state.facet(Fl)){let o=r(n);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(e=Math.max(e,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:t,right:e,top:i,bottom:s}}const Je=B.define();class yt{constructor(t,e,i,s){this.fromA=t,this.toA=e,this.fromB=i,this.toB=s}join(t){return new yt(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(e.length==0)return t;let i=[];for(let s=0,r=0,o=0;;){let l=s<t.length?t[s].fromB:1e9,a=r<e.length?e[r]:1e9,h=Math.min(l,a);if(h==1e9)break;let f=h+o,c=h,u=f;for(;;)if(r<e.length&&e[r]<=c){let d=e[r+1];r+=2,c=Math.max(c,d);for(let p=s;p<t.length&&t[p].fromB<=c;p++)o=t[p].toA-t[p].toB;u=Math.max(u,d+o)}else if(s<t.length&&t[s].fromB<=c){let d=t[s++];c=Math.max(c,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new yt(f,u,h,c))}return i}}class Zi{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=J.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new yt(r,o,l,a))),this.changedRanges=s}static create(t,e,i){return new Zi(t,e,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const $h=[];class _{constructor(t,e,i=0){this.dom=t,this.length=e,this.flags=i,this.parent=null,t.cmTile=this}get breakAfter(){return this.flags&1}get children(){return $h}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(t){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&Ch(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(t){this.dom=t,t.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t,e=this.posAtStart){let i=e;for(let s of this.children){if(s==t)return i;i+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}covers(t){return!0}coordsIn(t,e){return null}domPosFor(t,e){let i=se(this.dom),s=this.length?t>0:e>0;return new At(this.parent.dom,i+(s?1:0),t==0||t==this.length)}markDirty(t){this.flags&=-3,t&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let t=this;t;t=t.parent)if(t instanceof xs)return t;return null}static get(t){return t.cmTile}}class ys extends _{constructor(t){super(t,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(t){this.children.push(t),t.parent=this}sync(t){if(this.flags&2)return;super.sync(t);let e=this.dom,i=null,s,r=(t==null?void 0:t.node)==e?t:null,o=0;for(let l of this.children){if(l.sync(t),o+=l.length+l.breakAfter,s=i?i.nextSibling:e.firstChild,r&&s!=l.dom&&(r.written=!0),l.dom.parentNode==e)for(;s&&s!=l.dom;)s=Ir(s);else e.insertBefore(l.dom,s);i=l.dom}for(s=i?i.nextSibling:e.firstChild,r&&s&&(r.written=!0);s;)s=Ir(s);this.length=o}}function Ir(n){let t=n.nextSibling;return n.parentNode.removeChild(n),t}class xs extends ys{constructor(t,e){super(e),this.view=t}owns(t){for(;t;t=t.parent)if(t==this)return!0;return!1}isBlock(){return!0}nearest(t){for(;;){if(!t)return null;let e=_.get(t);if(e&&this.owns(e))return e;t=t.parentNode}}blockTiles(t){for(let e=[],i=this,s=0,r=0;;)if(s==i.children.length){if(!e.length)return;i=i.parent,i.breakAfter&&r++,s=e.pop()}else{let o=i.children[s++];if(o instanceof jt)e.push(s),i=o,s=0;else{let l=r+o.length,a=t(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(t,e){let i,s=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(t>=a&&t<=h){if(l.isWidget()&&e>=-1&&e<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<t||t==h&&(e<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,s=t-a),(h>t||t==a&&(e>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=t-a)}}),!i&&!r)throw new Error("No tile at position "+t);return i&&e<0||!r?{tile:i,offset:s}:{tile:r,offset:o}}}class jt extends ys{constructor(t,e){super(t),this.wrapper=e}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,e){let i=new jt(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class Re extends ys{constructor(t,e){super(t),this.attrs=e}isLine(){return!0}static start(t,e,i){let s=new Re(e||document.createElement("div"),t);return(!e||!i)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(t,e,i){let s=null,r=-1,o=null,l=-1;function a(f,c){for(let u=0,d=0;u<f.children.length&&d<=c;u++){let p=f.children[u],g=d+p.length;g>=c&&(p.isComposite()?a(p,c-d):(!o||o.isHidden&&(e>0||i&&jh(o,p)))&&(g>c||p.flags&32)?(o=p,l=c-d):(d<c||p.flags&16&&!p.isHidden)&&(s=p,r=c-d)),d=g}}a(this,t);let h=(e<0?s:o)||s||o;return h?{tile:h,offset:h==s?r:l}:null}coordsIn(t,e){let i=this.resolveInline(t,e,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),e):qh(this)}domIn(t,e){let i=this.resolveInline(t,e);if(i){let{tile:s,offset:r}=i;if(this.dom.contains(s.dom))return s.isText()?new At(s.dom,Math.min(s.dom.nodeValue.length,r)):s.domPosFor(r,s.flags&16?1:s.flags&32?-1:e);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new At(a.dom,0);a==i.tile&&(l=!0)}}return new At(this.dom,0)}}function qh(n){let t=n.dom.lastChild;if(!t)return n.dom.getBoundingClientRect();let e=ii(t);return e[e.length-1]||null}function jh(n,t){let e=n.coordsIn(0,1),i=t.coordsIn(0,1);return e&&i&&i.top<e.bottom}class ct extends ys{constructor(t,e){super(t),this.mark=e}get domAttrs(){return this.mark.attrs}static of(t,e){let i=new ct(e||document.createElement(t.tagName),t);return e||(i.flags|=4),i}}class de extends _{constructor(t,e){super(t,e.length),this.text=e}sync(t){this.flags&2||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,e){let i=this.dom.nodeValue.length;t>i&&(t=i);let s=t,r=t,o=0;t==0&&e<0||t==i&&e>=0?S.chrome||S.gecko||(t?(s--,o=1):r<i&&(r++,o=-1)):e<0?s--:r<i&&r++;let l=ui(this.dom,s,r).getClientRects();if(!l.length)return null;let a=l[(o?o<0:e>=0)?0:l.length-1];return S.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?ci(a,o<0):a||null}static of(t,e){let i=new de(e||document.createTextNode(t),t);return e||(i.flags|=2),i}}class be extends _{constructor(t,e,i,s){super(t,e,s),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,e){return this.coordsInWidget(t,e,!1)}coordsInWidget(t,e,i){let s=this.widget.coordsAt(this.dom,t,e);if(s)return s;if(i)return ci(this.dom.getBoundingClientRect(),this.length?t==0:e<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:t>0;for(let a=l?r.length-1:0;o=r[a],!(t>0?a==0:a==r.length-1||o.top<o.bottom);a+=l?-1:1);return ci(o,!l)}}get overrideDOMText(){if(!this.length)return L.empty;let{root:t}=this;if(!t)return L.empty;let e=this.posAtStart;return t.view.state.doc.slice(e,e+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,e,i,s,r){return r||(r=t.toDOM(e),t.editable||(r.contentEditable="false")),new be(r,i,t,s)}}class ts extends _{constructor(t){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),super(e,0,t)}get isHidden(){return!0}get overrideDOMText(){return L.empty}coordsIn(t){return this.dom.getBoundingClientRect()}}class Uh{constructor(t){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=t}advance(t,e,i){let{tile:s,index:r,beforeBreak:o,parents:l}=this;for(;t||e>0;)if(s.isComposite())if(o){if(!t)break;i&&i.break(),t--,o=!1}else if(r==s.children.length){if(!t&&!l.length)break;i&&i.leave(s),o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++}else{let a=s.children[r],h=a.breakAfter;(e>0?a.length<=t:a.length<t)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,r++,t-=a.length):(l.push({tile:s,index:r}),s=a,r=0,i&&a.isComposite()&&i.enter(a))}else if(r==s.length)o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++;else if(t){let a=Math.min(t,s.length-r);i&&i.skip(s,r,r+a),t-=a,r+=a}else break;return this.tile=s,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Gh{constructor(t,e,i,s){this.from=t,this.to=e,this.wrapper=i,this.rank=s}}class _h{constructor(t,e,i){this.cache=t,this.root=e,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(t,e,i,s){var r;this.flushBuffer();let o=this.ensureMarks(e,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+t.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new de(l.dom,l.text+t);a.parent=o}else o.append(s||de.of(t,(r=this.cache.find(de))===null||r===void 0?void 0:r.dom));this.pos+=t.length,this.afterWidget=null}addComposition(t,e){let i=this.curLine;i.dom!=e.line.dom&&(i.setDOM(this.cache.reused.has(e.line)?Ps(e.line.dom):e.line.dom),this.cache.reused.set(e.line,2));let s=i;for(let l=e.marks.length-1;l>=0;l--){let a=e.marks[l],h=s.lastChild;if(h instanceof ct&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(Ps(a.dom)),s=h;else{if(this.cache.reused.get(a)){let c=_.get(a.dom);c&&c.setDOM(Ps(a.dom))}let f=ct.of(a.mark,a.dom);s.append(f),s=f}this.cache.reused.set(a,2)}let r=_.get(t.text);r&&this.cache.reused.set(r,2);let o=new de(t.text,t.text.nodeValue);o.flags|=8,s.append(o)}addInlineWidget(t,e,i){let s=this.afterWidget&&t.flags&48&&(this.afterWidget.flags&48)==(t.flags&48);s||this.flushBuffer();let r=this.ensureMarks(e,i);!s&&!(t.flags&16)&&r.append(this.getBuffer(1)),r.append(t),this.pos+=t.length,this.afterWidget=t}addMark(t,e,i){this.flushBuffer(),this.ensureMarks(e,i).append(t),this.pos+=t.length,this.afterWidget=null}addBlockWidget(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}continueWidget(t){let e=this.afterWidget||this.lastBlock;e.length+=t,this.pos+=t}addLineStart(t,e){var i;t||(t=Wl);let s=Re.start(t,e||((i=this.cache.find(Re))===null||i===void 0?void 0:i.dom),!!e);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(t){this.getBlockPos().append(t),this.pos+=t.length,this.lastBlock=t,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(t){this.blockPosCovered()||this.addLineStart(t)}ensureLine(t){this.curLine||this.addLineStart(t)}ensureMarks(t,e){var i;let s=this.curLine;for(let r=t.length-1;r>=0;r--){let o=t[r],l;if(e>0&&(l=s.lastChild)&&l instanceof ct&&l.mark.eq(o))s=l,e--;else{let a=ct.of(o,(i=this.cache.find(ct,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);s.append(a),s=a,e=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let t=this.curLine.lastChild;(!t||!Lr(this.curLine,!1)||t.dom.nodeName!="BR"&&t.isWidget()&&!(S.ios&&Lr(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Is,0,32)||new be(Is.toDOM(),0,Is,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let t=this.wrappers.length-1;t>=0;t--)this.wrappers[t].to<this.pos&&this.wrappers.splice(t,1);for(let t=this.blockWrappers;t.value&&t.from<=this.pos;t.next())if(t.to>=this.pos){let e=new Gh(t.from,t.to,t.value,t.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-e.rank||this.wrappers[i-1].to-e.to)<0;)i--;this.wrappers.splice(i,0,e)}this.wrapperPos=this.pos}getBlockPos(){var t;this.updateBlockWrappers();let e=this.root;for(let i of this.wrappers){let s=e.lastChild;if(i.from<this.pos&&s instanceof jt&&s.wrapper.eq(i.wrapper))e=s;else{let r=jt.of(i.wrapper,(t=this.cache.find(jt,o=>o.wrapper.eq(i.wrapper)))===null||t===void 0?void 0:t.dom);e.append(r),e=r}}return e}blockPosCovered(){let t=this.lastBlock;return t!=null&&!t.breakAfter&&(!t.isWidget()||(t.flags&160)>0)}getBuffer(t){let e=2|(t<0?16:32),i=this.cache.find(ts,void 0,1);return i&&(i.flags=e),i||new ts(e)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Yh{constructor(t){this.skipCount=0,this.text="",this.textOff=0,this.cursor=t.iter()}skip(t){this.textOff+t<=this.text.length?this.textOff+=t:(this.skipCount+=t-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(t){if(this.textOff==this.text.length){let{value:s,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let l=this.textOff=Math.min(t,s.length);return r?null:s.slice(0,l)}let e=Math.min(this.text.length,this.textOff+t),i=this.text.slice(this.textOff,e);return this.textOff=e,i}}const es=[be,Re,de,ct,ts,jt,xs];for(let n=0;n<es.length;n++)es[n].bucket=n;class Jh{constructor(t){this.view=t,this.buckets=es.map(()=>[]),this.index=es.map(()=>0),this.reused=new Map}add(t){let e=t.constructor.bucket,i=this.buckets[e];i.length<6?i.push(t):i[this.index[e]=(this.index[e]+1)%6]=t}find(t,e,i=2){let s=t.bucket,r=this.buckets[s],o=this.index[s];for(let l=r.length-1;l>=0;l--){let a=(l+o)%r.length,h=r[a];if((!e||e(h))&&!this.reused.has(h))return r.splice(a,1),a<o&&this.index[s]--,this.reused.set(h,i),h}return null}findWidget(t,e,i){let s=this.buckets[0];if(s.length)for(let r=0,o=0;;r++){if(r==s.length){if(o)return null;o=1,r=0}let l=s[r];if(!this.reused.has(l)&&(o==0?l.widget.compare(t):l.widget.constructor==t.constructor&&t.updateDOM(l.dom,this.view)))return s.splice(r,1),r<this.index[0]&&this.index[0]--,l.widget==t&&l.length==e&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new be(l.dom,e,t,l.flags&-498|i))}}reuse(t){return this.reused.set(t,1),t}maybeReuse(t,e=2){if(!this.reused.has(t))return this.reused.set(t,e),t.dom}clear(){for(let t=0;t<this.buckets.length;t++)this.buckets[t].length=this.index[t]=0}}class Xh{constructor(t,e,i,s,r){this.view=t,this.decorations=s,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new Jh(t),this.text=new Yh(t.state.doc),this.builder=new _h(this.cache,new xs(t,t.contentDOM),N.iter(i)),this.cache.reused.set(e,2),this.old=new Uh(e),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(t,e){let i=e&&this.getCompositionContext(e.text);for(let s=0,r=0,o=0;;){let l=o<t.length?t[o++]:null,a=l?l.fromA:this.old.root.length;if(a>s){let h=a-s;this.preserve(h,!o,!l),s=a,r+=h}if(!l)break;e&&l.fromA<=e.range.fromA&&l.toA>=e.range.toA?(this.forward(l.fromA,e.range.fromA,e.range.fromA<e.range.toA?1:-1),this.emit(r,e.range.fromB),this.cache.clear(),this.builder.addComposition(e,i),this.text.skip(e.range.toB-e.range.fromB),this.forward(e.range.fromA,l.toA),this.emit(e.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(r,l.toB)),r=l.toB,s=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(t,e,i){let s=tf(this.old),r=this.openMarks;this.old.advance(t,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?be.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,s,r),r=s.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,s,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),s,r)),r=s.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof ts)this.cache.add(o);else if(o instanceof ct)this.builder.ensureLine(null),this.builder.addMark(o,s,r),this.cache.reused.set(o,1),r=s.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ct&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=r=0):o instanceof ct&&(s.shift(),r=Math.min(r,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(t)}emit(t,e){let i=null,s=this.builder,r=0,o=N.spans(this.decorations,t,e,{point:(l,a,h,f,c,u)=>{if(h instanceof ge){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=f.length,c>f.length)s.continueWidget(a-l);else{let d=h.widget||(h.block?Ee.block:Ee.inline),p=Qh(h),g=this.cache.findWidget(d,a-l,p)||be.of(d,this.view,a-l,p);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(i),s.addBlockWidget(g)):(s.ensureLine(i),s.addInlineWidget(g,f,c))}i=null}else i=Zh(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,f)=>{for(let c=l;c<a;){let u=this.text.next(Math.min(512,a-c));u==null?(s.addLineStartIfNotCovered(i),s.addBreak(),c++):(s.ensureLine(i),s.addText(u,h,c==l?f:h.length),c+=u.length),i=null}}});s.addLineStartIfNotCovered(i),this.openWidget=o>r,this.openMarks=o}forward(t,e,i=1){e-t<=10?this.old.advance(e-t,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(e-t-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(t){let e=[],i=null;for(let s=t.parentNode;;s=s.parentNode){let r=_.get(s);if(s==this.view.contentDOM)break;r instanceof ct?e.push(r):r!=null&&r.isLine()?i=r:r instanceof jt||(s.nodeName=="DIV"&&!i&&s!=this.view.contentDOM?i=new Re(s,Wl):i||e.push(ct.of(new bi({tagName:s.nodeName.toLowerCase(),attributes:Ah(s)}),s)))}return{line:i,marks:e}}}function Lr(n,t){let e=i=>{for(let s of i.children)if((t?s.isText():s.length)||e(s))return!0;return!1};return e(n)}function Qh(n){let t=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(t|=256),t}const Wl={class:"cm-line"};function Zh(n,t){let e=t.spec.attributes,i=t.spec.class;return!e&&!i||(n||(n={class:"cm-line"}),e&&Hn(e,n),i&&(n.class+=" "+i)),n}function tf(n){let t=[];for(let e=n.parents.length;e>1;e--){let i=e==n.parents.length?n.tile:n.parents[e].tile;i instanceof ct&&t.push(i.mark)}return t}function Ps(n){let t=_.get(n);return t&&t.setDOM(n.cloneNode()),n}class Ee extends ze{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}}Ee.inline=new Ee("span");Ee.block=new Ee("div");const Is=new class extends ze{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Rr{constructor(t){this.view=t,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=K.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new xs(t,t.contentDOM),this.updateInner([new yt(0,0,0,t.state.doc.length)],null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:f,toA:c})=>c<this.minWidthFrom||f>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.updateEditContextFormatting(t);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((e=this.domChanged)===null||e===void 0)&&e.newSel?s=this.domChanged.newSel.head:!ff(t.changes,this.hasComposition)&&!t.selectionSet&&(s=t.state.selection.main.head));let r=s>-1?sf(this.view,t.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:f,to:c}=this.hasComposition;i=new yt(f,c,t.changes.mapPos(f,-1),t.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(S.ie||S.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=of(o,this.decorations,t.changes);a.length&&(i=yt.extendWithRanges(i,a));let h=af(l,this.blockWrappers,t.changes);return h.length&&(i=yt.extendWithRanges(i,h)),r&&!i.some(f=>f.fromA<=r.range.fromA&&f.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(e||t.length){let o=this.tile,l=new Xh(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);e&&_.get(e.text)&&l.cache.reused.set(_.get(e.text),2),this.tile=l.run(t,e),yn(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=S.chrome||S.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof Ls&&s.push(r.dom);i.updateGaps(s)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let i of e.effects)i.is(Ll)&&(this.editContextFormatting=i.value)}updateSelection(t=!1,e=!1){(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,s=this.view.root.activeElement,r=s==i,o=!r&&!(this.view.state.facet(Kt)||i.tabIndex>-1)&&ei(i,this.view.observer.selectionRange)&&!(s&&i.contains(s));if(!(r||e||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,f;if(a.empty?f=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(f=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),S.gecko&&a.empty&&!this.hasComposition&&ef(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=f=new At(u,0),l=!0}let c=this.view.observer.selectionRange;(l||!c.focusNode||(!si(h.node,h.offset,c.anchorNode,c.anchorOffset)||!si(f.node,f.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,a))&&(this.view.observer.ignore(()=>{S.android&&S.chrome&&i.contains(c.focusNode)&&hf(c.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=fi(this.view.root);if(u)if(a.empty){if(S.gecko){let d=nf(h.node,h.offset);if(d&&d!=3){let p=(d==1?yl:xl)(h.node,h.offset);p&&(h=new At(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(f.node,f.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,f]=[f,h]),d.setEnd(f.node,f.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,f)),this.impreciseAnchor=h.precise?null:new At(c.anchorNode,c.anchorOffset),this.impreciseHead=f.precise?null:new At(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&si(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=fi(t.root),{anchorNode:s,anchorOffset:r}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let o=this.lineAt(e.head,e.assoc);if(!o)return;let l=o.posAtStart;if(e.head==l||e.head==l+o.length)return;let a=this.coordsAt(e.head,-1),h=this.coordsAt(e.head,1);if(!a||!h||a.bottom>h.top)return;let f=this.domAtPos(e.head+e.assoc,e.assoc);i.collapse(f.node,f.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(s,r)}posFromDOM(t,e){let i=this.tile.nearest(t);if(!i)return this.tile.dom.compareDocumentPosition(t)&2?0:this.view.state.doc.length;let s=i.posAtStart;if(i.isComposite()){let r;if(t==i.dom)r=i.dom.childNodes[e];else{let o=Gt(t)==0?0:e==0?-1:1;for(;;){let l=t.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(t==l.firstChild?o=-1:o=1),t=l}o<0?r=t:r=t.nextSibling}if(r==i.dom.firstChild)return s;for(;r&&!_.get(r);)r=r.nextSibling;if(!r)return s+i.length;for(let o=0,l=s;;o++){let a=i.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return i.isText()?t==i.dom?s+e:s+(e?i.length:0):s}domAtPos(t,e){let{tile:i,offset:s}=this.tile.resolveBlock(t,e);return i.isWidget()?i.domPosFor(t,e):i.domIn(s,e)}inlineDOMNearPos(t,e){let i,s=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,f)=>{if(h.isWidget()){if(h.flags&32&&f>=t)return!0;h.flags&16&&(r=!0)}else{let c=f+h.length;if(f<=t&&(i=h,s=t-f,r=c<t),c>=t&&!o&&(o=h,l=t-f,a=f>t),f>t&&o)return!0}}),!i&&!o?this.domAtPos(t,e):(r&&o?i=null:a&&i&&(o=null),i&&e<0||!o?i.domIn(s,e):o.domIn(l,e))}coordsAt(t,e){let{tile:i,offset:s}=this.tile.resolveBlock(t,e);return i.isWidget()?i.widget instanceof Ls?null:i.coordsInWidget(s,e,!0):i.coordsIn(s,e)}lineAt(t,e){let{tile:i}=this.tile.resolveBlock(t,e);return i.isLine()?i:null}coordsForChar(t){let{tile:e,offset:i}=this.tile.resolveBlock(t,1);if(!e.isLine())return null;function s(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=s(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&o<r.length){let l=st(r.text,o);if(l==o)return null;let a=ui(r.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let f=a[h];if(h==a.length-1||f.top<f.bottom&&f.left<f.right)return f}}return null}return s(e,i)}measureVisibleLineHeights(t){let e=[],{from:i,to:s}=t,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==G.LTR,h=0,f=(c,u,d)=>{for(let p=0;p<c.children.length&&!(u>s);p++){let g=c.children[p],m=u+g.length,b=g.dom.getBoundingClientRect(),{height:x}=b;if(d&&!p&&(h+=b.top-d.top),g instanceof jt)m>i&&f(g,u,b);else if(u>=i&&(h>0&&e.push(-h),e.push(x+h),h=0,o)){let v=g.dom.lastChild,T=v?ii(v):[];if(T.length){let C=T[T.length-1],M=a?C.right-b.left:b.right-C.left;M>l&&(l=M,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=m)}}d&&p==c.children.length-1&&(h+=d.bottom-b.bottom),u=m+g.breakAfter}};return f(this.tile,0,null),e}textDirectionAt(t){let{tile:e}=this.tile.resolveBlock(t,1);return getComputedStyle(e.dom).direction=="rtl"?G.RTL:G.LTR}measureTextSize(){let t=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let f=ii(h.dom);if(f.length!=1)return;l+=f[0].width,a=f[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(t)return t;let e=document.createElement("div"),i,s,r;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(e);let o=ii(e.firstChild)[0];i=e.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,e.remove()}),{lineHeight:i,charWidth:s,textHeight:r}}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,s=0;;s++){let r=s==e.viewports.length?null:e.viewports[s],o=r?r.from-1:this.view.state.doc.length;if(o>i){let l=(e.lineBlockAt(o).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(K.replace({widget:new Ls(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return K.set(t)}updateDeco(){let t=1,e=this.view.state.facet(bs).map(r=>(this.dynamicDecorationMap[t++]=typeof r=="function")?r(this.view):r),i=!1,s=this.view.state.facet(Un).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[t++]=i,e.push(N.join(s))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;this.blockWrappers=this.view.state.facet(El).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(t){if(t.isSnapshot){let h=this.view.viewState.lineBlockAt(t.range.head);this.view.scrollDOM.scrollTop=h.top-t.yMargin,this.view.scrollDOM.scrollLeft=t.xMargin;return}for(let h of this.view.state.facet(Il))try{if(h(this.view,t.range,t))return!0}catch(f){gt(this.view.state,f,"scroll handler")}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 r=Gn(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(Bh(this.view.scrollDOM,o,e.head<e.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,l),-l),Math.max(Math.min(t.yMargin,a),-a),this.view.textDirection==G.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(e.head,1);h&&h.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(t){let e=i=>i.isWidget()||i.children.some(e);return e(this.tile.resolveBlock(t,1).tile)}destroy(){yn(this.tile)}}function yn(n,t){let e=t==null?void 0:t.get(n);if(e!=1){e==null&&n.destroy();for(let i of n.children)yn(i,t)}}function ef(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function Vl(n,t){let e=n.observer.selectionRange;if(!e.focusNode)return null;let i=yl(e.focusNode,e.focusOffset),s=xl(e.focusNode,e.focusOffset),r=i||s;if(s&&i&&s.node!=i.node){let l=_.get(s.node);if(!l||l.isText()&&l.text!=s.node.nodeValue)r=s;else if(n.docView.lastCompositionAfterCursor){let a=_.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(r=s)}}if(n.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=t-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function sf(n,t,e){let i=Vl(n,e);if(!i)return null;let{node:s,from:r,to:o}=i,l=s.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=t.invertedDesc;return{range:new yt(a.mapPos(r),a.mapPos(o),r,o),text:s}}function nf(n,t){return n.nodeType!=1?0:(t&&n.childNodes[t-1].contentEditable=="false"?1:0)|(t<n.childNodes.length&&n.childNodes[t].contentEditable=="false"?2:0)}let rf=class{constructor(){this.changes=[]}compareRange(t,e){Te(t,e,this.changes)}comparePoint(t,e){Te(t,e,this.changes)}boundChange(t){Te(t,t,this.changes)}};function of(n,t,e){let i=new rf;return N.compare(n,t,e,i),i.changes}class lf{constructor(){this.changes=[]}compareRange(t,e){Te(t,e,this.changes)}comparePoint(){}boundChange(t){Te(t,t,this.changes)}}function af(n,t,e){let i=new lf;return N.compare(n,t,e,i),i.changes}function hf(n,t){for(let e=n;e&&e!=t;e=e.assignedSlot||e.parentNode)if(e.nodeType==1&&e.contentEditable=="false")return!0;return!1}function ff(n,t){let e=!1;return t&&n.iterChangedRanges((i,s)=>{i<t.to&&s>t.from&&(e=!0)}),e}class Ls extends ze{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function cf(n,t,e=1){let i=n.charCategorizer(t),s=n.doc.lineAt(t),r=t-s.from;if(s.length==0)return w.cursor(t);r==0?e=1:r==s.length&&(e=-1);let o=r,l=r;e<0?o=st(s.text,r,!1):l=st(s.text,r);let a=i(s.text.slice(o,l));for(;o>0;){let h=st(s.text,o,!1);if(i(s.text.slice(h,o))!=a)break;o=h}for(;l<s.length;){let h=st(s.text,l);if(i(s.text.slice(l,h))!=a)break;l=h}return w.range(o+s.from,l+s.from)}function uf(n,t,e,i,s){let r=Math.round((i-t.left)*n.defaultCharacterWidth);if(n.lineWrapping&&e.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((s-e.top-(n.defaultLineHeight-l)*.5)/l);r+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(e.from,e.to);return e.from+yh(o,r,n.state.tabSize)}function df(n,t,e){let i=n.lineBlockAt(t);if(Array.isArray(i.type)){let s;for(let r of i.type){if(r.from>t)break;if(!(r.to<t)){if(r.from<t&&r.to>t)return r;(!s||r.type==kt.Text&&(s.type!=r.type||(e<0?r.from<t:r.to>t)))&&(s=r)}}return s||i}return i}function pf(n,t,e,i){let s=df(n,t.head,t.assoc||-1),r=!i||s.type!=kt.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(t.assoc<0&&t.head>s.from?t.head-1:t.head);if(r){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(s.from),a=n.posAtCoords({x:e==(l==G.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return w.cursor(a,e?-1:1)}return w.cursor(e?s.to:s.from,e?-1:1)}function Er(n,t,e,i){let s=n.state.doc.lineAt(t.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let l=t,a=null;;){let h=Vh(s,r,o,l,e),f=Cl;if(!h){if(s.number==(e?n.state.doc.lines:1))return l;f=`
|
|
8
8
|
`,s=n.state.doc.line(s.number+(e?1:-1)),r=n.bidiSpans(s),h=n.visualLineSide(s,!e)}if(a){if(!a(f))return l}else{if(!i)return h;a=i(f)}l=h}}function gf(n,t,e){let i=n.state.charCategorizer(t),s=i(e);return r=>{let o=i(r);return s==$t.Space&&(s=o),s==o}}function mf(n,t,e,i){let s=t.head,r=e?1:-1;if(s==(e?n.state.doc.length:0))return w.cursor(s,t.assoc);let o=t.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(s,(t.empty?t.assoc:0)||(e?1:-1)),f=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-p.from))),l=(r<0?p.top:p.bottom)+f}let c=a.left+o,u=i??n.viewState.heightOracle.textHeight>>1,d=xn(n,{x:c,y:l+u*r},!1,r);return w.cursor(d.pos,d.assoc,void 0,o)}function ni(n,t,e){for(;;){let i=0;for(let s of n)s.between(t-1,t+1,(r,o,l)=>{if(t>r&&t<o){let a=i||e||(t-r<o-t?-1:1);t=a<0?r:o,i=a}});if(!i)return t}}function Hl(n,t){let e=null;for(let i=0;i<t.ranges.length;i++){let s=t.ranges[i],r=null;if(s.empty){let o=ni(n,s.from,0);o!=s.from&&(r=w.cursor(o,-1))}else{let o=ni(n,s.from,-1),l=ni(n,s.to,1);(o!=s.from||l!=s.to)&&(r=w.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(e||(e=t.ranges.slice()),e[i]=r)}return e?w.create(e,t.mainIndex):t}function Rs(n,t,e){let i=ni(n.state.facet(xi).map(s=>s(n)),e.from,t.head>e.from?-1:1);return i==e.from?e:w.cursor(i,i<e.from?1:-1)}class Nt{constructor(t,e){this.pos=t,this.assoc=e}}function xn(n,t,e,i){let s=n.contentDOM.getBoundingClientRect(),r=s.top+n.viewState.paddingTop,{x:o,y:l}=t,a=l-r,h;for(;;){if(a<0)return new Nt(0,1);if(a>n.viewState.docHeight)return new Nt(n.state.doc.length,-1);if(h=n.elementAtHeight(a),i==null)break;if(h.type==kt.Text){if(i<0?h.to<n.viewport.from:h.from>n.viewport.to)break;let u=n.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+r:u.bottom>=a+r))break}let c=n.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+c:h.top-c}if(n.viewport.from>=h.to||n.viewport.to<=h.from){if(e)return null;if(h.type==kt.Text){let c=uf(n,s,h,o,l);return new Nt(c,c==h.from?1:-1)}}if(h.type!=kt.Text)return a<(h.top+h.bottom)/2?new Nt(h.from,1):new Nt(h.to,-1);let f=n.docView.lineAt(h.from,2);return(!f||f.length!=h.length)&&(f=n.docView.lineAt(h.from,-2)),new bf(n,o,l,n.textDirectionAt(h.from)).scanTile(f,h.from)}class bf{constructor(t,e,i,s){this.view=t,this.x=e,this.y=i,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(t){return(!this.line||this.line.from>t||this.line.to<t)&&(this.line=this.view.state.doc.lineAt(t),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(t,e){let{line:i,spans:s}=this.bidiSpansAt(t);return s[Ft.find(s,t-i.from,-1,e)].level==this.baseDir}dirAt(t,e){let{line:i,spans:s}=this.bidiSpansAt(t);return s[Ft.find(s,t-i.from,-1,e)].dir}bidiIn(t,e){let{spans:i,line:s}=this.bidiSpansAt(t);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+s.from<e)}scan(t,e){let i=0,s=t.length-1,r=new Set,o=this.bidiIn(t[0],t[s]),l,a,h=-1,f=1e9,c;t:for(;i<s;){let d=s-i,p=i+s>>1;e:if(r.has(p)){let m=i+Math.floor(Math.random()*d);for(let b=0;b<d;b++){if(!r.has(m)){p=m;break e}m++,m==s&&(m=i)}break t}r.add(p);let g=e(p);if(g)for(let m=0;m<g.length;m++){let b=g[m],x=0;if(b.bottom<this.y)(!l||l.bottom<b.bottom)&&(l=b),x=1;else if(b.top>this.y)(!a||a.top>b.top)&&(a=b),x=-1;else{let v=b.left>this.x?this.x-b.left:b.right<this.x?this.x-b.right:0,T=Math.abs(v);T<f&&(h=p,f=T,c=b),v&&(x=v<0==(this.baseDir==G.LTR)?-1:1)}x==-1&&(!o||this.baseDirAt(t[p],1))?s=p:x==1&&(!o||this.baseDirAt(t[p+1],-1))&&(i=p+1)}}if(!c){let d=l&&(!a||this.y-l.bottom<a.top-this.y)?l:a;return this.y=(d.top+d.bottom)/2,this.scan(t,e)}let u=(o?this.dirAt(t[h],1):this.baseDir)==G.LTR;return{i:h,after:this.x>(c.left+c.right)/2==u}}scanText(t,e){let i=[];for(let r=0;r<t.length;r=st(t.text,r))i.push(e+r);i.push(e+t.length);let s=this.scan(i,r=>{let o=i[r]-e,l=i[r+1]-e;return ui(t.dom,o,l).getClientRects()});return s.after?new Nt(i[s.i+1],-1):new Nt(i[s.i],1)}scanTile(t,e){if(!t.length)return new Nt(e,1);if(t.children.length==1){let l=t.children[0];if(l.isText())return this.scanText(l,e);if(l.isComposite())return this.scanTile(l,e)}let i=[e];for(let l=0,a=e;l<t.children.length;l++)i.push(a+=t.children[l].length);let s=this.scan(i,l=>{let a=t.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:ui(a.dom,0,a.length)).getClientRects()}),r=t.children[s.i],o=i[s.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):s.after?new Nt(i[s.i+1],-1):new Nt(o,1)}}const ke="";class yf{constructor(t,e){this.points=t,this.view=e,this.text="",this.lineSeparator=e.state.facet(E.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=ke}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let s=t;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=_.get(s),l=s.nextSibling;if(l==e){o!=null&&o.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=_.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Qi(s))||Qi(l)&&(s.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>r)&&!wf(l,e)&&this.lineBreak(),s=l}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=s.exec(e))&&(r=l.index,o=l[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==t&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(t){let e=_.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&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)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(xf(t,i.node,i.offset)?e:0))}}function xf(n,t,e){for(;;){if(!t||e<Gt(t))return!1;if(t==n)return!0;e=se(t)+1,t=t.parentNode}}function wf(n,t){let e;for(;!(n==t||!n);n=n.nextSibling){let i=_.get(n);if(!(i!=null&&i.isWidget()))return!1;i&&(e||(e=[])).push(i)}if(e)for(let i of e){let s=i.overrideDOMText;if(s!=null&&s.length)return!1}return!0}class Nr{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class kf{constructor(t,e,i,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:r,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=zl(t.docView.tile,e,i,0))){let l=r||o?[]:Sf(t),a=new yf(l,t);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Cf(l,this.bounds.from)}else{let l=t.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!dn(t.contentDOM,l.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!dn(t.contentDOM,l.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(l.anchorNode,l.anchorOffset),f=t.viewport;if((S.ios||S.chrome)&&t.state.selection.main.empty&&a!=h&&(f.from>0||f.to<t.state.doc.length)){let c=Math.min(a,h),u=Math.max(a,h),d=f.from-c,p=f.to-u;(d==0||d==1||c==0)&&(p==0||p==-1||u==t.state.doc.length)&&(a=0,h=t.state.doc.length)}t.inputState.composing>-1&&t.state.selection.ranges.length>1?this.newSel=t.state.selection.replaceRange(w.range(h,a)):this.newSel=w.single(h,a)}}}function zl(n,t,e,i){if(n.isComposite()){let s=-1,r=-1,o=-1,l=-1;for(let a=0,h=i,f=i;a<n.children.length;a++){let c=n.children[a],u=h+c.length;if(h<t&&u>e)return zl(c,t,e,h);if(u>=t&&s==-1&&(s=a,r=h),h>e&&c.dom.parentNode==n.dom){o=a,l=f;break}f=u,h=u+c.breakAfter}return{from:r,to:l<0?i+n.length:l,startDOM:(s?n.children[s-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o<n.children.length&&o>=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function Kl(n,t){let e,{newSel:i}=t,{state:s}=n,r=s.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(t.bounds){let{from:l,to:a}=t.bounds,h=r.from,f=null;(o===8||S.android&&t.text.length<a-l)&&(h=r.to,f="end");let c=s.doc.sliceString(l,a,ke),u,d;!r.empty&&r.from>=l&&r.to<=a&&(t.typeOver||c!=t.text)&&c.slice(0,r.from-l)==t.text.slice(0,r.from-l)&&c.slice(r.to-l)==t.text.slice(u=t.text.length-(c.length-(r.to-l)))?e={from:r.from,to:r.to,insert:L.of(t.text.slice(r.from-l,u).split(ke))}:(d=$l(c,t.text,h-l,f))&&(S.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==ke+ke&&d.toB--,e={from:l+d.from,to:l+d.toA,insert:L.of(t.text.slice(d.from,d.toB).split(ke))})}else i&&(!n.hasFocus&&s.facet(Kt)||is(i,r))&&(i=null);if(!e&&!i)return!1;if((S.mac||S.android)&&e&&e.from==e.to&&e.from==r.head-1&&/^\. ?$/.test(e.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&e.insert.length==2&&(i=w.single(i.main.anchor-1,i.main.head-1)),e={from:e.from,to:e.to,insert:L.of([e.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).to<r.to&&n.docView.lineHasWidget(r.to)&&n.inputState.insertingTextAt>Date.now()-50?e={from:r.from,to:r.to,insert:s.toText(n.inputState.insertingText)}:S.chrome&&e&&e.from==e.to&&e.from==r.head&&e.insert.toString()==`
|
|
9
9
|
`&&n.lineWrapping&&(i&&(i=w.single(i.main.anchor-1,i.main.head-1)),e={from:r.from,to:r.to,insert:L.of([" "])}),e)return _n(n,e,i,o);if(i&&!is(i,r)){let l=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(l=!0),a=n.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=Hl(s.facet(xi).map(h=>h(n)),i))),n.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function _n(n,t,e,i=-1){if(S.ios&&n.inputState.flushIOSKey(t))return!0;let s=n.state.selection.main;if(S.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&n.state.sliceDoc(t.from,s.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&Be(n.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&t.insert.length==0||i==8&&t.insert.length<t.to-t.from&&t.to>s.head)&&Be(n.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&t.insert.length==0&&Be(n.contentDOM,"Delete",46)))return!0;let r=t.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=vf(n,t,e));return n.state.facet(Ol).some(a=>a(n,t.from,t.to,r,l))||n.dispatch(l()),!0}function vf(n,t,e){let i,s=n.state,r=s.selection.main,o=-1;if(t.from==t.to&&t.from<r.from||t.from>r.to){let a=t.from<r.from?-1:1,h=a<0?r.from:r.to,f=ni(s.facet(xi).map(c=>c(n)),h,a);t.from==f&&(o=f)}if(o>-1)i={changes:t,selection:w.cursor(t.from+t.insert.length,-1)};else if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!e||e.main.empty&&e.main.from==t.from+t.insert.length)&&n.inputState.composing<0){let a=r.from<t.from?s.sliceDoc(r.from,t.from):"",h=r.to>t.to?s.sliceDoc(t.to,r.to):"";i=s.replaceSelection(n.state.toText(a+t.insert.sliceString(0,void 0,n.state.lineBreak)+h))}else{let a=s.changes(t),h=e&&e.main.to<=a.newLength?e.main:void 0;if(s.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&t.to<=r.to+10&&t.to>=r.to-10){let f=n.state.sliceDoc(t.from,t.to),c,u=e&&Vl(n,e.main.head);if(u){let p=t.insert.length-(t.to-t.from);c={from:u.from,to:u.to-p}}else c=n.state.doc.lineAt(r.head);let d=r.to-t.to;i=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let g=p.to-d,m=g-f.length;if(n.state.sliceDoc(m,g)!=f||g>=c.from&&m<=c.to)return{range:p};let b=s.changes({from:m,to:g,insert:t.insert}),x=p.to-r.to;return{changes:b,range:h?w.range(Math.max(0,h.anchor+x),Math.max(0,h.head+x)):p.map(b)}})}else i={changes:a,selection:h&&s.selection.replaceRange(h)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:l,scrollIntoView:!0})}function $l(n,t,e,i){let s=Math.min(n.length,t.length),r=0;for(;r<s&&n.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==s&&n.length==t.length)return null;let o=n.length,l=t.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));e-=o+a-r}if(o<r&&n.length<t.length){let a=e<=r&&e>=o?r-e:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=e<=r&&e>=l?r-e:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Sf(n){let t=[];if(n.root.activeElement!=n.contentDOM)return t;let{anchorNode:e,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return e&&(t.push(new Nr(e,i)),(s!=e||r!=i)&&t.push(new Nr(s,r))),t}function Cf(n,t){if(n.length==0)return null;let e=n[0].pos,i=n.length==2?n[1].pos:e;return e>-1&&i>-1?w.single(e+t,i+t):null}function is(n,t){return t.head==n.main.head&&t.anchor==n.main.anchor}class Af{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,S.safari&&t.contentDOM.addEventListener("input",()=>null),S.gecko&&Hf(t.contentDOM.ownerDocument)}handleEvent(t){!Lf(this.view,t)||this.ignoreDuringComposition(t)||t.type=="keydown"&&this.keydown(t)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let s of i.observers)s(this.view,e);for(let s of i.handlers){if(e.defaultPrevented)break;if(s(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=Mf(t),i=this.handlers,s=this.view.contentDOM;for(let r in e)if(r!="scroll"){let o=!e[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!e[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&t.keyCode!=27&&jl.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),S.android&&S.chrome&&!t.synthetic&&(t.keyCode==13||t.keyCode==8))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return S.ios&&!t.synthetic&&!t.altKey&&!t.metaKey&&((e=ql.find(i=>i.keyCode==t.keyCode))&&!t.ctrlKey||Tf.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0):(t.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(t){let e=this.pendingIOSKey;return!e||e.key=="Enter"&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString())?!1:(this.pendingIOSKey=void 0,Be(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0))}ignoreDuringComposition(t){return!/^key/.test(t.type)||t.synthetic?!1:this.composing>0?!0:S.safari&&!S.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Fr(n,t){return(e,i)=>{try{return t.call(n,i,e)}catch(s){gt(e.state,s)}}}function Mf(n){let t=Object.create(null);function e(i){return t[i]||(t[i]={observers:[],handlers:[]})}for(let i of n){let s=i.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&e(l).handlers.push(Fr(i.value,a))}if(o)for(let l in o){let a=o[l];a&&e(l).observers.push(Fr(i.value,a))}}for(let i in Tt)e(i).handlers.push(Tt[i]);for(let i in ut)e(i).observers.push(ut[i]);return t}const ql=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Tf="dthko",jl=[16,17,18,20,91,92,224,225],Oi=6;function Di(n){return Math.max(0,n)*.7+8}function Bf(n,t){return Math.max(Math.abs(n.clientX-t.clientX),Math.abs(n.clientY-t.clientY))}class Of{constructor(t,e,i,s){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=gl(t.contentDOM),this.atoms=t.state.facet(xi).map(o=>o(t));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(E.allowMultipleSelections)&&Df(t,e),this.dragging=If(t,e)&&_l(e)==1?null:!1}start(t){this.dragging===!1&&this.select(t)}move(t){if(t.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Bf(this.startEvent,t)<10)return;this.select(this.lastEvent=t);let e=0,i=0,s=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Gn(this.view);t.clientX-a.left<=s+Oi?e=-Di(s-t.clientX):t.clientX+a.right>=o-Oi&&(e=Di(t.clientX-o)),t.clientY-a.top<=r+Oi?i=-Di(r-t.clientY):t.clientY+a.bottom>=l-Oi&&(i=Di(t.clientY-l)),this.setScrollSpeed(e,i)}up(t){this.dragging==null&&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=this.view.inputState.draggedContent=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(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),this.dragging===!1&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=Hl(this.atoms,this.style.get(t,this.extend,this.multiple));(this.mustSelect||!i.eq(e.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(e=>e.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Df(n,t){let e=n.state.facet(Al);return e.length?e[0](t):S.mac?t.metaKey:t.ctrlKey}function Pf(n,t){let e=n.state.facet(Ml);return e.length?e[0](t):S.mac?!t.altKey:!t.ctrlKey}function If(n,t){let{main:e}=n.state.selection;if(e.empty)return!1;let i=fi(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function Lf(n,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,i;e!=n.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(i=_.get(e))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(t))return!1;return!0}const Tt=Object.create(null),ut=Object.create(null),Ul=S.ie&&S.ie_version<15||S.ios&&S.webkit_version<604;function Rf(n){let t=n.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{n.focus(),e.remove(),Gl(n,e.value)},50)}function ws(n,t,e){for(let i of n.facet(t))e=i(e,n);return e}function Gl(n,t){t=ws(n.state,$n,t);let{state:e}=n,i,s=1,r=e.toText(t),o=r.lines==e.selection.ranges.length;if(wn!=null&&e.selection.ranges.every(a=>a.empty)&&wn==r.toString()){let a=-1;i=e.changeByRange(h=>{let f=e.doc.lineAt(h.from);if(f.from==a)return{range:h};a=f.from;let c=e.toText((o?r.line(s++).text:t)+e.lineBreak);return{changes:{from:f.from,insert:c},range:w.cursor(h.from+c.length)}})}else o?i=e.changeByRange(a=>{let h=r.line(s++);return{changes:{from:a.from,to:a.to,insert:h.text},range:w.cursor(a.from+h.length)}}):i=e.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ut.scroll=n=>{n.inputState.lastScrollTop=n.scrollDOM.scrollTop,n.inputState.lastScrollLeft=n.scrollDOM.scrollLeft};ut.wheel=ut.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Tt.keydown=(n,t)=>(n.inputState.setSelectionOrigin("select"),t.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);ut.touchstart=(n,t)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};ut.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Tt.mousedown=(n,t)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let e=null;for(let i of n.state.facet(Tl))if(e=i(n,t),e)break;if(!e&&t.button==0&&(e=Nf(n,t)),e){let i=!n.hasFocus;n.inputState.startMouseSelection(new Of(n,t,e,i)),i&&n.observer.ignore(()=>{ml(n.contentDOM);let r=n.root.activeElement;r&&!r.contains(n.contentDOM)&&r.blur()});let s=n.inputState.mouseSelection;if(s)return s.start(t),s.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function Wr(n,t,e,i){if(i==1)return w.cursor(t,e);if(i==2)return cf(n.state,t,e);{let s=n.docView.lineAt(t,e),r=n.state.doc.lineAt(s?s.posAtEnd:t),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return l<n.state.doc.length&&l==r.to&&l++,w.range(o,l)}}const Ef=S.ie&&S.ie_version<=11;let Vr=null,Hr=0,zr=0;function _l(n){if(!Ef)return n.detail;let t=Vr,e=zr;return Vr=n,zr=Date.now(),Hr=!t||e>Date.now()-400&&Math.abs(t.clientX-n.clientX)<2&&Math.abs(t.clientY-n.clientY)<2?(Hr+1)%3:1}function Nf(n,t){let e=n.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),i=_l(t),s=n.state.selection;return{update(r){r.docChanged&&(e.pos=r.changes.mapPos(e.pos),s=s.map(r.changes))},get(r,o,l){let a=n.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,f=Wr(n,a.pos,a.assoc,i);if(e.pos!=a.pos&&!o){let c=Wr(n,e.pos,e.assoc,i),u=Math.min(c.from,f.from),d=Math.max(c.to,f.to);f=u<f.from?w.range(u,d):w.range(d,u)}return o?s.replaceRange(s.main.extend(f.from,f.to)):l&&i==1&&s.ranges.length>1&&(h=Ff(s,a.pos))?h:l?s.addRange(f):w.create([f])}}}function Ff(n,t){for(let e=0;e<n.ranges.length;e++){let{from:i,to:s}=n.ranges[e];if(i<=t&&s>=t)return w.create(n.ranges.slice(0,e).concat(n.ranges.slice(e+1)),n.mainIndex==e?0:n.mainIndex-(n.mainIndex>e?1:0))}return null}Tt.dragstart=(n,t)=>{let{selection:{main:e}}=n.state;if(t.target.draggable){let s=n.docView.tile.nearest(t.target);if(s&&s.isWidget()){let r=s.posAtStart,o=r+s.length;(r>=e.to||o<=e.from)&&(e=w.range(r,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=e,t.dataTransfer&&(t.dataTransfer.setData("Text",ws(n.state,qn,n.state.sliceDoc(e.from,e.to))),t.dataTransfer.effectAllowed="copyMove"),!1};Tt.dragend=n=>(n.inputState.draggedContent=null,!1);function Kr(n,t,e,i){if(e=ws(n.state,$n,e),!e)return;let s=n.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:r}=n.inputState,o=i&&r&&Pf(n,t)?{from:r.from,to:r.to}:null,l={from:s,insert:e},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Tt.drop=(n,t)=>{if(!t.dataTransfer)return!1;if(n.state.readOnly)return!0;let e=t.dataTransfer.files;if(e&&e.length){let i=Array(e.length),s=0,r=()=>{++s==e.length&&Kr(n,t,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<e.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(e[o])}return!0}else{let i=t.dataTransfer.getData("Text");if(i)return Kr(n,t,i,!0),!0}return!1};Tt.paste=(n,t)=>{if(n.state.readOnly)return!0;n.observer.flush();let e=Ul?null:t.clipboardData;return e?(Gl(n,e.getData("text/plain")||e.getData("text/uri-list")),!0):(Rf(n),!1)};function Wf(n,t){let e=n.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Vf(n){let t=[],e=[],i=!1;for(let s of n.selection.ranges)s.empty||(t.push(n.sliceDoc(s.from,s.to)),e.push(s));if(!t.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(t.push(o.text),e.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:ws(n,qn,t.join(n.lineBreak)),ranges:e,linewise:i}}let wn=null;Tt.copy=Tt.cut=(n,t)=>{if(!ei(n.contentDOM,n.observer.selectionRange))return!1;let{text:e,ranges:i,linewise:s}=Vf(n.state);if(!e&&!s)return!1;wn=s?e:null,t.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Ul?null:t.clipboardData;return r?(r.clearData(),r.setData("text/plain",e),!0):(Wf(n,e),!1)};const Yl=ye.define();function Jl(n,t){let e=[];for(let i of n.facet(Dl)){let s=i(n,t);s&&e.push(s)}return e.length?n.update({effects:e,annotations:Yl.of(!0)}):null}function Xl(n){setTimeout(()=>{let t=n.hasFocus;if(t!=n.inputState.notifiedFocused){let e=Jl(n.state,t);e?n.dispatch(e):n.update([])}},10)}ut.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),Xl(n)};ut.blur=n=>{n.observer.clearSelectionRange(),Xl(n)};ut.compositionstart=ut.compositionupdate=n=>{n.observer.editContext||(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0))};ut.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,S.chrome&&S.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};ut.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Tt.beforeinput=(n,t)=>{var e,i;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(n.inputState.insertingText=t.data,n.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&n.observer.editContext){let r=(e=t.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain"),o=t.getTargetRanges();if(r&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),h=n.posAtDOM(l.endContainer,l.endOffset);return _n(n,{from:a,to:h,insert:n.state.toText(r)},null),!0}}let s;if(S.chrome&&S.android&&(s=ql.find(r=>r.inputType==t.inputType))&&(n.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return S.ios&&t.inputType=="deleteContentForward"&&n.observer.flushSoon(),S.safari&&t.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>ut.compositionend(n,t),20),!1};const $r=new Set;function Hf(n){$r.has(n)||($r.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const qr=["pre-wrap","normal","pre-line","break-spaces"];let Ne=!1;function jr(){Ne=!1}class zf{constructor(t){this.lineWrapping=t,this.doc=L.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}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)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return qr.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(s*10)]||(e=!0,this.heightSamples[Math.floor(s*10)]=!0)}return e}refresh(t,e,i,s,r,o){let l=qr.indexOf(t)>-1,a=Math.abs(e-this.lineHeight)>.3||this.lineWrapping!=l||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=l,this.lineHeight=e,this.charWidth=i,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let h=0;h<o.length;h++){let f=o[h];f<0?h++:this.heightSamples[Math.floor(f*10)]=!0}}return a}}class Kf{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Ct{constructor(t,e,i,s,r){this.from=t,this.length=e,this.top=i,this.height=s,this._content=r}get type(){return typeof this._content=="number"?kt.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ge?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Ct(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var H=function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n}(H||(H={}));const ji=.001;class at{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>ji&&(Ne=!0),this.height=t)}replace(t,e,i){return at.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,s){let r=this,o=i.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:f,toB:c}=s[l],u=r.lineAt(a,H.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=h?u:r.lineAt(h,H.ByPosNoHeight,i,0,0);for(c+=d.to-h,h=d.to;l>0&&u.from<=s[l-1].toA;)a=s[l-1].fromA,f=s[l-1].fromB,l--,a<u.from&&(u=r.lineAt(a,H.ByPosNoHeight,i,0,0));f+=u.from-a,a=u.from;let p=Yn.build(i.setDoc(o),t,f,c);r=ss(r,r.replace(a,h,p))}return r.updateHeight(i,0)}static empty(){return new pt(0,0,0)}static of(t){if(t.length==1)return t[0];let e=0,i=t.length,s=0,r=0;for(;;)if(e==i)if(s>r*2){let l=t[e-1];l.break?t.splice(--e,1,l.left,null,l.right):t.splice(--e,1,l.left,l.right),i+=1+l.break,s-=l.size}else if(r>s*2){let l=t[i];l.break?t.splice(i,1,l.left,null,l.right):t.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(s<r){let l=t[e++];l&&(s+=l.size)}else{let l=t[--i];l&&(r+=l.size)}let o=0;return t[e-1]==null?(o=1,e--):t[e]==null&&(o=1,i++),new qf(at.of(t.slice(0,e)),o,at.of(t.slice(i)))}}function ss(n,t){return n==t?n:(n.constructor!=t.constructor&&(Ne=!0),t)}at.prototype.size=1;const $f=K.replace({});class Ql extends at{constructor(t,e,i){super(t,e),this.deco=i,this.spaceAbove=0}mainBlock(t,e){return new Ct(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(t,e,i,s){return this.spaceAbove&&t<i+this.spaceAbove?new Ct(s,0,i,this.spaceAbove,$f):this.mainBlock(i,s)}lineAt(t,e,i,s,r){let o=this.mainBlock(s,r);return this.spaceAbove?this.blockAt(0,i,s,r).join(o):o}forEachLine(t,e,i,s,r,o){t<=r+this.length&&e>=r&&o(this.lineAt(0,H.ByPos,i,s,r))}setMeasuredHeight(t){let e=t.heights[t.index++];e<0?(this.spaceAbove=-e,e=t.heights[t.index++]):this.spaceAbove=0,this.setHeight(e)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class pt extends Ql{constructor(t,e,i){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(t,e){return new Ct(e,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,e,i){let s=i[0];return i.length==1&&(s instanceof pt||s instanceof Z&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof Z?s=new pt(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):at.of(i)}updateHeight(t,e=0,i=!1,s){return s&&s.from<=e&&s.more?this.setMeasuredHeight(s):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Z extends at{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-i+1,o,l=0;if(t.lineWrapping){let a=Math.min(this.height,t.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:l}}blockAt(t,e,i,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(e,s);if(e.lineWrapping){let h=s+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),f=e.doc.lineAt(h),c=l+f.length*a,u=Math.max(i,t-c/2);return new Ct(f.from,f.length,u,c,0)}else{let h=Math.max(0,Math.min(o-r,Math.floor((t-i)/l))),{from:f,length:c}=e.doc.line(r+h);return new Ct(f,c,i+l*h,l,0)}}lineAt(t,e,i,s,r){if(e==H.ByHeight)return this.blockAt(t,i,s,r);if(e==H.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(t);return new Ct(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),h=i.doc.lineAt(t),f=l+h.length*a,c=h.number-o,u=s+l*c+a*(h.from-r-c);return new Ct(h.from,h.length,Math.max(s,Math.min(u,s+this.height-f)),f,0)}forEachLine(t,e,i,s,r,o){t=Math.max(t,r),e=Math.min(e,r+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,r);for(let f=t,c=s;f<=e;){let u=i.doc.lineAt(f);if(f==t){let p=u.number-l;c+=a*p+h*(t-r-p)}let d=a+h*u.length;o(new Ct(u.from,u.length,c,d,0)),c+=d,f=u.to+1}}replace(t,e,i){let s=this.length-e;if(s>0){let r=i[i.length-1];r instanceof Z?i[i.length-1]=new Z(r.length+s):i.push(null,new Z(s-1))}if(t>0){let r=i[0];r instanceof Z?i[0]=new Z(t+r.length):i.unshift(new Z(t-1),null)}return at.of(i)}decomposeLeft(t,e){e.push(new Z(t-1),null)}decomposeRight(t,e){e.push(null,new Z(this.length-t-1))}updateHeight(t,e=0,i=!1,s){let r=e+this.length;if(s&&s.from<=e+this.length&&s.more){let o=[],l=Math.max(e,s.from),a=-1;for(s.from>e&&o.push(new Z(s.from-e-1).updateHeight(t,e));l<=r&&s.more;){let f=t.doc.lineAt(l).length;o.length&&o.push(null);let c=s.heights[s.index++],u=0;c<0&&(u=-c,c=s.heights[s.index++]),a==-1?a=c:Math.abs(c-a)>=ji&&(a=-2);let d=new pt(f,c,u);d.outdated=!1,o.push(d),l+=f+1}l<=r&&o.push(null,new Z(r-l).updateHeight(t,l));let h=at.of(o);return(a<0||Math.abs(h.height-this.height)>=ji||Math.abs(a-this.heightMetrics(t,e).perLine)>=ji)&&(Ne=!0),ss(this,h)}else(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class qf extends at{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 this.flags&1}blockAt(t,e,i,s){let r=i+this.left.height;return t<r?this.left.blockAt(t,e,i,s):this.right.blockAt(t,e,r,s+this.left.length+this.break)}lineAt(t,e,i,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=e==H.ByHeight?t<o:t<l,h=a?this.left.lineAt(t,e,i,s,r):this.right.lineAt(t,e,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let f=e==H.ByPosNoHeight?H.ByPosNoHeight:H.ByPos;return a?h.join(this.right.lineAt(l,f,i,o,l)):this.left.lineAt(l,f,i,s,r).join(h)}forEachLine(t,e,i,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,i,s,r,o),e>=a&&this.right.forEachLine(t,e,i,l,a,o);else{let h=this.lineAt(a,H.ByPos,i,s,r);t<h.from&&this.left.forEachLine(t,h.from-1,i,s,r,o),h.to>=t&&h.from<=e&&o(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,l,a,o)}}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 r=[];t>0&&this.decomposeLeft(t,r);let o=r.length;for(let l of i)r.push(l);if(t>0&&Ur(r,o-1),e<this.length){let l=r.length;this.decomposeRight(e,r),Ur(r,l)}return at.of(r)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,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?at.of(this.break?[t,null,e]:[t,e]):(this.left=ss(this.left,t),this.right=ss(this.right,e),this.setHeight(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:r,right:o}=this,l=e+r.length+this.break,a=null;return s&&s.from<=e+r.length&&s.more?a=r=r.updateHeight(t,e,i,s):r.updateHeight(t,e,i),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(t,l,i,s):o.updateHeight(t,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ur(n,t){let e,i;n[t]==null&&(e=n[t-1])instanceof Z&&(i=n[t+1])instanceof Z&&n.splice(t-1,3,new Z(e.length+1+i.length))}const jf=5;class Yn{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 pt?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new pt(i-this.pos,-1,0)),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,r=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new Ql(o,s,i)):(o||r||s>=jf)&&this.addLineDeco(s,r,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||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new pt(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,e){let i=new Z(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 pt)return t;let e=new pt(0,-1,0);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,t),s.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof pt)&&!this.isCovered?this.nodes.push(new pt(0,-1,0)):(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=t;for(let s of this.nodes)s instanceof pt&&s.updateHeight(this.oracle,i),i+=s?s.length:1;return this.nodes}static build(t,e,i,s){let r=new Yn(i,t);return N.spans(e,i,s,r,0),r.finish(i)}}function Uf(n,t,e){let i=new Gf;return N.compare(n,t,e,i,0),i.changes}class Gf{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,s){(t<e||i&&i.heightRelevant||s&&s.heightRelevant)&&Te(t,e,this.changes,5)}}function _f(n,t){let e=n.getBoundingClientRect(),i=n.ownerDocument,s=i.defaultView||window,r=Math.max(0,e.left),o=Math.min(s.innerWidth,e.right),l=Math.max(0,e.top),a=Math.min(s.innerHeight,e.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(h.nodeType==1){let f=h,c=window.getComputedStyle(f);if((f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let u=f.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==n.parentNode?s.innerHeight:a,u.bottom)}h=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-e.left,right:Math.max(r,o)-e.left,top:l-(e.top+t),bottom:Math.max(l,a)-(e.top+t)}}function Yf(n){let t=n.getBoundingClientRect(),e=n.ownerDocument.defaultView||window;return t.left<e.innerWidth&&t.right>0&&t.top<e.innerHeight&&t.bottom>0}function Jf(n,t){let e=n.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}class Es{constructor(t,e,i,s){this.from=t,this.to=e,this.size=i,this.displaySize=s}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let s=t[i],r=e[i];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(t,e){return K.replace({widget:new Xf(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class Xf extends ze{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 Gr{constructor(t,e){this.view=t,this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=_r,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=G.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=e.facet(jn).some(s=>typeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new zf(i),this.stateDeco=Yr(e),this.heightMap=at.empty().applyChanges(this.stateDeco,L.empty,this.heightOracle.setDoc(e.doc),[new yt(0,0,0,e.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=K.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=t.scrollDOM,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:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);t.push(new Pi(r,o))}}return this.viewports=t.sort((i,s)=>i.from-s.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?_r:new Jn(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(Xe(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=Yr(this.state);let s=t.changedRanges,r=yt.extendWithRanges(s,Uf(i,this.stateDeco,t?t.changes:J.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);jr(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||Ne)&&(t.flags|=2),l?(this.scrollAnchorPos=t.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,t.flags|=this.updateForViewport(),(h||!t.changes.empty||t.flags&2)&&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(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&(t.selectionSet||t.focusChanged)&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(zh)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:t}=this,e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?G.RTL:G.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",l=e.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,f=0;if(l.width&&l.height){let{scaleX:C,scaleY:M}=pl(e,l);(C>.005&&Math.abs(this.scaleX-C)>.005||M>.005&&Math.abs(this.scaleY-M)>.005)&&(this.scaleX=C,this.scaleY=M,h|=16,o=a=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,h|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=16);let d=gl(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=bl(this.scrollParent||t.win);let g=(this.printing?Jf:_f)(e,this.paddingTop),m=g.top-this.pixelViewport.top,b=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let x=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(x!=this.inView&&(this.inView=x,x&&(a=!0)),!this.inView&&!this.scrollTarget&&!Yf(t.dom))return 0;let v=l.width;if((this.contentDOMWidth!=v||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,h|=16),a){let C=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(C)&&(o=!0),o||s.lineWrapping&&Math.abs(v-this.contentDOMWidth)>s.charWidth){let{lineHeight:M,charWidth:A,textHeight:R}=t.docView.measureTextSize();o=M>0&&s.refresh(r,M,A,R,Math.max(5,v/A),C),o&&(t.docView.minWidth=0,h|=16)}m>0&&b>0?f=Math.max(m,b):m<0&&b<0&&(f=Math.min(m,b)),jr();for(let M of this.viewports){let A=M.from==this.viewport.from?C:t.docView.measureVisibleLineHeights(M);this.heightMap=(o?at.empty().applyChanges(this.stateDeco,L.empty,this.heightOracle,[new yt(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Kf(M.from,A))}Ne&&(h|=2)}let T=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return T&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||T)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}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,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Pi(s.lineAt(o-i*1e3,H.ByHeight,r,0,0).from,s.lineAt(l+(1-i)*1e3,H.ByHeight,r,0,0).to);if(e){let{head:h}=e.range;if(h<a.from||h>a.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=s.lineAt(h,H.ByPos,r,0,0),u;e.y=="center"?u=(c.top+c.bottom)/2-f/2:e.y=="start"||e.y=="nearest"&&h<a.from?u=c.top:u=c.bottom-f,a=new Pi(s.lineAt(u-1e3/2,H.ByHeight,r,0,0).from,s.lineAt(u+f+1e3/2,H.ByHeight,r,0,0).to)}}return a}mapViewport(t,e){let i=e.mapPos(t.from,-1),s=e.mapPos(t.to,1);return new Pi(this.heightMap.lineAt(i,H.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,H.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,H.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,H.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(t==0||s<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r<l+2*1e3}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 Es(e.mapPos(s.from),e.mapPos(s.to),s.size,s.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=G.LTR&&!i)return[];let l=[],a=(f,c,u,d)=>{if(c-f<r)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let b of g)if(b>f&&b<c){a(f,b-10,u,d),a(b+10,c,u,d);return}let m=Zf(t,b=>b.from>=u.from&&b.to<=u.to&&Math.abs(b.from-f)<r&&Math.abs(b.to-c)<r&&!g.some(x=>b.from<x&&b.to>x));if(!m){if(c<u.to&&e&&i&&e.visibleRanges.some(v=>v.from<=c&&v.to>=c)){let v=e.moveToLineBoundary(w.cursor(c),!1,!0).head;v>f&&(c=v)}let b=this.gapSize(u,f,c,d),x=i||b<2e6?b:2e6;m=new Es(f,c,b,x)}l.push(m)},h=f=>{if(f.length<o||f.type!=kt.Text)return;let c=Qf(f.from,f.to,this.stateDeco);if(c.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let g=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,b;if(u!=null){let x=Li(c,u),v=((this.visibleBottom-this.visibleTop)/2+g)/f.height;m=x-v,b=x+v}else m=(this.visibleTop-f.top-g)/f.height,b=(this.visibleBottom-f.top+g)/f.height;d=Ii(c,m),p=Ii(c,b)}else{let g=c.total*this.heightOracle.charWidth,m=s*this.heightOracle.charWidth,b=0;if(g>2e6)for(let M of t)M.from>=f.from&&M.from<f.to&&M.size!=M.displaySize&&M.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=M.size-M.displaySize);let x=this.pixelViewport.left+b,v=this.pixelViewport.right+b,T,C;if(u!=null){let M=Li(c,u),A=((v-x)/2+m)/g;T=M-A,C=M+A}else T=(x-m)/g,C=(v+m)/g;d=Ii(c,T),p=Ii(c,C)}d>f.from&&a(f.from,d,f,c),p<f.to&&a(p,f.to,f,c)};for(let f of this.viewportLines)Array.isArray(f.type)?f.type.forEach(h):h(f);return l}gapSize(t,e,i,s){let r=Li(s,i)-Li(s,e);return this.heightOracle.lineWrapping?t.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(t){Es.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=K.set(t.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];N.spans(e,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let r=0;r<i.length&&!(s&8);r++){let o=this.visibleRanges[r],l=i[r];(o.from!=l.from||o.to!=l.to)&&(s|=4,t&&t.mapPos(o.from,-1)==l.from&&t.mapPos(o.to,1)==l.to||(s|=8))}return this.visibleRanges=i,s}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||Xe(this.heightMap.lineAt(t,H.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||Xe(this.heightMap.lineAt(this.scaler.fromDOM(t),H.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Xe(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 Pi{constructor(t,e){this.from=t,this.to=e}}function Qf(n,t,e){let i=[],s=n,r=0;return N.spans(e,n,t,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),r+=o-s),s=l}},20),s<t&&(i.push({from:s,to:t}),r+=t-s),{total:r,ranges:i}}function Ii({total:n,ranges:t},e){if(e<=0)return t[0].from;if(e>=1)return t[t.length-1].to;let i=Math.floor(n*e);for(let s=0;;s++){let{from:r,to:o}=t[s],l=o-r;if(i<=l)return r+i;i-=l}}function Li(n,t){let e=0;for(let{from:i,to:s}of n.ranges){if(t<=s){e+=t-i;break}e+=s-i}return e/n.total}function Zf(n,t){for(let e of n)if(t(e))return e}const _r={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Yr(n){let t=n.facet(bs).filter(i=>typeof i!="function"),e=n.facet(Un).filter(i=>typeof i!="function");return e.length&&t.push(N.join(e)),t}class Jn{constructor(t,e,i){let s=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=e.lineAt(l,H.ByPos,t,0,0).top,f=e.lineAt(a,H.ByPos,t,0,0).bottom;return s+=f-h,{from:l,to:a,top:h,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(e.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(t){for(let e=0,i=0,s=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.top)return s+(t-i)*this.scale;if(t<=r.bottom)return r.domTop+(t-r.top);i=r.bottom,s=r.domBottom}}fromDOM(t){for(let e=0,i=0,s=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.domTop)return i+(t-s)/this.scale;if(t<=r.domBottom)return r.top+(t-r.domTop);i=r.bottom,s=r.domBottom}}eq(t){return t instanceof Jn?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to):!1}}function Xe(n,t){if(t.scale==1)return n;let e=t.toDOM(n.top),i=t.toDOM(n.bottom);return new Ct(n.from,n.length,e,i-e,Array.isArray(n._content)?n._content.map(s=>Xe(s,t)):n._content)}const Ri=B.define({combine:n=>n.join(" ")}),kn=B.define({combine:n=>n.indexOf(!0)>-1}),vn=ee.newName(),Zl=ee.newName(),ta=ee.newName(),ea={"&light":"."+Zl,"&dark":"."+ta};function Sn(n,t,e){return new ee(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!e||!e[s])throw new RangeError(`Unsupported selector: ${s}`);return e[s]}):n+" "+i}})}const tc=Sn("."+vn,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},ea),ec={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ns=S.ie&&S.ie_version<=11;class ic{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Oh,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let i of e)this.queue.push(i);(S.ie&&S.ie_version<=11||S.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&S.android&&t.constructor.EDIT_CONTEXT!==!1&&!(S.chrome&&S.chrome_version<126)&&(this.editContext=new nc(t),t.state.facet(Kt)&&(t.contentDOM.editContext=this.editContext.editContext)),Ns&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){(t.type=="change"||!t.type)&&!t.matches||(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]))){this.gapIntersection.disconnect();for(let e of 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(Kt)?i.root.activeElement!=this.dom:!ei(this.dom,s))return;let r=s.anchorNode&&i.docView.tile.nearest(s.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(S.ie&&S.ie_version<=11||S.android&&S.chrome)&&!i.state.selection.main.empty&&s.focusNode&&si(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=fi(t.root);if(!e)return!1;let i=S.safari&&t.root.nodeType==11&&t.root.activeElement==this.dom&&sc(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let s=ei(this.dom,i);return s&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&Ph(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),s&&(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(i.nodeType==1)!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(i.nodeType==11)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=e)i.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,ec),Ns&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ns&&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 r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Be(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let 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 r of t){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),e==-1?{from:e,to:i}=o:(e=Math.min(o.from,e),i=Math.max(o.to,i)))}return{from:e,to:i,typeOver:s}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),s=this.selectionChanged&&ei(this.dom,this.selectionRange);if(t<0&&!s)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new kf(this.view,t,e,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,s=Kl(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!is(this.view.state.selection,e.newSel.main))&&this.view.update([]),s}readMutation(t){let e=this.view.docView.tile.nearest(t.target);if(!e||e.isWidget())return null;if(e.markDirty(t.type=="attributes"),t.type=="childList"){let i=Jr(e,t.previousSibling||t.target.previousSibling,-1),s=Jr(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:s?e.posBefore(s):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{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),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):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),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Kt)!=t.state.facet(Kt)&&(t.view.contentDOM.editContext=t.state.facet(Kt)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Jr(n,t,e){for(;t;){let i=_.get(t);if(i&&i.parent==n)return i;let s=t.parentNode;t=s!=n.dom?s:e>0?t.nextSibling:t.previousSibling}return null}function Xr(n,t){let e=t.startContainer,i=t.startOffset,s=t.endContainer,r=t.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return si(o.node,o.offset,s,r)&&([e,i,s,r]=[s,r,e,i]),{anchorNode:e,anchorOffset:i,focusNode:s,focusOffset:r}}function sc(n,t){if(t.getComposedRanges){let s=t.getComposedRanges(n.root)[0];if(s)return Xr(n,s)}let e=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),e=s.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),e?Xr(n,e):null}class nc{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let s=t.state.selection.main,{anchor:r,head:o}=s,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let f=$l(t.state.sliceDoc(l,a),i.text,(h?s.from:s.to)-l,h?"end":null);if(!f){let u=w.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));is(u,s)||t.dispatch({selection:u,userEvent:"select"});return}let c={from:f.from+l,to:f.toA+l,insert:L.of(i.text.slice(f.from,f.toB).split(`
|
|
10
|
-
`))};if((S.mac||S.android)&&c.from==o-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:l,to:a,insert:L.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);_n(t,c,w.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),c.from<c.to&&!c.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=t.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}e.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=i=>{let s=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let f=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(K.mark({attributes:{style:f}}).range(a,h))}}}t.dispatch({effects:Ll.of(K.set(s))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let s=fi(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,s=this.pendingContextChange;return t.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let f=h.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(h)){s=this.pendingContextChange=null,e+=f,this.to+=f;return}else s=null,this.revertPending(t.state);if(r+=e,o+=e,o<=this.from)this.from+=f,this.to+=f;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=f}e+=f}),s&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),s=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class O{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(s=>s.forEach(r=>i(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Dh(t.parent)||document,this.viewState=new Gr(this,t.state||E.create(t)),t.scrollTo&&t.scrollTo.is(Bi)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ve).map(s=>new Ds(s));for(let s of this.plugins)s.update(this);this.observer=new ic(this),this.inputState=new Af(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Rr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let e=t.length==1&&t[0]instanceof et?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,s,r=this.state;for(let u of t){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;t.some(u=>u.annotation(Yl))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Jl(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(f=null)):this.observer.clear(),r.facet(E.phrases)!=this.state.facet(E.phrases))return this.setState(r);s=Zi.create(this,r,t),s.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of t){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;c=new Oe(d.empty?d:w.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Bi)&&(c=d.value.clip(this.state))}this.viewState.update(s,c),this.bidiCache=ns.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(Je)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Ri)!=s.state.facet(Ri)&&(this.viewState.mustMeasureContent=!0),(e||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(bn))try{u(s)}catch(d){gt(this.state,d,"update listener")}(a||f)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),f&&!Kl(this,f)&&h.force&&Be(this.contentDOM,h.key,h.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Gr(this,t),this.plugins=t.facet(ve).map(i=>new Ds(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Rr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(ve),i=t.state.facet(ve);if(e!=i){let s=[];for(let r of i){let o=e.indexOf(r);if(o<0)s.push(new Ds(r));else{let l=this.plugins[o];l.mustUpdate=t,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=t&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=t;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(i){gt(this.state,i,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(bl(i||this.win))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let f=h.map(d=>{try{return d.read(this)}catch(p){return gt(this.state,p),Qr}}),c=Zi.create(this,this.state,[]),u=!1;c.flags|=a,e?e.flags|=a:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(f[d]!=Qr)try{let p=h[d];p.write&&p.write(f[d],this)}catch(p){gt(this.state,p)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=((r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o)/this.scaleY;if((p>1||p<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let l of this.state.facet(bn))l(e)}get themeClasses(){return vn+" "+(this.state.facet(kn)?ta:Zl)+" "+this.state.facet(Ri)}updateAttrs(){let t=Zr(this,Rl,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Kt)?"true":"false",class:"cm-content",style:`${S.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Zr(this,jn,e);let i=this.observer.ignore(()=>{let s=Br(this.contentDOM,this.contentAttrs,e),r=Br(this.dom,this.editorAttrs,t);return s||r});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let s of i.effects)if(s.is(O.announce)){e&&(this.announceDOM.textContent=""),e=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Je);let t=this.state.facet(O.cspNonce);ee.mount(this.root,this.styleModules.concat(tc).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){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(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(i=>i.plugin==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}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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 Rs(this,t,Er(this,t,e,i))}moveByGroup(t,e){return Rs(this,t,Er(this,t,e,i=>gf(this,t.head,i)))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),r=i[e?i.length-1:0];return w.cursor(r.side(e,s)+t.from,r.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return pf(this,t,e,i)}moveVertically(t,e,i){return Rs(this,t,mf(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=xn(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),xn(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),r=this.bidiSpans(s),o=r[Ft.find(r,t-s.from,-1,e)];return ci(i,o.dir==G.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}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(Pl)||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>rc)return Sl(t.length);let e=this.textDirectionAt(t.from),i;for(let r of this.bidiCache)if(r.from==t.from&&r.dir==e&&(r.fresh||vl(r.isolates,i=Pr(this,t))))return r.order;i||(i=Pr(this,t));let s=Wh(t.text,e,i);return this.bidiCache.push(new ns(t.from,t.to,e,i,!0,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||S.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ml(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Bi.of(new Oe(typeof t=="number"?w.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Bi.of(new Oe(w.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Vt.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Vt.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=ee.newName(),s=[Ri.of(i),Je.of(Sn(`.${i}`,t))];return e&&e.dark&&s.push(kn.of(!0)),s}static baseTheme(t){return He.lowest(Je.of(Sn("."+vn,t,ea)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&_.get(i)||_.get(t);return((e=s==null?void 0:s.root)===null||e===void 0?void 0:e.view)||null}}O.styleModule=Je;O.inputHandler=Ol;O.clipboardInputFilter=$n;O.clipboardOutputFilter=qn;O.scrollHandler=Il;O.focusChangeEffect=Dl;O.perLineTextDirection=Pl;O.exceptionSink=Bl;O.updateListener=bn;O.editable=Kt;O.mouseSelectionStyle=Tl;O.dragMovesSelection=Ml;O.clickAddsSelectionRange=Al;O.decorations=bs;O.blockWrappers=El;O.outerDecorations=Un;O.atomicRanges=xi;O.bidiIsolatedRanges=Nl;O.scrollMargins=Fl;O.darkTheme=kn;O.cspNonce=B.define({combine:n=>n.length?n[0]:""});O.contentAttributes=jn;O.editorAttributes=Rl;O.lineWrapping=O.contentAttributes.of({class:"cm-lineWrapping"});O.announce=z.define();const rc=4096,Qr={};class ns{constructor(t,e,i,s,r,o){this.from=t,this.to=e,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(t,e){if(e.empty&&!t.some(r=>r.fresh))return t;let i=[],s=t.length?t[t.length-1].dir:G.LTR;for(let r=Math.max(0,t.length-10);r<t.length;r++){let o=t[r];o.dir==s&&!e.touchesRange(o.from,o.to)&&i.push(new ns(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Zr(n,t,e){for(let i=n.state.facet(t),s=i.length-1;s>=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&Hn(o,e)}return e}const oc=S.mac?"mac":S.windows?"win":S.linux?"linux":"key";function lc(n,t){const e=n.split(/-(?!$)/);let i=e[e.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;a<e.length-1;++a){const h=e[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))s=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))t=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return s&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Ei(n,t,e){return t.altKey&&(n="Alt-"+n),t.ctrlKey&&(n="Ctrl-"+n),t.metaKey&&(n="Meta-"+n),e!==!1&&t.shiftKey&&(n="Shift-"+n),n}const ac=He.default(O.domEventHandlers({keydown(n,t){return uc(hc(t.state),n,t,"editor")}})),Xn=B.define({enables:ac}),to=new WeakMap;function hc(n){let t=n.facet(Xn),e=to.get(t);return e||to.set(t,e=cc(t.reduce((i,s)=>i.concat(s),[]))),e}let Qt=null;const fc=4e3;function cc(n,t=oc){let e=Object.create(null),i=Object.create(null),s=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,f)=>{var c,u;let d=e[o]||(e[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>lc(b,t));for(let b=1;b<p.length;b++){let x=p.slice(0,b).join(" ");s(x,!0),d[x]||(d[x]={preventDefault:!0,stopPropagation:!1,run:[v=>{let T=Qt={view:v,prefix:x,scope:o};return setTimeout(()=>{Qt==T&&(Qt=null)},fc),!0}]})}let g=p.join(" ");s(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(c=d._any)===null||c===void 0?void 0:c.run)===null||u===void 0?void 0:u.slice())||[]});a&&m.run.push(a),h&&(m.preventDefault=!0),f&&(m.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let f=e[h]||(e[h]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let u in f)f[u].run.push(d=>c(d,Cn))}let a=o[t]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return e}let Cn=null;function uc(n,t,e,i){Cn=t;let s=vh(t),r=he(s,0),o=we(r)==s.length&&s!=" ",l="",a=!1,h=!1,f=!1;Qt&&Qt.view==e&&Qt.scope==i&&(l=Qt.prefix+" ",jl.indexOf(t.keyCode)<0&&(h=!0,Qt=null));let c=new Set,u=m=>{if(m){for(let b of m.run)if(!c.has(b)&&(c.add(b),b(e)))return m.stopPropagation&&(f=!0),!0;m.preventDefault&&(m.stopPropagation&&(f=!0),h=!0)}return!1},d=n[i],p,g;return d&&(u(d[l+Ei(s,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(S.windows&&t.ctrlKey&&t.altKey)&&!(S.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=ie[t.keyCode])&&p!=s?(u(d[l+Ei(p,t,!0)])||t.shiftKey&&(g=ai[t.keyCode])!=s&&g!=p&&u(d[l+Ei(g,t,!1)]))&&(a=!0):o&&t.shiftKey&&u(d[l+Ei(s,t,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&f&&t.stopPropagation(),Cn=null,a}class dc extends ze{constructor(t){super(),this.content=t}toDOM(t){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),e.setAttribute("aria-hidden","true"),e}coordsAt(t){let e=t.firstChild?ii(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode),s=ci(e[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function pp(n){let t=Vt.fromClass(class{constructor(e){this.view=e,this.placeholder=n?K.set([K.widget({widget:new dc(n),side:1}).range(0)]):K.none}get decorations(){return this.view.state.doc.length?K.none:this.placeholder}},{decorations:e=>e.decorations});return typeof n=="string"?[t,O.contentAttributes.of({"aria-placeholder":n})]:t}const Ni="-10000px";class pc{constructor(t,e,i,s){this.facet=e,this.createTooltipView=i,this.removeTooltipView=s,this.input=t.state.facet(e),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(t,e){var i;let s=t.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(t);return!1}let o=[],l=e?[]:null;for(let a=0;a<r.length;a++){let h=r[a],f=-1;if(h){for(let c=0;c<this.tooltips.length;c++){let u=this.tooltips[c];u&&u.create==h.create&&(f=c)}if(f<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let c=o[a]=this.tooltipViews[f];l&&(l[a]=e[f]),c.update&&c.update(t)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return e&&(l.forEach((a,h)=>e[h]=a),e.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function gc(n){let t=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Fs=B.define({combine:n=>{var t,e,i;return{position:S.ios?"absolute":((t=n.find(s=>s.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=n.find(s=>s.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||gc}}}),eo=new WeakMap,ia=Vt.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=n.state.facet(Fs);this.position=t.position,this.parent=t.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new pc(n,sa,(e,i)=>this.createTooltip(e,i),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.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){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(n,this.above);t&&this.observeIntersection();let e=t||n.geometryChanged,i=n.state.facet(Fs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;e=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(n,t){let e=n.create(this.view),i=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",e.dom.appendChild(s)}return e.dom.style.position=this.position,e.dom.style.top=Ni,e.dom.style.left="0px",this.container.insertBefore(e.dom,i),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var n,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(S.safari){let o=r.getBoundingClientRect();e=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else e=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(e||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(n=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=Gn(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Fs).tooltipSpace(this.view),scaleX:n,scaleY:t,makeAbsolute:e}}writeMeasure(n){var t;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:i,scaleX:s,scaleY:r}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:f}=h,c=n.pos[l],u=n.size[l];if(!c||a.clip!==!1&&(c.bottom<=Math.max(e.top,i.top)||c.top>=Math.min(e.bottom,i.bottom)||c.right<Math.max(e.left,i.left)-.1||c.left>Math.min(e.right,i.right)+.1)){f.style.top=Ni;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=u.right-u.left,m=(t=eo.get(h))!==null&&t!==void 0?t:u.bottom-u.top,b=h.offset||bc,x=this.view.textDirection==G.LTR,v=u.width>i.right-i.left?x?i.left:i.right-u.width:x?Math.max(i.left,Math.min(c.left-(d?14:0)+b.x,i.right-g)):Math.min(Math.max(i.left,c.left-g+(d?14:0)-b.x),i.right-g),T=this.above[l];!a.strictSide&&(T?c.top-m-p-b.y<i.top:c.bottom+m+p+b.y>i.bottom)&&T==i.bottom-c.bottom>c.top-i.top&&(T=this.above[l]=!T);let C=(T?c.top-i.top:i.bottom-c.bottom)-p;if(C<m&&h.resize!==!1){if(C<this.view.defaultLineHeight){f.style.top=Ni;continue}eo.set(h,m),f.style.height=(m=C)/r+"px"}else f.style.height&&(f.style.height="");let M=T?c.top-m-p-b.y:c.bottom+p+b.y,A=v+g;if(h.overlap!==!0)for(let R of o)R.left<A&&R.right>v&&R.top<M+m&&R.bottom>M&&(M=T?R.top-m-2-p:R.bottom+p+2);if(this.position=="absolute"?(f.style.top=(M-n.parent.top)/r+"px",io(f,(v-n.parent.left)/s)):(f.style.top=M/r+"px",io(f,v/s)),d){let R=c.left+(x?b.x:-b.x)-(v+14-7);d.style.left=R/s+"px"}h.overlap!==!0&&o.push({left:v,top:M,right:A,bottom:M+m}),f.classList.toggle("cm-tooltip-above",T),f.classList.toggle("cm-tooltip-below",!T),h.positioned&&h.positioned(n.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 n of this.manager.tooltipViews)n.dom.style.top=Ni}},{eventObservers:{scroll(){this.maybeMeasure()}}});function io(n,t){let e=parseInt(n.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(n.style.left=t+"px")}const mc=O.baseTheme({".cm-tooltip":{zIndex:500,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:`${7*2}px`,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"}}}),bc={x:0,y:0},sa=B.define({enables:[ia,mc]});function na(n,t){let e=n.plugin(ia);if(!e)return null;let i=e.manager.tooltips.indexOf(t);return i<0?null:e.manager.tooltipViews[i]}class Fe extends te{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Fe.prototype.elementClass="";Fe.prototype.toDOM=void 0;Fe.prototype.mapMode=lt.TrackBefore;Fe.prototype.startSide=Fe.prototype.endSide=-1;Fe.prototype.point=!0;const ra=1024;let yc=0;class xt{constructor(t,e){this.from=t,this.to=e}}class P{constructor(t={}){this.id=yc++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=ht.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}}P.closedBy=new P({deserialize:n=>n.split(" ")});P.openedBy=new P({deserialize:n=>n.split(" ")});P.group=new P({deserialize:n=>n.split(" ")});P.isolate=new P({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});P.contextHash=new P({perNode:!0});P.lookAhead=new P({perNode:!0});P.mounted=new P({perNode:!0});class De{constructor(t,e,i,s=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=s}static get(t){return t&&t.props&&t.props[P.mounted.id]}}const xc=Object.create(null);class ht{constructor(t,e,i,s=0){this.name=t,this.props=e,this.id=i,this.flags=s}static define(t){let e=t.props&&t.props.length?Object.create(null):xc,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),s=new ht(t.name||"",e,t.id,i);if(t.props){for(let r of t.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}}return s}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(P.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let s of i.split(" "))e[s]=t[i];return i=>{for(let s=i.prop(P.group),r=-1;r<(s?s.length:0);r++){let o=e[r<0?i.name:s[r]];if(o)return o}}}}ht.none=new ht("",Object.create(null),0,8);class Qn{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let s=null;for(let r of t){let o=r(i);if(o){s||(s=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in s&&(l=a.combine(s[a.id],l)),s[a.id]=l}}e.push(s?new ht(i.name,s,i.id,i.flags):i)}return new Qn(e)}}const Fi=new WeakMap,so=new WeakMap;var F;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(F||(F={}));class q{constructor(t,e,i,s,r){if(this.type=t,this.children=e,this.positions=i,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=De.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let s=i.toString();s&&(e&&(e+=","),e+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new rs(this.topNode,t)}cursorAt(t,e=0,i=0){let s=Fi.get(this)||this.topNode,r=new rs(s);return r.moveTo(t,e),Fi.set(this,r._tree),r}get topNode(){return new nt(this,0,0,null)}resolve(t,e=0){let i=di(Fi.get(this)||this.topNode,t,e,!1);return Fi.set(this,i),i}resolveInner(t,e=0){let i=di(so.get(this)||this.topNode,t,e,!0);return so.set(this,i),i}resolveStack(t,e=0){return vc(this,t,e)}iterate(t){let{enter:e,leave:i,from:s=0,to:r=this.length}=t,o=t.mode||0,l=(o&F.IncludeAnonymous)>0;for(let a=this.cursor(o|F.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||e(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:er(ht.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,s)=>new q(this.type,e,i,s,this.propValues),t.makeTree||((e,i,s)=>new q(ht.none,e,i,s)))}static build(t){return Sc(t)}}q.empty=new q(ht.none,[],[],0);class Zn{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Zn(this.buffer,this.index)}}class ne{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ht.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],s=this.set.types[e],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),t+=4,i==t)return r;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return r+"("+o.join(",")+")"}findChild(t,e,i,s,r){let{buffer:o}=this,l=-1;for(let a=t;a!=e&&!(oa(r,s,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(t,e,i){let s=this.buffer,r=new Uint16Array(e-t),o=0;for(let l=t,a=0;l<e;){r[a++]=s[l++],r[a++]=s[l++]-i;let h=r[a++]=s[l++]-i;r[a++]=s[l++]-t,o=Math.max(o,h)}return new ne(r,o,this.set)}}function oa(n,t,e,i){switch(n){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function di(n,t,e,i){for(var s;n.from==n.to||(e<1?n.from>=t:n.from>t)||(e>-1?n.to<=t:n.to<t);){let o=!i&&n instanceof nt&&n.index<0?null:n.parent;if(!o)return n;n=o}let r=i?0:F.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof nt&&o.index<0&&((s=l.enter(t,e,r))===null||s===void 0?void 0:s.from)!=o.from&&(n=l);for(;;){let o=n.enter(t,e,r);if(!o)return n;n=o}}class la{cursor(t=0){return new rs(this,t)}getChild(t,e=null,i=null){let s=no(this,t,e,i);return s.length?s[0]:null}getChildren(t,e=null,i=null){return no(this,t,e,i)}resolve(t,e=0){return di(this,t,e,!1)}resolveInner(t,e=0){return di(this,t,e,!0)}matchContext(t){return An(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let s=e.lastChild;if(!s||s.to!=e.to)break;s.type.isError&&s.from==s.to?(i=e,e=s.prevSibling):e=s}return i}get node(){return this}get next(){return this.parent}}class nt extends la{constructor(t,e,i,s){super(),this._tree=t,this.from=e,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=e>0?l.length:-1;t!=h;t+=e){let f=l[t],c=a[t]+o.from,u;if(!(!(r&F.EnterBracketed&&f instanceof q&&(u=De.get(f))&&!u.overlay&&u.bracketed&&i>=c&&i<=c+f.length)&&!oa(s,i,c,c+f.length))){if(f instanceof ne){if(r&F.ExcludeBuffers)continue;let d=f.findChild(0,f.buffer.length,e,i-c,s);if(d>-1)return new Wt(new wc(o,f,t,c),null,d)}else if(r&F.IncludeAnonymous||!f.type.isAnonymous||tr(f)){let d;if(!(r&F.IgnoreMounts)&&(d=De.get(f))&&!d.overlay)return new nt(d.tree,c,t,o);let p=new nt(f,c,t,o);return r&F.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(e<0?f.children.length-1:0,e,i,s,r)}}}if(r&F.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let s;if(!(i&F.IgnoreOverlays)&&(s=De.get(this._tree))&&s.overlay){let r=t-this.from,o=i&F.EnterBracketed&&s.bracketed;for(let{from:l,to:a}of s.overlay)if((e>0||o?l<=r:l<r)&&(e<0||o?a>=r:a>r))return new nt(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function no(n,t,e,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(e!=null){for(let o=!1;!o;)if(o=s.type.is(e),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(t)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function An(n,t,e=t.length-1){for(let i=n;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}class wc{constructor(t,e,i,s){this.parent=t,this.buffer=e,this.index=i,this.start=s}}class Wt extends la{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.context.start,i);return r<0?null:new Wt(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&F.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new Wt(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Wt(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Wt(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];t.push(i.slice(s,r,o)),e.push(0)}return new q(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function aa(n){if(!n.length)return null;let t=0,e=n[0];for(let r=1;r<n.length;r++){let o=n[r];(o.from>e.from||o.to<e.to)&&(e=o,t=r)}let i=e instanceof nt&&e.index<0?null:e.parent,s=n.slice();return i?s[t]=i:s.splice(t,1),new kc(s,e)}class kc{constructor(t,e){this.heads=t,this.node=e}get next(){return aa(this.heads)}}function vc(n,t,e){let i=n.resolveInner(t,e),s=null;for(let r=i instanceof nt?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[i])).push(o.resolve(t,e)),r=o}else{let o=De.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let l=new nt(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(di(l,t,e,!1))}}return s?aa(s):i}class rs{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~F.EnterBracketed,t instanceof nt)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:s}=this.buffer;return this.type=e||s.set.types[s.buffer[t]],this.from=i+s.buffer[t+1],this.to=i+s.buffer[t+2],!0}yield(t){return t?t instanceof nt?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&F.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&F.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&F.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(e.findChild(s,this.index,-1,0,4))}else{let s=e.buffer[this.index+3];if(s<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:s}=this;if(s){if(t>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:e,parent:i}=s)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let r=e+t,o=t<0?-1:i._tree.children.length;r!=o;r+=t){let l=i._tree.children[r];if(this.mode&F.IncludeAnonymous||l instanceof ne||!l.type.isAnonymous||tr(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=t;o;o=o._parent)if(o.index==s){if(s==this.index)return o;e=o,i=r+1;break t}s=this.stack[--r]}for(let s=i;s<this.stack.length;s++)e=new Wt(this.buffer,e,this.stack[s]);return this.bufferNode=new Wt(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let s=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&e&&e(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(t){if(!this.buffer)return An(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let s=t.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return An(this._tree,t,s);let o=i[e.buffer[this.stack[r]]];if(!o.isAnonymous){if(t[s]&&t[s]!=o.name)return!1;s--}}return!0}}function tr(n){return n.children.some(t=>t instanceof ne||!t.type.isAnonymous||tr(t))}function Sc(n){var t;let{buffer:e,nodeSet:i,maxBufferLength:s=ra,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(e)?new Zn(e,e.length):e,a=i.types,h=0,f=0;function c(C,M,A,R,V,U){let{id:I,start:D,end:$,size:j}=l,Q=f,Yt=h;if(j<0)if(l.next(),j==-1){let Ht=r[I];A.push(Ht),R.push(D-C);return}else if(j==-3){h=I;return}else if(j==-4){f=I;return}else throw new RangeError(`Unrecognized record size: ${j}`);let qe=a[I],Si,oe,dr=D-C;if($-D<=s&&(oe=m(l.pos-M,V))){let Ht=new Uint16Array(oe.size-oe.skip),mt=l.pos-oe.size,Dt=Ht.length;for(;l.pos>mt;)Dt=b(oe.start,Ht,Dt);Si=new ne(Ht,$-oe.start,i),dr=oe.start-C}else{let Ht=l.pos-j;l.next();let mt=[],Dt=[],le=I>=o?I:-1,xe=0,Ci=$;for(;l.pos>Ht;)le>=0&&l.id==le&&l.size>=0?(l.end<=Ci-s&&(p(mt,Dt,D,xe,l.end,Ci,le,Q,Yt),xe=mt.length,Ci=l.end),l.next()):U>2500?u(D,Ht,mt,Dt):c(D,Ht,mt,Dt,le,U+1);if(le>=0&&xe>0&&xe<mt.length&&p(mt,Dt,D,xe,D,Ci,le,Q,Yt),mt.reverse(),Dt.reverse(),le>-1&&xe>0){let pr=d(qe,Yt);Si=er(qe,mt,Dt,0,mt.length,0,$-D,pr,pr)}else Si=g(qe,mt,Dt,$-D,Q-$,Yt)}A.push(Si),R.push(dr)}function u(C,M,A,R){let V=[],U=0,I=-1;for(;l.pos>M;){let{id:D,start:$,end:j,size:Q}=l;if(Q>4)l.next();else{if(I>-1&&$<I)break;I<0&&(I=j-s),V.push(D,$,j),U++,l.next()}}if(U){let D=new Uint16Array(U*4),$=V[V.length-2];for(let j=V.length-3,Q=0;j>=0;j-=3)D[Q++]=V[j],D[Q++]=V[j+1]-$,D[Q++]=V[j+2]-$,D[Q++]=Q;A.push(new ne(D,V[2]-$,i)),R.push($-C)}}function d(C,M){return(A,R,V)=>{let U=0,I=A.length-1,D,$;if(I>=0&&(D=A[I])instanceof q){if(!I&&D.type==C&&D.length==V)return D;($=D.prop(P.lookAhead))&&(U=R[I]+D.length+$)}return g(C,A,R,V,U,M)}}function p(C,M,A,R,V,U,I,D,$){let j=[],Q=[];for(;C.length>R;)j.push(C.pop()),Q.push(M.pop()+A-V);C.push(g(i.types[I],j,Q,U-V,D-U,$)),M.push(V-A)}function g(C,M,A,R,V,U,I){if(U){let D=[P.contextHash,U];I=I?[D].concat(I):[D]}if(V>25){let D=[P.lookAhead,V];I=I?[D].concat(I):[D]}return new q(C,M,A,R,I)}function m(C,M){let A=l.fork(),R=0,V=0,U=0,I=A.end-s,D={size:0,start:0,skip:0};t:for(let $=A.pos-C;A.pos>$;){let j=A.size;if(A.id==M&&j>=0){D.size=R,D.start=V,D.skip=U,U+=4,R+=4,A.next();continue}let Q=A.pos-j;if(j<0||Q<$||A.start<I)break;let Yt=A.id>=o?4:0,qe=A.start;for(A.next();A.pos>Q;){if(A.size<0)if(A.size==-3||A.size==-4)Yt+=4;else break t;else A.id>=o&&(Yt+=4);A.next()}V=qe,R+=j,U+=Yt}return(M<0||R==C)&&(D.size=R,D.start=V,D.skip=U),D.size>4?D:void 0}function b(C,M,A){let{id:R,start:V,end:U,size:I}=l;if(l.next(),I>=0&&R<o){let D=A;if(I>4){let $=l.pos-(I-4);for(;l.pos>$;)A=b(C,M,A)}M[--A]=D,M[--A]=U-C,M[--A]=V-C,M[--A]=R}else I==-3?h=R:I==-4&&(f=R);return A}let x=[],v=[];for(;l.pos>0;)c(n.start||0,n.bufferStart||0,x,v,-1,0);let T=(t=n.length)!==null&&t!==void 0?t:x.length?v[0]+x[0].length:0;return new q(a[n.topID],x.reverse(),v.reverse(),T)}const ro=new WeakMap;function Ui(n,t){if(!n.isAnonymous||t instanceof ne||t.type!=n)return 1;let e=ro.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=n||!(i instanceof q)){e=1;break}e+=Ui(n,i)}ro.set(t,e)}return e}function er(n,t,e,i,s,r,o,l,a){let h=0;for(let p=i;p<s;p++)h+=Ui(n,t[p]);let f=Math.ceil(h*1.5/8),c=[],u=[];function d(p,g,m,b,x){for(let v=m;v<b;){let T=v,C=g[v],M=Ui(n,p[v]);for(v++;v<b;v++){let A=Ui(n,p[v]);if(M+A>=f)break;M+=A}if(v==T+1){if(M>f){let A=p[T];d(A.children,A.positions,0,A.children.length,g[T]+x);continue}c.push(p[T])}else{let A=g[v-1]+p[v-1].length-C;c.push(er(n,p,g,T,v,C,A,null,a))}u.push(C+x-r)}}return d(t,e,i,s,0),(l||a)(c,u,o)}class gp{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let s=this.map.get(t);s||this.map.set(t,s=new Map),s.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof Wt?this.setBuffer(t.context.buffer,t.index,e):t instanceof nt&&this.map.set(t.tree,e)}get(t){return t instanceof Wt?this.getBuffer(t.context.buffer,t.index):t instanceof nt?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Ut{constructor(t,e,i,s,r=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let s=[new Ut(0,t.length,t,0,!1,i)];for(let r of e)r.to>t.length&&s.push(r);return s}static applyChanges(t,e,i=128){if(!e.length)return t;let s=[],r=1,o=t.length?t[0]:null;for(let l=0,a=0,h=0;;l++){let f=l<e.length?e[l]:null,c=f?f.fromA:1e9;if(c-a>=i)for(;o&&o.from<c;){let u=o;if(a>=u.from||c<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,c)-h;u=d>=p?null:new Ut(d,p,u.tree,u.offset+h,l>0,!!f)}if(u&&s.push(u),o.to>c)break;o=r<t.length?t[r++]:null}if(!f)break;a=f.toA,h=f.toA-f.toB}return s}}class ha{startParse(t,e,i){return typeof t=="string"&&(t=new Cc(t)),i=i?i.length?i.map(s=>new xt(s.from,s.to)):[new xt(0,0)]:[new xt(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let s=this.startParse(t,e,i);for(;;){let r=s.advance();if(r)return r}}}class Cc{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function mp(n){return(t,e,i,s)=>new Mc(t,n,e,i,s)}class oo{constructor(t,e,i,s,r,o){this.parser=t,this.parse=e,this.overlay=i,this.bracketed=s,this.target=r,this.from=o}}function lo(n){if(!n.length||n.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}class Ac{constructor(t,e,i,s,r,o,l,a){this.parser=t,this.predicate=e,this.mounts=i,this.index=s,this.start=r,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Mn=new P({perNode:!0});class Mc{constructor(t,e,i,s,r){this.nest=e,this.input=i,this.fragments=s,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new q(i.type,i.children,i.positions,i.length,i.propValues.concat([[Mn,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[P.mounted.id]=new De(e,t.overlay,t.parser,t.bracketed),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new Oc(this.fragments),e=null,i=null,s=new rs(new nt(this.baseTree,this.ranges[0].from,0,null),F.IncludeAnonymous|F.IgnoreMounts);t:for(let r,o;;){let l=!0,a;if(this.stoppedAt!=null&&s.from>=this.stoppedAt)l=!1;else if(t.hasNode(s)){if(e){let h=e.mounts.find(f=>f.frag.from<=s.from&&f.frag.to>=s.to&&f.mount.overlay);if(h)for(let f of h.mount.overlay){let c=f.from+h.pos,u=f.to+h.pos;c>=s.from&&u<=s.to&&!e.ranges.some(d=>d.from<u&&d.to>c)&&e.ranges.push({from:c,to:u})}}l=!1}else if(i&&(o=Tc(i.ranges,s.from,s.to)))l=o!=2;else if(!s.type.isAnonymous&&(r=this.nest(s,this.input))&&(s.from<s.to||!r.overlay)){s.tree||(Bc(s),e&&e.depth++,i&&i.depth++);let h=t.findMounts(s.from,r.parser);if(typeof r.overlay=="function")e=new Ac(r.parser,r.overlay,h,this.inner.length,s.from,!!r.bracketed,s.tree,e);else{let f=fo(this.ranges,r.overlay||(s.from<s.to?[new xt(s.from,s.to)]:[]));f.length&&lo(f),(f.length||!r.overlay)&&this.inner.push(new oo(r.parser,f.length?r.parser.startParse(this.input,co(h,f),f):r.parser.startParse(""),r.overlay?r.overlay.map(c=>new xt(c.from-s.from,c.to-s.from)):null,!!r.bracketed,s.tree,f.length?f[0].from:s.from)),r.overlay?f.length&&(i={ranges:f,depth:0,prev:i}):l=!1}}else if(e&&(a=e.predicate(s))&&(a===!0&&(a=new xt(s.from,s.to)),a.from<a.to)){let h=e.ranges.length-1;h>=0&&e.ranges[h].to==a.from?e.ranges[h]={from:e.ranges[h].from,to:a.to}:e.ranges.push(a)}if(l&&s.firstChild())e&&e.depth++,i&&i.depth++;else for(;!s.nextSibling();){if(!s.parent())break t;if(e&&!--e.depth){let h=fo(this.ranges,e.ranges);h.length&&(lo(h),this.inner.splice(e.index,0,new oo(e.parser,e.parser.startParse(this.input,co(e.mounts,h),h),e.ranges.map(f=>new xt(f.from-e.start,f.to-e.start)),e.bracketed,e.target,h[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}}function Tc(n,t,e){for(let i of n){if(i.from>=e)break;if(i.to>t)return i.from<=t&&i.to>=e?2:1}return 0}function ao(n,t,e,i,s,r){if(t<e){let o=n.buffer[t+1];i.push(n.slice(t,e,o)),s.push(o-r)}}function Bc(n){let{node:t}=n,e=[],i=t.context.buffer;do e.push(n.index),n.parent();while(!n.tree);let s=n.tree,r=s.children.indexOf(i),o=s.children[r],l=o.buffer,a=[r];function h(f,c,u,d,p,g){let m=e[g],b=[],x=[];ao(o,f,m,b,x,d);let v=l[m+1],T=l[m+2];a.push(b.length);let C=g?h(m+4,l[m+3],o.set.types[l[m]],v,T-v,g-1):t.toTree();return b.push(C),x.push(v-d),ao(o,l[m+3],c,b,x,d),new q(u,b,x,p)}s.children[r]=h(0,l.length,ht.none,0,o.length,e.length-1);for(let f of a){let c=n.tree.children[f],u=n.tree.positions[f];n.yield(new nt(c,u+n.from,f,n._tree))}}class ho{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(F.IncludeAnonymous|F.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)e.to>=t&&e.enter(i,1,F.IgnoreOverlays|F.ExcludeBuffers)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof q)e=e.children[0];else break}return!1}}let Oc=class{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(e=i.tree.prop(Mn))!==null&&e!==void 0?e:i.to,this.inner=new ho(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(Mn))!==null&&t!==void 0?t:e.to,this.inner=new ho(e.tree,-e.offset)}}findMounts(t,e){var i;let s=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let r=this.inner.cursor.node;r;r=r.parent){let o=(i=r.tree)===null||i===void 0?void 0:i.prop(P.mounted);if(o&&o.parser==e)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=r.to)break;a.tree==this.curFrag.tree&&s.push({frag:a,pos:r.from-a.offset,mount:o})}}}return s}};function fo(n,t){let e=null,i=t;for(let s=1,r=0;s<n.length;s++){let o=n[s-1].to,l=n[s].from;for(;r<i.length;r++){let a=i[r];if(a.from>=l)break;a.to<=o||(e||(i=e=t.slice()),a.from<o?(e[r]=new xt(a.from,o),a.to>l&&e.splice(r+1,0,new xt(l,a.to))):a.to>l?e[r--]=new xt(l,a.to):e.splice(r--,1))}}return i}function Dc(n,t,e,i){let s=0,r=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let f=s==n.length?1e9:o?n[s].to:n[s].from,c=r==t.length?1e9:l?t[r].to:t[r].from;if(o!=l){let u=Math.max(a,e),d=Math.min(f,c,i);u<d&&h.push(new xt(u,d))}if(a=Math.min(f,c),a==1e9)break;f==a&&(o?(o=!1,s++):o=!0),c==a&&(l?(l=!1,r++):l=!0)}return h}function co(n,t){let e=[];for(let{pos:i,mount:s,frag:r}of n){let o=i+(s.overlay?s.overlay[0].from:0),l=o+s.tree.length,a=Math.max(r.from,o),h=Math.min(r.to,l);if(s.overlay){let f=s.overlay.map(u=>new xt(u.from+i,u.to+i)),c=Dc(t,f,a,h);for(let u=0,d=a;;u++){let p=u==c.length,g=p?h:c[u].from;if(g>d&&e.push(new Ut(d,g,s.tree,-o,r.from>=d||r.openStart,r.to<=g||r.openEnd)),p)break;d=c[u].to}}else e.push(new Ut(a,h,s.tree,-o,r.from>=o||r.openStart,r.to<=l||r.openEnd))}return e}var uo={};class os{constructor(t,e,i,s,r,o,l,a,h,f=0,c){this.p=t,this.stack=e,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=f,this.parent=c}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let s=t.parser.context;return new os(t,[],e,i,i,0,[],0,s?new po(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,s=t&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=r.dynamicPrecedence(s);if(l&&(this.score+=l),i==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let a=this.stack.length-(i-1)*3-(t&262144?6:0),h=a?this.stack[a-2]:this.p.ranges[0].from,f=this.reducePos-h;f>=2e3&&!(!((e=this.p.parser.nodeSet.types[s])===null||e===void 0)&&e.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=f));let c=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-c;if(s<r.minRepeatTerm||t&131072){let d=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,h,d,u+4,!0)}if(t&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=r.getGoto(d,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,h)}storeNode(t,e,i,s=4,r=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(e==i)return;if(o.buffer[l-2]>=e){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(t,e,i,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(t,e,i,s){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let r=t,{parser:o}=this.p;this.pos=s;let l=o.stateFlag(r,1);!l&&(s>i||e<=o.maxNode)&&(this.reducePos=s),this.pushState(r,l?i:Math.min(i,this.reducePos)),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,s,4)}else this.pos=s,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,s,4)}apply(t,e,i,s){t&65536?this.reduce(t):this.shift(t,e,i,s)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(e,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),s=t.bufferBase+e;for(;t&&s==t.bufferBase;)t=t.parent;return new os(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new Pc(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if((i&65536)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let s=[];for(let r=0,o;r<e.length;r+=2)(o=e[r+1])!=this.state&&this.p.parser.hasAction(o,t)&&s.push(e[r],o);if(this.stack.length<120)for(let r=0;s.length<8&&r<e.length;r+=2){let o=e[r+1];s.some((l,a)=>a&1&&l==o)||s.push(e[r],o)}e=s}let i=[];for(let s=0;s<e.length&&i.length<4;s+=2){let r=e[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(e[s],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let i=e>>19,s=e&65535,r=this.stack.length-i*3;if(r<0||t.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;e=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(s,r)=>{if(!e.includes(s))return e.push(s),t.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&t.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new po(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class po{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class Pc{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=s}}class ls{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new ls(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new ls(this.stack,this.pos,this.index)}}function Qe(n,t=Uint16Array){if(typeof n!="string")return n;let e=null;for(let i=0,s=0;i<n.length;){let r=0;for(;;){let o=n.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}e?e[s++]=r:e=new t(r)}return e}class Gi{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const go=new Gi;class Ic{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=go,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,s=this.rangeIndex,r=this.pos+t;for(;r<i.from;){if(!s)return null;let o=this.ranges[--s];r-=i.from-o.to,i=o}for(;e<0?r>i.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,s;if(e>=0&&e<this.chunk.length)i=this.pos+t,s=this.chunk.charCodeAt(e);else{let r=this.resolveOffset(t,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=go,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let s of this.ranges){if(s.from>=e)break;s.to>t&&(i+=this.input.read(Math.max(s.from,t),Math.min(s.to,e)))}return i}}class Pe{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;fa(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}Pe.prototype.contextual=Pe.prototype.fallback=Pe.prototype.extend=!1;class Lc{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data=typeof t=="string"?Qe(t):t}token(t,e){let i=t.pos,s=0;for(;;){let r=t.next<0,o=t.resolveOffset(1,1);if(fa(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(r||s++,o==null)break;t.reset(o,t.token)}s&&(t.reset(i,t.token),t.acceptToken(this.elseToken,s))}}Lc.prototype.contextual=Pe.prototype.fallback=Pe.prototype.extend=!1;class yp{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function fa(n,t,e,i,s,r){let o=0,l=1<<i,{dialect:a}=e.p.parser;t:for(;(l&n[o])!=0;){let h=n[o+1];for(let d=o+3;d<h;d+=2)if((n[d+1]&l)>0){let p=n[d];if(a.allows(p)&&(t.token.value==-1||t.token.value==p||Rc(p,t.token.value,s,r))){t.acceptToken(p);break}}let f=t.next,c=0,u=n[o+2];if(t.next<0&&u>c&&n[h+u*3-3]==65535){o=n[h+u*3-1];continue t}for(;c<u;){let d=c+u>>1,p=h+d+(d<<1),g=n[p],m=n[p+1]||65536;if(f<g)u=d;else if(f>=m)c=d+1;else{o=n[p+2],t.advance();continue t}}break}}function mo(n,t,e){for(let i=t,s;(s=n[i])!=65535;i++)if(s==e)return i-t;return-1}function Rc(n,t,e,i){let s=mo(e,i,t);return s<0||mo(e,i,n)<s}const dt=typeof process<"u"&&uo&&/\bparse\b/.test(uo.LOG);let Ws=null;function bo(n,t,e){let i=n.cursor(F.IncludeAnonymous);for(i.moveTo(t);;)if(!(e<0?i.childBefore(t):i.childAfter(t)))for(;;){if((e<0?i.to<t:i.from>t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(n.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:n.length}}class Ec{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?bo(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?bo(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],s=this.index[e];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[s],o=this.start[e]+i.positions[s];if(o>t)return this.nextStart=o,null;if(r instanceof q){if(o==t){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(P.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[e]++,o+r.length>=Math.max(this.safeFrom,t)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+r.length}}}class Nc{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new Gi)}getActions(t){let e=0,i=null,{parser:s}=t.p,{tokenizers:r}=s,o=s.stateSlot(t.state,3),l=t.curContext?t.curContext.hash:0,a=0;for(let h=0;h<r.length;h++){if((1<<h&o)==0)continue;let f=r[h],c=this.tokens[h];if(!(i&&!f.fallback)&&((f.contextual||c.start!=t.pos||c.mask!=o||c.context!=l)&&(this.updateCachedToken(c,f,t),c.mask=o,c.context=l),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),c.value!=0)){let u=e;if(c.extended>-1&&(e=this.addActions(t,c.extended,c.end,e)),e=this.addActions(t,c.value,c.end,e),!f.extend&&(i=c,e>u))break}}for(;this.actions.length>e;)this.actions.pop();return a&&t.setLookAhead(a),!i&&t.pos==this.stream.end&&(i=new Gi,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new Gi,{pos:i,p:s}=t;return e.start=i,e.end=Math.min(i+1,s.stream.end),e.value=i==s.stream.end?s.parser.eofTerm:0,e}updateCachedToken(t,e,i){let s=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(s,t),i),t.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==t.value){let l=r.specializers[o](this.stream.read(t.start,t.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?t.value=l>>1:t.extended=l>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,e,i,s){for(let r=0;r<s;r+=3)if(this.actions[r]==t)return s;return this.actions[s++]=t,this.actions[s++]=e,this.actions[s++]=i,s}addActions(t,e,i,s){let{state:r}=t,{parser:o}=t.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(r,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=zt(l,h+2);else{s==0&&l[h+1]==2&&(s=this.putAction(zt(l,h+2),e,i,s));break}l[h]==e&&(s=this.putAction(zt(l,h+1),e,i,s))}return s}}class Fc{constructor(t,e,i,s){this.parser=t,this.input=e,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Ic(e,s),this.tokens=new Nc(t,this.stream),this.topTerm=t.top[1];let{from:r}=s[0];this.stacks=[os.start(this,t.top[0],r)],this.fragments=i.length&&this.stream.end-r>t.bufferLength*4?new Ec(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],s,r;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<t.length;o++){let l=t[o];for(;;){if(this.tokens.mainToken=null,l.pos>e)i.push(l);else{if(this.advanceStack(l,i,t))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&Vc(s);if(o)return dt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw dt&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return dt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let h=i[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue t}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let s=t.pos,{parser:r}=this,o=dt?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let h=t.curContext&&t.curContext.tracker.strict,f=h?t.curContext.hash:0;for(let c=this.fragments.nodeAt(s);c;){let u=this.parser.nodeSet.types[c.type.id]==c.type?r.getGoto(t.state,c.type.id):-1;if(u>-1&&c.length&&(!h||(c.prop(P.contextHash)||0)==f))return t.useNode(c,u),dt&&console.log(o+this.stackID(t)+` (via reuse of ${r.getName(c.type.id)})`),!0;if(!(c instanceof q)||c.children.length==0||c.positions[0]>0)break;let d=c.children[0];if(d instanceof q&&c.positions[0]==0)c=d;else break}}let l=r.stateSlot(t.state,4);if(l>0)return t.reduce(l),dt&&console.log(o+this.stackID(t)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let a=this.tokens.getActions(t);for(let h=0;h<a.length;){let f=a[h++],c=a[h++],u=a[h++],d=h==a.length||!i,p=d?t:t.split(),g=this.tokens.mainToken;if(p.apply(f,c,g?g.start:p.pos,u),dt&&console.log(o+this.stackID(p)+` (via ${(f&65536)==0?"shift":`reduce of ${r.getName(f&65535)}`} for ${r.getName(c)} @ ${s}${p==t?"":", split"})`),d)return!0;p.pos>s?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return yo(t,e),!0}}runRecovery(t,e,i){let s=null,r=!1;for(let o=0;o<t.length;o++){let l=t[o],a=e[o<<1],h=e[(o<<1)+1],f=dt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),dt&&console.log(f+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let c=l.split(),u=f;for(let d=0;d<10&&c.forceReduce()&&(dt&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));d++)dt&&(u=this.stackID(c)+" -> ");for(let d of l.recoverByInsert(a))dt&&console.log(f+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),dt&&console.log(f+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),yo(l,i)):(!s||s.score<c.score)&&(s=c)}return s}stackToTree(t){return t.close(),q.build({buffer:ls.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(Ws||(Ws=new WeakMap)).get(t);return e||Ws.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function yo(n,t){for(let e=0;e<t.length;e++){let i=t[e];if(i.pos==n.pos&&i.sameState(n)){t[e].score<n.score&&(t[e]=n);return}}t.push(n)}class Wc{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||this.disabled[t]==0}}const Vs=n=>n;class xp{constructor(t){this.start=t.start,this.shift=t.shift||Vs,this.reduce=t.reduce||Vs,this.reuse=t.reuse||Vs,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class Tn extends ha{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let l=0;l<t.repeatNodeCount;l++)e.push("");let i=Object.keys(t.topRules).map(l=>t.topRules[l][1]),s=[];for(let l=0;l<e.length;l++)s.push([]);function r(l,a,h){s[l].push([a,a.deserialize(String(h))])}if(t.nodeProps)for(let l of t.nodeProps){let a=l[0];typeof a=="string"&&(a=P[a]);for(let h=1;h<l.length;){let f=l[h++];if(f>=0)r(f,a,l[h++]);else{let c=l[h+-f];for(let u=-f;u>0;u--)r(l[h++],a,c);h++}}}this.nodeSet=new Qn(e.map((l,a)=>ht.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(a)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=ra;let o=Qe(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(xo),this.states=Qe(t.states,Uint32Array),this.data=Qe(t.stateData),this.goto=Qe(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(l=>typeof l=="number"?new Pe(o,l):l),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let s=new Fc(this,t,e,i);for(let r of this.wrappers)s=r(s,t,e,i);return s}getGoto(t,e,i=!1){let s=this.goto;if(e>=s[0])return-1;for(let r=s[e+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let h=r+(o>>1);r<h;r++)if(s[r]==t)return a;if(l)return-1}}hasAction(t,e){let i=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(t,s?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=zt(i,r+2)];else{if(i[r+1]==2)return zt(i,r+2);break}if(o==e||o==0)return zt(i,r+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,i=>i==e?!0:null)}allActions(t,e){let i=this.stateSlot(t,4),s=i?e(i):void 0;for(let r=this.stateSlot(t,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=zt(this.data,r+2);else break;s=e(zt(this.data,r+1))}return s}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=zt(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];e.some((r,o)=>o&1&&r==s)||e.push(this.data[i],s)}}return e}configure(t){let e=Object.assign(Object.create(Tn.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let s=t.tokenizers.find(r=>r.from==i);return s?s.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=t.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return e.specializers[s]=xo(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let r of t.split(" ")){let o=e.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;r<e.length;r++)if(!i[r])for(let o=this.dialects[e[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new Wc(t,i,s)}static deserialize(t){return new Tn(t)}}function zt(n,t){return n[t]|n[t+1]<<16}function Vc(n){let t=null;for(let e of n){let i=e.p.stoppedAt;(e.pos==e.p.stream.end||i!=null&&e.pos>i)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function xo(n){if(n.external){let t=n.extend?1:0;return(e,i)=>n.external(e,i)<<1|t}return n.get}let Hc=0;class bt{constructor(t,e,i,s){this.name=t,this.set=e,this.base=i,this.modified=s,this.id=Hc++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof bt&&(e=t),e!=null&&e.base)throw new Error("Can not derive from a modified tag");let s=new bt(i,[],null,[]);if(s.set.push(s),e)for(let r of e.set)s.set.push(r);return s}static defineModifier(t){let e=new as(t);return i=>i.modified.indexOf(e)>-1?i:as.get(i.base||i,i.modified.concat(e).sort((s,r)=>s.id-r.id))}}let zc=0;class as{constructor(t){this.name=t,this.instances=[],this.id=zc++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&Kc(e,l.modified));if(i)return i;let s=[],r=new bt(t.name,s,t,e);for(let l of e)l.instances.push(r);let o=$c(e);for(let l of t.set)if(!l.modified.length)for(let a of o)s.push(as.get(l,a));return r}}function Kc(n,t){return n.length==t.length&&n.every((e,i)=>e==t[i])}function $c(n){let t=[[]];for(let e=0;e<n.length;e++)for(let i=0,s=t.length;i<s;i++)t.push(t[i].concat(n[e]));return t.sort((e,i)=>i.length-e.length)}function qc(n){let t=Object.create(null);for(let e in n){let i=n[e];Array.isArray(i)||(i=[i]);for(let s of e.split(" "))if(s){let r=[],o=2,l=s;for(let c=0;;){if(l=="..."&&c>0&&c+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==s.length)break;let d=s[c++];if(c==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(c)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let f=new pi(i,o,a>0?r.slice(0,a):null);t[h]=f.sort(t[h])}}return ca.add(t)}const ca=new P({combine(n,t){let e,i,s;for(;n||t;){if(!n||t&&n.depth>=t.depth?(s=t,t=t.next):(s=n,n=n.next),e&&e.mode==s.mode&&!s.context&&!e.context)continue;let r=new pi(s.tags,s.mode,s.context);e?e.next=r:i=r,e=r}return i}});class pi{constructor(t,e,i,s){this.tags=t,this.mode=e,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}pi.empty=new pi([],2,null);function ua(n,t){let e=Object.create(null);for(let r of n)if(!Array.isArray(r.tag))e[r.tag.id]=r.class;else for(let o of r.tag)e[o.id]=r.class;let{scope:i,all:s=null}=t||{};return{style:r=>{let o=s;for(let l of r)for(let a of l.set){let h=e[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function jc(n,t){let e=null;for(let i of n){let s=i.style(t);s&&(e=e?e+" "+s:s)}return e}function Uc(n,t,e,i=0,s=n.length){let r=new Gc(i,Array.isArray(t)?t:[t],e);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class Gc{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,s,r){let{type:o,from:l,to:a}=t;if(l>=i||a<=e)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,f=_c(t)||pi.empty,c=jc(r,f.tags);if(c&&(h&&(h+=" "),h+=c,f.mode==1&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(e,l),h),f.opaque)return;let u=t.tree&&t.tree.prop(P.mounted);if(u&&u.overlay){let d=t.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),g=t.firstChild();for(let m=0,b=l;;m++){let x=m<u.overlay.length?u.overlay[m]:null,v=x?x.from+l:a,T=Math.max(e,b),C=Math.min(i,v);if(T<C&&g)for(;t.from<C&&(this.highlightRange(t,T,C,s,r),this.startSpan(Math.min(C,t.to),h),!(t.to>=v||!t.nextSibling())););if(!x||v>i)break;b=x.to+l,b>e&&(this.highlightRange(d.cursor(),Math.max(e,x.from+l),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),h))}g&&t.parent()}else if(t.firstChild()){u&&(s="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,s,r),this.startSpan(Math.min(i,t.to),h)}while(t.nextSibling());t.parent()}}}function _c(n){let t=n.type.prop(ca);for(;t&&t.context&&!n.matchContext(t.context);)t=t.next;return t||null}const k=bt.define,Wi=k(),Jt=k(),wo=k(Jt),ko=k(Jt),Xt=k(),Vi=k(Xt),Hs=k(Xt),Rt=k(),ae=k(Rt),It=k(),Lt=k(),Bn=k(),Ge=k(Bn),Hi=k(),y={comment:Wi,lineComment:k(Wi),blockComment:k(Wi),docComment:k(Wi),name:Jt,variableName:k(Jt),typeName:wo,tagName:k(wo),propertyName:ko,attributeName:k(ko),className:k(Jt),labelName:k(Jt),namespace:k(Jt),macroName:k(Jt),literal:Xt,string:Vi,docString:k(Vi),character:k(Vi),attributeValue:k(Vi),number:Hs,integer:k(Hs),float:k(Hs),bool:k(Xt),regexp:k(Xt),escape:k(Xt),color:k(Xt),url:k(Xt),keyword:It,self:k(It),null:k(It),atom:k(It),unit:k(It),modifier:k(It),operatorKeyword:k(It),controlKeyword:k(It),definitionKeyword:k(It),moduleKeyword:k(It),operator:Lt,derefOperator:k(Lt),arithmeticOperator:k(Lt),logicOperator:k(Lt),bitwiseOperator:k(Lt),compareOperator:k(Lt),updateOperator:k(Lt),definitionOperator:k(Lt),typeOperator:k(Lt),controlOperator:k(Lt),punctuation:Bn,separator:k(Bn),bracket:Ge,angleBracket:k(Ge),squareBracket:k(Ge),paren:k(Ge),brace:k(Ge),content:Rt,heading:ae,heading1:k(ae),heading2:k(ae),heading3:k(ae),heading4:k(ae),heading5:k(ae),heading6:k(ae),contentSeparator:k(Rt),list:k(Rt),quote:k(Rt),emphasis:k(Rt),strong:k(Rt),link:k(Rt),monospace:k(Rt),strikethrough:k(Rt),inserted:k(),deleted:k(),changed:k(),invalid:k(),meta:Hi,documentMeta:k(Hi),annotation:k(Hi),processingInstruction:k(Hi),definition:bt.defineModifier("definition"),constant:bt.defineModifier("constant"),function:bt.defineModifier("function"),standard:bt.defineModifier("standard"),local:bt.defineModifier("local"),special:bt.defineModifier("special")};for(let n in y){let t=y[n];t instanceof bt&&(t.name=n)}ua([{tag:y.link,class:"tok-link"},{tag:y.heading,class:"tok-heading"},{tag:y.emphasis,class:"tok-emphasis"},{tag:y.strong,class:"tok-strong"},{tag:y.keyword,class:"tok-keyword"},{tag:y.atom,class:"tok-atom"},{tag:y.bool,class:"tok-bool"},{tag:y.url,class:"tok-url"},{tag:y.labelName,class:"tok-labelName"},{tag:y.inserted,class:"tok-inserted"},{tag:y.deleted,class:"tok-deleted"},{tag:y.literal,class:"tok-literal"},{tag:y.string,class:"tok-string"},{tag:y.number,class:"tok-number"},{tag:[y.regexp,y.escape,y.special(y.string)],class:"tok-string2"},{tag:y.variableName,class:"tok-variableName"},{tag:y.local(y.variableName),class:"tok-variableName tok-local"},{tag:y.definition(y.variableName),class:"tok-variableName tok-definition"},{tag:y.special(y.variableName),class:"tok-variableName2"},{tag:y.definition(y.propertyName),class:"tok-propertyName tok-definition"},{tag:y.typeName,class:"tok-typeName"},{tag:y.namespace,class:"tok-namespace"},{tag:y.className,class:"tok-className"},{tag:y.macroName,class:"tok-macroName"},{tag:y.propertyName,class:"tok-propertyName"},{tag:y.operator,class:"tok-operator"},{tag:y.comment,class:"tok-comment"},{tag:y.meta,class:"tok-meta"},{tag:y.invalid,class:"tok-invalid"},{tag:y.punctuation,class:"tok-punctuation"}]);var zs;const Se=new P;function Yc(n){return B.define({combine:n?t=>t.concat(n):void 0})}const Jc=new P;class Mt{constructor(t,e,i=[],s=""){this.data=t,this.name=s,E.prototype.hasOwnProperty("tree")||Object.defineProperty(E.prototype,"tree",{get(){return vt(this)}}),this.parser=e,this.extension=[Ve.of(this),E.languageData.of((r,o,l)=>{let a=vo(r,o,l),h=a.type.prop(Se);if(!h)return[];let f=r.facet(h),c=a.type.prop(Jc);if(c){let u=a.resolve(o-a.from,l);for(let d of c)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(t,e,i=-1){return vo(t,e,i).type.prop(Se)==this.data}findRegions(t){let e=t.facet(Ve);if((e==null?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Se)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(P.mounted);if(l){if(l.tree.prop(Se)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof q&&s(h,r.positions[a]+o)}};return s(vt(t),0),i}get allowsNesting(){return!0}}Mt.setState=z.define();function vo(n,t,e){let i=n.facet(Ve),s=vt(n).topNode;if(!i||i.allowsNesting)for(let r=s;r;r=r.enter(t,e,F.ExcludeBuffers|F.EnterBracketed))r.type.isTop&&(s=r);return s}class On extends Mt{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Yc(t.languageData);return new On(e,t.parser.configure({props:[Se.add(i=>i.isTop?e:void 0)]}),t.name)}configure(t,e){return new On(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function vt(n){let t=n.field(Mt.state,!1);return t?t.tree:q.empty}class Xc{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let _e=null;class hs{constructor(t,e,i=[],s,r,o,l,a){this.parser=t,this.state=e,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new hs(t,e,[],q.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Xc(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=q.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(Ut.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Ut.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=_e;_e=this;try{return t()}finally{_e=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=So(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let a=[];if(t.iterChangedRanges((h,f,c,u)=>a.push({fromA:h,toA:f,fromB:c,toB:u})),i=Ut.applyChanges(i,a),s=q.empty,r=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let f=t.mapPos(h.from,1),c=t.mapPos(h.to,-1);f<c&&l.push({from:f,to:c})}}}return new hs(this.parser,e,i,s,r,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:s,to:r}=this.skipped[i];s<t.to&&r>t.from&&(this.fragments=So(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends ha{createParse(e,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=_e;if(a){for(let h of s)a.tempSkipped.push(h);t&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,t]):t)}return this.parsedPos=o,new q(ht.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return _e}}function So(n,t,e){return Ut.applyChanges(n,[{fromA:t,toA:e,fromB:t,toB:e}])}class We{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new We(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=hs.create(t.facet(Ve).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new We(i)}}Mt.state=_t.define({create:We.init,update(n,t){for(let e of t.effects)if(e.is(Mt.setState))return e.value;return t.startState.facet(Ve)!=t.state.facet(Ve)?We.init(t.state):n.apply(t)}});let da=n=>{let t=setTimeout(()=>n(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(da=n=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(n,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const Ks=typeof navigator<"u"&&(!((zs=navigator.scheduling)===null||zs===void 0)&&zs.isInputPending)?()=>navigator.scheduling.isInputPending():null,Qc=Vt.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Mt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Mt.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=da(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,r=i.field(Mt.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Ks?Math.max(25,t.timeRemaining()-5):1e9),l=r.context.treeLen<s&&i.doc.length>s+1e3,a=r.context.work(()=>Ks&&Ks()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Mt.setState.of(new We(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>gt(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ve=B.define({combine(n){return n.length?n[0]:null},enables:n=>[Mt.state,Qc,O.contentAttributes.compute([n],t=>{let e=t.facet(n);return e&&e.name?{"data-language":e.name}:{}})]});class kp{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const Zc=B.define(),ks=B.define({combine:n=>{if(!n.length)return" ";let t=n[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return t}});function fs(n){let t=n.facet(ks);return t.charCodeAt(0)==9?n.tabSize*t.length:t.length}function cs(n,t){let e="",i=n.tabSize,s=n.facet(ks)[0];if(s==" "){for(;t>=i;)e+=" ",t-=i;s=" "}for(let r=0;r<t;r++)e+=s;return e}function pa(n,t){n instanceof E&&(n=new vs(n));for(let i of n.state.facet(Zc)){let s=i(n,t);if(s!==void 0)return s}let e=vt(n.state);return e.length>=t?eu(n,e,t):null}class vs{constructor(t,e={}){this.state=t,this.options=e,this.unit=fs(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(t,e);return i.slice(t-s,Math.min(i.length,t+100-s))}column(t,e=1){let{text:i,from:s}=this.lineAt(t,e),r=this.countColumn(i,t-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return gs(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:s}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const tu=new P;function eu(n,t,e){let i=t.resolveStack(e),s=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(s!=i.node){let r=[];for(let o=s;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return ga(i,n,e)}function ga(n,t,e){for(let i=n;i;i=i.next){let s=su(i.node);if(s)return s(ir.create(t,e,i))}return 0}function iu(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function su(n){let t=n.type.prop(tu);if(t)return t;let e=n.firstChild,i;if(e&&(i=e.type.prop(P.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>ma(o,!0,1,void 0,r&&!iu(o)?s.from:void 0)}return n.parent==null?nu:null}function nu(){return 0}class ir extends vs{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new ir(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(ru(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return ga(this.context.next,this.base,this.pos)}}function ru(n,t){for(let e=t;e;e=e.parent)if(n==e)return!0;return!1}function ou(n){let t=n.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(e.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=e.to;;){let a=t.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(e.to-r.from))[0].length;return{from:e.from,to:e.to+h}}l=a.to}}function vp({closing:n,align:t=!0,units:e=1}){return i=>ma(i,t,e,n)}function ma(n,t,e,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=t?ou(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*e)}const Sp=n=>n.baseIndent;function Cp({except:n,units:t=1}={}){return e=>{let i=n&&n.test(e.textAfter);return e.baseIndent+(i?0:t*e.unit)}}const Ap=new P;function Mp(n){let t=n.firstChild,e=n.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?n.to:e.from}:null}class wi{constructor(t,e){this.specs=t;let i;function s(l){let a=ee.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof e.all=="string"?e.all:e.all?s(e.all):void 0,o=e.scope;this.scope=o instanceof Mt?l=>l.prop(Se)==o.data:o?l=>l==o:void 0,this.style=ua(t.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new ee(i):null,this.themeType=e.themeType}static define(t,e){return new wi(t,e||{})}}const Dn=B.define(),lu=B.define({combine(n){return n.length?[n[0]]:null}});function $s(n){let t=n.facet(Dn);return t.length?t:n.facet(lu)}function au(n,t){let e=[fu],i;return n instanceof wi&&(n.module&&e.push(O.styleModule.of(n.module)),i=n.themeType),i?e.push(Dn.computeN([O.darkTheme],s=>s.facet(O.darkTheme)==(i=="dark")?[n]:[])):e.push(Dn.of(n)),e}class hu{constructor(t){this.markCache=Object.create(null),this.tree=vt(t.state),this.decorations=this.buildDeco(t,$s(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=vt(t.state),i=$s(t.state),s=i!=$s(t.startState),{viewport:r}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!s&&e.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return K.none;let i=new oi;for(let{from:s,to:r}of t.visibleRanges)Uc(this.tree,e,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=K.mark({class:a})))},s,r);return i.finish()}}const fu=He.high(Vt.fromClass(hu,{decorations:n=>n.decorations})),Tp=wi.define([{tag:y.meta,color:"#404740"},{tag:y.link,textDecoration:"underline"},{tag:y.heading,textDecoration:"underline",fontWeight:"bold"},{tag:y.emphasis,fontStyle:"italic"},{tag:y.strong,fontWeight:"bold"},{tag:y.strikethrough,textDecoration:"line-through"},{tag:y.keyword,color:"#708"},{tag:[y.atom,y.bool,y.url,y.contentSeparator,y.labelName],color:"#219"},{tag:[y.literal,y.inserted],color:"#164"},{tag:[y.string,y.deleted],color:"#a11"},{tag:[y.regexp,y.escape,y.special(y.string)],color:"#e40"},{tag:y.definition(y.variableName),color:"#00f"},{tag:y.local(y.variableName),color:"#30a"},{tag:[y.typeName,y.namespace],color:"#085"},{tag:y.className,color:"#167"},{tag:[y.special(y.variableName),y.macroName],color:"#256"},{tag:y.definition(y.propertyName),color:"#00c"},{tag:y.comment,color:"#940"},{tag:y.invalid,color:"#f00"}]),cu=1e4,uu="()[]{}",du=new P;function Pn(n,t,e){let i=n.prop(t<0?P.openedBy:P.closedBy);if(i)return i;if(n.name.length==1){let s=e.indexOf(n.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function In(n){let t=n.type.prop(du);return t?t(n.node):n}function Ce(n,t,e,i={}){let s=i.maxScanDistance||cu,r=i.brackets||uu,o=vt(n),l=o.resolveInner(t,e);for(let a=l;a;a=a.parent){let h=Pn(a.type,e,r);if(h&&a.from<a.to){let f=In(a);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return pu(n,t,e,a,f,h,r)}}return gu(n,t,e,o,l.type,s,r)}function pu(n,t,e,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},h=0,f=l==null?void 0:l.cursor();if(f&&(e<0?f.childBefore(i.from):f.childAfter(i.to)))do if(e<0?f.to<=i.from:f.from>=i.to){if(h==0&&r.indexOf(f.type.name)>-1&&f.from<f.to){let c=In(f);return{start:a,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(Pn(f.type,e,o))h++;else if(Pn(f.type,-e,o)){if(h==0){let c=In(f);return{start:a,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(e<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function gu(n,t,e,i,s,r,o){let l=e<0?n.sliceDoc(t-1,t):n.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=e>0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},f=n.doc.iterRange(t,e>0?n.doc.length:0),c=0;for(let u=0;!f.next().done&&u<=r;){let d=f.value;e<0&&(u+=d.length);let p=t+u*e;for(let g=e>0?0:d.length-1,m=e>0?d.length:-1;g!=m;g+=e){let b=o.indexOf(d[g]);if(!(b<0||i.resolveInner(p+g,1).type!=s))if(b%2==0==e>0)c++;else{if(c==1)return{start:h,end:{from:p+g,to:p+g+1},matched:b>>1==a>>1};c--}}e>0&&(u+=d.length)}return f.done?{start:h,matched:!1}:null}const mu=Object.create(null),Co=[ht.none],Ao=[],Mo=Object.create(null),bu=Object.create(null);for(let[n,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])bu[n]=yu(mu,t);function qs(n,t){Ao.indexOf(n)>-1||(Ao.push(n),console.warn(t))}function yu(n,t){let e=[];for(let l of t.split(" ")){let a=[];for(let h of l.split(".")){let f=n[h]||y[h];f?typeof f=="function"?a.length?a=a.map(f):qs(h,`Modifier ${h} used at start of tag`):a.length?qs(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:qs(h,`Unknown highlighting tag ${h}`)}for(let h of a)e.push(h)}if(!e.length)return 0;let i=t.replace(/ /g,"_"),s=i+" "+e.map(l=>l.id),r=Mo[s];if(r)return r.id;let o=Mo[s]=ht.define({id:Co.length,name:i,props:[qc({[i]:e})]});return Co.push(o),o.id}G.RTL,G.LTR;class ba{constructor(t,e,i,s){this.state=t,this.pos=e,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=vt(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),s=e.text.slice(i-e.from,this.pos-e.from),r=s.search(ya(t,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(t,e,i){t=="abort"&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function To(n){let t=Object.keys(n).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function xu(n){let t=Object.create(null),e=Object.create(null);for(let{label:s}of n){t[s[0]]=!0;for(let r=1;r<s.length;r++)e[s[r]]=!0}let i=To(t)+To(e)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function wu(n){let t=n.map(s=>typeof s=="string"?{label:s}:s),[e,i]=t.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:xu(t);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:t,validFor:e}:null}}function Bp(n,t){return e=>{for(let i=vt(e.state).resolveInner(e.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return t(e)}}class Bo{constructor(t,e,i,s){this.completion=t,this.source=e,this.match=i,this.score=s}}function pe(n){return n.selection.main.from}function ya(n,t){var e;let{source:i}=n,s=t&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(e=n.flags)!==null&&e!==void 0?e:n.ignoreCase?"i":"")}const sr=ye.define();function ku(n,t,e,i){let{main:s}=n.selection,r=e-s.from,o=i-s.from;return{...n.changeByRange(l=>{if(l!=s&&e!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(e,i))return{range:l};let a=n.toText(t);return{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:a},range:w.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Oo=new WeakMap;function vu(n){if(!Array.isArray(n))return n;let t=Oo.get(n);return t||Oo.set(n,t=wu(n)),t}const us=z.define(),gi=z.define();class Su{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=he(t,e),s=we(i);this.chars.push(i);let r=t.slice(e,e+s),o=r.toUpperCase();this.folded.push(he(o==r?r.toLowerCase():o,0)),e+=s}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:s,precise:r,byWord:o}=this;if(e.length==1){let x=he(t,0),v=we(x),T=v==t.length?0:-100;if(x!=e[0])if(x==i[0])T+=-200;else return null;return this.ret(T,[0,v])}let l=t.indexOf(this.pattern);if(l==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,h=0;if(l<0){for(let x=0,v=Math.min(t.length,200);x<v&&h<a;){let T=he(t,x);(T==e[h]||T==i[h])&&(s[h++]=x),x+=we(T)}if(h<a)return null}let f=0,c=0,u=!1,d=0,p=-1,g=-1,m=/[a-z]/.test(t),b=!0;for(let x=0,v=Math.min(t.length,200),T=0;x<v&&c<a;){let C=he(t,x);l<0&&(f<a&&C==e[f]&&(r[f++]=x),d<a&&(C==e[d]||C==i[d]?(d==0&&(p=x),g=x+1,d++):d=0));let M,A=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(M=nh(C))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!x||A==1&&m||T==0&&A!=0)&&(e[c]==C||i[c]==C&&(u=!0)?o[c++]=x:o.length&&(b=!1)),T=A,x+=we(C)}return c==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,t):d==a&&p==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==a?this.ret(-900-t.length,[p,g]):c==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,t):e.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,t)}result(t,e,i){let s=[],r=0;for(let o of e){let l=o+(this.astral?we(he(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(t-i.length,s)}}class Cu{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const X=B.define({combine(n){return mh(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Au,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>Do(t(i),e(i)),optionClass:(t,e)=>i=>Do(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})}});function Do(n,t){return n?t?n+" "+t:n:t}function Au(n,t,e,i,s,r){let o=n.textDirection==G.RTL,l=o,a=!1,h="top",f,c,u=t.left-s.left,d=s.right-t.right,p=i.right-i.left,g=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))f=Math.max(s.top,Math.min(e.top,s.bottom-g))-t.top,c=Math.min(400,l?u:d);else{a=!0,c=Math.min(400,(o?t.right:s.right-t.left)-30);let x=s.bottom-t.bottom;x>=g||x>t.top?f=e.bottom-t.top:(h="bottom",f=t.bottom-e.top)}let m=(t.bottom-t.top)/r.offsetHeight,b=(t.right-t.left)/r.offsetWidth;return{style:`${h}: ${f/m}px; max-width: ${c/b}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const nr=z.define();function Mu(n){let t=n.addToOptions.slice();return n.icons&&t.push({render(e){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),e.type&&i.classList.add(...e.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),t.push({render(e,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=e.displayLabel||e.label,a=0;for(let h=0;h<r.length;){let f=r[h++],c=r[h++];f>a&&o.appendChild(document.createTextNode(l.slice(a,f)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(f,c))),u.className="cm-completionMatchedText",a=c}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(e){if(!e.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=e.detail,i},position:80}),t.sort((e,i)=>e.position-i.position).map(e=>e.render)}function js(n,t,e){if(n<=e)return{from:0,to:n};if(t<0&&(t=0),t<=n>>1){let s=Math.floor(t/e);return{from:s*e,to:(s+1)*e}}let i=Math.floor((n-t)/e);return{from:n-(i+1)*e,to:n-i*e}}class Tu{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=t.state.field(e),{options:r,selected:o}=s.open,l=t.state.facet(X);this.optionContent=Mu(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=js(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=t.state.field(e).open;for(let f=a.target,c;f&&f!=this.dom;f=f.parentNode)if(f.nodeName=="LI"&&(c=/-(\d+)$/.exec(f.id))&&+c[1]<h.length){this.applyCompletion(t,h[+c[1]]),a.preventDefault();return}if(a.target==this.list){let f=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;f!=null&&(t.dispatch({effects:nr.of(f)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=t.state.field(this.stateField,!1);h&&h.tooltip&&t.state.facet(X).closeOnBlur&&a.relatedTarget!=t.contentDOM&&t.dispatch({effects:gi.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let i=t.state.field(this.stateField),s=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=js(r.length,o,t.state.facet(X).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((e=s.open)===null||e===void 0?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of e.split(" "))i&&this.dom.classList.add(i);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=js(e.options.length,e.selected,this.view.state.facet(X).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:s}=e.options[e.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(l,s)}).catch(l=>gt(this.view.state,l,"completion info")):(this.addInfoPane(o,s),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),t.nodeType!=null)i.appendChild(t),this.infoDestroy=null;else{let{dom:s,destroy:r}=t;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return e&&Ou(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=t.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,e.bottom)-10||s.bottom<Math.max(r.top,e.top)+10?null:this.view.state.facet(X).positionInfo(this.view,e,s,i,r,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const s=document.createElement("ul");s.id=e,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=t[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof h!="string"&&h.header)s.appendChild(h.header(h));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const f=s.appendChild(document.createElement("li"));f.id=e+"-"+o,f.setAttribute("role","option");let c=this.optionClass(l);c&&(f.className=c);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&f.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Bu(n,t){return e=>new Tu(e,n,t)}function Ou(n,t){let e=n.getBoundingClientRect(),i=t.getBoundingClientRect(),s=e.height/n.offsetHeight;i.top<e.top?n.scrollTop-=(e.top-i.top)/s:i.bottom>e.bottom&&(n.scrollTop+=(i.bottom-e.bottom)/s)}function Po(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Du(n,t){let e=[],i=null,s=null,r=f=>{e.push(f);let{section:c}=f.completion;if(c){i||(i=[]);let u=typeof c=="string"?c:c.name;i.some(d=>d.name==u)||i.push(typeof c=="string"?{name:u}:c)}},o=t.facet(X);for(let f of n)if(f.hasResult()){let c=f.result.getMatch;if(f.result.filter===!1)for(let u of f.result.options)r(new Bo(u,f.source,c?c(u):[],1e9-e.length));else{let u=t.sliceDoc(f.from,f.to),d,p=o.filterStrict?new Cu(u):new Su(u);for(let g of f.result.options)if(d=p.match(g.label)){let m=g.displayLabel?c?c(g,d.matched):[]:d.matched,b=d.score+(g.boost||0);if(r(new Bo(g,f.source,m,b)),typeof g.section=="object"&&g.section.rank==="dynamic"){let{name:x}=g.section;s||(s=Object.create(null)),s[x]=Math.max(b,s[x]||-1e9)}}}}if(i){let f=Object.create(null),c=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?s[p.name]-s[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(u))c-=1e5,f[d.name]=c;for(let d of e){let{section:p}=d.completion;p&&(d.score+=f[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let f of e.sort((c,u)=>u.score-c.score||h(c.completion,u.completion))){let c=f.completion;!a||a.label!=c.label||a.detail!=c.detail||a.type!=null&&c.type!=null&&a.type!=c.type||a.apply!=c.apply||a.boost!=c.boost?l.push(f):Po(f.completion)>Po(a)&&(l[l.length-1]=f),a=f.completion}return l}class Ae{constructor(t,e,i,s,r,o){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new Ae(this.options,Io(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,s,r,o){if(s&&!o&&t.some(h=>h.isPending))return s.setDisabled();let l=Du(t,e);if(!l.length)return s&&t.some(h=>h.isPending)?s.setDisabled():null;let a=e.facet(X).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let h=s.options[s.selected].completion;for(let f=0;f<l.length;f++)if(l[f].completion==h){a=f;break}}return new Ae(l,Io(i,a),{pos:t.reduce((h,f)=>f.hasResult()?Math.min(h,f.from):h,1e8),create:Nu,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(t){return new Ae(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ae(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ds{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new ds(Ru,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:e}=t,i=e.facet(X),r=(i.override||e.languageDataAt("autocomplete",pe(e)).map(vu)).map(a=>(this.active.find(f=>f.source==a)||new wt(a,this.active.some(f=>f.state!=0)?1:0)).update(t,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=t.effects.some(a=>a.is(rr));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||r.some(a=>a.hasResult()&&t.changes.touchesRange(a.from,a.to))||!Pu(r,this.active)||l?o=Ae.build(r,e,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new wt(a.source,0):a));for(let a of t.effects)a.is(nr)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new ds(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Iu:Lu}}function Pu(n,t){if(n==t)return!0;for(let e=0,i=0;;){for(;e<n.length&&!n[e].hasResult();)e++;for(;i<t.length&&!t[i].hasResult();)i++;let s=e==n.length,r=i==t.length;if(s||r)return s==r;if(n[e++].result!=t[i++].result)return!1}}const Iu={"aria-autocomplete":"list"},Lu={};function Io(n,t){let e={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return t>-1&&(e["aria-activedescendant"]=n+"-"+t),e}const Ru=[];function xa(n,t){if(n.isUserEvent("input.complete")){let i=n.annotation(sr);if(i&&t.activateOnCompletion(i))return 12}let e=n.isUserEvent("input.type");return e&&t.activateOnTyping?5:e?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class wt{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(t,e){let i=xa(t,e),s=this;(i&8||i&16&&this.touches(t))&&(s=new wt(s.source,0)),i&4&&s.state==0&&(s=new wt(this.source,1)),s=s.updateFor(t,i);for(let r of t.effects)if(r.is(us))s=new wt(s.source,1,r.value);else if(r.is(gi))s=new wt(s.source,0);else if(r.is(rr))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(pe(t.state))}}class Ie extends wt{constructor(t,e,i,s,r,o){super(t,3,e),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(t,e){var i;if(!(e&3))return this.map(t.changes);let s=this.result;s.map&&!t.changes.empty&&(s=s.map(s,t.changes));let r=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),l=pe(t.state);if(l>o||!s||e&2&&(pe(t.startState)==this.from||l<this.limit))return new wt(this.source,e&4?1:0);let a=t.changes.mapPos(this.limit);return Eu(s.validFor,t.state,r,o)?new Ie(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new ba(t.state,l,!1)))?new Ie(this.source,this.explicit,a,s,s.from,(i=s.to)!==null&&i!==void 0?i:pe(t.state)):new wt(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Ie(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new wt(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Eu(n,t,e,i){if(!n)return!1;let s=t.sliceDoc(e,i);return typeof n=="function"?n(s,e,i,t):ya(n,!0).test(s)}const rr=z.define({map(n,t){return n.map(e=>e.map(t))}}),ft=_t.define({create(){return ds.start()},update(n,t){return n.update(t)},provide:n=>[sa.from(n,t=>t.tooltip),O.contentAttributes.from(n,t=>t.attrs)]});function or(n,t){const e=t.completion.apply||t.completion.label;let i=n.state.field(ft).active.find(s=>s.source==t.source);return i instanceof Ie?(typeof e=="string"?n.dispatch({...ku(n.state,e,i.from,i.to),annotations:sr.of(t.completion)}):e(n,t.completion,i.from,i.to),!0):!1}const Nu=Bu(ft,or);function zi(n,t="option"){return e=>{let i=e.state.field(ft,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<e.state.facet(X).interactionDelay)return!1;let s=1,r;t=="page"&&(r=na(e,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=t=="page"?0:o-1:l>=o&&(l=t=="page"?o-1:0),e.dispatch({effects:nr.of(l)}),!0}}const Fu=n=>{let t=n.state.field(ft,!1);return n.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<n.state.facet(X).interactionDelay?!1:or(n,t.open.options[t.open.selected])},Us=n=>n.state.field(ft,!1)?(n.dispatch({effects:us.of(!0)}),!0):!1,Wu=n=>{let t=n.state.field(ft,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(n.dispatch({effects:gi.of(null)}),!0)};class Vu{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const Hu=50,zu=1e3,Ku=Vt.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of n.state.field(ft).active)t.isPending&&this.startQuery(t)}update(n){let t=n.state.field(ft),e=n.state.facet(X);if(!n.selectionSet&&!n.docChanged&&n.startState.field(ft)==t)return;let i=n.transactions.some(r=>{let o=xa(r,e);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>Hu&&Date.now()-o.time>zu){for(let l of o.context.abortListeners)try{l()}catch(a){gt(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(us)))&&(this.pendingStart=!0);let s=this.pendingStart?50:e.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,t=n.field(ft);for(let e of t.active)e.isPending&&!this.running.some(i=>i.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(X).updateSyncTime))}startQuery(n){let{state:t}=this.view,e=pe(t),i=new ba(t,e,n.explicit,this.view),s=new Vu(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:gi.of(null)}),gt(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(X).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],e=this.view.state.facet(X),i=this.view.state.field(ft);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=pe(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),h=new Ie(r.active.source,r.active.explicit,a,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:l);for(let f of r.updates)h=h.update(f,e);if(h.hasResult()){t.push(h);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new wt(r.active.source,0);for(let a of r.updates)l=l.update(a,e);l.isPending||t.push(l)}else this.startQuery(o)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:rr.of(t)})}},{eventHandlers:{blur(n){let t=this.view.state.field(ft,!1);if(t&&t.tooltip&&this.view.state.facet(X).closeOnBlur){let e=t.open&&na(this.view,t.open.tooltip);(!e||!e.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:gi.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:us.of(!1)}),20),this.composing=0}}}),$u=typeof navigator=="object"&&/Win/.test(navigator.platform),qu=He.highest(O.domEventHandlers({keydown(n,t){let e=t.state.field(ft,!1);if(!e||!e.open||e.open.disabled||e.open.selected<0||n.key.length>1||n.ctrlKey&&!($u&&n.altKey)||n.metaKey)return!1;let i=e.open.options[e.open.selected],s=e.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&or(t,i),!1}})),wa=O.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class ju{constructor(t,e,i,s){this.field=t,this.line=e,this.from=i,this.to=s}}class lr{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,lt.TrackDel),i=t.mapPos(this.to,1,lt.TrackDel);return e==null||i==null?null:new lr(this.field,e,i)}}class ar{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],s=[e],r=t.doc.lineAt(e),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,f=/^\t*/.exec(a)[0].length;for(let c=0;c<f;c++)h+=t.facet(ks);s.push(e+h.length-f),a=h+a.slice(f)}i.push(a),e+=a.length+1}let l=this.fieldPositions.map(a=>new lr(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(t){let e=[],i=[],s=[],r;for(let o of t.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1,f=a.replace(/\\[{}]/g,c=>c[1]);for(let c=0;c<e.length;c++)(l!=null?e[c].seq==l:f&&e[c].name==f)&&(h=c);if(h<0){let c=0;for(;c<e.length&&(l==null||e[c].seq!=null&&e[c].seq<l);)c++;e.splice(c,0,{seq:l,name:f}),h=c;for(let u of s)u.field>=h&&u.field++}for(let c of s)if(c.line==i.length&&c.from>r.index){let u=r[2]?3+(r[1]||"").length:2;c.from-=u,c.to-=u}s.push(new ju(h,i.length,r.index,r.index+f.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let f of s)f.line==i.length&&f.from>h&&(f.from--,f.to--);return a}),i.push(o)}return new ar(i,s)}}let Uu=K.widget({widget:new class extends ze{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Gu=K.mark({class:"cm-snippetField"});class Ke{constructor(t,e){this.ranges=t,this.active=e,this.deco=K.set(t.map(i=>(i.from==i.to?Uu:Gu).range(i.from,i.to)),!0)}map(t){let e=[];for(let i of this.ranges){let s=i.map(t);if(!s)return null;e.push(s)}return new Ke(e,this.active)}selectionInsideField(t){return t.ranges.every(e=>this.ranges.some(i=>i.field==this.active&&i.from<=e.from&&i.to>=e.to))}}const ki=z.define({map(n,t){return n&&n.map(t)}}),_u=z.define(),mi=_t.define({create(){return null},update(n,t){for(let e of t.effects){if(e.is(ki))return e.value;if(e.is(_u)&&n)return new Ke(n.ranges,e.value)}return n&&t.docChanged&&(n=n.map(t.changes)),n&&t.selection&&!n.selectionInsideField(t.selection)&&(n=null),n},provide:n=>O.decorations.from(n,t=>t?t.deco:K.none)});function hr(n,t){return w.create(n.filter(e=>e.field==t).map(e=>w.range(e.from,e.to)))}function Yu(n){let t=ar.parse(n);return(e,i,s,r)=>{let{text:o,ranges:l}=t.instantiate(e.state,s),{main:a}=e.state.selection,h={changes:{from:s,to:r==a.from?a.to:r,insert:L.of(o)},scrollIntoView:!0,annotations:i?[sr.of(i),et.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=hr(l,0)),l.some(f=>f.field>0)){let f=new Ke(l,0),c=h.effects=[ki.of(f)];e.state.field(mi,!1)===void 0&&c.push(z.appendConfig.of([mi,td,ed,wa]))}e.dispatch(e.state.update(h))}}function ka(n){return({state:t,dispatch:e})=>{let i=t.field(mi,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return e(t.update({selection:hr(i.ranges,s),effects:ki.of(r?null:new Ke(i.ranges,s)),scrollIntoView:!0})),!0}}const Ju=({state:n,dispatch:t})=>n.field(mi,!1)?(t(n.update({effects:ki.of(null)})),!0):!1,Xu=ka(1),Qu=ka(-1),Zu=[{key:"Tab",run:Xu,shift:Qu},{key:"Escape",run:Ju}],Lo=B.define({combine(n){return n.length?n[0]:Zu}}),td=He.highest(Xn.compute([Lo],n=>n.facet(Lo)));function Op(n,t){return{...t,apply:Yu(n)}}const ed=O.domEventHandlers({mousedown(n,t){let e=t.state.field(mi,!1),i;if(!e||(i=t.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=e.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==e.active?!1:(t.dispatch({selection:hr(e.ranges,s.field),effects:ki.of(e.ranges.some(r=>r.field>s.field)?new Ke(e.ranges,s.field):null),scrollIntoView:!0}),!0)}}),va=new class extends te{};va.startSide=1;va.endSide=-1;function Dp(n={}){return[qu,ft,X.of(n),Ku,sd,wa]}const id=[{key:"Ctrl-Space",run:Us},{mac:"Alt-`",run:Us},{mac:"Alt-i",run:Us},{key:"Escape",run:Wu},{key:"ArrowDown",run:zi(!0)},{key:"ArrowUp",run:zi(!1)},{key:"PageDown",run:zi(!0,"page")},{key:"PageUp",run:zi(!1,"page")},{key:"Enter",run:Fu}],sd=He.highest(Xn.computeN([X],n=>n.facet(X).defaultKeymap?[id]:[])),nd=n=>{let{state:t}=n,e=t.doc.lineAt(t.selection.main.from),i=cr(n.state,e.from);return i.line?rd(n):i.block?ld(n):!1};function fr(n,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let s=n(t,e);return s?(i(e.update(s)),!0):!1}}const rd=fr(fd,0),od=fr(Sa,0),ld=fr((n,t)=>Sa(n,t,hd(t)),0);function cr(n,t){let e=n.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}const Ye=50;function ad(n,{open:t,close:e},i,s){let r=n.sliceDoc(i-Ye,i),o=n.sliceDoc(s,s+Ye),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-t.length,h)==t&&o.slice(a,a+e.length)==e)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let f,c;s-i<=2*Ye?f=c=n.sliceDoc(i,s):(f=n.sliceDoc(i,i+Ye),c=n.sliceDoc(s-Ye,s));let u=/^\s*/.exec(f)[0].length,d=/\s*$/.exec(c)[0].length,p=c.length-d-e.length;return f.slice(u,u+t.length)==t&&c.slice(p,p+e.length)==e?{open:{pos:i+u+t.length,margin:/\s/.test(f.charAt(u+t.length))?1:0},close:{pos:s-d-e.length,margin:/\s/.test(c.charAt(p-1))?1:0}}:null}function hd(n){let t=[];for(let e of n.selection.ranges){let i=n.doc.lineAt(e.from),s=e.to<=i.to?i:n.doc.lineAt(e.to);s.from>i.from&&s.from==e.to&&(s=e.to==i.to+1?i:n.doc.lineAt(e.to-1));let r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=s.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return t}function Sa(n,t,e=t.selection.ranges){let i=e.map(r=>cr(t,r.from).block);if(!i.every(r=>r))return null;let s=e.map((r,o)=>ad(t,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:t.changes(e.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:h,close:f}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:f.pos-f.margin,to:f.pos+a.close.length})}return{changes:r}}return null}function fd(n,t,e=t.selection.ranges){let i=[],s=-1;t:for(let{from:r,to:o}of e){let l=i.length,a=1e9,h;for(let f=r;f<=o;){let c=t.doc.lineAt(f);if(h==null&&(h=cr(t,c.from).line,!h))continue t;if(c.from>s&&(r==o||o>c.from)){s=c.from;let u=/^\s*/.exec(c.text)[0].length,d=u==c.length,p=c.text.slice(u,u+h.length)==h?u:-1;u<c.text.length&&u<a&&(a=u),i.push({line:c,comment:p,token:h,indent:u,empty:d,single:!1})}f=c.to+1}if(a<1e9)for(let f=l;f<i.length;f++)i[f].indent<i[f].line.text.length&&(i[f].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:f,single:c}of i)(c||!f)&&r.push({from:l.from+h,insert:a+" "});let o=t.changes(r);return{changes:o,selection:t.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,f=h+a.length;o.text[f-o.from]==" "&&f++,r.push({from:h,to:f})}return{changes:r}}return null}function $e(n,t){return w.create(n.ranges.map(t),n.mainIndex)}function Bt(n,t){return n.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Ot({state:n,dispatch:t},e){let i=$e(n.selection,e);return i.eq(n.selection,!0)?!1:(t(Bt(n,i)),!0)}function Ss(n,t){return w.cursor(t?n.to:n.from)}function Ca(n,t){return Ot(n,e=>e.empty?n.moveByChar(e,t):Ss(e,t))}function rt(n){return n.textDirectionAt(n.state.selection.main.head)==G.LTR}const Aa=n=>Ca(n,!rt(n)),Ma=n=>Ca(n,rt(n));function Ta(n,t){return Ot(n,e=>e.empty?n.moveByGroup(e,t):Ss(e,t))}const cd=n=>Ta(n,!rt(n)),ud=n=>Ta(n,rt(n));function dd(n,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(t.from,t.to)))||t.firstChild}function Cs(n,t,e){let i=vt(n).resolveInner(t.head),s=e?P.closedBy:P.openedBy;for(let a=t.head;;){let h=e?i.childAfter(a):i.childBefore(a);if(!h)break;dd(n,h,s)?i=h:a=e?h.to:h.from}let r=i.type.prop(s),o,l;return r&&(o=e?Ce(n,i.from,1):Ce(n,i.to,-1))&&o.matched?l=e?o.end.to:o.end.from:l=e?i.to:i.from,w.cursor(l,e?-1:1)}const pd=n=>Ot(n,t=>Cs(n.state,t,!rt(n))),gd=n=>Ot(n,t=>Cs(n.state,t,rt(n)));function Ba(n,t){return Ot(n,e=>{if(!e.empty)return Ss(e,t);let i=n.moveVertically(e,t);return i.head!=e.head?i:n.moveToLineBoundary(e,t)})}const Oa=n=>Ba(n,!1),Da=n=>Ba(n,!0);function Pa(n){let t=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,e=0,i=0,s;if(t){for(let r of n.state.facet(O.scrollMargins)){let o=r(n);o!=null&&o.top&&(e=Math.max(o==null?void 0:o.top,e)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}s=n.scrollDOM.clientHeight-e-i}else s=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(n.defaultLineHeight,s-5)}}function Ia(n,t){let e=Pa(n),{state:i}=n,s=$e(i.selection,o=>o.empty?n.moveVertically(o,t,e.height):Ss(o,t));if(s.eq(i.selection))return!1;let r;if(e.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+e.marginTop,h=l.bottom-e.marginBottom;o&&o.top>a&&o.bottom<h&&(r=O.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(Bt(i,s),{effects:r}),!0}const Ro=n=>Ia(n,!1),Ln=n=>Ia(n,!0);function re(n,t,e){let i=n.lineBlockAt(t.head),s=n.moveToLineBoundary(t,e);if(s.head==t.head&&s.head!=(e?i.to:i.from)&&(s=n.moveToLineBoundary(t,e,!1)),!e&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&t.head!=i.from+r&&(s=w.cursor(i.from+r))}return s}const md=n=>Ot(n,t=>re(n,t,!0)),bd=n=>Ot(n,t=>re(n,t,!1)),yd=n=>Ot(n,t=>re(n,t,!rt(n))),xd=n=>Ot(n,t=>re(n,t,rt(n))),wd=n=>Ot(n,t=>w.cursor(n.lineBlockAt(t.head).from,1)),kd=n=>Ot(n,t=>w.cursor(n.lineBlockAt(t.head).to,-1));function vd(n,t,e){let i=!1,s=$e(n.selection,r=>{let o=Ce(n,r.head,-1)||Ce(n,r.head,1)||r.head>0&&Ce(n,r.head-1,1)||r.head<n.doc.length&&Ce(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return w.cursor(l)});return i?(t(Bt(n,s)),!0):!1}const Sd=({state:n,dispatch:t})=>vd(n,t);function St(n,t){let e=$e(n.state.selection,i=>{let s=t(i);return w.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return e.eq(n.state.selection)?!1:(n.dispatch(Bt(n.state,e)),!0)}function La(n,t){return St(n,e=>n.moveByChar(e,t))}const Ra=n=>La(n,!rt(n)),Ea=n=>La(n,rt(n));function Na(n,t){return St(n,e=>n.moveByGroup(e,t))}const Cd=n=>Na(n,!rt(n)),Ad=n=>Na(n,rt(n)),Md=n=>St(n,t=>Cs(n.state,t,!rt(n))),Td=n=>St(n,t=>Cs(n.state,t,rt(n)));function Fa(n,t){return St(n,e=>n.moveVertically(e,t))}const Wa=n=>Fa(n,!1),Va=n=>Fa(n,!0);function Ha(n,t){return St(n,e=>n.moveVertically(e,t,Pa(n).height))}const Eo=n=>Ha(n,!1),No=n=>Ha(n,!0),Bd=n=>St(n,t=>re(n,t,!0)),Od=n=>St(n,t=>re(n,t,!1)),Dd=n=>St(n,t=>re(n,t,!rt(n))),Pd=n=>St(n,t=>re(n,t,rt(n))),Id=n=>St(n,t=>w.cursor(n.lineBlockAt(t.head).from)),Ld=n=>St(n,t=>w.cursor(n.lineBlockAt(t.head).to)),Fo=({state:n,dispatch:t})=>(t(Bt(n,{anchor:0})),!0),Wo=({state:n,dispatch:t})=>(t(Bt(n,{anchor:n.doc.length})),!0),Vo=({state:n,dispatch:t})=>(t(Bt(n,{anchor:n.selection.main.anchor,head:0})),!0),Ho=({state:n,dispatch:t})=>(t(Bt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Rd=({state:n,dispatch:t})=>(t(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Ed=({state:n,dispatch:t})=>{let e=As(n).map(({from:i,to:s})=>w.range(i,Math.min(s+1,n.doc.length)));return t(n.update({selection:w.create(e),userEvent:"select"})),!0},Nd=({state:n,dispatch:t})=>{let e=$e(n.selection,i=>{let s=vt(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return w.range(l.to,l.from)}return i});return e.eq(n.selection)?!1:(t(Bt(n,e)),!0)};function za(n,t){let{state:e}=n,i=e.selection,s=e.selection.ranges.slice();for(let r of e.selection.ranges){let o=e.doc.lineAt(r.head);if(t?o.to<n.state.doc.length:o.from>0)for(let l=r;;){let a=n.moveVertically(l,t);if(a.head<o.from||a.head>o.to){s.some(h=>h.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==i.ranges.length?!1:(n.dispatch(Bt(e,w.create(s,s.length-1))),!0)}const Fd=n=>za(n,!1),Wd=n=>za(n,!0),Vd=({state:n,dispatch:t})=>{let e=n.selection,i=null;return e.ranges.length>1?i=w.create([e.main]):e.main.empty||(i=w.create([w.cursor(e.main.head)])),i?(t(Bt(n,i)),!0):!1};function vi(n,t){if(n.state.readOnly)return!1;let e="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=t(r);a<o?(e="delete.backward",a=Ki(n,a,!1)):a>o&&(e="delete.forward",a=Ki(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Ki(n,o,!1),l=Ki(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:w.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?O.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Ki(n,t,e){if(n instanceof O)for(let i of n.state.facet(O.atomicRanges).map(s=>s(n)))i.between(t,t,(s,r)=>{s<t&&r>t&&(t=e?r:s)});return t}const Ka=(n,t,e)=>vi(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(e&&!t&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let h=gs(l,r.tabSize),f=h%fs(r)||fs(r);for(let c=0;c<f&&l[l.length-1-c]==" ";c++)s--;a=s}else a=st(o.text,s-o.from,t,t)+o.from,a==s&&o.number!=(t?r.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=st(o.text,a-o.from,!1,!1)+o.from);return a}),Rn=n=>Ka(n,!1,!0),$a=n=>Ka(n,!0,!1),qa=(n,t)=>vi(n,e=>{let i=e.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(t?r.to:r.from)){i==e.head&&r.number!=(t?s.doc.lines:1)&&(i+=t?1:-1);break}let a=st(r.text,i-r.from,t)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),f=o(h);if(l!=null&&f!=l)break;(h!=" "||i!=e.head)&&(l=f),i=a}return i}),ja=n=>qa(n,!1),Hd=n=>qa(n,!0),zd=n=>vi(n,t=>{let e=n.lineBlockAt(t.head).to;return t.head<e?e:Math.min(n.state.doc.length,t.head+1)}),Kd=n=>vi(n,t=>{let e=n.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),$d=n=>vi(n,t=>{let e=n.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(n.state.doc.length,t.head+1)}),qd=({state:n,dispatch:t})=>{if(n.readOnly)return!1;let e=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:L.of(["",""])},range:w.cursor(i.from)}));return t(n.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},jd=({state:n,dispatch:t})=>{if(n.readOnly)return!1;let e=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:st(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:st(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:w.cursor(l)}});return e.changes.empty?!1:(t(n.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function As(n){let t=[],e=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),e>=s.number){let o=t[t.length-1];o.to=r.to,o.ranges.push(i)}else t.push({from:s.from,to:r.to,ranges:[i]});e=r.number+1}return t}function Ua(n,t,e){if(n.readOnly)return!1;let i=[],s=[];for(let r of As(n)){if(e?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(e?r.to+1:r.from-1),l=o.length+1;if(e){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(w.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(w.range(a.anchor-l,a.head-l))}}return i.length?(t(n.update({changes:i,scrollIntoView:!0,selection:w.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Ud=({state:n,dispatch:t})=>Ua(n,t,!1),Gd=({state:n,dispatch:t})=>Ua(n,t,!0);function Ga(n,t,e){if(n.readOnly)return!1;let i=[];for(let r of As(n))e?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let s=n.changes(i);return t(n.update({changes:s,selection:n.selection.map(s,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const _d=({state:n,dispatch:t})=>Ga(n,t,!1),Yd=({state:n,dispatch:t})=>Ga(n,t,!0),Jd=n=>{if(n.state.readOnly)return!1;let{state:t}=n,e=t.changes(As(t).map(({from:s,to:r})=>(s>0?s--:r<t.doc.length&&r++,{from:s,to:r}))),i=$e(t.selection,s=>{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(e);return n.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Xd(n,t){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=vt(n).resolveInner(t),i=e.childBefore(t),s=e.childAfter(t),r;return i&&s&&i.to<=t&&s.from>=t&&(r=i.type.prop(P.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const zo=_a(!1),Qd=_a(!0);function _a(n){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(s=>{let{from:r,to:o}=s,l=t.doc.lineAt(r),a=!n&&r==o&&Xd(t,r);n&&(r=o=(o<=l.to?l:t.doc.lineAt(o)).to);let h=new vs(t,{simulateBreak:r,simulateDoubleBreak:!!a}),f=pa(h,r);for(f==null&&(f=gs(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let c=["",cs(t,f)];return a&&c.push(cs(t,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:L.of(c)},range:w.cursor(r+1+c[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function ur(n,t){let e=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>e&&(i.empty||i.to>l.from)&&(t(l,s,i),e=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:w.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Zd=({state:n,dispatch:t})=>{if(n.readOnly)return!1;let e=Object.create(null),i=new vs(n,{overrideIndentation:r=>{let o=e[r];return o??-1}}),s=ur(n,(r,o,l)=>{let a=pa(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],f=cs(n,a);(h!=f||l.from<r.from+h.length)&&(e[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:f}))});return s.changes.empty||t(n.update(s,{userEvent:"indent"})),!0},Ya=({state:n,dispatch:t})=>n.readOnly?!1:(t(n.update(ur(n,(e,i)=>{i.push({from:e.from,insert:n.facet(ks)})}),{userEvent:"input.indent"})),!0),Ja=({state:n,dispatch:t})=>n.readOnly?!1:(t(n.update(ur(n,(e,i)=>{let s=/^\s*/.exec(e.text)[0];if(!s)return;let r=gs(s,n.tabSize),o=0,l=cs(n,Math.max(0,r-fs(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),tp=n=>(n.setTabFocusMode(),!0),ep=[{key:"Ctrl-b",run:Aa,shift:Ra,preventDefault:!0},{key:"Ctrl-f",run:Ma,shift:Ea},{key:"Ctrl-p",run:Oa,shift:Wa},{key:"Ctrl-n",run:Da,shift:Va},{key:"Ctrl-a",run:wd,shift:Id},{key:"Ctrl-e",run:kd,shift:Ld},{key:"Ctrl-d",run:$a},{key:"Ctrl-h",run:Rn},{key:"Ctrl-k",run:zd},{key:"Ctrl-Alt-h",run:ja},{key:"Ctrl-o",run:qd},{key:"Ctrl-t",run:jd},{key:"Ctrl-v",run:Ln}],ip=[{key:"ArrowLeft",run:Aa,shift:Ra,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:cd,shift:Cd,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:yd,shift:Dd,preventDefault:!0},{key:"ArrowRight",run:Ma,shift:Ea,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:ud,shift:Ad,preventDefault:!0},{mac:"Cmd-ArrowRight",run:xd,shift:Pd,preventDefault:!0},{key:"ArrowUp",run:Oa,shift:Wa,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Fo,shift:Vo},{mac:"Ctrl-ArrowUp",run:Ro,shift:Eo},{key:"ArrowDown",run:Da,shift:Va,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Wo,shift:Ho},{mac:"Ctrl-ArrowDown",run:Ln,shift:No},{key:"PageUp",run:Ro,shift:Eo},{key:"PageDown",run:Ln,shift:No},{key:"Home",run:bd,shift:Od,preventDefault:!0},{key:"Mod-Home",run:Fo,shift:Vo},{key:"End",run:md,shift:Bd,preventDefault:!0},{key:"Mod-End",run:Wo,shift:Ho},{key:"Enter",run:zo,shift:zo},{key:"Mod-a",run:Rd},{key:"Backspace",run:Rn,shift:Rn,preventDefault:!0},{key:"Delete",run:$a,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ja,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Hd,preventDefault:!0},{mac:"Mod-Backspace",run:Kd,preventDefault:!0},{mac:"Mod-Delete",run:$d,preventDefault:!0}].concat(ep.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Pp=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:pd,shift:Md},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:gd,shift:Td},{key:"Alt-ArrowUp",run:Ud},{key:"Shift-Alt-ArrowUp",run:_d},{key:"Alt-ArrowDown",run:Gd},{key:"Shift-Alt-ArrowDown",run:Yd},{key:"Mod-Alt-ArrowUp",run:Fd},{key:"Mod-Alt-ArrowDown",run:Wd},{key:"Escape",run:Vd},{key:"Mod-Enter",run:Qd},{key:"Alt-l",mac:"Ctrl-l",run:Ed},{key:"Mod-i",run:Nd,preventDefault:!0},{key:"Mod-[",run:Ja},{key:"Mod-]",run:Ya},{key:"Mod-Alt-\\",run:Zd},{key:"Shift-Mod-k",run:Jd},{key:"Shift-Mod-\\",run:Sd},{key:"Mod-/",run:nd},{key:"Alt-A",run:od},{key:"Ctrl-m",mac:"Shift-Alt-m",run:tp}].concat(ip),Ip={key:"Tab",run:Ya,shift:Ja},sp="#e5c07b",Ko="#e06c75",np="#56b6c2",rp="#ffffff",_i="#abb2bf",En="#7d8799",op="#61afef",lp="#98c379",$o="#d19a66",ap="#c678dd",hp="#21252b",qo="#2c313a",jo="#282c34",Gs="#353a42",fp="#3E4451",Uo="#528bff",cp=O.theme({"&":{color:_i,backgroundColor:jo},".cm-content":{caretColor:Uo},".cm-cursor, .cm-dropCursor":{borderLeftColor:Uo},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:fp},".cm-panels":{backgroundColor:hp,color:_i},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:jo,color:En,border:"none"},".cm-activeLineGutter":{backgroundColor:qo},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Gs},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Gs,borderBottomColor:Gs},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:qo,color:_i}}},{dark:!0}),up=wi.define([{tag:y.keyword,color:ap},{tag:[y.name,y.deleted,y.character,y.propertyName,y.macroName],color:Ko},{tag:[y.function(y.variableName),y.labelName],color:op},{tag:[y.color,y.constant(y.name),y.standard(y.name)],color:$o},{tag:[y.definition(y.name),y.separator],color:_i},{tag:[y.typeName,y.className,y.number,y.changed,y.annotation,y.modifier,y.self,y.namespace],color:sp},{tag:[y.operator,y.operatorKeyword,y.url,y.escape,y.regexp,y.link,y.special(y.string)],color:np},{tag:[y.meta,y.comment],color:En},{tag:y.strong,fontWeight:"bold"},{tag:y.emphasis,fontStyle:"italic"},{tag:y.strikethrough,textDecoration:"line-through"},{tag:y.link,color:En,textDecoration:"underline"},{tag:y.heading,fontWeight:"bold",color:Ko},{tag:[y.atom,y.bool,y.special(y.variableName)],color:$o},{tag:[y.processingInstruction,y.string,y.inserted],color:lp},{tag:y.invalid,color:rp}]),Lp=[cp,au(up)];export{pp as A,Lp as B,xp as C,au as D,yp as E,Tp as F,F as I,Tn as L,gp as N,Lc as a,On as b,Cp as c,Mp as d,kp as e,Ap as f,vt as g,Jc as h,tu as i,Sp as j,vp as k,Bp as l,wu as m,Yc as n,Op as o,mp as p,O as q,w as r,qc as s,y as t,du as u,E as v,Dp as w,Xn as x,Pp as y,Ip as z};
|
|
10
|
+
`))};if((S.mac||S.android)&&c.from==o-1&&/^\. ?$/.test(i.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:l,to:a,insert:L.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);_n(t,c,w.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),c.from<c.to&&!c.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=t.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}e.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=i=>{let s=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let f=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(K.mark({attributes:{style:f}}).range(a,h))}}}t.dispatch({effects:Ll.of(K.set(s))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(t.state)}};for(let i in this.handlers)e.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let s=fi(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,s=this.pendingContextChange;return t.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let f=h.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(h)){s=this.pendingContextChange=null,e+=f,this.to+=f;return}else s=null,this.revertPending(t.state);if(r+=e,o+=e,o<=this.from)this.from+=f,this.to+=f;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=f}e+=f}),s&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),s=this.toContextPos(e.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>1e4*3)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class O{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(s=>s.forEach(r=>i(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Dh(t.parent)||document,this.viewState=new Gr(this,t.state||E.create(t)),t.scrollTo&&t.scrollTo.is(Bi)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ve).map(s=>new Ds(s));for(let s of this.plugins)s.update(this);this.observer=new ic(this),this.inputState=new Af(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Rr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((e=document.fonts)===null||e===void 0)&&e.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let e=t.length==1&&t[0]instanceof et?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,s,r=this.state;for(let u of t){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;t.some(u=>u.annotation(Yl))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Jl(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(f=null)):this.observer.clear(),r.facet(E.phrases)!=this.state.facet(E.phrases))return this.setState(r);s=Zi.create(this,r,t),s.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of t){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;c=new Oe(d.empty?d:w.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Bi)&&(c=d.value.clip(this.state))}this.viewState.update(s,c),this.bidiCache=ns.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),e=this.docView.update(s),this.state.facet(Je)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Ri)!=s.state.facet(Ri)&&(this.viewState.mustMeasureContent=!0),(e||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),e&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(bn))try{u(s)}catch(d){gt(this.state,d,"update listener")}(a||f)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),f&&!Kl(this,f)&&h.force&&Be(this.contentDOM,h.key,h.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Gr(this,t),this.plugins=t.facet(ve).map(i=>new Ds(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Rr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(ve),i=t.state.facet(ve);if(e!=i){let s=[];for(let r of i){let o=e.indexOf(r);if(o<0)s.push(new Ds(r));else{let l=this.plugins[o];l.mustUpdate=t,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=t&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=t;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(i){gt(this.state,i,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(bl(i||this.win))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(s);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let f=h.map(d=>{try{return d.read(this)}catch(p){return gt(this.state,p),Qr}}),c=Zi.create(this,this.state,[]),u=!1;c.flags|=a,e?e.flags|=a:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(f[d]!=Qr)try{let p=h[d];p.write&&p.write(f[d],this)}catch(p){gt(this.state,p)}if(u&&this.docView.updateSelection(!0),!c.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=((r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o)/this.scaleY;if((p>1||p<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let l of this.state.facet(bn))l(e)}get themeClasses(){return vn+" "+(this.state.facet(kn)?ta:Zl)+" "+this.state.facet(Ri)}updateAttrs(){let t=Zr(this,Rl,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Kt)?"true":"false",class:"cm-content",style:`${S.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Zr(this,jn,e);let i=this.observer.ignore(()=>{let s=Br(this.contentDOM,this.contentAttrs,e),r=Br(this.dom,this.editorAttrs,t);return s||r});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let s of i.effects)if(s.is(O.announce)){e&&(this.announceDOM.textContent=""),e=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Je);let t=this.state.facet(O.cspNonce);ee.mount(this.root,this.styleModules.concat(tc).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){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(e===void 0||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(i=>i.plugin==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}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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 Rs(this,t,Er(this,t,e,i))}moveByGroup(t,e){return Rs(this,t,Er(this,t,e,i=>gf(this,t.head,i)))}visualLineSide(t,e){let i=this.bidiSpans(t),s=this.textDirectionAt(t.from),r=i[e?i.length-1:0];return w.cursor(r.side(e,s)+t.from,r.forward(!e,s)?1:-1)}moveToLineBoundary(t,e,i=!0){return pf(this,t,e,i)}moveVertically(t,e,i){return Rs(this,t,mf(this,t,e,i))}domAtPos(t,e=1){return this.docView.domAtPos(t,e)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){this.readMeasured();let i=xn(this,t,e);return i&&i.pos}posAndSideAtCoords(t,e=!0){return this.readMeasured(),xn(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),r=this.bidiSpans(s),o=r[Ft.find(r,t-s.from,-1,e)];return ci(i,o.dir==G.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}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(Pl)||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>rc)return Sl(t.length);let e=this.textDirectionAt(t.from),i;for(let r of this.bidiCache)if(r.from==t.from&&r.dir==e&&(r.fresh||vl(r.isolates,i=Pr(this,t))))return r.order;i||(i=Pr(this,t));let s=Wh(t.text,e,i);return this.bidiCache.push(new ns(t.from,t.to,e,i,!0,s)),s}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||S.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ml(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Bi.of(new Oe(typeof t=="number"?w.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Bi.of(new Oe(w.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Vt.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Vt.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=ee.newName(),s=[Ri.of(i),Je.of(Sn(`.${i}`,t))];return e&&e.dark&&s.push(kn.of(!0)),s}static baseTheme(t){return He.lowest(Je.of(Sn("."+vn,t,ea)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),s=i&&_.get(i)||_.get(t);return((e=s==null?void 0:s.root)===null||e===void 0?void 0:e.view)||null}}O.styleModule=Je;O.inputHandler=Ol;O.clipboardInputFilter=$n;O.clipboardOutputFilter=qn;O.scrollHandler=Il;O.focusChangeEffect=Dl;O.perLineTextDirection=Pl;O.exceptionSink=Bl;O.updateListener=bn;O.editable=Kt;O.mouseSelectionStyle=Tl;O.dragMovesSelection=Ml;O.clickAddsSelectionRange=Al;O.decorations=bs;O.blockWrappers=El;O.outerDecorations=Un;O.atomicRanges=xi;O.bidiIsolatedRanges=Nl;O.scrollMargins=Fl;O.darkTheme=kn;O.cspNonce=B.define({combine:n=>n.length?n[0]:""});O.contentAttributes=jn;O.editorAttributes=Rl;O.lineWrapping=O.contentAttributes.of({class:"cm-lineWrapping"});O.announce=z.define();const rc=4096,Qr={};class ns{constructor(t,e,i,s,r,o){this.from=t,this.to=e,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(t,e){if(e.empty&&!t.some(r=>r.fresh))return t;let i=[],s=t.length?t[t.length-1].dir:G.LTR;for(let r=Math.max(0,t.length-10);r<t.length;r++){let o=t[r];o.dir==s&&!e.touchesRange(o.from,o.to)&&i.push(new ns(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Zr(n,t,e){for(let i=n.state.facet(t),s=i.length-1;s>=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&Hn(o,e)}return e}const oc=S.mac?"mac":S.windows?"win":S.linux?"linux":"key";function lc(n,t){const e=n.split(/-(?!$)/);let i=e[e.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;a<e.length-1;++a){const h=e[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))s=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))t=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return s&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Ei(n,t,e){return t.altKey&&(n="Alt-"+n),t.ctrlKey&&(n="Ctrl-"+n),t.metaKey&&(n="Meta-"+n),e!==!1&&t.shiftKey&&(n="Shift-"+n),n}const ac=He.default(O.domEventHandlers({keydown(n,t){return uc(hc(t.state),n,t,"editor")}})),Xn=B.define({enables:ac}),to=new WeakMap;function hc(n){let t=n.facet(Xn),e=to.get(t);return e||to.set(t,e=cc(t.reduce((i,s)=>i.concat(s),[]))),e}let Qt=null;const fc=4e3;function cc(n,t=oc){let e=Object.create(null),i=Object.create(null),s=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,f)=>{var c,u;let d=e[o]||(e[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>lc(b,t));for(let b=1;b<p.length;b++){let x=p.slice(0,b).join(" ");s(x,!0),d[x]||(d[x]={preventDefault:!0,stopPropagation:!1,run:[v=>{let T=Qt={view:v,prefix:x,scope:o};return setTimeout(()=>{Qt==T&&(Qt=null)},fc),!0}]})}let g=p.join(" ");s(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(c=d._any)===null||c===void 0?void 0:c.run)===null||u===void 0?void 0:u.slice())||[]});a&&m.run.push(a),h&&(m.preventDefault=!0),f&&(m.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let f=e[h]||(e[h]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let u in f)f[u].run.push(d=>c(d,Cn))}let a=o[t]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return e}let Cn=null;function uc(n,t,e,i){Cn=t;let s=vh(t),r=he(s,0),o=we(r)==s.length&&s!=" ",l="",a=!1,h=!1,f=!1;Qt&&Qt.view==e&&Qt.scope==i&&(l=Qt.prefix+" ",jl.indexOf(t.keyCode)<0&&(h=!0,Qt=null));let c=new Set,u=m=>{if(m){for(let b of m.run)if(!c.has(b)&&(c.add(b),b(e)))return m.stopPropagation&&(f=!0),!0;m.preventDefault&&(m.stopPropagation&&(f=!0),h=!0)}return!1},d=n[i],p,g;return d&&(u(d[l+Ei(s,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(S.windows&&t.ctrlKey&&t.altKey)&&!(S.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=ie[t.keyCode])&&p!=s?(u(d[l+Ei(p,t,!0)])||t.shiftKey&&(g=ai[t.keyCode])!=s&&g!=p&&u(d[l+Ei(g,t,!1)]))&&(a=!0):o&&t.shiftKey&&u(d[l+Ei(s,t,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&f&&t.stopPropagation(),Cn=null,a}class dc extends ze{constructor(t){super(),this.content=t}toDOM(t){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),e.setAttribute("aria-hidden","true"),e}coordsAt(t){let e=t.firstChild?ii(t.firstChild):[];if(!e.length)return null;let i=window.getComputedStyle(t.parentNode),s=ci(e[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function pp(n){let t=Vt.fromClass(class{constructor(e){this.view=e,this.placeholder=n?K.set([K.widget({widget:new dc(n),side:1}).range(0)]):K.none}get decorations(){return this.view.state.doc.length?K.none:this.placeholder}},{decorations:e=>e.decorations});return typeof n=="string"?[t,O.contentAttributes.of({"aria-placeholder":n})]:t}const Ni="-10000px";class pc{constructor(t,e,i,s){this.facet=e,this.createTooltipView=i,this.removeTooltipView=s,this.input=t.state.facet(e),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(t,e){var i;let s=t.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(t);return!1}let o=[],l=e?[]:null;for(let a=0;a<r.length;a++){let h=r[a],f=-1;if(h){for(let c=0;c<this.tooltips.length;c++){let u=this.tooltips[c];u&&u.create==h.create&&(f=c)}if(f<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let c=o[a]=this.tooltipViews[f];l&&(l[a]=e[f]),c.update&&c.update(t)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return e&&(l.forEach((a,h)=>e[h]=a),e.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function gc(n){let t=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const Fs=B.define({combine:n=>{var t,e,i;return{position:S.ios?"absolute":((t=n.find(s=>s.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=n.find(s=>s.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||gc}}}),eo=new WeakMap,ia=Vt.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=n.state.facet(Fs);this.position=t.position,this.parent=t.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new pc(n,sa,(e,i)=>this.createTooltip(e,i),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.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){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(n,this.above);t&&this.observeIntersection();let e=t||n.geometryChanged,i=n.state.facet(Fs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;e=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(n,t){let e=n.create(this.view),i=t?t.dom:null;if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",e.dom.appendChild(s)}return e.dom.style.position=this.position,e.dom.style.top=Ni,e.dom.style.left="0px",this.container.insertBefore(e.dom,i),e.mount&&e.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(e.dom),e}destroy(){var n,t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,t=1,e=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(S.safari){let o=r.getBoundingClientRect();e=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else e=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(e||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(n=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:t}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),s=Gn(this.view);return{visible:{left:i.left+s.left,top:i.top+s.top,right:i.right-s.right,bottom:i.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Fs).tooltipSpace(this.view),scaleX:n,scaleY:t,makeAbsolute:e}}writeMeasure(n){var t;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:e,space:i,scaleX:s,scaleY:r}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:f}=h,c=n.pos[l],u=n.size[l];if(!c||a.clip!==!1&&(c.bottom<=Math.max(e.top,i.top)||c.top>=Math.min(e.bottom,i.bottom)||c.right<Math.max(e.left,i.left)-.1||c.left>Math.min(e.right,i.right)+.1)){f.style.top=Ni;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=u.right-u.left,m=(t=eo.get(h))!==null&&t!==void 0?t:u.bottom-u.top,b=h.offset||bc,x=this.view.textDirection==G.LTR,v=u.width>i.right-i.left?x?i.left:i.right-u.width:x?Math.max(i.left,Math.min(c.left-(d?14:0)+b.x,i.right-g)):Math.min(Math.max(i.left,c.left-g+(d?14:0)-b.x),i.right-g),T=this.above[l];!a.strictSide&&(T?c.top-m-p-b.y<i.top:c.bottom+m+p+b.y>i.bottom)&&T==i.bottom-c.bottom>c.top-i.top&&(T=this.above[l]=!T);let C=(T?c.top-i.top:i.bottom-c.bottom)-p;if(C<m&&h.resize!==!1){if(C<this.view.defaultLineHeight){f.style.top=Ni;continue}eo.set(h,m),f.style.height=(m=C)/r+"px"}else f.style.height&&(f.style.height="");let M=T?c.top-m-p-b.y:c.bottom+p+b.y,A=v+g;if(h.overlap!==!0)for(let R of o)R.left<A&&R.right>v&&R.top<M+m&&R.bottom>M&&(M=T?R.top-m-2-p:R.bottom+p+2);if(this.position=="absolute"?(f.style.top=(M-n.parent.top)/r+"px",io(f,(v-n.parent.left)/s)):(f.style.top=M/r+"px",io(f,v/s)),d){let R=c.left+(x?b.x:-b.x)-(v+14-7);d.style.left=R/s+"px"}h.overlap!==!0&&o.push({left:v,top:M,right:A,bottom:M+m}),f.classList.toggle("cm-tooltip-above",T),f.classList.toggle("cm-tooltip-below",!T),h.positioned&&h.positioned(n.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 n of this.manager.tooltipViews)n.dom.style.top=Ni}},{eventObservers:{scroll(){this.maybeMeasure()}}});function io(n,t){let e=parseInt(n.style.left,10);(isNaN(e)||Math.abs(t-e)>1)&&(n.style.left=t+"px")}const mc=O.baseTheme({".cm-tooltip":{zIndex:500,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:`${7*2}px`,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"}}}),bc={x:0,y:0},sa=B.define({enables:[ia,mc]});function na(n,t){let e=n.plugin(ia);if(!e)return null;let i=e.manager.tooltips.indexOf(t);return i<0?null:e.manager.tooltipViews[i]}class Fe extends te{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Fe.prototype.elementClass="";Fe.prototype.toDOM=void 0;Fe.prototype.mapMode=lt.TrackBefore;Fe.prototype.startSide=Fe.prototype.endSide=-1;Fe.prototype.point=!0;const ra=1024;let yc=0;class xt{constructor(t,e){this.from=t,this.to=e}}class P{constructor(t={}){this.id=yc++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=ht.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}}P.closedBy=new P({deserialize:n=>n.split(" ")});P.openedBy=new P({deserialize:n=>n.split(" ")});P.group=new P({deserialize:n=>n.split(" ")});P.isolate=new P({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});P.contextHash=new P({perNode:!0});P.lookAhead=new P({perNode:!0});P.mounted=new P({perNode:!0});class De{constructor(t,e,i,s=!1){this.tree=t,this.overlay=e,this.parser=i,this.bracketed=s}static get(t){return t&&t.props&&t.props[P.mounted.id]}}const xc=Object.create(null);class ht{constructor(t,e,i,s=0){this.name=t,this.props=e,this.id=i,this.flags=s}static define(t){let e=t.props&&t.props.length?Object.create(null):xc,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),s=new ht(t.name||"",e,t.id,i);if(t.props){for(let r of t.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}}return s}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(P.group);return e?e.indexOf(t)>-1:!1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let s of i.split(" "))e[s]=t[i];return i=>{for(let s=i.prop(P.group),r=-1;r<(s?s.length:0);r++){let o=e[r<0?i.name:s[r]];if(o)return o}}}}ht.none=new ht("",Object.create(null),0,8);class Qn{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let s=null;for(let r of t){let o=r(i);if(o){s||(s=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in s&&(l=a.combine(s[a.id],l)),s[a.id]=l}}e.push(s?new ht(i.name,s,i.id,i.flags):i)}return new Qn(e)}}const Fi=new WeakMap,so=new WeakMap;var F;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(F||(F={}));class q{constructor(t,e,i,s,r){if(this.type=t,this.children=e,this.positions=i,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=De.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let s=i.toString();s&&(e&&(e+=","),e+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new rs(this.topNode,t)}cursorAt(t,e=0,i=0){let s=Fi.get(this)||this.topNode,r=new rs(s);return r.moveTo(t,e),Fi.set(this,r._tree),r}get topNode(){return new nt(this,0,0,null)}resolve(t,e=0){let i=di(Fi.get(this)||this.topNode,t,e,!1);return Fi.set(this,i),i}resolveInner(t,e=0){let i=di(so.get(this)||this.topNode,t,e,!0);return so.set(this,i),i}resolveStack(t,e=0){return vc(this,t,e)}iterate(t){let{enter:e,leave:i,from:s=0,to:r=this.length}=t,o=t.mode||0,l=(o&F.IncludeAnonymous)>0;for(let a=this.cursor(o|F.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||e(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:er(ht.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,s)=>new q(this.type,e,i,s,this.propValues),t.makeTree||((e,i,s)=>new q(ht.none,e,i,s)))}static build(t){return Sc(t)}}q.empty=new q(ht.none,[],[],0);class Zn{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Zn(this.buffer,this.index)}}class ne{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return ht.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],s=this.set.types[e],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),t+=4,i==t)return r;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return r+"("+o.join(",")+")"}findChild(t,e,i,s,r){let{buffer:o}=this,l=-1;for(let a=t;a!=e&&!(oa(r,s,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(t,e,i){let s=this.buffer,r=new Uint16Array(e-t),o=0;for(let l=t,a=0;l<e;){r[a++]=s[l++],r[a++]=s[l++]-i;let h=r[a++]=s[l++]-i;r[a++]=s[l++]-t,o=Math.max(o,h)}return new ne(r,o,this.set)}}function oa(n,t,e,i){switch(n){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function di(n,t,e,i){for(var s;n.from==n.to||(e<1?n.from>=t:n.from>t)||(e>-1?n.to<=t:n.to<t);){let o=!i&&n instanceof nt&&n.index<0?null:n.parent;if(!o)return n;n=o}let r=i?0:F.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof nt&&o.index<0&&((s=l.enter(t,e,r))===null||s===void 0?void 0:s.from)!=o.from&&(n=l);for(;;){let o=n.enter(t,e,r);if(!o)return n;n=o}}class la{cursor(t=0){return new rs(this,t)}getChild(t,e=null,i=null){let s=no(this,t,e,i);return s.length?s[0]:null}getChildren(t,e=null,i=null){return no(this,t,e,i)}resolve(t,e=0){return di(this,t,e,!1)}resolveInner(t,e=0){return di(this,t,e,!0)}matchContext(t){return An(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let s=e.lastChild;if(!s||s.to!=e.to)break;s.type.isError&&s.from==s.to?(i=e,e=s.prevSibling):e=s}return i}get node(){return this}get next(){return this.parent}}class nt extends la{constructor(t,e,i,s){super(),this._tree=t,this.from=e,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=e>0?l.length:-1;t!=h;t+=e){let f=l[t],c=a[t]+o.from,u;if(!(!(r&F.EnterBracketed&&f instanceof q&&(u=De.get(f))&&!u.overlay&&u.bracketed&&i>=c&&i<=c+f.length)&&!oa(s,i,c,c+f.length))){if(f instanceof ne){if(r&F.ExcludeBuffers)continue;let d=f.findChild(0,f.buffer.length,e,i-c,s);if(d>-1)return new Wt(new wc(o,f,t,c),null,d)}else if(r&F.IncludeAnonymous||!f.type.isAnonymous||tr(f)){let d;if(!(r&F.IgnoreMounts)&&(d=De.get(f))&&!d.overlay)return new nt(d.tree,c,t,o);let p=new nt(f,c,t,o);return r&F.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(e<0?f.children.length-1:0,e,i,s,r)}}}if(r&F.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let s;if(!(i&F.IgnoreOverlays)&&(s=De.get(this._tree))&&s.overlay){let r=t-this.from,o=i&F.EnterBracketed&&s.bracketed;for(let{from:l,to:a}of s.overlay)if((e>0||o?l<=r:l<r)&&(e<0||o?a>=r:a>r))return new nt(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function no(n,t,e,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(e!=null){for(let o=!1;!o;)if(o=s.type.is(e),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(t)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function An(n,t,e=t.length-1){for(let i=n;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}class wc{constructor(t,e,i,s){this.parent=t,this.buffer=e,this.index=i,this.start=s}}class Wt extends la{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.context.start,i);return r<0?null:new Wt(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&F.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new Wt(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Wt(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Wt(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];t.push(i.slice(s,r,o)),e.push(0)}return new q(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function aa(n){if(!n.length)return null;let t=0,e=n[0];for(let r=1;r<n.length;r++){let o=n[r];(o.from>e.from||o.to<e.to)&&(e=o,t=r)}let i=e instanceof nt&&e.index<0?null:e.parent,s=n.slice();return i?s[t]=i:s.splice(t,1),new kc(s,e)}class kc{constructor(t,e){this.heads=t,this.node=e}get next(){return aa(this.heads)}}function vc(n,t,e){let i=n.resolveInner(t,e),s=null;for(let r=i instanceof nt?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[i])).push(o.resolve(t,e)),r=o}else{let o=De.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=t&&o.overlay[o.overlay.length-1].to>=t){let l=new nt(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(di(l,t,e,!1))}}return s?aa(s):i}class rs{get name(){return this.type.name}constructor(t,e=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=e&~F.EnterBracketed,t instanceof nt)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,e){this.index=t;let{start:i,buffer:s}=this.buffer;return this.type=e||s.set.types[s.buffer[t]],this.from=i+s.buffer[t+1],this.to=i+s.buffer[t+2],!0}yield(t){return t?t instanceof nt?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],t,e-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?i&F.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&F.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&F.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(e.findChild(s,this.index,-1,0,4))}else{let s=e.buffer[this.index+3];if(s<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:s}=this;if(s){if(t>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:e,parent:i}=s)}else({index:e,_parent:i}=this._tree);for(;i;{index:e,_parent:i}=i)if(e>-1)for(let r=e+t,o=t<0?-1:i._tree.children.length;r!=o;r+=t){let l=i._tree.children[r];if(this.mode&F.IncludeAnonymous||l instanceof ne||!l.type.isAnonymous||tr(l))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=t;o;o=o._parent)if(o.index==s){if(s==this.index)return o;e=o,i=r+1;break t}s=this.stack[--r]}for(let s=i;s<this.stack.length;s++)e=new Wt(this.buffer,e,this.stack[s]);return this.bufferNode=new Wt(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let s=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&e&&e(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(t){if(!this.buffer)return An(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let s=t.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return An(this._tree,t,s);let o=i[e.buffer[this.stack[r]]];if(!o.isAnonymous){if(t[s]&&t[s]!=o.name)return!1;s--}}return!0}}function tr(n){return n.children.some(t=>t instanceof ne||!t.type.isAnonymous||tr(t))}function Sc(n){var t;let{buffer:e,nodeSet:i,maxBufferLength:s=ra,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(e)?new Zn(e,e.length):e,a=i.types,h=0,f=0;function c(C,M,A,R,V,U){let{id:I,start:D,end:$,size:j}=l,Q=f,Yt=h;if(j<0)if(l.next(),j==-1){let Ht=r[I];A.push(Ht),R.push(D-C);return}else if(j==-3){h=I;return}else if(j==-4){f=I;return}else throw new RangeError(`Unrecognized record size: ${j}`);let qe=a[I],Si,oe,dr=D-C;if($-D<=s&&(oe=m(l.pos-M,V))){let Ht=new Uint16Array(oe.size-oe.skip),mt=l.pos-oe.size,Dt=Ht.length;for(;l.pos>mt;)Dt=b(oe.start,Ht,Dt);Si=new ne(Ht,$-oe.start,i),dr=oe.start-C}else{let Ht=l.pos-j;l.next();let mt=[],Dt=[],le=I>=o?I:-1,xe=0,Ci=$;for(;l.pos>Ht;)le>=0&&l.id==le&&l.size>=0?(l.end<=Ci-s&&(p(mt,Dt,D,xe,l.end,Ci,le,Q,Yt),xe=mt.length,Ci=l.end),l.next()):U>2500?u(D,Ht,mt,Dt):c(D,Ht,mt,Dt,le,U+1);if(le>=0&&xe>0&&xe<mt.length&&p(mt,Dt,D,xe,D,Ci,le,Q,Yt),mt.reverse(),Dt.reverse(),le>-1&&xe>0){let pr=d(qe,Yt);Si=er(qe,mt,Dt,0,mt.length,0,$-D,pr,pr)}else Si=g(qe,mt,Dt,$-D,Q-$,Yt)}A.push(Si),R.push(dr)}function u(C,M,A,R){let V=[],U=0,I=-1;for(;l.pos>M;){let{id:D,start:$,end:j,size:Q}=l;if(Q>4)l.next();else{if(I>-1&&$<I)break;I<0&&(I=j-s),V.push(D,$,j),U++,l.next()}}if(U){let D=new Uint16Array(U*4),$=V[V.length-2];for(let j=V.length-3,Q=0;j>=0;j-=3)D[Q++]=V[j],D[Q++]=V[j+1]-$,D[Q++]=V[j+2]-$,D[Q++]=Q;A.push(new ne(D,V[2]-$,i)),R.push($-C)}}function d(C,M){return(A,R,V)=>{let U=0,I=A.length-1,D,$;if(I>=0&&(D=A[I])instanceof q){if(!I&&D.type==C&&D.length==V)return D;($=D.prop(P.lookAhead))&&(U=R[I]+D.length+$)}return g(C,A,R,V,U,M)}}function p(C,M,A,R,V,U,I,D,$){let j=[],Q=[];for(;C.length>R;)j.push(C.pop()),Q.push(M.pop()+A-V);C.push(g(i.types[I],j,Q,U-V,D-U,$)),M.push(V-A)}function g(C,M,A,R,V,U,I){if(U){let D=[P.contextHash,U];I=I?[D].concat(I):[D]}if(V>25){let D=[P.lookAhead,V];I=I?[D].concat(I):[D]}return new q(C,M,A,R,I)}function m(C,M){let A=l.fork(),R=0,V=0,U=0,I=A.end-s,D={size:0,start:0,skip:0};t:for(let $=A.pos-C;A.pos>$;){let j=A.size;if(A.id==M&&j>=0){D.size=R,D.start=V,D.skip=U,U+=4,R+=4,A.next();continue}let Q=A.pos-j;if(j<0||Q<$||A.start<I)break;let Yt=A.id>=o?4:0,qe=A.start;for(A.next();A.pos>Q;){if(A.size<0)if(A.size==-3||A.size==-4)Yt+=4;else break t;else A.id>=o&&(Yt+=4);A.next()}V=qe,R+=j,U+=Yt}return(M<0||R==C)&&(D.size=R,D.start=V,D.skip=U),D.size>4?D:void 0}function b(C,M,A){let{id:R,start:V,end:U,size:I}=l;if(l.next(),I>=0&&R<o){let D=A;if(I>4){let $=l.pos-(I-4);for(;l.pos>$;)A=b(C,M,A)}M[--A]=D,M[--A]=U-C,M[--A]=V-C,M[--A]=R}else I==-3?h=R:I==-4&&(f=R);return A}let x=[],v=[];for(;l.pos>0;)c(n.start||0,n.bufferStart||0,x,v,-1,0);let T=(t=n.length)!==null&&t!==void 0?t:x.length?v[0]+x[0].length:0;return new q(a[n.topID],x.reverse(),v.reverse(),T)}const ro=new WeakMap;function Ui(n,t){if(!n.isAnonymous||t instanceof ne||t.type!=n)return 1;let e=ro.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=n||!(i instanceof q)){e=1;break}e+=Ui(n,i)}ro.set(t,e)}return e}function er(n,t,e,i,s,r,o,l,a){let h=0;for(let p=i;p<s;p++)h+=Ui(n,t[p]);let f=Math.ceil(h*1.5/8),c=[],u=[];function d(p,g,m,b,x){for(let v=m;v<b;){let T=v,C=g[v],M=Ui(n,p[v]);for(v++;v<b;v++){let A=Ui(n,p[v]);if(M+A>=f)break;M+=A}if(v==T+1){if(M>f){let A=p[T];d(A.children,A.positions,0,A.children.length,g[T]+x);continue}c.push(p[T])}else{let A=g[v-1]+p[v-1].length-C;c.push(er(n,p,g,T,v,C,A,null,a))}u.push(C+x-r)}}return d(t,e,i,s,0),(l||a)(c,u,o)}class gp{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let s=this.map.get(t);s||this.map.set(t,s=new Map),s.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof Wt?this.setBuffer(t.context.buffer,t.index,e):t instanceof nt&&this.map.set(t.tree,e)}get(t){return t instanceof Wt?this.getBuffer(t.context.buffer,t.index):t instanceof nt?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class Ut{constructor(t,e,i,s,r=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let s=[new Ut(0,t.length,t,0,!1,i)];for(let r of e)r.to>t.length&&s.push(r);return s}static applyChanges(t,e,i=128){if(!e.length)return t;let s=[],r=1,o=t.length?t[0]:null;for(let l=0,a=0,h=0;;l++){let f=l<e.length?e[l]:null,c=f?f.fromA:1e9;if(c-a>=i)for(;o&&o.from<c;){let u=o;if(a>=u.from||c<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,c)-h;u=d>=p?null:new Ut(d,p,u.tree,u.offset+h,l>0,!!f)}if(u&&s.push(u),o.to>c)break;o=r<t.length?t[r++]:null}if(!f)break;a=f.toA,h=f.toA-f.toB}return s}}class ha{startParse(t,e,i){return typeof t=="string"&&(t=new Cc(t)),i=i?i.length?i.map(s=>new xt(s.from,s.to)):[new xt(0,0)]:[new xt(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let s=this.startParse(t,e,i);for(;;){let r=s.advance();if(r)return r}}}class Cc{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function mp(n){return(t,e,i,s)=>new Mc(t,n,e,i,s)}class oo{constructor(t,e,i,s,r,o){this.parser=t,this.parse=e,this.overlay=i,this.bracketed=s,this.target=r,this.from=o}}function lo(n){if(!n.length||n.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}class Ac{constructor(t,e,i,s,r,o,l,a){this.parser=t,this.predicate=e,this.mounts=i,this.index=s,this.start=r,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Mn=new P({perNode:!0});class Mc{constructor(t,e,i,s,r){this.nest=e,this.input=i,this.fragments=s,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new q(i.type,i.children,i.positions,i.length,i.propValues.concat([[Mn,this.stoppedAt]]))),i}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[P.mounted.id]=new De(e,t.overlay,t.parser,t.bracketed),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new Oc(this.fragments),e=null,i=null,s=new rs(new nt(this.baseTree,this.ranges[0].from,0,null),F.IncludeAnonymous|F.IgnoreMounts);t:for(let r,o;;){let l=!0,a;if(this.stoppedAt!=null&&s.from>=this.stoppedAt)l=!1;else if(t.hasNode(s)){if(e){let h=e.mounts.find(f=>f.frag.from<=s.from&&f.frag.to>=s.to&&f.mount.overlay);if(h)for(let f of h.mount.overlay){let c=f.from+h.pos,u=f.to+h.pos;c>=s.from&&u<=s.to&&!e.ranges.some(d=>d.from<u&&d.to>c)&&e.ranges.push({from:c,to:u})}}l=!1}else if(i&&(o=Tc(i.ranges,s.from,s.to)))l=o!=2;else if(!s.type.isAnonymous&&(r=this.nest(s,this.input))&&(s.from<s.to||!r.overlay)){s.tree||(Bc(s),e&&e.depth++,i&&i.depth++);let h=t.findMounts(s.from,r.parser);if(typeof r.overlay=="function")e=new Ac(r.parser,r.overlay,h,this.inner.length,s.from,!!r.bracketed,s.tree,e);else{let f=fo(this.ranges,r.overlay||(s.from<s.to?[new xt(s.from,s.to)]:[]));f.length&&lo(f),(f.length||!r.overlay)&&this.inner.push(new oo(r.parser,f.length?r.parser.startParse(this.input,co(h,f),f):r.parser.startParse(""),r.overlay?r.overlay.map(c=>new xt(c.from-s.from,c.to-s.from)):null,!!r.bracketed,s.tree,f.length?f[0].from:s.from)),r.overlay?f.length&&(i={ranges:f,depth:0,prev:i}):l=!1}}else if(e&&(a=e.predicate(s))&&(a===!0&&(a=new xt(s.from,s.to)),a.from<a.to)){let h=e.ranges.length-1;h>=0&&e.ranges[h].to==a.from?e.ranges[h]={from:e.ranges[h].from,to:a.to}:e.ranges.push(a)}if(l&&s.firstChild())e&&e.depth++,i&&i.depth++;else for(;!s.nextSibling();){if(!s.parent())break t;if(e&&!--e.depth){let h=fo(this.ranges,e.ranges);h.length&&(lo(h),this.inner.splice(e.index,0,new oo(e.parser,e.parser.startParse(this.input,co(e.mounts,h),h),e.ranges.map(f=>new xt(f.from-e.start,f.to-e.start)),e.bracketed,e.target,h[0].from))),e=e.prev}i&&!--i.depth&&(i=i.prev)}}}}function Tc(n,t,e){for(let i of n){if(i.from>=e)break;if(i.to>t)return i.from<=t&&i.to>=e?2:1}return 0}function ao(n,t,e,i,s,r){if(t<e){let o=n.buffer[t+1];i.push(n.slice(t,e,o)),s.push(o-r)}}function Bc(n){let{node:t}=n,e=[],i=t.context.buffer;do e.push(n.index),n.parent();while(!n.tree);let s=n.tree,r=s.children.indexOf(i),o=s.children[r],l=o.buffer,a=[r];function h(f,c,u,d,p,g){let m=e[g],b=[],x=[];ao(o,f,m,b,x,d);let v=l[m+1],T=l[m+2];a.push(b.length);let C=g?h(m+4,l[m+3],o.set.types[l[m]],v,T-v,g-1):t.toTree();return b.push(C),x.push(v-d),ao(o,l[m+3],c,b,x,d),new q(u,b,x,p)}s.children[r]=h(0,l.length,ht.none,0,o.length,e.length-1);for(let f of a){let c=n.tree.children[f],u=n.tree.positions[f];n.yield(new nt(c,u+n.from,f,n._tree))}}class ho{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(F.IncludeAnonymous|F.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)e.to>=t&&e.enter(i,1,F.IgnoreOverlays|F.ExcludeBuffers)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(e.children.length&&e.positions[0]==0&&e.children[0]instanceof q)e=e.children[0];else break}return!1}}let Oc=class{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=(e=i.tree.prop(Mn))!==null&&e!==void 0?e:i.to,this.inner=new ho(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=(t=e.tree.prop(Mn))!==null&&t!==void 0?t:e.to,this.inner=new ho(e.tree,-e.offset)}}findMounts(t,e){var i;let s=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let r=this.inner.cursor.node;r;r=r.parent){let o=(i=r.tree)===null||i===void 0?void 0:i.prop(P.mounted);if(o&&o.parser==e)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=r.to)break;a.tree==this.curFrag.tree&&s.push({frag:a,pos:r.from-a.offset,mount:o})}}}return s}};function fo(n,t){let e=null,i=t;for(let s=1,r=0;s<n.length;s++){let o=n[s-1].to,l=n[s].from;for(;r<i.length;r++){let a=i[r];if(a.from>=l)break;a.to<=o||(e||(i=e=t.slice()),a.from<o?(e[r]=new xt(a.from,o),a.to>l&&e.splice(r+1,0,new xt(l,a.to))):a.to>l?e[r--]=new xt(l,a.to):e.splice(r--,1))}}return i}function Dc(n,t,e,i){let s=0,r=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let f=s==n.length?1e9:o?n[s].to:n[s].from,c=r==t.length?1e9:l?t[r].to:t[r].from;if(o!=l){let u=Math.max(a,e),d=Math.min(f,c,i);u<d&&h.push(new xt(u,d))}if(a=Math.min(f,c),a==1e9)break;f==a&&(o?(o=!1,s++):o=!0),c==a&&(l?(l=!1,r++):l=!0)}return h}function co(n,t){let e=[];for(let{pos:i,mount:s,frag:r}of n){let o=i+(s.overlay?s.overlay[0].from:0),l=o+s.tree.length,a=Math.max(r.from,o),h=Math.min(r.to,l);if(s.overlay){let f=s.overlay.map(u=>new xt(u.from+i,u.to+i)),c=Dc(t,f,a,h);for(let u=0,d=a;;u++){let p=u==c.length,g=p?h:c[u].from;if(g>d&&e.push(new Ut(d,g,s.tree,-o,r.from>=d||r.openStart,r.to<=g||r.openEnd)),p)break;d=c[u].to}}else e.push(new Ut(a,h,s.tree,-o,r.from>=o||r.openStart,r.to<=l||r.openEnd))}return e}var uo={};class os{constructor(t,e,i,s,r,o,l,a,h,f=0,c){this.p=t,this.stack=e,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=f,this.parent=c}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let s=t.parser.context;return new os(t,[],e,i,i,0,[],0,s?new po(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,s=t&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=r.dynamicPrecedence(s);if(l&&(this.score+=l),i==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let a=this.stack.length-(i-1)*3-(t&262144?6:0),h=a?this.stack[a-2]:this.p.ranges[0].from,f=this.reducePos-h;f>=2e3&&!(!((e=this.p.parser.nodeSet.types[s])===null||e===void 0)&&e.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=f):this.p.lastBigReductionSize<f&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=f));let c=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-c;if(s<r.minRepeatTerm||t&131072){let d=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,h,d,u+4,!0)}if(t&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=r.getGoto(d,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,h)}storeNode(t,e,i,s=4,r=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(e==i)return;if(o.buffer[l-2]>=e){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(t,e,i,s);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4)}this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(t,e,i,s){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let r=t,{parser:o}=this.p;this.pos=s;let l=o.stateFlag(r,1);!l&&(s>i||e<=o.maxNode)&&(this.reducePos=s),this.pushState(r,l?i:Math.min(i,this.reducePos)),this.shiftContext(e,i),e<=o.maxNode&&this.buffer.push(e,i,s,4)}else this.pos=s,this.shiftContext(e,i),e<=this.p.parser.maxNode&&this.buffer.push(e,i,s,4)}apply(t,e,i,s){t&65536?this.reduce(t):this.shift(t,e,i,s)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let s=this.pos;this.reducePos=this.pos=s+t.length,this.pushState(e,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),s=t.bufferBase+e;for(;t&&s==t.bufferBase;)t=t.parent;return new os(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new Pc(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if((i&65536)==0)return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let s=[];for(let r=0,o;r<e.length;r+=2)(o=e[r+1])!=this.state&&this.p.parser.hasAction(o,t)&&s.push(e[r],o);if(this.stack.length<120)for(let r=0;s.length<8&&r<e.length;r+=2){let o=e[r+1];s.some((l,a)=>a&1&&l==o)||s.push(e[r],o)}e=s}let i=[];for(let s=0;s<e.length&&i.length<4;s+=2){let r=e[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(e[s],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let i=e>>19,s=e&65535,r=this.stack.length-i*3;if(r<0||t.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;e=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],i=(s,r)=>{if(!e.includes(s))return e.push(s),t.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&t.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new po(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class po{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class Pc{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=s}}class ls{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new ls(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new ls(this.stack,this.pos,this.index)}}function Qe(n,t=Uint16Array){if(typeof n!="string")return n;let e=null;for(let i=0,s=0;i<n.length;){let r=0;for(;;){let o=n.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}e?e[s++]=r:e=new t(r)}return e}class Gi{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const go=new Gi;class Ic{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=go,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,s=this.rangeIndex,r=this.pos+t;for(;r<i.from;){if(!s)return null;let o=this.ranges[--s];r-=i.from-o.to,i=o}for(;e<0?r>i.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,s;if(e>=0&&e<this.chunk.length)i=this.pos+t,s=this.chunk.charCodeAt(e);else{let r=this.resolveOffset(t,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=go,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let s of this.ranges){if(s.from>=e)break;s.to>t&&(i+=this.input.read(Math.max(s.from,t),Math.min(s.to,e)))}return i}}class Pe{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;fa(this.data,t,e,this.id,i.data,i.tokenPrecTable)}}Pe.prototype.contextual=Pe.prototype.fallback=Pe.prototype.extend=!1;class Lc{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data=typeof t=="string"?Qe(t):t}token(t,e){let i=t.pos,s=0;for(;;){let r=t.next<0,o=t.resolveOffset(1,1);if(fa(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(r||s++,o==null)break;t.reset(o,t.token)}s&&(t.reset(i,t.token),t.acceptToken(this.elseToken,s))}}Lc.prototype.contextual=Pe.prototype.fallback=Pe.prototype.extend=!1;class yp{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function fa(n,t,e,i,s,r){let o=0,l=1<<i,{dialect:a}=e.p.parser;t:for(;(l&n[o])!=0;){let h=n[o+1];for(let d=o+3;d<h;d+=2)if((n[d+1]&l)>0){let p=n[d];if(a.allows(p)&&(t.token.value==-1||t.token.value==p||Rc(p,t.token.value,s,r))){t.acceptToken(p);break}}let f=t.next,c=0,u=n[o+2];if(t.next<0&&u>c&&n[h+u*3-3]==65535){o=n[h+u*3-1];continue t}for(;c<u;){let d=c+u>>1,p=h+d+(d<<1),g=n[p],m=n[p+1]||65536;if(f<g)u=d;else if(f>=m)c=d+1;else{o=n[p+2],t.advance();continue t}}break}}function mo(n,t,e){for(let i=t,s;(s=n[i])!=65535;i++)if(s==e)return i-t;return-1}function Rc(n,t,e,i){let s=mo(e,i,t);return s<0||mo(e,i,n)<s}const dt=typeof process<"u"&&uo&&/\bparse\b/.test(uo.LOG);let Ws=null;function bo(n,t,e){let i=n.cursor(F.IncludeAnonymous);for(i.moveTo(t);;)if(!(e<0?i.childBefore(t):i.childAfter(t)))for(;;){if((e<0?i.to<t:i.from>t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(n.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:n.length}}class Ec{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?bo(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?bo(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],s=this.index[e];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[s],o=this.start[e]+i.positions[s];if(o>t)return this.nextStart=o,null;if(r instanceof q){if(o==t){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(P.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[e]++,o+r.length>=Math.max(this.safeFrom,t)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+r.length}}}class Nc{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new Gi)}getActions(t){let e=0,i=null,{parser:s}=t.p,{tokenizers:r}=s,o=s.stateSlot(t.state,3),l=t.curContext?t.curContext.hash:0,a=0;for(let h=0;h<r.length;h++){if((1<<h&o)==0)continue;let f=r[h],c=this.tokens[h];if(!(i&&!f.fallback)&&((f.contextual||c.start!=t.pos||c.mask!=o||c.context!=l)&&(this.updateCachedToken(c,f,t),c.mask=o,c.context=l),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),c.value!=0)){let u=e;if(c.extended>-1&&(e=this.addActions(t,c.extended,c.end,e)),e=this.addActions(t,c.value,c.end,e),!f.extend&&(i=c,e>u))break}}for(;this.actions.length>e;)this.actions.pop();return a&&t.setLookAhead(a),!i&&t.pos==this.stream.end&&(i=new Gi,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new Gi,{pos:i,p:s}=t;return e.start=i,e.end=Math.min(i+1,s.stream.end),e.value=i==s.stream.end?s.parser.eofTerm:0,e}updateCachedToken(t,e,i){let s=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(s,t),i),t.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==t.value){let l=r.specializers[o](this.stream.read(t.start,t.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?t.value=l>>1:t.extended=l>>1;break}}}else t.value=0,t.end=this.stream.clipPos(s+1)}putAction(t,e,i,s){for(let r=0;r<s;r+=3)if(this.actions[r]==t)return s;return this.actions[s++]=t,this.actions[s++]=e,this.actions[s++]=i,s}addActions(t,e,i,s){let{state:r}=t,{parser:o}=t.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(r,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=zt(l,h+2);else{s==0&&l[h+1]==2&&(s=this.putAction(zt(l,h+2),e,i,s));break}l[h]==e&&(s=this.putAction(zt(l,h+1),e,i,s))}return s}}class Fc{constructor(t,e,i,s){this.parser=t,this.input=e,this.ranges=s,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Ic(e,s),this.tokens=new Nc(t,this.stream),this.topTerm=t.top[1];let{from:r}=s[0];this.stacks=[os.start(this,t.top[0],r)],this.fragments=i.length&&this.stream.end-r>t.bufferLength*4?new Ec(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],s,r;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<t.length;o++){let l=t[o];for(;;){if(this.tokens.mainToken=null,l.pos>e)i.push(l);else{if(this.advanceStack(l,i,t))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&Vc(s);if(o)return dt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw dt&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return dt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let h=i[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue t}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let s=t.pos,{parser:r}=this,o=dt?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let h=t.curContext&&t.curContext.tracker.strict,f=h?t.curContext.hash:0;for(let c=this.fragments.nodeAt(s);c;){let u=this.parser.nodeSet.types[c.type.id]==c.type?r.getGoto(t.state,c.type.id):-1;if(u>-1&&c.length&&(!h||(c.prop(P.contextHash)||0)==f))return t.useNode(c,u),dt&&console.log(o+this.stackID(t)+` (via reuse of ${r.getName(c.type.id)})`),!0;if(!(c instanceof q)||c.children.length==0||c.positions[0]>0)break;let d=c.children[0];if(d instanceof q&&c.positions[0]==0)c=d;else break}}let l=r.stateSlot(t.state,4);if(l>0)return t.reduce(l),dt&&console.log(o+this.stackID(t)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let a=this.tokens.getActions(t);for(let h=0;h<a.length;){let f=a[h++],c=a[h++],u=a[h++],d=h==a.length||!i,p=d?t:t.split(),g=this.tokens.mainToken;if(p.apply(f,c,g?g.start:p.pos,u),dt&&console.log(o+this.stackID(p)+` (via ${(f&65536)==0?"shift":`reduce of ${r.getName(f&65535)}`} for ${r.getName(c)} @ ${s}${p==t?"":", split"})`),d)return!0;p.pos>s?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return yo(t,e),!0}}runRecovery(t,e,i){let s=null,r=!1;for(let o=0;o<t.length;o++){let l=t[o],a=e[o<<1],h=e[(o<<1)+1],f=dt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),dt&&console.log(f+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let c=l.split(),u=f;for(let d=0;d<10&&c.forceReduce()&&(dt&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));d++)dt&&(u=this.stackID(c)+" -> ");for(let d of l.recoverByInsert(a))dt&&console.log(f+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),dt&&console.log(f+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),yo(l,i)):(!s||s.score<c.score)&&(s=c)}return s}stackToTree(t){return t.close(),q.build({buffer:ls.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(Ws||(Ws=new WeakMap)).get(t);return e||Ws.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function yo(n,t){for(let e=0;e<t.length;e++){let i=t[e];if(i.pos==n.pos&&i.sameState(n)){t[e].score<n.score&&(t[e]=n);return}}t.push(n)}class Wc{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||this.disabled[t]==0}}const Vs=n=>n;class xp{constructor(t){this.start=t.start,this.shift=t.shift||Vs,this.reduce=t.reduce||Vs,this.reuse=t.reuse||Vs,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class Tn extends ha{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let l=0;l<t.repeatNodeCount;l++)e.push("");let i=Object.keys(t.topRules).map(l=>t.topRules[l][1]),s=[];for(let l=0;l<e.length;l++)s.push([]);function r(l,a,h){s[l].push([a,a.deserialize(String(h))])}if(t.nodeProps)for(let l of t.nodeProps){let a=l[0];typeof a=="string"&&(a=P[a]);for(let h=1;h<l.length;){let f=l[h++];if(f>=0)r(f,a,l[h++]);else{let c=l[h+-f];for(let u=-f;u>0;u--)r(l[h++],a,c);h++}}}this.nodeSet=new Qn(e.map((l,a)=>ht.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(a)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=ra;let o=Qe(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(xo),this.states=Qe(t.states,Uint32Array),this.data=Qe(t.stateData),this.goto=Qe(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(l=>typeof l=="number"?new Pe(o,l):l),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let s=new Fc(this,t,e,i);for(let r of this.wrappers)s=r(s,t,e,i);return s}getGoto(t,e,i=!1){let s=this.goto;if(e>=s[0])return-1;for(let r=s[e+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let h=r+(o>>1);r<h;r++)if(s[r]==t)return a;if(l)return-1}}hasAction(t,e){let i=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(t,s?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=zt(i,r+2)];else{if(i[r+1]==2)return zt(i,r+2);break}if(o==e||o==0)return zt(i,r+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,i=>i==e?!0:null)}allActions(t,e){let i=this.stateSlot(t,4),s=i?e(i):void 0;for(let r=this.stateSlot(t,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=zt(this.data,r+2);else break;s=e(zt(this.data,r+1))}return s}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=zt(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];e.some((r,o)=>o&1&&r==s)||e.push(this.data[i],s)}}return e}configure(t){let e=Object.assign(Object.create(Tn.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let s=t.tokenizers.find(r=>r.from==i);return s?s.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=t.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return e.specializers[s]=xo(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let r of t.split(" ")){let o=e.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;r<e.length;r++)if(!i[r])for(let o=this.dialects[e[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new Wc(t,i,s)}static deserialize(t){return new Tn(t)}}function zt(n,t){return n[t]|n[t+1]<<16}function Vc(n){let t=null;for(let e of n){let i=e.p.stoppedAt;(e.pos==e.p.stream.end||i!=null&&e.pos>i)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function xo(n){if(n.external){let t=n.extend?1:0;return(e,i)=>n.external(e,i)<<1|t}return n.get}let Hc=0;class bt{constructor(t,e,i,s){this.name=t,this.set=e,this.base=i,this.modified=s,this.id=Hc++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i=typeof t=="string"?t:"?";if(t instanceof bt&&(e=t),e!=null&&e.base)throw new Error("Can not derive from a modified tag");let s=new bt(i,[],null,[]);if(s.set.push(s),e)for(let r of e.set)s.set.push(r);return s}static defineModifier(t){let e=new as(t);return i=>i.modified.indexOf(e)>-1?i:as.get(i.base||i,i.modified.concat(e).sort((s,r)=>s.id-r.id))}}let zc=0;class as{constructor(t){this.name=t,this.instances=[],this.id=zc++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&Kc(e,l.modified));if(i)return i;let s=[],r=new bt(t.name,s,t,e);for(let l of e)l.instances.push(r);let o=$c(e);for(let l of t.set)if(!l.modified.length)for(let a of o)s.push(as.get(l,a));return r}}function Kc(n,t){return n.length==t.length&&n.every((e,i)=>e==t[i])}function $c(n){let t=[[]];for(let e=0;e<n.length;e++)for(let i=0,s=t.length;i<s;i++)t.push(t[i].concat(n[e]));return t.sort((e,i)=>i.length-e.length)}function qc(n){let t=Object.create(null);for(let e in n){let i=n[e];Array.isArray(i)||(i=[i]);for(let s of e.split(" "))if(s){let r=[],o=2,l=s;for(let c=0;;){if(l=="..."&&c>0&&c+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==s.length)break;let d=s[c++];if(c==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(c)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let f=new pi(i,o,a>0?r.slice(0,a):null);t[h]=f.sort(t[h])}}return ca.add(t)}const ca=new P({combine(n,t){let e,i,s;for(;n||t;){if(!n||t&&n.depth>=t.depth?(s=t,t=t.next):(s=n,n=n.next),e&&e.mode==s.mode&&!s.context&&!e.context)continue;let r=new pi(s.tags,s.mode,s.context);e?e.next=r:i=r,e=r}return i}});class pi{constructor(t,e,i,s){this.tags=t,this.mode=e,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}pi.empty=new pi([],2,null);function ua(n,t){let e=Object.create(null);for(let r of n)if(!Array.isArray(r.tag))e[r.tag.id]=r.class;else for(let o of r.tag)e[o.id]=r.class;let{scope:i,all:s=null}=t||{};return{style:r=>{let o=s;for(let l of r)for(let a of l.set){let h=e[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function jc(n,t){let e=null;for(let i of n){let s=i.style(t);s&&(e=e?e+" "+s:s)}return e}function Uc(n,t,e,i=0,s=n.length){let r=new Gc(i,Array.isArray(t)?t:[t],e);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class Gc{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,s,r){let{type:o,from:l,to:a}=t;if(l>=i||a<=e)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,f=_c(t)||pi.empty,c=jc(r,f.tags);if(c&&(h&&(h+=" "),h+=c,f.mode==1&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(e,l),h),f.opaque)return;let u=t.tree&&t.tree.prop(P.mounted);if(u&&u.overlay){let d=t.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),g=t.firstChild();for(let m=0,b=l;;m++){let x=m<u.overlay.length?u.overlay[m]:null,v=x?x.from+l:a,T=Math.max(e,b),C=Math.min(i,v);if(T<C&&g)for(;t.from<C&&(this.highlightRange(t,T,C,s,r),this.startSpan(Math.min(C,t.to),h),!(t.to>=v||!t.nextSibling())););if(!x||v>i)break;b=x.to+l,b>e&&(this.highlightRange(d.cursor(),Math.max(e,x.from+l),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),h))}g&&t.parent()}else if(t.firstChild()){u&&(s="");do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,s,r),this.startSpan(Math.min(i,t.to),h)}while(t.nextSibling());t.parent()}}}function _c(n){let t=n.type.prop(ca);for(;t&&t.context&&!n.matchContext(t.context);)t=t.next;return t||null}const k=bt.define,Wi=k(),Jt=k(),wo=k(Jt),ko=k(Jt),Xt=k(),Vi=k(Xt),Hs=k(Xt),Rt=k(),ae=k(Rt),It=k(),Lt=k(),Bn=k(),Ge=k(Bn),Hi=k(),y={comment:Wi,lineComment:k(Wi),blockComment:k(Wi),docComment:k(Wi),name:Jt,variableName:k(Jt),typeName:wo,tagName:k(wo),propertyName:ko,attributeName:k(ko),className:k(Jt),labelName:k(Jt),namespace:k(Jt),macroName:k(Jt),literal:Xt,string:Vi,docString:k(Vi),character:k(Vi),attributeValue:k(Vi),number:Hs,integer:k(Hs),float:k(Hs),bool:k(Xt),regexp:k(Xt),escape:k(Xt),color:k(Xt),url:k(Xt),keyword:It,self:k(It),null:k(It),atom:k(It),unit:k(It),modifier:k(It),operatorKeyword:k(It),controlKeyword:k(It),definitionKeyword:k(It),moduleKeyword:k(It),operator:Lt,derefOperator:k(Lt),arithmeticOperator:k(Lt),logicOperator:k(Lt),bitwiseOperator:k(Lt),compareOperator:k(Lt),updateOperator:k(Lt),definitionOperator:k(Lt),typeOperator:k(Lt),controlOperator:k(Lt),punctuation:Bn,separator:k(Bn),bracket:Ge,angleBracket:k(Ge),squareBracket:k(Ge),paren:k(Ge),brace:k(Ge),content:Rt,heading:ae,heading1:k(ae),heading2:k(ae),heading3:k(ae),heading4:k(ae),heading5:k(ae),heading6:k(ae),contentSeparator:k(Rt),list:k(Rt),quote:k(Rt),emphasis:k(Rt),strong:k(Rt),link:k(Rt),monospace:k(Rt),strikethrough:k(Rt),inserted:k(),deleted:k(),changed:k(),invalid:k(),meta:Hi,documentMeta:k(Hi),annotation:k(Hi),processingInstruction:k(Hi),definition:bt.defineModifier("definition"),constant:bt.defineModifier("constant"),function:bt.defineModifier("function"),standard:bt.defineModifier("standard"),local:bt.defineModifier("local"),special:bt.defineModifier("special")};for(let n in y){let t=y[n];t instanceof bt&&(t.name=n)}ua([{tag:y.link,class:"tok-link"},{tag:y.heading,class:"tok-heading"},{tag:y.emphasis,class:"tok-emphasis"},{tag:y.strong,class:"tok-strong"},{tag:y.keyword,class:"tok-keyword"},{tag:y.atom,class:"tok-atom"},{tag:y.bool,class:"tok-bool"},{tag:y.url,class:"tok-url"},{tag:y.labelName,class:"tok-labelName"},{tag:y.inserted,class:"tok-inserted"},{tag:y.deleted,class:"tok-deleted"},{tag:y.literal,class:"tok-literal"},{tag:y.string,class:"tok-string"},{tag:y.number,class:"tok-number"},{tag:[y.regexp,y.escape,y.special(y.string)],class:"tok-string2"},{tag:y.variableName,class:"tok-variableName"},{tag:y.local(y.variableName),class:"tok-variableName tok-local"},{tag:y.definition(y.variableName),class:"tok-variableName tok-definition"},{tag:y.special(y.variableName),class:"tok-variableName2"},{tag:y.definition(y.propertyName),class:"tok-propertyName tok-definition"},{tag:y.typeName,class:"tok-typeName"},{tag:y.namespace,class:"tok-namespace"},{tag:y.className,class:"tok-className"},{tag:y.macroName,class:"tok-macroName"},{tag:y.propertyName,class:"tok-propertyName"},{tag:y.operator,class:"tok-operator"},{tag:y.comment,class:"tok-comment"},{tag:y.meta,class:"tok-meta"},{tag:y.invalid,class:"tok-invalid"},{tag:y.punctuation,class:"tok-punctuation"}]);var zs;const Se=new P;function Yc(n){return B.define({combine:n?t=>t.concat(n):void 0})}const Jc=new P;class Mt{constructor(t,e,i=[],s=""){this.data=t,this.name=s,E.prototype.hasOwnProperty("tree")||Object.defineProperty(E.prototype,"tree",{get(){return vt(this)}}),this.parser=e,this.extension=[Ve.of(this),E.languageData.of((r,o,l)=>{let a=vo(r,o,l),h=a.type.prop(Se);if(!h)return[];let f=r.facet(h),c=a.type.prop(Jc);if(c){let u=a.resolve(o-a.from,l);for(let d of c)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(t,e,i=-1){return vo(t,e,i).type.prop(Se)==this.data}findRegions(t){let e=t.facet(Ve);if((e==null?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Se)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(P.mounted);if(l){if(l.tree.prop(Se)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof q&&s(h,r.positions[a]+o)}};return s(vt(t),0),i}get allowsNesting(){return!0}}Mt.setState=z.define();function vo(n,t,e){let i=n.facet(Ve),s=vt(n).topNode;if(!i||i.allowsNesting)for(let r=s;r;r=r.enter(t,e,F.ExcludeBuffers|F.EnterBracketed))r.type.isTop&&(s=r);return s}class On extends Mt{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Yc(t.languageData);return new On(e,t.parser.configure({props:[Se.add(i=>i.isTop?e:void 0)]}),t.name)}configure(t,e){return new On(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function vt(n){let t=n.field(Mt.state,!1);return t?t.tree:q.empty}class Xc{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let _e=null;class hs{constructor(t,e,i=[],s,r,o,l,a){this.parser=t,this.state=e,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new hs(t,e,[],q.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Xc(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=q.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(Ut.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Ut.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=_e;_e=this;try{return t()}finally{_e=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=So(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let a=[];if(t.iterChangedRanges((h,f,c,u)=>a.push({fromA:h,toA:f,fromB:c,toB:u})),i=Ut.applyChanges(i,a),s=q.empty,r=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let f=t.mapPos(h.from,1),c=t.mapPos(h.to,-1);f<c&&l.push({from:f,to:c})}}}return new hs(this.parser,e,i,s,r,o,l,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:s,to:r}=this.skipped[i];s<t.to&&r>t.from&&(this.fragments=So(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends ha{createParse(e,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=_e;if(a){for(let h of s)a.tempSkipped.push(h);t&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,t]):t)}return this.parsedPos=o,new q(ht.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return _e}}function So(n,t,e){return Ut.applyChanges(n,[{fromA:t,toA:e,fromB:t,toB:e}])}class We{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new We(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=hs.create(t.facet(Ve).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new We(i)}}Mt.state=_t.define({create:We.init,update(n,t){for(let e of t.effects)if(e.is(Mt.setState))return e.value;return t.startState.facet(Ve)!=t.state.facet(Ve)?We.init(t.state):n.apply(t)}});let da=n=>{let t=setTimeout(()=>n(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(da=n=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(n,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const Ks=typeof navigator<"u"&&(!((zs=navigator.scheduling)===null||zs===void 0)&&zs.isInputPending)?()=>navigator.scheduling.isInputPending():null,Qc=Vt.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Mt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Mt.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=da(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,r=i.field(Mt.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!Ks?Math.max(25,t.timeRemaining()-5):1e9),l=r.context.treeLen<s&&i.doc.length>s+1e3,a=r.context.work(()=>Ks&&Ks()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-e,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Mt.setState.of(new We(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>gt(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ve=B.define({combine(n){return n.length?n[0]:null},enables:n=>[Mt.state,Qc,O.contentAttributes.compute([n],t=>{let e=t.facet(n);return e&&e.name?{"data-language":e.name}:{}})]});class kp{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}const Zc=B.define(),ks=B.define({combine:n=>{if(!n.length)return" ";let t=n[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return t}});function fs(n){let t=n.facet(ks);return t.charCodeAt(0)==9?n.tabSize*t.length:t.length}function cs(n,t){let e="",i=n.tabSize,s=n.facet(ks)[0];if(s==" "){for(;t>=i;)e+=" ",t-=i;s=" "}for(let r=0;r<t;r++)e+=s;return e}function pa(n,t){n instanceof E&&(n=new vs(n));for(let i of n.state.facet(Zc)){let s=i(n,t);if(s!==void 0)return s}let e=vt(n.state);return e.length>=t?eu(n,e,t):null}class vs{constructor(t,e={}){this.state=t,this.options=e,this.unit=fs(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(t,e);return i.slice(t-s,Math.min(i.length,t+100-s))}column(t,e=1){let{text:i,from:s}=this.lineAt(t,e),r=this.countColumn(i,t-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return gs(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:s}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const tu=new P;function eu(n,t,e){let i=t.resolveStack(e),s=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(s!=i.node){let r=[];for(let o=s;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return ga(i,n,e)}function ga(n,t,e){for(let i=n;i;i=i.next){let s=su(i.node);if(s)return s(ir.create(t,e,i))}return 0}function iu(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function su(n){let t=n.type.prop(tu);if(t)return t;let e=n.firstChild,i;if(e&&(i=e.type.prop(P.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>ma(o,!0,1,void 0,r&&!iu(o)?s.from:void 0)}return n.parent==null?nu:null}function nu(){return 0}class ir extends vs{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new ir(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(ru(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return ga(this.context.next,this.base,this.pos)}}function ru(n,t){for(let e=t;e;e=e.parent)if(n==e)return!0;return!1}function ou(n){let t=n.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(e.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=e.to;;){let a=t.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(e.to-r.from))[0].length;return{from:e.from,to:e.to+h}}l=a.to}}function vp({closing:n,align:t=!0,units:e=1}){return i=>ma(i,t,e,n)}function ma(n,t,e,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=t?ou(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*e)}const Sp=n=>n.baseIndent;function Cp({except:n,units:t=1}={}){return e=>{let i=n&&n.test(e.textAfter);return e.baseIndent+(i?0:t*e.unit)}}const Ap=new P;function Mp(n){let t=n.firstChild,e=n.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?n.to:e.from}:null}class wi{constructor(t,e){this.specs=t;let i;function s(l){let a=ee.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof e.all=="string"?e.all:e.all?s(e.all):void 0,o=e.scope;this.scope=o instanceof Mt?l=>l.prop(Se)==o.data:o?l=>l==o:void 0,this.style=ua(t.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new ee(i):null,this.themeType=e.themeType}static define(t,e){return new wi(t,e||{})}}const Dn=B.define(),lu=B.define({combine(n){return n.length?[n[0]]:null}});function $s(n){let t=n.facet(Dn);return t.length?t:n.facet(lu)}function au(n,t){let e=[fu],i;return n instanceof wi&&(n.module&&e.push(O.styleModule.of(n.module)),i=n.themeType),i?e.push(Dn.computeN([O.darkTheme],s=>s.facet(O.darkTheme)==(i=="dark")?[n]:[])):e.push(Dn.of(n)),e}class hu{constructor(t){this.markCache=Object.create(null),this.tree=vt(t.state),this.decorations=this.buildDeco(t,$s(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=vt(t.state),i=$s(t.state),s=i!=$s(t.startState),{viewport:r}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<r.to&&!s&&e.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return K.none;let i=new oi;for(let{from:s,to:r}of t.visibleRanges)Uc(this.tree,e,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=K.mark({class:a})))},s,r);return i.finish()}}const fu=He.high(Vt.fromClass(hu,{decorations:n=>n.decorations})),Tp=wi.define([{tag:y.meta,color:"#404740"},{tag:y.link,textDecoration:"underline"},{tag:y.heading,textDecoration:"underline",fontWeight:"bold"},{tag:y.emphasis,fontStyle:"italic"},{tag:y.strong,fontWeight:"bold"},{tag:y.strikethrough,textDecoration:"line-through"},{tag:y.keyword,color:"#708"},{tag:[y.atom,y.bool,y.url,y.contentSeparator,y.labelName],color:"#219"},{tag:[y.literal,y.inserted],color:"#164"},{tag:[y.string,y.deleted],color:"#a11"},{tag:[y.regexp,y.escape,y.special(y.string)],color:"#e40"},{tag:y.definition(y.variableName),color:"#00f"},{tag:y.local(y.variableName),color:"#30a"},{tag:[y.typeName,y.namespace],color:"#085"},{tag:y.className,color:"#167"},{tag:[y.special(y.variableName),y.macroName],color:"#256"},{tag:y.definition(y.propertyName),color:"#00c"},{tag:y.comment,color:"#940"},{tag:y.invalid,color:"#f00"}]),cu=1e4,uu="()[]{}",du=new P;function Pn(n,t,e){let i=n.prop(t<0?P.openedBy:P.closedBy);if(i)return i;if(n.name.length==1){let s=e.indexOf(n.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function In(n){let t=n.type.prop(du);return t?t(n.node):n}function Ce(n,t,e,i={}){let s=i.maxScanDistance||cu,r=i.brackets||uu,o=vt(n),l=o.resolveInner(t,e);for(let a=l;a;a=a.parent){let h=Pn(a.type,e,r);if(h&&a.from<a.to){let f=In(a);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return pu(n,t,e,a,f,h,r)}}return gu(n,t,e,o,l.type,s,r)}function pu(n,t,e,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},h=0,f=l==null?void 0:l.cursor();if(f&&(e<0?f.childBefore(i.from):f.childAfter(i.to)))do if(e<0?f.to<=i.from:f.from>=i.to){if(h==0&&r.indexOf(f.type.name)>-1&&f.from<f.to){let c=In(f);return{start:a,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(Pn(f.type,e,o))h++;else if(Pn(f.type,-e,o)){if(h==0){let c=In(f);return{start:a,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(e<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function gu(n,t,e,i,s,r,o){let l=e<0?n.sliceDoc(t-1,t):n.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=e>0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},f=n.doc.iterRange(t,e>0?n.doc.length:0),c=0;for(let u=0;!f.next().done&&u<=r;){let d=f.value;e<0&&(u+=d.length);let p=t+u*e;for(let g=e>0?0:d.length-1,m=e>0?d.length:-1;g!=m;g+=e){let b=o.indexOf(d[g]);if(!(b<0||i.resolveInner(p+g,1).type!=s))if(b%2==0==e>0)c++;else{if(c==1)return{start:h,end:{from:p+g,to:p+g+1},matched:b>>1==a>>1};c--}}e>0&&(u+=d.length)}return f.done?{start:h,matched:!1}:null}const mu=Object.create(null),Co=[ht.none],Ao=[],Mo=Object.create(null),bu=Object.create(null);for(let[n,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])bu[n]=yu(mu,t);function qs(n,t){Ao.indexOf(n)>-1||(Ao.push(n),console.warn(t))}function yu(n,t){let e=[];for(let l of t.split(" ")){let a=[];for(let h of l.split(".")){let f=n[h]||y[h];f?typeof f=="function"?a.length?a=a.map(f):qs(h,`Modifier ${h} used at start of tag`):a.length?qs(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:qs(h,`Unknown highlighting tag ${h}`)}for(let h of a)e.push(h)}if(!e.length)return 0;let i=t.replace(/ /g,"_"),s=i+" "+e.map(l=>l.id),r=Mo[s];if(r)return r.id;let o=Mo[s]=ht.define({id:Co.length,name:i,props:[qc({[i]:e})]});return Co.push(o),o.id}G.RTL,G.LTR;class ba{constructor(t,e,i,s){this.state=t,this.pos=e,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=vt(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),s=e.text.slice(i-e.from,this.pos-e.from),r=s.search(ya(t,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(t,e,i){t=="abort"&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function To(n){let t=Object.keys(n).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function xu(n){let t=Object.create(null),e=Object.create(null);for(let{label:s}of n){t[s[0]]=!0;for(let r=1;r<s.length;r++)e[s[r]]=!0}let i=To(t)+To(e)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function wu(n){let t=n.map(s=>typeof s=="string"?{label:s}:s),[e,i]=t.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:xu(t);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:t,validFor:e}:null}}function Bp(n,t){return e=>{for(let i=vt(e.state).resolveInner(e.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return t(e)}}class Bo{constructor(t,e,i,s){this.completion=t,this.source=e,this.match=i,this.score=s}}function pe(n){return n.selection.main.from}function ya(n,t){var e;let{source:i}=n,s=t&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(e=n.flags)!==null&&e!==void 0?e:n.ignoreCase?"i":"")}const sr=ye.define();function ku(n,t,e,i){let{main:s}=n.selection,r=e-s.from,o=i-s.from;return{...n.changeByRange(l=>{if(l!=s&&e!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(e,i))return{range:l};let a=n.toText(t);return{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:a},range:w.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Oo=new WeakMap;function vu(n){if(!Array.isArray(n))return n;let t=Oo.get(n);return t||Oo.set(n,t=wu(n)),t}const us=z.define(),gi=z.define();class Su{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=he(t,e),s=we(i);this.chars.push(i);let r=t.slice(e,e+s),o=r.toUpperCase();this.folded.push(he(o==r?r.toLowerCase():o,0)),e+=s}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:s,precise:r,byWord:o}=this;if(e.length==1){let x=he(t,0),v=we(x),T=v==t.length?0:-100;if(x!=e[0])if(x==i[0])T+=-200;else return null;return this.ret(T,[0,v])}let l=t.indexOf(this.pattern);if(l==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=e.length,h=0;if(l<0){for(let x=0,v=Math.min(t.length,200);x<v&&h<a;){let T=he(t,x);(T==e[h]||T==i[h])&&(s[h++]=x),x+=we(T)}if(h<a)return null}let f=0,c=0,u=!1,d=0,p=-1,g=-1,m=/[a-z]/.test(t),b=!0;for(let x=0,v=Math.min(t.length,200),T=0;x<v&&c<a;){let C=he(t,x);l<0&&(f<a&&C==e[f]&&(r[f++]=x),d<a&&(C==e[d]||C==i[d]?(d==0&&(p=x),g=x+1,d++):d=0));let M,A=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(M=nh(C))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!x||A==1&&m||T==0&&A!=0)&&(e[c]==C||i[c]==C&&(u=!0)?o[c++]=x:o.length&&(b=!1)),T=A,x+=we(C)}return c==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,t):d==a&&p==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==a?this.ret(-900-t.length,[p,g]):c==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,t):e.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,t)}result(t,e,i){let s=[],r=0;for(let o of e){let l=o+(this.astral?we(he(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(t-i.length,s)}}class Cu{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const X=B.define({combine(n){return mh(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Au,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>Do(t(i),e(i)),optionClass:(t,e)=>i=>Do(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})}});function Do(n,t){return n?t?n+" "+t:n:t}function Au(n,t,e,i,s,r){let o=n.textDirection==G.RTL,l=o,a=!1,h="top",f,c,u=t.left-s.left,d=s.right-t.right,p=i.right-i.left,g=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))f=Math.max(s.top,Math.min(e.top,s.bottom-g))-t.top,c=Math.min(400,l?u:d);else{a=!0,c=Math.min(400,(o?t.right:s.right-t.left)-30);let x=s.bottom-t.bottom;x>=g||x>t.top?f=e.bottom-t.top:(h="bottom",f=t.bottom-e.top)}let m=(t.bottom-t.top)/r.offsetHeight,b=(t.right-t.left)/r.offsetWidth;return{style:`${h}: ${f/m}px; max-width: ${c/b}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const nr=z.define();function Mu(n){let t=n.addToOptions.slice();return n.icons&&t.push({render(e){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),e.type&&i.classList.add(...e.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),t.push({render(e,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=e.displayLabel||e.label,a=0;for(let h=0;h<r.length;){let f=r[h++],c=r[h++];f>a&&o.appendChild(document.createTextNode(l.slice(a,f)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(f,c))),u.className="cm-completionMatchedText",a=c}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(e){if(!e.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=e.detail,i},position:80}),t.sort((e,i)=>e.position-i.position).map(e=>e.render)}function js(n,t,e){if(n<=e)return{from:0,to:n};if(t<0&&(t=0),t<=n>>1){let s=Math.floor(t/e);return{from:s*e,to:(s+1)*e}}let i=Math.floor((n-t)/e);return{from:n-(i+1)*e,to:n-i*e}}class Tu{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=t.state.field(e),{options:r,selected:o}=s.open,l=t.state.facet(X);this.optionContent=Mu(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=js(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=t.state.field(e).open;for(let f=a.target,c;f&&f!=this.dom;f=f.parentNode)if(f.nodeName=="LI"&&(c=/-(\d+)$/.exec(f.id))&&+c[1]<h.length){this.applyCompletion(t,h[+c[1]]),a.preventDefault();return}if(a.target==this.list){let f=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;f!=null&&(t.dispatch({effects:nr.of(f)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=t.state.field(this.stateField,!1);h&&h.tooltip&&t.state.facet(X).closeOnBlur&&a.relatedTarget!=t.contentDOM&&t.dispatch({effects:gi.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var e;let i=t.state.field(this.stateField),s=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=js(r.length,o,t.state.facet(X).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((e=s.open)===null||e===void 0?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of e.split(" "))i&&this.dom.classList.add(i);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=js(e.options.length,e.selected,this.view.state.facet(X).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:s}=e.options[e.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(l,s)}).catch(l=>gt(this.view.state,l,"completion info")):(this.addInfoPane(o,s),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),t.nodeType!=null)i.appendChild(t),this.infoDestroy=null;else{let{dom:s,destroy:r}=t;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return e&&Ou(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=t.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,e.bottom)-10||s.bottom<Math.max(r.top,e.top)+10?null:this.view.state.facet(X).positionInfo(this.view,e,s,i,r,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const s=document.createElement("ul");s.id=e,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=t[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof h!="string"&&h.header)s.appendChild(h.header(h));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const f=s.appendChild(document.createElement("li"));f.id=e+"-"+o,f.setAttribute("role","option");let c=this.optionClass(l);c&&(f.className=c);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&f.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Bu(n,t){return e=>new Tu(e,n,t)}function Ou(n,t){let e=n.getBoundingClientRect(),i=t.getBoundingClientRect(),s=e.height/n.offsetHeight;i.top<e.top?n.scrollTop-=(e.top-i.top)/s:i.bottom>e.bottom&&(n.scrollTop+=(i.bottom-e.bottom)/s)}function Po(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Du(n,t){let e=[],i=null,s=null,r=f=>{e.push(f);let{section:c}=f.completion;if(c){i||(i=[]);let u=typeof c=="string"?c:c.name;i.some(d=>d.name==u)||i.push(typeof c=="string"?{name:u}:c)}},o=t.facet(X);for(let f of n)if(f.hasResult()){let c=f.result.getMatch;if(f.result.filter===!1)for(let u of f.result.options)r(new Bo(u,f.source,c?c(u):[],1e9-e.length));else{let u=t.sliceDoc(f.from,f.to),d,p=o.filterStrict?new Cu(u):new Su(u);for(let g of f.result.options)if(d=p.match(g.label)){let m=g.displayLabel?c?c(g,d.matched):[]:d.matched,b=d.score+(g.boost||0);if(r(new Bo(g,f.source,m,b)),typeof g.section=="object"&&g.section.rank==="dynamic"){let{name:x}=g.section;s||(s=Object.create(null)),s[x]=Math.max(b,s[x]||-1e9)}}}}if(i){let f=Object.create(null),c=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?s[p.name]-s[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(u))c-=1e5,f[d.name]=c;for(let d of e){let{section:p}=d.completion;p&&(d.score+=f[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let f of e.sort((c,u)=>u.score-c.score||h(c.completion,u.completion))){let c=f.completion;!a||a.label!=c.label||a.detail!=c.detail||a.type!=null&&c.type!=null&&a.type!=c.type||a.apply!=c.apply||a.boost!=c.boost?l.push(f):Po(f.completion)>Po(a)&&(l[l.length-1]=f),a=f.completion}return l}class Ae{constructor(t,e,i,s,r,o){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new Ae(this.options,Io(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,s,r,o){if(s&&!o&&t.some(h=>h.isPending))return s.setDisabled();let l=Du(t,e);if(!l.length)return s&&t.some(h=>h.isPending)?s.setDisabled():null;let a=e.facet(X).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let h=s.options[s.selected].completion;for(let f=0;f<l.length;f++)if(l[f].completion==h){a=f;break}}return new Ae(l,Io(i,a),{pos:t.reduce((h,f)=>f.hasResult()?Math.min(h,f.from):h,1e8),create:Nu,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(t){return new Ae(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ae(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ds{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new ds(Ru,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:e}=t,i=e.facet(X),r=(i.override||e.languageDataAt("autocomplete",pe(e)).map(vu)).map(a=>(this.active.find(f=>f.source==a)||new wt(a,this.active.some(f=>f.state!=0)?1:0)).update(t,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=t.effects.some(a=>a.is(rr));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||r.some(a=>a.hasResult()&&t.changes.touchesRange(a.from,a.to))||!Pu(r,this.active)||l?o=Ae.build(r,e,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new wt(a.source,0):a));for(let a of t.effects)a.is(nr)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new ds(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Iu:Lu}}function Pu(n,t){if(n==t)return!0;for(let e=0,i=0;;){for(;e<n.length&&!n[e].hasResult();)e++;for(;i<t.length&&!t[i].hasResult();)i++;let s=e==n.length,r=i==t.length;if(s||r)return s==r;if(n[e++].result!=t[i++].result)return!1}}const Iu={"aria-autocomplete":"list"},Lu={};function Io(n,t){let e={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return t>-1&&(e["aria-activedescendant"]=n+"-"+t),e}const Ru=[];function xa(n,t){if(n.isUserEvent("input.complete")){let i=n.annotation(sr);if(i&&t.activateOnCompletion(i))return 12}let e=n.isUserEvent("input.type");return e&&t.activateOnTyping?5:e?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class wt{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(t,e){let i=xa(t,e),s=this;(i&8||i&16&&this.touches(t))&&(s=new wt(s.source,0)),i&4&&s.state==0&&(s=new wt(this.source,1)),s=s.updateFor(t,i);for(let r of t.effects)if(r.is(us))s=new wt(s.source,1,r.value);else if(r.is(gi))s=new wt(s.source,0);else if(r.is(rr))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(pe(t.state))}}class Ie extends wt{constructor(t,e,i,s,r,o){super(t,3,e),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(t,e){var i;if(!(e&3))return this.map(t.changes);let s=this.result;s.map&&!t.changes.empty&&(s=s.map(s,t.changes));let r=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),l=pe(t.state);if(l>o||!s||e&2&&(pe(t.startState)==this.from||l<this.limit))return new wt(this.source,e&4?1:0);let a=t.changes.mapPos(this.limit);return Eu(s.validFor,t.state,r,o)?new Ie(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new ba(t.state,l,!1)))?new Ie(this.source,this.explicit,a,s,s.from,(i=s.to)!==null&&i!==void 0?i:pe(t.state)):new wt(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Ie(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new wt(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Eu(n,t,e,i){if(!n)return!1;let s=t.sliceDoc(e,i);return typeof n=="function"?n(s,e,i,t):ya(n,!0).test(s)}const rr=z.define({map(n,t){return n.map(e=>e.map(t))}}),ft=_t.define({create(){return ds.start()},update(n,t){return n.update(t)},provide:n=>[sa.from(n,t=>t.tooltip),O.contentAttributes.from(n,t=>t.attrs)]});function or(n,t){const e=t.completion.apply||t.completion.label;let i=n.state.field(ft).active.find(s=>s.source==t.source);return i instanceof Ie?(typeof e=="string"?n.dispatch({...ku(n.state,e,i.from,i.to),annotations:sr.of(t.completion)}):e(n,t.completion,i.from,i.to),!0):!1}const Nu=Bu(ft,or);function zi(n,t="option"){return e=>{let i=e.state.field(ft,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<e.state.facet(X).interactionDelay)return!1;let s=1,r;t=="page"&&(r=na(e,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=t=="page"?0:o-1:l>=o&&(l=t=="page"?o-1:0),e.dispatch({effects:nr.of(l)}),!0}}const Fu=n=>{let t=n.state.field(ft,!1);return n.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<n.state.facet(X).interactionDelay?!1:or(n,t.open.options[t.open.selected])},Us=n=>n.state.field(ft,!1)?(n.dispatch({effects:us.of(!0)}),!0):!1,Wu=n=>{let t=n.state.field(ft,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(n.dispatch({effects:gi.of(null)}),!0)};class Vu{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const Hu=50,zu=1e3,Ku=Vt.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of n.state.field(ft).active)t.isPending&&this.startQuery(t)}update(n){let t=n.state.field(ft),e=n.state.facet(X);if(!n.selectionSet&&!n.docChanged&&n.startState.field(ft)==t)return;let i=n.transactions.some(r=>{let o=xa(r,e);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>Hu&&Date.now()-o.time>zu){for(let l of o.context.abortListeners)try{l()}catch(a){gt(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(us)))&&(this.pendingStart=!0);let s=this.pendingStart?50:e.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,t=n.field(ft);for(let e of t.active)e.isPending&&!this.running.some(i=>i.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(X).updateSyncTime))}startQuery(n){let{state:t}=this.view,e=pe(t),i=new ba(t,e,n.explicit,this.view),s=new Vu(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:gi.of(null)}),gt(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(X).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],e=this.view.state.facet(X),i=this.view.state.field(ft);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=pe(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),h=new Ie(r.active.source,r.active.explicit,a,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:l);for(let f of r.updates)h=h.update(f,e);if(h.hasResult()){t.push(h);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new wt(r.active.source,0);for(let a of r.updates)l=l.update(a,e);l.isPending||t.push(l)}else this.startQuery(o)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:rr.of(t)})}},{eventHandlers:{blur(n){let t=this.view.state.field(ft,!1);if(t&&t.tooltip&&this.view.state.facet(X).closeOnBlur){let e=t.open&&na(this.view,t.open.tooltip);(!e||!e.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:gi.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:us.of(!1)}),20),this.composing=0}}}),$u=typeof navigator=="object"&&/Win/.test(navigator.platform),qu=He.highest(O.domEventHandlers({keydown(n,t){let e=t.state.field(ft,!1);if(!e||!e.open||e.open.disabled||e.open.selected<0||n.key.length>1||n.ctrlKey&&!($u&&n.altKey)||n.metaKey)return!1;let i=e.open.options[e.open.selected],s=e.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&or(t,i),!1}})),wa=O.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class ju{constructor(t,e,i,s){this.field=t,this.line=e,this.from=i,this.to=s}}class lr{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,lt.TrackDel),i=t.mapPos(this.to,1,lt.TrackDel);return e==null||i==null?null:new lr(this.field,e,i)}}class ar{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],s=[e],r=t.doc.lineAt(e),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,f=/^\t*/.exec(a)[0].length;for(let c=0;c<f;c++)h+=t.facet(ks);s.push(e+h.length-f),a=h+a.slice(f)}i.push(a),e+=a.length+1}let l=this.fieldPositions.map(a=>new lr(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(t){let e=[],i=[],s=[],r;for(let o of t.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1,f=a.replace(/\\[{}]/g,c=>c[1]);for(let c=0;c<e.length;c++)(l!=null?e[c].seq==l:f&&e[c].name==f)&&(h=c);if(h<0){let c=0;for(;c<e.length&&(l==null||e[c].seq!=null&&e[c].seq<l);)c++;e.splice(c,0,{seq:l,name:f}),h=c;for(let u of s)u.field>=h&&u.field++}for(let c of s)if(c.line==i.length&&c.from>r.index){let u=r[2]?3+(r[1]||"").length:2;c.from-=u,c.to-=u}s.push(new ju(h,i.length,r.index,r.index+f.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let f of s)f.line==i.length&&f.from>h&&(f.from--,f.to--);return a}),i.push(o)}return new ar(i,s)}}let Uu=K.widget({widget:new class extends ze{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Gu=K.mark({class:"cm-snippetField"});class Ke{constructor(t,e){this.ranges=t,this.active=e,this.deco=K.set(t.map(i=>(i.from==i.to?Uu:Gu).range(i.from,i.to)),!0)}map(t){let e=[];for(let i of this.ranges){let s=i.map(t);if(!s)return null;e.push(s)}return new Ke(e,this.active)}selectionInsideField(t){return t.ranges.every(e=>this.ranges.some(i=>i.field==this.active&&i.from<=e.from&&i.to>=e.to))}}const ki=z.define({map(n,t){return n&&n.map(t)}}),_u=z.define(),mi=_t.define({create(){return null},update(n,t){for(let e of t.effects){if(e.is(ki))return e.value;if(e.is(_u)&&n)return new Ke(n.ranges,e.value)}return n&&t.docChanged&&(n=n.map(t.changes)),n&&t.selection&&!n.selectionInsideField(t.selection)&&(n=null),n},provide:n=>O.decorations.from(n,t=>t?t.deco:K.none)});function hr(n,t){return w.create(n.filter(e=>e.field==t).map(e=>w.range(e.from,e.to)))}function Yu(n){let t=ar.parse(n);return(e,i,s,r)=>{let{text:o,ranges:l}=t.instantiate(e.state,s),{main:a}=e.state.selection,h={changes:{from:s,to:r==a.from?a.to:r,insert:L.of(o)},scrollIntoView:!0,annotations:i?[sr.of(i),et.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=hr(l,0)),l.some(f=>f.field>0)){let f=new Ke(l,0),c=h.effects=[ki.of(f)];e.state.field(mi,!1)===void 0&&c.push(z.appendConfig.of([mi,td,ed,wa]))}e.dispatch(e.state.update(h))}}function ka(n){return({state:t,dispatch:e})=>{let i=t.field(mi,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return e(t.update({selection:hr(i.ranges,s),effects:ki.of(r?null:new Ke(i.ranges,s)),scrollIntoView:!0})),!0}}const Ju=({state:n,dispatch:t})=>n.field(mi,!1)?(t(n.update({effects:ki.of(null)})),!0):!1,Xu=ka(1),Qu=ka(-1),Zu=[{key:"Tab",run:Xu,shift:Qu},{key:"Escape",run:Ju}],Lo=B.define({combine(n){return n.length?n[0]:Zu}}),td=He.highest(Xn.compute([Lo],n=>n.facet(Lo)));function Op(n,t){return{...t,apply:Yu(n)}}const ed=O.domEventHandlers({mousedown(n,t){let e=t.state.field(mi,!1),i;if(!e||(i=t.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=e.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==e.active?!1:(t.dispatch({selection:hr(e.ranges,s.field),effects:ki.of(e.ranges.some(r=>r.field>s.field)?new Ke(e.ranges,s.field):null),scrollIntoView:!0}),!0)}}),va=new class extends te{};va.startSide=1;va.endSide=-1;function Dp(n={}){return[qu,ft,X.of(n),Ku,sd,wa]}const id=[{key:"Ctrl-Space",run:Us},{mac:"Alt-`",run:Us},{mac:"Alt-i",run:Us},{key:"Escape",run:Wu},{key:"ArrowDown",run:zi(!0)},{key:"ArrowUp",run:zi(!1)},{key:"PageDown",run:zi(!0,"page")},{key:"PageUp",run:zi(!1,"page")},{key:"Enter",run:Fu}],sd=He.highest(Xn.computeN([X],n=>n.facet(X).defaultKeymap?[id]:[])),nd=n=>{let{state:t}=n,e=t.doc.lineAt(t.selection.main.from),i=cr(n.state,e.from);return i.line?rd(n):i.block?ld(n):!1};function fr(n,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let s=n(t,e);return s?(i(e.update(s)),!0):!1}}const rd=fr(fd,0),od=fr(Sa,0),ld=fr((n,t)=>Sa(n,t,hd(t)),0);function cr(n,t){let e=n.languageDataAt("commentTokens",t,1);return e.length?e[0]:{}}const Ye=50;function ad(n,{open:t,close:e},i,s){let r=n.sliceDoc(i-Ye,i),o=n.sliceDoc(s,s+Ye),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-t.length,h)==t&&o.slice(a,a+e.length)==e)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let f,c;s-i<=2*Ye?f=c=n.sliceDoc(i,s):(f=n.sliceDoc(i,i+Ye),c=n.sliceDoc(s-Ye,s));let u=/^\s*/.exec(f)[0].length,d=/\s*$/.exec(c)[0].length,p=c.length-d-e.length;return f.slice(u,u+t.length)==t&&c.slice(p,p+e.length)==e?{open:{pos:i+u+t.length,margin:/\s/.test(f.charAt(u+t.length))?1:0},close:{pos:s-d-e.length,margin:/\s/.test(c.charAt(p-1))?1:0}}:null}function hd(n){let t=[];for(let e of n.selection.ranges){let i=n.doc.lineAt(e.from),s=e.to<=i.to?i:n.doc.lineAt(e.to);s.from>i.from&&s.from==e.to&&(s=e.to==i.to+1?i:n.doc.lineAt(e.to-1));let r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=s.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return t}function Sa(n,t,e=t.selection.ranges){let i=e.map(r=>cr(t,r.from).block);if(!i.every(r=>r))return null;let s=e.map((r,o)=>ad(t,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:t.changes(e.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:h,close:f}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:f.pos-f.margin,to:f.pos+a.close.length})}return{changes:r}}return null}function fd(n,t,e=t.selection.ranges){let i=[],s=-1;t:for(let{from:r,to:o}of e){let l=i.length,a=1e9,h;for(let f=r;f<=o;){let c=t.doc.lineAt(f);if(h==null&&(h=cr(t,c.from).line,!h))continue t;if(c.from>s&&(r==o||o>c.from)){s=c.from;let u=/^\s*/.exec(c.text)[0].length,d=u==c.length,p=c.text.slice(u,u+h.length)==h?u:-1;u<c.text.length&&u<a&&(a=u),i.push({line:c,comment:p,token:h,indent:u,empty:d,single:!1})}f=c.to+1}if(a<1e9)for(let f=l;f<i.length;f++)i[f].indent<i[f].line.text.length&&(i[f].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:f,single:c}of i)(c||!f)&&r.push({from:l.from+h,insert:a+" "});let o=t.changes(r);return{changes:o,selection:t.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,f=h+a.length;o.text[f-o.from]==" "&&f++,r.push({from:h,to:f})}return{changes:r}}return null}function $e(n,t){return w.create(n.ranges.map(t),n.mainIndex)}function Bt(n,t){return n.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Ot({state:n,dispatch:t},e){let i=$e(n.selection,e);return i.eq(n.selection,!0)?!1:(t(Bt(n,i)),!0)}function Ss(n,t){return w.cursor(t?n.to:n.from)}function Ca(n,t){return Ot(n,e=>e.empty?n.moveByChar(e,t):Ss(e,t))}function rt(n){return n.textDirectionAt(n.state.selection.main.head)==G.LTR}const Aa=n=>Ca(n,!rt(n)),Ma=n=>Ca(n,rt(n));function Ta(n,t){return Ot(n,e=>e.empty?n.moveByGroup(e,t):Ss(e,t))}const cd=n=>Ta(n,!rt(n)),ud=n=>Ta(n,rt(n));function dd(n,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(t.from,t.to)))||t.firstChild}function Cs(n,t,e){let i=vt(n).resolveInner(t.head),s=e?P.closedBy:P.openedBy;for(let a=t.head;;){let h=e?i.childAfter(a):i.childBefore(a);if(!h)break;dd(n,h,s)?i=h:a=e?h.to:h.from}let r=i.type.prop(s),o,l;return r&&(o=e?Ce(n,i.from,1):Ce(n,i.to,-1))&&o.matched?l=e?o.end.to:o.end.from:l=e?i.to:i.from,w.cursor(l,e?-1:1)}const pd=n=>Ot(n,t=>Cs(n.state,t,!rt(n))),gd=n=>Ot(n,t=>Cs(n.state,t,rt(n)));function Ba(n,t){return Ot(n,e=>{if(!e.empty)return Ss(e,t);let i=n.moveVertically(e,t);return i.head!=e.head?i:n.moveToLineBoundary(e,t)})}const Oa=n=>Ba(n,!1),Da=n=>Ba(n,!0);function Pa(n){let t=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,e=0,i=0,s;if(t){for(let r of n.state.facet(O.scrollMargins)){let o=r(n);o!=null&&o.top&&(e=Math.max(o==null?void 0:o.top,e)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}s=n.scrollDOM.clientHeight-e-i}else s=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(n.defaultLineHeight,s-5)}}function Ia(n,t){let e=Pa(n),{state:i}=n,s=$e(i.selection,o=>o.empty?n.moveVertically(o,t,e.height):Ss(o,t));if(s.eq(i.selection))return!1;let r;if(e.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+e.marginTop,h=l.bottom-e.marginBottom;o&&o.top>a&&o.bottom<h&&(r=O.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(Bt(i,s),{effects:r}),!0}const Ro=n=>Ia(n,!1),Ln=n=>Ia(n,!0);function re(n,t,e){let i=n.lineBlockAt(t.head),s=n.moveToLineBoundary(t,e);if(s.head==t.head&&s.head!=(e?i.to:i.from)&&(s=n.moveToLineBoundary(t,e,!1)),!e&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&t.head!=i.from+r&&(s=w.cursor(i.from+r))}return s}const md=n=>Ot(n,t=>re(n,t,!0)),bd=n=>Ot(n,t=>re(n,t,!1)),yd=n=>Ot(n,t=>re(n,t,!rt(n))),xd=n=>Ot(n,t=>re(n,t,rt(n))),wd=n=>Ot(n,t=>w.cursor(n.lineBlockAt(t.head).from,1)),kd=n=>Ot(n,t=>w.cursor(n.lineBlockAt(t.head).to,-1));function vd(n,t,e){let i=!1,s=$e(n.selection,r=>{let o=Ce(n,r.head,-1)||Ce(n,r.head,1)||r.head>0&&Ce(n,r.head-1,1)||r.head<n.doc.length&&Ce(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return w.cursor(l)});return i?(t(Bt(n,s)),!0):!1}const Sd=({state:n,dispatch:t})=>vd(n,t);function St(n,t){let e=$e(n.state.selection,i=>{let s=t(i);return w.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return e.eq(n.state.selection)?!1:(n.dispatch(Bt(n.state,e)),!0)}function La(n,t){return St(n,e=>n.moveByChar(e,t))}const Ra=n=>La(n,!rt(n)),Ea=n=>La(n,rt(n));function Na(n,t){return St(n,e=>n.moveByGroup(e,t))}const Cd=n=>Na(n,!rt(n)),Ad=n=>Na(n,rt(n)),Md=n=>St(n,t=>Cs(n.state,t,!rt(n))),Td=n=>St(n,t=>Cs(n.state,t,rt(n)));function Fa(n,t){return St(n,e=>n.moveVertically(e,t))}const Wa=n=>Fa(n,!1),Va=n=>Fa(n,!0);function Ha(n,t){return St(n,e=>n.moveVertically(e,t,Pa(n).height))}const Eo=n=>Ha(n,!1),No=n=>Ha(n,!0),Bd=n=>St(n,t=>re(n,t,!0)),Od=n=>St(n,t=>re(n,t,!1)),Dd=n=>St(n,t=>re(n,t,!rt(n))),Pd=n=>St(n,t=>re(n,t,rt(n))),Id=n=>St(n,t=>w.cursor(n.lineBlockAt(t.head).from)),Ld=n=>St(n,t=>w.cursor(n.lineBlockAt(t.head).to)),Fo=({state:n,dispatch:t})=>(t(Bt(n,{anchor:0})),!0),Wo=({state:n,dispatch:t})=>(t(Bt(n,{anchor:n.doc.length})),!0),Vo=({state:n,dispatch:t})=>(t(Bt(n,{anchor:n.selection.main.anchor,head:0})),!0),Ho=({state:n,dispatch:t})=>(t(Bt(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Rd=({state:n,dispatch:t})=>(t(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Ed=({state:n,dispatch:t})=>{let e=As(n).map(({from:i,to:s})=>w.range(i,Math.min(s+1,n.doc.length)));return t(n.update({selection:w.create(e),userEvent:"select"})),!0},Nd=({state:n,dispatch:t})=>{let e=$e(n.selection,i=>{let s=vt(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return w.range(l.to,l.from)}return i});return e.eq(n.selection)?!1:(t(Bt(n,e)),!0)};function za(n,t){let{state:e}=n,i=e.selection,s=e.selection.ranges.slice();for(let r of e.selection.ranges){let o=e.doc.lineAt(r.head);if(t?o.to<n.state.doc.length:o.from>0)for(let l=r;;){let a=n.moveVertically(l,t);if(a.head<o.from||a.head>o.to){s.some(h=>h.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==i.ranges.length?!1:(n.dispatch(Bt(e,w.create(s,s.length-1))),!0)}const Fd=n=>za(n,!1),Wd=n=>za(n,!0),Vd=({state:n,dispatch:t})=>{let e=n.selection,i=null;return e.ranges.length>1?i=w.create([e.main]):e.main.empty||(i=w.create([w.cursor(e.main.head)])),i?(t(Bt(n,i)),!0):!1};function vi(n,t){if(n.state.readOnly)return!1;let e="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=t(r);a<o?(e="delete.backward",a=Ki(n,a,!1)):a>o&&(e="delete.forward",a=Ki(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Ki(n,o,!1),l=Ki(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:w.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?O.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Ki(n,t,e){if(n instanceof O)for(let i of n.state.facet(O.atomicRanges).map(s=>s(n)))i.between(t,t,(s,r)=>{s<t&&r>t&&(t=e?r:s)});return t}const Ka=(n,t,e)=>vi(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(e&&!t&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let h=gs(l,r.tabSize),f=h%fs(r)||fs(r);for(let c=0;c<f&&l[l.length-1-c]==" ";c++)s--;a=s}else a=st(o.text,s-o.from,t,t)+o.from,a==s&&o.number!=(t?r.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=st(o.text,a-o.from,!1,!1)+o.from);return a}),Rn=n=>Ka(n,!1,!0),$a=n=>Ka(n,!0,!1),qa=(n,t)=>vi(n,e=>{let i=e.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(t?r.to:r.from)){i==e.head&&r.number!=(t?s.doc.lines:1)&&(i+=t?1:-1);break}let a=st(r.text,i-r.from,t)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),f=o(h);if(l!=null&&f!=l)break;(h!=" "||i!=e.head)&&(l=f),i=a}return i}),ja=n=>qa(n,!1),Hd=n=>qa(n,!0),zd=n=>vi(n,t=>{let e=n.lineBlockAt(t.head).to;return t.head<e?e:Math.min(n.state.doc.length,t.head+1)}),Kd=n=>vi(n,t=>{let e=n.moveToLineBoundary(t,!1).head;return t.head>e?e:Math.max(0,t.head-1)}),$d=n=>vi(n,t=>{let e=n.moveToLineBoundary(t,!0).head;return t.head<e?e:Math.min(n.state.doc.length,t.head+1)}),qd=({state:n,dispatch:t})=>{if(n.readOnly)return!1;let e=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:L.of(["",""])},range:w.cursor(i.from)}));return t(n.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},jd=({state:n,dispatch:t})=>{if(n.readOnly)return!1;let e=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:st(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:st(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:w.cursor(l)}});return e.changes.empty?!1:(t(n.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function As(n){let t=[],e=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),e>=s.number){let o=t[t.length-1];o.to=r.to,o.ranges.push(i)}else t.push({from:s.from,to:r.to,ranges:[i]});e=r.number+1}return t}function Ua(n,t,e){if(n.readOnly)return!1;let i=[],s=[];for(let r of As(n)){if(e?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(e?r.to+1:r.from-1),l=o.length+1;if(e){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(w.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(w.range(a.anchor-l,a.head-l))}}return i.length?(t(n.update({changes:i,scrollIntoView:!0,selection:w.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Ud=({state:n,dispatch:t})=>Ua(n,t,!1),Gd=({state:n,dispatch:t})=>Ua(n,t,!0);function Ga(n,t,e){if(n.readOnly)return!1;let i=[];for(let r of As(n))e?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let s=n.changes(i);return t(n.update({changes:s,selection:n.selection.map(s,e?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const _d=({state:n,dispatch:t})=>Ga(n,t,!1),Yd=({state:n,dispatch:t})=>Ga(n,t,!0),Jd=n=>{if(n.state.readOnly)return!1;let{state:t}=n,e=t.changes(As(t).map(({from:s,to:r})=>(s>0?s--:r<t.doc.length&&r++,{from:s,to:r}))),i=$e(t.selection,s=>{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(e);return n.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Xd(n,t){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=vt(n).resolveInner(t),i=e.childBefore(t),s=e.childAfter(t),r;return i&&s&&i.to<=t&&s.from>=t&&(r=i.type.prop(P.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const zo=_a(!1),Qd=_a(!0);function _a(n){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(s=>{let{from:r,to:o}=s,l=t.doc.lineAt(r),a=!n&&r==o&&Xd(t,r);n&&(r=o=(o<=l.to?l:t.doc.lineAt(o)).to);let h=new vs(t,{simulateBreak:r,simulateDoubleBreak:!!a}),f=pa(h,r);for(f==null&&(f=gs(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let c=["",cs(t,f)];return a&&c.push(cs(t,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:L.of(c)},range:w.cursor(r+1+c[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function ur(n,t){let e=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>e&&(i.empty||i.to>l.from)&&(t(l,s,i),e=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:w.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Zd=({state:n,dispatch:t})=>{if(n.readOnly)return!1;let e=Object.create(null),i=new vs(n,{overrideIndentation:r=>{let o=e[r];return o??-1}}),s=ur(n,(r,o,l)=>{let a=pa(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],f=cs(n,a);(h!=f||l.from<r.from+h.length)&&(e[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:f}))});return s.changes.empty||t(n.update(s,{userEvent:"indent"})),!0},Ya=({state:n,dispatch:t})=>n.readOnly?!1:(t(n.update(ur(n,(e,i)=>{i.push({from:e.from,insert:n.facet(ks)})}),{userEvent:"input.indent"})),!0),Ja=({state:n,dispatch:t})=>n.readOnly?!1:(t(n.update(ur(n,(e,i)=>{let s=/^\s*/.exec(e.text)[0];if(!s)return;let r=gs(s,n.tabSize),o=0,l=cs(n,Math.max(0,r-fs(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),tp=n=>(n.setTabFocusMode(),!0),ep=[{key:"Ctrl-b",run:Aa,shift:Ra,preventDefault:!0},{key:"Ctrl-f",run:Ma,shift:Ea},{key:"Ctrl-p",run:Oa,shift:Wa},{key:"Ctrl-n",run:Da,shift:Va},{key:"Ctrl-a",run:wd,shift:Id},{key:"Ctrl-e",run:kd,shift:Ld},{key:"Ctrl-d",run:$a},{key:"Ctrl-h",run:Rn},{key:"Ctrl-k",run:zd},{key:"Ctrl-Alt-h",run:ja},{key:"Ctrl-o",run:qd},{key:"Ctrl-t",run:jd},{key:"Ctrl-v",run:Ln}],ip=[{key:"ArrowLeft",run:Aa,shift:Ra,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:cd,shift:Cd,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:yd,shift:Dd,preventDefault:!0},{key:"ArrowRight",run:Ma,shift:Ea,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:ud,shift:Ad,preventDefault:!0},{mac:"Cmd-ArrowRight",run:xd,shift:Pd,preventDefault:!0},{key:"ArrowUp",run:Oa,shift:Wa,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Fo,shift:Vo},{mac:"Ctrl-ArrowUp",run:Ro,shift:Eo},{key:"ArrowDown",run:Da,shift:Va,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Wo,shift:Ho},{mac:"Ctrl-ArrowDown",run:Ln,shift:No},{key:"PageUp",run:Ro,shift:Eo},{key:"PageDown",run:Ln,shift:No},{key:"Home",run:bd,shift:Od,preventDefault:!0},{key:"Mod-Home",run:Fo,shift:Vo},{key:"End",run:md,shift:Bd,preventDefault:!0},{key:"Mod-End",run:Wo,shift:Ho},{key:"Enter",run:zo,shift:zo},{key:"Mod-a",run:Rd},{key:"Backspace",run:Rn,shift:Rn,preventDefault:!0},{key:"Delete",run:$a,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ja,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Hd,preventDefault:!0},{mac:"Mod-Backspace",run:Kd,preventDefault:!0},{mac:"Mod-Delete",run:$d,preventDefault:!0}].concat(ep.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Pp=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:pd,shift:Md},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:gd,shift:Td},{key:"Alt-ArrowUp",run:Ud},{key:"Shift-Alt-ArrowUp",run:_d},{key:"Alt-ArrowDown",run:Gd},{key:"Shift-Alt-ArrowDown",run:Yd},{key:"Mod-Alt-ArrowUp",run:Fd},{key:"Mod-Alt-ArrowDown",run:Wd},{key:"Escape",run:Vd},{key:"Mod-Enter",run:Qd},{key:"Alt-l",mac:"Ctrl-l",run:Ed},{key:"Mod-i",run:Nd,preventDefault:!0},{key:"Mod-[",run:Ja},{key:"Mod-]",run:Ya},{key:"Mod-Alt-\\",run:Zd},{key:"Shift-Mod-k",run:Jd},{key:"Shift-Mod-\\",run:Sd},{key:"Mod-/",run:nd},{key:"Alt-A",run:od},{key:"Ctrl-m",mac:"Shift-Alt-m",run:tp}].concat(ip),Ip={key:"Tab",run:Ya,shift:Ja},sp="#e5c07b",Ko="#e06c75",np="#56b6c2",rp="#ffffff",_i="#abb2bf",En="#7d8799",op="#61afef",lp="#98c379",$o="#d19a66",ap="#c678dd",hp="#21252b",qo="#2c313a",jo="#282c34",Gs="#353a42",fp="#3E4451",Uo="#528bff",cp=O.theme({"&":{color:_i,backgroundColor:jo},".cm-content":{caretColor:Uo},".cm-cursor, .cm-dropCursor":{borderLeftColor:Uo},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:fp},".cm-panels":{backgroundColor:hp,color:_i},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:jo,color:En,border:"none"},".cm-activeLineGutter":{backgroundColor:qo},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Gs},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Gs,borderBottomColor:Gs},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:qo,color:_i}}},{dark:!0}),up=wi.define([{tag:y.keyword,color:ap},{tag:[y.name,y.deleted,y.character,y.propertyName,y.macroName],color:Ko},{tag:[y.function(y.variableName),y.labelName],color:op},{tag:[y.color,y.constant(y.name),y.standard(y.name)],color:$o},{tag:[y.definition(y.name),y.separator],color:_i},{tag:[y.typeName,y.className,y.number,y.changed,y.annotation,y.modifier,y.self,y.namespace],color:sp},{tag:[y.operator,y.operatorKeyword,y.url,y.escape,y.regexp,y.link,y.special(y.string)],color:np},{tag:[y.meta,y.comment],color:En},{tag:y.strong,fontWeight:"bold"},{tag:y.emphasis,fontStyle:"italic"},{tag:y.strikethrough,textDecoration:"line-through"},{tag:y.link,color:En,textDecoration:"underline"},{tag:y.heading,fontWeight:"bold",color:Ko},{tag:[y.atom,y.bool,y.special(y.variableName)],color:$o},{tag:[y.processingInstruction,y.string,y.inserted],color:lp},{tag:y.invalid,color:rp}]),Lp=[cp,au(up)];export{Yc as A,Op as B,xp as C,w as D,yp as E,du as F,F as I,kp as L,gp as N,On as a,tu as b,wu as c,Cp as d,Tn as e,Ap as f,vt as g,O as h,Bp as i,E as j,Dp as k,Xn as l,Pp as m,Ip as n,Lp as o,pp as p,au as q,Tp as r,qc as s,y as t,mp as u,Lc as v,Mp as w,Jc as x,Sp as y,vp as z};
|