function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

import ConfigProvider from '../config-provider';
import { preFormatDateValue } from './utils';
import Calendar from './calendar';
/* istanbul ignore next */

var transform = function transform(props, deprecated) {
  var type = props.type,
      onChange = props.onChange,
      base = props.base,
      disabledMonth = props.disabledMonth,
      disabledYear = props.disabledYear,
      others = _objectWithoutProperties(props, ["type", "onChange", "base", "disabledMonth", "disabledYear"]);

  var newProps = others;

  if ('type' in props) {
    deprecated('type', 'shape', 'Calendar');
    newProps.shape = type;

    if ('shape' in props) {
      newProps.shape = props.shape;
    }
  }

  if ('base' in props) {
    deprecated('base', 'defaultVisibleMonth', 'Calendar');

    var newDefaultVisibleMonth = function newDefaultVisibleMonth() {
      preFormatDateValue(base, 'YYYY-MM-DD');
    };

    if ('defaultVisibleMonth' in props) {
      newDefaultVisibleMonth = props.defaultVisibleMonth;
    }

    newProps.defaultVisibleMonth = newDefaultVisibleMonth;
  }

  if ('onChange' in props && typeof onChange === 'function') {
    deprecated('onChange', 'onSelect', 'Calendar');

    var newOnSelect = function newOnSelect(date) {
      onChange({
        mode: others.mode,
        value: date
      });

      if ('onSelect' in props) {
        props.onSelect(date);
      }
    };

    newProps.onSelect = newOnSelect;
  }

  if ('disabledMonth' in props && typeof disabledMonth === 'function') {
    deprecated('disabledMonth', 'disabledDate', 'Calendar');
  }

  if ('disabledYear' in props && typeof disabledYear === 'function') {
    deprecated('disabledYear', 'disabledDate', 'Calendar');
  }

  if ('yearCellRender' in props && typeof yearCellRender === 'function') {
    deprecated('yearCellRender', 'monthCellRender/dateCellRender', 'Calendar');
  }

  if ('language' in props) {
    deprecated('language', 'moment.locale', 'Calendar');
  }

  return newProps;
};

export default ConfigProvider.config(Calendar, {
  transform: transform
});