
import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
import '../../../platform/hover/browser/hoverService.js';
import '../../../platform/undoRedo/common/undoRedoService.js';
import '../../browser/services/inlineCompletionsService.js';
import '../../common/services/languageFeatureDebounce.js';
import { Emitter, Event, ValueWithChangeEvent } from '../../../base/common/event.js';
import { ImmortalReference, DisposableStore, toDisposable, combinedDisposable, Disposable } from '../../../base/common/lifecycle.js';
import '../../common/model.js';
import '../../../base/common/arrays.js';
import '../../../base/common/async.js';
import '../../../base/common/charCode.js';
import '../../../base/common/path.js';
import { OS, isLinux, isMacintosh } from '../../../base/common/platform.js';
import { format } from '../../../base/common/strings.js';
import '../../../base/common/errors.js';
import { ResourceMap } from '../../../base/common/map.js';
import { IInstantiationService, createDecorator } from '../../../platform/instantiation/common/instantiation.js';
import { registerSingleton, InstantiationType, getSingletonServiceDescriptors } from '../../../platform/instantiation/common/extensions.js';
import '../../common/services/semanticTokensStylingService.js';
import './standaloneCodeEditorService.js';
import './standaloneLayoutService.js';
import { addDisposableListener, EventType } from '../../../base/browser/dom.js';
import { StandardKeyboardEvent } from '../../../base/browser/keyboardEvent.js';
import { mainWindow } from '../../../base/browser/window.js';
import { decodeKeybinding, KeyCodeChord } from '../../../base/common/keybindings.js';
import { basename } from '../../../base/common/resources.js';
import Severity$1 from '../../../base/common/severity.js';
import { URI } from '../../../base/common/uri.js';
import { AccessibilityService } from '../../../platform/accessibility/browser/accessibilityService.js';
import { IAccessibilityService } from '../../../platform/accessibility/common/accessibility.service.js';
import { IAccessibilitySignalService } from '../../../platform/accessibilitySignal/browser/accessibilitySignalService.service.js';
import { IMenuService } from '../../../platform/actions/common/actions.service.js';
import { MenuService } from '../../../platform/actions/common/menuService.js';
import { BrowserClipboardService } from '../../../platform/clipboard/browser/clipboardService.js';
import { IClipboardService } from '../../../platform/clipboard/common/clipboardService.service.js';
import { CommandsRegistry } from '../../../platform/commands/common/commands.js';
import { ICommandService } from '../../../platform/commands/common/commands.service.js';
import { ConfigurationTarget } from '../../../platform/configuration/common/configuration.js';
import { IConfigurationService } from '../../../platform/configuration/common/configuration.service.js';
import { Configuration as Configuration$1, ConfigurationModel, ConfigurationChangeEvent } from '../../../platform/configuration/common/configurationModels.js';
import { DefaultConfiguration as DefaultConfiguration$1 } from '../../../platform/configuration/common/configurations.js';
import { ContextKeyService } from '../../../platform/contextkey/browser/contextKeyService.js';
import { IContextKeyService } from '../../../platform/contextkey/common/contextkey.service.js';
import { ContextMenuService } from '../../../platform/contextview/browser/contextMenuService.js';
import { IContextViewService, IContextMenuService } from '../../../platform/contextview/browser/contextView.service.js';
import { ContextViewService } from '../../../platform/contextview/browser/contextViewService.js';
import { NullDataChannelService } from '../../../platform/dataChannel/common/dataChannel.js';
import { IDataChannelService } from '../../../platform/dataChannel/common/dataChannel.service.js';
import { IDefaultAccountService } from '../../../platform/defaultAccount/common/defaultAccount.service.js';
import { IDialogService } from '../../../platform/dialogs/common/dialogs.service.js';
import { IEnvironmentService } from '../../../platform/environment/common/environment.service.js';
import { SyncDescriptor } from '../../../platform/instantiation/common/descriptors.js';
import { InstantiationService } from '../../../platform/instantiation/common/instantiationService.js';
import { ServiceCollection } from '../../../platform/instantiation/common/serviceCollection.js';
import { AbstractKeybindingService } from '../../../platform/keybinding/common/abstractKeybindingService.js';
import { IKeybindingService } from '../../../platform/keybinding/common/keybinding.service.js';
import { KeybindingResolver } from '../../../platform/keybinding/common/keybindingResolver.js';
import { KeybindingsRegistry } from '../../../platform/keybinding/common/keybindingsRegistry.js';
import { ResolvedKeybindingItem } from '../../../platform/keybinding/common/resolvedKeybindingItem.js';
import { USLayoutResolvedKeybinding } from '../../../platform/keybinding/common/usLayoutResolvedKeybinding.js';
import { ILabelService } from '../../../platform/label/common/label.service.js';
import { ILayoutService } from '../../../platform/layout/browser/layoutService.service.js';
import { ListService } from '../../../platform/list/browser/listService.js';
import { IListService } from '../../../platform/list/browser/listService.service.js';
import { ConsoleLogger, NullLoggerService } from '../../../platform/log/common/log.js';
import { ILogService, ILoggerService } from '../../../platform/log/common/log.service.js';
import { LogService } from '../../../platform/log/common/logService.js';
import { IMarkerService } from '../../../platform/markers/common/markers.service.js';
import { MarkerService } from '../../../platform/markers/common/markerService.js';
import { NoOpNotification, NotificationsFilter } from '../../../platform/notification/common/notification.js';
import { INotificationService } from '../../../platform/notification/common/notification.service.js';
import { IOpenerService } from '../../../platform/opener/common/opener.service.js';
import { IProgressService, IEditorProgressService } from '../../../platform/progress/common/progress.service.js';
import { IQuickInputService } from '../../../platform/quickinput/common/quickInput.service.js';
import { InMemoryStorageService } from '../../../platform/storage/common/storage.js';
import { IStorageService } from '../../../platform/storage/common/storage.service.js';
import { TelemetryLevel } from '../../../platform/telemetry/common/telemetry.js';
import { ITelemetryService } from '../../../platform/telemetry/common/telemetry.service.js';
import { IUserInteractionService } from '../../../platform/userInteraction/browser/userInteractionService.service.js';
import { UserInteractionService } from '../../../platform/userInteraction/browser/userInteractionServiceImpl.js';
import { IWebWorkerService } from '../../../platform/webWorker/browser/webWorkerService.service.js';
import { WorkspaceFolder, STANDALONE_EDITOR_WORKSPACE_ID, WorkbenchState } from '../../../platform/workspace/common/workspace.js';
import { IWorkspaceContextService } from '../../../platform/workspace/common/workspace.service.js';
import { IWorkspaceTrustManagementService } from '../../../platform/workspace/common/workspaceTrust.service.js';
import { ResourceEdit, ResourceTextEdit } from '../../browser/services/bulkEditService.js';
import { IBulkEditService } from '../../browser/services/bulkEditService.service.js';
import { ICodeEditorService } from '../../browser/services/codeEditorService.service.js';
import { OpenerService } from '../../browser/services/openerService.js';
import { NullRenameSymbolTrackerService } from '../../browser/services/renameSymbolTrackerService.js';
import { IRenameSymbolTrackerService } from '../../browser/services/renameSymbolTrackerService.service.js';
import { isEditorConfigurationKey, isDiffEditorConfigurationKey } from '../../common/config/editorConfigurationSchema.js';
import { EditOperation } from '../../common/core/editOperation.js';
import { Position } from '../../common/core/position.js';
import { Range } from '../../common/core/range.js';
import { ILanguageService } from '../../common/languages/language.service.js';
import { LanguageService } from '../../common/services/languageService.js';
import { IMarkerDecorationsService } from '../../common/services/markerDecorations.service.js';
import { MarkerDecorationsService } from '../../common/services/markerDecorationsService.js';
import { IModelService } from '../../common/services/model.service.js';
import { ModelService } from '../../common/services/modelService.js';
import { ITextModelService } from '../../common/services/resolverService.service.js';
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from '../../common/services/textResourceConfiguration.service.js';
import { ITreeSitterLibraryService } from '../../common/services/treeSitter/treeSitterLibraryService.service.js';
import { StandaloneServicesNLS } from '../../common/standaloneStrings.js';
import { IStandaloneThemeService } from '../common/standaloneTheme.service.js';
import { StandaloneQuickInputService } from './quickInput/standaloneQuickInputService.js';
import { StandaloneWebWorkerService } from './services/standaloneWebWorkerService.js';
import { StandaloneThemeService } from './standaloneThemeService.js';
import { StandaloneTreeSitterLibraryService } from './standaloneTreeSitterLibraryService.js';

