import 'package:flutter/material.dart';


class CommonConstants {
  static String apiProto = 'https';
  static String apiHost = 'app.sendico.io';
  static String apiEndpoint = '/api/v1';
  static String amplitudeSecret = 'c3d75b3e2520d708440acbb16b923e79';
  static String amplitudeServerZone = 'EU';
  static String posthogApiKey = 'phc_lVhbruaZpxiQxppHBJpL36ARnPlkqbCewv6cauoceTN';
  static String posthogHost = 'https://eu.i.posthog.com';
  static Locale defaultLocale = const Locale('en');
  static String defaultCurrency = 'EUR';
  static int defaultDimensionLength = 500;
  static String clientId = '';
  static String wsProto = 'ws';
  static String wsEndpoint = '/ws';
  static Color themeColor = Color.fromARGB(255, 0, 0, 0);
  static String nilObjectRef = '000000000000000000000000';

  // Public getters for shared properties
  static String get serviceUrl => '$apiProto://$apiHost';
  static String get apiUrl => '$serviceUrl$apiEndpoint';
  static String get wsUrl => '$wsProto://$apiHost$apiEndpoint$wsEndpoint';
  static const String accessTokenStorageKey = 'access_token';
  static const String refreshTokenStorageKey = 'refresh_token';
  static const String currentOrgKey = 'current_org';
  static const String deviceIdStorageKey = 'device_id';

  // Method to apply the configuration, called by platform-specific implementations
  static void applyConfiguration(Map<String, dynamic> configJson) {
    apiProto = configJson['apiProto'] ?? apiProto;
    apiHost = configJson['apiHost'] ?? apiHost;
    apiEndpoint = configJson['apiEndpoint'] ?? apiEndpoint;
    amplitudeSecret = configJson['amplitudeSecret'] ?? amplitudeSecret;
    amplitudeServerZone = configJson['amplitudeServerZone'] ?? amplitudeServerZone;
    posthogApiKey = configJson['posthogApiKey'] ?? posthogApiKey;
    posthogHost = configJson['posthogHost'] ?? posthogHost;
    defaultLocale = Locale(configJson['defaultLocale'] ?? defaultLocale.languageCode);
    defaultCurrency = configJson['defaultCurrency'] ?? defaultCurrency;
    wsProto = configJson['wsProto'] ?? wsProto;
    wsEndpoint = configJson['wsEndpoint'] ?? wsEndpoint;
    defaultDimensionLength = configJson['defaultDimensionLength'] ?? defaultDimensionLength;
    clientId = configJson['clientId'] ?? clientId;
    if (configJson.containsKey('themeColor')) {
      themeColor = Color(int.parse(configJson['themeColor']));
    }
  }
}
