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, html, customElement, state, property, classMap } from '../../../../../external/lit/index.js';
import { UmbTreeItemElementBase } from '../../../../core/tree/index.js';
let UmbDocumentTreeItemElement = class UmbDocumentTreeItemElement extends UmbTreeItemElementBase {
    constructor() {
        super(...arguments);
        this._name = '';
        /**
         * @internal
         * Indicates whether the document is a draft, this is controlled internally but present as an attribute as it affects styling.
         */
        this._isDraft = false;
        // eslint-disable-next-line @typescript-eslint/naming-convention
        this._renderExpandSymbol = () => {
            // If this in the menu and it is a collection, then we will enforce the user to the Collection view instead of expanding.
            // `this._forceShowExpand` is equivalent to hasCollection for this element.
            if (this._isMenu && this._forceShowExpand) {
                return html `<umb-icon data-mark="open-collection" name="icon-list" style="font-size: 8px;"></umb-icon>`;
            }
            else {
                return undefined;
            }
        };
    }
    #api;
    set api(value) {
        this.#api = value;
        if (this.#api) {
            this.observe(this.#api.name, (name) => (this._name = name || ''));
            this.observe(this.#api.isDraft, (isDraft) => (this._isDraft = isDraft || false));
            this.observe(this.#api.hasCollection, (has) => {
                const oldValue = this._forceShowExpand;
                this._forceShowExpand = has;
                this.requestUpdate('_forceShowExpand', oldValue);
            });
            this.observe(this.#api.icon, (icon) => (this.#icon = icon || ''));
            this.observe(this.#api.flags, (flags) => (this._flags = flags || ''));
            // Observe noAccess from context and update base class property (_noAccess).
            // This enables access restriction behavior (click prevention) and styling from the base class.
            this.observe(this.#api.noAccess, (noAccess) => (this._noAccess = noAccess));
        }
        super.api = value;
    }
    get api() {
        return this.#api;
    }
    #icon;
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    _extractFlags(item) {
        // Empty on purpose and NOT calling super to prevent doing what the base does. [NL]
    }
    _getIconName() {
        return this.#icon;
    }
    renderLabel() {
        return html `<span id="label" slot="label" class=${classMap({ draft: this._isDraft, noAccess: this._noAccess })}>
			${this._name}
		</span> `;
    }
    static { this.styles = [
        ...UmbTreeItemElementBase.styles,
        css `
			:host([draft]) #label {
				opacity: 0.6;
			}
			:host([draft]) umb-icon {
				opacity: 0.6;
			}
		`,
    ]; }
};
__decorate([
    property({ type: Object, attribute: false })
], UmbDocumentTreeItemElement.prototype, "api", null);
__decorate([
    state()
], UmbDocumentTreeItemElement.prototype, "_name", void 0);
__decorate([
    property({ type: Boolean, reflect: true, attribute: 'draft' })
], UmbDocumentTreeItemElement.prototype, "_isDraft", void 0);
UmbDocumentTreeItemElement = __decorate([
    customElement('umb-document-tree-item')
], UmbDocumentTreeItemElement);
export { UmbDocumentTreeItemElement };
export default UmbDocumentTreeItemElement;
