import type { Component } from 'vue';
import type { ComponentType } from './types/index';

/**
 * Component list, register here to setting it in the form
 */
import {
  Input,
  Select,
  Radio,
  Checkbox,
  AutoComplete,
  Cascader,
  DatePicker,
  InputNumber,
  Switch,
  TimePicker,
  TreeSelect,
  Slider,
  Rate,
} from 'ant-design-vue';

import RadioButtonGroup from './components/RadioButtonGroup.vue';
import ApiSelect from './components/ApiSelect.vue';
import ApiTreeSelect from './components/ApiTreeSelect.vue';
import { BasicUpload } from '/@/components/Upload';
import { StrengthMeter } from '/@/components/StrengthMeter';
import { IconPicker } from '/@/components/Icon';
import { CountdownInput } from '/@/components/CountDown';
import ApiRadioGroup from './components/ApiRadioGroup.vue';
//自定义组件
import JAddInput from './externalCompns/components/JAddInput.vue';
import { JEasyCron } from './externalCompns/components/JEasyCron';
import ColorPicker from './components/ColorPicker.vue';
import IconDrawer from './components/IconDrawer.vue';
import ApiUpload from './components/ApiUpload.vue';
import ApiSearchSelect from './components/ApiSearchSelect.vue';
import CustomMinMaxInput from './externalCompns/components/CustomMinMaxInput.vue';
import StructForm from './externalCompns/components/StructForm/StructForm.vue';
import ApiSelectScrollLoad from './components/ApiSelectScrollLoad.vue';

const componentMap = new Map<ComponentType, Component>();

componentMap.set('Input', Input);
componentMap.set('InputGroup', Input.Group);
componentMap.set('InputPassword', Input.Password);
componentMap.set('InputSearch', Input.Search);
componentMap.set('InputTextArea', Input.TextArea);
componentMap.set('InputNumber', InputNumber);
componentMap.set('AutoComplete', AutoComplete);
componentMap.set('ApiRadioGroup', ApiRadioGroup);

componentMap.set('Select', Select);
componentMap.set('ApiSelect', ApiSelect);
componentMap.set('TreeSelect', TreeSelect);
componentMap.set('ApiTreeSelect', ApiTreeSelect);
componentMap.set('Switch', Switch);
componentMap.set('RadioButtonGroup', RadioButtonGroup);
componentMap.set('RadioGroup', Radio.Group);
componentMap.set('Checkbox', Checkbox);
componentMap.set('CheckboxGroup', Checkbox.Group);
componentMap.set('Cascader', Cascader);
componentMap.set('Slider', Slider);
componentMap.set('Rate', Rate);

componentMap.set('DatePicker', DatePicker);
componentMap.set('MonthPicker', DatePicker.MonthPicker);
componentMap.set('RangePicker', DatePicker.RangePicker);
componentMap.set('WeekPicker', DatePicker.WeekPicker);
componentMap.set('TimePicker', TimePicker);
componentMap.set('StrengthMeter', StrengthMeter);
componentMap.set('IconPicker', IconPicker);
componentMap.set('InputCountDown', CountdownInput);

componentMap.set('Upload', BasicUpload);
//注册自定义组件
componentMap.set('JAddInput', JAddInput);
componentMap.set('JEasyCron', JEasyCron);
componentMap.set('ColorPicker', ColorPicker);
componentMap.set('IconDrawer', IconDrawer);
componentMap.set('ApiUpload', ApiUpload);
componentMap.set('ApiSearchSelect', ApiSearchSelect);
componentMap.set('CustomMinMaxInput', CustomMinMaxInput);
componentMap.set('StructForm', StructForm);
componentMap.set('ApiSelectScrollLoad', ApiSelectScrollLoad);

export function add(compName: ComponentType, component: Component) {
  componentMap.set(compName, component);
}

export function del(compName: ComponentType) {
  componentMap.delete(compName);
}

export { componentMap };
