1import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{dt as t,pt as n,ut as r,wt as i}from"./vendor-Bb9yCo9K.js";import{t as a}from"./vendor-i18n-C715PcBm.js";import{_ as o,b as s,c,d as l,f as u,m as d,p as f,s as p,v as m}from"./client-Bcq1k1Ig.js";import{t as h}from"./authStore-Dtvixuf6.js";import{O as g}from"./index-Bbv-53qk.js";import{_,g as v,o as y}from"./oauth-C92aq55O.js";import{a as b,i as x,n as S,r as C,s as w,t as T}from"./webOAuth-4N8-X5lB.js";var E=e(i(),1);function D(e=`authorization_failed`){return g[e]??g.authorization_failed}function O(e,t=`request-failed`){let n=new URL(p(e),window.location.origin);return n.searchParams.set(`googleBindError`,t),`${n.pathname}${n.search}`}function k(){let{t:e}=a(),{provider:i}=t(),[p]=n(),g=r(),k=h(e=>e.refresh),A=h(e=>e.reset),j=h(e=>e.setLoginError),M=(0,E.useRef)(!1);return(0,E.useEffect)(()=>{if(M.current)return;M.current=!0;let t=p.get(`state`),n=p.get(`code`),r=p.get(`error`),a=f()||`/home`,h=w(i),E=h===`google`?C(h):null,N=h===`google`?E?.mode??`login`:x(t),P=h===`google`&&N===`bind-email`,F=N===`login`?m():null,I=d(h===`google`?E?.path??a:b(t,a),`/home`),L=(t=`authorization_failed`)=>{if(h&&T(h),P){g(O(I),{replace:!0});return}j(e(D(t))),g(l(I,F),{replace:!0})};if(!h){L();return}let R=h===`google`?S(h):y(h),z=!!(t&&R&&R===t);if(h===`google`&&(!z||!E)){L(`authorization_failed`);return}if(r){L(r.toLowerCase());return}if(!n){L(`missing_code`);return}if(!t||h!==`google`&&!z){L(`authorization_failed`);return}if(N===`bind-email`){if(h!==`google`){L();return}_(n,t).then(e=>e.alreadyBound?(T(h),g(O(I,`already-bound`),{replace:!0}),null):k()).then(e=>{if(!e)return;let{session:t}=e;if(T(h),!t.authenticated){A(),g(l(I),{replace:!0});return}u(),j(null),g(I,{replace:!0})}).catch(()=>{L(`token_exchange_failed`)});return}v(h,n,t).then(()=>k()).then(({account:e,session:t})=>{if(T(h),!t.authenticated){L(`token_exchange_failed`);return}let n=c(I,e);u(),j(null),!s(F)&&(o(),g(n,{replace:!0}))}).catch(()=>{A(),L(`token_exchange_failed`)})},[g,i,k,A,p,j,e]),null}export{k as OAuthCallbackPage};
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.