(function(){window.WorkflowService=function(componentInstanceId,handledRoles){this.promiseRoleManager=function(){const mappingOfUserRoles={};const promises=[];const __load=function(roleName){return User.get({component:componentInstanceId,userStatesToExclude:["DEACTIVATED"],includeRemoved:true,roles:roleName}).then(function(users){users.forEach(function(user){let userRoles=mappingOfUserRoles[user.id];if(!userRoles){userRoles=[];mappingOfUserRoles[user.id]=userRoles}userRoles.push(roleName)})})};for(let roleName in handledRoles){handledRoles[roleName].name=
roleName;promises.push(__load(roleName))}return sp.promise.whenAllResolved(promises).then(function(){return new function(){this.getRolesOfComponentInstance=function(){const roles=[];for(let roleName in handledRoles)roles.push(extendsObject({},handledRoles[roleName]));return roles};this.getRolesOfUser=function(userId){const roles=[];const mappingOfUserRole=mappingOfUserRoles[userId]||[];mappingOfUserRole.forEach(function(roleName){roles.push(extendsObject({},handledRoles[roleName]))});return roles};
this.getMatchingRoles=function(userId,otherUserId){if(userId&&otherUserId){const userRoles=this.getRolesOfUser(userId);const substituteRoles=this.getRolesOfUser(otherUserId);return userRoles.filter(function(role){return substituteRoles.indexOfElement(role,"name")>=0})}};this.getNotMatchingRoles=function(userId,otherUserId){if(userId&&otherUserId){const userRoles=this.getRolesOfUser(userId);const substituteRoles=this.getRolesOfUser(otherUserId);return userRoles.filter(function(role){return substituteRoles.indexOfElement(role,
"name")<0})}}}})}}})();