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