import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';

/**
 * Configuration for SEON geolocation services.
 */
export interface SeonGeolocationConfig {
  /**
   * When enabled, SEON pre-fetches location on creation
   * of a SeonReactNativeMobileWrapper object for better performance.
   * Only applicable on Android.
   */
  prefetchEnabled?: boolean;

  /**
   * Property for the network timeout for SEON's geolocation services in milliseconds.
   * The default value is 3000.
   * @platform android, ios
   */
  geolocationServiceTimeoutMs?: number;

  /**
   * Property for the maximum location data age permitted in seconds.
   * The default value is 600.
   * Only applicable on Android.
   * @platform android, ios
   */
  maxGeoLocationCacheAgeSec?: number;

  /**
   * Property for the enabled status for SEON's geolocation services.
   * @platform android, ios
   */
  geolocationEnabled?: boolean;
}

/**
 * Defines all the methods the native module will expose for the new architecture.
 */
export interface Spec extends TurboModule {
  /**
   * Sets the session ID for the current user session.
   */
  setSessionId(sessionId: string): Promise<void>;

  /**
   * Enables or disables debug logging for the SEON SDK.
   */
  setLoggingEnabled(enabled: boolean): Promise<void>;

  /**
   * Retrieves device intelligence as a base64-encoded string.
   */
  getFingerprintBase64(): Promise<string>;

  /**
   * Starts monitoring user behavior.
   */
  startBehaviourMonitoring(): Promise<void>;

  /**
   * Stops monitoring and returns enriched intelligence as base64-encoded string.
   */
  stopBehaviourMonitoring(): Promise<string>;

  /**
   * Enables or disables SEON's geolocation services.
   */
  setGeolocationEnabled(enabled: boolean): Promise<void>;

  /**
   * Sets configuration for SEON's geolocation services.
   */
  setGeoLocationConfig(config: SeonGeolocationConfig): Promise<void>;
}

// TurboModuleRegistry will look up the native module by this name.
// Ensure this name matches your Objective-C class registration & codegen config!
export default TurboModuleRegistry.getEnforcing<Spec>(
  'SeonReactNativeMobileWrapperSpec'
);
