import O from"../node_modules/.pnpm/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.mjs";import{defineComponent as p,reactive as w,getCurrentInstance as C,onMounted as R,onUpdated as M,onUnmounted as x,watch as H}from"vue";import{findDOMNode as W}from"../_util/props-util/index.mjs";const U=p({compatConfig:{MODE:3},name:"ResizeObserver",props:{disabled:Boolean,onResize:Function},emits:["resize"],setup(s,{slots:m}){const n=w({width:0,height:0,offsetHeight:0,offsetWidth:0});let h=null,t=null;const i=()=>{t&&(t.disconnect(),t=null)},u=d=>{const{onResize:e}=s,o=d[0].target,{width:v,height:z}=o.getBoundingClientRect(),{offsetWidth:f,offsetHeight:c}=o,l=Math.floor(v),a=Math.floor(z);if(n.width!==l||n.height!==a||n.offsetWidth!==f||n.offsetHeight!==c){const g={width:l,height:a,offsetWidth:f,offsetHeight:c};Object.assign(n,g),e&&Promise.resolve().then(()=>{e({...g,offsetWidth:f,offsetHeight:c},o)})}},b=C(),r=()=>{const{disabled:d}=s;if(d){i();return}const e=W(b);e!==h&&(i(),h=e),!t&&e&&(t=new O(u),t.observe(e))};return R(()=>{r()}),M(()=>{r()}),x(()=>{i()}),H(()=>s.disabled,()=>{r()},{flush:"post"}),()=>m.default?.()[0]}});export{U as default};
