import { UIManager, Platform, Image } from 'react-native';
let MapViewManagerCommands = {
  create: 1,
  center: 2,
  setMapVenue: 3,
  centerMapOnPoint: 4,
  setFollowBlueDot: 5,
  setUserPosition: 6,
  setUserPositionXY: 7,
  clearWayfindingPath: 8,
  wayfindToWaypoint: 9,
  wayfindBetweenWaypoints: 10,
  drawNavigationPath: 11,
  styleUnitsForDestination: 12,
  styleShape: 13,
  addMapIcon: 14,
  startOdp: 15,
  stopOdp: 16,
  uploadLogs: 17,
  setMapViewBounds: 18,
  setMapViewToPath: 19
};
if (Platform.OS == 'ios') {
  MapViewManagerCommands = {
    create: 'create',
    center: 'center',
    setMapVenue: 'setMapVenue',
    centerMapOnPoint: 'centerMapOnPoint',
    setFollowBlueDot: 'setFollowBlueDot',
    setUserPosition: 'setUserPosition',
    setUserPositionXY: 'setUserPositionXY',
    clearWayfindingPath: 'clearWayfindingPath',
    wayfindToWaypoint: 'wayfindToWaypoint',
    wayfindBetweenWaypoints: 'wayfindBetweenWaypoints',
    drawNavigationPath: 'drawNavigationPath',
    styleUnitsForDestination: 'styleUnitsForDestination',
    styleShape: 'styleShape',
    addMapIcon: 'addMapIcon',
    startOdp: 'startOdp',
    stopOdp: 'stopOdp',
    uploadLogs: 'uploadLogs',
    setMapViewBounds: 'setMapViewBounds',
    setMapViewToPath: 'setMapViewToPath'
  };
}
const createImage = imageSource => {
  const image = {
    iconSource: imageSource
  };
  return createImageUrl(image);
};
const createImageUrl = image => {
  const updatedImage = {
    ...image
  };
  if (updatedImage.iconSource) {
    const resolvedImage = Image.resolveAssetSource(updatedImage.iconSource);
    if (!updatedImage.iconHeight) {
      updatedImage.iconHeight = 25;
    }
    if (!updatedImage.iconWidth) {
      updatedImage.iconWidth = resolvedImage.width;
    }
    updatedImage.iconUrl = resolvedImage.uri;
    updatedImage.iconImage = resolvedImage;
  }
  return updatedImage;
};
export const createFragment = viewId => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.create.toString(), [viewId]);
export const centerMap = (viewId, options) => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.center.toString(), [options]);
export function getRandomInt(max) {
  return Math.floor(Math.random() * max);
}
export const setMapVenue = _ref => {
  var _mapOptions$user;
  let {
    viewId,
    credentials,
    mapOptions = {}
  } = _ref;
  if (mapOptions && mapOptions.user && (_mapOptions$user = mapOptions.user) !== null && _mapOptions$user !== void 0 && _mapOptions$user.iconImage) mapOptions.user = {
    ...mapOptions.user,
    ...createImage(mapOptions.user.iconImage)
  };
  UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setMapVenue.toString(), [credentials, mapOptions]);
};
export const addMapIcon = (viewId, coordinates, coordType, icon) => {
  const mapIcon = createImageUrl(icon);
  UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.addMapIcon.toString(), [coordinates, coordType, mapIcon]);
};
export const centerMapOnPoint = (viewId, options) => {
  UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.centerMapOnPoint.toString(), [options]);
};
export const setMapViewBounds = (viewId, options) => {
  UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setMapViewBounds.toString(), [options]);
};
export const setMapViewToPath = (viewId, options) => {
  UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setMapViewToPath.toString(), [options]);
};
export const setFollowBlueDot = function (viewId, enabled) {
  let rotate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  let interval = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500;
  return UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setFollowBlueDot.toString(), [enabled, rotate, interval]);
};
export const setUserPosition = (viewId, x, y, heading, confidence, format) => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setUserPosition.toString(), [x, y, heading, confidence, format]);
export const clearWayfindingPath = viewId => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.clearWayfindingPath.toString(), []);
export const wayfindToWaypoint = (viewId, waypointId) => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.wayfindToWaypoint.toString(), [waypointId]);
export const wayfindBetweenWaypoints = (viewId, originId, destinationId) => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.wayfindBetweenWaypoints.toString(), [originId, destinationId]);
export const drawNavigationPath = (viewId, pathId, shouldFocus, style, originIconUrl, destinationIconUrl) => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.drawNavigationPath.toString(), [pathId, shouldFocus, style, originIconUrl ? createImageUrl(originIconUrl) : originIconUrl, destinationIconUrl ? createImageUrl(destinationIconUrl) : destinationIconUrl]);
export const styleUnitsForDestination = (viewId, destination, style) => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.styleUnitsForDestination.toString(), [destination, style]);
export const styleShape = (viewId, id, style) => UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.styleShape.toString(), [id, style]);

// export type ImageSourcePropType = ImageURISource | ImageURISource[] | ImageRequireSource | Image;
//# sourceMappingURL=SendCommand.js.map