import"../chunks/DsnmJJEf.js";import{o as v}from"../chunks/vrwecVo1.js";import{p as L,t as T,a as G,b as S,i as $,d as i,c as x,$ as b,s as A,r as m}from"../chunks/Dyk1ealw.js";import{s as D}from"../chunks/DEEYSJdk.js";import{h as E}from"../chunks/BGzpdNMV.js";import{g as r}from"../chunks/BCu6PYO-.js";import{b as s}from"../chunks/DXU0JJLc.js";import{p as d}from"../chunks/BES_pAfq.js";import{i as o}from"../chunks/CVq-Ik9t.js";import{e as M}from"../chunks/DibDeWsm.js";import{L as O}from"../chunks/BkBShXgg.js";import{t as g}from"../chunks/CDBVw774.js";var y=x('<div class="flex min-h-screen items-center justify-center bg-background p-4"><div class="flex items-center gap-3 text-muted-foreground"><!> <span class="text-sm"> </span></div></div>');function V(_,N){L(N,!0);function I(){const t=d.url.searchParams.get("returnTo");return t&&t.startsWith("/")&&!t.startsWith("//")?t:`${s}/`}function c(){g.error(o.t("ADMIN_NEXT.LOGIN.SSO_FAILED")),r(`${s}/login`)}v(async()=>{const t=d.url.searchParams,e=I();if(t.get("sso_error")){c();return}const u=t.get("code");if(!u){r(`${s}/login`);return}try{const n=await M(u);if(n.requires2fa&&n.challengeToken){sessionStorage.setItem("grav_sso_2fa",n.challengeToken),r(`${s}/login?returnTo=${encodeURIComponent(e)}`);return}g.success(o.t("ADMIN_NEXT.LOGIN.SIGNED_IN_SUCCESSFULLY")),r(e)}catch{c()}});var a=y();E("13s5ly6",t=>{$(e=>{b.title=e??""},[()=>o.t("ADMIN_NEXT.LOGIN.LOGIN_GRAV_ADMIN")])});var p=i(a),f=i(p);O(f,{size:18,class:"animate-spin"});var l=A(f,2),h=i(l,!0);m(l),m(p),m(a),T(t=>D(h,t),[()=>o.t("ADMIN_NEXT.LOGIN.SIGNING_IN")]),G(_,a),S()}export{V as component};
