/**
 * Project Dashboard Types
 *
 * Type definitions for project-related components.
 * These types will be updated when the API endpoints are implemented.
 *
 * @module components/projects/types
 */

// ============================================================================
// Project Types
// ============================================================================

/**
 * Matches backend: ProjectStatus enum in app/models/syndarix/enums.py
 */
export type ProjectStatus = 'active' | 'paused' | 'completed' | 'archived';

export type AutonomyLevel = 'full_control' | 'milestone' | 'autonomous';

export interface Project {
  id: string;
  name: string;
  description?: string;
  status: ProjectStatus;
  autonomy_level: AutonomyLevel;
  current_sprint_id?: string;
  created_at: string;
  updated_at?: string;
  owner_id: string;
}

// ============================================================================
// Agent Types
// ============================================================================

/**
 * Matches backend: AgentStatus enum in app/models/syndarix/enums.py
 */
export type AgentStatus = 'idle' | 'working' | 'waiting' | 'paused' | 'terminated';

export interface AgentInstance {
  id: string;
  agent_type_id: string;
  project_id: string;
  name: string;
  role: string;
  status: AgentStatus;
  current_task?: string;
  last_activity_at?: string;
  spawned_at: string;
  avatar?: string;
}

// ============================================================================
// Sprint Types
// ============================================================================

/**
 * Matches backend: SprintStatus enum in app/models/syndarix/enums.py
 */
export type SprintStatus = 'planned' | 'active' | 'in_review' | 'completed' | 'cancelled';

export interface Sprint {
  id: string;
  project_id: string;
  name: string;
  goal?: string;
  status: SprintStatus;
  start_date?: string;
  end_date?: string;
  total_issues: number;
  completed_issues: number;
  in_progress_issues: number;
  blocked_issues: number;
  todo_issues: number;
}

export interface BurndownDataPoint {
  day: number;
  date?: string;
  remaining: number;
  ideal: number;
}

// ============================================================================
// Issue Types
// ============================================================================

/**
 * Matches backend: IssueStatus enum in app/models/syndarix/enums.py
 */
export type IssueStatus = 'open' | 'in_progress' | 'in_review' | 'blocked' | 'closed';

export type IssuePriority = 'low' | 'medium' | 'high' | 'critical';

export interface Issue {
  id: string;
  project_id: string;
  sprint_id?: string;
  title: string;
  description?: string;
  status: IssueStatus;
  priority: IssuePriority;
  assignee_id?: string;
  created_at: string;
  updated_at?: string;
  labels?: string[];
}

export interface IssueCountSummary {
  open: number;
  in_progress: number;
  in_review: number;
  blocked: number;
  closed: number;
  total: number;
}

// ============================================================================
// Activity Types
// ============================================================================

export interface ActivityItem {
  id: string;
  type:
    | 'agent_message'
    | 'issue_update'
    | 'agent_status'
    | 'approval_request'
    | 'sprint_event'
    | 'system';
  agent?: string;
  message: string;
  timestamp: string;
  requires_action?: boolean;
  metadata?: Record<string, unknown>;
}
