import React from "react";
import ButtonWidget from "../Widgets/Standard/Button";
import TextBoxWidget from "../Widgets/Standard/TextBox";
import TextAreaWidget from "../Widgets/Standard/TextArea";
import TextEditorWidget from "../Widgets/Standard/Editor";
import HtmlWidget from "../Widgets/Standard/Html";
import DropDownWidget from "../Widgets/Standard/Dropdown";
import GridWidget from "../Widgets/Standard/Grid";
import CardGridWidget from "../Widgets/Standard/CardGrid";
import DateWidget from "../Widgets/Standard/Date";
import IconWidget from "../Widgets/Standard/Icon";
import { WidgetTypes } from "../constant";
import Label from "../Widgets/Standard/Label";
import Checkbox from "../Widgets/Standard/Checkbox";

class WidgetFactory {
  private static factory: WidgetFactory;
  private widgetMap = new Map<string, React.FC<any>>();

  private constructor() {
    this.createWidgetMap();
  }

  static get() {
    if (!WidgetFactory.factory) {
      WidgetFactory.factory = new WidgetFactory();
    }
    return WidgetFactory.factory;
  }

  private createWidgetMap(): void {
    this.widgetMap.set(WidgetTypes.BUTTON, ButtonWidget);
    this.widgetMap.set(WidgetTypes.TEXTBOX, TextBoxWidget);
    this.widgetMap.set(WidgetTypes.TEXTAREA, TextAreaWidget);
    this.widgetMap.set(WidgetTypes.TEXTEDITOR, TextEditorWidget);
    this.widgetMap.set(WidgetTypes.HTML, HtmlWidget);
    this.widgetMap.set(WidgetTypes.DROPDOWN, DropDownWidget);
    this.widgetMap.set(WidgetTypes.GRID, GridWidget);
    this.widgetMap.set(WidgetTypes.CARD, CardGridWidget);
    this.widgetMap.set(WidgetTypes.DATE, DateWidget);
    this.widgetMap.set(WidgetTypes.ICON, IconWidget);
    this.widgetMap.set(WidgetTypes.LABEL, Label);
    this.widgetMap.set(WidgetTypes.CHECKBOX, Checkbox);
  }

  getWidgets(): Map<string, React.FC> {
    return this.widgetMap;
  }
}

export default WidgetFactory;
