import type {
  TranslationSeedItem,
  TranslationSeedModule,
} from './translation-seed.types';
export const PLENARY_LABELS: ReadonlyArray<readonly [string, string, string]> =
  [
    ['working_group', 'Working Group', 'ក្រុមការងារ'],
    ['category', 'Category', 'ប្រភេទ'],
    ['status', 'Status', 'ស្ថានភាព'],
    ['primary_agency', 'Primary Agency', 'ស្ថាប័នទទួលបន្ទុក'],
    ['year', 'Year', 'ឆ្នាំ'],
    ['progress_report', 'Progress Report', 'របាយការណ៍វឌ្ឍនភាព'],
    ['all_working_groups', 'All working groups', 'ក្រុមការងារទាំងអស់'],
    ['all_categories', 'All categories', 'ប្រភេទទាំងអស់'],
    ['all_statuses', 'All statuses', 'ស្ថានភាពទាំងអស់'],
    ['all_agencies', 'All agencies', 'ស្ថាប័នទាំងអស់'],
    ['all_years', 'All years', 'ឆ្នាំទាំងអស់'],
    ['reset', 'RESET', 'កំណត់ឡើងវិញ'],
    ['page_title', 'Dashboard', 'ផ្ទាំងគ្រប់គ្រង'],
    [
      'dashboard_subtitle',
      'Monitor G-PSF implementation. Use filters and click charts to drill down.',
      'តាមដានការអនុវត្ត G-PSF។ ប្រើតម្រង និងចុចលើក្រាហ្វ ដើម្បីមើលព័ត៌មានលម្អិត។',
    ],
    ['export', 'Export', 'នាំចេញ'],
    ['new_item', 'New', 'បង្កើតថ្មី'],
    [
      'new_progress_report',
      'New Progress Report',
      'បង្កើតរបាយការណ៍វឌ្ឍនភាពថ្មី',
    ],
    ['last_updated', 'Last updated', 'ធ្វើបច្ចុប្បន្នភាពចុងក្រោយ'],
    ['add_issue', 'Add Issue', 'បន្ថែមបញ្ហា'],
    ['request_meeting', 'Request Meeting', 'ស្នើសុំកិច្ចប្រជុំ'],
    ['csv', 'CSV', 'CSV'],
    ['xlsx', 'XLSX', 'XLSX'],
    ['image', 'Image', 'រូបភាព'],
    ['overall_status', 'Overall Implementation Status', 'ស្ថានភាពអនុវត្តរួម'],
    ['total_issues', 'Total Issues', 'បញ្ហាសរុប'],
    ['solved', 'Solved', 'បានដោះស្រាយ'],
    ['in_progress', 'In Progress', 'កំពុងដោះស្រាយ'],
    ['not_addressed', 'Not Addressed', 'មិនទាន់ដោះស្រាយ'],
    ['primary_agencies', 'Government Primary Agencies', 'ស្ថាប័នរដ្ឋចម្បង'],
    ['working_group_chart', 'Working Group', 'ក្រុមការងារ'],
    ['category_of_issues', 'Category of Issues', 'ប្រភេទបញ្ហា'],
    ['other', 'Other', 'ផ្សេងៗ'],
    ['both', 'Both', 'ទាំងពីរ'],
    ['s1', 'S1', 'ឆមាសទី១'],
    ['s2', 'S2', 'ឆមាសទី២'],
    [
      'not_published',
      'CDC G-PSF has not published a plenary dashboard yet.',
      'CDC G-PSF មិនទាន់បានចេញផ្សាយផ្ទាំងគ្រប់គ្រងវេទិការនៅឡើយទេ។',
    ],
    [
      'total_primary_agencies',
      'Total Primary Agencies',
      'ស្ថាប័នទទួលបន្ទុកសរុប',
    ],
    [
      'load_failed',
      'Unable to load the dashboard.',
      'មិនអាចទាញយកផ្ទាំងគ្រប់គ្រងបានទេ។',
    ],
    ['export_chart', 'Export chart', 'នាំចេញក្រាហ្វ'],
    ['filter', 'Filter', 'តម្រង'],
    ['filter_by', 'Filter by...', 'តម្រងតាម...'],
    ['back', 'Back', 'ត្រឡប់ក្រោយ'],
    ['remove_filter', 'Remove filter', 'លុបតម្រង'],
    ['no_options', 'No options available', 'មិនមានជម្រើស'],
    ['clear_all', 'Clear all', 'សម្អាតទាំងអស់'],
    ['select_all', 'Select all', 'ជ្រើសរើសទាំងអស់'],
    ['clear_selection', 'Clear', 'សម្អាត'],
    ['month', 'Month', 'ខែ'],
    ['filters', 'Filters', 'តម្រង'],
    ['view_all', 'View All', 'មើលទាំងអស់'],
    ['view_less', 'View Less', 'មើលតិច'],
    ['apply_filters', 'Apply Filters', 'អនុវត្តតម្រង'],
    ['new_plenary', 'New Plenary', 'បង្កើតវេទិការថ្មី'],
    ['in_progress_status', 'In Progress Status', 'ស្ថានភាពកំពុងដោះស្រាយ'],
    ['measure_category', 'Measure Category', 'ប្រភេទវិធានការ'],
    ['working_group_name', 'Working group Name', 'ឈ្មោះក្រុមការងារ'],
    ['mid_progress', 'Mid Progress', 'វឌ្ឍនភាពពាក់កណ្ដាល'],
    ['early_progress', 'Early Progress', 'វឌ្ឍនភាពដំបូង'],
  ];
export function plenarySeedPage(module: TranslationSeedModule) {
  return ['pswg', 'cdc', 'cefp'].includes(module)
    ? 'dashboard_plenary'
    : 'plenary_dashboard';
}
export function withPlenaryLabels(
  module: TranslationSeedModule,
  items: TranslationSeedItem[],
): TranslationSeedItem[] {
  const page = plenarySeedPage(module);
  const existing = new Set(
    items
      .filter((item) => item.module === module && item.page === page)
      .map((item) => item.translationKey),
  );
  return [
    ...items,
    ...(module === 'ministry' ? ministryPlenaryLabelSeeds(items) : []),
    ...PLENARY_LABELS.filter(([key]) => !existing.has(key)).map(
      ([translationKey, englishText, khmerText]) => ({
        module,
        page,
        translationKey,
        englishText,
        khmerText,
        isActive: true,
        parent: { module, page, translationKey: 'title' },
      }),
    ),
  ];
}
export function selectPlenarySeeds(
  module: TranslationSeedModule,
  items: TranslationSeedItem[],
): TranslationSeedItem[] {
  const selected = new Map<string, TranslationSeedItem>();
  const id = (item: { module: string; page: string; translationKey: string }) =>
    [item.module, item.page, item.translationKey].join('/');
  function add(item: TranslationSeedItem) {
    if (selected.has(id(item))) return;
    if (item.parent) {
      const parent = items.find(
        (candidate) => id(candidate) === id(item.parent!),
      );
      if (!parent)
        throw new Error(
          'Missing dashboard translation parent: ' + id(item.parent),
        );
      add(parent);
    }
    selected.set(id(item), item);
  }
  items
    .filter(
      (item) =>
        item.module === module &&
        (item.page === plenarySeedPage(module) ||
          (module === 'ministry' &&
            ['plenary_plenaries', 'plenary_rgc_decisions'].includes(
              item.page,
            ))),
    )
    .forEach(add);
  return [...selected.values()];
}
import { ministryPlenaryLabelSeeds } from './ministry-plenary-labels.seed';
