import{Bt as e,Gr as t,Ht as n,Jr as r,Rr as i,Sr as a,Tr as o,Ur as s,Ut as c,ar as l,at as u,ct as d,fr as f,hr as p,jr as m,lt as h,ni as g,nt as _,ot as v,pr as y,st as b,zr as x}from"./style-QAnagFj5.js";import{h as S,x as C}from"./style-BqiJaO0R.js";var w=(e,t,n,i)=>{let s={offsetX:0,offsetY:0},c=r(!1),l=(t,n)=>{if(e.value){let{offsetX:r,offsetY:a}=s,o=e.value.getBoundingClientRect(),c=o.left,l=o.top,u=o.width,d=o.height,f=document.documentElement.clientWidth,p=document.documentElement.clientHeight,m=-c+r,h=-l+a,g=f-c-u+r,_=p-l-(d<p?d:0)+a;i?.value||(t=Math.min(Math.max(t,m),g),n=Math.min(Math.max(n,h),_)),s.offsetX=t,s.offsetY=n,e.value.style.transform=`translate(${v(t)}, ${v(n)})`}},u=e=>{let t=e.clientX,n=e.clientY,{offsetX:r,offsetY:i}=s,a=e=>{c.value||=!0,l(r+e.clientX-t,i+e.clientY-n)},o=()=>{c.value=!1,document.removeEventListener(`mousemove`,a),document.removeEventListener(`mouseup`,o)};document.addEventListener(`mousemove`,a),document.addEventListener(`mouseup`,o)},d=()=>{t.value&&e.value&&(t.value.addEventListener(`mousedown`,u),window.addEventListener(`resize`,m))},f=()=>{t.value&&e.value&&(t.value.removeEventListener(`mousedown`,u),window.removeEventListener(`resize`,m))},p=()=>{s.offsetX=0,s.offsetY=0,e.value&&(e.value.style.transform=``)},m=()=>{let{offsetX:e,offsetY:t}=s;l(e,t)};return o(()=>{x(()=>{n.value?d():f()})}),a(()=>{f()}),{isDragging:c,resetPosition:p,updatePosition:m}},T=(n,r={})=>{s(n)||e(`[useLockscreen]`,`You need to pass a ref param to this function`);let a=r.ns||_(`popup`),o=l(()=>a.bm(`parent`,`hidden`)),c=0,f=!1,p=`0`,m=!1,g=()=>{m||(m=!0,setTimeout(()=>{typeof document>`u`||f&&document&&(document.body.style.width=p,h(document.body,o.value))},200))};i(n,e=>{if(!e){g();return}m=!1,f=!d(document.body,o.value),f&&(p=document.body.style.width,u(document.body,o.value)),c=C(a.namespace.value);let t=document.documentElement.clientHeight<document.body.scrollHeight,n=b(document.body,`overflowY`);c>0&&(t||n===`scroll`)&&f&&(document.body.style.width=`calc(100% - ${c}px)`)}),t(()=>g())},E=e=>{if(!e)return{onClick:g,onMousedown:g,onMouseup:g};let t=!1,n=!1;return{onClick:r=>{t&&n&&e(r),t=n=!1},onMousedown:e=>{t=e.target===e.currentTarget},onMouseup:e=>{n=e.target===e.currentTarget}}},D=n({mask:{type:Boolean,default:!0},customMaskEvent:Boolean,overlayClass:{type:c([String,Array,Object])},zIndex:{type:c([String,Number])}}),O={click:e=>e instanceof MouseEvent},k=`overlay`,A=y({name:`ElOverlay`,props:D,emits:O,setup(e,{slots:t,emit:n}){let r=_(k),{onClick:i,onMousedown:a,onMouseup:o}=E(e.customMaskEvent?void 0:e=>{n(`click`,e)});return()=>e.mask?f(`div`,{class:[r.b(),e.overlayClass],style:{zIndex:e.zIndex},onClick:i,onMousedown:a,onMouseup:o},[m(t,`default`)],S.STYLE|S.CLASS|S.PROPS,[`onClick`,`onMouseup`,`onMousedown`]):p(`div`,{class:e.overlayClass,style:{zIndex:e.zIndex,position:`fixed`,top:`0px`,right:`0px`,bottom:`0px`,left:`0px`}},[m(t,`default`)])}});export{w as i,E as n,T as r,A as t};