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