1import{u as U,U as A,e as _,y as j,r as a,j as e,S as B,d as E}from"./index-6AHMKm1b.js";import{O as N,e as k}from"./oauth-CSTjbwOM.js";import{B as R}from"./BrandingBadges-8yOmWgJS.js";const I=()=>{const{t:s}=U(),l=A(),h=_(),n=j(t=>t.userEmail()),[c,f]=a.useState(null),[v,w]=a.useState(null),[u,d]=a.useState(!1),[m,g]=a.useState(!0),[i,p]=a.useState("");a.useEffect(()=>{var b;const t=typeof l.search=="string"?l.search:((b=globalThis.location)==null?void 0:b.search)??"",r=new URLSearchParams(t).get("login_challenge");if(!r){p(s("oauth.errors.missingChallenge"));return}if(!n){h({to:"/login",search:{login_challenge:r}});return}f(r),g(!0),N.getLoginRequest(r).then(L=>{w(L.mcp_client_name??null),g(!1)}).catch(()=>{g(!1)})},[l.search,n,h,s]);const S=async()=>{var t;if(c){d(!0);try{const o=await N.acceptLogin({login_challenge:c});if(!((t=o.data)!=null&&t.redirect_to)){p(s("login.oauthMissingRedirect")),d(!1);return}window.location.href=o.data.redirect_to}catch(o){p(s(k(o))),d(!1)}}},y=()=>{j.getState().logout(),h({to:"/login",search:c?{login_challenge:c}:{}})},C=n?n.charAt(0).toUpperCase():"",x=m?"...":v||"the AI assistant";return i?e.jsxs("div",{className:"hubspot-auth-wrapper",children:[e.jsx("div",{className:"hubspot-auth-logo",children:e.jsx("img",{src:"/images/cy-logo.svg",alt:"CookieYes logo"})}),e.jsx("div",{className:"hubspot-connect-content",children:e.jsxs("div",{className:"hubspot-auth-card",children:[e.jsx("h5",{className:"font-semibold text-2xl mb-3 text-[#27283c] text-center",children:s("oauth.errors.title")}),e.jsx("p",{className:"text-base text-center text-[#27283c]",children:i})]})})]}):c?e.jsxs("div",{className:"hubspot-auth-wrapper",children:[e.jsx("div",{className:"hubspot-auth-logo",children:e.jsx("img",{src:"/images/cy-logo.svg",alt:"CookieYes logo"})}),e.jsxs("div",{className:"hubspot-connect-content",children:[e.jsx("div",{className:"hubspot-auth-card",children:e.jsxs("div",{className:"hubspot-welcome-inner","data-testid":"oauth-welcome-back",children:[e.jsxs("h2",{className:"hubspot-welcome-title",children:[s("oauth.switchUser.titleLine1"),e.jsx("br",{}),s("oauth.switchUser.titleLine2")]}),e.jsxs("div",{className:"hubspot-user-card",children:[e.jsx("div",{className:"hubspot-user-avatar",children:C}),e.jsxs("div",{className:"hubspot-user-info",children:[e.jsx("p",{className:"hubspot-user-label",children:s("hubspot.loggedInAs")}),e.jsx("p",{className:"hubspot-user-email",children:n})]})]}),e.jsx("div",{className:"hubspot-info-banner",children:e.jsx("p",{children:s("oauth.switchUser.infoBanner",{clientName:x})})}),i&&e.jsx("p",{className:"text-danger text-sm text-center m-0",children:i}),e.jsx("button",{type:"button","data-testid":"continue-btn",className:"hubspot-connect-btn",onClick:S,disabled:u||m,children:m||u?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[s("oauth.switchUser.connectButton",{clientName:x}),e.jsx(B,{className:"w-4 h-4"})]}):s("oauth.switchUser.connectButton",{clientName:x})}),e.jsx("div",{className:"hubspot-switch-account",children:e.jsx("button",{type:"button","data-testid":"another-account-btn",className:"hubspot-switch-account-btn",onClick:y,disabled:u,children:s("oauth.switchUser.useAnotherAccount")})})]})}),e.jsx("div",{className:"hubspot-trust-badges",children:e.jsx(R,{isCheckoutOrLogin:!0,displaySmallBadges:!1})})]})]}):null},q=E("/oauth/switch-user")({component:I});export{q as Route};
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.