import{k as d}from"./chunk-5Z3QBZPS.js";import{D as p,R as v}from"./chunk-OGMMZFJL.js";import{Ha as f,I as h,K as u,_ as m,aa as l,f as n,fa as o,g as c,ka as s,p as a}from"./chunk-QVZULMP5.js";var T=(()=>{class i{constructor(t,e){this.router=t,this.ngZone=e,this.timeoutDuration=10*60*1e3,this.activityEvents=["mousemove","mousedown","keypress","keydown","click","touchstart","scroll"],this.onDestroy$=new n,this.isActive=!1,this.eventHandlers={}}initialize(t){t&&(this.timeoutDuration=t),this.start()}start(){this.isActive||(this.isActive=!0,this.resetTimeout(),this.registerActivityEvents())}stop(){this.isActive&&(this.isActive=!1,clearTimeout(this.timeoutTimer),this.removeActivityEvents())}setTimeoutDuration(t){this.timeoutDuration=t,this.isActive&&this.resetTimeout()}resetTimeout(){this.isActive&&(clearTimeout(this.timeoutTimer),this.timeoutTimer=setTimeout(()=>this.handleTimeout(),this.timeoutDuration))}registerActivityEvents(){let t=new n;this.ngZone.runOutsideAngular(()=>{this.activityEvents.forEach(e=>window.addEventListener(e,()=>t.next()))}),t.pipe(u(500),m(this.onDestroy$)).subscribe(()=>{this.ngZone.run(()=>this.resetTimeout())})}removeActivityEvents(){this.activityEvents.forEach(t=>{let e=this.eventHandlers[t];e&&(window.removeEventListener(t,e),delete this.eventHandlers[t])})}handleTimeout(){let t=this.router.url;t!=="/locallogin"&&t!=="/login"&&this.router.navigate(["/logout"])}ngOnDestroy(){clearTimeout(this.timeoutTimer),this.onDestroy$.next(),this.onDestroy$.complete(),this.removeActivityEvents()}static{this.\u0275fac=function(e){return new(e||i)(s(v),s(f))}}static{this.\u0275prov=o({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var L=(()=>{class i{constructor(t,e,r){this.http=t,this.apiService=e,this.idleTimeoutService=r,this.constants={},this.constantsLoadedSubject=new c(!1),this.enableTimeout=!1,this.timeoutDuration=20,typeof globalThis.jasmine<"u"||this.fetchConstants().subscribe()}fetchConstants(){return this.constantsLoadedSubject.value?a(this.constants):this.apiService.portalProperties().pipe(l(t=>{Object.keys(t.body.portalProperties.componentsProperties).forEach(e=>{this.constants[e]=t.body.portalProperties.componentsProperties[e],e==="ENABLE_IDEAL_TIMEOUT"&&(this.enableTimeout=t.body.portalProperties.componentsProperties[e]),e==="IDEAL_TIMEOUT"&&(this.timeoutDuration=t.body.portalProperties.componentsProperties[e])}),this.enableTimeout==!0?(this.idleTimeoutService.setTimeoutDuration(this.timeoutDuration*60*1e3),this.idleTimeoutService.start()):this.idleTimeoutService.stop(),this.constantsLoadedSubject.next(!0)}),h(this.handleError("fetchConstants")))}getConstant(t){return this.constants[t]}areConstantsLoaded(){return this.constantsLoadedSubject.asObservable()}clearConstants(){this.constants={},this.constantsLoadedSubject.next(!1)}handleError(t="operation",e){return r=>(console.error(`${t} failed: ${r.message}`),a(e))}static{this.\u0275fac=function(e){return new(e||i)(s(p),s(d),s(T))}}static{this.\u0275prov=o({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();export{T as a,L as b};
