import{aR as c}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,o){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,o),o)}};const u=async()=>c("pro_get_all_courses",void 0,void 0,"GET"),r=async()=>c("pro_get_all_quizes",void 0,void 0,"GET"),d=async()=>c("pro_get_all_groups",void 0,void 0,"GET"),g=async t=>c("pro_get_all_lessons_by_course",void 0,{courseId:t},"GET"),f=async(t,o)=>c("pro_get_all_topic_by_lesson",void 0,{courseId:t,lessonId:o},"GET");globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(t,o){return this.cache.has(t)?this.cache.get(t):(this.cache.set(t,o),o)}};const h=async t=>{t.setComponent("course-id",e=>{e.loading=!0});const{data:o,status:n}=await u();if(n==="error"){t.setComponent("course-id",e=>{t.util.isSelectComponent(e)&&(e.status=n,e.loading=!1,e.invalidMessage=o)}),console.error("Failed to fetch course");return}t.setComponent("course-id",e=>{t.util.isSelectComponent(e)&&(e.options=o,e.loading=!1,e.status=void 0)})},m=async t=>{t.setComponent("quiz-id",e=>{e.loading=!0});const{data:o,status:n}=await r();if(n==="error"){t.setComponent("quiz-id",e=>{t.util.isSelectComponent(e)&&(e.status=n,e.loading=!1,e.invalidMessage=o)}),console.error("Failed to fetch quiz");return}t.setComponent("quiz-id",e=>{t.util.isSelectComponent(e)&&(e.options=o,e.loading=!1,e.status=void 0)})},p=async t=>{t.setComponent("group-id",e=>{e.loading=!0});const{data:o,status:n}=await d();if(n==="error"){t.setComponent("group-id",e=>{t.util.isSelectComponent(e)&&(e.status=n,e.loading=!1,e.invalidMessage=o)}),console.error("Failed to fetch group");return}t.setComponent("group-id",e=>{t.util.isSelectComponent(e)&&(e.options=o,e.loading=!1,e.status=void 0)})},_=async t=>{var a;t.setComponent("lesson-id",s=>{s.loading=!0});const o=(a=t.getComponent("course-id"))==null?void 0:a.value,{data:n,status:e}=await g(o);if(e==="error"){t.setComponent("lesson-id",s=>{t.util.isSelectComponent(s)&&(s.status=e,s.loading=!1,s.invalidMessage=n)}),console.error("Failed to fetch lesson");return}t.setComponent("lesson-id",s=>{t.util.isSelectComponent(s)&&(s.options=n,s.loading=!1,s.status=void 0)})},y=async t=>{var s,l;t.setComponent("topic-id",i=>{i.loading=!0});const o=(s=t.getComponent("lesson-id"))==null?void 0:s.value,n=(l=t.getComponent("course-id"))==null?void 0:l.value,{data:e,status:a}=await f(n,o);if(a==="error"){t.setComponent("topic-id",i=>{t.util.isSelectComponent(i)&&(i.status=a,i.loading=!1,i.invalidMessage=e)}),console.error("Failed to fetch topic");return}t.setComponent("topic-id",i=>{t.util.isSelectComponent(i)&&(i.options=e,i.loading=!1,i.status=void 0)})};export{h as a,p as b,m as c,y as d,_ as f};
