import { Injectable, Optional } from '@angular/core';
import { NotifierActionType } from './../models/notifier-action.model';
import { NotifierConfig } from './../models/notifier-config.model';
import { NotifierQueueService } from './notifier-queue.service';
/**
 * Notifier service
 *
 * This service provides access to the public notifier API. Once injected into a component, directive, pipe, service, or any other building
 * block of an applications, it can be used to show new notifications, and hide existing ones. Internally, it transforms API calls into
 * actions, which then get thrown into the action queue - eventually being processed at the right moment.
 */
export var NotifierService = (function () {
    /**
     * Constructor
     *
     * @param {NotifierQueueService} notifierQueueService Notifier queue service
     * @param {NotifierConfig}       config               Notifier configuration, optionally injected as a dependency
     */
    function NotifierService(notifierQueueService, config) {
        this.queueService = notifierQueueService;
        this.config = config === null ? new NotifierConfig() : config; // Use custom config (if set), else create a default config
    }
    /**
     * Get the notifier configuration
     *
     * @returns {NotifierConfig} Notifier configuration
     */
    NotifierService.prototype.getConfig = function () {
        return this.config;
    };
    /**
     * API: Show a new notification
     *
     * @param {NotifierNotificationOptions} notificationOptions Notification options
     */
    NotifierService.prototype.show = function (notificationOptions) {
        this.queueService.push({
            payload: notificationOptions,
            type: NotifierActionType.SHOW
        });
    };
    /**
     * API: Hide a specific notification, given its ID
     *
     * @param {string} notificationId ID of the notification to hide
     */
    NotifierService.prototype.hide = function (notificationId) {
        this.queueService.push({
            payload: notificationId,
            type: NotifierActionType.HIDE
        });
    };
    /**
     * API: Hide the newest notification
     */
    NotifierService.prototype.hideNewest = function () {
        this.queueService.push({
            type: NotifierActionType.HIDE_NEWEST
        });
    };
    /**
     * API: Hide the oldest notification
     */
    NotifierService.prototype.hideOldest = function () {
        this.queueService.push({
            type: NotifierActionType.HIDE_OLDEST
        });
    };
    /**
     * API: Hide all notifications at once
     */
    NotifierService.prototype.hideAll = function () {
        this.queueService.push({
            type: NotifierActionType.HIDE_ALL
        });
    };
    /**
     * API: Shortcut for showing a new notification
     *
     * @param {string} type             Type of the notification
     * @param {string} message          Message of the notification
     * @param {string} [notificationId] Unique ID for the notification (optional)
     */
    NotifierService.prototype.notify = function (type, message, notificationId) {
        var notificationOptions = {
            message: message,
            type: type
        };
        if (notificationId !== undefined) {
            notificationOptions.id = notificationId;
        }
        this.show(notificationOptions);
    };
    NotifierService.decorators = [
        { type: Injectable },
    ];
    /** @nocollapse */
    NotifierService.ctorParameters = function () { return [
        { type: NotifierQueueService, },
        { type: NotifierConfig, decorators: [{ type: Optional },] },
    ]; };
    return NotifierService;
}());
//# sourceMappingURL=notifier.service.js.map