!function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||o(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=o(t))||e&&t&&"number"==typeof t.length){a&&(t=a);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,s=!0,c=!1;return{s:function(){a=a.call(t)},n:function(){var t=a.next();return s=t.done,t},e:function(t){c=!0,n=t},f:function(){try{s||null==a.return||a.return()}finally{if(c)throw n}}}}function i(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var i,o,r,n,s=[],c=!0,l=!1;try{if(r=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;c=!1}else for(;!(c=(i=r.call(a)).done)&&(s.push(i.value),s.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=a.return&&(n=a.return(),Object(n)!==n))return}finally{if(l)throw o}}return s}}(t,e)||o(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){if(t){if("string"==typeof t)return r(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,i=new Array(e);a0,this.$view_cart_link=this.$is_block?this.$wrapper.find(".wvs-has-block-enabled"):this.$wrapper.find(".added_to_cart"),this.$price=this.$wrapper.find(".price:first"),this.$firstUL=this.$element.find(".variations ul:first"),this.is_cart_button_available=this.$cart_button.length>0,this.$price_html=this.$price.clone().html(),this.$attributeFields=this.$element.find(".variations select"),this.$attributeSwatchesFields=this.$element.find("ul.variable-items-wrapper"),this.$resetVariations=this.$element.find(".wvs_archive_reset_variations");var s=!1;if(r(woo_variation_swatches_pro_options.enable_single_variation_preview)&&r(woo_variation_swatches_pro_options.enable_single_variation_preview_archive)){var c=this.$firstUL.data("preview_attribute_name")?this.$firstUL.data("preview_attribute_name"):this.$attributeFields.first().data("attribute_name");s=".variations select[data-attribute_name='".concat(c,"']")}this.$element.off(".wc-variation-form"),this.$element.addClass("wvs-pro-loaded"),this.$element.on("click.wc-variation-form",".wvs_archive_reset_variations > a",this.onReset),this.$element.on("change.wc-variation-form",".variations select",this.onChange),this.$element.on("check_variations.wc-variation-form",this.onCheckVariations),this.$element.on("update_variation_values.wc-variation-form",this.onUpdateAttributes),this.$element.on("found_variation.wc-variation-form",this.onFoundVariation),this.$element.on("reset_data.wc-variation-form",this.onResetDisplayedVariation),this.$element.on("woocommerce_variation_has_changed.wc-variation-form",this.onVariationChanged),this.is_cart_button_available&&this.$cart_button.on("click.wc-variation-form",this.onAjaxAddToCart),this.haveSingleVariationPreview()&&(this.$element.on("click.wc-variation-form",".wvs_archive_reset_variations > a",this.onResetDisplayedVariation),this.$element.on("change.wc-variation-form",s,this.onPreviewChange)),woo_variation_swatches_pro_options.enable_catalog_mode&&"expand"===woo_variation_swatches_pro_options.catalog_mode_behaviour&&this.$element.on("click.wc-variation-form",".woo-variation-swatches-variable-item-more",this.onExpandVariableItems),!woo_variation_swatches_pro_options.enable_catalog_mode&&woo_variation_swatches_pro_options.enable_archive_display_limit&&this.$element.on("click.wc-variation-form",".woo-variation-swatches-variable-item-more",this.onExpandVariableItems),this.$element.on("woo_variation_swatches_pro_loaded.wc-variation-form",this.onInit),this.$element.trigger("woo_variation_swatches_pro_loaded",this)}var h,d,u;return h=t,d=[{key:"start",value:function(){var t=this;setTimeout((function(){t.$element.trigger("check_variations"),t.$element.trigger("woo_variation_swatches_pro",t),t.swatchInit()}),100)}},{key:"haveSingleVariationPreview",value:function(){return!woo_variation_swatches_pro_options.enable_catalog_mode&&woo_variation_swatches_pro_options.enable_single_variation_preview&&woo_variation_swatches_pro_options.enable_single_variation_preview_archive}},{key:"AjaxAddToCart",value:function(t){var e=this,a=n(t),i=a.data("quantity"),r=this.getQueryArgs(a.attr("href")),c=this.getAttributes(r),l=r.variation_id,h=s(s({},c),{},{quantity:i,product_id:l,_wpnonce:woo_variation_swatches_pro_params._wpnonce});a.removeClass("added"),a.addClass("loading"),n(document.body).trigger("adding_to_cart",[a,h]),n.ajax({dataType:"json",global:!1,url:woo_variation_swatches_pro_params.wc_ajax_url.toString().replace("%%endpoint%%","woo_add_to_cart_variation"),method:"POST",data:h}).fail((function(t,e){console.error("product cart data not available.",h,e)})).done((function(t){t&&(t.error&&t.product_url?o.location=t.product_url:"yes"!==woo_variation_swatches_pro_options.cart_redirect_after_add?(n(document.body).trigger("added_to_cart",[t.fragments,t.cart_hash,a]),e.$is_block&&(e.$view_cart_link.removeClass("wvs-hide-view-cart-link"),a.removeClass("loading"),a.addClass("added"))):o.location=woo_variation_swatches_pro_options.cart_url)})).always((function(){}))}},{key:"getAttributes",value:function(t){var e={};for(var a in t)"attribute_"===a.substring(0,10)&&(e[a]=t[a]);return e}},{key:"expandVariableItems",value:function(t){n(t.currentTarget).parent().removeClass("enabled-display-limit-mode enabled-catalog-display-limit-mode enabled-archive-display-limit-mode"),n(t.currentTarget).remove()}},{key:"init",value:function(){var t=this,e=this.threshold_max,a=this.total_children;this.defaultImage(),this.defaultCartButton(),this.isAjaxVariation()&&e>=a?(this.xhr&&this.xhr.abort(),woo_variation_swatches_pro_options.enable_archive_preloader&&this.$element.block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),this.xhr=n.ajax({global:!1,cache:!0,url:woo_variation_swatches_pro_params.wc_ajax_url.toString().replace("%%endpoint%%","woo_get_variations"),method:"POST",data:{product_id:this.product_id,is_archive:!0,_wpnonce:woo_variation_swatches_pro_params._wpnonce}}),this.xhr.fail((function(e,a){console.error("product archive variations not available on: ".concat(t.product_id,"."),a)})),this.xhr.done((function(e){e&&(t.$element.data("product_variations",e),t.product_variations=t.$element.data("product_variations"),t.is_ajax_variation=!1,t.start())})),this.xhr.always((function(){woo_variation_swatches_pro_options.enable_archive_preloader&&t.$element.unblock()}))):this.start()}},{key:"initFetch",value:function(){var t=this,e=this.threshold_max,a=this.total_children;this.defaultImage(),this.defaultCartButton(),this.isAjaxVariation()&&e>=a?(woo_variation_swatches_pro_options.enable_archive_preloader&&this.$element.block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),wp.apiFetch({path:"woo-variation-swatches/v1/archive-product/".concat(this.product_id)}).then((function(e){t.$element.data("product_variations",e),t.product_variations=t.$element.data("product_variations"),t.is_ajax_variation=!1,t.start()})).catch((function(e){console.error("archive product variations fetching failed: ".concat(t.product_id,"."),e)})).finally((function(){woo_variation_swatches_pro_options.enable_archive_preloader&&t.$element.unblock()}))):this.start()}},{key:"fetchPreviewChange",value:function(t){var e=this,a=n(t).data("attribute_name")||n(t).attr("name"),i=n(t).val()||"",o={},r=this.getChosenAttributes();i&&r.count&&r.count>r.chosenCount&&(o.product_id=this.product_id,o[a]=i,wp.apiFetch({path:wp.url.addQueryArgs("/woo-variation-swatches/v1/archive-product-preview",o)}).then((function(t){e.updatePreviewImage(t)})).catch((function(t){console.error("archive product variation preview fetching failed: ".concat(e.product_id,"."),t)})).finally((function(){})))}},{key:"previewChange",value:function(t){var e=this,a=n(t).data("attribute_name")||n(t).attr("name"),i=n(t).val()||"",o={},r=this.getChosenAttributes();i&&r.count&&r.count>r.chosenCount&&(o.product_id=this.product_id,o[a]=i,o._wpnonce=woo_variation_swatches_pro_params._wpnonce,this.previewXhr=n.ajax({global:!1,url:woo_variation_swatches_pro_params.wc_ajax_url.toString().replace("%%endpoint%%","woo_get_preview_variation"),method:"POST",data:o}),this.previewXhr.fail((function(t,i){console.error("archive product preview not available on ".concat(e.product_id,"."),a,i)})),this.previewXhr.done((function(t){e.updatePreviewImage(t)})))}},{key:"getAvailableVariations",value:function(){return this.$element.data("product_variations")||[]}},{key:"toggleResetLink",value:function(t){t?this.$resetVariations.removeClass("show hide").addClass("show"):this.$resetVariations.removeClass("show hide").addClass("hide")}},{key:"reset",value:function(){this.$attributeFields.val("").trigger("change"),this.$element.trigger("reset_data")}},{key:"getChosenAttributes",value:function(){var t={},e=0,a=0;return this.$attributeFields.each((function(){var i=n(this).data("attribute_name")||n(this).attr("name"),o=n(this).val()||"";o.length>0&&a++,e++,t[i]=o})),{count:e,chosenCount:a,data:t}}},{key:"isMatch",value:function(t,e){var a=!0;for(var i in t)if(t.hasOwnProperty(i)){var o=t[i],r=e[i];void 0!==o&&void 0!==r&&0!==o.length&&0!==r.length&&o!==r&&(a=!1)}return a}},{key:"findMatchingVariations",value:function(t,e){for(var a=[],i=0;i0){var f=p.shift(),m={};m.attribute_name=c,m.attribute_value=u,m.variation=f,o.push(m)}}}catch(t){d.e(t)}finally{d.f()}}}return o}},{key:"updateAttributes",value:function(t){var e=this,a=this.getChosenAttributes(),i=a.data;this.isAjaxVariation()||(this.$attributeFields.each((function(t,o){var r,s=n(o),c=s.data("attribute_name")||s.attr("name"),l=n(o).data("show_option_none"),h=":gt(0)",_=n("