license import { Inject , Injectable , Optional , PLATFORM_ID } from '@angular/core' ; import { isPlatformBrowser } from '@angular/common' ; const hasV8BreakIterator = ( typeof Intl !== 'undefined' && ( Intl as any ) . v8BreakIterator ) ; /**
 * Service to detect the current platform by comparing the userAgent strings and
 * checking browser-specific global properties.
 */ @ Injectable ( { providedIn : 'root' } ) export class Platform { /**
     * Whether the Angular application is being rendered in the browser.
     * We want to use the Angular platform check because if the Document is shimmed
     * without the navigator, the following checks will fail. This is preferred because
     * sometimes the Document may be shimmed without the user's knowledge or intention
     */ isBrowser : boolean = this . _platformId ? isPlatformBrowser ( this . _platformId ) : typeof document === 'object' && ! ! document ; /** Whether the current browser is Microsoft Edge. */ EDGE : boolean = this . isBrowser && /(edge)/i . test ( navigator . userAgent ) ; /** Whether the current rendering engine is Microsoft Trident. */ TRIDENT : boolean = this . isBrowser && /(msie|trident)/i . test ( navigator . userAgent ) ; /** Whether the current rendering engine is Blink. */ BLINK : boolean = this . isBrowser && ( ! ! ( ( window as any ) . chrome || hasV8BreakIterator ) && typeof CSS !== 'undefined' && ! this . EDGE && ! this . TRIDENT ) ; /** Whether the current rendering engine is WebKit. */ WEBKIT : boolean = this . isBrowser && /AppleWebKit/i . test ( navigator . userAgent ) && ! this . BLINK && ! this . EDGE && ! this . TRIDENT ; /** Whether the current platform is Apple iOS. */ IOS : boolean = this . isBrowser && /iPad|iPhone|iPod/ . test ( navigator . userAgent ) && ! ( 'MSStream' in window ) ; /** Whether the current browser is Firefox. */ FIREFOX : boolean = this . isBrowser && /(firefox|minefield)/i . test ( navigator . userAgent ) ; /** Whether the current platform is Android. */ ANDROID : boolean = this . isBrowser && /android/i . test ( navigator . userAgent ) && ! this . TRIDENT ; /** Whether the current browser is Safari. */ SAFARI : boolean = this . isBrowser && /safari/i . test ( navigator . userAgent ) && this . WEBKIT ; breaking-change constructor ( @ Optional ( ) @ Inject ( PLATFORM_ID ) private _platformId ? ) { } }