1import{K as te,h as ie,i as oe,e as le,bo as ne,k as ce,P as me,r as t,j as e,bq as P,d as b,L as F,U as de,m as ue,n as pe,b as l,I as L,B as O}from"./index-Ct8eLu1I.js";import{u as he}from"./useOrganizationSlug-Im1jCHRI.js";import{P as k}from"./password-input-DW2M4R6A.js";import{T as ge,a as xe,b as R,c as $}from"./tabs-BxjRtXE_.js";import{S as fe}from"./SocialLoginButtons-BRhX2Tdp.js";import{E as ve}from"./ExistingAccountResetHelper-DlBMMj0u.js";import{o as je,s as h}from"./types-3c7sL9OC.js";import"./eye-off-D8k5J7Ic.js";import"./eye-BX6Kc3UM.js";import"./circle-check-big-B2qMybdU.js";import"./key-round-CQA2_xI6.js";import"./mail-BgXQiqCk.js";const z=je({email:h().email("Invalid email address"),password:h().min(6,"Password must be at least 6 characters")}),ye=z.extend({fullName:h().min(2,"Name must be at least 2 characters"),confirmPassword:h()}).refine(r=>r.password===r.confirmPassword,{message:"Passwords don't match",path:["confirmPassword"]}),Ie=()=>{const{orgSlug:r}=te(),[g]=ie(),x=oe(),{data:d,isLoading:Y}=he(r),{user:T,isAdmin:D,signIn:H,signUp:M,loading:f,isAdminLoading:E}=le(),{branding:s,setOrganizationFromSlug:_,contentColors:v}=ne(),V=ce(),{toast:i}=me(),[n,u]=t.useState(!1),W=g.get("tab"),[J,I]=t.useState(W==="signup"?"signup":"login"),[j,y]=t.useState(null),A=g.get("email")||"",w=g.get("redirect")||"",[p,B]=t.useState(A),[N,K]=t.useState(""),[c,G]=t.useState(A),[C,Q]=t.useState(""),[U,X]=t.useState(""),[S,Z]=t.useState("");t.useEffect(()=>{r&&_(r)},[r,_]),t.useEffect(()=>{T&&!f&&!E&&x(w||`/org/${r}/account?tab=home`)},[T,f,D,E,x,r,w]);const ee=async a=>{a.preventDefault();const m=z.safeParse({email:p,password:N});if(!m.success){i({title:"Validation Error",description:m.error.errors[0].message,variant:"destructive"});return}u(!0);const{error:o}=await H(p,N);u(!1),o?o.message==="Invalid login credentials"?(y({email:p,reason:"login"}),i({title:"Sign In Failed",description:"That email and password combination didn't work.",variant:"destructive"})):i({title:"Login Failed",description:o.message,variant:"destructive"}):(y(null),i({title:"Welcome Back!",description:"You have successfully logged in."}))},se=async a=>{a.preventDefault();const m=ye.safeParse({email:c,password:C,confirmPassword:U,fullName:S});if(!m.success){i({title:"Validation Error",description:m.error.errors[0].message,variant:"destructive"});return}u(!0);const{error:o,alreadyRegistered:re}=await M(c,C,S);u(!1),re?(B(c),I("login"),y({email:c,reason:"signup"})):i(o?{title:"Sign Up Failed",description:o.message,variant:"destructive"}:{title:"Account Created!",description:"Your account has been created. You can now view your registrations."})},q=(s==null?void 0:s.name)||(d==null?void 0:d.name)||V.racer,ae=v?{backgroundColor:v.cardBg,color:v.cardFg}:{};return f||Y?e.jsx(P,{showFooter:!1,children:e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(b,{className:"h-8 w-8 animate-spin",style:{color:(s==null?void 0:s.primary_color)||"hsl(var(--primary))"}})})}):d?e.jsx(P,{showFooter:!1,children:e.jsx("section",{className:"min-h-screen flex items-center justify-center py-12",children:e.jsx("div",{className:"container mx-auto px-4 relative z-10",children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsxs("div",{className:"text-center mb-8",children:[s!=null&&s.favicon_url?e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:s.favicon_url,alt:`${q} Icon`,className:"h-16 w-16 rounded-xl object-contain"})}):e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-xl mb-4",style:{backgroundColor:(s==null?void 0:s.primary_color)||"hsl(var(--primary))"},children:e.jsx(de,{className:"h-8 w-8 text-white"})}),e.jsxs("h1",{className:"font-display text-3xl",style:{fontFamily:s!=null&&s.font_heading?`"${s.font_heading}", sans-serif`:void 0},children:[q.toUpperCase()," ACCOUNT"]}),e.jsx("p",{className:"opacity-70 mt-2",children:"Create an account to view your past registrations"})]}),e.jsx(ue,{style:ae,className:"border",children:e.jsxs(pe,{className:"pt-6",children:[e.jsxs(ge,{value:J,onValueChange:a=>I(a),children:[e.jsxs(xe,{className:"grid w-full grid-cols-2 mb-6",children:[e.jsx(R,{value:"login",children:"Log In"}),e.jsx(R,{value:"signup",children:"Sign Up"})]}),e.jsxs($,{value:"login",children:[e.jsxs("form",{onSubmit:ee,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"login-email",children:"Email"}),e.jsx(L,{id:"login-email",type:"email",placeholder:"[email protected]",value:p,onChange:a=>B(a.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"login-password",children:"Password"}),e.jsx(k,{id:"login-password",value:N,onChange:a=>K(a.target.value),required:!0})]}),e.jsx("div",{className:"text-right",children:e.jsx(F,{to:`/org/${r}/forgot-password`,style:{color:(s==null?void 0:s.primary_color)||"hsl(var(--primary))"},className:"text-sm hover:underline",children:"Forgot password?"})}),e.jsx(O,{type:"submit",className:"w-full",style:{backgroundColor:(s==null?void 0:s.primary_color)||"hsl(var(--primary))",color:"#ffffff"},disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"mr-2 h-4 w-4 animate-spin"}),"Signing In..."]}):"Sign In"})]}),j&&e.jsx(ve,{email:j.email,reason:j.reason,primaryColor:s==null?void 0:s.primary_color})]}),e.jsxs($,{value:"signup",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 p-3 mb-4",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-amber-500 shrink-0 mt-0.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("path",{d:"M12 17h.01"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{className:"text-foreground",children:"Important:"})," Please sign up with the same email you used for your registration so your history, coupons, and wallet are linked to your account."]})]}),e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"signup-name",children:"Full Name"}),e.jsx(L,{id:"signup-name",type:"text",placeholder:"John Doe",value:S,onChange:a=>Z(a.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"signup-email",children:"Email"}),e.jsx(L,{id:"signup-email",type:"email",placeholder:"[email protected]",value:c,onChange:a=>G(a.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"signup-password",children:"Password"}),e.jsx(k,{id:"signup-password",value:C,onChange:a=>Q(a.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"signup-confirm-password",children:"Confirm Password"}),e.jsx(k,{id:"signup-confirm-password",value:U,onChange:a=>X(a.target.value),required:!0})]}),e.jsx(O,{type:"submit",className:"w-full",style:{backgroundColor:(s==null?void 0:s.primary_color)||"hsl(var(--primary))",color:"#ffffff"},disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]})]})]}),e.jsx(fe,{primaryColor:s==null?void 0:s.primary_color,disabled:n}),e.jsx("p",{className:"text-center text-sm opacity-70 mt-6",children:"Creating an account is o
1ptional. You can still register for events without one."})]})}),e.jsx("p",{className:"text-center text-sm opacity-70 mt-4",children:e.jsx(F,{to:`/org/${r}/events`,style:{color:(s==null?void 0:s.primary_color)||"hsl(var(--primary))"},className:"hover:underline",children:"â Back to events"})})]})})})}):e.jsx(P,{children:e.jsxs("div",{className:"container mx-auto px-4 py-20 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold mb-4",children:"Organization Not Found"}),e.jsx("p",{className:"opacity-70 mb-6",children:"The organization you're looking for doesn't exist or is no longer active."}),e.jsx(F,{to:"/",style:{color:(s==null?void 0:s.primary_color)||"hsl(var(--primary))"},className:"hover:underline",children:"Return to Main Site"})]})})};export{Ie 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.