import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import"./vendor-primevue-7po8Zk9v.js";import"./vendor-firebase-CdLSXhbt.js";import"./vendor-other-CrvBxfcV.js";import{t}from"./types-0oh-UGWL.js";import"./remoteConfig-CNDr9CtS.js";import{r as n}from"./api-3C7_IVZO.js";import"./colorUtil-C83P1Arv.js";import"./i18n-DjEVEIh2.js";import{n as r}from"./useErrorHandling-CBX3YQ5l.js";import"./vendor-reka-ui-Bm3o_ZTf.js";import"./Button-mG8zDgxj.js";import{tn as i,wr as a}from"./dialogService-BC0EXJA5.js";import"./systemStatsStore-gvlzOl4W.js";import"./dialogStore-BbHfkjRE.js";import"./useCopyToClipboard-CUuoo5Dm.js";import"./vendor-tiptap-DsZVujQD.js";import"./vendor-markdown-yjaB1jgA.js";import"./markdownRendererUtil-D5cHPoK2.js";const useSessionCookie=()=>{let createSession=async()=>{if(!t)return;let{flags:e}=r();try{let t=a(),r;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}r={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}r=e}let i=await fetch(n.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...r,"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(n.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-CfvbMJQl.js.map