import { h } from '@stencil/core';
const fieldTypeMap = new Map();
export function registerField(fieldType, inputGenerator) {
  fieldTypeMap.set(fieldType, inputGenerator);
}
export function generateField(field, value, errors = [], disabled, onFieldChange, onFieldBlur) {
  if (field.render) {
    return field.render(field, value, errors, disabled, onFieldChange, onFieldBlur);
  }
  if (field.customViewTag) {
    const Tag = field.customViewTag;
    return h(Tag, { disabled: disabled, field: field, errors: errors, onChange: onFieldChange, onBlur: onFieldBlur, value: value });
  }
  const generator = fieldTypeMap.get(field.type);
  if (generator) {
    return generator(field, value, errors, disabled, onFieldChange, onFieldBlur);
  }
  return null;
}
