import {
  TextComponent1Config,
  TextComponent3Config,
  TextComponent4Config,
  TextComponent5Config,
  TextComponentDefaultConfig,
  transformTextComponentConfig,
} from './TextComponent/config';
import { ComponentInfo } from '/@/api/dataBoard/model';
import { transformPictureConfig } from './PictureComponent/pictureComponent.config';
import {
  DashboardComponentLayout,
  Instrument1DefaultConfig,
  Instrument2DefaultConfig,
  instrumentComponent1,
  instrumentComponent2,
  transformDashboardComponentConfig,
} from './InstrumentComponent/dashBoardComponent.config';
import { DigitalComponentDefaultConfig } from './InstrumentComponent/digitalDashBoard.config';
import {
  ControlComponentDefaultConfig,
  transformControlConfig,
} from './ControlComponent/control.config';

import TextComponent from './TextComponent/TextComponent.vue';
import DashBoardComponent from './InstrumentComponent/DashBoardComponent.vue';
import PictureComponent from './PictureComponent/PictureComponent.vue';
import DigitalDashBoard from './InstrumentComponent/DigitalDashBoard.vue';
import ToggleSwitch from './ControlComponent/ToggleSwitch.vue';
import SlidingSwitch from './ControlComponent/SlidingSwitch.vue';
import SwitchWithIcon from './ControlComponent/SwitchWithIcon.vue';
import MapComponent from './MapComponent/MapComponent.vue';
import {
  MaphistoryTrackConfig,
  MapRealTrackConfig,
  transfromMapComponentConfig,
} from './MapComponent/map.config';
import { ComponentConfig } from '../types/type';
import { FrontComponent, FrontComponentCategory } from '../const/const';

export const frontComponentDefaultConfigMap = new Map<FrontComponent, Partial<ComponentInfo>>();

export const frontComponentMap = new Map<FrontComponent, ComponentConfig>();

frontComponentMap.set(FrontComponent.TEXT_COMPONENT_1, {
  Component: TextComponent,
  ComponentName: '文本组件1',
  ComponentKey: FrontComponent.TEXT_COMPONENT_1,
  ComponentConfig: TextComponent1Config,
  ComponentCategory: FrontComponentCategory.TEXT,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: true,
  transformConfig: transformTextComponentConfig,
});

frontComponentMap.set(FrontComponent.TEXT_COMPONENT_3, {
  Component: TextComponent,
  ComponentName: '文本组件2',
  ComponentKey: FrontComponent.TEXT_COMPONENT_3,
  ComponentConfig: TextComponent3Config,
  ComponentCategory: FrontComponentCategory.TEXT,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: true,
  transformConfig: transformTextComponentConfig,
});

frontComponentMap.set(FrontComponent.TEXT_COMPONENT_4, {
  Component: TextComponent,
  ComponentName: '文本组件3',
  ComponentKey: FrontComponent.TEXT_COMPONENT_4,
  ComponentConfig: TextComponent4Config,
  ComponentCategory: FrontComponentCategory.TEXT,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: true,
  transformConfig: transformTextComponentConfig,
});

frontComponentMap.set(FrontComponent.TEXT_COMPONENT_5, {
  Component: TextComponent,
  ComponentName: '文本组件4',
  ComponentKey: FrontComponent.TEXT_COMPONENT_5,
  ComponentConfig: TextComponent5Config,
  ComponentCategory: FrontComponentCategory.TEXT,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: true,
  transformConfig: transformTextComponentConfig,
});

frontComponentMap.set(FrontComponent.INSTRUMENT_COMPONENT_1, {
  Component: DashBoardComponent,
  ComponentName: '仪表盘',
  ComponentKey: FrontComponent.INSTRUMENT_COMPONENT_1,
  ComponentConfig: {
    chartOption: instrumentComponent1(Instrument1DefaultConfig),
    componentType: FrontComponent.INSTRUMENT_COMPONENT_1,
  } as DashboardComponentLayout,
  ComponentCategory: FrontComponentCategory.INSTRUMENT,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: true,
  transformConfig: transformDashboardComponentConfig,
});

frontComponentMap.set(FrontComponent.INSTRUMENT_COMPONENT_2, {
  Component: DashBoardComponent,
  ComponentName: '阶段仪表盘',
  ComponentKey: FrontComponent.INSTRUMENT_COMPONENT_2,
  ComponentConfig: {
    chartOption: instrumentComponent2(Instrument2DefaultConfig),
    componentType: FrontComponent.INSTRUMENT_COMPONENT_2,
  } as DashboardComponentLayout,
  ComponentCategory: FrontComponentCategory.INSTRUMENT,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: true,
  transformConfig: transformDashboardComponentConfig,
});

