/**
 * This is based on the AlIdentityIconComponent from @o3/design, in turn based on the
 * NameColoredSquareComponent from dunkirk project, etc, etc.
 *
 * @author Cristhian Rendón <crendon@alertlogic.com>
 * @author Gisler Garces <ggarces@alertlogic.com>
 * @author McNielsen <knielsen@alertlogic.com>
 *
 * @copyright Alert Logic, Inc 2019
 */
import { Input, Component } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
function AlIdentityIconComponent_div_1_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelementStart(1, "small", 7);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r2.name);
} }
function AlIdentityIconComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵelementStart(1, "span", 4);
    i0.ɵɵelementStart(2, "font", 5);
    i0.ɵɵelementStart(3, "span");
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, AlIdentityIconComponent_div_1_div_5_Template, 3, 1, "div", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", ctx_r0.classes);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", ctx_r0.initials, " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r0.withLegend === true);
} }
function AlIdentityIconComponent_div_2_div_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelementStart(1, "strong", 7);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r3 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r3.name, "");
} }
function AlIdentityIconComponent_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵelementStart(1, "div", 4);
    i0.ɵɵelementStart(2, "font", 9);
    i0.ɵɵelementStart(3, "span");
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(5, AlIdentityIconComponent_div_2_div_5_Template, 3, 1, "div", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", ctx_r1.classes);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1(" ", ctx_r1.initials, " ");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.withLegend === true);
} }
var AlIdentityIconComponent = /** @class */ (function () {
    function AlIdentityIconComponent() {
        /**
         *  @property Indicates whether the icon should be circular instead of the rectangular default
         */
        this.circular = false;
        /**
         * @property If true, the full name will be included after the initial icon.
         */
        this.withLegend = false;
        /**
         * @property display mode; can be 'big' or 'small'
         */
        this.display = "big";
        this.initials = "";
        this.classes = 'identity-icon color1';
        this.maxLengthInitials = 2;
    }
    AlIdentityIconComponent.prototype.ngOnChanges = function (changes) {
        if (changes.hasOwnProperty("name") && this.name) {
            var parts = this.name.split(" ");
            var classes = ['identity-icon', this.getColorClass(this.name)];
            this.initials = parts.map(function (part) { return part.trim().toUpperCase().charAt(0); }).join("");
            if (this.initials.length > this.maxLengthInitials) {
                this.initials = this.initials.substring(0, this.maxLengthInitials);
            }
            if (this.circular) {
                classes.push("circular");
            }
            this.classes = classes.join(" ");
        }
    };
    AlIdentityIconComponent.prototype.getColorClass = function (name) {
        var value = name.trim().toLowerCase().charCodeAt(0);
        if (value >= 97 && value <= 122) {
            return "color" + Math.floor((value - 97) / 2 + 1).toString();
        }
        return "color1";
    };
    /** @nocollapse */ AlIdentityIconComponent.ɵfac = function AlIdentityIconComponent_Factory(t) { return new (t || AlIdentityIconComponent)(); };
    /** @nocollapse */ AlIdentityIconComponent.ɵcmp = i0.ɵɵdefineComponent({ type: AlIdentityIconComponent, selectors: [["al-identity-icon"]], inputs: { name: "name", circular: "circular", withLegend: "withLegend", display: "display" }, features: [i0.ɵɵNgOnChangesFeature], decls: 3, vars: 2, consts: [["ng-class", "{linkable: false}", 1, "al-identity-icon"], ["class", "al-identity-icon-space", 4, "ngIf"], ["class", "colored-square-container-small", 4, "ngIf"], [1, "al-identity-icon-space"], [3, "ngClass"], [1, "colored-initials"], [4, "ngIf"], [1, "center-block"], [1, "colored-square-container-small"], [1, "colored-initials-small"]], template: function AlIdentityIconComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, AlIdentityIconComponent_div_1_Template, 6, 3, "div", 1);
            i0.ɵɵtemplate(2, AlIdentityIconComponent_div_2_Template, 6, 3, "div", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.display === "big");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.display === "small");
        } }, directives: [i1.NgIf, i1.NgClass], styles: [".al-identity-icon[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;flex-flow:column nowrap}.al-identity-icon[_ngcontent-%COMP%]   .al-identity-icon-space[_ngcontent-%COMP%]{display:flex}.al-identity-icon[_ngcontent-%COMP%]   .identity-icon[_ngcontent-%COMP%]{height:35px;width:35px;margin-right:3px;padding:0;text-align:center;display:flex;align-items:center;justify-content:center}.al-identity-icon[_ngcontent-%COMP%]   .identity-icon.circular[_ngcontent-%COMP%]{border-radius:50%}.al-identity-icon[_ngcontent-%COMP%]   .identity-icon-small[_ngcontent-%COMP%]{height:16px;width:16px;margin-right:3px;padding:0;text-align:center;display:flex;align-items:center;justify-content:center}.al-identity-icon[_ngcontent-%COMP%]   .identity-icon-small.circular[_ngcontent-%COMP%]{border-radius:50%}.al-identity-icon[_ngcontent-%COMP%]   .colored-initials-small[_ngcontent-%COMP%]{color:#fff;font-size:.7em}.al-identity-icon[_ngcontent-%COMP%]   .colored-initials[_ngcontent-%COMP%]{color:#fff;font-size:1.4em}.al-identity-icon[_ngcontent-%COMP%]   .colored-initials-selected[_ngcontent-%COMP%]{font-size:1.5em}.al-identity-icon[_ngcontent-%COMP%]   .color-selected[_ngcontent-%COMP%]{background-color:#fff}.al-identity-icon[_ngcontent-%COMP%]   .colored-square-container-small[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center}.al-identity-icon[_ngcontent-%COMP%]   .color1[_ngcontent-%COMP%]{background-color:#ff7f00}.al-identity-icon[_ngcontent-%COMP%]   .color2[_ngcontent-%COMP%]{background-color:#5498b5}.al-identity-icon[_ngcontent-%COMP%]   .color3[_ngcontent-%COMP%]{background-color:#8fc183}.al-identity-icon[_ngcontent-%COMP%]   .color4[_ngcontent-%COMP%]{background-color:#a8ccdb}.al-identity-icon[_ngcontent-%COMP%]   .color5[_ngcontent-%COMP%]{background-color:#f8bb2c}.al-identity-icon[_ngcontent-%COMP%]   .color6[_ngcontent-%COMP%]{background-color:#e20010}.al-identity-icon[_ngcontent-%COMP%]   .color7[_ngcontent-%COMP%]{background-color:#6c6c6c}.al-identity-icon[_ngcontent-%COMP%]   .color8[_ngcontent-%COMP%]{background-color:#8ebcd0}.al-identity-icon[_ngcontent-%COMP%]   .color9[_ngcontent-%COMP%]{background-color:#e53935}.al-identity-icon[_ngcontent-%COMP%]   .color10[_ngcontent-%COMP%]{background-color:#aed2a5}.al-identity-icon[_ngcontent-%COMP%]   .color11[_ngcontent-%COMP%]{background-color:#9f9f9f}.al-identity-icon[_ngcontent-%COMP%]   .color12[_ngcontent-%COMP%]{background-color:#9eacac}.al-identity-icon[_ngcontent-%COMP%]   .color13[_ngcontent-%COMP%]{background-color:#99f}.al-identity-icon.linkable[_ngcontent-%COMP%]{cursor:pointer;color:transparent}"] });
    return AlIdentityIconComponent;
}());
export { AlIdentityIconComponent };
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(AlIdentityIconComponent, [{
        type: Component,
        args: [{
                selector: 'al-identity-icon',
                templateUrl: './al-identity-icon.component.html',
                styleUrls: ['./al-identity-icon.component.scss']
            }]
    }], null, { name: [{
            type: Input
        }], circular: [{
            type: Input
        }], withLegend: [{
            type: Input
        }], display: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 