import { ControlType, ImplementationStatus } from '@/lib/sdk'

export type DisplayControlType = 'preventive' | 'detective' | 'corrective'
export type DisplayCategory = 'technical' | 'organizational' | 'physical'
export type DisplayStatus = 'implemented' | 'partial' | 'planned' | 'not-implemented'

export interface DisplayControl {
  id: string
  name: string
  description: string
  type: ControlType
  category: string
  implementationStatus: ImplementationStatus
  evidence: string[]
  owner: string | null
  dueDate: Date | null
  code: string
  displayType: DisplayControlType
  displayCategory: DisplayCategory
  displayStatus: DisplayStatus
  effectivenessPercent: number
  linkedRequirements: string[]
  linkedEvidence: { id: string; title: string; status: string }[]
  lastReview: Date
}

export interface RAGControlSuggestion {
  control_id: string
  domain: string
  title: string
  description: string
  pass_criteria: string
  implementation_guidance?: string
  is_automated: boolean
  automation_tool?: string
  priority: number
  confidence_score: number
}

export function mapControlTypeToDisplay(type: ControlType): DisplayCategory {
  switch (type) {
    case 'TECHNICAL': return 'technical'
    case 'ORGANIZATIONAL': return 'organizational'
    case 'PHYSICAL': return 'physical'
    default: return 'technical'
  }
}

export function mapStatusToDisplay(status: ImplementationStatus): DisplayStatus {
  switch (status) {
    case 'IMPLEMENTED': return 'implemented'
    case 'PARTIAL': return 'partial'
    case 'NOT_IMPLEMENTED': return 'not-implemented'
    default: return 'not-implemented'
  }
}
