"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatNetworkCode = exports.parseNetworkCode = exports.pickNetworkContract = exports.getTrendingTokenNetwork = exports.isValerisNetwork = exports.normalizeNetwork = exports.ANY_NETWORK_CODE = exports.CODE_TO_NETWORK = exports.NETWORK_CODES = exports.VALERIS_ALLOWED_NETWORKS = void 0;
exports.VALERIS_ALLOWED_NETWORKS = [
    "Ethereum",
    "BNB Smart Chain",
    "Polygon",
    "Avalanche C-Chain",
    "Base"
];
exports.NETWORK_CODES = {
    Ethereum: "ETH",
    "BNB Smart Chain": "BSC",
    Polygon: "POLY",
    "Avalanche C-Chain": "AVAX",
    Base: "BASE"
};
exports.CODE_TO_NETWORK = Object.fromEntries(Object.entries(exports.NETWORK_CODES).map(([network, code]) => [code, network]));
exports.ANY_NETWORK_CODE = "ANY";
const NETWORK_ALIASES = {
    ethereum: "Ethereum",
    "ethereum mainnet": "Ethereum",
    bsc: "BNB Smart Chain",
    "bnb smart chain": "BNB Smart Chain",
    binance: "BNB Smart Chain",
    "binance smart chain": "BNB Smart Chain",
    polygon: "Polygon",
    "polygon mainnet": "Polygon",
    matic: "Polygon",
    avalanche: "Avalanche C-Chain",
    "avalanche c-chain": "Avalanche C-Chain",
    avax: "Avalanche C-Chain",
    base: "Base",
    "base mainnet": "Base"
};
const normalizeNetwork = (networkName) => {
    if (!networkName)
        return undefined;
    const normalized = networkName.trim().toLowerCase();
    return NETWORK_ALIASES[normalized];
};
exports.normalizeNetwork = normalizeNetwork;
const isValerisNetwork = (networkName) => {
    return (0, exports.normalizeNetwork)(networkName) !== undefined;
};
exports.isValerisNetwork = isValerisNetwork;
const getTrendingTokenNetwork = (token) => {
    for (const contract of token.contractAddresses) {
        const network = (0, exports.normalizeNetwork)(contract.network);
        if (network)
            return network;
    }
    return undefined;
};
exports.getTrendingTokenNetwork = getTrendingTokenNetwork;
const pickNetworkContract = (token, network) => {
    return token.contractAddresses.find((contract) => (0, exports.normalizeNetwork)(contract.network) === network);
};
exports.pickNetworkContract = pickNetworkContract;
const parseNetworkCode = (code) => {
    if (!code || code === exports.ANY_NETWORK_CODE)
        return undefined;
    return exports.CODE_TO_NETWORK[code];
};
exports.parseNetworkCode = parseNetworkCode;
const formatNetworkCode = (network) => {
    if (!network)
        return exports.ANY_NETWORK_CODE;
    return exports.NETWORK_CODES[network];
};
exports.formatNetworkCode = formatNetworkCode;
