import * as monaco from 'monaco-editor';
import { StandaloneServices, ILanguageService } from 'vscode/services';

const customAliases = {
    csharp: ['c#'],
    'objective-c': ['objectivec', 'objc'],
    python: ['datascience-python', 'python3'],
    r: ['datascience-r'],
    vb: ['vb.net'],
    javascriptreact: ['react'],
    javascript: ['node'],
    typescript: ['angular'],
    sql: ['mysql'],
    postgres: ['postgresql', 'postgres', 'pg', 'postgre']
};
for (const [languageId, aliases] of Object.entries(customAliases)) {
    monaco.languages.register({
        id: languageId,
        aliases
    });
}
function getMonacoLanguage(languageOrModeId) {
    const languageService = StandaloneServices.get(ILanguageService);
    const modeId = languageService.getLanguageIdByLanguageName(languageOrModeId.toLowerCase());
    if (modeId != null) {
        return modeId;
    }
    if (languageService.isRegisteredLanguageId(languageOrModeId)) {
        return languageOrModeId;
    }
    if (languageService.isRegisteredLanguageId(languageOrModeId.toLowerCase())) {
        return languageOrModeId.toLowerCase();
    }
    return 'plaintext';
}
async function loadLanguage(languageId) {
    StandaloneServices.get(ILanguageService).createById(languageId);
}

export { getMonacoLanguage, loadLanguage };
