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_EDIT_RELATION_TYPE_WORKSPACE_PATH_PATTERN } from '../../../paths.js';
import { UMB_COLLECTION_CONTEXT } from '../../../../../core/collection/index.js';
import { css, html, customElement, state } from '../../../../../../external/lit/index.js';
import { UmbTextStyles } from '../../../../../core/style/index.js';
import { UmbLitElement } from '../../../../../core/lit-element/index.js';
let UmbRelationTypeTableCollectionViewElement = class UmbRelationTypeTableCollectionViewElement extends UmbLitElement {
    #collectionContext;
    constructor() {
        super();
        this._tableConfig = {
            allowSelection: false,
        };
        this._tableColumns = [
            {
                name: 'Relation Type',
                alias: 'relationTypeName',
            },
        ];
        this._tableItems = [];
        this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
            this.#collectionContext = instance;
            this.#observeCollectionItems();
        });
    }
    #observeCollectionItems() {
        if (!this.#collectionContext)
            return;
        this.observe(this.#collectionContext.items, (items) => this.#createTableItems(items), 'umbCollectionItemsObserver');
    }
    #createTableItems(relationTypes) {
        this._tableItems = relationTypes.map((relationType) => {
            return {
                id: relationType.unique,
                icon: 'icon-trafic',
                data: [
                    {
                        columnAlias: 'relationTypeName',
                        value: html `<a
							href=${UMB_EDIT_RELATION_TYPE_WORKSPACE_PATH_PATTERN.generateAbsolute({
                            unique: relationType.unique,
                        })}
							>${relationType.name}</a
						>`,
                    },
                ],
            };
        });
    }
    render() {
        return html `
			<umb-table .config=${this._tableConfig} .columns=${this._tableColumns} .items=${this._tableItems}></umb-table>
		`;
    }
    static { this.styles = [
        UmbTextStyles,
        css `
			:host {
				display: flex;
				flex-direction: column;
			}
		`,
    ]; }
};
__decorate([
    state()
], UmbRelationTypeTableCollectionViewElement.prototype, "_tableConfig", void 0);
__decorate([
    state()
], UmbRelationTypeTableCollectionViewElement.prototype, "_tableColumns", void 0);
__decorate([
    state()
], UmbRelationTypeTableCollectionViewElement.prototype, "_tableItems", void 0);
UmbRelationTypeTableCollectionViewElement = __decorate([
    customElement('umb-relation-type-table-collection-view')
], UmbRelationTypeTableCollectionViewElement);
export { UmbRelationTypeTableCollectionViewElement };
export default UmbRelationTypeTableCollectionViewElement;
