import{r as p,j as e}from"./@radix-Cdvw4jJ8.js";import{u as d,S as h,a as j,b as y}from"./form-schemas-dyDkAxXP.js";import{E as w}from"./EmptyState-CjrgDtVk.js";import{A,I as U,P as b,U as P,S as g}from"./UsageReason-DhiUV1bu.js";import{f as _}from"./@react-router-DeDfXbUF.js";import{f as F,i as C,F as E,j as N,u as k,a as H,S as I}from"./index-BgEfQ3_G.js";import{c as M}from"./@tanstack-5gTMR7G2.js";import{u as D}from"./login-mutation-C1hvP_cX.js";import{S as R}from"./SetPassword-BmbgL_ed.js";import"./check-circle-C4tYvbtw.js";import"./UpdatePasswordSchemas-D_DCETSO.js";import"./zod-XdS2h1ws.js";import"./index.esm-DhJo3mA6.js";import"./gcp-B1I3Qvcx.js";import"./@reactflow-B_iCtR7X.js";import"./PasswordChecker-B88WjuCe.js";const S=p.createContext(null);function T({children:t,initialUser:r}){const[a,s]=p.useState(r||{});return e.jsx(S.Provider,{value:{newUser:a,setNewUser:s},children:t})}function l(){const t=p.useContext(S);if(t===null)throw new Error("useActivationContext must be used within an ActivationProvider");return t}function L(){const{setSurveyStep:t}=d(),{setNewUser:r,newUser:a}=l();function s({fullName:n,getUpdates:o,email:u}){r(c=>({...c,...u?{email:u}:{email:null},full_name:n,email_opted_in:o})),t(c=>c+1)}return e.jsx(A,{email:a.email,fullName:a.full_name,submitHandler:s})}async function z({userId:t,body:r}){const a=C(N.users.activate(t)),s=await F(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 E({status:s.status,statusText:s.statusText,message:n})}return s.json()}function J(t){return M({mutationFn:async r=>z(r),...t})}function O({userId:t,setUsername:r}){const{newUser:a}=l(),{setAuthState:s}=k(),{setSurveyStep:n}=d(),{mutate:o}=D({onSuccess:()=>{s("true"),n(i=>i+1)}}),{toast:u}=H(),{mutate:c}=J({onSuccess:async i=>{r(i.name),o({username:i.name,password:a.password??void 0})},onError:i=>{i instanceof Error&&u({status:"error",emphasis:"subtle",icon:e.jsx(I,{className:"h-5 w-5 shrink-0 fill-error-700"}),description:i.message,rounded:!0})}});function m({other:i,providers:f,otherVal:x}){const v={infra_providers:i?[...f,x]:f,finished_onboarding_survey:!0};c({userId:t,body:{...a,user_metadata:{...a.user_metadata,...v}}})}return e.jsx(U,{submitHandler:m})}function W(){const{setSurveyStep:t}=d(),{setNewUser:r}=l();function a({newPassword:s}){r(n=>({...n,password:s})),t(n=>n+1)}return e.jsx(R,{submitHandler:a})}function Y(){const{setSurveyStep:t}=d(),{setNewUser:r}=l();function a({primaryUse:s}){const n={primary_use:s};r(o=>({...o,user_metadata:{...o.user_metadata,...n}})),t(o=>o+1)}return e.jsx(b,{submitHandler:a})}function Z(){const{setSurveyStep:t}=d(),{setNewUser:r}=l();function a({usageReason:s,comparison_tools:n,otherTool:o,otherToolVal:u}){const c={usage_reason:s,...!!n&&{comparing_tools:o&&u?[...n,u]:n}};r(m=>({...m,user_metadata:{...m.user_metadata,...c}})),t(m=>m+1)}return e.jsx(P,{submitHandler:a})}function q(){const{surveyStep:t}=d(),[r]=_(),[a,s]=p.useState(""),n=r.get("user"),o=r.get("token");return!n||!o?e.jsx(w,{children:e.jsx("p",{children:"Invalid activation link."})}):e.jsx(e.Fragment,{children:e.jsxs(T,{initialUser:{activation_token:o},children:[e.jsx(h,{stepAmount:6}),t===1&&e.jsx(L,{}),t===2&&e.jsx(W,{}),t===3&&e.jsx(Y,{}),t===4&&e.jsx(Z,{}),t===5&&e.jsx(O,{setUsername:s,userId:n}),t===6&&e.jsx(g,{}),t===7&&e.jsx(j,{subHeader:"Your created your ZenML account",username:a})]})})}function mt(){return e.jsx("div",{children:e.jsx(y,{children:e.jsx(q,{})})})}export{mt as default};
