import { UserImporterOptions, ImportCandidate } from 'ipfs-unixfs-importer';
import * as ipfs_unixfs_importer_types_src_types from 'ipfs-unixfs-importer/types/src/types';
import * as Web3 from 'web3';
import Web3__default from 'web3';
import * as bn_js from 'bn.js';
import { AbiItem } from 'web3-utils';
import * as axios from 'axios';
import { AxiosResponse, AxiosRequestConfig, AxiosError } from 'axios';
import FormData from 'form-data';
import { provider } from 'web3-core';

declare type Content = ReadableStream | Buffer | string;
interface ImageHasher {
    options: UserImporterOptions;
    content: ImportCandidate;
}
interface NonImageHasher {
    options: UserImporterOptions;
    content: Uint8Array;
}
interface HashedImage {
    path: string | undefined;
    cid: string;
    size: number;
}

type ContractABI = {
  abi: AbiItem[]
  contractName: string
}

declare class Utils {
    static importDataContractABI(pathStr: string): ContractABI;
    static importEthContractABI(pathStr: string): Record<string, unknown>;
    static utf8ToHex(utf8Str: string): string;
    static padRight(hexStr: string, size: number): string;
    static hexToUtf8(hexStr: string): string;
    static keccak256(utf8Str: string): string;
    static isBN(number: number): boolean;
    static toBN(number: number, base: number): bn_js;
    static BN(): typeof bn_js;
    static checkStrLen(str: string, maxLen: number, minLen?: number): void;
    static wait(milliseconds: number): Promise<void>;
    static isFQDN(url: string): boolean;
    static isHttps(url: string): boolean;
    static isHealthy(url: string): Promise<any>;
    static formatOptionalMultihash(multihash: string): string;
    static decodeMultihash(multihash: string): {
        digest: string;
        hashFn: number;
        size: number;
    };
    /**
     * Given a digest value (written on chain, obtained through AudiusABIDecoder.decodeMethod),
     * convert back to a IFPS CIDv0
     * @param multihashDigest digest value from decodeMultihash
     * @returns String CID value
     */
    static encodeMultihash(multihashDigest: string): string;
    static parseDataFromResponse(response: AxiosResponse): any;
    static configureWeb3(web3Provider: string, chainNetworkId: string, requiresAccount?: boolean): Promise<false | Web3.default>;
    static get zeroAddress(): string;
    static isZeroAddress(address: string): boolean;
    static makeUuid(): string;
    /**
     * Decodes a string id into an int. Returns null if an invalid ID.
     */
    static decodeHashId(id: string): number | null;
    /**
     * Encodes an int to a string based hashid
     */
    static encodeHashId(id: number | null): string | null;
    /**
     * If `promise` responds before `timeoutMs`,
     * this function returns its response; else rejects with `timeoutMessage`
     */
    static racePromiseWithTimeout(promise: Promise<void>, timeoutMs: number, timeoutMessage: string): Promise<unknown>;
    static fileHasher: {
        convertNanosToMillis(nanoSeconds: bigint): bigint;
        initImageHasher(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, options: ipfs_unixfs_importer_types_src_types.UserImporterOptions): ImageHasher;
        initNonImageHasher(content: Uint8Array, options: ipfs_unixfs_importer_types_src_types.UserImporterOptions): NonImageHasher;
        convertToBuffer(content: Content, logger: any): Promise<Buffer>;
        hashNonImages(content: Uint8Array, options?: ipfs_unixfs_importer_types_src_types.UserImporterOptions): Promise<string>;
        hashImages(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, options?: ipfs_unixfs_importer_types_src_types.UserImporterOptions): Promise<HashedImage[]>;
        generateNonImageCid(content: Content, logger?: any): Promise<string>;
        generateImageCids(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, logger?: any): Promise<HashedImage[]>;
    };
}

declare global {
    interface Window {
        grecaptcha: {
            ready: (callback: () => void) => Promise<void>;
            execute: (siteKey: string, config: {
                action: string;
            }) => Promise<string>;
        };
    }
}

