import{a7 as g,j as e,a8 as S,r as y,aF as C,h as r,S as l,q as V,t as L,m as A,T as I,a1 as R}from"./vendor-ClLR6ncd.js";import{d as w,i as d,E as W,ar as D,o as M,L as h}from"./index-OtVJl4GC.js";import"./lodash-ZyeDnt0e.js";import{B as c}from"./Box-Co2WcNPC.js";import{R as T}from"./RefreshDataButton-BMv_Vwgi.js";import{C as p}from"./Chip-DoCs8Smb.js";var u={},k=S;Object.defineProperty(u,"__esModule",{value:!0});var f=u.default=void 0,B=k(g()),E=e;f=u.default=(0,B.default)((0,E.jsx)("path",{d:"m12 16.5 4-4h-3v-9h-2v9H8zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2"}),"SystemUpdateAlt");function _(){return W(["current-webview"],async()=>{const a=await d({url:"/webview/version"});return a.date=new Date(a.date).toLocaleString(),a})}function q(){return w(async({pullVersions:a})=>{const t=await d({url:"/webview/versions",params:{"pull-versions":a}});for(const s of t.available)s.date=new Date(s.date);return{...t,pullVersions:a}})}function z(a){return w(t=>d({method:"put",url:"/webview/version",params:{version:t}}),{...a,onSettled:()=>{a==null||a.onSettled(),D.invalidateQueries(["current-webview"])}})}const F={position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",bgcolor:"background.paper",boxShadow:24,p:4};function G({children:a}){const[t,s]=y.useState(!1),i=z({onSettled:()=>{s(!1)},onSuccess:()=>{window.location.reload()},onMutate:()=>{s(!0)}});return e.jsxs(e.Fragment,{children:[e.jsx(C,{open:t,onClose:()=>{},children:e.jsx(c,{sx:F,children:e.jsx(r,{variant:"h4",children:"Updating WebView version..."})})},"modal-window"),a({changeVersion:i.mutate})]})}function N(){const a=q(),t=_(),s=M();return e.jsx(G,{children:({changeVersion:i})=>{var x,v;return e.jsx(l,{spacing:s,sx:{flexGrow:1,textAlign:"left"},children:t.isSuccess?e.jsxs(e.Fragment,{children:[e.jsxs(l,{direction:"row",spacing:1,justifyContent:"space-between",children:[e.jsx(r,{variant:"h4",children:"WebView versions"}),e.jsx(T,{disabled:a.isLoading,onClick:a.mutate})]}),e.jsxs(r,{variant:"h6",children:["Current version:"," ",e.jsxs(r,{component:"span",children:[(x=t.data)==null?void 0:x.version," (",(v=t.data)==null?void 0:v.date,")"]})]}),e.jsx(r,{variant:"h6",children:"Available versions:"}),a.isIdle?e.jsx(r,{children:'Click on "REFRESH DATA" button above to get a list of available versions from franz.com.'}):a.isSuccess?a.data.available.length===0?e.jsx(r,{children:"There are no WebView versions available."}):e.jsx(V,{disablePadding:!0,children:a.data.available.map(({date:j,version:n},b)=>{const o=n===a.data.current,m=b===0;return e.jsx(L,{sx:[{pl:1,pr:1},o?{backgroundColor:"primary.appBar"}:void 0],disableGutters:!0,secondaryAction:o?null:e.jsx(I,{title:"Download and install",children:e.jsx(R,{size:"large",onClick:()=>i(n),children:e.jsx(f,{fontSize:"inherit"})})}),children:e.jsx(A,{primary:e.jsxs(l,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(r,{children:n}),o?e.jsx(p,{label:"current"}):null,m?e.jsx(p,{label:"latest",color:"primary"}):null]}),secondary:j.toLocaleString()})},n)})}):e.jsx(c,{flexGrow:1,children:e.jsx(h,{})})]}):e.jsx(c,{sx:{display:"flex",alignItems:"center",flexGrow:1},children:e.jsx(h,{})})})}})}export{N as default};
