(function(){window.CommunityMembershipService=function(context){const repository=new CommunityMembershipRepository(context);this.getOwnMembershipOf=function(){return repository.getMembershipOf(currentUser.id)};this.getMembers=function(){return repository.getMembers()};this.join=function(){return repository.join()};this.validateJoinRequest=function(user,accept,message){return repository.validateJoinRequest(user,accept,message)};this.leave=function(reason){return repository.leave(reason)}};const CommunityMember=
function(){this.type="CommunityMember";this.$onInit=function(){}};const CommunityMembershipRepository=function(context){const baseUri=webContext+"/services/community/"+context.componentInstanceId+"/memberships";const baseAdapter=RESTAdapter.get(baseUri,CommunityMember);const ctlBaseUri=webContext+"/Rcommunity/"+context.componentInstanceId;const ctlBaseAdapter=RESTAdapter.get(ctlBaseUri,CommunityMember);this.getMembershipOf=function(userId){let targetedUser=userId===currentUser.id?"me":userId;return baseAdapter.find({url:baseAdapter.url+
"/users/"+targetedUser})};this.getMembers=function(){let criteria=baseAdapter.criteria({page:{number:1,size:1}});return baseAdapter.find({url:baseAdapter.url+"/members",criteria:criteria}).then(function(members){const memberships=members.memberships;memberships.realSize=members.realSize;return memberships})};this.join=function(){return ctlBaseAdapter.post(ctlBaseAdapter.url+"/members/join",{})};this.validateJoinRequest=function(user,accept,message){const formData=new FormData;formData.set("accept",
accept);formData.set("message",message);return ctlBaseAdapter.post(ctlBaseAdapter.url+"/members/join/validate/"+user.id,formData)};this.leave=function(reason){const formData=new FormData;formData.set("reason",reason.reason);formData.set("message",reason.message);formData.set("contactInFuture",reason.contactInFuture);return ctlBaseAdapter.post(ctlBaseAdapter.url+"/members/leave",formData)}};window.CommunityMembershipService.prototype.Constants={MembershipStatus:{COMMITTED:"COMMITTED",PENDING:"PENDING",
REFUSED:"REFUSED",REMOVED:"REMOVED"}}})();