declare type ServiceName = string;
interface ServiceWithEndpoint {
    endpoint: string;
    spID?: string;
}
declare type Service = ServiceName | ServiceWithEndpoint;
interface Request {
    id?: string;
    url: string;
}
interface Timing {
    request: Request;
    response: AxiosResponse | null;
    millis: number | null;
}

declare type Maybe<T> = T | undefined;
interface Logger {
    /**
     * Write a 'log' level log.
     */
    log: (message: any, ...optionalParams: any[]) => any;
    /**
     * Write a 'info' level log.
     */
    info: (message: any, ...optionalParams: any[]) => any;
    /**
     * Write an 'error' level log.
     */
    error: (message: any, ...optionalParams: any[]) => any;
    /**
     * Write a 'warn' level log.
     */
    warn: (message: any, ...optionalParams: any[]) => any;
    /**
     * Write a 'debug' level log.
     */
    debug?: (message: any, ...optionalParams: any[]) => any;
    /**
     * Write a 'verbose' level log.
     */
    verbose?: (message: any, ...optionalParams: any[]) => any;
}

declare type SchemaConfig = {
    schema: {
        definitions: Record<string, {
            required: string[];
            properties: Record<string, {
                default: unknown;
            }>;
        } | {}>;
    };
    baseDefinition: string;
    validate?: (obj: Record<string, unknown>) => void;
};
declare type Schemas = {
    TrackSchema: SchemaConfig;
    UserSchema: SchemaConfig;
};

type Web3Config = {
  useExternalWeb3: boolean
  internalWeb3Config: {
    web3ProviderEndpoints: string[]
  }
}

declare class Web3Manager {
  getWalletAddress(): string
  sign(clientChallengeKey: string): Promise<string>
  provider(service: string, timeout: number): provider
  getWeb3(): Web3__default
  setWeb3(web3: Web3__default)
  web3Config: Web3Config
  web3: Web3__default
}

declare type CurrentUser = {
    user_id: string;
    wallet: string;
    blocknumber: number;
    track_blocknumber: number;
    creator_node_endpoint: string;
    is_creator: boolean;
};
/**
 * Singleton class to store the current user if initialized.
 * Some instances of AudiusLibs and services require a current user to
 * return valid queries, e.g. requesting the a discprov to return a reposted track.
 */
declare class UserStateManager {
    currentUser: CurrentUser | null;
    constructor();
    /**
     * Sets this.currentUser with currentUser
     * @param {Object} currentUser fields to override this.currentUser with
     */
    setCurrentUser(currentUser: CurrentUser): void;
    getCurrentUser(): CurrentUser | null;
    getCurrentUserId(): string | null;
    clearUser(): void;
}

