import { type CompiledFormula } from '@bilig/formula';
import type { CellValue, WorkbookSnapshot } from '@bilig/protocol';
import type { EngineCellMutationRef, EngineFormulaSourceRefs } from '../cell-mutations-at.js';
import type { InitialFormulaEntryRefSource } from '../engine/services/formula-initialization-refs.js';
import type { FormulaInstanceSnapshot } from '../formula/formula-instance-table.js';
import type { FormulaTemplateResolution, FormulaTemplateSnapshot } from '../formula/template-bank.js';
import type { StringPool } from '../string-pool.js';
import type { WorkbookStore } from '../workbook-store.js';
import { type CachedRuntimeFormulaRef } from './runtime-image-cached-formula-refs.js';
import { type RuntimeImageFormulaFamilyRunSnapshot } from './runtime-image-formula-family-runs.js';
export interface RuntimeImage {
    readonly version: 1;
    readonly templateBank: readonly FormulaTemplateSnapshot[];
    readonly formulaInstances: readonly FormulaInstanceSnapshot[];
    readonly formulaValues: readonly RuntimeImageFormulaValueSnapshot[];
    readonly cellValues?: readonly RuntimeImageCellValueSnapshot[];
    readonly formulaFamilyRuns?: readonly RuntimeImageFormulaFamilyRunSnapshot[];
    readonly sheetCells?: readonly RuntimeImageSheetCellsSnapshot[];
}
export interface RuntimeImageFormulaValueSnapshot {
    readonly sheetName: string;
    readonly row: number;
    readonly col: number;
    readonly value: CellValue;
}
export interface RuntimeImageCellValueSnapshot {
    readonly sheetName: string;
    readonly row: number;
    readonly col: number;
    readonly value: CellValue;
}
export interface RuntimeImageSheetCellsSnapshot {
    readonly sheetName: string;
    readonly coords: readonly RuntimeImageCellCoordinateSnapshot[];
    readonly coordinateOrder?: 'dense-row-major';
    readonly dimensions?: RuntimeImageSheetDimensionsSnapshot;
    readonly cellCount?: number;
}
export interface RuntimeImageCellCoordinateSnapshot {
    readonly row: number;
    readonly col: number;
}
export interface RuntimeImageSheetDimensionsSnapshot {
    readonly width: number;
    readonly height: number;
}
export interface RuntimeImageRestoreArgs {
    readonly snapshot: WorkbookSnapshot;
    readonly runtimeImage: RuntimeImage;
    readonly workbook: WorkbookStore;
    readonly strings: StringPool;
    readonly resetWorkbook: (workbookName?: string) => void;
    readonly checkEvaluationBudget?: (stepCost?: number) => void;
    readonly hydrateTemplateBank: (templates: readonly FormulaTemplateSnapshot[]) => void;
    readonly resolveTemplateById?: (templateId: number, source: string, row: number, col: number) => FormulaTemplateResolution | undefined;
    readonly initializeCellFormulasAt: (refs: readonly EngineCellMutationRef[], potentialNewCells?: number) => void;
    readonly initializeFormulaSourcesAt?: (refs: EngineFormulaSourceRefs, potentialNewCells?: number) => void;
    readonly resolveTemplateForCell?: (source: string, row: number, col: number) => FormulaTemplateResolution;
    readonly initializePreparedCellFormulasAt?: (refs: InitialFormulaEntryRefSource<PreparedRuntimeFormulaRef>, potentialNewCells?: number) => void;
    readonly initializeHydratedPreparedCellFormulasAt?: (refs: InitialFormulaEntryRefSource<HydratedPreparedRuntimeFormulaRef>, potentialNewCells?: number) => void;
    readonly initializeCachedFormulaSourcesAt?: (refs: readonly CachedRuntimeFormulaRef[], potentialNewCells?: number) => void;
}
export interface WorkbookRestoreResult {
    readonly formulaCount: number;
}
export interface WorkbookSnapshotRestoreArgs {
    readonly snapshot: WorkbookSnapshot;
    readonly workbook: WorkbookStore;
    readonly strings: StringPool;
    readonly resetWorkbook: (workbookName?: string) => void;
    readonly checkEvaluationBudget?: (stepCost?: number) => void;
    readonly initializeCellFormulasAt: (refs: readonly EngineCellMutationRef[], potentialNewCells?: number) => void;
    readonly initializeFormulaSourcesAt?: (refs: EngineFormulaSourceRefs, potentialNewCells?: number) => void;
    readonly resolveTemplateForCell?: (source: string, row: number, col: number) => FormulaTemplateResolution;
    readonly initializeHydratedPreparedCellFormulasAt?: (refs: InitialFormulaEntryRefSource<HydratedPreparedRuntimeFormulaRef>, potentialNewCells?: number) => void;
    readonly initializeCachedFormulaSourcesAt?: (refs: readonly CachedRuntimeFormulaRef[], potentialNewCells?: number) => void;
}
export interface PreparedRuntimeFormulaRef {
    readonly sheetId: number;
    readonly row: number;
    readonly col: number;
    readonly source: string;
    readonly compiled: CompiledFormula;
    readonly templateId?: number;
    readonly cellIndex?: number;
}
export interface HydratedPreparedRuntimeFormulaRef extends PreparedRuntimeFormulaRef {
    readonly value: CellValue;
    readonly preserveCachedValueOnFullRecalc?: boolean;
}
export declare function restoreWorkbookFromSnapshot(args: WorkbookSnapshotRestoreArgs): WorkbookRestoreResult;
export declare function restoreWorkbookFromRuntimeImage(args: RuntimeImageRestoreArgs): WorkbookRestoreResult;
