function waitForWindow(): Promise { return new Promise((resolve) => { if (typeof window !== 'undefined') { resolve(window); } else { const intervalId = setInterval(() => { if (typeof window !== 'undefined') { clearInterval(intervalId); resolve(window); } }, 100); } }); }