import{r as t,u as P,j as e,L,a as I,b as U,P as F}from"./index-B1SopS7p.js";import{A as z}from"./AuthPageLayout-Bn_7rRH9.js";import{S as A,a as M,C as T}from"./Checkbox-D9RiB0ry.js";import{L as r}from"./Label-_kIZXND3.js";import{I as n}from"./InputField-D06kMgpV.js";import"./bundle-mjs-COJ8Fh6m.js";import"./clsx-B-dksMZM.js";function D(){const[i,y]=t.useState(""),[h,v]=t.useState(""),[u,N]=t.useState(""),[g,b]=t.useState(""),[p,w]=t.useState(""),[o,S]=t.useState(!1),[c,E]=t.useState(!1),[d,a]=t.useState(""),[l,m]=t.useState(""),k=P(),C=async s=>{if(s.preventDefault(),a(""),m(""),!c){a("You must accept the Terms and Conditions");return}const f={email:g,password:p,firstName:i,lastName:h,institution:u};try{await I(f),k("/verify-email",{state:{email:f.email}})}catch(x){x instanceof Error?x.message==="Email already registered"?m("This email is already registered"):a(x.message):a("Unexpected error during signup")}},j=!!l||!!d||!c;return e.jsx("div",{className:"flex flex-col flex-1 w-full overflow-y-auto lg:w-1/2 no-scrollbar",children:e.jsx("div",{className:"flex flex-col justify-center flex-1 w-full max-w-md mx-auto",children:e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 sm:mb-8",children:[e.jsx("h1",{className:"mb-2 font-semibold text-gray-800 text-title-sm dark:text-white/90 sm:text-title-md",children:"Sign Up"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Enter your details to create an account!"})]}),e.jsxs("div",{children:[e.jsx("form",{onSubmit:C,children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsxs(r,{children:["First Name",e.jsx("span",{className:"text-error-500",children:"*"})]}),e.jsx(n,{type:"text",id:"fname",name:"fname",placeholder:"Enter your first name",value:i,onChange:s=>y(s.target.value)})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsxs(r,{children:["Last Name",e.jsx("span",{className:"text-error-500",children:"*"})]}),e.jsx(n,{type:"text",id:"lname",name:"lname",placeholder:"Enter your last name",value:h,onChange:s=>v(s.target.value)})]})]}),e.jsxs("div",{children:[e.jsxs(r,{children:["Institution",e.jsx("span",{className:"text-error-500",children:"*"})]}),e.jsx(n,{type:"text",id:"institution",name:"institution",placeholder:"Enter your institution",value:u,onChange:s=>N(s.target.value)})]}),e.jsxs("div",{children:[e.jsxs(r,{children:["Email",e.jsx("span",{className:"text-error-500",children:"*"})]}),e.jsx(n,{type:"email",id:"email",name:"email",placeholder:"Enter your email",value:g,onChange:s=>{b(s.target.value),m("")},className:l?"border border-error-500":""}),l&&e.jsx("p",{className:"text-sm text-error-500 mt-1",children:l})]}),e.jsxs("div",{children:[e.jsxs(r,{children:["Password",e.jsx("span",{className:"text-error-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(n,{placeholder:"Enter your password",type:o?"text":"password",value:p,onChange:s=>w(s.target.value)}),e.jsx("span",{onClick:()=>S(!o),className:"absolute z-30 -translate-y-1/2 cursor-pointer right-4 top-1/2",children:o?e.jsx(A,{className:"fill-gray-500 dark:fill-gray-400 size-5"}):e.jsx(M,{className:"fill-gray-500 dark:fill-gray-400 size-5"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(T,{className:"w-5 h-5",checked:c,onChange:s=>{E(s),a("")}}),e.jsxs("p",{className:"inline-block font-normal text-gray-500 dark:text-gray-400",children:["By creating an account you agree to the"," ",e.jsx("span",{className:"text-gray-800 dark:text-white/90",children:"Terms and Conditions"})," ","and our"," ",e.jsx("span",{className:"text-gray-800 dark:text-white",children:"Privacy Policy"}),"."]})]}),d&&e.jsx("p",{className:"text-sm text-error-500 text-center",children:d}),e.jsx("div",{children:e.jsx("button",{type:"submit",disabled:j,className:`flex items-center justify-center w-full px-4 py-3 text-sm font-medium text-white transition rounded-lg shadow-theme-xs ${j?"bg-gray-400 cursor-not-allowed":"bg-brand-500 hover:bg-brand-600"}`,children:"Sign Up"})})]})}),e.jsx("div",{className:"mt-5",children:e.jsxs("p",{className:"text-sm font-normal text-center text-gray-700 dark:text-gray-400 sm:text-start",children:["Already have an account?"," ",e.jsx(L,{to:"/signin",className:"text-brand-500 hover:text-brand-600 dark:text-brand-400",children:"Sign In"})]})})]})]})})})}function J(){const{clearProcessingState:i}=U();return t.useEffect(()=>{i()},[]),e.jsxs(e.Fragment,{children:[e.jsx(F,{title:"Scipion",description:"Scipion web"}),e.jsx(z,{children:e.jsx(D,{})})]})}export{J as default};