class SimpleModel {
    constructor(model) {
        this.disposed = false;
        this.model = model;
        this._onWillDispose = ( new Emitter());
    }
    get onWillDispose() {
        return this._onWillDispose.event;
    }
    resolve() {
        return Promise.resolve();
    }
    get textEditorModel() {
        return this.model;
    }
    createSnapshot() {
        return this.model.createSnapshot();
    }
    isReadonly() {
        return false;
    }
    dispose() {
        this.disposed = true;
        this._onWillDispose.fire();
    }
    isDisposed() {
        return this.disposed;
    }
    isResolved() {
        return true;
    }
    getLanguageId() {
        return this.model.getLanguageId();
    }
}
let StandaloneTextModelService = class StandaloneTextModelService {
    constructor(modelService) {
        this.modelService = modelService;
    }
    createModelReference(resource) {
        const model = this.modelService.getModel(resource);
        if (!model) {
            return Promise.reject(( new Error(`Model not found`)));
        }
        return Promise.resolve(( new ImmortalReference(( new SimpleModel(model)))));
    }
    registerTextModelContentProvider(scheme, provider) {
        return {
            dispose: function() {}
        };
    }
    canHandleResource(resource) {
        return false;
    }
};
StandaloneTextModelService = ( __decorate([( __param(0, IModelService))], StandaloneTextModelService));
class StandaloneEditorProgressService {
    static {
        this.NULL_PROGRESS_RUNNER = {
            done: () => {},
            total: () => {},
            worked: () => {}
        };
    }
    show() {
        return StandaloneEditorProgressService.NULL_PROGRESS_RUNNER;
    }
    async showWhile(promise, delay) {
        await promise;
    }
}
class StandaloneProgressService {
    withProgress(_options, task, onDidCancel) {
        return task({
            report: () => {}
        });
    }
}
class StandaloneEnvironmentService {
    constructor() {
        this.stateResource = ( URI.from({
            scheme: "monaco",
            authority: "stateResource"
        }));
        this.userRoamingDataHome = ( URI.from({
            scheme: "monaco",
            authority: "userRoamingDataHome"
        }));
        this.keyboardLayoutResource = ( URI.from({
            scheme: "monaco",
            authority: "keyboardLayoutResource"
        }));
        this.argvResource = ( URI.from({
            scheme: "monaco",
            authority: "argvResource"
        }));
        this.untitledWorkspacesHome = ( URI.from({
            scheme: "monaco",
            authority: "untitledWorkspacesHome"
        }));
        this.workspaceStorageHome = ( URI.from({
            scheme: "monaco",
            authority: "workspaceStorageHome"
        }));
        this.localHistoryHome = ( URI.from({
            scheme: "monaco",
            authority: "localHistoryHome"
        }));
        this.cacheHome = ( URI.from({
            scheme: "monaco",
            authority: "cacheHome"
        }));
        this.userDataSyncHome = ( URI.from({
            scheme: "monaco",
            authority: "userDataSyncHome"
        }));
        this.sync = undefined;
        this.continueOn = undefined;
        this.editSessionId = undefined;
        this.debugExtensionHost = {
            port: null,
            break: false
        };
        this.isExtensionDevelopment = false;
        this.disableExtensions = false;
        this.disableExperiments = false;
        this.enableExtensions = undefined;
        this.extensionDevelopmentLocationURI = undefined;
        this.extensionDevelopmentKind = undefined;
        this.extensionTestsLocationURI = undefined;
        this.logsHome = ( URI.from({
            scheme: "monaco",
            authority: "logsHome"
        }));
        this.logLevel = undefined;
        this.extensionLogLevel = undefined;
        this.verbose = false;
        this.isBuilt = false;
        this.disableTelemetry = false;
        this.serviceMachineIdResource = ( URI.from({
            scheme: "monaco",
            authority: "serviceMachineIdResource"
        }));
        this.policyFile = undefined;
    }
}
class StandaloneDialogService {
    constructor() {
        this.onWillShowDialog = Event.None;
        this.onDidShowDialog = Event.None;
    }
    async confirm(confirmation) {
        const confirmed = this.doConfirm(confirmation.message, confirmation.detail);
        return {
            confirmed,
            checkboxChecked: false
        };
    }
    doConfirm(message, detail) {
        let messageText = message;
        if (detail) {
            messageText = messageText + "\n\n" + detail;
        }
        return mainWindow.confirm(messageText);
    }
    async prompt(prompt) {
        let result = undefined;
        const confirmed = this.doConfirm(prompt.message, prompt.detail);
        if (confirmed) {
            const promptButtons = [...(prompt.buttons ?? [])];
            if (prompt.cancelButton && typeof prompt.cancelButton !== "string" && typeof prompt.cancelButton !== "boolean") {
                promptButtons.push(prompt.cancelButton);
            }
            result = await promptButtons[0]?.run({
                checkboxChecked: false
            });
        }
        return {
            result
        };
    }
    async info(message, detail) {
        await this.prompt({
            type: Severity$1.Info,
            message,
            detail
        });
    }
    async warn(message, detail) {
        await this.prompt({
            type: Severity$1.Warning,
            message,
            detail
        });
    }
    async error(message, detail) {
        await this.prompt({
            type: Severity$1.Error,
            message,
            detail
        });
    }
    input() {
        return Promise.resolve({
            confirmed: false
        });
    }
    about() {
        return Promise.resolve(undefined);
    }
}
class StandaloneNotificationService {
    constructor() {
        this.onDidChangeFilter = Event.None;
    }
    static {
        this.NO_OP = ( new NoOpNotification());
    }
    info(message) {
        return this.notify({
            severity: Severity$1.Info,
            message
        });
    }
    warn(message) {
        return this.notify({
            severity: Severity$1.Warning,
            message
        });
    }
    error(error) {
        return this.notify({
            severity: Severity$1.Error,
            message: error
        });
    }
    notify(notification) {
        switch (notification.severity) {
        case Severity$1.Error:
            console.error(notification.message);
            break;
        case Severity$1.Warning:
            console.warn(notification.message);
            break;
        default:
            console.log(notification.message);
            break;
        }
        return StandaloneNotificationService.NO_OP;
    }
    prompt(severity, message, choices, options) {
        return StandaloneNotificationService.NO_OP;
    }
    status(message, options) {
        return {
            close: () => {}
        };
    }
    setFilter(filter) {}
    getFilter(source) {
        return NotificationsFilter.OFF;
    }
    getFilters() {
        return [];
    }
    removeFilter(sourceId) {}
}
let StandaloneCommandService = class StandaloneCommandService {
    constructor(instantiationService) {
        this._onWillExecuteCommand = ( new Emitter());
        this._onDidExecuteCommand = ( new Emitter());
        this.onWillExecuteCommand = this._onWillExecuteCommand.event;
        this.onDidExecuteCommand = this._onDidExecuteCommand.event;
        this._instantiationService = instantiationService;
    }
    executeCommand(id, ...args) {
        const command = CommandsRegistry.getCommand(id);
        if (!command) {
            return Promise.reject(( new Error(`command '${id}' not found`)));
        }
        try {
            this._onWillExecuteCommand.fire({
                commandId: id,
                args
            });
            const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]);
            this._onDidExecuteCommand.fire({
                commandId: id,
                args
            });
            return Promise.resolve(result);
        } catch (err) {
            return Promise.reject(err);
        }
    }
};
StandaloneCommandService = ( __decorate([( __param(0, IInstantiationService))], StandaloneCommandService));
let StandaloneKeybindingService = class StandaloneKeybindingService extends AbstractKeybindingService {
    constructor(
        contextKeyService,
        commandService,
        telemetryService,
        notificationService,
        logService,
        codeEditorService
    ) {
        super(
            contextKeyService,
            commandService,
            telemetryService,
            notificationService,
            logService
        );
        this._cachedResolver = null;
        this._dynamicKeybindings = [];
        this._domNodeListeners = [];
    }
    registerContainer(container) {
        const disposables = ( new DisposableStore());
        disposables.add(addDisposableListener(container, EventType.KEY_DOWN, e => {
            const keyEvent = ( new StandardKeyboardEvent(e));
            const shouldPreventDefault = this._dispatch(keyEvent, keyEvent.target);
            if (shouldPreventDefault) {
                keyEvent.preventDefault();
                keyEvent.stopPropagation();
            }
        }));
        disposables.add(addDisposableListener(container, EventType.KEY_UP, e => {
            const keyEvent = ( new StandardKeyboardEvent(e));
            const shouldPreventDefault = this._singleModifierDispatch(keyEvent, keyEvent.target);
            if (shouldPreventDefault) {
                keyEvent.preventDefault();
            }
        }));
        this._domNodeListeners.push(( new DomNodeListeners(container, disposables)));
        disposables.add(toDisposable(() => {
            for (let i = 0; i < this._domNodeListeners.length; i++) {
                const domNodeListeners = this._domNodeListeners[i];
                if (domNodeListeners.domNode === container) {
                    this._domNodeListeners.splice(i, 1);
                    domNodeListeners.dispose();
                }
            }
        }));
        return disposables;
    }
    addDynamicKeybinding(command, keybinding, handler, when) {
        return combinedDisposable(
            CommandsRegistry.registerCommand(command, handler),
            this.addDynamicKeybindings([{
                keybinding,
                command,
                when
            }])
        );
    }
    addDynamicKeybindings(rules) {
        const entries = ( rules.map(rule => {
            const keybinding = decodeKeybinding(rule.keybinding, OS);
            return {
                keybinding,
                command: rule.command ?? null,
                commandArgs: rule.commandArgs,
                when: rule.when,
                weight1: 1000,
                weight2: 0,
                extensionId: null,
                isBuiltinExtension: false
            };
        }));
        this._dynamicKeybindings = this._dynamicKeybindings.concat(entries);
        this.updateResolver();
        return toDisposable(() => {
            for (let i = 0; i < this._dynamicKeybindings.length; i++) {
                if (this._dynamicKeybindings[i] === entries[0]) {
                    this._dynamicKeybindings.splice(i, entries.length);
                    this.updateResolver();
                    return;
                }
            }
        });
    }
    updateResolver() {
        this._cachedResolver = null;
        this._onDidUpdateKeybindings.fire();
    }
    getUserKeybindingItems() {
        return this._toNormalizedKeybindingItems(this._dynamicKeybindings, false);
    }
    _getResolver() {
        if (!this._cachedResolver) {
            const defaults = this._toNormalizedKeybindingItems(KeybindingsRegistry.getDefaultKeybindings(), true);
            const overrides = this.getUserKeybindingItems();
            this._cachedResolver = ( new KeybindingResolver(defaults, overrides, str => this._log(str)));
        }
        return this._cachedResolver;
    }
    _documentHasFocus() {
        return mainWindow.document.hasFocus();
    }
    _toNormalizedKeybindingItems(items, isDefault) {
        const result = [];
        let resultLen = 0;
        for (const item of items) {
            const when = item.when || undefined;
            const keybinding = item.keybinding;
            if (!keybinding) {
                result[resultLen++] = ( new ResolvedKeybindingItem(undefined, item.command, item.commandArgs, when, isDefault, null, false));
            } else {
                const resolvedKeybindings = this.resolveKeybinding(keybinding);
                for (const resolvedKeybinding of resolvedKeybindings) {
                    result[resultLen++] = ( new ResolvedKeybindingItem(
                        resolvedKeybinding,
                        item.command,
                        item.commandArgs,
                        when,
                        isDefault,
                        null,
                        false
                    ));
                }
            }
        }
        return result;
    }
    resolveKeybinding(keybinding) {
        return USLayoutResolvedKeybinding.resolveKeybinding(keybinding, OS);
    }
    resolveKeyboardEvent(keyboardEvent) {
        const chord = ( new KeyCodeChord(
            keyboardEvent.ctrlKey,
            keyboardEvent.shiftKey,
            keyboardEvent.altKey,
            keyboardEvent.metaKey,
            keyboardEvent.keyCode
        ));
        return ( new USLayoutResolvedKeybinding([chord], OS));
    }
    resolveUserBinding(userBinding) {
        return [];
    }
    _dumpDebugInfo() {
        return "";
    }
    _dumpDebugInfoJSON() {
        return "";
    }
    registerSchemaContribution(contribution) {
        return Disposable.None;
    }
    enableKeybindingHoldMode(commandId) {
        return undefined;
    }
};
StandaloneKeybindingService = ( __decorate([( __param(0, IContextKeyService)), ( __param(1, ICommandService)), ( __param(2, ITelemetryService)), ( __param(3, INotificationService)), ( __param(4, ILogService)), ( __param(5, ICodeEditorService))], StandaloneKeybindingService));
class DomNodeListeners extends Disposable {
    constructor(domNode, disposables) {
        super();
        this.domNode = domNode;
        this._register(disposables);
    }
}
function isConfigurationOverrides(thing) {
    return !!thing && typeof thing === "object" && (!thing.overrideIdentifier || typeof thing.overrideIdentifier === "string") && (!thing.resource || thing.resource instanceof URI);
}
let StandaloneConfigurationService = class StandaloneConfigurationService {
    constructor(logService) {
        this.logService = logService;
        this._onDidChangeConfiguration = ( new Emitter());
        this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
        const defaultConfiguration = ( new DefaultConfiguration$1(logService));
        this._configuration = ( new Configuration$1(
            defaultConfiguration.reload(),
            ConfigurationModel.createEmptyModel(logService),
            ConfigurationModel.createEmptyModel(logService),
            ConfigurationModel.createEmptyModel(logService),
            ConfigurationModel.createEmptyModel(logService),
            ConfigurationModel.createEmptyModel(logService),
            ( new ResourceMap()),
            ConfigurationModel.createEmptyModel(logService),
            ( new ResourceMap()),
            logService
        ));
        defaultConfiguration.dispose();
    }
    getValue(arg1, arg2) {
        const section = typeof arg1 === "string" ? arg1 : undefined;
        const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : {};
        return this._configuration.getValue(section, overrides, undefined);
    }
    updateValues(values) {
        const previous = {
            data: this._configuration.toData()
        };
        const changedKeys = [];
        for (const entry of values) {
            const [key, value] = entry;
            if (this.getValue(key) === value) {
                continue;
            }
            this._configuration.updateValue(key, value);
            changedKeys.push(key);
        }
        if (changedKeys.length > 0) {
            const configurationChangeEvent = ( new ConfigurationChangeEvent({
                keys: changedKeys,
                overrides: []
            }, previous, this._configuration, undefined, this.logService));
            configurationChangeEvent.source = ConfigurationTarget.MEMORY;
            this._onDidChangeConfiguration.fire(configurationChangeEvent);
        }
        return Promise.resolve();
    }
    updateValue(key, value, arg3, arg4) {
        return this.updateValues([[key, value]]);
    }
    inspect(key, options = {}) {
        return this._configuration.inspect(key, options, undefined);
    }
    keys() {
        return ( this._configuration.keys(undefined));
    }
    reloadConfiguration() {
        return Promise.resolve(undefined);
    }
    getConfigurationData() {
        const emptyModel = {
            contents: {},
            keys: [],
            overrides: []
        };
        return {
            defaults: emptyModel,
            policy: emptyModel,
            application: emptyModel,
            userLocal: emptyModel,
            userRemote: emptyModel,
            workspace: emptyModel,
            folders: []
        };
    }
};
StandaloneConfigurationService = ( __decorate([( __param(0, ILogService))], StandaloneConfigurationService));
let StandaloneResourceConfigurationService = class StandaloneResourceConfigurationService extends Disposable {
    constructor(configurationService, modelService, languageService) {
        super();
        this.configurationService = configurationService;
        this.modelService = modelService;
        this.languageService = languageService;
        this._onDidChangeConfiguration = this._register(( new Emitter()));
        this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
        this._register(this.configurationService.onDidChangeConfiguration(e => {
            this._onDidChangeConfiguration.fire({
                affectedKeys: e.affectedKeys,
                affectsConfiguration: (resource, configuration) => e.affectsConfiguration(configuration)
            });
        }));
    }
    getValue(resource, arg2, arg3) {
        const position = Position.isIPosition(arg2) ? arg2 : null;
        const section = position ? (typeof arg3 === "string" ? arg3 : undefined) : (typeof arg2 === "string" ? arg2 : undefined);
        const language = resource ? this.getLanguage(resource, position) : undefined;
        if (typeof section === "undefined") {
            return this.configurationService.getValue({
                resource,
                overrideIdentifier: language
            });
        }
        return this.configurationService.getValue(section, {
            resource,
            overrideIdentifier: language
        });
    }
    inspect(resource, position, section) {
        const language = resource ? this.getLanguage(resource, position) : undefined;
        return this.configurationService.inspect(section, {
            resource,
            overrideIdentifier: language
        });
    }
    getLanguage(resource, position) {
        const model = this.modelService.getModel(resource);
        if (model) {
            return position ? model.getLanguageIdAtPosition(position.lineNumber, position.column) : model.getLanguageId();
        }
        return this.languageService.guessLanguageIdByFilepathOrFirstLine(resource);
    }
    updateValue(resource, key, value, configurationTarget) {
        return this.configurationService.updateValue(key, value, {
            resource
        }, configurationTarget);
    }
};
StandaloneResourceConfigurationService = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IModelService)), ( __param(2, ILanguageService))], StandaloneResourceConfigurationService));
let StandaloneResourcePropertiesService = class StandaloneResourcePropertiesService {
    constructor(configurationService) {
        this.configurationService = configurationService;
    }
    getEOL(resource, language) {
        const eol = this.configurationService.getValue("files.eol", {
            overrideIdentifier: language,
            resource
        });
        if (eol && typeof eol === "string" && eol !== "auto") {
            return eol;
        }
        return (isLinux || isMacintosh) ? "\n" : "\r\n";
    }
};
StandaloneResourcePropertiesService = ( __decorate([( __param(0, IConfigurationService))], StandaloneResourcePropertiesService));
class StandaloneTelemetryService {
    constructor() {
        this.telemetryLevel = TelemetryLevel.NONE;
        this.sessionId = "someValue.sessionId";
        this.machineId = "someValue.machineId";
        this.sqmId = "someValue.sqmId";
        this.devDeviceId = "someValue.devDeviceId";
        this.firstSessionDate = "someValue.firstSessionDate";
        this.sendErrorTelemetry = false;
    }
    setEnabled() {}
    setExperimentProperty() {}
    publicLog() {}
    publicLog2() {}
    publicLogError() {}
    publicLogError2() {}
}
class StandaloneWorkspaceContextService {
    static {
        this.SCHEME = "inmemory";
    }
    constructor() {
        this._onDidChangeWorkspaceName = ( new Emitter());
        this.onDidChangeWorkspaceName = this._onDidChangeWorkspaceName.event;
        this._onWillChangeWorkspaceFolders = ( new Emitter());
        this.onWillChangeWorkspaceFolders = this._onWillChangeWorkspaceFolders.event;
        this._onDidChangeWorkspaceFolders = ( new Emitter());
        this.onDidChangeWorkspaceFolders = this._onDidChangeWorkspaceFolders.event;
        this._onDidChangeWorkbenchState = ( new Emitter());
        this.onDidChangeWorkbenchState = this._onDidChangeWorkbenchState.event;
        const resource = ( URI.from({
            scheme: StandaloneWorkspaceContextService.SCHEME,
            authority: "model",
            path: "/"
        }));
        this.workspace = {
            id: STANDALONE_EDITOR_WORKSPACE_ID,
            folders: [( new WorkspaceFolder({
                uri: resource,
                name: "",
                index: 0
            }))]
        };
    }
    getCompleteWorkspace() {
        return Promise.resolve(this.getWorkspace());
    }
    getWorkspace() {
        return this.workspace;
    }
    getWorkbenchState() {
        if (this.workspace) {
            if (this.workspace.configuration) {
                return WorkbenchState.WORKSPACE;
            }
            return WorkbenchState.FOLDER;
        }
        return WorkbenchState.EMPTY;
    }
    hasWorkspaceData() {
        return this.getWorkbenchState() !== WorkbenchState.EMPTY;
    }
    getWorkspaceFolder(resource) {
        return resource && resource.scheme === StandaloneWorkspaceContextService.SCHEME ? this.workspace.folders[0] : null;
    }
    isInsideWorkspace(resource) {
        return resource && resource.scheme === StandaloneWorkspaceContextService.SCHEME;
    }
    isCurrentWorkspace(workspaceIdOrFolder) {
        return true;
    }
}
function updateConfigurationService(configurationService, source, isDiffEditor) {
    if (!source) {
        return;
    }
    if (!(configurationService instanceof StandaloneConfigurationService)) {
        return;
    }
    const toUpdate = [];
    ( Object.keys(source)).forEach(key => {
        if (isEditorConfigurationKey(key)) {
            toUpdate.push([`editor.${key}`, source[key]]);
        }
        if (isDiffEditor && isDiffEditorConfigurationKey(key)) {
            toUpdate.push([`diffEditor.${key}`, source[key]]);
        }
    });
    if (toUpdate.length > 0) {
        configurationService.updateValues(toUpdate);
    }
}
let StandaloneBulkEditService = class StandaloneBulkEditService {
    constructor(_modelService) {
        this._modelService = _modelService;
    }
    hasPreviewHandler() {
        return false;
    }
    setPreviewHandler() {
        return Disposable.None;
    }
    async apply(editsIn, _options) {
        const edits = Array.isArray(editsIn) ? editsIn : ResourceEdit.convert(editsIn);
        const textEdits = ( new Map());
        for (const edit of edits) {
            if (!(edit instanceof ResourceTextEdit)) {
                throw ( new Error("bad edit - only text edits are supported"));
            }
            const model = this._modelService.getModel(edit.resource);
            if (!model) {
                throw ( new Error("bad edit - model not found"));
            }
            if (typeof edit.versionId === "number" && model.getVersionId() !== edit.versionId) {
                throw ( new Error("bad state - model changed in the meantime"));
            }
            let array = textEdits.get(model);
            if (!array) {
                array = [];
                textEdits.set(model, array);
            }
            array.push(
                EditOperation.replaceMove(Range.lift(edit.textEdit.range), edit.textEdit.text)
            );
        }
        let totalEdits = 0;
        let totalFiles = 0;
        for (const [model, edits] of textEdits) {
            model.pushStackElement();
            model.pushEditOperations([], edits, () => []);
            model.pushStackElement();
            totalFiles += 1;
            totalEdits += edits.length;
        }
        return {
            ariaSummary: format(StandaloneServicesNLS.bulkEditServiceSummary, totalEdits, totalFiles),
            isApplied: totalEdits > 0
        };
    }
};
StandaloneBulkEditService = ( __decorate([( __param(0, IModelService))], StandaloneBulkEditService));
class StandaloneUriLabelService {
    constructor() {
        this.onDidChangeFormatters = Event.None;
    }
    getUriLabel(resource, options) {
        if (resource.scheme === "file") {
            return resource.fsPath;
        }
        return resource.path;
    }
    getUriBasenameLabel(resource) {
        return basename(resource);
    }
    getWorkspaceLabel(workspace, options) {
        return "";
    }
    getSeparator(scheme, authority) {
        return "/";
    }
    registerFormatter(formatter) {
        throw ( new Error("Not implemented"));
    }
    registerCachedFormatter(formatter) {
        return this.registerFormatter(formatter);
    }
    getHostLabel() {
        return "";
    }
    getHostTooltip() {
        return undefined;
    }
}
let StandaloneContextViewService = class StandaloneContextViewService extends ContextViewService {
    constructor(layoutService, _codeEditorService) {
        super(layoutService);
        this._codeEditorService = _codeEditorService;
    }
    showContextView(delegate, container, shadowRoot) {
        if (!container) {
            const codeEditor = this._codeEditorService.getFocusedCodeEditor() || this._codeEditorService.getActiveCodeEditor();
            if (codeEditor) {
                container = codeEditor.getContainerDomNode();
            }
        }
        return super.showContextView(delegate, container, shadowRoot);
    }
};
StandaloneContextViewService = ( __decorate([( __param(0, ILayoutService)), ( __param(1, ICodeEditorService))], StandaloneContextViewService));
class StandaloneWorkspaceTrustManagementService {
    constructor() {
        this._neverEmitter = ( new Emitter());
        this.onDidChangeTrust = this._neverEmitter.event;
        this.onDidChangeTrustedFolders = this._neverEmitter.event;
        this.workspaceResolved = Promise.resolve();
        this.workspaceTrustInitialized = Promise.resolve();
        this.acceptsOutOfWorkspaceFiles = true;
    }
    isWorkspaceTrusted() {
        return true;
    }
    isWorkspaceTrustForced() {
        return false;
    }
    canSetParentFolderTrust() {
        return false;
    }
    async setParentFolderTrust(trusted) {}
    canSetWorkspaceTrust() {
        return false;
    }
    async setWorkspaceTrust(trusted) {}
    getUriTrustInfo(uri) {
        throw ( new Error("Method not supported."));
    }
    async setUrisTrust(uri, trusted) {}
    getTrustedUris() {
        return [];
    }
    async setTrustedUris(uris) {}
    addWorkspaceTrustTransitionParticipant(participant) {
        throw ( new Error("Method not supported."));
    }
}
class StandaloneLanguageService extends LanguageService {
    constructor() {
        super();
    }
}
class StandaloneLogService extends LogService {
    constructor() {
        super(( new ConsoleLogger()));
    }
}
let StandaloneContextMenuService = class StandaloneContextMenuService extends ContextMenuService {
    constructor(
        telemetryService,
        notificationService,
        contextViewService,
        keybindingService,
        menuService,
        contextKeyService
    ) {
        super(
            telemetryService,
            notificationService,
            contextViewService,
            keybindingService,
            menuService,
            contextKeyService
        );
        this.configure({
            blockMouse: false
        });
    }
};
StandaloneContextMenuService = ( __decorate([( __param(0, ITelemetryService)), ( __param(1, INotificationService)), ( __param(2, IContextViewService)), ( __param(3, IKeybindingService)), ( __param(4, IMenuService)), ( __param(5, IContextKeyService))], StandaloneContextMenuService));
class StandaloneAccessbilitySignalService {
    async playSignal(cue, options) {}
    async playSignals(cues) {}
    getEnabledState(signal, userGesture, modality) {
        return ValueWithChangeEvent.const(false);
    }
    getDelayMs(signal, modality) {
        return 0;
    }
    isSoundEnabled(cue) {
        return false;
    }
    isAnnouncementEnabled(cue) {
        return false;
    }
    onSoundEnabledChanged(cue) {
        return Event.None;
    }
    async playSound(cue, allowManyInParallel) {}
    playSignalLoop(cue) {
        return toDisposable(() => {});
    }
}
class StandaloneDefaultAccountService {
    constructor() {
        this.onDidChangeDefaultAccount = Event.None;
        this.onDidChangePolicyData = Event.None;
        this.policyData = null;
        this.copilotTokenInfo = null;
        this.onDidChangeCopilotTokenInfo = Event.None;
    }
    async getDefaultAccount() {
        return null;
    }
    setDefaultAccountProvider() {}
    async refresh() {
        return null;
    }
    getDefaultAccountAuthenticationProvider() {
        return {
            id: "default",
            name: "Default",
            enterprise: false
        };
    }
    async signIn() {
        return null;
    }
    async signOut() {}
}
registerSingleton(IWebWorkerService, StandaloneWebWorkerService, InstantiationType.Eager);
registerSingleton(ILogService, StandaloneLogService, InstantiationType.Eager);
registerSingleton(
    IConfigurationService,
    StandaloneConfigurationService,
    InstantiationType.Eager
);
registerSingleton(
    ITextResourceConfigurationService,
    StandaloneResourceConfigurationService,
    InstantiationType.Eager
);
registerSingleton(
    ITextResourcePropertiesService,
    StandaloneResourcePropertiesService,
    InstantiationType.Eager
);
registerSingleton(
    IWorkspaceContextService,
    StandaloneWorkspaceContextService,
    InstantiationType.Eager
);
registerSingleton(ILabelService, StandaloneUriLabelService, InstantiationType.Eager);
registerSingleton(ITelemetryService, StandaloneTelemetryService, InstantiationType.Eager);
registerSingleton(IDialogService, StandaloneDialogService, InstantiationType.Eager);
registerSingleton(IEnvironmentService, StandaloneEnvironmentService, InstantiationType.Eager);
registerSingleton(
    INotificationService,
    StandaloneNotificationService,
    InstantiationType.Eager
);
registerSingleton(IMarkerService, MarkerService, InstantiationType.Eager);
registerSingleton(ILanguageService, StandaloneLanguageService, InstantiationType.Eager);
registerSingleton(IStandaloneThemeService, StandaloneThemeService, InstantiationType.Eager);
registerSingleton(IModelService, ModelService, InstantiationType.Eager);
registerSingleton(
    IMarkerDecorationsService,
    MarkerDecorationsService,
    InstantiationType.Eager
);
registerSingleton(IContextKeyService, ContextKeyService, InstantiationType.Eager);
registerSingleton(IProgressService, StandaloneProgressService, InstantiationType.Eager);
registerSingleton(
    IEditorProgressService,
    StandaloneEditorProgressService,
    InstantiationType.Eager
);
registerSingleton(IStorageService, InMemoryStorageService, InstantiationType.Eager);
registerSingleton(IBulkEditService, StandaloneBulkEditService, InstantiationType.Eager);
registerSingleton(
    IWorkspaceTrustManagementService,
    StandaloneWorkspaceTrustManagementService,
    InstantiationType.Eager
);
registerSingleton(ITextModelService, StandaloneTextModelService, InstantiationType.Eager);
registerSingleton(IAccessibilityService, AccessibilityService, InstantiationType.Eager);
registerSingleton(IListService, ListService, InstantiationType.Eager);
registerSingleton(ICommandService, StandaloneCommandService, InstantiationType.Eager);
registerSingleton(IKeybindingService, StandaloneKeybindingService, InstantiationType.Eager);
registerSingleton(IQuickInputService, StandaloneQuickInputService, InstantiationType.Eager);
registerSingleton(IContextViewService, StandaloneContextViewService, InstantiationType.Eager);
registerSingleton(IOpenerService, OpenerService, InstantiationType.Eager);
registerSingleton(IClipboardService, BrowserClipboardService, InstantiationType.Eager);
registerSingleton(IContextMenuService, StandaloneContextMenuService, InstantiationType.Eager);
registerSingleton(IMenuService, MenuService, InstantiationType.Eager);
registerSingleton(
    IAccessibilitySignalService,
    StandaloneAccessbilitySignalService,
    InstantiationType.Eager
);
registerSingleton(
    ITreeSitterLibraryService,
    StandaloneTreeSitterLibraryService,
    InstantiationType.Eager
);
registerSingleton(ILoggerService, NullLoggerService, InstantiationType.Eager);
registerSingleton(IDataChannelService, NullDataChannelService, InstantiationType.Eager);
registerSingleton(
    IDefaultAccountService,
    StandaloneDefaultAccountService,
    InstantiationType.Eager
);
registerSingleton(
    IRenameSymbolTrackerService,
    NullRenameSymbolTrackerService,
    InstantiationType.Eager
);
registerSingleton(IUserInteractionService, UserInteractionService, InstantiationType.Eager);
var StandaloneServices;
(function(StandaloneServices) {
    const serviceCollection = ( new ServiceCollection());
    for (const [id, descriptor] of getSingletonServiceDescriptors()) {
        serviceCollection.set(id, descriptor);
    }
    const instantiationService = ( new InstantiationService(serviceCollection, true));
    serviceCollection.set(IInstantiationService, instantiationService);
    function get(serviceId) {
        if (!initialized) {
            initialize({});
        }
        const r = serviceCollection.get(serviceId);
        if (!r) {
            throw ( new Error("Missing service " + serviceId));
        }
        if (r instanceof SyncDescriptor) {
            return instantiationService.invokeFunction(accessor => accessor.get(serviceId));
        } else {
            return r;
        }
    }
    StandaloneServices.get = get;
    let initialized = false;
    const onDidInitialize = ( new Emitter());
    function initialize(overrides) {
        if (initialized) {
            return instantiationService;
        }
        initialized = true;
        for (const [id, descriptor] of getSingletonServiceDescriptors()) {
            if (!serviceCollection.get(id)) {
                serviceCollection.set(id, descriptor);
            }
        }
        for (const serviceId in overrides) {
            if (overrides.hasOwnProperty(serviceId)) {
                const serviceIdentifier = ( createDecorator(serviceId));
                const r = serviceCollection.get(serviceIdentifier);
                if (r instanceof SyncDescriptor) {
                    serviceCollection.set(serviceIdentifier, overrides[serviceId]);
                }
            }
        }
        onDidInitialize.fire();
        return instantiationService;
    }
    StandaloneServices.initialize = initialize;
    function withServices(callback) {
        if (initialized) {
            return callback();
        }
        const disposable = ( new DisposableStore());
        const listener = disposable.add(onDidInitialize.event(() => {
            listener.dispose();
            disposable.add(callback());
        }));
        return disposable;
    }
    StandaloneServices.withServices = withServices;
})(StandaloneServices || (StandaloneServices = {}));

export { StandaloneCommandService, StandaloneConfigurationService, StandaloneKeybindingService, StandaloneNotificationService, StandaloneServices, updateConfigurationService };
