-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.min.js
378 lines (335 loc) · 175 KB
/
index.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
var oe=navigator.userAgent,On=navigator.platform,he=/gecko\/\d/i.test(oe),An=/MSIE \d/.test(oe),Dn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(oe),dr=/Edge\/(\d+)/.exec(oe),T=An||Dn||dr,N=T&&(An?document.documentMode||6:+(dr||Dn)[1]),z=!dr&&/WebKit\//.test(oe),Ws=z&&/Qt\/\d+\.\d+/.test(oe),St=!dr&&/Chrome\//.test(oe),re=/Opera\//.test(oe),Lt=/Apple Computer/.test(navigator.vendor),Nn=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(oe),Hn=/PhantomJS/.test(oe),ft=Lt&&(/Mobile\/\w+/.test(oe)||navigator.maxTouchPoints>2),$t=/Android/.test(oe),Qe=ft||$t||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(oe),X=ft||/Mac/.test(On),Wn=/\bCrOS\b/.test(oe),Pn=/win/i.test(On),kt=re&&oe.match(/Version\/(\d*\.\d*)/);kt&&(kt=Number(kt[1]));kt&&kt>=15&&(re=!1,z=!0);var kl=X&&(Ws||re&&(kt==null||kt<12.11)),ki=he||T&&N>=9;function pt(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var ce=function(e,t){let i=e.className,r=pt(t).exec(i);if(r){let l=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(l?r[1]+l:"")}};function Se(e){for(let t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function q(e,t){return Se(e).appendChild(t)}function v(e,t,i,r){let l=document.createElement(e);if(i&&(l.className=i),r&&(l.style.cssText=r),typeof t=="string")l.appendChild(document.createTextNode(t));else if(t)for(let n=0;n<t.length;++n)l.appendChild(t[n]);return l}function Je(e,t,i,r){let l=v(e,t,i,r);return l.setAttribute("role","presentation"),l}var Ge;document.createRange?Ge=function(e,t,i,r){let l=document.createRange();return l.setEnd(r||e,i),l.setStart(e,t),l}:Ge=function(e,t,i){let r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(l){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function Le(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function $(){let e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function ge(e,t){let i=e.className;pt(t).test(i)||(e.className+=(i?" ":"")+t)}function hr(e,t){let i=e.split(" ");for(let r=0;r<i.length;r++)i[r]&&!pt(i[r]).test(t)&&(t+=" "+i[r]);return t}var Mt=function(e){e.select()};ft?Mt=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:T&&(Mt=function(e){try{e.select()}catch(t){}});function Mi(e){let t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function We(e,t,i){t||(t={});for(let r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function Z(e,t,i,r,l){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(let n=r||0,o=l||0;;){let s=e.indexOf(" ",n);if(s<0||s>=t)return o+(t-n);o+=s-n,o+=i-o%i,n=s+1}}var ke=class{constructor(){this.id=null,this.f=null,this.time=0,this.handler=Mi(this.onTimeout,this)}onTimeout(t){t.id=0,t.time<=+new Date?t.f():setTimeout(t.handler,t.time-+new Date)}set(t,i){this.f=i;let r=+new Date+t;(!this.id||r<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,t),this.time=r)}};function _(e,t){for(let i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var cr=50,dt={toString:function(){return"CodeMirror.Pass"}},V={scroll:!1},gr={origin:"*mouse"},Tt={origin:"+move"};function Ti(e,t,i){for(let r=0,l=0;;){let n=e.indexOf(" ",r);n==-1&&(n=e.length);let o=n-r;if(n==e.length||l+o>=t)return r+Math.min(o,t-l);if(l+=n-r,l+=i-l%i,r=n+1,l>=t)return r}}var mr=[""];function Yt(e){for(;mr.length<=e;)mr.push(j(mr)+" ");return mr[e]}function j(e){return e[e.length-1]}function ht(e,t){let i=[];for(let r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function _n(e,t,i){let r=0,l=i(t);for(;r<e.length&&i(e[r])<=l;)r++;e.splice(r,0,t)}function En(){}function yr(e,t){let i;return Object.create?i=Object.create(e):(En.prototype=e,i=new En),t&&We(t,i),i}var Ps=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function xr(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Ps.test(e))}function ji(e,t){return t?t.source.indexOf("\\w")>-1&&xr(e)?!0:t.test(e):xr(e)}function Ml(e){for(let t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var _s=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function br(e){return e.charCodeAt(0)>=768&&_s.test(e)}function Cr(e,t,i){for(;(i<0?t>0:t<e.length)&&br(e.charAt(t));)t+=i;return t}function jt(e,t,i){let r=t>i?-1:1;for(;;){if(t==i)return t;let l=(t+i)/2,n=r<0?Math.ceil(l):Math.floor(l);if(n==t)return e(n)?t:i;e(n)?i=n:t=n+r}}function Fn(e,t,i,r){if(!e)return r(t,i,"ltr",0);let l=!1;for(let n=0;n<e.length;++n){let o=e[n];(o.from<i&&o.to>t||t==i&&o.to==t)&&(r(Math.max(o.from,t),Math.min(o.to,i),o.level==1?"rtl":"ltr",n),l=!0)}l||r(t,i,"ltr")}var qt=null;function Ve(e,t,i){let r;qt=null;for(let l=0;l<e.length;++l){let n=e[l];if(n.from<t&&n.to>t)return l;n.to==t&&(n.from!=n.to&&i=="before"?r=l:qt=l),n.from==t&&(n.from!=n.to&&i!="before"?r=l:qt=l)}return r??qt}var Es=function(){let e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(u){return u<=247?e.charAt(u):1424<=u&&u<=1524?"R":1536<=u&&u<=1785?t.charAt(u-1536):1774<=u&&u<=2220?"r":8192<=u&&u<=8203?"w":u==8204?"b":"L"}let r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,l=/[stwN]/,n=/[LRr]/,o=/[Lb1n]/,s=/[1n]/;function a(u,f,p){this.level=u,this.from=f,this.to=p}return function(u,f){let p=f=="ltr"?"L":"R";if(u.length==0||f=="ltr"&&!r.test(u))return!1;let h=u.length,d=[];for(let g=0;g<h;++g)d.push(i(u.charCodeAt(g)));for(let g=0,b=p;g<h;++g){let m=d[g];m=="m"?d[g]=b:b=m}for(let g=0,b=p;g<h;++g){let m=d[g];m=="1"&&b=="r"?d[g]="n":n.test(m)&&(b=m,m=="r"&&(d[g]="R"))}for(let g=1,b=d[0];g<h-1;++g){let m=d[g];m=="+"&&b=="1"&&d[g+1]=="1"?d[g]="1":m==","&&b==d[g+1]&&(b=="1"||b=="n")&&(d[g]=b),b=m}for(let g=0;g<h;++g){let b=d[g];if(b==",")d[g]="N";else if(b=="%"){let m;for(m=g+1;m<h&&d[m]=="%";++m);let M=g&&d[g-1]=="!"||m<h&&d[m]=="1"?"1":"N";for(let w=g;w<m;++w)d[w]=M;g=m-1}}for(let g=0,b=p;g<h;++g){let m=d[g];b=="L"&&m=="1"?d[g]="L":n.test(m)&&(b=m)}for(let g=0;g<h;++g)if(l.test(d[g])){let b;for(b=g+1;b<h&&l.test(d[b]);++b);let m=(g?d[g-1]:p)=="L",M=(b<h?d[b]:p)=="L",w=m==M?m?"L":"R":p;for(let D=g;D<b;++D)d[D]=w;g=b-1}let c=[],y;for(let g=0;g<h;)if(o.test(d[g])){let b=g;for(++g;g<h&&o.test(d[g]);++g);c.push(new a(0,b,g))}else{let b=g,m=c.length,M=f=="rtl"?1:0;for(++g;g<h&&d[g]!="L";++g);for(let w=b;w<g;)if(s.test(d[w])){b<w&&(c.splice(m,0,new a(1,b,w)),m+=M);let D=w;for(++w;w<g&&s.test(d[w]);++w);c.splice(m,0,new a(2,D,w)),m+=M,b=w}else++w;b<g&&c.splice(m,0,new a(1,b,g))}return f=="ltr"&&(c[0].level==1&&(y=u.match(/^\s+/))&&(c[0].from=y[0].length,c.unshift(new a(0,0,y[0].length))),j(c).level==1&&(y=u.match(/\s+$/))&&(j(c).to-=y[0].length,c.push(new a(0,h-y[0].length,h)))),f=="rtl"?c.reverse():c}}();function le(e,t){let i=e.order;return i==null&&(i=e.order=Es(e.text,t)),i}var In=[],S=function(e,t,i){if(e.addEventListener)e.addEventListener(t,i,!1);else if(e.attachEvent)e.attachEvent("on"+t,i);else{let r=e._handlers||(e._handlers={});r[t]=(r[t]||In).concat(i)}};function vr(e,t){return e._handlers&&e._handlers[t]||In}function Q(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{let r=e._handlers,l=r&&r[t];if(l){let n=_(l,i);n>-1&&(r[t]=l.slice(0,n).concat(l.slice(n+1)))}}}function P(e,t){let i=vr(e,t);if(!i.length)return;let r=Array.prototype.slice.call(arguments,2);for(let l=0;l<i.length;++l)i[l].apply(null,r)}function R(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),P(e,i||t.type,e,t),wr(t)||t.codemirrorIgnore}function Sr(e){let t=e._handlers&&e._handlers.cursorActivity;if(!t)return;let i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]);for(let r=0;r<t.length;++r)_(i,t[r])==-1&&i.push(t[r])}function ee(e,t){return vr(e,t).length>0}function Pe(e){e.prototype.on=function(t,i){S(this,t,i)},e.prototype.off=function(t,i){Q(this,t,i)}}function U(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Tl(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function wr(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function et(e){U(e),Tl(e)}function Zt(e){return e.target||e.srcElement}function jl(e){let t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),X&&e.ctrlKey&&t==1&&(t=3),t}var Rn=function(){if(T&&N<9)return!1;let e=v("div");return"draggable"in e||"dragDrop"in e}(),Ol;function zn(e){if(Ol==null){let i=v("span","\u200B");q(e,v("span",[i,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(Ol=i.offsetWidth<=1&&i.offsetHeight>2&&!(T&&N<8))}let t=Ol?v("span","\u200B"):v("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return t.setAttribute("cm-text",""),t}var Al;function Bn(e){if(Al!=null)return Al;let t=q(e,document.createTextNode("A\u062EA")),i=Ge(t,0,1).getBoundingClientRect(),r=Ge(t,1,2).getBoundingClientRect();return Se(e),!i||i.left==i.right?!1:Al=r.right-i.right<3}var Qt=`
b`.split(/\n/).length!=3?e=>{let t=0,i=[],r=e.length;for(;t<=r;){let l=e.indexOf(`
`,t);l==-1&&(l=e.length);let n=e.slice(t,e.charAt(l-1)=="\r"?l-1:l),o=n.indexOf("\r");o!=-1?(i.push(n.slice(0,o)),t+=o+1):(i.push(n),t=l+1)}return i}:e=>e.split(/\r\n?|\n/),Gn=window.getSelection?e=>{try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:e=>{let t;try{t=e.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Un=(()=>{let e=v("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")})(),Dl=null;function Kn(e){if(Dl!=null)return Dl;let t=q(e,v("span","x")),i=t.getBoundingClientRect(),r=Ge(t,0,1).getBoundingClientRect();return Dl=Math.abs(i.left-r.left)>1}var Lr={},Ot={};function Xn(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Lr[e]=t}function $n(e,t){Ot[e]=t}function Oi(e){if(typeof e=="string"&&Ot.hasOwnProperty(e))e=Ot[e];else if(e&&typeof e.name=="string"&&Ot.hasOwnProperty(e.name)){let t=Ot[e.name];typeof t=="string"&&(t={name:t}),e=yr(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Oi("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Oi("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function Ai(e,t){t=Oi(t);let i=Lr[t.name];if(!i)return Ai(e,"text/plain");let r=i(e,t);if(At.hasOwnProperty(t.name)){let l=At[t.name];for(let n in l)!l.hasOwnProperty(n)||(r.hasOwnProperty(n)&&(r["_"+n]=r[n]),r[n]=l[n])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(let l in t.modeProps)r[l]=t.modeProps[l];return r}var At={};function Yn(e,t){let i=At.hasOwnProperty(e)?At[e]:At[e]={};We(t,i)}function Ue(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);let i={};for(let r in t){let l=t[r];l instanceof Array&&(l=l.concat([])),i[r]=l}return i}function Di(e,t){let i;for(;e.innerMode&&(i=e.innerMode(t),!(!i||i.mode==e));)t=i.state,e=i.mode;return i||{mode:e,state:t}}function kr(e,t,i){return e.startState?e.startState(t,i):!0}var qn=class{constructor(t,i,r){this.pos=this.start=0,this.string=t,this.tabSize=i||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=r}eol(){return this.pos>=this.string.length}sol(){return this.pos==this.lineStart}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let i=this.string.charAt(this.pos),r;if(typeof t=="string"?r=i==t:r=i&&(t.test?t.test(i):t(i)),r)return++this.pos,i}eatWhile(t){let i=this.pos;for(;this.eat(t););return this.pos>i}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let i=this.string.indexOf(t,this.pos);if(i>-1)return this.pos=i,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Z(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Z(this.string,this.lineStart,this.tabSize):0)}indentation(){return Z(this.string,null,this.tabSize)-(this.lineStart?Z(this.string,this.lineStart,this.tabSize):0)}match(t,i,r){if(typeof t=="string"){let l=o=>r?o.toLowerCase():o,n=this.string.substr(this.pos,t.length);if(l(n)==l(t))return i!==!1&&(this.pos+=t.length),!0}else{let l=this.string.slice(this.pos).match(t);return l&&l.index>0?null:(l&&i!==!1&&(this.pos+=l[0].length),l)}}current(){return this.string.slice(this.start,this.pos)}hideFirstChars(t,i){this.lineStart+=t;try{return i()}finally{this.lineStart-=t}}lookAhead(t){let i=this.lineOracle;return i&&i.lookAhead(t)}baseToken(){let t=this.lineOracle;return t&&t.baseToken(this.pos)}},Jt=qn;function C(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");let i=e;for(;!i.lines;)for(let r=0;;++r){let l=i.children[r],n=l.chunkSize();if(t<n){i=l;break}t-=n}return i.lines[t]}function _e(e,t,i){let r=[],l=t.line;return e.iter(t.line,i.line+1,n=>{let o=n.text;l==i.line&&(o=o.slice(0,i.ch)),l==t.line&&(o=o.slice(t.ch)),r.push(o),++l}),r}function Mr(e,t,i){let r=[];return e.iter(t,i,l=>{r.push(l.text)}),r}function se(e,t){let i=t-e.height;if(i)for(let r=e;r;r=r.parent)r.height+=i}function O(e){if(e.parent==null)return null;let t=e.parent,i=_(t.lines,e);for(let r=t.parent;r;t=r,r=r.parent)for(let l=0;r.children[l]!=t;++l)i+=r.children[l].chunkSize();return i+t.first}function Ee(e,t){let i=e.first;e:do{for(let l=0;l<e.children.length;++l){let n=e.children[l],o=n.height;if(t<o){e=n;continue e}t-=o,i+=n.chunkSize()}return i}while(!e.lines);let r=0;for(;r<e.lines.length;++r){let l=e.lines[r],n=l.height;if(t<n)break;t-=n}return i+r}function ct(e,t){return t>=e.first&&t<e.first+e.size}function Vt(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function x(e,t,i=null){if(!(this instanceof x))return new x(e,t,i);this.line=e,this.ch=t,this.sticky=i}function k(e,t){return e.line-t.line||e.ch-t.ch}function Ni(e,t){return e.sticky==t.sticky&&k(e,t)==0}function Hi(e){return x(e.line,e.ch)}function Dt(e,t){return k(e,t)<0?t:e}function Nt(e,t){return k(e,t)<0?e:t}function Tr(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function L(e,t){if(t.line<e.first)return x(e.first,0);let i=e.first+e.size-1;return t.line>i?x(i,C(e,i).text.length):Fs(t,C(e,t.line).text.length)}function Fs(e,t){let i=e.ch;return i==null||i>t?x(e.line,t):i<0?x(e.line,0):e}function Nl(e,t){let i=[];for(let r=0;r<t.length;r++)i[r]=L(e,t[r]);return i}var Wi=class{constructor(t,i){this.state=t,this.lookAhead=i}},Ht=class{constructor(t,i,r,l){this.state=i,this.doc=t,this.line=r,this.maxLookAhead=l||0,this.baseTokens=null,this.baseTokenPos=1}lookAhead(t){let i=this.doc.getLine(this.line+t);return i!=null&&t>this.maxLookAhead&&(this.maxLookAhead=t),i}baseToken(t){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=t;)this.baseTokenPos+=2;let i=this.baseTokens[this.baseTokenPos+1];return{type:i&&i.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-t}}nextLine(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--}static fromSaved(t,i,r){return i instanceof Wi?new Ht(t,Ue(t.mode,i.state),r,i.lookAhead):new Ht(t,Ue(t.mode,i),r)}save(t){let i=t!==!1?Ue(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Wi(i,this.maxLookAhead):i}};function Hl(e,t,i,r){let l=[e.state.modeGen],n={};Zn(e,t.text,e.doc.mode,i,(s,a)=>l.push(s,a),n,r);let o=i.state;for(let s=0;s<e.state.overlays.length;++s){i.baseTokens=l;let a=e.state.overlays[s],u=1,f=0;i.state=!0,Zn(e,t.text,a.mode,i,(p,h)=>{let d=u;for(;f<p;){let c=l[u];c>p&&l.splice(u,1,p,l[u+1],c),u+=2,f=Math.min(p,c)}if(!!h)if(a.opaque)l.splice(d,u-d,p,"overlay "+h),u=d+2;else for(;d<u;d+=2){let c=l[d+1];l[d+1]=(c?c+" ":"")+"overlay "+h}},n),i.state=o,i.baseTokens=null,i.baseTokenPos=1}return{styles:l,classes:n.bgClass||n.textClass?n:null}}function jr(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){let r=gt(e,O(t)),l=t.text.length>e.options.maxHighlightLength&&Ue(e.doc.mode,r.state),n=Hl(e,t,r);l&&(r.state=l),t.stateAfter=r.save(!l),t.styles=n.styles,n.classes?t.styleClasses=n.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function gt(e,t,i){let r=e.doc,l=e.display;if(!r.mode.startState)return new Ht(r,!0,t);let n=Is(e,t,i),o=n>r.first&&C(r,n-1).stateAfter,s=o?Ht.fromSaved(r,o,n):new Ht(r,kr(r.mode),n);return r.iter(n,t,a=>{Or(e,a.text,s);let u=s.line;a.stateAfter=u==t-1||u%5==0||u>=l.viewFrom&&u<l.viewTo?s.save():null,s.nextLine()}),i&&(r.modeFrontier=s.line),s}function Or(e,t,i,r){let l=e.doc.mode,n=new Jt(t,e.options.tabSize,i);for(n.start=n.pos=r||0,t==""&&Qn(l,i.state);!n.eol();)Wl(l,n,i.state),n.start=n.pos}function Qn(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;let i=Di(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function Wl(e,t,i,r){for(let l=0;l<10;l++){r&&(r[0]=Di(e,i).mode);let n=e.token(t,i);if(t.pos>t.start)return n}throw new Error("Mode "+e.name+" failed to advance stream.")}var Pl=class{constructor(t,i,r){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=i||null,this.state=r}};function _l(e,t,i,r){let l=e.doc,n=l.mode,o;t=L(l,t);let s=C(l,t.line),a=gt(e,t.line,i),u=new Jt(s.text,e.options.tabSize,a),f;for(r&&(f=[]);(r||u.pos<t.ch)&&!u.eol();)u.start=u.pos,o=Wl(n,u,a.state),r&&f.push(new Pl(u,o,Ue(l.mode,a.state)));return r?f:new Pl(u,o,a.state)}function Jn(e,t){if(e)for(;;){let i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);let r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function Zn(e,t,i,r,l,n,o){let s=i.flattenSpans;s==null&&(s=e.options.flattenSpans);let a=0,u=null,f=new Jt(t,e.options.tabSize,r),p,h=e.options.addModeClass&&[null];for(t==""&&Jn(Qn(i,r.state),n);!f.eol();){if(f.pos>e.options.maxHighlightLength?(s=!1,o&&Or(e,t,r,f.pos),f.pos=t.length,p=null):p=Jn(Wl(i,f,r.state,h),n),h){let d=h[0].name;d&&(p="m-"+(p?d+" "+p:d))}if(!s||u!=p){for(;a<f.start;)a=Math.min(f.start,a+5e3),l(a,u);u=p}f.start=f.pos}for(;a<f.pos;){let d=Math.min(f.pos,a+5e3);l(d,u),a=d}}function Is(e,t,i){let r,l,n=e.doc,o=i?-1:t-(e.doc.mode.innerMode?1e3:100);for(let s=t;s>o;--s){if(s<=n.first)return n.first;let a=C(n,s-1),u=a.stateAfter;if(u&&(!i||s+(u instanceof Wi?u.lookAhead:0)<=n.modeFrontier))return s;let f=Z(a.text,null,e.options.tabSize);(l==null||r>f)&&(l=s-1,r=f)}return l}function Vn(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;let i=e.first;for(let r=t-1;r>i;r--){let l=C(e,r).stateAfter;if(l&&(!(l instanceof Wi)||r+l.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var El=!1,Me=!1;function eo(){El=!0}function to(){Me=!0}function Pi(e,t,i){this.marker=e,this.from=t,this.to=i}function ei(e,t){if(e)for(let i=0;i<e.length;++i){let r=e[i];if(r.marker==t)return r}}function io(e,t){let i;for(let r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function ro(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Rs(e,t,i){let r;if(e)for(let l=0;l<e.length;++l){let n=e[l],o=n.marker;if(n.from==null||(o.inclusiveLeft?n.from<=t:n.from<t)||n.from==t&&o.type=="bookmark"&&(!i||!n.marker.insertLeft)){let a=n.to==null||(o.inclusiveRight?n.to>=t:n.to>t);(r||(r=[])).push(new Pi(o,n.from,a?null:n.to))}}return r}function zs(e,t,i){let r;if(e)for(let l=0;l<e.length;++l){let n=e[l],o=n.marker;if(n.to==null||(o.inclusiveRight?n.to>=t:n.to>t)||n.from==t&&o.type=="bookmark"&&(!i||n.marker.insertLeft)){let a=n.from==null||(o.inclusiveLeft?n.from<=t:n.from<t);(r||(r=[])).push(new Pi(o,a?null:n.from-t,n.to==null?null:n.to-t))}}return r}function _i(e,t){if(t.full)return null;let i=ct(e,t.from.line)&&C(e,t.from.line).markedSpans,r=ct(e,t.to.line)&&C(e,t.to.line).markedSpans;if(!i&&!r)return null;let l=t.from.ch,n=t.to.ch,o=k(t.from,t.to)==0,s=Rs(i,l,o),a=zs(r,n,o),u=t.text.length==1,f=j(t.text).length+(u?l:0);if(s)for(let h=0;h<s.length;++h){let d=s[h];if(d.to==null){let c=ei(a,d.marker);c?u&&(d.to=c.to==null?null:c.to+f):d.to=l}}if(a)for(let h=0;h<a.length;++h){let d=a[h];d.to!=null&&(d.to+=f),d.from==null?ei(s,d.marker)||(d.from=f,u&&(s||(s=[])).push(d)):(d.from+=f,u&&(s||(s=[])).push(d))}s&&(s=lo(s)),a&&a!=s&&(a=lo(a));let p=[s];if(!u){let h=t.text.length-2,d;if(h>0&&s)for(let c=0;c<s.length;++c)s[c].to==null&&(d||(d=[])).push(new Pi(s[c].marker,null,null));for(let c=0;c<h;++c)p.push(d);p.push(a)}return p}function lo(e){for(let t=0;t<e.length;++t){let i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function no(e,t,i){let r=null;if(e.iter(t.line,i.line+1,n=>{if(n.markedSpans)for(let o=0;o<n.markedSpans.length;++o){let s=n.markedSpans[o].marker;s.readOnly&&(!r||_(r,s)==-1)&&(r||(r=[])).push(s)}}),!r)return null;let l=[{from:t,to:i}];for(let n=0;n<r.length;++n){let o=r[n],s=o.find(0);for(let a=0;a<l.length;++a){let u=l[a];if(k(u.to,s.from)<0||k(u.from,s.to)>0)continue;let f=[a,1],p=k(u.from,s.from),h=k(u.to,s.to);(p<0||!o.inclusiveLeft&&!p)&&f.push({from:u.from,to:s.from}),(h>0||!o.inclusiveRight&&!h)&&f.push({from:s.to,to:u.to}),l.splice.apply(l,f),a+=f.length-3}}return l}function Fl(e){let t=e.markedSpans;if(!!t){for(let i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}}function Il(e,t){if(!!t){for(let i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}}function Ar(e){return e.inclusiveLeft?-1:0}function Dr(e){return e.inclusiveRight?1:0}function Nr(e,t){let i=e.lines.length-t.lines.length;if(i!=0)return i;let r=e.find(),l=t.find(),n=k(r.from,l.from)||Ar(e)-Ar(t);if(n)return-n;let o=k(r.to,l.to)||Dr(e)-Dr(t);return o||t.id-e.id}function oo(e,t){let i=Me&&e.markedSpans,r;if(i)for(let l,n=0;n<i.length;++n)l=i[n],l.marker.collapsed&&(t?l.from:l.to)==null&&(!r||Nr(r,l.marker)<0)&&(r=l.marker);return r}function so(e){return oo(e,!0)}function Hr(e){return oo(e,!1)}function ao(e,t){let i=Me&&e.markedSpans,r;if(i)for(let l=0;l<i.length;++l){let n=i[l];n.marker.collapsed&&(n.from==null||n.from<t)&&(n.to==null||n.to>t)&&(!r||Nr(r,n.marker)<0)&&(r=n.marker)}return r}function Rl(e,t,i,r,l){let n=C(e,t),o=Me&&n.markedSpans;if(o)for(let s=0;s<o.length;++s){let a=o[s];if(!a.marker.collapsed)continue;let u=a.marker.find(0),f=k(u.from,i)||Ar(a.marker)-Ar(l),p=k(u.to,r)||Dr(a.marker)-Dr(l);if(!(f>=0&&p<=0||f<=0&&p>=0)&&(f<=0&&(a.marker.inclusiveRight&&l.inclusiveLeft?k(u.to,i)>=0:k(u.to,i)>0)||f>=0&&(a.marker.inclusiveRight&&l.inclusiveLeft?k(u.from,r)<=0:k(u.from,r)<0)))return!0}}function ne(e){let t;for(;t=so(e);)e=t.find(-1,!0).line;return e}function uo(e){let t;for(;t=Hr(e);)e=t.find(1,!0).line;return e}function fo(e){let t,i;for(;t=Hr(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function Ei(e,t){let i=C(e,t),r=ne(i);return i==r?t:O(r)}function Wr(e,t){if(t>e.lastLine())return t;let i=C(e,t),r;if(!Te(e,i))return t;for(;r=Hr(i);)i=r.find(1,!0).line;return O(i)+1}function Te(e,t){let i=Me&&t.markedSpans;if(i){for(let r,l=0;l<i.length;++l)if(r=i[l],!!r.marker.collapsed){if(r.from==null)return!0;if(!r.marker.widgetNode&&r.from==0&&r.marker.inclusiveLeft&&zl(e,t,r))return!0}}}function zl(e,t,i){if(i.to==null){let r=i.marker.find(1,!0);return zl(e,r.line,ei(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(let r,l=0;l<t.markedSpans.length;++l)if(r=t.markedSpans[l],r.marker.collapsed&&!r.marker.widgetNode&&r.from==i.to&&(r.to==null||r.to!=i.from)&&(r.marker.inclusiveLeft||i.marker.inclusiveRight)&&zl(e,t,r))return!0}function me(e){e=ne(e);let t=0,i=e.parent;for(let r=0;r<i.lines.length;++r){let l=i.lines[r];if(l==e)break;t+=l.height}for(let r=i.parent;r;i=r,r=i.parent)for(let l=0;l<r.children.length;++l){let n=r.children[l];if(n==i)break;t+=n.height}return t}function ti(e){if(e.height==0)return 0;let t=e.text.length,i,r=e;for(;i=so(r);){let l=i.find(0,!0);r=l.from.line,t+=l.from.ch-l.to.ch}for(r=e;i=Hr(r);){let l=i.find(0,!0);t-=r.text.length-l.from.ch,r=l.to.line,t+=r.text.length-l.to.ch}return t}function ii(e){let t=e.display,i=e.doc;t.maxLine=C(i,i.first),t.maxLineLength=ti(t.maxLine),t.maxLineChanged=!0,i.iter(r=>{let l=ti(r);l>t.maxLineLength&&(t.maxLineLength=l,t.maxLine=r)})}var tt=class{constructor(t,i,r){this.text=t,Il(this,i),this.height=r?r(this):1}lineNo(){return O(this)}};Pe(tt);function po(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Fl(e),Il(e,i);let l=r?r(e):1;l!=e.height&&se(e,l)}function ho(e){e.parent=null,Fl(e)}var Bs={},Gs={};function co(e,t){if(!e||/^\s*$/.test(e))return null;let i=t.addModeClass?Gs:Bs;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Pr(e,t){let i=Je("span",null,null,z?"padding-right: .1px":null),r={pre:Je("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(let l=0;l<=(t.rest?t.rest.length:0);l++){let n=l?t.rest[l-1]:t.line,o;r.pos=0,r.addToken=Us,Bn(e.display.measure)&&(o=le(n,e.doc.direction))&&(r.addToken=Ks(r.addToken,o)),r.map=[];let s=t!=e.display.externalMeasured&&O(n);Xs(n,r,jr(e,n,s)),n.styleClasses&&(n.styleClasses.bgClass&&(r.bgClass=hr(n.styleClasses.bgClass,r.bgClass||"")),n.styleClasses.textClass&&(r.textClass=hr(n.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(zn(e.display.measure))),l==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(z){let l=r.content.lastChild;(/\bcm-tab\b/.test(l.className)||l.querySelector&&l.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return P(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=hr(r.pre.className,r.textClass||"")),r}function go(e){let t=v("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Us(e,t,i,r,l,n,o){if(!t)return;let s=e.splitSpaces?$s(t,e.trailingSpace):t,a=e.cm.state.specialChars,u=!1,f;if(!a.test(t))e.col+=t.length,f=document.createTextNode(s),e.map.push(e.pos,e.pos+t.length,f),T&&N<9&&(u=!0),e.pos+=t.length;else{f=document.createDocumentFragment();let p=0;for(;;){a.lastIndex=p;let h=a.exec(t),d=h?h.index-p:t.length-p;if(d){let y=document.createTextNode(s.slice(p,p+d));T&&N<9?f.appendChild(v("span",[y])):f.appendChild(y),e.map.push(e.pos,e.pos+d,y),e.col+=d,e.pos+=d}if(!h)break;p+=d+1;let c;if(h[0]==" "){let y=e.cm.options.tabSize,g=y-e.col%y;c=f.appendChild(v("span",Yt(g),"cm-tab")),c.setAttribute("role","presentation"),c.setAttribute("cm-text"," "),e.col+=g}else h[0]=="\r"||h[0]==`
`?(c=f.appendChild(v("span",h[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),c.setAttribute("cm-text",h[0]),e.col+=1):(c=e.cm.options.specialCharPlaceholder(h[0]),c.setAttribute("cm-text",h[0]),T&&N<9?f.appendChild(v("span",[c])):f.appendChild(c),e.col+=1);e.map.push(e.pos,e.pos+1,c),e.pos++}}if(e.trailingSpace=s.charCodeAt(t.length-1)==32,i||r||l||u||n||o){let p=i||"";r&&(p+=r),l&&(p+=l);let h=v("span",[f],p,n);if(o)for(let d in o)o.hasOwnProperty(d)&&d!="style"&&d!="class"&&h.setAttribute(d,o[d]);return e.content.appendChild(h)}e.content.appendChild(f)}function $s(e,t){if(e.length>1&&!/ /.test(e))return e;let i=t,r="";for(let l=0;l<e.length;l++){let n=e.charAt(l);n==" "&&i&&(l==e.length-1||e.charCodeAt(l+1)==32)&&(n="\xA0"),r+=n,i=n==" "}return r}function Ks(e,t){return(i,r,l,n,o,s,a)=>{l=l?l+" cm-force-border":"cm-force-border";let u=i.pos,f=u+r.length;for(;;){let p;for(let h=0;h<t.length&&(p=t[h],!(p.to>u&&p.from<=u));h++);if(p.to>=f)return e(i,r,l,n,o,s,a);e(i,r.slice(0,p.to-u),l,n,null,s,a),n=null,r=r.slice(p.to-u),u=p.to}}}function mo(e,t,i,r){let l=!r&&i.widgetNode;l&&e.map.push(e.pos,e.pos+t,l),!r&&e.cm.display.input.needsContentAttribute&&(l||(l=e.content.appendChild(document.createElement("span"))),l.setAttribute("cm-marker",i.id)),l&&(e.cm.display.input.setUneditable(l),e.content.appendChild(l)),e.pos+=t,e.trailingSpace=!1}function Xs(e,t,i){let r=e.markedSpans,l=e.text,n=0;if(!r){for(let m=1;m<i.length;m+=2)t.addToken(t,l.slice(n,n=i[m]),co(i[m+1],t.cm.options));return}let o=l.length,s=0,a=1,u="",f,p,h=0,d,c,y,g,b;for(;;){if(h==s){d=c=y=p="",b=null,g=null,h=Infinity;let M=[],w;for(let D=0;D<r.length;++D){let H=r[D],W=H.marker;if(W.type=="bookmark"&&H.from==s&&W.widgetNode)M.push(W);else if(H.from<=s&&(H.to==null||H.to>s||W.collapsed&&H.to==s&&H.from==s)){if(H.to!=null&&H.to!=s&&h>H.to&&(h=H.to,c=""),W.className&&(d+=" "+W.className),W.css&&(p=(p?p+";":"")+W.css),W.startStyle&&H.from==s&&(y+=" "+W.startStyle),W.endStyle&&H.to==h&&(w||(w=[])).push(W.endStyle,H.to),W.title&&((b||(b={})).title=W.title),W.attributes)for(let de in W.attributes)(b||(b={}))[de]=W.attributes[de];W.collapsed&&(!g||Nr(g.marker,W)<0)&&(g=H)}else H.from>s&&h>H.from&&(h=H.from)}if(w)for(let D=0;D<w.length;D+=2)w[D+1]==h&&(c+=" "+w[D]);if(!g||g.from==s)for(let D=0;D<M.length;++D)mo(t,0,M[D]);if(g&&(g.from||0)==s){if(mo(t,(g.to==null?o+1:g.to)-s,g.marker,g.from==null),g.to==null)return;g.to==s&&(g=!1)}}if(s>=o)break;let m=Math.min(o,h);for(;;){if(u){let M=s+u.length;if(!g){let w=M>m?u.slice(0,m-s):u;t.addToken(t,w,f?f+d:d,y,s+w.length==h?c:"",p,b)}if(M>=m){u=u.slice(m-s),s=m;break}s=M,y=""}u=l.slice(n,n=i[a++]),f=co(i[a++],t.cm.options)}}}function Bl(e,t,i){this.line=t,this.rest=fo(t),this.size=this.rest?O(j(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Te(e,t)}function Fi(e,t,i){let r=[],l;for(let n=t;n<i;n=l){let o=new Bl(e.doc,C(e.doc,n),n);l=n+o.size,r.push(o)}return r}var ri=null;function yo(e){ri?ri.ops.push(e):e.ownsGroup=ri={ops:[e],delayedCallbacks:[]}}function Ys(e){let t=e.delayedCallbacks,i=0;do{for(;i<t.length;i++)t[i].call(null);for(let r=0;r<e.ops.length;r++){let l=e.ops[r];if(l.cursorActivityHandlers)for(;l.cursorActivityCalled<l.cursorActivityHandlers.length;)l.cursorActivityHandlers[l.cursorActivityCalled++].call(null,l.cm)}}while(i<t.length)}function xo(e,t){let i=e.ownsGroup;if(!!i)try{Ys(i)}finally{ri=null,t(i)}}var Ii=null;function E(e,t){let i=vr(e,t);if(!i.length)return;let r=Array.prototype.slice.call(arguments,2),l;ri?l=ri.delayedCallbacks:Ii?l=Ii:(l=Ii=[],setTimeout(qs,0));for(let n=0;n<i.length;++n)l.push(()=>i[n].apply(null,r))}function qs(){let e=Ii;Ii=null;for(let t=0;t<e.length;++t)e[t]()}function _r(e,t,i,r){for(let l=0;l<t.changes.length;l++){let n=t.changes[l];n=="text"?Zs(e,t):n=="gutter"?bo(e,t,i,r):n=="class"?Gl(e,t):n=="widget"&&Qs(e,t,r)}t.changes=null}function Ri(e){return e.node==e.text&&(e.node=v("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),T&&N<8&&(e.node.style.zIndex=2)),e.node}function Js(e,t){let i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){let r=Ri(t);t.background=r.insertBefore(v("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function Co(e,t){let i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):Pr(e,t)}function Zs(e,t){let i=t.text.className,r=Co(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,Gl(e,t)):i&&(t.text.className=i)}function Gl(e,t){Js(e,t),t.line.wrapClass?Ri(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");let i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function bo(e,t,i,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){let n=Ri(t);t.gutterBackground=v("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,`left: ${e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth}px; width: ${r.gutterTotalWidth}px`),e.display.input.setUneditable(t.gutterBackground),n.insertBefore(t.gutterBackground,t.text)}let l=t.line.gutterMarkers;if(e.options.lineNumbers||l){let n=Ri(t),o=t.gutter=v("div",null,"CodeMirror-gutter-wrapper",`left: ${e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth}px`);if(o.setAttribute("aria-hidden","true"),e.display.input.setUneditable(o),n.insertBefore(o,t.text),t.line.gutterClass&&(o.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!l||!l["CodeMirror-linenumbers"])&&(t.lineNumber=o.appendChild(v("div",Vt(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt",`left: ${r.gutterLeft["CodeMirror-linenumbers"]}px; width: ${e.display.lineNumInnerWidth}px`))),l)for(let s=0;s<e.display.gutterSpecs.length;++s){let a=e.display.gutterSpecs[s].className,u=l.hasOwnProperty(a)&&l[a];u&&o.appendChild(v("div",[u],"CodeMirror-gutter-elt",`left: ${r.gutterLeft[a]}px; width: ${r.gutterWidth[a]}px`))}}}function Qs(e,t,i){t.alignable&&(t.alignable=null);let r=pt("CodeMirror-linewidget");for(let l=t.node.firstChild,n;l;l=n)n=l.nextSibling,r.test(l.className)&&t.node.removeChild(l);vo(e,t,i)}function wo(e,t,i,r){let l=Co(e,t);return t.text=t.node=l.pre,l.bgClass&&(t.bgClass=l.bgClass),l.textClass&&(t.textClass=l.textClass),Gl(e,t),bo(e,t,i,r),vo(e,t,r),t.node}function vo(e,t,i){if(So(e,t.line,t,i,!0),t.rest)for(let r=0;r<t.rest.length;r++)So(e,t.rest[r],t,i,!1)}function So(e,t,i,r,l){if(!t.widgets)return;let n=Ri(i);for(let o=0,s=t.widgets;o<s.length;++o){let a=s[o],u=v("div",[a.node],"CodeMirror-linewidget"+(a.className?" "+a.className:""));a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),Vs(a,u,i,r),e.display.input.setUneditable(u),l&&a.above?n.insertBefore(u,i.gutter||i.text):n.appendChild(u),E(a,"redraw")}}function Vs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);let l=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(l-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=l+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function mt(e){if(e.height!=null)return e.height;let t=e.doc.cm;if(!t)return 0;if(!Le(document.body,e.node)){let i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),q(t.display.measure,v("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function ye(e,t){for(let i=Zt(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function li(e){return e.lineSpace.offsetTop}function ni(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Ul(e){if(e.cachedPaddingH)return e.cachedPaddingH;let t=q(e.measure,v("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function ae(e){return cr-e.display.nativeBarWidth}function je(e){return e.display.scroller.clientWidth-ae(e)-e.display.barWidth}function oi(e){return e.display.scroller.clientHeight-ae(e)-e.display.barHeight}function ea(e,t,i){let r=e.options.lineWrapping,l=r&&je(e);if(!t.measure.heights||r&&t.measure.width!=l){let n=t.measure.heights=[];if(r){t.measure.width=l;let o=t.text.firstChild.getClientRects();for(let s=0;s<o.length-1;s++){let a=o[s],u=o[s+1];Math.abs(a.bottom-u.bottom)>2&&n.push((a.bottom+u.top)/2-i.top)}}n.push(i.bottom-i.top)}}function Kl(e,t,i){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(let r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(let r=0;r<e.rest.length;r++)if(O(e.rest[r])>i)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function ta(e,t){t=ne(t);let i=O(t),r=e.display.externalMeasured=new Bl(e.doc,t,i);r.lineN=i;let l=r.built=Pr(e,r);return r.text=l.pre,q(e.display.lineMeasure,l.pre),r}function Xl(e,t,i,r){return Fe(e,Wt(e,t),i,r)}function zi(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[it(e,t)];let i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function Wt(e,t){let i=O(t),r=zi(e,i);r&&!r.text?r=null:r&&r.changes&&(_r(e,r,i,Er(e)),e.curOp.forceUpdate=!0),r||(r=ta(e,t));let l=Kl(r,t,i);return{line:t,view:r,rect:null,map:l.map,cache:l.cache,before:l.before,hasHeights:!1}}function Fe(e,t,i,r,l){t.before&&(i=-1);let n=i+(r||""),o;return t.cache.hasOwnProperty(n)?o=t.cache[n]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(ea(e,t.view,t.rect),t.hasHeights=!0),o=ia(e,t,i,r),o.bogus||(t.cache[n]=o)),{left:o.left,right:o.right,top:l?o.rtop:o.top,bottom:l?o.rbottom:o.bottom}}var Lo={left:0,right:0,top:0,bottom:0};function $l(e,t,i){let r,l,n,o,s,a;for(let u=0;u<e.length;u+=3)if(s=e[u],a=e[u+1],t<s?(l=0,n=1,o="left"):t<a?(l=t-s,n=l+1):(u==e.length-3||t==a&&e[u+3]>t)&&(n=a-s,l=n-1,t>=a&&(o="right")),l!=null){if(r=e[u+2],s==a&&i==(r.insertLeft?"left":"right")&&(o=i),i=="left"&&l==0)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[(u-=3)+2],o="left";if(i=="right"&&l==a-s)for(;u<e.length-3&&e[u+3]==e[u+4]&&!e[u+5].insertLeft;)r=e[(u+=3)+2],o="right";break}return{node:r,start:l,end:n,collapse:o,coverStart:s,coverEnd:a}}function ra(e,t){let i=Lo;if(t=="left")for(let r=0;r<e.length&&(i=e[r]).left==i.right;r++);else for(let r=e.length-1;r>=0&&(i=e[r]).left==i.right;r--);return i}function ia(e,t,i,r){let l=$l(t.map,i,r),n=l.node,o=l.start,s=l.end,a=l.collapse,u;if(n.nodeType==3){for(let m=0;m<4;m++){for(;o&&br(t.line.text.charAt(l.coverStart+o));)--o;for(;l.coverStart+s<l.coverEnd&&br(t.line.text.charAt(l.coverStart+s));)++s;if(T&&N<9&&o==0&&s==l.coverEnd-l.coverStart?u=n.parentNode.getBoundingClientRect():u=ra(Ge(n,o,s).getClientRects(),r),u.left||u.right||o==0)break;s=o,o=o-1,a="right"}T&&N<11&&(u=la(e.display.measure,u))}else{o>0&&(a=r="right");let m;e.options.lineWrapping&&(m=n.getClientRects()).length>1?u=m[r=="right"?m.length-1:0]:u=n.getBoundingClientRect()}if(T&&N<9&&!o&&(!u||!u.left&&!u.right)){let m=n.parentNode.getClientRects()[0];m?u={left:m.left,right:m.left+yt(e.display),top:m.top,bottom:m.bottom}:u=Lo}let f=u.top-t.rect.top,p=u.bottom-t.rect.top,h=(f+p)/2,d=t.view.measure.heights,c=0;for(;c<d.length-1&&!(h<d[c]);c++);let y=c?d[c-1]:0,g=d[c],b={left:(a=="right"?u.right:u.left)-t.rect.left,right:(a=="left"?u.left:u.right)-t.rect.left,top:y,bottom:g};return!u.left&&!u.right&&(b.bogus=!0),e.options.singleCursorHeightPerLine||(b.rtop=f,b.rbottom=p),b}function la(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Kn(e))return t;let i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function Yl(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(let t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ql(e){e.display.externalMeasure=null,Se(e.display.lineMeasure);for(let t=0;t<e.display.view.length;t++)Yl(e.display.view[t])}function xt(e){ql(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ko(){return St&&$t?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Mo(){return St&&$t?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function Zl(e){let t=0;if(e.widgets)for(let i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=mt(e.widgets[i]));return t}function Bi(e,t,i,r,l){if(!l){let o=Zl(t);i.top+=o,i.bottom+=o}if(r=="line")return i;r||(r="local");let n=me(t);if(r=="local"?n+=li(e.display):n-=e.display.viewOffset,r=="page"||r=="window"){let o=e.display.lineSpace.getBoundingClientRect();n+=o.top+(r=="window"?0:Mo());let s=o.left+(r=="window"?0:ko());i.left+=s,i.right+=s}return i.top+=n,i.bottom+=n,i}function Ql(e,t,i){if(i=="div")return t;let r=t.left,l=t.top;if(i=="page")r-=ko(),l-=Mo();else if(i=="local"||!i){let o=e.display.sizer.getBoundingClientRect();r+=o.left,l+=o.top}let n=e.display.lineSpace.getBoundingClientRect();return{left:r-n.left,top:l-n.top}}function Gi(e,t,i,r,l){return r||(r=C(e.doc,t.line)),Bi(e,r,Xl(e,r,t.ch,l),i)}function ue(e,t,i,r,l,n){r=r||C(e.doc,t.line),l||(l=Wt(e,r));function o(c,y){let g=Fe(e,l,c,y?"right":"left",n);return y?g.left=g.right:g.right=g.left,Bi(e,r,g,i)}let s=le(r,e.doc.direction),a=t.ch,u=t.sticky;if(a>=r.text.length?(a=r.text.length,u="before"):a<=0&&(a=0,u="after"),!s)return o(u=="before"?a-1:a,u=="before");function f(c,y,g){let b=s[y],m=b.level==1;return o(g?c-1:c,m!=g)}let p=Ve(s,a,u),h=qt,d=f(a,p,u=="before");return h!=null&&(d.other=f(a,h,u!="before")),d}function Jl(e,t){let i=0;t=L(e.doc,t),e.options.lineWrapping||(i=yt(e.display)*t.ch);let r=C(e.doc,t.line),l=me(r)+li(e.display);return{left:i,right:i,top:l,bottom:l+r.height}}function Vl(e,t,i,r,l){let n=x(e,t,i);return n.xRel=l,r&&(n.outside=r),n}function Fr(e,t,i){let r=e.doc;if(i+=e.display.viewOffset,i<0)return Vl(r.first,0,null,-1,-1);let l=Ee(r,i),n=r.first+r.size-1;if(l>n)return Vl(r.first+r.size-1,C(r,n).text.length,null,1,1);t<0&&(t=0);let o=C(r,l);for(;;){let s=na(e,o,l,t,i),a=ao(o,s.ch+(s.xRel>0||s.outside>0?1:0));if(!a)return s;let u=a.find(1);if(u.line==l)return u;o=C(r,l=u.line)}}function To(e,t,i,r){r-=Zl(t);let l=t.text.length,n=jt(o=>Fe(e,i,o-1).bottom<=r,l,0);return l=jt(o=>Fe(e,i,o).top>r,n,l),{begin:n,end:l}}function Ir(e,t,i,r){i||(i=Wt(e,t));let l=Bi(e,t,Fe(e,i,r),"line").top;return To(e,t,i,l)}function en(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function na(e,t,i,r,l){l-=me(t);let n=Wt(e,t),o=Zl(t),s=0,a=t.text.length,u=!0,f=le(t,e.doc.direction);if(f){let b=(e.options.lineWrapping?sa:oa)(e,t,i,n,f,r,l);u=b.level!=1,s=u?b.from:b.to-1,a=u?b.to:b.from-1}let p=null,h=null,d=jt(b=>{let m=Fe(e,n,b);return m.top+=o,m.bottom+=o,en(m,r,l,!1)?(m.top<=l&&m.left<=r&&(p=b,h=m),!0):!1},s,a),c,y,g=!1;if(h){let b=r-h.left<h.right-r,m=b==u;d=p+(m?0:1),y=m?"after":"before",c=b?h.left:h.right}else{!u&&(d==a||d==s)&&d++,y=d==0?"after":d==t.text.length?"before":Fe(e,n,d-(u?1:0)).bottom+o<=l==u?"after":"before";let b=ue(e,x(i,d,y),"line",t,n);c=b.left,g=l<b.top?-1:l>=b.bottom?1:0}return d=Cr(t.text,d,1),Vl(i,d,y,g,r-c)}function oa(e,t,i,r,l,n,o){let s=jt(u=>{let f=l[u],p=f.level!=1;return en(ue(e,x(i,p?f.to:f.from,p?"before":"after"),"line",t,r),n,o,!0)},0,l.length-1),a=l[s];if(s>0){let u=a.level!=1,f=ue(e,x(i,u?a.from:a.to,u?"after":"before"),"line",t,r);en(f,n,o,!0)&&f.top>o&&(a=l[s-1])}return a}function sa(e,t,i,r,l,n,o){let{begin:s,end:a}=To(e,t,r,o);/\s/.test(t.text.charAt(a-1))&&a--;let u=null,f=null;for(let p=0;p<l.length;p++){let h=l[p];if(h.from>=a||h.to<=s)continue;let d=h.level!=1,c=Fe(e,r,d?Math.min(a,h.to)-1:Math.max(s,h.from)).right,y=c<n?n-c+1e9:c-n;(!u||f>y)&&(u=h,f=y)}return u||(u=l[l.length-1]),u.from<s&&(u={from:s,to:u.to,level:u.level}),u.to>a&&(u={from:u.from,to:a,level:u.level}),u}var Pt;function rt(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Pt==null){Pt=v("pre",null,"CodeMirror-line-like");for(let i=0;i<49;++i)Pt.appendChild(document.createTextNode("x")),Pt.appendChild(v("br"));Pt.appendChild(document.createTextNode("x"))}q(e.measure,Pt);let t=Pt.offsetHeight/50;return t>3&&(e.cachedTextHeight=t),Se(e.measure),t||1}function yt(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;let t=v("span","xxxxxxxxxx"),i=v("pre",[t],"CodeMirror-line-like");q(e.measure,i);let r=t.getBoundingClientRect(),l=(r.right-r.left)/10;return l>2&&(e.cachedCharWidth=l),l||10}function Er(e){let t=e.display,i={},r={},l=t.gutters.clientLeft;for(let n=t.gutters.firstChild,o=0;n;n=n.nextSibling,++o){let s=e.display.gutterSpecs[o].className;i[s]=n.offsetLeft+n.clientLeft+l,r[s]=n.clientWidth}return{fixedPos:Ui(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Ui(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function tn(e){let t=rt(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/yt(e.display)-3);return l=>{if(Te(e.doc,l))return 0;let n=0;if(l.widgets)for(let o=0;o<l.widgets.length;o++)l.widgets[o].height&&(n+=l.widgets[o].height);return i?n+(Math.ceil(l.text.length/r)||1)*t:n+t}}function si(e){let t=e.doc,i=tn(e);t.iter(r=>{let l=i(r);l!=r.height&&se(r,l)})}function Ie(e,t,i,r){let l=e.display;if(!i&&Zt(t).getAttribute("cm-not-content")=="true")return null;let n,o,s=l.lineSpace.getBoundingClientRect();try{n=t.clientX-s.left,o=t.clientY-s.top}catch(f){return null}let a=Fr(e,n,o),u;if(r&&a.xRel>0&&(u=C(e.doc,a.line).text).length==a.ch){let f=Z(u,u.length,e.options.tabSize)-u.length;a=x(a.line,Math.max(0,Math.round((n-Ul(e.display).left)/yt(e.display))-f))}return a}function it(e,t){if(t>=e.display.viewTo||(t-=e.display.viewFrom,t<0))return null;let i=e.display.view;for(let r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function G(e,t,i,r){t==null&&(t=e.doc.first),i==null&&(i=e.doc.first+e.doc.size),r||(r=0);let l=e.display;if(r&&i<l.viewTo&&(l.updateLineNumbers==null||l.updateLineNumbers>t)&&(l.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=l.viewTo)Me&&Ei(e.doc,t)<l.viewTo&<(e);else if(i<=l.viewFrom)Me&&Wr(e.doc,i+r)>l.viewFrom?lt(e):(l.viewFrom+=r,l.viewTo+=r);else if(t<=l.viewFrom&&i>=l.viewTo)lt(e);else if(t<=l.viewFrom){let o=Rr(e,i,i+r,1);o?(l.view=l.view.slice(o.index),l.viewFrom=o.lineN,l.viewTo+=r):lt(e)}else if(i>=l.viewTo){let o=Rr(e,t,t,-1);o?(l.view=l.view.slice(0,o.index),l.viewTo=o.lineN):lt(e)}else{let o=Rr(e,t,t,-1),s=Rr(e,i,i+r,1);o&&s?(l.view=l.view.slice(0,o.index).concat(Fi(e,o.lineN,s.lineN)).concat(l.view.slice(s.index)),l.viewTo+=r):lt(e)}let n=l.externalMeasured;n&&(i<n.lineN?n.lineN+=r:t<n.lineN+n.size&&(l.externalMeasured=null))}function Ce(e,t,i){e.curOp.viewChanged=!0;let r=e.display,l=e.display.externalMeasured;if(l&&t>=l.lineN&&t<l.lineN+l.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;let n=r.view[it(e,t)];if(n.node==null)return;let o=n.changes||(n.changes=[]);_(o,i)==-1&&o.push(i)}function lt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Rr(e,t,i,r){let l=it(e,t),n,o=e.display.view;if(!Me||i==e.doc.first+e.doc.size)return{index:l,lineN:i};let s=e.display.viewFrom;for(let a=0;a<l;a++)s+=o[a].size;if(s!=t){if(r>0){if(l==o.length-1)return null;n=s+o[l].size-t,l++}else n=s-t;t+=n,i+=n}for(;Ei(e.doc,i)!=i;){if(l==(r<0?0:o.length-1))return null;i+=r*o[l-(r<0?1:0)].size,l+=r}return{index:l,lineN:i}}function jo(e,t,i){let r=e.display;r.view.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=Fi(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=Fi(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(it(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(Fi(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,it(e,i)))),r.viewTo=i}function rn(e){let t=e.display.view,i=0;for(let r=0;r<t.length;r++){let l=t[r];!l.hidden&&(!l.node||l.changes)&&++i}return i}function _t(e){e.display.input.showSelection(e.display.input.prepareSelection())}function zr(e,t=!0){let i=e.doc,r={},l=r.cursors=document.createDocumentFragment(),n=r.selection=document.createDocumentFragment();for(let o=0;o<i.sel.ranges.length;o++){if(!t&&o==i.sel.primIndex)continue;let s=i.sel.ranges[o];if(s.from().line>=e.display.viewTo||s.to().line<e.display.viewFrom)continue;let a=s.empty();(a||e.options.showCursorWhenSelecting)&&ln(e,s.head,l),a||aa(e,s,n)}return r}function ln(e,t,i){let r=ue(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),l=i.appendChild(v("div","\xA0","CodeMirror-cursor"));if(l.style.left=r.left+"px",l.style.top=r.top+"px",l.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){let n=i.appendChild(v("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));n.style.display="",n.style.left=r.other.left+"px",n.style.top=r.other.top+"px",n.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Br(e,t){return e.top-t.top||e.left-t.left}function aa(e,t,i){let r=e.display,l=e.doc,n=document.createDocumentFragment(),o=Ul(e.display),s=o.left,a=Math.max(r.sizerWidth,je(e)-r.sizer.offsetLeft)-o.right,u=l.direction=="ltr";function f(c,y,g,b){y<0&&(y=0),y=Math.round(y),b=Math.round(b),n.appendChild(v("div",null,"CodeMirror-selected",`position: absolute; left: ${c}px;
top: ${y}px; width: ${g??a-c}px;
height: ${b-y}px`))}function p(c,y,g){let b=C(l,c),m=b.text.length,M,w;function D(de,ie){return Gi(e,x(c,de),"div",b,ie)}function H(de,ie,ze){let Be=Ir(e,b,null,de),xe=ie=="ltr"==(ze=="after")?"left":"right",J=ze=="after"?Be.begin:Be.end-(/\s/.test(b.text.charAt(Be.end-1))?2:1);return D(J,xe)[xe]}let W=le(b,l.direction);return Fn(W,y||0,g??m,(de,ie,ze,Be)=>{let xe=ze=="ltr",J=D(de,xe?"left":"right"),be=D(ie-1,xe?"right":"left"),fr=y==null&&de==0,pr=g==null&&ie==m,Sl=Be==0,Ll=!W||Be==W.length-1;if(be.top-J.top<=3){let Xt=(u?fr:pr)&&Sl,Si=(u?pr:fr)&&Ll,wt=Xt?s:(xe?J:be).left,Li=Si?a:(xe?be:J).right;f(wt,J.top,Li-wt,J.bottom)}else{let Xt,Si,wt,Li;xe?(Xt=u&&fr&&Sl?s:J.left,Si=u?a:H(de,ze,"before"),wt=u?s:H(ie,ze,"after"),Li=u&&pr&&Ll?a:be.right):(Xt=u?H(de,ze,"before"):s,Si=!u&&fr&&Sl?a:J.right,wt=!u&&pr&&Ll?s:be.left,Li=u?H(ie,ze,"after"):a),f(Xt,J.top,Si-Xt,J.bottom),J.bottom<be.top&&f(s,J.bottom,null,be.top),f(wt,be.top,Li-wt,be.bottom)}(!M||Br(J,M)<0)&&(M=J),Br(be,M)<0&&(M=be),(!w||Br(J,w)<0)&&(w=J),Br(be,w)<0&&(w=be)}),{start:M,end:w}}let h=t.from(),d=t.to();if(h.line==d.line)p(h.line,h.ch,d.ch);else{let c=C(l,h.line),y=C(l,d.line),g=ne(c)==ne(y),b=p(h.line,h.ch,g?c.text.length+1:null).end,m=p(d.line,g?0:null,d.ch).start;g&&(b.top<m.top-2?(f(b.right,b.top,null,b.bottom),f(s,m.top,m.left,m.bottom)):f(b.right,b.top,m.left-b.right,b.bottom)),b.bottom<m.top&&f(s,b.bottom,null,m.top)}i.appendChild(n)}function ai(e){if(!e.state.focused)return;let t=e.display;clearInterval(t.blinker);let i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(()=>{e.hasFocus()||Ke(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function Ur(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||Gr(e))}function Kr(e){e.state.delayingBlurEvent=!0,setTimeout(()=>{e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&Ke(e))},100)}function Gr(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),e.options.readOnly!="nocursor"&&(e.state.focused||(P(e,"focus",e,t),e.state.focused=!0,ge(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),z&&setTimeout(()=>e.display.input.reset(!0),20)),e.display.input.receivedFocus()),ai(e))}function Ke(e,t){e.state.delayingBlurEvent||(e.state.focused&&(P(e,"blur",e,t),e.state.focused=!1,ce(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(()=>{e.state.focused||(e.display.shift=!1)},150))}function Et(e){let t=e.display,i=t.lineDiv.offsetTop;for(let r=0;r<t.view.length;r++){let l=t.view[r],n=e.options.lineWrapping,o,s=0;if(l.hidden)continue;if(T&&N<8){let u=l.node.offsetTop+l.node.offsetHeight;o=u-i,i=u}else{let u=l.node.getBoundingClientRect();o=u.bottom-u.top,!n&&l.text.firstChild&&(s=l.text.firstChild.getBoundingClientRect().right-u.left-1)}let a=l.line.height-o;if((a>.005||a<-.005)&&(se(l.line,o),Oo(l.line),l.rest))for(let u=0;u<l.rest.length;u++)Oo(l.rest[u]);if(s>e.display.sizerWidth){let u=Math.ceil(s/yt(e.display));u>e.display.maxLineLength&&(e.display.maxLineLength=u,e.display.maxLine=l.line,e.display.maxLineChanged=!0)}}}function Oo(e){if(e.widgets)for(let t=0;t<e.widgets.length;++t){let i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function ui(e,t,i){let r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-li(e));let l=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,n=Ee(t,r),o=Ee(t,l);if(i&&i.ensure){let s=i.ensure.from.line,a=i.ensure.to.line;s<n?(n=s,o=Ee(t,me(C(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=o&&(n=Ee(t,me(C(t,a))-e.wrapper.clientHeight),o=a)}return{from:n,to:Math.max(o,n+1)}}function Ao(e,t){if(R(e,"scrollCursorIntoView"))return;let i=e.display,r=i.sizer.getBoundingClientRect(),l=null;if(t.top+r.top<0?l=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(l=!1),l!=null&&!Hn){let n=v("div","\u200B",null,`position: absolute;
top: ${t.top-i.viewOffset-li(e.display)}px;
height: ${t.bottom-t.top+ae(e)+i.barHeight}px;
left: ${t.left}px; width: ${Math.max(2,t.right-t.left)}px;`);e.display.lineSpace.appendChild(n),n.scrollIntoView(l),e.display.lineSpace.removeChild(n)}}function Do(e,t,i,r){r==null&&(r=0);let l;!e.options.lineWrapping&&t==i&&(t=t.ch?x(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?x(t.line,t.ch+1,"before"):t);for(let n=0;n<5;n++){let o=!1,s=ue(e,t),a=!i||i==t?s:ue(e,i);l={left:Math.min(s.left,a.left),top:Math.min(s.top,a.top)-r,right:Math.max(s.left,a.left),bottom:Math.max(s.bottom,a.bottom)+r};let u=nn(e,l),f=e.doc.scrollTop,p=e.doc.scrollLeft;if(u.scrollTop!=null&&(bt(e,u.scrollTop),Math.abs(e.doc.scrollTop-f)>1&&(o=!0)),u.scrollLeft!=null&&(Re(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-p)>1&&(o=!0)),!o)break}return l}function No(e,t){let i=nn(e,t);i.scrollTop!=null&&bt(e,i.scrollTop),i.scrollLeft!=null&&Re(e,i.scrollLeft)}function nn(e,t){let i=e.display,r=rt(e.display);t.top<0&&(t.top=0);let l=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,n=oi(e),o={};t.bottom-t.top>n&&(t.bottom=t.top+n);let s=e.doc.height+ni(i),a=t.top<r,u=t.bottom>s-r;if(t.top<l)o.scrollTop=a?0:t.top;else if(t.bottom>l+n){let c=Math.min(t.top,(u?s:t.bottom)-n);c!=l&&(o.scrollTop=c)}let f=e.options.fixedGutter?0:i.gutters.offsetWidth,p=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-f,h=je(e)-i.gutters.offsetWidth,d=t.right-t.left>h;return d&&(t.right=t.left+h),t.left<10?o.scrollLeft=0:t.left<p?o.scrollLeft=Math.max(0,t.left+f-(d?0:10)):t.right>h+p-3&&(o.scrollLeft=t.right+(d?0:10)-h),o}function Xi(e,t){t!=null&&($r(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Oe(e){$r(e);let t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Ft(e,t,i){(t!=null||i!=null)&&$r(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Ho(e,t){$r(e),e.curOp.scrollToPos=t}function $r(e){let t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;let i=Jl(e,t.from),r=Jl(e,t.to);on(e,i,r,t.margin)}}function on(e,t,i,r){let l=nn(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});Ft(e,l.scrollLeft,l.scrollTop)}function bt(e,t){Math.abs(e.doc.scrollTop-t)<2||(he||Ki(e,{top:t}),sn(e,t,!0),he&&Ki(e),nt(e,100))}function sn(e,t,i){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),!(e.display.scroller.scrollTop==t&&!i)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Re(e,t,i,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),!((i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)&&(e.doc.scrollLeft=t,Xr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function It(e){let t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+ni(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:r,scrollHeight:r+ae(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var Wo=class{constructor(t,i,r){this.cm=r;let l=this.vert=v("div",[v("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=v("div",[v("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");l.tabIndex=n.tabIndex=-1,t(l),t(n),S(l,"scroll",()=>{l.clientHeight&&i(l.scrollTop,"vertical")}),S(n,"scroll",()=>{n.clientWidth&&i(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,T&&N<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}update(t){let i=t.scrollWidth>t.clientWidth+1,r=t.scrollHeight>t.clientHeight+1,l=t.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=i?l+"px":"0";let n=t.viewHeight-(i?l:0);this.vert.firstChild.style.height=Math.max(0,t.scrollHeight-t.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(i){this.horiz.style.display="block",this.horiz.style.right=r?l+"px":"0",this.horiz.style.left=t.barLeft+"px";let n=t.viewWidth-t.barLeft-(r?l:0);this.horiz.firstChild.style.width=Math.max(0,t.scrollWidth-t.clientWidth+n)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&t.clientHeight>0&&(l==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?l:0,bottom:i?l:0}}setScrollLeft(t){this.horiz.scrollLeft!=t&&(this.horiz.scrollLeft=t),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")}setScrollTop(t){this.vert.scrollTop!=t&&(this.vert.scrollTop=t),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")}zeroWidthHack(){let t=X&&!Nn?"12px":"18px";this.horiz.style.height=this.vert.style.width=t,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ke,this.disableVert=new ke}enableZeroWidthBar(t,i,r){t.style.pointerEvents="auto";function l(){let n=t.getBoundingClientRect();(r=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1))!=t?t.style.pointerEvents="none":i.set(1e3,l)}i.set(1e3,l)}clear(){let t=this.horiz.parentNode;t.removeChild(this.horiz),t.removeChild(this.vert)}},Po=class{update(){return{bottom:0,right:0}}setScrollLeft(){}setScrollTop(){}clear(){}};function ot(e,t){t||(t=It(e));let i=e.display.barWidth,r=e.display.barHeight;_o(e,t);for(let l=0;l<4&&i!=e.display.barWidth||r!=e.display.barHeight;l++)i!=e.display.barWidth&&e.options.lineWrapping&&Et(e),_o(e,It(e)),i=e.display.barWidth,r=e.display.barHeight}function _o(e,t){let i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var an={native:Wo,null:Po};function Yr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&ce(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new an[e.options.scrollbarStyle](t=>{e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),S(t,"mousedown",()=>{e.state.focused&&setTimeout(()=>e.display.input.focus(),0)}),t.setAttribute("cm-not-content","true")},(t,i)=>{i=="horizontal"?Re(e,t):bt(e,t)},e),e.display.scrollbars.addClass&&ge(e.display.wrapper,e.display.scrollbars.addClass)}var ua=0;function Xe(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++ua},yo(e.curOp)}function $e(e){let t=e.curOp;t&&xo(t,i=>{for(let r=0;r<i.ops.length;r++)i.ops[r].cm.curOp=null;fa(i)})}function fa(e){let t=e.ops;for(let i=0;i<t.length;i++)pa(t[i]);for(let i=0;i<t.length;i++)da(t[i]);for(let i=0;i<t.length;i++)ha(t[i]);for(let i=0;i<t.length;i++)ca(t[i]);for(let i=0;i<t.length;i++)ga(t[i])}function pa(e){let t=e.cm,i=t.display;Eo(t),e.updateMaxLine&&ii(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new qr(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function da(e){e.updatedDisplay=e.mustUpdate&&Qr(e.cm,e.update)}function ha(e){let t=e.cm,i=t.display;e.updatedDisplay&&Et(t),e.barMeasure=It(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Xl(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+ae(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-je(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function ca(e){let t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Re(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);let i=e.focus&&e.focus==$();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&ot(t,e.barMeasure),e.updatedDisplay&&Zr(t,e.barMeasure),e.selectionChanged&&ai(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&Ur(e.cm)}function ga(e){let t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&un(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&sn(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Re(t,e.scrollLeft,!0,!0),e.scrollToPos){let o=Do(t,L(r,e.scrollToPos.from),L(r,e.scrollToPos.to),e.scrollToPos.margin);Ao(t,o)}let l=e.maybeHiddenMarkers,n=e.maybeUnhiddenMarkers;if(l)for(let o=0;o<l.length;++o)l[o].lines.length||P(l[o],"hide");if(n)for(let o=0;o<n.length;++o)n[o].lines.length&&P(n[o],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&P(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function B(e,t){if(e.curOp)return t();Xe(e);try{return t()}finally{$e(e)}}function I(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Xe(e);try{return t.apply(e,arguments)}finally{$e(e)}}}function te(e){return function(){if(this.curOp)return e.apply(this,arguments);Xe(this);try{return e.apply(this,arguments)}finally{$e(this)}}}function Y(e){return function(){let t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);Xe(t);try{return e.apply(this,arguments)}finally{$e(t)}}}function nt(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,Mi(ma,e))}function ma(e){let t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;let i=+new Date+e.options.workTime,r=gt(e,t.highlightFrontier),l=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),n=>{if(r.line>=e.display.viewFrom){let o=n.styles,s=n.text.length>e.options.maxHighlightLength?Ue(t.mode,r.state):null,a=Hl(e,n,r,!0);s&&(r.state=s),n.styles=a.styles;let u=n.styleClasses,f=a.classes;f?n.styleClasses=f:u&&(n.styleClasses=null);let p=!o||o.length!=n.styles.length||u!=f&&(!u||!f||u.bgClass!=f.bgClass||u.textClass!=f.textClass);for(let h=0;!p&&h<o.length;++h)p=o[h]!=n.styles[h];p&&l.push(r.line),n.stateAfter=r.save(),r.nextLine()}else n.text.length<=e.options.maxHighlightLength&&Or(e,n.text,r),n.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return nt(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),l.length&&B(e,()=>{for(let n=0;n<l.length;n++)Ce(e,l[n],"text")})}var qr=class{constructor(t,i,r){let l=t.display;this.viewport=i,this.visible=ui(l,t.doc,i),this.editorIsHidden=!l.wrapper.offsetWidth,this.wrapperHeight=l.wrapper.clientHeight,this.wrapperWidth=l.wrapper.clientWidth,this.oldDisplayWidth=je(t),this.force=r,this.dims=Er(t),this.events=[]}signal(t,i){ee(t,i)&&this.events.push(arguments)}finish(){for(let t=0;t<this.events.length;t++)P.apply(null,this.events[t])}};function Eo(e){let t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=ae(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=ae(e)+"px",t.scrollbarsClipped=!0)}function ya(e){if(e.hasFocus())return null;let t=$();if(!t||!Le(e.display.lineDiv,t))return null;let i={activeElt:t};if(window.getSelection){let r=window.getSelection();r.anchorNode&&r.extend&&Le(e.display.lineDiv,r.anchorNode)&&(i.anchorNode=r.anchorNode,i.anchorOffset=r.anchorOffset,i.focusNode=r.focusNode,i.focusOffset=r.focusOffset)}return i}function xa(e){if(!(!e||!e.activeElt||e.activeElt==$())&&(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&Le(document.body,e.anchorNode)&&Le(document.body,e.focusNode))){let t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function Qr(e,t){let i=e.display,r=e.doc;if(t.editorIsHidden)return lt(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&rn(e)==0)return!1;Jr(e)&&(lt(e),t.dims=Er(e));let l=r.first+r.size,n=Math.max(t.visible.from-e.options.viewportMargin,r.first),o=Math.min(l,t.visible.to+e.options.viewportMargin);i.viewFrom<n&&n-i.viewFrom<20&&(n=Math.max(r.first,i.viewFrom)),i.viewTo>o&&i.viewTo-o<20&&(o=Math.min(l,i.viewTo)),Me&&(n=Ei(e.doc,n),o=Wr(e.doc,o));let s=n!=i.viewFrom||o!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;jo(e,n,o),i.viewOffset=me(C(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";let a=rn(e);if(!s&&a==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;let u=ya(e);return a>4&&(i.lineDiv.style.display="none"),ba(e,i.updateLineNumbers,t.dims),a>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,xa(u),Se(i.cursorDiv),Se(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,s&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,nt(e,400)),i.updateLineNumbers=null,!0}function un(e,t){let i=t.viewport;for(let r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==je(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+ni(e.display)-oi(e),i.top)}),t.visible=ui(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=ui(e.display,e.doc,i));if(!Qr(e,t))break;Et(e);let l=It(e);_t(e),ot(e,l),Zr(e,l),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Ki(e,t){let i=new qr(e,t);if(Qr(e,i)){Et(e),un(e,i);let r=It(e);_t(e),ot(e,r),Zr(e,r),i.finish()}}function ba(e,t,i){let r=e.display,l=e.options.lineNumbers,n=r.lineDiv,o=n.firstChild;function s(f){let p=f.nextSibling;return z&&X&&e.display.currentWheelTarget==f?f.style.display="none":f.parentNode.removeChild(f),p}let a=r.view,u=r.viewFrom;for(let f=0;f<a.length;f++){let p=a[f];if(!p.hidden)if(!p.node||p.node.parentNode!=n){let h=wo(e,p,u,i);n.insertBefore(h,o)}else{for(;o!=p.node;)o=s(o);let h=l&&t!=null&&t<=u&&p.lineNumber;p.changes&&(_(p.changes,"gutter")>-1&&(h=!1),_r(e,p,u,i)),h&&(Se(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(Vt(e.options,u)))),o=p.node.nextSibling}u+=p.size}for(;o;)o=s(o)}function fi(e){let t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",E(e,"gutterChanged",e)}function Zr(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+ae(e)+"px"}function Xr(e){let t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;let r=Ui(t)-t.scroller.scrollLeft+e.doc.scrollLeft,l=t.gutters.offsetWidth,n=r+"px";for(let o=0;o<i.length;o++)if(!i[o].hidden){e.options.fixedGutter&&(i[o].gutter&&(i[o].gutter.style.left=n),i[o].gutterBackground&&(i[o].gutterBackground.style.left=n));let s=i[o].alignable;if(s)for(let a=0;a<s.length;a++)s[a].style.left=n}e.options.fixedGutter&&(t.gutters.style.left=r+l+"px")}function Jr(e){if(!e.options.lineNumbers)return!1;let t=e.doc,i=Vt(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){let l=r.measure.appendChild(v("div",[v("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),n=l.firstChild.offsetWidth,o=l.offsetWidth-n;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(n,r.lineGutter.offsetWidth-o)+1,r.lineNumWidth=r.lineNumInnerWidth+o,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",fi(e.display),!0}return!1}function $i(e,t){let i=[],r=!1;for(let l=0;l<e.length;l++){let n=e[l],o=null;if(typeof n!="string"&&(o=n.style,n=n.className),n=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:n,style:o})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function fn(e){let t=e.gutters,i=e.gutterSpecs;Se(t),e.lineGutter=null;for(let r=0;r<i.length;++r){let{className:l,style:n}=i[r],o=t.appendChild(v("div",null,"CodeMirror-gutter "+l));n&&(o.style.cssText=n),l=="CodeMirror-linenumbers"&&(e.lineGutter=o,o.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",fi(e)}function pi(e){fn(e.display),G(e),Xr(e)}function Fo(e,t,i,r){let l=this;this.input=i,l.scrollbarFiller=v("div",null,"CodeMirror-scrollbar-filler"),l.scrollbarFiller.setAttribute("cm-not-content","true"),l.gutterFiller=v("div",null,"CodeMirror-gutter-filler"),l.gutterFiller.setAttribute("cm-not-content","true"),l.lineDiv=Je("div",null,"CodeMirror-code"),l.selectionDiv=v("div",null,null,"position: relative; z-index: 1"),l.cursorDiv=v("div",null,"CodeMirror-cursors"),l.measure=v("div",null,"CodeMirror-measure"),l.lineMeasure=v("div",null,"CodeMirror-measure"),l.lineSpace=Je("div",[l.measure,l.lineMeasure,l.selectionDiv,l.cursorDiv,l.lineDiv],null,"position: relative; outline: none");let n=Je("div",[l.lineSpace],"CodeMirror-lines");l.mover=v("div",[n],null,"position: relative"),l.sizer=v("div",[l.mover],"CodeMirror-sizer"),l.sizerWidth=null,l.heightForcer=v("div",null,null,"position: absolute; height: "+cr+"px; width: 1px;"),l.gutters=v("div",null,"CodeMirror-gutters"),l.lineGutter=null,l.scroller=v("div",[l.sizer,l.heightForcer,l.gutters],"CodeMirror-scroll"),l.scroller.setAttribute("tabIndex","-1"),l.wrapper=v("div",[l.scrollbarFiller,l.gutterFiller,l.scroller],"CodeMirror"),T&&N<8&&(l.gutters.style.zIndex=-1,l.scroller.style.paddingRight=0),!z&&!(he&&Qe)&&(l.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(l.wrapper):e(l.wrapper)),l.viewFrom=l.viewTo=t.first,l.reportedViewFrom=l.reportedViewTo=t.first,l.view=[],l.renderedView=null,l.externalMeasured=null,l.viewOffset=0,l.lastWrapHeight=l.lastWrapWidth=0,l.updateLineNumbers=null,l.nativeBarWidth=l.barHeight=l.barWidth=0,l.scrollbarsClipped=!1,l.lineNumWidth=l.lineNumInnerWidth=l.lineNumChars=null,l.alignWidgets=!1,l.cachedCharWidth=l.cachedTextHeight=l.cachedPaddingH=null,l.maxLine=null,l.maxLineLength=0,l.maxLineChanged=!1,l.wheelDX=l.wheelDY=l.wheelStartX=l.wheelStartY=null,l.shift=!1,l.selForContextMenu=null,l.activeTouch=null,l.gutterSpecs=$i(r.gutters,r.lineNumbers),fn(l),i.init(l)}var Vr=0,ve=null;T?ve=-.53:he?ve=15:St?ve=-.7:Lt&&(ve=-1/3);function Io(e){let t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function Ro(e){let t=Io(e);return t.x*=ve,t.y*=ve,t}function pn(e,t){let i=Io(t),r=i.x,l=i.y,n=e.display,o=n.scroller,s=o.scrollWidth>o.clientWidth,a=o.scrollHeight>o.clientHeight;if(!!(r&&s||l&&a)){if(l&&X&&z){e:for(let u=t.target,f=n.view;u!=o;u=u.parentNode)for(let p=0;p<f.length;p++)if(f[p].node==u){e.display.currentWheelTarget=u;break e}}if(r&&!he&&!re&&ve!=null){l&&a&&bt(e,Math.max(0,o.scrollTop+l*ve)),Re(e,Math.max(0,o.scrollLeft+r*ve)),(!l||l&&a)&&U(t),n.wheelStartX=null;return}if(l&&ve!=null){let u=l*ve,f=e.doc.scrollTop,p=f+n.wrapper.clientHeight;u<0?f=Math.max(0,f+u-50):p=Math.min(e.doc.height,p+u+50),Ki(e,{top:f,bottom:p})}Vr<20&&(n.wheelStartX==null?(n.wheelStartX=o.scrollLeft,n.wheelStartY=o.scrollTop,n.wheelDX=r,n.wheelDY=l,setTimeout(()=>{if(n.wheelStartX==null)return;let u=o.scrollLeft-n.wheelStartX,f=o.scrollTop-n.wheelStartY,p=f&&n.wheelDY&&f/n.wheelDY||u&&n.wheelDX&&u/n.wheelDX;n.wheelStartX=n.wheelStartY=null,!!p&&(ve=(ve*Vr+p)/(Vr+1),++Vr)},200)):(n.wheelDX+=r,n.wheelDY+=l))}}var fe=class{constructor(t,i){this.ranges=t,this.primIndex=i}primary(){return this.ranges[this.primIndex]}equals(t){if(t==this)return!0;if(t.primIndex!=this.primIndex||t.ranges.length!=this.ranges.length)return!1;for(let i=0;i<this.ranges.length;i++){let r=this.ranges[i],l=t.ranges[i];if(!Ni(r.anchor,l.anchor)||!Ni(r.head,l.head))return!1}return!0}deepCopy(){let t=[];for(let i=0;i<this.ranges.length;i++)t[i]=new A(Hi(this.ranges[i].anchor),Hi(this.ranges[i].head));return new fe(t,this.primIndex)}somethingSelected(){for(let t=0;t<this.ranges.length;t++)if(!this.ranges[t].empty())return!0;return!1}contains(t,i){i||(i=t);for(let r=0;r<this.ranges.length;r++){let l=this.ranges[r];if(k(i,l.from())>=0&&k(t,l.to())<=0)return r}return-1}},A=class{constructor(t,i){this.anchor=t,this.head=i}from(){return Nt(this.anchor,this.head)}to(){return Dt(this.anchor,this.head)}empty(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};function pe(e,t,i){let r=e&&e.options.selectionsMayTouch,l=t[i];t.sort((n,o)=>k(n.from(),o.from())),i=_(t,l);for(let n=1;n<t.length;n++){let o=t[n],s=t[n-1],a=k(s.to(),o.from());if(r&&!o.empty()?a>0:a>=0){let u=Nt(s.from(),o.from()),f=Dt(s.to(),o.to()),p=s.empty()?o.from()==o.head:s.from()==s.head;n<=i&&--i,t.splice(--n,2,new A(p?f:u,p?u:f))}}return new fe(t,i)}function we(e,t){return new fe([new A(e,t||e)],0)}function Ae(e){return e.text?x(e.from.line+e.text.length-1,j(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function zo(e,t){if(k(e,t.from)<0)return e;if(k(e,t.to)<=0)return Ae(t);let i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Ae(t).ch-t.to.ch),x(i,r)}function el(e,t){let i=[];for(let r=0;r<e.sel.ranges.length;r++){let l=e.sel.ranges[r];i.push(new A(zo(l.anchor,t),zo(l.head,t)))}return pe(e.cm,i,e.sel.primIndex)}function Bo(e,t,i){return e.line==t.line?x(i.line,e.ch-t.ch+i.ch):x(i.line+(e.line-t.line),e.ch)}function Go(e,t,i){let r=[],l=x(e.first,0),n=l;for(let o=0;o<t.length;o++){let s=t[o],a=Bo(s.from,l,n),u=Bo(Ae(s),l,n);if(l=s.to,n=u,i=="around"){let f=e.sel.ranges[o],p=k(f.head,f.anchor)<0;r[o]=new A(p?u:a,p?a:u)}else r[o]=new A(a,a)}return new fe(r,e.sel.primIndex)}function Yi(e){e.doc.mode=Ai(e.options,e.doc.modeOption),di(e)}function di(e){e.doc.iter(t=>{t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,nt(e,100),e.state.modeGen++,e.curOp&&G(e)}function dn(e,t){return t.from.ch==0&&t.to.ch==0&&j(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function qi(e,t,i,r){function l(y){return i?i[y]:null}function n(y,g,b){po(y,g,b,r),E(y,"change",y,t)}function o(y,g){let b=[];for(let m=y;m<g;++m)b.push(new tt(u[m],l(m),r));return b}let s=t.from,a=t.to,u=t.text,f=C(e,s.line),p=C(e,a.line),h=j(u),d=l(u.length-1),c=a.line-s.line;if(t.full)e.insert(0,o(0,u.length)),e.remove(u.length,e.size-u.length);else if(dn(e,t)){let y=o(0,u.length-1);n(p,p.text,d),c&&e.remove(s.line,c),y.length&&e.insert(s.line,y)}else if(f==p)if(u.length==1)n(f,f.text.slice(0,s.ch)+h+f.text.slice(a.ch),d);else{let y=o(1,u.length-1);y.push(new tt(h+f.text.slice(a.ch),d,r)),n(f,f.text.slice(0,s.ch)+u[0],l(0)),e.insert(s.line+1,y)}else if(u.length==1)n(f,f.text.slice(0,s.ch)+u[0]+p.text.slice(a.ch),l(0)),e.remove(s.line+1,c);else{n(f,f.text.slice(0,s.ch)+u[0],l(0)),n(p,h+p.text.slice(a.ch),d);let y=o(1,u.length-1);c>1&&e.remove(s.line+1,c-1),e.insert(s.line+1,y)}E(e,"change",e,t)}function De(e,t,i){function r(l,n,o){if(l.linked)for(let s=0;s<l.linked.length;++s){let a=l.linked[s];if(a.doc==n)continue;let u=o&&a.sharedHist;i&&!u||(t(a.doc,u),r(a.doc,l,u))}}r(e,null,!0)}function tl(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,si(e),Yi(e),Uo(e),e.options.lineWrapping||ii(e),e.options.mode=t.modeOption,G(e)}function Uo(e){(e.doc.direction=="rtl"?ge:ce)(e.display.lineDiv,"CodeMirror-rtl")}function Ko(e){B(e,()=>{Uo(e),G(e)})}function Zi(e){this.done=[],this.undone=[],this.undoDepth=e?e.undoDepth:Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e?e.maxGeneration:1}function il(e,t){let i={from:Hi(t.from),to:Ae(t),text:_e(e,t.from,t.to)};return Xo(e,i,t.from.line,t.to.line+1),De(e,r=>Xo(r,i,t.from.line,t.to.line+1),!0),i}function $o(e){for(;e.length&&j(e).ranges;)e.pop()}function Ca(e,t){if(t)return $o(e.done),j(e.done);if(e.done.length&&!j(e.done).ranges)return j(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),j(e.done)}function rl(e,t,i,r){let l=e.history;l.undone.length=0;let n=+new Date,o,s;if((l.lastOp==r||l.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&l.lastModTime>n-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(o=Ca(l,l.lastOp==r)))s=j(o.changes),k(t.from,t.to)==0&&k(t.from,s.to)==0?s.to=Ae(t):o.changes.push(il(e,t));else{let a=j(l.done);for((!a||!a.ranges)&&Qi(e.sel,l.done),o={changes:[il(e,t)],generation:l.generation},l.done.push(o);l.done.length>l.undoDepth;)l.done.shift(),l.done[0].ranges||l.done.shift()}l.done.push(i),l.generation=++l.maxGeneration,l.lastModTime=l.lastSelTime=n,l.lastOp=l.lastSelOp=r,l.lastOrigin=l.lastSelOrigin=t.origin,s||P(e,"historyAdded")}function va(e,t,i,r){let l=t.charAt(0);return l=="*"||l=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Yo(e,t,i,r){let l=e.history,n=r&&r.origin;i==l.lastSelOp||n&&l.lastSelOrigin==n&&(l.lastModTime==l.lastSelTime&&l.lastOrigin==n||va(e,n,j(l.done),t))?l.done[l.done.length-1]=t:Qi(t,l.done),l.lastSelTime=+new Date,l.lastSelOrigin=n,l.lastSelOp=i,r&&r.clearRedo!==!1&&$o(l.undone)}function Qi(e,t){let i=j(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Xo(e,t,i,r){let l=t["spans_"+e.id],n=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),o=>{o.markedSpans&&((l||(l=t["spans_"+e.id]={}))[n]=o.markedSpans),++n})}function wa(e){if(!e)return null;let t;for(let i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function Sa(e,t){let i=t["spans_"+e.id];if(!i)return null;let r=[];for(let l=0;l<t.text.length;++l)r.push(wa(i[l]));return r}function hn(e,t){let i=Sa(e,t),r=_i(e,t);if(!i)return r;if(!r)return i;for(let l=0;l<i.length;++l){let n=i[l],o=r[l];if(n&&o){e:for(let s=0;s<o.length;++s){let a=o[s];for(let u=0;u<n.length;++u)if(n[u].marker==a.marker)continue e;n.push(a)}}else o&&(i[l]=o)}return i}function Rt(e,t,i){let r=[];for(let n=0;n<e.length;++n){let o=e[n];if(o.ranges){r.push(i?fe.prototype.deepCopy.call(o):o);continue}let s=o.changes,a=[];r.push({changes:a});for(let u=0;u<s.length;++u){let f=s[u],p;if(a.push({from:f.from,to:f.to,text:f.text}),t)for(var l in f)(p=l.match(/^spans_(\d+)$/))&&_(t,Number(p[1]))>-1&&(j(a)[l]=f[l],delete f[l])}}return r}function ll(e,t,i,r){if(r){let l=e.anchor;if(i){let n=k(t,l)<0;n!=k(i,l)<0?(l=t,t=i):n!=k(t,i)<0&&(t=i)}return new A(l,t)}else return new A(i||t,t)}function zt(e,t,i,r,l){l==null&&(l=e.cm&&(e.cm.display.shift||e.extend)),K(e,new fe([ll(e.sel.primary(),t,i,l)],0),r)}function cn(e,t,i){let r=[],l=e.cm&&(e.cm.display.shift||e.extend);for(let o=0;o<e.sel.ranges.length;o++)r[o]=ll(e.sel.ranges[o],t[o],null,l);let n=pe(e.cm,r,e.sel.primIndex);K(e,n,i)}function hi(e,t,i,r){let l=e.sel.ranges.slice(0);l[t]=i,K(e,pe(e.cm,l,e.sel.primIndex),r)}function gn(e,t,i,r){K(e,we(t,i),r)}function La(e,t,i){let r={ranges:t.ranges,update:function(l){this.ranges=[];for(let n=0;n<l.length;n++)this.ranges[n]=new A(L(e,l[n].anchor),L(e,l[n].head))},origin:i&&i.origin};return P(e,"beforeSelectionChange",e,r),e.cm&&P(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?pe(e.cm,r.ranges,r.ranges.length-1):t}function nl(e,t,i){let r=e.history.done,l=j(r);l&&l.ranges?(r[r.length-1]=t,ci(e,t,i)):K(e,t,i)}function K(e,t,i){ci(e,t,i),Yo(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function ci(e,t,i){(ee(e,"beforeSelectionChange")||e.cm&&ee(e.cm,"beforeSelectionChange"))&&(t=La(e,t,i));let r=i&&i.bias||(k(t.primary().head,e.sel.primary().head)<0?-1:1);qo(e,Zo(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&e.cm.getOption("readOnly")!="nocursor"&&Oe(e.cm)}function qo(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,Sr(e.cm)),E(e,"cursorActivity",e))}function mn(e){qo(e,Zo(e,e.sel,null,!1))}function Zo(e,t,i,r){let l;for(let n=0;n<t.ranges.length;n++){let o=t.ranges[n],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[n],a=gi(e,o.anchor,s&&s.anchor,i,r),u=gi(e,o.head,s&&s.head,i,r);(l||a!=o.anchor||u!=o.head)&&(l||(l=t.ranges.slice(0,n)),l[n]=new A(a,u))}return l?pe(e.cm,l,t.primIndex):t}function mi(e,t,i,r,l){let n=C(e,t.line);if(n.markedSpans)for(let o=0;o<n.markedSpans.length;++o){let s=n.markedSpans[o],a=s.marker,u="selectLeft"in a?!a.selectLeft:a.inclusiveLeft,f="selectRight"in a?!a.selectRight:a.inclusiveRight;if((s.from==null||(u?s.from<=t.ch:s.from<t.ch))&&(s.to==null||(f?s.to>=t.ch:s.to>t.ch))){if(l&&(P(a,"beforeCursorEnter"),a.explicitlyCleared))if(n.markedSpans){--o;continue}else break;if(!a.atomic)continue;if(i){let h=a.find(r<0?1:-1),d;if((r<0?f:u)&&(h=Qo(e,h,-r,h&&h.line==t.line?n:null)),h&&h.line==t.line&&(d=k(h,i))&&(r<0?d<0:d>0))return mi(e,h,t,r,l)}let p=a.find(r<0?-1:1);return(r<0?u:f)&&(p=Qo(e,p,r,p.line==t.line?n:null)),p?mi(e,p,t,r,l):null}}return t}function gi(e,t,i,r,l){let n=r||1,o=mi(e,t,i,n,l)||!l&&mi(e,t,i,n,!0)||mi(e,t,i,-n,l)||!l&&mi(e,t,i,-n,!0);return o||(e.cantEdit=!0,x(e.first,0))}function Qo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?L(e,x(t.line-1)):null:i>0&&t.ch==(r||C(e,t.line)).text.length?t.line<e.first+e.size-1?x(t.line+1,0):null:new x(t.line,t.ch+i)}function ol(e){e.setSelection(x(e.firstLine(),0),x(e.lastLine()),V)}function Jo(e,t,i){let r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:()=>r.canceled=!0};return i&&(r.update=(l,n,o,s)=>{l&&(r.from=L(e,l)),n&&(r.to=L(e,n)),o&&(r.text=o),s!==void 0&&(r.origin=s)}),P(e,"beforeChange",e,r),e.cm&&P(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function st(e,t,i){if(e.cm){if(!e.cm.curOp)return I(e.cm,st)(e,t,i);if(e.cm.state.suppressEdits)return}if((ee(e,"beforeChange")||e.cm&&ee(e.cm,"beforeChange"))&&(t=Jo(e,t,!0),!t))return;let r=El&&!i&&no(e,t.from,t.to);if(r)for(let l=r.length-1;l>=0;--l)Vo(e,{from:r[l].from,to:r[l].to,text:l?[""]:t.text,origin:t.origin});else Vo(e,t)}function Vo(e,t){if(t.text.length==1&&t.text[0]==""&&k(t.from,t.to)==0)return;let i=el(e,t);rl(e,t,i,e.cm?e.cm.curOp.id:NaN),Ji(e,t,i,_i(e,t));let r=[];De(e,(l,n)=>{!n&&_(r,l.history)==-1&&(es(l.history,t),r.push(l.history)),Ji(l,t,null,_i(l,t))})}function Vi(e,t,i){let r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;let l=e.history,n,o=e.sel,s=t=="undo"?l.done:l.undone,a=t=="undo"?l.undone:l.done,u=0;for(;u<s.length&&(n=s[u],!(i?n.ranges&&!n.equals(e.sel):!n.ranges));u++);if(u==s.length)return;for(l.lastOrigin=l.lastSelOrigin=null;;)if(n=s.pop(),n.ranges){if(Qi(n,a),i&&!n.equals(e.sel)){K(e,n,{clearRedo:!1});return}o=n}else if(r){s.push(n);return}else break;let f=[];Qi(o,a),a.push({changes:f,generation:l.generation}),l.generation=n.generation||++l.maxGeneration;let p=ee(e,"beforeChange")||e.cm&&ee(e.cm,"beforeChange");for(let h=n.changes.length-1;h>=0;--h){let d=n.changes[h];if(d.origin=t,p&&!Jo(e,d,!1)){s.length=0;return}f.push(il(e,d));let c=h?el(e,d):j(s);Ji(e,d,c,hn(e,d)),!h&&e.cm&&e.cm.scrollIntoView({from:d.from,to:Ae(d)});let y=[];De(e,(g,b)=>{!b&&_(y,g.history)==-1&&(es(g.history,d),y.push(g.history)),Ji(g,d,null,hn(g,d))})}}function ts(e,t){if(t!=0&&(e.first+=t,e.sel=new fe(ht(e.sel.ranges,i=>new A(x(i.anchor.line+t,i.anchor.ch),x(i.head.line+t,i.head.ch))),e.sel.primIndex),e.cm)){G(e.cm,e.first,e.first-t,t);for(let i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Ce(e.cm,r,"gutter")}}function Ji(e,t,i,r){if(e.cm&&!e.cm.curOp)return I(e.cm,Ji)(e,t,i,r);if(t.to.line<e.first){ts(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){let n=t.text.length-1-(e.first-t.from.line);ts(e,n),t={from:x(e.first,0),to:x(t.to.line+n,t.to.ch),text:[j(t.text)],origin:t.origin}}let l=e.lastLine();t.to.line>l&&(t={from:t.from,to:x(l,C(e,l).text.length),text:[t.text[0]],origin:t.origin}),t.removed=_e(e,t.from,t.to),i||(i=el(e,t)),e.cm?ka(e.cm,t,r):qi(e,t,r),ci(e,i,V),e.cantEdit&&gi(e,x(e.firstLine(),0))&&(e.cantEdit=!1)}function ka(e,t,i){let r=e.doc,l=e.display,n=t.from,o=t.to,s=!1,a=n.line;e.options.lineWrapping||(a=O(ne(C(r,n.line))),r.iter(a,o.line+1,h=>{if(h==l.maxLine)return s=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Sr(e),qi(r,t,i,tn(e)),e.options.lineWrapping||(r.iter(a,n.line+t.text.length,h=>{let d=ti(h);d>l.maxLineLength&&(l.maxLine=h,l.maxLineLength=d,l.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),Vn(r,n.line),nt(e,400);let u=t.text.length-(o.line-n.line)-1;t.full?G(e):n.line==o.line&&t.text.length==1&&!dn(e.doc,t)?Ce(e,n.line,"text"):G(e,n.line,o.line+1,u);let f=ee(e,"changes"),p=ee(e,"change");if(p||f){let h={from:n,to:o,text:t.text,removed:t.removed,origin:t.origin};p&&E(e,"change",e,h),f&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Ne(e,t,i,r,l){r||(r=i),k(r,i)<0&&([i,r]=[r,i]),typeof t=="string"&&(t=e.splitLines(t)),st(e,{from:i,to:r,text:t,origin:l})}function is(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function rs(e,t,i,r){for(let l=0;l<e.length;++l){let n=e[l],o=!0;if(n.ranges){n.copied||(n=e[l]=n.deepCopy(),n.copied=!0);for(let s=0;s<n.ranges.length;s++)is(n.ranges[s].anchor,t,i,r),is(n.ranges[s].head,t,i,r);continue}for(let s=0;s<n.changes.length;++s){let a=n.changes[s];if(i<a.from.line)a.from=x(a.from.line+r,a.from.ch),a.to=x(a.to.line+r,a.to.ch);else if(t<=a.to.line){o=!1;break}}o||(e.splice(0,l+1),l=0)}}function es(e,t){let i=t.from.line,r=t.to.line,l=t.text.length-(r-i)-1;rs(e.done,i,r,l),rs(e.undone,i,r,l)}function Bt(e,t,i,r){let l=t,n=t;return typeof t=="number"?n=C(e,Tr(e,t)):l=O(t),l==null?null:(r(n,l)&&e.cm&&Ce(e.cm,l,i),n)}function yi(e){this.lines=e,this.parent=null;let t=0;for(let i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}yi.prototype={chunkSize(){return this.lines.length},removeInner(e,t){for(let i=e,r=e+t;i<r;++i){let l=this.lines[i];this.height-=l.height,ho(l),E(l,"delete")}this.lines.splice(e,t)},collapse(e){e.push.apply(e,this.lines)},insertInner(e,t,i){this.height+=i,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(let r=0;r<t.length;++r)t[r].parent=this},iterN(e,t,i){for(let r=e+t;e<r;++e)if(i(this.lines[e]))return!0}};function xi(e){this.children=e;let t=0,i=0;for(let r=0;r<e.length;++r){let l=e[r];t+=l.chunkSize(),i+=l.height,l.parent=this}this.size=t,this.height=i,this.parent=null}xi.prototype={chunkSize(){return this.size},removeInner(e,t){this.size-=t;for(let i=0;i<this.children.length;++i){let r=this.children[i],l=r.chunkSize();if(e<l){let n=Math.min(t,l-e),o=r.height;if(r.removeInner(e,n),this.height-=o-r.height,l==n&&(this.children.splice(i--,1),r.parent=null),(t-=n)==0)break;e=0}else e-=l}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof yi))){let i=[];this.collapse(i),this.children=[new yi(i)],this.children[0].parent=this}},collapse(e){for(let t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner(e,t,i){this.size+=t.length,this.height+=i;for(let r=0;r<this.children.length;++r){let l=this.children[r],n=l.chunkSize();if(e<=n){if(l.insertInner(e,t,i),l.lines&&l.lines.length>50){let o=l.lines.length%25+25;for(let s=o;s<l.lines.length;){let a=new yi(l.lines.slice(s,s+=25));l.height-=a.height,this.children.splice(++r,0,a),a.parent=this}l.lines=l.lines.slice(0,o),this.maybeSpill()}break}e-=n}},maybeSpill(){if(this.children.length<=10)return;let e=this;do{let t=e.children.splice(e.children.length-5,5),i=new xi(t);if(e.parent){e.size-=i.size,e.height-=i.height;let r=_(e.parent.children,e);e.parent.children.splice(r+1,0,i)}else{let r=new xi(e.children);r.parent=e,e.children=[r,i],e=r}i.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN(e,t,i){for(let r=0;r<this.children.length;++r){let l=this.children[r],n=l.chunkSize();if(e<n){let o=Math.min(t,n-e);if(l.iterN(e,o,i))return!0;if((t-=o)==0)break;e=0}else e-=n}}};var er=class{constructor(t,i,r){if(r)for(let l in r)r.hasOwnProperty(l)&&(this[l]=r[l]);this.doc=t,this.node=i}clear(){let t=this.doc.cm,i=this.line.widgets,r=this.line,l=O(r);if(l==null||!i)return;for(let o=0;o<i.length;++o)i[o]==this&&i.splice(o--,1);i.length||(r.widgets=null);let n=mt(this);se(r,Math.max(0,r.height-n)),t&&(B(t,()=>{ls(t,r,-n),Ce(t,l,"widget")}),E(t,"lineWidgetCleared",t,this,l))}changed(){let t=this.height,i=this.doc.cm,r=this.line;this.height=null;let l=mt(this)-t;!l||(Te(this.doc,r)||se(r,r.height+l),i&&B(i,()=>{i.curOp.forceUpdate=!0,ls(i,r,l),E(i,"lineWidgetChanged",i,this,O(r))}))}};Pe(er);function ls(e,t,i){me(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Xi(e,i)}function ns(e,t,i,r){let l=new er(e,i,r),n=e.cm;return n&&l.noHScroll&&(n.display.alignWidgets=!0),Bt(e,t,"widget",o=>{let s=o.widgets||(o.widgets=[]);if(l.insertAt==null?s.push(l):s.splice(Math.min(s.length,Math.max(0,l.insertAt)),0,l),l.line=o,n&&!Te(e,o)){let a=me(o)<e.scrollTop;se(o,o.height+mt(l)),a&&Xi(n,l.height),n.curOp.forceUpdate=!0}return!0}),n&&E(n,"lineWidgetAdded",n,l,typeof t=="number"?t:O(t)),l}var os=0,tr=class{constructor(t,i){this.lines=[],this.type=i,this.doc=t,this.id=++os}clear(){if(this.explicitlyCleared)return;let t=this.doc.cm,i=t&&!t.curOp;if(i&&Xe(t),ee(this,"clear")){let n=this.find();n&&E(this,"clear",n.from,n.to)}let r=null,l=null;for(let n=0;n<this.lines.length;++n){let o=this.lines[n],s=ei(o.markedSpans,this);t&&!this.collapsed?Ce(t,O(o),"text"):t&&(s.to!=null&&(l=O(o)),s.from!=null&&(r=O(o))),o.markedSpans=io(o.markedSpans,s),s.from==null&&this.collapsed&&!Te(this.doc,o)&&t&&se(o,rt(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(let n=0;n<this.lines.length;++n){let o=ne(this.lines[n]),s=ti(o);s>t.display.maxLineLength&&(t.display.maxLine=o,t.display.maxLineLength=s,t.display.maxLineChanged=!0)}r!=null&&t&&this.collapsed&&G(t,r,l+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&mn(t.doc)),t&&E(t,"markerCleared",t,this,r,l),i&&$e(t),this.parent&&this.parent.clear()}find(t,i){t==null&&this.type=="bookmark"&&(t=1);let r,l;for(let n=0;n<this.lines.length;++n){let o=this.lines[n],s=ei(o.markedSpans,this);if(s.from!=null&&(r=x(i?o:O(o),s.from),t==-1))return r;if(s.to!=null&&(l=x(i?o:O(o),s.to),t==1))return l}return r&&{from:r,to:l}}changed(){let t=this.find(-1,!0),i=this,r=this.doc.cm;!t||!r||B(r,()=>{let l=t.line,n=O(t.line),o=zi(r,n);if(o&&(Yl(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Te(i.doc,l)&&i.height!=null){let s=i.height;i.height=null;let a=mt(i)-s;a&&se(l,l.height+a)}E(r,"markerChanged",r,this)})}attachLine(t){if(!this.lines.length&&this.doc.cm){let i=this.doc.cm.curOp;(!i.maybeHiddenMarkers||_(i.maybeHiddenMarkers,this)==-1)&&(i.maybeUnhiddenMarkers||(i.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(t)}detachLine(t){if(this.lines.splice(_(this.lines,t),1),!this.lines.length&&this.doc.cm){let i=this.doc.cm.curOp;(i.maybeHiddenMarkers||(i.maybeHiddenMarkers=[])).push(this)}}};Pe(tr);function Gt(e,t,i,r,l){if(r&&r.shared)return Ma(e,t,i,r,l);if(e.cm&&!e.cm.curOp)return I(e.cm,Gt)(e,t,i,r,l);let n=new tr(e,l),o=k(t,i);if(r&&We(r,n,!1),o>0||o==0&&n.clearWhenEmpty!==!1)return n;if(n.replacedWith&&(n.collapsed=!0,n.widgetNode=Je("span",[n.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||n.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(n.widgetNode.insertLeft=!0)),n.collapsed){if(Rl(e,t.line,t,i,n)||t.line!=i.line&&Rl(e,i.line,t,i,n))throw new Error("Inserting collapsed marker partially overlapping an existing one");to()}n.addToHistory&&rl(e,{from:t,to:i,origin:"markText"},e.sel,NaN);let s=t.line,a=e.cm,u;if(e.iter(s,i.line+1,f=>{a&&n.collapsed&&!a.options.lineWrapping&&ne(f)==a.display.maxLine&&(u=!0),n.collapsed&&s!=t.line&&se(f,0),ro(f,new Pi(n,s==t.line?t.ch:null,s==i.line?i.ch:null)),++s}),n.collapsed&&e.iter(t.line,i.line+1,f=>{Te(e,f)&&se(f,0)}),n.clearOnEnter&&S(n,"beforeCursorEnter",()=>n.clear()),n.readOnly&&(eo(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),n.collapsed&&(n.id=++os,n.atomic=!0),a){if(u&&(a.curOp.updateMaxLine=!0),n.collapsed)G(a,t.line,i.line+1);else if(n.className||n.startStyle||n.endStyle||n.css||n.attributes||n.title)for(let f=t.line;f<=i.line;f++)Ce(a,f,"text");n.atomic&&mn(a.doc),E(a,"markerAdded",a,n)}return n}var ir=class{constructor(t,i){this.markers=t,this.primary=i;for(let r=0;r<t.length;++r)t[r].parent=this}clear(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(let t=0;t<this.markers.length;++t)this.markers[t].clear();E(this,"clear")}}find(t,i){return this.primary.find(t,i)}};Pe(ir);function Ma(e,t,i,r,l){r=We(r),r.shared=!1;let n=[Gt(e,t,i,r,l)],o=n[0],s=r.widgetNode;return De(e,a=>{s&&(r.widgetNode=s.cloneNode(!0)),n.push(Gt(a,L(a,t),L(a,i),r,l));for(let u=0;u<a.linked.length;++u)if(a.linked[u].isParent)return;o=j(n)}),new ir(n,o)}function yn(e){return e.findMarks(x(e.first,0),e.clipPos(x(e.lastLine())),t=>t.parent)}function ss(e,t){for(let i=0;i<t.length;i++){let r=t[i],l=r.find(),n=e.clipPos(l.from),o=e.clipPos(l.to);if(k(n,o)){let s=Gt(e,n,o,r.primary,r.primary.type);r.markers.push(s),s.parent=r}}}function as(e){for(let t=0;t<e.length;t++){let i=e[t],r=[i.primary.doc];De(i.primary.doc,l=>r.push(l));for(let l=0;l<i.markers.length;l++){let n=i.markers[l];_(r,n.doc)==-1&&(n.parent=null,i.markers.splice(l--,1))}}}var Ta=0,at=function(e,t,i,r,l){if(!(this instanceof at))return new at(e,t,i,r,l);i==null&&(i=0),xi.call(this,[new yi([new tt("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;let n=x(i,0);this.sel=we(n),this.history=new Zi(null),this.id=++Ta,this.modeOption=t,this.lineSep=r,this.direction=l=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),qi(this,{from:n,to:n,text:e}),K(this,we(n),V)};at.prototype=yr(xi.prototype,{constructor:at,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){let i=0;for(let r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){let t=Mr(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:Y(function(e){let t=x(this.first,0),i=this.first+this.size-1;st(this,{from:t,to:x(i,C(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&Ft(this.cm,0,0),K(this,we(t),V)}),replaceRange:function(e,t,i,r){t=L(this,t),i=i?L(this,i):t,Ne(this,e,t,i,r)},getRange:function(e,t,i){let r=_e(this,L(this,e),L(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(e){let t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(ct(this,e))return C(this,e)},getLineNumber:function(e){return O(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=C(this,e)),ne(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return L(this,e)},getCursor:function(e){let t=this.sel.primary(),i;return e==null||e=="head"?i=t.head:e=="anchor"?i=t.anchor:e=="end"||e=="to"||e===!1?i=t.to():i=t.from(),i},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Y(function(e,t,i){gn(this,L(this,typeof e=="number"?x(e,t||0):e),null,i)}),setSelection:Y(function(e,t,i){gn(this,L(this,e),L(this,t||e),i)}),extendSelection:Y(function(e,t,i){zt(this,L(this,e),t&&L(this,t),i)}),extendSelections:Y(function(e,t){cn(this,Nl(this,e),t)}),extendSelectionsBy:Y(function(e,t){let i=ht(this.sel.ranges,e);cn(this,Nl(this,i),t)}),setSelections:Y(function(e,t,i){if(!e.length)return;let r=[];for(let l=0;l<e.length;l++)r[l]=new A(L(this,e[l].anchor),L(this,e[l].head||e[l].anchor));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),K(this,pe(this.cm,r,t),i)}),addSelection:Y(function(e,t,i){let r=this.sel.ranges.slice(0);r.push(new A(L(this,e),L(this,t||e))),K(this,pe(this.cm,r,r.length-1),i)}),getSelection:function(e){let t=this.sel.ranges,i;for(let r=0;r<t.length;r++){let l=_e(this,t[r].from(),t[r].to());i=i?i.concat(l):l}return e===!1?i:i.join(e||this.lineSeparator())},getSelections:function(e){let t=[],i=this.sel.ranges;for(let r=0;r<i.length;r++){let l=_e(this,i[r].from(),i[r].to());e!==!1&&(l=l.join(e||this.lineSeparator())),t[r]=l}return t},replaceSelection:function(e,t,i){let r=[];for(let l=0;l<this.sel.ranges.length;l++)r[l]=e;this.replaceSelections(r,t,i||"+input")},replaceSelections:Y(function(e,t,i){let r=[],l=this.sel;for(let o=0;o<l.ranges.length;o++){let s=l.ranges[o];r[o]={from:s.from(),to:s.to(),text:this.splitLines(e[o]),origin:i}}let n=t&&t!="end"&&Go(this,r,t);for(let o=r.length-1;o>=0;o--)st(this,r[o]);n?nl(this,n):this.cm&&Oe(this.cm)}),undo:Y(function(){Vi(this,"undo")}),redo:Y(function(){Vi(this,"redo")}),undoSelection:Y(function(){Vi(this,"undo",!0)}),redoSelection:Y(function(){Vi(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){let e=this.history,t=0,i=0;for(let r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(let r=0;r<e.undone.length;r++)e.undone[r].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){this.history=new Zi(this.history),De(this,e=>e.history=this.history,!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:Rt(this.history.done),undone:Rt(this.history.undone)}},setHistory:function(e){let t=this.history=new Zi(this.history);t.done=Rt(e.done.slice(0),null,!0),t.undone=Rt(e.undone.slice(0),null,!0)},setGutterMarker:Y(function(e,t,i){return Bt(this,e,"gutter",r=>{let l=r.gutterMarkers||(r.gutterMarkers={});return l[t]=i,!i&&Ml(l)&&(r.gutterMarkers=null),!0})}),clearGutter:Y(function(e){this.iter(t=>{t.gutterMarkers&&t.gutterMarkers[e]&&Bt(this,t,"gutter",()=>(t.gutterMarkers[e]=null,Ml(t.gutterMarkers)&&(t.gutterMarkers=null),!0))})}),lineInfo:function(e){let t;if(typeof e=="number"){if(!ct(this,e)||(t=e,e=C(this,e),!e))return null}else if(t=O(e),t==null)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:Y(function(e,t,i){return Bt(this,e,t=="gutter"?"gutter":"class",r=>{let l=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!r[l])r[l]=i;else{if(pt(i).test(r[l]))return!1;r[l]+=" "+i}return!0})}),removeLineClass:Y(function(e,t,i){return Bt(this,e,t=="gutter"?"gutter":"class",r=>{let l=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",n=r[l];if(n)if(i==null)r[l]=null;else{let o=n.match(pt(i));if(!o)return!1;let s=o.index+o[0].length;r[l]=n.slice(0,o.index)+(!o.index||s==n.length?"":" ")+n.slice(s)||null}else return!1;return!0})}),addLineWidget:Y(function(e,t,i){return ns(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return Gt(this,L(this,e),L(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){let i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=L(this,e),Gt(this,e,e,i,"bookmark")},findMarksAt:function(e){e=L(this,e);let t=[],i=C(this,e.line).markedSpans;if(i)for(let r=0;r<i.length;++r){let l=i[r];(l.from==null||l.from<=e.ch)&&(l.to==null||l.to>=e.ch)&&t.push(l.marker.parent||l.marker)}return t},findMarks:function(e,t,i){e=L(this,e),t=L(this,t);let r=[],l=e.line;return this.iter(e.line,t.line+1,n=>{let o=n.markedSpans;if(o)for(let s=0;s<o.length;s++){let a=o[s];!(a.to!=null&&l==e.line&&e.ch>=a.to||a.from==null&&l!=e.line||a.from!=null&&l==t.line&&a.from>=t.ch)&&(!i||i(a.marker))&&r.push(a.marker.parent||a.marker)}++l}),r},getAllMarks:function(){let e=[];return this.iter(t=>{let i=t.markedSpans;if(i)for(let r=0;r<i.length;++r)i[r].from!=null&&e.push(i[r].marker)}),e},posFromIndex:function(e){let t,i=this.first,r=this.lineSeparator().length;return this.iter(l=>{let n=l.text.length+r;if(n>e)return t=e,!0;e-=n,++i}),L(this,x(i,t))},indexFromPos:function(e){e=L(this,e);let t=e.ch;if(e.line<this.first||e.ch<0)return 0;let i=this.lineSeparator().length;return this.iter(this.first,e.line,r=>{t+=r.text.length+i}),t},copy:function(e){let t=new at(Mr(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});let t=this.first,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);let r=new at(Mr(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],ss(r,yn(this)),r},unlinkDoc:function(e){if(e instanceof us&&(e=e.doc),this.linked){for(let t=0;t<this.linked.length;++t)if(this.linked[t].doc==e){this.linked.splice(t,1),e.unlinkDoc(this),as(yn(this));break}}if(e.history==this.history){let t=[e.id];De(e,i=>t.push(i.id),!0),e.history=new Zi(null),e.history.done=Rt(this.history.done,t),e.history.undone=Rt(this.history.undone,t)}},iterLinkedDocs:function(e){De(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Qt(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:Y(function(e){e!="rtl"&&(e="ltr"),e!=this.direction&&(this.direction=e,this.iter(t=>t.order=null),this.cm&&Ko(this.cm))})});at.prototype.eachLine=at.prototype.iter;var Ye=at;var fs=0;function ps(e){let t=this;if(xn(t),R(t,e)||ye(t.display,e))return;U(e),T&&(fs=+new Date);let i=Ie(t,e,!0),r=e.dataTransfer.files;if(!(!i||t.isReadOnly()))if(r&&r.length&&window.FileReader&&window.File){let l=r.length,n=Array(l),o=0,s=()=>{++o==l&&I(t,()=>{i=L(t.doc,i);let u={from:i,to:i,text:t.doc.splitLines(n.filter(f=>f!=null).join(t.doc.lineSeparator())),origin:"paste"};st(t.doc,u),nl(t.doc,we(L(t.doc,i),L(t.doc,Ae(u))))})()},a=(u,f)=>{if(t.options.allowDropFileTypes&&_(t.options.allowDropFileTypes,u.type)==-1){s();return}let p=new FileReader;p.onerror=()=>s(),p.onload=()=>{let h=p.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(h)){s();return}n[f]=h,s()},p.readAsText(u)};for(let u=0;u<r.length;u++)a(r[u],u)}else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(e),setTimeout(()=>t.display.input.focus(),20);return}try{let l=e.dataTransfer.getData("Text");if(l){let n;if(t.state.draggingText&&!t.state.draggingText.copy&&(n=t.listSelections()),ci(t.doc,we(i,i)),n)for(let o=0;o<n.length;++o)Ne(t.doc,"",n[o].anchor,n[o].head,"drag");t.replaceSelection(l,"around","paste"),t.display.input.focus()}}catch(l){}}}function ds(e,t){if(T&&(!e.state.draggingText||+new Date-fs<100)){et(t);return}if(!(R(e,t)||ye(e.display,t))&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!Lt)){let i=v("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",re&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),re&&i.parentNode.removeChild(i)}}function hs(e,t){let i=Ie(e,t);if(!i)return;let r=document.createDocumentFragment();ln(e,i,r),e.display.dragCursor||(e.display.dragCursor=v("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),q(e.display.dragCursor,r)}function xn(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function cs(e){if(!document.getElementsByClassName)return;let t=document.getElementsByClassName("CodeMirror"),i=[];for(let r=0;r<t.length;r++){let l=t[r].CodeMirror;l&&i.push(l)}i.length&&i[0].operation(()=>{for(let r=0;r<i.length;r++)e(i[r])})}var gs=!1;function ms(){gs||(ja(),gs=!0)}function ja(){let e;S(window,"resize",()=>{e==null&&(e=setTimeout(()=>{e=null,cs(Oa)},100))}),S(window,"blur",()=>cs(Ke))}function Oa(e){let t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}var qe={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};for(let e=0;e<10;e++)qe[e+48]=qe[e+96]=String(e);for(let e=65;e<=90;e++)qe[e]=String.fromCharCode(e);for(let e=1;e<=12;e++)qe[e+111]=qe[e+63235]="F"+e;var Ze={};Ze.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"};Ze.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};Ze.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"};Ze.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]};Ze.default=X?Ze.macDefault:Ze.pcDefault;function Aa(e){let t=e.split(/-(?!$)/);e=t[t.length-1];let i,r,l,n;for(let o=0;o<t.length-1;o++){let s=t[o];if(/^(cmd|meta|m)$/i.test(s))n=!0;else if(/^a(lt)?$/i.test(s))i=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))l=!0;else throw new Error("Unrecognized modifier name: "+s)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),n&&(e="Cmd-"+e),l&&(e="Shift-"+e),e}function ys(e){let t={};for(let i in e)if(e.hasOwnProperty(i)){let r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}let l=ht(i.split(" "),Aa);for(let n=0;n<l.length;n++){let o,s;n==l.length-1?(s=l.join(" "),o=r):(s=l.slice(0,n+1).join(" "),o="...");let a=t[s];if(!a)t[s]=o;else if(a!=o)throw new Error("Inconsistent bindings for "+s)}delete e[i]}for(let i in t)e[i]=t[i];return e}function Ct(e,t,i,r){t=bi(t);let l=t.call?t.call(e,r):t[e];if(l===!1)return"nothing";if(l==="...")return"multi";if(l!=null&&i(l))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return Ct(e,t.fallthrough,i,r);for(let n=0;n<t.fallthrough.length;n++){let o=Ct(e,t.fallthrough[n],i,r);if(o)return o}}}function sl(e){let t=typeof e=="string"?e:qe[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function bn(e,t,i){let r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(kl?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(kl?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function al(e,t){if(re&&e.keyCode==34&&e.char)return!1;let i=qe[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),bn(i,e,t))}function bi(e){return typeof e=="string"?Ze[e]:e}function vt(e,t){let i=e.doc.sel.ranges,r=[];for(let l=0;l<i.length;l++){let n=t(i[l]);for(;r.length&&k(n.from,j(r).to)<=0;){let o=r.pop();if(k(o.from,n.from)<0){n.from=o.from;break}}r.push(n)}B(e,()=>{for(let l=r.length-1;l>=0;l--)Ne(e.doc,"",r[l].from,r[l].to,"+delete");Oe(e)})}function Cn(e,t,i){let r=Cr(e.text,t+i,i);return r<0||r>e.text.length?null:r}function ul(e,t,i){let r=Cn(e,t.ch,i);return r==null?null:new x(t.line,r,i<0?"after":"before")}function rr(e,t,i,r,l){if(e){t.doc.direction=="rtl"&&(l=-l);let n=le(i,t.doc.direction);if(n){let o=l<0?j(n):n[0],a=l<0==(o.level==1)?"after":"before",u;if(o.level>0||t.doc.direction=="rtl"){let f=Wt(t,i);u=l<0?i.text.length-1:0;let p=Fe(t,f,u).top;u=jt(h=>Fe(t,f,h).top==p,l<0==(o.level==1)?o.from:o.to-1,u),a=="before"&&(u=Cn(i,u,1))}else u=l<0?o.to:o.from;return new x(r,u,a)}}return new x(r,l<0?i.text.length:0,l<0?"before":"after")}function xs(e,t,i,r){let l=le(t,e.doc.direction);if(!l)return ul(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");let n=Ve(l,i.ch,i.sticky),o=l[n];if(e.doc.direction=="ltr"&&o.level%2==0&&(r>0?o.to>i.ch:o.from<i.ch))return ul(t,i,r);let s=(c,y)=>Cn(t,c instanceof x?c.ch:c,y),a,u=c=>e.options.lineWrapping?(a=a||Wt(e,t),Ir(e,t,a,c)):{begin:0,end:t.text.length},f=u(i.sticky=="before"?s(i,-1):i.ch);if(e.doc.direction=="rtl"||o.level==1){let c=o.level==1==r<0,y=s(i,c?1:-1);if(y!=null&&(c?y<=o.to&&y<=f.end:y>=o.from&&y>=f.begin)){let g=c?"before":"after";return new x(i.line,y,g)}}let p=(c,y,g)=>{let b=(m,M)=>M?new x(i.line,s(m,1),"before"):new x(i.line,m,"after");for(;c>=0&&c<l.length;c+=y){let m=l[c],M=y>0==(m.level!=1),w=M?g.begin:s(g.end,-1);if(m.from<=w&&w<m.to||(w=M?m.from:s(m.to,-1),g.begin<=w&&w<g.end))return b(w,M)}},h=p(n+r,r,f);if(h)return h;let d=r>0?f.end:s(f.begin,-1);return d!=null&&!(r>0&&d==t.text.length)&&(h=p(r>0?0:l.length-1,r,u(d)),h)?h:null}var ut={selectAll:ol,singleSelection:e=>e.setSelection(e.getCursor("anchor"),e.getCursor("head"),V),killLine:e=>vt(e,t=>{if(t.empty()){let i=C(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:x(t.head.line+1,0)}:{from:t.head,to:x(t.head.line,i)}}else return{from:t.from(),to:t.to()}}),deleteLine:e=>vt(e,t=>({from:x(t.from().line,0),to:L(e.doc,x(t.to().line+1,0))})),delLineLeft:e=>vt(e,t=>({from:x(t.from().line,0),to:t.from()})),delWrappedLineLeft:e=>vt(e,t=>{let i=e.charCoords(t.head,"div").top+5;return{from:e.coordsChar({left:0,top:i},"div"),to:t.from()}}),delWrappedLineRight:e=>vt(e,t=>{let i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:r}}),undo:e=>e.undo(),redo:e=>e.redo(),undoSelection:e=>e.undoSelection(),redoSelection:e=>e.redoSelection(),goDocStart:e=>e.extendSelection(x(e.firstLine(),0)),goDocEnd:e=>e.extendSelection(x(e.lastLine())),goLineStart:e=>e.extendSelectionsBy(t=>bs(e,t.head.line),{origin:"+move",bias:1}),goLineStartSmart:e=>e.extendSelectionsBy(t=>Cs(e,t.head),{origin:"+move",bias:1}),goLineEnd:e=>e.extendSelectionsBy(t=>Da(e,t.head.line),{origin:"+move",bias:-1}),goLineRight:e=>e.extendSelectionsBy(t=>{let i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Tt),goLineLeft:e=>e.extendSelectionsBy(t=>{let i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},Tt),goLineLeftSmart:e=>e.extendSelectionsBy(t=>{let i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?Cs(e,t.head):r},Tt),goLineUp:e=>e.moveV(-1,"line"),goLineDown:e=>e.moveV(1,"line"),goPageUp:e=>e.moveV(-1,"page"),goPageDown:e=>e.moveV(1,"page"),goCharLeft:e=>e.moveH(-1,"char"),goCharRight:e=>e.moveH(1,"char"),goColumnLeft:e=>e.moveH(-1,"column"),goColumnRight:e=>e.moveH(1,"column"),goWordLeft:e=>e.moveH(-1,"word"),goGroupRight:e=>e.moveH(1,"group"),goGroupLeft:e=>e.moveH(-1,"group"),goWordRight:e=>e.moveH(1,"word"),delCharBefore:e=>e.deleteH(-1,"codepoint"),delCharAfter:e=>e.deleteH(1,"char"),delWordBefore:e=>e.deleteH(-1,"word"),delWordAfter:e=>e.deleteH(1,"word"),delGroupBefore:e=>e.deleteH(-1,"group"),delGroupAfter:e=>e.deleteH(1,"group"),indentAuto:e=>e.indentSelection("smart"),indentMore:e=>e.indentSelection("add"),indentLess:e=>e.indentSelection("subtract"),insertTab:e=>e.replaceSelection(" "),insertSoftTab:e=>{let t=[],i=e.listSelections(),r=e.options.tabSize;for(let l=0;l<i.length;l++){let n=i[l].from(),o=Z(e.getLine(n.line),n.ch,r);t.push(Yt(r-o%r))}e.replaceSelections(t)},defaultTab:e=>{e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:e=>B(e,()=>{let t=e.listSelections(),i=[];for(let r=0;r<t.length;r++){if(!t[r].empty())continue;let l=t[r].head,n=C(e.doc,l.line).text;if(n){if(l.ch==n.length&&(l=new x(l.line,l.ch-1)),l.ch>0)l=new x(l.line,l.ch+1),e.replaceRange(n.charAt(l.ch-1)+n.charAt(l.ch-2),x(l.line,l.ch-2),l,"+transpose");else if(l.line>e.doc.first){let o=C(e.doc,l.line-1).text;o&&(l=new x(l.line,1),e.replaceRange(n.charAt(0)+e.doc.lineSeparator()+o.charAt(o.length-1),x(l.line-1,o.length-1),l,"+transpose"))}}i.push(new A(l,l))}e.setSelections(i)}),newlineAndIndent:e=>B(e,()=>{let t=e.listSelections();for(let i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(let i=0;i<t.length;i++)e.indentLine(t[i].from().line,null,!0);Oe(e)}),openLine:e=>e.replaceSelection(`
`,"start"),toggleOverwrite:e=>e.toggleOverwrite()};function bs(e,t){let i=C(e.doc,t),r=ne(i);return r!=i&&(t=O(r)),rr(!0,e,r,t,1)}function Da(e,t){let i=C(e.doc,t),r=uo(i);return r!=i&&(t=O(r)),rr(!0,e,i,t,-1)}function Cs(e,t){let i=bs(e,t.line),r=C(e.doc,i.line),l=le(r,e.doc.direction);if(!l||l[0].level==0){let n=Math.max(i.ch,r.text.search(/\S/)),o=t.line==i.line&&t.ch<=n&&t.ch;return x(i.line,o?0:n,i.sticky)}return i}function fl(e,t,i){if(typeof t=="string"&&(t=ut[t],!t))return!1;e.display.input.ensurePolled();let r=e.display.shift,l=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),l=t(e)!=dt}finally{e.display.shift=r,e.state.suppressEdits=!1}return l}function Na(e,t,i){for(let r=0;r<e.state.keyMaps.length;r++){let l=Ct(t,e.state.keyMaps[r],i,e);if(l)return l}return e.options.extraKeys&&Ct(t,e.options.extraKeys,i,e)||Ct(t,e.options.keyMap,i,e)}var Ha=new ke;function Ci(e,t,i,r){let l=e.state.keySeq;if(l){if(sl(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Ha.set(50,()=>{e.state.keySeq==l&&(e.state.keySeq=null,e.display.input.reset())}),vs(e,l+" "+t,i,r))return!0}return vs(e,t,i,r)}function vs(e,t,i,r){let l=Na(e,t,r);return l=="multi"&&(e.state.keySeq=t),l=="handled"&&E(e,"keyHandled",e,t,i),(l=="handled"||l=="multi")&&(U(i),ai(e)),!!l}function ws(e,t){let i=al(t,!0);return i?t.shiftKey&&!e.state.keySeq?Ci(e,"Shift-"+i,t,r=>fl(e,r,!0))||Ci(e,i,t,r=>{if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return fl(e,r)}):Ci(e,i,t,r=>fl(e,r)):!1}function Wa(e,t,i){return Ci(e,"'"+i+"'",t,r=>fl(e,r,!0))}var vn=null;function pl(e){let t=this;if(e.target&&e.target!=t.display.input.getField()||(t.curOp.focus=$(),R(t,e)))return;T&&N<11&&e.keyCode==27&&(e.returnValue=!1);let i=e.keyCode;t.display.shift=i==16||e.shiftKey;let r=ws(t,e);re&&(vn=r?i:null,!r&&i==88&&!Un&&(X?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),he&&!X&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Pa(t)}function Pa(e){let t=e.display.lineDiv;ge(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(ce(t,"CodeMirror-crosshair"),Q(document,"keyup",i),Q(document,"mouseover",i))}S(document,"keyup",i),S(document,"mouseover",i)}function dl(e){e.keyCode==16&&(this.doc.sel.shift=!1),R(this,e)}function hl(e){let t=this;if(e.target&&e.target!=t.display.input.getField()||ye(t.display,e)||R(t,e)||e.ctrlKey&&!e.altKey||X&&e.metaKey)return;let i=e.keyCode,r=e.charCode;if(re&&i==vn){vn=null,U(e);return}if(re&&(!e.which||e.which<10)&&ws(t,e))return;let l=String.fromCharCode(r??i);l!="\b"&&(Wa(t,e,l)||t.display.input.onKeyPress(e))}var _a=400,wn=class{constructor(t,i,r){this.time=t,this.pos=i,this.button=r}compare(t,i,r){return this.time+_a>t&&k(i,this.pos)==0&&r==this.button}},lr,nr;function Ea(e,t){let i=+new Date;return nr&&nr.compare(i,e,t)?(lr=nr=null,"triple"):lr&&lr.compare(i,e,t)?(nr=new wn(i,e,t),lr=null,"double"):(lr=new wn(i,e,t),nr=null,"single")}function gl(e){let t=this,i=t.display;if(R(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,ye(i,e)){z||(i.scroller.draggable=!1,setTimeout(()=>i.scroller.draggable=!0,100));return}if(cl(t,e))return;let r=Ie(t,e),l=jl(e),n=r?Ea(r,l):"single";window.focus(),l==1&&t.state.selectingText&&t.state.selectingText(e),!(r&&Fa(t,l,r,n,e))&&(l==1?r?Ia(t,r,n,e):Zt(e)==i.scroller&&U(e):l==2?(r&&zt(t.doc,r),setTimeout(()=>i.input.focus(),20)):l==3&&(ki?t.display.input.onContextMenu(e):Kr(t)))}function Fa(e,t,i,r,l){let n="Click";return r=="double"?n="Double"+n:r=="triple"&&(n="Triple"+n),n=(t==1?"Left":t==2?"Middle":"Right")+n,Ci(e,bn(n,l),l,o=>{if(typeof o=="string"&&(o=ut[o]),!o)return!1;let s=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),s=o(e,i)!=dt}finally{e.state.suppressEdits=!1}return s})}function Ra(e,t,i){let r=e.getOption("configureMouse"),l=r?r(e,t,i):{};if(l.unit==null){let n=Wn?i.shiftKey&&i.metaKey:i.altKey;l.unit=n?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(l.extend==null||e.doc.extend)&&(l.extend=e.doc.extend||i.shiftKey),l.addNew==null&&(l.addNew=X?i.metaKey:i.ctrlKey),l.moveOnDrag==null&&(l.moveOnDrag=!(X?i.altKey:i.ctrlKey)),l}function Ia(e,t,i,r){T?setTimeout(Mi(Ur,e),0):e.curOp.focus=$();let l=Ra(e,i,r),n=e.doc.sel,o;e.options.dragDrop&&Rn&&!e.isReadOnly()&&i=="single"&&(o=n.contains(t))>-1&&(k((o=n.ranges[o]).from(),t)<0||t.xRel>0)&&(k(o.to(),t)>0||t.xRel<0)?za(e,r,t,l):Ba(e,r,t,l)}function za(e,t,i,r){let l=e.display,n=!1,o=I(e,u=>{z&&(l.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:Kr(e)),Q(l.wrapper.ownerDocument,"mouseup",o),Q(l.wrapper.ownerDocument,"mousemove",s),Q(l.scroller,"dragstart",a),Q(l.scroller,"drop",o),n||(U(u),r.addNew||zt(e.doc,i,null,null,r.extend),z&&!Lt||T&&N==9?setTimeout(()=>{l.wrapper.ownerDocument.body.focus({preventScroll:!0}),l.input.focus()},20):l.input.focus())}),s=function(u){n=n||Math.abs(t.clientX-u.clientX)+Math.abs(t.clientY-u.clientY)>=10},a=()=>n=!0;z&&(l.scroller.draggable=!0),e.state.draggingText=o,o.copy=!r.moveOnDrag,S(l.wrapper.ownerDocument,"mouseup",o),S(l.wrapper.ownerDocument,"mousemove",s),S(l.scroller,"dragstart",a),S(l.scroller,"drop",o),e.state.delayingBlurEvent=!0,setTimeout(()=>l.input.focus(),20),l.scroller.dragDrop&&l.scroller.dragDrop()}function Ss(e,t,i){if(i=="char")return new A(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new A(x(t.line,0),L(e.doc,x(t.line+1,0)));let r=i(e,t);return new A(r.from,r.to)}function Ba(e,t,i,r){T&&Kr(e);let l=e.display,n=e.doc;U(t);let o,s,a=n.sel,u=a.ranges;if(r.addNew&&!r.extend?(s=n.sel.contains(i),s>-1?o=u[s]:o=new A(i,i)):(o=n.sel.primary(),s=n.sel.primIndex),r.unit=="rectangle")r.addNew||(o=new A(i,i)),i=Ie(e,t,!0,!0),s=-1;else{let m=Ss(e,i,r.unit);r.extend?o=ll(o,m.anchor,m.head,r.extend):o=m}r.addNew?s==-1?(s=u.length,K(n,pe(e,u.concat([o]),s),{scroll:!1,origin:"*mouse"})):u.length>1&&u[s].empty()&&r.unit=="char"&&!r.extend?(K(n,pe(e,u.slice(0,s).concat(u.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),a=n.sel):hi(n,s,o,gr):(s=0,K(n,new fe([o],0),gr),a=n.sel);let f=i;function p(m){if(k(f,m)!=0)if(f=m,r.unit=="rectangle"){let M=[],w=e.options.tabSize,D=Z(C(n,i.line).text,i.ch,w),H=Z(C(n,m.line).text,m.ch,w),W=Math.min(D,H),de=Math.max(D,H);for(let ie=Math.min(i.line,m.line),ze=Math.min(e.lastLine(),Math.max(i.line,m.line));ie<=ze;ie++){let Be=C(n,ie).text,xe=Ti(Be,W,w);W==de?M.push(new A(x(ie,xe),x(ie,xe))):Be.length>xe&&M.push(new A(x(ie,xe),x(ie,Ti(Be,de,w))))}M.length||M.push(new A(i,i)),K(n,pe(e,a.ranges.slice(0,s).concat(M),s),{origin:"*mouse",scroll:!1}),e.scrollIntoView(m)}else{let M=o,w=Ss(e,m,r.unit),D=M.anchor,H;k(w.anchor,D)>0?(H=w.head,D=Nt(M.from(),w.anchor)):(H=w.anchor,D=Dt(M.to(),w.head));let W=a.ranges.slice(0);W[s]=Ga(e,new A(L(n,D),H)),K(n,pe(e,W,s),gr)}}let h=l.wrapper.getBoundingClientRect(),d=0;function c(m){let M=++d,w=Ie(e,m,!0,r.unit=="rectangle");if(!!w)if(k(w,f)!=0){e.curOp.focus=$(),p(w);let D=ui(l,n);(w.line>=D.to||w.line<D.from)&&setTimeout(I(e,()=>{d==M&&c(m)}),150)}else{let D=m.clientY<h.top?-20:m.clientY>h.bottom?20:0;D&&setTimeout(I(e,()=>{d==M&&(l.scroller.scrollTop+=D,c(m))}),50)}}function y(m){e.state.selectingText=!1,d=Infinity,m&&(U(m),l.input.focus()),Q(l.wrapper.ownerDocument,"mousemove",g),Q(l.wrapper.ownerDocument,"mouseup",b),n.history.lastSelOrigin=null}let g=I(e,m=>{m.buttons===0||!jl(m)?y(m):c(m)}),b=I(e,y);e.state.selectingText=b,S(l.wrapper.ownerDocument,"mousemove",g),S(l.wrapper.ownerDocument,"mouseup",b)}function Ga(e,t){let{anchor:i,head:r}=t,l=C(e.doc,i.line);if(k(i,r)==0&&i.sticky==r.sticky)return t;let n=le(l);if(!n)return t;let o=Ve(n,i.ch,i.sticky),s=n[o];if(s.from!=i.ch&&s.to!=i.ch)return t;let a=o+(s.from==i.ch==(s.level!=1)?0:1);if(a==0||a==n.length)return t;let u;if(r.line!=i.line)u=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{let c=Ve(n,r.ch,r.sticky),y=c-o||(r.ch-i.ch)*(s.level==1?-1:1);c==a-1||c==a?u=y<0:u=y>0}let f=n[a+(u?-1:0)],p=u==(f.level==1),h=p?f.from:f.to,d=p?"after":"before";return i.ch==h&&i.sticky==d?t:new A(new x(i.line,h,d),r)}function Ls(e,t,i,r){let l,n;if(t.touches)l=t.touches[0].clientX,n=t.touches[0].clientY;else try{l=t.clientX,n=t.clientY}catch(a){return!1}if(l>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&U(t);let o=e.display,s=o.lineDiv.getBoundingClientRect();if(n>s.bottom||!ee(e,i))return wr(t);n-=s.top-o.viewOffset;for(let a=0;a<e.display.gutterSpecs.length;++a){let u=o.gutters.childNodes[a];if(u&&u.getBoundingClientRect().right>=l){let f=Ee(e.doc,n),p=e.display.gutterSpecs[a];return P(e,i,e,f,p.className,t),wr(t)}}}function cl(e,t){return Ls(e,t,"gutterClick",!0)}function Sn(e,t){ye(e.display,t)||Ua(e,t)||R(e,t,"contextmenu")||ki||e.display.input.onContextMenu(t)}function Ua(e,t){return ee(e,"gutterContextMenu")?Ls(e,t,"gutterContextMenu",!1):!1}function ml(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),xt(e)}var Ut={toString:function(){return"CodeMirror.Init"}},Ln={},or={};function ks(e){let t=e.optionHandlers;function i(r,l,n,o){e.defaults[r]=l,n&&(t[r]=o?(s,a,u)=>{u!=Ut&&n(s,a,u)}:n)}e.defineOption=i,e.Init=Ut,i("value","",(r,l)=>r.setValue(l),!0),i("mode",null,(r,l)=>{r.doc.modeOption=l,Yi(r)},!0),i("indentUnit",2,Yi,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,r=>{di(r),xt(r),G(r)},!0),i("lineSeparator",null,(r,l)=>{if(r.doc.lineSep=l,!l)return;let n=[],o=r.doc.first;r.doc.iter(s=>{for(let a=0;;){let u=s.text.indexOf(l,a);if(u==-1)break;a=u+l.length,n.push(x(o,u))}o++});for(let s=n.length-1;s>=0;s--)Ne(r.doc,l,n[s],x(n[s].line,n[s].ch+l.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,(r,l,n)=>{r.state.specialChars=new RegExp(l.source+(l.test(" ")?"":"| "),"g"),n!=Ut&&r.refresh()}),i("specialCharPlaceholder",go,r=>r.refresh(),!0),i("electricChars",!0),i("inputStyle",Qe?"contenteditable":"textarea",()=>{throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,(r,l)=>r.getInputField().spellcheck=l,!0),i("autocorrect",!1,(r,l)=>r.getInputField().autocorrect=l,!0),i("autocapitalize",!1,(r,l)=>r.getInputField().autocapitalize=l,!0),i("rtlMoveVisually",!Pn),i("wholeLineUpdateBefore",!0),i("theme","default",r=>{ml(r),pi(r)},!0),i("keyMap","default",(r,l,n)=>{let o=bi(l),s=n!=Ut&&bi(n);s&&s.detach&&s.detach(r,o),o.attach&&o.attach(r,s||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Xa,!0),i("gutters",[],(r,l)=>{r.display.gutterSpecs=$i(l,r.options.lineNumbers),pi(r)},!0),i("fixedGutter",!0,(r,l)=>{r.display.gutters.style.left=l?Ui(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,r=>ot(r),!0),i("scrollbarStyle","native",r=>{Yr(r),ot(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,(r,l)=>{r.display.gutterSpecs=$i(r.options.gutters,l),pi(r)},!0),i("firstLineNumber",1,pi,!0),i("lineNumberFormatter",r=>r,pi,!0),i("showCursorWhenSelecting",!1,_t,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,(r,l)=>{l=="nocursor"&&(Ke(r),r.display.input.blur()),r.display.input.readOnlyChanged(l)}),i("screenReaderLabel",null,(r,l)=>{l=l===""?null:l,r.display.input.screenReaderLabelChanged(l)}),i("disableInput",!1,(r,l)=>{l||r.display.input.reset()},!0),i("dragDrop",!0,Ka),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,_t,!0),i("singleCursorHeightPerLine",!0,_t,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,di,!0),i("addModeClass",!1,di,!0),i("pollInterval",100),i("undoDepth",200,(r,l)=>r.doc.history.undoDepth=l),i("historyEventDelay",1250),i("viewportMargin",10,r=>r.refresh(),!0),i("maxHighlightLength",1e4,di,!0),i("moveInputWithCursor",!0,(r,l)=>{l||r.display.input.resetPosition()}),i("tabindex",null,(r,l)=>r.display.input.getField().tabIndex=l||""),i("autofocus",null),i("direction","ltr",(r,l)=>r.doc.setDirection(l),!0),i("phrases",null)}function Ka(e,t,i){let r=i&&i!=Ut;if(!t!=!r){let l=e.display.dragFunctions,n=t?S:Q;n(e.display.scroller,"dragstart",l.start),n(e.display.scroller,"dragenter",l.enter),n(e.display.scroller,"dragover",l.over),n(e.display.scroller,"dragleave",l.leave),n(e.display.scroller,"drop",l.drop)}}function Xa(e){e.options.lineWrapping?(ge(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(ce(e.display.wrapper,"CodeMirror-wrap"),ii(e)),si(e),G(e),xt(e),setTimeout(()=>ot(e),100)}function F(e,t){if(!(this instanceof F))return new F(e,t);this.options=t=t?We(t):{},We(Ln,t,!1);let i=t.value;typeof i=="string"?i=new Ye(i,t.mode,null,t.lineSeparator,t.direction):t.mode&&(i.modeOption=t.mode),this.doc=i;let r=new F.inputStyles[t.inputStyle](this),l=this.display=new Fo(e,i,r,t);l.wrapper.CodeMirror=this,ml(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Yr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new ke,keySeq:null,specialChars:null},t.autofocus&&!Qe&&l.input.focus(),T&&N<11&&setTimeout(()=>this.display.input.reset(!0),20),$a(this),ms(),Xe(this),this.curOp.forceUpdate=!0,tl(this,i),t.autofocus&&!Qe||this.hasFocus()?setTimeout(()=>{this.hasFocus()&&!this.state.focused&&Gr(this)},20):Ke(this);for(let n in or)or.hasOwnProperty(n)&&or[n](this,t[n],Ut);Jr(this),t.finishInit&&t.finishInit(this);for(let n=0;n<kn.length;++n)kn[n](this);$e(this),z&&t.lineWrapping&&getComputedStyle(l.lineDiv).textRendering=="optimizelegibility"&&(l.lineDiv.style.textRendering="auto")}F.defaults=Ln;F.optionHandlers=or;var us=F;function $a(e){let t=e.display;S(t.scroller,"mousedown",I(e,gl)),T&&N<11?S(t.scroller,"dblclick",I(e,a=>{if(R(e,a))return;let u=Ie(e,a);if(!u||cl(e,a)||ye(e.display,a))return;U(a);let f=e.findWordAt(u);zt(e.doc,f.anchor,f.head)})):S(t.scroller,"dblclick",a=>R(e,a)||U(a)),S(t.scroller,"contextmenu",a=>Sn(e,a)),S(t.input.getField(),"contextmenu",a=>{t.scroller.contains(a.target)||Sn(e,a)});let i,r={end:0};function l(){t.activeTouch&&(i=setTimeout(()=>t.activeTouch=null,1e3),r=t.activeTouch,r.end=+new Date)}function n(a){if(a.touches.length!=1)return!1;let u=a.touches[0];return u.radiusX<=1&&u.radiusY<=1}function o(a,u){if(u.left==null)return!0;let f=u.left-a.left,p=u.top-a.top;return f*f+p*p>20*20}S(t.scroller,"touchstart",a=>{if(!R(e,a)&&!n(a)&&!cl(e,a)){t.input.ensurePolled(),clearTimeout(i);let u=+new Date;t.activeTouch={start:u,moved:!1,prev:u-r.end<=300?r:null},a.touches.length==1&&(t.activeTouch.left=a.touches[0].pageX,t.activeTouch.top=a.touches[0].pageY)}}),S(t.scroller,"touchmove",()=>{t.activeTouch&&(t.activeTouch.moved=!0)}),S(t.scroller,"touchend",a=>{let u=t.activeTouch;if(u&&!ye(t,a)&&u.left!=null&&!u.moved&&new Date-u.start<300){let f=e.coordsChar(t.activeTouch,"page"),p;!u.prev||o(u,u.prev)?p=new A(f,f):!u.prev.prev||o(u,u.prev.prev)?p=e.findWordAt(f):p=new A(x(f.line,0),L(e.doc,x(f.line+1,0))),e.setSelection(p.anchor,p.head),e.focus(),U(a)}l()}),S(t.scroller,"touchcancel",l),S(t.scroller,"scroll",()=>{t.scroller.clientHeight&&(bt(e,t.scroller.scrollTop),Re(e,t.scroller.scrollLeft,!0),P(e,"scroll",e))}),S(t.scroller,"mousewheel",a=>pn(e,a)),S(t.scroller,"DOMMouseScroll",a=>pn(e,a)),S(t.wrapper,"scroll",()=>t.wrapper.scrollTop=t.wrapper.scrollLeft=0),t.dragFunctions={enter:a=>{R(e,a)||et(a)},over:a=>{R(e,a)||(hs(e,a),et(a))},start:a=>ds(e,a),drop:I(e,ps),leave:a=>{R(e,a)||xn(e)}};let s=t.input.getField();S(s,"keyup",a=>dl.call(e,a)),S(s,"keydown",I(e,pl)),S(s,"keypress",I(e,hl)),S(s,"focus",a=>Gr(e,a)),S(s,"blur",a=>Ke(e,a))}var kn=[];F.defineInitHook=e=>kn.push(e);function Kt(e,t,i,r){let l=e.doc,n;i==null&&(i="add"),i=="smart"&&(l.mode.indent?n=gt(e,t).state:i="prev");let o=e.options.tabSize,s=C(l,t),a=Z(s.text,null,o);s.stateAfter&&(s.stateAfter=null);let u=s.text.match(/^\s*/)[0],f;if(!r&&!/\S/.test(s.text))f=0,i="not";else if(i=="smart"&&(f=l.mode.indent(n,s.text.slice(u.length),s.text),f==dt||f>150)){if(!r)return;i="prev"}i=="prev"?t>l.first?f=Z(C(l,t-1).text,null,o):f=0:i=="add"?f=a+e.options.indentUnit:i=="subtract"?f=a-e.options.indentUnit:typeof i=="number"&&(f=a+i),f=Math.max(0,f);let p="",h=0;if(e.options.indentWithTabs)for(let d=Math.floor(f/o);d;--d)h+=o,p+=" ";if(h<f&&(p+=Yt(f-h)),p!=u)return Ne(l,p,x(t,0),x(t,u.length),"+input"),s.stateAfter=null,!0;for(let d=0;d<l.sel.ranges.length;d++){let c=l.sel.ranges[d];if(c.head.line==t&&c.head.ch<u.length){let y=x(t,u.length);hi(l,d,new A(y,y));break}}}var He=null;function vi(e){He=e}function sr(e,t,i,r,l){let n=e.doc;e.display.shift=!1,r||(r=n.sel);let o=+new Date-200,s=l=="paste"||e.state.pasteIncoming>o,a=Qt(t),u=null;if(s&&r.ranges.length>1)if(He&&He.text.join(`
`)==t){if(r.ranges.length%He.text.length==0){u=[];for(let p=0;p<He.text.length;p++)u.push(n.splitLines(He.text[p]))}}else a.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(u=ht(a,p=>[p]));let f=e.curOp.updateInput;for(let p=r.ranges.length-1;p>=0;p--){let h=r.ranges[p],d=h.from(),c=h.to();h.empty()&&(i&&i>0?d=x(d.line,d.ch-i):e.state.overwrite&&!s?c=x(c.line,Math.min(C(n,c.line).text.length,c.ch+j(a).length)):s&&He&&He.lineWise&&He.text.join(`
`)==a.join(`
`)&&(d=c=x(d.line,0)));let y={from:d,to:c,text:u?u[p%u.length]:a,origin:l||(s?"paste":e.state.cutIncoming>o?"cut":"+input")};st(e.doc,y),E(e,"inputRead",e,y)}t&&!s&&Mn(e,t),Oe(e),e.curOp.updateInput<2&&(e.curOp.updateInput=f),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function yl(e,t){let i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&B(t,()=>sr(t,i,0,null,"paste")),!0}function Mn(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;let i=e.doc.sel;for(let r=i.ranges.length-1;r>=0;r--){let l=i.ranges[r];if(l.head.ch>100||r&&i.ranges[r-1].head.line==l.head.line)continue;let n=e.getModeAt(l.head),o=!1;if(n.electricChars){for(let s=0;s<n.electricChars.length;s++)if(t.indexOf(n.electricChars.charAt(s))>-1){o=Kt(e,l.head.line,"smart");break}}else n.electricInput&&n.electricInput.test(C(e.doc,l.head.line).text.slice(0,l.head.ch))&&(o=Kt(e,l.head.line,"smart"));o&&E(e,"electricInput",e,l.head.line)}}function xl(e){let t=[],i=[];for(let r=0;r<e.doc.sel.ranges.length;r++){let l=e.doc.sel.ranges[r].head.line,n={anchor:x(l,0),head:x(l+1,0)};i.push(n),t.push(e.getRange(n.anchor,n.head))}return{text:t,ranges:i}}function Tn(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function bl(){let e=v("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=v("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return z?e.style.width="1000px":e.setAttribute("wrap","off"),ft&&(e.style.border="1px solid black"),Tn(e),t}function Ts(e){let t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,l){let n=this.options,o=n[r];n[r]==l&&r!="mode"||(n[r]=l,t.hasOwnProperty(r)&&I(this,t[r])(this,l,o),P(this,"optionChange",this,r))},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,l){this.state.keyMaps[l?"push":"unshift"](bi(r))},removeKeyMap:function(r){let l=this.state.keyMaps;for(let n=0;n<l.length;++n)if(l[n]==r||l[n].name==r)return l.splice(n,1),!0},addOverlay:te(function(r,l){let n=r.token?r:e.getMode(this.options,r);if(n.startState)throw new Error("Overlays may not be stateful.");_n(this.state.overlays,{mode:n,modeSpec:r,opaque:l&&l.opaque,priority:l&&l.priority||0},o=>o.priority),this.state.modeGen++,G(this)}),removeOverlay:te(function(r){let l=this.state.overlays;for(let n=0;n<l.length;++n){let o=l[n].modeSpec;if(o==r||typeof r=="string"&&o.name==r){l.splice(n,1),this.state.modeGen++,G(this);return}}}),indentLine:te(function(r,l,n){typeof l!="string"&&typeof l!="number"&&(l==null?l=this.options.smartIndent?"smart":"prev":l=l?"add":"subtract"),ct(this.doc,r)&&Kt(this,r,l,n)}),indentSelection:te(function(r){let l=this.doc.sel.ranges,n=-1;for(let o=0;o<l.length;o++){let s=l[o];if(s.empty())s.head.line>n&&(Kt(this,s.head.line,r,!0),n=s.head.line,o==this.doc.sel.primIndex&&Oe(this));else{let a=s.from(),u=s.to(),f=Math.max(n,a.line);n=Math.min(this.lastLine(),u.line-(u.ch?0:1))+1;for(let h=f;h<n;++h)Kt(this,h,r);let p=this.doc.sel.ranges;a.ch==0&&l.length==p.length&&p[o].from().ch>0&&hi(this.doc,o,new A(a,p[o].to()),V)}}}),getTokenAt:function(r,l){return _l(this,r,l)},getLineTokens:function(r,l){return _l(this,x(r),l,!0)},getTokenTypeAt:function(r){r=L(this.doc,r);let l=jr(this,C(this.doc,r.line)),n=0,o=(l.length-1)/2,s=r.ch,a;if(s==0)a=l[2];else for(;;){let f=n+o>>1;if((f?l[f*2-1]:0)>=s)o=f;else if(l[f*2+1]<s)n=f+1;else{a=l[f*2+2];break}}let u=a?a.indexOf("overlay "):-1;return u<0?a:u==0?null:a.slice(0,u-1)},getModeAt:function(r){let l=this.doc.mode;return l.innerMode?e.innerMode(l,this.getTokenAt(r).state).mode:l},getHelper:function(r,l){return this.getHelpers(r,l)[0]},getHelpers:function(r,l){let n=[];if(!i.hasOwnProperty(l))return n;let o=i[l],s=this.getModeAt(r);if(typeof s[l]=="string")o[s[l]]&&n.push(o[s[l]]);else if(s[l])for(let a=0;a<s[l].length;a++){let u=o[s[l][a]];u&&n.push(u)}else s.helperType&&o[s.helperType]?n.push(o[s.helperType]):o[s.name]&&n.push(o[s.name]);for(let a=0;a<o._global.length;a++){let u=o._global[a];u.pred(s,this)&&_(n,u.val)==-1&&n.push(u.val)}return n},getStateAfter:function(r,l){let n=this.doc;return r=Tr(n,r??n.first+n.size-1),gt(this,r+1,l).state},cursorCoords:function(r,l){let n,o=this.doc.sel.primary();return r==null?n=o.head:typeof r=="object"?n=L(this.doc,r):n=r?o.from():o.to(),ue(this,n,l||"page")},charCoords:function(r,l){return Gi(this,L(this.doc,r),l||"page")},coordsChar:function(r,l){return r=Ql(this,r,l||"page"),Fr(this,r.left,r.top)},lineAtHeight:function(r,l){return r=Ql(this,{top:r,left:0},l||"page").top,Ee(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,l,n){let o=!1,s;if(typeof r=="number"){let a=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>a&&(r=a,o=!0),s=C(this.doc,r)}else s=r;return Bi(this,s,{top:0,left:0},l||"page",n||o).top+(o?this.doc.height-me(s):0)},defaultTextHeight:function(){return rt(this.display)},defaultCharWidth:function(){return yt(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,l,n,o,s){let a=this.display;r=ue(this,L(this.doc,r));let u=r.bottom,f=r.left;if(l.style.position="absolute",l.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(l),a.sizer.appendChild(l),o=="over")u=r.top;else if(o=="above"||o=="near"){let p=Math.max(a.wrapper.clientHeight,this.doc.height),h=Math.max(a.sizer.clientWidth,a.lineSpace.clientWidth);(o=="above"||r.bottom+l.offsetHeight>p)&&r.top>l.offsetHeight?u=r.top-l.offsetHeight:r.bottom+l.offsetHeight<=p&&(u=r.bottom),f+l.offsetWidth>h&&(f=h-l.offsetWidth)}l.style.top=u+"px",l.style.left=l.style.right="",s=="right"?(f=a.sizer.clientWidth-l.offsetWidth,l.style.right="0px"):(s=="left"?f=0:s=="middle"&&(f=(a.sizer.clientWidth-l.offsetWidth)/2),l.style.left=f+"px"),n&&No(this,{left:f,top:u,right:f+l.offsetWidth,bottom:u+l.offsetHeight})},triggerOnKeyDown:te(pl),triggerOnKeyPress:te(hl),triggerOnKeyUp:dl,triggerOnMouseDown:te(gl),execCommand:function(r){if(ut.hasOwnProperty(r))return ut[r].call(null,this)},triggerElectric:te(function(r){Mn(this,r)}),findPosH:function(r,l,n,o){let s=1;l<0&&(s=-1,l=-l);let a=L(this.doc,r);for(let u=0;u<l&&(a=jn(this.doc,a,s,n,o),!a.hitSide);++u);return a},moveH:te(function(r,l){this.extendSelectionsBy(n=>this.display.shift||this.doc.extend||n.empty()?jn(this.doc,n.head,r,l,this.options.rtlMoveVisually):r<0?n.from():n.to(),Tt)}),deleteH:te(function(r,l){let n=this.doc.sel,o=this.doc;n.somethingSelected()?o.replaceSelection("",null,"+delete"):vt(this,s=>{let a=jn(o,s.head,r,l,!1);return r<0?{from:a,to:s.head}:{from:s.head,to:a}})}),findPosV:function(r,l,n,o){let s=1,a=o;l<0&&(s=-1,l=-l);let u=L(this.doc,r);for(let f=0;f<l;++f){let p=ue(this,u,"div");if(a==null?a=p.left:p.left=a,u=Ms(this,p,s,n),u.hitSide)break}return u},moveV:te(function(r,l){let n=this.doc,o=[],s=!this.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(a=>{if(s)return r<0?a.from():a.to();let u=ue(this,a.head,"div");a.goalColumn!=null&&(u.left=a.goalColumn),o.push(u.left);let f=Ms(this,u,r,l);return l=="page"&&a==n.sel.primary()&&Xi(this,Gi(this,f,"div").top-u.top),f},Tt),o.length)for(let a=0;a<n.sel.ranges.length;a++)n.sel.ranges[a].goalColumn=o[a]}),findWordAt:function(r){let l=this.doc,n=C(l,r.line).text,o=r.ch,s=r.ch;if(n){let a=this.getHelper(r,"wordChars");(r.sticky=="before"||s==n.length)&&o?--o:++s;let u=n.charAt(o),f=ji(u,a)?p=>ji(p,a):/\s/.test(u)?p=>/\s/.test(p):p=>!/\s/.test(p)&&!ji(p);for(;o>0&&f(n.charAt(o-1));)--o;for(;s<n.length&&f(n.charAt(s));)++s}return new A(x(r.line,o),x(r.line,s))},toggleOverwrite:function(r){r!=null&&r==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?ge(this.display.cursorDiv,"CodeMirror-overwrite"):ce(this.display.cursorDiv,"CodeMirror-overwrite"),P(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==$()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:te(function(r,l){Ft(this,r,l)}),getScrollInfo:function(){let r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-ae(this)-this.display.barHeight,width:r.scrollWidth-ae(this)-this.display.barWidth,clientHeight:oi(this),clientWidth:je(this)}},scrollIntoView:te(function(r,l){r==null?(r={from:this.doc.sel.primary().head,to:null},l==null&&(l=this.options.cursorScrollMargin)):typeof r=="number"?r={from:x(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=l||0,r.from.line!=null?Ho(this,r):on(this,r.from,r.to,r.margin)}),setSize:te(function(r,l){let n=s=>typeof s=="number"||/^\d+$/.test(String(s))?s+"px":s;r!=null&&(this.display.wrapper.style.width=n(r)),l!=null&&(this.display.wrapper.style.height=n(l)),this.options.lineWrapping&&ql(this);let o=this.display.viewFrom;this.doc.iter(o,this.display.viewTo,s=>{if(s.widgets){for(let a=0;a<s.widgets.length;a++)if(s.widgets[a].noHScroll){Ce(this,o,"widget");break}}++o}),this.curOp.forceUpdate=!0,P(this,"refresh",this)}),operation:function(r){return B(this,r)},startOperation:function(){return Xe(this)},endOperation:function(){return $e(this)},refresh:te(function(){let r=this.display.cachedTextHeight;G(this),this.curOp.forceUpdate=!0,xt(this),Ft(this,this.doc.scrollLeft,this.doc.scrollTop),fi(this.display),(r==null||Math.abs(r-rt(this.display))>.5||this.options.lineWrapping)&&si(this),P(this,"refresh",this)}),swapDoc:te(function(r){let l=this.doc;return l.cm=null,this.state.selectingText&&this.state.selectingText(),tl(this,r),xt(this),this.display.input.reset(),Ft(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,E(this,"swapDoc",this,l),l}),phrase:function(r){let l=this.options.phrases;return l&&Object.prototype.hasOwnProperty.call(l,r)?l[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Pe(e),e.registerHelper=function(r,l,n){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][l]=n},e.registerGlobalHelper=function(r,l,n,o){e.registerHelper(r,l,o),i[r]._global.push({pred:n,val:o})}}function jn(e,t,i,r,l){let n=t,o=i,s=C(e,t.line),a=l&&e.direction=="rtl"?-i:i;function u(){let h=t.line+a;return h<e.first||h>=e.first+e.size?!1:(t=new x(h,t.ch,t.sticky),s=C(e,h))}function f(h){let d;if(r=="codepoint"){let c=s.text.charCodeAt(t.ch+(i>0?0:-1));if(isNaN(c))d=null;else{let y=i>0?c>=55296&&c<56320:c>=56320&&c<57343;d=new x(t.line,Math.max(0,Math.min(s.text.length,t.ch+i*(y?2:1))),-i)}}else l?d=xs(e.cm,s,t,i):d=ul(s,t,i);if(d==null)if(!h&&u())t=rr(l,e.cm,s,t.line,a);else return!1;else t=d;return!0}if(r=="char"||r=="codepoint")f();else if(r=="column")f(!0);else if(r=="word"||r=="group"){let h=null,d=r=="group",c=e.cm&&e.cm.getHelper(t,"wordChars");for(let y=!0;!(i<0&&!f(!y));y=!1){let g=s.text.charAt(t.ch)||`
`,b=ji(g,c)?"w":d&&g==`
`?"n":!d||/\s/.test(g)?null:"p";if(d&&!y&&!b&&(b="s"),h&&h!=b){i<0&&(i=1,f(),t.sticky="after");break}if(b&&(h=b),i>0&&!f(!y))break}}let p=gi(e,t,n,o,!0);return Ni(n,p)&&(p.hitSide=!0),p}function Ms(e,t,i,r){let l=e.doc,n=t.left,o;if(r=="page"){let a=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=Math.max(a-.5*rt(e.display),3);o=(i>0?t.bottom:t.top)+i*u}else r=="line"&&(o=i>0?t.bottom+3:t.top-3);let s;for(;s=Fr(e,n,o),!!s.outside;){if(i<0?o<=0:o>=l.height){s.hitSide=!0;break}o+=i*5}return s}var Cl=class{constructor(t){this.cm=t,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ke,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null}init(t){let i=this,r=i.cm,l=i.div=t.lineDiv;l.contentEditable=!0,Tn(l,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function n(s){for(let a=s.target;a;a=a.parentNode){if(a==l)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(a.className))break}return!1}S(l,"paste",s=>{!n(s)||R(r,s)||yl(s,r)||N<=11&&setTimeout(I(r,()=>this.updateFromDOM()),20)}),S(l,"compositionstart",s=>{this.composing={data:s.data,done:!1}}),S(l,"compositionupdate",s=>{this.composing||(this.composing={data:s.data,done:!1})}),S(l,"compositionend",s=>{this.composing&&(s.data!=this.composing.data&&this.readFromDOMSoon(),this.composing.done=!0)}),S(l,"touchstart",()=>i.forceCompositionEnd()),S(l,"input",()=>{this.composing||this.readFromDOMSoon()});function o(s){if(!n(s)||R(r,s))return;if(r.somethingSelected())vi({lineWise:!1,text:r.getSelections()}),s.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){let p=xl(r);vi({lineWise:!0,text:p.text}),s.type=="cut"&&r.operation(()=>{r.setSelections(p.ranges,0,V),r.replaceSelection("",null,"cut")})}else return;if(s.clipboardData){s.clipboardData.clearData();let p=He.text.join(`
`);if(s.clipboardData.setData("Text",p),s.clipboardData.getData("Text")==p){s.preventDefault();return}}let a=bl(),u=a.firstChild;r.display.lineSpace.insertBefore(a,r.display.lineSpace.firstChild),u.value=He.text.join(`
`);let f=$();Mt(u),setTimeout(()=>{r.display.lineSpace.removeChild(a),f.focus(),f==l&&i.showPrimarySelection()},50)}S(l,"copy",o),S(l,"cut",o)}screenReaderLabelChanged(t){t?this.div.setAttribute("aria-label",t):this.div.removeAttribute("aria-label")}prepareSelection(){let t=zr(this.cm,!1);return t.focus=$()==this.div,t}showSelection(t,i){!t||!this.cm.display.view.length||((t.focus||i)&&this.showPrimarySelection(),this.showMultipleSelections(t))}getSelection(){return this.cm.display.wrapper.ownerDocument.getSelection()}showPrimarySelection(){let t=this.getSelection(),i=this.cm,r=i.doc.sel.primary(),l=r.from(),n=r.to();if(i.display.viewTo==i.display.viewFrom||l.line>=i.display.viewTo||n.line<i.display.viewFrom){t.removeAllRanges();return}let o=vl(i,t.anchorNode,t.anchorOffset),s=vl(i,t.focusNode,t.focusOffset);if(o&&!o.bad&&s&&!s.bad&&k(Nt(o,s),l)==0&&k(Dt(o,s),n)==0)return;let a=i.display.view,u=l.line>=i.display.viewFrom&&js(i,l)||{node:a[0].measure.map[2],offset:0},f=n.line<i.display.viewTo&&js(i,n);if(!f){let d=a[a.length-1].measure,c=d.maps?d.maps[d.maps.length-1]:d.map;f={node:c[c.length-1],offset:c[c.length-2]-c[c.length-3]}}if(!u||!f){t.removeAllRanges();return}let p=t.rangeCount&&t.getRangeAt(0),h;try{h=Ge(u.node,u.offset,f.offset,f.node)}catch(d){}h&&(!he&&i.state.focused?(t.collapse(u.node,u.offset),h.collapsed||(t.removeAllRanges(),t.addRange(h))):(t.removeAllRanges(),t.addRange(h)),p&&t.anchorNode==null?t.addRange(p):he&&this.startGracePeriod()),this.rememberSelection()}startGracePeriod(){clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(()=>{this.gracePeriod=!1,this.selectionChanged()&&this.cm.operation(()=>this.cm.curOp.selectionChanged=!0)},20)}showMultipleSelections(t){q(this.cm.display.cursorDiv,t.cursors),q(this.cm.display.selectionDiv,t.selection)}rememberSelection(){let t=this.getSelection();this.lastAnchorNode=t.anchorNode,this.lastAnchorOffset=t.anchorOffset,this.lastFocusNode=t.focusNode,this.lastFocusOffset=t.focusOffset}selectionInEditor(){let t=this.getSelection();if(!t.rangeCount)return!1;let i=t.getRangeAt(0).commonAncestorContainer;return Le(this.div,i)}focus(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||$()!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())}blur(){this.div.blur()}getField(){return this.div}supportsTouch(){return!0}receivedFocus(){let t=this;this.selectionInEditor()?this.pollSelection():B(this.cm,()=>t.cm.curOp.selectionChanged=!0);function i(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,i))}this.polling.set(this.cm.options.pollInterval,i)}selectionChanged(){let t=this.getSelection();return t.anchorNode!=this.lastAnchorNode||t.anchorOffset!=this.lastAnchorOffset||t.focusNode!=this.lastFocusNode||t.focusOffset!=this.lastFocusOffset}pollSelection(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;let t=this.getSelection(),i=this.cm;if($t&&St&&this.cm.display.gutterSpecs.length&&Ya(t.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();let r=vl(i,t.anchorNode,t.anchorOffset),l=vl(i,t.focusNode,t.focusOffset);r&&l&&B(i,()=>{K(i.doc,we(r,l),V),(r.bad||l.bad)&&(i.curOp.selectionChanged=!0)})}pollContent(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);let t=this.cm,i=t.display,r=t.doc.sel.primary(),l=r.from(),n=r.to();if(l.ch==0&&l.line>t.firstLine()&&(l=x(l.line-1,C(t.doc,l.line-1).length)),n.ch==C(t.doc,n.line).text.length&&n.line<t.lastLine()&&(n=x(n.line+1,0)),l.line<i.viewFrom||n.line>i.viewTo-1)return!1;let o,s,a;l.line==i.viewFrom||(o=it(t,l.line))==0?(s=O(i.view[0].line),a=i.view[0].node):(s=O(i.view[o].line),a=i.view[o-1].node.nextSibling);let u=it(t,n.line),f,p;if(u==i.view.length-1?(f=i.viewTo-1,p=i.lineDiv.lastChild):(f=O(i.view[u+1].line)-1,p=i.view[u+1].node.previousSibling),!a)return!1;let h=t.doc.splitLines(qa(t,a,p,s,f)),d=_e(t.doc,x(s,0),x(f,C(t.doc,f).text.length));for(;h.length>1&&d.length>1;)if(j(h)==j(d))h.pop(),d.pop(),f--;else if(h[0]==d[0])h.shift(),d.shift(),s++;else break;let c=0,y=0,g=h[0],b=d[0],m=Math.min(g.length,b.length);for(;c<m&&g.charCodeAt(c)==b.charCodeAt(c);)++c;let M=j(h),w=j(d),D=Math.min(M.length-(h.length==1?c:0),w.length-(d.length==1?c:0));for(;y<D&&M.charCodeAt(M.length-y-1)==w.charCodeAt(w.length-y-1);)++y;if(h.length==1&&d.length==1&&s==l.line)for(;c&&c>l.ch&&M.charCodeAt(M.length-y-1)==w.charCodeAt(w.length-y-1);)c--,y++;h[h.length-1]=M.slice(0,M.length-y).replace(/^\u200b+/,""),h[0]=h[0].slice(c).replace(/\u200b+$/,"");let H=x(s,c),W=x(f,d.length?j(d).length-y:0);if(h.length>1||h[0]||k(H,W))return Ne(t.doc,h,H,W,"+input"),!0}ensurePolled(){this.forceCompositionEnd()}reset(){this.forceCompositionEnd()}forceCompositionEnd(){!this.composing||(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())}readFromDOMSoon(){this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(()=>{if(this.readDOMTimeout=null,this.composing)if(this.composing.done)this.composing=null;else return;this.updateFromDOM()},80))}updateFromDOM(){(this.cm.isReadOnly()||!this.pollContent())&&B(this.cm,()=>G(this.cm))}setUneditable(t){t.contentEditable="false"}onKeyPress(t){t.charCode==0||this.composing||(t.preventDefault(),this.cm.isReadOnly()||I(this.cm,sr)(this.cm,String.fromCharCode(t.charCode==null?t.keyCode:t.charCode),0))}readOnlyChanged(t){this.div.contentEditable=String(t!="nocursor")}onContextMenu(){}resetPosition(){}},Os=Cl;Cl.prototype.needsContentAttribute=!0;function js(e,t){let i=zi(e,t.line);if(!i||i.hidden)return null;let r=C(e.doc,t.line),l=Kl(i,r,t.line),n=le(r,e.doc.direction),o="left";n&&(o=Ve(n,t.ch)%2?"right":"left");let s=$l(l.map,t.ch,o);return s.offset=s.collapse=="right"?s.end:s.start,s}function Ya(e){for(let t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function wi(e,t){return t&&(e.bad=!0),e}function qa(e,t,i,r,l){let n="",o=!1,s=e.doc.lineSeparator(),a=!1;function u(d){return c=>c.id==d}function f(){o&&(n+=s,a&&(n+=s),o=a=!1)}function p(d){d&&(f(),n+=d)}function h(d){if(d.nodeType==1){let c=d.getAttribute("cm-text");if(c){p(c);return}let y=d.getAttribute("cm-marker"),g;if(y){let m=e.findMarks(x(r,0),x(l+1,0),u(+y));m.length&&(g=m[0].find(0))&&p(_e(e.doc,g.from,g.to).join(s));return}if(d.getAttribute("contenteditable")=="false")return;let b=/^(pre|div|p|li|table|br)$/i.test(d.nodeName);if(!/^br$/i.test(d.nodeName)&&d.textContent.length==0)return;b&&f();for(let m=0;m<d.childNodes.length;m++)h(d.childNodes[m]);/^(pre|p)$/i.test(d.nodeName)&&(a=!0),b&&(o=!0)}else d.nodeType==3&&p(d.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;h(t),t!=i;)t=t.nextSibling,a=!1;return n}function vl(e,t,i){let r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return wi(e.clipPos(x(e.display.viewTo-1)),!0);t=null,i=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(let l=0;l<e.display.view.length;l++){let n=e.display.view[l];if(n.node==r)return Za(n,t,i)}}function Za(e,t,i){let r=e.text.firstChild,l=!1;if(!t||!Le(r,t))return wi(x(O(e.line),0),!0);if(t==r&&(l=!0,t=r.childNodes[i],i=0,!t)){let p=e.rest?j(e.rest):e.line;return wi(x(O(p),p.text.length),l)}let n=t.nodeType==3?t:null,o=t;for(!n&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(n=t.firstChild,i&&(i=n.nodeValue.length));o.parentNode!=r;)o=o.parentNode;let s=e.measure,a=s.maps;function u(p,h,d){for(let c=-1;c<(a?a.length:0);c++){let y=c<0?s.map:a[c];for(let g=0;g<y.length;g+=3){let b=y[g+2];if(b==p||b==h){let m=O(c<0?e.line:e.rest[c]),M=y[g]+d;return(d<0||b!=p)&&(M=y[g+(d?1:0)]),x(m,M)}}}}let f=u(n,o,i);if(f)return wi(f,l);for(let p=o.nextSibling,h=n?n.nodeValue.length-i:0;p;p=p.nextSibling){if(f=u(p,p.firstChild,0),f)return wi(x(f.line,f.ch-h),l);h+=p.textContent.length}for(let p=o.previousSibling,h=i;p;p=p.previousSibling){if(f=u(p,p.firstChild,-1),f)return wi(x(f.line,f.ch+h),l);h+=p.textContent.length}}var wl=class{constructor(t){this.cm=t,this.prevInput="",this.pollingFast=!1,this.polling=new ke,this.hasSelection=!1,this.composing=null}init(t){let i=this,r=this.cm;this.createField(t);let l=this.textarea;t.wrapper.insertBefore(this.wrapper,t.wrapper.firstChild),ft&&(l.style.width="0px"),S(l,"input",()=>{T&&N>=9&&this.hasSelection&&(this.hasSelection=null),i.poll()}),S(l,"paste",o=>{R(r,o)||yl(o,r)||(r.state.pasteIncoming=+new Date,i.fastPoll())});function n(o){if(!R(r,o)){if(r.somethingSelected())vi({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){let s=xl(r);vi({lineWise:!0,text:s.text}),o.type=="cut"?r.setSelections(s.ranges,null,V):(i.prevInput="",l.value=s.text.join(`
`),Mt(l))}else return;o.type=="cut"&&(r.state.cutIncoming=+new Date)}}S(l,"cut",n),S(l,"copy",n),S(t.scroller,"paste",o=>{if(ye(t,o)||R(r,o))return;if(!l.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}let s=new Event("paste");s.clipboardData=o.clipboardData,l.dispatchEvent(s)}),S(t.lineSpace,"selectstart",o=>{ye(t,o)||U(o)}),S(l,"compositionstart",()=>{let o=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:o,range:r.markText(o,r.getCursor("to"),{className:"CodeMirror-composing"})}}),S(l,"compositionend",()=>{i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})}createField(t){this.wrapper=bl(),this.textarea=this.wrapper.firstChild}screenReaderLabelChanged(t){t?this.textarea.setAttribute("aria-label",t):this.textarea.removeAttribute("aria-label")}prepareSelection(){let t=this.cm,i=t.display,r=t.doc,l=zr(t);if(t.options.moveInputWithCursor){let n=ue(t,r.sel.primary().head,"div"),o=i.wrapper.getBoundingClientRect(),s=i.lineDiv.getBoundingClientRect();l.teTop=Math.max(0,Math.min(i.wrapper.clientHeight-10,n.top+s.top-o.top)),l.teLeft=Math.max(0,Math.min(i.wrapper.clientWidth-10,n.left+s.left-o.left))}return l}showSelection(t){let i=this.cm,r=i.display;q(r.cursorDiv,t.cursors),q(r.selectionDiv,t.selection),t.teTop!=null&&(this.wrapper.style.top=t.teTop+"px",this.wrapper.style.left=t.teLeft+"px")}reset(t){if(this.contextMenuPending||this.composing)return;let i=this.cm;if(i.somethingSelected()){this.prevInput="";let r=i.getSelection();this.textarea.value=r,i.state.focused&&Mt(this.textarea),T&&N>=9&&(this.hasSelection=r)}else t||(this.prevInput=this.textarea.value="",T&&N>=9&&(this.hasSelection=null))}getField(){return this.textarea}supportsTouch(){return!1}focus(){if(this.cm.options.readOnly!="nocursor"&&(!Qe||$()!=this.textarea))try{this.textarea.focus()}catch(t){}}blur(){this.textarea.blur()}resetPosition(){this.wrapper.style.top=this.wrapper.style.left=0}receivedFocus(){this.slowPoll()}slowPoll(){this.pollingFast||this.polling.set(this.cm.options.pollInterval,()=>{this.poll(),this.cm.state.focused&&this.slowPoll()})}fastPoll(){let t=!1,i=this;i.pollingFast=!0;function r(){!i.poll()&&!t?(t=!0,i.polling.set(60,r)):(i.pollingFast=!1,i.slowPoll())}i.polling.set(20,r)}poll(){let t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||Gn(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;let l=i.value;if(l==r&&!t.somethingSelected())return!1;if(T&&N>=9&&this.hasSelection===l||X&&/[\uf700-\uf7ff]/.test(l))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){let s=l.charCodeAt(0);if(s==8203&&!r&&(r="\u200B"),s==8666)return this.reset(),this.cm.execCommand("undo")}let n=0,o=Math.min(r.length,l.length);for(;n<o&&r.charCodeAt(n)==l.charCodeAt(n);)++n;return B(t,()=>{sr(t,l.slice(n),r.length-n,null,this.composing?"*compose":null),l.length>1e3||l.indexOf(`
`)>-1?i.value=this.prevInput="":this.prevInput=l,this.composing&&(this.composing.range.clear(),this.composing.range=t.markText(this.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0}ensurePolled(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)}onKeyPress(){T&&N>=9&&(this.hasSelection=null),this.fastPoll()}onContextMenu(t){let i=this,r=i.cm,l=r.display,n=i.textarea;i.contextMenuPending&&i.contextMenuPending();let o=Ie(r,t),s=l.scroller.scrollTop;if(!o||re)return;r.options.resetSelectionOnContextMenu&&r.doc.sel.contains(o)==-1&&I(r,K)(r.doc,we(o),V);let u=n.style.cssText,f=i.wrapper.style.cssText,p=i.wrapper.offsetParent.getBoundingClientRect();i.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: ${t.clientY-p.top-5}px; left: ${t.clientX-p.left-5}px;
z-index: 1000; background: ${T?"rgba(255, 255, 255, .05)":"transparent"};
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;let h;z&&(h=window.scrollY),l.input.focus(),z&&window.scrollTo(null,h),l.input.reset(),r.somethingSelected()||(n.value=i.prevInput=" "),i.contextMenuPending=c,l.selForContextMenu=r.doc.sel,clearTimeout(l.detectingSelectAll);function d(){if(n.selectionStart!=null){let y=r.somethingSelected(),g="\u200B"+(y?n.value:"");n.value="\u21DA",n.value=g,i.prevInput=y?"":"\u200B",n.selectionStart=1,n.selectionEnd=g.length,l.selForContextMenu=r.doc.sel}}function c(){if(i.contextMenuPending==c&&(i.contextMenuPending=!1,i.wrapper.style.cssText=f,n.style.cssText=u,T&&N<9&&l.scrollbars.setScrollTop(l.scroller.scrollTop=s),n.selectionStart!=null)){(!T||T&&N<9)&&d();let y=0,g=()=>{l.selForContextMenu==r.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&i.prevInput=="\u200B"?I(r,ol)(r):y++<10?l.detectingSelectAll=setTimeout(g,500):(l.selForContextMenu=null,l.input.reset())};l.detectingSelectAll=setTimeout(g,200)}}if(T&&N>=9&&d(),ki){et(t);let y=()=>{Q(window,"mouseup",y),setTimeout(c,20)};S(window,"mouseup",y)}else setTimeout(c,50)}readOnlyChanged(t){t||this.reset(),this.textarea.disabled=t=="nocursor",this.textarea.readOnly=!!t}setUneditable(){}},As=wl;wl.prototype.needsContentAttribute=!1;function Ds(e,t){if(t=t?We(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){let n=$();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}function i(){e.value=l.getValue()}let r;if(e.form&&(S(e.form,"submit",i),!t.leaveSubmitMethodAlone)){let n=e.form;r=n.submit;try{let o=n.submit=()=>{i(),n.submit=r,n.submit(),n.submit=o}}catch(o){}}t.finishInit=n=>{n.save=i,n.getTextArea=()=>e,n.toTextArea=()=>{n.toTextArea=isNaN,i(),e.parentNode.removeChild(n.getWrapperElement()),e.style.display="",e.form&&(Q(e.form,"submit",i),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=r))}},e.style.display="none";let l=F(n=>e.parentNode.insertBefore(n,e.nextSibling),t);return l}function Ns(e){e.off=Q,e.on=S,e.wheelEventPixels=Ro,e.Doc=Ye,e.splitLines=Qt,e.countColumn=Z,e.findColumn=Ti,e.isWordChar=xr,e.Pass=dt,e.signal=P,e.Line=tt,e.changeEnd=Ae,e.scrollbarModel=an,e.Pos=x,e.cmpPos=k,e.modes=Lr,e.mimeModes=Ot,e.resolveMode=Oi,e.getMode=Ai,e.modeExtensions=At,e.extendMode=Yn,e.copyState=Ue,e.startState=kr,e.innerMode=Di,e.commands=ut,e.keyMap=Ze,e.keyName=al,e.isModifierKey=sl,e.lookupKey=Ct,e.normalizeKeyMap=ys,e.StringStream=Jt,e.SharedTextMarker=ir,e.TextMarker=tr,e.LineWidget=er,e.e_preventDefault=U,e.e_stopPropagation=Tl,e.e_stop=et,e.addClass=ge,e.contains=Le,e.rmClass=ce,e.keyNames=qe}ks(F);Ts(F);var Qa="iter insert remove copy getEditor constructor".split(" ");for(let e in Ye.prototype)Ye.prototype.hasOwnProperty(e)&&_(Qa,e)<0&&(F.prototype[e]=function(t){return function(){return t.apply(this.doc,arguments)}}(Ye.prototype[e]));Pe(Ye);F.inputStyles={textarea:As,contenteditable:Os};F.defineMode=function(e){!F.defaults.mode&&e!="null"&&(F.defaults.mode=e),Xn.apply(this,arguments)};F.defineMIME=$n;F.defineMode("null",()=>({token:e=>e.skipToEnd()}));F.defineMIME("text/plain","null");F.defineExtension=(e,t)=>{F.prototype[e]=t};F.defineDocExtension=(e,t)=>{Ye.prototype[e]=t};F.fromTextArea=Ds;Ns(F);F.version="5.61.0";var ar=F;var Hs=`
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: auto;
color: black;
direction: ltr;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-fat-cursor-mark {
background-color: rgba(20, 255, 20, 0.5);
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7;
}
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@-webkit-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: 0;
overflow: hidden;
}
.CodeMirror-ruler {
border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
.CodeMirror-composing { border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 50px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -50px; margin-right: -50px;
padding-bottom: 50px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 50px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -50px;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0; bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual;
}
.CodeMirror-wrap pre.CodeMirror-line,
.CodeMirror-wrap pre.CodeMirror-line-like {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
padding: 0.1px; /* Force widget margins to stay inside of the container */
}
.CodeMirror-widget {}
.CodeMirror-rtl pre { direction: rtl; }
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background-color: #ffa;
background-color: rgba(255, 255, 0, .4);
}
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }
`;self.CodeMirror=ar;var ur=class extends HTMLElement{static get observedAttributes(){return["src","readonly","mode","theme"]}attributeChangedCallback(t,i,r){!this.__initialized||i!==r&&(t==="readonly"?this[t]=r!==null:this[t]=r)}get readonly(){return this.editor.getOption("readOnly")}set readonly(t){this.editor.setOption("readOnly",t)}get mode(){return this.editor.getOption("mode")}set mode(t){this.editor.setOption("mode",t)}get theme(){return this.editor.getOption("theme")}set theme(t){this.editor.setOption("theme",t)}get src(){return this.getAttribute("src")}set src(t){this.setAttribute("src",t),this.setSrc()}get value(){return this.editor.getValue()}set value(t){this.__initialized?this.setValueForced(t):this.__preInitValue=t}constructor(){super();let t={childList:!0,characterData:!0,subtree:!0},i=r=>r.type==="childList"&&(Array.from(r.addedNodes).some(l=>l.tagName==="LINK")||Array.from(r.removedNodes).some(l=>l.tagName==="LINK"));this.__observer=new MutationObserver((r,l)=>{r.some(i)&&this.refreshStyles(),this.lookupInnerScript(n=>{this.value=n})}),this.__observer.observe(this,t),this.__initialized=!1,this.__element=null,this.editor=null}async connectedCallback(){let t=this.attachShadow({mode:"open"}),i=document.createElement("template"),r=document.createElement("style");r.innerHTML=Hs,i.innerHTML=ur.template(),t.appendChild(r),t.appendChild(i.content.cloneNode(!0)),this.style.display="block",this.__element=t.querySelector("textarea");let l=this.hasAttribute("mode")?this.getAttribute("mode"):"null",n=this.hasAttribute("theme")?this.getAttribute("theme"):"default",o=this.getAttribute("readonly");o===""?o=!0:o!=="nocursor"&&(o=!1),this.refreshStyles(),this.lookupInnerScript(a=>{this.value=a});let s=ar.defaults.viewportMargin;if(this.hasAttribute("viewport-margin")){let a=this.getAttribute("viewport-margin").toLowerCase();s=a==="infinity"?Infinity:parseInt(a)}this.editor=ar.fromTextArea(this.__element,{lineNumbers:!0,readOnly:o,mode:l,theme:n,viewportMargin:s}),this.hasAttribute("src")&&this.setSrc(),await new Promise(a=>setTimeout(a,50)),this.__initialized=!0,this.__preInitValue!==void 0&&this.setValueForced(this.__preInitValue)}disconnectedCallback(){this.editor&&this.editor.toTextArea(),this.editor=null,this.__initialized=!1,this.__observer.disconnect()}async setSrc(){let t=this.getAttribute("src"),i=await this.fetchSrc(t);this.value=i}async setValueForced(t){this.editor.swapDoc(ar.Doc(t,this.getAttribute("mode"))),this.editor.refresh()}async fetchSrc(t){return(await fetch(t)).text()}refreshStyles(){Array.from(this.shadowRoot.children).forEach(t=>{t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"&&t.remove()}),Array.from(this.children).forEach(t=>{t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"&&this.shadowRoot.appendChild(t.cloneNode(!0))})}static template(){return`
<textarea style="display:inherit; width:inherit; height:inherit;"></textarea>
`}lookupInnerScript(t){let i=this.querySelector("script");if(i&&i.getAttribute("type")==="wc-content"){let r=ur.dedentText(i.innerHTML);r=r.replace(/<(\/?script)(.*?)>/g,"<$1$2>"),t(r)}}static dedentText(t){let i=t.split(`
`);i[0]===""&&i.splice(0,1);let r=i[0],l=0,o=r[0]===" "?" ":" ";for(;r[l]===o;)l+=1;let s=[];for(let a of i){let u=a;for(let f=0;f<l&&u[0]===o;f++)u=u.substring(1);s.push(u)}return s[s.length-1]===""&&s.splice(s.length-1,1),s.join(`
`)}};customElements.define("wc-codemirror",ur);export{ur as WCCodeMirror};