'use client'; export function getRecaptchaToken(action: string = 'submit'): Promise { return new Promise((resolve) => { const siteKey = process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY; if (typeof window === 'undefined' || !siteKey || !(window as any).grecaptcha) { resolve(null); return; } try { (window as any).grecaptcha.ready(() => { (window as any).grecaptcha .execute(siteKey, { action }) .then((token: string) => resolve(token)) .catch(() => resolve(null)); }); } catch { resolve(null); } }); }