import scopes from '@utils/scopes';
// @ts-ignore
import { ModelUseTypes } from '@devsun/pgs-modeler/dist/build';
import { Route } from 'vue-router/types';
import { lazyLoadView } from '@utils/lazyloadview';

const categories = {
  services: {
    label: 'services.serviceConstructor',
    path: 'services',
    scopes: scopes.services,
  },
};

const routes = [
  {
    children: [
      {
        component: () => import('@components/services/index.vue'),
        meta: {
          // icon: 'category',
          label: 'services.serviceConstructor',
          place: 'drawer',
          scopes: categories.services.scopes,
        },
        name: 'services',
        path: '',
        props: (route: Route) => {
          return {
            searchQuery: {
              status: route.query.status,
              search: route.query.search,
            },
          };
        },
      },
      {
        path: 'emulation',
        component: () => import('@/components/services/emulation/index.vue'),
      },
      {
        component: () => import('@/components/services/modeler/create.vue'),
        name: 'modeler-create',
        path: 'modeler/create',
      },
      {
        component: () => import('@/components/services/modeler/create.vue'),
        name: 'modeler-create-registry',
        path: 'modeler/registries/create',
      },
      {
        component: () =>
          import('@/components/services/modeler/service-page.vue'),
        name: 'modeler-service-page',
        path: 'modeler/service/:serviceId',
      },
      {
        path: 'modeler/service/:serviceId/model/input',
        component: () => import('@/components/services/modeler/model-page.vue'),
        props: { modelUseType: ModelUseTypes.INPUT, readOnly: true },
      },
      {
        path: 'modeler/service/:serviceId/model',
        component: () => import('@/components/services/modeler/model-page.vue'),
        props: { modelUseType: ModelUseTypes.MAIN, readOnly: false },
      },
      {
        path: 'modeler/service/:serviceId/mapper',
        component: () =>
          import('@/components/services/modeler/mapper-page.vue'),
      },
      {
        path: 'modeler/service/:serviceId/export-import',
        component: () =>
          import('@/components/services/modeler/export-import-page.vue'),
        props: { modelUseType: ModelUseTypes.MAIN, readonly: false },
      },
      {
        path: 'modeler/service/:serviceId/schema/:schemaId',
        component: () =>
          import('@/components/services/modeler/schema-page.vue'),
      },
    ],
    component: () => lazyLoadView(import('@router/services/index.vue')),
    path: categories.services.path,
  },
];

export default routes;
