import e from"@babel/runtime/helpers/slicedToArray";import{useState as t,useMemo as r,useEffect as i}from"react";import a from"prop-types";import{Tooltip as n,TextField as o}from"@material-ui/core";import{debounce as u}from"lodash";import{getIsImperial as l}from"../../utils/unitSystem.js";import{convertValue as s}from"../../../../utils/index.js";import{jsx as d}from"react/jsx-runtime";var m=u((function(e){e()}),1500),p=function(e){var t,r=null==e||null===(t=e.nativeEvent)||void 0===t?void 0:t.data,i="-"===r&&""===e.target.value;return"e"===r||"E"===r||"+"===r||"."===r||i},c=function(a){var u=a.radius,c=a.editable,f=a.onChange,v=a["data-testid"],b=t(u),h=e(b,2),g=h[0],x=h[1],y=t(null),R=e(y,2),j=R[0],k=R[1],T=r((function(){return l()}),[]);i((function(){var e=T?u:s(u,"length","mi","km",3);x(Number.parseFloat(e).toFixed(2))}),[u]);return d(n,{title:c?"":"To make radius active select Subject Well.",children:d(o,{"data-testid":"".concat(v,"_input"),type:"number",label:"Radius (".concat(T?"miles":"km",")"),value:g||"",disabled:!c,onChange:function(e){var t=e.target.value;if(!p(e)){if(!Number.isFinite(+t)||+t<0)k("Incorrect radius");else{k(null);var r=T?+t:s(t,"length","km","mi",3);m((function(){f(+r)}))}x(t)}},error:!!j,helperText:j},"ows4-radius-input")})};c.propTypes={radius:a.number.isRequired,editable:a.bool.isRequired,onChange:a.func.isRequired,"data-testid":a.string},c.defaultProps={"data-testid":"RadiusInput"};export{c as RadiusInput,p as isBuggySymbolEntered};
