import{makeGlobalSize as t,useEditorMode as e,makeStyle as r,getSingleColorVariable as o,getGlobalColorStateStyle as n,composeSize as a,removePaddingYInStyle as i}from"@gem-sdk/core";import{useState as m,useEffect as s,useMemo as c}from"react";import l from"./useMountTransition.js";import{useGetProductId as d}from"../../hooks/useGetProductId.js";import{composeIconSvg as p}from"../common/helpers.js";let u=u=>{let{accordions:f,index:g,builderProps:v,parentSetting:h={},parentStyle:j={},handleDropDown:w}=u,{iconPosition:I,titleTypo:$,iconCollapse:k,iconExpand:x,iconSvg:b}=h;delete $?.attrs?.color;let{itemContentSpacing:y,iconColor:A,contentSizePadding:D}=j,G=f?.includes(g?.toString()??""),M=t(D),P=e(),[S,T]=m(G),q=l(S||!1,500);s(()=>{T(G)},[G]);let z=c(()=>p({isShow:G,iconExpand:x,iconCollapse:k,iconSvg:b}),[G,x,k,b]),B=c(()=>r({fd:"left"===I?"row":"row-reverse",jc:"right"===I?"space-between":""}),[I]),C=c(()=>{let t={normal:A?.normal??"transparent",hover:A?.hover??A?.active??A?.normal??"transparent",active:A?.active??A?.normal??"transparent"};return G?r({c:o(t?.active)}):n("c",t)},[A,G]),{refContainer:E,productID:F}=d(),H=c(()=>{let t=`gp-accordion-item-${v?.uid}-${g}`;return F?`${t}-${F}`:t},[v?.uid,g,F]),J=c(()=>{let t={...D&&M.padding,...y?.type||D?{}:a(y?.custom)};return G?t:i(t)},[D,y,G,M]),K=c(()=>q||S||"edit"!==P,[q,S,P]);return{productID:F,isShow:G,getIdDropdownItem:(t,e)=>{!t.target.closest(".gp-text")&&w&&e&&(T(!S),w(e))},makeIcon:z,refContainer:E,uniqueId:H,isRenderChildren:K,composePosition:B,composeIconColor:C,composeContentSizeStyle:J,hasTransitionedIn:q,isMounted:S}};export{u as default};
