import type { Hash } from '@ariestools/sdk';
import type { Payload, WithHashMeta } from '@xyo-network/sdk';
import type { BlockRate, BlockViewer, ChainId, SignedHydratedBlockWithHashMeta, SingleTimeConfig, TimeDurations, XL1BlockNumber, XL1BlockRange } from '@xyo-network/xl1-protocol/protocol-lib';
import { LruCacheMap } from '../driver-memory/index.js';
import type { CreatableProviderParams } from '../protocol-sdk/index-node.js';
import { AbstractCreatableProvider } from '../protocol-sdk/index-node.js';
/** Parameters for RestBlockViewer. */
export interface RestBlockViewerParams extends CreatableProviderParams {
    /** Optional fetch override (custom agents, auth headers, tests). Defaults to the global fetch. */
    fetchFn?: typeof globalThis.fetch;
    /** Base URL of the finalized (immutable) static chain files (e.g. a public R2 bucket or CDN domain). */
    finalizedBaseUrl: string;
    /** head Poll Interval Ms configuration or state exposed by this contract. */
    headPollIntervalMs?: number;
}
/**
 * A BlockViewer over a statically generated REST file layout (see `@xyo-network/xl1-network-model`).
 *
 * Reads are anonymous HTTP GETs against immutable files, so everything is cached
 * aggressively. The mutable head is a stateful question the finalized file layout cannot
 * answer, so `currentBlock()` delegates to the injected `ChainStateViewer` — a required
 * dependency, mirroring `RestFinalizationViewer` — and the result is reused for
 * `CURRENT_BLOCK_CACHE_TTL_MS` so a burst of concurrent `currentBlock()` callers share one
 * delegate call instead of each issuing their own. The step-summary families are
 * `IndexViewer`'s data, so `blocksByStep` delegates to the injected `IndexViewer` (also a
 * required dependency) and maps the summary to blocks; only completed steps are published —
 * the in-flight tail step reads as null and returns [].
 *
 * `blocksByNumber` fans out per-block GETs in parallel (newest-first assembly, contiguous
 * prefix only). Walks at `limit >= 31` tile the window with `deepCalculateFramesFromRange`
 * (see protocol-sdk frame helpers), load each multi-block frame via `blocksByStep`, and fill
 * only single-block leftovers / unpublished in-flight steps with individual GETs.
 * `blocksByHash` resolves the head by hash, then reuses `blocksByNumber` and verifies
 * `previous` linkage before returning. There is no hard upper bound on `limit` beyond
 * available chain history.
 */
