import{b0 as P,az as p,aI as C,ao as e,aF as v,L as N,aP as i,aq as d,bU as a}from"./app-k0jcl5PQ.js";import{L as u}from"./F6ooBnzv.chunk.js";var o=(s=>(s[s.Scheduled=1]="Scheduled",s[s.InProgress=2]="InProgress",s[s.Completed=3]="Completed",s[s.Error=4]="Error",s))(o||{});const t="settings.updateLocalCache",c=N.encloseNamespace(t);function I(s,r){var n;if(!r)return null;if(((n=r.currentBuild)==null?void 0:n.version)===r.latestBuild.version)return"success";if(!s||s.buildId!==r.latestBuild.id)return"update-available";switch(s==null?void 0:s.status){case o.Completed:return"success";case o.Error:return"error";case o.Scheduled:return"scheduled";case o.InProgress:return"updating"}}function E(s){const r=P(),n=p(u.updates(s.deviceId)),x=p(u.deviceUpdate(s.deviceId)),[m,h]=C.useState(!1);function j(){h(!0),r(u.update(s.deviceId,n.data.latestBuild.version)).finally(()=>h(!1))}C.useEffect(()=>{const f=window.setInterval(()=>{r(u.deviceUpdate(s.deviceId))},5e3);return()=>window.clearInterval(f)},[]);const l=I(x.data,n.data),g=!!l&&!!x.hasCompleted&&!!n.hasCompleted;return e.jsx(v,{title:c("title"),closePopup:s.closePopup,showLoadingSpinner:!g,children:g&&e.jsxs(e.Fragment,{children:[l==="success"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-center mb-3",children:e.jsx("img",{src:i.LocalCache.UP_TO_DATE,className:"img-fliud"})}),e.jsx("p",{children:e.jsx(d,{namespace:t,phrase:"upToDate"})}),e.jsx(a,{children:e.jsx(a.Cancel,{onClick:s.closePopup,className:"me-0",text:c("close"),variant:"dark"})})]}),l==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-center mb-3",children:e.jsx("img",{src:i.LocalCache.ERROR,className:"img-fliud"})}),e.jsx("p",{children:e.jsx(d,{namespace:t,phrase:"error"})}),e.jsxs(a,{children:[e.jsx(a.Cancel,{onClick:s.closePopup,text:c("close")}),e.jsx(a.Submit,{onClick:j,text:c("retry"),variant:"dark",showSpinner:m})]})]}),l==="scheduled"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-center mb-3",children:e.jsx("img",{src:i.LocalCache.SCHEDULED,className:"img-fliud"})}),e.jsx("p",{children:e.jsx(d,{namespace:t,phrase:"scheduled"})}),e.jsx(a,{children:e.jsx(a.Cancel,{onClick:s.closePopup,className:"me-0",text:c("close"),variant:"dark"})})]}),l==="update-available"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-center mb-3",children:e.jsx("img",{src:i.LocalCache.UPDATE_AVAILABLE,className:"img-fliud"})}),e.jsx("p",{children:e.jsx(d,{namespace:t,phrase:"updateAvailable"})}),e.jsxs(a,{children:[e.jsx(a.Cancel,{onClick:s.closePopup}),e.jsx(a.Submit,{onClick:j,text:c("update"),variant:"dark",showSpinner:m})]})]}),l==="updating"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-center mb-3",children:e.jsx("img",{src:i.LocalCache.UPDATING,className:"img-fliud"})}),e.jsx("p",{children:e.jsx(d,{namespace:t,phrase:"updating"})}),e.jsx(a,{children:e.jsx(a.Cancel,{onClick:s.closePopup,className:"me-0",text:c("close"),variant:"dark"})})]})]})})}export{E as UpdateLocalCacheView};
//# sourceMappingURL=Cdo1x7XB.chunk.js.map
