// Demo/placeholder data for dashboard pages
// This will be replaced with real API calls once the backend is connected

export interface CostEntry {
  id: string;
  provider: string;
  amount: number;
  period: string; // YYYY-MM format
  category: string;
  note: string;
  createdAt: string;
}

export interface MonthlySpending {
  month: string;
  openai: number;
  anthropic: number;
  other: number;
  total: number;
}

export interface ProviderBreakdown {
  name: string;
  value: number;
  color: string;
}

export const PROVIDER_COLORS: Record<string, string> = {
  OpenAI: "#6366F1",
  Anthropic: "#F59E0B",
  "Google AI": "#10B981",
  "AWS Bedrock": "#EF4444",
  Azure: "#3B82F6",
  Other: "#8B5CF6",
};

export const demoEntries: CostEntry[] = [
  { id: "1", provider: "OpenAI", amount: 45.2, period: "2026-02", category: "API Usage", note: "GPT-4o production traffic", createdAt: "2026-02-14" },
  { id: "2", provider: "Anthropic", amount: 32.1, period: "2026-02", category: "API Usage", note: "Claude 3.5 Sonnet", createdAt: "2026-02-12" },
  { id: "3", provider: "OpenAI", amount: 18.5, period: "2026-02", category: "API Usage", note: "Embeddings", createdAt: "2026-02-10" },
  { id: "4", provider: "Google AI", amount: 8.15, period: "2026-02", category: "API Usage", note: "Gemini Pro", createdAt: "2026-02-08" },
  { id: "5", provider: "OpenAI", amount: 23.5, period: "2026-02", category: "Subscription", note: "ChatGPT Plus", createdAt: "2026-02-01" },
  { id: "6", provider: "OpenAI", amount: 52.3, period: "2026-01", category: "API Usage", note: "GPT-4o production traffic", createdAt: "2026-01-28" },
  { id: "7", provider: "Anthropic", amount: 38.7, period: "2026-01", category: "API Usage", note: "Claude 3.5 Sonnet", createdAt: "2026-01-20" },
  { id: "8", provider: "OpenAI", amount: 15.2, period: "2026-01", category: "API Usage", note: "Embeddings", createdAt: "2026-01-15" },
  { id: "9", provider: "Google AI", amount: 6.8, period: "2026-01", category: "API Usage", note: "Gemini Pro", createdAt: "2026-01-10" },
  { id: "10", provider: "Anthropic", amount: 12.0, period: "2026-01", category: "Subscription", note: "Claude Pro", createdAt: "2026-01-01" },
  { id: "11", provider: "OpenAI", amount: 48.9, period: "2025-12", category: "API Usage", note: "GPT-4o production traffic", createdAt: "2025-12-28" },
  { id: "12", provider: "Anthropic", amount: 29.4, period: "2025-12", category: "API Usage", note: "Claude 3 Opus", createdAt: "2025-12-20" },
  { id: "13", provider: "AWS Bedrock", amount: 22.1, period: "2025-12", category: "API Usage", note: "Bedrock Claude", createdAt: "2025-12-15" },
  { id: "14", provider: "OpenAI", amount: 41.6, period: "2025-11", category: "API Usage", note: "GPT-4o", createdAt: "2025-11-25" },
  { id: "15", provider: "Anthropic", amount: 25.3, period: "2025-11", category: "API Usage", note: "Claude 3.5 Sonnet", createdAt: "2025-11-15" },
  { id: "16", provider: "OpenAI", amount: 36.8, period: "2025-10", category: "API Usage", note: "GPT-4 Turbo", createdAt: "2025-10-20" },
  { id: "17", provider: "Anthropic", amount: 21.5, period: "2025-10", category: "API Usage", note: "Claude 3 Haiku", createdAt: "2025-10-10" },
  { id: "18", provider: "OpenAI", amount: 31.2, period: "2025-09", category: "API Usage", note: "GPT-4", createdAt: "2025-09-25" },
  { id: "19", provider: "Anthropic", amount: 18.9, period: "2025-09", category: "API Usage", note: "Claude 3 Sonnet", createdAt: "2025-09-15" },
  { id: "20", provider: "Google AI", amount: 5.4, period: "2025-09", category: "API Usage", note: "Gemini", createdAt: "2025-09-10" },
];

export const monthlySpending: MonthlySpending[] = [
  { month: "Sep 2025", openai: 31.2, anthropic: 18.9, other: 5.4, total: 55.5 },
  { month: "Oct 2025", openai: 36.8, anthropic: 21.5, other: 0, total: 58.3 },
  { month: "Nov 2025", openai: 41.6, anthropic: 25.3, other: 0, total: 66.9 },
  { month: "Dec 2025", openai: 48.9, anthropic: 29.4, other: 22.1, total: 100.4 },
  { month: "Jan 2026", openai: 67.5, anthropic: 50.7, other: 6.8, total: 125.0 },
  { month: "Feb 2026", openai: 87.2, anthropic: 32.1, other: 8.15, total: 127.45 },
];

export const providerBreakdown: ProviderBreakdown[] = [
  { name: "OpenAI", value: 87.2, color: "#6366F1" },
  { name: "Anthropic", value: 32.1, color: "#F59E0B" },
  { name: "Google AI", value: 8.15, color: "#10B981" },
];

export function getCurrentMonthTotal(): number {
  return demoEntries
    .filter((e) => e.period === "2026-02")
    .reduce((sum, e) => sum + e.amount, 0);
}

export function getProjectedMonthly(): number {
  // Simple projection: current spend * (days in month / days elapsed)
  const dayOfMonth = 15;
  const daysInMonth = 28;
  const currentTotal = getCurrentMonthTotal();
  return (currentTotal / dayOfMonth) * daysInMonth;
}

export function getPotentialSavings(): { amount: number; percent: number } {
  const projected = getProjectedMonthly();
  // LLMHosts typically saves 30-50% through caching + routing
  const savingsPercent = 40;
  const savingsAmount = projected * (savingsPercent / 100);
  return { amount: savingsAmount, percent: savingsPercent };
}
