import { Event } from '../../../../base/common/event.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
import { ExtensionIdentifier, IExtensionDescription, IExtension, IExtensionContributions } from '../../../../platform/extensions/common/extensions.js';
import { IFileService } from '../../../../platform/files/common/files.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { ILogService } from '../../../../platform/log/common/log.js';
import { INotificationService } from '../../../../platform/notification/common/notification.js';
import { IProductService } from '../../../../platform/product/common/productService.js';
import { IRemoteAuthorityResolverService, ResolverResult } from '../../../../platform/remote/common/remoteAuthorityResolver.js';
import { IRemoteExtensionsScannerService } from '../../../../platform/remote/common/remoteExtensionsScanner.js';
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js';
import { IWorkspaceContextService } from '../../../../platform/workspace/common/workspace.js';
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';
import { IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService } from '../../extensionManagement/common/extensionManagement.js';
import { ExtensionDescriptionRegistrySnapshot } from './extensionDescriptionRegistry.js';
import { IExtensionHostKindPicker, ExtensionHostKind } from './extensionHostKind.js';
import { IExtensionHostManager } from './extensionHostManagers.js';
import { IExtensionManifestPropertiesService } from './extensionManifestPropertiesService.js';
import { ExtensionRunningLocation } from './extensionRunningLocation.js';
import { ExtensionRunningLocationTracker } from './extensionRunningLocationTracker.js';
import { IExtensionService, IWillActivateEvent, IResponsiveStateChangeEvent, WillStopExtensionHostsEvent, IExtensionHost, ActivationKind, ExtensionActivationReason, ExtensionPointContribution, IExtensionsStatus } from './extensions.js';
import { ExtensionsProposedApi } from './extensionsProposedApi.js';
import { IExtensionPoint } from './extensionsRegistry.js';
import { ILifecycleService } from '../../lifecycle/common/lifecycle.js';
import { IRemoteAgentService } from '../../remote/common/remoteAgentService.js';

