import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import"./vendor-primevue-DxVRNMbC.js";import"./vendor-firebase-CdLSXhbt.js";import"./vendor-other-D7Cc5Ixw.js";import{t}from"./types-BW--Ya-K.js";import{t as n}from"./useFeatureFlags-B0oLxKlK.js";import{r}from"./api-Bo3xGkUk.js";import"./colorUtil-_hWBTBqR.js";import"./i18n-YWjgSklj.js";import"./vendor-reka-ui-DNqLZfNK.js";import"./Button-DREXX1Gv.js";import{Kt as i,ar as a}from"./dialogService-BTVFmf6F.js";import"./systemStatsStore-D-GJwPc7.js";import"./useErrorHandling-D_QKYdSx.js";import"./dialogStore-CUaBKWKw.js";import"./useCopyToClipboard-C_P-Vq1j.js";import"./vendor-tiptap-CjhX_1DY.js";import"./vendor-markdown-CyF8uRn7.js";import"./markdownRendererUtil-DU6rKHAL.js";import"./useExternalLink-Vt2OTFDR.js";const useSessionCookie=()=>{let createSession=async()=>{if(!t)return;let{flags:e}=n();try{let t=a(),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 i=await fetch(r.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...n,"Content-Type":`application/json`}});if(!i.ok){let e=await i.json().catch(()=>({}));console.warn(`Failed to create session cookie:`,e.message||i.statusText)}}catch(e){console.warn(`Failed to create session cookie:`,e)}},deleteSession=async()=>{if(t)try{let e=await fetch(r.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}};i().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-D7fl5UKt.js.map