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_DOCUMENT_TYPE_ENTITY_TYPE } from '../entity.js';
import { UMB_EDIT_DOCUMENT_TYPE_WORKSPACE_PATH_PATTERN } from '../paths.js';
import { customElement, html, ifDefined, nothing, property, state } from '../../../../external/lit/index.js';
import { UmbLitElement } from '../../../core/lit-element/index.js';
import { UmbModalRouteRegistrationController } from '../../../core/router/index.js';
import { UMB_WORKSPACE_MODAL } from '../../../core/workspace/index.js';
let UmbDocumentTypePropertyTypeItemRefElement = class UmbDocumentTypePropertyTypeItemRefElement extends UmbLitElement {
    constructor() {
        super();
        this.readonly = false;
        this.standalone = false;
        this._editPath = '';
        new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
            .addUniquePaths(['unique'])
            .onSetup(() => {
            return { data: { entityType: UMB_DOCUMENT_TYPE_ENTITY_TYPE, preset: {} } };
        })
            .observeRouteBuilder((routeBuilder) => {
            this._editPath = routeBuilder({});
        });
    }
    #getHref() {
        if (!this.item?.unique)
            return;
        const path = UMB_EDIT_DOCUMENT_TYPE_WORKSPACE_PATH_PATTERN.generateLocal({ unique: this.item.documentType.unique });
        return `${this._editPath}/${path}`;
    }
    #getName() {
        const documentTypeName = this.item?.documentType.name ?? 'Unknown';
        return `Document Type: ${documentTypeName}`;
    }
    #getDetail() {
        const propertyTypeDetails = this.item?.name ? this.item.name + ' (' + this.item.alias + ')' : 'Unknown';
        return `Property Type: ${propertyTypeDetails}`;
    }
    render() {
        if (!this.item)
            return nothing;
        return html `
			<uui-ref-node
				name=${this.#getName()}
				detail=${this.#getDetail()}
				href=${ifDefined(this.#getHref())}
				?readonly=${this.readonly}
				?standalone=${this.standalone}>
				<slot name="actions" slot="actions"></slot>
				${this.#renderIcon()}
			</uui-ref-node>
		`;
    }
    #renderIcon() {
        if (!this.item?.documentType.icon)
            return nothing;
        return html `<umb-icon slot="icon" name=${this.item.documentType.icon}></umb-icon>`;
    }
};
__decorate([
    property({ type: Object })
], UmbDocumentTypePropertyTypeItemRefElement.prototype, "item", void 0);
__decorate([
    property({ type: Boolean })
], UmbDocumentTypePropertyTypeItemRefElement.prototype, "readonly", void 0);
__decorate([
    property({ type: Boolean })
], UmbDocumentTypePropertyTypeItemRefElement.prototype, "standalone", void 0);
__decorate([
    state()
], UmbDocumentTypePropertyTypeItemRefElement.prototype, "_editPath", void 0);
UmbDocumentTypePropertyTypeItemRefElement = __decorate([
    customElement('umb-document-type-property-type-item-ref')
], UmbDocumentTypePropertyTypeItemRefElement);
export { UmbDocumentTypePropertyTypeItemRefElement };
export { UmbDocumentTypePropertyTypeItemRefElement as element };
