export interface LocalizedText {
  ru: string
  en: string
}

export interface Config {
  label: LocalizedText
  categories: string[]
  icon: string
  preview?: string
  version: string
}

////////////////////////

export enum ColumnType {
  String = 'string',
  Number = 'number',
  Date = 'date',
}

export enum DataQueryFunction {
  Group = 'group',
  Sum = 'sum',
  Avg = 'avg',
  Count = 'count',
}

export enum BlockIcon {
  AxisX = 'sys:axis-x',
  AxisY = 'sys:axis-y',
}

export interface DataBlock {
  key: string
  queryFn: DataQueryFunction
  label: LocalizedText
  icon?: BlockIcon
  columnTypes: ColumnType[]
  limit?: number
}

export type DataOptions = DataBlock[]
export type CreateDataOptions = () => DataOptions

////////////////////////

export interface ViewOptionBase {
  key: string
  label: LocalizedText
  defaultValue?: any
}

export interface CheckboxOption extends ViewOptionBase {
  element: 'checkbox'
}

export interface SelectItem {
  label: LocalizedText
  value: string
}

export interface SelectOption extends ViewOptionBase {
  element: 'select'
  options: SelectItem[]
}

export interface InputOption extends ViewOptionBase {
  element: 'input'
}

export interface GroupOption {
  key: string
  label: LocalizedText
  defaultOpen: boolean
  children: ViewOption[]
}

export type ViewOption = CheckboxOption | SelectOption | InputOption
export type ViewOptions = Array<ViewOption | GroupOption>
export type CreateViewOptions = () => ViewOptions

////////////////////////

export interface ComponentProps {
  dataOptions: DataOptions
  viewOptions: ViewOptions
}
