export default () => ({
  // Server port | منفذ الخادم
  port: parseInt(process.env.PORT || '3001', 10),

  // Environment | بيئة العمل
  nodeEnv: process.env.NODE_ENV || 'development',

  // Meta Ads API Configuration | إعدادات واجهة برمجة تطبيقات ميتا
  // how to get access token from meta ads api
  // https://developers.facebook.com/docs/marketing-apis/access-tokens/
  // https://developers.facebook.com/docs/marketing-apis/access-tokens/get-long-lived-user-access-tokens/

  meta: {
    apiVersion: process.env.META_API_VERSION || 'v19.0',
    accessToken: process.env.META_ACCESS_TOKEN,
    adAccountId: process.env.META_AD_ACCOUNT_ID,
    appId: process.env.META_APP_ID,
    appSecret: process.env.META_APP_SECRET,
    redirectUri: process.env.META_REDIRECT_URI,
  },

  // Analytics Configuration | إعدادات التحليلات
  analytics: {
    geminiApiKey: process.env.GEMINI_API_KEY,
  },

  // Database Configuration | إعدادات قاعدة البيانات
  database: {
    host: process.env.DB_HOST,
    port: parseInt(process.env.DB_PORT || '5432', 10),
    username: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME,
  },

  // TikTok Ads Configuration
  tiktok: {
    appId: process.env.TIKTOK_APP_ID,
    secret: process.env.TIKTOK_SECRET,
    redirectUri: process.env.TIKTOK_REDIRECT_URI,
  },

  // Google Ads Configuration
  google: {
    clientId: process.env.GOOGLE_CLIENT_ID,
    clientSecret: process.env.GOOGLE_CLIENT_SECRET,
    redirectUri: process.env.GOOGLE_REDIRECT_URI,
    developerToken: process.env.GOOGLE_DEVELOPER_TOKEN,
  },

  // Payment Gateways
  paymob: {
    apiKey: process.env.PAYMOB_API_KEY,
    cardIntegrationId: process.env.PAYMOB_CARD_INTEGRATION_ID,
    walletIntegrationId: process.env.PAYMOB_WALLET_INTEGRATION_ID,
    hmacSecret: process.env.PAYMOB_HMAC_SECRET,
  },
  binance: {
    apiKey: process.env.BINANCE_API_KEY,
    secretKey: process.env.BINANCE_SECRET_KEY,
  },
  notifications: {
    telegramToken: process.env.TELEGRAM_BOT_TOKEN,
    telegramChatId: process.env.TELEGRAM_CHAT_ID,
    slackWebhookUrl: process.env.SLACK_WEBHOOK_URL,
    firebase: {
      serviceAccount: process.env.FIREBASE_SERVICE_ACCOUNT_JSON, // Path to service account JSON or raw JSON string
    },
  },
  // Redis Caching Configuration | إعدادات التخزين المؤقت (ريديس)
  redis: {
    host: process.env.REDIS_HOST || 'localhost',
    port: parseInt(process.env.REDIS_PORT || '6379', 10),
  },
});
