import{a as h,b as l}from"./chunk-DFE67JWZ.js";var d=class{constructor(t,e,i,a,o,c,u){this.datePipe=t,this.toastr=e,this.cdr=i,this.router=a,this.sharedService=o,this.translatorService=c,this.dataManagementService=u,this.list=[],this.sortedList=[],this.sortDirection=!1,this.searchUser="",this.filteredList=[],this.noUsersFound=!1,this.showNavigation=!1,this.next="",this.previous="",this.last="",this.first="",this.currentpageCount=0,this.totalpageCount=0,this.sortColumn="userName",this.selectedRadio="",this.parseResponse=s=>r=>{this.list=r.body.data,this.list=r.body.data.map(n=>l(h({},n),{userNameEncoded:btoa(n.userName)})),this.filteredList=[...this.list],this.sortTable(this.sortColumn),r.body.metadata?(this.showNavigation=!0,this.next=r.body.metadata.links?.next,this.previous=r.body.metadata.links?.previous,this.last=r.body.metadata.links?.last,this.first=r.body.metadata.links?.first,this.currentpageCount=r.body.metadata.pageNumber,this.totalpageCount=Math.ceil(r.body.metadata.totalCount/r.body.metadata.recordsPerPage)):this.showNavigation=!1,s?s():this.cdr.detectChanges()},this.parseError=s=>{switch(s.status){case 400:console.error("Bad Request: ",s.message);break;case 401:console.error("Unauthorized: ",s.message),this.toastr.error(this.translatorService.getTranslation("Token expired, navigating to logout page."),this.translatorService.getTranslation("Error")),setTimeout(()=>{this.router.navigate(["/logout"])},3e3);break;case 403:console.error("Forbidden: ",s.message);break;case 404:console.error("Not Found: ",s.message);break;case 447:this.toastr.info(this.translatorService.getTranslation("Changes were not saved.  The User is under Legal hold. Please contact your Administrator."),this.translatorService.getTranslation("Info"));break;case 500:console.error("Internal Server Error: ",s.message);break;case 503:console.error("Internal Server Error: ",s.message);break;default:console.error("Unknown Error: ",s.message);break}}}getFormattedDate(t){return this.datePipe.transform(t,"dd-MMM-yyyy HH:mm:ss")||""}sendMeTo(t,e){e!=""&&this.sharedService.setData("currentPolicyName",e),this.router.navigate([t])}getAll(t,e){return this.sortedList=[],this.sortDirection=!1,this.dataManagementService.getAll(t).subscribe(this.parseResponse(e),this.parseError)}getAll_Navigate(t,e){this.sortedList=[],this.sortDirection=!1,this.dataManagementService.getAll_Navigate(t,e).subscribe(this.parseResponse(),this.parseError)}sortTable(t){this.sortColumn===t?this.sortDirection=!this.sortDirection:(this.sortColumn=t,this.sortDirection=!0),this.applySorting()}applySorting(){this.sortedList=this.filteredList.sort((t,e)=>{let i=t[this.sortColumn]||"",a=e[this.sortColumn]||"";typeof i=="string"&&(i=i.toLowerCase()),typeof a=="string"&&(a=a.toLowerCase());let o=0;return i>a?o=1:i<a&&(o=-1),this.sortDirection?o:-o})}getCaretClass(t){return this.sortColumn===t?this.sortDirection?"fa fa-caret-up":"fa fa-caret-down":""}trackByUser(t,e){return e.userName}filterUsers(){this.searchUser=this.searchUser.trim();let t=this.searchUser.toLowerCase();this.filteredList=this.list.filter(e=>e.userName?.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t)||e.emailId?.toLowerCase().includes(t)),this.noUsersFound=this.filteredList.length===0,this.applySorting()}};export{d as a};
/**i18n:0c85d88e1c63ff70ec487b533ab43e97f8cd56e4c41bc493c1dbcaa27295944a*/
