import SIDAddressVerification from './NativeSIDAddressVerification';

import { NativeEventEmitter } from 'react-native';

const eventEmitter = new NativeEventEmitter(SIDAddressVerification);

eventEmitter.addListener('onLocationUpdate', (data) => {
  console.log('Location update:', data);
});

// Type for the resolved address
export type ResolvedAddress = {
  latitude: number;
  longitude: number;
  fullAddress: string;
  country?: string;
  state?: string;
  city?: string;
  postalCode?: string;
  street?: string;
};

// Example usage
// await MyAwesomeModule.startTrackingWithConfig('API_KEY', 'TOKEN', 'REFRESH_TOKEN');

export function startTrackingWithConfig(
  apiKey: string,
  customerID: string,
  verificationId: string
): Promise<boolean> {
  return SIDAddressVerification.startTrackingWithConfig(
    apiKey,
    customerID,
    verificationId
  );
}

export function stopTracking(): void {
  SIDAddressVerification.stopTracking();
}

export function fetchConfiguration(
  apiKey: string,
  customerID: string,
  token: string,
  refreshToken: string
): Promise<{ pollingInterval: number; sessionTimeout: number }> {
  return SIDAddressVerification.fetchConfiguration(
    apiKey,
    customerID,
    token,
    refreshToken
  );
}

export function pickLocation(): Promise<ResolvedAddress> {
  return SIDAddressVerification.pickLocation();
}

export function multiply(a: number, b: number): number {
  return SIDAddressVerification.multiply(a, b);
}