export declare class RestBlockViewer extends AbstractCreatableProvider<RestBlockViewerParams, BlockViewer['eventData']> implements BlockViewer {
    /** Connection kinds supported by this provider. */
    static readonly connectionTypes: readonly ["rest"];
    /** Primary moniker used to resolve this provider. */
    static readonly defaultMoniker: "BlockViewer";
    /** Provider monikers that must resolve before this provider can be created. */
    static readonly dependencies: ("IndexViewer" | "ChainStateViewer")[];
    /** Provider monikers implemented by this provider class. */
    static readonly monikers: "BlockViewer"[];
    /** Read, write, or mixed capability surface exposed by the provider. */
    static readonly surface: "node";
    /** Moniker implemented by this provider instance. */
    moniker: "BlockViewer";
    protected blockByHashCache: LruCacheMap<import("@ariestools/sdk").BrandedHash, [{
        schema: "network.xyo.boundwitness" & {
            readonly __schema: true;
        };
        addresses: (import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }))[];
        payload_hashes: import("@ariestools/sdk").BrandedHash[];
        payload_schemas: import("@xyo-network/sdk").BrandedSchema<string>[];
        previous_hashes: (import("@ariestools/sdk").BrandedHash | null)[];
        $signatures: import("@ariestools/sdk").BrandedHex[];
        block: XL1BlockNumber;
        chain: import("@ariestools/sdk").BrandedHex;
        previous: import("@ariestools/sdk").BrandedHash | null;
        $epoch: number;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
        $destination?: import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }) | undefined;
        $sourceQuery?: import("@ariestools/sdk").BrandedHash | undefined;
        protocol?: number | undefined;
        step_hashes?: import("@ariestools/sdk").BrandedHash[] | undefined;
    }, {
        [x: string]: unknown;
        schema: import("@xyo-network/sdk").BrandedSchema<string>;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
    }[]], () => void>;
    protected blockByHashInFlight: Map<import("@ariestools/sdk").BrandedHash, Promise<[{
        schema: "network.xyo.boundwitness" & {
            readonly __schema: true;
        };
        addresses: (import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }))[];
        payload_hashes: import("@ariestools/sdk").BrandedHash[];
        payload_schemas: import("@xyo-network/sdk").BrandedSchema<string>[];
        previous_hashes: (import("@ariestools/sdk").BrandedHash | null)[];
        $signatures: import("@ariestools/sdk").BrandedHex[];
        block: XL1BlockNumber;
        chain: import("@ariestools/sdk").BrandedHex;
        previous: import("@ariestools/sdk").BrandedHash | null;
        $epoch: number;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
        $destination?: import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }) | undefined;
        $sourceQuery?: import("@ariestools/sdk").BrandedHash | undefined;
        protocol?: number | undefined;
        step_hashes?: import("@ariestools/sdk").BrandedHash[] | undefined;
    }, {
        [x: string]: unknown;
        schema: import("@xyo-network/sdk").BrandedSchema<string>;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
    }[]] | null>>;
    protected blockByNumberCache: LruCacheMap<XL1BlockNumber, [{
        schema: "network.xyo.boundwitness" & {
            readonly __schema: true;
        };
        addresses: (import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }))[];
        payload_hashes: import("@ariestools/sdk").BrandedHash[];
        payload_schemas: import("@xyo-network/sdk").BrandedSchema<string>[];
        previous_hashes: (import("@ariestools/sdk").BrandedHash | null)[];
        $signatures: import("@ariestools/sdk").BrandedHex[];
        block: XL1BlockNumber;
        chain: import("@ariestools/sdk").BrandedHex;
        previous: import("@ariestools/sdk").BrandedHash | null;
        $epoch: number;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
        $destination?: import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }) | undefined;
        $sourceQuery?: import("@ariestools/sdk").BrandedHash | undefined;
        protocol?: number | undefined;
        step_hashes?: import("@ariestools/sdk").BrandedHash[] | undefined;
    }, {
        [x: string]: unknown;
        schema: import("@xyo-network/sdk").BrandedSchema<string>;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
    }[]], () => void>;
    protected blockByNumberInFlight: Map<XL1BlockNumber, Promise<[{
        schema: "network.xyo.boundwitness" & {
            readonly __schema: true;
        };
        addresses: (import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }))[];
        payload_hashes: import("@ariestools/sdk").BrandedHash[];
        payload_schemas: import("@xyo-network/sdk").BrandedSchema<string>[];
        previous_hashes: (import("@ariestools/sdk").BrandedHash | null)[];
        $signatures: import("@ariestools/sdk").BrandedHex[];
        block: XL1BlockNumber;
        chain: import("@ariestools/sdk").BrandedHex;
        previous: import("@ariestools/sdk").BrandedHash | null;
        $epoch: number;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
        $destination?: import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }) | undefined;
        $sourceQuery?: import("@ariestools/sdk").BrandedHash | undefined;
        protocol?: number | undefined;
        step_hashes?: import("@ariestools/sdk").BrandedHash[] | undefined;
    }, {
        [x: string]: unknown;
        schema: import("@xyo-network/sdk").BrandedSchema<string>;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
    }[]] | null>>;
    protected currentBlockCache: LruCacheMap<string, Promise<[{
        schema: "network.xyo.boundwitness" & {
            readonly __schema: true;
        };
        addresses: (import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }))[];
        payload_hashes: import("@ariestools/sdk").BrandedHash[];
        payload_schemas: import("@xyo-network/sdk").BrandedSchema<string>[];
        previous_hashes: (import("@ariestools/sdk").BrandedHash | null)[];
        $signatures: import("@ariestools/sdk").BrandedHex[];
        block: XL1BlockNumber;
        chain: import("@ariestools/sdk").BrandedHex;
        previous: import("@ariestools/sdk").BrandedHash | null;
        $epoch: number;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
        $destination?: import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }) | undefined;
        $sourceQuery?: import("@ariestools/sdk").BrandedHash | undefined;
        protocol?: number | undefined;
        step_hashes?: import("@ariestools/sdk").BrandedHash[] | undefined;
    }, {
        [x: string]: unknown;
        schema: import("@xyo-network/sdk").BrandedSchema<string>;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
    }[]]>, () => void>;
    protected payloadCache: LruCacheMap<import("@ariestools/sdk").BrandedHash, WithHashMeta<Payload>, () => void>;
    protected stepCaches: LruCacheMap<number, [{
        schema: "network.xyo.boundwitness" & {
            readonly __schema: true;
        };
        addresses: (import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }))[];
        payload_hashes: import("@ariestools/sdk").BrandedHash[];
        payload_schemas: import("@xyo-network/sdk").BrandedSchema<string>[];
        previous_hashes: (import("@ariestools/sdk").BrandedHash | null)[];
        $signatures: import("@ariestools/sdk").BrandedHex[];
        block: XL1BlockNumber;
        chain: import("@ariestools/sdk").BrandedHex;
        previous: import("@ariestools/sdk").BrandedHash | null;
        $epoch: number;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
        $destination?: import("@xyo-network/sdk").XyoQuantAddress | (Lowercase<string> & {
            readonly __hex: true;
        } & {
            readonly __address: true;
        }) | undefined;
        $sourceQuery?: import("@ariestools/sdk").BrandedHash | undefined;
        protocol?: number | undefined;
        step_hashes?: import("@ariestools/sdk").BrandedHash[] | undefined;
    }, {
        [x: string]: unknown;
        schema: import("@xyo-network/sdk").BrandedSchema<string>;
        _hash: import("@ariestools/sdk").BrandedHash;
        _dataHash: import("@ariestools/sdk").BrandedHash;
    }[]][], () => void>[];
    private _chainStateViewer;
    private _headPollHash?;
    private _headPollInProgress;
    private _headPollTimer;
    private _indexViewer;
    /** Finalizes  base url. */
    get finalizedBaseUrl(): string;
    protected get fetchFn(): typeof globalThis.fetch;
    protected get headPollIntervalMs(): number | undefined;
    /** Returns the params handler result exposed by this provider. */
    static paramsHandler(params: Partial<RestBlockViewerParams>): Promise<{
        fetchFn: typeof fetch | undefined;
        finalizedBaseUrl: string;
        headPollIntervalMs: number | undefined;
        context: import('../protocol-sdk/index-node.js').CreatableProviderContextType;
        name?: import("@ariestools/sdk").CreatableName;
        statusReporter?: import("@ariestools/sdk").CreatableStatusReporter<void> | undefined;
        logger?: import("@ariestools/sdk").Logger;
        meterProvider?: import("@opentelemetry/api").MeterProvider;
        traceProvider?: import("@opentelemetry/api").TracerProvider;
    }>;
    /** Returns the block by hash result exposed by this provider. */
    blockByHash(hash: Hash): Promise<SignedHydratedBlockWithHashMeta | null>;
    /** Returns the block by number result exposed by this provider. */
    blockByNumber(blockNumber: XL1BlockNumber): Promise<SignedHydratedBlockWithHashMeta | null>;
    /** Returns the blocks by hash result exposed by this provider. */
    blocksByHash(hash: Hash, limit?: number): Promise<SignedHydratedBlockWithHashMeta[]>;
    /** Returns the blocks by number result exposed by this provider. */
    blocksByNumber(blockNumber: XL1BlockNumber, limit?: number): Promise<SignedHydratedBlockWithHashMeta[]>;
    /** Returns the blocks by step result exposed by this provider. */
    blocksByStep(stepLevel: number, stepIndex: number): Promise<SignedHydratedBlockWithHashMeta[]>;
    /** Returns the chain id result exposed by this provider. */
    chainId(): Promise<ChainId>;
    /** Returns the chain id result exposed by this provider. */
    chainId(blockNumber: XL1BlockNumber): Promise<ChainId>;
    /** Returns the chain id result exposed by this provider. */
    chainId(blockNumber: 'latest'): Promise<ChainId>;
    /** Creates the provider instance after its dependencies and configuration have resolved. */
    createHandler(): Promise<void>;
    /** Returns block. */
    currentBlock(): Promise<SignedHydratedBlockWithHashMeta>;
    /** Returns block hash. */
    currentBlockHash(): Promise<Hash>;
    /** Returns block number. */
    currentBlockNumber(): Promise<XL1BlockNumber>;
    /** Returns the payload by hash result exposed by this provider. */
    payloadByHash(hash: Hash): Promise<WithHashMeta<Payload> | null>;
    /** Returns the payloads by hash result exposed by this provider. */
    payloadsByHash(hashes: Hash[]): Promise<WithHashMeta<Payload>[]>;
    /** Returns the rate result exposed by this provider. */
    rate(range: XL1BlockRange, timeUnit?: keyof TimeDurations): Promise<BlockRate>;
    /** Returns the step size rate result exposed by this provider. */
    stepSizeRate(start: XL1BlockNumber, stepIndex: number, count?: number, timeUnit?: keyof TimeDurations): Promise<BlockRate>;
    /** Returns the time duration rate result exposed by this provider. */
    timeDurationRate(timeConfig: SingleTimeConfig, startBlockNumber?: XL1BlockNumber, timeUnit?: keyof TimeDurations, toleranceMs?: number, maxAttempts?: number): Promise<BlockRate>;
    protected startHandler(): Promise<void>;
    protected stopHandler(): Promise<void>;
    private assertBlocksByRangeLimit;
    /**
     * Fan-out per-block GETs for `[high - count + 1, high]`, assemble newest-first, and stop at
     * the first missing/broken link. Fetches exactly `count` candidates (no off-by-one past the
     * requested window).
     */
    private blocksByNumberParallel;
    /**
     * Large-range path: tile `[high - count + 1, high]` with `deepCalculateFramesFromRange`
     * (largest complete step frames first, capped at `blocksMaxStep`), load each multi-block
     * frame via `blocksByStep`, and fill only single-block leftovers or unpublished frames with
     * per-block GETs. Returns `undefined` when no frame produced blocks so the caller can fall
     * back to a pure parallel fan-out.
     */
    private blocksByNumberViaDeepFrames;
    /** Validates a parsed block file and populates both block caches. */
    private cacheBlock;
    /** Newest-first contiguous non-null prefix (stops at the first hole). */
    private contiguousNonNullPrefix;
    /**
     * Keeps the longest newest-first prefix where each block's `previous` matches the next
     * block's hash and block numbers decrease by one. Truncates on the first break so callers
     * never return a silently forked/gapped list from a parallel fan-out.
     */
    private contiguousPreviousLinkedPrefix;
    /** The head is ChainStateViewer's question; delegate, then seed the immutable block caches. */
    private fetchCurrentBlock;
    private fetchJson;
    /** Parallel per-block fill for `[start, end]` inclusive (skips numbers already present). */
    private loadBlockNumbersIntoMap;
    /**
     * Loads one deep-calculated frame into the block map: multi-block frames map to a published
     * `blocksByStep` file when available; singles and unpublished frames fall back to per-block GETs.
     */
    private loadFrameIntoMap;
    private pollHead;
    private startHeadPolling;
    private stopHeadPolling;
}
//# sourceMappingURL=RestBlockViewer.d.ts.map