class Trustpilot extends HTMLElement{constructor(){super(),document.querySelectorAll(".footer-bottom-pane-wrap trustpilot-summary").length<2&&(this.shouldDefinePlacement=JSON.parse(this.dataset.definePlacement),this.isMobile=window.innerWidth<1025,this.definePlacement(),this.buildSelecotrs(),this.fetchData())}static getElementName(){return"trustpilot-summary"}get companyName(){return"www.perfumania.com"}definePlacement(){const desktopTpWrapper=document.querySelector("footer.footer-wrapper .footer-bottom-pane-wrap");!this.shouldDefinePlacement||this.isMobile||!desktopTpWrapper||desktopTpWrapper.prepend(this)}buildSelecotrs(){this.tpScore=this.querySelector("[data-tp-score]"),this.tpReview=this.querySelector("[data-tp-reviews]"),this.globalTpSrOnly=document.querySelectorAll("[data-tp-sr-only]")}async fetchData(){try{const data=await(await fetch(`https://api.trustpilot.com/v1/business-units/find?name=${this.companyName}`,{headers:{apikey:"Bma1O3hzcwubG63AcMXW8wTysjZoFllM","Content-Type":"application/json"}})).json();this.data=data,this.render(),this.updateGlobalSrOnlyText()}catch(err){console.log(err)}}updateGlobalSrOnlyText(){if(!this.data)return;const srText=`TrustScore ${this.data.score.trustScore} ${this.data.numberOfReviews.total} reviews`,reviewText="TrustScore "+this.data.score.trustScore+" stars out of 5 stars rating on Trustpilot. Based on "+this.data.numberOfReviews.total+" reviews Opens in a new window ";this.globalTpSrOnly=document.querySelectorAll("[data-tp-sr-only]"),this.globalTpSrOnly.forEach(elem=>{elem.textContent=reviewText;const parentLink=elem.closest("a");parentLink&&(parentLink.setAttribute("aria-label",srText),parentLink.setAttribute("aria-description",reviewText))})}render(){if(!this.data||!this.data.status||this.data.status!=="active")return;this.tpScore.innerHTML="TrustScore "+this.data.score.trustScore+"",this.tpReview.innerHTML=""+this.data.numberOfReviews.total+" reviews";const srText=`TrustScore ${this.data.score.trustScore} ${this.data.numberOfReviews.total} reviews`,reviewText="TrustScore "+this.data.score.trustScore+" stars out of 5 stars rating on Trustpilot. Based on "+this.data.numberOfReviews.total+" reviews Opens in a new window ",link=this.querySelector("a");link.setAttribute("aria-label",srText),link.setAttribute("aria-description",reviewText)}}customElements.define(Trustpilot.getElementName(),Trustpilot); //# sourceMappingURL=/cdn/shop/t/731/assets/trustpilot.js.map?v=146809823459659428161750335990