declare type Metadata = {
    track_segments: unknown;
    download?: {
        is_downloadable: boolean;
        cid: string;
    };
    cover_art_sizes: string;
};
declare type ProgressCB = (loaded: number, total: number) => void;
declare type MonitoringCallbacks = {
    request?: Function;
    healthCheck?: Function;
};
declare type ClockValueRequestConfig = {
    user: CurrentUser;
    endpoint: string;
    timeout?: number;
};
declare type FileUploadResponse = {
    data: {
        uuid: string;
    };
    error: Error;
};
declare class CreatorNode$1 {
    /**
     * Pulls off the primary creator node from a creator node endpoint string.
     * @param endpoints user.creator_node_endpoint
     */
    static getPrimary(endpoints: string): string | undefined;
    /**
     * Pulls off the secondary creator nodes from a creator node endpoint string.
     * @param endpoints user.creator_node_endpoint
     */
    static getSecondaries(endpoints: string): string[];
    /**
     * Pulls the user's creator nodes out of the list
     * @param endpoints user.creator_node_endpoint
     */
    static getEndpoints(endpoints: string): string[];
    /**
     * Builds the creator_node_endpoint value off of a primary and secondaries list
     * @param primary the primary endpoint
     * @param secondaries a list of secondary endpoints
     */
    static buildEndpoint(primary: string, secondaries: string[]): string;
    /**
     * Pulls off the user's clock value from a creator node endpoint and the user's wallet address.
     * @param endpoint content node endpoint
     * @param wallet user wallet address
     * @param timeout max time alloted for clock request
     * @param params optional query string params
     */
    static getClockValue(endpoint: string, wallet: string, timeout: number, params?: Record<string, string>): Promise<any>;
    /**
     * Checks if a download is available from provided creator node endpoints
     * @param endpoints creator node endpoints
     * @param trackId
     */
    static checkIfDownloadAvailable(endpoints: string, trackId: number): Promise<any>;
    web3Manager: Web3Manager;
    creatorNodeEndpoint: string;
    isServer: boolean;
    userStateManager: UserStateManager;
    lazyConnect: boolean;
    schemas: Schemas;
    passList: Set<string> | null;
    blockList: Set<string> | null;
    monitoringCallbacks: MonitoringCallbacks;
    connected: boolean;
    connecting: boolean;
    authToken: null;
    maxBlockNumber: number;
    /**
     * Constructs a service class for a creator node
     * @param web3Manager
     * @param creatorNodeEndpoint fallback creator node endpoint (to be deprecated)
     * @param isServer
     * @param userStateManager  singleton UserStateManager instance
     * @param lazyConnect whether or not to lazy connect (sign in) on load
     * @param schemas
     * @param passList whether or not to include only specified nodes (default null)
     * @param blockList whether or not to exclude any nodes (default null)
     * @param monitoringCallbacks callbacks to be invoked with metrics from requests sent to a service
     */
    constructor(web3Manager: Web3Manager, creatorNodeEndpoint: string, isServer: boolean, userStateManager: UserStateManager, lazyConnect: boolean, schemas: Schemas, passList?: Set<string> | null, blockList?: Set<string> | null, monitoringCallbacks?: MonitoringCallbacks);
    init(): Promise<void>;
    /** Establishes a connection to a content node endpoint */
    connect(): Promise<void>;
    /** Checks if connected, otherwise establishing a connection */
    ensureConnected(): Promise<void>;
    getEndpoint(): string;
    /**
     * Switch from one creatorNodeEndpoint to another including logging out from the old node, updating the endpoint and logging into new node */
    setEndpoint(creatorNodeEndpoint: string): Promise<void>;
    /** Clear all connection state in this class by deleting authToken and setting 'connected' = false */
    clearConnection(): void;
    /**
     * Uploads creator content to a creator node
     * @param metadata the creator metadata
     */
    uploadCreatorContent(metadata: Metadata, blockNumber?: null): Promise<any>;
    /**
     * Creates a creator on the creator node, associating user id with file content
     * @param audiusUserId returned by user creation on-blockchain
     * @param metadataFileUUID unique ID for metadata file
     * @param blockNumber
     */
    associateCreator(audiusUserId: number, metadataFileUUID: string, blockNumber: number): Promise<void>;
    /**
     * Uploads a track (including audio and image content) to a creator node
     * @param trackFile the audio content
     * @param coverArtFile the image content
     * @param metadata the metadata for the track
     * @param onProgress an optional on progress callback
     */
    uploadTrackContent(trackFile: File, coverArtFile: File, metadata: Metadata, onProgress?: ProgressCB): Promise<any>;
    /**
     * Uploads track metadata to a creator node
     * The metadata object must include a `track_id` field or a
     * source file must be provided (returned from uploading track content).
     * @param metadata
     * @param sourceFile
     */
    uploadTrackMetadata(metadata: Metadata, sourceFile: string): Promise<any>;
    /**
     * Creates a track on the content node, associating track id with file content
     * @param audiusTrackId returned by track creation on-blockchain
     * @param metadataFileUUID unique ID for metadata file
     * @param blockNumber
     * @param transcodedTrackUUID the CID for the transcoded master if this is a first-time upload
     */
    associateTrack(audiusTrackId: number, metadataFileUUID: string, blockNumber: number, transcodedTrackUUID: string): Promise<void>;
    /**
     * Uploads an image to the connected content node
     * @param file image to upload
     * @param onProgress called with loaded bytes and total bytes
     * @param timeoutMs timeout in ms axios request to upload file to CN will wait
     * @return response body
     */
    uploadImage(file: File, square: boolean | undefined, onProgress: ProgressCB, timeoutMs?: number | null): Promise<{
        uuid: string;
    }>;
    /**
     * @param file track to upload
     * @param onProgress called with loaded bytes and total bytes
     * @return response body
     */
    uploadTrackAudio(file: File, onProgress: ProgressCB): Promise<any>;
    handleAsyncTrackUpload(file: File, onProgress: ProgressCB): Promise<any>;
    pollProcessingStatus(uuid: string): Promise<any>;
    /**
     * Gets the task progress given the task type and uuid associated with the task
     * @param uuid the uuid of the track transcoding task
     * @returns the status, and the success or failed response if the task is complete
     */
    getTrackContentProcessingStatus(uuid: string): Promise<any>;
    /**
     * Given a particular endpoint to a creator node, check whether
     * this user has a sync in progress on that node.
     * @param endpoint
     * @param timeout ms
     */
    getSyncStatus(endpoint: string, timeout?: number | null): Promise<{
        status: any;
        userBlockNumber: number;
        trackBlockNumber: number;
        isBehind: boolean;
        isConfigured: boolean;
    }>;
    /**
     * Syncs a secondary creator node for a given user
     * @param secondary
     * @param primary specific primary to use
     * @param immediate whether or not this is a blocking request and handled right away
     * @param validate whether or not to validate the provided secondary is valid
     */
    syncSecondary(secondary: string, primary?: string, immediate?: boolean, validate?: boolean): Promise<axios.AxiosResponse<any> | undefined>;
    /**
     * Signs up a creator node user with a wallet address
     * @param walletAddress
     */
    _signupNodeUser(walletAddress: string): Promise<void>;
    /**
     * Logs user into cnode, if not already logged in.
     * Requests a challenge from cnode, sends signed challenge response to cn.
     * If successful, receive and set authToken locally.
     */
    _loginNodeUser(): Promise<void>;
    /** Calls logout on the content node. Needs an authToken for this since logout is an authenticated endpoint */
    _logoutNodeUser(): Promise<void>;
    /**
     * Gets and returns the clock values across the replica set for the wallet in userStateManager.
     * @returns Array of objects with the structure:
     *
     * {
     *  type: 'primary' or 'secondary',
     *  endpoint: <Content Node endpoint>,
     *  clockValue: clock value (should be an integer) or null
     * }
     *
     * 'clockValue' may be null if the request to fetch the clock value fails
     */
    getClockValuesFromReplicaSet(): Promise<{
        type: string;
        endpoint: string;
        clockValue: any;
    }[] | undefined>;
    /**
     * Wrapper around getClockValue() to return either a proper or null clock value
     * @param {Object} param
     * @param {Object} param.user user metadata object from userStateManager
     * @param {string} param.endpoint the Content Node endpoint to check the clock value for
     * @param {number?} [param.timeout=1000] the max time allotted for a clock request; defaulted to 1000ms
     */
    _clockValueRequest({ user, endpoint, timeout }: ClockValueRequestConfig): Promise<{
        type: string;
        endpoint: string;
        clockValue: any;
    }>;
    /**
     * Makes an axios request to the connected creator node.
     * @param requiresConnection if set, the currently configured creator node
     * is connected to before the request is made.
     * @return response body
     */
    _makeRequest(axiosRequestObj: AxiosRequestConfig, requiresConnection?: boolean): Promise<any>;
    /**
     * Create headers and formData for file upload
     * @param {Object} file the file to upload
     * @param {boolean} [isTrackUpload] flag to determine if uploading track. If true, add track upload headers
     * @returns headers and formData in an object
     */
    createFormDataAndUploadHeaders(file: File, extraFormDataOptions?: Record<string, unknown>): {
        headers: Record<string, string | null>;
        formData: FormData;
    };
    /**
     * Uploads a file to the connected creator node.
     * @param file
     * @param route route to handle upload (image_upload, track_upload, etc.)
     * @param onProgress called with loaded bytes and total bytes
     * @param extraFormDataOptions extra FormData fields passed to the upload
     * @param retries max number of attempts made for axios request to upload file to CN before erroring
     * @param timeoutMs timeout in ms axios request to upload file to CN will wait
     */
    _uploadFile(file: File, route: string, onProgress?: ProgressCB, extraFormDataOptions?: Record<string, unknown>, retries?: number, timeoutMs?: number | null): Promise<FileUploadResponse>;
    _handleErrorHelper(e: Error | AxiosError, requestUrl?: string, requestId?: string | null): Promise<void>;
}

