var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { UMB_CURRENT_USER_MODAL } from './modals/current-user/current-user-modal.token.js';
import { UMB_CURRENT_USER_CONTEXT } from './constants.js';
import { css, html, customElement, state } from '../../../external/lit/index.js';
import { umbOpenModal } from '../../core/modal/index.js';
import { UmbHeaderAppButtonElement } from '../../core/components/index.js';
let UmbCurrentUserHeaderAppElement = class UmbCurrentUserHeaderAppElement extends UmbHeaderAppButtonElement {
    #currentUserContext;
    constructor() {
        super();
        this.consumeContext(UMB_CURRENT_USER_CONTEXT, (instance) => {
            this.#currentUserContext = instance;
            this._observeCurrentUser();
        });
    }
    async _observeCurrentUser() {
        if (!this.#currentUserContext)
            return;
        this.observe(this.#currentUserContext.currentUser, (currentUser) => {
            this._currentUser = currentUser;
        }, 'umbCurrentUserObserver');
    }
    async #handleUserClick() {
        await umbOpenModal(this, UMB_CURRENT_USER_MODAL).catch(() => undefined);
    }
    render() {
        return html `
			<uui-button
				@click=${this.#handleUserClick}
				look="primary"
				label=${this.localize.term('visuallyHiddenTexts_profileOptions')}
				compact>
				<umb-user-avatar
					id="Avatar"
					.name=${this._currentUser?.name}
					.imgUrls=${this._currentUser?.avatarUrls || []}></umb-user-avatar>
			</uui-button>
		`;
    }
    static { this.styles = [
        ...UmbHeaderAppButtonElement.styles,
        css `
			uui-button {
				font-size: 14px;
			}
		`,
    ]; }
};
__decorate([
    state()
], UmbCurrentUserHeaderAppElement.prototype, "_currentUser", void 0);
UmbCurrentUserHeaderAppElement = __decorate([
    customElement('umb-current-user-header-app')
], UmbCurrentUserHeaderAppElement);
export { UmbCurrentUserHeaderAppElement };
export default UmbCurrentUserHeaderAppElement;
