import { defaultSelectionName } from './selectionDefaults';

/** 管理后台盘口选项展示名（按 code + 当前语言） */
export function adminSelectionLabel(
  t: (key: string) => string,
  code: string,
  opts?: { lineValue?: number | null; period?: string },
): string {
  const i18nKey = `matchEditor.selection.${code}`;
  const translated = t(i18nKey);
  if (translated !== i18nKey) return translated;

  const score = code.match(/^SCORE_(\d+)_(\d+)$/);
  if (score) return `${score[1]}-${score[2]}`;

  if (opts) {
    const name = defaultSelectionName(code, opts);
    if (name !== code) return name;
  }

  return code;
}
