import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{i as n,on as r,r as i,sn as a}from"./api-z_dXWY_S.js";import{i as o,r as s}from"./useErrorHandling-Dt_X40fr.js";import{Bo as c,Vo as l,_i as u,vi as d}from"./dialogService-Cr3DyAja.js";var useSessionCookie,f=t((()=>{s(),r(),n(),c(),useSessionCookie=()=>{let createSession=async()=>{if(!a)return;let{flags:e}=o();try{let t=l(),n;if(e.teamWorkspacesEnabled){let e=await t.getIdToken();if(!e){console.warn(`Failed to create session cookie:`,`No Firebase token available for session creation`);return}n={Authorization:`Bearer ${e}`}}else{let e=await t.getAuthHeader();if(!e){console.warn(`Failed to create session cookie:`,`No auth header available for session creation`);return}n=e}let r=await fetch(i.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...n,"Content-Type":`application/json`}});if(!r.ok){let e=await r.json().catch(()=>({}));console.warn(`Failed to create session cookie:`,e.message||r.statusText)}}catch(e){console.warn(`Failed to create session cookie:`,e)}},deleteSession=async()=>{if(a)try{let e=await fetch(i.apiURL(`/auth/session`),{method:`DELETE`,credentials:`include`});if(!e.ok){let t=await e.json().catch(()=>({}));console.warn(`Failed to delete session cookie:`,t.message||e.statusText)}}catch(e){console.warn(`Failed to delete session cookie:`,e)}};return{createSession,deleteSession}}}));t((()=>{f(),u(),d().registerExtension({name:`Comfy.Cloud.SessionCookie`,onAuthUserResolved:async()=>{let{createSession:e}=useSessionCookie();await e()},onAuthTokenRefreshed:async()=>{let{createSession:e}=useSessionCookie();await e()},onAuthUserLogout:async()=>{let{deleteSession:e}=useSessionCookie();await e()}})}))();
//# sourceMappingURL=cloudSessionCookie-DkDl-dBF.js.map