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 { css, customElement, html, nothing, property, repeat, state } from '../../../../../external/lit/index.js';
import { umbExtensionsRegistry } from '../../../extension-registry/index.js';
import { UmbExtensionsElementAndApiInitializer } from '../../../../../libs/extension-api/index.js';
import { UmbLitElement } from '../../../lit-element/index.js';
import { UmbTextStyles } from '../../../style/index.js';
/**
 *
 * @param manifest
 * @returns
 */
function ExtensionApiArgsMethod(manifest) {
    return [{ meta: manifest.meta }];
}
let UmbPropertyActionMenuElement = class UmbPropertyActionMenuElement extends UmbLitElement {
    constructor() {
        super(...arguments);
        this._actions = [];
        this.#propertyEditorUiAlias = '';
    }
    set propertyEditorUiAlias(alias) {
        this.#propertyEditorUiAlias = alias;
        // TODO: Stop using string for 'propertyAction', we need to start using Const. [NL]
        new UmbExtensionsElementAndApiInitializer(this, umbExtensionsRegistry, 'propertyAction', ExtensionApiArgsMethod, (propertyAction) => propertyAction.forPropertyEditorUis.includes(alias), (actions) => (this._actions = actions), 'extensionsInitializer');
    }
    get propertyEditorUiAlias() {
        return this.#propertyEditorUiAlias;
    }
    #propertyEditorUiAlias;
    render() {
        if (!this._actions?.length)
            return nothing;
        return html `
			<uui-button
				id="popover-trigger"
				popovertarget="property-action-popover"
				data-mark="open-property-actions"
				label=${this.localize.term('actions_viewActionsFor')}
				compact>
				<uui-symbol-more id="more-symbol"></uui-symbol-more>
			</uui-button>
			<uui-popover-container id="property-action-popover">
				<umb-popover-layout>
					${repeat(this._actions, (action) => action.alias, (action) => action.component)}
				</umb-popover-layout>
			</uui-popover-container>
		`;
    }
    static { this.styles = [
        UmbTextStyles,
        css `
			:host {
				--uui-menu-item-flat-structure: 1;
			}

			#more-symbol {
				font-size: 1rem;
			}

			#popover-trigger {
				--uui-button-padding-top-factor: 0.5;
				--uui-button-padding-bottom-factor: 0.1;
				--uui-button-height: 18px;
				--uui-button-border-radius: 6px;
			}
		`,
    ]; }
};
__decorate([
    state()
], UmbPropertyActionMenuElement.prototype, "_actions", void 0);
__decorate([
    property()
], UmbPropertyActionMenuElement.prototype, "propertyEditorUiAlias", null);
UmbPropertyActionMenuElement = __decorate([
    customElement('umb-property-action-menu')
], UmbPropertyActionMenuElement);
export { UmbPropertyActionMenuElement };
