import { Component, Inject } from '@angular/core';
import { MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
import { UpdateViewComponent } from '../../update-view/update-view.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/snack-bar";
import * as i2 from "@angular/material/dialog";
import * as i3 from "@angular/router";
import * as i4 from "./../../techlify-update.service";
import * as i5 from "./../../../core/alert.service";
import * as i6 from "@angular/material/button";
import * as i7 from "@angular/material/icon";
import * as i8 from "@angular/material/tooltip";
import * as i9 from "@angular/flex-layout/flex";
export class UpdateNotifierSnackComponent {
    constructor(data, snackBarRef, dialog, router, techlifyUpdateService, alertService) {
        this.data = data;
        this.snackBarRef = snackBarRef;
        this.dialog = dialog;
        this.router = router;
        this.techlifyUpdateService = techlifyUpdateService;
        this.alertService = alertService;
        this.maxDescriptionLength = 70;
        this.descriptionText = '';
    }
    ngOnInit() {
        this.techlifyUpdate = this.data.techlifyUpdate;
        this.rootNavUrl = this.data.rootNavUrl;
        this.determineDescription(this.techlifyUpdate?.description);
    }
    close() {
        this.createUpdateViewRecord();
        this.snackBarRef.dismiss();
    }
    determineDescription(description) {
        if (!description || description.length <= this.maxDescriptionLength) {
            this.descriptionText = description;
            return;
        }
        this.descriptionText = description.substring(0, this.maxDescriptionLength) + "...";
    }
    openUpdateView() {
        this.close();
        const dialogRef = this.dialog.open(UpdateViewComponent, {
            width: "800px",
            autoFocus: false,
            data: {
                techlifyUpdate: this.techlifyUpdate,
                rootNavUrl: this.data.rootNavUrl
            } // Any data passed here will be injected into the model
        });
    }
    openUpdateHistory() {
        this.close();
        this.router.navigate([this.rootNavUrl + "/update-history"]);
    }
    async createUpdateViewRecord() {
        try {
            var techlifyUpdateView = {
                update_id: this.techlifyUpdate?.id
            };
            let result = await this.techlifyUpdateService.createUpdateViewRecord(techlifyUpdateView);
        }
        catch (error) {
            this.alertService.addAlert("Unable to process, try later", "warn");
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: UpdateNotifierSnackComponent, deps: [{ token: MAT_SNACK_BAR_DATA }, { token: i1.MatSnackBarRef }, { token: i2.MatDialog }, { token: i3.Router }, { token: i4.TechlifyUpdateService }, { token: i5.AlertService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: UpdateNotifierSnackComponent, selector: "app-update-notifier-snack", ngImport: i0, template: "<div fxLayout=\"column\">\n  <div fxLayout=\"row wrap\" fxLayoutAlign=\"space-between\">\n    <div fxLayout=\"row wrap\" fxLayoutGap=\"1rem\">\n      <span fxLayoutAlign=\"center center\">\n        <mat-icon class=\"large-icon primary-color\">\n          <span class=\"material-icons-outlined\">\n            grading\n          </span>\n        </mat-icon>\n      </span>\n      <div fxLayout=\"column\">\n        <h5 class=\"primary-color text-truncate\" matTooltip=\"{{techlifyUpdate?.title}}\" matTooltipPosition=\"below\">\n          App Update: {{techlifyUpdate?.title}}\n        </h5>\n        <small class=\"text-muted\">\n          Version : {{techlifyUpdate?.version}}\n        </small>\n      </div>\n    </div>\n    <div fxLayoutAlign=\"end center\" class=\"text-muted\">\n      <button mat-icon-button type=\"button\" (click)=\"close()\">\n        <mat-icon>clear</mat-icon>\n      </button>\n    </div>\n  </div>\n  <div fxLayout=\"row\" class=\"text-muted\" style=\"margin-top: 1rem;\" [innerHtml]=\"descriptionText\">\n  </div>\n  <div fxLayout=\"row\" fxLayoutAlign=\"space-between\">\n    <button type=\"button\" mat-button class=\"primary-color\" (click)=\"openUpdateHistory()\">\n      <mat-icon>\n        history\n      </mat-icon>\n      Update History\n    </button>\n    <button type=\"button\" mat-raised-button class=\"primary-bg text-white\" (click)=\"openUpdateView()\">\n      View\n    </button>\n  </div>\n</div>\n", styles: [".large-icon{transform:scale(1.5)}.primary-color{color:#009fdd!important}.primary-bg{background-color:#009fdd!important}.text-muted,.text-white{color:#d3d3d3}.text-truncate{width:400px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}@media screen and (max-width: 1440px){.text-truncate{width:350px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}}@media screen and (max-width: 1024px){.text-truncate{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}}@media screen and (max-width: 1024px){.text-truncate{width:190px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}}\n"], dependencies: [{ kind: "component", type: i6.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i8.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "directive", type: i9.DefaultLayoutDirective, selector: "  [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md],  [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md],  [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm],  [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i9.DefaultLayoutGapDirective, selector: "  [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md],  [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md],  [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm],  [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { kind: "directive", type: i9.DefaultLayoutAlignDirective, selector: "  [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md],  [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md],  [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm],  [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: UpdateNotifierSnackComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-update-notifier-snack', template: "<div fxLayout=\"column\">\n  <div fxLayout=\"row wrap\" fxLayoutAlign=\"space-between\">\n    <div fxLayout=\"row wrap\" fxLayoutGap=\"1rem\">\n      <span fxLayoutAlign=\"center center\">\n        <mat-icon class=\"large-icon primary-color\">\n          <span class=\"material-icons-outlined\">\n            grading\n          </span>\n        </mat-icon>\n      </span>\n      <div fxLayout=\"column\">\n        <h5 class=\"primary-color text-truncate\" matTooltip=\"{{techlifyUpdate?.title}}\" matTooltipPosition=\"below\">\n          App Update: {{techlifyUpdate?.title}}\n        </h5>\n        <small class=\"text-muted\">\n          Version : {{techlifyUpdate?.version}}\n        </small>\n      </div>\n    </div>\n    <div fxLayoutAlign=\"end center\" class=\"text-muted\">\n      <button mat-icon-button type=\"button\" (click)=\"close()\">\n        <mat-icon>clear</mat-icon>\n      </button>\n    </div>\n  </div>\n  <div fxLayout=\"row\" class=\"text-muted\" style=\"margin-top: 1rem;\" [innerHtml]=\"descriptionText\">\n  </div>\n  <div fxLayout=\"row\" fxLayoutAlign=\"space-between\">\n    <button type=\"button\" mat-button class=\"primary-color\" (click)=\"openUpdateHistory()\">\n      <mat-icon>\n        history\n      </mat-icon>\n      Update History\n    </button>\n    <button type=\"button\" mat-raised-button class=\"primary-bg text-white\" (click)=\"openUpdateView()\">\n      View\n    </button>\n  </div>\n</div>\n", styles: [".large-icon{transform:scale(1.5)}.primary-color{color:#009fdd!important}.primary-bg{background-color:#009fdd!important}.text-muted,.text-white{color:#d3d3d3}.text-truncate{width:400px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}@media screen and (max-width: 1440px){.text-truncate{width:350px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}}@media screen and (max-width: 1024px){.text-truncate{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}}@media screen and (max-width: 1024px){.text-truncate{width:190px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:0}}\n"] }]
        }], ctorParameters: () => [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [MAT_SNACK_BAR_DATA]
                }] }, { type: i1.MatSnackBarRef }, { type: i2.MatDialog }, { type: i3.Router }, { type: i4.TechlifyUpdateService }, { type: i5.AlertService }] });
//# sourceMappingURL=data:application/json;base64, 