const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/nc-dropdown.DhmgfxJS.css","assets/transition.CvUO2vaL.css","assets/nc-progress.CH-8wlT8.css","assets/nc-main.D1w4vh_Q.css"])))=>i.map(i=>d[i]);
import{t as e}from"./preload-helper.BbTAn5NJ.js";import{t}from"./nc-session.ixzqfs6Y.js";var n=null;async function r(){n==null&&(n=await e(()=>import(`./nc-service-worker.Aow4I0zo.js`),[]))}var i=4,a=40,o=`reload-count`,s=`reload-info`,c=`error-overlay`,l=null,u=0,d=``;function f(e,t=3e3){l==null&&(l=setTimeout(()=>{m(e),d||(d=e),l=null},t))}function p(){l&&(clearTimeout(l),l=null),m(``),g()}function m(n){t.setLocalData(c,n),d=n,e(async()=>{let{mainState:e}=await import(`./nc-state.CPuytqVj.js`);return{mainState:e}},__vite__mapDeps([0,1,2,3])).then(({mainState:e})=>{let t=e();t.rec.show_error_overlay=n})}function h(){return t.getLocalData(c)||``}function g(){t.deleteLocalData(c)}async function _(e,c=``){let l=parseInt(t.getLocalData(o)||`0`)||0;if(l>=i){l==i&&(l+=1,t.setLocalData(o,l),setTimeout(()=>{console.warn(`•-• reload: max error already shown, clearing reload count, caller ${e}, error ${c}`),v()},a*8),console.error(`•-• reload: max error already shown, ignoring reload call, caller ${e}, error ${c}`),T());return}let d=Date.now()-u;if(d<300){console.debug(`•-• reload: ignoring error too soon after cache success, timeSinceCacheSuccess=${d}ms, caller ${e}, error ${c}`);return}console.warn(`•-• reload called: caller ${e}, count: ${l}, error: ${c}, time: ${Date.now()}`),l<i?(l+=1,t.setLocalData(o,l),t.setLocalData(s,JSON.stringify({caller:e,error:c})),console.warn(`•-• reload: count=${l}`),l===1?setTimeout(()=>{console.warn(`•-• reload: count=${l}, soft reload`),S(!1)},a):l===2?setTimeout(()=>{console.warn(`•-• reload: count=${l}, hard reload`),S(!0)},a*2):l===3?(console.warn(`•-• reload: count=${l}, reinstalling service worker`),await r(),n.removeServiceWorker(`install`,()=>{setTimeout(()=>{console.warn(`•-• reload: count=${l}, service worker reinstalled, soft reload`),S(!1)},a*3)})):(console.warn(`•-• reload: count=${l}, reinstalling service worker`),await r(),n.removeServiceWorker(`install`,()=>{setTimeout(()=>{console.warn(`•-• reload: count=${l}, service worker reinstalled, hard reload`),S(!0)},a*4)}))):(console.error(`•-• reload: max attempts reached, caller ${e}, error ${c}`),T())}function v(){let e=parseInt(t.getLocalData(o)||`0`)||0;if(e>0){let n=t.getLocalData(s),r=n?JSON.parse(n):{};console.debug(`•-• reload cleared: caller ${r.caller}, count=${e}, error=${r.error}`),t.deleteLocalData(o),t.deleteLocalData(s)}}function y(){v(),p()}function b(e){var t,n;return e&&((t=e.message)!=null&&t.includes(`text/html`)||(n=e.message)!=null&&n.includes(`Failed to load module script`)||e.toString().includes(`text/html`))?(console.warn(`🔄 Module MIME type error detected, triggering refresh`),_(`mime-type`,e.message||`MIME type error`),!0):!1}function x(){t.deleteLocalData(o)}function S(e=!0){location.reload(e)}function C(){t.deleteLocalData(o),t.deleteLocalData(s),g(),S(!0)}function w(e){var t;_(`service-worker`,`${(t=e.data)==null?void 0:t.type}: ${e.data.url}`)}function T(){let e=t.getLocalData(s),n=e?JSON.parse(e):{},r=n.caller||``,i=n.error||``;console.error(`Automatic reload failed: ${r===`service-worker`?`Build Error`:`Connection Failed`}, error: ${i}, caller: ${r}`),f(`backend`)}export{p as cancelErrorOverlay,b as checkMimeTypeError,g as clearErrorOverlay,y as clearErrorState,v as clearReloadCount,x as clearServiceWorkerCount,S as doReload,h as getErrorOverlay,w as onServiceWorkerMessage,_ as reload,C as resetAndReload,m as setErrorOverlay,f as showErrorOverlay};