import{r as c}from"./app-BGey7YPf.js";const d=1,p=1e6;let a=0;function A(){return a=(a+1)%Number.MAX_SAFE_INTEGER,a.toString()}const i=new Map,S=t=>{if(i.has(t))return;const s=setTimeout(()=>{i.delete(t),n({type:"REMOVE_TOAST",toastId:t})},p);i.set(t,s)},f=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,d)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(e=>e.id===s.toast.id?{...e,...s.toast}:e)};case"DISMISS_TOAST":{const{toastId:e}=s;return e?S(e):t.toasts.forEach(o=>{S(o.id)}),{...t,toasts:t.toasts.map(o=>o.id===e||e===void 0?{...o,open:!1}:o)}}case"REMOVE_TOAST":return s.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(e=>e.id!==s.toastId)}}},r=[];let T={toasts:[]};function n(t){T=f(T,t),r.forEach(s=>{s(T)})}function E({...t}){const s=A(),e=u=>n({type:"UPDATE_TOAST",toast:{...u,id:s}}),o=()=>n({type:"DISMISS_TOAST",toastId:s});return n({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:u=>{u||o()}}}),{id:s,dismiss:o,update:e}}function _(){const[t,s]=c.useState(T);return c.useEffect(()=>(r.push(s),()=>{const e=r.indexOf(s);e>-1&&r.splice(e,1)}),[t]),{...t,toast:E,dismiss:e=>n({type:"DISMISS_TOAST",toastId:e})}}export{E as t,_ as u};
