(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[327],{20508:(e,s,t)=>{"use strict";t.d(s,{A:()=>r});let r=(0,t(71847).A)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]])},42284:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>C});var r=t(95155),a=t(12115),l=t(20063),i=t(52619),n=t.n(i),o=t(3998),c=t(65142),d=t(55010),h=t(76444),m=t(18332),x=t(20508),u=t(23664),p=t(99708),w=t(70532),j=t(57828),f=t(7420),g=t(36489),y=t(58261),N=t(76343),b=t(37861),v=t(66091),S=t(67734);function k(){let e=(0,l.useRouter)(),s=(0,l.useSearchParams)(),t=(null==s?void 0:s.get("ref"))||void 0,i=(0,S.Ps)(),k=(0,S.jA)(),[C,A]=(0,a.useState)(!0),[E,P]=(0,a.useState)({name:"",email:"",password:"",confirmPassword:""}),[F,O]=(0,a.useState)(!1),[T,_]=(0,a.useState)(!1),[J,q]=(0,a.useState)(!1),[M,R]=(0,a.useState)(!1),[U,D]=(0,a.useState)(""),[H,I]=(0,a.useState)("");(0,a.useEffect)(()=>{A(!1)},[i,k]),(0,a.useEffect)(()=>{C||!i||k||e.push("/auth/customer/signup/phone")},[i,k,C,e]);let V=e=>{let{name:s,value:t}=e.target;P(e=>({...e,[s]:t}))},W=async s=>{if(s.preventDefault(),D(""),I(""),(()=>{if(!E.name.trim())return D("نام الزامی است"),!1;if(!E.email.trim())return D("ایمیل الزامی است"),!1;if(!E.email.includes("@"))return D("ایمیل معتبر نیست"),!1;let e=(0,N.Oj)(E.password);return e.isValid?E.password===E.confirmPassword||(D("رمز عبور و تأیید آن مطابقت ندارند"),!1):(D(e.errors[0]),!1)})()){R(!0);try{let s=await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E.name,email:E.email,password:E.password,role:"CUSTOMER",referralCode:t})}),r=await s.json();if(!s.ok)if(400===s.status)throw Error(r.message||"اطلاعات وارد شده نامعتبر است");else if(409===s.status)throw Error("کاربری با این ایمیل قبلاً ثبت نام کرده است");else throw Error("خطای سرور. لطفاً دوباره تلاش کنید");I("ثبت نام با موفقیت انجام شد! در حال ورود..."),await (0,y.SP)(E.email,E.password,"CUSTOMER",g.signIn,e)}catch(e){e instanceof Error?D(e.message):D("خطای غیرمنتظره‌ای رخ داد. لطفاً دوباره تلاش کنید")}finally{R(!1)}}};return(0,r.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-purple-900 via-blue-900 to-indigo-900 p-4",children:(0,r.jsxs)("div",{className:"max-w-md w-full space-y-8 bg-white/10 backdrop-blur-lg rounded-xl border border-white/20 p-8",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"flex justify-center mb-4",children:(0,r.jsx)("div",{className:"p-4 rounded-2xl",style:{backgroundColor:"#ffa515"},children:(0,r.jsx)(f.W,{className:"h-12 w-auto"})})}),(0,r.jsx)("h2",{className:"text-3xl font-bold text-white mb-2",children:"ثبت‌نام بازیکن"}),(0,r.jsx)("p",{className:"text-gray-300",children:"عضو جامعه گیمرهای پلیمو شوید"})]}),U&&(0,r.jsx)(m.Fc,{className:"border-red-500/50 bg-red-500/10 text-red-200",children:(0,r.jsx)(m.TN,{children:U})}),H&&(0,r.jsx)(m.Fc,{className:"border-green-500/50 bg-green-500/10 text-green-200",children:(0,r.jsx)(m.TN,{children:H})}),(0,r.jsxs)("form",{onSubmit:W,className:"space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(h.J,{htmlFor:"name",className:"text-white",children:"نام و نام خانوادگی"}),(0,r.jsxs)("div",{className:"relative mt-1",children:[(0,r.jsx)(c.p,{id:"name",name:"name",type:"text",required:!0,value:E.name,onChange:V,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10",placeholder:"نام خود را وارد کنید"}),(0,r.jsx)(x.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(h.J,{htmlFor:"email",className:"text-white",children:"ایمیل"}),(0,r.jsxs)("div",{className:"relative mt-1",children:[(0,r.jsx)(c.p,{id:"email",name:"email",type:"email",required:!0,value:E.email,onChange:V,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10",placeholder:"ایمیل خود را وارد کنید"}),(0,r.jsx)(u.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(h.J,{htmlFor:"password",className:"text-white",children:"رمز عبور"}),(0,r.jsxs)("div",{className:"relative mt-1",children:[(0,r.jsx)(d.y,{id:"password",name:"password",type:F?"text":"password",required:!0,value:E.password,onChange:V,onFocus:()=>q(!0),className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 pl-10",placeholder:"رمز عبور امن وارد کنید"}),(0,r.jsx)(p.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,r.jsx)("button",{type:"button",onClick:()=>O(!F),className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white",children:F?(0,r.jsx)(w.A,{className:"h-4 w-4"}):(0,r.jsx)(j.A,{className:"h-4 w-4"})})]}),J&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(b.u,{password:E.password})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(h.J,{htmlFor:"confirmPassword",className:"text-white",children:"تأیید رمز عبور"}),(0,r.jsxs)("div",{className:"relative mt-1",children:[(0,r.jsx)(d.y,{id:"confirmPassword",name:"confirmPassword",type:T?"text":"password",required:!0,value:E.confirmPassword,onChange:V,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 pl-10",placeholder:"رمز عبور را مجدداً وارد کنید"}),(0,r.jsx)(p.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,r.jsx)("button",{type:"button",onClick:()=>_(!T),className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white",children:T?(0,r.jsx)(w.A,{className:"h-4 w-4"}):(0,r.jsx)(j.A,{className:"h-4 w-4"})})]})]}),(0,r.jsx)(o.$,{type:"submit",disabled:M,className:"w-full bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 text-white font-medium py-3",children:M?"در حال ثبت نام...":"ثبت نام"}),(0,r.jsxs)("div",{className:"text-center text-sm space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("span",{className:"text-gray-300",children:["قبلاً حساب کاربری دارید؟"," "]}),(0,r.jsx)(n(),{href:(0,v.kk)(),className:"text-purple-400 font-medium hover:text-purple-300 hover:underline",children:"ورود"})]}),!i&&(0,r.jsx)("div",{children:(0,r.jsx)(n(),{href:"/auth/customer/signup/phone",className:"text-gray-400 hover:text-gray-300 hover:underline",children:"ثبت نام با شماره موبایل"})})]})]}),(0,r.jsx)("div",{className:"text-center mt-6",children:(0,r.jsx)(n(),{href:"/",className:"text-sm text-gray-400 hover:text-gray-300 hover:underline",children:"بازگشت به صفحه اصلی"})})]})})}function C(){return(0,r.jsx)(a.Suspense,{fallback:(0,r.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-purple-900 via-blue-900 to-indigo-900",children:(0,r.jsx)("div",{className:"text-white",children:"در حال بارگذاری..."})}),children:(0,r.jsx)(k,{})})}},66049:(e,s,t)=>{Promise.resolve().then(t.bind(t,42284))}},e=>{e.O(0,[7620,8501,6489,8720,3003,4623,7358],()=>e(e.s=66049)),_N_E=e.O()}]);