export type CodexModelOption = {
  value: string;
  label: string;
  description: string;
};

export const DEFAULT_CODEX_MODEL = 'gpt-5.4';

export const CODEX_MODEL_OPTIONS: CodexModelOption[] = [
  {
    value: 'gpt-5.4',
    label: 'GPT-5.4',
    description: '기본 균형형 모델',
  },
  {
    value: 'gpt-5.4-mini',
    label: 'GPT-5.4 Mini',
    description: '빠른 응답 중심',
  },
  {
    value: 'gpt-5.3-codex',
    label: 'GPT-5.3 Codex',
    description: '코딩 최적화',
  },
  {
    value: 'gpt-5.3-codex-spark',
    label: 'GPT-5.3 Codex Spark',
    description: '초고속 코딩 응답',
  },
  {
    value: 'gpt-5.2-codex',
    label: 'GPT-5.2 Codex',
    description: '안정적인 코드 작업',
  },
  {
    value: 'gpt-5.1-codex-mini',
    label: 'GPT-5.1 Codex Mini',
    description: '가벼운 작업용',
  },
  {
    value: 'gpt-5.1-codex-max',
    label: 'GPT-5.1 Codex Max',
    description: '깊은 추론 중심',
  },
];

export function normalizeCodexModel(value: string | null | undefined) {
  const normalized = value?.trim() ?? '';

  if (!normalized) {
    return DEFAULT_CODEX_MODEL;
  }

  return CODEX_MODEL_OPTIONS.some((option) => option.value === normalized) ? normalized : DEFAULT_CODEX_MODEL;
}

export function resolveCodexModelLabel(value: string | null | undefined) {
  const normalized = normalizeCodexModel(value);
  return CODEX_MODEL_OPTIONS.find((option) => option.value === normalized)?.label ?? normalized;
}
