import { BatchUpdateType } from "../../stores/batches";
import type { BatchId, BeeClient, EthernaGatewayClient, PostageBatch } from "../../clients";
import type { VideoSource, VideoSourceRaw } from "../../schemas/video";
import type { UpdatingBatch } from "../../stores/batches";
import type { AnyBatch } from "./types";
export interface BatchesHandlerOptions {
    gatewayType: "etherna-gateway" | "bee";
    beeClient: BeeClient;
    gatewayClient: EthernaGatewayClient;
    network?: "mainnet" | "testnet";
}
export declare class BatchesHandler {
    batches: AnyBatch[];
    onBatchesLoading?(): void;
    onBatchesLoaded?(batches: AnyBatch[]): void;
    onBatchLoadError?(batchId: BatchId, error: any): void;
    onBatchCreating?(): void;
    onBatchCreated?(batch: AnyBatch): void;
    onBatchUpdating?(batchId: BatchId): void;
    onBatchUpdated?(batch: AnyBatch): void;
    protected beeClient: BeeClient;
    protected gatewayClient: EthernaGatewayClient;
    protected gatewayType: BatchesHandlerOptions["gatewayType"];
    protected network: BatchesHandlerOptions["network"];
    defaultBlockTime: number;
    constructor(opts: BatchesHandlerOptions);
    get cachedPrice(): {
        url: string;
        price: number;
    } | undefined;
    private set cachedPrice(value);
    /**
     * Load all batches
     *
     * @param batchIds Id of the batches
     * @returns Loaded batches
     */
    loadBatches(batchIds?: BatchId[]): Promise<AnyBatch[]>;
    /**
     * Fetch a batch from given id
     *
     * @param batchId Id of the batch to fetch
     * @param waitPropagation Wait for the batch to be propagated
     * @returns The batch (can throw if not found)
     */
    fetchBatch(batchId: BatchId, waitPropagation?: boolean): Promise<AnyBatch>;
    /**
     * Topup a batch (increase TTL)
     *
     * @param batchId Batch to topup
     * @param byAmount Amount to topup
     */
    topupBatch(batchId: BatchId, byAmount: number | string): Promise<void>;
    /**
     * Dilute batch (increase depth)
     *
     * @param batchId Id of the batch to dilute
     * @param depth New depth
     */
    diluteBatch(batchId: BatchId, depth: number): Promise<void>;
    /**
     * Find the right batch for the given size
     *
     * @param size Size needed for the uploads
     * @returns The batch or `undefined` if not found
     */
    getBatchForSize(size: number): AnyBatch | undefined;
    /**
     * Find a batch from an id (in memory)
     *
     * @param batchId Batch id to search for
     * @returns The batch or undefined if not found
     */
    findBatchById(batchId: BatchId): AnyBatch | undefined;
    /**
     * Get an existing batch or create a new one based on size
     *
     * @param size Size needed for the uploads
     * @param ttl Expiration in seconds (for creation, default is 2 years)
     * @returns The batch
     */
    getOrCreateBatchForSize(size: number, ttl?: number): Promise<AnyBatch>;
    /**
     * Create new batch based on size and ttl
     *
     * @param size Batch min size
     * @param ttl Batch expiration in seconds
     * @param signal Abort signal
     * @returns The created batch
     */
    createBatchForSize(size: number, ttl?: number, signal?: AbortSignal): Promise<AnyBatch>;
    /**
     * Auto-increase batch size and re-balance TTL
     *
     * @param batch Batch to extend
     * @param addSize Size to add to the batch
     */
    increaseBatchSize(batch: AnyBatch, addSize: number): Promise<boolean>;
    /**
     * Increase a batch expiration time
     *
     * @param batch Batch to extend
     * @param addTTL Seconds to add to batch
     */
    increaseBatchTTL(batch: AnyBatch, addTTL: number): Promise<boolean>;
    waitBatchPropagation(batch: AnyBatch | UpdatingBatch, updateType: BatchUpdateType, interval?: number): Promise<AnyBatch>;
    isCreatingBatch(batch: AnyBatch | UpdatingBatch): boolean;
    canUploadTo(batch: AnyBatch, size: number): boolean;
    /**
     * Refresh a batch after utilization
     *
     * @param batch The batch used
     */
    refreshBatch(batch: AnyBatch): Promise<void>;
    calcDepthAmount(size?: number, ttl?: number): Promise<{
        amount: string;
        depth: number;
    }>;
    calcDepthAmountForBatch(batch: AnyBatch, additionalSize: number): Promise<{
        amount: string;
        depth: number;
    }>;
    calcBatchSizeForVideo(videoSizeInBytes: number, quality: number): number;
    calcBatchSizeForVideoSources(sources: (VideoSource | VideoSourceRaw)[], duration: number): number;
    fetchPrice(): Promise<number>;
    parseBatch(batch: AnyBatch): PostageBatch;
    getBatchId(batch: {
        id: BatchId;
    } | {
        batchID: BatchId;
    }): BatchId;
}
//# sourceMappingURL=index.d.ts.map