import"./rolldown-runtime-DIIn1E2Q.js";import"./vendor-primevue-_eYbXsHY.js";import"./vendor-firebase-D7u00oy9.js";import"./vendor-other-D7fTIduy.js";import{t as e}from"./types-DPJvCrdo.js";import{n as t}from"./useFeatureFlags-ChmiVSwD.js";import{r as n}from"./api-BebQfoGK.js";import"./vendor-markdown-Da9QPS2x.js";import"./colorUtil-xHrUTSza.js";import"./i18n-dAUEhQVe.js";import"./vendor-reka-ui-D1HCh14_.js";import"./Button-hTbieW3T.js";import{ar as r,ji as i}from"./dialogService-Cm1GEBK8.js";import"./formatUtil-Gr6H7233.js";import"./userStore-DMlTsx5E.js";import"./useErrorHandling-DudkVSep.js";import"./extensionStore-P-YqST__.js";import"./useExternalLink-DY6FqhTr.js";import"./vendor-tiptap-CcjHVRxb.js";import"./markdownRendererUtil-PltcX2Bi.js";import"./Popover-BhkpNQxC.js";import"./electronDownloadStore-BYrGQ7mS.js";var useSessionCookie=()=>{let createSession=async()=>{if(!e)return;let{flags:r}=t();try{let e=i(),t;if(r.teamWorkspacesEnabled){let n=await e.getIdToken();if(!n){console.warn(`Failed to create session cookie:`,`No Firebase token available for session creation`);return}t={Authorization:`Bearer ${n}`}}else{let n=await e.getAuthHeader();if(!n){console.warn(`Failed to create session cookie:`,`No auth header available for session creation`);return}t=n}let a=await fetch(n.apiURL(`/auth/session`),{method:`POST`,credentials:`include`,headers:{...t,"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(e)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}};r().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-Dz-eY4d0.js.map