import { ServiceIdentifier } from '../../../../platform/instantiation/common/instantiation.js';
import { Event } from '../../../../base/common/event.js';
import { IExtension, IExtensionManifest, ExtensionType, IExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
import { InstallExtensionResult, ILocalExtension, InstallOptions, IGalleryExtension, Metadata, IExtensionManagementService, InstallExtensionEvent, UninstallExtensionEvent, DidUninstallExtensionEvent } from '../../../../platform/extensionManagement/common/extensionManagement.js';
import { URI } from '../../../../base/common/uri.js';

type DidChangeProfileEvent = {
    readonly added: ILocalExtension[];
    readonly removed: ILocalExtension[];
};
declare const IProfileAwareExtensionManagementService: ServiceIdentifier<IProfileAwareExtensionManagementService>;
interface IProfileAwareExtensionManagementService extends IExtensionManagementService {
    readonly onDidChangeProfile: Event<DidChangeProfileEvent>;
}
interface IExtensionManagementServer {
    readonly id: string;
    readonly label: string;
    readonly extensionManagementService: IProfileAwareExtensionManagementService;
}
interface IResourceExtension {
    readonly identifier: IExtensionIdentifier;
    readonly location: URI;
    readonly manifest: IExtensionManifest;
    readonly readmeUri?: URI;
    readonly changelogUri?: URI;
}
type InstallExtensionOnServerEvent = InstallExtensionEvent & {
    server: IExtensionManagementServer;
};
type UninstallExtensionOnServerEvent = UninstallExtensionEvent & {
    server: IExtensionManagementServer;
};
type DidUninstallExtensionOnServerEvent = DidUninstallExtensionEvent & {
    server: IExtensionManagementServer;
};
type DidChangeProfileForServerEvent = DidChangeProfileEvent & {
    server: IExtensionManagementServer;
};
declare const IWorkbenchExtensionManagementService: ServiceIdentifier<IWorkbenchExtensionManagementService>;
interface IWorkbenchExtensionManagementService extends IProfileAwareExtensionManagementService {
    readonly _serviceBrand: undefined;
    onInstallExtension: Event<InstallExtensionOnServerEvent>;
    onDidInstallExtensions: Event<readonly InstallExtensionResult[]>;
    onUninstallExtension: Event<UninstallExtensionOnServerEvent>;
    onDidUninstallExtension: Event<DidUninstallExtensionOnServerEvent>;
    onDidChangeProfile: Event<DidChangeProfileForServerEvent>;
    onDidEnableExtensions: Event<IExtension[]>;
    isWorkspaceExtensionsSupported(): boolean;
    getExtensions(locations: URI[]): Promise<IResourceExtension[]>;
    getInstalledWorkspaceExtensions(includeInvalid: boolean): Promise<ILocalExtension[]>;
    installVSIX(location: URI, manifest: IExtensionManifest, installOptions?: InstallOptions): Promise<ILocalExtension>;
    installFromLocation(location: URI): Promise<ILocalExtension>;
    installResourceExtension(extension: IResourceExtension, installOptions: InstallOptions): Promise<ILocalExtension>;
    updateFromGallery(gallery: IGalleryExtension, extension: ILocalExtension, installOptions?: InstallOptions): Promise<ILocalExtension>;
}
declare const enum EnablementState {
    DisabledByTrustRequirement = 0,
    DisabledByExtensionKind = 1,
    DisabledByEnvironment = 2,
    EnabledByEnvironment = 3,
    DisabledByVirtualWorkspace = 4,
    DisabledByExtensionDependency = 5,
    DisabledGlobally = 6,
    DisabledWorkspace = 7,
    EnabledGlobally = 8,
    EnabledWorkspace = 9
}
declare const IWorkbenchExtensionEnablementService: ServiceIdentifier<IWorkbenchExtensionEnablementService>;
interface IWorkbenchExtensionEnablementService {
    readonly _serviceBrand: undefined;
    /**
     * Event to listen on for extension enablement changes
     */
    readonly onEnablementChanged: Event<readonly IExtension[]>;
    /**
     * Returns the enablement state for the given extension
     */
    getEnablementState(extension: IExtension): EnablementState;
    /**
     * Returns the enablement states for the given extensions
     * @param extensions list of extensions
     * @param workspaceTypeOverrides Workspace type overrides
     */
    getEnablementStates(extensions: IExtension[], workspaceTypeOverrides?: {
        trusted?: boolean;
    }): EnablementState[];
    /**
     * Returns the enablement states for the dependencies of the given extension
     */
    getDependenciesEnablementStates(extension: IExtension): [IExtension, EnablementState][];
    /**
     * Returns `true` if the enablement can be changed.
     */
    canChangeEnablement(extension: IExtension): boolean;
    /**
     * Returns `true` if the enablement can be changed.
     */
    canChangeWorkspaceEnablement(extension: IExtension): boolean;
    /**
     * Returns `true` if the given extension is enabled.
     */
    isEnabled(extension: IExtension): boolean;
    /**
     * Returns `true` if the given enablement state is enabled enablement state.
     */
    isEnabledEnablementState(enablementState: EnablementState): boolean;
    /**
     * Returns `true` if the given extension identifier is disabled globally.
     * Extensions can be disabled globally or in workspace or both.
     * If an extension is disabled in both then enablement state shows only workspace.
     * This will
     */
    isDisabledGlobally(extension: IExtension): boolean;
    /**
     * Enable or disable the given extension.
     * if `workspace` is `true` then enablement is done for workspace, otherwise globally.
     *
     * Returns a promise that resolves to boolean value.
     * if resolves to `true` then requires restart for the change to take effect.
     *
     * Throws error if enablement is requested for workspace and there is no workspace
     */
    setEnablement(extensions: IExtension[], state: EnablementState): Promise<boolean[]>;
    /**
     * Updates the enablement state of the extensions when workspace trust changes.
     */
    updateExtensionsEnablementsWhenWorkspaceTrustChanges(): Promise<void>;
}
interface IScannedExtension extends IExtension {
    readonly metadata?: Metadata;
}
type ScanOptions = {
    readonly skipInvalidExtensions?: boolean;
};
declare const IWebExtensionsScannerService: ServiceIdentifier<IWebExtensionsScannerService>;
interface IWebExtensionsScannerService {
    readonly _serviceBrand: undefined;
    scanSystemExtensions(): Promise<IExtension[]>;
    scanUserExtensions(profileLocation: URI, options?: ScanOptions): Promise<IScannedExtension[]>;
    scanExtensionsUnderDevelopment(): Promise<IExtension[]>;
    scanExistingExtension(extensionLocation: URI, extensionType: ExtensionType, profileLocation: URI): Promise<IScannedExtension | null>;
    addExtension(location: URI, metadata: Metadata, profileLocation: URI): Promise<IScannedExtension>;
    addExtensionFromGallery(galleryExtension: IGalleryExtension, metadata: Metadata, profileLocation: URI): Promise<IScannedExtension>;
    removeExtension(extension: IScannedExtension, profileLocation: URI): Promise<void>;
    copyExtensions(fromProfileLocation: URI, toProfileLocation: URI, filter: (extension: IScannedExtension) => boolean): Promise<void>;
    updateMetadata(extension: IScannedExtension, metaData: Partial<Metadata>, profileLocation: URI): Promise<IScannedExtension>;
    scanExtensionManifest(extensionLocation: URI): Promise<IExtensionManifest | null>;
}

export { type DidChangeProfileEvent, type DidChangeProfileForServerEvent, type DidUninstallExtensionOnServerEvent, EnablementState, type IExtensionManagementServer, IProfileAwareExtensionManagementService, type IResourceExtension, type IScannedExtension, IWebExtensionsScannerService, IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService, type InstallExtensionOnServerEvent, type ScanOptions, type UninstallExtensionOnServerEvent };
