import{r as g,a3 as h,b as j,j as o,y as S}from"./index-Bf3Szspx.js";import{u as I,S as P}from"./styles-B026eHci.js";import{S as k}from"./Snackbar-Dzu1h48C.js";import"./Alert-DQ-rWV5J.js";import"./Icon-SjE0NP4G.js";function v(s,n){const[r,t]=g.useState(0);return g.useEffect(()=>{if(!n||s===1/0)return;let e,a;const c=()=>{const i=(Date.now()-e)/s*100;i<100?(t(i),a=requestAnimationFrame(c)):t(100)};return(()=>{e=Date.now(),a=requestAnimationFrame(c)})(),()=>{cancelAnimationFrame(a)}},[s,n]),s===1/0?100:r}function F(s){const n=h(),r=j(),{severity:t,open:e,translationKey:a,message:c,action:p,duration:m,uuid:l,placement:i}=n,u=I(),y=v(m,e),x={"common.errors.generic":r.formatMessage({id:"common.errors.generic"}),"common.errors.forbidden":r.formatMessage({id:"common.errors.forbidden"}),"common.errors.image":r.formatMessage({id:"common.errors.image"}),"common.errors.tooManyRequests":r.formatMessage({id:"common.errors.tooManyRequests"})},b=l?` Error ID: ${l}`:"",d=()=>n.clear(),f=m!==1/0&&y===100;return g.useEffect(()=>{f&&setTimeout(d,0)},[f]),o.jsx(k,{open:e,onClose:d,...s,...i&&{anchorOrigin:i},children:o.jsxs("div",{className:u.styledContainer,children:[e?o.jsx(P,{severity:t,onClose:d,action:p,snackbar:!0,children:(c||x[a])+b}):o.jsx("div",{}),e&&o.jsx("div",{className:u.progressBarContainer,style:f?{opacity:0}:null,children:o.jsx("div",{className:S(u.progressBar,t),style:{width:`${y}%`}})})]})})}export{P as StyledAlert,F as default};