// source --> https://mcmmoto.ch/wp-content/plugins/et-core-plugin/packages/xstore-compare/assets/js/script.min.js 
!function(T){"use strict";etTheme.autoinit.XStoreCompare=etTheme.XStoreCompare=function(){var m,p,a,u,n,c,d,l,_,t,f,o;function h(r,i,s){r<i?T(s[r]).hasClass("processing")||(T(s[r]).trigger("click").addClass("processing"),T(document.body).on("added_to_cart",function(e,t,a,o){o.attr("data-product_id")==T(s[r]).attr("data-product_id")&&(o.removeClass("processing in-process"),h(++r,i,s))})):T(s[r-1]).parent().hasClass("keeper-all-products-buttons")&&T(".et_b_header-compare").find("li").unblock()}function g(e,t,a){e<t&&(T(a[e]).hasClass("processing")||T(a[e]).trigger("click",{is_multiple:!0,i:e,max:t,buttons:a}).addClass("processing"))}function x(e,t,a){var o;e<t&&(o=_?"in-process":"processing",T(a[e]).hasClass(o)||T(a[e]).trigger("click",{is_multiple:!0,i:e,max:t,buttons:a}).addClass(o))}function v(){var e;return a||(T.ajax({url:xstore_compare_params.ajaxurl,dataType:"json",method:"POST",data:{cookie_key:p,action:"xstore_get_user_compare"},success:function(e){return a=e.products.products.map(e=>JSON.stringify(e))},error:function(){},complete:function(){}}),(e=etTheme.getCookie(p))?e.split("|"):[])}function b(){var e;return a?a.map(e=>JSON.parse(e).id):(T.ajax({url:xstore_compare_params.ajaxurl,dataType:"json",method:"POST",data:{cookie_key:p,action:"xstore_get_user_compare"},success:function(e){var t=e.products.products;return a=e.products.products.map(e=>JSON.stringify(e)),t},error:function(){},complete:function(){}}),(e=etTheme.getCookie(p))&&T.isArray(e)?e.split("|").map(e=>JSON.parse(e).id):[])}function y(e,a={}){e=parseInt(e);var o=v(),t=o.map(e=>JSON.parse(e).id).indexOf(e);if(-1<t){if(o.splice(t,1),etTheme.setCookie(p,o.join("|")),a.table_row)a.table_row.css({position:"relative",zoom:1}),a.table_row.find("td:last-child").block({message:null,overlayCSS:{opacity:.6}}).attr("style",null),_?setTimeout(function(){a.table_row.remove()},1500):(a.table_row.find("td:last-child").unblock(),setTimeout(function(){a.table_row.attr("style",null)},500));else if(a.table_cols&&_){let t=a.table_cols.first().parents(".xstore-compare-table");t.block({message:null,overlayCSS:{opacity:.6}}),setTimeout(function(){o.length<4?a.table_cols.each(function(){T(this).attr("data-product_id","ghost-product-"+(4-o.length)),T(this).hasClass("xstore-compare-product")?T(this).html('<span class="xstore-compare-image">'+xstore_compare_params.placeholder_image+"</span>"):T(this).html(""),T(this).parent().append(T(this).remove())}):a.table_cols.each(function(){T(this).remove()})}),setTimeout(function(){t.unblock().removeClass("processing").attr("style",null);var e=t.parent();r(e,"horizontal")||e.find(".xstore-compare-table-arrow").remove()},500)}T(document).find("."+m+"[data-id="+e+"]").each(function(){a.table_row||T(this).addClass("processing"),f(T(this),JSON.parse(T(this).attr("data-settings")),"remove")}),a.minicompare&&a.liItem.block({message:null,overlayCSS:{opacity:.6}}),xstore_compare_params.is_loggedin&&(clearTimeout(u),u=setTimeout(function(){k(o.join("|"))},1500)),a.is_multiple?(a.i++,T(document).trigger("xstore_compare/removed_product",[o,e,a.is_multiple,a.i,a.max,a.buttons])):T(document).trigger("xstore_compare/removed_product",[o,e])}}function r(e,t){return"vertical"==t?e.get(0).scrollHeight>e.innerHeight():"horizontal"==t&&e.get(0).scrollWidth>e.innerWidth()}function k(e){T.ajax({url:xstore_compare_params.ajaxurl,dataType:"json",method:"POST",data:{action:"xstore_update_user_compare",cookie_key:p,products:e},success:function(e){},error:function(){},complete:function(){}})}function i(e,t){e.length&&(t?(e.attr("data-o_id")||e.attr("data-o_id",e.data("id")),e.attr("data-id",t)):void 0!==e.attr("data-o_id")&&e.attr("data-id",e.attr("data-o_id")),o(e,parseInt(t)))}function s(e){void 0!==e.attr("data-o_id")&&(e.attr("data-id",e.attr("data-o_id")),o(e,e.attr("data-o_id")))}"undefined"!=typeof Cookies&&(etTheme.xstore_compare={},m="xstore-compare",p=xstore_compare_params.compare_id,a=null,c=n=u=0,d=etTheme.et_global.w_width<etTheme.et_global.mob_header_start||etConfig.layoutSettings.is_mobile?T(".mobile-header-wrapper"):T(".header-wrapper"),l=T("body").hasClass("xstore-compare-page"),_=T("body").hasClass("xstore-compare-owner"),t=0,T.ajax({url:xstore_compare_params.ajaxurl,dataType:"json",method:"POST",data:{cookie_key:p,action:"xstore_get_user_compare"},success:function(e){a=e.products.products.map(e=>JSON.stringify(e)),T(document).trigger("xstore_compare_initialized",[a])},error:function(){},complete:function(){}}),xstore_compare_params.ajax_fragments&&(T(document).on("xstore_compare_initialized",function(e,t){T(document).trigger("xstore_compare_fragment_refresh",[t])}),T(window).on("pageshow",function(e){e.originalEvent.persisted&&(T(".et_b_compare-dropdown").empty(),T(document).trigger("xstore_compare_fragment_refresh",[v()]))})),T(document).on("click","."+m,function(e,t){e.preventDefault();var a=T(this).attr("data-action"),o=T(this).attr("data-id"),r=T(this).data("settings")||{},i=T(this).hasClass(m+"-redirect"),e=t&&!!t.is_multiple,s={},n=(e&&(s={is_multiple:!0,i:t.i,max:t.max,buttons:t.buttons}),T(this).parents("td"));switch((e||n)&&(s.table_cols=T(this).parents("table").find('td[data-product_id="'+o+'"]')),a){case"add":T(this).addClass("processing"),f(T(this),r,a);var c,[d,l={}]=[o,s];d=parseInt(d),-1===b().indexOf(d)&&((c=v()).push(JSON.stringify({id:d,time:Math.floor((new Date).getTime()/1e3)})),etTheme.setCookie(p,c.join("|"),xstore_compare_params.days_cache),l.table_row&&!_&&(l.table_row.css({position:"relative",zoom:1}),l.table_row.find("td:last-child").block({message:null,overlayCSS:{opacity:.6}}).attr("style",null),l.table_row.find("td:last-child").unblock(),setTimeout(function(){l.table_row.attr("style",null)},500)),xstore_compare_params.is_loggedin&&(clearTimeout(u),u=setTimeout(function(){k(c.join("|"))},1500)),T(document).find("."+m+"[data-id="+d+"]").each(function(){T(this).addClass("processing"),f(T(this),JSON.parse(T(this).attr("data-settings")))}),l.is_multiple?(l.i++,T(document).trigger("xstore_compare/added_product",[c,d,l.is_multiple,l.i,l.max,l.buttons])):T(document).trigger("xstore_compare/added_product",[c,d])),i&&T(this).addClass(m+"-redirect-ready");break;case"remove":i&&T(this).hasClass(m+"-redirect-ready")?window.location.href=xstore_compare_params.compare_page_url:(_||n||T(this).addClass("processing"),f(T(this),r,a),y(o,s))}}),f=function(e,t,a="add"){"add"==a?(t.removeText&&(e.find(".button-text").text(t.removeText),e.find(".mt-mes").text(t.removeText)),t.iconRemove&&t.iconRemove!=t.iconAdd&&e.find(".et-icon").addClass(t.iconRemove).removeClass(t.iconAdd),e.attr("data-action","remove"),e.attr("href",e.attr("href").replace("add_to_compare","remove_compare"))):(t.addText&&(e.find(".button-text").text(t.addText),e.find(".mt-mes").text(t.addText)),t.iconAdd&&t.iconAdd!=t.iconRemove&&e.find(".et-icon").addClass(t.iconAdd).removeClass(t.iconRemove),e.attr("data-action","add"),e.attr("href",e.attr("href").replace("remove_compare","add_to_compare"))),e.removeClass(m+"-redirect-ready"),setTimeout(function(){e.removeClass("processing"),e.removeClass("in-process")},300)},T(document).on("click",".xstore-minicompare-remove",function(e){e.preventDefault(),y(T(this).data("id"),{minicompare:!0,liItem:T(this).parents("li")})}),T(".xstore-compare-table :checkbox").on("click",function(){var e;"product-bulk-select"==T(this).attr("name")?T(this).closest("table").children("tbody").find(":checkbox").prop("checked",T(this).prop("checked")):(e=T(this).closest("tbody").find(':checkbox:not([name="product-bulk-select"])').filter(":visible:enabled").not(":checked"),T(this).closest("table").find(':checkbox[name="product-bulk-select"]').prop("checked",function(){return 0===e.length}))}),T(document).on("click",".xstore-compare-form .add-all-products",function(e){e.preventDefault(),confirm(xstore_compare_params.confirmQuestion)&&(etConfig.ajaxProductAddedNotify.type="alert",(e=T(this).closest(".xstore-compare-form").find("table").children("tbody").find(":checkbox").parents("tr").find(".ajax_add_to_cart")).length<1?alert(xstore_compare_params.no_products_available):h(0,e.length,e))}),T(document).on("click",".et_b_header-compare .add-all-products",function(e){var t;e.preventDefault(),confirm(xstore_compare_params.confirmQuestion)&&(etConfig.ajaxProductAddedNotify.type="alert",(t=(e=T(this).parents(".et_b_header-compare")).find(".keeper-all-products-buttons .ajax_add_to_cart")).length?(e.find("li").block({message:null,overlayCSS:{opacity:.6}}),h(0,t.length,t)):t.length<1&&alert(xstore_compare_params.no_products_available))}),T(".xstore-compare-actions").on("click",function(e){e.preventDefault();var a,t,o=!(etConfig.ajaxProductAddedNotify.type="alert"),r=!1,e=T(this).closest(".xstore-compare-form").find("table").children("tbody").find(":checkbox:checked"),r=[];if(e.parents("td").each(function(){var e=T(this).data("product_id");r.push(T(this).closest(".xstore-compare-form").find("table").children("tbody").find('td[data-product_id="'+e+'"]'))}),r.length<1)alert(xstore_compare_params.no_active_checkbox);else if(confirm(xstore_compare_params.confirmQuestion))switch(T(this).parent().find("select").val()){case"add":o?a=o.find(".ajax_add_to_cart"):r&&(a=[],r.forEach(function(e,t){e=T(e).find(".ajax_add_to_cart");e.length&&a.push(e)})),a.length<1?alert(xstore_compare_params.no_products_available):h(0,a.length,a);break;case"add_compare":o?a=o.find("."+m+'[data-action="add"]'):r&&(a=[],r.forEach(function(e,t){e=T(e).find("."+m+'[data-action="add"]');e.length&&a.push(e)})),a.addClass("in-process"),g(0,a.length,a);break;case"remove":o?a=o.find("."+m+'[data-action="remove"]"]'):r&&(a=[],r.forEach(function(e,t){e=T(e).find("."+m+'[data-action="remove"]');e.length&&a.push(e)})),_?(t=T(this).closest(".xstore-compare-form").find("table").children("tbody").find("td."+m+"-action[data-product_id]"),a.length==t.find("."+m).length?(etTheme.setCookie(p,"",0),xstore_compare_params.is_loggedin&&k([]),T(document).trigger("xstore_compare_fragment_refresh",[[]])):x(0,a.length,a)):(a.addClass("in-process"),x(0,a.length,a))}}),l&&T(".xstore-compare-table-wrapper").length&&(r(T(".xstore-compare-table-wrapper"),"horizontal")||T(".xstore-compare-table-wrapper").find(".xstore-compare-table-arrow").remove()),T(".xstore-compare-table-arrow").on("click",function(){var e,t,a;e=T(this),t=e.parent(),a=e.parent().find("tbody").find("tr:last-child td:last-child").outerWidth(),"right"==e.data("side")?(e=a+t.scrollLeft(),t.animate({scrollLeft:e})):(e=a-t.scrollLeft(),t.animate({scrollLeft:-e}))}),T(document).on("xstore_compare/removed_product",function(e,t,a,o,r,i,s){if(o&&r<i)setTimeout(function(){x(r,i,s)},1700);else if(clearTimeout(c),c=setTimeout(function(){T(document).trigger("xstore_compare_fragment_refresh",[t])},700),l&&void 0!==etTheme.quickView&&T(e.target.activeElement).parents(".et-quick-view-wrapper").length)etTheme.et_woocommerce.quick_view_opened&&etTheme.closeQuickView()}),T(document).on("xstore_compare/added_product",function(e,o,r,t,a,i,s){if(t&&a<i)setTimeout(function(){g(a,i,s)},1700);else switch(clearTimeout(c),c=setTimeout(function(){T(document).trigger("xstore_compare_fragment_refresh",[o])},700),clearTimeout(n),xstore_compare_params.notify_type){case"alert":etTheme.notify(etConfig.successfullyAdded);break;case"alert_advanced":T.ajax({url:xstore_compare_params.ajaxurl,data:{product_id:r,action:"xstore_get_compare_product_info"},method:"POST",success:function(e){var t=T("<a>",{class:"et-notify-image",href:e.product_link,target:"_self"}).html(e.product_image),e=T("<div>",{class:"et-notify-info"}).html(e.product_title),a=T("<a>",{class:"et-notify-button",href:xstore_compare_params.compare_page_url}).html(xstore_compare_params.view_compare);e.append(a[0].outerHTML),etTheme.notify(t[0].outerHTML+e[0].outerHTML,"info",5e3,!0)}});break;case"mini_compare":let e=T(d).find(".et_b_header-compare.et_element-top-level"),t=T(d).find(".et_b_header-compare.et_element-top-level.et-off-canvas .et-mini-content"),a=T(d).find(".et_b_header-compare.et_element-top-level.et-off-canvas");a.length&&(etTheme.closeQuickView(),etTheme.showHideElementsOnCanvasActions(!0),etTheme.et_global.deny_link_click=!0,T(".et-mobile-panel-wrapper").addClass("outside")),e.addClass("active"),t.addClass("active"),a.addClass("et-content-shown"),n=setTimeout(function(){e.removeClass("active")},1e3)}}),T(document).on("found_variation","form.variations_form",function(e,t){var a=T(e.target).closest(".product").find(".xstore-compare-single");a.length&&(xstore_compare_params.is_multilingual?(a.block({message:null,overlayCSS:{opacity:.6}}),T.ajax({url:xstore_compare_params.ajaxurl,data:{variation_id:t.variation_id,action:"xstore_get_origin_compare_product_variation_id"},method:"POST",success:function(e){i(a,e.variation_id),a.unblock()}})):i(a,t.variation_id))}),T(document).on("reset_data","form.variations_form",function(e){e=T(e.target).closest(".product").find(".xstore-compare-single");e.length&&s(e)}),T(document).on("found_variation","div.st-swatch-in-loop",function(e,t){var a=T(e.target).closest(".product").find(".xstore-compare");a.length&&(xstore_compare_params.is_multilingual?(a.block({message:null,overlayCSS:{opacity:.6}}),T.ajax({url:xstore_compare_params.ajaxurl,data:{variation_id:t.variation_id,action:"xstore_get_origin_compare_product_variation_id"},method:"POST",success:function(e){i(a,e.variation_id),a.unblock()}})):i(a,t.variation_id))}),T(document).on("reset_data","div.st-swatch-in-loop",function(e){e=T(e.target).closest(".product").find(".xstore-compare");e.length&&s(e)}),T(document).on("change",".xstore-compare-form .xstore-compare-quantity .qty",function(){if(clearTimeout(t),0==T(this).val()){let e=T(this).parents("tbody").find('td[data-product_id="'+T(this).parents("td").data("product_id")+'"] .'+m+'[data-action="remove"]');t=setTimeout(function(){e.trigger("click")},1500)}}),o=etTheme.xstore_compare.switch_variation_button=function(e,t){-1===b().indexOf(t)?f(e,JSON.parse(e.attr("data-settings")),"remove"):f(e,JSON.parse(e.attr("data-settings")))},T(document).on("xstore_compare_fragment_refresh",function(e,t){var a;a=t,T.ajax({url:xstore_compare_params.ajaxurl,data:{products:a,products_count:a.length,action:"xstore_compare_fragments"},method:"POST",success:function(e){e&&e.fragments&&T.each(e.fragments,function(e,t){T(e).replaceWith(t)}),a.length<1?(T(".et_b_header-compare").find(".product_list-popup-footer-wrapper").hide(),_&&l&&T.ajax({url:xstore_compare_params.ajaxurl,data:{action:"xstore_empty_compare_page"},method:"POST",success:function(e){e&&e.page_content&&(T(document).find("form.xstore-compare-form").replaceWith(e.page_content),T(document).find(".xstore-compare-share").remove())}})):T(".et_b_header-compare").find(".product_list-popup-footer-wrapper").attr("style",null)}})}))}}(jQuery);