/**
 * 下注业务码与玩家可见说明（对齐 Laravel `ErrorCode` 与产品文档 §6.3 / §6.4）。
 */
export function mapTicketBetError(
  code: number,
  fallbackMsg: string,
  t?: (key: string) => string,
): string {
  const msg = (key: string, fallback: string) => t?.(key) ?? fallback;
  switch (code) {
    case 4001:
      return msg(
        "hall.ticketError.4001",
        "该号码本期赔付池不足，已售罄。请更换号码、金额或玩法后重试。",
      );
    case 2003:
    case 1001:
      return msg("hall.ticketError.1001", "余额不足，请先转入后再下注。");
    case 2001:
      return msg("hall.ticketError.2001", "本期已封盘，无法继续下注。");
    case 2002:
      return msg("hall.ticketError.2002", "该玩法已关闭，请选择其他玩法。");
    case 2004:
      return msg("hall.ticketError.2004", "号码格式或长度不符合该玩法要求。");
    case 2005:
      return msg(
        "hall.ticketError.2005",
        "玩法参数不完整（如单双大小需选择位数与维度）。",
      );
    case 2006:
      return msg("hall.ticketError.2006", "期号无效或已切换，请刷新大厅后重试。");
    case 2007:
      return msg("hall.ticketError.2007", "该玩法暂不支持或缺少赔率配置。");
    case 2008:
      return msg(
        "hall.ticketError.2008",
        "赔率或玩法配置已更新，请关闭预览后重新操作。",
      );
    case 2009:
      return msg(
        "hall.ticketError.2009",
        "该订单已退款或不可重复提交，请关闭预览后重新下注。",
      );
    case 1007:
      return msg("hall.ticketError.1007", "彩票钱包已冻结，暂无法下注。");
    case 1003:
      return msg("hall.ticketError.1003", "下注金额超出该玩法允许范围。");
    default:
      return fallbackMsg || msg("hall.ticketError.fallback", "下注失败，请稍后重试。");
  }
}
