import { Component, Input } from '@angular/core';
import { UrlTransformerService } from '@aztrix/helpers';
import { AvatarType } from '../avatar-type';
import { BadgeIconType } from '../badge-icon-type';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/helpers";
import * as i2 from "@angular/common";
import * as i3 from "@aztrix/icons";
import * as i4 from "@aztrix/components/image-source";
import * as i5 from "@aztrix/components/property-published-button";
import * as i6 from "../badge-icon/badge-icon.component";
export class AvatarComponent {
    constructor(_urlTransformer) {
        this._urlTransformer = _urlTransformer;
        this.source = null;
        this.type = AvatarType.INDIVIDUAL;
        this.iconColor = 'avatar-bg';
        this.border = true;
        this.round = true;
        this.rounded = false;
        this.published = false;
        this.fallbackIcon = this._fallbackIcon(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 (!this.source) {
            this._source = null;
        }
        if (changes.source || changes.type) {
            this.fallbackIcon = this._fallbackIcon(this.type);
        }
    }
    _fallbackIcon(type) {
        switch (type) {
            case AvatarType.ORGANISATION:
                return 'factory';
            case AvatarType.GROUP:
                return 'account-group';
            case AvatarType.PROPOSAL:
                return 'file-document-edit';
            case AvatarType.PAGE:
                return 'card-text';
            default:
                return 'account';
        }
    }
    _sourceAvatar(source) {
        return source.includes('data:image')
            ? source
            : this._urlTransformer.transformUrl(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: [{ token: i1.UrlTransformerService }], 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", round: "round", rounded: "rounded", published: "published" }, usesOnChanges: true, ngImport: i0, template: "<!-- image -->\n<ax-image-source\n  *ngIf=\"!icon\"\n  [border]=\"border\"\n  [source]=\"_source\"\n  [round]=\"round\"\n  [rounded]=\"rounded\"\n>\n  <div\n    class=\"placeholder\"\n    [ngClass]=\"{border: border}\"\n    [style.border-radius]=\"round || rounded ? (round ? '50%' : '10px') : undefined\"\n  >\n    <ax-icon class=\"placeholder-icon\" [name]=\"fallbackIcon\"></ax-icon>\n  </div>\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:3px solid #ebebeb;background-color:var(--primary-color-400);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:#1877f2}.avatar.twitter{background-color:#000}.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)}.placeholder{display:flex;align-items:center;justify-content:center;width:100%;height:100%;color:#fff9;background-color:var(--primary-color-400)}.placeholder.border{border:3px solid #ebebeb}.placeholder .placeholder-icon{width:50%;height:50%}.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:#1877f2}.avatar-bg--twitter{background-color:#000}.avatar-bg--google{background-color:#5789ee}.avatar-bg--microsoft{background-color:#66a5ee}.avatar-bg--yahoo{background-color:#9871d8}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.IconComponent, selector: "ax-icon", inputs: ["name", "inline"] }, { kind: "component", type: i4.ImageSourceComponent, selector: "ax-image-source", inputs: ["source", "fallbackSource", "actualSize", "alt", "round", "rounded", "border"] }, { kind: "component", type: i5.PropertyPublishedButtonComponent, selector: "ax-property-published-button" }, { kind: "component", type: i6.BadgeIconComponent, selector: "ax-badge-icon", inputs: ["type", "color"] }, { kind: "pipe", type: i2.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  [round]=\"round\"\n  [rounded]=\"rounded\"\n>\n  <div\n    class=\"placeholder\"\n    [ngClass]=\"{border: border}\"\n    [style.border-radius]=\"round || rounded ? (round ? '50%' : '10px') : undefined\"\n  >\n    <ax-icon class=\"placeholder-icon\" [name]=\"fallbackIcon\"></ax-icon>\n  </div>\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:3px solid #ebebeb;background-color:var(--primary-color-400);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:#1877f2}.avatar.twitter{background-color:#000}.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)}.placeholder{display:flex;align-items:center;justify-content:center;width:100%;height:100%;color:#fff9;background-color:var(--primary-color-400)}.placeholder.border{border:3px solid #ebebeb}.placeholder .placeholder-icon{width:50%;height:50%}.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:#1877f2}.avatar-bg--twitter{background-color:#000}.avatar-bg--google{background-color:#5789ee}.avatar-bg--microsoft{background-color:#66a5ee}.avatar-bg--yahoo{background-color:#9871d8}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.UrlTransformerService }]; }, propDecorators: { source: [{
                type: Input
            }], type: [{
                type: Input
            }], icon: [{
                type: Input
            }], iconColor: [{
                type: Input
            }], badge: [{
                type: Input
            }], badgeColor: [{
                type: Input
            }], border: [{
                type: Input
            }], round: [{
                type: Input
            }], rounded: [{
                type: Input
            }], published: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 