@foris/avocado-not-front 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -576,7 +576,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
576
576
  `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[Fm]=this[Fm]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=Vs(o);n[a]||(mE(i,o),n[a]=!0)}return I.isArray(e)?e.forEach(s):s(e),this}}It.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),I.reduceDescriptors(It.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}}),I.freezeMethods(It);function Ku(r,e){const t=this||Fs,n=e||t,i=It.from(n.headers);let s=n.data;return I.forEach(r,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function Vm(r){return!!(r&&r.__CANCEL__)}function Hi(r,e,t){de.call(this,r??"canceled",de.ERR_CANCELED,e,t),this.name="CanceledError"}I.inherits(Hi,de,{__CANCEL__:!0});function jm(r,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new de("Request failed with status code "+t.status,[de.ERR_BAD_REQUEST,de.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function gE(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function yE(r,e){r=r||10;const t=new Array(r),n=new Array(r);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),u=n[s];o||(o=c),t[i]=l,n[i]=c;let h=s,d=0;for(;h!==i;)d+=t[h++],h=h%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),c-o<e)return;const f=u&&c-u;return f?Math.round(d*1e3/f):void 0}}function vE(r,e){let t=0,n=1e3/e,i,s;const o=(c,u=Date.now())=>{t=u,i=null,s&&(clearTimeout(s),s=null),r.apply(null,c)};return[(...c)=>{const u=Date.now(),h=u-t;h>=n?o(c,u):(i=c,s||(s=setTimeout(()=>{s=null,o(i)},n-h)))},()=>i&&o(i)]}const Qa=(r,e,t=3)=>{let n=0;const i=yE(50,250);return vE(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,l=o-n,c=i(l),u=o<=a;n=o;const h={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&u?(a-o)/c:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};r(h)},t)},Wm=(r,e)=>{const t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},Qm=r=>(...e)=>I.asap(()=>r(...e)),bE=_t.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,_t.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,CE=_t.hasStandardBrowserEnv?{write(r,e,t,n,i,s){const o=[r+"="+encodeURIComponent(e)];I.isNumber(t)&&o.push("expires="+new Date(t).toGMTString()),I.isString(n)&&o.push("path="+n),I.isString(i)&&o.push("domain="+i),s===!0&&o.push("secure"),document.cookie=o.join("; ")},read(r){const e=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function wE(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function kE(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function qm(r,e,t){let n=!wE(e);return r&&(n||t==!1)?kE(r,e):e}const Um=r=>r instanceof It?{...r}:r;function ei(r,e){e=e||{};const t={};function n(c,u,h,d){return I.isPlainObject(c)&&I.isPlainObject(u)?I.merge.call({caseless:d},c,u):I.isPlainObject(u)?I.merge({},u):I.isArray(u)?u.slice():u}function i(c,u,h,d){if(I.isUndefined(u)){if(!I.isUndefined(c))return n(void 0,c,h,d)}else return n(c,u,h,d)}function s(c,u){if(!I.isUndefined(u))return n(void 0,u)}function o(c,u){if(I.isUndefined(u)){if(!I.isUndefined(c))return n(void 0,c)}else return n(void 0,u)}function a(c,u,h){if(h in e)return n(c,u);if(h in r)return n(void 0,c)}const l={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,u,h)=>i(Um(c),Um(u),h,!0)};return I.forEach(Object.keys(Object.assign({},r,e)),function(u){const h=l[u]||i,d=h(r[u],e[u],u);I.isUndefined(d)&&h!==a||(t[u]=d)}),t}const zm=r=>{const e=ei({},r);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=e;e.headers=o=It.from(o),e.url=Nm(qm(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let l;if(I.isFormData(t)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((l=o.getContentType())!==!1){const[c,...u]=l?l.split(";").map(h=>h.trim()).filter(Boolean):[];o.setContentType([c||"multipart/form-data",...u].join("; "))}}if(_t.hasStandardBrowserEnv&&(n&&I.isFunction(n)&&(n=n(e)),n||n!==!1&&bE(e.url))){const c=i&&s&&CE.read(s);c&&o.set(i,c)}return e},SE=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,n){const i=zm(r);let s=i.data;const o=It.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=i,u,h,d,f,p;function g(){f&&f(),p&&p(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let m=new XMLHttpRequest;m.open(i.method.toUpperCase(),i.url,!0),m.timeout=i.timeout;function b(){if(!m)return;const k=It.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),v={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:k,config:r,request:m};jm(function(S){t(S),g()},function(S){n(S),g()},v),m=null}"onloadend"in m?m.onloadend=b:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(b)},m.onabort=function(){m&&(n(new de("Request aborted",de.ECONNABORTED,r,m)),m=null)},m.onerror=function(){n(new de("Network Error",de.ERR_NETWORK,r,m)),m=null},m.ontimeout=function(){let C=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const v=i.transitional||Bm;i.timeoutErrorMessage&&(C=i.timeoutErrorMessage),n(new de(C,v.clarifyTimeoutError?de.ETIMEDOUT:de.ECONNABORTED,r,m)),m=null},s===void 0&&o.setContentType(null),"setRequestHeader"in m&&I.forEach(o.toJSON(),function(C,v){m.setRequestHeader(v,C)}),I.isUndefined(i.withCredentials)||(m.withCredentials=!!i.withCredentials),a&&a!=="json"&&(m.responseType=i.responseType),c&&([d,p]=Qa(c,!0),m.addEventListener("progress",d)),l&&m.upload&&([h,f]=Qa(l),m.upload.addEventListener("progress",h),m.upload.addEventListener("loadend",f)),(i.cancelToken||i.signal)&&(u=k=>{m&&(n(!k||k.type?new Hi(null,r,m):k),m.abort(),m=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const _=gE(i.url);if(_&&_t.protocols.indexOf(_)===-1){n(new de("Unsupported protocol "+_+":",de.ERR_BAD_REQUEST,r));return}m.send(s||null)})},_E=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,i;const s=function(c){if(!i){i=!0,a();const u=c instanceof Error?c:this.reason;n.abort(u instanceof de?u:new Hi(u instanceof Error?u.message:u))}};let o=e&&setTimeout(()=>{o=null,s(new de(`timeout ${e} of ms exceeded`,de.ETIMEDOUT))},e);const a=()=>{r&&(o&&clearTimeout(o),o=null,r.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),r=null)};r.forEach(c=>c.addEventListener("abort",s));const{signal:l}=n;return l.unsubscribe=()=>I.asap(a),l}},xE=function*(r,e){let t=r.byteLength;if(t<e){yield r;return}let n=0,i;for(;n<t;)i=n+e,yield r.slice(n,i),n=i},OE=async function*(r,e){for await(const t of EE(r))yield*xE(t,e)},EE=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const e=r.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},$m=(r,e,t,n)=>{const i=OE(r,e);let s=0,o,a=l=>{o||(o=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:c,value:u}=await i.next();if(c){a(),l.close();return}let h=u.byteLength;if(t){let d=s+=h;t(d)}l.enqueue(new Uint8Array(u))}catch(c){throw a(c),c}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},qa=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ym=qa&&typeof ReadableStream=="function",DE=qa&&(typeof TextEncoder=="function"?(r=>e=>r.encode(e))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),Zm=(r,...e)=>{try{return!!r(...e)}catch{return!1}},ME=Ym&&Zm(()=>{let r=!1;const e=new Request(_t.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!e}),Xm=64*1024,Gu=Ym&&Zm(()=>I.isReadableStream(new Response("").body)),Ua={stream:Gu&&(r=>r.body)};qa&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Ua[e]&&(Ua[e]=I.isFunction(r[e])?t=>t[e]():(t,n)=>{throw new de(`Response type '${e}' is not supported`,de.ERR_NOT_SUPPORT,n)})})})(new Response);const PE=async r=>{if(r==null)return 0;if(I.isBlob(r))return r.size;if(I.isSpecCompliantForm(r))return(await new Request(_t.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(I.isArrayBufferView(r)||I.isArrayBuffer(r))return r.byteLength;if(I.isURLSearchParams(r)&&(r=r+""),I.isString(r))return(await DE(r)).byteLength},TE=async(r,e)=>{const t=I.toFiniteNumber(r.getContentLength());return t??PE(e)},Ju={http:GO,xhr:SE,fetch:qa&&(async r=>{let{url:e,method:t,data:n,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:l,responseType:c,headers:u,withCredentials:h="same-origin",fetchOptions:d}=zm(r);c=c?(c+"").toLowerCase():"text";let f=_E([i,s&&s.toAbortSignal()],o),p;const g=f&&f.unsubscribe&&(()=>{f.unsubscribe()});let m;try{if(l&&ME&&t!=="get"&&t!=="head"&&(m=await TE(u,n))!==0){let v=new Request(e,{method:"POST",body:n,duplex:"half"}),x;if(I.isFormData(n)&&(x=v.headers.get("content-type"))&&u.setContentType(x),v.body){const[S,D]=Wm(m,Qa(Qm(l)));n=$m(v.body,Xm,S,D)}}I.isString(h)||(h=h?"include":"omit");const b="credentials"in Request.prototype;p=new Request(e,{...d,signal:f,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:b?h:void 0});let _=await fetch(p);const k=Gu&&(c==="stream"||c==="response");if(Gu&&(a||k&&g)){const v={};["status","statusText","headers"].forEach(P=>{v[P]=_[P]});const x=I.toFiniteNumber(_.headers.get("content-length")),[S,D]=a&&Wm(x,Qa(Qm(a),!0))||[];_=new Response($m(_.body,Xm,S,()=>{D&&D(),g&&g()}),v)}c=c||"text";let C=await Ua[I.findKey(Ua,c)||"text"](_,r);return!k&&g&&g(),await new Promise((v,x)=>{jm(v,x,{data:C,headers:It.from(_.headers),status:_.status,statusText:_.statusText,config:r,request:p})})}catch(b){throw g&&g(),b&&b.name==="TypeError"&&/fetch/i.test(b.message)?Object.assign(new de("Network Error",de.ERR_NETWORK,r,p),{cause:b.cause||b}):de.from(b,b&&b.code,r,p)}})};I.forEach(Ju,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const Km=r=>`- ${r}`,AE=r=>I.isFunction(r)||r===null||r===!1,Gm={getAdapter:r=>{r=I.isArray(r)?r:[r];const{length:e}=r;let t,n;const i={};for(let s=0;s<e;s++){t=r[s];let o;if(n=t,!AE(t)&&(n=Ju[(o=String(t)).toLowerCase()],n===void 0))throw new de(`Unknown adapter '${o}'`);if(n)break;i[o||"#"+s]=n}if(!n){const s=Object.entries(i).map(([a,l])=>`adapter ${a} `+(l===!1?"is not supported by the environment":"is not available in the build"));let o=e?s.length>1?`since :
577
577
  `+s.map(Km).join(`
578
578
  `):" "+Km(s[0]):"as no adapter specified";throw new de("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n},adapters:Ju};function eh(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new Hi(null,r)}function Jm(r){return eh(r),r.headers=It.from(r.headers),r.data=Ku.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),Gm.getAdapter(r.adapter||Fs.adapter)(r).then(function(n){return eh(r),n.data=Ku.call(r,r.transformResponse,n),n.headers=It.from(n.headers),n},function(n){return Vm(n)||(eh(r),n&&n.response&&(n.response.data=Ku.call(r,r.transformResponse,n.response),n.response.headers=It.from(n.response.headers))),Promise.reject(n)})}const e3="1.8.4",za={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{za[r]=function(n){return typeof n===r||"a"+(e<1?"n ":" ")+r}});const t3={};za.transitional=function(e,t,n){function i(s,o){return"[Axios v"+e3+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(e===!1)throw new de(i(o," has been removed"+(t?" in "+t:"")),de.ERR_DEPRECATED);return t&&!t3[o]&&(t3[o]=!0,console.warn(i(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,o,a):!0}},za.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function RE(r,e,t){if(typeof r!="object")throw new de("options must be an object",de.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const a=r[s],l=a===void 0||o(a,s,r);if(l!==!0)throw new de("option "+s+" must be "+l,de.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new de("Unknown option "+s,de.ERR_BAD_OPTION)}}const $a={assertOptions:RE,validators:za},Tn=$a.validators;class ti{constructor(e){this.defaults=e,this.interceptors={request:new Im,response:new Im}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
579
- `+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=ei(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&$a.assertOptions(n,{silentJSONParsing:Tn.transitional(Tn.boolean),forcedJSONParsing:Tn.transitional(Tn.boolean),clarifyTimeoutError:Tn.transitional(Tn.boolean)},!1),i!=null&&(I.isFunction(i)?t.paramsSerializer={serialize:i}:$a.assertOptions(i,{encode:Tn.function,serialize:Tn.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),$a.assertOptions(t,{baseUrl:Tn.spelling("baseURL"),withXsrfToken:Tn.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=s&&I.merge(s.common,s[t.method]);s&&I.forEach(["delete","get","head","post","put","patch","common"],p=>{delete s[p]}),t.headers=It.concat(o,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let u,h=0,d;if(!l){const p=[Jm.bind(this),void 0];for(p.unshift.apply(p,a),p.push.apply(p,c),d=p.length,u=Promise.resolve(t);h<d;)u=u.then(p[h++],p[h++]);return u}d=a.length;let f=t;for(h=0;h<d;){const p=a[h++],g=a[h++];try{f=p(f)}catch(m){g.call(this,m);break}}try{u=Jm.call(this,f)}catch(p){return Promise.reject(p)}for(h=0,d=c.length;h<d;)u=u.then(c[h++],c[h++]);return u}getUri(e){e=ei(this.defaults,e);const t=qm(e.baseURL,e.url,e.allowAbsoluteUrls);return Nm(t,e.params,e.paramsSerializer)}}I.forEach(["delete","get","head","options"],function(e){ti.prototype[e]=function(t,n){return this.request(ei(n||{},{method:e,url:t,data:(n||{}).data}))}}),I.forEach(["post","put","patch"],function(e){function t(n){return function(s,o,a){return this.request(ei(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}ti.prototype[e]=t(),ti.prototype[e+"Form"]=t(!0)});class th{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new Hi(s,o,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new th(function(i){e=i}),cancel:e}}}function LE(r){return function(t){return r.apply(null,t)}}function NE(r){return I.isObject(r)&&r.isAxiosError===!0}const nh={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(nh).forEach(([r,e])=>{nh[e]=r});function n3(r){const e=new ti(r),t=wm(ti.prototype.request,e);return I.extend(t,ti.prototype,e,{allOwnKeys:!0}),I.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return n3(ei(r,i))},t}const Je=n3(Fs);Je.Axios=ti,Je.CanceledError=Hi,Je.CancelToken=th,Je.isCancel=Vm,Je.VERSION=e3,Je.toFormData=ja,Je.AxiosError=de,Je.Cancel=Je.CanceledError,Je.all=function(e){return Promise.all(e)},Je.spread=LE,Je.isAxiosError=NE,Je.mergeConfig=ei,Je.AxiosHeaders=It,Je.formToJSON=r=>Hm(I.isHTMLForm(r)?new FormData(r):r),Je.getAdapter=Gm.getAdapter,Je.HttpStatusCode=nh,Je.default=Je;const r3=()=>new AbortController,IE=(r,e={},t={},n=!1)=>{const i=r3();return n&&i.abort(),{call:Je.get(r,{headers:{...e},params:t,signal:i.signal}),controller:i}},i3=(r,e={},t={},n={},i=!1)=>{const s=r3();return i&&s.abort(),{call:Je.post(r,t,{headers:{...e},params:n,signal:s.signal}),controller:s}},s3=()=>{let r;return{callEndpoint:async n=>{n.controller&&(r=n.controller);let i={};try{i=await n.call}catch(s){throw s}return i},cancelEndpoint:()=>{r&&r.abort()}}},o3=async(r,e,t="",n={},i={})=>{try{const{callEndpoint:s}=s3(),{api:o,headers:a}=r,l=sessionStorage.getItem("sessionId"),c=new URLSearchParams({session_name:e});t&&c.append("hash_code",t),l&&c.append("sessionId",l);const u=`${o}/not-front/next-ui/?${c.toString()}`,h=i3(u,a||{"content-type":"application/json"},n,i,!1);return await s(h)}catch(s){return console.error(s),Promise.reject(s)}},a3={body:"_body_1crqw_1",body_content:"_body_content_1crqw_4"},BE=({inputs:r})=>me.jsx("section",{className:a3.body,children:me.jsx("div",{className:"container",children:me.jsx("div",{className:"container_row",children:me.jsx("div",{className:`${a3.body_content} col_6 col_md_12`,children:r.map((e,t)=>me.jsx(O.Fragment,{children:e},t))})})})}),Fi=()=>{const r=dn(s=>s),{callEndpoint:e}=s3(),t=async(s,o,a,l)=>{var c;try{const u=(c=r[s])==null?void 0:c.apiConfig,h={state:{...a},triggerKey:l};return await o3(u,s,o,h)}catch(u){throw console.error("[getNextUI] Error fetching next UI:",u),u}},n=async s=>{if(!s||s.type!=="rest"){console.warn("[fetchDataSource] Invalid or missing dataSource");return}try{const{method:o,url:a,headers:l,data:c}=s,u=o==="post"?i3(a,l,c):IE(a,l);return await e(u)}catch(o){throw console.error("[fetchDataSource] Error:",o),o}};return{getNextUI:t,fetchDataSource:n,fetchAndGetNextUI:async(s,o,a,l,c)=>{try{const u=await n(c);return u&&await t(s,o,a,l)}catch(u){throw console.error("[fetchAndGetNextUI] Error fetching and navigating:",u),u}}}},HE=({userFlow:r,items:e,responseKey:t})=>{const{getNextUI:n}=Fi(),i=dn(a=>{var l;return((l=a[r])==null?void 0:l.entries)||{}}),s=O.useCallback(async({actionType:a,hashCode:l,redirectUrl:c})=>{try{switch(a){case"GO_TO_NEXT_UI":const u=await n(r,l,i,t);u!=null&&u.data&&Gr(r,u==null?void 0:u.data);break;case"REDIRECT":c?window.location.href=c:console.warn("Missing redirectUrl for REDIRECT actionType");break;default:console.warn(`Unhandled actionType: ${a}`);break}}catch(u){alert(JSON.stringify(u))}},[]),o=O.useMemo(()=>e==null?void 0:e.map(a=>({title:a==null?void 0:a.title,component:me.jsx("div",{onClick:()=>s(a)})})),[]);return me.jsx(n1,{items:o})},FE=r=>{const{userFlow:e,pageId:t,responseKey:n,actionType:i,label:s,content:o,dataSource:a,redirectUrl:l,...c}=r,{getNextUI:u,fetchDataSource:h,fetchAndGetNextUI:d}=Fi(),f=dn(b=>{var _;return((_=b[e])==null?void 0:_.entries)||{}}),p={...f,[n]:{status:200}},g=O.useCallback(async()=>{var b;try{xr(e,p);const _=async k=>{const C=await k(e,t,p,n,a);C!=null&&C.data&&Gr(e,C==null?void 0:C.data)};switch(i){case"GO_TO_NEXT_UI":await _(u);break;case"FETCH_AND_GO_TO_NEXT_UI":await _(d);break;case"GET_DATA_SOURCE":{const k=await u(e,t,p,n),C=(b=k==null?void 0:k.data)==null?void 0:b.content;if((C==null?void 0:C.type)!=="fetch")break;const v=C==null?void 0:C.dataSource,x=await h(v),S={...f,[n]:{status:x==null?void 0:x.status,content:x==null?void 0:x.data}};xr(e,p);const D=await u(e,t,S,n);D!=null&&D.data&&Gr(e,D==null?void 0:D.data);break}case"REDIRECT":l?window.location.href=l:console.warn("Missing redirectUrl for REDIRECT actionType");break;default:console.warn(`Unhandled actionType: ${i}`);break}}catch(_){alert(JSON.stringify(_))}},[i,a,f,t,n,e]),m={...c,children:o??s,onClick:g};return me.jsx(r1,{...m})},VE=r=>{const{userFlow:e,pageId:t,responseKey:n,actionType:i,label:s,value:o,required:a,...l}=r,c={...l},{getNextUI:u}=Fi(),h=dn(m=>{var b;return((b=m[e])==null?void 0:b.entries)||{}}),[d,f]=O.useState(o||!1),p=O.useMemo(()=>a&&s?`${s} *`:s??"",[s,a]),g=O.useCallback(async()=>{try{const m=!d;f(m);const b={...h,[n]:m};switch(xr(e,b),i){case"GO_TO_NEXT_UI":const _=await u(e,t,b,n);_!=null&&_.data&&Gr(e,_==null?void 0:_.data);break;default:console.warn(`Unhandled actionType: ${i}`);break}}catch(m){console.error("Error in checkbox action:",m),alert(JSON.stringify(m))}},[i,h,t,n,e]);return me.jsx(g7,{...c,labelRight:p,value:d,onChange:()=>g()})};function rh(){return rh=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},rh.apply(this,arguments)}function jE(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}let ih=[],l3=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<r.length;e++)(e%2?l3:ih).push(t=t+r[e])})();function WE(r){if(r<768)return!1;for(let e=0,t=ih.length;;){let n=e+t>>1;if(r<ih[n])t=n;else if(r>=l3[n])e=n+1;else return!0;if(e==t)return!1}}function c3(r){return r>=127462&&r<=127487}const u3=8205;function QE(r,e,t=!0,n=!0){return(t?h3:qE)(r,e,n)}function h3(r,e,t){if(e==r.length)return e;e&&d3(r.charCodeAt(e))&&f3(r.charCodeAt(e-1))&&e--;let n=sh(r,e);for(e+=p3(n);e<r.length;){let i=sh(r,e);if(n==u3||i==u3||t&&WE(i))e+=p3(i),n=i;else if(c3(i)){let s=0,o=e-2;for(;o>=0&&c3(sh(r,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function qE(r,e,t){for(;e>0;){let n=h3(r,e-2,t);if(n<e)return n;e--}return 0}function sh(r,e){let t=r.charCodeAt(e);if(!f3(t)||e+1==r.length)return t;let n=r.charCodeAt(e+1);return d3(n)?(t-55296<<10)+(n-56320)+65536:t}function d3(r){return r>=56320&&r<57344}function f3(r){return r>=55296&&r<56320}function p3(r){return r<65536?1:2}class xe{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Vi(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),An.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Vi(this,e,t);let n=[];return this.decompose(e,t,n,0),An.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new js(this),s=new js(e);for(let o=t,a=t;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=n)return!0}}iter(e=1){return new js(this,e)}iterRange(e,t=this.length){return new g3(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new y3(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?xe.empty:e.length<=32?new et(e):An.from(et.split(e,[]))}}class et extends xe{constructor(e,t=UE(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((t?n:a)>=e)return new zE(i,a,n,o);i=a+1,n++}}decompose(e,t,n,i){let s=e<=0&&t>=this.length?this:new et(m3(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(i&1){let o=n.pop(),a=Ya(s.text,o.text.slice(),0,s.length);if(a.length<=32)n.push(new et(a,o.length+s.length));else{let l=a.length>>1;n.push(new et(a.slice(0,l)),new et(a.slice(l)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof et))return super.replace(e,t,n);[e,t]=Vi(this,e,t);let i=Ya(this.text,Ya(n.text,m3(this.text,0,e)),t),s=this.length+n.length-(t-e);return i.length<=32?new et(i,s):An.from(et.split(i,[]),s)}sliceString(e,t=this.length,n=`
579
+ `+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=ei(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&$a.assertOptions(n,{silentJSONParsing:Tn.transitional(Tn.boolean),forcedJSONParsing:Tn.transitional(Tn.boolean),clarifyTimeoutError:Tn.transitional(Tn.boolean)},!1),i!=null&&(I.isFunction(i)?t.paramsSerializer={serialize:i}:$a.assertOptions(i,{encode:Tn.function,serialize:Tn.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),$a.assertOptions(t,{baseUrl:Tn.spelling("baseURL"),withXsrfToken:Tn.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=s&&I.merge(s.common,s[t.method]);s&&I.forEach(["delete","get","head","post","put","patch","common"],p=>{delete s[p]}),t.headers=It.concat(o,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let u,h=0,d;if(!l){const p=[Jm.bind(this),void 0];for(p.unshift.apply(p,a),p.push.apply(p,c),d=p.length,u=Promise.resolve(t);h<d;)u=u.then(p[h++],p[h++]);return u}d=a.length;let f=t;for(h=0;h<d;){const p=a[h++],g=a[h++];try{f=p(f)}catch(m){g.call(this,m);break}}try{u=Jm.call(this,f)}catch(p){return Promise.reject(p)}for(h=0,d=c.length;h<d;)u=u.then(c[h++],c[h++]);return u}getUri(e){e=ei(this.defaults,e);const t=qm(e.baseURL,e.url,e.allowAbsoluteUrls);return Nm(t,e.params,e.paramsSerializer)}}I.forEach(["delete","get","head","options"],function(e){ti.prototype[e]=function(t,n){return this.request(ei(n||{},{method:e,url:t,data:(n||{}).data}))}}),I.forEach(["post","put","patch"],function(e){function t(n){return function(s,o,a){return this.request(ei(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}ti.prototype[e]=t(),ti.prototype[e+"Form"]=t(!0)});class th{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new Hi(s,o,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new th(function(i){e=i}),cancel:e}}}function LE(r){return function(t){return r.apply(null,t)}}function NE(r){return I.isObject(r)&&r.isAxiosError===!0}const nh={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(nh).forEach(([r,e])=>{nh[e]=r});function n3(r){const e=new ti(r),t=wm(ti.prototype.request,e);return I.extend(t,ti.prototype,e,{allOwnKeys:!0}),I.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return n3(ei(r,i))},t}const Je=n3(Fs);Je.Axios=ti,Je.CanceledError=Hi,Je.CancelToken=th,Je.isCancel=Vm,Je.VERSION=e3,Je.toFormData=ja,Je.AxiosError=de,Je.Cancel=Je.CanceledError,Je.all=function(e){return Promise.all(e)},Je.spread=LE,Je.isAxiosError=NE,Je.mergeConfig=ei,Je.AxiosHeaders=It,Je.formToJSON=r=>Hm(I.isHTMLForm(r)?new FormData(r):r),Je.getAdapter=Gm.getAdapter,Je.HttpStatusCode=nh,Je.default=Je;const r3=()=>new AbortController,IE=(r,e={},t={},n=!1)=>{const i=r3();return n&&i.abort(),{call:Je.get(r,{headers:{...e},params:t,signal:i.signal}),controller:i}},i3=(r,e={},t={},n={},i=!1)=>{const s=r3();return i&&s.abort(),{call:Je.post(r,t,{headers:{...e},params:n,signal:s.signal}),controller:s}},s3=()=>{let r;return{callEndpoint:async n=>{n.controller&&(r=n.controller);let i={};try{i=await n.call}catch(s){throw s}return i},cancelEndpoint:()=>{r&&r.abort()}}},o3=async(r,e,t="",n={},i={})=>{try{const{callEndpoint:s}=s3(),{api:o,headers:a}=r,l=sessionStorage.getItem("sessionId"),c=new URLSearchParams({session_name:e});t&&c.append("hash_code",t),l&&c.append("sessionId",l);const u=`${o}/not-front/next-ui/?${c.toString()}`,h=i3(u,a||{"content-type":"application/json"},n,i,!1);return await s(h)}catch(s){return console.error(s),Promise.reject(s)}},a3={body:"_body_1crqw_1",body_content:"_body_content_1crqw_4"},BE=({inputs:r})=>me.jsx("section",{className:a3.body,children:me.jsx("div",{className:"container",children:me.jsx("div",{className:"container_row",children:me.jsx("div",{className:`${a3.body_content} col_6 col_md_12`,children:r.map((e,t)=>me.jsx(O.Fragment,{children:e},t))})})})}),Fi=()=>{const r=dn(s=>s),{callEndpoint:e}=s3(),t=async(s,o,a,l)=>{var c;try{const u=(c=r[s])==null?void 0:c.apiConfig,h={state:{...a},triggerKey:l};return await o3(u,s,o,h)}catch(u){throw console.error("[getNextUI] Error fetching next UI:",u),u}},n=async s=>{if(!s||s.type!=="rest"){console.warn("[fetchDataSource] Invalid or missing dataSource");return}try{const{method:o,url:a,headers:l,data:c}=s,u=o==="post"?i3(a,l,c):IE(a,l);return await e(u)}catch(o){throw console.error("[fetchDataSource] Error:",o),o}};return{getNextUI:t,fetchDataSource:n,fetchAndGetNextUI:async(s,o,a,l,c)=>{try{const u=await n(c);return u&&await t(s,o,a,l)}catch(u){throw console.error("[fetchAndGetNextUI] Error fetching and navigating:",u),u}}}},HE=({userFlow:r,items:e,responseKey:t})=>{const{getNextUI:n}=Fi(),i=dn(a=>{var l;return((l=a[r])==null?void 0:l.entries)||{}}),s=O.useCallback(async({actionType:a,hashCode:l,redirectUrl:c})=>{try{switch(a){case"GO_TO_NEXT_UI":const u=await n(r,l,i,t);u!=null&&u.data&&Gr(r,u==null?void 0:u.data);break;case"REDIRECT":c?window.location.href=c:console.warn("Missing redirectUrl for REDIRECT actionType");break;default:console.warn(`Unhandled actionType: ${a}`);break}}catch(u){alert(JSON.stringify(u))}},[]),o=O.useMemo(()=>e==null?void 0:e.map(a=>({title:a==null?void 0:a.title,component:me.jsx("div",{onClick:()=>s(a)})})),[]);return me.jsx(n1,{items:o})},FE=r=>{const{userFlow:e,pageId:t,responseKey:n,actionType:i,label:s,content:o,dataSource:a,redirectUrl:l,...c}=r,{getNextUI:u,fetchDataSource:h,fetchAndGetNextUI:d}=Fi(),f=dn(b=>{var _;return((_=b[e])==null?void 0:_.entries)||{}}),p={...f,[n]:{status:200}},g=O.useCallback(async()=>{var b;try{xr(e,p);const _=async k=>{const C=await k(e,t,p,n,a);C!=null&&C.data&&Gr(e,C==null?void 0:C.data)};switch(i){case"GO_TO_NEXT_UI":await _(u);break;case"FETCH_AND_GO_TO_NEXT_UI":await _(d);break;case"GET_DATA_SOURCE":{const k=await u(e,t,p,n),C=(b=k==null?void 0:k.data)==null?void 0:b.content;if((C==null?void 0:C.type)!=="fetch")break;const v=C==null?void 0:C.dataSource,x=await h(v),S={...f,[n]:{status:x==null?void 0:x.status,content:x==null?void 0:x.data}};xr(e,p);const D=await u(e,t,S,n);D!=null&&D.data&&Gr(e,D==null?void 0:D.data);break}case"REDIRECT":l?window.location.href=l:console.warn("Missing redirectUrl for REDIRECT actionType");break;default:console.warn(`Unhandled actionType: ${i}`);break}}catch(_){alert(JSON.stringify(_))}},[i,a,f,t,n,e]),m={...c,children:o??s,onClick:g};return me.jsx(r1,{...m})},VE=r=>{const{userFlow:e,pageId:t,responseKey:n,actionType:i,label:s,value:o,required:a,...l}=r,c={...l},{getNextUI:u}=Fi(),h=dn(m=>{var b;return((b=m[e])==null?void 0:b.entries)||{}}),[d,f]=O.useState(o||!1),p=O.useMemo(()=>a&&s?`${s} *`:s??"",[s,a]),g=O.useCallback(async()=>{try{const m=!d;f(m);const b={...h,[n]:m};switch(xr(e,b),i){case"GO_TO_NEXT_UI":const _=await u(e,t,b,n);_!=null&&_.data&&Gr(e,_==null?void 0:_.data);break;default:console.warn(`Unhandled actionType: ${i}`);break}}catch(m){console.error("Error in checkbox action:",m),alert(JSON.stringify(m))}},[i,h,t,n,e]);return me.jsx(g7,{...c,labelRight:p,checked:d,onChange:g})};function rh(){return rh=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},rh.apply(this,arguments)}function jE(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,s;for(s=0;s<n.length;s++)i=n[s],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}let ih=[],l3=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<r.length;e++)(e%2?l3:ih).push(t=t+r[e])})();function WE(r){if(r<768)return!1;for(let e=0,t=ih.length;;){let n=e+t>>1;if(r<ih[n])t=n;else if(r>=l3[n])e=n+1;else return!0;if(e==t)return!1}}function c3(r){return r>=127462&&r<=127487}const u3=8205;function QE(r,e,t=!0,n=!0){return(t?h3:qE)(r,e,n)}function h3(r,e,t){if(e==r.length)return e;e&&d3(r.charCodeAt(e))&&f3(r.charCodeAt(e-1))&&e--;let n=sh(r,e);for(e+=p3(n);e<r.length;){let i=sh(r,e);if(n==u3||i==u3||t&&WE(i))e+=p3(i),n=i;else if(c3(i)){let s=0,o=e-2;for(;o>=0&&c3(sh(r,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function qE(r,e,t){for(;e>0;){let n=h3(r,e-2,t);if(n<e)return n;e--}return 0}function sh(r,e){let t=r.charCodeAt(e);if(!f3(t)||e+1==r.length)return t;let n=r.charCodeAt(e+1);return d3(n)?(t-55296<<10)+(n-56320)+65536:t}function d3(r){return r>=56320&&r<57344}function f3(r){return r>=55296&&r<56320}function p3(r){return r<65536?1:2}class xe{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Vi(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),An.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Vi(this,e,t);let n=[];return this.decompose(e,t,n,0),An.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new js(this),s=new js(e);for(let o=t,a=t;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=n)return!0}}iter(e=1){return new js(this,e)}iterRange(e,t=this.length){return new g3(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new y3(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?xe.empty:e.length<=32?new et(e):An.from(et.split(e,[]))}}class et extends xe{constructor(e,t=UE(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((t?n:a)>=e)return new zE(i,a,n,o);i=a+1,n++}}decompose(e,t,n,i){let s=e<=0&&t>=this.length?this:new et(m3(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(i&1){let o=n.pop(),a=Ya(s.text,o.text.slice(),0,s.length);if(a.length<=32)n.push(new et(a,o.length+s.length));else{let l=a.length>>1;n.push(new et(a.slice(0,l)),new et(a.slice(l)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof et))return super.replace(e,t,n);[e,t]=Vi(this,e,t);let i=Ya(this.text,Ya(n.text,m3(this.text,0,e)),t),s=this.length+n.length-(t-e);return i.length<=32?new et(i,s):An.from(et.split(i,[]),s)}sliceString(e,t=this.length,n=`
580
580
  `){[e,t]=Vi(this,e,t);let i="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let a=this.text[o],l=s+a.length;s>e&&o&&(i+=n),e<l&&t>s&&(i+=a.slice(Math.max(0,e-s),t-s)),s=l+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let s of e)n.push(s),i+=s.length+1,n.length==32&&(t.push(new et(n,i)),n=[],i=-1);return i>-1&&t.push(new et(n,i)),t}}class An extends xe{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,i){for(let s=0;;s++){let o=this.children[s],a=i+o.length,l=n+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,n,i);i=a+1,n=l+1}}decompose(e,t,n,i){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let a=this.children[s],l=o+a.length;if(e<=l&&t>=o){let c=i&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?n.push(a):a.decompose(e-o,t-o,n,c)}o=l+1}}replace(e,t,n){if([e,t]=Vi(this,e,t),n.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let o=this.children[i],a=s+o.length;if(e>=s&&t<=a){let l=o.replace(e-s,t-s,n),c=this.lines-o.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new An(u,this.length-(t-e)+n.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
581
581
  `){[e,t]=Vi(this,e,t);let i="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let a=this.children[s],l=o+a.length;o>e&&s&&(i+=n),e<l&&t>o&&(i+=a.sliceString(e-o,t-o,n)),o=l+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof An))return 0;let n=0,[i,s,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,s+=t){if(i==o||s==a)return n;let l=this.children[i],c=e.children[s];if(l!=c)return n+l.scanIdentical(c,t);n+=l.length+1}}static from(e,t=e.reduce((n,i)=>n+i.length+1,-1)){let n=0;for(let f of e)n+=f.lines;if(n<32){let f=[];for(let p of e)p.flatten(f);return new et(f,t)}let i=Math.max(32,n>>5),s=i<<1,o=i>>1,a=[],l=0,c=-1,u=[];function h(f){let p;if(f.lines>s&&f instanceof An)for(let g of f.children)h(g);else f.lines>o&&(l>o||!l)?(d(),a.push(f)):f instanceof et&&l&&(p=u[u.length-1])instanceof et&&f.lines+p.lines<=32?(l+=f.lines,c+=f.length+1,u[u.length-1]=new et(p.text.concat(f.text),p.length+1+f.length)):(l+f.lines>i&&d(),l+=f.lines,c+=f.length+1,u.push(f))}function d(){l!=0&&(a.push(u.length==1?u[0]:An.from(u,c)),c=-1,l=u.length=0)}for(let f of e)h(f);return d(),a.length==1?a[0]:new An(a,t)}}xe.empty=new et([""],0);function UE(r){let e=-1;for(let t of r)e+=t.length+1;return e}function Ya(r,e,t=0,n=1e9){for(let i=0,s=0,o=!0;s<r.length&&i<=n;s++){let a=r[s],l=i+a.length;l>=t&&(l>n&&(a=a.slice(0,n-i)),i<t&&(a=a.slice(t-i)),o?(e[e.length-1]+=a,o=!1):e.push(a)),i=l+1}return e}function m3(r,e,t){return Ya(r,[""],e,t)}class js{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof et?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],s=this.offsets[n],o=s>>1,a=i instanceof et?i.text.length:i.children.length;if(o==(t>0?a:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
582
582
  `,this;e--}else if(i instanceof et){let l=i.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof et?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class g3{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new js(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class y3{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:i}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(xe.prototype[Symbol.iterator]=function(){return this.iter()},js.prototype[Symbol.iterator]=g3.prototype[Symbol.iterator]=y3.prototype[Symbol.iterator]=function(){return this});class zE{constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}get length(){return this.to-this.from}}function Vi(r,e,t){return e=Math.max(0,Math.min(r.length,e)),[e,Math.max(e,Math.min(r.length,t))]}function yt(r,e,t=!0,n=!0){return QE(r,e,t,n)}function $E(r){return r>=56320&&r<57344}function YE(r){return r>=55296&&r<56320}function Bt(r,e){let t=r.charCodeAt(e);if(!YE(t)||e+1==r.length)return t;let n=r.charCodeAt(e+1);return $E(n)?(t-55296<<10)+(n-56320)+65536:t}function oh(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function Rn(r){return r<65536?1:2}const ah=/\r\n?|\n/;var Tt=function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r}(Tt||(Tt={}));class Ln{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(n,i,s),i+=s):i+=o,n+=s}}iterChangedRanges(e,t=!1){lh(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new Ln(e)}composeDesc(e){return this.empty?e:e.empty?this:v3(this,e)}mapDesc(e,t=!1){return e.empty?this:ch(this,e,t)}mapPos(e,t=-1,n=Tt.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],c=i+a;if(l<0){if(c>e)return s+(e-i);s+=a}else{if(n!=Tt.Simple&&c>=e&&(n==Tt.TrackDel&&i<e&&c>e||n==Tt.TrackBefore&&i<e||n==Tt.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!a)return e==i||t<0?s:s+l;s+=l}i=c}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,t=e){for(let n=0,i=0;n<this.sections.length&&i<=t;){let s=this.sections[n++],o=this.sections[n++],a=i+s;if(o>=0&&i<=t&&a>=e)return i<e&&a>t?"cover":!0;i=a}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ln(e)}static create(e){return new Ln(e)}}class at extends Ln{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return lh(this,(t,n,i,s,o)=>e=e.replace(i,i+(n-t),o),!1),e}mapDesc(e,t=!1){return ch(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,s=0;i<t.length;i+=2){let o=t[i],a=t[i+1];if(a>=0){t[i]=a,t[i+1]=o;let l=i>>1;for(;n.length<l;)n.push(xe.empty);n.push(o?e.slice(s,s+o):xe.empty)}s+=o}return new at(t,n)}compose(e){return this.empty?e:e.empty?this:v3(this,e,!0)}map(e,t=!1){return e.empty?this:ch(this,e,t,!0)}iterChanges(e,t=!1){lh(this,e,t)}get desc(){return Ln.create(this.sections)}filter(e){let t=[],n=[],i=[],s=new Ws(this);e:for(let o=0,a=0;;){let l=o==e.length?1e9:e[o++];for(;a<l||a==l&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,l-a);xt(i,u,-1);let h=s.ins==-1?-1:s.off==0?s.ins:0;xt(t,u,h),h>0&&Or(n,t,s.text),s.forward(u),a+=u}let c=e[o++];for(;a<c;){if(s.done)break e;let u=Math.min(s.len,c-a);xt(t,u,-1),xt(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),a+=u}}return{changes:new at(t,n),filtered:Ln.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):i==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],s=[],o=0,a=null;function l(u=!1){if(!u&&!i.length)return;o<t&&xt(i,t-o,-1);let h=new at(i,s);a=a?a.compose(h.map(a)):h,i=[],s=[],o=0}function c(u){if(Array.isArray(u))for(let h of u)c(h);else if(u instanceof at){if(u.length!=t)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${t})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:h,to:d=h,insert:f}=u;if(h>d||h<0||d>t)throw new RangeError(`Invalid change range ${h} to ${d} (in doc of length ${t})`);let p=f?typeof f=="string"?xe.of(f.split(n||ah)):f:xe.empty,g=p.length;if(h==d&&g==0)return;h<o&&l(),h>o&&xt(i,h-o,-1),xt(i,d-h,g),Or(s,i,p),o=d}}return c(e),l(!a),a}static empty(e){return new at(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let s=e[i];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<i;)n.push(xe.empty);n[i]=xe.of(s.slice(1)),t.push(s[0],n[i].length)}}}return new at(t,n)}static createSet(e,t){return new at(e,t)}}function xt(r,e,t,n=!1){if(e==0&&t<=0)return;let i=r.length-2;i>=0&&t<=0&&t==r[i+1]?r[i]+=e:i>=0&&e==0&&r[i]==0?r[i+1]+=t:n?(r[i]+=e,r[i+1]+=t):r.push(e,t)}function Or(r,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<r.length)r[r.length-1]=r[r.length-1].append(t);else{for(;r.length<n;)r.push(xe.empty);r.push(t)}}function lh(r,e,t){let n=r.inserted;for(let i=0,s=0,o=0;o<r.sections.length;){let a=r.sections[o++],l=r.sections[o++];if(l<0)i+=a,s+=a;else{let c=i,u=s,h=xe.empty;for(;c+=a,u+=l,l&&n&&(h=h.append(n[o-2>>1])),!(t||o==r.sections.length||r.sections[o+1]<0);)a=r.sections[o++],l=r.sections[o++];e(i,c,s,u,h),i=c,s=u}}}function ch(r,e,t,n=!1){let i=[],s=n?[]:null,o=new Ws(r),a=new Ws(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);xt(i,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!t))){let c=a.len;for(xt(i,a.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&l<o.i&&o.len<=u&&(xt(i,0,o.ins),s&&Or(s,i,o.text),l=o.i),o.forward(u),c-=u}a.next()}else if(o.ins>=0){let c=0,u=o.len;for(;u;)if(a.ins==-1){let h=Math.min(u,a.len);c+=h,u-=h,a.forward(h)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;xt(i,c,l<o.i?o.ins:0),s&&l<o.i&&Or(s,i,o.text),l=o.i,o.forward(o.len-u)}else{if(o.done&&a.done)return s?at.createSet(i,s):Ln.create(i);throw new Error("Mismatched change set lengths")}}}function v3(r,e,t=!1){let n=[],i=t?[]:null,s=new Ws(r),o=new Ws(e);for(let a=!1;;){if(s.done&&o.done)return i?at.createSet(n,i):Ln.create(n);if(s.ins==0)xt(n,s.len,0,a),s.next();else if(o.len==0&&!o.done)xt(n,0,o.ins,a),i&&Or(i,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,o.len),c=n.length;if(s.ins==-1){let u=o.ins==-1?-1:o.off?0:o.ins;xt(n,l,u,a),i&&u&&Or(i,n,o.text)}else o.ins==-1?(xt(n,s.off?0:s.len,l,a),i&&Or(i,n,s.textBit(l))):(xt(n,s.off?0:s.len,o.off?0:o.ins,a),i&&!o.off&&Or(i,n,o.text));a=(s.ins>l||o.ins>=0&&o.len>l)&&(a||n.length>c),s.forward2(l),o.forward(l)}}}}class Ws{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?xe.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?xe.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ni{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new ni(n,i,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return Q.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Q.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Q.range(e.anchor,e.head)}static create(e,t,n){return new ni(e,t,n)}}class Q{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:Q.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Q([this.main],0)}addRange(e,t=!0){return Q.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,Q.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Q(e.ranges.map(t=>ni.fromJSON(t)),e.main)}static single(e,t=e){return new Q([Q.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=n:s.from<n)return Q.normalized(e.slice(),t);n=s.to}return new Q(e,t)}static cursor(e,t=0,n,i){return ni.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(i??16777215)<<6)}static range(e,t,n,i){let s=(n??16777215)<<6|(i==null?7:Math.min(6,i));return t<e?ni.create(t,e,48|s):ni.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((i,s)=>i.from-s.from),t=e.indexOf(n);for(let i=1;i<e.length;i++){let s=e[i],o=e[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,l=Math.max(s.to,o.to);i<=t&&t--,e.splice(--i,2,s.anchor>s.head?Q.range(l,a):Q.range(a,l))}}return new Q(e,t)}}function b3(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let uh=0;class J{constructor(e,t,n,i,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=uh++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new J(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:hh),!!e.static,e.enables)}of(e){return new Za([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Za(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Za(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function hh(r,e){return r==e||r.length==e.length&&r.every((t,n)=>t===e[n])}class Za{constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=uh++}dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let h of this.dependencies)h=="doc"?l=!0:h=="selection"?c=!0:((t=e[h.id])!==null&&t!==void 0?t:1)&1||u.push(e[h.id]);return{create(h){return h.values[o]=n(h),1},update(h,d){if(l&&d.docChanged||c&&(d.docChanged||d.selection)||dh(h,u)){let f=n(h);if(a?!C3(f,h.values[o],i):!i(f,h.values[o]))return h.values[o]=f,1}return 0},reconfigure:(h,d)=>{let f,p=d.config.address[s];if(p!=null){let g=Ja(d,p);if(this.dependencies.every(m=>m instanceof J?d.facet(m)===h.facet(m):m instanceof vt?d.field(m,!1)==h.field(m,!1):!0)||(a?C3(f=n(h),g,i):i(f=n(h),g)))return h.values[o]=g,0}else f=n(h);return h.values[o]=f,1}}}}function C3(r,e,t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!t(r[n],e[n]))return!1;return!0}function dh(r,e){let t=!1;for(let n of e)qs(r,n)&1&&(t=!0);return t}function ZE(r,e,t){let n=t.map(l=>r[l.id]),i=t.map(l=>l.type),s=n.filter(l=>!(l&1)),o=r[e.id]>>1;function a(l){let c=[];for(let u=0;u<n.length;u++){let h=Ja(l,n[u]);if(i[u]==2)for(let d of h)c.push(d);else c.push(h)}return e.combine(c)}return{create(l){for(let c of n)qs(l,c);return l.values[o]=a(l),1},update(l,c){if(!dh(l,s))return 0;let u=a(l);return e.compare(u,l.values[o])?0:(l.values[o]=u,1)},reconfigure(l,c){let u=dh(l,n),h=c.config.facets[e.id],d=c.facet(e);if(h&&!u&&hh(t,h))return l.values[o]=d,0;let f=a(l);return e.compare(f,d)?(l.values[o]=d,0):(l.values[o]=f,1)}}}const Xa=J.define({static:!0});class vt{constructor(e,t,n,i,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let t=new vt(uh++,e.create,e.update,e.compare||((n,i)=>n===i),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Xa).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,i)=>{let s=n.values[t],o=this.updateF(s,i);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,i)=>{let s=n.facet(Xa),o=i.facet(Xa),a;return(a=s.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(n.values[t]=a.create(n),1):i.config.address[this.id]!=null?(n.values[t]=i.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,Xa.of({field:this,create:e})]}get extension(){return this}}const ri={lowest:4,low:3,default:2,high:1,highest:0};function Qs(r){return e=>new w3(e,r)}const ii={highest:Qs(ri.highest),high:Qs(ri.high),default:Qs(ri.default),low:Qs(ri.low),lowest:Qs(ri.lowest)};class w3{constructor(e,t){this.inner=e,this.prec=t}}class Ka{of(e){return new fh(this,e)}reconfigure(e){return Ka.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class fh{constructor(e,t){this.compartment=e,this.inner=t}}class Ga{constructor(e,t,n,i,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let i=[],s=Object.create(null),o=new Map;for(let d of XE(e,t,o))d instanceof vt?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let a=Object.create(null),l=[],c=[];for(let d of i)a[d.id]=c.length<<1,c.push(f=>d.slot(f));let u=n==null?void 0:n.config.facets;for(let d in s){let f=s[d],p=f[0].facet,g=u&&u[d]||[];if(f.every(m=>m.type==0))if(a[p.id]=l.length<<1|1,hh(g,f))l.push(n.facet(p));else{let m=p.combine(f.map(b=>b.value));l.push(n&&p.compare(m,n.facet(p))?n.facet(p):m)}else{for(let m of f)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=c.length<<1,c.push(b=>m.dynamicSlot(b)));a[p.id]=c.length<<1,c.push(m=>ZE(m,p,f))}}let h=c.map(d=>d(a));return new Ga(e,o,h,a,l,s)}}function XE(r,e,t){let n=[[],[],[],[],[]],i=new Map;function s(o,a){let l=i.get(o);if(l!=null){if(l<=a)return;let c=n[l].indexOf(o);c>-1&&n[l].splice(c,1),o instanceof fh&&t.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof fh){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),s(c,a)}else if(o instanceof w3)s(o.inner,o.prec);else if(o instanceof vt)n[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof Za)n[a].push(o),o.facet.extensions&&s(o.facet.extensions,ri.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,a)}}return s(r,ri.default),n.reduce((o,a)=>o.concat(a))}function qs(r,e){if(e&1)return 2;let t=e>>1,n=r.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;r.status[t]=4;let i=r.computeSlot(r,r.config.dynamicSlots[t]);return r.status[t]=2|i}function Ja(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}const k3=J.define(),ph=J.define({combine:r=>r.some(e=>e),static:!0}),S3=J.define({combine:r=>r.length?r[0]:void 0,static:!0}),_3=J.define(),x3=J.define(),O3=J.define(),E3=J.define({combine:r=>r.length?r[0]:!1});class Nn{constructor(e,t){this.type=e,this.value=t}static define(){return new KE}}class KE{of(e){return new Nn(this,e)}}class GE{constructor(e){this.map=e}of(e){return new fe(this,e)}}class fe{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new fe(this.type,t)}is(e){return this.type==e}static define(e={}){return new GE(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let s=i.map(t);s&&n.push(s)}return n}}fe.reconfigure=fe.define(),fe.appendConfig=fe.define();class lt{constructor(e,t,n,i,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&b3(n,t.newLength),s.some(a=>a.type==lt.time)||(this.annotations=s.concat(lt.time.of(Date.now())))}static create(e,t,n,i,s,o){return new lt(e,t,n,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(lt.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}lt.time=Nn.define(),lt.userEvent=Nn.define(),lt.addToHistory=Nn.define(),lt.remote=Nn.define();function JE(r,e){let t=[];for(let n=0,i=0;;){let s,o;if(n<r.length&&(i==e.length||e[i]>=r[n]))s=r[n++],o=r[n++];else if(i<e.length)s=e[i++],o=e[i++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function D3(r,e,t){var n;let i,s,o;return t?(i=e.changes,s=at.empty(e.changes.length),o=r.changes.compose(e.changes)):(i=e.changes.map(r.changes),s=r.changes.mapDesc(e.changes,!0),o=r.changes.compose(i)),{changes:o,selection:e.selection?e.selection.map(s):(n=r.selection)===null||n===void 0?void 0:n.map(i),effects:fe.mapEffects(r.effects,i).concat(fe.mapEffects(e.effects,s)),annotations:r.annotations.length?r.annotations.concat(e.annotations):e.annotations,scrollIntoView:r.scrollIntoView||e.scrollIntoView}}function mh(r,e,t){let n=e.selection,i=ji(e.annotations);return e.userEvent&&(i=i.concat(lt.userEvent.of(e.userEvent))),{changes:e.changes instanceof at?e.changes:at.of(e.changes||[],t,r.facet(S3)),selection:n&&(n instanceof Q?n:Q.single(n.anchor,n.head)),effects:ji(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function M3(r,e,t){let n=mh(r,e.length?e[0]:{},r.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;n=D3(n,mh(r,e[s],o?n.changes.newLength:r.doc.length),o)}let i=lt.create(r,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return tD(t?eD(i):i)}function eD(r){let e=r.startState,t=!0;for(let i of e.facet(_3)){let s=i(r);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:JE(t,s))}if(t!==!0){let i,s;if(t===!1)s=r.changes.invertedDesc,i=at.empty(e.doc.length);else{let o=r.changes.filter(t);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}r=lt.create(e,i,r.selection&&r.selection.map(s),fe.mapEffects(r.effects,s),r.annotations,r.scrollIntoView)}let n=e.facet(x3);for(let i=n.length-1;i>=0;i--){let s=n[i](r);s instanceof lt?r=s:Array.isArray(s)&&s.length==1&&s[0]instanceof lt?r=s[0]:r=M3(e,ji(s),!1)}return r}function tD(r){let e=r.startState,t=e.facet(O3),n=r;for(let i=t.length-1;i>=0;i--){let s=t[i](r);s&&Object.keys(s).length&&(n=D3(n,mh(e,s,r.changes.newLength),!0))}return n==r?r:lt.create(e,r.changes,r.selection,n.effects,n.annotations,n.scrollIntoView)}const nD=[];function ji(r){return r==null?nD:Array.isArray(r)?r:[r]}var ze=function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r}(ze||(ze={}));const rD=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let gh;try{gh=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function iD(r){if(gh)return gh.test(r);for(let e=0;e<r.length;e++){let t=r[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||rD.test(t)))return!0}return!1}function sD(r){return e=>{if(!/\S/.test(e))return ze.Space;if(iD(e))return ze.Word;for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return ze.Word;return ze.Other}}class we{constructor(e,t,n,i,s,o){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)qs(this,a<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return qs(this,n),Ja(this,n)}update(...e){return M3(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:i}=t;for(let a of e.effects)a.is(Ka.reconfigure)?(t&&(i=new Map,t.compartments.forEach((l,c)=>i.set(c,l)),t=null),i.set(a.value.compartment,a.value.extension)):a.is(fe.reconfigure)?(t=null,n=a.value):a.is(fe.appendConfig)&&(t=null,n=ji(n).concat(a.value));let s;t?s=e.startState.values.slice():(t=Ga.resolve(n,i,this),s=new we(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(ph)?e.newSelection:e.newSelection.asSingle();new we(t,e.newDoc,o,s,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Q.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),s=[n.range],o=ji(n.effects);for(let a=1;a<t.ranges.length;a++){let l=e(t.ranges[a]),c=this.changes(l.changes),u=c.map(i);for(let d=0;d<a;d++)s[d]=s[d].map(u);let h=i.mapDesc(c,!0);s.push(l.range.map(h)),i=i.compose(u),o=fe.mapEffects(o,u).concat(fe.mapEffects(ji(l.effects),h))}return{changes:i,selection:Q.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof at?e:at.of(e,this.doc.length,this.facet(we.lineSeparator))}toText(e){return xe.of(e.split(this.facet(we.lineSeparator)||ah))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(qs(this,t),Ja(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof vt&&this.config.address[i.id]!=null&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let o=n[s],a=e[s];i.push(o.init(l=>o.spec.fromJSON(a,l)))}}return we.create({doc:e.doc,selection:Q.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(e={}){let t=Ga.resolve(e.extensions||[],new Map),n=e.doc instanceof xe?e.doc:xe.of((e.doc||"").split(t.staticFacet(we.lineSeparator)||ah)),i=e.selection?e.selection instanceof Q?e.selection:Q.single(e.selection.anchor,e.selection.head):Q.single(0);return b3(i,n.length),t.staticFacet(ph)||(i=i.asSingle()),new we(t,n,i,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(we.tabSize)}get lineBreak(){return this.facet(we.lineSeparator)||`
@@ -587,7 +587,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
587
587
  `&&r.lineWrapping&&(n&&(n=Q.single(n.main.anchor-1,n.main.head-1)),t={from:i.from,to:i.to,insert:xe.of([" "])}),t)return Xh(r,t,n,s);if(n&&!n.main.eq(i)){let o=!1,a="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(o=!0),a=r.inputState.lastSelectionOrigin),r.dispatch({selection:n,scrollIntoView:o,userEvent:a}),!0}else return!1}function Xh(r,e,t,n=-1){if(ee.ios&&r.inputState.flushIOSKey(e))return!0;let i=r.state.selection.main;if(ee.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&r.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ui(r.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>i.head)&&Ui(r.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&Ui(r.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let o,a=()=>o||(o=KD(r,e,t));return r.state.facet(pg).some(l=>l(r,e.from,e.to,s,a))||r.dispatch(a()),!0}function KD(r,e,t){let n,i=r.state,s=i.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&r.inputState.composing<0){let a=s.from<e.from?i.sliceDoc(s.from,e.from):"",l=s.to>e.to?i.sliceDoc(e.to,s.to):"";n=i.replaceSelection(r.state.toText(a+e.insert.sliceString(0,void 0,r.state.lineBreak)+l))}else{let a=i.changes(e),l=t&&t.main.to<=a.newLength?t.main:void 0;if(i.selection.ranges.length>1&&r.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let c=r.state.sliceDoc(e.from,e.to),u,h=t&&Og(r,t.main.head);if(h){let p=e.insert.length-(e.to-e.from);u={from:h.from,to:h.to-p}}else u=r.state.doc.lineAt(s.head);let d=s.to-e.to,f=s.to-s.from;n=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:l||p.map(a)};let g=p.to-d,m=g-c.length;if(p.to-p.from!=f||r.state.sliceDoc(m,g)!=c||p.to>=u.from&&p.from<=u.to)return{range:p};let b=i.changes({from:m,to:g,insert:e.insert}),_=p.to-s.to;return{changes:b,range:l?Q.range(Math.max(0,l.anchor+_),Math.max(0,l.head+_)):p.map(b)}})}else n={changes:a,selection:l&&i.selection.replaceRange(l)}}let o="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,o+=".compose",r.inputState.compositionFirstChange&&(o+=".start",r.inputState.compositionFirstChange=!1)),i.update(n,{userEvent:o,scrollIntoView:!0})}function GD(r,e,t,n){let i=Math.min(r.length,e.length),s=0;for(;s<i&&r.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==i&&r.length==e.length)return null;let o=r.length,a=e.length;for(;o>0&&a>0&&r.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(n=="end"){let l=Math.max(0,s-Math.min(o,a));t-=o+l-s}if(o<s&&r.length<e.length){let l=t<=s&&t>=o?s-t:0;s-=l,a=s+(a-o),o=s}else if(a<s){let l=t<=s&&t>=a?s-t:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function JD(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}=r.observer.selectionRange;return t&&(e.push(new Rg(t,n)),(i!=t||s!=n)&&e.push(new Rg(i,s))),e}function eM(r,e){if(r.length==0)return null;let t=r[0].pos,n=r.length==2?r[1].pos:t;return t>-1&&n>-1?Q.single(t+e,n+e):null}class tM{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,ee.safari&&e.contentDOM.addEventListener("input",()=>null),ee.gecko&&yM(e.contentDOM.ownerDocument)}handleEvent(e){!cM(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let i of n.observers)i(this.view,t);for(let i of n.handlers){if(t.defaultPrevented)break;if(i(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=nM(e),n=this.handlers,i=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,a=n[s];a&&o!=!a.handlers.length&&(i.removeEventListener(s,this.handleEvent),a=null),a||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Bg.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),ee.android&&ee.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return ee.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Ig.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||rM.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ui(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:ee.safari&&!ee.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Ng(r,e){return(t,n)=>{try{return e.call(r,n,t)}catch(i){Ft(t.state,i)}}}function nM(r){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of r){let i=n.spec;if(i&&i.domEventHandlers)for(let s in i.domEventHandlers){let o=i.domEventHandlers[s];o&&t(s).handlers.push(Ng(n.value,o))}if(i&&i.domEventObservers)for(let s in i.domEventObservers){let o=i.domEventObservers[s];o&&t(s).observers.push(Ng(n.value,o))}}for(let n in mn)t(n).handlers.push(mn[n]);for(let n in rn)t(n).observers.push(rn[n]);return e}const Ig=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],rM="dthko",Bg=[16,17,18,20,91,92,224,225],hl=6;function dl(r){return Math.max(0,r)*.7+8}function iM(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}class sM{constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=fD(e.contentDOM),this.atoms=e.state.facet(qh).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(we.allowMultipleSelections)&&oM(e,t),this.dragging=lM(e,t)&&zg(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&iM(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,i=0,s=0,o=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:a}=this.scrollParents.y.getBoundingClientRect());let l=Uh(this.view);e.clientX-l.left<=i+hl?t=-dl(i-e.clientX):e.clientX+l.right>=o-hl&&(t=dl(e.clientX-o)),e.clientY-l.top<=s+hl?n=-dl(s-e.clientY):e.clientY+l.bottom>=a-hl&&(n=dl(e.clientY-a)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;n<e.ranges.length;n++){let i=e.ranges[n],s=null;if(i.empty){let o=ul(this.atoms,i.from,0);o!=i.from&&(s=Q.cursor(o,-1))}else{let o=ul(this.atoms,i.from,-1),a=ul(this.atoms,i.to,1);(o!=i.from||a!=i.to)&&(s=Q.range(i.from==i.anchor?o:a,i.from==i.head?o:a))}s&&(t||(t=e.ranges.slice()),t[n]=s)}return t?Q.create(t,e.mainIndex):e}select(e){let{view:t}=this,n=this.skipAtoms(this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function oM(r,e){let t=r.state.facet(ug);return t.length?t[0](e):ee.mac?e.metaKey:e.ctrlKey}function aM(r,e){let t=r.state.facet(hg);return t.length?t[0](e):ee.mac?!e.altKey:!e.ctrlKey}function lM(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let n=Ys(r.root);if(!n||n.rangeCount==0)return!0;let i=n.getRangeAt(0).getClientRects();for(let s=0;s<i.length;s++){let o=i[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function cM(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=r.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=Fe.get(t))&&n.ignoreEvent(e))return!1;return!0}const mn=Object.create(null),rn=Object.create(null),Hg=ee.ie&&ee.ie_version<15||ee.ios&&ee.webkit_version<604;function uM(r){let e=r.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{r.focus(),t.remove(),Fg(r,t.value)},50)}function fl(r,e,t){for(let n of r.facet(e))t=n(t,r);return t}function Fg(r,e){e=fl(r.state,Vh,e);let{state:t}=r,n,i=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Kh!=null&&t.selection.ranges.every(l=>l.empty)&&Kh==s.toString()){let l=-1;n=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let h=t.toText((o?s.line(i++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:h},range:Q.cursor(c.from+h.length)}})}else o?n=t.changeByRange(l=>{let c=s.line(i++);return{changes:{from:l.from,to:l.to,insert:c.text},range:Q.cursor(l.from+c.length)}}):n=t.replaceSelection(s);r.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}rn.scroll=r=>{r.inputState.lastScrollTop=r.scrollDOM.scrollTop,r.inputState.lastScrollLeft=r.scrollDOM.scrollLeft},mn.keydown=(r,e)=>(r.inputState.setSelectionOrigin("select"),e.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1),rn.touchstart=(r,e)=>{r.inputState.lastTouchTime=Date.now(),r.inputState.setSelectionOrigin("select.pointer")},rn.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")},mn.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of r.state.facet(dg))if(t=n(r,e),t)break;if(!t&&e.button==0&&(t=fM(r,e)),t){let n=!r.hasFocus;r.inputState.startMouseSelection(new sM(r,e,t,n)),n&&r.observer.ignore(()=>{F3(r.contentDOM);let s=r.root.activeElement;s&&!s.contains(r.contentDOM)&&s.blur()});let i=r.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}return!1};function Vg(r,e,t,n){if(n==1)return Q.cursor(e,t);if(n==2)return VD(r.state,e,t);{let i=rt.find(r.docView,e),s=r.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,a=i?i.posAtEnd:s.to;return a<r.state.doc.length&&a==s.to&&a++,Q.range(o,a)}}let jg=(r,e,t)=>e>=t.top&&e<=t.bottom&&r>=t.left&&r<=t.right;function hM(r,e,t,n){let i=rt.find(r.docView,e);if(!i)return 1;let s=e-i.posAtStart;if(s==0)return 1;if(s==i.length)return-1;let o=i.coordsAt(s,-1);if(o&&jg(t,n,o))return-1;let a=i.coordsAt(s,1);return a&&jg(t,n,a)?1:o&&o.bottom>=n?-1:1}function Wg(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:hM(r,t,e.clientX,e.clientY)}}const dM=ee.ie&&ee.ie_version<=11;let Qg=null,qg=0,Ug=0;function zg(r){if(!dM)return r.detail;let e=Qg,t=Ug;return Qg=r,Ug=Date.now(),qg=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(qg+1)%3:1}function fM(r,e){let t=Wg(r,e),n=zg(e),i=r.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),i=i.map(s.changes))},get(s,o,a){let l=Wg(r,s),c,u=Vg(r,l.pos,l.bias,n);if(t.pos!=l.pos&&!o){let h=Vg(r,t.pos,t.bias,n),d=Math.min(h.from,u.from),f=Math.max(h.to,u.to);u=d<u.from?Q.range(d,f):Q.range(f,d)}return o?i.replaceRange(i.main.extend(u.from,u.to)):a&&n==1&&i.ranges.length>1&&(c=pM(i,l.pos))?c:a?i.addRange(u):Q.create([u])}}}function pM(r,e){for(let t=0;t<r.ranges.length;t++){let{from:n,to:i}=r.ranges[t];if(n<=e&&i>=e)return Q.create(r.ranges.slice(0,t).concat(r.ranges.slice(t+1)),r.mainIndex==t?0:r.mainIndex-(r.mainIndex>t?1:0))}return null}mn.dragstart=(r,e)=>{let{selection:{main:t}}=r.state;if(e.target.draggable){let i=r.docView.nearest(e.target);if(i&&i.isWidget){let s=i.posAtStart,o=s+i.length;(s>=t.to||o<=t.from)&&(t=Q.range(s,o))}}let{inputState:n}=r;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",fl(r.state,jh,r.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1},mn.dragend=r=>(r.inputState.draggedContent=null,!1);function $g(r,e,t,n){if(t=fl(r.state,Vh,t),!t)return;let i=r.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=r.inputState,o=n&&s&&aM(r,e)?{from:s.from,to:s.to}:null,a={from:i,insert:t},l=r.state.changes(o?[o,a]:a);r.focus(),r.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),r.inputState.draggedContent=null}mn.drop=(r,e)=>{if(!e.dataTransfer)return!1;if(r.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),i=0,s=()=>{++i==t.length&&$g(r,e,n.filter(o=>o!=null).join(r.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let a=new FileReader;a.onerror=s,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[o]=a.result),s()},a.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return $g(r,e,n,!0),!0}return!1},mn.paste=(r,e)=>{if(r.state.readOnly)return!0;r.observer.flush();let t=Hg?null:e.clipboardData;return t?(Fg(r,t.getData("text/plain")||t.getData("text/uri-list")),!0):(uM(r),!1)};function mM(r,e){let t=r.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),r.focus()},50)}function gM(r){let e=[],t=[],n=!1;for(let i of r.selection.ranges)i.empty||(e.push(r.sliceDoc(i.from,i.to)),t.push(i));if(!e.length){let i=-1;for(let{from:s}of r.selection.ranges){let o=r.doc.lineAt(s);o.number>i&&(e.push(o.text),t.push({from:o.from,to:Math.min(r.doc.length,o.to+1)})),i=o.number}n=!0}return{text:fl(r,jh,e.join(r.lineBreak)),ranges:t,linewise:n}}let Kh=null;mn.copy=mn.cut=(r,e)=>{let{text:t,ranges:n,linewise:i}=gM(r.state);if(!t&&!i)return!1;Kh=i?t:null,e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=Hg?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(mM(r,t),!1)};const Yg=Nn.define();function Zg(r,e){let t=[];for(let n of r.facet(mg)){let i=n(r,e);i&&t.push(i)}return t.length?r.update({effects:t,annotations:Yg.of(!0)}):null}function Xg(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=Zg(r.state,e);t?r.dispatch(t):r.update([])}},10)}rn.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),Xg(r)},rn.blur=r=>{r.observer.clearSelectionRange(),Xg(r)},rn.compositionstart=rn.compositionupdate=r=>{r.observer.editContext||(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0&&(r.inputState.composing=0))},rn.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,ee.chrome&&ee.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))},rn.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()},mn.beforeinput=(r,e)=>{var t,n;if(e.inputType=="insertReplacementText"&&r.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let a=o[0],l=r.posAtDOM(a.startContainer,a.startOffset),c=r.posAtDOM(a.endContainer,a.endOffset);return Xh(r,{from:l,to:c,insert:r.state.toText(s)},null),!0}}let i;if(ee.chrome&&ee.android&&(i=Ig.find(s=>s.inputType==e.inputType))&&(r.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return ee.ios&&e.inputType=="deleteContentForward"&&r.observer.flushSoon(),ee.safari&&e.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>rn.compositionend(r,e),20),!1};const Kg=new Set;function yM(r){Kg.has(r)||(Kg.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}const Gg=["pre-wrap","normal","pre-line","break-spaces"];let Zi=!1;function Jg(){Zi=!1}class vM{constructor(e){this.lineWrapping=e,this.doc=xe.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Gg.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(i*10)]||(t=!0,this.heightSamples[Math.floor(i*10)]=!0)}return t}refresh(e,t,n,i,s,o){let a=Gg.indexOf(e)>-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=s,l){this.heightSamples={};for(let c=0;c<o.length;c++){let u=o[c];u<0?c++:this.heightSamples[Math.floor(u*10)]=!0}}return l}}class bM{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Fn{constructor(e,t,n,i,s){this.from=e,this.length=t,this.top=n,this.height=i,this._content=s}get type(){return typeof this._content=="number"?At.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Pr?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Fn(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var qe=function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r}(qe||(qe={}));const pl=.001;class Rt{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>pl&&(Zi=!0),this.height=e)}replace(e,t,n){return Rt.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let s=this,o=n.doc;for(let a=i.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:h}=i[a],d=s.lineAt(l,qe.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:s.lineAt(c,qe.ByPosNoHeight,n,0,0);for(h+=f.to-c,c=f.to;a>0&&d.from<=i[a-1].toA;)l=i[a-1].fromA,u=i[a-1].fromB,a--,l<d.from&&(d=s.lineAt(l,qe.ByPosNoHeight,n,0,0));u+=d.from-l,l=d.from;let p=Gh.build(n.setDoc(o),e,u,h);s=ml(s,s.replace(l,c,p))}return s.updateHeight(n,0)}static empty(){return new Zt(0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,i=0,s=0;for(;;)if(t==n)if(i>s*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),n+=1+a.break,i-=a.size}else if(s>i*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,s-=a.size}else break;else if(i<s){let a=e[t++];a&&(i+=a.size)}else{let a=e[--n];a&&(s+=a.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new CM(Rt.of(e.slice(0,t)),o,Rt.of(e.slice(n)))}}function ml(r,e){return r==e?r:(r.constructor!=e.constructor&&(Zi=!0),e)}Rt.prototype.size=1;class e6 extends Rt{constructor(e,t,n){super(e,t),this.deco=n}blockAt(e,t,n,i){return new Fn(i,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,i,s){return this.blockAt(0,n,i,s)}forEachLine(e,t,n,i,s,o){e<=s+this.length&&t>=s&&o(this.blockAt(0,n,i,s))}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more&&this.setHeight(i.heights[i.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zt extends e6{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,i){return new Fn(i,this.length,n,this.height,this.breaks)}replace(e,t,n){let i=n[0];return n.length==1&&(i instanceof Zt||i instanceof Ct&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Ct?i=new Zt(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):Rt.of(n)}updateHeight(e,t=0,n=!1,i){return i&&i.from<=t&&i.more?this.setHeight(i.heights[i.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ct extends Rt{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,s=i-n+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:i,perLine:o,perChar:a}}blockAt(e,t,n,i){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,i);if(t.lineWrapping){let c=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),u=t.doc.lineAt(c),h=a+u.length*l,d=Math.max(n,e-h/2);return new Fn(u.from,u.length,d,h,0)}else{let c=Math.max(0,Math.min(o-s,Math.floor((e-n)/a))),{from:u,length:h}=t.doc.line(s+c);return new Fn(u,h,n+a*c,a,0)}}lineAt(e,t,n,i,s){if(t==qe.ByHeight)return this.blockAt(e,n,i,s);if(t==qe.ByPosNoHeight){let{from:f,to:p}=n.doc.lineAt(e);return new Fn(f,p-f,0,0,0)}let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(n,s),c=n.doc.lineAt(e),u=a+c.length*l,h=c.number-o,d=i+a*h+l*(c.from-s-h);return new Fn(c.from,c.length,Math.max(i,Math.min(d,i+this.height-u)),u,0)}forEachLine(e,t,n,i,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:a,perLine:l,perChar:c}=this.heightMetrics(n,s);for(let u=e,h=i;u<=t;){let d=n.doc.lineAt(u);if(u==e){let p=d.number-a;h+=l*p+c*(e-s-p)}let f=l+c*d.length;o(new Fn(d.from,d.length,h,f,0)),h+=f,u=d.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let s=n[n.length-1];s instanceof Ct?n[n.length-1]=new Ct(s.length+i):n.push(null,new Ct(i-1))}if(e>0){let s=n[0];s instanceof Ct?n[0]=new Ct(e+s.length):n.unshift(new Ct(e-1),null)}return Rt.of(n)}decomposeLeft(e,t){t.push(new Ct(e-1),null)}decomposeRight(e,t){t.push(null,new Ct(this.length-e-1))}updateHeight(e,t=0,n=!1,i){let s=t+this.length;if(i&&i.from<=t+this.length&&i.more){let o=[],a=Math.max(t,i.from),l=-1;for(i.from>t&&o.push(new Ct(i.from-t-1).updateHeight(e,t));a<=s&&i.more;){let u=e.doc.lineAt(a).length;o.length&&o.push(null);let h=i.heights[i.index++];l==-1?l=h:Math.abs(h-l)>=pl&&(l=-2);let d=new Zt(u,h);d.outdated=!1,o.push(d),a+=u+1}a<=s&&o.push(null,new Ct(s-a).updateHeight(e,a));let c=Rt.of(o);return(l<0||Math.abs(c.height-this.height)>=pl||Math.abs(l-this.heightMetrics(e,t).perLine)>=pl)&&(Zi=!0),ml(this,c)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class CM extends Rt{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,i){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,s,i+this.left.length+this.break)}lineAt(e,t,n,i,s){let o=i+this.left.height,a=s+this.left.length+this.break,l=t==qe.ByHeight?e<o:e<a,c=l?this.left.lineAt(e,t,n,i,s):this.right.lineAt(e,t,n,o,a);if(this.break||(l?c.to<a:c.from>a))return c;let u=t==qe.ByPosNoHeight?qe.ByPosNoHeight:qe.ByPos;return l?c.join(this.right.lineAt(a,u,n,o,a)):this.left.lineAt(a,u,n,i,s).join(c)}forEachLine(e,t,n,i,s,o){let a=i+this.left.height,l=s+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,n,i,s,o),t>=l&&this.right.forEachLine(e,t,n,a,l,o);else{let c=this.lineAt(l,qe.ByPos,n,i,s);e<c.from&&this.left.forEachLine(e,c.from-1,n,i,s,o),c.to>=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,a,l,o)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of n)s.push(a);if(e>0&&t6(s,o-1),t<this.length){let a=s.length;this.decomposeRight(t,s),t6(s,a)}return Rt.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Rt.of(this.break?[e,null,t]:[e,t]):(this.left=ml(this.left,e),this.right=ml(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,i){let{left:s,right:o}=this,a=t+s.length+this.break,l=null;return i&&i.from<=t+s.length&&i.more?l=s=s.updateHeight(e,t,n,i):s.updateHeight(e,t,n),i&&i.from<=a+o.length&&i.more?l=o=o.updateHeight(e,a,n,i):o.updateHeight(e,a,n),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function t6(r,e){let t,n;r[e]==null&&(t=r[e-1])instanceof Ct&&(n=r[e+1])instanceof Ct&&r.splice(e-1,3,new Ct(t.length+1+n.length))}const wM=5;class Gh{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Zt?i.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Zt(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new e6(o,i,n)):(o||s||i>=wM)&&this.addLineDeco(i,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Zt(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Ct(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zt)return e;let t=new Zt(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Zt)&&!this.isCovered?this.nodes.push(new Zt(0,-1)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let i of this.nodes)i instanceof Zt&&i.updateHeight(this.oracle,n),n+=i?i.length:1;return this.nodes}static build(e,t,n,i){let s=new Gh(n,e);return Oe.spans(t,n,i,s,0),s.finish(n)}}function kM(r,e,t){let n=new SM;return Oe.compare(r,e,t,n,0),n.changes}class SM{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&ol(e,t,this.changes,5)}}function _M(r,e){let t=r.getBoundingClientRect(),n=r.ownerDocument,i=n.defaultView||window,s=Math.max(0,t.left),o=Math.min(i.innerWidth,t.right),a=Math.max(0,t.top),l=Math.min(i.innerHeight,t.bottom);for(let c=r.parentNode;c&&c!=n.body;)if(c.nodeType==1){let u=c,h=window.getComputedStyle(u);if((u.scrollHeight>u.clientHeight||u.scrollWidth>u.clientWidth)&&h.overflow!="visible"){let d=u.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),a=Math.max(a,d.top),l=Math.min(c==r.parentNode?i.innerHeight:l,d.bottom)}c=h.position=="absolute"||h.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function xM(r){let e=r.getBoundingClientRect(),t=r.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function OM(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Jh{constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],s=t[n];if(i.from!=s.from||i.to!=s.to||i.size!=s.size)return!1}return!0}draw(e,t){return ie.replace({widget:new EM(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class EM extends or{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class n6{constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=r6,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Qe.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(Qh).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new vM(t),this.stateDeco=e.facet(to).filter(n=>typeof n!="function"),this.heightMap=Rt.empty().applyChanges(this.stateDeco,xe.empty,this.heightOracle.setDoc(e.doc),[new nn(0,0,0,e.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ie.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new gl(s,o))}}return this.viewports=e.sort((n,i)=>n.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?r6:new ed(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(io(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(to).filter(u=>typeof u!="function");let i=e.changedRanges,s=nn.extendWithRanges(i,kM(n,this.stateDeco,e?e.changes:at.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Jg(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Zi)&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<l.from||t.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(yg)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),i=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Qe.RTL:Qe.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:C,scaleY:v}=H3(t,a);(C>.005&&Math.abs(this.scaleX-C)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=C,this.scaleY=v,c|=16,o=l=!0)}let h=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=h||this.paddingBottom!=d)&&(this.paddingTop=h,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=W3(e.scrollDOM);let p=(this.printing?OM:_M)(t,this.paddingTop),g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(l=!0)),!this.inView&&!this.scrollTarget&&!xM(e.dom))return 0;let _=a.width;if((this.contentDOMWidth!=_||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),l){let C=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(C)&&(o=!0),o||i.lineWrapping&&Math.abs(_-this.contentDOMWidth)>i.charWidth){let{lineHeight:v,charWidth:x,textHeight:S}=e.docView.measureTextSize();o=v>0&&i.refresh(s,v,x,S,_/x,C),o&&(e.docView.minWidth=0,c|=16)}g>0&&m>0?u=Math.max(g,m):g<0&&m<0&&(u=Math.min(g,m)),Jg();for(let v of this.viewports){let x=v.from==this.viewport.from?C:e.docView.measureVisibleLineHeights(v);this.heightMap=(o?Rt.empty().applyChanges(this.stateDeco,xe.empty,this.heightOracle,[new nn(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new bM(v.from,x))}Zi&&(c|=2)}let k=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return k&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),c|=this.updateForViewport()),(c&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new gl(i.lineAt(o-n*1e3,qe.ByHeight,s,0,0).from,i.lineAt(a+(1-n)*1e3,qe.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(c<l.from||c>l.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),h=i.lineAt(c,qe.ByPos,s,0,0),d;t.y=="center"?d=(h.top+h.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c<l.from?d=h.top:d=h.bottom-u,l=new gl(i.lineAt(d-1e3/2,qe.ByHeight,s,0,0).from,i.lineAt(d+u+1e3/2,qe.ByHeight,s,0,0).to)}}return l}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new gl(this.heightMap.lineAt(n,qe.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,qe.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:i}=this.heightMap.lineAt(e,qe.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,qe.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:a}=this;return(e==0||i<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=a+Math.max(10,Math.min(n,250)))&&i>o-2*1e3&&s<a+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new Jh(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,s=i>>1,o=i<<1;if(this.defaultTextDirection!=Qe.LTR&&!n)return[];let a=[],l=(u,h,d,f)=>{if(h-u<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let b of g)if(b>u&&b<h){l(u,b-10,d,f),l(b+10,h,d,f);return}let m=MM(e,b=>b.from>=d.from&&b.to<=d.to&&Math.abs(b.from-u)<s&&Math.abs(b.to-h)<s&&!g.some(_=>b.from<_&&b.to>_));if(!m){if(h<d.to&&t&&n&&t.visibleRanges.some(k=>k.from<=h&&k.to>=h)){let k=t.moveToLineBoundary(Q.cursor(h),!1,!0).head;k>u&&(h=k)}let b=this.gapSize(d,u,h,f),_=n||b<2e6?b:2e6;m=new Jh(u,h,b,_)}a.push(m)},c=u=>{if(u.length<o||u.type!=At.Text)return;let h=DM(u.from,u.to,this.stateDeco);if(h.total<o)return;let d=this.scrollTarget?this.scrollTarget.range.head:null,f,p;if(n){let g=i/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,b;if(d!=null){let _=vl(h,d),k=((this.visibleBottom-this.visibleTop)/2+g)/u.height;m=_-k,b=_+k}else m=(this.visibleTop-u.top-g)/u.height,b=(this.visibleBottom-u.top+g)/u.height;f=yl(h,m),p=yl(h,b)}else{let g=h.total*this.heightOracle.charWidth,m=i*this.heightOracle.charWidth,b=0;if(g>2e6)for(let x of e)x.from>=u.from&&x.from<u.to&&x.size!=x.displaySize&&x.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=x.size-x.displaySize);let _=this.pixelViewport.left+b,k=this.pixelViewport.right+b,C,v;if(d!=null){let x=vl(h,d),S=((k-_)/2+m)/g;C=x-S,v=x+S}else C=(_-m)/g,v=(k+m)/g;f=yl(h,C),p=yl(h,v)}f>u.from&&l(u.from,f,u,h),p<u.to&&l(p,u.to,u,h)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(c):c(u);return a}gapSize(e,t,n,i){let s=vl(i,n)-vl(i,t);return this.heightOracle.lineWrapping?e.height*s:i.total*this.heightOracle.charWidth*s}updateLineGaps(e){Jh.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=ie.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];Oe.spans(t,this.viewport.from,this.viewport.to,{span(s,o){n.push({from:s,to:o})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let s=0;s<n.length&&!(i&8);s++){let o=this.visibleRanges[s],a=n[s];(o.from!=a.from||o.to!=a.to)&&(i|=4,e&&e.mapPos(o.from,-1)==a.from&&e.mapPos(o.to,1)==a.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||io(this.heightMap.lineAt(e,qe.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||io(this.heightMap.lineAt(this.scaler.fromDOM(e),qe.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return io(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class gl{constructor(e,t){this.from=e,this.to=t}}function DM(r,e,t){let n=[],i=r,s=0;return Oe.spans(t,r,e,{span(){},point(o,a){o>i&&(n.push({from:i,to:o}),s+=o-i),i=a}},20),i<e&&(n.push({from:i,to:e}),s+=e-i),{total:s,ranges:n}}function yl({total:r,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(r*t);for(let i=0;;i++){let{from:s,to:o}=e[i],a=o-s;if(n<=a)return s+n;n-=a}}function vl(r,e){let t=0;for(let{from:n,to:i}of r.ranges){if(e<=i){t+=e-n;break}t+=i-n}return t/r.total}function MM(r,e){for(let t of r)if(e(t))return t}const r6={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}};class ed{constructor(e,t,n){let i=0,s=0,o=0;this.viewports=n.map(({from:a,to:l})=>{let c=t.lineAt(a,qe.ByPos,e,0,0).top,u=t.lineAt(l,qe.ByPos,e,0,0).bottom;return i+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,n=0,i=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return i+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,i=s.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-i)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,i=s.domBottom}}eq(e){return e instanceof ed?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function io(r,e){if(e.scale==1)return r;let t=e.toDOM(r.top),n=e.toDOM(r.bottom);return new Fn(r.from,r.length,t,n-t,Array.isArray(r._content)?r._content.map(i=>io(i,e)):r._content)}const bl=J.define({combine:r=>r.join(" ")}),td=J.define({combine:r=>r.indexOf(!0)>-1}),nd=Er.newName(),i6=Er.newName(),s6=Er.newName(),o6={"&light":"."+i6,"&dark":"."+s6};function rd(r,e,t){return new Er(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,i=>{if(i=="&")return r;if(!t||!t[i])throw new RangeError(`Unsupported selector: ${i}`);return t[i]}):r+" "+n}})}const PM=rd("."+nd,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},o6),TM={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},id=ee.ie&&ee.ie_version<=11;class AM{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new pD,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(ee.ie&&ee.ie_version<=11||ee.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(ee.chrome&&ee.chrome_version<126)&&(this.editContext=new LM(e),e.state.facet(lr)&&(e.contentDOM.editContext=this.editContext.editContext)),id&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(lr)?n.root.activeElement!=this.dom:!nl(this.dom,i))return;let s=i.anchorNode&&n.docView.nearest(i.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(ee.ie&&ee.ie_version<=11||ee.android&&ee.chrome)&&!n.state.selection.main.empty&&i.focusNode&&Zs(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ys(e.root);if(!t)return!1;let n=ee.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&RM(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=nl(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&gD(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,TM),id&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),id&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let i=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ui(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&nl(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new XD(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=Lg(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=a6(t,e.previousSibling||e.target.previousSibling,-1),i=a6(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(lr)!=e.state.facet(lr)&&(e.view.contentDOM.editContext=e.state.facet(lr)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function a6(r,e,t){for(;e;){let n=Fe.get(e);if(n&&n.parent==r)return n;let i=e.parentNode;e=i!=r.dom?i:t>0?e.nextSibling:e.previousSibling}return null}function l6(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,s=e.endOffset,o=r.docView.domAtPos(r.state.selection.main.anchor);return Zs(o.node,o.offset,i,s)&&([t,n,i,s]=[i,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}}function RM(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return l6(r,i)}let t=null;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",n,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",n,!0),t?l6(r,t):null}class LM{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let i=e.state.selection.main,{anchor:s,head:o}=i,a=this.toEditorPos(n.updateRangeStart),l=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:a,drifted:!1});let c={from:a,to:l,insert:xe.of(n.text.split(`
588
588
  `))};if(c.from==this.from&&s<this.from?c.from=s:c.to==this.to&&s>this.to&&(c.to=s),c.from==c.to&&!c.insert.length){let u=Q.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));u.main.eq(i)||e.dispatch({selection:u,userEvent:"select"});return}if((ee.mac||ee.android)&&c.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:a,to:l,insert:xe.of([n.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);Xh(e,c,Q.single(this.toEditorPos(n.selectionStart,u),this.toEditorPos(n.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=n=>{let i=[],s=null;for(let o=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);o<a;o++){let l=e.coordsForChar(o);s=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||s||new DOMRect,i.push(s)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=n=>{let i=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,a=s.underlineThickness;if(o!="None"&&a!="None"){let l=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(l<c){let u=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${a=="Thin"?1:2}px`;i.push(ie.mark({attributes:{style:u}}).range(l,c))}}}e.dispatch({effects:bg.of(ie.set(i))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let i=Ys(n.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,a,l,c)=>{if(n)return;let u=c.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(c)){i=this.pendingContextChange=null,t+=u,this.to+=u;return}else i=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),c.toString()),this.to+=u}t+=u}),i&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),i=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class X{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(i=>i.forEach(s=>n(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||mD(e.parent)||document,this.viewState=new n6(e.state||we.create(e)),e.scrollTo&&e.scrollTo.is(ll)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(eo).map(i=>new Wh(i));for(let i of this.plugins)i.update(this);this.observer=new AM(this),this.inputState=new tM(this),this.inputState.ensureHandlers(this.plugins),this.docView=new xg(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof lt?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,i,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(d=>d.annotation(Yg))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Zg(s,o),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(we.phrases)!=this.state.facet(we.phrases))return this.setState(s);i=cl.create(this,s,e),i.flags|=a;let h=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(h&&(h=h.map(d.changes)),d.scrollIntoView){let{main:f}=d.state.selection;h=new Yi(f.empty?f:Q.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of d.effects)f.is(ll)&&(h=f.value.clip(this.state))}this.viewState.update(i,h),this.bidiCache=Cl.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),t=this.docView.update(i),this.state.facet(no)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(bl)!=i.state.facet(bl)&&(this.viewState.mustMeasureContent=!0),(t||n||h||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(Fh))try{d(i)}catch(f){Ft(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Lg(this,u)&&c.force&&Ui(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new n6(e),this.plugins=e.facet(eo).map(n=>new Wh(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new xg(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(eo),n=e.state.facet(eo);if(t!=n){let i=[];for(let s of n){let o=t.indexOf(s);if(o<0)i.push(new Wh(s));else{let a=this.plugins[o];a.mustUpdate=e,i.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Ft(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(W3(n))s=-1,o=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(i);s=f.from,o=f.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(f=>{try{return f.read(this)}catch(p){return Ft(this.state,p),c6}}),h=cl.create(this,this.state,[]),d=!1;h.flags|=l,t?t.flags|=l:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),d=this.docView.update(h),d&&this.docViewUpdate());for(let f=0;f<c.length;f++)if(u[f]!=c6)try{let p=c[f];p.write&&p.write(u[f],this)}catch(p){Ft(this.state,p)}if(d&&this.docView.updateSelection(!0),!h.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(p>1||p<-1){i=i+p,n.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Fh))a(t)}get themeClasses(){return nd+" "+(this.state.facet(td)?s6:i6)+" "+this.state.facet(bl)}updateAttrs(){let e=u6(this,Cg,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(lr)?"true":"false",class:"cm-content",style:`${ee.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),u6(this,Qh,t);let n=this.observer.ignore(()=>{let i=Rh(this.contentDOM,this.contentAttrs,t),s=Rh(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let i of n.effects)if(i.is(X.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(no);let e=this.state.facet(X.cspNonce);Er.mount(this.root,this.styleModules.concat(PM).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.spec!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Zh(this,e,Ag(this,e,t,n))}moveByGroup(e,t){return Zh(this,e,Ag(this,e,t,n=>zD(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return Q.cursor(s.side(t,i)+e.from,s.forward(!t,i)?1:-1)}moveToLineBoundary(e,t,n=!0){return UD(this,e,t,n)}moveVertically(e,t,n){return Zh(this,e,$D(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Pg(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),s=this.bidiSpans(i),o=s[Tr.find(s,e-i.from,-1,t)];return Xs(n,o.dir==Qe.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(gg)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>NM)return lg(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||ag(s.isolates,n=Sg(this,e))))return s.order;n||(n=Sg(this,e));let i=MD(e.text,t,n);return this.bidiCache.push(new Cl(e.from,e.to,t,n,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||ee.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{F3(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return ll.of(new Yi(typeof e=="number"?Q.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return ll.of(new Yi(Q.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return tt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return tt.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Er.newName(),i=[bl.of(n),no.of(rd(`.${n}`,e))];return t&&t.dark&&i.push(td.of(!0)),i}static baseTheme(e){return ii.lowest(no.of(rd("."+nd,e,o6)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&Fe.get(n)||Fe.get(e);return((t=i==null?void 0:i.rootView)===null||t===void 0?void 0:t.view)||null}}X.styleModule=no,X.inputHandler=pg,X.clipboardInputFilter=Vh,X.clipboardOutputFilter=jh,X.scrollHandler=vg,X.focusChangeEffect=mg,X.perLineTextDirection=gg,X.exceptionSink=fg,X.updateListener=Fh,X.editable=lr,X.mouseSelectionStyle=dg,X.dragMovesSelection=hg,X.clickAddsSelectionRange=ug,X.decorations=to,X.outerDecorations=wg,X.atomicRanges=qh,X.bidiIsolatedRanges=kg,X.scrollMargins=_g,X.darkTheme=td,X.cspNonce=J.define({combine:r=>r.length?r[0]:""}),X.contentAttributes=Qh,X.editorAttributes=Cg,X.lineWrapping=X.contentAttributes.of({class:"cm-lineWrapping"}),X.announce=fe.define();const NM=4096,c6={};class Cl{constructor(e,t,n,i,s,o){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],i=e.length?e[e.length-1].dir:Qe.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==i&&!t.touchesRange(o.from,o.to)&&n.push(new Cl(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function u6(r,e,t){for(let n=r.state.facet(e),i=n.length-1;i>=0;i--){let s=n[i],o=typeof s=="function"?s(r):s;o&&Ah(o,t)}return t}const IM=ee.mac?"mac":ee.windows?"win":ee.linux?"linux":"key";function BM(r,e){const t=r.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let i,s,o,a;for(let l=0;l<t.length-1;++l){const c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(n="Alt-"+n),s&&(n="Ctrl-"+n),a&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function wl(r,e,t){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t!==!1&&e.shiftKey&&(r="Shift-"+r),r}const HM=ii.default(X.domEventHandlers({keydown(r,e){return f6(d6(e.state),r,e,"editor")}})),kl=J.define({enables:HM}),h6=new WeakMap;function d6(r){let e=r.facet(kl),t=h6.get(e);return t||h6.set(e,t=jM(e.reduce((n,i)=>n.concat(i),[]))),t}function FM(r,e,t){return f6(d6(r.state),e,r,t)}let Ar=null;const VM=4e3;function jM(r,e=IM){let t=Object.create(null),n=Object.create(null),i=(o,a)=>{let l=n[o];if(l==null)n[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,c,u)=>{var h,d;let f=t[o]||(t[o]=Object.create(null)),p=a.split(/ (?!$)/).map(b=>BM(b,e));for(let b=1;b<p.length;b++){let _=p.slice(0,b).join(" ");i(_,!0),f[_]||(f[_]={preventDefault:!0,stopPropagation:!1,run:[k=>{let C=Ar={view:k,prefix:_,scope:o};return setTimeout(()=>{Ar==C&&(Ar=null)},VM),!0}]})}let g=p.join(" ");i(g,!1);let m=f[g]||(f[g]={preventDefault:!1,stopPropagation:!1,run:((d=(h=f._any)===null||h===void 0?void 0:h.run)===null||d===void 0?void 0:d.slice())||[]});l&&m.run.push(l),c&&(m.preventDefault=!0),u&&(m.stopPropagation=!0)};for(let o of r){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:h}=o;for(let d in u)u[d].run.push(f=>h(f,sd))}let l=o[e]||o.key;if(l)for(let c of a)s(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}let sd=null;function f6(r,e,t,n){sd=e;let i=uD(e),s=Bt(i,0),o=Rn(s)==i.length&&i!=" ",a="",l=!1,c=!1,u=!1;Ar&&Ar.view==t&&Ar.scope==n&&(a=Ar.prefix+" ",Bg.indexOf(e.keyCode)<0&&(c=!0,Ar=null));let h=new Set,d=m=>{if(m){for(let b of m.run)if(!h.has(b)&&(h.add(b),b(t)))return m.stopPropagation&&(u=!0),!0;m.preventDefault&&(m.stopPropagation&&(u=!0),c=!0)}return!1},f=r[n],p,g;return f&&(d(f[a+wl(i,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ee.windows&&e.ctrlKey&&e.altKey)&&(p=Dr[e.keyCode])&&p!=i?(d(f[a+wl(p,e,!0)])||e.shiftKey&&(g=$s[e.keyCode])!=i&&g!=p&&d(f[a+wl(g,e,!1)]))&&(l=!0):o&&e.shiftKey&&d(f[a+wl(i,e,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),sd=null,l}class so{constructor(e,t,n,i,s){this.className=e,this.left=t,this.top=n,this.width=i,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let i=e.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let s=p6(e);return[new so(t,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return WM(e,t,n)}}function p6(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==Qe.LTR?e.left:e.right-r.scrollDOM.clientWidth*r.scaleX)-r.scrollDOM.scrollLeft*r.scaleX,top:e.top-r.scrollDOM.scrollTop*r.scaleY}}function m6(r,e,t,n){let i=r.coordsAtPos(e,t*2);if(!i)return n;let s=r.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,a=r.posAtCoords({x:s.left+1,y:o}),l=r.posAtCoords({x:s.right-1,y:o});return a==null||l==null?n:{from:Math.max(n.from,Math.min(a,l)),to:Math.min(n.to,Math.max(a,l))}}function WM(r,e,t){if(t.to<=r.viewport.from||t.from>=r.viewport.to)return[];let n=Math.max(t.from,r.viewport.from),i=Math.min(t.to,r.viewport.to),s=r.textDirection==Qe.LTR,o=r.contentDOM,a=o.getBoundingClientRect(),l=p6(r),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),h=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=a.right-(u?parseInt(u.paddingRight):0),f=Yh(r,n,1),p=Yh(r,i,-1),g=f.type==At.Text?f:null,m=p.type==At.Text?p:null;if(g&&(r.lineWrapping||f.widgetLineBreaks)&&(g=m6(r,n,1,g)),m&&(r.lineWrapping||p.widgetLineBreaks)&&(m=m6(r,i,-1,m)),g&&m&&g.from==m.from&&g.to==m.to)return _(k(t.from,t.to,g));{let v=g?k(t.from,null,g):C(f,!1),x=m?k(null,t.to,m):C(p,!0),S=[];return(g||f).to<(m||p).from-(g&&m?1:0)||f.widgetLineBreaks>1&&v.bottom+r.defaultLineHeight/2<x.top?S.push(b(h,v.bottom,d,x.top)):v.bottom<x.top&&r.elementAtHeight((v.bottom+x.top)/2).type==At.Text&&(v.bottom=x.top=(v.bottom+x.top)/2),_(v).concat(S).concat(_(x))}function b(v,x,S,D){return new so(e,v-l.left,x-l.top,S-v,D-x)}function _({top:v,bottom:x,horizontal:S}){let D=[];for(let P=0;P<S.length;P+=2)D.push(b(S[P],v,S[P+1],x));return D}function k(v,x,S){let D=1e9,P=-1e9,F=[];function A(L,H,j,q,$){let re=r.coordsAtPos(L,L==S.to?-2:2),he=r.coordsAtPos(j,j==S.from?2:-2);!re||!he||(D=Math.min(re.top,he.top,D),P=Math.max(re.bottom,he.bottom,P),$==Qe.LTR?F.push(s&&H?h:re.left,s&&q?d:he.right):F.push(!s&&q?h:he.left,!s&&H?d:re.right))}let N=v??S.from,B=x??S.to;for(let L of r.visibleRanges)if(L.to>N&&L.from<B)for(let H=Math.max(L.from,N),j=Math.min(L.to,B);;){let q=r.state.doc.lineAt(H);for(let $ of r.bidiSpans(q)){let re=$.from+q.from,he=$.to+q.from;if(re>=j)break;he>H&&A(Math.max(re,H),v==null&&re<=N,Math.min(he,j),x==null&&he>=B,$.dir)}if(H=q.to+1,H>=j)break}return F.length==0&&A(N,v==null,B,x==null,r.textDirection),{top:D,bottom:P,horizontal:F}}function C(v,x){let S=a.top+(x?v.top:v.bottom);return{top:S,bottom:S,horizontal:[]}}}function QM(r,e){return r.constructor==e.constructor&&r.eq(e)}class qM{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Sl)!=e.state.facet(Sl)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(Sl);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!QM(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[n].constructor&&i.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(i.draw(),t);for(;t;){let i=t.nextSibling;t.remove(),t=i}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Sl=J.define();function g6(r){return[tt.define(e=>new qM(e,r)),Sl.of(r)]}const oo=J.define({combine(r){return In(r,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function UM(r={}){return[oo.of(r),zM,$M,YM,yg.of(!0)]}function y6(r){return r.startState.facet(oo)!=r.state.facet(oo)}const zM=g6({above:!0,markers(r){let{state:e}=r,t=e.facet(oo),n=[];for(let i of e.selection.ranges){let s=i==e.selection.main;if(i.empty||t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:Q.cursor(i.head,i.head>i.anchor?-1:1);for(let l of so.forRange(r,o,a))n.push(l)}}return n},update(r,e){r.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=y6(r);return t&&v6(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){v6(e.state,r)},class:"cm-cursorLayer"});function v6(r,e){e.style.animationDuration=r.facet(oo).cursorBlinkRate+"ms"}const $M=g6({above:!1,markers(r){return r.state.selection.ranges.map(e=>e.empty?[]:so.forRange(r,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||y6(r)},class:"cm-selectionLayer"}),YM=ii.highest(X.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),b6=fe.define({map(r,e){return r==null?null:e.mapPos(r)}}),ao=vt.define({create(){return null},update(r,e){return r!=null&&(r=e.changes.mapPos(r)),e.effects.reduce((t,n)=>n.is(b6)?n.value:t,r)}}),ZM=tt.fromClass(class{constructor(r){this.view=r,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(r){var e;let t=r.state.field(ao);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(r.startState.field(ao)!=t||r.docChanged||r.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:r}=this,e=r.state.field(ao),t=e!=null&&r.coordsAtPos(e);if(!t)return null;let n=r.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+r.scrollDOM.scrollLeft*r.scaleX,top:t.top-n.top+r.scrollDOM.scrollTop*r.scaleY,height:t.bottom-t.top}}drawCursor(r){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;r?(this.cursor.style.left=r.left/e+"px",this.cursor.style.top=r.top/t+"px",this.cursor.style.height=r.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(r){this.view.state.field(ao)!=r&&this.view.dispatch({effects:b6.of(r)})}},{eventObservers:{dragover(r){this.setDropPos(this.view.posAtCoords({x:r.clientX,y:r.clientY}))},dragleave(r){(r.target==this.view.contentDOM||!this.view.contentDOM.contains(r.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function XM(){return[ao,ZM]}function C6(r,e,t,n,i){e.lastIndex=0;for(let s=r.iterRange(t,n),o=t,a;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;a=e.exec(s.value);)i(o+a.index,a)}function KM(r,e){let t=r.visibleRanges;if(t.length==1&&t[0].from==r.viewport.from&&t[0].to==r.viewport.to)return t;let n=[];for(let{from:i,to:s}of t)i=Math.max(r.state.doc.lineAt(i).from,i-e),s=Math.min(r.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=i?n[n.length-1].to=s:n.push({from:i,to:s});return n}class GM{constructor(e){const{regexp:t,decoration:n,decorate:i,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(a,l,c,u)=>i(u,c,c+a[0].length,a,l);else if(typeof n=="function")this.addMatch=(a,l,c,u)=>{let h=n(a,l,c);h&&u(c,c+a[0].length,h)};else if(n)this.addMatch=(a,l,c,u)=>u(c,c+a[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new ir,n=t.add.bind(t);for(let{from:i,to:s}of KM(e,this.maxLength))C6(e.state.doc,this.regexp,i,s,(o,a)=>this.addMatch(a,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,i=-1;return e.docChanged&&e.changes.iterChanges((s,o,a,l)=>{l>=e.view.viewport.from&&a<=e.view.viewport.to&&(n=Math.min(a,n),i=Math.max(l,i))}),e.viewportMoved||i-n>1e3?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),n,i):t}updateRange(e,t,n,i){for(let s of e.visibleRanges){let o=Math.max(s.from,n),a=Math.min(s.to,i);if(a>o){let l=e.state.doc.lineAt(o),c=l.to<a?e.state.doc.lineAt(a):l,u=Math.max(s.from,l.from),h=Math.min(s.to,c.to);if(this.boundary){for(;o>l.from;o--)if(this.boundary.test(l.text[o-1-l.from])){u=o;break}for(;a<c.to;a++)if(this.boundary.test(c.text[a-c.from])){h=a;break}}let d=[],f,p=(g,m,b)=>d.push(b.range(g,m));if(l==c)for(this.regexp.lastIndex=u-l.from;(f=this.regexp.exec(l.text))&&f.index<h-l.from;)this.addMatch(f,e,f.index+l.from,p);else C6(e.state.doc,this.regexp,u,h,(g,m)=>this.addMatch(m,e,g,p));t=t.update({filterFrom:u,filterTo:h,filter:(g,m)=>g<u||m>h,add:d})}}return t}}const od=/x/.unicode!=null?"gu":"g",JM=new RegExp(`[\0-\b
589
589
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,od),eP={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let ad=null;function tP(){var r;if(ad==null&&typeof document<"u"&&document.body){let e=document.body.style;ad=((r=e.tabSize)!==null&&r!==void 0?r:e.MozTabSize)!=null}return ad||!1}const _l=J.define({combine(r){let e=In(r,{render:null,specialChars:JM,addSpecialChars:null});return(e.replaceTabs=!tP())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,od)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,od)),e}});function nP(r={}){return[_l.of(r),rP()]}let w6=null;function rP(){return w6||(w6=tt.fromClass(class{constructor(r){this.view=r,this.decorations=ie.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(r.state.facet(_l)),this.decorations=this.decorator.createDeco(r)}makeDecorator(r){return new GM({regexp:r.specialChars,decoration:(e,t,n)=>{let{doc:i}=t.state,s=Bt(e[0],0);if(s==9){let o=i.lineAt(n),a=t.state.tabSize,l=Wi(o.text,a,n-o.from);return ie.replace({widget:new aP((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=ie.replace({widget:new oP(r,s)}))},boundary:r.replaceTabs?void 0:/[^]/})}update(r){let e=r.state.facet(_l);r.startState.facet(_l)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(r.view)):this.decorations=this.decorator.updateDeco(r,this.decorations)}},{decorations:r=>r.decorations}))}const iP="•";function sP(r){return r>=32?iP:r==10?"␤":String.fromCharCode(9216+r)}class oP extends or{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=sP(this.code),n=e.state.phrase("Control character")+" "+(eP[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,n,t);if(i)return i;let s=document.createElement("span");return s.textContent=t,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class aP extends or{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function lP(){return uP}const cP=ie.line({class:"cm-activeLine"}),uP=tt.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.docChanged||r.selectionSet)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=-1,t=[];for(let n of r.state.selection.ranges){let i=r.lineBlockAt(n.head);i.from>e&&(t.push(cP.range(i.from)),e=i.from)}return ie.set(t)}},{decorations:r=>r.decorations});class hP extends or{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Qi(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),i=Xs(t[0],n.direction!="rtl"),s=parseInt(n.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function dP(r){let e=tt.fromClass(class{constructor(t){this.view=t,this.placeholder=r?ie.set([ie.widget({widget:new hP(r),side:1}).range(0)]):ie.none}get decorations(){return this.view.state.doc.length?ie.none:this.placeholder}},{decorations:t=>t.decorations});return typeof r=="string"?[e,X.contentAttributes.of({"aria-placeholder":r})]:e}const ld=2e3;function fP(r,e,t){let n=Math.min(e.line,t.line),i=Math.max(e.line,t.line),s=[];if(e.off>ld||t.off>ld||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=n;l<=i;l++){let c=r.doc.line(l);c.length<=a&&s.push(Q.range(c.from+o,c.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=n;l<=i;l++){let c=r.doc.line(l),u=kh(c.text,o,r.tabSize,!0);if(u<0)s.push(Q.cursor(c.to));else{let h=kh(c.text,a,r.tabSize);s.push(Q.range(c.from+u,c.from+h))}}}return s}function pP(r,e){let t=r.coordsAtPos(r.viewport.from);return t?Math.round(Math.abs((t.left-e)/r.defaultCharacterWidth)):-1}function k6(r,e){let t=r.posAtCoords({x:e.clientX,y:e.clientY},!1),n=r.state.doc.lineAt(t),i=t-n.from,s=i>ld?-1:i==n.length?pP(r,e.clientX):Wi(n.text,r.state.tabSize,t-n.from);return{line:n.number,col:s,off:i}}function mP(r,e){let t=k6(r,e),n=r.state.selection;return t?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(t.line).from),o=i.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(i.changes)}},get(i,s,o){let a=k6(r,i);if(!a)return n;let l=fP(r.state,t,a);return l.length?o?Q.create(l.concat(n.ranges)):Q.create(l):n}}:null}function gP(r){let e=t=>t.altKey&&t.button==0;return X.mouseSelectionStyle.of((t,n)=>e(n)?mP(t,n):null)}const yP={Alt:[18,r=>!!r.altKey],Control:[17,r=>!!r.ctrlKey],Shift:[16,r=>!!r.shiftKey],Meta:[91,r=>!!r.metaKey]},vP={style:"cursor: crosshair"};function bP(r={}){let[e,t]=yP[r.key||"Alt"],n=tt.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==e||t(i))},keyup(i){(i.keyCode==e||!t(i))&&this.set(!1)},mousemove(i){this.set(t(i))}}});return[n,X.contentAttributes.of(i=>{var s;return!((s=i.plugin(n))===null||s===void 0)&&s.isDown?vP:null})]}const lo="-10000px";class S6{constructor(e,t,n,i){this.facet=t,this.createTooltipView=n,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=n(o,s))}update(e,t){var n;let i=e.state.facet(this.facet),s=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=t?[]:null;for(let l=0;l<s.length;l++){let c=s[l],u=-1;if(c){for(let h=0;h<this.tooltips.length;h++){let d=this.tooltips[h];d&&d.create==c.create&&(u=h)}if(u<0)o[l]=this.createTooltipView(c,l?o[l-1]:null),a&&(a[l]=!!c.above);else{let h=o[l]=this.tooltipViews[u];a&&(a[l]=t[u]),h.update&&h.update(e)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(n=l.destroy)===null||n===void 0||n.call(l));return t&&(a.forEach((l,c)=>t[c]=l),t.length=a.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function CP(r){let e=r.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const cd=J.define({combine:r=>{var e,t,n;return{position:ee.ios?"absolute":((e=r.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=r.find(i=>i.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=r.find(i=>i.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||CP}}}),_6=new WeakMap,ud=tt.fromClass(class{constructor(r){this.view=r,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=r.state.facet(cd);this.position=e.position,this.parent=e.parent,this.classes=r.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new S6(r,hd,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),r.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let r of this.manager.tooltipViews)this.intersectionObserver.observe(r.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(r){r.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(r,this.above);e&&this.observeIntersection();let t=e||r.geometryChanged,n=r.state.facet(cd);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(r,e){let t=r.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),r.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",t.dom.appendChild(i)}return t.dom.style.position=this.position,t.dom.style.top=lo,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var r,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(r=n.destroy)===null||r===void 0||r.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let r=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(ee.gecko)t=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==lo&&s.style.left=="0px"){let o=s.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(t||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(r=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:r,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),i=Uh(this.view);return{visible:{left:n.left+i.left,top:n.top+i.top,right:n.right-i.right,bottom:n.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let a=this.manager.tooltipViews[o];return a.getCoords?a.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(cd).tooltipSpace(this.view),scaleX:r,scaleY:e,makeAbsolute:t}}writeMeasure(r){var e;if(r.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:n,scaleX:i,scaleY:s}=r,o=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,h=r.pos[a],d=r.size[a];if(!h||l.clip!==!1&&(h.bottom<=Math.max(t.top,n.top)||h.top>=Math.min(t.bottom,n.bottom)||h.right<Math.max(t.left,n.left)-.1||h.left>Math.min(t.right,n.right)+.1)){u.style.top=lo;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,g=d.right-d.left,m=(e=_6.get(c))!==null&&e!==void 0?e:d.bottom-d.top,b=c.offset||kP,_=this.view.textDirection==Qe.LTR,k=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(h.left-(f?14:0)+b.x,n.right-g)):Math.min(Math.max(n.left,h.left-g+(f?14:0)-b.x),n.right-g),C=this.above[a];!l.strictSide&&(C?h.top-m-p-b.y<n.top:h.bottom+m+p+b.y>n.bottom)&&C==n.bottom-h.bottom>h.top-n.top&&(C=this.above[a]=!C);let v=(C?h.top-n.top:n.bottom-h.bottom)-p;if(v<m&&c.resize!==!1){if(v<this.view.defaultLineHeight){u.style.top=lo;continue}_6.set(c,m),u.style.height=(m=v)/s+"px"}else u.style.height&&(u.style.height="");let x=C?h.top-m-p-b.y:h.bottom+p+b.y,S=k+g;if(c.overlap!==!0)for(let D of o)D.left<S&&D.right>k&&D.top<x+m&&D.bottom>x&&(x=C?D.top-m-2-p:D.bottom+p+2);if(this.position=="absolute"?(u.style.top=(x-r.parent.top)/s+"px",x6(u,(k-r.parent.left)/i)):(u.style.top=x/s+"px",x6(u,k/i)),f){let D=h.left+(_?b.x:-b.x)-(k+14-7);f.style.left=D/i+"px"}c.overlap!==!0&&o.push({left:k,top:x,right:S,bottom:x+m}),u.classList.toggle("cm-tooltip-above",C),u.classList.toggle("cm-tooltip-below",!C),c.positioned&&c.positioned(r.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let r of this.manager.tooltipViews)r.dom.style.top=lo}},{eventObservers:{scroll(){this.maybeMeasure()}}});function x6(r,e){let t=parseInt(r.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(r.style.left=e+"px")}const wP=X.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),kP={x:0,y:0},hd=J.define({enables:[ud,wP]}),xl=J.define({combine:r=>r.reduce((e,t)=>e.concat(t),[])});class Ol{static create(e){return new Ol(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new S6(e,xl,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let i=n[e];if(i!==void 0){if(t===void 0)t=i;else if(t!==i)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const SP=hd.compute([xl],r=>{let e=r.facet(xl);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:Ol.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class _P{constructor(e,t,n,i,s){this.view=e,this.source=t,this.field=n,this.setHover=i,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.nearest(t.target);if(!n)return;let i,s=1;if(n instanceof Mr)i=n.posAtStart;else{if(i=e.posAtCoords(t),i==null)return;let a=e.coordsAtPos(i);if(!a||t.y<a.top||t.y>a.bottom||t.x<a.left-e.defaultCharacterWidth||t.x>a.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==Qe.RTL?-1:1;s=t.x<a.left?-c:c}let o=this.source(e,i,s);if(o!=null&&o.then){let a=this.pending={pos:i};o.then(l=>{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Ft(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(ud),t=e?e.manager.tooltips.findIndex(n=>n.create==Ol.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&s&&!xP(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,a=(n=(t=i[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!OP(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const El=4;function xP(r,e){let{left:t,right:n,top:i,bottom:s}=r.getBoundingClientRect(),o;if(o=r.querySelector(".cm-tooltip-arrow")){let a=o.getBoundingClientRect();i=Math.min(a.top,i),s=Math.max(a.bottom,s)}return e.clientX>=t-El&&e.clientX<=n+El&&e.clientY>=i-El&&e.clientY<=s+El}function OP(r,e,t,n,i,s){let o=r.scrollDOM.getBoundingClientRect(),a=r.documentTop+r.documentPadding.top+r.contentHeight;if(o.left>n||o.right<n||o.top>i||Math.min(o.bottom,a)<i)return!1;let l=r.posAtCoords({x:n,y:i},!1);return l>=e&&l<=t}function EP(r,e={}){let t=fe.define(),n=vt.define({create(){return[]},update(i,s){if(i.length&&(e.hideOnChange&&(s.docChanged||s.selection)?i=[]:e.hideOn&&(i=i.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of i){let l=s.changes.mapPos(a.pos,-1,Tt.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),o.push(c)}}i=o}for(let o of s.effects)o.is(t)&&(i=o.value),o.is(DP)&&(i=[]);return i},provide:i=>xl.from(i)});return{active:n,extension:[n,tt.define(i=>new _P(i,r,n,t,e.hoverTime||300)),SP]}}function O6(r,e){let t=r.plugin(ud);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const DP=fe.define(),E6=J.define({combine(r){let e,t;for(let n of r)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function co(r,e){let t=r.plugin(D6),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const D6=tt.fromClass(class{constructor(r){this.input=r.state.facet(uo),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(r));let e=r.state.facet(E6);this.top=new Dl(r,!0,e.topContainer),this.bottom=new Dl(r,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(r){let e=r.state.facet(E6);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Dl(r.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Dl(r.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=r.state.facet(uo);if(t!=this.input){let n=t.filter(l=>l),i=[],s=[],o=[],a=[];for(let l of n){let c=this.specs.indexOf(l),u;c<0?(u=l(r.view),a.push(u)):(u=this.panels[c],u.update&&u.update(r)),i.push(u),(u.top?s:o).push(u)}this.specs=n,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>X.scrollMargins.of(e=>{let t=e.plugin(r);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Dl{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=M6(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=M6(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function M6(r){let e=r.nextSibling;return r.remove(),e}const uo=J.define({enables:D6});class cr extends si{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}cr.prototype.elementClass="",cr.prototype.toDOM=void 0,cr.prototype.mapMode=Tt.TrackBefore,cr.prototype.startSide=cr.prototype.endSide=-1,cr.prototype.point=!0;const Ml=J.define(),MP=J.define(),PP={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Oe.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},ho=J.define();function TP(r){return[T6(),ho.of(Object.assign(Object.assign({},PP),r))]}const P6=J.define({combine:r=>r.some(e=>e)});function T6(r){return[AP]}const AP=tt.fromClass(class{constructor(r){this.view=r,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(ho).map(e=>new R6(r,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!r.state.facet(P6),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}update(r){if(this.updateGutters(r)){let e=this.prevViewport,t=r.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}r.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(P6)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=r.view.viewport}syncGutters(r){let e=this.dom.nextSibling;r&&this.dom.remove();let t=Oe.iter(this.view.state.facet(Ml),this.view.viewport.from),n=[],i=this.gutters.map(s=>new RP(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==At.Text&&o){dd(t,n,a.from);for(let l of i)l.line(this.view,a,n);o=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(s.type==At.Text){dd(t,n,s.from);for(let o of i)o.line(this.view,s,n)}else if(s.widget)for(let o of i)o.widget(this.view,s);for(let s of i)s.finish();r&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(r){let e=r.startState.facet(ho),t=r.state.facet(ho),n=r.docChanged||r.heightChanged||r.viewportChanged||!Oe.eq(r.startState.facet(Ml),r.state.facet(Ml),r.view.viewport.from,r.view.viewport.to);if(e==t)for(let i of this.gutters)i.update(r)&&(n=!0);else{n=!0;let i=[];for(let s of t){let o=e.indexOf(s);o<0?i.push(new R6(this.view,s)):(this.gutters[o].update(r),i.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)this.dom.appendChild(s.dom);this.gutters=i}return n}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove()}},{provide:r=>X.scrollMargins.of(e=>{let t=e.plugin(r);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==Qe.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function A6(r){return Array.isArray(r)?r:[r]}function dd(r,e,t){for(;r.value&&r.from<=t;)r.from==t&&e.push(r.value),r.next()}class RP{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=Oe.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:i}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==i.elements.length){let a=new L6(e,o,s,n);i.elements.push(a),i.dom.appendChild(a.dom)}else i.elements[this.i].update(e,o,s,n);this.height=t.bottom,this.i++}line(e,t,n){let i=[];dd(this.cursor,i,t.from),n.length&&(i=i.concat(n));let s=this.gutter.config.lineMarker(e,t,i);s&&i.unshift(s);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,i)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),i=n?[n]:null;for(let s of e.state.facet(MP)){let o=s(e,t.widget,t);o&&(i||(i=[])).push(o)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class R6{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,i=>{let s=i.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,a,i)&&i.preventDefault()});this.markers=A6(t.markers(e)),t.initialSpacer&&(this.spacer=new L6(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=A6(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],e);i!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[i])}let n=e.view.viewport;return!Oe.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class L6{constructor(e,t,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,i)}update(e,t,n,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),LP(this.markers,i)||this.setMarkers(e,i)}setMarkers(e,t){let n="cm-gutterElement",i=this.dom.firstChild;for(let s=0,o=0;;){let a=o,l=s<t.length?t[s++]:null,c=!1;if(l){let u=l.elementClass;u&&(n+=" "+u);for(let h=o;h<this.markers.length;h++)if(this.markers[h].compare(l)){a=h,c=!0;break}}else a=this.markers.length;for(;o<a;){let u=this.markers[o++];if(u.toDOM){u.destroy(i);let h=i.nextSibling;i.remove(),i=h}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(e),i)),c&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}function LP(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].compare(e[t]))return!1;return!0}const NP=J.define(),IP=J.define(),Xi=J.define({combine(r){return In(r,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let i in t){let s=n[i],o=t[i];n[i]=s?(a,l,c)=>s(a,l,c)||o(a,l,c):o}return n}})}});class fd extends cr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function pd(r,e){return r.state.facet(Xi).formatNumber(e,r.state)}const BP=ho.compute([Xi],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(NP)},lineMarker(e,t,n){return n.some(i=>i.toDOM)?null:new fd(pd(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let i of e.state.facet(IP)){let s=i(e,t,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Xi)!=e.state.facet(Xi),initialSpacer(e){return new fd(pd(e,N6(e.state.doc.lines)))},updateSpacer(e,t){let n=pd(t.view,N6(t.view.state.doc.lines));return n==e.number?e:new fd(n)},domEventHandlers:r.facet(Xi).domEventHandlers}));function HP(r={}){return[Xi.of(r),T6(),BP]}function N6(r){let e=9;for(;e<r;)e=e*10+9;return e}const FP=new class extends cr{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},VP=Ml.compute(["selection"],r=>{let e=[],t=-1;for(let n of r.selection.ranges){let i=r.doc.lineAt(n.head).from;i>t&&(t=i,e.push(FP.range(i)))}return Oe.of(e)});function jP(){return VP}const I6=1024;let WP=0;class md{constructor(e,t){this.from=e,this.to=t}}class be{constructor(e={}){this.id=WP++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Vt.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}be.closedBy=new be({deserialize:r=>r.split(" ")}),be.openedBy=new be({deserialize:r=>r.split(" ")}),be.group=new be({deserialize:r=>r.split(" ")}),be.isolate=new be({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}}),be.contextHash=new be({perNode:!0}),be.lookAhead=new be({perNode:!0}),be.mounted=new be({perNode:!0});class Pl{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[be.mounted.id]}}const QP=Object.create(null);class Vt{constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}static define(e){let t=e.props&&e.props.length?Object.create(null):QP,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Vt(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(be.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return n=>{for(let i=n.prop(be.group),s=-1;s<(i?i.length:0);s++){let o=t[s<0?n.name:i[s]];if(o)return o}}}}Vt.none=new Vt("",Object.create(null),0,8);class gd{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let i=null;for(let s of e){let o=s(n);o&&(i||(i=Object.assign({},n.props)),i[o[0].id]=o[1])}t.push(i?new Vt(n.name,i,n.id,n.flags):n)}return new gd(t)}}const Tl=new WeakMap,B6=new WeakMap;var ht;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays"})(ht||(ht={}));class it{constructor(e,t,n,i,s){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=Pl.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let i=n.toString();i&&(t&&(t+=","),t+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new bd(this.topNode,e)}cursorAt(e,t=0,n=0){let i=Tl.get(this)||this.topNode,s=new bd(i);return s.moveTo(e,t),Tl.set(this,s._tree),s}get topNode(){return new sn(this,0,0,null)}resolve(e,t=0){let n=fo(Tl.get(this)||this.topNode,e,t,!1);return Tl.set(this,n),n}resolveInner(e,t=0){let n=fo(B6.get(this)||this.topNode,e,t,!0);return B6.set(this,n),n}resolveStack(e,t=0){return zP(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&ht.IncludeAnonymous)>0;for(let l=this.cursor(o|ht.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&n&&(a||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:wd(Vt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,i)=>new it(this.type,t,n,i,this.propValues),e.makeTree||((t,n,i)=>new it(Vt.none,t,n,i)))}static build(e){return $P(e)}}it.empty=new it(Vt.none,[],[],0);class yd{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new yd(this.buffer,this.index)}}class Rr{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Vt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,n,i,s){let{buffer:o}=this,a=-1;for(let l=e;l!=t&&!(H6(s,i,o[l+1],o[l+2])&&(a=l,n>0));l=o[l+3]);return a}slice(e,t,n){let i=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a<t;){s[l++]=i[a++],s[l++]=i[a++]-n;let c=s[l++]=i[a++]-n;s[l++]=i[a++]-e,o=Math.max(o,c)}return new Rr(s,o,this.set)}}function H6(r,e,t,n){switch(r){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function fo(r,e,t,n){for(var i;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let o=!n&&r instanceof sn&&r.index<0?null:r.parent;if(!o)return r;r=o}let s=n?0:ht.IgnoreOverlays;if(n)for(let o=r,a=o.parent;a;o=a,a=o.parent)o instanceof sn&&o.index<0&&((i=a.enter(e,t,s))===null||i===void 0?void 0:i.from)!=o.from&&(r=a);for(;;){let o=r.enter(e,t,s);if(!o)return r;r=o}}class F6{cursor(e=0){return new bd(this,e)}getChild(e,t=null,n=null){let i=V6(this,e,t,n);return i.length?i[0]:null}getChildren(e,t=null,n=null){return V6(this,e,t,n)}resolve(e,t=0){return fo(this,e,t,!1)}resolveInner(e,t=0){return fo(this,e,t,!0)}matchContext(e){return vd(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(n=t,t=i.prevSibling):t=i}return n}get node(){return this}get next(){return this.parent}}class sn extends F6{constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=t>0?a.length:-1;e!=c;e+=t){let u=a[e],h=l[e]+o.from;if(H6(i,n,h,h+u.length)){if(u instanceof Rr){if(s&ht.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,n-h,i);if(d>-1)return new Lr(new qP(o,u,e,h),null,d)}else if(s&ht.IncludeAnonymous||!u.type.isAnonymous||Cd(u)){let d;if(!(s&ht.IgnoreMounts)&&(d=Pl.get(u))&&!d.overlay)return new sn(d.tree,h,e,o);let f=new sn(u,h,e,o);return s&ht.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(t<0?u.children.length-1:0,t,n,i)}}}if(s&ht.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let i;if(!(n&ht.IgnoreOverlays)&&(i=Pl.get(this._tree))&&i.overlay){let s=e-this.from;for(let{from:o,to:a}of i.overlay)if((t>0?o<=s:o<s)&&(t<0?a>=s:a>s))return new sn(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function V6(r,e,t,n){let i=r.cursor(),s=[];if(!i.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=i.type.is(t),!i.nextSibling())return s}for(;;){if(n!=null&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return n==null?s:[]}}function vd(r,e,t=e.length-1){for(let n=r;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class qP{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class Lr extends F6{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new Lr(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,n=0){if(n&ht.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new Lr(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Lr(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Lr(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,s=n.buffer[this.index+3];if(s>i){let o=n.buffer[this.index+1];e.push(n.slice(i,s,o)),t.push(0)}return new it(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function j6(r){if(!r.length)return null;let e=0,t=r[0];for(let s=1;s<r.length;s++){let o=r[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let n=t instanceof sn&&t.index<0?null:t.parent,i=r.slice();return n?i[e]=n:i.splice(e,1),new UP(i,t)}class UP{constructor(e,t){this.heads=e,this.node=t}get next(){return j6(this.heads)}}function zP(r,e,t){let n=r.resolveInner(e,t),i=null;for(let s=n instanceof sn?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[n])).push(o.resolve(e,t)),s=o}else{let o=Pl.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new sn(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[n])).push(fo(a,e,t,!1))}}return i?j6(i):n}class bd{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof sn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return e?e instanceof sn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&ht.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ht.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ht.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let i=n<0?0:this.stack[n]+4;if(this.index!=i)return this.yieldBuf(t.findChild(i,this.index,-1,0,4))}else{let i=t.buffer[this.index+3];if(i<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(i)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let a=n._tree.children[s];if(this.mode&ht.IncludeAnonymous||a instanceof Rr||!a.type.isAnonymous||Cd(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;t=o,n=s+1;break e}i=this.stack[--s]}for(let i=n;i<this.stack.length;i++)t=new Lr(this.buffer,t,this.stack[i]);return this.bufferNode=new Lr(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return vd(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return vd(this._tree,e,i);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Cd(r){return r.children.some(e=>e instanceof Rr||!e.type.isAnonymous||Cd(e))}function $P(r){var e;let{buffer:t,nodeSet:n,maxBufferLength:i=I6,reused:s=[],minRepeatType:o=n.types.length}=r,a=Array.isArray(t)?new yd(t,t.length):t,l=n.types,c=0,u=0;function h(v,x,S,D,P,F){let{id:A,start:N,end:B,size:L}=a,H=u,j=c;for(;L<0;)if(a.next(),L==-1){let ce=s[A];S.push(ce),D.push(N-v);return}else if(L==-3){c=A;return}else if(L==-4){u=A;return}else throw new RangeError(`Unrecognized record size: ${L}`);let q=l[A],$,re,he=N-v;if(B-N<=i&&(re=m(a.pos-x,P))){let ce=new Uint16Array(re.size-re.skip),Ue=a.pos-re.size,R=ce.length;for(;a.pos>Ue;)R=b(re.start,ce,R);$=new Rr(ce,B-re.start,n),he=re.start-v}else{let ce=a.pos-L;a.next();let Ue=[],R=[],W=A>=o?A:-1,z=0,pe=B;for(;a.pos>ce;)W>=0&&a.id==W&&a.size>=0?(a.end<=pe-i&&(p(Ue,R,N,z,a.end,pe,W,H,j),z=Ue.length,pe=a.end),a.next()):F>2500?d(N,ce,Ue,R):h(N,ce,Ue,R,W,F+1);if(W>=0&&z>0&&z<Ue.length&&p(Ue,R,N,z,N,pe,W,H,j),Ue.reverse(),R.reverse(),W>-1&&z>0){let Ne=f(q,j);$=wd(q,Ue,R,0,Ue.length,0,B-N,Ne,Ne)}else $=g(q,Ue,R,B-N,H-B,j)}S.push($),D.push(he)}function d(v,x,S,D){let P=[],F=0,A=-1;for(;a.pos>x;){let{id:N,start:B,end:L,size:H}=a;if(H>4)a.next();else{if(A>-1&&B<A)break;A<0&&(A=L-i),P.push(N,B,L),F++,a.next()}}if(F){let N=new Uint16Array(F*4),B=P[P.length-2];for(let L=P.length-3,H=0;L>=0;L-=3)N[H++]=P[L],N[H++]=P[L+1]-B,N[H++]=P[L+2]-B,N[H++]=H;S.push(new Rr(N,P[2]-B,n)),D.push(B-v)}}function f(v,x){return(S,D,P)=>{let F=0,A=S.length-1,N,B;if(A>=0&&(N=S[A])instanceof it){if(!A&&N.type==v&&N.length==P)return N;(B=N.prop(be.lookAhead))&&(F=D[A]+N.length+B)}return g(v,S,D,P,F,x)}}function p(v,x,S,D,P,F,A,N,B){let L=[],H=[];for(;v.length>D;)L.push(v.pop()),H.push(x.pop()+S-P);v.push(g(n.types[A],L,H,F-P,N-F,B)),x.push(P-S)}function g(v,x,S,D,P,F,A){if(F){let N=[be.contextHash,F];A=A?[N].concat(A):[N]}if(P>25){let N=[be.lookAhead,P];A=A?[N].concat(A):[N]}return new it(v,x,S,D,A)}function m(v,x){let S=a.fork(),D=0,P=0,F=0,A=S.end-i,N={size:0,start:0,skip:0};e:for(let B=S.pos-v;S.pos>B;){let L=S.size;if(S.id==x&&L>=0){N.size=D,N.start=P,N.skip=F,F+=4,D+=4,S.next();continue}let H=S.pos-L;if(L<0||H<B||S.start<A)break;let j=S.id>=o?4:0,q=S.start;for(S.next();S.pos>H;){if(S.size<0)if(S.size==-3)j+=4;else break e;else S.id>=o&&(j+=4);S.next()}P=q,D+=L,F+=j}return(x<0||D==v)&&(N.size=D,N.start=P,N.skip=F),N.size>4?N:void 0}function b(v,x,S){let{id:D,start:P,end:F,size:A}=a;if(a.next(),A>=0&&D<o){let N=S;if(A>4){let B=a.pos-(A-4);for(;a.pos>B;)S=b(v,x,S)}x[--S]=N,x[--S]=F-v,x[--S]=P-v,x[--S]=D}else A==-3?c=D:A==-4&&(u=D);return S}let _=[],k=[];for(;a.pos>0;)h(r.start||0,r.bufferStart||0,_,k,-1,0);let C=(e=r.length)!==null&&e!==void 0?e:_.length?k[0]+_[0].length:0;return new it(l[r.topID],_.reverse(),k.reverse(),C)}const W6=new WeakMap;function Al(r,e){if(!r.isAnonymous||e instanceof Rr||e.type!=r)return 1;let t=W6.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=r||!(n instanceof it)){t=1;break}t+=Al(r,n)}W6.set(e,t)}return t}function wd(r,e,t,n,i,s,o,a,l){let c=0;for(let p=n;p<i;p++)c+=Al(r,e[p]);let u=Math.ceil(c*1.5/8),h=[],d=[];function f(p,g,m,b,_){for(let k=m;k<b;){let C=k,v=g[k],x=Al(r,p[k]);for(k++;k<b;k++){let S=Al(r,p[k]);if(x+S>=u)break;x+=S}if(k==C+1){if(x>u){let S=p[C];f(S.children,S.positions,0,S.children.length,g[C]+_);continue}h.push(p[C])}else{let S=g[k-1]+p[k-1].length-v;h.push(wd(r,p,g,C,k,v,S,null,l))}d.push(v+_-s)}}return f(e,t,n,i,0),(a||l)(h,d,o)}class ci{constructor(e,t,n,i,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let i=[new ci(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&i.push(s);return i}static applyChanges(e,t,n=128){if(!t.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<t.length?t[a]:null,h=u?u.fromA:1e9;if(h-l>=n)for(;o&&o.from<h;){let d=o;if(l>=d.from||h<=d.to||c){let f=Math.max(d.from,l)-c,p=Math.min(d.to,h)-c;d=f>=p?null:new ci(f,p,d.tree,d.offset+c,a>0,!!u)}if(d&&i.push(d),o.to>h)break;o=s<e.length?e[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}class Q6{startParse(e,t,n){return typeof e=="string"&&(e=new YP(e)),n=n?n.length?n.map(i=>new md(i.from,i.to)):[new md(0,0)]:[new md(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let s=i.advance();if(s)return s}}}class YP{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new be({perNode:!0});let ZP=0,ur=class Rf{constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=ZP++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof Rf&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let i=new Rf(n,[],null,[]);if(i.set.push(i),t)for(let s of t.set)i.set.push(s);return i}static defineModifier(e){let t=new Rl(e);return n=>n.modified.indexOf(t)>-1?n:Rl.get(n.base||n,n.modified.concat(t).sort((i,s)=>i.id-s.id))}},XP=0;class Rl{constructor(e){this.name=e,this.instances=[],this.id=XP++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(a=>a.base==e&&KP(t,a.modified));if(n)return n;let i=[],s=new ur(e.name,i,e,t);for(let a of t)a.instances.push(s);let o=GP(t);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(Rl.get(a,l));return s}}function KP(r,e){return r.length==e.length&&r.every((t,n)=>t==e[n])}function GP(r){let e=[[]];for(let t=0;t<r.length;t++)for(let n=0,i=e.length;n<i;n++)e.push(e[n].concat(r[t]));return e.sort((t,n)=>n.length-t.length)}function po(r){let e=Object.create(null);for(let t in r){let n=r[t];Array.isArray(n)||(n=[n]);for(let i of t.split(" "))if(i){let s=[],o=2,a=i;for(let h=0;;){if(a=="..."&&h>0&&h+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+i);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),h+=d[0].length,h==i.length)break;let f=i[h++];if(h==i.length&&f=="!"){o=0;break}if(f!="/")throw new RangeError("Invalid path: "+i);a=i.slice(h)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new Ll(n,o,l>0?s.slice(0,l):null);e[c]=u.sort(e[c])}}return q6.add(e)}const q6=new be;class Ll{constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Ll.empty=new Ll([],2,null);function U6(r,e){let t=Object.create(null);for(let s of r)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:n,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:n}}function JP(r,e){let t=null;for(let n of r){let i=n.style(e);i&&(t=t?t+" "+i:i)}return t}function eT(r,e,t,n=0,i=r.length){let s=new tT(n,Array.isArray(e)?e:[e],t);s.highlightRange(r.cursor(),n,i,"",s.highlighters),s.flush(i)}class tT{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,i,s){let{type:o,from:a,to:l}=e;if(a>=n||l<=t)return;o.isTop&&(s=this.highlighters.filter(f=>!f.scope||f.scope(o)));let c=i,u=nT(e)||Ll.empty,h=JP(s,u.tags);if(h&&(c&&(c+=" "),c+=h,u.mode==1&&(i+=(i?" ":"")+h)),this.startSpan(Math.max(t,a),c),u.opaque)return;let d=e.tree&&e.tree.prop(be.mounted);if(d&&d.overlay){let f=e.node.enter(d.overlay[0].from+a,1),p=this.highlighters.filter(m=>!m.scope||m.scope(d.tree.type)),g=e.firstChild();for(let m=0,b=a;;m++){let _=m<d.overlay.length?d.overlay[m]:null,k=_?_.from+a:l,C=Math.max(t,b),v=Math.min(n,k);if(C<v&&g)for(;e.from<v&&(this.highlightRange(e,C,v,i,s),this.startSpan(Math.min(v,e.to),c),!(e.to>=k||!e.nextSibling())););if(!_||k>n)break;b=_.to+a,b>t&&(this.highlightRange(f.cursor(),Math.max(t,_.from+a),Math.min(n,b),"",p),this.startSpan(Math.min(n,b),c))}g&&e.parent()}else if(e.firstChild()){d&&(i="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,i,s),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}}function nT(r){let e=r.type.prop(q6);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}const Y=ur.define,Nl=Y(),Nr=Y(),z6=Y(Nr),$6=Y(Nr),Ir=Y(),Il=Y(Ir),kd=Y(Ir),Vn=Y(),ui=Y(Vn),jn=Y(),Wn=Y(),Sd=Y(),mo=Y(Sd),Bl=Y(),T={comment:Nl,lineComment:Y(Nl),blockComment:Y(Nl),docComment:Y(Nl),name:Nr,variableName:Y(Nr),typeName:z6,tagName:Y(z6),propertyName:$6,attributeName:Y($6),className:Y(Nr),labelName:Y(Nr),namespace:Y(Nr),macroName:Y(Nr),literal:Ir,string:Il,docString:Y(Il),character:Y(Il),attributeValue:Y(Il),number:kd,integer:Y(kd),float:Y(kd),bool:Y(Ir),regexp:Y(Ir),escape:Y(Ir),color:Y(Ir),url:Y(Ir),keyword:jn,self:Y(jn),null:Y(jn),atom:Y(jn),unit:Y(jn),modifier:Y(jn),operatorKeyword:Y(jn),controlKeyword:Y(jn),definitionKeyword:Y(jn),moduleKeyword:Y(jn),operator:Wn,derefOperator:Y(Wn),arithmeticOperator:Y(Wn),logicOperator:Y(Wn),bitwiseOperator:Y(Wn),compareOperator:Y(Wn),updateOperator:Y(Wn),definitionOperator:Y(Wn),typeOperator:Y(Wn),controlOperator:Y(Wn),punctuation:Sd,separator:Y(Sd),bracket:mo,angleBracket:Y(mo),squareBracket:Y(mo),paren:Y(mo),brace:Y(mo),content:Vn,heading:ui,heading1:Y(ui),heading2:Y(ui),heading3:Y(ui),heading4:Y(ui),heading5:Y(ui),heading6:Y(ui),contentSeparator:Y(Vn),list:Y(Vn),quote:Y(Vn),emphasis:Y(Vn),strong:Y(Vn),link:Y(Vn),monospace:Y(Vn),strikethrough:Y(Vn),inserted:Y(),deleted:Y(),changed:Y(),invalid:Y(),meta:Bl,documentMeta:Y(Bl),annotation:Y(Bl),processingInstruction:Y(Bl),definition:ur.defineModifier("definition"),constant:ur.defineModifier("constant"),function:ur.defineModifier("function"),standard:ur.defineModifier("standard"),local:ur.defineModifier("local"),special:ur.defineModifier("special")};for(let r in T){let e=T[r];e instanceof ur&&(e.name=r)}U6([{tag:T.link,class:"tok-link"},{tag:T.heading,class:"tok-heading"},{tag:T.emphasis,class:"tok-emphasis"},{tag:T.strong,class:"tok-strong"},{tag:T.keyword,class:"tok-keyword"},{tag:T.atom,class:"tok-atom"},{tag:T.bool,class:"tok-bool"},{tag:T.url,class:"tok-url"},{tag:T.labelName,class:"tok-labelName"},{tag:T.inserted,class:"tok-inserted"},{tag:T.deleted,class:"tok-deleted"},{tag:T.literal,class:"tok-literal"},{tag:T.string,class:"tok-string"},{tag:T.number,class:"tok-number"},{tag:[T.regexp,T.escape,T.special(T.string)],class:"tok-string2"},{tag:T.variableName,class:"tok-variableName"},{tag:T.local(T.variableName),class:"tok-variableName tok-local"},{tag:T.definition(T.variableName),class:"tok-variableName tok-definition"},{tag:T.special(T.variableName),class:"tok-variableName2"},{tag:T.definition(T.propertyName),class:"tok-propertyName tok-definition"},{tag:T.typeName,class:"tok-typeName"},{tag:T.namespace,class:"tok-namespace"},{tag:T.className,class:"tok-className"},{tag:T.macroName,class:"tok-macroName"},{tag:T.propertyName,class:"tok-propertyName"},{tag:T.operator,class:"tok-operator"},{tag:T.comment,class:"tok-comment"},{tag:T.meta,class:"tok-meta"},{tag:T.invalid,class:"tok-invalid"},{tag:T.punctuation,class:"tok-punctuation"}]);var _d;const Ki=new be;function rT(r){return J.define({combine:r?e=>e.concat(r):void 0})}const iT=new be;class gn{constructor(e,t,n=[],i=""){this.data=e,this.name=i,we.prototype.hasOwnProperty("tree")||Object.defineProperty(we.prototype,"tree",{get(){return dt(this)}}),this.parser=t,this.extension=[Br.of(this),we.languageData.of((s,o,a)=>{let l=Y6(s,o,a),c=l.type.prop(Ki);if(!c)return[];let u=s.facet(c),h=l.type.prop(iT);if(h){let d=l.resolve(o-l.from,a);for(let f of h)if(f.test(d,s)){let p=s.facet(f.facet);return f.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return Y6(e,t,n).type.prop(Ki)==this.data}findRegions(e){let t=e.facet(Br);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(s,o)=>{if(s.prop(Ki)==this.data){n.push({from:o,to:o+s.length});return}let a=s.prop(be.mounted);if(a){if(a.tree.prop(Ki)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+o,to:l.to+o});else n.push({from:o,to:o+s.length});return}else if(a.overlay){let l=n.length;if(i(a.tree,a.overlay[0].from+o),n.length>l)return}}for(let l=0;l<s.children.length;l++){let c=s.children[l];c instanceof it&&i(c,s.positions[l]+o)}};return i(dt(e),0),n}get allowsNesting(){return!0}}gn.setState=fe.define();function Y6(r,e,t){let n=r.facet(Br),i=dt(r).topNode;if(!n||n.allowsNesting)for(let s=i;s;s=s.enter(e,t,ht.ExcludeBuffers))s.type.isTop&&(i=s);return i}class hi extends gn{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=rT(e.languageData);return new hi(t,e.parser.configure({props:[Ki.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new hi(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function dt(r){let e=r.field(gn.state,!1);return e?e.tree:it.empty}class sT{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let go=null;class Hl{constructor(e,t,n=[],i,s,o,a,l){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Hl(e,t,[],it.empty,0,n,[],null)}startParse(){return this.parser.startParse(new sT(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=it.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(ci.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ci.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=go;go=this;try{return e()}finally{go=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Z6(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,h,d)=>l.push({fromA:c,toA:u,fromB:h,toB:d})),n=ci.applyChanges(n,l),i=it.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),h=e.mapPos(c.to,-1);u<h&&a.push({from:u,to:h})}}}return new Hl(this.parser,t,n,i,s,o,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:i,to:s}=this.skipped[n];i<e.to&&s>e.from&&(this.fragments=Z6(this.fragments,i,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Q6{createParse(t,n,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let l=go;if(l){for(let c of i)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new it(Vt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return go}}function Z6(r,e,t){return ci.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}class Gi{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Gi(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Hl.create(e.facet(Br).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Gi(n)}}gn.state=vt.define({create:Gi.init,update(r,e){for(let t of e.effects)if(t.is(gn.setState))return t.value;return e.startState.facet(Br)!=e.state.facet(Br)?Gi.init(e.state):r.apply(e)}});let X6=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(X6=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const xd=typeof navigator<"u"&&(!((_d=navigator.scheduling)===null||_d===void 0)&&_d.isInputPending)?()=>navigator.scheduling.isInputPending():null,oT=tt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(gn.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(gn.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=X6(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,s=n.field(gn.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!xd?Math.max(25,e.timeRemaining()-5):1e9),a=s.context.treeLen<i&&n.doc.length>i+1e3,l=s.context.work(()=>xd&&xd()||Date.now()>o,i+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:gn.setState.of(new Gi(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ft(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Br=J.define({combine(r){return r.length?r[0]:null},enables:r=>[gn.state,oT,X.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]});class Od{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const aT=J.define(),Fl=J.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function Vl(r){let e=r.facet(Fl);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function yo(r,e){let t="",n=r.tabSize,i=r.facet(Fl)[0];if(i==" "){for(;e>=n;)t+=" ",e-=n;i=" "}for(let s=0;s<e;s++)t+=i;return t}function Ed(r,e){r instanceof we&&(r=new jl(r));for(let n of r.state.facet(aT)){let i=n(r,e);if(i!==void 0)return i}let t=dt(r.state);return t.length>=e?lT(r,t,e):null}class jl{constructor(e,t={}){this.state=e,this.options=t,this.unit=Vl(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=n.from&&i<=n.to?s&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e,t=1){let{text:n,from:i}=this.lineAt(e,t),s=this.countColumn(n,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return Wi(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:i}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Wl=new be;function lT(r,e,t){let n=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=n.node){let s=[];for(let o=i;o&&!(o.from==n.node.from&&o.type==n.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return K6(n,r,t)}function K6(r,e,t){for(let n=r;n;n=n.next){let i=uT(n.node);if(i)return i(Dd.create(e,t,n))}return 0}function cT(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function uT(r){let e=r.type.prop(Wl);if(e)return e;let t=r.firstChild,n;if(t&&(n=t.type.prop(be.closedBy))){let i=r.lastChild,s=i&&n.indexOf(i.name)>-1;return o=>J6(o,!0,1,void 0,s&&!cT(o)?i.from:void 0)}return r.parent==null?hT:null}function hT(){return 0}class Dd extends jl{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new Dd(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(dT(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return K6(this.context.next,this.base,this.pos)}}function dT(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function fT(r){let e=r.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let i=r.options.simulateBreak,s=r.state.doc.lineAt(t.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function G6({closing:r,align:e=!0,units:t=1}){return n=>J6(n,e,t,r)}function J6(r,e,t,n,i){let s=r.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||i==r.pos+o,l=e?fT(r):null;return l?a?r.column(l.from):r.column(l.to):r.baseIndent+(a?0:r.unit*t)}function Md({except:r,units:e=1}={}){return t=>{let n=r&&r.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const pT=200;function mT(){return we.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let t=r.newDoc,{head:n}=r.newSelection.main,i=t.lineAt(n);if(n>i.from+pT)return r;let s=t.sliceString(i.from,n);if(!e.some(c=>c.test(s)))return r;let{state:o}=r,a=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==a)continue;a=u.from;let h=Ed(o,u.from);if(h==null)continue;let d=/^\s*/.exec(u.text)[0],f=yo(o,h);d!=f&&l.push({from:u.from,to:u.from+d.length,insert:f})}return l.length?[r,{changes:l,sequential:!0}]:r})}const gT=J.define(),Ql=new be;function e2(r){let e=r.firstChild,t=r.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?r.to:t.from}:null}function yT(r,e,t){let n=dt(r);if(n.length<t)return null;let i=n.resolveStack(t,1),s=null;for(let o=i;o;o=o.next){let a=o.node;if(a.to<=t||a.from>t)continue;if(s&&a.from<e)break;let l=a.type.prop(Ql);if(l&&(a.to<n.length-50||n.length==r.doc.length||!vT(a))){let c=l(a,r);c&&c.from<=t&&c.from>=e&&c.to>t&&(s=c)}}return s}function vT(r){let e=r.lastChild;return e&&e.to==r.to&&e.type.isError}function ql(r,e,t){for(let n of r.facet(gT)){let i=n(r,e,t);if(i)return i}return yT(r,e,t)}function t2(r,e){let t=e.mapPos(r.from,1),n=e.mapPos(r.to,-1);return t>=n?void 0:{from:t,to:n}}const Ul=fe.define({map:t2}),vo=fe.define({map:t2});function n2(r){let e=[];for(let{head:t}of r.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(r.lineBlockAt(t));return e}const di=vt.define({create(){return ie.none},update(r,e){r=r.map(e.changes);for(let t of e.effects)if(t.is(Ul)&&!bT(r,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(s2),i=n?ie.replace({widget:new _T(n(e.state,t.value))}):l2;r=r.update({add:[i.range(t.value.from,t.value.to)]})}else t.is(vo)&&(r=r.update({filter:(n,i)=>t.value.from!=n||t.value.to!=i,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:n}=e.selection.main;r.between(n,n,(i,s)=>{i<n&&s>n&&(t=!0)}),t&&(r=r.update({filterFrom:n,filterTo:n,filter:(i,s)=>s<=n||i>=n}))}return r},provide:r=>X.decorations.from(r),toJSON(r,e){let t=[];return r.between(0,e.doc.length,(n,i)=>{t.push(n,i)}),t},fromJSON(r){if(!Array.isArray(r)||r.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<r.length;){let n=r[t++],i=r[t++];if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(l2.range(n,i))}return ie.set(e,!0)}});function zl(r,e,t){var n;let i=null;return(n=r.field(di,!1))===null||n===void 0||n.between(e,t,(s,o)=>{(!i||i.from>s)&&(i={from:s,to:o})}),i}function bT(r,e,t){let n=!1;return r.between(e,e,(i,s)=>{i==e&&s==t&&(n=!0)}),n}function r2(r,e){return r.field(di,!1)?e:e.concat(fe.appendConfig.of(o2()))}const CT=r=>{for(let e of n2(r)){let t=ql(r.state,e.from,e.to);if(t)return r.dispatch({effects:r2(r.state,[Ul.of(t),i2(r,t)])}),!0}return!1},wT=r=>{if(!r.state.field(di,!1))return!1;let e=[];for(let t of n2(r)){let n=zl(r.state,t.from,t.to);n&&e.push(vo.of(n),i2(r,n,!1))}return e.length&&r.dispatch({effects:e}),e.length>0};function i2(r,e,t=!0){let n=r.state.doc.lineAt(e.from).number,i=r.state.doc.lineAt(e.to).number;return X.announce.of(`${r.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${r.state.phrase("to")} ${i}.`)}const kT=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:CT},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:wT},{key:"Ctrl-Alt-[",run:r=>{let{state:e}=r,t=[];for(let n=0;n<e.doc.length;){let i=r.lineBlockAt(n),s=ql(e,i.from,i.to);s&&t.push(Ul.of(s)),n=(s?r.lineBlockAt(s.to):i).to+1}return t.length&&r.dispatch({effects:r2(r.state,t)}),!!t.length}},{key:"Ctrl-Alt-]",run:r=>{let e=r.state.field(di,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,r.state.doc.length,(n,i)=>{t.push(vo.of({from:n,to:i}))}),r.dispatch({effects:t}),!0}}],ST={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},s2=J.define({combine(r){return In(r,ST)}});function o2(r){return[di,ET]}function a2(r,e){let{state:t}=r,n=t.facet(s2),i=o=>{let a=r.lineBlockAt(r.posAtDOM(o.target)),l=zl(r.state,a.from,a.to);l&&r.dispatch({effects:vo.of(l)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(r,i,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const l2=ie.replace({widget:new class extends or{toDOM(r){return a2(r,null)}}});class _T extends or{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return a2(e,this.value)}}const xT={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Pd extends cr{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function OT(r={}){let e=Object.assign(Object.assign({},xT),r),t=new Pd(e,!0),n=new Pd(e,!1),i=tt.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Br)!=o.state.facet(Br)||o.startState.field(di,!1)!=o.state.field(di,!1)||dt(o.startState)!=dt(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new ir;for(let l of o.viewportLineBlocks){let c=zl(o.state,l.from,l.to)?n:ql(o.state,l.from,l.to)?t:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:s}=e;return[i,TP({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(i))===null||a===void 0?void 0:a.markers)||Oe.empty},initialSpacer(){return new Pd(e,!1)},domEventHandlers:Object.assign(Object.assign({},s),{click:(o,a,l)=>{if(s.click&&s.click(o,a,l))return!0;let c=zl(o.state,a.from,a.to);if(c)return o.dispatch({effects:vo.of(c)}),!0;let u=ql(o.state,a.from,a.to);return u?(o.dispatch({effects:Ul.of(u)}),!0):!1}})}),o2()]}const ET=X.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class bo{constructor(e,t){this.specs=e;let n;function i(a){let l=Er.newName();return(n||(n=Object.create(null)))["."+l]=a,l}const s=typeof t.all=="string"?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof gn?a=>a.prop(Ki)==o.data:o?a=>a==o:void 0,this.style=U6(e.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=n?new Er(n):null,this.themeType=t.themeType}static define(e,t){return new bo(e,t||{})}}const Td=J.define(),c2=J.define({combine(r){return r.length?[r[0]]:null}});function Ad(r){let e=r.facet(Td);return e.length?e:r.facet(c2)}function u2(r,e){let t=[MT],n;return r instanceof bo&&(r.module&&t.push(X.styleModule.of(r.module)),n=r.themeType),e!=null&&e.fallback?t.push(c2.of(r)):n?t.push(Td.computeN([X.darkTheme],i=>i.facet(X.darkTheme)==(n=="dark")?[r]:[])):t.push(Td.of(r)),t}class DT{constructor(e){this.markCache=Object.create(null),this.tree=dt(e.state),this.decorations=this.buildDeco(e,Ad(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=dt(e.state),n=Ad(e.state),i=n!=Ad(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!i&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return ie.none;let n=new ir;for(let{from:i,to:s}of e.visibleRanges)eT(this.tree,t,(o,a,l)=>{n.add(o,a,this.markCache[l]||(this.markCache[l]=ie.mark({class:l})))},i,s);return n.finish()}}const MT=ii.high(tt.fromClass(DT,{decorations:r=>r.decorations})),PT=bo.define([{tag:T.meta,color:"#404740"},{tag:T.link,textDecoration:"underline"},{tag:T.heading,textDecoration:"underline",fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strong,fontWeight:"bold"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.keyword,color:"#708"},{tag:[T.atom,T.bool,T.url,T.contentSeparator,T.labelName],color:"#219"},{tag:[T.literal,T.inserted],color:"#164"},{tag:[T.string,T.deleted],color:"#a11"},{tag:[T.regexp,T.escape,T.special(T.string)],color:"#e40"},{tag:T.definition(T.variableName),color:"#00f"},{tag:T.local(T.variableName),color:"#30a"},{tag:[T.typeName,T.namespace],color:"#085"},{tag:T.className,color:"#167"},{tag:[T.special(T.variableName),T.macroName],color:"#256"},{tag:T.definition(T.propertyName),color:"#00c"},{tag:T.comment,color:"#940"},{tag:T.invalid,color:"#f00"}]),TT=X.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),h2=1e4,d2="()[]{}",f2=J.define({combine(r){return In(r,{afterCursor:!0,brackets:d2,maxScanDistance:h2,renderMatch:LT})}}),AT=ie.mark({class:"cm-matchingBracket"}),RT=ie.mark({class:"cm-nonmatchingBracket"});function LT(r){let e=[],t=r.matched?AT:RT;return e.push(t.range(r.start.from,r.start.to)),r.end&&e.push(t.range(r.end.from,r.end.to)),e}const NT=[vt.define({create(){return ie.none},update(r,e){if(!e.docChanged&&!e.selection)return r;let t=[],n=e.state.facet(f2);for(let i of e.state.selection.ranges){if(!i.empty)continue;let s=Qn(e.state,i.head,-1,n)||i.head>0&&Qn(e.state,i.head-1,1,n)||n.afterCursor&&(Qn(e.state,i.head,1,n)||i.head<e.state.doc.length&&Qn(e.state,i.head+1,-1,n));s&&(t=t.concat(n.renderMatch(s,e.state)))}return ie.set(t,!0)},provide:r=>X.decorations.from(r)}),TT];function IT(r={}){return[f2.of(r),NT]}const BT=new be;function Rd(r,e,t){let n=r.prop(e<0?be.openedBy:be.closedBy);if(n)return n;if(r.name.length==1){let i=t.indexOf(r.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function Ld(r){let e=r.type.prop(BT);return e?e(r.node):r}function Qn(r,e,t,n={}){let i=n.maxScanDistance||h2,s=n.brackets||d2,o=dt(r),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Rd(l.type,t,s);if(c&&l.from<l.to){let u=Ld(l);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return HT(r,e,t,l,u,c,s)}}return FT(r,e,t,o,a.type,i,s)}function HT(r,e,t,n,i,s,o){let a=n.parent,l={from:i.from,to:i.to},c=0,u=a==null?void 0:a.cursor();if(u&&(t<0?u.childBefore(n.from):u.childAfter(n.to)))do if(t<0?u.to<=n.from:u.from>=n.to){if(c==0&&s.indexOf(u.type.name)>-1&&u.from<u.to){let h=Ld(u);return{start:l,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(Rd(u.type,t,o))c++;else if(Rd(u.type,-t,o)){if(c==0){let h=Ld(u);return{start:l,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function FT(r,e,t,n,i,s,o){let a=t<0?r.sliceDoc(e-1,e):r.sliceDoc(e,e+1),l=o.indexOf(a);if(l<0||l%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=r.doc.iterRange(e,t>0?r.doc.length:0),h=0;for(let d=0;!u.next().done&&d<=s;){let f=u.value;t<0&&(d+=f.length);let p=e+d*t;for(let g=t>0?0:f.length-1,m=t>0?f.length:-1;g!=m;g+=t){let b=o.indexOf(f[g]);if(!(b<0||n.resolveInner(p+g,1).type!=i))if(b%2==0==t>0)h++;else{if(h==1)return{start:c,end:{from:p+g,to:p+g+1},matched:b>>1==l>>1};h--}}t>0&&(d+=f.length)}return u.done?{start:c,matched:!1}:null}const VT=Object.create(null),p2=[Vt.none],m2=[],g2=Object.create(null),jT=Object.create(null);for(let[r,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])jT[r]=WT(VT,e);function Nd(r,e){m2.indexOf(r)>-1||(m2.push(r),console.warn(e))}function WT(r,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=r[c]||T[c];u?typeof u=="function"?l.length?l=l.map(u):Nd(c,`Modifier ${c} used at start of tag`):l.length?Nd(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Nd(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),i=n+" "+t.map(a=>a.id),s=g2[i];if(s)return s.id;let o=g2[i]=Vt.define({id:p2.length,name:n,props:[po({[n]:t})]});return p2.push(o),o.id}Qe.RTL,Qe.LTR;const QT=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),n=Bd(r.state,t.from);return n.line?qT(r):n.block?zT(r):!1};function Id(r,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let i=r(e,t);return i?(n(t.update(i)),!0):!1}}const qT=Id(ZT,0),UT=Id(y2,0),zT=Id((r,e)=>y2(r,e,YT(e)),0);function Bd(r,e){let t=r.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Co=50;function $T(r,{open:e,close:t},n,i){let s=r.sliceDoc(n-Co,n),o=r.sliceDoc(i,i+Co),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,c=s.length-a;if(s.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:n-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let u,h;i-n<=2*Co?u=h=r.sliceDoc(n,i):(u=r.sliceDoc(n,n+Co),h=r.sliceDoc(i-Co,i));let d=/^\s*/.exec(u)[0].length,f=/\s*$/.exec(h)[0].length,p=h.length-f-t.length;return u.slice(d,d+e.length)==e&&h.slice(p,p+t.length)==t?{open:{pos:n+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:i-f-t.length,margin:/\s/.test(h.charAt(p-1))?1:0}}:null}function YT(r){let e=[];for(let t of r.selection.ranges){let n=r.doc.lineAt(t.from),i=t.to<=n.to?n:r.doc.lineAt(t.to);i.from>n.from&&i.from==t.to&&(i=t.to==n.to+1?n:r.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=i.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:i.to})}return e}function y2(r,e,t=e.selection.ranges){let n=t.map(s=>Bd(e,s.from).block);if(!n.every(s=>s))return null;let i=t.map((s,o)=>$T(e,n[o],s.from,s.to));if(r!=2&&!i.every(s=>s))return{changes:e.changes(t.map((s,o)=>i[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(r!=1&&i.some(s=>s)){let s=[];for(let o=0,a;o<i.length;o++)if(a=i[o]){let l=n[o],{open:c,close:u}=a;s.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:s}}return null}function ZT(r,e,t=e.selection.ranges){let n=[],i=-1;for(let{from:s,to:o}of t){let a=n.length,l=1e9,c=Bd(e,s).line;if(c){for(let u=s;u<=o;){let h=e.doc.lineAt(u);if(h.from>i&&(s==o||o>h.from)){i=h.from;let d=/^\s*/.exec(h.text)[0].length,f=d==h.length,p=h.text.slice(d,d+c.length)==c?d:-1;d<h.text.length&&d<l&&(l=d),n.push({line:h,comment:p,token:c,indent:d,empty:f,single:!1})}u=h.to+1}if(l<1e9)for(let u=a;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=l);n.length==a+1&&(n[a].single=!0)}}if(r!=2&&n.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:u,single:h}of n)(h||!u)&&s.push({from:a.from+c,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(r!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of n)if(a>=0){let c=o.from+a,u=c+l.length;o.text[u-o.from]==" "&&u++,s.push({from:c,to:u})}return{changes:s}}return null}const Hd=Nn.define(),XT=Nn.define(),KT=J.define(),v2=J.define({combine(r){return In(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,i)=>e(n,i)||t(n,i)})}}),b2=vt.define({create(){return qn.empty},update(r,e){let t=e.state.facet(v2),n=e.annotation(Hd);if(n){let l=jt.fromTransaction(e,n.selection),c=n.side,u=c==0?r.undone:r.done;return l?u=Yl(u,u.length,t.minDepth,l):u=k2(u,e.startState.selection),new qn(c==0?n.rest:u,c==0?u:n.rest)}let i=e.annotation(XT);if((i=="full"||i=="before")&&(r=r.isolate()),e.annotation(lt.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let s=jt.fromTransaction(e),o=e.annotation(lt.time),a=e.annotation(lt.userEvent);return s?r=r.addChanges(s,o,a,t,e):e.selection&&(r=r.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(i=="full"||i=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new qn(r.done.map(jt.fromJSON),r.undone.map(jt.fromJSON))}});function GT(r={}){return[b2,v2.of(r),X.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?C2:e.inputType=="historyRedo"?Fd:null;return n?(e.preventDefault(),n(t)):!1}})]}function $l(r,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let i=t.field(b2,!1);if(!i)return!1;let s=i.pop(r,t,e);return s?(n(s),!0):!1}}const C2=$l(0,!1),Fd=$l(1,!1),JT=$l(0,!0),eA=$l(1,!0);class jt{constructor(e,t,n,i,s){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new jt(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new jt(e.changes&&at.fromJSON(e.changes),[],e.mapped&&Ln.fromJSON(e.mapped),e.startSelection&&Q.fromJSON(e.startSelection),e.selectionsAfter.map(Q.fromJSON))}static fromTransaction(e,t){let n=on;for(let i of e.startState.facet(KT)){let s=i(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new jt(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,on)}static selection(e){return new jt(void 0,on,void 0,void 0,e)}}function Yl(r,e,t,n){let i=e+1>t+20?e-t-1:0,s=r.slice(i,e);return s.push(n),s}function tA(r,e){let t=[],n=!1;return r.iterChangedRanges((i,s)=>t.push(i,s)),e.iterChangedRanges((i,s,o,a)=>{for(let l=0;l<t.length;){let c=t[l++],u=t[l++];a>=c&&o<=u&&(n=!0)}}),n}function nA(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function w2(r,e){return r.length?e.length?r.concat(e):r:e}const on=[],rA=200;function k2(r,e){if(r.length){let t=r[r.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-rA));return n.length&&n[n.length-1].eq(e)?r:(n.push(e),Yl(r,r.length-1,1e9,t.setSelAfter(n)))}else return[jt.selection([e])]}function iA(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Vd(r,e){if(!r.length)return r;let t=r.length,n=on;for(;t;){let i=sA(r[t-1],e,n);if(i.changes&&!i.changes.empty||i.effects.length){let s=r.slice(0,t);return s[t-1]=i,s}else e=i.mapped,t--,n=i.selectionsAfter}return n.length?[jt.selection(n)]:on}function sA(r,e,t){let n=w2(r.selectionsAfter.length?r.selectionsAfter.map(a=>a.map(e)):on,t);if(!r.changes)return jt.selection(n);let i=r.changes.map(e),s=e.mapDesc(r.changes,!0),o=r.mapped?r.mapped.composeDesc(s):s;return new jt(i,fe.mapEffects(r.effects,e),o,r.startSelection.map(s),n)}const oA=/^(input\.type|delete)($|\.)/;class qn{constructor(e,t,n=0,i=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new qn(this.done,this.undone):this}addChanges(e,t,n,i,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||oA.test(n))&&(!a.selectionsAfter.length&&t-this.prevTime<i.newGroupDelay&&i.joinToEvent(s,tA(a.changes,e.changes))||n=="input.type.compose")?o=Yl(o,o.length-1,i.minDepth,new jt(e.changes.compose(a.changes),w2(fe.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,on)):o=Yl(o,o.length,i.minDepth,e),new qn(o,on,t,n)}addSelection(e,t,n,i){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:on;return s.length>0&&t-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&nA(s[s.length-1],e)?this:new qn(k2(this.done,e),this.undone,t,n)}addMapping(e){return new qn(Vd(this.done,e),Vd(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let i=e==0?this.done:this.undone;if(i.length==0)return null;let s=i[i.length-1],o=s.selectionsAfter[0]||t.selection;if(n&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Hd.of({side:e,rest:iA(i),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let a=i.length==1?on:i.slice(0,i.length-1);return s.mapped&&(a=Vd(a,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Hd.of({side:e,rest:a,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}qn.empty=new qn(on,on);const aA=[{key:"Mod-z",run:C2,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Fd,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Fd,preventDefault:!0},{key:"Mod-u",run:JT,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:eA,preventDefault:!0}];function Ji(r,e){return Q.create(r.ranges.map(e),r.mainIndex)}function Un(r,e){return r.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function yn({state:r,dispatch:e},t){let n=Ji(r.selection,t);return n.eq(r.selection,!0)?!1:(e(Un(r,n)),!0)}function Zl(r,e){return Q.cursor(e?r.to:r.from)}function S2(r,e){return yn(r,t=>t.empty?r.moveByChar(t,e):Zl(t,e))}function Et(r){return r.textDirectionAt(r.state.selection.main.head)==Qe.LTR}const _2=r=>S2(r,!Et(r)),x2=r=>S2(r,Et(r));function O2(r,e){return yn(r,t=>t.empty?r.moveByGroup(t,e):Zl(t,e))}const lA=r=>O2(r,!Et(r)),cA=r=>O2(r,Et(r));function uA(r,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function Xl(r,e,t){let n=dt(r).resolveInner(e.head),i=t?be.closedBy:be.openedBy;for(let l=e.head;;){let c=t?n.childAfter(l):n.childBefore(l);if(!c)break;uA(r,c,i)?n=c:l=t?c.to:c.from}let s=n.type.prop(i),o,a;return s&&(o=t?Qn(r,n.from,1):Qn(r,n.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?n.to:n.from,Q.cursor(a,t?-1:1)}const hA=r=>yn(r,e=>Xl(r.state,e,!Et(r))),dA=r=>yn(r,e=>Xl(r.state,e,Et(r)));function E2(r,e){return yn(r,t=>{if(!t.empty)return Zl(t,e);let n=r.moveVertically(t,e);return n.head!=t.head?n:r.moveToLineBoundary(t,e)})}const D2=r=>E2(r,!1),M2=r=>E2(r,!0);function P2(r){let e=r.scrollDOM.clientHeight<r.scrollDOM.scrollHeight-2,t=0,n=0,i;if(e){for(let s of r.state.facet(X.scrollMargins)){let o=s(r);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(n=Math.max(o==null?void 0:o.bottom,n))}i=r.scrollDOM.clientHeight-t-n}else i=(r.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(r.defaultLineHeight,i-5)}}function T2(r,e){let t=P2(r),{state:n}=r,i=Ji(n.selection,o=>o.empty?r.moveVertically(o,e,t.height):Zl(o,e));if(i.eq(n.selection))return!1;let s;if(t.selfScroll){let o=r.coordsAtPos(n.selection.main.head),a=r.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottom<c&&(s=X.scrollIntoView(i.main.head,{y:"start",yMargin:o.top-l}))}return r.dispatch(Un(n,i),{effects:s}),!0}const A2=r=>T2(r,!1),jd=r=>T2(r,!0);function Hr(r,e,t){let n=r.lineBlockAt(e.head),i=r.moveToLineBoundary(e,t);if(i.head==e.head&&i.head!=(t?n.to:n.from)&&(i=r.moveToLineBoundary(e,t,!1)),!t&&i.head==n.from&&n.length){let s=/^\s*/.exec(r.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&e.head!=n.from+s&&(i=Q.cursor(n.from+s))}return i}const fA=r=>yn(r,e=>Hr(r,e,!0)),pA=r=>yn(r,e=>Hr(r,e,!1)),mA=r=>yn(r,e=>Hr(r,e,!Et(r))),gA=r=>yn(r,e=>Hr(r,e,Et(r))),yA=r=>yn(r,e=>Q.cursor(r.lineBlockAt(e.head).from,1)),vA=r=>yn(r,e=>Q.cursor(r.lineBlockAt(e.head).to,-1));function bA(r,e,t){let n=!1,i=Ji(r.selection,s=>{let o=Qn(r,s.head,-1)||Qn(r,s.head,1)||s.head>0&&Qn(r,s.head-1,1)||s.head<r.doc.length&&Qn(r,s.head+1,-1);if(!o||!o.end)return s;n=!0;let a=o.start.from==s.head?o.end.to:o.end.from;return Q.cursor(a)});return n?(e(Un(r,i)),!0):!1}const CA=({state:r,dispatch:e})=>bA(r,e);function an(r,e){let t=Ji(r.state.selection,n=>{let i=e(n);return Q.range(n.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return t.eq(r.state.selection)?!1:(r.dispatch(Un(r.state,t)),!0)}function R2(r,e){return an(r,t=>r.moveByChar(t,e))}const L2=r=>R2(r,!Et(r)),N2=r=>R2(r,Et(r));function I2(r,e){return an(r,t=>r.moveByGroup(t,e))}const wA=r=>I2(r,!Et(r)),kA=r=>I2(r,Et(r)),SA=r=>an(r,e=>Xl(r.state,e,!Et(r))),_A=r=>an(r,e=>Xl(r.state,e,Et(r)));function B2(r,e){return an(r,t=>r.moveVertically(t,e))}const H2=r=>B2(r,!1),F2=r=>B2(r,!0);function V2(r,e){return an(r,t=>r.moveVertically(t,e,P2(r).height))}const j2=r=>V2(r,!1),W2=r=>V2(r,!0),xA=r=>an(r,e=>Hr(r,e,!0)),OA=r=>an(r,e=>Hr(r,e,!1)),EA=r=>an(r,e=>Hr(r,e,!Et(r))),DA=r=>an(r,e=>Hr(r,e,Et(r))),MA=r=>an(r,e=>Q.cursor(r.lineBlockAt(e.head).from)),PA=r=>an(r,e=>Q.cursor(r.lineBlockAt(e.head).to)),Q2=({state:r,dispatch:e})=>(e(Un(r,{anchor:0})),!0),q2=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.doc.length})),!0),U2=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.selection.main.anchor,head:0})),!0),z2=({state:r,dispatch:e})=>(e(Un(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),TA=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),AA=({state:r,dispatch:e})=>{let t=Gl(r).map(({from:n,to:i})=>Q.range(n,Math.min(i+1,r.doc.length)));return e(r.update({selection:Q.create(t),userEvent:"select"})),!0},RA=({state:r,dispatch:e})=>{let t=Ji(r.selection,n=>{let i=dt(r),s=i.resolveStack(n.from,1);if(n.empty){let o=i.resolveStack(n.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:a}=o;if((a.from<n.from&&a.to>=n.to||a.to>n.to&&a.from<=n.from)&&o.next)return Q.range(a.to,a.from)}return n});return t.eq(r.selection)?!1:(e(Un(r,t)),!0)},LA=({state:r,dispatch:e})=>{let t=r.selection,n=null;return t.ranges.length>1?n=Q.create([t.main]):t.main.empty||(n=Q.create([Q.cursor(t.main.head)])),n?(e(Un(r,n)),!0):!1};function wo(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:n}=r,i=n.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);l<o?(t="delete.backward",l=Kl(r,l,!1)):l>o&&(t="delete.forward",l=Kl(r,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Kl(r,o,!1),a=Kl(r,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:Q.cursor(o,o<s.head?-1:1)}});return i.changes.empty?!1:(r.dispatch(n.update(i,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?X.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Kl(r,e,t){if(r instanceof X)for(let n of r.state.facet(X.atomicRanges).map(i=>i(r)))n.between(e,e,(i,s)=>{i<e&&s>e&&(e=t?s:i)});return e}const $2=(r,e,t)=>wo(r,n=>{let i=n.from,{state:s}=r,o=s.doc.lineAt(i),a,l;if(t&&!e&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(a=o.text.slice(0,i-o.from))){if(a[a.length-1]==" ")return i-1;let c=Wi(a,s.tabSize),u=c%Vl(s)||Vl(s);for(let h=0;h<u&&a[a.length-1-h]==" ";h++)i--;l=i}else l=yt(o.text,i-o.from,e,e)+o.from,l==i&&o.number!=(e?s.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(l-o.from,i-o.from))&&(l=yt(o.text,l-o.from,!1,!1)+o.from);return l}),Wd=r=>$2(r,!1,!0),Y2=r=>$2(r,!0,!1),Z2=(r,e)=>wo(r,t=>{let n=t.head,{state:i}=r,s=i.doc.lineAt(n),o=i.charCategorizer(n);for(let a=null;;){if(n==(e?s.to:s.from)){n==t.head&&s.number!=(e?i.doc.lines:1)&&(n+=e?1:-1);break}let l=yt(s.text,n-s.from,e)+s.from,c=s.text.slice(Math.min(n,l)-s.from,Math.max(n,l)-s.from),u=o(c);if(a!=null&&u!=a)break;(c!=" "||n!=t.head)&&(a=u),n=l}return n}),X2=r=>Z2(r,!1),NA=r=>Z2(r,!0),IA=r=>wo(r,e=>{let t=r.lineBlockAt(e.head).to;return e.head<t?t:Math.min(r.state.doc.length,e.head+1)}),BA=r=>wo(r,e=>{let t=r.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),HA=r=>wo(r,e=>{let t=r.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(r.state.doc.length,e.head+1)}),FA=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:xe.of(["",""])},range:Q.cursor(n.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},VA=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(n=>{if(!n.empty||n.from==0||n.from==r.doc.length)return{range:n};let i=n.from,s=r.doc.lineAt(i),o=i==s.from?i-1:yt(s.text,i-s.from,!1)+s.from,a=i==s.to?i+1:yt(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:r.doc.slice(i,a).append(r.doc.slice(o,i))},range:Q.cursor(a)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gl(r){let e=[],t=-1;for(let n of r.selection.ranges){let i=r.doc.lineAt(n.from),s=r.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=r.doc.lineAt(n.to-1)),t>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(n)}else e.push({from:i.from,to:s.to,ranges:[n]});t=s.number+1}return e}function K2(r,e,t){if(r.readOnly)return!1;let n=[],i=[];for(let s of Gl(r)){if(t?s.to==r.doc.length:s.from==0)continue;let o=r.doc.lineAt(t?s.to+1:s.from-1),a=o.length+1;if(t){n.push({from:s.to,to:o.to},{from:s.from,insert:o.text+r.lineBreak});for(let l of s.ranges)i.push(Q.range(Math.min(r.doc.length,l.anchor+a),Math.min(r.doc.length,l.head+a)))}else{n.push({from:o.from,to:s.from},{from:s.to,insert:r.lineBreak+o.text});for(let l of s.ranges)i.push(Q.range(l.anchor-a,l.head-a))}}return n.length?(e(r.update({changes:n,scrollIntoView:!0,selection:Q.create(i,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}const jA=({state:r,dispatch:e})=>K2(r,e,!1),WA=({state:r,dispatch:e})=>K2(r,e,!0);function G2(r,e,t){if(r.readOnly)return!1;let n=[];for(let i of Gl(r))t?n.push({from:i.from,insert:r.doc.slice(i.from,i.to)+r.lineBreak}):n.push({from:i.to,insert:r.lineBreak+r.doc.slice(i.from,i.to)});return e(r.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const QA=({state:r,dispatch:e})=>G2(r,e,!1),qA=({state:r,dispatch:e})=>G2(r,e,!0),UA=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(Gl(e).map(({from:i,to:s})=>(i>0?i--:s<e.doc.length&&s++,{from:i,to:s}))),n=Ji(e.selection,i=>{let s;if(r.lineWrapping){let o=r.lineBlockAt(i.head),a=r.coordsAtPos(i.head,i.assoc||1);a&&(s=o.bottom+r.documentTop-a.bottom+r.defaultLineHeight/2)}return r.moveVertically(i,!0,s)}).map(t);return r.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function zA(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=dt(r).resolveInner(e),n=t.childBefore(e),i=t.childAfter(e),s;return n&&i&&n.to<=e&&i.from>=e&&(s=n.type.prop(be.closedBy))&&s.indexOf(i.name)>-1&&r.doc.lineAt(n.to).from==r.doc.lineAt(i.from).from&&!/\S/.test(r.sliceDoc(n.to,i.from))?{from:n.to,to:i.from}:null}const J2=e5(!1),$A=e5(!0);function e5(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:s,to:o}=i,a=e.doc.lineAt(s),l=!r&&s==o&&zA(e,s);r&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new jl(e,{simulateBreak:s,simulateDoubleBreak:!!l}),u=Ed(c,s);for(u==null&&(u=Wi(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<a.to&&/\s/.test(a.text[o-a.from]);)o++;l?{from:s,to:o}=l:s>a.from&&s<a.from+100&&!/\S/.test(a.text.slice(0,s))&&(s=a.from);let h=["",yo(e,u)];return l&&h.push(yo(e,c.lineIndent(a.from,-1))),{changes:{from:s,to:o,insert:xe.of(h)},range:Q.cursor(s+1+h[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Qd(r,e){let t=-1;return r.changeByRange(n=>{let i=[];for(let o=n.from;o<=n.to;){let a=r.doc.lineAt(o);a.number>t&&(n.empty||n.to>a.from)&&(e(a,i,n),t=a.number),o=a.to+1}let s=r.changes(i);return{changes:i,range:Q.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}const YA=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),n=new jl(r,{overrideIndentation:s=>{let o=t[s];return o??-1}}),i=Qd(r,(s,o,a)=>{let l=Ed(n,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=yo(r,l);(c!=u||a.from<s.from+c.length)&&(t[s.from]=l,o.push({from:s.from,to:s.from+c.length,insert:u}))});return i.changes.empty||e(r.update(i,{userEvent:"indent"})),!0},t5=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(Qd(r,(t,n)=>{n.push({from:t.from,insert:r.facet(Fl)})}),{userEvent:"input.indent"})),!0),n5=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(Qd(r,(t,n)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let s=Wi(i,r.tabSize),o=0,a=yo(r,Math.max(0,s-Vl(r)));for(;o<i.length&&o<a.length&&i.charCodeAt(o)==a.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+i.length,insert:a.slice(o)})}),{userEvent:"delete.dedent"})),!0),ZA=r=>(r.setTabFocusMode(),!0),XA=[{key:"Ctrl-b",run:_2,shift:L2,preventDefault:!0},{key:"Ctrl-f",run:x2,shift:N2},{key:"Ctrl-p",run:D2,shift:H2},{key:"Ctrl-n",run:M2,shift:F2},{key:"Ctrl-a",run:yA,shift:MA},{key:"Ctrl-e",run:vA,shift:PA},{key:"Ctrl-d",run:Y2},{key:"Ctrl-h",run:Wd},{key:"Ctrl-k",run:IA},{key:"Ctrl-Alt-h",run:X2},{key:"Ctrl-o",run:FA},{key:"Ctrl-t",run:VA},{key:"Ctrl-v",run:jd}],KA=[{key:"ArrowLeft",run:_2,shift:L2,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:lA,shift:wA,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:mA,shift:EA,preventDefault:!0},{key:"ArrowRight",run:x2,shift:N2,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:cA,shift:kA,preventDefault:!0},{mac:"Cmd-ArrowRight",run:gA,shift:DA,preventDefault:!0},{key:"ArrowUp",run:D2,shift:H2,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Q2,shift:U2},{mac:"Ctrl-ArrowUp",run:A2,shift:j2},{key:"ArrowDown",run:M2,shift:F2,preventDefault:!0},{mac:"Cmd-ArrowDown",run:q2,shift:z2},{mac:"Ctrl-ArrowDown",run:jd,shift:W2},{key:"PageUp",run:A2,shift:j2},{key:"PageDown",run:jd,shift:W2},{key:"Home",run:pA,shift:OA,preventDefault:!0},{key:"Mod-Home",run:Q2,shift:U2},{key:"End",run:fA,shift:xA,preventDefault:!0},{key:"Mod-End",run:q2,shift:z2},{key:"Enter",run:J2,shift:J2},{key:"Mod-a",run:TA},{key:"Backspace",run:Wd,shift:Wd},{key:"Delete",run:Y2},{key:"Mod-Backspace",mac:"Alt-Backspace",run:X2},{key:"Mod-Delete",mac:"Alt-Delete",run:NA},{mac:"Mod-Backspace",run:BA},{mac:"Mod-Delete",run:HA}].concat(XA.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),GA=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:hA,shift:SA},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:dA,shift:_A},{key:"Alt-ArrowUp",run:jA},{key:"Shift-Alt-ArrowUp",run:QA},{key:"Alt-ArrowDown",run:WA},{key:"Shift-Alt-ArrowDown",run:qA},{key:"Escape",run:LA},{key:"Mod-Enter",run:$A},{key:"Alt-l",mac:"Ctrl-l",run:AA},{key:"Mod-i",run:RA,preventDefault:!0},{key:"Mod-[",run:n5},{key:"Mod-]",run:t5},{key:"Mod-Alt-\\",run:YA},{key:"Shift-Mod-k",run:UA},{key:"Shift-Mod-\\",run:CA},{key:"Mod-/",run:QT},{key:"Alt-A",run:UT},{key:"Ctrl-m",mac:"Shift-Alt-m",run:ZA}].concat(KA),JA={key:"Tab",run:t5,shift:n5};function je(){var r=arguments[0];typeof r=="string"&&(r=document.createElement(r));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var i=t[n];typeof i=="string"?r.setAttribute(n,i):i!=null&&(r[n]=i)}e++}for(;e<arguments.length;e++)r5(r,arguments[e]);return r}function r5(r,e){if(typeof e=="string")r.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)r.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)r5(r,e[t]);else throw new RangeError("Unsupported child node: "+e)}const i5=typeof String.prototype.normalize=="function"?r=>r.normalize("NFKD"):r=>r;class es{constructor(e,t,n=0,i=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=s?a=>s(i5(a)):i5,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Bt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=oh(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Rn(e);let i=this.normalize(t);if(i.length)for(let s=0,o=n;;s++){let a=i.charCodeAt(s),l=this.match(a,o,this.bufferPos+this.bufferStart);if(s==i.length-1){if(l)return this.value=l,this;break}o==n&&s<t.length&&t.charCodeAt(s)==a&&o++}}}match(e,t,n){let i=null;for(let s=0;s<this.matches.length;s+=2){let o=this.matches[s],a=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?i={from:this.matches[s+1],to:n}:(this.matches[s]++,a=!0)),a||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?i={from:t,to:n}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(es.prototype[Symbol.iterator]=function(){return this});const s5={from:-1,to:-1,match:/.*/.exec("")},qd="gm"+(/x/.unicode==null?"":"u");class o5{constructor(e,t,n,i=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=s5,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new a5(e,t,n,i,s);this.re=new RegExp(t,qd+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let o=e.lineAt(i);this.curLineStart=o.from,this.matchPos=Jl(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,i=n+t[0].length;if(this.matchPos=Jl(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Ud=new WeakMap;class ts{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let i=Ud.get(e);if(!i||i.from>=n||i.to<=t){let a=new ts(t,e.sliceString(t,n));return Ud.set(e,a),a}if(i.from==t&&i.to==n)return i;let{text:s,from:o}=i;return o>t&&(s=e.sliceString(t,o)+s,o=t),i.to<n&&(s+=e.sliceString(i.to,n)),Ud.set(e,new ts(o,s)),new ts(t,s.slice(t-o,n-o))}}class a5{constructor(e,t,n,i,s){this.text=e,this.to=s,this.done=!1,this.value=s5,this.matchPos=Jl(e,i),this.re=new RegExp(t,qd+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=ts.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,i=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,match:t},this.matchPos=Jl(this.text,i+(n==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ts.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(o5.prototype[Symbol.iterator]=a5.prototype[Symbol.iterator]=function(){return this});function eR(r){try{return new RegExp(r,qd),!0}catch{return!1}}function Jl(r,e){if(e>=r.length)return e;let t=r.lineAt(e),n;for(;e<t.to&&(n=t.text.charCodeAt(e-t.from))>=56320&&n<57344;)e++;return e}function zd(r){let e=String(r.state.doc.lineAt(r.state.selection.main.head).number),t=je("input",{class:"cm-textfield",name:"line",value:e}),n=je("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),r.dispatch({effects:ko.of(!1)}),r.focus()):s.keyCode==13&&(s.preventDefault(),i())},onsubmit:s=>{s.preventDefault(),i()}},je("label",r.state.phrase("Go to line"),": ",t)," ",je("button",{class:"cm-button",type:"submit"},r.state.phrase("go")),je("button",{name:"close",onclick:()=>{r.dispatch({effects:ko.of(!1)}),r.focus()},"aria-label":r.state.phrase("close"),type:"button"},["×"]));function i(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=r,a=o.doc.lineAt(o.selection.main.head),[,l,c,u,h]=s,d=u?+u.slice(1):0,f=c?+c:a.number;if(c&&h){let m=f/100;l&&(m=m*(l=="-"?-1:1)+a.number/o.doc.lines),f=Math.round(o.doc.lines*m)}else c&&l&&(f=f*(l=="-"?-1:1)+a.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,f))),g=Q.cursor(p.from+Math.max(0,Math.min(d,p.length)));r.dispatch({effects:[ko.of(!1),X.scrollIntoView(g.from,{y:"center"})],selection:g}),r.focus()}return{dom:n}}const ko=fe.define(),l5=vt.define({create(){return!0},update(r,e){for(let t of e.effects)t.is(ko)&&(r=t.value);return r},provide:r=>uo.from(r,e=>e?zd:null)}),tR=r=>{let e=co(r,zd);if(!e){let t=[ko.of(!0)];r.state.field(l5,!1)==null&&t.push(fe.appendConfig.of([l5,nR])),r.dispatch({effects:t}),e=co(r,zd)}return e&&e.dom.querySelector("input").select(),!0},nR=X.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),rR={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},iR=J.define({combine(r){return In(r,rR,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function sR(r){return[uR,cR]}const oR=ie.mark({class:"cm-selectionMatch"}),aR=ie.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function c5(r,e,t,n){return(t==0||r(e.sliceDoc(t-1,t))!=ze.Word)&&(n==e.doc.length||r(e.sliceDoc(n,n+1))!=ze.Word)}function lR(r,e,t,n){return r(e.sliceDoc(t,t+1))==ze.Word&&r(e.sliceDoc(n-1,n))==ze.Word}const cR=tt.fromClass(class{constructor(r){this.decorations=this.getDeco(r)}update(r){(r.selectionSet||r.docChanged||r.viewportChanged)&&(this.decorations=this.getDeco(r.view))}getDeco(r){let e=r.state.facet(iR),{state:t}=r,n=t.selection;if(n.ranges.length>1)return ie.none;let i=n.main,s,o=null;if(i.empty){if(!e.highlightWordAroundCursor)return ie.none;let l=t.wordAt(i.head);if(!l)return ie.none;o=t.charCategorizer(i.head),s=t.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<e.minSelectionLength||l>200)return ie.none;if(e.wholeWords){if(s=t.sliceDoc(i.from,i.to),o=t.charCategorizer(i.head),!(c5(o,t,i.from,i.to)&&lR(o,t,i.from,i.to)))return ie.none}else if(s=t.sliceDoc(i.from,i.to),!s)return ie.none}let a=[];for(let l of r.visibleRanges){let c=new es(t.doc,s,l.from,l.to);for(;!c.next().done;){let{from:u,to:h}=c.value;if((!o||c5(o,t,u,h))&&(i.empty&&u<=i.from&&h>=i.to?a.push(aR.range(u,h)):(u>=i.to||h<=i.from)&&a.push(oR.range(u,h)),a.length>e.maxMatches))return ie.none}}return ie.set(a)}},{decorations:r=>r.decorations}),uR=X.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),hR=({state:r,dispatch:e})=>{let{selection:t}=r,n=Q.create(t.ranges.map(i=>r.wordAt(i.head)||Q.cursor(i.head)),t.mainIndex);return n.eq(t)?!1:(e(r.update({selection:n})),!0)};function dR(r,e){let{main:t,ranges:n}=r.selection,i=r.wordAt(t.head),s=i&&i.from==t.from&&i.to==t.to;for(let o=!1,a=new es(r.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new es(r.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(l=>l.from==a.value.from))continue;if(s){let l=r.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}const fR=({state:r,dispatch:e})=>{let{ranges:t}=r.selection;if(t.some(s=>s.from===s.to))return hR({state:r,dispatch:e});let n=r.sliceDoc(t[0].from,t[0].to);if(r.selection.ranges.some(s=>r.sliceDoc(s.from,s.to)!=n))return!1;let i=dR(r,n);return i?(e(r.update({selection:r.selection.addRange(Q.range(i.from,i.to),!1),effects:X.scrollIntoView(i.to)})),!0):!1},ns=J.define({combine(r){return In(r,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new xR(e),scrollToMatch:e=>X.scrollIntoView(e)})}});class u5{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||eR(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
590
- `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new yR(this):new mR(this)}getCursor(e,t=0,n){let i=e.doc?e:we.create({doc:e});return n==null&&(n=i.doc.length),this.regexp?is(this,i,t,n):rs(this,i,t,n)}}class h5{constructor(e){this.spec=e}}function rs(r,e,t,n){return new es(e.doc,r.unquoted,t,n,r.caseSensitive?void 0:i=>i.toLowerCase(),r.wholeWord?pR(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function pR(r,e){return(t,n,i,s)=>((s>t||s+i.length<n)&&(s=Math.max(0,t-2),i=r.sliceString(s,Math.min(r.length,n+2))),(e(ec(i,t-s))!=ze.Word||e(tc(i,t-s))!=ze.Word)&&(e(tc(i,n-s))!=ze.Word||e(ec(i,n-s))!=ze.Word))}class mR extends h5{constructor(e){super(e)}nextMatch(e,t,n){let i=rs(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let s=Math.min(e.doc.length,t+this.spec.unquoted.length);i=rs(this.spec,e,0,s).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==n?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let s=Math.max(t,i-1e4-this.spec.unquoted.length),o=rs(this.spec,e,s,i),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(s==t)return null;i-=1e4}}prevMatch(e,t,n){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=t||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=rs(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let s=rs(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function is(r,e,t,n){return new o5(e.doc,r.search,{ignoreCase:!r.caseSensitive,test:r.wholeWord?gR(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function ec(r,e){return r.slice(yt(r,e,!1),e)}function tc(r,e){return r.slice(e,yt(r,e))}function gR(r){return(e,t,n)=>!n[0].length||(r(ec(n.input,n.index))!=ze.Word||r(tc(n.input,n.index))!=ze.Word)&&(r(tc(n.input,n.index+n[0].length))!=ze.Word||r(ec(n.input,n.index+n[0].length))!=ze.Word)}class yR extends h5{nextMatch(e,t,n){let i=is(this.spec,e,n,e.doc.length).next();return i.done&&(i=is(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let s=Math.max(t,n-i*1e4),o=is(this.spec,e,s,n),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==t||a.from>s+10))return a;if(s==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let i=n.length;i>0;i--){let s=+n.slice(0,i);if(s>0&&s<e.match.length)return e.match[s]+n.slice(i)}return t})}matchAll(e,t){let n=is(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let s=is(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const So=fe.define(),$d=fe.define(),Fr=vt.define({create(r){return new Yd(Xd(r).create(),null)},update(r,e){for(let t of e.effects)t.is(So)?r=new Yd(t.value.create(),r.panel):t.is($d)&&(r=new Yd(r.query,t.value?Zd:null));return r},provide:r=>uo.from(r,e=>e.panel)});class Yd{constructor(e,t){this.query=e,this.panel=t}}const vR=ie.mark({class:"cm-searchMatch"}),bR=ie.mark({class:"cm-searchMatch cm-searchMatch-selected"}),CR=tt.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(Fr))}update(r){let e=r.state.field(Fr);(e!=r.startState.field(Fr)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:r,panel:e}){if(!e||!r.spec.valid)return ie.none;let{view:t}=this,n=new ir;for(let i=0,s=t.visibleRanges,o=s.length;i<o;i++){let{from:a,to:l}=s[i];for(;i<o-1&&l>s[i+1].from-2*250;)l=s[++i].to;r.highlight(t.state,a,l,(c,u)=>{let h=t.state.selection.ranges.some(d=>d.from==c&&d.to==u);n.add(c,u,h?bR:vR)})}return n.finish()}},{decorations:r=>r.decorations});function _o(r){return e=>{let t=e.state.field(Fr,!1);return t&&t.query.spec.valid?r(e,t):m5(e)}}const nc=_o((r,{query:e})=>{let{to:t}=r.state.selection.main,n=e.nextMatch(r.state,t,t);if(!n)return!1;let i=Q.single(n.from,n.to),s=r.state.facet(ns);return r.dispatch({selection:i,effects:[Kd(r,n),s.scrollToMatch(i.main,r)],userEvent:"select.search"}),p5(r),!0}),rc=_o((r,{query:e})=>{let{state:t}=r,{from:n}=t.selection.main,i=e.prevMatch(t,n,n);if(!i)return!1;let s=Q.single(i.from,i.to),o=r.state.facet(ns);return r.dispatch({selection:s,effects:[Kd(r,i),o.scrollToMatch(s.main,r)],userEvent:"select.search"}),p5(r),!0}),wR=_o((r,{query:e})=>{let t=e.matchAll(r.state,1e3);return!t||!t.length?!1:(r.dispatch({selection:Q.create(t.map(n=>Q.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),kR=({state:r,dispatch:e})=>{let t=r.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:i}=t.main,s=[],o=0;for(let a=new es(r.doc,r.sliceDoc(n,i));!a.next().done;){if(s.length>1e3)return!1;a.value.from==n&&(o=s.length),s.push(Q.range(a.value.from,a.value.to))}return e(r.update({selection:Q.create(s,o),userEvent:"select.search.matches"})),!0},d5=_o((r,{query:e})=>{let{state:t}=r,{from:n,to:i}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,n,n);if(!s)return!1;let o=s,a=[],l,c,u=[];if(o.from==n&&o.to==i&&(c=t.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),u.push(X.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))),o){let h=a.length==0||a[0].from>=s.to?0:s.to-s.from-c.length;l=Q.single(o.from-h,o.to-h),u.push(Kd(r,o)),u.push(t.facet(ns).scrollToMatch(l.main,r))}return r.dispatch({changes:a,selection:l,effects:u,userEvent:"input.replace"}),!0}),SR=_o((r,{query:e})=>{if(r.state.readOnly)return!1;let t=e.matchAll(r.state,1e9).map(i=>{let{from:s,to:o}=i;return{from:s,to:o,insert:e.getReplacement(i)}});if(!t.length)return!1;let n=r.state.phrase("replaced $ matches",t.length)+".";return r.dispatch({changes:t,effects:X.announce.of(n),userEvent:"input.replace.all"}),!0});function Zd(r){return r.state.facet(ns).createPanel(r)}function Xd(r,e){var t,n,i,s,o;let a=r.selection.main,l=a.empty||a.to>a.from+100?"":r.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=r.facet(ns);return new u5({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function f5(r){let e=co(r,Zd);return e&&e.dom.querySelector("[main-field]")}function p5(r){let e=f5(r);e&&e==r.root.activeElement&&e.select()}const m5=r=>{let e=r.state.field(Fr,!1);if(e&&e.panel){let t=f5(r);if(t&&t!=r.root.activeElement){let n=Xd(r.state,e.query.spec);n.valid&&r.dispatch({effects:So.of(n)}),t.focus(),t.select()}}else r.dispatch({effects:[$d.of(!0),e?So.of(Xd(r.state,e.query.spec)):fe.appendConfig.of(ER)]});return!0},g5=r=>{let e=r.state.field(Fr,!1);if(!e||!e.panel)return!1;let t=co(r,Zd);return t&&t.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:$d.of(!1)}),!0},_R=[{key:"Mod-f",run:m5,scope:"editor search-panel"},{key:"F3",run:nc,shift:rc,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:nc,shift:rc,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:g5,scope:"editor search-panel"},{key:"Mod-Shift-l",run:kR},{key:"Mod-Alt-g",run:tR},{key:"Mod-d",run:fR,preventDefault:!0}];class xR{constructor(e){this.view=e;let t=this.query=e.state.field(Fr).query.spec;this.commit=this.commit.bind(this),this.searchField=je("input",{value:t.search,placeholder:Xt(e,"Find"),"aria-label":Xt(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=je("input",{value:t.replace,placeholder:Xt(e,"Replace"),"aria-label":Xt(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=je("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=je("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=je("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(i,s,o){return je("button",{class:"cm-button",name:i,onclick:s,type:"button"},o)}this.dom=je("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>nc(e),[Xt(e,"next")]),n("prev",()=>rc(e),[Xt(e,"previous")]),n("select",()=>wR(e),[Xt(e,"all")]),je("label",null,[this.caseField,Xt(e,"match case")]),je("label",null,[this.reField,Xt(e,"regexp")]),je("label",null,[this.wordField,Xt(e,"by word")]),...e.state.readOnly?[]:[je("br"),this.replaceField,n("replace",()=>d5(e),[Xt(e,"replace")]),n("replaceAll",()=>SR(e),[Xt(e,"replace all")])],je("button",{name:"close",onclick:()=>g5(e),"aria-label":Xt(e,"close"),type:"button"},["×"])])}commit(){let e=new u5({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:So.of(e)}))}keydown(e){FM(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?rc:nc)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),d5(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(So)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ns).top}}function Xt(r,e){return r.state.phrase(e)}const ic=30,sc=/[\s\.,:;?!]/;function Kd(r,{from:e,to:t}){let n=r.state.doc.lineAt(e),i=r.state.doc.lineAt(t).to,s=Math.max(n.from,e-ic),o=Math.min(i,t+ic),a=r.state.sliceDoc(s,o);if(s!=n.from){for(let l=0;l<ic;l++)if(!sc.test(a[l+1])&&sc.test(a[l])){a=a.slice(l);break}}if(o!=i){for(let l=a.length-1;l>a.length-ic;l--)if(!sc.test(a[l-1])&&sc.test(a[l])){a=a.slice(0,l);break}}return X.announce.of(`${r.state.phrase("current match")}. ${a} ${r.state.phrase("on line")} ${n.number}.`)}const OR=X.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ER=[Fr,ii.low(CR),OR];class y5{constructor(e,t,n,i){this.state=e,this.pos=t,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=dt(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),s=i.search(w5(e,!1));return s<0?null:{from:n+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function v5(r){let e=Object.keys(r).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function DR(r){let e=Object.create(null),t=Object.create(null);for(let{label:i}of r){e[i[0]]=!0;for(let s=1;s<i.length;s++)t[i[s]]=!0}let n=v5(e)+v5(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function b5(r){let e=r.map(i=>typeof i=="string"?{label:i}:i),[t,n]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:DR(e);return i=>{let s=i.matchBefore(n);return s||i.explicit?{from:s?s.from:i.pos,options:e,validFor:t}:null}}function MR(r,e){return t=>{for(let n=dt(t.state).resolveInner(t.pos,-1);n;n=n.parent){if(r.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return e(t)}}class C5{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function fi(r){return r.selection.main.from}function w5(r,e){var t;let{source:n}=r,i=e&&n[0]!="^",s=n[n.length-1]!="$";return!i&&!s?r:new RegExp(`${i?"^":""}(?:${n})${s?"$":""}`,(t=r.flags)!==null&&t!==void 0?t:r.ignoreCase?"i":"")}const k5=Nn.define();function PR(r,e,t,n){let{main:i}=r.selection,s=t-i.from,o=n-i.from;return Object.assign(Object.assign({},r.changeByRange(a=>{if(a!=i&&t!=n&&r.sliceDoc(a.from+s,a.from+o)!=r.sliceDoc(t,n))return{range:a};let l=r.toText(e);return{changes:{from:a.from+s,to:n==i.from?a.to:a.from+o,insert:l},range:Q.cursor(a.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const S5=new WeakMap;function TR(r){if(!Array.isArray(r))return r;let e=S5.get(r);return e||S5.set(r,e=b5(r)),e}const oc=fe.define(),xo=fe.define();class AR{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Bt(e,t),i=Rn(n);this.chars.push(n);let s=e.slice(t,t+i),o=s.toUpperCase();this.folded.push(Bt(o==s?s.toLowerCase():o,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:s,byWord:o}=this;if(t.length==1){let _=Bt(e,0),k=Rn(_),C=k==e.length?0:-100;if(_!=t[0])if(_==n[0])C+=-200;else return null;return this.ret(C,[0,k])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,c=0;if(a<0){for(let _=0,k=Math.min(e.length,200);_<k&&c<l;){let C=Bt(e,_);(C==t[c]||C==n[c])&&(i[c++]=_),_+=Rn(C)}if(c<l)return null}let u=0,h=0,d=!1,f=0,p=-1,g=-1,m=/[a-z]/.test(e),b=!0;for(let _=0,k=Math.min(e.length,200),C=0;_<k&&h<l;){let v=Bt(e,_);a<0&&(u<l&&v==t[u]&&(s[u++]=_),f<l&&(v==t[f]||v==n[f]?(f==0&&(p=_),g=_+1,f++):f=0));let x,S=v<255?v>=48&&v<=57||v>=97&&v<=122?2:v>=65&&v<=90?1:0:(x=oh(v))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!_||S==1&&m||C==0&&S!=0)&&(t[h]==v||n[h]==v&&(d=!0)?o[h++]=_:o.length&&(b=!1)),C=S,_+=Rn(v)}return h==l&&o[0]==0&&b?this.result(-100+(d?-200:0),o,e):f==l&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):f==l?this.ret(-900-e.length,[p,g]):h==l?this.result(-100+(d?-200:0)+-700+(b?0:-1100),o,e):t.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,n){let i=[],s=0;for(let o of t){let a=o+(this.astral?Rn(Bt(n,o)):1);s&&i[s-1]==o?i[s-1]=a:(i[s++]=o,i[s++]=a)}return this.ret(e-n.length,i)}}class RR{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const ft=J.define({combine(r){return In(r,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:LR,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>_5(e(n),t(n)),optionClass:(e,t)=>n=>_5(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function _5(r,e){return r?e?r+" "+e:r:e}function LR(r,e,t,n,i,s){let o=r.textDirection==Qe.RTL,a=o,l=!1,c="top",u,h,d=e.left-i.left,f=i.right-e.right,p=n.right-n.left,g=n.bottom-n.top;if(a&&d<Math.min(p,f)?a=!1:!a&&f<Math.min(p,d)&&(a=!0),p<=(a?d:f))u=Math.max(i.top,Math.min(t.top,i.bottom-g))-e.top,h=Math.min(400,a?d:f);else{l=!0,h=Math.min(400,(o?e.right:i.right-e.left)-30);let _=i.bottom-e.bottom;_>=g||_>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let m=(e.bottom-e.top)/s.offsetHeight,b=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${u/m}px; max-width: ${h/b}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}function NR(r){let e=r.addToOptions.slice();return r.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,i,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;c<s.length;){let u=s[c++],h=s[c++];u>l&&o.appendChild(document.createTextNode(a.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(a.slice(u,h))),d.className="cm-completionMatchedText",l=h}return l<a.length&&o.appendChild(document.createTextNode(a.slice(l))),o},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function Gd(r,e,t){if(r<=t)return{from:0,to:r};if(e<0&&(e=0),e<=r>>1){let i=Math.floor(e/t);return{from:i*t,to:(i+1)*t}}let n=Math.floor((r-e)/t);return{from:r-(n+1)*t,to:r-n*t}}class IR{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:s,selected:o}=i.open,a=e.state.facet(ft);this.optionContent=NR(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=Gd(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,h;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(h=/-(\d+)$/.exec(u.id))&&+h[1]<c.length){this.applyCompletion(e,c[+h[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(ft).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:xo.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:s,selected:o,disabled:a}=n.open;(!i.open||i.open.options!=s)&&(this.range=Gd(s.length,o,e.state.facet(ft).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),a!=((t=i.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Gd(t.options.length,t.selected,this.view.state.facet(ft).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let s=typeof i=="string"?document.createTextNode(i):i(n);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,n)}).catch(o=>Ft(this.view.state,o,"completion info")):this.addInfoPane(s,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:s}=e;n.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)n.nodeName!="LI"||!n.id?i--:i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&HR(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(s.bottom,t.bottom)-10||i.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(ft).positionInfo(this.view,t,i,n,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let s=null;for(let o=n.from;o<n.to;o++){let{completion:a,match:l}=e[o],{section:c}=a;if(c){let d=typeof c=="string"?c:c.name;if(d!=s&&(o>n.from||n.from==0))if(s=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let h=this.optionClass(a);h&&(u.className=h);for(let d of this.optionContent){let f=d(a,this.view.state,this.view,l);f&&u.appendChild(f)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function BR(r,e){return t=>new IR(t,r,e)}function HR(r,e){let t=r.getBoundingClientRect(),n=e.getBoundingClientRect(),i=t.height/r.offsetHeight;n.top<t.top?r.scrollTop-=(t.top-n.top)/i:n.bottom>t.bottom&&(r.scrollTop+=(n.bottom-t.bottom)/i)}function x5(r){return(r.boost||0)*100+(r.apply?10:0)+(r.info?5:0)+(r.type?1:0)}function FR(r,e){let t=[],n=null,i=c=>{t.push(c);let{section:u}=c.completion;if(u){n||(n=[]);let h=typeof u=="string"?u:u.name;n.some(d=>d.name==h)||n.push(typeof u=="string"?{name:h}:u)}},s=e.facet(ft);for(let c of r)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let h of c.result.options)i(new C5(h,c.source,u?u(h):[],1e9-t.length));else{let h=e.sliceDoc(c.from,c.to),d,f=s.filterStrict?new RR(h):new AR(h);for(let p of c.result.options)if(d=f.match(p.label)){let g=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new C5(p,c.source,g,d.score+(p.boost||0)))}}}if(n){let c=Object.create(null),u=0,h=(d,f)=>{var p,g;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((g=f.rank)!==null&&g!==void 0?g:1e9)||(d.name<f.name?-1:1)};for(let d of n.sort(h))u-=1e5,c[d.name]=u;for(let d of t){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.name])}}let o=[],a=null,l=s.compareCompletions;for(let c of t.sort((u,h)=>h.score-u.score||l(u.completion,h.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?o.push(c):x5(c.completion)>x5(a)&&(o[o.length-1]=c),a=c.completion}return o}class ss{constructor(e,t,n,i,s,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new ss(this.options,O5(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,s,o){if(i&&!o&&e.some(c=>c.isPending))return i.setDisabled();let a=FR(e,t);if(!a.length)return i&&e.some(c=>c.isPending)?i.setDisabled():null;let l=t.facet(ft).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}}return new ss(a,O5(n,l),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:UR,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(e){return new ss(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new ss(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ac{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new ac(QR,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(ft),s=(n.override||t.languageDataAt("autocomplete",fi(t)).map(TR)).map(l=>(this.active.find(u=>u.source==l)||new ln(l,this.active.some(u=>u.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let o=this.open,a=e.effects.some(l=>l.is(Jd));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!VR(s,this.active)||a?o=ss.build(s,t,this.id,o,n,a):o&&o.disabled&&!s.some(l=>l.isPending)&&(o=null),!o&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new ln(l.source,0):l));for(let l of e.effects)l.is(D5)&&(o=o&&o.setSelected(l.value,this.id));return s==this.active&&o==this.open?this:new ac(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?jR:WR}}function VR(r,e){if(r==e)return!0;for(let t=0,n=0;;){for(;t<r.length&&!r[t].hasResult();)t++;for(;n<e.length&&!e[n].hasResult();)n++;let i=t==r.length,s=n==e.length;if(i||s)return i==s;if(r[t++].result!=e[n++].result)return!1}}const jR={"aria-autocomplete":"list"},WR={};function O5(r,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":r};return e>-1&&(t["aria-activedescendant"]=r+"-"+e),t}const QR=[];function E5(r,e){if(r.isUserEvent("input.complete")){let n=r.annotation(k5);if(n&&e.activateOnCompletion(n))return 12}let t=r.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:r.isUserEvent("delete.backward")?2:r.selection?8:r.docChanged?16:0}class ln{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=E5(e,t),i=this;(n&8||n&16&&this.touches(e))&&(i=new ln(i.source,0)),n&4&&i.state==0&&(i=new ln(this.source,1)),i=i.updateFor(e,n);for(let s of e.effects)if(s.is(oc))i=new ln(i.source,1,s.value);else if(s.is(xo))i=new ln(i.source,0);else if(s.is(Jd))for(let o of s.value)o.source==i.source&&(i=o);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(fi(e.state))}}class os extends ln{constructor(e,t,n,i,s,o){super(e,3,t),this.limit=n,this.result=i,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=fi(e.state);if(a>o||!i||t&2&&(fi(e.startState)==this.from||a<this.limit))return new ln(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return qR(i.validFor,e.state,s,o)?new os(this.source,this.explicit,l,i,s,o):i.update&&(i=i.update(i,s,o,new y5(e.state,a,!1)))?new os(this.source,this.explicit,l,i,i.from,(n=i.to)!==null&&n!==void 0?n:fi(e.state)):new ln(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new os(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ln(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function qR(r,e,t,n){if(!r)return!1;let i=e.sliceDoc(t,n);return typeof r=="function"?r(i,t,n,e):w5(r,!0).test(i)}const Jd=fe.define({map(r,e){return r.map(t=>t.map(e))}}),D5=fe.define(),Wt=vt.define({create(){return ac.start()},update(r,e){return r.update(e)},provide:r=>[hd.from(r,e=>e.tooltip),X.contentAttributes.from(r,e=>e.attrs)]});function ef(r,e){const t=e.completion.apply||e.completion.label;let n=r.state.field(Wt).active.find(i=>i.source==e.source);return n instanceof os?(typeof t=="string"?r.dispatch(Object.assign(Object.assign({},PR(r.state,t,n.from,n.to)),{annotations:k5.of(e.completion)})):t(r,e.completion,n.from,n.to),!0):!1}const UR=BR(Wt,ef);function lc(r,e="option"){return t=>{let n=t.state.field(Wt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(ft).interactionDelay)return!1;let i=1,s;e=="page"&&(s=O6(t,n.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,a=n.open.selected>-1?n.open.selected+i*(r?1:-1):r?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:D5.of(a)}),!0}}const zR=r=>{let e=r.state.field(Wt,!1);return r.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<r.state.facet(ft).interactionDelay?!1:ef(r,e.open.options[e.open.selected])},M5=r=>r.state.field(Wt,!1)?(r.dispatch({effects:oc.of(!0)}),!0):!1,$R=r=>{let e=r.state.field(Wt,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(r.dispatch({effects:xo.of(null)}),!0)};class YR{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const ZR=50,XR=1e3,KR=tt.fromClass(class{constructor(r){this.view=r,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of r.state.field(Wt).active)e.isPending&&this.startQuery(e)}update(r){let e=r.state.field(Wt),t=r.state.facet(ft);if(!r.selectionSet&&!r.docChanged&&r.startState.field(Wt)==e)return;let n=r.transactions.some(s=>{let o=E5(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(n||o.context.abortOnDocChange&&r.docChanged||o.updates.length+r.transactions.length>ZR&&Date.now()-o.time>XR){for(let a of o.context.abortListeners)try{a()}catch(l){Ft(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...r.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),r.transactions.some(s=>s.effects.some(o=>o.is(oc)))&&(this.pendingStart=!0);let i=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of r.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:r}=this.view,e=r.field(Wt);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ft).updateSyncTime))}startQuery(r){let{state:e}=this.view,t=fi(e),n=new y5(e,t,r.explicit,this.view),i=new YR(r,n);this.running.push(i),Promise.resolve(r.source(n)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:xo.of(null)}),Ft(this.view.state,s)})}scheduleAccept(){this.running.every(r=>r.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ft).updateSyncTime))}accept(){var r;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ft),n=this.view.state.field(Wt);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let a=fi(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(a,s.done.from+(s.active.explicit?0:1)),c=new os(s.active.source,s.active.explicit,l,s.done,s.done.from,(r=s.done.to)!==null&&r!==void 0?r:a);for(let u of s.updates)c=c.update(u,t);if(c.hasResult()){e.push(c);continue}}let o=n.active.find(a=>a.source==s.active.source);if(o&&o.isPending)if(s.done==null){let a=new ln(s.active.source,0);for(let l of s.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:Jd.of(e)})}},{eventHandlers:{blur(r){let e=this.view.state.field(Wt,!1);if(e&&e.tooltip&&this.view.state.facet(ft).closeOnBlur){let t=e.open&&O6(this.view,e.open.tooltip);(!t||!t.dom.contains(r.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:xo.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:oc.of(!1)}),20),this.composing=0}}}),GR=typeof navigator=="object"&&/Win/.test(navigator.platform),JR=ii.highest(X.domEventHandlers({keydown(r,e){let t=e.state.field(Wt,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||r.key.length>1||r.ctrlKey&&!(GR&&r.altKey)||r.metaKey)return!1;let n=t.open.options[t.open.selected],i=t.active.find(o=>o.source==n.source),s=n.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(r.key)>-1&&ef(e,n),!1}})),eL=X.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Oo={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},pi=fe.define({map(r,e){let t=e.mapPos(r,-1,Tt.TrackAfter);return t??void 0}}),tf=new class extends si{};tf.startSide=1,tf.endSide=-1;const P5=vt.define({create(){return Oe.empty},update(r,e){if(r=r.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);r=r.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(pi)&&(r=r.update({add:[tf.range(t.value,t.value+1)]}));return r}});function tL(){return[rL,P5]}const nf="()[]{}<>«»»«[]{}";function T5(r){for(let e=0;e<nf.length;e+=2)if(nf.charCodeAt(e)==r)return nf.charAt(e+1);return oh(r<128?r:r+1)}function A5(r,e){return r.languageDataAt("closeBrackets",e)[0]||Oo}const nL=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),rL=X.inputHandler.of((r,e,t,n)=>{if((nL?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let i=r.state.selection.main;if(n.length>2||n.length==2&&Rn(Bt(n,0))==1||e!=i.from||t!=i.to)return!1;let s=sL(r.state,n);return s?(r.dispatch(s),!0):!1}),iL=[{key:"Backspace",run:({state:r,dispatch:e})=>{if(r.readOnly)return!1;let n=A5(r,r.selection.main.head).brackets||Oo.brackets,i=null,s=r.changeByRange(o=>{if(o.empty){let a=oL(r.doc,o.head);for(let l of n)if(l==a&&cc(r.doc,o.head)==T5(Bt(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Q.cursor(o.head-l.length)}}return{range:i=o}});return i||e(r.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function sL(r,e){let t=A5(r,r.selection.main.head),n=t.brackets||Oo.brackets;for(let i of n){let s=T5(Bt(i,0));if(e==i)return s==i?cL(r,i,n.indexOf(i+i+i)>-1,t):aL(r,i,s,t.before||Oo.before);if(e==s&&R5(r,r.selection.main.from))return lL(r,i,s)}return null}function R5(r,e){let t=!1;return r.field(P5).between(0,r.doc.length,n=>{n==e&&(t=!0)}),t}function cc(r,e){let t=r.sliceString(e,e+2);return t.slice(0,Rn(Bt(t,0)))}function oL(r,e){let t=r.sliceString(e-2,e);return Rn(Bt(t,0))==t.length?t:t.slice(1)}function aL(r,e,t,n){let i=null,s=r.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:pi.of(o.to+e.length),range:Q.range(o.anchor+e.length,o.head+e.length)};let a=cc(r.doc,o.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:pi.of(o.head+e.length),range:Q.cursor(o.head+e.length)}:{range:i=o}});return i?null:r.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function lL(r,e,t){let n=null,i=r.changeByRange(s=>s.empty&&cc(r.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:Q.cursor(s.head+t.length)}:n={range:s});return n?null:r.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function cL(r,e,t,n){let i=n.stringPrefixes||Oo.stringPrefixes,s=null,o=r.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:pi.of(a.to+e.length),range:Q.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=cc(r.doc,l),u;if(c==e){if(L5(r,l))return{changes:{insert:e+e,from:l},effects:pi.of(l+e.length),range:Q.cursor(l+e.length)};if(R5(r,l)){let d=t&&r.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+d.length,insert:d},range:Q.cursor(l+d.length)}}}else{if(t&&r.sliceDoc(l-2*e.length,l)==e+e&&(u=N5(r,l-2*e.length,i))>-1&&L5(r,u))return{changes:{insert:e+e+e+e,from:l},effects:pi.of(l+e.length),range:Q.cursor(l+e.length)};if(r.charCategorizer(l)(c)!=ze.Word&&N5(r,l,i)>-1&&!uL(r,l,e,i))return{changes:{insert:e+e,from:l},effects:pi.of(l+e.length),range:Q.cursor(l+e.length)}}return{range:s=a}});return s?null:r.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function L5(r,e){let t=dt(r).resolveInner(e+1);return t.parent&&t.from==e}function uL(r,e,t,n){let i=dt(r).resolveInner(e,-1),s=n.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=r.sliceDoc(i.from,Math.min(i.to,i.from+t.length+s)),l=a.indexOf(t);if(!l||l>-1&&n.indexOf(a.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>t.length+l;){if(r.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function N5(r,e,t){let n=r.charCategorizer(e);if(n(r.sliceDoc(e-1,e))!=ze.Word)return e;for(let i of t){let s=e-i.length;if(r.sliceDoc(s,e)==i&&n(r.sliceDoc(s-1,s))!=ze.Word)return s}return-1}function hL(r={}){return[JR,Wt,ft.of(r),KR,dL,eL]}const I5=[{key:"Ctrl-Space",run:M5},{mac:"Alt-`",run:M5},{key:"Escape",run:$R},{key:"ArrowDown",run:lc(!0)},{key:"ArrowUp",run:lc(!1)},{key:"PageDown",run:lc(!0,"page")},{key:"PageUp",run:lc(!1,"page")},{key:"Enter",run:zR}],dL=ii.highest(kl.computeN([ft],r=>r.facet(ft).defaultKeymap?[I5]:[]));class B5{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class mi{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=n.facet(Eo).markerFilter;i&&(e=i(e,n));let s=e.slice().sort((u,h)=>u.from-h.from||u.to-h.to),o=new ir,a=[],l=0;for(let u=0;;){let h=u==s.length?null:s[u];if(!h&&!a.length)break;let d,f;for(a.length?(d=l,f=a.reduce((g,m)=>Math.min(g,m.to),h&&h.from>d?h.from:1e8)):(d=h.from,f=h.to,a.push(h),u++);u<s.length;){let g=s[u];if(g.from==d&&(g.to>g.from||g.to==d))a.push(g),u++,f=Math.min(g.to,f);else{f=Math.min(g.from,f);break}}let p=_L(a);if(a.some(g=>g.from==g.to||g.from==g.to-1&&n.doc.lineAt(g.from).to==g.from))o.add(d,d,ie.widget({widget:new CL(p),diagnostics:a.slice()}));else{let g=a.reduce((m,b)=>b.markClass?m+" "+b.markClass:m,"");o.add(d,f,ie.mark({class:"cm-lintRange cm-lintRange-"+p+g,diagnostics:a.slice(),inclusiveEnd:a.some(m=>m.to>f)}))}l=f;for(let g=0;g<a.length;g++)a[g].to<=l&&a.splice(g--,1)}let c=o.finish();return new mi(c,t,as(c))}}function as(r,e=null,t=0){let n=null;return r.between(t,1e9,(i,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!n)n=new B5(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new B5(n.from,s,n.diagnostic)}}),n}function fL(r,e){let t=e.pos,n=e.end||t,i=r.state.facet(Eo).hideOn(r,t,n);if(i!=null)return i;let s=r.startState.doc.lineAt(e.pos);return!!(r.effects.some(o=>o.is(H5))||r.changes.touchesRange(s.from,Math.max(s.to,n)))}function pL(r,e){return r.field(Kt,!1)?e:e.concat(fe.appendConfig.of(xL))}const H5=fe.define(),rf=fe.define(),F5=fe.define(),Kt=vt.define({create(){return new mi(ie.none,null,null)},update(r,e){if(e.docChanged&&r.diagnostics.size){let t=r.diagnostics.map(e.changes),n=null,i=r.panel;if(r.selected){let s=e.changes.mapPos(r.selected.from,1);n=as(t,r.selected.diagnostic,s)||as(t,null,s)}!t.size&&i&&e.state.facet(Eo).autoPanel&&(i=null),r=new mi(t,i,n)}for(let t of e.effects)if(t.is(H5)){let n=e.state.facet(Eo).autoPanel?t.value.length?Do.open:null:r.panel;r=mi.init(t.value,n,e.state)}else t.is(rf)?r=new mi(r.diagnostics,t.value?Do.open:null,r.selected):t.is(F5)&&(r=new mi(r.diagnostics,r.panel,t.value));return r},provide:r=>[uo.from(r,e=>e.panel),X.decorations.from(r,e=>e.diagnostics)]}),mL=ie.mark({class:"cm-lintRange cm-lintRange-active"});function gL(r,e,t){let{diagnostics:n}=r.state.field(Kt),i,s=-1,o=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(e<c||t<0)))return i=u.diagnostics,s=l,o=c,!1});let a=r.state.facet(Eo).tooltipFilter;return i&&a&&(i=a(i,r.state)),i?{pos:s,end:o,above:r.state.doc.lineAt(s).to<o,create(){return{dom:yL(r,i)}}}:null}function yL(r,e){return je("ul",{class:"cm-tooltip-lint"},e.map(t=>W5(r,t,!1)))}const vL=r=>{let e=r.state.field(Kt,!1);(!e||!e.panel)&&r.dispatch({effects:pL(r.state,[rf.of(!0)])});let t=co(r,Do.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},V5=r=>{let e=r.state.field(Kt,!1);return!e||!e.panel?!1:(r.dispatch({effects:rf.of(!1)}),!0)},bL=[{key:"Mod-Shift-m",run:vL,preventDefault:!0},{key:"F8",run:r=>{let e=r.state.field(Kt,!1);if(!e)return!1;let t=r.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(r.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)}}],Eo=J.define({combine(r){return Object.assign({sources:r.map(e=>e.source).filter(e=>e!=null)},In(r.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))}});function j5(r){let e=[];if(r)e:for(let{name:t}of r){for(let n=0;n<t.length;n++){let i=t[n];if(/[a-zA-Z]/.test(i)&&!e.some(s=>s.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function W5(r,e,t){var n;let i=t?j5(e.actions):[];return je("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},je("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(r):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let f=as(r.state.field(Kt).diagnostics,e);f&&s.apply(r,f.from,f.to)},{name:c}=s,u=i[o]?c.indexOf(i[o]):-1,h=u<0?c:[c.slice(0,u),je("u",c.slice(u,u+1)),c.slice(u+1)];return je("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${i[o]})"`}.`},h)}),e.source&&je("div",{class:"cm-diagnosticSource"},e.source))}class CL extends or{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return je("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Q5{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=W5(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Do{constructor(e){this.view=e,this.items=[];let t=i=>{if(i.keyCode==27)V5(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=j5(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=as(this.view.state.field(Kt).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;i.preventDefault()},n=i=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(i.target)&&this.moveSelection(s)};this.list=je("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=je("div",{class:"cm-panel-lint"},this.list,je("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>V5(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Kt).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Kt),n=0,i=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let u of c.diagnostics){if(o.has(u))continue;o.add(u);let h=-1,d;for(let f=n;f<this.items.length;f++)if(this.items[f].diagnostic==u){h=f;break}h<0?(d=new Q5(this.view,u),this.items.splice(n,0,d),i=!0):(d=this.items[h],h>n&&(this.items.splice(n,h-n),i=!0)),t&&d.diagnostic==t.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new Q5(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Kt),n=as(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:F5.of(n)})}static open(e){return new Do(e)}}function wL(r,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(r)}</svg>')`}function uc(r){return wL(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${r}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const kL=X.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:uc("#d11")},".cm-lintRange-warning":{backgroundImage:uc("orange")},".cm-lintRange-info":{backgroundImage:uc("#999")},".cm-lintRange-hint":{backgroundImage:uc("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function SL(r){return r=="error"?4:r=="warning"?3:r=="info"?2:1}function _L(r){let e="hint",t=1;for(let n of r){let i=SL(n.severity);i>t&&(t=i,e=n.severity)}return e}const xL=[Kt,X.decorations.compute([Kt],r=>{let{selected:e,panel:t}=r.field(Kt);return!e||!t||e.from==e.to?ie.none:ie.set([mL.range(e.from,e.to)])}),EP(gL,{hideOn:fL}),kL];var q5=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(iL)),e.defaultKeymap!==!1&&(n=n.concat(GA)),e.searchKeymap!==!1&&(n=n.concat(_R)),e.historyKeymap!==!1&&(n=n.concat(aA)),e.foldKeymap!==!1&&(n=n.concat(kT)),e.completionKeymap!==!1&&(n=n.concat(I5)),e.lintKeymap!==!1&&(n=n.concat(bL));var i=[];return e.lineNumbers!==!1&&i.push(HP()),e.highlightActiveLineGutter!==!1&&i.push(jP()),e.highlightSpecialChars!==!1&&i.push(nP()),e.history!==!1&&i.push(GT()),e.foldGutter!==!1&&i.push(OT()),e.drawSelection!==!1&&i.push(UM()),e.dropCursor!==!1&&i.push(XM()),e.allowMultipleSelections!==!1&&i.push(we.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(mT()),e.syntaxHighlighting!==!1&&i.push(u2(PT,{fallback:!0})),e.bracketMatching!==!1&&i.push(IT()),e.closeBrackets!==!1&&i.push(tL()),e.autocompletion!==!1&&i.push(hL()),e.rectangularSelection!==!1&&i.push(gP()),t!==!1&&i.push(bP()),e.highlightActiveLine!==!1&&i.push(lP()),e.highlightSelectionMatches!==!1&&i.push(sR()),e.tabSize&&typeof e.tabSize=="number"&&i.push(Fl.of(" ".repeat(e.tabSize))),i.concat([kl.of(n.flat())]).filter(Boolean)};const OL="#e5c07b",U5="#e06c75",EL="#56b6c2",DL="#ffffff",hc="#abb2bf",sf="#7d8799",ML="#61afef",PL="#98c379",z5="#d19a66",TL="#c678dd",AL="#21252b",$5="#2c313a",Y5="#282c34",of="#353a42",RL="#3E4451",Z5="#528bff",LL=X.theme({"&":{color:hc,backgroundColor:Y5},".cm-content":{caretColor:Z5},".cm-cursor, .cm-dropCursor":{borderLeftColor:Z5},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:RL},".cm-panels":{backgroundColor:AL,color:hc},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Y5,color:sf,border:"none"},".cm-activeLineGutter":{backgroundColor:$5},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:of},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:of,borderBottomColor:of},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:$5,color:hc}}},{dark:!0}),NL=bo.define([{tag:T.keyword,color:TL},{tag:[T.name,T.deleted,T.character,T.propertyName,T.macroName],color:U5},{tag:[T.function(T.variableName),T.labelName],color:ML},{tag:[T.color,T.constant(T.name),T.standard(T.name)],color:z5},{tag:[T.definition(T.name),T.separator],color:hc},{tag:[T.typeName,T.className,T.number,T.changed,T.annotation,T.modifier,T.self,T.namespace],color:OL},{tag:[T.operator,T.operatorKeyword,T.url,T.escape,T.regexp,T.link,T.special(T.string)],color:EL},{tag:[T.meta,T.comment],color:sf},{tag:T.strong,fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.link,color:sf,textDecoration:"underline"},{tag:T.heading,fontWeight:"bold",color:U5},{tag:[T.atom,T.bool,T.special(T.variableName)],color:z5},{tag:[T.processingInstruction,T.string,T.inserted],color:PL},{tag:T.invalid,color:DL}]),IL=[LL,u2(NL)];var BL=X.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),HL=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:i=!1,theme:s="light",placeholder:o="",basicSetup:a=!0}=e,l=[];switch(t&&l.unshift(kl.of([JA])),a&&(typeof a=="boolean"?l.unshift(q5()):l.unshift(q5(a))),o&&l.unshift(dP(o)),s){case"light":l.push(BL);break;case"dark":l.push(IL);break;case"none":break;default:l.push(s);break}return n===!1&&l.push(X.editable.of(!1)),i&&l.push(we.readOnly.of(!0)),[...l]},FL=r=>({line:r.state.doc.lineAt(r.state.selection.main.from),lineCount:r.state.doc.lines,lineBreak:r.state.lineBreak,length:r.state.doc.length,readOnly:r.state.readOnly,tabSize:r.state.tabSize,selection:r.state.selection,selectionAsSingle:r.state.selection.asSingle().main,ranges:r.state.selection.ranges,selectionCode:r.state.sliceDoc(r.state.selection.main.from,r.state.selection.main.to),selections:r.state.selection.ranges.map(e=>r.state.sliceDoc(e.from,e.to)),selectedText:r.state.selection.ranges.some(e=>!e.empty)}),X5=Nn.define(),VL=[];function jL(r){var{value:e,selection:t,onChange:n,onStatistics:i,onCreateEditor:s,onUpdate:o,extensions:a=VL,autoFocus:l,theme:c="light",height:u=null,minHeight:h=null,maxHeight:d=null,width:f=null,minWidth:p=null,maxWidth:g=null,placeholder:m="",editable:b=!0,readOnly:_=!1,indentWithTab:k=!0,basicSetup:C=!0,root:v,initialState:x}=r,[S,D]=O.useState(),[P,F]=O.useState(),[A,N]=O.useState(),B=X.theme({"&":{height:u,minHeight:h,maxHeight:d,width:f,minWidth:p,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),L=X.updateListener.of(q=>{if(q.docChanged&&typeof n=="function"&&!q.transactions.some(he=>he.annotation(X5))){var $=q.state.doc,re=$.toString();n(re,q)}i&&i(FL(q))}),H=HL({theme:c,editable:b,readOnly:_,placeholder:m,indentWithTab:k,basicSetup:C}),j=[L,B,...H];return o&&typeof o=="function"&&j.push(X.updateListener.of(o)),j=j.concat(a),O.useLayoutEffect(()=>{if(S&&!A){var q={doc:e,selection:t,extensions:j},$=x?we.fromJSON(x.json,q,x.fields):we.create(q);if(N($),!P){var re=new X({state:$,parent:S,root:v});F(re),s&&s(re,$)}}return()=>{P&&(N(void 0),F(void 0))}},[S,A]),O.useEffect(()=>{r.container&&D(r.container)},[r.container]),O.useEffect(()=>()=>{P&&(P.destroy(),F(void 0))},[P]),O.useEffect(()=>{l&&P&&P.focus()},[l,P]),O.useEffect(()=>{P&&P.dispatch({effects:fe.reconfigure.of(j)})},[c,a,u,h,d,f,p,g,m,b,_,k,C,n,o]),O.useEffect(()=>{if(e!==void 0){var q=P?P.state.doc.toString():"";P&&e!==q&&P.dispatch({changes:{from:0,to:q.length,insert:e||""},annotations:[X5.of(!0)]})}},[e,P]),{state:A,setState:N,view:P,setView:F,container:S,setContainer:D}}var WL=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],K5=O.forwardRef((r,e)=>{var{className:t,value:n="",selection:i,extensions:s=[],onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:c,autoFocus:u,theme:h="light",height:d,minHeight:f,maxHeight:p,width:g,minWidth:m,maxWidth:b,basicSetup:_,placeholder:k,indentWithTab:C,editable:v,readOnly:x,root:S,initialState:D}=r,P=jE(r,WL),F=O.useRef(null),{state:A,view:N,container:B,setContainer:L}=jL({root:S,value:n,autoFocus:u,theme:h,height:d,minHeight:f,maxHeight:p,width:g,minWidth:m,maxWidth:b,basicSetup:_,placeholder:k,indentWithTab:C,editable:v,readOnly:x,selection:i,onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:c,extensions:s,initialState:D});O.useImperativeHandle(e,()=>({editor:F.current,state:A,view:N}),[F,B,A,N]);var H=O.useCallback(q=>{F.current=q,L(q)},[L]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var j=typeof h=="string"?"cm-theme-"+h:"cm-theme";return me.jsx("div",rh({ref:H,className:""+j+(t?" "+t:"")},P))});K5.displayName="CodeMirror";var G5={npm_package_exports___require:"./dist/avocado-not-front.umd.js",npm_package_devDependencies__types_node:"20.2.5",npm_package_devDependencies__testing_library_jest_dom:"6.4.0",npm_config_user_agent:"pnpm/9.10.0 npm/? node/v20.17.0 linux x64",CI:"true",npm_package_devDependencies__testing_library_user_event:"14.5.2",npm_package_devDependencies_vite:"5.0.12",npm_node_execpath:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_publishConfig_access:"public",npm_package_files_0:"dist",HOME:"/home/runner",npm_package_dependencies_react_select_async_paginate:"0.7.3",npm_package_devDependencies_classnames:"2.3.2",npm_package_devDependencies_sass:"1.62.1",npm_config_auto_install_peers:"true",npm_package_devDependencies_vite_plugin_dts:"3.7.1",npm_package_dependencies__codemirror_lang_yaml:"6.1.2",npm_package_devDependencies_typescript:"5.1.3",npm_package_peerDependencies_react_select_async_paginate:"0.7.3",npm_package_types:"./dist/index.d.ts",npm_package_devDependencies__types_react_dom:"18.0.11",npm_package_devDependencies__vitejs_plugin_react_swc:"3.5.0",npm_package_type:"module",npm_package_dependencies_zustand:"4.5.4",npm_package_module:"./dist/avocado-not-front.es.js",npm_package_devDependencies__types_testing_library__jest_dom:"6.0.0",npm_package_dependencies__foris_avocado_icons:"workspace:*",npm_config_registry:"https://registry.npmjs.org/",npm_config_node_linker:"hoisted",npm_package_dependencies__codemirror_lang_json:"6.0.1",npm_package_exports___import:"./dist/avocado-not-front.es.js",npm_package_dependencies__foris_avocado_core:"workspace:*",npm_package_dependencies_axios:"^1.8.4",npm_config_node_gyp:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/avocado/avocado/packages/avocado-not-front/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/opt/hostedtoolcache/node/20.17.0/x64/bin:/home/runner/setup-pnpm/node_modules/.bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",TURBO_HASH:"9c19156cb8fbdb60",npm_package_name:"@foris/avocado-not-front",npm_package_scripts_start_stubby_examples:"stubby -d src/services/stubs/stubby-examples.yml -w -s 8300 -q",NODE:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_config_frozen_lockfile:"",npm_config_legacy_peer_deps:"true",LANG:"C.UTF-8",npm_package_dependencies_react_dom:"18.2.0",npm_package_main:"./dist/avocado-not-front.umd.js",npm_lifecycle_script:"tsc && vite build",npm_package_dependencies__uiw_react_codemirror:"4.23.12",NODE_PATH:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/node_modules",npm_package_version:"0.9.0",npm_package_devDependencies__testing_library_react:"14.2.0",npm_package_devDependencies__types_react:"18.0.28",npm_package_devDependencies_jsdom:"24.0.0",npm_lifecycle_event:"build",npm_package_scripts_build:"tsc && vite build",npm_package_dependencies__codemirror_lang_sql:"6.8.0",npm_package_dependencies__foris_avocado_suite:"workspace:*",npm_package_dependencies_jsonpath:"1.1.1",npm_package_devDependencies__foris_tsconfig:"workspace:*",npm_package_dependencies_react_select:"5.8.0",PWD:"/home/runner/work/avocado/avocado/packages/avocado-not-front",npm_execpath:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/pnpm.cjs",npm_package_devDependencies_stubby:"^5.1.0",npm_command:"run-script",PNPM_SCRIPT_SRC_DIR:"/home/runner/work/avocado/avocado/packages/avocado-not-front",npm_package_scripts_start_stubby:"stubby -d src/services/stubs/stubby-config.yml -w -s 8200 -q",npm_package_dependencies_react:"18.2.0",npm_package_peerDependencies_react_select:"5.8.0",INIT_CWD:"/home/runner/work/avocado/avocado/packages/avocado-not-front",NODE_ENV:"production"};class dc{constructor(e,t,n,i,s,o,a,l,c,u=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let i=e.parser.context;return new dc(e,[],t,n,n,0,[],0,i?new J5(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let a=s.dynamicPrecedence(i);if(a&&(this.score+=a),n==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(n-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((t=this.p.parser.nodeSet.types[i])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let h=l?this.stack[l-1]:0,d=this.bufferBase+this.buffer.length-h;if(i<s.minRepeatTerm||e&131072){let f=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,c,f,d+4,!0)}if(e&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=s.getGoto(f,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,c)}storeNode(e,t,n,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==n)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,i);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>n;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=i}}shift(e,t,n,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4);else{let s=e,{parser:o}=this.p;(i>this.pos||t<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,i,4)}}apply(e,t,n,i){e&65536?this.reduce(e):this.shift(e,t,n,i)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new dc(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new QL(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let i=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&i.push(t[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<t.length;s+=2){let o=t[s+1];i.some((a,l)=>l&1&&a==o)||i.push(t[s],o)}t=i}let n=[];for(let i=0;i<t.length&&n.length<4;i+=2){let s=t[i+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[i],this.pos),o.reducePos=this.pos,o.score-=200,n.push(o)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,i=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(i,s)=>{if(!t.includes(i))return t.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=n(o,s+1);if(a!=null)return a}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new J5(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class J5{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class QL{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}}class fc{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new fc(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new fc(this.stack,this.pos,this.index)}}function pc(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let n=0,i=0;n<r.length;){let s=0;for(;;){let o=r.charCodeAt(n++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[i++]=s:t=new e(s)}return t}class mc{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const e9=new mc;class qL{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=e9,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!i)return null;let o=this.ranges[--i];s-=n.from-o.to,n=o}for(;t<0?s>n.to:s>=n.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-n.to,n=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,i;if(t>=0&&t<this.chunk.length)n=this.pos+e,i=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(n=s,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=n;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-n)),i=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),i}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=e9,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let i of this.ranges){if(i.from>=t)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return n}}class ls{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;UL(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}ls.prototype.contextual=ls.prototype.fallback=ls.prototype.extend=!1,ls.prototype.fallback=ls.prototype.extend=!1;class Mo{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function UL(r,e,t,n,i,s){let o=0,a=1<<n,{dialect:l}=t.p.parser;e:for(;a&r[o];){let c=r[o+1];for(let f=o+3;f<c;f+=2)if((r[f+1]&a)>0){let p=r[f];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||zL(p,e.token.value,i,s))){e.acceptToken(p);break}}let u=e.next,h=0,d=r[o+2];if(e.next<0&&d>h&&r[c+d*3-3]==65535){o=r[c+d*3-1];continue e}for(;h<d;){let f=h+d>>1,p=c+f+(f<<1),g=r[p],m=r[p+1]||65536;if(u<g)d=f;else if(u>=m)h=f+1;else{o=r[p+2],e.advance();continue e}}break}}function t9(r,e,t){for(let n=e,i;(i=r[n])!=65535;n++)if(i==t)return n-e;return-1}function zL(r,e,t,n){let i=t9(t,n,e);return i<0||t9(t,n,r)<i}const Gt=typeof process<"u"&&G5&&/\bparse\b/.test(G5.LOG);let af=null;function n9(r,e,t){let n=r.cursor(ht.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(r.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:r.length}}class $L{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?n9(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?n9(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],i=this.index[t];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=n.children[i],o=this.start[t]+n.positions[i];if(o>e)return this.nextStart=o,null;if(s instanceof it){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(be.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class YL{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new mc)}getActions(e){let t=0,n=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<s.length;c++){if(!(1<<c&o))continue;let u=s[c],h=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||h.start!=e.pos||h.mask!=o||h.context!=a)&&(this.updateCachedToken(h,u,e),h.mask=o,h.context=a),h.lookAhead>h.end+25&&(l=Math.max(h.lookAhead,l)),h.value!=0)){let d=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!u.extend&&(n=h,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!n&&e.pos==this.stream.end&&(n=new mc,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new mc,{pos:n,p:i}=e;return t.start=n,t.end=Math.min(n+1,i.stream.end),t.value=n==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,n){let i=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(i,e),n),e.value>-1){let{parser:s}=n.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),n);if(a>=0&&n.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,n,i){for(let s=0;s<i;s+=3)if(this.actions[s]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=n,i}addActions(e,t,n,i){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let l=0;l<2;l++)for(let c=o.stateSlot(s,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=hr(a,c+2);else{i==0&&a[c+1]==2&&(i=this.putAction(hr(a,c+2),t,n,i));break}a[c]==t&&(i=this.putAction(hr(a,c+1),t,n,i))}return i}}class ZL{constructor(e,t,n,i){this.parser=e,this.input=t,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new qL(t,i),this.tokens=new YL(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[dc.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>e.bufferLength*4?new $L(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>t)n.push(a);else{if(this.advanceStack(a,n,e))continue;{i||(i=[],s=[]),i.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!n.length){let o=i&&GL(i);if(o)return Gt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Gt&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,n);if(o)return Gt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((a,l)=>l.score-a.score);n.length>o;)n.pop();n.some(a=>a.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o<n.length-1;o++){let a=n[o];for(let l=o+1;l<n.length;l++){let c=n[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)n.splice(l--,1);else{n.splice(o--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let o=1;o<n.length;o++)n[o].pos<this.minStackPos&&(this.minStackPos=n[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let i=e.pos,{parser:s}=this,o=Gt?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let h=this.fragments.nodeAt(i);h;){let d=this.parser.nodeSet.types[h.type.id]==h.type?s.getGoto(e.state,h.type.id):-1;if(d>-1&&h.length&&(!c||(h.prop(be.contextHash)||0)==u))return e.useNode(h,d),Gt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(h.type.id)})`),!0;if(!(h instanceof it)||h.children.length==0||h.positions[0]>0)break;let f=h.children[0];if(f instanceof it&&h.positions[0]==0)h=f;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),Gt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],h=l[c++],d=l[c++],f=c==l.length||!n,p=f?e:e.split(),g=this.tokens.mainToken;if(p.apply(u,h,g?g.start:p.pos,d),Gt&&console.log(o+this.stackID(p)+` (via ${u&65536?`reduce of ${s.getName(u&65535)}`:"shift"} for ${s.getName(h)} @ ${i}${p==e?"":", split"})`),f)return!0;p.pos>i?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return r9(e,t),!0}}runRecovery(e,t,n){let i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],l=t[o<<1],c=t[(o<<1)+1],u=Gt?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),Gt&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,n))))continue;let h=a.split(),d=u;for(let f=0;h.forceReduce()&&f<10&&(Gt&&console.log(d+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));f++)Gt&&(d=this.stackID(h)+" -> ");for(let f of a.recoverByInsert(l))Gt&&console.log(u+this.stackID(f)+" (via recover-insert)"),this.advanceFully(f,n);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),Gt&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),r9(a,n)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),it.build({buffer:fc.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(af||(af=new WeakMap)).get(e);return t||af.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function r9(r,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==r.pos&&n.sameState(r)){e[t].score<r.score&&(e[t]=r);return}}e.push(r)}class XL{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}const lf=r=>r;class KL{constructor(e){this.start=e.start,this.shift=e.shift||lf,this.reduce=e.reduce||lf,this.reuse=e.reuse||lf,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class gi extends Q6{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;a<e.repeatNodeCount;a++)t.push("");let n=Object.keys(e.topRules).map(a=>e.topRules[a][1]),i=[];for(let a=0;a<t.length;a++)i.push([]);function s(a,l,c){i[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=be[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)s(u,l,a[c++]);else{let h=a[c+-u];for(let d=-u;d>0;d--)s(a[c++],l,h);c++}}}this.nodeSet=new gd(t.map((a,l)=>Vt.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[l],top:n.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=I6;let o=pc(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(i9),this.states=pc(e.states,Uint32Array),this.data=pc(e.stateData),this.goto=pc(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new ls(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let i=new ZL(this,e,t,n);for(let s of this.wrappers)i=s(i,e,t,n);return i}getGoto(e,t,n=!1){let i=this.goto;if(t>=i[0])return-1;for(let s=i[t+1];;){let o=i[s++],a=o&1,l=i[s++];if(a&&n)return l;for(let c=s+(o>>1);s<c;s++)if(i[s]==e)return l;if(a)return-1}}hasAction(e,t){let n=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(e,i?2:1),o;;s+=3){if((o=n[s])==65535)if(n[s+1]==1)o=n[s=hr(n,s+2)];else{if(n[s+1]==2)return hr(n,s+2);break}if(o==t||o==0)return hr(n,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),i=n?t(n):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=hr(this.data,s+2);else break;i=t(hr(this.data,s+1))}return i}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=hr(this.data,n+2);else break;if(!(this.data[n+2]&1)){let i=this.data[n+1];t.some((s,o)=>o&1&&s==i)||t.push(this.data[n],i)}}return t}configure(e){let t=Object.assign(Object.create(gi.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let i=e.tokenizers.find(s=>s.from==n);return i?i.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,i)=>{let s=e.specializers.find(a=>a.from==n.external);if(!s)return n;let o=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[i]=i9(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(n[o]=!0)}let i=null;for(let s=0;s<t.length;s++)if(!n[s])for(let o=this.dialects[t[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new XL(e,n,i)}static deserialize(e){return new gi(e)}}function hr(r,e){return r[e]|r[e+1]<<16}function GL(r){let e=null;for(let t of r){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function i9(r){if(r.external){let e=r.extend?1:0;return(t,n)=>r.external(t,n)<<1|e}return r.get}const JL=po({String:T.string,Number:T.number,"True False":T.bool,PropertyName:T.propertyName,Null:T.null,", :":T.separator,"[ ]":T.squareBracket,"{ }":T.brace}),eN=gi.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[JL],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),tN=hi.define({name:"json",parser:eN.configure({props:[Wl.add({Object:Md({except:/^\s*\}/}),Array:Md({except:/^\s*\]/})}),Ql.add({"Object Array":e2})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function s9(){return new Od(tN)}const nN=36,o9=1,rN=2,cs=3,cf=4,iN=5,sN=6,oN=7,aN=8,lN=9,cN=10,uN=11,hN=12,dN=13,fN=14,pN=15,mN=16,gN=17,a9=18,yN=19,l9=20,c9=21,u9=22,vN=23,bN=24;function uf(r){return r>=65&&r<=90||r>=97&&r<=122||r>=48&&r<=57}function CN(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70}function yi(r,e,t){for(let n=!1;;){if(r.next<0)return;if(r.next==e&&!n){r.advance();return}n=t&&!n&&r.next==92,r.advance()}}function wN(r,e){e:for(;;){if(r.next<0)return;if(r.next==36){r.advance();for(let t=0;t<e.length;t++){if(r.next!=e.charCodeAt(t))continue e;r.advance()}if(r.next==36){r.advance();return}}else r.advance()}}function kN(r,e){let t="[{<(".indexOf(String.fromCharCode(e)),n=t<0?e:"]}>)".charCodeAt(t);for(;;){if(r.next<0)return;if(r.next==n&&r.peek(1)==39){r.advance(2);return}r.advance()}}function hf(r,e){for(;!(r.next!=95&&!uf(r.next));)e!=null&&(e+=String.fromCharCode(r.next)),r.advance();return e}function SN(r){if(r.next==39||r.next==34||r.next==96){let e=r.next;r.advance(),yi(r,e,!1)}else hf(r)}function h9(r,e){for(;r.next==48||r.next==49;)r.advance();e&&r.next==e&&r.advance()}function d9(r,e){for(;;){if(r.next==46){if(e)break;e=!0}else if(r.next<48||r.next>57)break;r.advance()}if(r.next==69||r.next==101)for(r.advance(),(r.next==43||r.next==45)&&r.advance();r.next>=48&&r.next<=57;)r.advance()}function f9(r){for(;!(r.next<0||r.next==10);)r.advance()}function vi(r,e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)==r)return!0;return!1}const df=` \r
590
+ `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new yR(this):new mR(this)}getCursor(e,t=0,n){let i=e.doc?e:we.create({doc:e});return n==null&&(n=i.doc.length),this.regexp?is(this,i,t,n):rs(this,i,t,n)}}class h5{constructor(e){this.spec=e}}function rs(r,e,t,n){return new es(e.doc,r.unquoted,t,n,r.caseSensitive?void 0:i=>i.toLowerCase(),r.wholeWord?pR(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function pR(r,e){return(t,n,i,s)=>((s>t||s+i.length<n)&&(s=Math.max(0,t-2),i=r.sliceString(s,Math.min(r.length,n+2))),(e(ec(i,t-s))!=ze.Word||e(tc(i,t-s))!=ze.Word)&&(e(tc(i,n-s))!=ze.Word||e(ec(i,n-s))!=ze.Word))}class mR extends h5{constructor(e){super(e)}nextMatch(e,t,n){let i=rs(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let s=Math.min(e.doc.length,t+this.spec.unquoted.length);i=rs(this.spec,e,0,s).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==n?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let s=Math.max(t,i-1e4-this.spec.unquoted.length),o=rs(this.spec,e,s,i),a=null;for(;!o.nextOverlapping().done;)a=o.value;if(a)return a;if(s==t)return null;i-=1e4}}prevMatch(e,t,n){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=t||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=rs(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let s=rs(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}function is(r,e,t,n){return new o5(e.doc,r.search,{ignoreCase:!r.caseSensitive,test:r.wholeWord?gR(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function ec(r,e){return r.slice(yt(r,e,!1),e)}function tc(r,e){return r.slice(e,yt(r,e))}function gR(r){return(e,t,n)=>!n[0].length||(r(ec(n.input,n.index))!=ze.Word||r(tc(n.input,n.index))!=ze.Word)&&(r(tc(n.input,n.index+n[0].length))!=ze.Word||r(ec(n.input,n.index+n[0].length))!=ze.Word)}class yR extends h5{nextMatch(e,t,n){let i=is(this.spec,e,n,e.doc.length).next();return i.done&&(i=is(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let s=Math.max(t,n-i*1e4),o=is(this.spec,e,s,n),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==t||a.from>s+10))return a;if(s==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let i=n.length;i>0;i--){let s=+n.slice(0,i);if(s>0&&s<e.match.length)return e.match[s]+n.slice(i)}return t})}matchAll(e,t){let n=is(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let s=is(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)i(s.value.from,s.value.to)}}const So=fe.define(),$d=fe.define(),Fr=vt.define({create(r){return new Yd(Xd(r).create(),null)},update(r,e){for(let t of e.effects)t.is(So)?r=new Yd(t.value.create(),r.panel):t.is($d)&&(r=new Yd(r.query,t.value?Zd:null));return r},provide:r=>uo.from(r,e=>e.panel)});class Yd{constructor(e,t){this.query=e,this.panel=t}}const vR=ie.mark({class:"cm-searchMatch"}),bR=ie.mark({class:"cm-searchMatch cm-searchMatch-selected"}),CR=tt.fromClass(class{constructor(r){this.view=r,this.decorations=this.highlight(r.state.field(Fr))}update(r){let e=r.state.field(Fr);(e!=r.startState.field(Fr)||r.docChanged||r.selectionSet||r.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:r,panel:e}){if(!e||!r.spec.valid)return ie.none;let{view:t}=this,n=new ir;for(let i=0,s=t.visibleRanges,o=s.length;i<o;i++){let{from:a,to:l}=s[i];for(;i<o-1&&l>s[i+1].from-2*250;)l=s[++i].to;r.highlight(t.state,a,l,(c,u)=>{let h=t.state.selection.ranges.some(d=>d.from==c&&d.to==u);n.add(c,u,h?bR:vR)})}return n.finish()}},{decorations:r=>r.decorations});function _o(r){return e=>{let t=e.state.field(Fr,!1);return t&&t.query.spec.valid?r(e,t):m5(e)}}const nc=_o((r,{query:e})=>{let{to:t}=r.state.selection.main,n=e.nextMatch(r.state,t,t);if(!n)return!1;let i=Q.single(n.from,n.to),s=r.state.facet(ns);return r.dispatch({selection:i,effects:[Kd(r,n),s.scrollToMatch(i.main,r)],userEvent:"select.search"}),p5(r),!0}),rc=_o((r,{query:e})=>{let{state:t}=r,{from:n}=t.selection.main,i=e.prevMatch(t,n,n);if(!i)return!1;let s=Q.single(i.from,i.to),o=r.state.facet(ns);return r.dispatch({selection:s,effects:[Kd(r,i),o.scrollToMatch(s.main,r)],userEvent:"select.search"}),p5(r),!0}),wR=_o((r,{query:e})=>{let t=e.matchAll(r.state,1e3);return!t||!t.length?!1:(r.dispatch({selection:Q.create(t.map(n=>Q.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),kR=({state:r,dispatch:e})=>{let t=r.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:i}=t.main,s=[],o=0;for(let a=new es(r.doc,r.sliceDoc(n,i));!a.next().done;){if(s.length>1e3)return!1;a.value.from==n&&(o=s.length),s.push(Q.range(a.value.from,a.value.to))}return e(r.update({selection:Q.create(s,o),userEvent:"select.search.matches"})),!0},d5=_o((r,{query:e})=>{let{state:t}=r,{from:n,to:i}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,n,n);if(!s)return!1;let o=s,a=[],l,c,u=[];if(o.from==n&&o.to==i&&(c=t.toText(e.getReplacement(o)),a.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),u.push(X.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))),o){let h=a.length==0||a[0].from>=s.to?0:s.to-s.from-c.length;l=Q.single(o.from-h,o.to-h),u.push(Kd(r,o)),u.push(t.facet(ns).scrollToMatch(l.main,r))}return r.dispatch({changes:a,selection:l,effects:u,userEvent:"input.replace"}),!0}),SR=_o((r,{query:e})=>{if(r.state.readOnly)return!1;let t=e.matchAll(r.state,1e9).map(i=>{let{from:s,to:o}=i;return{from:s,to:o,insert:e.getReplacement(i)}});if(!t.length)return!1;let n=r.state.phrase("replaced $ matches",t.length)+".";return r.dispatch({changes:t,effects:X.announce.of(n),userEvent:"input.replace.all"}),!0});function Zd(r){return r.state.facet(ns).createPanel(r)}function Xd(r,e){var t,n,i,s,o;let a=r.selection.main,l=a.empty||a.to>a.from+100?"":r.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=r.facet(ns);return new u5({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:c.literal,regexp:(s=e==null?void 0:e.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function f5(r){let e=co(r,Zd);return e&&e.dom.querySelector("[main-field]")}function p5(r){let e=f5(r);e&&e==r.root.activeElement&&e.select()}const m5=r=>{let e=r.state.field(Fr,!1);if(e&&e.panel){let t=f5(r);if(t&&t!=r.root.activeElement){let n=Xd(r.state,e.query.spec);n.valid&&r.dispatch({effects:So.of(n)}),t.focus(),t.select()}}else r.dispatch({effects:[$d.of(!0),e?So.of(Xd(r.state,e.query.spec)):fe.appendConfig.of(ER)]});return!0},g5=r=>{let e=r.state.field(Fr,!1);if(!e||!e.panel)return!1;let t=co(r,Zd);return t&&t.dom.contains(r.root.activeElement)&&r.focus(),r.dispatch({effects:$d.of(!1)}),!0},_R=[{key:"Mod-f",run:m5,scope:"editor search-panel"},{key:"F3",run:nc,shift:rc,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:nc,shift:rc,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:g5,scope:"editor search-panel"},{key:"Mod-Shift-l",run:kR},{key:"Mod-Alt-g",run:tR},{key:"Mod-d",run:fR,preventDefault:!0}];class xR{constructor(e){this.view=e;let t=this.query=e.state.field(Fr).query.spec;this.commit=this.commit.bind(this),this.searchField=je("input",{value:t.search,placeholder:Xt(e,"Find"),"aria-label":Xt(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=je("input",{value:t.replace,placeholder:Xt(e,"Replace"),"aria-label":Xt(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=je("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=je("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=je("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(i,s,o){return je("button",{class:"cm-button",name:i,onclick:s,type:"button"},o)}this.dom=je("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>nc(e),[Xt(e,"next")]),n("prev",()=>rc(e),[Xt(e,"previous")]),n("select",()=>wR(e),[Xt(e,"all")]),je("label",null,[this.caseField,Xt(e,"match case")]),je("label",null,[this.reField,Xt(e,"regexp")]),je("label",null,[this.wordField,Xt(e,"by word")]),...e.state.readOnly?[]:[je("br"),this.replaceField,n("replace",()=>d5(e),[Xt(e,"replace")]),n("replaceAll",()=>SR(e),[Xt(e,"replace all")])],je("button",{name:"close",onclick:()=>g5(e),"aria-label":Xt(e,"close"),type:"button"},["×"])])}commit(){let e=new u5({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:So.of(e)}))}keydown(e){FM(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?rc:nc)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),d5(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(So)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ns).top}}function Xt(r,e){return r.state.phrase(e)}const ic=30,sc=/[\s\.,:;?!]/;function Kd(r,{from:e,to:t}){let n=r.state.doc.lineAt(e),i=r.state.doc.lineAt(t).to,s=Math.max(n.from,e-ic),o=Math.min(i,t+ic),a=r.state.sliceDoc(s,o);if(s!=n.from){for(let l=0;l<ic;l++)if(!sc.test(a[l+1])&&sc.test(a[l])){a=a.slice(l);break}}if(o!=i){for(let l=a.length-1;l>a.length-ic;l--)if(!sc.test(a[l-1])&&sc.test(a[l])){a=a.slice(0,l);break}}return X.announce.of(`${r.state.phrase("current match")}. ${a} ${r.state.phrase("on line")} ${n.number}.`)}const OR=X.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ER=[Fr,ii.low(CR),OR];class y5{constructor(e,t,n,i){this.state=e,this.pos=t,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=dt(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),s=i.search(w5(e,!1));return s<0?null:{from:n+s,to:this.pos,text:i.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function v5(r){let e=Object.keys(r).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function DR(r){let e=Object.create(null),t=Object.create(null);for(let{label:i}of r){e[i[0]]=!0;for(let s=1;s<i.length;s++)t[i[s]]=!0}let n=v5(e)+v5(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function b5(r){let e=r.map(i=>typeof i=="string"?{label:i}:i),[t,n]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:DR(e);return i=>{let s=i.matchBefore(n);return s||i.explicit?{from:s?s.from:i.pos,options:e,validFor:t}:null}}function MR(r,e){return t=>{for(let n=dt(t.state).resolveInner(t.pos,-1);n;n=n.parent){if(r.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return e(t)}}class C5{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function fi(r){return r.selection.main.from}function w5(r,e){var t;let{source:n}=r,i=e&&n[0]!="^",s=n[n.length-1]!="$";return!i&&!s?r:new RegExp(`${i?"^":""}(?:${n})${s?"$":""}`,(t=r.flags)!==null&&t!==void 0?t:r.ignoreCase?"i":"")}const k5=Nn.define();function PR(r,e,t,n){let{main:i}=r.selection,s=t-i.from,o=n-i.from;return Object.assign(Object.assign({},r.changeByRange(a=>{if(a!=i&&t!=n&&r.sliceDoc(a.from+s,a.from+o)!=r.sliceDoc(t,n))return{range:a};let l=r.toText(e);return{changes:{from:a.from+s,to:n==i.from?a.to:a.from+o,insert:l},range:Q.cursor(a.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const S5=new WeakMap;function TR(r){if(!Array.isArray(r))return r;let e=S5.get(r);return e||S5.set(r,e=b5(r)),e}const oc=fe.define(),xo=fe.define();class AR{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Bt(e,t),i=Rn(n);this.chars.push(n);let s=e.slice(t,t+i),o=s.toUpperCase();this.folded.push(Bt(o==s?s.toLowerCase():o,0)),t+=i}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:s,byWord:o}=this;if(t.length==1){let _=Bt(e,0),k=Rn(_),C=k==e.length?0:-100;if(_!=t[0])if(_==n[0])C+=-200;else return null;return this.ret(C,[0,k])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,c=0;if(a<0){for(let _=0,k=Math.min(e.length,200);_<k&&c<l;){let C=Bt(e,_);(C==t[c]||C==n[c])&&(i[c++]=_),_+=Rn(C)}if(c<l)return null}let u=0,h=0,d=!1,f=0,p=-1,g=-1,m=/[a-z]/.test(e),b=!0;for(let _=0,k=Math.min(e.length,200),C=0;_<k&&h<l;){let v=Bt(e,_);a<0&&(u<l&&v==t[u]&&(s[u++]=_),f<l&&(v==t[f]||v==n[f]?(f==0&&(p=_),g=_+1,f++):f=0));let x,S=v<255?v>=48&&v<=57||v>=97&&v<=122?2:v>=65&&v<=90?1:0:(x=oh(v))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!_||S==1&&m||C==0&&S!=0)&&(t[h]==v||n[h]==v&&(d=!0)?o[h++]=_:o.length&&(b=!1)),C=S,_+=Rn(v)}return h==l&&o[0]==0&&b?this.result(-100+(d?-200:0),o,e):f==l&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):f==l?this.ret(-900-e.length,[p,g]):h==l?this.result(-100+(d?-200:0)+-700+(b?0:-1100),o,e):t.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,n){let i=[],s=0;for(let o of t){let a=o+(this.astral?Rn(Bt(n,o)):1);s&&i[s-1]==o?i[s-1]=a:(i[s++]=o,i[s++]=a)}return this.ret(e-n.length,i)}}class RR{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const ft=J.define({combine(r){return In(r,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:LR,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>_5(e(n),t(n)),optionClass:(e,t)=>n=>_5(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function _5(r,e){return r?e?r+" "+e:r:e}function LR(r,e,t,n,i,s){let o=r.textDirection==Qe.RTL,a=o,l=!1,c="top",u,h,d=e.left-i.left,f=i.right-e.right,p=n.right-n.left,g=n.bottom-n.top;if(a&&d<Math.min(p,f)?a=!1:!a&&f<Math.min(p,d)&&(a=!0),p<=(a?d:f))u=Math.max(i.top,Math.min(t.top,i.bottom-g))-e.top,h=Math.min(400,a?d:f);else{l=!0,h=Math.min(400,(o?e.right:i.right-e.left)-30);let _=i.bottom-e.bottom;_>=g||_>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let m=(e.bottom-e.top)/s.offsetHeight,b=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${u/m}px; max-width: ${h/b}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}function NR(r){let e=r.addToOptions.slice();return r.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,i,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;c<s.length;){let u=s[c++],h=s[c++];u>l&&o.appendChild(document.createTextNode(a.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(a.slice(u,h))),d.className="cm-completionMatchedText",l=h}return l<a.length&&o.appendChild(document.createTextNode(a.slice(l))),o},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function Gd(r,e,t){if(r<=t)return{from:0,to:r};if(e<0&&(e=0),e<=r>>1){let i=Math.floor(e/t);return{from:i*t,to:(i+1)*t}}let n=Math.floor((r-e)/t);return{from:r-(n+1)*t,to:r-n*t}}class IR{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:s,selected:o}=i.open,a=e.state.facet(ft);this.optionContent=NR(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=Gd(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,h;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(h=/-(\d+)$/.exec(u.id))&&+h[1]<c.length){this.applyCompletion(e,c[+h[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(ft).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:xo.of(null)})}),this.showOptions(s,i.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:s,selected:o,disabled:a}=n.open;(!i.open||i.open.options!=s)&&(this.range=Gd(s.length,o,e.state.facet(ft).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),a!=((t=i.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Gd(t.options.length,t.selected,this.view.state.facet(ft).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let s=typeof i=="string"?document.createTextNode(i):i(n);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,n)}).catch(o=>Ft(this.view.state,o,"completion info")):this.addInfoPane(s,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:s}=e;n.appendChild(i),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)n.nodeName!="LI"||!n.id?i--:i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&HR(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(s.bottom,t.bottom)-10||i.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(ft).positionInfo(this.view,t,i,n,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let s=null;for(let o=n.from;o<n.to;o++){let{completion:a,match:l}=e[o],{section:c}=a;if(c){let d=typeof c=="string"?c:c.name;if(d!=s&&(o>n.from||n.from==0))if(s=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let h=this.optionClass(a);h&&(u.className=h);for(let d of this.optionContent){let f=d(a,this.view.state,this.view,l);f&&u.appendChild(f)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function BR(r,e){return t=>new IR(t,r,e)}function HR(r,e){let t=r.getBoundingClientRect(),n=e.getBoundingClientRect(),i=t.height/r.offsetHeight;n.top<t.top?r.scrollTop-=(t.top-n.top)/i:n.bottom>t.bottom&&(r.scrollTop+=(n.bottom-t.bottom)/i)}function x5(r){return(r.boost||0)*100+(r.apply?10:0)+(r.info?5:0)+(r.type?1:0)}function FR(r,e){let t=[],n=null,i=c=>{t.push(c);let{section:u}=c.completion;if(u){n||(n=[]);let h=typeof u=="string"?u:u.name;n.some(d=>d.name==h)||n.push(typeof u=="string"?{name:h}:u)}},s=e.facet(ft);for(let c of r)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let h of c.result.options)i(new C5(h,c.source,u?u(h):[],1e9-t.length));else{let h=e.sliceDoc(c.from,c.to),d,f=s.filterStrict?new RR(h):new AR(h);for(let p of c.result.options)if(d=f.match(p.label)){let g=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new C5(p,c.source,g,d.score+(p.boost||0)))}}}if(n){let c=Object.create(null),u=0,h=(d,f)=>{var p,g;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((g=f.rank)!==null&&g!==void 0?g:1e9)||(d.name<f.name?-1:1)};for(let d of n.sort(h))u-=1e5,c[d.name]=u;for(let d of t){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.name])}}let o=[],a=null,l=s.compareCompletions;for(let c of t.sort((u,h)=>h.score-u.score||l(u.completion,h.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?o.push(c):x5(c.completion)>x5(a)&&(o[o.length-1]=c),a=c.completion}return o}class ss{constructor(e,t,n,i,s,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new ss(this.options,O5(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,s,o){if(i&&!o&&e.some(c=>c.isPending))return i.setDisabled();let a=FR(e,t);if(!a.length)return i&&e.some(c=>c.isPending)?i.setDisabled():null;let l=t.facet(ft).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}}return new ss(a,O5(n,l),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:UR,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(e){return new ss(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new ss(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ac{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new ac(QR,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(ft),s=(n.override||t.languageDataAt("autocomplete",fi(t)).map(TR)).map(l=>(this.active.find(u=>u.source==l)||new ln(l,this.active.some(u=>u.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let o=this.open,a=e.effects.some(l=>l.is(Jd));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!VR(s,this.active)||a?o=ss.build(s,t,this.id,o,n,a):o&&o.disabled&&!s.some(l=>l.isPending)&&(o=null),!o&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new ln(l.source,0):l));for(let l of e.effects)l.is(D5)&&(o=o&&o.setSelected(l.value,this.id));return s==this.active&&o==this.open?this:new ac(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?jR:WR}}function VR(r,e){if(r==e)return!0;for(let t=0,n=0;;){for(;t<r.length&&!r[t].hasResult();)t++;for(;n<e.length&&!e[n].hasResult();)n++;let i=t==r.length,s=n==e.length;if(i||s)return i==s;if(r[t++].result!=e[n++].result)return!1}}const jR={"aria-autocomplete":"list"},WR={};function O5(r,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":r};return e>-1&&(t["aria-activedescendant"]=r+"-"+e),t}const QR=[];function E5(r,e){if(r.isUserEvent("input.complete")){let n=r.annotation(k5);if(n&&e.activateOnCompletion(n))return 12}let t=r.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:r.isUserEvent("delete.backward")?2:r.selection?8:r.docChanged?16:0}class ln{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=E5(e,t),i=this;(n&8||n&16&&this.touches(e))&&(i=new ln(i.source,0)),n&4&&i.state==0&&(i=new ln(this.source,1)),i=i.updateFor(e,n);for(let s of e.effects)if(s.is(oc))i=new ln(i.source,1,s.value);else if(s.is(xo))i=new ln(i.source,0);else if(s.is(Jd))for(let o of s.value)o.source==i.source&&(i=o);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(fi(e.state))}}class os extends ln{constructor(e,t,n,i,s,o){super(e,3,t),this.limit=n,this.result=i,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),a=fi(e.state);if(a>o||!i||t&2&&(fi(e.startState)==this.from||a<this.limit))return new ln(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return qR(i.validFor,e.state,s,o)?new os(this.source,this.explicit,l,i,s,o):i.update&&(i=i.update(i,s,o,new y5(e.state,a,!1)))?new os(this.source,this.explicit,l,i,i.from,(n=i.to)!==null&&n!==void 0?n:fi(e.state)):new ln(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new os(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new ln(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function qR(r,e,t,n){if(!r)return!1;let i=e.sliceDoc(t,n);return typeof r=="function"?r(i,t,n,e):w5(r,!0).test(i)}const Jd=fe.define({map(r,e){return r.map(t=>t.map(e))}}),D5=fe.define(),Wt=vt.define({create(){return ac.start()},update(r,e){return r.update(e)},provide:r=>[hd.from(r,e=>e.tooltip),X.contentAttributes.from(r,e=>e.attrs)]});function ef(r,e){const t=e.completion.apply||e.completion.label;let n=r.state.field(Wt).active.find(i=>i.source==e.source);return n instanceof os?(typeof t=="string"?r.dispatch(Object.assign(Object.assign({},PR(r.state,t,n.from,n.to)),{annotations:k5.of(e.completion)})):t(r,e.completion,n.from,n.to),!0):!1}const UR=BR(Wt,ef);function lc(r,e="option"){return t=>{let n=t.state.field(Wt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(ft).interactionDelay)return!1;let i=1,s;e=="page"&&(s=O6(t,n.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,a=n.open.selected>-1?n.open.selected+i*(r?1:-1):r?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:D5.of(a)}),!0}}const zR=r=>{let e=r.state.field(Wt,!1);return r.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<r.state.facet(ft).interactionDelay?!1:ef(r,e.open.options[e.open.selected])},M5=r=>r.state.field(Wt,!1)?(r.dispatch({effects:oc.of(!0)}),!0):!1,$R=r=>{let e=r.state.field(Wt,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(r.dispatch({effects:xo.of(null)}),!0)};class YR{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const ZR=50,XR=1e3,KR=tt.fromClass(class{constructor(r){this.view=r,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of r.state.field(Wt).active)e.isPending&&this.startQuery(e)}update(r){let e=r.state.field(Wt),t=r.state.facet(ft);if(!r.selectionSet&&!r.docChanged&&r.startState.field(Wt)==e)return;let n=r.transactions.some(s=>{let o=E5(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(n||o.context.abortOnDocChange&&r.docChanged||o.updates.length+r.transactions.length>ZR&&Date.now()-o.time>XR){for(let a of o.context.abortListeners)try{a()}catch(l){Ft(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...r.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),r.transactions.some(s=>s.effects.some(o=>o.is(oc)))&&(this.pendingStart=!0);let i=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of r.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:r}=this.view,e=r.field(Wt);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ft).updateSyncTime))}startQuery(r){let{state:e}=this.view,t=fi(e),n=new y5(e,t,r.explicit,this.view),i=new YR(r,n);this.running.push(i),Promise.resolve(r.source(n)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:xo.of(null)}),Ft(this.view.state,s)})}scheduleAccept(){this.running.every(r=>r.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ft).updateSyncTime))}accept(){var r;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ft),n=this.view.state.field(Wt);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let a=fi(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(a,s.done.from+(s.active.explicit?0:1)),c=new os(s.active.source,s.active.explicit,l,s.done,s.done.from,(r=s.done.to)!==null&&r!==void 0?r:a);for(let u of s.updates)c=c.update(u,t);if(c.hasResult()){e.push(c);continue}}let o=n.active.find(a=>a.source==s.active.source);if(o&&o.isPending)if(s.done==null){let a=new ln(s.active.source,0);for(let l of s.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:Jd.of(e)})}},{eventHandlers:{blur(r){let e=this.view.state.field(Wt,!1);if(e&&e.tooltip&&this.view.state.facet(ft).closeOnBlur){let t=e.open&&O6(this.view,e.open.tooltip);(!t||!t.dom.contains(r.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:xo.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:oc.of(!1)}),20),this.composing=0}}}),GR=typeof navigator=="object"&&/Win/.test(navigator.platform),JR=ii.highest(X.domEventHandlers({keydown(r,e){let t=e.state.field(Wt,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||r.key.length>1||r.ctrlKey&&!(GR&&r.altKey)||r.metaKey)return!1;let n=t.open.options[t.open.selected],i=t.active.find(o=>o.source==n.source),s=n.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(r.key)>-1&&ef(e,n),!1}})),eL=X.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Oo={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},pi=fe.define({map(r,e){let t=e.mapPos(r,-1,Tt.TrackAfter);return t??void 0}}),tf=new class extends si{};tf.startSide=1,tf.endSide=-1;const P5=vt.define({create(){return Oe.empty},update(r,e){if(r=r.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);r=r.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(pi)&&(r=r.update({add:[tf.range(t.value,t.value+1)]}));return r}});function tL(){return[rL,P5]}const nf="()[]{}<>«»»«[]{}";function T5(r){for(let e=0;e<nf.length;e+=2)if(nf.charCodeAt(e)==r)return nf.charAt(e+1);return oh(r<128?r:r+1)}function A5(r,e){return r.languageDataAt("closeBrackets",e)[0]||Oo}const nL=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),rL=X.inputHandler.of((r,e,t,n)=>{if((nL?r.composing:r.compositionStarted)||r.state.readOnly)return!1;let i=r.state.selection.main;if(n.length>2||n.length==2&&Rn(Bt(n,0))==1||e!=i.from||t!=i.to)return!1;let s=sL(r.state,n);return s?(r.dispatch(s),!0):!1}),iL=[{key:"Backspace",run:({state:r,dispatch:e})=>{if(r.readOnly)return!1;let n=A5(r,r.selection.main.head).brackets||Oo.brackets,i=null,s=r.changeByRange(o=>{if(o.empty){let a=oL(r.doc,o.head);for(let l of n)if(l==a&&cc(r.doc,o.head)==T5(Bt(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Q.cursor(o.head-l.length)}}return{range:i=o}});return i||e(r.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function sL(r,e){let t=A5(r,r.selection.main.head),n=t.brackets||Oo.brackets;for(let i of n){let s=T5(Bt(i,0));if(e==i)return s==i?cL(r,i,n.indexOf(i+i+i)>-1,t):aL(r,i,s,t.before||Oo.before);if(e==s&&R5(r,r.selection.main.from))return lL(r,i,s)}return null}function R5(r,e){let t=!1;return r.field(P5).between(0,r.doc.length,n=>{n==e&&(t=!0)}),t}function cc(r,e){let t=r.sliceString(e,e+2);return t.slice(0,Rn(Bt(t,0)))}function oL(r,e){let t=r.sliceString(e-2,e);return Rn(Bt(t,0))==t.length?t:t.slice(1)}function aL(r,e,t,n){let i=null,s=r.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:pi.of(o.to+e.length),range:Q.range(o.anchor+e.length,o.head+e.length)};let a=cc(r.doc,o.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:pi.of(o.head+e.length),range:Q.cursor(o.head+e.length)}:{range:i=o}});return i?null:r.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function lL(r,e,t){let n=null,i=r.changeByRange(s=>s.empty&&cc(r.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:Q.cursor(s.head+t.length)}:n={range:s});return n?null:r.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function cL(r,e,t,n){let i=n.stringPrefixes||Oo.stringPrefixes,s=null,o=r.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:pi.of(a.to+e.length),range:Q.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=cc(r.doc,l),u;if(c==e){if(L5(r,l))return{changes:{insert:e+e,from:l},effects:pi.of(l+e.length),range:Q.cursor(l+e.length)};if(R5(r,l)){let d=t&&r.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+d.length,insert:d},range:Q.cursor(l+d.length)}}}else{if(t&&r.sliceDoc(l-2*e.length,l)==e+e&&(u=N5(r,l-2*e.length,i))>-1&&L5(r,u))return{changes:{insert:e+e+e+e,from:l},effects:pi.of(l+e.length),range:Q.cursor(l+e.length)};if(r.charCategorizer(l)(c)!=ze.Word&&N5(r,l,i)>-1&&!uL(r,l,e,i))return{changes:{insert:e+e,from:l},effects:pi.of(l+e.length),range:Q.cursor(l+e.length)}}return{range:s=a}});return s?null:r.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function L5(r,e){let t=dt(r).resolveInner(e+1);return t.parent&&t.from==e}function uL(r,e,t,n){let i=dt(r).resolveInner(e,-1),s=n.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=r.sliceDoc(i.from,Math.min(i.to,i.from+t.length+s)),l=a.indexOf(t);if(!l||l>-1&&n.indexOf(a.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>t.length+l;){if(r.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function N5(r,e,t){let n=r.charCategorizer(e);if(n(r.sliceDoc(e-1,e))!=ze.Word)return e;for(let i of t){let s=e-i.length;if(r.sliceDoc(s,e)==i&&n(r.sliceDoc(s-1,s))!=ze.Word)return s}return-1}function hL(r={}){return[JR,Wt,ft.of(r),KR,dL,eL]}const I5=[{key:"Ctrl-Space",run:M5},{mac:"Alt-`",run:M5},{key:"Escape",run:$R},{key:"ArrowDown",run:lc(!0)},{key:"ArrowUp",run:lc(!1)},{key:"PageDown",run:lc(!0,"page")},{key:"PageUp",run:lc(!1,"page")},{key:"Enter",run:zR}],dL=ii.highest(kl.computeN([ft],r=>r.facet(ft).defaultKeymap?[I5]:[]));class B5{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class mi{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let i=n.facet(Eo).markerFilter;i&&(e=i(e,n));let s=e.slice().sort((u,h)=>u.from-h.from||u.to-h.to),o=new ir,a=[],l=0;for(let u=0;;){let h=u==s.length?null:s[u];if(!h&&!a.length)break;let d,f;for(a.length?(d=l,f=a.reduce((g,m)=>Math.min(g,m.to),h&&h.from>d?h.from:1e8)):(d=h.from,f=h.to,a.push(h),u++);u<s.length;){let g=s[u];if(g.from==d&&(g.to>g.from||g.to==d))a.push(g),u++,f=Math.min(g.to,f);else{f=Math.min(g.from,f);break}}let p=_L(a);if(a.some(g=>g.from==g.to||g.from==g.to-1&&n.doc.lineAt(g.from).to==g.from))o.add(d,d,ie.widget({widget:new CL(p),diagnostics:a.slice()}));else{let g=a.reduce((m,b)=>b.markClass?m+" "+b.markClass:m,"");o.add(d,f,ie.mark({class:"cm-lintRange cm-lintRange-"+p+g,diagnostics:a.slice(),inclusiveEnd:a.some(m=>m.to>f)}))}l=f;for(let g=0;g<a.length;g++)a[g].to<=l&&a.splice(g--,1)}let c=o.finish();return new mi(c,t,as(c))}}function as(r,e=null,t=0){let n=null;return r.between(t,1e9,(i,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!n)n=new B5(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new B5(n.from,s,n.diagnostic)}}),n}function fL(r,e){let t=e.pos,n=e.end||t,i=r.state.facet(Eo).hideOn(r,t,n);if(i!=null)return i;let s=r.startState.doc.lineAt(e.pos);return!!(r.effects.some(o=>o.is(H5))||r.changes.touchesRange(s.from,Math.max(s.to,n)))}function pL(r,e){return r.field(Kt,!1)?e:e.concat(fe.appendConfig.of(xL))}const H5=fe.define(),rf=fe.define(),F5=fe.define(),Kt=vt.define({create(){return new mi(ie.none,null,null)},update(r,e){if(e.docChanged&&r.diagnostics.size){let t=r.diagnostics.map(e.changes),n=null,i=r.panel;if(r.selected){let s=e.changes.mapPos(r.selected.from,1);n=as(t,r.selected.diagnostic,s)||as(t,null,s)}!t.size&&i&&e.state.facet(Eo).autoPanel&&(i=null),r=new mi(t,i,n)}for(let t of e.effects)if(t.is(H5)){let n=e.state.facet(Eo).autoPanel?t.value.length?Do.open:null:r.panel;r=mi.init(t.value,n,e.state)}else t.is(rf)?r=new mi(r.diagnostics,t.value?Do.open:null,r.selected):t.is(F5)&&(r=new mi(r.diagnostics,r.panel,t.value));return r},provide:r=>[uo.from(r,e=>e.panel),X.decorations.from(r,e=>e.diagnostics)]}),mL=ie.mark({class:"cm-lintRange cm-lintRange-active"});function gL(r,e,t){let{diagnostics:n}=r.state.field(Kt),i,s=-1,o=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(e<c||t<0)))return i=u.diagnostics,s=l,o=c,!1});let a=r.state.facet(Eo).tooltipFilter;return i&&a&&(i=a(i,r.state)),i?{pos:s,end:o,above:r.state.doc.lineAt(s).to<o,create(){return{dom:yL(r,i)}}}:null}function yL(r,e){return je("ul",{class:"cm-tooltip-lint"},e.map(t=>W5(r,t,!1)))}const vL=r=>{let e=r.state.field(Kt,!1);(!e||!e.panel)&&r.dispatch({effects:pL(r.state,[rf.of(!0)])});let t=co(r,Do.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},V5=r=>{let e=r.state.field(Kt,!1);return!e||!e.panel?!1:(r.dispatch({effects:rf.of(!1)}),!0)},bL=[{key:"Mod-Shift-m",run:vL,preventDefault:!0},{key:"F8",run:r=>{let e=r.state.field(Kt,!1);if(!e)return!1;let t=r.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(r.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)}}],Eo=J.define({combine(r){return Object.assign({sources:r.map(e=>e.source).filter(e=>e!=null)},In(r.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))}});function j5(r){let e=[];if(r)e:for(let{name:t}of r){for(let n=0;n<t.length;n++){let i=t[n];if(/[a-zA-Z]/.test(i)&&!e.some(s=>s.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function W5(r,e,t){var n;let i=t?j5(e.actions):[];return je("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},je("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(r):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let f=as(r.state.field(Kt).diagnostics,e);f&&s.apply(r,f.from,f.to)},{name:c}=s,u=i[o]?c.indexOf(i[o]):-1,h=u<0?c:[c.slice(0,u),je("u",c.slice(u,u+1)),c.slice(u+1)];return je("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${i[o]})"`}.`},h)}),e.source&&je("div",{class:"cm-diagnosticSource"},e.source))}class CL extends or{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return je("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Q5{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=W5(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Do{constructor(e){this.view=e,this.items=[];let t=i=>{if(i.keyCode==27)V5(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=j5(s.actions);for(let a=0;a<o.length;a++)if(o[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=as(this.view.state.field(Kt).diagnostics,s);l&&s.actions[a].apply(e,l.from,l.to)}}else return;i.preventDefault()},n=i=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(i.target)&&this.moveSelection(s)};this.list=je("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=je("div",{class:"cm-panel-lint"},this.list,je("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>V5(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Kt).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Kt),n=0,i=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let u of c.diagnostics){if(o.has(u))continue;o.add(u);let h=-1,d;for(let f=n;f<this.items.length;f++)if(this.items[f].diagnostic==u){h=f;break}h<0?(d=new Q5(this.view,u),this.items.splice(n,0,d),i=!0):(d=this.items[h],h>n&&(this.items.splice(n,h-n),i=!0)),t&&d.diagnostic==t.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new Q5(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Kt),n=as(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:F5.of(n)})}static open(e){return new Do(e)}}function wL(r,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(r)}</svg>')`}function uc(r){return wL(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${r}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const kL=X.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:uc("#d11")},".cm-lintRange-warning":{backgroundImage:uc("orange")},".cm-lintRange-info":{backgroundImage:uc("#999")},".cm-lintRange-hint":{backgroundImage:uc("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function SL(r){return r=="error"?4:r=="warning"?3:r=="info"?2:1}function _L(r){let e="hint",t=1;for(let n of r){let i=SL(n.severity);i>t&&(t=i,e=n.severity)}return e}const xL=[Kt,X.decorations.compute([Kt],r=>{let{selected:e,panel:t}=r.field(Kt);return!e||!t||e.from==e.to?ie.none:ie.set([mL.range(e.from,e.to)])}),EP(gL,{hideOn:fL}),kL];var q5=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(iL)),e.defaultKeymap!==!1&&(n=n.concat(GA)),e.searchKeymap!==!1&&(n=n.concat(_R)),e.historyKeymap!==!1&&(n=n.concat(aA)),e.foldKeymap!==!1&&(n=n.concat(kT)),e.completionKeymap!==!1&&(n=n.concat(I5)),e.lintKeymap!==!1&&(n=n.concat(bL));var i=[];return e.lineNumbers!==!1&&i.push(HP()),e.highlightActiveLineGutter!==!1&&i.push(jP()),e.highlightSpecialChars!==!1&&i.push(nP()),e.history!==!1&&i.push(GT()),e.foldGutter!==!1&&i.push(OT()),e.drawSelection!==!1&&i.push(UM()),e.dropCursor!==!1&&i.push(XM()),e.allowMultipleSelections!==!1&&i.push(we.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(mT()),e.syntaxHighlighting!==!1&&i.push(u2(PT,{fallback:!0})),e.bracketMatching!==!1&&i.push(IT()),e.closeBrackets!==!1&&i.push(tL()),e.autocompletion!==!1&&i.push(hL()),e.rectangularSelection!==!1&&i.push(gP()),t!==!1&&i.push(bP()),e.highlightActiveLine!==!1&&i.push(lP()),e.highlightSelectionMatches!==!1&&i.push(sR()),e.tabSize&&typeof e.tabSize=="number"&&i.push(Fl.of(" ".repeat(e.tabSize))),i.concat([kl.of(n.flat())]).filter(Boolean)};const OL="#e5c07b",U5="#e06c75",EL="#56b6c2",DL="#ffffff",hc="#abb2bf",sf="#7d8799",ML="#61afef",PL="#98c379",z5="#d19a66",TL="#c678dd",AL="#21252b",$5="#2c313a",Y5="#282c34",of="#353a42",RL="#3E4451",Z5="#528bff",LL=X.theme({"&":{color:hc,backgroundColor:Y5},".cm-content":{caretColor:Z5},".cm-cursor, .cm-dropCursor":{borderLeftColor:Z5},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:RL},".cm-panels":{backgroundColor:AL,color:hc},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Y5,color:sf,border:"none"},".cm-activeLineGutter":{backgroundColor:$5},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:of},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:of,borderBottomColor:of},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:$5,color:hc}}},{dark:!0}),NL=bo.define([{tag:T.keyword,color:TL},{tag:[T.name,T.deleted,T.character,T.propertyName,T.macroName],color:U5},{tag:[T.function(T.variableName),T.labelName],color:ML},{tag:[T.color,T.constant(T.name),T.standard(T.name)],color:z5},{tag:[T.definition(T.name),T.separator],color:hc},{tag:[T.typeName,T.className,T.number,T.changed,T.annotation,T.modifier,T.self,T.namespace],color:OL},{tag:[T.operator,T.operatorKeyword,T.url,T.escape,T.regexp,T.link,T.special(T.string)],color:EL},{tag:[T.meta,T.comment],color:sf},{tag:T.strong,fontWeight:"bold"},{tag:T.emphasis,fontStyle:"italic"},{tag:T.strikethrough,textDecoration:"line-through"},{tag:T.link,color:sf,textDecoration:"underline"},{tag:T.heading,fontWeight:"bold",color:U5},{tag:[T.atom,T.bool,T.special(T.variableName)],color:z5},{tag:[T.processingInstruction,T.string,T.inserted],color:PL},{tag:T.invalid,color:DL}]),IL=[LL,u2(NL)];var BL=X.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),HL=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:i=!1,theme:s="light",placeholder:o="",basicSetup:a=!0}=e,l=[];switch(t&&l.unshift(kl.of([JA])),a&&(typeof a=="boolean"?l.unshift(q5()):l.unshift(q5(a))),o&&l.unshift(dP(o)),s){case"light":l.push(BL);break;case"dark":l.push(IL);break;case"none":break;default:l.push(s);break}return n===!1&&l.push(X.editable.of(!1)),i&&l.push(we.readOnly.of(!0)),[...l]},FL=r=>({line:r.state.doc.lineAt(r.state.selection.main.from),lineCount:r.state.doc.lines,lineBreak:r.state.lineBreak,length:r.state.doc.length,readOnly:r.state.readOnly,tabSize:r.state.tabSize,selection:r.state.selection,selectionAsSingle:r.state.selection.asSingle().main,ranges:r.state.selection.ranges,selectionCode:r.state.sliceDoc(r.state.selection.main.from,r.state.selection.main.to),selections:r.state.selection.ranges.map(e=>r.state.sliceDoc(e.from,e.to)),selectedText:r.state.selection.ranges.some(e=>!e.empty)}),X5=Nn.define(),VL=[];function jL(r){var{value:e,selection:t,onChange:n,onStatistics:i,onCreateEditor:s,onUpdate:o,extensions:a=VL,autoFocus:l,theme:c="light",height:u=null,minHeight:h=null,maxHeight:d=null,width:f=null,minWidth:p=null,maxWidth:g=null,placeholder:m="",editable:b=!0,readOnly:_=!1,indentWithTab:k=!0,basicSetup:C=!0,root:v,initialState:x}=r,[S,D]=O.useState(),[P,F]=O.useState(),[A,N]=O.useState(),B=X.theme({"&":{height:u,minHeight:h,maxHeight:d,width:f,minWidth:p,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),L=X.updateListener.of(q=>{if(q.docChanged&&typeof n=="function"&&!q.transactions.some(he=>he.annotation(X5))){var $=q.state.doc,re=$.toString();n(re,q)}i&&i(FL(q))}),H=HL({theme:c,editable:b,readOnly:_,placeholder:m,indentWithTab:k,basicSetup:C}),j=[L,B,...H];return o&&typeof o=="function"&&j.push(X.updateListener.of(o)),j=j.concat(a),O.useLayoutEffect(()=>{if(S&&!A){var q={doc:e,selection:t,extensions:j},$=x?we.fromJSON(x.json,q,x.fields):we.create(q);if(N($),!P){var re=new X({state:$,parent:S,root:v});F(re),s&&s(re,$)}}return()=>{P&&(N(void 0),F(void 0))}},[S,A]),O.useEffect(()=>{r.container&&D(r.container)},[r.container]),O.useEffect(()=>()=>{P&&(P.destroy(),F(void 0))},[P]),O.useEffect(()=>{l&&P&&P.focus()},[l,P]),O.useEffect(()=>{P&&P.dispatch({effects:fe.reconfigure.of(j)})},[c,a,u,h,d,f,p,g,m,b,_,k,C,n,o]),O.useEffect(()=>{if(e!==void 0){var q=P?P.state.doc.toString():"";P&&e!==q&&P.dispatch({changes:{from:0,to:q.length,insert:e||""},annotations:[X5.of(!0)]})}},[e,P]),{state:A,setState:N,view:P,setView:F,container:S,setContainer:D}}var WL=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],K5=O.forwardRef((r,e)=>{var{className:t,value:n="",selection:i,extensions:s=[],onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:c,autoFocus:u,theme:h="light",height:d,minHeight:f,maxHeight:p,width:g,minWidth:m,maxWidth:b,basicSetup:_,placeholder:k,indentWithTab:C,editable:v,readOnly:x,root:S,initialState:D}=r,P=jE(r,WL),F=O.useRef(null),{state:A,view:N,container:B,setContainer:L}=jL({root:S,value:n,autoFocus:u,theme:h,height:d,minHeight:f,maxHeight:p,width:g,minWidth:m,maxWidth:b,basicSetup:_,placeholder:k,indentWithTab:C,editable:v,readOnly:x,selection:i,onChange:o,onStatistics:a,onCreateEditor:l,onUpdate:c,extensions:s,initialState:D});O.useImperativeHandle(e,()=>({editor:F.current,state:A,view:N}),[F,B,A,N]);var H=O.useCallback(q=>{F.current=q,L(q)},[L]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var j=typeof h=="string"?"cm-theme-"+h:"cm-theme";return me.jsx("div",rh({ref:H,className:""+j+(t?" "+t:"")},P))});K5.displayName="CodeMirror";var G5={npm_package_exports___require:"./dist/avocado-not-front.umd.js",npm_package_devDependencies__types_node:"20.2.5",npm_package_devDependencies__testing_library_jest_dom:"6.4.0",npm_config_user_agent:"pnpm/9.10.0 npm/? node/v20.17.0 linux x64",CI:"true",npm_package_devDependencies__testing_library_user_event:"14.5.2",npm_package_devDependencies_vite:"5.0.12",npm_node_execpath:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_package_publishConfig_access:"public",npm_package_files_0:"dist",HOME:"/home/runner",npm_package_dependencies_react_select_async_paginate:"0.7.3",npm_package_devDependencies_classnames:"2.3.2",npm_package_devDependencies_sass:"1.62.1",npm_config_auto_install_peers:"true",npm_package_devDependencies_vite_plugin_dts:"3.7.1",npm_package_dependencies__codemirror_lang_yaml:"6.1.2",npm_package_devDependencies_typescript:"5.1.3",npm_package_peerDependencies_react_select_async_paginate:"0.7.3",npm_package_types:"./dist/index.d.ts",npm_package_devDependencies__types_react_dom:"18.0.11",npm_package_devDependencies__vitejs_plugin_react_swc:"3.5.0",npm_package_type:"module",npm_package_dependencies_zustand:"4.5.4",npm_package_module:"./dist/avocado-not-front.es.js",npm_package_devDependencies__types_testing_library__jest_dom:"6.0.0",npm_package_dependencies__foris_avocado_icons:"workspace:*",npm_config_registry:"https://registry.npmjs.org/",npm_config_node_linker:"hoisted",npm_package_dependencies__codemirror_lang_json:"6.0.1",npm_package_exports___import:"./dist/avocado-not-front.es.js",npm_package_dependencies__foris_avocado_core:"workspace:*",npm_package_dependencies_axios:"^1.8.4",npm_config_node_gyp:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/avocado/avocado/packages/avocado-not-front/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/work/avocado/avocado/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/avocado/avocado/node_modules/.bin:/opt/hostedtoolcache/node/20.17.0/x64/bin:/home/runner/setup-pnpm/node_modules/.bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",TURBO_HASH:"6161b1c60dd23d29",npm_package_name:"@foris/avocado-not-front",npm_package_scripts_start_stubby_examples:"stubby -d src/services/stubs/stubby-examples.yml -w -s 8300 -q",NODE:"/opt/hostedtoolcache/node/20.17.0/x64/bin/node",npm_config_frozen_lockfile:"",npm_config_legacy_peer_deps:"true",LANG:"C.UTF-8",npm_package_dependencies_react_dom:"18.2.0",npm_package_main:"./dist/avocado-not-front.umd.js",npm_lifecycle_script:"tsc && vite build",npm_package_dependencies__uiw_react_codemirror:"4.23.12",NODE_PATH:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/node_modules",npm_package_version:"0.9.1",npm_package_devDependencies__testing_library_react:"14.2.0",npm_package_devDependencies__types_react:"18.0.28",npm_package_devDependencies_jsdom:"24.0.0",npm_lifecycle_event:"build",npm_package_scripts_build:"tsc && vite build",npm_package_dependencies__codemirror_lang_sql:"6.8.0",npm_package_dependencies__foris_avocado_suite:"workspace:*",npm_package_dependencies_jsonpath:"1.1.1",npm_package_devDependencies__foris_tsconfig:"workspace:*",npm_package_dependencies_react_select:"5.8.0",PWD:"/home/runner/work/avocado/avocado/packages/avocado-not-front",npm_execpath:"/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@9.10.0/node_modules/pnpm/bin/pnpm.cjs",npm_package_devDependencies_stubby:"^5.1.0",npm_command:"run-script",PNPM_SCRIPT_SRC_DIR:"/home/runner/work/avocado/avocado/packages/avocado-not-front",npm_package_scripts_start_stubby:"stubby -d src/services/stubs/stubby-config.yml -w -s 8200 -q",npm_package_dependencies_react:"18.2.0",npm_package_peerDependencies_react_select:"5.8.0",INIT_CWD:"/home/runner/work/avocado/avocado/packages/avocado-not-front",NODE_ENV:"production"};class dc{constructor(e,t,n,i,s,o,a,l,c,u=0,h){this.p=e,this.stack=t,this.state=n,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=h}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let i=e.parser.context;return new dc(e,[],t,n,n,0,[],0,i?new J5(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let a=s.dynamicPrecedence(i);if(a&&(this.score+=a),n==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(n-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((t=this.p.parser.nodeSet.types[i])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let h=l?this.stack[l-1]:0,d=this.bufferBase+this.buffer.length-h;if(i<s.minRepeatTerm||e&131072){let f=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,c,f,d+4,!0)}if(e&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=s.getGoto(f,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,c)}storeNode(e,t,n,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==n)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,i);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>n;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=i}}shift(e,t,n,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4);else{let s=e,{parser:o}=this.p;(i>this.pos||t<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,i,4)}}apply(e,t,n,i){e&65536?this.reduce(e):this.shift(e,t,n,i)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new dc(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new QL(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let i=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&i.push(t[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<t.length;s+=2){let o=t[s+1];i.some((a,l)=>l&1&&a==o)||i.push(t[s],o)}t=i}let n=[];for(let i=0;i<t.length&&n.length<4;i+=2){let s=t[i+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[i],this.pos),o.reducePos=this.pos,o.score-=200,n.push(o)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,i=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(i,s)=>{if(!t.includes(i))return t.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=n(o,s+1);if(a!=null)return a}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new J5(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class J5{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class QL{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=i}}class fc{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new fc(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new fc(this.stack,this.pos,this.index)}}function pc(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let n=0,i=0;n<r.length;){let s=0;for(;;){let o=r.charCodeAt(n++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[i++]=s:t=new e(s)}return t}class mc{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const e9=new mc;class qL{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=e9,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!i)return null;let o=this.ranges[--i];s-=n.from-o.to,n=o}for(;t<0?s>n.to:s>=n.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-n.to,n=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,i;if(t>=0&&t<this.chunk.length)n=this.pos+e,i=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(n=s,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=n;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-n)),i=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),i}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=e9,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let i of this.ranges){if(i.from>=t)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return n}}class ls{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;UL(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}ls.prototype.contextual=ls.prototype.fallback=ls.prototype.extend=!1,ls.prototype.fallback=ls.prototype.extend=!1;class Mo{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function UL(r,e,t,n,i,s){let o=0,a=1<<n,{dialect:l}=t.p.parser;e:for(;a&r[o];){let c=r[o+1];for(let f=o+3;f<c;f+=2)if((r[f+1]&a)>0){let p=r[f];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||zL(p,e.token.value,i,s))){e.acceptToken(p);break}}let u=e.next,h=0,d=r[o+2];if(e.next<0&&d>h&&r[c+d*3-3]==65535){o=r[c+d*3-1];continue e}for(;h<d;){let f=h+d>>1,p=c+f+(f<<1),g=r[p],m=r[p+1]||65536;if(u<g)d=f;else if(u>=m)h=f+1;else{o=r[p+2],e.advance();continue e}}break}}function t9(r,e,t){for(let n=e,i;(i=r[n])!=65535;n++)if(i==t)return n-e;return-1}function zL(r,e,t,n){let i=t9(t,n,e);return i<0||t9(t,n,r)<i}const Gt=typeof process<"u"&&G5&&/\bparse\b/.test(G5.LOG);let af=null;function n9(r,e,t){let n=r.cursor(ht.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(r.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:r.length}}class $L{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?n9(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?n9(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],i=this.index[t];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=n.children[i],o=this.start[t]+n.positions[i];if(o>e)return this.nextStart=o,null;if(s instanceof it){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(be.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class YL{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new mc)}getActions(e){let t=0,n=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<s.length;c++){if(!(1<<c&o))continue;let u=s[c],h=this.tokens[c];if(!(n&&!u.fallback)&&((u.contextual||h.start!=e.pos||h.mask!=o||h.context!=a)&&(this.updateCachedToken(h,u,e),h.mask=o,h.context=a),h.lookAhead>h.end+25&&(l=Math.max(h.lookAhead,l)),h.value!=0)){let d=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!u.extend&&(n=h,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!n&&e.pos==this.stream.end&&(n=new mc,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new mc,{pos:n,p:i}=e;return t.start=n,t.end=Math.min(n+1,i.stream.end),t.value=n==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,n){let i=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(i,e),n),e.value>-1){let{parser:s}=n.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),n);if(a>=0&&n.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,n,i){for(let s=0;s<i;s+=3)if(this.actions[s]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=n,i}addActions(e,t,n,i){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let l=0;l<2;l++)for(let c=o.stateSlot(s,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=hr(a,c+2);else{i==0&&a[c+1]==2&&(i=this.putAction(hr(a,c+2),t,n,i));break}a[c]==t&&(i=this.putAction(hr(a,c+1),t,n,i))}return i}}class ZL{constructor(e,t,n,i){this.parser=e,this.input=t,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new qL(t,i),this.tokens=new YL(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[dc.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>e.bufferLength*4?new $L(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>t)n.push(a);else{if(this.advanceStack(a,n,e))continue;{i||(i=[],s=[]),i.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!n.length){let o=i&&GL(i);if(o)return Gt&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Gt&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,n);if(o)return Gt&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((a,l)=>l.score-a.score);n.length>o;)n.pop();n.some(a=>a.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o<n.length-1;o++){let a=n[o];for(let l=o+1;l<n.length;l++){let c=n[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)n.splice(l--,1);else{n.splice(o--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let o=1;o<n.length;o++)n[o].pos<this.minStackPos&&(this.minStackPos=n[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let i=e.pos,{parser:s}=this,o=Gt?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let h=this.fragments.nodeAt(i);h;){let d=this.parser.nodeSet.types[h.type.id]==h.type?s.getGoto(e.state,h.type.id):-1;if(d>-1&&h.length&&(!c||(h.prop(be.contextHash)||0)==u))return e.useNode(h,d),Gt&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(h.type.id)})`),!0;if(!(h instanceof it)||h.children.length==0||h.positions[0]>0)break;let f=h.children[0];if(f instanceof it&&h.positions[0]==0)h=f;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),Gt&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],h=l[c++],d=l[c++],f=c==l.length||!n,p=f?e:e.split(),g=this.tokens.mainToken;if(p.apply(u,h,g?g.start:p.pos,d),Gt&&console.log(o+this.stackID(p)+` (via ${u&65536?`reduce of ${s.getName(u&65535)}`:"shift"} for ${s.getName(h)} @ ${i}${p==e?"":", split"})`),f)return!0;p.pos>i?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return r9(e,t),!0}}runRecovery(e,t,n){let i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],l=t[o<<1],c=t[(o<<1)+1],u=Gt?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),Gt&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,n))))continue;let h=a.split(),d=u;for(let f=0;h.forceReduce()&&f<10&&(Gt&&console.log(d+this.stackID(h)+" (via force-reduce)"),!this.advanceFully(h,n));f++)Gt&&(d=this.stackID(h)+" -> ");for(let f of a.recoverByInsert(l))Gt&&console.log(u+this.stackID(f)+" (via recover-insert)"),this.advanceFully(f,n);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),Gt&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),r9(a,n)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),it.build({buffer:fc.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(af||(af=new WeakMap)).get(e);return t||af.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function r9(r,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==r.pos&&n.sameState(r)){e[t].score<r.score&&(e[t]=r);return}}e.push(r)}class XL{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}const lf=r=>r;class KL{constructor(e){this.start=e.start,this.shift=e.shift||lf,this.reduce=e.reduce||lf,this.reuse=e.reuse||lf,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class gi extends Q6{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;a<e.repeatNodeCount;a++)t.push("");let n=Object.keys(e.topRules).map(a=>e.topRules[a][1]),i=[];for(let a=0;a<t.length;a++)i.push([]);function s(a,l,c){i[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=be[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)s(u,l,a[c++]);else{let h=a[c+-u];for(let d=-u;d>0;d--)s(a[c++],l,h);c++}}}this.nodeSet=new gd(t.map((a,l)=>Vt.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[l],top:n.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=I6;let o=pc(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(i9),this.states=pc(e.states,Uint32Array),this.data=pc(e.stateData),this.goto=pc(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new ls(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let i=new ZL(this,e,t,n);for(let s of this.wrappers)i=s(i,e,t,n);return i}getGoto(e,t,n=!1){let i=this.goto;if(t>=i[0])return-1;for(let s=i[t+1];;){let o=i[s++],a=o&1,l=i[s++];if(a&&n)return l;for(let c=s+(o>>1);s<c;s++)if(i[s]==e)return l;if(a)return-1}}hasAction(e,t){let n=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(e,i?2:1),o;;s+=3){if((o=n[s])==65535)if(n[s+1]==1)o=n[s=hr(n,s+2)];else{if(n[s+1]==2)return hr(n,s+2);break}if(o==t||o==0)return hr(n,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),i=n?t(n):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=hr(this.data,s+2);else break;i=t(hr(this.data,s+1))}return i}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=hr(this.data,n+2);else break;if(!(this.data[n+2]&1)){let i=this.data[n+1];t.some((s,o)=>o&1&&s==i)||t.push(this.data[n],i)}}return t}configure(e){let t=Object.assign(Object.create(gi.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let i=e.tokenizers.find(s=>s.from==n);return i?i.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,i)=>{let s=e.specializers.find(a=>a.from==n.external);if(!s)return n;let o=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[i]=i9(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(n[o]=!0)}let i=null;for(let s=0;s<t.length;s++)if(!n[s])for(let o=this.dialects[t[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new XL(e,n,i)}static deserialize(e){return new gi(e)}}function hr(r,e){return r[e]|r[e+1]<<16}function GL(r){let e=null;for(let t of r){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function i9(r){if(r.external){let e=r.extend?1:0;return(t,n)=>r.external(t,n)<<1|e}return r.get}const JL=po({String:T.string,Number:T.number,"True False":T.bool,PropertyName:T.propertyName,Null:T.null,", :":T.separator,"[ ]":T.squareBracket,"{ }":T.brace}),eN=gi.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[JL],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),tN=hi.define({name:"json",parser:eN.configure({props:[Wl.add({Object:Md({except:/^\s*\}/}),Array:Md({except:/^\s*\]/})}),Ql.add({"Object Array":e2})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function s9(){return new Od(tN)}const nN=36,o9=1,rN=2,cs=3,cf=4,iN=5,sN=6,oN=7,aN=8,lN=9,cN=10,uN=11,hN=12,dN=13,fN=14,pN=15,mN=16,gN=17,a9=18,yN=19,l9=20,c9=21,u9=22,vN=23,bN=24;function uf(r){return r>=65&&r<=90||r>=97&&r<=122||r>=48&&r<=57}function CN(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70}function yi(r,e,t){for(let n=!1;;){if(r.next<0)return;if(r.next==e&&!n){r.advance();return}n=t&&!n&&r.next==92,r.advance()}}function wN(r,e){e:for(;;){if(r.next<0)return;if(r.next==36){r.advance();for(let t=0;t<e.length;t++){if(r.next!=e.charCodeAt(t))continue e;r.advance()}if(r.next==36){r.advance();return}}else r.advance()}}function kN(r,e){let t="[{<(".indexOf(String.fromCharCode(e)),n=t<0?e:"]}>)".charCodeAt(t);for(;;){if(r.next<0)return;if(r.next==n&&r.peek(1)==39){r.advance(2);return}r.advance()}}function hf(r,e){for(;!(r.next!=95&&!uf(r.next));)e!=null&&(e+=String.fromCharCode(r.next)),r.advance();return e}function SN(r){if(r.next==39||r.next==34||r.next==96){let e=r.next;r.advance(),yi(r,e,!1)}else hf(r)}function h9(r,e){for(;r.next==48||r.next==49;)r.advance();e&&r.next==e&&r.advance()}function d9(r,e){for(;;){if(r.next==46){if(e)break;e=!0}else if(r.next<48||r.next>57)break;r.advance()}if(r.next==69||r.next==101)for(r.advance(),(r.next==43||r.next==45)&&r.advance();r.next>=48&&r.next<=57;)r.advance()}function f9(r){for(;!(r.next<0||r.next==10);)r.advance()}function vi(r,e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)==r)return!0;return!1}const df=` \r
591
591
  `;function p9(r,e,t){let n=Object.create(null);n.true=n.false=iN,n.null=n.unknown=sN;for(let i of r.split(" "))i&&(n[i]=l9);for(let i of e.split(" "))i&&(n[i]=c9);for(let i of(t||"").split(" "))i&&(n[i]=bN);return n}const ff={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',caseInsensitiveIdentifiers:!1,words:p9("absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ","array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ")};function _N(r,e,t,n){let i={};for(let s in ff)i[s]=(r.hasOwnProperty(s)?r:ff)[s];return e&&(i.words=p9(e,t||"",n)),i}function m9(r){return new Mo(e=>{var t;let{next:n}=e;if(e.advance(),vi(n,df)){for(;vi(e.next,df);)e.advance();e.acceptToken(nN)}else if(n==36&&r.doubleDollarQuotedStrings){let i=hf(e,"");e.next==36&&(e.advance(),wN(e,i),e.acceptToken(cs))}else if(n==39||n==34&&r.doubleQuotedStrings)yi(e,n,r.backslashEscapes),e.acceptToken(cs);else if(n==35&&r.hashComments||n==47&&e.next==47&&r.slashComments)f9(e),e.acceptToken(o9);else if(n==45&&e.next==45&&(!r.spaceAfterDashes||e.peek(1)==32))f9(e),e.acceptToken(o9);else if(n==47&&e.next==42){e.advance();for(let i=1;;){let s=e.next;if(e.next<0)break;if(e.advance(),s==42&&e.next==47){if(i--,e.advance(),!i)break}else s==47&&e.next==42&&(i++,e.advance())}e.acceptToken(rN)}else if((n==101||n==69)&&e.next==39)e.advance(),yi(e,39,!0),e.acceptToken(cs);else if((n==110||n==78)&&e.next==39&&r.charSetCasts)e.advance(),yi(e,39,r.backslashEscapes),e.acceptToken(cs);else if(n==95&&r.charSetCasts)for(let i=0;;i++){if(e.next==39&&i>1){e.advance(),yi(e,39,r.backslashEscapes),e.acceptToken(cs);break}if(!uf(e.next))break;e.advance()}else if(r.plsqlQuotingMechanism&&(n==113||n==81)&&e.next==39&&e.peek(1)>0&&!vi(e.peek(1),df)){let i=e.peek(1);e.advance(2),kN(e,i),e.acceptToken(cs)}else if(n==40)e.acceptToken(oN);else if(n==41)e.acceptToken(aN);else if(n==123)e.acceptToken(lN);else if(n==125)e.acceptToken(cN);else if(n==91)e.acceptToken(uN);else if(n==93)e.acceptToken(hN);else if(n==59)e.acceptToken(dN);else if(r.unquotedBitLiterals&&n==48&&e.next==98)e.advance(),h9(e),e.acceptToken(u9);else if((n==98||n==66)&&(e.next==39||e.next==34)){const i=e.next;e.advance(),r.treatBitsAsBytes?(yi(e,i,r.backslashEscapes),e.acceptToken(vN)):(h9(e,i),e.acceptToken(u9))}else if(n==48&&(e.next==120||e.next==88)||(n==120||n==88)&&e.next==39){let i=e.next==39;for(e.advance();CN(e.next);)e.advance();i&&e.next==39&&e.advance(),e.acceptToken(cf)}else if(n==46&&e.next>=48&&e.next<=57)d9(e,!0),e.acceptToken(cf);else if(n==46)e.acceptToken(fN);else if(n>=48&&n<=57)d9(e,!1),e.acceptToken(cf);else if(vi(n,r.operatorChars)){for(;vi(e.next,r.operatorChars);)e.advance();e.acceptToken(pN)}else if(vi(n,r.specialVar))e.next==n&&e.advance(),SN(e),e.acceptToken(gN);else if(vi(n,r.identifierQuotes))yi(e,n,!1),e.acceptToken(yN);else if(n==58||n==44)e.acceptToken(mN);else if(uf(n)){let i=hf(e,String.fromCharCode(n));e.acceptToken(e.next==46||e.peek(-i.length-1)==46?a9:(t=r.words[i.toLowerCase()])!==null&&t!==void 0?t:a9)}})}const g9=m9(ff),xN=gi.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,g9],topRules:{Script:[0,25]},tokenPrec:0});function pf(r){let e=r.cursor().moveTo(r.from,-1);for(;/Comment/.test(e.name);)e.moveTo(e.from,-1);return e.node}function Po(r,e){let t=r.sliceString(e.from,e.to),n=/^([`'"])(.*)\1$/.exec(t);return n?n[2]:t}function gc(r){return r&&(r.name=="Identifier"||r.name=="QuotedIdentifier")}function ON(r,e){if(e.name=="CompositeIdentifier"){let t=[];for(let n=e.firstChild;n;n=n.nextSibling)gc(n)&&t.push(Po(r,n));return t}return[Po(r,e)]}function y9(r,e){for(let t=[];;){if(!e||e.name!=".")return t;let n=pf(e);if(!gc(n))return t;t.unshift(Po(r,n)),e=pf(n)}}function EN(r,e){let t=dt(r).resolveInner(e,-1),n=MN(r.doc,t);return t.name=="Identifier"||t.name=="QuotedIdentifier"||t.name=="Keyword"?{from:t.from,quoted:t.name=="QuotedIdentifier"?r.doc.sliceString(t.from,t.from+1):null,parents:y9(r.doc,pf(t)),aliases:n}:t.name=="."?{from:e,quoted:null,parents:y9(r.doc,t),aliases:n}:{from:e,quoted:null,parents:[],empty:!0,aliases:n}}const DN=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function MN(r,e){let t;for(let i=e;!t;i=i.parent){if(!i)return null;i.name=="Statement"&&(t=i)}let n=null;for(let i=t.firstChild,s=!1,o=null;i;i=i.nextSibling){let a=i.name=="Keyword"?r.sliceString(i.from,i.to).toLowerCase():null,l=null;if(!s)s=a=="from";else if(a=="as"&&o&&gc(i.nextSibling))l=Po(r,i.nextSibling);else{if(a&&DN.has(a))break;o&&gc(i)&&(l=Po(r,i))}l&&(n||(n=Object.create(null)),n[l]=ON(r,o)),o=/Identifier$/.test(i.name)?i:null}return n}function PN(r,e){return r?e.map(t=>Object.assign(Object.assign({},t),{label:t.label[0]==r?t.label:r+t.label+r,apply:void 0})):e}const TN=/^\w*$/,AN=/^[`'"]?\w*[`'"]?$/;function v9(r){return r.self&&typeof r.self.label=="string"}class mf{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(e){let t=this.children||(this.children=Object.create(null)),n=t[e];return n||(e&&!this.list.some(i=>i.label==e)&&this.list.push(b9(e,"type",this.idQuote,this.idCaseInsensitive)),t[e]=new mf(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(n=>n.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t=="string"?b9(t,"property",this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):v9(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],i=null,s=t.replace(/\\?\./g,a=>a=="."?"\0":a).split("\0"),o=this;v9(n)&&(i=n.self,n=n.children);for(let a=0;a<s.length;a++)i&&a==s.length-1&&o.addCompletion(i),o=o.child(s[a].replace(/\\\./g,"."));o.addNamespace(n)}}}function b9(r,e,t,n){return new RegExp("^[a-z_][a-z_\\d]*$",n?"i":"").test(r)?{label:r,type:e}:{label:r,type:e,apply:t+r+t}}function RN(r,e,t,n,i,s){var o;let a=((o=s==null?void 0:s.spec.identifierQuotes)===null||o===void 0?void 0:o[0])||'"',l=new mf(a,!!(s!=null&&s.spec.caseInsensitiveIdentifiers)),c=i?l.child(i):null;return l.addNamespace(r),e&&(c||l).addCompletions(e),t&&l.addCompletions(t),c&&l.addCompletions(c.list),n&&l.addCompletions((c||l).child(n).list),u=>{let{parents:h,from:d,quoted:f,empty:p,aliases:g}=EN(u.state,u.pos);if(p&&!u.explicit)return null;g&&h.length==1&&(h=g[h[0]]||h);let m=l;for(let k of h){for(;!m.children||!m.children[k];)if(m==l&&c)m=c;else if(m==c&&n)m=m.child(n);else return null;let C=m.maybeChild(k);if(!C)return null;m=C}let b=f&&u.state.sliceDoc(u.pos,u.pos+1)==f,_=m.list;return m==l&&g&&(_=_.concat(Object.keys(g).map(k=>({label:k,type:"constant"})))),{from:d,to:b?u.pos+1:void 0,options:PN(f,_),validFor:f?AN:TN}}}function LN(r){return r==c9?"type":r==l9?"keyword":"variable"}function NN(r,e,t){let n=Object.keys(r).map(i=>t(e?i.toUpperCase():i,LN(r[i])));return MR(["QuotedIdentifier","SpecialVar","String","LineComment","BlockComment","."],b5(n))}let IN=xN.configure({props:[Wl.add({Statement:Md()}),Ql.add({Statement(r,e){return{from:Math.min(r.from+100,e.doc.lineAt(r.from).to),to:r.to}},BlockComment(r){return{from:r.from+2,to:r.to-2}}}),po({Keyword:T.keyword,Type:T.typeName,Builtin:T.standard(T.name),Bits:T.number,Bytes:T.string,Bool:T.bool,Null:T.null,Number:T.number,String:T.string,Identifier:T.name,QuotedIdentifier:T.special(T.string),SpecialVar:T.special(T.name),LineComment:T.lineComment,BlockComment:T.blockComment,Operator:T.operator,"Semi Punctuation":T.punctuation,"( )":T.paren,"{ }":T.brace,"[ ]":T.squareBracket})]});class gf{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}static define(e){let t=_N(e,e.keywords,e.types,e.builtin),n=hi.define({name:"sql",parser:IN.configure({tokenizers:[{from:g9,to:m9(t)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new gf(t,n,e)}}function BN(r,e){return{label:r,type:e,boost:-1}}function HN(r,e=!1,t){return NN(r.dialect.words,e,t||BN)}function FN(r){return r.schema?RN(r.schema,r.tables,r.schemas,r.defaultTable,r.defaultSchema,r.dialect||yf):()=>null}function VN(r){return r.schema?(r.dialect||yf).language.data.of({autocomplete:FN(r)}):[]}function jN(r={}){let e=r.dialect||yf;return new Od(e.language,[VN(r),e.language.data.of({autocomplete:HN(e,r.upperCaseKeywords,r.keywordCompletion)})])}const yf=gf.define({}),us=63,C9=64,WN=1,QN=2,w9=3,qN=4,k9=5,UN=6,zN=7,S9=65,$N=66,YN=8,ZN=9,XN=10,KN=11,GN=12,_9=13,JN=19,eI=20,tI=29,nI=33,rI=34,iI=47,sI=0,vf=1,bf=2,To=3,Cf=4;class bi{constructor(e,t,n){this.parent=e,this.depth=t,this.type=n,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+n}}bi.top=new bi(null,-1,sI);function Ao(r,e){for(let t=0,n=e-r.pos-1;;n--,t++){let i=r.peek(n);if(dr(i)||i==-1)return t}}function wf(r){return r==32||r==9}function dr(r){return r==10||r==13}function x9(r){return wf(r)||dr(r)}function Ci(r){return r<0||x9(r)}const oI=new KL({start:bi.top,reduce(r,e){return r.type==To&&(e==eI||e==rI)?r.parent:r},shift(r,e,t,n){if(e==w9)return new bi(r,Ao(n,n.pos),vf);if(e==S9||e==k9)return new bi(r,Ao(n,n.pos),bf);if(e==us)return r.parent;if(e==JN||e==nI)return new bi(r,0,To);if(e==_9&&r.type==Cf)return r.parent;if(e==iI){let i=/[1-9]/.exec(n.read(n.pos,t.pos));if(i)return new bi(r,r.depth+ +i[0],Cf)}return r},hash(r){return r.hash}});function hs(r,e,t=0){return r.peek(t)==e&&r.peek(t+1)==e&&r.peek(t+2)==e&&Ci(r.peek(t+3))}const aI=new Mo((r,e)=>{if(r.next==-1&&e.canShift(C9))return r.acceptToken(C9);let t=r.peek(-1);if((dr(t)||t<0)&&e.context.type!=To){if(hs(r,45))if(e.canShift(us))r.acceptToken(us);else return r.acceptToken(WN,3);if(hs(r,46))if(e.canShift(us))r.acceptToken(us);else return r.acceptToken(QN,3);let n=0;for(;r.next==32;)n++,r.advance();(n<e.context.depth||n==e.context.depth&&e.context.type==vf&&(r.next!=45||!Ci(r.peek(1))))&&r.next!=-1&&!dr(r.next)&&r.next!=35&&r.acceptToken(us,-n)}},{contextual:!0}),lI=new Mo((r,e)=>{if(e.context.type==To){r.next==63&&(r.advance(),Ci(r.next)&&r.acceptToken(zN));return}if(r.next==45)r.advance(),Ci(r.next)&&r.acceptToken(e.context.type==vf&&e.context.depth==Ao(r,r.pos-1)?qN:w9);else if(r.next==63)r.advance(),Ci(r.next)&&r.acceptToken(e.context.type==bf&&e.context.depth==Ao(r,r.pos-1)?UN:k9);else{let t=r.pos;for(;;)if(wf(r.next)){if(r.pos==t)return;r.advance()}else if(r.next==33)D9(r);else if(r.next==38)kf(r);else if(r.next==42){kf(r);break}else if(r.next==39||r.next==34){if(Sf(r,!0))break;return}else if(r.next==91||r.next==123){if(!uI(r))return;break}else{M9(r,!0,!1,0);break}for(;wf(r.next);)r.advance();if(r.next==58){if(r.pos==t&&e.canShift(tI))return;let n=r.peek(1);Ci(n)&&r.acceptTokenTo(e.context.type==bf&&e.context.depth==Ao(r,t)?$N:S9,t)}}},{contextual:!0});function cI(r){return r>32&&r<127&&r!=34&&r!=37&&r!=44&&r!=60&&r!=62&&r!=92&&r!=94&&r!=96&&r!=123&&r!=124&&r!=125}function O9(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70}function E9(r,e){return r.next==37?(r.advance(),O9(r.next)&&r.advance(),O9(r.next)&&r.advance(),!0):cI(r.next)||e&&r.next==44?(r.advance(),!0):!1}function D9(r){if(r.advance(),r.next==60){for(r.advance();;)if(!E9(r,!0)){r.next==62&&r.advance();break}}else for(;E9(r,!1););}function kf(r){for(r.advance();!Ci(r.next)&&yc(r.tag)!="f";)r.advance()}function Sf(r,e){let t=r.next,n=!1,i=r.pos;for(r.advance();;){let s=r.next;if(s<0)break;if(r.advance(),s==t)if(s==39)if(r.next==39)r.advance();else break;else break;else if(s==92&&t==34)r.next>=0&&r.advance();else if(dr(s)){if(e)return!1;n=!0}else if(e&&r.pos>=i+1024)return!1}return!n}function uI(r){for(let e=[],t=r.pos+1024;;)if(r.next==91||r.next==123)e.push(r.next),r.advance();else if(r.next==39||r.next==34){if(!Sf(r,!0))return!1}else if(r.next==93||r.next==125){if(e[e.length-1]!=r.next-2)return!1;if(e.pop(),r.advance(),!e.length)return!0}else{if(r.next<0||r.pos>t||dr(r.next))return!1;r.advance()}}const hI="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function yc(r){return r<33?"u":r>125?"s":hI[r-33]}function _f(r,e){let t=yc(r);return t!="u"&&!(e&&t=="f")}function M9(r,e,t,n){if(yc(r.next)=="s"||(r.next==63||r.next==58||r.next==45)&&_f(r.peek(1),t))r.advance();else return!1;let i=r.pos;for(;;){let s=r.next,o=0,a=n+1;for(;x9(s);){if(dr(s)){if(e)return!1;a=0}else a++;s=r.peek(++o)}if(!(s>=0&&(s==58?_f(r.peek(o+1),t):s==35?r.peek(o-1)!=32:_f(s,t)))||!t&&a<=n||a==0&&!t&&(hs(r,45,o)||hs(r,46,o)))break;if(e&&yc(s)=="f")return!1;for(let c=o;c>=0;c--)r.advance();if(e&&r.pos>i+1024)return!1}return!0}const dI=new Mo((r,e)=>{if(r.next==33)D9(r),r.acceptToken(GN);else if(r.next==38||r.next==42){let t=r.next==38?XN:KN;kf(r),r.acceptToken(t)}else r.next==39||r.next==34?(Sf(r,!1),r.acceptToken(ZN)):M9(r,!1,e.context.type==To,e.context.depth)&&r.acceptToken(YN)}),fI=new Mo((r,e)=>{let t=e.context.type==Cf?e.context.depth:-1,n=r.pos;e:for(;;){let i=0,s=r.next;for(;s==32;)s=r.peek(++i);if(!i&&(hs(r,45,i)||hs(r,46,i))||!dr(s)&&(t<0&&(t=Math.max(e.context.depth+1,i)),i<t))break;for(;;){if(r.next<0)break e;let o=dr(r.next);if(r.advance(),o)continue e;n=r.pos}}r.acceptTokenTo(_9,n)}),pI=po({DirectiveName:T.keyword,DirectiveContent:T.attributeValue,"DirectiveEnd DocEnd":T.meta,QuotedLiteral:T.string,BlockLiteralHeader:T.special(T.string),BlockLiteralContent:T.content,Literal:T.content,"Key/Literal Key/QuotedLiteral":T.definition(T.propertyName),"Anchor Alias":T.labelName,Tag:T.typeName,Comment:T.lineComment,": , -":T.separator,"?":T.punctuation,"[ ]":T.squareBracket,"{ }":T.brace}),mI=gi.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:oI,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[pI],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[aI,lI,dI,fI,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),gI=gi.deserialize({version:14,states:"!vOQOPOOO]OPO'#C_OhOPO'#C^OOOO'#Cc'#CcOpOPO'#CaQOOOOOO{OPOOOOOO'#Cb'#CbO!WOPO'#C`O!`OPO,58xOOOO-E6a-E6aOOOO-E6`-E6`OOOO'#C_'#C_OOOO1G.d1G.d",stateData:"!h~OXPOYROWTP~OWVXXRXYRX~OYVOXSP~OXROYROWTX~OXROYROWTP~OYVOXSX~OX[O~OXY~",goto:"vWPPX[beioRUOQQOR]XRXQTTOUQWQRZWSSOURYS",nodeNames:"⚠ Document Frontmatter DashLine FrontmatterContent Body",maxTerm:10,skippedNodes:[0],repeatNodeCount:2,tokenData:"$z~RXOYnYZ!^Z]n]^!^^}n}!O!i!O;'Sn;'S;=`!c<%lOn~qXOYnYZ!^Z]n]^!^^;'Sn;'S;=`!c<%l~n~On~~!^~!cOY~~!fP;=`<%ln~!lZOYnYZ!^Z]n]^!^^}n}!O#_!O;'Sn;'S;=`!c<%l~n~On~~!^~#bZOYnYZ!^Z]n]^!^^}n}!O$T!O;'Sn;'S;=`!c<%l~n~On~~!^~$WXOYnYZ$sZ]n]^$s^;'Sn;'S;=`!c<%l~n~On~~$s~$zOX~Y~",tokenizers:[0],topRules:{Document:[0,1]},tokenPrec:67}),yI=hi.define({name:"yaml",parser:mI.configure({props:[Wl.add({Stream:r=>{for(let e=r.node.resolve(r.pos,-1);e&&e.to>=r.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.from<e.to)return r.baseIndentFor(e);if(e.name=="BlockLiteral")return r.baseIndentFor(e)+r.unit;if(e.name=="BlockSequence"||e.name=="BlockMapping")return r.column(e.from,1);if(e.name=="QuotedLiteral")return null;if(e.name=="Literal"){let t=r.column(e.from,1);if(t==r.lineIndent(e.from,1))return t;if(e.to>r.pos)return null}}return null},FlowMapping:G6({closing:"}"}),FlowSequence:G6({closing:"]"})}),Ql.add({"FlowMapping FlowSequence":e2,"Item Pair BlockLiteral":(r,e)=>({from:e.doc.lineAt(r.from).to,to:r.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function vI(){return new Od(yI)}T.meta;const xf={codeEditor:"_codeEditor_1viyo_1",codeEditor_label:"_codeEditor_label_1viyo_4",codeEditor_input:"_codeEditor_input_1viyo_13"},bI=r=>{const{userFlow:e,responseKey:t,label:n,language:i,placeholder:s,value:o,required:a}=r,[l,c]=O.useState(o),u={json:s9(),sql:jN(),yaml:vI()},h=O.useMemo(()=>a&&n?`${n} *`:n??"",[n,a]),d=f=>{c(f);const p={[t]:f};xr(e,p)};return me.jsxs("div",{className:xf.codeEditor,children:[me.jsx("label",{className:xf.codeEditor_label,children:h}),me.jsx(K5,{className:xf.codeEditor_input,value:l,height:"400px",placeholder:s,extensions:[u[i]??s9()],onChange:f=>d(f),theme:"dark"})]})};var P9={exports:{}};/*!
592
592
  Copyright (c) 2018 Jed Watson.
593
593
  Licensed under the MIT License (MIT), see