import{a as t,f as e,r as s,h as n,H as o}from"./p-91e1cdd0.js";const i=t=>!("isConnected"in t)||t.isConnected,r=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys())t.set(e,t.get(e).filter(i))})(...e)}),2e3)}})(),c={items:[]},a=new class{constructor(){const{state:s}=((s,n)=>{const o=((t,e=((t,e)=>t!==e))=>{let s=new Map(Object.entries(null!=t?t:{}));const n={dispose:[],get:[],set:[],reset:[]},o=()=>{s=new Map(Object.entries(null!=t?t:{})),n.reset.forEach((t=>t()))},i=t=>(n.get.forEach((e=>e(t))),s.get(t)),r=(t,o)=>{const i=s.get(t);e(o,i,t)&&(s.set(t,o),n.set.forEach((e=>e(t,o,i))))},c="undefined"==typeof Proxy?{}:new Proxy(t,{get:(t,e)=>i(e),ownKeys:()=>Array.from(s.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>s.has(e),set:(t,e,s)=>(r(e,s),!0)}),a=(t,e)=>(n[t].push(e),()=>{((t,e)=>{const s=t.indexOf(e);s>=0&&(t[s]=t[t.length-1],t.length--)})(n[t],e)});return{state:c,get:i,set:r,on:a,onChange:(e,s)=>{const n=a("set",((t,n)=>{t===e&&s(n)})),o=a("reset",(()=>s(t[e])));return()=>{n(),o()}},use:(...t)=>t.forEach((t=>{t.set&&a("set",t.set),t.get&&a("get",t.get),t.reset&&a("reset",t.reset)})),dispose:()=>{n.dispose.forEach((t=>t())),o()},reset:o,forceUpdate:t=>{const e=s.get(t);n.set.forEach((s=>s(t,e,e)))}}})(s,n);return(({on:s})=>{const n=new Map;"function"==typeof t&&(s("dispose",(()=>{n.clear()})),s("get",(e=>{const s=t();s&&((t,e,s)=>{const n=t.get(e);n?n.includes(s)||n.push(s):t.set(e,[s])})(n,e,s)})),s("set",(t=>{const s=n.get(t);s&&n.set(t,s.filter(e)),r(n)})),s("reset",(()=>{n.forEach((t=>t.forEach(e))),r(n)})))})(o),o})(c);this._state=s}get state(){return this._state}closeCurrent(){const t=[...this._state.items];t.shift(),this._state.items=t}clearNotifications(){this._state.items=[]}showErrorNotification(t,e){this.pushNotification(t,null!=e?e:0,"danger")}showInfoNotification(t,e){this.pushNotification(t,null!=e?e:0,"info")}showWarningNotification(t,e){this.pushNotification(t,null!=e?e:0,"warning")}showSuccessNotification(t,e){this.pushNotification(t,null!=e?e:0,"success")}pushNotification(t,e,s){const n=[...this._state.items];n.push({details:t,type:s,priority:e}),this._state.items=n.sort(((t,e)=>e.priority-t.priority))}},l=class{constructor(t){s(this,t)}disconnectedCallback(){a.clearNotifications()}render(){const{items:t}=a.state;return t.length<=0?n(o,null):n("div",{class:`alert alert-${t[0].type}`,role:"alert"},n("div",{class:"d-flex"},n("p",{class:"mb-0 flex-grow-1"},n("strong",null,t[0].details.title)),n("button",{onClick:this.handleClose,type:"button",class:"close pb-1","aria-label":"Close"},n("span",{"aria-hidden":"true"},"×"))),n("p",{class:"mb-0 mt-1"},t[0].details.description))}handleClose(){a.closeCurrent()}};export{l as ap_ben_notifications_section}