export type QuestionType =
  | 'single_choice'
  | 'multiple_choice'
  | 'rating'
  | 'text_long'
  | 'text_short'
  | 'section'

export interface QuestionOption {
  value: string
  label: string
}

export interface RatingOptions {
  min: number
  max: number
  min_label: string
  max_label: string
}

export interface ConditionalRule {
  if_question: string
  op: 'eq'
  value: string
  action: 'show'
}

export interface Question {
  id: string
  survey_id: string
  code: string
  type: QuestionType
  prompt: string
  position: number
  is_sensitive: boolean
  required: boolean
  max_select: number | null
  options: QuestionOption[] | RatingOptions | null
  conditional_rules: ConditionalRule[] | null
}

export interface Survey {
  id: string
  title: string
  status: string
  is_anonymous: boolean
  k_threshold: number
  questions: Question[]
}

// Answers keyed by question code
export type FormAnswers = Record<string, string | string[] | number | null>
