"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.drawNavigationPath = exports.createFragment = exports.clearWayfindingPath = exports.centerMapOnPoint = exports.centerMap = exports.addMapIcon = void 0;
exports.getRandomInt = getRandomInt;
exports.wayfindToWaypoint = exports.wayfindBetweenWaypoints = exports.styleUnitsForDestination = exports.styleShape = exports.setUserPosition = exports.setMapViewToPath = exports.setMapViewBounds = exports.setMapVenue = exports.setFollowBlueDot = void 0;
var _reactNative = require("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 (_reactNative.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 = _reactNative.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;
};
const createFragment = viewId => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.create.toString(), [viewId]);
exports.createFragment = createFragment;
const centerMap = (viewId, options) => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.center.toString(), [options]);
exports.centerMap = centerMap;
function getRandomInt(max) {
  return Math.floor(Math.random() * max);
}
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)
  };
  _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setMapVenue.toString(), [credentials, mapOptions]);
};
exports.setMapVenue = setMapVenue;
const addMapIcon = (viewId, coordinates, coordType, icon) => {
  const mapIcon = createImageUrl(icon);
  _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.addMapIcon.toString(), [coordinates, coordType, mapIcon]);
};
exports.addMapIcon = addMapIcon;
const centerMapOnPoint = (viewId, options) => {
  _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.centerMapOnPoint.toString(), [options]);
};
exports.centerMapOnPoint = centerMapOnPoint;
const setMapViewBounds = (viewId, options) => {
  _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setMapViewBounds.toString(), [options]);
};
exports.setMapViewBounds = setMapViewBounds;
const setMapViewToPath = (viewId, options) => {
  _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setMapViewToPath.toString(), [options]);
};
exports.setMapViewToPath = setMapViewToPath;
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 _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setFollowBlueDot.toString(), [enabled, rotate, interval]);
};
exports.setFollowBlueDot = setFollowBlueDot;
const setUserPosition = (viewId, x, y, heading, confidence, format) => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.setUserPosition.toString(), [x, y, heading, confidence, format]);
exports.setUserPosition = setUserPosition;
const clearWayfindingPath = viewId => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.clearWayfindingPath.toString(), []);
exports.clearWayfindingPath = clearWayfindingPath;
const wayfindToWaypoint = (viewId, waypointId) => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.wayfindToWaypoint.toString(), [waypointId]);
exports.wayfindToWaypoint = wayfindToWaypoint;
const wayfindBetweenWaypoints = (viewId, originId, destinationId) => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.wayfindBetweenWaypoints.toString(), [originId, destinationId]);
exports.wayfindBetweenWaypoints = wayfindBetweenWaypoints;
const drawNavigationPath = (viewId, pathId, shouldFocus, style, originIconUrl, destinationIconUrl) => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.drawNavigationPath.toString(), [pathId, shouldFocus, style, originIconUrl ? createImageUrl(originIconUrl) : originIconUrl, destinationIconUrl ? createImageUrl(destinationIconUrl) : destinationIconUrl]);
exports.drawNavigationPath = drawNavigationPath;
const styleUnitsForDestination = (viewId, destination, style) => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.styleUnitsForDestination.toString(), [destination, style]);
exports.styleUnitsForDestination = styleUnitsForDestination;
const styleShape = (viewId, id, style) => _reactNative.UIManager.dispatchViewManagerCommand(viewId, MapViewManagerCommands.styleShape.toString(), [id, style]);

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