"""Shared split-level evaluation orchestration helpers."""

from __future__ import annotations

from typing import TYPE_CHECKING


if TYPE_CHECKING:
    from collections.abc import Callable, Mapping, Sequence


def evaluate_available_splits(
    requested_splits: Sequence[str],
    split_to_loader: Mapping[str, object],
    evaluate_split: Callable[[str, object], list[dict]],
) -> list[dict]:
    """Run split evaluator for available loaders and concatenate payload."""
    payload: list[dict] = []
    for split in requested_splits:
        loader = split_to_loader.get(split)
        if loader is None:
            continue
        payload.extend(evaluate_split(split, loader))
    return payload

