/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, attachShadowTemplate, coerceNumber, coerceBoolean, FoundationProperty } from '@tylertech/forge-core';
import { AvatarAdapter } from './avatar-adapter';
import { AvatarFoundation } from './avatar-foundation';
import { AVATAR_CONSTANTS } from './avatar-constants';
import { BaseComponent } from '../core/base/base-component';
const template = '<template><div class=\"forge-avatar\" aria-hidden=\"true\" part=\"root\"><slot></slot></div></template>';
const styles = ':host{display:inline-block;contain:content}:host([hidden]){display:none}.forge-avatar{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-size:1.25rem;font-size:var(--forge-typography-title-font-size, 1.25rem);line-height:2rem;line-height:var(--forge-typography-title-line-height, 2rem);font-weight:400;font-weight:var(--forge-typography-title-font-weight,400);letter-spacing:.0125em;letter-spacing:var(--forge-typography-title-letter-spacing, .0125em);text-decoration:inherit;-webkit-text-decoration:var(--forge-typography-title-text-decoration,inherit);text-decoration:var(--forge-typography-title-text-decoration,inherit);text-transform:inherit;text-transform:var(--forge-typography-title-text-transform,inherit);font-size:1rem;font-size:var(--forge-avatar-font-size, 1rem);font-weight:400;font-weight:var(--forge-avatar-font-weight,400);background-color:none;background-color:var(--forge-avatar-theme-background,none);height:40px;height:var(--forge-avatar-size,40px);width:40px;width:var(--forge-avatar-size,40px);color:#fff;color:var(--forge-avatar-theme-on-background,#fff);border-radius:50%;border-radius:var(--forge-avatar-radius,50%);display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;background-position:center;background-repeat:no-repeat;background-size:cover;overflow:hidden;-webkit-transition:height .2s cubic-bezier(.4, 0, .2, 1),width .2s cubic-bezier(.4, 0, .2, 1);transition:height .2s cubic-bezier(.4, 0, .2, 1),width .2s cubic-bezier(.4, 0, .2, 1)}';
/**
 * The custom element class behind the `<forge-avatar>` element.
 *
 * @tag forge-avatar
 */
let AvatarComponent = class AvatarComponent extends BaseComponent {
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._foundation = new AvatarFoundation(new AvatarAdapter(this));
    }
    static get observedAttributes() {
        return [
            AVATAR_CONSTANTS.attributes.TEXT,
            AVATAR_CONSTANTS.attributes.LETTER_COUNT,
            AVATAR_CONSTANTS.attributes.IMAGE_URL,
            AVATAR_CONSTANTS.attributes.AUTO_COLOR
        ];
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case AVATAR_CONSTANTS.attributes.TEXT:
                this.text = newValue;
                break;
            case AVATAR_CONSTANTS.attributes.LETTER_COUNT:
                this.letterCount = coerceNumber(newValue);
                break;
            case AVATAR_CONSTANTS.attributes.IMAGE_URL:
                this.imageUrl = newValue;
                break;
            case AVATAR_CONSTANTS.attributes.AUTO_COLOR:
                this.autoColor = coerceBoolean(newValue);
                break;
        }
    }
};
__decorate([
    FoundationProperty()
], AvatarComponent.prototype, "text", void 0);
__decorate([
    FoundationProperty()
], AvatarComponent.prototype, "letterCount", void 0);
__decorate([
    FoundationProperty()
], AvatarComponent.prototype, "imageUrl", void 0);
__decorate([
    FoundationProperty()
], AvatarComponent.prototype, "autoColor", void 0);
AvatarComponent = __decorate([
    CustomElement({
        name: AVATAR_CONSTANTS.elementName
    })
], AvatarComponent);
export { AvatarComponent };
