"use strict";
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2024-2026 Gracker (Chris)
// This file is part of SmartPerfetto. See LICENSE for details.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createEnterpriseRuntimeDashboardRoutes = createEnterpriseRuntimeDashboardRoutes;
const express_1 = __importDefault(require("express"));
const auth_1 = require("../middleware/auth");
const rbac_1 = require("../services/rbac");
const enterpriseRuntimeDashboardService_1 = require("../services/enterpriseRuntimeDashboardService");
function createEnterpriseRuntimeDashboardRoutes(deps = {}) {
    const router = express_1.default.Router();
    router.use(auth_1.authenticate);
    router.use((req, res, next) => {
        const context = (0, auth_1.requireRequestContext)(req);
        if (!(0, rbac_1.hasRbacPermission)(context, 'runtime:manage')) {
            (0, rbac_1.sendForbidden)(res, 'Runtime dashboard requires runtime:manage permission');
            return;
        }
        next();
    });
    router.get('/', (req, res) => {
        const context = (0, auth_1.requireRequestContext)(req);
        res.json((0, enterpriseRuntimeDashboardService_1.buildEnterpriseRuntimeDashboard)(context, deps));
    });
    return router;
}
exports.default = createEnterpriseRuntimeDashboardRoutes();
//# sourceMappingURL=enterpriseRuntimeDashboardRoutes.js.map