/**
 * Model configurations with pricing (as of 2024)
 */
const MODEL_CONFIGS = {
    "gpt-4": {
        name: "GPT-4",
        shortName: "GPT-4",
        costPer1kTokens: 0.03,
        maxTokens: 8192,
    },
    "gpt-4-turbo": {
        name: "GPT-4 Turbo",
        shortName: "GPT-4T",
        costPer1kTokens: 0.01,
        maxTokens: 128000,
    },
    "gpt-3.5-turbo": {
        name: "GPT-3.5 Turbo",
        shortName: "GPT-3.5",
        costPer1kTokens: 0.0005,
        maxTokens: 16385,
    },
    "claude-3-opus": {
        name: "Claude 3 Opus",
        shortName: "Opus",
        costPer1kTokens: 0.015,
        maxTokens: 200000,
    },
    "claude-3-sonnet": {
        name: "Claude 3.5 Sonnet",
        shortName: "Sonnet",
        costPer1kTokens: 0.003,
        maxTokens: 200000,
    },
    "claude-3-haiku": {
        name: "Claude 3 Haiku",
        shortName: "Haiku",
        costPer1kTokens: 0.00025,
        maxTokens: 200000,
    },
    "gemini-pro": {
        name: "Gemini Pro",
        shortName: "Gemini",
        costPer1kTokens: 0.00025,
        maxTokens: 32000,
    },
    "gemini-ultra": {
        name: "Gemini Ultra",
        shortName: "Ultra",
        costPer1kTokens: 0.0025,
        maxTokens: 32000,
    },
    custom: {
        name: "Custom",
        shortName: "Custom",
        costPer1kTokens: 0,
        maxTokens: 4096,
    },
};
/**
 * Estimate token count from text
 * Uses a simple word-based heuristic (1 token ≈ 0.75 words for English)
 * This is an approximation - actual tokenization varies by model
 */
const estimateTokens = (text) => {
    if (!text)
        return 0;
    // Remove extra whitespace and split into words
    const words = text.trim().split(/\s+/).filter(Boolean);
    // Rough estimation: 1 token ≈ 0.75 words (or 4 characters)
    // This is a common approximation for GPT models
    const wordBasedEstimate = Math.ceil(words.length / 0.75);
    const charBasedEstimate = Math.ceil(text.length / 4);
    // Use the average of both methods for better accuracy
    return Math.ceil((wordBasedEstimate + charBasedEstimate) / 2);
};
/**
 * Calculate cost based on token count
 */
const calculateCost = (tokens, costPer1kTokens) => {
    return (tokens / 1000) * costPer1kTokens;
};
/**
 * Format cost for display
 */
const formatCost = (cost) => {
    if (cost < 0.01) {
        return `$${cost.toFixed(4)}`;
    }
    if (cost < 0.1) {
        return `$${cost.toFixed(3)}`;
    }
    return `$${cost.toFixed(2)}`;
};
/**
 * Format token count for display
 */
const formatTokenCount = (tokens) => {
    if (tokens >= 1000000) {
        return `${(tokens / 1000000).toFixed(1)}M`;
    }
    if (tokens >= 1000) {
        return `${(tokens / 1000).toFixed(1)}K`;
    }
    return tokens.toString();
};

export { MODEL_CONFIGS, calculateCost, estimateTokens, formatCost, formatTokenCount };
