(self.webpackChunknisje=self.webpackChunknisje||[]).push([[877],{32704:function(e,a,t){"use strict";t.r(a);var r=t(63027),n=t(33804),l=t(33163),s=t(2006),d=t(97011),c=t(63842),i=t(12666);const m=(0,s.getOption)("learndashEndpoint");function o(e,a){const t=[];return(0,n.filter)(e,(e=>!(0,n.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,l.__)("All"),href:"/learndash",isActive:!e}];let r=[];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,n.isEmpty)(t)||(r=[...r,...t])})),r=(0,n.uniqBy)(r,"id"),r&&r.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,r.createElement)("div",{className:"learndash-error"},(0,r.createElement)("h2",null,(0,l.__)("Error")),(0,r.createElement)("p",null,(0,l.__)("Please set an external courses endpoint in the Learndash settings panel.")));const[e,a]=(0,c.useSearchQuery)("/learndash/"),t=(0,c.useParams)(),s=parseInt((null==t?void 0:t.page)||"1",10),u=null==t?void 0:t.termId,{isLoading:p,data:_}=(0,i.useQuery)(["learndash",s,e,u],(()=>function(e=1,a="",t=""){let r=`${m}?_embed&page=${e}&per_page=99`;return(0,n.isEmpty)(a)||(r+=`&search=${a}`),(0,n.isEmpty)(t)||(r+=`&ld_course_category=${t}`),fetch(r).then((e=>e.json()))}(s,e,u)));return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(d.Header,{title:(0,l.__)("E-learning"),searchValue:e,onSearch:a,filters:h(null==t?void 0:t.termId,_)}),!p&&(0,r.createElement)("div",{className:"learndash-table"},(0,r.createElement)("div",{className:"learndash-table-thead"},(0,r.createElement)("span",{className:"learndash-table-td"},(0,l.__)("Title")),(0,r.createElement)("span",{className:"learndash-table-td"},(0,l.__)("Categories")),(0,r.createElement)("span",{className:"learndash-table-td learndash-table-td-long"},(0,l.__)("Description"))),(0,r.createElement)("div",{className:"learndash-table-tbody"},_.map((e=>{const{type:a}=e;if("sfwd-courses"!==a)return null;const{id:t,link:n,_embedded:l}=e;let{title:s,excerpt:d}=e,c=[],i=[];return l["wp:term"]&&(c=l["wp:term"],i=o(c,"ld_course_category")),s=s&&s.rendered||"",d=d&&d.rendered||"",d||(d=e.meta&&e.meta.teft_cards_excerpt||""),(0,r.createElement)("a",{className:"learndash-table-tr",href:n,key:t,target:"_blank",rel:"noopener noreferrer"},(0,r.createElement)("span",{className:"learndash-table-td"},s),(0,r.createElement)("span",{className:"learndash-table-td"},i.map(((e,a)=>(0,r.createElement)("div",{key:a},e.name)))),(0,r.createElement)("span",{className:"learndash-table-td learndash-table-td-description learndash-table-td-long"},d))})))))}}}]);