/**
 * StreamBuf - Cross-Platform Multi-purpose Read-Write Stream
 *
 * A unified implementation that works in both Node.js and Browser environments
 * using the cross-platform EventEmitter from modules/stream.
 *
 * Features:
 * - As MemBuf: write data, then call toBuffer() to consolidate
 * - As StreamHub: pipe to multiple writable streams
 * - As readable stream: feed data into writable part and read from it
 */
import { EventEmitter } from "@stream";
import { StringBuf } from "@excel/utils/string-buf";
type TextEncoding = "utf-8" | "utf8" | BufferEncoding;
interface StreamBufOptions {
    bufSize?: number;
    batch?: boolean;
}
/**
 * StreamBuf is a multi-purpose read-write stream that works in both
 * Node.js and Browser environments.
 *
 * It extends EventEmitter to provide stream-like events:
 * - 'data': emitted when data is written (flowing mode)
 * - 'readable': emitted when data is available to read
 * - 'finish': emitted when end() is called
 * - 'error': emitted on errors
 * - 'drain': emitted when buffer drains (after pipe)
 */
declare class StreamBuf extends EventEmitter {
    private bufSize;
    private buffers;
    private batch;
    private corked;
    private paused;
    private encoding;
    private pipes;
    private _ended;
    private _writableStream;
    private _writableStreamWriter;
    private _asyncWriteQueue;
    constructor(options?: StreamBufOptions);
    /**
     * Returns true if the stream is writable (not ended)
     * Required for compatibility with Node.js pipe()
     */
    get writable(): boolean;
    /**
     * Consolidate all buffers into a single Uint8Array
     */
    toBuffer(): Uint8Array | null;
    private _getWritableBuffer;
    private _pipeChunk;
    private _writeToBuffers;
    /**
     * Write data to the stream
     */
    write(data: Uint8Array | string | StringBuf | ArrayBuffer | ArrayBufferView, encoding?: TextEncoding | Function, callback?: Function): Promise<boolean>;
    /**
     * Cork the stream - buffer writes until uncork
     */
    cork(): void;
    private _flush;
    /**
     * Uncork the stream - flush buffered writes
     */
    uncork(): void;
    /**
     * End the stream
     */
    end(chunk?: any, encoding?: TextEncoding, callback?: Function): void;
    /**
     * Read from the stream
     */
    read(size?: number): Uint8Array;
    /**
     * Read from the stream and return as string.
     * Cross-platform compatible - works identically in Node.js and Browser.
     */
    readString(encoding?: TextEncoding): string;
    /**
     * Set encoding for string reads
     */
    setEncoding(encoding: string): void;
    /**
     * Pause the stream
     */
    pause(): void;
    /**
     * Resume the stream
     */
    resume(): void;
    /**
     * Check if stream is paused
     */
    isPaused(): boolean;
    /**
     * Pipe to a writable stream
     */
    pipe<T extends {
        write: Function;
        end?: Function;
    }>(destination: T): T;
    /**
     * Pipe to a native WritableStream (browser Streams API).
     * This properly handles async writes and waits for completion before finish.
     */
    pipeTo(writableStream: WritableStream<Uint8Array>): void;
    /**
     * Remove a piped destination
     */
    unpipe(destination: any): void;
    /**
     * Put data back at the front (not implemented)
     */
    unshift(): void;
    /**
     * Wrap a stream (not implemented)
     */
    wrap(): void;
    /**
     * Push data to the stream (alias for write)
     */
    push(chunk: any): boolean;
}
export { StreamBuf };
