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_BLOCK_SINGLE_TYPE } from '../../constants.js';
import { html, customElement, property, state } from '../../../../../external/lit/index.js';
import { UmbLitElement } from '../../../../core/lit-element/index.js';
import { UMB_WORKSPACE_MODAL } from '../../../../core/workspace/index.js';
import { UmbModalRouteRegistrationController } from '../../../../core/router/index.js';
import { UmbChangeEvent } from '../../../../core/event/index.js';
// TODO: This is across packages, how should we go about getting just a single element from another package? like here we just need the `umb-input-block-type` element.
import '../../../block-type/index.js';
/**
 * @element umb-property-editor-ui-block-single-type-configuration
 */
let UmbPropertyEditorUIBlockSingleBlockConfigurationElement = class UmbPropertyEditorUIBlockSingleBlockConfigurationElement extends UmbLitElement {
    #blockTypeWorkspaceModalRegistration;
    constructor() {
        super();
        this.value = [];
        this.#blockTypeWorkspaceModalRegistration?.destroy();
        this.#blockTypeWorkspaceModalRegistration = new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
            .addAdditionalPath(UMB_BLOCK_SINGLE_TYPE)
            .onSetup(() => {
            return { data: { entityType: UMB_BLOCK_SINGLE_TYPE, preset: {} }, modal: { size: 'large' } };
        })
            .observeRouteBuilder((routeBuilder) => {
            const newpath = routeBuilder({});
            this._workspacePath = newpath;
        });
    }
    #onCreate(e) {
        const selectedElementType = e.detail.contentElementTypeKey;
        if (selectedElementType) {
            this.#blockTypeWorkspaceModalRegistration?.open({}, 'create/' + selectedElementType + '/null');
        }
    }
    #onChange(e) {
        e.stopPropagation();
        this.value = e.target.value;
        this.dispatchEvent(new UmbChangeEvent());
    }
    render() {
        return html `<umb-input-block-type
			.value=${this.value}
			.workspacePath=${this._workspacePath}
			@create=${this.#onCreate}
			@delete=${this.#onChange}
			@change=${this.#onChange}></umb-input-block-type>`;
    }
};
__decorate([
    property({ attribute: false })
], UmbPropertyEditorUIBlockSingleBlockConfigurationElement.prototype, "value", void 0);
__decorate([
    property({ type: Object, attribute: false })
], UmbPropertyEditorUIBlockSingleBlockConfigurationElement.prototype, "config", void 0);
__decorate([
    state()
], UmbPropertyEditorUIBlockSingleBlockConfigurationElement.prototype, "_workspacePath", void 0);
UmbPropertyEditorUIBlockSingleBlockConfigurationElement = __decorate([
    customElement('umb-property-editor-ui-block-single-type-configuration')
], UmbPropertyEditorUIBlockSingleBlockConfigurationElement);
export { UmbPropertyEditorUIBlockSingleBlockConfigurationElement };
export default UmbPropertyEditorUIBlockSingleBlockConfigurationElement;
