1import{w as b,a as c,p as e,v as A}from"./chunk-6CSD65Y2-B9EdUb7a.js";import{B as P}from"./Button-B5mWdm47.js";/* empty css */import"./index-CCCltmCc.js";import{P as u}from"./PageMeta-DAbMhs77.js";import{supabase as v}from"./supabase-y7-6yKvl.js";import{A as l,a as h,S as k,M as E,b as L,c as m,d as M,e as R}from"./AuthShell-BDVUMNBb.js";/* empty css */import"./LogoIcon-TjMDZPsr.js";const f=typeof window<"u"&&window.location.hostname==="localhost"?"http://localhost:8787":"https://api.motion.dev",O=b(function(){const[d,g]=c.useState(""),[p,S]=c.useState(""),[w,i]=c.useState(""),[n,o]=c.useState("idle");async function x(t){if(!t.user.email){i("No email associated with this account"),o("idle");return}const a=await fetch(`${f}/cssstudio/account-state`,{headers:{Authorization:`Bearer ${t.access_token}`}});if(!a.ok){i("Could not verify your account. Please try again."),o("idle");return}const{hasPurchase:r}=await a.json();if(!r){o("no-purchase");return}await y(t.access_token,t.refresh_token)}function j(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("cs_session")}async function y(t,s){window.opener&&window.opener.postMessage({type:"auth-token",token:t,refreshToken:s},"*");const a=j();if(a)try{await fetch(`${f}/cssstudio/auth/deposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session:a,accessToken:t,refreshToken:s})})}catch{}if(o("success"),window.opener)try{window.close()}catch{}}async function C(t){t.preventDefault(),i(""),o("loading");const s=`${window.location.origin}/login`,{data:a,error:r}=await v.auth.signUp({email:d,password:p,options:{emailRedirectTo:s}});if(r){i(r.message),o("idle");return}a.session?await x(a.session):o("confirm-email")}return n==="success"?e.jsxs(l,{children:[e.jsx(u,{title:"Create account | CSS Studio"}),e.jsx(h,{icon:e.jsx(k,{}),heading:"You're logged in",children:e.jsx("p",{children:"Your account is ready."})})]}):n==="confirm-email"?e.jsxs(l,{children:[e.jsx(u,{title:"Create account | CSS Studio"}),e.jsx(h,{icon:e.jsx(E,{}),heading:"Check your email",children:e.jsxs("p",{children:["We sent a confirmation link to ",e.jsx("strong",{children:d}),". Click it to activate your account."]})})]}):n==="no-purchase"?e.jsxs(l,{children:[e.jsx(u,{title:"Create account | CSS Studio"}),e.jsxs(h,{heading:"Purchase required",variant:"error",children:[e.jsx("p",{children:"Your account is ready, but you need to purchase CSS Studio."}),e.jsx(P,{to:"/pricing",className:"auth-btn",children:"View pricing"})]})]}):e.jsxs(l,{children:[e.jsx(u,{title:"Create account | CSS Studio"}),e.jsxs(L,{heading:"Create an account",subtitle:"Use the same email you used to purchase CSS Studio.",onSubmit:C,children:[e.jsx(m,{label:"Email",type:"email",value:d,onChange:t=>g(t.target.value),placeholder:"[email protected]",required:!0,autoFocus:!0}),e.jsx(m,{label:"Password",type:"password",value:p,onChange:t=>S(t.target.value),required:!0,minLength:6}),e.jsx(M,{children:w}),e.jsx(R,{loading:n==="loading",loadingLabel:"Creating account...",children:"Create account"})]}),e.jsxs("p",{className:"auth-switch",children:["Already have an account? ",e.jsx(A,{to:"/login",children:"Log in"})]})]})});export{O 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.