declare class EthContracts {
  getCurrentVersion: (serviceName: string) => Promise<string>
  getNumberOfVersions: (spType: string) => Promise<number>
  getVersion: (spType: string, queryIndex: number) => Promise<string>
  getServiceProviderList: (
    serviceName: string
  ) => Promise<ServiceWithEndpoint[]>

  hasSameMajorAndMinorVersion: (version1: string, version2: string) => boolean
  isInRegressedMode: () => boolean
}

declare type GetServicesInput = (() => Promise<ServiceName[]>) | ((config: {
    verbose: false;
}) => Promise<ServiceName[]>) | ((config: {
    verbose: true;
}) => Promise<ServiceWithEndpoint[]>) | ((config: {
    verbose: boolean;
}) => Promise<ServiceName[] | ServiceWithEndpoint[]>);
interface GetServices {
    (): Promise<ServiceName[]>;
    (config: {
        verbose: false;
    }): Promise<ServiceName[]>;
    (config: {
        verbose: true;
    }): Promise<ServiceWithEndpoint[]>;
    (config: {
        verbose: boolean;
    }): Promise<Service[]>;
}
interface Decision$1 {
    stage: string;
    val?: unknown;
}
declare type Backup = {
    block_difference: number;
    version: string;
};
interface ServiceSelectionConfig {
    blacklist?: Set<string> | undefined | null;
    whitelist?: Set<string> | undefined | null;
    getServices: GetServicesInput;
    maxConcurrentRequests?: number;
    requestTimeout?: Maybe<number>;
    unhealthyTTL?: number;
    backupsTTL?: number;
}
/**
 * A class that assists with autoselecting services.
 * `ServiceSelection` is intended to be overridden with further
 * business logic that a particular sevice might preference.
 *
 * The general use case is as follows:
 *
 * ```
 *
 * const selector = new ServiceSelection({
 *   getServices: ethContracts.getDiscoveryProviders()
 * })
 *
 * const service = await selector.select()
 *
 * ```
 *
 * This class operates by taking a list of services and
 * round-robin makes requests at them until a suitable one is found.
 *
 * Two types of "bad" services are defined below:
 *  - Unhealthy: this service is bad and should not be used
 *  - Backup: this service is bad, but if we can't find anything better, maybe use it
 *
 * Classes that extend `ServiceSelection` can choose to implement custom logic on top
 * of them and is generally how this class is intended to be used.
 */
