import{slicedToArray as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as o,jsxs as n}from"react/jsx-runtime";import{forwardRef as a,useRef as c,useState as s,useCallback as i}from"react";import l from"../../hooks/useMergeRefs.js";import r from"../Icon/Icon.js";import t from"../Heading/Heading.js";import p from"../Icon/Icons/components/DropdownChevronDown.js";import d from"classnames";import"./ExpandCollapse.scss.js";var m=a((function(a,m){var u=a.children,f=a.headerComponentRenderer,_=void 0===f?null:f,v=a.title,h=void 0===v?"":v,x=a.className,j=a.defaultOpenState,g=void 0!==j&&j,b=a.iconSize,N=void 0===b?24:b,y=a.id,C=void 0===y?"":y,O=a.open,k=a.onClick,I=void 0===k?null:k,S=c(null),w=l({refs:[m,S]}),H=s(g),z=e(H,2),D=z[0],R=z[1],T=void 0===O?D:O,A=i((function(){return o(t,{type:t.types.h5,value:h,className:"expand-collapse__header-content"})}),[h]);return o("div",Object.assign({ref:w,className:d("expand-collapse--wrapper",x),id:C},{children:n("div",Object.assign({className:"expand-collapse"},{children:[n("button",Object.assign({type:"button",className:d("expand-collapse__header","expand-collapse__section",{"expand-collapse__header--open":T}),onClickCapture:I||function(){R(!D)},"aria-expanded":T,"aria-controls":"".concat(C,"-controls")},{children:[0!==h.length?A():_&&_(),o(r,{className:T?"animate-icon-open":"animate-icon-close",iconType:r.type.SVG,icon:p,iconSize:N,clickable:!1})]})),T&&o("div",Object.assign({className:"expand-collapse__content expand-collapse__section ".concat(T&&"animate-expand-collapse__content"),id:"".concat(C,"-controls"),role:"region"},{children:u}))]}))}))}));export{m as default};
