'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index$1 = require('./index-457520a1.js');
const elementQuestionBase = require('./element-question-base-a6f39464.js');

const ElementCheckboxEditor = class {
    constructor(hostRef) {
        index$1.registerInstance(this, hostRef);
        this.label = {
            name: 'Checkbox',
            labelQuestion: 'Formulate your question',
            labelRequired: 'Required',
            labelMax: 'Max answers',
            labelOCOptionAdd: 'Add Option',
            labelOCOptionRemove: 'Delete Option',
            labelOCOther: 'Other',
            labelOCOtherAdd: 'Add "Other"',
            labelOCOtherRemove: 'Remove "Other"',
            labelOCImageUpload: 'Upload Image',
            labelOCImageDelete: 'Delete Image',
            labelOrientation: 'Oriëntation',
            labelOrientationH: 'Horizontal',
            labelOrientationV: 'Vertical',
            placeholderOptions: 'Option'
        };
        this.handleOther = (event) => {
            const target = event.target;
            this.handler.set('options', target.value);
            this.handler.set('other', event.detail, { emit: true });
        };
        this.transformMax = {
            path: 'validation',
            get: (value) => `max:${value}`,
            set: (value) => value.slice(4)
        };
    }
    prop(path, options = {}) {
        return this.handler.prop(path, Object.assign(Object.assign({}, options), { label: this.label }));
    }
    render() {
        const { labelOrientationH, labelOrientationV } = this.label;
        const { options } = this.value;
        return (index$1.h(elementQuestionBase.ElementQuestionBase, { question: this.prop('question', { localize: true }), required: this.prop('required') }, index$1.h("bce-option-creator", Object.assign({}, this.prop('options', { default: () => [], localize: true }), { "allow-other": true, label: this.label, other: this.handler.get('other'), onOther: this.handleOther })), index$1.h("bce-input", Object.assign({}, this.prop('max', { transform: this.transformMax }), { type: "number", min: options.length ? '1' : '0', max: '' + options.length })), index$1.h("bce-select", Object.assign({}, this.prop('orientation'), { type: "radio" }), index$1.h("bce-option", { value: "horizontal" }, labelOrientationH), index$1.h("bce-option", { value: "vertical" }, labelOrientationV)), index$1.h("slot", null)));
    }
};

exports.bce_element_checkbox_editor = ElementCheckboxEditor;
