import { ReferenceField } from '@dvn/core/doldurma/src/fields/reference';
import { BaseField } from './BaseField';
import { DateField } from './fields/date';
import { MultipleChoiceField } from './fields/multiple-choice';
import { NumberField } from './fields/number';
import { RangeField } from './fields/range';
import { SectionHeaderField } from './fields/section-header';
import { SingleChoiceField } from './fields/single-choice';
import { SubFormField } from './fields/sub-form';
import { TextField } from './fields/text';
export function generateFieldModelFromRawData(fieldData) {
  if (!fieldData) {
    return undefined;
  }
  switch (fieldData.type) {
    case DateField.type:
      return Object.assign(Object.create(DateField.prototype), fieldData);
    case MultipleChoiceField.type:
      return Object.assign(Object.create(MultipleChoiceField.prototype), fieldData);
    case NumberField.type:
      return Object.assign(Object.create(NumberField.prototype), fieldData);
    case RangeField.type:
      return Object.assign(Object.create(RangeField.prototype), fieldData);
    case SectionHeaderField.type:
      return Object.assign(Object.create(SectionHeaderField.prototype), fieldData);
    case SingleChoiceField.type:
      return Object.assign(Object.create(SingleChoiceField.prototype), fieldData);
    case SubFormField.type:
      return Object.assign(Object.create(SubFormField.prototype), fieldData);
    case TextField.type:
      return Object.assign(Object.create(TextField.prototype), fieldData);
    case ReferenceField.type:
      return Object.assign(Object.create(ReferenceField.prototype), fieldData);
    default:
      return Object.assign(Object.create(BaseField.prototype), fieldData);
  }
}
