@neuctra/authix 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2869,7 +2869,7 @@ const $s = [
|
|
|
2869
2869
|
...g,
|
|
2870
2870
|
appId: d
|
|
2871
2871
|
}, E = await Bn(f, { baseUrl: T, apiKey: S });
|
|
2872
|
-
N({ type: "success", text: "Account created successfully!" }), u && u(E)
|
|
2872
|
+
N({ type: "success", text: "Account created successfully!" }), u && u(E);
|
|
2873
2873
|
} catch (f) {
|
|
2874
2874
|
const E = f.message || "Signup failed. Please try again.";
|
|
2875
2875
|
N({ type: "error", text: E }), y && y(f);
|
|
@@ -3383,7 +3383,7 @@ const $s = [
|
|
|
3383
3383
|
{ email: w, password: K, appId: S },
|
|
3384
3384
|
{ baseUrl: y, apiKey: T }
|
|
3385
3385
|
);
|
|
3386
|
-
N({ type: "success", text: `Welcome ${j.name}` }), c?.(j)
|
|
3386
|
+
N({ type: "success", text: `Welcome ${j.name}` }), c?.(j);
|
|
3387
3387
|
} catch (j) {
|
|
3388
3388
|
const X = j.message || "Login failed";
|
|
3389
3389
|
N({ type: "error", text: X }), u?.(j);
|
|
@@ -199,12 +199,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
199
199
|
*
|
|
200
200
|
* This source code is licensed under the ISC license.
|
|
201
201
|
* See the LICENSE file in the root directory of this source tree.
|
|
202
|
-
*/const Pe=$("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),$e={baseUrl:"",apiKey:"",appId:""},Gn=e=>{if(!e.baseUrl||!e.apiKey||!e.appId)throw new Error("baseUrl, apiKey, and appId are required");$e.baseUrl=e.baseUrl,$e.apiKey=e.apiKey,$e.appId=e.appId},ge=()=>$e,Zn=({logoUrl:e,logoLinkUrl:t,title:r="Create Your Account",subtitle:s="Join our platform today",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:i="#00C214",gradient:a="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,showAvatar:h=!1,loginUrl:c,onSuccess:u,onError:y})=>{const{baseUrl:R,apiKey:k,appId:d}=ge(),b={name:"",email:"",password:"",...h&&{avatarUrl:""}},[g,M]=S.useState(b),[D,_]=S.useState(!1),[T,B]=S.useState(!1),[m,N]=S.useState(null),[w,F]=S.useState({}),K=typeof window<"u"?window.innerWidth<768:!1,L=l?"#ffffff":"#111827",Y=l?"#a1a1aa":"#6b7280",Z=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",E=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",J=q=>{const{name:f,value:C}=q.target;M(z=>({...z,[f]:C})),w[f]&&F(z=>({...z,[f]:void 0}))},H=()=>{const q={};return g.name.trim()||(q.name="Name is required"),g.email.trim()?/\S+@\S+\.\S+/.test(g.email)||(q.email="Invalid email address"):q.email="Email is required",g.password?g.password.length<6&&(q.password="Password must be at least 6 characters"):q.password="Password is required",F(q),Object.keys(q).length===0},A=async q=>{if(q.preventDefault(),!!H()){B(!0),N(null);try{const f={...g,appId:d},C=await An(f,{baseUrl:R,apiKey:k});N({type:"success",text:"Account created successfully!"}),u&&u(C)
|
|
202
|
+
*/const Pe=$("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),$e={baseUrl:"",apiKey:"",appId:""},Gn=e=>{if(!e.baseUrl||!e.apiKey||!e.appId)throw new Error("baseUrl, apiKey, and appId are required");$e.baseUrl=e.baseUrl,$e.apiKey=e.apiKey,$e.appId=e.appId},ge=()=>$e,Zn=({logoUrl:e,logoLinkUrl:t,title:r="Create Your Account",subtitle:s="Join our platform today",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:i="#00C214",gradient:a="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,showAvatar:h=!1,loginUrl:c,onSuccess:u,onError:y})=>{const{baseUrl:R,apiKey:k,appId:d}=ge(),b={name:"",email:"",password:"",...h&&{avatarUrl:""}},[g,M]=S.useState(b),[D,_]=S.useState(!1),[T,B]=S.useState(!1),[m,N]=S.useState(null),[w,F]=S.useState({}),K=typeof window<"u"?window.innerWidth<768:!1,L=l?"#ffffff":"#111827",Y=l?"#a1a1aa":"#6b7280",Z=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",E=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",J=q=>{const{name:f,value:C}=q.target;M(z=>({...z,[f]:C})),w[f]&&F(z=>({...z,[f]:void 0}))},H=()=>{const q={};return g.name.trim()||(q.name="Name is required"),g.email.trim()?/\S+@\S+\.\S+/.test(g.email)||(q.email="Invalid email address"):q.email="Email is required",g.password?g.password.length<6&&(q.password="Password must be at least 6 characters"):q.password="Password is required",F(q),Object.keys(q).length===0},A=async q=>{if(q.preventDefault(),!!H()){B(!0),N(null);try{const f={...g,appId:d},C=await An(f,{baseUrl:R,apiKey:k});N({type:"success",text:"Account created successfully!"}),u&&u(C)}catch(f){const C=f.message||"Signup failed. Please try again.";N({type:"error",text:C}),y&&y(f)}finally{B(!1)}}},I={width:"100%",padding:K?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:Z,border:`1px solid ${E}`,borderRadius:"10px",color:L,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"};return n.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:[n.jsxs("div",{style:{minWidth:K?"320px":"380px",width:"100%",maxWidth:K?"340px":"390px",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:K?"30px 24px":"18px 28px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[e?n.jsx("a",{href:t||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:e,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(je,{size:40,color:i,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:L,margin:0},children:r}),n.jsx("p",{style:{fontSize:"14px",color:Y},children:s})]}),h&&g.avatarUrl&&n.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:n.jsx("img",{src:g.avatarUrl,alt:"Avatar Preview",style:{width:"60px",height:"60px",borderRadius:"50%",objectFit:"cover",border:`2px solid ${i}30`},onError:q=>{const f=q.target;f.style.display="none"}})}),n.jsxs("form",{onSubmit:A,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-name",style:{fontSize:"14px",fontWeight:500,color:L},children:"Full Name"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(je,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:Y}}),n.jsx("input",{id:"signup-name",type:"text",name:"name",placeholder:"Enter your full name",value:g.name,onChange:J,style:{...I,borderColor:w.name?"#ef4444":E}})]}),w.name&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:w.name})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-email",style:{fontSize:"14px",fontWeight:500,color:L},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(he,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:Y}}),n.jsx("input",{id:"signup-email",type:"email",name:"email",placeholder:"Enter your email address",value:g.email,onChange:J,style:{...I,borderColor:w.email?"#ef4444":E}})]}),w.email&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:w.email})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-password",style:{fontSize:"14px",fontWeight:500,color:L},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:Y}}),n.jsx("input",{id:"signup-password",type:D?"text":"password",name:"password",placeholder:"Create a secure password",value:g.password,onChange:J,style:{...I,borderColor:w.password?"#ef4444":E}}),n.jsx("button",{type:"button",onClick:()=>_(!D),style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:Y,cursor:"pointer",padding:"4px"},children:D?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]}),w.password&&n.jsx("span",{style:{color:"#ef4444",fontSize:"12px",marginTop:"2px"},children:w.password})]}),h&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"signup-avatar",style:{fontSize:"14px",fontWeight:500,color:L},children:"Avatar URL (Optional)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Qt,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:Y}}),n.jsx("input",{id:"signup-avatar",type:"url",name:"avatarUrl",placeholder:"Paste your avatar image URL",value:g.avatarUrl||"",onChange:J,style:I})]})]}),c&&n.jsx("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:n.jsx("a",{href:c,style:{color:i,textDecoration:"none",fontWeight:500},children:"Already have an account?"})}),m&&n.jsxs("div",{style:{padding:"12px",borderRadius:"12px",fontSize:"12px",display:"flex",alignItems:"start",gap:"10px",backgroundColor:m.type==="success"?`${i}15`:"rgba(239,68,68,0.1)",border:m.type==="success"?`1px solid ${i}30`:"1px solid rgba(239,68,68,0.3)",color:m.type==="success"?i:"#ef4444"},children:[m.type==="success"?n.jsx(xe,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:m.text})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:a,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600,cursor:T?"not-allowed":"pointer",opacity:T?.7:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:T?n.jsxs(n.Fragment,{children:[n.jsx(Hn,{size:18,style:{animation:"spin 1s linear infinite"}}),"Creating Account..."]}):"Create Account"})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:Y,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:i,fontWeight:600},children:"Neuctra Authix"})]})]}),n.jsx("style",{children:`
|
|
203
203
|
@keyframes spin {
|
|
204
204
|
from { transform: rotate(0deg); }
|
|
205
205
|
to { transform: rotate(360deg); }
|
|
206
206
|
}
|
|
207
|
-
`})]})},Qn=async(e,t)=>{const{email:r,password:s,appId:o}=e,{baseUrl:i,apiKey:a}=t;if(!a)throw new Error("API key is required for login");try{const l=await W.post(`${i}/users/login`,{email:r,password:s,appId:o},{headers:{"Content-Type":"application/json","x-api-key":a}});return l.data?.user&&localStorage.setItem("userInfo",JSON.stringify(l.data.user)),l.data.user}catch(l){const h=l.response?.data?.message||l.message||"Login failed";throw console.error("Login API Error:",h),{success:!1,message:h,status:l.response?.status||500}}},es=({logoUrl:e,logoLinkUrl:t,title:r="Sign In to Your Account",subtitle:s="Welcome back! Please enter your details",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:i="#00C214",gradient:a="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,signupUrl:h,onSuccess:c,onError:u})=>{const{baseUrl:y,apiKey:R,appId:k}=ge(),[d,b]=S.useState("login"),[g,M]=S.useState(1),[D,_]=S.useState(!1),[T,B]=S.useState(!1),[m,N]=S.useState(null),[w,F]=S.useState(""),[K,L]=S.useState(""),[Y,Z]=S.useState({email:"",otp:"",newPassword:"",appId:k}),E=window.innerWidth<768,J=l?"#ffffff":"#111827",H=l?"#a1a1aa":"#6b7280",A=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",I=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",q=async x=>{x.preventDefault(),B(!0),N(null);try{const j=await Qn({email:w,password:K,appId:k},{baseUrl:y,apiKey:R});N({type:"success",text:`Welcome ${j.name}`}),c?.(j),window.location.reload()}catch(j){const X=j.message||"Login failed";N({type:"error",text:X}),u?.(j)}finally{B(!1)}},f=x=>{Z({...Y,[x.target.name]:x.target.value})},C=async x=>{x.preventDefault(),B(!0),N(null);try{const j=await W.post(`${y}/users/forgot-password`,{email:Y.email,appId:k},{headers:{"x-api-key":R}});j.data.success?(M(2),N({type:"success",text:"OTP sent to your email"})):N({type:"error",text:j.data.message||"Failed to send OTP"})}catch(j){N({type:"error",text:j.response?.data?.message||"Something went wrong"})}finally{B(!1)}},z=async x=>{x.preventDefault(),B(!0),N(null);try{const j=await W.post(`${y}/users/reset-password`,Y,{headers:{"x-api-key":R}});j.data.success?(N({type:"success",text:"Password reset successfully!"}),M(1),Z({email:"",otp:"",newPassword:"",appId:k}),b("login")):N({type:"error",text:j.data.message||"Reset failed"})}catch(j){N({type:"error",text:j.response?.data?.message||"Something went wrong"})}finally{B(!1)}},O={width:"100%",padding:E?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:A,border:`1px solid ${I}`,borderRadius:"10px",color:J,fontSize:"15px",outline:"none",transition:"all 0.2s ease"};return n.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:n.jsxs("div",{style:{minWidth:E?"320px":"380px",maxWidth:E?"340px":"390px",width:"100%",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:E?"30px 24px":"18px 28px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[e?n.jsx("a",{href:t||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:e,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(je,{size:40,color:i,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:J,margin:0},children:d==="login"?r:g===1?"Forgot Password":"Reset Password"}),n.jsx("p",{style:{fontSize:"14px",color:H},children:d==="login"?s:"Follow the steps to reset your password"})]}),d==="login"&&n.jsxs("form",{onSubmit:q,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(he,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"login-email",type:"email",placeholder:"Enter your email",value:w,onChange:x=>F(x.target.value),style:O})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-password",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"login-password",type:D?"text":"password",placeholder:"Enter your password",value:K,onChange:x=>L(x.target.value),style:O}),n.jsx("button",{type:"button",onClick:()=>_(!D),style:{position:"absolute",right:"14px",padding:"4px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:H,cursor:"pointer"},children:D?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:[h&&n.jsx("a",{href:h,style:{color:i,textDecoration:"none",fontWeight:500},children:"Create new account"}),n.jsx("button",{type:"button",onClick:()=>b("forgot"),style:{background:"none",border:"none",color:i,fontWeight:500,cursor:"pointer"},children:"Forgot password?"})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:a,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600},children:T?"Signing In...":"Sign In"})]}),d==="forgot"&&n.jsxs("form",{onSubmit:g===1?C:z,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[g===1?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"forgot-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(he,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"forgot-email",type:"email",name:"email",placeholder:"Enter your email",value:Y.email,onChange:f,style:O})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"otp",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"One-Time Password (OTP)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(er,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"otp",type:"text",name:"otp",placeholder:"Enter OTP",value:Y.otp,onChange:f,style:O})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"newPassword",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"New Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"newPassword",type:"password",name:"newPassword",placeholder:"Enter new password",value:Y.newPassword,onChange:f,style:O})]})]})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:a,color:"#fff",border:"none",fontSize:"14px",borderRadius:"10px",fontWeight:600},children:T?"Please wait...":g===1?"Send Reset OTP":"Reset Password"}),n.jsx("button",{type:"button",onClick:()=>{b("login"),M(1)},style:{background:"none",border:"none",fontSize:"14px",color:H,marginTop:"6px",cursor:"pointer"},children:"Back to Login"})]}),m&&n.jsxs("div",{style:{marginTop:"16px",padding:"12px",borderRadius:"12px",fontSize:"14px",display:"flex",alignItems:"center",gap:"10px",backgroundColor:m.type==="success"?`${i}15`:"rgba(239,68,68,0.1)",border:m.type==="success"?`1px solid ${i}30`:"1px solid rgba(239,68,68,0.3)",color:m.type==="success"?i:"#ef4444"},children:[m.type==="success"?n.jsx(xe,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:m.text})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:H,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:i,fontWeight:600},children:"Neuctra Authix"})]})]})})},ts=()=>{try{const e=localStorage.getItem("userInfo");return!!(e&&e!=="undefined"&&e!=="null")}catch{return!1}},rs=({children:e,fallback:t=null,width:r,height:s})=>{if(!ts())return n.jsx(n.Fragment,{children:t});const o={display:"inline-flex",alignItems:"center",verticalAlign:"middle",...r?{width:r}:{},...s?{height:s}:{}};return n.jsx("span",{style:o,children:e})},ns=()=>{try{const e=localStorage.getItem("userInfo");return!!(e&&e!=="undefined"&&e!=="null")}catch{return!1}},ss=({children:e,fallback:t=null,width:r,height:s})=>{if(ns())return n.jsx(n.Fragment,{children:t});const o={display:"inline-flex",alignItems:"center",verticalAlign:"middle",...r?{width:r}:{},...s?{height:s}:{}};return n.jsx("span",{style:o,children:e})},os=({isOpen:e,onClose:t,onSuccess:r,onError:s,userId:o,token:i,colors:a})=>{const{baseUrl:l,apiKey:h,appId:c}=ge(),[u,y]=S.useState(!1),[R,k]=S.useState(""),[d,b]=S.useState("warning"),[g,M]=S.useState(!1);if(S.useEffect(()=>{const m=()=>{M(window.innerWidth<640)};return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]),!e)return null;const D=async()=>{y(!0),b("processing");try{const{data:m}=await W.delete(`${l}/users/delete/${o}`,{data:{appId:c},headers:{"x-api-key":h}});m.success?(r(m.message||"Account deleted successfully"),b("success"),setTimeout(()=>{localStorage.removeItem("userInfo"),localStorage.removeItem("userToken"),window.location.href="/"},2e3)):(s(m.message||"Failed to delete account"),b("warning"))}catch(m){s(m.response?.data?.message||"Something went wrong"),b("warning")}finally{y(!1)}},_=R.toLowerCase()==="delete my account",T=m=>{m.target===m.currentTarget&&d!=="processing"&&d!=="success"&&t()},B=()=>{switch(d){case"warning":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #ef4444, #dc2626)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(We,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Delete Account"})})]}),n.jsx("button",{onClick:t,"aria-label":"Close modal",style:{background:"transparent",border:"none",color:a.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.2s ease"},onMouseOver:m=>{m.currentTarget.style.backgroundColor=a.border,m.currentTarget.style.color=a.textPrimary},onMouseOut:m=>{m.currentTarget.style.backgroundColor="transparent",m.currentTarget.style.color=a.textTertiary},children:n.jsx(Pe,{size:20})})]}),n.jsxs("div",{style:{display:"flex",gap:"16px",padding:"20px",background:`${a.error}15`,border:`1px solid ${a.error}30`,borderRadius:"12px",marginBottom:"20px"},children:[n.jsx("div",{style:{color:a.error,flexShrink:0,display:"flex",alignItems:"flex-start"},children:n.jsx(sr,{size:24})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h4",{style:{color:a.textPrimary,margin:"0 0 12px 0",fontSize:"16px",fontWeight:600},children:"Before you proceed..."}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[{icon:n.jsx(Mn,{size:16}),text:"All your data will be permanently deleted"},{icon:n.jsx(Xn,{size:16}),text:"This action cannot be reversed"},{icon:n.jsx(ot,{size:16}),text:"You will lose access to all services"}].map((m,N)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",fontSize:"14px",color:a.textSecondary},children:[n.jsx("div",{style:{color:a.error,flexShrink:0},children:m.icon}),n.jsx("span",{children:m.text})]},N))})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:g?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:t,style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${a.border}`,background:"transparent",color:a.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:g?"none":1,minWidth:g?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:m=>{m.currentTarget.style.backgroundColor=a.border,m.currentTarget.style.transform="translateY(-1px)"},onMouseOut:m=>{m.currentTarget.style.backgroundColor="transparent",m.currentTarget.style.transform="translateY(0)"},children:"Cancel"}),n.jsxs("button",{onClick:()=>b("confirmation"),style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:"pointer",flex:g?"none":1,minWidth:g?"100%":"140px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:m=>{m.currentTarget.style.transform="translateY(-1px)",m.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)"},onMouseOut:m=>{m.currentTarget.style.transform="translateY(0)",m.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)"},children:[n.jsx(We,{size:16}),"Continue to Delete"]})]})]});case"confirmation":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #f59e0b, #d97706)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(sr,{size:24})}),n.jsx("div",{style:{flex:1},children:n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Confirm Deletion"})})]}),n.jsxs("div",{style:{marginBottom:"24px"},children:[n.jsxs("p",{style:{color:a.textSecondary,marginBottom:"16px",fontSize:"14px",lineHeight:"1.5"},children:["Type"," ",n.jsx("strong",{style:{color:a.textPrimary},children:'"delete my account"'})," ","to confirm:"]}),n.jsx("input",{type:"text",value:R,onChange:m=>k(m.target.value),placeholder:"delete my account",style:{width:"100%",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${_?a.success:a.error}`,backgroundColor:"transparent",color:a.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:m=>{m.target.style.boxShadow=`0 0 0 3px ${a.accent}20`},onBlur:m=>{m.target.style.boxShadow="none"},autoFocus:!0}),_&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"10px",color:a.success,fontSize:"14px",fontWeight:500},children:[n.jsx(rt,{size:16}),n.jsx("span",{children:"Confirmation accepted"})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:"column-reverse",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:()=>{b("warning"),k("")},style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${a.border}`,background:"transparent",color:a.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:g?"none":1,minWidth:g?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:m=>{m.currentTarget.style.backgroundColor=a.border,m.currentTarget.style.transform="translateY(-1px)"},onMouseOut:m=>{m.currentTarget.style.backgroundColor="transparent",m.currentTarget.style.transform="translateY(0)"},children:"Go Back"}),n.jsxs("button",{onClick:D,disabled:!_||u,style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:!_||u?"not-allowed":"pointer",flex:g?"none":1,minWidth:g?"100%":"140px",opacity:!_||u?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:!_||u?"none":"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:m=>{_&&!u&&(m.currentTarget.style.transform="translateY(-1px)",m.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)")},onMouseOut:m=>{_&&!u&&(m.currentTarget.style.transform="translateY(0)",m.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)")},children:[n.jsx(We,{size:16}),"Yes, Delete My Account"]})]})]});case"processing":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #6b7280, #4b5563)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(ce,{size:20,style:{animation:"spin 1s linear infinite"}})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Deleting Account"}),n.jsx("p",{style:{color:a.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Please wait while we process your request"})]})]}),n.jsx("div",{style:{marginBottom:"20px"},children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{text:"Removing your data",active:!0},{text:"Closing active sessions",active:!1},{text:"Finalizing deletion",active:!1}].map((m,N)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:m.active?`${a.accent}10`:"transparent"},children:[n.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:m.active?a.accent:a.textTertiary,transition:"all 0.3s ease",boxShadow:m.active?`0 0 0 4px ${a.accent}20`:"none"}}),n.jsx("span",{style:{fontSize:"14px",color:m.active?a.textPrimary:a.textSecondary,fontWeight:m.active?500:400},children:m.text})]},N))})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${a.accent}10`,borderRadius:"10px",fontSize:"14px",color:a.textSecondary},children:[n.jsx(nr,{size:18,style:{color:a.accent,flexShrink:0}}),n.jsx("span",{children:"You will be redirected to the login page shortly"})]})]});case"success":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #10b981, #059669)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(rt,{size:20})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Account Deleted"}),n.jsx("p",{style:{color:a.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Your account has been successfully deleted"})]})]}),n.jsxs("div",{style:{textAlign:"center",padding:"20px",background:`${a.success}10`,border:`1px solid ${a.success}20`,borderRadius:"12px",marginBottom:"24px"},children:[n.jsx(rt,{size:48,style:{color:a.success,marginBottom:"12px",display:"block",margin:"0 auto 12px auto"}}),n.jsx("p",{style:{color:a.textPrimary,fontSize:"16px",fontWeight:600,margin:"0 0 8px 0"},children:"Goodbye!"}),n.jsx("p",{style:{color:a.textSecondary,fontSize:"14px",margin:0,lineHeight:"1.5"},children:"Your account and all associated data have been permanently removed from our systems."})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${a.accent}10`,borderRadius:"10px",fontSize:"14px",color:a.textSecondary,justifyContent:"center"},children:[n.jsx(ce,{size:16,style:{animation:"spin 1s linear infinite",color:a.accent}}),n.jsx("span",{children:"Redirecting to login page..."})]})]})}};return n.jsxs("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e4,animation:"fadeIn 0.3s ease-out"},onClick:T,children:[n.jsx("div",{style:{backgroundColor:a.surface,border:`1px solid ${a.border}`,borderRadius:"20px",width:"100%",maxWidth:"480px",padding:"24px",boxShadow:"0 32px 64px rgba(0,0,0,0.4)",animation:"scaleIn 0.3s ease-out"},className:"delete-modal-container",children:B()}),n.jsx("style",{children:`
|
|
207
|
+
`})]})},Qn=async(e,t)=>{const{email:r,password:s,appId:o}=e,{baseUrl:i,apiKey:a}=t;if(!a)throw new Error("API key is required for login");try{const l=await W.post(`${i}/users/login`,{email:r,password:s,appId:o},{headers:{"Content-Type":"application/json","x-api-key":a}});return l.data?.user&&localStorage.setItem("userInfo",JSON.stringify(l.data.user)),l.data.user}catch(l){const h=l.response?.data?.message||l.message||"Login failed";throw console.error("Login API Error:",h),{success:!1,message:h,status:l.response?.status||500}}},es=({logoUrl:e,logoLinkUrl:t,title:r="Sign In to Your Account",subtitle:s="Welcome back! Please enter your details",footerText:o="Secure authentication powered by Neuctra Authix",primaryColor:i="#00C214",gradient:a="linear-gradient(135deg, #22c55e, #00C214)",darkMode:l=!0,signupUrl:h,onSuccess:c,onError:u})=>{const{baseUrl:y,apiKey:R,appId:k}=ge(),[d,b]=S.useState("login"),[g,M]=S.useState(1),[D,_]=S.useState(!1),[T,B]=S.useState(!1),[m,N]=S.useState(null),[w,F]=S.useState(""),[K,L]=S.useState(""),[Y,Z]=S.useState({email:"",otp:"",newPassword:"",appId:k}),E=window.innerWidth<768,J=l?"#ffffff":"#111827",H=l?"#a1a1aa":"#6b7280",A=l?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.02)",I=l?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",q=async x=>{x.preventDefault(),B(!0),N(null);try{const j=await Qn({email:w,password:K,appId:k},{baseUrl:y,apiKey:R});N({type:"success",text:`Welcome ${j.name}`}),c?.(j)}catch(j){const X=j.message||"Login failed";N({type:"error",text:X}),u?.(j)}finally{B(!1)}},f=x=>{Z({...Y,[x.target.name]:x.target.value})},C=async x=>{x.preventDefault(),B(!0),N(null);try{const j=await W.post(`${y}/users/forgot-password`,{email:Y.email,appId:k},{headers:{"x-api-key":R}});j.data.success?(M(2),N({type:"success",text:"OTP sent to your email"})):N({type:"error",text:j.data.message||"Failed to send OTP"})}catch(j){N({type:"error",text:j.response?.data?.message||"Something went wrong"})}finally{B(!1)}},z=async x=>{x.preventDefault(),B(!0),N(null);try{const j=await W.post(`${y}/users/reset-password`,Y,{headers:{"x-api-key":R}});j.data.success?(N({type:"success",text:"Password reset successfully!"}),M(1),Z({email:"",otp:"",newPassword:"",appId:k}),b("login")):N({type:"error",text:j.data.message||"Reset failed"})}catch(j){N({type:"error",text:j.response?.data?.message||"Something went wrong"})}finally{B(!1)}},O={width:"100%",padding:E?"10px 14px 10px 44px":"10px 16px 10px 44px",backgroundColor:A,border:`1px solid ${I}`,borderRadius:"10px",color:J,fontSize:"15px",outline:"none",transition:"all 0.2s ease"};return n.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:n.jsxs("div",{style:{minWidth:E?"320px":"380px",maxWidth:E?"340px":"390px",width:"100%",display:"flex",flexDirection:"column",borderRadius:"10px",fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",backgroundColor:l?"#000000":"#ffffff",padding:E?"30px 24px":"18px 28px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",marginBottom:"10px"},children:[e?n.jsx("a",{href:t||"/",target:"_self",rel:"noopener noreferrer",children:n.jsx("img",{src:e,alt:"Logo",style:{height:"50px",width:"50px",marginBottom:"10px"}})}):n.jsx(je,{size:40,color:i,style:{marginBottom:"10px"}}),n.jsx("h2",{style:{fontSize:"24px",fontWeight:700,color:J,margin:0},children:d==="login"?r:g===1?"Forgot Password":"Reset Password"}),n.jsx("p",{style:{fontSize:"14px",color:H},children:d==="login"?s:"Follow the steps to reset your password"})]}),d==="login"&&n.jsxs("form",{onSubmit:q,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(he,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"login-email",type:"email",placeholder:"Enter your email",value:w,onChange:x=>F(x.target.value),style:O})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"login-password",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"login-password",type:D?"text":"password",placeholder:"Enter your password",value:K,onChange:x=>L(x.target.value),style:O}),n.jsx("button",{type:"button",onClick:()=>_(!D),style:{position:"absolute",right:"14px",padding:"4px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",color:H,cursor:"pointer"},children:D?n.jsx(nt,{size:20}):n.jsx(st,{size:20})})]})]}),n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"13px"},children:[h&&n.jsx("a",{href:h,style:{color:i,textDecoration:"none",fontWeight:500},children:"Create new account"}),n.jsx("button",{type:"button",onClick:()=>b("forgot"),style:{background:"none",border:"none",color:i,fontWeight:500,cursor:"pointer"},children:"Forgot password?"})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:a,color:"#fff",border:"none",borderRadius:"10px",fontSize:"14px",fontWeight:600},children:T?"Signing In...":"Sign In"})]}),d==="forgot"&&n.jsxs("form",{onSubmit:g===1?C:z,style:{display:"flex",flexDirection:"column",gap:"14px"},children:[g===1?n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[n.jsx("label",{htmlFor:"forgot-email",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"Email Address"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(he,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"forgot-email",type:"email",name:"email",placeholder:"Enter your email",value:Y.email,onChange:f,style:O})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"otp",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"One-Time Password (OTP)"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(er,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"otp",type:"text",name:"otp",placeholder:"Enter OTP",value:Y.otp,onChange:f,style:O})]})]}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:[n.jsx("label",{htmlFor:"newPassword",style:{fontSize:"14px",fontWeight:500,color:l?"#ffffff":"#000000"},children:"New Password"}),n.jsxs("div",{style:{position:"relative"},children:[n.jsx(Se,{size:20,style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",color:H}}),n.jsx("input",{id:"newPassword",type:"password",name:"newPassword",placeholder:"Enter new password",value:Y.newPassword,onChange:f,style:O})]})]})]}),n.jsx("button",{type:"submit",disabled:T,style:{padding:"12px",background:a,color:"#fff",border:"none",fontSize:"14px",borderRadius:"10px",fontWeight:600},children:T?"Please wait...":g===1?"Send Reset OTP":"Reset Password"}),n.jsx("button",{type:"button",onClick:()=>{b("login"),M(1)},style:{background:"none",border:"none",fontSize:"14px",color:H,marginTop:"6px",cursor:"pointer"},children:"Back to Login"})]}),m&&n.jsxs("div",{style:{marginTop:"16px",padding:"12px",borderRadius:"12px",fontSize:"14px",display:"flex",alignItems:"center",gap:"10px",backgroundColor:m.type==="success"?`${i}15`:"rgba(239,68,68,0.1)",border:m.type==="success"?`1px solid ${i}30`:"1px solid rgba(239,68,68,0.3)",color:m.type==="success"?i:"#ef4444"},children:[m.type==="success"?n.jsx(xe,{size:20}):n.jsx(le,{size:20}),n.jsx("span",{children:m.text})]}),n.jsxs("div",{style:{textAlign:"center",fontSize:"12px",color:H,marginTop:"16px",padding:"0 4px"},children:["Secure authentication powered by"," ",n.jsx("span",{style:{color:i,fontWeight:600},children:"Neuctra Authix"})]})]})})},ts=()=>{try{const e=localStorage.getItem("userInfo");return!!(e&&e!=="undefined"&&e!=="null")}catch{return!1}},rs=({children:e,fallback:t=null,width:r,height:s})=>{if(!ts())return n.jsx(n.Fragment,{children:t});const o={display:"inline-flex",alignItems:"center",verticalAlign:"middle",...r?{width:r}:{},...s?{height:s}:{}};return n.jsx("span",{style:o,children:e})},ns=()=>{try{const e=localStorage.getItem("userInfo");return!!(e&&e!=="undefined"&&e!=="null")}catch{return!1}},ss=({children:e,fallback:t=null,width:r,height:s})=>{if(ns())return n.jsx(n.Fragment,{children:t});const o={display:"inline-flex",alignItems:"center",verticalAlign:"middle",...r?{width:r}:{},...s?{height:s}:{}};return n.jsx("span",{style:o,children:e})},os=({isOpen:e,onClose:t,onSuccess:r,onError:s,userId:o,token:i,colors:a})=>{const{baseUrl:l,apiKey:h,appId:c}=ge(),[u,y]=S.useState(!1),[R,k]=S.useState(""),[d,b]=S.useState("warning"),[g,M]=S.useState(!1);if(S.useEffect(()=>{const m=()=>{M(window.innerWidth<640)};return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]),!e)return null;const D=async()=>{y(!0),b("processing");try{const{data:m}=await W.delete(`${l}/users/delete/${o}`,{data:{appId:c},headers:{"x-api-key":h}});m.success?(r(m.message||"Account deleted successfully"),b("success"),setTimeout(()=>{localStorage.removeItem("userInfo"),localStorage.removeItem("userToken"),window.location.href="/"},2e3)):(s(m.message||"Failed to delete account"),b("warning"))}catch(m){s(m.response?.data?.message||"Something went wrong"),b("warning")}finally{y(!1)}},_=R.toLowerCase()==="delete my account",T=m=>{m.target===m.currentTarget&&d!=="processing"&&d!=="success"&&t()},B=()=>{switch(d){case"warning":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"24px",gap:"16px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #ef4444, #dc2626)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(We,{size:20})}),n.jsx("div",{children:n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Delete Account"})})]}),n.jsx("button",{onClick:t,"aria-label":"Close modal",style:{background:"transparent",border:"none",color:a.textTertiary,cursor:"pointer",padding:"8px",borderRadius:"8px",width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.2s ease"},onMouseOver:m=>{m.currentTarget.style.backgroundColor=a.border,m.currentTarget.style.color=a.textPrimary},onMouseOut:m=>{m.currentTarget.style.backgroundColor="transparent",m.currentTarget.style.color=a.textTertiary},children:n.jsx(Pe,{size:20})})]}),n.jsxs("div",{style:{display:"flex",gap:"16px",padding:"20px",background:`${a.error}15`,border:`1px solid ${a.error}30`,borderRadius:"12px",marginBottom:"20px"},children:[n.jsx("div",{style:{color:a.error,flexShrink:0,display:"flex",alignItems:"flex-start"},children:n.jsx(sr,{size:24})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h4",{style:{color:a.textPrimary,margin:"0 0 12px 0",fontSize:"16px",fontWeight:600},children:"Before you proceed..."}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[{icon:n.jsx(Mn,{size:16}),text:"All your data will be permanently deleted"},{icon:n.jsx(Xn,{size:16}),text:"This action cannot be reversed"},{icon:n.jsx(ot,{size:16}),text:"You will lose access to all services"}].map((m,N)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",fontSize:"14px",color:a.textSecondary},children:[n.jsx("div",{style:{color:a.error,flexShrink:0},children:m.icon}),n.jsx("span",{children:m.text})]},N))})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:g?"column-reverse":"row",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:t,style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${a.border}`,background:"transparent",color:a.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:g?"none":1,minWidth:g?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:m=>{m.currentTarget.style.backgroundColor=a.border,m.currentTarget.style.transform="translateY(-1px)"},onMouseOut:m=>{m.currentTarget.style.backgroundColor="transparent",m.currentTarget.style.transform="translateY(0)"},children:"Cancel"}),n.jsxs("button",{onClick:()=>b("confirmation"),style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:"pointer",flex:g?"none":1,minWidth:g?"100%":"140px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:m=>{m.currentTarget.style.transform="translateY(-1px)",m.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)"},onMouseOut:m=>{m.currentTarget.style.transform="translateY(0)",m.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)"},children:[n.jsx(We,{size:16}),"Continue to Delete"]})]})]});case"confirmation":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #f59e0b, #d97706)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(sr,{size:24})}),n.jsx("div",{style:{flex:1},children:n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Confirm Deletion"})})]}),n.jsxs("div",{style:{marginBottom:"24px"},children:[n.jsxs("p",{style:{color:a.textSecondary,marginBottom:"16px",fontSize:"14px",lineHeight:"1.5"},children:["Type"," ",n.jsx("strong",{style:{color:a.textPrimary},children:'"delete my account"'})," ","to confirm:"]}),n.jsx("input",{type:"text",value:R,onChange:m=>k(m.target.value),placeholder:"delete my account",style:{width:"100%",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${_?a.success:a.error}`,backgroundColor:"transparent",color:a.textPrimary,fontSize:"15px",outline:"none",transition:"all 0.2s ease",boxSizing:"border-box"},onFocus:m=>{m.target.style.boxShadow=`0 0 0 3px ${a.accent}20`},onBlur:m=>{m.target.style.boxShadow="none"},autoFocus:!0}),_&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"10px",color:a.success,fontSize:"14px",fontWeight:500},children:[n.jsx(rt,{size:16}),n.jsx("span",{children:"Confirmation accepted"})]})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",flexDirection:"column-reverse",justifyContent:"flex-end",alignItems:"stretch"},children:[n.jsx("button",{onClick:()=>{b("warning"),k("")},style:{padding:"10px 24px",borderRadius:"10px",border:`1.5px solid ${a.border}`,background:"transparent",color:a.textPrimary,fontSize:"14px",fontWeight:500,cursor:"pointer",flex:g?"none":1,minWidth:g?"100%":"120px",transition:"all 0.2s ease"},onMouseOver:m=>{m.currentTarget.style.backgroundColor=a.border,m.currentTarget.style.transform="translateY(-1px)"},onMouseOut:m=>{m.currentTarget.style.backgroundColor="transparent",m.currentTarget.style.transform="translateY(0)"},children:"Go Back"}),n.jsxs("button",{onClick:D,disabled:!_||u,style:{padding:"10px 24px",borderRadius:"10px",border:"none",background:"linear-gradient(135deg, #ef4444, #dc2626)",color:"white",fontSize:"14px",fontWeight:600,cursor:!_||u?"not-allowed":"pointer",flex:g?"none":1,minWidth:g?"100%":"140px",opacity:!_||u?.6:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s ease",boxShadow:!_||u?"none":"0 4px 12px rgba(239, 68, 68, 0.4)"},onMouseOver:m=>{_&&!u&&(m.currentTarget.style.transform="translateY(-1px)",m.currentTarget.style.boxShadow="0 6px 20px rgba(239, 68, 68, 0.5)")},onMouseOut:m=>{_&&!u&&(m.currentTarget.style.transform="translateY(0)",m.currentTarget.style.boxShadow="0 4px 12px rgba(239, 68, 68, 0.4)")},children:[n.jsx(We,{size:16}),"Yes, Delete My Account"]})]})]});case"processing":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #6b7280, #4b5563)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(ce,{size:20,style:{animation:"spin 1s linear infinite"}})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Deleting Account"}),n.jsx("p",{style:{color:a.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Please wait while we process your request"})]})]}),n.jsx("div",{style:{marginBottom:"20px"},children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[{text:"Removing your data",active:!0},{text:"Closing active sessions",active:!1},{text:"Finalizing deletion",active:!1}].map((m,N)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",borderRadius:"8px",transition:"all 0.2s ease",backgroundColor:m.active?`${a.accent}10`:"transparent"},children:[n.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:m.active?a.accent:a.textTertiary,transition:"all 0.3s ease",boxShadow:m.active?`0 0 0 4px ${a.accent}20`:"none"}}),n.jsx("span",{style:{fontSize:"14px",color:m.active?a.textPrimary:a.textSecondary,fontWeight:m.active?500:400},children:m.text})]},N))})}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${a.accent}10`,borderRadius:"10px",fontSize:"14px",color:a.textSecondary},children:[n.jsx(nr,{size:18,style:{color:a.accent,flexShrink:0}}),n.jsx("span",{children:"You will be redirected to the login page shortly"})]})]});case"success":return n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"24px"},children:[n.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"12px",background:"linear-gradient(135deg, #10b981, #059669)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",flexShrink:0},children:n.jsx(rt,{size:20})}),n.jsxs("div",{style:{flex:1},children:[n.jsx("h3",{style:{color:a.textPrimary,margin:0,fontSize:"20px",fontWeight:700,lineHeight:"1.3"},children:"Account Deleted"}),n.jsx("p",{style:{color:a.textTertiary,margin:"4px 0 0 0",fontSize:"14px",lineHeight:"1.4"},children:"Your account has been successfully deleted"})]})]}),n.jsxs("div",{style:{textAlign:"center",padding:"20px",background:`${a.success}10`,border:`1px solid ${a.success}20`,borderRadius:"12px",marginBottom:"24px"},children:[n.jsx(rt,{size:48,style:{color:a.success,marginBottom:"12px",display:"block",margin:"0 auto 12px auto"}}),n.jsx("p",{style:{color:a.textPrimary,fontSize:"16px",fontWeight:600,margin:"0 0 8px 0"},children:"Goodbye!"}),n.jsx("p",{style:{color:a.textSecondary,fontSize:"14px",margin:0,lineHeight:"1.5"},children:"Your account and all associated data have been permanently removed from our systems."})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px",background:`${a.accent}10`,borderRadius:"10px",fontSize:"14px",color:a.textSecondary,justifyContent:"center"},children:[n.jsx(ce,{size:16,style:{animation:"spin 1s linear infinite",color:a.accent}}),n.jsx("span",{children:"Redirecting to login page..."})]})]})}};return n.jsxs("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.8)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",zIndex:1e4,animation:"fadeIn 0.3s ease-out"},onClick:T,children:[n.jsx("div",{style:{backgroundColor:a.surface,border:`1px solid ${a.border}`,borderRadius:"20px",width:"100%",maxWidth:"480px",padding:"24px",boxShadow:"0 32px 64px rgba(0,0,0,0.4)",animation:"scaleIn 0.3s ease-out"},className:"delete-modal-container",children:B()}),n.jsx("style",{children:`
|
|
208
208
|
@keyframes fadeIn {
|
|
209
209
|
from { opacity: 0; }
|
|
210
210
|
to { opacity: 1; }
|