1import{j as l}from"./ui-radix-Bk4hRwrv.js";import{R as E,u as S,r as n}from"./router-vendor-DYgwYSPk.js";import{b}from"./state-vendor-BAEYWeIk.js";import{b as N,c as R}from"./auth-vendor-BbutvCVi.js";import{b as U}from"./utils-vendor-CsQ2SZQD.js";import{l as _,b as L,t as j,d as k,L as v}from"./index-aG5_WC5Q.js";import"./react-vendor-F2Vt0_di.js";import"./icons-vendor-D0sZMWLB.js";const D="https://server.skysenders.ai/api/partners/public",I="4e435af8-2351-4df4-a8ed-73eefd731c74",y=U.create({baseURL:D,timeout:6e4,headers:{"Content-Type":"application/json",partner_auth_id:I}}),w=async s=>{try{return(await y.post("/customers/login",{email:s})).data}catch(t){throw console.error("Error during customer login:",t),t}},P=async(s,t,i)=>{try{return(await y.post("/customers/add",{email:s,name:t,company_name:i})).data}catch(o){throw console.error("Error during customer signup:",o),o}},C=()=>{const s=b(),{isLoaded:t,signOut:i,sessionId:o}=N(),{isLoaded:c,user:r}=R(),m=S(),u=n.useCallback(async()=>{s(_()),await i(),m("/sign-in")},[s,i,m]),d=n.useCallback(async()=>{if(!o){u();return}const a=r?.primaryEmailAddress?.emailAddress,f=r?.firstName||"",g=r?.lastName||"",x=`${f} ${g}`.trim()||a?.split("@")[0]||"User";if(a)try{let e;try{e=await w(a)}catch(h){if(h.response?.status===404)console.log("User not found, creating new customer..."),await P(a,x),e=await w(a);else throw h}const A={id:e.customer.id.toString(),firstName:f,lastName:g,email:e.customer.email,token:o,company:e.customer.company_name,sessionDate:Date.now()};s(L(A)),window.location.href=e.magic_link}catch(e){console.error("Authentication error:",e),j({title:"Failed to authenticate",description:e.response?.data?.message||"Please try again",variant:"destructive"}),u()}},[r,o,s,u]);n.useEffect(()=>{c&&!r&&m("/sign-in")},[c,m,r]);const p=n.useMemo(()=>t&&c&&!!r,[r,t,c]);return n.useEffect(()=>{p&&(s(k()),d())},[s,p,d]),l.jsx("div",{className:"flex flex-row h-screen w-full bg-[#191A1A]",children:l.jsx("div",{className:"flex flex-1 h-50 w-50 justify-center items-center",children:l.jsx(v,{})})})},Y=E.memo(C);export{Y as default};
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.