1import{r as s,j as e}from"./vendor-radix-_DSeAjJN.js";import{c as z,b as K,p as Q,A,q as V,a as k,d as Y,T as J,L as I,B as j,S as X,t as c,s as Z}from"./index-kCmOl8t5.js";import{I as R}from"./input-Bee1xi3q.js";import{L as E}from"./label-CWcrhaBJ.js";import{A as ee,G as te,F as se}from"./FacebookSignInButton-CgyA9DsX.js";import{P as ae}from"./PasswordStrengthMeter-B5gI-LcG.js";import{M as L}from"./authActions-D6bmRbPb.js";import{m as re,c as ne}from"./signupSource-P0WscT6I.js";import{W as ie}from"./WhatsAppFields-Bn04tvyN.js";import{D as oe,p as ue}from"./phone-D1itOloW.js";import{u as ce,w as le}from"./vendor-icons-BrMlqT7e.js";import{o as me,s as F}from"./types-DHgsoueE.js";import"./vendor-supabase-CJeKTvkw.js";import"./vendor-recharts-CyfsaX7h.js";function Te(){const w=z(),[i]=K(),l=i.get("redirect"),a=Q(i.get(A)),v=i.get("plan")==="monthly"?"monthly":"yearly",_=i.get("tier")==="starter"?"&tier=starter":"",o=a??(l==="checkout"?`/checkout?plan=${v}${_}`:"/dashboard"),b=a?`/login${V(a)}`:`/login${l?`?redirect=${l}&plan=${v}`:""}`,{t}=k(["auth"]),{t:N}=k("app"),{session:S}=Y(),[m,$]=s.useState(""),[p,D]=s.useState(""),[y,d]=s.useState(!1),[M,O]=s.useState(!1),[C,U]=s.useState(!1),[T,W]=s.useState(oe),[h,q]=s.useState(""),[x,B]=s.useState(!1),G=me({email:F().trim().email({message:t("auth:signup.errEmail")}).max(255),password:F().min(L,{message:t("auth:signup.errPassword")}).max(128)});s.useEffect(()=>{S&&w(o,{replace:!0})},[S,w,o]);const H=async r=>{r.preventDefault();const u=G.safeParse({email:m,password:p});if(!u.success){c({title:t("auth:validation.errTitle"),description:u.error.issues[0].message,variant:"destructive"});return}let g=null;if(h.trim()!==""){const n=ue(h,T);if(!n.ok){c({title:t("auth:validation.errTitle"),description:N(`account.whatsapp.error.${n.error}`),variant:"destructive"});return}if(!x){c({title:t("auth:validation.errTitle"),description:N("account.whatsapp.consentRequired"),variant:"destructive"});return}g=n.e164}d(!0);const P=new URL("/auth/callback",window.location.origin);a&&P.searchParams.set(A,a),re();const{error:f}=await Z.auth.signUp({email:u.data.email,password:u.data.password,options:{emailRedirectTo:P.toString(),data:{signup_source:ne(),...g?{whatsapp_e164:g,whatsapp_opt_in_marketing:x}:{}}}});if(f){d(!1);const n=f.message.includes("registered")?t("auth:signup.errExisting"):f.message;c({title:t("auth:signup.errTitle"),description:n,variant:"destructive"});return}d(!1),O(!0)};return M?e.jsx("div",{className:"min-h-screen pl-landing-canvas text-foreground flex items-center justify-center px-4",children:e.jsxs("div",{className:"w-full max-w-sm pl-landing-card rounded-2xl p-8 text-center",children:[e.jsx(ce,{className:"w-12 h-12 text-primary mx-auto mb-4"}),e.jsx("h1",{className:"text-xl font-bold mb-2",children:t("auth:signup.doneTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:e.jsx(J,{i18nKey:"auth:signup.doneText",values:{email:m},components:[e.jsx("strong",{className:"text-foreground"},"0")]})}),e.jsx(I,{to:b,children:e.jsx(j,{variant:"outline",className:"w-full",children:t("auth:signup.doneCta")})})]})}):e.jsxs(ee,{children:[e.jsx(X,{title:"Criar conta â PromoLink",description:"Crie sua conta gratuita no PromoLink e comece a publicar promoções da Amazon e Mercado Livre no Telegram com 1 clique.",path:"/signup"}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mb-1",children:t("auth:signup.title")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:t("auth:signup.subtitle")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(te,{authRedirect:a??o}),e.jsx(se,{authRedirect:a??o}),!C&&e.jsxs(j,{type:"button",className:"w-full",onClick:()=>U(!0),children:[e.jsx(le,{className:"h-4 w-4"}),t("auth:oauth.email")]})]}),C&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 my-4","aria-hidden":"true",children:[e.jsx("span",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:t("auth:oauth.divider")}),e.jsx("span",{className:"h-px flex-1 bg-border"})]}),e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{htmlFor:"email",children:t("auth:signup.email")}),e.jsx(R,{id:"email",type:"email",autoComplete:"email",autoFocus:!0,value:m,onChange:r=>$(r.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{htmlFor:"password",children:t("auth:signup.password")}),e.jsx(R,{id:"password",type:"password",autoComplete:"new-password",value:p,onChange:r=>D(r.target.value),required:!0,minLength:L}),e.jsx(ae,{password:p})]}),e.jsx("div",{className:"rounded-xl border border-border/60 p-3",children:e.jsx(ie,{idPrefix:"signup-whatsapp",country:T,onCountryChange:W,value:h,onValueChange:q,optIn:x,onOptInChange:B})}),e.jsx(j,{type:"submit",className:"w-full",disabled:y,children:t(y?"auth:signup.submitting":"auth:signup.submit")})]})]}),e.jsxs("p",{className:"mt-6 text-sm text-center text-muted-foreground",children:[t("auth:signup.haveAccount")," ",e.jsx(I,{to:b,className:"text-primary font-medium hover:underline",children:t("auth:signup.signIn")})]})]})}export{Te 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.