import{slicedToArray as t,defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import o,{forwardRef as i,useRef as r,useState as s,useCallback as l,useMemo as a,useEffect as n}from"react";import{camelCase as d}from"es-toolkit";import u from"classnames";import{getStyle as p}from"../../helpers/typesciptCssModulesHelper.js";import m from"../../hooks/usePrevious/index.js";import c from"../../hooks/useMergeRef.js";import{ButtonWrapper as f}from"./ButtonWrapper.js";import{Button as v}from"@vibe/button/mockedClassNames";import{withStaticProps as b}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import{getTestId as h}from"../../tests/testIds.js";import{ComponentDefaultTestId as y,ComponentVibeId as k}from"../../tests/constants.js";import B from"./ButtonGroup.module.scss.js";var C=b(i((function(i,v){var b=i.className,C=i.options,j=i.name,N=void 0===j?"":j,T=i.disabled,g=void 0!==T&&T,P=i.value,x=void 0===P?"":P,M=i.onSelect,O=i.size,S=void 0===O?"small":O,U=i.kind,D=void 0===U?"secondary":U,W=i.groupAriaLabel,z=void 0===W?"":W,E=i.tooltipPosition,G=i.tooltipHideDelay,H=i.tooltipShowDelay,I=i.tooltipContainerSelector,_=i.tooltipMoveBy,w=i.blurOnMouseUp,A=void 0===w||w,L=i.id,R=i["data-testid"],F=i.fullWidth,q=void 0!==F&&F,J=r(),K=c(v,J),Q=s(x),V=t(Q,2),X=V[0],Y=V[1],Z=m(x),$=l((function(t){g||t.disabled||(Y(t.value),M&&M(t.value,N))}),[M,g,N]),tt=function(t){return(null==t?void 0:t.value)===X},et=a((function(){return C.find((function(t){return tt(t)}))}),[C,X]),ot=a((function(){return C.map((function(t,i){var r=tt(t),s=0===i,l=i===C.length-1,a=tt(C[i+1]);return o.createElement(f,{key:t.value,size:S,onClick:function(){return $(t)},rightIcon:t.icon,leftIcon:t.leftIcon,active:r,rightFlat:i!==C.length-1,leftFlat:0!==i,kind:"tertiary",preventClickAnimation:!0,ariaLabel:t.ariaLabel,tooltipContent:t.tooltipContent,tooltipPosition:E,tooltipHideDelay:G,tooltipShowDelay:H,tooltipContainerSelector:I,tooltipMoveBy:_,blurOnMouseUp:A,fullWidth:q,className:u(B.button,B.optionText,e(e(e(e(e(e({},B.selected,r),B.disabled,g),B.buttonDisabled,t.disabled),B.fullWidth,q),B.startBorder,s),B.endBorder,l||!a)),activeButtonClassName:B.activeButton},t.text)}))}),[C,X,S,E,G,H,I,_,A,g,q,$]);return n((function(){x!==Z&&x!==X&&Y(x)}),[x,Z,X,Y]),o.createElement("div",{className:u(B.buttonGroup,b,p(B,d("kind-"+D)),e({},B.disabled,g)),id:L,"data-testid":R||h(y.BUTTON_GROUP,L),"data-vibe":k.BUTTON_GROUP,ref:K},o.createElement("div",{role:"group","aria-label":z,className:u(B.buttonsContainer,e({},B.fullWidth,q)),"aria-disabled":g},ot),et&&et.subText&&o.createElement("div",{className:u(B.subTextContainer)},et.subText))})),{sizes:v.sizes,kinds:v.kinds});export{C as default};
//# sourceMappingURL=ButtonGroup.js.map
