// Shared types moved from hooks like `useTradeLineItems`

export interface ClaimCode {
  id: number;
  tcp_name: string;
  tu_code: string;
  ex_code: string;
  eq_code: string;
  is_active: boolean;
  created_at: string;
  updated_at: string;
}

export interface Dispute {
  id: number;
  dispute_id: string;
  claim_code: ClaimCode;
  vendor: string[];
  bureau: string;
  created_at: number;
  updated_at: number;
  custom_data: string[];
}

export interface DisputesProps {
  id: number;
  type: string;
  title: string;
  reason: string;
  status: string;
  tcpStatus: string;
  disputes?: Dispute[];
  account_number?: string;
  credit_balance?: number;
  unpaid_balance_amount?: number;
  account_type?: string;
  credit_loan_type?: string;
  account_ownership_type?: string;
  past_due_amount?: number;
  high_credit_amount?: number;
  high_balance_amount?: number;
  tradeline_status?: string;
  opened_date?: string;
  reported_date?: string;
  last_payment_date?: string;

  processed_status?: string;
  original_balance_amount?: number;
  is_negative?: boolean;
}

// Types for tradeline API response
export interface TradelineClientAttributes {
  Id: string;
  FirstName: string;
  MiddleName: string;
  LastName: string;
  Email: string;
}

export interface TradelineSegmentRule {
  field: string;
  count_repeat: number;
  relation: string;
  operator: string;
  value: string;
}

export interface TradelineSegmentConditions {
  combinator: 'AND' | 'OR' | string;
  not: number;
  count_repeat: number;
  relation: string;
  rules: TradelineSegmentRule[];
}

export interface TradelineSegments {
  id: number;
  type: string;
  name: string;
  description: string;
  conditions: TradelineSegmentConditions;
  is_active: boolean;
  is_archive: boolean;
  clients_count: number;
  tradelines_count: number;
  usage_count: number;
  created_at: string; // ISO datetime
  updated_at: string; // ISO datetime
}

export interface TradelineClient {
  id: number;
  salesforce_id: number;
  ssn: number;
  email: string;
  mobile_phone: string;
  joint_customer_sf_id: string;
  client_key: string;
  attributes: TradelineClientAttributes;
  segments: TradelineSegments;
}

export interface TradelineCreditReport {
  id: number;
  report_id: number;
  report_type_id: number;
  vendor_id: number;
  bureau_id: number;
  client_key: string;
  internal_client_key: number;
  bureau_report_id: string;
  vendor_report_id: string;
  report_date: string;
  customer_bureau_id: string;
  customer_first_name: string;
  customer_last_name: string;
  customer_other_name: string;
  customer_ssn: string;
  customer_birth_date: string;
  customer_addr_street: string;
  customer_addr_city: string;
  customer_addr_state: string;
  customer_add_zip: string;
  customer_addr_type: string;
  customer_home_phone: string;
  customer_mobile_phone: string;
  is_first_credit_report: boolean;
  tradeline_items_nbr: number;
  negative_items_nbr: number;
  positive_items_nbr: number;
  hard_inquiry_nbr: number;
  soft_inquiry_nbr: number;
  credit_utilization_per: number;
  credit_card_num: number;
  outstanding_balance: number;
  available_credit: number;
  monthly_payments: number;
  dilingquent_account: number;
  close_account: number;
  open_account: number;
  modified_date: string; // date
}

export interface TradelineCreditor {
  creditor_id: number;
  report_id: number;
  internal_client_key: number;
  creditor_group_id: string;
  creditor_bureau_id: string;
  creditor_name: string;
  creditor_addr_street: string;
  creditor_addr_city: string;
  creditor_addr_state: string;
  creditor_addr_zip: string;
  creditor_phone: string;
  creditor_business_type_id: string;
  creditor_contact: string;
  raw_industry_code: string;
  raw_industry_text: string;
  is_active: boolean;
  modified_date: string; // date
}

export interface TradelineDisputeClaimCode {
  id: number;
  tcp_name: string;
  tu_code: string;
  ex_code: string;
  eq_code: string;
  is_active: boolean;
  created_at: string; // ISO datetime
  updated_at: string; // ISO datetime
}

export interface TradelineDisputeItem {
  id: number;
  dispute_id: string;
  claim_code: TradelineDisputeClaimCode;
  vendor: unknown; // example shows "array"; keeping as unknown
  bureau: string; // e.g., 'transunion'
  created_at: number;
  updated_at: number;
  custom_data: string[];
}

export interface TradelineItem {
  tradeline_id: number;
  report_id: number;
  internal_client_key: number;
  tradeline_status: string;
  tradeline_type: string;
  bureau_tradeline_id: string;
  vendor_tradeline_id: string;
  creditor_id: number;
  original_creditor_id: string;
  account_number: string;
  account_name: string;
  account_type: string;
  account_status: string;
  opened_date: string;
  close_date: string;
  reported_date: string;
  credit_loan_type: string;
  account_ownership_type: string;
  terms_desc: string;
  terms_month: string;
  months_viewed: string;
  original_balance_amount: number;
  unpaid_balance_amount: number;
  credit_limit: number;
  credit_balance: number;
  past_due_amount: number;
  monthly_payment: number;
  high_balance_amount: number;
  high_credit_amount: number;
  charge_off_date: string;
  collection_date: string;
  account_paid_date: string;
  last_payment_date: string;
  last_activity_date: string;
  late_count_30_days: number;
  late_count_60_days: number;
  late_count_90_days: number;
  is_negative: boolean;
  is_hard_inquiry: boolean;
  is_soft_inquiry: boolean;
  is_mortgage: boolean;
  is_collection: boolean;
  is_charge_off: boolean;
  is_revolving: boolean;
  is_secure_loan: boolean;
  is_disputed: boolean;
  is_closed: boolean;
  current_rateing_code: string;
  current_rating_type: string;
  highest_adverse_rating_code: string;
  highest_adverse_rating_type: string;
  most_recent_adverse_rating_code: string;
  most_recent_adverse_rating_type: string;
  most_recent_adverse_rating_date: string;
  prior_tradeline_id: string;
  modified_date: string;
  tradeline_md5: string;
  tradeline_sub_type: string;
  tradeline_source: string;
  dispute_handler: string;
  attorney_name: string;
  court_name: string;
  credit_trade_reference_id: string;
  disposition_date: string;
  disposition_type: string;
  settled_date: string;
  created_date: string;
  client: TradelineClient;
  creditReport: TradelineCreditReport;
  creditor: TradelineCreditor;
  metadata: { status: string; not_dispute: boolean };
  disputes: Dispute[];
}

export interface TradelineListResponse {
  data: TradelineItem[];
  links?: { first: string; last: string; prev: string; next: string };
  meta?: {
    current_page: number;
    from: number;
    last_page: number;
    links: Array<{
      url: string | null;
      label: string;
      active: boolean;
    }>;
    path: string;
    per_page: number;
    to: number;
    total: number;
  };
  totalCounts?: Array<{
    value: string;
    total: number;
  }>;
}

export interface AttestationOption {
  id: number;
  value: string;
  type: string;
}

export interface AttestationOptionsResponse {
  data: AttestationOption[];
}
