"use strict";(self.webpackChunknisje=self.webpackChunknisje||[]).push([[877],{2704:function(e,a,t){t.r(a);var n=t(9307),r=t(2819),s=t(5736),l=t(1695),d=t(1027),c=t(5638),i=t(5231);const m=(0,t(7626).getConstant)("learndashEndpoint");function o(e,a){const t=[];return(0,r.filter)(e,(e=>!(0,r.isEmpty)(e))).forEach((e=>{Array.isArray(e)&&e.forEach((e=>{e.taxonomy&&a===e.taxonomy&&t.push(e)}))})),t}function h(e,a){const t=[{title:(0,s.__)("All","nisje"),href:"/learndash",isActive:!e}];let n=[];return a&&0!==Object.keys(a).length?(Object.keys(a).forEach((e=>{const t=o(a[e]._embedded&&a[e]._embedded["wp:term"],"ld_course_category");(0,r.isEmpty)(t)||(n=[...n,...t])})),n=(0,r.uniqBy)(n,"id"),n&&n.forEach((a=>{t.push({title:a.name,href:`/learndash/term/${a.id}`,isActive:parseInt(e,10)===a.id})})),t):t}a.default=function(){if(!m)return(0,n.createElement)("div",{className:"learndash-error"},(0,n.createElement)("h2",null,(0,s.__)("Error","nisje")),(0,n.createElement)("p",null,(0,s.__)("Please set an external courses endpoint in the Learndash settings panel.","nisje")));const[e,a]=(0,c.useSearchQuery)("/learndash/"),t=(0,d.useParams)(),u=parseInt((null==t?void 0:t.page)||"1",10),p=null==t?void 0:t.termId,{isLoading:_,data:E}=(0,i.useQuery)(["learndash",u,e,p],(()=>function(){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",t=`${m}?_embed&page=${arguments.length>0&&void 0!==arguments[0]?arguments[0]:1}&per_page=99`;return(0,r.isEmpty)(e)||(t+=`&search=${e}`),(0,r.isEmpty)(a)||(t+=`&ld_course_category=${a}`),fetch(t).then((e=>e.json()))}(u,e,p)));return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(l.Header,{title:(0,s.__)("E-learning","nisje"),searchValue:e,onSearch:a,filters:h(null==t?void 0:t.termId,E)}),!_&&(0,n.createElement)("div",{className:"learndash-table"},(0,n.createElement)("div",{className:"learndash-table-thead"},(0,n.createElement)("span",{className:"learndash-table-td"},(0,s.__)("Title","nisje")),(0,n.createElement)("span",{className:"learndash-table-td"},(0,s.__)("Categories","nisje")),(0,n.createElement)("span",{className:"learndash-table-td learndash-table-td-long"},(0,s.__)("Description","nisje"))),(0,n.createElement)("div",{className:"learndash-table-tbody"},E.map((e=>{const{type:a}=e;if("sfwd-courses"!==a)return null;const{id:t,link:r,_embedded:s}=e;let{title:l,excerpt:d}=e,c=[],i=[];return s["wp:term"]&&(c=s["wp:term"],i=o(c,"ld_course_category")),l=l&&l.rendered||"",d=d&&d.rendered||"",d||(d=e.meta&&e.meta.teft_cards_excerpt||""),(0,n.createElement)("a",{className:"learndash-table-tr",href:r,key:t,target:"_blank",rel:"noopener noreferrer"},(0,n.createElement)("span",{className:"learndash-table-td"},l),(0,n.createElement)("span",{className:"learndash-table-td"},i.map(((e,a)=>(0,n.createElement)("div",{key:a},e.name)))),(0,n.createElement)("span",{className:"learndash-table-td learndash-table-td-description learndash-table-td-long"},d))})))))}}}]);