!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);const{createElement:r,render:o,useState:s,useEffect:a,Fragment:i}=wp.element,{select:c,dispatch:l}=wp.data;var p=e=>{const[t,n]=s(!1),[o,l]=s(!1),[p,u]=s(""),d=c("vibebp").getToken();a(()=>{n(!0)},[e]);let m={};return o&&(m={opacity:"0.5","pointer-events":"none"}),r(i,null,t?r("div",{className:"popup_wrapper",onClick:e=>{e.preventDefault(),document.querySelector(".popup_wrapper")&&e.target===document.querySelector(".popup_wrapper")&&n(!1)}},r("div",{className:"popup_content"},r("span",{className:"vicon vicon-close",onClick:()=>{n(!1)}}),r("h3",null,window.vibe_course_credits.translations.buy_with_credits),r("p",{dangerouslySetInnerHTML:{__html:e.price.price}}),p.length?r("div",{className:"vbp_message error message"},p):"",r("div",{className:"popup-footer"},r("a",{className:"button is-primary",style:m,onClick:()=>{l(!0),fetch(window.wplms_course_data.api_url+"/student/wallet/assigncourse?post",{method:"post",body:JSON.stringify({id:e.id,token:d})}).then(e=>e.json()).then(t=>{if(t.status){n(!1);var r=new CustomEvent("reload_course_button",{detail:{course:e.id}});document.dispatchEvent(r)}else t.hasOwnProperty("message")&&t.message.length&&u(t.message);l(!1)})}},window.wplms_course_data.translations.yes),r("a",{className:"button is-primary",onClick:()=>{n(!1)}},window.wplms_course_data.translations.cancel)))):"")};const{createElement:u,render:d,useState:m,useEffect:f,Fragment:_}=wp.element,{select:y,dispatch:w}=wp.data;document.addEventListener("coursebuttonpricingclicked",e=>{if(console.log(e),null!==document.getElementById("wplms_popup")&&document.getElementById("wplms_popup").remove(),"#credits"==e.detail.price||"#credits"==e.detail.price.link){let t=document.createElement("div");t.setAttribute("id","wplms_popup"),document.body.appendChild(t),d(u(p,{id:e.detail.course,price:e.detail.price}),document.getElementById("wplms_popup"))}},!1)}]);