declare abstract class AbstractExtensionService extends Disposable implements IExtensionService {
    protected readonly _extensionsProposedApi: ExtensionsProposedApi;
    protected readonly _extensionHostFactory: IExtensionHostFactory;
    protected readonly _extensionHostKindPicker: IExtensionHostKindPicker;
    protected readonly _instantiationService: IInstantiationService;
    protected readonly _notificationService: INotificationService;
    protected readonly _environmentService: IWorkbenchEnvironmentService;
    protected readonly _telemetryService: ITelemetryService;
    protected readonly _extensionEnablementService: IWorkbenchExtensionEnablementService;
    protected readonly _fileService: IFileService;
    protected readonly _productService: IProductService;
    protected readonly _extensionManagementService: IWorkbenchExtensionManagementService;
    private readonly _contextService;
    private readonly _configurationService;
    private readonly _extensionManifestPropertiesService;
    protected readonly _logService: ILogService;
    protected readonly _remoteAgentService: IRemoteAgentService;
    protected readonly _remoteExtensionsScannerService: IRemoteExtensionsScannerService;
    private readonly _lifecycleService;
    protected readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService;
    private readonly _dialogService;
    _serviceBrand: undefined;
    private readonly _onDidRegisterExtensions;
    readonly onDidRegisterExtensions: Event<void>;
    private readonly _onDidChangeExtensionsStatus;
    readonly onDidChangeExtensionsStatus: Event<ExtensionIdentifier[]>;
    private readonly _onDidChangeExtensions;
    readonly onDidChangeExtensions: Event<{
        readonly added: ReadonlyArray<IExtensionDescription>;
        readonly removed: ReadonlyArray<IExtensionDescription>;
    }>;
    private readonly _onWillActivateByEvent;
    readonly onWillActivateByEvent: Event<IWillActivateEvent>;
    private readonly _onDidChangeResponsiveChange;
    readonly onDidChangeResponsiveChange: Event<IResponsiveStateChangeEvent>;
    private readonly _onWillStop;
    readonly onWillStop: Event<WillStopExtensionHostsEvent>;
    private readonly _activationEventReader;
    private readonly _registry;
    private readonly _installedExtensionsReady;
    private readonly _extensionStatus;
    private readonly _allRequestedActivateEvents;
    private readonly _runningLocations;
    private readonly _remoteCrashTracker;
    private _deltaExtensionsQueue;
    private _inHandleDeltaExtensions;
    private _extensionHostManagers;
    private _resolveAuthorityAttempt;
    constructor(_extensionsProposedApi: ExtensionsProposedApi, _extensionHostFactory: IExtensionHostFactory, _extensionHostKindPicker: IExtensionHostKindPicker, _instantiationService: IInstantiationService, _notificationService: INotificationService, _environmentService: IWorkbenchEnvironmentService, _telemetryService: ITelemetryService, _extensionEnablementService: IWorkbenchExtensionEnablementService, _fileService: IFileService, _productService: IProductService, _extensionManagementService: IWorkbenchExtensionManagementService, _contextService: IWorkspaceContextService, _configurationService: IConfigurationService, _extensionManifestPropertiesService: IExtensionManifestPropertiesService, _logService: ILogService, _remoteAgentService: IRemoteAgentService, _remoteExtensionsScannerService: IRemoteExtensionsScannerService, _lifecycleService: ILifecycleService, _remoteAuthorityResolverService: IRemoteAuthorityResolverService, _dialogService: IDialogService);
    protected _getExtensionHostManagers(kind: ExtensionHostKind): IExtensionHostManager[];
    private _getExtensionHostManagerByRunningLocation;
    protected _handleDeltaExtensions(item: DeltaExtensionsQueueItem): Promise<void>;
    private _deltaExtensions;
    private _updateExtensionsOnExtHosts;
    private _updateExtensionsOnExtHost;
    canAddExtension(extension: IExtensionDescription): boolean;
    private _canAddExtension;
    canRemoveExtension(extension: IExtensionDescription): boolean;
    private _activateAddedExtensionIfNeeded;
    protected _initialize(): Promise<void>;
    private _processExtensions;
    private _handleExtensionTests;
    private findTestExtensionHost;
    private _releaseBarrier;
    protected _resolveAuthorityInitial(remoteAuthority: string): Promise<ResolverResult>;
    protected _resolveAuthorityAgain(): Promise<void>;
    private _resolveAuthorityWithLogging;
    protected _resolveAuthorityOnExtensionHosts(kind: ExtensionHostKind, remoteAuthority: string): Promise<ResolverResult>;
    stopExtensionHosts(reason: string): Promise<boolean>;
    protected _doStopExtensionHosts(): void;
    private _doStopExtensionHostsWithVeto;
    private _startExtensionHostsIfNecessary;
    private _createExtensionHostManager;
    protected _doCreateExtensionHostManager(extensionHost: IExtensionHost, initialActivationEvents: string[]): IExtensionHostManager;
    private _onExtensionHostCrashOrExit;
    protected _onExtensionHostCrashed(extensionHost: IExtensionHostManager, code: number, signal: string | null): void;
    private _getExtensionHostExitInfoWithTimeout;
    private _onRemoteExtensionHostCrashed;
    protected _logExtensionHostCrash(extensionHost: IExtensionHostManager): void;
    startExtensionHosts(updates?: {
        toAdd: IExtension[];
        toRemove: string[];
    }): Promise<void>;
    activateByEvent(activationEvent: string, activationKind?: ActivationKind): Promise<void>;
    private _activateByEvent;
    activateById(extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<void>;
    activationEventIsDone(activationEvent: string): boolean;
    whenInstalledExtensionsRegistered(): Promise<boolean>;
    get extensions(): IExtensionDescription[];
    protected _getExtensionRegistrySnapshotWhenReady(): Promise<ExtensionDescriptionRegistrySnapshot>;
    getExtension(id: string): Promise<IExtensionDescription | undefined>;
    readExtensionPointContributions<T extends IExtensionContributions[keyof IExtensionContributions]>(extPoint: IExtensionPoint<T>): Promise<ExtensionPointContribution<T>[]>;
    getExtensionsStatus(): {
        [id: string]: IExtensionsStatus;
    };
    getInspectPorts(extensionHostKind: ExtensionHostKind, tryEnableInspector: boolean): Promise<number[]>;
    setRemoteEnvironment(env: {
        [key: string]: string | null;
    }): Promise<void>;
    private _safeInvokeIsEnabled;
    private _doHandleExtensionPoints;
    private _getOrCreateExtensionStatus;
    private _handleExtensionPointMessage;
    private static _handleExtensionPoint;
    private _acquireInternalAPI;
    _activateById(extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<void>;
    private _onWillActivateExtension;
    private _onDidActivateExtension;
    private _onDidActivateExtensionError;
    private _onExtensionRuntimeError;
    protected abstract _resolveExtensions(): Promise<ResolvedExtensions>;
    protected abstract _scanSingleExtension(extension: IExtension): Promise<IExtensionDescription | null>;
    protected abstract _onExtensionHostExit(code: number): void;
    protected abstract _resolveAuthority(remoteAuthority: string): Promise<ResolverResult>;
}
declare class ResolvedExtensions {
    readonly local: IExtensionDescription[];
    readonly remote: IExtensionDescription[];
    readonly hasLocalProcess: boolean;
    readonly allowRemoteExtensionsInLocalWebWorker: boolean;
    constructor(local: IExtensionDescription[], remote: IExtensionDescription[], hasLocalProcess: boolean, allowRemoteExtensionsInLocalWebWorker: boolean);
}
interface IExtensionHostFactory {
    createExtensionHost(runningLocations: ExtensionRunningLocationTracker, runningLocation: ExtensionRunningLocation, isInitialStart: boolean): IExtensionHost | null;
}
declare class DeltaExtensionsQueueItem {
    readonly toAdd: IExtension[];
    readonly toRemove: string[] | IExtension[];
    constructor(toAdd: IExtension[], toRemove: string[] | IExtension[]);
}

export { AbstractExtensionService, DeltaExtensionsQueueItem, type IExtensionHostFactory, ResolvedExtensions };
