(()=>{const{createElement:e,render:t,useState:s,useEffect:n,Fragment:a,useRef:d}=wp.element,{select:l,dispatch:i}=wp.data,r=t=>{var r=d(null);const[o,_]=s(!0),[w,u]=s([]),[c,m]=s("");return n((()=>{fetch(`${window.dashboard_news.api}/get_news/?user_id${t.settings.user_id}`,{method:"post",body:JSON.stringify({user_id:t.settings.user_id,token:l("vibebp").getToken(),number:window.dashboard_news.settings.number})}).then((e=>e.ok?e.json():{status:0,message:window.wplms_course_data.translations.error_loading_data})).then((e=>{e.status&&(e.data&&u(e.data),e.extras&&m(e.extras)),_(!1),document.dispatchEvent(new CustomEvent("vibebp_widget_loaded",{detail:{props:t}}))})).catch((e=>{_(!1),console.error("Uh oh, an error!",e),i("vibebp").addNotification({text:window.wplms_course_data.translations.error_loading_data})}))}),[]),n((()=>{if(!o&&w.length){var e=r.current;new Flickity(e,{cellAlign:"left",contain:!0})}}),[w,o]),e("div",{className:"wplms_dashboard_news_widget"},e("h3",{class:"widget_title"},t.settings.title),o?e("div",{class:"widget_loader"},e("div",null),e("div",null),e("div",null),e("div",null)):e(a,null,c.length?e(a,null,e("div",{dangerouslySetInnerHTML:{__html:c}})):"",w.length?e(a,null,e("ul",{className:"wplms_news_slides",ref:r},w.map((t=>e("div",{className:"wplms_news_slide",dangerouslySetInnerHTML:{__html:t}}))))):e("div",{className:"vbp_message"},window.dashboard_news.translations.not_found)))};document.addEventListener("wplms_dash_news",(s=>{s.target.removeEventListener(s.type,arguments.callee),document.querySelectorAll(".wplms_dash_news").forEach((n=>{t(e(r,{settings:s.detail.widget.options}),n)}))}))})();