const android = /(android)/i.test( window.navigator.userAgent );
const chrome = !! window.chrome;
const firefox = typeof InstallTrigger !== 'undefined';
const ie = /* @cc_on!@ */ false || document.documentMode || false;
const edge = ! ie && !! window.StyleMedia;
const ios = !! window.navigator.userAgent.match( /(iPod|iPhone|iPad)/i );
const iosMobile = !! window.navigator.userAgent.match( /(iPod|iPhone)/i );
const opera =
!! window.opera || window.navigator.userAgent.indexOf( ' OPR/' ) >= 0;
const safari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || !chrome && !opera && window.webkitAudioContext !== 'undefined'; // eslint-disable-line
const os = window.navigator.platform;
/**
* @module browsers
* @description Runs a series of tests to return an object with browser data in it.
*
* @since 1.0.0
*
* @return {object} An object with browser data as keys and true false as values: android, chrome, edge, firefox,
* ie, ios, iosMobile, opera, safari, os.
*
* @example
* import { browsers } from "@gravityforms/utils";
*
* function Example() {
* const browser = browsers();
* return browser.ie || browser.firefox || ( browser.chrome && ! browser.edge )
* ? document.documentElement
* : document.body;
* }
*
*/
export default function browsers() {
return {
android,
chrome,
edge,
firefox,
ie,
ios,
iosMobile,
opera,
safari,
os,
};
}