@redocly/replay 0.7.7 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +2 -3
- package/package.json +2 -2
package/dist/replay.cjs
CHANGED
|
@@ -674,7 +674,7 @@ html body {
|
|
|
674
674
|
`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),c=t.visualLineSide(i,!n)}if(l){if(!l(u))return a}else{if(!r)return c;l=r(u)}a=c}}function S9(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==jt.Space&&(i=o),i==o}}function w9(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return ie.cursor(i,e.assoc);let o=e.goalColumn,a,l=t.contentDOM.getBoundingClientRect(),c=t.coordsAtPos(i,e.assoc||-1),u=t.documentTop;if(c)o==null&&(o=c.left-l.left),a=s<0?c.top:c.bottom;else{let h=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(l.right-l.left,t.defaultCharacterWidth*(i-h.from))),a=(s<0?h.top:h.bottom)+u}let f=l.left+o,d=r??t.viewState.heightOracle.textHeight>>1;for(let h=0;;h+=10){let p=a+(d+h)*s,O=QE(t,{x:f,y:p},!1,s);if(p<l.top||p>l.bottom||(s<0?O<i:O>i)){let g=t.docView.coordsForChar(O),x=!g||p<g.top?-1:1;return ie.cursor(O,x,void 0,o)}}}function Lu(t,e,n){for(;;){let r=0;for(let i of t)i.between(e-1,e+1,(s,o,a)=>{if(e>s&&e<o){let l=r||n||(e-s<o-e?-1:1);e=l<0?s:o,r=l}});if(!r)return e}}function rp(t,e,n){let r=Lu(t.state.facet(zO).map(i=>i(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ie.cursor(r,r<n.from?1:-1)}class C9{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=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.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&F9(e.contentDOM.ownerDocument)}handleEvent(e){!R9(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=k9(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,a=r[s];a&&o!=!a.handlers.length&&(i.removeEventListener(s,this.handleEvent),a=null),a||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(e.keyCode!=27&&ME.indexOf(e.keyCode)<0&&(this.view.inputState.lastEscPress=0),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=NE.find(r=>r.keyCode==e.keyCode))&&!e.ctrlKey||A9.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Go(this.view.contentDOM,n.key,n.keyCode,n instanceof KeyboardEvent?n:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function bb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){Zn(n.state,i)}}}function k9(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec;if(i&&i.domEventHandlers)for(let s in i.domEventHandlers){let o=i.domEventHandlers[s];o&&n(s).handlers.push(bb(r.value,o))}if(i&&i.domEventObservers)for(let s in i.domEventObservers){let o=i.domEventObservers[s];o&&n(s).observers.push(bb(r.value,o))}}for(let r in zr)n(r).handlers.push(zr[r]);for(let r in jr)n(r).observers.push(jr[r]);return e}const NE=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],A9="dthko",ME=[16,17,18,20,91,92,224,225],au=6;function lu(t){return Math.max(0,t)*.7+8}function P9(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class E9{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParent=VF(e.contentDOM),this.atoms=e.state.facet(zO).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Ye.allowMultipleSelections)&&I9(e,n),this.dragging=$9(e,n)&&LE(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var n;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&P9(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let r=0,i=0,s=((n=this.scrollParent)===null||n===void 0?void 0:n.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=_E(this.view);e.clientX-o.left<=s.left+au?r=-lu(s.left-e.clientX):e.clientX+o.right>=s.right-au&&(r=lu(e.clientX-s.right)),e.clientY-o.top<=s.top+au?i=-lu(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-au&&(i=lu(e.clientY-s.bottom)),this.setScrollSpeed(r,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let n=null;for(let r=0;r<e.ranges.length;r++){let i=e.ranges[r],s=null;if(i.empty){let o=Lu(this.atoms,i.from,0);o!=i.from&&(s=ie.cursor(o,-1))}else{let o=Lu(this.atoms,i.from,-1),a=Lu(this.atoms,i.to,1);(o!=i.from||a!=i.to)&&(s=ie.range(i.from==i.anchor?o:a,i.from==i.head?o:a))}s&&(n||(n=e.ranges.slice()),n[r]=s)}return n?ie.create(n,e.mainIndex):e}select(e){let{view:n}=this,r=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function I9(t,e){let n=t.state.facet(SE);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function T9(t,e){let n=t.state.facet(wE);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function $9(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=$f(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s<i.length;s++){let o=i[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function R9(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ct.get(n))&&r.ignoreEvent(e))return!1;return!0}const zr=Object.create(null),jr=Object.create(null),FE=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function j9(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),ZE(t,n.value)},50)}function ZE(t,e){let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(V0!=null&&n.selection.ranges.every(l=>l.empty)&&V0==s.toString()){let l=-1;r=n.changeByRange(c=>{let u=n.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:u.from,insert:f},range:ie.cursor(c.from+f.length)}})}else o?r=n.changeByRange(l=>{let c=s.line(i++);return{changes:{from:l.from,to:l.to,insert:c.text},range:ie.cursor(l.from+c.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}jr.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};zr.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&(t.inputState.lastEscPress=Date.now()),!1);jr.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};jr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};zr.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(CE))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=B9(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new E9(t,e,n,r)),r&&t.observer.ignore(()=>rE(t.contentDOM));let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}return!1};function Sb(t,e,n,r){if(r==1)return ie.cursor(e,n);if(r==2)return m9(t.state,e,n);{let i=tn.find(t.docView,e),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,a=i?i.posAtEnd:s.to;return a<t.state.doc.length&&a==s.to&&a++,ie.range(o,a)}}let WE=(t,e)=>t>=e.top&&t<=e.bottom,wb=(t,e,n)=>WE(e,n)&&t>=n.left&&t<=n.right;function D9(t,e,n,r){let i=tn.find(t.docView,e);if(!i)return 1;let s=e-i.posAtStart;if(s==0)return 1;if(s==i.length)return-1;let o=i.coordsAt(s,-1);if(o&&wb(n,r,o))return-1;let a=i.coordsAt(s,1);return a&&wb(n,r,a)?1:o&&WE(r,o)?-1:1}function Cb(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:D9(t,n,e.clientX,e.clientY)}}const _9=Oe.ie&&Oe.ie_version<=11;let kb=null,Ab=0,Pb=0;function LE(t){if(!_9)return t.detail;let e=kb,n=Pb;return kb=t,Pb=Date.now(),Ab=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Ab+1)%3:1}function B9(t,e){let n=Cb(t,e),r=LE(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,a){let l=Cb(t,s),c,u=Sb(t,l.pos,l.bias,r);if(n.pos!=l.pos&&!o){let f=Sb(t,n.pos,n.bias,r),d=Math.min(f.from,u.from),h=Math.max(f.to,u.to);u=d<u.from?ie.range(d,h):ie.range(h,d)}return o?i.replaceRange(i.main.extend(u.from,u.to)):a&&r==1&&i.ranges.length>1&&(c=Q9(i,l.pos))?c:a?i.addRange(u):ie.create([u])}}}function Q9(t,e){for(let n=0;n<t.ranges.length;n++){let{from:r,to:i}=t.ranges[n];if(r<=e&&i>=e)return ie.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}zr.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.nearest(e.target);if(i&&i.isWidget){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=ie.range(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(n.from,n.to)),e.dataTransfer.effectAllowed="copyMove"),!1};zr.dragend=t=>(t.inputState.draggedContent=null,!1);function Eb(t,e,n,r){if(!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&T9(t,e)?{from:s.from,to:s.to}:null,a={from:i,insert:n},l=t.state.changes(o?[o,a]:a);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}zr.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&Eb(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<n.length;o++){let a=new FileReader;a.onerror=s,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(r[o]=a.result),s()},a.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return Eb(t,e,r,!0),!0}return!1};zr.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=FE?null:e.clipboardData;return n?(ZE(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(j9(t),!1)};function N9(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function M9(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:e.join(t.lineBreak),ranges:n,linewise:r}}let V0=null;zr.copy=zr.cut=(t,e)=>{let{text:n,ranges:r,linewise:i}=M9(t.state);if(!n&&!i)return!1;V0=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=FE?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(N9(t,n),!1)};const VE=Ci.define();function zE(t,e){let n=[];for(let r of t.facet(PE)){let i=r(t,e);i&&n.push(i)}return n?t.update({effects:n,annotations:VE.of(!0)}):null}function XE(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=zE(t.state,e);n?t.dispatch(n):t.update([])}},10)}jr.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),XE(t)};jr.blur=t=>{t.observer.clearSelectionRange(),XE(t)};jr.compositionstart=jr.compositionupdate=t=>{t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)};jr.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50)};jr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};zr.beforeinput=(t,e)=>{var n;let r;if(Oe.chrome&&Oe.android&&(r=NE.find(i=>i.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let i=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>i+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>jr.compositionend(t,e),20),!1};const Ib=new Set;function F9(t){Ib.has(t)||(Ib.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Tb=["pre-wrap","normal","pre-line","break-spaces"];class Z9{constructor(e){this.lineWrapping=e,this.doc=ot.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Tb.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];i<0?r++:this.heightSamples[Math.floor(i*10)]||(n=!0,this.heightSamples[Math.floor(i*10)]=!0)}return n}refresh(e,n,r,i,s,o){let a=Tb.indexOf(e)>-1,l=Math.round(n)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,l){this.heightSamples={};for(let c=0;c<o.length;c++){let u=o[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return l}}class W9{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class li{constructor(e,n,r,i,s){this.from=e,this.length=n,this.top=r,this.height=i,this._content=s}get type(){return typeof this._content=="number"?Wn.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 bs?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new li(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var Tt=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Tt||(Tt={}));const Vu=.001;class Ln{constructor(e,n,r=2){this.length=e,this.height=n,this.flags=r}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,n){this.height!=n&&(Math.abs(this.height-n)>Vu&&(e.heightChanged=!0),this.height=n)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let a=i.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:f}=i[a],d=s.lineAt(l,Tt.ByPosNoHeight,r.setDoc(n),0,0),h=d.to>=c?d:s.lineAt(c,Tt.ByPosNoHeight,r,0,0);for(f+=h.to-c,c=h.to;a>0&&d.from<=i[a-1].toA;)l=i[a-1].fromA,u=i[a-1].fromB,a--,l<d.from&&(d=s.lineAt(l,Tt.ByPosNoHeight,r,0,0));u+=d.from-l,l=d.from;let p=XO.build(r.setDoc(o),e,u,f);s=s.replace(l,c,p)}return s.updateHeight(r,0)}static empty(){return new fr(0,0)}static of(e){if(e.length==1)return e[0];let n=0,r=e.length,i=0,s=0;for(;;)if(n==r)if(i>s*2){let a=e[n-1];a.break?e.splice(--n,1,a.left,null,a.right):e.splice(--n,1,a.left,a.right),r+=1+a.break,i-=a.size}else if(s>i*2){let a=e[r];a.break?e.splice(r,1,a.left,null,a.right):e.splice(r,1,a.left,a.right),r+=2+a.break,s-=a.size}else break;else if(i<s){let a=e[n++];a&&(i+=a.size)}else{let a=e[--r];a&&(s+=a.size)}let o=0;return e[n-1]==null?(o=1,n--):e[n]==null&&(o=1,r++),new L9(Ln.of(e.slice(0,n)),o,Ln.of(e.slice(r)))}}Ln.prototype.size=1;class GE extends Ln{constructor(e,n,r){super(e,n),this.deco=r}blockAt(e,n,r,i){return new li(i,this.length,r,this.height,this.deco||0)}lineAt(e,n,r,i,s){return this.blockAt(0,r,i,s)}forEachLine(e,n,r,i,s,o){e<=s+this.length&&n>=s&&o(this.blockAt(0,r,i,s))}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setHeight(e,i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class fr extends GE{constructor(e,n){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,n,r,i){return new li(i,this.length,r,this.height,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof fr||i instanceof mn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof mn?i=new fr(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):Ln.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setHeight(e,i.heights[i.index++]):(r||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class mn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:a}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(n,i);if(n.lineWrapping){let c=i+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-r)/this.height))*this.length)),u=n.doc.lineAt(c),f=a+u.length*l,d=Math.max(r,e-f/2);return new li(u.from,u.length,d,f,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((e-r)/a))),{from:u,length:f}=n.doc.line(s+c);return new li(u,f,r+a*c,a,0)}}lineAt(e,n,r,i,s){if(n==Tt.ByHeight)return this.blockAt(e,r,i,s);if(n==Tt.ByPosNoHeight){let{from:h,to:p}=r.doc.lineAt(e);return new li(h,p-h,0,0,0)}let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(r,s),c=r.doc.lineAt(e),u=a+c.length*l,f=c.number-o,d=i+a*f+l*(c.from-s-f);return new li(c.from,c.length,Math.max(i,Math.min(d,i+this.height-u)),u,0)}forEachLine(e,n,r,i,s,o){e=Math.max(e,s),n=Math.min(n,s+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(r,s);for(let u=e,f=i;u<=n;){let d=r.doc.lineAt(u);if(u==e){let p=d.number-a;f+=l*p+c*(e-s-p)}let h=l+c*d.length;o(new li(d.from,d.length,f,h,0)),f+=h,u=d.to+1}}replace(e,n,r){let i=this.length-n;if(i>0){let s=r[r.length-1];s instanceof mn?r[r.length-1]=new mn(s.length+i):r.push(null,new mn(i-1))}if(e>0){let s=r[0];s instanceof mn?r[0]=new mn(e+s.length):r.unshift(new mn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new mn(e-1),null)}decomposeRight(e,n){n.push(null,new mn(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],a=Math.max(n,i.from),l=-1;for(i.from>n&&o.push(new mn(i.from-n-1).updateHeight(e,n));a<=s&&i.more;){let u=e.doc.lineAt(a).length;o.length&&o.push(null);let f=i.heights[i.index++];l==-1?l=f:Math.abs(f-l)>=Vu&&(l=-2);let d=new fr(u,f);d.outdated=!1,o.push(d),a+=u+1}a<=s&&o.push(null,new mn(s-a).updateHeight(e,a));let c=Ln.of(o);return(l<0||Math.abs(c.height-this.height)>=Vu||Math.abs(l-this.heightMetrics(e,n).perLine)>=Vu)&&(e.heightChanged=!0),c}else(r||this.outdated)&&(this.setHeight(e,e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class L9 extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,i){let s=r+this.left.height;return e<s?this.left.blockAt(e,n,r,i):this.right.blockAt(e,n,s,i+this.left.length+this.break)}lineAt(e,n,r,i,s){let o=i+this.left.height,a=s+this.left.length+this.break,l=n==Tt.ByHeight?e<o:e<a,c=l?this.left.lineAt(e,n,r,i,s):this.right.lineAt(e,n,r,o,a);if(this.break||(l?c.to<a:c.from>a))return c;let u=n==Tt.ByPosNoHeight?Tt.ByPosNoHeight:Tt.ByPos;return l?c.join(this.right.lineAt(a,u,r,o,a)):this.left.lineAt(a,u,r,i,s).join(c)}forEachLine(e,n,r,i,s,o){let a=i+this.left.height,l=s+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,n,r,i,s,o),n>=l&&this.right.forEachLine(e,n,r,a,l,o);else{let c=this.lineAt(l,Tt.ByPos,r,i,s);e<c.from&&this.left.forEachLine(e,c.from-1,r,i,s,o),c.to>=e&&c.from<=n&&o(c),n>c.to&&this.right.forEachLine(c.to+1,n,r,a,l,o)}}replace(e,n,r){let i=this.left.length+this.break;if(n<i)return this.balanced(this.left.replace(e,n,r),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of r)s.push(a);if(e>0&&$b(s,o-1),n<this.length){let a=s.length;this.decomposeRight(n,s),$b(s,a)}return Ln.of(s)}decomposeLeft(e,n){let r=this.left.length;if(e<=r)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(r++,e>=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e<r&&this.left.decomposeRight(e,n),this.break&&e<i&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=e,this.right=n,this.height=e.height+n.height,this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,a=n+s.length+this.break,l=null;return i&&i.from<=n+s.length&&i.more?l=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=a+o.length&&i.more?l=o=o.updateHeight(e,a,r,i):o.updateHeight(e,a,r),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function $b(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof mn&&(r=t[e+1])instanceof mn&&t.splice(e-1,3,new mn(n.length+1+r.length))}const V9=5;class XO{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof fr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new fr(r-this.pos,-1)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e<n||r.heightRelevant){let i=r.widget?r.widget.estimatedHeight:0,s=r.widget?r.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let o=n-e;r.block?this.addBlock(new GE(o,i,r)):(o||s||i>=V9)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new fr(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,n){let r=new mn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof fr)return e;let n=new fr(0,-1);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof fr)&&!this.isCovered?this.nodes.push(new fr(0,-1)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let r=e;for(let i of this.nodes)i instanceof fr&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(e,n,r,i){let s=new XO(r,e);return et.spans(n,r,i,s,0),s.finish(r)}}function z9(t,e,n){let r=new X9;return et.compare(t,e,n,r,0),r.changes}class X9{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,r,i){(e<n||r&&r.heightRelevant||i&&i.heightRelevant)&&Q0(e,n,this.changes,5)}}function G9(t,e){let n=t.getBoundingClientRect(),r=t.ownerDocument,i=r.defaultView||window,s=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let c=t.parentNode;c&&c!=r.body;)if(c.nodeType==1){let u=c,f=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&f.overflow!="visible"){let d=u.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),a=Math.max(a,d.top),l=c==t.parentNode?d.bottom:Math.min(l,d.bottom)}c=f.position=="absolute"||f.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:a-(n.top+e),bottom:Math.max(a,l)-(n.top+e)}}function q9(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class ip{constructor(e,n,r){this.from=e,this.to=n,this.size=r}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++){let i=e[r],s=n[r];if(i.from!=s.from||i.to!=s.to||i.size!=s.size)return!1}return!0}draw(e,n){return Se.replace({widget:new U9(this.size*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class U9 extends Ai{constructor(e,n){super(),this.size=e,this.vertical=n}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Rb{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=jb,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=$t.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=e.facet(VO).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Z9(n),this.stateDeco=e.facet(Wl).filter(r=>typeof r!="function"),this.heightMap=Ln.empty().applyChanges(this.stateDeco,ot.empty,this.heightOracle.setDoc(e.doc),[new Tr(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Se.set(this.lineGaps.map(r=>r.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new cu(s,o))}}this.viewports=e.sort((r,i)=>r.from-i.from),this.scaler=this.heightMap.height<=7e6?jb:new J9(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:ul(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=this.state.facet(Wl).filter(u=>typeof u!="function");let i=e.changedRanges,s=Tr.extendWithRanges(i,z9(r,this.stateDeco,e?e.changes:rn.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<l.from||n.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,n));let c=!e.changes.empty||e.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),c&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(IE)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?$t.RTL:$t.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=n.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:b,scaleY:S}=nE(n,a);(b>.005&&Math.abs(this.scaleX-b)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=b,this.scaleY=S,c|=8,o=l=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,d=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=8);let h=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=h&&(this.scrollAnchorHeight=-1,this.scrollTop=h),this.scrolledToBottom=sE(e.scrollDOM);let p=(this.printing?q9:G9)(n,this.paddingTop),O=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let x=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(x!=this.inView&&(this.inView=x,x&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let v=a.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),l){let b=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(b)&&(o=!0),o||i.lineWrapping&&Math.abs(v-this.contentDOMWidth)>i.charWidth){let{lineHeight:S,charWidth:w,textHeight:C}=e.docView.measureTextSize();o=S>0&&i.refresh(s,S,w,C,v/w,b),o&&(e.docView.minWidth=0,c|=8)}O>0&&g>0?u=Math.max(O,g):O<0&&g<0&&(u=Math.min(O,g)),i.heightChanged=!1;for(let S of this.viewports){let w=S.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?Ln.empty().applyChanges(this.stateDeco,ot.empty,this.heightOracle,[new Tr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new W9(S.from,w))}i.heightChanged&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new cu(i.lineAt(o-r*1e3,Tt.ByHeight,s,0,0).from,i.lineAt(a+(1-r)*1e3,Tt.ByHeight,s,0,0).to);if(n){let{head:c}=n.range;if(c<l.from||c>l.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(c,Tt.ByPos,s,0,0),d;n.y=="center"?d=(f.top+f.bottom)/2-u/2:n.y=="start"||n.y=="nearest"&&c<l.from?d=f.top:d=f.bottom-u,l=new cu(i.lineAt(d-1e3/2,Tt.ByHeight,s,0,0).from,i.lineAt(d+u+1e3/2,Tt.ByHeight,s,0,0).to)}}return l}mapViewport(e,n){let r=n.mapPos(e.from,-1),i=n.mapPos(e.to,1);return new cu(this.heightMap.lineAt(r,Tt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,Tt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},r=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,Tt.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,Tt.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:a}=this;return(e==0||i<=o-Math.max(10,Math.min(-r,250)))&&(n==this.state.doc.length||s>=a+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s<a+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let r=[];for(let i of e)n.touchesRange(i.from,i.to)||r.push(new ip(n.mapPos(i.from),n.mapPos(i.to),i.size));return r}ensureLineGaps(e,n){let r=this.heightOracle.lineWrapping,i=r?1e4:2e3,s=i>>1,o=i<<1;if(this.defaultTextDirection!=$t.LTR&&!r)return[];let a=[],l=(c,u,f,d)=>{if(u-c<s)return;let h=this.state.selection.main,p=[h.from];h.empty||p.push(h.to);for(let g of p)if(g>c&&g<u){l(c,g-10,f,d),l(g+10,u,f,d);return}let O=H9(e,g=>g.from>=f.from&&g.to<=f.to&&Math.abs(g.from-c)<s&&Math.abs(g.to-u)<s&&!p.some(x=>g.from<x&&g.to>x));if(!O){if(u<f.to&&n&&r&&n.visibleRanges.some(g=>g.from<=u&&g.to>=u)){let g=n.moveToLineBoundary(ie.cursor(u),!1,!0).head;g>c&&(u=g)}O=new ip(c,u,this.gapSize(f,c,u,d))}a.push(O)};for(let c of this.viewportLines){if(c.length<o)continue;let u=Y9(c.from,c.to,this.stateDeco);if(u.total<o)continue;let f=this.scrollTarget?this.scrollTarget.range.head:null,d,h;if(r){let p=i/this.heightOracle.lineLength*this.heightOracle.lineHeight,O,g;if(f!=null){let x=fu(u,f),v=((this.visibleBottom-this.visibleTop)/2+p)/c.height;O=x-v,g=x+v}else O=(this.visibleTop-c.top-p)/c.height,g=(this.visibleBottom-c.top+p)/c.height;d=uu(u,O),h=uu(u,g)}else{let p=u.total*this.heightOracle.charWidth,O=i*this.heightOracle.charWidth,g,x;if(f!=null){let v=fu(u,f),y=((this.pixelViewport.right-this.pixelViewport.left)/2+O)/p;g=v-y,x=v+y}else g=(this.pixelViewport.left-O)/p,x=(this.pixelViewport.right+O)/p;d=uu(u,g),h=uu(u,x)}d>c.from&&l(c.from,d,c,u),h<c.to&&l(h,c.to,c,u)}return a}gapSize(e,n,r,i){let s=fu(i,r)-fu(i,n);return this.heightOracle.lineWrapping?e.height*s:i.total*this.heightOracle.charWidth*s}updateLineGaps(e){ip.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Se.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let n=[];et.spans(e,this.viewport.from,this.viewport.to,{span(i,s){n.push({from:i,to:s})},point(){}},20);let r=n.length!=this.visibleRanges.length||this.visibleRanges.some((i,s)=>i.from!=n[s].from||i.to!=n[s].to);return this.visibleRanges=n,r?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||ul(this.heightMap.lineAt(e,Tt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return ul(this.heightMap.lineAt(this.scaler.fromDOM(e),Tt.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return ul(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class cu{constructor(e,n){this.from=e,this.to=n}}function Y9(t,e,n){let r=[],i=t,s=0;return et.spans(n,t,e,{span(){},point(o,a){o>i&&(r.push({from:i,to:o}),s+=o-i),i=a}},20),i<e&&(r.push({from:i,to:e}),s+=e-i),{total:s,ranges:r}}function uu({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],a=o-s;if(r<=a)return s+r;r-=a}}function fu(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function H9(t,e){for(let n of t)if(e(n))return n}const jb={toDOM(t){return t},fromDOM(t){return t},scale:1};class J9{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:a,to:l})=>{let c=n.lineAt(a,Tt.ByPos,e,0,0).top,u=n.lineAt(l,Tt.ByPos,e,0,0).bottom;return i+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.top)return i+(e-r)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);r=s.bottom,i=s.domBottom}}fromDOM(e){for(let n=0,r=0,i=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.domTop)return r+(e-i)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);r=s.bottom,i=s.domBottom}}}function ul(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new li(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>ul(i,e)):t._content)}const du=me.define({combine:t=>t.join(" ")}),z0=me.define({combine:t=>t.indexOf(!0)>-1}),X0=xs.newName(),qE=xs.newName(),UE=xs.newName(),YE={"&light":"."+qE,"&dark":"."+UE};function G0(t,e,n){return new xs(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const K9=G0("."+X0,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",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:"#444"},".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",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},YE),fl="";class e8{constructor(e,n){this.points=e,this.text="",this.lineSeparator=n.facet(Ye.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=fl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=i.nextSibling;if(o==n)break;let a=Ct.get(i),l=Ct.get(o);(a&&l?a.breakAfter:(a?a.breakAfter:Rf(i))||Rf(o)&&(i.nodeName!="BR"||i.cmIgnore)&&this.text.length>s)&&this.lineBreak(),i=o}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(a=i.exec(n))&&(s=a.index,o=a[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);r=s+o}}readNode(e){if(e.cmIgnore)return;let n=Ct.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(t8(e,r.node,r.offset)?n:0))}}function t8(t,e,n){for(;;){if(!e||n<Fi(e))return!1;if(e==t)return!0;n=Js(e)+1,e=e.parentNode}}class Db{constructor(e,n){this.node=e,this.offset=n,this.pos=-1}}class n8{constructor(e,n,r,i){this.typeOver=i,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=e.docView.domBoundsAround(n,r,0))){let a=s||o?[]:s8(e),l=new e8(a,e.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=o8(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!$0(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!$0(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((Oe.ios||Oe.chrome)&&e.state.selection.main.empty&&l!=c&&(u.from>0||u.to<e.state.doc.length)){let f=Math.min(l,c),d=Math.max(l,c),h=u.from-f,p=u.to-d;(h==0||h==1||f==0)&&(p==0||p==-1||d==e.state.doc.length)&&(l=0,c=e.state.doc.length)}this.newSel=ie.single(c,l)}}}function HE(t,e){let n,{newSel:r}=e,i=t.state.selection.main,s=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:a}=e.bounds,l=i.from,c=null;(s===8||Oe.android&&e.text.length<a-o)&&(l=i.to,c="end");let u=i8(t.state.doc.sliceString(o,a,fl),e.text,l-o,c);u&&(Oe.chrome&&s==13&&u.toB==u.from+2&&e.text.slice(u.from,u.toB)==fl+fl&&u.toB--,n={from:o+u.from,to:o+u.toA,insert:ot.of(e.text.slice(u.from,u.toB).split(fl))})}else r&&(!t.hasFocus&&t.state.facet(zd)||r.main.eq(i))&&(r=null);if(!n&&!r)return!1;if(!n&&e.typeOver&&!i.empty&&r&&r.main.empty?n={from:i.from,to:i.to,insert:t.state.doc.slice(i.from,i.to)}:n&&n.from>=i.from&&n.to<=i.to&&(n.from!=i.from||n.to!=i.to)&&i.to-i.from-(n.to-n.from)<=4?n={from:i.from,to:i.to,insert:t.state.doc.slice(i.from,n.from).append(n.insert).append(t.state.doc.slice(n.to,i.to))}:(Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==i.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ie.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:ot.of([" "])}):Oe.chrome&&n&&n.from==n.to&&n.from==i.head&&n.insert.toString()==`
|
|
675
675
|
`&&t.lineWrapping&&(r&&(r=ie.single(r.main.anchor-1,r.main.head-1)),n={from:i.from,to:i.to,insert:ot.of([" "])}),n){if(Oe.ios&&t.inputState.flushIOSKey(n)||Oe.android&&(n.to==i.to&&(n.from==i.from||n.from==i.from-1&&t.state.sliceDoc(n.from,i.from)==" ")&&n.insert.length==1&&n.insert.lines==2&&Go(t.contentDOM,"Enter",13)||(n.from==i.from-1&&n.to==i.to&&n.insert.length==0||s==8&&n.insert.length<n.to-n.from&&n.to>i.head)&&Go(t.contentDOM,"Backspace",8)||n.from==i.from&&n.to==i.to+1&&n.insert.length==0&&Go(t.contentDOM,"Delete",46)))return!0;let o=n.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let a,l=()=>a||(a=r8(t,n,r));return t.state.facet(AE).some(c=>c(t,n.from,n.to,o,l))||t.dispatch(l()),!0}else if(r&&!r.main.eq(i)){let o=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(o=!0),a=t.inputState.lastSelectionOrigin),t.dispatch({selection:r,scrollIntoView:o,userEvent:a}),!0}else return!1}function r8(t,e,n){let r,i=t.state,s=i.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.from<e.from?i.sliceDoc(s.from,e.from):"",l=s.to>e.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+l))}else{let a=i.changes(e),l=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),u,f=n&&BE(t,n.main.head);if(f){let p=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-p}}else u=t.state.doc.lineAt(s.head);let d=s.to-e.to,h=s.to-s.from;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:l||p.map(a)};let O=p.to-d,g=O-c.length;if(p.to-p.from!=h||t.state.sliceDoc(g,O)!=c||p.to>=u.from&&p.from<=u.to)return{range:p};let x=i.changes({from:g,to:O,insert:e.insert}),v=p.to-s.to;return{changes:x,range:l?ie.range(Math.max(0,l.anchor+v),Math.max(0,l.head+v)):p.map(x)}})}else r={changes:a,selection:l&&i.selection.replaceRange(l)}}let o="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:o,scrollIntoView:!0})}function i8(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s<i&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==i&&t.length==e.length)return null;let o=t.length,a=e.length;for(;o>0&&a>0&&t.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(r=="end"){let l=Math.max(0,s-Math.min(o,a));n-=o+l-s}if(o<s&&t.length<e.length){let l=n<=s&&n>=o?s-n:0;s-=l,a=s+(a-o),o=s}else if(a<s){let l=n<=s&&n>=a?s-n:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function s8(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new Db(n,r)),(i!=n||s!=r)&&e.push(new Db(i,s))),e}function o8(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ie.single(n+e,r+e):null}const a8={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},sp=Oe.ie&&Oe.ie_version<=11;class l8{constructor(e){this.view=e,this.active=!1,this.selectionRange=new zF,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),sp&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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 n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){e.type=="change"&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(zd)?r.root.activeElement!=this.dom:!Wu(r.dom,i))return;let s=i.anchorNode&&r.docView.nearest(i.anchorNode);if(s&&s.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&i.focusNode&&wl(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=$f(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&ZF(this.dom.ownerDocument)==this.dom&&c8(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=Wu(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&GF(this.dom,r)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(r),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let r=this.dom;r;)if(r.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==r?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);for(let r of this.scrollTargets=n)r.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,a8),sp&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),sp&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var r;if(!this.delayedAndroidKey){let i=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Go(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((r=this.delayedAndroidKey)===null||r===void 0)&&r.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&Wu(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new n8(this.view,e,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=HE(this.view,n);return this.view.state==r&&this.view.update([]),i}readMutation(e){let n=this.view.docView.nearest(e.target);if(!n||n.ignoreMutation(e))return null;if(n.markDirty(e.type=="attributes"),e.type=="attributes"&&(n.flags|=4),e.type=="childList"){let r=_b(n,e.previousSibling||e.target.previousSibling,-1),i=_b(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener("change",this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener("change",this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function _b(t,e,n){for(;e;){let r=Ct.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function Bb(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return wl(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function c8(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Bb(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?Bb(t,n):null}class de{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(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),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(r=>r.forEach(i=>n(i,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XF(e.parent)||document,this.viewState=new Rb(e.state||Ye.create(e)),e.scrollTo&&e.scrollTo.is(ou)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ll).map(r=>new tp(r));for(let r of this.plugins)r.update(this);this.observer=new l8(this),this.inputState=new C9(this),this.inputState.ensureHandlers(this.plugins),this.docView=new pb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let n=e.length==1&&e[0]instanceof Ut?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(d=>d.annotation(VE))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=zE(s,o),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(Ye.phrases)!=this.state.facet(Ye.phrases))return this.setState(s);i=jf.create(this,s,e),i.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection;f=new qo(h.empty?h:ie.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of d.effects)h.is(ou)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=Df.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(cl)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(du)!=i.state.facet(du)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(Z0))try{d(i)}catch(h){Zn(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!HE(this,u)&&c.force&&Go(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new Rb(e),this.plugins=e.facet(ll).map(r=>new tp(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new pb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ll),r=e.state.facet(ll);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new tp(s));else{let a=this.plugins[o];a.mustUpdate=e,i.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){Zn(this.state,r,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(sE(r))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);s=h.from,o=h.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(h=>{try{return h.read(this)}catch(p){return Zn(this.state,p),Qb}}),f=jf.create(this,this.state,[]),d=!1;f.flags|=l,n?n.flags|=l:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h<c.length;h++)if(u[h]!=Qb)try{let p=c[h];p.write&&p.write(u[h],this)}catch(p){Zn(this.state,p)}if(d&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(p>1||p<-1){i=i+p,r.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let a of this.state.facet(Z0))a(n)}get themeClasses(){return X0+" "+(this.state.facet(z0)?UE:qE)+" "+this.state.facet(du)}updateAttrs(){let e=Nb(this,$E,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(zd)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Nb(this,VO,n);let r=this.observer.ignore(()=>{let i=B0(this.contentDOM,this.contentAttrs,n),s=B0(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(de.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(cl);let e=this.state.facet(de.cspNonce);xs.mount(this.root,this.styleModules.concat(K9).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.spec!=e)&&this.pluginMap.set(e,n=this.plugins.find(r=>r.spec==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return rp(this,e,yb(this,e,n,r))}moveByGroup(e,n){return rp(this,e,yb(this,e,n,r=>S9(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return ie.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return b9(this,e,n,r)}moveVertically(e,n,r){return rp(this,e,w9(this,e,n,r))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){return this.readMeasured(),QE(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.docView.coordsAt(e,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(e),s=this.bidiSpans(i),o=s[ls.find(s,e-i.from,-1,n)];return Ld(r,o.dir==$t.LTR==n>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(EE)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>u8)return yE(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||xE(s.isolates,r=hb(this,e))))return s.order;r||(r=hb(this,e));let i=s9(e.text,n,r);return this.bidiCache.push(new Df(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{rE(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){return ou.of(new qo(typeof e=="number"?ie.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return ou.of(new qo(ie.cursor(r.from),"start","start",r.top-e,n,!0))}static domEventHandlers(e){return Bt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Bt.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=xs.newName(),i=[du.of(r),cl.of(G0(`.${r}`,e))];return n&&n.dark&&i.push(z0.of(!0)),i}static baseTheme(e){return wi.lowest(cl.of(G0("."+X0,e,YE)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&Ct.get(r)||Ct.get(e);return((n=i==null?void 0:i.rootView)===null||n===void 0?void 0:n.view)||null}}de.styleModule=cl;de.inputHandler=AE;de.scrollHandler=TE;de.focusChangeEffect=PE;de.perLineTextDirection=EE;de.exceptionSink=kE;de.updateListener=Z0;de.editable=zd;de.mouseSelectionStyle=CE;de.dragMovesSelection=wE;de.clickAddsSelectionRange=SE;de.decorations=Wl;de.outerDecorations=RE;de.atomicRanges=zO;de.bidiIsolatedRanges=jE;de.scrollMargins=DE;de.darkTheme=z0;de.cspNonce=me.define({combine:t=>t.length?t[0]:""});de.contentAttributes=VO;de.editorAttributes=$E;de.lineWrapping=de.contentAttributes.of({class:"cm-lineWrapping"});de.announce=Ne.define();const u8=4096,Qb={};class Df{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:$t.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new Df(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function Nb(t,e,n){for(let r=t.state.facet(e),i=r.length-1;i>=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&_0(o,n)}return n}const f8=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function d8(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,a;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),s&&(r="Ctrl-"+r),a&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function hu(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const h8=wi.default(de.domEventHandlers({keydown(t,e){return KE(JE(e.state),t,e,"editor")}})),Ta=me.define({enables:h8}),Mb=new WeakMap;function JE(t){let e=t.facet(Ta),n=Mb.get(e);return n||Mb.set(e,n=m8(e.reduce((r,i)=>r.concat(i),[]))),n}function p8(t,e,n){return KE(JE(t.state),e,t,n)}let is=null;const g8=4e3;function m8(t,e=f8){let n=Object.create(null),r=Object.create(null),i=(o,a)=>{let l=r[o];if(l==null)r[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,c,u)=>{var f,d;let h=n[o]||(n[o]=Object.create(null)),p=a.split(/ (?!$)/).map(x=>d8(x,e));for(let x=1;x<p.length;x++){let v=p.slice(0,x).join(" ");i(v,!0),h[v]||(h[v]={preventDefault:!0,stopPropagation:!1,run:[y=>{let b=is={view:y,prefix:v,scope:o};return setTimeout(()=>{is==b&&(is=null)},g8),!0}]})}let O=p.join(" ");i(O,!1);let g=h[O]||(h[O]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let o of t){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in u)u[f].run.push(o.any)}let l=o[e]||o.key;if(l)for(let c of a)s(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}function KE(t,e,n,r){let i=FF(e),s=bn(i,0),o=Ar(s)==i.length&&i!=" ",a="",l=!1,c=!1,u=!1;is&&is.view==n&&is.scope==r&&(a=is.prefix+" ",ME.indexOf(e.keyCode)<0&&(c=!0,is=null));let f=new Set,d=g=>{if(g){for(let x of g.run)if(!f.has(x)&&(f.add(x),x(n,e)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},h=t[r],p,O;return h&&(d(h[a+hu(i,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&(p=ys[e.keyCode])&&p!=i?(d(h[a+hu(p,e,!0)])||e.shiftKey&&(O=Zl[e.keyCode])!=i&&O!=p&&d(h[a+hu(O,e,!1)]))&&(l=!0):o&&e.shiftKey&&d(h[a+hu(i,e,!0)])&&(l=!0),!l&&d(h._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),l}class mc{constructor(e,n,r,i,s){this.className=e,this.left=n,this.top=r,this.width=i,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,r){if(r.empty){let i=e.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let s=e2(e);return[new mc(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return O8(e,n,r)}}function e2(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==$t.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Fb(t,e,n){let r=ie.cursor(e);return{from:Math.max(n.from,t.moveToLineBoundary(r,!1,!0).from),to:Math.min(n.to,t.moveToLineBoundary(r,!0,!0).from),type:Wn.Text}}function O8(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),i=Math.min(n.to,t.viewport.to),s=t.textDirection==$t.LTR,o=t.contentDOM,a=o.getBoundingClientRect(),l=e2(t),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),f=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=a.right-(u?parseInt(u.paddingRight):0),h=L0(t,r),p=L0(t,i),O=h.type==Wn.Text?h:null,g=p.type==Wn.Text?p:null;if(O&&(t.lineWrapping||h.widgetLineBreaks)&&(O=Fb(t,r,O)),g&&(t.lineWrapping||p.widgetLineBreaks)&&(g=Fb(t,i,g)),O&&g&&O.from==g.from)return v(y(n.from,n.to,O));{let S=O?y(n.from,null,O):b(h,!1),w=g?y(null,n.to,g):b(p,!0),C=[];return(O||h).to<(g||p).from-(O&&g?1:0)||h.widgetLineBreaks>1&&S.bottom+t.defaultLineHeight/2<w.top?C.push(x(f,S.bottom,d,w.top)):S.bottom<w.top&&t.elementAtHeight((S.bottom+w.top)/2).type==Wn.Text&&(S.bottom=w.top=(S.bottom+w.top)/2),v(S).concat(C).concat(v(w))}function x(S,w,C,k){return new mc(e,S-l.left,w-l.top-.01,C-S,k-w+.01)}function v({top:S,bottom:w,horizontal:C}){let k=[];for(let P=0;P<C.length;P+=2)k.push(x(C[P],S,C[P+1],w));return k}function y(S,w,C){let k=1e9,P=-1e9,A=[];function E(Q,_,Z,G,L){let U=t.coordsAtPos(Q,Q==C.to?-2:2),q=t.coordsAtPos(Z,Z==C.from?2:-2);!U||!q||(k=Math.min(U.top,q.top,k),P=Math.max(U.bottom,q.bottom,P),L==$t.LTR?A.push(s&&_?f:U.left,s&&G?d:q.right):A.push(!s&&G?f:q.left,!s&&_?d:U.right))}let $=S??C.from,R=w??C.to;for(let Q of t.visibleRanges)if(Q.to>$&&Q.from<R)for(let _=Math.max(Q.from,$),Z=Math.min(Q.to,R);;){let G=t.state.doc.lineAt(_);for(let L of t.bidiSpans(G)){let U=L.from+G.from,q=L.to+G.from;if(U>=Z)break;q>_&&E(Math.max(U,_),S==null&&U<=$,Math.min(q,Z),w==null&&q>=R,L.dir)}if(_=G.to+1,_>=Z)break}return A.length==0&&E($,S==null,R,w==null,t.textDirection),{top:k,bottom:P,horizontal:A}}function b(S,w){let C=a.top+(w?S.top:S.bottom);return{top:C,bottom:C,horizontal:[]}}}function v8(t,e){return t.constructor==e.constructor&&t.eq(e)}class x8{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(zu)!=e.state.facet(zu)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(zu);for(;n<r.length&&r[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:n}=this.view;(e!=this.scaleX||n!=this.scaleY)&&(this.scaleX=e,this.scaleY=n,this.dom.style.transform=`scale(${1/e}, ${1/n})`)}draw(e){if(e.length!=this.drawn.length||e.some((n,r)=>!v8(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let i of e)i.update&&n&&i.constructor&&this.drawn[r].constructor&&i.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(i.draw(),n);for(;n;){let i=n.nextSibling;n.remove(),n=i}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const zu=me.define();function t2(t){return[Bt.define(e=>new x8(e,t)),zu.of(t)]}const n2=!Oe.ios,Ll=me.define({combine(t){return ki(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function y8(t={}){return[Ll.of(t),b8,S8,w8,IE.of(!0)]}function r2(t){return t.startState.facet(Ll)!=t.state.facet(Ll)}const b8=t2({above:!0,markers(t){let{state:e}=t,n=e.facet(Ll),r=[];for(let i of e.selection.ranges){let s=i==e.selection.main;if(i.empty?!s||n2:n.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:ie.cursor(i.head,i.head>i.anchor?-1:1);for(let l of mc.forRange(t,o,a))r.push(l)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=r2(t);return n&&Zb(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Zb(e.state,t)},class:"cm-cursorLayer"});function Zb(t,e){e.style.animationDuration=t.facet(Ll).cursorBlinkRate+"ms"}const S8=t2({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:mc.forRange(t,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||r2(t)},class:"cm-selectionLayer"}),q0={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};n2&&(q0[".cm-line"].caretColor="transparent !important",q0[".cm-content"]={caretColor:"transparent !important"});const w8=wi.highest(de.theme(q0)),i2=Ne.define({map(t,e){return t==null?null:e.mapPos(t)}}),dl=ln.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((n,r)=>r.is(i2)?r.value:n,t)}}),C8=Bt.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let n=t.state.field(dl);n==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(dl)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field(dl),n=e!=null&&t.coordsAtPos(e);if(!n)return null;let r=t.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+t.scrollDOM.scrollLeft*t.scaleX,top:n.top-r.top+t.scrollDOM.scrollTop*t.scaleY,height:n.bottom-n.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/n+"px",this.cursor.style.height=t.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field(dl)!=t&&this.view.dispatch({effects:i2.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function k8(){return[dl,C8]}function Wb(t,e,n,r,i){e.lastIndex=0;for(let s=t.iterRange(n,r),o=n,a;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;a=e.exec(s.value);)i(o+a.index,a)}function A8(t,e){let n=t.visibleRanges;if(n.length==1&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;let r=[];for(let{from:i,to:s}of n)i=Math.max(t.state.doc.lineAt(i).from,i-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),r.length&&r[r.length-1].to>=i?r[r.length-1].to=s:r.push({from:i,to:s});return r}class s2{constructor(e){const{regexp:n,decoration:r,decorate:i,boundary:s,maxLength:o=1e3}=e;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=(a,l,c,u)=>i(u,c,c+a[0].length,a,l);else if(typeof r=="function")this.addMatch=(a,l,c,u)=>{let f=r(a,l,c);f&&u(c,c+a[0].length,f)};else if(r)this.addMatch=(a,l,c,u)=>u(c,c+a[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let n=new vs,r=n.add.bind(n);for(let{from:i,to:s}of A8(e,this.maxLength))Wb(e.state.doc,this.regexp,i,s,(o,a)=>this.addMatch(a,e,o,r));return n.finish()}updateDeco(e,n){let r=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((s,o,a,l)=>{l>e.view.viewport.from&&a<e.view.viewport.to&&(r=Math.min(a,r),i=Math.max(l,i))}),e.viewportChanged||i-r>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,n.map(e.changes),r,i):n}updateRange(e,n,r,i){for(let s of e.visibleRanges){let o=Math.max(s.from,r),a=Math.min(s.to,i);if(a>o){let l=e.state.doc.lineAt(o),c=l.to<a?e.state.doc.lineAt(a):l,u=Math.max(s.from,l.from),f=Math.min(s.to,c.to);if(this.boundary){for(;o>l.from;o--)if(this.boundary.test(l.text[o-1-l.from])){u=o;break}for(;a<c.to;a++)if(this.boundary.test(c.text[a-c.from])){f=a;break}}let d=[],h,p=(O,g,x)=>d.push(x.range(O,g));if(l==c)for(this.regexp.lastIndex=u-l.from;(h=this.regexp.exec(l.text))&&h.index<f-l.from;)this.addMatch(h,e,h.index+l.from,p);else Wb(e.state.doc,this.regexp,u,f,(O,g)=>this.addMatch(g,e,O,p));n=n.update({filterFrom:u,filterTo:f,filter:(O,g)=>O<u||g>f,add:d})}}return n}}const U0=/x/.unicode!=null?"gu":"g",P8=new RegExp(`[\0-\b
|
|
676
676
|
--\u2028\u2029\uFEFF-]`,U0),E8={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let op=null;function I8(){var t;if(op==null&&typeof document<"u"&&document.body){let e=document.body.style;op=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return op||!1}const Xu=me.define({combine(t){let e=ki(t,{render:null,specialChars:P8,addSpecialChars:null});return(e.replaceTabs=!I8())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,U0)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,U0)),e}});function T8(t={}){return[Xu.of(t),$8()]}let Lb=null;function $8(){return Lb||(Lb=Bt.fromClass(class{constructor(t){this.view=t,this.decorations=Se.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Xu)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new s2({regexp:t.specialChars,decoration:(e,n,r)=>{let{doc:i}=n.state,s=bn(e[0],0);if(s==9){let o=i.lineAt(r),a=n.state.tabSize,l=Ia(o.text,a,r-o.from);return Se.replace({widget:new _8((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Se.replace({widget:new D8(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Xu);t.startState.facet(Xu)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const R8="•";function j8(t){return t>=32?R8:t==10?"":String.fromCharCode(9216+t)}class D8 extends Ai{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=j8(this.code),r=e.state.phrase("Control character")+" "+(E8[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let s=document.createElement("span");return s.textContent=n,s.title=r,s.setAttribute("aria-label",r),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class _8 extends Ai{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function B8(){return N8}const Q8=Se.line({class:"cm-activeLine"}),N8=Bt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let i=t.lineBlockAt(r.head);i.from>e&&(n.push(Q8.range(i.from)),e=i.from)}return Se.set(n)}},{decorations:t=>t.decorations});let M8=class extends Ai{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let n=e.firstChild?aa(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Ld(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}};function F8(t){return Bt.fromClass(class{constructor(e){this.view=e,this.placeholder=t?Se.set([Se.widget({widget:new M8(t),side:1}).range(0)]):Se.none}get decorations(){return this.view.state.doc.length?Se.none:this.placeholder}},{decorations:e=>e.decorations})}const Y0=2e3;function Z8(t,e,n){let r=Math.min(e.line,n.line),i=Math.max(e.line,n.line),s=[];if(e.off>Y0||n.off>Y0||e.col<0||n.col<0){let o=Math.min(e.off,n.off),a=Math.max(e.off,n.off);for(let l=r;l<=i;l++){let c=t.doc.line(l);c.length<=a&&s.push(ie.range(c.from+o,c.to+a))}}else{let o=Math.min(e.col,n.col),a=Math.max(e.col,n.col);for(let l=r;l<=i;l++){let c=t.doc.line(l),u=E0(c.text,o,t.tabSize,!0);if(u<0)s.push(ie.cursor(c.to));else{let f=E0(c.text,a,t.tabSize);s.push(ie.range(c.from+u,c.from+f))}}}return s}function W8(t,e){let n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}function Vb(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),r=t.state.doc.lineAt(n),i=n-r.from,s=i>Y0?-1:i==r.length?W8(t,e.clientX):Ia(r.text,t.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function L8(t,e){let n=Vb(t,e),r=t.state.selection;return n?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(n.line).from),o=i.state.doc.lineAt(s);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},r=r.map(i.changes)}},get(i,s,o){let a=Vb(t,i);if(!a)return r;let l=Z8(t.state,n,a);return l.length?o?ie.create(l.concat(r.ranges)):ie.create(l):r}}:null}function V8(t){let e=n=>n.altKey&&n.button==0;return de.mouseSelectionStyle.of((n,r)=>e(r)?L8(n,r):null)}const z8={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},X8={style:"cursor: crosshair"};function G8(t={}){let[e,n]=z8[t.key||"Alt"],r=Bt.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==e||n(i))},keyup(i){(i.keyCode==e||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,de.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?X8:null})]}const Ha="-10000px";class o2{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=n?[]:null;for(let l=0;l<s.length;l++){let c=s[l],u=-1;if(c){for(let f=0;f<this.tooltips.length;f++){let d=this.tooltips[f];d&&d.create==c.create&&(u=f)}if(u<0)o[l]=this.createTooltipView(c,l?o[l-1]:null),a&&(a[l]=!!c.above);else{let f=o[l]=this.tooltipViews[u];a&&(a[l]=n[u]),f.update&&f.update(e)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(a.forEach((l,c)=>n[c]=l),n.length=a.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function q8(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const ap=me.define({combine:t=>{var e,n,r;return{position:Oe.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||q8}}}),zb=new WeakMap,GO=Bt.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(ap);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new o2(t,qO,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(ap);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=Ha,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect(),e=1,n=1,r=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:i}=this.manager.tooltipViews[0];if(Oe.gecko)r=i.offsetParent!=this.container.ownerDocument.body;else if(i.style.top==Ha&&i.style.left=="0px"){let s=i.getBoundingClientRect();r=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(r||this.position=="absolute")if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(e=i.width/this.parent.offsetWidth,n=i.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:n}=this.view.viewState);return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map((i,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(i.pos):this.view.coordsAtPos(i.pos)}),size:this.manager.tooltipViews.map(({dom:i})=>i.getBoundingClientRect()),space:this.view.state.facet(ap).tooltipSpace(this.view),scaleX:e,scaleY:n,makeAbsolute:r}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{editor:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,f=t.pos[a],d=t.size[a];if(!f||f.bottom<=Math.max(n.top,r.top)||f.top>=Math.min(n.bottom,r.bottom)||f.right<Math.max(n.left,r.left)-.1||f.left>Math.min(n.right,r.right)+.1){u.style.top=Ha;continue}let h=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,O=d.right-d.left,g=(e=zb.get(c))!==null&&e!==void 0?e:d.bottom-d.top,x=c.offset||Y8,v=this.view.textDirection==$t.LTR,y=d.width>r.right-r.left?v?r.left:r.right-d.width:v?Math.min(f.left-(h?14:0)+x.x,r.right-O):Math.max(r.left,f.left-O+(h?14:0)-x.x),b=this.above[a];!l.strictSide&&(b?f.top-(d.bottom-d.top)-x.y<r.top:f.bottom+(d.bottom-d.top)+x.y>r.bottom)&&b==r.bottom-f.bottom>f.top-r.top&&(b=this.above[a]=!b);let S=(b?f.top-r.top:r.bottom-f.bottom)-p;if(S<g&&c.resize!==!1){if(S<this.view.defaultLineHeight){u.style.top=Ha;continue}zb.set(c,g),u.style.height=(g=S)/s+"px"}else u.style.height&&(u.style.height="");let w=b?f.top-g-p-x.y:f.bottom+p+x.y,C=y+O;if(c.overlap!==!0)for(let k of o)k.left<C&&k.right>y&&k.top<w+g&&k.bottom>w&&(w=b?k.top-g-2-p:k.bottom+p+2);if(this.position=="absolute"?(u.style.top=(w-t.parent.top)/s+"px",u.style.left=(y-t.parent.left)/i+"px"):(u.style.top=w/s+"px",u.style.left=y/i+"px"),h){let k=f.left+(v?x.x:-x.x)-(y+14-7);h.style.left=k/i+"px"}c.overlap!==!0&&o.push({left:y,top:w,right:C,bottom:w+g}),u.classList.toggle("cm-tooltip-above",b),u.classList.toggle("cm-tooltip-below",!b),c.positioned&&c.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Ha}},{eventObservers:{scroll(){this.maybeMeasure()}}}),U8=de.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${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"}}}),Y8={x:0,y:0},qO=me.define({enables:[GO,U8]}),_f=me.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Xd{static create(e){return new Xd(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new o2(e,_f,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const H8=qO.compute([_f],t=>{let e=t.facet(_f);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Xd.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class J8{constructor(e,n,r,i,s){this.view=e,this.source=n,this.field=r,this.setHover=i,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:n}=this,r=e.docView.nearest(n.target);if(!r)return;let i,s=1;if(r instanceof as)i=r.posAtStart;else{if(i=e.posAtCoords(n),i==null)return;let a=e.coordsAtPos(i);if(!a||n.y<a.top||n.y>a.bottom||n.x<a.left-e.defaultCharacterWidth||n.x>a.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==$t.RTL?-1:1;s=n.x<a.left?-c:c}let o=this.source(e,i,s);if(o!=null&&o.then){let a=this.pending={pos:i};o.then(l=>{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Zn(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(GO),n=e?e.manager.tooltips.findIndex(r=>r.create==Xd.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&s&&!K8(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,a=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!eZ(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const pu=4;function K8(t,e){let n=t.getBoundingClientRect();return e.clientX>=n.left-pu&&e.clientX<=n.right+pu&&e.clientY>=n.top-pu&&e.clientY<=n.bottom+pu}function eZ(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),a=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,a)<i)return!1;let l=t.posAtCoords({x:r,y:i},!1);return l>=e&&l<=n}function tZ(t,e={}){let n=Ne.define(),r=ln.define({create(){return[]},update(i,s){if(i.length&&(e.hideOnChange&&(s.docChanged||s.selection)?i=[]:e.hideOn&&(i=i.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of i){let l=s.changes.mapPos(a.pos,-1,wn.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),o.push(c)}}i=o}for(let o of s.effects)o.is(n)&&(i=o.value),o.is(nZ)&&(i=[]);return i},provide:i=>_f.from(i)});return[r,Bt.define(i=>new J8(i,t,r,n,e.hoverTime||300)),H8]}function a2(t,e){let n=t.plugin(GO);if(!n)return null;let r=n.manager.tooltips.indexOf(e);return r<0?null:n.manager.tooltipViews[r]}const nZ=Ne.define(),Xb=me.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}});function Vl(t,e){let n=t.plugin(l2),r=n?n.specs.indexOf(e):-1;return r>-1?n.panels[r]:null}const l2=Bt.fromClass(class{constructor(t){this.input=t.state.facet(zl),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(Xb);this.top=new gu(t,!0,e.topContainer),this.bottom=new gu(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(Xb);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new gu(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new gu(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(zl);if(n!=this.input){let r=n.filter(l=>l),i=[],s=[],o=[],a=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(t.view),a.push(u)):(u=this.panels[c],u.update&&u.update(t)),i.push(u),(u.top?s:o).push(u)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>de.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});let gu=class{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=Gb(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=Gb(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function Gb(t){let e=t.nextSibling;return t.remove(),e}const zl=me.define({enables:l2});class Wi extends Hs{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Wi.prototype.elementClass="";Wi.prototype.toDOM=void 0;Wi.prototype.mapMode=wn.TrackBefore;Wi.prototype.startSide=Wi.prototype.endSide=-1;Wi.prototype.point=!0;const Gu=me.define(),rZ={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>et.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},kl=me.define();function iZ(t){return[c2(),kl.of(Object.assign(Object.assign({},rZ),t))]}const qb=me.define({combine:t=>t.some(e=>e)});function c2(t){return[sZ]}const sZ=Bt.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(kl).map(e=>new Yb(t,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!t.state.facet(qb),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(qb)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let n=et.iter(this.view.state.facet(Gu),this.view.viewport.from),r=[],i=this.gutters.map(s=>new oZ(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==Wn.Text&&o){H0(n,r,a.from);for(let l of i)l.line(this.view,a,r);o=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(s.type==Wn.Text){H0(n,r,s.from);for(let o of i)o.line(this.view,s,r)}else if(s.widget)for(let o of i)o.widget(this.view,s);for(let s of i)s.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(kl),n=t.state.facet(kl),r=t.docChanged||t.heightChanged||t.viewportChanged||!et.eq(t.startState.facet(Gu),t.state.facet(Gu),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let i of this.gutters)i.update(t)&&(r=!0);else{r=!0;let i=[];for(let s of n){let o=e.indexOf(s);o<0?i.push(new Yb(this.view,s)):(this.gutters[o].update(t),i.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>de.scrollMargins.of(e=>{let n=e.plugin(t);return!n||n.gutters.length==0||!n.fixed?null:e.textDirection==$t.LTR?{left:n.dom.offsetWidth*e.scaleX}:{right:n.dom.offsetWidth*e.scaleX}})});function Ub(t){return Array.isArray(t)?t:[t]}function H0(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class oZ{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=et.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:i}=this,s=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==i.elements.length){let a=new u2(e,o,s,r);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,o,s,r);this.height=n.bottom,this.i++}line(e,n,r){let i=[];H0(this.cursor,i,n.from),r.length&&(i=i.concat(r));let s=this.gutter.config.lineMarker(e,n,i);s&&i.unshift(s);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,i)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n);r&&this.addElement(e,n,[r])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Yb{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let s=i.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[r](e,a,i)&&i.preventDefault()});this.markers=Ub(n.markers(e)),n.initialSpacer&&(this.spacer=new u2(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ub(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let r=e.view.viewport;return!et.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class u2{constructor(e,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,i)}update(e,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),aZ(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let s=0,o=0;;){let a=o,l=s<n.length?n[s++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(l)){a=f,c=!0;break}}else a=this.markers.length;for(;o<a;){let u=this.markers[o++];if(u.toDOM){u.destroy(i);let f=i.nextSibling;i.remove(),i=f}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(e),i)),c&&o++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function aZ(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}const lZ=me.define(),Do=me.define({combine(t){return ki(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,n){let r=Object.assign({},e);for(let i in n){let s=r[i],o=n[i];r[i]=s?(a,l,c)=>s(a,l,c)||o(a,l,c):o}return r}})}});class lp extends Wi{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function cp(t,e){return t.state.facet(Do).formatNumber(e,t.state)}const cZ=kl.compute([Do],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(lZ)},lineMarker(e,n,r){return r.some(i=>i.toDOM)?null:new lp(cp(e,e.state.doc.lineAt(n.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Do)!=e.state.facet(Do),initialSpacer(e){return new lp(cp(e,Hb(e.state.doc.lines)))},updateSpacer(e,n){let r=cp(n.view,Hb(n.view.state.doc.lines));return r==e.number?e:new lp(r)},domEventHandlers:t.facet(Do).domEventHandlers}));function uZ(t={}){return[Do.of(t),c2(),cZ]}function Hb(t){let e=9;for(;e<t;)e=e*10+9;return e}const fZ=new class extends Wi{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},dZ=Gu.compute(["selection"],t=>{let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.head).from;i>n&&(n=i,e.push(fZ.range(i)))}return et.of(e)});function hZ(){return dZ}const f2=1024;let pZ=0,Pr=class{constructor(e,n){this.from=e,this.to=n}};class Ve{constructor(e={}){this.id=pZ++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Vn.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Ve.closedBy=new Ve({deserialize:t=>t.split(" ")});Ve.openedBy=new Ve({deserialize:t=>t.split(" ")});Ve.group=new Ve({deserialize:t=>t.split(" ")});Ve.isolate=new Ve({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Ve.contextHash=new Ve({perNode:!0});Ve.lookAhead=new Ve({perNode:!0});Ve.mounted=new Ve({perNode:!0});class Xl{constructor(e,n,r){this.tree=e,this.overlay=n,this.parser=r}static get(e){return e&&e.props&&e.props[Ve.mounted.id]}}const gZ=Object.create(null);class Vn{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):gZ,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Vn(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Ve.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Ve.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Vn.none=new Vn("",Object.create(null),0,8);class UO{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let i=null;for(let s of e){let o=s(r);o&&(i||(i=Object.assign({},r.props)),i[o[0].id]=o[1])}n.push(i?new Vn(r.name,i,r.id,r.flags):r)}return new UO(n)}}const mu=new WeakMap,Jb=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(Pt||(Pt={}));class _t{constructor(e,n,r,i,s){if(this.type=e,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=Xl.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Bf(this.topNode,e)}cursorAt(e,n=0,r=0){let i=mu.get(this)||this.topNode,s=new Bf(i);return s.moveTo(e,n),mu.set(this,s._tree),s}get topNode(){return new jn(this,0,0,null)}resolve(e,n=0){let r=Gl(mu.get(this)||this.topNode,e,n,!1);return mu.set(this,r),r}resolveInner(e,n=0){let r=Gl(Jb.get(this)||this.topNode,e,n,!0);return Jb.set(this,r),r}resolveStack(e,n=0){return vZ(this,e,n)}iterate(e){let{enter:n,leave:r,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&Pt.IncludeAnonymous)>0;for(let l=this.cursor(o|Pt.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:JO(Vn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new _t(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new _t(Vn.none,n,r,i)))}static build(e){return xZ(e)}}_t.empty=new _t(Vn.none,[],[],0);class YO{constructor(e,n){this.buffer=e,this.index=n}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 YO(this.buffer,this.index)}}class Ss{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Vn.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,r==e)return s;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,r,i,s){let{buffer:o}=this,a=-1;for(let l=e;l!=n&&!(d2(s,i,o[l+1],o[l+2])&&(a=l,r>0));l=o[l+3]);return a}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let a=e,l=0;a<n;){s[l++]=i[a++],s[l++]=i[a++]-r;let c=s[l++]=i[a++]-r;s[l++]=i[a++]-e,o=Math.max(o,c)}return new Ss(s,o,this.set)}}function d2(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function Gl(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!r&&t instanceof jn&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=r?0:Pt.IgnoreOverlays;if(r)for(let o=t,a=o.parent;a;o=a,a=o.parent)o instanceof jn&&o.index<0&&((i=a.enter(e,n,s))===null||i===void 0?void 0:i.from)!=o.from&&(t=a);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class h2{cursor(e=0){return new Bf(this,e)}getChild(e,n=null,r=null){let i=Kb(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return Kb(this,e,n,r)}resolve(e,n=0){return Gl(this,e,n,!1)}resolveInner(e,n=0){return Gl(this,e,n,!0)}matchContext(e){return J0(this,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class jn extends h2{constructor(e,n,r,i){super(),this._tree=e,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=n>0?a.length:-1;e!=c;e+=n){let u=a[e],f=l[e]+o.from;if(d2(i,r,f,f+u.length)){if(u instanceof Ss){if(s&Pt.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,n,r-f,i);if(d>-1)return new ci(new mZ(o,u,e,f),null,d)}else if(s&Pt.IncludeAnonymous||!u.type.isAnonymous||HO(u)){let d;if(!(s&Pt.IgnoreMounts)&&(d=Xl.get(u))&&!d.overlay)return new jn(d.tree,f,e,o);let h=new jn(u,f,e,o);return s&Pt.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&Pt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,r=0){let i;if(!(r&Pt.IgnoreOverlays)&&(i=Xl.get(this._tree))&&i.overlay){let s=e-this.from;for(let{from:o,to:a}of i.overlay)if((n>0?o<=s:o<s)&&(n<0?a>=s:a>s))return new jn(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Kb(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function J0(t,e,n=e.length-1){for(let r=t.parent;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class mZ{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class ci extends h2{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new ci(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new ci(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new ci(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new ci(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new _t(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function p2(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let r=n instanceof jn&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new OZ(i,n)}class OZ{constructor(e,n){this.heads=e,this.node=n}get next(){return p2(this.heads)}}function vZ(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof jn?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(e,n)),s=o}else{let o=Xl.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new jn(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Gl(a,e,n,!1))}}return i?p2(i):r}class Bf{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof jn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof jn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&Pt.IncludeAnonymous||a instanceof Ss||!a.type.isAnonymous||HO(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new ci(this.buffer,n,this.stack[i]);return this.bufferNode=new ci(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;i&&n&&n(this),i=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return J0(this.node,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return J0(this.node,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function HO(t){return t.children.some(e=>e instanceof Ss||!e.type.isAnonymous||HO(e))}function xZ(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=f2,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new YO(n,n.length):n,l=r.types,c=0,u=0;function f(S,w,C,k,P,A){let{id:E,start:$,end:R,size:Q}=a,_=u;for(;Q<0;)if(a.next(),Q==-1){let q=s[E];C.push(q),k.push($-S);return}else if(Q==-3){c=E;return}else if(Q==-4){u=E;return}else throw new RangeError(`Unrecognized record size: ${Q}`);let Z=l[E],G,L,U=$-S;if(R-$<=i&&(L=g(a.pos-w,P))){let q=new Uint16Array(L.size-L.skip),V=a.pos-L.size,j=q.length;for(;a.pos>V;)j=x(L.start,q,j);G=new Ss(q,R-L.start,r),U=L.start-S}else{let q=a.pos-Q;a.next();let V=[],j=[],N=E>=o?E:-1,B=0,H=R;for(;a.pos>q;)N>=0&&a.id==N&&a.size>=0?(a.end<=H-i&&(p(V,j,$,B,a.end,H,N,_),B=V.length,H=a.end),a.next()):A>2500?d($,q,V,j):f($,q,V,j,N,A+1);if(N>=0&&B>0&&B<V.length&&p(V,j,$,B,$,H,N,_),V.reverse(),j.reverse(),N>-1&&B>0){let F=h(Z);G=JO(Z,V,j,0,V.length,0,R-$,F,F)}else G=O(Z,V,j,R-$,_-R)}C.push(G),k.push(U)}function d(S,w,C,k){let P=[],A=0,E=-1;for(;a.pos>w;){let{id:$,start:R,end:Q,size:_}=a;if(_>4)a.next();else{if(E>-1&&R<E)break;E<0&&(E=Q-i),P.push($,R,Q),A++,a.next()}}if(A){let $=new Uint16Array(A*4),R=P[P.length-2];for(let Q=P.length-3,_=0;Q>=0;Q-=3)$[_++]=P[Q],$[_++]=P[Q+1]-R,$[_++]=P[Q+2]-R,$[_++]=_;C.push(new Ss($,P[2]-R,r)),k.push(R-S)}}function h(S){return(w,C,k)=>{let P=0,A=w.length-1,E,$;if(A>=0&&(E=w[A])instanceof _t){if(!A&&E.type==S&&E.length==k)return E;($=E.prop(Ve.lookAhead))&&(P=C[A]+E.length+$)}return O(S,w,C,k,P)}}function p(S,w,C,k,P,A,E,$){let R=[],Q=[];for(;S.length>k;)R.push(S.pop()),Q.push(w.pop()+C-P);S.push(O(r.types[E],R,Q,A-P,$-A)),w.push(P-C)}function O(S,w,C,k,P=0,A){if(c){let E=[Ve.contextHash,c];A=A?[E].concat(A):[E]}if(P>25){let E=[Ve.lookAhead,P];A=A?[E].concat(A):[E]}return new _t(S,w,C,k,A)}function g(S,w){let C=a.fork(),k=0,P=0,A=0,E=C.end-i,$={size:0,start:0,skip:0};e:for(let R=C.pos-S;C.pos>R;){let Q=C.size;if(C.id==w&&Q>=0){$.size=k,$.start=P,$.skip=A,A+=4,k+=4,C.next();continue}let _=C.pos-Q;if(Q<0||_<R||C.start<E)break;let Z=C.id>=o?4:0,G=C.start;for(C.next();C.pos>_;){if(C.size<0)if(C.size==-3)Z+=4;else break e;else C.id>=o&&(Z+=4);C.next()}P=G,k+=Q,A+=Z}return(w<0||k==S)&&($.size=k,$.start=P,$.skip=A),$.size>4?$:void 0}function x(S,w,C){let{id:k,start:P,end:A,size:E}=a;if(a.next(),E>=0&&k<o){let $=C;if(E>4){let R=a.pos-(E-4);for(;a.pos>R;)C=x(S,w,C)}w[--C]=$,w[--C]=A-S,w[--C]=P-S,w[--C]=k}else E==-3?c=k:E==-4&&(u=k);return C}let v=[],y=[];for(;a.pos>0;)f(t.start||0,t.bufferStart||0,v,y,-1,0);let b=(e=t.length)!==null&&e!==void 0?e:v.length?y[0]+v[0].length:0;return new _t(l[t.topID],v.reverse(),y.reverse(),b)}const e1=new WeakMap;function qu(t,e){if(!t.isAnonymous||e instanceof Ss||e.type!=t)return 1;let n=e1.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof _t)){n=1;break}n+=qu(t,r)}e1.set(e,n)}return n}function JO(t,e,n,r,i,s,o,a,l){let c=0;for(let p=r;p<i;p++)c+=qu(t,e[p]);let u=Math.ceil(c*1.5/8),f=[],d=[];function h(p,O,g,x,v){for(let y=g;y<x;){let b=y,S=O[y],w=qu(t,p[y]);for(y++;y<x;y++){let C=qu(t,p[y]);if(w+C>=u)break;w+=C}if(y==b+1){if(w>u){let C=p[b];h(C.children,C.positions,0,C.children.length,O[b]+v);continue}f.push(p[b])}else{let C=O[y-1]+p[y-1].length-S;f.push(JO(t,p,O,b,y,S,C,null,l))}d.push(S+v-s)}}return h(e,n,r,i,0),(a||l)(f,d,o)}class g2{constructor(){this.map=new WeakMap}setBuffer(e,n,r){let i=this.map.get(e);i||this.map.set(e,i=new Map),i.set(n,r)}getBuffer(e,n){let r=this.map.get(e);return r&&r.get(n)}set(e,n){e instanceof ci?this.setBuffer(e.context.buffer,e.index,n):e instanceof jn&&this.map.set(e.tree,n)}get(e){return e instanceof ci?this.getBuffer(e.context.buffer,e.index):e instanceof jn?this.map.get(e.tree):void 0}cursorSet(e,n){e.buffer?this.setBuffer(e.buffer.buffer,e.index,n):this.map.set(e.tree,n)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Qi{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new Qi(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,f=u?u.fromA:1e9;if(f-l>=r)for(;o&&o.from<f;){let d=o;if(l>=d.from||f<=d.to||c){let h=Math.max(d.from,l)-c,p=Math.min(d.to,f)-c;d=h>=p?null:new Qi(h,p,d.tree,d.offset+c,a>0,!!u)}if(d&&i.push(d),o.to>f)break;o=s<e.length?e[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}let m2=class{startParse(e,n,r){return typeof e=="string"&&(e=new yZ(e)),r=r?r.length?r.map(i=>new Pr(i.from,i.to)):[new Pr(0,0)]:[new Pr(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}};class yZ{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}function bZ(t){return(e,n,r,i)=>new wZ(e,t,n,r,i)}class t1{constructor(e,n,r,i,s){this.parser=e,this.parse=n,this.overlay=r,this.target=i,this.from=s}}function n1(t){if(!t.length||t.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class SZ{constructor(e,n,r,i,s,o,a){this.parser=e,this.predicate=n,this.mounts=r,this.index=i,this.start=s,this.target=o,this.prev=a,this.depth=0,this.ranges=[]}}const K0=new Ve({perNode:!0});class wZ{constructor(e,n,r,i,s){this.nest=n,this.input=r,this.fragments=i,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new _t(r.type,r.children,r.positions,r.length,r.propValues.concat([[K0,this.stoppedAt]]))),r}let e=this.inner[this.innerDone],n=e.parse.advance();if(n){this.innerDone++;let r=Object.assign(Object.create(null),e.target.props);r[Ve.mounted.id]=new Xl(n,e.overlay,e.parser),e.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].from<e&&(e=Math.min(e,this.inner[n].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].parse.stopAt(e)}startInner(){let e=new AZ(this.fragments),n=null,r=null,i=new Bf(new jn(this.baseTree,this.ranges[0].from,0,null),Pt.IncludeAnonymous|Pt.IgnoreMounts);e:for(let s,o;;){let a=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)a=!1;else if(e.hasNode(i)){if(n){let c=n.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(c)for(let u of c.mount.overlay){let f=u.from+c.pos,d=u.to+c.pos;f>=i.from&&d<=i.to&&!n.ranges.some(h=>h.from<d&&h.to>f)&&n.ranges.push({from:f,to:d})}}a=!1}else if(r&&(o=CZ(r.ranges,i.from,i.to)))a=o!=2;else if(!i.type.isAnonymous&&(s=this.nest(i,this.input))&&(i.from<i.to||!s.overlay)){i.tree||kZ(i);let c=e.findMounts(i.from,s.parser);if(typeof s.overlay=="function")n=new SZ(s.parser,s.overlay,c,this.inner.length,i.from,i.tree,n);else{let u=s1(this.ranges,s.overlay||(i.from<i.to?[new Pr(i.from,i.to)]:[]));u.length&&n1(u),(u.length||!s.overlay)&&this.inner.push(new t1(s.parser,u.length?s.parser.startParse(this.input,o1(c,u),u):s.parser.startParse(""),s.overlay?s.overlay.map(f=>new Pr(f.from-i.from,f.to-i.from)):null,i.tree,u.length?u[0].from:i.from)),s.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):a=!1}}else n&&(l=n.predicate(i))&&(l===!0&&(l=new Pr(i.from,i.to)),l.from<l.to&&n.ranges.push(l));if(a&&i.firstChild())n&&n.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(n&&!--n.depth){let c=s1(this.ranges,n.ranges);c.length&&(n1(c),this.inner.splice(n.index,0,new t1(n.parser,n.parser.startParse(this.input,o1(n.mounts,c),c),n.ranges.map(u=>new Pr(u.from-n.start,u.to-n.start)),n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function CZ(t,e,n){for(let r of t){if(r.from>=n)break;if(r.to>e)return r.from<=e&&r.to>=n?2:1}return 0}function r1(t,e,n,r,i,s){if(e<n){let o=t.buffer[e+1];r.push(t.slice(e,n,o)),i.push(o-s)}}function kZ(t){let{node:e}=t,n=[],r=e.context.buffer;do n.push(t.index),t.parent();while(!t.tree);let i=t.tree,s=i.children.indexOf(r),o=i.children[s],a=o.buffer,l=[s];function c(u,f,d,h,p,O){let g=n[O],x=[],v=[];r1(o,u,g,x,v,h);let y=a[g+1],b=a[g+2];l.push(x.length);let S=O?c(g+4,a[g+3],o.set.types[a[g]],y,b-y,O-1):e.toTree();return x.push(S),v.push(y-h),r1(o,a[g+3],f,x,v,h),new _t(d,x,v,p)}i.children[s]=c(0,a.length,Vn.none,0,o.length,n.length-1);for(let u of l){let f=t.tree.children[u],d=t.tree.positions[u];t.yield(new jn(f,d+t.from,u,t._tree))}}class i1{constructor(e,n){this.offset=n,this.done=!1,this.cursor=e.cursor(Pt.IncludeAnonymous|Pt.IgnoreMounts)}moveTo(e){let{cursor:n}=this,r=e-this.offset;for(;!this.done&&n.from<r;)n.to>=e&&n.enter(r,1,Pt.IgnoreOverlays|Pt.ExcludeBuffers)||n.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==e.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof _t)n=n.children[0];else break}return!1}}let AZ=class{constructor(e){var n;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let r=this.curFrag=e[0];this.curTo=(n=r.tree.prop(K0))!==null&&n!==void 0?n:r.to,this.inner=new i1(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(e=n.tree.prop(K0))!==null&&e!==void 0?e:n.to,this.inner=new i1(n.tree,-n.offset)}}findMounts(e,n){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(r=s.tree)===null||r===void 0?void 0:r.prop(Ve.mounted);if(o&&o.parser==n)for(let a=this.fragI;a<this.fragments.length;a++){let l=this.fragments[a];if(l.from>=s.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:s.from-l.offset,mount:o})}}}return i}};function s1(t,e){let n=null,r=e;for(let i=1,s=0;i<t.length;i++){let o=t[i-1].to,a=t[i].from;for(;s<r.length;s++){let l=r[s];if(l.from>=a)break;l.to<=o||(n||(r=n=e.slice()),l.from<o?(n[s]=new Pr(l.from,o),l.to>a&&n.splice(s+1,0,new Pr(a,l.to))):l.to>a?n[s--]=new Pr(a,l.to):n.splice(s--,1))}}return r}function PZ(t,e,n,r){let i=0,s=0,o=!1,a=!1,l=-1e9,c=[];for(;;){let u=i==t.length?1e9:o?t[i].to:t[i].from,f=s==e.length?1e9:a?e[s].to:e[s].from;if(o!=a){let d=Math.max(l,n),h=Math.min(u,f,r);d<h&&c.push(new Pr(d,h))}if(l=Math.min(u,f),l==1e9)break;u==l&&(o?(o=!1,i++):o=!0),f==l&&(a?(a=!1,s++):a=!0)}return c}function o1(t,e){let n=[];for(let{pos:r,mount:i,frag:s}of t){let o=r+(i.overlay?i.overlay[0].from:0),a=o+i.tree.length,l=Math.max(s.from,o),c=Math.min(s.to,a);if(i.overlay){let u=i.overlay.map(d=>new Pr(d.from+r,d.to+r)),f=PZ(e,u,l,c);for(let d=0,h=l;;d++){let p=d==f.length,O=p?c:f[d].from;if(O>h&&n.push(new Qi(h,O,i.tree,-o,s.from>=h||s.openStart,s.to<=O||s.openEnd)),p)break;h=f[d].to}}else n.push(new Qi(l,c,i.tree,-o,s.from>=o||s.openStart,s.to<=a||s.openEnd))}return n}let EZ=0,es=class O2{constructor(e,n,r){this.set=e,this.base=n,this.modified=r,this.id=EZ++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let n=new O2([],null,[]);if(n.set.push(n),e)for(let r of e.set)n.set.push(r);return n}static defineModifier(){let e=new Qf;return n=>n.modified.indexOf(e)>-1?n:Qf.get(n.base||n,n.modified.concat(e).sort((r,i)=>r.id-i.id))}},IZ=0;class Qf{constructor(){this.instances=[],this.id=IZ++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&TZ(n,a.modified));if(r)return r;let i=[],s=new es(i,e,n);for(let a of n)a.instances.push(s);let o=$Z(n);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(Qf.get(a,l));return s}}function TZ(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function $Z(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function $a(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,a=i;for(let f=0;;){if(a=="..."&&f>0&&f+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+i);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==i.length)break;let h=i[f++];if(f==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);a=i.slice(f)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new Nf(r,o,l>0?s.slice(0,l):null);e[c]=u.sort(e[c])}}return v2.add(e)}const v2=new Ve;class Nf{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Nf.empty=new Nf([],2,null);function x2(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:r,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let l of a.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function RZ(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function jZ(t,e,n,r=0,i=t.length){let s=new DZ(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class DZ{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:a,to:l}=e;if(a>=r||l<=n)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let c=i,u=_Z(e)||Nf.empty,f=RZ(s,u.tags);if(f&&(c&&(c+=" "),c+=f,u.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,a),c),u.opaque)return;let d=e.tree&&e.tree.prop(Ve.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(d.tree.type)),O=e.firstChild();for(let g=0,x=a;;g++){let v=g<d.overlay.length?d.overlay[g]:null,y=v?v.from+a:l,b=Math.max(n,x),S=Math.min(r,y);if(b<S&&O)for(;e.from<S&&(this.highlightRange(e,b,S,i,s),this.startSpan(Math.min(S,e.to),c),!(e.to>=y||!e.nextSibling())););if(!v||y>r)break;x=v.to+a,x>n&&(this.highlightRange(h.cursor(),Math.max(n,v.from+a),Math.min(r,x),"",p),this.startSpan(Math.min(r,x),c))}O&&e.parent()}else if(e.firstChild()){d&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function _Z(t){let e=t.type.prop(v2);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const fe=es.define,Ou=fe(),ts=fe(),a1=fe(ts),l1=fe(ts),ns=fe(),vu=fe(ns),up=fe(ns),ni=fe(),Ms=fe(ni),ei=fe(),ti=fe(),em=fe(),Ja=fe(em),xu=fe(),I={comment:Ou,lineComment:fe(Ou),blockComment:fe(Ou),docComment:fe(Ou),name:ts,variableName:fe(ts),typeName:a1,tagName:fe(a1),propertyName:l1,attributeName:fe(l1),className:fe(ts),labelName:fe(ts),namespace:fe(ts),macroName:fe(ts),literal:ns,string:vu,docString:fe(vu),character:fe(vu),attributeValue:fe(vu),number:up,integer:fe(up),float:fe(up),bool:fe(ns),regexp:fe(ns),escape:fe(ns),color:fe(ns),url:fe(ns),keyword:ei,self:fe(ei),null:fe(ei),atom:fe(ei),unit:fe(ei),modifier:fe(ei),operatorKeyword:fe(ei),controlKeyword:fe(ei),definitionKeyword:fe(ei),moduleKeyword:fe(ei),operator:ti,derefOperator:fe(ti),arithmeticOperator:fe(ti),logicOperator:fe(ti),bitwiseOperator:fe(ti),compareOperator:fe(ti),updateOperator:fe(ti),definitionOperator:fe(ti),typeOperator:fe(ti),controlOperator:fe(ti),punctuation:em,separator:fe(em),bracket:Ja,angleBracket:fe(Ja),squareBracket:fe(Ja),paren:fe(Ja),brace:fe(Ja),content:ni,heading:Ms,heading1:fe(Ms),heading2:fe(Ms),heading3:fe(Ms),heading4:fe(Ms),heading5:fe(Ms),heading6:fe(Ms),contentSeparator:fe(ni),list:fe(ni),quote:fe(ni),emphasis:fe(ni),strong:fe(ni),link:fe(ni),monospace:fe(ni),strikethrough:fe(ni),inserted:fe(),deleted:fe(),changed:fe(),invalid:fe(),meta:xu,documentMeta:fe(xu),annotation:fe(xu),processingInstruction:fe(xu),definition:es.defineModifier(),constant:es.defineModifier(),function:es.defineModifier(),standard:es.defineModifier(),local:es.defineModifier(),special:es.defineModifier()};x2([{tag:I.link,class:"tok-link"},{tag:I.heading,class:"tok-heading"},{tag:I.emphasis,class:"tok-emphasis"},{tag:I.strong,class:"tok-strong"},{tag:I.keyword,class:"tok-keyword"},{tag:I.atom,class:"tok-atom"},{tag:I.bool,class:"tok-bool"},{tag:I.url,class:"tok-url"},{tag:I.labelName,class:"tok-labelName"},{tag:I.inserted,class:"tok-inserted"},{tag:I.deleted,class:"tok-deleted"},{tag:I.literal,class:"tok-literal"},{tag:I.string,class:"tok-string"},{tag:I.number,class:"tok-number"},{tag:[I.regexp,I.escape,I.special(I.string)],class:"tok-string2"},{tag:I.variableName,class:"tok-variableName"},{tag:I.local(I.variableName),class:"tok-variableName tok-local"},{tag:I.definition(I.variableName),class:"tok-variableName tok-definition"},{tag:I.special(I.variableName),class:"tok-variableName2"},{tag:I.definition(I.propertyName),class:"tok-propertyName tok-definition"},{tag:I.typeName,class:"tok-typeName"},{tag:I.namespace,class:"tok-namespace"},{tag:I.className,class:"tok-className"},{tag:I.macroName,class:"tok-macroName"},{tag:I.propertyName,class:"tok-propertyName"},{tag:I.operator,class:"tok-operator"},{tag:I.comment,class:"tok-comment"},{tag:I.meta,class:"tok-meta"},{tag:I.invalid,class:"tok-invalid"},{tag:I.punctuation,class:"tok-punctuation"}]);var fp;const _o=new Ve;function y2(t){return me.define({combine:t?e=>e.concat(t):void 0})}const KO=new Ve;class Lr{constructor(e,n,r=[],i=""){this.data=e,this.name=i,Ye.prototype.hasOwnProperty("tree")||Object.defineProperty(Ye.prototype,"tree",{get(){return Dt(this)}}),this.parser=n,this.extension=[Cs.of(this),Ye.languageData.of((s,o,a)=>{let l=c1(s,o,a),c=l.type.prop(_o);if(!c)return[];let u=s.facet(c),f=l.type.prop(KO);if(f){let d=l.resolve(o-l.from,a);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(u)}}return u})].concat(r)}isActiveAt(e,n,r=-1){return c1(e,n,r).type.prop(_o)==this.data}findRegions(e){let n=e.facet(Cs);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(_o)==this.data){r.push({from:o,to:o+s.length});return}let a=s.prop(Ve.mounted);if(a){if(a.tree.prop(_o)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+s.length});return}else if(a.overlay){let l=r.length;if(i(a.tree,a.overlay[0].from+o),r.length>l)return}}for(let l=0;l<s.children.length;l++){let c=s.children[l];c instanceof _t&&i(c,s.positions[l]+o)}};return i(Dt(e),0),r}get allowsNesting(){return!0}}Lr.setState=Ne.define();function c1(t,e,n){let r=t.facet(Cs),i=Dt(t).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(e,n,Pt.ExcludeBuffers))s.type.isTop&&(i=s);return i}class ws extends Lr{constructor(e,n,r){super(e,n,[],r),this.parser=n}static define(e){let n=y2(e.languageData);return new ws(n,e.parser.configure({props:[_o.add(r=>r.isTop?n:void 0)]}),e.name)}configure(e,n){return new ws(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Dt(t){let e=t.field(Lr.state,!1);return e?e.tree:_t.empty}class BZ{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e<r||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ka=null;class Mf{constructor(e,n,r=[],i,s,o,a,l){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Mf(e,n,[],_t.empty,0,r,[],null)}startParse(){return this.parser.startParse(new BZ(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=_t.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(Qi.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Qi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ka;Ka=this;try{return e()}finally{Ka=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=u1(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,f,d)=>l.push({fromA:c,toA:u,fromB:f,toB:d})),r=Qi.applyChanges(r,l),i=_t.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);u<f&&a.push({from:u,to:f})}}}return new Mf(this.parser,n,r,i,s,o,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:s}=this.skipped[r];i<e.to&&s>e.from&&(this.fragments=u1(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends m2{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let l=Ka;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new _t(Vn.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ka}}function u1(t,e,n){return Qi.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class ua{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new ua(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Mf.create(e.facet(Cs).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new ua(r)}}Lr.state=ln.define({create:ua.init,update(t,e){for(let n of e.effects)if(n.is(Lr.setState))return n.value;return e.startState.facet(Cs)!=e.state.facet(Cs)?ua.init(e.state):t.apply(e)}});let b2=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(b2=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const dp=typeof navigator<"u"&&(!((fp=navigator.scheduling)===null||fp===void 0)&&fp.isInputPending)?()=>navigator.scheduling.isInputPending():null,QZ=Bt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Lr.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Lr.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=b2(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,s=r.field(Lr.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!dp?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<i&&r.doc.length>i+1e3,l=s.context.work(()=>dp&&dp()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Lr.setState.of(new ua(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Zn(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Cs=me.define({combine(t){return t.length?t[0]:null},enables:t=>[Lr.state,QZ,de.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class Oc{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const NZ=me.define(),vc=me.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ff(t){let e=t.facet(vc);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function ql(t,e){let n="",r=t.tabSize,i=t.facet(vc)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s<e;s++)n+=i;return n}function ev(t,e){t instanceof Ye&&(t=new Gd(t));for(let r of t.state.facet(NZ)){let i=r(t,e);if(i!==void 0)return i}let n=Dt(t.state);return n.length>=e?MZ(t,n,e):null}class Gd{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ff(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i<e:i<=e)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(e,n);return r.slice(e-i,Math.min(r.length,e+100-i))}column(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.countColumn(r,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return Ia(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ra=new Ve;function MZ(t,e,n){let r=e.resolveStack(n),i=r.node.enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o!=r.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return S2(r,t,n)}function S2(t,e,n){for(let r=t;r;r=r.next){let i=ZZ(r.node);if(i)return i(tv.create(e,n,r))}return 0}function FZ(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function ZZ(t){let e=t.type.prop(Ra);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(Ve.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>w2(o,!0,1,void 0,s&&!FZ(o)?i.from:void 0)}return t.parent==null?WZ:null}function WZ(){return 0}class tv extends Gd{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new tv(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(LZ(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return S2(this.context.next,this.base,this.pos)}}function LZ(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function VZ(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let a=n.to;;){let l=e.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped)return l.from<o?n:null;a=l.to}}function zZ({closing:t,align:e=!0,units:n=1}){return r=>w2(r,e,n,t)}function w2(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,a=r&&s.slice(o,o+r.length)==r||i==t.pos+o,l=e?VZ(t):null;return l?a?t.column(l.from):t.column(l.to):t.baseIndent+(a?0:t.unit*n)}const XZ=t=>t.baseIndent;function Uo({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const GZ=200;function qZ(){return Ye.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:r}=t.newSelection.main,i=n.lineAt(r);if(r>i.from+GZ)return t;let s=n.sliceString(i.from,r);if(!e.some(c=>c.test(s)))return t;let{state:o}=t,a=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=ev(o,u.from);if(f==null)continue;let d=/^\s*/.exec(u.text)[0],h=ql(o,f);d!=h&&l.push({from:u.from,to:u.from+d.length,insert:h})}return l.length?[t,{changes:l,sequential:!0}]:t})}const UZ=me.define(),ja=new Ve;function nv(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function YZ(t,e,n){let r=Dt(t);if(r.length<n)return null;let i=r.resolveStack(n,1),s=null;for(let o=i;o;o=o.next){let a=o.node;if(a.to<=n||a.from>n)continue;if(s&&a.from<e)break;let l=a.type.prop(ja);if(l&&(a.to<r.length-50||r.length==t.doc.length||!HZ(a))){let c=l(a,t);c&&c.from<=n&&c.from>=e&&c.to>n&&(s=c)}}return s}function HZ(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Zf(t,e,n){for(let r of t.facet(UZ)){let i=r(t,e,n);if(i)return i}return YZ(t,e,n)}function C2(t,e){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);return n>=r?void 0:{from:n,to:r}}const qd=Ne.define({map:C2}),xc=Ne.define({map:C2});function k2(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(r=>r.from<=n&&r.to>=n)||e.push(t.lineBlockAt(n));return e}const to=ln.define({create(){return Se.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)if(n.is(qd)&&!JZ(t,n.value.from,n.value.to)){let{preparePlaceholder:r}=e.state.facet(E2),i=r?Se.replace({widget:new sW(r(e.state,n.value))}):f1;t=t.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(xc)&&(t=t.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));if(e.selection){let n=!1,{head:r}=e.selection.main;t.between(r,r,(i,s)=>{i<r&&s>r&&(n=!0)}),n&&(t=t.update({filterFrom:r,filterTo:r,filter:(i,s)=>s<=r||i>=r}))}return t},provide:t=>de.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let r=t[n++],i=t[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(f1.range(r,i))}return Se.set(e,!0)}});function Wf(t,e,n){var r;let i=null;return(r=t.field(to,!1))===null||r===void 0||r.between(e,n,(s,o)=>{(!i||i.from>s)&&(i={from:s,to:o})}),i}function JZ(t,e,n){let r=!1;return t.between(e,e,(i,s)=>{i==e&&s==n&&(r=!0)}),r}function A2(t,e){return t.field(to,!1)?e:e.concat(Ne.appendConfig.of(I2()))}const KZ=t=>{for(let e of k2(t)){let n=Zf(t.state,e.from,e.to);if(n)return t.dispatch({effects:A2(t.state,[qd.of(n),P2(t,n)])}),!0}return!1},eW=t=>{if(!t.state.field(to,!1))return!1;let e=[];for(let n of k2(t)){let r=Wf(t.state,n.from,n.to);r&&e.push(xc.of(r),P2(t,r,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function P2(t,e,n=!0){let r=t.state.doc.lineAt(e.from).number,i=t.state.doc.lineAt(e.to).number;return de.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${t.state.phrase("to")} ${i}.`)}const tW=t=>{let{state:e}=t,n=[];for(let r=0;r<e.doc.length;){let i=t.lineBlockAt(r),s=Zf(e,i.from,i.to);s&&n.push(qd.of(s)),r=(s?t.lineBlockAt(s.to):i).to+1}return n.length&&t.dispatch({effects:A2(t.state,n)}),!!n.length},nW=t=>{let e=t.state.field(to,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(r,i)=>{n.push(xc.of({from:r,to:i}))}),t.dispatch({effects:n}),!0},rW=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:KZ},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:eW},{key:"Ctrl-Alt-[",run:tW},{key:"Ctrl-Alt-]",run:nW}],iW={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},E2=me.define({combine(t){return ki(t,iW)}});function I2(t){return[to,lW]}function T2(t,e){let{state:n}=t,r=n.facet(E2),i=o=>{let a=t.lineBlockAt(t.posAtDOM(o.target)),l=Wf(t.state,a.from,a.to);l&&t.dispatch({effects:xc.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(t,i,e);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const f1=Se.replace({widget:new class extends Ai{toDOM(t){return T2(t,null)}}});class sW extends Ai{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return T2(e,this.value)}}const oW={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class hp extends Wi{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function aW(t={}){let e=Object.assign(Object.assign({},oW),t),n=new hp(e,!0),r=new hp(e,!1),i=Bt.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Cs)!=o.state.facet(Cs)||o.startState.field(to,!1)!=o.state.field(to,!1)||Dt(o.startState)!=Dt(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new vs;for(let l of o.viewportLineBlocks){let c=Wf(o.state,l.from,l.to)?r:Zf(o.state,l.from,l.to)?n:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:s}=e;return[i,iZ({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(i))===null||a===void 0?void 0:a.markers)||et.empty},initialSpacer(){return new hp(e,!1)},domEventHandlers:Object.assign(Object.assign({},s),{click:(o,a,l)=>{if(s.click&&s.click(o,a,l))return!0;let c=Wf(o.state,a.from,a.to);if(c)return o.dispatch({effects:xc.of(c)}),!0;let u=Zf(o.state,a.from,a.to);return u?(o.dispatch({effects:qd.of(u)}),!0):!1}})}),I2()]}const lW=de.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Da{constructor(e,n){this.specs=e;let r;function i(a){let l=xs.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const s=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof Lr?a=>a.prop(_o)==o.data:o?a=>a==o:void 0,this.style=x2(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=r?new xs(r):null,this.themeType=n.themeType}static define(e,n){return new Da(e,n||{})}}const tm=me.define(),$2=me.define({combine(t){return t.length?[t[0]]:null}});function pp(t){let e=t.facet(tm);return e.length?e:t.facet($2)}function rv(t,e){let n=[uW],r;return t instanceof Da&&(t.module&&n.push(de.styleModule.of(t.module)),r=t.themeType),e!=null&&e.fallback?n.push($2.of(t)):r?n.push(tm.computeN([de.darkTheme],i=>i.facet(de.darkTheme)==(r=="dark")?[t]:[])):n.push(tm.of(t)),n}class cW{constructor(e){this.markCache=Object.create(null),this.tree=Dt(e.state),this.decorations=this.buildDeco(e,pp(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=Dt(e.state),r=pp(e.state),i=r!=pp(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!i&&n.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Se.none;let r=new vs;for(let{from:i,to:s}of e.visibleRanges)jZ(this.tree,n,(o,a,l)=>{r.add(o,a,this.markCache[l]||(this.markCache[l]=Se.mark({class:l})))},i,s);return r.finish()}}const uW=wi.high(Bt.fromClass(cW,{decorations:t=>t.decorations})),fW=Da.define([{tag:I.meta,color:"#404740"},{tag:I.link,textDecoration:"underline"},{tag:I.heading,textDecoration:"underline",fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strong,fontWeight:"bold"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.keyword,color:"#708"},{tag:[I.atom,I.bool,I.url,I.contentSeparator,I.labelName],color:"#219"},{tag:[I.literal,I.inserted],color:"#164"},{tag:[I.string,I.deleted],color:"#a11"},{tag:[I.regexp,I.escape,I.special(I.string)],color:"#e40"},{tag:I.definition(I.variableName),color:"#00f"},{tag:I.local(I.variableName),color:"#30a"},{tag:[I.typeName,I.namespace],color:"#085"},{tag:I.className,color:"#167"},{tag:[I.special(I.variableName),I.macroName],color:"#256"},{tag:I.definition(I.propertyName),color:"#00c"},{tag:I.comment,color:"#940"},{tag:I.invalid,color:"#f00"}]),dW=de.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),R2=1e4,j2="()[]{}",D2=me.define({combine(t){return ki(t,{afterCursor:!0,brackets:j2,maxScanDistance:R2,renderMatch:gW})}}),hW=Se.mark({class:"cm-matchingBracket"}),pW=Se.mark({class:"cm-nonmatchingBracket"});function gW(t){let e=[],n=t.matched?hW:pW;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}const mW=ln.define({create(){return Se.none},update(t,e){if(!e.docChanged&&!e.selection)return t;let n=[],r=e.state.facet(D2);for(let i of e.state.selection.ranges){if(!i.empty)continue;let s=ui(e.state,i.head,-1,r)||i.head>0&&ui(e.state,i.head-1,1,r)||r.afterCursor&&(ui(e.state,i.head,1,r)||i.head<e.state.doc.length&&ui(e.state,i.head+1,-1,r));s&&(n=n.concat(r.renderMatch(s,e.state)))}return Se.set(n,!0)},provide:t=>de.decorations.from(t)}),OW=[mW,dW];function vW(t={}){return[D2.of(t),OW]}const iv=new Ve;function nm(t,e,n){let r=t.prop(e<0?Ve.openedBy:Ve.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function rm(t){let e=t.type.prop(iv);return e?e(t.node):t}function ui(t,e,n,r={}){let i=r.maxScanDistance||R2,s=r.brackets||j2,o=Dt(t),a=o.resolveInner(e,n);for(let l=a;l;l=l.parent){let c=nm(l.type,n,s);if(c&&l.from<l.to){let u=rm(l);if(u&&(n>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return xW(t,e,n,l,u,c,s)}}return yW(t,e,n,o,a.type,i,s)}function xW(t,e,n,r,i,s,o){let a=r.parent,l={from:i.from,to:i.to},c=0,u=a==null?void 0:a.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(c==0&&s.indexOf(u.type.name)>-1&&u.from<u.to){let f=rm(u);return{start:l,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(nm(u.type,n,o))c++;else if(nm(u.type,-n,o)){if(c==0){let f=rm(u);return{start:l,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function yW(t,e,n,r,i,s,o){let a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(a);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?e-1:e,to:n>0?e+1:e},u=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let d=0;!u.next().done&&d<=s;){let h=u.value;n<0&&(d+=h.length);let p=e+d*n;for(let O=n>0?0:h.length-1,g=n>0?h.length:-1;O!=g;O+=n){let x=o.indexOf(h[O]);if(!(x<0||r.resolveInner(p+O,1).type!=i))if(x%2==0==n>0)f++;else{if(f==1)return{start:c,end:{from:p+O,to:p+O+1},matched:x>>1==l>>1};f--}}n>0&&(d+=h.length)}return u.done?{start:c,matched:!1}:null}const bW=Object.create(null),d1=[Vn.none],h1=[],p1=Object.create(null),SW=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])SW[t]=wW(bW,e);function gp(t,e){h1.indexOf(t)>-1||(h1.push(t),console.warn(e))}function wW(t,e){let n=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=t[c]||I[c];u?typeof u=="function"?l.length?l=l.map(u):gp(c,`Modifier ${c} used at start of tag`):l.length?gp(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:gp(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(a=>a.id),s=p1[i];if(s)return s.id;let o=p1[i]=Vn.define({id:d1.length,name:r,props:[$a({[r]:n})]});return d1.push(o),o.id}$t.RTL,$t.LTR;const CW=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=ov(t.state,n.from);return r.line?kW(t):r.block?PW(t):!1};function sv(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const kW=sv(TW,0),AW=sv(_2,0),PW=sv((t,e)=>_2(t,e,IW(e)),0);function ov(t,e){let n=t.languageDataAt("commentTokens",e);return n.length?n[0]:{}}const el=50;function EW(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-el,r),o=t.sliceDoc(i,i+el),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,c=s.length-a;if(s.slice(c-e.length,c)==e&&o.slice(l,l+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let u,f;i-r<=2*el?u=f=t.sliceDoc(r,i):(u=t.sliceDoc(r,r+el),f=t.sliceDoc(i-el,i));let d=/^\s*/.exec(u)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-n.length;return u.slice(d,d+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:i-h-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function IW(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to),s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function _2(t,e,n=e.selection.ranges){let r=n.map(s=>ov(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>EW(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,a;o<i.length;o++)if(a=i[o]){let l=r[o],{open:c,close:u}=a;s.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:s}}return null}function TW(t,e,n=e.selection.ranges){let r=[],i=-1;for(let{from:s,to:o}of n){let a=r.length,l=1e9,c=ov(e,s).line;if(c){for(let u=s;u<=o;){let f=e.doc.lineAt(u);if(f.from>i&&(s==o||o>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+c.length)==c?d:-1;d<f.text.length&&d<l&&(l=d),r.push({line:f,comment:p,token:c,indent:d,empty:h,single:!1})}u=f.to+1}if(l<1e9)for(let u=a;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=l);r.length==a+1&&(r[a].single=!0)}}if(t!=2&&r.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of r)(f||!u)&&s.push({from:a.from+c,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of r)if(a>=0){let c=o.from+a,u=c+l.length;o.text[u-o.from]==" "&&u++,s.push({from:c,to:u})}return{changes:s}}return null}const im=Ci.define(),$W=Ci.define(),RW=me.define(),B2=me.define({combine(t){return ki(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),Q2=ln.define({create(){return fi.empty},update(t,e){let n=e.state.facet(B2),r=e.annotation(im);if(r){let l=Hn.fromTransaction(e,r.selection),c=r.side,u=c==0?t.undone:t.done;return l?u=Lf(u,u.length,n.minDepth,l):u=F2(u,e.startState.selection),new fi(c==0?r.rest:u,c==0?u:r.rest)}let i=e.annotation($W);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Ut.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Hn.fromTransaction(e),o=e.annotation(Ut.time),a=e.annotation(Ut.userEvent);return s?t=t.addChanges(s,o,a,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,a,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new fi(t.done.map(Hn.fromJSON),t.undone.map(Hn.fromJSON))}});function jW(t={}){return[Q2,B2.of(t),de.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?N2:e.inputType=="historyRedo"?sm:null;return r?(e.preventDefault(),r(n)):!1}})]}function Ud(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(Q2,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const N2=Ud(0,!1),sm=Ud(1,!1),DW=Ud(0,!0),_W=Ud(1,!0);class Hn{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Hn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Hn(e.changes&&rn.fromJSON(e.changes),[],e.mapped&&gi.fromJSON(e.mapped),e.startSelection&&ie.fromJSON(e.startSelection),e.selectionsAfter.map(ie.fromJSON))}static fromTransaction(e,n){let r=Er;for(let i of e.startState.facet(RW)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Hn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,Er)}static selection(e){return new Hn(void 0,Er,void 0,void 0,e)}}function Lf(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function BW(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,a)=>{for(let l=0;l<n.length;){let c=n[l++],u=n[l++];a>=c&&o<=u&&(r=!0)}}),r}function QW(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function M2(t,e){return t.length?e.length?t.concat(e):t:e}const Er=[],NW=200;function F2(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-NW));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Lf(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Hn.selection([e])]}function MW(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function mp(t,e){if(!t.length)return t;let n=t.length,r=Er;for(;n;){let i=FW(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Hn.selection(r)]:Er}function FW(t,e,n){let r=M2(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):Er,n);if(!t.changes)return Hn.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Hn(i,Ne.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const ZW=/^(input\.type|delete)($|\.)/;class fi{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new fi(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!r||ZW.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,BW(a.changes,e.changes))||r=="input.type.compose")?o=Lf(o,o.length-1,i.minDepth,new Hn(e.changes.compose(a.changes),M2(e.effects,a.effects),a.mapped,a.startSelection,Er)):o=Lf(o,o.length,i.minDepth,e),new fi(o,Er,n,r)}addSelection(e,n,r,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Er;return s.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&QW(s[s.length-1],e)?this:new fi(F2(this.done,e),this.undone,n,r)}addMapping(e){return new fi(mp(this.done,e),mp(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,r){let i=e==0?this.done:this.undone;if(i.length==0)return null;let s=i[i.length-1],o=s.selectionsAfter[0]||n.selection;if(r&&s.selectionsAfter.length)return n.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:im.of({side:e,rest:MW(i),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?Er:i.slice(0,i.length-1);return s.mapped&&(a=mp(a,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:im.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}fi.empty=new fi(Er,Er);const WW=[{key:"Mod-z",run:N2,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:sm,preventDefault:!0},{linux:"Ctrl-Shift-z",run:sm,preventDefault:!0},{key:"Mod-u",run:DW,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:_W,preventDefault:!0}];function _a(t,e){return ie.create(t.ranges.map(e),t.mainIndex)}function Pi(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Xr({state:t,dispatch:e},n){let r=_a(t.selection,n);return r.eq(t.selection,!0)?!1:(e(Pi(t,r)),!0)}function Yd(t,e){return ie.cursor(e?t.to:t.from)}function Z2(t,e){return Xr(t,n=>n.empty?t.moveByChar(n,e):Yd(n,e))}function Dn(t){return t.textDirectionAt(t.state.selection.main.head)==$t.LTR}const W2=t=>Z2(t,!Dn(t)),L2=t=>Z2(t,Dn(t));function V2(t,e){return Xr(t,n=>n.empty?t.moveByGroup(n,e):Yd(n,e))}const LW=t=>V2(t,!Dn(t)),VW=t=>V2(t,Dn(t));function zW(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Hd(t,e,n){let r=Dt(t).resolveInner(e.head),i=n?Ve.closedBy:Ve.openedBy;for(let l=e.head;;){let c=n?r.childAfter(l):r.childBefore(l);if(!c)break;zW(t,c,i)?r=c:l=n?c.to:c.from}let s=r.type.prop(i),o,a;return s&&(o=n?ui(t,r.from,1):ui(t,r.to,-1))&&o.matched?a=n?o.end.to:o.end.from:a=n?r.to:r.from,ie.cursor(a,n?-1:1)}const XW=t=>Xr(t,e=>Hd(t.state,e,!Dn(t))),GW=t=>Xr(t,e=>Hd(t.state,e,Dn(t)));function z2(t,e){return Xr(t,n=>{if(!n.empty)return Yd(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const X2=t=>z2(t,!1),G2=t=>z2(t,!0);function q2(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0,i;if(e){for(let s of t.state.facet(de.scrollMargins)){let o=s(t);o!=null&&o.top&&(n=Math.max(o==null?void 0:o.top,n)),o!=null&&o.bottom&&(r=Math.max(o==null?void 0:o.bottom,r))}i=t.scrollDOM.clientHeight-n-r}else i=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,i-5)}}function U2(t,e){let n=q2(t),{state:r}=t,i=_a(r.selection,o=>o.empty?t.moveVertically(o,e,n.height):Yd(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,c=a.bottom-n.marginBottom;o&&o.top>l&&o.bottom<c&&(s=de.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-l}))}return t.dispatch(Pi(r,i),{effects:s}),!0}const g1=t=>U2(t,!1),om=t=>U2(t,!0);function Ts(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=ie.cursor(r.from+s))}return i}const qW=t=>Xr(t,e=>Ts(t,e,!0)),UW=t=>Xr(t,e=>Ts(t,e,!1)),YW=t=>Xr(t,e=>Ts(t,e,!Dn(t))),HW=t=>Xr(t,e=>Ts(t,e,Dn(t))),JW=t=>Xr(t,e=>ie.cursor(t.lineBlockAt(e.head).from,1)),KW=t=>Xr(t,e=>ie.cursor(t.lineBlockAt(e.head).to,-1));function e6(t,e,n){let r=!1,i=_a(t.selection,s=>{let o=ui(t,s.head,-1)||ui(t,s.head,1)||s.head>0&&ui(t,s.head-1,1)||s.head<t.doc.length&&ui(t,s.head+1,-1);if(!o||!o.end)return s;r=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return ie.cursor(a)});return r?(e(Pi(t,i)),!0):!1}const t6=({state:t,dispatch:e})=>e6(t,e);function Dr(t,e){let n=_a(t.state.selection,r=>{let i=e(r);return ie.range(r.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return n.eq(t.state.selection)?!1:(t.dispatch(Pi(t.state,n)),!0)}function Y2(t,e){return Dr(t,n=>t.moveByChar(n,e))}const H2=t=>Y2(t,!Dn(t)),J2=t=>Y2(t,Dn(t));function K2(t,e){return Dr(t,n=>t.moveByGroup(n,e))}const n6=t=>K2(t,!Dn(t)),r6=t=>K2(t,Dn(t)),i6=t=>Dr(t,e=>Hd(t.state,e,!Dn(t))),s6=t=>Dr(t,e=>Hd(t.state,e,Dn(t)));function eI(t,e){return Dr(t,n=>t.moveVertically(n,e))}const tI=t=>eI(t,!1),nI=t=>eI(t,!0);function rI(t,e){return Dr(t,n=>t.moveVertically(n,e,q2(t).height))}const m1=t=>rI(t,!1),O1=t=>rI(t,!0),o6=t=>Dr(t,e=>Ts(t,e,!0)),a6=t=>Dr(t,e=>Ts(t,e,!1)),l6=t=>Dr(t,e=>Ts(t,e,!Dn(t))),c6=t=>Dr(t,e=>Ts(t,e,Dn(t))),u6=t=>Dr(t,e=>ie.cursor(t.lineBlockAt(e.head).from)),f6=t=>Dr(t,e=>ie.cursor(t.lineBlockAt(e.head).to)),v1=({state:t,dispatch:e})=>(e(Pi(t,{anchor:0})),!0),x1=({state:t,dispatch:e})=>(e(Pi(t,{anchor:t.doc.length})),!0),y1=({state:t,dispatch:e})=>(e(Pi(t,{anchor:t.selection.main.anchor,head:0})),!0),b1=({state:t,dispatch:e})=>(e(Pi(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),d6=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),h6=({state:t,dispatch:e})=>{let n=Jd(t).map(({from:r,to:i})=>ie.range(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:ie.create(n),userEvent:"select"})),!0},p6=({state:t,dispatch:e})=>{let n=_a(t.selection,r=>{var i;let s=Dt(t).resolveStack(r.from,1);for(let o=s;o;o=o.next){let{node:a}=o;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&(!((i=a.parent)===null||i===void 0)&&i.parent))return ie.range(a.to,a.from)}return r});return e(Pi(t,n)),!0},g6=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ie.create([n.main]):n.main.empty||(r=ie.create([ie.cursor(n.main.head)])),r?(e(Pi(t,r)),!0):!1};function yc(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);l<o?(n="delete.backward",l=yu(t,l,!1)):l>o&&(n="delete.forward",l=yu(t,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=yu(t,o,!1),a=yu(t,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:ie.cursor(o,o<s.head?-1:1)}});return i.changes.empty?!1:(t.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?de.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function yu(t,e,n){if(t instanceof de)for(let r of t.state.facet(de.atomicRanges).map(i=>i(t)))r.between(e,e,(i,s)=>{i<e&&s>e&&(e=n?s:i)});return e}const iI=(t,e)=>yc(t,n=>{let r=n.from,{state:i}=t,s=i.doc.lineAt(r),o,a;if(!e&&r>s.from&&r<s.from+200&&!/[^ \t]/.test(o=s.text.slice(0,r-s.from))){if(o[o.length-1]==" ")return r-1;let l=Ia(o,i.tabSize),c=l%Ff(i)||Ff(i);for(let u=0;u<c&&o[o.length-1-u]==" ";u++)r--;a=r}else a=kn(s.text,r-s.from,e,e)+s.from,a==r&&s.number!=(e?i.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(a-s.from,r-s.from))&&(a=kn(s.text,a-s.from,!1,!1)+s.from);return a}),am=t=>iI(t,!1),sI=t=>iI(t,!0),oI=(t,e)=>yc(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let a=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let l=kn(s.text,r-s.from,e)+s.from,c=s.text.slice(Math.min(r,l)-s.from,Math.max(r,l)-s.from),u=o(c);if(a!=null&&u!=a)break;(c!=" "||r!=n.head)&&(a=u),r=l}return r}),aI=t=>oI(t,!1),m6=t=>oI(t,!0),O6=t=>yc(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),v6=t=>yc(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),x6=t=>yc(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),y6=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ot.of(["",""])},range:ie.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},b6=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:kn(s.text,i-s.from,!1)+s.from,a=i==s.to?i+1:kn(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(o,i))},range:ie.cursor(a)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Jd(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function lI(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Jd(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),a=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let l of s.ranges)i.push(ie.range(Math.min(t.doc.length,l.anchor+a),Math.min(t.doc.length,l.head+a)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let l of s.ranges)i.push(ie.range(l.anchor-a,l.head-a))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ie.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const S6=({state:t,dispatch:e})=>lI(t,e,!1),w6=({state:t,dispatch:e})=>lI(t,e,!0);function cI(t,e,n){if(t.readOnly)return!1;let r=[];for(let i of Jd(t))n?r.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):r.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});return e(t.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const C6=({state:t,dispatch:e})=>cI(t,e,!1),k6=({state:t,dispatch:e})=>cI(t,e,!0),A6=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Jd(e).map(({from:i,to:s})=>(i>0?i--:s<e.doc.length&&s++,{from:i,to:s}))),r=_a(e.selection,i=>t.moveVertically(i,!0)).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function P6(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Dt(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(Ve.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const E6=uI(!1),I6=uI(!0);function uI(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,a=e.doc.lineAt(s),l=!t&&s==o&&P6(e,s);t&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new Gd(e,{simulateBreak:s,simulateDoubleBreak:!!l}),u=ev(c,s);for(u==null&&(u=Ia(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:s,to:o}=l:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let f=["",ql(e,u)];return l&&f.push(ql(e,c.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:ot.of(f)},range:ie.cursor(s+1+f[1].length)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function av(t,e){let n=-1;return t.changeByRange(r=>{let i=[];for(let o=r.from;o<=r.to;){let a=t.doc.lineAt(o);a.number>n&&(r.empty||r.to>a.from)&&(e(a,i,r),n=a.number),o=a.to+1}let s=t.changes(i);return{changes:i,range:ie.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const T6=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Gd(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=av(t,(s,o,a)=>{let l=ev(r,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=ql(t,l);(c!=u||a.from<s.from+c.length)&&(n[s.from]=l,o.push({from:s.from,to:s.from+c.length,insert:u}))});return i.changes.empty||e(t.update(i,{userEvent:"indent"})),!0},fI=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(av(t,(n,r)=>{r.push({from:n.from,insert:t.facet(vc)})}),{userEvent:"input.indent"})),!0),dI=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(av(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Ia(i,t.tabSize),o=0,a=ql(t,Math.max(0,s-Ff(t)));for(;o<i.length&&o<a.length&&i.charCodeAt(o)==a.charCodeAt(o);)o++;r.push({from:n.from+o,to:n.from+i.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),$6=[{key:"Ctrl-b",run:W2,shift:H2,preventDefault:!0},{key:"Ctrl-f",run:L2,shift:J2},{key:"Ctrl-p",run:X2,shift:tI},{key:"Ctrl-n",run:G2,shift:nI},{key:"Ctrl-a",run:JW,shift:u6},{key:"Ctrl-e",run:KW,shift:f6},{key:"Ctrl-d",run:sI},{key:"Ctrl-h",run:am},{key:"Ctrl-k",run:O6},{key:"Ctrl-Alt-h",run:aI},{key:"Ctrl-o",run:y6},{key:"Ctrl-t",run:b6},{key:"Ctrl-v",run:om}],R6=[{key:"ArrowLeft",run:W2,shift:H2,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:LW,shift:n6,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:YW,shift:l6,preventDefault:!0},{key:"ArrowRight",run:L2,shift:J2,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:VW,shift:r6,preventDefault:!0},{mac:"Cmd-ArrowRight",run:HW,shift:c6,preventDefault:!0},{key:"ArrowUp",run:X2,shift:tI,preventDefault:!0},{mac:"Cmd-ArrowUp",run:v1,shift:y1},{mac:"Ctrl-ArrowUp",run:g1,shift:m1},{key:"ArrowDown",run:G2,shift:nI,preventDefault:!0},{mac:"Cmd-ArrowDown",run:x1,shift:b1},{mac:"Ctrl-ArrowDown",run:om,shift:O1},{key:"PageUp",run:g1,shift:m1},{key:"PageDown",run:om,shift:O1},{key:"Home",run:UW,shift:a6,preventDefault:!0},{key:"Mod-Home",run:v1,shift:y1},{key:"End",run:qW,shift:o6,preventDefault:!0},{key:"Mod-End",run:x1,shift:b1},{key:"Enter",run:E6},{key:"Mod-a",run:d6},{key:"Backspace",run:am,shift:am},{key:"Delete",run:sI},{key:"Mod-Backspace",mac:"Alt-Backspace",run:aI},{key:"Mod-Delete",mac:"Alt-Delete",run:m6},{mac:"Mod-Backspace",run:v6},{mac:"Mod-Delete",run:x6}].concat($6.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),j6=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:XW,shift:i6},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:GW,shift:s6},{key:"Alt-ArrowUp",run:S6},{key:"Shift-Alt-ArrowUp",run:C6},{key:"Alt-ArrowDown",run:w6},{key:"Shift-Alt-ArrowDown",run:k6},{key:"Escape",run:g6},{key:"Mod-Enter",run:I6},{key:"Alt-l",mac:"Ctrl-l",run:h6},{key:"Mod-i",run:p6,preventDefault:!0},{key:"Mod-[",run:dI},{key:"Mod-]",run:fI},{key:"Mod-Alt-\\",run:T6},{key:"Shift-Mod-k",run:A6},{key:"Shift-Mod-\\",run:t6},{key:"Mod-/",run:CW},{key:"Alt-A",run:AW}].concat(R6),D6={key:"Tab",run:fI,shift:dI};function At(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e<arguments.length;e++)hI(t,arguments[e]);return t}function hI(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var n=0;n<e.length;n++)hI(t,e[n]);else throw new RangeError("Unsupported child node: "+e)}const S1=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class fa{constructor(e,n,r=0,i=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=s?a=>s(S1(a)):S1,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return bn(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let n=QO(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=Ar(e);let i=this.normalize(n);for(let s=0,o=r;;s++){let a=i.charCodeAt(s),l=this.match(a,o,this.bufferPos+this.bufferStart);if(s==i.length-1){if(l)return this.value=l,this;break}o==r&&s<n.length&&n.charCodeAt(s)==a&&o++}}}match(e,n,r){let i=null;for(let s=0;s<this.matches.length;s+=2){let o=this.matches[s],a=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?i={from:this.matches[s+1],to:r}:(this.matches[s]++,a=!0)),a||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:n,to:r}:this.matches.push(1,n)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(fa.prototype[Symbol.iterator]=function(){return this});const pI={from:-1,to:-1,match:/.*/.exec("")},lv="gm"+(/x/.unicode==null?"":"u");class gI{constructor(e,n,r,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=pI,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new mI(e,n,r,i,s);this.re=new RegExp(n,lv+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=Vf(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,i=r+n[0].length;if(this.matchPos=Vf(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,match:n},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Op=new WeakMap;class Yo{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let i=Op.get(e);if(!i||i.from>=r||i.to<=n){let a=new Yo(n,e.sliceString(n,r));return Op.set(e,a),a}if(i.from==n&&i.to==r)return i;let{text:s,from:o}=i;return o>n&&(s=e.sliceString(n,o)+s,o=n),i.to<r&&(s+=e.sliceString(i.to,r)),Op.set(e,new Yo(o,s)),new Yo(n,s.slice(n-o,r-o))}}class mI{constructor(e,n,r,i,s){this.text=e,this.to=s,this.done=!1,this.value=pI,this.matchPos=Vf(e,i),this.re=new RegExp(n,lv+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.flat=Yo.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,i=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,i,n)))return this.value={from:r,to:i,match:n},this.matchPos=Vf(this.text,i+(r==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Yo.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(gI.prototype[Symbol.iterator]=mI.prototype[Symbol.iterator]=function(){return this});function _6(t){try{return new RegExp(t,lv),!0}catch{return!1}}function Vf(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}function lm(t){let e=String(t.state.doc.lineAt(t.state.selection.main.head).number),n=At("input",{class:"cm-textfield",name:"line",value:e}),r=At("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),t.dispatch({effects:zf.of(!1)}),t.focus()):s.keyCode==13&&(s.preventDefault(),i())},onsubmit:s=>{s.preventDefault(),i()}},At("label",t.state.phrase("Go to line"),": ",n)," ",At("button",{class:"cm-button",type:"submit"},t.state.phrase("go")));function i(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!s)return;let{state:o}=t,a=o.doc.lineAt(o.selection.main.head),[,l,c,u,f]=s,d=u?+u.slice(1):0,h=c?+c:a.number;if(c&&f){let g=h/100;l&&(g=g*(l=="-"?-1:1)+a.number/o.doc.lines),h=Math.round(o.doc.lines*g)}else c&&l&&(h=h*(l=="-"?-1:1)+a.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,h))),O=ie.cursor(p.from+Math.max(0,Math.min(d,p.length)));t.dispatch({effects:[zf.of(!1),de.scrollIntoView(O.from,{y:"center"})],selection:O}),t.focus()}return{dom:r}}const zf=Ne.define(),w1=ln.define({create(){return!0},update(t,e){for(let n of e.effects)n.is(zf)&&(t=n.value);return t},provide:t=>zl.from(t,e=>e?lm:null)}),B6=t=>{let e=Vl(t,lm);if(!e){let n=[zf.of(!0)];t.state.field(w1,!1)==null&&n.push(Ne.appendConfig.of([w1,Q6])),t.dispatch({effects:n}),e=Vl(t,lm)}return e&&e.dom.querySelector("input").select(),!0},Q6=de.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),N6={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},M6=me.define({combine(t){return ki(t,N6,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function F6(t){return[z6,V6]}const Z6=Se.mark({class:"cm-selectionMatch"}),W6=Se.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function C1(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=jt.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=jt.Word)}function L6(t,e,n,r){return t(e.sliceDoc(n,n+1))==jt.Word&&t(e.sliceDoc(r-1,r))==jt.Word}const V6=Bt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(M6),{state:n}=t,r=n.selection;if(r.ranges.length>1)return Se.none;let i=r.main,s,o=null;if(i.empty){if(!e.highlightWordAroundCursor)return Se.none;let l=n.wordAt(i.head);if(!l)return Se.none;o=n.charCategorizer(i.head),s=n.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<e.minSelectionLength||l>200)return Se.none;if(e.wholeWords){if(s=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(C1(o,n,i.from,i.to)&&L6(o,n,i.from,i.to)))return Se.none}else if(s=n.sliceDoc(i.from,i.to),!s)return Se.none}let a=[];for(let l of t.visibleRanges){let c=new fa(n.doc,s,l.from,l.to);for(;!c.next().done;){let{from:u,to:f}=c.value;if((!o||C1(o,n,u,f))&&(i.empty&&u<=i.from&&f>=i.to?a.push(W6.range(u,f)):(u>=i.to||f<=i.from)&&a.push(Z6.range(u,f)),a.length>e.maxMatches))return Se.none}}return Se.set(a)}},{decorations:t=>t.decorations}),z6=de.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),X6=({state:t,dispatch:e})=>{let{selection:n}=t,r=ie.create(n.ranges.map(i=>t.wordAt(i.head)||ie.cursor(i.head)),n.mainIndex);return r.eq(n)?!1:(e(t.update({selection:r})),!0)};function G6(t,e){let{main:n,ranges:r}=t.selection,i=t.wordAt(n.head),s=i&&i.from==n.from&&i.to==n.to;for(let o=!1,a=new fa(t.doc,e,r[r.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new fa(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),o=!0}else{if(o&&r.some(l=>l.from==a.value.from))continue;if(s){let l=t.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const q6=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return X6({state:t,dispatch:e});let r=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=r))return!1;let i=G6(t,r);return i?(e(t.update({selection:t.selection.addRange(ie.range(i.from,i.to),!1),effects:de.scrollIntoView(i.to)})),!0):!1},Ba=me.define({combine(t){return ki(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new oL(e),scrollToMatch:e=>de.scrollIntoView(e)})}});class OI{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||_6(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
|
|
677
|
-
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new J6(this):new Y6(this)}getCursor(e,n=0,r){let i=e.doc?e:Ye.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?Io(this,i,n,r):Eo(this,i,n,r)}}class vI{constructor(e){this.spec=e}}function Eo(t,e,n,r){return new fa(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:i=>i.toLowerCase(),t.wholeWord?U6(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function U6(t,e){return(n,r,i,s)=>((s>n||s+i.length<r)&&(s=Math.max(0,n-2),i=t.sliceString(s,Math.min(t.length,r+2))),(e(Xf(i,n-s))!=jt.Word||e(Gf(i,n-s))!=jt.Word)&&(e(Gf(i,r-s))!=jt.Word||e(Xf(i,r-s))!=jt.Word))}class Y6 extends vI{constructor(e){super(e)}nextMatch(e,n,r){let i=Eo(this.spec,e,r,e.doc.length).nextOverlapping();return i.done&&(i=Eo(this.spec,e,0,n).nextOverlapping()),i.done?null:i.value}prevMatchInRange(e,n,r){for(let i=r;;){let s=Math.max(n,i-1e4-this.spec.unquoted.length),o=Eo(this.spec,e,s,i),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(s==n)return null;i-=1e4}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=Eo(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=Eo(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function Io(t,e,n,r){return new gI(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?H6(e.charCategorizer(e.selection.main.head)):void 0},n,r)}function Xf(t,e){return t.slice(kn(t,e,!1),e)}function Gf(t,e){return t.slice(e,kn(t,e))}function H6(t){return(e,n,r)=>!r[0].length||(t(Xf(r.input,r.index))!=jt.Word||t(Gf(r.input,r.index))!=jt.Word)&&(t(Gf(r.input,r.index+r[0].length))!=jt.Word||t(Xf(r.input,r.index+r[0].length))!=jt.Word)}class J6 extends vI{nextMatch(e,n,r){let i=Io(this.spec,e,r,e.doc.length).next();return i.done&&(i=Io(this.spec,e,0,n).next()),i.done?null:i.value}prevMatchInRange(e,n,r){for(let i=1;;i++){let s=Math.max(n,r-i*1e4),o=Io(this.spec,e,s,r),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==n||a.from>s+10))return a;if(s==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(n,r)=>r=="$"?"$":r=="&"?e.match[0]:r!="0"&&+r<e.match.length?e.match[r]:n)}matchAll(e,n){let r=Io(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=Io(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const Ul=Ne.define(),cv=Ne.define(),ps=ln.define({create(t){return new vp(cm(t).create(),null)},update(t,e){for(let n of e.effects)n.is(Ul)?t=new vp(n.value.create(),t.panel):n.is(cv)&&(t=new vp(t.query,n.value?uv:null));return t},provide:t=>zl.from(t,e=>e.panel)});class vp{constructor(e,n){this.query=e,this.panel=n}}const K6=Se.mark({class:"cm-searchMatch"}),eL=Se.mark({class:"cm-searchMatch cm-searchMatch-selected"}),tL=Bt.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(ps))}update(t){let e=t.state.field(ps);(e!=t.startState.field(ps)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Se.none;let{view:n}=this,r=new vs;for(let i=0,s=n.visibleRanges,o=s.length;i<o;i++){let{from:a,to:l}=s[i];for(;i<o-1&&l>s[i+1].from-2*250;)l=s[++i].to;t.highlight(n.state,a,l,(c,u)=>{let f=n.state.selection.ranges.some(d=>d.from==c&&d.to==u);r.add(c,u,f?eL:K6)})}return r.finish()}},{decorations:t=>t.decorations});function bc(t){return e=>{let n=e.state.field(ps,!1);return n&&n.query.spec.valid?t(e,n):bI(e)}}const qf=bc((t,{query:e})=>{let{to:n}=t.state.selection.main,r=e.nextMatch(t.state,n,n);if(!r)return!1;let i=ie.single(r.from,r.to),s=t.state.facet(Ba);return t.dispatch({selection:i,effects:[fv(t,r),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),yI(t),!0}),Uf=bc((t,{query:e})=>{let{state:n}=t,{from:r}=n.selection.main,i=e.prevMatch(n,r,r);if(!i)return!1;let s=ie.single(i.from,i.to),o=t.state.facet(Ba);return t.dispatch({selection:s,effects:[fv(t,i),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),yI(t),!0}),nL=bc((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:ie.create(n.map(r=>ie.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),rL=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,s=[],o=0;for(let a=new fa(t.doc,t.sliceDoc(r,i));!a.next().done;){if(s.length>1e3)return!1;a.value.from==r&&(o=s.length),s.push(ie.range(a.value.from,a.value.to))}return e(t.update({selection:ie.create(s,o),userEvent:"select.search.matches"})),!0},k1=bc((t,{query:e})=>{let{state:n}=t,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,r,r);if(!s)return!1;let o=[],a,l,c=[];if(s.from==r&&s.to==i&&(l=n.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:l}),s=e.nextMatch(n,s.from,s.to),c.push(de.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))),s){let u=o.length==0||o[0].from>=s.to?0:s.to-s.from-l.length;a=ie.single(s.from-u,s.to-u),c.push(fv(t,s)),c.push(n.facet(Ba).scrollToMatch(a.main,t))}return t.dispatch({changes:o,selection:a,effects:c,userEvent:"input.replace"}),!0}),iL=bc((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(i=>{let{from:s,to:o}=i;return{from:s,to:o,insert:e.getReplacement(i)}});if(!n.length)return!1;let r=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:de.announce.of(r),userEvent:"input.replace.all"}),!0});function uv(t){return t.state.facet(Ba).createPanel(t)}function cm(t,e){var n,r,i,s,o;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=t.facet(Ba);return new OI({search:((n=e==null?void 0:e.literal)!==null&&n!==void 0?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e==null?void 0:e.caseSensitive)!==null&&r!==void 0?r:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function xI(t){let e=Vl(t,uv);return e&&e.dom.querySelector("[main-field]")}function yI(t){let e=xI(t);e&&e==t.root.activeElement&&e.select()}const bI=t=>{let e=t.state.field(ps,!1);if(e&&e.panel){let n=xI(t);if(n&&n!=t.root.activeElement){let r=cm(t.state,e.query.spec);r.valid&&t.dispatch({effects:Ul.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[cv.of(!0),e?Ul.of(cm(t.state,e.query.spec)):Ne.appendConfig.of(lL)]});return!0},SI=t=>{let e=t.state.field(ps,!1);if(!e||!e.panel)return!1;let n=Vl(t,uv);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:cv.of(!1)}),!0},sL=[{key:"Mod-f",run:bI,scope:"editor search-panel"},{key:"F3",run:qf,shift:Uf,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:qf,shift:Uf,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:SI,scope:"editor search-panel"},{key:"Mod-Shift-l",run:rL},{key:"Mod-Alt-g",run:B6},{key:"Mod-d",run:q6,preventDefault:!0}];class oL{constructor(e){this.view=e;let n=this.query=e.state.field(ps).query.spec;this.commit=this.commit.bind(this),this.searchField=At("input",{value:n.search,placeholder:sr(e,"Find"),"aria-label":sr(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=At("input",{value:n.replace,placeholder:sr(e,"Replace"),"aria-label":sr(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=At("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=At("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=At("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(i,s,o){return At("button",{class:"cm-button",name:i,onclick:s,type:"button"},o)}this.dom=At("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>qf(e),[sr(e,"next")]),r("prev",()=>Uf(e),[sr(e,"previous")]),r("select",()=>nL(e),[sr(e,"all")]),At("label",null,[this.caseField,sr(e,"match case")]),At("label",null,[this.reField,sr(e,"regexp")]),At("label",null,[this.wordField,sr(e,"by word")]),...e.state.readOnly?[]:[At("br"),this.replaceField,r("replace",()=>k1(e),[sr(e,"replace")]),r("replaceAll",()=>iL(e),[sr(e,"replace all")])],At("button",{name:"close",onclick:()=>SI(e),"aria-label":sr(e,"close"),type:"button"},["×"])])}commit(){let e=new OI({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Ul.of(e)}))}keydown(e){p8(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Uf:qf)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),k1(this.view))}update(e){for(let n of e.transactions)for(let r of n.effects)r.is(Ul)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Ba).top}}function sr(t,e){return t.state.phrase(e)}const bu=30,Su=/[\s\.,:;?!]/;function fv(t,{from:e,to:n}){let r=t.state.doc.lineAt(e),i=t.state.doc.lineAt(n).to,s=Math.max(r.from,e-bu),o=Math.min(i,n+bu),a=t.state.sliceDoc(s,o);if(s!=r.from){for(let l=0;l<bu;l++)if(!Su.test(a[l+1])&&Su.test(a[l])){a=a.slice(l);break}}if(o!=i){for(let l=a.length-1;l>a.length-bu;l--)if(!Su.test(a[l-1])&&Su.test(a[l])){a=a.slice(0,l);break}}return de.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${r.number}.`)}const aL=de.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),lL=[ps,wi.low(tL),aL];class wI{constructor(e,n,r){this.state=e,this.pos=n,this.explicit=r,this.abortListeners=[]}tokenBefore(e){let n=Dt(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),s=i.search(kI(e,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n){e=="abort"&&this.abortListeners&&this.abortListeners.push(n)}}function A1(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function cL(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let s=1;s<i.length;s++)n[i[s]]=!0}let r=A1(e)+A1(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function CI(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[n,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:cL(e);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:e,validFor:n}:null}}function uL(t,e){return n=>{for(let r=Dt(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(t.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(n)}}class P1{constructor(e,n,r,i){this.completion=e,this.source=n,this.match=r,this.score=i}}function gs(t){return t.selection.main.from}function kI(t,e){var n;let{source:r}=t,i=e&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?t:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const dv=Ci.define();function fL(t,e,n,r){let{main:i}=t.selection,s=n-i.from,o=r-i.from;return Object.assign(Object.assign({},t.changeByRange(a=>a!=i&&n!=r&&t.sliceDoc(a.from+s,a.from+o)!=t.sliceDoc(n,r)?{range:a}:{changes:{from:a.from+s,to:r==i.from?a.to:a.from+o,insert:e},range:ie.cursor(a.from+s+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const E1=new WeakMap;function dL(t){if(!Array.isArray(t))return t;let e=E1.get(t);return e||E1.set(t,e=CI(t)),e}const Yf=Ne.define(),Yl=Ne.define();class hL{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let r=bn(e,n),i=Ar(r);this.chars.push(r);let s=e.slice(n,n+i),o=s.toUpperCase();this.folded.push(bn(o==s?s.toLowerCase():o,0)),n+=i}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:s,byWord:o}=this;if(n.length==1){let v=bn(e,0),y=Ar(v),b=y==e.length?0:-100;if(v!=n[0])if(v==r[0])b+=-200;else return null;return this.ret(b,[0,y])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(a<0){for(let v=0,y=Math.min(e.length,200);v<y&&c<l;){let b=bn(e,v);(b==n[c]||b==r[c])&&(i[c++]=v),v+=Ar(b)}if(c<l)return null}let u=0,f=0,d=!1,h=0,p=-1,O=-1,g=/[a-z]/.test(e),x=!0;for(let v=0,y=Math.min(e.length,200),b=0;v<y&&f<l;){let S=bn(e,v);a<0&&(u<l&&S==n[u]&&(s[u++]=v),h<l&&(S==n[h]||S==r[h]?(h==0&&(p=v),O=v+1,h++):h=0));let w,C=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(w=QO(S))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||C==1&&g||b==0&&C!=0)&&(n[f]==S||r[f]==S&&(d=!0)?o[f++]=v:o.length&&(x=!1)),b=C,v+=Ar(S)}return f==l&&o[0]==0&&x?this.result(-100+(d?-200:0),o,e):h==l&&p==0?this.ret(-200-e.length+(O==e.length?0:-100),[0,O]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):h==l?this.ret(-900-e.length,[p,O]):f==l?this.result(-100+(d?-200:0)+-700+(x?0:-1100),o,e):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,n,r){let i=[],s=0;for(let o of n){let a=o+(this.astral?Ar(bn(r,o)):1);s&&i[s-1]==o?i[s-1]=a:(i[s++]=o,i[s++]=a)}return this.ret(e-r.length,i)}}class pL{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const Cn=me.define({combine(t){return ki(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:gL,filterStrict:!1,compareCompletions:(e,n)=>e.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>r=>I1(e(r),n(r)),optionClass:(e,n)=>r=>I1(e(r),n(r)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function I1(t,e){return t?e?t+" "+e:t:e}function gL(t,e,n,r,i,s){let o=t.textDirection==$t.RTL,a=o,l=!1,c="top",u,f,d=e.left-i.left,h=i.right-e.right,p=r.right-r.left,O=r.bottom-r.top;if(a&&d<Math.min(p,h)?a=!1:!a&&h<Math.min(p,d)&&(a=!0),p<=(a?d:h))u=Math.max(i.top,Math.min(n.top,i.bottom-O))-e.top,f=Math.min(400,a?d:h);else{l=!0,f=Math.min(400,(o?e.right:i.right-e.left)-30);let v=i.bottom-e.bottom;v>=O||v>e.top?u=n.bottom-e.top:(c="bottom",u=e.bottom-n.top)}let g=(e.bottom-e.top)/s.offsetHeight,x=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${f/x}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}function mL(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(n,r,i,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=n.displayLabel||n.label,l=0;for(let c=0;c<s.length;){let u=s[c++],f=s[c++];u>l&&o.appendChild(document.createTextNode(a.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(a.slice(u,f))),d.className="cm-completionMatchedText",l=f}return l<a.length&&o.appendChild(document.createTextNode(a.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),e.sort((n,r)=>n.position-r.position).map(n=>n.render)}function xp(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let i=Math.floor(e/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((t-e)/n);return{from:t-(r+1)*n,to:t-r*n}}class OL{constructor(e,n,r){this.view=e,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(n),{options:s,selected:o}=i.open,a=e.state.facet(Cn);this.optionContent=mL(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=xp(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(n).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Cn).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Yl.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let r=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=i){let{options:s,selected:o,disabled:a}=r.open;(!i.open||i.open.options!=s)&&(this.range=xp(s.length,o,e.state.facet(Cn).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),a!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=xp(n.options.length,n.selected,this.view.state.facet(Cn).maxRenderedOptions),this.showOptions(n.options,e.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let s=typeof i=="string"?document.createTextNode(i):i(r);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,r)}).catch(o=>Zn(this.view.state,o,"completion info")):this.addInfoPane(s,r)}}addInfoPane(e,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:s}=e;r.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&xL(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(Cn).positionInfo(this.view,n,i,r,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions"));let s=null;for(let o=r.from;o<r.to;o++){let{completion:a,match:l}=e[o],{section:c}=a;if(c){let d=typeof c=="string"?c:c.name;if(d!=s&&(o>r.from||r.from==0))if(s=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let h=i.appendChild(document.createElement("completion-section"));h.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let d of this.optionContent){let h=d(a,this.view.state,this.view,l);h&&u.appendChild(h)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function vL(t,e){return n=>new OL(n,t,e)}function xL(t,e){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=n.height/t.offsetHeight;r.top<n.top?t.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(t.scrollTop+=(r.bottom-n.bottom)/i)}function T1(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function yL(t,e){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let f=typeof u=="string"?u:u.name;r.some(d=>d.name==f)||r.push(typeof u=="string"?{name:f}:u)}},s=e.facet(Cn);for(let c of t)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)i(new P1(f,c.source,u?u(f):[],1e9-n.length));else{let f=e.sliceDoc(c.from,c.to),d,h=s.filterStrict?new pL(f):new hL(f);for(let p of c.result.options)if(d=h.match(p.label)){let O=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new P1(p,c.source,O,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,f=(d,h)=>{var p,O;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((O=h.rank)!==null&&O!==void 0?O:1e9)||(d.name<h.name?-1:1)};for(let d of r.sort(f))u-=1e5,c[d.name]=u;for(let d of n){let{section:h}=d.completion;h&&(d.score+=c[typeof h=="string"?h:h.name])}}let o=[],a=null,l=s.compareCompletions;for(let c of n.sort((u,f)=>f.score-u.score||l(u.completion,f.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?o.push(c):T1(c.completion)>T1(a)&&(o[o.length-1]=c),a=c.completion}return o}class Bo{constructor(e,n,r,i,s,o){this.options=e,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new Bo(this.options,$1(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,r,i,s){let o=yL(e,n);if(!o.length)return i&&e.some(l=>l.state==1)?new Bo(i.options,i.attrs,i.tooltip,i.timestamp,i.selected,!0):null;let a=n.facet(Cn).selectOnOpen?0:-1;if(i&&i.selected!=a&&i.selected!=-1){let l=i.options[i.selected].completion;for(let c=0;c<o.length;c++)if(o[c].completion==l){a=c;break}}return new Bo(o,$1(r,a),{pos:e.reduce((l,c)=>c.hasResult()?Math.min(l,c.from):l,1e8),create:kL,above:s.aboveCursor},i?i.timestamp:Date.now(),a,!1)}map(e){return new Bo(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Hf{constructor(e,n,r){this.active=e,this.id=n,this.open=r}static start(){return new Hf(wL,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,r=n.facet(Cn),s=(r.override||n.languageDataAt("autocomplete",gs(n)).map(dL)).map(a=>(this.active.find(c=>c.source==a)||new Mn(a,this.active.some(c=>c.state!=0)?1:0)).update(e,r));s.length==this.active.length&&s.every((a,l)=>a==this.active[l])&&(s=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!bL(s,this.active)?o=Bo.build(s,n,this.id,o,r):o&&o.disabled&&!s.some(a=>a.state==1)&&(o=null),!o&&s.every(a=>a.state!=1)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new Mn(a.source,0):a));for(let a of e.effects)a.is(PI)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new Hf(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:SL}}function bL(t,e){if(t==e)return!0;for(let n=0,r=0;;){for(;n<t.length&&!t[n].hasResult;)n++;for(;r<e.length&&!e[r].hasResult;)r++;let i=n==t.length,s=r==e.length;if(i||s)return i==s;if(t[n++].result!=e[r++].result)return!1}}const SL={"aria-autocomplete":"list"};function $1(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const wL=[];function um(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(dv);if(n&&e.activateOnCompletion(n))return"input"}return t.isUserEvent("input.type")?"input":t.isUserEvent("delete.backward")?"delete":null}class Mn{constructor(e,n,r=-1){this.source=e,this.state=n,this.explicitPos=r}hasResult(){return!1}update(e,n){let r=um(e,n),i=this;r?i=i.handleUserEvent(e,r,n):e.docChanged?i=i.handleChange(e):e.selection&&i.state!=0&&(i=new Mn(i.source,0));for(let s of e.effects)if(s.is(Yf))i=new Mn(i.source,1,s.value?gs(e.state):-1);else if(s.is(Yl))i=new Mn(i.source,0);else if(s.is(AI))for(let o of s.value)o.source==i.source&&(i=o);return i}handleUserEvent(e,n,r){return n=="delete"||!r.activateOnTyping?this.map(e.changes):new Mn(this.source,1)}handleChange(e){return e.changes.touchesRange(gs(e.startState))?new Mn(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Mn(this.source,this.state,e.mapPos(this.explicitPos))}}class Ho extends Mn{constructor(e,n,r,i,s){super(e,2,n),this.result=r,this.from=i,this.to=s}hasResult(){return!0}handleUserEvent(e,n,r){var i;let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let o=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),l=gs(e.state);if((this.explicitPos<0?l<=o:l<this.from)||l>a||!s||n=="delete"&&gs(e.startState)==this.from)return new Mn(this.source,n=="input"&&r.activateOnTyping?1:0);let c=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return CL(s.validFor,e.state,o,a)?new Ho(this.source,c,s,o,a):s.update&&(s=s.update(s,o,a,new wI(e.state,l,c>=0)))?new Ho(this.source,c,s,s.from,(i=s.to)!==null&&i!==void 0?i:gs(e.state)):new Mn(this.source,1,c)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Mn(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Ho(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Mn(this.source,0)}}function CL(t,e,n,r){if(!t)return!1;let i=e.sliceDoc(n,r);return typeof t=="function"?t(i,n,r,e):kI(t,!0).test(i)}const AI=Ne.define({map(t,e){return t.map(n=>n.map(e))}}),PI=Ne.define(),Yn=ln.define({create(){return Hf.start()},update(t,e){return t.update(e)},provide:t=>[qO.from(t,e=>e.tooltip),de.contentAttributes.from(t,e=>e.attrs)]});function hv(t,e){const n=e.completion.apply||e.completion.label;let r=t.state.field(Yn).active.find(i=>i.source==e.source);return r instanceof Ho?(typeof n=="string"?t.dispatch(Object.assign(Object.assign({},fL(t.state,n,r.from,r.to)),{annotations:dv.of(e.completion)})):n(t,e.completion,r.from,r.to),!0):!1}const kL=vL(Yn,hv);function wu(t,e="option"){return n=>{let r=n.state.field(Yn,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Cn).interactionDelay)return!1;let i=1,s;e=="page"&&(s=a2(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(t?1:-1):t?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),n.dispatch({effects:PI.of(a)}),!0}}const EI=t=>{let e=t.state.field(Yn,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Cn).interactionDelay?!1:hv(t,e.open.options[e.open.selected])},AL=t=>t.state.field(Yn,!1)?(t.dispatch({effects:Yf.of(!0)}),!0):!1,PL=t=>{let e=t.state.field(Yn,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Yl.of(null)}),!0)};class EL{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const IL=50,TL=1e3,$L=Bt.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Yn).active)e.state==1&&this.startQuery(e)}update(t){let e=t.state.field(Yn),n=t.state.facet(Cn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Yn)==e)return;let r=t.transactions.some(s=>(s.selection||s.docChanged)&&!um(s,n));for(let s=0;s<this.running.length;s++){let o=this.running[s];if(r||o.updates.length+t.transactions.length>IL&&Date.now()-o.time>TL){for(let a of o.context.abortListeners)try{a()}catch(l){Zn(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(Yf)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.state==1&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of t.transactions)um(s,n)=="input"?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Yn);for(let n of e.active)n.state==1&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n)}startQuery(t){let{state:e}=this.view,n=gs(e),r=new wI(e,n,t.explicitPos==n),i=new EL(t,r);this.running.push(i),Promise.resolve(t.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Yl.of(null)}),Zn(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Cn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(Cn);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let o=new Ho(i.active.source,i.active.explicitPos,i.done,i.done.from,(t=i.done.to)!==null&&t!==void 0?t:gs(i.updates.length?i.updates[0].startState:this.view.state));for(let a of i.updates)o=o.update(a,n);if(o.hasResult()){e.push(o);continue}}let s=this.view.state.field(Yn).active.find(o=>o.source==i.active.source);if(s&&s.state==1)if(i.done==null){let o=new Mn(i.active.source,0);for(let a of i.updates)o=o.update(a,n);o.state!=1&&e.push(o)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:AI.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Yn,!1);if(e&&e.tooltip&&this.view.state.facet(Cn).closeOnBlur){let n=e.open&&a2(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Yl.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Yf.of(!1)}),20),this.composing=0}}}),RL=typeof navigator=="object"&&/Win/.test(navigator.platform),jL=wi.highest(de.domEventHandlers({keydown(t,e){let n=e.state.field(Yn,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(RL&&t.altKey)||t.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&hv(e,r),!1}})),II=de.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"},".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 DL{constructor(e,n,r,i){this.field=e,this.line=n,this.from=r,this.to=i}}class pv{constructor(e,n,r){this.field=e,this.from=n,this.to=r}map(e){let n=e.mapPos(this.from,-1,wn.TrackDel),r=e.mapPos(this.to,1,wn.TrackDel);return n==null||r==null?null:new pv(this.field,n,r)}}class gv{constructor(e,n){this.lines=e,this.fieldPositions=n}instantiate(e,n){let r=[],i=[n],s=e.doc.lineAt(n),o=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let f=0;f<u;f++)c+=e.facet(vc);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let a=this.fieldPositions.map(l=>new pv(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:a}}static parse(e){let n=[],r=[],i=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let a=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1;for(let u=0;u<n.length;u++)(a!=null?n[u].seq==a:l&&n[u].name==l)&&(c=u);if(c<0){let u=0;for(;u<n.length&&(a==null||n[u].seq!=null&&n[u].seq<a);)u++;n.splice(u,0,{seq:a,name:l}),c=u;for(let f of i)f.field>=c&&f.field++}i.push(new DL(c,r.length,s.index,s.index+l.length)),o=o.slice(0,s.index)+l+o.slice(s.index+s[0].length)}for(let a;a=/\\([{}])/.exec(o);){o=o.slice(0,a.index)+a[1]+o.slice(a.index+a[0].length);for(let l of i)l.line==r.length&&l.from>a.index&&(l.from--,l.to--)}r.push(o)}return new gv(r,i)}}let _L=Se.widget({widget:new class extends Ai{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),BL=Se.mark({class:"cm-snippetField"});class Qa{constructor(e,n){this.ranges=e,this.active=n,this.deco=Se.set(e.map(r=>(r.from==r.to?_L:BL).range(r.from,r.to)))}map(e){let n=[];for(let r of this.ranges){let i=r.map(e);if(!i)return null;n.push(i)}return new Qa(n,this.active)}selectionInsideField(e){return e.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const Sc=Ne.define({map(t,e){return t&&t.map(e)}}),QL=Ne.define(),Hl=ln.define({create(){return null},update(t,e){for(let n of e.effects){if(n.is(Sc))return n.value;if(n.is(QL)&&t)return new Qa(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>de.decorations.from(t,e=>e?e.deco:Se.none)});function mv(t,e){return ie.create(t.filter(n=>n.field==e).map(n=>ie.range(n.from,n.to)))}function NL(t){let e=gv.parse(t);return(n,r,i,s)=>{let{text:o,ranges:a}=e.instantiate(n.state,i),l={changes:{from:i,to:s,insert:ot.of(o)},scrollIntoView:!0,annotations:r?[dv.of(r),Ut.userEvent.of("input.complete")]:void 0};if(a.length&&(l.selection=mv(a,0)),a.some(c=>c.field>0)){let c=new Qa(a,0),u=l.effects=[Sc.of(c)];n.state.field(Hl,!1)===void 0&&u.push(Ne.appendConfig.of([Hl,LL,VL,II]))}n.dispatch(n.state.update(l))}}function TI(t){return({state:e,dispatch:n})=>{let r=e.field(Hl,!1);if(!r||t<0&&r.active==0)return!1;let i=r.active+t,s=t>0&&!r.ranges.some(o=>o.field==i+t);return n(e.update({selection:mv(r.ranges,i),effects:Sc.of(s?null:new Qa(r.ranges,i)),scrollIntoView:!0})),!0}}const ML=({state:t,dispatch:e})=>t.field(Hl,!1)?(e(t.update({effects:Sc.of(null)})),!0):!1,FL=TI(1),ZL=TI(-1),WL=[{key:"Tab",run:FL,shift:ZL},{key:"Escape",run:ML}],R1=me.define({combine(t){return t.length?t[0]:WL}}),LL=wi.highest(Ta.compute([R1],t=>t.facet(R1)));function Un(t,e){return Object.assign(Object.assign({},e),{apply:NL(t)})}const VL=de.domEventHandlers({mousedown(t,e){let n=e.state.field(Hl,!1),r;if(!n||(r=e.posAtCoords({x:t.clientX,y:t.clientY}))==null)return!1;let i=n.ranges.find(s=>s.from<=r&&s.to>=r);return!i||i.field==n.active?!1:(e.dispatch({selection:mv(n.ranges,i.field),effects:Sc.of(n.ranges.some(s=>s.field>i.field)?new Qa(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Jl={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zs=Ne.define({map(t,e){let n=e.mapPos(t,-1,wn.TrackAfter);return n??void 0}}),Ov=new class extends Hs{};Ov.startSide=1;Ov.endSide=-1;const $I=ln.define({create(){return et.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of e.effects)n.is(zs)&&(t=t.update({add:[Ov.range(n.value,n.value+1)]}));return t}});function zL(){return[GL,$I]}const yp="()[]{}<>";function RI(t){for(let e=0;e<yp.length;e+=2)if(yp.charCodeAt(e)==t)return yp.charAt(e+1);return QO(t<128?t:t+1)}function jI(t,e){return t.languageDataAt("closeBrackets",e)[0]||Jl}const XL=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),GL=de.inputHandler.of((t,e,n,r)=>{if((XL?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(r.length>2||r.length==2&&Ar(bn(r,0))==1||e!=i.from||n!=i.to)return!1;let s=YL(t.state,r);return s?(t.dispatch(s),!0):!1}),qL=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=jI(t,t.selection.main.head).brackets||Jl.brackets,i=null,s=t.changeByRange(o=>{if(o.empty){let a=HL(t.doc,o.head);for(let l of r)if(l==a&&Kd(t.doc,o.head)==RI(bn(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:ie.cursor(o.head-l.length)}}return{range:i=o}});return i||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},UL=[{key:"Backspace",run:qL}];function YL(t,e){let n=jI(t,t.selection.main.head),r=n.brackets||Jl.brackets;for(let i of r){let s=RI(bn(i,0));if(e==i)return s==i?eV(t,i,r.indexOf(i+i+i)>-1,n):JL(t,i,s,n.before||Jl.before);if(e==s&&DI(t,t.selection.main.from))return KL(t,i,s)}return null}function DI(t,e){let n=!1;return t.field($I).between(0,t.doc.length,r=>{r==e&&(n=!0)}),n}function Kd(t,e){let n=t.sliceString(e,e+2);return n.slice(0,Ar(bn(n,0)))}function HL(t,e){let n=t.sliceString(e-2,e);return Ar(bn(n,0))==n.length?n:n.slice(1)}function JL(t,e,n,r){let i=null,s=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:zs.of(o.to+e.length),range:ie.range(o.anchor+e.length,o.head+e.length)};let a=Kd(t.doc,o.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+n,from:o.head},effects:zs.of(o.head+e.length),range:ie.cursor(o.head+e.length)}:{range:i=o}});return i?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function KL(t,e,n){let r=null,i=t.changeByRange(s=>s.empty&&Kd(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:ie.cursor(s.head+n.length)}:r={range:s});return r?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function eV(t,e,n,r){let i=r.stringPrefixes||Jl.stringPrefixes,s=null,o=t.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:zs.of(a.to+e.length),range:ie.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=Kd(t.doc,l),u;if(c==e){if(j1(t,l))return{changes:{insert:e+e,from:l},effects:zs.of(l+e.length),range:ie.cursor(l+e.length)};if(DI(t,l)){let d=n&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+d.length,insert:d},range:ie.cursor(l+d.length)}}}else{if(n&&t.sliceDoc(l-2*e.length,l)==e+e&&(u=D1(t,l-2*e.length,i))>-1&&j1(t,u))return{changes:{insert:e+e+e+e,from:l},effects:zs.of(l+e.length),range:ie.cursor(l+e.length)};if(t.charCategorizer(l)(c)!=jt.Word&&D1(t,l,i)>-1&&!tV(t,l,e,i))return{changes:{insert:e+e,from:l},effects:zs.of(l+e.length),range:ie.cursor(l+e.length)}}return{range:s=a}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function j1(t,e){let n=Dt(t).resolveInner(e+1);return n.parent&&n.from==e}function tV(t,e,n,r){let i=Dt(t).resolveInner(e,-1),s=r.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=t.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),l=a.indexOf(n);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(t.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function D1(t,e,n){let r=t.charCategorizer(e);if(r(t.sliceDoc(e-1,e))!=jt.Word)return e;for(let i of n){let s=e-i.length;if(t.sliceDoc(s,e)==i&&r(t.sliceDoc(s-1,s))!=jt.Word)return s}return-1}function nV(t={}){return[jL,Yn,Cn.of(t),$L,rV,II]}const _I=[{key:"Ctrl-Space",run:AL},{key:"Escape",run:PL},{key:"ArrowDown",run:wu(!0)},{key:"ArrowUp",run:wu(!1)},{key:"PageDown",run:wu(!0,"page")},{key:"PageUp",run:wu(!1,"page")},{key:"Enter",run:EI}],rV=wi.highest(Ta.computeN([Cn],t=>t.facet(Cn).defaultKeymap?[_I]:[]));class iV{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Vs{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=e,s=r.facet(cs).markerFilter;s&&(i=s(i,r));let o=Se.set(i.map(a=>a.from==a.to||a.from==a.to-1&&r.doc.lineAt(a.from).to==a.from?Se.widget({widget:new gV(a),diagnostic:a}).range(a.from):Se.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity+(a.markClass?" "+a.markClass:"")},diagnostic:a,inclusive:!0}).range(a.from,a.to)),!0);return new Vs(o,n,da(o))}}function da(t,e=null,n=0){let r=null;return t.between(n,1e9,(i,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return r=new iV(i,s,o.diagnostic),!1}),r}function sV(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(cs).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(vv))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function BI(t,e){return t.field(gr,!1)?e:e.concat(Ne.appendConfig.of(FI))}function oV(t,e){return{effects:BI(t,[vv.of(e)])}}const vv=Ne.define(),xv=Ne.define(),QI=Ne.define(),gr=ln.define({create(){return new Vs(Se.none,null,null)},update(t,e){if(e.docChanged){let n=t.diagnostics.map(e.changes),r=null;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);r=da(n,t.selected.diagnostic,i)||da(n,null,i)}t=new Vs(n,t.panel,r)}for(let n of e.effects)n.is(vv)?t=Vs.init(n.value,t.panel,e.state):n.is(xv)?t=new Vs(t.diagnostics,n.value?eh.open:null,t.selected):n.is(QI)&&(t=new Vs(t.diagnostics,t.panel,n.value));return t},provide:t=>[zl.from(t,e=>e.panel),de.decorations.from(t,e=>e.diagnostics)]}),aV=Se.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function lV(t,e,n){let{diagnostics:r}=t.state.field(gr),i=[],s=2e8,o=0;r.between(e-(n<0?1:0),e+(n>0?1:0),(l,c,{spec:u})=>{e>=l&&e<=c&&(l==c||(e>l||n>0)&&(e<c||n<0))&&(i.push(u.diagnostic),s=Math.min(l,s),o=Math.max(c,o))});let a=t.state.facet(cs).tooltipFilter;return a&&(i=a(i,t.state)),i.length?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:cV(t,i)}}}:null}function cV(t,e){return At("ul",{class:"cm-tooltip-lint"},e.map(n=>MI(t,n,!1)))}const uV=t=>{let e=t.state.field(gr,!1);(!e||!e.panel)&&t.dispatch({effects:BI(t.state,[xv.of(!0)])});let n=Vl(t,eh.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},_1=t=>{let e=t.state.field(gr,!1);return!e||!e.panel?!1:(t.dispatch({effects:xv.of(!1)}),!0)},fV=t=>{let e=t.state.field(gr,!1);if(!e)return!1;let n=t.state.selection.main,r=e.diagnostics.iter(n.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},dV=[{key:"Mod-Shift-m",run:uV,preventDefault:!0},{key:"F8",run:fV}],hV=Bt.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(cs);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:n}=e.facet(cs);n.length&&Promise.all(n.map(r=>Promise.resolve(r(this.view)))).then(r=>{let i=r.reduce((s,o)=>s.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(oV(this.view.state,i))},r=>{Zn(this.view.state,r)})}}update(t){let e=t.state.facet(cs);(t.docChanged||e!=t.startState.facet(cs)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),cs=me.define({combine(t){return Object.assign({sources:t.map(e=>e.source).filter(e=>e!=null)},ki(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n}))}});function pV(t,e={}){return[cs.of({source:t,config:e}),hV,FI]}function NI(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let i=n[r];if(/[a-zA-Z]/.test(i)&&!e.some(s=>s.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function MI(t,e,n){var r;let i=n?NI(e.actions):[];return At("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},At("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let h=da(t.state.field(gr).diagnostics,e);h&&s.apply(t,h.from,h.to)},{name:c}=s,u=i[o]?c.indexOf(i[o]):-1,f=u<0?c:[c.slice(0,u),At("u",c.slice(u,u+1)),c.slice(u+1)];return At("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&At("div",{class:"cm-diagnosticSource"},e.source))}class gV extends Ai{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return At("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class B1{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=MI(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class eh{constructor(e){this.view=e,this.items=[];let n=i=>{if(i.keyCode==27)_1(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=NI(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=da(this.view.state.field(gr).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;i.preventDefault()},r=i=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(i.target)&&this.moveSelection(s)};this.list=At("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=At("div",{class:"cm-panel-lint"},this.list,At("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>_1(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(gr).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(gr),r=0,i=!1,s=null;for(e.between(0,this.view.state.doc.length,(o,a,{spec:l})=>{let c=-1,u;for(let f=r;f<this.items.length;f++)if(this.items[f].diagnostic==l.diagnostic){c=f;break}c<0?(u=new B1(this.view,l.diagnostic),this.items.splice(r,0,u),i=!0):(u=this.items[c],c>r&&(this.items.splice(r,c-r),i=!0)),n&&u.diagnostic==n.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),r++});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new B1(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:a})=>{let l=a.height/this.list.offsetHeight;o.top<a.top?this.list.scrollTop-=(a.top-o.top)/l:o.bottom>a.bottom&&(this.list.scrollTop+=(o.bottom-a.bottom)/l)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(gr),r=da(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:QI.of(r)})}static open(e){return new eh(e)}}function mV(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Cu(t){return mV(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const OV=de.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Cu("#d11")},".cm-lintRange-warning":{backgroundImage:Cu("orange")},".cm-lintRange-info":{backgroundImage:Cu("#999")},".cm-lintRange-hint":{backgroundImage:Cu("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),FI=[gr,de.decorations.compute([gr],t=>{let{selected:e,panel:n}=t.field(gr);return!e||!n||e.from==e.to?Se.none:Se.set([aV.range(e.from,e.to)])}),tZ(lV,{hideOn:sV}),OV];var Q1=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,r=[];e.closeBracketsKeymap!==!1&&(r=r.concat(UL)),e.defaultKeymap!==!1&&(r=r.concat(j6)),e.searchKeymap!==!1&&(r=r.concat(sL)),e.historyKeymap!==!1&&(r=r.concat(WW)),e.foldKeymap!==!1&&(r=r.concat(rW)),e.completionKeymap!==!1&&(r=r.concat(_I)),e.lintKeymap!==!1&&(r=r.concat(dV));var i=[];return e.lineNumbers!==!1&&i.push(uZ()),e.highlightActiveLineGutter!==!1&&i.push(hZ()),e.highlightSpecialChars!==!1&&i.push(T8()),e.history!==!1&&i.push(jW()),e.foldGutter!==!1&&i.push(aW()),e.drawSelection!==!1&&i.push(y8()),e.dropCursor!==!1&&i.push(k8()),e.allowMultipleSelections!==!1&&i.push(Ye.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(qZ()),e.syntaxHighlighting!==!1&&i.push(rv(fW,{fallback:!0})),e.bracketMatching!==!1&&i.push(vW()),e.closeBrackets!==!1&&i.push(zL()),e.autocompletion!==!1&&i.push(nV()),e.rectangularSelection!==!1&&i.push(V8()),n!==!1&&i.push(G8()),e.highlightActiveLine!==!1&&i.push(B8()),e.highlightSelectionMatches!==!1&&i.push(F6()),e.tabSize&&typeof e.tabSize=="number"&&i.push(vc.of(" ".repeat(e.tabSize))),i.concat([Ta.of(r.flat())]).filter(Boolean)};const vV="#e5c07b",N1="#e06c75",xV="#56b6c2",yV="#ffffff",Uu="#abb2bf",fm="#7d8799",bV="#61afef",SV="#98c379",M1="#d19a66",wV="#c678dd",CV="#21252b",F1="#2c313a",Z1="#282c34",bp="#353a42",kV="#3E4451",W1="#528bff",AV=de.theme({"&":{color:Uu,backgroundColor:Z1},".cm-content":{caretColor:W1},".cm-cursor, .cm-dropCursor":{borderLeftColor:W1},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:kV},".cm-panels":{backgroundColor:CV,color:Uu},".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:Z1,color:fm,border:"none"},".cm-activeLineGutter":{backgroundColor:F1},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:bp},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:bp,borderBottomColor:bp},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:F1,color:Uu}}},{dark:!0}),PV=Da.define([{tag:I.keyword,color:wV},{tag:[I.name,I.deleted,I.character,I.propertyName,I.macroName],color:N1},{tag:[I.function(I.variableName),I.labelName],color:bV},{tag:[I.color,I.constant(I.name),I.standard(I.name)],color:M1},{tag:[I.definition(I.name),I.separator],color:Uu},{tag:[I.typeName,I.className,I.number,I.changed,I.annotation,I.modifier,I.self,I.namespace],color:vV},{tag:[I.operator,I.operatorKeyword,I.url,I.escape,I.regexp,I.link,I.special(I.string)],color:xV},{tag:[I.meta,I.comment],color:fm},{tag:I.strong,fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.link,color:fm,textDecoration:"underline"},{tag:I.heading,fontWeight:"bold",color:N1},{tag:[I.atom,I.bool,I.special(I.variableName)],color:M1},{tag:[I.processingInstruction,I.string,I.inserted],color:SV},{tag:I.invalid,color:yV}]),EV=[AV,rv(PV)];var IV=de.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),TV=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:r=!0,readOnly:i=!1,theme:s="light",placeholder:o="",basicSetup:a=!0}=e,l=[];switch(n&&l.unshift(Ta.of([D6])),a&&(typeof a=="boolean"?l.unshift(Q1()):l.unshift(Q1(a))),o&&l.unshift(F8(o)),s){case"light":l.push(IV);break;case"dark":l.push(EV);break;case"none":break;default:l.push(s);break}return r===!1&&l.push(de.editable.of(!1)),i&&l.push(Ye.readOnly.of(!0)),[...l]},$V=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)}),L1=Ci.define(),RV=[];function jV(t){var{value:e,selection:n,onChange:r,onStatistics:i,onCreateEditor:s,onUpdate:o,extensions:a=RV,autoFocus:l,theme:c="light",height:u=null,minHeight:f=null,maxHeight:d=null,width:h=null,minWidth:p=null,maxWidth:O=null,placeholder:g="",editable:x=!0,readOnly:v=!1,indentWithTab:y=!0,basicSetup:b=!0,root:S,initialState:w}=t,[C,k]=D.useState(),[P,A]=D.useState(),[E,$]=D.useState(),R=de.theme({"&":{height:u,minHeight:f,maxHeight:d,width:h,minWidth:p,maxWidth:O},"& .cm-scroller":{height:"100% !important"}}),Q=de.updateListener.of(G=>{if(G.docChanged&&typeof r=="function"&&!G.transactions.some(q=>q.annotation(L1))){var L=G.state.doc,U=L.toString();r(U,G)}i&&i($V(G))}),_=TV({theme:c,editable:x,readOnly:v,placeholder:g,indentWithTab:y,basicSetup:b}),Z=[Q,R,..._];return o&&typeof o=="function"&&Z.push(de.updateListener.of(o)),Z=Z.concat(a),D.useEffect(()=>{if(C&&!E){var G={doc:e,selection:n,extensions:Z},L=w?Ye.fromJSON(w.json,G,w.fields):Ye.create(G);if($(L),!P){var U=new de({state:L,parent:C,root:S});A(U),s&&s(U,L)}}return()=>{P&&($(void 0),A(void 0))}},[C,E]),D.useEffect(()=>k(t.container),[t.container]),D.useEffect(()=>()=>{P&&(P.destroy(),A(void 0))},[P]),D.useEffect(()=>{l&&P&&P.focus()},[l,P]),D.useEffect(()=>{P&&P.dispatch({effects:Ne.reconfigure.of(Z)})},[c,a,u,f,d,h,p,O,g,x,v,y,b,r,o]),D.useEffect(()=>{if(e!==void 0){var G=P?P.state.doc.toString():"";P&&e!==G&&P.dispatch({changes:{from:0,to:G.length,insert:e||""},annotations:[L1.of(!0)]})}},[e,P]),{state:E,setState:$,view:P,setView:A,container:C,setContainer:k}}var DV=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],ZI=D.forwardRef((t,e)=>{var{className:n,value:r="",selection:i,extensions:s=[],onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:c,autoFocus:u,theme:f="light",height:d,minHeight:h,maxHeight:p,width:O,minWidth:g,maxWidth:x,basicSetup:v,placeholder:y,indentWithTab:b,editable:S,readOnly:w,root:C,initialState:k}=t,P=Dk(t,DV),A=D.useRef(null),{state:E,view:$,container:R}=jV({container:A.current,root:C,value:r,autoFocus:u,theme:f,height:d,minHeight:h,maxHeight:p,width:O,minWidth:g,maxWidth:x,basicSetup:v,placeholder:y,indentWithTab:b,editable:S,readOnly:w,selection:i,onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:c,extensions:s,initialState:k});if(D.useImperativeHandle(e,()=>({editor:A.current,state:E,view:$}),[A,R,E,$]),typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var Q=typeof f=="string"?"cm-theme-"+f:"cm-theme";return m.jsx("div",ke({ref:A,className:""+Q+(n?" "+n:"")},P))});ZI.displayName="CodeMirror";function Jf(){return Jf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Jf.apply(this,arguments)}var WI=t=>{var{theme:e,settings:n={},styles:r=[]}=t,i={".cm-gutters":{}},s={};n.background&&(s.backgroundColor=n.background),n.backgroundImage&&(s.backgroundImage=n.backgroundImage),n.foreground&&(s.color=n.foreground),n.fontSize&&(s.fontSize=n.fontSize),(n.background||n.foreground)&&(i["&"]=s),n.fontFamily&&(i["&.cm-editor .cm-scroller"]={fontFamily:n.fontFamily}),n.gutterBackground&&(i[".cm-gutters"].backgroundColor=n.gutterBackground),n.gutterForeground&&(i[".cm-gutters"].color=n.gutterForeground),n.gutterBorder&&(i[".cm-gutters"].borderRightColor=n.gutterBorder),n.caret&&(i[".cm-content"]={caretColor:n.caret},i[".cm-cursor, .cm-dropCursor"]={borderLeftColor:n.caret});var o={};n.gutterActiveForeground&&(o.color=n.gutterActiveForeground),n.lineHighlight&&(i[".cm-activeLine"]={backgroundColor:n.lineHighlight},o.backgroundColor=n.lineHighlight),i[".cm-activeLineGutter"]=o,n.selection&&(i["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:n.selection+" !important"}),n.selectionMatch&&(i["& .cm-selectionMatch"]={backgroundColor:n.selectionMatch});var a=de.theme(i,{dark:e==="dark"}),l=Da.define(r),c=[a,rv(l)];return c},_V={background:"#2e3235",foreground:"#bdbdbd",caret:"#a0a4ae",selection:"#d7d4f063",selectionMatch:"#d7d4f063",gutterBackground:"#2e3235",gutterForeground:"#999",gutterActiveForeground:"#4f5b66",lineHighlight:"#545b6130"},yv=t=>{var{theme:e="dark",settings:n={},styles:r=[]}=t||{};return WI({theme:e,settings:Jf({},_V,n),styles:[{tag:I.keyword,color:"#cf6edf"},{tag:[I.name,I.deleted,I.character,I.macroName],color:"#56c8d8"},{tag:[I.propertyName],color:"#facf4e"},{tag:[I.variableName],color:"#bdbdbd"},{tag:[I.function(I.variableName)],color:"#56c8d8"},{tag:[I.labelName],color:"#cf6edf"},{tag:[I.color,I.constant(I.name),I.standard(I.name)],color:"#facf4e"},{tag:[I.definition(I.name),I.separator],color:"#fa5788"},{tag:[I.brace],color:"#cf6edf"},{tag:[I.annotation],color:"#ff5f52"},{tag:[I.number,I.changed,I.annotation,I.modifier,I.self,I.namespace],color:"#ffad42"},{tag:[I.typeName,I.className],color:"#ffad42"},{tag:[I.operator,I.operatorKeyword],color:"#7186f0"},{tag:[I.tagName],color:"#99d066"},{tag:[I.squareBracket],color:"#ff5f52"},{tag:[I.angleBracket],color:"#606f7a"},{tag:[I.attributeName],color:"#bdbdbd"},{tag:[I.regexp],color:"#ff5f52"},{tag:[I.quote],color:"#6abf69"},{tag:[I.string],color:"#99d066"},{tag:I.link,color:"#56c8d8",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[I.url,I.escape,I.special(I.string)],color:"#facf4e"},{tag:[I.meta],color:"#707d8b"},{tag:[I.comment],color:"#707d8b",fontStyle:"italic"},{tag:I.monospace,color:"#bdbdbd"},{tag:I.strong,fontWeight:"bold",color:"#ff5f52"},{tag:I.emphasis,fontStyle:"italic",color:"#99d066"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.heading,fontWeight:"bold",color:"#facf4e"},{tag:I.heading1,fontWeight:"bold",color:"#facf4e"},{tag:[I.heading2,I.heading3,I.heading4],fontWeight:"bold",color:"#facf4e"},{tag:[I.heading5,I.heading6],color:"#facf4e"},{tag:[I.atom,I.bool,I.special(I.variableName)],color:"#56c8d8"},{tag:[I.processingInstruction,I.inserted],color:"#ff5f52"},{tag:[I.contentSeparator],color:"#56c8d8"},{tag:I.invalid,color:"#606f7a",borderBottom:"1px dotted #ff5f52"},...r]})},BV=yv;yv();yv();var QV={background:"#FAFAFA",foreground:"#90A4AE",caret:"#272727",selection:"#80CBC440",selectionMatch:"#80CBC440",gutterBackground:"#FAFAFA",gutterForeground:"#90A4AE",gutterBorder:"transparent",lineHighlight:"#CCD7DA50"},dm=t=>{var{theme:e="light",settings:n={},styles:r=[]}=t||{};return WI({theme:e,settings:Jf({},QV,n),styles:[{tag:I.keyword,color:"#39ADB5"},{tag:[I.name,I.deleted,I.character,I.macroName],color:"#90A4AE"},{tag:[I.propertyName],color:"#6182B8"},{tag:[I.processingInstruction,I.string,I.inserted,I.special(I.string)],color:"#91B859"},{tag:[I.function(I.variableName),I.labelName],color:"#6182B8"},{tag:[I.color,I.constant(I.name),I.standard(I.name)],color:"#39ADB5"},{tag:[I.definition(I.name),I.separator],color:"#90A4AE"},{tag:[I.className],color:"#E2931D"},{tag:[I.number,I.changed,I.annotation,I.modifier,I.self,I.namespace],color:"#F76D47"},{tag:[I.typeName],color:"#E2931D",fontStyle:"#E2931D"},{tag:[I.operator,I.operatorKeyword],color:"#39ADB5"},{tag:[I.url,I.escape,I.regexp,I.link],color:"#91B859"},{tag:[I.meta,I.comment],color:"#90A4AE"},{tag:I.strong,fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.link,textDecoration:"underline"},{tag:I.heading,fontWeight:"bold",color:"#39ADB5"},{tag:[I.atom,I.bool,I.special(I.variableName)],color:"#90A4AE"},{tag:I.invalid,color:"#E5393570"},{tag:I.strikethrough,textDecoration:"line-through"},...r]})};dm();function NV(t){const e={settings:{background:"var(--bg-color-tonal)",fontFamily:"var(--code-block-font-family)"},styles:[{tag:[I.propertyName],color:"var(--code-block-tokens-property-string-color)"},{tag:[I.processingInstruction,I.string,I.inserted,I.special(I.string)],color:"var(--code-block-tokens-string-color)"},{tag:[I.atom,I.bool,I.special(I.variableName)],color:"var(--text-color-secondary)"}]};switch(t){case"light":return dm(e);case"dark":return BV(e);default:return dm(e)}}const LI=Ne.define();function Kf({dataTestId:t,...e}){const n=Re(),r=an(),{stateExtensions:i}=e,s=D.useRef(null),[o,a]=D.useState(!1),l=D.useMemo(()=>i?i.map(c=>wi.highest(c({selectedEnvironment:r,state:n}))):[],[i,r,n]);return D.useEffect(()=>{var u;const c=(u=s.current)==null?void 0:u.view;c&&c.dispatch({effects:LI.of()})},[n.environments,r]),m.jsx(MV,{"data-testid":t,onClick:()=>a(!0),children:m.jsx(ZI,{autoFocus:o,className:"codemirror-container",ref:s,theme:NV("light"),basicSetup:{bracketMatching:!0,closeBrackets:!0,tabSize:2,foldGutter:!1,lineNumbers:!0,lintKeymap:!0,drawSelection:!1},onBlur:()=>a(!1),...e,extensions:[...l,...e.extensions||[]]})})}const MV=T.div`
|
|
677
|
+
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new J6(this):new Y6(this)}getCursor(e,n=0,r){let i=e.doc?e:Ye.create({doc:e});return r==null&&(r=i.doc.length),this.regexp?Io(this,i,n,r):Eo(this,i,n,r)}}class vI{constructor(e){this.spec=e}}function Eo(t,e,n,r){return new fa(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:i=>i.toLowerCase(),t.wholeWord?U6(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function U6(t,e){return(n,r,i,s)=>((s>n||s+i.length<r)&&(s=Math.max(0,n-2),i=t.sliceString(s,Math.min(t.length,r+2))),(e(Xf(i,n-s))!=jt.Word||e(Gf(i,n-s))!=jt.Word)&&(e(Gf(i,r-s))!=jt.Word||e(Xf(i,r-s))!=jt.Word))}class Y6 extends vI{constructor(e){super(e)}nextMatch(e,n,r){let i=Eo(this.spec,e,r,e.doc.length).nextOverlapping();return i.done&&(i=Eo(this.spec,e,0,n).nextOverlapping()),i.done?null:i.value}prevMatchInRange(e,n,r){for(let i=r;;){let s=Math.max(n,i-1e4-this.spec.unquoted.length),o=Eo(this.spec,e,s,i),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(s==n)return null;i-=1e4}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=Eo(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=Eo(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function Io(t,e,n,r){return new gI(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?H6(e.charCategorizer(e.selection.main.head)):void 0},n,r)}function Xf(t,e){return t.slice(kn(t,e,!1),e)}function Gf(t,e){return t.slice(e,kn(t,e))}function H6(t){return(e,n,r)=>!r[0].length||(t(Xf(r.input,r.index))!=jt.Word||t(Gf(r.input,r.index))!=jt.Word)&&(t(Gf(r.input,r.index+r[0].length))!=jt.Word||t(Xf(r.input,r.index+r[0].length))!=jt.Word)}class J6 extends vI{nextMatch(e,n,r){let i=Io(this.spec,e,r,e.doc.length).next();return i.done&&(i=Io(this.spec,e,0,n).next()),i.done?null:i.value}prevMatchInRange(e,n,r){for(let i=1;;i++){let s=Math.max(n,r-i*1e4),o=Io(this.spec,e,s,r),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==n||a.from>s+10))return a;if(s==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(n,r)=>r=="$"?"$":r=="&"?e.match[0]:r!="0"&&+r<e.match.length?e.match[r]:n)}matchAll(e,n){let r=Io(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=n)return null;i.push(r.value)}return i}highlight(e,n,r,i){let s=Io(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const Ul=Ne.define(),cv=Ne.define(),ps=ln.define({create(t){return new vp(cm(t).create(),null)},update(t,e){for(let n of e.effects)n.is(Ul)?t=new vp(n.value.create(),t.panel):n.is(cv)&&(t=new vp(t.query,n.value?uv:null));return t},provide:t=>zl.from(t,e=>e.panel)});class vp{constructor(e,n){this.query=e,this.panel=n}}const K6=Se.mark({class:"cm-searchMatch"}),eL=Se.mark({class:"cm-searchMatch cm-searchMatch-selected"}),tL=Bt.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(ps))}update(t){let e=t.state.field(ps);(e!=t.startState.field(ps)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Se.none;let{view:n}=this,r=new vs;for(let i=0,s=n.visibleRanges,o=s.length;i<o;i++){let{from:a,to:l}=s[i];for(;i<o-1&&l>s[i+1].from-2*250;)l=s[++i].to;t.highlight(n.state,a,l,(c,u)=>{let f=n.state.selection.ranges.some(d=>d.from==c&&d.to==u);r.add(c,u,f?eL:K6)})}return r.finish()}},{decorations:t=>t.decorations});function bc(t){return e=>{let n=e.state.field(ps,!1);return n&&n.query.spec.valid?t(e,n):bI(e)}}const qf=bc((t,{query:e})=>{let{to:n}=t.state.selection.main,r=e.nextMatch(t.state,n,n);if(!r)return!1;let i=ie.single(r.from,r.to),s=t.state.facet(Ba);return t.dispatch({selection:i,effects:[fv(t,r),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),yI(t),!0}),Uf=bc((t,{query:e})=>{let{state:n}=t,{from:r}=n.selection.main,i=e.prevMatch(n,r,r);if(!i)return!1;let s=ie.single(i.from,i.to),o=t.state.facet(Ba);return t.dispatch({selection:s,effects:[fv(t,i),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),yI(t),!0}),nL=bc((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:ie.create(n.map(r=>ie.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),rL=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,s=[],o=0;for(let a=new fa(t.doc,t.sliceDoc(r,i));!a.next().done;){if(s.length>1e3)return!1;a.value.from==r&&(o=s.length),s.push(ie.range(a.value.from,a.value.to))}return e(t.update({selection:ie.create(s,o),userEvent:"select.search.matches"})),!0},k1=bc((t,{query:e})=>{let{state:n}=t,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,r,r);if(!s)return!1;let o=[],a,l,c=[];if(s.from==r&&s.to==i&&(l=n.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:l}),s=e.nextMatch(n,s.from,s.to),c.push(de.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))),s){let u=o.length==0||o[0].from>=s.to?0:s.to-s.from-l.length;a=ie.single(s.from-u,s.to-u),c.push(fv(t,s)),c.push(n.facet(Ba).scrollToMatch(a.main,t))}return t.dispatch({changes:o,selection:a,effects:c,userEvent:"input.replace"}),!0}),iL=bc((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(i=>{let{from:s,to:o}=i;return{from:s,to:o,insert:e.getReplacement(i)}});if(!n.length)return!1;let r=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:de.announce.of(r),userEvent:"input.replace.all"}),!0});function uv(t){return t.state.facet(Ba).createPanel(t)}function cm(t,e){var n,r,i,s,o;let a=t.selection.main,l=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=t.facet(Ba);return new OI({search:((n=e==null?void 0:e.literal)!==null&&n!==void 0?n:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=e==null?void 0:e.caseSensitive)!==null&&r!==void 0?r:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function xI(t){let e=Vl(t,uv);return e&&e.dom.querySelector("[main-field]")}function yI(t){let e=xI(t);e&&e==t.root.activeElement&&e.select()}const bI=t=>{let e=t.state.field(ps,!1);if(e&&e.panel){let n=xI(t);if(n&&n!=t.root.activeElement){let r=cm(t.state,e.query.spec);r.valid&&t.dispatch({effects:Ul.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[cv.of(!0),e?Ul.of(cm(t.state,e.query.spec)):Ne.appendConfig.of(lL)]});return!0},SI=t=>{let e=t.state.field(ps,!1);if(!e||!e.panel)return!1;let n=Vl(t,uv);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:cv.of(!1)}),!0},sL=[{key:"Mod-f",run:bI,scope:"editor search-panel"},{key:"F3",run:qf,shift:Uf,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:qf,shift:Uf,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:SI,scope:"editor search-panel"},{key:"Mod-Shift-l",run:rL},{key:"Mod-Alt-g",run:B6},{key:"Mod-d",run:q6,preventDefault:!0}];class oL{constructor(e){this.view=e;let n=this.query=e.state.field(ps).query.spec;this.commit=this.commit.bind(this),this.searchField=At("input",{value:n.search,placeholder:sr(e,"Find"),"aria-label":sr(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=At("input",{value:n.replace,placeholder:sr(e,"Replace"),"aria-label":sr(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=At("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=At("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=At("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(i,s,o){return At("button",{class:"cm-button",name:i,onclick:s,type:"button"},o)}this.dom=At("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,r("next",()=>qf(e),[sr(e,"next")]),r("prev",()=>Uf(e),[sr(e,"previous")]),r("select",()=>nL(e),[sr(e,"all")]),At("label",null,[this.caseField,sr(e,"match case")]),At("label",null,[this.reField,sr(e,"regexp")]),At("label",null,[this.wordField,sr(e,"by word")]),...e.state.readOnly?[]:[At("br"),this.replaceField,r("replace",()=>k1(e),[sr(e,"replace")]),r("replaceAll",()=>iL(e),[sr(e,"replace all")])],At("button",{name:"close",onclick:()=>SI(e),"aria-label":sr(e,"close"),type:"button"},["×"])])}commit(){let e=new OI({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Ul.of(e)}))}keydown(e){p8(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Uf:qf)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),k1(this.view))}update(e){for(let n of e.transactions)for(let r of n.effects)r.is(Ul)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Ba).top}}function sr(t,e){return t.state.phrase(e)}const bu=30,Su=/[\s\.,:;?!]/;function fv(t,{from:e,to:n}){let r=t.state.doc.lineAt(e),i=t.state.doc.lineAt(n).to,s=Math.max(r.from,e-bu),o=Math.min(i,n+bu),a=t.state.sliceDoc(s,o);if(s!=r.from){for(let l=0;l<bu;l++)if(!Su.test(a[l+1])&&Su.test(a[l])){a=a.slice(l);break}}if(o!=i){for(let l=a.length-1;l>a.length-bu;l--)if(!Su.test(a[l-1])&&Su.test(a[l])){a=a.slice(0,l);break}}return de.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${r.number}.`)}const aL=de.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),lL=[ps,wi.low(tL),aL];class wI{constructor(e,n,r){this.state=e,this.pos=n,this.explicit=r,this.abortListeners=[]}tokenBefore(e){let n=Dt(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),s=i.search(kI(e,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n){e=="abort"&&this.abortListeners&&this.abortListeners.push(n)}}function A1(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function cL(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let s=1;s<i.length;s++)n[i[s]]=!0}let r=A1(e)+A1(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function CI(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[n,r]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:cL(e);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:e,validFor:n}:null}}function uL(t,e){return n=>{for(let r=Dt(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(t.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return e(n)}}class P1{constructor(e,n,r,i){this.completion=e,this.source=n,this.match=r,this.score=i}}function gs(t){return t.selection.main.from}function kI(t,e){var n;let{source:r}=t,i=e&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?t:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const dv=Ci.define();function fL(t,e,n,r){let{main:i}=t.selection,s=n-i.from,o=r-i.from;return Object.assign(Object.assign({},t.changeByRange(a=>a!=i&&n!=r&&t.sliceDoc(a.from+s,a.from+o)!=t.sliceDoc(n,r)?{range:a}:{changes:{from:a.from+s,to:r==i.from?a.to:a.from+o,insert:e},range:ie.cursor(a.from+s+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}const E1=new WeakMap;function dL(t){if(!Array.isArray(t))return t;let e=E1.get(t);return e||E1.set(t,e=CI(t)),e}const Yf=Ne.define(),Yl=Ne.define();class hL{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let r=bn(e,n),i=Ar(r);this.chars.push(r);let s=e.slice(n,n+i),o=s.toUpperCase();this.folded.push(bn(o==s?s.toLowerCase():o,0)),n+=i}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:s,byWord:o}=this;if(n.length==1){let v=bn(e,0),y=Ar(v),b=y==e.length?0:-100;if(v!=n[0])if(v==r[0])b+=-200;else return null;return this.ret(b,[0,y])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(a<0){for(let v=0,y=Math.min(e.length,200);v<y&&c<l;){let b=bn(e,v);(b==n[c]||b==r[c])&&(i[c++]=v),v+=Ar(b)}if(c<l)return null}let u=0,f=0,d=!1,h=0,p=-1,O=-1,g=/[a-z]/.test(e),x=!0;for(let v=0,y=Math.min(e.length,200),b=0;v<y&&f<l;){let S=bn(e,v);a<0&&(u<l&&S==n[u]&&(s[u++]=v),h<l&&(S==n[h]||S==r[h]?(h==0&&(p=v),O=v+1,h++):h=0));let w,C=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(w=QO(S))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||C==1&&g||b==0&&C!=0)&&(n[f]==S||r[f]==S&&(d=!0)?o[f++]=v:o.length&&(x=!1)),b=C,v+=Ar(S)}return f==l&&o[0]==0&&x?this.result(-100+(d?-200:0),o,e):h==l&&p==0?this.ret(-200-e.length+(O==e.length?0:-100),[0,O]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):h==l?this.ret(-900-e.length,[p,O]):f==l?this.result(-100+(d?-200:0)+-700+(x?0:-1100),o,e):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,n,r){let i=[],s=0;for(let o of n){let a=o+(this.astral?Ar(bn(r,o)):1);s&&i[s-1]==o?i[s-1]=a:(i[s++]=o,i[s++]=a)}return this.ret(e-r.length,i)}}class pL{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let n=e.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(e.length==this.pattern.length?0:-100),this)}}const Cn=me.define({combine(t){return ki(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:gL,filterStrict:!1,compareCompletions:(e,n)=>e.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>r=>I1(e(r),n(r)),optionClass:(e,n)=>r=>I1(e(r),n(r)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function I1(t,e){return t?e?t+" "+e:t:e}function gL(t,e,n,r,i,s){let o=t.textDirection==$t.RTL,a=o,l=!1,c="top",u,f,d=e.left-i.left,h=i.right-e.right,p=r.right-r.left,O=r.bottom-r.top;if(a&&d<Math.min(p,h)?a=!1:!a&&h<Math.min(p,d)&&(a=!0),p<=(a?d:h))u=Math.max(i.top,Math.min(n.top,i.bottom-O))-e.top,f=Math.min(400,a?d:h);else{l=!0,f=Math.min(400,(o?e.right:i.right-e.left)-30);let v=i.bottom-e.bottom;v>=O||v>e.top?u=n.bottom-e.top:(c="bottom",u=e.bottom-n.top)}let g=(e.bottom-e.top)/s.offsetHeight,x=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${f/x}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}function mL(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),e.push({render(n,r,i,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=n.displayLabel||n.label,l=0;for(let c=0;c<s.length;){let u=s[c++],f=s[c++];u>l&&o.appendChild(document.createTextNode(a.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(a.slice(u,f))),d.className="cm-completionMatchedText",l=f}return l<a.length&&o.appendChild(document.createTextNode(a.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),e.sort((n,r)=>n.position-r.position).map(n=>n.render)}function xp(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let i=Math.floor(e/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((t-e)/n);return{from:t-(r+1)*n,to:t-r*n}}class OL{constructor(e,n,r){this.view=e,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(n),{options:s,selected:o}=i.open,a=e.state.facet(Cn);this.optionContent=mL(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=xp(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(n).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Cn).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Yl.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let r=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),r!=i){let{options:s,selected:o,disabled:a}=r.open;(!i.open||i.open.options!=s)&&(this.range=xp(s.length,o,e.state.facet(Cn).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),a!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=xp(n.options.length,n.selected,this.view.state.facet(Cn).maxRenderedOptions),this.showOptions(n.options,e.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let s=typeof i=="string"?document.createTextNode(i):i(r);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,r)}).catch(o=>Zn(this.view.state,o,"completion info")):this.addInfoPane(s,r)}}addInfoPane(e,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",e.nodeType!=null)r.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:s}=e;r.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==e?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&xL(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(Cn).positionInfo(this.view,n,i,r,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions"));let s=null;for(let o=r.from;o<r.to;o++){let{completion:a,match:l}=e[o],{section:c}=a;if(c){let d=typeof c=="string"?c:c.name;if(d!=s&&(o>r.from||r.from==0))if(s=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let h=i.appendChild(document.createElement("completion-section"));h.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let d of this.optionContent){let h=d(a,this.view.state,this.view,l);h&&u.appendChild(h)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function vL(t,e){return n=>new OL(n,t,e)}function xL(t,e){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=n.height/t.offsetHeight;r.top<n.top?t.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(t.scrollTop+=(r.bottom-n.bottom)/i)}function T1(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function yL(t,e){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let f=typeof u=="string"?u:u.name;r.some(d=>d.name==f)||r.push(typeof u=="string"?{name:f}:u)}},s=e.facet(Cn);for(let c of t)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)i(new P1(f,c.source,u?u(f):[],1e9-n.length));else{let f=e.sliceDoc(c.from,c.to),d,h=s.filterStrict?new pL(f):new hL(f);for(let p of c.result.options)if(d=h.match(p.label)){let O=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new P1(p,c.source,O,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,f=(d,h)=>{var p,O;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((O=h.rank)!==null&&O!==void 0?O:1e9)||(d.name<h.name?-1:1)};for(let d of r.sort(f))u-=1e5,c[d.name]=u;for(let d of n){let{section:h}=d.completion;h&&(d.score+=c[typeof h=="string"?h:h.name])}}let o=[],a=null,l=s.compareCompletions;for(let c of n.sort((u,f)=>f.score-u.score||l(u.completion,f.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?o.push(c):T1(c.completion)>T1(a)&&(o[o.length-1]=c),a=c.completion}return o}class Bo{constructor(e,n,r,i,s,o){this.options=e,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new Bo(this.options,$1(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,r,i,s){let o=yL(e,n);if(!o.length)return i&&e.some(l=>l.state==1)?new Bo(i.options,i.attrs,i.tooltip,i.timestamp,i.selected,!0):null;let a=n.facet(Cn).selectOnOpen?0:-1;if(i&&i.selected!=a&&i.selected!=-1){let l=i.options[i.selected].completion;for(let c=0;c<o.length;c++)if(o[c].completion==l){a=c;break}}return new Bo(o,$1(r,a),{pos:e.reduce((l,c)=>c.hasResult()?Math.min(l,c.from):l,1e8),create:kL,above:s.aboveCursor},i?i.timestamp:Date.now(),a,!1)}map(e){return new Bo(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class Hf{constructor(e,n,r){this.active=e,this.id=n,this.open=r}static start(){return new Hf(wL,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,r=n.facet(Cn),s=(r.override||n.languageDataAt("autocomplete",gs(n)).map(dL)).map(a=>(this.active.find(c=>c.source==a)||new Mn(a,this.active.some(c=>c.state!=0)?1:0)).update(e,r));s.length==this.active.length&&s.every((a,l)=>a==this.active[l])&&(s=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!bL(s,this.active)?o=Bo.build(s,n,this.id,o,r):o&&o.disabled&&!s.some(a=>a.state==1)&&(o=null),!o&&s.every(a=>a.state!=1)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new Mn(a.source,0):a));for(let a of e.effects)a.is(PI)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new Hf(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:SL}}function bL(t,e){if(t==e)return!0;for(let n=0,r=0;;){for(;n<t.length&&!t[n].hasResult;)n++;for(;r<e.length&&!e[r].hasResult;)r++;let i=n==t.length,s=r==e.length;if(i||s)return i==s;if(t[n++].result!=e[r++].result)return!1}}const SL={"aria-autocomplete":"list"};function $1(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const wL=[];function um(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(dv);if(n&&e.activateOnCompletion(n))return"input"}return t.isUserEvent("input.type")?"input":t.isUserEvent("delete.backward")?"delete":null}class Mn{constructor(e,n,r=-1){this.source=e,this.state=n,this.explicitPos=r}hasResult(){return!1}update(e,n){let r=um(e,n),i=this;r?i=i.handleUserEvent(e,r,n):e.docChanged?i=i.handleChange(e):e.selection&&i.state!=0&&(i=new Mn(i.source,0));for(let s of e.effects)if(s.is(Yf))i=new Mn(i.source,1,s.value?gs(e.state):-1);else if(s.is(Yl))i=new Mn(i.source,0);else if(s.is(AI))for(let o of s.value)o.source==i.source&&(i=o);return i}handleUserEvent(e,n,r){return n=="delete"||!r.activateOnTyping?this.map(e.changes):new Mn(this.source,1)}handleChange(e){return e.changes.touchesRange(gs(e.startState))?new Mn(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Mn(this.source,this.state,e.mapPos(this.explicitPos))}}class Ho extends Mn{constructor(e,n,r,i,s){super(e,2,n),this.result=r,this.from=i,this.to=s}hasResult(){return!0}handleUserEvent(e,n,r){var i;let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let o=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),l=gs(e.state);if((this.explicitPos<0?l<=o:l<this.from)||l>a||!s||n=="delete"&&gs(e.startState)==this.from)return new Mn(this.source,n=="input"&&r.activateOnTyping?1:0);let c=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return CL(s.validFor,e.state,o,a)?new Ho(this.source,c,s,o,a):s.update&&(s=s.update(s,o,a,new wI(e.state,l,c>=0)))?new Ho(this.source,c,s,s.from,(i=s.to)!==null&&i!==void 0?i:gs(e.state)):new Mn(this.source,1,c)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Mn(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Ho(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Mn(this.source,0)}}function CL(t,e,n,r){if(!t)return!1;let i=e.sliceDoc(n,r);return typeof t=="function"?t(i,n,r,e):kI(t,!0).test(i)}const AI=Ne.define({map(t,e){return t.map(n=>n.map(e))}}),PI=Ne.define(),Yn=ln.define({create(){return Hf.start()},update(t,e){return t.update(e)},provide:t=>[qO.from(t,e=>e.tooltip),de.contentAttributes.from(t,e=>e.attrs)]});function hv(t,e){const n=e.completion.apply||e.completion.label;let r=t.state.field(Yn).active.find(i=>i.source==e.source);return r instanceof Ho?(typeof n=="string"?t.dispatch(Object.assign(Object.assign({},fL(t.state,n,r.from,r.to)),{annotations:dv.of(e.completion)})):n(t,e.completion,r.from,r.to),!0):!1}const kL=vL(Yn,hv);function wu(t,e="option"){return n=>{let r=n.state.field(Yn,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Cn).interactionDelay)return!1;let i=1,s;e=="page"&&(s=a2(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(t?1:-1):t?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),n.dispatch({effects:PI.of(a)}),!0}}const EI=t=>{let e=t.state.field(Yn,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Cn).interactionDelay?!1:hv(t,e.open.options[e.open.selected])},AL=t=>t.state.field(Yn,!1)?(t.dispatch({effects:Yf.of(!0)}),!0):!1,PL=t=>{let e=t.state.field(Yn,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Yl.of(null)}),!0)};class EL{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const IL=50,TL=1e3,$L=Bt.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Yn).active)e.state==1&&this.startQuery(e)}update(t){let e=t.state.field(Yn),n=t.state.facet(Cn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Yn)==e)return;let r=t.transactions.some(s=>(s.selection||s.docChanged)&&!um(s,n));for(let s=0;s<this.running.length;s++){let o=this.running[s];if(r||o.updates.length+t.transactions.length>IL&&Date.now()-o.time>TL){for(let a of o.context.abortListeners)try{a()}catch(l){Zn(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(Yf)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.state==1&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of t.transactions)um(s,n)=="input"?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Yn);for(let n of e.active)n.state==1&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n)}startQuery(t){let{state:e}=this.view,n=gs(e),r=new wI(e,n,t.explicitPos==n),i=new EL(t,r);this.running.push(i),Promise.resolve(t.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Yl.of(null)}),Zn(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Cn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(Cn);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let o=new Ho(i.active.source,i.active.explicitPos,i.done,i.done.from,(t=i.done.to)!==null&&t!==void 0?t:gs(i.updates.length?i.updates[0].startState:this.view.state));for(let a of i.updates)o=o.update(a,n);if(o.hasResult()){e.push(o);continue}}let s=this.view.state.field(Yn).active.find(o=>o.source==i.active.source);if(s&&s.state==1)if(i.done==null){let o=new Mn(i.active.source,0);for(let a of i.updates)o=o.update(a,n);o.state!=1&&e.push(o)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:AI.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Yn,!1);if(e&&e.tooltip&&this.view.state.facet(Cn).closeOnBlur){let n=e.open&&a2(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Yl.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Yf.of(!1)}),20),this.composing=0}}}),RL=typeof navigator=="object"&&/Win/.test(navigator.platform),jL=wi.highest(de.domEventHandlers({keydown(t,e){let n=e.state.field(Yn,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(RL&&t.altKey)||t.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&hv(e,r),!1}})),II=de.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"},".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 DL{constructor(e,n,r,i){this.field=e,this.line=n,this.from=r,this.to=i}}class pv{constructor(e,n,r){this.field=e,this.from=n,this.to=r}map(e){let n=e.mapPos(this.from,-1,wn.TrackDel),r=e.mapPos(this.to,1,wn.TrackDel);return n==null||r==null?null:new pv(this.field,n,r)}}class gv{constructor(e,n){this.lines=e,this.fieldPositions=n}instantiate(e,n){let r=[],i=[n],s=e.doc.lineAt(n),o=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let f=0;f<u;f++)c+=e.facet(vc);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let a=this.fieldPositions.map(l=>new pv(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:a}}static parse(e){let n=[],r=[],i=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|([^}]*))\}/.exec(o);){let a=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1;for(let u=0;u<n.length;u++)(a!=null?n[u].seq==a:l&&n[u].name==l)&&(c=u);if(c<0){let u=0;for(;u<n.length&&(a==null||n[u].seq!=null&&n[u].seq<a);)u++;n.splice(u,0,{seq:a,name:l}),c=u;for(let f of i)f.field>=c&&f.field++}i.push(new DL(c,r.length,s.index,s.index+l.length)),o=o.slice(0,s.index)+l+o.slice(s.index+s[0].length)}for(let a;a=/\\([{}])/.exec(o);){o=o.slice(0,a.index)+a[1]+o.slice(a.index+a[0].length);for(let l of i)l.line==r.length&&l.from>a.index&&(l.from--,l.to--)}r.push(o)}return new gv(r,i)}}let _L=Se.widget({widget:new class extends Ai{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),BL=Se.mark({class:"cm-snippetField"});class Qa{constructor(e,n){this.ranges=e,this.active=n,this.deco=Se.set(e.map(r=>(r.from==r.to?_L:BL).range(r.from,r.to)))}map(e){let n=[];for(let r of this.ranges){let i=r.map(e);if(!i)return null;n.push(i)}return new Qa(n,this.active)}selectionInsideField(e){return e.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const Sc=Ne.define({map(t,e){return t&&t.map(e)}}),QL=Ne.define(),Hl=ln.define({create(){return null},update(t,e){for(let n of e.effects){if(n.is(Sc))return n.value;if(n.is(QL)&&t)return new Qa(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>de.decorations.from(t,e=>e?e.deco:Se.none)});function mv(t,e){return ie.create(t.filter(n=>n.field==e).map(n=>ie.range(n.from,n.to)))}function NL(t){let e=gv.parse(t);return(n,r,i,s)=>{let{text:o,ranges:a}=e.instantiate(n.state,i),l={changes:{from:i,to:s,insert:ot.of(o)},scrollIntoView:!0,annotations:r?[dv.of(r),Ut.userEvent.of("input.complete")]:void 0};if(a.length&&(l.selection=mv(a,0)),a.some(c=>c.field>0)){let c=new Qa(a,0),u=l.effects=[Sc.of(c)];n.state.field(Hl,!1)===void 0&&u.push(Ne.appendConfig.of([Hl,LL,VL,II]))}n.dispatch(n.state.update(l))}}function TI(t){return({state:e,dispatch:n})=>{let r=e.field(Hl,!1);if(!r||t<0&&r.active==0)return!1;let i=r.active+t,s=t>0&&!r.ranges.some(o=>o.field==i+t);return n(e.update({selection:mv(r.ranges,i),effects:Sc.of(s?null:new Qa(r.ranges,i)),scrollIntoView:!0})),!0}}const ML=({state:t,dispatch:e})=>t.field(Hl,!1)?(e(t.update({effects:Sc.of(null)})),!0):!1,FL=TI(1),ZL=TI(-1),WL=[{key:"Tab",run:FL,shift:ZL},{key:"Escape",run:ML}],R1=me.define({combine(t){return t.length?t[0]:WL}}),LL=wi.highest(Ta.compute([R1],t=>t.facet(R1)));function Un(t,e){return Object.assign(Object.assign({},e),{apply:NL(t)})}const VL=de.domEventHandlers({mousedown(t,e){let n=e.state.field(Hl,!1),r;if(!n||(r=e.posAtCoords({x:t.clientX,y:t.clientY}))==null)return!1;let i=n.ranges.find(s=>s.from<=r&&s.to>=r);return!i||i.field==n.active?!1:(e.dispatch({selection:mv(n.ranges,i.field),effects:Sc.of(n.ranges.some(s=>s.field>i.field)?new Qa(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Jl={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},zs=Ne.define({map(t,e){let n=e.mapPos(t,-1,wn.TrackAfter);return n??void 0}}),Ov=new class extends Hs{};Ov.startSide=1;Ov.endSide=-1;const $I=ln.define({create(){return et.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of e.effects)n.is(zs)&&(t=t.update({add:[Ov.range(n.value,n.value+1)]}));return t}});function zL(){return[GL,$I]}const yp="()[]{}<>";function RI(t){for(let e=0;e<yp.length;e+=2)if(yp.charCodeAt(e)==t)return yp.charAt(e+1);return QO(t<128?t:t+1)}function jI(t,e){return t.languageDataAt("closeBrackets",e)[0]||Jl}const XL=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),GL=de.inputHandler.of((t,e,n,r)=>{if((XL?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(r.length>2||r.length==2&&Ar(bn(r,0))==1||e!=i.from||n!=i.to)return!1;let s=YL(t.state,r);return s?(t.dispatch(s),!0):!1}),qL=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=jI(t,t.selection.main.head).brackets||Jl.brackets,i=null,s=t.changeByRange(o=>{if(o.empty){let a=HL(t.doc,o.head);for(let l of r)if(l==a&&Kd(t.doc,o.head)==RI(bn(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:ie.cursor(o.head-l.length)}}return{range:i=o}});return i||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},UL=[{key:"Backspace",run:qL}];function YL(t,e){let n=jI(t,t.selection.main.head),r=n.brackets||Jl.brackets;for(let i of r){let s=RI(bn(i,0));if(e==i)return s==i?eV(t,i,r.indexOf(i+i+i)>-1,n):JL(t,i,s,n.before||Jl.before);if(e==s&&DI(t,t.selection.main.from))return KL(t,i,s)}return null}function DI(t,e){let n=!1;return t.field($I).between(0,t.doc.length,r=>{r==e&&(n=!0)}),n}function Kd(t,e){let n=t.sliceString(e,e+2);return n.slice(0,Ar(bn(n,0)))}function HL(t,e){let n=t.sliceString(e-2,e);return Ar(bn(n,0))==n.length?n:n.slice(1)}function JL(t,e,n,r){let i=null,s=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:zs.of(o.to+e.length),range:ie.range(o.anchor+e.length,o.head+e.length)};let a=Kd(t.doc,o.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:e+n,from:o.head},effects:zs.of(o.head+e.length),range:ie.cursor(o.head+e.length)}:{range:i=o}});return i?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function KL(t,e,n){let r=null,i=t.changeByRange(s=>s.empty&&Kd(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:ie.cursor(s.head+n.length)}:r={range:s});return r?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function eV(t,e,n,r){let i=r.stringPrefixes||Jl.stringPrefixes,s=null,o=t.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:zs.of(a.to+e.length),range:ie.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=Kd(t.doc,l),u;if(c==e){if(j1(t,l))return{changes:{insert:e+e,from:l},effects:zs.of(l+e.length),range:ie.cursor(l+e.length)};if(DI(t,l)){let d=n&&t.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+d.length,insert:d},range:ie.cursor(l+d.length)}}}else{if(n&&t.sliceDoc(l-2*e.length,l)==e+e&&(u=D1(t,l-2*e.length,i))>-1&&j1(t,u))return{changes:{insert:e+e+e+e,from:l},effects:zs.of(l+e.length),range:ie.cursor(l+e.length)};if(t.charCategorizer(l)(c)!=jt.Word&&D1(t,l,i)>-1&&!tV(t,l,e,i))return{changes:{insert:e+e,from:l},effects:zs.of(l+e.length),range:ie.cursor(l+e.length)}}return{range:s=a}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function j1(t,e){let n=Dt(t).resolveInner(e+1);return n.parent&&n.from==e}function tV(t,e,n,r){let i=Dt(t).resolveInner(e,-1),s=r.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=t.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),l=a.indexOf(n);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(t.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function D1(t,e,n){let r=t.charCategorizer(e);if(r(t.sliceDoc(e-1,e))!=jt.Word)return e;for(let i of n){let s=e-i.length;if(t.sliceDoc(s,e)==i&&r(t.sliceDoc(s-1,s))!=jt.Word)return s}return-1}function nV(t={}){return[jL,Yn,Cn.of(t),$L,rV,II]}const _I=[{key:"Ctrl-Space",run:AL},{key:"Escape",run:PL},{key:"ArrowDown",run:wu(!0)},{key:"ArrowUp",run:wu(!1)},{key:"PageDown",run:wu(!0,"page")},{key:"PageUp",run:wu(!1,"page")},{key:"Enter",run:EI}],rV=wi.highest(Ta.computeN([Cn],t=>t.facet(Cn).defaultKeymap?[_I]:[]));class iV{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Vs{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=e,s=r.facet(cs).markerFilter;s&&(i=s(i,r));let o=Se.set(i.map(a=>a.from==a.to||a.from==a.to-1&&r.doc.lineAt(a.from).to==a.from?Se.widget({widget:new gV(a),diagnostic:a}).range(a.from):Se.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity+(a.markClass?" "+a.markClass:"")},diagnostic:a,inclusive:!0}).range(a.from,a.to)),!0);return new Vs(o,n,da(o))}}function da(t,e=null,n=0){let r=null;return t.between(n,1e9,(i,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return r=new iV(i,s,o.diagnostic),!1}),r}function sV(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(cs).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(vv))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function BI(t,e){return t.field(gr,!1)?e:e.concat(Ne.appendConfig.of(FI))}function oV(t,e){return{effects:BI(t,[vv.of(e)])}}const vv=Ne.define(),xv=Ne.define(),QI=Ne.define(),gr=ln.define({create(){return new Vs(Se.none,null,null)},update(t,e){if(e.docChanged){let n=t.diagnostics.map(e.changes),r=null;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);r=da(n,t.selected.diagnostic,i)||da(n,null,i)}t=new Vs(n,t.panel,r)}for(let n of e.effects)n.is(vv)?t=Vs.init(n.value,t.panel,e.state):n.is(xv)?t=new Vs(t.diagnostics,n.value?eh.open:null,t.selected):n.is(QI)&&(t=new Vs(t.diagnostics,t.panel,n.value));return t},provide:t=>[zl.from(t,e=>e.panel),de.decorations.from(t,e=>e.diagnostics)]}),aV=Se.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function lV(t,e,n){let{diagnostics:r}=t.state.field(gr),i=[],s=2e8,o=0;r.between(e-(n<0?1:0),e+(n>0?1:0),(l,c,{spec:u})=>{e>=l&&e<=c&&(l==c||(e>l||n>0)&&(e<c||n<0))&&(i.push(u.diagnostic),s=Math.min(l,s),o=Math.max(c,o))});let a=t.state.facet(cs).tooltipFilter;return a&&(i=a(i,t.state)),i.length?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:cV(t,i)}}}:null}function cV(t,e){return At("ul",{class:"cm-tooltip-lint"},e.map(n=>MI(t,n,!1)))}const uV=t=>{let e=t.state.field(gr,!1);(!e||!e.panel)&&t.dispatch({effects:BI(t.state,[xv.of(!0)])});let n=Vl(t,eh.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},_1=t=>{let e=t.state.field(gr,!1);return!e||!e.panel?!1:(t.dispatch({effects:xv.of(!1)}),!0)},fV=t=>{let e=t.state.field(gr,!1);if(!e)return!1;let n=t.state.selection.main,r=e.diagnostics.iter(n.to+1);return!r.value&&(r=e.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},dV=[{key:"Mod-Shift-m",run:uV,preventDefault:!0},{key:"F8",run:fV}],hV=Bt.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(cs);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:e}=this.view,{sources:n}=e.facet(cs);n.length&&Promise.all(n.map(r=>Promise.resolve(r(this.view)))).then(r=>{let i=r.reduce((s,o)=>s.concat(o));this.view.state.doc==e.doc&&this.view.dispatch(oV(this.view.state,i))},r=>{Zn(this.view.state,r)})}}update(t){let e=t.state.facet(cs);(t.docChanged||e!=t.startState.facet(cs)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),cs=me.define({combine(t){return Object.assign({sources:t.map(e=>e.source).filter(e=>e!=null)},ki(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n}))}});function pV(t,e={}){return[cs.of({source:t,config:e}),hV,FI]}function NI(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let i=n[r];if(/[a-zA-Z]/.test(i)&&!e.some(s=>s.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function MI(t,e,n){var r;let i=n?NI(e.actions):[];return At("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},At("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let h=da(t.state.field(gr).diagnostics,e);h&&s.apply(t,h.from,h.to)},{name:c}=s,u=i[o]?c.indexOf(i[o]):-1,f=u<0?c:[c.slice(0,u),At("u",c.slice(u,u+1)),c.slice(u+1)];return At("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&At("div",{class:"cm-diagnosticSource"},e.source))}class gV extends Ai{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return At("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class B1{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=MI(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class eh{constructor(e){this.view=e,this.items=[];let n=i=>{if(i.keyCode==27)_1(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=NI(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=da(this.view.state.field(gr).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;i.preventDefault()},r=i=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(i.target)&&this.moveSelection(s)};this.list=At("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=At("div",{class:"cm-panel-lint"},this.list,At("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>_1(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(gr).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(gr),r=0,i=!1,s=null;for(e.between(0,this.view.state.doc.length,(o,a,{spec:l})=>{let c=-1,u;for(let f=r;f<this.items.length;f++)if(this.items[f].diagnostic==l.diagnostic){c=f;break}c<0?(u=new B1(this.view,l.diagnostic),this.items.splice(r,0,u),i=!0):(u=this.items[c],c>r&&(this.items.splice(r,c-r),i=!0)),n&&u.diagnostic==n.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),r++});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new B1(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:a})=>{let l=a.height/this.list.offsetHeight;o.top<a.top?this.list.scrollTop-=(a.top-o.top)/l:o.bottom>a.bottom&&(this.list.scrollTop+=(o.bottom-a.bottom)/l)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(gr),r=da(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:QI.of(r)})}static open(e){return new eh(e)}}function mV(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Cu(t){return mV(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const OV=de.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Cu("#d11")},".cm-lintRange-warning":{backgroundImage:Cu("orange")},".cm-lintRange-info":{backgroundImage:Cu("#999")},".cm-lintRange-hint":{backgroundImage:Cu("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),FI=[gr,de.decorations.compute([gr],t=>{let{selected:e,panel:n}=t.field(gr);return!e||!n||e.from==e.to?Se.none:Se.set([aV.range(e.from,e.to)])}),tZ(lV,{hideOn:sV}),OV];var Q1=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,r=[];e.closeBracketsKeymap!==!1&&(r=r.concat(UL)),e.defaultKeymap!==!1&&(r=r.concat(j6)),e.searchKeymap!==!1&&(r=r.concat(sL)),e.historyKeymap!==!1&&(r=r.concat(WW)),e.foldKeymap!==!1&&(r=r.concat(rW)),e.completionKeymap!==!1&&(r=r.concat(_I)),e.lintKeymap!==!1&&(r=r.concat(dV));var i=[];return e.lineNumbers!==!1&&i.push(uZ()),e.highlightActiveLineGutter!==!1&&i.push(hZ()),e.highlightSpecialChars!==!1&&i.push(T8()),e.history!==!1&&i.push(jW()),e.foldGutter!==!1&&i.push(aW()),e.drawSelection!==!1&&i.push(y8()),e.dropCursor!==!1&&i.push(k8()),e.allowMultipleSelections!==!1&&i.push(Ye.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(qZ()),e.syntaxHighlighting!==!1&&i.push(rv(fW,{fallback:!0})),e.bracketMatching!==!1&&i.push(vW()),e.closeBrackets!==!1&&i.push(zL()),e.autocompletion!==!1&&i.push(nV()),e.rectangularSelection!==!1&&i.push(V8()),n!==!1&&i.push(G8()),e.highlightActiveLine!==!1&&i.push(B8()),e.highlightSelectionMatches!==!1&&i.push(F6()),e.tabSize&&typeof e.tabSize=="number"&&i.push(vc.of(" ".repeat(e.tabSize))),i.concat([Ta.of(r.flat())]).filter(Boolean)};const vV="#e5c07b",N1="#e06c75",xV="#56b6c2",yV="#ffffff",Uu="#abb2bf",fm="#7d8799",bV="#61afef",SV="#98c379",M1="#d19a66",wV="#c678dd",CV="#21252b",F1="#2c313a",Z1="#282c34",bp="#353a42",kV="#3E4451",W1="#528bff",AV=de.theme({"&":{color:Uu,backgroundColor:Z1},".cm-content":{caretColor:W1},".cm-cursor, .cm-dropCursor":{borderLeftColor:W1},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:kV},".cm-panels":{backgroundColor:CV,color:Uu},".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:Z1,color:fm,border:"none"},".cm-activeLineGutter":{backgroundColor:F1},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:bp},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:bp,borderBottomColor:bp},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:F1,color:Uu}}},{dark:!0}),PV=Da.define([{tag:I.keyword,color:wV},{tag:[I.name,I.deleted,I.character,I.propertyName,I.macroName],color:N1},{tag:[I.function(I.variableName),I.labelName],color:bV},{tag:[I.color,I.constant(I.name),I.standard(I.name)],color:M1},{tag:[I.definition(I.name),I.separator],color:Uu},{tag:[I.typeName,I.className,I.number,I.changed,I.annotation,I.modifier,I.self,I.namespace],color:vV},{tag:[I.operator,I.operatorKeyword,I.url,I.escape,I.regexp,I.link,I.special(I.string)],color:xV},{tag:[I.meta,I.comment],color:fm},{tag:I.strong,fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.link,color:fm,textDecoration:"underline"},{tag:I.heading,fontWeight:"bold",color:N1},{tag:[I.atom,I.bool,I.special(I.variableName)],color:M1},{tag:[I.processingInstruction,I.string,I.inserted],color:SV},{tag:I.invalid,color:yV}]),EV=[AV,rv(PV)];var IV=de.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),TV=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:r=!0,readOnly:i=!1,theme:s="light",placeholder:o="",basicSetup:a=!0}=e,l=[];switch(n&&l.unshift(Ta.of([D6])),a&&(typeof a=="boolean"?l.unshift(Q1()):l.unshift(Q1(a))),o&&l.unshift(F8(o)),s){case"light":l.push(IV);break;case"dark":l.push(EV);break;case"none":break;default:l.push(s);break}return r===!1&&l.push(de.editable.of(!1)),i&&l.push(Ye.readOnly.of(!0)),[...l]},$V=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)}),L1=Ci.define(),RV=[];function jV(t){var{value:e,selection:n,onChange:r,onStatistics:i,onCreateEditor:s,onUpdate:o,extensions:a=RV,autoFocus:l,theme:c="light",height:u=null,minHeight:f=null,maxHeight:d=null,width:h=null,minWidth:p=null,maxWidth:O=null,placeholder:g="",editable:x=!0,readOnly:v=!1,indentWithTab:y=!0,basicSetup:b=!0,root:S,initialState:w}=t,[C,k]=D.useState(),[P,A]=D.useState(),[E,$]=D.useState(),R=de.theme({"&":{height:u,minHeight:f,maxHeight:d,width:h,minWidth:p,maxWidth:O},"& .cm-scroller":{height:"100% !important"}}),Q=de.updateListener.of(G=>{if(G.docChanged&&typeof r=="function"&&!G.transactions.some(q=>q.annotation(L1))){var L=G.state.doc,U=L.toString();r(U,G)}i&&i($V(G))}),_=TV({theme:c,editable:x,readOnly:v,placeholder:g,indentWithTab:y,basicSetup:b}),Z=[Q,R,..._];return o&&typeof o=="function"&&Z.push(de.updateListener.of(o)),Z=Z.concat(a),D.useEffect(()=>{if(C&&!E){var G={doc:e,selection:n,extensions:Z},L=w?Ye.fromJSON(w.json,G,w.fields):Ye.create(G);if($(L),!P){var U=new de({state:L,parent:C,root:S});A(U),s&&s(U,L)}}return()=>{P&&($(void 0),A(void 0))}},[C,E]),D.useEffect(()=>k(t.container),[t.container]),D.useEffect(()=>()=>{P&&(P.destroy(),A(void 0))},[P]),D.useEffect(()=>{l&&P&&P.focus()},[l,P]),D.useEffect(()=>{P&&P.dispatch({effects:Ne.reconfigure.of(Z)})},[c,a,u,f,d,h,p,O,g,x,v,y,b,r,o]),D.useEffect(()=>{if(e!==void 0){var G=P?P.state.doc.toString():"";P&&e!==G&&P.dispatch({changes:{from:0,to:G.length,insert:e||""},annotations:[L1.of(!0)]})}},[e,P]),{state:E,setState:$,view:P,setView:A,container:C,setContainer:k}}var DV=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],ZI=D.forwardRef((t,e)=>{var{className:n,value:r="",selection:i,extensions:s=[],onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:c,autoFocus:u,theme:f="light",height:d,minHeight:h,maxHeight:p,width:O,minWidth:g,maxWidth:x,basicSetup:v,placeholder:y,indentWithTab:b,editable:S,readOnly:w,root:C,initialState:k}=t,P=Dk(t,DV),A=D.useRef(null),{state:E,view:$,container:R}=jV({container:A.current,root:C,value:r,autoFocus:u,theme:f,height:d,minHeight:h,maxHeight:p,width:O,minWidth:g,maxWidth:x,basicSetup:v,placeholder:y,indentWithTab:b,editable:S,readOnly:w,selection:i,onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:c,extensions:s,initialState:k});if(D.useImperativeHandle(e,()=>({editor:A.current,state:E,view:$}),[A,R,E,$]),typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var Q=typeof f=="string"?"cm-theme-"+f:"cm-theme";return m.jsx("div",ke({ref:A,className:""+Q+(n?" "+n:"")},P))});ZI.displayName="CodeMirror";function Jf(){return Jf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Jf.apply(null,arguments)}var WI=t=>{var{theme:e,settings:n={},styles:r=[]}=t,i={".cm-gutters":{}},s={};n.background&&(s.backgroundColor=n.background),n.backgroundImage&&(s.backgroundImage=n.backgroundImage),n.foreground&&(s.color=n.foreground),n.fontSize&&(s.fontSize=n.fontSize),(n.background||n.foreground)&&(i["&"]=s),n.fontFamily&&(i["&.cm-editor .cm-scroller"]={fontFamily:n.fontFamily}),n.gutterBackground&&(i[".cm-gutters"].backgroundColor=n.gutterBackground),n.gutterForeground&&(i[".cm-gutters"].color=n.gutterForeground),n.gutterBorder&&(i[".cm-gutters"].borderRightColor=n.gutterBorder),n.caret&&(i[".cm-content"]={caretColor:n.caret},i[".cm-cursor, .cm-dropCursor"]={borderLeftColor:n.caret});var o={};n.gutterActiveForeground&&(o.color=n.gutterActiveForeground),n.lineHighlight&&(i[".cm-activeLine"]={backgroundColor:n.lineHighlight},o.backgroundColor=n.lineHighlight),i[".cm-activeLineGutter"]=o,n.selection&&(i["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:n.selection+" !important"}),n.selectionMatch&&(i["& .cm-selectionMatch"]={backgroundColor:n.selectionMatch});var a=de.theme(i,{dark:e==="dark"}),l=Da.define(r),c=[a,rv(l)];return c},_V={background:"#2e3235",foreground:"#bdbdbd",caret:"#a0a4ae",selection:"#d7d4f063",selectionMatch:"#d7d4f063",gutterBackground:"#2e3235",gutterForeground:"#999",gutterActiveForeground:"#4f5b66",lineHighlight:"#545b6130"},yv=t=>{var{theme:e="dark",settings:n={},styles:r=[]}=t||{};return WI({theme:e,settings:Jf({},_V,n),styles:[{tag:I.keyword,color:"#cf6edf"},{tag:[I.name,I.deleted,I.character,I.macroName],color:"#56c8d8"},{tag:[I.propertyName],color:"#facf4e"},{tag:[I.variableName],color:"#bdbdbd"},{tag:[I.function(I.variableName)],color:"#56c8d8"},{tag:[I.labelName],color:"#cf6edf"},{tag:[I.color,I.constant(I.name),I.standard(I.name)],color:"#facf4e"},{tag:[I.definition(I.name),I.separator],color:"#fa5788"},{tag:[I.brace],color:"#cf6edf"},{tag:[I.annotation],color:"#ff5f52"},{tag:[I.number,I.changed,I.annotation,I.modifier,I.self,I.namespace],color:"#ffad42"},{tag:[I.typeName,I.className],color:"#ffad42"},{tag:[I.operator,I.operatorKeyword],color:"#7186f0"},{tag:[I.tagName],color:"#99d066"},{tag:[I.squareBracket],color:"#ff5f52"},{tag:[I.angleBracket],color:"#606f7a"},{tag:[I.attributeName],color:"#bdbdbd"},{tag:[I.regexp],color:"#ff5f52"},{tag:[I.quote],color:"#6abf69"},{tag:[I.string],color:"#99d066"},{tag:I.link,color:"#56c8d8",textDecoration:"underline",textUnderlinePosition:"under"},{tag:[I.url,I.escape,I.special(I.string)],color:"#facf4e"},{tag:[I.meta],color:"#707d8b"},{tag:[I.comment],color:"#707d8b",fontStyle:"italic"},{tag:I.monospace,color:"#bdbdbd"},{tag:I.strong,fontWeight:"bold",color:"#ff5f52"},{tag:I.emphasis,fontStyle:"italic",color:"#99d066"},{tag:I.strikethrough,textDecoration:"line-through"},{tag:I.heading,fontWeight:"bold",color:"#facf4e"},{tag:I.heading1,fontWeight:"bold",color:"#facf4e"},{tag:[I.heading2,I.heading3,I.heading4],fontWeight:"bold",color:"#facf4e"},{tag:[I.heading5,I.heading6],color:"#facf4e"},{tag:[I.atom,I.bool,I.special(I.variableName)],color:"#56c8d8"},{tag:[I.processingInstruction,I.inserted],color:"#ff5f52"},{tag:[I.contentSeparator],color:"#56c8d8"},{tag:I.invalid,color:"#606f7a",borderBottom:"1px dotted #ff5f52"},...r]})},BV=yv;yv();yv();var QV={background:"#FAFAFA",foreground:"#90A4AE",caret:"#272727",selection:"#80CBC440",selectionMatch:"#80CBC440",gutterBackground:"#FAFAFA",gutterForeground:"#90A4AE",gutterBorder:"transparent",lineHighlight:"#CCD7DA50"},dm=t=>{var{theme:e="light",settings:n={},styles:r=[]}=t||{};return WI({theme:e,settings:Jf({},QV,n),styles:[{tag:I.keyword,color:"#39ADB5"},{tag:[I.name,I.deleted,I.character,I.macroName],color:"#90A4AE"},{tag:[I.propertyName],color:"#6182B8"},{tag:[I.processingInstruction,I.string,I.inserted,I.special(I.string)],color:"#91B859"},{tag:[I.function(I.variableName),I.labelName],color:"#6182B8"},{tag:[I.color,I.constant(I.name),I.standard(I.name)],color:"#39ADB5"},{tag:[I.definition(I.name),I.separator],color:"#90A4AE"},{tag:[I.className],color:"#E2931D"},{tag:[I.number,I.changed,I.annotation,I.modifier,I.self,I.namespace],color:"#F76D47"},{tag:[I.typeName],color:"#E2931D",fontStyle:"#E2931D"},{tag:[I.operator,I.operatorKeyword],color:"#39ADB5"},{tag:[I.url,I.escape,I.regexp,I.link],color:"#91B859"},{tag:[I.meta,I.comment],color:"#90A4AE"},{tag:I.strong,fontWeight:"bold"},{tag:I.emphasis,fontStyle:"italic"},{tag:I.link,textDecoration:"underline"},{tag:I.heading,fontWeight:"bold",color:"#39ADB5"},{tag:[I.atom,I.bool,I.special(I.variableName)],color:"#90A4AE"},{tag:I.invalid,color:"#E5393570"},{tag:I.strikethrough,textDecoration:"line-through"},...r]})};dm();function NV(t){const e={settings:{background:"var(--bg-color-tonal)",fontFamily:"var(--code-block-font-family)"},styles:[{tag:[I.propertyName],color:"var(--code-block-tokens-property-string-color)"},{tag:[I.processingInstruction,I.string,I.inserted,I.special(I.string)],color:"var(--code-block-tokens-string-color)"},{tag:[I.atom,I.bool,I.special(I.variableName)],color:"var(--text-color-secondary)"}]};switch(t){case"light":return dm(e);case"dark":return BV(e);default:return dm(e)}}const LI=Ne.define();function Kf({dataTestId:t,...e}){const n=Re(),r=an(),{stateExtensions:i}=e,s=D.useRef(null),[o,a]=D.useState(!1),l=D.useMemo(()=>i?i.map(c=>wi.highest(c({selectedEnvironment:r,state:n}))):[],[i,r,n]);return D.useEffect(()=>{var u;const c=(u=s.current)==null?void 0:u.view;c&&c.dispatch({effects:LI.of()})},[n.environments,r]),m.jsx(MV,{"data-testid":t,onClick:()=>a(!0),children:m.jsx(ZI,{autoFocus:o,className:"codemirror-container",ref:s,theme:NV("light"),basicSetup:{bracketMatching:!0,closeBrackets:!0,tabSize:2,foldGutter:!1,lineNumbers:!0,lintKeymap:!0,drawSelection:!1},onBlur:()=>a(!1),...e,extensions:[...l,...e.extensions||[]]})})}const MV=T.div`
|
|
678
678
|
.cm-content {
|
|
679
679
|
background-color: var(--bg-color);
|
|
680
680
|
caret-color: var(--code-block-text-color);
|
package/dist/replay.js
CHANGED
|
@@ -33974,11 +33974,10 @@ function yd() {
|
|
|
33974
33974
|
return yd = Object.assign ? Object.assign.bind() : function(t) {
|
|
33975
33975
|
for (var e = 1; e < arguments.length; e++) {
|
|
33976
33976
|
var n = arguments[e];
|
|
33977
|
-
for (var r in n)
|
|
33978
|
-
Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
|
|
33977
|
+
for (var r in n) ({}).hasOwnProperty.call(n, r) && (t[r] = n[r]);
|
|
33979
33978
|
}
|
|
33980
33979
|
return t;
|
|
33981
|
-
}, yd.apply(
|
|
33980
|
+
}, yd.apply(null, arguments);
|
|
33982
33981
|
}
|
|
33983
33982
|
var _I = (t) => {
|
|
33984
33983
|
var {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/replay",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/replay.cjs",
|
|
6
6
|
"module": "./dist/replay.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
20
20
|
"react-router-dom": "^6.21.1",
|
|
21
21
|
"styled-components": "^5.3.11",
|
|
22
|
-
"@redocly/theme": "0.45.
|
|
22
|
+
"@redocly/theme": "0.45.1"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@codemirror/autocomplete": "^6.15.0",
|