PageSourceSearch

https://ttypes.ai/assets/Account-CXsr2Adw.js

js ttypes.ai collected 2026-10-05 13:48:57 UTC 12,047 bytes, 1 lines download raw bytes

1import{r as i,j as e,i as w,b2 as S,B as P,a as Q,b as V,c as W,b3 as Z,A as ee,au as se,aX as ae,g as te,k as ne,f as re,aC as ie,m as le,s as ce,b4 as oe,a$ as de,b0 as me,b1 as ue}from"./index-BR27rmZV.js";import{C as K}from"./credit-card-B11kGqkk.js";import{C as M}from"./clock-BgPhcTPH.js";import{C as xe}from"./circle-alert-DK6-AC-H.js";function B({product:l,onSubscribe:A,subscribing:N,className:c}){const[n,f]=i.useState("annual"),u=l.prices.find(d=>d.interval==="month"),h=l.prices.find(d=>d.interval==="year"),o=n==="monthly"?u:h,v=l.trialDays[n],b=d=>(d/100).toFixed(2);return e.jsxs("div",{className:w("bg-card rounded-xl shadow-soft p-6 space-y-4 animate-fade-in",c),children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-semibold text-lg text-foreground mb-2",children:l.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l.description})]}),e.jsxs("div",{className:"flex items-center gap-2 p-1 bg-muted rounded-lg",children:[e.jsx("button",{onClick:()=>f("monthly"),className:w("flex-1 py-1.5 px-3 rounded-md text-xs font-medium transition-all",n==="monthly"?"bg-background shadow text-foreground":"text-muted-foreground hover:text-foreground"),children:"Monthly"}),e.jsxs("button",{onClick:()=>f("annual"),className:w("flex-1 py-1.5 px-3 rounded-md text-xs font-medium transition-all",n==="annual"?"bg-background shadow text-foreground":"text-muted-foreground hover:text-foreground"),children:["Annual"," ",u&&h&&e.jsxs("span",{className:"ml-1 text-green-600",children:["Save"," ",Math.round((u.amount*12-h.amount)/(u.amount*12)*100),"%"]})]})]}),o&&e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"text-3xl font-bold text-foreground",children:["$",b(o.amount),e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/",o.interval]})]})}),v>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 bg-green-50 dark:bg-green-900/20 px-3 py-2 rounded-lg",children:[e.jsx(S,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[v,"-day free trial"]})]}),e.jsxs(P,{variant:"navy",className:"w-full gap-2",onClick:()=>o&&A(o.id),disabled:N||!o,children:[e.jsx(K,{className:"w-4 h-4"}),N?"Redirecting to Stripe…":"Start Free Trial"]})]})}function ve(){var I,L;const[l,A]=i.useState(!1),N=Q(),{toast:c}=V(),n=W(),[f,u]=i.useState(!1),[h,o]=i.useState([]),[v,b]=i.useState(!0),[d,k]=i.useState(!1),m=h.filter(t=>t.productType!=="one_time_assessment"&&t.prices.some(r=>r.interval==="month"||r.interval==="year")),x=Z(h),j=(x==null?void 0:x.oneTimePrice)??(x==null?void 0:x.prices.find(t=>t.type==="one_time"))??null,y=j?`$${(j.amount/100).toFixed(2)}`:null,[R,$]=i.useState(!1),[T,U]=i.useState(!1),[a,_]=i.useState(null),[D,Y]=i.useState(""),[C,G]=i.useState("");i.useEffect(()=>{(async()=>{U(!0);try{const r=await te();if(r){const g=r.userId??r.username;G(g||"");const s=await ne(g),p=await re();Y(p.email??"");const z=(s==null?void 0:s.displayName)??p.name??p.preferred_username??null,H=(s==null?void 0:s.location)??p.address??null,J=(s==null?void 0:s.bio)??p.profile??null;let O=(s==null?void 0:s.avatarUrl)??p.picture??null;if(s!=null&&s.avatarKey)try{O=await ie(s.avatarKey)}catch{}_({id:g||"",preferred_name:z,location:H,bio:J,avatar_url:O,age:(s==null?void 0:s.age)??null,gender:(s==null?void 0:s.gender)??null,vocation:(s==null?void 0:s.vocation)??null,maritalStatus:(s==null?void 0:s.maritalStatus)??null})}}catch{}U(!1)})()},[]),i.useEffect(()=>{(async()=>{b(!0);try{const r=await le();o(r)}catch(r){console.error("Failed to load products:",r),c({title:"Failed to load pricing",description:"Please refresh the page to try again.",variant:"destructive"})}finally{b(!1)}})()},[c]);const E=async t=>{u(!0);try{await ce(t)}catch(r){c({title:"Unable to start checkout",description:r instanceof Error?r.message:"Please try again.",variant:"destructive"}),u(!1)}},X=async()=>{k(!0);try{await oe(j==null?void 0:j.id)}catch(t){c({title:"Unable to start checkout",description:t instanceof Error?t.message:"Please try again.",variant:"destructive"}),k(!1)}},q=async t=>{if(!C){c({title:"No session",description:"Please log in again.",variant:"destructive"});return}let r=(a==null?void 0:a.avatar_url)??null,g;if(t.profileImage)try{const s=await de(C,t.profileImage,"avatar");r=s.url,g=s.key}catch{r=t.profileImage}try{await me({userAttributes:{name:t.name??"",address:t.location??"",profile:t.bio??""}}),await ue({id:C,displayName:t.name??null,location:t.location??null,bio:t.bio??null,avatarUrl:r??null,avatarKey:g??null,email:D??null,age:t.age??null,gender:t.gender??null,vocation:t.vocation??null,maritalStatus:t.maritalStatus??null}),c({title:"Profile updated",description:"Your profile has been saved."}),_(s=>s&&{...s,preferred_name:t.name,location:t.location,bio:t.bio,avatar_url:r,age:t.age??s.age,gender:t.gender??s.gender,vocation:t.vocation??s.vocation,maritalStatus:t.maritalStatus??s.maritalStatus})}catch(s){const F=s instanceof Error?s.message:String(s);c({title:"Failed to save profile",description:F,variant:"destructive"})}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ee,{collapsed:l,onToggle:()=>A(!l)}),e.jsx("main",{className:w("transition-all duration-300 min-h-screen pb-20 md:pb-0",!N&&(l?"ml-16":"ml-60")),children:e.jsxs("div",{className:"p-6 max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-accent/20 flex items-center justify-center",children:e.jsx(se,{className:"w-6 h-6 text-accent"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-display font-semibold text-foreground",children:"Account"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage your profile information"})]})]}),e.jsxs("div",{className:"bg-card rounded-xl shadow-soft p-6 mb-6 animate-fade-in",children:[e.jsx("div",{className:"flex items-center gap-2 mb-6",children:e.jsx("h2",{className:"font-display font-semibold text-foreground",children:"Your Profile"})}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg bg-muted/30 overflow-hidden shrink-0",children:a!=null&&a.avatar_url?e.jsx("img",{src:a.avatar_url,alt:"avatar",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"NA"})}),e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx("p",{className:"font-medium",children:(a==null?void 0:a.preferred_name)||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Location"}),e.jsx("p",{className:"font-medium",children:(a==null?void 0:a.location)||"—"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Bio"}),e.jsx("p",{className:"font-medium whitespace-pre-line",children:(a==null?void 0:a.bio)||"—"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Account Email"}),e.jsx("p",{className:"font-medium",children:D||"—"})]})]})})]}),e.jsx("div",{className:"mt-4",children:e.jsx(P,{variant:"navy",onClick:()=>$(!0),disabled:T,children:T?"Loading...":"Edit Profile"})})]}),e.jsxs("div",{className:"bg-card rounded-xl shadow-soft p-6 mb-6 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(K,{className:"w-5 h-5 text-accent"}),e.jsx("h2",{className:"font-display font-semibold text-foreground",children:"Subscription"})]}),n.loading||v?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading subscription status…"}):n.isActive?e.jsxs("div",{className:"space-y-3",children:[n.isTrialing?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-blue-600",children:[e.jsx(S,{className:"w-5 h-5"}),e.jsxs("span",{className:"font-medium",children:["Free Trial Active —"," ",m.length>0&&n.plan?`$${((((I=m[0].prices.find(t=>t.interval===(n.plan==="annual"?"year":"month")))==null?void 0:I.amount)??0)/100).toFixed(2)}/${n.plan==="annual"?"year":"month"} after trial`:n.plan==="annual"?"$89.99/year after trial":"$8.99/month after trial"]})]}),n.renewsAt&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-900",children:[e.jsx(M,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:["Trial ends:"," ",new Date(n.renewsAt).toLocaleDateString()]})]}),e.jsx("p",{className:"text-xs text-blue-700 mt-1",children:"Your card will be charged after the trial period unless you cancel."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[e.jsx(S,{className:"w-5 h-5"}),e.jsxs("span",{className:"font-medium",children:["Active —"," ",m.length>0&&n.plan?`$${((((L=m[0].prices.find(t=>t.interval===(n.plan==="annual"?"year":"month")))==null?void 0:L.amount)??0)/100).toFixed(2)}/${n.plan==="annual"?"year":"month"}`:n.plan==="annual"?"$89.99/year":"$8.99/month"]})]}),n.renewsAt&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(M,{className:"w-4 h-4"}),e.jsx("span",{children:n.cancelAtPeriodEnd?`Cancels on ${new Date(n.renewsAt).toLocaleDateString()}`:`Renews on ${new Date(n.renewsAt).toLocaleDateString()}`})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You have full access to the Comprehensive Assessment and all premium features."})]}):n.isPastDue?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600",children:[e.jsx(xe,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:"Payment past due"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please update your payment method to restore access."}),m.length>0&&e.jsx(B,{product:m[0],onSubscribe:E,subscribing:f})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Subscribe to unlock the"," ",e.jsx("strong",{children:"Comprehensive Assessment"})," (12 Types, deep spiritual insights, growth recommendations), Thrive Circle, and all premium features."]}),m.length>0?e.jsx("div",{className:"grid gap-4",children:m.map(t=>e.jsx(B,{product:t,onSubscribe:E,subscribing:f},t.id))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No subscription plans available at the moment."}),x&&!n.hasAssessmentAccess&&e.jsxs("div",{className:"rounded-xl border border-accent/40 bg-card p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{className:"w-5 h-5 text-accent"}),e.jsx("h3",{className:"font-semibold text-foreground",children:"Ttypes Discovery"}),e.jsx("span",{className:"ml-auto text-xs font-medium text-primary bg-primary/10 px-2 py-0.5 rounded-full border border-primary/20",children:y?`${y} · one-time`:"one-time"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Prefer a one-time option? Take the full 12-Type comprehensive assessment and get your personal report to keep — no subscription, no trial, no recurring charges."}),e.jsx(P,{variant:"navy",className:"w-full",onClick:X,disabled:d||v,children:d?"Redirecting to Stripe…":y?`Get Ttypes Discovery — ${y}`:"Get Ttypes Discovery"})]})]})]})]})}),e.jsx(ae,{open:R,onOpenChange:$,onSave:q,initialData:{name:(a==null?void 0:a.preferred_name)??void 0,location:(a==null?void 0:a.location)??void 0,bio:(a==null?void 0:a.bio)??void 0,profileImage:(a==null?void 0:a.avatar_url)??void 0,age:(a==null?void 0:a.age)??void 0,gender:(a==null?void 0:a.gender)??void 0,vocation:(a==null?void 0:a.vocation)??void 0,maritalStatus:(a==null?void 0:a.maritalStatus)??void 0}})]})}export{ve as default};

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.