declare class ServiceSelection {
    blacklist: Set<string> | undefined | null;
    whitelist: Set<string> | undefined | null;
    getServices: GetServices;
    maxConcurrentRequests: number;
    requestTimeout: number;
    unhealthyTTL: number;
    backupsTTL: number;
    unhealthy: Set<string>;
    backups: Record<string, Backup>;
    totalAttempts: number;
    decisionTree: Decision$1[];
    unhealthyCleanupTimeout: NodeJS.Timeout | null;
    backupCleanupTimeout: NodeJS.Timeout | null;
    constructor({ blacklist, whitelist, getServices, maxConcurrentRequests, requestTimeout, // 30s
    unhealthyTTL, // 1 hour
    backupsTTL }: ServiceSelectionConfig);
    /**
     * Selects a service
     * @param reset if reset is true, clear the decision tree
     */
    select(reset?: any): Promise<any>;
    /**
     * Finds all selectable services (respecting whitelist, health checks & timeouts).
     * Note: this method is potentially slow.
     * If you need just a single service, prefer calling `.select()`
     * @param {boolean} verbose whether or not to return full services metadata
     * @param {Set} whitelist a whitelist to override the set of endpoints
     */
    findAll({ verbose, whitelist }?: {
        verbose?: boolean | undefined;
        whitelist?: Set<string> | null | undefined;
    }): Promise<(Service | null)[]>;
    /** Triggers a clean up of unhealthy and backup services so they can be retried later */
    triggerCleanup(): void;
    clearUnhealthy(): void;
    clearBackups(): void;
    /** A short-circuit. If overriden, can be used to skip selection (which could be slow) */
    shortcircuit(): null | string;
    /**
     * Filter out services that are in the blacklist
     * @param services endpoints
     */
    filterFromBlacklist(services: string[]): string[];
    /** Filter down services to those in the whitelist */
    filterToWhitelist(services: string[]): string[];
    /** Filter out known unhealthy services from the provided */
    filterOutKnownUnhealthy(services: string[]): string[];
    /** Given a list of services, samples maxConcurrentRequests from them */
    getSelectionRound(services: string[]): string[];
    /** Gets the total number of attempts we've made this instantiation */
    getTotalAttempts(): number;
    /** Where does the health check for this type of service live */
    static getHealthCheckEndpoint(service: string): string;
    /**
     * What the criteria is for a healthy service
     * @param response axios response
     * @param {{ [key: string]: string}} urlMap health check urls mapped to their cannonical url
     * e.g. https://discoveryprovider.audius.co/health_check => https://discoveryprovider.audius.co
     */
    isHealthy(response: AxiosResponse, _urlMap: Record<string, Service>): boolean;
    /** Races requests against each other with provided timeouts and health checks */
    race(services: string[]): Promise<{
        best: null;
        errored: (string | undefined)[];
    }>;
    /** Adds a service to the unhealthy set */
    addUnhealthy(service: ServiceName): void;
    /** Gets unhealthy set size */
    getUnhealthySize(): number;
    /**
     * Removes from unhealthy set
     * @param key service endpoint
     */
    removeFromUnhealthy(key: string): void;
    /**
     * Adds a service to the list of backups
     * @param service the service to add
     * @param response the services response. This can be used to weigh various
     * backups against eachother
     */
    addBackup(service: string, response: Backup): void;
    /**
     * Controls how a backup is picked. Overriding methods may choose to use the backup's response.
     * e.g. pick a backup that's the fewest versions behind
     */
    selectFromBackups(): Promise<string | undefined>;
    /**
     * Removes from backups
     * @param key service endpoint
     */
    removeFromBackups(key: string): void;
    /**
     * Returns the size of backups
     */
    getBackupsSize(): number;
}

