import { ENVIRONMENT_INITIALIZER, inject } from '@angular/core';
import { PendingChangesGuard } from '@guards/can-deactivate.guard';
import { IqserRoutes } from '@iqser/common-ui';
import { WebSocketService } from '@services/web-socket.service';
import { FileAssignService } from '../shared-dossiers/services/file-assign.service';
import { FilePreviewScreenComponent } from './file-preview-screen.component';
import { DocumentUnloadedGuard } from './services/document-unloaded.guard';
import { FilePreviewDialogService } from './services/file-preview-dialog.service';
import { ManualRedactionService } from './services/manual-redaction.service';
import { TablesService } from './services/tables.service';

export default [
    {
        path: '',
        component: FilePreviewScreenComponent,
        pathMatch: 'full',
        canDeactivate: [PendingChangesGuard, DocumentUnloadedGuard],
        providers: [
            FilePreviewDialogService,
            ManualRedactionService,
            DocumentUnloadedGuard,
            TablesService,
            FileAssignService,
            {
                provide: ENVIRONMENT_INITIALIZER,
                multi: true,
                useFactory: () => {
                    const service = inject(WebSocketService);
                    return () => {
                        setTimeout(() => service.connect('/redaction-gateway-v1/websocket'), 2000);
                    };
                },
            },
        ],
    },
] satisfies IqserRoutes;
