import { __decorate, __metadata } from "tslib";
import { Component, Input } from '@angular/core';
import { MatomoService } from '@aztrix/helpers';
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 "@aztrix/helpers";
import * as i3 from "@angular/common";
import * as i4 from "../../account-button/account-button.component";
import * as i5 from "@angular/material/slide-toggle";
let AnalyticsSettingButtonComponent = class AnalyticsSettingButtonComponent extends AbstractSettingButton {
    constructor(_settings, _matomoService) {
        super();
        this._settings = _settings;
        this._matomoService = _matomoService;
    }
    toggle() {
        this._settings
            .updateAccountSettings({
            ...this.settings,
            collectAnalytics: !this.settings?.collectAnalytics,
        })
            .subscribe((settings) => {
            this.settings = settings;
            if (settings?.collectAnalytics) {
                this._matomoService.setConsentGiven();
            }
            else {
                this._matomoService.removeConsentGiven();
            }
        });
    }
    stopPropagation(event) {
        event.stopPropagation();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AnalyticsSettingButtonComponent, deps: [{ token: i1.SettingsService }, { token: i2.MatomoService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: AnalyticsSettingButtonComponent, selector: "ax-analytics-setting-button", inputs: { settings: "settings" }, usesInheritance: true, ngImport: i0, template: "<ax-account-button\n  [title]=\"'settings.privacy.analytics.title' | translate\"\n  [hint]=\"'settings.privacy.analytics.explanation' | translate\"\n  [type]=\"type\"\n  [color]=\"color\"\n  [loading]=\"_loading\"\n  [postIcon]=\"''\"\n  icon=\"cookie-cog-outline\"\n  (click)=\"toggle()\"\n>\n  <mat-slide-toggle\n    *ngIf=\"settings\"\n    [checked]=\"settings.collectAnalytics\"\n    class=\"post\"\n    color=\"primary\"\n    (click)=\"stopPropagation($event)\"\n  ></mat-slide-toggle>\n</ax-account-button>\n", styles: [".post{pointer-events:none}\n"], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i4.AccountButtonComponent, selector: "ax-account-button", inputs: ["title", "hint", "color", "postIcon"] }, { kind: "component", type: i5.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: i2.TranslatePipe, name: "translate" }] }); }
};
AnalyticsSettingButtonComponent = __decorate([
    UntilDestroy(),
    __metadata("design:paramtypes", [SettingsService,
        MatomoService])
], AnalyticsSettingButtonComponent);
export { AnalyticsSettingButtonComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AnalyticsSettingButtonComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-analytics-setting-button', template: "<ax-account-button\n  [title]=\"'settings.privacy.analytics.title' | translate\"\n  [hint]=\"'settings.privacy.analytics.explanation' | translate\"\n  [type]=\"type\"\n  [color]=\"color\"\n  [loading]=\"_loading\"\n  [postIcon]=\"''\"\n  icon=\"cookie-cog-outline\"\n  (click)=\"toggle()\"\n>\n  <mat-slide-toggle\n    *ngIf=\"settings\"\n    [checked]=\"settings.collectAnalytics\"\n    class=\"post\"\n    color=\"primary\"\n    (click)=\"stopPropagation($event)\"\n  ></mat-slide-toggle>\n</ax-account-button>\n", styles: [".post{pointer-events:none}\n"] }]
        }], ctorParameters: () => [{ type: i1.SettingsService }, { type: i2.MatomoService }], propDecorators: { settings: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 