import e from"../../_util/KeyCode.mjs";function t(e,t){try{return Object.keys(t).some(n=>e.target===t[n].ref)}catch{return!1}}function n(e,{min:t,max:n}){return e<t||e>n}function r(e){return e.touches.length>1||e.type.toLowerCase()===`touchend`&&e.touches.length>0}function i(e,{marks:t,step:n,min:r,max:i}){let o=Object.keys(t).map(Number.parseFloat);if(n!==null){let t=10**a(n),s=Math.floor((i*t-r*t)/(n*t)),c=Math.min((e-r)/n,s),l=Math.round(c)*n+r;o.push(l)}let s=o.map(t=>Math.abs(e-t));return o[s.indexOf(Math.min(...s))]}function a(e){let t=e.toString(),n=0;return t.includes(`.`)&&(n=t.length-t.indexOf(`.`)-1),n}function o(e,t){let n=1;return window.visualViewport&&(n=+(window.visualViewport.width/document.body.getBoundingClientRect().width).toFixed(2)),(e?t.clientY:t.pageX)/n}function s(e,t){let n=1;return window.visualViewport&&(n=+(window.visualViewport.width/document.body.getBoundingClientRect().width).toFixed(2)),(e?t.touches[0].clientY:t.touches[0].pageX)/n}function c(e,t){let n=t.getBoundingClientRect();return e?n.top+n.height*.5:window.scrollX+n.left+n.width*.5}function l(e,{max:t,min:n}){return e<=n?n:e>=t?t:e}function u(e,t){let{step:n}=t,r=isFinite(i(e,t))?i(e,t):0;return n===null?r:Number.parseFloat(r.toFixed(a(n)))}function d(e){e.stopPropagation(),e.preventDefault()}function f(e,t,n){let r={increase:(e,t)=>e+t,decrease:(e,t)=>e-t},i=r[e](Object.keys(n.marks).indexOf(JSON.stringify(t)),1),a=Object.keys(n.marks)[i];return n.step?r[e](t,n.step):Object.keys(n.marks).length&&n.marks[a]?n.marks[a]:t}function p(t,n,r){let i=`increase`,a=`decrease`,o=i;switch(t.keyCode){case e.UP:o=n&&r?a:i;break;case e.RIGHT:o=!n&&r?a:i;break;case e.DOWN:o=n&&r?i:a;break;case e.LEFT:o=!n&&r?i:a;break;case e.END:return(e,t)=>t.max;case e.HOME:return(e,t)=>t.min;case e.PAGE_UP:return(e,t)=>e+t.step*2;case e.PAGE_DOWN:return(e,t)=>e-t.step*2;default:return}return(e,t)=>f(o,e,t)}export{f as calculateNextValue,l as ensureValueInRange,u as ensureValuePrecision,i as getClosestPoint,c as getHandleCenterPosition,p as getKeyboardValueMutator,o as getMousePosition,a as getPrecision,s as getTouchPosition,t as isEventFromHandle,r as isNotTouchEvent,n as isValueOutOfRange,d as pauseEvent};