import scopes, { getScopes } from '@utils/scopes';
import { USER_SCOPES } from '@constants/entities/Scope';

import { expansionMenuItem, disabledMenuItem } from './utils';

const gomu = getScopes([
  USER_SCOPES.GOMU_SPECIALIST,
  USER_SCOPES.SYSTEM_ADMINISTRATOR,
]);

const mil = getScopes([
  USER_SCOPES.MILITARY_COMMISSAR,
  USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
  // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
  USER_SCOPES.SYSTEM_ADMINISTRATOR,
]);

export default function createRoute({ path, icon, label, order }) {
  return expansionMenuItem({
    path,
    label,
    icon,
    order,
    children: [
      expansionMenuItem({
        path: 'summon',
        label: 'Вызов граждан',
        children: [
          {
            component: () => import('@/recruits/components/call-list'),
            path: 'list/details/:id',
            meta: {
              customHeader: true,
              scopes: getScopes([
                USER_SCOPES.MILITARY_COMMISSAR,
                USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                USER_SCOPES.SYSTEM_ADMINISTRATOR,
                USER_SCOPES.GOMU_OBSERVER,
              ]),
            },
            children: [
              {
                name: 'call-list',
                path: 'call-list',
                component: () => import('@/recruits/components/call-list/main'),
              },
              {
                name: 'call-list-settings',
                path: 'call-list-settings',
                component: () => import('@/recruits/components/call-list/settings'),
              },
            ],
          },
          {
            component: () => import('@/recruits/layouts/basic-list-layout'),
            path: 'list',
            children: [
              {
                name: 'conscription-list',
                path: 'conscripts',
                components: {
                  listButtons: () =>
                    import(
                      '@/recruits/components/conscription/listButtons.vue'
                    ),
                  default: () => import('@/recruits/components/conscription'),
                },
                meta: {
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.MILITARY_COMMISSARIAT_OBSERVER,
                  ]),
                  place: 'drawer',
                  label: 'Граждане, подлежащие вызову',
                  storeCountGetters: 'menuCounters/conscription',
                },
              },
              {
                name: 'call-lists',
                components: {
                  listButtons: () =>
                    import('@/recruits/components/call-lists/listButtons.vue'),
                  default: () => import('@/recruits/components/call-lists'),
                },
                path: '',
                meta: {
                  clickable: true,
                  label: 'Списки на вызов',
                  place: 'drawer',
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                    USER_SCOPES.GOMU_OBSERVER,
                  ]),
                  storeCountGetters: 'menuCounters/list',
                },
              },
            ],
          },
          {
            component: () => import('@/recruits/layouts/basic-list-layout'),
            path: 'search',
            children: [
              {
                name: 'recruits-to-call',
                components: {
                  listButtons: () =>
                    import(
                      '@/recruits/components/recruits-to-call/listButtons.vue'
                    ),
                  default: () =>
                    import('@/recruits/components/recruits-to-call'),
                },
                path: '',
                meta: {
                  label: 'Добавить граждан в список',
                  listTitle: 'Добавление граждан в список на вызов',
                  place: 'drawer',
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                  ]),
                  storeCountGetters: 'menuCounters/recruitsForLists',
                },
              },
            ],
          },
        ],
      }),
      {
        component: () => import('@/recruits/components/subpoena-card'),
        path: 'card/:id',
        meta: {
          tabs: [
            {
              name: 'Информация',
              path: 'subpoena-card',
            },
            {
              name: 'История',
              path: 'subpoena-history',
            },
          ],
          scopes: getScopes([
            USER_SCOPES.MILITARY_COMMISSAR,
            USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
            // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
            USER_SCOPES.SYSTEM_ADMINISTRATOR,
            USER_SCOPES.GOMU_OBSERVER,
            USER_SCOPES.GOMU_SPECIALIST,
          ]),
        },
        children: [
          {
            name: 'subpoena-card',
            path: '',
            components: {
              masthead: () =>
                import('@/recruits/components/subpoena-card/masthead.vue'),
              default: () =>
                import('@/recruits/components/subpoena-card/details-tab.vue'),
            },
            meta: {
              scopes: getScopes([
                USER_SCOPES.MILITARY_COMMISSAR,
                USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                USER_SCOPES.SYSTEM_ADMINISTRATOR,
                USER_SCOPES.GOMU_OBSERVER,
                USER_SCOPES.GOMU_SPECIALIST,
              ]),
              isTrackable: false,
            },
          },
          {
            name: 'subpoena-history',
            path: 'history',
            components: {
              masthead: () =>
                import('@/recruits/components/subpoena-card/masthead.vue'),
              default: () =>
                import('@/recruits/components/subpoena-card/history-tab.vue'),
            },
            meta: {
              scopes: getScopes([
                USER_SCOPES.MILITARY_COMMISSAR,
                USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                USER_SCOPES.GOMU_OBSERVER,
                USER_SCOPES.SYSTEM_ADMINISTRATOR,
                USER_SCOPES.GOMU_SPECIALIST,
              ]),
              isTrackable: false,
            },
          },
        ],
      },
      expansionMenuItem({
        path: 'tasks-log',
        label: 'Журнал заданий на формирование повесток',
        children: [
          disabledMenuItem({
            path: 'active',
            label: 'Активные задания',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'done',
            label: 'Завершённые задания',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'errors',
            label: 'Ошибки',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'log',
        label: 'Журнал формирования выписок',
        children: [
          disabledMenuItem({
            path: 'requests',
            label: 'Журнал запросов на выписку',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'responses',
            label: 'Журнал ответов',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'errors',
            label: 'Ошибки',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'extracts',
        label: 'Запросы выписок из реестра',
        children: [
          disabledMenuItem({
            path: 'request',
            label: 'Запрос выписки',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'results',
            label: 'Результаты запроса',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'errors',
            label: 'Ошибки',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              // USER_SCOPES.MILITARY_CONSCRIPTION_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'edits',
        label: 'Изменение повестки',
        children: [
          disabledMenuItem({
            path: 'list',
            label: 'Редактирование повесток',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'drafts',
            label: 'Черновики повесток',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'log',
            label: 'Журнал изменений',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'resends',
        label: 'Повторная отправка повесток',
        children: [
          disabledMenuItem({
            path: 'log',
            label: 'Журнал на повторную отправку',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'status',
            label: 'Статусы отправки',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'tasks',
        label: 'Задания на формирование повесток',
        children: [
          disabledMenuItem({
            path: 'log',
            label: 'Журнал заданий',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'manual',
            label: 'Ручное задание',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'auto',
            label: 'Автоматические задания',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'monitoring',
            label: 'Мониторинг заданий',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'search',
        label: 'Поиск повесток',
        children: [
          disabledMenuItem({
            path: 'files',
            label: 'Поиск файла выгрузки',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          {
            component: () => import('@/recruits/layouts/basic-list-layout.vue'),
            path: 'person',
            children: [
              {
                name: 'list-of-subpoenas',
                component: () => import('@/recruits/components/subpoenas'),
                path: '',
                meta: {
                  listTitle: 'Реестр повесток',
                  label: 'Поиск по гражданину',
                  place: 'drawer',
                  scopes: getScopes([
                    USER_SCOPES.MILITARY_COMMISSAR,
                    USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
                    USER_SCOPES.GOMU_OBSERVER,
                    USER_SCOPES.GOMU_SPECIALIST,
                    USER_SCOPES.SYSTEM_ADMINISTRATOR,
                  ]),
                },
              },
            ],
          },
          disabledMenuItem({
            path: 'vk',
            label: 'Поиск по военкомату',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'type',
            label: 'Поиск по типу повестки',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'alt',
            label: 'Произвольный поиск',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'archive',
        label: 'Архив повесток',
        children: [
          disabledMenuItem({
            path: 'requests',
            label: 'Задания на перенос в архив',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'search',
            label: 'Поиск в архиве',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'log',
            label: 'Журнал архивирования',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'monitoring',
        label: 'Мониторинг получения повесток',
        children: [
          disabledMenuItem({
            path: 'paper',
            label: 'Мониторинг бумага',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'digital',
            label: 'Мониторинг цифровая повестка',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'showcase',
        label: 'Витрина данных',
        children: [
          disabledMenuItem({
            path: 'all',
            label: 'Просмотр всех данных',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'search',
            label: 'Поиск записи',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
      expansionMenuItem({
        path: 'update',
        label: 'Мониторинг обновления витрины',
        children: [
          disabledMenuItem({
            path: 'monitoring',
            label: 'Журнал обновлений',
            scopes: getScopes([
              USER_SCOPES.GOMU_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'start',
            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: 'templates',
        label: 'Электронные образы повесток',
        children: [
          disabledMenuItem({
            path: 'search',
            label: 'Поиск документа',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.GOMU_OBSERVER,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
          disabledMenuItem({
            path: 'archive',
            label: 'Выгрузка архив',
            scopes: getScopes([
              USER_SCOPES.MILITARY_COMMISSAR,
              USER_SCOPES.MILITARY_RECRUIT_SPECIALIST,
              USER_SCOPES.SYSTEM_ADMINISTRATOR,
            ]),
          }),
        ],
      }),
    ],
  });
}
