'use strict';

const index$1 = require('./index-ce58ddc5.js');
const index = require('./index-7e3bc620.js');
const BaseField = require('./BaseField-d019ade6.js');

class MultipleChoiceFieldOption {
  constructor(label, value) {
    this.label = label;
    this.value = value;
  }
}
class MultipleChoiceField extends BaseField.BaseField {
  constructor(id, title, options, description, inputType = 'checkbox', placeholder) {
    super(id, 'multiple-choice');
    this.title = title;
    this.description = description;
    this.options = options;
    this.inputType = inputType;
    this.placeholder = placeholder;
  }
  showPreview() {
    this.preview = true;
    return this;
  }
  getOptionOfValue(value) {
    if (!this.optionsByValue) {
      this.optionsByValue = {};
      for (let i = 0; i < this.options.length; i += 1) {
        this.optionsByValue[this.options[i].value] = this.options[i];
      }
    }
    return this.optionsByValue[value] || { label: value, value };
  }
}
MultipleChoiceField.type = 'multiple-choice';

const render = (field, value, errors, disabled, onFieldChange, onFieldBlur) => index$1.h("dvn-field-input-multiple-choice", { disabled: disabled, errors: errors, field: field, onChange: (e) => onFieldChange(field, e.detail), onBlur: () => onFieldBlur(field), value: value });
// register 'multiple-choice' key for json form generations
index.registerField('multiple-choice', render);

exports.MultipleChoiceField = MultipleChoiceField;
exports.MultipleChoiceFieldOption = MultipleChoiceFieldOption;
