import{j as y}from"./query-ATBhtd3K.js";import{r as d}from"./vendor-EnoIVk-c.js";import{u as S}from"./useAuth-CqtZE9nt.js";import{u as P}from"./AuthContext-CYne_gJM.js";import{a as C,L as v}from"./routing-nZgBtxly.js";import{u as w,c as U,W as R,P as I}from"./en-IUV4ZXKH-BjYNERUx.js";import{u as x}from"./i18n-BYxb14hm.js";import"./index-D4SjcYxX.js";function N(){var u;const{t:b}=x(),e=(c,n)=>b(`AuthWelcome.${c}`,n),{isAuthenticated:o,isLoading:r,user:s}=S(),{clearSession:h}=P(),i=C(),[A,T]=d.useState(!1),f=w(),p=U(),{data:t}=p.me.useQuery(),a=p.acceptTerms.useMutation();d.useEffect(()=>{if(!r){if(!o){i.push("/auth/connect");return}if(t!=null&&t.termsAcceptedAt){i.push("/");return}if(o&&t!==void 0&&(t!=null&&t.termsAcceptedAt)){i.push("/");return}}},[r,o,i,t]);const l=async c=>{if(!c){h(),i.push("/");return}try{await a.mutateAsync(),T(!0),setTimeout(()=>{i.push("/")},1e3)}catch(n){console.error("Terms acceptance error:",n),f.showError(e("errorAcceptingTerms"))}},g=r?"loading":A?"accepted":"form",m=((u=s==null?void 0:s.name)==null?void 0:u.split(" ")[0])??"";return y.jsx(R,{userName:m,termsAcceptedAt:(t==null?void 0:t.termsAcceptedAt)??null,isNewUser:!(t!=null&&t.termsAcceptedAt),status:g,isProcessing:a.isPending,onAccept:()=>l(!0),onDecline:()=>l(!1),translations:{loading:e("loading"),welcomeTitle:e("welcomeTitle"),thanksForAccepting:e("thanksForAccepting"),welcomeUser:e("welcomeUser",{firstName:m}),reviewTermsPrompt:e("reviewTermsPrompt"),termsSummaryTitle:e("termsSummaryTitle"),termsSummaryIntro:e("termsSummaryIntro"),acceptableUseTitle:e("acceptableUseTitle"),acceptableUseResponsible:e("acceptableUseResponsible"),acceptableUseRespect:e("acceptableUseRespect"),acceptableUseConduct:e("acceptableUseConduct"),prohibitedContentTitle:e("prohibitedContentTitle"),prohibitedContentIntro:e("prohibitedContentIntro"),prohibitedIllegal:e("prohibitedIllegal"),prohibitedAdult:e("prohibitedAdult"),prohibitedHate:e("prohibitedHate"),prohibitedViolence:e("prohibitedViolence"),prohibitedMisinformation:e("prohibitedMisinformation"),prohibitedPrivacy:e("prohibitedPrivacy"),prohibitedCopyright:e("prohibitedCopyright"),prohibitedMalware:e("prohibitedMalware"),prohibitedSpam:e("prohibitedSpam"),conductTitle:e("conductTitle"),conductDescription:e("conductDescription"),conductLink:e("conductLink"),conductPromotion:e("conductPromotion"),responsibilitiesTitle:e("responsibilitiesTitle"),responsibilitiesSecure:e("responsibilitiesSecure"),responsibilitiesReport:e("responsibilitiesReport"),responsibilitiesAccurate:e("responsibilitiesAccurate"),responsibilitiesComply:e("responsibilitiesComply"),violationsWarning:e("violationsWarning"),readFullTerms:e("readFullTerms"),termsOfService:e("termsOfService"),and:e("and"),privacyPolicy:e("privacyPolicy"),declineAndSignOut:e("declineAndSignOut"),acceptAndContinue:e("acceptAndContinue"),processing:e("processing"),legallyBound:e("legallyBound")},PageLayout:I,Link:v})}export{N as default};
//# sourceMappingURL=page-DU4gR5Xo.js.map
