import{d as b,u as L}from"./deviceTree.170dfbd9.js";import{r as p,bN as E}from"./index.8d733f79.js";function w(d){const t=p(230);let o=!1,n=0,u=0;b({category:"device_tree"}).then(e=>{var m;t.value=((m=e.data)==null?void 0:m.width)||230});const c=e=>{o=!0,n=e.clientX,u=t.value,document.addEventListener("mousemove",s),document.addEventListener("mouseup",i),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},s=e=>{if(!o)return;const m=e.clientX-n,r=u+m;r>199&&r<461&&(t.value=r)},i=()=>{o=!1,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",i),document.body.style.cursor="",document.body.style.userSelect="",d&&d.onDragEnd&&d.onDragEnd(t.value),L({category:"device_tree",width:`${t.value}`}).then(e=>{})};return E(()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",i)}),{width:t,startDrag:c}}function S(d={}){const{defaultSize:h,min:y,max:t,onDragEnd:o,direction:n}=d,u=n==="top"||n==="bottom"?"height":"width",c=p(h);let s=!1,i=0,e=0;const m=a=>{s=!0,i=u==="height"?a.clientY:a.clientX,e=c.value,document.addEventListener("mousemove",r),document.addEventListener("mouseup",l);const f=u==="height"?"row-resize":"col-resize";document.body.style.cursor=f,document.body.style.userSelect="none"},r=a=>{if(!s)return;let v=(u==="height"?a.clientY:a.clientX)-i;(n==="left"||n==="top")&&(v=-v);const g=e+v;g>=y&&g<=t&&(c.value=g)},l=()=>{s=!1,document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",l),document.body.style.cursor="",document.body.style.userSelect="",o==null||o(c.value)};return E(()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",l)}),{size:c,startDrag:m}}export{S as a,w as u};
