(self.webpackChunknisje=self.webpackChunknisje||[]).push([[877],{32704:function(e,a,t){"use strict";t.r(a);var n=t(63027),r=t(33804),s=t(33163),l=t(2006),d=t(97011),c=t(63842),i=t(12666);const m=(0,l.getOption)("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,c.useParams)(),l=parseInt((null==t?void 0:t.page)||"1",10),u=null==t?void 0:t.termId,{isLoading:p,data:_}=(0,i.useQuery)(["learndash",l,e,u],(()=>function(e=1,a="",t=""){let n=`${m}?_embed&page=${e}&per_page=99`;return(0,r.isEmpty)(a)||(n+=`&search=${a}`),(0,r.isEmpty)(t)||(n+=`&ld_course_category=${t}`),fetch(n).then((e=>e.json()))}(l,e,u)));return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(d.Header,{title:(0,s.__)("E-learning","nisje"),searchValue:e,onSearch:a,filters:h(null==t?void 0:t.termId,_)}),!p&&(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"},_.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))})))))}}}]);