'use client';
import{jsx as e}from"react/jsx-runtime";import o from"../components/Notifications.js";import{useState as t,useRef as r,useMemo as n,startTransition as c,useEffect as s}from"react";import{useId as i}from"@gem-sdk/core";let l=()=>document.body,a=0;function f(f){let{getContainer:u=l,maxCount:m,onAllRemoved:p,...y}=f??{},d=i(),[k,h]=t(),b=r(null),g=n(()=>e(o,{ref:b,container:k,maxCount:m,onAllRemoved:p}),[k,m,p]),[j,v]=t([]),x=n(()=>({open:e=>{let o=function(...e){let o={};return e.forEach(e=>{e&&Object.keys(e).forEach(t=>{let r=e[t];void 0!==r&&(o[t]=r)})}),o}(y,e);(null===o.key||void 0===o.key)&&(o.key=`${d}-${a}`,a+=1),c(()=>{v(e=>[...e,{type:"open",config:o}])})},close:e=>{c(()=>{v(o=>[...o,{type:"close",key:e}])})},destroy:()=>{c(()=>{v(e=>[...e,{type:"destroy"}])})}}),[y,d]);return s(()=>{h(u())},[u]),s(()=>{b.current&&j.length&&(j.forEach(e=>{switch(e.type){case"open":b.current?.open(e.config);break;case"close":b.current?.close(e.key);break;case"destroy":b.current?.destroy()}}),v(()=>[]))},[j]),[x,g]}export{f as default};
