1import{r as u,j as e,aa as re,as as H,am as ne,p as le,ac as oe,m as R,ap as ie,C as X,aF as de,T as ce,b9 as xe,w as me,x as ue,W as he,L as pe}from"./vendor-2be7022e.js";import{C as ge}from"./ChestOpening-d14db790.js";import{m as fe}from"./ExerciseRenderer-8dc68f23.js";import{s as be}from"./index-c61a06a9.js";import{u as we,g as Ne}from"./dailyGoal-18fe029c.js";import{a as I,g as L,p as je}from"./shared-d9b446ea.js";const ke=()=>{var s;return typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches)};function ye(s,{duration:n=700,startFromZero:a=!1}={}){const l=Number.isFinite(s)?s:0,[i,t]=u.useState(a?0:l),d=u.useRef(a?0:l),h=u.useRef(!0);return u.useEffect(()=>{const f=h.current&&a?0:d.current;if(h.current=!1,f===l||ke()){t(l),d.current=l;return}let m;const g=Date.now();function N(){const r=Math.min(1,(Date.now()-g)/n),c=1-Math.pow(1-r,3);t(Math.round(f+(l-f)*c)),r<1?m=requestAnimationFrame(N):d.current=l}return m=requestAnimationFrame(N),()=>cancelAnimationFrame(m)},[l,n]),i}const B=70,J=["#FF7A1A","#58CC02","#1CB0F6","#FFC800","#E11D48"];function ve(s){return Number.isFinite(s)?Math.max(0,Math.min(1,s)):0}function Ce(s){const n=Math.max(0,Math.round((Number(s)||0)/1e3)),a=Math.floor(n/60),l=n%60;return`${a}:${String(l).padStart(2,"0")}`}const O={mcq:"Multiple choice",multiple_choice:"Multiple choice",translate:"Translate",fill_blank:"Fill in the blank",match:"Match pairs",listen:"Listening",speak:"Speaking",type_answer:"Type the answer",true_false:"True or false",translate_mcq:"Translate",match_pairs:"Match pairs",word_bank:"Build the sentence",sentence_order:"Put words in order"};function Me(s){const n=String(s||"").toLowerCase();if(O[n])return O[n];const a=n.replace(/[_-]+/g," ").trim();return a?a[0].toUpperCase()+a.slice(1):"Exercise"}function _e(){const s=u.useMemo(()=>Array.from({length:24}).map((n,a)=>({left:Math.round(a*37%100),delay:a%7*.18,dur:2.4+a%5*.4,color:J[a%J.length],size:7+a%3*3,round:a%2===0})),[]);return e.jsx("div",{className:"pointer-events-none absolute inset-0 overflow-hidden motion-reduce:hidden","aria-hidden":!0,children:s.map((n,a)=>e.jsx("span",{className:"absolute top-0",style:{left:`${n.left}%`,width:n.size,height:n.size,background:n.color,borderRadius:n.round?"9999px":"2px",animation:`confettiFall ${n.dur}s linear ${n.delay}s infinite`}},a))})}function U({label:s,icon:n,value:a,tone:l,badge:i}){const t={gold:{ring:"ring-gold-400 dark:ring-gold-500/40",band:"bg-gold-400",text:"text-gold-500 dark:text-gold-400"},grass:{ring:"ring-grass-500 dark:ring-grass-500/40",band:"bg-grass-500",text:"text-grass-600 dark:text-grass-400"}},d=t[l]||t.gold;return e.jsxs("div",{className:"relative overflow-hidden rounded-2xl ring-2 "+d.ring,children:[e.jsx("div",{className:"py-1.5 text-center text-xs font-extrabold uppercase tracking-wide text-white "+d.band,children:s}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 bg-white py-3 dark:bg-[#18181b]",children:[e.jsx(n,{className:"h-5 w-5 "+d.text}),e.jsx("span",{className:"font-display text-2xl font-extrabold leading-none tabular-nums "+d.text,children:a})]}),i?e.jsx("span",{className:"absolute right-1.5 top-1 rounded-full bg-white/90 px-1.5 text-[10px] font-extrabold text-gold-600",children:i}):null]})}async function Se({lessonTitle:s,xp:n,accuracy:a}){var i;const l=`ð¦ð² Just completed "${s}" on Haylingua! +${n} XP · ${a}% accuracy. Learning Armenian one lesson at a time ðª haylingua.am`;if(navigator.share&&((i=window.matchMedia)!=null&&i.call(window,"(pointer: coarse)").matches))try{return await navigator.share({text:l}),"shared"}catch(t){if((t==null?void 0:t.name)==="AbortError")return"cancelled"}try{return await navigator.clipboard.writeText(l),"copied"}catch{return"failed"}}function Fe(s){const[n,a]=u.useState({data:null,error:"",loading:!1}),l=u.useCallback(async()=>{const i=I();if(i){a(t=>({...t,error:"",loading:!0}));try{const[t,d,h]=await Promise.all([L(i,"/me/stats","Couldn't load today's progress."),L(i,"/me/wallet","Couldn't load today's progress."),L(i,"/me/quests","").catch(()=>null)]);a({loading:!1,error:"",data:{todayXp:Number(t==null?void 0:t.today_xp)||0,streak:Number(t==null?void 0:t.streak)||0,chests:Number(d==null?void 0:d.chests)||0,claimableQuests:h&&Number(h.claimable)||0}})}catch(t){a(d=>({...d,loading:!1,error:t.message}))}}},[]);return u.useEffect(()=>{s&&l()},[s,l]),[n,l,a]}function S({icon:s,iconClass:n,children:a,action:l}){return e.jsxs("div",{className:"flex min-h-[2.75rem] items-center gap-3 px-3.5 py-2",children:[e.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-xl "+n,
1children:e.jsx(s,{className:"h-4 w-4"})}),e.jsx("div",{className:"min-w-0 flex-1 text-left text-sm",children:a}),l?e.jsx("div",{className:"shrink-0",children:l}):null]})}function Te({save:s,onRetrySave:n,startedPracticedToday:a}){const l=we(),i=Ne(l),t=(s==null?void 0:s.status)==="saved",[d,h,f]=Fe(t),[m,g]=u.useState({busy:!1,error:"",reward:null});async function N(){if(!m.busy){g({busy:!0,error:"",reward:null});try{const o=await je(I(),"/me/chests/open",void 0,"Couldn't open the chest.");window.dispatchEvent(new CustomEvent("hay_wallet",Number.isFinite(Number(o==null?void 0:o.gems))?{detail:{gems:Number(o.gems)}}:void 0)),window.dispatchEvent(new CustomEvent("hay_rewards_changed")),f(p=>p.data?{...p,data:{...p.data,chests:Math.max(0,p.data.chests-1)}}:p),g({busy:!1,error:"",reward:{type:(o==null?void 0:o.reward_type)||"gems",gems:Number((o==null?void 0:o.reward_gems)||0),rarity:(o==null?void 0:o.rarity)||"wooden",xpBoost:!!(o!=null&&o.xp_boost_granted)}})}catch(o){o.status===400&&h(),g({busy:!1,error:o.message,reward:null})}}}if(!s||s.status==="skipped")return null;const r="w-full max-w-sm overflow-hidden rounded-2xl bg-slate-50 ring-1 ring-slate-200/70 dark:bg-white/[0.03] dark:ring-white/[0.08]";if(s.status==="error")return e.jsx("div",{className:r+" px-4 py-3 text-left",role:"alert",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ce,{className:"mt-0.5 h-5 w-5 shrink-0 text-cardinal-500"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-extrabold text-slate-900 dark:text-white",children:"Your XP isn't saved yet"}),e.jsx("p",{className:"mt-0.5 text-xs text-slate-500 dark:text-stone-400",children:s.error}),e.jsxs("button",{type:"button",onClick:n,className:"mt-2 inline-flex items-center gap-1.5 text-sm font-extrabold text-brand-600 hover:underline dark:text-brand-400",children:[e.jsx(xe,{className:"h-3.5 w-3.5"})," Try again"]})]})]})});if(!t||!d.data&&!d.error)return e.jsx("div",{className:r,"aria-busy":"true","aria-label":"Saving your progress",children:e.jsx("div",{className:"space-y-2.5 px-3.5 py-3",children:[0,1].map(o=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"h-8 w-8 animate-pulse rounded-xl bg-slate-200 dark:bg-white/[0.06]"}),e.jsx("span",{className:"h-3.5 flex-1 animate-pulse rounded-full bg-slate-200 dark:bg-white/[0.06]"})]},o))})});if(!d.data)return e.jsxs("div",{className:r+" flex items-center justify-between gap-3 px-4 py-3 text-left",children:[e.jsxs("span",{className:"flex items-center gap-2 text-xs text-slate-500 dark:text-stone-400",children:[e.jsx(X,{className:"h-4 w-4 shrink-0 text-grass-600"})," Lesson saved. ",d.error]}),e.jsx("button",{type:"button",onClick:h,className:"shrink-0 text-sm font-extrabold text-brand-600 hover:underline dark:text-brand-400",children:"Retry"})]});const c=d.data,b=Math.min(100,Math.round(c.todayXp/i*100)),w=c.todayXp>=i,v=a===!1&&c.streak>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:r+" divide-y divide-slate-200/70 dark:divide-white/[0.06]",children:[e.jsxs(S,{icon:w?me:H,iconClass:w?"bg-gold-100 text-gold-600 dark:bg-gold-500/20 dark:text-gold-400":"bg-white text-brand-500 ring-1 ring-slate-200 dark:bg-white/[0.06] dark:ring-0",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"font-extrabold text-slate-900 dark:text-white",children:w?"Daily goal reached":"Daily goal"}),e.jsxs("span",{className:"text-xs font-bold tabular-nums text-slate-500 dark:text-stone-400",children:[c.todayXp," / ",i," XP"]})]}),e.jsx("div",{className:"mt-1.5 h-2 overflow-hidden rounded-full bg-slate-200 dark:bg-white/[0.08]",role:"progressbar","aria-valuemin":0,"aria-valuemax":i,"aria-valuenow":Math.min(c.todayXp,i),"aria-label":"Daily goal",children:e.jsx("div",{className:"h-full rounded-full transition-[width] duration-700 "+(w?"bg-gold-400":"bg-brand-500"),style:{width:`${b}%`}})}),!w&&e.jsxs("div",{className:"mt-1 text-[11px] text-slate-400 dark:text-stone-500",children:[i-c.todayXp," XP to go today"]})]}),c.streak>0&&e.jsxs(S,{icon:ue,iconClass:"bg-orange-50 text-orange-500 dark:bg-orange-500/15",children:[e.jsxs("span",{className:"font-extrabold text-slate-900 dark:text-white",children:[c.streak," day streak"]}),e.jsx("span",{className:"ml-1.5 text-xs text-slate-500 dark:text-stone-400",children:v?c.streak===1?"Started today":"Extended today":"Safe for today"})]}),c.chests>0&&e.jsxs(S,{icon:he,iconClass:"bg-gold-100 text-gold-600 dark:bg-gold-500/20 dark:text-gold-400",action:e.jsxs("button",{type:"button",onClick:N,disabled:m.busy,className:"inline-flex items-center gap-1.5 rounded-xl bg-gold-400 px-3 py-1.5 text-xs font-extrabold text-white transition hover:bg-gold-500 disabled:opacity-60",children:[m.busy&&e.jsx(R,{className:"h-3.5 w-3.5 animate-spin"})," Open"]}),children:[e.jsx("span",{className:"font-extrabold text-slate-900 dark:text-white",children:c.chests===1?"A chest to open":`${c.chests} chests to open`}),m.error&&e.jsx("div",{className:"text-xs text-cardinal-600 dar
1k:text-cardinal-400",children:m.error})]}),c.claimableQuests>0&&e.jsx(S,{icon:X,iconClass:"bg-grass-50 text-grass-600 dark:bg-grass-500/15 dark:text-grass-400",action:e.jsx(pe,{to:"/rewards",className:"text-xs font-extrabold text-brand-600 hover:underline dark:text-brand-400",children:"Collect"}),children:e.jsx("span",{className:"font-extrabold text-slate-900 dark:text-white",children:c.claimableQuests===1?"A quest is ready to collect":`${c.claimableQuests} quests ready to collect`})})]}),m.reward&&e.jsx(ge,{reward:m.reward,onClose:()=>g(o=>({...o,reward:null}))})]})}function Ee({lesson:s,mascotCharacter:n="armen",sessionXpEarned:a,comboBonusXp:l=0,mistakes:i=0,analytics:t,analyticsError:d,onOpenExercise:h,onRetry:f,retryBusy:m=!1,retryError:g="",onContinue:N,save:r,onRetrySave:c,continuePending:b=!1,startedPracticedToday:w,timeMs:v}){var q,z;const o=Number(i)===0,[p,W]=u.useState(!1),[$,A]=u.useState(""),K=u.useMemo(()=>ve(t==null?void 0:t.completion_ratio),[t]),F=t?Math.round(K*100):100,V=Number((t==null?void 0:t.earned_xp)??0)||0,T=Number((t==null?void 0:t.correct_exercises)??(t==null?void 0:t.completed_exercises)??0)||0,j=Number((t==null?void 0:t.total_exercises)??0)||0,D=Number(a||V)||0,C=(r==null?void 0:r.status)==="saved"&&r.doubleXp,k=(r==null?void 0:r.status)==="saved"?Math.max(1,Number(r.xpBoost)||1):1,E=(C?D*2:D)+D*(k-1),Y=k>1?`${k+(C?1:0)}Ã`:C?"2Ã":null,Z=ye(E,{duration:900,startFromZero:!0}),M=u.useMemo(()=>{const x=Number((t==null?void 0:t.total_attempts)??0)||0,_=Number((t==null?void 0:t.correct_attempts)??0)||0;return x?Math.round(_/x*100):j>0?Math.round(T/j*100):F},[t,T,j,F]),ee=M>=90?"Amazing":M>=70?"Great":"Good",y=F>=B;u.useEffect(()=>{y&&be.complete()},[]);const te=(r==null?void 0:r.status)==="saving",P=(r==null?void 0:r.status)==="error",se=b?"Savingâ¦":P&&!r.unauthorized?"Save and continue":P?"Log in again":"Continue";async function ae(){const x=await Se({lessonTitle:(s==null?void 0:s.title)||"a lesson",xp:E,accuracy:M});(x==="copied"||x==="failed")&&(A(x),setTimeout(()=>A(""),2500))}return e.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-white dark:bg-[#0f0f10] sm:static sm:z-auto sm:mx-auto sm:my-6 sm:block sm:max-w-lg sm:overflow-hidden sm:rounded-3xl sm:shadow-md sm:ring-1 sm:ring-slate-200 dark:sm:ring-white/[0.08]",children:[y?e.jsx(_e,{}):null,e.jsxs("div",{className:"relative flex flex-1 flex-col items-center justify-center gap-4 overflow-y-auto px-6 py-6 text-center sm:flex-none sm:overflow-visible sm:pt-10",children:[e.jsx("img",{src:fe(n,y?"positive":"negative"),alt:"","aria-hidden":"true",className:"animate-pop h-32 w-32 object-contain drop-shadow-xl [@media(min-height:760px)]:h-40 [@media(min-height:760px)]:w-40 sm:h-44 sm:w-44"}),e.jsxs("div",{className:"page-in",style:{animationDelay:"100ms"},children:[e.jsx("h2",{className:"font-display text-3xl font-extrabold tracking-tight text-gold-500 sm:text-4xl dark:text-gold-400",children:o?"Perfect lesson!":y?"Lesson complete!":"Almost there!"}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-slate-500 dark:text-stone-400",children:o?"Ô¿Õ¥ÖÖÕ¥ÕÕ½! Not a single mistake.":y?`${i} mistake${Number(i)===1?"":"s"}. Retry any time to master it.`:`Get ${B}% or more to master this lesson. Retry and you've got it.`})]}),e.jsxs("div",{className:"grid w-full max-w-sm grid-cols-2 gap-3",children:[e.jsx("div",{className:"tile-pop",style:{animationDelay:"180ms"},children:e.jsx(U,{label:"Total XP",icon:re,value:`+${Z}`,tone:"gold",badge:Y})}),e.jsx("div",{className:"tile-pop",style:{animationDelay:"230ms"},children:e.jsx(U,{label:ee,icon:H,value:`${M}%`,tone:"grass"})})]}),e.jsxs("div",{className:"page-in flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-sm font-bold text-slate-400 dark:text-stone-500",style:{animationDelay:"280ms"},children:[j?e.jsxs("span",{children:[T,"/",j," correct"]}):null,Number.isFinite(v)?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ne,{className:"h-4 w-4"})," ",Ce(v)]}):null,l>0?e.jsxs("span",{className:"text-brand-500 dark:text-brand-400",children:["+",l," combo"]}):null,k>1?e.jsxs("span",{className:"text-gold-600 dark:text-gold-400",children:[k,"à XP boost used"]}):C?e.jsx("span",{className:"text-gold-600 dark:text-gold-400",children:"Double XP used"}):null]}),e.jsx("div",{className:"page-in flex w-full justify-center",style:{animationDelay:"340ms"},children:e.jsx(Te,{save:r,onRetrySave:c,startedPracticedToday:w})}),(r==null?void 0:r.status)==="skipped"&&r.reason?e.jsx("p",{className:"text-xs font-semibold text-slate-400 dark:text-stone-500",children:r.reason}):null,(r==null?void 0:r.status)==="saved"&&((q=r.stats)==null?void 0:q.lesson_completed)===!1?e.jsx("p",{className:"max-w-sm text-xs font-semibold text-slate-500 dark:text-stone-400",children:"This one doesn't count yet â you skipped most of it. Play it again and answer more of the exercises to unlock the next lesson."}):null,g?e.jsx("p",{role:"alert",className:"text-sm font-semibold text-cardinal-600 dar
1k:text-cardinal-400",children:g}):null,(z=t==null?void 0:t.exercises)!=null&&z.length?e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("button",{type:"button",onClick:()=>W(x=>!x),"aria-expanded":p,className:"mx-auto inline-flex items-center gap-1.5 text-sm font-bold text-slate-500 hover:text-slate-700 dark:text-stone-400 dark:hover:text-stone-200",children:[p?e.jsx(le,{className:"h-4 w-4"}):e.jsx(oe,{className:"h-4 w-4"}),p?"Hide details":"View details"]}),p?e.jsx("div",{className:"mt-3 divide-y divide-slate-100 overflow-hidden rounded-2xl text-left ring-1 ring-slate-200 dark:divide-white/[0.06] dark:ring-white/[0.08]",children:t.exercises.map((x,_)=>{const G=!!x.completed,Q=Number(x.attempts)||0;return e.jsxs("button",{type:"button",onClick:()=>h==null?void 0:h(x),className:"flex w-full items-center justify-between gap-4 p-3 text-left hover:bg-slate-50 dark:hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"truncate text-sm font-bold text-slate-800 dark:text-white",children:[_+1,". ",Me(x.kind)]}),e.jsxs("div",{className:"mt-0.5 text-xs font-semibold text-slate-400 dark:text-stone-500",children:[Q," ",Q===1?"try":"tries"," · ",Math.round((Number(x.accuracy)||0)*100),"% · ",Number(x.xp)||0," XP"]})]}),e.jsx("span",{className:"shrink-0 rounded-full px-2.5 py-1 text-xs font-bold "+(G?"bg-grass-50 text-grass-700 dark:bg-grass-500/15 dark:text-grass-400":"bg-slate-100 text-slate-500 dark:bg-white/[0.06] dark:text-stone-400"),children:G?"Done":"Missed"})]},x.exercise_id??_)})}):null]}):d?e.jsx("p",{className:"text-xs font-semibold text-slate-400 dark:text-stone-500",children:"Exercise details aren't available right now."}):null]}),e.jsx("div",{className:"safe-b relative shrink-0 border-t-2 border-slate-100 bg-white px-4 py-4 dark:border-white/[0.06] dark:bg-[#0f0f10] sm:border-t-0 sm:bg-transparent sm:pb-8 sm:dark:bg-transparent",children:e.jsxs("div",{className:"mx-auto flex max-w-md flex-col gap-2",children:[e.jsxs("button",{type:"button",onClick:N,disabled:b||m,className:"btn3d btn3d-brand inline-flex w-full items-center justify-center gap-2 uppercase disabled:opacity-70",children:[b?e.jsx(R,{className:"h-4 w-4 animate-spin"}):null,se," ",!b&&e.jsx("span",{"aria-hidden":!0,children:"â"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-sm font-bold text-slate-400 dark:text-stone-500",children:[e.jsxs("button",{type:"button",onClick:f,disabled:m||b||te,className:"inline-flex items-center gap-1.5 hover:text-slate-600 disabled:opacity-50 dark:hover:text-stone-300",children:[m?e.jsx(R,{className:"h-4 w-4 animate-spin"}):e.jsx(ie,{className:"h-4 w-4"})," Retry"]}),e.jsx("button",{type:"button",onClick:ae,className:"inline-flex items-center gap-1.5 hover:text-slate-600 dark:hover:text-stone-300",children:$==="copied"?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 text-grass-500"})," Copied"]}):$==="failed"?e.jsx("span",{className:"text-cardinal-500",children:"Couldn't copy"}):e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"h-4 w-4"})," Share"]})})]})]})})]})}export{Ee as L}; 2//# sourceMappingURL=LessonCompletionScreen-00a19922.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.