document.addEventListener("DOMContentLoaded",()=>{let rentalData=varStore.rentalData;"object"!=typeof rentalData&&(rentalData={});let placeholderElement=$("[tag-placeholder-rental]");(rentalData.properties??[]).forEach(property=>{let newElement=placeholderElement.clone();newElement.removeClass("hide");let firstImage=(property.images??[])[0]??{};newElement.find("[tag-rental-img]").attr("src",firstImage.imagelink??""),newElement.find("[tag-rental-price]").text("$"+(property.rent??"N/A")+"/mo"),newElement.find("[tag-rental-beds]").text((property.bedrooms??"N/A")+" Bed"),newElement.find("[tag-rental-baths]").text((property.bathrooms??"N/A")+" Bath"),newElement.find("[tag-rental-area]").text((property.sqft??"N/A")+" ft²"),newElement.find("[tag-rental-address]").text(property.address??"N/A"),property.city&&property.state&&newElement.find("[tag-rental-location]").text(property.city+", "+property.state),property.class_ad=property.class_ad??"No Description Provided!",property.class_ad_truncated=property.class_ad??"No Description Provided!",property.class_ad.length>=580&&(property.class_ad_truncated=property.class_ad.slice(0,575)+"..."),newElement.find("[tag-rental-description]").text(property.class_ad_truncated),newElement.on("click",evt=>{if(evt.preventDefault(),window.location.hash=property.property_id,$("[tag-rental-modal]").removeClass("inactive"),$("[tag-rental-modal]").on("click",function(e){$(e.target).closest("[tag-rental-modal-content]").length||($(this).addClass("inactive"),window.location.hash="")}),$("[tag-modal-apply-btn]").on("click",function(e){window.location=property.app_link.length?property.app_link:"/contact"}),property.address){let address=property.address+" "+property.city+","+property.state,fullEmbedUrl="https://www.google.com/maps/embed/v1/place?key=AIzaSyCu1RwjICem7MPqXQOKPdd3x8PE3ccVKcY"+"&q="+encodeURIComponent(address);$("[tag-modal-rental-map-embed]").attr("src",fullEmbedUrl)}$("[tag-modal-rental-image]").remove(),$("[tag-image-indicator]").remove();let placeholderCarouselImgElement=$("[tag-modal-rental-image-placeholder]"),placeholderCarouselImgIndicatorElement=$("[tag-image-indicator-placeholder]"),rentalImages=property.images??[];if(0===rentalImages.length){let newImageElement=placeholderCarouselImgElement.clone();newImageElement.removeClass("hide"),newImageElement.removeAttr("tag-modal-rental-image-placeholder"),newImageElement.attr("tag-modal-rental-image",""),newImageElement.attr("src","images/realty-logo.png"),newImageElement.css("padding","10%"),newImageElement.appendTo("[tag-card-container]")}else for(let image of rentalImages){if(rentalImages.length>1){let newIndicatorElement=placeholderCarouselImgIndicatorElement.clone();newIndicatorElement.removeClass("hide"),newIndicatorElement.removeAttr("tag-image-indicator-placeholder"),newIndicatorElement.attr("tag-image-indicator",""),newIndicatorElement.appendTo("[tag-image-indicator-container]")}let newImageElement=placeholderCarouselImgElement.clone();newImageElement.removeClass("hide"),newImageElement.removeAttr("tag-modal-rental-image-placeholder"),newImageElement.attr("tag-modal-rental-image",""),newImageElement.attr("tag-carousel-card",""),newImageElement.attr("src",image.imagelink??""),newImageElement.appendTo("[tag-card-container]")}window.rentalCarousel&&window.rentalCarousel.reset(),$("[tag-modal-rental-price]").text("$"+(property.rent??"N/A")+"/mo"),$("[tag-modal-rental-beds]").text((property.bedrooms??"N/A")+" Bed"),$("[tag-modal-rental-baths]").text((property.bathrooms??"N/A")+" Bath"),$("[tag-modal-rental-area]").text((property.sqft??"N/A")+" ft²"),$("[tag-modal-rental-address]").text(property.address??"N/A"),$("[tag-modal-rental-feature]").remove();let placeholderRentalFeatureElement=$("[tag-modal-rental-feature-placeholder]"),rentalFeatures=property.features??[];if(0==rentalFeatures.length)$("[tag-modal-rental-features-section]").addClass("hide");else{$("[tag-modal-rental-features-section]").removeClass("hide");for(let feature of rentalFeatures){let newFeatureElement=placeholderRentalFeatureElement.clone();newFeatureElement.removeClass("hide"),newFeatureElement.removeAttr("tag-modal-rental-feature-placeholder"),newFeatureElement.attr("tag-modal-rental-feature",""),newFeatureElement.children().text(feature),newFeatureElement.appendTo("[tag-modal-rental-features-container]")}}property.class_ad=property.class_ad??"No Description Provided!",$("[tag-modal-rental-description]").text(property.class_ad)}),newElement.appendTo("[tag-rentals-container]"),window.location.hash==="#"+property.property_id&&newElement.click()}),jQuery.fn.carousel=function(options={}){let carousel={},reset=()=>{carousel.boundary=1,carousel.element=$(this),carousel.cardContainer=carousel.element.find("[tag-card-container]"),carousel.cards=carousel.element.find("[tag-carousel-card]"),carousel.currentIndex=0,carousel.currentPosition=0,carousel.circular=options.circular??!1,validateButtonVisibility(),updatePosition("")};function convertToVw(width){return width/window.innerWidth*100}function updatePosition(slide="right",count=0){let offsetIndex=carousel.currentIndex,positionOffset=0,rightBoundary=carousel.cards.length-carousel.boundary;for(let i=0;i0)positionOffset-=convertToVw(carousel.cards.eq(offsetIndex-1).outerWidth()),offsetIndex--;else{offsetIndex=carousel.cards.length-carousel.boundary;for(let x=0;x=carousel.cards.length-carousel.boundary&&!0!==carousel.circular?carousel.element.find("[tag-carousel-btn-right]").hide():carousel.element.find("[tag-carousel-btn-right]").show()),carousel.element.find("[tag-image-indicator]").removeClass("active"),carousel.element.find("[tag-image-indicator]").eq(carousel.currentIndex).addClass("active")}return carousel.reset=()=>{reset()},reset(),carousel.updatePosition=(slide="right",count=1)=>{updatePosition(slide,count)},carousel.recalcPositions=()=>{recalcPositions()},setInterval(function(){carousel.cardContainer.outerWidth()a+b,0)+parseInt(carousel.cardContainer.css("gap"))*carousel.boundary&&carousel.boundary>1&&(carousel.boundary-=1,carousel.element.find("[tag-carousel-btn-right]").show())},300),carousel.element.find("[tag-carousel-btn-left]").click(function(){carousel.updatePosition("left",1)}),carousel.element.find("[tag-carousel-btn-right]").click(function(){carousel.updatePosition("right",1)}),window.addEventListener("resize",event=>{recalcPositions()}),carousel},window.rentalCarousel=$("[tag-carousel-container]").carousel({circular:!0})});