declare enum DECISION_TREE_STATE {
    GET_ALL_SERVICES = "Get All Services",
    FILTER_TO_WHITELIST = "Filter To Whitelist",
    FILTER_FROM_BLACKLIST = "Filter From Blacklist",
    FILTER_OUT_UNHEALTHY_OUTDATED_AND_NO_STORAGE_SPACE = "Filter Out Unhealthy, Outdated, And No Storage Space",
    FILTER_OUT_SYNC_IN_PROGRESS = "Filter Out Sync In Progress",
    SELECT_PRIMARY_AND_SECONDARIES = "Select Primary And Secondaries"
}

declare type Timeout = number | null;
declare function getSpIDForEndpoint(endpoint: string): string | undefined;
declare function setSpIDForEndpoint(endpoint: string, spID?: string): void;
declare type CreatorNode = {
    getSyncStatus: (service: Service, timeout: Timeout) => Promise<{
        isBehind: boolean;
        isConfigured: boolean;
    }>;
    passList?: Set<string>;
    blockList?: Set<string>;
    monitoringCallbacks: {
        healthCheck?: (config: Record<string, unknown>) => Promise<AxiosResponse>;
    };
};
declare type CreatorNodeSelectionConfig = Omit<ServiceSelectionConfig, 'getServices'> & {
    creatorNode: CreatorNode;
    numberOfNodes: number;
    ethContracts: EthContracts;
    maxStorageUsedPercent?: number;
    timeout?: Timeout;
    equivalencyDelta?: number | null;
    preferHigherPatchForPrimary?: boolean;
    preferHigherPatchForSecondaries?: boolean;
    logger?: Logger;
};
interface Decision {
    stage: DECISION_TREE_STATE;
    val?: unknown;
}
declare class CreatorNodeSelection extends ServiceSelection {
    decisionTree: Decision[];
    currentVersion: string;
    ethContracts: EthContracts;
    creatorNode: CreatorNode;
    numberOfNodes: number;
    timeout: Timeout;
    equivalencyDelta: number | null;
    preferHigherPatchForPrimary: boolean;
    preferHigherPatchForSecondaries: boolean;
    healthCheckPath: string;
    backupsList: string[];
    backupTimings: Timing[];
    maxStorageUsedPercent: number;
    logger: Logger;
    constructor({ creatorNode, numberOfNodes, ethContracts, whitelist, blacklist, logger, maxStorageUsedPercent, timeout, equivalencyDelta, preferHigherPatchForPrimary, preferHigherPatchForSecondaries }: CreatorNodeSelectionConfig);
    /**
     * Selects a primary and secondary Content Nodes. Order of preference is highest version, then response time.
     *
     * 1. Retrieve all the Content Node services
     * 2. Filter from/out Content Nodes based off of the whitelist and blacklist
     * 3. Filter out unhealthy, outdated, and still syncing nodes via health and sync check
     * 4. Sort by healthiest (highest version -> lowest version); secondary check if equal version based off of responseTime
     * 5. Select a primary and numberOfNodes-1 number of secondaries (most likely 2) from backups
     * @param performSyncCheck whether or not to check whether the nodes need syncs before selection
     */
    select(performSyncCheck?: boolean, log?: boolean): Promise<{
        primary: string;
        secondaries: string[];
        services: Record<string, any>;
    }>;
    /**
     * Checks the sync progress of a Content Node
     * @param service Content Node endopint
     * @param timeout ms
     */
    getSyncStatus(service: ServiceName, timeout?: Timeout): Promise<{
        service: string;
        syncStatus: {
            isBehind: boolean;
            isConfigured: boolean;
        };
        error: null;
    } | {
        service: string;
        syncStatus: null;
        error: unknown;
    }>;
    /**
     * Sets backupsList to input
     * @param backupsList string array of Content Node endpoints
     */
    setBackupsList(backupsList: ServiceName[], backupTimings: Timing[]): void;
    /**
     * Get backups in the form of an array
     */
    getBackupsList(): string[];
    /**
     * Get backup timings in the form of an array
     */
    getBackupTimings(): Timing[];
    /**
     * Select a primary Content Node
     * @param {string[]} services all healthy Content Node endpoints
     */
    getPrimary(services: string[]): string;
    /**
     * Selects secondary Content Nodes
     * Returns first nodes from `services`, optionally sorted by version
     */
    getSecondaries(): string[];
    /**
     * Performs a sync check for every endpoint in services. Returns an array of successful sync checked endpoints and
     * adds the err'd sync checked endpoints to this.unhealthy
     * @param services content node endpoints
     * @param timeout ms applied to each request
     */
    _performSyncChecks(services: ServiceName[], timeout?: Timeout): Promise<string[]>;
    /**
     * Performs a health check for every endpoint in services. Returns an array of successful health checked endpoints and
     * adds the err'd health checked endpoints to this.unhealthy, and a mapping of successful endpoint to its health check response.
     * @param services content node endpoints
     */
    _performHealthChecks(services: string[]): Promise<{
        healthyServicesList: string[];
        healthyServicesMap: Record<string, any>;
        healthyServiceTimings: Timing[];
    }>;
    _hasEnoughStorageSpace(storagePathSize?: number | null, storagePathUsed?: number | null): boolean;
}

export { CreatorNode$1 as CreatorNode, CreatorNodeSelection, Utils, getSpIDForEndpoint, setSpIDForEndpoint };
