import { r as registerInstance, h } from './index-b13326fc.js';
import { E as ElementQuestionBase } from './element-question-base-275076e1.js';
var BceElementInputTemplate = /** @class */ (function () {
    function BceElementInputTemplate(hostRef) {
        var _this = this;
        registerInstance(this, hostRef);
        // 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({}, options));
    };
    BceElementInputTemplate.prototype.render = function () {
        var _a = this.value, hasAnswer = _a.hasAnswer, multiline = _a.multiline;
        return (h(ElementQuestionBase, { t: this.t, question: this.prop('question', { localize: true }), required: this.prop('required') }, h("bce-switch", Object.assign({}, this.prop('multiline', { on: this.onMultiline }), { label: this.t('me-element-input-multiline') })), h("bce-input", Object.assign({}, this.prop('min'), { label: this.t('min'), type: "number" })), h("bce-input", Object.assign({}, this.prop('max'), { label: this.t('max'), type: "number" })), h("bce-switch", Object.assign({}, this.prop('hasAnswer', { on: this.onHasAnswer }), { label: this.t('answer') })), 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 };
