import{t as e}from"./connect.config-Cuh0hj_Q-DrP71hlD.js";var t=[e.routerBasename,`service-worker.js`].join(`/`).replace(/\/{2,}/gm,`/`),n=new class{ready=!1;debug=!1;registration=null;constructor(e=!1){this.debug=e}setDebug(e){this.debug=e}#e(t){this.debug&&console.log(`ServiceWorker message: `,t);let n=`type`in t.data?t:null;switch(n?.data.type){case`NEW_VERSION_AVAILABLE`:if(n.data.version===e.appVersion)return;n.data.requiresHardRefresh&&(this.debug&&console.log(`New version available`),window.location.reload());break;default:console.warn(`Unhandled message:`,n);break}}#t(e){this.debug&&console.log(`ServiceWorker registered: `,e),navigator.serviceWorker.addEventListener(`message`,this.#e.bind(this)),this.registration=e,this.ready=!0}async#n(){try{let n=await navigator.serviceWorker.getRegistration();if(n)await n.update(),this.#t(n);else{let e=await navigator.serviceWorker.register(t);this.#t(e),e.addEventListener(`updatefound`,()=>{this.#t(e)})}let r=setInterval(async()=>{let e=await navigator.serviceWorker.getRegistration();e?await e.update():(clearInterval(r),this.registerServiceWorker())},e.appVersionCheckInterval)}catch(e){console.error(`ServiceWorker registration failed: `,e)}}registerServiceWorker(e=!1){if(this.debug=e,!(`serviceWorker`in navigator)){console.warn(`Service Worker not available`);return}window.addEventListener(`load`,()=>{this.#n().catch(console.error)})}};export{n as t};
//# sourceMappingURL=registerServiceWorker-LI8_JXt3-D97JUIqb.js.map