!function(){"use strict";var e={init:function(){this.show(),this.remove(),this.ratings(),this.votes(),this.reply()},show:function(){document.querySelectorAll(".edd-review-vote").forEach(function(e){e.style.display=""})},remove:function(){document.querySelectorAll(".edd_show_if_no_js").forEach(function(e){e.remove()})},ratings:function(){var e=document.querySelector(".edd-reviews-star-rating-container");if(e){var t=e.querySelectorAll(".edd-reviews-star-rating"),n=e.querySelector("#edd-reviews-star-rating"),r=0;t.forEach(function(e){e.addEventListener("mouseenter",function(){i(parseInt(this.getAttribute("data-rating"),10))}),e.addEventListener("click",function(){i(r=parseInt(this.getAttribute("data-rating"),10)),n&&(n.value=r)})}),e.addEventListener("mouseleave",function(){i(r)})}function i(e){t.forEach(function(t){parseInt(t.getAttribute("data-rating"),10)<=e?(t.classList.remove("dashicons-star-empty"),t.classList.add("dashicons-star-filled")):(t.classList.remove("dashicons-star-filled"),t.classList.add("dashicons-star-empty"))})}},votes:function(){document.querySelectorAll("span.edd-reviews-voting-buttons a").forEach(function(e){e.addEventListener("click",function(e){e.preventDefault();var t=new FormData;t.append("action","edd_reviews_process_vote"),t.append("security",edd_reviews_params.edd_voting_nonce),t.append("review_vote",this.dataset.eddReviewsVote),t.append("comment_id",this.dataset.eddReviewsCommentId),t.append("edd_reviews_ajax",!0);var n=this.closest(".edd-review-review-helpful"),r=document.createElement("img");r.src=edd_reviews_params.ajax_loader,r.className="edd-reviews-vote-ajax",n.after(r),fetch(edd_reviews_params.ajax_url,{method:"POST",credentials:"same-origin",body:t}).then(function(e){return e.json()}).then(function(e){if(e.data){n.innerHTML=e.data;var t=n.querySelector(".edd-review-vote");t&&(t.style.display="")}}).finally(function(){var e=document.querySelector(".edd-reviews-vote-ajax");e&&e.remove()})})})},reply:function(){document.querySelectorAll(".edd_review .comment-reply-link").forEach(function(e){e.addEventListener("click",function(e){e.preventDefault();var t=document.getElementById("edd-reviews-respond"),n=document.getElementById("edd-reviews-reply");t&&(t.style.display="none"),n&&(n.style.display="")})});var e=document.querySelector(".edd-reviews-form #cancel-comment-reply-link");e&&e.addEventListener("click",function(e){e.preventDefault();var t=document.getElementById("edd-reviews-respond"),n=document.getElementById("edd-reviews-reply");t&&(t.style.display=""),n&&(n.style.display="none")})}};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){e.init()}):e.init()}();