PageSourceSearch

https://thehealthblueprint.netlify.app/assets/OnboardingPage-kRNEd8cY.js

js thehealthblueprint.netlify.app collected 2026-10-03 11:30:52 UTC 18,530 bytes, 1 lines download raw bytes

1import{u as he,e as ee,s as me,d as ge,j as e,P as xe}from"./index-qxLdu01o.js";import{h as pe,r as o}from"./react-vendor-DiO3iB5x.js";import{D as be,O as C,a as M}from"./Dashboard-jvWXZLnz.js";import{l as fe,k as ye}from"./firebase-vendor-D4ueP5ox.js";import{c as je,g as ve}from"./checkout-Wfzv-Z50.js";import{X as te,b as se,c as Ne}from"./ui-vendor-BQuO2PEF.js";import"./epub-vendor-BazRY6S7.js";import"./AdminPanel-DrQ-Fdx_.js";import"./editor-vendor-DpdRwt6R.js";import"./landingAnalytics-BeOIaztk.js";import"./bookLandingSeo-CBuy-xSJ.js";import"./siteUrl-eTryvWpS.js";import"./config-C5REQQhu.js";const A="#f9f7f2",m=7,le=8,S=3e3,we=5e3,ke=600;function Ce(s){if(s===0)return null;const a={1:"your name",2:"your age",3:"your height",4:"your weight",5:"your health goals",6:"your restrictions",7:"your notes"}[s];return a?`Analyzing ${a}…`:s===m?"Building your health picture…":"Analyzing your responses…"}function Se(s){return{0:"Name",1:"Age",2:"Height",3:"Weight",4:"Health goals",5:"Restrictions",6:"Preferences"}[s]??`Step ${s+1}`}function Ae(s){return s<=3?"Body composition analysis":s===4?"Understanding health goals":s===5?"Building in restrictions":s===6?"Modifying plan based on preferences":"Building your plan"}function re(s){const l=s==null?void 0:s.trim();return l&&l.split(/\s+/)[0]||"there"}function G(s){var g,d,f,y;const l=[],a=(h,u)=>h.length<=u?h:h.slice(0,u)+"…";if((g=s.displayName)!=null&&g.trim()&&l.push({label:"Adding your name",detail:s.displayName.trim()}),s.age!=null||s.height!=null||s.weight!=null){const h=[s.age!=null?`Age ${s.age}`:"",s.height!=null?`${s.height} ${s.heightUnit??"cm"}`:"",s.weight!=null?`${s.weight} ${s.weightUnit??"kg"}`:""].filter(Boolean);l.push({label:"Adding age & body metrics",detail:h.join(" · ")})}return(d=s.healthGoals)!=null&&d.trim()&&l.push({label:"Incorporating your goals",detail
1:a(s.healthGoals.trim(),48)}),(f=s.restrictions)!=null&&f.trim()&&l.push({label:"Adding restrictions",detail:a(s.restrictions.trim(),48)}),(y=s.notes)!=null&&y.trim()&&l.push({label:"Adding your preferences",detail:a(s.notes.trim(),48)}),l.push({label:"Finalizing your plan",detail:""}),l}function ae({questionIndex:s,form:l,setForm:a,inputRef:g,onKeyDown:d,showCalculatingLine:f,analyzingMessage:y}){const h={backgroundColor:A},u={ref:g,onKeyDown:d,style:h,className:"caret-blue-600"};return e.jsxs("div",{className:`w-full ${s===0?"pt-0":""}`,children:[s===0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"-mt-2 mb-8 rounded-2xl border border-blue-100 bg-white/90 p-5 shadow-sm",children:[e.jsx("p",{className:"text-lg font-medium text-gray-900 mb-1",children:"Welcome to Your Blueprint!"}),e.jsx("p",{className:"text-gray-600 text-[15px] leading-relaxed",children:"Please take 2 minutes to fill out this short quiz. It will help us tailor your daily wellness plan to fit your exact needs."})]}),e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 mb-6",children:"What's your name?"}),e.jsx(C,{label:"",placeholder:"Your name",value:l.displayName??"",onChange:i=>a(n=>({...n,displayName:i.target.value})),...u})]}),s===1&&e.jsxs(e.Fragment,{children:[e.jsxs("h1",{className:"text-2xl font-semibold text-gray-900 mb-6",children:["Welcome, ",re(l.displayName),"! How old are you?"]}),e.jsx(C,{label:"",type:"text",inputMode:"numeric",placeholder:"Age",value:l.age!=null?String(l.age):"",onChange:i=>{const n=i.target.value.replace(/\D/g,"").slice(0,3);a(x=>({...x,age:n===""?void 0:parseInt(n,10)||void 0}))},...u})]}),s===2&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 mb-6",children:"Got it! What's your height?"}),e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("div",{className:"w-28 shrink-0",children:e.jsx(C,{label:"",type:"text",inputMode:"decimal",placeholder:"170",value:l.height!=null?String(l.height):"",onChange:i=>{const n=i.target.value.trim();a(x=>({...x,height:n===""?void 0:parseFloat(n)||void 0}))},...u})}),e.jsxs("select",{className:"pb-3 text-[18px] text-gray-900 bg-transparent border-0 border-b-2 border-gray-300 focus:outline-none focus:border-blue-500 shrink-0",style:h,value:l.heightUnit??"cm",onChange:i=>a(n=>({...n,heightUnit:i.target.value})),children:[e.jsx("option",{value:"cm",children:"cm"}),e.jsx("option",{value:"in",children:"in"})]})]})]}),s===3&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 mb-6",children:"Almost there! What's your weight?"}),e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("div",{className:"w-28 shrink-0",children:e.jsx(C,{label:"",type:"text",inputMode:"decimal",placeholder:"70",value:l.weight!=null?String(l.weight):"",onChange:i=>{const n=i.target.value.trim();a(x=>({...x,weight:n===""?void 0:parseFloat(n)||void 0}))},...u})}),e.jsxs("select",{className:"pb-3 text-[18px] text-gray-900 bg-transparent border-0 border-b-2 border-gray-300 focus:outline-none focus:border-blue-500 shrink-0",style:h,value:l.weightUnit??"kg",onChange:i=>a(n=>({...n,weightUnit:i.target.value})),children:[e.jsx("option",{value:"kg",children:"kg"}),e.jsx("option",{value:"lb",children:"lb"})]})]})]}),s===4&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 mb-2",children:"Thanks! What are your health goals?"}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:"e.g. better sleep, more energy, weight management"}),e.jsx(M,{placeholder:"Tell us your main health goals...",rows:3,value:l.healthGoals??"",onChange:i=>a(n=>({...n,healthGoals:i.target.value})),ref:g,onKeyDown:d,style:h,className:"caret-blue-600"})]}),s===5&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 mb-2",children:"Got it. Any restrictions we should know?"}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:"Dietary or activity restrictions"}),e.jsx(M,{placeholder:"e.g. no dairy, avoid high impact...",rows:3,value:l.restrictions??"",onChange:i=>a(n=>({...n,restrictions:i.target.value})),ref:g,onKeyDown:d,style:h,className:"caret-blue-600"})]}),s===6&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 mb-2",children:"Last one! Anything else?"}),e.jsx("p",{className:"text-gray-600 text-sm mb-6",children:"Optional notes for your custom plan."}),e.jsx(M,{placeholder:"e.g. medication, schedule, preferences...",rows:3,value:l.notes??"",onChange:i=>a(n=>({...n,notes:i.target.value})),ref:g,onKeyDown:d,style:h,className:"caret-blue-600"})]})]})}const Re=()=>{var H,Q,Y,X,Z,J,K;const s=pe(),{user:l}
1=he(),[a,g]=o.useState(0),[d,f]=o.useState(null),[y,h]=o.useState(!1),[u,i]=o.useState(!1),[n,x]=o.useState("idle"),[ne,T]=o.useState(null),[N,O]=o.useState(!1),[P,ie]=o.useState(null),[U,oe]=o.useState(0),[E,B]=o.useState(0),I=o.useRef(null),j=o.useRef(null),L=o.useRef(!1),[r,D]=o.useState({displayName:"",age:void 0,height:void 0,heightUnit:"cm",weight:void 0,weightUnit:"kg",healthGoals:"",restrictions:"",notes:""});o.useEffect(()=>{l||s("/",{replace:!0})},[l,s]),o.useEffect(()=>{l&&ee(l.uid,l.email??null).catch(t=>console.error("Failed to ensure user doc:",t))},[l]);const ce=((d??a)+1)/le*100,z=()=>{a>=le-1||y||(a<m-1?(f(a),h(!0)):a===m-1&&(g(m),i(!0),setTimeout(()=>i(!1),S)))},de=()=>{if(d===null)return;const t=d;f(null),h(!1),g(t+1),i(!0),setTimeout(()=>i(!1),S)},R=()=>{a>0&&g(t=>t-1)},_=()=>{l&&ee(l.uid,l.email??null).then(()=>s("/",{replace:!0})).catch(t=>console.error("Failed to ensure user doc on skip:",t))};o.useEffect(()=>{if(!u)return;const c=setTimeout(()=>i(!1),a===m?we:S);return()=>clearTimeout(c)},[u,a,d]),o.useEffect(()=>{if(a!==m||!u)return;B(0);const t=G(r),c=Math.max(0,t.length-1),b=setInterval(()=>{B(w=>w>=c?c:w+1)},ke);return()=>clearInterval(b)},[a,u,r]),o.useEffect(()=>{if(!l||a!==m||u||L.current)return;L.current=!0;const t=r;(async()=>{var c;try{await me(l.uid,{age:t.age,height:t.height,heightUnit:t.heightUnit,weight:t.weight,weightUnit:t.weightUnit,healthGoals:t.healthGoals||void 0,restrictions:t.restrictions||void 0,notes:t.notes||void 0}),(c=t.displayName)!=null&&c.trim()&&await fe(ye(ge,"users",l.uid),{displayName:t.displayName.trim()},{merge:!0})}catch(b){console.error("Failed to save onboarding profile:",b)}})()},[l,a,u,r]),o.useEffect(()=>{if(a<m&&d===null){const t=setTimeout(()=>{var c;return(c=I.current)==null?void 0:c.focus()},u?S+100:400);return()=>clearTimeout(t)}},[a,d,u]),o.useEffect(()=>{if(!N||!P)return;let t=!1;const c=()=>{const p=j.current;if(p){try{typeof p.destroy=="function"?p.destroy():typeof p.unmount=="function"&&p.unmount()}catch{}j.current=null}};c(),x("loading"),T(null);const b=`${window.location.origin}/?checkout=success`,w=`onboarding-checkout-drawer-${U}`;return je(b,P).then(async p=>{if(t)return;const V=await ve();if(!V||t)return;const k=V,q=`#${w}`;if(k.initEmbeddedCheckout){const v=await k.initEmbeddedCheckout({clientSecret:p});if(t)return;j.current=v,v.mount(q),x("ready")}else if(k.embedCheckout){const v=k.embedCheckout({clientSecret:p,returnUrl:b});if(t)return;j.current=v,v.mount(q),x("ready")}else T("Embedded checkout is not available. Please try again or use a different browser."),x("error")}).catch(p=>{t||(T(p instanceof Error?p.message:"Failed to load checkout"),x("error"))}),()=>{t=!0,c()}},[N,P,U]);const ue=t=>{ie(t),oe(Date.now()),O(!0)},F=()=>{const t=j.current;if(t){try{typeof t.destroy=="function"?t.destroy():typeof t.unmount=="function"&&t.unmount()}catch{}j.current=null}O(!1)};if(!l)return null;const $=d??a,W=a<m?Ae($):null;return e.jsxs("div",{className:"min-h-screen relative",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:e.jsx(be,{})}),e.jsx("div",{className:"absolute inset-0 backdrop-blur-md bg-black/20 pointer-events-none","aria-hidden":!0}),e.jsxs("div",{className:"relative z-10 min-h-screen flex flex-col items-center justify-center p-[10px]",children:[e.jsxs("div",{className:"relative w-full max-w-lg md:max-w-6xl flex flex-col rounded-2xl overflow-hidden shadow-xl min-h-[calc(100vh-20px)] max-h-[calc(100vh-20px)]",style:{backgroundColor:A},children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("div",{className:"h-1 bg-gray-200",children:e.jsx("div",{className:"h-full bg-blue-600 transition-all duration-300 ease-out",style:{width:`${ce}%`}})}),W&&e.jsx("p",{className:"text-xs text-gray-500 mt-1.5 text-center max-w-lg mx-auto px-4",children:W})]}),e.jsx("button",{type:"button",onClick:_,className:"absolute top-3 right-3 z-10 p-2 rounded-lg text-gray-500 hover:text-gray-700 hover:bg-gray-200/80 transition-colors","aria-label":"Skip and go to my plan",children:e.jsx(te,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 p-6",children:[a<m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a>0&&e.jsx("button",{type:"button",onClick:R,className:"p-2 -ml-2 roun
1ded-lg hover:bg-gray-200/80 transition-colors","aria-label":"Back",children:e.jsx(se,{className:"w-5 h-5 text-gray-600"})}),e.jsx("span",{className:"text-sm font-medium text-gray-500",children:Se($)})]}),e.jsx("div",{className:`flex-1 flex min-h-0 overflow-hidden ${$===0?"items-start justify-center pt-0":"items-center justify-center"}`,children:d!==null?e.jsx("div",{className:"animate-slide-out-up w-full",onAnimationEnd:de,children:e.jsx(ae,{questionIndex:d,form:r,setForm:D,inputRef:I,showCalculatingLine:!1,analyzingMessage:null})},`exit-${d}`):e.jsx("div",{className:"animate-slide-up w-full",children:e.jsx(ae,{questionIndex:a,form:r,setForm:D,inputRef:I,showCalculatingLine:u,analyzingMessage:Ce(a),onKeyDown:t=>{t.key==="Enter"&&!(t.target instanceof HTMLTextAreaElement)&&(t.preventDefault(),z())}})},`enter-${a}`)}),e.jsxs("div",{className:"mt-auto pt-8",children:[e.jsxs("button",{type:"button",onClick:z,disabled:y,className:"w-full flex items-center justify-center gap-2 py-3.5 px-4 rounded-xl font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 transition-colors",children:[a===m-1?"Continue to summary":"Next",e.jsx(Ne,{className:"w-5 h-5"})]}),e.jsx("button",{type:"button",onClick:_,className:"w-full mt-3 text-sm font-normal text-gray-500 hover:text-gray-700 transition-colors",children:"Skip and take me to my plan"})]})]}),a===m&&e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:u?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center min-h-0 py-8",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-6",children:"Building your plan"}),e.jsx("div",{className:"w-full max-w-sm space-y-2",children:(()=>{const t=G(r),c=t[E]??t[t.length-1];return e.jsxs("div",{className:"rounded-xl border border-blue-100 bg-white/90 px-4 py-3 text-center animate-fade-in",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:c.label}),c.detail&&e.jsx("p",{className:"text-xs text-gray-600 mt-1 truncate max-w-full",title:c.detail,children:c.detail})]},E)})()}),e.jsx("div",{className:"mt-6 h-1 w-48 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-blue-500 rounded-full transition-all duration-300",style:{width:`${(()=>{const t=G(r);return t.length>0?(E+1)/t.length*100:0})()}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"rounded-xl border-2 border-emerald-200 bg-emerald-50/90 p-5 shadow-sm",children:[e.jsx("h3",{className:"flex items-center gap-2 text-lg font-semibold text-emerald-900 mb-2",children:(H=r.displayName)!=null&&H.trim()?`${re(r.displayName).replace(/^./,t=>t.toUpperCase())}, your wellness plan is ready!`:"Your wellness plan is ready!"}),e.jsx("p",{className:"text-emerald-800 text-[15px] leading-relaxed mb-3",children:"Based on your goals and preferences, we've built a daily plan designed just for you. Unlock your plan below."}),(r.age!=null||r.height!=null||r.weight!=null||((Q=r.healthGoals)==null?void 0:Q.trim())||((Y=r.restrictions)==null?void 0:Y.trim())||((X=r.notes)==null?void 0:X.trim()))&&e.jsxs("div",{className:"text-sm text-emerald-800/90 border-t border-emerald-200/80 pt-3 mt-3 space-y-1.5",children:[(r.age!=null||r.height!=null||r.weight!=null)&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Profile:"})," ",[r.age!=null&&`Age ${r.age}`,r.height!=null&&`${r.height} ${r.heightUnit??"cm"}`,r.weight!=null&&`${r.weight} ${r.weightUnit??"kg"}`].filter(Boolean).join(" · ")]}),((Z=r.healthGoals)==null?void 0:Z.trim())&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Goals:"})," ",r.healthGoals.trim().length>60?r.healthGoals.trim().slice(0,60)+"…":r.healthGoals.trim()]}),((J=r.restrictions)==null?void 0:J.trim())&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Restrictions:"})," ",r.restrictions.trim().length>60?r.restrictions.trim().slice(0,60)+"…":r.restrictions.trim()]}),((K=r.notes)==null?void 0:K.trim())&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Notes:"})," ",r.notes.trim().length>60?r.notes.trim().slice(0,60)+"…":r.notes.trim()]})]})]})}),e.jsx("div",{className:"mt-4 space-y-3",children:xe.map(t=>e.jsxs("button",{type:"button",onClick:()=>ue(t.priceId),className:`relative w-full text-left rounded-xl border-2 p-4 transition-all ${t.badge==="MOST POPULAR"?"border-blue-500 bg-blue-50/80 shadow-sm pt-6":"border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50/80"}`,children:[t.badge==="MOST POPULAR"&&e.jsx("span",{className:"absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 text-xs font-medium px-2.5 py-1 rounded-full bg-blue-600 text-white shadow-sm",children:t.badge}),e.jsxs("div",{className:"flex justify-between items-start gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap min-w-0 flex-1",children:[e.jsx("span",{className:"font-semibold text-gray-900",children:t.label}),e.jsxs("span",{className:"flex items-center gap-2 shrink-0",children:[t.badge&&t.badge!=="MOST POPULAR"&&e.jsx("span",{className:"text-xs font-medium px-2 py-0.5 rounded-full bg-gray-200 text-gray-700",children:t.badge}),t.savingsPercent!=null&&e.jsxs("span",{className:"text-xs font-medium text-emerald-700 bg-emerald-100 px-2 py-0.5 rounded-full",children:["Save ",t.savingsPercent,"%"]})]})]}),e.jsx("p",{className:"text-lg font-semibold text-gray-900 shrink-0",children:t.priceDisplay})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:t.priceLabel}),e.jsx("ul",{className:"mt-2 space-y-1 text-sm text-gray-600 list-disc list-inside",children:t.bullets.map((c,b)=>e.jsx("li",{children:c},b))})]},t.priceId))}),e.jsxs("button",{type:"button",onClick:R,className:"mt-6 flex items-center gap-1 py-3 px-4 roun
1ded-xl font-medium text-gray-700 bg-white border border-gray-200 hover:bg-gray-50",children:[e.jsx(se,{className:"w-4 h-4"})," Back"]})]})})]})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-black/40 z-40 transition-opacity",onClick:F,"aria-hidden":"true"}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-full max-w-md bg-white shadow-2xl z-50 transform transition-transform duration-300 ease-out ${N?"translate-x-0":"translate-x-full"}`,style:{backgroundColor:A},role:"dialog","aria-label":"Complete your subscription",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 shrink-0",style:{backgroundColor:A},children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Complete your subscription"}),e.jsx("button",{type:"button",onClick:F,className:"p-2 rounded-lg hover:bg-gray-200/80 transition-colors","aria-label":"Close",children:e.jsx(te,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",children:[(n==="loading"||n==="ready")&&e.jsxs("div",{className:"relative min-h-[400px]",children:[e.jsx("div",{id:`onboarding-checkout-drawer-${U}`,className:"min-h-[400px] rounded-xl overflow-hidden"}),n==="loading"&&e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-gray-50 rounded-xl border border-gray-200",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mb-2"}),e.jsx("p",{className:"text-gray-500 text-sm",children:"Loading checkout…"})]})]}),n==="error"&&e.jsx("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-red-700 text-sm",children:ne})]})]})})]})]})]})};export{Re as OnboardingPage};

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.