import { __decorate, __metadata } from "tslib";
import { Component, Input } from '@angular/core';
import { SettingsService } from '@aztrix/sdk';
import { UntilDestroy } from '@ngneat/until-destroy';
import { AbstractSettingButton } from '../abstract-setting-button';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/sdk";
import * as i2 from "@angular/common";
import * as i3 from "../../account-button/account-button.component";
import * as i4 from "@angular/material/slide-toggle";
import * as i5 from "@aztrix/helpers";
let NewsletterSettingButtonComponent = class NewsletterSettingButtonComponent extends AbstractSettingButton {
    constructor(_settings) {
        super();
        this._settings = _settings;
    }
    toggle() {
        this._settings
            .updateAccountSettings({
            ...this.settings,
            newsletterAccepted: !this.settings?.newsletterAccepted,
        })
            .subscribe((settings) => {
            this.settings = settings;
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NewsletterSettingButtonComponent, deps: [{ token: i1.SettingsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: NewsletterSettingButtonComponent, selector: "ax-newsletter-setting-button", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: "<ax-account-button\n  [title]=\"'settings.account.description' | translate\"\n  [hint]=\"hint\"\n  [type]=\"type\"\n  [color]=\"color\"\n  [loading]=\"_loading\"\n  [postIcon]=\"''\"\n  icon=\"email-outline\"\n  (click)=\"toggle()\"\n>\n  <mat-slide-toggle\n    *ngIf=\"settings\"\n    [checked]=\"settings.newsletterAccepted\"\n    class=\"post\"\n    color=\"primary\"\n  ></mat-slide-toggle>\n</ax-account-button>\n", styles: [".post{pointer-events:none}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.AccountButtonComponent, selector: "ax-account-button", inputs: ["title", "hint", "color", "postIcon"] }, { kind: "component", type: i4.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "color", "disabled", "disableRipple", "tabIndex", "checked", "hideIcon"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }] }); }
};
NewsletterSettingButtonComponent = __decorate([
    UntilDestroy(),
    __metadata("design:paramtypes", [SettingsService])
], NewsletterSettingButtonComponent);
export { NewsletterSettingButtonComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NewsletterSettingButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-newsletter-setting-button', template: "<ax-account-button\n  [title]=\"'settings.account.description' | translate\"\n  [hint]=\"hint\"\n  [type]=\"type\"\n  [color]=\"color\"\n  [loading]=\"_loading\"\n  [postIcon]=\"''\"\n  icon=\"email-outline\"\n  (click)=\"toggle()\"\n>\n  <mat-slide-toggle\n    *ngIf=\"settings\"\n    [checked]=\"settings.newsletterAccepted\"\n    class=\"post\"\n    color=\"primary\"\n  ></mat-slide-toggle>\n</ax-account-button>\n", styles: [".post{pointer-events:none}\n"] }]
        }], ctorParameters: () => [{ type: i1.SettingsService }], propDecorators: { settings: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV3c2xldHRlci1zZXR0aW5nLWJ1dHRvbi5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvbXBvbmVudHMvYWNjb3VudC9hY2NvdW50LXNldHRpbmdzL25ld3NsZXR0ZXItc2V0dGluZy1idXR0b24vbmV3c2xldHRlci1zZXR0aW5nLWJ1dHRvbi5jb21wb25lbnQudHMiLCIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2NvbXBvbmVudHMvYWNjb3VudC9hY2NvdW50LXNldHRpbmdzL25ld3NsZX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