// User & Auth
export enum UserType {
  PLAYER = 'PLAYER',
  AGENT = 'AGENT',
  ADMIN = 'ADMIN',
}

export enum UserStatus {
  ACTIVE = 'ACTIVE',
  DISABLED = 'DISABLED',
  LOCKED = 'LOCKED',
}

/** Minimum agent tier (root agents). Actual levels are unbounded integers when `agent.max_level` is 0. */
export const MIN_AGENT_LEVEL = 1;

/**
 * Legacy enum for the original two-tier demo. Production code should use numeric `agentLevel` / `AgentProfile.level`.
 */
export enum AgentLevel {
  LEVEL_1 = 1,
  LEVEL_2 = 2,
}

// Match
export enum MatchStatus {
  DRAFT = 'DRAFT',
  PUBLISHED = 'PUBLISHED',
  CLOSED = 'CLOSED',
  PENDING_SETTLEMENT = 'PENDING_SETTLEMENT',
  SETTLED = 'SETTLED',
  CANCELLED = 'CANCELLED',
  VOID = 'VOID',
}

export enum MarketStatus {
  OPEN = 'OPEN',
  SUSPENDED = 'SUSPENDED',
  CLOSED = 'CLOSED',
}

export enum MarketType {
  FT_CORRECT_SCORE = 'FT_CORRECT_SCORE',
  HT_CORRECT_SCORE = 'HT_CORRECT_SCORE',
  SH_CORRECT_SCORE = 'SH_CORRECT_SCORE',
  FT_HANDICAP = 'FT_HANDICAP',
  FT_OVER_UNDER = 'FT_OVER_UNDER',
  FT_1X2 = 'FT_1X2',
  FT_ODD_EVEN = 'FT_ODD_EVEN',
  HT_HANDICAP = 'HT_HANDICAP',
  HT_OVER_UNDER = 'HT_OVER_UNDER',
  HT_1X2 = 'HT_1X2',
  OUTRIGHT_WINNER = 'OUTRIGHT_WINNER',
}

export enum Period {
  FT = 'FT',
  HT = 'HT',
  SH = 'SH',
  OUTRIGHT = 'OUTRIGHT',
}

// Bet
export enum BetType {
  SINGLE = 'SINGLE',
  PARLAY = 'PARLAY',
}

export enum BetStatus {
  PENDING = 'PENDING',
  WON = 'WON',
  LOST = 'LOST',
  PUSH = 'PUSH',
  VOID = 'VOID',
  CANCELLED = 'CANCELLED',
  SETTLED = 'SETTLED',
}

export enum SelectionResult {
  WIN = 'WIN',
  HALF_WIN = 'HALF_WIN',
  PUSH = 'PUSH',
  HALF_LOSE = 'HALF_LOSE',
  LOSE = 'LOSE',
  VOID = 'VOID',
}

// Wallet
export enum WalletTransactionType {
  MANUAL_DEPOSIT = 'MANUAL_DEPOSIT',
  MANUAL_WITHDRAW = 'MANUAL_WITHDRAW',
  BET_FREEZE = 'BET_FREEZE',
  BET_SETTLE_WIN = 'BET_SETTLE_WIN',
  BET_SETTLE_LOSE = 'BET_SETTLE_LOSE',
  BET_SETTLE_PUSH = 'BET_SETTLE_PUSH',
  BET_VOID_REFUND = 'BET_VOID_REFUND',
  CASHBACK = 'CASHBACK',
  RESETTLE_REVERSE = 'RESETTLE_REVERSE',
  MANUAL_ADJUST = 'MANUAL_ADJUST',
}

export enum WalletStatus {
  ACTIVE = 'ACTIVE',
  FROZEN = 'FROZEN',
  DISABLED = 'DISABLED',
}

// Locale
export const SUPPORTED_LOCALES = ['zh-CN', 'ms-MY', 'en-US'] as const;
export type Locale = (typeof SUPPORTED_LOCALES)[number];
export const DEFAULT_LOCALE: Locale = 'zh-CN';

// Admin roles
export enum AdminRole {
  SUPER_ADMIN = 'SUPER_ADMIN',
  MATCH_ADMIN = 'MATCH_ADMIN',
  FINANCE_ADMIN = 'FINANCE_ADMIN',
  SUPPORT = 'SUPPORT',
}

export const PARLAY_MIN_LEGS = 2;
export const PARLAY_MAX_LEGS = 5;

export * from './betting-rules';
export * from './market-catalog';
export * from './locale';
export * from './builtinPlayers';
export * from './playerLocale';
export * from './playerUsername';
export * from './initial-depositRemark';
export * from './phone-countries';
export * from './match-time';

export interface ApiResponse<T = unknown> {
  success: boolean;
  data?: T;
  message?: string;
  error?: string;
  code?: string;
  params?: Record<string, string | number> | null;
}

export * from './api-errors';
