import { Component } from '@angular/core';
import { finalize } from 'rxjs';
import { TechlifyListingControllerInterface } from '../../base-model';
import * as i0 from "@angular/core";
import * as i1 from "./techlify-notification-type.service";
import * as i2 from "./techlify-notification-subscription.service";
import * as i3 from "@angular/common";
import * as i4 from "@angular/material/card";
import * as i5 from "@angular/material/divider";
import * as i6 from "@angular/material/list";
import * as i7 from "@angular/material/progress-bar";
import * as i8 from "@angular/material/slide-toggle";
import * as i9 from "@angular/flex-layout/flex";
export class TechlifyNotificationForUserComponent extends TechlifyListingControllerInterface {
    constructor(techlifyNotificationTypeService, techlifyNotificationSubscriptionService) {
        super();
        this.techlifyNotificationTypeService = techlifyNotificationTypeService;
        this.techlifyNotificationSubscriptionService = techlifyNotificationSubscriptionService;
        this.filters = {
            sort_by: 'group|desc'
        };
    }
    ngOnInit() {
        this.loadData();
    }
    loadData() {
        this.filters.page = this.page;
        this.filters.perPage = this.perPage;
        this.isWorking = true;
        this.techlifyNotificationTypeService.index(this.filters)
            .pipe(finalize(() => this.isWorking = false))
            .subscribe((result) => {
            this.models = result?.data;
        });
    }
    toggleSubscription(notificationType, field, event) {
        notificationType[field] = event.checked;
        notificationType.type_id = notificationType?.id;
        notificationType.isWorking = true;
        this.techlifyNotificationSubscriptionService.store(notificationType)
            .pipe(finalize(() => notificationType.isWorking = false))
            .subscribe(x => { });
    }
    ngOnDestroy() {
        // Until destroyed uses it
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TechlifyNotificationForUserComponent, deps: [{ token: i1.TechlifyNotificationTypeService }, { token: i2.TechlifyNotificationSubscriptionService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: TechlifyNotificationForUserComponent, selector: "app-techlify-notification-for-user", usesInheritance: true, ngImport: i0, template: "<div fxLayout=\"column\" class=\"container my-4\">\n    <div>\n        <mat-card appearance=\"outlined\">\n            <h3>My Notification Preferences</h3>\n        </mat-card>\n        <mat-progress-bar mode=\"indeterminate\" *ngIf=\"isWorking\"></mat-progress-bar>\n        <mat-card appearance=\"outlined\" class=\"mt-4\">\n            <mat-list fxLayout=\"column\">\n                <mat-list-item fxLayout>\n                    <h5 fxFlex=\"33%\" class=\"p-1\">Notification</h5>\n                    <h5 fxFlex class=\"p-1\">Email</h5>\n                    <h5 fxFlex class=\"p-1\">Mobile</h5>\n                    <h5 fxFlex class=\"p-1\">In-App</h5>\n                </mat-list-item>\n                <ng-container *ngFor=\"let model of models|keyvalue\">\n                    <mat-list-item>\n                        <h5 class=\"p-1\">{{model?.key}}</h5>\n                    </mat-list-item>\n                    <mat-list-item *ngFor=\"let notificationType of model.value\" fxLayout=\"start center\">\n                        <div fxFlex=\"33%\" class=\"p-1\">\n                            <div>{{notificationType?.title}} </div>\n                            <div style=\"text-wrap: auto; line-height: normal;\">\n                                <small class=\"text-secondary\"> {{notificationType?.description}} </small>\n                            </div>\n                        </div>\n                        <div fxFlex class=\"p-1\">\n                            <mat-slide-toggle\n                                (change)=\"toggleSubscription(notificationType,'is_subscribed_email',$event)\"\n                                [checked]=\"notificationType?.is_subscribed_email\"\n                                [disabled]=\"(!notificationType.is_editable) || notificationType.isWorking || notificationType?.is_subscribed_email_default == null\">\n                            </mat-slide-toggle>\n                        </div>\n                        <div fxFlex class=\"p-1\">\n                            <mat-slide-toggle\n                                (change)=\"toggleSubscription(notificationType,'is_subscribed_mobile',$event)\"\n                                [checked]=\"notificationType?.is_subscribed_mobile\"\n                                [disabled]=\"(!notificationType.is_editable) || notificationType.isWorking || notificationType?.is_subscribed_mobile_default == null\">\n                            </mat-slide-toggle>\n                        </div>\n                        <div fxFlex class=\"p-1\">\n                            <mat-slide-toggle\n                                (change)=\"toggleSubscription(notificationType,'is_subscribed_in_app',$event)\"\n                                [checked]=\"notificationType?.is_subscribed_in_app\"\n                                [disabled]=\"(!notificationType.is_editable) || notificationType.isWorking || notificationType?.is_subscribed_in_app_default == null\">\n                            </mat-slide-toggle>\n                        </div>\n                    </mat-list-item>\n                    <mat-divider></mat-divider>\n                </ng-container>\n            </mat-list>\n        </mat-card>\n    </div>\n\n</div>", styles: [":host ::ng-deep .mdc-list-item.mdc-list-item--with-one-line{height:auto!important}\n"], dependencies: [{ kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i4.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "component", type: i5.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "component", type: i6.MatList, selector: "mat-list", exportAs: ["matList"] }, { kind: "component", type: i6.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }, { kind: "component", type: i7.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: i8.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "color", "disabled", "disableRipple", "tabIndex", "checked", "hideIcon", "disabledInteractive"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }, { 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.DefaultFlexDirective, selector: "  [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md],  [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md],  [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm],  [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "pipe", type: i3.KeyValuePipe, name: "keyvalue" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TechlifyNotificationForUserComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-techlify-notification-for-user', template: "<div fxLayout=\"column\" class=\"container my-4\">\n    <div>\n        <mat-card appearance=\"outlined\">\n            <h3>My Notification Preferences</h3>\n        </mat-card>\n        <mat-progress-bar mode=\"indeterminate\" *ngIf=\"isWorking\"></mat-progress-bar>\n        <mat-card appearance=\"outlined\" class=\"mt-4\">\n            <mat-list fxLayout=\"column\">\n                <mat-list-item fxLayout>\n                    <h5 fxFlex=\"33%\" class=\"p-1\">Notification</h5>\n                    <h5 fxFlex class=\"p-1\">Email</h5>\n                    <h5 fxFlex class=\"p-1\">Mobile</h5>\n                    <h5 fxFlex class=\"p-1\">In-App</h5>\n                </mat-list-item>\n                <ng-container *ngFor=\"let model of models|keyvalue\">\n                    <mat-list-item>\n                        <h5 class=\"p-1\">{{model?.key}}</h5>\n                    </mat-list-item>\n                    <mat-list-item *ngFor=\"let notificationType of model.value\" fxLayout=\"start center\">\n                        <div fxFlex=\"33%\" class=\"p-1\">\n                            <div>{{notificationType?.title}} </div>\n                            <div style=\"text-wrap: auto; line-height: normal;\">\n                                <small class=\"text-secondary\"> {{notificationType?.description}} </small>\n                            </div>\n                        </div>\n                        <div fxFlex class=\"p-1\">\n                            <mat-slide-toggle\n                                (change)=\"toggleSubscription(notificationType,'is_subscribed_email',$event)\"\n                                [checked]=\"notificationType?.is_subscribed_email\"\n                                [disabled]=\"(!notificationType.is_editable) || notificationType.isWorking || notificationType?.is_subscribed_email_default == null\">\n                            </mat-slide-toggle>\n                        </div>\n                        <div fxFlex class=\"p-1\">\n                            <mat-slide-toggle\n                                (change)=\"toggleSubscription(notificationType,'is_subscribed_mobile',$event)\"\n                                [checked]=\"notificationType?.is_subscribed_mobile\"\n                                [disabled]=\"(!notificationType.is_editable) || notificationType.isWorking || notificationType?.is_subscribed_mobile_default == null\">\n                            </mat-slide-toggle>\n                        </div>\n                        <div fxFlex class=\"p-1\">\n                            <mat-slide-toggle\n                                (change)=\"toggleSubscription(notificationType,'is_subscribed_in_app',$event)\"\n                                [checked]=\"notificationType?.is_subscribed_in_app\"\n                                [disabled]=\"(!notificationType.is_editable) || notificationType.isWorking || notificationType?.is_subscribed_in_app_default == null\">\n                            </mat-slide-toggle>\n                        </div>\n                    </mat-list-item>\n                    <mat-divider></mat-divider>\n                </ng-container>\n            </mat-list>\n        </mat-card>\n    </div>\n\n</div>", styles: [":host ::ng-deep .mdc-list-item.mdc-list-item--with-one-line{height:auto!important}\n"] }]
        }], ctorParameters: () => [{ type: i1.TechlifyNotificationTypeService }, { type: i2.TechlifyNotificationSubscriptionService }] });
//# sourceMappingURL=data:application/json;base64, 