'use strict';

var type = require('../../common/propsValues/type.js');
var logActionRequired = require('../../utilities/logActionRequired.js');
var control = require('../../common/propsValues/control.js');
var size = require('../../common/propsValues/size.js');

const deprecatedTypeMap = {
  [type.Type.PRIMARY]: control.ControlType.ACCENT,
  [type.Type.SECONDARY]: control.ControlType.ACCENT,
  [type.Type.LINK]: control.ControlType.ACCENT,
  [type.Type.PAY]: control.ControlType.POSITIVE,
  [type.Type.DANGER]: control.ControlType.NEGATIVE
};
const oldTypePriorityMap = {
  [type.Type.DANGER]: control.Priority.SECONDARY,
  [type.Type.LINK]: control.Priority.TERTIARY,
  [type.Type.SECONDARY]: control.Priority.SECONDARY
};
const deprecatedTypeMapMessage = {
  [type.Type.DANGER]: 'Type.NEGATIVE',
  [type.Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',
  [type.Type.PAY]: 'ControlType.POSITIVE',
  [type.Type.PRIMARY]: 'ControlType.ACCENT',
  [type.Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY'
};
const deprecatedTypes = Object.keys(deprecatedTypeMap);
const establishNewType = originalType => deprecatedTypeMap[originalType] || originalType;
const establishNewPriority = (originalPriority, originalType) => {
  const type = establishNewType(originalType);

  // The old SECONDARY and LINK types now map to priorities. If they're still using one of
  // these old types, ignore whatever priority they've passed and use this instead.
  if (oldTypePriorityMap[originalType]) {
    return oldTypePriorityMap[originalType];
  }
  // Only ControlType.ACCENT supports tertiary styles
  if (originalPriority === control.Priority.TERTIARY && type !== control.ControlType.ACCENT) {
    return control.Priority.SECONDARY;
  }
  return originalPriority;
};
const logDeprecationNotices = ({
  size: size$1,
  type
}) => {
  logActionRequired.logActionRequiredIf('Button has deprecated the `Size.EXTRA_SMALL` value for the `size` prop. Please use Size.SMALL instead.', size$1 === size.Size.EXTRA_SMALL);
  logActionRequired.logActionRequiredIf(`Button has deprecated the ${type} value for the \`type\` prop. Please update to ${deprecatedTypeMapMessage[type]}.`, deprecatedTypes.includes(type));
};

exports.establishNewPriority = establishNewPriority;
exports.establishNewType = establishNewType;
exports.logDeprecationNotices = logDeprecationNotices;
//# sourceMappingURL=legacyUtils.js.map
