import e from"react";import{twMerge as t}from"tailwind-merge";import o from"../../../assets/ArrowDownHeadIcon.js";import"tslib";import n from"../../../assets/CalendarIcon.js";import l from"../../../assets/XCircleIcon.js";import{BaseColors as r}from"../../../lib/constants.js";import{borderRadius as a,boxShadow as i,border as s}from"../../../lib/shape.js";import{sizing as m}from"../../../lib/sizing.js";import{spacing as d}from"../../../lib/spacing.js";import{fontSize as c,fontWeight as g}from"../../../lib/font.js";import{colorPalette as p,DEFAULT_COLOR as u}from"../../../lib/theme.js";import{getColorClassNames as f}from"../../../lib/utils.js";import{formatSelectedDates as h,makeDateRangePickerClassName as w}from"./dateRangePickerUtils.js";import{getSelectButtonColors as b,hasValue as x}from"../selectUtils.js";const C=({value:C,options:j,placeholder:v,disabled:R,calendarRef:B,showCalendar:D,setShowCalendar:E,onCalendarKeyDown:N,enableDropdown:y,dropdownRef:X,showDropdown:I,setShowDropdown:T,onDropdownKeyDown:k,locale:K,dropdownPlaceholder:S="Select",enableClear:M,onClear:P})=>{var L;const[U,Y,z]=C,A=null!=(U||Y),H=x(z),q=A?h(U,Y,K):v,F=z?String(null===(L=j.find((e=>e.value===z)))||void 0===L?void 0:L.text):S;return e.createElement("div",{className:t(w("button"),"flex items-center justify-between",f("white").bgColor,a.md.all,i.sm)},e.createElement("button",{type:"button",ref:B,onClick:()=>E(!D),onKeyDown:N,className:t(w("calendarButton"),"flex items-center w-full truncate focus:outline-none focus:ring-2",b(A,R),y?s.none.right:t(a.md.right,s.sm.right),f(r.Blue,p.lightRing).focusRingColor,d.twoXl.paddingX,d.sm.paddingY,a.md.left,s.sm.all),disabled:R},e.createElement(n,{className:t(w("calendarButtonIcon"),"flex-none",f(u,p.lightText).textColor,m.lg.height,m.lg.width,d.threeXs.negativeMarginLeft,d.lg.marginRight),"aria-hidden":"true"}),e.createElement("p",{className:t(w("calendarButtonText"),"whitespace-nowrap truncate w-full text-start",c.sm,g.md)},q),M&&A?e.createElement("div",{role:"button",className:t(w("resetButton"),d.xs.marginRight),onClick:e=>{e.stopPropagation(),P()}},e.createElement(l,{className:t("flex-none",m.md.height,m.md.width,f(u,p.lightText).textColor),"aria-hidden":"true"})):null),y?e.createElement("button",{type:"button",ref:X,onClick:()=>T(!I),className:t(w("dropdownButton"),"inline-flex justify-between w-48 truncate focus:outline-none focus:ring-2",b(H,R),f(r.Blue,p.lightRing).focusRingColor,d.twoXl.paddingX,d.sm.paddingY,d.px.negativeMarginLeft,a.md.right,s.sm.all),onKeyDown:k,disabled:R},e.createElement("p",{className:t(w("dropdownButtonText"),"whitespace-nowrap truncate",c.sm,g.md)},F),e.createElement(o,{className:t(w("dropdownButtonIcon"),"flex-none",m.lg.height,m.lg.width,d.twoXs.negativeMarginRight,f(u,p.lightText).textColor),"aria-hidden":"true"})):null)};export{C as default};
