import { h } from './index-55faf181.js';
import { r as registerField } from './index-403e215e.js';
import { B as BaseField } from './BaseField-461b6d0c.js';

class MultipleChoiceFieldOption {
  constructor(label, value) {
    this.label = label;
    this.value = value;
  }
}
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';

const render$1 = (field, value, errors, disabled, onFieldChange, onFieldBlur) => 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
registerField('multiple-choice', render$1);

class SingleChoiceFieldOption {
  constructor(label, value, tint, description) {
    this.label = label;
    this.value = value;
    this.tint = tint;
    this.description = description;
  }
}
class SingleChoiceField extends BaseField {
  constructor(id, title, options, description, inputType = 'radioButton', placeholder) {
    super(id, 'single-choice');
    this.title = title;
    this.options = options;
    this.inputType = inputType;
    this.description = description;
    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 };
  }
  setOptions(options) {
    this.options = options;
    return this;
  }
  setDataProvider(dataProvider) {
    this.dataProvider = dataProvider;
    return this;
  }
  setDataAdapter(dataAdapter) {
    this.dataAdapter = dataAdapter;
    return this;
  }
}
SingleChoiceField.type = 'single-choice';

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

export { MultipleChoiceField as M, SingleChoiceField as S, SingleChoiceFieldOption as a, MultipleChoiceFieldOption as b };
