import{a as y}from"./chunk-EA3HR36B.js";import{v}from"./chunk-POWTZQEB.js";import"./chunk-AZNUVYH2.js";import"./chunk-4SQIPONB.js";import"./chunk-OMYRNWA7.js";import"./chunk-DQZNL7BK.js";import{a as b}from"./chunk-BAEZMG5T.js";import{a as h}from"./chunk-C72E7DYO.js";import"./chunk-WIPHIZE3.js";import"./chunk-LXYD2H4H.js";import"./chunk-IEDTWYT7.js";import"./chunk-TMA5MVRB.js";import"./chunk-VRBUVT76.js";import"./chunk-VUFRXBL5.js";import"./chunk-AG5UR6GS.js";import"./chunk-XXT62TCF.js";import"./chunk-YUC4NXDM.js";import"./chunk-6P3ZDNP3.js";import"./chunk-VP22RGQG.js";import"./chunk-3FDFNYAA.js";import"./chunk-3HDMTDNY.js";import"./chunk-YR6PJKN6.js";import"./chunk-HVO2LBIZ.js";import"./chunk-JU53QNJX.js";import"./chunk-EMJJQSXR.js";import"./chunk-2G4GCCRX.js";import"./chunk-KAJE4RE3.js";import"./chunk-H6QVTBMZ.js";import"./chunk-XNR6WIGX.js";import"./chunk-5KOP4ULD.js";import"./chunk-F2X3VGZZ.js";import"./chunk-RYV2RH4B.js";import"./chunk-CV2ZWZQE.js";import"./chunk-R2UR7BVM.js";import{q as g}from"./chunk-HKLJ6VPZ.js";import"./chunk-MQ46LYK7.js";import"./chunk-PQ5Q7HJL.js";import"./chunk-72CHOCZD.js";import{Eb as f,Fb as P,G as o,Gb as c,O as l,Ua as d,Y as t,f as p,gb as u,tb as n}from"./chunk-56X5LYJH.js";import{a as m}from"./chunk-TSRGIXR5.js";var S=class a{userPermissions=[];userPermissionsEndPoint="";subTitleOfPage="";detail;loading=!0;destroy$=new p;userId;route=t(g);_apiService=t(h);permissionFormService=t(y);ngOnInit(){this.getUserId(),this.buildFormFields(),this.loadDetail()}getUserId(){this.userId=this.route.snapshot.paramMap.get("id"),this.userPermissionsEndPoint="permission/update/"+this.userId}buildFormFields(){this.loadPermissions()}loadPermissions(){this.loading=!1,this.permissionFormService.loadPermissionsAsAccordion().pipe(o(()=>this.loading=!0)).subscribe(e=>{this.userPermissions=[...this.userPermissions,...e]})}loadDetail(){this.userId&&(this.loading=!1,this._apiService.GetById("permission",this.userId).pipe(l(this.destroy$),o(()=>this.loading=!0)).subscribe({next:e=>{this.subTitleOfPage=e.data.full_name+" - "+e.data.position,this.detail={facilities:e.data.facilities.map(i=>{let s={};return i.roles?.forEach(r=>{s[`roles_${r.id}`]=r.permissions?.map(F=>F.id)||[]}),m({id:i.id,name:i.name,Permissions:i.permissions?.map(r=>r.id)||[]},s)})}},error:e=>{console.error("Error fetching user permission details",e)}}))}static \u0275fac=function(i){return new(i||a)};static \u0275cmp=u({type:a,selectors:[["app-user-permission"]],decls:2,vars:12,consts:[["appShowLoaderUntilPageLoaded","",3,"isReady"],["translationPrefix","manualPermissions","routeAfterSuccess","/home/permissions/all","fileNameTranslated","shared",3,"titleOfPage","subTitleOfPage","ApplySubTranslationprefixTitle","fields","Put","url","formValues","titleOfButton","ApplyTranslationprefix","useMethodPut","titleImgSrc"]],template:function(i,s){i&1&&(f(0,"div",0),c(1,"app-main-form",1),P()),i&2&&(n("isReady",s.loading),d(),n("titleOfPage","userPermission")("subTitleOfPage",s.subTitleOfPage)("ApplySubTranslationprefixTitle",!1)("fields",s.userPermissions)("Put",!0)("url",s.userPermissionsEndPoint)("formValues",s.detail)("titleOfButton","savePermissions")("ApplyTranslationprefix",!0)("useMethodPut",!0)("titleImgSrc","assets/images/entry.png"))},dependencies:[v,b],encapsulation:2})};export{S as UserPermissionComponent};
