'use client';
import{jsx as e,Fragment as t}from"react/jsx-runtime";import{forwardRef as o,useState as l,useCallback as r,useImperativeHandle as p,useMemo as g}from"react";import{createPortal as i}from"react-dom";import{cls as f}from"@gem-sdk/core";import m from"./Notice.js";let n=o((o,n)=>{let{container:s,maxCount:c}=o,[a,x]=l([]),d=r(e=>{let t=a.find(t=>t.key===e);t?.onClose?.(),x(t=>t.filter(t=>t.key!==e))},[a]);p(n,()=>({open:e=>{x(t=>{let o=[...t],l=o.findIndex(t=>t.key===e.key);return l>=0?o[l]=e:o.push(e),c&&o.length>c&&(o=o.slice(-c)),o})},close:e=>{d(e)},destroy:()=>{x([])}}),[c,d]);let h=g(()=>{let e={};return a.forEach(t=>{let{placement:o="top-right"}=t;e[o]=[...e[o]||[],t]}),e},[a]);if(!s)return null;let u=e(t,{children:Object.keys(h).map(t=>{let o=h[t];return e("div",{style:{zIndex:9999999},className:f("gp-fixed gp-flex gp-max-h-screen gp-items-end gp-gap-2",{"gp-left-1/2 gp-top-4 -gp-translate-x-1/2 gp-flex-col":"top"===t,"gp-bottom-4 gp-left-1/2 -gp-translate-x-1/2 gp-flex-col":"bottom"===t,"gp-left-4 gp-top-4 gp-flex-col":"top-left"===t,"gp-right-4 gp-top-4 gp-flex-col":"top-right"===t,"gp-bottom-4 gp-left-4 gp-flex-col-reverse":"bottom-left"===t,"gp-bottom-4 gp-right-4 gp-flex-col-reverse":"bottom-right"===t}),children:o?.map(t=>{let{key:o,...l}=t;return e(m,{eventKey:o,...l,onNoticeClose:d},o)})},t)})});return i(u,s)});n.displayName="Notifications";export{n as default};
