"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdminConsoleConfigService = void 0;
const common_1 = require("@nestjs/common");
const auth_config_service_1 = require("../../core/services/auth-config.service");
let AdminConsoleConfigService = class AdminConsoleConfigService {
    authConfig;
    constructor(authConfig) {
        this.authConfig = authConfig;
    }
    get options() {
        return this.authConfig.getConfig().adminConsole ?? {};
    }
    ensureEnabled() {
        if (this.options?.enabled === false) {
            throw new common_1.NotFoundException('Admin console is disabled');
        }
    }
    getCookieName() {
        return this.options?.sessionCookieName ?? 'nest_auth_admin';
    }
    getBasePath() {
        return this.options?.basePath;
    }
    getSessionSecret() {
        return this.options?.secretKey ?? 'change-me-admin-secret';
    }
    getSessionDuration() {
        return this.options?.sessionDuration ?? '2h';
    }
    getCookieOptions() {
        const secureDefault = process.env.NODE_ENV === 'production';
        const base = {
            httpOnly: true,
            sameSite: 'lax',
            secure: secureDefault,
            path: this.getBasePath(),
        };
        return {
            ...base,
            ...(this.options?.cookie ?? {}),
            path: this.options?.cookie?.path ?? base.path,
        };
    }
    allowAdminManagement() {
        return this.options?.allowAdminManagement !== false;
    }
    getSecretKey() {
        return this.options?.secretKey;
    }
};
exports.AdminConsoleConfigService = AdminConsoleConfigService;
exports.AdminConsoleConfigService = AdminConsoleConfigService = __decorate([
    (0, common_1.Injectable)(),
    __metadata("design:paramtypes", [auth_config_service_1.AuthConfigService])
], AdminConsoleConfigService);
//# sourceMappingURL=admin-console-config.service.js.map