function animateTo(e,n,t){return new Promise((i=>{if((null==t?void 0:t.duration)===1/0)throw new Error("Promise-based animations must be finite.");if(!(null==e?void 0:e.animate))return;const a=e.animate(n,{...t,duration:prefersReducedMotion()?0:t.duration});a&&(a.addEventListener("cancel",i,{once:!0}),a.addEventListener("finish",i,{once:!0}))}))}function prefersReducedMotion(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function stopAnimations(e){var n;return Promise.all(((null===(n=null==e?void 0:e.getAnimations)||void 0===n?void 0:n.call(e))||[]).map((e=>new Promise((n=>{const t=requestAnimationFrame(n);e.addEventListener("cancel",(()=>t),{once:!0}),e.addEventListener("finish",(()=>t),{once:!0}),e.cancel()})))))}function shimKeyframesHeightAuto(e,n){return e.map((e=>({...e,height:"auto"===e.height?`${n}px`:e.height})))}const defaultAnimationRegistry=new Map,customAnimationRegistry=new WeakMap;function ensureAnimation(e){return null!=e?e:{keyframes:[],options:{duration:0}}}function setDefaultAnimation(e,n){defaultAnimationRegistry.set(e,ensureAnimation(n))}function getAnimation(e,n,t={}){var i;const a=customAnimationRegistry.get(e),o=null!==(i=null==a?void 0:a[n])&&void 0!==i?i:defaultAnimationRegistry.get(n);return o?"rtl"===t.dir&&o.rtlKeyframes?{...o,keyframes:o.rtlKeyframes}:o:{keyframes:[],options:{duration:0}}}export{animateTo as a,stopAnimations as b,shimKeyframesHeightAuto as c,getAnimation as g,setDefaultAnimation as s};