(()=>{"use strict";const t=class{minField;maxField;constructor(t,n){this.minField=t,this.maxField=n,this.initEvents()}initEvents(){this.minField.on("change",this.validateFields.bind(this)),this.maxField.on("change",this.validateFields.bind(this))}validateFields(){let t=this.parseQuantity(this.minField),n=this.parseQuantity(this.maxField);t=Math.max(0,t),n=Math.max(0,n),n>0&&n<t&&(n=t),this.minField.val(t),this.maxField.val(n)}parseQuantity(t){const n=t.val();return""===n?0:Math.max(0,parseInt(n,10))}};var n;(n=jQuery)(document).ready((function(){const i=dokan_order_min_max||{};if(n("#dokan-product-list-table").on("click",".editline a",(function(){const a=n(this).closest(".row-actions").siblings(`.${i.constants.QUICK_EDIT_META_DATA}`).data("min-max-data");if(!a)return;const s=n(this).closest(".row-actions").siblings(`.${i.constants.QUICK_EDIT_META_DATA}`).data("product-id"),o=n(`#post-${s}.dokan-product-list-inline-edit-form .dokan-min-max-wrapper.dokan-min-max-vendor`),d=o.find(`.${i.constants.QUICK_EDIT_MINIMUM_QUANTITY}`),e=o.find(`.${i.constants.QUICK_EDIT_MAXIMUM_QUANTITY}`);d.val(a.min_quantity),e.val(a.max_quantity),new t(d,e)})),n("#bulk-product-action").on("click",(function(){if("edit"===n("#bulk-product-action-selector").val()){const a=n("#bulk-edit .dokan-min-max-wrapper.dokan-min-max-vendor"),s=a.find(`.${i.constants.BULK_EDIT_VENDOR_MINIMUM_QUANTITY}`),o=a.find(`.${i.constants.BULK_EDIT_VENDOR_MAXIMUM_QUANTITY}`);new t(s,o)}})),n(".dokan-product-edit-form").length>0){const a=n(`.${i.constants.VENDOR_SIMPLE_PRODUCT_METABOX_WRAPPER}`),s=a.find(`#${i.constants.SIMPLE_PRODUCT_MIN_QUANTITY}`),o=a.find(`#${i.constants.SIMPLE_PRODUCT_MAX_QUANTITY}`);new t(s,o)}n(".dokan-attribute-variation-options").length>0&&n(".dokan-product-variation-wrapper").on("click",".dokan-product-variation-itmes .variation-topbar-heading",(function(a){const s=n(a.currentTarget).parent().find(`.${i.constants.VENDOR_VARIATION_PRODUCT_METABOX_WRAPPER}`);"true"!==s.attr("data-variation-min-max-loaded")&&(s.attr("data-variation-min-max-loaded","true"),s.map(((a,s)=>{const o=n(s).find(`.${i.constants.VARIATION_PRODUCT_MIN_QUANTITY}`),d=n(s).find(`.${i.constants.VARIATION_PRODUCT_MAX_QUANTITY}`);new t(o,d)})))}))}))})();