cognitune 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +2 -0
- package/SETUP.md +111 -0
- package/dist/cli.js +153 -14
- package/dist/web/assets/{Map-DyU40kFC.js → Map-pFoOaroM.js} +1 -1
- package/dist/web/assets/{Practice-Xw4Aap9n.js → Practice-DJ_GeEEw.js} +3 -3
- package/dist/web/assets/{_baseUniq-Sb6_kXmC.js → _baseUniq-Cgcxu-ug.js} +1 -1
- package/dist/web/assets/{architectureDiagram-UYN6MBPD-x3eTjV-t.js → architectureDiagram-UYN6MBPD-F11egvO5.js} +1 -1
- package/dist/web/assets/{blockDiagram-ZHA2E4KO-agwz5ZWE.js → blockDiagram-ZHA2E4KO-DcLwUr6e.js} +1 -1
- package/dist/web/assets/{c4Diagram-6F5ED5ID-CJxB9Ung.js → c4Diagram-6F5ED5ID-DoK6LsEW.js} +1 -1
- package/dist/web/assets/channel-cS78OL1L.js +1 -0
- package/dist/web/assets/{chunk-5HRBRIJM-f0vN99nH.js → chunk-5HRBRIJM-BZZC4mrX.js} +1 -1
- package/dist/web/assets/{chunk-7U56Z5CX-BM--ABPc.js → chunk-7U56Z5CX-CRQL1BaD.js} +1 -1
- package/dist/web/assets/{chunk-ASOPGD6M-CR8uj1YE.js → chunk-ASOPGD6M-MyeXPUAo.js} +1 -1
- package/dist/web/assets/{chunk-KFBOBJHC-5IsURXrq.js → chunk-KFBOBJHC-ivtJnQTl.js} +1 -1
- package/dist/web/assets/{chunk-T2TOU4HS-Byx0enoR.js → chunk-T2TOU4HS-DfaWwXAy.js} +1 -1
- package/dist/web/assets/{chunk-TMUBEWPD-BIF411CX.js → chunk-TMUBEWPD-1vGEp44G.js} +1 -1
- package/dist/web/assets/classDiagram-LNE6IOMH-BV-X_A98.js +1 -0
- package/dist/web/assets/classDiagram-v2-MQ7JQ4JX-BV-X_A98.js +1 -0
- package/dist/web/assets/clone-CX7XQP1C.js +1 -0
- package/dist/web/assets/{dagre-4EVJKHTY-1RD8lskl.js → dagre-4EVJKHTY-BzJqGMK1.js} +1 -1
- package/dist/web/assets/{diagram-QW4FP2JN-PO1Q65My.js → diagram-QW4FP2JN-DserUmhH.js} +1 -1
- package/dist/web/assets/{erDiagram-6RL3IURR-Cr2hBiWe.js → erDiagram-6RL3IURR-BeMwcZZW.js} +1 -1
- package/dist/web/assets/{flowDiagram-7ASYPVHJ-ClDedrj1.js → flowDiagram-7ASYPVHJ-C2Qt1H4b.js} +1 -1
- package/dist/web/assets/{ganttDiagram-NTVNEXSI-D13tzRyI.js → ganttDiagram-NTVNEXSI-DjG6T96W.js} +1 -1
- package/dist/web/assets/{gitGraph-YCYPL57B-BsavMmM6.js → gitGraph-YCYPL57B-C92c8R4j.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-NRZ2UAAF-DIucBoe8.js → gitGraphDiagram-NRZ2UAAF-C0OK2-pl.js} +1 -1
- package/dist/web/assets/{graph-CClVjaHZ.js → graph-jcgmh1Ot.js} +1 -1
- package/dist/web/assets/{index-Cv-pFH6x.js → index-B05Rh3LW.js} +1 -1
- package/dist/web/assets/{index-D91GOqgw.js → index-BD8q1ij7.js} +1 -1
- package/dist/web/assets/{index-Dls_C4WS.js → index-BJepU7_w.js} +1 -1
- package/dist/web/assets/{index-CS1X9Gl5.js → index-BPFm8xBn.js} +1 -1
- package/dist/web/assets/{index-DBSUkj1m.js → index-BTAmHv-d.js} +1 -1
- package/dist/web/assets/index-Bs71achu.js +509 -0
- package/dist/web/assets/{index-DUIbUB4M.js → index-BtCLkneo.js} +1 -1
- package/dist/web/assets/{index-DkYraAal.js → index-CW1WHdXq.js} +1 -1
- package/dist/web/assets/{index-DDrV_F4m.js → index-CfFkiEw9.js} +1 -1
- package/dist/web/assets/{index-SjGg9_vE.js → index-D-9XGv5u.js} +1 -1
- package/dist/web/assets/{index-o9r5KATO.js → index-D3Zk0Btz.js} +1 -1
- package/dist/web/assets/{index-2r9n9DTs.js → index-D5AcpGl_.js} +1 -1
- package/dist/web/assets/{index-D45gW5O5.js → index-D8PR6AHG.js} +1 -1
- package/dist/web/assets/{index-DRtWlWMo.js → index-DB9Tltht.js} +1 -1
- package/dist/web/assets/{index-B_vWzZYC.js → index-DIV7qBvA.js} +1 -1
- package/dist/web/assets/{index-CMZRuo_o.js → index-DJ7YtDlC.js} +1 -1
- package/dist/web/assets/{index-ByIxB7D0.js → index-DM-V8yrZ.js} +1 -1
- package/dist/web/assets/index-DajatLhQ.css +1 -0
- package/dist/web/assets/{index-DxsK976j.js → index-DgTHE4KH.js} +1 -1
- package/dist/web/assets/{index-B3eGs35g.js → index-DgVZUoYY.js} +1 -1
- package/dist/web/assets/{index-BqYXODG4.js → index-H4qir-5V.js} +1 -1
- package/dist/web/assets/{index-eIlS8nUF.js → index-HBtEhFV8.js} +1 -1
- package/dist/web/assets/{index-BOSsA0NJ.js → index-TRTMCU2f.js} +1 -1
- package/dist/web/assets/{index-6LcRt5Lv.js → index-a7yJqPRD.js} +1 -1
- package/dist/web/assets/{infoDiagram-A4XQUW5V-DAnVWlAh.js → infoDiagram-A4XQUW5V-DqkPyvzP.js} +1 -1
- package/dist/web/assets/{journeyDiagram-G5WM74LC-pfkLfgwO.js → journeyDiagram-G5WM74LC-CPoGO9lU.js} +1 -1
- package/dist/web/assets/{kanban-definition-QRCXZQQD-ntmo18GF.js → kanban-definition-QRCXZQQD-DhYcbXpZ.js} +1 -1
- package/dist/web/assets/{layout-B4CWy8Hm.js → layout-D3h_RNbG.js} +1 -1
- package/dist/web/assets/{mermaid.core-lBUDS75V.js → mermaid.core-QonkHgY_.js} +4 -4
- package/dist/web/assets/{min-DbZdLDS_.js → min-u5yV8FH_.js} +1 -1
- package/dist/web/assets/{mindmap-definition-GWI6TPTV-Bl9WyGjM.js → mindmap-definition-GWI6TPTV-7qne4US6.js} +1 -1
- package/dist/web/assets/{pieDiagram-YF2LJOPJ-DnH09lh-.js → pieDiagram-YF2LJOPJ-CYjuzLxS.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-OS5C2QUG-BxEAU4LU.js → quadrantDiagram-OS5C2QUG-iNs3hmmI.js} +1 -1
- package/dist/web/assets/{requirementDiagram-MIRIMTAZ-QAvHb6Mc.js → requirementDiagram-MIRIMTAZ-tDYOd2xQ.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-Y46BX6SQ-eS48EBnq.js → sankeyDiagram-Y46BX6SQ-Ce34Wa1G.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-G6AWOVSC-CzMqlsbJ.js → sequenceDiagram-G6AWOVSC-i7VCqMq3.js} +1 -1
- package/dist/web/assets/{stateDiagram-MAYHULR4-xkap43Xx.js → stateDiagram-MAYHULR4-BSREATU6.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-4JROLMXI-CtOZAypx.js +1 -0
- package/dist/web/assets/{timeline-definition-U7ZMHBDA-BAuokBbp.js → timeline-definition-U7ZMHBDA-DgAweJ73.js} +1 -1
- package/dist/web/assets/{xychartDiagram-6QU3TZC5-Cnc3AQRt.js → xychartDiagram-6QU3TZC5-DxWMJtPc.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +2 -1
- package/dist/web/assets/channel-BBLQ9UF8.js +0 -1
- package/dist/web/assets/classDiagram-LNE6IOMH-BtyOxYYt.js +0 -1
- package/dist/web/assets/classDiagram-v2-MQ7JQ4JX-BtyOxYYt.js +0 -1
- package/dist/web/assets/clone-qT-pKr2u.js +0 -1
- package/dist/web/assets/index-Biw9rLAa.css +0 -1
- package/dist/web/assets/index-ChTnBaTd.js +0 -493
- package/dist/web/assets/stateDiagram-v2-4JROLMXI-T7PcvgVe.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
var yu=Object.defineProperty;var bu=(n,e,t)=>e in n?yu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var nl=(n,e,t)=>bu(n,typeof e!="symbol"?e+"":e,t);import{f as rh,r as Y,j as _,_ as b,h as vu,u as wu,i as ku,a as Su,k as Cu,l as Au,b as Mu,S as sl,E as Tu,C as Eu,m as Du,L as Ou,A as Lu,B as _u,n as Pu,V as Ru,o as Iu,p as Vs,J as Bu,q as Nu,v as wn,w as Vu,x as Wu,R as Fu,y as Hu,T as ju,d as Ws,z as zu,D as qu,G as rl,e as $u}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-HBtEhFV8.js","assets/index-BD8q1ij7.js","assets/index-Bs71achu.js","assets/index-DajatLhQ.css","assets/index-CfFkiEw9.js","assets/index-DgTHE4KH.js","assets/index-D5AcpGl_.js","assets/index-DB9Tltht.js","assets/index-D-9XGv5u.js","assets/index-D3Zk0Btz.js","assets/index-TRTMCU2f.js","assets/index-BTAmHv-d.js","assets/index-a7yJqPRD.js","assets/index-BPFm8xBn.js","assets/index-B05Rh3LW.js","assets/index-CW1WHdXq.js","assets/index-H4qir-5V.js","assets/index-BtCLkneo.js","assets/index-D8PR6AHG.js","assets/index-BJepU7_w.js","assets/index-DgVZUoYY.js","assets/dockerfile-BKs6k2Af.js","assets/simple-mode-GW_nhZxv.js","assets/factor-kuTfRLto.js","assets/nsis-LY0VT_u5.js","assets/pug-DukmZTjD.js","assets/javascript-qCveANmP.js","assets/index-DJ7YtDlC.js","assets/index-DIV7qBvA.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var yu=Object.defineProperty;var bu=(n,e,t)=>e in n?yu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var nl=(n,e,t)=>bu(n,typeof e!="symbol"?e+"":e,t);import{f as rh,r as Y,j as _,_ as b,h as vu,u as wu,i as ku,a as Su,k as Cu,l as Au,b as Mu,S as sl,E as Tu,C as Eu,m as Du,L as Ou,A as Lu,B as _u,n as Pu,V as Ru,o as Iu,p as Vs,J as Bu,q as Nu,v as wn,w as Vu,x as Wu,R as Fu,y as Hu,T as ju,d as Ws,z as zu,D as qu,G as rl,e as $u}from"./index-Bs71achu.js";/**
|
|
3
3
|
* @license lucide-react v0.468.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -22,4 +22,4 @@ var yu=Object.defineProperty;var bu=(n,e,t)=>e in n?yu(n,e,{enumerable:!0,config
|
|
|
22
22
|
--\u2028\u2029\uFEFF-]`,Xr),gm={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 Qs=null;function xm(){var n;if(Qs==null&&typeof document<"u"&&document.body){let e=document.body.style;Qs=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Qs||!1}const Jn=P.define({combine(n){let e=xt(n,{render:null,specialChars:mm,addSpecialChars:null});return(e.replaceTabs=!xm())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Xr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Xr)),e}});function ym(n={}){return[Jn.of(n),bm()]}let Jl=null;function bm(){return Jl||(Jl=le.fromClass(class{constructor(n){this.view=n,this.decorations=N.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Jn)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new pm({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=_e(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=Mi(o.text,l,i-o.from);return N.replace({widget:new Sm((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=N.replace({widget:new km(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Jn);n.startState.facet(Jn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const vm="•";function wm(n){return n>=32?vm:n==10?"":String.fromCharCode(9216+n)}class km extends tt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=wm(this.code),i=e.state.phrase("Control character")+" "+(gm[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Sm extends tt{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 Cm(){return Mm}const Am=N.line({class:"cm-activeLine"}),Mm=le.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>e&&(t.push(Am.range(s.from)),e=s.from)}return N.set(t)}},{decorations:n=>n.decorations});class Tm extends tt{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Hi(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),s=Yi(t[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function Em(n){let e=le.fromClass(class{constructor(t){this.view=t,this.placeholder=n?N.set([N.widget({widget:new Tm(n),side:1}).range(0)]):N.none}get decorations(){return this.view.state.doc.length?N.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,D.contentAttributes.of({"aria-placeholder":n})]:e}const Qr=2e3;function Dm(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Qr||t.off>Qr||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let h=n.doc.line(a);h.length<=l&&r.push(v.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let h=n.doc.line(a),c=Er(h.text,o,n.tabSize,!0);if(c<0)r.push(v.cursor(h.to));else{let f=Er(h.text,l,n.tabSize);r.push(v.range(h.from+c,h.from+f))}}}return r}function Om(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function Yl(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>Qr?-1:s==i.length?Om(n,e.clientX):Mi(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function Lm(n,e){let t=Yl(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=Yl(n,s);if(!l)return i;let a=Dm(n.state,t,l);return a.length?o?v.create(a.concat(i.ranges)):v.create(a):i}}:null}function _m(n){let e=t=>t.altKey&&t.button==0;return D.mouseSelectionStyle.of((t,i)=>e(i)?Lm(t,i):null)}const Pm={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},Rm={style:"cursor: crosshair"};function Im(n={}){let[e,t]=Pm[n.key||"Alt"],i=le.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,D.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?Rm:null})]}const Pn="-10000px";class Mc{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let h=r[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function Tc(n){let e=n.dom.ownerDocument.documentElement,t=e.clientWidth,i=getComputedStyle(e);if(!/stable/.test(i.scrollbarGutter||""))return{left:0,right:t};let s=e.getBoundingClientRect(),r=n.win.scrollX;return{left:Math.max(0,s.left+r-parseFloat(i.marginLeft)),right:Math.min(t,s.right+r+parseFloat(i.marginRight))}}function Bm(n){let{left:e,right:t}=Tc(n);return{top:0,left:e,right:t,bottom:n.dom.ownerDocument.documentElement.clientHeight}}const Zs=P.define({combine:n=>{var e,t,i;return{position:L.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Bm}}}),Xl=new WeakMap,Eo=le.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Zs);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Mc(n,Do,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Zs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=Pn,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1,i=0;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(L.safari){let l=o.getBoundingClientRect();t=Math.abs(l.top+1e4)>1||Math.abs(l.left)>1}else t=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(n=o.width/this.parent.offsetWidth,e=o.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);else i=Tc(this.view).left;let s=this.view.scrollDOM.getBoundingClientRect(),r=Ao(this.view);return{visible:{left:s.left+r.left,top:s.top+r.top,right:s.right-r.right,bottom:s.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,l)=>{let a=this.manager.tooltipViews[l];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(Zs).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t,fixedLeft:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:i,scaleX:s,scaleY:r}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=n.pos[l],u=n.size[l];if(!f||a.clip!==!1&&(f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1)){c.style.top=Pn;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=u.right-u.left,g=(e=Xl.get(h))!==null&&e!==void 0?e:u.bottom-u.top,x=h.offset||Vm,A=this.view.textDirection==Z.LTR,w=u.width>i.right-i.left?A?i.left:i.right-u.width:A?Math.max(i.left,Math.min(f.left-(d?14:0)+x.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-x.x),i.right-m),E=this.above[l];!a.strictSide&&(E?f.top-g-p-x.y<i.top:f.bottom+g+p+x.y>i.bottom)&&E==i.bottom-f.bottom>f.top-i.top&&(E=this.above[l]=!E);let S=(E?f.top-i.top:i.bottom-f.bottom)-p;if(S<g&&h.resize!==!1){if(S<this.view.defaultLineHeight){c.style.top=Pn;continue}Xl.set(h,g),c.style.height=(g=S)/r+"px"}else c.style.height&&(c.style.height="");let M=E?f.top-g-p-x.y:f.bottom+p+x.y,T=w+m;if(h.overlap!==!0)for(let V of o)V.left<T&&V.right>w&&V.top<M+g&&V.bottom>M&&(M=E?V.top-g-2-p:V.bottom+p+2);if(this.position=="absolute"?(c.style.top=(M-n.parent.top)/r+"px",Ql(c,(w-n.parent.left)/s)):(c.style.top=M/r+"px",Ql(c,(w-n.fixedLeft)/s)),d){let V=f.left+(A?x.x:-x.x)-(w+14-7);d.style.left=V/s+"px"}h.overlap!==!0&&o.push({left:w,top:M,right:T,bottom:M+g}),c.classList.toggle("cm-tooltip-above",E),c.classList.toggle("cm-tooltip-below",!E),h.positioned&&h.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Pn}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ql(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const Nm=D.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Vm={x:0,y:0},Do=P.define({enables:[Eo,Nm]}),cs=P.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class Ds{static create(e){return new Ds(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Mc(e,cs,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let s=i[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}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 Wm=Do.compute([cs],n=>{let e=n.facet(cs);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Ds.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Ec=P.define();class Fm{constructor(e,t,i,s,r,o){this.view=e,this.source=t,this.field=i,this.locked=s,this.setHover=r,this.hoverTime=o,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(e){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:t}=this,i=e.docView.tile.nearest(t.target);if(!i)return;let s,r=1;if(i.isWidget())s=i.posAtStart;else{if(s=e.posAtCoords(t),s==null)return;let o=e.coordsAtPos(s);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(s)).find(h=>h.from<=s&&h.to>=s),a=l&&l.dir==Z.RTL?-1:1;r=t.x<o.left?-a:a}this.activateHover(e,s,r)}activateHover(e,t,i,s){let r=this.source(e,t,i),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];s&&this.locked.set(a,s),e.dispatch({effects:this.setHover.of(a)})}};if(r&&"then"in r){let l=this.pending={pos:t};r.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>Ie(e.state,a,"hover tooltip"))}else o(r)}get tooltip(){let e=this.view.plugin(Eo),t=e?e.manager.tooltips.findIndex(i=>i.create==Ds.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;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:s,tooltip:r}=this;if(s.length&&!this.locked.has(s)&&r&&!Hm(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(i=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!jm(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:s}=this;s.length&&!this.locked.has(s)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Rn=4;function Hm(n,e){let{left:t,right:i,top:s,bottom:r}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),r=Math.max(l.bottom,r)}return e.clientX>=t-Rn&&e.clientX<=i+Rn&&e.clientY>=s-Rn&&e.clientY<=r+Rn}function jm(n,e,t,i,s,r){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=n.posAtCoords({x:i,y:s},!1);return a>=e&&a<=t}function zm(n,e={}){let t=F.define(),i=new WeakMap,s=Ce.define({create(){return[]},update(o,l){let a=i.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(h=>!e.hideOn(l,h)))),l.docChanged&&o.length){let h=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,we.TrackDel);if(f!=null){let u=Object.assign(Object.create(null),c);u.pos=f,u.end!=null&&(u.end=l.changes.mapPos(u.end)),h.push(u)}}o=h}for(let h of l.effects)h.is(t)&&(o=h.value,a=void 0),(h.is($m)&&!h.value||h.value==s)&&(o=[]);return o.length&&a&&i.set(o,a),o},provide:o=>cs.from(o)});const r=le.define(o=>new Fm(o,n,s,i,t,e.hoverTime||300));return{active:s,extension:[s,r,Ec.of(r),Wm]}}function qm(n,e,t,i={}){var s;let r=n.state.facet(Ec).map(o=>n.plugin(o)).filter(o=>!!o);if(i.tooltip&&i.tooltip.active){let o=r.find(l=>l.field==i.tooltip.active);o&&(r=[o])}for(let o of r)o.activateHover(n,e,t,(s=i.until)!==null&&s!==void 0?s:()=>!1)}function Dc(n,e){let t=n.plugin(Eo);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const $m=F.define(),Zl=P.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Os(n,e){let t=n.plugin(Oc),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Oc=le.fromClass(class{constructor(n){this.input=n.state.facet(Qi),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(Zl);this.top=new In(n,!0,e.topContainer),this.bottom=new In(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(Zl);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new In(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new In(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Qi);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(n.view),l.push(c)):(c=this.panels[h],c.update&&c.update(n)),s.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>D.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class In{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.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";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=ea(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=ea(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 ea(n){let e=n.nextSibling;return n.remove(),e}const Qi=P.define({enables:Oc});function Km(n,e){let t,i=new Promise(o=>t=o),s=o=>Gm(o,e,t);n.state.field(Yn,!1)?n.dispatch({effects:Lc.of(s)}):n.dispatch({effects:F.appendConfig.of(Yn.init(()=>[s]))});let r=_c.of(s);return{close:r,result:i.then(o=>((n.win.queueMicrotask||(a=>n.win.setTimeout(a,10)))(()=>{n.state.field(Yn).indexOf(s)>-1&&n.dispatch({effects:r})}),o))}}function Um(n,e){let t=n.state.field(Yn,!1)||[];for(let i of t){let s=Os(n,i);if(s&&s.dom.classList.contains(e))return s}return null}const Yn=Ce.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(Lc)?n=[t.value].concat(n):t.is(_c)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>Qi.computeN([n],e=>e.field(n))}),Lc=F.define(),_c=F.define();function Gm(n,e,t){let i=e.content?e.content(n,()=>l(null)):null;if(!i){if(i=Q("form"),e.input){let a=Q("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),i.appendChild(Q("label",(e.label||"")+": ",a))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Q("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let s=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let a=0;a<s.length;a++){let h=s[a];h.addEventListener("keydown",c=>{c.keyCode==27?(c.preventDefault(),l(null)):c.keyCode==13&&(c.preventDefault(),l(h))}),h.addEventListener("submit",c=>{c.preventDefault(),l(h)})}let r=Q("div",i,Q("button",{onclick:()=>l(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");let o=typeof e.focus=="string"?i.querySelector(e.focus):e.focus?i.querySelector("input")||i.querySelector("button"):null;function l(a){r.contains(r.ownerDocument.activeElement)&&n.focus(),t(a)}return{dom:r,top:e.top,mount:()=>{o&&("select"in o?o.select():"focus"in o&&o.focus())},destroy:()=>t(null)}}class St extends _t{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}St.prototype.elementClass="";St.prototype.toDOM=void 0;St.prototype.mapMode=we.TrackBefore;St.prototype.startSide=St.prototype.endSide=-1;St.prototype.point=!0;const Xn=P.define(),Jm=P.define(),Ym={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>$.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},qi=P.define();function Xm(n){return[Pc(),qi.of({...Ym,...n})]}const ta=P.define({combine:n=>n.some(e=>e)});function Pc(n){return[Qm]}const Qm=le.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(qi).map(e=>new na(n,e)),this.fixed=!n.state.facet(ta);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(ta)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=$.iter(this.view.state.facet(Xn),this.view.viewport.from),i=[],s=this.gutters.map(r=>new Zm(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==ke.Text&&o){Zr(t,i,l.from);for(let a of s)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==ke.Text){Zr(t,i,r.from);for(let o of s)o.line(this.view,r,i)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(qi),t=n.state.facet(qi),i=n.docChanged||n.heightChanged||n.viewportChanged||!$.eq(n.startState.facet(Xn),n.state.facet(Xn),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new na(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>D.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Z.LTR?{left:i,right:s}:{right:i,left:s}})});function ia(n){return Array.isArray(n)?n:[n]}function Zr(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class Zm{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=$.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new Rc(e,o,r,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];Zr(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),s=i?[i]:null;for(let r of e.state.facet(Jm)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class na{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,s)&&s.preventDefault()});this.markers=ia(t.markers(e)),t.initialSpacer&&(this.spacer=new Rc(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=ia(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!$.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Rc{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),eg(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(s);let f=s.nextSibling;s.remove(),s=f}}if(!a)break;a.toDOM&&(h?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function eg(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}const tg=P.define(),ig=P.define(),li=P.define({combine(n){return xt(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let s in t){let r=i[s],o=t[s];i[s]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return i}})}});class er extends St{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function tr(n,e){return n.state.facet(li).formatNumber(e,n.state)}const ng=qi.compute([li],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(tg)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new er(tr(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let s of e.state.facet(ig)){let r=s(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(li)!=e.state.facet(li),initialSpacer(e){return new er(tr(e,sa(e.state.doc.lines)))},updateSpacer(e,t){let i=tr(t.view,sa(t.view.state.doc.lines));return i==e.number?e:new er(i)},domEventHandlers:n.facet(li).domEventHandlers,side:"before"}));function sg(n={}){return[li.of(n),Pc(),ng]}function sa(n){let e=9;for(;e<n;)e=e*10+9;return e}const rg=new class extends St{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},og=Xn.compute(["selection"],n=>{let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(rg.range(s)))}return $.of(e)});function lg(){return og}const ag=1024;let hg=0;class qe{constructor(e,t){this.from=e,this.to=t}}class q{constructor(e={}){this.id=hg++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Le.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}q.closedBy=new q({deserialize:n=>n.split(" ")});q.openedBy=new q({deserialize:n=>n.split(" ")});q.group=new q({deserialize:n=>n.split(" ")});q.isolate=new q({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});q.contextHash=new q({perNode:!0});q.lookAhead=new q({perNode:!0});q.mounted=new q({perNode:!0});class di{constructor(e,t,i,s=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=s}static get(e){return e&&e.props&&e.props[q.mounted.id]}}const cg=Object.create(null);class Le{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):cg,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new Le(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(q.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(q.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}}Le.none=new Le("",Object.create(null),0,8);class Oo{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let s=null;for(let r of e){let o=r(i);if(o){s||(s=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in s&&(l=a.combine(s[a.id],l)),s[a.id]=l}}t.push(s?new Le(i.name,s,i.id,i.flags):i)}return new Oo(t)}}const Bn=new WeakMap,ra=new WeakMap;var G;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(G||(G={}));class te{constructor(e,t,i,s,r){if(this.type=e,this.children=t,this.positions=i,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=di.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let s=i.toString();s&&(t&&(t+=","),t+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new fs(this.topNode,e)}cursorAt(e,t=0,i=0){let s=Bn.get(this)||this.topNode,r=new fs(s);return r.moveTo(e,t),Bn.set(this,r._tree),r}get topNode(){return new Me(this,0,0,null)}resolve(e,t=0){let i=Zi(Bn.get(this)||this.topNode,e,t,!1);return Bn.set(this,i),i}resolveInner(e,t=0){let i=Zi(ra.get(this)||this.topNode,e,t,!0);return ra.set(this,i),i}resolveStack(e,t=0){return dg(this,e,t)}iterate(e){let{enter:t,leave:i,from:s=0,to:r=this.length}=e,o=e.mode||0,l=(o&G.IncludeAnonymous)>0;for(let a=this.cursor(o|G.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Po(Le.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new te(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new te(Le.none,t,i,s)))}static build(e){return pg(e)}}te.empty=new te(Le.none,[],[],0);class Lo{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Lo(this.buffer,this.index)}}class Bt{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Le.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e+=4,i==e)return r;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,i,s,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Ic(r,s,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=s[l++],r[a++]=s[l++]-i;let h=r[a++]=s[l++]-i;r[a++]=s[l++]-e,o=Math.max(o,h)}return new Bt(r,o,this.set)}}function Ic(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Zi(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof Me&&n.index<0?null:n.parent;if(!o)return n;n=o}let r=i?0:G.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof Me&&o.index<0&&((s=l.enter(e,t,r))===null||s===void 0?void 0:s.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,r);if(!o)return n;n=o}}class Bc{cursor(e=0){return new fs(this,e)}getChild(e,t=null,i=null){let s=oa(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return oa(this,e,t,i)}resolve(e,t=0){return Zi(this,e,t,!1)}resolveInner(e,t=0){return Zi(this,e,t,!0)}matchContext(e){return eo(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(i=t,t=s.prevSibling):t=s}return i}get node(){return this}get next(){return this.parent}}class Me extends Bc{constructor(e,t,i,s){super(),this._tree=e,this.from=t,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(r&G.EnterBracketed&&c instanceof te&&(u=di.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!Ic(s,i,f,f+c.length))){if(c instanceof Bt){if(r&G.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,i-f,s);if(d>-1)return new ut(new fg(o,c,e,f),null,d)}else if(r&G.IncludeAnonymous||!c.type.isAnonymous||_o(c)){let d;if(!(r&G.IgnoreMounts)&&(d=di.get(c))&&!d.overlay)return new Me(d.tree,f,e,o);let p=new Me(c,f,e,o);return r&G.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,s,r)}}}if(r&G.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let s;if(!(i&G.IgnoreOverlays)&&(s=di.get(this._tree))&&s.overlay){let r=e-this.from,o=i&G.EnterBracketed&&s.bracketed;for(let{from:l,to:a}of s.overlay)if((t>0||o?l<=r:l<r)&&(t<0||o?a>=r:a>r))return new Me(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function oa(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function eo(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class fg{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class ut extends Bc{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new ut(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&G.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new ut(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new ut(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new ut(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];e.push(i.slice(s,r,o)),t.push(0)}return new te(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Nc(n){if(!n.length)return null;let e=0,t=n[0];for(let r=1;r<n.length;r++){let o=n[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let i=t instanceof Me&&t.index<0?null:t.parent,s=n.slice();return i?s[e]=i:s.splice(e,1),new ug(s,t)}class ug{constructor(e,t){this.heads=e,this.node=t}get next(){return Nc(this.heads)}}function dg(n,e,t){let i=n.resolveInner(e,t),s=null;for(let r=i instanceof Me?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[i])).push(o.resolve(e,t)),r=o}else{let o=di.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Me(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(Zi(l,e,t,!1))}}return s?Nc(s):i}class fs{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~G.EnterBracketed,e instanceof Me)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof Me?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&G.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&G.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&G.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:i}=s)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&G.IncludeAnonymous||l instanceof Bt||!l.type.isAnonymous||_o(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}for(let s=i;s<this.stack.length;s++)t=new ut(this.buffer,t,this.stack[s]);return this.bufferNode=new ut(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&t&&t(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(e){if(!this.buffer)return eo(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return eo(this._tree,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function _o(n){return n.children.some(e=>e instanceof Bt||!e.type.isAnonymous||_o(e))}function pg(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=ag,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new Lo(t,t.length):t,a=i.types,h=0,c=0;function f(S,M,T,V,B,H){let{id:W,start:I,end:z,size:j}=l,J=c,ne=h;if(j<0)if(l.next(),j==-1){let Je=r[W];T.push(Je),V.push(I-S);return}else if(j==-3){h=W;return}else if(j==-4){c=W;return}else throw new RangeError(`Unrecognized record size: ${j}`);let X=a[W],de,se,xe=I-S;if(z-I<=s&&(se=g(l.pos-M,B))){let Je=new Uint16Array(se.size-se.skip),ye=l.pos-se.size,Ne=Je.length;for(;l.pos>ye;)Ne=x(se.start,Je,Ne);de=new Bt(Je,z-se.start,i),xe=se.start-S}else{let Je=l.pos-j;l.next();let ye=[],Ne=[],Ve=W>=o?W:-1,Ye=0,yt=z,Ht=J;for(;l.pos>Je;)Ve>=0&&l.id==Ve&&l.size>=0?(l.end<=yt-s&&(p(ye,Ne,I,Ye,l.end,yt,Ve,Ht,ne),Ye=ye.length,yt=l.end,Ht=c),l.next()):H>2500?u(I,Je,ye,Ne):(Ve>=0&&l.size==-1&&r[l.id].type==i.types[Ve]&&(Ye<ye.length&&p(ye,Ne,I,Ye,l.end,yt,Ve,Ht,ne),Ye=ye.length+1,yt=l.start,Ht=c),f(I,Je,ye,Ne,Ve,H+1));if(Ve>=0&&Ye>0&&Ye<ye.length&&p(ye,Ne,I,Ye,I,yt,Ve,Ht,ne),ye.reverse(),Ne.reverse(),Ve>-1&&Ye>0){let vn=d(X,ne);de=Po(X,ye,Ne,0,ye.length,0,z-I,vn,vn)}else de=m(X,ye,Ne,z-I,J-z,ne)}T.push(de),V.push(xe)}function u(S,M,T,V){let B=[],H=0,W=-1;for(;l.pos>M;){let{id:I,start:z,end:j,size:J}=l;if(J>4)l.next();else{if(W>-1&&z<W)break;W<0&&(W=j-s),B.push(I,z,j),H++,l.next()}}if(H){let I=new Uint16Array(H*4),z=B[B.length-2];for(let j=B.length-3,J=0;j>=0;j-=3)I[J++]=B[j],I[J++]=B[j+1]-z,I[J++]=B[j+2]-z,I[J++]=J;T.push(new Bt(I,B[2]-z,i)),V.push(z-S)}}function d(S,M){return(T,V,B)=>{let H=0,W=T.length-1,I,z;if(W>=0&&(I=T[W])instanceof te){if(!W&&I.type==S&&I.length==B)return I;(z=I.prop(q.lookAhead))&&(H=V[W]+I.length+z-B)}return m(S,T,V,B,H,M)}}function p(S,M,T,V,B,H,W,I,z){let j=[],J=[];for(;S.length>V;)j.push(S.pop()),J.push(M.pop()+T-B);S.push(m(i.types[W],j,J,H-B,I-H,z)),M.push(B-T)}function m(S,M,T,V,B,H,W){if(H){let I=[q.contextHash,H];W=W?[I].concat(W):[I]}if(B>25){let I=[q.lookAhead,B];W=W?[I].concat(W):[I]}return new te(S,M,T,V,W)}function g(S,M){let T=l.fork(),V=0,B=0,H=0,W=T.end-s,I={size:0,start:0,skip:0};e:for(let z=T.pos-S;T.pos>z;){let j=T.size;if(T.id==M&&j>=0){I.size=V,I.start=B,I.skip=H,H+=4,V+=4,T.next();continue}let J=T.pos-j;if(j<0||J<z||T.start<W)break;let ne=T.id>=o?4:0,X=T.start;for(T.next();T.pos>J;){if(T.size<0)if(T.size==-3||T.size==-4)ne+=4;else break e;else T.id>=o&&(ne+=4);T.next()}B=X,V+=j,H+=ne}return(M<0||V==S)&&(I.size=V,I.start=B,I.skip=H),I.size>4?I:void 0}function x(S,M,T){let{id:V,start:B,end:H,size:W}=l;if(l.next(),W>=0&&V<o){let I=T;if(W>4){let z=l.pos-(W-4);for(;l.pos>z;)T=x(S,M,T)}M[--T]=I,M[--T]=H-S,M[--T]=B-S,M[--T]=V}else W==-3?h=V:W==-4&&(c=V);return T}let A=[],w=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,A,w,-1,0);let E=(e=n.length)!==null&&e!==void 0?e:A.length?w[0]+A[0].length:0;return new te(a[n.topID],A.reverse(),w.reverse(),E)}const la=new WeakMap;function Qn(n,e){if(!n.isAnonymous||e instanceof Bt||e.type!=n)return 1;let t=la.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof te)){t=1;break}t+=Qn(n,i)}la.set(e,t)}return t}function Po(n,e,t,i,s,r,o,l,a){let h=0;for(let p=i;p<s;p++)h+=Qn(n,e[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,m,g,x,A){for(let w=g;w<x;){let E=w,S=m[w],M=Qn(n,p[w]);for(w++;w<x;w++){let T=Qn(n,p[w]);if(M+T>=c)break;M+=T}if(w==E+1){if(M>c){let T=p[E];d(T.children,T.positions,0,T.children.length,m[E]+A);continue}f.push(p[E])}else{let T=m[w-1]+p[w-1].length-S;f.push(Po(n,p,m,E,w,S,T,null,a))}u.push(S+A-r)}}return d(e,t,i,s,0),(l||a)(f,u,o)}class Yb{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof ut?this.setBuffer(e.context.buffer,e.index,t):e instanceof Me&&this.map.set(e.tree,t)}get(e){return e instanceof ut?this.getBuffer(e.context.buffer,e.index):e instanceof Me?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class wt{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let s=[new wt(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new wt(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&s.push(u),o.to>f)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return s}}class Vc{startParse(e,t,i){return typeof e=="string"&&(e=new mg(e)),i=i?i.length?i.map(s=>new qe(s.from,s.to)):[new qe(0,0)]:[new qe(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}}class mg{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function Xb(n){return(e,t,i,s)=>new xg(e,n,t,i,s)}class aa{constructor(e,t,i,s,r,o){this.parser=e,this.parse=t,this.overlay=i,this.bracketed=s,this.target=r,this.from=o}}function ha(n){if(!n.length||n.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}class gg{constructor(e,t,i,s,r,o,l,a){this.parser=e,this.predicate=t,this.mounts=i,this.index=s,this.start=r,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Wc=new q({perNode:!0});class xg{constructor(e,t,i,s,r){this.nest=t,this.input=i,this.fragments=s,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new te(i.type,i.children,i.positions,i.length,i.propValues.concat([[Wc,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[q.mounted.id]=new di(t,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new vg(this.fragments),t=null,i=null,s=new fs(new Me(this.baseTree,this.ranges[0].from,0,null),G.IncludeAnonymous|G.IgnoreMounts);e:for(let r,o;;){let l=!0,a;if(this.stoppedAt!=null&&s.from>=this.stoppedAt)l=!1;else if(e.hasNode(s)){if(t){let h=t.mounts.find(c=>c.frag.from<=s.from&&c.frag.to>=s.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let f=c.from+h.pos,u=c.to+h.pos;f>=s.from&&u<=s.to&&!t.ranges.some(d=>d.from<u&&d.to>f)&&t.ranges.push({from:f,to:u})}}l=!1}else if(i&&(o=yg(i.ranges,s.from,s.to)))l=o!=2;else if(!s.type.isAnonymous&&(r=this.nest(s,this.input))&&(s.from<s.to||!r.overlay)){s.tree||(bg(s),t&&t.depth++,i&&i.depth++);let h=e.findMounts(s.from,r.parser);if(typeof r.overlay=="function")t=new gg(r.parser,r.overlay,h,this.inner.length,s.from,!!r.bracketed,s.tree,t);else{let c=da(this.ranges,r.overlay||(s.from<s.to?[new qe(s.from,s.to)]:[]));c.length&&ha(c),(c.length||!r.overlay)&&this.inner.push(new aa(r.parser,c.length?r.parser.startParse(this.input,pa(h,c),c):r.parser.startParse(""),r.overlay?r.overlay.map(f=>new qe(f.from-s.from,f.to-s.from)):null,!!r.bracketed,s.tree,c.length?c[0].from:s.from)),r.overlay?c.length&&(i={ranges:c,depth:0,prev:i}):l=!1}}else if(t&&(a=t.predicate(s))&&(a===!0&&(a=new qe(s.from,s.to)),a.from<a.to)){let h=t.ranges.length-1;h>=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(l&&s.firstChild())t&&t.depth++,i&&i.depth++;else for(;!s.nextSibling();){if(!s.parent())break e;if(t&&!--t.depth){let h=da(this.ranges,t.ranges);h.length&&(ha(h),this.inner.splice(t.index,0,new aa(t.parser,t.parser.startParse(this.input,pa(t.mounts,h),h),t.ranges.map(c=>new qe(c.from-t.start,c.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function yg(n,e,t){for(let i of n){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function ca(n,e,t,i,s,r){if(e<t){let o=n.buffer[e+1];i.push(n.slice(e,t,o)),s.push(o-r)}}function bg(n){let{node:e}=n,t=[],i=e.context.buffer;do t.push(n.index),n.parent();while(!n.tree);let s=n.tree,r=s.children.indexOf(i),o=s.children[r],l=o.buffer,a=[r];function h(c,f,u,d,p,m){let g=t[m],x=[],A=[];ca(o,c,g,x,A,d);let w=l[g+1],E=l[g+2];a.push(x.length);let S=m?h(g+4,l[g+3],o.set.types[l[g]],w,E-w,m-1):e.toTree();return x.push(S),A.push(w-d),ca(o,l[g+3],f,x,A,d),new te(u,x,A,p)}s.children[r]=h(0,l.length,Le.none,0,o.length,t.length-1);for(let c of a){let f=n.tree.children[c],u=n.tree.positions[c];n.yield(new Me(f,u+n.from,c,n._tree))}}class fa{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(G.IncludeAnonymous|G.IgnoreMounts|G.ExcludeBuffers)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)if(!(t.to>=i&&t.enter(i,1,G.IncludeAnonymous|G.IgnoreMounts|G.IgnoreOverlays|G.ExcludeBuffers)))if(t.to<=i)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof te)t=t.children[0];else break}return!1}}function ua(n){let e=n.tree.prop(Wc);return e==null?n.to:Math.min(n.to,e-n.offset)}class vg{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=ua(t),this.inner=new fa(t.tree,-t.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(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=ua(e),this.inner=new fa(e.tree,-e.offset)}}findMounts(e,t){var i;let s=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let r=this.inner.cursor.node;r;r=r.parent){let o=(i=r.tree)===null||i===void 0?void 0:i.prop(q.mounted);if(o&&o.parser==t)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=r.to)break;a.tree==this.curFrag.tree&&s.push({frag:a,pos:r.from-a.offset,mount:o})}}}return s}}function da(n,e){let t=null,i=e;for(let s=1,r=0;s<n.length;s++){let o=n[s-1].to,l=n[s].from;for(;r<i.length;r++){let a=i[r];if(a.from>=l)break;a.to<=o||(t||(i=t=e.slice()),a.from<o?(t[r]=new qe(a.from,o),a.to>l&&t.splice(r+1,0,new qe(l,a.to))):a.to>l?t[r--]=new qe(l,a.to):t.splice(r--,1))}}return i}function wg(n,e,t,i){let s=0,r=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=s==n.length?1e9:o?n[s].to:n[s].from,f=r==e.length?1e9:l?e[r].to:e[r].from;if(o!=l){let u=Math.max(a,t),d=Math.min(c,f,i);u<d&&h.push(new qe(u,d))}if(a=Math.min(c,f),a==1e9)break;c==a&&(o?(o=!1,s++):o=!0),f==a&&(l?(l=!1,r++):l=!0)}return h}function pa(n,e){let t=[];for(let{pos:i,mount:s,frag:r}of n){let o=i+(s.overlay?s.overlay[0].from:0),l=o+s.tree.length,a=Math.max(r.from,o),h=Math.min(r.to,l);if(s.overlay){let c=s.overlay.map(u=>new qe(u.from+i,u.to+i)),f=wg(e,c,a,h);for(let u=0,d=a;;u++){let p=u==f.length,m=p?h:f[u].from;if(m>d&&t.push(new wt(d,m,s.tree,-o,r.from>=d||r.openStart,r.to<=m||r.openEnd)),p)break;d=f[u].to}}else t.push(new wt(a,h,s.tree,-o,r.from>=o||r.openStart,r.to<=l||r.openEnd))}return t}let kg=0;class je{constructor(e,t,i,s){this.name=e,this.set=t,this.base=i,this.modified=s,this.id=kg++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof je&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let s=new je(i,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new us(e);return i=>i.modified.indexOf(t)>-1?i:us.get(i.base||i,i.modified.concat(t).sort((s,r)=>s.id-r.id))}}let Sg=0;class us{constructor(e){this.name=e,this.instances=[],this.id=Sg++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Cg(t,l.modified));if(i)return i;let s=[],r=new je(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=Ag(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(us.get(l,a));return r}}function Cg(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function Ag(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,s=e.length;i<s;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Mg(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let f=0;;){if(l=="..."&&f>0&&f+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==s.length)break;let d=s[f++];if(f==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(f)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let c=new en(i,o,a>0?r.slice(0,a):null);e[h]=c.sort(e[h])}}return Fc.add(e)}const Fc=new q({combine(n,e){let t,i,s;for(;n||e;){if(!n||e&&n.depth<=e.depth?(s=e,e=e.next):(s=n,n=n.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let r=new en(s.tags,s.mode,s.context);t?t.next=r:i=r,t=r}return i}});class en{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}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}}en.empty=new en([],2,null);function Hc(n,e){let t=Object.create(null);for(let r of n)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:i,all:s=null}=e||{};return{style:r=>{let o=s;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Tg(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function Eg(n,e,t,i=0,s=n.length){let r=new Dg(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class Dg{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,s,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,c=Og(e)||en.empty,f=Tg(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(s+=(s?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(q.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,x=l;;g++){let A=g<u.overlay.length?u.overlay[g]:null,w=A?A.from+l:a,E=Math.max(t,x),S=Math.min(i,w);if(E<S&&m)for(;e.from<S&&(this.highlightRange(e,E,S,s,r),this.startSpan(Math.min(S,e.to),h),!(e.to>=w||!e.nextSibling())););if(!A||w>i)break;x=A.to+l,x>t&&(this.highlightRange(d.cursor(),Math.max(t,A.from+l),Math.min(i,x),"",p),this.startSpan(Math.min(i,x),h))}m&&e.parent()}else if(e.firstChild()){u&&(s="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function Og(n){let e=n.type.prop(Fc);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const O=je.define,Nn=O(),Mt=O(),ma=O(Mt),ga=O(Mt),Tt=O(),Vn=O(Tt),ir=O(Tt),lt=O(),zt=O(lt),rt=O(),ot=O(),to=O(),_i=O(to),Wn=O(),k={comment:Nn,lineComment:O(Nn),blockComment:O(Nn),docComment:O(Nn),name:Mt,variableName:O(Mt),typeName:ma,tagName:O(ma),propertyName:ga,attributeName:O(ga),className:O(Mt),labelName:O(Mt),namespace:O(Mt),macroName:O(Mt),literal:Tt,string:Vn,docString:O(Vn),character:O(Vn),attributeValue:O(Vn),number:ir,integer:O(ir),float:O(ir),bool:O(Tt),regexp:O(Tt),escape:O(Tt),color:O(Tt),url:O(Tt),keyword:rt,self:O(rt),null:O(rt),atom:O(rt),unit:O(rt),modifier:O(rt),operatorKeyword:O(rt),controlKeyword:O(rt),definitionKeyword:O(rt),moduleKeyword:O(rt),operator:ot,derefOperator:O(ot),arithmeticOperator:O(ot),logicOperator:O(ot),bitwiseOperator:O(ot),compareOperator:O(ot),updateOperator:O(ot),definitionOperator:O(ot),typeOperator:O(ot),controlOperator:O(ot),punctuation:to,separator:O(to),bracket:_i,angleBracket:O(_i),squareBracket:O(_i),paren:O(_i),brace:O(_i),content:lt,heading:zt,heading1:O(zt),heading2:O(zt),heading3:O(zt),heading4:O(zt),heading5:O(zt),heading6:O(zt),contentSeparator:O(lt),list:O(lt),quote:O(lt),emphasis:O(lt),strong:O(lt),link:O(lt),monospace:O(lt),strikethrough:O(lt),inserted:O(),deleted:O(),changed:O(),invalid:O(),meta:Wn,documentMeta:O(Wn),annotation:O(Wn),processingInstruction:O(Wn),definition:je.defineModifier("definition"),constant:je.defineModifier("constant"),function:je.defineModifier("function"),standard:je.defineModifier("standard"),local:je.defineModifier("local"),special:je.defineModifier("special")};for(let n in k){let e=k[n];e instanceof je&&(e.name=n)}Hc([{tag:k.link,class:"tok-link"},{tag:k.heading,class:"tok-heading"},{tag:k.emphasis,class:"tok-emphasis"},{tag:k.strong,class:"tok-strong"},{tag:k.keyword,class:"tok-keyword"},{tag:k.atom,class:"tok-atom"},{tag:k.bool,class:"tok-bool"},{tag:k.url,class:"tok-url"},{tag:k.labelName,class:"tok-labelName"},{tag:k.inserted,class:"tok-inserted"},{tag:k.deleted,class:"tok-deleted"},{tag:k.literal,class:"tok-literal"},{tag:k.string,class:"tok-string"},{tag:k.number,class:"tok-number"},{tag:[k.regexp,k.escape,k.special(k.string)],class:"tok-string2"},{tag:k.variableName,class:"tok-variableName"},{tag:k.local(k.variableName),class:"tok-variableName tok-local"},{tag:k.definition(k.variableName),class:"tok-variableName tok-definition"},{tag:k.special(k.variableName),class:"tok-variableName2"},{tag:k.definition(k.propertyName),class:"tok-propertyName tok-definition"},{tag:k.typeName,class:"tok-typeName"},{tag:k.namespace,class:"tok-namespace"},{tag:k.className,class:"tok-className"},{tag:k.macroName,class:"tok-macroName"},{tag:k.propertyName,class:"tok-propertyName"},{tag:k.operator,class:"tok-operator"},{tag:k.comment,class:"tok-comment"},{tag:k.meta,class:"tok-meta"},{tag:k.invalid,class:"tok-invalid"},{tag:k.punctuation,class:"tok-punctuation"}]);function xa(n,e,t,i=0,s=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let r=s;for(let o=i;o<e;o++)n.charCodeAt(o)==9?r+=t-r%t:r++;return r}class jc{constructor(e,t,i,s){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=s,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=xa(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:xa(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let s=o=>i?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return s(r)==s(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}var nr;const Gt=new q;function zc(n){return P.define({combine:n?e=>e.concat(n):void 0})}const Lg=new q;class $e{constructor(e,t,i=[],s=""){this.data=e,this.name=s,K.prototype.hasOwnProperty("tree")||Object.defineProperty(K.prototype,"tree",{get(){return Se(this)}}),this.parser=t,this.extension=[Nt.of(this),K.languageData.of((r,o,l)=>{let a=ya(r,o,l),h=a.type.prop(Gt);if(!h)return[];let c=r.facet(h),f=a.type.prop(Lg);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return ya(e,t,i).type.prop(Gt)==this.data}findRegions(e){let t=e.facet(Nt);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Gt)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(q.mounted);if(l){if(l.tree.prop(Gt)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof te&&s(h,r.positions[a]+o)}};return s(Se(e),0),i}get allowsNesting(){return!0}}$e.setState=F.define();function ya(n,e,t){let i=n.facet(Nt),s=Se(n).topNode;if(!i||i.allowsNesting)for(let r=s;r;r=r.enter(e,t,G.ExcludeBuffers|G.EnterBracketed))r.type.isTop&&(s=r);return s}class io extends $e{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=zc(e.languageData);return new io(t,e.parser.configure({props:[Gt.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new io(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Se(n){let e=n.field($e.state,!1);return e?e.tree:te.empty}class _g{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Pi=null;class Si{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Si(e,t,[],te.empty,0,i,[],null)}startParse(){return this.parser.startParse(new _g(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=te.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(wt.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(wt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Pi;Pi=this;try{return e()}finally{Pi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ba(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=wt.applyChanges(i,a),s=te.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new Si(this.parser,t,i,s,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:s,to:r}=this.skipped[i];s<e.to&&r>e.from&&(this.fragments=ba(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Vc{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=Pi;if(a){for(let h of s)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new te(Le.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Pi}}function ba(n,e,t){return wt.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class Ci{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new Ci(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Si.create(e.facet(Nt).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new Ci(i)}}$e.state=Ce.define({create:Ci.init,update(n,e){for(let t of e.effects)if(t.is($e.setState))return t.value;return e.startState.facet(Nt)!=e.state.facet(Nt)?Ci.init(e.state):n.apply(e)}});let qc=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(qc=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const sr=typeof navigator<"u"&&(!((nr=navigator.scheduling)===null||nr===void 0)&&nr.isInputPending)?()=>navigator.scheduling.isInputPending():null,Pg=le.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field($e.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field($e.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=qc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,r=i.field($e.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!sr?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&i.doc.length>s+1e3,a=r.context.work(()=>sr&&sr()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:$e.setState.of(new Ci(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ie(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Nt=P.define({combine(n){return n.length?n[0]:null},enables:n=>[$e.state,Pg,D.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class Rg{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class y{constructor(e,t,i,s,r,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=s,this.loadFunc=r,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new y(e.name,(e.alias||[]).concat(e.name).map(s=>s.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let s of e)if(s.filename&&s.filename.test(t))return s;let i=/\.([^.]+)$/.exec(t);if(i){for(let s of e)if(s.extensions.indexOf(i[1])>-1)return s}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let s of e)if(s.alias.some(r=>r==t))return s;if(i)for(let s of e)for(let r of s.alias){let o=t.indexOf(r);if(o>-1&&(r.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+r.length])))return s}return null}}const Ig=P.define(),pn=P.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function ei(n){let e=n.facet(pn);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function tn(n,e){let t="",i=n.tabSize,s=n.facet(pn)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r<e;r++)t+=s;return t}function Ro(n,e){n instanceof K&&(n=new Ls(n));for(let i of n.state.facet(Ig)){let s=i(n,e);if(s!==void 0)return s}let t=Se(n.state);return t.length>=e?Bg(n,t,e):null}class Ls{constructor(e,t={}){this.state=e,this.options=t,this.unit=ei(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(e,t);return i.slice(e-s,Math.min(i.length,e+100-s))}column(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.countColumn(i,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return Mi(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const $c=new q;function Bg(n,e,t){let i=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=i.node){let r=[];for(let o=s;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return Kc(i,n,t)}function Kc(n,e,t){for(let i=n;i;i=i.next){let s=Vg(i.node);if(s)return s(Io.create(e,t,i))}return 0}function Ng(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Vg(n){let e=n.type.prop($c);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(q.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>Uc(o,!0,1,void 0,r&&!Ng(o)?s.from:void 0)}return n.parent==null?Wg:null}function Wg(){return 0}class Io extends Ls{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Io(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Fg(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Kc(this.context.next,this.base,this.pos)}}function Fg(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function Hg(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function Zb({closing:n,align:e=!0,units:t=1}){return i=>Uc(i,e,t,n)}function Uc(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=e?Hg(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const e1=n=>n.baseIndent;function t1({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const jg=200;function zg(){return K.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+jg)return n;let r=t.sliceString(s.from,i);if(!e.some(h=>h.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=Ro(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=tn(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const qg=P.define(),$g=new q;function i1(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}function Kg(n,e,t){let i=Se(n);if(i.length<t)return null;let s=i.resolveStack(t,1),r=null;for(let o=s;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop($g);if(a&&(l.to<i.length-50||i.length==n.doc.length||!Ug(l))){let h=a(l,n);h&&h.from<=t&&h.from>=e&&h.to>t&&(r=h)}}return r}function Ug(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function ds(n,e,t){for(let i of n.facet(qg)){let s=i(n,e,t);if(s)return s}return Kg(n,e,t)}function Gc(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const _s=F.define({map:Gc}),mn=F.define({map:Gc});function Jc(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const ti=Ce.define({create(){return N.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,s)=>n=va(n,i,s)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(_s)&&!Gg(n,i.value.from,i.value.to)?t.push(i.value):i.is(mn)&&(n=n.update({filter:(s,r)=>i.value.from!=s||i.value.to!=r,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(Qc),s=t.map(r=>(i?N.replace({widget:new t0(i(e.state,r))}):wa).range(r.from,r.to));n=n.update({add:s})}return e.selection&&(n=va(n,e.selection.main.head)),n},provide:n=>D.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let i=n[t++],s=n[t++];if(typeof i!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(wa.range(i,s))}return N.set(e,!0)}});function va(n,e,t=e){let i=!1;return n.between(e,t,(s,r)=>{s<t&&r>e&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(s,r)=>s>=t||r<=e}):n}function ps(n,e,t){var i;let s=null;return(i=n.field(ti,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function Gg(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function Yc(n,e){return n.field(ti,!1)?e:e.concat(F.appendConfig.of(Zc()))}const Jg=n=>{for(let e of Jc(n)){let t=ds(n.state,e.from,e.to);if(t)return n.dispatch({effects:Yc(n.state,[_s.of(t),Xc(n,t)])}),!0}return!1},Yg=n=>{if(!n.state.field(ti,!1))return!1;let e=[];for(let t of Jc(n)){let i=ps(n.state,t.from,t.to);i&&e.push(mn.of(i),Xc(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function Xc(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return D.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const Xg=n=>{let{state:e}=n,t=[];for(let i=0;i<e.doc.length;){let s=n.lineBlockAt(i),r=ds(e,s.from,s.to);r&&t.push(_s.of(r)),i=(r?n.lineBlockAt(r.to):s).to+1}return t.length&&n.dispatch({effects:Yc(n.state,t)}),!!t.length},Qg=n=>{let e=n.state.field(ti,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(mn.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},Zg=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Jg},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Yg},{key:"Ctrl-Alt-[",run:Xg},{key:"Ctrl-Alt-]",run:Qg}],e0={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Qc=P.define({combine(n){return xt(n,e0)}});function Zc(n){return[ti,s0]}function ef(n,e){let{state:t}=n,i=t.facet(Qc),s=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=ps(n.state,l.from,l.to);a&&n.dispatch({effects:mn.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,s,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const wa=N.replace({widget:new class extends tt{toDOM(n){return ef(n,null)}}});class t0 extends tt{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ef(e,this.value)}}const i0={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class rr extends St{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function n0(n={}){let e={...i0,...n},t=new rr(e,!0),i=new rr(e,!1),s=le.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Nt)!=o.state.facet(Nt)||o.startState.field(ti,!1)!=o.state.field(ti,!1)||Se(o.startState)!=Se(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Ze;for(let a of o.viewportLineBlocks){let h=ps(o.state,a.from,a.to)?i:ds(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[s,Xm({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||$.empty},initialSpacer(){return new rr(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=ps(o.state,l.from,l.to);if(h)return o.dispatch({effects:mn.of(h)}),!0;let c=ds(o.state,l.from,l.to);return c?(o.dispatch({effects:_s.of(c)}),!0):!1}}}),Zc()]}const s0=D.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 gn{constructor(e,t){this.specs=e;let i;function s(l){let a=Pt.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof $e?l=>l.prop(Gt)==o.data:o?l=>l==o:void 0,this.style=Hc(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new Pt(i):null,this.themeType=t.themeType}static define(e,t){return new gn(e,t||{})}}const no=P.define(),tf=P.define({combine(n){return n.length?[n[0]]:null}});function or(n){let e=n.facet(no);return e.length?e:n.facet(tf)}function nf(n,e){let t=[o0],i;return n instanceof gn&&(n.module&&t.push(D.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(tf.of(n)):i?t.push(no.computeN([D.darkTheme],s=>s.facet(D.darkTheme)==(i=="dark")?[n]:[])):t.push(no.of(n)),t}class r0{constructor(e){this.markCache=Object.create(null),this.tree=Se(e.state),this.decorations=this.buildDeco(e,or(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Se(e.state),i=or(e.state),s=i!=or(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return N.none;let i=new Ze;for(let{from:s,to:r}of e.visibleRanges)Eg(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=N.mark({class:a})))},s,r);return i.finish()}}const o0=Wt.high(le.fromClass(r0,{decorations:n=>n.decorations})),l0=gn.define([{tag:k.meta,color:"#404740"},{tag:k.link,textDecoration:"underline"},{tag:k.heading,textDecoration:"underline",fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strong,fontWeight:"bold"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.keyword,color:"#708"},{tag:[k.atom,k.bool,k.url,k.contentSeparator,k.labelName],color:"#219"},{tag:[k.literal,k.inserted],color:"#164"},{tag:[k.string,k.deleted],color:"#a11"},{tag:[k.regexp,k.escape,k.special(k.string)],color:"#e40"},{tag:k.definition(k.variableName),color:"#00f"},{tag:k.local(k.variableName),color:"#30a"},{tag:[k.typeName,k.namespace],color:"#085"},{tag:k.className,color:"#167"},{tag:[k.special(k.variableName),k.macroName],color:"#256"},{tag:k.definition(k.propertyName),color:"#00c"},{tag:k.comment,color:"#940"},{tag:k.invalid,color:"#f00"}]),a0=D.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),sf=1e4,rf="()[]{}",of=P.define({combine(n){return xt(n,{afterCursor:!0,brackets:rf,maxScanDistance:sf,renderMatch:f0})}}),h0=N.mark({class:"cm-matchingBracket"}),c0=N.mark({class:"cm-nonmatchingBracket"});function f0(n){let e=[],t=n.matched?h0:c0;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function ka(n){let e=[],t=n.facet(of);for(let i of n.selection.ranges){if(!i.empty)continue;let s=dt(n,i.head,-1,t)||i.head>0&&dt(n,i.head-1,1,t)||t.afterCursor&&(dt(n,i.head,1,t)||i.head<n.doc.length&&dt(n,i.head+1,-1,t));s&&(e=e.concat(t.renderMatch(s,n)))}return N.set(e,!0)}const u0=le.fromClass(class{constructor(n){this.paused=!1,this.decorations=ka(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=ka(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),d0=[u0,a0];function p0(n={}){return[of.of(n),d0]}const m0=new q;function so(n,e,t){let i=n.prop(e<0?q.openedBy:q.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function ro(n){let e=n.type.prop(m0);return e?e(n.node):n}function dt(n,e,t,i={}){let s=i.maxScanDistance||sf,r=i.brackets||rf,o=Se(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=so(a.type,t,r);if(h&&a.from<a.to){let c=ro(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return g0(n,e,t,a,c,h,r)}}return x0(n,e,t,o,l.type,s,r)}function g0(n,e,t,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},h=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from<c.to){let f=ro(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(so(c.type,t,o))h++;else if(so(c.type,-t,o)){if(h==0){let f=ro(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function x0(n,e,t,i,s,r,o){if(t<0?!e:e==n.doc.length)return null;let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let x=o.indexOf(d[m]);if(!(x<0||i.resolveInner(p+m,1).type!=s))if(x%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+m,to:p+m+1},matched:x>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}function y0(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||b0,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||Vo,mergeTokens:n.mergeTokens!==!1}}function b0(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}const Sa=new WeakMap;class Bo extends $e{constructor(e){let t=zc(e.languageData),i=y0(e),s,r=new class extends Vc{createParse(o,l,a){return new w0(s,o,l,a)}};super(t,r,[],e.name),this.topNode=C0(t,this),s=this,this.streamParser=i,this.stateAfter=new q({perNode:!0}),this.tokenTable=e.tokenTable?new cf(i.tokenTable):S0}static define(e){return new Bo(e)}getIndent(e){let t,{overrideIndentation:i}=e.options;i&&(t=Sa.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let s=No(this,e.node.tree,e.node.from,e.node.from,t??e.pos),r,o;if(s?(o=s.state,r=s.pos+1):(o=this.streamParser.startState(e.unit),r=e.node.from),e.pos-r>1e4)return null;for(;r<e.pos;){let a=e.state.doc.lineAt(r),h=Math.min(e.pos,a.to);if(a.length){let c=i?i(a.from):-1,f=new jc(a.text,e.state.tabSize,e.unit,c<0?void 0:c);for(;f.pos<h-a.from;)af(this.streamParser.token,f,o)}else this.streamParser.blankLine(o,e.unit);if(h==e.pos)break;r=a.to+1}let l=e.lineAt(e.pos);return i&&t==null&&Sa.set(e.state,l.from),this.streamParser.indent(o,/^\s*(.*)/.exec(l.text)[1],e)}get allowsNesting(){return!1}}function No(n,e,t,i,s){let r=t>=i&&t+e.length<=s&&e.prop(n.stateAfter);if(r)return{state:n.streamParser.copyState(r),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof te&&a<s&&No(n,l,a,i,s);if(h)return h}return null}function lf(n,e,t,i,s){if(s&&t<=0&&i>=e.length)return e;!s&&t==0&&e.type==n.topNode&&(s=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],l=e.children[r],a;if(o<i&&l instanceof te){if(!(a=lf(n,l,t-o,i-o,s)))break;return s?new te(e.type,e.children.slice(0,r).concat(a),e.positions.slice(0,r+1),o+a.length):a}}return null}function v0(n,e,t,i,s){for(let r of e){let o=r.from+(r.openStart?25:0),l=r.to-(r.openEnd?25:0),a=o<=t&&l>t&&No(n,r.tree,0-r.offset,t,l),h;if(a&&a.pos<=i&&(h=lf(n,r.tree,t+r.offset,a.pos+r.offset,!1)))return{state:a.state,tree:h}}return{state:n.streamParser.startState(s?ei(s):4),tree:te.empty}}class w0{constructor(e,t,i,s){this.lang=e,this.input=t,this.fragments=i,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let r=Si.get(),o=s[0].from,{state:l,tree:a}=v0(e,i,o,this.to,r==null?void 0:r.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);r&&this.parsedPos<r.viewport.from-1e5&&s.some(h=>h.from<=r.viewport.from&&h.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(ei(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=Si.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+512);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
23
23
|
`&&(t="");else{let i=t.indexOf(`
|
|
24
24
|
`);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let s=this.rangeIndex;;){let r=this.ranges[s].to;if(r>=i||(t=t.slice(0,r-(i-t.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let s=this.ranges[this.rangeIndex].to,r=e+t;if(i>0?s>r:s>=r)break;let o=this.ranges[++this.rangeIndex].from;t+=o-s}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,s){let r=4;if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let l=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-l}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&r==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=i:this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),s=0,{streamParser:r}=this.lang,o=new jc(t,e?e.state.tabSize:4,e?ei(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=af(r.token,o,this.state);if(l&&(s=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,s)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=te.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:k0,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new te(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new te(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function af(n,e,t){e.start=e.pos;for(let i=0;i<10;i++){let s=n(e,t);if(e.pos>e.start)return s}throw new Error("Stream parser failed to advance stream.")}const Vo=Object.create(null),nn=[Le.none],k0=new Oo(nn),Ca=[],Aa=Object.create(null),hf=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])hf[n]=ff(Vo,e);class cf{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),hf)}resolve(e){return e?this.table[e]||(this.table[e]=ff(this.extra,e)):0}}const S0=new cf(Vo);function lr(n,e){Ca.indexOf(n)>-1||(Ca.push(n),console.warn(e))}function ff(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=n[h]||k[h];c?typeof c=="function"?a.length?a=a.map(c):lr(h,`Modifier ${h} used at start of tag`):a.length?lr(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:lr(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(l=>l.id),r=Aa[s];if(r)return r.id;let o=Aa[s]=Le.define({id:nn.length,name:i,props:[Mg({[i]:t})]});return nn.push(o),o.id}function C0(n,e){let t=Le.define({id:nn.length,name:"Document",props:[Gt.add(()=>n),$c.add(()=>i=>e.getIndent(i))],top:!0});return nn.push(t),t}Z.RTL,Z.LTR;const A0=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Fo(n.state,t.from);return i.line?M0(n):i.block?E0(n):!1};function Wo(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const M0=Wo(L0,0),T0=Wo(uf,0),E0=Wo((n,e)=>uf(n,e,O0(e)),0);function Fo(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Ri=50;function D0(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-Ri,i),o=n.sliceDoc(s,s+Ri),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,f;s-i<=2*Ri?c=f=n.sliceDoc(i,s):(c=n.sliceDoc(i,i+Ri),f=n.sliceDoc(s-Ri,s));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function O0(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to);s.from>i.from&&s.from==t.to&&(s=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function uf(n,e,t=e.selection.ranges){let i=t.map(r=>Fo(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>D0(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:h,close:c}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:r}}return null}function L0(n,e,t=e.selection.ranges){let i=[],s=-1;e:for(let{from:r,to:o}of t){let l=i.length,a=1e9,h;for(let c=r;c<=o;){let f=e.doc.lineAt(c);if(h==null&&(h=Fo(e,f.from).line,!h))continue e;if(f.from>s&&(r==o||o>f.from)){s=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}const oo=gt.define(),_0=gt.define(),P0=P.define(),df=P.define({combine(n){return xt(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),pf=Ce.define({create(){return pt.empty},update(n,e){let t=e.state.facet(df),i=e.annotation(oo);if(i){let a=Be.fromTransaction(e,i.selection),h=i.side,c=h==0?n.undone:n.done;return a?c=ms(c,c.length,t.minDepth,a):c=xf(c,e.startState.selection),new pt(h==0?i.rest:c,h==0?c:i.rest)}let s=e.annotation(_0);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(fe.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=Be.fromTransaction(e),o=e.annotation(fe.time),l=e.annotation(fe.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new pt(n.done.map(Be.fromJSON),n.undone.map(Be.fromJSON))}});function R0(n={}){return[pf,df.of(n),D.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?mf:e.inputType=="historyRedo"?lo:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ps(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(pf,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const mf=Ps(0,!1),lo=Ps(1,!1),I0=Ps(0,!0),B0=Ps(1,!0);class Be{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new Be(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Be(e.changes&&ue.fromJSON(e.changes),[],e.mapped&&mt.fromJSON(e.mapped),e.startSelection&&v.fromJSON(e.startSelection),e.selectionsAfter.map(v.fromJSON))}static fromTransaction(e,t){let i=Ke;for(let s of e.startState.facet(P0)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new Be(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ke)}static selection(e){return new Be(void 0,Ke,void 0,void 0,e)}}function ms(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function N0(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function V0(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function gf(n,e){return n.length?e.length?n.concat(e):n:e}const Ke=[],W0=200;function xf(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-W0));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),ms(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Be.selection([e])]}function F0(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function ar(n,e){if(!n.length)return n;let t=n.length,i=Ke;for(;t;){let s=H0(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[Be.selection(i)]:Ke}function H0(n,e,t){let i=gf(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Ke,t);if(!n.changes)return Be.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new Be(s,F.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const j0=/^(input\.type|delete)($|\.)/;class pt{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new pt(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||j0.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,N0(l.changes,e.changes))||i=="input.type.compose")?o=ms(o,o.length-1,s.minDepth,new Be(e.changes.compose(l.changes),gf(F.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Ke)):o=ms(o,o.length,s.minDepth,e),new pt(o,Ke,t,i)}addSelection(e,t,i,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Ke;return r.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&V0(r[r.length-1],e)?this:new pt(xf(this.done,e),this.undone,t,i)}addMapping(e){return new pt(ar(this.done,e),ar(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:oo.of({side:e,rest:F0(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?Ke:s.slice(0,s.length-1);return r.mapped&&(l=ar(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:oo.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}pt.empty=new pt(Ke,Ke);const z0=[{key:"Mod-z",run:mf,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:lo,preventDefault:!0},{linux:"Ctrl-Shift-z",run:lo,preventDefault:!0},{key:"Mod-u",run:I0,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:B0,preventDefault:!0}];function Ti(n,e){return v.create(n.ranges.map(e),n.mainIndex)}function it(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function nt({state:n,dispatch:e},t){let i=Ti(n.selection,t);return i.eq(n.selection,!0)?!1:(e(it(n,i)),!0)}function Rs(n,e){return v.cursor(e?n.to:n.from)}function yf(n,e){return nt(n,t=>t.empty?n.moveByChar(t,e):Rs(t,e))}function Te(n){return n.textDirectionAt(n.state.selection.main.head)==Z.LTR}const bf=n=>yf(n,!Te(n)),vf=n=>yf(n,Te(n));function wf(n,e){return nt(n,t=>t.empty?n.moveByGroup(t,e):Rs(t,e))}const q0=n=>wf(n,!Te(n)),$0=n=>wf(n,Te(n));function K0(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Is(n,e,t){let i=Se(n).resolveInner(e.head),s=t?q.closedBy:q.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;K0(n,h,s)?i=h:a=t?h.to:h.from}let r=i.type.prop(s),o,l;return r&&(o=t?dt(n,i.from,1):dt(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,v.cursor(l,t?-1:1)}const U0=n=>nt(n,e=>Is(n.state,e,!Te(n))),G0=n=>nt(n,e=>Is(n.state,e,Te(n)));function kf(n,e){return nt(n,t=>{if(!t.empty)return Rs(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const Sf=n=>kf(n,!1),Cf=n=>kf(n,!0);function Af(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,s;if(e){for(let r of n.state.facet(D.scrollMargins)){let o=r(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}s=n.scrollDOM.clientHeight-t-i}else s=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,s-5)}}function Mf(n,e){let t=Af(n),{state:i}=n,s=Ti(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):Rs(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(r=D.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(it(i,s),{effects:r}),!0}const Ma=n=>Mf(n,!1),ao=n=>Mf(n,!0);function Ft(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=v.cursor(i.from+r))}return s}const J0=n=>nt(n,e=>Ft(n,e,!0)),Y0=n=>nt(n,e=>Ft(n,e,!1)),X0=n=>nt(n,e=>Ft(n,e,!Te(n))),Q0=n=>nt(n,e=>Ft(n,e,Te(n))),Z0=n=>nt(n,e=>n.moveToLineBoundary(e,!1,!1)),ex=n=>nt(n,e=>n.moveToLineBoundary(e,!0,!1));function tx(n,e,t){let i=!1,s=Ti(n.selection,r=>{let o=dt(n,r.head,-1)||dt(n,r.head,1)||r.head>0&&dt(n,r.head-1,1)||r.head<n.doc.length&&dt(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return v.cursor(l)});return i?(e(it(n,s)),!0):!1}const ix=({state:n,dispatch:e})=>tx(n,e);function Ge(n,e,t){let i=Ti(n.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=v.range(s.head,s.anchor));let r=t(s);return v.range(s.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(it(n.state,i)),!0)}function Tf(n,e){return Ge(n,e,t=>n.moveByChar(t,e))}const Ef=n=>Tf(n,!Te(n)),Df=n=>Tf(n,Te(n));function Of(n,e){return Ge(n,e,t=>n.moveByGroup(t,e))}const nx=n=>Of(n,!Te(n)),sx=n=>Of(n,Te(n)),rx=n=>{let e=!Te(n);return Ge(n,e,t=>Is(n.state,t,e))},ox=n=>{let e=Te(n);return Ge(n,e,t=>Is(n.state,t,e))};function Lf(n,e){return Ge(n,e,t=>n.moveVertically(t,e))}const _f=n=>Lf(n,!1),Pf=n=>Lf(n,!0);function Rf(n,e){return Ge(n,e,t=>n.moveVertically(t,e,Af(n).height))}const Ta=n=>Rf(n,!1),Ea=n=>Rf(n,!0),lx=n=>Ge(n,!0,e=>Ft(n,e,!0)),ax=n=>Ge(n,!1,e=>Ft(n,e,!1)),hx=n=>{let e=!Te(n);return Ge(n,e,t=>Ft(n,t,e))},cx=n=>{let e=Te(n);return Ge(n,e,t=>Ft(n,t,e))},fx=n=>Ge(n,!1,e=>v.cursor(n.lineBlockAt(e.head).from)),ux=n=>Ge(n,!0,e=>v.cursor(n.lineBlockAt(e.head).to)),Da=({state:n,dispatch:e})=>(e(it(n,{anchor:0})),!0),Oa=({state:n,dispatch:e})=>(e(it(n,{anchor:n.doc.length})),!0),La=({state:n,dispatch:e})=>(e(it(n,{anchor:n.selection.main.anchor,head:0})),!0),_a=({state:n,dispatch:e})=>(e(it(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),dx=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),px=({state:n,dispatch:e})=>{let t=Bs(n).map(({from:i,to:s})=>v.undirectionalRange(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:v.create(t),userEvent:"select"})),!0},mx=({state:n,dispatch:e})=>{let t=Ti(n.selection,i=>{let s=Se(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return v.undirectionalRange(l.from,l.to)}return i});return t.eq(n.selection)?!1:(e(it(n,t)),!0)};function If(n,e){let{state:t}=n,i=t.selection,s=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<n.state.doc.length:o.from>0)for(let l=r;;){let a=n.moveVertically(l,e);if(a.head<o.from||a.head>o.to){s.some(h=>h.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==i.ranges.length?!1:(n.dispatch(it(t,v.create(s,s.length-1))),!0)}const gx=n=>If(n,!1),xx=n=>If(n,!0),yx=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=v.create([t.main]):t.main.empty||(i=v.create([v.cursor(t.main.head)])),i?(e(it(n,i)),!0):!1};function xn(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=Fn(n,a,!1)):a>o&&(t="delete.forward",a=Fn(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Fn(n,o,!1),l=Fn(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:v.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?D.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Fn(n,e,t){if(n instanceof D)for(let i of n.state.facet(D.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const Bf=(n,e,t)=>xn(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let h=Mi(l,r.tabSize),c=h%ei(r)||ei(r);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)s--;a=s}else a=me(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=me(o.text,a-o.from,!1,!1)+o.from);return a}),ho=n=>Bf(n,!1,!0),Nf=n=>Bf(n,!0,!1),Vf=(n,e)=>xn(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=me(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),Wf=n=>Vf(n,!1),bx=n=>Vf(n,!0),vx=n=>xn(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),wx=n=>xn(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),kx=n=>xn(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),Sx=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:U.of(["",""])},range:v.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Cx=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:me(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:me(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:v.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Bs(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function Ff(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of Bs(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(v.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(v.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:v.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Ax=({state:n,dispatch:e})=>Ff(n,e,!1),Mx=({state:n,dispatch:e})=>Ff(n,e,!0);function Hf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of Bs(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let s=n.changes(i);return e(n.update({changes:s,selection:n.selection.map(s,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Tx=({state:n,dispatch:e})=>Hf(n,e,!1),Ex=({state:n,dispatch:e})=>Hf(n,e,!0),Dx=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Bs(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),i=Ti(e.selection,s=>{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Ox(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Se(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(q.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const Pa=jf(!1),Lx=jf(!0);function jf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&Ox(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new Ls(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Ro(h,r);for(c==null&&(c=Mi(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",tn(e,c)];return a&&f.push(tn(e,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:U.of(f)},range:v.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ho(n,e){let t=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:v.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const _x=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Ls(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Ho(n,(r,o,l)=>{let a=Ro(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=tn(n,a);(h!=c||l.from<r.from+h.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:c}))});return s.changes.empty||e(n.update(s,{userEvent:"indent"})),!0},zf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ho(n,(t,i)=>{i.push({from:t.from,insert:n.facet(pn)})}),{userEvent:"input.indent"})),!0),qf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ho(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=Mi(s,n.tabSize),o=0,l=tn(n,Math.max(0,r-ei(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Px=n=>(n.setTabFocusMode(),!0),Rx=[{key:"Ctrl-b",run:bf,shift:Ef,preventDefault:!0},{key:"Ctrl-f",run:vf,shift:Df},{key:"Ctrl-p",run:Sf,shift:_f},{key:"Ctrl-n",run:Cf,shift:Pf},{key:"Ctrl-a",run:Z0,shift:fx},{key:"Ctrl-e",run:ex,shift:ux},{key:"Ctrl-d",run:Nf},{key:"Ctrl-h",run:ho},{key:"Ctrl-k",run:vx},{key:"Ctrl-Alt-h",run:Wf},{key:"Ctrl-o",run:Sx},{key:"Ctrl-t",run:Cx},{key:"Ctrl-v",run:ao}],Ix=[{key:"ArrowLeft",run:bf,shift:Ef,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:q0,shift:nx,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:X0,shift:hx,preventDefault:!0},{key:"ArrowRight",run:vf,shift:Df,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:$0,shift:sx,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Q0,shift:cx,preventDefault:!0},{key:"ArrowUp",run:Sf,shift:_f,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Da,shift:La},{mac:"Ctrl-ArrowUp",run:Ma,shift:Ta},{key:"ArrowDown",run:Cf,shift:Pf,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Oa,shift:_a},{mac:"Ctrl-ArrowDown",run:ao,shift:Ea},{key:"PageUp",run:Ma,shift:Ta},{key:"PageDown",run:ao,shift:Ea},{key:"Home",run:Y0,shift:ax,preventDefault:!0},{key:"Mod-Home",run:Da,shift:La},{key:"End",run:J0,shift:lx,preventDefault:!0},{key:"Mod-End",run:Oa,shift:_a},{key:"Enter",run:Pa,shift:Pa},{key:"Mod-a",run:dx},{key:"Backspace",run:ho,shift:ho,preventDefault:!0},{key:"Delete",run:Nf,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Wf,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:bx,preventDefault:!0},{mac:"Mod-Backspace",run:wx,preventDefault:!0},{mac:"Mod-Delete",run:kx,preventDefault:!0}].concat(Rx.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Bx=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:U0,shift:rx},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:G0,shift:ox},{key:"Alt-ArrowUp",run:Ax},{key:"Shift-Alt-ArrowUp",run:Tx},{key:"Alt-ArrowDown",run:Mx},{key:"Shift-Alt-ArrowDown",run:Ex},{key:"Mod-Alt-ArrowUp",run:gx},{key:"Mod-Alt-ArrowDown",run:xx},{key:"Escape",run:yx},{key:"Mod-Enter",run:Lx},{key:"Alt-l",mac:"Ctrl-l",run:px},{key:"Mod-i",run:mx,preventDefault:!0},{key:"Mod-[",run:qf},{key:"Mod-]",run:zf},{key:"Mod-Alt-\\",run:_x},{key:"Shift-Mod-k",run:Dx},{key:"Shift-Mod-\\",run:ix},{key:"Mod-/",run:A0},{key:"Alt-A",mac:"Ctrl-A",run:T0},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Px}].concat(Ix),Nx={key:"Tab",run:zf,shift:qf},Ra=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Ai{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(Ra(l)):Ra,this.query=this.normalize(t)}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 _e(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 t=uo(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=ht(e);let s=this.normalize(t);if(s.length)for(let r=0,o=i,l=!0;;r++){let a=s.charCodeAt(r),h=this.match(a,o,l,this.bufferPos+this.bufferStart,r==s.length-1);if(h)return this.value=h,this;if(r==s.length-1)break;l&&r<t.length&&t.charCodeAt(r)==a?o++:l=!1}}}match(e,t,i,s,r){let o=null;for(let l=0;l<this.matches.length;){let a=this.matches[l],h=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?o={from:a.from,to:s,precise:r&&a.precise}:(a.index++,h=!0)),h?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:s,precise:i&&r}:this.matches.push({from:t,index:1,precise:i})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(Ai.prototype[Symbol.iterator]=function(){return this});const $f={from:-1,to:-1,match:/.*/.exec(""),precise:!0},jo="gm"+(/x/.unicode==null?"":"u");class Kf{constructor(e,t,i,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=$f,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Uf(e,t,i,s,r);this.re=new RegExp(t,jo+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=gs(e,s),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 t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,s=i+t[0].length;if(this.matchPos=gs(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,precise:!0,match:t},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 hr=new WeakMap;class pi{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=hr.get(e);if(!s||s.from>=i||s.to<=t){let l=new pi(t,e.sliceString(t,i));return hr.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<i&&(r+=e.sliceString(s.to,i)),hr.set(e,new pi(o,r)),new pi(t,r.slice(t-o,i-o))}}class Uf{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=!1,this.value=$f,this.matchPos=gs(e,s),this.re=new RegExp(t,jo+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=pi.get(e,s,this.chunkEnd(s+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,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,s=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,precise:!0,match:t},this.matchPos=gs(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=pi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Kf.prototype[Symbol.iterator]=Uf.prototype[Symbol.iterator]=function(){return this});function Vx(n){try{return new RegExp(n,jo),!0}catch{return!1}}function gs(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}const Wx=n=>{let e=Um(n,"cm-goto-line");if(e){let o=e.dom.querySelector("input[type=text]");return o&&o.select(),!0}let{state:t}=n,i=String(t.doc.lineAt(n.state.selection.main.head).number),{close:s,result:r}=Km(n,{class:"cm-goto-line",label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return r.then(o=>{let l=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!l){n.dispatch({effects:s});return}let a=t.doc.lineAt(t.selection.main.head),[,h,c,f,u]=l,d=f?+f.slice(1):0,p=c?+c:a.number;if(c&&u){let x=p/100;h&&(x=x*(h=="-"?-1:1)+a.number/t.doc.lines),p=Math.round(t.doc.lines*x)}else c&&h&&(p=p*(h=="-"?-1:1)+a.number);let m=t.doc.line(Math.max(1,Math.min(t.doc.lines,p))),g=v.cursor(m.from+Math.max(0,Math.min(d,m.length)));n.dispatch({effects:[s,D.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},Fx={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Hx=P.define({combine(n){return xt(n,Fx,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function jx(n){return[Ux,Kx]}const zx=N.mark({class:"cm-selectionMatch"}),qx=N.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Ia(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=oe.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=oe.Word)}function $x(n,e,t,i){return n(e.sliceDoc(t,t+1))==oe.Word&&n(e.sliceDoc(i-1,i))==oe.Word}const Kx=le.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Hx),{state:t}=n,i=t.selection;if(i.ranges.length>1)return N.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return N.none;let a=t.wordAt(s.head);if(!a)return N.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return N.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Ia(o,t,s.from,s.to)&&$x(o,t,s.from,s.to)))return N.none}else if(r=t.sliceDoc(s.from,s.to),!r)return N.none}let l=[];for(let a of n.visibleRanges){let h=new Ai(t.doc,r,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||Ia(o,t,c,f))&&(s.empty&&c<=s.from&&f>=s.to?l.push(qx.range(c,f)):(c>=s.to||f<=s.from)&&l.push(zx.range(c,f)),l.length>e.maxMatches))return N.none}}return N.set(l)}},{decorations:n=>n.decorations}),Ux=D.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Gx=({state:n,dispatch:e})=>{let{selection:t}=n,i=v.create(t.ranges.map(s=>n.wordAt(s.head)||v.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function Jx(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new Ai(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Ai(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const Yx=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return Gx({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=Jx(n,i);return s?(e(n.update({selection:n.selection.addRange(v.range(s.from,s.to),!1),effects:D.scrollIntoView(s.to)})),!0):!1},Ei=P.define({combine(n){return xt(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new cy(e),scrollToMatch:e=>D.scrollIntoView(e)})}});class Gf{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||Vx(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
25
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new iy(this):new Zx(this)}getCursor(e,t=0,i){let s=e.doc?e:K.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?ri(this,s,t,i):si(this,s,t,i)}}class Jf{constructor(e){this.spec=e}}function Xx(n,e,t){return(i,s,r,o)=>{if(t&&!t(i,s,r,o))return!1;let l=i>=o&&s<=o+r.length?r.slice(i-o,s-o):e.doc.sliceString(i,s);return n(l,e,i,s)}}function si(n,e,t,i){let s;return n.wholeWord&&(s=Qx(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(s=Xx(n.test,e,s)),new Ai(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),s)}function Qx(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(xs(s,t-r))!=oe.Word||e(ys(s,t-r))!=oe.Word)&&(e(ys(s,i-r))!=oe.Word||e(xs(s,i-r))!=oe.Word))}class Zx extends Jf{constructor(e){super(e)}nextMatch(e,t,i){let s=si(this.spec,e,i,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=si(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==i?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=si(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=i)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=si(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=si(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function ey(n,e,t){return(i,s,r)=>(!t||t(i,s,r))&&n(r[0],e,i,s)}function ri(n,e,t,i){let s;return n.wholeWord&&(s=ty(e.charCategorizer(e.selection.main.head))),n.test&&(s=ey(n.test,e,s)),new Kf(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:s},t,i)}function xs(n,e){return n.slice(me(n,e,!1),e)}function ys(n,e){return n.slice(e,me(n,e))}function ty(n){return(e,t,i)=>!i[0].length||(n(xs(i.input,i.index))!=oe.Word||n(ys(i.input,i.index))!=oe.Word)&&(n(ys(i.input,i.index+i[0].length))!=oe.Word||n(xs(i.input,i.index+i[0].length))!=oe.Word)}class iy extends Jf{nextMatch(e,t,i){let s=ri(this.spec,e,i,e.doc.length).next();return s.done&&(s=ri(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=ri(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let s=i.length;s>0;s--){let r=+i.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+i.slice(s)}return t})}matchAll(e,t){let i=ri(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ri(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const sn=F.define(),zo=F.define(),Lt=Ce.define({create(n){return new cr(co(n).create(),null)},update(n,e){for(let t of e.effects)t.is(sn)?n=new cr(t.value.create(),n.panel):t.is(zo)&&(n=new cr(n.query,t.value?qo:null));return n},provide:n=>Qi.from(n,e=>e.panel)});class cr{constructor(e,t){this.query=e,this.panel=t}}const ny=N.mark({class:"cm-searchMatch"}),sy=N.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ry=le.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Lt))}update(n){let e=n.state.field(Lt);(e!=n.startState.field(Lt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return N.none;let{view:t}=this,i=new Ze;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?sy:ny)})}return i.finish()}},{decorations:n=>n.decorations});function yn(n){return e=>{let t=e.state.field(Lt,!1);return t&&t.query.spec.valid?n(e,t):Qf(e)}}const bs=yn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=v.single(i.from,i.to),r=n.state.facet(Ei);return n.dispatch({selection:s,effects:[$o(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Xf(n),!0}),vs=yn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=v.single(s.from,s.to),o=n.state.facet(Ei);return n.dispatch({selection:r,effects:[$o(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Xf(n),!0}),oy=yn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:v.create(t.map(i=>v.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),ly=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new Ai(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(v.range(l.value.from,l.value.to))}return e(n.update({selection:v.create(r,o),userEvent:"select.search.matches"})),!0},Ba=yn((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,h,c=[];o.precise?o.from==i&&o.to==s&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(t,o.from,o.to),c.push(D.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let f=n.state.changes(l);return o&&(a=v.single(o.from,o.to).map(f),c.push($o(n,o)),c.push(t.facet(Ei).scrollToMatch(a.main,n))),n.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),ay=yn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let s of e.matchAll(n.state,1e9)){let{from:r,to:o,precise:l}=s;l&&t.push({from:r,to:o,insert:e.getReplacement(s)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:D.announce.of(i),userEvent:"input.replace.all"}),!0});function qo(n){return n.state.facet(Ei).createPanel(n)}function co(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(Ei);return new Gf({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Yf(n){let e=Os(n,qo);return e&&e.dom.querySelector("[main-field]")}function Xf(n){let e=Yf(n);e&&e==n.root.activeElement&&e.select()}const Qf=n=>{let e=n.state.field(Lt,!1);if(e&&e.panel){let t=Yf(n);if(t&&t!=n.root.activeElement){let i=co(n.state,e.query.spec);i.valid&&n.dispatch({effects:sn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[zo.of(!0),e?sn.of(co(n.state,e.query.spec)):F.appendConfig.of(uy)]});return!0},Zf=n=>{let e=n.state.field(Lt,!1);if(!e||!e.panel)return!1;let t=Os(n,qo);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:zo.of(!1)}),!0},hy=[{key:"Mod-f",run:Qf,scope:"editor search-panel"},{key:"F3",run:bs,shift:vs,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:bs,shift:vs,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Zf,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ly},{key:"Mod-Alt-g",run:Wx},{key:"Mod-d",run:Yx,preventDefault:!0}];class cy{constructor(e){this.view=e;let t=this.query=e.state.field(Lt).query.spec;this.commit=this.commit.bind(this),this.searchField=Q("input",{value:t.search,placeholder:We(e,"Find"),"aria-label":We(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Q("input",{value:t.replace,placeholder:We(e,"Replace"),"aria-label":We(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Q("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Q("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Q("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return Q("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=Q("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>bs(e),[We(e,"next")]),i("prev",()=>vs(e),[We(e,"previous")]),i("select",()=>oy(e),[We(e,"all")]),Q("label",null,[this.caseField,We(e,"match case")]),Q("label",null,[this.reField,We(e,"regexp")]),Q("label",null,[this.wordField,We(e,"by word")]),...e.state.readOnly?[]:[Q("br"),this.replaceField,i("replace",()=>Ba(e),[We(e,"replace")]),i("replaceAll",()=>ay(e),[We(e,"replace all")])],Q("button",{name:"close",onclick:()=>Zf(e),"aria-label":We(e,"close"),type:"button"},["×"])])}commit(){let e=new Gf({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:sn.of(e)}))}keydown(e){em(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?vs:bs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Ba(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(sn)&&!i.value.eq(this.query)&&this.setQuery(i.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(Ei).top}}function We(n,e){return n.state.phrase(e)}const Hn=30,jn=/[\s\.,:;?!]/;function $o(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-Hn),o=Math.min(s,t+Hn),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<Hn;a++)if(!jn.test(l[a+1])&&jn.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-Hn;a--)if(!jn.test(l[a-1])&&jn.test(l[a])){l=l.slice(0,a);break}}return D.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const fy=D.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"}}),uy=[Lt,Wt.low(ry),fy];class eu{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Se(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(tu(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Na(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function dy(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=Na(e)+Na(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function py(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:dy(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function n1(n,e){return t=>{for(let i=Se(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class Va{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function Xt(n){return n.selection.main.from}function tu(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Ko=gt.define();function my(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return{...n.changeByRange(l=>{if(l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i))return{range:l};let a=n.toText(e);return{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:a},range:v.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Wa=new WeakMap;function gy(n){if(!Array.isArray(n))return n;let e=Wa.get(n);return e||Wa.set(n,e=py(n)),e}const ws=F.define(),rn=F.define();class xy{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=_e(e,t),s=ht(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(_e(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let A=_e(e,0),w=ht(A),E=w==e.length?0:-100;if(A!=t[0])if(A==i[0])E+=-200;else return null;return this.ret(E,[0,w])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let A=0,w=Math.min(e.length,200);A<w&&h<a;){let E=_e(e,A);(E==t[h]||E==i[h])&&(s[h++]=A),A+=ht(E)}if(h<a)return null}let c=0,f=0,u=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),x=!0;for(let A=0,w=Math.min(e.length,200),E=0;A<w&&f<a;){let S=_e(e,A);l<0&&(c<a&&S==t[c]&&(r[c++]=A),d<a&&(S==t[d]||S==i[d]?(d==0&&(p=A),m=A+1,d++):d=0));let M,T=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(M=uo(S))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!A||T==1&&g||E==0&&T!=0)&&(t[f]==S||i[f]==S&&(u=!0)?o[f++]=A:o.length&&(x=!1)),E=T,A+=ht(S)}return f==a&&o[0]==0&&x?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):f==a?this.result(-100+(u?-200:0)+-700+(x?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?ht(_e(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}}class yy{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 t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const pe=P.define({combine(n){return xt(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:by,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Fa(e(i),t(i)),optionClass:(e,t)=>i=>Fa(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Fa(n,e){return n?e?n+" "+e:n:e}function by(n,e,t,i,s,r){let o=n.textDirection==Z.RTL,l=o,a=!1,h="top",c,f,u=e.left-s.left,d=s.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))c=Math.max(s.top,Math.min(t.top,s.bottom-m))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:s.right-e.left)-30);let A=s.bottom-e.bottom;A>=m||A>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let g=(e.bottom-e.top)/r.offsetHeight,x=(e.right-e.left)/r.offsetWidth;return{style:`${h}: ${c/g}px; max-width: ${f/x}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const Uo=F.define();function vy(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<r.length;){let c=r[h++],f=r[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function fr(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class wy{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(pe);this.optionContent=vy(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=fr(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(e,h[+f[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:Uo.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(pe).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:rn.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=fr(r.length,o,e.state.facet(pe).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=fr(t.options.length,t.selected,this.view.state.facet(pe).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,s)}).catch(l=>Ie(this.view.state,l,"completion info")):(this.addInfoPane(o,s),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Sy(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(pe).positionInfo(this.view,t,s,i,r,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,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof h!="string"&&h.header)s.appendChild(h.header(h));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function ky(n,e){return t=>new wy(t,n,e)}function Sy(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/s:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function Ha(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Cy(n,e){let t=[],i=null,s=null,r=c=>{t.push(c);let{section:f}=c.completion;if(f){i||(i=[]);let u=typeof f=="string"?f:f.name;i.some(d=>d.name==u)||i.push(typeof f=="string"?{name:u}:f)}},o=e.facet(pe);for(let c of n)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)r(new Va(u,c.source,f?f(u):[],1e9-t.length));else{let u=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new yy(u):new xy(u);for(let m of c.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,x=d.score+(m.boost||0);if(r(new Va(m,c.source,g,x)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:A}=m.section;s||(s=Object.create(null)),s[A]=Math.max(x,s[A]||-1e9)}}}}if(i){let c=Object.create(null),f=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?s[p.name]-s[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(u))f-=1e5,c[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let c of t.sort((f,u)=>u.score-f.score||h(f.completion,u.completion))){let f=c.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?l.push(c):Ha(c.completion)>Ha(a)&&(l[l.length-1]=c),a=c.completion}return l}class ai{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new ai(this.options,ja(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,o){if(s&&!o&&e.some(h=>h.isPending))return s.setDisabled();let l=Cy(e,t);if(!l.length)return s&&e.some(h=>h.isPending)?s.setDisabled():null;let a=t.facet(pe).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let h=s.options[s.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==h){a=c;break}}return new ai(l,ja(i,a),{pos:e.reduce((h,c)=>c.hasResult()?Math.min(h,c.from):h,1e8),create:Oy,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new ai(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new ai(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ks{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new ks(Ey,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(pe),r=(i.override||t.languageDataAt("autocomplete",Xt(t)).map(gy)).map(a=>(this.active.find(c=>c.source==a)||new Ue(a,this.active.some(c=>c.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Go));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Ay(r,this.active)||l?o=ai.build(r,t,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new Ue(a.source,0):a));for(let a of e.effects)a.is(Uo)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new ks(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?My:Ty}}function Ay(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const My={"aria-autocomplete":"list"},Ty={};function ja(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const Ey=[];function iu(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Ko);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class Ue{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=iu(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new Ue(s.source,0)),i&4&&s.state==0&&(s=new Ue(this.source,1)),s=s.updateFor(e,i);for(let r of e.effects)if(r.is(ws))s=new Ue(s.source,1,r.value);else if(r.is(rn))s=new Ue(s.source,0);else if(r.is(Go))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Xt(e.state))}}class mi extends Ue{constructor(e,t,i,s,r,o){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=Xt(e.state);if(l>o||!s||t&2&&(Xt(e.startState)==this.from||l<this.limit))return new Ue(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return Dy(s.validFor,e.state,r,o)?new mi(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new eu(e.state,l,!1)))?new mi(this.source,this.explicit,a,s,s.from,(i=s.to)!==null&&i!==void 0?i:Xt(e.state)):new Ue(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new mi(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new Ue(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Dy(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):tu(n,!0).test(s)}const Go=F.define({map(n,e){return n.map(t=>t.map(e))}}),Pe=Ce.define({create(){return ks.start()},update(n,e){return n.update(e)},provide:n=>[Do.from(n,e=>e.tooltip),D.contentAttributes.from(n,e=>e.attrs)]});function Jo(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(Pe).active.find(s=>s.source==e.source);return i instanceof mi?(typeof t=="string"?n.dispatch({...my(n.state,t,i.from,i.to),annotations:Ko.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const Oy=ky(Pe,Jo);function zn(n,e="option"){return t=>{let i=t.state.field(Pe,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(pe).interactionDelay)return!1;let s=1,r;e=="page"&&(r=Dc(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Uo.of(l)}),!0}}const Ly=n=>{let e=n.state.field(Pe,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(pe).interactionDelay?!1:Jo(n,e.open.options[e.open.selected])},ur=n=>n.state.field(Pe,!1)?(n.dispatch({effects:ws.of(!0)}),!0):!1,_y=n=>{let e=n.state.field(Pe,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:rn.of(null)}),!0)};class Py{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ry=50,Iy=1e3,By=le.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(Pe).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(Pe),t=n.state.facet(pe);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Pe)==e)return;let i=n.transactions.some(r=>{let o=iu(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>Ry&&Date.now()-o.time>Iy){for(let l of o.context.abortListeners)try{l()}catch(a){Ie(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(ws)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(Pe);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pe).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Xt(e),i=new eu(e,t,n.explicit,this.view),s=new Py(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:rn.of(null)}),Ie(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pe).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(pe),i=this.view.state.field(Pe);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=Xt(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),h=new mi(r.active.source,r.active.explicit,a,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:l);for(let c of r.updates)h=h.update(c,t);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new Ue(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Go.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Pe,!1);if(e&&e.tooltip&&this.view.state.facet(pe).closeOnBlur){let t=e.open&&Dc(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:rn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ws.of(!1)}),20),this.composing=0}}}),Ny=typeof navigator=="object"&&/Win/.test(navigator.platform),Vy=Wt.highest(D.domEventHandlers({keydown(n,e){let t=e.state.field(Pe,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||!n.key||n.key.length>1||n.ctrlKey&&!(Ny&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&Jo(e,i),!1}})),nu=D.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",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Wy{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class Yo{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,we.TrackDel),i=e.mapPos(this.to,1,we.TrackDel);return t==null||i==null?null:new Yo(this.field,t,i)}}class Xo{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,c=/^\t*/.exec(a)[0].length;for(let f=0;f<c;f++)h+=e.facet(pn);s.push(t+h.length-c),a=h+a.slice(c)}i.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new Yo(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1;l===0&&(l=1e9);let c=a.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(l!=null?t[f].seq==l:c&&t[f].name==c)&&(h=f);if(h<0){let f=0;for(;f<t.length&&(l==null||t[f].seq!=null&&t[f].seq<l);)f++;t.splice(f,0,{seq:l,name:c}),h=f;for(let u of s)u.field>=h&&u.field++}for(let f of s)if(f.line==i.length&&f.from>r.index){let u=r[2]?3+(r[1]||"").length:2;f.from-=u,f.to-=u}s.push(new Wy(h,i.length,r.index,r.index+c.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let c of s)c.line==i.length&&c.from>h&&(c.from--,c.to--);return a}),i.push(o)}return new Xo(i,s)}}let Fy=N.widget({widget:new class extends tt{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Hy=N.mark({class:"cm-snippetField"});class Di{constructor(e,t){this.ranges=e,this.active=t,this.deco=N.set(e.map(i=>(i.from==i.to?Fy:Hy).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new Di(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const bn=F.define({map(n,e){return n&&n.map(e)}}),jy=F.define(),on=Ce.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(bn))return t.value;if(t.is(jy)&&n)return new Di(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>D.decorations.from(n,e=>e?e.deco:N.none)});function Qo(n,e){return v.create(n.filter(t=>t.field==e).map(t=>v.range(t.from,t.to)))}function zy(n){let e=Xo.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),{main:a}=t.state.selection,h={changes:{from:s,to:r==a.from?a.to:r,insert:U.of(o)},scrollIntoView:!0,annotations:i?[Ko.of(i),fe.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=Qo(l,0)),l.some(c=>c.field>0)){let c=new Di(l,0),f=h.effects=[bn.of(c)];t.state.field(on,!1)===void 0&&f.push(F.appendConfig.of([on,Gy,Jy,nu]))}t.dispatch(t.state.update(h))}}function su(n){return({state:e,dispatch:t})=>{let i=e.field(on,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:Qo(i.ranges,s),effects:bn.of(r?null:new Di(i.ranges,s)),scrollIntoView:!0})),!0}}const qy=({state:n,dispatch:e})=>n.field(on,!1)?(e(n.update({effects:bn.of(null)})),!0):!1,$y=su(1),Ky=su(-1),Uy=[{key:"Tab",run:$y,shift:Ky},{key:"Escape",run:qy}],za=P.define({combine(n){return n.length?n[0]:Uy}}),Gy=Wt.highest(dn.compute([za],n=>n.facet(za)));function s1(n,e){return{...e,apply:zy(n)}}const Jy=D.domEventHandlers({mousedown(n,e){let t=e.state.field(on,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:Qo(t.ranges,s.field),effects:bn.of(t.ranges.some(r=>r.field>s.field)?new Di(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),ln={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Jt=F.define({map(n,e){let t=e.mapPos(n,-1,we.TrackAfter);return t??void 0}}),Zo=new class extends _t{};Zo.startSide=1;Zo.endSide=-1;const ru=Ce.define({create(){return $.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Jt)&&(n=n.update({add:[Zo.range(t.value,t.value+1)]}));return n}});function Yy(){return[Qy,ru]}const dr="()[]{}<>«»»«[]{}";function ou(n){for(let e=0;e<dr.length;e+=2)if(dr.charCodeAt(e)==n)return dr.charAt(e+1);return uo(n<128?n:n+1)}function lu(n,e){return n.languageDataAt("closeBrackets",e)[0]||ln}const Xy=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Qy=D.inputHandler.of((n,e,t,i)=>{if((Xy?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&ht(_e(i,0))==1||e!=s.from||t!=s.to)return!1;let r=tb(n.state,i);return r?(n.dispatch(r),!0):!1}),Zy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=lu(n,n.selection.main.head).brackets||ln.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=ib(n.doc,o.head);for(let a of i)if(a==l&&Ns(n.doc,o.head)==ou(_e(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:v.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},eb=[{key:"Backspace",run:Zy}];function tb(n,e){let t=lu(n,n.selection.main.head),i=t.brackets||ln.brackets;for(let s of i){let r=ou(_e(s,0));if(e==s)return r==s?rb(n,s,i.indexOf(s+s+s)>-1,t):nb(n,s,r,t.before||ln.before);if(e==r&&au(n,n.selection.main.from))return sb(n,s,r)}return null}function au(n,e){let t=!1;return n.field(ru).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Ns(n,e){let t=n.sliceString(e,e+2);return t.slice(0,ht(_e(t,0)))}function ib(n,e){let t=n.sliceString(e-2,e);return ht(_e(t,0))==t.length?t:t.slice(1)}function nb(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Jt.of(o.to+e.length),range:v.range(o.anchor+e.length,o.head+e.length)};let l=Ns(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Jt.of(o.head+e.length),range:v.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function sb(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&Ns(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:v.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function rb(n,e,t,i){let s=i.stringPrefixes||ln.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Jt.of(l.to+e.length),range:v.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Ns(n.doc,a),c;if(h==e){if(qa(n,a))return{changes:{insert:e+e,from:a},effects:Jt.of(a+e.length),range:v.cursor(a+e.length)};if(au(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:v.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=$a(n,a-2*e.length,s))>-1&&qa(n,c))return{changes:{insert:e+e+e+e,from:a},effects:Jt.of(a+e.length),range:v.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=oe.Word&&$a(n,a,s)>-1&&!ob(n,a,e,s))return{changes:{insert:e+e,from:a},effects:Jt.of(a+e.length),range:v.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function qa(n,e){let t=Se(n).resolveInner(e+1);return t.parent&&t.from==e}function ob(n,e,t,i){let s=Se(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=s.to==e&&s.parent;if(!h)break;s=h}return!1}function $a(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=oe.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=oe.Word)return r}return-1}function lb(n={}){return[Vy,Pe,pe.of(n),By,ab,nu]}const hu=[{key:"Ctrl-Space",run:ur},{mac:"Alt-`",run:ur},{mac:"Alt-i",run:ur},{key:"Escape",run:_y},{key:"ArrowDown",run:zn(!0)},{key:"ArrowUp",run:zn(!1)},{key:"PageDown",run:zn(!0,"page")},{key:"PageUp",run:zn(!1,"page")},{key:"Enter",run:Ly}],ab=Wt.highest(dn.computeN([pe],n=>n.facet(pe).defaultKeymap?[hu]:[]));class Ka{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Kt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(an).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Ze,l=[],a=0,h=i.doc.iter(),c=0,f=i.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!l.length)break;let m,g;if(l.length)m=a,g=l.reduce((w,E)=>Math.min(w,E.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;g=p.to,l.push(p),d++}for(;d<r.length;){let w=r[d];if(w.from==m&&(w.to>w.from||w.to==m))l.push(w),d++,g=Math.min(w.to,g);else{g=Math.min(w.from,g);break}}g=Math.min(g,f);let x=!1;if(l.some(w=>w.from==m&&(w.to==g||g==f))&&(x=m==g,!x&&g-m<10)){let w=m-(c+h.value.length);w>0&&(h.next(w),c=m);for(let E=m;;){if(E>=g){x=!0;break}if(!h.lineBreak&&c+h.value.length>E)break;E=c+h.value.length,c+=h.value.length,h.next()}}let A=wb(l);if(x)o.add(m,m,N.widget({widget:new xb(A),diagnostics:l.slice()}));else{let w=l.reduce((E,S)=>S.markClass?E+" "+S.markClass:E,"");o.add(m,g,N.mark({class:"cm-lintRange cm-lintRange-"+A+w,diagnostics:l.slice(),inclusiveEnd:l.some(E=>E.to>g)}))}if(a=g,a==f)break;for(let w=0;w<l.length;w++)l[w].to<=a&&l.splice(w--,1)}let u=o.finish();return new Kt(u,t,Vt(u))}}function Vt(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new Ka(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Ka(i.from,r,i.diagnostic)}}),i}function hb(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(an).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(cu))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function cb(n,e){return n.field(He,!1)?e:e.concat(F.appendConfig.of(kb))}const cu=F.define(),el=F.define(),fu=F.define(),He=Ce.define({create(){return new Kt(N.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Vt(t,n.selected.diagnostic,r)||Vt(t,null,r)}!t.size&&s&&e.state.facet(an).autoPanel&&(s=null),n=new Kt(t,s,i)}for(let t of e.effects)if(t.is(cu)){let i=e.state.facet(an).autoPanel?t.value.length?hn.open:null:n.panel;n=Kt.init(t.value,i,e.state)}else t.is(el)?n=new Kt(n.diagnostics,t.value?hn.open:null,n.selected):t.is(fu)&&(n=new Kt(n.diagnostics,n.panel,t.value));return n},provide:n=>[Qi.from(n,e=>e.panel),D.decorations.from(n,e=>e.diagnostics)]}),fb=N.mark({class:"cm-lintRange cm-lintRange-active"});function ub(n,e,t){let{diagnostics:i}=n.state.field(He),s,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{if(e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0)))return s=c.diagnostics,r=a,o=h,!1});let l=n.state.facet(an).tooltipFilter;return s&&l&&(s=l(s,n.state)),s?{pos:r,end:o,above:!0,create(){return{dom:db(n,s)}}}:null}function db(n,e){return Q("ul",{class:"cm-tooltip-lint"},e.map(t=>du(n,t,!1)))}const pb=n=>{let e=n.state.field(He,!1);(!e||!e.panel)&&n.dispatch({effects:cb(n.state,[el.of(!0)])});let t=Os(n,hn.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Ua=n=>{let e=n.state.field(He,!1);return!e||!e.panel?!1:(n.dispatch({effects:el.of(!1)}),!0)},mb=n=>{let e=n.state.field(He,!1);if(!e)return!1;let t=n.state.selection.main,i=Vt(e.diagnostics,null,t.to+1);return!i&&(i=Vt(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),qm(n,i.from,1,{tooltip:pu,until:s=>s.docChanged||s.newSelection.main.head<i.from||s.newSelection.main.head>i.to}),!0)},gb=[{key:"Mod-Shift-m",run:pb,preventDefault:!0},{key:"F8",run:mb}],an=P.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...xt(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Ga,tooltipFilter:Ga,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,s,r)=>e(i,s,r)||t(i,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function Ga(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function uu(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function du(n,e,t){var i;let s=t?uu(e.actions):[];return Q("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Q("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Vt(n.state.field(He).diagnostics,e);p&&r.apply(n,p.from,p.to)},{name:h}=r,c=s[o]?h.indexOf(s[o]):-1,f=c<0?h:[h.slice(0,c),Q("u",h.slice(c,c+1)),h.slice(c+1)],u=r.markClass?" "+r.markClass:"";return Q("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&Q("div",{class:"cm-diagnosticSource"},e.source))}class xb extends tt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Q("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Ja{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=du(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class hn{constructor(e){this.view=e,this.items=[];let t=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)Ua(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=uu(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Vt(this.view.state.field(He).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()}},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=Q("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=Q("div",{class:"cm-panel-lint"},this.list,Q("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Ua(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(He).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(He),i=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new Ja(this.view,c),this.items.splice(i,0,u),s=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),s=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new Ja(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/h:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(He),i=Vt(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:fu.of(i)})}static open(e){return new hn(e)}}function yb(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function qn(n){return yb(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const bb=D.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:qn("#f11")},".cm-lintRange-warning":{backgroundImage:qn("orange")},".cm-lintRange-info":{backgroundImage:qn("#999")},".cm-lintRange-hint":{backgroundImage:qn("#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}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function vb(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function wb(n){let e="hint",t=1;for(let i of n){let s=vb(i.severity);s>t&&(t=s,e=i.severity)}return e}const pu=zm(ub,{hideOn:hb}),kb=[He,D.decorations.compute([He],n=>{let{selected:e,panel:t}=n.field(He);return!e||!t||e.from==e.to?N.none:N.set([fb.range(e.from,e.to)])}),pu,bb];var Ya=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(eb)),e.defaultKeymap!==!1&&(i=i.concat(Bx)),e.searchKeymap!==!1&&(i=i.concat(hy)),e.historyKeymap!==!1&&(i=i.concat(z0)),e.foldKeymap!==!1&&(i=i.concat(Zg)),e.completionKeymap!==!1&&(i=i.concat(hu)),e.lintKeymap!==!1&&(i=i.concat(gb));var s=[];return e.lineNumbers!==!1&&s.push(sg()),e.highlightActiveLineGutter!==!1&&s.push(lg()),e.highlightSpecialChars!==!1&&s.push(ym()),e.history!==!1&&s.push(R0()),e.foldGutter!==!1&&s.push(n0()),e.drawSelection!==!1&&s.push(om()),e.dropCursor!==!1&&s.push(um()),e.allowMultipleSelections!==!1&&s.push(K.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(zg()),e.syntaxHighlighting!==!1&&s.push(nf(l0,{fallback:!0})),e.bracketMatching!==!1&&s.push(p0()),e.closeBrackets!==!1&&s.push(Yy()),e.autocompletion!==!1&&s.push(lb()),e.rectangularSelection!==!1&&s.push(_m()),t!==!1&&s.push(Im()),e.highlightActiveLine!==!1&&s.push(Cm()),e.highlightSelectionMatches!==!1&&s.push(jx()),e.tabSize&&typeof e.tabSize=="number"&&s.push(pn.of(" ".repeat(e.tabSize))),s.concat([dn.of(i.flat())]).filter(Boolean)};const Sb="#e5c07b",Xa="#e06c75",Cb="#56b6c2",Ab="#ffffff",Zn="#abb2bf",fo="#7d8799",Mb="#61afef",Tb="#98c379",Qa="#d19a66",Eb="#c678dd",Db="#21252b",Za="#2c313a",eh="#282c34",pr="#353a42",Ob="#3E4451",th="#528bff",Lb=D.theme({"&":{color:Zn,backgroundColor:eh},".cm-content":{caretColor:th},".cm-cursor, .cm-dropCursor":{borderLeftColor:th},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Ob},".cm-panels":{backgroundColor:Db,color:Zn},".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:eh,color:fo,border:"none"},".cm-activeLineGutter":{backgroundColor:Za},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:pr},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:pr,borderBottomColor:pr},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Za,color:Zn}}},{dark:!0}),_b=gn.define([{tag:k.keyword,color:Eb},{tag:[k.name,k.deleted,k.character,k.propertyName,k.macroName],color:Xa},{tag:[k.function(k.variableName),k.labelName],color:Mb},{tag:[k.color,k.constant(k.name),k.standard(k.name)],color:Qa},{tag:[k.definition(k.name),k.separator],color:Zn},{tag:[k.typeName,k.className,k.number,k.changed,k.annotation,k.modifier,k.self,k.namespace],color:Sb},{tag:[k.operator,k.operatorKeyword,k.url,k.escape,k.regexp,k.link,k.special(k.string)],color:Cb},{tag:[k.meta,k.comment],color:fo},{tag:k.strong,fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.link,color:fo,textDecoration:"underline"},{tag:k.heading,fontWeight:"bold",color:Xa},{tag:[k.atom,k.bool,k.special(k.variableName)],color:Qa},{tag:[k.processingInstruction,k.string,k.inserted],color:Tb},{tag:k.invalid,color:Ab}]),mu=[Lb,nf(_b)];var Pb=D.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Rb=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:i=!0,readOnly:s=!1,theme:r="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(t&&a.unshift(dn.of([Nx])),l&&(typeof l=="boolean"?a.unshift(Ya()):a.unshift(Ya(l))),o&&a.unshift(Em(o)),r){case"light":a.push(Pb);break;case"dark":a.push(mu);break;case"none":break;default:a.push(r);break}return i===!1&&a.push(D.editable.of(!1)),s&&a.push(K.readOnly.of(!0)),[...a]},Ib=n=>({line:n.state.doc.lineAt(n.state.selection.main.from),lineCount:n.state.doc.lines,lineBreak:n.state.lineBreak,length:n.state.doc.length,readOnly:n.state.readOnly,tabSize:n.state.tabSize,selection:n.state.selection,selectionAsSingle:n.state.selection.asSingle().main,ranges:n.state.selection.ranges,selectionCode:n.state.sliceDoc(n.state.selection.main.from,n.state.selection.main.to),selections:n.state.selection.ranges.map(e=>n.state.sliceDoc(e.from,e.to)),selectedText:n.state.selection.ranges.some(e=>!e.empty)}),ih=gt.define(),Bb=[];function Nb(n){var{value:e,selection:t,onChange:i,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=Bb,autoFocus:a,theme:h="light",height:c=null,minHeight:f=null,maxHeight:u=null,width:d=null,minWidth:p=null,maxWidth:m=null,placeholder:g="",editable:x=!0,readOnly:A=!1,indentWithTab:w=!0,basicSetup:E=!0,root:S,initialState:M}=n,[T,V]=Y.useState(),[B,H]=Y.useState(),[W,I]=Y.useState(),z=D.theme({"&":{height:c,minHeight:f,maxHeight:u,width:d,minWidth:p,maxWidth:m},"& .cm-scroller":{height:"100% !important"}}),j=D.updateListener.of(X=>{if(X.docChanged&&typeof i=="function"&&!X.transactions.some(xe=>xe.annotation(ih))){var de=X.state.doc,se=de.toString();i(se,X)}s&&s(Ib(X))}),J=Rb({theme:h,editable:x,readOnly:A,placeholder:g,indentWithTab:w,basicSetup:E}),ne=[j,z,...J];return o&&typeof o=="function"&&ne.push(D.updateListener.of(o)),ne=ne.concat(l),Y.useEffect(()=>{if(T&&!W){var X={doc:e,selection:t,extensions:ne},de=M?K.fromJSON(M.json,X,M.fields):K.create(X);if(I(de),!B){var se=new D({state:de,parent:T,root:S});H(se),r&&r(se,de)}}return()=>{B&&(I(void 0),H(void 0))}},[T,W]),Y.useEffect(()=>V(n.container),[n.container]),Y.useEffect(()=>()=>{B&&(B.destroy(),H(void 0))},[B]),Y.useEffect(()=>{a&&B&&B.focus()},[a,B]),Y.useEffect(()=>{B&&B.dispatch({effects:F.reconfigure.of(ne)})},[h,l,c,f,u,d,p,m,g,x,A,w,E,i,o]),Y.useEffect(()=>{if(e!==void 0){var X=B?B.state.doc.toString():"";B&&e!==X&&B.dispatch({changes:{from:0,to:X.length,insert:e||""},annotations:[ih.of(!0)]})}},[e,B]),{state:W,setState:I,view:B,setView:H,container:T,setContainer:V}}var Vb=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],gu=Y.forwardRef((n,e)=>{var{className:t,value:i="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,autoFocus:c,theme:f="light",height:u,minHeight:d,maxHeight:p,width:m,minWidth:g,maxWidth:x,basicSetup:A,placeholder:w,indentWithTab:E,editable:S,readOnly:M,root:T,initialState:V}=n,B=Uu(n,Vb),H=Y.useRef(null),{state:W,view:I,container:z}=Nb({container:H.current,root:T,value:i,autoFocus:c,theme:f,height:u,minHeight:d,maxHeight:p,width:m,minWidth:g,maxWidth:x,basicSetup:A,placeholder:w,indentWithTab:E,editable:S,readOnly:M,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,extensions:r,initialState:V});if(Y.useImperativeHandle(e,()=>({editor:H.current,state:W,view:I}),[H,z,W,I]),typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var j=typeof f=="string"?"cm-theme-"+f:"cm-theme";return _.jsx("div",mr({ref:H,className:""+j+(t?" "+t:"")},B))});gu.displayName="CodeMirror";function C(n){return new Rg(Bo.define(n))}function At(n){return b(()=>import("./index-eIlS8nUF.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.sql({dialect:e[n]}))}const Wb=[y.of({name:"C",extensions:["c","h","ino"],load(){return b(()=>import("./index-DDrV_F4m.js"),__vite__mapDeps([4,1,2,3])).then(n=>n.cpp())}}),y.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return b(()=>import("./index-DDrV_F4m.js"),__vite__mapDeps([4,1,2,3])).then(n=>n.cpp())}}),y.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return At("Cassandra")}}),y.of({name:"CSS",extensions:["css"],load(){return b(()=>import("./index-DxsK976j.js"),__vite__mapDeps([5,1,2,3])).then(n=>n.css())}}),y.of({name:"Go",extensions:["go"],load(){return b(()=>import("./index-2r9n9DTs.js"),__vite__mapDeps([6,1,2,3])).then(n=>n.go())}}),y.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return b(()=>import("./index-DRtWlWMo.js"),__vite__mapDeps([7,1,5,2,3,8])).then(n=>n.html())}}),y.of({name:"Java",extensions:["java"],load(){return b(()=>import("./index-o9r5KATO.js"),__vite__mapDeps([9,1,2,3])).then(n=>n.java())}}),y.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return b(()=>import("./index-SjGg9_vE.js"),__vite__mapDeps([8,1,2,3])).then(n=>n.javascript())}}),y.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return b(()=>import("./index-BOSsA0NJ.js"),__vite__mapDeps([10,1,2,3])).then(n=>n.json())}}),y.of({name:"JSX",extensions:["jsx"],load(){return b(()=>import("./index-SjGg9_vE.js"),__vite__mapDeps([8,1,2,3])).then(n=>n.javascript({jsx:!0}))}}),y.of({name:"LESS",extensions:["less"],load(){return b(()=>import("./index-DBSUkj1m.js"),__vite__mapDeps([11,5,1,2,3])).then(n=>n.less())}}),y.of({name:"Liquid",extensions:["liquid"],load(){return b(()=>import("./index-6LcRt5Lv.js"),__vite__mapDeps([12,7,1,5,2,3,8])).then(n=>n.liquid())}}),y.of({name:"MariaDB SQL",load(){return At("MariaSQL")}}),y.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return b(()=>import("./index-CS1X9Gl5.js"),__vite__mapDeps([13,7,1,5,2,3,8])).then(n=>n.markdown())}}),y.of({name:"MS SQL",load(){return At("MSSQL")}}),y.of({name:"MySQL",load(){return At("MySQL")}}),y.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return b(()=>import("./index-Cv-pFH6x.js"),__vite__mapDeps([14,1,7,5,2,3,8])).then(n=>n.php())}}),y.of({name:"PLSQL",extensions:["pls"],load(){return At("PLSQL")}}),y.of({name:"PostgreSQL",load(){return At("PostgreSQL")}}),y.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return b(()=>import("./index-DkYraAal.js"),__vite__mapDeps([15,1,2,3])).then(n=>n.python())}}),y.of({name:"Rust",extensions:["rs"],load(){return b(()=>import("./index-BqYXODG4.js"),__vite__mapDeps([16,1,2,3])).then(n=>n.rust())}}),y.of({name:"Sass",extensions:["sass"],load(){return b(()=>import("./index-DUIbUB4M.js"),__vite__mapDeps([17,1,5,2,3])).then(n=>n.sass({indented:!0}))}}),y.of({name:"SCSS",extensions:["scss"],load(){return b(()=>import("./index-DUIbUB4M.js"),__vite__mapDeps([17,1,5,2,3])).then(n=>n.sass())}}),y.of({name:"SQL",extensions:["sql"],load(){return At("StandardSQL")}}),y.of({name:"SQLite",load(){return At("SQLite")}}),y.of({name:"TSX",extensions:["tsx"],load(){return b(()=>import("./index-SjGg9_vE.js"),__vite__mapDeps([8,1,2,3])).then(n=>n.javascript({jsx:!0,typescript:!0}))}}),y.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return b(()=>import("./index-SjGg9_vE.js"),__vite__mapDeps([8,1,2,3])).then(n=>n.javascript({typescript:!0}))}}),y.of({name:"WebAssembly",extensions:["wat","wast"],load(){return b(()=>import("./index-D45gW5O5.js"),__vite__mapDeps([18,1,2,3])).then(n=>n.wast())}}),y.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return b(()=>import("./index-Dls_C4WS.js"),__vite__mapDeps([19,1,2,3])).then(n=>n.xml())}}),y.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return b(()=>import("./index-B3eGs35g.js"),__vite__mapDeps([20,1,2,3])).then(n=>n.yaml())}}),y.of({name:"APL",extensions:["dyalog","apl"],load(){return b(()=>import("./apl-B4CMkyY2.js"),[]).then(n=>C(n.apl))}}),y.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return b(()=>import("./asciiarmor-Df11BRmG.js"),[]).then(n=>C(n.asciiArmor))}}),y.of({name:"ASN.1",extensions:["asn","asn1"],load(){return b(()=>import("./asn1-EdZsLKOL.js"),[]).then(n=>C(n.asn1({})))}}),y.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return b(()=>import("./asterisk-B-8jnY81.js"),[]).then(n=>C(n.asterisk))}}),y.of({name:"Brainfuck",extensions:["b","bf"],load(){return b(()=>import("./brainfuck-C4LP7Hcl.js"),[]).then(n=>C(n.brainfuck))}}),y.of({name:"Cobol",extensions:["cob","cpy"],load(){return b(()=>import("./cobol-CWcv1MsR.js"),[]).then(n=>C(n.cobol))}}),y.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.csharp))}}),y.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return b(()=>import("./clojure-BMjYHr_A.js"),[]).then(n=>C(n.clojure))}}),y.of({name:"ClojureScript",extensions:["cljs"],load(){return b(()=>import("./clojure-BMjYHr_A.js"),[]).then(n=>C(n.clojure))}}),y.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return b(()=>import("./css-BnMrqG3P.js"),[]).then(n=>C(n.gss))}}),y.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return b(()=>import("./cmake-BQqOBYOt.js"),[]).then(n=>C(n.cmake))}}),y.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return b(()=>import("./coffeescript-S37ZYGWr.js"),[]).then(n=>C(n.coffeeScript))}}),y.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return b(()=>import("./commonlisp-DBKNyK5s.js"),[]).then(n=>C(n.commonLisp))}}),y.of({name:"Cypher",extensions:["cyp","cypher"],load(){return b(()=>import("./cypher-C_CwsFkJ.js"),[]).then(n=>C(n.cypher))}}),y.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return b(()=>import("./python-BuPzkPfP.js"),[]).then(n=>C(n.cython))}}),y.of({name:"Crystal",extensions:["cr"],load(){return b(()=>import("./crystal-SjHAIU92.js"),[]).then(n=>C(n.crystal))}}),y.of({name:"D",extensions:["d"],load(){return b(()=>import("./d-pRatUO7H.js"),[]).then(n=>C(n.d))}}),y.of({name:"Dart",extensions:["dart"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.dart))}}),y.of({name:"diff",extensions:["diff","patch"],load(){return b(()=>import("./diff-DbItnlRl.js"),[]).then(n=>C(n.diff))}}),y.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return b(()=>import("./dockerfile-BKs6k2Af.js"),__vite__mapDeps([21,22])).then(n=>C(n.dockerFile))}}),y.of({name:"DTD",extensions:["dtd"],load(){return b(()=>import("./dtd-DF_7sFjM.js"),[]).then(n=>C(n.dtd))}}),y.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return b(()=>import("./dylan-DwRh75JA.js"),[]).then(n=>C(n.dylan))}}),y.of({name:"EBNF",load(){return b(()=>import("./ebnf-CDyGwa7X.js"),[]).then(n=>C(n.ebnf))}}),y.of({name:"ECL",extensions:["ecl"],load(){return b(()=>import("./ecl-Cabwm37j.js"),[]).then(n=>C(n.ecl))}}),y.of({name:"edn",extensions:["edn"],load(){return b(()=>import("./clojure-BMjYHr_A.js"),[]).then(n=>C(n.clojure))}}),y.of({name:"Eiffel",extensions:["e"],load(){return b(()=>import("./eiffel-CnydiIhH.js"),[]).then(n=>C(n.eiffel))}}),y.of({name:"Elm",extensions:["elm"],load(){return b(()=>import("./elm-vLlmbW-K.js"),[]).then(n=>C(n.elm))}}),y.of({name:"Erlang",extensions:["erl"],load(){return b(()=>import("./erlang-BNw1qcRV.js"),[]).then(n=>C(n.erlang))}}),y.of({name:"Esper",load(){return b(()=>import("./sql-D0XecflT.js"),[]).then(n=>C(n.esper))}}),y.of({name:"Factor",extensions:["factor"],load(){return b(()=>import("./factor-kuTfRLto.js"),__vite__mapDeps([23,22])).then(n=>C(n.factor))}}),y.of({name:"FCL",load(){return b(()=>import("./fcl-Kvtd6kyn.js"),[]).then(n=>C(n.fcl))}}),y.of({name:"Forth",extensions:["forth","fth","4th"],load(){return b(()=>import("./forth-Ffai-XNe.js"),[]).then(n=>C(n.forth))}}),y.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return b(()=>import("./fortran-DYz_wnZ1.js"),[]).then(n=>C(n.fortran))}}),y.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return b(()=>import("./mllike-CXdrOF99.js"),[]).then(n=>C(n.fSharp))}}),y.of({name:"Gas",extensions:["s"],load(){return b(()=>import("./gas-Bneqetm1.js"),[]).then(n=>C(n.gas))}}),y.of({name:"Gherkin",extensions:["feature"],load(){return b(()=>import("./gherkin-heZmZLOM.js"),[]).then(n=>C(n.gherkin))}}),y.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return b(()=>import("./groovy-D9Dt4D0W.js"),[]).then(n=>C(n.groovy))}}),y.of({name:"Haskell",extensions:["hs"],load(){return b(()=>import("./haskell-BWDZoCOh.js"),[]).then(n=>C(n.haskell))}}),y.of({name:"Haxe",extensions:["hx"],load(){return b(()=>import("./haxe-H-WmDvRZ.js"),[]).then(n=>C(n.haxe))}}),y.of({name:"HXML",extensions:["hxml"],load(){return b(()=>import("./haxe-H-WmDvRZ.js"),[]).then(n=>C(n.hxml))}}),y.of({name:"HTTP",load(){return b(()=>import("./http-DBlCnlav.js"),[]).then(n=>C(n.http))}}),y.of({name:"IDL",extensions:["pro"],load(){return b(()=>import("./idl-BEugSyMb.js"),[]).then(n=>C(n.idl))}}),y.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return b(()=>import("./javascript-qCveANmP.js"),[]).then(n=>C(n.jsonld))}}),y.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return b(()=>import("./jinja2-C4DGRd-O.js"),[]).then(n=>C(n.jinja2))}}),y.of({name:"Julia",extensions:["jl"],load(){return b(()=>import("./julia-DuME0IfC.js"),[]).then(n=>C(n.julia))}}),y.of({name:"Kotlin",extensions:["kt","kts"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.kotlin))}}),y.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return b(()=>import("./livescript-BwQOo05w.js"),[]).then(n=>C(n.liveScript))}}),y.of({name:"Lua",extensions:["lua"],load(){return b(()=>import("./lua-VAEuO923.js"),[]).then(n=>C(n.lua))}}),y.of({name:"mIRC",extensions:["mrc"],load(){return b(()=>import("./mirc-CjQqDB4T.js"),[]).then(n=>C(n.mirc))}}),y.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return b(()=>import("./mathematica-DTrFuWx2.js"),[]).then(n=>C(n.mathematica))}}),y.of({name:"Modelica",extensions:["mo"],load(){return b(()=>import("./modelica-Dc1JOy9r.js"),[]).then(n=>C(n.modelica))}}),y.of({name:"MUMPS",extensions:["mps"],load(){return b(()=>import("./mumps-BT43cFF4.js"),[]).then(n=>C(n.mumps))}}),y.of({name:"Mbox",extensions:["mbox"],load(){return b(()=>import("./mbox-CNhZ1qSd.js"),[]).then(n=>C(n.mbox))}}),y.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return b(()=>import("./nginx-DdIZxoE0.js"),[]).then(n=>C(n.nginx))}}),y.of({name:"NSIS",extensions:["nsh","nsi"],load(){return b(()=>import("./nsis-LY0VT_u5.js"),__vite__mapDeps([24,22])).then(n=>C(n.nsis))}}),y.of({name:"NTriples",extensions:["nt","nq"],load(){return b(()=>import("./ntriples-BfvgReVJ.js"),[]).then(n=>C(n.ntriples))}}),y.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.objectiveC))}}),y.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.objectiveCpp))}}),y.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return b(()=>import("./mllike-CXdrOF99.js"),[]).then(n=>C(n.oCaml))}}),y.of({name:"Octave",extensions:["m"],load(){return b(()=>import("./octave-Ck1zUtKM.js"),[]).then(n=>C(n.octave))}}),y.of({name:"Oz",extensions:["oz"],load(){return b(()=>import("./oz-BzwKVEFT.js"),[]).then(n=>C(n.oz))}}),y.of({name:"Pascal",extensions:["p","pas"],load(){return b(()=>import("./pascal--L3eBynH.js"),[]).then(n=>C(n.pascal))}}),y.of({name:"Perl",extensions:["pl","pm"],load(){return b(()=>import("./perl-CdXCOZ3F.js"),[]).then(n=>C(n.perl))}}),y.of({name:"Pig",extensions:["pig"],load(){return b(()=>import("./pig-CevX1Tat.js"),[]).then(n=>C(n.pig))}}),y.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return b(()=>import("./powershell-CFHJl5sT.js"),[]).then(n=>C(n.powerShell))}}),y.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return b(()=>import("./properties-C78fOPTZ.js"),[]).then(n=>C(n.properties))}}),y.of({name:"ProtoBuf",extensions:["proto"],load(){return b(()=>import("./protobuf-ChK-085T.js"),[]).then(n=>C(n.protobuf))}}),y.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return b(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([25,26])).then(n=>C(n.pug))}}),y.of({name:"Puppet",extensions:["pp"],load(){return b(()=>import("./puppet-DMA9R1ak.js"),[]).then(n=>C(n.puppet))}}),y.of({name:"Q",extensions:["q"],load(){return b(()=>import("./q-pXgVlZs6.js"),[]).then(n=>C(n.q))}}),y.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return b(()=>import("./r-DUYO_cvP.js"),[]).then(n=>C(n.r))}}),y.of({name:"RPM Changes",load(){return b(()=>import("./rpm-CTu-6PCP.js"),[]).then(n=>C(n.rpmChanges))}}),y.of({name:"RPM Spec",extensions:["spec"],load(){return b(()=>import("./rpm-CTu-6PCP.js"),[]).then(n=>C(n.rpmSpec))}}),y.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return b(()=>import("./ruby-BK5aLJev.js"),[]).then(n=>C(n.ruby))}}),y.of({name:"SAS",extensions:["sas"],load(){return b(()=>import("./sas-B4kiWyti.js"),[]).then(n=>C(n.sas))}}),y.of({name:"Scala",extensions:["scala"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.scala))}}),y.of({name:"Scheme",extensions:["scm","ss"],load(){return b(()=>import("./scheme-C41bIUwD.js"),[]).then(n=>C(n.scheme))}}),y.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return b(()=>import("./shell-CjFT_Tl9.js"),[]).then(n=>C(n.shell))}}),y.of({name:"Sieve",extensions:["siv","sieve"],load(){return b(()=>import("./sieve-C3Gn_uJK.js"),[]).then(n=>C(n.sieve))}}),y.of({name:"Smalltalk",extensions:["st"],load(){return b(()=>import("./smalltalk-CnHTOXQT.js"),[]).then(n=>C(n.smalltalk))}}),y.of({name:"Solr",load(){return b(()=>import("./solr-DehyRSwq.js"),[]).then(n=>C(n.solr))}}),y.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return b(()=>import("./mllike-CXdrOF99.js"),[]).then(n=>C(n.sml))}}),y.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return b(()=>import("./sparql-DkYu6x3z.js"),[]).then(n=>C(n.sparql))}}),y.of({name:"Spreadsheet",alias:["excel","formula"],load(){return b(()=>import("./spreadsheet-BCZA_wO0.js"),[]).then(n=>C(n.spreadsheet))}}),y.of({name:"Squirrel",extensions:["nut"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.squirrel))}}),y.of({name:"Stylus",extensions:["styl"],load(){return b(()=>import("./stylus-B533Al4x.js"),[]).then(n=>C(n.stylus))}}),y.of({name:"Swift",extensions:["swift"],load(){return b(()=>import("./swift-BzpIVaGY.js"),[]).then(n=>C(n.swift))}}),y.of({name:"sTeX",load(){return b(()=>import("./stex-C3f8Ysf7.js"),[]).then(n=>C(n.stex))}}),y.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return b(()=>import("./stex-C3f8Ysf7.js"),[]).then(n=>C(n.stex))}}),y.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return b(()=>import("./verilog-C6RDOZhf.js"),[]).then(n=>C(n.verilog))}}),y.of({name:"Tcl",extensions:["tcl"],load(){return b(()=>import("./tcl-DVfN8rqt.js"),[]).then(n=>C(n.tcl))}}),y.of({name:"Textile",extensions:["textile"],load(){return b(()=>import("./textile-CnDTJFAw.js"),[]).then(n=>C(n.textile))}}),y.of({name:"TiddlyWiki",load(){return b(()=>import("./tiddlywiki-DO-Gjzrf.js"),[]).then(n=>C(n.tiddlyWiki))}}),y.of({name:"Tiki wiki",load(){return b(()=>import("./tiki-DGYXhP31.js"),[]).then(n=>C(n.tiki))}}),y.of({name:"TOML",extensions:["toml"],load(){return b(()=>import("./toml-Bm5Em-hy.js"),[]).then(n=>C(n.toml))}}),y.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return b(()=>import("./troff-wAsdV37c.js"),[]).then(n=>C(n.troff))}}),y.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return b(()=>import("./ttcn-CfJYG6tj.js"),[]).then(n=>C(n.ttcn))}}),y.of({name:"TTCN_CFG",extensions:["cfg"],load(){return b(()=>import("./ttcn-cfg-B9xdYoR4.js"),[]).then(n=>C(n.ttcnCfg))}}),y.of({name:"Turtle",extensions:["ttl"],load(){return b(()=>import("./turtle-B1tBg_DP.js"),[]).then(n=>C(n.turtle))}}),y.of({name:"Web IDL",extensions:["webidl"],load(){return b(()=>import("./webidl-ZXfAyPTL.js"),[]).then(n=>C(n.webIDL))}}),y.of({name:"VB.NET",extensions:["vb"],load(){return b(()=>import("./vb-CmGdzxic.js"),[]).then(n=>C(n.vb))}}),y.of({name:"VBScript",extensions:["vbs"],load(){return b(()=>import("./vbscript-BuJXcnF6.js"),[]).then(n=>C(n.vbScript))}}),y.of({name:"Velocity",extensions:["vtl"],load(){return b(()=>import("./velocity-D8B20fx6.js"),[]).then(n=>C(n.velocity))}}),y.of({name:"Verilog",extensions:["v"],load(){return b(()=>import("./verilog-C6RDOZhf.js"),[]).then(n=>C(n.verilog))}}),y.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return b(()=>import("./vhdl-lSbBsy5d.js"),[]).then(n=>C(n.vhdl))}}),y.of({name:"XQuery",extensions:["xy","xquery"],load(){return b(()=>import("./xquery-CQfU5ijd.js"),[]).then(n=>C(n.xQuery))}}),y.of({name:"Yacas",extensions:["ys"],load(){return b(()=>import("./yacas-BJ4BC0dw.js"),[]).then(n=>C(n.yacas))}}),y.of({name:"Z80",extensions:["z80"],load(){return b(()=>import("./z80-Hz9HOZM7.js"),[]).then(n=>C(n.z80))}}),y.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return b(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(n=>C(n.mscgen))}}),y.of({name:"Xù",extensions:["xu"],load(){return b(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(n=>C(n.xu))}}),y.of({name:"MsGenny",extensions:["msgenny"],load(){return b(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(n=>C(n.msgenny))}}),y.of({name:"Vue",extensions:["vue"],load(){return b(()=>import("./index-CMZRuo_o.js"),__vite__mapDeps([27,7,1,5,2,3,8])).then(n=>n.vue())}}),y.of({name:"Angular Template",load(){return b(()=>import("./index-B_vWzZYC.js"),__vite__mapDeps([28,7,1,5,2,3,8])).then(n=>n.angular())}})];function Fb(n){const[e,t]=Y.useState([]);return Y.useEffect(()=>{if(t([]),!n)return;const i=y.matchFilename(Wb,n.split("/").pop()??"");if(!i)return;let s=!0;return i.load().then(r=>s&&t([r])),()=>{s=!1}},[n]),e}const Hb=/\bHOLE \d+\b/,jb=N.line({class:"cm-hole-line"}),zb=le.fromClass(class{constructor(n){nl(this,"decorations");this.decorations=nh(n)}update(n){(n.docChanged||n.viewportChanged)&&(this.decorations=nh(n.view))}},{decorations:n=>n.decorations});function nh(n){const e=new Ze;for(const{from:t,to:i}of n.visibleRanges)for(let s=t;s<=i;){const r=n.state.doc.lineAt(s);Hb.test(r.text)&&e.add(r.from,r.from,jb),s=r.to+1}return e.finish()}function sh(n,e){const t=n.state.doc,i=new RegExp(`\\bHOLE ${e.id}\\b`);let s=-1;for(let r=1;r<=t.lines;r++)if(i.test(t.line(r).text)){s=t.line(r).from;break}s<0&&(s=t.line(Math.min(Math.max(1,e.startLine),t.lines)).from),n.dispatch({selection:{anchor:s},effects:D.scrollIntoView(s,{y:"center"})}),n.focus()}function qb(n,e){const t={name:"",kids:new Map};for(const s of n){const r=e(s.path).split("/");let o=t;r.forEach((l,a)=>{o.kids.has(l)||o.kids.set(l,{name:l,kids:new Map}),o=o.kids.get(l),a===r.length-1&&(o.path=s.path)})}const i=s=>{for(const[r,o]of s.kids)s.kids.set(r,i(o));if(!s.path&&s.kids.size===1&&s.name){const r=[...s.kids.values()][0];if(!r.path)return{...r,name:`${s.name}/${r.name}`}}return s};return i(t)}function $b(){var tl;const{id:n=""}=vu(),{project:e,rel:t}=wu(),i=ku(),s=Su(),r=Cu(),o=Au(),l=Mu({queryKey:["practice",e.id,n],queryFn:()=>$u(`/projects/${e.id}/practice/${n}`)}),a=l.data,h=Y.useMemo(()=>(a==null?void 0:a.files)??(a?[{path:a.file,original:a.original,holed:a.holed,attempt:a.attempt}]:[]),[a]),c=Y.useMemo(()=>a?a.holes.map(R=>({...R,file:R.file??a.file})):[],[a]),[f,u]=Y.useState(null),[d,p]=Y.useState(null),[m,g]=Y.useState(!0),[x,A]=Y.useState({}),[w,E]=Y.useState(null),[S,M]=Y.useState(!1),T=Y.useRef(),V=Y.useRef(null),B=Y.useRef(null),H=Y.useRef(null),W=Fb(f??void 0);Y.useEffect(()=>{var R;!a||d||(p(Object.fromEntries(h.map(re=>[re.path,re.attempt]))),u(((R=h[0])==null?void 0:R.path)??null))},[a,h,d]);const I=async()=>{clearTimeout(T.current);const R=V.current;V.current=null,R&&(await rl(`/projects/${e.id}/practice/${n}/attempt`,R),g(!0))};Y.useEffect(()=>()=>clearTimeout(T.current),[]);const z=R=>c.filter(re=>re.file===R),j=!!f&&z(f).length>0,J=Y.useMemo(()=>[...W,zb,...j?[]:[K.readOnly.of(!0),D.editable.of(!1)]],[W,j]);if(l.isLoading)return _.jsx("div",{className:"p-8",children:_.jsx(sl,{})});if(!a)return _.jsx(Tu,{title:"Practice not found"});if(!d||!f)return _.jsx("div",{className:"p-8",children:_.jsx(sl,{})});const ne=R=>{var re;return(re=a.review)==null?void 0:re.holes.find(ce=>ce.id===R)},X=h.find(R=>R.path===f),de=R=>{p(re=>({...re,[f]:R})),g(!1),V.current={file:f,text:R},clearTimeout(T.current),T.current=setTimeout(I,800)},se=R=>{R!==f&&(I(),u(R))},xe=R=>{E(R.id),R.file&&R.file!==f?(H.current=R,se(R.file)):B.current&&sh(B.current,R)},Je=async()=>{await I(),o.run(`/projects/${e.id}/practice/${n}/review`,{},()=>i.invalidateQueries({queryKey:["practice",e.id,n]}))},ye=async()=>{window.confirm("Put every hole back? Your answers in all files are cleared.")&&(clearTimeout(T.current),V.current=null,p(Object.fromEntries(h.map(R=>[R.path,R.holed]))),await Promise.all(h.filter(R=>z(R.path).length).map(R=>rl(`/projects/${e.id}/practice/${n}/attempt`,{file:R.path,text:R.holed}))),g(!0))},Ne=qb(h,t),Ve=(R,re)=>{if(!R.path)return _.jsxs("div",{children:[_.jsxs("div",{className:"flex h-[22px] items-center gap-1 pr-2 text-[13px] text-muted",style:{paddingLeft:re*12+8},children:[_.jsx(zu,{className:"h-3.5 w-3.5 shrink-0"})," ",_.jsx("span",{className:"truncate",children:R.name})]}),[...R.kids.values()].map(jt=>Ve(jt,re+1))]},`d:${R.name}:${re}`);const ce=z(R.path),Ct=ce.filter(jt=>{var il;return((il=ne(jt.id))==null?void 0:il.verdict)==="right"}).length;return _.jsxs("button",{onClick:()=>se(R.path),title:t(R.path),className:Vs("flex h-[22px] w-full items-center gap-1 pr-2 text-left text-[13px]",R.path===f?"bg-sel text-ink dark:text-white":"hover:bg-raised",!ce.length&&"text-muted"),style:{paddingLeft:re*12+8},children:[_.jsx(qu,{className:"h-3.5 w-3.5 shrink-0 text-muted"}),_.jsx("span",{className:"min-w-0 flex-1 truncate",children:R.name}),ce.length?_.jsx("span",{className:Vs("rounded-sm px-1 text-[11px] font-semibold",a.review&&Ct===ce.length?"bg-good/15 text-good":"bg-warn/15 text-warn"),title:`${ce.length} hole${ce.length>1?"s":""}`,children:a.review?`${Ct}/${ce.length}`:ce.length}):_.jsx(Fs,{className:"h-3 w-3 shrink-0","aria-label":"read only"})]},R.path)},Ye=_.jsxs("div",{className:"flex h-full flex-col bg-side",children:[_.jsxs("div",{className:"px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted",children:["Files · ",h.length]}),_.jsx("div",{className:"min-h-0 flex-1 overflow-auto pb-3",children:[...Ne.kids.values()].map(R=>Ve(R,0))}),_.jsxs("p",{className:"border-t border-line px-3 py-2 text-[11px] text-muted",children:["Numbers are holes to fill. ",_.jsx(Fs,{className:"inline h-3 w-3"})," files are context, read only."]})]}),yt=_.jsxs("div",{className:"flex h-full flex-col",children:[_.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-panel px-3 py-1.5 text-xs text-muted",children:[_.jsx("span",{className:"truncate font-mono text-[12.5px] text-ink",title:t(f),children:t(f)}),j?_.jsx("span",{className:"flex shrink-0 items-center gap-1",children:m?_.jsxs(_.Fragment,{children:[_.jsx(Eu,{className:"h-3.5 w-3.5 text-good"})," saved"]}):"saving..."}):_.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[_.jsx(Fs,{className:"h-3 w-3"})," context, read only"]}),_.jsx("span",{className:"ml-auto hidden shrink-0 lg:inline",children:"A copy in cognitune; your folder is not touched"})]}),_.jsx("div",{className:"relative min-h-0 flex-1 bg-panel",children:_.jsx("div",{className:"absolute inset-0",children:_.jsx(gu,{value:d[f]??X.attempt,onChange:de,theme:r?mu:"light",extensions:J,height:"100%",onCreateEditor:R=>{B.current=R;const re=H.current;re&&re.file===f&&(H.current=null,setTimeout(()=>sh(R,re),0))}},f)})})]}),Ht=_.jsxs("div",{className:"flex h-full flex-col bg-panel",children:[_.jsx("div",{className:"border-b border-line px-3 py-1.5 text-xs font-medium",children:"Original (holes marked)"}),_.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:_.jsx(Du,{text:X.original,lang:Kb(f),marks:z(f).map(R=>({from:R.startLine,to:R.endLine,cls:"hole"}))})})]}),vn=_.jsxs("div",{className:"flex h-full flex-col bg-panel",children:[_.jsxs("div",{className:"border-b border-line p-4",children:[_.jsxs(Ou,{to:`/p/${e.id}/library`,className:"inline-flex items-center gap-1 text-xs text-muted hover:text-ink",children:[_.jsx(Lu,{className:"h-3.5 w-3.5"})," Library"]}),_.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[_.jsxs(_u,{tone:"accent",children:["practice · level ",a.level]}),_.jsxs("span",{className:"text-xs text-muted",children:[c.length," hole",c.length>1?"s":""," · ",Pu(a.createdAt)]})]}),a.concept&&_.jsx("div",{className:"read-sm mt-2 font-medium",children:a.concept}),_.jsx("p",{className:"mt-2 text-xs text-muted",children:"Click a hole to jump to it. Write the code it needs; pseudo-code is fine if the logic is right."})]}),_.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-auto p-3",children:[((tl=a.review)==null?void 0:tl.summary)&&_.jsx("div",{className:"rounded border border-accent/25 bg-accent/5 p-3 text-sm",children:a.review.summary}),c.map(R=>{const re=x[R.id]??0,ce=ne(R.id);return _.jsxs("div",{role:"button",tabIndex:0,onClick:()=>xe(R),onKeyDown:Ct=>Ct.key==="Enter"&&xe(R),className:Vs("card cursor-pointer p-3 transition hover:border-accent/50",w===R.id&&"border-accent ring-1 ring-accent/40",ce&&(ce.verdict==="right"?"border-good/40":ce.verdict==="partial"?"border-warn/40":"border-bad/40")),children:[_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsxs("span",{className:"rounded-sm bg-warn/15 px-1.5 py-0.5 font-mono text-[12px] font-semibold text-warn",children:["HOLE ",R.id]}),_.jsxs("span",{className:"min-w-0 truncate font-mono text-[11.5px] text-muted",title:t(R.file),children:[t(R.file).split("/").pop(),":",R.startLine]}),ce&&_.jsx("span",{className:"ml-auto",children:_.jsx(Ru,{v:ce.verdict})})]}),_.jsx("p",{className:"read-sm mt-2",children:R.intent}),R.hints.slice(0,re).map((Ct,jt)=>_.jsxs("div",{className:"mt-2 flex gap-2 rounded bg-raised px-2.5 py-1.5 text-[13px]",children:[_.jsx(Iu,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn"})," ",Ct]},jt)),re<R.hints.length&&_.jsxs("button",{className:"mt-2 text-xs font-medium text-accent hover:underline",onClick:Ct=>{Ct.stopPropagation(),A(jt=>({...jt,[R.id]:re+1}))},children:[re===0?"Show a hint":"Another hint"," (",re,"/",R.hints.length,")"]}),(ce==null?void 0:ce.feedback)&&_.jsx("p",{className:"mt-2 border-t border-line pt-2 text-[13px] text-muted",children:ce.feedback})]},R.id)})]}),_.jsxs("div",{className:"space-y-2 border-t border-line p-3",children:[o.busy&&o.job&&_.jsx(Bu,{kind:"review",elapsed:o.elapsed}),o.error&&_.jsx(Nu,{error:o.error,onClose:o.clearError}),_.jsx(wn,{variant:"primary",size:"lg",className:"w-full",icon:_.jsx(Vu,{className:"h-4 w-4"}),loading:o.busy,onClick:Je,children:"Check my work"}),_.jsxs("div",{className:"grid grid-cols-3 gap-2 [&>button]:whitespace-nowrap",children:[_.jsx(wn,{size:"sm",icon:S?_.jsx(Ku,{className:"h-3.5 w-3.5"}):_.jsx(Wu,{className:"h-3.5 w-3.5"}),onClick:()=>M(R=>!R),children:S?"Hide original":"Show original"}),_.jsx(wn,{size:"sm",icon:_.jsx(Fu,{className:"h-3.5 w-3.5"}),title:"Put every hole back",onClick:ye,children:"Start over"}),_.jsx(wn,{size:"sm",variant:"danger",icon:_.jsx(ju,{className:"h-3.5 w-3.5"}),title:"Move this practice to the archive",onClick:async()=>{await Hu(`/projects/${e.id}/practice/${a.id}`),s(`/p/${e.id}/library`)},children:"Archive"})]})]})]}),xu=S?_.jsx(Ws,{id:"practice-orig",side:"right",initial:520,min:300,max:1e3,left:yt,right:Ht}):yt;return _.jsx(Ws,{id:"practice-holes",side:"right",collapsible:!0,initial:380,min:300,max:560,className:"h-full",left:_.jsx(Ws,{id:"practice-files",collapsible:!0,initial:230,min:170,max:420,left:Ye,right:xu}),right:vn})}function Kb(n){var i;const e=((i=n.split(".").pop())==null?void 0:i.toLowerCase())??"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",go:"go",rs:"rust",java:"java",rb:"ruby",sh:"bash",sql:"sql",yml:"yaml",yaml:"yaml",json:"json",md:"markdown",cs:"csharp",kt:"kotlin"}[e]??"text"}const r1=Object.freeze(Object.defineProperty({__proto__:null,PracticePage:$b},Symbol.toStringTag,{value:"Module"}));export{K as A,Gt as B,eu as C,ag as D,D as E,y as F,Si as G,m0 as H,G as I,Lg as J,r1 as K,io as L,Oo as N,Vc as P,te as T,Rg as a,n1 as b,t1 as c,py as d,Se as e,$g as f,i1 as g,v as h,$c as i,Zb as j,Le as k,q as l,e1 as m,s1 as n,Yb as o,Xb as p,je as q,Mi as r,Mg as s,k as t,Wt as u,dn as v,$e as w,pn as x,qg as y,zc as z};
|
|
25
|
+
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new iy(this):new Zx(this)}getCursor(e,t=0,i){let s=e.doc?e:K.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?ri(this,s,t,i):si(this,s,t,i)}}class Jf{constructor(e){this.spec=e}}function Xx(n,e,t){return(i,s,r,o)=>{if(t&&!t(i,s,r,o))return!1;let l=i>=o&&s<=o+r.length?r.slice(i-o,s-o):e.doc.sliceString(i,s);return n(l,e,i,s)}}function si(n,e,t,i){let s;return n.wholeWord&&(s=Qx(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(s=Xx(n.test,e,s)),new Ai(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:r=>r.toLowerCase(),s)}function Qx(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(xs(s,t-r))!=oe.Word||e(ys(s,t-r))!=oe.Word)&&(e(ys(s,i-r))!=oe.Word||e(xs(s,i-r))!=oe.Word))}class Zx extends Jf{constructor(e){super(e)}nextMatch(e,t,i){let s=si(this.spec,e,i,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=si(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==i?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=si(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=i)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=si(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=si(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function ey(n,e,t){return(i,s,r)=>(!t||t(i,s,r))&&n(r[0],e,i,s)}function ri(n,e,t,i){let s;return n.wholeWord&&(s=ty(e.charCategorizer(e.selection.main.head))),n.test&&(s=ey(n.test,e,s)),new Kf(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:s},t,i)}function xs(n,e){return n.slice(me(n,e,!1),e)}function ys(n,e){return n.slice(e,me(n,e))}function ty(n){return(e,t,i)=>!i[0].length||(n(xs(i.input,i.index))!=oe.Word||n(ys(i.input,i.index))!=oe.Word)&&(n(ys(i.input,i.index+i[0].length))!=oe.Word||n(xs(i.input,i.index+i[0].length))!=oe.Word)}class iy extends Jf{nextMatch(e,t,i){let s=ri(this.spec,e,i,e.doc.length).next();return s.done&&(s=ri(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=ri(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let s=i.length;s>0;s--){let r=+i.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+i.slice(s)}return t})}matchAll(e,t){let i=ri(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ri(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const sn=F.define(),zo=F.define(),Lt=Ce.define({create(n){return new cr(co(n).create(),null)},update(n,e){for(let t of e.effects)t.is(sn)?n=new cr(t.value.create(),n.panel):t.is(zo)&&(n=new cr(n.query,t.value?qo:null));return n},provide:n=>Qi.from(n,e=>e.panel)});class cr{constructor(e,t){this.query=e,this.panel=t}}const ny=N.mark({class:"cm-searchMatch"}),sy=N.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ry=le.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Lt))}update(n){let e=n.state.field(Lt);(e!=n.startState.field(Lt)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return N.none;let{view:t}=this,i=new Ze;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?sy:ny)})}return i.finish()}},{decorations:n=>n.decorations});function yn(n){return e=>{let t=e.state.field(Lt,!1);return t&&t.query.spec.valid?n(e,t):Qf(e)}}const bs=yn((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=v.single(i.from,i.to),r=n.state.facet(Ei);return n.dispatch({selection:s,effects:[$o(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Xf(n),!0}),vs=yn((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=v.single(s.from,s.to),o=n.state.facet(Ei);return n.dispatch({selection:r,effects:[$o(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Xf(n),!0}),oy=yn((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:v.create(t.map(i=>v.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),ly=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new Ai(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(v.range(l.value.from,l.value.to))}return e(n.update({selection:v.create(r,o),userEvent:"select.search.matches"})),!0},Ba=yn((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,h,c=[];o.precise?o.from==i&&o.to==s&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(t,o.from,o.to),c.push(D.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let f=n.state.changes(l);return o&&(a=v.single(o.from,o.to).map(f),c.push($o(n,o)),c.push(t.facet(Ei).scrollToMatch(a.main,n))),n.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),ay=yn((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let s of e.matchAll(n.state,1e9)){let{from:r,to:o,precise:l}=s;l&&t.push({from:r,to:o,insert:e.getReplacement(s)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:D.announce.of(i),userEvent:"input.replace.all"}),!0});function qo(n){return n.state.facet(Ei).createPanel(n)}function co(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=n.facet(Ei);return new Gf({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:h.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function Yf(n){let e=Os(n,qo);return e&&e.dom.querySelector("[main-field]")}function Xf(n){let e=Yf(n);e&&e==n.root.activeElement&&e.select()}const Qf=n=>{let e=n.state.field(Lt,!1);if(e&&e.panel){let t=Yf(n);if(t&&t!=n.root.activeElement){let i=co(n.state,e.query.spec);i.valid&&n.dispatch({effects:sn.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[zo.of(!0),e?sn.of(co(n.state,e.query.spec)):F.appendConfig.of(uy)]});return!0},Zf=n=>{let e=n.state.field(Lt,!1);if(!e||!e.panel)return!1;let t=Os(n,qo);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:zo.of(!1)}),!0},hy=[{key:"Mod-f",run:Qf,scope:"editor search-panel"},{key:"F3",run:bs,shift:vs,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:bs,shift:vs,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Zf,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ly},{key:"Mod-Alt-g",run:Wx},{key:"Mod-d",run:Yx,preventDefault:!0}];class cy{constructor(e){this.view=e;let t=this.query=e.state.field(Lt).query.spec;this.commit=this.commit.bind(this),this.searchField=Q("input",{value:t.search,placeholder:We(e,"Find"),"aria-label":We(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Q("input",{value:t.replace,placeholder:We(e,"Replace"),"aria-label":We(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Q("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Q("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Q("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return Q("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=Q("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>bs(e),[We(e,"next")]),i("prev",()=>vs(e),[We(e,"previous")]),i("select",()=>oy(e),[We(e,"all")]),Q("label",null,[this.caseField,We(e,"match case")]),Q("label",null,[this.reField,We(e,"regexp")]),Q("label",null,[this.wordField,We(e,"by word")]),...e.state.readOnly?[]:[Q("br"),this.replaceField,i("replace",()=>Ba(e),[We(e,"replace")]),i("replaceAll",()=>ay(e),[We(e,"replace all")])],Q("button",{name:"close",onclick:()=>Zf(e),"aria-label":We(e,"close"),type:"button"},["×"])])}commit(){let e=new Gf({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:sn.of(e)}))}keydown(e){em(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?vs:bs)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Ba(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(sn)&&!i.value.eq(this.query)&&this.setQuery(i.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(Ei).top}}function We(n,e){return n.state.phrase(e)}const Hn=30,jn=/[\s\.,:;?!]/;function $o(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-Hn),o=Math.min(s,t+Hn),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<Hn;a++)if(!jn.test(l[a+1])&&jn.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-Hn;a--)if(!jn.test(l[a-1])&&jn.test(l[a])){l=l.slice(0,a);break}}return D.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const fy=D.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"}}),uy=[Lt,Wt.low(ry),fy];class eu{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Se(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(tu(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Na(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function dy(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=Na(e)+Na(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function py(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:dy(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function n1(n,e){return t=>{for(let i=Se(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class Va{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function Xt(n){return n.selection.main.from}function tu(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Ko=gt.define();function my(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return{...n.changeByRange(l=>{if(l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i))return{range:l};let a=n.toText(e);return{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:a},range:v.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Wa=new WeakMap;function gy(n){if(!Array.isArray(n))return n;let e=Wa.get(n);return e||Wa.set(n,e=py(n)),e}const ws=F.define(),rn=F.define();class xy{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=_e(e,t),s=ht(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(_e(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let A=_e(e,0),w=ht(A),E=w==e.length?0:-100;if(A!=t[0])if(A==i[0])E+=-200;else return null;return this.ret(E,[0,w])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let A=0,w=Math.min(e.length,200);A<w&&h<a;){let E=_e(e,A);(E==t[h]||E==i[h])&&(s[h++]=A),A+=ht(E)}if(h<a)return null}let c=0,f=0,u=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),x=!0;for(let A=0,w=Math.min(e.length,200),E=0;A<w&&f<a;){let S=_e(e,A);l<0&&(c<a&&S==t[c]&&(r[c++]=A),d<a&&(S==t[d]||S==i[d]?(d==0&&(p=A),m=A+1,d++):d=0));let M,T=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(M=uo(S))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!A||T==1&&g||E==0&&T!=0)&&(t[f]==S||i[f]==S&&(u=!0)?o[f++]=A:o.length&&(x=!1)),E=T,A+=ht(S)}return f==a&&o[0]==0&&x?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):f==a?this.result(-100+(u?-200:0)+-700+(x?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?ht(_e(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}}class yy{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 t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const pe=P.define({combine(n){return xt(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:by,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Fa(e(i),t(i)),optionClass:(e,t)=>i=>Fa(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Fa(n,e){return n?e?n+" "+e:n:e}function by(n,e,t,i,s,r){let o=n.textDirection==Z.RTL,l=o,a=!1,h="top",c,f,u=e.left-s.left,d=s.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))c=Math.max(s.top,Math.min(t.top,s.bottom-m))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:s.right-e.left)-30);let A=s.bottom-e.bottom;A>=m||A>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let g=(e.bottom-e.top)/r.offsetHeight,x=(e.right-e.left)/r.offsetWidth;return{style:`${h}: ${c/g}px; max-width: ${f/x}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const Uo=F.define();function vy(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<r.length;){let c=r[h++],f=r[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function fr(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class wy{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(pe);this.optionContent=vy(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=fr(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(e,h[+f[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:Uo.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(pe).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:rn.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=fr(r.length,o,e.state.facet(pe).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=fr(t.options.length,t.selected,this.view.state.facet(pe).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,s)}).catch(l=>Ie(this.view.state,l,"completion info")):(this.addInfoPane(o,s),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Sy(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(pe).positionInfo(this.view,t,s,i,r,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,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof h!="string"&&h.header)s.appendChild(h.header(h));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function ky(n,e){return t=>new wy(t,n,e)}function Sy(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/s:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function Ha(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function Cy(n,e){let t=[],i=null,s=null,r=c=>{t.push(c);let{section:f}=c.completion;if(f){i||(i=[]);let u=typeof f=="string"?f:f.name;i.some(d=>d.name==u)||i.push(typeof f=="string"?{name:u}:f)}},o=e.facet(pe);for(let c of n)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)r(new Va(u,c.source,f?f(u):[],1e9-t.length));else{let u=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new yy(u):new xy(u);for(let m of c.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,x=d.score+(m.boost||0);if(r(new Va(m,c.source,g,x)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:A}=m.section;s||(s=Object.create(null)),s[A]=Math.max(x,s[A]||-1e9)}}}}if(i){let c=Object.create(null),f=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?s[p.name]-s[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(u))f-=1e5,c[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let c of t.sort((f,u)=>u.score-f.score||h(f.completion,u.completion))){let f=c.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?l.push(c):Ha(c.completion)>Ha(a)&&(l[l.length-1]=c),a=c.completion}return l}class ai{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new ai(this.options,ja(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,o){if(s&&!o&&e.some(h=>h.isPending))return s.setDisabled();let l=Cy(e,t);if(!l.length)return s&&e.some(h=>h.isPending)?s.setDisabled():null;let a=t.facet(pe).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let h=s.options[s.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==h){a=c;break}}return new ai(l,ja(i,a),{pos:e.reduce((h,c)=>c.hasResult()?Math.min(h,c.from):h,1e8),create:Oy,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new ai(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new ai(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ks{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new ks(Ey,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(pe),r=(i.override||t.languageDataAt("autocomplete",Xt(t)).map(gy)).map(a=>(this.active.find(c=>c.source==a)||new Ue(a,this.active.some(c=>c.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Go));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Ay(r,this.active)||l?o=ai.build(r,t,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new Ue(a.source,0):a));for(let a of e.effects)a.is(Uo)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new ks(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?My:Ty}}function Ay(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const My={"aria-autocomplete":"list"},Ty={};function ja(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const Ey=[];function iu(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Ko);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class Ue{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=iu(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new Ue(s.source,0)),i&4&&s.state==0&&(s=new Ue(this.source,1)),s=s.updateFor(e,i);for(let r of e.effects)if(r.is(ws))s=new Ue(s.source,1,r.value);else if(r.is(rn))s=new Ue(s.source,0);else if(r.is(Go))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Xt(e.state))}}class mi extends Ue{constructor(e,t,i,s,r,o){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=Xt(e.state);if(l>o||!s||t&2&&(Xt(e.startState)==this.from||l<this.limit))return new Ue(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return Dy(s.validFor,e.state,r,o)?new mi(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new eu(e.state,l,!1)))?new mi(this.source,this.explicit,a,s,s.from,(i=s.to)!==null&&i!==void 0?i:Xt(e.state)):new Ue(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new mi(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new Ue(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Dy(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):tu(n,!0).test(s)}const Go=F.define({map(n,e){return n.map(t=>t.map(e))}}),Pe=Ce.define({create(){return ks.start()},update(n,e){return n.update(e)},provide:n=>[Do.from(n,e=>e.tooltip),D.contentAttributes.from(n,e=>e.attrs)]});function Jo(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(Pe).active.find(s=>s.source==e.source);return i instanceof mi?(typeof t=="string"?n.dispatch({...my(n.state,t,i.from,i.to),annotations:Ko.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const Oy=ky(Pe,Jo);function zn(n,e="option"){return t=>{let i=t.state.field(Pe,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(pe).interactionDelay)return!1;let s=1,r;e=="page"&&(r=Dc(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Uo.of(l)}),!0}}const Ly=n=>{let e=n.state.field(Pe,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(pe).interactionDelay?!1:Jo(n,e.open.options[e.open.selected])},ur=n=>n.state.field(Pe,!1)?(n.dispatch({effects:ws.of(!0)}),!0):!1,_y=n=>{let e=n.state.field(Pe,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:rn.of(null)}),!0)};class Py{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ry=50,Iy=1e3,By=le.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(Pe).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(Pe),t=n.state.facet(pe);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Pe)==e)return;let i=n.transactions.some(r=>{let o=iu(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>Ry&&Date.now()-o.time>Iy){for(let l of o.context.abortListeners)try{l()}catch(a){Ie(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(ws)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(Pe);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pe).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Xt(e),i=new eu(e,t,n.explicit,this.view),s=new Py(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:rn.of(null)}),Ie(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(pe).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(pe),i=this.view.state.field(Pe);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=Xt(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),h=new mi(r.active.source,r.active.explicit,a,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:l);for(let c of r.updates)h=h.update(c,t);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new Ue(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Go.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Pe,!1);if(e&&e.tooltip&&this.view.state.facet(pe).closeOnBlur){let t=e.open&&Dc(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:rn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ws.of(!1)}),20),this.composing=0}}}),Ny=typeof navigator=="object"&&/Win/.test(navigator.platform),Vy=Wt.highest(D.domEventHandlers({keydown(n,e){let t=e.state.field(Pe,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||!n.key||n.key.length>1||n.ctrlKey&&!(Ny&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&Jo(e,i),!1}})),nu=D.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",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Wy{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class Yo{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,we.TrackDel),i=e.mapPos(this.to,1,we.TrackDel);return t==null||i==null?null:new Yo(this.field,t,i)}}class Xo{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,c=/^\t*/.exec(a)[0].length;for(let f=0;f<c;f++)h+=e.facet(pn);s.push(t+h.length-c),a=h+a.slice(c)}i.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new Yo(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1;l===0&&(l=1e9);let c=a.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(l!=null?t[f].seq==l:c&&t[f].name==c)&&(h=f);if(h<0){let f=0;for(;f<t.length&&(l==null||t[f].seq!=null&&t[f].seq<l);)f++;t.splice(f,0,{seq:l,name:c}),h=f;for(let u of s)u.field>=h&&u.field++}for(let f of s)if(f.line==i.length&&f.from>r.index){let u=r[2]?3+(r[1]||"").length:2;f.from-=u,f.to-=u}s.push(new Wy(h,i.length,r.index,r.index+c.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let c of s)c.line==i.length&&c.from>h&&(c.from--,c.to--);return a}),i.push(o)}return new Xo(i,s)}}let Fy=N.widget({widget:new class extends tt{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Hy=N.mark({class:"cm-snippetField"});class Di{constructor(e,t){this.ranges=e,this.active=t,this.deco=N.set(e.map(i=>(i.from==i.to?Fy:Hy).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new Di(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const bn=F.define({map(n,e){return n&&n.map(e)}}),jy=F.define(),on=Ce.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(bn))return t.value;if(t.is(jy)&&n)return new Di(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>D.decorations.from(n,e=>e?e.deco:N.none)});function Qo(n,e){return v.create(n.filter(t=>t.field==e).map(t=>v.range(t.from,t.to)))}function zy(n){let e=Xo.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),{main:a}=t.state.selection,h={changes:{from:s,to:r==a.from?a.to:r,insert:U.of(o)},scrollIntoView:!0,annotations:i?[Ko.of(i),fe.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=Qo(l,0)),l.some(c=>c.field>0)){let c=new Di(l,0),f=h.effects=[bn.of(c)];t.state.field(on,!1)===void 0&&f.push(F.appendConfig.of([on,Gy,Jy,nu]))}t.dispatch(t.state.update(h))}}function su(n){return({state:e,dispatch:t})=>{let i=e.field(on,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:Qo(i.ranges,s),effects:bn.of(r?null:new Di(i.ranges,s)),scrollIntoView:!0})),!0}}const qy=({state:n,dispatch:e})=>n.field(on,!1)?(e(n.update({effects:bn.of(null)})),!0):!1,$y=su(1),Ky=su(-1),Uy=[{key:"Tab",run:$y,shift:Ky},{key:"Escape",run:qy}],za=P.define({combine(n){return n.length?n[0]:Uy}}),Gy=Wt.highest(dn.compute([za],n=>n.facet(za)));function s1(n,e){return{...e,apply:zy(n)}}const Jy=D.domEventHandlers({mousedown(n,e){let t=e.state.field(on,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:Qo(t.ranges,s.field),effects:bn.of(t.ranges.some(r=>r.field>s.field)?new Di(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),ln={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Jt=F.define({map(n,e){let t=e.mapPos(n,-1,we.TrackAfter);return t??void 0}}),Zo=new class extends _t{};Zo.startSide=1;Zo.endSide=-1;const ru=Ce.define({create(){return $.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Jt)&&(n=n.update({add:[Zo.range(t.value,t.value+1)]}));return n}});function Yy(){return[Qy,ru]}const dr="()[]{}<>«»»«[]{}";function ou(n){for(let e=0;e<dr.length;e+=2)if(dr.charCodeAt(e)==n)return dr.charAt(e+1);return uo(n<128?n:n+1)}function lu(n,e){return n.languageDataAt("closeBrackets",e)[0]||ln}const Xy=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Qy=D.inputHandler.of((n,e,t,i)=>{if((Xy?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&ht(_e(i,0))==1||e!=s.from||t!=s.to)return!1;let r=tb(n.state,i);return r?(n.dispatch(r),!0):!1}),Zy=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=lu(n,n.selection.main.head).brackets||ln.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=ib(n.doc,o.head);for(let a of i)if(a==l&&Ns(n.doc,o.head)==ou(_e(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:v.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},eb=[{key:"Backspace",run:Zy}];function tb(n,e){let t=lu(n,n.selection.main.head),i=t.brackets||ln.brackets;for(let s of i){let r=ou(_e(s,0));if(e==s)return r==s?rb(n,s,i.indexOf(s+s+s)>-1,t):nb(n,s,r,t.before||ln.before);if(e==r&&au(n,n.selection.main.from))return sb(n,s,r)}return null}function au(n,e){let t=!1;return n.field(ru).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Ns(n,e){let t=n.sliceString(e,e+2);return t.slice(0,ht(_e(t,0)))}function ib(n,e){let t=n.sliceString(e-2,e);return ht(_e(t,0))==t.length?t:t.slice(1)}function nb(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Jt.of(o.to+e.length),range:v.range(o.anchor+e.length,o.head+e.length)};let l=Ns(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Jt.of(o.head+e.length),range:v.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function sb(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&Ns(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:v.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function rb(n,e,t,i){let s=i.stringPrefixes||ln.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Jt.of(l.to+e.length),range:v.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Ns(n.doc,a),c;if(h==e){if(qa(n,a))return{changes:{insert:e+e,from:a},effects:Jt.of(a+e.length),range:v.cursor(a+e.length)};if(au(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:v.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=$a(n,a-2*e.length,s))>-1&&qa(n,c))return{changes:{insert:e+e+e+e,from:a},effects:Jt.of(a+e.length),range:v.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=oe.Word&&$a(n,a,s)>-1&&!ob(n,a,e,s))return{changes:{insert:e+e,from:a},effects:Jt.of(a+e.length),range:v.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function qa(n,e){let t=Se(n).resolveInner(e+1);return t.parent&&t.from==e}function ob(n,e,t,i){let s=Se(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=s.to==e&&s.parent;if(!h)break;s=h}return!1}function $a(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=oe.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=oe.Word)return r}return-1}function lb(n={}){return[Vy,Pe,pe.of(n),By,ab,nu]}const hu=[{key:"Ctrl-Space",run:ur},{mac:"Alt-`",run:ur},{mac:"Alt-i",run:ur},{key:"Escape",run:_y},{key:"ArrowDown",run:zn(!0)},{key:"ArrowUp",run:zn(!1)},{key:"PageDown",run:zn(!0,"page")},{key:"PageUp",run:zn(!1,"page")},{key:"Enter",run:Ly}],ab=Wt.highest(dn.computeN([pe],n=>n.facet(pe).defaultKeymap?[hu]:[]));class Ka{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Kt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(an).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Ze,l=[],a=0,h=i.doc.iter(),c=0,f=i.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!l.length)break;let m,g;if(l.length)m=a,g=l.reduce((w,E)=>Math.min(w,E.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;g=p.to,l.push(p),d++}for(;d<r.length;){let w=r[d];if(w.from==m&&(w.to>w.from||w.to==m))l.push(w),d++,g=Math.min(w.to,g);else{g=Math.min(w.from,g);break}}g=Math.min(g,f);let x=!1;if(l.some(w=>w.from==m&&(w.to==g||g==f))&&(x=m==g,!x&&g-m<10)){let w=m-(c+h.value.length);w>0&&(h.next(w),c=m);for(let E=m;;){if(E>=g){x=!0;break}if(!h.lineBreak&&c+h.value.length>E)break;E=c+h.value.length,c+=h.value.length,h.next()}}let A=wb(l);if(x)o.add(m,m,N.widget({widget:new xb(A),diagnostics:l.slice()}));else{let w=l.reduce((E,S)=>S.markClass?E+" "+S.markClass:E,"");o.add(m,g,N.mark({class:"cm-lintRange cm-lintRange-"+A+w,diagnostics:l.slice(),inclusiveEnd:l.some(E=>E.to>g)}))}if(a=g,a==f)break;for(let w=0;w<l.length;w++)l[w].to<=a&&l.splice(w--,1)}let u=o.finish();return new Kt(u,t,Vt(u))}}function Vt(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new Ka(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Ka(i.from,r,i.diagnostic)}}),i}function hb(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(an).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(cu))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function cb(n,e){return n.field(He,!1)?e:e.concat(F.appendConfig.of(kb))}const cu=F.define(),el=F.define(),fu=F.define(),He=Ce.define({create(){return new Kt(N.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=Vt(t,n.selected.diagnostic,r)||Vt(t,null,r)}!t.size&&s&&e.state.facet(an).autoPanel&&(s=null),n=new Kt(t,s,i)}for(let t of e.effects)if(t.is(cu)){let i=e.state.facet(an).autoPanel?t.value.length?hn.open:null:n.panel;n=Kt.init(t.value,i,e.state)}else t.is(el)?n=new Kt(n.diagnostics,t.value?hn.open:null,n.selected):t.is(fu)&&(n=new Kt(n.diagnostics,n.panel,t.value));return n},provide:n=>[Qi.from(n,e=>e.panel),D.decorations.from(n,e=>e.diagnostics)]}),fb=N.mark({class:"cm-lintRange cm-lintRange-active"});function ub(n,e,t){let{diagnostics:i}=n.state.field(He),s,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{if(e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0)))return s=c.diagnostics,r=a,o=h,!1});let l=n.state.facet(an).tooltipFilter;return s&&l&&(s=l(s,n.state)),s?{pos:r,end:o,above:!0,create(){return{dom:db(n,s)}}}:null}function db(n,e){return Q("ul",{class:"cm-tooltip-lint"},e.map(t=>du(n,t,!1)))}const pb=n=>{let e=n.state.field(He,!1);(!e||!e.panel)&&n.dispatch({effects:cb(n.state,[el.of(!0)])});let t=Os(n,hn.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Ua=n=>{let e=n.state.field(He,!1);return!e||!e.panel?!1:(n.dispatch({effects:el.of(!1)}),!0)},mb=n=>{let e=n.state.field(He,!1);if(!e)return!1;let t=n.state.selection.main,i=Vt(e.diagnostics,null,t.to+1);return!i&&(i=Vt(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),qm(n,i.from,1,{tooltip:pu,until:s=>s.docChanged||s.newSelection.main.head<i.from||s.newSelection.main.head>i.to}),!0)},gb=[{key:"Mod-Shift-m",run:pb,preventDefault:!0},{key:"F8",run:mb}],an=P.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...xt(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Ga,tooltipFilter:Ga,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,s,r)=>e(i,s,r)||t(i,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function Ga(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function uu(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function du(n,e,t){var i;let s=t?uu(e.actions):[];return Q("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Q("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Vt(n.state.field(He).diagnostics,e);p&&r.apply(n,p.from,p.to)},{name:h}=r,c=s[o]?h.indexOf(s[o]):-1,f=c<0?h:[h.slice(0,c),Q("u",h.slice(c,c+1)),h.slice(c+1)],u=r.markClass?" "+r.markClass:"";return Q("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&Q("div",{class:"cm-diagnosticSource"},e.source))}class xb extends tt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Q("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Ja{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=du(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class hn{constructor(e){this.view=e,this.items=[];let t=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)Ua(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=uu(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=Vt(this.view.state.field(He).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()}},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=Q("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=Q("div",{class:"cm-panel-lint"},this.list,Q("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Ua(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(He).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(He),i=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new Ja(this.view,c),this.items.splice(i,0,u),s=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),s=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new Ja(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/h:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(He),i=Vt(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:fu.of(i)})}static open(e){return new hn(e)}}function yb(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function qn(n){return yb(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const bb=D.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:qn("#f11")},".cm-lintRange-warning":{backgroundImage:qn("orange")},".cm-lintRange-info":{backgroundImage:qn("#999")},".cm-lintRange-hint":{backgroundImage:qn("#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}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function vb(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function wb(n){let e="hint",t=1;for(let i of n){let s=vb(i.severity);s>t&&(t=s,e=i.severity)}return e}const pu=zm(ub,{hideOn:hb}),kb=[He,D.decorations.compute([He],n=>{let{selected:e,panel:t}=n.field(He);return!e||!t||e.from==e.to?N.none:N.set([fb.range(e.from,e.to)])}),pu,bb];var Ya=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(eb)),e.defaultKeymap!==!1&&(i=i.concat(Bx)),e.searchKeymap!==!1&&(i=i.concat(hy)),e.historyKeymap!==!1&&(i=i.concat(z0)),e.foldKeymap!==!1&&(i=i.concat(Zg)),e.completionKeymap!==!1&&(i=i.concat(hu)),e.lintKeymap!==!1&&(i=i.concat(gb));var s=[];return e.lineNumbers!==!1&&s.push(sg()),e.highlightActiveLineGutter!==!1&&s.push(lg()),e.highlightSpecialChars!==!1&&s.push(ym()),e.history!==!1&&s.push(R0()),e.foldGutter!==!1&&s.push(n0()),e.drawSelection!==!1&&s.push(om()),e.dropCursor!==!1&&s.push(um()),e.allowMultipleSelections!==!1&&s.push(K.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(zg()),e.syntaxHighlighting!==!1&&s.push(nf(l0,{fallback:!0})),e.bracketMatching!==!1&&s.push(p0()),e.closeBrackets!==!1&&s.push(Yy()),e.autocompletion!==!1&&s.push(lb()),e.rectangularSelection!==!1&&s.push(_m()),t!==!1&&s.push(Im()),e.highlightActiveLine!==!1&&s.push(Cm()),e.highlightSelectionMatches!==!1&&s.push(jx()),e.tabSize&&typeof e.tabSize=="number"&&s.push(pn.of(" ".repeat(e.tabSize))),s.concat([dn.of(i.flat())]).filter(Boolean)};const Sb="#e5c07b",Xa="#e06c75",Cb="#56b6c2",Ab="#ffffff",Zn="#abb2bf",fo="#7d8799",Mb="#61afef",Tb="#98c379",Qa="#d19a66",Eb="#c678dd",Db="#21252b",Za="#2c313a",eh="#282c34",pr="#353a42",Ob="#3E4451",th="#528bff",Lb=D.theme({"&":{color:Zn,backgroundColor:eh},".cm-content":{caretColor:th},".cm-cursor, .cm-dropCursor":{borderLeftColor:th},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Ob},".cm-panels":{backgroundColor:Db,color:Zn},".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:eh,color:fo,border:"none"},".cm-activeLineGutter":{backgroundColor:Za},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:pr},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:pr,borderBottomColor:pr},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Za,color:Zn}}},{dark:!0}),_b=gn.define([{tag:k.keyword,color:Eb},{tag:[k.name,k.deleted,k.character,k.propertyName,k.macroName],color:Xa},{tag:[k.function(k.variableName),k.labelName],color:Mb},{tag:[k.color,k.constant(k.name),k.standard(k.name)],color:Qa},{tag:[k.definition(k.name),k.separator],color:Zn},{tag:[k.typeName,k.className,k.number,k.changed,k.annotation,k.modifier,k.self,k.namespace],color:Sb},{tag:[k.operator,k.operatorKeyword,k.url,k.escape,k.regexp,k.link,k.special(k.string)],color:Cb},{tag:[k.meta,k.comment],color:fo},{tag:k.strong,fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.link,color:fo,textDecoration:"underline"},{tag:k.heading,fontWeight:"bold",color:Xa},{tag:[k.atom,k.bool,k.special(k.variableName)],color:Qa},{tag:[k.processingInstruction,k.string,k.inserted],color:Tb},{tag:k.invalid,color:Ab}]),mu=[Lb,nf(_b)];var Pb=D.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Rb=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:i=!0,readOnly:s=!1,theme:r="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(t&&a.unshift(dn.of([Nx])),l&&(typeof l=="boolean"?a.unshift(Ya()):a.unshift(Ya(l))),o&&a.unshift(Em(o)),r){case"light":a.push(Pb);break;case"dark":a.push(mu);break;case"none":break;default:a.push(r);break}return i===!1&&a.push(D.editable.of(!1)),s&&a.push(K.readOnly.of(!0)),[...a]},Ib=n=>({line:n.state.doc.lineAt(n.state.selection.main.from),lineCount:n.state.doc.lines,lineBreak:n.state.lineBreak,length:n.state.doc.length,readOnly:n.state.readOnly,tabSize:n.state.tabSize,selection:n.state.selection,selectionAsSingle:n.state.selection.asSingle().main,ranges:n.state.selection.ranges,selectionCode:n.state.sliceDoc(n.state.selection.main.from,n.state.selection.main.to),selections:n.state.selection.ranges.map(e=>n.state.sliceDoc(e.from,e.to)),selectedText:n.state.selection.ranges.some(e=>!e.empty)}),ih=gt.define(),Bb=[];function Nb(n){var{value:e,selection:t,onChange:i,onStatistics:s,onCreateEditor:r,onUpdate:o,extensions:l=Bb,autoFocus:a,theme:h="light",height:c=null,minHeight:f=null,maxHeight:u=null,width:d=null,minWidth:p=null,maxWidth:m=null,placeholder:g="",editable:x=!0,readOnly:A=!1,indentWithTab:w=!0,basicSetup:E=!0,root:S,initialState:M}=n,[T,V]=Y.useState(),[B,H]=Y.useState(),[W,I]=Y.useState(),z=D.theme({"&":{height:c,minHeight:f,maxHeight:u,width:d,minWidth:p,maxWidth:m},"& .cm-scroller":{height:"100% !important"}}),j=D.updateListener.of(X=>{if(X.docChanged&&typeof i=="function"&&!X.transactions.some(xe=>xe.annotation(ih))){var de=X.state.doc,se=de.toString();i(se,X)}s&&s(Ib(X))}),J=Rb({theme:h,editable:x,readOnly:A,placeholder:g,indentWithTab:w,basicSetup:E}),ne=[j,z,...J];return o&&typeof o=="function"&&ne.push(D.updateListener.of(o)),ne=ne.concat(l),Y.useEffect(()=>{if(T&&!W){var X={doc:e,selection:t,extensions:ne},de=M?K.fromJSON(M.json,X,M.fields):K.create(X);if(I(de),!B){var se=new D({state:de,parent:T,root:S});H(se),r&&r(se,de)}}return()=>{B&&(I(void 0),H(void 0))}},[T,W]),Y.useEffect(()=>V(n.container),[n.container]),Y.useEffect(()=>()=>{B&&(B.destroy(),H(void 0))},[B]),Y.useEffect(()=>{a&&B&&B.focus()},[a,B]),Y.useEffect(()=>{B&&B.dispatch({effects:F.reconfigure.of(ne)})},[h,l,c,f,u,d,p,m,g,x,A,w,E,i,o]),Y.useEffect(()=>{if(e!==void 0){var X=B?B.state.doc.toString():"";B&&e!==X&&B.dispatch({changes:{from:0,to:X.length,insert:e||""},annotations:[ih.of(!0)]})}},[e,B]),{state:W,setState:I,view:B,setView:H,container:T,setContainer:V}}var Vb=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],gu=Y.forwardRef((n,e)=>{var{className:t,value:i="",selection:s,extensions:r=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,autoFocus:c,theme:f="light",height:u,minHeight:d,maxHeight:p,width:m,minWidth:g,maxWidth:x,basicSetup:A,placeholder:w,indentWithTab:E,editable:S,readOnly:M,root:T,initialState:V}=n,B=Uu(n,Vb),H=Y.useRef(null),{state:W,view:I,container:z}=Nb({container:H.current,root:T,value:i,autoFocus:c,theme:f,height:u,minHeight:d,maxHeight:p,width:m,minWidth:g,maxWidth:x,basicSetup:A,placeholder:w,indentWithTab:E,editable:S,readOnly:M,selection:s,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,extensions:r,initialState:V});if(Y.useImperativeHandle(e,()=>({editor:H.current,state:W,view:I}),[H,z,W,I]),typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var j=typeof f=="string"?"cm-theme-"+f:"cm-theme";return _.jsx("div",mr({ref:H,className:""+j+(t?" "+t:"")},B))});gu.displayName="CodeMirror";function C(n){return new Rg(Bo.define(n))}function At(n){return b(()=>import("./index-HBtEhFV8.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.sql({dialect:e[n]}))}const Wb=[y.of({name:"C",extensions:["c","h","ino"],load(){return b(()=>import("./index-CfFkiEw9.js"),__vite__mapDeps([4,1,2,3])).then(n=>n.cpp())}}),y.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return b(()=>import("./index-CfFkiEw9.js"),__vite__mapDeps([4,1,2,3])).then(n=>n.cpp())}}),y.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return At("Cassandra")}}),y.of({name:"CSS",extensions:["css"],load(){return b(()=>import("./index-DgTHE4KH.js"),__vite__mapDeps([5,1,2,3])).then(n=>n.css())}}),y.of({name:"Go",extensions:["go"],load(){return b(()=>import("./index-D5AcpGl_.js"),__vite__mapDeps([6,1,2,3])).then(n=>n.go())}}),y.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return b(()=>import("./index-DB9Tltht.js"),__vite__mapDeps([7,1,5,2,3,8])).then(n=>n.html())}}),y.of({name:"Java",extensions:["java"],load(){return b(()=>import("./index-D3Zk0Btz.js"),__vite__mapDeps([9,1,2,3])).then(n=>n.java())}}),y.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return b(()=>import("./index-D-9XGv5u.js"),__vite__mapDeps([8,1,2,3])).then(n=>n.javascript())}}),y.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return b(()=>import("./index-TRTMCU2f.js"),__vite__mapDeps([10,1,2,3])).then(n=>n.json())}}),y.of({name:"JSX",extensions:["jsx"],load(){return b(()=>import("./index-D-9XGv5u.js"),__vite__mapDeps([8,1,2,3])).then(n=>n.javascript({jsx:!0}))}}),y.of({name:"LESS",extensions:["less"],load(){return b(()=>import("./index-BTAmHv-d.js"),__vite__mapDeps([11,5,1,2,3])).then(n=>n.less())}}),y.of({name:"Liquid",extensions:["liquid"],load(){return b(()=>import("./index-a7yJqPRD.js"),__vite__mapDeps([12,7,1,5,2,3,8])).then(n=>n.liquid())}}),y.of({name:"MariaDB SQL",load(){return At("MariaSQL")}}),y.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return b(()=>import("./index-BPFm8xBn.js"),__vite__mapDeps([13,7,1,5,2,3,8])).then(n=>n.markdown())}}),y.of({name:"MS SQL",load(){return At("MSSQL")}}),y.of({name:"MySQL",load(){return At("MySQL")}}),y.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return b(()=>import("./index-B05Rh3LW.js"),__vite__mapDeps([14,1,7,5,2,3,8])).then(n=>n.php())}}),y.of({name:"PLSQL",extensions:["pls"],load(){return At("PLSQL")}}),y.of({name:"PostgreSQL",load(){return At("PostgreSQL")}}),y.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return b(()=>import("./index-CW1WHdXq.js"),__vite__mapDeps([15,1,2,3])).then(n=>n.python())}}),y.of({name:"Rust",extensions:["rs"],load(){return b(()=>import("./index-H4qir-5V.js"),__vite__mapDeps([16,1,2,3])).then(n=>n.rust())}}),y.of({name:"Sass",extensions:["sass"],load(){return b(()=>import("./index-BtCLkneo.js"),__vite__mapDeps([17,1,5,2,3])).then(n=>n.sass({indented:!0}))}}),y.of({name:"SCSS",extensions:["scss"],load(){return b(()=>import("./index-BtCLkneo.js"),__vite__mapDeps([17,1,5,2,3])).then(n=>n.sass())}}),y.of({name:"SQL",extensions:["sql"],load(){return At("StandardSQL")}}),y.of({name:"SQLite",load(){return At("SQLite")}}),y.of({name:"TSX",extensions:["tsx"],load(){return b(()=>import("./index-D-9XGv5u.js"),__vite__mapDeps([8,1,2,3])).then(n=>n.javascript({jsx:!0,typescript:!0}))}}),y.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return b(()=>import("./index-D-9XGv5u.js"),__vite__mapDeps([8,1,2,3])).then(n=>n.javascript({typescript:!0}))}}),y.of({name:"WebAssembly",extensions:["wat","wast"],load(){return b(()=>import("./index-D8PR6AHG.js"),__vite__mapDeps([18,1,2,3])).then(n=>n.wast())}}),y.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return b(()=>import("./index-BJepU7_w.js"),__vite__mapDeps([19,1,2,3])).then(n=>n.xml())}}),y.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return b(()=>import("./index-DgVZUoYY.js"),__vite__mapDeps([20,1,2,3])).then(n=>n.yaml())}}),y.of({name:"APL",extensions:["dyalog","apl"],load(){return b(()=>import("./apl-B4CMkyY2.js"),[]).then(n=>C(n.apl))}}),y.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return b(()=>import("./asciiarmor-Df11BRmG.js"),[]).then(n=>C(n.asciiArmor))}}),y.of({name:"ASN.1",extensions:["asn","asn1"],load(){return b(()=>import("./asn1-EdZsLKOL.js"),[]).then(n=>C(n.asn1({})))}}),y.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return b(()=>import("./asterisk-B-8jnY81.js"),[]).then(n=>C(n.asterisk))}}),y.of({name:"Brainfuck",extensions:["b","bf"],load(){return b(()=>import("./brainfuck-C4LP7Hcl.js"),[]).then(n=>C(n.brainfuck))}}),y.of({name:"Cobol",extensions:["cob","cpy"],load(){return b(()=>import("./cobol-CWcv1MsR.js"),[]).then(n=>C(n.cobol))}}),y.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.csharp))}}),y.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return b(()=>import("./clojure-BMjYHr_A.js"),[]).then(n=>C(n.clojure))}}),y.of({name:"ClojureScript",extensions:["cljs"],load(){return b(()=>import("./clojure-BMjYHr_A.js"),[]).then(n=>C(n.clojure))}}),y.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return b(()=>import("./css-BnMrqG3P.js"),[]).then(n=>C(n.gss))}}),y.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return b(()=>import("./cmake-BQqOBYOt.js"),[]).then(n=>C(n.cmake))}}),y.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return b(()=>import("./coffeescript-S37ZYGWr.js"),[]).then(n=>C(n.coffeeScript))}}),y.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return b(()=>import("./commonlisp-DBKNyK5s.js"),[]).then(n=>C(n.commonLisp))}}),y.of({name:"Cypher",extensions:["cyp","cypher"],load(){return b(()=>import("./cypher-C_CwsFkJ.js"),[]).then(n=>C(n.cypher))}}),y.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return b(()=>import("./python-BuPzkPfP.js"),[]).then(n=>C(n.cython))}}),y.of({name:"Crystal",extensions:["cr"],load(){return b(()=>import("./crystal-SjHAIU92.js"),[]).then(n=>C(n.crystal))}}),y.of({name:"D",extensions:["d"],load(){return b(()=>import("./d-pRatUO7H.js"),[]).then(n=>C(n.d))}}),y.of({name:"Dart",extensions:["dart"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.dart))}}),y.of({name:"diff",extensions:["diff","patch"],load(){return b(()=>import("./diff-DbItnlRl.js"),[]).then(n=>C(n.diff))}}),y.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return b(()=>import("./dockerfile-BKs6k2Af.js"),__vite__mapDeps([21,22])).then(n=>C(n.dockerFile))}}),y.of({name:"DTD",extensions:["dtd"],load(){return b(()=>import("./dtd-DF_7sFjM.js"),[]).then(n=>C(n.dtd))}}),y.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return b(()=>import("./dylan-DwRh75JA.js"),[]).then(n=>C(n.dylan))}}),y.of({name:"EBNF",load(){return b(()=>import("./ebnf-CDyGwa7X.js"),[]).then(n=>C(n.ebnf))}}),y.of({name:"ECL",extensions:["ecl"],load(){return b(()=>import("./ecl-Cabwm37j.js"),[]).then(n=>C(n.ecl))}}),y.of({name:"edn",extensions:["edn"],load(){return b(()=>import("./clojure-BMjYHr_A.js"),[]).then(n=>C(n.clojure))}}),y.of({name:"Eiffel",extensions:["e"],load(){return b(()=>import("./eiffel-CnydiIhH.js"),[]).then(n=>C(n.eiffel))}}),y.of({name:"Elm",extensions:["elm"],load(){return b(()=>import("./elm-vLlmbW-K.js"),[]).then(n=>C(n.elm))}}),y.of({name:"Erlang",extensions:["erl"],load(){return b(()=>import("./erlang-BNw1qcRV.js"),[]).then(n=>C(n.erlang))}}),y.of({name:"Esper",load(){return b(()=>import("./sql-D0XecflT.js"),[]).then(n=>C(n.esper))}}),y.of({name:"Factor",extensions:["factor"],load(){return b(()=>import("./factor-kuTfRLto.js"),__vite__mapDeps([23,22])).then(n=>C(n.factor))}}),y.of({name:"FCL",load(){return b(()=>import("./fcl-Kvtd6kyn.js"),[]).then(n=>C(n.fcl))}}),y.of({name:"Forth",extensions:["forth","fth","4th"],load(){return b(()=>import("./forth-Ffai-XNe.js"),[]).then(n=>C(n.forth))}}),y.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return b(()=>import("./fortran-DYz_wnZ1.js"),[]).then(n=>C(n.fortran))}}),y.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return b(()=>import("./mllike-CXdrOF99.js"),[]).then(n=>C(n.fSharp))}}),y.of({name:"Gas",extensions:["s"],load(){return b(()=>import("./gas-Bneqetm1.js"),[]).then(n=>C(n.gas))}}),y.of({name:"Gherkin",extensions:["feature"],load(){return b(()=>import("./gherkin-heZmZLOM.js"),[]).then(n=>C(n.gherkin))}}),y.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return b(()=>import("./groovy-D9Dt4D0W.js"),[]).then(n=>C(n.groovy))}}),y.of({name:"Haskell",extensions:["hs"],load(){return b(()=>import("./haskell-BWDZoCOh.js"),[]).then(n=>C(n.haskell))}}),y.of({name:"Haxe",extensions:["hx"],load(){return b(()=>import("./haxe-H-WmDvRZ.js"),[]).then(n=>C(n.haxe))}}),y.of({name:"HXML",extensions:["hxml"],load(){return b(()=>import("./haxe-H-WmDvRZ.js"),[]).then(n=>C(n.hxml))}}),y.of({name:"HTTP",load(){return b(()=>import("./http-DBlCnlav.js"),[]).then(n=>C(n.http))}}),y.of({name:"IDL",extensions:["pro"],load(){return b(()=>import("./idl-BEugSyMb.js"),[]).then(n=>C(n.idl))}}),y.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return b(()=>import("./javascript-qCveANmP.js"),[]).then(n=>C(n.jsonld))}}),y.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return b(()=>import("./jinja2-C4DGRd-O.js"),[]).then(n=>C(n.jinja2))}}),y.of({name:"Julia",extensions:["jl"],load(){return b(()=>import("./julia-DuME0IfC.js"),[]).then(n=>C(n.julia))}}),y.of({name:"Kotlin",extensions:["kt","kts"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.kotlin))}}),y.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return b(()=>import("./livescript-BwQOo05w.js"),[]).then(n=>C(n.liveScript))}}),y.of({name:"Lua",extensions:["lua"],load(){return b(()=>import("./lua-VAEuO923.js"),[]).then(n=>C(n.lua))}}),y.of({name:"mIRC",extensions:["mrc"],load(){return b(()=>import("./mirc-CjQqDB4T.js"),[]).then(n=>C(n.mirc))}}),y.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return b(()=>import("./mathematica-DTrFuWx2.js"),[]).then(n=>C(n.mathematica))}}),y.of({name:"Modelica",extensions:["mo"],load(){return b(()=>import("./modelica-Dc1JOy9r.js"),[]).then(n=>C(n.modelica))}}),y.of({name:"MUMPS",extensions:["mps"],load(){return b(()=>import("./mumps-BT43cFF4.js"),[]).then(n=>C(n.mumps))}}),y.of({name:"Mbox",extensions:["mbox"],load(){return b(()=>import("./mbox-CNhZ1qSd.js"),[]).then(n=>C(n.mbox))}}),y.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return b(()=>import("./nginx-DdIZxoE0.js"),[]).then(n=>C(n.nginx))}}),y.of({name:"NSIS",extensions:["nsh","nsi"],load(){return b(()=>import("./nsis-LY0VT_u5.js"),__vite__mapDeps([24,22])).then(n=>C(n.nsis))}}),y.of({name:"NTriples",extensions:["nt","nq"],load(){return b(()=>import("./ntriples-BfvgReVJ.js"),[]).then(n=>C(n.ntriples))}}),y.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.objectiveC))}}),y.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.objectiveCpp))}}),y.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return b(()=>import("./mllike-CXdrOF99.js"),[]).then(n=>C(n.oCaml))}}),y.of({name:"Octave",extensions:["m"],load(){return b(()=>import("./octave-Ck1zUtKM.js"),[]).then(n=>C(n.octave))}}),y.of({name:"Oz",extensions:["oz"],load(){return b(()=>import("./oz-BzwKVEFT.js"),[]).then(n=>C(n.oz))}}),y.of({name:"Pascal",extensions:["p","pas"],load(){return b(()=>import("./pascal--L3eBynH.js"),[]).then(n=>C(n.pascal))}}),y.of({name:"Perl",extensions:["pl","pm"],load(){return b(()=>import("./perl-CdXCOZ3F.js"),[]).then(n=>C(n.perl))}}),y.of({name:"Pig",extensions:["pig"],load(){return b(()=>import("./pig-CevX1Tat.js"),[]).then(n=>C(n.pig))}}),y.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return b(()=>import("./powershell-CFHJl5sT.js"),[]).then(n=>C(n.powerShell))}}),y.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return b(()=>import("./properties-C78fOPTZ.js"),[]).then(n=>C(n.properties))}}),y.of({name:"ProtoBuf",extensions:["proto"],load(){return b(()=>import("./protobuf-ChK-085T.js"),[]).then(n=>C(n.protobuf))}}),y.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return b(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([25,26])).then(n=>C(n.pug))}}),y.of({name:"Puppet",extensions:["pp"],load(){return b(()=>import("./puppet-DMA9R1ak.js"),[]).then(n=>C(n.puppet))}}),y.of({name:"Q",extensions:["q"],load(){return b(()=>import("./q-pXgVlZs6.js"),[]).then(n=>C(n.q))}}),y.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return b(()=>import("./r-DUYO_cvP.js"),[]).then(n=>C(n.r))}}),y.of({name:"RPM Changes",load(){return b(()=>import("./rpm-CTu-6PCP.js"),[]).then(n=>C(n.rpmChanges))}}),y.of({name:"RPM Spec",extensions:["spec"],load(){return b(()=>import("./rpm-CTu-6PCP.js"),[]).then(n=>C(n.rpmSpec))}}),y.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return b(()=>import("./ruby-BK5aLJev.js"),[]).then(n=>C(n.ruby))}}),y.of({name:"SAS",extensions:["sas"],load(){return b(()=>import("./sas-B4kiWyti.js"),[]).then(n=>C(n.sas))}}),y.of({name:"Scala",extensions:["scala"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.scala))}}),y.of({name:"Scheme",extensions:["scm","ss"],load(){return b(()=>import("./scheme-C41bIUwD.js"),[]).then(n=>C(n.scheme))}}),y.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return b(()=>import("./shell-CjFT_Tl9.js"),[]).then(n=>C(n.shell))}}),y.of({name:"Sieve",extensions:["siv","sieve"],load(){return b(()=>import("./sieve-C3Gn_uJK.js"),[]).then(n=>C(n.sieve))}}),y.of({name:"Smalltalk",extensions:["st"],load(){return b(()=>import("./smalltalk-CnHTOXQT.js"),[]).then(n=>C(n.smalltalk))}}),y.of({name:"Solr",load(){return b(()=>import("./solr-DehyRSwq.js"),[]).then(n=>C(n.solr))}}),y.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return b(()=>import("./mllike-CXdrOF99.js"),[]).then(n=>C(n.sml))}}),y.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return b(()=>import("./sparql-DkYu6x3z.js"),[]).then(n=>C(n.sparql))}}),y.of({name:"Spreadsheet",alias:["excel","formula"],load(){return b(()=>import("./spreadsheet-BCZA_wO0.js"),[]).then(n=>C(n.spreadsheet))}}),y.of({name:"Squirrel",extensions:["nut"],load(){return b(()=>import("./clike-B9uivgTg.js"),[]).then(n=>C(n.squirrel))}}),y.of({name:"Stylus",extensions:["styl"],load(){return b(()=>import("./stylus-B533Al4x.js"),[]).then(n=>C(n.stylus))}}),y.of({name:"Swift",extensions:["swift"],load(){return b(()=>import("./swift-BzpIVaGY.js"),[]).then(n=>C(n.swift))}}),y.of({name:"sTeX",load(){return b(()=>import("./stex-C3f8Ysf7.js"),[]).then(n=>C(n.stex))}}),y.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return b(()=>import("./stex-C3f8Ysf7.js"),[]).then(n=>C(n.stex))}}),y.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return b(()=>import("./verilog-C6RDOZhf.js"),[]).then(n=>C(n.verilog))}}),y.of({name:"Tcl",extensions:["tcl"],load(){return b(()=>import("./tcl-DVfN8rqt.js"),[]).then(n=>C(n.tcl))}}),y.of({name:"Textile",extensions:["textile"],load(){return b(()=>import("./textile-CnDTJFAw.js"),[]).then(n=>C(n.textile))}}),y.of({name:"TiddlyWiki",load(){return b(()=>import("./tiddlywiki-DO-Gjzrf.js"),[]).then(n=>C(n.tiddlyWiki))}}),y.of({name:"Tiki wiki",load(){return b(()=>import("./tiki-DGYXhP31.js"),[]).then(n=>C(n.tiki))}}),y.of({name:"TOML",extensions:["toml"],load(){return b(()=>import("./toml-Bm5Em-hy.js"),[]).then(n=>C(n.toml))}}),y.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return b(()=>import("./troff-wAsdV37c.js"),[]).then(n=>C(n.troff))}}),y.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return b(()=>import("./ttcn-CfJYG6tj.js"),[]).then(n=>C(n.ttcn))}}),y.of({name:"TTCN_CFG",extensions:["cfg"],load(){return b(()=>import("./ttcn-cfg-B9xdYoR4.js"),[]).then(n=>C(n.ttcnCfg))}}),y.of({name:"Turtle",extensions:["ttl"],load(){return b(()=>import("./turtle-B1tBg_DP.js"),[]).then(n=>C(n.turtle))}}),y.of({name:"Web IDL",extensions:["webidl"],load(){return b(()=>import("./webidl-ZXfAyPTL.js"),[]).then(n=>C(n.webIDL))}}),y.of({name:"VB.NET",extensions:["vb"],load(){return b(()=>import("./vb-CmGdzxic.js"),[]).then(n=>C(n.vb))}}),y.of({name:"VBScript",extensions:["vbs"],load(){return b(()=>import("./vbscript-BuJXcnF6.js"),[]).then(n=>C(n.vbScript))}}),y.of({name:"Velocity",extensions:["vtl"],load(){return b(()=>import("./velocity-D8B20fx6.js"),[]).then(n=>C(n.velocity))}}),y.of({name:"Verilog",extensions:["v"],load(){return b(()=>import("./verilog-C6RDOZhf.js"),[]).then(n=>C(n.verilog))}}),y.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return b(()=>import("./vhdl-lSbBsy5d.js"),[]).then(n=>C(n.vhdl))}}),y.of({name:"XQuery",extensions:["xy","xquery"],load(){return b(()=>import("./xquery-CQfU5ijd.js"),[]).then(n=>C(n.xQuery))}}),y.of({name:"Yacas",extensions:["ys"],load(){return b(()=>import("./yacas-BJ4BC0dw.js"),[]).then(n=>C(n.yacas))}}),y.of({name:"Z80",extensions:["z80"],load(){return b(()=>import("./z80-Hz9HOZM7.js"),[]).then(n=>C(n.z80))}}),y.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return b(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(n=>C(n.mscgen))}}),y.of({name:"Xù",extensions:["xu"],load(){return b(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(n=>C(n.xu))}}),y.of({name:"MsGenny",extensions:["msgenny"],load(){return b(()=>import("./mscgen-BA5vi2Kp.js"),[]).then(n=>C(n.msgenny))}}),y.of({name:"Vue",extensions:["vue"],load(){return b(()=>import("./index-DJ7YtDlC.js"),__vite__mapDeps([27,7,1,5,2,3,8])).then(n=>n.vue())}}),y.of({name:"Angular Template",load(){return b(()=>import("./index-DIV7qBvA.js"),__vite__mapDeps([28,7,1,5,2,3,8])).then(n=>n.angular())}})];function Fb(n){const[e,t]=Y.useState([]);return Y.useEffect(()=>{if(t([]),!n)return;const i=y.matchFilename(Wb,n.split("/").pop()??"");if(!i)return;let s=!0;return i.load().then(r=>s&&t([r])),()=>{s=!1}},[n]),e}const Hb=/\bHOLE \d+\b/,jb=N.line({class:"cm-hole-line"}),zb=le.fromClass(class{constructor(n){nl(this,"decorations");this.decorations=nh(n)}update(n){(n.docChanged||n.viewportChanged)&&(this.decorations=nh(n.view))}},{decorations:n=>n.decorations});function nh(n){const e=new Ze;for(const{from:t,to:i}of n.visibleRanges)for(let s=t;s<=i;){const r=n.state.doc.lineAt(s);Hb.test(r.text)&&e.add(r.from,r.from,jb),s=r.to+1}return e.finish()}function sh(n,e){const t=n.state.doc,i=new RegExp(`\\bHOLE ${e.id}\\b`);let s=-1;for(let r=1;r<=t.lines;r++)if(i.test(t.line(r).text)){s=t.line(r).from;break}s<0&&(s=t.line(Math.min(Math.max(1,e.startLine),t.lines)).from),n.dispatch({selection:{anchor:s},effects:D.scrollIntoView(s,{y:"center"})}),n.focus()}function qb(n,e){const t={name:"",kids:new Map};for(const s of n){const r=e(s.path).split("/");let o=t;r.forEach((l,a)=>{o.kids.has(l)||o.kids.set(l,{name:l,kids:new Map}),o=o.kids.get(l),a===r.length-1&&(o.path=s.path)})}const i=s=>{for(const[r,o]of s.kids)s.kids.set(r,i(o));if(!s.path&&s.kids.size===1&&s.name){const r=[...s.kids.values()][0];if(!r.path)return{...r,name:`${s.name}/${r.name}`}}return s};return i(t)}function $b(){var tl;const{id:n=""}=vu(),{project:e,rel:t}=wu(),i=ku(),s=Su(),r=Cu(),o=Au(),l=Mu({queryKey:["practice",e.id,n],queryFn:()=>$u(`/projects/${e.id}/practice/${n}`)}),a=l.data,h=Y.useMemo(()=>(a==null?void 0:a.files)??(a?[{path:a.file,original:a.original,holed:a.holed,attempt:a.attempt}]:[]),[a]),c=Y.useMemo(()=>a?a.holes.map(R=>({...R,file:R.file??a.file})):[],[a]),[f,u]=Y.useState(null),[d,p]=Y.useState(null),[m,g]=Y.useState(!0),[x,A]=Y.useState({}),[w,E]=Y.useState(null),[S,M]=Y.useState(!1),T=Y.useRef(),V=Y.useRef(null),B=Y.useRef(null),H=Y.useRef(null),W=Fb(f??void 0);Y.useEffect(()=>{var R;!a||d||(p(Object.fromEntries(h.map(re=>[re.path,re.attempt]))),u(((R=h[0])==null?void 0:R.path)??null))},[a,h,d]);const I=async()=>{clearTimeout(T.current);const R=V.current;V.current=null,R&&(await rl(`/projects/${e.id}/practice/${n}/attempt`,R),g(!0))};Y.useEffect(()=>()=>clearTimeout(T.current),[]);const z=R=>c.filter(re=>re.file===R),j=!!f&&z(f).length>0,J=Y.useMemo(()=>[...W,zb,...j?[]:[K.readOnly.of(!0),D.editable.of(!1)]],[W,j]);if(l.isLoading)return _.jsx("div",{className:"p-8",children:_.jsx(sl,{})});if(!a)return _.jsx(Tu,{title:"Practice not found"});if(!d||!f)return _.jsx("div",{className:"p-8",children:_.jsx(sl,{})});const ne=R=>{var re;return(re=a.review)==null?void 0:re.holes.find(ce=>ce.id===R)},X=h.find(R=>R.path===f),de=R=>{p(re=>({...re,[f]:R})),g(!1),V.current={file:f,text:R},clearTimeout(T.current),T.current=setTimeout(I,800)},se=R=>{R!==f&&(I(),u(R))},xe=R=>{E(R.id),R.file&&R.file!==f?(H.current=R,se(R.file)):B.current&&sh(B.current,R)},Je=async()=>{await I(),o.run(`/projects/${e.id}/practice/${n}/review`,{},()=>i.invalidateQueries({queryKey:["practice",e.id,n]}))},ye=async()=>{window.confirm("Put every hole back? Your answers in all files are cleared.")&&(clearTimeout(T.current),V.current=null,p(Object.fromEntries(h.map(R=>[R.path,R.holed]))),await Promise.all(h.filter(R=>z(R.path).length).map(R=>rl(`/projects/${e.id}/practice/${n}/attempt`,{file:R.path,text:R.holed}))),g(!0))},Ne=qb(h,t),Ve=(R,re)=>{if(!R.path)return _.jsxs("div",{children:[_.jsxs("div",{className:"flex h-[22px] items-center gap-1 pr-2 text-[13px] text-muted",style:{paddingLeft:re*12+8},children:[_.jsx(zu,{className:"h-3.5 w-3.5 shrink-0"})," ",_.jsx("span",{className:"truncate",children:R.name})]}),[...R.kids.values()].map(jt=>Ve(jt,re+1))]},`d:${R.name}:${re}`);const ce=z(R.path),Ct=ce.filter(jt=>{var il;return((il=ne(jt.id))==null?void 0:il.verdict)==="right"}).length;return _.jsxs("button",{onClick:()=>se(R.path),title:t(R.path),className:Vs("flex h-[22px] w-full items-center gap-1 pr-2 text-left text-[13px]",R.path===f?"bg-sel text-ink dark:text-white":"hover:bg-raised",!ce.length&&"text-muted"),style:{paddingLeft:re*12+8},children:[_.jsx(qu,{className:"h-3.5 w-3.5 shrink-0 text-muted"}),_.jsx("span",{className:"min-w-0 flex-1 truncate",children:R.name}),ce.length?_.jsx("span",{className:Vs("rounded-sm px-1 text-[11px] font-semibold",a.review&&Ct===ce.length?"bg-good/15 text-good":"bg-warn/15 text-warn"),title:`${ce.length} hole${ce.length>1?"s":""}`,children:a.review?`${Ct}/${ce.length}`:ce.length}):_.jsx(Fs,{className:"h-3 w-3 shrink-0","aria-label":"read only"})]},R.path)},Ye=_.jsxs("div",{className:"flex h-full flex-col bg-side",children:[_.jsxs("div",{className:"px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted",children:["Files · ",h.length]}),_.jsx("div",{className:"min-h-0 flex-1 overflow-auto pb-3",children:[...Ne.kids.values()].map(R=>Ve(R,0))}),_.jsxs("p",{className:"border-t border-line px-3 py-2 text-[11px] text-muted",children:["Numbers are holes to fill. ",_.jsx(Fs,{className:"inline h-3 w-3"})," files are context, read only."]})]}),yt=_.jsxs("div",{className:"flex h-full flex-col",children:[_.jsxs("div",{className:"flex items-center gap-2 border-b border-line bg-panel px-3 py-1.5 text-xs text-muted",children:[_.jsx("span",{className:"truncate font-mono text-[12.5px] text-ink",title:t(f),children:t(f)}),j?_.jsx("span",{className:"flex shrink-0 items-center gap-1",children:m?_.jsxs(_.Fragment,{children:[_.jsx(Eu,{className:"h-3.5 w-3.5 text-good"})," saved"]}):"saving..."}):_.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[_.jsx(Fs,{className:"h-3 w-3"})," context, read only"]}),_.jsx("span",{className:"ml-auto hidden shrink-0 lg:inline",children:"A copy in cognitune; your folder is not touched"})]}),_.jsx("div",{className:"relative min-h-0 flex-1 bg-panel",children:_.jsx("div",{className:"absolute inset-0",children:_.jsx(gu,{value:d[f]??X.attempt,onChange:de,theme:r?mu:"light",extensions:J,height:"100%",onCreateEditor:R=>{B.current=R;const re=H.current;re&&re.file===f&&(H.current=null,setTimeout(()=>sh(R,re),0))}},f)})})]}),Ht=_.jsxs("div",{className:"flex h-full flex-col bg-panel",children:[_.jsx("div",{className:"border-b border-line px-3 py-1.5 text-xs font-medium",children:"Original (holes marked)"}),_.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:_.jsx(Du,{text:X.original,lang:Kb(f),marks:z(f).map(R=>({from:R.startLine,to:R.endLine,cls:"hole"}))})})]}),vn=_.jsxs("div",{className:"flex h-full flex-col bg-panel",children:[_.jsxs("div",{className:"border-b border-line p-4",children:[_.jsxs(Ou,{to:`/p/${e.id}/library`,className:"inline-flex items-center gap-1 text-xs text-muted hover:text-ink",children:[_.jsx(Lu,{className:"h-3.5 w-3.5"})," Library"]}),_.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[_.jsxs(_u,{tone:"accent",children:["practice · level ",a.level]}),_.jsxs("span",{className:"text-xs text-muted",children:[c.length," hole",c.length>1?"s":""," · ",Pu(a.createdAt)]})]}),a.concept&&_.jsx("div",{className:"read-sm mt-2 font-medium",children:a.concept}),_.jsx("p",{className:"mt-2 text-xs text-muted",children:"Click a hole to jump to it. Write the code it needs; pseudo-code is fine if the logic is right."})]}),_.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-auto p-3",children:[((tl=a.review)==null?void 0:tl.summary)&&_.jsx("div",{className:"rounded border border-accent/25 bg-accent/5 p-3 text-sm",children:a.review.summary}),c.map(R=>{const re=x[R.id]??0,ce=ne(R.id);return _.jsxs("div",{role:"button",tabIndex:0,onClick:()=>xe(R),onKeyDown:Ct=>Ct.key==="Enter"&&xe(R),className:Vs("card cursor-pointer p-3 transition hover:border-accent/50",w===R.id&&"border-accent ring-1 ring-accent/40",ce&&(ce.verdict==="right"?"border-good/40":ce.verdict==="partial"?"border-warn/40":"border-bad/40")),children:[_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsxs("span",{className:"rounded-sm bg-warn/15 px-1.5 py-0.5 font-mono text-[12px] font-semibold text-warn",children:["HOLE ",R.id]}),_.jsxs("span",{className:"min-w-0 truncate font-mono text-[11.5px] text-muted",title:t(R.file),children:[t(R.file).split("/").pop(),":",R.startLine]}),ce&&_.jsx("span",{className:"ml-auto",children:_.jsx(Ru,{v:ce.verdict})})]}),_.jsx("p",{className:"read-sm mt-2",children:R.intent}),R.hints.slice(0,re).map((Ct,jt)=>_.jsxs("div",{className:"mt-2 flex gap-2 rounded bg-raised px-2.5 py-1.5 text-[13px]",children:[_.jsx(Iu,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn"})," ",Ct]},jt)),re<R.hints.length&&_.jsxs("button",{className:"mt-2 text-xs font-medium text-accent hover:underline",onClick:Ct=>{Ct.stopPropagation(),A(jt=>({...jt,[R.id]:re+1}))},children:[re===0?"Show a hint":"Another hint"," (",re,"/",R.hints.length,")"]}),(ce==null?void 0:ce.feedback)&&_.jsx("p",{className:"mt-2 border-t border-line pt-2 text-[13px] text-muted",children:ce.feedback})]},R.id)})]}),_.jsxs("div",{className:"space-y-2 border-t border-line p-3",children:[o.busy&&o.job&&_.jsx(Bu,{kind:"review",elapsed:o.elapsed}),o.error&&_.jsx(Nu,{error:o.error,onClose:o.clearError}),_.jsx(wn,{variant:"primary",size:"lg",className:"w-full",icon:_.jsx(Vu,{className:"h-4 w-4"}),loading:o.busy,onClick:Je,children:"Check my work"}),_.jsxs("div",{className:"grid grid-cols-3 gap-2 [&>button]:whitespace-nowrap",children:[_.jsx(wn,{size:"sm",icon:S?_.jsx(Ku,{className:"h-3.5 w-3.5"}):_.jsx(Wu,{className:"h-3.5 w-3.5"}),onClick:()=>M(R=>!R),children:S?"Hide original":"Show original"}),_.jsx(wn,{size:"sm",icon:_.jsx(Fu,{className:"h-3.5 w-3.5"}),title:"Put every hole back",onClick:ye,children:"Start over"}),_.jsx(wn,{size:"sm",variant:"danger",icon:_.jsx(ju,{className:"h-3.5 w-3.5"}),title:"Move this practice to the archive",onClick:async()=>{await Hu(`/projects/${e.id}/practice/${a.id}`),s(`/p/${e.id}/library`)},children:"Archive"})]})]})]}),xu=S?_.jsx(Ws,{id:"practice-orig",side:"right",initial:520,min:300,max:1e3,left:yt,right:Ht}):yt;return _.jsx(Ws,{id:"practice-holes",side:"right",collapsible:!0,initial:380,min:300,max:560,className:"h-full",left:_.jsx(Ws,{id:"practice-files",collapsible:!0,initial:230,min:170,max:420,left:Ye,right:xu}),right:vn})}function Kb(n){var i;const e=((i=n.split(".").pop())==null?void 0:i.toLowerCase())??"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",go:"go",rs:"rust",java:"java",rb:"ruby",sh:"bash",sql:"sql",yml:"yaml",yaml:"yaml",json:"json",md:"markdown",cs:"csharp",kt:"kotlin"}[e]??"text"}const r1=Object.freeze(Object.defineProperty({__proto__:null,PracticePage:$b},Symbol.toStringTag,{value:"Module"}));export{K as A,Gt as B,eu as C,ag as D,D as E,y as F,Si as G,m0 as H,G as I,Lg as J,r1 as K,io as L,Oo as N,Vc as P,te as T,Rg as a,n1 as b,t1 as c,py as d,Se as e,$g as f,i1 as g,v as h,$c as i,Zb as j,Le as k,q as l,e1 as m,s1 as n,Yb as o,Xb as p,je as q,Mi as r,Mg as s,k as t,Wt as u,dn as v,$e as w,pn as x,qg as y,zc as z};
|