'use strict';

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

var _math = require('./math.js');

var _math2 = _interopRequireDefault(_math);

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

var _ol_CenterConstraint_ = {};

/**
 * @param {ol.Extent} extent Extent.
 * @return {ol.CenterConstraintType} The constraint.
 */
_ol_CenterConstraint_.createExtent = function (extent) {
  return (
    /**
     * @param {ol.Coordinate|undefined} center Center.
     * @return {ol.Coordinate|undefined} Center.
     */
    function (center) {
      if (center) {
        return [_math2.default.clamp(center[0], extent[0], extent[2]), _math2.default.clamp(center[1], extent[1], extent[3])];
      } else {
        return undefined;
      }
    }
  );
};

/**
 * @param {ol.Coordinate|undefined} center Center.
 * @return {ol.Coordinate|undefined} Center.
 */
_ol_CenterConstraint_.none = function (center) {
  return center;
};
exports.default = _ol_CenterConstraint_;
module.exports = exports['default'];