import { parseRoutingInstructionsWithNative } from '../engine-selection/native-virtual-router-routing-instructions-semantics.js';
export function parseRoutingInstructions(messages) {
    if (!Array.isArray(messages) || messages.length === 0) {
        return [];
    }
    return parseRoutingInstructionsWithNative(messages);
}
export function parseAndPreprocessRoutingInstructions(messages) {
    const rawInstructions = parseRoutingInstructions(messages);
    if (rawInstructions.length === 0) {
        return [];
    }
    const clearIndex = rawInstructions.findIndex((inst) => inst.type === 'clear');
    if (clearIndex < 0) {
        return rawInstructions;
    }
    return rawInstructions.slice(clearIndex + 1);
}
export function extractClearInstruction(messages) {
    return parseRoutingInstructions(messages).some((inst) => inst.type === 'clear');
}
export function extractStopMessageClearInstruction(messages) {
    return parseRoutingInstructions(messages).some((inst) => inst.type === 'stopMessageClear');
}
