import{g}from"./base-4c430c4f.js";import{s as W,al as B,S as U}from"./normalize-040897f0.js";const C=(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,b=-u+n,D=-l+s,H=Y-u-w+n,T=x-l-X+s,d=f=>{const r=Math.min(Math.max(n+f.clientX-L,b),H),h=Math.min(Math.max(s+f.clientY-M,D),T);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)};W(()=>{B(()=>{p.value?E():a()})}),U(()=>{a()})};export{C as u};
