import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy, Optional, Inject, Input, NgModule } from '@angular/core';
import { BASE_URL } from '@aztrix/sdk';
import { BehaviorSubject, ReplaySubject } from 'rxjs';
import { map } from 'rxjs/operators';
import * as i1 from '@aztrix/helpers';
import { HelperPipesModule } from '@aztrix/helpers';
import * as i2 from '@aztrix/components/avatar';
import { AvatarModule } from '@aztrix/components/avatar';
import * as i3 from '@aztrix/components/link';
import { LinkModule } from '@aztrix/components/link';
import * as i4 from '@angular/common';
import { CommonModule } from '@angular/common';
import { ImageSourceModule } from '@aztrix/components/image-source';
import { IconsModule } from '@aztrix/icons';

class ProfileThumbnailComponent {
    constructor(_baseUrl, _translate) {
        this._baseUrl = _baseUrl;
        this._translate = _translate;
        this.error$ = new BehaviorSubject(false);
        this.profile$ = new ReplaySubject(1);
        this.profileLink$ = this.profile$.pipe(map((profile) => this._baseUrl + '/profile/' + profile.id));
    }
    ngOnInit() {
        if (!this.profile) {
            this.error$.next(true);
        }
    }
    ngOnChanges(changes) {
        if (this.profile && changes.profile) {
            this.profile$.next(this.profile);
        }
        else {
            this.error$.next(true);
        }
    }
}
ProfileThumbnailComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ProfileThumbnailComponent, deps: [{ token: BASE_URL, optional: true }, { token: i1.TranslateService }], target: i0.ɵɵFactoryTarget.Component });
ProfileThumbnailComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: ProfileThumbnailComponent, selector: "ax-profile-thumbnail", inputs: { profile: "profile" }, usesOnChanges: true, ngImport: i0, template: "<a [axLink]=\"profileLink$ | async\" target=\"_blank\">\n  <div class=\"profile-container\">\n    <ax-avatar-by-profile [profile]=\"profile$ | async\"></ax-avatar-by-profile>\n    <p>{{ profile$ | async | displayName }}</p>\n  </div>\n</a>\n", styles: [":host{background-color:#fff;box-shadow:0 1px 5px #00000026;border-radius:10px}:host:hover{background-color:#fffc}a{padding:1rem;text-decoration:none;display:inline-block;height:100%}.profile-container{text-align:center}ax-avatar-by-profile{display:inline-block;max-width:120px}p{color:#000}\n"], dependencies: [{ kind: "component", type: i2.AvatarByProfileComponent, selector: "ax-avatar-by-profile", inputs: ["profile", "edit", "badge", "badgeColor", "border"], outputs: ["update"] }, { kind: "directive", type: i3.LinkDirective, selector: "a[axLink],area[axLink]", inputs: ["axLink"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i1.DisplayNamePipe, name: "displayName" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ProfileThumbnailComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-profile-thumbnail', changeDetection: ChangeDetectionStrategy.OnPush, template: "<a [axLink]=\"profileLink$ | async\" target=\"_blank\">\n  <div class=\"profile-container\">\n    <ax-avatar-by-profile [profile]=\"profile$ | async\"></ax-avatar-by-profile>\n    <p>{{ profile$ | async | displayName }}</p>\n  </div>\n</a>\n", styles: [":host{background-color:#fff;box-shadow:0 1px 5px #00000026;border-radius:10px}:host:hover{background-color:#fffc}a{padding:1rem;text-decoration:none;display:inline-block;height:100%}.profile-container{text-align:center}ax-avatar-by-profile{display:inline-block;max-width:120px}p{color:#000}\n"] }]
        }], ctorParameters: function () {
        return [{ type: undefined, decorators: [{
                        type: Optional
                    }, {
                        type: Inject,
                        args: [BASE_URL]
                    }] }, { type: i1.TranslateService }];
    }, propDecorators: { profile: [{
                type: Input
            }] } });

class ProfileThumbnailModule {
}
ProfileThumbnailModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ProfileThumbnailModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
ProfileThumbnailModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.5", ngImport: i0, type: ProfileThumbnailModule, declarations: [ProfileThumbnailComponent], imports: [CommonModule,
        AvatarModule,
        IconsModule,
        HelperPipesModule,
        ImageSourceModule,
        LinkModule], exports: [ProfileThumbnailComponent] });
ProfileThumbnailModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ProfileThumbnailModule, imports: [CommonModule,
        AvatarModule,
        IconsModule,
        HelperPipesModule,
        ImageSourceModule,
        LinkModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: ProfileThumbnailModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [ProfileThumbnailComponent],
                    imports: [
                        CommonModule,
                        AvatarModule,
                        IconsModule,
                        HelperPipesModule,
                        ImageSourceModule,
                        LinkModule,
                    ],
                    exports: [ProfileThumbnailComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { ProfileThumbnailComponent, ProfileThumbnailModule };
//# sourceMappingURL=aztrix-components-profile-thumbnail.mjs.map
//# sourceMappingURL=aztrix-components-profile-thumbnail.mjs.map
