"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.AnnouncementsController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const client_1 = require("@prisma/client");
const require_role_decorator_1 = require("../auth/require-role.decorator");
const current_user_decorator_1 = require("../common/current-user.decorator");
const swagger_docs_1 = require("../common/swagger-docs");
const feature_catalog_1 = require("../features/feature-catalog");
const require_feature_decorator_1 = require("../features/require-feature.decorator");
const announcements_service_1 = require("./announcements.service");
const announcement_dto_1 = require("./dto/announcement.dto");
let AnnouncementsController = class AnnouncementsController {
    announcements;
    constructor(announcements) {
        this.announcements = announcements;
    }
    getOptions() {
        return this.announcements.getOptions();
    }
    findAll(user, estateId) {
        return this.announcements.findAll(user, estateId);
    }
    findOne(user, id) {
        return this.announcements.findOne(user, id);
    }
    create(dto, user) {
        return this.announcements.create(dto, user);
    }
};
exports.AnnouncementsController = AnnouncementsController;
__decorate([
    (0, common_1.Get)('options'),
    (0, require_role_decorator_1.RequireRole)(client_1.UserRole.ESTATE_ADMIN, client_1.UserRole.SECURITY_SUPERVISOR, client_1.UserRole.GUARD, client_1.UserRole.RESIDENT),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.ANNOUNCEMENTS_VIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'List announcement options',
        description: 'Returns announcement categories, priority options, and public-safe content rules for MobileApp and WebApp announcement screens.'
    }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Announcement options returned.' }),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AnnouncementsController.prototype, "getOptions", null);
__decorate([
    (0, common_1.Get)(),
    (0, require_role_decorator_1.RequireRole)(client_1.UserRole.ESTATE_ADMIN, client_1.UserRole.SECURITY_SUPERVISOR, client_1.UserRole.GUARD, client_1.UserRole.RESIDENT),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.ANNOUNCEMENTS_VIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'List estate announcements',
        description: 'Returns published estate announcements and news visible to the signed-in estate.'
    }),
    (0, swagger_1.ApiQuery)({ name: 'estateId', required: false, example: swagger_docs_1.ESTATE_ID_EXAMPLE }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Announcements returned.' }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Query)('estateId')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String]),
    __metadata("design:returntype", void 0)
], AnnouncementsController.prototype, "findAll", null);
__decorate([
    (0, common_1.Get)(':id'),
    (0, require_role_decorator_1.RequireRole)(client_1.UserRole.ESTATE_ADMIN, client_1.UserRole.SECURITY_SUPERVISOR, client_1.UserRole.GUARD, client_1.UserRole.RESIDENT),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.ANNOUNCEMENTS_VIEW),
    (0, swagger_1.ApiOperation)({
        summary: 'View announcement detail',
        description: 'Returns a single published announcement with author, target, attachment metadata, and read-status data where available.'
    }),
    (0, swagger_1.ApiParam)({ name: 'id', example: 'announcement-uuid' }),
    (0, swagger_1.ApiResponse)({ status: 200, description: 'Announcement returned.' }),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Param)('id')),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String]),
    __metadata("design:returntype", void 0)
], AnnouncementsController.prototype, "findOne", null);
__decorate([
    (0, common_1.Post)(),
    (0, require_role_decorator_1.RequireRole)(client_1.UserRole.ESTATE_ADMIN, client_1.UserRole.SECURITY_SUPERVISOR, client_1.UserRole.GUARD),
    (0, require_feature_decorator_1.RequireFeature)(feature_catalog_1.FeatureKey.ANNOUNCEMENTS_SEND),
    (0, swagger_1.ApiOperation)({
        summary: 'Send estate announcement',
        description: 'Sends a plan-limited estate announcement. Promotional, political, spam, or unrelated content is blocked and logged for super-admin review.'
    }),
    (0, swagger_1.ApiBody)({ type: announcement_dto_1.CreateAnnouncementDto }),
    (0, swagger_1.ApiResponse)({ status: 201, description: 'Announcement sent.' }),
    (0, swagger_docs_1.ApiValidationError)(),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [announcement_dto_1.CreateAnnouncementDto, Object]),
    __metadata("design:returntype", void 0)
], AnnouncementsController.prototype, "create", null);
exports.AnnouncementsController = AnnouncementsController = __decorate([
    (0, swagger_1.ApiTags)('Announcements'),
    (0, swagger_docs_1.ApiProtectedEndpoint)(),
    (0, common_1.Controller)({ path: 'announcements', version: '1' }),
    __metadata("design:paramtypes", [announcements_service_1.AnnouncementsService])
], AnnouncementsController);
//# sourceMappingURL=announcements.controller.js.map