import { r as registerInstance, h, g as getElement } from './core-095fd691.js';
import { B as Block } from './block-89b88b6d.js';
import { l as linker } from './input-linker-2b74e80e.js';
import { E as ElementQuestionBase } from './element-question-base-5de5ce16.js';

const BceElementTableTemplate = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.metadata = {};
        this.optionIcon = Block.ICON_MAP['table'];
        this.question = '';
        this.required = false;
        this.columns = [];
        this.orientation = 'horizontal';
        this.maxRows = 0;
        this.labelQuestion = 'Formulate your question';
        this.labelRequired = 'Required';
        this.labelOCAddButton = 'Add';
        this.labelOCRemoveButton = 'Delete';
        this.labelOCOther = 'Other';
        this.labelOCImage = 'Image';
        this.labelOrientation = 'Oriëntation';
        this.labelOrientationH = 'Horizontal';
        this.labelOrientationV = 'Vertical';
        this.labelMaxRows = 'Max row count';
        this.placeholderColumns = 'Column';
        this._link = linker(this, this.handleInput);
        this._question = this._link('question');
        this._required = this._link('required');
        this._columns = this._link('columns');
        this._orientation = this._link('orientation');
        this._maxRows = this._link('maxRows');
    }
    handleInput(name, event) {
        const input = event.target;
        if (!input)
            return;
        event.cancelBubble = true;
        this[name] = input.value;
        this.value = this.updateValue({ [name]: input.value });
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    updateValue(part = {}) {
        const current = {
            question: this.question,
            required: this.required,
            columns: this.columns,
            orientation: this.orientation,
            maxRows: this.maxRows,
            metadata: Object.assign({}, this.metadata)
        };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        const columns = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage }, this._columns);
        return (h(ElementQuestionBase, { question: this._question, required: this._required }, h("bce-option-creator", Object.assign({}, columns)), h("bce-input", Object.assign({ type: "radio" }, this._orientation), h("bce-option", { value: "horizontal" }, this.labelOrientationH), h("bce-option", { value: "vertical" }, this.labelOrientationV)), h("bce-input", Object.assign({ type: "number" }, this._maxRows))));
    }
    get el() { return getElement(this); }
};

export { BceElementTableTemplate as bce_element_table_template };
