import e from"../../_util/raf.mjs";import{onBeforeUnmount as t,onMounted as n,shallowRef as r,watch as i}from"vue";var a=[`measure`,`align`,null,`motion`],o=(o,s)=>{let c=r(null),l=r(),u=r(!1);function d(e){u.value||(c.value=e)}function f(){e.cancel(l.value)}function p(t){f(),l.value=e(()=>{let e=c.value;switch(c.value){case`align`:e=`motion`;break;case`motion`:e=`stable`;break;default:}d(e),t?.()})}return i(o,()=>{d(`measure`)},{immediate:!0,flush:`post`}),n(()=>{i(c,()=>{switch(c.value){case`measure`:s();break;default:}c.value&&(l.value=e(async()=>{let e=a.indexOf(c.value),t=a[e+1];t&&e!==-1&&d(t)}))},{immediate:!0,flush:`post`})}),t(()=>{u.value=!0,f()}),[c,p]};export{o as default};