import { AsyncOptLazy, Eq, TraverseState, type ArrayNonEmpty, type AsyncCollectFun, type MaybePromise, type ToJSON } from '@rimbu/common';
import { AsyncReducer, AsyncTransformer, type AsyncFastIterator, type AsyncStream, type AsyncStreamSource } from '@rimbu/stream/async';
import { type AsyncStreamConstructors } from '@rimbu/stream/async-custom';
export declare abstract class AsyncStreamBase<T> implements AsyncStream<T> {
    abstract [Symbol.asyncIterator](): AsyncFastIterator<T>;
    asyncStream(): this;
    equals(other: AsyncStreamSource<T>, options?: {
        eq?: Eq<T>;
        negate?: boolean;
    }): Promise<boolean>;
    assumeNonEmpty(): AsyncStream.NonEmpty<T>;
    asNormal(): AsyncStream<T>;
    prepend(value: AsyncOptLazy<T>): AsyncStream.NonEmpty<T>;
    append(value: AsyncOptLazy<T>): AsyncStream.NonEmpty<T>;
    forEach(f: (value: T, index: number, halt: () => void) => MaybePromise<void>, options?: {
        state?: TraverseState;
    }): Promise<void>;
    forEachPure<A extends readonly unknown[]>(f: (value: T, ...args: A) => MaybePromise<void>, ...args: A): Promise<void>;
    indexed(options?: {
        startIndex?: number;
    }): AsyncStream<[number, T]>;
    filter(pred: (value: T, index: number, halt: () => void) => MaybePromise<boolean>, options?: {
        negate?: boolean | undefined;
    }): any;
    filterPure<A extends readonly unknown[]>(options: {
        pred: (value: T, ...args: A) => MaybePromise<boolean>;
        negate?: boolean | undefined;
    }, ...args: A): any;
    withOnly<F extends T>(values: F[]): AsyncStream<F>;
    without<F extends T>(values: F[]): any;
    map<T2>(mapFun: (value: T, index: number) => MaybePromise<T2>): AsyncStream<T2>;
    mapPure<T2, A extends readonly unknown[]>(mapFun: (value: T, ...args: A) => MaybePromise<T2>, ...args: A): AsyncStream<T2>;
    collect<R>(collectFun: AsyncCollectFun<T, R>): AsyncStream<R>;
    flatMap<T2>(flatMapFun: (value: T, index: number, halt: () => void) => AsyncStreamSource<T2>): AsyncStream<T2>;
    flatZip<T2>(flatMapFun: (value: T, index: number, halt: () => void) => AsyncStreamSource<T2>): AsyncStream<[T, T2]>;
    transform<R>(transformer: AsyncTransformer.Accept<T, R>): AsyncStream<R>;
    first<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O>;
    last<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O>;
    single<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O>;
    count(): Promise<number>;
    countElement(value: T, options?: {
        eq?: Eq<T>;
        negate?: boolean;
    }): Promise<number>;
    find<O>(pred: (value: T, index: number) => MaybePromise<boolean>, options?: {
        occurrance?: number | undefined;
        negate?: boolean | undefined;
        otherwise?: AsyncOptLazy<O>;
    }): Promise<T | O>;
    elementAt<O>(index: number, otherwise?: AsyncOptLazy<O>): Promise<T | O>;
    indicesWhere(pred: (value: T) => MaybePromise<boolean>, options?: {
        negate?: boolean;
    }): AsyncStream<number>;
    indicesOf(searchValue: T, options?: {
        eq?: Eq<T>;
        negate?: boolean;
    }): AsyncStream<number>;
    indexWhere(pred: (value: T, index: number) => MaybePromise<boolean>, options?: {
        occurrance?: number;
        negate?: boolean;
    }): Promise<number | undefined>;
    indexOf(searchValue: T, options?: {
        occurrance?: number | undefined;
        eq?: Eq<T> | undefined;
        negate?: boolean | undefined;
    }): Promise<number | undefined>;
    some(pred: (value: T, index: number) => MaybePromise<boolean>, options?: {
        negate?: boolean;
    }): Promise<boolean>;
    every(pred: (value: T, index: number) => MaybePromise<boolean>, options?: {
        negate?: boolean;
    }): Promise<boolean>;
    contains(searchValue: T, options?: {
        amount?: number;
        eq?: Eq<T>;
        negate?: boolean;
    }): Promise<boolean>;
    containsSlice(source: AsyncStreamSource.NonEmpty<T>, options?: {
        eq?: Eq<T>;
        amount?: number;
    }): Promise<boolean>;
    takeWhile(pred: (value: T, index: number) => MaybePromise<boolean>, options?: {
        negate?: boolean;
    }): AsyncStream<T>;
    dropWhile(pred: (value: T, index: number) => MaybePromise<boolean>, options?: {
        negate?: boolean;
    }): AsyncStream<T>;
    take(amount: number): AsyncStream<T>;
    drop(amount: number): AsyncStream<T>;
    repeat(amount?: number): AsyncStream<T>;
    concat(...others: ArrayNonEmpty<AsyncStreamSource<T>>): any;
    min<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O>;
    minBy<O>(compare: (v1: T, v2: T) => number, otherwise?: AsyncOptLazy<O>): Promise<T | O>;
    max<O>(otherwise?: AsyncOptLazy<O>): Promise<T | O>;
    maxBy<O>(compare: (v1: T, v2: T) => number, otherwise?: AsyncOptLazy<O>): Promise<T | O>;
    intersperse(sep: AsyncStreamSource<T>): AsyncStream<T>;
    join({ sep, start, end, valueToString, ifEmpty, }?: {
        sep?: string | undefined;
        start?: string | undefined;
        end?: string | undefined;
        valueToString?: StringConstructor | undefined;
        ifEmpty?: undefined;
    }): Promise<string>;
    mkGroup({ sep, start, end, }?: {
        sep?: AsyncStreamSource<T>;
        start?: AsyncStreamSource<T>;
        end?: AsyncStreamSource<T>;
    }): any;
    splitWhere<R>(pred: (value: T, index: number) => MaybePromise<boolean>, options?: {
        negate?: boolean | undefined;
        collector?: AsyncReducer.Accept<T, R> | undefined;
    }): AsyncStream<R>;
    splitOn<R>(sepElem: T, options?: {
        eq?: Eq<T> | undefined;
        negate?: boolean | undefined;
        collector?: AsyncReducer.Accept<T, R> | undefined;
    }): AsyncStream<R>;
    splitOnSlice<R>(sepSlice: AsyncStreamSource<T>, options?: {
        eq?: Eq<T> | undefined;
        collector?: AsyncReducer.Accept<T, R> | undefined;
    }): AsyncStream<R>;
    distinctPrevious(options?: {
        eq?: Eq<T> | undefined;
        negate?: boolean | undefined;
    }): AsyncStream<T>;
    window<R>(windowSize: number, options?: {
        skipAmount?: number | undefined;
        collector?: AsyncReducer.Accept<T, R> | undefined;
    }): AsyncStream<R>;
    partition(pred: (value: T, index: number) => MaybePromise<boolean>, options?: {
        collectorTrue?: any;
        collectorFalse?: any;
    }): Promise<[any, any]>;
    groupBy<K, R>(valueToKey: (value: T, index: number) => MaybePromise<K>, options?: {
        collector?: AsyncReducer.Accept<readonly [K, T], R> | undefined;
    }): Promise<R>;
    fold<R>(init: AsyncOptLazy<R>, next: (current: R, value: T, index: number, halt: () => void) => MaybePromise<R>): Promise<R>;
    foldStream<R>(init: AsyncOptLazy<R>, next: (current: R, value: T, index: number, halt: () => void) => MaybePromise<R>): AsyncStream<R>;
    reduce<const S extends AsyncReducer.CombineShape<T>>(shape: S & AsyncReducer.CombineShape<T>): Promise<AsyncReducer.CombineResult<S>>;
    reduceStream<const S extends AsyncReducer.CombineShape<T>>(shape: S & AsyncReducer.CombineShape<T>): AsyncStream<AsyncReducer.CombineResult<S>>;
    toArray(): Promise<T[]>;
    toString(): string;
    toJSON(): Promise<ToJSON<T[], 'AsyncStream'>>;
}
export declare class AsyncFromStream<T> extends AsyncStreamBase<T> {
    [Symbol.asyncIterator]: () => AsyncFastIterator<T>;
    constructor(createIterator: () => AsyncFastIterator<T>);
}
export declare class AsyncTransformerStream<T, R = T> extends AsyncStreamBase<R> {
    readonly source: AsyncStream<T>;
    readonly transformer: AsyncTransformer.Accept<T, R>;
    constructor(source: AsyncStream<T>, transformer: AsyncTransformer.Accept<T, R>);
    [Symbol.asyncIterator](): AsyncFastIterator<R>;
}
export declare class AsyncOfStream<T> extends AsyncStreamBase<T> {
    readonly values: ArrayNonEmpty<AsyncOptLazy<T>>;
    constructor(values: ArrayNonEmpty<AsyncOptLazy<T>>);
    [Symbol.asyncIterator](): AsyncFastIterator<T>;
}
export declare function isAsyncStream(obj: any): obj is AsyncStream<any>;
/**
 * An `AsyncStream` implementation that wraps an arbitrary `AsyncStreamSource`.
 * Used internally by `fromAsyncStreamSource` but also available for advanced use cases.
 */
