"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkEnvironment = checkEnvironment;
const getPolicyResponseCode_1 = require("./getPolicyResponseCode");
/**
 * @internal
 * Verify that the policy.environment requirement is met.
 *
 * @param policy
 * @param context
 * @param entity
 * @returns
 */
function checkEnvironment(policy, context, _entity) {
    const checks = [];
    if (policy.environments && policy.environments.length) {
        let result = "granted";
        if (!policy.environments.includes(context.environment)) {
            result = "not-in-environment";
        }
        const check = {
            name: `user in ${policy.environments.join(",")} org`,
            value: context.environment,
            code: (0, getPolicyResponseCode_1.getPolicyResponseCode)(result),
            response: result,
        };
        checks.push(check);
    }
    return checks;
}
//# sourceMappingURL=checkEnvironment.js.map