import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard } from '../guards/auth.guard';
import { InactivityGuard } from '../guards/inactivity.guard';
import { UserDataResolver } from '../resolvers/userData.resolver';
import { HomePage } from './home.page';

const routes: Routes = [
  {
    path: 'home',
    component: HomePage,
    resolve: {
      userData: UserDataResolver,
    },
    children: [
      {
        path: 'events',
        children: [
          {
            path:'',
            loadChildren: ()=> import('../pages/events/events.module').then(m => m.EventsPageModule)
          },
          {
            path:':eventId/:caller',
            loadChildren: () => import('../pages/agenda/view-event/view-event.module').then( m => m.ViewEventPageModule),
          },
          {
            path:'expediente',
            children: [
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/expediente/expediente-detail/expediente-detail.module').then(m => m.ExpedienteDetailPageModule),
              },
            ]
          },
          {
            path:'expedientes-pr',
            children: [
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.module').then(m => m.ExpedientePrPageModule),
              },
            ]
          },
        ]
      },
      {
        path: 'attachments',
        children: [
          {
            path:':eventId',
          loadChildren: ()=> import('../pages/events/attachments/attachments.module').then(m => m.AttachmentsPageModule)
          },

        ],

      },
      {
        path: 'attendees',
        children: [
          {
            path:'',
            loadChildren: ()=> import('../pages/events/attendees/attendees.module').then(m => m.AttendeesPageModule)
          },
        ],

      },
      {
        path: 'attendees-modal',
        children: [
          {
            path:'',
            loadChildren: ()=> import('../shared/event/attendee-modal/attendee-modal.module').then(m => m.AttendeeModalPageModule)
          },
        ],

      },
      // {
      //   path: 'login',
      //   children: [
      //     {
      //       path:'',
      //       loadChildren: ()=> import('../pages/login/login.module').then(m => m.LoginPageModule)
      //     },
      //   ],
      //   canActivate: [LoginGuard]

      // },
      {
        path: 'agenda',
        children: [
          {
            path:'',
          loadChildren: ()=> import('../pages/agenda/agenda.module').then(m => m.AgendaPageModule)
          },
          {
            path:':eventId/:caller',
            loadChildren: () => import('../pages/agenda/view-event/view-event.module').then( m => m.ViewEventPageModule),
          },
          {
            path: 'eventId/:caller',
            loadChildren: () => import('../pages/agenda/view-event/view-event.module').then( m => m.ViewEventPageModule),
          },
          {
            path: 'edit-event',
            loadChildren: () => import('../pages/agenda/edit-event/edit-event.module').then( m => m.EditEventPageModule)
          },
          {
            path: 'emend-message-modal',
            loadChildren: () => import('../pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.module').then( m => m.ApproveEventModalPageModule)
          },
          {
            path: 'view-event',
            loadChildren: () => import('../pages/agenda/view-event/view-event.module').then( m => m.ViewEventPageModule)
          },
          {
            path:'event-list',
            children: [
              {
                path:'',
                loadChildren: ()=> import('../pages/gabinete-digital/event-list/event-list.module').then(m => m.EventListPageModule)
              },
              {
                path:'approve-event',
                children : [
                  {
                    path:':serialNumber/:caller',
                    loadChildren: ()=> import('../pages/gabinete-digital/event-list/approve-event/approve-event.module').then(m => m.ApproveEventPageModule)
                  },
                ]
              }
            ]
          },
        ],

      },
      {
        path: 'gabinete-digital',
        children: [
          {
            path:'',
            loadChildren: ()=> import('../pages/gabinete-digital/gabinete-digital.module').then(m => m.GabineteDigitalPageModule)
          },
          {
            path:'expediente',
            children: [
              {
                path:'',
                loadChildren: ()=> import('../pages/gabinete-digital/expediente/expediente.module').then(m => m.ExpedientePageModule)
              },
              {
                path:':SerialNumber',
                loadChildren: ()=> import('../pages/gabinete-digital/expediente/expediente-detail/expediente-detail.module').then(m => m.ExpedienteDetailPageModule)
              },
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/expediente/expediente-detail/expediente-detail.module').then(m => m.ExpedienteDetailPageModule)
              },
              {
                path:'events/:eventId/:caller',
                loadChildren: ()=> import('../pages/events/event-detail/event-detail.module').then(m => m.EventDetailPageModule),
              },
              {
                path:'expediente-task-modal',
                loadChildren: ()=> import('../pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.module').then(m => m.ExpedientTaskModalPageModule),
              },
            ]
          },
          {
            path: 'expedientes-pr',
            children: [
              {
                path: '',
                loadChildren: ()=> import('../pages/gabinete-digital/expedientes-pr/expedientes-pr.module').then(m => m.ExpedientesPrPageModule),
              },
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.module').then(m => m.ExpedientePrPageModule),
              },
            ]
          },
          {
            path: 'despachos',
            children: [
              {
                path: '',
                loadChildren: ()=> import('../pages/gabinete-digital/despachos/despachos.module').then(m => m.DespachosPageModule),
              },
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/despachos/despacho/despacho.module').then(m => m.DespachoPageModule),
              },
            ]
          },
          {
            path: 'despachos-pr',
            children: [
              {
                path: '',
                loadChildren: ()=> import('../pages/gabinete-digital/despachos-pr/despachos-pr.module').then(m => m.DespachosPrPageModule),
              },
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.module').then(m => m.DespachoPrPageModule),
              },
            ]
          },
          {
            path: 'pedidos',
            children: [
              {
                path: '',
                loadChildren: ()=> import('../pages/gabinete-digital/pedidos/pedidos.module').then(m => m.PedidosPageModule),
              },
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/pedidos/pedido/pedido.module').then(m => m.PedidoPageModule),
              },
            ]
          },
          {
            path: 'diplomas',
            children: [
              {
                path: '',
                loadChildren: ()=> import('../pages/gabinete-digital/diplomas/diplomas.module').then(m => m.DiplomasPageModule),
              },
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/diplomas/diploma/diploma.module').then(m => m.DiplomaPageModule),
              },
            ]
          },
          {
            path: 'diplomas-assinar',
            children: [
              {
                path: '',
                loadChildren: ()=> import('../pages/gabinete-digital/diplomas-assinar/diplomas-assinar.module').then(m => m.DiplomasAssinarPageModule),
              },
              {
                path:':SerialNumber/:caller',
                loadChildren: ()=> import('../pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.module').then(m => m.DiplomaAssinarPageModule),
              },
            ]
          },
          {
            path:'event-list',
            children: [
              {
                path:'',
                loadChildren: ()=> import('../pages/gabinete-digital/event-list/event-list.module').then(m => m.EventListPageModule)
              },
              {
                path:'approve-event',
                children : [
                  {
                    path:':serialNumber/:caller',
                    loadChildren: ()=> import('../pages/gabinete-digital/event-list/approve-event/approve-event.module').then(m => m.ApproveEventPageModule)
                  },
                ]
              }
            ]
          },
          {
            path: 'events-to-approve',
            children: [
              {
                path: '',
                loadChildren: ()=> import('../shared/gabinete-digital/edit-event-to-approve/edit-event.module')
              }
            ]
          }
        ],
      },
      {
        path: 'search',
        children: [
          {
            path:'',
            loadChildren: ()=> import('../pages/search/search.module').then(m => m.SearchPageModule)
          }
        ],

      },
      {
        path: 'publications',
        children: [
          {
            path:'',
            loadChildren: ()=> import('../pages/publications/publications.module').then(m => m.PublicationsPageModule)
          },
          {
            path:':folderId',
            loadChildren: ()=> import('../pages/publications/view-publications/view-publications.module').then(m => m.ViewPublicationsPageModule)
          },
          {
            path:'view-publications',
            children: [
              {
                path:':folderId/:publicationId',
                loadChildren: ()=> import('../pages/publications/view-publications/publication-detail/publication-detail.module').then(m => m.PublicationDetailPageModule)
              },
            ]
          },
          {
            path:'new-publication',
            loadChildren: ()=> import('../shared/publication/new-publication/new-publication.module').then(m => m.NewPublicationPageModule)
          },
          {
            path: 'request-options',
            loadChildren: () => import('../shared/popover/request-options/request-options.module').then( m => m.RequestOptionsPageModule)
          },
        ],

      },
      {
        path: 'chat',
        children: [
          {
            path:'',
            loadChildren: ()=> import('../pages/chat/chat.module').then(m => m.ChatPageModule)
          },
          {
            path:'messages',
            children: [
              {
                path:':roomId',
                loadChildren: ()=> import('../pages/chat/messages/messages.module').then(m => m.MessagesPageModule)
              },
              {
                path:'contacts',
                loadChildren: ()=> import('../shared/chat/messages/contacts/contacts.module').then(m => m.ContactsPageModule)
              },
              {
                path:'contacts',
                loadChildren: ()=> import('../pages/chat/messages/contacts/contacts.module').then(m => m.ContactsPageModule)
              },
            ]
          },
          {
            path:'group-messages',
            children:[
              {
                path:'',
                loadChildren: ()=> import('../pages/chat/group-messages/group-messages.module').then(m => m.GroupMessagesPageModule)
              },
              {
                path:'group-contacts',
                loadChildren: ()=> import('../shared/chat/group-messages/group-contacts/group-contacts.module').then(m => m.GroupContactsPageModule)
              },
              {
                path:'group-contacts',
                loadChildren: ()=> import('../pages/chat/group-messages/group-contacts/group-contacts.module').then(m => m.GroupContactsPageModule)
              },
            ]
          },
          {
            path:':eventId/:caller',
            loadChildren: () => import('../pages/agenda/view-event/view-event.module').then( m => m.ViewEventPageModule),
          },

        ],

      },
      {
        path: 'document-detail',
        children: [
          {
            path:'',
            loadChildren: ()=> import('../modals/document-detail/document-detail.module').then(m => m.DocumentDetailPageModule)
          },
        ],

      },
    ],
    canActivate: [AuthGuard]
  },
  {
    path: 'inactivity',
    children: [
      {
        path:'',
        loadChildren: ()=> import('../pages/inactivity/inactivity.module').then(m => m.InactivityPageModule)
      },
    ],
    canActivate: [InactivityGuard]
  },
  {
    path: 'login',
    children: [
      {
        path:'',
        loadChildren: ()=> import('../pages/inactivity/inactivity.module').then(m => m.InactivityPageModule)
      },
    ],
    canActivate: [InactivityGuard]
  },
  {
    path: 'pin',
    children: [
      {
        path:'',
        loadChildren: ()=> import('../pages/inactivity/inactivity.module').then(m => m.InactivityPageModule)
      },
    ],
    canActivate: [InactivityGuard]

  },
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class HomePageRoutingModule {}
