import{j as e}from"./@radix-D8tIKeo-.js";import{u as l,S,a as x,b as f}from"./form-schemas-DIDGOd4P.js";import{A as y,a as h,P as v,S as j}from"./primary-role-CSDJ71nH.js";import{w as _,x as C,c2 as g,u as b,e as U}from"./index-B44sgOyQ.js";import{a as c}from"./@monaco-editor-CuNQBT0l.js";import{u as w}from"./update-current-user-mutation-CQUkpgeU.js";import{h as P}from"./@tanstack-nMqraTcu.js";import"./@elkjs-CmhuJAjY.js";import"./@react-router-D1ODL_Ub.js";import"./@zod-2qqdh1cM.js";import"./UpdatePasswordSchemas-B_4QwKjY.js";import"./bar-chart-square-check-BAWR96En.js";import"./dataflow-2-tGxvLWVU.js";import"./credit-card-DUUXYKNG.js";import"./eye-CuzpINsY.js";import"./file-text-B8km-r-t.js";import"./layout-BBB8hotd.js";import"./message-chat-square-DYzrL6MT.js";import"./slash-circle-CpQAWsOq.js";import"./transform-DsIiQtL0.js";import"./@reactflow-DgowYF6H.js";const d=c.createContext(null);function A({children:t,initialUser:n}){const[a,r]=c.useState(n||{});return e.jsx(d.Provider,{value:{user:a,setUser:r},children:t})}function p(){const t=c.useContext(d);if(t===null)throw new Error("useSurveyUserContext must be used within an SurveyUserProvider");return t}function E({user:t}){const{setSurveyStep:n}=l(),{setUser:a}=p();function r({fullName:o,getUpdates:i,email:s}){a(u=>({...u,...s?{email:s}:{email:null},full_name:o,email_opted_in:i})),n(2)}return e.jsx(y,{email:t.metadata?.email,fullName:t.body?.full_name,submitHandler:r})}function k(){const{user:t}=p(),{setSurveyStep:n}=l(),{toast:a}=_(),r=P(),{mutate:o}=w({onSuccess:async()=>{await r.invalidateQueries({queryKey:g()}),n(s=>s+1)},onError:s=>{s instanceof Error&&a({status:"error",emphasis:"subtle",icon:e.jsx(C,{className:"h-5 w-5 shrink-0 fill-error-700"}),description:s.message,rounded:!0})}});function i({biggestChallenge:s,aiTypes:u}){const m={ai_types_working_with:u,biggest_ai_challenges:s,finished_onboarding_survey:!0};o({...t,user_metadata:{...t.user_metadata,...m}})}return e.jsx(h,{submitHandler:i})}function D({user:t}){const{setSurveyStep:n}=l(),{setUser:a}=p();function r({primaryRole:o,otherVal:i}){const u={primary_role:o==="other"?i:o};a(m=>({...m,user_metadata:{...m.user_metadata,...u}})),n(3)}return e.jsx(v,{user:t,submitHandler:r})}function F(){const{data:t,isPending:n,isError:a}=b({throwOnError:!0}),{surveyStep:r}=l();return a?null:n?e.jsx(U,{className:"h-[300px]"}):e.jsx(e.Fragment,{children:e.jsxs(A,{children:[e.jsx(S,{stepAmount:4}),r===1&&e.jsx(E,{user:t}),r===2&&e.jsx(D,{user:t}),r===3&&e.jsx(k,{}),r===4&&e.jsx(j,{}),r===5&&e.jsx(x,{subHeader:"Your ZenML account is now updated",displayBody:!1,username:t.name})]})})}function ee(){return e.jsx("div",{children:e.jsx(f,{children:e.jsx(F,{})})})}export{ee as default};
