(()=>{var e,a;e=jQuery,a={init:function(){e("body").on("click","a#dokan-become-wholesale-customer-btn",this.makeWholesaleCustomer),e("input[name=variation_id]").on("change",this.triggerVariationWholesale),e(".dokan-wholesale-options").on("change",".wholesaleCheckbox",this.toggleWholesaleWrapper),e("body").on("change",".dokan-variation-wholesale .wholesaleCheckbox",this.toggleWholesaleVariationWrapper)},triggerVariationWholesale:function(a){a.preventDefault();for(var o=e(".variations_form").data("product_variations"),i=e("input[name=variation_id]").val(),l=0;l<o.length;l++)if(o[l].variation_id==i){var s=o[l];if(DokanWholesale.check_permission)if("yes"==s._enable_wholesale){var t=DokanWholesale.variation_wholesale_string.wholesale_price+": <strong>"+DokanWholesale.currency_symbol+s._wholesale_price+"</strong> ("+DokanWholesale.variation_wholesale_string.minimum_quantity+": <strong>"+s._wholesale_quantity+"</strong>)";e(".single_variation").append('<div class="woocommerce-variation-wholesale">'+t+"</div>")}else e(".single_variation").find(".woocommerce-variation-wholesale").remove()}},makeWholesaleCustomer:function(a){a.preventDefault();var o=e(this),i=dokan.rest.root+dokan.rest.version+"/wholesale/register",l={id:o.data("id")};jQuery(".dokan-wholesale-migration-wrapper").block({message:null,overlayCSS:{background:"#fff url("+dokan.ajax_loader+") no-repeat center",opacity:.6}}),e.post(i,l,(function(e){"active"==e.wholesale_status?o.closest("li").html('<div class="woocommerce-message" style="margin-bottom:0px">'+dokan.wholesale.activeStatusMessage+"</div>"):o.closest("li").html('<div class="woocommerce-info" style="margin-bottom:0px">'+dokan.wholesale.deactiveStatusMessage+"</div>"),jQuery(".dokan-wholesale-migration-wrapper").unblock()}))},toggleWholesaleWrapper:function(){e(this).is(":checked")?e(".show_if_wholesale").slideDown("fast"):e(".show_if_wholesale").slideUp("fast")},toggleWholesaleVariationWrapper:function(){e(this).is(":checked")?e(this).closest(".dokan-variation-wholesale").find(".show_if_variation_wholesale").slideDown("fast"):e(this).closest(".dokan-variation-wholesale").find(".show_if_variation_wholesale").slideUp("fast")}},e(document).ready((function(){a.init()}))})();