!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={}.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=Array(e);a<e;a++)i[a]=t[a];return i}function n(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,i)}return a}function s(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?n(Object(a),!0).forEach(function(e){l(t,e,a[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):n(Object(a)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))})}return t}function c(t,e){for(var a=0;a<e.length;a++){var i=e[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,h(i.key),i)}}function l(t,e,a){return(e=h(e))in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function h(e){var a=function(e,a){if("object"!=t(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var o=i.call(e,a||"default");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===a?String:Number)(e)}(e,"string");return"symbol"==t(a)?a:a+""}!function(o){"use strict";function r(t){if(!t)return!1;if("boolean"==typeof t)return t;var e=String(t).toLowerCase().trim();return!!["1","true","yes","on"].includes(e)||1===t}var n,h=(n=jQuery,function(){return t=function t(e,a,i){var o=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),l(this,"defaults",{}),l(this,"onInit",function(t){o.initFetch()}),l(this,"onAjaxAddToCart",function(t){if(n(t.target).is(".loading"))return!1;n(t.target).is(".wvs_ajax_add_to_cart")&&(t.preventDefault(),t.stopPropagation(),o.AjaxAddToCart(t.target))}),l(this,"onExpandVariableItems",function(t){t.preventDefault(),o.expandVariableItems(t)}),l(this,"onPreviewChange",function(t){t.preventDefault(),o.$element.off("reset_data.wc-variation-form"),o.fetchPreviewChange(t.currentTarget)}),l(this,"onChange",function(t){o.$element.trigger("woocommerce_variation_select_change"),o.$element.trigger("check_variations"),o.$element.trigger("woocommerce_variation_has_changed")}),l(this,"onReset",function(t){t.preventDefault(),o.reset()}),l(this,"onResetDisplayedVariation",function(t){o.resetDisplayedVariation()}),l(this,"onUpdateAttributes",function(t){o.updateAttributes(t)}),l(this,"onCheckVariations",function(t){o.checkVariations()}),l(this,"onVariationChanged",function(t){o.setupSwatchesItems()}),l(this,"onFoundVariation",function(t,e,a){o.foundVariation(e,a)}),this.name=i,this.element=e,this.$element=n(e),this.settings=n.extend(!0,{},this.defaults,a),this.product_variations=this.$element.data("product_variations")||[],this.is_ajax_variation=this.product_variations.length<1,this.product_id=parseInt(this.$element.data("product_id"),10),this.threshold_min=parseInt(this.$element.data("threshold_min"),10),this.threshold_max=parseInt(this.$element.data("threshold_max"),10),this.total_children=parseInt(this.$element.data("total_children"),10),this.total_attribute=parseInt(this.$element.data("total_attribute"),10),this.xhr=!1,this.previewXhr=!1,this.loading=!0,this.$information=this.$element.find(".wvs-archive-information"),this.$wrapper=this.$element.closest(woo_variation_swatches_pro_options.archive_product_wrapper),this.$image=this.$wrapper.find(woo_variation_swatches_pro_options.archive_image_selector),this.$cart_button=this.$wrapper.find(woo_variation_swatches_pro_options.archive_cart_button_selector),this.$is_block=this.$wrapper.find(".wvs-has-block-enabled").length>0,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)},h=[{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;i<t.length;i++){var o=t[i];this.isMatch(o.attributes,e)&&a.push(o)}return a}},{key:"findStockVariations",value:function(t,e){for(var o=[],r=0,n=Object.entries(e.data);r<n.length;r++){var s=i(n[r],2),c=s[0];if(0===s[1].length){var h,d=a(this.$element.find("ul[data-attribute_name='".concat(c,"']")).data("attribute_values")||[]);try{for(d.s();!(h=d.n()).done;){var u=h.value,v=_.extend(e.data,l({},c,u)),p=this.findMatchingVariations(t,v);if(p.length>0){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("<select/>"),d=s.val()||"",u=!0;if(!s.data("attribute_html")){var v=s.clone();v.find("option").prop("disabled",!1).prop("selected",!1).removeAttr("attached").removeClass("out-of-stock"),s.data("attribute_html",v.html())}_.html(s.data("attribute_html"));var p=n.extend(!0,{},i);p[c]="";var f=e.findMatchingVariations(e.getAvailableVariations(),p),m={};for(var w in f)if(void 0!==f[w]){var g=f[w].attributes;for(var b in g)if(b===c){var y=g[b];f[w].is_in_stock&&(m[y]=!0)}}for(var $ in f)if(void 0!==f[$]){var k=f[$].attributes;for(var C in k)if(k.hasOwnProperty(C)){var x=k[C],A="";if(C===c)if(f[$].variation_is_active&&(A="enabled"),f[$].is_in_stock,x){x=n("<div/>").html(x).text();var j=_.find("option");if(j.length)for(var S=0,P=j.length;S<P;S++){var I=n(j[S]);if(x===I.val()){I.addClass("attached "+A),m.hasOwnProperty(x)||I.addClass("out-of-stock"),a.count>1&&a.chosenCount,a.count>1&&(a.chosenCount,a.count),!woo_variation_swatches_pro_options.enable_clickable_out_of_stock_archive&&a.count;break}}}else _.find("option:gt(0)").addClass("attached "+A)}}r=_.find("option.attached").length,d&&(u=!1,0!==r&&_.find("option.attached.enabled").each(function(){var t=n(this).val();if(d===t)return u=!0,!1})),r>0&&d&&u&&"no"===l&&(_.find("option:first").remove(),h=""),_.find("option"+h+":not(.attached)").remove(),s.html(_.html()),s.find("option"+h+":not(.enabled)").prop("disabled",!0),d?u?s.val(d):s.val("").trigger("change"):s.val("")}),this.$element.trigger("woocommerce_update_variation_values"))}},{key:"checkVariations",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=e||this.getChosenAttributes(),i=a.data;if(a.count&&a.count===a.chosenCount)if(this.isAjaxVariation())this.xhr&&this.xhr.abort(),this.$element.block({message:null,overlayCSS:{background:"#FFFFFF",opacity:.6}}),i.product_id=this.product_id,i.custom_data=this.$element.data("custom_data"),i._wpnonce=woo_variation_swatches_pro_params._wpnonce,this.xhr=n.ajax({global:!1,url:woo_variation_swatches_pro_params.wc_ajax_url.toString().replace("%%endpoint%%","woo_get_variation"),method:"POST",data:i}),this.xhr.fail(function(e,a){console.error("product variations not available on ".concat(t.product_id,"."),a)}),this.xhr.done(function(e){e?t.$element.trigger("found_variation",[e,!0]):(t.$element.trigger("reset_data"),a.chosenCount=0)}),this.xhr.always(function(){t.$element.unblock()});else{this.$element.trigger("update_variation_values");var o=this.getAvailableVariations(),r=this.findMatchingVariations(o,i).shift();r?this.$element.trigger("found_variation",[r,!1]):(this.$element.trigger("reset_data"),a.chosenCount=0)}else this.$element.trigger("update_variation_values"),this.$element.trigger("reset_data");this.toggleResetLink(a.chosenCount>0),this.$element.trigger("woo_variation_swatches_pro_check_variations",[a])}},{key:"isAjaxVariation",value:function(){return this.is_ajax_variation}},{key:"swatchInit",value:function(){this.setupSwatchesItems(),this.setupSwatchesEvents(),this.deselectNonAvailable()}},{key:"setupSwatchesItems",value:function(){var t=this;this.$attributeSwatchesFields.each(function(a,i){var o="",r=n(i).parent().find("select.woo-variation-raw-select"),s=r.find("option"),c=r.find("option:disabled"),l=r.find("option.enabled.out-of-stock"),h=r.find("option:selected"),d=r.find("option").eq(1),u=(n(i).data("attribute_name"),n(i).data("attribute_values")),v=[],p=[],f=[];s.each(function(){""!==n(this).val()&&(v.push(n(this).val()),o=0===h.length?d.val():h.val())}),c.each(function(){""!==n(this).val()&&f.push(n(this).val())}),l.each(function(){""!==n(this).val()&&p.push(n(this).val())});var m=_.difference(v,f),w=[].concat(e(_.difference(u,v)),f);t.setupSwatchesItem(i,o,m,p,w)})}},{key:"setupSwatchesItem",value:function(t,e,a,i,o){var s=this,c=n(t).parent().prev().find(".woo-selected-variation-item-name");n(t).find("li.variable-item").each(function(t,l){var h=n(l).attr("data-value"),d=n(l).attr("data-title");n(l).removeClass("selected disabled no-stock").addClass("disabled"),n(l).attr("aria-checked","false"),n(l).attr("tabindex","-1"),n(l).attr("data-wvstooltip-out-of-stock",""),n(l).find("input.variable-item-radio-input:radio").prop("disabled",!0).prop("checked",!1),e.length<1&&r(woo_variation_swatches_pro_options.show_archive_attribute_label)&&c.text(""),s.isAjaxVariation()?(n(l).find("input.variable-item-radio-input:radio").prop("disabled",!1),n(l).removeClass("selected disabled no-stock"),h===e&&(n(l).addClass("selected"),n(l).attr("aria-checked","true"),n(l).attr("tabindex","0"),n(l).find("input.variable-item-radio-input:radio").prop("disabled",!1).prop("checked",!0),r(woo_variation_swatches_pro_options.show_archive_attribute_label)&&r(woo_variation_swatches_pro_options.show_archive_variation_label)&&c.text("".concat(woo_variation_swatches_pro_options.archive_variation_label_separator," ").concat(d)),n(l).trigger("wvs-item-updated",[e,h]))):(_.includes(a,h)&&(n(l).removeClass("selected disabled"),n(l).removeAttr("aria-hidden"),n(l).attr("tabindex","0"),n(l).find("input.variable-item-radio-input:radio").prop("disabled",!1),h===e&&(n(l).addClass("selected"),n(l).attr("aria-checked","true"),n(l).find("input.variable-item-radio-input:radio").prop("checked",!0),r(woo_variation_swatches_pro_options.show_archive_attribute_label)&&r(woo_variation_swatches_pro_options.show_archive_variation_label)&&c.text("".concat(woo_variation_swatches_pro_options.archive_variation_label_separator," ").concat(d)),n(l).trigger("wvs-item-updated",[e,h]))),_.includes(i,h)&&(n(l).attr("data-wvstooltip-out-of-stock",woo_variation_swatches_pro_options.out_of_stock_tooltip_text),r(woo_variation_swatches_pro_options.clickable_out_of_stock)&&n(l).removeClass("disabled").addClass("no-stock")),_.includes(o,h)&&n(l).attr("data-wvstooltip-out-of-stock",woo_variation_swatches_pro_options.unavailable_tooltip_text))})}},{key:"setupSwatchesEvents",value:function(){var t=this,e=this.$element;this.$attributeSwatchesFields.each(function(a,i){var s=n(i).parent().find("select.woo-variation-raw-select");if(r(woo_variation_swatches_pro_options.clear_on_reselect)?(n(i).on("click.wc-variation-form","li.variable-item:not(.selected):not(.radio-variable-item)",function(t){t.preventDefault(),t.stopPropagation();var a=n(this).data("attribute_name"),i=n(this).data("value");s.val(i).trigger("change"),s.trigger("click"),n(this).trigger("wvs-selected-item",[a,i,s,e])}),n(i).on("click.wc-variation-form","li.variable-item.selected:not(.radio-variable-item)",function(t){t.preventDefault(),t.stopPropagation();var a=n(this).data("attribute_name"),i=n(this).data("value");if(r(woo_variation_swatches_pro_options.enable_catalog_mode)&&"hover"===woo_variation_swatches_pro_options.catalog_mode_trigger)return!1;s.val("").trigger("change"),s.trigger("click"),n(this).trigger("wvs-unselected-item",[a,i,s,e])}),n(i).on("click.wc-variation-form","input.variable-item-radio-input:radio",function(t){t.stopPropagation(),n(this).trigger("change.wc-variation-form",{radioChange:!0})}),n(i).on("change.wc-variation-form","input.variable-item-radio-input:radio",function(t,a){if(t.preventDefault(),t.stopPropagation(),a&&a.radioChange){var i=n(this).data("attribute_name"),o=n(this).val();n(this).parent("li.radio-variable-item").hasClass("selected")?(s.val("").trigger("change"),n(this).closest("li.radio-variable-item").trigger("wvs-unselected-item",[i,o,s,e])):(s.val(o).trigger("change"),n(this).closest("li.radio-variable-item").trigger("wvs-selected-item",[i,o,s,e])),s.trigger("click")}})):(n(i).on("click.wc-variation-form","li.variable-item:not(.radio-variable-item)",function(t){t.preventDefault(),t.stopPropagation();var a=n(this).data("attribute_name"),i=n(this).data("value");s.val(i).trigger("change"),s.trigger("click"),n(this).trigger("wvs-selected-item",[a,i,s,e])}),n(i).on("change.wc-variation-form","input.variable-item-radio-input:radio",function(t){t.preventDefault(),t.stopPropagation();var a=n(this).data("attribute_name"),i=n(this).val();s.val(i).trigger("change"),s.trigger("click"),n(this).closest("li.radio-variable-item").removeClass("selected disabled no-stock").addClass("selected"),n(this).closest("li.radio-variable-item").trigger("wvs-selected-item",[a,i,s,e])})),n(i).on("keydown.wvs","li.variable-item:not(.disabled)",function(t){(t.keyCode&&32===t.keyCode||t.key&&" "===t.key||t.keyCode&&13===t.keyCode||t.key&&"enter"===t.key.toLowerCase())&&(t.preventDefault(),n(this).trigger("click"))}),r(woo_variation_swatches_pro_options.enable_catalog_mode)&&"hover"===woo_variation_swatches_pro_options.catalog_mode_trigger&&(t.threshold_max<t.total_children?n(i).on("mouseenter.wvs","li.variable-item:not(.radio-variable-item)",function(){n(this).trigger("click"),n(i).off("mouseenter.wvs")}):n(i).on("mouseenter.wvs","li.variable-item:not(.radio-variable-item)",function(t){n(this).trigger("click")}),r(woo_variation_swatches_pro_options.linkable_attribute))){if(r(woo_variation_swatches_pro_options.is_mobile)&&!r(woo_variation_swatches_pro_options.linkable_attribute_mobile))return!0;n(i).on("click.linkable","li.variable-item:not(.radio-variable-item)",function(t){if(void 0!==t.originalEvent){var e=n(this).attr("data-url");e&&(o.location.href=e)}})}}),this.$element.find("[data-wvstooltip]").each(function(t,e){n(e).on("mouseenter",function(t){var a=e.getBoundingClientRect(),i=o.getComputedStyle(e,":before"),r=o.getComputedStyle(e,":after"),n=parseInt(r.getPropertyValue("border-top-width"),10),s=parseInt(i.getPropertyValue("height"),10),c=parseInt(i.getPropertyValue("width"),10),l=s+n+2;e.classList.toggle("wvs-tooltip-position-bottom",a.top<l);var h=c/2,_=a.left+a.width/2,d=h-_,u=h>_,v=h+_,p=document.body.clientWidth<v,f=document.body.clientWidth-v;e.style.setProperty("--horizontal-position","0px"),u&&e.style.setProperty("--horizontal-position","".concat(d+2,"px")),p&&e.style.setProperty("--horizontal-position","".concat(f-2,"px"))})})}},{key:"extractAttributes",value:function(t){var e,i=new Set,o=a(this.product_variations);try{for(o.s();!(e=o.n()).done;){var r=e.value.attributes;for(var n in r)r[n].length>0&&i.add(n)}}catch(t){o.e(t)}finally{o.f()}return i.delete(t),Array.from(i)}},{key:"getUnavailableAttributes",value:function(t,e){return 0===this.findMatchingVariations(this.product_variations,t).filter(function(t){return!r(woo_variation_swatches_pro_options.disable_out_of_stock)||t.is_in_stock}).length?this.extractAttributes(e):[]}},{key:"deselectNonAvailable",value:function(){var t=this;r(woo_variation_swatches_pro_options.deselect_unavailable)&&this.$element.on("wvs-selected-item.wvs",function(e,i,o){var r=s(s({},t.getChosenAttributes().data),{},l({},i,o.toString())),c=t.getUnavailableAttributes(r,i);if(c.length>0){var h,_=a(c);try{for(_.s();!(h=_.n()).done;){var d=h.value;t.$attributeSwatchesFields.find('li[data-attribute_name="'.concat(d,'"]')).removeClass("selected"),t.$attributeFields.filter('[data-attribute_name="'.concat(d,'"]')).each(function(t,e){n(e).val("").trigger("change")})}}catch(t){_.e(t)}finally{_.f()}t.$attributeSwatchesFields.filter('[data-attribute_name="'.concat(i,'"]')).each(function(){n(this).find('[data-value="'.concat(o,'"]')).removeClass("disabled").addClass("selected")}),t.$attributeFields.filter('[data-attribute_name="'.concat(i,'"]')).each(function(t,e){n(e).val(o).trigger("change")})}})}},{key:"resetDisplayedVariation",value:function(){this.resetPrice(),this.resetImage(),this.resetAvailabilityInfo(),this.resetCartButton()}},{key:"foundVariation",value:function(t,e){var a=!0;this.updateImage(t),this.reAttachCatalogModeHover(),r(woo_variation_swatches_pro_options.enable_catalog_mode)||(this.updateAvailabilityInfo(t),this.updatePrice(t)),t.is_purchasable&&t.is_in_stock&&t.variation_is_visible||(a=!1),a&&!r(woo_variation_swatches_pro_options.enable_catalog_mode)?this.updateCartButton(t):this.resetCartButton(),1===this.total_attribute&&r(woo_variation_swatches_pro_options.enable_catalog_mode)&&r(woo_variation_swatches_pro_options.disable_catalog_mode_on_single_attribute)&&(this.updateAvailabilityInfo(t),this.updatePrice(t),a?this.updateCartButton(t):this.resetCartButton()),this.$element.trigger("show_variation",[t,a])}},{key:"reAttachCatalogModeHover",value:function(){!r(woo_variation_swatches_pro_options.is_mobile)&&this.threshold_max<this.total_children&&r(woo_variation_swatches_pro_options.enable_catalog_mode)&&"hover"===woo_variation_swatches_pro_options.catalog_mode_trigger&&this.$attributeSwatchesFields.each(function(t,e){n(e).one("mouseenter.wc-variation-form","li.variable-item:not(.radio-variable-item):not(.selected)",function(){n(this).trigger("click")})})}},{key:"updateCartButton",value:function(t){if(this.is_cart_button_available){this.$cart_button.removeClass("added"),this.$is_block?this.$view_cart_link.addClass("wvs-hide-view-cart-link"):this.$wrapper.find(".added_to_cart").remove();var e=s(s({},this.getChosenAttributes().data),{},{"add-to-cart":this.product_id,variation_id:t.variation_id});this.$cart_button.attr("href",this.addQueryArgs(this.$cart_button.attr("href"),e)),this.$cart_button.html(t.add_to_cart_text),this.$cart_button.attr("aria-label",t.add_to_cart_description),"yes"===woo_variation_swatches_pro_options.enable_ajax_add_to_cart&&this.$cart_button.addClass("wvs_ajax_add_to_cart")}}},{key:"resetCartButton",value:function(){this.is_cart_button_available&&(this.$cart_button.data("variation_id",""),this.$cart_button.data("variations",""),this.$cart_button.html(this.$cart_button.attr("data-o_html")),this.$cart_button.attr("data-product_id",this.$cart_button.attr("data-o_product_id")),this.$cart_button.attr("href",this.$cart_button.attr("data-o_href")),this.$cart_button.attr("aria-label",this.$cart_button.attr("data-o_aria-label")),this.$cart_button.removeClass("wvs_ajax_add_to_cart"),this.$cart_button.removeClass("added"),this.$is_block?this.$view_cart_link.addClass("wvs-hide-view-cart-link"):this.$wrapper.find(".added_to_cart").remove())}},{key:"addQueryArgs",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=new URL(t);for(var i in e)a.searchParams.set(i,e[i]);return a.href}},{key:"getQueryArgs",value:function(t){var e=new URL(t);return Object.fromEntries(e.searchParams)}},{key:"updateAvailabilityInfo",value:function(t){var e;r(woo_variation_swatches_pro_options.archive_show_availability)&&(e=(e=(e=(t.variation_is_visible?wp.template("wvs-variation-template"):wp.template("wvs-unavailable-variation-template"))({variation:t})).replace("/*<![CDATA[*/","")).replace("/*]]>*/",""),this.$information.html(e))}},{key:"resetAvailabilityInfo",value:function(){this.$information.html("")}},{key:"updatePrice",value:function(t){t&&t.price_html&&t.price_html.length>1&&this.$price.html(t.price_html)}},{key:"resetPrice",value:function(){this.$price.html(this.$price_html)}},{key:"defaultImage",value:function(){this.$image.attr("data-o_src",this.$image.attr("src")),this.$image.attr("srcset")&&this.$image.attr("data-o_srcset",this.$image.attr("srcset")),this.$image.attr("sizes")&&this.$image.attr("data-o_sizes",this.$image.attr("sizes"))}},{key:"defaultCartButton",value:function(){this.is_cart_button_available&&(this.$cart_button.attr("data-o_html",this.$cart_button.html()),this.$cart_button.attr("href")&&this.$cart_button.attr("data-o_href",this.$cart_button.attr("href")),this.$cart_button.attr("aria-label")&&this.$cart_button.attr("data-o_aria-label",this.$cart_button.attr("aria-label")))}},{key:"updateImage",value:function(t){t&&t.image&&t.image.src&&t.image.src.length>1&&(this.$image.attr("src",t.image.src),t.image.srcset&&t.image.srcset.length>1&&this.$image.attr("srcset",t.image.srcset),t.image.sizes&&t.image.sizes.length>1&&this.$image.attr("sizes",t.image.sizes))}},{key:"updatePreviewImage",value:function(t){t&&t.image&&t.image.thumb_src&&t.image.thumb_src.length>1&&(this.$image.attr("src",t.image.thumb_src),t.image.srcset&&t.image.srcset.length>1&&this.$image.attr("srcset",t.image.srcset),t.image.sizes&&t.image.sizes.length>1&&this.$image.attr("sizes",t.image.sizes))}},{key:"resetImage",value:function(){this.$image.attr("src",this.$image.attr("data-o_src")),this.$image.attr("data-o_srcset")&&this.$image.attr("srcset",this.$image.attr("data-o_srcset")),this.$image.attr("data-o_sizes")&&this.$image.attr("sizes",this.$image.attr("data-o_sizes"))}},{key:"destroy",value:function(){this.$element.off(".wc-variation-form"),this.$element.removeClass("wvs-pro-loaded"),this.$element.removeData(this.name)}}],h&&c(t.prototype,h),d&&c(t,d),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,h,d}()),d=function(e){return function(a,i){e.fn[a]=function(o){for(var r=this,n=arguments.length,s=new Array(n>1?n-1:0),c=1;c<n;c++)s[c-1]=arguments[c];return this.each(function(n,c){var l=e(c),h=l.data(a);if(h||(h=new i(l,e.extend({},o),a),l.data(a,h)),"string"==typeof o){if("object"===t(h[o]))return h[o];var _;if("function"==typeof h[o])return(_=h)[o].apply(_,s)}return r})},e.fn[a].Constructor=i,e[a]=function(t){for(var i,o=arguments.length,r=new Array(o>1?o-1:0),n=1;n<o;n++)r[n-1]=arguments[n];return(i=e({}))[a].apply(i,[t].concat(r))},e.fn[a].noConflict=function(){return e.fn[a]}}}(jQuery);d("WooVariationSwatchesPro",h)}(window)}(),jQuery(function(t){try{var e=new IntersectionObserver(function(a){a.forEach(function(a){a.isIntersecting&&(t(a.target).WooVariationSwatchesPro(),e.unobserve(a.target))})},{rootMargin:"50% 0px",threshold:0});t(document).on("woo_variation_swatches_pro_init",function(){t(".wvs-archive-variations-wrapper:not(.wvs-pro-loaded)").each(function(t,a){e.observe(a)})}).trigger("woo_variation_swatches_pro_init")}catch(t){window.console.log("Variation Swatches Pro:",t)}t(document).on("jet-filter-content-rendered.wvs",function(){t(document).trigger("woo_variation_swatches_pro_init")}),t(document).on("yith_infs_added_elem.wvs",function(){t(document).trigger("woo_variation_swatches_pro_init")}),t(document).on("astraInfinitePaginationLoaded.wvs",function(){t(document).trigger("woo_variation_swatches_pro_init")}),t(document).ajaxComplete(function(t,e,a){_.delay(function(){},100)}),t(document.body).on("post-load.wvs",function(){t(document).trigger("woo_variation_swatches_pro_init")}),t(document).on("yith-wcan-ajax-filtered.wvs",function(){t(document).trigger("woo_variation_swatches_pro_init")}),t(document).on("yith_wcwl_reload_fragments",function(){t(document).trigger("woo_variation_swatches_pro_init")}),t(document).on("berocket_ajax_products_loaded.wvs berocket_ajax_products_infinite_loaded.wvs",function(){t(document).trigger("woo_variation_swatches_pro_init")}),t(".shop-container .products, .infinite-scroll-wrap").on("append.infiniteScroll",function(e,a,i){t(document).trigger("woo_variation_swatches_pro_init")}),t(document).on("facetwp-loaded.wvs",function(){t(document.body).trigger("woo_variation_swatches_pro_init")}),t(document).on("nm_infload_after.wvs nm_ajax_shop_update_content.wvs",function(){t(document).trigger("woo_variation_swatches_pro_init")}),t("body").on("aln_reloaded.wvs",function(){_.delay(function(){t(document).trigger("woo_variation_swatches_pro_init")},100)})});