import e,{useCallback as n,useMemo as t}from"react";import r from"classnames";import{useDayPicker as o,useNavigation as a}from"react-day-picker";import i from"../../IconButton/IconButton.js";import l from"../Dropdown/Dropdown.js";import s from"./DatePickerHeader.module.scss.js";import{useMonthsOptionItems as u,useYearsOptionItems as c}from"./datePickerHooks.js";import{format as m}from"date-fns";import f from"../../../../components/layout/dist/Flex/Flex.js";import p from"../../../../components/button/dist/Button/Button.js";import d from"../../../../icons/dist/react/DropdownChevronLeft.js";import b from"../../../../icons/dist/react/DropdownChevronRight.js";var v=function(m){var v=m.setDisplayMonth,j=m.monthSelectionAriaLabel,D=m.yearSelectionAriaLabel,g=m.nextButtonAriaLabel,k=m.prevButtonAriaLabel,M=m.locale,w=m.className,y=o().month,B=a(),E=B.goToMonth,A=B.nextMonth,C=B.previousMonth,R=n((function(){return E(A)}),[E,A]),z=n((function(){return E(C)}),[E,C]),N=u({locale:M}),x=c({locale:M}),T=t((function(){return N.map((function(e){return Object.assign(Object.assign({},e),{value:e.id})}))}),[N]),F=t((function(){return x.map((function(e){return Object.assign(Object.assign({},e),{value:e.id})}))}),[x]),I=t((function(){return L(y,M)}),[y,M]),O=t((function(){return h(y,M)}),[y,M]),S=n((function(e){var n=e.value,t=new Date(y);t.setMonth(+n),v(t)}),[y,v]),Y=n((function(e){var n=e.value,t=new Date(y);t.setFullYear(+n),v(t)}),[y,v]),H=t((function(){return T.find((function(e){return e.value===""+y.getMonth()}))}),[T,y]),P=t((function(){return F.find((function(e){return e.value===""+y.getFullYear()}))}),[F,y]);return e.createElement("div",{className:r(s.datePickerHeader,w)},e.createElement(f,{gap:"small"},e.createElement(l,{className:s.monthButtonDropdown,ariaLabel:j,options:T,value:H,onChange:S,menuWrapperClassName:s.monthButtonDropdown,size:"small",valueRenderer:function(e){return I},searchable:!1,clearable:!1,borderless:!0}),e.createElement(l,{className:s.yearButtonDropdown,ariaLabel:D,options:F,value:P,onChange:Y,menuWrapperClassName:s.yearButtonDropdown,size:"small",valueRenderer:function(e){return O},searchable:!1,clearable:!1,borderless:!0})),e.createElement(f,null,e.createElement(i,{kind:p.kinds.TERTIARY,size:p.sizes.SMALL,ariaLabel:k,onClick:z,icon:d}),e.createElement(i,{kind:p.kinds.TERTIARY,size:p.sizes.SMALL,ariaLabel:g,onClick:R,icon:b})))};function h(e,n){return m(e,"yyyy",{locale:n})}function L(e,n){return m(e,"MMM",{locale:n})}export{v as default,L as getMonthButtonLabel,h as getYearButtonLabel};
//# sourceMappingURL=DatePickerHeader.js.map
