import { time as p } from "../frameloop/sync-time.es.js";
import { setStyle as c } from "../render/dom/style-set.es.js";
import { JSAnimation as f } from "./JSAnimation.es.js";
import { NativeAnimation as u } from "./NativeAnimation.es.js";
import { replaceTransitionType as d } from "./utils/replace-transition-type.es.js";
import { replaceStringEasing as h } from "./waapi/utils/unsupported-easing.es.js";
import { clamp as T } from "../../../../../../motion-utils@12.36.0/node_modules/motion-utils/dist/es/clamp.es.js";
const o = 10;
class N extends u {
  constructor(t) {
    h(t), d(t), super(t), t.startTime !== void 0 && t.autoplay !== !1 && (this.startTime = t.startTime), this.options = t;
  }
  /**
   * WAAPI doesn't natively have any interruption capabilities.
   *
   * Rather than read committed styles back out of the DOM, we can
   * create a renderless JS animation and sample it twice to calculate
   * its current value, "previous" value, and therefore allow
   * Motion to calculate velocity for any subsequent animation.
   */
  updateMotionValue(t) {
    const { motionValue: e, onUpdate: y, onComplete: A, element: m, ...l } = this.options;
    if (!e)
      return;
    if (t !== void 0) {
      e.set(t);
      return;
    }
    const i = new f({
      ...l,
      autoplay: !1
    }), a = Math.max(o, p.now() - this.startTime), n = T(0, o, a - o), r = i.sample(a).value, { name: s } = this.options;
    m && s && c(m, s, r), e.setWithVelocity(i.sample(Math.max(0, a - n)).value, r, n), i.stop();
  }
}
export {
  N as NativeAnimationExtended
};
//# sourceMappingURL=NativeAnimationExtended.es.js.map
