import type { CellValue } from '@bilig/protocol';
import type { RuntimeDirectLookupDescriptor } from '../runtime-state.js';
export interface OperationLookupDirtyWriteRequest {
    readonly sheetName: string;
    readonly row: number;
    readonly col: number;
    readonly oldValue: CellValue;
    readonly newValue: CellValue;
    readonly oldStringId?: number;
    readonly newStringId?: number;
}
interface ExactLookupImpactEntry {
    readonly formulaCellIndex: number;
    readonly rowStart: number;
    readonly rowEnd: number;
    readonly operandKey: string | undefined;
}
interface ExactLookupImpactCache {
    readonly entries: readonly ExactLookupImpactEntry[];
    readonly operandKeys: ReadonlySet<string>;
}
export type ExactLookupImpactCaches = Map<string, ExactLookupImpactCache>;
interface OperationLookupDirtyMarkerFormulaAccess {
    get(cellIndex: number): {
        readonly directLookup: RuntimeDirectLookupDescriptor | undefined;
    } | undefined;
}
interface OperationLookupDirtyMarkerWorkbookAccess {
    getSheet(sheetName: string): {
        readonly id: number;
    } | undefined;
}
export interface OperationLookupDirtyMarkerService {
    readonly markAffectedExactLookupDependents: (request: OperationLookupDirtyWriteRequest, formulaChangedCount: number, caches: ExactLookupImpactCaches) => number;
    readonly markAffectedApproximateLookupDependents: (request: OperationLookupDirtyWriteRequest, formulaChangedCount: number) => number;
    readonly noteExactLookupLiteralWriteWhenDirty: (request: OperationLookupDirtyWriteRequest, formulaChangedCount: number, caches: ExactLookupImpactCaches) => number;
    readonly noteSortedLookupLiteralWriteWhenDirty: (request: OperationLookupDirtyWriteRequest, formulaChangedCount: number) => number;
}
export declare function createOperationLookupDirtyMarkerService(args: {
    readonly state: {
        readonly workbook: OperationLookupDirtyMarkerWorkbookAccess;
        readonly formulas: OperationLookupDirtyMarkerFormulaAccess;
        readonly strings: {
            get(id: number): string;
        };
    };
    readonly getEntityDependents: (entityId: number) => Uint32Array;
    readonly getSingleEntityDependent: (entityId: number) => number;
    readonly markFormulaChanged: (cellIndex: number, count: number) => number;
    readonly readCellValueForLookup: (cellIndex: number | undefined) => {
        value: CellValue;
        stringId: number | undefined;
    };
    readonly canSkipApproximateLookupDirtyMark: (directLookup: Extract<RuntimeDirectLookupDescriptor, {
        kind: 'approximate' | 'approximate-uniform-numeric';
    }>, request: OperationLookupDirtyWriteRequest) => boolean;
    readonly noteExactLookupLiteralWrite: (request: OperationLookupDirtyWriteRequest) => void;
    readonly noteSortedLookupLiteralWrite: (request: OperationLookupDirtyWriteRequest) => void;
    readonly lookupImpactCacheKey: (sheetId: number, col: number) => string;
}): OperationLookupDirtyMarkerService;
export {};
