import { analyzeProviderKey } from './native-router-hotpath.js';
function parseProviderKey(providerKey) {
    return analyzeProviderKey(providerKey);
}
export function extractProviderId(providerKey) {
    return parseProviderKey(providerKey).providerId;
}
export function extractKeyAlias(providerKey) {
    const alias = parseProviderKey(providerKey).alias;
    if (!alias) {
        return null;
    }
    return normalizeAliasDescriptor(alias);
}
export function normalizeAliasDescriptor(alias) {
    return alias;
}
export function extractKeyIndex(providerKey) {
    return parseProviderKey(providerKey).keyIndex;
}
export function getProviderModelId(providerKey, providerRegistry) {
    const profile = providerRegistry.get(providerKey);
    if (profile.modelId) {
        return profile.modelId;
    }
    const parts = providerKey.split('.');
    if (parts.length === 2) {
        return parts[1] || null;
    }
    if (parts.length === 3) {
        return parts[2] || null;
    }
    return null;
}
export function extractExcludedProviderKeySet(metadata) {
    if (!metadata) {
        return new Set();
    }
    const raw = metadata.excludedProviderKeys;
    if (!Array.isArray(raw) || raw.length === 0) {
        return new Set();
    }
    const normalized = raw
        .map((value) => (typeof value === 'string' ? value.trim() : ''))
        .filter((value) => Boolean(value));
    return new Set(normalized);
}
