import { Observable, BehaviorSubject } from 'rxjs';
import { settingsService } from './settings-service';
import { CommandRegistry } from './command-service';
// import { CommandsRegistry } from '@vscode/monaco-editor/esm/vs/platform/commands/common/commands';
import { extensionsService } from './extensions-service';
import {
    TextDocumentLocationProviderIDRegistry,
    TextDocumentLocationProviderRegistry,
    TextDocumentReferencesProviderRegistry,
    PlatformContext,
    TextDocumentHoverProviderRegistry,
    IExtServices,
    TextDocumentСompletionProviderRegistry,
    TextDocumentHightLightProviderRegistry,
    TextDocumentRenameProviderRegistry,
    TextDocumentFormattingProviderRegistry,
    TextDocumentSymbolDefinitionProviderRegistry,
    TextDocumentCodeActionsRegistry,
    TextDocumentCodeLenthRegistry,
    TextDocumentLinkRegistry,
    TextDocumentColorRegistry,
    TextDocumentFoldingRangesRegistry,
    TextDocumentWorkspaceSymbolRegistry,
} from '@workbench-stack/extension-api';
import { createFileService } from './file-service';
import { ViewProviderRegistry } from './view-service';
import { TextModelResolverService } from './text-model-resolver-service';
import { ContributionRegistry } from '../api/providers/contribution';
import { EMPTY_ENVIRONMENT } from '../api/environment';
import { editorWindowsService } from './windows-service';
import { LanguageFeatureRegistry } from '@vscode/monaco-editor/esm/vs/editor/common/modes/languageFeatureRegistry';
import { DocumentRangeFormattingEditProvider } from 'cdecode';
import { IClientService as IWorkbenchService } from '@workbench-stack/core';
// import {
//     TextDocumentDecorationProviderRegistry,
// } from './decoration';
/**
 * Services is a container for all services used by the client applicatino.
 */
export class Services implements IExtServices, IWorkbenchService {


    private environment = new BehaviorSubject(EMPTY_ENVIRONMENT);
    constructor(
        private platformContext: PlatformContext | any,
        private internalService: IWorkbenchService,
    ) {
        console.log('Services!!!!!!!!!!!');
    }

    public readonly windows = editorWindowsService(this.platformContext);
    public readonly configuration = settingsService(this.platformContext.apolloClient, this.platformContext.reduxState$);
    public readonly extensions = extensionsService(this.platformContext.apolloClient, this.platformContext.reduxState$);
    public readonly commands =  new CommandRegistry(); // CommandsRegistry as any; //commandService(this.platformContext.apolloClient, this.platformContext.reduxState$);
    public readonly contribution = new ContributionRegistry(this.environment, this.commands);
    // depreciate use modelService

    public readonly textDocumentDefinition = new TextDocumentLocationProviderRegistry();
    public readonly textDocumentImplementation = new TextDocumentLocationProviderRegistry();
    public readonly textDocumentReferences = new TextDocumentReferencesProviderRegistry();
    public readonly textDocumentTypeDefinition = new TextDocumentLocationProviderRegistry();
    public readonly textDocumentLocations = new TextDocumentLocationProviderIDRegistry();
    public readonly textDocumentHover = new TextDocumentHoverProviderRegistry();
    public readonly textDocumentСompletion = new TextDocumentСompletionProviderRegistry();
    public readonly textDocumentHightLight = new TextDocumentHightLightProviderRegistry();
    public readonly textDocumentRename = new TextDocumentRenameProviderRegistry();
    public readonly textDocumentFormatting = new TextDocumentFormattingProviderRegistry();
    public readonly textDocumentSymbolDefinition = new TextDocumentSymbolDefinitionProviderRegistry();
    public readonly textDocumentCodeAction = new TextDocumentCodeActionsRegistry();
    public readonly textDocumentCodeLenth = new TextDocumentCodeLenthRegistry();
    public readonly textDocumentLink = new TextDocumentLinkRegistry();
    public readonly textDocumentColor = new TextDocumentColorRegistry();
    public readonly textDocumentFoldingRanges = new TextDocumentFoldingRangesRegistry();
    public readonly rangeFormattingEditProviderRegistry = new LanguageFeatureRegistry<DocumentRangeFormattingEditProvider>();
    public readonly textDocumentWorkspaceSymbol = new TextDocumentWorkspaceSymbolRegistry();
    // public readonly textDocumentDecoration = new TextDocumentDecorationProviderRegistry();
    public readonly views = new ViewProviderRegistry();
    public readonly treeViews = new ViewProviderRegistry();
    public readonly fileService = createFileService(this.platformContext.apolloClient);



    public readonly editorService = this.internalService.editorService;
    public readonly editorGroupsService = this.internalService.editorGroupsService;
    public readonly codeEditorService = this.internalService.codeEditorService;
    public readonly textFileService = this.internalService.textFileService;
    public readonly untitledEditorService = this.internalService.untitledEditorService;
    public readonly modelService = this.internalService.modelService;
    public readonly modeService = this.internalService.modeService;
    public readonly contextKeyService = this.internalService.contextKeyService;
    public readonly resourceContextKey = this.internalService.resourceContextKey;
    public readonly lifecycleService = this.internalService.lifecycleService;
    public readonly preferenceEditorService = this.internalService.preferenceEditorService;
    public readonly jsonEditingService = this.internalService.jsonEditingService;
    public readonly workspaceContextService = this.internalService.workspaceContextService;
    public readonly configurationService = this.internalService.configurationService;
    public readonly notificationService = this.internalService.notificationService;
    public readonly dialogService = this.internalService.dialogService;
    public readonly statusbarService = this.internalService.statusbarService;
    public readonly keybindingService = this.internalService.keybindingService;
    public readonly keybindingEditingService = this.internalService.keybindingEditingService;
    public readonly keymapService = this.internalService.keymapService;
    public readonly storageService = this.internalService.storageService;
    public readonly commandService = this.internalService.commandService;

    /**
     *
     * @deprecated use modelService instead
     * @memberof Services
     */
    public model = this.internalService.modelService;
}
