"use strict";const n=require("react/jsx-runtime"),t=require("react"),f=require("../tools/tools.cjs"),g=require("./toast-body.cjs"),L=require("./toast-container.cjs"),j=require("./toast-header.cjs"),a=function(E){const{as:S="div",autohide:m=!0,body:h,bodyProps:_,className:y,customContent:T,delay:C=5e3,dropOldClass:v,fade:r=!0,header:q,headerProps:H,onChange:i,style:x,variables:b,visible:l=!1,...I}=E,[s,c]=t.useState(!1),[p,o]=t.useState(!1),w=t.useRef(null),R=t.useMemo(()=>{const e=f.classx(!v&&"toast",r&&"fade",s&&"show",p&&"showing",y),u=f.stylex((d,F)=>({tKey:f.convertBsKeyToVar(F)}),b,x);return{className:e,style:u}},[y,v,r,s,p,x,b]),B=t.useCallback(e=>{i==null||i(e)},[i]);return t.useEffect(()=>{let e;return m&&s&&(e=setTimeout(()=>{B(!1)},C)),()=>{e&&clearTimeout(e)}},[m,C,B,s]),t.useEffect(()=>{if(!r){c(l);return}const e=w.current;if(!e)return;const u=()=>{l?o(!1):(o(!1),c(!1))};e.addEventListener("transitionend",u);let d;return l?(c(!0),o(!0),d=requestAnimationFrame(()=>o(!1))):s&&(c(!0),o(!0)),()=>{e.removeEventListener("transitionend",u),d&&cancelAnimationFrame(d)}},[r,s,l]),n.jsx(S,{...I,...R,ref:w,children:T||n.jsxs(n.Fragment,{children:[q&&n.jsx(j.ToastHeader,{...H,children:q}),h&&n.jsx(g.ToastBody,{..._,children:h})]})})};a.Header=j.ToastHeader;a.Body=g.ToastBody;a.Container=L.ToastContainer;a.displayName="BRL.ToastItem";exports.ToastItem=a;
//# sourceMappingURL=toast-item.cjs.map
