"use strict";const L=require("react/jsx-runtime"),t=require("react"),c=require("../tools/tools.cjs"),k=function(B){const{as:O="div",backdrop:u,className:m,dropOldClass:v,fade:n=!0,onChange:r,scroll:l,style:p,variables:y,visible:e=!1,...g}=B,[d,f]=t.useState(e),[b,o]=t.useState(!1),h=t.useRef(null),w=t.useMemo(()=>{const s=c.classx(!v&&"offcanvas-backdrop",n&&"fade",b&&"show",m),a=c.stylex((i,C)=>({tKey:c.convertBsKeyToVar(C)}),y,p);return{className:s,style:a}},[m,v,n,b,p,y]),x=t.useCallback(s=>{u!=="static"&&(o(!1),r==null||r(!1,s))},[u,r]);return t.useEffect(()=>{if(!n){f(e),o(e);return}if(e&&!d){f(!0);return}const s=h.current;if(!s)return;const a=()=>{e||(l||(document.body.classList.remove("overflow-hidden"),document.body.style.removeProperty("padding-right")),f(!1))};s.addEventListener("transitionend",a);let i;return e?(l||(document.body.style.setProperty("padding-right",c.getScrollbarWidth("px")),document.body.classList.add("overflow-hidden")),i=requestAnimationFrame(()=>o(!0))):o(!1),()=>{s.removeEventListener("transitionend",a),i&&cancelAnimationFrame(i)}},[n,l,d,e]),d&&L.jsx(O,{...g,...w,onClick:x,ref:h})};k.displayName="BRL.OffcanvasBackdrop";exports.OffcanvasBackdrop=k;
//# sourceMappingURL=offcanvas-backdrop.cjs.map
