var _closeTimeout;
import { __classPrivateFieldGet } from "tslib";
import { Component, TemplateRef, ViewChild } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { DEFAULT_CONFIG } from './constant';
import { ZUIToastDataService } from './service/data.service';
export class ZUIToastComponent {
    constructor(snackbar, zuiToastDataService) {
        this.snackbar = snackbar;
        this.zuiToastDataService = zuiToastDataService;
        // #subscription = new Subscription()
        // #subject = new Subject()
        _closeTimeout.set(this, void 0);
        this.config = DEFAULT_CONFIG;
        this.items = [];
        // #closeNotify = (): void => {
        //   const first = this.items[this.items.length - 1]
        //   this.#closeTimeout = setTimeout(() => {
        //     this.close(first.id)
        //   }, 2000)
        // }
        this.open = (config = {}) => {
            config = Object.assign(Object.assign({}, this.config), config);
            this.snackBarRef = this.snackbar.openFromTemplate(this.templateRef, config);
            this.zuiToastDataService.setNotifyItems([]);
            // this.#subject.next()
            return this.snackBarRef;
        };
        this.close = () => {
            this.snackbar.dismiss();
        };
        // this.#subscription.add(
        //   this.#subject
        //     .pipe(
        //       map(() => {
        //         this.items.unshift({id: ZUIFR.datatype.uuid()})
        //       }),
        //       debounceTime(300)
        //     )
        //     .subscribe(() => {
        //       this.items[0].html = $('.zui-toast-content').html()
        //       this.#closeNotify()
        //     })
        // )
    }
    ngOnDestroy() {
        clearTimeout(__classPrivateFieldGet(this, _closeTimeout));
    }
}
_closeTimeout = new WeakMap();
ZUIToastComponent.decorators = [
    { type: Component, args: [{
                selector: 'zui-toast',
                template: "<ng-template #templateRef>\n  <div class=\"zui-toast-item\">\n    <div class=\"d-flex\">\n      <div class=\"d-flex-1 zui-toast-item-color zui-toast-content\">\n        <ng-content></ng-content>\n      </div>\n      <mat-icon class=\"zui-pointer zui-toast-item-close fs-18 lh-24\" (click)=\"close()\">close</mat-icon>\n    </div>\n  </div>\n</ng-template>\n<!-- <ng-template #templateRef>\n  <div class=\"zui-toast-item\" *ngFor=\"let item of items\">\n    <div class=\"d-flex\">\n      <div class=\"d-flex-1 zui-toast-item-color zui-toast-content\">\n        <ng-container *ngIf=\"item?.html; else content\">\n          <div [innerHTML]=\"item.html\"></div>\n        </ng-container>\n        <ng-template #content>\n          <ng-content></ng-content>\n        </ng-template>\n      </div>\n      <mat-icon class=\"zui-pointer zui-toast-item-close fs-18 lh-24\" (click)=\"close(item.id)\">close</mat-icon>\n    </div>\n  </div>\n</ng-template> -->\n",
                styles: [".zui-toast-item{margin-bottom:10px;border-radius:4px;padding:10px;box-shadow:0 3px 5px -1px rgba(0,0,0,.2),0 6px 10px rgba(0,0,0,.1411764706),0 1px 18px rgba(0,0,0,.1215686275)}.zui-toast-item-close{color:#000;opacity:.5}.zui-toast-item-close:hover{opacity:1}.zui-toast-item-color{color:#000}::ng-deep .zui-toast.mat-snack-bar-container{background:transparent!important;box-shadow:none!important}"]
            },] }
];
ZUIToastComponent.ctorParameters = () => [
    { type: MatSnackBar },
    { type: ZUIToastDataService }
];
ZUIToastComponent.propDecorators = {
    templateRef: [{ type: ViewChild, args: ['templateRef',] }]
};
//# sourceMappingURL=index.component.js.map