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