import {createPermissionHook} from 'expo'

import * as AppleTypes from './apple/AppleMaps.types'
import {AppleMapsView} from './apple/AppleMapsView'
import ExpoMaps from './ExpoMaps'
import * as GoogleTypes from './google/GoogleMaps.types'
import {GoogleMapsView} from './google/GoogleMapsView'
import {GoogleStreetView} from './google/GoogleStreetView'

/**
 * @hidden
 */
export namespace GoogleMaps {
  export const View = GoogleMapsView
  export const StreetView = GoogleStreetView

  export const MapType = GoogleTypes.GoogleMapsMapType
  export type MapType = GoogleTypes.GoogleMapsMapType

  export const MapColorScheme = GoogleTypes.GoogleMapsColorScheme
  export type MapColorScheme = GoogleTypes.GoogleMapsColorScheme

  export type Marker = GoogleTypes.GoogleMapsMarker
  export type MapUISettings = GoogleTypes.GoogleMapsUISettings
  export type MapProperties = GoogleTypes.GoogleMapsProperties

  export type MapProps = GoogleTypes.GoogleMapsViewProps
  export type MapView = GoogleTypes.GoogleMapsViewType

  export type StreetViewProps = GoogleTypes.GoogleStreetViewProps
}

/**
 * @hidden
 */
export namespace AppleMaps {
  export const View = AppleMapsView

  export const MapType = AppleTypes.AppleMapsMapType
  export type MapType = AppleTypes.AppleMapsMapType

  export const MapStyleElevation =
    AppleTypes.AppleMapsMapStyleElevation
  export type MapStyleElevation =
    AppleTypes.AppleMapsMapStyleElevation

  export const MapColorScheme = AppleTypes.AppleMapsColorScheme
  export type MapColorScheme = AppleTypes.AppleMapsColorScheme

  export const ContourStyle = AppleTypes.AppleMapsContourStyle
  export type ContourStyle = AppleTypes.AppleMapsContourStyle

  export type Marker = AppleTypes.AppleMapsMarker
  export type Annotation = AppleTypes.AppleMapsAnnotation
  export type MapUISettings = AppleTypes.AppleMapsUISettings
  export type MapProperties = AppleTypes.AppleMapsProperties

  export type MapProps = AppleTypes.AppleMapsViewProps
  export type MapView = AppleTypes.AppleMapsViewType
}

export const requestPermissionsAsync =
  ExpoMaps.requestPermissionsAsync
export const getPermissionsAsync = ExpoMaps.getPermissionsAsync

/**
 * Check or request permissions to access the location.
 * This uses both `requestPermissionsAsync` and `getPermissionsAsync` to interact with the permissions.
 *
 * @example
 * ```ts
 * const [status, requestPermission] = useLocationPermissions();
 * ```
 */
export const useLocationPermissions = createPermissionHook({
  getMethod: getPermissionsAsync,
  requestMethod: requestPermissionsAsync,
})

export * from './shared.types'
