function o(n, t, e) {
  return new Promise((r) => {
    if (e?.duration === 1 / 0)
      throw new Error("Promise-based animations must be finite.");
    const i = n.animate(t, {
      ...e,
      duration: a() ? 0 : e.duration
    });
    i.addEventListener("cancel", r, { once: !0 }), i.addEventListener("finish", r, { once: !0 });
  });
}
function s(n) {
  return n = n.toString().toLowerCase(), n.indexOf("ms") > -1 ? parseFloat(n) : n.indexOf("s") > -1 ? parseFloat(n) * 1e3 : parseFloat(n);
}
function a() {
  return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}
function u(n) {
  return Promise.all(
    n.getAnimations().map((t) => new Promise((e) => {
      t.cancel(), requestAnimationFrame(e);
    }))
  );
}
function c(n, t) {
  return n.map((e) => ({
    ...e,
    height: e.height === "auto" ? `${t}px` : e.height
  }));
}
export {
  o as a,
  c as b,
  a as c,
  s as p,
  u as s
};