frontComponentMap.set(FrontComponent.DIGITAL_DASHBOARD_COMPONENT, {
  Component: DigitalDashBoard,
  ComponentName: '数字仪表盘',
  ComponentKey: FrontComponent.DIGITAL_DASHBOARD_COMPONENT,
  ComponentCategory: FrontComponentCategory.INSTRUMENT,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: true,
  transformConfig: transformDashboardComponentConfig,
});

frontComponentMap.set(FrontComponent.PICTURE_COMPONENT_1, {
  Component: PictureComponent,
  ComponentName: '图片组件',
  ComponentKey: FrontComponent.PICTURE_COMPONENT_1,
  ComponentCategory: FrontComponentCategory.PICTURE,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: false,
  transformConfig: transformPictureConfig,
});

frontComponentMap.set(FrontComponent.CONTROL_COMPONENT_SWITCH_WITH_ICON, {
  Component: SwitchWithIcon,
  ComponentName: '控制按钮1',
  ComponentKey: FrontComponent.CONTROL_COMPONENT_SWITCH_WITH_ICON,
  ComponentCategory: FrontComponentCategory.CONTROL,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: true,
  transformConfig: transformControlConfig,
});

frontComponentMap.set(FrontComponent.CONTROL_COMPONENT_SLIDING_SWITCH, {
  Component: SlidingSwitch,
  ComponentName: '控制按钮2',
  ComponentKey: FrontComponent.CONTROL_COMPONENT_SLIDING_SWITCH,
  ComponentCategory: FrontComponentCategory.CONTROL,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: false,
  transformConfig: transformControlConfig,
});

frontComponentMap.set(FrontComponent.CONTROL_COMPONENT_TOGGLE_SWITCH, {
  Component: ToggleSwitch,
  ComponentName: '控制按钮3',
  ComponentKey: FrontComponent.CONTROL_COMPONENT_TOGGLE_SWITCH,
  ComponentCategory: FrontComponentCategory.CONTROL,
  isMultipleDataSource: false,
  hasHistoryTrend: true,
  hasSetting: false,
  transformConfig: transformControlConfig,
});

frontComponentMap.set(FrontComponent.MAP_COMPONENT_TRACK_REAL, {
  Component: MapComponent,
  ComponentName: '实时轨迹',
  ComponentKey: FrontComponent.MAP_COMPONENT_TRACK_REAL,
  ComponentConfig: MapRealTrackConfig,
  ComponentCategory: FrontComponentCategory.MAP,
  isMultipleDataSource: true,
  hasHistoryTrend: false,
  hasSetting: false,
  transformConfig: transfromMapComponentConfig,
});

frontComponentMap.set(FrontComponent.MAP_COMPONENT_TRACK_HISTORY, {
  Component: MapComponent,
  ComponentName: '历史轨迹',
  ComponentKey: FrontComponent.MAP_COMPONENT_TRACK_HISTORY,
  ComponentConfig: MaphistoryTrackConfig,
  ComponentCategory: FrontComponentCategory.MAP,
  isMultipleDataSource: true,
  hasHistoryTrend: false,
  hasSetting: false,
  transformConfig: transfromMapComponentConfig,
});

frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_1, TextComponentDefaultConfig);
frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_3, TextComponentDefaultConfig);
frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_4, TextComponentDefaultConfig);
frontComponentDefaultConfigMap.set(FrontComponent.TEXT_COMPONENT_5, TextComponentDefaultConfig);

frontComponentDefaultConfigMap.set(FrontComponent.INSTRUMENT_COMPONENT_1, Instrument1DefaultConfig);
frontComponentDefaultConfigMap.set(FrontComponent.INSTRUMENT_COMPONENT_2, Instrument2DefaultConfig);

frontComponentDefaultConfigMap.set(
  FrontComponent.DIGITAL_DASHBOARD_COMPONENT,
  DigitalComponentDefaultConfig
);

frontComponentDefaultConfigMap.set(
  FrontComponent.CONTROL_COMPONENT_SWITCH_WITH_ICON,
  ControlComponentDefaultConfig
);

export const getComponentDefaultConfig = (key: FrontComponent) => {
  return frontComponentDefaultConfigMap.get(key) || {};
};
