import{slicedToArray as e,defineProperty as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import o from"classnames";import n,{forwardRef as a,useRef as i,useState as r,useCallback as s}from"react";import l from"../../hooks/useMergeRef.js";import{Icon as c}from"@vibe/icon/mockedClassNames";import d from"../Text/Text.js";import{DropdownChevronDown as m}from"@vibe/icons";import{getTestId as p,ComponentDefaultTestId as f}from"../../tests/testIds.js";import v from"./ExpandCollapse.module.scss.js";import{ComponentVibeId as u}from"../../tests/constants.js";var C=a((function(a,C){var h=a.children,N=a.headerComponentRenderer,E=void 0===N?null:N,g=a.title,x=void 0===g?"":g,y=a.className,P=a.defaultOpenState,b=void 0!==P&&P,j=a.iconSize,k=void 0===j?24:j,B=a.iconPosition,O=void 0===B?"right":B,A=a.id,S=void 0===A?"":A,I=a.open,L=a.onClick,T=void 0===L?null:L,_=a.hideBorder,z=void 0!==_&&_,D=a.headerClassName,R=a.contentClassName,X=a.componentClassName,w=a["data-testid"],H=a.captureOnClick,M=void 0===H||H,q=i(null),F=l(C,q),G=r(b),J=e(G,2),K=J[0],Q=J[1],U=void 0===I?K:I,V=function(){Q(!K)},W=s((function(){return"string"==typeof x?n.createElement(d,{type:"text1",className:o(v.headerContent)},x):x}),[x]),Y=function(){return n.createElement(c,{className:o(v.iconComponent,t(t({},v.animateIconOpen,U),v.animateIconClose,!U)),iconType:"svg",icon:m,iconSize:k})};return n.createElement("div",{ref:F,className:y,id:S,"data-testid":w||p(f.EXPAND_COLLAPSE,S),"data-vibe":u.EXPAND_COLLAPSE},n.createElement("div",{className:o(v.expandCollapse,t(t({},v.hideBorder,z),v.showBorder,!z),X)},n.createElement("button",{type:"button",className:o(v.header,v.section,D,t(t(t({},v.headerOpen,U),v.hideBorderBottom,z),v.leftIcon,"left"===O)),onClickCapture:M?T||V:void 0,onClick:M?void 0:T||V,"aria-expanded":U,"aria-controls":"".concat(S,"-controls")},"left"===O&&Y(),"string"!=typeof x||0!==x.length?W():E&&E(),"right"===O&&Y()),U&&n.createElement("div",{className:o(v.content,v.section,R,t({},v.animateExpandCollapseContent,U)),id:"".concat(S,"-controls"),role:"region"},h)))}));export{C as default};
//# sourceMappingURL=ExpandCollapse.js.map
