/** Маппинг кода локали в название языка для LLM */
const LOCALE_TO_LANGUAGE: Record<string, string> = {
  ru: 'Russian',
  en: 'English',
  de: 'German',
  fr: 'French',
  es: 'Spanish',
  it: 'Italian',
  pt: 'Portuguese',
  uk: 'Ukrainian',
  pl: 'Polish',
  zh: 'Chinese',
  ja: 'Japanese',
  ko: 'Korean',
  ar: 'Arabic',
  tr: 'Turkish',
  be: 'Belarusian',
  kk: 'Kazakh',
  sv: 'Swedish',
  nb: 'Norwegian',
  da: 'Danish',
  fi: 'Finnish',
  cs: 'Czech',
  sk: 'Slovak',
  hu: 'Hungarian',
  ro: 'Romanian',
  bg: 'Bulgarian',
  hr: 'Croatian',
  sr: 'Serbian',
  el: 'Greek',
  hi: 'Hindi',
  th: 'Thai',
  vi: 'Vietnamese',
  id: 'Indonesian',
  ms: 'Malay',
  he: 'Hebrew',
  fa: 'Persian',
};

/**
 * Возвращает инструкцию для LLM о языке ответа.
 * Добавлять в system prompt каждого запроса (classifier, researcher, writer).
 */
export function getLocaleInstruction(locale?: string): string {
  if (!locale) return '';
  const lang = locale.split('-')[0];
  const languageName = LOCALE_TO_LANGUAGE[lang] ?? lang;
  return `
<response_language>
User's locale is ${locale}. Always format your response in ${languageName}, regardless of the language of the query or search results. Even when the discussed content is in another language, respond in ${languageName}.
</response_language>`;
}
