"use strict";const e=require("react/jsx-runtime"),a=require("react"),v=require("../tools/tools.cjs"),S=require("./offcanvas-backdrop.cjs"),w=require("./offcanvas-body.cjs"),T=require("./offcanvas-header.cjs"),_=require("./offcanvas-title.cjs"),o=function(E){const{as:H="div",backdrop:u=!0,body:p,bodyProps:N,className:b,dropOldClass:h,fade:R=!0,header:m,headerProps:L,onChange:n,placement:f,responsive:i,scroll:P,style:O,title:y,titleProps:F,variables:x,visible:l=!1,...K}=E,[c,d]=a.useState(l),j=a.useRef(null),[k,B]=a.useState(!1),[g,q]=a.useState(!1),[r,C]=a.useState(!1),V=a.useMemo(()=>{const s=v.classx(!h&&(i?`offcanvas-${i}`:"offcanvas"),f&&`offcanvas-${f}`,k&&"showing",g&&"hiding",r&&"show",b),t=v.stylex((G,z)=>({tKey:v.convertBsKeyToVar(z)}),x,O);return{className:s,style:t}},[b,h,g,f,i,r,k,O,x]),$=a.useCallback(s=>{d(!1),n==null||n(!1,s)},[n]),M=a.useCallback((s,t)=>{d(s),n==null||n(s,t)},[n]);return a.useEffect(()=>{const s=j.current;if(!s)return;const t=()=>{c?B(!1):q(!1)};return s.addEventListener("transitionend",t),c?(C(!0),B(!0)):r&&(C(!1),q(!0)),()=>s.removeEventListener("transitionend",t)},[r,c]),a.useEffect(()=>{d(l)},[l]),e.jsxs(e.Fragment,{children:[e.jsxs(H,{...K,...V,ref:j,children:[m||(y?e.jsxs(T.OffcanvasHeader,{...L,children:[e.jsx(_.OffcanvasTitle,{...F,children:y}),e.jsx("button",{"aria-label":"Close",className:"btn-close","data-bs-dismiss":"offcanvas",onClick:$,type:"button"})]}):e.jsx(e.Fragment,{})),p&&e.jsx(w.OffcanvasBody,{...N,children:p})]}),u&&e.jsx(S.OffcanvasBackdrop,{backdrop:u,fade:R,onChange:M,scroll:P,visible:c})]})};o.Header=T.OffcanvasHeader;o.Title=_.OffcanvasTitle;o.Body=w.OffcanvasBody;o.Backdrop=S.OffcanvasBackdrop;o.displayName="BRL.Offcanvas";exports.Offcanvas=o;
//# sourceMappingURL=offcanvas.cjs.map
