/**
 * MLOps Job / 워크플로우 / 파이프라인 상태 카탈로그
 *
 * 사용처: LGCNSMLOpsPage
 */

import type { BadgeIntent } from '@lib/theme/variants';

export type MlopsJobStatus = 'running' | 'done' | 'fail' | 'pending';

export const MLOPS_JOB_STATUSES: Record<MlopsJobStatus, { i18nKey: string; fallback: { ko: string; en: string }; intent: BadgeIntent }> = {
  running: {
    i18nKey: 'mlopsJob.running',
    fallback: { ko: '실행중', en: 'Running' },
    intent: 'info',
  },
  done: {
    i18nKey: 'mlopsJob.done',
    fallback: { ko: '완료', en: 'Done' },
    intent: 'success',
  },
  fail: {
    i18nKey: 'mlopsJob.fail',
    fallback: { ko: '실패', en: 'Failed' },
    intent: 'critical',
  },
  pending: {
    i18nKey: 'mlopsJob.pending',
    fallback: { ko: '대기', en: 'Pending' },
    intent: 'muted',
  },
};

export function getMlopsJobStatusIntent(s: string): BadgeIntent {
  return MLOPS_JOB_STATUSES[s as MlopsJobStatus]?.intent ?? 'muted';
}

export function getMlopsJobStatusLabel(
  s: string,
  t: (k: string, opts?: { defaultValue?: string }) => string,
  lang: 'ko' | 'en' = 'ko',
): string {
  const meta = MLOPS_JOB_STATUSES[s as MlopsJobStatus];
  if (!meta) return s;
  return t(meta.i18nKey, { defaultValue: meta.fallback[lang] });
}
