/**
 * Filter raw TMDB results down to ones the user does NOT own. The library
 * map keys items by their TMDB id; we drop anything that hits. When no
 * library map has loaded yet, returns an empty array so rows hide rather
 * than briefly showing items the user already owns.
 */
export function filterToMissing<T extends { id: number; original_language?: string }>(
  raw: T[],
  lib?: Map<string, unknown> | null,
  hideAdult = false,
  adultFlag?: (m: T) => boolean,
): T[] {
  if (!lib) return []
  let list = raw.filter(m => !lib.has(String(m.id)))
  if (hideAdult && adultFlag) list = list.filter(m => !adultFlag(m))
  return list
}

export const GENRE_ROWS: Array<{ label: string; subtitle: string }> = [
  { label: 'Action', subtitle: 'Bullets, fists, explosions' },
  { label: 'Drama', subtitle: 'Stories that hit deep' },
  { label: 'Comedy', subtitle: 'Light watching' },
  { label: 'Science Fiction', subtitle: 'Beyond the possible' },
  { label: 'Thriller', subtitle: 'Edge-of-your-seat tension' },
  { label: 'Horror', subtitle: 'Lights off' },
  { label: 'Animation', subtitle: 'Drawn to perfection' },
  { label: 'Romance', subtitle: 'Love and longing' },
  { label: 'Fantasy', subtitle: 'Worlds of magic' },
  { label: 'Mystery', subtitle: 'Puzzles to solve' },
]

export const LANGUAGE_ROWS: Array<{ code: string; label: string; subtitle: string }> = [
  { code: 'ja', label: 'Japanese cinema', subtitle: 'From Kurosawa to Kore-eda' },
  { code: 'ko', label: 'Korean cinema', subtitle: 'New wave thrillers and drama' },
  { code: 'fr', label: 'French cinema', subtitle: 'Auteurs and arthouse' },
  { code: 'es', label: 'Spanish-language cinema', subtitle: 'Spain and Latin America' },
  { code: 'de', label: 'German cinema', subtitle: 'Berlin school and beyond' },
  { code: 'it', label: 'Italian cinema', subtitle: 'Neo-realism to giallo' },
  { code: 'zh', label: 'Chinese-language cinema', subtitle: 'Mainland, Hong Kong, Taiwan' },
  { code: 'hi', label: 'Hindi cinema', subtitle: 'Bollywood at its best' },
]
