import { expansionMenuItem, disabledMenuItem } from './utils';
import { getScopes } from '@utils/scopes';
import { USER_SCOPES } from '@constants/entities/Scope';
import { lazyLoadView } from '@utils/lazyloadview';
import { lazyLoadWatcher } from '@/recruits/utils/mfe-loader';

export default function createRoute({ path, icon, label, order }) {
  return expansionMenuItem({
    path,
    label,
    icon,
    order,
    children: [
      disabledMenuItem({
        path: 'drafts',
        label: 'Черновики',
      }),
      // {
      //   component: () => import('@/recruits/layouts/main-view.vue'),
      //   path: 'drafts',
      //   children: [{
      //     name: 'mfe-drafts',
      //     component: () => lazyLoadWatcher(() => import('@/recruits/components/mfe/DraftsApp.vue')),
      //     path: ':subpath*',
      //     meta: {
      //       label: 'Черновики',
      //       place: 'drawer',
      //       order: 10,
      //     }
      //   }],
      // },
      {
        component: () => import('@/recruits/layouts/basic-list-layout.vue'),
        path: 'journal-smev',
        children: [
          {
            name: 'journal-smev',
            component: () => import('@/recruits/components/journal-smev'),
            path: '',
            meta: {
              place: 'drawer',
              label: 'Журнал входящих и исходящих сообщений СМЭВ',
              scopes: getScopes([
                USER_SCOPES.SYSTEM_ADMINISTRATOR,
                USER_SCOPES.GOMU_OBSERVER,
              ]),
            },
          },
        ],
      },
      expansionMenuItem({
        path: 'import-log',
        label: 'Журнал приёма файлов',
        children: [
          disabledMenuItem({
            path: 'received',
            label: 'Реестр принятых файлов',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'protocols',
            label: 'Протоколы приёма',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'manual',
            label: 'Ручной приём',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'import-error-log',
        label: 'Журнал ошибок приёма',
        children: [
          disabledMenuItem({
            path: 'registry',
            label: 'Реестр ошибок приёма',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'schema-errors',
            label: 'Ошибки схемы',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'flk-errors',
            label: 'Ошибки ФЛК',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'manual',
            label: 'Ручной приём',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'protocols',
            label: 'Протоколы ошибок',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'export-log',
        label: 'Журнал отправки файлов',
        children: [
          disabledMenuItem({
            path: 'registry',
            label: 'Реестр отправленных файлов',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'protocols',
            label: 'Протоколы отправки',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'manual',
            label: 'Ручная отправка',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'export-error-log',
        label: 'Журнал ошибок отправки',
        children: [
          disabledMenuItem({
            path: 'registry',
            label: 'Реестр ошибок отправки',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'protocols',
            label: 'Ручная отправка',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'manual',
            label: 'Протоколы ошибок',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'flk-not-passed',
        label: 'Не прошедшие ФЛК',
        children: [
          disabledMenuItem({
            path: 'log',
            label: 'Журнал записей',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'corrections',
            label: 'Корректировка ручная',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'incidents',
            label: 'Инциденты ФЛК',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'manual-identification',
        label: 'Ручная идентификация',
        children: [
          disabledMenuItem({
            path: 'log',
            label: 'Журнал идентифицированных',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'merge',
            label: 'Задания на слияния',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'branch',
            label: 'Задание на разделение',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'request-generation',
            label: 'Формирование запроса данных',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'responses',
            label: 'Ответы на запросы',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'results',
            label: 'Результаты идентификации',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'auto-reports-log',
        label: 'Запросы автоматические',
        children: [
          disabledMenuItem({
            path: 'requests',
            label: 'Журнал запросов',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'responses',
            label: 'Журнал ответов',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'errors',
            label: 'Журнал ошибок',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'manual-reports-log',
        label: 'Запросы пользовательские',
        children: [
          disabledMenuItem({
            path: 'requests',
            label: 'Журнал запросов пользователя',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'responses',
            label: 'Журнал ответов',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'errors',
            label: 'Журнал ошибок',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'import',
        label: 'Ручная загрузка данных',
        children: [
          {
            component: () => import('@/recruits/layouts/main-view.vue'),
            path: 'upload',
            children: [
              {
                name: 'import',
                component: () => import('@/recruits/components/import'),
                path: '',
                meta: {
                  place: 'drawer',
                  label: 'Загрузить данные',
                  order: 10,
                  scopes: getScopes([USER_SCOPES.GOMU_SPECIALIST]),
                },
              },
              {
                name: 'conscription-import',
                path: 'import-conscripts',
                component: () =>
                  import('@/recruits/components/conscription/import'),
                meta: {
                  place: 'drawer',
                  order: 11,
                  label: 'Загрузить список граждан на вызов',
                  listTitle: 'Загрузить список граждан на вызов',
                  scopes: getScopes([USER_SCOPES.MILITARY_RECRUIT_SPECIALIST]),
                },
              },
              {
                name: 'staging-import',
                path: 'staging-import',
                component: () => import('@/recruits/components/staging-import'),
                meta: {
                  place: 'drawer',
                  order: 12,
                  label:
                    'Загрузить военные идентификаторы для постановки на учёт',
                  listTitle:
                    'Загрузить военные идентификаторы для постановки на учёт',
                  scopes: getScopes([USER_SCOPES.MILITARY_RECRUIT_SPECIALIST]),
                },
              },
              // {
              //   name: 'registered-import',
              //   path: 'import-registered',
              //   component: () =>
              //     import('@/recruits/components/registered/import'),
              //   meta: {
              //     place: 'drawer',
              //     order: 13,
              //     label:
              //       'Загрузить список граждан, состоящих на воинском учёте',
              //     listTitle:
              //       'Загрузить список граждан, состоящих на воинском учёте',
              //     scopes: getScopes([USER_SCOPES.MILITARY_RECRUIT_SPECIALIST]),
              //   },
              // },
              // {
              //   component: () => import('@/recruits/layouts/basic-list-layout'),
              //   path: 'summons',
              //   children: [
              //     {
              //       name: 'call-lists-import-scv',
              //       components: {
              //         listButtons: () =>
              //           import(
              //             '@/recruits/components/call-lists-import-csv/listButtons.vue'
              //           ),
              //         default: () => import('@/recruits/components/call-lists-import-csv'),
              //       },
              //       path: '',
              //       meta: {
              //         label: 'Загрузить список граждан на вызов',
              //         listTitle: 'Импорт списка граждан на вызов',
              //         place: 'drawer',
              //         order: 15,
              //         scopes: getScopes([
              //           USER_SCOPES.MILITARY_COMMISSAR,
              //           USER_SCOPES.GOMU_SPECIALIST,
              //           USER_SCOPES.SYSTEM_ADMINISTRATOR,
              //         ]),
              //       },
              //     },
              //   ],
              // },
            ],
          },
          {
            component: () => import('@/recruits/layouts/basic-list-layout.vue'),
            path: 'log',
            children: [
              {
                name: 'log-success',
                components: {
                  listButtons: () =>
                    import('@/recruits/components/successImport/list-buttons'),
                  default: () => import('@/recruits/components/successImport'),
                },
                path: 'success',
                meta: {
                  place: 'drawer',
                  label: 'Журнал загрузки записей',
                  order: 30,
                  scopes: getScopes([
                    USER_SCOPES.GOMU_SPECIALIST,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                  ]),
                },
              },
              {
                name: 'log-error',
                components: {
                  listButtons: () =>
                    import('@/recruits/components/errorsImport/list-buttons'),
                  default: () => import('@/recruits/components/errorsImport'),
                },
                path: 'error',
                meta: {
                  place: 'drawer',
                  label: 'Журнал ошибок загрузки записей',
                  order: 20,
                  scopes: getScopes([
                    USER_SCOPES.GOMU_SPECIALIST,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                  ]),
                },
              },
              {
                name: 'log-import',
                path: 'import',
                components: {
                  listButtons: () =>
                    import('@/recruits/components/log/log-import/list-buttons'),
                  default: () => import('@/recruits/components/log/log-import'),
                },
                meta: {
                  place: 'drawer',
                  label: 'Журнал загрузки файлов',
                  order: 40,
                  scopes: getScopes([
                    USER_SCOPES.GOMU_SPECIALIST,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                  ]),
                },
              },
            ],
          },
          disabledMenuItem({
            path: 'monitoring',
            label: 'Мониторинг загрузки',
            order: 50,
          }),
          {
            name: 'import-details',
            path: 'details/:id',
            component: () =>
              import('@/recruits/components/log/log-import-details'),
            meta: {
              scopes: getScopes([
                USER_SCOPES.GOMU_SPECIALIST,
                USER_SCOPES.SYSTEM_ADMINISTRATOR,
                USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              ]),
            },
          },
        ],
      }),
      expansionMenuItem({
        path: 'export',
        label: 'Ручная выгрузка данных',
        children: [
          {
            name: 'staging-export',
            path: 'staging-export',
            component: () => import('@/recruits/components/staging-export'),
            meta: {
              place: 'drawer',
              order: 13,
              label: 'Выгрузить данные',
              listTitle: 'Выгрузить данные',
              scopes: getScopes([USER_SCOPES.MILITARY_RECRUIT_SPECIALIST]),
            },
          },
          {
            name: 'subpoena-export',
            path: 'subpoena-export',
            component: () => import('@/recruits/components/subpoena-export'),
            meta: {
              place: 'drawer',
              order: 13,
              label: 'Список вызванных граждан',
              listTitle: 'Список вызванных граждан',
              scopes: getScopes([USER_SCOPES.MILITARY_RECRUIT_SPECIALIST]),
            },
          },
          {
            component: () => import('@/recruits/layouts/basic-list-layout.vue'),
            path: '',
            children: [
              {
                name: 'analytical-units',
                path: 'analytical-units',
                component: () =>
                  import('@/recruits/components/analytical-units'),
                meta: {
                  place: 'drawer',
                  order: 14,
                  label: 'Аналитические агрегаты',
                  listTitle: 'Аналитические агрегаты',
                  scopes: getScopes([
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.GOMU_OBSERVER,
                  ]),
                },
              },
            ],
          },
        ],
      }),
      expansionMenuItem({
        path: 'archive',
        label: 'Управление архивом',
        children: [
          disabledMenuItem({
            path: 'registry',
            label: 'Реестр разделов',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'request',
            label: 'Задание на архивирование',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'search',
            label: 'Поиск',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      {
        component: () => import('@/recruits/layouts/basic-list-layout.vue'),
        path: '',
        children: [
          {
            name: 'geps-notifications',
            path: 'geps-notifications',
            meta: {
              label: 'Уведомления на ЕПГУ',
              place: 'drawer',
              order: 20,
              scopes: getScopes([
                USER_SCOPES.MILITARY_COMMISSAR,
                USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                USER_SCOPES.SYSTEM_ADMINISTRATOR,
                USER_SCOPES.GOMU_OBSERVER,
                USER_SCOPES.GOMU_SPECIALIST,
                USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
              ]),
            },
            component: () =>
              lazyLoadView(import('@/recruits/components/geps-notifications')),
          },
        ],
      },
    ],
  });
}
