"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),v=require("react-i18next"),h=require("react-router-dom"),n=require("lucide-react"),i=require("./index-CVOA4qIe.js");function j(){const{t:a}=v.useTranslation("auth"),[u]=h.useSearchParams(),g=h.useNavigate(),[o,s]=l.useState("processing"),[x,d]=l.useState("");l.useEffect(()=>{const f={auth_failed:a("authCallbackPage.authFailedError"),no_email:a("authCallbackPage.noEmailError"),account_disabled:a("authCallbackPage.accountDisabledError"),account_locked:a("authCallbackPage.accountLockedError"),internal_error:a("authCallbackPage.internalError")},m=u.get("error");if(m){s("error"),d(f[m]||a("authCallbackPage.generalError"));return}(async()=>{try{try{const t=await i.getClientIpAddress(),r=i.detectDeviceType();(t||r)&&await fetch("/api/auth/update-session-client-info",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientIp:t,deviceType:r})})}catch{}const c=await fetch("/api/auth/me",{credentials:"include"});if(!c.ok)throw new Error("Failed to fetch user info");const p=await c.json();localStorage.setItem("user",JSON.stringify(p));try{const t=await fetch("/api/onboarding/status",{credentials:"include"});if(t.ok&&!(await t.json()).hasCompletedOnboarding){s("success"),setTimeout(()=>{window.location.href="/auth/onboarding"},1500);return}}catch{}try{const t=await i.userApi.preferences.get(),r={mode:t.theme||"dark",accentColorKey:t.accentColorKey||"indigo",borderRadius:t.borderRadius||{},itemPaletteKey:t.itemPaletteKey||"neutral"};localStorage.setItem("smartstack-theme-config",JSON.stringify(r)),t.language&&localStorage.setItem("i18nextLng",t.language)}catch{}s("success"),localStorage.removeItem("currentTenantId"),localStorage.removeItem("currentTenantSlug"),localStorage.removeItem("isGlobalView"),setTimeout(()=>{window.location.href="/myspace"},1500)}catch(c){console.error("Auth callback error:",c),s("error"),d(a("authCallbackPage.generalError"))}})()},[u,a]);const 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:[o==="processing"&&e.jsxs("div",{className:"text-center",children:[e.jsx(n.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:a("authCallbackPage.processing")}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:a("authCallbackPage.success")})]}),o==="success"&&e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto bg-[var(--success-bg)] rounded-full flex items-center justify-center mb-4",children:e.jsx(n.CheckCircle,{className:"w-10 h-10 text-[var(--success-text)]"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("authCallbackPage.success")}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:a("authCallbackPage.success")})]}),o==="error"&&e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto bg-[var(--error-bg)] rounded-full flex items-center justify-center mb-4",children:e.jsx(n.XCircle,{className:"w-10 h-10 text-[var(--error-text)]"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("authCallbackPage.generalError")}),e.jsx("div",{className:"bg-[var(--error-bg)] rounded-lg p-4 mb-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(n.AlertCircle,{className:"w-5 h-5 text-[var(--error-text)] flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-[var(--error-text)]",children:x})]})}),e.jsx("button",{onClick:b,className:"btn btn-primary w-full",children:a("login.submit")})]})]})})})}exports.AuthCallbackPage=j;
//# sourceMappingURL=AuthCallbackPage-D_BW4voI.js.map
