const e=require("../../_util/raf.js"),t=require("../../_util/supportsPassive.js"),n=require("../../vc-util/Dom/addEventListener.js"),r=require("../../vc-util/devWarning.js"),i=require("../../table/context.js");let a=require("vue");var o={mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`},touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`}},s=50,c=(0,a.defineComponent)({compatConfig:{MODE:3},name:`DragHandle`,props:{prefixCls:String,width:{type:Number,required:!0},minWidth:{type:Number,default:s},maxWidth:{type:Number,default:1/0},column:{type:Object,default:void 0}},setup(c){let l=0,u={remove:()=>{}},d={remove:()=>{}},f=()=>{u.remove(),d.remove()};(0,a.onUnmounted)(()=>{f()}),(0,a.watchEffect)(()=>{r.default(!isNaN(c.width),`Table`,`width must be a number when use resizable`)});let{onResizeColumn:p}=i.useInjectTableContext(),m=(0,a.computed)(()=>typeof c.minWidth==`number`&&!isNaN(c.minWidth)?c.minWidth:s),h=(0,a.computed)(()=>typeof c.maxWidth==`number`&&!isNaN(c.maxWidth)?c.maxWidth:1/0),g=(0,a.getCurrentInstance)(),_=0,v=(0,a.shallowRef)(!1),y,b=t=>{let n=0;n=t.touches?t.touches.length?t.touches[0].pageX:t.changedTouches[0].pageX:t.pageX;let r=l-n,i=Math.max(_-r,m.value);i=Math.min(i,h.value),e.default.cancel(y),y=e.default(()=>{p(i,c.column.__originColumn__)})},x=e=>{b(e)},S=e=>{v.value=!1,b(e),f()},C=(e,t)=>{v.value=!0,f(),_=g.vnode.el.parentNode.getBoundingClientRect().width,!(e instanceof MouseEvent&&e.which!==1)&&(e.stopPropagation&&e.stopPropagation(),l=e.touches?e.touches[0].pageX:e.pageX,u=n.default(document.documentElement,t.move,x),d=n.default(document.documentElement,t.stop,S))},w=e=>{e.stopPropagation(),e.preventDefault(),C(e,o.mouse)},T=e=>{e.stopPropagation(),e.preventDefault(),C(e,o.touch)},E=e=>{e.stopPropagation(),e.preventDefault()};return()=>{let{prefixCls:e}=c,n={[t.default?`onTouchstartPassive`:`onTouchstart`]:e=>T(e)};return(0,a.createVNode)(`div`,{class:`${e}-resize-handle ${v.value?`dragging`:``}`,onMousedown:w,...n,onClick:E},[(0,a.createVNode)(`div`,{class:`${e}-resize-handle-line`},null)])}}});exports.default=c;