import { __require as requireUaParser } from '../../../../ua-parser-js@0.7.41/node_modules/ua-parser-js/src/ua-parser.js';

/**
 * Copyright (c) 2013-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

var UserAgentData;
var hasRequiredUserAgentData;

function requireUserAgentData () {
	if (hasRequiredUserAgentData) return UserAgentData;
	hasRequiredUserAgentData = 1;

	var UAParser = requireUaParser();

	var UNKNOWN = 'Unknown';
	var PLATFORM_MAP = {
	  'Mac OS': 'Mac OS X'
	};
	/**
	 * Convert from UAParser platform name to what we expect.
	 */

	function convertPlatformName(name) {
	  return PLATFORM_MAP[name] || name;
	}
	/**
	 * Get the version number in parts. This is very naive. We actually get major
	 * version as a part of UAParser already, which is generally good enough, but
	 * let's get the minor just in case.
	 */


	function getBrowserVersion(version) {
	  if (!version) {
	    return {
	      major: '',
	      minor: ''
	    };
	  }

	  var parts = version.split('.');
	  return {
	    major: parts[0],
	    minor: parts[1]
	  };
	}
	/**
	 * Get the UA data fom UAParser and then convert it to the format we're
	 * expecting for our APIS.
	 */


	var parser = new UAParser();
	var results = parser.getResult(); // Do some conversion first.

	var browserVersionData = getBrowserVersion(results.browser.version);
	var uaData = {
	  browserArchitecture: results.cpu.architecture || UNKNOWN,
	  browserFullVersion: results.browser.version || UNKNOWN,
	  browserMinorVersion: browserVersionData.minor || UNKNOWN,
	  browserName: results.browser.name || UNKNOWN,
	  browserVersion: results.browser.major || UNKNOWN,
	  deviceName: results.device.model || UNKNOWN,
	  engineName: results.engine.name || UNKNOWN,
	  engineVersion: results.engine.version || UNKNOWN,
	  platformArchitecture: results.cpu.architecture || UNKNOWN,
	  platformName: convertPlatformName(results.os.name) || UNKNOWN,
	  platformVersion: results.os.version || UNKNOWN,
	  platformFullVersion: results.os.version || UNKNOWN
	};
	UserAgentData = uaData;
	return UserAgentData;
}

export { requireUserAgentData as __require };
//# sourceMappingURL=UserAgentData.js.map
