import * as i0 from '@angular/core';
import { EventEmitter, Directive, Inject, Input, Output } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import * as i1 from '@ironsource/fusion-ui/components/notification/common/services';
import { NotificationType } from '@ironsource/fusion-ui/components/notification/common/entities';
import { isFunction } from '@ironsource/fusion-ui/utils';
import { BehaviorSubject } from 'rxjs';

class NotificationBaseComponent {
    get notificationType() {
        return NotificationType[this.data.type].toLowerCase();
    }
    constructor(document, notificationService, elRef, renderer) {
        this.document = document;
        this.notificationService = notificationService;
        this.elRef = elRef;
        this.renderer = renderer;
        this.data = {
            type: NotificationType.Basic,
            title: '',
            content: '',
            shown: false
        };
        // eslint-disable-next-line
        this.onClose = new EventEmitter();
        this.closeIconName$ = new BehaviorSubject({ iconName: 'close', iconVersion: 'v2' });
    }
    ngAfterViewInit() {
        this.renderer.appendChild(this.document.body, this.elRef.nativeElement);
    }
    close() {
        this.notificationService.hideNotification();
        this.onClose.emit(this.elRef.nativeElement);
    }
    secondaryButtonClicked() {
        if (this.data && this.data.buttons && this.data.buttons.secondary && isFunction(this.data.buttons.secondary.onClick)) {
            this.data.buttons.secondary.onClick();
        }
        else {
            this.close();
        }
    }
    primaryButtonClicked() {
        if (this.data && isFunction(this.data.buttons.primary.onClick)) {
            this.data.buttons.primary.onClick();
        }
        else {
            this.close();
        }
    }
    static { this.ɵfac = function NotificationBaseComponent_Factory(t) { return new (t || NotificationBaseComponent)(i0.ɵɵdirectiveInject(DOCUMENT), i0.ɵɵdirectiveInject(i1.NotificationService), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2)); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: NotificationBaseComponent, inputs: { data: "data" }, outputs: { onClose: "onClose" } }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NotificationBaseComponent, [{
        type: Directive
    }], () => [{ type: Document, decorators: [{
                type: Inject,
                args: [DOCUMENT]
            }] }, { type: i1.NotificationService }, { type: i0.ElementRef }, { type: i0.Renderer2 }], { data: [{
            type: Input
        }], onClose: [{
            type: Output
        }] }); })();

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

export { NotificationBaseComponent };
//# sourceMappingURL=ironsource-fusion-ui-components-notification-common-base.mjs.map
