/**
 * AI 모델 배포 / 품질 게이트 / 실험 상태 카탈로그
 *
 * 사용처: MLOpsPage
 */

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

// ─── 모델 배포 상태 ──────────────
export type ModelStatus = 'DEPLOYED' | 'APPROVED' | 'TESTING' | 'DRAFT';

export const MODEL_STATUSES: Record<ModelStatus, { i18nKey: string; fallback: { ko: string; en: string }; intent: BadgeIntent }> = {
  DEPLOYED: {
    i18nKey: 'modelStatus.DEPLOYED',
    fallback: { ko: '배포됨', en: 'Deployed' },
    intent: 'success',
  },
  APPROVED: {
    i18nKey: 'modelStatus.APPROVED',
    fallback: { ko: '승인', en: 'Approved' },
    intent: 'info',
  },
  TESTING: {
    i18nKey: 'modelStatus.TESTING',
    fallback: { ko: '테스트', en: 'Testing' },
    intent: 'warning',
  },
  DRAFT: {
    i18nKey: 'modelStatus.DRAFT',
    fallback: { ko: '초안', en: 'Draft' },
    intent: 'muted',
  },
};

export function getModelStatusIntent(s: string): BadgeIntent {
  return MODEL_STATUSES[s as ModelStatus]?.intent ?? 'muted';
}
export function getModelStatusLabel(
  s: string,
  t: (k: string, opts?: { defaultValue?: string }) => string,
  lang: 'ko' | 'en' = 'ko',
): string {
  const meta = MODEL_STATUSES[s as ModelStatus];
  if (!meta) return s;
  return t(meta.i18nKey, { defaultValue: meta.fallback[lang] });
}

// ─── 품질 게이트 상태 ──────────────
export type QualityGateStatus = 'pass' | 'fail' | 'run' | 'pending';

export const QUALITY_GATE_STATUSES: Record<QualityGateStatus, { intent: BadgeIntent; pulse?: boolean; fallback: { ko: string; en: string } }> = {
  pass: { intent: 'success', fallback: { ko: '통과', en: 'Pass' } },
  fail: { intent: 'critical', fallback: { ko: '실패', en: 'Fail' } },
  run: { intent: 'warning', pulse: true, fallback: { ko: '실행중', en: 'Running' } },
  pending: { intent: 'muted', fallback: { ko: '대기', en: 'Pending' } },
};

export function getQualityGateIntent(s: string): BadgeIntent {
  return QUALITY_GATE_STATUSES[s as QualityGateStatus]?.intent ?? 'muted';
}

// ─── 실험 상태 ──────────────
export type ExperimentStatus = 'running' | 'done' | 'failed';

export const EXPERIMENT_STATUSES: Record<ExperimentStatus, { intent: BadgeIntent; pulse?: boolean; fallback: { ko: string; en: string } }> = {
  running: { intent: 'info', pulse: true, fallback: { ko: '실행중', en: 'Running' } },
  done: { intent: 'success', fallback: { ko: '완료', en: 'Done' } },
  failed: { intent: 'critical', fallback: { ko: '실패', en: 'Failed' } },
};

export function getExperimentIntent(s: string): BadgeIntent {
  return EXPERIMENT_STATUSES[s as ExperimentStatus]?.intent ?? 'muted';
}
