import{a as I}from"./chunk-3TM4PNYS.js";import{d as P}from"./chunk-7EAWKBIV.js";import{$b as n,Hc as C,I as S,Mc as E,Zc as s,_b as T,dd as A,ed as N,fd as y,na as a,rd as M,s as u}from"./chunk-ATD4AEXQ.js";import{_c as L,ca as i,fa as o,g as h,gd as f,q as v}from"./chunk-BXH3QC5E.js";var w=(()=>{class t{currentComponent;bypassGuardOnce=!1;setCurrentComponent(e){this.currentComponent=e}setBypassGuardOnce(){this.bypassGuardOnce=!0}resetBypassGuard(){this.bypassGuardOnce=!1}shouldNavigateBack(){return this.bypassGuardOnce}checkCanNavigateBack(){return h(this,null,function*(){return this.currentComponent?this.currentComponent.canNavigateBack():!0})}static \u0275fac=function(r){return new(r||t)};static \u0275prov=i({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();var R=(()=>{class t{canDeactivate(e){return e.canNavigateBack()}static \u0275fac=function(r){return new(r||t)};static \u0275prov=i({token:t,factory:t.\u0275fac})}return t})();var p=class{messagePanel;translate;constructor(m,e){this.messagePanel=m,this.translate=e}allowNavigation(){return this.isSomethingChanged()?new Promise(m=>{let e=A.getWarningDefaultConfig().addContentConfig(new N().withMessage(this.translate.instant("MSG_UNSAVED_CHANGES_NAVIGATE"))).withCancelButton(!0).withCloseAction(r=>{m(r)});this.messagePanel.showMessagePanel(e)}):!0}},U=(()=>{class t{canDeactivate(e){return e.allowNavigation()}static \u0275fac=function(r){return new(r||t)};static \u0275prov=i({token:t,factory:t.\u0275fac})}return t})();var d=(()=>{class t{restService;router;translateService;toastMessageService;matDialog;loadingService;redirectToLoginInProgress=!1;constructor(e,r,c,l,O,j){this.restService=e,this.router=r,this.translateService=c,this.toastMessageService=l,this.matDialog=O,this.loadingService=j}closeOpenDialogsAndNavigateToLogin(e){this.closeOpenDialogs(),!this.redirectToLoginInProgress&&(this.redirectToLoginInProgress=!0,this.navigateToLoginAndLogout(e))}closeOpenDialogs(){this.matDialog.closeAll()}logout(){return s.hasValidAuthCredentials()?this.restService.delete(S.LOGOUT):v(null)}navigateToLoginAndLogout(e){this.isUserTriggeredLogout(e)||this.showToastPanelWithTranslatedErrorMessage(e.valueOf()),this.router.navigateByUrl(a.Login.path,{state:{forceNavigation:!0,bypassBackNavigationGuard:!this.isUserTriggeredLogout(e)}}).then(r=>{r?this.logout().subscribe(()=>{this.cleanupActions(e)}):(this.redirectToLoginInProgress=!1,this.loadingService.hideAll())}).catch(n.EMPTY_REJECTION_HANDLER)}cleanupActions(e){this.redirectToLoginInProgress=!1,this.loadingService.hideAll(),this.isUserTriggeredLogout(e)&&window.location.reload(),T.clearLoginLocalStorage(),C.clearSessionStorage()}isUserTriggeredLogout(e){return e===u.TYPE_USER_LOGOUT}showToastPanelWithTranslatedErrorMessage(e){if(n.isNullOrUndefinedOrEmpty(e))return;let r=this.translateService.instant(e);this.toastMessageService.showToastPanel(y.getErrorDefaultConfig().withMessage(r))}static \u0275fac=function(r){return new(r||t)(o(P),o(f),o(L),o(M),o(E),o(I))};static \u0275prov=i({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();var D=(()=>{class t{router;redirectToLoginService;constructor(e,r){this.router=e,this.redirectToLoginService=r}canActivateChild(e,r){if(r.url.includes(`/${a.Login.path}/`)){let c=this.router.currentNavigation().extras.state,l=!1;return!n.isNullOrUndefined(c)&&c.forceNavigation&&(l=!0),s.isFullyAuthenticated()&&!l?(this.router.navigate([a.MainPanel.path]).catch(n.EMPTY_REJECTION_HANDLER),!1):!0}return r.url.includes("/"+a.ChooseBuWorkstation.path)&&!s.hasValidAuthCredentials()?(this.router.navigate([a.Auth.path]).catch(n.EMPTY_REJECTION_HANDLER),!1):s.isFullyAuthenticated()?!0:(this.redirectToLoginService.closeOpenDialogsAndNavigateToLogin(u.TYPE_REFRESH_TOKEN_LOGOUT),!1)}static \u0275fac=function(r){return new(r||t)(o(f),o(d))};static \u0275prov=i({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();export{d as a,D as b,w as c,R as d,p as e,U as f};
