import { Component, Input } from '@angular/core';
import { AvatarType } from '../avatar-type';
import { BadgeIconType } from '../badge-icon-type';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@aztrix/icons";
import * as i3 from "@aztrix/components/image-source";
import * as i4 from "@aztrix/components/property-published-button";
import * as i5 from "../badge-icon/badge-icon.component";
export class AvatarComponent {
    constructor() {
        this.source = null;
        this.type = AvatarType.INDIVIDUAL;
        this.iconColor = 'avatar-bg';
        this.border = true;
        this.published = false;
        this.fallback = this._fallbackAvatar(this.source, this.type);
        // eslint-disable-next-line @typescript-eslint/naming-convention
        this.AvatarType = AvatarType;
    }
    ngOnChanges(changes) {
        if (changes.source && this.source) {
            this._source = this._sourceAvatar(this.source);
        }
        if (changes.source || changes.type) {
            this.fallback = this._fallbackAvatar(this.source, this.type);
        }
    }
    _fallbackAvatar(source, type) {
        switch (type) {
            case AvatarType.ORGANISATION:
                return `assets/images/avatar/default/default_avatar_organisation${source ? '' : '_placeholder'}.png`;
            case AvatarType.GROUP:
                return `assets/images/avatar/default/default_avatar_group${source ? '' : '_placeholder'}.png`;
            case AvatarType.PROPOSAL:
                return `assets/images/avatar/default/default_avatar_proposal${source ? '' : '_placeholder'}.png`;
            case AvatarType.PAGE:
                return `assets/images/avatar/default/default_avatar_page${source ? '' : '_placeholder'}.png`;
            default:
                return `assets/images/avatar/default/default_avatar_individual${source ? '' : '_placeholder'}.png`;
        }
    }
    _sourceAvatar(source) {
        return source.includes('data:image') ? source : this._staticFilePath(source);
    }
    _staticFilePath(source) {
        return this.type === AvatarType.ALIST
            ? `staticFiles/alistFiles/${source}`
            : `staticFiles/avatars/${source}`;
    }
}
AvatarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
AvatarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.5", type: AvatarComponent, selector: "ax-avatar", inputs: { source: "source", type: "type", icon: "icon", iconColor: "iconColor", badge: "badge", badgeColor: "badgeColor", border: "border", published: "published" }, usesOnChanges: true, ngImport: i0, template: "<!-- image -->\n<ax-image-source\n  *ngIf=\"!icon\"\n  [border]=\"border\"\n  [source]=\"_source\"\n  [fallbackSource]=\"fallback\"\n  [round]=\"type === AvatarType.INDIVIDUAL || type === AvatarType.ALIST\"\n  [rounded]=\"type === AvatarType.GROUP\"\n></ax-image-source>\n\n<!-- icon -->\n<div *ngIf=\"icon\" class=\"avatar\" [ngClass]=\"[iconColor, type | lowercase]\">\n  <ax-icon class=\"icon avatar-icon\" [name]=\"icon\"></ax-icon>\n</div>\n\n<!-- badge -->\n<div class=\"avatar-badge\" *ngIf=\"badge && badgeColor\">\n  <ax-badge-icon [type]=\"badge\" [color]=\"badgeColor\"></ax-badge-icon>\n</div>\n\n<ax-property-published-button *ngIf=\"published\"></ax-property-published-button>\n", styles: [":host{position:relative;display:flex;width:100%;height:100%}:host ::ng-deep ax-property-published-button{right:23px;top:0;background-color:transparent}@media only screen and (min-width: 600px){:host ::ng-deep ax-property-published-button{right:42px;top:-9px}}.avatar{width:100%;height:100%;border:1px solid #bdc3c9;background-color:#a7a8ac;text-align:center;font-size:inherit;color:#fff}.avatar.individual{border-radius:50%}.avatar.group{border-radius:10px}.avatar.organisation{border-radius:0}.avatar.facebook{background-color:#425a99}.avatar.twitter{background-color:#71aee9}.avatar.google{background-color:#5789ee}.avatar.microsoft{background-color:#66a5ee}.avatar.yahoo{background-color:#9871d8}.avatar.avatar-bg--green{background-color:var(--primary-color-500)}.avatar-badge{display:block;min-width:18px;min-height:18px;position:absolute;bottom:-2px;right:-2px}.avatar-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;width:50%;height:50%}.avatar-bg{background-color:#a7a8ac}.avatar-bg--facebook{background-color:#425a99}.avatar-bg--twitter{background-color:#71aee9}.avatar-bg--google{background-color:#5789ee}.avatar-bg--microsoft{background-color:#66a5ee}.avatar-bg--yahoo{background-color:#9871d8}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.IconComponent, selector: "ax-icon", inputs: ["name", "inline"] }, { kind: "component", type: i3.ImageSourceComponent, selector: "ax-image-source", inputs: ["source", "fallbackSource", "actualSize", "alt", "safe", "round", "rounded", "border"] }, { kind: "component", type: i4.PropertyPublishedButtonComponent, selector: "ax-property-published-button" }, { kind: "component", type: i5.BadgeIconComponent, selector: "ax-badge-icon", inputs: ["type", "color"] }, { kind: "pipe", type: i1.LowerCasePipe, name: "lowercase" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AvatarComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-avatar', template: "<!-- image -->\n<ax-image-source\n  *ngIf=\"!icon\"\n  [border]=\"border\"\n  [source]=\"_source\"\n  [fallbackSource]=\"fallback\"\n  [round]=\"type === AvatarType.INDIVIDUAL || type === AvatarType.ALIST\"\n  [rounded]=\"type === AvatarType.GROUP\"\n></ax-image-source>\n\n<!-- icon -->\n<div *ngIf=\"icon\" class=\"avatar\" [ngClass]=\"[iconColor, type | lowercase]\">\n  <ax-icon class=\"icon avatar-icon\" [name]=\"icon\"></ax-icon>\n</div>\n\n<!-- badge -->\n<div class=\"avatar-badge\" *ngIf=\"badge && badgeColor\">\n  <ax-badge-icon [type]=\"badge\" [color]=\"badgeColor\"></ax-badge-icon>\n</div>\n\n<ax-property-published-button *ngIf=\"published\"></ax-property-published-button>\n", styles: [":host{position:relative;display:flex;width:100%;height:100%}:host ::ng-deep ax-property-published-button{right:23px;top:0;background-color:transparent}@media only screen and (min-width: 600px){:host ::ng-deep ax-property-published-button{right:42px;top:-9px}}.avatar{width:100%;height:100%;border:1px solid #bdc3c9;background-color:#a7a8ac;text-align:center;font-size:inherit;color:#fff}.avatar.individual{border-radius:50%}.avatar.group{border-radius:10px}.avatar.organisation{border-radius:0}.avatar.facebook{background-color:#425a99}.avatar.twitter{background-color:#71aee9}.avatar.google{background-color:#5789ee}.avatar.microsoft{background-color:#66a5ee}.avatar.yahoo{background-color:#9871d8}.avatar.avatar-bg--green{background-color:var(--primary-color-500)}.avatar-badge{display:block;min-width:18px;min-height:18px;position:absolute;bottom:-2px;right:-2px}.avatar-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;width:50%;height:50%}.avatar-bg{background-color:#a7a8ac}.avatar-bg--facebook{background-color:#425a99}.avatar-bg--twitter{background-color:#71aee9}.avatar-bg--google{background-color:#5789ee}.avatar-bg--microsoft{background-color:#66a5ee}.avatar-bg--yahoo{background-color:#9871d8}\n"] }]
        }], propDecorators: { source: [{
                type: Input
            }], type: [{
                type: Input
            }], icon: [{
                type: Input
            }], iconColor: [{
                type: Input
            }], badge: [{
                type: Input
            }], badgeColor: [{
                type: Input
            }], border: [{
                type: Input
            }], published: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 