import { __esDecorate, __runInitializers } from "tslib";
import { AccessRule } from './AccessRule.js';
import { observed, toRaw } from '../../decorators/observed.js';
/**
 * The action is allowed if the authenticated user has a specific role.
 * This is used to enforce role-based access control (RBAC).
 * For example, only users with the "admin" role can perform certain actions.
 */
let MatchUserRoleAccessRule = (() => {
    let _classSuper = AccessRule;
    let _role_decorators;
    let _role_initializers = [];
    let _role_extraInitializers = [];
    return class MatchUserRoleAccessRule extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _role_decorators = [observed({ deep: true })];
            __esDecorate(this, null, _role_decorators, { kind: "accessor", name: "role", static: false, private: false, access: { has: obj => "role" in obj, get: obj => obj.role, set: (obj, value) => { obj.role = value; } }, metadata: _metadata }, _role_initializers, _role_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        type;
        #role_accessor_storage = __runInitializers(this, _role_initializers, void 0);
        get role() { return this.#role_accessor_storage; }
        set role(value) { this.#role_accessor_storage = value; }
        constructor(state = {}) {
            super(state);
            __runInitializers(this, _role_extraInitializers);
            this.type = 'matchUserRole';
            this.role = state.role ? [...state.role] : [];
        }
        toJSON() {
            return {
                ...super.toJSON(),
                role: structuredClone(toRaw(this, this.role)),
            };
        }
    };
})();
export { MatchUserRoleAccessRule };
//# sourceMappingURL=MatchUserRole.js.map