import type { DrawResultListItem } from "@/types/api/draw-results";

export type TicketItemListRow = {
  ticket_no: string;
  order_no: string | null | undefined;
  order_status?: string | null;
  draw_no: string | null | undefined;
  currency_code: string | null | undefined;
  play_code: string;
  original_number: string | null;
  total_bet_amount: number;
  actual_deduct_amount: number;
  status: string;
  win_amount: number;
  jackpot_win_amount: number;
  placed_at: string | null | undefined;
  updated_at: string | null | undefined;
};

export type TicketItemsListPayload = {
  items: TicketItemListRow[];
  total: number;
  page: number;
  per_page: number;
  last_page: number;
};

export type TicketItemCombinationRow = {
  combination_no: number;
  number_4d: string;
  bet_amount: number;
  estimated_payout: number;
};

export type TicketItemDetailPayload = {
  ticket_no: string;
  order_no: string | null | undefined;
  order_status?: string | null;
  draw_no: string | null | undefined;
  currency_code: string | null | undefined;
  play_code: string;
  dimension: number | null;
  digit_slot: number | null;
  original_number: string | null;
  normalized_number: string;
  unit_bet_amount: number;
  total_bet_amount: number;
  rebate_rate_snapshot: string;
  actual_deduct_amount: number;
  status: string;
  fail_reason_code?: string | null;
  fail_reason_text?: string | null;
  win_amount: number;
  jackpot_win_amount: number;
  settled_at: string | null | undefined;
  placed_at: string | null | undefined;
  odds_snapshot_json: unknown;
  combinations: TicketItemCombinationRow[];
  settlement: {
    matched_prize_tier: string | null;
    win_amount_minor: number;
    jackpot_allocation_minor: number;
  } | null;
  published_draw_results: DrawResultListItem | null;
};

export type TicketDrawMyMatchPayload = {
  draw_no: string;
  hit_numbers_4d: string[];
  total_win_minor: number;
  total_jackpot_win_minor: number;
  winning_ticket_count: number;
  has_bets: boolean;
};
