/*!
 * KoliBri - The accessible HTML-Standard
 */
import{h as t,r as s,F as e}from"./index-a5e15b1e.js";import{a as o}from"./i18n-73edd5e1.js";import{n}from"./dev.utils-c7d151c6.js";import"./index-c3ae175d.js";import"./index-eb50dd62.js";const a=({toastState:s,onClose:e,key:a})=>t("div",{class:`toast ${s.status}`,key:a},t("kol-alert",{class:"alert",_alert:!0,_label:s.toast.label,_level:0,_hasCloser:!0,_type:s.toast.type,_variant:s.toast.alertVariant||"card",_on:{onClose:e}},t("div",{ref:t=>{"function"==typeof s.toast.render&&t&&s.toast.render(t,{close:()=>e()})}},"string"==typeof s.toast.description?s.toast.description:null))),i="@layer kol-component {\n\t:host {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tposition: fixed;\n\t\tz-index: 200;\n\t}\n\n\t.close-all {\n\t\talign-self: flex-end;\n\t}\n}\n",l=i,c=300,r=class{constructor(t){s(this,t),this.state={_toastStates:[]}}async enqueue(t){const s={toast:t,status:"adding",id:`toast-${n()}`};return this.state=Object.assign(Object.assign({},this.state),{_toastStates:[s,...this.state._toastStates]}),setTimeout((()=>{this.state=Object.assign(Object.assign({},this.state),{_toastStates:this.state._toastStates.map((t=>t.id===s.id?Object.assign(Object.assign({},t),{status:"settled"}):t))})}),c),()=>{this.handleClose(s)}}handleClose(t){this.state=Object.assign(Object.assign({},this.state),{_toastStates:this.state._toastStates.map((s=>(s.id===t.id&&(s.status="removing"),s)))}),setTimeout((()=>{this.state=Object.assign(Object.assign({},this.state),{_toastStates:this.state._toastStates.filter((s=>s.id!==t.id))})}),c)}async closeAll(){this.state=Object.assign(Object.assign({},this.state),{_toastStates:this.state._toastStates.map((t=>Object.assign(Object.assign({},t),{status:"removing"})))}),setTimeout((()=>{this.state=Object.assign(Object.assign({},this.state),{_toastStates:[]})}),c)}render(){return t(e,null,this.state._toastStates.length>1&&t("kol-button",{_label:o("kol-toast-close-all"),class:"close-all",_on:{onClick:()=>{this.closeAll()}}}),this.state._toastStates.map((s=>t(a,{toastState:s,onClose:()=>this.handleClose(s),key:s.id}))))}};r.style={default:l};export{r as kol_toast_container};