export const toastStore = $state({ items: [] });

export function toast(message, type = "success") {
    const id = crypto.randomUUID();
    toastStore.items.push({ id, message, type });
    setTimeout(() => dismiss(id), 3500);
}

export function dismiss(id) {
    const idx = toastStore.items.findIndex(t => t.id === id);
    if (idx !== -1) toastStore.items.splice(idx, 1);
}
