import{N as g}from"./el-button-46177dcd.js";import{z as T,H as W,A as U}from"./index-b8bd6c45.js";const z=(t,e,p)=>{let c={offsetX:0,offsetY:0};const m=i=>{const L=i.clientX,M=i.clientY,{offsetX:n,offsetY:s}=c,o=t.value.getBoundingClientRect(),u=o.left,l=o.top,w=o.width,X=o.height,Y=document.documentElement.clientWidth,x=document.documentElement.clientHeight,H=-u+n,b=-l+s,B=Y-u-w+n,D=x-l-X+s,d=f=>{const r=Math.min(Math.max(n+f.clientX-L,H),B),h=Math.min(Math.max(s+f.clientY-M,b),D);c={offsetX:r,offsetY:h},t.value.style.transform=`translate(${g(r)}, ${g(h)})`},v=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",v)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",v)},E=()=>{e.value&&t.value&&e.value.addEventListener("mousedown",m)},a=()=>{e.value&&t.value&&e.value.removeEventListener("mousedown",m)};T(()=>{W(()=>{p.value?E():a()})}),U(()=>{a()})};export{z as u};
