import { r as registerInstance, h } from './index-d0047af2.js';
import { E as ElementQuestionBase } from './element-question-base-5ebd9dee.js';
var BceElementInputTemplate = /** @class */ (function () {
    function BceElementInputTemplate(hostRef) {
        var _this = this;
        registerInstance(this, hostRef);
        this.label = {
            name: 'Input',
            labelQuestion: 'Formulate your question',
            labelRequired: 'Required',
            labelMultiline: 'Multiline',
            labelMin: 'Min',
            labelMax: 'Max',
            labelHasAnswer: 'Answer',
            labelAnswer: '',
            placeholderAnswer: 'Formulate the correct answer'
        };
        // private handleInput(name: string, event: Event) {
        //   const input = event.target as any;
        //   if (!input) return;
        //
        //   const { value } = input;
        //   if (name === 'answer' && !value) this.hasAnswer = false;
        //   if (name === 'hasAnswer' && !value) this.answer = '';
        //   if (name === 'multiline') {
        //     this.hasAnswer = false;
        //     this.answer = '';
        //   }
        //
        //   event.cancelBubble = true;
        //   (this as any)[name] = value;
        //   this.value = this.updateValue({ [name]: value });
        //   this.el.dispatchEvent(new Event('input', { bubbles: true }));
        // }
        this.onAnswer = function (value) {
            if (!value)
                _this.handler.set('hasAnswer', false);
        };
        this.onHasAnswer = function (value) {
            if (!value)
                _this.handler.set('answer', '', { localize: true });
        };
        this.onMultiline = function (value) {
            _this.handler.set('hasAnswer', false);
            _this.handler.set('answer', '', { localize: true });
        };
    }
    BceElementInputTemplate.prototype.prop = function (path, options) {
        if (options === void 0) { options = {}; }
        return this.handler.prop(path, Object.assign(Object.assign({}, options), { label: this.label }));
    };
    BceElementInputTemplate.prototype.render = function () {
        var _a = this.value, hasAnswer = _a.hasAnswer, multiline = _a.multiline;
        return (h(ElementQuestionBase, { question: this.prop('question', { localize: true }), required: this.prop('required') }, h("bce-switch", Object.assign({}, this.prop('multiline', { on: this.onMultiline }))), h("bce-input", Object.assign({}, this.prop('min'), { type: "number" })), h("bce-input", Object.assign({}, this.prop('max'), { type: "number" })), h("bce-switch", Object.assign({}, this.prop('hasAnswer', { on: this.onHasAnswer }))), hasAnswer && (h("bce-input", Object.assign({}, this.prop('answer', { on: this.onAnswer, localize: true }), { type: multiline ? 'textarea' : 'text', validation: "required" }))), h("slot", null)));
    };
    return BceElementInputTemplate;
}());
export { BceElementInputTemplate as bce_element_input_editor };
