export interface DiffEntry {
  newContent: string
  oldContent: string
}

export interface DiffContents {
  [filePath: string]: DiffEntry // Key is the file path (e.g., "path/to/file.py")
}

export interface PrCommentFields {
  file_path?: string // Likely the main Python file being optimized
  speedup_x?: string
  loop_count?: number
  speedup_pct?: string
  best_runtime?: string
  report_table?: Record<string, { failed: number; passed: number }>
  function_name?: string // The Python function optimized
  original_runtime?: string
  benchmark_details?: any
  optimization_explanation?: string
}

export interface ExperimentMetadata {
  repo?: string
  type?: string
  owner?: string
  userId?: string
  pullNumber?: number
  diffContents?: DiffContents // This will contain the Python code diffs
  existingTests?: string
  generatedTests?: string
  prCommentFields?: PrCommentFields
  modifiedCode?: { [fileKey: string]: string } // Store modified code by file key
  lastModified?: string
  modifiedBy?: string
}

// This interface can be useful for the data fetched in page.tsx
export interface OptimizationFeatureData {
  experiment_metadata: ExperimentMetadata | null
  organization: string | null
  repository: string | null
  // include other fields you select from the optimization_features table
}
export interface GitHubUserSearchResult {
  username: string
  githubUserId: number
  avatarUrl: string
}

export type UserRole = "owner" | "admin" | "member"

export interface Member {
  id: string
  user_id: string
  username: string
  role: string
  added_at: Date
  avatarUrl: string
}

export const APP_ROUTES = {
  BASE: "/apikeys",
  API_KEYS: "/apikeys",
  DASHBOARD: "/dashboard",
  REVIEW_OPTIMIZATIONS: "/review-optimizations",
  REPOSITORIES: "/repositories",
  GETTING_STARTED: "/getting-started",
  BILLING: "/billing",
} satisfies Record<
  | "BASE"
  | "API_KEYS"
  | "DASHBOARD"
  | "REVIEW_OPTIMIZATIONS"
  | "REPOSITORIES"
  | "GETTING_STARTED"
  | "BILLING",
  string
>
