'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("react-dom"),l=require("@gem-sdk/core"),o=require("./Notice.js");const p=t.forwardRef((p,s)=>{let{container:g,maxCount:a}=p,[i,n]=t.useState([]),c=t.useCallback(e=>{let t=i.find(t=>t.key===e);t?.onClose?.(),n(t=>t.filter(t=>t.key!==e))},[i]);t.useImperativeHandle(s,()=>({open:e=>{n(t=>{let r=[...t],l=r.findIndex(t=>t.key===e.key);return l>=0?r[l]=e:r.push(e),a&&r.length>a&&(r=r.slice(-a)),r})},close:e=>{c(e)},destroy:()=>{n([])}}),[a,c]);let f=t.useMemo(()=>{let e={};return i.forEach(t=>{let{placement:r="top-right"}=t;e[r]=[...e[r]||[],t]}),e},[i]);if(!g)return null;let u=e.jsx(e.Fragment,{children:Object.keys(f).map(t=>{let r=f[t];return e.jsx("div",{style:{zIndex:9999999},className:l.cls("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:r?.map(t=>{let{key:r,...l}=t;return e.jsx(o.default,{eventKey:r,...l,onNoticeClose:c},r)})},t)})});return r.createPortal(u,g)});p.displayName="Notifications",exports.default=p;
