"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const ease = require("./dist-es-easing-ease.cjs");
const isEasingArray = require("./dist-es-easing-utils-is-easing-array.cjs");
const map = require("./dist-es-easing-utils-map.cjs");
const interpolate = require("./dist-es-utils-interpolate.cjs");
const _default = require("./dist-es-utils-offsets-default.cjs");
const time = require("./dist-es-utils-offsets-time.cjs");
function defaultEasing(values, easing) {
  return values.map(() => easing || ease.easeInOut).splice(0, values.length - 1);
}
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease: ease2 = "easeInOut" }) {
  const easingFunctions = isEasingArray.isEasingArray(ease2) ? ease2.map(map.easingDefinitionToFunction) : map.easingDefinitionToFunction(ease2);
  const state = {
    done: false,
    value: keyframeValues[0]
  };
  const absoluteTimes = time.convertOffsetToTimes(
    // Only use the provided offsets if they're the correct length
    // TODO Maybe we should warn here if there's a length mismatch
    times && times.length === keyframeValues.length ? times : _default.defaultOffset(keyframeValues),
    duration
  );
  const mapTimeToKeyframe = interpolate.interpolate(absoluteTimes, keyframeValues, {
    ease: Array.isArray(easingFunctions) ? easingFunctions : defaultEasing(keyframeValues, easingFunctions)
  });
  return {
    calculatedDuration: duration,
    next: (t) => {
      state.value = mapTimeToKeyframe(t);
      state.done = t >= duration;
      return state;
    }
  };
}
exports.defaultEasing = defaultEasing;
exports.keyframes = keyframes;
//# sourceMappingURL=dist-es-animation-generators-keyframes.cjs.map
