"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.isDisabled=exports.getMonth=exports.getWeek=exports.toRange=exports.dayOffset=exports.getCalendar=exports.makeDayObject=void 0,require("core-js/modules/es6.array.fill");var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")),_dateFns=require("date-fns"),makeDayObject=function(e,t){var a=t.startDate,n=t.endDate,r=t.hoverDate,s=t.minDate,i=t.maxDate,o=t.month,d=getRange(a,n,r);return{date:e,isToday:(0,_dateFns.isToday)(e),isWeekend:(0,_dateFns.isWeekend)(e),isLastMonth:(0,_dateFns.isSameMonth)((0,_dateFns.subMonths)(e,1),o),isNextMonth:(0,_dateFns.isSameMonth)((0,_dateFns.addMonths)(e,1),o),isStartDate:isStartDate(e,d),isEndDate:isEndDate(e,d),isWithinSelection:isWithinSelection(e,a,n),isPreview:isPreview(e,a,n,r),isDisabled:isDisabled(e,s,i)}};exports.makeDayObject=makeDayObject;var getCalendar=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,a=(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).onlyMonth,n=void 0!==a&&a;if(calendarCache[e])return calendarCache[e];var r=getMonth(e);if(n)return calendarCache[e]=(0,_toConsumableArray2.default)(r);var s=(7+(0,_dateFns.getDay)((0,_dateFns.startOfMonth)(e))-t)%7,i=getMonth((0,_dateFns.subMonths)(e,1),(0,_dateFns.getDaysInMonth)((0,_dateFns.subMonths)(e,1))-s),o=42-(r.length+s),d=getMonth((0,_dateFns.addMonths)(e,1),0,-1<o?o:0);return calendarCache[e]=[].concat((0,_toConsumableArray2.default)(i),(0,_toConsumableArray2.default)(r),(0,_toConsumableArray2.default)(d))};exports.getCalendar=getCalendar;var calendarCache={},dayOffset=function(e){return e?["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].indexOf(e.toLowerCase()):0};exports.dayOffset=dayOffset;var toRange=function(e,t){if((0,_dateFns.isBefore)(t,e)){var a=[t,e];e=a[0],t=a[1]}return{startDate:e,endDate:t}};exports.toRange=toRange;var getRange=function(e,t,a){return toRange(e,e&&t?t:e&&a?a:e)},getWeek=function(e){var a=(0,_dateFns.startOfWeek)(new Date,{weekStartsOn:e});return Array(7).fill(1).map(function(e,t){return(0,_dateFns.addDays)(a,t)})};exports.getWeek=getWeek;var getMonth=function(e){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,t=2<arguments.length?arguments[2]:void 0,n=(0,_dateFns.startOfMonth)(e),r=(0,_dateFns.getDaysInMonth)(e)-a;return r=(r=Math.min(Math.max(parseInt(r),0),-1<t?t:r))<0?0:r,Array(r).fill(1).map(function(e,t){return(0,_dateFns.addDays)(n,t+a)})};exports.getMonth=getMonth;var isWithinSelection=function(e,t,a){var n=toRange(t,a);return!(!t||!a)&&(0,_dateFns.isWithinRange)(e,n.startDate,n.endDate)},isDisabled=function(e,t,a){return t&&(0,_dateFns.isBefore)(e,t)||a&&(0,_dateFns.isAfter)(e,a)};exports.isDisabled=isDisabled;var isStartDate=function(e,t){return t.startDate&&(0,_dateFns.isSameDay)(e,t.startDate)},isEndDate=function(e,t){return t.endDate&&(0,_dateFns.isSameDay)(e,t.endDate)},isPreview=function(e,t,a,n){var r=toRange(t,n);return t&&!a&&(0,_dateFns.isWithinRange)(e,r.startDate,r.endDate)};
//# sourceMappingURL=DatePickerCalc.js.map
