// Tiny shared toast controller. Import `toast` anywhere and call toast.show('...'). class ToastController { message = $state(''); visible = $state(false); #timer: ReturnType | null = null; show(msg: string, ms = 2200): void { this.message = msg; this.visible = true; if (this.#timer) clearTimeout(this.#timer); this.#timer = setTimeout(() => (this.visible = false), ms); } } export const toast = new ToastController();