import{r as l,aJ as e,aN as x}from"./@ui-core-DKdciH1Z.js";import{u as m,S as v,a as w,b as y}from"./form-schemas-CtQXlH0G.js";import{F as j,G as A,H as g,J as P,w as _,x as b,y as U,K as C}from"./index-D7KLAbvI.js";import{A as F,a as k,P as N,S as E}from"./primary-role-T4nm9YYN.js";import{f as H}from"./@react-router-DaIuhn3X.js";import{u as M}from"./login-mutation-DXJBG58L.js";import{S as D}from"./SetPassword-CgJRXXLK.js";import"./@zod-DKyD3xVW.js";import"./UpdatePasswordSchemas-C1WO1M58.js";import"./@reactflow-CJzATMj6.js";import"./@monaco-editor-CSMpaClf.js";import"./bar-chart-square-check-Lt3fLSJ-.js";import"./dataflow-2-iGdAJFn_.js";import"./credit-card-DizUoT70.js";import"./eye-0EFEzbgA.js";import"./file-text-BLW8J__B.js";import"./layout-BRN9AeDt.js";import"./message-chat-square-SV9o-mj_.js";import"./slash-circle-DHtQ7yx0.js";import"./transform-Bq7p9csj.js";import"./PasswordChecker-B1pCmlB2.js";const p=l.createContext(null);function T({children:t,initialUser:r}){const[a,s]=l.useState(r||{});return e.jsx(p.Provider,{value:{newUser:a,setNewUser:s},children:t})}function d(){const t=l.useContext(p);if(t===null)throw new Error("useActivationContext must be used within an ActivationProvider");return t}function J(){const{setSurveyStep:t}=m(),{setNewUser:r,newUser:a}=d();function s({fullName:n,getUpdates:o,email:i}){r(c=>({...c,...i?{email:i}:{email:null},full_name:n,email_opted_in:o})),t(c=>c+1)}return e.jsx(F,{email:a.email,fullName:a.full_name,submitHandler:s})}async function I({userId:t,body:r}){const a=g(P.users.activate(t)),s=await j(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok){const n=await s.json().then(o=>Array.isArray(o.detail)?o.detail[1]:o.detail).catch(()=>"Failed to update activate user");throw new A({status:s.status,statusText:s.statusText,message:n})}return s.json()}function L(t){return x({mutationFn:async r=>I(r),...t})}function R({userId:t,setUsername:r}){const{newUser:a}=d(),{setAuthState:s}=_(),{setSurveyStep:n}=m(),{mutate:o}=M({onSuccess:()=>{s("true"),n(u=>u+1)}}),{toast:i}=b(),{mutate:c}=L({onSuccess:async u=>{r(u.name),o({username:u.name,password:a.password??void 0})},onError:u=>{u instanceof Error&&i({status:"error",emphasis:"subtle",icon:e.jsx(U,{className:"h-5 w-5 shrink-0 fill-error-700"}),description:u.message,rounded:!0})}});function S({aiTypes:u,biggestChallenge:f}){const h={ai_types_working_with:u,biggest_ai_challenges:f,finished_onboarding_survey:!0};c({userId:t,body:{...a,user_metadata:{...a.user_metadata,...h}}})}return e.jsx(k,{submitHandler:S})}function z(){const{setSurveyStep:t}=m(),{setNewUser:r}=d();function a({newPassword:s}){r(n=>({...n,password:s})),t(n=>n+1)}return e.jsx(D,{submitHandler:a})}function G(){const{setSurveyStep:t}=m(),{setNewUser:r}=d();function a({primaryRole:s,otherVal:n}){const o={primary_role:s==="other"?n:s};r(i=>({...i,user_metadata:{...i.user_metadata,...o}})),t(i=>i+1)}return e.jsx(N,{submitHandler:a})}function K(){const{surveyStep:t}=m(),[r]=H(),[a,s]=l.useState(""),n=r.get("user"),o=r.get("token");return!n||!o?e.jsx(C,{children:e.jsx("p",{children:"Invalid activation link."})}):e.jsx(e.Fragment,{children:e.jsxs(T,{initialUser:{activation_token:o},children:[e.jsx(v,{stepAmount:5}),t===1&&e.jsx(J,{}),t===2&&e.jsx(z,{}),t===3&&e.jsx(G,{}),t===4&&e.jsx(R,{setUsername:s,userId:n}),t===5&&e.jsx(E,{}),t===6&&e.jsx(w,{subHeader:"Your created your ZenML account",username:a})]})})}function lt(){return e.jsx("div",{children:e.jsx(y,{children:e.jsx(K,{})})})}export{lt as default};
