"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSupportRoutes = createSupportRoutes;
const express_1 = require("express");
const index_js_1 = require("../controllers/index.js");
function createSupportRoutes(module, logger) {
    const router = (0, express_1.Router)();
    const dashboard = (0, index_js_1.createSupportDashboardController)(module.ticketService, module.agentService, logger);
    const tickets = (0, index_js_1.createSupportTicketController)(module.ticketService, module.messageService, module.userService, module.noteService, module.orchestrator, logger);
    const agents = (0, index_js_1.createSupportAgentController)(module.agentService, logger);
    const settings = (0, index_js_1.createSupportSettingsController)(module.settingsService, logger);
    const notes = (0, index_js_1.createInternalNoteController)(module.noteService, logger);
    const search = (0, index_js_1.createSupportSearchController)(module.messageService, module.ticketService, logger);
    router.get("/dashboard", wrap(dashboard.getDashboard));
    router.get("/tickets", wrap(tickets.list));
    router.get("/tickets/:id", wrap(tickets.getById));
    router.post("/tickets/:id/reply", wrap(tickets.reply));
    router.post("/tickets/:id/assign", wrap(tickets.assign));
    router.post("/tickets/:id/status", wrap(tickets.updateStatus));
    router.post("/tickets/:id/priority", wrap(tickets.updatePriority));
    router.post("/tickets/:id/read", wrap(tickets.markAsRead));
    router.get("/agents", wrap(agents.list));
    router.post("/agents", wrap(agents.create));
    router.put("/agents/:id", wrap(agents.update));
    router.post("/agents/me/online", wrap(agents.setOnline));
    router.delete("/agents/:id", wrap(agents.delete));
    router.get("/settings", wrap(settings.get));
    router.put("/settings", wrap(settings.update));
    router.get("/notes/:ticketId", wrap(notes.listByTicket));
    router.post("/notes", wrap(notes.create));
    router.put("/notes/:id", wrap(notes.update));
    router.delete("/notes/:id", wrap(notes.delete));
    router.get("/search", wrap(search.search));
    return router;
}
function wrap(handler) {
    return (req, res, next) => {
        handler(req, res).catch(next);
    };
}
