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