import { isPlatformServer, CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { EventEmitter, PLATFORM_ID, Directive, Inject, HostBinding, Output, NgModule } from '@angular/core';

class BsUserAgentDirective {
    constructor(platformId) {
        this.platformId = platformId;
        this.detected = new EventEmitter();
    }
    get isAndroid() {
        return !isPlatformServer(this.platformId) && !!navigator && !!navigator.userAgent.match(/Android/i);
    }
    get isIos() {
        return !isPlatformServer(this.platformId) && !!navigator && !!navigator.userAgent.match(/iPhone|iPad|iPod/i);
    }
    get isWindows() {
        return !isPlatformServer(this.platformId) && !!navigator && !!navigator.userAgent.match(/Windows/i);
    }
    get browserClass() {
        const browser = this.getBrowser();
        if (!browser) {
            return null;
        }
        else {
            return `browser-${browser.toLowerCase()}`;
        }
    }
    getBrowser() {
        if (!isPlatformServer(this.platformId) && !!navigator) {
            const userAgent = navigator.userAgent;
            if (userAgent.match(/opr\//i)) {
                return 'Opera';
            }
            else if (userAgent.match(/edg/i)) {
                return 'Edge';
            }
            else if (userAgent.match(/chrome|chromium|crios/i)) {
                return 'Chrome';
            }
            else if (userAgent.match(/firefox|fxios/i)) {
                return 'Firefox';
            }
            else if (userAgent.match(/safari/i)) {
                return 'Safari';
            }
            else {
                return undefined;
            }
        }
        else {
            return undefined;
        }
    }
    ngAfterViewInit() {
        setTimeout(() => {
            let os;
            let webbrowser = this.getBrowser();
            if (this.isAndroid) {
                os = 'Android';
            }
            else if (this.isIos) {
                os = 'iOS';
            }
            else if (this.isWindows) {
                os = 'Windows';
            }
            else {
                os = undefined;
            }
            this.detected.emit({ os, webbrowser });
        });
    }
}
BsUserAgentDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsUserAgentDirective, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Directive });
BsUserAgentDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.7", type: BsUserAgentDirective, selector: "[bsUserAgent]", outputs: { detected: "detected" }, host: { properties: { "class.os-android": "this.isAndroid", "class.os-ios": "this.isIos", "class.os-windows": "this.isWindows", "class": "this.browserClass" } }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsUserAgentDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[bsUserAgent]'
                }]
        }], ctorParameters: function () { return [{ type: Object, decorators: [{
                    type: Inject,
                    args: [PLATFORM_ID]
                }] }]; }, propDecorators: { isAndroid: [{
                type: HostBinding,
                args: ['class.os-android']
            }], isIos: [{
                type: HostBinding,
                args: ['class.os-ios']
            }], isWindows: [{
                type: HostBinding,
                args: ['class.os-windows']
            }], browserClass: [{
                type: HostBinding,
                args: ['class']
            }], detected: [{
                type: Output
            }] } });

class BsUserAgentModule {
}
BsUserAgentModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsUserAgentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
BsUserAgentModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: BsUserAgentModule, declarations: [BsUserAgentDirective], imports: [CommonModule], exports: [BsUserAgentDirective] });
BsUserAgentModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsUserAgentModule, imports: [CommonModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsUserAgentModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        BsUserAgentDirective
                    ],
                    imports: [
                        CommonModule
                    ],
                    exports: [
                        BsUserAgentDirective
                    ]
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { BsUserAgentDirective, BsUserAgentModule };
//# sourceMappingURL=mintplayer-ng-bootstrap-user-agent.mjs.map
