!function(e){woodmartThemeModule.singleProdReviews=function(){let i=e("#reviews");function t(){let i=e(".wd-rating-summary-cont").find(".wd-active");return i.length>0?i.find(".wd-rating-label").data("rating").toString():""}function o(o=!1,n=!1){let s=e(".commentlist"),r=s.length>0?s.data("reviews-columns"):{},d={action:"woodmart_filter_review",rating:t(),product_id:i.data("product-id"),order_by:0<i.find(".wd-reviews-sorting-select :checked").length?i.find(".wd-reviews-sorting-select :checked").val():"newest",only_images:e("#wd-with-image-checkbox").is(":checked"),summary_criteria_ids:woodmart_settings.summary_criteria_ids};r.hasOwnProperty("reviews_columns")&&(d.reviews_columns=r.reviews_columns),r.hasOwnProperty("reviews_columns_tablet")&&(d.reviews_columns_tablet=r.reviews_columns_tablet),r.hasOwnProperty("reviews_columns_mobile")&&(d.reviews_columns_mobile=r.reviews_columns_mobile),o&&(d.rating="",d.only_images=!1),e.ajax({url:woodmart_settings.ajaxurl,method:"GET",data:d,beforeSend:function(){let e=i.find("#comments .commentlist");i.find("#comments .wd-loader-overlay").addClass("wd-loading"),n&&i.find(".wd-rating-summary-wrap .wd-loader-overlay").addClass("wd-loading"),e.removeClass("wd-active"),e.removeClass("wd-in")},complete:function(){i.find("#comments .wd-loader-overlay").removeClass("wd-loading"),n&&i.find(".wd-rating-summary-wrap .wd-loader-overlay").removeClass("wd-loading"),setTimeout(function(){i.find("#comments .commentlist").addClass("wd-active")},50),setTimeout(function(){i.find("#comments .commentlist").addClass("wd-in")},100)},success:function(t){(!d.rating??!d.only_images)&&e(".wd-reviews-sorting-clear").addClass("wd-hide"),t.title&&i.find(".woocommerce-Reviews-title").html(t.title),e(document).trigger("woodmart_reviews_sorting_clear",d),t.content&&i.find("#comments .wd-reviews-content").html(t.content),woodmartThemeModule.hasOwnProperty("photoswipeImages")&&"function"==typeof woodmartThemeModule.photoswipeImages&&woodmartThemeModule.photoswipeImages()},error:function(e){console.error(e)}})}i.off("click",".wd-rating-summary-item").on("click",".wd-rating-summary-item",function(){if(!woodmart_settings.is_rating_summary_filter_enabled||e(this).hasClass("wd-empty"))return;e(this).siblings().removeClass("wd-active"),e(this).toggleClass("wd-active");let i=t();e(document).on("woodmart_reviews_sorting_clear",function(t,o){i?e(".wd-reviews-sorting-clear").removeClass("wd-hide"):e(".wd-reviews-sorting-clear").addClass("wd-hide")}),o(!1,!0)}).off("click",".wd-reviews-sorting-clear").on("click",".wd-reviews-sorting-clear",function(i){i.preventDefault(),e(".wd-rating-summary-item").each(function(){e(this).removeClass("wd-active")}),e(document).on("woodmart_reviews_sorting_clear",function(i,t){e(".wd-reviews-sorting-clear").addClass("wd-hide")}),e("#wd-with-image-checkbox").prop("checked",!1),o(!0,!0)}).off("click","#wd-with-image-checkbox").on("click","#wd-with-image-checkbox",function(){let i=e(this).is(":checked");e(document).on("woodmart_reviews_sorting_clear",function(t,o){i?e(".wd-reviews-sorting-clear").removeClass("wd-hide"):0===o.rating.length&&e(".wd-reviews-sorting-clear").addClass("wd-hide")}),o()}).off("change",".wd-reviews-sorting-select").on("change",".wd-reviews-sorting-select",function(){o()})},e(document).ready(function(){woodmartThemeModule.singleProdReviews()}),window.addEventListener("wdOpenDescHiddenTab",function(e){woodmartThemeModule.hasOwnProperty("singleProdReviews")&&woodmartThemeModule.singleProdReviews()})}(jQuery);