@nocobase/app 1.9.0-beta.8 → 2.0.0-alpha.10

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.
Files changed (135) hide show
  1. package/dist/client/113.736e29a0.async.js +7 -0
  2. package/dist/client/1145.0351040a.async.js +3 -0
  3. package/dist/client/1161.0b3b5766.async.js +40 -0
  4. package/dist/client/1442.be509f94.async.js +5 -0
  5. package/dist/client/1595.1827ce7f.async.js +45 -0
  6. package/dist/client/1758.eeeacf43.async.js +5 -0
  7. package/dist/client/1883.6ee256ab.async.js +17 -0
  8. package/dist/client/1905.ff0793ff.async.js +12 -0
  9. package/dist/client/2042.feb4b9ac.async.js +10 -0
  10. package/dist/client/2097.5a49892c.async.js +12 -0
  11. package/dist/client/2190.4f5395e5.async.js +3 -0
  12. package/dist/client/2380.900b7a22.async.js +15 -0
  13. package/dist/client/2612.0865e67e.async.js +19 -0
  14. package/dist/client/2775.455c3402.async.js +47 -0
  15. package/dist/client/2936.902710e4.async.js +28 -0
  16. package/dist/client/3357.be95167c.async.js +28 -0
  17. package/dist/client/341.fba65e23.async.js +28 -0
  18. package/dist/client/3451.a9466e73.async.js +24 -0
  19. package/dist/client/4327.68c0f17b.async.js +16 -0
  20. package/dist/client/4351.efe05af2.async.js +15 -0
  21. package/dist/client/4666.fb83d11a.async.js +9 -0
  22. package/dist/client/4727.0f6df8fb.async.js +1 -0
  23. package/dist/client/4750.044f647b.async.js +32 -0
  24. package/dist/client/4926.58238954.async.js +17 -0
  25. package/dist/client/5013.b14730ba.async.js +3 -0
  26. package/dist/client/5501.22d50b3a.async.js +23 -0
  27. package/dist/client/5662.8c643e63.async.js +26 -0
  28. package/dist/client/5950.179a885e.async.js +4 -0
  29. package/dist/client/6021.cdefa0d3.async.js +22 -0
  30. package/dist/client/645.ea6376fe.async.js +60 -0
  31. package/dist/client/6474.49632e37.async.js +21 -0
  32. package/dist/client/6534.6ea6468b.async.js +33 -0
  33. package/dist/client/6747.de538558.async.js +22 -0
  34. package/dist/client/689.4de33d65.async.js +3 -0
  35. package/dist/client/6920.497d7e80.async.js +59 -0
  36. package/dist/client/6996.ae27c9d6.async.js +9 -0
  37. package/dist/client/703.20003a5c.async.js +17 -0
  38. package/dist/client/7087.5646e199.async.js +6 -0
  39. package/dist/client/7197.bb3092b2.async.js +35 -0
  40. package/dist/client/7482.3924bcd9.async.js +1 -0
  41. package/dist/client/7483.546ddcb6.async.js +23 -0
  42. package/dist/client/7534.0d69e071.async.js +34 -0
  43. package/dist/client/816.b71d5e67.async.js +1 -0
  44. package/dist/client/8183.4c6f7e21.async.js +12 -0
  45. package/dist/client/8408.c0ef773c.async.js +84 -0
  46. package/dist/client/8805.819c4f44.async.js +20 -0
  47. package/dist/client/9017.4ae5c322.async.js +6 -0
  48. package/dist/client/9042.3d21f631.async.js +45 -0
  49. package/dist/client/908.0e8c8a54.async.js +14 -0
  50. package/dist/client/9317.fe6ffa9a.async.js +13 -0
  51. package/dist/client/935.97d45ffa.async.js +27 -0
  52. package/dist/client/95.24aa76c4.async.js +6 -0
  53. package/dist/client/9547.a442df93.async.js +25 -0
  54. package/dist/client/9801.34b13a74.async.js +9 -0
  55. package/dist/client/9844.6f484975.async.js +37 -0
  56. package/dist/client/index.html +1 -1
  57. package/dist/client/index.html.tpl +1 -1
  58. package/dist/client/npm._at_ant-design.c2d0554a.async.js +141 -0
  59. package/dist/client/npm._at_babel.94b2dd75.async.js +3 -0
  60. package/dist/client/npm._at_codemirror.23366286.async.js +26 -0
  61. package/dist/client/npm._at_floating-ui.c19fd4ef.async.js +1 -0
  62. package/dist/client/npm._at_formily.7785699b.async.js +96 -0
  63. package/dist/client/npm._at_lezer.8e7184b5.async.js +2 -0
  64. package/dist/client/npm._at_rc-component.fcc6d966.async.js +8 -0
  65. package/dist/client/npm._at_react-spring.2682ca90.async.js +1 -0
  66. package/dist/client/npm._at_umijs.f64c1387.async.js +7 -0
  67. package/dist/client/npm._at_use-gesture.c2876964.async.js +1 -0
  68. package/dist/client/npm.acorn.1f389fab.async.js +6 -0
  69. package/dist/client/npm.ahooks.9a89c2a5.async.js +6 -0
  70. package/dist/client/npm.antd-mobile-icons.4b133b6b.async.js +1 -0
  71. package/dist/client/npm.antd-mobile.1a8a8320.async.js +2 -0
  72. package/dist/client/npm.antd.acf65d87.async.js +935 -0
  73. package/dist/client/npm.async-validator.32d9020f.async.js +12 -0
  74. package/dist/client/{npm.d3-selection.15d6ab5b.async.js → npm.d3-selection.605ec083.async.js} +1 -1
  75. package/dist/client/{npm.d3-transition.5fd82a9c.async.js → npm.d3-transition.1d02fe5d.async.js} +1 -1
  76. package/dist/client/{npm.dayjs.45ed1676.async.js → npm.dayjs.549164ec.async.js} +1 -1
  77. package/dist/client/npm.dompurify.2dcd638d.async.js +2 -0
  78. package/dist/client/{npm.entities.8159ac3e.async.js → npm.entities.536e25f7.async.js} +1 -1
  79. package/dist/client/{npm.highlight.js.f727dfe3.async.js → npm.highlight.js.d3beb708.async.js} +2 -2
  80. package/dist/client/{npm.htmlparser2.1a3babb6.async.js → npm.htmlparser2.ee1fb042.async.js} +1 -1
  81. package/dist/client/npm.joi.0be0ffb8.async.js +1 -0
  82. package/dist/client/npm.lodash-es.d3d83c5d.async.js +1 -0
  83. package/dist/client/{npm.lodash.5dcc1c5e.async.js → npm.lodash.0ff318b3.async.js} +2 -2
  84. package/dist/client/{npm.markdown-it.5b35f93d.async.js → npm.markdown-it.9eced26c.async.js} +1 -1
  85. package/dist/client/npm.mermaid.91e7e45d.async.js +1556 -0
  86. package/dist/client/npm.rc-cascader.641db835.async.js +4 -0
  87. package/dist/client/npm.rc-field-form.6a3cf561.async.js +1 -0
  88. package/dist/client/npm.rc-image.500705f3.async.js +1 -0
  89. package/dist/client/npm.rc-menu.623f9c7e.async.js +1 -0
  90. package/dist/client/npm.rc-picker.baba6981.async.js +22 -0
  91. package/dist/client/npm.rc-select.34fc277e.async.js +3 -0
  92. package/dist/client/npm.rc-slider.a10210c6.async.js +1 -0
  93. package/dist/client/npm.rc-table.ffbc8feb.async.js +22 -0
  94. package/dist/client/npm.rc-tree-select.866d1acb.async.js +5 -0
  95. package/dist/client/npm.rc-tree.c1d5eac5.async.js +1 -0
  96. package/dist/client/npm.rc-util.4aa445e4.async.js +35 -0
  97. package/dist/client/{npm.react-router-dom.2109af81.async.js → npm.react-router-dom.c4482ef7.async.js} +1 -1
  98. package/dist/client/npm.ses.94a6543e.async.js +29 -0
  99. package/dist/client/npm.slate-react.ef6881ab.async.js +15 -0
  100. package/dist/client/npm.slate.44c32547.async.js +1 -0
  101. package/dist/client/npm.unknown.1838c8f4.chunk.css +1 -0
  102. package/dist/client/npm.util.9c956416.async.js +10 -0
  103. package/dist/client/p__index.1c738231.async.js +2272 -0
  104. package/dist/client/p__index.1f505ad4.chunk.css +1 -0
  105. package/dist/client/umi.822db02d.js +63 -0
  106. package/lib/config/cache.d.ts +2 -11
  107. package/lib/config/cache.js +3 -2
  108. package/lib/config/index.d.ts +2 -21
  109. package/lib/config/index.js +3 -0
  110. package/package.json +6 -6
  111. package/src/config/cache.ts +5 -4
  112. package/src/config/index.ts +5 -1
  113. package/dist/client/6858.082255a5.async.js +0 -59
  114. package/dist/client/npm._at_ant-design.5b9b3ce7.async.js +0 -141
  115. package/dist/client/npm._at_formily.f71b1c62.async.js +0 -96
  116. package/dist/client/npm._at_rc-component.5f4cc5e2.async.js +0 -8
  117. package/dist/client/npm._at_umijs.7f6c4722.async.js +0 -7
  118. package/dist/client/npm.ahooks.c5b165dc.async.js +0 -6
  119. package/dist/client/npm.antd.168d1e29.async.js +0 -464
  120. package/dist/client/npm.dompurify.2ca7a7c6.async.js +0 -3
  121. package/dist/client/npm.elkjs.f35a7d45.async.js +0 -26
  122. package/dist/client/npm.lodash-es.99877438.async.js +0 -1
  123. package/dist/client/npm.mermaid.b398414f.async.js +0 -1529
  124. package/dist/client/npm.rc-cascader.cf6ec555.async.js +0 -4
  125. package/dist/client/npm.rc-image.d550fa79.async.js +0 -1
  126. package/dist/client/npm.rc-menu.da4ef0ce.async.js +0 -1
  127. package/dist/client/npm.rc-picker.89eafb74.async.js +0 -22
  128. package/dist/client/npm.rc-select.44fb85b4.async.js +0 -3
  129. package/dist/client/npm.rc-slider.d2d511ab.async.js +0 -1
  130. package/dist/client/npm.rc-table.c5aa8a0d.async.js +0 -22
  131. package/dist/client/npm.rc-tree-select.5597dcbf.async.js +0 -5
  132. package/dist/client/npm.rc-tree.49888c60.async.js +0 -1
  133. package/dist/client/p__index.15474ef0.async.js +0 -1685
  134. package/dist/client/p__index.e4a52407.chunk.css +0 -1
  135. package/dist/client/umi.cb68cc62.js +0 -63
@@ -0,0 +1,26 @@
1
+ "use strict";(self.webpackChunknocobase=self.webpackChunknocobase||[]).push([[7436],{34790:function(pn,Ni,it){it.d(Ni,{B1:function(){return $e},GA:function(){return o},Gn:function(){return ge},Mb:function(){return Nt},TK:function(){return Oe},eC:function(){return Kt},vQ:function(){return Xi},ys:function(){return ze}});var T=it(78120),re=it(47421),te=it(59119);class Oe{constructor(y,x,L,I){this.state=y,this.pos=x,this.explicit=L,this.view=I,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(y){let x=(0,te.qz)(this.state).resolveInner(this.pos,-1);for(;x&&y.indexOf(x.name)<0;)x=x.parent;return x?{from:x.from,to:this.pos,text:this.state.sliceDoc(x.from,this.pos),type:x.type}:null}matchBefore(y){let x=this.state.doc.lineAt(this.pos),L=Math.max(x.from,this.pos-250),I=x.text.slice(L-x.from,this.pos-x.from),G=I.search(Rt(y,!1));return G<0?null:{from:L+G,to:this.pos,text:I.slice(G)}}get aborted(){return this.abortListeners==null}addEventListener(y,x,L){y=="abort"&&this.abortListeners&&(this.abortListeners.push(x),L&&L.onDocChange&&(this.abortOnDocChange=!0))}}function ut(P){let y=Object.keys(P).join(""),x=/\w/.test(y);return x&&(y=y.replace(/\w/g,"")),`[${x?"\\w":""}${y.replace(/[^\w\s]/g,"\\$&")}]`}function Lt(P){let y=Object.create(null),x=Object.create(null);for(let{label:I}of P){y[I[0]]=!0;for(let G=1;G<I.length;G++)x[I[G]]=!0}let L=ut(y)+ut(x)+"*$";return[new RegExp("^"+L),new RegExp(L)]}function Nt(P){let y=P.map(I=>typeof I=="string"?{label:I}:I),[x,L]=y.every(I=>/^\w+$/.test(I.label))?[/\w*$/,/\w+$/]:Lt(y);return I=>{let G=I.matchBefore(L);return G||I.explicit?{from:G?G.from:I.pos,options:y,validFor:x}:null}}function Jt(P,y){return x=>{for(let L=syntaxTree(x.state).resolveInner(x.pos,-1);L;L=L.parent){if(P.indexOf(L.name)>-1)return y(x);if(L.type.isTop)break}return null}}function Kt(P,y){return x=>{for(let L=(0,te.qz)(x.state).resolveInner(x.pos,-1);L;L=L.parent){if(P.indexOf(L.name)>-1)return null;if(L.type.isTop)break}return y(x)}}class St{constructor(y,x,L,I){this.completion=y,this.source=x,this.match=L,this.score=I}}function Dt(P){return P.selection.main.from}function Rt(P,y){var x;let{source:L}=P,I=y&&L[0]!="^",G=L[L.length-1]!="$";return!I&&!G?P:new RegExp(`${I?"^":""}(?:${L})${G?"$":""}`,(x=P.flags)!==null&&x!==void 0?x:P.ignoreCase?"i":"")}const Ze=T.q6.define();function wi(P,y,x,L){let{main:I}=P.selection,G=x-I.from,oe=L-I.from;return Object.assign(Object.assign({},P.changeByRange(de=>{if(de!=I&&x!=L&&P.sliceDoc(de.from+G,de.from+oe)!=P.sliceDoc(x,L))return{range:de};let fe=P.toText(y);return{changes:{from:de.from+G,to:L==I.from?de.to:de.from+oe,insert:fe},range:T.jT.cursor(de.from+G+fe.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const Ut=new WeakMap;function Ai(P){if(!Array.isArray(P))return P;let y=Ut.get(P);return y||Ut.set(P,y=Nt(P)),y}const pi=T.Py.define(),mi=T.Py.define();class Gt{constructor(y){this.pattern=y,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let x=0;x<y.length;){let L=(0,T.gm)(y,x),I=(0,T.nZ)(L);this.chars.push(L);let G=y.slice(x,x+I),oe=G.toUpperCase();this.folded.push((0,T.gm)(oe==G?G.toLowerCase():oe,0)),x+=I}this.astral=y.length!=this.chars.length}ret(y,x){return this.score=y,this.matched=x,this}match(y){if(this.pattern.length==0)return this.ret(-100,[]);if(y.length<this.pattern.length)return null;let{chars:x,folded:L,any:I,precise:G,byWord:oe}=this;if(x.length==1){let Qt=(0,T.gm)(y,0),Vi=(0,T.nZ)(Qt),Bi=Vi==y.length?0:-100;if(Qt!=x[0])if(Qt==L[0])Bi+=-200;else return null;return this.ret(Bi,[0,Vi])}let de=y.indexOf(this.pattern);if(de==0)return this.ret(y.length==this.pattern.length?0:-100,[0,this.pattern.length]);let fe=x.length,Me=0;if(de<0){for(let Qt=0,Vi=Math.min(y.length,200);Qt<Vi&&Me<fe;){let Bi=(0,T.gm)(y,Qt);(Bi==x[Me]||Bi==L[Me])&&(I[Me++]=Qt),Qt+=(0,T.nZ)(Bi)}if(Me<fe)return null}let Ce=0,_e=0,wt=!1,Wt=0,li=-1,yi=-1,Di=/[a-z]/.test(y),xi=!0;for(let Qt=0,Vi=Math.min(y.length,200),Bi=0;Qt<Vi&&_e<fe;){let Ri=(0,T.gm)(y,Qt);de<0&&(Ce<fe&&Ri==x[Ce]&&(G[Ce++]=Qt),Wt<fe&&(Ri==x[Wt]||Ri==L[Wt]?(Wt==0&&(li=Qt),yi=Qt+1,Wt++):Wt=0));let Zi,A=Ri<255?Ri>=48&&Ri<=57||Ri>=97&&Ri<=122?2:Ri>=65&&Ri<=90?1:0:(Zi=(0,T.bg)(Ri))!=Zi.toLowerCase()?1:Zi!=Zi.toUpperCase()?2:0;(!Qt||A==1&&Di||Bi==0&&A!=0)&&(x[_e]==Ri||L[_e]==Ri&&(wt=!0)?oe[_e++]=Qt:oe.length&&(xi=!1)),Bi=A,Qt+=(0,T.nZ)(Ri)}return _e==fe&&oe[0]==0&&xi?this.result(-100+(wt?-200:0),oe,y):Wt==fe&&li==0?this.ret(-200-y.length+(yi==y.length?0:-100),[0,yi]):de>-1?this.ret(-700-y.length,[de,de+this.pattern.length]):Wt==fe?this.ret(-200+-700-y.length,[li,yi]):_e==fe?this.result(-100+(wt?-200:0)+-700+(xi?0:-1100),oe,y):x.length==2?null:this.result((I[0]?-700:0)+-200+-1100,I,y)}result(y,x,L){let I=[],G=0;for(let oe of x){let de=oe+(this.astral?(0,T.nZ)((0,T.gm)(L,oe)):1);G&&I[G-1]==oe?I[G-1]=de:(I[G++]=oe,I[G++]=de)}return this.ret(y-L.length,I)}}class Ft{constructor(y){this.pattern=y,this.matched=[],this.score=0,this.folded=y.toLowerCase()}match(y){if(y.length<this.pattern.length)return null;let x=y.slice(0,this.pattern.length),L=x==this.pattern?0:x.toLowerCase()==this.folded?-200:null;return L==null?null:(this.matched=[0,x.length],this.score=L+(y.length==this.pattern.length?0:-100),this)}}const Tt=T.r$.define({combine(P){return(0,T.BO)(P,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:We,filterStrict:!1,compareCompletions:(y,x)=>y.label.localeCompare(x.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(y,x)=>y&&x,closeOnBlur:(y,x)=>y&&x,icons:(y,x)=>y&&x,tooltipClass:(y,x)=>L=>et(y(L),x(L)),optionClass:(y,x)=>L=>et(y(L),x(L)),addToOptions:(y,x)=>y.concat(x),filterStrict:(y,x)=>y||x})}});function et(P,y){return P?y?P+" "+y:P:y}function We(P,y,x,L,I,G){let oe=P.textDirection==re.Nm.RTL,de=oe,fe=!1,Me="top",Ce,_e,wt=y.left-I.left,Wt=I.right-y.right,li=L.right-L.left,yi=L.bottom-L.top;if(de&&wt<Math.min(li,Wt)?de=!1:!de&&Wt<Math.min(li,wt)&&(de=!0),li<=(de?wt:Wt))Ce=Math.max(I.top,Math.min(x.top,I.bottom-yi))-y.top,_e=Math.min(400,de?wt:Wt);else{fe=!0,_e=Math.min(400,(oe?y.right:I.right-y.left)-30);let Qt=I.bottom-y.bottom;Qt>=yi||Qt>y.top?Ce=x.bottom-y.top:(Me="bottom",Ce=y.bottom-x.top)}let Di=(y.bottom-y.top)/G.offsetHeight,xi=(y.right-y.left)/G.offsetWidth;return{style:`${Me}: ${Ce/Di}px; max-width: ${_e/xi}px`,class:"cm-completionInfo-"+(fe?oe?"left-narrow":"right-narrow":de?"left":"right")}}function ht(P){let y=P.addToOptions.slice();return P.icons&&y.push({render(x){let L=document.createElement("div");return L.classList.add("cm-completionIcon"),x.type&&L.classList.add(...x.type.split(/\s+/g).map(I=>"cm-completionIcon-"+I)),L.setAttribute("aria-hidden","true"),L},position:20}),y.push({render(x,L,I,G){let oe=document.createElement("span");oe.className="cm-completionLabel";let de=x.displayLabel||x.label,fe=0;for(let Me=0;Me<G.length;){let Ce=G[Me++],_e=G[Me++];Ce>fe&&oe.appendChild(document.createTextNode(de.slice(fe,Ce)));let wt=oe.appendChild(document.createElement("span"));wt.appendChild(document.createTextNode(de.slice(Ce,_e))),wt.className="cm-completionMatchedText",fe=_e}return fe<de.length&&oe.appendChild(document.createTextNode(de.slice(fe))),oe},position:50},{render(x){if(!x.detail)return null;let L=document.createElement("span");return L.className="cm-completionDetail",L.textContent=x.detail,L},position:80}),y.sort((x,L)=>x.position-L.position).map(x=>x.render)}function Je(P,y,x){if(P<=x)return{from:0,to:P};if(y<0&&(y=0),y<=P>>1){let I=Math.floor(y/x);return{from:I*x,to:(I+1)*x}}let L=Math.floor((P-y)/x);return{from:P-(L+1)*x,to:P-L*x}}class di{constructor(y,x,L){this.view=y,this.stateField=x,this.applyCompletion=L,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:fe=>this.placeInfo(fe),key:this},this.space=null,this.currentClass="";let I=y.state.field(x),{options:G,selected:oe}=I.open,de=y.state.facet(Tt);this.optionContent=ht(de),this.optionClass=de.optionClass,this.tooltipClass=de.tooltipClass,this.range=Je(G.length,oe,de.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(y.state),this.dom.addEventListener("mousedown",fe=>{let{options:Me}=y.state.field(x).open;for(let Ce=fe.target,_e;Ce&&Ce!=this.dom;Ce=Ce.parentNode)if(Ce.nodeName=="LI"&&(_e=/-(\d+)$/.exec(Ce.id))&&+_e[1]<Me.length){this.applyCompletion(y,Me[+_e[1]]),fe.preventDefault();return}}),this.dom.addEventListener("focusout",fe=>{let Me=y.state.field(this.stateField,!1);Me&&Me.tooltip&&y.state.facet(Tt).closeOnBlur&&fe.relatedTarget!=y.contentDOM&&y.dispatch({effects:mi.of(null)})}),this.showOptions(G,I.id)}mount(){this.updateSel()}showOptions(y,x){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(y,x,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(y){var x;let L=y.state.field(this.stateField),I=y.startState.field(this.stateField);if(this.updateTooltipClass(y.state),L!=I){let{options:G,selected:oe,disabled:de}=L.open;(!I.open||I.open.options!=G)&&(this.range=Je(G.length,oe,y.state.facet(Tt).maxRenderedOptions),this.showOptions(G,L.id)),this.updateSel(),de!=((x=I.open)===null||x===void 0?void 0:x.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!de)}}updateTooltipClass(y){let x=this.tooltipClass(y);if(x!=this.currentClass){for(let L of this.currentClass.split(" "))L&&this.dom.classList.remove(L);for(let L of x.split(" "))L&&this.dom.classList.add(L);this.currentClass=x}}positioned(y){this.space=y,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let y=this.view.state.field(this.stateField),x=y.open;if((x.selected>-1&&x.selected<this.range.from||x.selected>=this.range.to)&&(this.range=Je(x.options.length,x.selected,this.view.state.facet(Tt).maxRenderedOptions),this.showOptions(x.options,y.id)),this.updateSelectedOption(x.selected)){this.destroyInfo();let{completion:L}=x.options[x.selected],{info:I}=L;if(!I)return;let G=typeof I=="string"?document.createTextNode(I):I(L);if(!G)return;"then"in G?G.then(oe=>{oe&&this.view.state.field(this.stateField,!1)==y&&this.addInfoPane(oe,L)}).catch(oe=>(0,re.OO)(this.view.state,oe,"completion info")):this.addInfoPane(G,L)}}addInfoPane(y,x){this.destroyInfo();let L=this.info=document.createElement("div");if(L.className="cm-tooltip cm-completionInfo",y.nodeType!=null)L.appendChild(y),this.infoDestroy=null;else{let{dom:I,destroy:G}=y;L.appendChild(I),this.infoDestroy=G||null}this.dom.appendChild(L),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(y){let x=null;for(let L=this.list.firstChild,I=this.range.from;L;L=L.nextSibling,I++)L.nodeName!="LI"||!L.id?I--:I==y?L.hasAttribute("aria-selected")||(L.setAttribute("aria-selected","true"),x=L):L.hasAttribute("aria-selected")&&L.removeAttribute("aria-selected");return x&&Xt(this.list,x),x}measureInfo(){let y=this.dom.querySelector("[aria-selected]");if(!y||!this.info)return null;let x=this.dom.getBoundingClientRect(),L=this.info.getBoundingClientRect(),I=y.getBoundingClientRect(),G=this.space;if(!G){let oe=this.dom.ownerDocument.documentElement;G={left:0,top:0,right:oe.clientWidth,bottom:oe.clientHeight}}return I.top>Math.min(G.bottom,x.bottom)-10||I.bottom<Math.max(G.top,x.top)+10?null:this.view.state.facet(Tt).positionInfo(this.view,x,I,L,G,this.dom)}placeInfo(y){this.info&&(y?(y.style&&(this.info.style.cssText=y.style),this.info.className="cm-tooltip cm-completionInfo "+(y.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(y,x,L){const I=document.createElement("ul");I.id=x,I.setAttribute("role","listbox"),I.setAttribute("aria-expanded","true"),I.setAttribute("aria-label",this.view.state.phrase("Completions")),I.addEventListener("mousedown",oe=>{oe.target==I&&oe.preventDefault()});let G=null;for(let oe=L.from;oe<L.to;oe++){let{completion:de,match:fe}=y[oe],{section:Me}=de;if(Me){let wt=typeof Me=="string"?Me:Me.name;if(wt!=G&&(oe>L.from||L.from==0))if(G=wt,typeof Me!="string"&&Me.header)I.appendChild(Me.header(Me));else{let Wt=I.appendChild(document.createElement("completion-section"));Wt.textContent=wt}}const Ce=I.appendChild(document.createElement("li"));Ce.id=x+"-"+oe,Ce.setAttribute("role","option");let _e=this.optionClass(de);_e&&(Ce.className=_e);for(let wt of this.optionContent){let Wt=wt(de,this.view.state,this.view,fe);Wt&&Ce.appendChild(Wt)}}return L.from&&I.classList.add("cm-completionListIncompleteTop"),L.to<y.length&&I.classList.add("cm-completionListIncompleteBottom"),I}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function ki(P,y){return x=>new di(x,P,y)}function Xt(P,y){let x=P.getBoundingClientRect(),L=y.getBoundingClientRect(),I=x.height/P.offsetHeight;L.top<x.top?P.scrollTop-=(x.top-L.top)/I:L.bottom>x.bottom&&(P.scrollTop+=(L.bottom-x.bottom)/I)}function si(P){return(P.boost||0)*100+(P.apply?10:0)+(P.info?5:0)+(P.type?1:0)}function nt(P,y){let x=[],L=null,I=Me=>{x.push(Me);let{section:Ce}=Me.completion;if(Ce){L||(L=[]);let _e=typeof Ce=="string"?Ce:Ce.name;L.some(wt=>wt.name==_e)||L.push(typeof Ce=="string"?{name:_e}:Ce)}},G=y.facet(Tt);for(let Me of P)if(Me.hasResult()){let Ce=Me.result.getMatch;if(Me.result.filter===!1)for(let _e of Me.result.options)I(new St(_e,Me.source,Ce?Ce(_e):[],1e9-x.length));else{let _e=y.sliceDoc(Me.from,Me.to),wt,Wt=G.filterStrict?new Ft(_e):new Gt(_e);for(let li of Me.result.options)if(wt=Wt.match(li.label)){let yi=li.displayLabel?Ce?Ce(li,wt.matched):[]:wt.matched;I(new St(li,Me.source,yi,wt.score+(li.boost||0)))}}}if(L){let Me=Object.create(null),Ce=0,_e=(wt,Wt)=>{var li,yi;return((li=wt.rank)!==null&&li!==void 0?li:1e9)-((yi=Wt.rank)!==null&&yi!==void 0?yi:1e9)||(wt.name<Wt.name?-1:1)};for(let wt of L.sort(_e))Ce-=1e5,Me[wt.name]=Ce;for(let wt of x){let{section:Wt}=wt.completion;Wt&&(wt.score+=Me[typeof Wt=="string"?Wt:Wt.name])}}let oe=[],de=null,fe=G.compareCompletions;for(let Me of x.sort((Ce,_e)=>_e.score-Ce.score||fe(Ce.completion,_e.completion))){let Ce=Me.completion;!de||de.label!=Ce.label||de.detail!=Ce.detail||de.type!=null&&Ce.type!=null&&de.type!=Ce.type||de.apply!=Ce.apply||de.boost!=Ce.boost?oe.push(Me):si(Me.completion)>si(de)&&(oe[oe.length-1]=Me),de=Me.completion}return oe}class kt{constructor(y,x,L,I,G,oe){this.options=y,this.attrs=x,this.tooltip=L,this.timestamp=I,this.selected=G,this.disabled=oe}setSelected(y,x){return y==this.selected||y>=this.options.length?this:new kt(this.options,vi(x,y),this.tooltip,this.timestamp,y,this.disabled)}static build(y,x,L,I,G,oe){if(I&&!oe&&y.some(Me=>Me.isPending))return I.setDisabled();let de=nt(y,x);if(!de.length)return I&&y.some(Me=>Me.isPending)?I.setDisabled():null;let fe=x.facet(Tt).selectOnOpen?0:-1;if(I&&I.selected!=fe&&I.selected!=-1){let Me=I.options[I.selected].completion;for(let Ce=0;Ce<de.length;Ce++)if(de[Ce].completion==Me){fe=Ce;break}}return new kt(de,vi(L,fe),{pos:y.reduce((Me,Ce)=>Ce.hasResult()?Math.min(Me,Ce.from):Me,1e8),create:ei,above:G.aboveCursor},I?I.timestamp:Date.now(),fe,!1)}map(y){return new kt(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:y.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new kt(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ft{constructor(y,x,L){this.active=y,this.id=x,this.open=L}static start(){return new ft(Yt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(y){let{state:x}=y,L=x.facet(Tt),G=(L.override||x.languageDataAt("autocomplete",Dt(x)).map(Ai)).map(fe=>(this.active.find(Ce=>Ce.source==fe)||new Be(fe,this.active.some(Ce=>Ce.state!=0)?1:0)).update(y,L));G.length==this.active.length&&G.every((fe,Me)=>fe==this.active[Me])&&(G=this.active);let oe=this.open,de=y.effects.some(fe=>fe.is(Ye));oe&&y.docChanged&&(oe=oe.map(y.changes)),y.selection||G.some(fe=>fe.hasResult()&&y.changes.touchesRange(fe.from,fe.to))||!It(G,this.active)||de?oe=kt.build(G,x,this.id,oe,L,de):oe&&oe.disabled&&!G.some(fe=>fe.isPending)&&(oe=null),!oe&&G.every(fe=>!fe.isPending)&&G.some(fe=>fe.hasResult())&&(G=G.map(fe=>fe.hasResult()?new Be(fe.source,0):fe));for(let fe of y.effects)fe.is(st)&&(oe=oe&&oe.setSelected(fe.value,this.id));return G==this.active&&oe==this.open?this:new ft(G,this.id,oe)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?$t:Et}}function It(P,y){if(P==y)return!0;for(let x=0,L=0;;){for(;x<P.length&&!P[x].hasResult();)x++;for(;L<y.length&&!y[L].hasResult();)L++;let I=x==P.length,G=L==y.length;if(I||G)return I==G;if(P[x++].result!=y[L++].result)return!1}}const $t={"aria-autocomplete":"list"},Et={};function vi(P,y){let x={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":P};return y>-1&&(x["aria-activedescendant"]=P+"-"+y),x}const Yt=[];function ye(P,y){if(P.isUserEvent("input.complete")){let L=P.annotation(Ze);if(L&&y.activateOnCompletion(L))return 12}let x=P.isUserEvent("input.type");return x&&y.activateOnTyping?5:x?1:P.isUserEvent("delete.backward")?2:P.selection?8:P.docChanged?16:0}class Be{constructor(y,x,L=!1){this.source=y,this.state=x,this.explicit=L}hasResult(){return!1}get isPending(){return this.state==1}update(y,x){let L=ye(y,x),I=this;(L&8||L&16&&this.touches(y))&&(I=new Be(I.source,0)),L&4&&I.state==0&&(I=new Be(this.source,1)),I=I.updateFor(y,L);for(let G of y.effects)if(G.is(pi))I=new Be(I.source,1,G.value);else if(G.is(mi))I=new Be(I.source,0);else if(G.is(Ye))for(let oe of G.value)oe.source==I.source&&(I=oe);return I}updateFor(y,x){return this.map(y.changes)}map(y){return this}touches(y){return y.changes.touchesRange(Dt(y.state))}}class Le extends Be{constructor(y,x,L,I,G,oe){super(y,3,x),this.limit=L,this.result=I,this.from=G,this.to=oe}hasResult(){return!0}updateFor(y,x){var L;if(!(x&3))return this.map(y.changes);let I=this.result;I.map&&!y.changes.empty&&(I=I.map(I,y.changes));let G=y.changes.mapPos(this.from),oe=y.changes.mapPos(this.to,1),de=Dt(y.state);if(de>oe||!I||x&2&&(Dt(y.startState)==this.from||de<this.limit))return new Be(this.source,x&4?1:0);let fe=y.changes.mapPos(this.limit);return Re(I.validFor,y.state,G,oe)?new Le(this.source,this.explicit,fe,I,G,oe):I.update&&(I=I.update(I,G,oe,new Oe(y.state,de,!1)))?new Le(this.source,this.explicit,fe,I,I.from,(L=I.to)!==null&&L!==void 0?L:Dt(y.state)):new Be(this.source,1,this.explicit)}map(y){return y.empty?this:(this.result.map?this.result.map(this.result,y):this.result)?new Le(this.source,this.explicit,y.mapPos(this.limit),this.result,y.mapPos(this.from),y.mapPos(this.to,1)):new Be(this.source,0)}touches(y){return y.changes.touchesRange(this.from,this.to)}}function Re(P,y,x,L){if(!P)return!1;let I=y.sliceDoc(x,L);return typeof P=="function"?P(I,x,L,y):Rt(P,!0).test(I)}const Ye=T.Py.define({map(P,y){return P.map(x=>x.map(y))}}),st=T.Py.define(),Ve=T.QQ.define({create(){return ft.start()},update(P,y){return P.update(y)},provide:P=>[re.hJ.from(P,y=>y.tooltip),re.tk.contentAttributes.from(P,y=>y.attrs)]});function yt(P,y){const x=y.completion.apply||y.completion.label;let L=P.state.field(Ve).active.find(I=>I.source==y.source);return L instanceof Le?(typeof x=="string"?P.dispatch(Object.assign(Object.assign({},wi(P.state,x,L.from,L.to)),{annotations:Ze.of(y.completion)})):x(P,y.completion,L.from,L.to),!0):!1}const ei=ki(Ve,yt);function Ct(P,y="option"){return x=>{let L=x.state.field(Ve,!1);if(!L||!L.open||L.open.disabled||Date.now()-L.open.timestamp<x.state.facet(Tt).interactionDelay)return!1;let I=1,G;y=="page"&&(G=(0,re.gB)(x,L.open.tooltip))&&(I=Math.max(2,Math.floor(G.dom.offsetHeight/G.dom.querySelector("li").offsetHeight)-1));let{length:oe}=L.open.options,de=L.open.selected>-1?L.open.selected+I*(P?1:-1):P?0:oe-1;return de<0?de=y=="page"?0:oe-1:de>=oe&&(de=y=="page"?oe-1:0),x.dispatch({effects:st.of(de)}),!0}}const De=P=>{let y=P.state.field(Ve,!1);return P.state.readOnly||!y||!y.open||y.open.selected<0||y.open.disabled||Date.now()-y.open.timestamp<P.state.facet(Tt).interactionDelay?!1:yt(P,y.open.options[y.open.selected])},zt=P=>P.state.field(Ve,!1)?(P.dispatch({effects:pi.of(!0)}),!0):!1,Bt=P=>{let y=P.state.field(Ve,!1);return!y||!y.active.some(x=>x.state!=0)?!1:(P.dispatch({effects:mi.of(null)}),!0)};class ie{constructor(y,x){this.active=y,this.context=x,this.time=Date.now(),this.updates=[],this.done=void 0}}const X=50,pe=1e3,ae=re.lg.fromClass(class{constructor(P){this.view=P,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let y of P.state.field(Ve).active)y.isPending&&this.startQuery(y)}update(P){let y=P.state.field(Ve),x=P.state.facet(Tt);if(!P.selectionSet&&!P.docChanged&&P.startState.field(Ve)==y)return;let L=P.transactions.some(G=>{let oe=ye(G,x);return oe&8||(G.selection||G.docChanged)&&!(oe&3)});for(let G=0;G<this.running.length;G++){let oe=this.running[G];if(L||oe.context.abortOnDocChange&&P.docChanged||oe.updates.length+P.transactions.length>X&&Date.now()-oe.time>pe){for(let de of oe.context.abortListeners)try{de()}catch(fe){(0,re.OO)(this.view.state,fe)}oe.context.abortListeners=null,this.running.splice(G--,1)}else oe.updates.push(...P.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),P.transactions.some(G=>G.effects.some(oe=>oe.is(pi)))&&(this.pendingStart=!0);let I=this.pendingStart?50:x.activateOnTypingDelay;if(this.debounceUpdate=y.active.some(G=>G.isPending&&!this.running.some(oe=>oe.active.source==G.source))?setTimeout(()=>this.startUpdate(),I):-1,this.composing!=0)for(let G of P.transactions)G.isUserEvent("input.type")?this.composing=2:this.composing==2&&G.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:P}=this.view,y=P.field(Ve);for(let x of y.active)x.isPending&&!this.running.some(L=>L.active.source==x.source)&&this.startQuery(x);this.running.length&&y.open&&y.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Tt).updateSyncTime))}startQuery(P){let{state:y}=this.view,x=Dt(y),L=new Oe(y,x,P.explicit,this.view),I=new ie(P,L);this.running.push(I),Promise.resolve(P.source(L)).then(G=>{I.context.aborted||(I.done=G||null,this.scheduleAccept())},G=>{this.view.dispatch({effects:mi.of(null)}),(0,re.OO)(this.view.state,G)})}scheduleAccept(){this.running.every(P=>P.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Tt).updateSyncTime))}accept(){var P;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let y=[],x=this.view.state.facet(Tt),L=this.view.state.field(Ve);for(let I=0;I<this.running.length;I++){let G=this.running[I];if(G.done===void 0)continue;if(this.running.splice(I--,1),G.done){let de=Dt(G.updates.length?G.updates[0].startState:this.view.state),fe=Math.min(de,G.done.from+(G.active.explicit?0:1)),Me=new Le(G.active.source,G.active.explicit,fe,G.done,G.done.from,(P=G.done.to)!==null&&P!==void 0?P:de);for(let Ce of G.updates)Me=Me.update(Ce,x);if(Me.hasResult()){y.push(Me);continue}}let oe=L.active.find(de=>de.source==G.active.source);if(oe&&oe.isPending)if(G.done==null){let de=new Be(G.active.source,0);for(let fe of G.updates)de=de.update(fe,x);de.isPending||y.push(de)}else this.startQuery(oe)}(y.length||L.open&&L.open.disabled)&&this.view.dispatch({effects:Ye.of(y)})}},{eventHandlers:{blur(P){let y=this.view.state.field(Ve,!1);if(y&&y.tooltip&&this.view.state.facet(Tt).closeOnBlur){let x=y.open&&(0,re.gB)(this.view,y.open.tooltip);(!x||!x.dom.contains(P.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:mi.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:pi.of(!1)}),20),this.composing=0}}}),Ae=typeof navigator=="object"&&/Win/.test(navigator.platform),Fe=T.Wl.highest(re.tk.domEventHandlers({keydown(P,y){let x=y.state.field(Ve,!1);if(!x||!x.open||x.open.disabled||x.open.selected<0||P.key.length>1||P.ctrlKey&&!(Ae&&P.altKey)||P.metaKey)return!1;let L=x.open.options[x.open.selected],I=x.active.find(oe=>oe.source==L.source),G=L.completion.commitCharacters||I.result.commitCharacters;return G&&G.indexOf(P.key)>-1&&yt(y,L),!1}})),Xe=re.tk.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:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class qe{constructor(y,x,L,I){this.field=y,this.line=x,this.from=L,this.to=I}}class dt{constructor(y,x,L){this.field=y,this.from=x,this.to=L}map(y){let x=y.mapPos(this.from,-1,T.gc.TrackDel),L=y.mapPos(this.to,1,T.gc.TrackDel);return x==null||L==null?null:new dt(this.field,x,L)}}class xt{constructor(y,x){this.lines=y,this.fieldPositions=x}instantiate(y,x){let L=[],I=[x],G=y.doc.lineAt(x),oe=/^\s*/.exec(G.text)[0];for(let fe of this.lines){if(L.length){let Me=oe,Ce=/^\t*/.exec(fe)[0].length;for(let _e=0;_e<Ce;_e++)Me+=y.facet(te.c);I.push(x+Me.length-Ce),fe=Me+fe.slice(Ce)}L.push(fe),x+=fe.length+1}let de=this.fieldPositions.map(fe=>new dt(fe.field,I[fe.line]+fe.from,I[fe.line]+fe.to));return{text:L,ranges:de}}static parse(y){let x=[],L=[],I=[],G;for(let oe of y.split(/\r\n?|\n/)){for(;G=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(oe);){let de=G[1]?+G[1]:null,fe=G[2]||G[3]||"",Me=-1,Ce=fe.replace(/\\[{}]/g,_e=>_e[1]);for(let _e=0;_e<x.length;_e++)(de!=null?x[_e].seq==de:Ce&&x[_e].name==Ce)&&(Me=_e);if(Me<0){let _e=0;for(;_e<x.length&&(de==null||x[_e].seq!=null&&x[_e].seq<de);)_e++;x.splice(_e,0,{seq:de,name:Ce}),Me=_e;for(let wt of I)wt.field>=Me&&wt.field++}I.push(new qe(Me,L.length,G.index,G.index+Ce.length)),oe=oe.slice(0,G.index)+fe+oe.slice(G.index+G[0].length)}oe=oe.replace(/\\([{}])/g,(de,fe,Me)=>{for(let Ce of I)Ce.line==L.length&&Ce.from>Me&&(Ce.from--,Ce.to--);return fe}),L.push(oe)}return new xt(L,I)}}let tt=re.p.widget({widget:new class extends re.l9{toDOM(){let P=document.createElement("span");return P.className="cm-snippetFieldPosition",P}ignoreEvent(){return!1}}}),bt=re.p.mark({class:"cm-snippetField"});class At{constructor(y,x){this.ranges=y,this.active=x,this.deco=re.p.set(y.map(L=>(L.from==L.to?tt:bt).range(L.from,L.to)))}map(y){let x=[];for(let L of this.ranges){let I=L.map(y);if(!I)return null;x.push(I)}return new At(x,this.active)}selectionInsideField(y){return y.ranges.every(x=>this.ranges.some(L=>L.field==this.active&&L.from<=x.from&&L.to>=x.to))}}const Ot=T.Py.define({map(P,y){return P&&P.map(y)}}),Ti=T.Py.define(),lt=T.QQ.define({create(){return null},update(P,y){for(let x of y.effects){if(x.is(Ot))return x.value;if(x.is(Ti)&&P)return new At(P.ranges,x.value)}return P&&y.docChanged&&(P=P.map(y.changes)),P&&y.selection&&!P.selectionInsideField(y.selection)&&(P=null),P},provide:P=>re.tk.decorations.from(P,y=>y?y.deco:re.p.none)});function rt(P,y){return T.jT.create(P.filter(x=>x.field==y).map(x=>T.jT.range(x.from,x.to)))}function Mi(P){let y=xt.parse(P);return(x,L,I,G)=>{let{text:oe,ranges:de}=y.instantiate(x.state,I),{main:fe}=x.state.selection,Me={changes:{from:I,to:G==fe.from?fe.to:G,insert:T.xv.of(oe)},scrollIntoView:!0,annotations:L?[Ze.of(L),T.YW.userEvent.of("input.complete")]:void 0};if(de.length&&(Me.selection=rt(de,0)),de.some(Ce=>Ce.field>0)){let Ce=new At(de,0),_e=Me.effects=[Ot.of(Ce)];x.state.field(lt,!1)===void 0&&_e.push(T.Py.appendConfig.of([lt,ee,Pe,Xe]))}x.dispatch(x.state.update(Me))}}function Oi(P){return({state:y,dispatch:x})=>{let L=y.field(lt,!1);if(!L||P<0&&L.active==0)return!1;let I=L.active+P,G=P>0&&!L.ranges.some(oe=>oe.field==I+P);return x(y.update({selection:rt(L.ranges,I),effects:Ot.of(G?null:new At(L.ranges,I)),scrollIntoView:!0})),!0}}const hi=({state:P,dispatch:y})=>P.field(lt,!1)?(y(P.update({effects:Ot.of(null)})),!0):!1,Pi=Oi(1),_i=Oi(-1);function _(P){let y=P.field(lt,!1);return!!(y&&y.ranges.some(x=>x.field==y.active+1))}function E(P){let y=P.field(lt,!1);return!!(y&&y.active>0)}const q=[{key:"Tab",run:Pi,shift:_i},{key:"Escape",run:hi}],K=T.r$.define({combine(P){return P.length?P[0]:q}}),ee=T.Wl.highest(re.$f.compute([K],P=>P.facet(K)));function ge(P,y){return Object.assign(Object.assign({},y),{apply:Mi(P)})}const Pe=re.tk.domEventHandlers({mousedown(P,y){let x=y.state.field(lt,!1),L;if(!x||(L=y.posAtCoords({x:P.clientX,y:P.clientY}))==null)return!1;let I=x.ranges.find(G=>G.from<=L&&G.to>=L);return!I||I.field==x.active?!1:(y.dispatch({selection:rt(x.ranges,I.field),effects:Ot.of(x.ranges.some(G=>G.field>I.field)?new At(x.ranges,I.field):null),scrollIntoView:!0}),!0)}});function Te(P){let y=P.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${y}]+`,"ug")}catch{return new RegExp(`[w${y}]`,"g")}}function je(P,y){return new RegExp(y(P.source),P.unicode?"u":"")}const ot=null;function ti(P){return ot[P]||(ot[P]=new WeakMap)}function ri(P,y,x,L,I){for(let G=P.iterLines(),oe=0;!G.next().done;){let{value:de}=G,fe;for(y.lastIndex=0;fe=y.exec(de);)if(!L[fe[0]]&&oe+fe.index!=I&&(x.push({type:"text",label:fe[0]}),L[fe[0]]=!0,x.length>=2e3))return;oe+=de.length+1}}function ci(P,y,x,L,I){let G=P.length>=1e3,oe=G&&y.get(P);if(oe)return oe;let de=[],fe=Object.create(null);if(P.children){let Me=0;for(let Ce of P.children){if(Ce.length>=1e3)for(let _e of ci(Ce,y,x,L-Me,I-Me))fe[_e.label]||(fe[_e.label]=!0,de.push(_e));else ri(Ce,x,de,fe,I-Me);Me+=Ce.length+1}}else ri(P,x,de,fe,I);return G&&de.length<2e3&&y.set(P,de),de}const fi=P=>{let y=P.state.languageDataAt("wordChars",P.pos).join(""),x=Te(y),L=P.matchBefore(je(x,oe=>oe+"$"));if(!L&&!P.explicit)return null;let I=L?L.from:P.pos,G=ci(P.state.doc,ti(y),x,5e4,I);return{from:I,options:G,validFor:je(x,oe=>"^"+oe)}},qt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},gi=T.Py.define({map(P,y){let x=y.mapPos(P,-1,T.gc.TrackAfter);return x??void 0}}),Li=new class extends T.uU{};Li.startSide=1,Li.endSide=-1;const Ei=T.QQ.define({create(){return T.Xs.empty},update(P,y){if(P=P.map(y.changes),y.selection){let x=y.state.doc.lineAt(y.selection.main.head);P=P.update({filter:L=>L>=x.from&&L<=x.to})}for(let x of y.effects)x.is(gi)&&(P=P.update({add:[Li.range(x.value,x.value+1)]}));return P}});function Xi(){return[oi,Ei]}const Pt="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function Ji(P){for(let y=0;y<Pt.length;y+=2)if(Pt.charCodeAt(y)==P)return Pt.charAt(y+1);return(0,T.bg)(P<128?P:P+1)}function sn(P,y){return P.languageDataAt("closeBrackets",y)[0]||qt}const an=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),oi=re.tk.inputHandler.of((P,y,x,L)=>{if((an?P.composing:P.compositionStarted)||P.state.readOnly)return!1;let I=P.state.selection.main;if(L.length>2||L.length==2&&(0,T.nZ)((0,T.gm)(L,0))==1||y!=I.from||x!=I.to)return!1;let G=a(P.state,L);return G?(P.dispatch(G),!0):!1}),o=[{key:"Backspace",run:({state:P,dispatch:y})=>{if(P.readOnly)return!1;let L=sn(P,P.selection.main.head).brackets||qt.brackets,I=null,G=P.changeByRange(oe=>{if(oe.empty){let de=D(P.doc,oe.head);for(let fe of L)if(fe==de&&w(P.doc,oe.head)==Ji((0,T.gm)(fe,0)))return{changes:{from:oe.head-fe.length,to:oe.head+fe.length},range:T.jT.cursor(oe.head-fe.length)}}return{range:I=oe}});return I||y(P.update(G,{scrollIntoView:!0,userEvent:"delete.backward"})),!I}}];function a(P,y){let x=sn(P,P.selection.main.head),L=x.brackets||qt.brackets;for(let I of L){let G=Ji((0,T.gm)(I,0));if(y==I)return G==I?Y(P,I,L.indexOf(I+I+I)>-1,x):O(P,I,G,x.before||qt.before);if(y==G&&d(P,P.selection.main.from))return H(P,I,G)}return null}function d(P,y){let x=!1;return P.field(Ei).between(0,P.doc.length,L=>{L==y&&(x=!0)}),x}function w(P,y){let x=P.sliceString(y,y+2);return x.slice(0,(0,T.nZ)((0,T.gm)(x,0)))}function D(P,y){let x=P.sliceString(y-2,y);return(0,T.nZ)((0,T.gm)(x,0))==x.length?x:x.slice(1)}function O(P,y,x,L){let I=null,G=P.changeByRange(oe=>{if(!oe.empty)return{changes:[{insert:y,from:oe.from},{insert:x,from:oe.to}],effects:gi.of(oe.to+y.length),range:T.jT.range(oe.anchor+y.length,oe.head+y.length)};let de=w(P.doc,oe.head);return!de||/\s/.test(de)||L.indexOf(de)>-1?{changes:{insert:y+x,from:oe.head},effects:gi.of(oe.head+y.length),range:T.jT.cursor(oe.head+y.length)}:{range:I=oe}});return I?null:P.update(G,{scrollIntoView:!0,userEvent:"input.type"})}function H(P,y,x){let L=null,I=P.changeByRange(G=>G.empty&&w(P.doc,G.head)==x?{changes:{from:G.head,to:G.head+x.length,insert:x},range:T.jT.cursor(G.head+x.length)}:L={range:G});return L?null:P.update(I,{scrollIntoView:!0,userEvent:"input.type"})}function Y(P,y,x,L){let I=L.stringPrefixes||qt.stringPrefixes,G=null,oe=P.changeByRange(de=>{if(!de.empty)return{changes:[{insert:y,from:de.from},{insert:y,from:de.to}],effects:gi.of(de.to+y.length),range:T.jT.range(de.anchor+y.length,de.head+y.length)};let fe=de.head,Me=w(P.doc,fe),Ce;if(Me==y){if(ue(P,fe))return{changes:{insert:y+y,from:fe},effects:gi.of(fe+y.length),range:T.jT.cursor(fe+y.length)};if(d(P,fe)){let wt=x&&P.sliceDoc(fe,fe+y.length*3)==y+y+y?y+y+y:y;return{changes:{from:fe,to:fe+wt.length,insert:wt},range:T.jT.cursor(fe+wt.length)}}}else{if(x&&P.sliceDoc(fe-2*y.length,fe)==y+y&&(Ce=Ee(P,fe-2*y.length,I))>-1&&ue(P,Ce))return{changes:{insert:y+y+y+y,from:fe},effects:gi.of(fe+y.length),range:T.jT.cursor(fe+y.length)};if(P.charCategorizer(fe)(Me)!=T.D0.Word&&Ee(P,fe,I)>-1&&!ve(P,fe,y,I))return{changes:{insert:y+y,from:fe},effects:gi.of(fe+y.length),range:T.jT.cursor(fe+y.length)}}return{range:G=de}});return G?null:P.update(oe,{scrollIntoView:!0,userEvent:"input.type"})}function ue(P,y){let x=(0,te.qz)(P).resolveInner(y+1);return x.parent&&x.from==y}function ve(P,y,x,L){let I=(0,te.qz)(P).resolveInner(y,-1),G=L.reduce((oe,de)=>Math.max(oe,de.length),0);for(let oe=0;oe<5;oe++){let de=P.sliceDoc(I.from,Math.min(I.to,I.from+x.length+G)),fe=de.indexOf(x);if(!fe||fe>-1&&L.indexOf(de.slice(0,fe))>-1){let Ce=I.firstChild;for(;Ce&&Ce.from==I.from&&Ce.to-Ce.from>x.length+fe;){if(P.sliceDoc(Ce.to-x.length,Ce.to)==x)return!1;Ce=Ce.firstChild}return!0}let Me=I.to==y&&I.parent;if(!Me)break;I=Me}return!1}function Ee(P,y,x){let L=P.charCategorizer(y);if(L(P.sliceDoc(y-1,y))!=T.D0.Word)return y;for(let I of x){let G=y-I.length;if(P.sliceDoc(G,y)==I&&L(P.sliceDoc(G-1,G))!=T.D0.Word)return G}return-1}function ze(P={}){return[Fe,Ve,Tt.of(P),ae,jt,Xe]}const $e=[{key:"Ctrl-Space",run:zt},{mac:"Alt-`",run:zt},{key:"Escape",run:Bt},{key:"ArrowDown",run:Ct(!0)},{key:"ArrowUp",run:Ct(!1)},{key:"PageDown",run:Ct(!0,"page")},{key:"PageUp",run:Ct(!1,"page")},{key:"Enter",run:De}],jt=T.Wl.highest(re.$f.computeN([Tt],P=>P.facet(Tt).defaultKeymap?[$e]:[]));function Fi(P){let y=P.field(Ve,!1);return y&&y.active.some(x=>x.isPending)?"pending":y&&y.active.some(x=>x.state!=0)?"active":null}const ii=new WeakMap;function Qi(P){var y;let x=(y=P.field(Ve,!1))===null||y===void 0?void 0:y.open;if(!x||x.disabled)return[];let L=ii.get(x.options);return L||ii.set(x.options,L=x.options.map(I=>I.completion)),L}function Ki(P){var y;let x=(y=P.field(Ve,!1))===null||y===void 0?void 0:y.open;return x&&!x.disabled&&x.selected>=0?x.options[x.selected].completion:null}function Ui(P){var y;let x=(y=P.field(Ve,!1))===null||y===void 0?void 0:y.open;return x&&!x.disabled&&x.selected>=0?x.selected:null}function rn(P){return st.of(P)}},45383:function(pn,Ni,it){it.d(Ni,{f$:function(){return De},m8:function(){return Je},wQ:function(){return Rn}});var T=it(78120),re=it(47421),te=it(59119),Oe=it(41113);const ut=u=>{let{state:S}=u,V=S.doc.lineAt(S.selection.main.from),W=wi(u.state,V.from);return W.line?Nt(u):W.block?Ze(u):!1};function Lt(u,S){return({state:V,dispatch:W})=>{if(V.readOnly)return!1;let Q=u(S,V);return Q?(W(V.update(Q)),!0):!1}}const Nt=Lt(Gt,0),Jt=null,Kt=null,St=Lt(mi,0),Dt=null,Rt=null,Ze=Lt((u,S)=>mi(u,S,pi(S)),0);function wi(u,S){let V=u.languageDataAt("commentTokens",S,1);return V.length?V[0]:{}}const Ut=50;function Ai(u,{open:S,close:V},W,Q){let J=u.sliceDoc(W-Ut,W),ne=u.sliceDoc(Q,Q+Ut),Se=/\s*$/.exec(J)[0].length,He=/^\s*/.exec(ne)[0].length,vt=J.length-Se;if(J.slice(vt-S.length,vt)==S&&ne.slice(He,He+V.length)==V)return{open:{pos:W-Se,margin:Se&&1},close:{pos:Q+He,margin:He&&1}};let ct,Vt;Q-W<=2*Ut?ct=Vt=u.sliceDoc(W,Q):(ct=u.sliceDoc(W,W+Ut),Vt=u.sliceDoc(Q-Ut,Q));let ni=/^\s*/.exec(ct)[0].length,ai=/\s*$/.exec(Vt)[0].length,ui=Vt.length-ai-V.length;return ct.slice(ni,ni+S.length)==S&&Vt.slice(ui,ui+V.length)==V?{open:{pos:W+ni+S.length,margin:/\s/.test(ct.charAt(ni+S.length))?1:0},close:{pos:Q-ai-V.length,margin:/\s/.test(Vt.charAt(ui-1))?1:0}}:null}function pi(u){let S=[];for(let V of u.selection.ranges){let W=u.doc.lineAt(V.from),Q=V.to<=W.to?W:u.doc.lineAt(V.to);Q.from>W.from&&Q.from==V.to&&(Q=V.to==W.to+1?W:u.doc.lineAt(V.to-1));let J=S.length-1;J>=0&&S[J].to>W.from?S[J].to=Q.to:S.push({from:W.from+/^\s*/.exec(W.text)[0].length,to:Q.to})}return S}function mi(u,S,V=S.selection.ranges){let W=V.map(J=>wi(S,J.from).block);if(!W.every(J=>J))return null;let Q=V.map((J,ne)=>Ai(S,W[ne],J.from,J.to));if(u!=2&&!Q.every(J=>J))return{changes:S.changes(V.map((J,ne)=>Q[ne]?[]:[{from:J.from,insert:W[ne].open+" "},{from:J.to,insert:" "+W[ne].close}]))};if(u!=1&&Q.some(J=>J)){let J=[];for(let ne=0,Se;ne<Q.length;ne++)if(Se=Q[ne]){let He=W[ne],{open:vt,close:ct}=Se;J.push({from:vt.pos-He.open.length,to:vt.pos+vt.margin},{from:ct.pos-ct.margin,to:ct.pos+He.close.length})}return{changes:J}}return null}function Gt(u,S,V=S.selection.ranges){let W=[],Q=-1;for(let{from:J,to:ne}of V){let Se=W.length,He=1e9,vt=wi(S,J).line;if(vt){for(let ct=J;ct<=ne;){let Vt=S.doc.lineAt(ct);if(Vt.from>Q&&(J==ne||ne>Vt.from)){Q=Vt.from;let ni=/^\s*/.exec(Vt.text)[0].length,ai=ni==Vt.length,ui=Vt.text.slice(ni,ni+vt.length)==vt?ni:-1;ni<Vt.text.length&&ni<He&&(He=ni),W.push({line:Vt,comment:ui,token:vt,indent:ni,empty:ai,single:!1})}ct=Vt.to+1}if(He<1e9)for(let ct=Se;ct<W.length;ct++)W[ct].indent<W[ct].line.text.length&&(W[ct].indent=He);W.length==Se+1&&(W[Se].single=!0)}}if(u!=2&&W.some(J=>J.comment<0&&(!J.empty||J.single))){let J=[];for(let{line:Se,token:He,indent:vt,empty:ct,single:Vt}of W)(Vt||!ct)&&J.push({from:Se.from+vt,insert:He+" "});let ne=S.changes(J);return{changes:ne,selection:S.selection.map(ne,1)}}else if(u!=1&&W.some(J=>J.comment>=0)){let J=[];for(let{line:ne,comment:Se,token:He}of W)if(Se>=0){let vt=ne.from+Se,ct=vt+He.length;ne.text[ct-ne.from]==" "&&ct++,J.push({from:vt,to:ct})}return{changes:J}}return null}const Ft=T.q6.define(),Tt=T.q6.define(),et=T.r$.define(),We=T.r$.define({combine(u){return(0,T.BO)(u,{minDepth:100,newGroupDelay:500,joinToEvent:(S,V)=>V},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(S,V)=>(W,Q)=>S(W,Q)||V(W,Q)})}}),ht=T.QQ.define({create(){return Ct.empty},update(u,S){let V=S.state.facet(We),W=S.annotation(Ft);if(W){let He=Et.fromTransaction(S,W.selection),vt=W.side,ct=vt==0?u.undone:u.done;return He?ct=vi(ct,ct.length,V.minDepth,He):ct=Ye(ct,S.startState.selection),new Ct(vt==0?W.rest:ct,vt==0?ct:W.rest)}let Q=S.annotation(Tt);if((Q=="full"||Q=="before")&&(u=u.isolate()),S.annotation(T.YW.addToHistory)===!1)return S.changes.empty?u:u.addMapping(S.changes.desc);let J=Et.fromTransaction(S),ne=S.annotation(T.YW.time),Se=S.annotation(T.YW.userEvent);return J?u=u.addChanges(J,ne,Se,V,S):S.selection&&(u=u.addSelection(S.startState.selection,ne,Se,V.newGroupDelay)),(Q=="full"||Q=="after")&&(u=u.isolate()),u},toJSON(u){return{done:u.done.map(S=>S.toJSON()),undone:u.undone.map(S=>S.toJSON())}},fromJSON(u){return new Ct(u.done.map(Et.fromJSON),u.undone.map(Et.fromJSON))}});function Je(u={}){return[ht,We.of(u),re.tk.domEventHandlers({beforeinput(S,V){let W=S.inputType=="historyUndo"?Xt:S.inputType=="historyRedo"?si:null;return W?(S.preventDefault(),W(V)):!1}})]}const di=null;function ki(u,S){return function({state:V,dispatch:W}){if(!S&&V.readOnly)return!1;let Q=V.field(ht,!1);if(!Q)return!1;let J=Q.pop(u,V,S);return J?(W(J),!0):!1}}const Xt=ki(0,!1),si=ki(1,!1),nt=ki(0,!0),kt=ki(1,!0);function ft(u){return function(S){let V=S.field(ht,!1);if(!V)return 0;let W=u==0?V.done:V.undone;return W.length-(W.length&&!W[0].changes?1:0)}}const It=null,$t=null;class Et{constructor(S,V,W,Q,J){this.changes=S,this.effects=V,this.mapped=W,this.startSelection=Q,this.selectionsAfter=J}setSelAfter(S){return new Et(this.changes,this.effects,this.mapped,this.startSelection,S)}toJSON(){var S,V,W;return{changes:(S=this.changes)===null||S===void 0?void 0:S.toJSON(),mapped:(V=this.mapped)===null||V===void 0?void 0:V.toJSON(),startSelection:(W=this.startSelection)===null||W===void 0?void 0:W.toJSON(),selectionsAfter:this.selectionsAfter.map(Q=>Q.toJSON())}}static fromJSON(S){return new Et(S.changes&&T.as.fromJSON(S.changes),[],S.mapped&&T.n0.fromJSON(S.mapped),S.startSelection&&T.jT.fromJSON(S.startSelection),S.selectionsAfter.map(T.jT.fromJSON))}static fromTransaction(S,V){let W=Le;for(let Q of S.startState.facet(et)){let J=Q(S);J.length&&(W=W.concat(J))}return!W.length&&S.changes.empty?null:new Et(S.changes.invert(S.startState.doc),W,void 0,V||S.startState.selection,Le)}static selection(S){return new Et(void 0,Le,void 0,void 0,S)}}function vi(u,S,V,W){let Q=S+1>V+20?S-V-1:0,J=u.slice(Q,S);return J.push(W),J}function Yt(u,S){let V=[],W=!1;return u.iterChangedRanges((Q,J)=>V.push(Q,J)),S.iterChangedRanges((Q,J,ne,Se)=>{for(let He=0;He<V.length;){let vt=V[He++],ct=V[He++];Se>=vt&&ne<=ct&&(W=!0)}}),W}function ye(u,S){return u.ranges.length==S.ranges.length&&u.ranges.filter((V,W)=>V.empty!=S.ranges[W].empty).length===0}function Be(u,S){return u.length?S.length?u.concat(S):u:S}const Le=[],Re=200;function Ye(u,S){if(u.length){let V=u[u.length-1],W=V.selectionsAfter.slice(Math.max(0,V.selectionsAfter.length-Re));return W.length&&W[W.length-1].eq(S)?u:(W.push(S),vi(u,u.length-1,1e9,V.setSelAfter(W)))}else return[Et.selection([S])]}function st(u){let S=u[u.length-1],V=u.slice();return V[u.length-1]=S.setSelAfter(S.selectionsAfter.slice(0,S.selectionsAfter.length-1)),V}function Ve(u,S){if(!u.length)return u;let V=u.length,W=Le;for(;V;){let Q=yt(u[V-1],S,W);if(Q.changes&&!Q.changes.empty||Q.effects.length){let J=u.slice(0,V);return J[V-1]=Q,J}else S=Q.mapped,V--,W=Q.selectionsAfter}return W.length?[Et.selection(W)]:Le}function yt(u,S,V){let W=Be(u.selectionsAfter.length?u.selectionsAfter.map(Se=>Se.map(S)):Le,V);if(!u.changes)return Et.selection(W);let Q=u.changes.map(S),J=S.mapDesc(u.changes,!0),ne=u.mapped?u.mapped.composeDesc(J):J;return new Et(Q,T.Py.mapEffects(u.effects,S),ne,u.startSelection.map(J),W)}const ei=/^(input\.type|delete)($|\.)/;class Ct{constructor(S,V,W=0,Q=void 0){this.done=S,this.undone=V,this.prevTime=W,this.prevUserEvent=Q}isolate(){return this.prevTime?new Ct(this.done,this.undone):this}addChanges(S,V,W,Q,J){let ne=this.done,Se=ne[ne.length-1];return Se&&Se.changes&&!Se.changes.empty&&S.changes&&(!W||ei.test(W))&&(!Se.selectionsAfter.length&&V-this.prevTime<Q.newGroupDelay&&Q.joinToEvent(J,Yt(Se.changes,S.changes))||W=="input.type.compose")?ne=vi(ne,ne.length-1,Q.minDepth,new Et(S.changes.compose(Se.changes),Be(T.Py.mapEffects(S.effects,Se.changes),Se.effects),Se.mapped,Se.startSelection,Le)):ne=vi(ne,ne.length,Q.minDepth,S),new Ct(ne,Le,V,W)}addSelection(S,V,W,Q){let J=this.done.length?this.done[this.done.length-1].selectionsAfter:Le;return J.length>0&&V-this.prevTime<Q&&W==this.prevUserEvent&&W&&/^select($|\.)/.test(W)&&ye(J[J.length-1],S)?this:new Ct(Ye(this.done,S),this.undone,V,W)}addMapping(S){return new Ct(Ve(this.done,S),Ve(this.undone,S),this.prevTime,this.prevUserEvent)}pop(S,V,W){let Q=S==0?this.done:this.undone;if(Q.length==0)return null;let J=Q[Q.length-1],ne=J.selectionsAfter[0]||V.selection;if(W&&J.selectionsAfter.length)return V.update({selection:J.selectionsAfter[J.selectionsAfter.length-1],annotations:Ft.of({side:S,rest:st(Q),selection:ne}),userEvent:S==0?"select.undo":"select.redo",scrollIntoView:!0});if(J.changes){let Se=Q.length==1?Le:Q.slice(0,Q.length-1);return J.mapped&&(Se=Ve(Se,J.mapped)),V.update({changes:J.changes,selection:J.startSelection,effects:J.effects,annotations:Ft.of({side:S,rest:Se,selection:ne}),filter:!1,userEvent:S==0?"undo":"redo",scrollIntoView:!0})}else return null}}Ct.empty=new Ct(Le,Le);const De=[{key:"Mod-z",run:Xt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:si,preventDefault:!0},{linux:"Ctrl-Shift-z",run:si,preventDefault:!0},{key:"Mod-u",run:nt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:kt,preventDefault:!0}];function zt(u,S){return T.jT.create(u.ranges.map(S),u.mainIndex)}function Bt(u,S){return u.update({selection:S,scrollIntoView:!0,userEvent:"select"})}function ie({state:u,dispatch:S},V){let W=zt(u.selection,V);return W.eq(u.selection,!0)?!1:(S(Bt(u,W)),!0)}function X(u,S){return T.jT.cursor(S?u.to:u.from)}function pe(u,S){return ie(u,V=>V.empty?u.moveByChar(V,S):X(V,S))}function ae(u){return u.textDirectionAt(u.state.selection.main.head)==re.Nm.LTR}const Ae=u=>pe(u,!ae(u)),Fe=u=>pe(u,ae(u)),Xe=u=>pe(u,!0),qe=u=>pe(u,!1);function dt(u,S,V){let W=S.head,Q=u.doc.lineAt(W);return W==(V?Q.to:Q.from)?W=V?Math.min(u.doc.length,Q.to+1):Math.max(0,Q.from-1):W=Q.from+findClusterBreak(Q.text,W-Q.from,V),EditorSelection.cursor(W,V?-1:1)}function xt(u,S){return ie(u,V=>V.empty?dt(u.state,V,S):X(V,S))}const tt=u=>xt(u,!0),bt=u=>xt(u,!1);function At(u,S){return ie(u,V=>V.empty?u.moveByGroup(V,S):X(V,S))}const Ot=u=>At(u,!ae(u)),Ti=u=>At(u,ae(u)),lt=u=>At(u,!0),rt=u=>At(u,!1);function Mi(u,S,V){let W=u.state.charCategorizer(S),Q=W(V),J=Q!=CharCategory.Space;return ne=>{let Se=W(ne);return Se!=CharCategory.Space?J&&Se==Q:(J=!1,!0)}}const Oi=u=>ie(u,S=>S.empty?u.moveByChar(S,!0,V=>Mi(u,S.head,V)):X(S,!0)),hi=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Pi(u,S,V){let W=u.state.charCategorizer(S.from),Q=CharCategory.Space,J=S.from,ne=0,Se=!1,He=!1,vt=!1,ct=ni=>{if(Se)return!1;J+=V?ni.length:-ni.length;let ai=W(ni),ui;if(ai==CharCategory.Word&&ni.charCodeAt(0)<128&&/[\W_]/.test(ni)&&(ai=-1),Q==CharCategory.Space&&(Q=ai),Q!=ai)return!1;if(Q==CharCategory.Word)if(ni.toLowerCase()==ni){if(!V&&He)return!1;vt=!0}else if(vt){if(V)return!1;Se=!0}else{if(He&&V&&W(ui=u.state.sliceDoc(J,J+1))==CharCategory.Word&&ui.toLowerCase()==ui)return!1;He=!0}return ne++,!0},Vt=u.moveByChar(S,V,ni=>(ct(ni),ct));if(hi&&Q==CharCategory.Word&&Vt.from==S.from+ne*(V?1:-1)){let ni=Math.min(S.head,Vt.head),ai=Math.max(S.head,Vt.head),ui=u.state.sliceDoc(ni,ai);if(ui.length>1&&/[\u4E00-\uffff]/.test(ui)){let fn=Array.from(hi.segment(ui));if(fn.length>1)return V?EditorSelection.cursor(S.head+fn[1].index,-1):EditorSelection.cursor(Vt.head+fn[fn.length-1].index,1)}}return Vt}function _i(u,S){return ie(u,V=>V.empty?Pi(u,V,S):X(V,S))}const _=u=>_i(u,!0),E=u=>_i(u,!1);function q(u,S,V){if(S.type.prop(V))return!0;let W=S.to-S.from;return W&&(W>2||/[^\s,.;:]/.test(u.sliceDoc(S.from,S.to)))||S.firstChild}function K(u,S,V){let W=(0,te.qz)(u).resolveInner(S.head),Q=V?Oe.md.closedBy:Oe.md.openedBy;for(let He=S.head;;){let vt=V?W.childAfter(He):W.childBefore(He);if(!vt)break;q(u,vt,Q)?W=vt:He=V?vt.to:vt.from}let J=W.type.prop(Q),ne,Se;return J&&(ne=V?(0,te.Um)(u,W.from,1):(0,te.Um)(u,W.to,-1))&&ne.matched?Se=V?ne.end.to:ne.end.from:Se=V?W.to:W.from,T.jT.cursor(Se,V?-1:1)}const ee=u=>ie(u,S=>K(u.state,S,!ae(u))),ge=u=>ie(u,S=>K(u.state,S,ae(u)));function Pe(u,S){return ie(u,V=>{if(!V.empty)return X(V,S);let W=u.moveVertically(V,S);return W.head!=V.head?W:u.moveToLineBoundary(V,S)})}const Te=u=>Pe(u,!1),je=u=>Pe(u,!0);function ot(u){let S=u.scrollDOM.clientHeight<u.scrollDOM.scrollHeight-2,V=0,W=0,Q;if(S){for(let J of u.state.facet(re.tk.scrollMargins)){let ne=J(u);ne!=null&&ne.top&&(V=Math.max(ne==null?void 0:ne.top,V)),ne!=null&&ne.bottom&&(W=Math.max(ne==null?void 0:ne.bottom,W))}Q=u.scrollDOM.clientHeight-V-W}else Q=(u.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:V,marginBottom:W,selfScroll:S,height:Math.max(u.defaultLineHeight,Q-5)}}function ti(u,S){let V=ot(u),{state:W}=u,Q=zt(W.selection,ne=>ne.empty?u.moveVertically(ne,S,V.height):X(ne,S));if(Q.eq(W.selection))return!1;let J;if(V.selfScroll){let ne=u.coordsAtPos(W.selection.main.head),Se=u.scrollDOM.getBoundingClientRect(),He=Se.top+V.marginTop,vt=Se.bottom-V.marginBottom;ne&&ne.top>He&&ne.bottom<vt&&(J=re.tk.scrollIntoView(Q.main.head,{y:"start",yMargin:ne.top-He}))}return u.dispatch(Bt(W,Q),{effects:J}),!0}const ri=u=>ti(u,!1),ci=u=>ti(u,!0);function fi(u,S,V){let W=u.lineBlockAt(S.head),Q=u.moveToLineBoundary(S,V);if(Q.head==S.head&&Q.head!=(V?W.to:W.from)&&(Q=u.moveToLineBoundary(S,V,!1)),!V&&Q.head==W.from&&W.length){let J=/^\s*/.exec(u.state.sliceDoc(W.from,Math.min(W.from+100,W.to)))[0].length;J&&S.head!=W.from+J&&(Q=T.jT.cursor(W.from+J))}return Q}const qt=u=>ie(u,S=>fi(u,S,!0)),gi=u=>ie(u,S=>fi(u,S,!1)),Li=u=>ie(u,S=>fi(u,S,!ae(u))),Ei=u=>ie(u,S=>fi(u,S,ae(u))),Xi=u=>ie(u,S=>T.jT.cursor(u.lineBlockAt(S.head).from,1)),Pt=u=>ie(u,S=>T.jT.cursor(u.lineBlockAt(S.head).to,-1));function Ji(u,S,V){let W=!1,Q=zt(u.selection,J=>{let ne=(0,te.Um)(u,J.head,-1)||(0,te.Um)(u,J.head,1)||J.head>0&&(0,te.Um)(u,J.head-1,1)||J.head<u.doc.length&&(0,te.Um)(u,J.head+1,-1);if(!ne||!ne.end)return J;W=!0;let Se=ne.start.from==J.head?ne.end.to:ne.end.from;return V?T.jT.range(J.anchor,Se):T.jT.cursor(Se)});return W?(S(Bt(u,Q)),!0):!1}const sn=({state:u,dispatch:S})=>Ji(u,S,!1),an=({state:u,dispatch:S})=>Ji(u,S,!0);function oi(u,S){let V=zt(u.state.selection,W=>{let Q=S(W);return T.jT.range(W.anchor,Q.head,Q.goalColumn,Q.bidiLevel||void 0)});return V.eq(u.state.selection)?!1:(u.dispatch(Bt(u.state,V)),!0)}function R(u,S){return oi(u,V=>u.moveByChar(V,S))}const o=u=>R(u,!ae(u)),a=u=>R(u,ae(u)),d=u=>R(u,!0),w=u=>R(u,!1),D=u=>oi(u,S=>dt(u.state,S,!0)),O=u=>oi(u,S=>dt(u.state,S,!1));function H(u,S){return oi(u,V=>u.moveByGroup(V,S))}const Y=u=>H(u,!ae(u)),ue=u=>H(u,ae(u)),ve=u=>H(u,!0),Ee=u=>H(u,!1),ze=u=>oi(u,S=>u.moveByChar(S,!0,V=>Mi(u,S.head,V)));function $e(u,S){return oi(u,V=>Pi(u,V,S))}const jt=u=>$e(u,!0),Fi=u=>$e(u,!1),ii=u=>oi(u,S=>K(u.state,S,!ae(u))),Qi=u=>oi(u,S=>K(u.state,S,ae(u)));function Ki(u,S){return oi(u,V=>u.moveVertically(V,S))}const Ui=u=>Ki(u,!1),rn=u=>Ki(u,!0);function P(u,S){return oi(u,V=>u.moveVertically(V,S,ot(u).height))}const y=u=>P(u,!1),x=u=>P(u,!0),L=u=>oi(u,S=>fi(u,S,!0)),I=u=>oi(u,S=>fi(u,S,!1)),G=u=>oi(u,S=>fi(u,S,!ae(u))),oe=u=>oi(u,S=>fi(u,S,ae(u))),de=u=>oi(u,S=>T.jT.cursor(u.lineBlockAt(S.head).from)),fe=u=>oi(u,S=>T.jT.cursor(u.lineBlockAt(S.head).to)),Me=({state:u,dispatch:S})=>(S(Bt(u,{anchor:0})),!0),Ce=({state:u,dispatch:S})=>(S(Bt(u,{anchor:u.doc.length})),!0),_e=({state:u,dispatch:S})=>(S(Bt(u,{anchor:u.selection.main.anchor,head:0})),!0),wt=({state:u,dispatch:S})=>(S(Bt(u,{anchor:u.selection.main.anchor,head:u.doc.length})),!0),Wt=({state:u,dispatch:S})=>(S(u.update({selection:{anchor:0,head:u.doc.length},userEvent:"select"})),!0),li=({state:u,dispatch:S})=>{let V=Ke(u).map(({from:W,to:Q})=>T.jT.range(W,Math.min(Q+1,u.doc.length)));return S(u.update({selection:T.jT.create(V),userEvent:"select"})),!0},yi=({state:u,dispatch:S})=>{let V=zt(u.selection,W=>{let Q=(0,te.qz)(u),J=Q.resolveStack(W.from,1);if(W.empty){let ne=Q.resolveStack(W.from,-1);ne.node.from>=J.node.from&&ne.node.to<=J.node.to&&(J=ne)}for(let ne=J;ne;ne=ne.next){let{node:Se}=ne;if((Se.from<W.from&&Se.to>=W.to||Se.to>W.to&&Se.from<=W.from)&&ne.next)return T.jT.range(Se.to,Se.from)}return W});return V.eq(u.selection)?!1:(S(Bt(u,V)),!0)},Di=({state:u,dispatch:S})=>{let V=u.selection,W=null;return V.ranges.length>1?W=T.jT.create([V.main]):V.main.empty||(W=T.jT.create([T.jT.cursor(V.main.head)])),W?(S(Bt(u,W)),!0):!1};function xi(u,S){if(u.state.readOnly)return!1;let V="delete.selection",{state:W}=u,Q=W.changeByRange(J=>{let{from:ne,to:Se}=J;if(ne==Se){let He=S(J);He<ne?(V="delete.backward",He=Qt(u,He,!1)):He>ne&&(V="delete.forward",He=Qt(u,He,!0)),ne=Math.min(ne,He),Se=Math.max(Se,He)}else ne=Qt(u,ne,!1),Se=Qt(u,Se,!0);return ne==Se?{range:J}:{changes:{from:ne,to:Se},range:T.jT.cursor(ne,ne<J.head?-1:1)}});return Q.changes.empty?!1:(u.dispatch(W.update(Q,{scrollIntoView:!0,userEvent:V,effects:V=="delete.selection"?re.tk.announce.of(W.phrase("Selection deleted")):void 0})),!0)}function Qt(u,S,V){if(u instanceof re.tk)for(let W of u.state.facet(re.tk.atomicRanges).map(Q=>Q(u)))W.between(S,S,(Q,J)=>{Q<S&&J>S&&(S=V?J:Q)});return S}const Vi=(u,S,V)=>xi(u,W=>{let Q=W.from,{state:J}=u,ne=J.doc.lineAt(Q),Se,He;if(V&&!S&&Q>ne.from&&Q<ne.from+200&&!/[^ \t]/.test(Se=ne.text.slice(0,Q-ne.from))){if(Se[Se.length-1]==" ")return Q-1;let vt=(0,T.IS)(Se,J.tabSize),ct=vt%(0,te.y1)(J)||(0,te.y1)(J);for(let Vt=0;Vt<ct&&Se[Se.length-1-Vt]==" ";Vt++)Q--;He=Q}else He=(0,T.cp)(ne.text,Q-ne.from,S,S)+ne.from,He==Q&&ne.number!=(S?J.doc.lines:1)?He+=S?1:-1:!S&&/[\ufe00-\ufe0f]/.test(ne.text.slice(He-ne.from,Q-ne.from))&&(He=(0,T.cp)(ne.text,He-ne.from,!1,!1)+ne.from);return He}),Bi=u=>Vi(u,!1,!0),Ri=u=>Vi(u,!1,!1),Zi=u=>Vi(u,!0,!1),A=(u,S)=>xi(u,V=>{let W=V.head,{state:Q}=u,J=Q.doc.lineAt(W),ne=Q.charCategorizer(W);for(let Se=null;;){if(W==(S?J.to:J.from)){W==V.head&&J.number!=(S?Q.doc.lines:1)&&(W+=S?1:-1);break}let He=(0,T.cp)(J.text,W-J.from,S)+J.from,vt=J.text.slice(Math.min(W,He)-J.from,Math.max(W,He)-J.from),ct=ne(vt);if(Se!=null&&ct!=Se)break;(vt!=" "||W!=V.head)&&(Se=ct),W=He}return W}),f=u=>A(u,!1),b=u=>A(u,!0),B=u=>xi(u,S=>{let V=u.lineBlockAt(S.head).to;return S.head<V?V:Math.min(u.state.doc.length,S.head+1)}),F=u=>xi(u,S=>{let V=u.lineBlockAt(S.head).from;return S.head>V?V:Math.max(0,S.head-1)}),U=u=>xi(u,S=>{let V=u.moveToLineBoundary(S,!1).head;return S.head>V?V:Math.max(0,S.head-1)}),Z=u=>xi(u,S=>{let V=u.moveToLineBoundary(S,!0).head;return S.head<V?V:Math.min(u.state.doc.length,S.head+1)}),be=({state:u,dispatch:S})=>{if(u.readOnly)return!1;let V=[];for(let W=0,Q="",J=u.doc.iter();;){if(J.next(),J.lineBreak||J.done){let ne=Q.search(/\s+$/);if(ne>-1&&V.push({from:W-(Q.length-ne),to:W}),J.done)break;Q=""}else Q=J.value;W+=J.value.length}return V.length?(S(u.update({changes:V,userEvent:"delete"})),!0):!1},me=({state:u,dispatch:S})=>{if(u.readOnly)return!1;let V=u.changeByRange(W=>({changes:{from:W.from,to:W.to,insert:T.xv.of(["",""])},range:T.jT.cursor(W.from)}));return S(u.update(V,{scrollIntoView:!0,userEvent:"input"})),!0},Ne=({state:u,dispatch:S})=>{if(u.readOnly)return!1;let V=u.changeByRange(W=>{if(!W.empty||W.from==0||W.from==u.doc.length)return{range:W};let Q=W.from,J=u.doc.lineAt(Q),ne=Q==J.from?Q-1:(0,T.cp)(J.text,Q-J.from,!1)+J.from,Se=Q==J.to?Q+1:(0,T.cp)(J.text,Q-J.from,!0)+J.from;return{changes:{from:ne,to:Se,insert:u.doc.slice(Q,Se).append(u.doc.slice(ne,Q))},range:T.jT.cursor(Se)}});return V.changes.empty?!1:(S(u.update(V,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ke(u){let S=[],V=-1;for(let W of u.selection.ranges){let Q=u.doc.lineAt(W.from),J=u.doc.lineAt(W.to);if(!W.empty&&W.to==J.from&&(J=u.doc.lineAt(W.to-1)),V>=Q.number){let ne=S[S.length-1];ne.to=J.to,ne.ranges.push(W)}else S.push({from:Q.from,to:J.to,ranges:[W]});V=J.number+1}return S}function _t(u,S,V){if(u.readOnly)return!1;let W=[],Q=[];for(let J of Ke(u)){if(V?J.to==u.doc.length:J.from==0)continue;let ne=u.doc.lineAt(V?J.to+1:J.from-1),Se=ne.length+1;if(V){W.push({from:J.to,to:ne.to},{from:J.from,insert:ne.text+u.lineBreak});for(let He of J.ranges)Q.push(T.jT.range(Math.min(u.doc.length,He.anchor+Se),Math.min(u.doc.length,He.head+Se)))}else{W.push({from:ne.from,to:J.from},{from:J.to,insert:u.lineBreak+ne.text});for(let He of J.ranges)Q.push(T.jT.range(He.anchor-Se,He.head-Se))}}return W.length?(S(u.update({changes:W,scrollIntoView:!0,selection:T.jT.create(Q,u.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Wi=({state:u,dispatch:S})=>_t(u,S,!1),Ii=({state:u,dispatch:S})=>_t(u,S,!0);function en(u,S,V){if(u.readOnly)return!1;let W=[];for(let Q of Ke(u))V?W.push({from:Q.from,insert:u.doc.slice(Q.from,Q.to)+u.lineBreak}):W.push({from:Q.to,insert:u.lineBreak+u.doc.slice(Q.from,Q.to)});return S(u.update({changes:W,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Yi=({state:u,dispatch:S})=>en(u,S,!1),kn=({state:u,dispatch:S})=>en(u,S,!0),mn=u=>{if(u.state.readOnly)return!1;let{state:S}=u,V=S.changes(Ke(S).map(({from:Q,to:J})=>(Q>0?Q--:J<S.doc.length&&J++,{from:Q,to:J}))),W=zt(S.selection,Q=>{let J;if(u.lineWrapping){let ne=u.lineBlockAt(Q.head),Se=u.coordsAtPos(Q.head,Q.assoc||1);Se&&(J=ne.bottom+u.documentTop-Se.bottom+u.defaultLineHeight/2)}return u.moveVertically(Q,!0,J)}).map(V);return u.dispatch({changes:V,selection:W,scrollIntoView:!0,userEvent:"delete.line"}),!0},Bn=({state:u,dispatch:S})=>(S(u.update(u.replaceSelection(u.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),Kn=({state:u,dispatch:S})=>(S(u.update(u.changeByRange(V=>{let W=/^\s*/.exec(u.doc.lineAt(V.from).text)[0];return{changes:{from:V.from,to:V.to,insert:u.lineBreak+W},range:EditorSelection.cursor(V.from+W.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);function Vn(u,S){if(/\(\)|\[\]|\{\}/.test(u.sliceDoc(S-1,S+1)))return{from:S,to:S};let V=(0,te.qz)(u).resolveInner(S),W=V.childBefore(S),Q=V.childAfter(S),J;return W&&Q&&W.to<=S&&Q.from>=S&&(J=W.type.prop(Oe.md.closedBy))&&J.indexOf(Q.name)>-1&&u.doc.lineAt(W.to).from==u.doc.lineAt(Q.from).from&&!/\S/.test(u.sliceDoc(W.to,Q.from))?{from:W.to,to:Q.from}:null}const tn=on(!1),gn=on(!0);function on(u){return({state:S,dispatch:V})=>{if(S.readOnly)return!1;let W=S.changeByRange(Q=>{let{from:J,to:ne}=Q,Se=S.doc.lineAt(J),He=!u&&J==ne&&Vn(S,J);u&&(J=ne=(ne<=Se.to?Se:S.doc.lineAt(ne)).to);let vt=new te.Gn(S,{simulateBreak:J,simulateDoubleBreak:!!He}),ct=(0,te.K0)(vt,J);for(ct==null&&(ct=(0,T.IS)(/^\s*/.exec(S.doc.lineAt(J).text)[0],S.tabSize));ne<Se.to&&/\s/.test(Se.text[ne-Se.from]);)ne++;He?{from:J,to:ne}=He:J>Se.from&&J<Se.from+100&&!/\S/.test(Se.text.slice(0,J))&&(J=Se.from);let Vt=["",(0,te.SS)(S,ct)];return He&&Vt.push((0,te.SS)(S,vt.lineIndent(Se.from,-1))),{changes:{from:J,to:ne,insert:T.xv.of(Vt)},range:T.jT.cursor(J+1+Vt[1].length)}});return V(S.update(W,{scrollIntoView:!0,userEvent:"input"})),!0}}function yn(u,S){let V=-1;return u.changeByRange(W=>{let Q=[];for(let ne=W.from;ne<=W.to;){let Se=u.doc.lineAt(ne);Se.number>V&&(W.empty||W.to>Se.from)&&(S(Se,Q,W),V=Se.number),ne=Se.to+1}let J=u.changes(Q);return{changes:Q,range:T.jT.range(J.mapPos(W.anchor,1),J.mapPos(W.head,1))}})}const Hi=({state:u,dispatch:S})=>{if(u.readOnly)return!1;let V=Object.create(null),W=new te.Gn(u,{overrideIndentation:J=>{let ne=V[J];return ne??-1}}),Q=yn(u,(J,ne,Se)=>{let He=(0,te.K0)(W,J.from);if(He==null)return;/\S/.test(J.text)||(He=0);let vt=/^\s*/.exec(J.text)[0],ct=(0,te.SS)(u,He);(vt!=ct||Se.from<J.from+vt.length)&&(V[J.from]=He,ne.push({from:J.from,to:J.from+vt.length,insert:ct}))});return Q.changes.empty||S(u.update(Q,{userEvent:"indent"})),!0},Ge=({state:u,dispatch:S})=>u.readOnly?!1:(S(u.update(yn(u,(V,W)=>{W.push({from:V.from,insert:u.facet(te.c)})}),{userEvent:"input.indent"})),!0),Ln=({state:u,dispatch:S})=>u.readOnly?!1:(S(u.update(yn(u,(V,W)=>{let Q=/^\s*/.exec(V.text)[0];if(!Q)return;let J=(0,T.IS)(Q,u.tabSize),ne=0,Se=(0,te.SS)(u,Math.max(0,J-(0,te.y1)(u)));for(;ne<Q.length&&ne<Se.length&&Q.charCodeAt(ne)==Se.charCodeAt(ne);)ne++;W.push({from:V.from+ne,to:V.from+Q.length,insert:Se.slice(ne)})}),{userEvent:"delete.dedent"})),!0),Tn=u=>(u.setTabFocusMode(),!0),Mn=u=>(u.setTabFocusMode(2e3),!0),xn=({state:u,dispatch:S})=>u.selection.ranges.some(V=>!V.empty)?Ge({state:u,dispatch:S}):(S(u.update(u.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),hn=[{key:"Ctrl-b",run:Ae,shift:o,preventDefault:!0},{key:"Ctrl-f",run:Fe,shift:a},{key:"Ctrl-p",run:Te,shift:Ui},{key:"Ctrl-n",run:je,shift:rn},{key:"Ctrl-a",run:Xi,shift:de},{key:"Ctrl-e",run:Pt,shift:fe},{key:"Ctrl-d",run:Zi},{key:"Ctrl-h",run:Bi},{key:"Ctrl-k",run:B},{key:"Ctrl-Alt-h",run:f},{key:"Ctrl-o",run:me},{key:"Ctrl-t",run:Ne},{key:"Ctrl-v",run:ci}],cn=[{key:"ArrowLeft",run:Ae,shift:o,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Ot,shift:Y,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Li,shift:G,preventDefault:!0},{key:"ArrowRight",run:Fe,shift:a,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Ti,shift:ue,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Ei,shift:oe,preventDefault:!0},{key:"ArrowUp",run:Te,shift:Ui,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Me,shift:_e},{mac:"Ctrl-ArrowUp",run:ri,shift:y},{key:"ArrowDown",run:je,shift:rn,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ce,shift:wt},{mac:"Ctrl-ArrowDown",run:ci,shift:x},{key:"PageUp",run:ri,shift:y},{key:"PageDown",run:ci,shift:x},{key:"Home",run:gi,shift:I,preventDefault:!0},{key:"Mod-Home",run:Me,shift:_e},{key:"End",run:qt,shift:L,preventDefault:!0},{key:"Mod-End",run:Ce,shift:wt},{key:"Enter",run:tn,shift:tn},{key:"Mod-a",run:Wt},{key:"Backspace",run:Bi,shift:Bi},{key:"Delete",run:Zi},{key:"Mod-Backspace",mac:"Alt-Backspace",run:f},{key:"Mod-Delete",mac:"Alt-Delete",run:b},{mac:"Mod-Backspace",run:U},{mac:"Mod-Delete",run:Z}].concat(hn.map(u=>({mac:u.key,run:u.run,shift:u.shift}))),Rn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ee,shift:ii},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:ge,shift:Qi},{key:"Alt-ArrowUp",run:Wi},{key:"Shift-Alt-ArrowUp",run:Yi},{key:"Alt-ArrowDown",run:Ii},{key:"Shift-Alt-ArrowDown",run:kn},{key:"Escape",run:Di},{key:"Mod-Enter",run:gn},{key:"Alt-l",mac:"Ctrl-l",run:li},{key:"Mod-i",run:yi,preventDefault:!0},{key:"Mod-[",run:Ln},{key:"Mod-]",run:Ge},{key:"Mod-Alt-\\",run:Hi},{key:"Shift-Mod-k",run:mn},{key:"Shift-Mod-\\",run:sn},{key:"Mod-/",run:ut},{key:"Alt-A",run:St},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Tn}].concat(cn),In={key:"Tab",run:Ge,shift:Ln}},58377:function(pn,Ni,it){it.d(Ni,{dy:function(){return ui},aG:function(){return Se},s6:function(){return ai}});var T=it(68792),re=it(9058),te=it(59119),Oe=it(41113);let ut=null;function Lt(){if(!ut&&typeof document=="object"&&document.body){let{style:g}=document.body,h=[],p=new Set;for(let v in g)v!="cssText"&&v!="cssFloat"&&typeof g[v]=="string"&&(/[A-Z]/.test(v)&&(v=v.replace(/[A-Z]/g,M=>"-"+M.toLowerCase())),p.has(v)||(h.push(v),p.add(v)));ut=h.sort().map(v=>({type:"property",label:v,apply:v+": "}))}return ut||[]}const Nt=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(g=>({type:"class",label:g})),Jt=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(g=>({type:"keyword",label:g})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(g=>({type:"constant",label:g}))),Kt=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(g=>({type:"type",label:g})),St=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(g=>({type:"keyword",label:g})),Dt=/^(\w[\w-]*|-\w[\w-]*|)$/,Rt=/^-(-[\w-]*)?$/;function Ze(g,h){var p;if((g.name=="("||g.type.isError)&&(g=g.parent||g),g.name!="ArgList")return!1;let v=(p=g.parent)===null||p===void 0?void 0:p.firstChild;return(v==null?void 0:v.name)!="Callee"?!1:h.sliceString(v.from,v.to)=="var"}const wi=new Oe.hr,Ut=["Declaration"];function Ai(g){for(let h=g;;){if(h.type.isTop)return h;if(!(h=h.parent))return g}}function pi(g,h,p){if(h.to-h.from>4096){let v=wi.get(h);if(v)return v;let M=[],$=new Set,j=h.cursor(Oe.vj.IncludeAnonymous);if(j.firstChild())do for(let le of pi(g,j.node,p))$.has(le.label)||($.add(le.label),M.push(le));while(j.nextSibling());return wi.set(h,M),M}else{let v=[],M=new Set;return h.cursor().iterate($=>{var j;if(p($)&&$.matchContext(Ut)&&((j=$.node.nextSibling)===null||j===void 0?void 0:j.name)==":"){let le=g.sliceString($.from,$.to);M.has(le)||(M.add(le),v.push({label:le,type:"variable"}))}}),v}}const Gt=(g=>h=>{let{state:p,pos:v}=h,M=(0,te.qz)(p).resolveInner(v,-1),$=M.type.isError&&M.from==M.to-1&&p.doc.sliceString(M.from,M.to)=="-";if(M.name=="PropertyName"||($||M.name=="TagName")&&/^(Block|Styles)$/.test(M.resolve(M.to).name))return{from:M.from,options:Lt(),validFor:Dt};if(M.name=="ValueName")return{from:M.from,options:Jt,validFor:Dt};if(M.name=="PseudoClassName")return{from:M.from,options:Nt,validFor:Dt};if(g(M)||(h.explicit||$)&&Ze(M,p.doc))return{from:g(M)||$?M.from:v,options:pi(p.doc,Ai(M),g),validFor:Rt};if(M.name=="TagName"){for(let{parent:ce}=M;ce;ce=ce.parent)if(ce.name=="Block")return{from:M.from,options:Lt(),validFor:Dt};return{from:M.from,options:Kt,validFor:Dt}}if(M.name=="AtKeyword")return{from:M.from,options:St,validFor:Dt};if(!h.explicit)return null;let j=M.resolve(v),le=j.childBefore(v);return le&&le.name==":"&&j.name=="PseudoClassSelector"?{from:v,options:Nt,validFor:Dt}:le&&le.name==":"&&j.name=="Declaration"||j.name=="ArgList"?{from:v,options:Jt,validFor:Dt}:j.name=="Block"||j.name=="Styles"?{from:v,options:Lt(),validFor:Dt}:null})(g=>g.name=="VariableName"),Ft=te.qp.define({name:"css",parser:re.E.configure({props:[te.uj.add({Declaration:(0,te.tC)()}),te.x0.add({"Block KeyframeList":te.Dv})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function Tt(){return new te.ri(Ft,Ft.data.of({autocomplete:Gt}))}var et=it(13249),We=it(47421),ht=it(78120),Je=it(35524),di=it(28699),ki;const Xt=new Oe.md;function si(g){return ht.r$.define({combine:g?h=>h.concat(g):void 0})}const nt=new Oe.md;class kt{constructor(h,p,v=[],M=""){this.data=h,this.name=M,ht.yy.prototype.hasOwnProperty("tree")||Object.defineProperty(ht.yy.prototype,"tree",{get(){return $t(this)}}),this.parser=p,this.extension=[Ct.of(this),ht.yy.languageData.of(($,j,le)=>{let ce=ft($,j,le),Ie=ce.type.prop(Xt);if(!Ie)return[];let Ue=$.facet(Ie),Mt=ce.type.prop(nt);if(Mt){let Si=ce.resolve(j-ce.from,le);for(let Zt of Mt)if(Zt.test(Si,$)){let $i=$.facet(Zt.facet);return Zt.type=="replace"?$i:$i.concat(Ue)}}return Ue})].concat(v)}isActiveAt(h,p,v=-1){return ft(h,p,v).type.prop(Xt)==this.data}findRegions(h){let p=h.facet(Ct);if((p==null?void 0:p.data)==this.data)return[{from:0,to:h.doc.length}];if(!p||!p.allowsNesting)return[];let v=[],M=($,j)=>{if($.prop(Xt)==this.data){v.push({from:j,to:j+$.length});return}let le=$.prop(Oe.md.mounted);if(le){if(le.tree.prop(Xt)==this.data){if(le.overlay)for(let ce of le.overlay)v.push({from:ce.from+j,to:ce.to+j});else v.push({from:j,to:j+$.length});return}else if(le.overlay){let ce=v.length;if(M(le.tree,le.overlay[0].from+j),v.length>ce)return}}for(let ce=0;ce<$.children.length;ce++){let Ie=$.children[ce];Ie instanceof Oe.mp&&M(Ie,$.positions[ce]+j)}};return M($t(h),0),v}get allowsNesting(){return!0}}kt.setState=ht.Py.define();function ft(g,h,p){let v=g.facet(Ct),M=$t(g).topNode;if(!v||v.allowsNesting)for(let $=M;$;$=$.enter(h,p,Oe.vj.ExcludeBuffers))$.type.isTop&&(M=$);return M}class It extends kt{constructor(h,p,v){super(h,p,[],v),this.parser=p}static define(h){let p=si(h.languageData);return new It(p,h.parser.configure({props:[Xt.add(v=>v.isTop?p:void 0)]}),h.name)}configure(h,p){return new It(this.data,this.parser.configure(h),p||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function $t(g){let h=g.field(kt.state,!1);return h?h.tree:Oe.mp.empty}function Et(g,h,p=50){var v;let M=(v=g.field(kt.state,!1))===null||v===void 0?void 0:v.context;if(!M)return null;let $=M.viewport;M.updateViewport({from:0,to:h});let j=M.isDone(h)||M.work(p,h)?M.tree:null;return M.updateViewport($),j}function vi(g,h=g.doc.length){var p;return((p=g.field(kt.state,!1))===null||p===void 0?void 0:p.context.isDone(h))||!1}function Yt(g,h=g.viewport.to,p=100){let v=Et(g.state,h,p);return v!=$t(g.state)&&g.dispatch({}),!!v}function ye(g){var h;return((h=g.plugin(ei))===null||h===void 0?void 0:h.isWorking())||!1}class Be{constructor(h){this.doc=h,this.cursorPos=0,this.string="",this.cursor=h.iter()}get length(){return this.doc.length}syncTo(h){return this.string=this.cursor.next(h-this.cursorPos).value,this.cursorPos=h+this.string.length,this.cursorPos-this.string.length}chunk(h){return this.syncTo(h),this.string}get lineChunks(){return!0}read(h,p){let v=this.cursorPos-this.string.length;return h<v||p>=this.cursorPos?this.doc.sliceString(h,p):this.string.slice(h-v,p-v)}}let Le=null;class Re{constructor(h,p,v=[],M,$,j,le,ce){this.parser=h,this.state=p,this.fragments=v,this.tree=M,this.treeLen=$,this.viewport=j,this.skipped=le,this.scheduleOn=ce,this.parse=null,this.tempSkipped=[]}static create(h,p,v){return new Re(h,p,[],Oe.mp.empty,0,v,[],null)}startParse(){return this.parser.startParse(new Be(this.state.doc),this.fragments)}work(h,p){return p!=null&&p>=this.state.doc.length&&(p=void 0),this.tree!=Oe.mp.empty&&this.isDone(p??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var v;if(typeof h=="number"){let M=Date.now()+h;h=()=>Date.now()>M}for(this.parse||(this.parse=this.startParse()),p!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>p)&&p<this.state.doc.length&&this.parse.stopAt(p);;){let M=this.parse.advance();if(M)if(this.fragments=this.withoutTempSkipped(Oe.i9.addTree(M,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(v=this.parse.stoppedAt)!==null&&v!==void 0?v:this.state.doc.length,this.tree=M,this.parse=null,this.treeLen<(p??this.state.doc.length))this.parse=this.startParse();else return!0;if(h())return!1}})}takeTree(){let h,p;this.parse&&(h=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>h)&&this.parse.stopAt(h),this.withContext(()=>{for(;!(p=this.parse.advance()););}),this.treeLen=h,this.tree=p,this.fragments=this.withoutTempSkipped(Oe.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(h){let p=Le;Le=this;try{return h()}finally{Le=p}}withoutTempSkipped(h){for(let p;p=this.tempSkipped.pop();)h=Ye(h,p.from,p.to);return h}changes(h,p){let{fragments:v,tree:M,treeLen:$,viewport:j,skipped:le}=this;if(this.takeTree(),!h.empty){let ce=[];if(h.iterChangedRanges((Ie,Ue,Mt,Si)=>ce.push({fromA:Ie,toA:Ue,fromB:Mt,toB:Si})),v=Oe.i9.applyChanges(v,ce),M=Oe.mp.empty,$=0,j={from:h.mapPos(j.from,-1),to:h.mapPos(j.to,1)},this.skipped.length){le=[];for(let Ie of this.skipped){let Ue=h.mapPos(Ie.from,1),Mt=h.mapPos(Ie.to,-1);Ue<Mt&&le.push({from:Ue,to:Mt})}}}return new Re(this.parser,p,v,M,$,j,le,this.scheduleOn)}updateViewport(h){if(this.viewport.from==h.from&&this.viewport.to==h.to)return!1;this.viewport=h;let p=this.skipped.length;for(let v=0;v<this.skipped.length;v++){let{from:M,to:$}=this.skipped[v];M<h.to&&$>h.from&&(this.fragments=Ye(this.fragments,M,$),this.skipped.splice(v--,1))}return this.skipped.length>=p?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(h,p){this.skipped.push({from:h,to:p})}static getSkippingParser(h){return new class extends Oe._b{createParse(p,v,M){let $=M[0].from,j=M[M.length-1].to;return{parsedPos:$,advance(){let ce=Le;if(ce){for(let Ie of M)ce.tempSkipped.push(Ie);h&&(ce.scheduleOn=ce.scheduleOn?Promise.all([ce.scheduleOn,h]):h)}return this.parsedPos=j,new Oe.mp(Oe.Jq.none,[],[],j-$)},stoppedAt:null,stopAt(){}}}}}isDone(h){h=Math.min(h,this.state.doc.length);let p=this.fragments;return this.treeLen>=h&&p.length&&p[0].from==0&&p[0].to>=h}static get(){return Le}}function Ye(g,h,p){return Oe.i9.applyChanges(g,[{fromA:h,toA:p,fromB:h,toB:p}])}class st{constructor(h){this.context=h,this.tree=h.tree}apply(h){if(!h.docChanged&&this.tree==this.context.tree)return this;let p=this.context.changes(h.changes,h.state),v=this.context.treeLen==h.startState.doc.length?void 0:Math.max(h.changes.mapPos(this.context.treeLen),p.viewport.to);return p.work(20,v)||p.takeTree(),new st(p)}static init(h){let p=Math.min(3e3,h.doc.length),v=Re.create(h.facet(Ct).parser,h,{from:0,to:p});return v.work(20,p)||v.takeTree(),new st(v)}}kt.state=ht.QQ.define({create:st.init,update(g,h){for(let p of h.effects)if(p.is(kt.setState))return p.value;return h.startState.facet(Ct)!=h.state.facet(Ct)?st.init(h.state):g.apply(h)}});let Ve=g=>{let h=setTimeout(()=>g(),500);return()=>clearTimeout(h)};typeof requestIdleCallback<"u"&&(Ve=g=>{let h=-1,p=setTimeout(()=>{h=requestIdleCallback(g,{timeout:500-100})},100);return()=>h<0?clearTimeout(p):cancelIdleCallback(h)});const yt=typeof navigator<"u"&&(!((ki=navigator.scheduling)===null||ki===void 0)&&ki.isInputPending)?()=>navigator.scheduling.isInputPending():null,ei=We.lg.fromClass(class{constructor(h){this.view=h,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(h){let p=this.view.state.field(kt.state).context;(p.updateViewport(h.view.viewport)||this.view.viewport.to>p.treeLen)&&this.scheduleWork(),(h.docChanged||h.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(p)}scheduleWork(){if(this.working)return;let{state:h}=this.view,p=h.field(kt.state);(p.tree!=p.context.tree||!p.context.isDone(h.doc.length))&&(this.working=Ve(this.work))}work(h){this.working=null;let p=Date.now();if(this.chunkEnd<p&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=p+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:v,viewport:{to:M}}=this.view,$=v.field(kt.state);if($.tree==$.context.tree&&$.context.isDone(M+1e5))return;let j=Date.now()+Math.min(this.chunkBudget,100,h&&!yt?Math.max(25,h.timeRemaining()-5):1e9),le=$.context.treeLen<M&&v.doc.length>M+1e3,ce=$.context.work(()=>yt&&yt()||Date.now()>j,M+(le?0:1e5));this.chunkBudget-=Date.now()-p,(ce||this.chunkBudget<=0)&&($.context.takeTree(),this.view.dispatch({effects:kt.setState.of(new st($.context))})),this.chunkBudget>0&&!(ce&&!le)&&this.scheduleWork(),this.checkAsyncSchedule($.context)}checkAsyncSchedule(h){h.scheduleOn&&(this.workScheduled++,h.scheduleOn.then(()=>this.scheduleWork()).catch(p=>(0,We.OO)(this.view.state,p)).then(()=>this.workScheduled--),h.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ct=ht.r$.define({combine(g){return g.length?g[0]:null},enables:g=>[kt.state,ei,We.tk.contentAttributes.compute([g],h=>{let p=h.facet(g);return p&&p.name?{"data-language":p.name}:{}})]});class De{constructor(h,p=[]){this.language=h,this.support=p,this.extension=[h,p]}}class zt{constructor(h,p,v,M,$,j=void 0){this.name=h,this.alias=p,this.extensions=v,this.filename=M,this.loadFunc=$,this.support=j,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(h=>this.support=h,h=>{throw this.loading=null,h}))}static of(h){let{load:p,support:v}=h;if(!p){if(!v)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");p=()=>Promise.resolve(v)}return new zt(h.name,(h.alias||[]).concat(h.name).map(M=>M.toLowerCase()),h.extensions||[],h.filename,p,v)}static matchFilename(h,p){for(let M of h)if(M.filename&&M.filename.test(p))return M;let v=/\.([^.]+)$/.exec(p);if(v){for(let M of h)if(M.extensions.indexOf(v[1])>-1)return M}return null}static matchLanguageName(h,p,v=!0){p=p.toLowerCase();for(let M of h)if(M.alias.some($=>$==p))return M;if(v)for(let M of h)for(let $ of M.alias){let j=p.indexOf($);if(j>-1&&($.length>2||!/\w/.test(p[j-1])&&!/\w/.test(p[j+$.length])))return M}return null}}const Bt=null,ie=ht.r$.define({combine:g=>{if(!g.length)return" ";let h=g[0];if(!h||/\S/.test(h)||Array.from(h).some(p=>p!=h[0]))throw new Error("Invalid indent unit: "+JSON.stringify(g[0]));return h}});function X(g){let h=g.facet(ie);return h.charCodeAt(0)==9?g.tabSize*h.length:h.length}function pe(g,h){let p="",v=g.tabSize,M=g.facet(ie)[0];if(M==" "){for(;h>=v;)p+=" ",h-=v;M=" "}for(let $=0;$<h;$++)p+=M;return p}function ae(g,h){g instanceof EditorState&&(g=new Fe(g));for(let v of g.state.facet(Bt)){let M=v(g,h);if(M!==void 0)return M}let p=$t(g.state);return p.length>=h?qe(g,p,h):null}function Ae(g,h,p){let v=Object.create(null),M=new Fe(g,{overrideIndentation:j=>{var le;return(le=v[j])!==null&&le!==void 0?le:-1}}),$=[];for(let j=h;j<=p;){let le=g.doc.lineAt(j);j=le.to+1;let ce=ae(M,le.from);if(ce==null)continue;/\S/.test(le.text)||(ce=0);let Ie=/^\s*/.exec(le.text)[0],Ue=pe(g,ce);Ie!=Ue&&(v[le.from]=ce,$.push({from:le.from,to:le.from+Ie.length,insert:Ue}))}return g.changes($)}class Fe{constructor(h,p={}){this.state=h,this.options=p,this.unit=X(h)}lineAt(h,p=1){let v=this.state.doc.lineAt(h),{simulateBreak:M,simulateDoubleBreak:$}=this.options;return M!=null&&M>=v.from&&M<=v.to?$&&M==h?{text:"",from:h}:(p<0?M<h:M<=h)?{text:v.text.slice(M-v.from),from:M}:{text:v.text.slice(0,M-v.from),from:v.from}:v}textAfterPos(h,p=1){if(this.options.simulateDoubleBreak&&h==this.options.simulateBreak)return"";let{text:v,from:M}=this.lineAt(h,p);return v.slice(h-M,Math.min(v.length,h+100-M))}column(h,p=1){let{text:v,from:M}=this.lineAt(h,p),$=this.countColumn(v,h-M),j=this.options.overrideIndentation?this.options.overrideIndentation(M):-1;return j>-1&&($+=j-this.countColumn(v,v.search(/\S|$/))),$}countColumn(h,p=h.length){return countColumn(h,this.state.tabSize,p)}lineIndent(h,p=1){let{text:v,from:M}=this.lineAt(h,p),$=this.options.overrideIndentation;if($){let j=$(M);if(j>-1)return j}return this.countColumn(v,v.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Xe=new Oe.md;function qe(g,h,p){let v=h.resolveStack(p),M=h.resolveInner(p,-1).resolve(p,0).enterUnfinishedNodesBefore(p);if(M!=v.node){let $=[];for(let j=M;j&&!(j.from<v.node.from||j.to>v.node.to||j.from==v.node.from&&j.type==v.node.type);j=j.parent)$.push(j);for(let j=$.length-1;j>=0;j--)v={node:$[j],next:v}}return dt(v,g,p)}function dt(g,h,p){for(let v=g;v;v=v.next){let M=tt(v.node);if(M)return M(At.create(h,p,v))}return 0}function xt(g){return g.pos==g.options.simulateBreak&&g.options.simulateDoubleBreak}function tt(g){let h=g.type.prop(Xe);if(h)return h;let p=g.firstChild,v;if(p&&(v=p.type.prop(NodeProp.closedBy))){let M=g.lastChild,$=M&&v.indexOf(M.name)>-1;return j=>rt(j,!0,1,void 0,$&&!xt(j)?M.from:void 0)}return g.parent==null?bt:null}function bt(){return 0}class At extends null{constructor(h,p,v){super(h.state,h.options),this.base=h,this.pos=p,this.context=v}get node(){return this.context.node}static create(h,p,v){return new At(h,p,v)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(h){let p=this.state.doc.lineAt(h.from);for(;;){let v=h.resolve(p.from);for(;v.parent&&v.parent.from==v.from;)v=v.parent;if(Ot(v,h))break;p=this.state.doc.lineAt(v.from)}return this.lineIndent(p.from)}continue(){return dt(this.context.next,this.base,this.pos)}}function Ot(g,h){for(let p=h;p;p=p.parent)if(g==p)return!0;return!1}function Ti(g){let h=g.node,p=h.childAfter(h.from),v=h.lastChild;if(!p)return null;let M=g.options.simulateBreak,$=g.state.doc.lineAt(p.from),j=M==null||M<=$.from?$.to:Math.min($.to,M);for(let le=p.to;;){let ce=h.childAfter(le);if(!ce||ce==v)return null;if(!ce.type.isSkipped){if(ce.from>=j)return null;let Ie=/^ */.exec($.text.slice(p.to-$.from))[0].length;return{from:p.from,to:p.to+Ie}}le=ce.to}}function lt({closing:g,align:h=!0,units:p=1}){return v=>rt(v,h,p,g)}function rt(g,h,p,v,M){let $=g.textAfter,j=$.match(/^\s*/)[0].length,le=v&&$.slice(j,j+v.length)==v||M==g.pos+j,ce=h?Ti(g):null;return ce?le?g.column(ce.from):g.column(ce.to):g.baseIndent+(le?0:g.unit*p)}const Mi=g=>g.baseIndent;function Oi({except:g,units:h=1}={}){return p=>{let v=g&&g.test(p.textAfter);return p.baseIndent+(v?0:h*p.unit)}}const hi=200;function Pi(){return EditorState.transactionFilter.of(g=>{if(!g.docChanged||!g.isUserEvent("input.type")&&!g.isUserEvent("input.complete"))return g;let h=g.startState.languageDataAt("indentOnInput",g.startState.selection.main.head);if(!h.length)return g;let p=g.newDoc,{head:v}=g.newSelection.main,M=p.lineAt(v);if(v>M.from+hi)return g;let $=p.sliceString(M.from,v);if(!h.some(Ie=>Ie.test($)))return g;let{state:j}=g,le=-1,ce=[];for(let{head:Ie}of j.selection.ranges){let Ue=j.doc.lineAt(Ie);if(Ue.from==le)continue;le=Ue.from;let Mt=ae(j,Ue.from);if(Mt==null)continue;let Si=/^\s*/.exec(Ue.text)[0],Zt=pe(j,Mt);Si!=Zt&&ce.push({from:Ue.from,to:Ue.from+Si.length,insert:Zt})}return ce.length?[g,{changes:ce,sequential:!0}]:g})}const _i=ht.r$.define(),_=new Oe.md;function E(g){let h=g.firstChild,p=g.lastChild;return h&&h.to<p.from?{from:h.to,to:p.type.isError?g.to:p.from}:null}function q(g,h,p){let v=$t(g);if(v.length<p)return null;let M=v.resolveStack(p,1),$=null;for(let j=M;j;j=j.next){let le=j.node;if(le.to<=p||le.from>p)continue;if($&&le.from<h)break;let ce=le.type.prop(_);if(ce&&(le.to<v.length-50||v.length==g.doc.length||!K(le))){let Ie=ce(le,g);Ie&&Ie.from<=p&&Ie.from>=h&&Ie.to>p&&($=Ie)}}return $}function K(g){let h=g.lastChild;return h&&h.to==g.to&&h.type.isError}function ee(g,h,p){for(let v of g.facet(_i)){let M=v(g,h,p);if(M)return M}return q(g,h,p)}function ge(g,h){let p=h.mapPos(g.from,1),v=h.mapPos(g.to,-1);return p>=v?void 0:{from:p,to:v}}const Pe=ht.Py.define({map:ge}),Te=ht.Py.define({map:ge});function je(g){let h=[];for(let{head:p}of g.state.selection.ranges)h.some(v=>v.from<=p&&v.to>=p)||h.push(g.lineBlockAt(p));return h}const ot=ht.QQ.define({create(){return We.p.none},update(g,h){h.isUserEvent("delete")&&h.changes.iterChangedRanges((p,v)=>g=ti(g,p,v)),g=g.map(h.changes);for(let p of h.effects)if(p.is(Pe)&&!fi(g,p.value.from,p.value.to)){let{preparePlaceholder:v}=h.state.facet(R),M=v?We.p.replace({widget:new w(v(h.state,p.value))}):d;g=g.update({add:[M.range(p.value.from,p.value.to)]})}else p.is(Te)&&(g=g.update({filter:(v,M)=>p.value.from!=v||p.value.to!=M,filterFrom:p.value.from,filterTo:p.value.to}));return h.selection&&(g=ti(g,h.selection.main.head)),g},provide:g=>We.tk.decorations.from(g),toJSON(g,h){let p=[];return g.between(0,h.doc.length,(v,M)=>{p.push(v,M)}),p},fromJSON(g){if(!Array.isArray(g)||g.length%2)throw new RangeError("Invalid JSON for fold state");let h=[];for(let p=0;p<g.length;){let v=g[p++],M=g[p++];if(typeof v!="number"||typeof M!="number")throw new RangeError("Invalid JSON for fold state");h.push(d.range(v,M))}return We.p.set(h,!0)}});function ti(g,h,p=h){let v=!1;return g.between(h,p,(M,$)=>{M<p&&$>h&&(v=!0)}),v?g.update({filterFrom:h,filterTo:p,filter:(M,$)=>M>=p||$<=h}):g}function ri(g){return g.field(ot,!1)||RangeSet.empty}function ci(g,h,p){var v;let M=null;return(v=g.field(ot,!1))===null||v===void 0||v.between(h,p,($,j)=>{(!M||M.from>$)&&(M={from:$,to:j})}),M}function fi(g,h,p){let v=!1;return g.between(h,h,(M,$)=>{M==h&&$==p&&(v=!0)}),v}function qt(g,h){return g.field(ot,!1)?h:h.concat(ht.Py.appendConfig.of(o()))}const gi=g=>{for(let h of je(g)){let p=ee(g.state,h.from,h.to);if(p)return g.dispatch({effects:qt(g.state,[Pe.of(p),Ei(g,p)])}),!0}return!1},Li=g=>{if(!g.state.field(ot,!1))return!1;let h=[];for(let p of je(g)){let v=ci(g.state,p.from,p.to);v&&h.push(Te.of(v),Ei(g,v,!1))}return h.length&&g.dispatch({effects:h}),h.length>0};function Ei(g,h,p=!0){let v=g.state.doc.lineAt(h.from).number,M=g.state.doc.lineAt(h.to).number;return We.tk.announce.of(`${g.state.phrase(p?"Folded lines":"Unfolded lines")} ${v} ${g.state.phrase("to")} ${M}.`)}const Xi=g=>{let{state:h}=g,p=[];for(let v=0;v<h.doc.length;){let M=g.lineBlockAt(v),$=ee(h,M.from,M.to);$&&p.push(Pe.of($)),v=($?g.lineBlockAt($.to):M).to+1}return p.length&&g.dispatch({effects:qt(g.state,p)}),!!p.length},Pt=g=>{let h=g.state.field(ot,!1);if(!h||!h.size)return!1;let p=[];return h.between(0,g.state.doc.length,(v,M)=>{p.push(Te.of({from:v,to:M}))}),g.dispatch({effects:p}),!0};function Ji(g,h){for(let p=h;;){let v=ee(g.state,p.from,p.to);if(v&&v.to>h.from)return v;if(!p.from)return null;p=g.lineBlockAt(p.from-1)}}const sn=g=>{let h=[];for(let p of je(g)){let v=ci(g.state,p.from,p.to);if(v)h.push(Te.of(v),Ei(g,v,!1));else{let M=Ji(g,p);M&&h.push(Pe.of(M),Ei(g,M))}}return h.length>0&&g.dispatch({effects:qt(g.state,h)}),!!h.length},an=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:gi},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Li},{key:"Ctrl-Alt-[",run:Xi},{key:"Ctrl-Alt-]",run:Pt}],oi={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},R=ht.r$.define({combine(g){return(0,ht.BO)(g,oi)}});function o(g){let h=[ot,Y];return g&&h.push(R.of(g)),h}function a(g,h){let{state:p}=g,v=p.facet(R),M=j=>{let le=g.lineBlockAt(g.posAtDOM(j.target)),ce=ci(g.state,le.from,le.to);ce&&g.dispatch({effects:Te.of(ce)}),j.preventDefault()};if(v.placeholderDOM)return v.placeholderDOM(g,M,h);let $=document.createElement("span");return $.textContent=v.placeholderText,$.setAttribute("aria-label",p.phrase("folded code")),$.title=p.phrase("unfold"),$.className="cm-foldPlaceholder",$.onclick=M,$}const d=We.p.replace({widget:new class extends We.l9{toDOM(g){return a(g,null)}}});class w extends We.l9{constructor(h){super(),this.value=h}eq(h){return this.value==h.value}toDOM(h){return a(h,this.value)}}const D={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class O extends null{constructor(h,p){super(),this.config=h,this.open=p}eq(h){return this.config==h.config&&this.open==h.open}toDOM(h){if(this.config.markerDOM)return this.config.markerDOM(this.open);let p=document.createElement("span");return p.textContent=this.open?this.config.openText:this.config.closedText,p.title=h.state.phrase(this.open?"Fold line":"Unfold line"),p}}function H(g={}){let h={...D,...g},p=new O(h,!0),v=new O(h,!1),M=ViewPlugin.fromClass(class{constructor(j){this.from=j.viewport.from,this.markers=this.buildMarkers(j)}update(j){(j.docChanged||j.viewportChanged||j.startState.facet(Ct)!=j.state.facet(Ct)||j.startState.field(ot,!1)!=j.state.field(ot,!1)||$t(j.startState)!=$t(j.state)||h.foldingChanged(j))&&(this.markers=this.buildMarkers(j.view))}buildMarkers(j){let le=new RangeSetBuilder;for(let ce of j.viewportLineBlocks){let Ie=ci(j.state,ce.from,ce.to)?v:ee(j.state,ce.from,ce.to)?p:null;Ie&&le.add(ce.from,ce.from,Ie)}return le.finish()}}),{domEventHandlers:$}=h;return[M,gutter({class:"cm-foldGutter",markers(j){var le;return((le=j.plugin(M))===null||le===void 0?void 0:le.markers)||RangeSet.empty},initialSpacer(){return new O(h,!1)},domEventHandlers:{...$,click:(j,le,ce)=>{if($.click&&$.click(j,le,ce))return!0;let Ie=ci(j.state,le.from,le.to);if(Ie)return j.dispatch({effects:Te.of(Ie)}),!0;let Ue=ee(j.state,le.from,le.to);return Ue?(j.dispatch({effects:Pe.of(Ue)}),!0):!1}}}),o()]}const Y=We.tk.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 ue{constructor(h,p){this.specs=h;let v;function M(le){let ce=di.V.newName();return(v||(v=Object.create(null)))["."+ce]=le,ce}const $=typeof p.all=="string"?p.all:p.all?M(p.all):void 0,j=p.scope;this.scope=j instanceof kt?le=>le.prop(Xt)==j.data:j?le=>le==j:void 0,this.style=(0,Je.QR)(h.map(le=>({tag:le.tag,class:le.class||M(Object.assign({},le,{tag:null}))})),{all:$}).style,this.module=v?new di.V(v):null,this.themeType=p.themeType}static define(h,p){return new ue(h,p||{})}}const ve=ht.r$.define(),Ee=ht.r$.define({combine(g){return g.length?[g[0]]:null}});function ze(g){let h=g.facet(ve);return h.length?h:g.facet(Ee)}function $e(g,h){let p=[ii],v;return g instanceof ue&&(g.module&&p.push(EditorView.styleModule.of(g.module)),v=g.themeType),h!=null&&h.fallback?p.push(Ee.of(g)):v?p.push(ve.computeN([EditorView.darkTheme],M=>M.facet(EditorView.darkTheme)==(v=="dark")?[g]:[])):p.push(ve.of(g)),p}function jt(g,h,p){let v=ze(g),M=null;if(v){for(let $ of v)if(!$.scope||p&&$.scope(p)){let j=$.style(h);j&&(M=M?M+" "+j:j)}}return M}class Fi{constructor(h){this.markCache=Object.create(null),this.tree=$t(h.state),this.decorations=this.buildDeco(h,ze(h.state)),this.decoratedTo=h.viewport.to}update(h){let p=$t(h.state),v=ze(h.state),M=v!=ze(h.startState),{viewport:$}=h.view,j=h.changes.mapPos(this.decoratedTo,1);p.length<$.to&&!M&&p.type==this.tree.type&&j>=$.to?(this.decorations=this.decorations.map(h.changes),this.decoratedTo=j):(p!=this.tree||h.viewportChanged||M)&&(this.tree=p,this.decorations=this.buildDeco(h.view,v),this.decoratedTo=$.to)}buildDeco(h,p){if(!p||!this.tree.length)return We.p.none;let v=new ht.f_;for(let{from:M,to:$}of h.visibleRanges)(0,Je.bW)(this.tree,p,(j,le,ce)=>{v.add(j,le,this.markCache[ce]||(this.markCache[ce]=We.p.mark({class:ce})))},M,$);return v.finish()}}const ii=ht.Wl.high(We.lg.fromClass(Fi,{decorations:g=>g.decorations})),Qi=ue.define([{tag:Je.pJ.meta,color:"#404740"},{tag:Je.pJ.link,textDecoration:"underline"},{tag:Je.pJ.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Je.pJ.emphasis,fontStyle:"italic"},{tag:Je.pJ.strong,fontWeight:"bold"},{tag:Je.pJ.strikethrough,textDecoration:"line-through"},{tag:Je.pJ.keyword,color:"#708"},{tag:[Je.pJ.atom,Je.pJ.bool,Je.pJ.url,Je.pJ.contentSeparator,Je.pJ.labelName],color:"#219"},{tag:[Je.pJ.literal,Je.pJ.inserted],color:"#164"},{tag:[Je.pJ.string,Je.pJ.deleted],color:"#a11"},{tag:[Je.pJ.regexp,Je.pJ.escape,Je.pJ.special(Je.pJ.string)],color:"#e40"},{tag:Je.pJ.definition(Je.pJ.variableName),color:"#00f"},{tag:Je.pJ.local(Je.pJ.variableName),color:"#30a"},{tag:[Je.pJ.typeName,Je.pJ.namespace],color:"#085"},{tag:Je.pJ.className,color:"#167"},{tag:[Je.pJ.special(Je.pJ.variableName),Je.pJ.macroName],color:"#256"},{tag:Je.pJ.definition(Je.pJ.propertyName),color:"#00c"},{tag:Je.pJ.comment,color:"#940"},{tag:Je.pJ.invalid,color:"#f00"}]),Ki=We.tk.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Ui=1e4,rn="()[]{}",P=ht.r$.define({combine(g){return(0,ht.BO)(g,{afterCursor:!0,brackets:rn,maxScanDistance:Ui,renderMatch:L})}}),y=We.p.mark({class:"cm-matchingBracket"}),x=We.p.mark({class:"cm-nonmatchingBracket"});function L(g){let h=[],p=g.matched?y:x;return h.push(p.range(g.start.from,g.start.to)),g.end&&h.push(p.range(g.end.from,g.end.to)),h}const G=[ht.QQ.define({create(){return We.p.none},update(g,h){if(!h.docChanged&&!h.selection)return g;let p=[],v=h.state.facet(P);for(let M of h.state.selection.ranges){if(!M.empty)continue;let $=Ce(h.state,M.head,-1,v)||M.head>0&&Ce(h.state,M.head-1,1,v)||v.afterCursor&&(Ce(h.state,M.head,1,v)||M.head<h.state.doc.length&&Ce(h.state,M.head+1,-1,v));$&&(p=p.concat(v.renderMatch($,h.state)))}return We.p.set(p,!0)},provide:g=>We.tk.decorations.from(g)}),Ki];function oe(g={}){return[P.of(g),G]}const de=new Oe.md;function fe(g,h,p){let v=g.prop(h<0?Oe.md.openedBy:Oe.md.closedBy);if(v)return v;if(g.name.length==1){let M=p.indexOf(g.name);if(M>-1&&M%2==(h<0?1:0))return[p[M+h]]}return null}function Me(g){let h=g.type.prop(de);return h?h(g.node):g}function Ce(g,h,p,v={}){let M=v.maxScanDistance||Ui,$=v.brackets||rn,j=$t(g),le=j.resolveInner(h,p);for(let ce=le;ce;ce=ce.parent){let Ie=fe(ce.type,p,$);if(Ie&&ce.from<ce.to){let Ue=Me(ce);if(Ue&&(p>0?h>=Ue.from&&h<Ue.to:h>Ue.from&&h<=Ue.to))return _e(g,h,p,ce,Ue,Ie,$)}}return wt(g,h,p,j,le.type,M,$)}function _e(g,h,p,v,M,$,j){let le=v.parent,ce={from:M.from,to:M.to},Ie=0,Ue=le==null?void 0:le.cursor();if(Ue&&(p<0?Ue.childBefore(v.from):Ue.childAfter(v.to)))do if(p<0?Ue.to<=v.from:Ue.from>=v.to){if(Ie==0&&$.indexOf(Ue.type.name)>-1&&Ue.from<Ue.to){let Mt=Me(Ue);return{start:ce,end:Mt?{from:Mt.from,to:Mt.to}:void 0,matched:!0}}else if(fe(Ue.type,p,j))Ie++;else if(fe(Ue.type,-p,j)){if(Ie==0){let Mt=Me(Ue);return{start:ce,end:Mt&&Mt.from<Mt.to?{from:Mt.from,to:Mt.to}:void 0,matched:!1}}Ie--}}while(p<0?Ue.prevSibling():Ue.nextSibling());return{start:ce,matched:!1}}function wt(g,h,p,v,M,$,j){let le=p<0?g.sliceDoc(h-1,h):g.sliceDoc(h,h+1),ce=j.indexOf(le);if(ce<0||ce%2==0!=p>0)return null;let Ie={from:p<0?h-1:h,to:p>0?h+1:h},Ue=g.doc.iterRange(h,p>0?g.doc.length:0),Mt=0;for(let Si=0;!Ue.next().done&&Si<=$;){let Zt=Ue.value;p<0&&(Si+=Zt.length);let $i=h+Si*p;for(let Gi=p>0?0:Zt.length-1,ln=p>0?Zt.length:-1;Gi!=ln;Gi+=p){let un=j.indexOf(Zt[Gi]);if(!(un<0||v.resolveInner($i+Gi,1).type!=M))if(un%2==0==p>0)Mt++;else{if(Mt==1)return{start:Ie,end:{from:$i+Gi,to:$i+Gi+1},matched:un>>1==ce>>1};Mt--}}p>0&&(Si+=Zt.length)}return Ue.done?{start:Ie,matched:!1}:null}function Wt(g,h,p,v=0,M=0){h==null&&(h=g.search(/[^\s\u00a0]/),h==-1&&(h=g.length));let $=M;for(let j=v;j<h;j++)g.charCodeAt(j)==9?$+=p-$%p:$++;return $}class li{constructor(h,p,v,M){this.string=h,this.tabSize=p,this.indentUnit=v,this.overrideIndent=M,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(h){let p=this.string.charAt(this.pos),v;if(typeof h=="string"?v=p==h:v=p&&(h instanceof RegExp?h.test(p):h(p)),v)return++this.pos,p}eatWhile(h){let p=this.pos;for(;this.eat(h););return this.pos>p}eatSpace(){let h=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>h}skipToEnd(){this.pos=this.string.length}skipTo(h){let p=this.string.indexOf(h,this.pos);if(p>-1)return this.pos=p,!0}backUp(h){this.pos-=h}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Wt(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var h;return(h=this.overrideIndent)!==null&&h!==void 0?h:Wt(this.string,null,this.tabSize)}match(h,p,v){if(typeof h=="string"){let M=j=>v?j.toLowerCase():j,$=this.string.substr(this.pos,h.length);return M($)==M(h)?(p!==!1&&(this.pos+=h.length),!0):null}else{let M=this.string.slice(this.pos).match(h);return M&&M.index>0?null:(M&&p!==!1&&(this.pos+=M[0].length),M)}}current(){return this.string.slice(this.start,this.pos)}}function yi(g){return{name:g.name||"",token:g.token,blankLine:g.blankLine||(()=>{}),startState:g.startState||(()=>!0),copyState:g.copyState||Di,indent:g.indent||(()=>null),languageData:g.languageData||{},tokenTable:g.tokenTable||f,mergeTokens:g.mergeTokens!==!1}}function Di(g){if(typeof g!="object")return g;let h={};for(let p in g){let v=g[p];h[p]=v instanceof Array?v.slice():v}return h}const xi=new WeakMap;class Qt extends null{constructor(h){let p=si(h.languageData),v=yi(h),M,$=new class extends Parser{createParse(j,le,ce){return new Zi(M,j,le,ce)}};super(p,$,[],h.name),this.topNode=_t(p,this),M=this,this.streamParser=v,this.stateAfter=new NodeProp({perNode:!0}),this.tokenTable=h.tokenTable?new be(v.tokenTable):me}static define(h){return new Qt(h)}getIndent(h){let p,{overrideIndentation:v}=h.options;v&&(p=xi.get(h.state),p!=null&&p<h.pos-1e4&&(p=void 0));let M=Vi(this,h.node.tree,h.node.from,h.node.from,p??h.pos),$,j;if(M?(j=M.state,$=M.pos+1):(j=this.streamParser.startState(h.unit),$=h.node.from),h.pos-$>1e4)return null;for(;$<h.pos;){let ce=h.state.doc.lineAt($),Ie=Math.min(h.pos,ce.to);if(ce.length){let Ue=v?v(ce.from):-1,Mt=new li(ce.text,h.state.tabSize,h.unit,Ue<0?void 0:Ue);for(;Mt.pos<Ie-ce.from;)A(this.streamParser.token,Mt,j)}else this.streamParser.blankLine(j,h.unit);if(Ie==h.pos)break;$=ce.to+1}let le=h.lineAt(h.pos);return v&&p==null&&xi.set(h.state,le.from),this.streamParser.indent(j,/^\s*(.*)/.exec(le.text)[1],h)}get allowsNesting(){return!1}}function Vi(g,h,p,v,M){let $=p>=v&&p+h.length<=M&&h.prop(g.stateAfter);if($)return{state:g.streamParser.copyState($),pos:p+h.length};for(let j=h.children.length-1;j>=0;j--){let le=h.children[j],ce=p+h.positions[j],Ie=le instanceof Tree&&ce<M&&Vi(g,le,ce,v,M);if(Ie)return Ie}return null}function Bi(g,h,p,v,M){if(M&&p<=0&&v>=h.length)return h;!M&&p==0&&h.type==g.topNode&&(M=!0);for(let $=h.children.length-1;$>=0;$--){let j=h.positions[$],le=h.children[$],ce;if(j<v&&le instanceof Tree){if(!(ce=Bi(g,le,p-j,v-j,M)))break;return M?new Tree(h.type,h.children.slice(0,$).concat(ce),h.positions.slice(0,$+1),j+ce.length):ce}}return null}function Ri(g,h,p,v,M){for(let $ of h){let j=$.from+($.openStart?25:0),le=$.to-($.openEnd?25:0),ce=j<=p&&le>p&&Vi(g,$.tree,0-$.offset,p,le),Ie;if(ce&&ce.pos<=v&&(Ie=Bi(g,$.tree,p+$.offset,ce.pos+$.offset,!1)))return{state:ce.state,tree:Ie}}return{state:g.streamParser.startState(M?X(M):4),tree:Tree.empty}}class Zi{constructor(h,p,v,M){this.lang=h,this.input=p,this.fragments=v,this.ranges=M,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=M[M.length-1].to;let $=Re.get(),j=M[0].from,{state:le,tree:ce}=Ri(h,v,j,this.to,$==null?void 0:$.state);this.state=le,this.parsedPos=this.chunkStart=j+ce.length;for(let Ie=0;Ie<ce.children.length;Ie++)this.chunks.push(ce.children[Ie]),this.chunkPos.push(ce.positions[Ie]);$&&this.parsedPos<$.viewport.from-1e5&&M.some(Ie=>Ie.from<=$.viewport.from&&Ie.to>=$.viewport.from)&&(this.state=this.lang.streamParser.startState(X($.state)),$.skipUntilInView(this.parsedPos,$.viewport.from),this.parsedPos=$.viewport.from),this.moveRangeIndex()}advance(){let h=Re.get(),p=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),v=Math.min(p,this.chunkStart+512);for(h&&(v=Math.min(v,h.viewport.to));this.parsedPos<v;)this.parseLine(h);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=p?this.finish():h&&this.parsedPos>=h.viewport.to?(h.skipUntilInView(this.parsedPos,p),this.finish()):null}stopAt(h){this.stoppedAt=h}lineAfter(h){let p=this.input.chunk(h);if(this.input.lineChunks)p==`
2
+ `&&(p="");else{let v=p.indexOf(`
3
+ `);v>-1&&(p=p.slice(0,v))}return h+p.length<=this.to?p:p.slice(0,this.to-h)}nextLine(){let h=this.parsedPos,p=this.lineAfter(h),v=h+p.length;for(let M=this.rangeIndex;;){let $=this.ranges[M].to;if($>=v||(p=p.slice(0,$-(v-p.length)),M++,M==this.ranges.length))break;let j=this.ranges[M].from,le=this.lineAfter(j);p+=le,v=j+le.length}return{line:p,end:v}}skipGapsTo(h,p,v){for(;;){let M=this.ranges[this.rangeIndex].to,$=h+p;if(v>0?M>$:M>=$)break;let j=this.ranges[++this.rangeIndex].from;p+=j-M}return p}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(h,p,v,M){let $=4;if(this.ranges.length>1){M=this.skipGapsTo(p,M,1),p+=M;let le=this.chunk.length;M=this.skipGapsTo(v,M,-1),v+=M,$+=this.chunk.length-le}let j=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&$==4&&j>=0&&this.chunk[j]==h&&this.chunk[j+2]==p?this.chunk[j+2]=v:this.chunk.push(h,p,v,$),M}parseLine(h){let{line:p,end:v}=this.nextLine(),M=0,{streamParser:$}=this.lang,j=new li(p,h?h.state.tabSize:4,h?X(h.state):2);if(j.eol())$.blankLine(this.state,j.indentUnit);else for(;!j.eol();){let le=A($.token,j,this.state);if(le&&(M=this.emitToken(this.lang.tokenTable.resolve(le),this.parsedPos+j.start,this.parsedPos+j.pos,M)),j.start>1e4)break}this.parsedPos=v,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let h=Tree.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:B,topID:0,maxBufferLength:512,reused:this.chunkReused});h=new Tree(h.type,h.children,h.positions,h.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(h),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new Tree(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function A(g,h,p){h.start=h.pos;for(let v=0;v<10;v++){let M=g(h,p);if(h.pos>h.start)return M}throw new Error("Stream parser failed to advance stream.")}const f=Object.create(null),b=[Oe.Jq.none],B=new Oe.Lj(b),F=[],U=Object.create(null),Z=Object.create(null);for(let[g,h]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"]])Z[g]=Ke(f,h);class be{constructor(h){this.extra=h,this.table=Object.assign(Object.create(null),Z)}resolve(h){return h?this.table[h]||(this.table[h]=Ke(this.extra,h)):0}}const me=new be(f);function Ne(g,h){F.indexOf(g)>-1||(F.push(g),console.warn(h))}function Ke(g,h){let p=[];for(let le of h.split(" ")){let ce=[];for(let Ie of le.split(".")){let Ue=g[Ie]||Je.pJ[Ie];Ue?typeof Ue=="function"?ce.length?ce=ce.map(Ue):Ne(Ie,`Modifier ${Ie} used at start of tag`):ce.length?Ne(Ie,`Tag ${Ie} used as modifier`):ce=Array.isArray(Ue)?Ue:[Ue]:Ne(Ie,`Unknown highlighting tag ${Ie}`)}for(let Ie of ce)p.push(Ie)}if(!p.length)return 0;let v=h.replace(/ /g,"_"),M=v+" "+p.map(le=>le.id),$=U[M];if($)return $.id;let j=U[M]=Oe.Jq.define({id:b.length,name:v,props:[(0,Je.Gv)({[v]:p})]});return b.push(j),j.id}function _t(g,h){let p=NodeType.define({id:b.length,name:"Document",props:[Xt.add(()=>g),Xe.add(()=>v=>h.getIndent(v))],top:!0});return b.push(p),p}function Wi(g){return g.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(g)}function Ii(g){for(let h=g.iter();!h.next().done;)if(Wi(h.value))return!0;return!1}function en(g){let h=!1;return g.iterChanges((p,v,M,$,j)=>{!h&&Ii(j)&&(h=!0)}),h}const Yi=ht.r$.define({combine:g=>g.some(h=>h)});function kn(g={}){let h=[mn];return g.alwaysIsolate&&h.push(Yi.of(!0)),h}const mn=We.lg.fromClass(class{constructor(g){this.always=g.state.facet(Yi)||g.textDirection!=We.Nm.LTR||g.state.facet(We.tk.perLineTextDirection),this.hasRTL=!this.always&&Ii(g.state.doc),this.tree=$t(g.state),this.decorations=this.always||this.hasRTL?Bn(g,this.tree,this.always):We.p.none}update(g){let h=g.state.facet(Yi)||g.view.textDirection!=We.Nm.LTR||g.state.facet(We.tk.perLineTextDirection);if(!h&&!this.hasRTL&&en(g.changes)&&(this.hasRTL=!0),!h&&!this.hasRTL)return;let p=$t(g.state);(h!=this.always||p!=this.tree||g.docChanged||g.viewportChanged)&&(this.tree=p,this.always=h,this.decorations=Bn(g.view,p,h))}},{provide:g=>{function h(p){var v,M;return(M=(v=p.plugin(g))===null||v===void 0?void 0:v.decorations)!==null&&M!==void 0?M:We.p.none}return[We.tk.outerDecorations.of(h),ht.Wl.lowest(We.tk.bidiIsolatedRanges.of(h))]}});function Bn(g,h,p){let v=new ht.f_,M=g.visibleRanges;p||(M=Kn(M,g.state.doc));for(let{from:$,to:j}of M)h.iterate({enter:le=>{let ce=le.type.prop(Oe.md.isolate);ce&&v.add(le.from,le.to,Vn[ce])},from:$,to:j});return v.finish()}function Kn(g,h){let p=h.iter(),v=0,M=[],$=null;for(let{from:j,to:le}of g)if(!($&&$.to>j&&(j=$.to,j>=le)))for(v+p.value.length<j&&(p.next(j-(v+p.value.length)),v=j);;){let ce=v,Ie=v+p.value.length;if(!p.lineBreak&&Wi(p.value)&&($&&$.to>ce-10?$.to=Math.min(le,Ie):M.push($={from:ce,to:Math.min(le,Ie)})),Ie>=le)break;v=Ie,p.next()}return M}const Vn={rtl:We.p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:We.Nm.RTL}),ltr:We.p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:We.Nm.LTR}),auto:We.p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})},tn=["_blank","_self","_top","_parent"],gn=["ascii","utf-8","utf-16","latin1","latin1"],on=["get","post","put","delete"],yn=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Hi=["true","false"],Ge={},Ln={a:{attrs:{href:null,ping:null,type:null,media:null,target:tn,hreflang:null}},abbr:Ge,address:Ge,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:Ge,aside:Ge,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:Ge,base:{attrs:{href:null,target:tn}},bdi:Ge,bdo:Ge,blockquote:{attrs:{cite:null}},body:Ge,br:Ge,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:yn,formmethod:on,formnovalidate:["novalidate"],formtarget:tn,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:Ge,center:Ge,cite:Ge,code:Ge,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:Ge,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:Ge,div:Ge,dl:Ge,dt:Ge,em:Ge,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:Ge,figure:Ge,footer:Ge,form:{attrs:{action:null,name:null,"accept-charset":gn,autocomplete:["on","off"],enctype:yn,method:on,novalidate:["novalidate"],target:tn}},h1:Ge,h2:Ge,h3:Ge,h4:Ge,h5:Ge,h6:Ge,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:Ge,hgroup:Ge,hr:Ge,html:{attrs:{manifest:null}},i:Ge,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:yn,formmethod:on,formnovalidate:["novalidate"],formtarget:tn,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:Ge,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:Ge,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:Ge,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:gn,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:Ge,noscript:Ge,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:Ge,param:{attrs:{name:null,value:null}},pre:Ge,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:Ge,rt:Ge,ruby:Ge,samp:Ge,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:gn}},section:Ge,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:Ge,source:{attrs:{src:null,type:null,media:null}},span:Ge,strong:Ge,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:Ge,summary:Ge,sup:Ge,table:Ge,tbody:Ge,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:Ge,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:Ge,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:Ge,time:{attrs:{datetime:null}},title:Ge,tr:Ge,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:Ge,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:Ge},Tn={accesskey:null,class:null,contenteditable:Hi,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Hi,autocorrect:Hi,autocapitalize:Hi,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Hi,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Hi,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Hi,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Hi,"aria-hidden":Hi,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Hi,"aria-multiselectable":Hi,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Hi,"aria-relevant":null,"aria-required":Hi,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Mn="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(g=>"on"+g);for(let g of Mn)Tn[g]=null;class xn{constructor(h,p){this.tags={...Ln,...h},this.globalAttrs={...Tn,...p},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}xn.default=new xn;function hn(g,h,p=g.length){if(!h)return"";let v=h.firstChild,M=v&&v.getChild("TagName");return M?g.sliceString(M.from,Math.min(M.to,p)):""}function cn(g,h=!1){for(;g;g=g.parent)if(g.name=="Element")if(h)h=!1;else return g;return null}function Rn(g,h,p){let v=p.tags[hn(g,cn(h))];return(v==null?void 0:v.children)||p.allTags}function In(g,h){let p=[];for(let v=cn(h);v&&!v.type.isTop;v=cn(v.parent)){let M=hn(g,v);if(M&&v.lastChild.name=="CloseTag")break;M&&p.indexOf(M)<0&&(h.name=="EndTag"||h.from>=v.firstChild.to)&&p.push(M)}return p}const u=/^[:\-\.\w\u00b7-\uffff]*$/;function S(g,h,p,v,M){let $=/\s*>/.test(g.sliceDoc(M,M+5))?"":">",j=cn(p,!0);return{from:v,to:M,options:Rn(g.doc,j,h).map(le=>({label:le,type:"type"})).concat(In(g.doc,p).map((le,ce)=>({label:"/"+le,apply:"/"+le+$,type:"type",boost:99-ce}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function V(g,h,p,v){let M=/\s*>/.test(g.sliceDoc(v,v+5))?"":">";return{from:p,to:v,options:In(g.doc,h).map(($,j)=>({label:$,apply:$+M,type:"type",boost:99-j})),validFor:u}}function W(g,h,p,v){let M=[],$=0;for(let j of Rn(g.doc,p,h))M.push({label:"<"+j,type:"type"});for(let j of In(g.doc,p))M.push({label:"</"+j+">",type:"type",boost:99-$++});return{from:v,to:v,options:M,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function Q(g,h,p,v,M){let $=cn(p),j=$?h.tags[hn(g.doc,$)]:null,le=j&&j.attrs?Object.keys(j.attrs):[],ce=j&&j.globalAttrs===!1?le:le.length?le.concat(h.globalAttrNames):h.globalAttrNames;return{from:v,to:M,options:ce.map(Ie=>({label:Ie,type:"property"})),validFor:u}}function J(g,h,p,v,M){var $;let j=($=p.parent)===null||$===void 0?void 0:$.getChild("AttributeName"),le=[],ce;if(j){let Ie=g.sliceDoc(j.from,j.to),Ue=h.globalAttrs[Ie];if(!Ue){let Mt=cn(p),Si=Mt?h.tags[hn(g.doc,Mt)]:null;Ue=(Si==null?void 0:Si.attrs)&&Si.attrs[Ie]}if(Ue){let Mt=g.sliceDoc(v,M).toLowerCase(),Si='"',Zt='"';/^['"]/.test(Mt)?(ce=Mt[0]=='"'?/^[^"]*$/:/^[^']*$/,Si="",Zt=g.sliceDoc(M,M+1)==Mt[0]?"":Mt[0],Mt=Mt.slice(1),v++):ce=/^[^\s<>='"]*$/;for(let $i of Ue)le.push({label:$i,apply:Si+$i+Zt,type:"constant"})}}return{from:v,to:M,options:le,validFor:ce}}function ne(g,h){let{state:p,pos:v}=h,M=$t(p).resolveInner(v,-1),$=M.resolve(v);for(let j=v,le;$==M&&(le=M.childBefore(j));){let ce=le.lastChild;if(!ce||!ce.type.isError||ce.from<ce.to)break;$=M=le,j=ce.from}return M.name=="TagName"?M.parent&&/CloseTag$/.test(M.parent.name)?V(p,M,M.from,v):S(p,g,M,M.from,v):M.name=="StartTag"?S(p,g,M,v,v):M.name=="StartCloseTag"||M.name=="IncompleteCloseTag"?V(p,M,v,v):M.name=="OpenTag"||M.name=="SelfClosingTag"||M.name=="AttributeName"?Q(p,g,M,M.name=="AttributeName"?M.from:v,v):M.name=="Is"||M.name=="AttributeValue"||M.name=="UnquotedAttributeValue"?J(p,g,M,M.name=="Is"?v:M.from,v):h.explicit&&($.name=="Element"||$.name=="Text"||$.name=="Document")?W(p,g,M,v):null}function Se(g){return ne(xn.default,g)}function He(g){let{extraTags:h,extraGlobalAttributes:p}=g,v=p||h?new xn(h,p):xn.default;return M=>ne(v,M)}const vt=et.Lz.parser.configure({top:"SingleExpression"}),ct=[{tag:"script",attrs:g=>g.type=="text/typescript"||g.lang=="ts",parser:et.ev.parser},{tag:"script",attrs:g=>g.type=="text/babel"||g.type=="text/jsx",parser:et.uh.parser},{tag:"script",attrs:g=>g.type=="text/typescript-jsx",parser:et._v.parser},{tag:"script",attrs(g){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(g.type)},parser:vt},{tag:"script",attrs(g){return!g.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(g.type)},parser:et.Lz.parser},{tag:"style",attrs(g){return(!g.lang||g.lang=="css")&&(!g.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(g.type))},parser:Ft.parser}],Vt=[{name:"style",parser:Ft.parser.configure({top:"Styles"})}].concat(Mn.map(g=>({name:g,parser:et.Lz.parser}))),ni=It.define({name:"html",parser:T.E.configure({props:[Xe.add({Element(g){let h=/^(\s*)(<\/)?/.exec(g.textAfter);return g.node.to<=g.pos+h[0].length?g.continue():g.lineIndent(g.node.from)+(h[2]?0:g.unit)},"OpenTag CloseTag SelfClosingTag"(g){return g.column(g.node.from)+g.unit},Document(g){if(g.pos+/\s*/.exec(g.textAfter)[0].length<g.node.to)return g.continue();let h=null,p;for(let v=g.node;;){let M=v.lastChild;if(!M||M.name!="Element"||M.to!=v.to)break;h=v=M}return h&&!((p=h.lastChild)&&(p.name=="CloseTag"||p.name=="SelfClosingTag"))?g.lineIndent(h.from)+g.unit:null}}),_.add({Element(g){let h=g.firstChild,p=g.lastChild;return!h||h.name!="OpenTag"?null:{from:h.to,to:p.name=="CloseTag"?p.from:g.to}}}),de.add({"OpenTag CloseTag":g=>g.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),ai=ni.configure({wrap:(0,T.X)(ct,Vt)});function ui(g={}){let h="",p;g.matchClosingTags===!1&&(h="noMatch"),g.selfClosingTags===!0&&(h=(h?h+" ":"")+"selfClosing"),(g.nestedLanguages&&g.nestedLanguages.length||g.nestedAttributes&&g.nestedAttributes.length)&&(p=(0,T.X)((g.nestedLanguages||[]).concat(ct),(g.nestedAttributes||[]).concat(Vt)));let v=p?ni.configure({wrap:p,dialect:h}):h?ai.configure({dialect:h}):ai;return new De(v,[ai.data.of({autocomplete:He(g)}),g.autoCloseTags!==!1?ms:[],(0,et.eJ)().support,Tt().support])}const fn=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),ms=We.tk.inputHandler.of((g,h,p,v,M)=>{if(g.composing||g.state.readOnly||h!=p||v!=">"&&v!="/"||!ai.isActiveAt(g.state,h,-1))return!1;let $=M(),{state:j}=$,le=j.changeByRange(ce=>{var Ie,Ue,Mt;let Si=j.doc.sliceString(ce.from-1,ce.to)==v,{head:Zt}=ce,$i=$t(j).resolveInner(Zt,-1),Gi;if(Si&&v==">"&&$i.name=="EndTag"){let ln=$i.parent;if(((Ue=(Ie=ln.parent)===null||Ie===void 0?void 0:Ie.lastChild)===null||Ue===void 0?void 0:Ue.name)!="CloseTag"&&(Gi=hn(j.doc,ln.parent,Zt))&&!fn.has(Gi)){let un=Zt+(j.doc.sliceString(Zt,Zt+1)===">"?1:0),Dn=`</${Gi}>`;return{range:ce,changes:{from:Zt,to:un,insert:Dn}}}}else if(Si&&v=="/"&&$i.name=="IncompleteCloseTag"){let ln=$i.parent;if($i.from==Zt-2&&((Mt=ln.lastChild)===null||Mt===void 0?void 0:Mt.name)!="CloseTag"&&(Gi=hn(j.doc,ln,Zt))&&!fn.has(Gi)){let un=Zt+(j.doc.sliceString(Zt,Zt+1)===">"?1:0),Dn=`${Gi}>`;return{range:ht.jT.cursor(Zt+Dn.length,-1),changes:{from:Zt,to:un,insert:Dn}}}}return{range:ce}});return le.changes.empty?!1:(g.dispatch([$,j.update(le,{userEvent:"input.complete",scrollIntoView:!0})]),!0)})},13249:function(pn,Ni,it){it.d(Ni,{Lz:function(){return et},_v:function(){return di},eJ:function(){return nt},ev:function(){return ht},uh:function(){return Je}});var T=it(43150),re=it(59119),te=it(78120),Oe=it(47421),ut=it(34790),Lt=it(41113);const Nt=[(0,ut.Gn)("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),(0,ut.Gn)("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),(0,ut.Gn)("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),(0,ut.Gn)("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),(0,ut.Gn)("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),(0,ut.Gn)(`try {
4
+ \${}
5
+ } catch (\${error}) {
6
+ \${}
7
+ }`,{label:"try",detail:"/ catch block",type:"keyword"}),(0,ut.Gn)("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),(0,ut.Gn)(`if (\${}) {
8
+ \${}
9
+ } else {
10
+ \${}
11
+ }`,{label:"if",detail:"/ else block",type:"keyword"}),(0,ut.Gn)(`class \${name} {
12
+ constructor(\${params}) {
13
+ \${}
14
+ }
15
+ }`,{label:"class",detail:"definition",type:"keyword"}),(0,ut.Gn)('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),(0,ut.Gn)('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],Jt=Nt.concat([(0,ut.Gn)("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),(0,ut.Gn)("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),(0,ut.Gn)("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),Kt=new Lt.hr,St=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Dt(ye){return(Be,Le)=>{let Re=Be.node.getChild("VariableDefinition");return Re&&Le(Re,ye),!0}}const Rt=["FunctionDeclaration"],Ze={FunctionDeclaration:Dt("function"),ClassDeclaration:Dt("class"),ClassExpression:()=>!0,EnumDeclaration:Dt("constant"),TypeAliasDeclaration:Dt("type"),NamespaceDeclaration:Dt("namespace"),VariableDefinition(ye,Be){ye.matchContext(Rt)||Be(ye,"variable")},TypeDefinition(ye,Be){Be(ye,"type")},__proto__:null};function wi(ye,Be){let Le=Kt.get(Be);if(Le)return Le;let Re=[],Ye=!0;function st(Ve,yt){let ei=ye.sliceString(Ve.from,Ve.to);Re.push({label:ei,type:yt})}return Be.cursor(Lt.vj.IncludeAnonymous).iterate(Ve=>{if(Ye)Ye=!1;else if(Ve.name){let yt=Ze[Ve.name];if(yt&&yt(Ve,st)||St.has(Ve.name))return!1}else if(Ve.to-Ve.from>8192){for(let yt of wi(ye,Ve.node))Re.push(yt);return!1}}),Kt.set(Be,Re),Re}const Ut=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Ai=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function pi(ye){let Be=(0,re.qz)(ye.state).resolveInner(ye.pos,-1);if(Ai.indexOf(Be.name)>-1)return null;let Le=Be.name=="VariableName"||Be.to-Be.from<20&&Ut.test(ye.state.sliceDoc(Be.from,Be.to));if(!Le&&!ye.explicit)return null;let Re=[];for(let Ye=Be;Ye;Ye=Ye.parent)St.has(Ye.name)&&(Re=Re.concat(wi(ye.state.doc,Ye)));return{options:Re,from:Le?Be.from:ye.pos,validFor:Ut}}function mi(ye,Be,Le){var Re;let Ye=[];for(;;){let st=Be.firstChild,Ve;if((st==null?void 0:st.name)=="VariableName")return Ye.push(ye(st)),{path:Ye.reverse(),name:Le};if((st==null?void 0:st.name)=="MemberExpression"&&((Re=Ve=st.lastChild)===null||Re===void 0?void 0:Re.name)=="PropertyName")Ye.push(ye(Ve)),Be=st;else return null}}function Gt(ye){let Be=Re=>ye.state.doc.sliceString(Re.from,Re.to),Le=syntaxTree(ye.state).resolveInner(ye.pos,-1);return Le.name=="PropertyName"?mi(Be,Le.parent,Be(Le)):(Le.name=="."||Le.name=="?.")&&Le.parent.name=="MemberExpression"?mi(Be,Le.parent,""):Ai.indexOf(Le.name)>-1?null:Le.name=="VariableName"||Le.to-Le.from<20&&Ut.test(Be(Le))?{path:[],name:Be(Le)}:Le.name=="MemberExpression"?mi(Be,Le,""):ye.explicit?{path:[],name:""}:null}function Ft(ye,Be){let Le=[],Re=new Set;for(let Ye=0;;Ye++){for(let Ve of(Object.getOwnPropertyNames||Object.keys)(ye)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(Ve)||Re.has(Ve))continue;Re.add(Ve);let yt;try{yt=ye[Ve]}catch{continue}Le.push({label:Ve,type:typeof yt=="function"?/^[A-Z]/.test(Ve)?"class":Be?"function":"method":Be?"variable":"property",boost:-Ye})}let st=Object.getPrototypeOf(ye);if(!st)return Le;ye=st}}function Tt(ye){let Be=new Map;return Le=>{let Re=Gt(Le);if(!Re)return null;let Ye=ye;for(let Ve of Re.path)if(Ye=Ye[Ve],!Ye)return null;let st=Be.get(Ye);return st||Be.set(Ye,st=Ft(Ye,!Re.path.length)),{from:Le.pos-Re.name.length,options:st,validFor:Ut}}}const et=re.qp.define({name:"javascript",parser:T.E.configure({props:[re.uj.add({IfStatement:(0,re.tC)({except:/^\s*({|else\b)/}),TryStatement:(0,re.tC)({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:re.ze,SwitchBody:ye=>{let Be=ye.textAfter,Le=/^\s*\}/.test(Be),Re=/^\s*(case|default)\b/.test(Be);return ye.baseIndent+(Le?0:Re?1:2)*ye.unit},Block:(0,re.vw)({closing:"}"}),ArrowFunction:ye=>ye.baseIndent+ye.unit,"TemplateString BlockComment":()=>null,"Statement Property":(0,re.tC)({except:/^\s*{/}),JSXElement(ye){let Be=/^\s*<\//.test(ye.textAfter);return ye.lineIndent(ye.node.from)+(Be?0:ye.unit)},JSXEscape(ye){let Be=/\s*\}/.test(ye.textAfter);return ye.lineIndent(ye.node.from)+(Be?0:ye.unit)},"JSXOpenTag JSXSelfClosingTag"(ye){return ye.column(ye.node.from)+ye.unit}}),re.x0.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":re.Dv,BlockComment(ye){return{from:ye.from+2,to:ye.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),We={test:ye=>/^JSX/.test(ye.name),facet:(0,re.kU)({commentTokens:{block:{open:"{/*",close:"*/}"}}})},ht=et.configure({dialect:"ts"},"typescript"),Je=et.configure({dialect:"jsx",props:[re.KC.add(ye=>ye.isTop?[We]:void 0)]}),di=et.configure({dialect:"jsx ts",props:[re.KC.add(ye=>ye.isTop?[We]:void 0)]},"typescript");let ki=ye=>({label:ye,type:"keyword"});const Xt="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(ki),si=Xt.concat(["declare","implements","private","protected","public"].map(ki));function nt(ye={}){let Be=ye.jsx?ye.typescript?di:Je:ye.typescript?ht:et,Le=ye.typescript?Jt.concat(si):Nt.concat(Xt);return new re.ri(Be,[et.data.of({autocomplete:(0,ut.eC)(Ai,(0,ut.Mb)(Le))}),et.data.of({autocomplete:pi}),ye.jsx?$t:[]])}function kt(ye){for(;;){if(ye.name=="JSXOpenTag"||ye.name=="JSXSelfClosingTag"||ye.name=="JSXFragmentTag")return ye;if(ye.name=="JSXEscape"||!ye.parent)return null;ye=ye.parent}}function ft(ye,Be,Le=ye.length){for(let Re=Be==null?void 0:Be.firstChild;Re;Re=Re.nextSibling)if(Re.name=="JSXIdentifier"||Re.name=="JSXBuiltin"||Re.name=="JSXNamespacedName"||Re.name=="JSXMemberExpression")return ye.sliceString(Re.from,Math.min(Re.to,Le));return""}const It=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),$t=Oe.tk.inputHandler.of((ye,Be,Le,Re,Ye)=>{if((It?ye.composing:ye.compositionStarted)||ye.state.readOnly||Be!=Le||Re!=">"&&Re!="/"||!et.isActiveAt(ye.state,Be,-1))return!1;let st=Ye(),{state:Ve}=st,yt=Ve.changeByRange(ei=>{var Ct;let{head:De}=ei,zt=(0,re.qz)(Ve).resolveInner(De-1,-1),Bt;if(zt.name=="JSXStartTag"&&(zt=zt.parent),!(Ve.doc.sliceString(De-1,De)!=Re||zt.name=="JSXAttributeValue"&&zt.to>De)){if(Re==">"&&zt.name=="JSXFragmentTag")return{range:ei,changes:{from:De,insert:"</>"}};if(Re=="/"&&zt.name=="JSXStartCloseTag"){let ie=zt.parent,X=ie.parent;if(X&&ie.from==De-2&&((Bt=ft(Ve.doc,X.firstChild,De))||((Ct=X.firstChild)===null||Ct===void 0?void 0:Ct.name)=="JSXFragmentTag")){let pe=`${Bt}>`;return{range:te.jT.cursor(De+pe.length,-1),changes:{from:De,insert:pe}}}}else if(Re==">"){let ie=kt(zt);if(ie&&ie.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(Ve.doc.sliceString(De,De+2))&&(Bt=ft(Ve.doc,ie,De)))return{range:ei,changes:{from:De,insert:`</${Bt}>`}}}}return{range:ei}});return yt.changes.empty?!1:(ye.dispatch([st,Ve.update(yt,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function Et(ye,Be){return Be||(Be={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:!0,node:!0,es6:!0,es2015:!0,es2017:!0,es2020:!0},rules:{}},ye.getRules().forEach((Le,Re)=>{var Ye;!((Ye=Le.meta.docs)===null||Ye===void 0)&&Ye.recommended&&(Be.rules[Re]=2)})),Le=>{let{state:Re}=Le,Ye=[];for(let{from:st,to:Ve}of et.findRegions(Re)){let yt=Re.doc.lineAt(st),ei={line:yt.number-1,col:st-yt.from,pos:st};for(let Ct of ye.verify(Re.sliceDoc(st,Ve),Be))Ye.push(Yt(Ct,Re.doc,ei))}return Ye}}function vi(ye,Be,Le,Re){return Le.line(ye+Re.line).from+Be+(ye==1?Re.col-1:-1)}function Yt(ye,Be,Le){let Re=vi(ye.line,ye.column,Be,Le),Ye={from:Re,to:ye.endLine!=null&&ye.endColumn!=1?vi(ye.endLine,ye.endColumn,Be,Le):Re,message:ye.message,source:ye.ruleId?"eslint:"+ye.ruleId:"eslint",severity:ye.severity==1?"warning":"error"};if(ye.fix){let{range:st,text:Ve}=ye.fix,yt=st[0]+Le.pos-Re,ei=st[1]+Le.pos-Re;Ye.actions=[{name:"fix",apply(Ct,De){Ct.dispatch({changes:{from:De+yt,to:De+ei,insert:Ve},scrollIntoView:!0})}}]}return Ye}},59119:function(pn,Ni,it){it.d(Ni,{Dv:function(){return pe},Gn:function(){return Et},K0:function(){return It},KC:function(){return Kt},Qf:function(){return ci},R_:function(){return Ji},SS:function(){return ft},Um:function(){return ve},c:function(){return nt},e7:function(){return E},kU:function(){return Jt},mi:function(){return ti},n$:function(){return O},nF:function(){return Li},nY:function(){return Bt},qp:function(){return Rt},qz:function(){return Ze},ri:function(){return ki},tC:function(){return De},uj:function(){return vi},vw:function(){return yt},x0:function(){return X},y1:function(){return kt},ze:function(){return Ct}});var T=it(41113),re=it(78120),te=it(47421),Oe=it(35524),ut=it(28699),Lt;const Nt=new T.md;function Jt(A){return re.r$.define({combine:A?f=>f.concat(A):void 0})}const Kt=new T.md;class St{constructor(f,b,B=[],F=""){this.data=f,this.name=F,re.yy.prototype.hasOwnProperty("tree")||Object.defineProperty(re.yy.prototype,"tree",{get(){return Ze(this)}}),this.parser=b,this.extension=[di.of(this),re.yy.languageData.of((U,Z,be)=>{let me=Dt(U,Z,be),Ne=me.type.prop(Nt);if(!Ne)return[];let Ke=U.facet(Ne),_t=me.type.prop(Kt);if(_t){let Wi=me.resolve(Z-me.from,be);for(let Ii of _t)if(Ii.test(Wi,U)){let en=U.facet(Ii.facet);return Ii.type=="replace"?en:en.concat(Ke)}}return Ke})].concat(B)}isActiveAt(f,b,B=-1){return Dt(f,b,B).type.prop(Nt)==this.data}findRegions(f){let b=f.facet(di);if((b==null?void 0:b.data)==this.data)return[{from:0,to:f.doc.length}];if(!b||!b.allowsNesting)return[];let B=[],F=(U,Z)=>{if(U.prop(Nt)==this.data){B.push({from:Z,to:Z+U.length});return}let be=U.prop(T.md.mounted);if(be){if(be.tree.prop(Nt)==this.data){if(be.overlay)for(let me of be.overlay)B.push({from:me.from+Z,to:me.to+Z});else B.push({from:Z,to:Z+U.length});return}else if(be.overlay){let me=B.length;if(F(be.tree,be.overlay[0].from+Z),B.length>me)return}}for(let me=0;me<U.children.length;me++){let Ne=U.children[me];Ne instanceof T.mp&&F(Ne,U.positions[me]+Z)}};return F(Ze(f),0),B}get allowsNesting(){return!0}}St.setState=re.Py.define();function Dt(A,f,b){let B=A.facet(di),F=Ze(A).topNode;if(!B||B.allowsNesting)for(let U=F;U;U=U.enter(f,b,T.vj.ExcludeBuffers))U.type.isTop&&(F=U);return F}class Rt extends St{constructor(f,b,B){super(f,b,[],B),this.parser=b}static define(f){let b=Jt(f.languageData);return new Rt(b,f.parser.configure({props:[Nt.add(B=>B.isTop?b:void 0)]}),f.name)}configure(f,b){return new Rt(this.data,this.parser.configure(f),b||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ze(A){let f=A.field(St.state,!1);return f?f.tree:T.mp.empty}function wi(A,f,b=50){var B;let F=(B=A.field(St.state,!1))===null||B===void 0?void 0:B.context;if(!F)return null;let U=F.viewport;F.updateViewport({from:0,to:f});let Z=F.isDone(f)||F.work(b,f)?F.tree:null;return F.updateViewport(U),Z}function Ut(A,f=A.doc.length){var b;return((b=A.field(St.state,!1))===null||b===void 0?void 0:b.context.isDone(f))||!1}function Ai(A,f=A.viewport.to,b=100){let B=wi(A.state,f,b);return B!=Ze(A.state)&&A.dispatch({}),!!B}function pi(A){var f;return((f=A.plugin(Je))===null||f===void 0?void 0:f.isWorking())||!1}class mi{constructor(f){this.doc=f,this.cursorPos=0,this.string="",this.cursor=f.iter()}get length(){return this.doc.length}syncTo(f){return this.string=this.cursor.next(f-this.cursorPos).value,this.cursorPos=f+this.string.length,this.cursorPos-this.string.length}chunk(f){return this.syncTo(f),this.string}get lineChunks(){return!0}read(f,b){let B=this.cursorPos-this.string.length;return f<B||b>=this.cursorPos?this.doc.sliceString(f,b):this.string.slice(f-B,b-B)}}let Gt=null;class Ft{constructor(f,b,B=[],F,U,Z,be,me){this.parser=f,this.state=b,this.fragments=B,this.tree=F,this.treeLen=U,this.viewport=Z,this.skipped=be,this.scheduleOn=me,this.parse=null,this.tempSkipped=[]}static create(f,b,B){return new Ft(f,b,[],T.mp.empty,0,B,[],null)}startParse(){return this.parser.startParse(new mi(this.state.doc),this.fragments)}work(f,b){return b!=null&&b>=this.state.doc.length&&(b=void 0),this.tree!=T.mp.empty&&this.isDone(b??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var B;if(typeof f=="number"){let F=Date.now()+f;f=()=>Date.now()>F}for(this.parse||(this.parse=this.startParse()),b!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>b)&&b<this.state.doc.length&&this.parse.stopAt(b);;){let F=this.parse.advance();if(F)if(this.fragments=this.withoutTempSkipped(T.i9.addTree(F,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(B=this.parse.stoppedAt)!==null&&B!==void 0?B:this.state.doc.length,this.tree=F,this.parse=null,this.treeLen<(b??this.state.doc.length))this.parse=this.startParse();else return!0;if(f())return!1}})}takeTree(){let f,b;this.parse&&(f=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>f)&&this.parse.stopAt(f),this.withContext(()=>{for(;!(b=this.parse.advance()););}),this.treeLen=f,this.tree=b,this.fragments=this.withoutTempSkipped(T.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(f){let b=Gt;Gt=this;try{return f()}finally{Gt=b}}withoutTempSkipped(f){for(let b;b=this.tempSkipped.pop();)f=Tt(f,b.from,b.to);return f}changes(f,b){let{fragments:B,tree:F,treeLen:U,viewport:Z,skipped:be}=this;if(this.takeTree(),!f.empty){let me=[];if(f.iterChangedRanges((Ne,Ke,_t,Wi)=>me.push({fromA:Ne,toA:Ke,fromB:_t,toB:Wi})),B=T.i9.applyChanges(B,me),F=T.mp.empty,U=0,Z={from:f.mapPos(Z.from,-1),to:f.mapPos(Z.to,1)},this.skipped.length){be=[];for(let Ne of this.skipped){let Ke=f.mapPos(Ne.from,1),_t=f.mapPos(Ne.to,-1);Ke<_t&&be.push({from:Ke,to:_t})}}}return new Ft(this.parser,b,B,F,U,Z,be,this.scheduleOn)}updateViewport(f){if(this.viewport.from==f.from&&this.viewport.to==f.to)return!1;this.viewport=f;let b=this.skipped.length;for(let B=0;B<this.skipped.length;B++){let{from:F,to:U}=this.skipped[B];F<f.to&&U>f.from&&(this.fragments=Tt(this.fragments,F,U),this.skipped.splice(B--,1))}return this.skipped.length>=b?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(f,b){this.skipped.push({from:f,to:b})}static getSkippingParser(f){return new class extends T._b{createParse(b,B,F){let U=F[0].from,Z=F[F.length-1].to;return{parsedPos:U,advance(){let me=Gt;if(me){for(let Ne of F)me.tempSkipped.push(Ne);f&&(me.scheduleOn=me.scheduleOn?Promise.all([me.scheduleOn,f]):f)}return this.parsedPos=Z,new T.mp(T.Jq.none,[],[],Z-U)},stoppedAt:null,stopAt(){}}}}}isDone(f){f=Math.min(f,this.state.doc.length);let b=this.fragments;return this.treeLen>=f&&b.length&&b[0].from==0&&b[0].to>=f}static get(){return Gt}}function Tt(A,f,b){return T.i9.applyChanges(A,[{fromA:f,toA:b,fromB:f,toB:b}])}class et{constructor(f){this.context=f,this.tree=f.tree}apply(f){if(!f.docChanged&&this.tree==this.context.tree)return this;let b=this.context.changes(f.changes,f.state),B=this.context.treeLen==f.startState.doc.length?void 0:Math.max(f.changes.mapPos(this.context.treeLen),b.viewport.to);return b.work(20,B)||b.takeTree(),new et(b)}static init(f){let b=Math.min(3e3,f.doc.length),B=Ft.create(f.facet(di).parser,f,{from:0,to:b});return B.work(20,b)||B.takeTree(),new et(B)}}St.state=re.QQ.define({create:et.init,update(A,f){for(let b of f.effects)if(b.is(St.setState))return b.value;return f.startState.facet(di)!=f.state.facet(di)?et.init(f.state):A.apply(f)}});let We=A=>{let f=setTimeout(()=>A(),500);return()=>clearTimeout(f)};typeof requestIdleCallback<"u"&&(We=A=>{let f=-1,b=setTimeout(()=>{f=requestIdleCallback(A,{timeout:500-100})},100);return()=>f<0?clearTimeout(b):cancelIdleCallback(f)});const ht=typeof navigator<"u"&&(!((Lt=navigator.scheduling)===null||Lt===void 0)&&Lt.isInputPending)?()=>navigator.scheduling.isInputPending():null,Je=te.lg.fromClass(class{constructor(f){this.view=f,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(f){let b=this.view.state.field(St.state).context;(b.updateViewport(f.view.viewport)||this.view.viewport.to>b.treeLen)&&this.scheduleWork(),(f.docChanged||f.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(b)}scheduleWork(){if(this.working)return;let{state:f}=this.view,b=f.field(St.state);(b.tree!=b.context.tree||!b.context.isDone(f.doc.length))&&(this.working=We(this.work))}work(f){this.working=null;let b=Date.now();if(this.chunkEnd<b&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=b+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:B,viewport:{to:F}}=this.view,U=B.field(St.state);if(U.tree==U.context.tree&&U.context.isDone(F+1e5))return;let Z=Date.now()+Math.min(this.chunkBudget,100,f&&!ht?Math.max(25,f.timeRemaining()-5):1e9),be=U.context.treeLen<F&&B.doc.length>F+1e3,me=U.context.work(()=>ht&&ht()||Date.now()>Z,F+(be?0:1e5));this.chunkBudget-=Date.now()-b,(me||this.chunkBudget<=0)&&(U.context.takeTree(),this.view.dispatch({effects:St.setState.of(new et(U.context))})),this.chunkBudget>0&&!(me&&!be)&&this.scheduleWork(),this.checkAsyncSchedule(U.context)}checkAsyncSchedule(f){f.scheduleOn&&(this.workScheduled++,f.scheduleOn.then(()=>this.scheduleWork()).catch(b=>(0,te.OO)(this.view.state,b)).then(()=>this.workScheduled--),f.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),di=re.r$.define({combine(A){return A.length?A[0]:null},enables:A=>[St.state,Je,te.tk.contentAttributes.compute([A],f=>{let b=f.facet(A);return b&&b.name?{"data-language":b.name}:{}})]});class ki{constructor(f,b=[]){this.language=f,this.support=b,this.extension=[f,b]}}class Xt{constructor(f,b,B,F,U,Z=void 0){this.name=f,this.alias=b,this.extensions=B,this.filename=F,this.loadFunc=U,this.support=Z,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(f=>this.support=f,f=>{throw this.loading=null,f}))}static of(f){let{load:b,support:B}=f;if(!b){if(!B)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");b=()=>Promise.resolve(B)}return new Xt(f.name,(f.alias||[]).concat(f.name).map(F=>F.toLowerCase()),f.extensions||[],f.filename,b,B)}static matchFilename(f,b){for(let F of f)if(F.filename&&F.filename.test(b))return F;let B=/\.([^.]+)$/.exec(b);if(B){for(let F of f)if(F.extensions.indexOf(B[1])>-1)return F}return null}static matchLanguageName(f,b,B=!0){b=b.toLowerCase();for(let F of f)if(F.alias.some(U=>U==b))return F;if(B)for(let F of f)for(let U of F.alias){let Z=b.indexOf(U);if(Z>-1&&(U.length>2||!/\w/.test(b[Z-1])&&!/\w/.test(b[Z+U.length])))return F}return null}}const si=re.r$.define(),nt=re.r$.define({combine:A=>{if(!A.length)return" ";let f=A[0];if(!f||/\S/.test(f)||Array.from(f).some(b=>b!=f[0]))throw new Error("Invalid indent unit: "+JSON.stringify(A[0]));return f}});function kt(A){let f=A.facet(nt);return f.charCodeAt(0)==9?A.tabSize*f.length:f.length}function ft(A,f){let b="",B=A.tabSize,F=A.facet(nt)[0];if(F==" "){for(;f>=B;)b+=" ",f-=B;F=" "}for(let U=0;U<f;U++)b+=F;return b}function It(A,f){A instanceof re.yy&&(A=new Et(A));for(let B of A.state.facet(si)){let F=B(A,f);if(F!==void 0)return F}let b=Ze(A.state);return b.length>=f?Yt(A,b,f):null}function $t(A,f,b){let B=Object.create(null),F=new Et(A,{overrideIndentation:Z=>{var be;return(be=B[Z])!==null&&be!==void 0?be:-1}}),U=[];for(let Z=f;Z<=b;){let be=A.doc.lineAt(Z);Z=be.to+1;let me=It(F,be.from);if(me==null)continue;/\S/.test(be.text)||(me=0);let Ne=/^\s*/.exec(be.text)[0],Ke=ft(A,me);Ne!=Ke&&(B[be.from]=me,U.push({from:be.from,to:be.from+Ne.length,insert:Ke}))}return A.changes(U)}class Et{constructor(f,b={}){this.state=f,this.options=b,this.unit=kt(f)}lineAt(f,b=1){let B=this.state.doc.lineAt(f),{simulateBreak:F,simulateDoubleBreak:U}=this.options;return F!=null&&F>=B.from&&F<=B.to?U&&F==f?{text:"",from:f}:(b<0?F<f:F<=f)?{text:B.text.slice(F-B.from),from:F}:{text:B.text.slice(0,F-B.from),from:B.from}:B}textAfterPos(f,b=1){if(this.options.simulateDoubleBreak&&f==this.options.simulateBreak)return"";let{text:B,from:F}=this.lineAt(f,b);return B.slice(f-F,Math.min(B.length,f+100-F))}column(f,b=1){let{text:B,from:F}=this.lineAt(f,b),U=this.countColumn(B,f-F),Z=this.options.overrideIndentation?this.options.overrideIndentation(F):-1;return Z>-1&&(U+=Z-this.countColumn(B,B.search(/\S|$/))),U}countColumn(f,b=f.length){return(0,re.IS)(f,this.state.tabSize,b)}lineIndent(f,b=1){let{text:B,from:F}=this.lineAt(f,b),U=this.options.overrideIndentation;if(U){let Z=U(F);if(Z>-1)return Z}return this.countColumn(B,B.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const vi=new T.md;function Yt(A,f,b){let B=f.resolveStack(b),F=f.resolveInner(b,-1).resolve(b,0).enterUnfinishedNodesBefore(b);if(F!=B.node){let U=[];for(let Z=F;Z&&!(Z.from<B.node.from||Z.to>B.node.to||Z.from==B.node.from&&Z.type==B.node.type);Z=Z.parent)U.push(Z);for(let Z=U.length-1;Z>=0;Z--)B={node:U[Z],next:B}}return ye(B,A,b)}function ye(A,f,b){for(let B=A;B;B=B.next){let F=Le(B.node);if(F)return F(Ye.create(f,b,B))}return 0}function Be(A){return A.pos==A.options.simulateBreak&&A.options.simulateDoubleBreak}function Le(A){let f=A.type.prop(vi);if(f)return f;let b=A.firstChild,B;if(b&&(B=b.type.prop(T.md.closedBy))){let F=A.lastChild,U=F&&B.indexOf(F.name)>-1;return Z=>ei(Z,!0,1,void 0,U&&!Be(Z)?F.from:void 0)}return A.parent==null?Re:null}function Re(){return 0}class Ye extends Et{constructor(f,b,B){super(f.state,f.options),this.base=f,this.pos=b,this.context=B}get node(){return this.context.node}static create(f,b,B){return new Ye(f,b,B)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(f){let b=this.state.doc.lineAt(f.from);for(;;){let B=f.resolve(b.from);for(;B.parent&&B.parent.from==B.from;)B=B.parent;if(st(B,f))break;b=this.state.doc.lineAt(B.from)}return this.lineIndent(b.from)}continue(){return ye(this.context.next,this.base,this.pos)}}function st(A,f){for(let b=f;b;b=b.parent)if(A==b)return!0;return!1}function Ve(A){let f=A.node,b=f.childAfter(f.from),B=f.lastChild;if(!b)return null;let F=A.options.simulateBreak,U=A.state.doc.lineAt(b.from),Z=F==null||F<=U.from?U.to:Math.min(U.to,F);for(let be=b.to;;){let me=f.childAfter(be);if(!me||me==B)return null;if(!me.type.isSkipped){if(me.from>=Z)return null;let Ne=/^ */.exec(U.text.slice(b.to-U.from))[0].length;return{from:b.from,to:b.to+Ne}}be=me.to}}function yt({closing:A,align:f=!0,units:b=1}){return B=>ei(B,f,b,A)}function ei(A,f,b,B,F){let U=A.textAfter,Z=U.match(/^\s*/)[0].length,be=B&&U.slice(Z,Z+B.length)==B||F==A.pos+Z,me=f?Ve(A):null;return me?be?A.column(me.from):A.column(me.to):A.baseIndent+(be?0:A.unit*b)}const Ct=A=>A.baseIndent;function De({except:A,units:f=1}={}){return b=>{let B=A&&A.test(b.textAfter);return b.baseIndent+(B?0:f*b.unit)}}const zt=200;function Bt(){return re.yy.transactionFilter.of(A=>{if(!A.docChanged||!A.isUserEvent("input.type")&&!A.isUserEvent("input.complete"))return A;let f=A.startState.languageDataAt("indentOnInput",A.startState.selection.main.head);if(!f.length)return A;let b=A.newDoc,{head:B}=A.newSelection.main,F=b.lineAt(B);if(B>F.from+zt)return A;let U=b.sliceString(F.from,B);if(!f.some(Ne=>Ne.test(U)))return A;let{state:Z}=A,be=-1,me=[];for(let{head:Ne}of Z.selection.ranges){let Ke=Z.doc.lineAt(Ne);if(Ke.from==be)continue;be=Ke.from;let _t=It(Z,Ke.from);if(_t==null)continue;let Wi=/^\s*/.exec(Ke.text)[0],Ii=ft(Z,_t);Wi!=Ii&&me.push({from:Ke.from,to:Ke.from+Wi.length,insert:Ii})}return me.length?[A,{changes:me,sequential:!0}]:A})}const ie=re.r$.define(),X=new T.md;function pe(A){let f=A.firstChild,b=A.lastChild;return f&&f.to<b.from?{from:f.to,to:b.type.isError?A.to:b.from}:null}function ae(A,f,b){let B=Ze(A);if(B.length<b)return null;let F=B.resolveStack(b,1),U=null;for(let Z=F;Z;Z=Z.next){let be=Z.node;if(be.to<=b||be.from>b)continue;if(U&&be.from<f)break;let me=be.type.prop(X);if(me&&(be.to<B.length-50||B.length==A.doc.length||!Ae(be))){let Ne=me(be,A);Ne&&Ne.from<=b&&Ne.from>=f&&Ne.to>b&&(U=Ne)}}return U}function Ae(A){let f=A.lastChild;return f&&f.to==A.to&&f.type.isError}function Fe(A,f,b){for(let B of A.facet(ie)){let F=B(A,f,b);if(F)return F}return ae(A,f,b)}function Xe(A,f){let b=f.mapPos(A.from,1),B=f.mapPos(A.to,-1);return b>=B?void 0:{from:b,to:B}}const qe=re.Py.define({map:Xe}),dt=re.Py.define({map:Xe});function xt(A){let f=[];for(let{head:b}of A.state.selection.ranges)f.some(B=>B.from<=b&&B.to>=b)||f.push(A.lineBlockAt(b));return f}const tt=re.QQ.define({create(){return te.p.none},update(A,f){f.isUserEvent("delete")&&f.changes.iterChangedRanges((b,B)=>A=bt(A,b,B)),A=A.map(f.changes);for(let b of f.effects)if(b.is(qe)&&!Ti(A,b.value.from,b.value.to)){let{preparePlaceholder:B}=f.state.facet(K),F=B?te.p.replace({widget:new Te(B(f.state,b.value))}):Pe;A=A.update({add:[F.range(b.value.from,b.value.to)]})}else b.is(dt)&&(A=A.update({filter:(B,F)=>b.value.from!=B||b.value.to!=F,filterFrom:b.value.from,filterTo:b.value.to}));return f.selection&&(A=bt(A,f.selection.main.head)),A},provide:A=>te.tk.decorations.from(A),toJSON(A,f){let b=[];return A.between(0,f.doc.length,(B,F)=>{b.push(B,F)}),b},fromJSON(A){if(!Array.isArray(A)||A.length%2)throw new RangeError("Invalid JSON for fold state");let f=[];for(let b=0;b<A.length;){let B=A[b++],F=A[b++];if(typeof B!="number"||typeof F!="number")throw new RangeError("Invalid JSON for fold state");f.push(Pe.range(B,F))}return te.p.set(f,!0)}});function bt(A,f,b=f){let B=!1;return A.between(f,b,(F,U)=>{F<b&&U>f&&(B=!0)}),B?A.update({filterFrom:f,filterTo:b,filter:(F,U)=>F>=b||U<=f}):A}function At(A){return A.field(tt,!1)||RangeSet.empty}function Ot(A,f,b){var B;let F=null;return(B=A.field(tt,!1))===null||B===void 0||B.between(f,b,(U,Z)=>{(!F||F.from>U)&&(F={from:U,to:Z})}),F}function Ti(A,f,b){let B=!1;return A.between(f,f,(F,U)=>{F==f&&U==b&&(B=!0)}),B}function lt(A,f){return A.field(tt,!1)?f:f.concat(re.Py.appendConfig.of(ee()))}const rt=A=>{for(let f of xt(A)){let b=Fe(A.state,f.from,f.to);if(b)return A.dispatch({effects:lt(A.state,[qe.of(b),Oi(A,b)])}),!0}return!1},Mi=A=>{if(!A.state.field(tt,!1))return!1;let f=[];for(let b of xt(A)){let B=Ot(A.state,b.from,b.to);B&&f.push(dt.of(B),Oi(A,B,!1))}return f.length&&A.dispatch({effects:f}),f.length>0};function Oi(A,f,b=!0){let B=A.state.doc.lineAt(f.from).number,F=A.state.doc.lineAt(f.to).number;return te.tk.announce.of(`${A.state.phrase(b?"Folded lines":"Unfolded lines")} ${B} ${A.state.phrase("to")} ${F}.`)}const hi=A=>{let{state:f}=A,b=[];for(let B=0;B<f.doc.length;){let F=A.lineBlockAt(B),U=Fe(f,F.from,F.to);U&&b.push(qe.of(U)),B=(U?A.lineBlockAt(U.to):F).to+1}return b.length&&A.dispatch({effects:lt(A.state,b)}),!!b.length},Pi=A=>{let f=A.state.field(tt,!1);if(!f||!f.size)return!1;let b=[];return f.between(0,A.state.doc.length,(B,F)=>{b.push(dt.of({from:B,to:F}))}),A.dispatch({effects:b}),!0};function _i(A,f){for(let b=f;;){let B=Fe(A.state,b.from,b.to);if(B&&B.to>f.from)return B;if(!b.from)return null;b=A.lineBlockAt(b.from-1)}}const _=A=>{let f=[];for(let b of xt(A)){let B=Ot(A.state,b.from,b.to);if(B)f.push(dt.of(B),Oi(A,B,!1));else{let F=_i(A,b);F&&f.push(qe.of(F),Oi(A,F))}}return f.length>0&&A.dispatch({effects:lt(A.state,f)}),!!f.length},E=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:rt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Mi},{key:"Ctrl-Alt-[",run:hi},{key:"Ctrl-Alt-]",run:Pi}],q={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},K=re.r$.define({combine(A){return(0,re.BO)(A,q)}});function ee(A){let f=[tt,ri];return A&&f.push(K.of(A)),f}function ge(A,f){let{state:b}=A,B=b.facet(K),F=Z=>{let be=A.lineBlockAt(A.posAtDOM(Z.target)),me=Ot(A.state,be.from,be.to);me&&A.dispatch({effects:dt.of(me)}),Z.preventDefault()};if(B.placeholderDOM)return B.placeholderDOM(A,F,f);let U=document.createElement("span");return U.textContent=B.placeholderText,U.setAttribute("aria-label",b.phrase("folded code")),U.title=b.phrase("unfold"),U.className="cm-foldPlaceholder",U.onclick=F,U}const Pe=te.p.replace({widget:new class extends te.l9{toDOM(A){return ge(A,null)}}});class Te extends te.l9{constructor(f){super(),this.value=f}eq(f){return this.value==f.value}toDOM(f){return ge(f,this.value)}}const je={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ot extends te.SJ{constructor(f,b){super(),this.config=f,this.open=b}eq(f){return this.config==f.config&&this.open==f.open}toDOM(f){if(this.config.markerDOM)return this.config.markerDOM(this.open);let b=document.createElement("span");return b.textContent=this.open?this.config.openText:this.config.closedText,b.title=f.state.phrase(this.open?"Fold line":"Unfold line"),b}}function ti(A={}){let f={...je,...A},b=new ot(f,!0),B=new ot(f,!1),F=te.lg.fromClass(class{constructor(Z){this.from=Z.viewport.from,this.markers=this.buildMarkers(Z)}update(Z){(Z.docChanged||Z.viewportChanged||Z.startState.facet(di)!=Z.state.facet(di)||Z.startState.field(tt,!1)!=Z.state.field(tt,!1)||Ze(Z.startState)!=Ze(Z.state)||f.foldingChanged(Z))&&(this.markers=this.buildMarkers(Z.view))}buildMarkers(Z){let be=new re.f_;for(let me of Z.viewportLineBlocks){let Ne=Ot(Z.state,me.from,me.to)?B:Fe(Z.state,me.from,me.to)?b:null;Ne&&be.add(me.from,me.from,Ne)}return be.finish()}}),{domEventHandlers:U}=f;return[F,(0,te.v5)({class:"cm-foldGutter",markers(Z){var be;return((be=Z.plugin(F))===null||be===void 0?void 0:be.markers)||re.Xs.empty},initialSpacer(){return new ot(f,!1)},domEventHandlers:{...U,click:(Z,be,me)=>{if(U.click&&U.click(Z,be,me))return!0;let Ne=Ot(Z.state,be.from,be.to);if(Ne)return Z.dispatch({effects:dt.of(Ne)}),!0;let Ke=Fe(Z.state,be.from,be.to);return Ke?(Z.dispatch({effects:qe.of(Ke)}),!0):!1}}}),ee()]}const ri=te.tk.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 ci{constructor(f,b){this.specs=f;let B;function F(be){let me=ut.V.newName();return(B||(B=Object.create(null)))["."+me]=be,me}const U=typeof b.all=="string"?b.all:b.all?F(b.all):void 0,Z=b.scope;this.scope=Z instanceof St?be=>be.prop(Nt)==Z.data:Z?be=>be==Z:void 0,this.style=(0,Oe.QR)(f.map(be=>({tag:be.tag,class:be.class||F(Object.assign({},be,{tag:null}))})),{all:U}).style,this.module=B?new ut.V(B):null,this.themeType=b.themeType}static define(f,b){return new ci(f,b||{})}}const fi=re.r$.define(),qt=re.r$.define({combine(A){return A.length?[A[0]]:null}});function gi(A){let f=A.facet(fi);return f.length?f:A.facet(qt)}function Li(A,f){let b=[Pt],B;return A instanceof ci&&(A.module&&b.push(te.tk.styleModule.of(A.module)),B=A.themeType),f!=null&&f.fallback?b.push(qt.of(A)):B?b.push(fi.computeN([te.tk.darkTheme],F=>F.facet(te.tk.darkTheme)==(B=="dark")?[A]:[])):b.push(fi.of(A)),b}function Ei(A,f,b){let B=gi(A),F=null;if(B){for(let U of B)if(!U.scope||b&&U.scope(b)){let Z=U.style(f);Z&&(F=F?F+" "+Z:Z)}}return F}class Xi{constructor(f){this.markCache=Object.create(null),this.tree=Ze(f.state),this.decorations=this.buildDeco(f,gi(f.state)),this.decoratedTo=f.viewport.to}update(f){let b=Ze(f.state),B=gi(f.state),F=B!=gi(f.startState),{viewport:U}=f.view,Z=f.changes.mapPos(this.decoratedTo,1);b.length<U.to&&!F&&b.type==this.tree.type&&Z>=U.to?(this.decorations=this.decorations.map(f.changes),this.decoratedTo=Z):(b!=this.tree||f.viewportChanged||F)&&(this.tree=b,this.decorations=this.buildDeco(f.view,B),this.decoratedTo=U.to)}buildDeco(f,b){if(!b||!this.tree.length)return te.p.none;let B=new re.f_;for(let{from:F,to:U}of f.visibleRanges)(0,Oe.bW)(this.tree,b,(Z,be,me)=>{B.add(Z,be,this.markCache[me]||(this.markCache[me]=te.p.mark({class:me})))},F,U);return B.finish()}}const Pt=re.Wl.high(te.lg.fromClass(Xi,{decorations:A=>A.decorations})),Ji=ci.define([{tag:Oe.pJ.meta,color:"#404740"},{tag:Oe.pJ.link,textDecoration:"underline"},{tag:Oe.pJ.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Oe.pJ.emphasis,fontStyle:"italic"},{tag:Oe.pJ.strong,fontWeight:"bold"},{tag:Oe.pJ.strikethrough,textDecoration:"line-through"},{tag:Oe.pJ.keyword,color:"#708"},{tag:[Oe.pJ.atom,Oe.pJ.bool,Oe.pJ.url,Oe.pJ.contentSeparator,Oe.pJ.labelName],color:"#219"},{tag:[Oe.pJ.literal,Oe.pJ.inserted],color:"#164"},{tag:[Oe.pJ.string,Oe.pJ.deleted],color:"#a11"},{tag:[Oe.pJ.regexp,Oe.pJ.escape,Oe.pJ.special(Oe.pJ.string)],color:"#e40"},{tag:Oe.pJ.definition(Oe.pJ.variableName),color:"#00f"},{tag:Oe.pJ.local(Oe.pJ.variableName),color:"#30a"},{tag:[Oe.pJ.typeName,Oe.pJ.namespace],color:"#085"},{tag:Oe.pJ.className,color:"#167"},{tag:[Oe.pJ.special(Oe.pJ.variableName),Oe.pJ.macroName],color:"#256"},{tag:Oe.pJ.definition(Oe.pJ.propertyName),color:"#00c"},{tag:Oe.pJ.comment,color:"#940"},{tag:Oe.pJ.invalid,color:"#f00"}]),sn=te.tk.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),an=1e4,oi="()[]{}",R=re.r$.define({combine(A){return(0,re.BO)(A,{afterCursor:!0,brackets:oi,maxScanDistance:an,renderMatch:d})}}),o=te.p.mark({class:"cm-matchingBracket"}),a=te.p.mark({class:"cm-nonmatchingBracket"});function d(A){let f=[],b=A.matched?o:a;return f.push(b.range(A.start.from,A.start.to)),A.end&&f.push(b.range(A.end.from,A.end.to)),f}const D=[re.QQ.define({create(){return te.p.none},update(A,f){if(!f.docChanged&&!f.selection)return A;let b=[],B=f.state.facet(R);for(let F of f.state.selection.ranges){if(!F.empty)continue;let U=ve(f.state,F.head,-1,B)||F.head>0&&ve(f.state,F.head-1,1,B)||B.afterCursor&&(ve(f.state,F.head,1,B)||F.head<f.state.doc.length&&ve(f.state,F.head+1,-1,B));U&&(b=b.concat(B.renderMatch(U,f.state)))}return te.p.set(b,!0)},provide:A=>te.tk.decorations.from(A)}),sn];function O(A={}){return[R.of(A),D]}const H=new T.md;function Y(A,f,b){let B=A.prop(f<0?T.md.openedBy:T.md.closedBy);if(B)return B;if(A.name.length==1){let F=b.indexOf(A.name);if(F>-1&&F%2==(f<0?1:0))return[b[F+f]]}return null}function ue(A){let f=A.type.prop(H);return f?f(A.node):A}function ve(A,f,b,B={}){let F=B.maxScanDistance||an,U=B.brackets||oi,Z=Ze(A),be=Z.resolveInner(f,b);for(let me=be;me;me=me.parent){let Ne=Y(me.type,b,U);if(Ne&&me.from<me.to){let Ke=ue(me);if(Ke&&(b>0?f>=Ke.from&&f<Ke.to:f>Ke.from&&f<=Ke.to))return Ee(A,f,b,me,Ke,Ne,U)}}return ze(A,f,b,Z,be.type,F,U)}function Ee(A,f,b,B,F,U,Z){let be=B.parent,me={from:F.from,to:F.to},Ne=0,Ke=be==null?void 0:be.cursor();if(Ke&&(b<0?Ke.childBefore(B.from):Ke.childAfter(B.to)))do if(b<0?Ke.to<=B.from:Ke.from>=B.to){if(Ne==0&&U.indexOf(Ke.type.name)>-1&&Ke.from<Ke.to){let _t=ue(Ke);return{start:me,end:_t?{from:_t.from,to:_t.to}:void 0,matched:!0}}else if(Y(Ke.type,b,Z))Ne++;else if(Y(Ke.type,-b,Z)){if(Ne==0){let _t=ue(Ke);return{start:me,end:_t&&_t.from<_t.to?{from:_t.from,to:_t.to}:void 0,matched:!1}}Ne--}}while(b<0?Ke.prevSibling():Ke.nextSibling());return{start:me,matched:!1}}function ze(A,f,b,B,F,U,Z){let be=b<0?A.sliceDoc(f-1,f):A.sliceDoc(f,f+1),me=Z.indexOf(be);if(me<0||me%2==0!=b>0)return null;let Ne={from:b<0?f-1:f,to:b>0?f+1:f},Ke=A.doc.iterRange(f,b>0?A.doc.length:0),_t=0;for(let Wi=0;!Ke.next().done&&Wi<=U;){let Ii=Ke.value;b<0&&(Wi+=Ii.length);let en=f+Wi*b;for(let Yi=b>0?0:Ii.length-1,kn=b>0?Ii.length:-1;Yi!=kn;Yi+=b){let mn=Z.indexOf(Ii[Yi]);if(!(mn<0||B.resolveInner(en+Yi,1).type!=F))if(mn%2==0==b>0)_t++;else{if(_t==1)return{start:Ne,end:{from:en+Yi,to:en+Yi+1},matched:mn>>1==me>>1};_t--}}b>0&&(Wi+=Ii.length)}return Ke.done?{start:Ne,matched:!1}:null}function $e(A,f,b,B=0,F=0){f==null&&(f=A.search(/[^\s\u00a0]/),f==-1&&(f=A.length));let U=F;for(let Z=B;Z<f;Z++)A.charCodeAt(Z)==9?U+=b-U%b:U++;return U}class jt{constructor(f,b,B,F){this.string=f,this.tabSize=b,this.indentUnit=B,this.overrideIndent=F,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(f){let b=this.string.charAt(this.pos),B;if(typeof f=="string"?B=b==f:B=b&&(f instanceof RegExp?f.test(b):f(b)),B)return++this.pos,b}eatWhile(f){let b=this.pos;for(;this.eat(f););return this.pos>b}eatSpace(){let f=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>f}skipToEnd(){this.pos=this.string.length}skipTo(f){let b=this.string.indexOf(f,this.pos);if(b>-1)return this.pos=b,!0}backUp(f){this.pos-=f}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=$e(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var f;return(f=this.overrideIndent)!==null&&f!==void 0?f:$e(this.string,null,this.tabSize)}match(f,b,B){if(typeof f=="string"){let F=Z=>B?Z.toLowerCase():Z,U=this.string.substr(this.pos,f.length);return F(U)==F(f)?(b!==!1&&(this.pos+=f.length),!0):null}else{let F=this.string.slice(this.pos).match(f);return F&&F.index>0?null:(F&&b!==!1&&(this.pos+=F[0].length),F)}}current(){return this.string.slice(this.start,this.pos)}}function Fi(A){return{name:A.name||"",token:A.token,blankLine:A.blankLine||(()=>{}),startState:A.startState||(()=>!0),copyState:A.copyState||ii,indent:A.indent||(()=>null),languageData:A.languageData||{},tokenTable:A.tokenTable||L,mergeTokens:A.mergeTokens!==!1}}function ii(A){if(typeof A!="object")return A;let f={};for(let b in A){let B=A[b];f[b]=B instanceof Array?B.slice():B}return f}const Qi=new WeakMap;class Ki extends null{constructor(f){let b=Jt(f.languageData),B=Fi(f),F,U=new class extends Parser{createParse(Z,be,me){return new y(F,Z,be,me)}};super(b,U,[],f.name),this.topNode=Wt(b,this),F=this,this.streamParser=B,this.stateAfter=new NodeProp({perNode:!0}),this.tokenTable=f.tokenTable?new Me(B.tokenTable):Ce}static define(f){return new Ki(f)}getIndent(f){let b,{overrideIndentation:B}=f.options;B&&(b=Qi.get(f.state),b!=null&&b<f.pos-1e4&&(b=void 0));let F=Ui(this,f.node.tree,f.node.from,f.node.from,b??f.pos),U,Z;if(F?(Z=F.state,U=F.pos+1):(Z=this.streamParser.startState(f.unit),U=f.node.from),f.pos-U>1e4)return null;for(;U<f.pos;){let me=f.state.doc.lineAt(U),Ne=Math.min(f.pos,me.to);if(me.length){let Ke=B?B(me.from):-1,_t=new jt(me.text,f.state.tabSize,f.unit,Ke<0?void 0:Ke);for(;_t.pos<Ne-me.from;)x(this.streamParser.token,_t,Z)}else this.streamParser.blankLine(Z,f.unit);if(Ne==f.pos)break;U=me.to+1}let be=f.lineAt(f.pos);return B&&b==null&&Qi.set(f.state,be.from),this.streamParser.indent(Z,/^\s*(.*)/.exec(be.text)[1],f)}get allowsNesting(){return!1}}function Ui(A,f,b,B,F){let U=b>=B&&b+f.length<=F&&f.prop(A.stateAfter);if(U)return{state:A.streamParser.copyState(U),pos:b+f.length};for(let Z=f.children.length-1;Z>=0;Z--){let be=f.children[Z],me=b+f.positions[Z],Ne=be instanceof Tree&&me<F&&Ui(A,be,me,B,F);if(Ne)return Ne}return null}function rn(A,f,b,B,F){if(F&&b<=0&&B>=f.length)return f;!F&&b==0&&f.type==A.topNode&&(F=!0);for(let U=f.children.length-1;U>=0;U--){let Z=f.positions[U],be=f.children[U],me;if(Z<B&&be instanceof Tree){if(!(me=rn(A,be,b-Z,B-Z,F)))break;return F?new Tree(f.type,f.children.slice(0,U).concat(me),f.positions.slice(0,U+1),Z+me.length):me}}return null}function P(A,f,b,B,F){for(let U of f){let Z=U.from+(U.openStart?25:0),be=U.to-(U.openEnd?25:0),me=Z<=b&&be>b&&Ui(A,U.tree,0-U.offset,b,be),Ne;if(me&&me.pos<=B&&(Ne=rn(A,U.tree,b+U.offset,me.pos+U.offset,!1)))return{state:me.state,tree:Ne}}return{state:A.streamParser.startState(F?kt(F):4),tree:Tree.empty}}class y{constructor(f,b,B,F){this.lang=f,this.input=b,this.fragments=B,this.ranges=F,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=F[F.length-1].to;let U=Ft.get(),Z=F[0].from,{state:be,tree:me}=P(f,B,Z,this.to,U==null?void 0:U.state);this.state=be,this.parsedPos=this.chunkStart=Z+me.length;for(let Ne=0;Ne<me.children.length;Ne++)this.chunks.push(me.children[Ne]),this.chunkPos.push(me.positions[Ne]);U&&this.parsedPos<U.viewport.from-1e5&&F.some(Ne=>Ne.from<=U.viewport.from&&Ne.to>=U.viewport.from)&&(this.state=this.lang.streamParser.startState(kt(U.state)),U.skipUntilInView(this.parsedPos,U.viewport.from),this.parsedPos=U.viewport.from),this.moveRangeIndex()}advance(){let f=Ft.get(),b=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),B=Math.min(b,this.chunkStart+2048);for(f&&(B=Math.min(B,f.viewport.to));this.parsedPos<B;)this.parseLine(f);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=b?this.finish():f&&this.parsedPos>=f.viewport.to?(f.skipUntilInView(this.parsedPos,b),this.finish()):null}stopAt(f){this.stoppedAt=f}lineAfter(f){let b=this.input.chunk(f);if(this.input.lineChunks)b==`
16
+ `&&(b="");else{let B=b.indexOf(`
17
+ `);B>-1&&(b=b.slice(0,B))}return f+b.length<=this.to?b:b.slice(0,this.to-f)}nextLine(){let f=this.parsedPos,b=this.lineAfter(f),B=f+b.length;for(let F=this.rangeIndex;;){let U=this.ranges[F].to;if(U>=B||(b=b.slice(0,U-(B-b.length)),F++,F==this.ranges.length))break;let Z=this.ranges[F].from,be=this.lineAfter(Z);b+=be,B=Z+be.length}return{line:b,end:B}}skipGapsTo(f,b,B){for(;;){let F=this.ranges[this.rangeIndex].to,U=f+b;if(B>0?F>U:F>=U)break;let Z=this.ranges[++this.rangeIndex].from;b+=Z-F}return b}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(f,b,B,F){let U=4;if(this.ranges.length>1){F=this.skipGapsTo(b,F,1),b+=F;let be=this.chunk.length;F=this.skipGapsTo(B,F,-1),B+=F,U+=this.chunk.length-be}let Z=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&U==4&&Z>=0&&this.chunk[Z]==f&&this.chunk[Z+2]==b?this.chunk[Z+2]=B:this.chunk.push(f,b,B,U),F}parseLine(f){let{line:b,end:B}=this.nextLine(),F=0,{streamParser:U}=this.lang,Z=new jt(b,f?f.state.tabSize:4,f?kt(f.state):2);if(Z.eol())U.blankLine(this.state,Z.indentUnit);else for(;!Z.eol();){let be=x(U.token,Z,this.state);if(be&&(F=this.emitToken(this.lang.tokenTable.resolve(be),this.parsedPos+Z.start,this.parsedPos+Z.pos,F)),Z.start>1e4)break}this.parsedPos=B,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let f=Tree.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:G,topID:0,maxBufferLength:2048,reused:this.chunkReused});f=new Tree(f.type,f.children,f.positions,f.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(f),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new Tree(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function x(A,f,b){f.start=f.pos;for(let B=0;B<10;B++){let F=A(f,b);if(f.pos>f.start)return F}throw new Error("Stream parser failed to advance stream.")}const L=Object.create(null),I=[T.Jq.none],G=new T.Lj(I),oe=[],de=Object.create(null),fe=Object.create(null);for(let[A,f]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"]])fe[A]=wt(L,f);class Me{constructor(f){this.extra=f,this.table=Object.assign(Object.create(null),fe)}resolve(f){return f?this.table[f]||(this.table[f]=wt(this.extra,f)):0}}const Ce=new Me(L);function _e(A,f){oe.indexOf(A)>-1||(oe.push(A),console.warn(f))}function wt(A,f){let b=[];for(let be of f.split(" ")){let me=[];for(let Ne of be.split(".")){let Ke=A[Ne]||Oe.pJ[Ne];Ke?typeof Ke=="function"?me.length?me=me.map(Ke):_e(Ne,`Modifier ${Ne} used at start of tag`):me.length?_e(Ne,`Tag ${Ne} used as modifier`):me=Array.isArray(Ke)?Ke:[Ke]:_e(Ne,`Unknown highlighting tag ${Ne}`)}for(let Ne of me)b.push(Ne)}if(!b.length)return 0;let B=f.replace(/ /g,"_"),F=B+" "+b.map(be=>be.id),U=de[F];if(U)return U.id;let Z=de[F]=T.Jq.define({id:I.length,name:B,props:[(0,Oe.Gv)({[B]:b})]});return I.push(Z),Z.id}function Wt(A,f){let b=NodeType.define({id:I.length,name:"Document",props:[Nt.add(()=>A),vi.add(()=>B=>f.getIndent(B))],top:!0});return I.push(b),b}function li(A){return A.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(A)}function yi(A){for(let f=A.iter();!f.next().done;)if(li(f.value))return!0;return!1}function Di(A){let f=!1;return A.iterChanges((b,B,F,U,Z)=>{!f&&yi(Z)&&(f=!0)}),f}const xi=re.r$.define({combine:A=>A.some(f=>f)});function Qt(A={}){let f=[Vi];return A.alwaysIsolate&&f.push(xi.of(!0)),f}const Vi=te.lg.fromClass(class{constructor(A){this.always=A.state.facet(xi)||A.textDirection!=te.Nm.LTR||A.state.facet(te.tk.perLineTextDirection),this.hasRTL=!this.always&&yi(A.state.doc),this.tree=Ze(A.state),this.decorations=this.always||this.hasRTL?Bi(A,this.tree,this.always):te.p.none}update(A){let f=A.state.facet(xi)||A.view.textDirection!=te.Nm.LTR||A.state.facet(te.tk.perLineTextDirection);if(!f&&!this.hasRTL&&Di(A.changes)&&(this.hasRTL=!0),!f&&!this.hasRTL)return;let b=Ze(A.state);(f!=this.always||b!=this.tree||A.docChanged||A.viewportChanged)&&(this.tree=b,this.always=f,this.decorations=Bi(A.view,b,f))}},{provide:A=>{function f(b){var B,F;return(F=(B=b.plugin(A))===null||B===void 0?void 0:B.decorations)!==null&&F!==void 0?F:te.p.none}return[te.tk.outerDecorations.of(f),re.Wl.lowest(te.tk.bidiIsolatedRanges.of(f))]}});function Bi(A,f,b){let B=new re.f_,F=A.visibleRanges;b||(F=Ri(F,A.state.doc));for(let{from:U,to:Z}of F)f.iterate({enter:be=>{let me=be.type.prop(T.md.isolate);me&&B.add(be.from,be.to,Zi[me])},from:U,to:Z});return B.finish()}function Ri(A,f){let b=f.iter(),B=0,F=[],U=null;for(let{from:Z,to:be}of A)if(!(U&&U.to>Z&&(Z=U.to,Z>=be)))for(B+b.value.length<Z&&(b.next(Z-(B+b.value.length)),B=Z);;){let me=B,Ne=B+b.value.length;if(!b.lineBreak&&li(b.value)&&(U&&U.to>me-10?U.to=Math.min(be,Ne):F.push(U={from:me,to:Math.min(be,Ne)})),Ne>=be)break;B=Ne,b.next()}return F}const Zi={rtl:te.p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:te.Nm.RTL}),ltr:te.p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:te.Nm.LTR}),auto:te.p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})}},28519:function(pn,Ni,it){it.d(Ni,{Fv:function(){return et},Q2:function(){return zt},ir:function(){return di},p0:function(){return Kt}});var T=it(47421),re=it(78120),te=it(18580);class Oe{constructor(X,pe,ae){this.from=X,this.to=pe,this.diagnostic=ae}}class ut{constructor(X,pe,ae){this.diagnostics=X,this.panel=pe,this.selected=ae}static init(X,pe,ae){let Ae=ae.facet(Je).markerFilter;Ae&&(X=Ae(X,ae));let Fe=X.slice().sort((tt,bt)=>tt.from-bt.from||tt.to-bt.to),Xe=new re.f_,qe=[],dt=0;for(let tt=0;;){let bt=tt==Fe.length?null:Fe[tt];if(!bt&&!qe.length)break;let At,Ot;for(qe.length?(At=dt,Ot=qe.reduce((lt,rt)=>Math.min(lt,rt.to),bt&&bt.from>At?bt.from:1e8)):(At=bt.from,Ot=bt.to,qe.push(bt),tt++);tt<Fe.length;){let lt=Fe[tt];if(lt.from==At&&(lt.to>lt.from||lt.to==At))qe.push(lt),tt++,Ot=Math.min(lt.to,Ot);else{Ot=Math.min(lt.from,Ot);break}}let Ti=Yt(qe);if(qe.some(lt=>lt.from==lt.to||lt.from==lt.to-1&&ae.doc.lineAt(lt.from).to==lt.from))Xe.add(At,At,T.p.widget({widget:new nt(Ti),diagnostics:qe.slice()}));else{let lt=qe.reduce((rt,Mi)=>Mi.markClass?rt+" "+Mi.markClass:rt,"");Xe.add(At,Ot,T.p.mark({class:"cm-lintRange cm-lintRange-"+Ti+lt,diagnostics:qe.slice(),inclusiveEnd:qe.some(rt=>rt.to>Ot)}))}dt=Ot;for(let lt=0;lt<qe.length;lt++)qe[lt].to<=dt&&qe.splice(lt--,1)}let xt=Xe.finish();return new ut(xt,pe,Lt(xt))}}function Lt(ie,X=null,pe=0){let ae=null;return ie.between(pe,1e9,(Ae,Fe,{spec:Xe})=>{if(!(X&&Xe.diagnostics.indexOf(X)<0))if(!ae)ae=new Oe(Ae,Fe,X||Xe.diagnostics[0]);else{if(Xe.diagnostics.indexOf(ae.diagnostic)<0)return!1;ae=new Oe(ae.from,Fe,ae.diagnostic)}}),ae}function Nt(ie,X){let pe=X.pos,ae=X.end||pe,Ae=ie.state.facet(Je).hideOn(ie,pe,ae);if(Ae!=null)return Ae;let Fe=ie.startState.doc.lineAt(X.pos);return!!(ie.effects.some(Xe=>Xe.is(St))||ie.changes.touchesRange(Fe.from,Math.max(Fe.to,ae)))}function Jt(ie,X){return ie.field(Ze,!1)?X:X.concat(re.Py.appendConfig.of(Ct))}function Kt(ie,X){return{effects:Jt(ie,[St.of(X)])}}const St=re.Py.define(),Dt=re.Py.define(),Rt=re.Py.define(),Ze=re.QQ.define({create(){return new ut(T.p.none,null,null)},update(ie,X){if(X.docChanged&&ie.diagnostics.size){let pe=ie.diagnostics.map(X.changes),ae=null,Ae=ie.panel;if(ie.selected){let Fe=X.changes.mapPos(ie.selected.from,1);ae=Lt(pe,ie.selected.diagnostic,Fe)||Lt(pe,null,Fe)}!pe.size&&Ae&&X.state.facet(Je).autoPanel&&(Ae=null),ie=new ut(pe,Ae,ae)}for(let pe of X.effects)if(pe.is(St)){let ae=X.state.facet(Je).autoPanel?pe.value.length?ft.open:null:ie.panel;ie=ut.init(pe.value,ae,X.state)}else pe.is(Dt)?ie=new ut(ie.diagnostics,pe.value?ft.open:null,ie.selected):pe.is(Rt)&&(ie=new ut(ie.diagnostics,ie.panel,pe.value));return ie},provide:ie=>[T.mH.from(ie,X=>X.panel),T.tk.decorations.from(ie,X=>X.diagnostics)]});function wi(ie){let X=ie.field(Ze,!1);return X?X.diagnostics.size:0}const Ut=T.p.mark({class:"cm-lintRange cm-lintRange-active"});function Ai(ie,X,pe){let{diagnostics:ae}=ie.state.field(Ze),Ae,Fe=-1,Xe=-1;ae.between(X-(pe<0?1:0),X+(pe>0?1:0),(dt,xt,{spec:tt})=>{if(X>=dt&&X<=xt&&(dt==xt||(X>dt||pe>0)&&(X<xt||pe<0)))return Ae=tt.diagnostics,Fe=dt,Xe=xt,!1});let qe=ie.state.facet(Je).tooltipFilter;return Ae&&qe&&(Ae=qe(Ae,ie.state)),Ae?{pos:Fe,end:Xe,above:ie.state.doc.lineAt(Fe).to<Xe,create(){return{dom:pi(ie,Ae)}}}:null}function pi(ie,X){return(0,te.Z)("ul",{class:"cm-tooltip-lint"},X.map(pe=>si(ie,pe,!1)))}const mi=ie=>{let X=ie.state.field(Ze,!1);(!X||!X.panel)&&ie.dispatch({effects:Jt(ie.state,[Dt.of(!0)])});let pe=(0,T.Sd)(ie,ft.open);return pe&&pe.dom.querySelector(".cm-panel-lint ul").focus(),!0},Gt=ie=>{let X=ie.state.field(Ze,!1);return!X||!X.panel?!1:(ie.dispatch({effects:Dt.of(!1)}),!0)},Ft=ie=>{let X=ie.state.field(Ze,!1);if(!X)return!1;let pe=ie.state.selection.main,ae=X.diagnostics.iter(pe.to+1);return!ae.value&&(ae=X.diagnostics.iter(0),!ae.value||ae.from==pe.from&&ae.to==pe.to)?!1:(ie.dispatch({selection:{anchor:ae.from,head:ae.to},scrollIntoView:!0}),!0)},Tt=ie=>{let{state:X}=ie,pe=X.field(Ze,!1);if(!pe)return!1;let ae=X.selection.main,Ae,Fe,Xe,qe;return pe.diagnostics.between(0,X.doc.length,(dt,xt)=>{xt<ae.to&&(Ae==null||Ae<dt)&&(Ae=dt,Fe=xt),(Xe==null||dt>Xe)&&(Xe=dt,qe=xt)}),Xe==null||Ae==null&&Xe==ae.from?!1:(ie.dispatch({selection:{anchor:Ae??Xe,head:Fe??qe},scrollIntoView:!0}),!0)},et=[{key:"Mod-Shift-m",run:mi,preventDefault:!0},{key:"F8",run:Ft}],We=T.lg.fromClass(class{constructor(ie){this.view=ie,this.timeout=-1,this.set=!0;let{delay:X}=ie.state.facet(Je);this.lintTime=Date.now()+X,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,X)}run(){clearTimeout(this.timeout);let ie=Date.now();if(ie<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-ie);else{this.set=!1;let{state:X}=this.view,{sources:pe}=X.facet(Je);pe.length&&ht(pe.map(ae=>Promise.resolve(ae(this.view))),ae=>{this.view.state.doc==X.doc&&this.view.dispatch(Kt(this.view.state,ae.reduce((Ae,Fe)=>Ae.concat(Fe))))},ae=>{(0,T.OO)(this.view.state,ae)})}}update(ie){let X=ie.state.facet(Je);(ie.docChanged||X!=ie.startState.facet(Je)||X.needsRefresh&&X.needsRefresh(ie))&&(this.lintTime=Date.now()+X.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,X.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function ht(ie,X,pe){let ae=[],Ae=-1;for(let Fe of ie)Fe.then(Xe=>{ae.push(Xe),clearTimeout(Ae),ae.length==ie.length?X(ae):Ae=setTimeout(()=>X(ae),200)},pe)}const Je=re.r$.define({combine(ie){return Object.assign({sources:ie.map(X=>X.source).filter(X=>X!=null)},(0,re.BO)(ie.map(X=>X.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(X,pe)=>X?pe?ae=>X(ae)||pe(ae):X:pe}))}});function di(ie,X={}){return[Je.of({source:ie,config:X}),We,Ct]}function ki(ie){let X=ie.plugin(We);X&&X.force()}function Xt(ie){let X=[];if(ie)e:for(let{name:pe}of ie){for(let ae=0;ae<pe.length;ae++){let Ae=pe[ae];if(/[a-zA-Z]/.test(Ae)&&!X.some(Fe=>Fe.toLowerCase()==Ae.toLowerCase())){X.push(Ae);continue e}}X.push("")}return X}function si(ie,X,pe){var ae;let Ae=pe?Xt(X.actions):[];return(0,te.Z)("li",{class:"cm-diagnostic cm-diagnostic-"+X.severity},(0,te.Z)("span",{class:"cm-diagnosticText"},X.renderMessage?X.renderMessage(ie):X.message),(ae=X.actions)===null||ae===void 0?void 0:ae.map((Fe,Xe)=>{let qe=!1,dt=At=>{if(At.preventDefault(),qe)return;qe=!0;let Ot=Lt(ie.state.field(Ze).diagnostics,X);Ot&&Fe.apply(ie,Ot.from,Ot.to)},{name:xt}=Fe,tt=Ae[Xe]?xt.indexOf(Ae[Xe]):-1,bt=tt<0?xt:[xt.slice(0,tt),(0,te.Z)("u",xt.slice(tt,tt+1)),xt.slice(tt+1)];return(0,te.Z)("button",{type:"button",class:"cm-diagnosticAction",onclick:dt,onmousedown:dt,"aria-label":` Action: ${xt}${tt<0?"":` (access key "${Ae[Xe]})"`}.`},bt)}),X.source&&(0,te.Z)("div",{class:"cm-diagnosticSource"},X.source))}class nt extends T.l9{constructor(X){super(),this.sev=X}eq(X){return X.sev==this.sev}toDOM(){return(0,te.Z)("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class kt{constructor(X,pe){this.diagnostic=pe,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=si(X,pe,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ft{constructor(X){this.view=X,this.items=[];let pe=Ae=>{if(Ae.keyCode==27)Gt(this.view),this.view.focus();else if(Ae.keyCode==38||Ae.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(Ae.keyCode==40||Ae.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(Ae.keyCode==36)this.moveSelection(0);else if(Ae.keyCode==35)this.moveSelection(this.items.length-1);else if(Ae.keyCode==13)this.view.focus();else if(Ae.keyCode>=65&&Ae.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:Fe}=this.items[this.selectedIndex],Xe=Xt(Fe.actions);for(let qe=0;qe<Xe.length;qe++)if(Xe[qe].toUpperCase().charCodeAt(0)==Ae.keyCode){let dt=Lt(this.view.state.field(Ze).diagnostics,Fe);dt&&Fe.actions[qe].apply(X,dt.from,dt.to)}}else return;Ae.preventDefault()},ae=Ae=>{for(let Fe=0;Fe<this.items.length;Fe++)this.items[Fe].dom.contains(Ae.target)&&this.moveSelection(Fe)};this.list=(0,te.Z)("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:pe,onclick:ae}),this.dom=(0,te.Z)("div",{class:"cm-panel-lint"},this.list,(0,te.Z)("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Gt(this.view)},"\xD7")),this.update()}get selectedIndex(){let X=this.view.state.field(Ze).selected;if(!X)return-1;for(let pe=0;pe<this.items.length;pe++)if(this.items[pe].diagnostic==X.diagnostic)return pe;return-1}update(){let{diagnostics:X,selected:pe}=this.view.state.field(Ze),ae=0,Ae=!1,Fe=null,Xe=new Set;for(X.between(0,this.view.state.doc.length,(qe,dt,{spec:xt})=>{for(let tt of xt.diagnostics){if(Xe.has(tt))continue;Xe.add(tt);let bt=-1,At;for(let Ot=ae;Ot<this.items.length;Ot++)if(this.items[Ot].diagnostic==tt){bt=Ot;break}bt<0?(At=new kt(this.view,tt),this.items.splice(ae,0,At),Ae=!0):(At=this.items[bt],bt>ae&&(this.items.splice(ae,bt-ae),Ae=!0)),pe&&At.diagnostic==pe.diagnostic?At.dom.hasAttribute("aria-selected")||(At.dom.setAttribute("aria-selected","true"),Fe=At):At.dom.hasAttribute("aria-selected")&&At.dom.removeAttribute("aria-selected"),ae++}});ae<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)Ae=!0,this.items.pop();this.items.length==0&&(this.items.push(new kt(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),Ae=!0),Fe?(this.list.setAttribute("aria-activedescendant",Fe.id),this.view.requestMeasure({key:this,read:()=>({sel:Fe.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:qe,panel:dt})=>{let xt=dt.height/this.list.offsetHeight;qe.top<dt.top?this.list.scrollTop-=(dt.top-qe.top)/xt:qe.bottom>dt.bottom&&(this.list.scrollTop+=(qe.bottom-dt.bottom)/xt)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),Ae&&this.sync()}sync(){let X=this.list.firstChild;function pe(){let ae=X;X=ae.nextSibling,ae.remove()}for(let ae of this.items)if(ae.dom.parentNode==this.list){for(;X!=ae.dom;)pe();X=ae.dom.nextSibling}else this.list.insertBefore(ae.dom,X);for(;X;)pe()}moveSelection(X){if(this.selectedIndex<0)return;let pe=this.view.state.field(Ze),ae=Lt(pe.diagnostics,this.items[X].diagnostic);ae&&this.view.dispatch({selection:{anchor:ae.from,head:ae.to},scrollIntoView:!0,effects:Rt.of(ae)})}static open(X){return new ft(X)}}function It(ie,X='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${X}>${encodeURIComponent(ie)}</svg>')`}function $t(ie){return It(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${ie}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Et=T.tk.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:$t("#d11")},".cm-lintRange-warning":{backgroundImage:$t("orange")},".cm-lintRange-info":{backgroundImage:$t("#999")},".cm-lintRange-hint":{backgroundImage:$t("#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}}});function vi(ie){return ie=="error"?4:ie=="warning"?3:ie=="info"?2:1}function Yt(ie){let X="hint",pe=1;for(let ae of ie){let Ae=vi(ae.severity);Ae>pe&&(pe=Ae,X=ae.severity)}return X}class ye extends T.SJ{constructor(X){super(),this.diagnostics=X,this.severity=Yt(X)}toDOM(X){let pe=document.createElement("div");pe.className="cm-lint-marker cm-lint-marker-"+this.severity;let ae=this.diagnostics,Ae=X.state.facet(De).tooltipFilter;return Ae&&(ae=Ae(ae,X.state)),ae.length&&(pe.onmouseover=()=>Le(X,pe,ae)),pe}}function Be(ie,X){let pe=ae=>{let Ae=X.getBoundingClientRect();if(!(ae.clientX>Ae.left-10&&ae.clientX<Ae.right+10&&ae.clientY>Ae.top-10&&ae.clientY<Ae.bottom+10)){for(let Fe=ae.target;Fe;Fe=Fe.parentNode)if(Fe.nodeType==1&&Fe.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",pe),ie.state.field(yt)&&ie.dispatch({effects:Ve.of(null)})}};window.addEventListener("mousemove",pe)}function Le(ie,X,pe){function ae(){let Xe=ie.elementAtHeight(X.getBoundingClientRect().top+5-ie.documentTop);ie.coordsAtPos(Xe.from)&&ie.dispatch({effects:Ve.of({pos:Xe.from,above:!1,clip:!1,create(){return{dom:pi(ie,pe),getCoords:()=>X.getBoundingClientRect()}}})}),X.onmouseout=X.onmousemove=null,Be(ie,X)}let{hoverTime:Ae}=ie.state.facet(De),Fe=setTimeout(ae,Ae);X.onmouseout=()=>{clearTimeout(Fe),X.onmouseout=X.onmousemove=null},X.onmousemove=()=>{clearTimeout(Fe),Fe=setTimeout(ae,Ae)}}function Re(ie,X){let pe=Object.create(null);for(let Ae of X){let Fe=ie.lineAt(Ae.from);(pe[Fe.from]||(pe[Fe.from]=[])).push(Ae)}let ae=[];for(let Ae in pe)ae.push(new ye(pe[Ae]).range(+Ae));return re.Xs.of(ae,!0)}const Ye=(0,T.v5)({class:"cm-gutter-lint",markers:ie=>ie.state.field(st),widgetMarker:(ie,X,pe)=>{let ae=[];return ie.state.field(st).between(pe.from,pe.to,(Ae,Fe,Xe)=>{Ae>pe.from&&Ae<pe.to&&ae.push(...Xe.diagnostics)}),ae.length?new ye(ae):null}}),st=re.QQ.define({create(){return re.Xs.empty},update(ie,X){ie=ie.map(X.changes);let pe=X.state.facet(De).markerFilter;for(let ae of X.effects)if(ae.is(St)){let Ae=ae.value;pe&&(Ae=pe(Ae||[],X.state)),ie=Re(X.state.doc,Ae.slice(0))}return ie}}),Ve=re.Py.define(),yt=re.QQ.define({create(){return null},update(ie,X){return ie&&X.docChanged&&(ie=Nt(X,ie)?null:Object.assign(Object.assign({},ie),{pos:X.changes.mapPos(ie.pos)})),X.effects.reduce((pe,ae)=>ae.is(Ve)?ae.value:pe,ie)},provide:ie=>T.hJ.from(ie)}),ei=T.tk.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:It('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:It('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:It('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Ct=[Ze,T.tk.decorations.compute([Ze],ie=>{let{selected:X,panel:pe}=ie.field(Ze);return!X||!pe||X.from==X.to?T.p.none:T.p.set([Ut.range(X.from,X.to)])}),(0,T.bF)(Ai,{hideOn:Nt}),Et],De=re.r$.define({combine(ie){return(0,re.BO)(ie,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function zt(ie={}){return[De.of(ie),st,Ye,ei,yt]}function Bt(ie,X){let pe=ie.field(Ze,!1);if(pe&&pe.diagnostics.size){let ae=[],Ae=[],Fe=-1;for(let Xe=RangeSet.iter([pe.diagnostics]);;Xe.next()){for(let qe=0;qe<ae.length;qe++)(!Xe.value||Xe.value.spec.diagnostics.indexOf(ae[qe])<0)&&(X(ae[qe],Ae[qe],Fe),ae.splice(qe,1),Ae.splice(qe--,1));if(!Xe.value)break;for(let qe of Xe.value.spec.diagnostics)ae.indexOf(qe)<0&&(ae.push(qe),Ae.push(Xe.from));Fe=Xe.to}}}},49892:function(pn,Ni,it){it.d(Ni,{Lp:function(){return Ti},sW:function(){return Tt}});var T=it(47421),re=it(78120),te=it(18580);const Oe=typeof String.prototype.normalize=="function"?_=>_.normalize("NFKD"):_=>_;class ut{constructor(E,q,K=0,ee=E.length,ge,Pe){this.test=Pe,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=E.iterRange(K,ee),this.bufferStart=K,this.normalize=ge?Te=>ge(Oe(Te)):Oe,this.query=this.normalize(q)}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(0,re.gm)(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 q=(0,re.bg)(E),K=this.bufferStart+this.bufferPos;this.bufferPos+=(0,re.nZ)(E);let ee=this.normalize(q);if(ee.length)for(let ge=0,Pe=K;;ge++){let Te=ee.charCodeAt(ge),je=this.match(Te,Pe,this.bufferPos+this.bufferStart);if(ge==ee.length-1){if(je)return this.value=je,this;break}Pe==K&&ge<q.length&&q.charCodeAt(ge)==Te&&Pe++}}}match(E,q,K){let ee=null;for(let ge=0;ge<this.matches.length;ge+=2){let Pe=this.matches[ge],Te=!1;this.query.charCodeAt(Pe)==E&&(Pe==this.query.length-1?ee={from:this.matches[ge+1],to:K}:(this.matches[ge]++,Te=!0)),Te||(this.matches.splice(ge,2),ge-=2)}return this.query.charCodeAt(0)==E&&(this.query.length==1?ee={from:q,to:K}:this.matches.push(1,q)),ee&&this.test&&!this.test(ee.from,ee.to,this.buffer,this.bufferStart)&&(ee=null),ee}}typeof Symbol<"u"&&(ut.prototype[Symbol.iterator]=function(){return this});const Lt={from:-1,to:-1,match:/.*/.exec("")},Nt="gm"+(/x/.unicode==null?"":"u");class Jt{constructor(E,q,K,ee=0,ge=E.length){if(this.text=E,this.to=ge,this.curLine="",this.done=!1,this.value=Lt,/\\[sWDnr]|\n|\r|\[\^/.test(q))return new Dt(E,q,K,ee,ge);this.re=new RegExp(q,Nt+(K!=null&&K.ignoreCase?"i":"")),this.test=K==null?void 0:K.test,this.iter=E.iter();let Pe=E.lineAt(ee);this.curLineStart=Pe.from,this.matchPos=Ze(E,ee),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 q=this.matchPos<=this.to&&this.re.exec(this.curLine);if(q){let K=this.curLineStart+q.index,ee=K+q[0].length;if(this.matchPos=Ze(this.text,ee+(K==ee?1:0)),K==this.curLineStart+this.curLine.length&&this.nextLine(),(K<ee||K>this.value.to)&&(!this.test||this.test(K,ee,q)))return this.value={from:K,to:ee,match:q},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 Kt=new WeakMap;class St{constructor(E,q){this.from=E,this.text=q}get to(){return this.from+this.text.length}static get(E,q,K){let ee=Kt.get(E);if(!ee||ee.from>=K||ee.to<=q){let Te=new St(q,E.sliceString(q,K));return Kt.set(E,Te),Te}if(ee.from==q&&ee.to==K)return ee;let{text:ge,from:Pe}=ee;return Pe>q&&(ge=E.sliceString(q,Pe)+ge,Pe=q),ee.to<K&&(ge+=E.sliceString(ee.to,K)),Kt.set(E,new St(Pe,ge)),new St(q,ge.slice(q-Pe,K-Pe))}}class Dt{constructor(E,q,K,ee,ge){this.text=E,this.to=ge,this.done=!1,this.value=Lt,this.matchPos=Ze(E,ee),this.re=new RegExp(q,Nt+(K!=null&&K.ignoreCase?"i":"")),this.test=K==null?void 0:K.test,this.flat=St.get(E,ee,this.chunkEnd(ee+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,q=this.re.exec(this.flat.text);if(q&&!q[0]&&q.index==E&&(this.re.lastIndex=E+1,q=this.re.exec(this.flat.text)),q){let K=this.flat.from+q.index,ee=K+q[0].length;if((this.flat.to>=this.to||q.index+q[0].length<=this.flat.text.length-10)&&(!this.test||this.test(K,ee,q)))return this.value={from:K,to:ee,match:q},this.matchPos=Ze(this.text,ee+(K==ee?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=St.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Jt.prototype[Symbol.iterator]=Dt.prototype[Symbol.iterator]=function(){return this});function Rt(_){try{return new RegExp(_,Nt),!0}catch{return!1}}function Ze(_,E){if(E>=_.length)return E;let q=_.lineAt(E),K;for(;E<q.to&&(K=q.text.charCodeAt(E-q.from))>=56320&&K<57344;)E++;return E}function wi(_){let E=String(_.state.doc.lineAt(_.state.selection.main.head).number),q=(0,te.Z)("input",{class:"cm-textfield",name:"line",value:E}),K=(0,te.Z)("form",{class:"cm-gotoLine",onkeydown:ge=>{ge.keyCode==27?(ge.preventDefault(),_.dispatch({effects:Ut.of(!1)}),_.focus()):ge.keyCode==13&&(ge.preventDefault(),ee())},onsubmit:ge=>{ge.preventDefault(),ee()}},(0,te.Z)("label",_.state.phrase("Go to line"),": ",q)," ",(0,te.Z)("button",{class:"cm-button",type:"submit"},_.state.phrase("go")),(0,te.Z)("button",{name:"close",onclick:()=>{_.dispatch({effects:Ut.of(!1)}),_.focus()},"aria-label":_.state.phrase("close"),type:"button"},["\xD7"]));function ee(){let ge=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(q.value);if(!ge)return;let{state:Pe}=_,Te=Pe.doc.lineAt(Pe.selection.main.head),[,je,ot,ti,ri]=ge,ci=ti?+ti.slice(1):0,fi=ot?+ot:Te.number;if(ot&&ri){let Li=fi/100;je&&(Li=Li*(je=="-"?-1:1)+Te.number/Pe.doc.lines),fi=Math.round(Pe.doc.lines*Li)}else ot&&je&&(fi=fi*(je=="-"?-1:1)+Te.number);let qt=Pe.doc.line(Math.max(1,Math.min(Pe.doc.lines,fi))),gi=re.jT.cursor(qt.from+Math.max(0,Math.min(ci,qt.length)));_.dispatch({effects:[Ut.of(!1),T.tk.scrollIntoView(gi.from,{y:"center"})],selection:gi}),_.focus()}return{dom:K}}const Ut=re.Py.define(),Ai=re.QQ.define({create(){return!0},update(_,E){for(let q of E.effects)q.is(Ut)&&(_=q.value);return _},provide:_=>T.mH.from(_,E=>E?wi:null)}),pi=_=>{let E=(0,T.Sd)(_,wi);if(!E){let q=[Ut.of(!0)];_.state.field(Ai,!1)==null&&q.push(re.Py.appendConfig.of([Ai,mi])),_.dispatch({effects:q}),E=(0,T.Sd)(_,wi)}return E&&E.dom.querySelector("input").select(),!0},mi=T.tk.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),Gt={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Ft=re.r$.define({combine(_){return(0,re.BO)(_,Gt,{highlightWordAroundCursor:(E,q)=>E||q,minSelectionLength:Math.min,maxMatches:Math.min})}});function Tt(_){let E=[ki,di];return _&&E.push(Ft.of(_)),E}const et=T.p.mark({class:"cm-selectionMatch"}),We=T.p.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function ht(_,E,q,K){return(q==0||_(E.sliceDoc(q-1,q))!=re.D0.Word)&&(K==E.doc.length||_(E.sliceDoc(K,K+1))!=re.D0.Word)}function Je(_,E,q,K){return _(E.sliceDoc(q,q+1))==re.D0.Word&&_(E.sliceDoc(K-1,K))==re.D0.Word}const di=T.lg.fromClass(class{constructor(_){this.decorations=this.getDeco(_)}update(_){(_.selectionSet||_.docChanged||_.viewportChanged)&&(this.decorations=this.getDeco(_.view))}getDeco(_){let E=_.state.facet(Ft),{state:q}=_,K=q.selection;if(K.ranges.length>1)return T.p.none;let ee=K.main,ge,Pe=null;if(ee.empty){if(!E.highlightWordAroundCursor)return T.p.none;let je=q.wordAt(ee.head);if(!je)return T.p.none;Pe=q.charCategorizer(ee.head),ge=q.sliceDoc(je.from,je.to)}else{let je=ee.to-ee.from;if(je<E.minSelectionLength||je>200)return T.p.none;if(E.wholeWords){if(ge=q.sliceDoc(ee.from,ee.to),Pe=q.charCategorizer(ee.head),!(ht(Pe,q,ee.from,ee.to)&&Je(Pe,q,ee.from,ee.to)))return T.p.none}else if(ge=q.sliceDoc(ee.from,ee.to),!ge)return T.p.none}let Te=[];for(let je of _.visibleRanges){let ot=new ut(q.doc,ge,je.from,je.to);for(;!ot.next().done;){let{from:ti,to:ri}=ot.value;if((!Pe||ht(Pe,q,ti,ri))&&(ee.empty&&ti<=ee.from&&ri>=ee.to?Te.push(We.range(ti,ri)):(ti>=ee.to||ri<=ee.from)&&Te.push(et.range(ti,ri)),Te.length>E.maxMatches))return T.p.none}}return T.p.set(Te)}},{decorations:_=>_.decorations}),ki=T.tk.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Xt=({state:_,dispatch:E})=>{let{selection:q}=_,K=re.jT.create(q.ranges.map(ee=>_.wordAt(ee.head)||re.jT.cursor(ee.head)),q.mainIndex);return K.eq(q)?!1:(E(_.update({selection:K})),!0)};function si(_,E){let{main:q,ranges:K}=_.selection,ee=_.wordAt(q.head),ge=ee&&ee.from==q.from&&ee.to==q.to;for(let Pe=!1,Te=new ut(_.doc,E,K[K.length-1].to);;)if(Te.next(),Te.done){if(Pe)return null;Te=new ut(_.doc,E,0,Math.max(0,K[K.length-1].from-1)),Pe=!0}else{if(Pe&&K.some(je=>je.from==Te.value.from))continue;if(ge){let je=_.wordAt(Te.value.from);if(!je||je.from!=Te.value.from||je.to!=Te.value.to)continue}return Te.value}}const nt=({state:_,dispatch:E})=>{let{ranges:q}=_.selection;if(q.some(ge=>ge.from===ge.to))return Xt({state:_,dispatch:E});let K=_.sliceDoc(q[0].from,q[0].to);if(_.selection.ranges.some(ge=>_.sliceDoc(ge.from,ge.to)!=K))return!1;let ee=si(_,K);return ee?(E(_.update({selection:_.selection.addRange(re.jT.range(ee.from,ee.to),!1),effects:T.tk.scrollIntoView(ee.to)})),!0):!1},kt=re.r$.define({combine(_){return(0,re.BO)(_,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:E=>new lt(E),scrollToMatch:E=>T.tk.scrollIntoView(E)})}});function ft(_){return _?[kt.of(_),_i]:_i}class It{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||Rt(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!E.wholeWord}unquote(E){return this.literal?E:E.replace(/\\([nrt\\])/g,(q,K)=>K=="n"?`
18
+ `:K=="r"?"\r":K=="t"?" ":"\\")}eq(E){return this.search==E.search&&this.replace==E.replace&&this.caseSensitive==E.caseSensitive&&this.regexp==E.regexp&&this.wholeWord==E.wholeWord}create(){return this.regexp?new Ye(this):new Yt(this)}getCursor(E,q=0,K){let ee=E.doc?E:re.yy.create({doc:E});return K==null&&(K=ee.doc.length),this.regexp?ye(this,ee,q,K):Et(this,ee,q,K)}}class $t{constructor(E){this.spec=E}}function Et(_,E,q,K){return new ut(E.doc,_.unquoted,q,K,_.caseSensitive?void 0:ee=>ee.toLowerCase(),_.wholeWord?vi(E.doc,E.charCategorizer(E.selection.main.head)):void 0)}function vi(_,E){return(q,K,ee,ge)=>((ge>q||ge+ee.length<K)&&(ge=Math.max(0,q-2),ee=_.sliceString(ge,Math.min(_.length,K+2))),(E(Be(ee,q-ge))!=re.D0.Word||E(Le(ee,q-ge))!=re.D0.Word)&&(E(Le(ee,K-ge))!=re.D0.Word||E(Be(ee,K-ge))!=re.D0.Word))}class Yt extends $t{constructor(E){super(E)}nextMatch(E,q,K){let ee=Et(this.spec,E,K,E.doc.length).nextOverlapping();if(ee.done){let ge=Math.min(E.doc.length,q+this.spec.unquoted.length);ee=Et(this.spec,E,0,ge).nextOverlapping()}return ee.done||ee.value.from==q&&ee.value.to==K?null:ee.value}prevMatchInRange(E,q,K){for(let ee=K;;){let ge=Math.max(q,ee-1e4-this.spec.unquoted.length),Pe=Et(this.spec,E,ge,ee),Te=null;for(;!Pe.nextOverlapping().done;)Te=Pe.value;if(Te)return Te;if(ge==q)return null;ee-=1e4}}prevMatch(E,q,K){let ee=this.prevMatchInRange(E,0,q);return ee||(ee=this.prevMatchInRange(E,Math.max(0,K-this.spec.unquoted.length),E.doc.length)),ee&&(ee.from!=q||ee.to!=K)?ee:null}getReplacement(E){return this.spec.unquote(this.spec.replace)}matchAll(E,q){let K=Et(this.spec,E,0,E.doc.length),ee=[];for(;!K.next().done;){if(ee.length>=q)return null;ee.push(K.value)}return ee}highlight(E,q,K,ee){let ge=Et(this.spec,E,Math.max(0,q-this.spec.unquoted.length),Math.min(K+this.spec.unquoted.length,E.doc.length));for(;!ge.next().done;)ee(ge.value.from,ge.value.to)}}function ye(_,E,q,K){return new Jt(E.doc,_.search,{ignoreCase:!_.caseSensitive,test:_.wholeWord?Re(E.charCategorizer(E.selection.main.head)):void 0},q,K)}function Be(_,E){return _.slice((0,re.cp)(_,E,!1),E)}function Le(_,E){return _.slice(E,(0,re.cp)(_,E))}function Re(_){return(E,q,K)=>!K[0].length||(_(Be(K.input,K.index))!=re.D0.Word||_(Le(K.input,K.index))!=re.D0.Word)&&(_(Le(K.input,K.index+K[0].length))!=re.D0.Word||_(Be(K.input,K.index+K[0].length))!=re.D0.Word)}class Ye extends $t{nextMatch(E,q,K){let ee=ye(this.spec,E,K,E.doc.length).next();return ee.done&&(ee=ye(this.spec,E,0,q).next()),ee.done?null:ee.value}prevMatchInRange(E,q,K){for(let ee=1;;ee++){let ge=Math.max(q,K-ee*1e4),Pe=ye(this.spec,E,ge,K),Te=null;for(;!Pe.next().done;)Te=Pe.value;if(Te&&(ge==q||Te.from>ge+10))return Te;if(ge==q)return null}}prevMatch(E,q,K){return this.prevMatchInRange(E,0,q)||this.prevMatchInRange(E,K,E.doc.length)}getReplacement(E){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(q,K)=>{if(K=="&")return E.match[0];if(K=="$")return"$";for(let ee=K.length;ee>0;ee--){let ge=+K.slice(0,ee);if(ge>0&&ge<E.match.length)return E.match[ge]+K.slice(ee)}return q})}matchAll(E,q){let K=ye(this.spec,E,0,E.doc.length),ee=[];for(;!K.next().done;){if(ee.length>=q)return null;ee.push(K.value)}return ee}highlight(E,q,K,ee){let ge=ye(this.spec,E,Math.max(0,q-250),Math.min(K+250,E.doc.length));for(;!ge.next().done;)ee(ge.value.from,ge.value.to)}}const st=re.Py.define(),Ve=re.Py.define(),yt=re.QQ.define({create(_){return new De(xt(_).create(),null)},update(_,E){for(let q of E.effects)q.is(st)?_=new De(q.value.create(),_.panel):q.is(Ve)&&(_=new De(_.query,q.value?dt:null));return _},provide:_=>T.mH.from(_,E=>E.panel)});function ei(_){let E=_.field(yt,!1);return E?E.query.spec:xt(_)}function Ct(_){var E;return((E=_.field(yt,!1))===null||E===void 0?void 0:E.panel)!=null}class De{constructor(E,q){this.query=E,this.panel=q}}const zt=T.p.mark({class:"cm-searchMatch"}),Bt=T.p.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ie=T.lg.fromClass(class{constructor(_){this.view=_,this.decorations=this.highlight(_.state.field(yt))}update(_){let E=_.state.field(yt);(E!=_.startState.field(yt)||_.docChanged||_.selectionSet||_.viewportChanged)&&(this.decorations=this.highlight(E))}highlight({query:_,panel:E}){if(!E||!_.spec.valid)return T.p.none;let{view:q}=this,K=new re.f_;for(let ee=0,ge=q.visibleRanges,Pe=ge.length;ee<Pe;ee++){let{from:Te,to:je}=ge[ee];for(;ee<Pe-1&&je>ge[ee+1].from-2*250;)je=ge[++ee].to;_.highlight(q.state,Te,je,(ot,ti)=>{let ri=q.state.selection.ranges.some(ci=>ci.from==ot&&ci.to==ti);K.add(ot,ti,ri?Bt:zt)})}return K.finish()}},{decorations:_=>_.decorations});function X(_){return E=>{let q=E.state.field(yt,!1);return q&&q.query.spec.valid?_(E,q):At(E)}}const pe=X((_,{query:E})=>{let{to:q}=_.state.selection.main,K=E.nextMatch(_.state,q,q);if(!K)return!1;let ee=re.jT.single(K.from,K.to),ge=_.state.facet(kt);return _.dispatch({selection:ee,effects:[hi(_,K),ge.scrollToMatch(ee.main,_)],userEvent:"select.search"}),bt(_),!0}),ae=X((_,{query:E})=>{let{state:q}=_,{from:K}=q.selection.main,ee=E.prevMatch(q,K,K);if(!ee)return!1;let ge=re.jT.single(ee.from,ee.to),Pe=_.state.facet(kt);return _.dispatch({selection:ge,effects:[hi(_,ee),Pe.scrollToMatch(ge.main,_)],userEvent:"select.search"}),bt(_),!0}),Ae=X((_,{query:E})=>{let q=E.matchAll(_.state,1e3);return!q||!q.length?!1:(_.dispatch({selection:re.jT.create(q.map(K=>re.jT.range(K.from,K.to))),userEvent:"select.search.matches"}),!0)}),Fe=({state:_,dispatch:E})=>{let q=_.selection;if(q.ranges.length>1||q.main.empty)return!1;let{from:K,to:ee}=q.main,ge=[],Pe=0;for(let Te=new ut(_.doc,_.sliceDoc(K,ee));!Te.next().done;){if(ge.length>1e3)return!1;Te.value.from==K&&(Pe=ge.length),ge.push(re.jT.range(Te.value.from,Te.value.to))}return E(_.update({selection:re.jT.create(ge,Pe),userEvent:"select.search.matches"})),!0},Xe=X((_,{query:E})=>{let{state:q}=_,{from:K,to:ee}=q.selection.main;if(q.readOnly)return!1;let ge=E.nextMatch(q,K,K);if(!ge)return!1;let Pe=ge,Te=[],je,ot,ti=[];Pe.from==K&&Pe.to==ee&&(ot=q.toText(E.getReplacement(Pe)),Te.push({from:Pe.from,to:Pe.to,insert:ot}),Pe=E.nextMatch(q,Pe.from,Pe.to),ti.push(T.tk.announce.of(q.phrase("replaced match on line $",q.doc.lineAt(K).number)+".")));let ri=_.state.changes(Te);return Pe&&(je=re.jT.single(Pe.from,Pe.to).map(ri),ti.push(hi(_,Pe)),ti.push(q.facet(kt).scrollToMatch(je.main,_))),_.dispatch({changes:ri,selection:je,effects:ti,userEvent:"input.replace"}),!0}),qe=X((_,{query:E})=>{if(_.state.readOnly)return!1;let q=E.matchAll(_.state,1e9).map(ee=>{let{from:ge,to:Pe}=ee;return{from:ge,to:Pe,insert:E.getReplacement(ee)}});if(!q.length)return!1;let K=_.state.phrase("replaced $ matches",q.length)+".";return _.dispatch({changes:q,effects:T.tk.announce.of(K),userEvent:"input.replace.all"}),!0});function dt(_){return _.state.facet(kt).createPanel(_)}function xt(_,E){var q,K,ee,ge,Pe;let Te=_.selection.main,je=Te.empty||Te.to>Te.from+100?"":_.sliceDoc(Te.from,Te.to);if(E&&!je)return E;let ot=_.facet(kt);return new It({search:((q=E==null?void 0:E.literal)!==null&&q!==void 0?q:ot.literal)?je:je.replace(/\n/g,"\\n"),caseSensitive:(K=E==null?void 0:E.caseSensitive)!==null&&K!==void 0?K:ot.caseSensitive,literal:(ee=E==null?void 0:E.literal)!==null&&ee!==void 0?ee:ot.literal,regexp:(ge=E==null?void 0:E.regexp)!==null&&ge!==void 0?ge:ot.regexp,wholeWord:(Pe=E==null?void 0:E.wholeWord)!==null&&Pe!==void 0?Pe:ot.wholeWord})}function tt(_){let E=(0,T.Sd)(_,dt);return E&&E.dom.querySelector("[main-field]")}function bt(_){let E=tt(_);E&&E==_.root.activeElement&&E.select()}const At=_=>{let E=_.state.field(yt,!1);if(E&&E.panel){let q=tt(_);if(q&&q!=_.root.activeElement){let K=xt(_.state,E.query.spec);K.valid&&_.dispatch({effects:st.of(K)}),q.focus(),q.select()}}else _.dispatch({effects:[Ve.of(!0),E?st.of(xt(_.state,E.query.spec)):re.Py.appendConfig.of(_i)]});return!0},Ot=_=>{let E=_.state.field(yt,!1);if(!E||!E.panel)return!1;let q=(0,T.Sd)(_,dt);return q&&q.dom.contains(_.root.activeElement)&&_.focus(),_.dispatch({effects:Ve.of(!1)}),!0},Ti=[{key:"Mod-f",run:At,scope:"editor search-panel"},{key:"F3",run:pe,shift:ae,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:pe,shift:ae,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Ot,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Fe},{key:"Mod-Alt-g",run:pi},{key:"Mod-d",run:nt,preventDefault:!0}];class lt{constructor(E){this.view=E;let q=this.query=E.state.field(yt).query.spec;this.commit=this.commit.bind(this),this.searchField=(0,te.Z)("input",{value:q.search,placeholder:rt(E,"Find"),"aria-label":rt(E,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=(0,te.Z)("input",{value:q.replace,placeholder:rt(E,"Replace"),"aria-label":rt(E,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=(0,te.Z)("input",{type:"checkbox",name:"case",form:"",checked:q.caseSensitive,onchange:this.commit}),this.reField=(0,te.Z)("input",{type:"checkbox",name:"re",form:"",checked:q.regexp,onchange:this.commit}),this.wordField=(0,te.Z)("input",{type:"checkbox",name:"word",form:"",checked:q.wholeWord,onchange:this.commit});function K(ee,ge,Pe){return(0,te.Z)("button",{class:"cm-button",name:ee,onclick:ge,type:"button"},Pe)}this.dom=(0,te.Z)("div",{onkeydown:ee=>this.keydown(ee),class:"cm-search"},[this.searchField,K("next",()=>pe(E),[rt(E,"next")]),K("prev",()=>ae(E),[rt(E,"previous")]),K("select",()=>Ae(E),[rt(E,"all")]),(0,te.Z)("label",null,[this.caseField,rt(E,"match case")]),(0,te.Z)("label",null,[this.reField,rt(E,"regexp")]),(0,te.Z)("label",null,[this.wordField,rt(E,"by word")]),...E.state.readOnly?[]:[(0,te.Z)("br"),this.replaceField,K("replace",()=>Xe(E),[rt(E,"replace")]),K("replaceAll",()=>qe(E),[rt(E,"replace all")])],(0,te.Z)("button",{name:"close",onclick:()=>Ot(E),"aria-label":rt(E,"close"),type:"button"},["\xD7"])])}commit(){let E=new It({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:st.of(E)}))}keydown(E){(0,T.$1)(this.view,E,"search-panel")?E.preventDefault():E.keyCode==13&&E.target==this.searchField?(E.preventDefault(),(E.shiftKey?ae:pe)(this.view)):E.keyCode==13&&E.target==this.replaceField&&(E.preventDefault(),Xe(this.view))}update(E){for(let q of E.transactions)for(let K of q.effects)K.is(st)&&!K.value.eq(this.query)&&this.setQuery(K.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(kt).top}}function rt(_,E){return _.state.phrase(E)}const Mi=30,Oi=/[\s\.,:;?!]/;function hi(_,{from:E,to:q}){let K=_.state.doc.lineAt(E),ee=_.state.doc.lineAt(q).to,ge=Math.max(K.from,E-Mi),Pe=Math.min(ee,q+Mi),Te=_.state.sliceDoc(ge,Pe);if(ge!=K.from){for(let je=0;je<Mi;je++)if(!Oi.test(Te[je+1])&&Oi.test(Te[je])){Te=Te.slice(je);break}}if(Pe!=ee){for(let je=Te.length-1;je>Te.length-Mi;je--)if(!Oi.test(Te[je-1])&&Oi.test(Te[je])){Te=Te.slice(0,je);break}}return T.tk.announce.of(`${_.state.phrase("current match")}. ${Te} ${_.state.phrase("on line")} ${K.number}.`)}const Pi=T.tk.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"}}),_i=[yt,re.Wl.low(ie),Pi]},78120:function(pn,Ni,it){it.d(Ni,{BO:function(){return ee},D0:function(){return Pi},Gz:function(){return oi},IS:function(){return an},Py:function(){return tt},QQ:function(){return Le},Wl:function(){return st},Xs:function(){return ot},YW:function(){return bt},as:function(){return et},bg:function(){return pi},cp:function(){return Ze},f_:function(){return ri},gc:function(){return Ft},gm:function(){return Ai},jT:function(){return nt},n0:function(){return Tt},nZ:function(){return mi},q6:function(){return qe},r$:function(){return It},uU:function(){return ge},xv:function(){return re},yy:function(){return K}});var T=it(14020);class re{lineAt(o){if(o<0||o>this.length)throw new RangeError(`Invalid position ${o} in document of length ${this.length}`);return this.lineInner(o,!1,1,0)}line(o){if(o<1||o>this.lines)throw new RangeError(`Invalid line number ${o} in ${this.lines}-line document`);return this.lineInner(o,!0,1,0)}replace(o,a,d){[o,a]=Rt(this,o,a);let w=[];return this.decompose(0,o,w,2),d.length&&d.decompose(0,d.length,w,3),this.decompose(a,this.length,w,1),Oe.from(w,this.length-(a-o)+d.length)}append(o){return this.replace(this.length,this.length,o)}slice(o,a=this.length){[o,a]=Rt(this,o,a);let d=[];return this.decompose(o,a,d,0),Oe.from(d,a-o)}eq(o){if(o==this)return!0;if(o.length!=this.length||o.lines!=this.lines)return!1;let a=this.scanIdentical(o,1),d=this.length-this.scanIdentical(o,-1),w=new Jt(this),D=new Jt(o);for(let O=a,H=a;;){if(w.next(O),D.next(O),O=0,w.lineBreak!=D.lineBreak||w.done!=D.done||w.value!=D.value)return!1;if(H+=w.value.length,w.done||H>=d)return!0}}iter(o=1){return new Jt(this,o)}iterRange(o,a=this.length){return new Kt(this,o,a)}iterLines(o,a){let d;if(o==null)d=this.iter();else{a==null&&(a=this.lines+1);let w=this.line(o).from;d=this.iterRange(w,Math.max(w,a==this.lines+1?this.length:a<=1?0:this.line(a-1).to))}return new St(d)}toString(){return this.sliceString(0)}toJSON(){let o=[];return this.flatten(o),o}constructor(){}static of(o){if(o.length==0)throw new RangeError("A document must have at least one line");return o.length==1&&!o[0]?re.empty:o.length<=32?new te(o):Oe.from(te.split(o,[]))}}class te extends re{constructor(o,a=ut(o)){super(),this.text=o,this.length=a}get lines(){return this.text.length}get children(){return null}lineInner(o,a,d,w){for(let D=0;;D++){let O=this.text[D],H=w+O.length;if((a?d:H)>=o)return new Dt(w,H,d,O);w=H+1,d++}}decompose(o,a,d,w){let D=o<=0&&a>=this.length?this:new te(Nt(this.text,o,a),Math.min(a,this.length)-Math.max(0,o));if(w&1){let O=d.pop(),H=Lt(D.text,O.text.slice(),0,D.length);if(H.length<=32)d.push(new te(H,O.length+D.length));else{let Y=H.length>>1;d.push(new te(H.slice(0,Y)),new te(H.slice(Y)))}}else d.push(D)}replace(o,a,d){if(!(d instanceof te))return super.replace(o,a,d);[o,a]=Rt(this,o,a);let w=Lt(this.text,Lt(d.text,Nt(this.text,0,o)),a),D=this.length+d.length-(a-o);return w.length<=32?new te(w,D):Oe.from(te.split(w,[]),D)}sliceString(o,a=this.length,d=`
19
+ `){[o,a]=Rt(this,o,a);let w="";for(let D=0,O=0;D<=a&&O<this.text.length;O++){let H=this.text[O],Y=D+H.length;D>o&&O&&(w+=d),o<Y&&a>D&&(w+=H.slice(Math.max(0,o-D),a-D)),D=Y+1}return w}flatten(o){for(let a of this.text)o.push(a)}scanIdentical(){return 0}static split(o,a){let d=[],w=-1;for(let D of o)d.push(D),w+=D.length+1,d.length==32&&(a.push(new te(d,w)),d=[],w=-1);return w>-1&&a.push(new te(d,w)),a}}class Oe extends re{constructor(o,a){super(),this.children=o,this.length=a,this.lines=0;for(let d of o)this.lines+=d.lines}lineInner(o,a,d,w){for(let D=0;;D++){let O=this.children[D],H=w+O.length,Y=d+O.lines-1;if((a?Y:H)>=o)return O.lineInner(o,a,d,w);w=H+1,d=Y+1}}decompose(o,a,d,w){for(let D=0,O=0;O<=a&&D<this.children.length;D++){let H=this.children[D],Y=O+H.length;if(o<=Y&&a>=O){let ue=w&((O<=o?1:0)|(Y>=a?2:0));O>=o&&Y<=a&&!ue?d.push(H):H.decompose(o-O,a-O,d,ue)}O=Y+1}}replace(o,a,d){if([o,a]=Rt(this,o,a),d.lines<this.lines)for(let w=0,D=0;w<this.children.length;w++){let O=this.children[w],H=D+O.length;if(o>=D&&a<=H){let Y=O.replace(o-D,a-D,d),ue=this.lines-O.lines+Y.lines;if(Y.lines<ue>>5-1&&Y.lines>ue>>5+1){let ve=this.children.slice();return ve[w]=Y,new Oe(ve,this.length-(a-o)+d.length)}return super.replace(D,H,Y)}D=H+1}return super.replace(o,a,d)}sliceString(o,a=this.length,d=`
20
+ `){[o,a]=Rt(this,o,a);let w="";for(let D=0,O=0;D<this.children.length&&O<=a;D++){let H=this.children[D],Y=O+H.length;O>o&&D&&(w+=d),o<Y&&a>O&&(w+=H.sliceString(o-O,a-O,d)),O=Y+1}return w}flatten(o){for(let a of this.children)a.flatten(o)}scanIdentical(o,a){if(!(o instanceof Oe))return 0;let d=0,[w,D,O,H]=a>0?[0,0,this.children.length,o.children.length]:[this.children.length-1,o.children.length-1,-1,-1];for(;;w+=a,D+=a){if(w==O||D==H)return d;let Y=this.children[w],ue=o.children[D];if(Y!=ue)return d+Y.scanIdentical(ue,a);d+=Y.length+1}}static from(o,a=o.reduce((d,w)=>d+w.length+1,-1)){let d=0;for(let $e of o)d+=$e.lines;if(d<32){let $e=[];for(let jt of o)jt.flatten($e);return new te($e,a)}let w=Math.max(32,d>>5),D=w<<1,O=w>>1,H=[],Y=0,ue=-1,ve=[];function Ee($e){let jt;if($e.lines>D&&$e instanceof Oe)for(let Fi of $e.children)Ee(Fi);else $e.lines>O&&(Y>O||!Y)?(ze(),H.push($e)):$e instanceof te&&Y&&(jt=ve[ve.length-1])instanceof te&&$e.lines+jt.lines<=32?(Y+=$e.lines,ue+=$e.length+1,ve[ve.length-1]=new te(jt.text.concat($e.text),jt.length+1+$e.length)):(Y+$e.lines>w&&ze(),Y+=$e.lines,ue+=$e.length+1,ve.push($e))}function ze(){Y!=0&&(H.push(ve.length==1?ve[0]:Oe.from(ve,ue)),ue=-1,Y=ve.length=0)}for(let $e of o)Ee($e);return ze(),H.length==1?H[0]:new Oe(H,a)}}re.empty=new te([""],0);function ut(R){let o=-1;for(let a of R)o+=a.length+1;return o}function Lt(R,o,a=0,d=1e9){for(let w=0,D=0,O=!0;D<R.length&&w<=d;D++){let H=R[D],Y=w+H.length;Y>=a&&(Y>d&&(H=H.slice(0,d-w)),w<a&&(H=H.slice(a-w)),O?(o[o.length-1]+=H,O=!1):o.push(H)),w=Y+1}return o}function Nt(R,o,a){return Lt(R,[""],o,a)}class Jt{constructor(o,a=1){this.dir=a,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[o],this.offsets=[a>0?1:(o instanceof te?o.text.length:o.children.length)<<1]}nextInner(o,a){for(this.done=this.lineBreak=!1;;){let d=this.nodes.length-1,w=this.nodes[d],D=this.offsets[d],O=D>>1,H=w instanceof te?w.text.length:w.children.length;if(O==(a>0?H:0)){if(d==0)return this.done=!0,this.value="",this;a>0&&this.offsets[d-1]++,this.nodes.pop(),this.offsets.pop()}else if((D&1)==(a>0?0:1)){if(this.offsets[d]+=a,o==0)return this.lineBreak=!0,this.value=`
21
+ `,this;o--}else if(w instanceof te){let Y=w.text[O+(a<0?-1:0)];if(this.offsets[d]+=a,Y.length>Math.max(0,o))return this.value=o==0?Y:a>0?Y.slice(o):Y.slice(0,Y.length-o),this;o-=Y.length}else{let Y=w.children[O+(a<0?-1:0)];o>Y.length?(o-=Y.length,this.offsets[d]+=a):(a<0&&this.offsets[d]--,this.nodes.push(Y),this.offsets.push(a>0?1:(Y instanceof te?Y.text.length:Y.children.length)<<1))}}}next(o=0){return o<0&&(this.nextInner(-o,-this.dir),o=this.value.length),this.nextInner(o,this.dir)}}class Kt{constructor(o,a,d){this.value="",this.done=!1,this.cursor=new Jt(o,a>d?-1:1),this.pos=a>d?o.length:0,this.from=Math.min(a,d),this.to=Math.max(a,d)}nextInner(o,a){if(a<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;o+=Math.max(0,a<0?this.pos-this.to:this.from-this.pos);let d=a<0?this.pos-this.from:this.to-this.pos;o>d&&(o=d),d-=o;let{value:w}=this.cursor.next(o);return this.pos+=(w.length+o)*a,this.value=w.length<=d?w:a<0?w.slice(w.length-d):w.slice(0,d),this.done=!this.value,this}next(o=0){return o<0?o=Math.max(o,this.from-this.pos):o>0&&(o=Math.min(o,this.to-this.pos)),this.nextInner(o,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class St{constructor(o){this.inner=o,this.afterBreak=!0,this.value="",this.done=!1}next(o=0){let{done:a,lineBreak:d,value:w}=this.inner.next(o);return a&&this.afterBreak?(this.value="",this.afterBreak=!1):a?(this.done=!0,this.value=""):d?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=w,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(re.prototype[Symbol.iterator]=function(){return this.iter()},Jt.prototype[Symbol.iterator]=Kt.prototype[Symbol.iterator]=St.prototype[Symbol.iterator]=function(){return this});class Dt{constructor(o,a,d,w){this.from=o,this.to=a,this.number=d,this.text=w}get length(){return this.to-this.from}}function Rt(R,o,a){return o=Math.max(0,Math.min(R.length,o)),[o,Math.max(o,Math.min(R.length,a))]}function Ze(R,o,a=!0,d=!0){return(0,T.c)(R,o,a,d)}function wi(R){return R>=56320&&R<57344}function Ut(R){return R>=55296&&R<56320}function Ai(R,o){let a=R.charCodeAt(o);if(!Ut(a)||o+1==R.length)return a;let d=R.charCodeAt(o+1);return wi(d)?(a-55296<<10)+(d-56320)+65536:a}function pi(R){return R<=65535?String.fromCharCode(R):(R-=65536,String.fromCharCode((R>>10)+55296,(R&1023)+56320))}function mi(R){return R<65536?1:2}const Gt=/\r\n?|\n/;var Ft=function(R){return R[R.Simple=0]="Simple",R[R.TrackDel=1]="TrackDel",R[R.TrackBefore=2]="TrackBefore",R[R.TrackAfter=3]="TrackAfter",R}(Ft||(Ft={}));class Tt{constructor(o){this.sections=o}get length(){let o=0;for(let a=0;a<this.sections.length;a+=2)o+=this.sections[a];return o}get newLength(){let o=0;for(let a=0;a<this.sections.length;a+=2){let d=this.sections[a+1];o+=d<0?this.sections[a]:d}return o}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(o){for(let a=0,d=0,w=0;a<this.sections.length;){let D=this.sections[a++],O=this.sections[a++];O<0?(o(d,w,D),w+=D):w+=O,d+=D}}iterChangedRanges(o,a=!1){Je(this,o,a)}get invertedDesc(){let o=[];for(let a=0;a<this.sections.length;){let d=this.sections[a++],w=this.sections[a++];w<0?o.push(d,w):o.push(w,d)}return new Tt(o)}composeDesc(o){return this.empty?o:o.empty?this:ki(this,o)}mapDesc(o,a=!1){return o.empty?this:di(this,o,a)}mapPos(o,a=-1,d=Ft.Simple){let w=0,D=0;for(let O=0;O<this.sections.length;){let H=this.sections[O++],Y=this.sections[O++],ue=w+H;if(Y<0){if(ue>o)return D+(o-w);D+=H}else{if(d!=Ft.Simple&&ue>=o&&(d==Ft.TrackDel&&w<o&&ue>o||d==Ft.TrackBefore&&w<o||d==Ft.TrackAfter&&ue>o))return null;if(ue>o||ue==o&&a<0&&!H)return o==w||a<0?D:D+Y;D+=Y}w=ue}if(o>w)throw new RangeError(`Position ${o} is out of range for changeset of length ${w}`);return D}touchesRange(o,a=o){for(let d=0,w=0;d<this.sections.length&&w<=a;){let D=this.sections[d++],O=this.sections[d++],H=w+D;if(O>=0&&w<=a&&H>=o)return w<o&&H>a?"cover":!0;w=H}return!1}toString(){let o="";for(let a=0;a<this.sections.length;){let d=this.sections[a++],w=this.sections[a++];o+=(o?" ":"")+d+(w>=0?":"+w:"")}return o}toJSON(){return this.sections}static fromJSON(o){if(!Array.isArray(o)||o.length%2||o.some(a=>typeof a!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Tt(o)}static create(o){return new Tt(o)}}class et extends Tt{constructor(o,a){super(o),this.inserted=a}apply(o){if(this.length!=o.length)throw new RangeError("Applying change set to a document with the wrong length");return Je(this,(a,d,w,D,O)=>o=o.replace(w,w+(d-a),O),!1),o}mapDesc(o,a=!1){return di(this,o,a,!0)}invert(o){let a=this.sections.slice(),d=[];for(let w=0,D=0;w<a.length;w+=2){let O=a[w],H=a[w+1];if(H>=0){a[w]=H,a[w+1]=O;let Y=w>>1;for(;d.length<Y;)d.push(re.empty);d.push(O?o.slice(D,D+O):re.empty)}D+=O}return new et(a,d)}compose(o){return this.empty?o:o.empty?this:ki(this,o,!0)}map(o,a=!1){return o.empty?this:di(this,o,a,!0)}iterChanges(o,a=!1){Je(this,o,a)}get desc(){return Tt.create(this.sections)}filter(o){let a=[],d=[],w=[],D=new Xt(this);e:for(let O=0,H=0;;){let Y=O==o.length?1e9:o[O++];for(;H<Y||H==Y&&D.len==0;){if(D.done)break e;let ve=Math.min(D.len,Y-H);We(w,ve,-1);let Ee=D.ins==-1?-1:D.off==0?D.ins:0;We(a,ve,Ee),Ee>0&&ht(d,a,D.text),D.forward(ve),H+=ve}let ue=o[O++];for(;H<ue;){if(D.done)break e;let ve=Math.min(D.len,ue-H);We(a,ve,-1),We(w,ve,D.ins==-1?-1:D.off==0?D.ins:0),D.forward(ve),H+=ve}}return{changes:new et(a,d),filtered:Tt.create(w)}}toJSON(){let o=[];for(let a=0;a<this.sections.length;a+=2){let d=this.sections[a],w=this.sections[a+1];w<0?o.push(d):w==0?o.push([d]):o.push([d].concat(this.inserted[a>>1].toJSON()))}return o}static of(o,a,d){let w=[],D=[],O=0,H=null;function Y(ve=!1){if(!ve&&!w.length)return;O<a&&We(w,a-O,-1);let Ee=new et(w,D);H=H?H.compose(Ee.map(H)):Ee,w=[],D=[],O=0}function ue(ve){if(Array.isArray(ve))for(let Ee of ve)ue(Ee);else if(ve instanceof et){if(ve.length!=a)throw new RangeError(`Mismatched change set length (got ${ve.length}, expected ${a})`);Y(),H=H?H.compose(ve.map(H)):ve}else{let{from:Ee,to:ze=Ee,insert:$e}=ve;if(Ee>ze||Ee<0||ze>a)throw new RangeError(`Invalid change range ${Ee} to ${ze} (in doc of length ${a})`);let jt=$e?typeof $e=="string"?re.of($e.split(d||Gt)):$e:re.empty,Fi=jt.length;if(Ee==ze&&Fi==0)return;Ee<O&&Y(),Ee>O&&We(w,Ee-O,-1),We(w,ze-Ee,Fi),ht(D,w,jt),O=ze}}return ue(o),Y(!H),H}static empty(o){return new et(o?[o,-1]:[],[])}static fromJSON(o){if(!Array.isArray(o))throw new RangeError("Invalid JSON representation of ChangeSet");let a=[],d=[];for(let w=0;w<o.length;w++){let D=o[w];if(typeof D=="number")a.push(D,-1);else{if(!Array.isArray(D)||typeof D[0]!="number"||D.some((O,H)=>H&&typeof O!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(D.length==1)a.push(D[0],0);else{for(;d.length<w;)d.push(re.empty);d[w]=re.of(D.slice(1)),a.push(D[0],d[w].length)}}}return new et(a,d)}static createSet(o,a){return new et(o,a)}}function We(R,o,a,d=!1){if(o==0&&a<=0)return;let w=R.length-2;w>=0&&a<=0&&a==R[w+1]?R[w]+=o:w>=0&&o==0&&R[w]==0?R[w+1]+=a:d?(R[w]+=o,R[w+1]+=a):R.push(o,a)}function ht(R,o,a){if(a.length==0)return;let d=o.length-2>>1;if(d<R.length)R[R.length-1]=R[R.length-1].append(a);else{for(;R.length<d;)R.push(re.empty);R.push(a)}}function Je(R,o,a){let d=R.inserted;for(let w=0,D=0,O=0;O<R.sections.length;){let H=R.sections[O++],Y=R.sections[O++];if(Y<0)w+=H,D+=H;else{let ue=w,ve=D,Ee=re.empty;for(;ue+=H,ve+=Y,Y&&d&&(Ee=Ee.append(d[O-2>>1])),!(a||O==R.sections.length||R.sections[O+1]<0);)H=R.sections[O++],Y=R.sections[O++];o(w,ue,D,ve,Ee),w=ue,D=ve}}}function di(R,o,a,d=!1){let w=[],D=d?[]:null,O=new Xt(R),H=new Xt(o);for(let Y=-1;;){if(O.done&&H.len||H.done&&O.len)throw new Error("Mismatched change set lengths");if(O.ins==-1&&H.ins==-1){let ue=Math.min(O.len,H.len);We(w,ue,-1),O.forward(ue),H.forward(ue)}else if(H.ins>=0&&(O.ins<0||Y==O.i||O.off==0&&(H.len<O.len||H.len==O.len&&!a))){let ue=H.len;for(We(w,H.ins,-1);ue;){let ve=Math.min(O.len,ue);O.ins>=0&&Y<O.i&&O.len<=ve&&(We(w,0,O.ins),D&&ht(D,w,O.text),Y=O.i),O.forward(ve),ue-=ve}H.next()}else if(O.ins>=0){let ue=0,ve=O.len;for(;ve;)if(H.ins==-1){let Ee=Math.min(ve,H.len);ue+=Ee,ve-=Ee,H.forward(Ee)}else if(H.ins==0&&H.len<ve)ve-=H.len,H.next();else break;We(w,ue,Y<O.i?O.ins:0),D&&Y<O.i&&ht(D,w,O.text),Y=O.i,O.forward(O.len-ve)}else{if(O.done&&H.done)return D?et.createSet(w,D):Tt.create(w);throw new Error("Mismatched change set lengths")}}}function ki(R,o,a=!1){let d=[],w=a?[]:null,D=new Xt(R),O=new Xt(o);for(let H=!1;;){if(D.done&&O.done)return w?et.createSet(d,w):Tt.create(d);if(D.ins==0)We(d,D.len,0,H),D.next();else if(O.len==0&&!O.done)We(d,0,O.ins,H),w&&ht(w,d,O.text),O.next();else{if(D.done||O.done)throw new Error("Mismatched change set lengths");{let Y=Math.min(D.len2,O.len),ue=d.length;if(D.ins==-1){let ve=O.ins==-1?-1:O.off?0:O.ins;We(d,Y,ve,H),w&&ve&&ht(w,d,O.text)}else O.ins==-1?(We(d,D.off?0:D.len,Y,H),w&&ht(w,d,D.textBit(Y))):(We(d,D.off?0:D.len,O.off?0:O.ins,H),w&&!O.off&&ht(w,d,O.text));H=(D.ins>Y||O.ins>=0&&O.len>Y)&&(H||d.length>ue),D.forward2(Y),O.forward(Y)}}}}class Xt{constructor(o){this.set=o,this.i=0,this.next()}next(){let{sections:o}=this.set;this.i<o.length?(this.len=o[this.i++],this.ins=o[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:o}=this.set,a=this.i-2>>1;return a>=o.length?re.empty:o[a]}textBit(o){let{inserted:a}=this.set,d=this.i-2>>1;return d>=a.length&&!o?re.empty:a[d].slice(this.off,o==null?void 0:this.off+o)}forward(o){o==this.len?this.next():(this.len-=o,this.off+=o)}forward2(o){this.ins==-1?this.forward(o):o==this.ins?this.next():(this.ins-=o,this.off+=o)}}class si{constructor(o,a,d){this.from=o,this.to=a,this.flags=d}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let o=this.flags&7;return o==7?null:o}get goalColumn(){let o=this.flags>>6;return o==16777215?void 0:o}map(o,a=-1){let d,w;return this.empty?d=w=o.mapPos(this.from,a):(d=o.mapPos(this.from,1),w=o.mapPos(this.to,-1)),d==this.from&&w==this.to?this:new si(d,w,this.flags)}extend(o,a=o){if(o<=this.anchor&&a>=this.anchor)return nt.range(o,a);let d=Math.abs(o-this.anchor)>Math.abs(a-this.anchor)?o:a;return nt.range(this.anchor,d)}eq(o,a=!1){return this.anchor==o.anchor&&this.head==o.head&&(!a||!this.empty||this.assoc==o.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(o){if(!o||typeof o.anchor!="number"||typeof o.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return nt.range(o.anchor,o.head)}static create(o,a,d){return new si(o,a,d)}}class nt{constructor(o,a){this.ranges=o,this.mainIndex=a}map(o,a=-1){return o.empty?this:nt.create(this.ranges.map(d=>d.map(o,a)),this.mainIndex)}eq(o,a=!1){if(this.ranges.length!=o.ranges.length||this.mainIndex!=o.mainIndex)return!1;for(let d=0;d<this.ranges.length;d++)if(!this.ranges[d].eq(o.ranges[d],a))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new nt([this.main],0)}addRange(o,a=!0){return nt.create([o].concat(this.ranges),a?0:this.mainIndex+1)}replaceRange(o,a=this.mainIndex){let d=this.ranges.slice();return d[a]=o,nt.create(d,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(o=>o.toJSON()),main:this.mainIndex}}static fromJSON(o){if(!o||!Array.isArray(o.ranges)||typeof o.main!="number"||o.main>=o.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new nt(o.ranges.map(a=>si.fromJSON(a)),o.main)}static single(o,a=o){return new nt([nt.range(o,a)],0)}static create(o,a=0){if(o.length==0)throw new RangeError("A selection needs at least one range");for(let d=0,w=0;w<o.length;w++){let D=o[w];if(D.empty?D.from<=d:D.from<d)return nt.normalized(o.slice(),a);d=D.to}return new nt(o,a)}static cursor(o,a=0,d,w){return si.create(o,o,(a==0?0:a<0?8:16)|(d==null?7:Math.min(6,d))|(w??16777215)<<6)}static range(o,a,d,w){let D=(d??16777215)<<6|(w==null?7:Math.min(6,w));return a<o?si.create(a,o,48|D):si.create(o,a,(a>o?8:0)|D)}static normalized(o,a=0){let d=o[a];o.sort((w,D)=>w.from-D.from),a=o.indexOf(d);for(let w=1;w<o.length;w++){let D=o[w],O=o[w-1];if(D.empty?D.from<=O.to:D.from<O.to){let H=O.from,Y=Math.max(D.to,O.to);w<=a&&a--,o.splice(--w,2,D.anchor>D.head?nt.range(Y,H):nt.range(H,Y))}}return new nt(o,a)}}function kt(R,o){for(let a of R.ranges)if(a.to>o)throw new RangeError("Selection points outside of document")}let ft=0;class It{constructor(o,a,d,w,D){this.combine=o,this.compareInput=a,this.compare=d,this.isStatic=w,this.id=ft++,this.default=o([]),this.extensions=typeof D=="function"?D(this):D}get reader(){return this}static define(o={}){return new It(o.combine||(a=>a),o.compareInput||((a,d)=>a===d),o.compare||(o.combine?(a,d)=>a===d:$t),!!o.static,o.enables)}of(o){return new Et([],this,0,o)}compute(o,a){if(this.isStatic)throw new Error("Can't compute a static facet");return new Et(o,this,1,a)}computeN(o,a){if(this.isStatic)throw new Error("Can't compute a static facet");return new Et(o,this,2,a)}from(o,a){return a||(a=d=>d),this.compute([o],d=>a(d.field(o)))}}function $t(R,o){return R==o||R.length==o.length&&R.every((a,d)=>a===o[d])}class Et{constructor(o,a,d,w){this.dependencies=o,this.facet=a,this.type=d,this.value=w,this.id=ft++}dynamicSlot(o){var a;let d=this.value,w=this.facet.compareInput,D=this.id,O=o[D]>>1,H=this.type==2,Y=!1,ue=!1,ve=[];for(let Ee of this.dependencies)Ee=="doc"?Y=!0:Ee=="selection"?ue=!0:((a=o[Ee.id])!==null&&a!==void 0?a:1)&1||ve.push(o[Ee.id]);return{create(Ee){return Ee.values[O]=d(Ee),1},update(Ee,ze){if(Y&&ze.docChanged||ue&&(ze.docChanged||ze.selection)||Yt(Ee,ve)){let $e=d(Ee);if(H?!vi($e,Ee.values[O],w):!w($e,Ee.values[O]))return Ee.values[O]=$e,1}return 0},reconfigure:(Ee,ze)=>{let $e,jt=ze.config.address[D];if(jt!=null){let Fi=Bt(ze,jt);if(this.dependencies.every(ii=>ii instanceof It?ze.facet(ii)===Ee.facet(ii):ii instanceof Le?ze.field(ii,!1)==Ee.field(ii,!1):!0)||(H?vi($e=d(Ee),Fi,w):w($e=d(Ee),Fi)))return Ee.values[O]=Fi,0}else $e=d(Ee);return Ee.values[O]=$e,1}}}}function vi(R,o,a){if(R.length!=o.length)return!1;for(let d=0;d<R.length;d++)if(!a(R[d],o[d]))return!1;return!0}function Yt(R,o){let a=!1;for(let d of o)zt(R,d)&1&&(a=!0);return a}function ye(R,o,a){let d=a.map(Y=>R[Y.id]),w=a.map(Y=>Y.type),D=d.filter(Y=>!(Y&1)),O=R[o.id]>>1;function H(Y){let ue=[];for(let ve=0;ve<d.length;ve++){let Ee=Bt(Y,d[ve]);if(w[ve]==2)for(let ze of Ee)ue.push(ze);else ue.push(Ee)}return o.combine(ue)}return{create(Y){for(let ue of d)zt(Y,ue);return Y.values[O]=H(Y),1},update(Y,ue){if(!Yt(Y,D))return 0;let ve=H(Y);return o.compare(ve,Y.values[O])?0:(Y.values[O]=ve,1)},reconfigure(Y,ue){let ve=Yt(Y,d),Ee=ue.config.facets[o.id],ze=ue.facet(o);if(Ee&&!ve&&$t(a,Ee))return Y.values[O]=ze,0;let $e=H(Y);return o.compare($e,ze)?(Y.values[O]=ze,0):(Y.values[O]=$e,1)}}}const Be=It.define({static:!0});class Le{constructor(o,a,d,w,D){this.id=o,this.createF=a,this.updateF=d,this.compareF=w,this.spec=D,this.provides=void 0}static define(o){let a=new Le(ft++,o.create,o.update,o.compare||((d,w)=>d===w),o);return o.provide&&(a.provides=o.provide(a)),a}create(o){let a=o.facet(Be).find(d=>d.field==this);return((a==null?void 0:a.create)||this.createF)(o)}slot(o){let a=o[this.id]>>1;return{create:d=>(d.values[a]=this.create(d),1),update:(d,w)=>{let D=d.values[a],O=this.updateF(D,w);return this.compareF(D,O)?0:(d.values[a]=O,1)},reconfigure:(d,w)=>{let D=d.facet(Be),O=w.facet(Be),H;return(H=D.find(Y=>Y.field==this))&&H!=O.find(Y=>Y.field==this)?(d.values[a]=H.create(d),1):w.config.address[this.id]!=null?(d.values[a]=w.field(this),0):(d.values[a]=this.create(d),1)}}}init(o){return[this,Be.of({field:this,create:o})]}get extension(){return this}}const Re={lowest:4,low:3,default:2,high:1,highest:0};function Ye(R){return o=>new Ve(o,R)}const st={highest:Ye(Re.highest),high:Ye(Re.high),default:Ye(Re.default),low:Ye(Re.low),lowest:Ye(Re.lowest)};class Ve{constructor(o,a){this.inner=o,this.prec=a}}class yt{of(o){return new ei(this,o)}reconfigure(o){return yt.reconfigure.of({compartment:this,extension:o})}get(o){return o.config.compartments.get(this)}}class ei{constructor(o,a){this.compartment=o,this.inner=a}}class Ct{constructor(o,a,d,w,D,O){for(this.base=o,this.compartments=a,this.dynamicSlots=d,this.address=w,this.staticValues=D,this.facets=O,this.statusTemplate=[];this.statusTemplate.length<d.length;)this.statusTemplate.push(0)}staticFacet(o){let a=this.address[o.id];return a==null?o.default:this.staticValues[a>>1]}static resolve(o,a,d){let w=[],D=Object.create(null),O=new Map;for(let ze of De(o,a,O))ze instanceof Le?w.push(ze):(D[ze.facet.id]||(D[ze.facet.id]=[])).push(ze);let H=Object.create(null),Y=[],ue=[];for(let ze of w)H[ze.id]=ue.length<<1,ue.push($e=>ze.slot($e));let ve=d==null?void 0:d.config.facets;for(let ze in D){let $e=D[ze],jt=$e[0].facet,Fi=ve&&ve[ze]||[];if($e.every(ii=>ii.type==0))if(H[jt.id]=Y.length<<1|1,$t(Fi,$e))Y.push(d.facet(jt));else{let ii=jt.combine($e.map(Qi=>Qi.value));Y.push(d&&jt.compare(ii,d.facet(jt))?d.facet(jt):ii)}else{for(let ii of $e)ii.type==0?(H[ii.id]=Y.length<<1|1,Y.push(ii.value)):(H[ii.id]=ue.length<<1,ue.push(Qi=>ii.dynamicSlot(Qi)));H[jt.id]=ue.length<<1,ue.push(ii=>ye(ii,jt,$e))}}let Ee=ue.map(ze=>ze(H));return new Ct(o,O,Ee,H,Y,D)}}function De(R,o,a){let d=[[],[],[],[],[]],w=new Map;function D(O,H){let Y=w.get(O);if(Y!=null){if(Y<=H)return;let ue=d[Y].indexOf(O);ue>-1&&d[Y].splice(ue,1),O instanceof ei&&a.delete(O.compartment)}if(w.set(O,H),Array.isArray(O))for(let ue of O)D(ue,H);else if(O instanceof ei){if(a.has(O.compartment))throw new RangeError("Duplicate use of compartment in extensions");let ue=o.get(O.compartment)||O.inner;a.set(O.compartment,ue),D(ue,H)}else if(O instanceof Ve)D(O.inner,O.prec);else if(O instanceof Le)d[H].push(O),O.provides&&D(O.provides,H);else if(O instanceof Et)d[H].push(O),O.facet.extensions&&D(O.facet.extensions,Re.default);else{let ue=O.extension;if(!ue)throw new Error(`Unrecognized extension value in extension set (${O}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);D(ue,H)}}return D(R,Re.default),d.reduce((O,H)=>O.concat(H))}function zt(R,o){if(o&1)return 2;let a=o>>1,d=R.status[a];if(d==4)throw new Error("Cyclic dependency between fields and/or facets");if(d&2)return d;R.status[a]=4;let w=R.computeSlot(R,R.config.dynamicSlots[a]);return R.status[a]=2|w}function Bt(R,o){return o&1?R.config.staticValues[o>>1]:R.values[o>>1]}const ie=It.define(),X=It.define({combine:R=>R.some(o=>o),static:!0}),pe=It.define({combine:R=>R.length?R[0]:void 0,static:!0}),ae=It.define(),Ae=It.define(),Fe=It.define(),Xe=It.define({combine:R=>R.length?R[0]:!1});class qe{constructor(o,a){this.type=o,this.value=a}static define(){return new dt}}class dt{of(o){return new qe(this,o)}}class xt{constructor(o){this.map=o}of(o){return new tt(this,o)}}class tt{constructor(o,a){this.type=o,this.value=a}map(o){let a=this.type.map(this.value,o);return a===void 0?void 0:a==this.value?this:new tt(this.type,a)}is(o){return this.type==o}static define(o={}){return new xt(o.map||(a=>a))}static mapEffects(o,a){if(!o.length)return o;let d=[];for(let w of o){let D=w.map(a);D&&d.push(D)}return d}}tt.reconfigure=tt.define(),tt.appendConfig=tt.define();class bt{constructor(o,a,d,w,D,O){this.startState=o,this.changes=a,this.selection=d,this.effects=w,this.annotations=D,this.scrollIntoView=O,this._doc=null,this._state=null,d&&kt(d,a.newLength),D.some(H=>H.type==bt.time)||(this.annotations=D.concat(bt.time.of(Date.now())))}static create(o,a,d,w,D,O){return new bt(o,a,d,w,D,O)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(o){for(let a of this.annotations)if(a.type==o)return a.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(o){let a=this.annotation(bt.userEvent);return!!(a&&(a==o||a.length>o.length&&a.slice(0,o.length)==o&&a[o.length]=="."))}}bt.time=qe.define(),bt.userEvent=qe.define(),bt.addToHistory=qe.define(),bt.remote=qe.define();function At(R,o){let a=[];for(let d=0,w=0;;){let D,O;if(d<R.length&&(w==o.length||o[w]>=R[d]))D=R[d++],O=R[d++];else if(w<o.length)D=o[w++],O=o[w++];else return a;!a.length||a[a.length-1]<D?a.push(D,O):a[a.length-1]<O&&(a[a.length-1]=O)}}function Ot(R,o,a){var d;let w,D,O;return a?(w=o.changes,D=et.empty(o.changes.length),O=R.changes.compose(o.changes)):(w=o.changes.map(R.changes),D=R.changes.mapDesc(o.changes,!0),O=R.changes.compose(w)),{changes:O,selection:o.selection?o.selection.map(D):(d=R.selection)===null||d===void 0?void 0:d.map(w),effects:tt.mapEffects(R.effects,w).concat(tt.mapEffects(o.effects,D)),annotations:R.annotations.length?R.annotations.concat(o.annotations):o.annotations,scrollIntoView:R.scrollIntoView||o.scrollIntoView}}function Ti(R,o,a){let d=o.selection,w=hi(o.annotations);return o.userEvent&&(w=w.concat(bt.userEvent.of(o.userEvent))),{changes:o.changes instanceof et?o.changes:et.of(o.changes||[],a,R.facet(pe)),selection:d&&(d instanceof nt?d:nt.single(d.anchor,d.head)),effects:hi(o.effects),annotations:w,scrollIntoView:!!o.scrollIntoView}}function lt(R,o,a){let d=Ti(R,o.length?o[0]:{},R.doc.length);o.length&&o[0].filter===!1&&(a=!1);for(let D=1;D<o.length;D++){o[D].filter===!1&&(a=!1);let O=!!o[D].sequential;d=Ot(d,Ti(R,o[D],O?d.changes.newLength:R.doc.length),O)}let w=bt.create(R,d.changes,d.selection,d.effects,d.annotations,d.scrollIntoView);return Mi(a?rt(w):w)}function rt(R){let o=R.startState,a=!0;for(let w of o.facet(ae)){let D=w(R);if(D===!1){a=!1;break}Array.isArray(D)&&(a=a===!0?D:At(a,D))}if(a!==!0){let w,D;if(a===!1)D=R.changes.invertedDesc,w=et.empty(o.doc.length);else{let O=R.changes.filter(a);w=O.changes,D=O.filtered.mapDesc(O.changes).invertedDesc}R=bt.create(o,w,R.selection&&R.selection.map(D),tt.mapEffects(R.effects,D),R.annotations,R.scrollIntoView)}let d=o.facet(Ae);for(let w=d.length-1;w>=0;w--){let D=d[w](R);D instanceof bt?R=D:Array.isArray(D)&&D.length==1&&D[0]instanceof bt?R=D[0]:R=lt(o,hi(D),!1)}return R}function Mi(R){let o=R.startState,a=o.facet(Fe),d=R;for(let w=a.length-1;w>=0;w--){let D=a[w](R);D&&Object.keys(D).length&&(d=Ot(d,Ti(o,D,R.changes.newLength),!0))}return d==R?R:bt.create(o,R.changes,R.selection,d.effects,d.annotations,d.scrollIntoView)}const Oi=[];function hi(R){return R==null?Oi:Array.isArray(R)?R:[R]}var Pi=function(R){return R[R.Word=0]="Word",R[R.Space=1]="Space",R[R.Other=2]="Other",R}(Pi||(Pi={}));const _i=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let _;try{_=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function E(R){if(_)return _.test(R);for(let o=0;o<R.length;o++){let a=R[o];if(/\w/.test(a)||a>"\x80"&&(a.toUpperCase()!=a.toLowerCase()||_i.test(a)))return!0}return!1}function q(R){return o=>{if(!/\S/.test(o))return Pi.Space;if(E(o))return Pi.Word;for(let a=0;a<R.length;a++)if(o.indexOf(R[a])>-1)return Pi.Word;return Pi.Other}}class K{constructor(o,a,d,w,D,O){this.config=o,this.doc=a,this.selection=d,this.values=w,this.status=o.statusTemplate.slice(),this.computeSlot=D,O&&(O._state=this);for(let H=0;H<this.config.dynamicSlots.length;H++)zt(this,H<<1);this.computeSlot=null}field(o,a=!0){let d=this.config.address[o.id];if(d==null){if(a)throw new RangeError("Field is not present in this state");return}return zt(this,d),Bt(this,d)}update(...o){return lt(this,o,!0)}applyTransaction(o){let a=this.config,{base:d,compartments:w}=a;for(let H of o.effects)H.is(yt.reconfigure)?(a&&(w=new Map,a.compartments.forEach((Y,ue)=>w.set(ue,Y)),a=null),w.set(H.value.compartment,H.value.extension)):H.is(tt.reconfigure)?(a=null,d=H.value):H.is(tt.appendConfig)&&(a=null,d=hi(d).concat(H.value));let D;a?D=o.startState.values.slice():(a=Ct.resolve(d,w,this),D=new K(a,this.doc,this.selection,a.dynamicSlots.map(()=>null),(Y,ue)=>ue.reconfigure(Y,this),null).values);let O=o.startState.facet(X)?o.newSelection:o.newSelection.asSingle();new K(a,o.newDoc,O,D,(H,Y)=>Y.update(H,o),o)}replaceSelection(o){return typeof o=="string"&&(o=this.toText(o)),this.changeByRange(a=>({changes:{from:a.from,to:a.to,insert:o},range:nt.cursor(a.from+o.length)}))}changeByRange(o){let a=this.selection,d=o(a.ranges[0]),w=this.changes(d.changes),D=[d.range],O=hi(d.effects);for(let H=1;H<a.ranges.length;H++){let Y=o(a.ranges[H]),ue=this.changes(Y.changes),ve=ue.map(w);for(let ze=0;ze<H;ze++)D[ze]=D[ze].map(ve);let Ee=w.mapDesc(ue,!0);D.push(Y.range.map(Ee)),w=w.compose(ve),O=tt.mapEffects(O,ve).concat(tt.mapEffects(hi(Y.effects),Ee))}return{changes:w,selection:nt.create(D,a.mainIndex),effects:O}}changes(o=[]){return o instanceof et?o:et.of(o,this.doc.length,this.facet(K.lineSeparator))}toText(o){return re.of(o.split(this.facet(K.lineSeparator)||Gt))}sliceDoc(o=0,a=this.doc.length){return this.doc.sliceString(o,a,this.lineBreak)}facet(o){let a=this.config.address[o.id];return a==null?o.default:(zt(this,a),Bt(this,a))}toJSON(o){let a={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(o)for(let d in o){let w=o[d];w instanceof Le&&this.config.address[w.id]!=null&&(a[d]=w.spec.toJSON(this.field(o[d]),this))}return a}static fromJSON(o,a={},d){if(!o||typeof o.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let w=[];if(d){for(let D in d)if(Object.prototype.hasOwnProperty.call(o,D)){let O=d[D],H=o[D];w.push(O.init(Y=>O.spec.fromJSON(H,Y)))}}return K.create({doc:o.doc,selection:nt.fromJSON(o.selection),extensions:a.extensions?w.concat([a.extensions]):w})}static create(o={}){let a=Ct.resolve(o.extensions||[],new Map),d=o.doc instanceof re?o.doc:re.of((o.doc||"").split(a.staticFacet(K.lineSeparator)||Gt)),w=o.selection?o.selection instanceof nt?o.selection:nt.single(o.selection.anchor,o.selection.head):nt.single(0);return kt(w,d.length),a.staticFacet(X)||(w=w.asSingle()),new K(a,d,w,a.dynamicSlots.map(()=>null),(D,O)=>O.create(D),null)}get tabSize(){return this.facet(K.tabSize)}get lineBreak(){return this.facet(K.lineSeparator)||`
22
+ `}get readOnly(){return this.facet(Xe)}phrase(o,...a){for(let d of this.facet(K.phrases))if(Object.prototype.hasOwnProperty.call(d,o)){o=d[o];break}return a.length&&(o=o.replace(/\$(\$|\d*)/g,(d,w)=>{if(w=="$")return"$";let D=+(w||1);return!D||D>a.length?d:a[D-1]})),o}languageDataAt(o,a,d=-1){let w=[];for(let D of this.facet(ie))for(let O of D(this,a,d))Object.prototype.hasOwnProperty.call(O,o)&&w.push(O[o]);return w}charCategorizer(o){return q(this.languageDataAt("wordChars",o).join(""))}wordAt(o){let{text:a,from:d,length:w}=this.doc.lineAt(o),D=this.charCategorizer(o),O=o-d,H=o-d;for(;O>0;){let Y=Ze(a,O,!1);if(D(a.slice(Y,O))!=Pi.Word)break;O=Y}for(;H<w;){let Y=Ze(a,H);if(D(a.slice(H,Y))!=Pi.Word)break;H=Y}return O==H?null:nt.range(O+d,H+d)}}K.allowMultipleSelections=X,K.tabSize=It.define({combine:R=>R.length?R[0]:4}),K.lineSeparator=pe,K.readOnly=Xe,K.phrases=It.define({compare(R,o){let a=Object.keys(R),d=Object.keys(o);return a.length==d.length&&a.every(w=>R[w]==o[w])}}),K.languageData=ie,K.changeFilter=ae,K.transactionFilter=Ae,K.transactionExtender=Fe,yt.reconfigure=tt.define();function ee(R,o,a={}){let d={};for(let w of R)for(let D of Object.keys(w)){let O=w[D],H=d[D];if(H===void 0)d[D]=O;else if(!(H===O||O===void 0))if(Object.hasOwnProperty.call(a,D))d[D]=a[D](H,O);else throw new Error("Config merge conflict for field "+D)}for(let w in o)d[w]===void 0&&(d[w]=o[w]);return d}class ge{eq(o){return this==o}range(o,a=o){return Pe.create(o,a,this)}}ge.prototype.startSide=ge.prototype.endSide=0,ge.prototype.point=!1,ge.prototype.mapMode=Ft.TrackDel;class Pe{constructor(o,a,d){this.from=o,this.to=a,this.value=d}static create(o,a,d){return new Pe(o,a,d)}}function Te(R,o){return R.from-o.from||R.value.startSide-o.value.startSide}class je{constructor(o,a,d,w){this.from=o,this.to=a,this.value=d,this.maxPoint=w}get length(){return this.to[this.to.length-1]}findIndex(o,a,d,w=0){let D=d?this.to:this.from;for(let O=w,H=D.length;;){if(O==H)return O;let Y=O+H>>1,ue=D[Y]-o||(d?this.value[Y].endSide:this.value[Y].startSide)-a;if(Y==O)return ue>=0?O:H;ue>=0?H=Y:O=Y+1}}between(o,a,d,w){for(let D=this.findIndex(a,-1e9,!0),O=this.findIndex(d,1e9,!1,D);D<O;D++)if(w(this.from[D]+o,this.to[D]+o,this.value[D])===!1)return!1}map(o,a){let d=[],w=[],D=[],O=-1,H=-1;for(let Y=0;Y<this.value.length;Y++){let ue=this.value[Y],ve=this.from[Y]+o,Ee=this.to[Y]+o,ze,$e;if(ve==Ee){let jt=a.mapPos(ve,ue.startSide,ue.mapMode);if(jt==null||(ze=$e=jt,ue.startSide!=ue.endSide&&($e=a.mapPos(ve,ue.endSide),$e<ze)))continue}else if(ze=a.mapPos(ve,ue.startSide),$e=a.mapPos(Ee,ue.endSide),ze>$e||ze==$e&&ue.startSide>0&&ue.endSide<=0)continue;($e-ze||ue.endSide-ue.startSide)<0||(O<0&&(O=ze),ue.point&&(H=Math.max(H,$e-ze)),d.push(ue),w.push(ze-O),D.push($e-O))}return{mapped:d.length?new je(w,D,d,H):null,pos:O}}}class ot{constructor(o,a,d,w){this.chunkPos=o,this.chunk=a,this.nextLayer=d,this.maxPoint=w}static create(o,a,d,w){return new ot(o,a,d,w)}get length(){let o=this.chunk.length-1;return o<0?0:Math.max(this.chunkEnd(o),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let o=this.nextLayer.size;for(let a of this.chunk)o+=a.value.length;return o}chunkEnd(o){return this.chunkPos[o]+this.chunk[o].length}update(o){let{add:a=[],sort:d=!1,filterFrom:w=0,filterTo:D=this.length}=o,O=o.filter;if(a.length==0&&!O)return this;if(d&&(a=a.slice().sort(Te)),this.isEmpty)return a.length?ot.of(a):this;let H=new fi(this,null,-1).goto(0),Y=0,ue=[],ve=new ri;for(;H.value||Y<a.length;)if(Y<a.length&&(H.from-a[Y].from||H.startSide-a[Y].value.startSide)>=0){let Ee=a[Y++];ve.addInner(Ee.from,Ee.to,Ee.value)||ue.push(Ee)}else H.rangeIndex==1&&H.chunkIndex<this.chunk.length&&(Y==a.length||this.chunkEnd(H.chunkIndex)<a[Y].from)&&(!O||w>this.chunkEnd(H.chunkIndex)||D<this.chunkPos[H.chunkIndex])&&ve.addChunk(this.chunkPos[H.chunkIndex],this.chunk[H.chunkIndex])?H.nextChunk():((!O||w>H.to||D<H.from||O(H.from,H.to,H.value))&&(ve.addInner(H.from,H.to,H.value)||ue.push(Pe.create(H.from,H.to,H.value))),H.next());return ve.finishInner(this.nextLayer.isEmpty&&!ue.length?ot.empty:this.nextLayer.update({add:ue,filter:O,filterFrom:w,filterTo:D}))}map(o){if(o.empty||this.isEmpty)return this;let a=[],d=[],w=-1;for(let O=0;O<this.chunk.length;O++){let H=this.chunkPos[O],Y=this.chunk[O],ue=o.touchesRange(H,H+Y.length);if(ue===!1)w=Math.max(w,Y.maxPoint),a.push(Y),d.push(o.mapPos(H));else if(ue===!0){let{mapped:ve,pos:Ee}=Y.map(H,o);ve&&(w=Math.max(w,ve.maxPoint),a.push(ve),d.push(Ee))}}let D=this.nextLayer.map(o);return a.length==0?D:new ot(d,a,D||ot.empty,w)}between(o,a,d){if(!this.isEmpty){for(let w=0;w<this.chunk.length;w++){let D=this.chunkPos[w],O=this.chunk[w];if(a>=D&&o<=D+O.length&&O.between(D,o-D,a-D,d)===!1)return}this.nextLayer.between(o,a,d)}}iter(o=0){return qt.from([this]).goto(o)}get isEmpty(){return this.nextLayer==this}static iter(o,a=0){return qt.from(o).goto(a)}static compare(o,a,d,w,D=-1){let O=o.filter(Ee=>Ee.maxPoint>0||!Ee.isEmpty&&Ee.maxPoint>=D),H=a.filter(Ee=>Ee.maxPoint>0||!Ee.isEmpty&&Ee.maxPoint>=D),Y=ci(O,H,d),ue=new Li(O,Y,D),ve=new Li(H,Y,D);d.iterGaps((Ee,ze,$e)=>Ei(ue,Ee,ve,ze,$e,w)),d.empty&&d.length==0&&Ei(ue,0,ve,0,0,w)}static eq(o,a,d=0,w){w==null&&(w=1e9-1);let D=o.filter(ve=>!ve.isEmpty&&a.indexOf(ve)<0),O=a.filter(ve=>!ve.isEmpty&&o.indexOf(ve)<0);if(D.length!=O.length)return!1;if(!D.length)return!0;let H=ci(D,O),Y=new Li(D,H,0).goto(d),ue=new Li(O,H,0).goto(d);for(;;){if(Y.to!=ue.to||!Xi(Y.active,ue.active)||Y.point&&(!ue.point||!Y.point.eq(ue.point)))return!1;if(Y.to>w)return!0;Y.next(),ue.next()}}static spans(o,a,d,w,D=-1){let O=new Li(o,null,D).goto(a),H=a,Y=O.openStart;for(;;){let ue=Math.min(O.to,d);if(O.point){let ve=O.activeForPoint(O.to),Ee=O.pointFrom<a?ve.length+1:O.point.startSide<0?ve.length:Math.min(ve.length,Y);w.point(H,ue,O.point,ve,Ee,O.pointRank),Y=Math.min(O.openEnd(ue),ve.length)}else ue>H&&(w.span(H,ue,O.active,Y),Y=O.openEnd(ue));if(O.to>d)return Y+(O.point&&O.to>d?1:0);H=O.to,O.next()}}static of(o,a=!1){let d=new ri;for(let w of o instanceof Pe?[o]:a?ti(o):o)d.add(w.from,w.to,w.value);return d.finish()}static join(o){if(!o.length)return ot.empty;let a=o[o.length-1];for(let d=o.length-2;d>=0;d--)for(let w=o[d];w!=ot.empty;w=w.nextLayer)a=new ot(w.chunkPos,w.chunk,a,Math.max(w.maxPoint,a.maxPoint));return a}}ot.empty=new ot([],[],null,-1);function ti(R){if(R.length>1)for(let o=R[0],a=1;a<R.length;a++){let d=R[a];if(Te(o,d)>0)return R.slice().sort(Te);o=d}return R}ot.empty.nextLayer=ot.empty;class ri{finishChunk(o){this.chunks.push(new je(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,o&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(o,a,d){this.addInner(o,a,d)||(this.nextLayer||(this.nextLayer=new ri)).add(o,a,d)}addInner(o,a,d){let w=o-this.lastTo||d.startSide-this.last.endSide;if(w<=0&&(o-this.lastFrom||d.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return w<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=o),this.from.push(o-this.chunkStart),this.to.push(a-this.chunkStart),this.last=d,this.lastFrom=o,this.lastTo=a,this.value.push(d),d.point&&(this.maxPoint=Math.max(this.maxPoint,a-o)),!0)}addChunk(o,a){if((o-this.lastTo||a.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,a.maxPoint),this.chunks.push(a),this.chunkPos.push(o);let d=a.value.length-1;return this.last=a.value[d],this.lastFrom=a.from[d]+o,this.lastTo=a.to[d]+o,!0}finish(){return this.finishInner(ot.empty)}finishInner(o){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return o;let a=ot.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(o):o,this.setMaxPoint);return this.from=null,a}}function ci(R,o,a){let d=new Map;for(let D of R)for(let O=0;O<D.chunk.length;O++)D.chunk[O].maxPoint<=0&&d.set(D.chunk[O],D.chunkPos[O]);let w=new Set;for(let D of o)for(let O=0;O<D.chunk.length;O++){let H=d.get(D.chunk[O]);H!=null&&(a?a.mapPos(H):H)==D.chunkPos[O]&&!(a!=null&&a.touchesRange(H,H+D.chunk[O].length))&&w.add(D.chunk[O])}return w}class fi{constructor(o,a,d,w=0){this.layer=o,this.skip=a,this.minPoint=d,this.rank=w}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(o,a=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(o,a,!1),this}gotoInner(o,a,d){for(;this.chunkIndex<this.layer.chunk.length;){let w=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(w)||this.layer.chunkEnd(this.chunkIndex)<o||w.maxPoint<this.minPoint))break;this.chunkIndex++,d=!1}if(this.chunkIndex<this.layer.chunk.length){let w=this.layer.chunk[this.chunkIndex].findIndex(o-this.layer.chunkPos[this.chunkIndex],a,!0);(!d||this.rangeIndex<w)&&this.setRangeIndex(w)}this.next()}forward(o,a){(this.to-o||this.endSide-a)<0&&this.gotoInner(o,a,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let o=this.layer.chunkPos[this.chunkIndex],a=this.layer.chunk[this.chunkIndex],d=o+a.from[this.rangeIndex];if(this.from=d,this.to=o+a.to[this.rangeIndex],this.value=a.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(o){if(o==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=o}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(o){return this.from-o.from||this.startSide-o.startSide||this.rank-o.rank||this.to-o.to||this.endSide-o.endSide}}class qt{constructor(o){this.heap=o}static from(o,a=null,d=-1){let w=[];for(let D=0;D<o.length;D++)for(let O=o[D];!O.isEmpty;O=O.nextLayer)O.maxPoint>=d&&w.push(new fi(O,a,d,D));return w.length==1?w[0]:new qt(w)}get startSide(){return this.value?this.value.startSide:0}goto(o,a=-1e9){for(let d of this.heap)d.goto(o,a);for(let d=this.heap.length>>1;d>=0;d--)gi(this.heap,d);return this.next(),this}forward(o,a){for(let d of this.heap)d.forward(o,a);for(let d=this.heap.length>>1;d>=0;d--)gi(this.heap,d);(this.to-o||this.value.endSide-a)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let o=this.heap[0];this.from=o.from,this.to=o.to,this.value=o.value,this.rank=o.rank,o.value&&o.next(),gi(this.heap,0)}}}function gi(R,o){for(let a=R[o];;){let d=(o<<1)+1;if(d>=R.length)break;let w=R[d];if(d+1<R.length&&w.compare(R[d+1])>=0&&(w=R[d+1],d++),a.compare(w)<0)break;R[d]=a,R[o]=w,o=d}}class Li{constructor(o,a,d){this.minPoint=d,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=qt.from(o,a,d)}goto(o,a=-1e9){return this.cursor.goto(o,a),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=o,this.endSide=a,this.openStart=-1,this.next(),this}forward(o,a){for(;this.minActive>-1&&(this.activeTo[this.minActive]-o||this.active[this.minActive].endSide-a)<0;)this.removeActive(this.minActive);this.cursor.forward(o,a)}removeActive(o){Pt(this.active,o),Pt(this.activeTo,o),Pt(this.activeRank,o),this.minActive=sn(this.active,this.activeTo)}addActive(o){let a=0,{value:d,to:w,rank:D}=this.cursor;for(;a<this.activeRank.length&&(D-this.activeRank[a]||w-this.activeTo[a])>0;)a++;Ji(this.active,a,d),Ji(this.activeTo,a,w),Ji(this.activeRank,a,D),o&&Ji(o,a,this.cursor.from),this.minActive=sn(this.active,this.activeTo)}next(){let o=this.to,a=this.point;this.point=null;let d=this.openStart<0?[]:null;for(;;){let w=this.minActive;if(w>-1&&(this.activeTo[w]-this.cursor.from||this.active[w].endSide-this.cursor.startSide)<0){if(this.activeTo[w]>o){this.to=this.activeTo[w],this.endSide=this.active[w].endSide;break}this.removeActive(w),d&&Pt(d,w)}else if(this.cursor.value)if(this.cursor.from>o){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let D=this.cursor.value;if(!D.point)this.addActive(d),this.cursor.next();else if(a&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=D,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=D.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(d){this.openStart=0;for(let w=d.length-1;w>=0&&d[w]<o;w--)this.openStart++}}activeForPoint(o){if(!this.active.length)return this.active;let a=[];for(let d=this.active.length-1;d>=0&&!(this.activeRank[d]<this.pointRank);d--)(this.activeTo[d]>o||this.activeTo[d]==o&&this.active[d].endSide>=this.point.endSide)&&a.push(this.active[d]);return a.reverse()}openEnd(o){let a=0;for(let d=this.activeTo.length-1;d>=0&&this.activeTo[d]>o;d--)a++;return a}}function Ei(R,o,a,d,w,D){R.goto(o),a.goto(d);let O=d+w,H=d,Y=d-o;for(;;){let ue=R.to+Y-a.to,ve=ue||R.endSide-a.endSide,Ee=ve<0?R.to+Y:a.to,ze=Math.min(Ee,O);if(R.point||a.point?R.point&&a.point&&(R.point==a.point||R.point.eq(a.point))&&Xi(R.activeForPoint(R.to),a.activeForPoint(a.to))||D.comparePoint(H,ze,R.point,a.point):ze>H&&!Xi(R.active,a.active)&&D.compareRange(H,ze,R.active,a.active),Ee>O)break;(ue||R.openEnd!=a.openEnd)&&D.boundChange&&D.boundChange(Ee),H=Ee,ve<=0&&R.next(),ve>=0&&a.next()}}function Xi(R,o){if(R.length!=o.length)return!1;for(let a=0;a<R.length;a++)if(R[a]!=o[a]&&!R[a].eq(o[a]))return!1;return!0}function Pt(R,o){for(let a=o,d=R.length-1;a<d;a++)R[a]=R[a+1];R.pop()}function Ji(R,o,a){for(let d=R.length-1;d>=o;d--)R[d+1]=R[d];R[o]=a}function sn(R,o){let a=-1,d=1e9;for(let w=0;w<o.length;w++)(o[w]-d||R[w].endSide-R[a].endSide)<0&&(a=w,d=o[w]);return a}function an(R,o,a=R.length){let d=0;for(let w=0;w<a&&w<R.length;)R.charCodeAt(w)==9?(d+=o-d%o,w++):(d++,w=Ze(R,w));return d}function oi(R,o,a,d){for(let w=0,D=0;;){if(D>=o)return w;if(w==R.length)break;D+=R.charCodeAt(w)==9?a-D%a:1,w=Ze(R,w)}return d===!0?-1:R.length}},23732:function(pn,Ni,it){it.d(Ni,{vk:function(){return We}});var T=it(47421),re=it(59119),te=it(35524);const Oe="#e5c07b",ut="#e06c75",Lt="#56b6c2",Nt="#ffffff",Jt="#abb2bf",Kt="#7d8799",St="#61afef",Dt="#98c379",Rt="#d19a66",Ze="#c678dd",wi="#21252b",Ut="#2c313a",Ai="#282c34",pi="#353a42",mi="#3E4451",Gt="#528bff",Ft={chalky:Oe,coral:ut,cyan:Lt,invalid:Nt,ivory:Jt,stone:Kt,malibu:St,sage:Dt,whiskey:Rt,violet:Ze,darkBackground:wi,highlightBackground:Ut,background:Ai,tooltipBackground:pi,selection:mi,cursor:Gt},Tt=T.tk.theme({"&":{color:Jt,backgroundColor:Ai},".cm-content":{caretColor:Gt},".cm-cursor, .cm-dropCursor":{borderLeftColor:Gt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:mi},".cm-panels":{backgroundColor:wi,color:Jt},".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:Ai,color:Kt,border:"none"},".cm-activeLineGutter":{backgroundColor:Ut},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:pi},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:pi,borderBottomColor:pi},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Ut,color:Jt}}},{dark:!0}),et=re.Qf.define([{tag:te.pJ.keyword,color:Ze},{tag:[te.pJ.name,te.pJ.deleted,te.pJ.character,te.pJ.propertyName,te.pJ.macroName],color:ut},{tag:[te.pJ.function(te.pJ.variableName),te.pJ.labelName],color:St},{tag:[te.pJ.color,te.pJ.constant(te.pJ.name),te.pJ.standard(te.pJ.name)],color:Rt},{tag:[te.pJ.definition(te.pJ.name),te.pJ.separator],color:Jt},{tag:[te.pJ.typeName,te.pJ.className,te.pJ.number,te.pJ.changed,te.pJ.annotation,te.pJ.modifier,te.pJ.self,te.pJ.namespace],color:Oe},{tag:[te.pJ.operator,te.pJ.operatorKeyword,te.pJ.url,te.pJ.escape,te.pJ.regexp,te.pJ.link,te.pJ.special(te.pJ.string)],color:Lt},{tag:[te.pJ.meta,te.pJ.comment],color:Kt},{tag:te.pJ.strong,fontWeight:"bold"},{tag:te.pJ.emphasis,fontStyle:"italic"},{tag:te.pJ.strikethrough,textDecoration:"line-through"},{tag:te.pJ.link,color:Kt,textDecoration:"underline"},{tag:te.pJ.heading,fontWeight:"bold",color:ut},{tag:[te.pJ.atom,te.pJ.bool,te.pJ.special(te.pJ.variableName)],color:Rt},{tag:[te.pJ.processingInstruction,te.pJ.string,te.pJ.inserted],color:Dt},{tag:te.pJ.invalid,color:Nt}]),We=[Tt,(0,re.nF)(et)]},47421:function(pn,Ni,it){it.d(Ni,{$1:function(){return qr},$f:function(){return Ys},AE:function(){return ao},Eu:function(){return Ko},HQ:function(){return Xo},Nm:function(){return Te},OO:function(){return P},S2:function(){return Ao},SJ:function(){return bn},Sd:function(){return pr},Uw:function(){return Qr},ZO:function(){return mo},Zs:function(){return xo},bF:function(){return Ro},gB:function(){return Io},hJ:function(){return Os},jH:function(){return To},l9:function(){return Ti},lg:function(){return I},mH:function(){return hs},p:function(){return rt},qr:function(){return no},tk:function(){return Ht},v5:function(){return Ho}});var T=it(78120),re=it(28699),te=it(81754);function Oe(s){let e;return s.nodeType==11?e=s.getSelection?s:s.ownerDocument:e=s,e.getSelection()}function ut(s,e){return e?s==e||s.contains(e.nodeType!=1?e.parentNode:e):!1}function Lt(s,e){if(!e.anchorNode)return!1;try{return ut(s,e.anchorNode)}catch{return!1}}function Nt(s){return s.nodeType==3?et(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function Jt(s,e,t,i){return t?Dt(s,e,t,i,-1)||Dt(s,e,t,i,1):!1}function Kt(s){for(var e=0;;e++)if(s=s.previousSibling,!s)return e}function St(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName)}function Dt(s,e,t,i,n){for(;;){if(s==t&&e==i)return!0;if(e==(n<0?0:Rt(s))){if(s.nodeName=="DIV")return!1;let r=s.parentNode;if(!r||r.nodeType!=1)return!1;e=Kt(s)+(n<0?0:1),s=r}else if(s.nodeType==1){if(s=s.childNodes[e+(n<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;e=n<0?Rt(s):0}else return!1}}function Rt(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function Ze(s,e){let t=e?s.left:s.right;return{left:t,right:t,top:s.top,bottom:s.bottom}}function wi(s){let e=s.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function Ut(s,e){let t=e.width/s.offsetWidth,i=e.height/s.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-s.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-s.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Ai(s,e,t,i,n,r,l,c){let m=s.ownerDocument,C=m.defaultView||window;for(let k=s,N=!1;k&&!N;)if(k.nodeType==1){let z,se=k==m.body,he=1,we=1;if(se)z=wi(C);else{if(/^(fixed|sticky)$/.test(getComputedStyle(k).position)&&(N=!0),k.scrollHeight<=k.clientHeight&&k.scrollWidth<=k.clientWidth){k=k.assignedSlot||k.parentNode;continue}let Qe=k.getBoundingClientRect();({scaleX:he,scaleY:we}=Ut(k,Qe)),z={left:Qe.left,right:Qe.left+k.clientWidth*he,top:Qe.top,bottom:Qe.top+k.clientHeight*we}}let ke=0,xe=0;if(n=="nearest")e.top<z.top?(xe=e.top-(z.top+l),t>0&&e.bottom>z.bottom+xe&&(xe=e.bottom-z.bottom+l)):e.bottom>z.bottom&&(xe=e.bottom-z.bottom+l,t<0&&e.top-xe<z.top&&(xe=e.top-(z.top+l)));else{let Qe=e.bottom-e.top,pt=z.bottom-z.top;xe=(n=="center"&&Qe<=pt?e.top+Qe/2-pt/2:n=="start"||n=="center"&&t<0?e.top-l:e.bottom-pt+l)-z.top}if(i=="nearest"?e.left<z.left?(ke=e.left-(z.left+r),t>0&&e.right>z.right+ke&&(ke=e.right-z.right+r)):e.right>z.right&&(ke=e.right-z.right+r,t<0&&e.left<z.left+ke&&(ke=e.left-(z.left+r))):ke=(i=="center"?e.left+(e.right-e.left)/2-(z.right-z.left)/2:i=="start"==c?e.left-r:e.right-(z.right-z.left)+r)-z.left,ke||xe)if(se)C.scrollBy(ke,xe);else{let Qe=0,pt=0;if(xe){let at=k.scrollTop;k.scrollTop+=xe/we,pt=(k.scrollTop-at)*we}if(ke){let at=k.scrollLeft;k.scrollLeft+=ke/he,Qe=(k.scrollLeft-at)*he}e={left:e.left-Qe,top:e.top-pt,right:e.right-Qe,bottom:e.bottom-pt},Qe&&Math.abs(Qe-ke)<1&&(i="nearest"),pt&&Math.abs(pt-xe)<1&&(n="nearest")}if(se)break;(e.top<z.top||e.bottom>z.bottom||e.left<z.left||e.right>z.right)&&(e={left:Math.max(e.left,z.left),right:Math.min(e.right,z.right),top:Math.max(e.top,z.top),bottom:Math.min(e.bottom,z.bottom)}),k=k.assignedSlot||k.parentNode}else if(k.nodeType==11)k=k.host;else break}function pi(s){let e=s.ownerDocument,t,i;for(let n=s.parentNode;n&&!(n==e.body||t&&i);)if(n.nodeType==1)!i&&n.scrollHeight>n.clientHeight&&(i=n),!t&&n.scrollWidth>n.clientWidth&&(t=n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;return{x:t,y:i}}class mi{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?Rt(t):0),i,Math.min(e.focusOffset,i?Rt(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}let Gt=null;function Ft(s){if(s.setActive)return s.setActive();if(Gt)return s.focus(Gt);let e=[];for(let t=s;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(s.focus(Gt==null?{get preventScroll(){return Gt={preventScroll:!0},!0}}:void 0),!Gt){Gt=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],r=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=r&&(i.scrollLeft=r)}}}let Tt;function et(s,e,t=e){let i=Tt||(Tt=document.createRange());return i.setEnd(s,t),i.setStart(s,e),i}function We(s,e,t,i){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=i);let r=new KeyboardEvent("keydown",n);r.synthetic=!0,s.dispatchEvent(r);let l=new KeyboardEvent("keyup",n);return l.synthetic=!0,s.dispatchEvent(l),r.defaultPrevented||l.defaultPrevented}function ht(s){for(;s;){if(s&&(s.nodeType==9||s.nodeType==11&&s.host))return s;s=s.assignedSlot||s.parentNode}return null}function Je(s){for(;s.attributes.length;)s.removeAttributeNode(s.attributes[0])}function di(s,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Rt(t));;)if(i){if(t.nodeType!=1)return!1;let n=t.childNodes[i-1];n.contentEditable=="false"?i--:(t=n,i=Rt(t))}else{if(t==s)return!0;i=Kt(t),t=t.parentNode}}function ki(s){return s.scrollTop>Math.max(1,s.scrollHeight-s.clientHeight-4)}function Xt(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=Rt(t)}else if(t.parentNode&&!St(t))i=Kt(t),t=t.parentNode;else return null}}function si(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!St(t))i=Kt(t)+1,t=t.parentNode;else return null}}class nt{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new nt(e.parentNode,Kt(e),t)}static after(e,t){return new nt(e.parentNode,Kt(e)+1,t)}}const kt=[];class ft{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let i of this.children){if(i==e)return t;t+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let i=this.dom,n=null,r;for(let l of this.children){if(l.flags&7){if(!l.dom&&(r=n?n.nextSibling:i.firstChild)){let c=ft.get(r);(!c||!c.parent&&c.canReuseDOM(l))&&l.reuseDOM(r)}l.sync(e,t),l.flags&=-8}if(r=n?n.nextSibling:i.firstChild,t&&!t.written&&t.node==i&&r!=l.dom&&(t.written=!0),l.dom.parentNode==i)for(;r&&r!=l.dom;)r=It(r);else i.insertBefore(l.dom,r);n=l.dom}for(r=n?n.nextSibling:i.firstChild,r&&t&&t.node==i&&(t.written=!0);r;)r=It(r)}else if(this.flags&1)for(let i of this.children)i.flags&7&&(i.sync(e,t),i.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let i;if(e==this.dom)i=this.dom.childNodes[t];else{let n=Rt(e)==0?0:t==0?-1:1;for(;;){let r=e.parentNode;if(r==this.dom)break;n==0&&r.firstChild!=r.lastChild&&(e==r.firstChild?n=-1:n=1),e=r}n<0?i=e:i=e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!ft.get(i);)i=i.nextSibling;if(!i)return this.length;for(let n=0,r=0;;n++){let l=this.children[n];if(l.dom==i)return r;r+=l.length+l.breakAfter}}domBoundsAround(e,t,i=0){let n=-1,r=-1,l=-1,c=-1;for(let m=0,C=i,k=i;m<this.children.length;m++){let N=this.children[m],z=C+N.length;if(C<e&&z>t)return N.domBoundsAround(e,t,C);if(z>=e&&n==-1&&(n=m,r=C),C>t&&N.dom.parentNode==this.dom){l=m,c=k;break}k=z,C=z+N.breakAfter}return{from:r,to:c<0?i+this.length:c,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:l<this.children.length&&l>=0?this.children[l].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=kt){this.markDirty();for(let n=e;n<t;n++){let r=this.children[n];r.parent==this&&i.indexOf(r)<0&&r.destroy()}i.length<250?this.children.splice(e,t-e,...i):this.children=[].concat(this.children.slice(0,e),i,this.children.slice(t));for(let n=0;n<i.length;n++)i[n].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(e=this.length){return new $t(this.children,e,this.children.length)}childPos(e,t=1){return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+(e=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,i,n,r,l){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}}ft.prototype.breakAfter=0;function It(s){let e=s.nextSibling;return s.parentNode.removeChild(s),e}class $t{constructor(e,t,i){this.children=e,this.pos=t,this.i=i,this.off=0}findPos(e,t=1){for(;;){if(e>this.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Et(s,e,t,i,n,r,l,c,m){let{children:C}=s,k=C.length?C[e]:null,N=r.length?r[r.length-1]:null,z=N?N.breakAfter:l;if(!(e==i&&k&&!l&&!z&&r.length<2&&k.merge(t,n,r.length?N:null,t==0,c,m))){if(i<C.length){let se=C[i];se&&(n<se.length||se.breakAfter&&(N!=null&&N.breakAfter))?(e==i&&(se=se.split(n),n=0),!z&&N&&se.merge(0,n,N,!0,0,m)?r[r.length-1]=se:((n||se.children.length&&!se.children[0].length)&&se.merge(0,n,null,!1,0,m),r.push(se))):se!=null&&se.breakAfter&&(N?N.breakAfter=1:l=1),i++}for(k&&(k.breakAfter=l,t>0&&(!l&&r.length&&k.merge(t,k.length,r[0],!1,c,0)?k.breakAfter=r.shift().breakAfter:(t<k.length||k.children.length&&k.children[k.children.length-1].length==0)&&k.merge(t,k.length,null,!1,c,0),e++));e<i&&r.length;)if(C[i-1].become(r[r.length-1]))i--,r.pop(),m=r.length?0:c;else if(C[e].become(r[0]))e++,r.shift(),c=r.length?0:m;else break;!r.length&&e&&i<C.length&&!C[e-1].breakAfter&&C[i].merge(0,0,C[e-1],!1,c,m)&&e--,(e<i||r.length)&&s.replaceChildren(e,i,r)}}function vi(s,e,t,i,n,r){let l=s.childCursor(),{i:c,off:m}=l.findPos(t,1),{i:C,off:k}=l.findPos(e,-1),N=e-t;for(let z of i)N+=z.length;s.length+=N,Et(s,C,k,c,m,i,0,n,r)}let Yt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},ye=typeof document<"u"?document:{documentElement:{style:{}}};const Be=/Edge\/(\d+)/.exec(Yt.userAgent),Le=/MSIE \d/.test(Yt.userAgent),Re=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Yt.userAgent),Ye=!!(Le||Re||Be),st=!Ye&&/gecko\/(\d+)/i.test(Yt.userAgent),Ve=!Ye&&/Chrome\/(\d+)/.exec(Yt.userAgent),yt="webkitFontSmoothing"in ye.documentElement.style,ei=!Ye&&/Apple Computer/.test(Yt.vendor),Ct=ei&&(/Mobile\/\w+/.test(Yt.userAgent)||Yt.maxTouchPoints>2);var De={mac:Ct||/Mac/.test(Yt.platform),windows:/Win/.test(Yt.platform),linux:/Linux|X11/.test(Yt.platform),ie:Ye,ie_version:Le?ye.documentMode||6:Re?+Re[1]:Be?+Be[1]:0,gecko:st,gecko_version:st?+(/Firefox\/(\d+)/.exec(Yt.userAgent)||[0,0])[1]:0,chrome:!!Ve,chrome_version:Ve?+Ve[1]:0,ios:Ct,android:/Android\b/.test(Yt.userAgent),webkit:yt,safari:ei,webkit_version:yt?+(/\bAppleWebKit\/(\d+)/.exec(Yt.userAgent)||[0,0])[1]:0,tabSize:ye.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const zt=256;class Bt extends ft{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof Bt)||this.length-(t-e)+i.length>zt||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new Bt(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new nt(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return X(this.dom,e,t)}}class ie extends ft{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let n of t)n.setParent(this)}setAttrs(e){if(Je(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,n,r,l){return i&&(!(i instanceof ie&&i.mark.eq(this.mark))||e&&r<=0||t<this.length&&l<=0)?!1:(vi(this,e,t,i?i.children.slice():[],r-1,l-1),this.markDirty(),!0)}split(e){let t=[],i=0,n=-1,r=0;for(let c of this.children){let m=i+c.length;m>e&&t.push(i<e?c.split(e-i):c),n<0&&i>=e&&(n=r),i=m,r++}let l=this.length-e;return this.length=e,n>-1&&(this.children.length=n,this.markDirty()),new ie(this.mark,t,l)}domAtPos(e){return Ae(this,e)}coordsAt(e,t){return Xe(this,e,t)}}function X(s,e,t){let i=s.nodeValue.length;e>i&&(e=i);let n=e,r=e,l=0;e==0&&t<0||e==i&&t>=0?De.chrome||De.gecko||(e?(n--,l=1):r<i&&(r++,l=-1)):t<0?n--:r<i&&r++;let c=et(s,n,r).getClientRects();if(!c.length)return null;let m=c[(l?l<0:t>=0)?0:c.length-1];return De.safari&&!l&&m.width==0&&(m=Array.prototype.find.call(c,C=>C.width)||m),l?Ze(m,l<0):m||null}class pe extends ft{static create(e,t,i){return new pe(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=pe.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,i,n,r,l){return i&&(!(i instanceof pe)||!this.widget.compare(i.widget)||e>0&&r<=0||t<this.length&&l<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}become(e){return e instanceof pe&&e.side==this.side&&this.widget.constructor==e.widget.constructor?(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(this.length==0)return T.xv.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,i=t&&t.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):T.xv.empty}domAtPos(e){return(this.length?e==0:this.side>0)?nt.before(this.dom):nt.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let n=this.dom.getClientRects(),r=null;if(!n.length)return null;let l=this.side?this.side<0:e>0;for(let c=l?n.length-1:0;r=n[c],!(e>0?c==0:c==n.length-1||r.top<r.bottom);c+=l?-1:1);return Ze(r,!l)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class ae extends ft{constructor(e){super(),this.side=e}get length(){return 0}merge(){return!1}become(e){return e instanceof ae&&e.side==this.side}split(){return new ae(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?nt.before(this.dom):nt.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return T.xv.empty}get isHidden(){return!0}}Bt.prototype.children=pe.prototype.children=ae.prototype.children=kt;function Ae(s,e){let t=s.dom,{children:i}=s,n=0;for(let r=0;n<i.length;n++){let l=i[n],c=r+l.length;if(!(c==r&&l.getSide()<=0)){if(e>r&&e<c&&l.dom.parentNode==t)return l.domAtPos(e-r);if(e<=r)break;r=c}}for(let r=n;r>0;r--){let l=i[r-1];if(l.dom.parentNode==t)return l.domAtPos(l.length)}for(let r=n;r<i.length;r++){let l=i[r];if(l.dom.parentNode==t)return l.domAtPos(0)}return new nt(t,0)}function Fe(s,e,t){let i,{children:n}=s;t>0&&e instanceof ie&&n.length&&(i=n[n.length-1])instanceof ie&&i.mark.eq(e.mark)?Fe(i,e.children[0],t-1):(n.push(e),e.setParent(s)),s.length+=e.length}function Xe(s,e,t){let i=null,n=-1,r=null,l=-1;function c(C,k){for(let N=0,z=0;N<C.children.length&&z<=k;N++){let se=C.children[N],he=z+se.length;he>=k&&(se.children.length?c(se,k-z):(!r||r.isHidden&&(t>0||dt(r,se)))&&(he>k||z==he&&se.getSide()>0)?(r=se,l=k-z):(z<k||z==he&&se.getSide()<0&&!se.isHidden)&&(i=se,n=k-z)),z=he}}c(s,e);let m=(t<0?i:r)||i||r;return m?m.coordsAt(Math.max(0,m==i?n:l),t):qe(s)}function qe(s){let e=s.dom.lastChild;if(!e)return s.dom.getBoundingClientRect();let t=Nt(e);return t[t.length-1]||null}function dt(s,e){let t=s.coordsAt(0,1),i=e.coordsAt(0,1);return t&&i&&i.top<t.bottom}function xt(s,e){for(let t in s)t=="class"&&e.class?e.class+=" "+s.class:t=="style"&&e.style?e.style+=";"+s.style:e[t]=s[t];return e}const tt=Object.create(null);function bt(s,e,t){if(s==e)return!0;s||(s=tt),e||(e=tt);let i=Object.keys(s),n=Object.keys(e);if(i.length-(t&&i.indexOf(t)>-1?1:0)!=n.length-(t&&n.indexOf(t)>-1?1:0))return!1;for(let r of i)if(r!=t&&(n.indexOf(r)==-1||s[r]!==e[r]))return!1;return!0}function At(s,e,t){let i=!1;if(e)for(let n in e)t&&n in t||(i=!0,n=="style"?s.style.cssText="":s.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(i=!0,n=="style"?s.style.cssText=t[n]:s.setAttribute(n,t[n]));return i}function Ot(s){let e=Object.create(null);for(let t=0;t<s.attributes.length;t++){let i=s.attributes[t];e[i.name]=i.value}return e}class Ti{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var lt=function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s}(lt||(lt={}));class rt extends T.uU{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new Mi(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new hi(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:l}=Pi(e,t);i=(r?t?-3e8:-1:5e8)-1,n=(l?t?2e8:1:-6e8)+1}return new hi(e,i,n,t,e.widget||null,!0)}static line(e){return new Oi(e)}static set(e,t=!1){return T.Xs.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}rt.none=T.Xs.empty;class Mi extends rt{constructor(e){let{start:t,end:i}=Pi(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof Mi&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&bt(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Mi.prototype.point=!1;class Oi extends rt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Oi&&this.spec.class==e.spec.class&&bt(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Oi.prototype.mapMode=T.gc.TrackBefore,Oi.prototype.point=!0;class hi extends rt{constructor(e,t,i,n,r,l){super(t,i,r,e),this.block=n,this.isReplace=l,this.mapMode=n?t<=0?T.gc.TrackBefore:T.gc.TrackAfter:T.gc.TrackDel}get type(){return this.startSide!=this.endSide?lt.WidgetRange:this.startSide<=0?lt.WidgetBefore:lt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof hi&&_i(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}hi.prototype.point=!0;function Pi(s,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=s;return t==null&&(t=s.inclusive),i==null&&(i=s.inclusive),{start:t??e,end:i??e}}function _i(s,e){return s==e||!!(s&&e&&s.compare(e))}function _(s,e,t,i=0){let n=t.length-1;n>=0&&t[n]+i>=s?t[n]=Math.max(t[n],e):t.push(s,e)}class E extends ft{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,n,r,l){if(i){if(!(i instanceof E))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),vi(this,e,t,i?i.children.slice():[],r,l),!0}split(e){let t=new E;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:n}=this.childPos(e);n&&(t.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let r=i;r<this.children.length;r++)t.append(this.children[r],0);for(;i>0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){bt(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Fe(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=xt(t,this.attrs||{})),i&&(this.attrs=xt({class:i},this.attrs||{}))}domAtPos(e){return Ae(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Je(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(At(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let n=this.dom.lastChild;for(;n&&ft.get(n)instanceof ie;)n=n.lastChild;if(!n||!this.length||n.nodeName!="BR"&&((i=ft.get(n))===null||i===void 0?void 0:i.isEditable)==!1&&(!De.ios||!this.children.some(r=>r instanceof Bt))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Bt)||/[^ -~]/.test(i.text))return null;let n=Nt(i.dom);if(n.length!=1)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=Xe(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:n}=this.parent.view.viewState,r=i.bottom-i.top;if(Math.abs(r-n.lineHeight)<2&&n.textHeight<r){let l=(r-n.textHeight)/2;return{top:i.top+l,bottom:i.bottom-l,left:i.left,right:i.left}}}return i}become(e){return e instanceof E&&this.children.length==0&&e.children.length==0&&bt(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let i=0,n=0;i<e.children.length;i++){let r=e.children[i],l=n+r.length;if(l>=t){if(r instanceof E)return r;if(l>t)break}n=l+r.breakAfter}return null}}class q extends ft{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,n,r,l){return i&&(!(i instanceof q)||!this.widget.compare(i.widget)||e>0&&r<=0||t<this.length&&l<=0)?!1:(this.length=e+(i?i.length:0)+(this.length-t),!0)}domAtPos(e){return e==0?nt.before(this.dom):nt.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let i=new q(this.widget,t,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return kt}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):T.xv.empty}domBoundsAround(){return null}become(e){return e instanceof q&&e.widget.constructor==this.widget.constructor?(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);return i||(this.widget instanceof K?null:Ze(this.dom.getBoundingClientRect(),this.length?e==0:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:i}=this.deco;return t==i?!1:e<0?t<0:i>0}}class K extends Ti{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class ee{constructor(e,t,i,n){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof q&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new E),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ge(new ae(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof q)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:r,lineBreak:l,done:c}=this.cursor.next(this.skip);if(this.skip=0,c)throw new Error("Ran out of text content when drawing inline views");if(l){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=r,this.textOff=0}let n=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(ge(new Bt(this.text.slice(this.textOff,this.textOff+n)),t),i),this.atCursorPos=!0,this.textOff+=n,e-=n,i=0}}span(e,t,i,n){this.buildText(t-e,i,n),this.pos=t,this.openStart<0&&(this.openStart=n)}point(e,t,i,n,r,l){if(this.disallowBlockEffectsFor[l]&&i instanceof hi){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let c=t-e;if(i instanceof hi)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new q(i.widget||Pe.block,c,i));else{let m=pe.create(i.widget||Pe.inline,c,c?0:i.startSide),C=this.atCursorPos&&!m.isEditable&&r<=n.length&&(e<t||i.startSide>0),k=!m.isEditable&&(e<t||r>n.length||i.startSide<=0),N=this.getLine();this.pendingBuffer==2&&!C&&!m.isEditable&&(this.pendingBuffer=0),this.flushBuffer(n),C&&(N.append(ge(new ae(1),n),r),r=n.length+Math.max(0,r-n.length)),N.append(ge(m,n),r),this.atCursorPos=k,this.pendingBuffer=k?e<t||r>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);c&&(this.textOff+c<=this.text.length?this.textOff+=c:(this.skip+=c-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,i,n,r){let l=new ee(e,t,i,r);return l.openEnd=T.Xs.spans(n,t,i,l),l.openStart<0&&(l.openStart=l.openEnd),l.finish(l.openEnd),l}}function ge(s,e){for(let t of e)s=new ie(t,[s],s.length);return s}class Pe extends Ti{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Pe.inline=new Pe("span"),Pe.block=new Pe("div");var Te=function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s}(Te||(Te={}));const je=Te.LTR,ot=Te.RTL;function ti(s){let e=[];for(let t=0;t<s.length;t++)e.push(1<<+s[t]);return e}const ri=ti("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),ci=ti("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),fi=Object.create(null),qt=[];for(let s of["()","[]","{}"]){let e=s.charCodeAt(0),t=s.charCodeAt(1);fi[e]=t,fi[t]=-e}function gi(s){return s<=247?ri[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?ci[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1}const Li=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ei{get dir(){return this.level%2?ot:je}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let r=-1;for(let l=0;l<e.length;l++){let c=e[l];if(c.from<=t&&c.to>=t){if(c.level==i)return l;(r<0||(n!=0?n<0?c.from<t:c.to>t:e[r].level>c.level))&&(r=l)}}if(r<0)throw new RangeError("Index out of range");return r}}function Xi(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++){let i=s[t],n=e[t];if(i.from!=n.from||i.to!=n.to||i.direction!=n.direction||!Xi(i.inner,n.inner))return!1}return!0}const Pt=[];function Ji(s,e,t,i,n){for(let r=0;r<=i.length;r++){let l=r?i[r-1].to:e,c=r<i.length?i[r].from:t,m=r?256:n;for(let C=l,k=m,N=m;C<c;C++){let z=gi(s.charCodeAt(C));z==512?z=k:z==8&&N==4&&(z=16),Pt[C]=z==4?2:z,z&7&&(N=z),k=z}for(let C=l,k=m,N=m;C<c;C++){let z=Pt[C];if(z==128)C<c-1&&k==Pt[C+1]&&k&24?z=Pt[C]=k:Pt[C]=256;else if(z==64){let se=C+1;for(;se<c&&Pt[se]==64;)se++;let he=C&&k==8||se<t&&Pt[se]==8?N==1?1:8:256;for(let we=C;we<se;we++)Pt[we]=he;C=se-1}else z==8&&N==1&&(Pt[C]=1);k=z,z&7&&(N=z)}}}function sn(s,e,t,i,n){let r=n==1?2:1;for(let l=0,c=0,m=0;l<=i.length;l++){let C=l?i[l-1].to:e,k=l<i.length?i[l].from:t;for(let N=C,z,se,he;N<k;N++)if(se=fi[z=s.charCodeAt(N)])if(se<0){for(let we=c-3;we>=0;we-=3)if(qt[we+1]==-se){let ke=qt[we+2],xe=ke&2?n:ke&4?ke&1?r:n:0;xe&&(Pt[N]=Pt[qt[we]]=xe),c=we;break}}else{if(qt.length==189)break;qt[c++]=N,qt[c++]=z,qt[c++]=m}else if((he=Pt[N])==2||he==1){let we=he==n;m=we?0:1;for(let ke=c-3;ke>=0;ke-=3){let xe=qt[ke+2];if(xe&2)break;if(we)qt[ke+2]|=2;else{if(xe&4)break;qt[ke+2]|=4}}}}}function an(s,e,t,i){for(let n=0,r=i;n<=t.length;n++){let l=n?t[n-1].to:s,c=n<t.length?t[n].from:e;for(let m=l;m<c;){let C=Pt[m];if(C==256){let k=m+1;for(;;)if(k==c){if(n==t.length)break;k=t[n++].to,c=n<t.length?t[n].from:e}else if(Pt[k]==256)k++;else break;let N=r==1,z=(k<e?Pt[k]:i)==1,se=N==z?N?1:2:i;for(let he=k,we=n,ke=we?t[we-1].to:s;he>m;)he==ke&&(he=t[--we].from,ke=we?t[we-1].to:s),Pt[--he]=se;m=k}else r=C,m++}}}function oi(s,e,t,i,n,r,l){let c=i%2?2:1;if(i%2==n%2)for(let m=e,C=0;m<t;){let k=!0,N=!1;if(C==r.length||m<r[C].from){let we=Pt[m];we!=c&&(k=!1,N=we==16)}let z=!k&&c==1?[]:null,se=k?i:i+1,he=m;e:for(;;)if(C<r.length&&he==r[C].from){if(N)break e;let we=r[C];if(!k)for(let ke=we.to,xe=C+1;;){if(ke==t)break e;if(xe<r.length&&r[xe].from==ke)ke=r[xe++].to;else{if(Pt[ke]==c)break e;break}}if(C++,z)z.push(we);else{we.from>m&&l.push(new Ei(m,we.from,se));let ke=we.direction==je!=!(se%2);R(s,ke?i+1:i,n,we.inner,we.from,we.to,l),m=we.to}he=we.to}else{if(he==t||(k?Pt[he]!=c:Pt[he]==c))break;he++}z?oi(s,m,he,i+1,n,z,l):m<he&&l.push(new Ei(m,he,se)),m=he}else for(let m=t,C=r.length;m>e;){let k=!0,N=!1;if(!C||m>r[C-1].to){let we=Pt[m-1];we!=c&&(k=!1,N=we==16)}let z=!k&&c==1?[]:null,se=k?i:i+1,he=m;e:for(;;)if(C&&he==r[C-1].to){if(N)break e;let we=r[--C];if(!k)for(let ke=we.from,xe=C;;){if(ke==e)break e;if(xe&&r[xe-1].to==ke)ke=r[--xe].from;else{if(Pt[ke-1]==c)break e;break}}if(z)z.push(we);else{we.to<m&&l.push(new Ei(we.to,m,se));let ke=we.direction==je!=!(se%2);R(s,ke?i+1:i,n,we.inner,we.from,we.to,l),m=we.from}he=we.from}else{if(he==e||(k?Pt[he-1]!=c:Pt[he-1]==c))break;he--}z?oi(s,he,m,i+1,n,z,l):he<m&&l.push(new Ei(he,m,se)),m=he}}function R(s,e,t,i,n,r,l){let c=e%2?2:1;Ji(s,n,r,i,c),sn(s,n,r,i,c),an(n,r,i,c),oi(s,n,r,e,t,i,l)}function o(s,e,t){if(!s)return[new Ei(0,0,e==ot?1:0)];if(e==je&&!t.length&&!Li.test(s))return a(s.length);if(t.length)for(;s.length>Pt.length;)Pt[Pt.length]=256;let i=[],n=e==je?0:1;return R(s,n,n,t,0,s.length,i),i}function a(s){return[new Ei(0,s,0)]}let d="";function w(s,e,t,i,n){var r;let l=i.head-s.from,c=Ei.find(e,l,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),m=e[c],C=m.side(n,t);if(l==C){let z=c+=n?1:-1;if(z<0||z>=e.length)return null;m=e[c=z],l=m.side(!n,t),C=m.side(n,t)}let k=(0,T.cp)(s.text,l,m.forward(n,t));(k<m.from||k>m.to)&&(k=C),d=s.text.slice(Math.min(l,k),Math.max(l,k));let N=c==(n?e.length-1:0)?null:e[c+(n?1:-1)];return N&&k==C&&N.level+(n?0:1)<m.level?T.jT.cursor(N.side(!n,t)+s.from,N.forward(n,t)?1:-1,N.level):T.jT.cursor(k+s.from,m.forward(n,t)?-1:1,m.level)}function D(s,e,t){for(let i=e;i<t;i++){let n=gi(s.charCodeAt(i));if(n==1)return je;if(n==2||n==4)return ot}return je}const O=T.r$.define(),H=T.r$.define(),Y=T.r$.define(),ue=T.r$.define(),ve=T.r$.define(),Ee=T.r$.define(),ze=T.r$.define(),$e=T.r$.define(),jt=T.r$.define(),Fi=T.r$.define({combine:s=>s.some(e=>e)}),ii=T.r$.define({combine:s=>s.some(e=>e)}),Qi=T.r$.define();class Ki{constructor(e,t="nearest",i="nearest",n=5,r=5,l=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=l}map(e){return e.empty?this:new Ki(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ki(T.jT.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ui=T.Py.define({map:(s,e)=>s.map(e)}),rn=T.Py.define();function P(s,e,t){let i=s.facet(ue);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const y=T.r$.define({combine:s=>s.length?s[0]:!0});let x=0;const L=T.r$.define({combine(s){return s.filter((e,t)=>{for(let i=0;i<t;i++)if(s[i].plugin==e.plugin)return!1;return!0})}});class I{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(L.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(L.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:n,provide:r,decorations:l}=t||{};return new I(x++,e,i,n,c=>{let m=[];return l&&m.push(fe.of(C=>{let k=C.plugin(c);return k?l(k):rt.none})),r&&m.push(r(c)),m})}static fromClass(e,t){return I.define((i,n)=>new e(i,n),t)}}class G{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(P(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){P(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){P(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const oe=T.r$.define(),de=T.r$.define(),fe=T.r$.define(),Me=T.r$.define(),Ce=T.r$.define(),_e=T.r$.define();function wt(s,e){let t=s.state.facet(_e);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(s):r),n=[];return T.Xs.spans(i,e.from,e.to,{point(){},span(r,l,c,m){let C=r-e.from,k=l-e.from,N=n;for(let z=c.length-1;z>=0;z--,m--){let se=c[z].spec.bidiIsolate,he;if(se==null&&(se=D(e.text,C,k)),m>0&&N.length&&(he=N[N.length-1]).to==C&&he.direction==se)he.to=k,N=he.inner;else{let we={from:C,to:k,direction:se,inner:[]};N.push(we),N=we.inner}}}}),n}const Wt=T.r$.define();function li(s){let e=0,t=0,i=0,n=0;for(let r of s.state.facet(Wt)){let l=r(s);l&&(l.left!=null&&(e=Math.max(e,l.left)),l.right!=null&&(t=Math.max(t,l.right)),l.top!=null&&(i=Math.max(i,l.top)),l.bottom!=null&&(n=Math.max(n,l.bottom)))}return{left:e,right:t,top:i,bottom:n}}const yi=T.r$.define();class Di{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new Di(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let n=0,r=0,l=0,c=0;;n++){let m=n==e.length?null:e[n],C=l-c,k=m?m.fromB:1e9;for(;r<t.length&&t[r]<k;){let N=t[r],z=t[r+1],se=Math.max(c,N),he=Math.min(k,z);if(se<=he&&new Di(se+C,he+C,se,he).addToSet(i),z>k)break;r+=2}if(!m)return i;new Di(m.fromA,m.toA,m.fromB,m.toB).addToSet(i),l=m.toA,c=m.toB}}}class xi{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=T.as.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,l,c,m)=>n.push(new Di(r,l,c,m))),this.changedRanges=n}static create(e,t,i){return new xi(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}class Qt extends ft{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=rt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new E],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Di(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:C,toA:k})=>k<this.minWidthFrom||C>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!B(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Ri(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:C,to:k}=this.hasComposition;i=new Di(C,k,e.changes.mapPos(C,-1),e.changes.mapPos(k,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(De.ie||De.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let l=this.decorations,c=this.updateDeco(),m=f(l,c,e.changes);return i=Di.extendWithRanges(i,m),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let l=De.chrome||De.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,l),this.flags&=-8,l&&(l.written||n.selectionRange.focusNode!=l.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(l=>l.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let l of this.children)l instanceof q&&l.widget instanceof K&&r.push(l.dom);n.updateGaps(r)}updateChildren(e,t,i){let n=i?i.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let l=n.length-1;;l--){let c=l>=0?n[l]:null;if(!c)break;let{fromA:m,toA:C,fromB:k,toB:N}=c,z,se,he,we;if(i&&i.range.fromB<N&&i.range.toB>k){let at=ee.build(this.view.state.doc,k,i.range.fromB,this.decorations,this.dynamicDecorationMap),mt=ee.build(this.view.state.doc,i.range.toB,N,this.decorations,this.dynamicDecorationMap);se=at.breakAtStart,he=at.openStart,we=mt.openEnd;let gt=this.compositionView(i);mt.breakAtStart?gt.breakAfter=1:mt.content.length&&gt.merge(gt.length,gt.length,mt.content[0],!1,mt.openStart,0)&&(gt.breakAfter=mt.content[0].breakAfter,mt.content.shift()),at.content.length&&gt.merge(0,0,at.content[at.content.length-1],!0,0,at.openEnd)&&at.content.pop(),z=at.content.concat(gt).concat(mt.content)}else({content:z,breakAtStart:se,openStart:he,openEnd:we}=ee.build(this.view.state.doc,k,N,this.decorations,this.dynamicDecorationMap));let{i:ke,off:xe}=r.findPos(C,1),{i:Qe,off:pt}=r.findPos(m,-1);Et(this,Qe,pt,ke,xe,z,se,he,we)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(rn)&&(this.editContextFormatting=i.value)}compositionView(e){let t=new Bt(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new ie(n,[t],t.length);let i=new E;return i.append(t,0),i}fixCompositionDOM(e){let t=(r,l)=>{l.flags|=8|(l.children.some(m=>m.flags&7)?1:0),this.markedForComposition.add(l);let c=ft.get(r);c&&c!=l&&(c.dom=null),l.setDOM(r)},i=this.childPos(e.range.fromB,1),n=this.children[i.i];t(e.line,n);for(let r=e.marks.length-1;r>=-1;r--)i=n.childPos(i.off,1),n=n.children[i.i],t(r>=0?e.marks[r].node:e.text,n)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,r=!n&&!(this.view.state.facet(y)||this.dom.tabIndex>-1)&&Lt(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||t||r))return;let l=this.forceSelection;this.forceSelection=!1;let c=this.view.state.selection.main,m=this.moveToLine(this.domAtPos(c.anchor)),C=c.empty?m:this.moveToLine(this.domAtPos(c.head));if(De.gecko&&c.empty&&!this.hasComposition&&Vi(m)){let N=document.createTextNode("");this.view.observer.ignore(()=>m.node.insertBefore(N,m.node.childNodes[m.offset]||null)),m=C=new nt(N,0),l=!0}let k=this.view.observer.selectionRange;(l||!k.focusNode||(!Jt(m.node,m.offset,k.anchorNode,k.anchorOffset)||!Jt(C.node,C.offset,k.focusNode,k.focusOffset))&&!this.suppressWidgetCursorChange(k,c))&&(this.view.observer.ignore(()=>{De.android&&De.chrome&&this.dom.contains(k.focusNode)&&b(k.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let N=Oe(this.view.root);if(N)if(c.empty){if(De.gecko){let z=Zi(m.node,m.offset);if(z&&z!=3){let se=(z==1?Xt:si)(m.node,m.offset);se&&(m=new nt(se.node,se.offset))}}N.collapse(m.node,m.offset),c.bidiLevel!=null&&N.caretBidiLevel!==void 0&&(N.caretBidiLevel=c.bidiLevel)}else if(N.extend){N.collapse(m.node,m.offset);try{N.extend(C.node,C.offset)}catch{}}else{let z=document.createRange();c.anchor>c.head&&([m,C]=[C,m]),z.setEnd(C.node,C.offset),z.setStart(m.node,m.offset),N.removeAllRanges(),N.addRange(z)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(m,C)),this.impreciseAnchor=m.precise?null:new nt(k.anchorNode,k.anchorOffset),this.impreciseHead=C.precise?null:new nt(k.focusNode,k.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Oe(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let l=E.find(this,t.head);if(!l)return;let c=l.posAtStart;if(t.head==c||t.head==c+l.length)return;let m=this.coordsAt(t.head,-1),C=this.coordsAt(t.head,1);if(!m||!C||m.bottom>C.top)return;let k=this.domAtPos(t.head+t.assoc);i.collapse(k.node,k.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let N=e.observer.selectionRange;e.docView.posFromDOM(N.anchorNode,N.anchorOffset)!=t.from&&i.collapse(n,r)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let n=e.offset;!i&&n<t.childNodes.length;n++){let r=ft.get(t.childNodes[n]);r instanceof E&&(i=r.domAtPos(0))}for(let n=e.offset-1;!i&&n>=0;n--){let r=ft.get(t.childNodes[n]);r instanceof E&&(i=r.domAtPos(r.length))}return i?new nt(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=ft.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let n=this.children[t];if(i<n.length||n instanceof E)break;t++,i=0}return this.children[t].domAtPos(i)}coordsAt(e,t){let i=null,n=0;for(let r=this.length,l=this.children.length-1;l>=0;l--){let c=this.children[l],m=r-c.breakAfter,C=m-c.length;if(m<e)break;if(C<=e&&(C<e||c.covers(-1))&&(m>e||c.covers(1))&&(!i||c instanceof E&&!(i instanceof E&&t>=0)))i=c,n=C;else if(i&&C==e&&m==e&&c instanceof q&&Math.abs(t)<2){if(c.deco.startSide<0)break;l&&(i=null)}r=C}return i?i.coordsAt(e-n,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),n=this.children[t];if(!(n instanceof E))return null;for(;n.children.length;){let{i:c,off:m}=n.childPos(i,1);for(;;c++){if(c==n.children.length)return null;if((n=n.children[c]).length)break}i=m}if(!(n instanceof Bt))return null;let r=(0,T.cp)(n.text,i);if(r==i)return null;let l=et(n.dom,i,r).getClientRects();for(let c=0;c<l.length;c++){let m=l[c];if(c==l.length-1||m.top<m.bottom&&m.left<m.right)return m}return null}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,r=this.view.contentDOM.clientWidth,l=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,c=-1,m=this.view.textDirection==Te.LTR;for(let C=0,k=0;k<this.children.length;k++){let N=this.children[k],z=C+N.length;if(z>n)break;if(C>=i){let se=N.dom.getBoundingClientRect();if(t.push(se.height),l){let he=N.dom.lastChild,we=he?Nt(he):[];if(we.length){let ke=we[we.length-1],xe=m?ke.right-se.left:se.right-ke.left;xe>c&&(c=xe,this.minWidth=r,this.minWidthFrom=C,this.minWidthTo=z)}}}C=z+N.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?Te.RTL:Te.LTR}measureTextSize(){for(let r of this.children)if(r instanceof E){let l=r.measureTextSize();if(l)return l}let e=document.createElement("div"),t,i,n;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=Nt(e.firstChild)[0];t=e.getBoundingClientRect().height,i=r?r.width/27:7,n=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new $t(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],l=r?r.from-1:this.length;if(l>i){let c=(t.lineBlockAt(l).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(rt.replace({widget:new K(c),block:!0,inclusive:!0,isBlockGap:!0}).range(i,l))}if(!r)break;i=r.to+1}return rt.set(e)}updateDeco(){let e=1,t=this.view.state.facet(fe).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(Me).map((r,l)=>{let c=typeof r=="function";return c&&(i=!0),c?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(T.Xs.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}scrollIntoView(e){if(e.isSnapshot){let C=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=C.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let C of this.view.state.facet(Qi))try{if(C(this.view,e.range,e))return!0}catch(k){P(this.view.state,k,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=li(this.view),l={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:c,offsetHeight:m}=this.view.scrollDOM;Ai(this.view.scrollDOM,l,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,c),-c),Math.max(Math.min(e.yMargin,m),-m),this.view.textDirection==Te.LTR)}}function Vi(s){return s.node.nodeType==1&&s.node.firstChild&&(s.offset==0||s.node.childNodes[s.offset-1].contentEditable=="false")&&(s.offset==s.node.childNodes.length||s.node.childNodes[s.offset].contentEditable=="false")}function Bi(s,e){let t=s.observer.selectionRange;if(!t.focusNode)return null;let i=Xt(t.focusNode,t.focusOffset),n=si(t.focusNode,t.focusOffset),r=i||n;if(n&&i&&n.node!=i.node){let c=ft.get(n.node);if(!c||c instanceof Bt&&c.text!=n.node.nodeValue)r=n;else if(s.docView.lastCompositionAfterCursor){let m=ft.get(i.node);!m||m instanceof Bt&&m.text!=i.node.nodeValue||(r=n)}}if(s.docView.lastCompositionAfterCursor=r!=i,!r)return null;let l=e-r.offset;return{from:l,to:l+r.node.nodeValue.length,node:r.node}}function Ri(s,e,t){let i=Bi(s,t);if(!i)return null;let{node:n,from:r,to:l}=i,c=n.nodeValue;if(/[\n\r]/.test(c)||s.state.doc.sliceString(i.from,i.to)!=c)return null;let m=e.invertedDesc,C=new Di(m.mapPos(r),m.mapPos(l),r,l),k=[];for(let N=n.parentNode;;N=N.parentNode){let z=ft.get(N);if(z instanceof ie)k.push({node:N,deco:z.mark});else{if(z instanceof E||N.nodeName=="DIV"&&N.parentNode==s.contentDOM)return{range:C,text:n,marks:k,line:N};if(N!=s.contentDOM)k.push({node:N,deco:new Mi({inclusive:!0,attributes:Ot(N),tagName:N.tagName.toLowerCase()})});else return null}}}function Zi(s,e){return s.nodeType!=1?0:(e&&s.childNodes[e-1].contentEditable=="false"?1:0)|(e<s.childNodes.length&&s.childNodes[e].contentEditable=="false"?2:0)}let A=class{constructor(){this.changes=[]}compareRange(e,t){_(e,t,this.changes)}comparePoint(e,t){_(e,t,this.changes)}boundChange(e){_(e,e,this.changes)}};function f(s,e,t){let i=new A;return T.Xs.compare(s,e,t,i),i.changes}function b(s,e){for(let t=s;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function B(s,e){let t=!1;return e&&s.iterChangedRanges((i,n)=>{i<e.to&&n>e.from&&(t=!0)}),t}function F(s,e,t=1){let i=s.charCategorizer(e),n=s.doc.lineAt(e),r=e-n.from;if(n.length==0)return T.jT.cursor(e);r==0?t=1:r==n.length&&(t=-1);let l=r,c=r;t<0?l=(0,T.cp)(n.text,r,!1):c=(0,T.cp)(n.text,r);let m=i(n.text.slice(l,c));for(;l>0;){let C=(0,T.cp)(n.text,l,!1);if(i(n.text.slice(C,l))!=m)break;l=C}for(;c<n.length;){let C=(0,T.cp)(n.text,c);if(i(n.text.slice(c,C))!=m)break;c=C}return T.jT.range(l+n.from,c+n.from)}function U(s,e){return e.left>s?e.left-s:Math.max(0,s-e.right)}function Z(s,e){return e.top>s?e.top-s:Math.max(0,s-e.bottom)}function be(s,e){return s.top<e.bottom-1&&s.bottom>e.top+1}function me(s,e){return e<s.top?{top:e,left:s.left,right:s.right,bottom:s.bottom}:s}function Ne(s,e){return e>s.bottom?{top:s.top,left:s.left,right:s.right,bottom:e}:s}function Ke(s,e,t){let i,n,r,l,c=!1,m,C,k,N;for(let he=s.firstChild;he;he=he.nextSibling){let we=Nt(he);for(let ke=0;ke<we.length;ke++){let xe=we[ke];n&&be(n,xe)&&(xe=me(Ne(xe,n.bottom),n.top));let Qe=U(e,xe),pt=Z(t,xe);if(Qe==0&&pt==0)return he.nodeType==3?_t(he,e,t):Ke(he,e,t);(!i||l>pt||l==pt&&r>Qe)&&(i=he,n=xe,r=Qe,l=pt,c=Qe?e<xe.left?ke>0:ke<we.length-1:!0),Qe==0?t>xe.bottom&&(!k||k.bottom<xe.bottom)?(m=he,k=xe):t<xe.top&&(!N||N.top>xe.top)&&(C=he,N=xe):k&&be(k,xe)?k=Ne(k,xe.bottom):N&&be(N,xe)&&(N=me(N,xe.top))}}if(k&&k.bottom>=t?(i=m,n=k):N&&N.top<=t&&(i=C,n=N),!i)return{node:s,offset:0};let z=Math.max(n.left,Math.min(n.right,e));if(i.nodeType==3)return _t(i,z,t);if(c&&i.contentEditable!="false")return Ke(i,z,t);let se=Array.prototype.indexOf.call(s.childNodes,i)+(e>=(n.left+n.right)/2?1:0);return{node:s,offset:se}}function _t(s,e,t){let i=s.nodeValue.length,n=-1,r=1e9,l=0;for(let c=0;c<i;c++){let m=et(s,c,c+1).getClientRects();for(let C=0;C<m.length;C++){let k=m[C];if(k.top==k.bottom)continue;l||(l=e-k.left);let N=(k.top>t?k.top-t:t-k.bottom)-1;if(k.left-1<=e&&k.right+1>=e&&N<r){let z=e>=(k.left+k.right)/2,se=z;if((De.chrome||De.gecko)&&et(s,c).getBoundingClientRect().left==k.right&&(se=!z),N<=0)return{node:s,offset:c+(se?1:0)};n=c+(se?1:0),r=N}}}return{node:s,offset:n>-1?n:l>0?s.nodeValue.length:0}}function Wi(s,e,t,i=-1){var n,r;let l=s.contentDOM.getBoundingClientRect(),c=l.top+s.viewState.paddingTop,m,{docHeight:C}=s.viewState,{x:k,y:N}=e,z=N-c;if(z<0)return 0;if(z>C)return s.state.doc.length;for(let at=s.viewState.heightOracle.textHeight/2,mt=!1;m=s.elementAtHeight(z),m.type!=lt.Text;)for(;z=i>0?m.bottom+at:m.top-at,!(z>=0&&z<=C);){if(mt)return t?null:0;mt=!0,i=-i}N=c+z;let se=m.from;if(se<s.viewport.from)return s.viewport.from==0?0:t?null:Ii(s,l,m,k,N);if(se>s.viewport.to)return s.viewport.to==s.state.doc.length?s.state.doc.length:t?null:Ii(s,l,m,k,N);let he=s.dom.ownerDocument,we=s.root.elementFromPoint?s.root:he,ke=we.elementFromPoint(k,N);ke&&!s.contentDOM.contains(ke)&&(ke=null),ke||(k=Math.max(l.left+1,Math.min(l.right-1,k)),ke=we.elementFromPoint(k,N),ke&&!s.contentDOM.contains(ke)&&(ke=null));let xe,Qe=-1;if(ke&&((n=s.docView.nearest(ke))===null||n===void 0?void 0:n.isEditable)!=!1){if(he.caretPositionFromPoint){let at=he.caretPositionFromPoint(k,N);at&&({offsetNode:xe,offset:Qe}=at)}else if(he.caretRangeFromPoint){let at=he.caretRangeFromPoint(k,N);at&&({startContainer:xe,startOffset:Qe}=at,(!s.contentDOM.contains(xe)||De.safari&&en(xe,Qe,k)||De.chrome&&Yi(xe,Qe,k))&&(xe=void 0))}xe&&(Qe=Math.min(Rt(xe),Qe))}if(!xe||!s.docView.dom.contains(xe)){let at=E.find(s.docView,se);if(!at)return z>m.top+m.height/2?m.to:m.from;({node:xe,offset:Qe}=Ke(at.dom,k,N))}let pt=s.docView.nearest(xe);if(!pt)return null;if(pt.isWidget&&((r=pt.dom)===null||r===void 0?void 0:r.nodeType)==1){let at=pt.dom.getBoundingClientRect();return e.y<at.top||e.y<=at.bottom&&e.x<=(at.left+at.right)/2?pt.posAtStart:pt.posAtEnd}else return pt.localPosFromDOM(xe,Qe)+pt.posAtStart}function Ii(s,e,t,i,n){let r=Math.round((i-e.left)*s.defaultCharacterWidth);if(s.lineWrapping&&t.height>s.defaultLineHeight*1.5){let c=s.viewState.heightOracle.textHeight,m=Math.floor((n-t.top-(s.defaultLineHeight-c)*.5)/c);r+=m*s.viewState.heightOracle.lineLength}let l=s.state.sliceDoc(t.from,t.to);return t.from+(0,T.Gz)(l,r,s.state.tabSize)}function en(s,e,t){let i,n=s;if(s.nodeType!=3||e!=(i=s.nodeValue.length))return!1;for(;;){let r=n.nextSibling;if(r){if(r.nodeName=="BR")break;return!1}else{let l=n.parentNode;if(!l||l.nodeName=="DIV")break;n=l}}return et(s,i-1,i).getBoundingClientRect().right>t}function Yi(s,e,t){if(e!=0)return!1;for(let n=s;;){let r=n.parentNode;if(!r||r.nodeType!=1||r.firstChild!=n)return!1;if(r.classList.contains("cm-line"))break;n=r}let i=s.nodeType==1?s.getBoundingClientRect():et(s,0,Math.max(s.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function kn(s,e,t){let i=s.lineBlockAt(e);if(Array.isArray(i.type)){let n;for(let r of i.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!n||r.type==lt.Text&&(n.type!=r.type||(t<0?r.from<e:r.to>e)))&&(n=r)}}return n||i}return i}function mn(s,e,t,i){let n=kn(s,e.head,e.assoc||-1),r=!i||n.type!=lt.Text||!(s.lineWrapping||n.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(r){let l=s.dom.getBoundingClientRect(),c=s.textDirectionAt(n.from),m=s.posAtCoords({x:t==(c==Te.LTR)?l.right-1:l.left+1,y:(r.top+r.bottom)/2});if(m!=null)return T.jT.cursor(m,t?-1:1)}return T.jT.cursor(t?n.to:n.from,t?-1:1)}function Bn(s,e,t,i){let n=s.state.doc.lineAt(e.head),r=s.bidiSpans(n),l=s.textDirectionAt(n.from);for(let c=e,m=null;;){let C=w(n,r,l,c,t),k=d;if(!C){if(n.number==(t?s.state.doc.lines:1))return c;k=`
23
+ `,n=s.state.doc.line(n.number+(t?1:-1)),r=s.bidiSpans(n),C=s.visualLineSide(n,!t)}if(m){if(!m(k))return c}else{if(!i)return C;m=i(k)}c=C}}function Kn(s,e,t){let i=s.state.charCategorizer(e),n=i(t);return r=>{let l=i(r);return n==T.D0.Space&&(n=l),n==l}}function Vn(s,e,t,i){let n=e.head,r=t?1:-1;if(n==(t?s.state.doc.length:0))return T.jT.cursor(n,e.assoc);let l=e.goalColumn,c,m=s.contentDOM.getBoundingClientRect(),C=s.coordsAtPos(n,e.assoc||-1),k=s.documentTop;if(C)l==null&&(l=C.left-m.left),c=r<0?C.top:C.bottom;else{let se=s.viewState.lineBlockAt(n);l==null&&(l=Math.min(m.right-m.left,s.defaultCharacterWidth*(n-se.from))),c=(r<0?se.top:se.bottom)+k}let N=m.left+l,z=i??s.viewState.heightOracle.textHeight>>1;for(let se=0;;se+=10){let he=c+(z+se)*r,we=Wi(s,{x:N,y:he},!1,r);if(he<m.top||he>m.bottom||(r<0?we<n:we>n)){let ke=s.docView.coordsForChar(we),xe=!ke||he<ke.top?-1:1;return T.jT.cursor(we,xe,void 0,l)}}}function tn(s,e,t){for(;;){let i=0;for(let n of s)n.between(e-1,e+1,(r,l,c)=>{if(e>r&&e<l){let m=i||t||(e-r<l-e?-1:1);e=m<0?r:l,i=m}});if(!i)return e}}function gn(s,e,t){let i=tn(s.state.facet(Ce).map(n=>n(s)),t.from,e.head>t.from?-1:1);return i==t.from?t:T.jT.cursor(i,i<t.from?1:-1)}const on="\uFFFF";class yn{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(T.yy.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=on}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let r=this.text.length;this.readNode(n);let l=n.nextSibling;if(l==t)break;let c=ft.get(n),m=ft.get(l);(c&&m?c.breakAfter:(c?c.breakAfter:St(n))||St(l)&&(n.nodeName!="BR"||n.cmIgnore)&&this.text.length>r)&&this.lineBreak(),n=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,l=1,c;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),l=this.lineSeparator.length):(c=n.exec(t))&&(r=c.index,l=c[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),l>1)for(let m of this.points)m.node==e&&m.pos>this.text.length&&(m.pos-=l-1);i=r+l}}readNode(e){if(e.cmIgnore)return;let t=ft.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Hi(e,i.node,i.offset)?t:0))}}function Hi(s,e,t){for(;;){if(!e||t<Rt(e))return!1;if(e==s)return!0;t=Kt(e)+1,e=e.parentNode}}class Ge{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Ln{constructor(e,t,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:l}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let c=r||l?[]:cn(e),m=new yn(c,e.state);m.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=m.text,this.newSel=Rn(c,this.bounds.from)}else{let c=e.observer.selectionRange,m=r&&r.node==c.focusNode&&r.offset==c.focusOffset||!ut(e.contentDOM,c.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(c.focusNode,c.focusOffset),C=l&&l.node==c.anchorNode&&l.offset==c.anchorOffset||!ut(e.contentDOM,c.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(c.anchorNode,c.anchorOffset),k=e.viewport;if((De.ios||De.chrome)&&e.state.selection.main.empty&&m!=C&&(k.from>0||k.to<e.state.doc.length)){let N=Math.min(m,C),z=Math.max(m,C),se=k.from-N,he=k.to-z;(se==0||se==1||N==0)&&(he==0||he==-1||z==e.state.doc.length)&&(m=0,C=e.state.doc.length)}this.newSel=T.jT.single(C,m)}}}function Tn(s,e){let t,{newSel:i}=e,n=s.state.selection.main,r=s.inputState.lastKeyTime>Date.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:c}=e.bounds,m=n.from,C=null;(r===8||De.android&&e.text.length<c-l)&&(m=n.to,C="end");let k=hn(s.state.doc.sliceString(l,c,on),e.text,m-l,C);k&&(De.chrome&&r==13&&k.toB==k.from+2&&e.text.slice(k.from,k.toB)==on+on&&k.toB--,t={from:l+k.from,to:l+k.toA,insert:T.xv.of(e.text.slice(k.from,k.toB).split(on))})}else i&&(!s.hasFocus&&s.state.facet(y)||i.main.eq(n))&&(i=null);if(!t&&!i)return!1;if(!t&&e.typeOver&&!n.empty&&i&&i.main.empty?t={from:n.from,to:n.to,insert:s.state.doc.slice(n.from,n.to)}:(De.mac||De.android)&&t&&t.from==t.to&&t.from==n.head-1&&/^\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=T.jT.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:T.xv.of([t.insert.toString().replace("."," ")])}):t&&t.from>=n.from&&t.to<=n.to&&(t.from!=n.from||t.to!=n.to)&&n.to-n.from-(t.to-t.from)<=4?t={from:n.from,to:n.to,insert:s.state.doc.slice(n.from,t.from).append(t.insert).append(s.state.doc.slice(t.to,n.to))}:De.chrome&&t&&t.from==t.to&&t.from==n.head&&t.insert.toString()==`
24
+ `&&s.lineWrapping&&(i&&(i=T.jT.single(i.main.anchor-1,i.main.head-1)),t={from:n.from,to:n.to,insert:T.xv.of([" "])}),t)return Mn(s,t,i,r);if(i&&!i.main.eq(n)){let l=!1,c="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(l=!0),c=s.inputState.lastSelectionOrigin),s.dispatch({selection:i,scrollIntoView:l,userEvent:c}),!0}else return!1}function Mn(s,e,t,i=-1){if(De.ios&&s.inputState.flushIOSKey(e))return!0;let n=s.state.selection.main;if(De.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&s.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&We(s.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>n.head)&&We(s.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&We(s.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let l,c=()=>l||(l=xn(s,e,t));return s.state.facet(Ee).some(m=>m(s,e.from,e.to,r,c))||s.dispatch(c()),!0}function xn(s,e,t){let i,n=s.state,r=n.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let c=r.from<e.from?n.sliceDoc(r.from,e.from):"",m=r.to>e.to?n.sliceDoc(e.to,r.to):"";i=n.replaceSelection(s.state.toText(c+e.insert.sliceString(0,void 0,s.state.lineBreak)+m))}else{let c=n.changes(e),m=t&&t.main.to<=c.newLength?t.main:void 0;if(n.selection.ranges.length>1&&s.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let C=s.state.sliceDoc(e.from,e.to),k,N=t&&Bi(s,t.main.head);if(N){let he=e.insert.length-(e.to-e.from);k={from:N.from,to:N.to-he}}else k=s.state.doc.lineAt(r.head);let z=r.to-e.to,se=r.to-r.from;i=n.changeByRange(he=>{if(he.from==r.from&&he.to==r.to)return{changes:c,range:m||he.map(c)};let we=he.to-z,ke=we-C.length;if(he.to-he.from!=se||s.state.sliceDoc(ke,we)!=C||he.to>=k.from&&he.from<=k.to)return{range:he};let xe=n.changes({from:ke,to:we,insert:e.insert}),Qe=he.to-r.to;return{changes:xe,range:m?T.jT.range(Math.max(0,m.anchor+Qe),Math.max(0,m.head+Qe)):he.map(xe)}})}else i={changes:c,selection:m&&n.selection.replaceRange(m)}}let l="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,l+=".compose",s.inputState.compositionFirstChange&&(l+=".start",s.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:l,scrollIntoView:!0})}function hn(s,e,t,i){let n=Math.min(s.length,e.length),r=0;for(;r<n&&s.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==n&&s.length==e.length)return null;let l=s.length,c=e.length;for(;l>0&&c>0&&s.charCodeAt(l-1)==e.charCodeAt(c-1);)l--,c--;if(i=="end"){let m=Math.max(0,r-Math.min(l,c));t-=l+m-r}if(l<r&&s.length<e.length){let m=t<=r&&t>=l?r-t:0;r-=m,c=r+(c-l),l=r}else if(c<r){let m=t<=r&&t>=c?r-t:0;r-=m,l=r+(l-c),c=r}return{from:r,toA:l,toB:c}}function cn(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return t&&(e.push(new Ge(t,i)),(n!=t||r!=i)&&e.push(new Ge(n,r))),e}function Rn(s,e){if(s.length==0)return null;let t=s[0].pos,i=s.length==2?s[1].pos:t;return t>-1&&i>-1?T.jT.single(t+e,i+e):null}class In{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,De.safari&&e.contentDOM.addEventListener("input",()=>null),De.gecko&&Tr(e.contentDOM.ownerDocument)}handleEvent(e){!ni(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=S(e),i=this.handlers,n=this.view.contentDOM;for(let r in t)if(r!="scroll"){let l=!t[r].handlers.length,c=i[r];c&&l!=!c.handlers.length&&(n.removeEventListener(r,this.handleEvent),c=null),c||n.addEventListener(r,this.handleEvent,{passive:l})}for(let r in i)r!="scroll"&&!t[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Q.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),De.android&&De.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return De.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=V.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||W.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,We(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:De.safari&&!De.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function u(s,e){return(t,i)=>{try{return e.call(s,i,t)}catch(n){P(t.state,n)}}}function S(s){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of s){let n=i.spec,r=n&&n.plugin.domEventHandlers,l=n&&n.plugin.domEventObservers;if(r)for(let c in r){let m=r[c];m&&t(c).handlers.push(u(i.value,m))}if(l)for(let c in l){let m=l[c];m&&t(c).observers.push(u(i.value,m))}}for(let i in ai)t(i).handlers.push(ai[i]);for(let i in ui)t(i).observers.push(ui[i]);return e}const V=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],W="dthko",Q=[16,17,18,20,91,92,224,225],J=6;function ne(s){return Math.max(0,s)*.7+8}function Se(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}class He{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=pi(e.contentDOM),this.atoms=e.state.facet(Ce).map(l=>l(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(T.yy.allowMultipleSelections)&&vt(e,t),this.dragging=Vt(e,t)&&Ue(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Se(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,n=0,r=0,l=this.view.win.innerWidth,c=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:l}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:c}=this.scrollParents.y.getBoundingClientRect());let m=li(this.view);e.clientX-m.left<=n+J?t=-ne(n-e.clientX):e.clientX+m.right>=l-J&&(t=ne(e.clientX-l)),e.clientY-m.top<=r+J?i=-ne(r-e.clientY):e.clientY+m.bottom>=c-J&&(i=ne(e.clientY-c)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;i<e.ranges.length;i++){let n=e.ranges[i],r=null;if(n.empty){let l=tn(this.atoms,n.from,0);l!=n.from&&(r=T.jT.cursor(l,-1))}else{let l=tn(this.atoms,n.from,-1),c=tn(this.atoms,n.to,1);(l!=n.from||c!=n.to)&&(r=T.jT.range(n.from==n.anchor?l:c,n.from==n.head?l:c))}r&&(t||(t=e.ranges.slice()),t[i]=r)}return t?T.jT.create(t,e.mainIndex):e}select(e){let{view:t}=this,i=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function vt(s,e){let t=s.state.facet(O);return t.length?t[0](e):De.mac?e.metaKey:e.ctrlKey}function ct(s,e){let t=s.state.facet(H);return t.length?t[0](e):De.mac?!e.altKey:!e.ctrlKey}function Vt(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let i=Oe(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r<n.length;r++){let l=n[r];if(l.left<=e.clientX&&l.right>=e.clientX&&l.top<=e.clientY&&l.bottom>=e.clientY)return!0}return!1}function ni(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=ft.get(t))&&i.ignoreEvent(e))return!1;return!0}const ai=Object.create(null),ui=Object.create(null),fn=De.ie&&De.ie_version<15||De.ios&&De.webkit_version<604;function ms(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),h(s,t.value)},50)}function g(s,e,t){for(let i of s.facet(e))t=i(t,s);return t}function h(s,e){e=g(s.state,$e,e);let{state:t}=s,i,n=1,r=t.toText(e),l=r.lines==t.selection.ranges.length;if(ln!=null&&t.selection.ranges.every(m=>m.empty)&&ln==r.toString()){let m=-1;i=t.changeByRange(C=>{let k=t.doc.lineAt(C.from);if(k.from==m)return{range:C};m=k.from;let N=t.toText((l?r.line(n++).text:e)+t.lineBreak);return{changes:{from:k.from,insert:N},range:T.jT.cursor(C.from+N.length)}})}else l?i=t.changeByRange(m=>{let C=r.line(n++);return{changes:{from:m.from,to:m.to,insert:C.text},range:T.jT.cursor(m.from+C.length)}}):i=t.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ui.scroll=s=>{s.inputState.lastScrollTop=s.scrollDOM.scrollTop,s.inputState.lastScrollLeft=s.scrollDOM.scrollLeft},ai.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1),ui.touchstart=(s,e)=>{s.inputState.lastTouchTime=Date.now(),s.inputState.setSelectionOrigin("select.pointer")},ui.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")},ai.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of s.state.facet(Y))if(t=i(s,e),t)break;if(!t&&e.button==0&&(t=Mt(s,e)),t){let i=!s.hasFocus;s.inputState.startMouseSelection(new He(s,e,t,i)),i&&s.observer.ignore(()=>{Ft(s.contentDOM);let r=s.root.activeElement;r&&!r.contains(s.contentDOM)&&r.blur()});let n=s.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}return!1};function p(s,e,t,i){if(i==1)return T.jT.cursor(e,t);if(i==2)return F(s.state,e,t);{let n=E.find(s.docView,e),r=s.state.doc.lineAt(n?n.posAtEnd:e),l=n?n.posAtStart:r.from,c=n?n.posAtEnd:r.to;return c<s.state.doc.length&&c==r.to&&c++,T.jT.range(l,c)}}let v=(s,e,t)=>e>=t.top&&e<=t.bottom&&s>=t.left&&s<=t.right;function M(s,e,t,i){let n=E.find(s.docView,e);if(!n)return 1;let r=e-n.posAtStart;if(r==0)return 1;if(r==n.length)return-1;let l=n.coordsAt(r,-1);if(l&&v(t,i,l))return-1;let c=n.coordsAt(r,1);return c&&v(t,i,c)?1:l&&l.bottom>=i?-1:1}function $(s,e){let t=s.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:M(s,t,e.clientX,e.clientY)}}const j=De.ie&&De.ie_version<=11;let le=null,ce=0,Ie=0;function Ue(s){if(!j)return s.detail;let e=le,t=Ie;return le=s,Ie=Date.now(),ce=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(ce+1)%3:1}function Mt(s,e){let t=$(s,e),i=Ue(e),n=s.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),n=n.map(r.changes))},get(r,l,c){let m=$(s,r),C,k=p(s,m.pos,m.bias,i);if(t.pos!=m.pos&&!l){let N=p(s,t.pos,t.bias,i),z=Math.min(N.from,k.from),se=Math.max(N.to,k.to);k=z<k.from?T.jT.range(z,se):T.jT.range(se,z)}return l?n.replaceRange(n.main.extend(k.from,k.to)):c&&i==1&&n.ranges.length>1&&(C=Si(n,m.pos))?C:c?n.addRange(k):T.jT.create([k])}}}function Si(s,e){for(let t=0;t<s.ranges.length;t++){let{from:i,to:n}=s.ranges[t];if(i<=e&&n>=e)return T.jT.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}ai.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let n=s.docView.nearest(e.target);if(n&&n.isWidget){let r=n.posAtStart,l=r+n.length;(r>=t.to||l<=t.from)&&(t=T.jT.range(r,l))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",g(s.state,jt,s.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1},ai.dragend=s=>(s.inputState.draggedContent=null,!1);function Zt(s,e,t,i){if(t=g(s.state,$e,t),!t)return;let n=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=s.inputState,l=i&&r&&ct(s,e)?{from:r.from,to:r.to}:null,c={from:n,insert:t},m=s.state.changes(l?[l,c]:c);s.focus(),s.dispatch({changes:m,selection:{anchor:m.mapPos(n,-1),head:m.mapPos(n,1)},userEvent:l?"move.drop":"input.drop"}),s.inputState.draggedContent=null}ai.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,r=()=>{++n==t.length&&Zt(s,e,i.filter(l=>l!=null).join(s.state.lineBreak),!1)};for(let l=0;l<t.length;l++){let c=new FileReader;c.onerror=r,c.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(c.result)||(i[l]=c.result),r()},c.readAsText(t[l])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Zt(s,e,i,!0),!0}return!1},ai.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=fn?null:e.clipboardData;return t?(h(s,t.getData("text/plain")||t.getData("text/uri-list")),!0):(ms(s),!1)};function $i(s,e){let t=s.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function Gi(s){let e=[],t=[],i=!1;for(let n of s.selection.ranges)n.empty||(e.push(s.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:r}of s.selection.ranges){let l=s.doc.lineAt(r);l.number>n&&(e.push(l.text),t.push({from:l.from,to:Math.min(s.doc.length,l.to+1)})),n=l.number}i=!0}return{text:g(s,jt,e.join(s.lineBreak)),ranges:t,linewise:i}}let ln=null;ai.copy=ai.cut=(s,e)=>{let{text:t,ranges:i,linewise:n}=Gi(s.state);if(!t&&!n)return!1;ln=n?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=fn?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):($i(s,t),!1)};const un=T.q6.define();function Dn(s,e){let t=[];for(let i of s.facet(ze)){let n=i(s,e);n&&t.push(n)}return t.length?s.update({effects:t,annotations:un.of(!0)}):null}function Is(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=Dn(s.state,e);t?s.dispatch(t):s.update([])}},10)}ui.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),Is(s)},ui.blur=s=>{s.observer.clearSelectionRange(),Is(s)},ui.compositionstart=ui.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))},ui.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,De.chrome&&De.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))},ui.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()},ai.beforeinput=(s,e)=>{var t,i;if(e.inputType=="insertReplacementText"&&s.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),l=e.getTargetRanges();if(r&&l.length){let c=l[0],m=s.posAtDOM(c.startContainer,c.startOffset),C=s.posAtDOM(c.endContainer,c.endOffset);return Mn(s,{from:m,to:C,insert:s.state.toText(r)},null),!0}}let n;if(De.chrome&&De.android&&(n=V.find(r=>r.inputType==e.inputType))&&(s.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var l;(((l=window.visualViewport)===null||l===void 0?void 0:l.height)||0)>r+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return De.ios&&e.inputType=="deleteContentForward"&&s.observer.flushSoon(),De.safari&&e.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>ui.compositionend(s,e),20),!1};const Ns=new Set;function Tr(s){Ns.has(s)||(Ns.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}const Fs=["pre-wrap","normal","pre-line","break-spaces"];let On=!1;function gs(){On=!1}class Ws{constructor(e){this.lineWrapping=e,this.doc=T.xv.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Fs.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(t=!0,this.heightSamples[Math.floor(n*10)]=!0)}return t}refresh(e,t,i,n,r,l){let c=Fs.indexOf(e)>-1,m=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=c;if(this.lineWrapping=c,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,m){this.heightSamples={};for(let C=0;C<l.length;C++){let k=l[C];k<0?C++:this.heightSamples[Math.floor(k*10)]=!0}}return m}}class Vs{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class dn{constructor(e,t,i,n,r){this.from=e,this.length=t,this.top=i,this.height=n,this._content=r}get type(){return typeof this._content=="number"?lt.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof hi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new dn(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var bi=function(s){return s[s.ByPos=0]="ByPos",s[s.ByHeight=1]="ByHeight",s[s.ByPosNoHeight=2]="ByPosNoHeight",s}(bi||(bi={}));const Un=.001;class qi{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Un&&(On=!0),this.height=e)}replace(e,t,i){return qi.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,l=i.doc;for(let c=n.length-1;c>=0;c--){let{fromA:m,toA:C,fromB:k,toB:N}=n[c],z=r.lineAt(m,bi.ByPosNoHeight,i.setDoc(t),0,0),se=z.to>=C?z:r.lineAt(C,bi.ByPosNoHeight,i,0,0);for(N+=se.to-C,C=se.to;c>0&&z.from<=n[c-1].toA;)m=n[c-1].fromA,k=n[c-1].fromB,c--,m<z.from&&(z=r.lineAt(m,bi.ByPosNoHeight,i,0,0));k+=z.from-m,m=z.from;let he=ys.build(i.setDoc(l),e,k,N);r=Gn(r,r.replace(m,C,he))}return r.updateHeight(i,0)}static empty(){return new nn(0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,n=0,r=0;for(;;)if(t==i)if(n>r*2){let c=e[t-1];c.break?e.splice(--t,1,c.left,null,c.right):e.splice(--t,1,c.left,c.right),i+=1+c.break,n-=c.size}else if(r>n*2){let c=e[i];c.break?e.splice(i,1,c.left,null,c.right):e.splice(i,1,c.left,c.right),i+=2+c.break,r-=c.size}else break;else if(n<r){let c=e[t++];c&&(n+=c.size)}else{let c=e[--i];c&&(r+=c.size)}let l=0;return e[t-1]==null?(l=1,t--):e[t]==null&&(l=1,i++),new Mr(qi.of(e.slice(0,t)),l,qi.of(e.slice(i)))}}function Gn(s,e){return s==e?s:(s.constructor!=e.constructor&&(On=!0),e)}qi.prototype.size=1;class Hs extends qi{constructor(e,t,i){super(e,t),this.deco=i}blockAt(e,t,i,n){return new dn(n,this.length,i,this.height,this.deco||0)}lineAt(e,t,i,n,r){return this.blockAt(0,i,n,r)}forEachLine(e,t,i,n,r,l){e<=r+this.length&&t>=r&&l(this.blockAt(0,i,n,r))}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class nn extends Hs{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,n){return new dn(n,this.length,i,this.height,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof nn||n instanceof zi&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof zi?n=new nn(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):qi.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class zi extends qi{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,l,c=0;if(e.lineWrapping){let m=Math.min(this.height,e.lineHeight*r);l=m/r,this.length>r+1&&(c=(this.height-m)/(this.length-r-1))}else l=this.height/r;return{firstLine:i,lastLine:n,perLine:l,perChar:c}}blockAt(e,t,i,n){let{firstLine:r,lastLine:l,perLine:c,perChar:m}=this.heightMetrics(t,n);if(t.lineWrapping){let C=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),k=t.doc.lineAt(C),N=c+k.length*m,z=Math.max(i,e-N/2);return new dn(k.from,k.length,z,N,0)}else{let C=Math.max(0,Math.min(l-r,Math.floor((e-i)/c))),{from:k,length:N}=t.doc.line(r+C);return new dn(k,N,i+c*C,c,0)}}lineAt(e,t,i,n,r){if(t==bi.ByHeight)return this.blockAt(e,i,n,r);if(t==bi.ByPosNoHeight){let{from:se,to:he}=i.doc.lineAt(e);return new dn(se,he-se,0,0,0)}let{firstLine:l,perLine:c,perChar:m}=this.heightMetrics(i,r),C=i.doc.lineAt(e),k=c+C.length*m,N=C.number-l,z=n+c*N+m*(C.from-r-N);return new dn(C.from,C.length,Math.max(n,Math.min(z,n+this.height-k)),k,0)}forEachLine(e,t,i,n,r,l){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:c,perLine:m,perChar:C}=this.heightMetrics(i,r);for(let k=e,N=n;k<=t;){let z=i.doc.lineAt(k);if(k==e){let he=z.number-c;N+=m*he+C*(e-r-he)}let se=m+C*z.length;l(new dn(z.from,z.length,N,se,0)),N+=se,k=z.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let r=i[i.length-1];r instanceof zi?i[i.length-1]=new zi(r.length+n):i.push(null,new zi(n-1))}if(e>0){let r=i[0];r instanceof zi?i[0]=new zi(e+r.length):i.unshift(new zi(e-1),null)}return qi.of(i)}decomposeLeft(e,t){t.push(new zi(e-1),null)}decomposeRight(e,t){t.push(null,new zi(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let l=[],c=Math.max(t,n.from),m=-1;for(n.from>t&&l.push(new zi(n.from-t-1).updateHeight(e,t));c<=r&&n.more;){let k=e.doc.lineAt(c).length;l.length&&l.push(null);let N=n.heights[n.index++];m==-1?m=N:Math.abs(N-m)>=Un&&(m=-2);let z=new nn(k,N);z.outdated=!1,l.push(z),c+=k+1}c<=r&&l.push(null,new zi(r-c).updateHeight(e,c));let C=qi.of(l);return(m<0||Math.abs(C.height-this.height)>=Un||Math.abs(m-this.heightMetrics(e,t).perLine)>=Un)&&(On=!0),Gn(this,C)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Mr extends qi{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,r,n+this.left.length+this.break)}lineAt(e,t,i,n,r){let l=n+this.left.height,c=r+this.left.length+this.break,m=t==bi.ByHeight?e<l:e<c,C=m?this.left.lineAt(e,t,i,n,r):this.right.lineAt(e,t,i,l,c);if(this.break||(m?C.to<c:C.from>c))return C;let k=t==bi.ByPosNoHeight?bi.ByPosNoHeight:bi.ByPos;return m?C.join(this.right.lineAt(c,k,i,l,c)):this.left.lineAt(c,k,i,n,r).join(C)}forEachLine(e,t,i,n,r,l){let c=n+this.left.height,m=r+this.left.length+this.break;if(this.break)e<m&&this.left.forEachLine(e,t,i,n,r,l),t>=m&&this.right.forEachLine(e,t,i,c,m,l);else{let C=this.lineAt(m,bi.ByPos,i,n,r);e<C.from&&this.left.forEachLine(e,C.from-1,i,n,r,l),C.to>=e&&C.from<=t&&l(C),t>C.to&&this.right.forEachLine(C.to+1,t,i,c,m,l)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let l=r.length;for(let c of i)r.push(c);if(e>0&&$s(r,l-1),t<this.length){let c=r.length;this.decomposeRight(t,r),$s(r,c)}return qi.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?qi.of(this.break?[e,null,t]:[e,t]):(this.left=Gn(this.left,e),this.right=Gn(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:l}=this,c=t+r.length+this.break,m=null;return n&&n.from<=t+r.length&&n.more?m=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=c+l.length&&n.more?m=l=l.updateHeight(e,c,i,n):l.updateHeight(e,c,i),m?this.balanced(r,l):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function $s(s,e){let t,i;s[e]==null&&(t=s[e-1])instanceof zi&&(i=s[e+1])instanceof zi&&s.splice(e-1,3,new zi(t.length+1+i.length))}const Dr=5;class ys{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof nn?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new nn(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let l=t-e;i.block?this.addBlock(new Hs(l,n,i)):(l||r||n>=Dr)&&this.addLineDeco(n,r,l)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new nn(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new zi(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof nn)return e;let t=new nn(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof nn)&&!this.isCovered?this.nodes.push(new nn(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let n of this.nodes)n instanceof nn&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(e,t,i,n){let r=new ys(i,e);return T.Xs.spans(t,i,n,r,0),r.finish(i)}}function Or(s,e,t){let i=new Pr;return T.Xs.compare(s,e,t,i,0),i.changes}class Pr{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&_(e,t,this.changes,5)}}function Er(s,e){let t=s.getBoundingClientRect(),i=s.ownerDocument,n=i.defaultView||window,r=Math.max(0,t.left),l=Math.min(n.innerWidth,t.right),c=Math.max(0,t.top),m=Math.min(n.innerHeight,t.bottom);for(let C=s.parentNode;C&&C!=i.body;)if(C.nodeType==1){let k=C,N=window.getComputedStyle(k);if((k.scrollHeight>k.clientHeight||k.scrollWidth>k.clientWidth)&&N.overflow!="visible"){let z=k.getBoundingClientRect();r=Math.max(r,z.left),l=Math.min(l,z.right),c=Math.max(c,z.top),m=Math.min(C==s.parentNode?n.innerHeight:m,z.bottom)}C=N.position=="absolute"||N.position=="fixed"?k.offsetParent:k.parentNode}else if(C.nodeType==11)C=C.host;else break;return{left:r-t.left,right:Math.max(r,l)-t.left,top:c-(t.top+e),bottom:Math.max(c,m)-(t.top+e)}}function Br(s){let e=s.getBoundingClientRect(),t=s.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Lr(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class bs{constructor(e,t,i,n){this.from=e,this.to=t,this.size=i,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],r=t[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(e,t){return rt.replace({widget:new Rr(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Rr extends Ti{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class zs{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=js,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Te.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(de).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Ws(t),this.stateDeco=e.facet(fe).filter(i=>typeof i!="function"),this.heightMap=qi.empty().applyChanges(this.stateDeco,T.xv.empty,this.heightOracle.setDoc(e.doc),[new Di(0,0,0,e.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=rt.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:r,to:l})=>n>=r&&n<=l)){let{from:r,to:l}=this.lineBlockAt(n);e.push(new Xn(r,l))}}return this.viewports=e.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?js:new ws(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Hn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(fe).filter(k=>typeof k!="function");let n=e.changedRanges,r=Di.extendWithRanges(n,Or(i,this.stateDeco,e?e.changes:T.as.empty(this.state.doc.length))),l=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);gs(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=l||On)&&(e.flags|=2),c?(this.scrollAnchorPos=e.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=l);let m=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<m.from||t.range.head>m.to)||!this.viewportIsAppropriate(m))&&(m=this.getViewport(0,t));let C=m.from!=this.viewport.from||m.to!=this.viewport.to;this.viewport=m,e.flags|=this.updateForViewport(),(C||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(ii)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Te.RTL:Te.LTR;let l=this.heightOracle.mustRefreshForWrapping(r),c=t.getBoundingClientRect(),m=l||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let C=0,k=0;if(c.width&&c.height){let{scaleX:at,scaleY:mt}=Ut(t,c);(at>.005&&Math.abs(this.scaleX-at)>.005||mt>.005&&Math.abs(this.scaleY-mt)>.005)&&(this.scaleX=at,this.scaleY=mt,C|=16,l=m=!0)}let N=(parseInt(i.paddingTop)||0)*this.scaleY,z=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=N||this.paddingBottom!=z)&&(this.paddingTop=N,this.paddingBottom=z,C|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(m=!0),this.editorWidth=e.scrollDOM.clientWidth,C|=16);let se=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=se&&(this.scrollAnchorHeight=-1,this.scrollTop=se),this.scrolledToBottom=ki(e.scrollDOM);let he=(this.printing?Lr:Er)(t,this.paddingTop),we=he.top-this.pixelViewport.top,ke=he.bottom-this.pixelViewport.bottom;this.pixelViewport=he;let xe=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(xe!=this.inView&&(this.inView=xe,xe&&(m=!0)),!this.inView&&!this.scrollTarget&&!Br(e.dom))return 0;let Qe=c.width;if((this.contentDOMWidth!=Qe||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=e.scrollDOM.clientHeight,C|=16),m){let at=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(at)&&(l=!0),l||n.lineWrapping&&Math.abs(Qe-this.contentDOMWidth)>n.charWidth){let{lineHeight:mt,charWidth:gt,textHeight:Ci}=e.docView.measureTextSize();l=mt>0&&n.refresh(r,mt,gt,Ci,Qe/gt,at),l&&(e.docView.minWidth=0,C|=16)}we>0&&ke>0?k=Math.max(we,ke):we<0&&ke<0&&(k=Math.min(we,ke)),gs();for(let mt of this.viewports){let gt=mt.from==this.viewport.from?at:e.docView.measureVisibleLineHeights(mt);this.heightMap=(l?qi.empty().applyChanges(this.stateDeco,T.xv.empty,this.heightOracle,[new Di(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,l,new Vs(mt.from,gt))}On&&(C|=2)}let pt=!this.viewportIsAppropriate(this.viewport,k)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return pt&&(C&2&&(C|=this.updateScaler()),this.viewport=this.getViewport(k,this.scrollTarget),C|=this.updateForViewport()),(C&2||pt)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(l?[]:this.lineGaps,e)),C|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),C}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:l,visibleBottom:c}=this,m=new Xn(n.lineAt(l-i*1e3,bi.ByHeight,r,0,0).from,n.lineAt(c+(1-i)*1e3,bi.ByHeight,r,0,0).to);if(t){let{head:C}=t.range;if(C<m.from||C>m.to){let k=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),N=n.lineAt(C,bi.ByPos,r,0,0),z;t.y=="center"?z=(N.top+N.bottom)/2-k/2:t.y=="start"||t.y=="nearest"&&C<m.from?z=N.top:z=N.bottom-k,m=new Xn(n.lineAt(z-1e3/2,bi.ByHeight,r,0,0).from,n.lineAt(z+k+1e3/2,bi.ByHeight,r,0,0).to)}}return m}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new Xn(this.heightMap.lineAt(i,bi.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,bi.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,bi.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,bi.ByPos,this.heightOracle,0,0),{visibleTop:l,visibleBottom:c}=this;return(e==0||n<=l-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=c+Math.max(10,Math.min(i,250)))&&n>l-2*1e3&&r<c+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new bs(t.mapPos(n.from),t.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,l=n<<1;if(this.defaultTextDirection!=Te.LTR&&!i)return[];let c=[],m=(k,N,z,se)=>{if(N-k<r)return;let he=this.state.selection.main,we=[he.from];he.empty||we.push(he.to);for(let xe of we)if(xe>k&&xe<N){m(k,xe-10,z,se),m(xe+10,N,z,se);return}let ke=Nr(e,xe=>xe.from>=z.from&&xe.to<=z.to&&Math.abs(xe.from-k)<r&&Math.abs(xe.to-N)<r&&!we.some(Qe=>xe.from<Qe&&xe.to>Qe));if(!ke){if(N<z.to&&t&&i&&t.visibleRanges.some(pt=>pt.from<=N&&pt.to>=N)){let pt=t.moveToLineBoundary(T.jT.cursor(N),!1,!0).head;pt>k&&(N=pt)}let xe=this.gapSize(z,k,N,se),Qe=i||xe<2e6?xe:2e6;ke=new bs(k,N,xe,Qe)}c.push(ke)},C=k=>{if(k.length<l||k.type!=lt.Text)return;let N=Ir(k.from,k.to,this.stateDeco);if(N.total<l)return;let z=this.scrollTarget?this.scrollTarget.range.head:null,se,he;if(i){let we=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,ke,xe;if(z!=null){let Qe=Qn(N,z),pt=((this.visibleBottom-this.visibleTop)/2+we)/k.height;ke=Qe-pt,xe=Qe+pt}else ke=(this.visibleTop-k.top-we)/k.height,xe=(this.visibleBottom-k.top+we)/k.height;se=Yn(N,ke),he=Yn(N,xe)}else{let we=N.total*this.heightOracle.charWidth,ke=n*this.heightOracle.charWidth,xe=0;if(we>2e6)for(let gt of e)gt.from>=k.from&&gt.from<k.to&&gt.size!=gt.displaySize&&gt.from*this.heightOracle.charWidth+xe<this.pixelViewport.left&&(xe=gt.size-gt.displaySize);let Qe=this.pixelViewport.left+xe,pt=this.pixelViewport.right+xe,at,mt;if(z!=null){let gt=Qn(N,z),Ci=((pt-Qe)/2+ke)/we;at=gt-Ci,mt=gt+Ci}else at=(Qe-ke)/we,mt=(pt+ke)/we;se=Yn(N,at),he=Yn(N,mt)}se>k.from&&m(k.from,se,k,N),he<k.to&&m(he,k.to,k,N)};for(let k of this.viewportLines)Array.isArray(k.type)?k.type.forEach(C):C(k);return c}gapSize(e,t,i,n){let r=Qn(n,i)-Qn(n,t);return this.heightOracle.lineWrapping?e.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(e){bs.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=rt.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];T.Xs.spans(t,this.viewport.from,this.viewport.to,{span(r,l){i.push({from:r,to:l})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let r=0;r<i.length&&!(n&8);r++){let l=this.visibleRanges[r],c=i[r];(l.from!=c.from||l.to!=c.to)&&(n|=4,e&&e.mapPos(l.from,-1)==c.from&&e.mapPos(l.to,1)==c.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Hn(this.heightMap.lineAt(e,bi.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Hn(this.heightMap.lineAt(this.scaler.fromDOM(e),bi.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Hn(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Xn{constructor(e,t){this.from=e,this.to=t}}function Ir(s,e,t){let i=[],n=s,r=0;return T.Xs.spans(t,s,e,{span(){},point(l,c){l>n&&(i.push({from:n,to:l}),r+=l-n),n=c}},20),n<e&&(i.push({from:n,to:e}),r+=e-n),{total:r,ranges:i}}function Yn({total:s,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(s*t);for(let n=0;;n++){let{from:r,to:l}=e[n],c=l-r;if(i<=c)return r+i;i-=c}}function Qn(s,e){let t=0;for(let{from:i,to:n}of s.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/s.total}function Nr(s,e){for(let t of s)if(e(t))return t}const js={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}};class ws{constructor(e,t,i){let n=0,r=0,l=0;this.viewports=i.map(({from:c,to:m})=>{let C=t.lineAt(c,bi.ByPos,e,0,0).top,k=t.lineAt(m,bi.ByPos,e,0,0).bottom;return n+=k-C,{from:c,to:m,top:C,bottom:k,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let c of this.viewports)c.domTop=l+(c.top-r)*this.scale,l=c.domBottom=c.domTop+(c.bottom-c.top),r=c.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return n+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,n=r.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-n)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,n=r.domBottom}}eq(e){return e instanceof ws?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function Hn(s,e){if(e.scale==1)return s;let t=e.toDOM(s.top),i=e.toDOM(s.bottom);return new dn(s.from,s.length,t,i-t,Array.isArray(s._content)?s._content.map(n=>Hn(n,e)):s._content)}const Zn=T.r$.define({combine:s=>s.join(" ")}),vs=T.r$.define({combine:s=>s.indexOf(!0)>-1}),ks=re.V.newName(),_s=re.V.newName(),Js=re.V.newName(),qs={"&light":"."+_s,"&dark":"."+Js};function xs(s,e,t){return new re.V(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return s;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):s+" "+i}})}const Fr=xs("."+ks,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},qs),Wr={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ss=De.ie&&De.ie_version<=11;class Vr{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new mi,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(De.ie&&De.ie_version<=11||De.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&De.android&&e.constructor.EDIT_CONTEXT!==!1&&!(De.chrome&&De.chrome_version<126)&&(this.editContext=new $r(e),e.state.facet(y)&&(e.contentDOM.editContext=this.editContext.editContext)),Ss&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(y)?i.root.activeElement!=this.dom:!Lt(this.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(De.ie&&De.ie_version<=11||De.android&&De.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Jt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Oe(e.root);if(!t)return!1;let i=De.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Hr(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=Lt(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&di(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Wr),Ss&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ss&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let n=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&We(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let l=this.readMutation(r);l&&(l.typeOver&&(n=!0),t==-1?{from:t,to:i}=l:(t=Math.min(l.from,t),i=Math.max(l.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Lt(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Ln(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=Tn(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=Ks(t,e.previousSibling||e.target.previousSibling,-1),n=Ks(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(y)!=e.state.facet(y)&&(e.view.contentDOM.editContext=e.state.facet(y)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Ks(s,e,t){for(;e;){let i=ft.get(e);if(i&&i.parent==s)return i;let n=e.parentNode;e=n!=s.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function Us(s,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,r=e.endOffset,l=s.docView.domAtPos(s.state.selection.main.anchor);return Jt(l.node,l.offset,n,r)&&([t,i,n,r]=[n,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}}function Hr(s,e){if(e.getComposedRanges){let n=e.getComposedRanges(s.root)[0];if(n)return Us(s,n)}let t=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",i,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",i,!0),t?Us(s,t):null}class $r{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let n=e.state.selection.main,{anchor:r,head:l}=n,c=this.toEditorPos(i.updateRangeStart),m=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:c,drifted:!1});let C={from:c,to:m,insert:T.xv.of(i.text.split(`
25
+ `))};if(C.from==this.from&&r<this.from?C.from=r:C.to==this.to&&r>this.to&&(C.to=r),C.from==C.to&&!C.insert.length){let k=T.jT.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));k.main.eq(n)||e.dispatch({selection:k,userEvent:"select"});return}if((De.mac||De.android)&&C.from==l-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(C={from:c,to:m,insert:T.xv.of([i.text.replace("."," ")])}),this.pendingContextChange=C,!e.state.readOnly){let k=this.to-this.from+(C.to-C.from+C.insert.length);Mn(e,C,T.jT.single(this.toEditorPos(i.selectionStart,k),this.toEditorPos(i.selectionEnd,k)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let l=this.toEditorPos(i.rangeStart),c=this.toEditorPos(i.rangeEnd);l<c;l++){let m=e.coordsForChar(l);r=m&&new DOMRect(m.left,m.top,m.right-m.left,m.bottom-m.top)||r||new DOMRect,n.push(r)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let r of i.getTextFormats()){let l=r.underlineStyle,c=r.underlineThickness;if(l!="None"&&c!="None"){let m=this.toEditorPos(r.rangeStart),C=this.toEditorPos(r.rangeEnd);if(m<C){let k=`text-decoration: underline ${l=="Dashed"?"dashed ":l=="Squiggle"?"wavy ":""}${c=="Thin"?1:2}px`;n.push(rt.mark({attributes:{style:k}}).range(m,C))}}}e.dispatch({effects:rn.of(rt.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let n=Oe(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,l,c,m,C)=>{if(i)return;let k=C.length-(l-r);if(n&&l>=n.to)if(n.from==r&&n.to==l&&n.insert.eq(C)){n=this.pendingContextChange=null,t+=k,this.to+=k;return}else n=null,this.revertPending(e.state);if(r+=t,l+=t,l<=this.from)this.from+=k,this.to+=k;else if(r<this.to){if(r<this.from||l>this.to||this.to-this.from+C.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(l),C.toString()),this.to+=k}t+=k}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ht{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(r=>i(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||ht(e.parent)||document,this.viewState=new zs(e.state||T.yy.create(e)),e.scrollTo&&e.scrollTo.is(Ui)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(L).map(n=>new G(n));for(let n of this.plugins)n.update(this);this.observer=new Vr(this),this.inputState=new In(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Qt(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof T.YW?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let z of e){if(z.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=z.state}if(this.destroyed){this.viewState.state=r;return}let l=this.hasFocus,c=0,m=null;e.some(z=>z.annotation(un))?(this.inputState.notifiedFocused=l,c=1):l!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=l,m=Dn(r,l),m||(c=1));let C=this.observer.delayedAndroidKey,k=null;if(C?(this.observer.clearDelayedAndroidKey(),k=this.observer.readChange(),(k&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(k=null)):this.observer.clear(),r.facet(T.yy.phrases)!=this.state.facet(T.yy.phrases))return this.setState(r);n=xi.create(this,r,e),n.flags|=c;let N=this.viewState.scrollTarget;try{this.updateState=2;for(let z of e){if(N&&(N=N.map(z.changes)),z.scrollIntoView){let{main:se}=z.state.selection;N=new Ki(se.empty?se:T.jT.cursor(se.head,se.head>se.anchor?-1:1))}for(let se of z.effects)se.is(Ui)&&(N=se.value.clip(this.state))}this.viewState.update(n,N),this.bidiCache=es.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(yi)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(z=>z.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(Zn)!=n.state.facet(Zn)&&(this.viewState.mustMeasureContent=!0),(t||i||N||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let z of this.state.facet(ve))try{z(n)}catch(se){P(this.state,se,"update listener")}(m||k)&&Promise.resolve().then(()=>{m&&this.state==m.startState&&this.dispatch(m),k&&!Tn(this,k)&&C.force&&We(this.contentDOM,C.key,C.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new zs(e),this.plugins=e.facet(L).map(i=>new G(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Qt(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(L),i=e.state.facet(L);if(t!=i){let n=[];for(let r of i){let l=t.indexOf(r);if(l<0)n.push(new G(r));else{let c=this.plugins[l];c.mustUpdate=e,n.push(c)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){P(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:l}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(l=-1),this.viewState.scrollAnchorHeight=-1;try{for(let c=0;;c++){if(l<0)if(ki(i))r=-1,l=this.viewState.heightMap.height;else{let se=this.viewState.scrollAnchorAt(n);r=se.from,l=se.top}this.updateState=1;let m=this.viewState.measure(this);if(!m&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(c>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let C=[];m&4||([this.measureRequests,C]=[C,this.measureRequests]);let k=C.map(se=>{try{return se.read(this)}catch(he){return P(this.state,he),Gs}}),N=xi.create(this,this.state,[]),z=!1;N.flags|=m,t?t.flags|=m:t=N,this.updateState=2,N.empty||(this.updatePlugins(N),this.inputState.update(N),this.updateAttrs(),z=this.docView.update(N),z&&this.docViewUpdate());for(let se=0;se<C.length;se++)if(k[se]!=Gs)try{let he=C[se];he.write&&he.write(k[se],this)}catch(he){P(this.state,he)}if(z&&this.docView.updateSelection(!0),!N.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,l=-1;continue}else{let he=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-l;if(he>1||he<-1){n=n+he,i.scrollTop=n/this.scaleY,l=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let c of this.state.facet(ve))c(t)}get themeClasses(){return ks+" "+(this.state.facet(vs)?Js:_s)+" "+this.state.facet(Zn)}updateAttrs(){let e=Xs(this,oe,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(y)?"true":"false",class:"cm-content",style:`${De.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Xs(this,de,t);let i=this.observer.ignore(()=>{let n=At(this.contentDOM,this.contentAttrs,t),r=At(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(Ht.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(yi);let e=this.state.facet(Ht.cspNonce);re.V.mount(this.root,this.styleModules.concat(Fr).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return gn(this,e,Bn(this,e,t,i))}moveByGroup(e,t){return gn(this,e,Bn(this,e,t,i=>Kn(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return T.jT.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return mn(this,e,t,i)}moveVertically(e,t,i){return gn(this,e,Vn(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Wi(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),l=r[Ei.find(r,e-n.from,-1,t)];return Ze(i,l.dir==Te.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Fi)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zr)return a(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Xi(r.isolates,i=wt(this,e))))return r.order;i||(i=wt(this,e));let n=o(e.text,t,i);return this.bidiCache.push(new es(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||De.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ft(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Ui.of(new Ki(typeof e=="number"?T.jT.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Ui.of(new Ki(T.jT.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return I.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return I.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=re.V.newName(),n=[Zn.of(i),yi.of(xs(`.${i}`,e))];return t&&t.dark&&n.push(vs.of(!0)),n}static baseTheme(e){return T.Wl.lowest(yi.of(xs("."+ks,e,qs)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&ft.get(i)||ft.get(e);return((t=n==null?void 0:n.rootView)===null||t===void 0?void 0:t.view)||null}}Ht.styleModule=yi,Ht.inputHandler=Ee,Ht.clipboardInputFilter=$e,Ht.clipboardOutputFilter=jt,Ht.scrollHandler=Qi,Ht.focusChangeEffect=ze,Ht.perLineTextDirection=Fi,Ht.exceptionSink=ue,Ht.updateListener=ve,Ht.editable=y,Ht.mouseSelectionStyle=Y,Ht.dragMovesSelection=H,Ht.clickAddsSelectionRange=O,Ht.decorations=fe,Ht.outerDecorations=Me,Ht.atomicRanges=Ce,Ht.bidiIsolatedRanges=_e,Ht.scrollMargins=Wt,Ht.darkTheme=vs,Ht.cspNonce=T.r$.define({combine:s=>s.length?s[0]:""}),Ht.contentAttributes=de,Ht.editorAttributes=oe,Ht.lineWrapping=Ht.contentAttributes.of({class:"cm-lineWrapping"}),Ht.announce=T.Py.define();const zr=4096,Gs={};class es{constructor(e,t,i,n,r,l){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=l}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:Te.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let l=e[r];l.dir==n&&!t.touchesRange(l.from,l.to)&&i.push(new es(t.mapPos(l.from,1),t.mapPos(l.to,-1),l.dir,l.isolates,!1,l.order))}return i}}function Xs(s,e,t){for(let i=s.state.facet(e),n=i.length-1;n>=0;n--){let r=i[n],l=typeof r=="function"?r(s):r;l&&xt(l,t)}return t}const jr=De.mac?"mac":De.windows?"win":De.linux?"linux":"key";function _r(s,e){const t=s.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let n,r,l,c;for(let m=0;m<t.length-1;++m){const C=t[m];if(/^(cmd|meta|m)$/i.test(C))c=!0;else if(/^a(lt)?$/i.test(C))n=!0;else if(/^(c|ctrl|control)$/i.test(C))r=!0;else if(/^s(hift)?$/i.test(C))l=!0;else if(/^mod$/i.test(C))e=="mac"?c=!0:r=!0;else throw new Error("Unrecognized modifier name: "+C)}return n&&(i="Alt-"+i),r&&(i="Ctrl-"+i),c&&(i="Meta-"+i),l&&(i="Shift-"+i),i}function ts(s,e,t){return e.altKey&&(s="Alt-"+s),e.ctrlKey&&(s="Ctrl-"+s),e.metaKey&&(s="Meta-"+s),t!==!1&&e.shiftKey&&(s="Shift-"+s),s}const Jr=T.Wl.default(Ht.domEventHandlers({keydown(s,e){return er(Zs(e.state),s,e,"editor")}})),Ys=T.r$.define({enables:Jr}),Qs=new WeakMap;function Zs(s){let e=s.facet(Ys),t=Qs.get(e);return t||Qs.set(e,t=Ur(e.reduce((i,n)=>i.concat(n),[]))),t}function qr(s,e,t){return er(Zs(s.state),e,s,t)}let Sn=null;const Kr=4e3;function Ur(s,e=jr){let t=Object.create(null),i=Object.create(null),n=(l,c)=>{let m=i[l];if(m==null)i[l]=c;else if(m!=c)throw new Error("Key binding "+l+" is used both as a regular binding and as a multi-stroke prefix")},r=(l,c,m,C,k)=>{var N,z;let se=t[l]||(t[l]=Object.create(null)),he=c.split(/ (?!$)/).map(xe=>_r(xe,e));for(let xe=1;xe<he.length;xe++){let Qe=he.slice(0,xe).join(" ");n(Qe,!0),se[Qe]||(se[Qe]={preventDefault:!0,stopPropagation:!1,run:[pt=>{let at=Sn={view:pt,prefix:Qe,scope:l};return setTimeout(()=>{Sn==at&&(Sn=null)},Kr),!0}]})}let we=he.join(" ");n(we,!1);let ke=se[we]||(se[we]={preventDefault:!1,stopPropagation:!1,run:((z=(N=se._any)===null||N===void 0?void 0:N.run)===null||z===void 0?void 0:z.slice())||[]});m&&ke.run.push(m),C&&(ke.preventDefault=!0),k&&(ke.stopPropagation=!0)};for(let l of s){let c=l.scope?l.scope.split(" "):["editor"];if(l.any)for(let C of c){let k=t[C]||(t[C]=Object.create(null));k._any||(k._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:N}=l;for(let z in k)k[z].run.push(se=>N(se,Cs))}let m=l[e]||l.key;if(m)for(let C of c)r(C,m,l.run,l.preventDefault,l.stopPropagation),l.shift&&r(C,"Shift-"+m,l.shift,l.preventDefault,l.stopPropagation)}return t}let Cs=null;function er(s,e,t,i){Cs=e;let n=(0,te.YG)(e),r=(0,T.gm)(n,0),l=(0,T.nZ)(r)==n.length&&n!=" ",c="",m=!1,C=!1,k=!1;Sn&&Sn.view==t&&Sn.scope==i&&(c=Sn.prefix+" ",Q.indexOf(e.keyCode)<0&&(C=!0,Sn=null));let N=new Set,z=ke=>{if(ke){for(let xe of ke.run)if(!N.has(xe)&&(N.add(xe),xe(t)))return ke.stopPropagation&&(k=!0),!0;ke.preventDefault&&(ke.stopPropagation&&(k=!0),C=!0)}return!1},se=s[i],he,we;return se&&(z(se[c+ts(n,e,!l)])?m=!0:l&&(e.altKey||e.metaKey||e.ctrlKey)&&!(De.windows&&e.ctrlKey&&e.altKey)&&(he=te.ue[e.keyCode])&&he!=n?(z(se[c+ts(he,e,!0)])||e.shiftKey&&(we=te.uY[e.keyCode])!=n&&we!=he&&z(se[c+ts(we,e,!1)]))&&(m=!0):l&&e.shiftKey&&z(se[c+ts(n,e,!0)])&&(m=!0),!m&&z(se._any)&&(m=!0)),C&&(m=!0),m&&k&&e.stopPropagation(),Cs=null,m}class $n{constructor(e,t,i,n,r){this.className=e,this.left=t,this.top=i,this.width=n,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let r=tr(e);return[new $n(t,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}else return Gr(e,t,i)}}function tr(s){let e=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==Te.LTR?e.left:e.right-s.scrollDOM.clientWidth*s.scaleX)-s.scrollDOM.scrollLeft*s.scaleX,top:e.top-s.scrollDOM.scrollTop*s.scaleY}}function ir(s,e,t,i){let n=s.coordsAtPos(e,t*2);if(!n)return i;let r=s.dom.getBoundingClientRect(),l=(n.top+n.bottom)/2,c=s.posAtCoords({x:r.left+1,y:l}),m=s.posAtCoords({x:r.right-1,y:l});return c==null||m==null?i:{from:Math.max(i.from,Math.min(c,m)),to:Math.min(i.to,Math.max(c,m))}}function Gr(s,e,t){if(t.to<=s.viewport.from||t.from>=s.viewport.to)return[];let i=Math.max(t.from,s.viewport.from),n=Math.min(t.to,s.viewport.to),r=s.textDirection==Te.LTR,l=s.contentDOM,c=l.getBoundingClientRect(),m=tr(s),C=l.querySelector(".cm-line"),k=C&&window.getComputedStyle(C),N=c.left+(k?parseInt(k.paddingLeft)+Math.min(0,parseInt(k.textIndent)):0),z=c.right-(k?parseInt(k.paddingRight):0),se=kn(s,i,1),he=kn(s,n,-1),we=se.type==lt.Text?se:null,ke=he.type==lt.Text?he:null;if(we&&(s.lineWrapping||se.widgetLineBreaks)&&(we=ir(s,i,1,we)),ke&&(s.lineWrapping||he.widgetLineBreaks)&&(ke=ir(s,n,-1,ke)),we&&ke&&we.from==ke.from&&we.to==ke.to)return Qe(pt(t.from,t.to,we));{let mt=we?pt(t.from,null,we):at(se,!1),gt=ke?pt(null,t.to,ke):at(he,!0),Ci=[];return(we||se).to<(ke||he).from-(we&&ke?1:0)||se.widgetLineBreaks>1&&mt.bottom+s.defaultLineHeight/2<gt.top?Ci.push(xe(N,mt.bottom,z,gt.top)):mt.bottom<gt.top&&s.elementAtHeight((mt.bottom+gt.top)/2).type==lt.Text&&(mt.bottom=gt.top=(mt.bottom+gt.top)/2),Qe(mt).concat(Ci).concat(Qe(gt))}function xe(mt,gt,Ci,ji){return new $n(e,mt-m.left,gt-m.top,Ci-mt,ji-gt)}function Qe({top:mt,bottom:gt,horizontal:Ci}){let ji=[];for(let Cn=0;Cn<Ci.length;Cn+=2)ji.push(xe(Ci[Cn],mt,Ci[Cn+1],gt));return ji}function pt(mt,gt,Ci){let ji=1e9,Cn=-1e9,us=[];function Ar(Pn,An,Wn,En,qn){let wn=s.coordsAtPos(Pn,Pn==Ci.to?-2:2),vn=s.coordsAtPos(Wn,Wn==Ci.from?2:-2);!wn||!vn||(ji=Math.min(wn.top,vn.top,ji),Cn=Math.max(wn.bottom,vn.bottom,Cn),qn==Te.LTR?us.push(r&&An?N:wn.left,r&&En?z:vn.right):us.push(!r&&En?N:vn.left,!r&&An?z:wn.right))}let ds=mt??Ci.from,ps=gt??Ci.to;for(let Pn of s.visibleRanges)if(Pn.to>ds&&Pn.from<ps)for(let An=Math.max(Pn.from,ds),Wn=Math.min(Pn.to,ps);;){let En=s.state.doc.lineAt(An);for(let qn of s.bidiSpans(En)){let wn=qn.from+En.from,vn=qn.to+En.from;if(wn>=Wn)break;vn>An&&Ar(Math.max(wn,An),mt==null&&wn<=ds,Math.min(vn,Wn),gt==null&&vn>=ps,qn.dir)}if(An=En.to+1,An>=Wn)break}return us.length==0&&Ar(ds,mt==null,ps,gt==null,s.textDirection),{top:ji,bottom:Cn,horizontal:us}}function at(mt,gt){let Ci=c.top+(gt?mt.top:mt.bottom);return{top:Ci,bottom:Ci,horizontal:[]}}}function Xr(s,e){return s.constructor==e.constructor&&s.eq(e)}class Yr{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(is)!=e.state.facet(is)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(is);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!Xr(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let n=t.nextSibling;t.remove(),t=n}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const is=T.r$.define();function nr(s){return[I.define(e=>new Yr(e,s)),is.of(s)]}const Nn=T.r$.define({combine(s){return(0,T.BO)(s,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Qr(s={}){return[Nn.of(s),Zr,eo,to,ii.of(!0)]}function tl(s){return s.facet(Nn)}function sr(s){return s.startState.facet(Nn)!=s.state.facet(Nn)}const Zr=nr({above:!0,markers(s){let{state:e}=s,t=e.facet(Nn),i=[];for(let n of e.selection.ranges){let r=n==e.selection.main;if(n.empty||t.drawRangeCursor){let l=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",c=n.empty?n:T.jT.cursor(n.head,n.head>n.anchor?-1:1);for(let m of $n.forRange(s,l,c))i.push(m)}}return i},update(s,e){s.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=sr(s);return t&&rr(s.state,e),s.docChanged||s.selectionSet||t},mount(s,e){rr(e.state,s)},class:"cm-cursorLayer"});function rr(s,e){e.style.animationDuration=s.facet(Nn).cursorBlinkRate+"ms"}const eo=nr({above:!1,markers(s){return s.state.selection.ranges.map(e=>e.empty?[]:$n.forRange(s,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(s,e){return s.docChanged||s.selectionSet||s.viewportChanged||sr(s)},class:"cm-selectionLayer"}),to=T.Wl.highest(Ht.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),or=T.Py.define({map(s,e){return s==null?null:e.mapPos(s)}}),zn=T.QQ.define({create(){return null},update(s,e){return s!=null&&(s=e.changes.mapPos(s)),e.effects.reduce((t,i)=>i.is(or)?i.value:t,s)}}),io=I.fromClass(class{constructor(s){this.view=s,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(s){var e;let t=s.state.field(zn);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(s.startState.field(zn)!=t||s.docChanged||s.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:s}=this,e=s.state.field(zn),t=e!=null&&s.coordsAtPos(e);if(!t)return null;let i=s.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+s.scrollDOM.scrollLeft*s.scaleX,top:t.top-i.top+s.scrollDOM.scrollTop*s.scaleY,height:t.bottom-t.top}}drawCursor(s){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;s?(this.cursor.style.left=s.left/e+"px",this.cursor.style.top=s.top/t+"px",this.cursor.style.height=s.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(s){this.view.state.field(zn)!=s&&this.view.dispatch({effects:or.of(s)})}},{eventObservers:{dragover(s){this.setDropPos(this.view.posAtCoords({x:s.clientX,y:s.clientY}))},dragleave(s){(s.target==this.view.contentDOM||!this.view.contentDOM.contains(s.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function no(){return[zn,io]}function lr(s,e,t,i,n){e.lastIndex=0;for(let r=s.iterRange(t,i),l=t,c;!r.next().done;l+=r.value.length)if(!r.lineBreak)for(;c=e.exec(r.value);)n(l+c.index,c)}function so(s,e){let t=s.visibleRanges;if(t.length==1&&t[0].from==s.viewport.from&&t[0].to==s.viewport.to)return t;let i=[];for(let{from:n,to:r}of t)n=Math.max(s.state.doc.lineAt(n).from,n-e),r=Math.min(s.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=n?i[i.length-1].to=r:i.push({from:n,to:r});return i}class As{constructor(e){const{regexp:t,decoration:i,decorate:n,boundary:r,maxLength:l=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(c,m,C,k)=>n(k,C,C+c[0].length,c,m);else if(typeof i=="function")this.addMatch=(c,m,C,k)=>{let N=i(c,m,C);N&&k(C,C+c[0].length,N)};else if(i)this.addMatch=(c,m,C,k)=>k(C,C+c[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=l}createDeco(e){let t=new T.f_,i=t.add.bind(t);for(let{from:n,to:r}of so(e,this.maxLength))lr(e.state.doc,this.regexp,n,r,(l,c)=>this.addMatch(c,e,l,i));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return e.docChanged&&e.changes.iterChanges((r,l,c,m)=>{m>=e.view.viewport.from&&c<=e.view.viewport.to&&(i=Math.min(c,i),n=Math.max(m,n))}),e.viewportMoved||n-i>1e3?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let r of e.visibleRanges){let l=Math.max(r.from,i),c=Math.min(r.to,n);if(c>=l){let m=e.state.doc.lineAt(l),C=m.to<c?e.state.doc.lineAt(c):m,k=Math.max(r.from,m.from),N=Math.min(r.to,C.to);if(this.boundary){for(;l>m.from;l--)if(this.boundary.test(m.text[l-1-m.from])){k=l;break}for(;c<C.to;c++)if(this.boundary.test(C.text[c-C.from])){N=c;break}}let z=[],se,he=(we,ke,xe)=>z.push(xe.range(we,ke));if(m==C)for(this.regexp.lastIndex=k-m.from;(se=this.regexp.exec(m.text))&&se.index<N-m.from;)this.addMatch(se,e,se.index+m.from,he);else lr(e.state.doc,this.regexp,k,N,(we,ke)=>this.addMatch(ke,e,we,he));t=t.update({filterFrom:k,filterTo:N,filter:(we,ke)=>we<k||ke>N,add:z})}}return t}}const Ts=/x/.unicode!=null?"gu":"g",ro=new RegExp(`[\0-\b
26
+ -\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Ts),oo={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 Ms=null;function lo(){var s;if(Ms==null&&typeof document<"u"&&document.body){let e=document.body.style;Ms=((s=e.tabSize)!==null&&s!==void 0?s:e.MozTabSize)!=null}return Ms||!1}const ns=T.r$.define({combine(s){let e=(0,T.BO)(s,{render:null,specialChars:ro,addSpecialChars:null});return(e.replaceTabs=!lo())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Ts)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Ts)),e}});function ao(s={}){return[ns.of(s),ho()]}let ar=null;function ho(){return ar||(ar=I.fromClass(class{constructor(s){this.view=s,this.decorations=rt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(s.state.facet(ns)),this.decorations=this.decorator.createDeco(s)}makeDecorator(s){return new As({regexp:s.specialChars,decoration:(e,t,i)=>{let{doc:n}=t.state,r=(0,T.gm)(e[0],0);if(r==9){let l=n.lineAt(i),c=t.state.tabSize,m=(0,T.IS)(l.text,c,i-l.from);return rt.replace({widget:new po((c-m%c)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=rt.replace({widget:new uo(s,r)}))},boundary:s.replaceTabs?void 0:/[^]/})}update(s){let e=s.state.facet(ns);s.startState.facet(ns)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(s.view)):this.decorations=this.decorator.updateDeco(s,this.decorations)}},{decorations:s=>s.decorations}))}const co="\u2022";function fo(s){return s>=32?co:s==10?"\u2424":String.fromCharCode(9216+s)}class uo extends Ti{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=fo(this.code),i=e.state.phrase("Control character")+" "+(oo[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,t);if(n)return n;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 po extends Ti{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}}const hr=null;function il(){return[hr,de.of(s=>{var e;return((e=s.plugin(hr))===null||e===void 0?void 0:e.attrs)||null})]}function mo(){return yo}const go=rt.line({class:"cm-activeLine"}),yo=I.fromClass(class{constructor(s){this.decorations=this.getDeco(s)}update(s){(s.docChanged||s.selectionSet)&&(this.decorations=this.getDeco(s.view))}getDeco(s){let e=-1,t=[];for(let i of s.state.selection.ranges){let n=s.lineBlockAt(i.head);n.from>e&&(t.push(go.range(n.from)),e=n.from)}return rt.set(t)}},{decorations:s=>s.decorations});class bo extends null{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?Nt(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),n=Ze(t[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return n.bottom-n.top>r*1.5?{left:n.left,right:n.right,top:n.top,bottom:n.top+r}:n}ignoreEvent(){return!1}}function nl(s){let e=I.fromClass(class{constructor(t){this.view=t,this.placeholder=s?rt.set([rt.widget({widget:new bo(s),side:1}).range(0)]):rt.none}get decorations(){return this.view.state.doc.length?rt.none:this.placeholder}},{decorations:t=>t.decorations});return typeof s=="string"?[e,Ht.contentAttributes.of({"aria-placeholder":s})]:e}const Ds=2e3;function wo(s,e,t){let i=Math.min(e.line,t.line),n=Math.max(e.line,t.line),r=[];if(e.off>Ds||t.off>Ds||e.col<0||t.col<0){let l=Math.min(e.off,t.off),c=Math.max(e.off,t.off);for(let m=i;m<=n;m++){let C=s.doc.line(m);C.length<=c&&r.push(T.jT.range(C.from+l,C.to+c))}}else{let l=Math.min(e.col,t.col),c=Math.max(e.col,t.col);for(let m=i;m<=n;m++){let C=s.doc.line(m),k=(0,T.Gz)(C.text,l,s.tabSize,!0);if(k<0)r.push(T.jT.cursor(C.to));else{let N=(0,T.Gz)(C.text,c,s.tabSize);r.push(T.jT.range(C.from+k,C.from+N))}}}return r}function vo(s,e){let t=s.coordsAtPos(s.viewport.from);return t?Math.round(Math.abs((t.left-e)/s.defaultCharacterWidth)):-1}function cr(s,e){let t=s.posAtCoords({x:e.clientX,y:e.clientY},!1),i=s.state.doc.lineAt(t),n=t-i.from,r=n>Ds?-1:n==i.length?vo(s,e.clientX):(0,T.IS)(i.text,s.state.tabSize,t-i.from);return{line:i.number,col:r,off:n}}function ko(s,e){let t=cr(s,e),i=s.state.selection;return t?{update(n){if(n.docChanged){let r=n.changes.mapPos(n.startState.doc.line(t.line).from),l=n.state.doc.lineAt(r);t={line:l.number,col:t.col,off:Math.min(t.off,l.length)},i=i.map(n.changes)}},get(n,r,l){let c=cr(s,n);if(!c)return i;let m=wo(s.state,t,c);return m.length?l?T.jT.create(m.concat(i.ranges)):T.jT.create(m):i}}:null}function xo(s){let e=(s==null?void 0:s.eventFilter)||(t=>t.altKey&&t.button==0);return Ht.mouseSelectionStyle.of((t,i)=>e(i)?ko(t,i):null)}const So={Alt:[18,s=>!!s.altKey],Control:[17,s=>!!s.ctrlKey],Shift:[16,s=>!!s.shiftKey],Meta:[91,s=>!!s.metaKey]},Co={style:"cursor: crosshair"};function Ao(s={}){let[e,t]=So[s.key||"Alt"],i=I.fromClass(class{constructor(n){this.view=n,this.isDown=!1}set(n){this.isDown!=n&&(this.isDown=n,this.view.update([]))}},{eventObservers:{keydown(n){this.set(n.keyCode==e||t(n))},keyup(n){(n.keyCode==e||!t(n))&&this.set(!1)},mousemove(n){this.set(t(n))}}});return[i,Ht.contentAttributes.of(n=>{var r;return!((r=n.plugin(i))===null||r===void 0)&&r.isDown?Co:null})]}const jn="-10000px";class fr{constructor(e,t,i,n){this.facet=t,this.createTooltipView=i,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(l=>l);let r=null;this.tooltipViews=this.tooltips.map(l=>r=i(l,r))}update(e,t){var i;let n=e.state.facet(this.facet),r=n.filter(m=>m);if(n===this.input){for(let m of this.tooltipViews)m.update&&m.update(e);return!1}let l=[],c=t?[]:null;for(let m=0;m<r.length;m++){let C=r[m],k=-1;if(C){for(let N=0;N<this.tooltips.length;N++){let z=this.tooltips[N];z&&z.create==C.create&&(k=N)}if(k<0)l[m]=this.createTooltipView(C,m?l[m-1]:null),c&&(c[m]=!!C.above);else{let N=l[m]=this.tooltipViews[k];c&&(c[m]=t[k]),N.update&&N.update(e)}}}for(let m of this.tooltipViews)l.indexOf(m)<0&&(this.removeTooltipView(m),(i=m.destroy)===null||i===void 0||i.call(m));return t&&(c.forEach((m,C)=>t[C]=m),t.length=c.length),this.input=n,this.tooltips=r,this.tooltipViews=l,!0}}function To(s={}){return ss.of(s)}function Mo(s){let e=s.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const ss=T.r$.define({combine:s=>{var e,t,i;return{position:De.ios?"absolute":((e=s.find(n=>n.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=s.find(n=>n.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=s.find(n=>n.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Mo}}}),ur=new WeakMap,rs=I.fromClass(class{constructor(s){this.view=s,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=s.state.facet(ss);this.position=e.position,this.parent=e.parent,this.classes=s.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 fr(s,Os,(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(),s.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 s of this.manager.tooltipViews)this.intersectionObserver.observe(s.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(s){s.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(s,this.above);e&&this.observeIntersection();let t=e||s.geometryChanged,i=s.state.facet(ss);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let n of this.manager.tooltipViews)n.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 n of this.manager.tooltipViews)this.container.appendChild(n.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(s,e){let t=s.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),s.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",t.dom.appendChild(n)}return t.dom.style.position=this.position,t.dom.style.top=jn,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 s,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(s=i.destroy)===null||s===void 0||s.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 s=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(De.gecko)t=r.offsetParent!=this.container.ownerDocument.body;else if(r.style.top==jn&&r.style.left=="0px"){let l=r.getBoundingClientRect();t=Math.abs(l.top+1e4)>1||Math.abs(l.left)>1}}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(s=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:s,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),n=li(this.view);return{visible:{left:i.left+n.left,top:i.top+n.top,right:i.right-n.right,bottom:i.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,l)=>{let c=this.manager.tooltipViews[l];return c.getCoords?c.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(ss).tooltipSpace(this.view),scaleX:s,scaleY:e,makeAbsolute:t}}writeMeasure(s){var e;if(s.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let c of this.manager.tooltipViews)c.dom.style.position="absolute"}let{visible:t,space:i,scaleX:n,scaleY:r}=s,l=[];for(let c=0;c<this.manager.tooltips.length;c++){let m=this.manager.tooltips[c],C=this.manager.tooltipViews[c],{dom:k}=C,N=s.pos[c],z=s.size[c];if(!N||m.clip!==!1&&(N.bottom<=Math.max(t.top,i.top)||N.top>=Math.min(t.bottom,i.bottom)||N.right<Math.max(t.left,i.left)-.1||N.left>Math.min(t.right,i.right)+.1)){k.style.top=jn;continue}let se=m.arrow?C.dom.querySelector(".cm-tooltip-arrow"):null,he=se?7:0,we=z.right-z.left,ke=(e=ur.get(C))!==null&&e!==void 0?e:z.bottom-z.top,xe=C.offset||Oo,Qe=this.view.textDirection==Te.LTR,pt=z.width>i.right-i.left?Qe?i.left:i.right-z.width:Qe?Math.max(i.left,Math.min(N.left-(se?14:0)+xe.x,i.right-we)):Math.min(Math.max(i.left,N.left-we+(se?14:0)-xe.x),i.right-we),at=this.above[c];!m.strictSide&&(at?N.top-ke-he-xe.y<i.top:N.bottom+ke+he+xe.y>i.bottom)&&at==i.bottom-N.bottom>N.top-i.top&&(at=this.above[c]=!at);let mt=(at?N.top-i.top:i.bottom-N.bottom)-he;if(mt<ke&&C.resize!==!1){if(mt<this.view.defaultLineHeight){k.style.top=jn;continue}ur.set(C,ke),k.style.height=(ke=mt)/r+"px"}else k.style.height&&(k.style.height="");let gt=at?N.top-ke-he-xe.y:N.bottom+he+xe.y,Ci=pt+we;if(C.overlap!==!0)for(let ji of l)ji.left<Ci&&ji.right>pt&&ji.top<gt+ke&&ji.bottom>gt&&(gt=at?ji.top-ke-2-he:ji.bottom+he+2);if(this.position=="absolute"?(k.style.top=(gt-s.parent.top)/r+"px",dr(k,(pt-s.parent.left)/n)):(k.style.top=gt/r+"px",dr(k,pt/n)),se){let ji=N.left+(Qe?xe.x:-xe.x)-(pt+14-7);se.style.left=ji/n+"px"}C.overlap!==!0&&l.push({left:pt,top:gt,right:Ci,bottom:gt+ke}),k.classList.toggle("cm-tooltip-above",at),k.classList.toggle("cm-tooltip-below",!at),C.positioned&&C.positioned(s.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 s of this.manager.tooltipViews)s.dom.style.top=jn}},{eventObservers:{scroll(){this.maybeMeasure()}}});function dr(s,e){let t=parseInt(s.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(s.style.left=e+"px")}const Do=Ht.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"}}}),Oo={x:0,y:0},Os=T.r$.define({enables:[rs,Do]}),_n=T.r$.define({combine:s=>s.reduce((e,t)=>e.concat(t),[])});class os{static create(e){return new os(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new fr(e,_n,(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 n=i[e];if(n!==void 0){if(t===void 0)t=n;else if(t!==n)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 Po=Os.compute([_n],s=>{let e=s.facet(_n);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:os.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Eo{constructor(e,t,i,n,r){this.view=e,this.source=t,this.field=i,this.setHover=n,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.nearest(t.target);if(!i)return;let n,r=1;if(i instanceof pe)n=i.posAtStart;else{if(n=e.posAtCoords(t),n==null)return;let c=e.coordsAtPos(n);if(!c||t.y<c.top||t.y>c.bottom||t.x<c.left-e.defaultCharacterWidth||t.x>c.right+e.defaultCharacterWidth)return;let m=e.bidiSpans(e.state.doc.lineAt(n)).find(k=>k.from<=n&&k.to>=n),C=m&&m.dir==Te.RTL?-1:1;r=t.x<c.left?-C:C}let l=this.source(e,n,r);if(l!=null&&l.then){let c=this.pending={pos:n};l.then(m=>{this.pending==c&&(this.pending=null,m&&!(Array.isArray(m)&&!m.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(m)?m:[m])}))},m=>P(e.state,m,"hover tooltip"))}else l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])})}get tooltip(){let e=this.view.plugin(rs),t=e?e.manager.tooltips.findIndex(i=>i.create==os.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:n,tooltip:r}=this;if(n.length&&r&&!Bo(r.dom,e)||this.pending){let{pos:l}=n[0]||this.pending,c=(i=(t=n[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:l;(l==c?this.view.posAtCoords(this.lastMove)!=l:!Lo(this.view,l,c,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){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),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const ls=4;function Bo(s,e){let{left:t,right:i,top:n,bottom:r}=s.getBoundingClientRect(),l;if(l=s.querySelector(".cm-tooltip-arrow")){let c=l.getBoundingClientRect();n=Math.min(c.top,n),r=Math.max(c.bottom,r)}return e.clientX>=t-ls&&e.clientX<=i+ls&&e.clientY>=n-ls&&e.clientY<=r+ls}function Lo(s,e,t,i,n,r){let l=s.scrollDOM.getBoundingClientRect(),c=s.documentTop+s.documentPadding.top+s.contentHeight;if(l.left>i||l.right<i||l.top>n||Math.min(l.bottom,c)<n)return!1;let m=s.posAtCoords({x:i,y:n},!1);return m>=e&&m<=t}function Ro(s,e={}){let t=T.Py.define(),i=T.QQ.define({create(){return[]},update(n,r){if(n.length&&(e.hideOnChange&&(r.docChanged||r.selection)?n=[]:e.hideOn&&(n=n.filter(l=>!e.hideOn(r,l))),r.docChanged)){let l=[];for(let c of n){let m=r.changes.mapPos(c.pos,-1,T.gc.TrackDel);if(m!=null){let C=Object.assign(Object.create(null),c);C.pos=m,C.end!=null&&(C.end=r.changes.mapPos(C.end)),l.push(C)}}n=l}for(let l of r.effects)l.is(t)&&(n=l.value),l.is(No)&&(n=[]);return n},provide:n=>_n.from(n)});return{active:i,extension:[i,I.define(n=>new Eo(n,s,i,t,e.hoverTime||300)),Po]}}function Io(s,e){let t=s.plugin(rs);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}function sl(s){return s.facet(_n).some(e=>e)}const No=T.Py.define(),rl=null;function ol(s){let e=s.plugin(rs);e&&e.maybeMeasure()}const Ps=T.r$.define({combine(s){let e,t;for(let i of s)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function ll(s){return s?[Ps.of(s)]:[]}function pr(s,e){let t=s.plugin(mr),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const mr=I.fromClass(class{constructor(s){this.input=s.state.facet(hs),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(s));let e=s.state.facet(Ps);this.top=new as(s,!0,e.topContainer),this.bottom=new as(s,!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(s){let e=s.state.facet(Ps);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new as(s.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new as(s.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=s.state.facet(hs);if(t!=this.input){let i=t.filter(m=>m),n=[],r=[],l=[],c=[];for(let m of i){let C=this.specs.indexOf(m),k;C<0?(k=m(s.view),c.push(k)):(k=this.panels[C],k.update&&k.update(s)),n.push(k),(k.top?r:l).push(k)}this.specs=i,this.panels=n,this.top.sync(r),this.bottom.sync(l);for(let m of c)m.dom.classList.add("cm-panel"),m.mount&&m.mount()}else for(let i of this.panels)i.update&&i.update(s)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:s=>Ht.scrollMargins.of(e=>{let t=e.plugin(s);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class as{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",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=gr(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=gr(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 gr(s){let e=s.nextSibling;return s.remove(),e}const hs=T.r$.define({enables:mr});function al(s,e){let t,i=new Promise(l=>t=l),n=l=>Fo(l,e,t);s.state.field(cs,!1)?s.dispatch({effects:yr.of(n)}):s.dispatch({effects:StateEffect.appendConfig.of(cs.init(()=>[n]))});let r=br.of(n);return{close:r,result:i.then(l=>((s.win.queueMicrotask||(m=>s.win.setTimeout(m,10)))(()=>{s.state.field(cs).indexOf(n)>-1&&s.dispatch({effects:r})}),l))}}function hl(s,e){let t=s.state.field(cs,!1)||[];for(let i of t){let n=pr(s,i);if(n&&n.dom.classList.contains(e))return n}return null}const cs=T.QQ.define({create(){return[]},update(s,e){for(let t of e.effects)t.is(yr)?s=[t.value].concat(s):t.is(br)&&(s=s.filter(i=>i!=t.value));return s},provide:s=>hs.computeN([s],e=>e.field(s))}),yr=T.Py.define(),br=T.Py.define();function Fo(s,e,t){let i=e.content?e.content(s,()=>l(null)):null;if(!i){if(i=elt("form"),e.input){let c=elt("input",e.input);/^(text|password|number|email|tel|url)$/.test(c.type)&&c.classList.add("cm-textfield"),c.name||(c.name="input"),i.appendChild(elt("label",(e.label||"")+": ",c))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(elt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let n=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let c=0;c<n.length;c++){let m=n[c];m.addEventListener("keydown",C=>{C.keyCode==27?(C.preventDefault(),l(null)):C.keyCode==13&&(C.preventDefault(),l(m))}),m.addEventListener("submit",C=>{C.preventDefault(),l(m)})}let r=elt("div",i,elt("button",{onclick:()=>l(null),"aria-label":s.state.phrase("close"),class:"cm-dialog-close",type:"button"},["\xD7"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function l(c){r.contains(r.ownerDocument.activeElement)&&s.focus(),t(c)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let c;typeof e.focus=="string"?c=i.querySelector(e.focus):c=i.querySelector("input")||i.querySelector("button"),c&&"select"in c?c.select():c&&"focus"in c&&c.focus()}}}}class bn extends T.uU{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}bn.prototype.elementClass="",bn.prototype.toDOM=void 0,bn.prototype.mapMode=T.gc.TrackBefore,bn.prototype.startSide=bn.prototype.endSide=-1,bn.prototype.point=!0;const fs=T.r$.define(),Wo=T.r$.define(),Vo={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>T.Xs.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Jn=T.r$.define();function Ho(s){return[wr(),Jn.of({...Vo,...s})]}const Es=T.r$.define({combine:s=>s.some(e=>e)});function wr(s){let e=[$o];return s&&s.fixed===!1&&e.push(Es.of(!0)),e}const $o=I.fromClass(class{constructor(s){this.view=s,this.domAfter=null,this.prevViewport=s.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=s.state.facet(Jn).map(e=>new kr(s,e)),this.fixed=!s.state.facet(Es);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),s.scrollDOM.insertBefore(this.dom,s.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(s){if(this.updateGutters(s)){let e=this.prevViewport,t=s.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(s.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(Es)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=s.view.viewport}syncGutters(s){let e=this.dom.nextSibling;s&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=T.Xs.iter(this.view.state.facet(fs),this.view.viewport.from),i=[],n=this.gutters.map(r=>new zo(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let l=!0;for(let c of r.type)if(c.type==lt.Text&&l){Bs(t,i,c.from);for(let m of n)m.line(this.view,c,i);l=!1}else if(c.widget)for(let m of n)m.widget(this.view,c)}else if(r.type==lt.Text){Bs(t,i,r.from);for(let l of n)l.line(this.view,r,i)}else if(r.widget)for(let l of n)l.widget(this.view,r);for(let r of n)r.finish();s&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(s){let e=s.startState.facet(Jn),t=s.state.facet(Jn),i=s.docChanged||s.heightChanged||s.viewportChanged||!T.Xs.eq(s.startState.facet(fs),s.state.facet(fs),s.view.viewport.from,s.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(s)&&(i=!0);else{i=!0;let n=[];for(let r of t){let l=e.indexOf(r);l<0?n.push(new kr(this.view,r)):(this.gutters[l].update(s),n.push(this.gutters[l]))}for(let r of this.gutters)r.dom.remove(),n.indexOf(r)<0&&r.destroy();for(let r of n)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=n}return i}destroy(){for(let s of this.gutters)s.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:s=>Ht.scrollMargins.of(e=>{let t=e.plugin(s);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,n=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Te.LTR?{left:i,right:n}:{right:i,left:n}})});function vr(s){return Array.isArray(s)?s:[s]}function Bs(s,e,t){for(;s.value&&s.from<=t;)s.from==t&&e.push(s.value),s.next()}class zo{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=T.Xs.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,r=(t.top-this.height)/e.scaleY,l=t.height/e.scaleY;if(this.i==n.elements.length){let c=new xr(e,l,r,i);n.elements.push(c),n.dom.appendChild(c.dom)}else n.elements[this.i].update(e,l,r,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];Bs(this.cursor,n,t.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let l=this.gutter;n.length==0&&!l.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let r of e.state.facet(Wo)){let l=r(e,t.widget,t);l&&(n||(n=[])).push(l)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class kr{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,n=>{let r=n.target,l;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let m=r.getBoundingClientRect();l=(m.top+m.bottom)/2}else l=n.clientY;let c=e.lineBlockAtHeight(l-e.documentTop);t.domEventHandlers[i](e,c,n)&&n.preventDefault()});this.markers=vr(t.markers(e)),t.initialSpacer&&(this.spacer=new xr(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=vr(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let i=e.view.viewport;return!T.Xs.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 xr{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),jo(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,l=0;;){let c=l,m=r<t.length?t[r++]:null,C=!1;if(m){let k=m.elementClass;k&&(i+=" "+k);for(let N=l;N<this.markers.length;N++)if(this.markers[N].compare(m)){c=N,C=!0;break}}else c=this.markers.length;for(;l<c;){let k=this.markers[l++];if(k.toDOM){k.destroy(n);let N=n.nextSibling;n.remove(),n=N}}if(!m)break;m.toDOM&&(C?n=n.nextSibling:this.dom.insertBefore(m.toDOM(e),n)),C&&l++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function jo(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(!s[t].compare(e[t]))return!1;return!0}const _o=T.r$.define(),Jo=T.r$.define(),Fn=T.r$.define({combine(s){return(0,T.BO)(s,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let n in t){let r=i[n],l=t[n];i[n]=r?(c,m,C)=>r(c,m,C)||l(c,m,C):l}return i}})}});class Ls extends bn{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Rs(s,e){return s.state.facet(Fn).formatNumber(e,s.state)}const qo=Jn.compute([Fn],s=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(_o)},lineMarker(e,t,i){return i.some(n=>n.toDOM)?null:new Ls(Rs(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let n of e.state.facet(Jo)){let r=n(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Fn)!=e.state.facet(Fn),initialSpacer(e){return new Ls(Rs(e,Sr(e.state.doc.lines)))},updateSpacer(e,t){let i=Rs(t.view,Sr(t.view.state.doc.lines));return i==e.number?e:new Ls(i)},domEventHandlers:s.facet(Fn).domEventHandlers,side:"before"}));function Ko(s={}){return[Fn.of(s),wr(),qo]}function Sr(s){let e=9;for(;e<s;)e=e*10+9;return e}const Uo=new class extends bn{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Go=fs.compute(["selection"],s=>{let e=[],t=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.head).from;n>t&&(t=n,e.push(Uo.range(n)))}return T.Xs.of(e)});function Xo(){return Go}function Cr(s){return I.define(e=>({decorations:s.createDeco(e),update(t){this.decorations=s.updateDeco(t,this.decorations)}}),{decorations:e=>e.decorations})}const Yo=rt.mark({class:"cm-highlightTab"}),Qo=rt.mark({class:"cm-highlightSpace"}),Zo=Cr(new As({regexp:/\t| /g,decoration:s=>s[0]==" "?Yo:Qo,boundary:/\S/}));function cl(){return Zo}const el=Cr(new As({regexp:/\s+$/g,decoration:rt.mark({class:"cm-trailingSpace"})}));function fl(){return el}const ul={HeightMap:qi,HeightOracle:Ws,MeasuredHeights:Vs,QueryType:bi,ChangedRange:Di,computeOrder:o,moveVisually:w,clearHeightChangeFlag:gs,getHeightChangeFlag:()=>On}}}]);