const addEventListenerStamped=(el,eventName,handler)=>{el.addEventListener?el.addEventListener(eventName,handler):el.attachEvent(`on${eventName}`,()=>{handler.call(el)})};function setElementProperties(element,properties){Object.assign(element,properties)}function setElementStyle(element,styles){Object.assign(element.style,styles)}function moveAndStyleWriteAReviewSection(messageContainer,headerContainer,writeAReviewContainer,writeAReviewText,reviewForm){messageContainer.insertAdjacentElement("beforeend",writeAReviewContainer),messageContainer.classList.add("flex","flex-col","items-center"),writeAReviewContainer.classList.add("m-auto","flex","p-4","text-center"),setElementProperties(writeAReviewText,{innerText:"Write the first review!"}),setElementStyle(headerContainer,{display:"none"}),messageContainer.insertAdjacentElement("beforeend",reviewForm)}function addAverageRatingText(overview){const averageRating=document.createElement("p");averageRating.className="uppercase m-0 text-left px-4",averageRating.textContent="Average rating",overview.insertAdjacentElement("beforeend",averageRating)}function updateSummary(){const stampedHeader=document.querySelector(".stamped-header"),sectionTitle=document.getElementById("reviews-container-title"),leftHeader=document.querySelector(".stamped-header-left"),rightHeader=document.querySelector(".stamped-header-right"),overview=document.querySelector(".summary-overview"),totalReviewsDisplay=document.querySelector(".stamped-summary .stamped-summary-text"),summary=document.querySelector(".stamped-summary"),writeAReviewContainer=document.querySelector(".stamped-summary-actions"),writeAReviewButton=document.querySelector(".stamped-summary-actions-newreview"),beTheFirstToWriteAReview=document.querySelector(".stamped-empty-state div"),reviewForm=document.querySelector(".new-review-form"),stampedMessages=document.querySelector(".stamped-messages"),reviews=parseInt(totalReviewsDisplay.dataset.count,10);reviews>0&&(sectionTitle.innerText="See What Others Had to Say"),addAverageRatingText(overview),totalReviewsDisplay.innerHTML=`
${reviews}

Total reviews

`,leftHeader.appendChild(totalReviewsDisplay),stampedHeader.insertAdjacentElement("beforeend",rightHeader),reviews===0?moveAndStyleWriteAReviewSection(stampedMessages,stampedHeader,writeAReviewContainer,writeAReviewButton,beTheFirstToWriteAReview,reviewForm):(summary.insertAdjacentElement("beforeend",writeAReviewContainer),leftHeader.appendChild(writeAReviewContainer)),leftHeader.classList.add("justify-between"),totalReviewsDisplay.style.display="flex",totalReviewsDisplay.style.justifyContent="center"}function updateCarousel(){const rightHeader=document.querySelector(".stamped-header-right"),carouselPhotoCount=document.querySelectorAll(".stamped-photos-carousel .stamped-photo").length,carousel=document.querySelector(".stamped-photos-carousel div");carousel.classList.add("flex","w-full","inner-carousel"),carousel.style.overflowX="scroll",carouselPhotoCount===0&&(rightHeader.style.display="none")}function updatePhotoResolution(){const photos=document.querySelectorAll(".stamped-photos-carousel .stamped-photo"),lowRes="tr=h-180",hiRes="tr=h-900";photos.forEach(photo=>{const currentBackground=photo.style.background;if(currentBackground.includes(lowRes)){const newBackground=currentBackground.replace(lowRes,hiRes);setElementStyle(photo,{background:newBackground})}})}function convertRadioIntoDropdown(question,selector,children){question.classList.add("stamped-dropdown");for(let i=1;i{for(let i=1;i{const questionText=question.firstChild.innerText;if(question.dataset.type==="radio"){const selector=document.createElement("select"),children=question.querySelectorAll("label"),selectFromDropdown=document.createElement("option");question.classList.add("stamped-question-grid"),question.firstChild.classList.add("question"),selectFromDropdown.innerText="SELECT FROM DROPDOWN",selector.append(selectFromDropdown),questionText!=="How did the item fit?"&&convertRadioIntoDropdown(question,selector,children)}})}function updateFormFieldText(){const form=document.querySelector(".stamped-content .new-review-form"),rating=document.querySelector(".stamped-form-review-rating"),headline=document.querySelector(".stamped-form-review-title"),body=document.querySelector(".stamped-form-review-body");form.style.border="none",rating.querySelector("label").innerText="Rate this Product",headline.querySelector("label").innerText="Headline",headline.querySelector("input").placeholder="Sum up your review",body.querySelector("label").innerText="Write Your Review",body.querySelector(".stamped-form-input textarea").placeholder="Give us the deets!",document.querySelectorAll(".stamped-form-custom-question").forEach(question=>{const label=question.querySelector("label");switch(label.innerText){case"What size did you wear?":label.innerText="What size did you buy?";break;case"Which of the following most closely matches how you would describe your body?":label.innerText="Which of the following most closely resembles your body type?";break;case"How did the item fit?":label.innerText="How did this item fit?";break;default:break}})}function updateOptionalFieldText(){document.querySelectorAll(".stamped-form-custom-question label").forEach(field=>{if(field.textContent==="Weight (lbs)"||field.textContent==="Bust Size"){const breakTag=field.querySelector("br"),optionalSpan=document.createElement("span");optionalSpan.textContent=" OPTIONAL",optionalSpan.style.fontWeight="400",breakTag.insertAdjacentElement("beforebegin",optionalSpan)}})}const stampedToggleTab=e=>{const heading=e.currentTarget,container=heading.nextElementSibling;container.classList.contains("open-tab")?(container.classList.remove("open-tab"),container.classList.remove("visible"),heading.querySelector(".tab-icon").innerText="+",container.setAttribute("aria-hidden","true")):(container.classList.add("open-tab"),container.classList.add("visible"),heading.querySelector(".tab-icon").innerText="\u2013",container.setAttribute("aria-hidden","false"))};function createReviewGuidelines(){const rating=document.querySelector(".stamped-form-review-rating"),tabContainer=document.createElement("div"),reviewGuidelines=`
Tips for Writing a Helpful Review

1. A picture\u2019s worth 1000 words. Photos are great! Just make sure that you don\u2019t include any images of minors in your upload, since the pictures are published on the web. Pro wedding pics, selfies, and anything in between can help tell a complete story for brides and bridesmaids.

2. Didn\u2019t love it? Tell us why and be descriptive (not destructive), so we can do something about it. While writing your review, keep in mind that we really do read every review and do our best to make adjustments accordingly.

3. We also love compliments, so if you loved your items, let us know.

4. The more context the better! We\u2019ve included a handful of optional questions on our review form that can serve as valuable metrics to customers with similar body types and dress sizes.

`;tabContainer.className="stamped-form-review-guidelines tab-container",tabContainer.innerHTML=reviewGuidelines,rating.after(tabContainer),tabContainer.querySelectorAll(".tab-heading").forEach(heading=>{heading.addEventListener("click",stampedToggleTab),heading.addEventListener("keydown",event=>{(event.key==="Enter"||event.key===" ")&&stampedToggleTab(event)})})}function styleAddPhotosButton(){const btn=document.querySelector(".stamped-file-uploader-btn");btn.innerHTML=`

Add photos or videos Optional

Pictures are super helpful for other shoppers!

+
`,btn.style.cssText=` display: block; text-align: left; margin: 0; padding-top: 0; color: #464646; border: 0; border-radius: 4px !important; max-width: 400px; `}function formatDate(dateElement){let dateText=dateElement.innerText;if(!dateText.includes(",")){const indexOfLastWhiteSpace=dateText.lastIndexOf(" ");dateText=`${dateText.substring(0,indexOfLastWhiteSpace)}, ${dateText.substring(indexOfLastWhiteSpace+1)}`,setElementProperties(dateElement,{innerText:dateText})}}function updateDateOfReview(){document.querySelectorAll(".stamped-review").forEach(review=>{const name=review.querySelector(".author"),date=review.querySelector(".created"),originalDateText=date.innerText;if(originalDateText.includes("/")){const dateParts=originalDateText.split("/"),displayDate=new Date(dateParts[2],dateParts[0]-1,dateParts[1]).toDateString().split(" ").slice(1).join(" ");date.innerText=displayDate,name.after(date)}formatDate(date)})}function updateReviewAttributes(){document.querySelectorAll(".stamped-review").forEach(review=>{const reviewOptionsContainer=review.querySelector(".stamped-review-options"),reviewOptions=review.querySelectorAll(".stamped-review-options li"),reviewProduct=review.querySelector(".stamped-review-product");reviewOptions.forEach(option=>{const optionValue=option.dataset.value,strongElement=option.querySelector("strong");switch(optionValue){case"how-did-the-item-fit":case"overall-fit":setElementProperties(strongElement,{innerText:"OVERALL FIT:"});break;case"which-of-the-following-most-closely-matches-how-you-would-describe-your-body":case"body-type":setElementProperties(strongElement,{innerText:"BODY TYPE:"});break;case"what-size-did-you-wear":case"size-worn":setElementProperties(strongElement,{innerText:"SIZE WORN:"});break;case"weight":case"weight-lbs":setElementProperties(strongElement,{innerText:"WEIGHT (LBS):"});break;case"height":setElementProperties(strongElement,{innerText:"HEIGHT:"});break;case"bust-size":case"bust":setElementProperties(strongElement,{innerText:"BUST:"});break;default:break}}),reviewProduct.before(reviewOptionsContainer)})}function updateFilters(){const filters=document.querySelectorAll(".stamped-filter-select"),filterLabel=document.querySelector(".stamped-reviews-filter-label"),filtersWrapper=document.querySelector(".stamped-filters-wrapper"),sortBy=document.querySelector(".stamped-sort-select-wrapper"),sortBy2=document.querySelector(".stamped-sort-select2-wrapper");filters.forEach(filter=>{filter.querySelector("option").innerText==="What's your typical street-wear size?"&&setElementStyle(filter,{display:"none"})}),filterLabel.innerText="FILTER",filterLabel.classList.add("text-base"),sortBy.classList.add("w-full","md:w-auto"),sortBy2.classList.add("w-full","md:w-auto"),filtersWrapper.append(sortBy)}function updateFilterSelectText(){const selectsContainer=document.querySelector(".stamped-filter-selects"),selects=document.querySelectorAll(".stamped-filter-selects select"),sortBy=document.querySelector(".stamped-sort-select2-wrapper");selects.forEach(select=>{if(select.querySelector("option").innerText!=="Sort"){const clonedSelector=select.cloneNode(!0);select.classList.add("stamped-selector"),clonedSelector.classList.add("cloned-selector"),selectsContainer.insertAdjacentElement("beforeend",clonedSelector)}});const stampedSelectors=document.querySelectorAll(".stamped-filter-selects .stamped-selector"),clonedSelectors=document.querySelectorAll(".stamped-filter-selects .cloned-selector");document.querySelector(".cloned-selector:last-child")?.after(sortBy),clonedSelectors.forEach(selector=>{const firstOption=selector.querySelector("option");switch(firstOption.innerText){case"What size did you wear?":firstOption.innerText="Size Worn";break;case"Which of the following most closely matches how you would describe your body?":firstOption.innerText="Body Type";break;default:break}selector.addEventListener("change",e=>{const selectorText=firstOption.innerText;let textToMatch="";switch(selectorText){case"How did the item fit?":textToMatch="How did the item fit?";break;case"Size Worn":textToMatch="What size did you wear?";break;case"Body Type":textToMatch="Which of the following most closely matches how you would describe your body?";break;default:break}stampedSelectors.forEach(stampedSelector=>{const optionElement=stampedSelector.querySelector("option");optionElement&&optionElement.innerText===textToMatch&&(setElementProperties(stampedSelector,{value:selector.value}),setElementProperties(stampedSelector,{selectedIndex:selector.selectedIndex}),window.StampedFn.filterReviews(e))})})})}function checkIfUpdatesNeeded(){const targetNode=document.querySelector("#stamped-reviews-tab"),config={attributes:!0,childList:!0,subtree:!0},callback=(mutationList,observer2)=>{observer2.disconnect(),updateReviewAttributes(),updateDateOfReview(),observer2.observe(targetNode,config)};new MutationObserver(callback).observe(targetNode,config)}function updateConfirmationMessage(){document.querySelectorAll(".stamped-thank-you p").forEach((message,index)=>{setElementProperties(message,{innerText:index===0?"Your review has been submitted!":"Your review will be posted once it's been approved."})})}function updateReviewCount(){const reviewCountProp=document.querySelector(".stamped-header [itemprop=reviewCount]");let reviewCount;reviewCountProp&&(reviewCount=reviewCountProp.content);const ratingValueProp=document.querySelector(".stamped-header [itemprop=ratingValue]");let ratingValue;return ratingValueProp&&(ratingValue=ratingValueProp.content),document.querySelectorAll(".review-stars-header").forEach(originalHeader=>{const header=originalHeader.cloneNode(!0);if(reviewCount&&reviewCount!==""&&reviewCount!=="0"){const roundedRating=parseFloat(ratingValue).toFixed(1);header.querySelector(".review-rating-text").innerText=`${roundedRating}`,header.classList.remove("none"),header.querySelector(".review-rating-count").innerText=` (${reviewCount} REVIEWS)`;const score=Math.round(ratingValue*10),scores=[score,score-10,score-20,score-30,score-40].map(val=>Math.max(0,Math.min(10,Math.floor(val))));header.querySelector(".review-title-text").textContent=`Users rated this product on average a ${score/10} out of 5.`,header.querySelector(".review-star-1").setAttribute("fill",`url(#Gradient${scores[0]})`),header.querySelector(".review-star-2").setAttribute("fill",`url(#Gradient${scores[1]})`),header.querySelector(".review-star-3").setAttribute("fill",`url(#Gradient${scores[2]})`),header.querySelector(".review-star-4").setAttribute("fill",`url(#Gradient${scores[3]})`),header.querySelector(".review-star-5").setAttribute("fill",`url(#Gradient${scores[4]})`)}else header.classList.add("none");originalHeader.parentNode.replaceChild(header,originalHeader),header.style.visibility="visible"}),{reviewCount,ratingValue}}window.updateReviewCount=updateReviewCount;let initialStampedLoad=!1;function executeAllUpdates(){updateSummary(),updateCarousel(),updatePhotoResolution(),updateFormQuestions(),updateFormFieldText(),updateOptionalFieldText(),createReviewGuidelines(),styleAddPhotosButton(),updateDateOfReview(),updateReviewAttributes(),updateFilters(),updateFilterSelectText(),updateReviewCount(),updateConfirmationMessage(),checkIfUpdatesNeeded()}function initializeReviewsUpdate(){addEventListenerStamped(document,"stamped:reviews:loaded",()=>{initialStampedLoad||(executeAllUpdates(),initialStampedLoad=!0)})}initializeReviewsUpdate(); //# sourceMappingURL=/cdn/shop/t/2918/assets/product--stamped-style-override.js.map