"use strict";

exports.__esModule = true;
exports.toFieldEdit = toFieldEdit;
exports.toNewFieldType = void 0;
// Reverse of the import detector's vocabulary: maps a schema field type
// (`PatternsFieldType`, uppercase) back to the import flow's `NewFieldType`. Only
// the types the field editor can produce need entries; anything else falls back
// to `text`.
const PATTERNS_TO_NEW_FIELD_TYPE = {
  SHORT_TEXT: 'text',
  LONG_TEXT: 'text',
  NUMBER: 'number',
  DATE: 'date',
  DATETIME: 'date',
  BOOLEAN: 'boolean',
  URL: 'url',
  IMAGE: 'image',
  VIDEO: 'video',
  DOCUMENT: 'document',
  AUDIO: 'audio'
};
const toNewFieldType = type => PATTERNS_TO_NEW_FIELD_TYPE[type] ?? 'text';

// Converts an edited field spec (the field editor's output) into the per-column
// new-field type + config the import flow stores via `setNewFieldConfig`.
exports.toNewFieldType = toNewFieldType;
function toFieldEdit(field) {
  const config = {
    ...(field.validation && {
      validation: field.validation
    }),
    ...(field.isPii && {
      isPii: true
    }),
    ...(field.helpText && {
      helpText: field.helpText
    })
  };
  return {
    fieldType: toNewFieldType(field.type),
    displayName: field.displayName,
    config: Object.keys(config).length > 0 ? config : undefined
  };
}
//# sourceMappingURL=fieldEdit.js.map