import { type Message } from './message-types.js';
import { type MplexStream } from './stream.js';
import type { MplexInit } from './index.js';
import type { AbortOptions, ComponentLogger, Stream, StreamMuxer, StreamMuxerInit } from '@libp2p/interface';
import type { Sink, Source } from 'it-stream-types';
import type { Uint8ArrayList } from 'uint8arraylist';
export interface MplexComponents {
    logger: ComponentLogger;
}
interface MplexStreamMuxerInit extends MplexInit, StreamMuxerInit {
    /**
     * The default timeout to use in ms when shutting down the muxer.
     */
    closeTimeout?: number;
}
export declare class MplexStreamMuxer implements StreamMuxer {
    protocol: string;
    sink: Sink<Source<Uint8ArrayList | Uint8Array>, Promise<void>>;
    source: AsyncGenerator<Uint8ArrayList | Uint8Array>;
    private readonly log;
    private _streamId;
    private readonly _streams;
    private readonly _init;
    private readonly _source;
    private readonly closeController;
    private readonly rateLimiter;
    private readonly closeTimeout;
    private readonly logger;
    constructor(components: MplexComponents, init?: MplexStreamMuxerInit);
    /**
     * Returns a Map of streams and their ids
     */
    get streams(): Stream[];
    /**
     * Initiate a new stream with the given name. If no name is
     * provided, the id of the stream will be used.
     */
    newStream(name?: string): Stream;
    /**
     * Close or abort all tracked streams and stop the muxer
     */
    close(options?: AbortOptions): Promise<void>;
    abort(err: Error): void;
    /**
     * Called whenever an inbound stream is created
     */
    _newReceiverStream(options: {
        id: number;
        name: string;
    }): MplexStream;
    _newStream(options: {
        id: number;
        name: string;
        type: 'initiator' | 'receiver';
        registry: Map<number, MplexStream>;
    }): MplexStream;
    /**
     * Creates a sink with an abortable source. Incoming messages will
     * also have their size restricted. All messages will be varint decoded.
     */
    _createSink(): Sink<Source<Uint8ArrayList | Uint8Array>, Promise<void>>;
    _handleIncoming(message: Message): Promise<void>;
}
export {};
//# sourceMappingURL=mplex.d.ts.map