1import{z as e,A as s,a as t,p as a,B as r,w as i}from"./chunk-6CSD65Y2-xYubHBmU.js";import{I as n,L as l}from"./input-CChToGUp.js";import{U as o,B as c,c as d,W as m}from"./button-DOmK1lVo.js";import{s as x}from"./createLucideIcon-B7UGDY3i.js";import{C as h,a as u,b as p,c as j,d as f}from"./card-yAgXAo72.js";import{L as v}from"./label-D_d7Vy2l.js";import{L as N,C as g,a as y}from"./loader-circle-Mux4UJzI.js";import{M as b,U as w}from"./user-BccZgP0Q.js";import{C as S,E as C,a as k}from"./index-BcwKVuK3.js";import"./analytics-DlS0y8Gc.js";const P=({met:e,text:s})=>a.jsxs("div",{className:d("flex items-center gap-1.5 text-xs transition-colors duration-200",e?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:[e?a.jsx(y,{className:"h-3 w-3"}):a.jsx("div",{className:"h-3 w-3"}),a.jsx("span",{children:s})]}),A=()=>{const[i]=e(),l=s(),d=i.get("token"),m=i.get("email"),[A,U]=t.useState(""),[I,T]=t.useState(""),[L,F]=t.useState(""),[E,z]=t.useState(!1),[D,q]=t.useState(!1),[B,O]=t.useState(!0),[W,M]=t.useState(null),[Y,$]=t.useState(!1),[G,H]=t.useState(null),[R,V]=t.useState(!1),_={minLength:I.length>=12,hasUppercase:/[A-Z]/.test(I),hasLowercase:/[a-z]/.test(I),hasNumber:/[0-9]/.test(I),hasSpecialChar:/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(I)},J=Object.values(_).every(Boolean),Z=I===L&&L.length>0;t.useEffect(()=>{(async()=>{if(!d)return M({valid:!1,error:"No invitation token provided. Please check your invitation link."}),void O(!1);if(!m)return M({valid:!1,error:"No email provided. Please check your invitation link."}),void O(!1);try{const e=await fetch(`https://api.ustechautomations.com/api/auth/invitation/${d}?email=${encodeURIComponent(m)}`,{method:"GET",headers:{"Content-Type":"application/json"}}),s=await e.json();if(e.ok){const e=!0===s?.success&&"data"in s&&"object"==typeof s.data&&null!==s.data?s.data:s;M({valid:!0,invitation:e.invitation})}else M({valid:!1,error:s.error||"Invalid or expired invitation."})}catch{M({valid:!1,error:"Unable to validate invitation. Please try again later."})}finally{O(!1)}})()},[d,m]),t.useEffect(()=>{document.title=B?"Validating Invitation - US Tech Automations":W?.valid?R?"Welcome - US Tech Automations":"Complete Setup - US Tech Automations":"Invalid Invitation - US Tech Automations"},[B,W,R]);if(B)return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-6",children:a.jsxs("div",{className:"w-full max-w-md
1space-y-6",children:[a.jsx("div",{className:"flex justify-center",children:a.jsxs(r,{to:"/",className:"flex items-center gap-3 opacity-80 hover:opacity-100 transition-smooth",children:[a.jsx(o,{size:40}),a.jsx("span",{className:"text-xl font-semibold text-foreground",children:"USTA Platform"})]})}),a.jsx(h,{className:"border bg-card/50 backdrop-blur-sm",children:a.jsxs(u,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-5",children:a.jsx(N,{className:"h-10 w-10 text-primary animate-spin"})}),a.jsx(p,{className:"text-2xl",children:"Validating Invitation"}),a.jsx(j,{className:"text-base",children:"Please wait while we verify your invitation..."})]})})]})});if(!W?.valid)return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-6",children:a.jsxs("div",{className:"w-full max-w-md space-y-6",children:[a.jsx("div",{className:"flex justify-center",children:a.jsxs(r,{to:"/",className:"flex items-center gap-3 opacity-80 hover:opacity-100 transition-smooth",children:[a.jsx(o,{size:40}),a.jsx("span",{className:"text-xl font-semibold text-foreground",children:"USTA Platform"})]})}),a.jsxs(h,{className:"border bg-card/50 backdrop-blur-sm",children:[a.jsxs(u,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-5",children:a.jsx(g,{className:"h-12 w-12 text-destructive"})}),a.jsx(p,{className:"text-2xl",children:"Invalid Invitation"}),a.jsx(j,{className:"text-base",children:W?.error})]}),a.jsxs(f,{className:"space-y-6",children:[a.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"If you believe this is an error, please contact your administrator to request a new invitation."}),a.jsx("div",{className:"flex justify-center",children:a.jsx(c,{asChild:!0,children:a.jsx(r,{to:"/login",children:"Go to Login"})})}),a.jsx("div",{className:"pt-6 border-t border-border text-center",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Need help?"," ",a.jsx("a",{href:"mailto:[email protected]",className:"text-primary hover:text-primary/80 transition-smooth",children:"Contact Support"})]})})]})]})]})});if(R)return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-6",children:a.jsxs("div",{className:"w-full max-w-md
1space-y-6",children:[a.jsx("div",{className:"flex justify-center",children:a.jsxs(r,{to:"/",className:"flex items-center gap-3 opacity-80 hover:opacity-100 transition-smooth",children:[a.jsx(o,{size:40}),a.jsx("span",{className:"text-xl font-semibold text-foreground",children:"USTA Platform"})]})}),a.jsxs(h,{className:"border bg-card/50 backdrop-blur-sm",children:[a.jsxs(u,{className:"text-center",children:[a.jsx("div",{className:"flex justify-center mb-5",children:a.jsx(y,{className:"h-12 w-12 text-green-500"})}),a.jsx(p,{className:"text-2xl",children:"Welcome!"}),a.jsx(j,{className:"text-base",children:"Your account has been created successfully. Redirecting you to the platform..."})]}),a.jsx(f,{children:a.jsx("div",{className:"flex justify-center",children:a.jsx(N,{className:"h-6 w-6 text-green-500 animate-spin"})})})]})]})});const K=W.invitation;return a.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-6",children:a.jsxs("div",{className:"w-full max-w-md space-y-6",children:[a.jsx("div",{className:"flex justify-center",children:a.jsxs(r,{to:"/",className:"flex items-center gap-3 opacity-80 hover:opacity-100 transition-smooth",children:[a.jsx(o,{size:40}),a.jsx("span",{className:"text-xl font-semibold text-foreground",children:"USTA Platform"})]})}),a.jsxs(h,{className:"border bg-card/50 backdrop-blur-sm",children:[a.jsxs(u,{className:"text-center",children:[a.jsx(p,{className:"text-2xl",children:"Welcome to USTA"}),a.jsx(j,{className:"text-base",children:"Complete your account setup to get started"})]}),a.jsxs(f,{className:"space-y-6",children:[a.jsxs("div",{className:"rounded-lg bg-primary/10 border border-primary/20 p-4 space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx(b,{className:"h-4 w-4 text-primary"}),a.jsx("span",{className:"text-sm text-foreground",children:K.email})]}),a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx(w,{className:"h-4 w-4 text-primary"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:K.invitedBy?a.jsxs(a.Fragment,{children:["Invited as ",a.jsx("strong",{className:"text-foreground",children:K.role})," by"," ",K.invitedBy]}):a.jsxs(a.Fragment,{children:["Account type: ",a.jsx("strong",{className:"text-foreground capitalize",children:K.role})]})})]})]}),G&&a.jsxs("div",{className:"rounded-md bg-destructive/10 p-4 flex items-start gap-3",children:[a.jsx(S,{className:"h-5 w-5 text-destructive flex-shrink-0 mt-0.5"}),a.jsx("p",{className:"text-sm text-destructive",children:G})]}),a.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),H(null),A.trim())if(J)if(Z){$(!0);try{const e=await fetch("https://api.ustechautomations.com/api/auth/accept-invite",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:d,email:W?.invitation?.email||m,password:I,name:A.trim()})}),s=await e.json();if(!e.ok){const e=s.validationErrors&&"object"==typeof s.validationErrors?Object.values(s.validationErrors)[0]:void 0;return void H(("string"==typeof e?e:s.error)||"Failed to create account. Please try again.")}const t=s?.data??s;t?.token&&x.setTokens(t.token,t.expires_in),V(!0),setTimeout(()=>{l("/core/flows")},2e3)}catch{H("Connection error. Please check your network and try again.")}finally{$(!1)}}else H("Passwords do not match.");else H("Please meet all password requirements.");else H("Please enter your name.")},className:"space-y-5",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(v,{htmlFor:"name",className:"text-sm font-normal",children:"Your Name"}),a.jsx(n,{id:"name",type:"text",value:A,onChange:e=>U(e.target.value),placeholder:"Enter your full name",required:!0,disabled:Y,autoComplete:"name"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(v,{htmlFor:"password",className:"text-sm font-normal",children:"Create Password"}),a.jsxs("div",{className:"relative",children:[a.jsx(n,{id:"password",type:E?"text":"password",value:I,onChange:e=>T(e.target.value),placeholder:"Create a strong password",required:!0,disabled:Y,autoComplete:"new-password",className:"pr-10"}),a.jsx("button",{type:"button",onClick:()=>z(!E),onMouseDown:e=>e.preventDefault(),tabIndex:-1,"aria-label":E?"Hide password":"Show password",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-smooth",children:E?a.jsx(C,{className:"h-4 w-4"}):a.jsx(k,{className:"h-4 w-4"})})]}),I.length>0&&a.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3",children:[a.jsx(P,{met:_.minLength,text:"12+ characters"}),a.jsx(P,{met:_.hasUppercase,text:"Uppercase"}),a.jsx(P,{met:_.hasLowercase,text:"Lowercase"}),a.jsx(P,{met:_.hasNumber,text:"Number"}),a.jsx(P,{met:_.hasSpecialChar,text:"Special character"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(v,{htmlFor:"confirmPassword",className:"text-sm font-normal",children:"Confirm Password"}),a.jsxs("div",{className:"relative",children:[a.jsx(n,{id:"confirmPassword",type:D?"text":"password",value:L,onChange:e=>F(e.target.value),placeholder:"Confirm your password",required:!0,disabled:Y,autoComplete:"new-password",className:"pr-10"}),a.jsx("button",{type:"button",onClick:()=>q(!D),onMouseDown:e=>e.preventDefault(),tabIndex:-1,"aria-label":D?"Hide password":"Show password",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-smooth",children:D?a.jsx(C,{className:"h-4 w-4"}):a.jsx(k,{className:"h-4 w-4"})})]}),L.length>0&&a.jsx("div",{className:"flex items-center gap-1.5 mt-2",children:Z?a.jsxs(a.Fragment,{children:[a.jsx(y,{className:"h-3.5 w-3.5 text-green-500"}),a.jsx("span",{className:"text-xs text-green-500",children:"Passwords match"})]}):a.jsxs(a.Fragment,{children:[a.jsx(S,{className:"h-3.5 w-3.5 text-destructive"}),a.jsx("span",{className:"text-xs text-destructive",children:"Passwords don't match"})]})})]}),a.jsx(c,{type:"submit",className:"w-full font-normal",disabled:Y||!J||!Z||!A.trim(),children:Y?a.jsxs(a.Fragment,{children:[a.jsx(N,{className:"h-4 w-4 mr-2 animate-spin"}),"Creating Account..."]}):"Create Account"})]}),a.jsx("div",{className:"pt-6 border-t border-border text-center",children:a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Already have an account?"," ",a.jsx(r,{to:"/login",className:"text-primary hover:text-primary/80 transition-smooth",children:"Sign In"})]})})]})]})]})})},U=()=>[{title:"Accept Invitation | US Tech Automations"},{name:"robots",content:"noindex, nofollow"}],I=i(function(){return a.jsx(m,{children:a.jsx(l,{children:a.jsx(A,{})})})});export{I as default,U as meta};
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.