// Dictionnaire de traduction croisée pour la recherche
// Permet de chercher "papa" et trouver les vidéos avec "dad", "father", etc.
// Format: mot_clé: [synonymes_anglais, autres_langues]

export const SEARCH_TRANSLATION_MAP: Record<string, string[]> = {
  // Français → Anglais
  "papa": ["dad", "father", "daddy", "papa"],
  "maman": ["mom", "mother", "mommy", "mama", "mum"],
  "père": ["father", "dad", "daddy"],
  "mère": ["mother", "mom", "mommy"],
  "fils": ["son", "boy"],
  "fille": ["daughter", "girl"],
  "frère": ["brother", "bro"],
  "sœur": ["sister", "sis"],
  "grand-père": ["grandpa", "grandfather", "granddad"],
  "grand-mère": ["grandma", "grandmother"],
  "oncle": ["uncle"],
  "tante": ["aunt"],
  "cousin": ["cousin"],
  "beau-père": ["stepdad", "stepfather"],
  "belle-mère": ["stepmom", "stepmother"],
  "amateur": ["amateur", "homemade", "amateur"],
  "maison": ["home", "house", "homemade"],
  "gros": ["big", "huge", "large", "fat"],
  "grosse": ["big", "huge", "large", "fat"],
  "couche": ["diaper", "nappy", "abdl"],
  "diaper": ["diaper", "nappy", "abdl", "couche"],
  "abdl": ["abdl", "diaper", "adult baby"],
  "bébé": ["baby"],
  "plein": ["full", "filled"],
  "compilation": ["compilation", "compilations", "comp"],
  "anal": ["anal"],
  "oral": ["oral", "blowjob", "bj"],
  "blonde": ["blonde", "blond"],
  "brune": ["brunette", "dark"],
  "rousse": ["redhead", "ginger"],
  "mature": ["mature", "milf", "older"],
  "jeune": ["young", "teen", "teenage"],
  "asiatique": ["asian"],
  "latin": ["latina", "latin"],
  "ebene": ["ebony", "black"],
  "blanc": ["white", "caucasian"],
  "groupe": ["group", "gangbang", "orgy"],
  "solo": ["solo", "alone", "masturbation"],
  "couple": ["couple"],
  "lesbien": ["lesbian"],
  "lesbienne": ["lesbian"],
  "gay": ["gay"],
  "trans": ["trans", "transgender", "shemale"],
  "massage": ["massage"],
  "bureau": ["office", "work"],
  "docteur": ["doctor"],
  "infirmière": ["nurse"],
  "professeur": ["teacher", "professor"],
  "étudiant": ["student"],
  "étudiante": ["student"],
  "patron": ["boss"],
  "voisine": ["neighbor", "neighbour"],
  "voisin": ["neighbor", "neighbour"],
  "inconnu": ["stranger", "unknown"],
  "public": ["public", "outdoor"],
  "extérieur": ["outdoor", "outside", "public"],
  "fétiche": ["fetish"],
  "domination": ["domination", "bdsm"],
  "soumis": ["submissive", "sub"],
  "dominant": ["dominant", "dom"],
  "uniforme": ["uniform"],
  "lingerie": ["lingerie"],
  "bas": ["stockings", "nylons"],
  "talons": ["heels", "high heels"],
  "naturel": ["natural", "real", "authentic"],
  "gros seins": ["big tits", "busty", "large breasts"],
  "petit": ["small", "petite", "tiny"],
  "fesses": ["ass", "butt", "booty"],
  "sein": ["breast", "boob", "tit"],
  "seins": ["breasts", "boobs", "tits"],
  // Espagnol → Anglais
  "papá": ["dad", "father", "daddy"],
  "mamá": ["mom", "mother", "mommy"],
  "padre": ["father", "dad"],
  "madre": ["mother", "mom"],
  "hijo": ["son"],
  "hija": ["daughter"],
  "hermano": ["brother"],
  "hermana": ["sister"],
  "abuelo": ["grandpa", "grandfather"],
  "abuela": ["grandma", "grandmother"],
  "joven": ["young", "teen"],
  "maduro": ["mature"],
  "grande": ["big", "large"],
  "pequeño": ["small", "petite", "tiny"],
  "público": ["public"],
  // Allemand → Anglais
  "vater": ["father", "dad"],
  "mutter": ["mother", "mom"],
  "sohn": ["son"],
  "tochter": ["daughter"],
  "bruder": ["brother"],
  "schwester": ["sister"],
  "jung": ["young", "teen"],
  "reif": ["mature"],
  "gross": ["big", "large"],
  "klein": ["small", "petite"],
  // Mots spécifiques pour V2
  "porn": ["porn", "porno", "sex", "adult"],
  "porno": ["porn", "porno", "sex", "adult"],
  "diaper porn": ["diaper", "abdl", "nappy", "adult baby"],
  "couche porn": ["diaper", "abdl", "nappy", "couche"],
  
  // Arabe translittéré
  "baba": ["dad", "father", "daddy", "papa"],
  "mama": ["mom", "mother", "mommy", "mama"],
};

/**
 * Traduit une requête de recherche en termes équivalents anglais
 * "papa" → ["dad", "father", "daddy", "papa"]
 * "diaper full" → ["diaper", "full"] + synonymes
 */
export function expandSearchQuery(query: string): string[] {
  const terms = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
  const expanded = new Set<string>();

  // Ajoute les termes originaux d'abord
  terms.forEach(t => expanded.add(t));

  // Cherche des synonymes pour chaque terme
  terms.forEach(term => {
    // Correspondance exacte
    if (SEARCH_TRANSLATION_MAP[term]) {
      SEARCH_TRANSLATION_MAP[term].forEach(s => expanded.add(s));
    }
    
    // Correspondance partielle sécurisée (seulement pour les mots longs pour éviter de matcher tout le dictionnaire)
    if (term.length >= 4) {
      Object.keys(SEARCH_TRANSLATION_MAP).forEach(key => {
        if (key.length >= 4 && (key.includes(term) || term.includes(key))) {
          SEARCH_TRANSLATION_MAP[key].forEach(s => expanded.add(s));
        }
      });
    }
  });

  // Cherche aussi la phrase entière
  const fullQuery = query.trim().toLowerCase();
  if (SEARCH_TRANSLATION_MAP[fullQuery]) {
    SEARCH_TRANSLATION_MAP[fullQuery].forEach(s => expanded.add(s));
  }

  // Plafonner à 15 termes maximum pour la V2
  return Array.from(expanded).slice(0, 15);
}
