"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),q=require("../utils/index.js"),M=()=>{};function V({currentScroll:e=i.ref(0),trackSpeed:v=i.ref(2),track:p=i.ref(null),bar:n=i.ref(null),tracking:d=i.ref(!1),type:R=i.ref("vertical"),barLength:o=i.ref(35),disabled:x=i.ref(!1),onDown:w=M,onMove:A=M,onUp:B=M,onScroll:P=M}){let r,s,f,l,m=!0,g=!1;function h(){if(!d.value)return;g=!0;const t=X(l,e.value);let a=!1;if(m){if(e.value<l){const u=e.value+t*v.value;e.value=Math.min(u,l),a=!0}}else if(e.value>l){const u=e.value-t*v.value;e.value=Math.max(u,l),a=!0}a&&P(e.value),(d.value&&m?e.value<l:e.value>l)?requestAnimationFrame(h):g=!1}function T(t){if(x.value||t.button!==0||(t.stopPropagation(),t.preventDefault(),!p.value||!n.value))return!1;document.addEventListener("pointermove",D),document.addEventListener("pointerup",E);const a=p.value.getBoundingClientRect(),u=n.value.getBoundingClientRect();let c;R.value==="vertical"?(r=a.height,s=u.top-a.top,f=u.top,c=s+t.clientY-f):(r=a.width,s=u.left-a.left,f=u.left,c=s+t.clientX-f),m=c/r*100>o.value;const C=(c/r*100-(m?o.value:0))/(100-o.value);l=q.ensureRangeValue(C*100),d.value=!0,w(e.value),h()}function D(t){t.stopPropagation(),t.preventDefault(),A(e.value);let a;R.value==="vertical"?a=s+t.clientY-f:a=s+t.clientX-f;const u=(a/r*100-(m?o.value:0))/(100-o.value);l=q.ensureRangeValue(u*100),!g&&h()}function E(t){t.preventDefault(),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",E),d.value=!1,B(e.value)}return{currentScroll:e,trackSpeed:v,track:p,bar:n,tracking:d,type:R,barLength:o,disabled:x,handleMouseDown:T}}function X(e,v){const p=Math.abs(e-v);for(let n=0;n<5;++n)if(p<(n+1)*20)return 1+.25*n;return 2}exports.useTrack=V;
