import{r as e}from"./rolldown-runtime-CpWojdLp.js";import{n as t,r as n,t as r}from"./jsx-runtime-BrKkGzFB.js";import{a as i,i as a,n as o,r as s,t as c}from"./select-BlyWGAl8.js";import{t as l}from"./password-input-DWL5jxHj.js";import{n as u}from"./wayfinder-DdLOzeRB.js";import{B as d,Et as f,O as p,Tt as m,at as h,g,jt as _,l as v}from"./app-KzKSswgw.js";import{t as y}from"./input-error-B1iqlu2_.js";import{t as b}from"./label-1JB2VirV.js";import{t as x}from"./countries-B5kGBc6Z.js";import{t as S}from"./turnstile-field-B_v13F1v.js";import{t as C}from"./contact-number-input-B2Qfn3u9.js";var w=e(n(),1),T=t(),E=e=>({url:E.url(e),method:`post`});E.definition={methods:[`post`],url:`/register`},E.url=e=>E.definition.url+u(e),E.post=e=>({url:E.url(e),method:`post`});var D=e=>({action:E.url(e),method:`post`});D.post=e=>({action:E.url(e),method:`post`}),E.form=D,Object.assign(E,E);var O=r();function k(e){let t=(0,T.c)(13),{turnstileSiteKey:n}=e,[r,s]=(0,w.useState)(``),[u,D]=(0,w.useState)(null),k;t[0]===n?k=t[1]:(k=n?.trim(),t[0]=n,t[1]=k);let j=!!k,{url:M}=_(),N;if(t[2]!==M){let e=M.split(`?`)[1]??``;N=new URLSearchParams(e).get(`ref`)??``,t[2]=M,t[3]=N}else N=t[3];let P=N,F;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,O.jsx)(f,{title:`Registro`}),t[4]=F):F=t[4];let I,L;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(I=E.form(),L=[`password`,`password_confirmation`],t[5]=I,t[6]=L):(I=t[5],L=t[6]);let R;return t[7]!==r||t[8]!==P||t[9]!==j||t[10]!==n||t[11]!==u?(R=(0,O.jsxs)(O.Fragment,{children:[F,(0,O.jsx)(m,{...I,resetOnSuccess:L,disableWhileProcessing:!0,className:`flex flex-col gap-6`,children:e=>{let{processing:t,errors:f}=e;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`grid gap-6`,children:[(0,O.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,O.jsxs)(`div`,{className:`grid gap-2`,children:[(0,O.jsx)(b,{htmlFor:`first_name`,children:`Nombre`}),(0,O.jsx)(p,{id:`first_name`,type:`text`,required:!0,autoFocus:!0,tabIndex:1,autoComplete:`given-name`,name:`first_name`,placeholder:`Nombre`}),(0,O.jsx)(y,{message:f.first_name,className:`mt-2`})]}),(0,O.jsxs)(`div`,{className:`grid gap-2`,children:[(0,O.jsx)(b,{htmlFor:`last_name`,children:`Apellido`}),(0,O.jsx)(p,{id:`last_name`,type:`text`,required:!0,tabIndex:2,autoComplete:`family-name`,name:`last_name`,placeholder:`Apellido`}),(0,O.jsx)(y,{message:f.last_name,className:`mt-2`})]})]}),(0,O.jsxs)(`div`,{className:`grid gap-2`,children:[(0,O.jsx)(b,{htmlFor:`email`,children:`Correo electrónico`}),(0,O.jsx)(p,{id:`email`,type:`email`,required:!0,tabIndex:3,autoComplete:`email`,name:`email`,placeholder:`email@example.com`}),(0,O.jsx)(y,{message:f.email})]}),(0,O.jsxs)(`div`,{className:`grid gap-2`,children:[(0,O.jsxs)(b,{htmlFor:`referral_code`,children:[`Código de referido`,` `,(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:`(opcional)`})]}),(0,O.jsx)(p,{id:`referral_code`,type:`text`,tabIndex:4,autoComplete:`off`,name:`referral_code`,defaultValue:P,placeholder:`Código o enlace recibido`}),(0,O.jsx)(y,{message:f.referral_code})]}),(0,O.jsxs)(`div`,{className:`grid gap-2`,children:[(0,O.jsx)(b,{htmlFor:`country`,children:`País`}),(0,O.jsxs)(c,{name:`country`,onValueChange:s,required:!0,children:[(0,O.jsx)(a,{id:`country`,className:`w-full`,tabIndex:5,children:(0,O.jsx)(i,{placeholder:`Selecciona tu país`})}),(0,O.jsx)(o,{children:x.map(A)})]}),(0,O.jsx)(y,{message:f.country})]}),(0,O.jsxs)(`div`,{className:`grid gap-2`,children:[(0,O.jsx)(b,{htmlFor:`contact_number`,children:`Número de contacto`}),(0,O.jsx)(C,{country:r,id:`contact_number`,tabIndex:6}),(0,O.jsx)(y,{message:f.contact_number})]}),(0,O.jsxs)(`div`,{className:`grid gap-2`,children:[(0,O.jsx)(b,{htmlFor:`password`,children:`Contraseña`}),(0,O.jsx)(l,{id:`password`,required:!0,tabIndex:7,autoComplete:`new-password`,name:`password`,placeholder:`Contraseña`}),(0,O.jsx)(y,{message:f.password})]}),(0,O.jsxs)(`div`,{className:`grid gap-2`,children:[(0,O.jsx)(b,{htmlFor:`password_confirmation`,children:`Confirmar contraseña`}),(0,O.jsx)(l,{id:`password_confirmation`,required:!0,tabIndex:8,autoComplete:`new-password`,name:`password_confirmation`,placeholder:`Repite la contraseña`}),(0,O.jsx)(y,{message:f.password_confirmation})]}),(0,O.jsx)(S,{siteKey:n,message:f[`cf-turnstile-response`],onTokenChange:D}),(0,O.jsxs)(d,{type:`submit`,className:`mt-2 w-full`,tabIndex:9,disabled:t||j&&!u,"data-test":`register-user-button`,children:[t&&(0,O.jsx)(h,{}),`Crear cuenta`]})]}),(0,O.jsxs)(`div`,{className:`text-center text-sm text-muted-foreground`,children:[`¿Ya tienes cuenta?`,` `,(0,O.jsx)(v,{href:g(),tabIndex:10,children:`Iniciar sesión`})]})]})}})]}),t[7]=r,t[8]=P,t[9]=j,t[10]=n,t[11]=u,t[12]=R):R=t[12],R}function A(e){return(0,O.jsx)(s,{value:e.value,children:e.label},e.value)}k.layout={title:`Crear una cuenta`,description:`Completa tus datos para registrarte`};export{k as default};