import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{Fr as n,Nn as r,Xn as i,Xr as a}from"./vendor-primevue-Cg-HmKZY.js";import{Q as o,Xn as s,fn as c,nn as l,tn as u}from"./vendor-other-CoxDvJ0a.js";import{n as d,r as f}from"./vendor-vue-J4jYbuLn.js";import{an as p,dn as m,dt as h,on as g,un as _,ut as v}from"./api-CJ30itpV.js";import{M as y,O as b,j as x,y as S}from"./PanelTemplate-hGipIJT8.js";import{Uo as C,Wo as w,fo as T,po as E}from"./dialogService-DvYmp2_F.js";var D,useReleaseService,O=t((()=>{u(),r(),w(),v(),D=l.create({baseURL:C(),headers:{"Content-Type":`application/json`}}),useReleaseService=()=>{let e=a(!1),t=a(null);n(()=>C(),e=>{D.defaults.baseURL=e});let handleApiError=(e,t,n)=>{if(!l.isAxiosError(e))return e instanceof Error?`${t}: ${e.message}`:`${t}: Unknown error occurred`;let r=e;if(r.response){let{status:e,data:i}=r.response;if(n&&n[e])return n[e];switch(e){case 400:return`Bad request: ${i?.message||`Invalid input`}`;case 401:return`Unauthorized: Authentication required`;case 403:return`Forbidden: ${i?.message||`Access denied`}`;case 404:return`Not found: ${i?.message||`Resource not found`}`;case 500:return`Server error: ${i?.message||`Internal server error`}`;default:return`${t}: ${i?.message||r.message}`}}return`${t}: ${r.message}`},executeApiRequest=async(n,r,i)=>{e.value=!0,t.value=null;try{return(await n()).data}catch(e){return h(e)||(t.value=handleApiError(e,r,i)),null}finally{e.value=!1}},getReleases=async(e,t)=>await executeApiRequest(()=>D.get(`/releases`,{params:e,signal:t}),`Failed to get releases`,{400:`Invalid project or version parameter`});return{isLoading:e,error:t,getReleases}}})),k,A,j=t((()=>{c(),f(),k=o(),r(),p(),T(),x(),_(),S(),O(),A=d(`release`,()=>{let e=a([]),t=a(!1),n=a(null),r=useReleaseService(),o=y(),c=E(),l=i(()=>g?o?.systemStats?.system?.cloud_version??``:o?.systemStats?.system?.comfyui_version??``),u=i(()=>c.get(`Comfy.Locale`)),d=i(()=>c.get(`Comfy.Release.Version`)),f=i(()=>c.get(`Comfy.Release.Status`)),p=i(()=>c.get(`Comfy.Release.Timestamp`)),h=i(()=>c.get(`Comfy.Notification.ShowVersionUpdates`)),_=i(()=>e.value[0]??null),v=i(()=>e.value.slice(0,3)),compareVersions=(e,t)=>(0,k.valid)(e)&&(0,k.valid)(t)?(0,k.compare)(e,t):e===t?0:1,x=i(()=>!!_.value&&compareVersions(_.value.version,l.value||`0.0.0`)>0),S=i(()=>!!_.value&&compareVersions(_.value.version,l.value||`0.0.0`)===0),C=i(()=>{let e=_.value?.attention;return e===`medium`||e===`high`}),w=i(()=>!(!m()||g||!h.value||!x.value||!C.value||d.value===_.value?.version&&[`skipped`,`changelog seen`].includes(f.value))),T=i(()=>{if(!m()||g||!h.value||!x.value)return!1;let{version:e}=_.value;return d.value===e&&f.value===`changelog seen`?!1:C.value?!0:!(d.value===e&&f.value===`skipped`&&p.value&&Date.now()-p.value>=2592e5)}),D=i(()=>!(!m()&&!g||!h.value||!_.value||(0,k.valid)(l.value)&&!S.value||d.value===_.value.version&&f.value===`what's new seen`));async function handleSkipRelease(e){e!==_.value?.version||f.value===`changelog seen`||(await c.set(`Comfy.Release.Version`,e),await c.set(`Comfy.Release.Status`,`skipped`),await c.set(`Comfy.Release.Timestamp`,Date.now()))}async function handleShowChangelog(e){e===_.value?.version&&(await c.set(`Comfy.Release.Version`,e),await c.set(`Comfy.Release.Status`,`changelog seen`),await c.set(`Comfy.Release.Timestamp`,Date.now()))}async function handleWhatsNewSeen(e){e===_.value?.version&&(await c.set(`Comfy.Release.Version`,e),await c.set(`Comfy.Release.Status`,`what's new seen`),await c.set(`Comfy.Release.Timestamp`,Date.now()))}async function fetchReleases(){if(!t.value&&!(!g&&!h.value)&&!o.systemStats?.system?.argv?.includes(`--disable-api-nodes`)){t.value=!0,n.value=null;try{o.systemStats||await s(o.isInitialized);let t=await r.getReleases({project:g?`cloud`:`comfyui`,current_version:l.value,form_factor:o.getFormFactor(),locale:b(u.value)});t===null?r.error.value&&(n.value=r.error.value):e.value=t}catch(e){n.value=e instanceof Error?e.message:`Unknown error occurred`}finally{t.value=!1}}}async function initialize(){await fetchReleases()}return{releases:e,isLoading:t,error:n,recentRelease:_,recentReleases:v,shouldShowToast:w,shouldShowRedDot:T,shouldShowPopup:D,shouldShowUpdateButton:x,handleSkipRelease,handleShowChangelog,handleWhatsNewSeen,fetchReleases,initialize}})}));export{A as n,j as t};
//# sourceMappingURL=releaseStore-FS4gHexT.js.map