UNPKG

use-monaco

Version:

[![npm](https://img.shields.io/npm/v/use-monaco)](https://npm.im/use-monaco)

12 lines (8 loc) 31.4 kB
(()=>{var me=Object.create,T=Object.defineProperty,ve=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty,xe=Object.getOwnPropertyNames,Se=Object.getOwnPropertyDescriptor,Q=e=>T(e,"__esModule",{value:!0}),q=(e,r)=>()=>(r||(r={exports:{}},e(r.exports,r)),r.exports),_e=(e,r)=>{Q(e);for(var t in r)T(e,t,{get:r[t],enumerable:!0})},M=(e,r,t)=>{if(Q(e),r&&typeof r=="object"||typeof r=="function")for(let n of xe(r))!ye.call(e,n)&&n!=="default"&&T(e,n,{get:()=>r[n],enumerable:!(t=Se(r,n))||t.enumerable});return e},O=e=>e&&e.__esModule?e:M(T(e!=null?me(ve(e)):{},"default",{value:e,enumerable:!0}),e),N=q(we=>{M(we,O(require("monaco-editor-core")))}),de=q(Ce=>{_e(Ce,{getJavaScriptWorker:()=>Oe,getTypeScriptWorker:()=>De,setupJavaScript:()=>Fe,setupTypeScript:()=>Ae});var k=O(N());"use strict";var V,K;function Ae(e){K=pe(e,"typescript")}function Fe(e){V=pe(e,"javascript")}function Oe(){return new Promise(function(e,r){if(!V)return r("JavaScript not registered!");e(V)})}function De(){return new Promise(function(e,r){if(!K)return r("TypeScript not registered!");e(K)})}function pe(e,r){var t=new Y(r,e),n=function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return t.getLanguageServiceWorker.apply(t,i)},o=new Z(n);return k.languages.registerCompletionItemProvider(r,new te(n)),k.languages.registerSignatureHelpProvider(r,new re(n)),k.languages.registerHoverProvider(r,new ne(n)),k.languages.registerDocumentHighlightProvider(r,new ie(n)),k.languages.registerDefinitionProvider(r,new se(o,n)),k.languages.registerReferenceProvider(r,new oe(o,n)),k.languages.registerDocumentSymbolProvider(r,new ae(n)),k.languages.registerDocumentRangeFormattingEditProvider(r,new ue(n)),k.languages.registerOnTypeFormattingEditProvider(r,new ce(n)),k.languages.registerCodeActionProvider(r,new le(n)),k.languages.registerRenameProvider(r,new fe(n)),new $(o,e,r,n),n}}),X="4.0.3",F=O(N());"use strict";var H;(function(e){e[e.None=0]="None",e[e.CommonJS=1]="CommonJS",e[e.AMD=2]="AMD",e[e.UMD=3]="UMD",e[e.System=4]="System",e[e.ES2015=5]="ES2015",e[e.ESNext=99]="ESNext"})(H||(H={}));var B;(function(e){e[e.None=0]="None",e[e.Preserve=1]="Preserve",e[e.React=2]="React",e[e.ReactNative=3]="ReactNative"})(B||(B={}));var J;(function(e){e[e.CarriageReturnLineFeed=0]="CarriageReturnLineFeed",e[e.LineFeed=1]="LineFeed"})(J||(J={}));var P;(function(e){e[e.ES3=0]="ES3",e[e.ES5=1]="ES5",e[e.ES2015=2]="ES2015",e[e.ES2016=3]="ES2016",e[e.ES2017=4]="ES2017",e[e.ES2018=5]="ES2018",e[e.ES2019=6]="ES2019",e[e.ES2020=7]="ES2020",e[e.ESNext=99]="ESNext",e[e.JSON=100]="JSON",e[e.Latest=99]="Latest"})(P||(P={}));var U;(function(e){e[e.Classic=1]="Classic",e[e.NodeJs=2]="NodeJs"})(U||(U={}));var he=function(){function e(r,t,n){this._onDidChange=new F.Emitter,this._onDidExtraLibsChange=new F.Emitter,this._extraLibs=Object.create(null),this._removedExtraLibs=Object.create(null),this._eagerModelSync=!1,this.setCompilerOptions(r),this.setDiagnosticsOptions(t),this.setWorkerOptions(n),this._onDidExtraLibsChangeTimeout=-1}return Object.defineProperty(e.prototype,"onDidChange",{get:function(){return this._onDidChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDidExtraLibsChange",{get:function(){return this._onDidExtraLibsChange.event},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"workerOptions",{get:function(){return this._workerOptions},enumerable:!1,configurable:!0}),e.prototype.getExtraLibs=function(){return this._extraLibs},e.prototype.addExtraLib=function(r,t){var n=this,o;if(typeof t=="undefined"?o="ts:extralib-"+Math.random().toString(36).substring(2,15):o=t,this._extraLibs[o]&&this._extraLibs[o].content===r)return{dispose:function(){}};var i=1;return this._removedExtraLibs[o]&&(i=this._removedExtraLibs[o]+1),this._extraLibs[o]&&(i=this._extraLibs[o].version+1),this._extraLibs[o]={content:r,version:i},this._fireOnDidExtraLibsChangeSoon(),{dispose:function(){var a=n._extraLibs[o];if(!a)return;if(a.version!==i)return;delete n._extraLibs[o],n._removedExtraLibs[o]=i,n._fireOnDidExtraLibsChangeSoon()}}},e.prototype.setExtraLibs=function(r){for(var t in this._extraLibs)this._removedExtraLibs[t]=this._extraLibs[t].version;if(this._extraLibs=Object.create(null),r&&r.length>0)for(var n=0,o=r;n<o.length;n++){var i=o[n],t=i.filePath||"ts:extralib-"+Math.random().toString(36).substring(2,15),a=i.content,c=1;this._removedExtraLibs[t]&&(c=this._removedExtraLibs[t]+1),this._extraLibs[t]={content:a,version:c}}this._fireOnDidExtraLibsChangeSoon()},e.prototype._fireOnDidExtraLibsChangeSoon=function(){var r=this;if(this._onDidExtraLibsChangeTimeout!==-1)return;this._onDidExtraLibsChangeTimeout=setTimeout(function(){r._onDidExtraLibsChangeTimeout=-1,r._onDidExtraLibsChange.fire(void 0)},0)},e.prototype.getCompilerOptions=function(){return this._compilerOptions},e.prototype.setCompilerOptions=function(r){this._compilerOptions=r||Object.create(null),this._onDidChange.fire(void 0)},e.prototype.getDiagnosticsOptions=function(){return this._diagnosticsOptions},e.prototype.setDiagnosticsOptions=function(r){this._diagnosticsOptions=r||Object.create(null),this._onDidChange.fire(void 0)},e.prototype.setWorkerOptions=function(r){this._workerOptions=r||Object.create(null),this._onDidChange.fire(void 0)},e.prototype.setMaximumWorkerIdleTime=function(r){},e.prototype.setEagerModelSync=function(r){this._eagerModelSync=r},e.prototype.getEagerModelSync=function(){return this._eagerModelSync},e}(),Ee=X,ge=new he({allowNonTsExtensions:!0,target:P.Latest},{noSemanticValidation:!1,noSyntaxValidation:!1},{}),be=new he({allowNonTsExtensions:!0,allowJs:!0,target:P.Latest},{noSemanticValidation:!0,noSyntaxValidation:!1},{}),Ne=function(){return I().then(function(e){return e.getTypeScriptWorker()})},Pe=function(){return I().then(function(e){return e.getJavaScriptWorker()})};F.languages.typescript={ModuleKind:H,JsxEmit:B,NewLineKind:J,ScriptTarget:P,ModuleResolutionKind:U,typescriptVersion:Ee,typescriptDefaults:ge,javascriptDefaults:be,getTypeScriptWorker:Ne,getJavaScriptWorker:Pe};var R=O(N());"use strict";var ke=function(e,r,t,n){function o(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function c(u){try{s(n.next(u))}catch(f){a(f)}}function l(u){try{s(n.throw(u))}catch(f){a(f)}}function s(u){u.done?i(u.value):o(u.value).then(c,l)}s((n=n.apply(e,r||[])).next())})},Le=function(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(u){return l([s,u])}}function l(s){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,o&&(i=s[0]&2?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;(o=0,i)&&(s=[s[0]&2,i.value]);switch(s[0]){case 0:case 1:i=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,o=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1],i=s;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(s);break}i[2]&&t.ops.pop(),t.trys.pop();continue}s=r.call(e,t)}catch(u){s=[6,u],o=0}finally{n=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},Y=function(){function e(r,t){var n=this;this._modeId=r,this._defaults=t,this._worker=null,this._client=null,this._configChangeListener=this._defaults.onDidChange(function(){return n._stopWorker()}),this._updateExtraLibsToken=0,this._extraLibsChangeListener=this._defaults.onDidExtraLibsChange(function(){return n._updateExtraLibs()})}return e.prototype._stopWorker=function(){this._worker&&(this._worker.dispose(),this._worker=null),this._client=null},e.prototype.dispose=function(){this._configChangeListener.dispose(),this._extraLibsChangeListener.dispose(),this._stopWorker()},e.prototype._updateExtraLibs=function(){return ke(this,void 0,void 0,function(){var r,t;return Le(this,function(n){switch(n.label){case 0:return this._worker?(r=++this._updateExtraLibsToken,[4,this._worker.getProxy()]):[2];case 1:return t=n.sent(),this._updateExtraLibsToken!==r?[2]:(t.updateExtraLibs(this._defaults.getExtraLibs()),[2])}})})},e.prototype._getClient=function(){var r=this;if(!this._client){this._worker=R.editor.createWebWorker({moduleId:"vs/language/typescript/tsWorker",label:this._modeId,keepIdleModels:!0,createData:{compilerOptions:this._defaults.getCompilerOptions(),extraLibs:this._defaults.getExtraLibs(),customWorkerPath:this._defaults.workerOptions.customWorkerPath}});var t=this._worker.getProxy();this._defaults.getEagerModelSync()&&(t=t.then(function(n){return r._worker?r._worker.withSyncedResources(R.editor.getModels().filter(function(o){return o.getModeId()===r._modeId}).map(function(o){return o.uri})):n})),this._client=t}return this._client},e.prototype.getLanguageServiceWorker=function(){for(var r=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var o;return this._getClient().then(function(i){o=i}).then(function(i){if(r._worker)return r._worker.withSyncedResources(t)}).then(function(i){return o})},e}(),h={};h["lib.d.ts"]=!0;h["lib.dom.d.ts"]=!0;h["lib.dom.iterable.d.ts"]=!0;h["lib.es2015.collection.d.ts"]=!0;h["lib.es2015.core.d.ts"]=!0;h["lib.es2015.d.ts"]=!0;h["lib.es2015.generator.d.ts"]=!0;h["lib.es2015.iterable.d.ts"]=!0;h["lib.es2015.promise.d.ts"]=!0;h["lib.es2015.proxy.d.ts"]=!0;h["lib.es2015.reflect.d.ts"]=!0;h["lib.es2015.symbol.d.ts"]=!0;h["lib.es2015.symbol.wellknown.d.ts"]=!0;h["lib.es2016.array.include.d.ts"]=!0;h["lib.es2016.d.ts"]=!0;h["lib.es2016.full.d.ts"]=!0;h["lib.es2017.d.ts"]=!0;h["lib.es2017.full.d.ts"]=!0;h["lib.es2017.intl.d.ts"]=!0;h["lib.es2017.object.d.ts"]=!0;h["lib.es2017.sharedmemory.d.ts"]=!0;h["lib.es2017.string.d.ts"]=!0;h["lib.es2017.typedarrays.d.ts"]=!0;h["lib.es2018.asyncgenerator.d.ts"]=!0;h["lib.es2018.asynciterable.d.ts"]=!0;h["lib.es2018.d.ts"]=!0;h["lib.es2018.full.d.ts"]=!0;h["lib.es2018.intl.d.ts"]=!0;h["lib.es2018.promise.d.ts"]=!0;h["lib.es2018.regexp.d.ts"]=!0;h["lib.es2019.array.d.ts"]=!0;h["lib.es2019.d.ts"]=!0;h["lib.es2019.full.d.ts"]=!0;h["lib.es2019.object.d.ts"]=!0;h["lib.es2019.string.d.ts"]=!0;h["lib.es2019.symbol.d.ts"]=!0;h["lib.es2020.bigint.d.ts"]=!0;h["lib.es2020.d.ts"]=!0;h["lib.es2020.full.d.ts"]=!0;h["lib.es2020.intl.d.ts"]=!0;h["lib.es2020.promise.d.ts"]=!0;h["lib.es2020.string.d.ts"]=!0;h["lib.es2020.symbol.wellknown.d.ts"]=!0;h["lib.es5.d.ts"]=!0;h["lib.es6.d.ts"]=!0;h["lib.esnext.d.ts"]=!0;h["lib.esnext.full.d.ts"]=!0;h["lib.esnext.intl.d.ts"]=!0;h["lib.esnext.promise.d.ts"]=!0;h["lib.esnext.string.d.ts"]=!0;h["lib.scripthost.d.ts"]=!0;h["lib.webworker.d.ts"]=!0;h["lib.webworker.importscripts.d.ts"]=!0;var d=O(N());"use strict";var w=function(){var e=function(r,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},e(r,t)};return function(r,t){e(r,t);function n(){this.constructor=r}r.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),S=function(e,r,t,n){function o(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function c(u){try{s(n.next(u))}catch(f){a(f)}}function l(u){try{s(n.throw(u))}catch(f){a(f)}}function s(u){u.done?i(u.value):o(u.value).then(c,l)}s((n=n.apply(e,r||[])).next())})},_=function(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(s){return function(u){return l([s,u])}}function l(s){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,o&&(i=s[0]&2?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;(o=0,i)&&(s=[s[0]&2,i.value]);switch(s[0]){case 0:case 1:i=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,o=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){t.label=s[1];break}if(s[0]===6&&t.label<i[1]){t.label=i[1],i=s;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(s);break}i[2]&&t.ops.pop(),t.trys.pop();continue}s=r.call(e,t)}catch(u){s=[6,u],o=0}finally{n=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},W;(function(e){e[e.None=0]="None",e[e.Block=1]="Block",e[e.Smart=2]="Smart"})(W||(W={}));function j(e,r,t){if(t===void 0&&(t=0),typeof e=="string")return e;if(e===void 0)return"";var n="";if(t){n+=r;for(var o=0;o<t;o++)n+=" "}if(n+=e.messageText,t++,e.next)for(var i=0,a=e.next;i<a.length;i++){var c=a[i];n+=j(c,r,t)}return n}function C(e){return e?e.map(function(r){return r.text}).join(""):""}var A=function(){function e(r){this._worker=r}return e.prototype._textSpanToRange=function(r,t){var n=r.getPositionAt(t.start),o=r.getPositionAt(t.start+t.length),i=n.lineNumber,a=n.column,c=o.lineNumber,l=o.column;return{startLineNumber:i,startColumn:a,endLineNumber:c,endColumn:l}},e}(),Z=function(){function e(r){this._worker=r,this._libFiles={},this._hasFetchedLibFiles=!1,this._fetchLibFilesPromise=null}return e.prototype.isLibFile=function(r){return r&&r.path.indexOf("/lib.")===0?!!h[r.path.slice(1)]:!1},e.prototype.getOrCreateModel=function(r){var t=d.editor.getModel(r);return t||(this.isLibFile(r)&&this._hasFetchedLibFiles?d.editor.createModel(this._libFiles[r.path.slice(1)],"javascript",r):null)},e.prototype._containsLibFile=function(r){for(var t=0,n=r;t<n.length;t++){var o=n[t];if(this.isLibFile(o))return!0}return!1},e.prototype.fetchLibFilesIfNecessary=function(r){return S(this,void 0,void 0,function(){return _(this,function(t){switch(t.label){case 0:return this._containsLibFile(r)?[4,this._fetchLibFiles()]:[2];case 1:return t.sent(),[2]}})})},e.prototype._fetchLibFiles=function(){var r=this;return this._fetchLibFilesPromise||(this._fetchLibFilesPromise=this._worker().then(function(t){return t.getLibFiles()}).then(function(t){r._hasFetchedLibFiles=!0,r._libFiles=t})),this._fetchLibFilesPromise},e}(),D;(function(e){e[e.Warning=0]="Warning",e[e.Error=1]="Error",e[e.Suggestion=2]="Suggestion",e[e.Message=3]="Message"})(D||(D={}));var $=function(e){w(r,e);function r(t,n,o,i){var a=e.call(this,i)||this;a._libFiles=t,a._defaults=n,a._selector=o,a._disposables=[],a._listener=Object.create(null);var c=function(u){if(u.getModeId()!==o)return;var f,p=u.onDidChangeContent(function(){clearTimeout(f),f=setTimeout(function(){return a._doValidate(u)},500)});a._listener[u.uri.toString()]={dispose:function(){p.dispose(),clearTimeout(f)}},a._doValidate(u)},l=function(u){d.editor.setModelMarkers(u,a._selector,[]);var f=u.uri.toString();a._listener[f]&&(a._listener[f].dispose(),delete a._listener[f])};a._disposables.push(d.editor.onDidCreateModel(c)),a._disposables.push(d.editor.onWillDisposeModel(l)),a._disposables.push(d.editor.onDidChangeModelLanguage(function(u){l(u.model),c(u.model)})),a._disposables.push({dispose:function(){for(var u=0,f=d.editor.getModels();u<f.length;u++){var p=f[u];l(p)}}});var s=function(){for(var u=0,f=d.editor.getModels();u<f.length;u++){var p=f[u];l(p),c(p)}};return a._disposables.push(a._defaults.onDidChange(s)),a._disposables.push(a._defaults.onDidExtraLibsChange(s)),d.editor.getModels().forEach(c),a}return r.prototype.dispose=function(){this._disposables.forEach(function(t){return t&&t.dispose()}),this._disposables=[]},r.prototype._doValidate=function(t){return S(this,void 0,void 0,function(){var n,o,i,a,c,l,s,u,f,p=this;return _(this,function(b){switch(b.label){case 0:return[4,this._worker(t.uri)];case 1:return n=b.sent(),t.isDisposed()?[2]:(o=[],i=this._defaults.getDiagnosticsOptions(),a=i.noSyntaxValidation,c=i.noSemanticValidation,l=i.noSuggestionDiagnostics,a||o.push(n.getSyntacticDiagnostics(t.uri.toString())),c||o.push(n.getSemanticDiagnostics(t.uri.toString())),l||o.push(n.getSuggestionDiagnostics(t.uri.toString())),[4,Promise.all(o)]);case 2:return s=b.sent(),!s||t.isDisposed()?[2]:(u=s.reduce(function(g,m){return m.concat(g)},[]).filter(function(g){return(p._defaults.getDiagnosticsOptions().diagnosticCodesToIgnore||[]).indexOf(g.code)===-1}),f=u.map(function(g){return g.relatedInformation||[]}).reduce(function(g,m){return m.concat(g)},[]).map(function(g){return g.file?d.Uri.parse(g.file.fileName):null}),[4,this._libFiles.fetchLibFilesIfNecessary(f)]);case 3:return b.sent(),t.isDisposed()?[2]:(d.editor.setModelMarkers(t,this._selector,u.map(function(g){return p._convertDiagnostics(t,g)})),[2])}})})},r.prototype._convertDiagnostics=function(t,n){var o=n.start||0,i=n.length||1,a=t.getPositionAt(o),c=a.lineNumber,l=a.column,s=t.getPositionAt(o+i),u=s.lineNumber,f=s.column,p=[];return n.reportsUnnecessary&&p.push(d.MarkerTag.Unnecessary),n.reportsDeprecated&&p.push(d.MarkerTag.Deprecated),{severity:this._tsDiagnosticCategoryToMarkerSeverity(n.category),startLineNumber:c,startColumn:l,endLineNumber:u,endColumn:f,message:j(n.messageText,` `),code:n.code.toString(),tags:p,relatedInformation:this._convertRelatedInformation(t,n.relatedInformation)}},r.prototype._convertRelatedInformation=function(t,n){var o=this;if(!n)return;var i=[];return n.forEach(function(a){var c=t;if(a.file){var l=d.Uri.parse(a.file.fileName);c=o._libFiles.getOrCreateModel(l)}if(!c)return;var s=a.start||0,u=a.length||1,f=c.getPositionAt(s),p=f.lineNumber,b=f.column,g=c.getPositionAt(s+u),m=g.lineNumber,y=g.column;i.push({resource:c.uri,startLineNumber:p,startColumn:b,endLineNumber:m,endColumn:y,message:j(a.messageText,` `)})}),i},r.prototype._tsDiagnosticCategoryToMarkerSeverity=function(t){switch(t){case D.Error:return d.MarkerSeverity.Error;case D.Message:return d.MarkerSeverity.Info;case D.Warning:return d.MarkerSeverity.Warning;case D.Suggestion:return d.MarkerSeverity.Hint}return d.MarkerSeverity.Info},r}(A),te=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"triggerCharacters",{get:function(){return["."]},enumerable:!1,configurable:!0}),r.prototype.provideCompletionItems=function(t,n,o,i){return S(this,void 0,void 0,function(){var a,c,l,s,u,f,p;return _(this,function(b){switch(b.label){case 0:return a=t.getWordUntilPosition(n),c=new d.Range(n.lineNumber,a.startColumn,n.lineNumber,a.endColumn),l=t.uri,s=t.getOffsetAt(n),[4,this._worker(l)];case 1:return u=b.sent(),[4,u.getCompletionsAtPosition(l.toString(),s)];case 2:return f=b.sent(),!f||t.isDisposed()?[2]:(p=f.entries.map(function(g){var m,y=c;if(g.replacementSpan){var L=t.getPositionAt(g.replacementSpan.start),z=t.getPositionAt(g.replacementSpan.start+g.replacementSpan.length);y=new d.Range(L.lineNumber,L.column,z.lineNumber,z.column)}var G=[];return((m=g.kindModifiers)===null||m===void 0?void 0:m.indexOf("deprecated"))!==-1&&G.push(d.languages.CompletionItemTag.Deprecated),{uri:l,position:n,offset:s,range:y,label:g.name,insertText:g.name,sortText:g.sortText,kind:r.convertKind(g.kind),tags:G}}),[2,{suggestions:p}])}})})},r.prototype.resolveCompletionItem=function(t,n){return S(this,void 0,void 0,function(){var o,i,a,c,l,s;return _(this,function(u){switch(u.label){case 0:return o=t,i=o.uri,a=o.position,c=o.offset,[4,this._worker(i)];case 1:return l=u.sent(),[4,l.getCompletionEntryDetails(i.toString(),c,o.label)];case 2:return s=u.sent(),s?[2,{uri:i,position:a,label:s.name,kind:r.convertKind(s.kind),detail:C(s.displayParts),documentation:{value:r.createDocumentationString(s)}}]:[2,o]}})})},r.convertKind=function(t){switch(t){case v.primitiveType:case v.keyword:return d.languages.CompletionItemKind.Keyword;case v.variable:case v.localVariable:return d.languages.CompletionItemKind.Variable;case v.memberVariable:case v.memberGetAccessor:case v.memberSetAccessor:return d.languages.CompletionItemKind.Field;case v.function:case v.memberFunction:case v.constructSignature:case v.callSignature:case v.indexSignature:return d.languages.CompletionItemKind.Function;case v.enum:return d.languages.CompletionItemKind.Enum;case v.module:return d.languages.CompletionItemKind.Module;case v.class:return d.languages.CompletionItemKind.Class;case v.interface:return d.languages.CompletionItemKind.Interface;case v.warning:return d.languages.CompletionItemKind.File}return d.languages.CompletionItemKind.Property},r.createDocumentationString=function(t){var n=C(t.documentation);if(t.tags)for(var o=0,i=t.tags;o<i.length;o++){var a=i[o];n+=` `+ee(a)}return n},r}(A);function ee(e){var r="*@"+e.name+"*";if(e.name==="param"&&e.text){var t=e.text.split(" "),n=t[0],o=t.slice(1);r+="`"+n+"`",o.length>0&&(r+=" \u2014 "+o.join(" "))}else e.text&&(r+=" \u2014 "+e.text);return r}var re=function(e){w(r,e);function r(){var t=e!==null&&e.apply(this,arguments)||this;return t.signatureHelpTriggerCharacters=["(",","],t}return r.prototype.provideSignatureHelp=function(t,n,o){return S(this,void 0,void 0,function(){var i,a,c,l,s;return _(this,function(u){switch(u.label){case 0:return i=t.uri,a=t.getOffsetAt(n),[4,this._worker(i)];case 1:return c=u.sent(),[4,c.getSignatureHelpItems(i.toString(),a)];case 2:return l=u.sent(),!l||t.isDisposed()?[2]:(s={activeSignature:l.selectedItemIndex,activeParameter:l.argumentIndex,signatures:[]},l.items.forEach(function(f){var p={label:"",parameters:[]};p.documentation={value:C(f.documentation)},p.label+=C(f.prefixDisplayParts),f.parameters.forEach(function(b,g,m){var y=C(b.displayParts),L={label:y,documentation:{value:C(b.documentation)}};p.label+=y,p.parameters.push(L),g<m.length-1&&(p.label+=C(f.separatorDisplayParts))}),p.label+=C(f.suffixDisplayParts),s.signatures.push(p)}),[2,{value:s,dispose:function(){}}])}})})},r}(A),ne=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype.provideHover=function(t,n,o){return S(this,void 0,void 0,function(){var i,a,c,l,s,u,f;return _(this,function(p){switch(p.label){case 0:return i=t.uri,a=t.getOffsetAt(n),[4,this._worker(i)];case 1:return c=p.sent(),[4,c.getQuickInfoAtPosition(i.toString(),a)];case 2:return l=p.sent(),!l||t.isDisposed()?[2]:(s=C(l.documentation),u=l.tags?l.tags.map(function(b){return ee(b)}).join(` `):"",f=C(l.displayParts),[2,{range:this._textSpanToRange(t,l.textSpan),contents:[{value:"```typescript\n"+f+"\n```\n"},{value:s+(u?` `+u:"")}]}])}})})},r}(A),ie=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype.provideDocumentHighlights=function(t,n,o){return S(this,void 0,void 0,function(){var i,a,c,l,s=this;return _(this,function(u){switch(u.label){case 0:return i=t.uri,a=t.getOffsetAt(n),[4,this._worker(i)];case 1:return c=u.sent(),[4,c.getOccurrencesAtPosition(i.toString(),a)];case 2:return l=u.sent(),!l||t.isDisposed()?[2]:[2,l.map(function(f){return{range:s._textSpanToRange(t,f.textSpan),kind:f.isWriteAccess?d.languages.DocumentHighlightKind.Write:d.languages.DocumentHighlightKind.Text}})]}})})},r}(A),se=function(e){w(r,e);function r(t,n){var o=e.call(this,n)||this;return o._libFiles=t,o}return r.prototype.provideDefinition=function(t,n,o){return S(this,void 0,void 0,function(){var i,a,c,l,s,u,f,p,b,g;return _(this,function(m){switch(m.label){case 0:return i=t.uri,a=t.getOffsetAt(n),[4,this._worker(i)];case 1:return c=m.sent(),[4,c.getDefinitionAtPosition(i.toString(),a)];case 2:return l=m.sent(),!l||t.isDisposed()?[2]:[4,this._libFiles.fetchLibFilesIfNecessary(l.map(function(y){return d.Uri.parse(y.fileName)}))];case 3:if(m.sent(),t.isDisposed())return[2];for(s=[],u=0,f=l;u<f.length;u++)p=f[u],b=d.Uri.parse(p.fileName),g=this._libFiles.getOrCreateModel(b),g&&s.push({uri:b,range:this._textSpanToRange(g,p.textSpan)});return[2,s]}})})},r}(A),oe=function(e){w(r,e);function r(t,n){var o=e.call(this,n)||this;return o._libFiles=t,o}return r.prototype.provideReferences=function(t,n,o,i){return S(this,void 0,void 0,function(){var a,c,l,s,u,f,p,b,g,m;return _(this,function(y){switch(y.label){case 0:return a=t.uri,c=t.getOffsetAt(n),[4,this._worker(a)];case 1:return l=y.sent(),[4,l.getReferencesAtPosition(a.toString(),c)];case 2:return s=y.sent(),!s||t.isDisposed()?[2]:[4,this._libFiles.fetchLibFilesIfNecessary(s.map(function(L){return d.Uri.parse(L.fileName)}))];case 3:if(y.sent(),t.isDisposed())return[2];for(u=[],f=0,p=s;f<p.length;f++)b=p[f],g=d.Uri.parse(b.fileName),m=this._libFiles.getOrCreateModel(g),m&&u.push({uri:g,range:this._textSpanToRange(m,b.textSpan)});return[2,u]}})})},r}(A),ae=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype.provideDocumentSymbols=function(t,n){return S(this,void 0,void 0,function(){var o,i,a,c,l,s=this;return _(this,function(u){switch(u.label){case 0:return o=t.uri,[4,this._worker(o)];case 1:return i=u.sent(),[4,i.getNavigationBarItems(o.toString())];case 2:return a=u.sent(),!a||t.isDisposed()?[2]:(c=function(f,p,b){var g={name:p.text,detail:"",kind:x[p.kind]||d.languages.SymbolKind.Variable,range:s._textSpanToRange(t,p.spans[0]),selectionRange:s._textSpanToRange(t,p.spans[0]),tags:[],containerName:b};if(p.childItems&&p.childItems.length>0)for(var m=0,y=p.childItems;m<y.length;m++){var L=y[m];c(f,L,g.name)}f.push(g)},l=[],a.forEach(function(f){return c(l,f)}),[2,l])}})})},r}(A),v=function(){function e(){}return e.unknown="",e.keyword="keyword",e.script="script",e.module="module",e.class="class",e.interface="interface",e.type="type",e.enum="enum",e.variable="var",e.localVariable="local var",e.function="function",e.localFunction="local function",e.memberFunction="method",e.memberGetAccessor="getter",e.memberSetAccessor="setter",e.memberVariable="property",e.constructorImplementation="constructor",e.callSignature="call",e.indexSignature="index",e.constructSignature="construct",e.parameter="parameter",e.typeParameter="type parameter",e.primitiveType="primitive type",e.label="label",e.alias="alias",e.const="const",e.let="let",e.warning="warning",e}(),x=Object.create(null);x[v.module]=d.languages.SymbolKind.Module;x[v.class]=d.languages.SymbolKind.Class;x[v.enum]=d.languages.SymbolKind.Enum;x[v.interface]=d.languages.SymbolKind.Interface;x[v.memberFunction]=d.languages.SymbolKind.Method;x[v.memberVariable]=d.languages.SymbolKind.Property;x[v.memberGetAccessor]=d.languages.SymbolKind.Property;x[v.memberSetAccessor]=d.languages.SymbolKind.Property;x[v.variable]=d.languages.SymbolKind.Variable;x[v.const]=d.languages.SymbolKind.Variable;x[v.localVariable]=d.languages.SymbolKind.Variable;x[v.variable]=d.languages.SymbolKind.Variable;x[v.function]=d.languages.SymbolKind.Function;x[v.localFunction]=d.languages.SymbolKind.Function;var E=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r._convertOptions=function(t){return{ConvertTabsToSpaces:t.insertSpaces,TabSize:t.tabSize,IndentSize:t.tabSize,IndentStyle:W.Smart,NewLineCharacter:` `,InsertSpaceAfterCommaDelimiter:!0,InsertSpaceAfterSemicolonInForStatements:!0,InsertSpaceBeforeAndAfterBinaryOperators:!0,InsertSpaceAfterKeywordsInControlFlowStatements:!0,InsertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis:!1,InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets:!1,InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces:!1,PlaceOpenBraceOnNewLineForControlBlocks:!1,PlaceOpenBraceOnNewLineForFunctions:!1}},r.prototype._convertTextChanges=function(t,n){return{text:n.newText,range:this._textSpanToRange(t,n.span)}},r}(A),ue=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype.provideDocumentRangeFormattingEdits=function(t,n,o,i){return S(this,void 0,void 0,function(){var a,c,l,s,u,f=this;return _(this,function(p){switch(p.label){case 0:return a=t.uri,c=t.getOffsetAt({lineNumber:n.startLineNumber,column:n.startColumn}),l=t.getOffsetAt({lineNumber:n.endLineNumber,column:n.endColumn}),[4,this._worker(a)];case 1:return s=p.sent(),[4,s.getFormattingEditsForRange(a.toString(),c,l,E._convertOptions(o))];case 2:return u=p.sent(),!u||t.isDisposed()?[2]:[2,u.map(function(b){return f._convertTextChanges(t,b)})]}})})},r}(E),ce=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"autoFormatTriggerCharacters",{get:function(){return[";","}",` `]},enumerable:!1,configurable:!0}),r.prototype.provideOnTypeFormattingEdits=function(t,n,o,i,a){return S(this,void 0,void 0,function(){var c,l,s,u,f=this;return _(this,function(p){switch(p.label){case 0:return c=t.uri,l=t.getOffsetAt(n),[4,this._worker(c)];case 1:return s=p.sent(),[4,s.getFormattingEditsAfterKeystroke(c.toString(),l,o,E._convertOptions(i))];case 2:return u=p.sent(),!u||t.isDisposed()?[2]:[2,u.map(function(b){return f._convertTextChanges(t,b)})]}})})},r}(E),le=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype.provideCodeActions=function(t,n,o,i){return S(this,void 0,void 0,function(){var a,c,l,s,u,f,p,b,g=this;return _(this,function(m){switch(m.label){case 0:return a=t.uri,c=t.getOffsetAt({lineNumber:n.startLineNumber,column:n.startColumn}),l=t.getOffsetAt({lineNumber:n.endLineNumber,column:n.endColumn}),s=E._convertOptions(t.getOptions()),u=o.markers.filter(function(y){return y.code}).map(function(y){return y.code}).map(Number),[4,this._worker(a)];case 1:return f=m.sent(),[4,f.getCodeFixesAtPosition(a.toString(),c,l,u,s)];case 2:return p=m.sent(),!p||t.isDisposed()?[2,{actions:[],dispose:function(){}}]:(b=p.filter(function(y){return y.changes.filter(function(L){return L.isNewFile}).length===0}).map(function(y){return g._tsCodeFixActionToMonacoCodeAction(t,o,y)}),[2,{actions:b,dispose:function(){}}])}})})},r.prototype._tsCodeFixActionToMonacoCodeAction=function(t,n,o){for(var i=[],a=0,c=o.changes;a<c.length;a++)for(var l=c[a],s=0,u=l.textChanges;s<u.length;s++){var f=u[s];i.push({resource:t.uri,edit:{range:this._textSpanToRange(t,f.span),text:f.newText}})}var p={title:o.description,edit:{edits:i},diagnostics:n.markers,kind:"quickfix"};return p},r}(E),fe=function(e){w(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return r.prototype.provideRenameEdits=function(t,n,o,i){return S(this,void 0,void 0,function(){var a,c,l,s,u,f,p,b,g,m;return _(this,function(y){switch(y.label){case 0:return a=t.uri,c=a.toString(),l=t.getOffsetAt(n),[4,this._worker(a)];case 1:return s=y.sent(),[4,s.getRenameInfo(c,l,{allowRenameOfImportPath:!1})];case 2:if(u=y.sent(),u.canRename===!1)return[2,{edits:[],rejectReason:u.localizedErrorMessage}];if(u.fileToRename!==void 0)throw new Error("Renaming files is not supported.");return[4,s.findRenameLocations(c,l,!1,!1,!1)];case 3:if(f=y.sent(),!f||t.isDisposed())return[2];for(p=[],b=0,g=f;b<g.length;b++)m=g[b],p.push({resource:d.Uri.parse(m.fileName),edit:{range:this._textSpanToRange(t,m.textSpan),text:o}});return[2,{edits:p}]}})})},r}(A);function I(){return Promise.resolve().then(()=>O(de()))}F.languages.onLanguage("typescript",function(){return I().then(function(e){return e.setupTypeScript(ge)})});F.languages.onLanguage("javascript",function(){return I().then(function(e){return e.setupJavaScript(be)})});})();