import { BaseField } from '../../BaseField';
export class MultipleChoiceFieldOption {
  constructor(label, value) {
    this.label = label;
    this.value = value;
  }
}
export class MultipleChoiceField extends 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';
