"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),h=require("react-router-dom"),c=require("lucide-react"),m=require("./index-Bin-Gy1w.js"),v={auth_failed:"L'authentification a échoué. Veuillez réessayer.",no_email:"Impossible de récupérer votre adresse email depuis le fournisseur.",account_disabled:"Votre compte est désactivé. Contactez l'administrateur.",account_locked:"Votre compte est verrouillé. Contactez l'administrateur.",internal_error:"Une erreur interne est survenue. Veuillez réessayer."};function y(){const[o]=h.useSearchParams(),g=h.useNavigate(),[l,a]=u.useState("processing"),[x,d]=u.useState("");u.useEffect(()=>{const r=o.get("token"),i=o.get("refreshToken"),s=o.get("error");if(s){a("error"),d(v[s]||"Une erreur est survenue lors de l'authentification.");return}r&&i?f(r,i):(a("error"),d("Paramètres d'authentification manquants."))},[o]);const f=async(r,i)=>{try{localStorage.setItem("token",r),localStorage.setItem("refreshToken",i);try{const t=await m.getClientIpAddress(),n=m.detectDeviceType();(t||n)&&await fetch("/api/auth/update-session-client-info",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({clientIp:t,deviceType:n})})}catch{}const s=await fetch("/api/auth/me",{headers:{Authorization:`Bearer ${r}`}});if(!s.ok)throw new Error("Failed to fetch user info");const p=await s.json();localStorage.setItem("user",JSON.stringify(p));try{const t=await fetch("/api/onboarding/status",{headers:{Authorization:`Bearer ${r}`}});if(t.ok&&!(await t.json()).hasCompletedOnboarding){a("success"),setTimeout(()=>{window.location.href="/auth/onboarding"},1500);return}}catch{}try{const t=await m.userApi.preferences.get(),n={mode:t.theme||"dark",accentColorKey:t.accentColorKey||"indigo",borderRadius:t.borderRadius||{},itemPaletteKey:t.itemPaletteKey||"neutral"};localStorage.setItem("smartstack-theme-config",JSON.stringify(n)),t.language&&localStorage.setItem("i18nextLng",t.language)}catch{}a("success"),localStorage.removeItem("currentTenantId"),localStorage.removeItem("currentTenantSlug"),localStorage.removeItem("isGlobalView"),setTimeout(()=>{window.location.href="/myspace"},1500)}catch(s){console.error("Auth callback error:",s),a("error"),d("Erreur lors de la finalisation de l'authentification.")}},b=()=>{g("/login")};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[var(--bg-primary)]",children:e.jsx("div",{className:"max-w-md w-full mx-4",children:e.jsxs("div",{className:"bg-[var(--bg-secondary)] rounded-2xl p-8 shadow-lg border border-[var(--border-color)]",children:[l==="processing"&&e.jsxs("div",{className:"text-center",children:[e.jsx(c.Loader2,{className:"w-16 h-16 mx-auto text-[var(--color-accent-500)] animate-spin mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Authentification en cours..."}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Veuillez patienter pendant que nous finalisons votre connexion."})]}),l==="success"&&e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center mb-4",children:e.jsx(c.CheckCircle,{className:"w-10 h-10 text-green-600 dark:text-green-400"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Connexion réussie !"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Vous allez être redirigé vers votre espace personnel..."})]}),l==="error"&&e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center mb-4",children:e.jsx(c.XCircle,{className:"w-10 h-10 text-red-600 dark:text-red-400"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Échec de l'authentification"}),e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 rounded-lg p-4 mb-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(c.AlertCircle,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300",children:x})]})}),e.jsx("button",{onClick:b,className:"btn btn-primary w-full",children:"Retourner à la connexion"})]})]})})})}exports.AuthCallbackPage=y;
//# sourceMappingURL=AuthCallbackPage-C_z47_qG.js.map
