(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[44347],{56268:(e,s,t)=>{Promise.resolve().then(t.bind(t,47006))},47006:(e,s,t)=>{"use strict";t.d(s,{ModuleLessonShell:()=>H});var l=t(19002),n=t(52114),r=t(40315),a=t(40399),i=t(84735),o=t(41181),c=t(78806);function d(){return(0,l.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,l.jsx)("div",{className:"mb-3 pt-2",children:(0,l.jsxs)("div",{className:"flex items-start gap-2",children:[(0,l.jsx)(c.E,{className:"h-9 w-9 shrink-0 rounded-md"}),(0,l.jsxs)("div",{className:"flex-1 space-y-2 pt-0.5",children:[(0,l.jsx)(c.E,{className:"h-9 w-2/3"}),(0,l.jsx)(c.E,{className:"h-5 w-1/3"})]})]})}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)(c.E,{className:"h-4 w-28"}),(0,l.jsx)(c.E,{className:"h-4 w-24"})]}),(0,l.jsx)(o.Zp,{children:(0,l.jsxs)(o.Wu,{className:"p-6 space-y-4",children:[(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)(c.E,{className:"h-4 w-full"}),(0,l.jsx)(c.E,{className:"h-4 w-full"}),(0,l.jsx)(c.E,{className:"h-4 w-5/6"})]}),(0,l.jsxs)("div",{className:"space-y-2 pt-2",children:[(0,l.jsx)(c.E,{className:"h-6 w-2/3"}),(0,l.jsx)(c.E,{className:"h-4 w-full"}),(0,l.jsx)(c.E,{className:"h-4 w-full"}),(0,l.jsx)(c.E,{className:"h-4 w-4/5"})]}),(0,l.jsxs)("div",{className:"space-y-2 pt-2",children:[(0,l.jsx)(c.E,{className:"h-4 w-full"}),(0,l.jsx)(c.E,{className:"h-4 w-full"}),(0,l.jsx)(c.E,{className:"h-4 w-3/4"})]}),(0,l.jsx)(c.E,{className:"h-48 w-full rounded-lg mt-4"}),(0,l.jsxs)("div",{className:"space-y-2 pt-2",children:[(0,l.jsx)(c.E,{className:"h-4 w-full"}),(0,l.jsx)(c.E,{className:"h-4 w-full"}),(0,l.jsx)(c.E,{className:"h-4 w-5/6"})]})]})})]})]})}var u=t(45139);function m(e,s){return"".concat("module-lesson-progress",":").concat(e,":").concat(s)}function x(e,s,t){try{localStorage.setItem(m(e,s),JSON.stringify({progress:t,timestamp:Date.now()}))}catch(e){}}var h=t(79526),f=t(31336),p=t(99824),v=t(10797),g=t(19026),j=t(27309),w=t(38913),N=t(1697),b=t(8639),E=t(23746),y=t(54995),C=t(88775),L=t(92409),S=t(43995),k=t(48728),I=t(26935),M=t(31055),T=t(52110),P=t(28937),O=t(81884),A=t(2005),R=t(11321),X=t(37088),D=t(1459);function F(e){let{isOpen:s,title:t="Complete this lesson?",description:r="You have started this lesson. Mark it complete before opening the next one?",completeLabel:a="Yes, complete it",priorCount:i=0,priorLabel:o,isSaving:c=!1,onClose:d,onSkip:u,onComplete:m}=e,[x,h]=(0,n.useState)(!1),f=i>0;(0,n.useEffect)(()=>{s||h(!1)},[s]),(0,n.useEffect)(()=>{if(!s||c)return;let e=e=>{"Enter"===e.key&&(e.preventDefault(),v())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,f,s,c]);let p=e=>{e||c||(h(!1),d())},v=()=>{m(f&&x)};return(0,l.jsx)(D.lG,{open:s,onOpenChange:p,children:(0,l.jsxs)(D.Cf,{className:"max-w-[calc(100vw-2rem)] sm:max-w-xl",onClose:()=>!c&&p(!1),children:[(0,l.jsxs)(D.c7,{children:[(0,l.jsx)("div",{className:"mb-2 flex h-10 w-10 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/20",children:(0,l.jsx)(O.A,{className:"h-5 w-5 text-green-600 dark:text-green-400"})}),(0,l.jsx)(D.L3,{children:t}),(0,l.jsx)(D.rr,{children:r})]}),f?(0,l.jsxs)("label",{className:"flex items-start gap-3 rounded-md border bg-muted/30 p-3 text-sm",children:[(0,l.jsx)(X.S,{className:"mt-0.5",checked:x,disabled:c,onCheckedChange:e=>h(!0===e)}),(0,l.jsx)("span",{className:"leading-5 text-muted-foreground",children:null!=o?o:"Also complete ".concat(i," started earlier ").concat(1===i?"item":"items"," before the destination.")})]}):null,(0,l.jsxs)(D.Es,{className:"grid grid-cols-3 gap-2",children:[(0,l.jsx)(M.$,{type:"button",variant:"outline",disabled:c,onClick:()=>{h(!1),u()},className:"h-11 w-full whitespace-nowrap",children:"No"}),(0,l.jsxs)(M.$,{type:"button",disabled:c,onClick:v,className:"col-span-2 h-11 w-full whitespace-nowrap",children:[c?(0,l.jsx)(A.A,{className:"mr-2 h-4 w-4 shrink-0 animate-spin"}):(0,l.jsx)(R.A,{className:"mr-2 h-4 w-4 shrink-0"}),(0,l.jsx)("span",{children:a}),c?null:(0,l.jsx)("kbd",{className:"ml-2 rounded border border-primary-foreground/30 px-1.5 py-0.5 text-[10px] font-semibold leading-none",children:"Enter"})]})]})]})})}var _=t(57126),z=t(17622),G=t(95836);function q(e,s,t){var l;return(null===(l=s[e])||void 0===l?void 0:l.status)===h.Xn.COMPLETED||t.has(e)}function B(e){let{isOpen:s,onClose:t,courseId:r,userId:o,modules:c,lessonProgress:d,onLessonsCompleted:m}=e,[x,f]=(0,n.useState)(()=>new Set),[p,v]=(0,n.useState)(!1),g=(0,n.useMemo)(()=>c.map(e=>{let s=function(e,s,t){let l=new Set,n=!1;for(let r of e)n&&l.add(r.id),r.isPrerequisite&&!q(r.id,s,t)&&(n=!0);return l}(e.lessons,d,x),t=e.lessons.filter(e=>{var t;return e.slug&&!s.has(e.id)&&(null===(t=d[e.id])||void 0===t?void 0:t.status)!==h.Xn.COMPLETED});return{courseModule:e,lockedLessonIds:s,selectableLessons:t,selectableLessonIds:t.map(e=>e.id)}}),[d,c,x]),j=(0,n.useMemo)(()=>g.flatMap(e=>e.selectableLessons.map(s=>({lesson:s,moduleSlug:e.courseModule.slug}))),[g]),w=(0,n.useMemo)(()=>new Set(j.map(e=>{let{lesson:s}=e;return s.id})),[j]),N=x.size,b=()=>{p||(f(new Set),t())},E=e=>{w.has(e)&&!p&&f(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},y=e=>{var s;if(p)return;let t=g.find(s=>s.courseModule.id===e.id),l=null!==(s=null==t?void 0:t.selectableLessonIds)&&void 0!==s?s:[],n=l.length>0&&l.every(e=>x.has(e));f(e=>{let s=new Set(e);return l.forEach(e=>{n?s.delete(e):s.add(e)}),s})},C=async()=>{if(0===x.size||p)return;v(!0);let e=j.filter(e=>{let{lesson:s}=e;return x.has(s.id)});try{for(let{lesson:t,moduleSlug:l}of e){let e=await (0,i.$)(o,t.slug,l,r,h.Xn.COMPLETED,{revalidateGamification:!1});if(!e.success){var s;throw Error(null!==(s=e.error)&&void 0!==s?s:"Failed to update progress")}}m(e.map(e=>{let{lesson:s}=e;return s.id})),(0,u.c)(o),G.o.success(1===e.length?"Progress updated for 1 lesson":"Progress updated for ".concat(e.length," lessons")),f(new Set),t()}catch(e){console.error("Failed to update course progress:",e),G.o.error(e instanceof Error?e.message:"Failed to update progress")}finally{v(!1)}};return(0,l.jsx)(D.lG,{open:s,onOpenChange:e=>{e||b()},children:(0,l.jsxs)(D.Cf,{className:"max-w-2xl",onClose:b,children:[(0,l.jsxs)(D.c7,{children:[(0,l.jsx)(D.L3,{children:"Update course progress"}),(0,l.jsx)(D.rr,{children:"Select completed lessons. Lessons after incomplete prerequisites stay locked until those prerequisites are complete."})]}),(0,l.jsx)("div",{className:"max-h-[60vh] overflow-y-auto pr-1",children:(0,l.jsx)("div",{className:"space-y-3",children:g.map(e=>{let{courseModule:s,lockedLessonIds:t,selectableLessons:n,selectableLessonIds:r}=e,i=s.lessons.filter(e=>q(e.id,d,x)).length,o=s.lessons.length>0&&i===s.lessons.length,c=r.some(e=>x.has(e));return(0,l.jsxs)("section",{className:"border",children:[(0,l.jsxs)("div",{className:(0,a.cn)("flex w-full cursor-pointer items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-muted/60",(p||0===n.length)&&"cursor-not-allowed opacity-60"),onClick:()=>y(s),children:[(0,l.jsx)(X.S,{checked:!!o||!!c&&"indeterminate",disabled:p||0===n.length,"aria-label":"Select available incomplete lessons in Module ".concat(s.orderIndex),onClick:e=>e.stopPropagation(),onCheckedChange:()=>y(s)}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("p",{className:"truncate text-sm font-semibold",children:["Module ",s.orderIndex]}),(0,l.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:s.title})]}),(0,l.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground",children:[i,"/",s.lessons.length]})]}),(0,l.jsx)("div",{className:"border-t",children:s.lessons.map(e=>{var s;let n=(null===(s=d[e.id])||void 0===s?void 0:s.status)===h.Xn.COMPLETED,r=x.has(e.id),i=t.has(e.id),o=p||n||i||!e.slug;return(0,l.jsxs)("div",{className:(0,a.cn)("flex w-full cursor-pointer items-center gap-3 px-4 py-2 text-left transition-colors hover:bg-muted/40",o&&"cursor-not-allowed opacity-70"),onClick:()=>E(e.id),children:[(0,l.jsx)(X.S,{checked:n||r,disabled:o,"aria-label":"Mark ".concat(e.title," complete"),onClick:e=>e.stopPropagation(),onCheckedChange:()=>E(e.id)}),(0,l.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm",children:e.title}),e.isPrerequisite?(0,l.jsx)(L.A,{className:"h-4 w-4 shrink-0 text-zinc-400"}):null,i?(0,l.jsx)(z.A,{className:"h-4 w-4 shrink-0 text-zinc-400"}):n?(0,l.jsx)(O.A,{className:"h-4 w-4 shrink-0 text-green-500"}):null]},e.id)})})]},s.id)})})}),(0,l.jsxs)(D.Es,{className:"gap-2 sm:justify-between",children:[(0,l.jsx)(M.$,{type:"button",variant:"ghost",onClick:()=>{p||f(new Set(w))},disabled:p||0===w.size,children:"Select available"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(D.HM,{asChild:!0,children:(0,l.jsx)(M.$,{type:"button",variant:"outline",onClick:()=>f(new Set),disabled:p,children:"Cancel"})}),(0,l.jsx)(M.$,{type:"button",onClick:C,disabled:p||0===N,children:p?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(A.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Updating"]}):1===N?"Mark 1 lesson complete":"Mark ".concat(N," lessons complete")})]})]})]})})}function $(e){var s,t,o,c,d;let{lessons:m,currentLessonId:x,userId:O,courseId:A,courseslug:R,courseTitle:X="Course",moduleSlug:D,isExampleCourse:z=!1,currentLesson:G,module:q,modules:$,lessonProgress:U={},onLessonsCompleted:W}=e,Z=(0,r.useRouter)(),{isExpanded:H,setIsExpanded:J}=(0,n.useContext)(_.I),[V,Y]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(64),[ee,es]=(0,n.useState)(!1),[et,el]=(0,n.useState)(null),[en,er]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=()=>{let e=window.innerWidth<640;Y(e),e&&J(!1)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[J]),(0,n.useEffect)(()=>{let e=0,s=()=>{var e;let s=document.querySelector("[data-app-navbar]"),t=null!==(e=null==s?void 0:s.getBoundingClientRect())&&void 0!==e?e:null;Q(t&&t.bottom>0?Math.round(t.bottom):0)},t=()=>{e&&window.cancelAnimationFrame(e),e=window.requestAnimationFrame(()=>{s()})};return s(),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{e&&window.cancelAnimationFrame(e),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[]);let ea=(e,s)=>{var t,n;let r=(null===(t=U[s])||void 0===t?void 0:t.status)===h.Xn.COMPLETED,a=(null===(n=U[s])||void 0===n?void 0:n.status)===h.Xn.IN_PROGRESS,i=r?"text-green-500":a?"text-yellow-500":"text-zinc-400";switch(e){case I.nv.VIDEO:return(0,l.jsx)(p.A,{className:"h-4 w-4 ".concat(i)});case I.nv.ARTICLE:return(0,l.jsx)(v.A,{className:"h-4 w-4 ".concat(i)});case I.nv.INTERACTIVE_ARTICLE:return(0,l.jsx)(g.A,{className:"h-4 w-4 ".concat(i)});case I.nv.DOWNLOAD:return(0,l.jsx)(j.A,{className:"h-4 w-4 ".concat(i)});case I.nv.QUIZ:return(0,l.jsx)(w.A,{className:"h-4 w-4 ".concat(i)});case I.nv.SLIDES:return(0,l.jsx)(N.A,{className:"h-4 w-4 ".concat(i)});case I.nv.NOTEBOOK:return(0,l.jsx)(b.A,{className:"h-4 w-4 ".concat(i)});case I.nv.MULTIMEDIA:return(0,l.jsx)(N.A,{className:"h-4 w-4 ".concat(i)});default:return(0,l.jsx)(b.A,{className:"h-4 w-4 ".concat(i)})}},ei=e=>e.length?Math.round(e.filter(e=>{var s;return(null===(s=U[e.id])||void 0===s?void 0:s.status)===h.Xn.COMPLETED}).length/e.length*100):0,eo=e=>100===ei(e)?"text-green-500":e.some(e=>{var s;let t=null===(s=U[e.id])||void 0===s?void 0:s.status;return t===h.Xn.COMPLETED||t===h.Xn.IN_PROGRESS})?"text-yellow-500":"text-zinc-400",ec=e=>{var s;return(null===(s=U[e])||void 0===s?void 0:s.status)===h.Xn.COMPLETED},ed=m.findIndex(e=>e.isPrerequisite&&!ec(e.id)),eu=e=>-1!==ed&&e>ed,em=(x?null===(s=U[x])||void 0===s?void 0:s.status:null)===h.Xn.IN_PROGRESS,ex=e=>G?m.filter(s=>{var t;return s.id!==G.id&&s.id!==e.id&&!!s.slug&&s.orderIndexs.slug?"/courses/".concat(R,"/modules/").concat(e,"/").concat(s.slug):null,ef=()=>{et&&(Z.push(et.href),el(null))},ep=e=>!!O&&em&&!!(null==G?void 0:G.slug)&&!!e&&e!==x,ev=(e,s)=>{if(ep(e.id)){var t;return el({...s,priorLessons:null!==(t=s.priorLessons)&&void 0!==t?t:ex(e)}),!0}return!1},eg=async e=>{if(!O||!(null==G?void 0:G.slug)||!et){ef();return}er(!0);try{let s=[];if(e)for(let e of et.priorLessons){if(!(await (0,i.$)(O,e.slug,D,A,h.Xn.COMPLETED,{revalidateGamification:!1})).success)return;s.push(e.id)}if(!(await (0,i.$)(O,G.slug,D,A,h.Xn.COMPLETED,{revalidateGamification:!1})).success)return;s.push(G.id),s.length>0&&(null==W||W(s),(0,u.c)(O)),ef()}catch(e){console.error("Failed to complete lesson before navigation:",e)}finally{er(!1)}},ej=(e,s)=>{if(eu(s)||!e.slug)return;V&&J(!1);let t=eh(D,e);if(t){if(ev(e,{href:t}))return;Z.push(t)}},ew=e=>{var s;if(e.slug===D)return;V&&J(!1);let t=e.lessons.find(e=>!!e.slug),l=(null==t?void 0:t.slug)?"/courses/".concat(R,"/modules/").concat(e.slug,"/").concat(t.slug):"/courses/".concat(R,"/modules/").concat(e.slug);t&&ev(t,{href:null!==(s=eh(e.slug,t))&&void 0!==s?s:l,priorLessons:[]})||Z.push(l)},eN=$.length?[...$].sort((e,s)=>e.orderIndex-s.orderIndex):[{id:D,title:null!==(t=null==q?void 0:q.title)&&void 0!==t?t:"Module",slug:D,orderIndex:null!==(o=null==q?void 0:q.orderIndex)&&void 0!==o?o:0,isFree:null===(c=null==q?void 0:q.isFree)||void 0===c||c,lessons:m}],eb=ei(m),eE=ei(eN.flatMap(e=>e.lessons));return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:(0,a.cn)("fixed left-0 bg-background border-r z-40 transition-all duration-300 overflow-hidden flex flex-col",H?"w-64":"w-12"),style:{top:K,height:"calc(100vh - ".concat(K,"px)")},children:[(0,l.jsx)("div",{className:"border-b shrink-0",children:(0,l.jsxs)("div",{className:"flex h-14 items-center justify-between px-3",children:[H?(0,l.jsx)("p",{className:"min-w-0 truncate text-sm font-semibold",children:X}):null,(0,l.jsx)(M.$,{variant:"ghost",size:"icon",onClick:()=>J(!H),className:(0,a.cn)("h-8 w-8 shrink-0",!H&&"mx-auto"),"aria-label":H?"Collapse sidebar":"Expand sidebar",children:H?(0,l.jsx)(E.A,{className:"h-4 w-4"}):(0,l.jsx)(y.A,{className:"h-4 w-4"})})]})}),(0,l.jsx)("div",{className:"flex-1 overflow-y-auto",children:eN.map(e=>{let s=e.slug===D,t=eo(e.lessons);return(0,l.jsxs)("div",{className:"border-b",children:[(0,l.jsxs)("button",{type:"button",onClick:()=>ew(e),className:(0,a.cn)("w-full flex items-center gap-3 px-3 py-3 text-left transition-colors",!H&&"justify-center px-0",s?"bg-accent/40":"hover:bg-accent/50"),"aria-label":H?void 0:"Module ".concat(e.orderIndex,": ").concat(e.title),children:[(0,l.jsx)(C.A,{className:(0,a.cn)("h-4 w-4 shrink-0",t)}),H?(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("p",{className:(0,a.cn)("truncate text-sm font-semibold",t),children:["Module ",e.orderIndex,s?" (".concat(eb,"%)"):null]}),(0,l.jsx)("p",{className:"truncate text-sm text-muted-foreground",children:e.title})]}):null]}),s?e.lessons.map((e,s)=>{let t=e.id===x,n=eu(s);return(0,l.jsxs)("button",{onClick:()=>ej(e,s),disabled:n,className:(0,a.cn)("w-full flex items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-accent/50",!H&&"justify-center px-0",n&&"cursor-not-allowed opacity-50 hover:bg-transparent",t&&"bg-accent text-accent-foreground"),"aria-label":H?void 0:e.title,children:[ea(e.lessonType,e.id),H&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("span",{className:"text-xs text-muted-foreground w-5",children:s+1}),(0,l.jsx)("span",{className:"truncate flex-1",children:e.title}),e.isPrerequisite?(0,l.jsx)(L.A,{className:"h-3.5 w-3.5 shrink-0 text-zinc-400"}):null]})]},e.id)}):null]},e.id)})}),(0,l.jsxs)("div",{className:"border-t shrink-0",children:[(0,l.jsxs)("button",{type:"button",onClick:()=>{f.Ay.show(P.B)},className:(0,a.cn)("w-full flex items-center gap-2 px-3 py-3 border-b text-sm text-muted-foreground hover:bg-accent/50 transition-colors",!H&&"justify-center px-0"),"aria-label":"Feedback",children:[(0,l.jsx)(S.A,{className:"h-4 w-4 shrink-0"}),H?(0,l.jsx)("span",{children:"Feedback"}):null]}),O?(0,l.jsxs)("button",{type:"button",onClick:()=>es(!0),className:(0,a.cn)("w-full flex items-center gap-2 px-3 py-3 border-b text-sm text-muted-foreground hover:bg-accent/50 transition-colors",!H&&"justify-center px-0"),"aria-label":"Update progress",children:[(0,l.jsx)(w.A,{className:"h-4 w-4 shrink-0"}),H?(0,l.jsx)("span",{children:"Update progress"}):null]}):null,(0,l.jsxs)("button",{type:"button",onClick:()=>{V&&J(!1),Z.push(z?"/courses":"/courses/".concat(R))},className:(0,a.cn)("w-full flex items-center gap-2 px-3 py-3 border-b text-sm text-muted-foreground hover:bg-accent/50 transition-colors",!H&&"justify-center px-0"),"aria-label":z?"Back to courses":"Back to modules",children:[(0,l.jsx)(k.A,{className:"h-4 w-4 shrink-0"}),H?(0,l.jsx)("span",{children:z?"Back to courses":"Back to modules"}):null]}),(0,l.jsxs)("div",{className:(0,a.cn)("px-3 py-3",!H&&"px-2"),children:[(0,l.jsxs)("div",{className:(0,a.cn)("mb-2 text-sm",H?"flex items-center justify-between":"text-center"),children:[H?(0,l.jsx)("span",{className:"text-muted-foreground",children:"Course progress"}):null,(0,l.jsxs)("span",{className:"font-medium",children:[eE,"%"]})]}),(0,l.jsx)(T.Progress,{value:eE,className:"h-2"})]})]}),O?(0,l.jsx)(B,{isOpen:ee,onClose:()=>es(!1),courseId:A,userId:O,modules:eN,lessonProgress:U,onLessonsCompleted:e=>{null==W||W(e)}}):null]}),(0,l.jsx)(F,{isOpen:!!et,isSaving:en,onClose:()=>el(null),onSkip:ef,onComplete:eg,priorCount:null!==(d=null==et?void 0:et.priorLessons.length)&&void 0!==d?d:0,priorLabel:(null==et?void 0:et.priorLessons.length)?"Also complete ".concat(et.priorLessons.length," started earlier ").concat(1===et.priorLessons.length?"lesson":"lessons"," before the destination."):void 0})]})}var U=t(39355);function W(e,s){let t={...e};for(let e of s)t[e]={...t[e],status:h.Xn.COMPLETED};return t}function Z(e){var s;let{children:t,course:r,module:i,lessons:o,lessonProgress:c,currentLesson:u,currentLessonIndex:m,nextLesson:x,nextModuleFirstLessonPath:h,userId:f,isFreeTier:p,onOptimisticCurrentCompleted:v,onOptimisticLessonsCompleted:g,earlierIncompleteLessons:j,hasEarlierIncompletePrerequisite:w}=e,{isExpanded:N}=(0,n.useContext)(_.I),b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{var e;null===(e=b.current)||void 0===e||e.scrollTo({top:0,left:0}),window.scrollTo({top:0,left:0}),document.documentElement.scrollTop=0,document.body.scrollTop=0},[null==u?void 0:u.id]),(0,l.jsxs)("div",{className:(0,a.cn)("flex-1 flex min-w-0 flex-col overflow-hidden transition-[margin] duration-300",N?"ml-64":"ml-12"),children:[(0,l.jsx)("div",{ref:b,className:"flex-1 overflow-auto px-3 py-2 pb-16 sm:px-4",children:(0,l.jsx)(n.Suspense,{fallback:(0,l.jsx)(d,{}),children:t})}),u?(0,l.jsx)(_._,{userId:null!=f?f:"",courseSlug:r.slug,courseId:r.id,moduleSlug:i.slug,moduleTitle:i.title,currentLessonId:u.id,currentLessonSlug:u.slug,currentLessonTitle:u.title,currentLessonType:u.lessonType,nextLessonSlug:(null==x?void 0:x.slug)||null,nextModuleFirstLessonPath:h,currentLessonIndex:m,totalLessons:o.length,currentLessonStatus:null===(s=c[u.id])||void 0===s?void 0:s.status,earlierIncompleteLessons:j,hasEarlierIncompletePrerequisite:w,currentLessonIsExam:u.isExam,currentLessonPassRate:u.passRate,isFreeTier:p,moduleIsFree:i.isFree,onOptimisticCurrentCompleted:v,onOptimisticLessonsCompleted:g}):null]})}function H(e){var s;let{children:t,lessons:a,course:o,module:c,modules:d,userId:f,initialLessonProgress:p,isFreeTier:v}=e,g=(0,r.usePathname)(),[j,w]=(0,n.useState)(p),{currentLesson:N,currentLessonIndex:b,nextLesson:E}=(0,n.useMemo)(()=>(function(e,s){var t,l;let n=s.split("/").filter(Boolean),r=null!==(t=n[n.length-1])&&void 0!==t?t:"",a=null!==(l=e.find(e=>e.slug===r))&&void 0!==l?l:null,i=a?e.findIndex(e=>e.id===a.id):-1,o=i>=0&&i{let e=[...d].sort((e,s)=>e.orderIndex-s.orderIndex),s=e.findIndex(e=>e.slug===c.slug),t=s>=0?e.slice(s+1).find(e=>e.lessons.some(e=>!!e.slug)):null,l=null==t?void 0:t.lessons.find(e=>!!e.slug);return t&&(null==l?void 0:l.slug)?"/courses/".concat(o.slug,"/modules/").concat(t.slug,"/").concat(l.slug):null},[o.slug,c.slug,d]),C=(0,n.useMemo)(()=>a.slice(0,Math.max(b,0)).filter(e=>{var s;return e.slug&&(null===(s=j[e.id])||void 0===s?void 0:s.status)!==h.Xn.COMPLETED}).map(e=>({id:e.id,slug:e.slug})),[b,j,a]),L=(0,n.useMemo)(()=>a.slice(0,Math.max(b,0)).some(e=>{var s;return e.isPrerequisite&&(null===(s=j[e.id])||void 0===s?void 0:s.status)!==h.Xn.COMPLETED}),[b,j,a]);(0,n.useEffect)(()=>{if(!f){w(p);return}w(function(e,s){if(!s)return e;let t={...e};for(let[e,l]of Object.entries(s)){if(!t[e])continue;let s=t[e].status,n=l.status;if(n===h.Xn.COMPLETED){t[e]={...t[e],status:h.Xn.COMPLETED};continue}n===h.Xn.IN_PROGRESS&&s===h.Xn.NOT_STARTED&&(t[e]={...t[e],status:h.Xn.IN_PROGRESS})}return t}(p,function(e,s){try{let t=localStorage.getItem(m(e,s));if(!t)return null;let l=JSON.parse(t);if(!l||"number"!=typeof l.timestamp||"object"!=typeof l.progress||null===l.progress||Date.now()-l.timestamp>36e5)return localStorage.removeItem(m(e,s)),null;return l.progress}catch(t){return localStorage.removeItem(m(e,s)),null}}(f,c.id)))},[p,c.id,f]),(0,n.useEffect)(()=>{var e,s;if(!f||!N||(null!==(s=null===(e=j[N.id])||void 0===e?void 0:e.status)&&void 0!==s?s:h.Xn.NOT_STARTED)!==h.Xn.NOT_STARTED)return;let t={...j,[N.id]:{...j[N.id],status:h.Xn.IN_PROGRESS}};w(t),x(f,c.id,t),(0,i.$)(f,N.slug,c.slug,o.id,h.Xn.IN_PROGRESS).then(e=>{e.success&&(0,u.c)(f)})},[o.id,N,j,c.id,c.slug,f]);let S=(0,n.useCallback)(()=>{if(!f||!N)return;let e=W(j,[N.id]);w(e),x(f,c.id,e)},[N,j,c.id,f]),k=(0,n.useCallback)(e=>{if(!f||0===e.length)return;let s=W(j,e);w(s),x(f,c.id,s)},[j,c.id,f]);return(0,l.jsx)("div",{className:"flex h-[calc(100vh-4rem)] min-w-0 flex-col",children:(0,l.jsx)("div",{className:"flex min-w-0 flex-1",children:(0,l.jsx)(_.SidebarProvider,{children:(0,l.jsxs)(U.S,{children:[(0,l.jsx)($,{lessons:a,currentLessonId:null!==(s=null==N?void 0:N.id)&&void 0!==s?s:"",userId:f,courseId:o.id,courseslug:o.slug,courseTitle:o.title,moduleSlug:c.slug,isExampleCourse:o.courseType===h.T3.EXAMPLE,module:{title:c.title,orderIndex:c.orderIndex,isFree:c.isFree},currentLesson:null!=N?N:void 0,modules:d,lessonProgress:j,isFreeTier:v,moduleIsFree:c.isFree,onLessonsCompleted:k}),(0,l.jsx)(Z,{lessons:a,course:o,module:c,lessonProgress:j,currentLesson:N,currentLessonIndex:b,nextLesson:E,nextModuleFirstLessonPath:y,userId:f,isFreeTier:v,onOptimisticCurrentCompleted:S,onOptimisticLessonsCompleted:k,earlierIncompleteLessons:C,hasEarlierIncompletePrerequisite:L,children:t})]})})})})}},41181:(e,s,t)=>{"use strict";t.d(s,{BT:()=>c,Wu:()=>d,ZB:()=>o,Zp:()=>a,aR:()=>i,wL:()=>u});var l=t(19002),n=t(52114),r=t(40399);let a=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,l.jsx)("div",{ref:s,className:(0,r.cn)("rounded-xl border bg-card text-card-foreground shadow",t),...n})});a.displayName="Card";let i=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,l.jsx)("div",{ref:s,className:(0,r.cn)("flex flex-col space-y-1.5 p-6",t),...n})});i.displayName="CardHeader";let o=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,l.jsx)("h3",{ref:s,className:(0,r.cn)("text-xl font-semibold leading-none tracking-tight",t),...n})});o.displayName="CardTitle";let c=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,l.jsx)("p",{ref:s,className:(0,r.cn)("text-sm text-muted-foreground",t),...n})});c.displayName="CardDescription";let d=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,l.jsx)("div",{ref:s,className:(0,r.cn)("p-6 pt-0",t),...n})});d.displayName="CardContent";let u=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,l.jsx)("div",{ref:s,className:(0,r.cn)("flex items-center p-6 pt-0",t),...n})});u.displayName="CardFooter"},37088:(e,s,t)=>{"use strict";t.d(s,{S:()=>o});var l=t(19002),n=t(52114),r=t(60),a=t(45359),i=t(40399);let o=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,l.jsx)(r.bL,{ref:s,className:(0,i.cn)("peer size-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...n,children:(0,l.jsx)(r.C1,{className:(0,i.cn)("flex items-center justify-center text-current"),children:(0,l.jsx)(a.A,{className:"size-4 shrink-0"})})})});o.displayName=r.bL.displayName},52110:(e,s,t)=>{"use strict";t.d(s,{Progress:()=>i});var l=t(19002),n=t(52114),r=t(67832),a=t(40399);let i=n.forwardRef((e,s)=>{let{className:t,value:n,...i}=e;return(0,l.jsx)(r.bL,{ref:s,className:(0,a.cn)("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",t),...i,children:(0,l.jsx)(r.C1,{className:"size-full flex-1 bg-primary transition-all",style:{transform:"translateX(-".concat(100-(n||0),"%)")}})})});i.displayName=r.bL.displayName},78806:(e,s,t)=>{"use strict";t.d(s,{E:()=>a});var l=t(19002),n=t(52114),r=t(40399);let a=n.forwardRef((e,s)=>{let{className:t,...n}=e;return(0,l.jsx)("div",{ref:s,className:(0,r.cn)("animate-pulse rounded-md bg-primary/10",t),...n})});a.displayName="SettingsSections"},42553:(e,s,t)=>{"use strict";t.d(s,{U:()=>n});var l=t(52114);function n(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{fallback:t,ssr:n=!0,getWindow:r}=s,a=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],t=l.useRef(e);return l.useEffect(()=>{t.current=e}),l.useCallback(function(){for(var e,s=arguments.length,l=Array(s),n=0;n{var s,l,r,i;return{media:e,matches:n?!!t:null===(l=(r=null!==(i=a())&&void 0!==i?i:window).matchMedia)||void 0===l?void 0:null===(s=l.call(r,e))||void 0===s?void 0:s.matches}});return l.useEffect(()=>{var s;let t=null!==(s=a())&&void 0!==s?s:window;o(s=>{let l={media:e,matches:t.matchMedia(e).matches};return s.matches===l.matches&&s.media===l.media?s:l});let l=function(e,s){try{return e.addEventListener("change",s),()=>e.removeEventListener("change",s)}catch(t){return e.addListener(s),()=>e.removeListener(s)}}(t.matchMedia(e),e=>{o(s=>s.media===e.media?{...s,matches:e.matches}:s)});return()=>l()},[a]),i.matches}}},e=>{var s=s=>e(e.s=s);e.O(0,[17094,55861,63791,44791,23039,31001,39586,71724,29071,58907,88709,48108,59644,28896,57126,28937,85030,5779,77358],()=>s(56268)),_N_E=e.O()}]);