import{r as e}from"./rolldown-runtime-DIIn1E2Q.js";import"./vendor-primevue-DOcVZxnt.js";import"./vendor-firebase-yTFzdAQf.js";import"./vendor-other-ZVm7XS8K.js";import{t}from"./types-Bc3W4AWd.js";import{t as n}from"./useFeatureFlags-CMK9o9Rw.js";import{r}from"./api-OgmjiUkn.js";import"./colorUtil-C9tyO6rZ.js";import"./i18n-S80A-Sy1.js";import"./vendor-reka-ui-EFkcZtPy.js";import"./Button-C-kbn1lh.js";import{$n as i,Ut as a}from"./dialogService-Dp405gae.js";import"./systemStatsStore-BAnEcJS2.js";import"./useErrorHandling-DfKSzlg9.js";import"./dialogStore-BDXSs8Ic.js";import"./userStore-C5cqCkur.js";import"./useCopyToClipboard-_eFTtqIy.js";import"./vendor-tiptap-BZCaYoPl.js";import"./vendor-markdown-Gcn_JH9N.js";import"./markdownRendererUtil-BD0lrBqH.js";import"./useExternalLink-CZSEXO8Q.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-BBSpSxP5.js.map