import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import"./vendor-primevue-DxVRNMbC.js";import"./vendor-firebase-CdLSXhbt.js";import"./vendor-other-CyG3qq8S.js";import{t}from"./types-DW97iHDr.js";import{n}from"./useFeatureFlags-CxRWjdi1.js";import{r}from"./api-DQLKc1Xa.js";import"./vendor-markdown-Cola12Wc.js";import"./colorUtil-Cth7eqhK.js";import"./i18n-DjV_9lZM.js";import"./vendor-reka-ui-CHPbCe4i.js";import"./Button-C7dWyQyS.js";import{or as i,qt as a}from"./dialogService-Cqui0UMO.js";import"./systemStatsStore-D9aNY5gT.js";import"./useErrorHandling-BFB8eSj5.js";import"./dialogStore-CXD5Bcfy.js";import"./useCopyToClipboard-C74olorb.js";import"./vendor-tiptap-BXSIIPYY.js";import"./markdownRendererUtil-Bm7Umh6C.js";import"./useExternalLink-Cc30SNi3.js";const useSessionCookie=()=>{let createSession=async()=>{if(!t)return;let{flags:e}=n();try{let t=i(),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 a=await fetch(r.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...n,"Content-Type":`application/json`}});if(!a.ok){let e=await a.json().catch(()=>({}));console.warn(`Failed to create session cookie:`,e.message||a.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}};a().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-DLn_EtE4.js.map