"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = compose;
/**
 * Composes higher-order components (enhancers) into a single higher-order component.
 * @param {...function} enhancers - The enhancers to compose.
 * @returns {function} A function that accepts a component, and returns a new component with all of
 * the supplied enhancers applied from right to left.
 */
function compose() {
  for (var _len = arguments.length, enhancers = Array(_len), _key = 0; _key < _len; _key++) {
    enhancers[_key] = arguments[_key];
  }

  if (enhancers.length === 0) {
    return function (component) {
      return component;
    };
  }

  if (enhancers.length === 1) {
    return enhancers[0];
  }

  return function (component) {
    return enhancers.reduceRight(function (result, enhancer) {
      return enhancer(result);
    }, component);
  };
}