Vue.createApp({components:{},computed:{hasAccommodation(){return this.reservationConfiguration?.accommodationItems!=null;},hasRestaurants(){return this.reservationConfiguration?.restaurantItems!=null;},hasSpa(){return this.reservationConfiguration?.spaItems!=null;},minArrival(){return moment().toDate();},minDeparture(){if(this.arrival==null){return moment().add(1,'d').toDate();}
return moment(this.arrival).add(1,'d').toDate();},startArrival(){return this.minArrival;},startDeparture(){return this.minDeparture;},arrivalValid(){if(this.arrival==null){this.arrivalIsValid=false;return false;}
this.arrivalIsValid=true;return null;},departureValid(){if(this.departure==null){this.departureIsValid=false;return false;}
this.departureIsValid=true;return null;},},data(){return{isMenuOpen:false,isReservationOpen:false,isHotelsOpen:false,activeImagePath:null,accommodationPanelActive:false,restaurantPanelActive:false,spaPanelActive:false,configId:null,isBrandLevel:true,isReservationLoading:false,reservationConfiguration:null,hoverHotelRestaurant:null,activeHotelRestaurant:null,activeRestaurant:null,activeRestaurantTelHref:'',hoverHotelSpa:null,activeHotelSpa:null,activeSpa:null,activeSpaTelHref:'',activeAccomodationHotel:null,activeAccomodationHotelTelHref:'',culture:'fr-FR',arrival:null,departure:null,arrivalIsValid:true,departureIsValid:true,isDisabled:true,submitted:false,showJoinModal:false,canSubmitDetails:true,firstName:null,lastName:null,email:null,telephone:null,date:null,message:null,responseMessage:null,activeIndex:null,isLoading:false,menuSubItemActiveIndex:null,}},mounted(){let $this=this;if(window.location.href.indexOf("#reservation")!==-1){$this.onToggleReservation(true);}
let nav=document.querySelectorAll('.navigation')[0];let configId=nav.dataset.configid;if(configId!=null&&configId.length){$this.configId=configId;}
let culture=document.querySelector('#cultureCode').value;$this.culture=culture;document.addEventListener('roombooking',(e)=>{$this.roomBookingEvent(e);});document.addEventListener('restaurantbooking',(e)=>{$this.restaurantBookingEvent(e);});document.addEventListener('spabooking',(e)=>{$this.spaBookingEvent(e);});window.addEventListener('hashchange',function(){let hash=new URL(document.URL).hash;if(!hash.length){$this.isMenuOpen=false;$this.isReservationOpen=false;$this.isHotelsOpen=false;}});const joinLinkElement=document.querySelectorAll('[href*="modalId=join-modal"]');let joinModal=document.querySelector('#join-modal');if(joinLinkElement!=null){joinLinkElement.forEach((el)=>{el.addEventListener('click',function(event){event.preventDefault();if(joinModal!=null){joinModal.style.display="block";}},false);});}
var joinForm=document.querySelector('.form-container .jointhecommunity');if(joinForm!=null){var isValid=false;let button=joinForm.querySelector('.umbraco-forms-navigation input');let emailField=joinForm.querySelector('.email input');let termsField=joinForm.querySelector('.dataconsent input');if(button!=null&&emailField!=null&&termsField!=null){isValid?button.removeAttribute('disabled'):button.setAttribute('disabled','disabled');}
joinForm.addEventListener('input',function(){let emailValidation=/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/;if(emailField.value!=""&&emailValidation.test(emailField.value)&&termsField.checked){isValid=true;}else{isValid=false;}
isValid?button.removeAttribute('disabled'):button.setAttribute('disabled','disabled');});}},methods:{roomBookingEvent(data){let $this=this;$this.hoverHotelRestaurant=null;$this.activeHotelRestaurant=null;$this.activeRestaurant=null;$this.activeAccomodationHotel=null;$this.loadData().then((e)=>{$this.onResetReservationPanels();$this.onSetOverlay(false);$this.isMenuOpen=false;$this.isReservationOpen=true;$this.activeAccomodationHotel=$this.reservationConfiguration.accommodationItems.find(x=>x.id==data.detail.property);if($this.activeAccomodationHotel==null){$this.isBrandLevel=true;}else{$this.isBrandLevel=false;}
$this.onSetAccommodationPanel();var url_ob=new URL(document.URL);url_ob.hash='#reservation';var new_url=url_ob.href;document.location.href=new_url;});},restaurantBookingEvent(data){let $this=this;$this.hoverHotelRestaurant=null;$this.activeHotelRestaurant=null;$this.activeRestaurant=null;$this.activeAccomodationHotel=null;$this.loadData().then((e)=>{$this.onResetReservationPanels();$this.onSetOverlay(false);$this.isMenuOpen=false;$this.isReservationOpen=true;$this.hoverHotelRestaurant=$this.reservationConfiguration.restaurantItems.find(x=>x.id==data.detail.property);$this.activeHotelRestaurant=$this.hoverHotelRestaurant;if(data.detail.restaurant!=null){$this.activeRestaurant=$this.activeHotelRestaurant.items.find(x=>x.id==data.detail.restaurant);}
$this.activeAccomodationHotel=$this.reservationConfiguration?.accommodationItems?.find(x=>x.id==data.detail.property);if($this.activeHotelRestaurant==null){$this.isBrandLevel=true;}else{$this.isBrandLevel=false;}
$this.restaurantPanelActive=true;var url_ob=new URL(document.URL);url_ob.hash='#reservation';var new_url=url_ob.href;document.location.href=new_url;});},spaBookingEvent(e){let $this=this;$this.hoverHotelSpa=null;$this.activeHotelSpa=null;$this.activeSpa=null;$this.activeAccomodationHotel=null;$this.loadData().then((e)=>{$this.onResetReservationPanels();$this.onSetOverlay(false);$this.isMenuOpen=false;$this.isReservationOpen=true;$this.hoverHotelSpa=$this.reservationConfiguration.spaItems.find(x=>x.id==data.detail.property);$this.activeHotelSpa=$this.hoverHotelSpa;if(data.detail.spa!=null){$this.activeSpa=$this.activeHotelSpa.items.find(x=>x.id==data.detail.spa);}
if($this.activeHotelSpa==null){$this.isBrandLevel=true;}else{$this.isBrandLevel=false;}
$this.spaPanelActive=true;var url_ob=new URL(document.URL);url_ob.hash='#reservation';var new_url=url_ob.href;document.location.href=new_url;});},onSetOverlay(open){if(open){document.body.classList.add('overlay-open');}else{document.body.classList.remove('overlay-open');}},loadData(){let $this=this;var cultureElement=document.getElementById('cultureCode');var cultureQuery=cultureElement.value??"en-GB";if($this.reservationConfiguration==null){return fetch('/umbraco/api/reservation/getconfiguration?id='+$this.configId+'&culture='+cultureQuery).then((response)=>response.json()).then((data)=>{$this.reservationConfiguration=data;return new Promise((resolve)=>{resolve($this.reservationConfiguration);});});}
return new Promise((resolve)=>{resolve($this.reservationConfiguration);});},onToggleReservation(open){let $this=this;$this.onSetOverlay(open);$this.isMenuOpen=false;$this.isHotelsOpen=false;$this.isReservationOpen=open;if(open){$this.hoverHotelRestaurant=null;$this.activeHotelRestaurant=null;$this.activeRestaurant=null;var url_ob=new URL(document.URL);url_ob.hash='#reservation';var new_url=url_ob.href;document.location.href=new_url;if($this.reservationConfiguration!=null&&$this.reservationConfiguration.accommodationItems.length){let apiKey=$this.reservationConfiguration.accommodationItems.find(x=>x.id==$this.configId).namastayApiKey;if(apiKey!==null&&apiKey!==''){window.hotelParameters={apiKey:apiKey,spreedlyApiKey:'D1a8Zma8lZfap6nZpUjPxp6OHBV',widgetButtonsClass:'namastay-widget-button',specialOfferButtonsClass:'namastay-offer-button',};initNamastay(window.hotelParameters);}}}else{history.replaceState(null,null,' ');}
let operationPromise=Promise.resolve();if(open&&$this.reservationConfiguration==null){operationPromise=$this.loadData().then((e)=>{$this.activeAccomodationHotel=$this.reservationConfiguration.accommodationItems.find(x=>x.id==$this.configId);if($this.activeAccomodationHotel==null){$this.isBrandLevel=true;}else{$this.isBrandLevel=false;if($this.activeAccomodationHotel!=null){let apiKey=$this.activeAccomodationHotel.namastayApiKey;if(apiKey!==null&&apiKey!==''){window.hotelParameters={apiKey:apiKey,spreedlyApiKey:'D1a8Zma8lZfap6nZpUjPxp6OHBV',widgetButtonsClass:'namastay-widget-button',specialOfferButtonsClass:'namastay-offer-button',};initNamastay(window.hotelParameters);}}
if($this.activeAccomodationHotel!=null&&$this.activeAccomodationHotel.telephone!=null&&$this.activeAccomodationHotel.telephone.length){$this.activeAccomodationHotelTelHref=$this.activeAccomodationHotel.telephone.replaceAll(' ','');if($this.activeAccomodationHotel.telephone.includes("(0)")){$this.activeAccomodationHotelTelHref=$this.activeAccomodationHotel.telephone.replaceAll('(0)','');$this.activeAccomodationHotelTelHref=$this.activeAccomodationHotelTelHref.replaceAll(' ','');}else{$this.activeAccomodationHotelTelHref=$this.activeAccomodationHotel.telephone;}}}
$this.accommodationPanelActive=true;});}
operationPromise.then(()=>{if(open){if($this.isBrandLevel){window?.trackEvent("Accommodation Brand Reservation Viewed","Reservation",null,null);window?.trackVirtualPageView("/modal/reservations","Accommodation Brand Reservation");window?.trackMenu("menu_click","Beaumier","Hotel");window?.trackModal("modal_view","Beaumier","Hotel");}else{window?.trackEvent("Accommodation Hotel Reservation Viewed","Reservation",$this.activeAccomodationHotel.hotelName,null);window?.trackVirtualPageView("/modal/reservations","Accommodation Hotel Reservation");window?.trackMenu("menu_click",$this.activeAccomodationHotel.hotelName,"Hotel");window?.trackModal("modal_view",$this.activeAccomodationHotel.hotelName,"Hotel");}}});},onToggleHotels(open){let $this=this;$this.onSetOverlay(open);$this.isHotelsOpen=open;$this.isReservationOpen=false;$this.isMenuOpen=false;if(open){var url_ob=new URL(document.URL);url_ob.hash='#hotels-menu';document.body.classList.add("no-scroll");var new_url=url_ob.href;document.location.href=new_url;}
else{history.replaceState(null,null,' ');document.body.classList.remove("no-scroll");}
if(open){window?.trackEvent("Hotels Menu Mobile Viewed","Navigation",null,null);window?.trackVirtualPageView("/modal/hotels-menu","Hotels Menu Mobile");}else{window?.trackEvent("Hotels Menu Mobile Closed","Navigation",null,null);}},onToggleMenu(open){let $this=this;$this.onSetOverlay(open);$this.isMenuOpen=open;$this.isHotelsOpen=false;$this.isReservationOpen=false;let firstIdxEl=document.getElementById('firstItemWithSubLinksIdx');if(firstIdxEl!=null&&firstIdxEl.getAttribute('data-firstItemWithSubLinksIdx')!=null){this.menuSubItemActiveIndex=parseInt(firstIdxEl.getAttribute('data-firstItemWithSubLinksIdx'));}
if(open){var url_ob=new URL(document.URL);url_ob.hash='#menu';var new_url=url_ob.href;document.location.href=new_url;}
else{history.replaceState(null,null,' ');}
if(open){window?.trackEvent("Main Menu Viewed","Navigation",null,null);window?.trackVirtualPageView("/modal/menu","Main Menu");}else{window?.trackEvent("Main Menu Closed","Navigation",null,null);}},onResetImage(){let $this=this;$this.activeImagePath=null;},onSetImage(path){let $this=this;$this.activeImagePath="https://beaumier.azureedge.net"+path;},onResetReservationPanels(){let $this=this;$this.accommodationPanelActive=false;$this.restaurantPanelActive=false;$this.spaPanelActive=false;},onResetData(){let $this=this;$this.hoverHotelRestaurant=null;$this.activeHotelRestaurant=null;$this.activeRestaurant=null;$this.hoverHotelSpa=null;$this.activeHotelSpa=null;$this.activeSpa=null;},onSetAccommodationPanel(){let $this=this;$this.onResetData();$this.onResetReservationPanels();$this.accommodationPanelActive=true;if($this.reservationConfiguration!=null&&$this.reservationConfiguration.accommodationItems.length){let apiKey=$this.reservationConfiguration.accommodationItems.find(x=>x.id==$this.configId).namastayApiKey;if(apiKey!==null&&apiKey!==''){window.hotelParameters={apiKey:apiKey,spreedlyApiKey:'D1a8Zma8lZfap6nZpUjPxp6OHBV',widgetButtonsClass:'namastay-widget-button',specialOfferButtonsClass:'namastay-offer-button',};initNamastay(window.hotelParameters);}}
if($this.activeAccomodationHotel!=null){window?.trackEvent("Accommodation Hotel Reservation Viewed","Reservation",$this.activeAccomodationHotel.hotelName,null);window?.trackVirtualPageView("/modal/reservations","Accommodation Hotel Reservation");window?.trackMenu("menu_click",$this.activeAccomodationHotel.hotelName,"Hotel");window?.trackModal("modal_view",$this.activeAccomodationHotel.hotelName,"Hotel");}else{window?.trackEvent("Accommodation Brand Reservation Viewed","Reservation",null);window?.trackVirtualPageView("/modal/reservations","Accommodation Brand Reservation");window?.trackMenu("menu_click","Beaumier","Hotel");window?.trackModal("modal_view","Beaumier","Hotel");}},onSetRestaurantPanel(){let $this=this;$this.onResetData();$this.onResetReservationPanels();$this.restaurantPanelActive=true;$this.hoverHotelRestaurant=$this.reservationConfiguration.restaurantItems[0];if($this.configId!=null&&$this.configId!=0){$this.onSetHotelRestaurant($this.reservationConfiguration.restaurantItems.find(x=>x.id==$this.configId));$this.activeHotelRestaurant=$this.reservationConfiguration.restaurantItems.find(x=>x.id==$this.configId);window?.trackEvent("Restaurant Reservation Viewed","Reservation",$this.hoverHotelRestaurant.hotelName,null);window?.trackVirtualPageView("/modal/reservations","Restaurant Reservation");window?.trackMenu("menu_click",$this.hoverHotelRestaurant.hotelName,"Restaurant");window?.trackModal("modal_view",$this.hoverHotelRestaurant.hotelName,"Restaurant");}else{window?.trackEvent("Restaurant Reservation Viewed","Reservation",null,null);window?.trackVirtualPageView("/modal/reservations","Restaurant Reservation");window?.trackMenu("menu_click","Beaumier","Restaurant");window?.trackModal("modal_view","Beaumier","Restaurant");}},onSetSpaPanel(){let $this=this;$this.onResetData();$this.onResetReservationPanels();$this.spaPanelActive=true;$this.hoverHotelSpa=$this.reservationConfiguration.spaItems[0];if($this.configId!=null&&$this.configId!=0){$this.onSetHotelSpa($this.reservationConfiguration.spaItems.find(x=>x.id==$this.configId));$this.activeSpa=$this.reservationConfiguration.spaItems.find(x=>x.id==$this.configId);$this.activeHotelSpa=$this.reservationConfiguration.spaItems.find(x=>x.id==$this.configId);window?.trackEvent("Spa Reservation Viewed","Reservation",$this.activeHotelSpa.hotelName,null);window?.trackVirtualPageView("/modal/reservations","Spa Reservation");window?.trackMenu("menu_click",$this.activeHotelSpa.hotelName,"Spa");window?.trackModal("modal_view",$this.activeHotelSpa.hotelName,"Spa");}else{window?.trackEvent("Spa Reservation Viewed","Reservation",null,null);window?.trackVirtualPageView("/modal/reservations","Spa Reservation");window?.trackMenu("menu_click","Beaumier","Spa");window?.trackModal("modal_view","Beaumier","Spa");}},onHoverSetHotelRestaurant(hotelRestaurant){let $this=this;$this.hoverHotelRestaurant=hotelRestaurant;},onSetHotelRestaurant(hotelRestaurant){let $this=this;if(hotelRestaurant.items!=null&&hotelRestaurant.items.length>0){if(hotelRestaurant.items.length==1){$this.activeHotelRestaurant=hotelRestaurant;$this.onSetActiveRestaurant(hotelRestaurant.items[0])}else{$this.activeHotelRestaurant=hotelRestaurant;}
window?.trackEvent("Restaurant Reservation Viewed","Reservation",$this.hoverHotelRestaurant.hotelName,null);window?.trackVirtualPageView("/modal/reservations","Restaurant Reservation");window?.trackMenu("menu_click",$this.hoverHotelRestaurant.hotelName,"Restaurant");window?.trackModal("modal_view",$this.hoverHotelRestaurant.hotelName,"Restaurant");}},onSetActiveRestaurant(restaurant){let $this=this;$this.activeRestaurant=restaurant;if($this.activeRestaurant!=null&&$this.activeRestaurant.telephone!=null&&$this.activeRestaurant.telephone.length){$this.activeRestaurantTelHref=$this.activeRestaurant.telephone.replaceAll(' ','');if($this.activeRestaurant.telephone.includes("(0)")){$this.activeRestaurantTelHref=$this.activeRestaurant.telephone.replaceAll('(0)','');$this.activeRestaurantTelHref=$this.activeRestaurantTelHref.replaceAll(' ','');}else{$this.activeRestaurantTelHref=$this.activeRestaurant.telephone;}}
window?.trackEvent("Restaurant Reservation Viewed","Reservation",$this.hoverHotelRestaurant.hotelName,$this.hoverHotelRestaurant.title);window?.trackVirtualPageView("/modal/reservations","Restaurant Reservation");window?.trackMenu("menu_click",$this.hoverHotelRestaurant.hotelName,"Restaurant");window?.trackModal("modal_view",$this.hoverHotelRestaurant.hotelName,"Restaurant");},onHoverSetHotelSpa(hotelSpa){let $this=this;$this.hoverHotelSpa=hotelSpa;},onSetHotelSpa(hotelSpa){let $this=this;if(hotelSpa!=null){$this.activeHotelSpa=hotelSpa;$this.onSetActiveSpa(hotelSpa)
window?.trackEvent("Spa Reservation Viewed","Reservation",$this.activeHotelSpa.hotelName,null);window?.trackVirtualPageView("/modal/reservations","Spa Reservation");window?.trackMenu("menu_click",$this.activeHotelSpa.hotelName,"Spa");window?.trackModal("modal_view",$this.activeHotelSpa.hotelName,"Spa");}},onSetActiveSpa(spa){let $this=this;$this.activeSpa=spa;if($this.activeSpa!=null&&$this.activeSpa.telephone!=null&&$this.activeSpa.telephone.length){$this.activeSpaTelHref=$this.activeSpa.telephone.replaceAll(' ','');if($this.activeSpa.telephone.includes("(0)")){$this.activeSpaTelHref=$this.activeSpa.telephone.replaceAll('(0)','');$this.activeSpaTelHref=$this.activeSpaTelHref.replaceAll(' ','');}else{$this.activeSpaTelHref=$this.activeSpa.telephone;}}},hideJoinModal(){let joinModal=document.querySelector('#join-modal');if(joinModal!=null){joinModal.style.display="none";}},joinModalClick(){let joinModal=document.querySelector('#join-modal');if(joinModal!=null){joinModal.style.display="block"}},checkAvailability(){if(this.departureIsValid&&this.arrivalIsValid){this.isDisabled=false;var cultureElement=document.getElementById('cultureCode');var cultureQuery=cultureElement.value??"en-US";if(cultureQuery=="en-GB"||cultureQuery=="de"){cultureQuery="en-US";}
window.open('https://be.synxis.com/?locale='+cultureQuery+'&level=chain'+'&adult=2'+'&child=0'+'&arrive='+moment(this.arrival).format('yyyy-MM-DD')+'&depart='+moment(this.departure).format('yyyy-MM-DD')+'&chain=28059')
if(open){window?.trackEvent("Brand Accommodation Search","Reservation",null,null);window?.trackVirtualPageView("/modal/reservations","Brand Accommodation Search");window?.trackMenu("menu_click","Beaumier","Hotel");window?.trackModal("modal_view","Beaumier","Hotel");}}else{this.isDisabled=true;}},submitDetails(){let emailValidation=/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$/;if(this.email!=null&&emailValidation.test(this.email)&&this.firstName!=null&&this.lastName!=null&&this.message!=null){var payload={FormId:this.activeSpa.spaFormName,FirstName:this.firstName,LastName:this.lastName,Email:this.email,Telephone:this.telephone,Date:this.date,Message:this.message};this.doPost(payload);window?.trackEvent("Spa Enquiry","Reservation",this.activeSpa.hotelName,null);window?.trackSpaForm("generate_lead",this.activeSpa.hotelName,"Reservation",this.email);window?.trackVirtualPageView("/modal/reservations","Spa Enquiry");}
else{alert("Please enter a value to all required fields");}},doPost(payload){this.isLoading=true;var hasSuccess=false;var hasError=false;fetch("/umbraco/api/formsSignup/spaPost",{method:"POST",headers:{'Content-Type':'application/json'},body:JSON.stringify(payload),}).then((response)=>response.json()).then((data)=>{hasSuccess=true;hasError=false;this.responseMessage=data.message;}).catch(function(error){console.log("something went wrong");console.log(error);this.isLoading=false;});},isSeasonUnavailable(item){let $this=this;if($this.arrival==null||$this.departure==null){return false;}
var arrivalMoment=moment($this.arrival);var departureMoment=moment($this.departure);if(item.seasons.length){for(let si=0;si<item.seasons.length;si++){let season=item.seasons[si];let seasonStart=moment(season.seasonStart);let seasonEnd=moment(season.seasonEnd);if(arrivalMoment.isSameOrAfter(seasonStart)&&departureMoment.isSameOrBefore(seasonEnd)){return false;}}}
return true;},toggleMenuElement(index){this.activeIndex=this.activeIndex===index?null:index;},setActive(index,indexesWithSubItems,firstIndex){if(indexesWithSubItems.includes(parseInt(index))){this.menuSubItemActiveIndex=index;}
else{this.menuSubItemActiveIndex=firstIndex;}},setInactive(firstIndex){this.menuSubItemActiveIndex=firstIndex;}}}).mount('#navigation');;
