import{twMerge as t}from"tailwind-merge";import{startOfToday as e,sub as r,startOfMonth as o,startOfYear as a,startOfDay as l,max as n,min as i,isEqual as u,startOfWeek as s,format as d,addDays as m,isToday as g}from"date-fns";import{borderRadius as c}from"../../../lib/shape.js";import{fontWeight as h}from"../../../lib/font.js";import{colorPalette as x,DEFAULT_COLOR as f}from"../../../lib/theme.js";import{makeClassName as v,getColorClassNames as y}from"../../../lib/utils.js";const D=v("DateRangePicker"),C=t=>{const e=s(new Date);return Array.from(Array(7)).map(((r,o)=>d(m(e,o),"EEEEEE",{locale:t})))},b=(t,e)=>t.charAt(0).toLocaleUpperCase(e.code)+t.substring(1),p=(t,e)=>{var r,o;const a=null!==(o=null===(r=e.find((e=>e.value===t)))||void 0===r?void 0:r.startDate)&&void 0!==o?o:null;return a?l(a):null},L=(t,r)=>{var o,a;return l(null!==(a=null===(o=r.find((e=>e.value===t)))||void 0===o?void 0:o.endDate)&&void 0!==a?a:e())},k=(t,e,r,o)=>(r&&(t=p(r,o)),t?l(t&&!e?t:n([t,e])):null),w=(t,e,r,o)=>(r&&(t=L(r,o)),t?l(t&&!e?t:i([t,e])):null),E=[{value:"tdy",text:"Today",startDate:e()},{value:"w",text:"Last 7 days",startDate:r(e(),{days:7})},{value:"t",text:"Last 30 days",startDate:r(e(),{days:30})},{value:"m",text:"Month to Date",startDate:o(e())},{value:"y",text:"Year to Date",startDate:a(e())}],S=(e,r,o,a,l,n)=>t(j(e,r,o,a,n,l),T(e,r,o,a,n,l),Y(e,r,o,l),$(e,r,o,a)),$=(t,e,r,o)=>e||r?e&&r&&u(t,e)&&u(t,r)?c.md.all:e&&r&&u(t,e)?c.md.left:e&&!r&&!o&&u(t,e)||e&&!r&&o&&t<e?c.md.all:e&&!r&&o&&u(t,e)&&o>e?c.md.left:e&&!r&&o&&t>e&&t<o||e&&r&&t>e&&t<r?c.none.all:e&&!r&&o&&u(t,o)&&!u(t,e)||e&&r&&u(t,r)?c.md.right:c.md.all:c.md.all,j=(t,e,r,o,a,l=!1)=>l?y("transparent").bgColor:e&&u(t,e)?y(a,x.background).bgColor:e&&!r&&o&&t>e&&t<o?y(f,x.lightBackground).bgColor:r&&u(t,r)?y(a,x.background).bgColor:e&&r&&t>e&&t<r?y(f,x.lightBackground).bgColor:y("transparent").bgColor,T=(e,r,o,a,l,n=!1)=>n?y(f,x.lightText).textColor:g(e)?r&&u(e,r)||o&&u(e,o)?y("white").textColor:t(y(l,x.text).textColor,h.lg):r&&u(e,r)?y("white").textColor:r&&!o&&a&&e>r&&e<a?y(f,x.darkestText).textColor:o&&u(e,o)?y("white").textColor:r&&o&&e>r&&e<o?y(l,x.text).textColor:y(f,x.darkestText).textColor,Y=(t,e,r,o=!1)=>o||e&&u(t,e)||r&&u(t,r)?"":"hover:bg-gray-200",A=(t,e,r)=>{const o=(null==r?void 0:r.code)||"en-US";if(!t&&!e)return"";if(t&&!e){const e={year:"numeric",month:"short",day:"numeric"};return t.toLocaleDateString(o,e)}if(t&&e){if(u(t,e)){const e={year:"numeric",month:"short",day:"numeric"};return t.toLocaleDateString(o,e)}if(t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()){const r={month:"short",day:"numeric"};return`${t.toLocaleDateString(o,r)} - \n                    ${e.getDate()}, ${e.getFullYear()}`}{const r={year:"numeric",month:"short",day:"numeric"};return`${t.toLocaleDateString(o,r)} - \n                    ${e.toLocaleDateString(o,r)}`}}return""};export{b as capitalize,E as defaultOptions,A as formatSelectedDates,S as getDateStyles,L as getEndDateByDropdownValue,p as getStartDateByDropdownValue,C as getWeekdays,D as makeDateRangePickerClassName,w as parseEndDate,k as parseStartDate};
