export interface CrawlQueueItem {
  id: string
  university_id: string
  university_name: string
  university_short: string
  queue_position: number | null
  priority: number
  current_phase: CrawlPhase
  discovery_completed: boolean
  discovery_completed_at?: string
  professors_completed: boolean
  professors_completed_at?: string
  all_staff_completed: boolean
  all_staff_completed_at?: string
  publications_completed: boolean
  publications_completed_at?: string
  discovery_count: number
  professors_count: number
  staff_count: number
  publications_count: number
  retry_count: number
  max_retries: number
  last_error?: string
  started_at?: string
  completed_at?: string
  progress_percent: number
  created_at: string
  updated_at: string
}

export type CrawlPhase = 'pending' | 'discovery' | 'professors' | 'all_staff' | 'publications' | 'completed' | 'failed' | 'paused'

export interface OrchestratorStatus {
  is_running: boolean
  current_university?: CrawlQueueItem
  current_phase: CrawlPhase
  queue_length: number
  completed_today: number
  total_processed: number
  last_activity?: string
}

export interface University {
  id: string
  name: string
  short_name?: string
  url: string
  state?: string
  uni_type?: string
}

export const API_BASE = '/api/admin/uni-crawler'

export const phaseConfig: Record<CrawlPhase, { label: string; color: string; icon: string }> = {
  pending: { label: 'Wartend', color: 'bg-gray-100 text-gray-700', icon: 'clock' },
  discovery: { label: 'Discovery', color: 'bg-blue-100 text-blue-700', icon: 'search' },
  professors: { label: 'Professoren', color: 'bg-indigo-100 text-indigo-700', icon: 'user' },
  all_staff: { label: 'Alle Mitarbeiter', color: 'bg-purple-100 text-purple-700', icon: 'users' },
  publications: { label: 'Publikationen', color: 'bg-orange-100 text-orange-700', icon: 'book' },
  completed: { label: 'Abgeschlossen', color: 'bg-green-100 text-green-700', icon: 'check' },
  failed: { label: 'Fehlgeschlagen', color: 'bg-red-100 text-red-700', icon: 'x' },
  paused: { label: 'Pausiert', color: 'bg-yellow-100 text-yellow-700', icon: 'pause' }
}
