lsp-ws-connection
Version:
Utility for adapting editors to language server protocol
1 lines • 71 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["lsp-ws-connection"]=t():e["lsp-ws-connection"]=t()}(self,(()=>(()=>{var e={725:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}m(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&m(e,"error",t,{once:!0})}(e,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function f(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function h(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function m(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(o){n.once&&e.removeEventListener(t,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)n(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},o.prototype.listenerCount=h,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},494:e=>{var t,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,c=[],u=!1,l=-1;function d(){u&&a&&(u=!1,a.length?c=a.concat(c):l=-1,c.length&&f())}function f(){if(!u){var e=s(d);u=!0;for(var t=c.length;t;){for(a=c,c=[];++l<t;)a&&a[l].run();l=-1,t=c.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new h(e,t)),1!==c.length||u||s(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},155:function(e,t,r){var n=r(494);!function(e,t){"use strict";if(!e.setImmediate){var r,i,o,s,a,c=1,u={},l=!1,d=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?r=function(e){n.nextTick((function(){p(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?(s="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&p(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),r=function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},r=function(e){o.port2.postMessage(e)}):d&&"onreadystatechange"in d.createElement("script")?(i=d.documentElement,r=function(e){var t=d.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):r=function(e){setTimeout(p,0,e)},f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var i={callback:e,args:t};return u[c]=i,r(c),c++},f.clearImmediate=h}function h(e){delete u[e]}function p(e){if(l)setTimeout(p,0,e);else{var t=u[e];if(t){l=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(void 0,r)}}(t)}finally{h(e),l=!1}}}}}("undefined"==typeof self?void 0===r.g?this:r.g:self)},306:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.createMessageConnection=t.BrowserMessageWriter=t.BrowserMessageReader=void 0,r(294).default.install();const o=r(778);i(r(778),t);class s extends o.AbstractMessageReader{constructor(e){super(),this._onData=new o.Emitter,this._messageListener=e=>{this._onData.fire(e.data)},e.addEventListener("error",(e=>this.fireError(e))),e.onmessage=this._messageListener}listen(e){return this._onData.event(e)}}t.BrowserMessageReader=s;class a extends o.AbstractMessageWriter{constructor(e){super(),this.context=e,this.errorCount=0,e.addEventListener("error",(e=>this.fireError(e)))}write(e){try{return this.context.postMessage(e),Promise.resolve()}catch(t){return this.handleError(t,e),Promise.reject(t)}}handleError(e,t){this.errorCount++,this.fireError(e,t,this.errorCount)}end(){}}t.BrowserMessageWriter=a,t.createMessageConnection=function(e,t,r,n){return void 0===r&&(r=o.NullLogger),o.ConnectionStrategy.is(n)&&(n={connectionStrategy:n}),(0,o.createMessageConnection)(e,t,r,n)}},294:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(834),i=r(469),o=r(493),s=r(690);class a extends s.AbstractMessageBuffer{constructor(e="utf-8"){super(e),this.asciiDecoder=new TextDecoder("ascii")}emptyBuffer(){return a.emptyBuffer}fromString(e,t){return(new TextEncoder).encode(e)}toString(e,t){return"ascii"===t?this.asciiDecoder.decode(e):new TextDecoder(t).decode(e)}asNative(e,t){return void 0===t?e:e.slice(0,t)}allocNative(e){return new Uint8Array(e)}}a.emptyBuffer=new Uint8Array(0);class c{constructor(e){this.socket=e,this._onData=new o.Emitter,this._messageListener=e=>{e.data.arrayBuffer().then((e=>{this._onData.fire(new Uint8Array(e))}),(()=>{(0,n.default)().console.error("Converting blob to array buffer failed.")}))},this.socket.addEventListener("message",this._messageListener)}onClose(e){return this.socket.addEventListener("close",e),i.Disposable.create((()=>this.socket.removeEventListener("close",e)))}onError(e){return this.socket.addEventListener("error",e),i.Disposable.create((()=>this.socket.removeEventListener("error",e)))}onEnd(e){return this.socket.addEventListener("end",e),i.Disposable.create((()=>this.socket.removeEventListener("end",e)))}onData(e){return this._onData.event(e)}}class u{constructor(e){this.socket=e}onClose(e){return this.socket.addEventListener("close",e),i.Disposable.create((()=>this.socket.removeEventListener("close",e)))}onError(e){return this.socket.addEventListener("error",e),i.Disposable.create((()=>this.socket.removeEventListener("error",e)))}onEnd(e){return this.socket.addEventListener("end",e),i.Disposable.create((()=>this.socket.removeEventListener("end",e)))}write(e,t){if("string"==typeof e){if(void 0!==t&&"utf-8"!==t)throw new Error(`In a Browser environments only utf-8 text encoding is supported. But got encoding: ${t}`);this.socket.send(e)}else this.socket.send(e);return Promise.resolve()}end(){this.socket.close()}}const l=new TextEncoder,d=Object.freeze({messageBuffer:Object.freeze({create:e=>new a(e)}),applicationJson:Object.freeze({encoder:Object.freeze({name:"application/json",encode:(e,t)=>{if("utf-8"!==t.charset)throw new Error(`In a Browser environments only utf-8 text encoding is supported. But got encoding: ${t.charset}`);return Promise.resolve(l.encode(JSON.stringify(e,void 0,0)))}}),decoder:Object.freeze({name:"application/json",decode:(e,t)=>{if(!(e instanceof Uint8Array))throw new Error("In a Browser environments only Uint8Arrays are supported.");return Promise.resolve(JSON.parse(new TextDecoder(t.charset).decode(e)))}})}),stream:Object.freeze({asReadableStream:e=>new c(e),asWritableStream:e=>new u(e)}),console,timer:Object.freeze({setTimeout(e,t,...r){const n=setTimeout(e,t,...r);return{dispose:()=>clearTimeout(n)}},setImmediate(e,...t){const r=setTimeout(e,0,...t);return{dispose:()=>clearTimeout(r)}},setInterval(e,t,...r){const n=setInterval(e,t,...r);return{dispose:()=>clearInterval(n)}}})});function f(){return d}!function(e){e.install=function(){n.default.install(d)}}(f||(f={})),t.default=f},778:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TraceFormat=t.TraceValues=t.Trace=t.ProgressType=t.ProgressToken=t.createMessageConnection=t.NullLogger=t.ConnectionOptions=t.ConnectionStrategy=t.WriteableStreamMessageWriter=t.AbstractMessageWriter=t.MessageWriter=t.ReadableStreamMessageReader=t.AbstractMessageReader=t.MessageReader=t.CancellationToken=t.CancellationTokenSource=t.Emitter=t.Event=t.Disposable=t.LRUCache=t.Touch=t.LinkedMap=t.ParameterStructures=t.NotificationType9=t.NotificationType8=t.NotificationType7=t.NotificationType6=t.NotificationType5=t.NotificationType4=t.NotificationType3=t.NotificationType2=t.NotificationType1=t.NotificationType0=t.NotificationType=t.ErrorCodes=t.ResponseError=t.RequestType9=t.RequestType8=t.RequestType7=t.RequestType6=t.RequestType5=t.RequestType4=t.RequestType3=t.RequestType2=t.RequestType1=t.RequestType0=t.RequestType=t.Message=t.RAL=void 0,t.CancellationStrategy=t.CancellationSenderStrategy=t.CancellationReceiverStrategy=t.ConnectionError=t.ConnectionErrors=t.LogTraceNotification=t.SetTraceNotification=void 0;const n=r(849);Object.defineProperty(t,"Message",{enumerable:!0,get:function(){return n.Message}}),Object.defineProperty(t,"RequestType",{enumerable:!0,get:function(){return n.RequestType}}),Object.defineProperty(t,"RequestType0",{enumerable:!0,get:function(){return n.RequestType0}}),Object.defineProperty(t,"RequestType1",{enumerable:!0,get:function(){return n.RequestType1}}),Object.defineProperty(t,"RequestType2",{enumerable:!0,get:function(){return n.RequestType2}}),Object.defineProperty(t,"RequestType3",{enumerable:!0,get:function(){return n.RequestType3}}),Object.defineProperty(t,"RequestType4",{enumerable:!0,get:function(){return n.RequestType4}}),Object.defineProperty(t,"RequestType5",{enumerable:!0,get:function(){return n.RequestType5}}),Object.defineProperty(t,"RequestType6",{enumerable:!0,get:function(){return n.RequestType6}}),Object.defineProperty(t,"RequestType7",{enumerable:!0,get:function(){return n.RequestType7}}),Object.defineProperty(t,"RequestType8",{enumerable:!0,get:function(){return n.RequestType8}}),Object.defineProperty(t,"RequestType9",{enumerable:!0,get:function(){return n.RequestType9}}),Object.defineProperty(t,"ResponseError",{enumerable:!0,get:function(){return n.ResponseError}}),Object.defineProperty(t,"ErrorCodes",{enumerable:!0,get:function(){return n.ErrorCodes}}),Object.defineProperty(t,"NotificationType",{enumerable:!0,get:function(){return n.NotificationType}}),Object.defineProperty(t,"NotificationType0",{enumerable:!0,get:function(){return n.NotificationType0}}),Object.defineProperty(t,"NotificationType1",{enumerable:!0,get:function(){return n.NotificationType1}}),Object.defineProperty(t,"NotificationType2",{enumerable:!0,get:function(){return n.NotificationType2}}),Object.defineProperty(t,"NotificationType3",{enumerable:!0,get:function(){return n.NotificationType3}}),Object.defineProperty(t,"NotificationType4",{enumerable:!0,get:function(){return n.NotificationType4}}),Object.defineProperty(t,"NotificationType5",{enumerable:!0,get:function(){return n.NotificationType5}}),Object.defineProperty(t,"NotificationType6",{enumerable:!0,get:function(){return n.NotificationType6}}),Object.defineProperty(t,"NotificationType7",{enumerable:!0,get:function(){return n.NotificationType7}}),Object.defineProperty(t,"NotificationType8",{enumerable:!0,get:function(){return n.NotificationType8}}),Object.defineProperty(t,"NotificationType9",{enumerable:!0,get:function(){return n.NotificationType9}}),Object.defineProperty(t,"ParameterStructures",{enumerable:!0,get:function(){return n.ParameterStructures}});const i=r(622);Object.defineProperty(t,"LinkedMap",{enumerable:!0,get:function(){return i.LinkedMap}}),Object.defineProperty(t,"LRUCache",{enumerable:!0,get:function(){return i.LRUCache}}),Object.defineProperty(t,"Touch",{enumerable:!0,get:function(){return i.Touch}});const o=r(469);Object.defineProperty(t,"Disposable",{enumerable:!0,get:function(){return o.Disposable}});const s=r(493);Object.defineProperty(t,"Event",{enumerable:!0,get:function(){return s.Event}}),Object.defineProperty(t,"Emitter",{enumerable:!0,get:function(){return s.Emitter}});const a=r(781);Object.defineProperty(t,"CancellationTokenSource",{enumerable:!0,get:function(){return a.CancellationTokenSource}}),Object.defineProperty(t,"CancellationToken",{enumerable:!0,get:function(){return a.CancellationToken}});const c=r(763);Object.defineProperty(t,"MessageReader",{enumerable:!0,get:function(){return c.MessageReader}}),Object.defineProperty(t,"AbstractMessageReader",{enumerable:!0,get:function(){return c.AbstractMessageReader}}),Object.defineProperty(t,"ReadableStreamMessageReader",{enumerable:!0,get:function(){return c.ReadableStreamMessageReader}});const u=r(389);Object.defineProperty(t,"MessageWriter",{enumerable:!0,get:function(){return u.MessageWriter}}),Object.defineProperty(t,"AbstractMessageWriter",{enumerable:!0,get:function(){return u.AbstractMessageWriter}}),Object.defineProperty(t,"WriteableStreamMessageWriter",{enumerable:!0,get:function(){return u.WriteableStreamMessageWriter}});const l=r(149);Object.defineProperty(t,"ConnectionStrategy",{enumerable:!0,get:function(){return l.ConnectionStrategy}}),Object.defineProperty(t,"ConnectionOptions",{enumerable:!0,get:function(){return l.ConnectionOptions}}),Object.defineProperty(t,"NullLogger",{enumerable:!0,get:function(){return l.NullLogger}}),Object.defineProperty(t,"createMessageConnection",{enumerable:!0,get:function(){return l.createMessageConnection}}),Object.defineProperty(t,"ProgressToken",{enumerable:!0,get:function(){return l.ProgressToken}}),Object.defineProperty(t,"ProgressType",{enumerable:!0,get:function(){return l.ProgressType}}),Object.defineProperty(t,"Trace",{enumerable:!0,get:function(){return l.Trace}}),Object.defineProperty(t,"TraceValues",{enumerable:!0,get:function(){return l.TraceValues}}),Object.defineProperty(t,"TraceFormat",{enumerable:!0,get:function(){return l.TraceFormat}}),Object.defineProperty(t,"SetTraceNotification",{enumerable:!0,get:function(){return l.SetTraceNotification}}),Object.defineProperty(t,"LogTraceNotification",{enumerable:!0,get:function(){return l.LogTraceNotification}}),Object.defineProperty(t,"ConnectionErrors",{enumerable:!0,get:function(){return l.ConnectionErrors}}),Object.defineProperty(t,"ConnectionError",{enumerable:!0,get:function(){return l.ConnectionError}}),Object.defineProperty(t,"CancellationReceiverStrategy",{enumerable:!0,get:function(){return l.CancellationReceiverStrategy}}),Object.defineProperty(t,"CancellationSenderStrategy",{enumerable:!0,get:function(){return l.CancellationSenderStrategy}}),Object.defineProperty(t,"CancellationStrategy",{enumerable:!0,get:function(){return l.CancellationStrategy}});const d=r(834);t.RAL=d.default},781:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CancellationTokenSource=t.CancellationToken=void 0;const n=r(834),i=r(482),o=r(493);var s;!function(e){e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:o.Event.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:o.Event.None}),e.is=function(t){const r=t;return r&&(r===e.None||r===e.Cancelled||i.boolean(r.isCancellationRequested)&&!!r.onCancellationRequested)}}(s=t.CancellationToken||(t.CancellationToken={}));const a=Object.freeze((function(e,t){const r=(0,n.default)().timer.setTimeout(e.bind(t),0);return{dispose(){r.dispose()}}}));class c{constructor(){this._isCancelled=!1}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?a:(this._emitter||(this._emitter=new o.Emitter),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=void 0)}}t.CancellationTokenSource=class{get token(){return this._token||(this._token=new c),this._token}cancel(){this._token?this._token.cancel():this._token=s.Cancelled}dispose(){this._token?this._token instanceof c&&this._token.dispose():this._token=s.None}}},149:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createMessageConnection=t.ConnectionOptions=t.CancellationStrategy=t.CancellationSenderStrategy=t.CancellationReceiverStrategy=t.ConnectionStrategy=t.ConnectionError=t.ConnectionErrors=t.LogTraceNotification=t.SetTraceNotification=t.TraceFormat=t.TraceValues=t.Trace=t.NullLogger=t.ProgressType=t.ProgressToken=void 0;const n=r(834),i=r(482),o=r(849),s=r(622),a=r(493),c=r(781);var u,l,d,f,h,p,m,g,v,y,b,w,_,T,E;!function(e){e.type=new o.NotificationType("$/cancelRequest")}(u||(u={})),function(e){e.is=function(e){return"string"==typeof e||"number"==typeof e}}(l=t.ProgressToken||(t.ProgressToken={})),function(e){e.type=new o.NotificationType("$/progress")}(d||(d={})),t.ProgressType=class{constructor(){}},function(e){e.is=function(e){return i.func(e)}}(f||(f={})),t.NullLogger=Object.freeze({error:()=>{},warn:()=>{},info:()=>{},log:()=>{}}),function(e){e[e.Off=0]="Off",e[e.Messages=1]="Messages",e[e.Compact=2]="Compact",e[e.Verbose=3]="Verbose"}(h=t.Trace||(t.Trace={})),(E=t.TraceValues||(t.TraceValues={})).Off="off",E.Messages="messages",E.Compact="compact",E.Verbose="verbose",function(e){e.fromString=function(t){if(!i.string(t))return e.Off;switch(t=t.toLowerCase()){case"off":default:return e.Off;case"messages":return e.Messages;case"compact":return e.Compact;case"verbose":return e.Verbose}},e.toString=function(t){switch(t){case e.Off:return"off";case e.Messages:return"messages";case e.Compact:return"compact";case e.Verbose:return"verbose";default:return"off"}}}(h=t.Trace||(t.Trace={})),function(e){e.Text="text",e.JSON="json"}(t.TraceFormat||(t.TraceFormat={})),function(e){e.fromString=function(t){return i.string(t)&&"json"===(t=t.toLowerCase())?e.JSON:e.Text}}(p=t.TraceFormat||(t.TraceFormat={})),function(e){e.type=new o.NotificationType("$/setTrace")}(m=t.SetTraceNotification||(t.SetTraceNotification={})),function(e){e.type=new o.NotificationType("$/logTrace")}(g=t.LogTraceNotification||(t.LogTraceNotification={})),function(e){e[e.Closed=1]="Closed",e[e.Disposed=2]="Disposed",e[e.AlreadyListening=3]="AlreadyListening"}(v=t.ConnectionErrors||(t.ConnectionErrors={}));class C extends Error{constructor(e,t){super(t),this.code=e,Object.setPrototypeOf(this,C.prototype)}}t.ConnectionError=C,function(e){e.is=function(e){const t=e;return t&&i.func(t.cancelUndispatched)}}(y=t.ConnectionStrategy||(t.ConnectionStrategy={})),function(e){e.Message=Object.freeze({createCancellationTokenSource:e=>new c.CancellationTokenSource}),e.is=function(e){const t=e;return t&&i.func(t.createCancellationTokenSource)}}(b=t.CancellationReceiverStrategy||(t.CancellationReceiverStrategy={})),function(e){e.Message=Object.freeze({sendCancellation:(e,t)=>e.sendNotification(u.type,{id:t}),cleanup(e){}}),e.is=function(e){const t=e;return t&&i.func(t.sendCancellation)&&i.func(t.cleanup)}}(w=t.CancellationSenderStrategy||(t.CancellationSenderStrategy={})),function(e){e.Message=Object.freeze({receiver:b.Message,sender:w.Message}),e.is=function(e){const t=e;return t&&b.is(t.receiver)&&w.is(t.sender)}}(_=t.CancellationStrategy||(t.CancellationStrategy={})),(t.ConnectionOptions||(t.ConnectionOptions={})).is=function(e){const t=e;return t&&(_.is(t.cancellationStrategy)||y.is(t.connectionStrategy))},function(e){e[e.New=1]="New",e[e.Listening=2]="Listening",e[e.Closed=3]="Closed",e[e.Disposed=4]="Disposed"}(T||(T={})),t.createMessageConnection=function(e,r,y,b){const w=void 0!==y?y:t.NullLogger;let E=0,R=0,k=0;const S="2.0";let O;const P=new Map;let M;const N=new Map,x=new Map;let L,j,q=new s.LinkedMap,D=new Map,$=new Set,I=new Map,A=h.Off,z=p.Text,W=T.New;const U=new a.Emitter,F=new a.Emitter,J=new a.Emitter,B=new a.Emitter,V=new a.Emitter,H=b&&b.cancellationStrategy?b.cancellationStrategy:_.Message;function K(e){if(null===e)throw new Error("Can't send requests with id null since the response can't be correlated.");return"req-"+e.toString()}function G(e){}function Q(){return W===T.Listening}function X(){return W===T.Closed}function Y(){return W===T.Disposed}function Z(){W!==T.New&&W!==T.Listening||(W=T.Closed,F.fire(void 0))}function ee(){L||0===q.size||(L=(0,n.default)().timer.setImmediate((()=>{L=void 0,function(){if(0===q.size)return;const e=q.shift();try{o.Message.isRequest(e)?function(e){if(Y())return;function t(t,n,i){const s={jsonrpc:S,id:e.id};t instanceof o.ResponseError?s.error=t.toJson():s.result=void 0===t?null:t,ne(s,n,i),r.write(s).catch((()=>w.error("Sending response failed.")))}function n(t,n,i){const o={jsonrpc:S,id:e.id,error:t.toJson()};ne(o,n,i),r.write(o).catch((()=>w.error("Sending response failed.")))}!function(e){if(A!==h.Off&&j)if(z===p.Text){let t;A!==h.Verbose&&A!==h.Compact||!e.params||(t=`Params: ${re(e.params)}\n\n`),j.log(`Received request '${e.method} - (${e.id})'.`,t)}else oe("receive-request",e)}(e);const s=P.get(e.method);let a,c;s&&(a=s.type,c=s.handler);const u=Date.now();if(c||O){const s=e.id??String(Date.now()),l=H.receiver.createCancellationTokenSource(s);null!==e.id&&$.has(e.id)&&l.cancel(),null!==e.id&&I.set(s,l);try{let d;if(c)if(void 0===e.params){if(void 0!==a&&0!==a.numberOfParams)return void n(new o.ResponseError(o.ErrorCodes.InvalidParams,`Request ${e.method} defines ${a.numberOfParams} params but received none.`),e.method,u);d=c(l.token)}else if(Array.isArray(e.params)){if(void 0!==a&&a.parameterStructures===o.ParameterStructures.byName)return void n(new o.ResponseError(o.ErrorCodes.InvalidParams,`Request ${e.method} defines parameters by name but received parameters by position`),e.method,u);d=c(...e.params,l.token)}else{if(void 0!==a&&a.parameterStructures===o.ParameterStructures.byPosition)return void n(new o.ResponseError(o.ErrorCodes.InvalidParams,`Request ${e.method} defines parameters by position but received parameters by name`),e.method,u);d=c(e.params,l.token)}else O&&(d=O(e.method,e.params,l.token));const f=d;d?f.then?f.then((r=>{I.delete(s),t(r,e.method,u)}),(t=>{I.delete(s),t instanceof o.ResponseError?n(t,e.method,u):t&&i.string(t.message)?n(new o.ResponseError(o.ErrorCodes.InternalError,`Request ${e.method} failed with message: ${t.message}`),e.method,u):n(new o.ResponseError(o.ErrorCodes.InternalError,`Request ${e.method} failed unexpectedly without providing any details.`),e.method,u)})):(I.delete(s),t(d,e.method,u)):(I.delete(s),function(t,n,i){void 0===t&&(t=null);const o={jsonrpc:S,id:e.id,result:t};ne(o,n,i),r.write(o).catch((()=>w.error("Sending response failed.")))}(d,e.method,u))}catch(r){I.delete(s),r instanceof o.ResponseError?t(r,e.method,u):r&&i.string(r.message)?n(new o.ResponseError(o.ErrorCodes.InternalError,`Request ${e.method} failed with message: ${r.message}`),e.method,u):n(new o.ResponseError(o.ErrorCodes.InternalError,`Request ${e.method} failed unexpectedly without providing any details.`),e.method,u)}}else n(new o.ResponseError(o.ErrorCodes.MethodNotFound,`Unhandled method ${e.method}`),e.method,u)}(e):o.Message.isNotification(e)?function(e){if(Y())return;let t,r;if(e.method===u.type.method){const t=e.params.id;return $.delete(t),void ie(e)}{const n=N.get(e.method);n&&(r=n.handler,t=n.type)}if(r||M)try{if(ie(e),r)if(void 0===e.params)void 0!==t&&0!==t.numberOfParams&&t.parameterStructures!==o.ParameterStructures.byName&&w.error(`Notification ${e.method} defines ${t.numberOfParams} params but received none.`),r();else if(Array.isArray(e.params)){const n=e.params;e.method===d.type.method&&2===n.length&&l.is(n[0])?r({token:n[0],value:n[1]}):(void 0!==t&&(t.parameterStructures===o.ParameterStructures.byName&&w.error(`Notification ${e.method} defines parameters by name but received parameters by position`),t.numberOfParams!==e.params.length&&w.error(`Notification ${e.method} defines ${t.numberOfParams} params but received ${n.length} arguments`)),r(...n))}else void 0!==t&&t.parameterStructures===o.ParameterStructures.byPosition&&w.error(`Notification ${e.method} defines parameters by position but received parameters by name`),r(e.params);else M&&M(e.method,e.params)}catch(t){t.message?w.error(`Notification handler '${e.method}' failed with message: ${t.message}`):w.error(`Notification handler '${e.method}' failed unexpectedly.`)}else J.fire(e)}(e):o.Message.isResponse(e)?function(e){if(!Y())if(null===e.id)e.error?w.error(`Received response message without id: Error is: \n${JSON.stringify(e.error,void 0,4)}`):w.error("Received response message without id. No further error information provided.");else{const t=e.id,r=D.get(t);if(function(e,t){if(A!==h.Off&&j)if(z===p.Text){let r;if(A!==h.Verbose&&A!==h.Compact||(e.error&&e.error.data?r=`Error data: ${re(e.error.data)}\n\n`:e.result?r=`Result: ${re(e.result)}\n\n`:void 0===e.error&&(r="No result returned.\n\n")),t){const n=e.error?` Request failed: ${e.error.message} (${e.error.code}).`:"";j.log(`Received response '${t.method} - (${e.id})' in ${Date.now()-t.timerStart}ms.${n}`,r)}else j.log(`Received response ${e.id} without active response promise.`,r)}else oe("receive-response",e)}(e,r),void 0!==r){D.delete(t);try{if(e.error){const t=e.error;r.reject(new o.ResponseError(t.code,t.message,t.data))}else{if(void 0===e.result)throw new Error("Should never happen.");r.resolve(e.result)}}catch(e){e.message?w.error(`Response handler '${r.method}' failed with message: ${e.message}`):w.error(`Response handler '${r.method}' failed unexpectedly.`)}}}}(e):function(e){if(!e)return void w.error("Received empty message.");w.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(e,null,4)}`);const t=e;if(i.string(t.id)||i.number(t.id)){const e=t.id,r=D.get(e);r&&r.reject(new Error("The received response has neither a result nor an error property."))}}(e)}finally{ee()}}()})))}e.onClose(Z),e.onError((function(e){U.fire([e,void 0,void 0])})),r.onClose(Z),r.onError((function(e){U.fire(e)}));const te=e=>{try{if(o.Message.isNotification(e)&&e.method===u.type.method){const t=e.params.id,n=K(t),i=q.get(n);if(o.Message.isRequest(i)){const o=b?.connectionStrategy,s=o&&o.cancelUndispatched?o.cancelUndispatched(i,G):void 0;if(s&&(void 0!==s.error||void 0!==s.result))return q.delete(n),I.delete(t),s.id=i.id,ne(s,e.method,Date.now()),void r.write(s).catch((()=>w.error("Sending response for canceled message failed.")))}const s=I.get(t);if(void 0!==s)return s.cancel(),void ie(e);$.add(t)}!function(e,t){var r;o.Message.isRequest(t)?e.set(K(t.id),t):o.Message.isResponse(t)?e.set(null===(r=t.id)?"res-unknown-"+(++k).toString():"res-"+r.toString(),t):e.set("not-"+(++R).toString(),t)}(q,e)}finally{ee()}};function re(e){if(null!=e)switch(A){case h.Verbose:return JSON.stringify(e,null,4);case h.Compact:return JSON.stringify(e);default:return}}function ne(e,t,r){if(A!==h.Off&&j)if(z===p.Text){let n;A!==h.Verbose&&A!==h.Compact||(e.error&&e.error.data?n=`Error data: ${re(e.error.data)}\n\n`:e.result?n=`Result: ${re(e.result)}\n\n`:void 0===e.error&&(n="No result returned.\n\n")),j.log(`Sending response '${t} - (${e.id})'. Processing request took ${Date.now()-r}ms`,n)}else oe("send-response",e)}function ie(e){if(A!==h.Off&&j&&e.method!==g.type.method)if(z===p.Text){let t;A!==h.Verbose&&A!==h.Compact||(t=e.params?`Params: ${re(e.params)}\n\n`:"No parameters provided.\n\n"),j.log(`Received notification '${e.method}'.`,t)}else oe("receive-notification",e)}function oe(e,t){if(!j||A===h.Off)return;const r={isLSPMessage:!0,type:e,message:t,timestamp:Date.now()};j.log(r)}function se(){if(X())throw new C(v.Closed,"Connection is closed.");if(Y())throw new C(v.Disposed,"Connection is disposed.")}function ae(e){return void 0===e?null:e}function ce(e){return null===e?void 0:e}function ue(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}function le(e,t){switch(e){case o.ParameterStructures.auto:return ue(t)?ce(t):[ae(t)];case o.ParameterStructures.byName:if(!ue(t))throw new Error("Received parameters by name but param is not an object literal.");return ce(t);case o.ParameterStructures.byPosition:return[ae(t)];default:throw new Error(`Unknown parameter structure ${e.toString()}`)}}function de(e,t){let r;const n=e.numberOfParams;switch(n){case 0:r=void 0;break;case 1:r=le(e.parameterStructures,t[0]);break;default:r=[];for(let e=0;e<t.length&&e<n;e++)r.push(ae(t[e]));if(t.length<n)for(let e=t.length;e<n;e++)r.push(null)}return r}const fe={sendNotification:(e,...t)=>{let n,s;if(se(),i.string(e)){n=e;const r=t[0];let i=0,a=o.ParameterStructures.auto;o.ParameterStructures.is(r)&&(i=1,a=r);let c=t.length;const u=c-i;switch(u){case 0:s=void 0;break;case 1:s=le(a,t[i]);break;default:if(a===o.ParameterStructures.byName)throw new Error(`Received ${u} parameters for 'by Name' notification parameter structure.`);s=t.slice(i,c).map((e=>ae(e)))}}else{const r=t;n=e.method,s=de(e,r)}const a={jsonrpc:S,method:n,params:s};return function(e){if(A!==h.Off&&j)if(z===p.Text){let t;A!==h.Verbose&&A!==h.Compact||(t=e.params?`Params: ${re(e.params)}\n\n`:"No parameters provided.\n\n"),j.log(`Sending notification '${e.method}'.`,t)}else oe("send-notification",e)}(a),r.write(a).catch((()=>w.error("Sending notification failed.")))},onNotification:(e,t)=>{let r;return se(),i.func(e)?M=e:t&&(i.string(e)?(r=e,N.set(e,{type:void 0,handler:t})):(r=e.method,N.set(e.method,{type:e,handler:t}))),{dispose:()=>{void 0!==r?N.delete(r):M=void 0}}},onProgress:(e,t,r)=>{if(x.has(t))throw new Error(`Progress handler for token ${t} already registered`);return x.set(t,r),{dispose:()=>{x.delete(t)}}},sendProgress:(e,t,r)=>fe.sendNotification(d.type,{token:t,value:r}),onUnhandledProgress:B.event,sendRequest:(e,...t)=>{let n,s,a;if(se(),function(){if(!Q())throw new Error("Call listen() first.")}(),i.string(e)){n=e;const r=t[0],i=t[t.length-1];let u=0,l=o.ParameterStructures.auto;o.ParameterStructures.is(r)&&(u=1,l=r);let d=t.length;c.CancellationToken.is(i)&&(d-=1,a=i);const f=d-u;switch(f){case 0:s=void 0;break;case 1:s=le(l,t[u]);break;default:if(l===o.ParameterStructures.byName)throw new Error(`Received ${f} parameters for 'by Name' request parameter structure.`);s=t.slice(u,d).map((e=>ae(e)))}}else{const r=t;n=e.method,s=de(e,r);const i=e.numberOfParams;a=c.CancellationToken.is(r[i])?r[i]:void 0}const u=E++;let l;return a&&(l=a.onCancellationRequested((()=>{const e=H.sender.sendCancellation(fe,u);return void 0===e?(w.log(`Received no promise from cancellation strategy when cancelling id ${u}`),Promise.resolve()):e.catch((()=>{w.log(`Sending cancellation messages for id ${u} failed`)}))}))),new Promise(((e,t)=>{const i={jsonrpc:S,id:u,method:n,params:s};let a={method:n,timerStart:Date.now(),resolve:t=>{e(t),H.sender.cleanup(u),l?.dispose()},reject:e=>{t(e),H.sender.cleanup(u),l?.dispose()}};!function(e){if(A!==h.Off&&j)if(z===p.Text){let t;A!==h.Verbose&&A!==h.Compact||!e.params||(t=`Params: ${re(e.params)}\n\n`),j.log(`Sending request '${e.method} - (${e.id})'.`,t)}else oe("send-request",e)}(i);try{r.write(i).catch((()=>w.error("Sending request failed.")))}catch(e){a.reject(new o.ResponseError(o.ErrorCodes.MessageWriteError,e.message?e.message:"Unknown reason")),a=null}a&&D.set(u,a)}))},onRequest:(e,t)=>{se();let r=null;return f.is(e)?(r=void 0,O=e):i.string(e)?(r=null,void 0!==t&&(r=e,P.set(e,{handler:t,type:void 0}))):void 0!==t&&(r=e.method,P.set(e.method,{type:e,handler:t})),{dispose:()=>{null!==r&&(void 0!==r?P.delete(r):O=void 0)}}},hasPendingResponse:()=>D.size>0,trace:async(e,t,r)=>{let n=!1,o=p.Text;void 0!==r&&(i.boolean(r)?n=r:(n=r.sendNotification||!1,o=r.traceFormat||p.Text)),A=e,z=o,j=A===h.Off?void 0:t,!n||X()||Y()||await fe.sendNotification(m.type,{value:h.toString(e)})},onError:U.event,onClose:F.event,onUnhandledNotification:J.event,onDispose:V.event,end:()=>{r.end()},dispose:()=>{if(Y())return;W=T.Disposed,V.fire(void 0);const t=new o.ResponseError(o.ErrorCodes.PendingResponseRejected,"Pending response rejected since connection got disposed");for(const e of D.values())e.reject(t);D=new Map,I=new Map,$=new Set,q=new s.LinkedMap,i.func(r.dispose)&&r.dispose(),i.func(e.dispose)&&e.dispose()},listen:()=>{se(),function(){if(Q())throw new C(v.AlreadyListening,"Connection is already listening")}(),W=T.Listening,e.listen(te)},inspect:()=>{(0,n.default)().console.log("inspect")}};return fe.onNotification(g.type,(e=>{if(A===h.Off||!j)return;const t=A===h.Verbose||A===h.Compact;j.log(e.message,t?e.verbose:void 0)})),fe.onNotification(d.type,(e=>{const t=x.get(e.token);t?t(e.value):B.fire(e)})),fe}},469:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Disposable=void 0,(t.Disposable||(t.Disposable={})).create=function(e){return{dispose:e}}},493:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=t.Event=void 0;const n=r(834);!function(e){const t={dispose(){}};e.None=function(){return t}}(t.Event||(t.Event={}));class i{add(e,t=null,r){this._callbacks||(this._callbacks=[],this._contexts=[]),this._callbacks.push(e),this._contexts.push(t),Array.isArray(r)&&r.push({dispose:()=>this.remove(e,t)})}remove(e,t=null){if(!this._callbacks)return;let r=!1;for(let n=0,i=this._callbacks.length;n<i;n++)if(this._callbacks[n]===e){if(this._contexts[n]===t)return this._callbacks.splice(n,1),void this._contexts.splice(n,1);r=!0}if(r)throw new Error("When adding a listener with a context, you should remove it with the same context")}invoke(...e){if(!this._callbacks)return[];const t=[],r=this._callbacks.slice(0),i=this._contexts.slice(0);for(let o=0,s=r.length;o<s;o++)try{t.push(r[o].apply(i[o],e))}catch(e){(0,n.default)().console.error(e)}return t}isEmpty(){return!this._callbacks||0===this._callbacks.length}dispose(){this._callbacks=void 0,this._contexts=void 0}}class o{constructor(e){this._options=e}get event(){return this._event||(this._event=(e,t,r)=>{this._callbacks||(this._callbacks=new i),this._options&&this._options.onFirstListenerAdd&&this._callbacks.isEmpty()&&this._options.onFirstListenerAdd(this),this._callbacks.add(e,t);const n={dispose:()=>{this._callbacks&&(this._callbacks.remove(e,t),n.dispose=o._noop,this._options&&this._options.onLastListenerRemove&&this._callbacks.isEmpty()&&this._options.onLastListenerRemove(this))}};return Array.isArray(r)&&r.push(n),n}),this._event}fire(e){this._callbacks&&this._callbacks.invoke.call(this._callbacks,e)}dispose(){this._callbacks&&(this._callbacks.dispose(),this._callbacks=void 0)}}t.Emitter=o,o._noop=function(){}},482:(e,t)=>{"use strict";function r(e){return"string"==typeof e||e instanceof String}function n(e){return Array.isArray(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.stringArray=t.array=t.func=t.error=t.number=t.string=t.boolean=void 0,t.boolean=function(e){return!0===e||!1===e},t.string=r,t.number=function(e){return"number"==typeof e||e instanceof Number},t.error=function(e){return e instanceof Error},t.func=function(e){return"function"==typeof e},t.array=n,t.stringArray=function(e){return n(e)&&e.every((e=>r(e)))}},622:(e,t)=>{"use strict";var r,n;Object.defineProperty(t,"__esModule",{value:!0}),t.LRUCache=t.LinkedMap=t.Touch=void 0,function(e){e.None=0,e.First=1,e.AsOld=e.First,e.Last=2,e.AsNew=e.Last}(n=t.Touch||(t.Touch={}));class i{constructor(){this[r]="LinkedMap",this._map=new Map,this._head=void 0,this._tail=void 0,this._size=0,this._state=0}clear(){this._map.clear(),this._head=void 0,this._tail=void 0,this._size=0,this._state++}isEmpty(){return!this._head&&!this._tail}get size(){return this._size}get first(){return this._head?.value}get last(){return this._tail?.value}has(e){return this._map.has(e)}get(e,t=n.None){const r=this._map.get(e);if(r)return t!==n.None&&this.touch(r,t),r.value}set(e,t,r=n.None){let i=this._map.get(e);if(i)i.value=t,r!==n.None&&this.touch(i,r);else{switch(i={key:e,value:t,next:void 0,previous:void 0},r){case n.None:this.addItemLast(i);break;case n.First:this.addItemFirst(i);break;case n.Last:default:this.addItemLast(i)}this._map.set(e,i),this._size++}return this}delete(e){return!!this.remove(e)}remove(e){const t=this._map.get(e);if(t)return this._map.delete(e),this.removeItem(t),this._size--,t.value}shift(){if(!this._head&&!this._tail)return;if(!this._head||!this._tail)throw new Error("Invalid list");const e=this._head;return this._map.delete(e.key),this.removeItem(e),this._size--,e.value}forEach(e,t){const r=this._state;let n=this._head;for(;n;){if(t?e.bind(t)(n.value,n.key,this):e(n.value,n.key,this),this._state!==r)throw new Error("LinkedMap got modified during iteration.");n=n.next}}keys(){const e=this._state;let t=this._head;const r={[Symbol.iterator]:()=>r,next:()=>{if(this._state!==e)throw new Error("LinkedMap got modified during iteration.");if(t){const e={value:t.key,done:!1};return t=t.next,e}return{value:void 0,done:!0}}};return r}values(){const e=this._state;let t=this._head;const r={[Symbol.iterator]:()=>r,next:()=>{if(this._state!==e)throw new Error("LinkedMap got modified during iteration.");if(t){const e={value:t.value,done:!1};return t=t.next,e}return{value:void 0,done:!0}}};return r}entries(){const e=this._state;let t=this._head;const r={[Symbol.iterator]:()=>r,next:()=>{if(this._state!==e)throw new Error("LinkedMap got modified during iteration.");if(t){const e={value:[t.key,t.value],done:!1};return t=t.next,e}return{value:void 0,done:!0}}};return r}[(r=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}trimOld(e){if(e>=this.size)return;if(0===e)return void this.clear();let t=this._head,r=this.size;for(;t&&r>e;)this._map.delete(t.key),t=t.next,r--;this._head=t,this._size=r,t&&(t.previous=void 0),this._state++}addItemFirst(e){if(this._head||this._tail){if(!this._head)throw new Error("Invalid list");e.next=this._head,this._head.previous=e}else this._tail=e;this._head=e,this._state++}addItemLast(e){if(this._head||this._tail){if(!this._tail)throw new Error("Invalid list");e.previous=this._tail,this._tail.next=e}else this._head=e;this._tail=e,this._state++}removeItem(e){if(e===this._head&&e===this._tail)this._head=void 0,this._tail=void 0;else if(e===this._head){if(!e.next)throw new Error("Invalid list");e.next.previous=void 0,this._head=e.next}else if(e===this._tail){if(!e.previous)throw new Error("Invalid list");e.previous.next=void 0,this._tail=e.previous}else{const t=e.next,r=e.previous;if(!t||!r)throw new Error("Invalid list");t.previous=r,r.next=t}e.next=void 0,e.previous=void 0,this._state++}touch(e,t){if(!this._head||!this._tail)throw new Error("Invalid list");if(t===n.First||t===n.Last)if(t===n.First){if(e===this._head)return;const t=e.next,r=e.previous;e===this._tail?(r.next=void 0,this._tail=r):(t.previous=r,r.next=t),e.previous=void 0,e.next=this._head,this._head.previous=e,this._head=e,this._state++}else if(t===n.Last){if(e===this._tail)return;const t=e.next,r=e.previous;e===this._head?(t.previous=void 0,this._head=t):(t.previous=r,r.next=t),e.next=void 0,e.previous=this._tail,this._tail.next=e,this._tail=e,this._state++}}toJSON(){const e=[];return this.forEach(((t,r)=>{e.push([r,t])})),e}fromJSON(e){this.clear();for(const[t,r]of e)this.set(t,r)}}t.LinkedMap=i,t.LRUCache=class extends i{constructor(e,t=1){super(),this._limit=e,this._ratio=Math.min(Math.max(0,t),1)}get limit(){return this._limit}set limit(e){this._limit=e,this.checkTrim()}get ratio(){return this._ratio}set ratio(e){this._ratio=Math.min(Math.max(0,e),1),this.checkTrim()}get(e,t=n.AsNew){return super.get(e,t)}peek(e){return super.get(e,n.None)}set(e,t){return super.set(e,t,n.Last),this.checkTrim(),this}checkTrim(){this.size>this._limit&&this.trimOld(Math.round(this._limit*this._ratio))}}},690:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractMessageBuffer=void 0,t.AbstractMessageBuffer=class{constructor(e="utf-8"){this._encoding=e,this._chunks=[],this._totalLength=0}get encoding(){return this._encoding}append(e){const t="string"==typeof e?this.fromString(e,this._encoding):e;this._chunks.push(t),this._totalLength+=t.byteLength}tryReadHeaders(){if(0===this._chunks.length)return;let e=0,t=0,r=0,n=0;e:for(;t<this._chunks.length;){const i=this._chunks[t];for(r=0;r<i.length;){switch(i[r]){case 13:switch(e){case 0:e=1;break;case 2:e=3;break;default:e=0}break;case 10:switch(e){case 1:e=2;break;case 3:e=4,r++;break e;default:e=0}break;default:e=0}r++}n+=i.byteLength,t++}if(4!==e)return;const i=this._read(n+r),o=new Map,s=this.toString(i,"ascii").split("\r\n");if(s.length<2)return o;for(let e=0;e<s.length-2;e++){const t=s[e],r=t.indexOf(":");if(-1===r)throw new Error("Message header must separate key and value using :");const n=t.substr(0,r),i=t.substr(r+1).trim();o.set(n,i)}return o}tryReadBody(e){if(!(this._totalLength<e))return this._read(e)}get numberOfBytes(){return this._totalLength}_read(e){if(0===e)return this.emptyBuffer();if(e>this._totalLength)throw new Error("Cannot read so many bytes!");if(this._chunks[0].byteLength===e){const t=this._chunks[0];return this._chunks.shift(),this._totalLength-=e,this.asNative(t)}if(this._chunks[0].byteLength>e){const t=this._chunks[0],r=this.asNative(t,e);return this._chunks[0]=t.slice(e),this._totalLength-=e,r}const t=this.allocNative(e);let r=0;for(;e>0;){const n=this._chunks[0];if(n.byteLength>e){const i=n.slice(0,e);t.set(i,r),r+=e,this._chunks[0]=n.slice(e),this._totalLength-=e,e-=e}else t.set(n,r),r+=n.byteLength,this._chunks.shift(),this._totalLength-=n.byteLength,e-=n.byteLength}return t}}},763:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableStreamMessageReader=t.AbstractMessageReader=t.MessageReader=void 0;const n=r(834),i=r(482),o=r(493);var s;(t.MessageReader||(t.MessageReader={})).is=function(e){let t=e;return t&&i.func(t.listen)&&i.func(t.dispose)&&i.func(t.onError)&&i.func(t.onClose)&&i.func(t.onPartialMessage)};class a{constructor(){this.errorEmitter=new o.Emitter,this.closeEmitter=new o.Emitter,this.partialMessageEmitter=new o.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError(e){this.errorEmitter.fire(this.asError(e))}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}get onPartialMessage(){return this.partialMessageEmitter.event}firePartialMessage(e){this.partialMessageEmitter.fire(e)}asError(e){return e instanceof Error?e:new Error(`Reader received error. Reason: ${i.string(e.message)?e.message:"unknown"}`)}}t.AbstractMessageReader=a,function(e){e.fromOptions=function(e){let t,r;const i=new Map;let o;const s=new Map;if(void 0===e||"string"==typeof e)t=e??"utf-8";else{if(t=e.charset??"utf-8",void 0!==e.contentDecoder&&(r=e.contentDecoder,i.set(r.name,r)),void 0!==e.contentDecoders)for(const t of e.contentDecoders)i.set(t.name,t);if(void 0!==e.contentTypeDecoder&&(o=e.contentTypeDecoder,s.set(o.name,o)),void 0!==e.contentTypeDecoders)for(const t of e.contentTypeDecoders)s.set(t.name,t)}return void 0===o&&(o=(0,n.default)().applicationJson.decoder,s.set(o.name,o)),{charset:t,contentDecoder:r,contentDecoders:i,contentTypeDecoder:o,contentTypeDecoders:s}}}(s||(s={})),t.ReadableStreamMessageReader=class extends a{constructor(e,t){super(),this.readable=e,this.options=s.fromOptions(t),this.buffer=(0,n.default)().messageBuffer.create(this.options.charset),this._partialMessageTimeout=1e4,this.nextMessageLength=-1,this.messageToken=0}set partialMessageTimeout(e){this._partialMessageTimeout=e}get partialMessageTimeout(){return this._partialMessageTimeout}listen(e){this.nextMessageLength=-1,this.messageToken=0,this.partialMessageTimer=void 0,this.callback=e;const t=this.readable.onData((e=>{this.onData(e)}));return this.readable.onError((e=>this.fireError(e))),this.readable.onClose((()=>this.fireClose())),t}onData(e){for(this.buffer.append(e);;){if(-1===this.nextMessageLength){const e=this.