const e=require("../../../_util/hooks/useState.js");let t=require("vue");var n=.1,r=.01,i=20,a=.995**i;function o(o,s){let[c,l]=e.default(),[u,d]=e.default(0),[f,p]=e.default(0),[m,h]=e.default(),g=(0,t.ref)();function _(e){let{screenX:t,screenY:n}=e.touches[0];l({x:t,y:n}),clearInterval(g.value)}function v(e){if(!c.value)return;e.preventDefault();let{screenX:t,screenY:n}=e.touches[0],r=t-c.value.x,i=n-c.value.y;s(r,i),l({x:t,y:n});let a=Date.now();p(a-u.value),d(a),h({x:r,y:i})}function y(){if(!c.value)return;let e=m.value;if(l(null),h(null),e){let t=e.x/f.value,o=e.y/f.value;if(Math.max(Math.abs(t),Math.abs(o))<n)return;let c=t,l=o;g.value=setInterval(()=>{if(Math.abs(c)<r&&Math.abs(l)<r){clearInterval(g.value);return}c*=a,l*=a,s(c*i,l*i)},i)}}let b=(0,t.ref)();function x(e){let{deltaX:t,deltaY:n}=e,r=0,i=Math.abs(t),a=Math.abs(n);i===a?r=b.value===`x`?t:n:i>a?(r=t,b.value=`x`):(r=n,b.value=`y`),s(-r,-r)&&e.preventDefault()}let S=(0,t.ref)({onTouchStart:_,onTouchMove:v,onTouchEnd:y,onWheel:x});function C(e){S.value.onTouchStart(e)}function w(e){S.value.onTouchMove(e)}function T(e){S.value.onTouchEnd(e)}function E(e){S.value.onWheel(e)}(0,t.onMounted)(()=>{document.addEventListener(`touchmove`,w,{passive:!1}),document.addEventListener(`touchend`,T,{passive:!1}),o.value?.addEventListener(`touchstart`,C,{passive:!1}),o.value?.addEventListener(`wheel`,E,{passive:!1})}),(0,t.onBeforeUnmount)(()=>{document.removeEventListener(`touchmove`,w),document.removeEventListener(`touchend`,T)})}exports.default=o;