"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionInputsController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const session_inputs_service_1 = require("./session-inputs.service");
const session_input_dto_1 = require("./dto/session-input.dto");
const core_entities_1 = require("../core-entities");
let SessionInputsController = class SessionInputsController {
    constructor(sessionInputsService) {
        this.sessionInputsService = sessionInputsService;
    }
    async create(sessionId, createSessionInputDto) {
        return this.sessionInputsService.create(sessionId, createSessionInputDto);
    }
    async findAll(sessionId) {
        return this.sessionInputsService.findAllBySessionId(sessionId);
    }
    async getActionsWithLogs(sessionId, inputId) {
        return this.sessionInputsService.findOne(sessionId, inputId);
    }
    async findOne(sessionId, inputId) {
        return this.sessionInputsService.findOne(sessionId, inputId);
    }
    async toggleDiscardedBatch(sessionId, dto) {
        return this.sessionInputsService.toggleDiscardedBatch(sessionId, dto);
    }
    async removeUntilHere(sessionId, inputId) {
        return this.sessionInputsService.removeUntilHere(sessionId, inputId);
    }
    async remove(sessionId, inputId) {
        return this.sessionInputsService.remove(sessionId, inputId);
    }
    async retry(sessionId, inputId, updateSessionInputDto) {
        return this.sessionInputsService.retry(sessionId, inputId, updateSessionInputDto);
    }
    async regenerateAiResponse(sessionId, inputId) {
        return this.sessionInputsService.regenerateAiResponse(sessionId, inputId);
    }
    async update(sessionId, inputId, updateDto) {
        return this.sessionInputsService.updateContent(sessionId, inputId, updateDto);
    }
};
exports.SessionInputsController = SessionInputsController;
__decorate([
    (0, common_1.Post)(),
    (0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
    (0, swagger_1.ApiOperation)({ summary: 'Create a new input (user prompt) in session' }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 201,
        description: 'Input created successfully',
        type: core_entities_1.SessionInput,
    }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Session not found' }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, session_input_dto_1.CreateSessionInputDto]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "create", null);
__decorate([
    (0, common_1.Get)(),
    (0, swagger_1.ApiOperation)({ summary: 'List all inputs for a session' }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'List of inputs',
        type: [core_entities_1.SessionInput],
    }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "findAll", null);
__decorate([
    (0, common_1.Get)(':inputId/actions-with-logs'),
    (0, swagger_1.ApiOperation)({
        summary: 'Get AIActions with executionLogs for a specific input (lazy-load endpoint)',
        description: 'Returns the input with its AIActions and their executionLogs. Use this endpoint to lazily load execution logs for a single input instead of loading all logs for the entire session.',
    }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiParam)({ name: 'inputId', description: 'Input UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Input with actions and logs found',
    }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Input or session not found' }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Param)('inputId', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "getActionsWithLogs", null);
__decorate([
    (0, common_1.Get)(':inputId'),
    (0, swagger_1.ApiOperation)({ summary: 'Get a specific input by ID' }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiParam)({ name: 'inputId', description: 'Input UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Input found', type: core_entities_1.SessionInput }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Input or session not found' }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Param)('inputId', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "findOne", null);
__decorate([
    (0, common_1.Patch)('batch-toggle-discarded'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiOperation)({
        summary: 'Batch toggle discarded status for inputs',
        description: 'Toggle is_discarded flag for multiple inputs to exclude/include them from LLM context. Discarded inputs are preserved in database but excluded from chat history sent to LLM.',
    }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Inputs toggled successfully',
        schema: { type: 'object', properties: { affected: { type: 'number' } } },
    }),
    (0, swagger_1.ApiResponse)({
        status: 404,
        description: 'No inputs found with provided IDs',
    }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, session_input_dto_1.BatchToggleDiscardedDto]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "toggleDiscardedBatch", null);
__decorate([
    (0, common_1.Delete)(':inputId/until-here'),
    (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
    (0, swagger_1.ApiOperation)({
        summary: 'Delete this input and all subsequent inputs (rollback history)',
    }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiParam)({
        name: 'inputId',
        description: 'Input UUID to delete from',
        format: 'uuid',
    }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'Inputs deleted successfully' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Input or session not found' }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Param)('inputId', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "removeUntilHere", null);
__decorate([
    (0, common_1.Delete)(':inputId'),
    (0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
    (0, swagger_1.ApiOperation)({ summary: 'Delete a single input' }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiParam)({ name: 'inputId', description: 'Input UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({ status: 204, description: 'Input deleted successfully' }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Input or session not found' }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Param)('inputId', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "remove", null);
__decorate([
    (0, common_1.Patch)(':inputId/retry'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiOperation)({
        summary: 'Retry an input with modified prompt (regenerate context & LLM call)',
    }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiParam)({ name: 'inputId', description: 'Input UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Input retried successfully',
        type: core_entities_1.SessionInput,
    }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Input or session not found' }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Param)('inputId', common_1.ParseUUIDPipe)),
    __param(2, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, session_input_dto_1.UpdateSessionInputDto]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "retry", null);
__decorate([
    (0, common_1.Post)(':inputId/regenerate'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiOperation)({ summary: 'Regenerate AI response for an existing input' }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiParam)({ name: 'inputId', description: 'Input UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'AI response regenerated',
        type: core_entities_1.SessionInput,
    }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Input or session not found' }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Param)('inputId', common_1.ParseUUIDPipe)),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "regenerateAiResponse", null);
__decorate([
    (0, common_1.Patch)(':inputId'),
    (0, common_1.HttpCode)(common_1.HttpStatus.OK),
    (0, swagger_1.ApiOperation)({
        summary: 'Update input content (silent edit)',
        description: 'Updates message content without triggering LLM regeneration. Use for redacting sensitive data or compressing session history. Does NOT regenerate context or call LLM.',
    }),
    (0, swagger_1.ApiParam)({ name: 'sessionId', description: 'Session UUID', format: 'uuid' }),
    (0, swagger_1.ApiParam)({ name: 'inputId', description: 'Input UUID', format: 'uuid' }),
    (0, swagger_1.ApiResponse)({
        status: 200,
        description: 'Input updated',
        type: core_entities_1.SessionInput,
    }),
    (0, swagger_1.ApiResponse)({ status: 404, description: 'Input or session not found' }),
    __param(0, (0, common_1.Param)('sessionId', common_1.ParseUUIDPipe)),
    __param(1, (0, common_1.Param)('inputId', common_1.ParseUUIDPipe)),
    __param(2, (0, common_1.Body)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, session_input_dto_1.UpdateSessionInputContentDto]),
    __metadata("design:returntype", Promise)
], SessionInputsController.prototype, "update", null);
exports.SessionInputsController = SessionInputsController = __decorate([
    (0, swagger_1.ApiTags)('session-inputs'),
    (0, common_1.Controller)('sessions/:sessionId/inputs'),
    __metadata("design:paramtypes", [session_inputs_service_1.SessionInputsService])
], SessionInputsController);
//# sourceMappingURL=session-inputs.controller.js.map