"use strict";var e=require("prop-types"),t=require("lodash"),a=require("@material-ui/core"),i=require("./TracesEditModal.css.js"),n=require("../Typography.js"),l=require("../Modal/Modal.js"),s=require("../KeyboardDateTimePicker.js"),r=require("../PostInput/PostInput.js"),o=require("../../utils/convert.js"),d=require("../../utils/index.js"),u=require("react/jsx-runtime");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=c(e),m="TracesEditModal",f=function(e){var t=e.onClose,c=e.onApply,p=e.postValue,f=e.onPostChange,h=e.timestampMs,x=e.onTimestampChange,y=e.timestampError,D=e.minDateMs,g=e.maxDateMs,b=e.isApplyDisabled,j=e.isDepthDataLoading,q=e.holeDepth,C=e.bitDepth,T=e.userCompanyId,M=d.getUnitDisplay("length"),R=o.convertValue(+C,"length","ft"),A=o.convertValue(+q,"length","ft");return u.jsxs(l,{open:!0,onClose:t,title:"Edit",contentClassName:i.modal,actions:u.jsxs(a.Grid,{container:!0,direction:"row",justify:"flex-end",alignItems:"center",spacing:2,children:[u.jsx(a.Grid,{item:!0,children:u.jsx(a.Button,{"data-testid":"".concat(m,"_cancel"),color:"primary",onClick:t,children:"Cancel"})}),u.jsx(a.Grid,{item:!0,children:u.jsx(a.Button,{"data-testid":"".concat(m,"_apply"),variant:"contained",color:"primary",disabled:b,onClick:c,children:"Apply"})})]}),children:[u.jsx(r,{className:i.modalPostInput,initialValue:p,userCompanyId:T,onChange:f}),u.jsxs(a.Box,{display:"flex",flexDirection:"column",children:[u.jsx(a.Box,{display:"flex",flexDirection:"column",mb:2,children:u.jsx(s,{label:"Time","data-testid":"".concat(m,"_date"),className:i.modalDateInput,disabled:j,ampm:!1,value:h,minDate:D,maxDate:g,onChange:x,format:"MM/DD/YYYY, HH:mm",error:!!y,helperText:y})}),Number.isFinite(q)&&u.jsxs(a.Box,{display:"flex",flexDirection:"column",mb:3,children:[u.jsx("span",{className:i.modalFieldLabel,children:"Hole Depth"}),u.jsx(n.Regular14,{"data-testid":"".concat(m,"_holeDepth"),children:j?"Loading...":"".concat(A," ").concat(M)})]}),Number.isFinite(C)&&u.jsxs(a.Box,{display:"flex",flexDirection:"column",children:[u.jsx("span",{className:i.modalFieldLabel,children:"Bit Depth"}),u.jsx(n.Regular14,{"data-testid":"".concat(m,"_bitDepth"),children:j?"Loading...":"".concat(R," ").concat(M)})]})]})]})};f.propTypes={isApplyDisabled:p.default.bool,isDepthDataLoading:p.default.bool,userCompanyId:p.default.oneOfType([p.default.string,p.default.number]).isRequired,timestampMs:p.default.oneOfType([p.default.string,p.default.number]).isRequired,minDateMs:p.default.oneOfType([p.default.string,p.default.number]).isRequired,maxDateMs:p.default.oneOfType([p.default.string,p.default.number]).isRequired,timestampError:p.default.string,holeDepth:p.default.oneOfType([p.default.string,p.default.number]).isRequired,bitDepth:p.default.oneOfType([p.default.string,p.default.number]).isRequired,initialAttachment:p.default.shape({}),postValue:p.default.shape({body:p.default.string,attachment:p.default.shape({})}).isRequired,onPostChange:p.default.func.isRequired,onTimestampChange:p.default.func.isRequired,onClose:p.default.func,onApply:p.default.func},f.defaultProps={initialAttachment:null,onClose:t.noop,onApply:t.noop,timestampError:"",isApplyDisabled:!1,isDepthDataLoading:!1},module.exports=f;
