import _typeof from "@babel/runtime/helpers/esm/typeof";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["type"];
export var predefinedEffects = {
  fade: function fade() {
    return {
      initial: {
        opacity: 0
      },
      animate: {
        opacity: 1,
        duration: 'quick2',
        easing: 'linear'
      },
      exit: {
        opacity: 0,
        duration: 'quick2',
        easing: 'linear'
      }
    };
  },
  scaleFade: function scaleFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          scale: 0.85
        }
      },
      animate: {
        opacity: 1,
        transform: {
          scale: 1
        },
        duration: 'moderate2',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          scale: 0.85
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  },
  slideUpFade: function slideUpFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          translateY: 'm'
        }
      },
      animate: {
        opacity: 1,
        transform: {
          translateY: 0
        },
        duration: 'moderate1',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          translateY: 'm'
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  },
  slideDownFade: function slideDownFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          translateY: '-m'
        }
      },
      animate: {
        opacity: 1,
        transform: {
          translateY: 0
        },
        duration: 'moderate1',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          translateY: '-m'
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  },
  slideLeftFade: function slideLeftFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          translateX: 'm'
        }
      },
      animate: {
        opacity: 1,
        transform: {
          translateX: 0
        },
        duration: 'moderate2',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          translateX: 'm'
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  },
  slideRightFade: function slideRightFade() {
    return {
      initial: {
        opacity: 0,
        transform: {
          translateX: '-m'
        }
      },
      animate: {
        opacity: 1,
        transform: {
          translateX: 0
        },
        duration: 'moderate2',
        easing: 'entry'
      },
      exit: {
        opacity: 0,
        transform: {
          translateX: '-m'
        },
        duration: 'moderate1',
        easing: 'exit'
      }
    };
  }
};
export function createEffect(_ref) {
  var type = _ref.type,
      customEffectProps = _objectWithoutProperties(_ref, _excluded);

  if (type && predefinedEffects[type] !== undefined) {
    return mergeDeepEffects(predefinedEffects[type](), customEffectProps);
  }

  return customEffectProps;
}
/**
 * It expects effect objects not containing arrays,
 * which will probably never happen in the future.
 */

function mergeDeepEffects(target, source) {
  Object.keys(source).forEach(function (key) {
    if (_typeof(target[key]) === 'object') {
      target[key] = mergeDeepEffects(target[key], source[key]);
    } else {
      target[key] = source[key];
    }
  });
  return target;
}