import{t as e}from"./DXb0ZbaM.js";var t=`false`,n=`false`,r=t===`true`,i=n===`true`;function a(t={}){let{immediate:n=!1,onNeedReload:a,onNeedRefresh:o,onOfflineReady:s,onRegistered:c,onRegisteredSW:l,onRegisterError:u}=t,d,f,p,m=async(e=!0)=>{await f,r||p?.()};async function h(){if(`serviceWorker`in navigator){if(d=await e(async()=>{let{Workbox:e}=await import(`./BerRZVxl.js`);return{Workbox:e}},[],import.meta.url).then(({Workbox:e})=>new e(`./sw.js`,{scope:`./`,type:`classic`})).catch(e=>{u?.(e)}),!d)return;if(p=()=>{d?.messageSkipWaiting()},!i)if(r)d.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&(a?a():window.location.reload())}),d.addEventListener(`installed`,e=>{e.isUpdate||s?.()});else{let e=!1,t=()=>{e=!0,d?.addEventListener(`controlling`,e=>{e.isUpdate&&(a?a():window.location.reload())}),o?.()};d.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&s?.():n.isExternal?t():!e&&s?.():n.isUpdate||s?.()}),d.addEventListener(`waiting`,t)}d.register({immediate:n}).then(e=>{l?l(`./sw.js`,e):c?.(e)}).catch(e=>{u?.(e)})}}return f=h(),m}export{a as registerSW};