import{r as l,j as e}from"./@radix-C7hRs6Kx.js";import{u as m,S as x,a as y,b as v}from"./form-schemas-CbvoEUHr.js";import{A as j,I as U,P as b,U as h,S as _}from"./UsageReason-DjI5qMje.js";import{f as g,ax as C,i as P,bd as w,l as A,S as E}from"./index-D2iSHVZq.js";import{c as F}from"./@tanstack-CSxjHCME.js";import"./check-circle-mvyzYvIW.js";import"./@react-router-CNP6g_RL.js";import"./UpdatePasswordSchemas-DbFEaezI.js";import"./zod-C0xYeTvL.js";import"./index.esm-D7jFlf5N.js";import"./gcp-CHNvgEss.js";import"./kubernetes-D6OUjwSK.js";import"./rocket-Cf-B-XOR.js";import"./@reactflow-CQi1Z1Wq.js";const S=l.createContext(null);function H({children:t,initialUser:n}){const[a,r]=l.useState(n||{});return e.jsx(S.Provider,{value:{user:a,setUser:r},children:t})}function d(){const t=l.useContext(S);if(t===null)throw new Error("useSurveyUserContext must be used within an SurveyUserProvider");return t}function D({user:t}){var u,i;const{setSurveyStep:n}=m(),{setUser:a}=d();function r({fullName:s,getUpdates:c,email:o}){a(p=>({...p,...o?{email:o}:{email:null},full_name:s,email_opted_in:c})),n(2)}return e.jsx(j,{email:(u=t.metadata)==null?void 0:u.email,fullName:(i=t.body)==null?void 0:i.full_name,submitHandler:r})}function I(){const{user:t}=d(),{setSurveyStep:n}=m(),{toast:a}=g(),r=F(),{mutate:u}=C({onSuccess:async()=>{await r.invalidateQueries({queryKey:w()}),n(s=>s+1)},onError:s=>{s instanceof Error&&a({status:"error",emphasis:"subtle",icon:e.jsx(P,{className:"h-5 w-5 shrink-0 fill-error-700"}),description:s.message,rounded:!0})}});function i({other:s,providers:c,otherVal:o}){const f={infra_providers:s?[...c,o]:c,finished_onboarding_survey:!0};u({...t,user_metadata:{...t.user_metadata,...f}})}return e.jsx(U,{submitHandler:i})}function R({user:t}){const{setSurveyStep:n}=m(),{setUser:a}=d();function r({primaryUse:u}){const i={primary_use:u};a(s=>({...s,user_metadata:{...s.user_metadata,...i}})),n(3)}return e.jsx(b,{user:t,submitHandler:r})}function k(){const{setSurveyStep:t}=m(),{setUser:n}=d();function a({usageReason:r,comparison_tools:u,otherTool:i,otherToolVal:s}){const c={usage_reason:r,...!!u&&{comparing_tools:i&&s?[...u,s]:u}};n(o=>({...o,user_metadata:{...o.user_metadata,...c}})),t(o=>o+1)}return e.jsx(h,{submitHandler:a})}function M(){const{data:t,isPending:n,isError:a}=A({throwOnError:!0}),{surveyStep:r}=m();return a?null:n?e.jsx(E,{className:"h-[300px]"}):e.jsx(e.Fragment,{children:e.jsxs(H,{children:[e.jsx(x,{stepAmount:5}),r===1&&e.jsx(D,{user:t}),r===2&&e.jsx(R,{user:t}),r===3&&e.jsx(k,{}),r===4&&e.jsx(I,{}),r===5&&e.jsx(_,{}),r===6&&e.jsx(y,{subHeader:"Your ZenML account is now updated",displayBody:!1,username:t.name})]})})}function X(){return e.jsx("div",{children:e.jsx(v,{children:e.jsx(M,{})})})}export{X as default};
