var v=Object.defineProperty;var _=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var w=(l,i,e)=>i in l?v(l,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[i]=e,o=(l,i)=>{for(var e in i||(i={}))z.call(i,e)&&w(l,e,i[e]);if(_)for(var e of _(i))I.call(i,e)&&w(l,e,i[e]);return l};import{r as k,j as t,L as q}from"./main-406.js";import{b as g,c as s,_ as u,o as j,N as F}from"./bi.394.85.js";const R=(l,i,e,d,n,a)=>{const r=o({},i),{name:x}=l.target;l.target.value!==""?r[x]=l.target.value:delete r[x],r[l.target.name]=l.target.value,e(o({},r))},Q=(l,i,e,d)=>{e(!0),l.courseId,g({},"mslms_fetch_all_course").then(n=>{if(n&&n.success){const a=o({},l);a.default||(a.default={}),n.data&&(a.default.allCourse=n.data),i(o({},a)),e(!1),s.success(u("Course fetched successfully","bit-integrations"));return}e(!1),s.error(u("Course fetch failed. please try again","bit-integrations"))}).catch(()=>e(!1))},S=(l,i,e,d)=>{e(!0);const n={courseId:l.courseId};g(n,"msLms_fetch_all_lesson").then(a=>{if(a&&a.success){const r=o({},l);r.default||(r.default={}),a.data&&(r.default.allLesson=a.data),i(o({},r)),e(!1),s.success(u("Lesson fetched successfully","bit-integrations"));return}e(!1),s.error(u("Lesson fetch failed. please try again","bit-integrations"))}).catch(()=>e(!1))},f=(l,i,e,d)=>{e(!0);const n={courseId:l.courseId};g(n,"msLms_fetch_all_quiz").then(a=>{if(a&&a.success){const r=o({},l);r.default||(r.default={}),a.data&&(r.default.allQuiz=a.data),i(o({},r)),e(!1),s.success(u("Quiz fetched successfully","bit-integrations"));return}e(!1),s.error(u("Quiz fetch failed. please try again","bit-integrations"))}).catch(()=>e(!1))};function H({formFields:l,handleInput:i,msLmsConf:e,setMsLmsConf:d,isLoading:n,setIsLoading:a,setSnackbar:r,allIntegURL:x,isInfo:D,edit:E}){var y,A,N;k.useEffect(()=>{["1","2","3","4","5"].includes(e.mainAction)&&Q(e,d,a)},[e.mainAction]);const p=(c,b)=>{const h=o({},e);c!==""?(h[b]=c,(e.mainAction==="2"||e.mainAction==="5")&&S(h,d,a),e.mainAction==="3"&&f(h,d,a)):delete h[b],d(o({},h))};return t.jsxs(t.Fragment,{children:[t.jsx("br",{}),t.jsx("b",{className:"wdt-200 d-in-b",children:u("Actions:","bit-integrations")}),t.jsxs("select",{onChange:i,name:"mainAction",value:e.mainAction,className:"btcd-paper-inp w-5",children:[t.jsx("option",{value:"",children:u("Select Actions","bit-integrations")}),e.allActions&&e.allActions.map(({key:c,label:b})=>t.jsx("option",{value:c,children:b},c))]}),t.jsx("br",{}),t.jsx("br",{}),["1","2","3","4","5"].includes(e.mainAction)&&t.jsxs("div",{className:"flx mt-4",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:u("Select a Course: ","bit-integrations")}),t.jsx(j,{className:"w-5",singleSelect:!0,defaultValue:e==null?void 0:e.courseId,options:((y=e==null?void 0:e.default)==null?void 0:y.allCourse)&&e.default.allCourse.map(c=>({label:c.post_title,value:c.ID.toString()})),onChange:c=>p(c,"courseId")}),t.jsx("button",{onClick:()=>fetchAllCourse(e,d,a,r),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${u("Fetch course list","bit-integrations")}'`},type:"button",disabled:n,children:"↻"})]}),(e.mainAction==="2"||e.mainAction==="5")&&(e==null?void 0:e.courseId)&&t.jsxs("div",{className:"flx mt-4",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:u("Select lesson: ","bit-integrations")}),t.jsx(j,{className:"w-5",singleSelect:!0,defaultValue:e==null?void 0:e.lessonId,options:((A=e==null?void 0:e.default)==null?void 0:A.allLesson)&&e.default.allLesson.map(c=>({label:c.post_title,value:c.ID.toString()})),onChange:c=>p(c,"lessonId")}),t.jsx("button",{onClick:()=>S(e,d,a),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${u("Fetch lesson list","bit-integrations")}'`},type:"button",disabled:n,children:"↻"})]}),e.mainAction==="3"&&(e==null?void 0:e.courseId)&&t.jsxs("div",{className:"flx mt-4",children:[t.jsx("b",{className:"wdt-200 d-in-b",children:u("Select quiz: ","bit-integrations")}),t.jsx(j,{className:"w-5",singleSelect:!0,defaultValue:e==null?void 0:e.quizId,options:((N=e==null?void 0:e.default)==null?void 0:N.allQuiz)&&e.default.allQuiz.map(c=>({label:c.post_title,value:c.ID.toString()})),onChange:c=>p(c,"quizId")}),t.jsx("button",{onClick:()=>f(e,d,a),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${u("Fetch quiz list","bit-integrations")}'`},type:"button",disabled:n,children:"↻"})]}),t.jsx("br",{}),t.jsx("br",{}),n&&t.jsx(q,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),t.jsx(F,{note:"This integration will only work for logged-in users."})]})}export{H as M,R as h};
