/** เก็บ `beforeinstallprompt` ไว้ใช้ทีหลัง (browser ยิงครั้งเดียวตอนโหลด ก่อน UI ที่จะแสดงปุ่มติดตั้งจะ mount) */ export type BeforeInstallPromptEvent = Event & { prompt: () => Promise; userChoice: Promise<{ outcome: "accepted" | "dismissed"; platform: string }>; }; let installPrompt: BeforeInstallPromptEvent | null = null; const listeners = new Set<(event: BeforeInstallPromptEvent | null) => void>(); export function getInstallPrompt() { return installPrompt; } export function setInstallPrompt(event: BeforeInstallPromptEvent | null) { installPrompt = event; for (const listener of listeners) listener(installPrompt); } export function subscribeToInstallPrompt( listener: (event: BeforeInstallPromptEvent | null) => void, ) { listeners.add(listener); return () => { listeners.delete(listener); }; }