1import{a as L,r as s,j as e,L as A,t as i,s as j}from"./index-DKEWaK1D.js";import{u as E}from"./useServerFn-BVU2hO3d.js";import{e as Y}from"./transition.functions-llJR_0JB.js";import{u as M}from"./useRedirectIfAuthed-B7ci3KKl.js";import{B as O}from"./button-Ec5vWc3v.js";import{I as o}from"./input-CpUVJ0_Z.js";import{L as l}from"./label-DSzxW4ai.js";import{M as P}from"./mail-DGBWvOEq.js";import{A as R}from"./arrow-right-DoDsb52A.js";import"./utils-BQHNewu7.js";import"./createLucideIcon-d1snq85H.js";function H(){const x=L(),{checking:y,authed:d}=M("/app"),w=E(Y),[p,h]=s.useState(!1),[g,f]=s.useState(!1),[n,b]=s.useState(""),[N,v]=s.useState(""),[a,S]=s.useState(""),[c,_]=s.useState("");async function k(t){if(t.preventDefault(),!(!n.trim()||!a.trim())){if(c.length<8){i.error("Password must be at least 8 characters.");return}h(!0);try{const r=`${window.location.origin}/app`,{error:m}=await j.auth.signUp({email:a.trim(),password:c,options:{emailRedirectTo:r,data:{full_name:n}}});if(m){const u=m.message.toLowerCase();if(u.includes("already")||u.includes("registered")||u.includes("exists")){i.info("You already have an account. sign in to continue."),x({to:"/switch/login",search:{email:a.trim()}});return}throw m}const{data:C}=await j.auth.getSession();if(C.session){await w({data:{fullName:n.trim(),organisationName:N.trim()||null,roleTitle:null,mobile:null,country:null,existingAssureEmail:null}}),i.success("Account created."),x({to:"/app",replace:!0});return}f(!0)}catch(r){i.error(r instanceof Error?r.message:String(r))}finally{h(!1)}}}return(y||d)&&!g?e.jsx("div",{className:"mx-auto max-w-[460px] px-5 py-24 text-sm text-foreground/60 text-center",children:d?"Opening Your Switchâ¦":"Loadingâ¦"}):g?e.jsx("section",{className:"surface-alt",children:e.jsx("div",{className:"mx-auto max-w-[480px] px-5 py-20 md:py-28",children:e.jsxs("div",{className:"rounded-3xl border border-black/5 bg-white p-10 text-center shadow-[0_1px_2px_rgba(0,0,0,0.04),0_12px_40px_-12px_rgba(0,0,0,0.08)]",children:[e.jsx("div",{className:"mx-auto flex size-14 items-center justify-center rounded-full bg-foreground
1/5",children:e.jsx(P,{className:"size-6 text-foreground/70"})}),e.jsx("h1",{className:"mt-6 font-display text-3xl font-semibold tracking-tight",children:"Check your inbox"}),e.jsxs("p",{className:"mt-4 text-foreground/65 text-[15px] leading-relaxed",children:["We've sent a confirmation link to"," ",e.jsx("span",{className:"text-foreground font-medium",children:a}),". Click it to open Your Switch."]}),e.jsxs("p",{className:"mt-5 text-[12px] text-foreground/50",children:["Wrong address?"," ",e.jsx("button",{type:"button",onClick:()=>f(!1),className:"text-foreground hover:opacity-70",children:"Start over"})]})]})})}):e.jsx("section",{className:"surface-alt",children:e.jsxs("div",{className:"mx-auto max-w-[480px] px-5 py-20 md:py-28",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-[0.18em] text-foreground/50",children:"Your Switch"}),e.jsx("h1",{className:"mt-4 font-display text-4xl md:text-5xl font-semibold tracking-tight leading-[1.05]",children:"Let's get you started."}),e.jsx("p",{className:"mt-4 text-foreground/65 text-[15px]",children:"Set up your account in under a minute."})]}),e.jsxs("form",{onSubmit:k,className:"mt-10 space-y-5 rounded-3xl border border-black/5 bg-white p-7 shadow-[0_1px_2px_rgba(0,0,0,0.04),0_12px_40px_-12px_rgba(0,0,0,0.08)]",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{className:"text-[13px]",children:"Your name"}),e.jsx(o,{value:n,onChange:t=>b(t.target.value),required:!0,className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{className:"text-[13px]",children:"Organisation"}),e.jsx(o,{value:N,onChange:t=>v(t.target.value),placeholder:"Optional",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{className:"text-[13px]",children:"Work email"}),e.jsx(o,{type:"email",value:a,onChange:t=>S(t.target.value),required:!0,className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{className:"text-[13px]",children:"Password"}),e.jsx(o,{type:"password",minLength:8,value:c,onChange:t=>_(t.target.value),required:!0,className:"h-11"}),e.jsx("p",{className:"text-[11px] text-foreground/50",children:"Minimum 8 characters."})]}),e.jsx(O,{type:"submit",disabled:p,className:"w-full rounded-full h-11 mt-2",children:p?"Creating accountâ¦":e.jsxs(e.Fragment,{children:["Create account ",e.jsx(R,{className:"ml-1 size-4"})]})}),e.jsxs("p",{className:"text-center text-[12px] text-foreground/55 pt-1",children:["Already registered?"," ",e.jsx(A,{to:"/switch/login",className:"text-foreground hover:opacity-70",children:"Sign in"})]})]})]})})}export{H as component};
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.