import { m as editor_api_exports } from "./editor.api-erJ7GEVs.js";
import { l as typescriptDefaults } from "./monaco.contribution-CoVlf0Jr.js";
/*!-----------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
* Released under the MIT license
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
*-----------------------------------------------------------------------------*/
var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __hasOwnProp = Object.prototype.hasOwnProperty, __copyProps = (u, A, F, I) => {
	if (A && typeof A == "object" || typeof A == "function") for (let L of __getOwnPropNames(A)) !__hasOwnProp.call(u, L) && L !== F && __defProp(u, L, {
		get: () => A[L],
		enumerable: !(I = __getOwnPropDesc(A, L)) || I.enumerable
	});
	return u;
}, __reExport = (u, A, j) => (__copyProps(u, A, "default"), j && __copyProps(j, A, "default")), monaco_editor_core_exports = {};
__reExport(monaco_editor_core_exports, editor_api_exports);
var WorkerManager = class {
	constructor(u, A) {
		this._modeId = u, this._defaults = A, this._worker = null, this._client = null, this._configChangeListener = this._defaults.onDidChange(() => this._stopWorker()), this._updateExtraLibsToken = 0, this._extraLibsChangeListener = this._defaults.onDidExtraLibsChange(() => this._updateExtraLibs());
	}
	dispose() {
		this._configChangeListener.dispose(), this._extraLibsChangeListener.dispose(), this._stopWorker();
	}
	_stopWorker() {
		this._worker &&= (this._worker.dispose(), null), this._client = null;
	}
	async _updateExtraLibs() {
		if (!this._worker) return;
		let u = ++this._updateExtraLibsToken, A = await this._worker.getProxy();
		this._updateExtraLibsToken === u && A.updateExtraLibs(this._defaults.getExtraLibs());
	}
	_getClient() {
		return this._client ||= (async () => (this._worker = monaco_editor_core_exports.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,
				inlayHintsOptions: this._defaults.inlayHintsOptions
			}
		}), this._defaults.getEagerModelSync() ? await this._worker.withSyncedResources(monaco_editor_core_exports.editor.getModels().filter((u) => u.getLanguageId() === this._modeId).map((u) => u.uri)) : await this._worker.getProxy()))(), this._client;
	}
	async getLanguageServiceWorker(...u) {
		let A = await this._getClient();
		return this._worker && await this._worker.withSyncedResources(u), A;
	}
}, libFileSet = {};
libFileSet["lib.d.ts"] = !0, libFileSet["lib.decorators.d.ts"] = !0, libFileSet["lib.decorators.legacy.d.ts"] = !0, libFileSet["lib.dom.asynciterable.d.ts"] = !0, libFileSet["lib.dom.d.ts"] = !0, libFileSet["lib.dom.iterable.d.ts"] = !0, libFileSet["lib.es2015.collection.d.ts"] = !0, libFileSet["lib.es2015.core.d.ts"] = !0, libFileSet["lib.es2015.d.ts"] = !0, libFileSet["lib.es2015.generator.d.ts"] = !0, libFileSet["lib.es2015.iterable.d.ts"] = !0, libFileSet["lib.es2015.promise.d.ts"] = !0, libFileSet["lib.es2015.proxy.d.ts"] = !0, libFileSet["lib.es2015.reflect.d.ts"] = !0, libFileSet["lib.es2015.symbol.d.ts"] = !0, libFileSet["lib.es2015.symbol.wellknown.d.ts"] = !0, libFileSet["lib.es2016.array.include.d.ts"] = !0, libFileSet["lib.es2016.d.ts"] = !0, libFileSet["lib.es2016.full.d.ts"] = !0, libFileSet["lib.es2016.intl.d.ts"] = !0, libFileSet["lib.es2017.d.ts"] = !0, libFileSet["lib.es2017.date.d.ts"] = !0, libFileSet["lib.es2017.full.d.ts"] = !0, libFileSet["lib.es2017.intl.d.ts"] = !0, libFileSet["lib.es2017.object.d.ts"] = !0, libFileSet["lib.es2017.sharedmemory.d.ts"] = !0, libFileSet["lib.es2017.string.d.ts"] = !0, libFileSet["lib.es2017.typedarrays.d.ts"] = !0, libFileSet["lib.es2018.asyncgenerator.d.ts"] = !0, libFileSet["lib.es2018.asynciterable.d.ts"] = !0, libFileSet["lib.es2018.d.ts"] = !0, libFileSet["lib.es2018.full.d.ts"] = !0, libFileSet["lib.es2018.intl.d.ts"] = !0, libFileSet["lib.es2018.promise.d.ts"] = !0, libFileSet["lib.es2018.regexp.d.ts"] = !0, libFileSet["lib.es2019.array.d.ts"] = !0, libFileSet["lib.es2019.d.ts"] = !0, libFileSet["lib.es2019.full.d.ts"] = !0, libFileSet["lib.es2019.intl.d.ts"] = !0, libFileSet["lib.es2019.object.d.ts"] = !0, libFileSet["lib.es2019.string.d.ts"] = !0, libFileSet["lib.es2019.symbol.d.ts"] = !0, libFileSet["lib.es2020.bigint.d.ts"] = !0, libFileSet["lib.es2020.d.ts"] = !0, libFileSet["lib.es2020.date.d.ts"] = !0, libFileSet["lib.es2020.full.d.ts"] = !0, libFileSet["lib.es2020.intl.d.ts"] = !0, libFileSet["lib.es2020.number.d.ts"] = !0, libFileSet["lib.es2020.promise.d.ts"] = !0, libFileSet["lib.es2020.sharedmemory.d.ts"] = !0, libFileSet["lib.es2020.string.d.ts"] = !0, libFileSet["lib.es2020.symbol.wellknown.d.ts"] = !0, libFileSet["lib.es2021.d.ts"] = !0, libFileSet["lib.es2021.full.d.ts"] = !0, libFileSet["lib.es2021.intl.d.ts"] = !0, libFileSet["lib.es2021.promise.d.ts"] = !0, libFileSet["lib.es2021.string.d.ts"] = !0, libFileSet["lib.es2021.weakref.d.ts"] = !0, libFileSet["lib.es2022.array.d.ts"] = !0, libFileSet["lib.es2022.d.ts"] = !0, libFileSet["lib.es2022.error.d.ts"] = !0, libFileSet["lib.es2022.full.d.ts"] = !0, libFileSet["lib.es2022.intl.d.ts"] = !0, libFileSet["lib.es2022.object.d.ts"] = !0, libFileSet["lib.es2022.regexp.d.ts"] = !0, libFileSet["lib.es2022.sharedmemory.d.ts"] = !0, libFileSet["lib.es2022.string.d.ts"] = !0, libFileSet["lib.es2023.array.d.ts"] = !0, libFileSet["lib.es2023.collection.d.ts"] = !0, libFileSet["lib.es2023.d.ts"] = !0, libFileSet["lib.es2023.full.d.ts"] = !0, libFileSet["lib.es5.d.ts"] = !0, libFileSet["lib.es6.d.ts"] = !0, libFileSet["lib.esnext.collection.d.ts"] = !0, libFileSet["lib.esnext.d.ts"] = !0, libFileSet["lib.esnext.decorators.d.ts"] = !0, libFileSet["lib.esnext.disposable.d.ts"] = !0, libFileSet["lib.esnext.full.d.ts"] = !0, libFileSet["lib.esnext.intl.d.ts"] = !0, libFileSet["lib.esnext.object.d.ts"] = !0, libFileSet["lib.esnext.promise.d.ts"] = !0, libFileSet["lib.scripthost.d.ts"] = !0, libFileSet["lib.webworker.asynciterable.d.ts"] = !0, libFileSet["lib.webworker.d.ts"] = !0, libFileSet["lib.webworker.importscripts.d.ts"] = !0, libFileSet["lib.webworker.iterable.d.ts"] = !0;
function flattenDiagnosticMessageText(u, A, j = 0) {
	if (typeof u == "string") return u;
	if (u === void 0) return "";
	let M = "";
	if (j) {
		M += A;
		for (let u = 0; u < j; u++) M += "  ";
	}
	if (M += u.messageText, j++, u.next) for (let N of u.next) M += flattenDiagnosticMessageText(N, A, j);
	return M;
}
function displayPartsToString(u) {
	return u ? u.map((u) => u.text).join("") : "";
}
var Adapter = class {
	constructor(u) {
		this._worker = u;
	}
	_textSpanToRange(u, A) {
		let j = u.getPositionAt(A.start), M = u.getPositionAt(A.start + A.length), { lineNumber: N, column: P } = j, { lineNumber: F, column: I } = M;
		return {
			startLineNumber: N,
			startColumn: P,
			endLineNumber: F,
			endColumn: I
		};
	}
}, LibFiles = class {
	constructor(u) {
		this._worker = u, this._libFiles = {}, this._hasFetchedLibFiles = !1, this._fetchLibFilesPromise = null;
	}
	isLibFile(u) {
		return u && u.path.indexOf("/lib.") === 0 ? !!libFileSet[u.path.slice(1)] : !1;
	}
	getOrCreateModel(u) {
		let j = monaco_editor_core_exports.Uri.parse(u), M = monaco_editor_core_exports.editor.getModel(j);
		if (M) return M;
		if (this.isLibFile(j) && this._hasFetchedLibFiles) return monaco_editor_core_exports.editor.createModel(this._libFiles[j.path.slice(1)], "typescript", j);
		let N = typescriptDefaults.getExtraLibs()[u];
		return N ? monaco_editor_core_exports.editor.createModel(N.content, "typescript", j) : null;
	}
	_containsLibFile(u) {
		for (let A of u) if (this.isLibFile(A)) return !0;
		return !1;
	}
	async fetchLibFilesIfNecessary(u) {
		this._containsLibFile(u) && await this._fetchLibFiles();
	}
	_fetchLibFiles() {
		return this._fetchLibFilesPromise ||= this._worker().then((u) => u.getLibFiles()).then((u) => {
			this._hasFetchedLibFiles = !0, this._libFiles = u;
		}), this._fetchLibFilesPromise;
	}
}, DiagnosticsAdapter = class extends Adapter {
	constructor(u, A, j, M) {
		super(M), this._libFiles = u, this._defaults = A, this._selector = j, this._disposables = [], this._listener = /* @__PURE__ */ Object.create(null);
		let N = (u) => {
			if (u.getLanguageId() !== j) return;
			let A = () => {
				let { onlyVisible: A } = this._defaults.getDiagnosticsOptions();
				A ? u.isAttachedToEditor() && this._doValidate(u) : this._doValidate(u);
			}, M, N = u.onDidChangeContent(() => {
				clearTimeout(M), M = window.setTimeout(A, 500);
			}), P = u.onDidChangeAttached(() => {
				let { onlyVisible: j } = this._defaults.getDiagnosticsOptions();
				j && (u.isAttachedToEditor() ? A() : monaco_editor_core_exports.editor.setModelMarkers(u, this._selector, []));
			});
			this._listener[u.uri.toString()] = { dispose() {
				N.dispose(), P.dispose(), clearTimeout(M);
			} }, A();
		}, P = (u) => {
			monaco_editor_core_exports.editor.setModelMarkers(u, this._selector, []);
			let A = u.uri.toString();
			this._listener[A] && (this._listener[A].dispose(), delete this._listener[A]);
		};
		this._disposables.push(monaco_editor_core_exports.editor.onDidCreateModel((u) => N(u))), this._disposables.push(monaco_editor_core_exports.editor.onWillDisposeModel(P)), this._disposables.push(monaco_editor_core_exports.editor.onDidChangeModelLanguage((u) => {
			P(u.model), N(u.model);
		})), this._disposables.push({ dispose() {
			for (let u of monaco_editor_core_exports.editor.getModels()) P(u);
		} });
		let F = () => {
			for (let u of monaco_editor_core_exports.editor.getModels()) P(u), N(u);
		};
		this._disposables.push(this._defaults.onDidChange(F)), this._disposables.push(this._defaults.onDidExtraLibsChange(F)), monaco_editor_core_exports.editor.getModels().forEach((u) => N(u));
	}
	dispose() {
		this._disposables.forEach((u) => u && u.dispose()), this._disposables = [];
	}
	async _doValidate(u) {
		let A = await this._worker(u.uri);
		if (u.isDisposed()) return;
		let j = [], { noSyntaxValidation: M, noSemanticValidation: N, noSuggestionDiagnostics: P } = this._defaults.getDiagnosticsOptions();
		M || j.push(A.getSyntacticDiagnostics(u.uri.toString())), N || j.push(A.getSemanticDiagnostics(u.uri.toString())), P || j.push(A.getSuggestionDiagnostics(u.uri.toString()));
		let F = await Promise.all(j);
		if (!F || u.isDisposed()) return;
		let I = F.reduce((u, A) => A.concat(u), []).filter((u) => (this._defaults.getDiagnosticsOptions().diagnosticCodesToIgnore || []).indexOf(u.code) === -1), R = I.map((u) => u.relatedInformation || []).reduce((u, A) => A.concat(u), []).map((u) => u.file ? monaco_editor_core_exports.Uri.parse(u.file.fileName) : null);
		await this._libFiles.fetchLibFilesIfNecessary(R), !u.isDisposed() && monaco_editor_core_exports.editor.setModelMarkers(u, this._selector, I.map((A) => this._convertDiagnostics(u, A)));
	}
	_convertDiagnostics(u, A) {
		let j = A.start || 0, M = A.length || 1, { lineNumber: N, column: P } = u.getPositionAt(j), { lineNumber: F, column: I } = u.getPositionAt(j + M), R = [];
		return A.reportsUnnecessary && R.push(monaco_editor_core_exports.MarkerTag.Unnecessary), A.reportsDeprecated && R.push(monaco_editor_core_exports.MarkerTag.Deprecated), {
			severity: this._tsDiagnosticCategoryToMarkerSeverity(A.category),
			startLineNumber: N,
			startColumn: P,
			endLineNumber: F,
			endColumn: I,
			message: flattenDiagnosticMessageText(A.messageText, "\n"),
			code: A.code.toString(),
			tags: R,
			relatedInformation: this._convertRelatedInformation(u, A.relatedInformation)
		};
	}
	_convertRelatedInformation(u, A) {
		if (!A) return [];
		let j = [];
		return A.forEach((A) => {
			let M = u;
			if (A.file && (M = this._libFiles.getOrCreateModel(A.file.fileName)), !M) return;
			let N = A.start || 0, P = A.length || 1, { lineNumber: F, column: I } = M.getPositionAt(N), { lineNumber: L, column: R } = M.getPositionAt(N + P);
			j.push({
				resource: M.uri,
				startLineNumber: F,
				startColumn: I,
				endLineNumber: L,
				endColumn: R,
				message: flattenDiagnosticMessageText(A.messageText, "\n")
			});
		}), j;
	}
	_tsDiagnosticCategoryToMarkerSeverity(u) {
		switch (u) {
			case 1: return monaco_editor_core_exports.MarkerSeverity.Error;
			case 3: return monaco_editor_core_exports.MarkerSeverity.Info;
			case 0: return monaco_editor_core_exports.MarkerSeverity.Warning;
			case 2: return monaco_editor_core_exports.MarkerSeverity.Hint;
		}
		return monaco_editor_core_exports.MarkerSeverity.Info;
	}
}, SuggestAdapter = class u extends Adapter {
	get triggerCharacters() {
		return ["."];
	}
	async provideCompletionItems(A, j, M, N) {
		let P = A.getWordUntilPosition(j), F = new monaco_editor_core_exports.Range(j.lineNumber, P.startColumn, j.lineNumber, P.endColumn), I = A.uri, R = A.getOffsetAt(j), z = await this._worker(I);
		if (A.isDisposed()) return;
		let B = await z.getCompletionsAtPosition(I.toString(), R);
		if (!(!B || A.isDisposed())) return { suggestions: B.entries.map((M) => {
			let N = F;
			if (M.replacementSpan) {
				let u = A.getPositionAt(M.replacementSpan.start), j = A.getPositionAt(M.replacementSpan.start + M.replacementSpan.length);
				N = new monaco_editor_core_exports.Range(u.lineNumber, u.column, j.lineNumber, j.column);
			}
			let P = [];
			return M.kindModifiers !== void 0 && M.kindModifiers.indexOf("deprecated") !== -1 && P.push(monaco_editor_core_exports.languages.CompletionItemTag.Deprecated), {
				uri: I,
				position: j,
				offset: R,
				range: N,
				label: M.name,
				insertText: M.name,
				sortText: M.sortText,
				kind: u.convertKind(M.kind),
				tags: P
			};
		}) };
	}
	async resolveCompletionItem(A, j) {
		let M = A, N = M.uri, P = M.position, F = M.offset, I = await (await this._worker(N)).getCompletionEntryDetails(N.toString(), F, M.label);
		return I ? {
			uri: N,
			position: P,
			label: I.name,
			kind: u.convertKind(I.kind),
			detail: displayPartsToString(I.displayParts),
			documentation: { value: u.createDocumentationString(I) }
		} : M;
	}
	static convertKind(u) {
		switch (u) {
			case Kind.primitiveType:
			case Kind.keyword: return monaco_editor_core_exports.languages.CompletionItemKind.Keyword;
			case Kind.variable:
			case Kind.localVariable: return monaco_editor_core_exports.languages.CompletionItemKind.Variable;
			case Kind.memberVariable:
			case Kind.memberGetAccessor:
			case Kind.memberSetAccessor: return monaco_editor_core_exports.languages.CompletionItemKind.Field;
			case Kind.function:
			case Kind.memberFunction:
			case Kind.constructSignature:
			case Kind.callSignature:
			case Kind.indexSignature: return monaco_editor_core_exports.languages.CompletionItemKind.Function;
			case Kind.enum: return monaco_editor_core_exports.languages.CompletionItemKind.Enum;
			case Kind.module: return monaco_editor_core_exports.languages.CompletionItemKind.Module;
			case Kind.class: return monaco_editor_core_exports.languages.CompletionItemKind.Class;
			case Kind.interface: return monaco_editor_core_exports.languages.CompletionItemKind.Interface;
			case Kind.warning: return monaco_editor_core_exports.languages.CompletionItemKind.File;
		}
		return monaco_editor_core_exports.languages.CompletionItemKind.Property;
	}
	static createDocumentationString(u) {
		let A = displayPartsToString(u.documentation);
		if (u.tags) for (let j of u.tags) A += `

${tagToString(j)}`;
		return A;
	}
};
function tagToString(u) {
	let A = `*@${u.name}*`;
	if (u.name === "param" && u.text) {
		let [j, ...M] = u.text;
		A += `\`${j.text}\``, M.length > 0 && (A += ` \u2014 ${M.map((u) => u.text).join(" ")}`);
	} else Array.isArray(u.text) ? A += ` \u2014 ${u.text.map((u) => u.text).join(" ")}` : u.text && (A += ` \u2014 ${u.text}`);
	return A;
}
var SignatureHelpAdapter = class u extends Adapter {
	constructor() {
		super(...arguments), this.signatureHelpTriggerCharacters = ["(", ","];
	}
	static _toSignatureHelpTriggerReason(u) {
		switch (u.triggerKind) {
			case monaco_editor_core_exports.languages.SignatureHelpTriggerKind.TriggerCharacter: return u.triggerCharacter ? u.isRetrigger ? {
				kind: "retrigger",
				triggerCharacter: u.triggerCharacter
			} : {
				kind: "characterTyped",
				triggerCharacter: u.triggerCharacter
			} : { kind: "invoked" };
			case monaco_editor_core_exports.languages.SignatureHelpTriggerKind.ContentChange: return u.isRetrigger ? { kind: "retrigger" } : { kind: "invoked" };
			case monaco_editor_core_exports.languages.SignatureHelpTriggerKind.Invoke:
			default: return { kind: "invoked" };
		}
	}
	async provideSignatureHelp(A, j, M, N) {
		let P = A.uri, F = A.getOffsetAt(j), I = await this._worker(P);
		if (A.isDisposed()) return;
		let L = await I.getSignatureHelpItems(P.toString(), F, { triggerReason: u._toSignatureHelpTriggerReason(N) });
		if (!L || A.isDisposed()) return;
		let R = {
			activeSignature: L.selectedItemIndex,
			activeParameter: L.argumentIndex,
			signatures: []
		};
		return L.items.forEach((u) => {
			let A = {
				label: "",
				parameters: []
			};
			A.documentation = { value: displayPartsToString(u.documentation) }, A.label += displayPartsToString(u.prefixDisplayParts), u.parameters.forEach((j, M, N) => {
				let P = displayPartsToString(j.displayParts), F = {
					label: P,
					documentation: { value: displayPartsToString(j.documentation) }
				};
				A.label += P, A.parameters.push(F), M < N.length - 1 && (A.label += displayPartsToString(u.separatorDisplayParts));
			}), A.label += displayPartsToString(u.suffixDisplayParts), R.signatures.push(A);
		}), {
			value: R,
			dispose() {}
		};
	}
}, QuickInfoAdapter = class extends Adapter {
	async provideHover(u, A, j) {
		let M = u.uri, N = u.getOffsetAt(A), P = await this._worker(M);
		if (u.isDisposed()) return;
		let F = await P.getQuickInfoAtPosition(M.toString(), N);
		if (!F || u.isDisposed()) return;
		let I = displayPartsToString(F.documentation), L = F.tags ? F.tags.map((u) => tagToString(u)).join("  \n\n") : "", R = displayPartsToString(F.displayParts);
		return {
			range: this._textSpanToRange(u, F.textSpan),
			contents: [{ value: "```typescript\n" + R + "\n```\n" }, { value: I + (L ? "\n\n" + L : "") }]
		};
	}
}, DocumentHighlightAdapter = class extends Adapter {
	async provideDocumentHighlights(u, A, j) {
		let M = u.uri, N = u.getOffsetAt(A), P = await this._worker(M);
		if (u.isDisposed()) return;
		let F = await P.getDocumentHighlights(M.toString(), N, [M.toString()]);
		if (!(!F || u.isDisposed())) return F.flatMap((A) => A.highlightSpans.map((A) => ({
			range: this._textSpanToRange(u, A.textSpan),
			kind: A.kind === "writtenReference" ? monaco_editor_core_exports.languages.DocumentHighlightKind.Write : monaco_editor_core_exports.languages.DocumentHighlightKind.Text
		})));
	}
}, DefinitionAdapter = class extends Adapter {
	constructor(u, A) {
		super(A), this._libFiles = u;
	}
	async provideDefinition(u, A, j) {
		let M = u.uri, N = u.getOffsetAt(A), P = await this._worker(M);
		if (u.isDisposed()) return;
		let F = await P.getDefinitionAtPosition(M.toString(), N);
		if (!F || u.isDisposed() || (await this._libFiles.fetchLibFilesIfNecessary(F.map((u) => monaco_editor_core_exports.Uri.parse(u.fileName))), u.isDisposed())) return;
		let I = [];
		for (let u of F) {
			let A = this._libFiles.getOrCreateModel(u.fileName);
			A && I.push({
				uri: A.uri,
				range: this._textSpanToRange(A, u.textSpan)
			});
		}
		return I;
	}
}, ReferenceAdapter = class extends Adapter {
	constructor(u, A) {
		super(A), this._libFiles = u;
	}
	async provideReferences(u, A, j, M) {
		let N = u.uri, P = u.getOffsetAt(A), F = await this._worker(N);
		if (u.isDisposed()) return;
		let I = await F.getReferencesAtPosition(N.toString(), P);
		if (!I || u.isDisposed() || (await this._libFiles.fetchLibFilesIfNecessary(I.map((u) => monaco_editor_core_exports.Uri.parse(u.fileName))), u.isDisposed())) return;
		let R = [];
		for (let u of I) {
			let A = this._libFiles.getOrCreateModel(u.fileName);
			A && R.push({
				uri: A.uri,
				range: this._textSpanToRange(A, u.textSpan)
			});
		}
		return R;
	}
}, OutlineAdapter = class extends Adapter {
	async provideDocumentSymbols(u, A) {
		let j = u.uri, M = await this._worker(j);
		if (u.isDisposed()) return;
		let N = await M.getNavigationTree(j.toString());
		if (!N || u.isDisposed()) return;
		let P = (A, j) => ({
			name: A.text,
			detail: "",
			kind: outlineTypeTable[A.kind] || monaco_editor_core_exports.languages.SymbolKind.Variable,
			range: this._textSpanToRange(u, A.spans[0]),
			selectionRange: this._textSpanToRange(u, A.spans[0]),
			tags: [],
			children: A.childItems?.map((u) => P(u, A.text)),
			containerName: j
		});
		return N.childItems ? N.childItems.map((u) => P(u)) : [];
	}
}, Kind = class {
	static {
		this.unknown = "";
	}
	static {
		this.keyword = "keyword";
	}
	static {
		this.script = "script";
	}
	static {
		this.module = "module";
	}
	static {
		this.class = "class";
	}
	static {
		this.interface = "interface";
	}
	static {
		this.type = "type";
	}
	static {
		this.enum = "enum";
	}
	static {
		this.variable = "var";
	}
	static {
		this.localVariable = "local var";
	}
	static {
		this.function = "function";
	}
	static {
		this.localFunction = "local function";
	}
	static {
		this.memberFunction = "method";
	}
	static {
		this.memberGetAccessor = "getter";
	}
	static {
		this.memberSetAccessor = "setter";
	}
	static {
		this.memberVariable = "property";
	}
	static {
		this.constructorImplementation = "constructor";
	}
	static {
		this.callSignature = "call";
	}
	static {
		this.indexSignature = "index";
	}
	static {
		this.constructSignature = "construct";
	}
	static {
		this.parameter = "parameter";
	}
	static {
		this.typeParameter = "type parameter";
	}
	static {
		this.primitiveType = "primitive type";
	}
	static {
		this.label = "label";
	}
	static {
		this.alias = "alias";
	}
	static {
		this.const = "const";
	}
	static {
		this.let = "let";
	}
	static {
		this.warning = "warning";
	}
}, outlineTypeTable = /* @__PURE__ */ Object.create(null);
outlineTypeTable[Kind.module] = monaco_editor_core_exports.languages.SymbolKind.Module, outlineTypeTable[Kind.class] = monaco_editor_core_exports.languages.SymbolKind.Class, outlineTypeTable[Kind.enum] = monaco_editor_core_exports.languages.SymbolKind.Enum, outlineTypeTable[Kind.interface] = monaco_editor_core_exports.languages.SymbolKind.Interface, outlineTypeTable[Kind.memberFunction] = monaco_editor_core_exports.languages.SymbolKind.Method, outlineTypeTable[Kind.memberVariable] = monaco_editor_core_exports.languages.SymbolKind.Property, outlineTypeTable[Kind.memberGetAccessor] = monaco_editor_core_exports.languages.SymbolKind.Property, outlineTypeTable[Kind.memberSetAccessor] = monaco_editor_core_exports.languages.SymbolKind.Property, outlineTypeTable[Kind.variable] = monaco_editor_core_exports.languages.SymbolKind.Variable, outlineTypeTable[Kind.const] = monaco_editor_core_exports.languages.SymbolKind.Variable, outlineTypeTable[Kind.localVariable] = monaco_editor_core_exports.languages.SymbolKind.Variable, outlineTypeTable[Kind.variable] = monaco_editor_core_exports.languages.SymbolKind.Variable, outlineTypeTable[Kind.function] = monaco_editor_core_exports.languages.SymbolKind.Function, outlineTypeTable[Kind.localFunction] = monaco_editor_core_exports.languages.SymbolKind.Function;
var FormatHelper = class extends Adapter {
	static _convertOptions(u) {
		return {
			ConvertTabsToSpaces: u.insertSpaces,
			TabSize: u.tabSize,
			IndentSize: u.tabSize,
			IndentStyle: 2,
			NewLineCharacter: "\n",
			InsertSpaceAfterCommaDelimiter: !0,
			InsertSpaceAfterSemicolonInForStatements: !0,
			InsertSpaceBeforeAndAfterBinaryOperators: !0,
			InsertSpaceAfterKeywordsInControlFlowStatements: !0,
			InsertSpaceAfterFunctionKeywordForAnonymousFunctions: !0,
			InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: !1,
			InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: !1,
			InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: !1,
			PlaceOpenBraceOnNewLineForControlBlocks: !1,
			PlaceOpenBraceOnNewLineForFunctions: !1
		};
	}
	_convertTextChanges(u, A) {
		return {
			text: A.newText,
			range: this._textSpanToRange(u, A.span)
		};
	}
}, FormatAdapter = class extends FormatHelper {
	constructor() {
		super(...arguments), this.canFormatMultipleRanges = !1;
	}
	async provideDocumentRangeFormattingEdits(u, A, j, M) {
		let N = u.uri, P = u.getOffsetAt({
			lineNumber: A.startLineNumber,
			column: A.startColumn
		}), F = u.getOffsetAt({
			lineNumber: A.endLineNumber,
			column: A.endColumn
		}), I = await this._worker(N);
		if (u.isDisposed()) return;
		let L = await I.getFormattingEditsForRange(N.toString(), P, F, FormatHelper._convertOptions(j));
		if (!(!L || u.isDisposed())) return L.map((A) => this._convertTextChanges(u, A));
	}
}, FormatOnTypeAdapter = class extends FormatHelper {
	get autoFormatTriggerCharacters() {
		return [
			";",
			"}",
			"\n"
		];
	}
	async provideOnTypeFormattingEdits(u, A, j, M, N) {
		let P = u.uri, F = u.getOffsetAt(A), I = await this._worker(P);
		if (u.isDisposed()) return;
		let L = await I.getFormattingEditsAfterKeystroke(P.toString(), F, j, FormatHelper._convertOptions(M));
		if (!(!L || u.isDisposed())) return L.map((A) => this._convertTextChanges(u, A));
	}
}, CodeActionAdaptor = class extends FormatHelper {
	async provideCodeActions(u, A, j, M) {
		let N = u.uri, P = u.getOffsetAt({
			lineNumber: A.startLineNumber,
			column: A.startColumn
		}), F = u.getOffsetAt({
			lineNumber: A.endLineNumber,
			column: A.endColumn
		}), I = FormatHelper._convertOptions(u.getOptions()), L = j.markers.filter((u) => u.code).map((u) => u.code).map(Number), R = await this._worker(N);
		if (u.isDisposed()) return;
		let z = await R.getCodeFixesAtPosition(N.toString(), P, F, L, I);
		return !z || u.isDisposed() ? {
			actions: [],
			dispose: () => {}
		} : {
			actions: z.filter((u) => u.changes.filter((u) => u.isNewFile).length === 0).map((A) => this._tsCodeFixActionToMonacoCodeAction(u, j, A)),
			dispose: () => {}
		};
	}
	_tsCodeFixActionToMonacoCodeAction(u, A, j) {
		let M = [];
		for (let A of j.changes) for (let j of A.textChanges) M.push({
			resource: u.uri,
			versionId: void 0,
			textEdit: {
				range: this._textSpanToRange(u, j.span),
				text: j.newText
			}
		});
		return {
			title: j.description,
			edit: { edits: M },
			diagnostics: A.markers,
			kind: "quickfix"
		};
	}
}, RenameAdapter = class extends Adapter {
	constructor(u, A) {
		super(A), this._libFiles = u;
	}
	async provideRenameEdits(u, A, j, M) {
		let N = u.uri, P = N.toString(), F = u.getOffsetAt(A), I = await this._worker(N);
		if (u.isDisposed()) return;
		let L = await I.getRenameInfo(P, F, { allowRenameOfImportPath: !1 });
		if (L.canRename === !1) return {
			edits: [],
			rejectReason: L.localizedErrorMessage
		};
		if (L.fileToRename !== void 0) throw Error("Renaming files is not supported.");
		let R = await I.findRenameLocations(P, F, !1, !1, !1);
		if (!R || u.isDisposed()) return;
		let z = [];
		for (let u of R) {
			let A = this._libFiles.getOrCreateModel(u.fileName);
			if (A) z.push({
				resource: A.uri,
				versionId: void 0,
				textEdit: {
					range: this._textSpanToRange(A, u.textSpan),
					text: j
				}
			});
			else throw Error(`Unknown file ${u.fileName}.`);
		}
		return { edits: z };
	}
}, InlayHintsAdapter = class extends Adapter {
	async provideInlayHints(u, A, j) {
		let M = u.uri, N = M.toString(), P = u.getOffsetAt({
			lineNumber: A.startLineNumber,
			column: A.startColumn
		}), F = u.getOffsetAt({
			lineNumber: A.endLineNumber,
			column: A.endColumn
		}), I = await this._worker(M);
		return u.isDisposed() ? null : {
			hints: (await I.provideInlayHints(N, P, F)).map((A) => ({
				...A,
				label: A.text,
				position: u.getPositionAt(A.position),
				kind: this._convertHintKind(A.kind)
			})),
			dispose: () => {}
		};
	}
	_convertHintKind(u) {
		switch (u) {
			case "Parameter": return monaco_editor_core_exports.languages.InlayHintKind.Parameter;
			case "Type": return monaco_editor_core_exports.languages.InlayHintKind.Type;
			default: return monaco_editor_core_exports.languages.InlayHintKind.Type;
		}
	}
}, javaScriptWorker, typeScriptWorker;
function setupTypeScript(u) {
	typeScriptWorker = setupMode(u, "typescript");
}
function setupJavaScript(u) {
	javaScriptWorker = setupMode(u, "javascript");
}
function getJavaScriptWorker() {
	return new Promise((u, A) => {
		if (!javaScriptWorker) return A("JavaScript not registered!");
		u(javaScriptWorker);
	});
}
function getTypeScriptWorker() {
	return new Promise((u, A) => {
		if (!typeScriptWorker) return A("TypeScript not registered!");
		u(typeScriptWorker);
	});
}
function setupMode(u, A) {
	let j = [], M = [], N = new WorkerManager(A, u);
	j.push(N);
	let P = (...u) => N.getLanguageServiceWorker(...u), F = new LibFiles(P);
	function I() {
		let { modeConfiguration: j } = u;
		disposeAll(M), j.completionItems && M.push(monaco_editor_core_exports.languages.registerCompletionItemProvider(A, new SuggestAdapter(P))), j.signatureHelp && M.push(monaco_editor_core_exports.languages.registerSignatureHelpProvider(A, new SignatureHelpAdapter(P))), j.hovers && M.push(monaco_editor_core_exports.languages.registerHoverProvider(A, new QuickInfoAdapter(P))), j.documentHighlights && M.push(monaco_editor_core_exports.languages.registerDocumentHighlightProvider(A, new DocumentHighlightAdapter(P))), j.definitions && M.push(monaco_editor_core_exports.languages.registerDefinitionProvider(A, new DefinitionAdapter(F, P))), j.references && M.push(monaco_editor_core_exports.languages.registerReferenceProvider(A, new ReferenceAdapter(F, P))), j.documentSymbols && M.push(monaco_editor_core_exports.languages.registerDocumentSymbolProvider(A, new OutlineAdapter(P))), j.rename && M.push(monaco_editor_core_exports.languages.registerRenameProvider(A, new RenameAdapter(F, P))), j.documentRangeFormattingEdits && M.push(monaco_editor_core_exports.languages.registerDocumentRangeFormattingEditProvider(A, new FormatAdapter(P))), j.onTypeFormattingEdits && M.push(monaco_editor_core_exports.languages.registerOnTypeFormattingEditProvider(A, new FormatOnTypeAdapter(P))), j.codeActions && M.push(monaco_editor_core_exports.languages.registerCodeActionProvider(A, new CodeActionAdaptor(P))), j.inlayHints && M.push(monaco_editor_core_exports.languages.registerInlayHintsProvider(A, new InlayHintsAdapter(P))), j.diagnostics && M.push(new DiagnosticsAdapter(F, u, A, P));
	}
	return I(), j.push(asDisposable(M)), P;
}
function asDisposable(u) {
	return { dispose: () => disposeAll(u) };
}
function disposeAll(u) {
	for (; u.length;) u.pop().dispose();
}
export { Adapter, CodeActionAdaptor, DefinitionAdapter, DiagnosticsAdapter, DocumentHighlightAdapter, FormatAdapter, FormatHelper, FormatOnTypeAdapter, InlayHintsAdapter, Kind, LibFiles, OutlineAdapter, QuickInfoAdapter, ReferenceAdapter, RenameAdapter, SignatureHelpAdapter, SuggestAdapter, WorkerManager, flattenDiagnosticMessageText, getJavaScriptWorker, getTypeScriptWorker, setupJavaScript, setupTypeScript };
