1import{a as i}from"./chunk-DTRHVFGO.js";import{e as l}from"./chunk-B5KTUONW.js";import{v as h}from"./chunk-WG6V4GBL.js";import{T as p,Y as u,a as c,b as m,na as n,p as s,pc as o}from"./chunk-TDJMGW2J.js";function d(r){return r.institucion_id!=null||r.codigo!=null?"usuario_institucion":"usuario"}var g=class r{http=u(h);router=u(l);currentUser=n(null);isAuthenticated=o(()=>!!this.currentUser());permissions=o(()=>this.currentUser()?.permisos??[]);subjectType=o(()=>this.currentUser()?.subjectType??null);activeInstitucionId=n(null);misInstituciones=n([]);hasPermission(t){return this.permissions().includes(t)}hasAnyPermission(t){return t.some(e=>this.permissions().includes(e))}setCurrentUser(t){let e=m(c({},t),{subjectType:t.subjectType??d(t)});return this.currentUser.set(e),this.activeInstitucionId.set(e.activeInstitucionId??e.institucion_id??null),e}async login(t,e){let a=await s(this.http.post(`${i.apiUrl}/auth/login`,{email:t,clave:e}));return this.setCurrentUser(a),a}async logout(){try{await s(this.http.post(`${i.apiUrl}/auth/logout`,{}))}catch{}this.currentUser.set(null),this.activeInstitucionId.set(null),this.misInstituciones.set([]),this.router.navigate(["/auth/login"])}async getMe(){let t=await s(this.http.get(`${i.apiUrl}/auth/me`));return this.setCurrentUser(t),t}async loadMisInstituciones(){let t=await s(this.http.get(`${i.apiUrl}/auth/me/instituciones`));return this.misInstituciones.set(t),t}async switchInstitucion(t){let e=await s(this.http.post(`${i.apiUrl}/auth/switch-institucion`,{institucionId:t}));return this.setCurrentUser(e)}async refreshToken(){await s(this.http.post(`${i.apiUrl}/auth/refresh`,{}))}async recoveryPassword(t){return s(this.http.post(`${i.apiUrl}/auth/recovery-password`,{email:t}))}async changePassword(t,e){return s(this.http.post(`${i.apiUrl}/auth/cambiar-clave`,{claveActual:t,claveNueva:e}))}static \u0275fac=function(e){return new(e||r)};static \u0275prov=p({token:r,factory:r.\u0275fac,providedIn:"root"})};export{g as a};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.