'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _moment = require('moment');

var _moment2 = _interopRequireDefault(_moment);

var _Button = require('../common/Button');

var _Button2 = _interopRequireDefault(_Button);

var _utils = require('../common/utils');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var Footer = function Footer(_ref) {
    var defaultValue = _ref.defaultValue,
        _ref$value = _ref.value,
        value = _ref$value === undefined ? defaultValue : _ref$value,
        translations = _ref.translations,
        style = _ref.style,
        onChange = _ref.onChange;

    var restStyle = (0, _utils.omit)(style, 'now', 'mode', 'ok');

    return _react2.default.createElement(
        'div',
        { className: 'date-footer', style: restStyle },
        _react2.default.createElement(
            _Button2.default,
            {
                isDisabled: isToday(value),
                style: style.now,
                onClick: isToday(value) ? function () {} : function () {
                    onChange(today(value || defaultValue));
                }
            },
            translations.today
        )
    );
};

function today(value) {
    return (0, _moment2.default)().locale(value.locale()).utcOffset(value.utcOffset());
}

function isToday(value) {
    return (0, _moment2.default)().isSame(value, 'd');
}

Footer.propTypes = {
    value: _react.PropTypes.object,
    defaultValue: _react.PropTypes.object.isRequired,
    translations: _react.PropTypes.object.isRequired,
    onChange: _react.PropTypes.func.isRequired
};

exports.default = Footer;
//# sourceMappingURL=Footer.js.map