import{l as o,m as h}from"./chunk-4YA5J5ZW.js";import{A as s,Za as r,c,y as l}from"./chunk-4BILO7NM.js";var p=(()=>{let t=class t{constructor(e,i){this.http=e,this.authRefService=i,this.onlineCheckInitialized=!1,this.checkingOnlineStatus=!1,this.online=new c(!1),this.watchAuth()}watchAuth(){this.authSubscription=this.authRefService.authenticated.subscribe({next:e=>{e?this.initOnlineCheck():this.stopOnlineCheck()}})}setOnlineStatus(e){this.online.next(e)}scheduleNextOnlineCheck(){this.onlineTimer=window.setTimeout(()=>{this.checkOnlineStatus()},2500)}checkOnlineStatus(){this.checkingOnlineStatus||(window.clearTimeout(this.onlineTimer),this.checkingOnlineStatus=!0,this.http.get("{{openApi}}/helpers/talk-to-me-goose").subscribe({next:()=>{this.setOnlineStatus(!0),this.checkingOnlineStatus=!1,this.scheduleNextOnlineCheck()},error:i=>{i.message.includes("NG0200")||this.setOnlineStatus(!1),this.checkingOnlineStatus=!1,this.scheduleNextOnlineCheck()}}))}stopOnlineCheck(){window.clearTimeout(this.onlineTimer),this.onlineCheckInitialized=!1}initOnlineCheck(){this.onlineCheckInitialized||(this.checkOnlineStatus(),this.onlineCheckInitialized=!0)}get apiUrl(){return h.API_URL}getContentUrl(e){let i=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${h.CONTENT_URL}/${i}`}ngOnDestroy(){this.authSubscription?.unsubscribe(),window.clearTimeout(this.onlineTimer)}};t.\u0275fac=function(i){return new(i||t)(s(r),s(o))},t.\u0275prov=l({token:t,factory:t.\u0275fac});let n=t;return n})();export{p as a};
