import { NgModule, RendererFactory2, Type } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DragDirective } from './drag.directive';
import { DropListDirective } from './drop-list.directive';
import { DropPlaceDirective } from './drop-place.directive';
import { AppDragDropService } from './app-drag-drop.service';
import { SidebarRoomDragPreviewComponent } from 'src/app/components/sidebar/sidebar-room/sidebar-room-drag-preview/sidebar-room-drag-preview.component';
import { SidebarDialogueDragPreviewComponent } from 'src/app/components/sidebar/sidebar-dialogue/sidebar-dialogue-drag-preview/sidebar-dialogue-drag-preview.component';
import { SidebarGroupDragPreviewComponent } from 'src/app/components/sidebar/sidebar-group/sidebar-group-drag-preview/sidebar-group-drag-preview.component';

@NgModule({
  declarations: [DragDirective, DropListDirective, DropPlaceDirective],
  imports: [CommonModule],
  providers: [
    {
      provide: AppDragDropService,
      useFactory: (rendererFactory: RendererFactory2) => {
        let dndServiceConfigMap = new Map<string, Type<any>>();
        dndServiceConfigMap.set('room', SidebarRoomDragPreviewComponent);
        dndServiceConfigMap.set('dialogue', SidebarDialogueDragPreviewComponent);
        dndServiceConfigMap.set('group', SidebarGroupDragPreviewComponent);

        return new AppDragDropService(rendererFactory, dndServiceConfigMap);
      },
      deps: [RendererFactory2],
    },
  ],
  exports: [DragDirective, DropListDirective, DropPlaceDirective],
})
export class AppDragDropModule {}