export declare class FromSource<T> extends AsyncStreamBase<T> {
    readonly source: AsyncStreamSource<T>;
    readonly close?: (() => MaybePromise<void>) | undefined;
    constructor(source: AsyncStreamSource<T>, close?: (() => MaybePromise<void>) | undefined);
    [Symbol.asyncIterator](): AsyncFastIterator<T>;
}
/**
 * An `AsyncStream` implementation that manages an external resource while streaming values.
 * The resource is opened on first iteration and closed when the stream completes or is disposed.
 */
export declare class FromResource<T, R> extends AsyncStreamBase<T> {
    readonly open: () => MaybePromise<R>;
    readonly createSource: (resource: R) => MaybePromise<AsyncStreamSource<T>>;
    readonly close?: ((resource: R) => MaybePromise<void>) | undefined;
    constructor(open: () => MaybePromise<R>, createSource: (resource: R) => MaybePromise<AsyncStreamSource<T>>, close?: ((resource: R) => MaybePromise<void>) | undefined);
    [Symbol.asyncIterator](): AsyncFastIterator<T>;
}
/**
 * A shared empty `AsyncStream` instance used throughout the async stream implementation.
 */
export declare const emptyAsyncStream: AsyncStream<any>;
/**
 * Returns true if the given async stream source is known to be empty.
 * If this function returns false, the source may still be empty; it is simply not known.
 * @param source - a potential async stream source
 */
