"use strict";const E=require("react/jsx-runtime"),p=require("react"),i=require("../tools/tools.cjs"),$=(a,o,n="",c=!1,t)=>{if(!c)return t?`${t}${n}`:`0${n}`;const f=a.dataset[`last${i.capitalizeFirstLetter(o)}`]||"0",e=o==="width"?a.offsetWidth:a.offsetHeight||f;return e!=="0"&&(a.dataset[`last${i.capitalizeFirstLetter(o)}`]=e.toString()),`${e}${n}`},C=function(o){const{as:n="div",className:c,collapsing:t=!0,dropOldClass:f,horizontal:e,style:d,variables:h,visible:l,...L}=o,[y,g]=p.useState(t?!1:l??!1),v=p.useRef(null),m=p.useMemo(()=>{const s=i.classx(!f&&"collapse",e&&"collapse-horizontal",y&&"show",c),r=i.stylex((u,w)=>({tKey:i.convertBsKeyToVar(w)}),h,d);return{className:s,style:r}},[c,f,e,y,d,h]);return p.useEffect(()=>{if(!t){g(l??!1);return}const s=v.current;if(!s)return;const r=s.children[0];if(!r||!r.dataset[e?"lastWidth":"lastHeight"]&&!l)return;const u=()=>{l?s.classList.add("collapse","show"):s.classList.add("collapse"),s.classList.remove("collapsing")};return s.addEventListener("transitionend",u),s.classList.remove("collapse","show"),s.classList.add("collapsing"),s.style.setProperty(e?"width":"height",$(r,e?"width":"height","px",l)),()=>s.removeEventListener("transitionend",u)},[t,e,l]),E.jsx(n,{...L,...m,ref:v})};C.displayName="BRL.Collapse";exports.Collapse=C;
//# sourceMappingURL=collapse.cjs.map
