import { ChangeDetectionStrategy, Component, Inject, Optional } from '@angular/core';
import { documentLink, MatomoService } from '@aztrix/helpers';
import { CommunicationType } from '@aztrix/models';
import { BACKEND_URL } from '@aztrix/sdk';
import { BehaviorSubject, first } from 'rxjs';
import { AbstractPropertyValueViewComponent } from '../abstract-property-value-view.component';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/helpers";
import * as i2 from "@angular/common";
import * as i3 from "../default-value-view/default-value-view.component";
import * as i4 from "rxjs";
export class DocumentValueViewComponent extends AbstractPropertyValueViewComponent {
    constructor(backendUrl$, _matomo) {
        super();
        this.backendUrl$ = backendUrl$;
        this._matomo = _matomo;
    }
    downloadPdf() {
        this._trackClick();
        this.backendUrl$
            .pipe(first())
            .subscribe((backendUrl) => window.open(documentLink(this.property, backendUrl), '_blank'));
    }
    _trackClick() {
        this._matomo.trackEvent('Document value', 'click', CommunicationType.URL.toLowerCase());
    }
}
DocumentValueViewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: DocumentValueViewComponent, deps: [{ token: BACKEND_URL, optional: true }, { token: i1.MatomoService }], target: i0.ɵɵFactoryTarget.Component });
DocumentValueViewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: DocumentValueViewComponent, selector: "ax-document-value-view", usesInheritance: true, ngImport: i0, template: "<ng-template #view>\n  <ax-default-value-view\n    [property]=\"property\"\n    [showVerificationLabel]=\"showVerificationLabel\"\n    [clickable]=\"false\"\n  ></ax-default-value-view>\n</ng-template>\n\n<ng-container *ngIf=\"clickable; else view\">\n  <a\n    class=\"c-card__property__link\"\n    [href]=\"property | propertyDocumentLink: (backendUrl$ | async)\"\n    [attr.download]=\"(property | propertyDisplayValue) + '.pdf'\"\n    (click)=\"downloadPdf(); $event.preventDefault()\"\n  >\n    <ng-container *ngTemplateOutlet=\"view\"></ng-container>\n  </a>\n</ng-container>\n", styles: [".property-value{font-size:16px;font-weight:700}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i3.DefaultValueViewComponent, selector: "ax-default-value-view" }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }, { kind: "pipe", type: i1.PropertyDisplayValuePipe, name: "propertyDisplayValue" }, { kind: "pipe", type: i1.PropertyDocumentLinkPipe, name: "propertyDocumentLink" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: DocumentValueViewComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-document-value-view', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-template #view>\n  <ax-default-value-view\n    [property]=\"property\"\n    [showVerificationLabel]=\"showVerificationLabel\"\n    [clickable]=\"false\"\n  ></ax-default-value-view>\n</ng-template>\n\n<ng-container *ngIf=\"clickable; else view\">\n  <a\n    class=\"c-card__property__link\"\n    [href]=\"property | propertyDocumentLink: (backendUrl$ | async)\"\n    [attr.download]=\"(property | propertyDisplayValue) + '.pdf'\"\n    (click)=\"downloadPdf(); $event.preventDefault()\"\n  >\n    <ng-container *ngTemplateOutlet=\"view\"></ng-container>\n  </a>\n</ng-container>\n", styles: [".property-value{font-size:16px;font-weight:700}\n"] }]
        }], ctorParameters: function () { return [{ type: i4.BehaviorSubject, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [BACKEND_URL]
                }] }, { type: i1.MatomoService }]; } });
//# sourceMappingURL=data:application/json;base64, 