!function(){"use strict";function bookingController($scope,$animate,$timeout,$location,$anchorScroll,util,bookingService,validation){var vm=this;function getValidDateOrNull(date){return date&&moment(date,"MM-DD-YYYY",!0).isValid()}function addBounceClass(){$animate.addClass(".alert","notifyBounce"),$timeout(removeBounceClass,500)}function removeBounceClass(){$animate.removeClass(".alert","notifyBounce")}vm.init=async function(propertyId,defaultCountryId){$scope.$parent.global.loadCalendar(propertyId),await bookingService.init(propertyId,defaultCountryId),vm.insure.isAllowedPDP=await bookingService.isAllowedPDP(propertyId),await bookingService.getOffer(vm.insure.isAllowedPDP&&"insurance"===vm.insure.type),bookingService.offer.success&&(vm.insure.price=bookingService.offer.prices.pdpInsurance.price,null==bookingService.offer.prices.potentialDeposit&&(vm.insure.isAllowedPDP=!1))},$scope.forms={},vm.offerHasError=bookingService.offerHasError,vm.bookingHasError=bookingService.bookingHasError,vm.testCardOnLiveServerError=bookingService.testCardOnLiveServerError,vm.ui=bookingService.ui,vm.serverError=bookingService.serverError,vm.request=bookingService.request,vm.response=bookingService.response,vm.property=bookingService.property,vm.offer=bookingService.offer,vm.terms=bookingService.terms,vm.error=bookingService.error,vm.rentalAgreementAccepted=!1,vm.pdpAgreementAccepted=!1,vm.insure={type:"insurance",isAllowedPDP:!1,price:0},vm.isDateOfBirthCorrect=!0,vm.birthDay=10,vm.birthMonth=10,vm.birthYear=1999,$scope.$watch((function(){var optionalServices=vm.offer.prices?vm.offer.prices.optionalServices:[],watchObject={paymentType:vm.request.paymentOptionId,services:$.map(optionalServices,(function(item){return item.selectedCount}))};return vm.offer.prices&&(bookingService.adwordsRemarketing.hrental_totalvalue=parseFloat(vm.offer.prices.total.totalPriceValue.amount)),JSON.stringify(watchObject)}),(function(){bookingService.request.paymentOption=vm.request.paymentOptionId,bookingService.ui.isBooking&&(document.body.style.overflow="hidden"),bookingService.offer.success&&!bookingService.ui.isInitial&&bookingService.getOffer(vm.insure.isAllowedPDP&&"insurance"===vm.insure.type).then((function(){bookingService.offer.success&&(vm.insure.price=bookingService.offer.prices.pdpInsurance.price)}))})),$scope.$watch("vm.booking.guest",(function(){vm.applyClientErrors()}),!0),$scope.$watch("vm.birthDay",(function(newValue){vm.request.guest.dateOfBirth=vm.birthMonth+"-"+vm.birthDay+"-"+vm.birthYear,vm.isDateOfBirthCorrect=getValidDateOrNull(vm.request.guest.dateOfBirth)})),$scope.$watch("vm.birthMonth",(function(newValue){vm.request.guest.dateOfBirth=vm.birthMonth+"-"+vm.birthDay+"-"+vm.birthYear,vm.isDateOfBirthCorrect=getValidDateOrNull(vm.request.guest.dateOfBirth)})),$scope.$watch("vm.birthYear",(function(newValue){vm.request.guest.dateOfBirth=vm.birthMonth+"-"+vm.birthDay+"-"+vm.birthYear,vm.isDateOfBirthCorrect=getValidDateOrNull(vm.request.guest.dateOfBirth)})),$scope.$watch("vm.request.guest.idType",(function(newValue){newValue?"Passport"!=vm.request.guest.idType&&"National ID"!=vm.request.guest.idType&&"Drivers License"!=vm.request.guest.idType?vm.isIdTypeSelected=!1:vm.isIdTypeSelected=!0:""===newValue&&(vm.isIdTypeSelected=!1)})),$scope.$watch("vm.request.guest.idType",(function(newValue){newValue?"Passport"!=vm.request.guest.idType&&"National ID"!=vm.request.guest.idType&&"Drivers License"!=vm.request.guest.idType?vm.isIdTypeSelected=!1:vm.isIdTypeSelected=!0:""===newValue&&(vm.isIdTypeSelected=!1)})),vm.applyClientErrors=function(){null!=$scope.forms.form&&validation.applyClientErrors($scope.forms.form,vm.errorMessages),void 0!==$scope.forms.formPDP&&validation.applyClientErrors($scope.forms.formPDP,vm.errorMessages)},vm.shouldFloat=function(field){return""!==field.$viewValue&&void 0!==field.$viewValue},vm.doneEditing=function(){bookingService.getOffer(vm.insure.isAllowedPDP&&"insurance"===vm.insure.type).then((function(){bookingService.offer.success&&(vm.ui.isEditing=!1,vm.insure.price=bookingService.offer.prices.pdpInsurance.price)}))},vm.getPhoneCountry=function(id){return $(id).intlTelInput("getSelectedCountryData").dialCode},vm.submit=function($event){if($event.stopPropagation(),vm.applyClientErrors(),vm.offerHasError())return void addBounceClass();const isPDPInsurance=vm.insure.isAllowedPDP&&"insurance"===vm.insure.type;return vm.request.guest.mobileCountryCode=vm.getPhoneCountry(isPDPInsurance?"#mobileNumberPDP":"#mobileNumber"),vm.request.guest.dateOfBirth=vm.birthMonth+"-"+vm.birthDay+"-"+vm.birthYear,vm.request.guest.dateOfBirth?vm.isDateOfBirthCorrect=getValidDateOrNull(vm.request.guest.dateOfBirth):""===vm.request.guest.dateOfBirth&&(vm.isDateOfBirthCorrect=!1),"Passport"!=vm.request.guest.idType&&"National ID"!=vm.request.guest.idType&&"Drivers License"!=vm.request.guest.idType&&(vm.isIdTypeSelected=!1),bookingService.book($scope.forms.form,$scope.forms.formPDP,isPDPInsurance).finally((function(){if(bookingService.ui.showErrorForPristineFields){const scrollTo=isPDPInsurance?"booking-form-PDP":"booking-form";$location.hash(scrollTo),$anchorScroll()}bookingService.ui.testCardLiveServer&&addBounceClass(),$scope.forms.form.$valid&&dataLayer.push({event:"GAevent",eventCategory:"bookingButton",eventAction:"GuestBookingButton",eventLabel:"Guest clicked booking button",eventValue:null,saleType:20})}))},vm.goBack=function(){document.location="/"+vm.booking.property.propertyId},vm.showSection=function(){return!(!vm.ui.hasGotOffer||vm.offerHasError()||null!=vm.serverError.message)},vm.showError=function(field){return!!field&&vm.ui.showErrorForPristineFields},vm.getBackgroundStyle=function(imagepath){if(imagepath)return{"background-image":"url("+imagepath+")"}},vm.getMyOffer=function(isPDP){bookingService.getOffer(isPDP)};var _minDateFromTo=util.createMinDateFromTo(0,1);vm.minDateFrom=function(){return _minDateFromTo.getMinDateFrom()},vm.minDateTo=function(){return _minDateFromTo.getMinDateTo(vm.request.fromDate)}}angular.module("app").controller("bookingController",bookingController),bookingController.$inject=["$scope","$animate","$timeout","$location","$anchorScroll","util","bookingService","validation"]}(),function(){"use strict";angular.module("app").directive("emptyToNull",(function(){return{restrict:"A",require:"ngModel",link:function(scope,elem,attrs,ctrl){ctrl.$parsers.push((function(viewValue){if(""!==viewValue)return viewValue}))}}}))}(),function(){"use strict";function bookingReceiptController($scope,$location,receiptService,cshphoneinputservice){var vm=this;function getBooking(data,error){var bookingDetails;error?vm.ui.requestIsBusy=!1:(vm.ui.requestIsBusy=!1,vm.currency=null!=(bookingDetails=data).price.rent.totalPrice[0]&&null!=bookingDetails.price.rent.totalPrice[0]?bookingDetails.price.rent.totalPrice[0]:"",function(holidayHomeServices){for(var i=0;i0&&null!=holidayHomeServices[i].prices.priceList[0].unitPrice?holidayHomeServices[i].prices.priceList[0].unitPrice:"",unitType=getServiceUnit(holidayHomeServices[i]);if(""!=unitPrice){var serviceId=holidayHomeServices[i].service.id;vm.holidayHomeServices[serviceId]=vm.currency+" "+unitPrice.amount+" "+unitType}}}(data.holidayHomeServices))}function getServiceUnit(holidayHomeService){var result=vm.servicesUnit.filter((c=>holidayHomeService.unitType==c.Value));return result&&result.length?result[0].Text:""}$scope.forms={},vm.ui=receiptService.ui,vm.invalidUrl=receiptService.invalidUrl,vm.booking=receiptService.booking,vm.response=receiptService.response,vm.serverError=receiptService.serverError,vm.servicesUnit=null,vm.holidayHomeServices=[],vm.guestInfo={guestNIF:"",guestPassport:"",country:{},validationError:{}},vm.isCheckoutButtonVisible=!0,vm.countries=[],vm.currentLanguageId="",vm.setUnitList=function(unitList){unitList.forEach((elem=>elem.Text=elem.Text.toLowerCase())),vm.servicesUnit=unitList},vm.init=function(data){receiptService.init(data.propertyId,data.bookingId,data.memberGuid,getBooking),vm.guestInfo.country=data.guestInfo.guestCountry,vm.currentLanguageId=data.currentLanguageId,data.guestInfo&&!0===data.guestInfo.guestInfoIsPresent?vm.guestInfo.savedInfo={countryCode:data.guestInfo.guestCountry.code}:cshphoneinputservice.getCountryNames(data.currentLanguageId).then((function(result){vm.countries=result}))},vm.checkout=function(){receiptService.checkout()},vm.setCountry=function(choice){vm.guestInfo.country=choice},vm.saveGuestInfo=function(){vm.ui.requestIsBusy=!0;var officialGuestInfo={isSpanishNational:""!==vm.guestInfo.guestNIF,guestIdNumber:""!==vm.guestInfo.guestNIF?vm.guestInfo.guestNIF:vm.guestInfo.guestPassport,countryCode:""!==vm.guestInfo.guestNIF?"ES":vm.guestInfo.country.code};receiptService.saveGuestInfo(officialGuestInfo).then((function(data){data&&null!==data.errorMessage&&(vm.guestInfo.guestNIF?vm.guestInfo.validationError.NIF=data.errorMessage:vm.guestInfo.validationError.passport=data.errorMessage),data&&null===data.errorMessage&&(vm.guestInfo.savedInfo={isSpanishNational:data.resultObject.isSpanishNational,countryCode:data.resultObject.countryCode}),vm.ui.requestIsBusy=!1}),(function(error){vm.guestInfo.guestNIF?vm.guestInfo.validationError.NIF=data.errorMessage:vm.guestInfo.validationError.passport=data.errorMessage,vm.ui.requestIsBusy=!1}))},vm.isNextPaymentRateAndIsNotCharged=function(paymentRate){return vm.isNextPaymentRate(paymentRate)&&!vm.isNextPaymentRateCharged()},vm.hasShowCheckoutButtonQueryParam=function(){return $location.search().hasOwnProperty("show_checkout_button")},vm.isNextPaymentRate=function(paymentRate){return null!=vm.booking.payment.nextPaymentRate&&paymentRate.id==vm.booking.payment.nextPaymentRate.id},vm.isNextPaymentRateCharged=function(){return vm.booking.payment.nextPaymentRate.state.isPaid},vm.isInitialPaymentRate=function(paymentRate){return paymentRate.id==vm.booking.payment.paymentRates[0].id},vm.getBackgroundStyle=function(imagepath){if(imagepath)return{"background-image":"url("+imagepath+")"}}}angular.module("app").controller("bookingReceiptController",bookingReceiptController),bookingReceiptController.$inject=["$scope","$location","receiptService","cshphoneinputservice"]}(),function(){"use strict";function priceBoxController($scope,$window,$animate,$timeout,$modal,propertyPriceBox,priceService,priceBoxRequest,bookingService,util,messageService,askQuestionService){var vm=this;vm.initial=priceService.initialResult,vm.priceBox=priceService.result,vm.criteria=propertyPriceBox.criteria,vm.request=priceBoxRequest.request,vm.maxGuests=0,vm.init=function(propertyId,maxGuests){vm.request.propertyId=propertyId,vm.request.adults=maxGuests0&&children.map((function(child){queryString+="children="+child.age+"&"}));queryString+=currencyId?"currencyId="+currencyId:"currencyId=1",service.isLateBookingAllowed()&&(queryString+="&allowlatebooking=true");return queryString}(dateFrom,dateTo,adults,children,currencyId);$window.location.href=service.baseUrl+params},init:async function(propertyId,defaultCountryId){var params=getUrlParams();(function(propertyId,dateFrom,dateTo,adults,children,currencyId,defaultCountryId){service.request.propertyId=propertyId,service.request.dateFrom=getValidDateOrNull(dateFrom),service.request.dateTo=getValidDateOrNull(dateTo),service.request.adults=parseInt(adults)||1,service.request.children=function(children){return children&&!Array.isArray(children)?[{age:children}]:children&&Array.isArray(children)?children.map((function(child){return{age:child}})):[]}(children),service.request.currencyId=currencyId||1,service.request.guest.countryId=defaultCountryId,service.request.paymentOptionId=1,service.request.dateFrom&&service.request.dateTo||(service.ui.isEditing=!0);angular.copy(service.request,service.oldRequest)})(propertyId,params.dateFrom?params.dateFrom[0]:null,params.dateTo?params.dateTo[0]:null,params.adults?params.adults[0]:null,params.children?params.children:null,params.currencyId?params.currencyId[0]:null,defaultCountryId),service.currentParams=$window.location.search,service.ui.isBusy=!0;var p1=getProperty(),p2=getTerms(),p3=getOffer(!0);$q.all([p1,p2,p3]).then((function(){service.ui.isBusy=!1,service.ui.isInitial=!1}),(function(){service.serverError=messageService.setLocalView(),service.ui.isBusy=!1,service.ui.isInitial=!1})),service.adwordsRemarketing.hrental_id=propertyId,service.adwordsRemarketing.hrental_pagetype="conversionintent",void 0!==params.dateFrom&&(service.adwordsRemarketing.hrental_startdate=params.dateFrom[0]);void 0!==params.dateTo&&(service.adwordsRemarketing.hrental_enddate=params.dateTo[0])},getOffer:getOffer,getProperty:getProperty,getTerms:getTerms,book:function(form,insuranceForm,includePDPInsurance){if(form.$invalid||includePDPInsurance&&insuranceForm&&insuranceForm.$invalid)return service.ui.showErrorForPristineFields=!0,$q.reject();return service.ui.isBooking=!0,doBook(form,includePDPInsurance)},isLateBookingAllowed:function(){try{var params=getUrlParams();return!!params.allowlatebooking&&"true"==params.allowlatebooking[0].toLowerCase()}catch(exp){return!1}},isAllowedPDP:async function(propertyId){return await api.isAllowedPDP(propertyId)}};return service;function getUrlParams(){var qd={};return $window.location.search&&$window.location.search.substr(1).split("&").forEach((function(item){var s=item.split("="),k=s[0],v=s[1]&&decodeURIComponent(s[1]);(qd[k]=qd[k]||[]).push(v)})),qd}function getValidDateOrNull(date){return date&&moment(date).isValid()?moment(date).toDate():null}function getOffer(includePDPInsurance){if(0!==service.request.propertyId){if(!service.request.dateFrom||!service.request.dateTo)return $q.when();if(!service.ui.hasGotOffer||!angular.equals(service.request,service.oldRequest)){service.ui.requestIsBusy=!0;var isLateBookingAllowed=service.isLateBookingAllowed();return api.getOffer(service.request.propertyId,service.request,getExtras(),isLateBookingAllowed,includePDPInsurance).then((function(data){angular.extend(service.offer,data),onFailure(service.offer.error),service.ui.requestIsBusy=!1,service.ui.hasGotOffer=!0,data.prices&&(service.adwordsRemarketing.hrental_totalvalue=parseFloat(data.prices.total.totalPriceValue.amount)),dataLayer.push({google_tag_params:service.adwordsRemarketing}),dataLayer.push({event:"remarketingPriceChange"})}),(function(serverError){return service.requestIsBusy=!1,service.ui.hasGotOffer=!0,$q.reject(serverError)}))}}}function getProperty(){if(0!==service.request.propertyId)return api.getProperty(service.request.propertyId).then((function(data){angular.extend(service.property,data)}))}function getTerms(){if(0!==service.request.propertyId)return api.getTerms(service.request.propertyId).then((function(data){angular.extend(service.terms,data)}))}function doBook(form,includePDPInsurance){service.request.guest.mobileCountryCode=util.getCountryCode(includePDPInsurance?"#mobileNumberPDP":"#mobileNumber");var request={...service.request,...service.request.guest,paymentProvider:"stripe",rentalAgreementAccepted:form.cbxRentalAgreementAccepted.$viewValue,includePDPInsurance:includePDPInsurance,PDPInsurancePrice:service.offer.prices.pdpInsurance.priceEUR};delete request.guest;var isLateBookingAllowed=service.isLateBookingAllowed();return api.book(request,getExtras(),isLateBookingAllowed).then((function(data){var response;angular.extend(service.response,data),(response=service.response).success&&stripe.redirectToCheckout({sessionId:response.successInfo.checkoutSessionId}).then((function(result){var error;(error=result.error)&&(service.response.error={},service.response.error.headline=error.headline||"",service.response.error.message=error.message||"")})),onFailure(service.response.error)}),(function(error){return error.modelState?(validation.applyServerErrors(form,error.modelState),service.ui.showErrorForPristineFields=!0,service.ui.isBooking=!1,$q.reject(error)):(service.ui.showErrorForPristineFields=!0,service.ui.isBooking=!1,$q.reject(error))}))}function getExtras(){var extras=[];if(service.offer&&service.offer.prices&&service.offer.prices.optionalServices)for(var i=0;i