const e=require("../_virtual/_rolldown/runtime.js"),t=require("../vc-util/Dom/addEventListener.js"),n=require("../_util/vnode.js"),r=require("../node_modules/.pnpm/dom-align@1.12.4/node_modules/dom-align/dist-web/index.js"),i=require("../vc-util/Dom/isVisible.js"),a=require("./hooks/useBuffer.js"),o=require("./util.js");let s=require("vue"),c=require("lodash-es/isEqual");c=e.__toESM(c,1);var l={align:Object,target:[Object,Function],onAlign:Function,monitorBufferTime:Number,monitorWindowResize:Boolean,disabled:Boolean};function u(e){return typeof e==`function`?e():null}function d(e){return typeof e!=`object`||!e?null:e}var f=(0,s.defineComponent)({compatConfig:{MODE:3},name:`Align`,props:l,emits:[`align`],setup(e,{expose:l,slots:f}){let p=(0,s.ref)({}),m=(0,s.ref)(),[h,g]=a.default(()=>{let{disabled:t,target:n,align:a,onAlign:s}=e;if(!t&&n&&m.value){let e=m.value,t,c=u(n),l=d(n);p.value.element=c,p.value.point=l,p.value.align=a;let{activeElement:f}=document;return c&&i.default(c)?t=r.alignElement(e,c,a):l&&(t=r.alignPoint(e,l,a)),o.restoreFocus(f,e),s&&t&&s(e,t),!0}return!1},(0,s.computed)(()=>e.monitorBufferTime)),_=(0,s.ref)({cancel:()=>{}}),v=(0,s.ref)({cancel:()=>{}}),y=()=>{let t=e.target,n=u(t),r=d(t);m.value!==v.value.element&&(v.value.cancel(),v.value.element=m.value,v.value.cancel=o.monitorResize(m.value,h)),(p.value.element!==n||!o.isSamePoint(p.value.point,r)||!(0,c.default)(p.value.align,e.align))&&(h(),_.value.element!==n&&(_.value.cancel(),_.value.element=n,_.value.cancel=o.monitorResize(n,h)))};(0,s.onMounted)(()=>{(0,s.nextTick)(()=>{y()})}),(0,s.onUpdated)(()=>{(0,s.nextTick)(()=>{y()})}),(0,s.watch)(()=>e.disabled,e=>{e?g():h()},{immediate:!0,flush:`post`});let b=(0,s.ref)(null);return(0,s.watch)(()=>e.monitorWindowResize,e=>{e?b.value||(b.value=t.default(window,`resize`,h)):b.value&&(b.value.remove(),b.value=null)},{flush:`post`}),(0,s.onUnmounted)(()=>{_.value.cancel(),v.value.cancel(),b.value&&b.value.remove(),g()}),l({forceAlign:()=>h(!0)}),()=>{let e=f?.default();return e?n.cloneElement(e[0],{ref:m},!0,!0):null}}});exports.alignProps=l,exports.default=f;