import { IExercise } from "./exercise-obj"
import { TTelemetryUrls } from "../managers/telemetry"

export type TGrading = "isolated" | "incremental" | "no-grading"

export type TMode = "preview" | "extension"

export type TConfigAction = "test" | "build" | "tutorial" | "reset" | "generate"

export type TConfigObjAttributes = "config" | "exercises" | "grading"

export type TCompiler =
  | "webpack"
  | "vanillajs"
  | "react"
  | "html"
  | "node"
  | "python"
  | "css"

export interface IConfigPath {
  base: string
}

export interface IEditor {
  mode?: TMode
  version?: string
  agent?: TAgent
  hideTerminal?: boolean
}

export interface TEntries {
  python3?: string
  html?: string
  node?: string
  react?: string
  java?: string
}

export interface IConfig {
  os: string
  port?: string
  repository?: string
  description?: string
  slug?: string
  dirPath: string
  preview?: string // Picture thumbnail
  entries: TEntries
  grading: TGrading
  configPath: string
  translations: Array<string>
  outputPath?: string
  editor: IEditor
  language: string
  title: string
  duration: number
  difficulty?: string
  exercisesPath: string
  disableGrading: boolean // TODO: Deprecate
  actions: Array<string> // TODO: Deprecate
  autoPlay: boolean
  projectType?: string
  // TODO: nameExerciseValidation
  contact?: string
  disabledActions?: Array<TConfigAction>
  compiler: TCompiler
  compilers: Array<TCompiler>
  publicPath: string
  publicUrl?: string
  bugsLink?: string
  videoSolutions?: boolean
  skills: Array<string>
  telemetry?: TTelemetryUrls
  variables?: TVariables
  suggestions: TSuggestions
  warnings: TWarnings
  runHook: (...agrs: Array<any>) => void
  testingFinishedCallback: (arg: any | undefined) => void
}
export type TAgent = "os" | "vscode" | null

export type TSuggestions = {
  agent: TAgent
}

type TWarnings = {
  agent?: string
  extension?: string
}

type TVariable = {
  type: "command" | "string"
  source: string
}
type TVariables = {
  [key: string]: TVariable | string
}

export interface IConfigObj {
  session?: number
  currentExercise?: any
  config?: IConfig
  exercises?: Array<IExercise>
  confPath?: IConfigPath
  address?: string // Maybe
}
