!function(e,t){"use strict";var a=null,o=window.JetCWSettings,i=o.compareMaxItems,n=o.compareItemsCount,s={init:function(){var a={"jet-compare.default":s.compareWidget};e.each(a,function(e,a){t.hooks.addAction("frontend/element_ready/"+e,a)}),s.commonInit(),e(window).on("jet-popup/render-content/ajax/success",s.prepareJetPopup)},commonInit:function(){e(document).on("click.JetCW",'.jet-compare-button__link[href="#"]',s.addToCompare).on("click.JetCW",'.jet-wishlist-button__link[href="#"]',s.addToWishlist).on("click.JetCW",".jet-compare-item-remove-button",s.removeFromCompare).on("click.JetCW",".jet-wishlist-item-remove-button",s.removeFromWishlist).on("jet-cw-load",s.addLoader).on("jet-cw-loaded",s.removeLoader).on("jet-engine/listing-grid/after-lazy-load",s.prepareCWSettingsAfterAjaxLoad).on("jet-woo-builder-content-rendered",s.prepareCWSettingsAfterAjaxLoad)},prepareCWSettingsAfterAjaxLoad:function(e,t,a){let o=a.data.jetCompareWishlistWidgets;s.setProperWidgetsSettings(o)},setProperWidgetsSettings:function(t){if(!t)return;let a={},i={},n=t.compare,s=t.wishlist;null===o.widgets?o.widgets={}:(a=o.widgets.compare,i=o.widgets.wishlist),o.widgets.compare=e.extend(a,n),o.widgets.wishlist=e.extend(i,s)},compareWidget:function(t){let a=t.find(".jet-compare-table__wrapper"),o=a.find(".jet-compare-table-action-control");o.each(function(){const t=e(this);t.hasClass("jet-compare-table-action-control__clear")?t.on("click.JetCW",s.removeFromCompare):t.on("click.JetCW",function(t){t.preventDefault();let i=e(this);i.hasClass("jet-compare-table-action-control__highlight")&&(a.hasClass("jet-compare-table-highlight")?a.removeClass("jet-compare-table-highlight"):a.addClass("jet-compare-table-highlight")),i.hasClass("jet-compare-table-action-control__differences")&&(a.hasClass("jet-compare-table-differences")?a.removeClass("jet-compare-table-differences"):a.addClass("jet-compare-table-differences")),o.length>1?i.hasClass("active")?(i.removeClass("active"),i.siblings(".jet-compare-table-action-control:not(.jet-compare-table-action-control__clear)").removeClass("disable")):(i.addClass("active"),i.siblings(".jet-compare-table-action-control:not(.jet-compare-table-action-control__clear)").addClass("disable")):i.hasClass("active")?i.removeClass("active"):i.addClass("active"),s.compareTableDifference(a)})})},compareTableDifference:function(t){let a=t.find(".jet-compare-table-row"),o=t.hasClass("jet-compare-table-highlight"),i=t.hasClass("jet-compare-table-differences");a.each(function(){let t=e(this),a=t.find(".jet-compare-table-cell");if(s.exceptionsDifference(t))return;let n=[];a.each(function(){let t=e(this);if(-1!==n.indexOf(t.text().trim()))return!0;n.push(t.text().trim())}),o&&n.length>1?t.addClass("highlighted"):!o&&t.hasClass("highlighted")&&t.removeClass("highlighted"),i&&n.length<=1?t.hide():!i&&t.is(":hidden")&&t.show()})},exceptionsDifference:function(t){let a=!1;return e.each(["remove-button","add-to-cart","product-title","stock-status","thumbnail","price","rating-stars"],function(e,o){t.children().find(".jet-cw-"+o).length>0&&(a=!0)}),a},prepareJetPopup:function(e,t){let a=t.request.data;(a.isJetWooBuilder||a.isJetEngine)&&s.setProperWidgetsSettings(a.jetCompareWishlistWidgets)},removeFromCompare:function(t){t.preventDefault();var o=e(this),i=o.data("product-id");a&&a.abort(),e(document).trigger("jet-cw-load",[o,i,"jet_update_compare_list"]),a=s.ajaxRequest(o,"jet_update_compare_list","remove",i)},removeFromWishlist:function(t){t.preventDefault();var o=e(this),i=o.data("product-id");a&&a.abort(),e(document).trigger("jet-cw-load",[o,i,"jet_update_wish_list"]),a=s.ajaxRequest(o,"jet_update_wish_list","remove",i)},addToWishlist:function(t){t.preventDefault();var o=e(this),i=o.data("product-id");a&&a.abort(),e(document).trigger("jet-cw-load",[o,i,"jet_update_wish_list"]),o.hasClass("jet-wishlist-item-remove-button")||(a=s.ajaxRequest(o,"jet_update_wish_list","add",i))},addToCompare:function(t){if(t.preventDefault(),n>=i&&!e(this).hasClass("jet-compare-item-remove-button"))s.showMessages("compare_max_items");else{var o=e(this),r=o.data("product-id");a&&a.abort(),e(document).trigger("jet-cw-load",[o,r,"jet_update_compare_list"]),o.hasClass("jet-compare-item-remove-button")||(a=s.ajaxRequest(o,"jet_update_compare_list","add",r))}},ajaxRequest:function(t,a,i,r){e.ajax({url:o.ajaxurl,type:"POST",dataType:"json",data:{action:a,pid:r,context:i,widgets_data:o.widgets}}).done(function(o){o.success?(n=o.data.compareItemsCount,s.renderResult(o.data),e(document).trigger("jet-cw-loaded",[t,r,a])):e(document).trigger("jet-cw-response-failed",[o])})},renderResult:function(t){let a=t.content;e.each(a,function(t,a){e(t).replaceWith(a),s.elementorFrontendInit(e(t)),s.compareWidget(e(t).offsetParent())})},addLoader:function(t,a,o,i){"jet_update_compare_list"===i&&(e('a.jet-compare-button__link[data-product-id="'+o+'"]').addClass("jet-cw-loading"),e("div.jet-compare-table__wrapper").addClass("jet-cw-loading"),e("a.jet-compare-count-button__link").addClass("jet-cw-loading")),"jet_update_wish_list"===i&&(e('a.jet-wishlist-button__link[data-product-id="'+o+'"]').addClass("jet-cw-loading"),e("a.jet-wishlist-count-button__link").addClass("jet-cw-loading"),e("div.jet-wishlist__content").addClass("jet-cw-loading"))},removeLoader:function(t,a,o,i){"jet_update_compare_list"===i&&(e('a.jet-compare-button__link[data-product-id="'+o+'"]').removeClass("jet-cw-loading"),e("div.jet-compare-table__wrapper").removeClass("jet-cw-loading"),e("a.jet-compare-count-button__link").removeClass("jet-cw-loading")),"jet_update_wish_list"===i&&(e('a.jet-wishlist-button__link[data-product-id="'+o+'"]').removeClass("jet-cw-loading"),e("a.jet-wishlist-count-button__link").removeClass("jet-cw-loading"),e("div.jet-wishlist__content").removeClass("jet-cw-loading"))},showMessages:function(t){var a=e(".jet-compare-message--max-items");"compare_max_items"===t&&(a.addClass("show"),setTimeout(function(){a.removeClass("show")},4e3))},elementorFrontendInit:function(t){t.find("[data-element_type]").each(function(){let t=e(this),a=t.data("element_type");a&&("widget"===a&&(a=t.data("widget_type"),window.elementorFrontend.hooks.doAction("frontend/element_ready/widget",t,e)),window.elementorFrontend.hooks.doAction("frontend/element_ready/global",t,e),window.elementorFrontend.hooks.doAction("frontend/element_ready/"+a,t,e))})}};t?e(window).on("elementor/frontend/init",s.init):s.commonInit()}(jQuery,window.elementorFrontend);