export interface GlossaryTerm {
  id: string;
  source: string;
  target: string;
  translations: Record<string, string>;
  created_at: string | null;
}

export interface Glossary {
  id: string;
  name: string;
  source_language: string;
  target_language: string;
  template_id?: string | null;
  terms: GlossaryTerm[];
  created_at: string;
  updated_at: string;
}

export interface GlossaryListItem {
  id: string;
  name: string;
  source_language: string;
  target_language: string;
  template_id?: string | null;
  terms_count: number;
  created_at: string;
}

export interface GlossaryListResponse {
  data: GlossaryListItem[];
  meta: {
    total: number;
    page: number;
    per_page: number;
    total_pages: number;
  };
}

export interface GlossaryDetailResponse {
  data: Glossary;
  meta: Record<string, unknown>;
}

export interface GlossaryCreateResponse {
  data: Glossary;
  meta: Record<string, unknown>;
}

export interface GlossaryUpdateResponse {
  data: Glossary;
  meta: Record<string, unknown>;
}

export interface GlossaryTermInput {
  source: string;
  target: string;
  translations?: Record<string, string>;
}

export interface GlossaryTermInputWithId extends GlossaryTermInput {
  id: string;
}

export interface GlossaryCreateInput {
  name: string;
  source_language?: string;
  target_language?: string;
  terms?: GlossaryTermInput[];
}

export interface GlossaryUpdateInput {
  name?: string;
  source_language?: string;
  target_language?: string;
  terms?: GlossaryTermInput[];
}

export const MAX_TERMS_PER_GLOSSARY = 500;

export const SUPPORTED_LANGUAGES: { code: string; label: string; flag: string }[] = [
  { code: 'multi', label: 'Multilingue', flag: '🌐' },
  { code: 'en', label: 'English', flag: '🇬🇧' },
  { code: 'fr', label: 'Français', flag: '🇫🇷' },
  { code: 'es', label: 'Español', flag: '🇪🇸' },
  { code: 'de', label: 'Deutsch', flag: '🇩🇪' },
  { code: 'pt', label: 'Português', flag: '🇧🇷' },
  { code: 'it', label: 'Italiano', flag: '🇮🇹' },
  { code: 'nl', label: 'Nederlands', flag: '🇳🇱' },
  { code: 'ru', label: 'Русский', flag: '🇷🇺' },
  { code: 'ja', label: '日本語', flag: '🇯🇵' },
  { code: 'ko', label: '한국어', flag: '🇰🇷' },
  { code: 'zh', label: '中文', flag: '🇨🇳' },
  { code: 'ar', label: 'العربية', flag: '🇸🇦' },
  { code: 'fa', label: 'فارسی', flag: '🇮🇷' },
];

// Generate unique IDs for React keys
let idCounter = 0;
export function generateTermId(): string {
  return `term-${Date.now()}-${++idCounter}`;
}
