export interface HeroAvatar {
  id: string;
  name: string;
  color: string; // NativeWind border color class
  url: string;
}

// PNG, not SVG — React Native's <Image> can't decode SVG (Hero-Avatars rendered
// blank/transparent on Android otherwise). DiceBear serves PNG at the /png path.
const DICEBEAR_BASE = 'https://api.dicebear.com/9.x/adventurer/png';

export const HERO_AVATARS: HeroAvatar[] = [
  { id: 'spider', name: 'Spider', color: 'border-red-500', url: `${DICEBEAR_BASE}?seed=spiderman&backgroundColor=b71c1c` },
  { id: 'hulk', name: 'Hulk', color: 'border-green-500', url: `${DICEBEAR_BASE}?seed=hulk&backgroundColor=1b5e20` },
  { id: 'iron', name: 'Iron', color: 'border-yellow-500', url: `${DICEBEAR_BASE}?seed=ironman&backgroundColor=e65100` },
  { id: 'cap', name: 'Captain', color: 'border-blue-500', url: `${DICEBEAR_BASE}?seed=captain&backgroundColor=0d47a1` },
  { id: 'storm', name: 'Storm', color: 'border-purple-500', url: `${DICEBEAR_BASE}?seed=storm&backgroundColor=4a148c` },
  { id: 'wolf', name: 'Wolf', color: 'border-gray-400', url: `${DICEBEAR_BASE}?seed=wolverine&backgroundColor=37474f` },
  { id: 'flash', name: 'Flash', color: 'border-red-400', url: `${DICEBEAR_BASE}?seed=flash&backgroundColor=c62828` },
  { id: 'panther', name: 'Panther', color: 'border-indigo-500', url: `${DICEBEAR_BASE}?seed=panther&backgroundColor=1a237e` },
  { id: 'phoenix', name: 'Phoenix', color: 'border-orange-500', url: `${DICEBEAR_BASE}?seed=phoenix&backgroundColor=bf360c` },
  { id: 'frost', name: 'Frost', color: 'border-cyan-400', url: `${DICEBEAR_BASE}?seed=frost&backgroundColor=006064` },
  { id: 'shadow', name: 'Shadow', color: 'border-gray-600', url: `${DICEBEAR_BASE}?seed=shadow&backgroundColor=212121` },
  { id: 'nova', name: 'Nova', color: 'border-pink-500', url: `${DICEBEAR_BASE}?seed=nova&backgroundColor=880e4f` },
];

export function getAvatarById(id: string): HeroAvatar | undefined {
  return HERO_AVATARS.find((a) => a.id === id);
}

export function getAvatarUrl(id: string): string {
  return getAvatarById(id)?.url ?? `${DICEBEAR_BASE}?seed=anonym&backgroundColor=374151`;
}
