1import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{i as n,r}from"./framework-DjWA_DlG.js";import{n as i}from"./dist-manhm6Cl.js";var a=e({MarketingAuthProvider:()=>l,useMarketingAuth:()=>u}),o=t(r(),1),s=n(),c=(0,o.createContext)(null);function l({children:e}){let[t,n]=(0,o.useState)(`loading`),[r,a]=(0,o.useState)(null),[l,u]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=new AbortController,t=setTimeout(()=>e.abort(),4e3);return fetch(`/api/auth/session`,{credentials:`same-origin`,cache:`no-store`,signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`Session check failed`);let t=await e.json();n(t.authenticated?`authenticated`:`unauthenticated`),a(t.authenticated?t.user??null:null)}).catch(()=>{n(`unauthenticated`)}).finally(()=>clearTimeout(t)),()=>{clearTimeout(t),e.abort()}},[]);let d=(0,o.useCallback)(async()=>{if(!l){u(!0);try{if(!(await fetch(`/api/auth/logout`,{method:`POST`,credentials:`same-origin`,cache:`no-store`})).ok)throw Error(`Logout failed`);n(`unauthenticated`),a(null),i.success(`Signed out`)}catch{i.error(`Could not sign out`)}finally{u(!1)}}},[l]),f=(0,o.useMemo)(()=>({status:t,authenticated:t===`authenticated`,user:r,signingOut:l,logout:d}),[d,l,t,r]);return(0,s.jsx)(c.Provider,{value:f,children:e})}function u(){let e=(0,o.useContext)(c);if(!e)throw Error(`useMarketingAuth must be used within MarketingAuthProvider`);return e}export{u as n,a as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.