!function(e){var t={};function r(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(n,s,function(t){return e[t]}.bind(null,s));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t);r(1);const{createElement:n,render:s,useState:o,useEffect:i,Fragment:a}=wp.element,{select:d,dispatch:l}=wp.data,u=e=>{const[t,r]=o(!0),[s,u]=o();i(()=>{fetch(`${window.course_progress.api}/course_progress?user_id=${e.settings.user_id}&finished=${e.settings.finished}`,{method:"post",body:JSON.stringify({user_id:e.settings.user_id,number:e.settings.number,finished:e.settings.finished,token:d("vibebp").getToken()})}).then(e=>e.ok?e.json():{status:0,message:window.wplms_course_data.translations.error_loading_data}).then(e=>{e.status&&u(e.data),r(!1)}).catch(t=>{r(!1),console.error("Uh oh, an error!",t),l("vibebp").addNotification({text:window.wplms_course_data.translations.error_loading_data}),document.dispatchEvent(new CustomEvent("vibebp_widget_loaded",{detail:{props:e}}))})},[]);return n("div",{className:"course_progress"},t?n("div",null,n("div",{class:"widget_loader"},n("div",null),n("div",null),n("div",null),n("div",null))):n(a,null,n("h3",{class:"widget_title"},e.settings.title),n("ul",{class:"dash-courses-progress"},s&&Array.isArray(s)?s.map(e=>{let t={width:parseInt(e.percentage)+"%",backgroundColor:e.background};return n("li",null,n("label",null,n("a",{onClick:()=>{return t=e.course_id,l("vibebp").setAction("course"),l("vibebp").setComponent("course"),void l("vibebp").setId(parseInt(t));var t},target:"_blank",dangerouslySetInnerHTML:{__html:e.title}}),n("span",null,e.percentage,"%")),n("div",{className:"progress course_progress","data-course":e.course_id},n("div",{className:"bar animate stretchRight load",style:t})))}):n("div",{className:"vbp_message"},window.course_progress.translations.no_courses))))};document.addEventListener("wplms_course_progress",e=>{e.detail.hasOwnProperty("widget")&&e.detail.widget&&document.querySelector("."+e.detail.widget.id)&&s(n(u,{settings:e.detail.widget.options}),document.querySelector("."+e.detail.widget.id))})},function(e,t,r){}]);