import type { App } from 'vue'

import dataFnsGenerateConfig from '../vc-picker/generate/dateFns'
import type {
  RangePickerProps as BaseRangePickerProps,
  PickerDateProps,
  PickerProps,
} from './generatePicker'
import generatePicker from './generatePicker'
import type { ExtraDatePickerProps, ExtraRangePickerProps } from './generatePicker/props'

export type DatePickerProps = PickerProps<Date> & ExtraDatePickerProps<Date>
export type MonthPickerProps = Omit<PickerDateProps<Date>, 'picker'> & ExtraDatePickerProps<Date>
export type WeekPickerProps = Omit<PickerDateProps<Date>, 'picker'> & ExtraDatePickerProps<Date>
export type RangePickerProps = BaseRangePickerProps<Date> & ExtraRangePickerProps<Date>

const { DatePicker, WeekPicker, MonthPicker, YearPicker, TimePicker, QuarterPicker, RangePicker } =
  generatePicker<Date>(dataFnsGenerateConfig)

/* istanbul ignore next */
export { MonthPicker, QuarterPicker, RangePicker, WeekPicker }

export default Object.assign(DatePicker, {
  WeekPicker,
  MonthPicker,
  YearPicker,
  RangePicker,
  TimePicker,
  QuarterPicker,
  install: (app: App) => {
    app.component(DatePicker.name, DatePicker)
    app.component(RangePicker.name, RangePicker)
    app.component(MonthPicker.name, MonthPicker)
    app.component(WeekPicker.name, WeekPicker)
    app.component(QuarterPicker.name, QuarterPicker)
    return app
  },
})
