;(()=>{"use strict";var e;(e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})({}),(e=jQuery)(document).ready(function(){function o(){const o=e("#eaw-viewed-products");o.hasClass("slick-initialized")&&o.slick("unslick");const{arrows:t,autoplay:r,autoplaySpeed:s,dots:i,infinite:a,pauseOnHover:d,slidesToShow:n}=ccpeaw.recentViewSlider;o.slick({dots:"1"==i,arrows:"1"==t,prevArrow:'<button class="slick-arrow slick-prev eaw-icon-arrow"></button>',nextArrow:'<button class="slick-arrow slick-next eaw-icon-arrow"></button>',infinite:"1"==a,autoplay:"1"==r,slidesToShow:parseInt(n)||3,autoplaySpeed:parseInt(s)||300,slidesToScroll:1,pauseOnHover:"1"==d,adaptiveHeight:!0,responsive:[{breakpoint:1024,settings:{slidesToShow:3,slidesToScroll:1}},{breakpoint:768,settings:{slidesToShow:2,slidesToScroll:1}},{breakpoint:480,settings:{slidesToShow:1,slidesToScroll:1}}]})}e("#eaw-viewed-products").length&&function(){if("undefined"==typeof wp||!wp.ajax||"undefined"==typeof ccpeaw)return void console.error("Required global objects are not defined.");const t=e(".eaw-viewed-products-wrapper").data("current_product_id"),r=e("#eaw-viewed-products");if(!r.length)return void console.warn("#eaw-viewed-products not found in DOM.");const s=e('<div class="eaw-viewed-products-preloader"><img src="'+ccpeaw.loader+'" alt="Loading..."></div>');r.html(s),wp.ajax.post("ccpeawGetViewedProducts",{eaw_nonce:ccpeaw.nonce,currentProductId:t}).done(function(e){e.success&&e.html?(r.html(e.html),r.removeClass("eaw-viewed-products-loading"),o()):r.html('<p class="eaw-viewed-products-error-message">No products found.</p>')}).fail(function(){r.html('<p class="eaw-viewed-products-error-message">No products found. Will be listed while visiting new products.</p>')}).always(function(){s.remove(),r.removeClass("eaw-viewed-products-loading")})}(),e(document).on("click",".eaw-remove-product",function(){const t=e(this).data("product-id"),r=e("#eaw-viewed-products"),s=e(this).closest(".eaw-recently-viewed-product"),i=r.parent(),a=e('<div class="eaw-viewed-products-preloader"><img src="'+ccpeaw.loader+'" alt="Removing..."></div>');s.append(a).addClass("eaw-viewed-products-loading"),wp.ajax.post("ccpeawDeleteViewedProducts",{eaw_nonce:ccpeaw.nonce,productId:t}).done(function(){s.remove(),o()}).fail(function(){Swal.fire({icon:"error",title:"Error",text:"Failed to remove product."})}).always(function(){a.remove(),i.removeClass("eaw-viewed-products-loading")})})})})();