import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
import { DEFAULT_IMAGE_WIDTH, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH } from './constants';

/**
 * Calculate initial media single pixel width.
 * Make it fall between max width and min width
 * @param origWidth original width of image (media node width)
 * @param maxWidth default to akEditorDefaultLayoutWidth (760)
 * @param minWidth default to MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH (24)
 */
export var getMediaSingleInitialWidth = function getMediaSingleInitialWidth() {
  var origWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_IMAGE_WIDTH;
  var maxWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : akEditorDefaultLayoutWidth;
  var minWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH;
  return Math.max(Math.min(origWidth, maxWidth), minWidth);
};