import { Router } from 'express';
import { getRouteLocals } from '../../utils/localsHelper.js';
import { RequestMissingReportRoutes } from './request-missing-report/routes.js';
import { DownloadReportRoutes } from './download-report/routes.js';
import { MyReportsRoutes } from './my-reports/routes.js';
import { ViewReportRoutes } from './view-report/routes.js';
import { RequestReportRoutes } from './request-report/routes.js';
import { ProductCollectionRoutes } from './product-collection/routes.js';
import { ReportCatalogueRoutes } from './report-catalogue/routes.js';
import { MyReportsCatalogueRoutes } from './my-reports-catalogue/routes.js';
import { setNestedPath } from '../../utils/urlHelper.js';

function DprRoutes({ layoutPath, services }) {
    const router = Router({ mergeParams: true });
    router.use('/', RequestMissingReportRoutes({ path: '/request-missing-report', layoutPath, services }));
    router.use('/', DownloadReportRoutes({ path: '/download-report', layoutPath, services }));
    router.use('/', MyReportsRoutes({ path: '/my-reports', layoutPath, services }));
    router.use('/', ViewReportRoutes({ path: '/view-report', layoutPath, services }));
    router.use('/', RequestReportRoutes({ path: '/request-report', layoutPath, services }));
    router.use('/', ProductCollectionRoutes({ path: '/product-collection', layoutPath, services }));
    router.use('/', ReportCatalogueRoutes({ path: '/report-catalogue', layoutPath, services }));
    router.use('/', MyReportsCatalogueRoutes({ layoutPath, services }));
    return router;
}
function Redirects() {
    const router = Router({ mergeParams: true });
    // Request route redirect
    router.get(`/async/:type/:reportId/:id/request`, (req, res) => {
        const { type, reportId, id } = req.params;
        const { nestedBaseUrl } = getRouteLocals(res);
        const path = setNestedPath(`/dpr/request-report/${type}/${reportId}/${id}/filters`, nestedBaseUrl);
        res.redirect(path);
    });
    // Status route redirect
    router.get(`/async/:type/:reportId/:id/request/:executionId`, (req, res) => {
        const { type, reportId, id, executionId } = req.params;
        const { nestedBaseUrl } = getRouteLocals(res);
        const path = setNestedPath(`/dpr/request-report/${type}/${reportId}/${id}/${executionId}/status`, nestedBaseUrl);
        res.redirect(path);
    });
    return router;
}
function Routes({ layoutPath, services }) {
    const router = Router({ mergeParams: true });
    router.use('/dpr', DprRoutes({ layoutPath, services }));
    router.use('/', Redirects());
    return router;
}

export { DprRoutes, Redirects, Routes, Routes as default };
//# sourceMappingURL=routes.js.map
