function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var ReservationDatepicker=function(){"use strict";function t(e,t){var t=t||{},i=(this.format=t.format||"YYYY-MM-DD",this.infoFormat=t.infoFormat||this.format,this.separator=t.separator||" - ",this.startOfWeek=t.startOfWeek||"sunday",this.startDate=t.startDate||new Date,this.endDate=t.endDate||!1,this.modeNigth=t.modeNigth||!1,this.minNights=t.minNights||1,this.maxNights=t.maxNights||0,this.minDays=t.minDays||1,this.maxDays=t.maxDays||0,this.selectForward=t.selectForward||!1,this.disabledDates=t.disabledDates||[],this.closedDates=t.closedDates||[],this.enableCheckout=t.enableCheckout||!1,this.container=t.container||"",this.animationSpeed=t.animationSpeed||".5s",this.hoveringTooltip=t.hoveringTooltip||!0,this.autoClose=void 0===t.autoClose||t.autoClose,this.modeInline=void 0!==t.modeInline&&t.modeInline,this.callBackChangeMonth=void 0===t.callBackChangeMonth?function(){}:t.callBackChangeMonth,this.timeoutCallback=!1,this);["minDays","maxDays","minNights","maxNights"].forEach(function(t){i[t]=parseInt(i[t])}),this.i18n=t.i18n||{selected:"Your stay:",night:"Night",nights:"Nights",day:"Day",days:"Days",button:"Close","day-names":["Sun","Mon","Tue","Wed","Thur","Fri","Sat"],"month-names":["January","February","March","April","May","June","July","August","September","October","November","December"],"error-more":"Date range should not be more than 1 night","error-more-plural":"Date range should not be more than %d nights","error-less":"Date range should not be less than 1 night","error-less-plural":"Date range should not be less than %d nights","info-more":"Please select a date range longer than 1 night","info-more-plural":"Please select a date range longer than %d nights","info-range":"Please select a date range between %d and %d nights","info-default":"Please select a date range",submit:"Submit",cancel:"Cancel selection",edit:"edit",date:"Date",dates:"Dates"},this.getValue=t.getValue||function(){return e.value},this.setValue=t.setValue||function(t){e.value=t},this.onSubmitDatePicker=t.onSubmitDatePicker||function(){},this.onEditDatePicker=t.onEditDatePicker||function(){},this.onSelectDateValid=t.onSelectDateValid||function(){},this.input=e,this.init()}return t.prototype.getWeekDayNames=function(){var t="";if("monday"===this.startOfWeek){for(var e=0;e<7;e++)t+='<th class="datepicker__week-name">'+this.lang("day-names")[(1+e)%7]+"</th>";return t}for(var i=0;i<7;i++)t+='<th class="datepicker__week-name">'+this.lang("day-names")[i]+"</th>";return t},t.prototype.getMonthDom=function(t){return document.getElementById(this.getMonthTableId(t))},t.prototype.getMonthName=function(t){return this.lang("month-names")[t]},t.prototype.getDatepickerId=function(){return"datepicker-"+this.generateId()},t.prototype.getMonthTableId=function(t){return"month-"+t+"-"+this.generateId()},t.prototype.getCloseButtonId=function(){return"close-"+this.generateId()},t.prototype.getTooltipId=function(){return"tooltip-"+this.generateId()},t.prototype.getNextMonth=function(t){t=new Date(t.valueOf());return new Date(t.setMonth(t.getMonth()+1))},t.prototype.getPrevMonth=function(t){t=new Date(t.valueOf());return new Date(t.setMonth(t.getMonth()-1))},t.prototype.getDateString=function(t,e){return void 0===e&&(e=this.format),fecha.format(t,e)},t.prototype.parseDate=function(t,e){return void 0===e&&(e=this.format),fecha.parse(t,e)},t.prototype.init=function(){this.parent=this.container||this.input.parentElement,this.start=!1,this.end=!1,this.modeNigth&&(this.minDays=1<this.minNights?this.minNights+1:2,this.maxDays=0<this.maxNights?this.maxNights+1:0),this.isNoInterval=1===this.maxDays,this.modeInline&&(this.input.style.display="none"),this.startDate&&"string"==typeof this.startDate&&(this.startDate=this.parseDate(this.startDate)),this.endDate&&"string"==typeof this.endDate&&(this.endDate=this.parseDate(this.endDate)),this.isTouchDevice()&&(this.hoveringTooltip=!1),this.isOpen=this.modeInline,this.changed=!1,this.createDom();var t=new Date;this.startDate&&this.compareMonth(t,this.startDate)<0&&(t=this.startDate),this.endDate&&0<this.compareMonth(this.getNextMonth(t),this.endDate)&&(t=this.getPrevMonth(this.endDate)),this.showMonth(t,1),this.showMonth(this.getNextMonth(t),2),this.topBarDefaultText(),0<this.disabledDates.length&&this.parseDisabledDates(),0<this.closedDates.length&&this.parseClosedDates(),this.addListeners(),this.disableNextPrevButtons()},t.prototype.addListeners=function(){for(var e=this,t=this.datepicker.getElementsByClassName("datepicker__month-button--next"),i=0;i<t.length;i++)t[i].addEventListener("click",function(t){return e.goToNextMonth(t)});for(var s=this.datepicker.getElementsByClassName("datepicker__month-button--prev"),a=0;a<s.length;a++)s[a].addEventListener("click",function(t){return e.goToPreviousMonth(t)});this.input.addEventListener("click",function(t){return e.openDatepicker(t)}),this.modeInline||document.getElementById(this.getCloseButtonId()).addEventListener("click",function(t){return e.closeDatepicker(t)}),this.datepicker.querySelector(".datepicker__submit-button").addEventListener("click",function(t){return e.getSubmitDatepicker(t)}),this.datepicker.querySelector(".datepicker__cancel-button").addEventListener("click",function(t){return e.clearSelection(),e.clearHovering(),e.reload()}),this.datepicker.querySelector(".datepicker__edit-button").addEventListener("click",function(t){return e.getEditDatepicker(t)}),document.addEventListener("click",function(t){return e.documentClick(t)}),document.addEventListener("mouseover",function(t){return e.documentHover(t)}),document.addEventListener("mouseout",function(t){return e.documentMouseOut(t)}),this.input.addEventListener("change",function(){return e.checkAndSetDefaultValue()})},t.prototype.generateId=function(){var t="";return this.input.id?t+=this.input.id:t+=Date.now(),t},t.prototype.createDom=function(){var t=this.createDatepickerDomString();this.parent.insertAdjacentHTML("beforeend",t),this.datepicker=document.getElementById(this.getDatepickerId())},t.prototype.createDatepickerDomString=function(){for(var t=this,e='<div id="'+this.getDatepickerId()+'" '+(t.modeInline?"":'style="display:none"')+' class="datepicker'+(t.modeInline?" datepicker--inline":" datepicker--closed")+(this.isNoInterval?" datepicker--no-interval":"")+'">',e=(e+='<div class="datepicker__inner">')+('<div class="datepicker__topbar"><div class="datepicker__info datepicker__info--selected"><span class="datepicker__info datepicker__info--selected-label">'+(this.isNoInterval?this.lang("dates"):this.lang("date"))+' : </span> <strong class="datepicker__info-text datepicker__info-text--start-day"></strong> <span class="datepicker__info-text datepicker__info--separator">'+this.separator+'</span> <strong class="datepicker__info-text datepicker__info-text--end-day"></strong></div><div class="datepicker__info datepicker__info--edit"><button type="button" class="datepicker__button datepicker__edit-button">'+this.lang("edit")+'</button></div><div class="datepicker__info datepicker__info--feedback"></div>'+(t.modeInline?"":'<button type="button" id="'+this.getCloseButtonId()+'" class="datepicker__close-button">'+this.lang("button")+"</button>")+"</div>")+'<div class="datepicker__months">',i=1;i<=2;i++)e+='<table id="'+t.getMonthTableId(i)+'" class="datepicker__month datepicker__month--month'+i+'"><thead><tr class="datepicker__month-caption"><th><span class="datepicker__month-button datepicker__month-button--prev" month="'+i+'">&lt;</span></th><th colspan="5" class="datepicker__month-name"></th><th><span class="datepicker__month-button datepicker__month-button--next" month="'+i+'">&gt;</span></th></tr><tr class="datepicker__week-days">'+t.getWeekDayNames(i)+"</tr></thead><tbody></tbody></table>";return e=(e=(e=(e+="</div>")+('<div style="display:none" id="'+this.getTooltipId()+'" class="datepicker__tooltip"></div>'))+('<div class="datepicker__submit"><button type="button" class="datepicker__button datepicker__cancel-button">'+this.lang("cancel")+'</button><button type="button" class="datepicker__button datepicker__submit-button" disabled>'+this.lang("submit")+"</button></div>"))+"</div>"+"</div>"},t.prototype.showMonth=function(t,e){var i=this.getMonthName(t.getMonth()),s=this.getMonthDom(e),a=s.getElementsByClassName("datepicker__month-name")[0],s=s.getElementsByTagName("tbody")[0];a.textContent=i+" "+t.getFullYear(),this.emptyElement(s),s.insertAdjacentHTML("beforeend",this.createMonthDomString(t)),this.updateSelectableRange(),this["month"+e]=t},t.prototype.createMonthDomString=function(t){var e=this,i=[],s="",a=(t.setDate(1),t.getDay()),n=t.getMonth();if(0<(a=0===a&&"monday"===this.startOfWeek?7:a))for(var o=a;0<o;o--){var r=new Date(t.getTime()-864e5*o),h=e.isValidDate(r.getTime());(e.startDate&&e.compareDay(r,e.startDate)<0||e.endDate&&0<e.compareDay(r,e.endDate))&&(h=!1),i.push({date:r,type:"lastMonth",day:r.getDate(),time:r.getTime(),valid:h})}for(var d=0;d<40;d++){var l=e.addDays(t,d);h=e.isValidDate(l.getTime()),(e.startDate&&e.compareDay(l,e.startDate)<0||e.endDate&&0<e.compareDay(l,e.endDate))&&(h=!1),i.push({date:l,type:l.getMonth()===n?"visibleMonth":"nextMonth",day:l.getDate(),time:l.getTime(),valid:h})}for(var c=0;c<6&&"nextMonth"!==i[7*c].type;c++){var p=0;s+='<tr class="datepicker__week-row">';for(var m=0;m<7;m++){var g=i[7*c+(g="monday"===e.startOfWeek?m+1:m)],u=e.getDateString(g.time)===e.getDateString(new Date),y=!1,D=!1,u=(g.valid&&0<e.disabledDates.length&&(-1<e.disabledDates.indexOf(e.getDateString(g.time,"YYYY-MM-DD"))?(y=!(g.valid=!1),p++):p=0),g.valid&&0<e.closedDates.length&&(-1<e.closedDates.indexOf(e.getDateString(g.time,"YYYY-MM-DD"))?(D=!(g.valid=!1),p++):p=0),{time:g.time,class:"datepicker__month-day--"+g.type+" datepicker__month-day--"+(g.valid?"valid":"invalid")+" "+(u?"datepicker__month-day--today":"")+" "+(y?"datepicker__month-day--disabled":"")+" "+(D?"datepicker__month-day--closed":"")+" "+(y&&e.enableCheckout&&1===p?"datepicker__month-day--checkout-enabled":"")});s+='<td class="datepicker__month-day '+u.class+'" '+e.printAttributes(u)+">"+g.day+"</td>"}s+="</tr>"}return s},t.prototype.openDatepicker=function(){this.modeInline||this.isOpen||(this.removeClass(this.datepicker,"datepicker--closed"),this.addClass(this.datepicker,"datepicker--open"),this.checkAndSetDefaultValue(),this.slideDown(this.datepicker,this.animationSpeed),this.isOpen=!0,this.showSelectedDays(),this.disableNextPrevButtons())},t.prototype.closeDatepicker=function(){this.modeInline||this.isOpen&&(this.removeClass(this.datepicker,"datepicker--open"),this.addClass(this.datepicker,"datepicker--closed"),this.slideUp(this.datepicker,this.animationSpeed),this.isOpen=!1)},t.prototype.getSubmitDatepicker=function(){this.addClass(this.datepicker,"datepicker--submit"),this.onSubmitDatePicker()},t.prototype.getEditDatepicker=function(){this.removeClass(this.datepicker,"datepicker--submit"),this.onEditDatePicker()},t.prototype.autoclose=function(){this.autoClose&&this.changed&&this.isOpen&&this.start&&this.end&&this.closeDatepicker()},t.prototype.documentClick=function(t){this.parent.contains(t.target)||t.target===this.input?"td"===t.target.tagName.toLowerCase()&&this.dayClicked(t.target):this.closeDatepicker()},t.prototype.documentHover=function(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&this.dayHovering(t.target)},t.prototype.documentMouseOut=function(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&(document.getElementById(this.getTooltipId()).style.display="none")},t.prototype.checkAndSetDefaultValue=function(){var t,e=this.getValue(),e=e?e.split(this.separator):"";e&&2<=e.length?((t=this.format).match(/Do/)&&(t=t.replace(/Do/,"D"),e[0]=e[0].replace(/(\d+)(th|nd|st)/,"$1"),e[1]=e[1].replace(/(\d+)(th|nd|st)/,"$1")),this.changed=!1,this.setDateRange(this.parseDate(e[0],t),this.parseDate(e[1],t)),this.changed=!0):this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none"},t.prototype.setDateRange=function(t,e){t.getTime()>e.getTime()&&(i=e,e=t,t=i,i=null);var i=!0;if(!(i=this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&0<this.compareDay(e,this.endDate)?!1:i))return this.showMonth(this.startDate,1),this.showMonth(this.getNextMonth(this.startDate),2),this.showSelectedDays(),void this.disableNextPrevButtons();this.start=t.getTime(),this.end=e.getTime(),0<this.compareDay(t,e)&&0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),this.showMonth(t,1),this.showMonth(e,2),this.showSelectedDays(),this.disableNextPrevButtons(),this.checkSelection(),this.showSelectedInfo(),this.checkValidSubmit(),this.autoclose()},t.prototype.showSelectedDays=function(){var t=this;if(this.start||this.end)for(var e=this.datepicker.getElementsByTagName("td"),i=0;i<e.length;i++){var s=parseInt(e[i].getAttribute("time"),10);t.start&&t.end&&t.end>=s&&t.start<=s||t.start&&!t.end&&t.getDateString(t.start,"YYYY-MM-DD")===t.getDateString(s,"YYYY-MM-DD")?t.addClass(e[i],"datepicker__month-day--selected"):t.removeClass(e[i],"datepicker__month-day--selected"),t.start&&t.getDateString(t.start,"YYYY-MM-DD")===t.getDateString(s,"YYYY-MM-DD")?t.addClass(e[i],"datepicker__month-day--first-day-selected"):t.removeClass(e[i],"datepicker__month-day--first-day-selected"),t.end&&t.getDateString(t.end,"YYYY-MM-DD")===t.getDateString(s,"YYYY-MM-DD")?t.addClass(e[i],"datepicker__month-day--last-day-selected"):t.removeClass(e[i],"datepicker__month-day--last-day-selected")}},t.prototype.showSelectedInfo=function(){var t=this.datepicker.getElementsByClassName("datepicker__info--selected")[0],e=t.getElementsByClassName("datepicker__info-text--start-day")[0],i=t.getElementsByClassName("datepicker__info-text--end-day")[0],s=document.getElementById(this.getCloseButtonId());e.textContent="",i.textContent="",this.start&&(t.style.display="",e.textContent=this.getDateString(new Date(parseInt(this.start,10)),this.infoFormat)),this.end&&(i.textContent=this.getDateString(new Date(parseInt(this.end,10)),this.infoFormat)),this.isNoInterval&&(i.textContent=""),this.start&&this.end?(t=this.countDays(this.end,this.start),this.modeNigth&&(t-=1),1===t?this.modeNigth?this.lang("night"):this.lang("day"):this.modeNigth?this.lang("nights"):this.lang("days"),e=this.getDateString(new Date(this.start)),this.isNoInterval||(e=e+this.separator+this.getDateString(new Date(this.end))),this.modeInline||(s.disabled=!1),this.setValue(e,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0):this.modeInline||(s.disabled=!0)},t.prototype.dayClicked=function(t){var e;this.hasClass(t,"datepicker__month-day--invalid")||this.hasClass(t,"datepicker__month-day--disabled")||(e=parseInt(t.getAttribute("time"),10),this.addClass(t,"datepicker__month-day--selected"),this.start&&this.end||!this.start&&!this.end?(this.start=e,this.isNoInterval?this.end=e:this.end=!1):this.start&&(this.end=e),this.start&&this.end&&this.start>this.end&&(e=this.end,this.end=this.start,this.start=e),this.start=parseInt(this.start,10),this.end=parseInt(this.end,10),this.clearHovering(),this.start&&!this.end&&this.dayHovering(t),this.updateSelectableRange(),this.checkSelection(),this.showSelectedInfo(),this.checkValidSubmit(),this.showSelectedDays(),this.autoclose())},t.prototype.isValidDate=function(t){if(t=parseInt(t,10),this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&0<this.compareDay(t,this.endDate))return!1;if(this.start&&!this.end){if(0<this.maxDays&&this.countDays(t,this.start)>this.maxDays||0<this.minDays&&this.countDays(t,this.start)<this.minDays)return!1;if(this.selectForward&&t<this.start)return!1;if(0<this.disabledDates.length){var e=this.getClosestDates(new Date(parseInt(this.start,10)));if(e[0]&&this.compareDay(t,e[0])<=0)return!1;if(e[1]&&0<=this.compareDay(t,e[1]))return!1}}return!0},t.prototype.checkValidSubmit=function(){var t=this.datepicker.querySelector(".datepicker__submit-button");this.start&&this.end?(t.disabled=!1,this.addClass(t,"active"),this.onSelectDateValid()):(t.disabled=!0,this.removeClass(t,"active"))},t.prototype.checkSelection=function(){var t=this,e=Math.ceil((this.end-this.start)/864e5)+1,i=this.datepicker.getElementsByClassName("datepicker__info--feedback")[0];if(this.maxDays&&e>this.maxDays){this.start=!1,this.end=!1;for(var s=this.datepicker.getElementsByTagName("td"),a=0;a<s.length;a++)t.removeClass(s[a],"datepicker__month-day--selected"),t.removeClass(s[a],"datepicker__month-day--first-day-selected"),t.removeClass(s[a],"datepicker__month-day--last-day-selected");var n=this.maxDays;this.modeNigth&&(n-=1),this.topBarErrorText(i,"error-more",n)}else if(this.minDays&&e<this.minDays){this.start=!1,this.end=!1;for(var o=this.datepicker.getElementsByTagName("td"),r=0;r<o.length;r++)t.removeClass(o[r],"datepicker__month-day--selected"),t.removeClass(o[r],"datepicker__month-day--first-day-selected"),t.removeClass(o[r],"datepicker__month-day--last-day-selected");n=this.minDays;this.modeNigth&&(n-=1),this.topBarErrorText(i,"error-less",n)}else this.start||this.end?(this.removeClass(i,"datepicker__info--error"),this.removeClass(i,"datepicker__info--help")):(this.removeClass(i,"datepicker__info--error"),this.addClass(i,"datepicker__info--help"))},t.prototype.addDays=function(t,e){t=new Date(t);return t.setDate(t.getDate()+e),t},t.prototype.countDays=function(t,e){return Math.abs(this.daysFrom1970(t)-this.daysFrom1970(e))+1},t.prototype.compareDay=function(t,e){t=parseInt(this.getDateString(t,"YYYYMMDD"),10)-parseInt(this.getDateString(e,"YYYYMMDD"),10);return 0<t?1:0==t?0:-1},t.prototype.compareMonth=function(t,e){t=parseInt(this.getDateString(t,"YYYYMM"),10)-parseInt(this.getDateString(e,"YYYYMM"),10);return 0<t?1:0==t?0:-1},t.prototype.daysFrom1970=function(t){return Math.floor(this.toLocalTimestamp(t)/864e5)},t.prototype.toLocalTimestamp=function(t){return"string"!=typeof(t="object"===_typeof(t)&&t.getTime?t.getTime():t)||t.match(/\d{13}/)||(t=this.parseDate(t).getTime()),t=parseInt(t,10)-60*(new Date).getTimezoneOffset()*1e3},t.prototype.printAttributes=function(t){var e,i=t,s="";for(e in t)Object.prototype.hasOwnProperty.call(i,e)&&(s+=e+'="'+i[e]+'" ');return s},t.prototype.callBackChangeMonthDate=function(){var t=this;clearTimeout(this.timeoutCallback),this.timeoutCallback=setTimeout(function(){t.callBackChangeMonth()},400)},t.prototype.goToNextMonth=function(t){var t=t.target.getAttribute("month"),e=1<t,i=e?this.month2:this.month1,i=this.getNextMonth(i);!this.isSingleMonth()&&!e&&0<=this.compareMonth(i,this.month2)||this.isMonthOutOfRange(i)||(this.showMonth(i,t),this.showSelectedDays(),this.disableNextPrevButtons(),this.callBackChangeMonthDate())},t.prototype.goToPreviousMonth=function(t){var t=t.target.getAttribute("month"),e=1<t,i=e?this.month2:this.month1,i=this.getPrevMonth(i);e&&this.compareMonth(i,this.month1)<=0||this.isMonthOutOfRange(i)||(this.showMonth(i,t),this.showSelectedDays(),this.disableNextPrevButtons(),this.callBackChangeMonthDate())},t.prototype.isSingleMonth=function(){return!this.isVisible(this.getMonthDom(2))},t.prototype.isMonthOutOfRange=function(t){t=new Date(t.valueOf());return!!(this.startDate&&new Date(t.getFullYear(),t.getMonth()+1,0,23,59,59)<this.startDate||this.endDate&&new Date(t.getFullYear(),t.getMonth(),1)>this.endDate)},t.prototype.disableNextPrevButtons=function(){var t,e,i;this.isSingleMonth()||(t=parseInt(this.getDateString(this.month1,"YYYYMM"),10),e=parseInt(this.getDateString(this.month2,"YYYYMM"),10),t=Math.abs(t-e),e=this.datepicker.getElementsByClassName("datepicker__month-button--next")[0],i=this.datepicker.getElementsByClassName("datepicker__month-button--prev")[1],1<t&&89!==t?(this.removeClass(e,"datepicker__month-button--disabled"),this.removeClass(i,"datepicker__month-button--disabled")):(this.addClass(e,"datepicker__month-button--disabled"),this.addClass(i,"datepicker__month-button--disabled")))},t.prototype.topBarDefaultText=function(){var t="",e=(this.minDays&&this.maxDays&&!this.isNoInterval?(t=this.lang("info-range"),t+=" "+this.lang(this.modeNigth?"nights":"days")):this.minDays&&2<this.minDays&&!this.isNoInterval?(t=this.lang("info-more-plural"),t+=" "+this.lang(this.modeNigth?"nights":"days")):this.minDays&&!this.isNoInterval?(t=this.lang("info-more"),t+=" "+this.lang(this.modeNigth?"night":"day")):t=this.lang("info-default"),this.datepicker.getElementsByClassName("datepicker__info--feedback")[0]),t=this.modeNigth?t.replace(/%d/,this.minDays-1).replace(/%d/,this.maxDays-1):t.replace(/%d/,this.minDays).replace(/%d/,this.maxDays);this.addClass(e,"datepicker__info--help"),this.removeClass(e,"datepicker__info--error"),e.textContent=t},t.prototype.topBarErrorText=function(t,e,i){this.addClass(t,"datepicker__info--error"),this.removeClass(t,"datepicker__info--help"),1<i?(e=(e=this.lang(e+"-plural")).replace("%d",i),e+=" "+this.lang(this.modeNigth?"nights":"days"),t.textContent=e):(e=this.lang(e),e+=" "+this.lang(this.modeNigth?"night":"day")),this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none"},t.prototype.updateSelectableRange=function(){for(var t,e=this,i=this.datepicker.getElementsByTagName("td"),s=this.start&&!this.end,a=0;a<i.length;a++)e.hasClass(i[a],"datepicker__month-day--invalid")&&e.hasClass(i[a],"datepicker__month-day--tmp")&&(e.removeClass(i[a],"datepicker__month-day--invalid"),e.removeClass(i[a],"datepicker__month-day--tmp"),e.addClass(i[a],"datepicker__month-day--valid")),s&&e.hasClass(i[a],"datepicker__month-day--visibleMonth")&&(e.hasClass(i[a],"datepicker__month-day--valid")||e.hasClass(i[a],"datepicker__month-day--disabled"))&&(t=parseInt(i[a].getAttribute("time"),10),e.isValidDate(t)?(e.addClass(i[a],"datepicker__month-day--valid"),e.addClass(i[a],"datepicker__month-day--tmp"),e.removeClass(i[a],"datepicker__month-day--invalid"),e.removeClass(i[a],"datepicker__month-day--disabled")):(e.addClass(i[a],"datepicker__month-day--invalid"),e.addClass(i[a],"datepicker__month-day--tmp"),e.removeClass(i[a],"datepicker__month-day--valid")));return!0},t.prototype.dayHovering=function(t){var e,i,s,a=this,n=parseInt(t.getAttribute("time"),10),o="";if(!this.hasClass(t,"datepicker__month-day--invalid")){for(var r,h=this.datepicker.getElementsByTagName("td"),d=0;d<h.length;d++){var l=parseInt(h[d].getAttribute("time"),10);l===n?a.addClass(h[d],"datepicker__month-day--hovering"):a.removeClass(h[d],"datepicker__month-day--hovering"),a.start&&!a.end&&(a.start<l&&l<=n||a.start>l&&n<=l)?a.addClass(h[d],"datepicker__month-day--hovering"):a.removeClass(h[d],"datepicker__month-day--hovering")}this.start&&!this.end&&(r=this.countDays(n,this.start),this.modeNigth&&(r-=1),this.hoveringTooltip&&("function"==typeof this.hoveringTooltip?o=this.hoveringTooltip(r,this.start,n):!0===this.hoveringTooltip&&0<r&&(o=r+" "+(1===r?this.lang("night"):this.lang("nights")))))}o?(r=t.getBoundingClientRect(),t=this.datepicker.getBoundingClientRect(),e=r.left-t.left,i=r.top-t.top,e+=r.width/2,(s=document.getElementById(this.getTooltipId())).style.display="",s.textContent=o,t=s.getBoundingClientRect().width,r=s.getBoundingClientRect().height,e-=t/2,i-=r,setTimeout(function(){s.style.left=e+"px",s.style.top=i+"px"},10)):document.getElementById(this.getTooltipId()).style.display="none"},t.prototype.clearHovering=function(){for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--hovering");document.getElementById(this.getTooltipId()).style.display="none"},t.prototype.clearSelection=function(){this.start=!1,this.end=!1;for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected");this.setValue(""),this.checkSelection(),this.showSelectedInfo(),this.checkValidSubmit(),this.showSelectedDays()},t.prototype.parseDisabledDates=function(){for(var t=[],e=0;e<this.disabledDates.length;e++)t[e]=new Date(this.disabledDates[e]);t.sort(function(t,e){return t-e}),this.disabledDatesTime=t},t.prototype.parseClosedDates=function(){for(var t=[],e=0;e<this.closedDates.length;e++)t[e]=new Date(this.closedDates[e]);t.sort(function(t,e){return t-e}),this.closedDatesTime=t},t.prototype.getClosestDates=function(t){var e=[!1,!1];if(t<this.disabledDatesTime[0])e=this.enableCheckout?[!1,this.addDays(this.disabledDatesTime[0],1)]:[!1,this.disabledDatesTime[0]];else if(t>this.disabledDatesTime[this.disabledDatesTime.length-1])e=[this.disabledDatesTime[this.disabledDatesTime.length-1],!1];else{for(var i,s=this.disabledDatesTime.length,a=this.disabledDatesTime.length,n=Math.abs(new Date(0,0,0).valueOf()),o=n,r=-n,h=0;h<this.disabledDatesTime.length;++h)(i=t-this.disabledDatesTime[h])<0&&r<i&&(a=h,r=i),0<i&&i<o&&(s=h,o=i);this.disabledDatesTime[s]&&(e[0]=this.disabledDatesTime[s]),void 0===this.disabledDatesTime[s]?e[1]=!1:this.enableCheckout?e[1]=this.addDays(this.disabledDatesTime[a],1):e[1]=this.disabledDatesTime[a]}return e},t.prototype.lang=function(t){return t in this.i18n?this.i18n[t]:""},t.prototype.emptyElement=function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},t.prototype.classRegex=function(t){return new RegExp("(^|\\s+)"+t+"(\\s+|$)")},t.prototype.hasClass=function(t,e){return this.classRegex(e).test(t.className)},t.prototype.addClass=function(t,e){this.hasClass(t,e)||(t.className=t.className+" "+e)},t.prototype.removeClass=function(t,e){t.className=t.className.replace(this.classRegex(e)," ")},t.prototype.isVisible=function(t){return t.offsetWidth||t.offsetHeight||t.getClientRects().length},t.prototype.slideDown=function(t,e){t.style.display="";var i=t.getBoundingClientRect().height;t.style.height=0,this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=i+"px",t.addEventListener("transitionend",function(){t.style.height=t.style.transition=t.style.display=""})},t.prototype.slideUp=function(t,e){var i=t.getBoundingClientRect().height;t.style.height=i+"px",this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=0,t.addEventListener("transitionend",function(){t.style.display="none"})},t.prototype.recalc=function(t){return t.offsetHeight},t.prototype.isTouchDevice=function(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch},t.prototype.open=function(){this.openDatepicker()},t.prototype.close=function(){this.closeDatepicker()},t.prototype.getDatePicker=function(){return this.datepicker},t.prototype.setRange=function(t,e){"string"==typeof t&&"string"==typeof e&&(t=this.parseDate(t),e=this.parseDate(e)),this.setDateRange(t,e)},t.prototype.clear=function(){this.clearSelection()},t.prototype.reload=function(){var t=new Date;this.startDate&&this.compareMonth(t,this.startDate)<0&&(t=this.startDate),this.endDate&&0<this.compareMonth(this.getNextMonth(t),this.endDate)&&(t=this.getPrevMonth(this.endDate)),this.showMonth(this.month1,1),this.showMonth(this.month2,2),this.end=!1,this.start=!1,this.input.value="",this.disableNextPrevButtons(),this.showSelectedInfo()},t.prototype.refresh=function(){this.showMonth(this.month1,1),this.showMonth(this.month2,2),this.disableNextPrevButtons(),this.showSelectedInfo()},t}();