import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'chat.vojo.app',
  appName: 'Vojo',
  webDir: 'dist',
  // Bot widgets (docs/plans/bots_tab.md Phase 2): on Android, Capacitor's
  // BridgeWebViewClient.shouldOverrideUrlLoading does NOT check
  // request.isForMainFrame(), so any cross-origin iframe URL not in
  // appAllowNavigationMask is hijacked into an external Intent.ACTION_VIEW
  // and the iframe stays blank. Same-origin /widgets/... is safe (resolves
  // to https://localhost under Capacitor).
  //
  // The Discord widget renders a nested hCaptcha iframe inside the
  // widgets.vojo.chat frame; without `*.hcaptcha.com` in the allowlist
  // the captcha challenge stays blank on Android and login is dead-ended.
  server: {
    allowNavigation: [
      'widgets.vojo.chat',
      'js.hcaptcha.com',
      'newassets.hcaptcha.com',
      '*.hcaptcha.com',
    ],
  },
  android: {
    // Keep default: resolveServiceWorkerRequests = true
    // SW is critical for authenticated Matrix media (MSC3916 / spec v1.11+)
    //
    // WebView bg color before first body paint. Without this the WebView
    // paints transparent/black during bundle hydration, which combined with
    // the post-splash window theme produced a visible black flash between
    // the Android 12+ system splash and the in-app AuthSplashScreen mascot.
    // Matches the native splash + AuthLayout + body backgrounds.
    backgroundColor: '#0d0e11',
  },
  plugins: {
    PushNotifications: {
      presentationOptions: ['badge', 'sound', 'alert'],
    },
  },
};

export default config;
