'+imagifyPricingModal.labels.errorPriceAPI+"
"),e.$modal.find(".imagify-modal-loader").fadeOut(300),void e.$modal.removeClass("imagify-modal-loading");if(c.imagify_discount_datas=i,i.is_active){if(i.applies_to instanceof Array){u=[];for(var A=[],B=0;B2)return!0;b===l.mo.index&&(f=a(".imagify-pre-checkout-offers .imagify-offer-monthly"),l.mo.selected&&(g=" imagify-offer-selected",f.addClass("imagify-offer-selected").find(".imagify-checkbox").prop("checked",!0)),e.populateOffer(f,c,"monthly")),d=a(p).clone(),d=e.populateOffer(d,c,"monthly",g),z+=d[0].outerHTML}),0===j.ot.length?(a(".imagify-pre-checkout-offers .imagify-offer-onetime").remove(),a(".imagify-tabs").remove(),a(".imagify-pricing-tab-onetime").remove()):a.each(j.ot,function(b,c){var d,f,g="";b===l.ot.index&&(f=a(".imagify-pre-checkout-offers .imagify-offer-onetime"),l.ot.selected&&(g=" imagify-offer-selected",f.addClass("imagify-offer-selected").find(".imagify-checkbox").prop("checked",!0)),e.populateOffer(f,c,"onetime")),d=a(o).clone(),d=e.populateOffer(d,c,"onetime",g),y+=d[0].outerHTML}),i){var C=e.getPromoAppliesTo(i);(C.includes(l.mo.plan_label)||C.includes(l.ot.plan_label)||"all"===C[0])&&a("#imagify-coupon-code").val(i.label),i.is_active&&e.checkCoupon()}m.parent().find(".imagify-offer-line")&&m.parent().find(".imagify-offer-line").remove(),m.before(z),n.parent().find(".imagify-offer-line")&&n.parent().find(".imagify-offer-line").remove(),n.before(y),e.$modal.find(".imagify-modal-loader").fadeOut(300),e.$modal.removeClass("imagify-modal-loading")}})}),e.populatePayBtn()})},getSuggestedOffers:function(b,c,d){var e,f,g=c.total+c.month,h={quota:0},i={mo:!1,ot:!1};if(0>b.ot.length)var j=b.ot[b.ot.length-1].id,k=b.ot[b.ot.length-1].label;if(0>b.ot.length)var l=b.mo[b.mo.length-1].id,m=b.mo[b.mo.length-1].label;return a.each(b.mo,function(a,b){return 0>b.quota&&(f={index:a,selected:1,plan_id:b.id,plan_label:b.label}),b.quota>h.quota&&(h={index:a,selected:1,quota:b.quota,plan_id:b.id,plan_label:b.label}),0===b.monthly_cost&&0===b.annual_cost||(0>=b.quota&&c.month>b.quota||c.total>b.quota||(!(0<=b.quota&&c.monthb.quota)&&(e=b,i.mo={index:a,selected:d>c.month&&d>c.total?0:1,plan_id:b.id,plan_label:b.label}),!0)))}),!1===i.mo&&(i.mo=void 0!==f?f:h),g-=b.mo[i.mo.index].quota,0===b.ot.length?i:g<=0?(a.each(b.ot,function(a,b){return b.quota=3?c.closest(".imagify-coupon-input").addClass("imagify-canbe-validate"):c.closest(".imagify-coupon-input").removeClass("imagify-canbe-validate"))}),a("#imagify-coupon-validate").on("click.imagify",function(){e.checkCoupon(),a(this).closest(".imagify-canbe-validate").removeClass("imagify-canbe-validate")}),e.$anotherBtn.on("click.imagify",function(b){var c=a(this).data("imagify-choose"),d="imagify-pricing-tab-"+("plan"===c?"monthly":"onetime");b.preventDefault(),e.switchToView(e.$plansView,{tab:d})}),e.$modal.on("click.imagify",".imagify-payment-btn-select-plan",function(b){var d=a(this),f=d.closest(".imagify-offer-line"),g=d.data("offer"),h=d.attr("data-offer"),i="imagify-pricing-tab-monthly"!==d.closest(".imagify-tab-content").attr("id"),j=i?e.$preView.find(".imagify-offer-onetime"):e.$preView.find(".imagify-offer-monthly"),k=i?null:d.closest(".imagify-pricing-table").hasClass("imagify-month-selected")?"monthly":"yearly",l=i?e.getHtmlPrice(g[Object.keys(g)[0]].price):e.getHtmlPrice(g[Object.keys(g)[0]].prices,k),m=i?"":''+f.find(".imagify-price-by").text()+"",n=f.find(".imagify-price-discount").html(),o=f.find(".imagify-approx-nb").text(),p=f.find(".imagify-offer-size").text(),q=a("#imagify-coupon-code");if(b.preventDefault(),e.switchToView(e.$preView),j.find(".imagify-number-block").html(l+m),n?(j.find(".imagify-price-discount").length<=0&&j.find(".imagify-col-price").prepend(''),j.find(".imagify-price-discount").html(n),j.find(".imagify-price-discount").show()):j.find(".imagify-price-discount").hide(),j.find(".imagify-approx-nb").text(o),j.find(".imagify-offer-size").text(p),j.attr("data-offer",h),i||(j.find(".imagify-price-add-data").text(f.find(".imagify-price-add-data").text()),"monthly"===k?j.find("#imagify-subscription-monthly").trigger("click.imagify"):j.find("#imagify-subscription-yearly").trigger("click.imagify"),j.find(".imagify-inline-options").find("input:radio:checked").trigger("change.imagify")),q=a("#imagify-coupon-code"),q.val(""),c.imagify_discount_datas){var r=e.getPromoAppliesTo(c.imagify_discount_datas);(r.includes(g[Object.keys(g)[0]].label)||"all"===r[0])&&q.val(c.imagify_discount_datas.label)}e.checkCoupon(),e.populatePayBtn()}),a("#imagify-modal-checkout-btn").on("click.imagify",function(b){var c,d,f;b.preventDefault(),a(this).hasClass("imagify-button-disabled")||(c=a(".imagify-offer-monthly"),d=a(".imagify-offer-onetime"),f={},c.hasClass("imagify-offer-selected")&&(f.monthly=JSON.parse(c.attr("data-offer"))),d.hasClass("imagify-offer-selected")&&(f.onetime=JSON.parse(d.attr("data-offer"))),imagifyPricingModal.userDataCache&&a.post(ajaxurl,{action:imagifyPricingModal.userDataCache.deleteAction,_wpnonce:imagifyPricingModal.userDataCache.deleteNonce}),e.switchToView(e.$paymentView),f.period=e.getPeriod(),e.iframeSetSrc(f))}),a(".imagify-back-to-plans").on("click.imagify",function(b){var c=a(this),d=c.closest(".imagify-cart-item").hasClass("imagify-cart-item-onetime");b.preventDefault(),d?a(".imagify-offer-onetime").find(".imagify-choose-another-plan").trigger("click.imagify"):a(".imagify-offer-monthly").find(".imagify-choose-another-plan").trigger("click.imagify")}),c.addEventListener("message",e.checkPluginMessage,!0))}(jQuery,document,window);