!function(S){"use strict";etTheme.autoinit.XStoreWishlist=etTheme.XStoreWishlist=function(){if("undefined"==typeof Cookies)return;etTheme.xstore_wishlist={};var h="xstore-wishlist",u=xstore_wishlist_params.wishlist_id,i=null,_=0,n=0,l=0,d=etTheme.et_global.w_width<etTheme.et_global.mob_header_start||etConfig.layoutSettings.is_mobile?S(".mobile-header-wrapper"):S(".header-wrapper"),c=S("body").hasClass("xstore-wishlist-page"),m=S("body").hasClass("xstore-wishlist-owner");let p=S(".elementor-location-header").length?".elementor-widget-theme-etheme_wishlist":".et_b_header-wishlist";var e=0,f=0,g=`
<svg viewBox="0 0 24 22" class="xstore-wishlist-animated-heart">
<path d="M23 6.6C23 12 17.1 17.5 12 21 6.9 17.5 1 12 1 6.6 1 3.5 3.5 1 6.5 1c2.3 0 4.7 1.5 5.5 3.5.8-2 3.2-3.5 5.5-3.5 3 0 5.5 2.5 5.5 5.6z"></path>
</svg>`,w=(xstore_wishlist_params.ajax_fragments&&(S(document).on("xstore_wishlist_initialized",function(t,e){S(document).trigger("xstore_wishlist_fragment_refresh",[e])}),S(window).on("pageshow",function(t){t.originalEvent.persisted&&(S(".et_b_wishlist-dropdown").empty(),S(document).trigger("xstore_wishlist_fragment_refresh",[y()]))}),S(document).on("xstore_wishlist_force_fragment_refresh",function(){S(".et_b_wishlist-dropdown").empty(),S(document).trigger("xstore_wishlist_fragment_refresh",[y()])})),S(document).on("click","."+h,function(t,e){t.preventDefault();var i=S(this).attr("data-action"),s=S(this).attr("data-id"),o=S(this).data("settings")||{},a=S(this).hasClass(h+"-redirect"),t=e&&!!e.is_multiple,r={},n=(t&&(r={is_multiple:!0,i:e.i,max:e.max,buttons:e.buttons}),S(this).parents("td"));switch((t||n)&&(r.table_row=S(this).parents("tr")),i){case"add":S(this).addClass("processing"),xstore_wishlist_params.animated_hearts&&(clearTimeout(f),S(this).prepend('<span class="xstore-wishlist-animated-hearts et-icon">'+g+g+g+g+g+"</span>")),w(S(this),o,i);var l,[d,c={}]=[s,r];d=parseInt(d),-1===T().indexOf(d)&&((l=y()).push(JSON.stringify({id:d,time:Math.floor((new Date).getTime()/1e3)})),etTheme.setCookie(u,l.join("|"),xstore_wishlist_params.days_cache),c.table_row&&!m&&(c.table_row.css({position:"relative",zoom:1}),c.table_row.find("td:last-child").block({message:null,overlayCSS:{opacity:.6}}).attr("style",null),c.table_row.find("td:last-child").unblock(),setTimeout(function(){c.table_row.attr("style",null)},500)),xstore_wishlist_params.is_loggedin&&(clearTimeout(_),_=setTimeout(function(){C(l.join("|"))},1500)),S(document).find("."+h+"[data-id="+d+"]").each(function(){S(this).addClass("processing"),w(S(this),JSON.parse(S(this).attr("data-settings")))}),c.is_multiple?(c.i++,S(document).trigger("xstore_wishlist/adding_product",[l,d,c.is_multiple,c.i,c.max,c.buttons])):S(document).trigger("xstore_wishlist/adding_product",[l,d])),a&&S(this).addClass(h+"-redirect-ready");break;case"remove":a&&S(this).hasClass(h+"-redirect-ready")?window.location.href=xstore_wishlist_params.wishlist_page_url:(m||n||S(this).addClass("processing"),w(S(this),o,i),k(s,r))}}),function(t,e,i="add"){"add"==i?(e.removeText&&(t.find(".button-text").text(e.removeText),t.find(".mt-mes").text(e.removeText)),e.iconRemove&&t.find(".et-icon").addClass(e.iconRemove).removeClass(e.iconAdd),t.attr("data-action","remove"),t.attr("href",t.attr("href").replace("add_to_wishlist","remove_wishlist"))):(e.addText&&(t.find(".button-text").text(e.addText),t.find(".mt-mes").text(e.addText)),e.iconAdd&&t.find(".et-icon").addClass(e.iconAdd).removeClass(e.iconRemove),t.attr("data-action","add"),t.attr("href",t.attr("href").replace("remove_wishlist","add_to_wishlist"))),t.removeClass(h+"-redirect-ready"),"add"!=i?setTimeout(function(){t.removeClass("processing in-process"),xstore_wishlist_params.animated_hearts&&t.addClass("xstore-wishlist-has-animation")},300):xstore_wishlist_params.animated_hearts?(clearTimeout(f),f=setTimeout(function(){"add"==i?t.removeClass("xstore-wishlist-has-animation"):t.addClass("xstore-wishlist-has-animation"),t.find(".xstore-wishlist-animated-hearts").remove(),t.removeClass("processing in-process")},1e3)):setTimeout(function(){t.removeClass("processing in-process")},300)});function x(o,a,r){o<a?S(r[o]).hasClass("processing")||(S(r[o]).trigger("click").addClass("processing"),S(document.body).on("added_to_cart",function(t,e,i,s){s.attr("data-product_id")==S(r[o]).attr("data-product_id")&&(s.removeClass("processing in-process"),x(++o,a,r))})):S(r[o-1]).parent().hasClass("keeper-all-products-buttons")&&S(p).find("li").unblock()}function v(t,e,i){t<e&&(S(i[t]).hasClass("processing")||S(i[t]).trigger("click",{is_multiple:!0,i:t,max:e,buttons:i}).addClass("processing"))}function b(t,e,i){var s;t<e&&(s=m?"in-process":"processing",S(i[t]).hasClass(s)||S(i[t]).trigger("click",{is_multiple:!0,i:t,max:e,buttons:i}).addClass(s))}function y(){var t;return i||(S.ajax({url:xstore_wishlist_params.ajaxurl,dataType:"json",method:"POST",data:{cookie_key:u,action:"xstore_get_user_wishlist"},success:function(t){return i=t.products.products.map(t=>JSON.stringify(t))},error:function(){},complete:function(){}}),(t=etTheme.getCookie(u))?t.split("|"):[])}function T(){var t;return i?i.map(t=>JSON.parse(t).id):(S.ajax({url:xstore_wishlist_params.ajaxurl,dataType:"json",method:"POST",data:{cookie_key:u,action:"xstore_get_user_wishlist"},success:function(t){var e=t.products.products;return i=t.products.products.map(t=>JSON.stringify(t)),e},error:function(){},complete:function(){}}),(t=etTheme.getCookie(u))&&S.isArray(t)?t.split("|").map(t=>JSON.parse(t).id):[])}S(document).on("click",".xstore-miniwishlist-remove",function(t){t.preventDefault(),k(S(this).data("id"),{miniwishlist:!0,liItem:S(this).parents("li")})}),S(".xstore-wishlist-table :checkbox").on("click",function(){var t;"product-bulk-select"==S(this).attr("name")?S(this).closest("table").children("tbody").find(":checkbox").prop("checked",S(this).prop("checked")):(t=S(this).closest("tbody").find(":checkbox").filter(":visible:enabled").not(":checked"),S(this).closest("table").children("thead, tfoot").find(":checkbox").prop("checked",function(){return 0===t.length}))}),S(document).on("click",".xstore-wishlist-form .add-all-products",function(t){t.preventDefault(),confirm(xstore_wishlist_params.confirmQuestion)&&(etConfig.ajaxProductAddedNotify.type="alert",(t=S(this).closest(".xstore-wishlist-form").find("table").children("tbody").find(":checkbox").parents("tr").find(".ajax_add_to_cart")).length<1?alert(xstore_wishlist_params.no_products_available):x(0,t.length,t))}),S(document).on("click",p+" .add-all-products",function(t){var e;t.preventDefault(),confirm(xstore_wishlist_params.confirmQuestion)&&(etConfig.ajaxProductAddedNotify.type="alert",(e=(t=S(this).parents(p)).find(".keeper-all-products-buttons .ajax_add_to_cart")).length?(t.find("li").block({message:null,overlayCSS:{opacity:.6}}),x(0,e.length,e)):e.length<1&&alert(xstore_wishlist_params.no_products_available))}),S(".xstore-wishlist-actions").on("click",function(t){t.preventDefault(),etConfig.ajaxProductAddedNotify.type="alert";var e=S(this).closest(".xstore-wishlist-form").find("table").children("tbody").find(":checkbox:checked").parents("tr");if(e.length<1)alert(xstore_wishlist_params.no_active_checkbox);else if(confirm(xstore_wishlist_params.confirmQuestion))switch(S(this).parent().find("select").val()){case"add":(s=e.find(".ajax_add_to_cart")).length<1?alert(xstore_wishlist_params.no_products_available):x(0,s.length,s);break;case"add_wishlist":(s=e.find("."+h+'[data-action="add"]')).addClass("in-process"),v(0,s.length,s);break;case"remove":var i,s=e.find("."+h+'[data-action="remove"]');m?(i=S(this).closest(".xstore-wishlist-form").find("table").children("tbody").find("tr"),s.length==i.find("."+h).length?(S.each(i,function(){S(this).css({position:"relative",zoom:1}),S(this).find("td:last-child").block({message:null,overlayCSS:{opacity:.6}}).attr("style",null)}),etTheme.setCookie(u,"",0),xstore_wishlist_params.is_loggedin&&C([]),S(document).trigger("xstore_wishlist_fragment_refresh",[[]])):b(0,s.length,s)):(s.addClass("in-process"),b(0,s.length,s))}});etTheme.xstore_wishlist.force_init_active_wishlist=function(){S.ajax({url:xstore_wishlist_params.ajaxurl,dataType:"json",method:"POST",data:{cookie_key:u,action:"xstore_get_user_wishlist"},success:function(t){i=t.products.products.map(t=>JSON.stringify(t)),S(document).trigger("xstore_wishlist_initialized",[i])},error:function(){},complete:function(){}})};function k(t,e={}){t=parseInt(t);var i=y(),s=i.map(t=>JSON.parse(t).id).indexOf(t);-1<s&&(i.splice(s,1),etTheme.setCookie(u,i.join("|")),e.table_row&&(e.table_row.css({position:"relative",zoom:1}),e.table_row.find("td:last-child").block({message:null,overlayCSS:{opacity:.6}}).attr("style",null),m?setTimeout(function(){e.table_row.remove()},1500):(e.table_row.find("td:last-child").unblock(),setTimeout(function(){e.table_row.attr("style",null)},500))),S(document).find("."+h+"[data-id="+t+"]").each(function(){e.table_row||S(this).addClass("processing"),w(S(this),JSON.parse(S(this).attr("data-settings")),"remove")}),e.miniwishlist&&!e.liItem.parents(".etheme-elementor-off-canvas").length&&e.liItem.block({message:null,overlayCSS:{opacity:.6}}),xstore_wishlist_params.is_loggedin&&(clearTimeout(_),_=setTimeout(function(){C(i.join("|"))},1500)),e.is_multiple?(e.i++,S(document).trigger("xstore_wishlist/removing_product",[i,t,e.is_multiple,e.i,e.max,e.buttons])):S(document).trigger("xstore_wishlist/removing_product",[i,t]))}function C(t){S.ajax({url:xstore_wishlist_params.ajaxurl,dataType:"json",method:"POST",data:{action:"xstore_update_user_wishlist",cookie_key:u,products:t},success:function(t){},error:function(){},complete:function(){}})}function s(t,e){t.length&&(e?(t.attr("data-o_id")||t.attr("data-o_id",t.data("id")),t.attr("data-id",e)):void 0!==t.attr("data-o_id")&&t.attr("data-id",t.attr("data-o_id")),a(t,parseInt(e)))}function o(t){void 0!==t.attr("data-o_id")&&(t.attr("data-id",t.attr("data-o_id")),a(t,t.attr("data-o_id")))}S(document).on("xstore_wishlist/removing_product",function(t,e,i,s,o,a,r){if(s&&o<a)setTimeout(function(){b(o,a,r)},1700);else{if(clearTimeout(l),l=setTimeout(function(){S(document).trigger("xstore_wishlist_fragment_refresh",[e])},700),c&&void 0!==etTheme.quickView&&S(t.target.activeElement).parents(".et-quick-view-wrapper").length){let t=S(document).find(".xstore-wishlist-form ."+h+"[data-id="+i+"]").parents("tr");t.css({position:"relative",zoom:1}),t.find("td:last-child").block({message:null,overlayCSS:{opacity:.6}}).attr("style",null),m?setTimeout(function(){t.remove()},1500):(t.find("td:last-child").unblock(),setTimeout(function(){t.attr("style",null)},500)),etTheme.et_woocommerce.quick_view_opened&&etTheme.closeQuickView()}S(document).trigger("xstore_wishlist/removed_product")}}),S(document).on("xstore_wishlist/adding_product",function(t,s,o,e,i,a,r){if(e&&i<a)setTimeout(function(){v(i,a,r)},1700);else switch(clearTimeout(l),l=setTimeout(function(){S(document).trigger("xstore_wishlist_fragment_refresh",[s])},700),clearTimeout(n),S(document).trigger("xstore_wishlist/added_product"),xstore_wishlist_params.notify_type){case"alert":etTheme.notify(etConfig.successfullyAdded);break;case"alert_advanced":S.ajax({url:xstore_wishlist_params.ajaxurl,data:{product_id:o,action:"xstore_get_wishlist_product_info"},method:"POST",success:function(t){var e=S("<a>",{class:"et-notify-image",href:t.product_link,target:"_self"}).html(t.product_image),t=S("<div>",{class:"et-notify-info"}).html(t.product_title),i=S("<a>",{class:"et-notify-button",href:xstore_wishlist_params.wishlist_page_url}).html(xstore_wishlist_params.view_wishlist);t.append(i[0].outerHTML),etTheme.notify(e[0].outerHTML+t[0].outerHTML,"info",5e3,!0)}});break;case"mini_wishlist":let t=S(d).find(p+".et_element-top-level"),e=S(d).find(p+".et_element-top-level.et-off-canvas .et-mini-content"),i=S(d).find(p+".et_element-top-level.et-off-canvas");i.length&&(etTheme.closeQuickView(),etTheme.showHideElementsOnCanvasActions(!0),etTheme.et_global.deny_link_click=!0,S(".et-mobile-panel-wrapper").addClass("outside")),t.addClass("active"),e.addClass("active"),i.addClass("et-content-shown"),n=setTimeout(function(){t.removeClass("active")},1e3)}}),S(document).on("found_variation","form.variations_form",function(t,e){var i=S(t.target).closest(".product").find(".xstore-wishlist-single");i.length&&(xstore_wishlist_params.is_multilingual?(i.block({message:null,overlayCSS:{opacity:.6}}),S.ajax({url:xstore_wishlist_params.ajaxurl,data:{variation_id:e.variation_id,action:"xstore_get_origin_wishlist_product_variation_id"},method:"POST",success:function(t){s(i,t.variation_id),i.unblock()}})):s(i,e.variation_id))}),S(document).on("reset_data","form.variations_form",function(t){t=S(t.target).closest(".product").find(".xstore-wishlist-single");t.length&&o(t)}),S(document).on("found_variation","div.st-swatch-in-loop",function(t,e){var i=S(t.target).closest(".product").find(".xstore-wishlist");i.length&&(xstore_wishlist_params.is_multilingual?(i.block({message:null,overlayCSS:{opacity:.6}}),S.ajax({url:xstore_wishlist_params.ajaxurl,data:{variation_id:e.variation_id,action:"xstore_get_origin_wishlist_product_variation_id"},method:"POST",success:function(t){s(i,t.variation_id),i.unblock()}})):s(i,e.variation_id))}),S(document).on("reset_data","div.st-swatch-in-loop",function(t){t=S(t.target).closest(".product").find(".xstore-wishlist");t.length&&o(t)}),S(document).on("change",".xstore-wishlist-form .xstore-wishlist-quantity .qty",function(){if(clearTimeout(e),0==S(this).val()){let t=S(this).parents("tr").find("."+h+'[data-action="remove"]');e=setTimeout(function(){t.trigger("click")},1500)}});var a=etTheme.xstore_wishlist.switch_variation_button=function(t,e){-1===T().indexOf(e)?w(t,JSON.parse(t.attr("data-settings")),"remove"):w(t,JSON.parse(t.attr("data-settings")))};const r=()=>{etTheme.xstore_wishlist.force_init_active_wishlist(),t.forEach(t=>window.removeEventListener(t,r,{passive:!0}))},t=["mousemove","mousedown","keydown","touchstart","wheel"];t.forEach(t=>window.addEventListener(t,r,{passive:!0})),S(document).on("xstore_wishlist_fragment_refresh",function(t,e){var i;i=e,S.ajax({url:xstore_wishlist_params.ajaxurl,data:{products:i,products_count:i.length,action:"xstore_wishlist_fragments"},method:"POST",success:function(t){t&&t.fragments&&S.each(t.fragments,function(t,e){S(t).replaceWith(e)}),i.length<1?(S(p).find(".product_list-popup-footer-wrapper").hide(),m&&c&&S.ajax({url:xstore_wishlist_params.ajaxurl,data:{action:"xstore_empty_wishlist_page"},method:"POST",success:function(t){t&&t.page_content&&(S(document).find("form.xstore-wishlist-form").replaceWith(t.page_content),S(document).find(".xstore-wishlist-share").remove())}})):S(p).find(".product_list-popup-footer-wrapper").attr("style",null),S(document).trigger("xstore_wishlist_fragment_refreshed",[i])}})})}}(jQuery);