/**
 * ASPA Adoption Tracker - Type Definitions
 * BGP-ASPA (Autonomous System Provider Authorization) adoption tracking
 */

export interface ASPAObject {
  customer_asn: number
  provider_asn: number
  afi: number
}

export interface SamplingResult {
  asns: number[]
  totalSampled: number
  weightedByRegion: Record<string, number>
  timestamp: Date
}

export interface AdoptionSnapshot {
  asn: number
  hasASPA: boolean
  providers: number[]
  region: string
}

export interface RegionalStats {
  region: string
  totalASNs: number
  ASNsWithASPA: number
  coveragePercentage: number
  topNetworks: Array<{ asn: number; name: string; providers: number }>
}

export interface IXPStats {
  ixpId: number
  ixpName: string
  participantCount: number
  participantsWithASPA: number
  coveragePercentage: number
}

export interface ForecastData {
  predictedCoverage6m: number
  confidence: number
  trend: 'up' | 'down' | 'stable'
  trendStrength: number
}

export interface AdoptionStats {
  current: {
    coverage: number
    trend: 'up' | 'down' | 'stable'
    change24h: number
  }
  trend: Array<{
    date: string
    coveragePercentage: number
    sampledASNs: number
  }>
  forecast: ForecastData
  regions: RegionalStats[]
  topAdopters: Array<{
    asn: number
    name: string
    providers: number
  }>
}

export interface AdoptionHistoryRecord {
  id: number
  sampleDate: Date
  sampledAt: Date
  totalASNsSampled: number
  ASNsWithASPA: number
  coveragePercentage: number
  adoptionRateChange?: number
  topAdopters: Array<{ asn: number; name: string; providers: number }>
  regions: RegionalStats[]
  sampleMethod?: string
  metadata: Record<string, unknown>
}

export interface RegionalBreakdownRecord {
  id: number
  sampleDate: Date
  region: string
  totalASNs: number
  ASNsWithASPA: number
  coveragePercentage: number
  topNetworks: Array<{ asn: number; name: string; providers: number }>
}

export interface IXPBreakdownRecord {
  id: number
  sampleDate: Date
  ixpId: number
  ixpName: string
  participantCount: number
  participantsWithASPA: number
  coveragePercentage: number
}

export interface SamplerOptions {
  stratifiedByRegion: boolean
  minASNsPerRegion: number
  seed?: number
}

export interface CollectorOptions {
  maxRetries: number
  timeoutMs: number
  rateLimit: number
}

export interface AggregatorOptions {
  includeRegions: boolean
  includeIXPs: boolean
}

export interface ForecasterOptions {
  historyDays: number
  forecastMonths: number
  regressionAlpha: number
}
