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