import{unrefElement as e}from"./unrefElement.mjs";import{defaultWindow as t}from"./_configurable.mjs";import{tryOnScopeDispose as n}from"./tryOnScopeDispose.mjs";import{useSupported as r}from"./useSupported.mjs";import{watch as i}from"vue";function a(a,o,s={}){let{window:c=t,...l}=s,u,d=r(()=>c&&`ResizeObserver`in c),f=()=>{u&&(u.disconnect(),u=void 0)},p=i(()=>e(a),e=>{f(),d.value&&c&&e&&(u=new ResizeObserver(o),u.observe(e,l))},{immediate:!0,flush:`post`}),m=()=>{f(),p()};return n(m),{isSupported:d,stop:m}}export{a as useResizeObserver};