jQuery((function(e){var n,t=e("#form_singleProduct"),a=e("#js_cover_paypal"),r=!1,o=e("#js_cover_paypal-loader");function i(){o.show(),setTimeout((function(){var i,s,c=((s=(i=t).serialize())||(s=i.find("input[name],select[name],textarea[name]").serialize()),s);if(!function(n){var t=n.split("&"),a=!1,o=[],i=[];return r||(r={}),e.each(t,(function(e,n){var t=n.split("=");void 0!==i[t[0]]?i[t[0]]=i[t[0]]+1:i[t[0]]=1;var s=t[0]+"-"+i[t[0]];o[s]=t[1],void 0!==r[s]&&r[s]===t[1]||(a=!0)})),r=o,a}(c))return!1;e.ajax({url:alidAjax.ajaxurl,type:"POST",dataType:"json",async:!0,data:{action:"slv_pay_set_express_order",args:c},success:function(t){if(t.hasOwnProperty("purchase_units")){var r=t.purchase_units;n&&n.close(),n=paypal.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"pay",tagline:!1},createOrder:function(e,n){return n.order.create({purchase_units:r})},onApprove:function(n,t){var o;a.show(),n.reference_id=r[0].reference_id,o=n,e.ajax({url:alidAjax.ajaxurl,type:"POST",dataType:"json",async:!0,data:{action:"slv_pay_complete_order",type:"paypal",args:o},success:function(e){e.hasOwnProperty("error")?(window.Notify(e.error,"danger"),a.hide()):e.hasOwnProperty("redirect")&&window.location.replace(e.redirect)}})}}),n.render("#js_paypal-button-container"),setTimeout((function(){o.hide()}),500)}else window.Notify(t.error,"danger")}})}),1500)}function s(){if(!1===function(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],a={line:"js-item-sku",variation:'[name="sku-meta-set[]"]'},r=!1,o=[];return t.find(a.variation).each((function(){0===e(this).val().length&&!1!==n?(e(this).closest(a.line).addClass("is-empty"),r=!0):(e(this).closest(a.line).removeClass("is-empty"),o.push(e(this).val()))})),!r&&{foo:o}}())return!1;i()}var c=0,u=document.getElementById("js_paypal-button-container");if(null!=u){var l=function(){1===c&&(s(),c=2)},d=function(){setTimeout((function(){c=1,null!=u&&u.offsetTop<e(window).height()&&l()}),400)};e(window).on("scroll",(function(){l()})),e("body").on("changeSku",(function(){c?2===c&&s():d()})),e(document).find(".js-product-sku").length||d()}}));