text: (function(){window.translations||(window.translations={}),window.translations.datepicker={start_from_sunday:0,months:["","Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],short_months:["","Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],days:["Пн","Вт","Ср","Чт","Пт","Сб","Вс"],legend:{startDate:"Дата заезда",endDate:"Дата выезда"}}}).call(this),function(){this.TpDatepickerMonthRenderer=function(){function t(t,e,i,r,s){var n;this.callback=t,this.daysNames=e,this.sundayFirst=i,this.onlyFuture=s,n=this.marks,this.marksPrev=n[0],this.marksCurrent=n[1],this.marksNext=n[2],this.isTouchDevice||(this.isTouchDevice=window.isTouchDevice),r&&(this.prefix=r)}return t.prototype.prefix="",t.prototype.marks=["prev","current-date","next"],t.prototype.isTouchDevice=null,t.prototype.render=function(t,e,i,r,s){return this._buildTable(this._monthDaysArray(t,e),i,r,s,e)},t.prototype._firstDay=function(t,e){return new Date(t,e-1,1).getDay()},t.prototype._monthLength=function(t,e){return 32-new Date(t,e-1,32,10).getDate()},t.prototype._monthDaysArray=function(t,e){var i,r,s,n,o,a,p,h,d;n=d=t,i=[],r=!0,1===e?(d--,o=12,s=e+1):12===e?(n++,s=1,o=e-1):(s=e+1,o=e-1),p=this._monthLength(d,o),h=p-this._firstDay(t,e)+1-this.sundayFirst,a=p+1,h===a&&(h-=6,r=!1);for(var c=h,u=a;u>c;i.push([d,o,c++,this.marksPrev]));for(var c=1,u=this._monthLength(t,e)+1;u>c;i.push([t,e,c++,this.marksCurrent]));for(var c=1;14>c;i.push([n,s,c++,this.marksNext]));return r&&i.shift(),i},t.prototype._callbackProxy=function(t){var e;return e=t.target,"DIV"===e.tagName&&(e=e.parentNode),e.classList.contains(this.prefix+"tp-datepicker-prev-date")&&this.onlyFuture?void 0:e.hasAttribute("id")&&this.callback(t.type,e)},t.prototype._buildTable=function(t,e,i,r,s){var n,o,a,p,h,d,c,u,l,f,y,k,D;for(k=document.createElement("table"),k.classList.add(this.prefix+"tp-datepicker-table"),k.classList.add(this.prefix+"tp-datepicker-table--"+(this.sundayFirst?"sunday-first":"normal-weekdays")),n=function(t){return function(e){return t._callbackProxy(e)}}(this),k.addEventListener("click",n),k.addEventListener("mouseout",n),k.addEventListener("mouseover",n),window.isTouchDevice&&(k.addEventListener("touchstart",n),k.addEventListener("touchend",n),k.addEventListener("touchmove",n)),D=k.appendChild(document.createElement("tr")),c=f=0;6>=f;c=++f)d=D.appendChild(document.createElement("td")),d.classList.add(this.prefix+"tp-datepicker-day_name"),d.textContent=this.daysNames[c];for(h={},c=y=0;42>y;c=++y)o=t[c],c%7===0&&(d=k.appendChild(document.createElement("tr"))),a=o[0]+"-"+o[1]+"-"+o[2],u=this.prefix+"tp-datepicker-"+a,p=h[u]=d.appendChild(document.createElement("td")),l=p.appendChild(document.createElement("div")),p.setAttribute("id",u),p.setAttribute("data-date",a),l.textContent=o[2],p.className=this.prefix+"tp-datepicker-"+o[3],i||e&&(r>o[2]&&s>=o[1]||o[3]===this.marksPrev)?p.className+=" "+this.prefix+"tp-datepicker-prev-date":p.className+=" "+this.prefix+"tp-datepicker-current";return this.days=h,k},t}()}.call(this),function(){this.TpDatepickerPopupRenderer=function(){function t(t,e,i){var r,s,n,o,a;this.datepicker=t,i&&(this.prefix=i),this.onlyFuture=this.datepicker.onlyFuture,r=this.datepicker.t.days,a=this.datepicker.t.start_from_sunday,a&&r.unshift(r.pop()),this.monthRenderer=new TpDatepickerMonthRenderer(e,r,a,this.prefix,this.onlyFuture),this.node=document.createElement("div"),this.nodeClassList=this.node.classList,this.nodeClassList.add(this.prefix+"tp-datepicker"),this.nodeClassList.add(this.prefix+"tp-datepicker-"+this.datepicker.type),s=document.createElement("div"),s.className=this.prefix+"tp-datepicker-header",o=document.createElement("span"),o.className=this.prefix+"tp-datepicker-prev-month-control",o.setAttribute("role","tp-datepicker-prev"),s.appendChild(o),this.MonthNode=document.createElement("span"),this.MonthNode.setAttribute("role","tp-datepicker-month"),s.appendChild(this.MonthNode),n=document.createElement("span"),n.className=this.prefix+"tp-datepicker-next-month-control",n.setAttribute("role","tp-datepicker-next"),s.appendChild(n),this.node.appendChild(s),this.datepickerContainerNode=document.createElement("div"),this.datepickerContainerNode.className=this.prefix+"tp-datepicker-container",this.datepickerContainerNode.setAttribute("role","tp-datepicker-table-wrapper"),this.datepickerContainerNode.appendChild(document.createElement("span")),this.node.appendChild(this.datepickerContainerNode),this.datepicker.legend&&(this.legendNode=document.createElement("span"),this.legendNode.className=this.prefix+"tp-datepicker-legend",this.legendNode.setAttribute("role","tp-datepicker-legend"),this.node.appendChild(this.legendNode)),document.body.appendChild(this.node),this.node}return t.prototype.prefix="",t.prototype.node=!1,t.prototype.monthRenderer=null,t.prototype.render=function(){var t,e,i;return i=this.datepicker.year,t=this.datepicker.month,e=this.monthRenderer.render(i,t,this.datepicker.isCurrentMonth,this.datepicker.isPrevMonth,this.datepicker.currentDay),this.nodeClassList.toggle(this.prefix+"tp-datepicker--current_month",this.onlyFuture&&this.datepicker.isCurrentMonth),this.updateMonth(this.datepicker.t.months[t]+" "+i),this.datepickerContainerNode.replaceChild(e,this.datepickerContainerNode.childNodes[0])},t.prototype.updateMonth=function(t){return this.MonthNode.textContent=t},t}()}.call(this),function(){window.isTouchDevice=window.ontouchstart||navigator.MaxTouchPoints>0||navigator.msMaxTouchPoints>0,this.SwipeDetector=function(){function t(t,e,i){this.wrapper=null!=t?t:document.body,this.callbacks=null!=e?e:{},this.sensivity=null!=i?i:10,this.wrapper.addEventListener("touchstart",function(t){return function(e){return t.handleTouchStart(e)}}(this),!1),this.wrapper.addEventListener("touchend",function(t){return function(e){return t.handleTouchEnd(e)}}(this),!1),this.wrapper.addEventListener("touchmove",function(t){return function(e){return t.handleTouchMove(e)}}(this),!1)}return t.prototype.xDown=null,t.prototype.yDown=null,t.prototype.wrapper=null,t.prototype.callbacks={},t.prototype.sensivity=50,t.prototype.xDiff=0,t.prototype.yDiff=0,t.prototype.blockScroll=!1,t.prototype.handleTouchStart=function(t){return this.blockScroll=!0,this.xDown=t.touches[0].clientX,this.yDown=t.touches[0].clientY},t.prototype.handleTouchEnd=function(t){return this.blockScroll=!1,Math.abs(this.xDiff)>Math.abs(this.yDiff)?Math.abs(Math.abs(this.xDiff)-Math.abs(this.yDiff))>this.sensivity&&(this.xDiff>0?this.callbacks.left&&this.callbacks.left():this.callbacks.right&&this.callbacks.right()):Math.abs(Math.abs(this.yDiff)-Math.abs(this.xDiff))>this.sensivity&&(this.yDiff>0?this.callbacks.up&&this.callbacks.up():this.callbacks.down&&this.callbacks.down()),this.xDown=null,this.yDown=null,this.xDiff=0,this.yDiff=0},t.prototype.handleTouchMove=function(t){var e,i;return this.blockScroll&&t.preventDefault(),this.xDown&&this.yDown?(e=t.touches[0].clientX,i=t.touches[0].clientY,this.xDiff+=this.xDown-e,this.yDiff+=this.yDown-i,this.xDown=e,this.yDown=i):void 0},t}()}.call(this),function(){window.positionManager={positionAround:function(t,e,i,r){var s,n,o,a,p,h,d,c;return null==i&&(i=!1),null==r&&(r={top:0,left:0}),e.style.position="absolute",s=document.documentElement.getBoundingClientRect(),d=t.getBoundingClientRect(),h=this._getOffset(t),p=t.offsetHeight,n=document.documentElement.clientHeight-d.bottom,a=i||n>e.offsetHeight,a||(a=n>d.top),a?(c=h.top+p-s.top+r.top,o=h.left-s.left+r.left):(c=h.top-e.offsetHeight-s.top-r.top,o=h.left-s.left+r.left),o+s.left+e.offsetWidth>window.innerWidth-s.left&&(o=window.innerWidth-s.left-e.offsetWidth),c+e.offsetHeight>window.innerHeight-s.top&&(c=window.innerHeight-s.top-e.offsetHeight),o<-s.left&&(o=-s.left),c<-s.top&&(c=-s.top),e.style.top=c+"px",e.style.left=o+"px"},_getOffset:function(t){var e,i;for(e=i=0;t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop);)e+=t.offsetLeft-t.scrollLeft,i+=t.offsetTop-t.scrollTop,t=t.offsetParent;return{top:i,left:e}}}}.call(this),function(){this.TpDatepicker=function(){function t(t){var e,i,r,s,n;for(null==t&&(t={}),this.nodes=[],this.datepickerWrapper=t.wrapper||document.body,this.roles=t.role&&[t.role]||t.roles||["tp-datepicker"],this.role=this.roles[0],t.callback&&(this.onSelect=t.callback),t.prefix&&(this.prefix=t.prefix),t.offsets&&(this.offsets=t.offsets),s=this.roles,e=0,i=s.length;i>e;e++)n=s[e],r=this.nodes[n]=this.datepickerWrapper.querySelector('[role="'+n+'"]'),r.classList.add(this.prefix+"tp-datepicker-trigger"),this[n]=this._parseDate(r.getAttribute("data-date")),r.setAttribute("readonly",!0),r.addEventListener("focus",this._listenerFor(n)),r.addEventListener("keydown",function(t){return function(e){return t._processKey(e.keyCode)}}(this));this._initPopup()}return t.prototype.prefix="",t.prototype.roles=[],t.prototype.role=null,t.prototype.wrapper=!1,t.prototype.popupRenderer=!1,t.prototype.today=new Date,t.prototype.isCurrentMonth=!1,t.prototype.t=window.translations.datepicker,t.prototype.isTouchDevice=window.isTouchDevice,t.prototype.settedRoles=!1,t.prototype.legend=!1,t.prototype.type="simple",t.prototype.onlyFuture=!0,t.prototype.offsets={top:0,left:0},t.prototype.onSelect=function(t,e){return console.log(e+" selected date "+t)},t.prototype._initPopup=function(){var t;return this.currentMonth=this.today.getMonth()+1,this.currentYear=this.today.getFullYear(),this.currentDay=this.today.getDate(),t=function(t){return function(e,i){return t._callback_proxy(e,i)}}(this),this.popupRenderer=new TpDatepickerPopupRenderer(this,t,this.prefix),window.SwipeDetector&&new SwipeDetector(this.popupRenderer.node,{left:function(t){return function(){return t.nextMonth()}}(this),right:function(t){return function(){return t.prevMonth()}}(this),down:function(t){return function(){return t.popupRenderer.node.classList.remove(t.prefix+"tp-datepicker--active")}}(this),up:function(t){return function(){return t.popupRenderer.node.classList.remove(t.prefix+"tp-datepicker--active")}}(this)}),this.popupRenderer.node.querySelector('[role="tp-datepicker-prev"]').addEventListener("click",function(t){return function(){return t.prevMonth()}}(this)),this.popupRenderer.node.querySelector('[role="tp-datepicker-next"]').addEventListener("click",function(t){return function(){return t.nextMonth()}}(this)),document.addEventListener("click",function(t){return function(e){var i;if(i=e.target){if("BODY"!==i.tagName&&"HTML"!==i.tagName){if(t.roles.indexOf(i.getAttribute("role"))>=0)return;for(;(i=i.parentNode)&&"BODY"!==i.tagName;)if(!i.parentNode||i.classList.contains(t.prefix+"tp-datepicker")||t.roles.indexOf(i.getAttribute("role"))>=0)return}return t.nodes[t.role].classList.remove(t.prefix+"tp-datepicker-trigger--active"),t.popupRenderer.node.classList.remove(t.prefix+"tp-datepicker--active")}}}(this))},t.prototype._processKey=function(t){switch(t){case 27:case 9:return this.popupRenderer.node.classList.remove(this.prefix+"tp-datepicker--active"),this.nodes[this.role].classList.remove(this.prefix+"tp-datepicker-trigger--active");case 8:return this.nodes[this.role].setAttribute("value","")}},t.prototype.prevMonth=function(){return this.onlyFuture&&this.isCurrentMonth?void 0:(1===this.month?(this.year--,this.month=12):this.month--,this._renderDatepicker())},t.prototype.nextMonth=function(){return 12===this.month?(this.year++,this.month=1):this.month++,this._renderDatepicker()},t.prototype.show=function(t,e){var i,r,s;this.role=t,this.callback=e,this.date=this._parseDate(this[this.role])||this.today,this.month=this.date.getMonth()+1,this.year=this.date.getFullYear(),this._renderDatepicker(),r=this.nodes;for(s in r)i=r[s],this.roles.indexOf(s)>-1&&i.classList.toggle(this.prefix+"tp-datepicker-trigger--active",s===this.role);return window.positionManager?window.positionManager.positionAround(this.nodes[this.role],this.popupRenderer.node,!1,this.offsets):void 0},t.prototype._callback_proxy=function(t,e){switch(t){case"click":return this.callback(e.getAttribute("data-date")),!0;default:return!1}},t.prototype._listenerFor=function(t){return function(e){return function(i){return e.show(t,function(i){return e._showCallback(i,t)}),e.isTouchDevice?(i.preventDefault(),i.target.blur()):void 0}}(this)},t.prototype._showCallback=function(t,e){return t&&(this[e]=t),this._setupDate(e,this[e]),this.settedRoles?void 0:(this.nodes[this.role].classList.remove(this.prefix+"tp-datepicker-trigger--active"),this.popupRenderer.node.classList.remove(this.prefix+"tp-datepicker--active"),this.onSelect(t,e))},t.prototype._setupDate=function(t,e){return this.nodes[t].setAttribute("data-date",e),this.nodes[t].setAttribute("value",this._formatDate(e))},t.prototype._renderDatepicker=function(){return this.isCurrentMonth=this.currentYear===this.year&&this.currentMonth===this.month,this.isPrevMonth=this.currentYear>this.year||this.currentYear===this.year&&this.currentMonth>this.month,this.popupRenderer.render(this),this.popupRenderer.node.classList.add(this.prefix+"tp-datepicker--active")},t.prototype._parseDate=function(t){var e;if(t)return e=t.split("-"),new Date(e[0],parseInt(e[1],10)-1,e[2])},t.prototype._stringifyDate=function(t){return t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate()},t.prototype._formatDate=function(t){var e;if(t)return e=t.split("-"),e[2]+" "+this.t.short_months[parseInt(e[1],10)].toLowerCase()+" "+e[0]},t.prototype._setScale=function(t,e){return null==e&&(e=this.popupRenderer.node),e.style.webkitTransform=e.style.transform="scale("+t+")"},t}()}.call(this),function(){var t=function(t,i){function r(){this.constructor=t}for(var s in i)e.call(i,s)&&(t[s]=i[s]);return r.prototype=i.prototype,t.prototype=new r,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.TpDatepickerRange=function(e){function i(t){var e;null==t&&(t={}),t.role=null,t.roles||(t.roles=["startDate","endDate"]),t.legend&&(this.legend=t.legend),i.__super__.constructor.call(this,t),e=this.roles,this.startDateRole=e[0],this.endDateRole=e[1],this.settedRoles[this.startDateRole]=this.settedRoles[this.endDateRole]=!1}return t(i,e),i.prototype.isEndDate=!1,i.prototype.settedRoles={},i.prototype.prevRole=!1,i.prototype.readyToDraw=!0,i.prototype.legend=!1,i.prototype.type="range",i.prototype.onSelect=function(t,e,i){return console.log(i+" selected range from "+t+" to "+e)},i.prototype.show=function(t,e){return this.role=t,this.callback=e,this.isEndDate=this.role===this.endDateRole,i.__super__.show.call(this,this.role,this.callback),this.prevRole=this.role},i.prototype._callback_proxy=function(t,e){if(i.__super__._callback_proxy.call(this,t,e))return!0;switch(t){case"mouseout":return this.readyToDraw=!0,!0;case"mouseover":if(!this.readyToDraw)return;return this.isEndDate?this._drawSausage(this.startDate,e.getAttribute("data-date")):this._drawSausage(e.getAttribute("data-date"),this.endDate),this.readyToDraw=!1,!0;default:return!1}},i.prototype._currentDateType=function(){return this.isEndDate?"endDate":"startDate"},i.prototype._showCallback=function(t,e){var r;return i.__super__._showCallback.call(this,t,e),t&&(this[this._currentDateType()]=t),this.settedRoles[e]=!0,this._checkDates(e),r=this._oppositeRole(e),this.settedRoles[r]?(this.nodes[this.role].classList.remove(this.prefix+"tp-datepicker-trigger--active"),this.popupRenderer.node.classList.remove(this.prefix+"tp-datepicker--active")):(this._setupDate(r,this[r]),this._listenerFor(r)()),this.onSelect(this.startDateObj,this.endDateObj,e)},i.prototype._oppositeRole=function(){return this.isEndDate?this.startDateRole:this.endDateRole},i.prototype._checkDates=function(t){var e;return this.startDateObj=this._parseDate(this.startDate)||this.endDateObj&&this._changeDate(this.endDateObj,-1)||this.today,this.endDateObj=this._parseDate(this.endDate)||this.startDateObj&&this._changeDate(this.startDateObj,1),e=this._oppositeRole(t),(this.startDateObj>=this.endDateObj||!this.settedRoles[e]||this.endDateObj===this.today)&&(this.settedRoles[e]=!1,this.isEndDate?(this.endDateObj===this.today&&(this.endDateObj=this._changeDate(this.today,1)),this.startDateObj=this._changeDate(this.endDateObj,-1)):this.endDateObj=this._changeDate(this.startDateObj,1)),this.startDate=this[this.startDateRole]=this._stringifyDate(this.startDateObj),this.endDate=this[this.endDateRole]=this._stringifyDate(this.endDateObj)},i.prototype._renderDatepicker=function(){return i.__super__._renderDatepicker.call(this),this._drawSausage(this.startDate,this.endDate),this.legend&&this.prevRole!==this.role?this._updateLegend(this.t.legend[this._currentDateType()]):void 0},i.prototype._updateLegend=function(t){var e;return e=this.popupRenderer.legendNode,e.textContent=t,e.classList.toggle(this.prefix+"tp-datepicker-legend--start-date",!this.isEndDate),e.classList.toggle(this.prefix+"tp-datepicker-legend--end-date",this.isEndDate),this._setScale(1.1,e),setTimeout(function(t){return function(){return t._setScale(1,e)}}(this),200)},i.prototype._drawSausage=function(t,e){var i,r,s,n,o,a,p,h,d,c,u,l;if(t||e){t||(t=e),e||(e=t),r=t.split("-"),i=e.split("-"),l=parseInt(r[1],10)<this.month&&parseInt(i[1],10)>=this.month,o=parseInt(i[1],10)<this.month&&parseInt(r[1],10)>=this.month,t=this.prefix+"tp-datepicker-"+t,e=this.prefix+"tp-datepicker-"+e,u=t===e,d=this.popupRenderer.monthRenderer.days,c=[];for(n in d)h=d[n],s=h.classList,this.onlyFuture&&s.contains(this.prefix+"tp-datepicker-prev-date")?c.push(void 0):(p=t===n,a=e===n,!p||(u||o)&&this.isEndDate?a&&(l||this.isEndDate)?(s.add(this.prefix+"tp-datepicker-end-sausage"),s.remove(this.prefix+"tp-datepicker-range"),s.remove(this.prefix+"tp-datepicker-start-sausage"),s.remove(this.prefix+"tp-datepicker-end-sausage--invisible"),s.remove(this.prefix+"tp-datepicker-start-sausage--invisible"),l&&s.add(this.prefix+"tp-datepicker-range"),l=u,c.push(o=!0)):l&&!o?(s.add(this.prefix+"tp-datepicker-range"),s.remove(this.prefix+"tp-datepicker-start-sausage"),c.push(s.remove(this.prefix+"tp-datepicker-end-sausage"))):(a?(o=!0,s.add(this.prefix+"tp-datepicker-end-sausage--invisible"),s.remove(this.prefix+"tp-datepicker-start-sausage--invisible")):p?(s.add(this.prefix+"tp-datepicker-start-sausage--invisible"),s.remove(this.prefix+"tp-datepicker-end-sausage--invisible")):(s.remove(this.prefix+"tp-datepicker-start-sausage--invisible"),s.remove(this.prefix+"tp-datepicker-end-sausage--invisible")),s.remove(this.prefix+"tp-datepicker-range"),s.remove(this.prefix+"tp-datepicker-start-sausage"),c.push(s.remove(this.prefix+"tp-datepicker-end-sausage"))):(s.add(this.prefix+"tp-datepicker-start-sausage"),s.remove(this.prefix+"tp-datepicker-range"),s.remove(this.prefix+"tp-datepicker-end-sausage"),s.remove(this.prefix+"tp-datepicker-end-sausage--invisible"),s.remove(this.prefix+"tp-datepicker-start-sausage--invisible"),l=!u,l&&!o?c.push(s.add(this.prefix+"tp-datepicker-range")):c.push(void 0)));return c}},i.prototype._changeDate=function(t,e){return null==e&&(e=1),new Date(new Date(t).setDate(t.getDate()+e))},i}(TpDatepicker)}.call(this);