export declare function isEmptyAsyncStreamSourceInstance(source: AsyncStreamSource<any>): boolean;
/**
 * Converts any `AsyncStreamSource` into an `AsyncFastIterator`.
 * This is the low-level entry point used by `fromAsyncStreamSource`.
 * @typeparam T - the element type
 * @param source - the async stream source to convert
 * @param close - optional callback that will be invoked when the iterator is closed
 */
export declare function asyncStreamSourceToIterator<T>(source: AsyncStreamSource<T>, close?: () => MaybePromise<void>): AsyncFastIterator<T>;
/**
 * Converts any `AsyncStreamSource` into a concrete `AsyncStream` implementation.
 * @typeparam T - the element type
 * @param source - the async stream source to convert
 */
export declare const fromAsyncStreamSource: {
    <T>(source: AsyncStreamSource.NonEmpty<T>): AsyncStream.NonEmpty<T>;
    <T>(source: AsyncStreamSource<T>): AsyncStream<T>;
};
declare const asyncStreamSourceHelpers: {
    fromAsyncStreamSource: {
        <T>(source: AsyncStreamSource.NonEmpty<T>): AsyncStream.NonEmpty<T>;
        <T>(source: AsyncStreamSource<T>): AsyncStream<T>;
    };
    isEmptyAsyncStreamSourceInstance: typeof isEmptyAsyncStreamSourceInstance;
};
export type AsyncStreamSourceHelpers = typeof asyncStreamSourceHelpers;
/**
 * Default implementation of the `AsyncStreamConstructors` interface.
 * This instance backs the exported `AsyncStream` value.
 */
export declare const AsyncStreamConstructorsImpl: AsyncStreamConstructors;
export {};
