import{Gr as re,Ln as be,Vr as qe}from"./chunk-DR8zdE1B.js";import{w as No}from"./chunk-MsEEQtoP.js";import{t as d}from"./chunk-BxwW_nba.js";import{t as e}from"./chunk-11TDjXx7.js";function c(e){this.message=e}c.prototype=new Error,c.prototype.name=`InvalidCharacterError`;var f=typeof window<`u`&&window.atob&&window.atob.bind(window)||function(e){var n=String(e).replace(/=+$/,``);if(n.length%4==1)throw new c(`'atob' failed: The string to be decoded is not correctly encoded.`);for(var t,r,i=0,o=0,s=``;r=n.charAt(o++);~r&&(t=i%4?64*t+r:r,i++%4)&&(s+=String.fromCharCode(255&t>>(-2*i&6))))r=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`.indexOf(r);return s};function m(e){var n=e.replace(/-/g,`+`).replace(/_/g,`/`);switch(n.length%4){case 0:break;case 2:n+=`==`;break;case 3:n+=`=`;break;default:throw`Illegal base64url string!`}try{return(function(t){return decodeURIComponent(f(t).replace(/(.)/g,(function(r,i){var o=i.charCodeAt(0).toString(16).toUpperCase();return o.length<2&&(o=`0`+o),`%`+o})))})(n)}catch{return f(n)}}function a(e){this.message=e}function b(e,n){if(typeof e!=`string`)throw new a(`Invalid token specified`);var t=(n=n||{}).header===!0?0:1;try{return JSON.parse(m(e.split(`.`)[t]))}catch(r){throw new a(`Invalid token specified: `+r.message)}}a.prototype=new Error,a.prototype.name=`InvalidTokenError`;var w=b;var C=(()=>{class e$1{constructor(t){this.http=t,this.baseUrl=e.apiBaseUrl+`/api/v1`}login(t){return this.getTokenInfo(`${this.baseUrl}/auth/login`,t)}changePassword(t){return this.getTokenInfo(`${this.baseUrl}/auth/change-password`,t)}sendMagicLoginUrl(t){return this.http.post(`${this.baseUrl}/auth/magic-login`,{destination:t.email,redirectTo:t.redirectTo})}register(t){return this.http.post(`${this.baseUrl}/users`,t)}firstRun(t){return this.http.post(`${this.baseUrl}/organisations`,t)}lostPassword(t){return this.http.post(`${this.baseUrl}/auth/lost-password`,t)}resetPassword(t){return this.http.post(`${this.baseUrl}/auth/reset-password`,t)}magicLogin(t){return this.getTokenInfo(`${e.apiBaseUrl}${t.url}`)}listOrganisationsForCurrentUser(){return this.http.get(`${this.baseUrl}/users/organisations`)}switchOrganisation(t){return this.getTokenInfo(`${this.baseUrl}/auth/switch-organisation`,t)}getEntraIdLoginUrl(){return this.http.get(`${this.baseUrl}/auth/entra-id/login`)}loginWithEntraId(t){return this.getTokenInfo(`${this.baseUrl}/auth/entra-id/callback`,t)}getTokenInfo(t,r){return(r?this.http.post(t,r):this.http.get(t)).pipe(be(o=>{let s=w(o.access_token);return{token:o.access_token,currentUser:s}}))}static{this.ɵfac=function(r){return new(r||e$1)(qe(No))}}static{this.ɵprov=re({token:e$1,factory:e$1.ɵfac,providedIn:d})}}return e$1})();export{w as n,C as t};
//# debugId=f447b15c-24f2-5866-8882-2d14176682f1
//# sourceMappingURL=chunk-D422i2Ov.js.map