"use strict";
// SPDX-License-Identifier: Apache-2.0
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable @typescript-eslint/no-explicit-any */
const ValidatedArgs_1 = __importDefault(require("../../../../../core/validation/ValidatedArgs"));
const FormatValidation_1 = __importDefault(require("../../FormatValidation"));
const InvalidValue_1 = require("../../error/InvalidValue");
class ApplyRolesRequest extends ValidatedArgs_1.default {
    securityId;
    targetId;
    roles;
    actives;
    constructor({ targetId, securityId, roles, actives, }) {
        super({
            securityId: FormatValidation_1.default.checkHederaIdFormatOrEvmAddress(),
            targetId: FormatValidation_1.default.checkHederaIdFormatOrEvmAddress(),
            roles: (vals) => {
                if (vals.length == 0) {
                    return [new InvalidValue_1.InvalidValue(`The list of roles cannot be empty.`)];
                }
                for (let i = 0; i < vals.length; i++) {
                    const err = FormatValidation_1.default.checkRole()(vals[i]);
                    if (err.length > 0) {
                        return err;
                    }
                    if (vals.indexOf(vals[i]) != i) {
                        return [new InvalidValue_1.InvalidValue(`role ${vals[i]} is duplicated`)];
                    }
                }
            },
            actives: (vals) => {
                if (vals.length != this.roles.length) {
                    return [new InvalidValue_1.InvalidValue(`The list of roles and actives must have equal length.`)];
                }
            },
        });
        this.securityId = securityId;
        this.targetId = targetId;
        this.roles = roles;
        this.actives = actives;
    }
}
exports.default = ApplyRolesRequest;
