"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/inputtext"),n=require("primereact/button"),i=require("primereact/csstransition"),r=require("primereact/portal"),s=require("primereact/utils"),a=require("primereact/tooltip"),o=require("primereact/ripple"),l=require("primereact/api"),u=require("primereact/overlayservice");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=p(e),h=p(l);function d(){return d=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,i=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}function P(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(e,t):void 0}}function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n1&&e[1]>e[0]),n}},{key:"onButtonClick",value:function(){this.isVisible()?this.hideOverlay():this.showOverlay()}},{key:"onPrevButtonClick",value:function(e){this.navigation={backward:!0,button:!0},this.navBackward(e)}},{key:"onNextButtonClick",value:function(e){this.navigation={backward:!1,button:!0},this.navForward(e)}},{key:"onContainerButtonKeydown",value:function(e){switch(e.which){case 9:this.trapFocus(e);break;case 27:this.hideOverlay(null,this.reFocusInputField),e.preventDefault()}}},{key:"trapFocus",value:function(e){e.preventDefault();var t=s.DomHandler.getFocusableElements(this.overlayRef.current);if(t&&t.length>0)if(document.activeElement){var n=t.indexOf(document.activeElement);e.shiftKey?-1===n||0===n?t[t.length-1].focus():t[n-1].focus():-1===n||n===t.length-1?t[0].focus():t[n+1].focus()}else t[0].focus()}},{key:"updateFocus",value:function(){var e;if(this.navigation){if(this.navigation.button)this.initFocusableCell(),this.navigation.backward?s.DomHandler.findSingle(this.overlayRef.current,".p-datepicker-prev").focus():s.DomHandler.findSingle(this.overlayRef.current,".p-datepicker-next").focus();else{if(this.navigation.backward){var t=s.DomHandler.find(this.overlayRef.current,".p-datepicker-calendar td span:not(.p-disabled)");e=t[t.length-1]}else e=s.DomHandler.findSingle(this.overlayRef.current,".p-datepicker-calendar td span:not(.p-disabled)");e&&(e.tabIndex="0",e.focus())}this.navigation=null}else this.initFocusableCell()}},{key:"initFocusableCell",value:function(){var e;if("month"===this.view){var t=s.DomHandler.find(this.overlayRef.current,".p-monthpicker .p-monthpicker-month"),n=s.DomHandler.findSingle(this.overlayRef.current,".p-monthpicker .p-monthpicker-month.p-highlight");t.forEach((function(e){return e.tabIndex=-1})),e=n||t[0]}else if(!(e=s.DomHandler.findSingle(this.overlayRef.current,"span.p-highlight"))){var i=s.DomHandler.findSingle(this.overlayRef.current,"td.p-datepicker-today span:not(.p-disabled)");e=i||s.DomHandler.findSingle(this.overlayRef.current,".p-datepicker-calendar td span:not(.p-disabled)")}e&&(e.tabIndex="0")}},{key:"navBackward",value:function(e){if(this.props.disabled)e.preventDefault();else{var t=new Date(this.getViewDate().getTime());if(t.setDate(1),"date"===this.props.view)0===t.getMonth()?(t.setMonth(11),t.setFullYear(t.getFullYear()-1)):t.setMonth(t.getMonth()-1);else if("month"===this.props.view){var n=t.getFullYear()-1;if(this.props.yearNavigator){var i=parseInt(this.props.yearRange.split(":")[0],10);ni&&(n=i)}t.setFullYear(n)}this.updateViewDate(e,t),e.preventDefault()}}},{key:"onMonthDropdownChange",value:function(e,t){var n=this.getViewDate(),i=new Date(n.getTime());i.setMonth(parseInt(t,10)),this.updateViewDate(e,i)}},{key:"onYearDropdownChange",value:function(e,t){var n=this.getViewDate(),i=new Date(n.getTime());i.setFullYear(parseInt(t,10)),this.updateViewDate(e,i)}},{key:"onTodayButtonClick",value:function(e){var t=new Date,n={day:t.getDate(),month:t.getMonth(),year:t.getFullYear(),today:!0,selectable:!0},i={hours:t.getHours(),minutes:t.getMinutes(),seconds:t.getSeconds(),milliseconds:t.getMilliseconds()};this.updateViewDate(e,t),this.onDateSelect(e,n,i),this.props.onTodayButtonClick&&this.props.onTodayButtonClick(e)}},{key:"onClearButtonClick",value:function(e){this.updateModel(e,null),this.updateInputfield(null),this.hideOverlay(null,this.reFocusInputField),this.props.onClearButtonClick&&this.props.onClearButtonClick(e)}},{key:"onPanelClick",value:function(e){this.props.inline||u.OverlayService.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"onPanelMouseUp",value:function(e){this.onPanelClick(e)}},{key:"onTimePickerElementMouseDown",value:function(e,t,n){this.props.disabled||(this.repeat(e,null,t,n),e.preventDefault())}},{key:"onTimePickerElementMouseUp",value:function(){this.props.disabled||this.clearTimePickerTimer()}},{key:"onTimePickerElementMouseLeave",value:function(){this.props.disabled||this.clearTimePickerTimer()}},{key:"repeat",value:function(e,t,n,i){var r=this;e.persist();var s=t||500;switch(this.clearTimePickerTimer(),this.timePickerTimer=setTimeout((function(){r.repeat(e,100,n,i)}),s),n){case 0:1===i?this.incrementHour(e):this.decrementHour(e);break;case 1:1===i?this.incrementMinute(e):this.decrementMinute(e);break;case 2:1===i?this.incrementSecond(e):this.decrementSecond(e);break;case 3:1===i?this.incrementMilliSecond(e):this.decrementMilliSecond(e)}}},{key:"clearTimePickerTimer",value:function(){this.timePickerTimer&&clearTimeout(this.timePickerTimer)}},{key:"incrementHour",value:function(e){var t=this.getCurrentDateTime(),n=t.getHours()+this.props.stepHour;this.validateHour(n=n>=24?n-24:n,t)&&(this.props.maxDate&&this.props.maxDate.toDateString()===t.toDateString()&&this.props.maxDate.getHours()===n&&(this.props.maxDate.getMinutes()t.getMinutes()||this.props.minDate.getMinutes()===t.getMinutes())?this.props.minDate.getSeconds()>t.getSeconds()?this.props.minDate.getMilliseconds()>t.getMilliseconds()?this.updateTime(e,n,this.props.minDate.getMinutes(),this.props.minDate.getSeconds(),this.props.minDate.getMilliseconds()):this.updateTime(e,n,this.props.minDate.getMinutes(),this.props.minDate.getSeconds(),t.getMilliseconds()):this.updateTime(e,n,this.props.minDate.getMinutes(),t.getSeconds(),t.getMilliseconds()):this.updateTime(e,n,t.getMinutes(),t.getSeconds(),t.getMilliseconds())),e.preventDefault()}},{key:"doStepMinute",value:function(e,t){if(this.props.stepMinute<=1)return t?e+t:e;if(!t&&e%(t=this.props.stepMinute)==0)return e;var n=e+t;return n=Math.floor(n/t)*t}},{key:"incrementMinute",value:function(e){var t=this.getCurrentDateTime(),n=t.getMinutes(),i=this.doStepMinute(n,this.props.stepMinute);this.validateMinute(i=i>59?i-60:i,t)&&(this.props.maxDate&&this.props.maxDate.toDateString()===t.toDateString()&&this.props.maxDate.getMinutes()===i&&this.props.maxDate.getSeconds()t.getSeconds()?this.props.minDate.getMilliseconds()>t.getMilliseconds()?this.updateTime(e,t.getHours(),i,this.props.minDate.getSeconds(),this.props.minDate.getMilliseconds()):this.updateTime(e,t.getHours(),i,this.props.minDate.getSeconds(),t.getMilliseconds()):this.updateTime(e,t.getHours(),i,t.getSeconds(),t.getMilliseconds())),e.preventDefault()}},{key:"incrementSecond",value:function(e){var t=this.getCurrentDateTime(),n=t.getSeconds()+this.props.stepSecond;this.validateSecond(n=n>59?n-60:n,t)&&(this.props.maxDate&&this.props.maxDate.toDateString()===t.toDateString()&&this.props.maxDate.getSeconds()===n&&this.props.maxDate.getMilliseconds()t.getMilliseconds()?this.updateTime(e,t.getHours(),t.getMinutes(),n,this.props.minDate.getMilliseconds()):this.updateTime(e,t.getHours(),t.getMinutes(),n,t.getMilliseconds())),e.preventDefault()}},{key:"incrementMilliSecond",value:function(e){var t=this.getCurrentDateTime(),n=t.getMilliseconds()+this.props.stepMillisec;this.validateMillisecond(n=n>999?n-1e3:n,t)&&this.updateTime(e,t.getHours(),t.getMinutes(),t.getSeconds(),n),e.preventDefault()}},{key:"decrementMilliSecond",value:function(e){var t=this.getCurrentDateTime(),n=t.getMilliseconds()-this.props.stepMillisec;this.validateMillisecond(n=n<0?n+999:n,t)&&this.updateTime(e,t.getHours(),t.getMinutes(),t.getSeconds(),n),e.preventDefault()}},{key:"toggleAmPm",value:function(e){var t=this.getCurrentDateTime(),n=t.getHours();this.updateTime(e,n>=12?n-12:n+12,t.getMinutes(),t.getSeconds(),t.getMilliseconds()),e.preventDefault()}},{key:"getViewDate",value:function(e){var t=this.props.value,n=e||(this.props.onViewDateChange?this.props.viewDate:this.state.viewDate);return Array.isArray(t)&&(t=t[0]),n&&this.isValidDate(n)?n:t&&this.isValidDate(t)?t:new Date}},{key:"getCurrentDateTime",value:function(){if(this.isSingleSelection())return this.props.value&&this.props.value instanceof Date?this.props.value:this.getViewDate();if(this.isMultipleSelection()){if(this.props.value&&this.props.value.length)return this.props.value[this.props.value.length-1]}else if(this.isRangeSelection()){if(this.props.value&&this.props.value.length)return this.props.value[1]||this.props.value[0]}return new Date}},{key:"isValidDate",value:function(e){return e instanceof Date&&!isNaN(e)}},{key:"validateHour",value:function(e,t){var n=!0,i=t?t.toDateString():null;return this.props.minDate&&i&&this.props.minDate.toDateString()===i&&this.props.minDate.getHours()>e&&(n=!1),this.props.maxDate&&i&&this.props.maxDate.toDateString()===i&&this.props.maxDate.getHours()e&&(n=!1),this.props.maxDate&&i&&this.props.maxDate.toDateString()===i&&t.getHours()===this.props.maxDate.getHours()&&this.props.maxDate.getMinutes()e&&(n=!1),this.props.maxDate&&i&&this.props.maxDate.toDateString()===i&&t.getHours()===this.props.maxDate.getHours()&&t.getMinutes()===this.props.maxDate.getMinutes()&&this.props.maxDate.getSeconds()e&&(n=!1),this.props.maxDate&&i&&this.props.maxDate.toDateString()===i&&t.getHours()===this.props.maxDate.getHours()&&t.getSeconds()===this.props.maxDate.getSeconds()&&t.getMinutes()===this.props.maxDate.getMinutes()&&this.props.maxDate.getMilliseconds()t&&(t=r),s&&sthis.props.value.length)&&this.selectDate(e,t,n);else this.selectDate(e,t,n);this.props.inline||!this.isSingleSelection()||this.props.showTime&&!this.props.hideOnDateTimeSelect||(setTimeout((function(){i.hideOverlay("dateselect")}),100),this.touchUIMask&&this.disableModality()),e.preventDefault()}else e.preventDefault()}},{key:"selectTime",value:function(e,t){if(this.props.showTime){var n,i,r,s;if(t)n=t.hours,i=t.minutes,r=t.seconds,s=t.milliseconds;else{var a=this.getCurrentDateTime(),o=[a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()];n=o[0],i=o[1],r=o[2],s=o[3]}e.setHours(n),e.setMinutes(i),e.setSeconds(r),e.setMilliseconds(s)}}},{key:"selectDate",value:function(e,t,n){var i=new Date(t.year,t.month,t.day);this.selectTime(i,n),this.props.minDate&&this.props.minDate>i&&(i=this.props.minDate),this.props.maxDate&&this.props.maxDate=s.getTime()?a=i:(a=s,s=i),this.updateModel(e,r=[s,a])}else this.updateModel(e,r=[i,null]);this.props.onSelect&&this.props.onSelect({originalEvent:e,value:i}),this.updateInputfield(r)}},{key:"onMonthSelect",value:function(e,t){this.onDateSelect(e,{year:this.getViewDate().getFullYear(),month:t,day:1,selectable:!0}),e.preventDefault()}},{key:"updateModel",value:function(e,t){if(this.props.onChange){var n=t&&t instanceof Date?new Date(t.getTime()):t;this.viewStateChanged=!0,this.props.onChange({originalEvent:e,value:n,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:n}})}}},{key:"showOverlay",value:function(e){var t=this;this.props.onVisibleChange?this.props.onVisibleChange({visible:!0,type:e}):this.setState({overlayVisible:!0},(function(){t.overlayEventListener=function(e){t.isOutsideClicked(e.target)||(t.isOverlayClicked=!0)},u.OverlayService.on("overlay-click",t.overlayEventListener)}))}},{key:"hideOverlay",value:function(e,t){var n=this,i=function(){n.viewStateChanged=!1,n.ignoreFocusFunctionality=!1,n.isOverlayClicked=!1,t&&t(),u.OverlayService.off("overlay-click",n.overlayEventListener),n.overlayEventListener=null};this.props.onVisibleChange?this.props.onVisibleChange({visible:!1,type:e,callback:i}):this.setState({overlayVisible:!1},i)}},{key:"onOverlayEnter",value:function(){if(this.props.autoZIndex){var e=this.props.touchUI?"modal":"overlay";s.ZIndexUtils.set(e,this.overlayRef.current,h.default.autoZIndex,this.props.baseZIndex||h.default.zIndex[e])}this.alignOverlay()}},{key:"onOverlayEntered",value:function(){this.bindDocumentClickListener(),this.bindDocumentResizeListener(),this.bindScrollListener(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindDocumentClickListener(),this.unbindDocumentResizeListener(),this.unbindScrollListener()}},{key:"onOverlayExited",value:function(){s.ZIndexUtils.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){!e.isOverlayClicked&&e.isVisible()&&e.isOutsideClicked(t.target)&&e.hideOverlay("outside"),e.isOverlayClicked=!1},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindDocumentResizeListener",value:function(){this.documentResizeListener||this.props.touchUI||(this.documentResizeListener=this.onWindowResize.bind(this),window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentResizeListener",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new s.ConnectedOverlayScrollHandler(this.container,(function(){e.isVisible()&&e.hideOverlay()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"isOutsideClicked",value:function(e){return this.container&&!(this.container.isSameNode(e)||this.isNavIconClicked(e)||this.container.contains(e)||this.overlayRef&&this.overlayRef.current.contains(e))}},{key:"isNavIconClicked",value:function(e){return s.DomHandler.hasClass(e,"p-datepicker-prev")||s.DomHandler.hasClass(e,"p-datepicker-prev-icon")||s.DomHandler.hasClass(e,"p-datepicker-next")||s.DomHandler.hasClass(e,"p-datepicker-next-icon")}},{key:"onWindowResize",value:function(){this.isVisible()&&!s.DomHandler.isTouchDevice()&&this.hideOverlay()}},{key:"alignOverlay",value:function(){this.props.touchUI?this.enableModality():s.DomHandler.alignOverlay(this.overlayRef.current,this.inputRef.current.parentElement,this.props.appendTo||h.default.appendTo)}},{key:"enableModality",value:function(){var e=this;this.touchUIMask||(this.touchUIMask=document.createElement("div"),this.touchUIMask.style.zIndex=String(s.ZIndexUtils.get(this.overlayRef.current)-1),s.DomHandler.addMultipleClasses(this.touchUIMask,"p-component-overlay p-datepicker-mask p-datepicker-mask-scrollblocker p-component-overlay-enter"),this.touchUIMaskClickListener=function(){e.disableModality()},this.touchUIMask.addEventListener("click",this.touchUIMaskClickListener),document.body.appendChild(this.touchUIMask),s.DomHandler.addClass(document.body,"p-overflow-hidden"))}},{key:"disableModality",value:function(){var e=this;this.touchUIMask&&(s.DomHandler.addClass(this.touchUIMask,"p-component-overlay-leave"),this.touchUIMask.addEventListener("animationend",(function(){e.destroyMask()})))}},{key:"destroyMask",value:function(){this.touchUIMask.removeEventListener("click",this.touchUIMaskClickListener),this.touchUIMaskClickListener=null,document.body.removeChild(this.touchUIMask),this.touchUIMask=null;for(var e,t=document.body.children,n=0;n=7?i-7:i}},{key:"getDaysCountInMonth",value:function(e,t){return 32-this.daylightSavingAdjust(new Date(t,e,32)).getDate()}},{key:"getDaysCountInPrevMonth",value:function(e,t){var n=this.getPreviousMonthAndYear(e,t);return this.getDaysCountInMonth(n.month,n.year)}},{key:"daylightSavingAdjust",value:function(e){return e?(e.setHours(e.getHours()>12?e.getHours()+2:0),e):null}},{key:"getPreviousMonthAndYear",value:function(e,t){var n,i;return 0===e?(n=11,i=t-1):(n=e-1,i=t),{month:n,year:i}}},{key:"getNextMonthAndYear",value:function(e,t){var n,i;return 11===e?(n=0,i=t+1):(n=e+1,i=t),{month:n,year:i}}},{key:"getSundayIndex",value:function(){var e=l.localeOption("firstDayOfWeek",this.props.locale);return e>0?7-e:0}},{key:"createWeekDays",value:function(){for(var e=[],t=l.localeOptions(this.props.locale),n=t.firstDayOfWeek,i=t.dayNamesMin,r=0;r<7;r++)e.push(i[n]),n=6===n?0:++n;return e}},{key:"createMonths",value:function(e,t){for(var n=[],i=0;i11&&(r=r%11-1,s=t+1),n.push(this.createMonth(r,s))}return n}},{key:"createMonth",value:function(e,t){for(var n=[],i=this.getFirstDayOfMonthIndex(e,t),r=this.getDaysCountInMonth(e,t),s=this.getDaysCountInPrevMonth(e,t),a=1,o=new Date,l=[],u=Math.ceil((r+i)/7),p=0;pr){var g=this.getNextMonthAndYear(e,t);c.push({day:a-r,month:g.month,year:g.year,otherMonth:!0,today:this.isToday(o,a-r,g.month,g.year),selectable:this.isSelectable(a-r,g.month,g.year,!0)})}else c.push({day:a,month:e,year:t,today:this.isToday(o,a,e,t),selectable:this.isSelectable(a,e,t,!1)});a++}this.props.showWeek&&l.push(this.getWeekNumber(new Date(c[0].year,c[0].month,c[0].day))),n.push(c)}return{month:e,year:t,dates:n,weekNumbers:l}}},{key:"getWeekNumber",value:function(e){var t=new Date(e.getTime());t.setDate(t.getDate()+4-(t.getDay()||7));var n=t.getTime();return t.setMonth(0),t.setDate(1),Math.floor(Math.round((n-t.getTime())/864e5)/7)+1}},{key:"isSelectable",value:function(e,t,n,i){var r=!0,s=!0,a=!0,o=!0,l=!0;return this.props.minDate&&(this.props.minDate.getFullYear()>n||this.props.minDate.getFullYear()===n&&(this.props.minDate.getMonth()>t||this.props.minDate.getMonth()===t&&this.props.minDate.getDate()>e))&&(r=!1),this.props.maxDate&&(this.props.maxDate.getFullYear()e.getHours()||this.props.minDate.getHours()===e.getHours()&&(this.props.minDate.getMinutes()>e.getMinutes()||this.props.minDate.getMinutes()===e.getMinutes()&&(this.props.minDate.getSeconds()>e.getSeconds()||this.props.minDate.getSeconds()===e.getSeconds()&&this.props.minDate.getMilliseconds()>e.getMilliseconds())))&&(t=!1),this.props.maxDate&&this.props.maxDate.toDateString()===e.toDateString()&&(this.props.maxDate.getHours()=i.getTime()}return!1}},{key:"isSingleSelection",value:function(){return"single"===this.props.selectionMode}},{key:"isRangeSelection",value:function(){return"range"===this.props.selectionMode}},{key:"isMultipleSelection",value:function(){return"multiple"===this.props.selectionMode}},{key:"isToday",value:function(e,t,n,i){return e.getDate()===t&&e.getMonth()===n&&e.getFullYear()===i}},{key:"isDateDisabled",value:function(e,t,n){if(this.props.disabledDates)for(var i=0;i11&&12!==n&&(n-=12),t+="12"===this.props.hourFormat&&0===n?12:n<10?"0"+n:n,t+=":",t+=i<10?"0"+i:i,this.props.showSeconds&&(t+=":",t+=r<10?"0"+r:r),this.props.showMillisec&&(t+=".",t+=s<100?(s<10?"00":"0")+s:s),"12"===this.props.hourFormat&&(t+=e.getHours()>11?" PM":" AM"),t}},{key:"parseValueFromString",value:function(e){if(!e||0===e.trim().length)return null;var t;if(this.isSingleSelection())t=this.parseDateTime(e);else if(this.isMultipleSelection()){t=[];var n,i=H(e.split(","));try{for(i.s();!(n=i.n()).done;){t.push(this.parseDateTime(n.value.trim()))}}catch(e){i.e(e)}finally{i.f()}}else if(this.isRangeSelection()){var r=e.split(" - ");t=[];for(var s=0;s23||s>59||"12"===this.props.hourFormat&&r>12||this.props.showSeconds&&(isNaN(a)||a>59)||this.props.showMillisec&&(isNaN(a)||a>1e3))throw new Error("Invalid time");return"12"===this.props.hourFormat&&12!==r&&"PM"===t&&(r+=12),{hour:r,minute:s,second:a,millisecond:o}}},{key:"parseDate",value:function(e,t){if(null==t||null==e)throw new Error("Invalid arguments");if(""===(e="object"===m(e)?e.toString():e+""))return null;var n,i,r,s,a=0,o="string"!=typeof this.props.shortYearCutoff?this.props.shortYearCutoff:(new Date).getFullYear()%100+parseInt(this.props.shortYearCutoff,10),u=-1,p=-1,c=-1,h=-1,d=!1,f=function(e){var i=n+1-1)for(p=1,c=h;;){if(c<=(i=this.getDaysCountInMonth(u,p-1)))break;p++,c-=i}if((s=this.daylightSavingAdjust(new Date(u,p-1,c))).getFullYear()!==u||s.getMonth()+1!==p||s.getDate()!==c)throw new Error("Invalid date");return s}},{key:"renderBackwardNavigator",value:function(e){var t=this;return c.default.createElement("button",d({type:"button",className:"p-datepicker-prev p-link"},e?{onClick:this.onPrevButtonClick,onKeyDown:function(e){return t.onContainerButtonKeydown(e)}}:{style:{visibility:"hidden"}}),c.default.createElement("span",{className:"p-datepicker-prev-icon pi pi-chevron-left"}),c.default.createElement(o.Ripple,null))}},{key:"renderForwardNavigator",value:function(e){var t=this;return c.default.createElement("button",d({type:"button",className:"p-datepicker-next p-link"},e?{onClick:this.onNextButtonClick,onKeyDown:function(e){return t.onContainerButtonKeydown(e)}}:{style:{visibility:"hidden"}}),c.default.createElement("span",{className:"p-datepicker-next-icon pi pi-chevron-right"}),c.default.createElement(o.Ripple,null))}},{key:"isInMinYear",value:function(e){return this.props.minDate&&this.props.minDate.getFullYear()===e.getFullYear()}},{key:"isInMaxYear",value:function(e){return this.props.maxDate&&this.props.maxDate.getFullYear()===e.getFullYear()}},{key:"renderTitleMonthElement",value:function(e){var t=this,n=l.localeOption("monthNames",this.props.locale);if(this.props.monthNavigator&&"month"!==this.props.view){var i=this.getViewDate(),r=i.getMonth(),a=n.map((function(e,n){return(!t.isInMinYear(i)||n>=t.props.minDate.getMonth())&&(!t.isInMaxYear(i)||n<=t.props.maxDate.getMonth())?{label:e,value:n,index:n}:null})).filter((function(e){return!!e})),o=a.map((function(e){return e.label})),u=c.default.createElement("select",{className:"p-datepicker-month",onChange:function(e){return t.onMonthDropdownChange(e,e.target.value)},value:r},a.map((function(e){return c.default.createElement("option",{key:e.label,value:e.value},e.label)})));return this.props.monthNavigatorTemplate?s.ObjectUtils.getJSXElement(this.props.monthNavigatorTemplate,{onChange:this.onMonthDropdownChange,className:"p-datepicker-month",value:r,names:o,options:a,element:u,props:this.props}):u}return c.default.createElement("span",{className:"p-datepicker-month"},n[e])}},{key:"renderTitleYearElement",value:function(e){var t=this;if(this.props.yearNavigator){for(var n=[],i=this.props.yearRange.split(":"),r=parseInt(i[0],10),a=parseInt(i[1],10),o=r;o<=a;o++)n.push(o);var l=this.getViewDate().getFullYear(),u=n.filter((function(e){return!(t.props.minDate&&t.props.minDate.getFullYear()>e||t.props.maxDate&&t.props.maxDate.getFullYear()11&&12!==t&&(t-=12));var n=t<10?"0"+t:t;return c.default.createElement("div",{className:"p-hour-picker"},c.default.createElement("button",{type:"button",className:"p-link",onMouseDown:function(t){return e.onTimePickerElementMouseDown(t,0,1)},onMouseUp:this.onTimePickerElementMouseUp,onMouseLeave:this.onTimePickerElementMouseLeave,onKeyDown:function(t){return e.onContainerButtonKeydown(t)}},c.default.createElement("span",{className:"pi pi-chevron-up"}),c.default.createElement(o.Ripple,null)),c.default.createElement("span",null,n),c.default.createElement("button",{type:"button",className:"p-link",onMouseDown:function(t){return e.onTimePickerElementMouseDown(t,0,-1)},onMouseUp:this.onTimePickerElementMouseUp,onMouseLeave:this.onTimePickerElementMouseLeave,onKeyDown:function(t){return e.onContainerButtonKeydown(t)}},c.default.createElement("span",{className:"pi pi-chevron-down"}),c.default.createElement(o.Ripple,null)))}},{key:"renderMinutePicker",value:function(){var e=this,t=this.getCurrentDateTime().getMinutes(),n=t<10?"0"+t:t;return c.default.createElement("div",{className:"p-minute-picker"},c.default.createElement("button",{type:"button",className:"p-link",onMouseDown:function(t){return e.onTimePickerElementMouseDown(t,1,1)},onMouseUp:this.onTimePickerElementMouseUp,onMouseLeave:this.onTimePickerElementMouseLeave,onKeyDown:function(t){return e.onContainerButtonKeydown(t)}},c.default.createElement("span",{className:"pi pi-chevron-up"}),c.default.createElement(o.Ripple,null)),c.default.createElement("span",null,n),c.default.createElement("button",{type:"button",className:"p-link",onMouseDown:function(t){return e.onTimePickerElementMouseDown(t,1,-1)},onMouseUp:this.onTimePickerElementMouseUp,onMouseLeave:this.onTimePickerElementMouseLeave,onKeyDown:function(t){return e.onContainerButtonKeydown(t)}},c.default.createElement("span",{className:"pi pi-chevron-down"}),c.default.createElement(o.Ripple,null)))}},{key:"renderSecondPicker",value:function(){var e=this;if(this.props.showSeconds){var t=this.getCurrentDateTime().getSeconds(),n=t<10?"0"+t:t;return c.default.createElement("div",{className:"p-second-picker"},c.default.createElement("button",{type:"button",className:"p-link",onMouseDown:function(t){return e.onTimePickerElementMouseDown(t,2,1)},onMouseUp:this.onTimePickerElementMouseUp,onMouseLeave:this.onTimePickerElementMouseLeave,onKeyDown:function(t){return e.onContainerButtonKeydown(t)}},c.default.createElement("span",{className:"pi pi-chevron-up"}),c.default.createElement(o.Ripple,null)),c.default.createElement("span",null,n),c.default.createElement("button",{type:"button",className:"p-link",onMouseDown:function(t){return e.onTimePickerElementMouseDown(t,2,-1)},onMouseUp:this.onTimePickerElementMouseUp,onMouseLeave:this.onTimePickerElementMouseLeave,onKeyDown:function(t){return e.onContainerButtonKeydown(t)}},c.default.createElement("span",{className:"pi pi-chevron-down"}),c.default.createElement(o.Ripple,null)))}return null}},{key:"renderMiliSecondPicker",value:function(){var e=this;if(this.props.showMillisec){var t=this.getCurrentDateTime().getMilliseconds(),n=t<100?(t<10?"00":"0")+t:t;return c.default.createElement("div",{className:"p-millisecond-picker"},c.default.createElement("button",{type:"button",className:"p-link",onMouseDown:function(t){return e.onTimePickerElementMouseDown(t,3,1)},onMouseUp:this.onTimePickerElementMouseUp,onMouseLeave:this.onTimePickerElementMouseLeave,onKeyDown:function(t){return e.onContainerButtonKeydown(t)}},c.default.createElement("span",{className:"pi pi-chevron-up"}),c.default.createElement(o.Ripple,null)),c.default.createElement("span",null,n),c.default.createElement("button",{type:"button",className:"p-link",onMouseDown:function(t){return e.onTimePickerElementMouseDown(t,3,-1)},onMouseUp:this.onTimePickerElementMouseUp,onMouseLeave:this.onTimePickerElementMouseLeave,onKeyDown:function(t){return e.onContainerButtonKeydown(t)}},c.default.createElement("span",{className:"pi pi-chevron-down"}),c.default.createElement(o.Ripple,null)))}return null}},{key:"renderAmPmPicker",value:function(){if("12"===this.props.hourFormat){var e=this.getCurrentDateTime().getHours()>11?"PM":"AM";return c.default.createElement("div",{className:"p-ampm-picker"},c.default.createElement("button",{type:"button",className:"p-link",onClick:this.toggleAmPm},c.default.createElement("span",{className:"pi pi-chevron-up"}),c.default.createElement(o.Ripple,null)),c.default.createElement("span",null,e),c.default.createElement("button",{type:"button",className:"p-link",onClick:this.toggleAmPm},c.default.createElement("span",{className:"pi pi-chevron-down"}),c.default.createElement(o.Ripple,null)))}return null}},{key:"renderSeparator",value:function(e){return c.default.createElement("div",{className:"p-separator"},c.default.createElement("span",null,e))}},{key:"renderTimePicker",value:function(){return this.props.showTime||this.props.timeOnly?c.default.createElement("div",{className:"p-timepicker"},this.renderHourPicker(),this.renderSeparator(":"),this.renderMinutePicker(),this.props.showSeconds&&this.renderSeparator(":"),this.renderSecondPicker(),this.props.showMillisec&&this.renderSeparator("."),this.renderMiliSecondPicker(),"12"===this.props.hourFormat&&this.renderSeparator(":"),this.renderAmPmPicker()):null}},{key:"renderInputElement",value:function(){return this.props.inline?null:c.default.createElement(t.InputText,{ref:this.inputRef,id:this.props.inputId,name:this.props.name,type:"text",className:this.props.inputClassName,style:this.props.inputStyle,readOnly:this.props.readOnlyInput,disabled:this.props.disabled,required:this.props.required,autoComplete:"off",placeholder:this.props.placeholder,tabIndex:this.props.tabIndex,onInput:this.onUserInput,onFocus:this.onInputFocus,onBlur:this.onInputBlur,onKeyDown:this.onInputKeyDown,"aria-labelledby":this.props.ariaLabelledBy,inputMode:this.props.inputMode})}},{key:"renderButton",value:function(){return this.props.showIcon?c.default.createElement(n.Button,{type:"button",icon:this.props.icon,onClick:this.onButtonClick,tabIndex:"-1",disabled:this.props.disabled,className:"p-datepicker-trigger"}):null}},{key:"renderContent",value:function(){var e=this.renderInputElement(),t=this.renderButton();return"left"===this.props.iconPos?c.default.createElement(c.default.Fragment,null,t,e):c.default.createElement(c.default.Fragment,null,e,t)}},{key:"renderButtonBar",value:function(){var e=this;if(this.props.showButtonBar){var t=s.classNames("p-button-text",this.props.todayButtonClassName),i=s.classNames("p-button-text",this.props.clearButtonClassName),r=l.localeOptions(this.props.locale),a=r.clear;return c.default.createElement("div",{className:"p-datepicker-buttonbar"},c.default.createElement(n.Button,{type:"button",label:r.today,onClick:this.onTodayButtonClick,onKeyDown:function(t){return e.onContainerButtonKeydown(t)},className:t}),c.default.createElement(n.Button,{type:"button",label:a,onClick:this.onClearButtonClick,onKeyDown:function(t){return e.onContainerButtonKeydown(t)},className:i}))}return null}},{key:"renderFooter",value:function(){if(this.props.footerTemplate){var e=this.props.footerTemplate();return c.default.createElement("div",{className:"p-datepicker-footer"},e)}return null}},{key:"render",value:function(){var e,t=this,n=s.classNames("p-calendar p-component p-inputwrapper",this.props.className,(I(e={},"p-calendar-w-btn p-calendar-w-btn-".concat(this.props.iconPos),this.props.showIcon),I(e,"p-calendar-disabled",this.props.disabled),I(e,"p-calendar-timeonly",this.props.timeOnly),I(e,"p-inputwrapper-filled",this.props.value||s.DomHandler.hasClass(this.inputRef.current,"p-filled")&&""!==this.inputRef.current.value),I(e,"p-inputwrapper-focus",this.state.focused),e)),i=s.classNames("p-datepicker p-component",this.props.panelClassName,{"p-datepicker-inline":this.props.inline,"p-disabled":this.props.disabled,"p-datepicker-timeonly":this.props.timeOnly,"p-datepicker-multiple-month":this.props.numberOfMonths>1,"p-datepicker-monthpicker":"month"===this.props.view,"p-datepicker-touch-ui":this.props.touchUI}),r=this.renderContent(),a=this.renderDatePicker(),o=this.renderTimePicker(),l=this.renderButtonBar(),u=this.renderFooter(),p=this.props.inline||this.isVisible();return c.default.createElement("span",{ref:function(e){return t.container=e},id:this.props.id,className:n,style:this.props.style},r,c.default.createElement(F,{ref:this.overlayRef,className:i,style:this.props.panelStyle,appendTo:this.props.appendTo,inline:this.props.inline,onClick:this.onPanelClick,onMouseUp:this.onPanelMouseUp,in:p,onEnter:this.onOverlayEnter,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited,transitionOptions:this.props.transitionOptions},a,o,l,u))}}]),v}();I(U,"defaultProps",{id:null,inputRef:null,name:null,value:null,visible:!1,viewDate:null,style:null,className:null,inline:!1,selectionMode:"single",inputId:null,inputStyle:null,inputClassName:null,inputMode:"none",required:!1,readOnlyInput:!1,keepInvalid:!1,mask:null,disabled:!1,tabIndex:null,placeholder:null,showIcon:!1,icon:"pi pi-calendar",iconPos:"right",showOnFocus:!0,numberOfMonths:1,view:"date",touchUI:!1,showTime:!1,timeOnly:!1,showSeconds:!1,showMillisec:!1,hourFormat:"24",stepHour:1,stepMinute:1,stepSecond:1,stepMillisec:1,shortYearCutoff:"+10",hideOnDateTimeSelect:!1,showWeek:!1,locale:null,dateFormat:null,panelStyle:null,panelClassName:null,monthNavigator:!1,yearNavigator:!1,yearRange:null,disabledDates:null,disabledDays:null,minDate:null,maxDate:null,maxDateCount:null,showOtherMonths:!0,selectOtherMonths:!1,showButtonBar:!1,todayButtonClassName:"p-button-secondary",clearButtonClassName:"p-button-secondary",autoZIndex:!0,baseZIndex:0,appendTo:null,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,dateTemplate:null,headerTemplate:null,footerTemplate:null,monthNavigatorTemplate:null,yearNavigatorTemplate:null,transitionOptions:null,onVisibleChange:null,onFocus:null,onBlur:null,onInput:null,onSelect:null,onChange:null,onViewDateChange:null,onTodayButtonClick:null,onClearButtonClick:null,onShow:null,onHide:null}),exports.Calendar=U;