/**
 * TypeScript types for the assessment frontend.
 */

// Rater types
export interface Rater {
  rater_id: string;
  name: string | null;
  created_at?: string;
}

export interface RaterCreate {
  rater_id: string;
  name?: string;
}

// Query types
export interface QueryInfo {
  query_id: string;
  query_text: string;
  category: string;
  idea_count: number;
}

export interface IdeaForRating {
  idea_id: string;
  text: string;
  index: number;
}

export interface QueryWithIdeas {
  query_id: string;
  query_text: string;
  category: string;
  ideas: IdeaForRating[];
  total_count: number;
}

// Rating types
export interface RatingSubmit {
  rater_id: string;
  idea_id: string;
  query_id: string;
  originality: number | null;
  elaboration: number | null;
  coherence: number | null;
  usefulness: number | null;
  skipped: boolean;
}

export interface Rating {
  id: number;
  rater_id: string;
  idea_id: string;
  query_id: string;
  originality: number | null;
  elaboration: number | null;
  coherence: number | null;
  usefulness: number | null;
  skipped: number;
  timestamp: string | null;
}

// Progress types
export interface QueryProgress {
  rater_id: string;
  query_id: string;
  completed_count: number;
  total_count: number;
  started_at?: string;
  updated_at?: string;
}

export interface RaterProgress {
  rater_id: string;
  queries: QueryProgress[];
  total_completed: number;
  total_ideas: number;
  percentage: number;
}

// Statistics types
export interface Statistics {
  rater_count: number;
  rating_count: number;
  skip_count: number;
  rated_ideas: number;
}

// Dimension definition types
export interface DimensionScale {
  1: string;
  2: string;
  3: string;
  4: string;
  5: string;
}

export interface DimensionDefinition {
  name: string;
  question: string;
  scale: DimensionScale;
  low_label: string;
  high_label: string;
}

export interface DimensionDefinitions {
  originality: DimensionDefinition;
  elaboration: DimensionDefinition;
  coherence: DimensionDefinition;
  usefulness: DimensionDefinition;
}

// Session info
export interface SessionInfo {
  experiment_id: string;
  total_ideas: number;
  query_count: number;
  conditions: string[];
  randomization_seed: number;
}

// UI State types
export type AppView = 'login' | 'instructions' | 'assessment' | 'completion';

export interface RatingState {
  originality: number | null;
  elaboration: number | null;
  coherence: number | null;
  usefulness: number | null;
}

export const EMPTY_RATING_STATE: RatingState = {
  originality: null,
  elaboration: null,
  coherence: null,
  usefulness: null,
};

export type DimensionKey = keyof RatingState;

export const DIMENSION_KEYS: DimensionKey[] = ['originality', 'elaboration', 'coherence', 'usefulness'];
