/** 质押团队节点等级（与后端 /uc/staking/team、direct/list 一致） */
export type StakingNodeLevelCode = 'NORMAL' | 'COMMUNITY' | 'CITY' | 'APAC' | 'GLOBAL'

const LEVEL_I18N_KEY: Record<string, string> = {
  NORMAL: 'finance.nodeLevelNormal',
  COMMUNITY: 'finance.nodeLevelCommunity',
  CITY: 'finance.nodeLevelCity',
  APAC: 'finance.nodeLevelApac',
  GLOBAL: 'finance.nodeLevelGlobal',
}

export function normalizeStakingNodeLevel(level: string | undefined | null): StakingNodeLevelCode {
  const u = String(level ?? 'NORMAL').trim().toUpperCase()
  if (u in LEVEL_I18N_KEY) {
    return u as StakingNodeLevelCode
  }
  return 'NORMAL'
}

export function stakingNodeLevelI18nKey(level: string | undefined | null): string {
  return LEVEL_I18N_KEY[normalizeStakingNodeLevel(level)] ?? LEVEL_I18N_KEY.NORMAL
}
