// src/components/ui/flag-src.ts — résolution pure du chemin d'un drapeau
// statique. Isolée du composant (aucun import React) pour rester testable en
// bun:test sous `--conditions=react-server`, où charger lucide-react/React
// planterait (createContext absent du build RSC).

/** `/flags/{alpha2}.svg` pour un code ISO alpha-2 valide, sinon null. */
export function flagSrc(code: string | null | undefined): string | null {
  if (!code || !/^[a-zA-Z]{2}$/.test(code)) return null;
  return `/flags/${code.toLowerCase()}.svg`;
}
