import { GlobalConfigMain } from '@teambit/global-config';
import { Graph } from '@teambit/graph.cleargraph';
import type { AspectLoaderMain } from '@teambit/aspect-loader';
import { RawBuilderData } from '@teambit/builder';
import { AspectDefinition } from '@teambit/aspect-loader';
import { CLIMain } from '@teambit/cli';
import type { AspectData, ComponentMain, ComponentMap, ResolveAspectsOptions } from '@teambit/component';
import { Component, ComponentFactory, Snap, State } from '@teambit/component';
import type { GraphqlMain } from '@teambit/graphql';
import { Harmony, SlotRegistry } from '@teambit/harmony';
import { IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';
import { LoggerMain, Logger } from '@teambit/logger';
import { ExpressMain } from '@teambit/express';
import type { UiMain } from '@teambit/ui';
import { ComponentIdList, ComponentID } from '@teambit/component-id';
import { ModelComponent, Lane, Version } from '@teambit/legacy/dist/scope/models';
import LegacyScope, { LegacyOnTagResult } from '@teambit/legacy/dist/scope/scope';
import { LegacyComponentLog as ComponentLog } from '@teambit/legacy-component-log';
import { DependencyResolverMain, NodeLinker } from '@teambit/dependency-resolver';
import { Remotes } from '@teambit/legacy/dist/remotes';
import { CompIdGraph } from '@teambit/graph';
import { Types } from '@teambit/legacy/dist/scope/object-registrar';
import { ObjectList } from '@teambit/legacy/dist/scope/objects/object-list';
import { RequireableComponent } from '@teambit/harmony.modules.requireable-component';
import { SnapsDistance } from '@teambit/legacy/dist/scope/component-ops/snaps-distance';
import { AuthData } from '@teambit/legacy/dist/scope/network/http/http';
import { FETCH_OPTIONS } from '@teambit/legacy.scope-api';
import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
import { BitId } from '@teambit/legacy-bit-id';
import { ExtensionDataList } from '@teambit/legacy/dist/consumer/config';
import { EnvsMain } from '@teambit/envs';
import { DepEdge } from '@teambit/legacy/dist/scope/models/version';
import { ScopeComponentLoader } from './scope-component-loader';
import { StagedConfig } from './staged-config';
import { ScopeAspectsLoader, ScopeLoadAspectsOptions } from './scope-aspects-loader';
type RemoteEventMetadata = {
    auth?: AuthData;
    headers?: {};
};
type RemoteEvent<Data> = (data: Data, metadata: RemoteEventMetadata, errors?: Array<string | Error>) => Promise<void>;
type OnPostPutData = {
    ids: ComponentID[];
    lanes: Lane[];
};
type OnPostDeleteData = {
    ids: ComponentID[];
};
type OnPreFetchObjectData = {
    ids: string[];
    fetchOptions: FETCH_OPTIONS;
};
type OnPostPut = RemoteEvent<OnPostPutData>;
type OnPostExport = RemoteEvent<OnPostPutData>;
type OnPostDelete = RemoteEvent<OnPostDeleteData>;
type OnPostObjectsPersist = RemoteEvent<undefined>;
type OnPreFetchObjects = RemoteEvent<OnPreFetchObjectData>;
type OnCompAspectReCalc = (component: Component) => Promise<AspectData | undefined>;
export type OnPostPutSlot = SlotRegistry<OnPostPut>;
export type OnPostDeleteSlot = SlotRegistry<OnPostDelete>;
export type OnPostExportSlot = SlotRegistry<OnPostExport>;
export type OnPostObjectsPersistSlot = SlotRegistry<OnPostObjectsPersist>;
export type OnPreFetchObjectsSlot = SlotRegistry<OnPreFetchObjects>;
export type OnCompAspectReCalcSlot = SlotRegistry<OnCompAspectReCalc>;
export type LoadOptions = {
    /**
     * In case the component we are loading is app, whether to load it as app (in a scope aspects capsule)
     */
    loadApps?: boolean;
    /**
     * In case the component we are loading is env, whether to load it as env (in a scope aspects capsule)
     */
    loadEnvs?: boolean;
    /**
     * Should we load the components' aspects (this useful when you only want sometime to load the component itself
     * as aspect but not its aspects)
     */
    loadCompAspects?: boolean;
    /**
     * Should we load the components' custom envs when loading from the scope
     * This is usually not required unless you load an aspect with custom env from the scope
     * usually when signing aspects
     */
    loadCustomEnvs?: boolean;
};
export type ScopeConfig = {
    httpTimeOut: number;
    description?: string;
    icon?: string;
    backgroundIconColor?: string;
    /**
     * Set a different package manager for the aspects capsules
     */
    aspectsPackageManager?: string;
    /**
     * Set a different node linker for the aspects capsules
     */
    aspectsNodeLinker?: NodeLinker;
};
export declare class ScopeMain implements ComponentFactory {
    /**
     * private reference to the instance of Harmony.
     */
    private harmony;
    /**
     * legacy scope
     */
    readonly legacyScope: LegacyScope;
    /**
     * component extension.
     */
    readonly componentExtension: ComponentMain;
    /**
     * slot registry for subscribing to build
     */
    readonly config: ScopeConfig;
    private postPutSlot;
    private postDeleteSlot;
    private postExportSlot;
    private postObjectsPersist;
    preFetchObjects: OnPreFetchObjectsSlot;
    private OnCompAspectReCalcSlot;
    private isolator;
    private aspectLoader;
    private logger;
    private envs;
    private dependencyResolver;
    private globalConfig;
    componentLoader: ScopeComponentLoader;
    constructor(
    /**
     * private reference to the instance of Harmony.
     */
    harmony: Harmony, 
    /**
     * legacy scope
     */
    legacyScope: LegacyScope, 
    /**
     * component extension.
     */
    componentExtension: ComponentMain, 
    /**
     * slot registry for subscribing to build
     */
    config: ScopeConfig, postPutSlot: OnPostPutSlot, postDeleteSlot: OnPostDeleteSlot, postExportSlot: OnPostExportSlot, postObjectsPersist: OnPostObjectsPersistSlot, preFetchObjects: OnPreFetchObjectsSlot, OnCompAspectReCalcSlot: OnCompAspectReCalcSlot, isolator: IsolatorMain, aspectLoader: AspectLoaderMain, logger: Logger, envs: EnvsMain, dependencyResolver: DependencyResolverMain, globalConfig: GlobalConfigMain);
    priority?: boolean | undefined;
    localAspects: string[];
    /**
     * name of the scope
     */
    get name(): string;
    get icon(): string | undefined;
    get backgroundIconColor(): string | undefined;
    get description(): string | undefined;
    get path(): string;
    get isLegacy(): boolean;
    get isGlobalScope(): boolean;
    get aspectsPackageManager(): string | undefined;
    get aspectsNodeLinker(): NodeLinker | undefined;
    reloadAspectsWithNewVersion(components: ConsumerComponent[]): Promise<void>;
    loadAspects(ids: string[], throwOnError?: boolean | undefined, neededFor?: string | undefined, lane?: Lane, opts?: ScopeLoadAspectsOptions): Promise<string[]>;
    resolveAspects(runtimeName?: string | undefined, componentIds?: ComponentID[] | undefined, opts?: ResolveAspectsOptions | undefined): Promise<AspectDefinition[]>;
    getResolvedAspects(components: Component[], opts?: {
        skipIfExists?: boolean;
        packageManagerConfigRootDir?: string;
        workspaceName?: string;
    }): Promise<RequireableComponent[]>;
    executeOnCompAspectReCalcSlot(component: Component): Promise<Component>;
    getDependencies(component: Component): import("@teambit/dependency-resolver").DependencyList;
    componentPackageName(component: Component): string;
    private upsertExtensionData;
    private getDataEntry;
    getIsolateAspectsOpts(opts?: {
        skipIfExists?: boolean;
        packageManagerConfigRootDir?: string;
        workspaceName?: string;
    }): IsolateComponentsOptions;
    getAspectCapsulePath(): string;
    shouldUseHashForCapsules(): boolean;
    getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;
    getScopeAspectsLoader(): ScopeAspectsLoader;
    clearCache(): Promise<void>;
    builderDataMapToLegacyOnTagResults(builderDataComponentMap: ComponentMap<RawBuilderData>): LegacyOnTagResult[];
    /**
     * register to the post-export slot.
     */
    onPostPut(postPutFn: OnPostPut): this;
    /**
     * register to the post-delete slot.
     */
    onPostDelete(postDeleteFn: OnPostDelete): this;
    /**
     * register to the post-export slot.
     */
    registerOnPostExport(postExportFn: OnPostExport): this;
    registerOnPreFetchObjects(preFetchObjectsFn: OnPreFetchObjects): this;
    registerOnCompAspectReCalc(compAspectReCalcSlotFn: OnCompAspectReCalc): void;
    registerOnPostObjectsPersist(postObjectsPersistFn: OnPostObjectsPersist): this;
    /**
     * Will fetch a list of components into the current scope.
     * This will only fetch the object and won't write the files to the actual FS
     */
    fetch(ids: ComponentIdList): void;
    delete({ ids, force, lanes }: {
        ids: string[];
        force: boolean;
        lanes: boolean;
    }, headers?: Record<string, any>): Promise<import("@teambit/legacy/dist/scope/removed-components").RemovedObjectSerialized>;
    isExported(id: ComponentID): boolean;
    /**
     * for long-running processes, such as `bit start` or `bit watch`, it's important to keep the following data up to date:
     * 1. scope-index (.bit/index.json file).
     * 2. remote-refs (.bit/refs/*).
     * 3. global config. so for example if a user logs in or out it would be reflected.
     * it's possible that other commands (e.g. `bit import`) modified these files, while these processes are running.
     * Because these data are kept in memory, they're not up to date anymore.
     */
    watchScopeInternalFiles(): Promise<void>;
    toObjectList(types: Types): Promise<ObjectList>;
    private toJs;
    getGraph(ids?: ComponentID[]): Promise<Graph<Component, string>>;
    getGraphIds(ids?: ComponentID[]): Promise<CompIdGraph>;
    getFlattenedEdges(id: ComponentID): Promise<DepEdge[] | undefined>;
    private getSavedGraphOfComponentIfExist;
    /**
     * import components into the scope.
     */
    import(ids: ComponentID[], { useCache, reFetchUnBuiltVersion, preferDependencyGraph, lane, reason, }?: {
        /**
         * if the component exists locally, don't go to the server to search for updates.
         */
        useCache?: boolean;
        /**
         * if the Version objects exists locally, but its `buildStatus` is Pending or Failed, reach the remote to find
         * whether the version was already built there.
         */
        reFetchUnBuiltVersion?: boolean;
        /**
         * if the component is on a lane, provide the lane object. the component will be fetched from the lane-scope and
         * not from the component-scope.
         */
        lane?: Lane;
        /**
         * if an external is missing and the remote has it with the dependency graph, don't fetch all its dependencies
         */
        preferDependencyGraph?: boolean;
        /**
         * reason why this import is needed (to show in the terminal)
         */
        reason?: string;
    }): Promise<void>;
    get(id: ComponentID, useCache?: boolean, importIfMissing?: boolean): Promise<Component | undefined>;
    getFromConsumerComponent(consumerComponent: ConsumerComponent): Promise<Component>;
    /**
     * get a component from a remote without importing it
     */
    getRemoteComponent(id: ComponentID): Promise<Component>;
    /**
     * get a component from a remote without importing it
     */
    getManyRemoteComponents(ids: ComponentID[]): Promise<Component[]>;
    /**
     * list all components in the scope.
     */
    list(filter?: {
        offset: number;
        limit: number;
        namespaces?: string[];
    }, includeCache?: boolean, includeFromLanes?: boolean, includeDeleted?: boolean): Promise<Component[]>;
    /**
     * for now, list of invalid components are mostly useful for the workspace.
     * in the future, this can return components that failed to load in the scope due to objects file
     * corruption or similar issues.
     */
    listInvalid(): Promise<never[]>;
    /**
     * get ids of all scope components.
     * @param includeCache whether or not include components that their scope-name is different than the current scope-name
     */
    listIds(includeCache?: boolean, includeFromLanes?: boolean, patterns?: string[]): Promise<ComponentID[]>;
    /**
     * Check if a specific id exist in the scope
     * @param componentId
     */
    hasId(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;
    hasIdNested(componentId: ComponentID, includeCache?: boolean): Promise<boolean>;
    /**
     * determine whether a component exists in the scope.
     */
    exists(modelComponent: ModelComponent): boolean;
    getMany(ids: ComponentID[], throwIfNotExist?: boolean): Promise<Component[]>;
    /**
     * important! you probably want to use `getMany`, which returns the components from the scope.
     * this method loads all aspects of the loaded components. (which hurts performance)
     */
    loadMany(ids: ComponentID[], lane?: Lane, opts?: LoadOptions): Promise<Component[]>;
    loadManyCompsAspects(components: Component[], lane?: Lane): Promise<Component[]>;
    /**
     * get a component and throw an exception if not found.
     * @param id component id
     */
    getOrThrow(id: ComponentID): Promise<Component>;
    /**
     * returns a specific state of a component.
     * @param id component ID.
     * @param hash state hash.
     */
    getState(id: ComponentID, hash: string): Promise<State>;
    getSnap(id: ComponentID, hash: string): Promise<Snap>;
    /**
     * get component log sorted by the timestamp in ascending order (from the earliest to the latest)
     */
    getLogs(id: ComponentID, shortHash?: boolean, startsFrom?: string, throwIfMissing?: boolean): Promise<ComponentLog[]>;
    getStagedConfig(): Promise<StagedConfig>;
    /**
     * whether a component is soft-removed.
     * the version is required as it can be removed on a lane. in which case, the version is the head in the lane.
     */
    isComponentRemoved(id: ComponentID): Promise<Boolean>;
    /**
     * whether the id with the specified version exits in the local scope.
     */
    isComponentInScope(id: ComponentID): Promise<boolean>;
    /**
     * resolve a component ID.
     * @param id component ID.
     */
    resolveComponentId(id: string | BitId | ComponentID): Promise<ComponentID>;
    private resolveComponentIdFromBitId;
    resolveMultipleComponentIds(ids: Array<string | ComponentID | ComponentID>): Promise<ComponentID[]>;
    /**
     * @deprecated use `this.idsByPattern` instead for consistency, which supports also negation and list of patterns.
     */
    byPattern(patterns: string[], scope?: string): Promise<Component[]>;
    /**
     * get component-ids matching the given pattern. a pattern can have multiple patterns separated by a comma.
     * it uses multimatch (https://www.npmjs.com/package/multimatch) package for the matching algorithm, which supports
     * (among others) negate character "!" to exclude ids. See the package page for more supported characters.
     */
    idsByPattern(pattern: string, throwForNoMatch?: boolean): Promise<ComponentID[]>;
    filterIdsFromPoolIdsByPattern(pattern: string, ids: ComponentID[], throwForNoMatch?: boolean, filterByStateFunc?: (state: any, poolIds: ComponentID[]) => Promise<ComponentID[]>): Promise<ComponentID[]>;
    getSnapDistance(id: ComponentID, throws?: boolean): Promise<SnapsDistance>;
    /**
     * get the distance for a component between two lanes. for example, lane-b forked from lane-a and lane-b added some new snaps
     * @param componentId
     * @param sourceHead head on the source lane. leave empty if the source is main
     * @param targetHead head on the target lane. leave empty if the target is main
     * @returns
     */
    getSnapsDistanceBetweenTwoSnaps(componentId: ComponentID, sourceHead?: string, targetHead?: string, throws?: boolean): Promise<SnapsDistance>;
    getExactVersionBySemverRange(id: ComponentID, range: string): Promise<string | undefined>;
    resumeExport(exportId: string, remotes: string[]): Promise<string[]>;
    /**
     * @deprecated use `this.resolveComponentId` instead.
     */
    resolveId(id: string): Promise<ComponentID>;
    _legacyRemotes(): Promise<Remotes>;
    /**
     * list all component ids from a remote-scope
     */
    listRemoteScope(scopeName: string): Promise<ComponentID[]>;
    getLegacyMinimal(id: ComponentID): Promise<ConsumerComponent | undefined>;
    /**
     * ModelComponent is of type `BitObject` which gets saved into the local scope as an object file.
     * It has data about the tags and the component head. It doesn't have any data about the source-files/artifacts etc.
     */
    getBitObjectModelComponent(id: ComponentID, throwIfNotExist?: boolean): Promise<ModelComponent | undefined>;
    /**
     * Version BitObject holds the data of the source files and build artifacts of a specific snap/tag.
     */
    getBitObjectVersion(modelComponent: ModelComponent, version: string, throwIfNotExist?: boolean): Promise<Version | undefined>;
    getBitObjectVersionById(id: ComponentID, throwIfNotExist?: boolean): Promise<Version | undefined>;
    /**
     * get a component and load its aspect
     */
    load(id: ComponentID, lane?: Lane, opts?: LoadOptions): Promise<Component | undefined>;
    loadCompAspects(component: Component, lane?: Lane, opts?: LoadOptions): Promise<Component>;
    loadComponentsAspect(component: Component): Promise<void>;
    addAspectsFromConfigObject(component: Component, configObject: Record<string, any>): Promise<void>;
    createAspectListFromExtensionDataList(extensionDataList: ExtensionDataList): Promise<import("@teambit/component").AspectList>;
    private extensionDataEntryToAspectEntry;
    getLastMergedPath(): string;
    isModified(): Promise<boolean>;
    write(): Promise<void>;
    hasObjects(hashes: string[]): Promise<string[]>;
    /**
     * declare the slots of scope extension.
     */
    static slots: (((registerFn: () => string) => SlotRegistry<OnPostPut>) | ((registerFn: () => string) => SlotRegistry<OnPostObjectsPersist>) | ((registerFn: () => string) => SlotRegistry<OnPreFetchObjects>) | ((registerFn: () => string) => SlotRegistry<OnCompAspectReCalc>))[];
    static runtime: import("@teambit/harmony").RuntimeDefinition;
    static dependencies: import("@teambit/harmony").Aspect[];
    static defaultConfig: ScopeConfig;
    static provider([componentExt, ui, graphql, cli, isolator, aspectLoader, express, loggerMain, envs, depsResolver, globalConfig]: [
        ComponentMain,
        UiMain,
        GraphqlMain,
        CLIMain,
        IsolatorMain,
        AspectLoaderMain,
        ExpressMain,
        LoggerMain,
        EnvsMain,
        DependencyResolverMain,
        GlobalConfigMain
    ], config: ScopeConfig, [postPutSlot, postDeleteSlot, postExportSlot, postObjectsPersistSlot, preFetchObjectsSlot, OnCompAspectReCalcSlot,]: [
        OnPostPutSlot,
        OnPostDeleteSlot,
        OnPostExportSlot,
        OnPostObjectsPersistSlot,
        OnPreFetchObjectsSlot,
        OnCompAspectReCalcSlot
    ], harmony: Harmony): Promise<ScopeMain | undefined>;
}
export {};
