package com.tt.honeyDue.network

/**
 * API Environment Configuration
 *
 * To switch environments, simply change the CURRENT_ENV value:
 * - Environment.LOCAL for local development
 * - Environment.DEV for remote dev/staging server
 * - Environment.PROD for production server
 */
object ApiConfig {
    // ⚠️ CHANGE THIS TO TOGGLE ENVIRONMENT ⚠️
    val CURRENT_ENV = Environment.LOCAL

    enum class Environment {
        LOCAL,
        DEV,
        PROD
    }

    /**
     * Get the base URL based on current environment and platform
     */
    fun getBaseUrl(): String {
        return when (CURRENT_ENV) {
            Environment.LOCAL -> "http://${getLocalhostAddress()}:8000/api"
            Environment.DEV -> "https://devapi.myhoneydue.com/api"
            Environment.PROD -> "https://api.myhoneydue.com/api"
        }
    }

    /**
     * Get the media base URL (without /api suffix) for serving media files
     */
    fun getMediaBaseUrl(): String {
        return when (CURRENT_ENV) {
            Environment.LOCAL -> "http://${getLocalhostAddress()}:8000"
            Environment.DEV -> "https://devapi.myhoneydue.com"
            Environment.PROD -> "https://api.myhoneydue.com"
        }
    }

    /**
     * Get environment name for logging
     */
    fun getEnvironmentName(): String {
        return when (CURRENT_ENV) {
            Environment.LOCAL -> "Local (${getLocalhostAddress()}:8000)"
            Environment.DEV -> "Dev Server (devapi.myhoneydue.com)"
            Environment.PROD -> "Production (api.myhoneydue.com)"
        }
    }

    /**
     * Google OAuth Web Client ID
     * This is the Web application client ID from Google Cloud Console.
     * It should match the GOOGLE_CLIENT_ID configured in the backend.
     *
     * Set via environment: actual client ID must be configured per environment.
     * To get this value:
     * 1. Go to Google Cloud Console -> APIs & Services -> Credentials
     * 2. Create or use an existing OAuth 2.0 Client ID of type "Web application"
     * 3. Copy the Client ID (format: xxx.apps.googleusercontent.com)
     * 4. Replace the empty string below with your client ID
     *
     * WARNING: An empty string means Google Sign-In is not configured.
     * The app should check [isGoogleSignInConfigured] before offering Google Sign-In.
     */
    const val GOOGLE_WEB_CLIENT_ID = ""

    /**
     * Whether Google Sign-In has been configured with a real client ID.
     * UI should check this before showing Google Sign-In buttons.
     */
    val isGoogleSignInConfigured: Boolean
        get() = GOOGLE_WEB_CLIENT_ID.isNotEmpty()
                && !GOOGLE_WEB_CLIENT_ID.contains("YOUR_")
}
