1import{r as i,a7 as b,c4 as f,a8 as h,j as e,O as E,dc as B,S as M,T as O,B as P,dd as k,D as x,M as m,z as j,aP as R,aQ as W,aR as z,cA as F}from"./index-DjMAzPc9.js";import{p as g}from"./partnerSession-CWaRim-w.js";import"./partnerClaims-BGIFJkx8.js";function I(l){return l&&typeof l=="object"&&"code"in l?String(l.code):""}async function w(){g.clear(),f(),await F(h)}function q({onChange:l}){const o=i.useRef(void 0);return i.useEffect(()=>b(h,a=>{o.current&&o.current!==(a==null?void 0:a.uid)&&(g.clear(),f()),o.current=(a==null?void 0:a.uid)??null,l(a?{email:a.email,signOut:w}:null)}),[l]),null}function L(){const[l,o]=i.useState(null),[a,A]=i.useState(!1),[y,s]=i.useState(null),[r,u]=i.useState(!1),[v,c]=i.useState(null),[t,d]=i.useState(null),p=i.useRef(void 0);i.useEffect(()=>b(h,n=>{p.current&&p.current!==(n==null?void 0:n.uid)&&(g.clear(),f()),p.current=(n==null?void 0:n.uid)??null,o(n),A(!0)}),[]);async function S(){if(!r){u(!0),c(null),d(null),g.clear(),f();try{await R(h,W()),s(null)}catch(n){I(n)==="auth/multi-factor-auth-required"?d(n):c(z(n))}finally{u(!1)}}}async function C(){if(!r){u(!0),c(null);try{await w(),s(null)}catch(n){c(n instanceof Error?n.message:"Sign-out did not complete. Please try again.")}finally{u(!1)}}}return a?e.jsxs(e.Fragment,{children:[e.jsx(E,{size:"small","aria-label":"Account menu",sx:{color:"var(--ds-text)","&:hover":{color:"var(--ds-text)",bgcolor:"var(--ds-surface)"},"&:focus-visible":{outline:"2px solid var(--ds-accent)",outlineOffset:2}},onClick:n=>s(n.currentTarget),children:"Account"}),e.jsxs(B,{anchorEl:y,open:!!y,onClose:()=>{!r&&!t&&s(null)},children:[e.jsxs(M,{sx:{minWidth:230,maxWidth:320,px:2,py:1},spacing:1,children:[e.jsx(O,{variant:"body2",sx:{overflowWrap:"anywhere"},children:l?l.email??"Signed in":"Not signed in"}),v?e.jsx(P,{severity:"error",role:"alert",children:v}):null,t?e.jsx(k,{error:t,onComplete:()=>{d(null),s(null)},onCancel:()=>d(null)}):null]}),e.jsx(x,{}),l?null:e.jsxs(m,{disabled:r||!!t,onClick:()=>void S(),children:[r?e.jsx(j,{size:16,sx:{mr:1}}):null,"Sign in with Google"]}),l?[e.jsxs(m,{disabled:r||!!t,onClick:()=>void S(),children:[r?e.jsx(j,{size:16,sx:{mr:1}}):null,"Switch account"]},"switch"),e.jsx(m,{disabled:r||!!t,onClick:()=>void C(),children:"Sign out"},"sign-out")]:null]})]}):null}export{L as PartnerAccountMenu,q as PartnerLoginWatcher};
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.