import{t as e}from"./preload-helper.BbTAn5NJ.js";import{n as t,t as n}from"./objectSpread2.C2EWlzLj.js";import{computed as r,createBlock as i,createCommentVNode as a,createElementBlock as o,createElementVNode as s,createTextVNode as c,createVNode as l,inject as u,onMounted as d,onUnmounted as f,openBlock as p,ref as m,resolveComponent as h,toDisplayString as g,unref as _,watch as v,withCtx as y}from"/vue.js";t();var b={id:`nc-error-icon`},x={id:`nc-error-title`},S={id:`nc-error-message`},C={class:`nc-error-row`},w={id:`time-value`},T={key:0,class:`nc-error-row nc-error-countdown`},E={id:`countdown-value`},D=300,O=Object.assign({name:`nc-error-overlay`},{__name:`nc-error-overlay`,emits:[`close`],setup(t,{emit:O}){let k=O,A=u(`state`),j=m(null),M=new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),N=m(`${Math.floor(D/60)}:${(D%60).toString().padStart(2,`0`)}`),P=null,F=r(()=>A.rec.show_error_overlay||``),I={web:{title:`Web Server Offline`,message:`Please start the Capacic Web server.`,icon:`🔌`,autoRetry:!0,buttonText:`Retry`},backend:{title:`Backend Server Offline`,message:`Please make sure the Capacic server is running.`,icon:`🔌`,autoRetry:!0,buttonText:`Retry`},"reload-failed":{title:`Connection Failed`,message:`The app failed to load after multiple attempts.`,icon:`⚠️`,autoRetry:!1,buttonText:`Refresh Page`}},L=r(()=>n(n({},I[F.value]||I.web),{},{error:A.error_overlay_error||``,caller:A.error_overlay_caller||``}));function R(){V(),e(async()=>{let{cancelErrorOverlay:e}=await import(`./nc-reload.B2f1BAXz.js`);return{cancelErrorOverlay:e}},[]).then(({cancelErrorOverlay:e})=>{e()}),k(`close`)}function z(){e(()=>import(`./nc-reload.B2f1BAXz.js`).then(e=>e.resetAndReload()),[])}function B(){if(!L.value.autoRetry)return;V();let e=D;P=setInterval(()=>{if(e--,e<=0){V(),z();return}N.value=`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`},1e3)}function V(){P&&(clearInterval(P),P=null)}v(()=>F.value,e=>{e&&L.value.autoRetry?B():V()},{immediate:!0}),d(()=>{document.addEventListener(`click`,H)});function H(e){if(j.value&&!j.value.contains(e.target)){let t=e.clientX,n=e.clientY;R(),setTimeout(()=>{let e=document.elementFromPoint(t,n);e&&e.click()},50)}}return f(()=>{V(),document.removeEventListener(`click`,H)}),(e,t)=>{let n=h(`nc-row`),r=h(`nc-button`),u=h(`nc-modal`);return p(),i(u,{show:!0,closeOnClick:!0,header:void 0,cancelText:void 0,okText:void 0,onModalCancel:R,onModalOk:R},{default:y(()=>[s(`div`,{class:`nc-error-overlay`,ref_key:`overlayRef`,ref:j},[l(n,{class:`nc-center-h`},{default:y(()=>[s(`div`,b,g(_(L).icon),1)]),_:1}),l(n,{class:`nc-center-h`},{default:y(()=>[s(`div`,x,g(_(L).title),1)]),_:1}),l(n,{class:`nc-center-h`},{default:y(()=>[s(`div`,S,g(_(L).message),1)]),_:1}),l(n,{class:`nc-center-h`},{default:y(()=>[s(`div`,C,[t[0]||(t[0]=c(`Offline since: `,-1)),s(`span`,w,g(_(M)),1)])]),_:1}),l(n,{class:`nc-center-h`},{default:y(()=>[_(L).autoRetry?(p(),o(`div`,T,[t[1]||(t[1]=c(`Auto-retry in `,-1)),s(`span`,E,g(_(N)),1)])):a(``,!0)]),_:1}),l(n,{class:`nc-center-h`},{default:y(()=>[l(r,{class:`nc-button-wide`,onClick:z,icon:`sync`,text:_(L).buttonText},null,8,[`text`])]),_:1})],512)]),_:1})}}});export{O as default};