import{K as e,Mt as t,P as n,Q as r,St as i,U as a,_t as o,ct as s,j as c,k as l,lt as u,x as d,yt as f,zt as p}from"./vue.runtime.esm-bundler-DpGzKKN4.js";import{Zt as m,a as h,b as g,i as _,n as v,r as y,t as b,w as x,y as S}from"./style-DGCNsUJ6.js";import{Pt as C,t as w}from"./vnode-DU8g6Rf7.js";p();var T=e=>{if(!e)return{onClick:t,onMousedown:t,onMouseup:t};let n=!1,r=!1;return{onClick:t=>{n&&r&&e(t),n=r=!1},onMousedown:e=>{n=e.target===e.currentTarget},onMouseup:e=>{r=e.target===e.currentTarget}}},E=S({mask:{type:Boolean,default:!0},customMaskEvent:Boolean,overlayClass:{type:g([String,Array,Object])},zIndex:{type:g([String,Number])}}),D={click:e=>e instanceof MouseEvent},O=`overlay`,k=c({name:`ElOverlay`,props:E,emits:D,setup(e,{slots:t,emit:i}){let a=m(O),{onClick:o,onMousedown:s,onMouseup:c}=T(e.customMaskEvent?void 0:e=>{i(`click`,e)});return()=>e.mask?l(`div`,{class:[a.b(),e.overlayClass],style:{zIndex:e.zIndex},onClick:o,onMousedown:s,onMouseup:c},[r(t,`default`)],w.STYLE|w.CLASS|w.PROPS,[`onClick`,`onMouseup`,`onMousedown`]):n(`div`,{class:e.overlayClass,style:{zIndex:e.zIndex,position:`fixed`,top:`0px`,right:`0px`,bottom:`0px`,left:`0px`}},[r(t,`default`)])}}),A=(t,n,r,o)=>{let s={offsetX:0,offsetY:0},c=i(!1),l=(e,n)=>{if(t.value){let{offsetX:r,offsetY:i}=s,a=t.value.getBoundingClientRect(),c=a.left,l=a.top,u=a.width,d=a.height,f=document.documentElement.clientWidth,p=document.documentElement.clientHeight,m=-c+r,h=-l+i,g=f-c-u+r,_=p-l-(d<p?d:0)+i;o?.value||(e=Math.min(Math.max(e,m),g),n=Math.min(Math.max(n,h),_)),s.offsetX=e,s.offsetY=n,t.value.style.transform=`translate(${v(e)}, ${v(n)})`}},d=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)},f=()=>{n.value&&t.value&&(n.value.addEventListener(`mousedown`,d),window.addEventListener(`resize`,h))},p=()=>{n.value&&t.value&&(n.value.removeEventListener(`mousedown`,d),window.removeEventListener(`resize`,h))},m=()=>{s.offsetX=0,s.offsetY=0,t.value&&(t.value.style.transform=``)},h=()=>{let{offsetX:e,offsetY:t}=s;l(e,t)};return e(()=>{u(()=>{r.value?f():p()})}),a(()=>{p()}),{isDragging:c,resetPosition:m,updatePosition:h}},j=(e,t={})=>{o(e)||x(`[useLockscreen]`,`You need to pass a ref param to this function`);let n=t.ns||m(`popup`),r=d(()=>n.bm(`parent`,`hidden`)),i=0,a=!1,c=`0`,l=()=>{setTimeout(()=>{typeof document>`u`||a&&document&&(document.body.style.width=c,h(document.body,r.value))},200)};s(e,e=>{if(!e){l();return}a=!_(document.body,r.value),a&&(c=document.body.style.width,b(document.body,r.value)),i=C(n.namespace.value);let t=document.documentElement.clientHeight<document.body.scrollHeight,o=y(document.body,`overflowY`);i>0&&(t||o===`scroll`)&&a&&(document.body.style.width=`calc(100% - ${i}px)`)}),f(()=>l())};export{T as i,A as n,k as r,j as t};