(()=>{"use strict";var e={n:o=>{var a=o&&o.__esModule?()=>o.default:()=>o;return e.d(a,{a}),a},d:(o,a)=>{for(var i in a)e.o(a,i)&&!e.o(o,i)&&Object.defineProperty(o,i,{enumerable:!0,get:a[i]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o)};const o=window.wp.apiFetch;var a,i,t=e.n(o);a=jQuery,i={init:function(){a("body").on("click","a#dokan-become-wholesale-customer-btn",this.makeWholesaleCustomer),a("input[name=variation_id]").on("change",this.triggerVariationWholesale),a(".dokan-wholesale-options").on("change",".wholesaleCheckbox",this.toggleWholesaleWrapper),a("body").on("change",".dokan-variation-wholesale .wholesaleCheckbox",this.toggleWholesaleVariationWrapper)},triggerVariationWholesale:function(e){e.preventDefault();const o=a(".variations_form").data("product_variations"),i=a("input[name=variation_id]").val();setTimeout(()=>{for(let t=0;t<o.length;t++)if(o[t].variation_id==i){const i=o[t];if(DokanWholesale.check_permission)if("yes"==i._enable_wholesale){var e=DokanWholesale.variation_wholesale_string.wholesale_price+": <strong>"+DokanWholesale.currency_symbol+i._wholesale_price+"</strong> ("+DokanWholesale.variation_wholesale_string.minimum_quantity+": <strong>"+i._wholesale_quantity+"</strong>)";a(".single_variation").append('<div class="woocommerce-variation-wholesale">'+e+"</div>")}else a(".single_variation").find(".woocommerce-variation-wholesale").remove()}},400)},makeWholesaleCustomer:function(e){e.preventDefault();var o=a(this);jQuery(".dokan-wholesale-migration-wrapper").block({message:null,overlayCSS:{background:"#fff url("+dokan.ajax_loader+") no-repeat center",opacity:.6}}),t()({path:"/dokan/v1/wholesale/register",method:"POST"}).then(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(){a(this).is(":checked")?a(".show_if_wholesale").slideDown("fast"):a(".show_if_wholesale").slideUp("fast")},toggleWholesaleVariationWrapper:function(){a(this).is(":checked")?a(this).closest(".dokan-variation-wholesale").find(".show_if_variation_wholesale").slideDown("fast"):a(this).closest(".dokan-variation-wholesale").find(".show_if_variation_wholesale").slideUp("fast")}},a(document).ready(function(){i.init()})})();