PageSourceSearch

https://trysteadier.app/assets/PickerPage-BaCvRd2_.js

js trysteadier.app collected 2026-10-02 15:59:33 UTC 17,169 bytes, 24 lines download raw bytes

vendor: 4,798 bytes, lines 1-22
1import{j as e,m as z,A as Z}from"./vendor-motion-CrVg7028.js";import{r as l,L as ee}from"./vendor-react-CMYciJPr.js";import{a as te}from"./HandDrawnIcons-4WXPd_iP.js";import{c as H,k as se,l as ae,m as ie,n as q,o as oe,p as ne,q as re,r as le,H as de,B as Y,s as j,u as W,h as ce,L as ue,A as me,S as $,v as pe,b as fe,w as G}from"./index-B58eJlvC.js";import{C as xe,a as he}from"./card-BPKN_CBw.js";import{C as ye}from"./chevron-down-Coxqo9cE.js";import{U}from"./UpgradeInlineCard-CAFx9s-o.js";import{B as ge}from"./BreathworkCard-Cr117jcy.js";import{u as be}from"./usePurchasedPrograms-3Ic4yVoF.js";import{u as K}from"./vendor-query-C4LcE4u2.js";import{L as je}from"./loader-circle-CrZD76VD.js";import"./vendor-supabase-XOXmZWMk.js";import"./arrow-right-knNoMMQa.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ve=H("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ce=H("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const _e=H("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);var E="Collapsible",[Ne,Ue]=se(E),[we,O]=Ne(E),Q=l.forwardRef((t,d)=>{const{__scopeCollapsible:h,open:y,defaultOpen:i,disabled:a,onOpenChange:u,...x}=t,[v,p]=ae({prop:y,defaultProp:i??!1,onChange:u,caller:E});return e.jsx(we,{scope:h,disabled:a,contentId:ie(),open:v,onOpenToggle:l.useCallback(()=>p(_=>!_),[p]),children:e.jsx(q.div,{"data-state":F(v),"data-disabled":a?"":void 0,...x,ref:d})})});Q.displayName=E;var V="CollapsibleTrigger",J=l.forwardRef((t,d)=>{const{__scopeCollapsible:h,...y}=t,i=O(V,h);return e.jsx(q.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":F(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...y,ref:d,onClick:oe(t.onClick,i.onOpenToggle)})});J.displayName=V;var D="CollapsibleContent",X=l.forwardRef((t,d)=>{const{forceMount:h,...y}=t,i=O(D,t.__scopeCollapsible);return e.jsx(ne,{present:h||i.open,children:({present:a})=>e.jsx(ke,{...y,ref:d,present:a})})});X.displayName=D;var ke=l.forwardRef((t,d)=>{const{__scopeCollapsible:h,present:y,children:i,...a}=t,u=O(D,h),[x,v]=l.useState(y),p=l.useRef(null),_=re(d,p),C=l.useRef(0),n=C.current,f=l.useRef(0),N=f.current,r=u.open||x,w=l.useRef(r),g=l.useRef(void 0);return l.useEffect(()=>{const m=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(m)},[]),le(()=>{const m=p.current;if(m){g.current=g.current||{transitionDuration:m.style.transitionDuration,animationName:m.style.animationName},m.style.transitionDuration="0s",m.style.animationName="none";const I=m.getBoundingClientRect();C.current=I.height,f.current=I.width,w.current||(m.style.transitionDuration=g.current.transitionDuration,m.style.animationName=g.current.animationName),v(y)}},[u.open,y]),e.jsx(q.div,{"data-state":F(u.open),"data-disabled":u.disabled?"":void 0,id:u.contentId,hidden:!r,...a,ref:_,style:{"--radix-collapsible-content-height":n?`${n}px`:void 0,"--radix-collapsible-content-width":N?`${N}px`:void 0,...t.style},children:r&&i})});function F(t){return t?"open":"closed"}var Ie=Q;const Se=Ie,Re=J,Le=X;async function T(t){try{const{data:{user:d}}=await j.auth.getUser();await j.from("safety_events").insert({user_id:(d==null?void 0:d.id)||null,risk_level:"HIGH",flags:[],safety_card_shown:!0,button_clicked:t})}catch{}}const Pe=({riskLevel:t,onDismiss:d})=>{const[h,y]=l.useState(!1),i=t==="HIGH",a=i?"You deserve support right now":"You don't have to carry this alone",u=i?`I'm really sorry you're feeling this much pain. You matter, and you deserve real support.
17
18I'm not a clinician, but I want you to be safe.
19
20If you feel you might hurt yourself or you're in immediate danger, call your local emergency number right now (911 in the U.S.).`:`I'm really glad you told me. What you're feeling is heavy, and you deserve support.
21
22I'm not a clinician, but I can share immediate resources.`;return e.jsx(z.div,{initial:{opacity:0,y:12}
22,animate:{opacity:1,y:0},transition:{duration:.4},children:e.jsx(xe,{className:"border-2 border-accent/40 bg-accent/5",children:e.jsxs(he,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{size:18,className:"text-accent"}),e.jsx("h2",{className:"font-display text-lg font-semibold text-foreground",children:a})]}),e.jsx("div",{className:"space-y-2 text-sm text-foreground/90 leading-relaxed",children:u.split(`
23
24`).map((x,v)=>e.jsx("p",{children:x},v))}),e.jsx("div",{className:"rounded-lg bg-accent/10 p-3 space-y-1 text-sm",children:e.jsxs("p",{className:"font-medium text-foreground",children:["🇺🇸 U.S.: Call or text ",e.jsx("strong",{children:"988"})," ",e.jsx("span",{className:"text-muted-foreground",children:"(Suicide & Crisis Lifeline, 24/7)"})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Y,{size:"sm",className:"gap-1.5",onClick:()=>{T("call_988"),window.open("tel:988","_self")},children:[e.jsx(_e,{size:14}),"Call 988"]}),e.jsxs(Y,{size:"sm",variant:"secondary",className:"gap-1.5",onClick:()=>{T("text_988"),window.open("sms:988","_self")},children:[e.jsx(Ce,{size:14}),"Text 988"]})]}),e.jsxs(Se,{open:h,onOpenChange:y,children:[e.jsx(Re,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors",onClick:()=>T("international_options"),children:[e.jsx(ve,{size:14}),"Show international options",e.jsx(ye,{size:12,className:`transition-transform ${h?"rotate-180":""}`})]})}),e.jsx(Le,{children:e.jsxs("div",{className:"mt-2 rounded-lg border border-border bg-card p-3 text-xs text-muted-foreground space-y-1.5",children:[e.jsxs("p",{children:["If you're outside the U.S., please call your local emergency number or visit"," ",e.jsx("a",{href:"https://findahelpline.com",target:"_blank",rel:"noopener noreferrer",className:"underline text-primary",children:"findahelpline.com"})," ","to find crisis support in your country."]}),e.jsxs("p",{children:["🇬🇧 UK: Call ",e.jsx("strong",{children:"116 123"})," (Samaritans)"]}),e.jsxs("p",{children:["🇨🇦 Canada: Call ",e.jsx("strong",{children:"988"})]}),e.jsxs("p",{children:["🇦🇺 Australia: Call ",e.jsx("strong",{children:"13 11 14"})," (Lifeline)"]})]})})]}),i&&d&&e.jsx("button",{onClick:()=>{T("im_safe"),d()},className:"mt-2 w-full rounded-lg border border-border bg-card py-2.5 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground",children:"I'm safe right now"}),!i&&e.jsx("p",{className:"text-xs text-muted-foreground italic pt-1",children:"If you'd like, here are some audios for gentle support below — no pressure."})]})})})},Ae=()=>{const{user:t}=W(),{data:d,isLoading:h}=K({queryKey:["for-you",t==null?void 0:t.id],enabled:!!t,staleTime:5*60*1e3,queryFn:async()=>{var I;const[u,x,v]=await Promise.all([j.from("favorites").select("audio_id").eq("user_id",t.id),j.from("play_events").select("audio_id").eq("user_id",t.id).order("created_at",{ascending:!1}).limit(50),j.from("completions").select("audio_id").eq("user_id",t.id)]),p=(u.data??[]).map(b=>b.audio_id),_=(x.data??[]).map(b=>b.audio_id),C=(v.data??[]).map(b=>b.audio_id),n=[...new Set([...p,...p,..._])];if(n.length===0)return null;const{data:f}=await j.from("audio_categories").select("audio_id, category_id").in("audio_id",n),N="551ddd32-9f5f-48eb-a8d6-e2ca445a30f7",r=["welcome to steadier - start here!","Meditation Made Easy"],w="The Calm Child Collection";let g=[],m="Based on your recent listening";if(f&&f.length>0){const b={};for(const o of f){const S=p.includes(o.audio_id)?3:1;b[o.category_id]=(b[o.category_id]??0)+S}const L=Object.entries(b).filter(([o])=>o!==N).sort((o,S)=>S[1]-o[1]).slice(0,3).map(([o])=>o),{data:k}=await j.from("categories").select("id, name").in("id",L),R=((I=k==null?void 0:k[0])==null?void 0:I.name)??"",{data:P}=await j.from("audio_categories").select("audio_id").in("category_id",L),c=[...new Set((P??[]).map(o=>o.audio_id))].filter(o=>!C.includes(o));if(c.length>0){const{data:o}=await j.from("audio_catalog").select("*").eq("status","published").in("audio_id",c.slice(0,12));g=(o??[]).filter(S=>{const A=(S.access_type||"subscription").split(",").map(M=>M.trim());return A.includes("free")||A.includes("subscription")}).slice(0,6)}R&&(m=`Because you've been exploring ${R.toLowerCase()}`)}if(g.length<3){const{data:b}=await j.from("audio_catalog").select("*").eq("status","published").limit(20);g=(b??[]).filter(k=>{const R=(k.access_type||"subscription").split(",").map(P=>P.trim());return k.current_category!==w&&!r.includes(k.title)&&!C.includes(k.audio_id)&&(R.includes("free")||R.includes("subscription"))}).sort(()=>Math.random()-.5).slice(0,6),m="Picked for you to explore"}return g.length===0?null:{recommendations:g,title:"For You",subtitle:m,isPersonalized:!0}}}),{data:y,isLoading:i}=K({queryKey:["community-favorites"],enabled:!t||!!t&&!h&&!d,staleTime:10*60*1e3,queryFn:async()=>{const u=["welcome to steadier - start here!","Meditation Made Easy"],x="The Calm Child Collection",{data:v}=await j.from("favorites").select("audio_id"),p={};for(const n of v??[])p[n.audio_id]=(p[n.audio_id]??0)+1;const _=Object.entries(p).sort((n,f)=>f[1]-n[1]).slice(0,6).map(([n])=>n);let C=[];if(_.length>0){const{data:n}=await j.from("audio_catalog").select("*").eq("status","published").in("audio_id",_);C=(n??[]).filter(f=>{const N=(f.access_type||"subscription").split(",").map(r=>r.trim());
24return f.current_category!==x&&!u.includes(f.title)&&(N.includes("free")||N.includes("subscription"))})}if(C.length<3){const{data:n}=await j.from("audio_catalog").select("*").eq("status","published").limit(20);C=(n??[]).filter(r=>{const w=(r.access_type||"subscription").split(",").map(g=>g.trim());return r.current_category!==x&&!u.includes(r.title)&&(w.includes("free")||w.includes("subscription"))}).sort(()=>Math.random()-.5).slice(0,6)}return{recommendations:C,title:"Community Favorites",subtitle:"Popular with other listeners",isPersonalized:!1}}}),a=d??y;return{recommendations:(a==null?void 0:a.recommendations)??[],title:(a==null?void 0:a.title)??"Community Favorites",subtitle:(a==null?void 0:a.subtitle)??"Popular with other listeners",isPersonalized:(a==null?void 0:a.isPersonalized)??!1,isLoading:h||i}},Ke=()=>{const t=be(),{profile:d,isAdmin:h,loading:y}=W(),i=!y&&!h&&!ce(d),[a,u]=l.useState(""),[x,v]=l.useState(!1),[p,_]=l.useState([]),[C,n]=l.useState(null),[f,N]=l.useState(!1),[r,w]=l.useState(null),[g,m]=l.useState(!1),I=async()=>{const s=a.trim();if(!(!s||x)){v(!0),_([]),n(null),w(null),m(!1);try{const{data:c,error:o}=await j.functions.invoke("audio-recommend",{body:{message:s}});if(o)throw o;if(c!=null&&c.error){G.error(c.error);return}c.safety&&c.safety.risk_level!=="NONE"&&w({risk_level:c.safety.risk_level,flags:c.safety.flags}),_(c.recommendations||[]),n(c.fallback_message||null),N(!0)}catch(c){console.error(c),G.error("Something went wrong. Please try again.")}finally{v(!1)}}},b=()=>{u(""),_([]),n(null),N(!1),w(null),m(!1)},L=!r||r.risk_level!=="HIGH"||g,{recommendations:k,title:R,subtitle:P}=Ae();return e.jsxs(ue,{children:[e.jsxs("div",{className:"px-5 pt-0 pb-12",children:[e.jsxs("button",{onClick:()=>{f?b():window.history.back()},className:"mb-6 inline-flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(me,{size:16}),"Back"]}),e.jsx(Z,{mode:"wait",children:f?e.jsxs(z.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4},children:[r&&!g&&e.jsx("div",{className:"mb-6",children:e.jsx(Pe,{riskLevel:r.risk_level,onDismiss:()=>m(!0)})}),L&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx($,{size:18,className:"text-primary"}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-primary",children:r?"Gentle support":"Recommended for you"})]}),e.jsx("h1",{className:"mb-2 font-display text-2xl font-bold text-foreground",children:r?"If you'd like, here are some audios":"Here's what might help"}),e.jsx("p",{className:"mb-6 text-sm text-muted-foreground",children:r?"No pressure — these are here for gentle support":"Based on what you shared"}),C&&p.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-card p-6",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:C})}):e.jsx("div",{className:"space-y-4",children:p.map((s,c)=>{var o,S,A,M,B;return e.jsx(z.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:c*.1,duration:.3},children:e.jsxs(ee,{to:`/audio/${s.slug||s.audio_id}`,className:"block rounded-xl border border-border bg-card p-4 transition-all hover:shadow-card",children:[e.jsx("div",{className:"mb-2 flex items-start justify-between gap-3",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-display text-base font-semibold text-foreground",children:((o=s.audio)==null?void 0:o.title)||s.audio_id}),e.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[((S=s.audio)==null?void 0:S.duration_display)||""," ",(A=s.audio)!=null&&A.current_category?`· ${(M=s.audio)==null?void 0:M.current_category}`:""]})]})}),e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:(B=s.audio)==null?void 0:B.description}),e.jsx("div",{className:"rounded-lg bg-primary/5 px-3 py-2",children:e.jsxs("p",{className:"text-xs italic text-primary",children:["💛 ",s.reason]})})]})},s.audio_id)})})]}),i&&L&&!r&&p.length>0&&e.jsx("div",{className:"mt-6",children:e.jsx(U,{})}),e.jsx("button",{onClick:b,className:"mt-6 flex w-full items-center justify-center gap-2 rounded-xl bg-secondary py-3 text-sm font-medium text-secondary-foreground",children:"Try again"})]},"results"):e.jsxs(z.div,{initial:{opacity:0,y:20}
24,animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx($,{size:18,className:"text-primary"}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-primary",children:"find your steady"})]}),e.jsx("h1",{className:"mb-3 font-display text-2xl font-bold text-foreground",children:"What are you in the mood for?"}),e.jsx("p",{className:"mb-8 text-sm text-muted-foreground",children:"Tell us what you're feeling, struggling with, or want to focus on — we'll find the right session for you."}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{value:a,onChange:s=>u(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),I())},placeholder:"e.g. I only have 5 minutes and my mind won't stop racing...",className:"min-h-[120px] w-full resize-none rounded-xl border-2 border-border bg-card p-4 pr-12 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-none",disabled:x}),e.jsx("button",{onClick:I,disabled:!a.trim()||x,className:"blob-2 absolute bottom-3 right-3 flex h-10 w-10 items-center justify-center border-2 border-cocoa bg-butter text-merlot transition-opacity disabled:opacity-40",children:x?e.jsx(je,{size:18,className:"animate-spin"}):e.jsx(te,{size:20,strokeWidth:2.2})})]}),x&&e.jsx(z.p,{initial:{opacity:0}
24,animate:{opacity:1},className:"mt-4 text-center text-sm text-muted-foreground",children:"Finding sessions that match what you shared..."}),i&&e.jsx("div",{className:"mt-5",children:e.jsx(U,{})}),e.jsxs("div",{className:"mt-6",children:[e.jsx("p",{className:"mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Try saying..."}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["I can't sleep and my mind won't stop racing","I snapped at my kids and feel terrible","I want to feel more patient today","I'm grieving and feeling heavy"].map(s=>e.jsx("button",{onClick:()=>u(s),className:"rounded-full border border-border bg-card px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-primary/30 hover:text-foreground",children:s},s))})]})]},"input")})]}),k.length>0&&!f&&e.jsxs("section",{className:"pt-0 pb-4",children:[e.jsx("div",{className:"px-5 pb-3",children:e.jsx(ge,{delay:0})}),e.jsx(pe,{title:R,subtitle:P}),e.jsx("div",{className:"flex gap-3 overflow-x-auto px-5 pb-2 scrollbar-hide",children:k.map((s,c)=>e.jsx(fe,{audio:s,variant:"featured",index:c,purchasedProgramIds:t},s.id))})]})]})};export{Ke 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.