export function selectRuntimeFormulaFamilyRunHints(args) {
    const restoredRuns = args.restoredRuns;
    if (restoredRuns === undefined || restoredRuns.runs.length === 0 || args.cellIndices.length === 0) {
        return undefined;
    }
    const availableCellIndices = new Set();
    for (let index = 0; index < args.cellIndices.length; index += 1) {
        availableCellIndices.add(args.cellIndices[index]);
    }
    const runs = restoredRuns.runs.filter((run) => run.cellIndices.every((cellIndex) => availableCellIndices.has(cellIndex)));
    return runs.length === 0 ? undefined : { runs, fallbackCount: 0 };
}
export function attachRuntimeFormulaFamilyRunHints(args) {
    const { refs, restoredRuns, runtimeRunCount } = args;
    if (refs.length === 0 || runtimeRunCount === 0) {
        return;
    }
    refs.freshFormulaFamilyRuns = undefined;
    if (args.cellIndicesAreRuntimeAligned && restoredRuns !== undefined && restoredRuns.fallbackCount === 0 && restoredRuns.runs.length > 0) {
        refs.freshFormulaFamilyRuns = restoredRuns.runs;
        refs.freshFormulaFamilyRunFallbackCount = 0;
        return;
    }
    refs.freshFormulaFamilyRunFallbackCount = runtimeRunCount;
}
//# sourceMappingURL=runtime-image-formula-family-run-hints.js.map