'use client';
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useMemo as r,Children as s}from"react";import{composeClasses as l}from"@gem-sdk/core";import o from"../../grid/components/ChildrenDroppable.js";import a from"../../text/components/Text.js";import n from"../hooks/useAccordionItem.js";import{createClass as i,createStyle as m,If as d}from"@gem-sdk/system";import{getItemContainerStyles as c,getDropdownStyles as p,getDropdownTextStyles as y,getIconRotateStyles as h,getIconGlobalSize as g,getGapStyles as f,getIconStyles as x,getRenderChildrenStyles as S}from"../common/styles.js";import{getItemContainerClasses as u,getDropdownClasses as v,getIconClasses as N,getIconRotateClasses as j,getContentClasses as _,getGapClasses as b,getLayoutIconClasses as I,getRenderChildrenClasses as A}from"../common/classes.js";import{getParentSettings as T,MINIMUM_CHILD as k,BODY_CHILD_INDEX as C}from"../common/helpers.js";let AccordionItem=H=>{let{children:L,index:M,parentUid:w,title:D,childrenIcon:F}=H,{iconSvg:q,titleTypo:z,layoutHeader:B,iconGlobalSize:E,iconCollapseSize:G,iconCollapse:J,iconExpand:K,alignment:O,configIconSize:P,iconPosition:Q}=T(H.parentSetting)??{},{refContainer:R,getIdDropdownItem:U,makeIcon:V,isShow:W,uniqueId:X,composeIconColor:Y,isRenderChildren:Z,composeContentSizeStyle:$,hasTransitionedIn:ee,isMounted:et,productID:er}=n(H),es=i(u),el=i(v(H.parentStyle,{isShow:W,uniqueId:X,makeIcon:V,index:M})),eo=i(N),ea=i(j(H.parentStyle,{isShow:W,iconExpand:K,iconSvg:q,iconCollapse:J})),en=i(_(w)),ei=i(b),em=m(c(H.parentStyle,W)),ed=m(p(H.parentStyle,{isShow:W,iconPosition:Q})),ec=m(y(H.parentStyle?.textColor,W)),ep=m(h(H.parentStyle,W,G)),ey=m(g(E)),eh=m(f(E,O)),eg=i(l("gp-inline-flex")),ef=i(I),ex=m(x(Y,P)),eS=i(A(H.parentStyle,{isShow:W,hasTransitionedIn:ee,isMounted:et})),eu=m(S()),ev=i(l("gp-accordion-item_body-inner gp-transition-all gp-duration-500 gp-min-h-0")),eN=i(l("gp-border gp-border-transparent group-hover:[color:var(--text-hover-color)]")),ej=r(()=>{let t=s.toArray(L);return t.length>=k?t[C]:e(o,{})},[L]);return e("div",{className:es,ref:R,style:em,children:t("div",{"data-index":M?.toString(),className:en,children:[t("div",{"aria-hidden":!0,onClick:e=>{U(e,M?.toString())},className:el,style:ed,children:[d(!!V,e("div",{className:eo,children:e("span",{style:ep,className:ea,dangerouslySetInnerHTML:{__html:V??""}})})),t("div",{className:ei,style:eh,children:[d("before-text"===B,e("div",{className:eg,style:{...ey},children:e("span",{className:ef,style:ex,dangerouslySetInnerHTML:{__html:F??""}})})),e(a,{setting:{text:D,htmlTag:"div",options:{uniqueId:X,productID:er,useState:!0},excludeFlex:!0},style:ec,styles:{typo:z},className:eN}),d("after-text"===B,e("div",{className:eg,style:{...ey},children:e("span",{className:ef,style:ex,dangerouslySetInnerHTML:{__html:F??""}})}))]})]}),Z&&e("div",{...H?.builderAttrs,className:eS,style:eu,"data-index":M,"data-show":W,children:e("div",{className:ev,style:$,children:ej})})]})})};export{AccordionItem as default};
