import { NgIf } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject, Input } from '@angular/core';
import { tuiIsString } from '@taiga-ui/cdk/utils/miscellaneous';
import { tuiAppearanceOptionsProvider, TuiWithAppearance, } from '@taiga-ui/core/directives/appearance';
import { TuiIcons } from '@taiga-ui/core/directives/icons';
import { TUI_AVATAR_OPTIONS } from './avatar.options';
import * as i0 from "@angular/core";
import * as i1 from "@taiga-ui/core/directives/appearance";
import * as i2 from "@taiga-ui/core/directives/icons";
class TuiAvatar {
    constructor() {
        this.options = inject(TUI_AVATAR_OPTIONS);
        this.size = this.options.size;
        this.round = this.options.round;
    }
    get value() {
        return this.src || '';
    }
    get svg() {
        return tuiIsString(this.value) && this.value.endsWith('.svg');
    }
    get type() {
        if (this.value && !tuiIsString(this.value)) {
            return 'img';
        }
        if (this.value.startsWith('@tui.')) {
            return 'icon';
        }
        if (this.value.length > 0 && this.value.length < 3) {
            return 'text';
        }
        return this.value.length ? 'img' : 'content';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TuiAvatar, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: TuiAvatar, isStandalone: true, selector: "tui-avatar,button[tuiAvatar],a[tuiAvatar]", inputs: { size: "size", round: "round", src: "src" }, host: { properties: { "attr.data-size": "size", "attr.data-type": "type", "class._round": "round", "class._svg": "svg" } }, providers: [tuiAppearanceOptionsProvider(TUI_AVATAR_OPTIONS)], hostDirectives: [{ directive: i1.TuiWithAppearance }, { directive: i2.TuiIcons, inputs: ["iconStart", "src"] }], ngImport: i0, template: "<img\n    *ngIf=\"type === 'img'\"\n    alt=\"\"\n    loading=\"lazy\"\n    [src]=\"value\"\n/>\n<ng-container *ngIf=\"type === 'text'\">{{ value }}</ng-container>\n<ng-content />\n", styles: [":host{--t-size: 3.5rem;--t-radius: .75rem;position:relative;display:inline-flex;flex-shrink:0;inline-size:var(--t-size);block-size:var(--t-size);align-items:center;justify-content:center;overflow:hidden;white-space:nowrap;border-radius:var(--t-radius);border:none;background:var(--tui-background-neutral-1);color:var(--tui-text-secondary);vertical-align:middle;box-sizing:border-box;padding:.25rem;opacity:.999}:host[data-size=xs]{--t-size: var(--tui-height-xs);--t-radius: .5rem;font:var(--tui-font-text-xs);font-weight:700}:host[data-size=xs][data-type=content]{font:var(--tui-font-text-m);font-size:.5625rem}:host[data-size=s]{--t-size: var(--tui-height-s);--t-radius: .5rem;font:var(--tui-font-text-s);font-weight:700}:host[data-size=s][data-type=content]{font:var(--tui-font-text-xs);font-weight:700}:host[data-size=m]{--t-size: calc(var(--tui-height-m) - .25rem);--t-radius: .75rem;font:var(--tui-font-text-l);font-weight:700}:host[data-size=m][data-type=content]{font:var(--tui-font-text-m);font-weight:700}:host[data-size=l]{--t-size: var(--tui-height-l);--t-radius: .75rem;font:var(--tui-font-heading-5)}:host[data-size=l][data-type=content]{font:var(--tui-font-text-l);font-weight:700}:host[data-size=xl]{--t-size: 5rem;--t-radius: .75rem;font:var(--tui-font-heading-3)}:host[data-size=xl][data-type=content]{font:var(--tui-font-heading-4)}:host[data-size=xxl]{--t-size: 6rem;--t-radius: 1rem;font:var(--tui-font-heading-3)}:host[data-size=xxl][data-type=content]{font:var(--tui-font-heading-3)}:host[data-size=xxxl]{--t-size: 8rem;--t-radius: 1.25rem;font:var(--tui-font-heading-2)}:host[data-size=xxxl][data-type=content]{font:var(--tui-font-heading-3)}:host[data-type]:before{display:none}:host:not([data-type=icon]):before{-webkit-mask:none;mask:none}:host[data-type=img]:not(._svg){background:transparent}:host[data-type=icon]:before{position:absolute;top:0;left:0;inline-size:100%;block-size:100%;content:\"\";display:block;font-size:calc(var(--t-size) * .6);-webkit-mask-size:1em;mask-size:1em}:host._round{--t-radius: calc(var(--t-size) / 2)}:host ::ng-deep img,:host ::ng-deep picture,:host ::ng-deep video{position:absolute;top:0;left:0;inline-size:100%;block-size:100%;object-fit:cover;box-sizing:border-box;border-radius:inherit}:host._svg img{padding:20%;object-fit:contain;border-radius:unset}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
export { TuiAvatar };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TuiAvatar, decorators: [{
            type: Component,
            args: [{ standalone: true, selector: 'tui-avatar,button[tuiAvatar],a[tuiAvatar]', imports: [NgIf], changeDetection: ChangeDetectionStrategy.OnPush, providers: [tuiAppearanceOptionsProvider(TUI_AVATAR_OPTIONS)], hostDirectives: [
                        TuiWithAppearance,
                        {
                            directive: TuiIcons,
                            inputs: ['iconStart: src'],
                        },
                    ], host: {
                        '[attr.data-size]': 'size',
                        '[attr.data-type]': 'type',
                        '[class._round]': 'round',
                        '[class._svg]': 'svg',
                    }, template: "<img\n    *ngIf=\"type === 'img'\"\n    alt=\"\"\n    loading=\"lazy\"\n    [src]=\"value\"\n/>\n<ng-container *ngIf=\"type === 'text'\">{{ value }}</ng-container>\n<ng-content />\n", styles: [":host{--t-size: 3.5rem;--t-radius: .75rem;position:relative;display:inline-flex;flex-shrink:0;inline-size:var(--t-size);block-size:var(--t-size);align-items:center;justify-content:center;overflow:hidden;white-space:nowrap;border-radius:var(--t-radius);border:none;background:var(--tui-background-neutral-1);color:var(--tui-text-secondary);vertical-align:middle;box-sizing:border-box;padding:.25rem;opacity:.999}:host[data-size=xs]{--t-size: var(--tui-height-xs);--t-radius: .5rem;font:var(--tui-font-text-xs);font-weight:700}:host[data-size=xs][data-type=content]{font:var(--tui-font-text-m);font-size:.5625rem}:host[data-size=s]{--t-size: var(--tui-height-s);--t-radius: .5rem;font:var(--tui-font-text-s);font-weight:700}:host[data-size=s][data-type=content]{font:var(--tui-font-text-xs);font-weight:700}:host[data-size=m]{--t-size: calc(var(--tui-height-m) - .25rem);--t-radius: .75rem;font:var(--tui-font-text-l);font-weight:700}:host[data-size=m][data-type=content]{font:var(--tui-font-text-m);font-weight:700}:host[data-size=l]{--t-size: var(--tui-height-l);--t-radius: .75rem;font:var(--tui-font-heading-5)}:host[data-size=l][data-type=content]{font:var(--tui-font-text-l);font-weight:700}:host[data-size=xl]{--t-size: 5rem;--t-radius: .75rem;font:var(--tui-font-heading-3)}:host[data-size=xl][data-type=content]{font:var(--tui-font-heading-4)}:host[data-size=xxl]{--t-size: 6rem;--t-radius: 1rem;font:var(--tui-font-heading-3)}:host[data-size=xxl][data-type=content]{font:var(--tui-font-heading-3)}:host[data-size=xxxl]{--t-size: 8rem;--t-radius: 1.25rem;font:var(--tui-font-heading-2)}:host[data-size=xxxl][data-type=content]{font:var(--tui-font-heading-3)}:host[data-type]:before{display:none}:host:not([data-type=icon]):before{-webkit-mask:none;mask:none}:host[data-type=img]:not(._svg){background:transparent}:host[data-type=icon]:before{position:absolute;top:0;left:0;inline-size:100%;block-size:100%;content:\"\";display:block;font-size:calc(var(--t-size) * .6);-webkit-mask-size:1em;mask-size:1em}:host._round{--t-radius: calc(var(--t-size) / 2)}:host ::ng-deep img,:host ::ng-deep picture,:host ::ng-deep video{position:absolute;top:0;left:0;inline-size:100%;block-size:100%;object-fit:cover;box-sizing:border-box;border-radius:inherit}:host._svg img{padding:20%;object-fit:contain;border-radius:unset}\n"] }]
        }], propDecorators: { size: [{
                type: Input
            }], round: [{
                type: Input
            }], src: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 