/**
 * @fileoverview added by tsickle
 * Generated from: lib/widgets/entry-components/toast/services/toast.service.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { TranslatePipe } from './../../../../shared/translate/pipes/translate.pipe';
import { ToastController } from '@ionic/angular';
import { Injectable } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@ionic/angular";
import * as i2 from "../../../../shared/translate/pipes/translate.pipe";
var ToastService = /** @class */ (function () {
    function ToastService(toastController, translatePipe) {
        this.toastController = toastController;
        this.translatePipe = translatePipe;
    }
    /**
     * @param {?} msg
     * @param {?=} btnTxt
     * @param {?=} handler
     * @return {?}
     */
    ToastService.prototype.presentToast = /**
     * @param {?} msg
     * @param {?=} btnTxt
     * @param {?=} handler
     * @return {?}
     */
    function (msg, btnTxt, handler) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var _a;
            return tslib_1.__generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        if (this.toast) {
                            this.toast.dismiss();
                        }
                        _a = this;
                        return [4 /*yield*/, this.toastController.create({
                                keyboardClose: true,
                                message: this.translatePipe.transform(msg),
                                position: 'bottom',
                                duration: 2000,
                                buttons: [
                                    btnTxt ? this.getButton(btnTxt, handler) : '',
                                ]
                            })];
                    case 1:
                        _a.toast = _b.sent();
                        this.toast.present();
                        return [2 /*return*/];
                }
            });
        });
    };
    /**
     * @param {?} btnTxt
     * @param {?} handler
     * @return {?}
     */
    ToastService.prototype.getButton = /**
     * @param {?} btnTxt
     * @param {?} handler
     * @return {?}
     */
    function (btnTxt, handler) {
        return {
            side: 'end',
            cssClass: ['inc-toast-button'],
            text: this.translatePipe.transform(btnTxt),
            handler: handler
        };
    };
    ToastService.decorators = [
        { type: Injectable, args: [{
                    providedIn: 'root'
                },] }
    ];
    /** @nocollapse */
    ToastService.ctorParameters = function () { return [
        { type: ToastController },
        { type: TranslatePipe }
    ]; };
    /** @nocollapse */ ToastService.ngInjectableDef = i0.defineInjectable({ factory: function ToastService_Factory() { return new ToastService(i0.inject(i1.ToastController), i0.inject(i2.TranslatePipe)); }, token: ToastService, providedIn: "root" });
    return ToastService;
}());
export { ToastService };
if (false) {
    /** @type {?} */
    ToastService.prototype.toast;
    /**
     * @type {?}
     * @private
     */
    ToastService.prototype.toastController;
    /**
     * @type {?}
     * @private
     */
    ToastService.prototype.translatePipe;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9hc3Quc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BpbmNsb3VkZWQvaW9uaWM0LWluY2xvdWRlZC1saWIvIiwic291cmNlcyI6WyJsaWIvd2lkZ2V0cy9lbnRyeS1jb21wb25lbnRzL3RvYXN0L3NlcnZpY2VzL3RvYXN0LnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBQ3BGLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUNqRCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOzs7O0FBRzNDO0lBTUksc0JBQW9CLGVBQWdDLEVBQVUsYUFBNEI7UUFBdEUsb0JBQWUsR0FBZixlQUFlLENBQWlCO1FBQVUsa0JBQWEsR0FBYixhQUFhLENBQWU7SUFBSSxDQUFDOzs7Ozs7O0lBRXpGLG1DQUFZOzs7Ozs7SUFBbEIsVUFBbUIsR0FBVyxFQUFFLE1BQWUsRUFBRSxPQUFhOzs7Ozs7d0JBQzFELElBQUksSUFBSSxDQUFDLEtBQUssRUFBRTs0QkFDWixJQUFJLENBQUMsS0FBSyxDQUFDLE9BQU8sRUFBRSxDQUFDO3lCQUN4Qjt3QkFDRCxLQUFBLElBQUksQ0FBQTt3QkFBUyxx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ICAgICAgIGJ0blR4dCA/IHRoaXMuZ2V0QnV0dG9uKGJ0blR4dCwgaGFuZGxlcikgOiAnJyxcclxuICAgICAgICAgICAgXVxyXG4gICAgICAgIH0pO1xyXG4gICAgICAgIHRoaXMudG9hc3QucHJlc2VudCgpO1xyXG4gICAgfVxyXG5cclxuICAgIGdldEJ1dHRvbihidG5UeHQ6IHN0cmluZywgaGFuZGxlcjogYW55KTogVG9hc3RCdXR0b24ge1xyXG4gICAgICAgIHJldHVybiB7XHJcbiAgICAgICAgICAgIHNpZGU6ICdlbmQnLFxyXG4gICAgICAgICAgICBjc3NDbGFzczogWydpbmMtdG9hc3QtYnV0dG9uJ10sXHJcbiAgICAgICAgICAgIHRleHQ6IHRoaXMudHJhbnNsYXRlUGlwZS50cmFuc2Zvcm0oYnRuVHh0KSxcclxuICAgICAgICAgICAgaGFuZGxlclxyXG4gICAgICAgIH07XHJcbiAgICB9XHJcbn1cclxuIl19