import type { CouponStrategy } from "@/lib/api/predictions/types";

// ========================
// Request DTOs
// ========================

export interface CreateCouponDto {
  name?: string;
  items: CouponItemDto[];
  strategy?: CouponStrategy;
}

export interface CouponItemDto {
  matchId: string;
  matchName?: string;
  market: string;
  pick: string;
  odd: number;
}

export interface SuggestCouponDto {
  matchIds: string[];
  strategy?: CouponStrategy;
  maxMatches?: number;
  minConfidence?: number;
}

export interface AnalyzeMatchDto {
  matchIds: string[];
}

// ========================
// Response DTOs
// ========================

export interface CouponResponseDto {
  id: string;
  name?: string;
  items: CouponItemDto[];
  strategy?: CouponStrategy;
  totalOdd: number;
  createdAt: string;
  status?: string;
  [key: string]: unknown;
}

export interface CouponHistoryDto {
  coupons: CouponResponseDto[];
  total: number;
}

export interface UserBettingStatsDto {
  totalCoupons: number;
  totalBets: number;
  wonBets: number;
  lostBets: number;
  pendingBets: number;
  winRate: number;
  [key: string]: unknown;
}

export interface MatchAnalysisResultDto {
  matchId: string;
  analysis: Record<string, unknown>;
  predictions: Record<string, unknown>;
  [key: string]: unknown;
}

export interface DailyBankoResponseDto {
  picks: Array<{
    matchId: string;
    matchName: string;
    pick: string;
    confidence: number;
    odd: number;
    [key: string]: unknown;
  }>;
  totalOdd: number;
  [key: string]: unknown;
}

export interface SuggestedCouponBetDto {
  match_id: string;
  match_name: string;
  market: string;
  pick: string;
  probability: number;
  confidence: number;
  odds: number;
  risk_level: string;
  data_quality: string;
}

export interface SuggestedCouponRejectedMatchDto {
  match_id: string;
  reason: string;
  threshold?: number;
}

export interface SmartCouponResultDto {
  strategy: CouponStrategy;
  generated_at: string;
  match_count: number;
  bets: SuggestedCouponBetDto[];
  total_odds: number;
  expected_win_rate: number;
  rejected_matches: SuggestedCouponRejectedMatchDto[];
}

// ========================
// Frequency Engine DTOs
// ========================

export interface FrequencyCouponRequestDto {
  matchIds?: string[];
  maxMatches?: number;
  minSignal?: number;
  markets?: string[];
}

export interface FrequencyCouponBetDto {
  match_id: string;
  match_name: string;
  league: string;
  market: string;
  pick: string;
  home_signal: number;
  away_signal: number;
  combined_signal: number;
  league_profile: string;
  historical_hit_rate: number;
  odds: number;
  home_odds_band: string;
  away_odds_band: string;
  home_match_count: number;
  away_match_count: number;
}

export interface FrequencyCouponRejectedDto {
  match_id: string;
  match_name: string;
  reason: string;
}

export interface FrequencyCouponResultDto {
  strategy: "FREQUENCY";
  generated_at: string;
  bets: FrequencyCouponBetDto[];
  total_odds: number;
  expected_hit_rate: number;
  expected_value: number;
  ev_positive: boolean;
  reasoning: string[];
  rejected_matches: FrequencyCouponRejectedDto[];
}
