import o from"@babel/runtime/helpers/defineProperty";import i from"@babel/runtime/helpers/slicedToArray";import{useState as s,useRef as n,useEffect as e}from"react";import{Input as t}from"@material-ui/core";import r from"classnames";import"./styles/sliderStyles.js";import{useHandleStyles as c}from"./styles/handleStyles.js";import{getIsInputValueValid as a,getValidatedValue as l}from"./utils.js";import{HOVER_ARREA_WIDTH_BY_DIMENSION as m,HOVER_ARREA_HEIGHT as d,HORIZONTAL_ORIENTATION as u,VERTICAL_ORIENTATION as p,HEAD_PLACEMENT as v}from"./constants.js";import{LeftIcon as h,RightIcon as I}from"../../icons/iconParkIcons.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import{jsxs as j,jsx as f}from"react/jsx-runtime";var b=function(b){var A,R,g,C,F=b.value,H=b.orientation,w=b.placement,y=b.dimension,E=b.readOnly,N=b.onChange,k=b.min,x=b.max,T=b.displayFormatter,z=b.isInsideArrowsVisible,O=b.arrowsOutsideConfig,S=b.classes,M=b.minimal,_=b["data-testid"],G=s(!1),L=i(G,2),P=L[0],q=L[1],D=s(F),V=i(D,2),W=V[0],B=V[1],K=n(null),U=H===u,X=H===p,Z=w===v,J=c({distance:null==O?void 0:O.distance,minimal:M,hoverAreaHeight:U?m[y]:d,hoverAreaWidth:U?d:m[y]}),Q=function(o){if(!E){var i=Number(o);a(i)?N(l(i,k,x)):q(!0)}};return e((function(){B(F),P&&q(!1)}),[F]),j("div",{className:r(J.root,S.handleRoot,J[y],(A={},o(A,J.horizontalHeadRoot,U&&Z),o(A,J.horizontalTailRoot,U&&!Z),o(A,J.verticalHeadRoot,X&&Z),o(A,J.verticalTailRoot,X&&!Z),o(A,J.minimalHandleRoot,M),A)),children:[f(h,{size:16,className:r(J.leftArrow,(R={},o(R,J.reversedLeftArrow,X),o(R,J.isInvisible,z&&!Z||Z&&(null==O?void 0:O.isLeftArrowInvisible)),R)),fill:"white"}),f("div",{className:r(J.handle,S.handle,(g={},o(g,J.horizontalHeadHandle,U&&Z),o(g,J.horizontalTailHandle,U&&!Z),o(g,J.verticalHeadHandle,X&&Z),o(g,J.verticalTailHandle,X&&!Z),o(g,J.minimalHandle,M),o(g,J.minimalVerticalHandle,M&&X),g)),"data-testid":_,children:!M&&f(t,{inputProps:{"data-testid":"handle-input"},readOnly:E,inputRef:K,onKeyDown:function(o){var i=o.keyCode,s=o.target;13===i&&Q(s.value)},onBlur:function(o){var i=o.target;Q(i.value)},classes:{root:r(J.inputRoot,P&&J.hasError)},value:E?T(W):W,onChange:function(o){var i=o.target.value;(function(o){var i,s,n=null==o||null===(i=o.target)||void 0===i?void 0:i.value,e=n?parseFloat(n):0,t=e>=Number.MIN_SAFE_INTEGER&&e<Number.MAX_SAFE_INTEGER,r=null==o||null===(s=o.nativeEvent)||void 0===s?void 0:s.data,c=n.split(".").length-1;return!t||!(!r||"."===r||"-"===r||r>="0"&&r<="9")||c>1||"-"===r&&""===n})(o)||(B(i),P&&q(!1))},disableUnderline:!0,error:!(Number.isFinite(+W)&&+W>=k&&+W<=x)})}),f(I,{size:16,className:r(J.rightArrow,(C={},o(C,J.reversedRightArrow,X),o(C,J.isInvisible,z&&Z||!Z&&(null==O?void 0:O.isRightArrowInvisible)),C)),fill:"white"})]})};export{b as Handle};
