namespace Nalu.Web.Services;

/// <summary>
/// Credit cost per validator. 1 = deterministic, 2 = light LLM, 5 = heavy LLM (70B context-aware).
/// </summary>
public static class CreditCosts
{
    private static readonly Dictionary<string, int> _costs = new(StringComparer.OrdinalIgnoreCase)
    {
        // 1 credit — deterministic
        ["validate_cpf"]        = 1,
        ["validate_cep"]        = 1,
        ["validate_cnpj"]       = 1,
        ["validate_email"]      = 1,
        ["validate_phone_br"]   = 1,
        ["validate_plate_br"]   = 1,
        ["validate_postal_code"]= 1,

        // 2 credits — light LLM
        ["validate_name"]       = 2,
        ["validate_full_name"]  = 2,
        ["validate_yes_no"]     = 2,
        ["validate_birthdate"]  = 2,
        ["validate_handoff"]    = 2,
        ["validate_cancel_intent"] = 2,
        ["validate_company_name"]  = 2,

        // 5 credits — heavy LLM (validate_reply)
        ["validate_reply"]      = 5,
    };

    public static int Get(string validatorId) =>
        _costs.TryGetValue(validatorId, out var cost) ? cost : 1;

    // Endpoint aliases → validator IDs
    private static readonly Dictionary<string, string> _aliases = new(StringComparer.OrdinalIgnoreCase)
    {
        ["name"]         = "validate_name",
        ["full-name"]    = "validate_full_name",
        ["cpf"]          = "validate_cpf",
        ["cep"]          = "validate_cep",
        ["phone"]        = "validate_phone_br",
        ["email"]        = "validate_email",
        ["postal-code"]  = "validate_postal_code",
        ["yes-no"]       = "validate_yes_no",
        ["birthdate"]    = "validate_birthdate",
        ["handoff"]      = "validate_handoff",
        ["cancel-intent"]= "validate_cancel_intent",
        ["cnpj"]         = "validate_cnpj",
        ["plate-br"]     = "validate_plate_br",
        ["company-name"] = "validate_company_name",
        ["reply"]        = "validate_reply",
    };

    public static int GetByEndpoint(string endpoint) =>
        _aliases.TryGetValue(endpoint, out var id) ? Get(id) : 1;
}
