1import{i as r,v as t,l as D,S as g,e as O,O as oe,C as ie,K as $e,t as a,G as ce,b as v,o as he,d as me,j as se,F as _e,g as Te}from"./solid-vendor-CQ4bklhx.js";import{u as V,x as X,af as Re,B as K,A as be,at as De,i as pe,p as ue,S as re,D as Pe,ai as ze}from"./index-BMJwaYYL.js";import{B as Se}from"./Barbell-BG03pchE.js";import{M as We}from"./Medal-CQTRXGfw.js";import{T as fe}from"./Target-ChoK037U.js";import{D as ye}from"./Dialog-CHpC-y1y.js";import{C as B}from"./Card-xg3jCnGU.js";import{C as Ae}from"./ComposerPill-nLRa3YJe.js";import{P as Fe}from"./PageContainer-EK4IkFM8.js";import{P as Ge}from"./PageHeader-Y1siV6n8.js";import{u as Me}from"./formatters-_QZKJmKi.js";import{d as Ee}from"./formatters-Ch-wDJY-.js";import{S as ae}from"./StatCard-BGSq-UeM.js";import{P as Ce}from"./Play-zgNRCak1.js";import{A as we}from"./ArrowCounterClockwise-Cv_m6uGd.js";import{M as ve}from"./Microphone-PA9oRevB.js";import{P as Le}from"./Pause-BJjYohNx.js";import{S as Ie}from"./Square-B2ND3oQV.js";import{u as Ke}from"./useSpeechRecognition-AJAi9Leh.js";import{A as Be}from"./ArrowRight-Dwjy_iXJ.js";import{L as je}from"./Lightbulb-Ns9170YU.js";import{S as He}from"./Sparkle-D1Wcl2JM.js";import{T as Oe}from"./ThumbsUp-BFJ7gocF.js";import"./ui-vendor-CMjh0a6q.js";import"./focusReturn-DVsHGUsg.js";import"./AnimatedNumber-BAcu4tjP.js";var qe=a('<div class="flex items-start justify-between mb-4"><div class="flex items-center gap-2"><h3 class="font-medium text-[var(--color-text)]">'),Ne=a('<div class=space-y-3><div class="flex justify-between text-sm"><span class=text-[var(--color-text-muted)]></span><span class="font-medium text-[var(--color-text)]"> / <!> </span></div><div class="h-3 bg-[var(--color-neutral-100)] rounded-full overflow-hidden"><div></div></div><div class="text-xs text-[var(--color-text-subtle)] text-center">'),Qe=a('<div class="text-center py-4"><p class="text-[var(--color-text-muted)] mb-3"></p><button type=button class="text-sm text-[var(--color-primary-600)] hover:text-[var(--color-primary-700)] font-medium">');const Ue=e=>{const{t:n}=V(),{formatDate:w}=Me(),d=()=>e.goal?Math.min(e.goal.completed_workouts/e.goal.target_workouts*100,100):0,p=()=>e.goal?`${w(e.goal.period_start)} - ${w(e.goal.period_end)}`:"";return r(B,{padded:"md",get children(){return[(()=>{var o=qe(),s=o.firstChild,l=s.firstChild;return t(s,r(fe,{class:"w-5 h-5 text-[var(--color-primary-600)]"}),l),t(l,(()=>{var i=D(()=>e.goal?.goal_type==="weekly");return()=>i()?n("goalProgress.weeklyGoal"):n("goalProgress.monthlyGoal")})()),t(o,r(g,{get when(){return e.goal?.is_achieved},get children(){return r(X,{variant:"success",size:"sm",get children(){return n("goalProgress.achieved")}})}}),null),o})(),r(g,{get when(){return e.goal},get fallback(){return(()=>{var o=Qe(),s=o.firstChild,l=s.nextSibling;return t(s,()=>n("goalProgress.noGoal")),$e(l,"click",e.onSetGoal,!0),t(l,()=>n("goalProgress.setWeeklyGoal")),o})()},get children(){var o=Ne(),s=o.firstChild,l=s.firstChild,i=l.nextSibling,h=i.firstChild,P=h.nextSibling;P.nextSibling;var C=s.nextSibling,R=C.firstChild,_=C.nextSibling;return t(l,()=>n("goalProgress.progress")),t(i,()=>e.goal.completed_workouts,h),t(i,()=>e.goal.target_workouts,P),t(i,()=>n("goalProgress.workouts"),null),t(_,p),O(x=>{var y=`h-full transition-all ${e.goal.is_achieved?"bg-[var(--color-success-500)]":"bg-[var(--color-primary-500)]"}`,E=`${d()}%`;return y!==x.e&&oe(R,x.e=y),E!==x.t&&ie(R,"width",x.t=E),x},{e:void 0,t:void 0}),o}})]}})};ce(["click"]);var Xe=a('<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3.5">');const Ve=e=>{const{t:n}=V(),w=()=>e.streak?.last_workout_date??null,d=()=>{const o=w();return o?Ee(o):0},p=()=>{if(!w())return n("streakDisplay.subNeverWorkedOut");const o=d();return n(o===0?"streakDisplay.subWorkedOutToday":o===1?"streakDisplay.subDaySinceWorkout":"streakDisplay.subDaysSinceWorkout")};return(()=>{var o=Xe();return t(o,r(ae,{variant:"editorial",get label(){return n("streakDisplay.currentStreak")},get value(){return e.streak?.current_streak??0},get sub(){return n("streakDisplay.subCurrentStreak")}}),null),t(o,r(ae,{variant:"editorial",get label(){return n("streakDisplay.longestStreak")},get value(){return e.streak?.longest_streak??0},get sub(){return n("streakDisplay.subLongestStreak")}}),null),t(o,r(ae,{variant:"editorial",get label(){return n("streakDisplay.totalWorkouts")},get value(){return e.streak?.total_workouts??0},get sub(){return n("streakDisplay.subTotalWorkouts")}}),null),t(o,r(ae,{variant:"editorial",get label(){return n("streakDisplay.lastWorkout")},get value(){return d()},get sub(){return p()}}),null),o})()};var Je=a('<div class="absolute inset-0 bg-gradient-to-br from-[var(--color-primary-50)] to-transparent opacity-50">'),Ye=a('<div class="space-y-3 pt-2"><p class="text-sm text-[var(--color-text-muted)]">'),Ze=a('<div class="text-center py-4 bg-[var(--color-success-50)] rounded-[var(--radius-lg)]"><p class="text-[var(--color-success-700)] font-medium"></p><p class="text-sm text-[var(--color-success-600)]">'),et=a('<div class=space-y-3><div><h3 class="text-xl font-semibold text-[var(--color-text)]"></h3></div><p class=text-[var(--color-text-muted)]></p><div class="flex items-center gap-4 text-sm text-[var(--color-text-subtle)]"><div class="flex items-center gap-1"><span>'),tt=a('<div class="relative space-y-4"><div class="flex items-start justify-between"><div><h2 class="text-lg font-semibold text-[var(--color-text)] flex items-center gap-2">'),rt=a('<div class="text-center py-8 text-[var(--color-text-muted)]">');const lt=e=>{switch(e){case"easy":return"success";case"medium":return"warning";case"hard":return"error";default:return"neutral"}},nt=e=>{switch(e){case"easy":return"todaysChallenge.difficulty.easy";case"medium":return"todaysChallenge.difficulty.medium";case"hard":return"todaysChallenge.difficulty.hard";default:return null}},at=e=>{switch(e){case"question":return"todaysChallenge.typeQuestion";case"topic_practice":return"todaysChallenge.typeTopicPractice";case"quick_drill":return"todaysChallenge.typeQuickDrill";default:return null}},st=e=>{const{t:n}=V();return r(B,{padded:"md",class:"relative overflow-hidden",get children(){return[Je(),(()=>{var w=tt(),d=w.firstChild,p=d.firstChild,o=p.firstChild;return t(o,r(Se,{class:"w-5 h-5 text-[var(--color-primary-600)]"}),null),t(o,()=>n("todaysChallenge.title"),null),t(p,r(g,{get when(){return e.todayDone},get children(){return r(X,{variant:"success",size:"sm",class:"mt-1",get children(){return n("todaysChallenge.completed")}})}}),null),t(d,r(g,{get when(){return e.challenge},get children(){return r(X,{get variant(){return lt(e.challenge.difficulty)},size:"sm",get children(){return(()=>{const s=nt(e.challenge.difficulty);return s?n(s):e.challenge.difficulty})()}})}}),null),t(w,r(g,{get when(){return e.challenge},get fallback(){return(()=>{var s=rt();return t(s,()=>n("todaysChallenge.noChallenge")),s})()},get children(){var s=et(),l=s.firstChild,i=l.firstChild,h=l.nextSibling,P=h.nextSibling,C=P.firstChild,R=C.firstChild;return t(l,r(X,{variant:"info",size:"sm",class:"mb-2",get children(){return(()=>{const _=at(e.challenge.challenge_type);return _?n(_):e.challenge.challenge_type})()}}),i),t(i,()=>e.challenge.title),t(h,()=>e.challenge.description),t(C,r(Re,{class:"w-4 h-4"}),R),t(R,()=>n("todaysChallenge.estimatedMinutes",{minutes:String(e.challenge.estimated_minutes)})),t(P,r(g,{get when(){return e.challenge.question_type},get children(){return r(X,{variant:"neutral",size:"sm",get children(){return e.challenge.question_type}})}}),null),t(s,r(g,{get when(){return D(()=>!e.todayDone)()&&!e.isActive},get children(){var _=Ye(),x=_.firstChild;return t(x,()=>n("todaysChallenge.practiceHint")),t(_,r(K,{get onClick(){return e.onStart},class:"w-full sm:w-auto",get children(){return[r(Ce,{class:"w-4 h-4 mr-2"}),D(()=>n("todaysChallenge.startPractice"))]}}),null),_}}),null),t(s,r(g,{get when(){return e.todayDone},get children(){var _=Ze(),x=_.firstChild,y=x.nextSibling;return t(x,()=>n("todaysChallenge.doneTitle")),t(y,()=>n("todaysChallenge.doneSubtitle")),_}}),null),s}}),null),w})()]}})};var ot=a('<div class="absolute inset-0 rounded-full bg-[var(--color-error-600)] opacity-30 transition-transform duration-500">'),it=a('<p class="text-[var(--color-error-600)] font-medium">'),ct=a('<p class="text-[var(--color-text-muted)] text-xs mt-1">'),ut=a('<p class="text-[var(--color-text)] whitespace-pre-wrap">'),dt=a('<div class=mt-4><label class="block text-sm font-medium text-[var(--color-text)] mb-2"></label><div>'),gt=a('<div class=space-y-4><div class="flex flex-col items-center gap-4"><div class=relative><button type=button></button></div><div class=text-center>'),ht=a('<p class="text-[var(--color-info-600)] text-sm animate-pulse">'),mt=a('<p class="text-[var(--color-text-muted)] text-sm">'),vt=a('<p class="text-[var(--color-text-subtle)] italic">');const pt=e=>{const{t:n}=V(),[w,d]=v(null),[p,o]=v(!1),s=e.autoStopOnSilence?{onSilenceDetected:i,silenceDuration:e.silenceDuration??2e3,minTranscriptLength:10}:{silenceDuration:e.silenceDuration??2e3,minTranscriptLength:10},l=Ke(s);function i(){l.transcript().trim().length>0&&C()}const h=async()=>{const y=await l.requestPermission();return d(y),y}
1,P=async()=>{if(w()===null){if(!await h())return}else if(!w()&&!await h())return;l.reset(),o(!0),await l.start(),e.onRecordingStart?.()},C=async()=>{await l.stop(),e.onRecordingStop?.(),setTimeout(()=>{const y=l.transcript().trim();y&&e.onTranscriptReady(y)},100)};he(()=>{l.isListening()&&l.stop()});const[R,_]=v(1);let x;return me(()=>{l.isListening()?x=window.setInterval(()=>{_(y=>y===1?1.15:1)},500):(x&&(clearInterval(x),x=void 0),_(1))}),he(()=>{x&&clearInterval(x)}),(()=>{var y=gt(),E=y.firstChild,I=E.firstChild,M=I.firstChild,U=I.nextSibling;return t(y,r(g,{get when(){return l.error()},get children(){return r(be,{variant:"error",get children(){return l.error()}})}}),E),t(I,r(g,{get when(){return l.isListening()},get children(){var u=ot();return O(z=>ie(u,"transform",`scale(${R()*1.3})`)),u}}),M),$e(M,"click",l.isListening()?C:P,!0),t(M,r(g,{get when(){return l.isListening()},get fallback(){return r(ve,{class:"w-8 h-8"})},get children(){return r(Ie,{class:"w-8 h-8"})}})),t(U,r(g,{get when(){return l.isListening()},get fallback(){return r(g,{get when(){return l.isTranscribing()},get fallback(){return(()=>{var u=mt();return t(u,()=>n("workout.voiceRecorder.clickToStart")),u})()},get children(){var u=ht();return t(u,()=>n("workout.voiceRecorder.processing")),u}})},get children(){return[(()=>{var u=it();return t(u,()=>n("workout.voiceRecorder.recording")),u})(),r(g,{get when(){return e.autoStopOnSilence},get children(){var u=ct();return t(u,()=>n("workout.voiceRecorder.autoStop")),u}})]}})),t(y,r(g,{get when(){return D(()=>!!p())()&&(l.isListening()||l.transcript())},get children(){var u=dt(),z=u.firstChild,W=z.nextSibling;return t(z,()=>n("workout.voiceRecorder.yourResponse")),t(W,r(g,{get when(){return l.transcript()},get fallback(){return(()=>{var A=vt();return t(A,(()=>{var b=D(()=>!!l.isListening());return()=>b()?n("workout.voiceRecorder.listening"):n("workout.voiceRecorder.noTranscript")})()),A})()},get children(){var A=ut();return t(A,()=>l.transcript()),A}})),O(()=>oe(W,`min-h-24 p-4 rounded-[var(--radius-lg)] border ${l.isListening()?"border-[var(--color-error-300)] bg-[var(--color-error-50)]":"border-[var(--color-border)] bg-[var(--color-neutral-50)]"}`)),u}}),null),O(u=>{var z=e.disabled||l.isTranscribing(),W=l.isListening()?n("workout.voiceRecorder.stopRecording"):n("workout.voiceRecorder.startRecording"),A=`relative w-20 h-20 rounded-full flex items-center justify-center transition-all duration-200 ${l.isListening()?"bg-[var(--color-error-600)] hover:bg-[var(--color-error-700)] text-[color:var(--color-on-error)]":"bg-[var(--color-primary-500)] hover:bg-[var(--color-primary-600)] text-[var(--color-on-primary)]"} ${e.disabled||l.isTranscribing()?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,b=`scale(${R()})`;return z!==u.e&&(M.disabled=u.e=z),W!==u.t&&se(M,"aria-label",u.t=W),A!==u.a&&oe(M,u.a=A),b!==u.o&&ie(M,"transform",u.o=b),u},{e:void 0,t:void 0,a:void 0,o:void 0}),y})()};ce(["click"]);var ft=a('<div class="flex flex-col items-center gap-4"><div class="flex items-center gap-3"><div></div></div><div><h2 class="text-xl font-semibold text-[var(--color-text)]"></h2><p class="text-[var(--color-text-muted)] text-sm mt-1">'),yt=a('<h3 class="font-medium text-[var(--color-text)] mb-3">'),wt=a('<div class="p-4 bg-[var(--color-neutral-50)] rounded-[var(--radius-lg)]"><p class="text-[var(--color-text-muted)] text-sm whitespace-pre-wrap">'),ge=a('<div class="flex items-center gap-2 mb-3"><h3 class="font-medium text-[var(--color-text)]">'),xt=a("<ul class=space-y-2>"),xe=a('<p class="text-[var(--color-text-muted)] text-sm">'),kt=a('<div class=space-y-6><div class="grid gap-4">'),$t=a('<li class="flex items-start gap-2 text-[var(--color-text-muted)] text-sm"><span class="text-[var(--color-success-500)] mt-1">â¢');const ke={A:{labelKey:"workoutFeedback.scoreA.label",variant:"success",descriptionKey:"workoutFeedback.scoreA.description"},B:{labelKey:"workoutFeedback.scoreB.label",variant:"success",descriptionKey:"workoutFeedback.scoreB.description"},C:{labelKey:"workoutFeedback.scoreC.label",variant:"info",descriptionKey:"workoutFeedback.scoreC.description"},D:{labelKey:"workoutFeedback.scoreD.label",variant:"warning",descriptionKey:"workoutFeedback.scoreD.description"},F:{labelKey:"workoutFeedback.scoreF.label",variant:"error",descriptionKey:"workoutFeedback.scoreF.description"}};function _t(e,n,w){const d={strengths:[],improvement:"",tip:""},p=e.match(/\*\*Strengths:\*\*\s*([\s\S]*?)(?=\*\*Improvement:|$)/i);if(p?.[1]){const i=p[1].trim().split(/[\n-â¢]/).map(h=>h.trim()).filter(h=>h.length>0);d.strengths=i.slice(0,3)}const o=e.match(/\*\*Improvement:\*\*\s*([\s\S]*?)(?=\*\*Tip:|$)/i);o?.[1]&&(d.improvement=o[1].trim());const s=e.match(/\*\*Tip:\*\*\s*([\s\S]*?)$/i);return s?.[1]&&(d.tip=s[1].trim()),!d.strengths.length&&!d.improvement&&!d.tip&&(d.strengths=[n],d.improvement=e.slice(0,200),d.tip=w),d}const bt=e=>{const{t:n}=V(),w=()=>e.analysis.score?.toUpperCase()||"C",d=()=>
1ke[w()]||ke.C,p=()=>_t(e.analysis.feedback||"",n("workoutFeedback.fallbackStrength"),n("workoutFeedback.fallbackTip"));return(()=>{var o=kt(),s=o.firstChild;return t(o,r(B,{padded:"md",class:"text-center py-8",get children(){var l=ft(),i=l.firstChild,h=i.firstChild,P=i.nextSibling,C=P.firstChild,R=C.nextSibling;return t(h,w),t(C,()=>n(d().labelKey)),t(R,()=>n(d().descriptionKey)),t(l,r(X,{variant:"secondary",size:"md",get children(){return[r(He,{class:"w-4 h-4 mr-1"}),"+",D(()=>e.analysis.xp_earned)," XP"]}}),null),O(()=>oe(h,`w-16 h-16 rounded-full flex items-center justify-center text-3xl font-bold ${d().variant==="success"?"bg-[var(--color-success-100)] text-[var(--color-success-700)]":d().variant==="info"?"bg-[var(--color-info-100)] text-[var(--color-info-700)]":d().variant==="warning"?"bg-[var(--color-warning-100)] text-[var(--color-warning-700)]":"bg-[var(--color-error-100)] text-[var(--color-error-700)]"}`)),l}}),s),t(o,r(B,{padded:"md",get children(){return[(()=>{var l=yt();return t(l,()=>n("workoutFeedback.yourResponse")),l})(),(()=>{var l=wt(),i=l.firstChild;return t(i,()=>e.transcript),l})()]}}),s),t(s,r(g,{get when(){return p().strengths.length>0},get children(){return r(B,{padded:"md",get children(){return[(()=>{var l=ge(),i=l.firstChild;return t(l,r(Oe,{class:"w-5 h-5 text-[var(--color-success-600)]"}),i),t(i,()=>n("workoutFeedback.strengths")),l})(),(()=>{var l=xt();return t(l,r(_e,{get each(){return p().strengths},children:i=>(()=>{var h=$t();return h.firstChild,t(h,i,null),h}
1)()})),l})()]}})}}),null),t(s,r(g,{get when(){return p().improvement},get children(){return r(B,{padded:"md",get children(){return[(()=>{var l=ge(),i=l.firstChild;return t(l,r(fe,{class:"w-5 h-5 text-[var(--color-warning-600)]"}),i),t(i,()=>n("workoutFeedback.areaToImprove")),l})(),(()=>{var l=xe();return t(l,()=>p().improvement),l})()]}})}}),null),t(s,r(g,{get when(){return p().tip},get children(){return r(B,{padded:"md",get children(){return[(()=>{var l=ge(),i=l.firstChild;return t(l,r(je,{class:"w-5 h-5 text-[var(--color-info-600)]"}),i),t(i,()=>n("workoutFeedback.proTip")),l})(),(()=>{var l=xe();return t(l,()=>p().tip),l})()]}})}}),null),t(o,r(K,{get onClick(){return e.onContinue},class:"w-full",size:"lg",get children(){return[D(()=>n("workout.continue")),r(Be,{class:"w-5 h-5 ml-2"})]}}),null),o})()};var St=a('<h2 class="text-xl font-semibold text-[var(--color-text)] mt-4">'),Ct=a('<p class="text-[var(--color-text-muted)] mt-2">'),Tt=a('<div class="flex justify-center gap-4">'),Rt=a('<div class="bg-[var(--color-info-50)] border border-[var(--color-info-200)] rounded-[var(--radius-lg)] p-4"><div class="flex items-start gap-3"><div><h3 class="font-medium text-[var(--color-info-800)]"></h3><p class="text-sm text-[var(--color-info-700)] mt-1">'),Dt=a('<div class=text-center><h2 class="text-xl font-semibold text-[var(--color-text)] mb-2"></h2><p class="text-[var(--color-text-muted)] text-lg">'),Pt=a('<div class="text-center py-4"><div class="text-5xl font-mono font-bold text-[var(--color-text)] mb-2"></div><div class="text-sm text-[var(--color-text-muted)]"></div><div class="mt-4 h-2 bg-[var(--color-neutral-100)] rounded-full overflow-hidden max-w-md mx-auto"><div class="h-full bg-[var(--color-primary-500)] transition-all duration-1000">'),zt=a('<div class="flex flex-col items-center gap-4"><p class="text-[var(--color-text-muted)] text-sm">'),Wt=a('<div class="flex justify-center gap-4 border-t border-[var(--color-border)] pt-4">'),At=a('<div class="text-center border-t border-[var(--color-border)] pt-4"><button type=button class="text-[var(--color-text-muted)] text-sm hover:text-[var(--color-text)] transition-colors">'),Ft=a("<div class=space-y-6>");const Gt=e=>{const{t:n}=V(),[w,d]=v(0),[p,o]=v(!1),[s,l]=v("ready"),[i,h]=v(""),[P,C]=v(!1);let R,_=0;const x=()=>{const b=e.startedAt.getTime();R=window.setInterval(()=>{if(!p()){const c=Date.now(),k=Math.max(0,Math.floor((c-b-_)/1e3));d(k)}},1e3)};me(()=>{x()}),me(()=>{e.analysisResult&&s()==="analyzing"&&l("results")}),he(()=>{R&&clearInterval(R)});const y=b=>{const c=Math.floor(b/60),k=b%60;return`${c.toString().padStart(2,"0")}:${k.toString().padStart(2,"0")}`};let E=0;const I=()=>{p()?_+=Date.now()-E:E=Date.now(),o(!p())},M=()=>{l("recording")},U=async b=>{h(b),l("analyzing"),await e.onAnalyze(b)},u=async()=>{C(!0);try{await e.onComplete(i()||void 0)}finally{C(!1)}},z=()=>{h(""),l("ready")},W=e.challenge.estimated_minutes*60,A=()=>Math.min(w()/W*100,100);return(()=>{var b=Ft();return t(b,r(g,{get when(){return D(()=>s()==="results")()&&e.analysisResult},get children(){return r(bt,{get transcript(){return i()},get analysis(){return e.analysisResult},onContinue:u})}}),null),t(b,r(g,{get when(){return s()==="analyzing"},get children(){return[r(B,{padded:"md",class:"text-center py-12",get children(){return[r(De,{class:"w-12 h-12 text-[var(--color-primary-500)] mx-auto animate-spin"}),(()=>{var c=St();return t(c,()=>n("workoutSession.analyzing")),c})(),(()=>{var c=Ct();return t(c,()=>n("workoutSession.analyzingSubtitle")),c})()]}}),r(g,{get when(){return e.analysisError},get children(){return[r(be,{variant:"error",get children(){return e.analysisError}}),(()=>{var c=Tt();return t(c,r(K,{variant:"ghost",onClick:z,get children(){return[r(we,{class:"w-4 h-4 mr-2"}),D(()=>n("workoutSession.tryAgain"))]}}),null),t(c,r(K,{onClick:u,get children(){return n("workoutSession.skipAnalysis")}}),null),c})()]}})]}}),null),t(b,r(g,{get when(){return s()==="ready"||s()==="recording"},get children(){return r(B,{padded:"md",class:"space-y-6",get children(){return[(()=>{var c=Rt(),k=c.firstChild,G=k.firstChild,q=G.firstChild,j=q.nextSibling;return t(k,r(ve,{class:"w-5 h-5 text-[var(--color-info-600)] flex-shrink-0 mt-0.5"}),G),t(q,()=>n("workoutSession.recordTitle")),t(j,()=>n("workoutSession.recordHint")),c})(),(()=>{var c=Dt(),k=c.firstChild,G=k.nextSibling;return t(k,()=>e.challenge.title),t(G,()=>e.challenge.description),c})(),(()=>{var c=Pt(),k=c.firstChild,G=k.nextSibling,q=G.nextSibling,j=q.firstChild;return t(k,()=>y(w())),t(G,()=>n("workoutSession.target",{minutes:String(e.challenge.estimated_minutes)})),O(le=>ie(j,"width",`${A()}%`)),c})(),r(g,{get when(){return s()==="recording"},get children(){return r(pt,{onTranscriptReady:U,autoStopOnSilence:!0,silenceDuration:2500})}}),r(g,{get when(){return s()==="ready"},get children(){var c=zt(),k=c.firstChild;return t(c,r(K,{onClick:M,size:"lg",class:"px-8",get children(){return[r(ve,{class:"w-5 h-5 mr-2"}),D(()=>n("workoutSession.recordAnswer"))]}}),k),t(k,()=>n("workoutSession.clickToRecord")),c}}),(()=>{var c=Wt();return t(c,r(K,{variant:"ghost",onClick:I,get disabled(){return s()==="recording"},get children(){return[r(g,{get when(){return p()},get fallback(){return r(Le,{class:"w-4 h-4 mr-2"})},get children(){return r(Ce,{class:"w-4 h-4 mr-2"})}}),D(()=>D(()=>!!p())()?n("workoutSession.resume"):n("workoutSession.pause"))]}}),null),t(c,r(K,{variant:"ghost",get onClick(){return e.onCancel},get children(){return[r(we,{class:"w-4 h-4 mr-2"}),D(()=>n("common.cancel"))]}}),null),c})(),(()=>{var c=At(),k=c.firstChild;return k.$$click=u,t(k,()=>n("workoutSession.skipRecording")),O(()=>k.disabled=P()),c})()]}})}}),null),b})()};ce(["click"]);async function Mt(){return pe("api/candidate/workout")}async function Et(e){return ue("api/candidate/workout/start",e)}async function Lt(e){return ue("api/candidate/workout/complete",e)}async function It(){return pe("api/candidate/workout/streak")}async function Kt(e=20,n=0){return pe(`api/candidate/workout/history?limit=${e}&offset=${n}`)}async function Bt(e){return ue("api/candidate/workout/goal",e)}async function jt(e){return ue("api/candidate/workout/analyze",e)}function Ht(){const[e,n]=v(null),[w,d]=v(null),[p,o]=v(!1),[s,l]=v(null),[i,h]=v(null),[P,C]=v(null),[R,_]=v(!0),[x,y]=v(null),[E,I]=v([]),[M,U]=v(0),[u,z]=v(null),[W,A]=v([]),[b,c]=v(""),[k,G]=v(!1),[q,j]=v(!1),[le,ne]=v(null),[de,H]=v(null),J=async()=>{try{_(!0),y(null);const m=await Mt();n(m.challenge??null),d(m.streak??null),o(m.today_done),l(m.current_goal??null)}catch(m){y("Failed to load today's workout"),console.error("Error fetching workout:",m)}finally{_(!1)}};return Te(()=>{J()}),{challenge:e,streak:w,todayDone:p,currentGoal:s,workoutId:i,startedAt:P,loading:R,error:x,history:E,historyTotal:M,completionResult:u,newBadges:W,transcript:b,isRecording:k,isAnalyzing:q,analysisResult:le,analysisError:de,fetchTodaysWorkout:J,start:async()=>{const m=e();if(m)try{const T=await Et({challenge_id:m.id});h(T.workout_id),C(new Date)}catch(T){throw console.error("Error starting workout:",T),T}},complete:async m=>{const T=i();if(T)try{const $=await Lt({workout_id:T,response_text:m||null});z($),d($.streak),o(!0),A($.new_badges??[]),$.goal_updated&&l($.goal_updated)}catch($){throw console.error("Error completing workout:",$),$}},fetchStreak:async()=>{try{const m=await It();d(m)}catch(m){console.error("Error fetching streak:",m)}
1},fetchHistory:async(m=20,T=0)=>{try{const $=await Kt(m,T);I($.workouts),U($.total)}catch($){console.error("Error fetching history:",$)}},setGoal:async(m,T)=>{try{const $=await Bt({goal_type:m,target_workouts:T});return l($),$}catch($){throw console.error("Error setting goal:",$),$}},resetWorkout:()=>{h(null),C(null),z(null),A([]),c(""),G(!1),j(!1),ne(null),H(null)},startRecording:()=>{G(!0),c(""),H(null)},stopRecording:()=>{G(!1)},setTranscriptText:m=>{c(m)},analyzeResponse:async m=>{const T=i();if(!T){H("No active workout");return}if(!m.trim()){H("No transcript to analyze");return}try{j(!0),H(null);const $=await jt({workout_id:T,transcript:m});ne($),c(m)}catch($){console.error("Error analyzing workout:",$),H("Failed to analyze your response. Please try again.")}finally{j(!1)}}}}var Ot=a('<div class=space-y-4><div class="grid grid-cols-4 gap-4">'),qt=a("<div class=text-[var(--color-error-600)]>"),Nt=a("<div class=mb-6>"),Qt=a('<div class="grid lg:grid-cols-3 gap-6"><div class=lg:col-span-2></div><div>'),Ut=a('<div class=space-y-4><div class="flex flex-wrap items-center gap-2"><div class=w-fit></div><div class="flex items-center gap-2 rounded-[var(--radius-capsule)] border border-[var(--color-border)] px-3 py-1.5"><input type=number min=1 class="w-12 border-none bg-transparent p-0 text-sm text-[var(--color-text)] placeholder:text-[var(--color-text-subtle)] focus:outline-none"><span class="text-sm text-[var(--color-text-subtle)]"></span></div></div><p class="text-xs text-[var(--color-text-muted)]"></p><div class="flex justify-end gap-3 border-t border-[var(--color-border)] pt-4">'),Xt=a("<p class=text-[var(--color-text-muted)]> "),Vt=a('<div class="border-t border-[var(--color-border)] pt-4"><h3 class="text-sm font-medium text-[var(--color-text-muted)] mb-2"></h3><div class="flex justify-center gap-2 flex-wrap">'),Jt=a('<div class="text-center space-y-4"><div class="w-16 h-16 bg-[var(--color-success-100)] rounded-full flex items-center justify-center mx-auto"></div><div class=space-y-2><p class=text-[var(--color-text-muted)]> <span class="font-bold text-[var(--color-primary-600)]">+<!> XP');const br=()=>{const{t:e}=V(),{challenge:n,streak:w,todayDone:d,currentGoal:p,workoutId:o,startedAt:s,loading:l,error:i,completionResult:h,newBadges:P,isAnalyzing:C,analysisResult:R,analysisError:_,start:x,complete:y,setGoal:E,resetWorkout:I,fetchTodaysWorkout:M,analyzeResponse:U}=Ht(),[u,z]=v(!1),[W,A]=v("weekly"),[b,c]=v(5),[k,G]=v(!1),q=async()=>{await x()},j=async f=>{await y(f),G(!0)},le=async f=>{await U(f)},ne=()=>{I()},de=async()=>{await E(W(),b()),z(!1)},H=()=>{G(!1),I(),M()},J=()=>o()!==null&&s()!==null;return r(Fe,{get children(){return[r(Ge,{get title(){return e("workout.title")}}),r(g,{get when(){return l()},get children(){var f=Ot(),F=f.firstChild;return t(f,r(re,{width:"100%",height:"200px",variant:"rectangular"}),F),t(F,r(re,{width:"100%",height:"80px",variant:"rectangular"}),null),t(F,r(re,{width:"100%",height:"80px",variant:"rectangular"}),null),t(F,r(re,{width:"100%",height:"80px",variant:"rectangular"}),null),t(F,r(re,{width:"100%",height:"80px",variant:"rectangular"}),null),f}}),r(g,{get when(){return i()},get children(){return r(B,{padded:"md",class:"text-center py-8",get children(){var f=qt();return t(f,i),f}})}}),r(g,{get when(){return D(()=>!l())()&&!i()},get children(){return[r(g,{get when(){return J()},get children(){return r(Gt,{get challenge(){return n()},get startedAt(){return s()},onComplete:j,onCancel:ne,onAnalyze:le,get isAnalyzing(){return C()},get analysisResult(){return R()},get analysisError(){return _()}})}}),r(g,{get when(){return!J()},get children(){return[(()=>{var f=Nt();return t(f,r(Ve,{get streak(){return w()}})),f})(),(()=>{var f=Qt(),F=f.firstChild,N=F.nextSibling;return t(F,r(st,{get challenge(){return n()},get todayDone(){return d()},get isActive(){return J()},onStart:q})),t(N,r(Ue,{get goal(){return p()},onSetGoal:()=>z(!0)})),f})()]}})]}}),r(ye,{get open(){return u()},onOpenChange:z,get title(){return e("workout.setGoal")},get description(){return e("workout.chooseFrequency")},size:"sm",get children(){var f=Ut(),F=f.firstChild,N=F.firstChild,Y=N.nextSibling,L=Y.firstChild,ee=L.nextSibling,te=F.nextSibling,Z=te.nextSibling;return t(N,r(Pe,{get trigger(){return r(Ae,{get label(){return e("workout.goalType")},get icon(){return r(ze,{class:"h-3.5 w-3.5 text-[var(--color-text-subtle)]"})},get children(){return D(()=>W()==="weekly")()?e("workout.weekly"):e("workout.monthly")}})},get items(){return[{label:e("workout.weekly"),value:"weekly"},{label:e("workout.monthly"),value:"monthly"}]},onSelect:S=>A(S)})),t(Y,r(fe,{class:"h-3.5 w-3.5 shrink-0 text-[var(--color-text-subtle)]"}),L),L.$$input=S=>c(Number.parseInt(S.currentTarget.value,10)||1),t(ee,(()=>{var S=D(()=>W()==="weekly");return()=>S()?e("workout.perWeek"):e("workout.perMonth")})()),t(te,()=>`${e("workout.maximum")} ${W()==="weekly"?e("workout.maxPerWeek"):e("workout.maxPerMonth")}`),t(Z,r(K,{variant:"ghost",onClick:()=>z(!1),get children(){return e("common.cancel")}}),null),t(Z,r(K,{variant:"super-primary",onClick:de,get children(){return e("workout.setGoal")}}),null),O(S=>{var Q=W()==="weekly"?7:31,m=e("workout.targetWorkouts"),T=e("workout.targetWorkouts");return Q!==S.e&&se(L,"max",S.e=Q),m!==S.t&&se(L,"placeholder",S.t=m),T!==S.a&&se(L,"aria-label",S.a=T),S},{e:void 0,t:void 0,a:void 0}),O(()=>L.value=b()),f}}),r(ye,{get open(){return D(()=>!!k())()&&!!h()},onOpenChange:f=>!f&&H(),get title(){return e("workout.complete")},size:"sm",get children(){var f=Jt(),F=f.firstChild,N=F.nextSibling,Y=N.firstChild,L=Y.firstChild,ee=L.nextSibling,te=ee.firstChild,Z=te.nextSibling;return Z.nextSibling,t(F,r(We,{class:"w-8 h-8 text-[var(--color-success-600)]"})),t(Y,()=>
1e("workout.xpEarned"),L),t(ee,()=>h()?.xp_earned??0,Z),t(N,r(g,{get when(){return D(()=>!!h()?.streak?.current_streak)()&&h().streak.current_streak>1},get children(){var S=Xt(),Q=S.firstChild;return t(S,r(Se,{class:"w-4 h-4 inline text-[var(--color-warning-500)]"}),Q),t(S,()=>e("workout.dayStreak").replace("{{count}}",String(h().streak.current_streak)),null),S}}),null),t(f,r(g,{get when(){return P().length>0},get children(){var S=Vt(),Q=S.firstChild,m=Q.nextSibling;return t(Q,()=>e("workout.newBadges")),t(m,r(_e,{get each(){return P()},children:T=>r(X,{variant:"success",size:"sm",get children(){return T.name}})})),S}}),null),t(f,r(K,{onClick:H,class:"w-full",get children(){return e("workout.continue")}}),null),f}})]}})};ce(["input"]);export{br as default}; 2//# sourceMappingURL=WorkoutPage-Z5iRD3XU.js.map
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.