export const MAPS = [
  { id: 'de_dust2', name: 'Dust II', image: '/maps/dust2.jpg' },
  { id: 'de_mirage', name: 'Mirage', image: '/maps/mirage.jpg' },
  { id: 'de_inferno', name: 'Inferno', image: '/maps/inferno.jpg' },
  { id: 'de_nuke', name: 'Nuke', image: '/maps/nuke.jpg' },
  { id: 'de_anubis', name: 'Anubis', image: '/maps/anubis.jpg' },
  { id: 'de_vertigo', name: 'Vertigo', image: '/maps/vertigo.jpg' },
  { id: 'de_ancient', name: 'Ancient', image: '/maps/ancient.jpg' },
] as const;

export const GAME_MODES = [
  { id: 'competitive', name: 'Competitive', description: '5v5 Ranked', icon: 'Shield' },
  { id: 'casual', name: 'Casual', description: '5v5 Unranked', icon: 'Gamepad2' },
] as const;

export const RANK_TIERS = [
  { name: 'Unranked', min: 0, max: 0, color: '#6B7280', placement: true },
  { name: 'Bronze', min: 100, max: 799, color: '#CD7F32' },
  { name: 'Silver', min: 800, max: 1199, color: '#C0C0C0' },
  { name: 'Gold', min: 1200, max: 1599, color: '#FFD700' },
  { name: 'Platinum', min: 1600, max: 1999, color: '#00CED1' },
  { name: 'Diamond', min: 2000, max: 2399, color: '#B9F2FF' },
  { name: 'Master', min: 2400, max: 2799, color: '#9B59B6' },
  { name: 'Grandmaster', min: 2800, max: 3199, color: '#E74C3C' },
  { name: 'Champion', min: 3200, max: 3500, color: '#FFD700' },
] as const;

export const TICKET_CATEGORIES = [
  { id: 'bug_report', name: 'Bug Report' },
  { id: 'account_issue', name: 'Account Issue' },
  { id: 'ban_appeal', name: 'Ban Appeal' },
  { id: 'match_issue', name: 'Match Issue' },
  { id: 'feature_request', name: 'Feature Request' },
  { id: 'billing', name: 'Billing' },
  { id: 'other', name: 'Other' },
] as const;

export const MATCH_STATUSES = {
  queuing: 'Queuing',
  matched: 'Matched',
  server_starting: 'Server Starting',
  waiting_for_players: 'Waiting for Players',
  knife_round: 'Knife Round',
  side_selection: 'Side Selection',
  live: 'Live',
  finished: 'Finished',
  aborted: 'Aborted',
  cancelled: 'Cancelled',
} as const;

export function getRankTier(mmr: number, placementDone: boolean) {
  if (!placementDone) return RANK_TIERS[0];
  return RANK_TIERS.find((r) => !('placement' in r) && mmr >= r.min && mmr <= r.max) || RANK_TIERS[1];
}

export function formatRelativeTime(dateStr: string): string {
  const date = new Date(dateStr);
  const now = new Date();
  const diff = now.getTime() - date.getTime();
  const seconds = Math.floor(diff / 1000);
  const minutes = Math.floor(seconds / 60);
  const hours = Math.floor(minutes / 60);
  const days = Math.floor(hours / 24);
  if (days > 0) return `${days}d ago`;
  if (hours > 0) return `${hours}h ago`;
  if (minutes > 0) return `${minutes}m ago`;
  return 'just now';
}

export function formatNumber(n: number): string {
  return n.toLocaleString('en-US');
}
