import type { SupportedBodyTypes } from '../index.js';
import type { Logger } from '@libp2p/interface';
interface RequestRange {
    start: number | undefined;
    end: number | undefined;
}
interface ByteRange extends RequestRange {
    size: number | undefined;
}
export declare class ByteRangeContext {
    private readonly headers?;
    readonly isRangeRequest: boolean;
    /**
     * This property is purposefully only set in `set fileSize` and should not be set directly.
     */
    private _fileSize;
    private _body;
    private readonly rangeRequestHeader;
    private readonly log;
    /**
     * multiPartBoundary is required for multipart responses
     */
    private readonly multiPartBoundary?;
    private readonly requestRanges;
    private byteRanges;
    readonly isMultiRangeRequest: boolean;
    private _isValidRangeRequest;
    constructor(logger: Logger, headers?: HeadersInit | undefined);
    getByteRanges(): ByteRange[];
    /**
     * You can pass a function when you need to support multi-range requests but have your own slicing logic, such as in the case of dag-pb/unixfs.
     *
     * @param bodyOrProvider - A supported body type or a function that returns a supported body type.
     * @param contentType - The content type of the body.
     */
    setBody(bodyOrProvider: SupportedBodyTypes | ((range: ByteRange) => AsyncGenerator<Uint8Array, void, unknown>), contentType?: string): void;
    getBody(responseContentType?: string): SupportedBodyTypes;
    private getSlicedBody;
    /**
     * Sometimes, we need to set the fileSize explicitly because we can't calculate
     * the size of the body (e.g. for unixfs content where we call .stat).
     *
     * This fileSize should otherwise only be called from `setBody`.
     */
    setFileSize(size: number | bigint | null): void;
    getFileSize(): number | null | undefined;
    private isValidByteStart;
    private isValidByteEnd;
    private isValidByteRange;
    /**
     * We may get the values required to determine if this is a valid range request at different times
     * so we need to calculate it when asked.
     */
    get isValidRangeRequest(): boolean;
    /**
     * Given all the information we have, this function returns the length that will be used when:
     * 1. calling unixfs.cat
     * 2. slicing the body
     */
    getLength(range?: ByteRange): number | undefined;
    /**
     * Converts a range request header into helia/unixfs supported range options
     * Note that the gateway specification says we "MAY" support multiple ranges (https://specs.ipfs.tech/http-gateways/path-gateway/#range-request-header) but we don't
     *
     * Also note that @helia/unixfs and ipfs-unixfs-exporter expect length and offset to be numbers, the range header is a string, and the size of the resource is likely a bigint.
     *
     * SUPPORTED:
     * Range: bytes=<range-start>-<range-end>
     * Range: bytes=<range-start>-
     * Range: bytes=-<suffix-length> // must pass size so we can calculate the offset. suffix-length is the number of bytes from the end of the file.
     * Range: bytes=<range-start>-<range-end>, <range-start>-<range-end>
     * Range: bytes=<range-start>-<range-end>, <range-start>-<range-end>, <range-start>-<range-end>
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#directives
     */
    private setOffsetDetails;
    /**
     * Helper to convert a SliceableBody to a Uint8Array
     */
    private convertToUint8Array;
    private getMultipartBody;
    private getSlicedBodyForRange;
    /**
     * Returns the content type for the response.
     * For multipart ranges, this will be multipart/byteranges with a boundary.
     */
    getContentType(): string | undefined;
    /**
     * This function returns the value of the "content-range" header.
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range
     *
     * Returns a string representing the following content ranges:
     *
     * @example
     * - Content-Range: <unit> <byteStart>-<byteEnd>/<byteSize>
     * - Content-Range: <unit> <byteStart>-<byteEnd>/*
     */
    get contentRangeHeaderValue(): string;
    private createRangeStream;
}
export {};
//# sourceMappingURL=byte-range-context.d.ts.map