class IdleDetector{constructor(t={}){this.idleLimit=t.idleLimit||5,this.idleTime=0,this.wasIdle=!1,this.alertSelector=t.alertSelector||".idle-alert",this.toastIdleId=t.toastIdleId||"liveToast",this.toastReturnId=t.toastReturnId||"backToast",this.events=t.events||["mousemove","keydown","scroll","click"],this.interval=null,this.timeout=null,this.init()}init(){this.events.forEach(t=>{window.addEventListener(t,()=>this.resetTimer())}),this.interval=setInterval(()=>{this.idleTime++,this.idleTime===this.idleLimit&&this.setIdleState()},1e3)}resetTimer(){this.idleTime=0;var t=document.querySelector(this.alertSelector);t&&!t.classList.contains("d-none")&&t.classList.add("d-none"),this.wasIdle&&(this.showToast(this.toastReturnId),this.wasIdle=!1)}setIdleState(){this.wasIdle=!0;var t=document.querySelector(this.alertSelector);t&&t.classList.remove("d-none"),this.showToast(this.toastIdleId)}showToast(t){let e=document.getElementById(t);e&&"undefined"!=typeof bootstrap&&bootstrap.Toast&&(this.timeout=setTimeout(()=>{new bootstrap.Toast(e).show()},500))}cleanup(){clearInterval(this.interval),clearTimeout(this.timeout)}}document.addEventListener("DOMContentLoaded",()=>{let t=new IdleDetector;window.addEventListener("beforeunload",()=>{t.cleanup()})});