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 { UmbExtensionPickerDataSource } from '../picker-data-source/extension.picker-data-source.js';
import { html, customElement, property } from '../../../../external/lit/index.js';
import { UmbLitElement } from '../../lit-element/index.js';
import { UmbFormControlMixin } from '../../validation/index.js';
import { UmbChangeEvent } from '../../event/index.js';
let UmbInputExtensionElement = class UmbInputExtensionElement extends UmbFormControlMixin(UmbLitElement) {
    constructor() {
        super(...arguments);
        this.#dataSource = new UmbExtensionPickerDataSource(this);
        this.#dataSourceConfig = [];
        this.min = 0;
        this.max = Infinity;
        this.selection = [];
        this.readonly = false;
    }
    #dataSource;
    #dataSourceConfig;
    #allowedExtensionTypes;
    set allowedExtensionTypes(value) {
        this.#allowedExtensionTypes = value;
        this.#dataSourceConfig = value?.length ? [{ alias: 'allowedExtensionTypes', value }] : [];
    }
    get allowedExtensionTypes() {
        return this.#allowedExtensionTypes;
    }
    getFormElement() {
        return undefined;
    }
    #onChange(event) {
        event.stopPropagation();
        // TODO: import correct type for UmbInputEntityDataElement when exported
        const target = event.target;
        this.selection = target.selection;
        this.value = target.value;
        this.dispatchEvent(new UmbChangeEvent());
    }
    render() {
        return html `<umb-input-entity-data
			.dataSourceApi=${this.#dataSource}
			.dataSourceConfig=${this.#dataSourceConfig}
			.value=${this.value}
			.selection=${this.selection}
			.min=${this.min}
			.max=${this.max}
			?readonly=${this.readonly}
			@change=${this.#onChange}></umb-input-entity-data>`;
    }
};
__decorate([
    property({ type: Array, attribute: false })
], UmbInputExtensionElement.prototype, "allowedExtensionTypes", null);
__decorate([
    property({ type: Number })
], UmbInputExtensionElement.prototype, "min", void 0);
__decorate([
    property({ type: Number })
], UmbInputExtensionElement.prototype, "max", void 0);
__decorate([
    property({ type: Array })
], UmbInputExtensionElement.prototype, "selection", void 0);
__decorate([
    property({ type: Boolean, reflect: true })
], UmbInputExtensionElement.prototype, "readonly", void 0);
UmbInputExtensionElement = __decorate([
    customElement('umb-input-extension')
], UmbInputExtensionElement);
export { UmbInputExtensionElement };
