"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/toConsumableArray"),r=require("react"),a=require("classnames"),n=require("prop-types"),i=require("@material-ui/core"),s=require("@material-ui/icons/Add"),l=require("@material-ui/icons/Delete");require("../shared/CancelButton.js"),require("../shared/ExpandCollapseButton.js"),require("../shared/FormatedNumber.js");var u=require("../shared/InputText.js");require("../shared/MoreButton.js"),require("../shared/SaveButton.js");var o=require("../shared/SelectField.js"),d=require("../shared/StaticField.js");require("../shared/SharedEditorElements.js"),require("../shared/ConfirmationPopup.js");var c=require("../sharedStyles.js"),f=require("../../../../../utils/mobileDetect.js"),p=require("../../../../../utils/index.js"),m=require("../../../../../constants/drillstring.js"),j=require("react/jsx-runtime");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=b(e),y=b(t),g=b(a),x=b(n),q=b(s),v=b(l);function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?O(Object(r),!0).forEach((function(t){h.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function P(e){var t,a=e.data,n=e.errors,s=e.isEditing,l=e.onChange,b=c.useStyles({isMobile:f.isMobileDetected,isEditing:s}),x=n||[],O=function(e){return function(){l([].concat(y.default(a.slice(0,e)),y.default(a.slice(e+1))))}},P=function(e){return function(t,r){var n=a.map((function(a,n){return n===e?M(M({},a),{},h.default({},t,r)):a}));l(n)}};return 0!==a.length||s?j.jsxs("div",{className:b.subGroup,children:[j.jsxs("div",{className:g.default(b.subTitle,h.default({},b.subTitleEditing,s)),children:["LWD Measurements",s&&j.jsx(i.IconButton,{"data-not-migrated-muiiconbutton":!0,className:b.addButton,onClick:function(){l([].concat(y.default(a),[{type:null,name:null,distance:null}]))},children:j.jsx(q.default,{className:b.addIcon,color:"primary"})})]}),j.jsx(i.Grid,{container:!0,spacing:2,className:g.default(b.detailedView,(t={},h.default(t,b.detailedViewMobile,f.isMobileDetected),h.default(t,b.eidtorNozzleView,s),t)),children:a.map((function(e,t){return j.jsxs(r.Fragment,{children:[s?j.jsx(o.SelectField,{type:"type",options:m.LWD_MEASUREMENT_TYPES,label:"Measurement Type",value:e.type,error:x[t]&&x[t].type,xs:3,onChangeField:P(t)}):j.jsx(d.StaticField,{label:"Measurement Type",value:e.type,format:null,xs:4}),s?j.jsx(u.InputText,{type:"name",label:"Measurement Name",value:e.name,error:x[t]&&x[t].name,xs:3,onChangeField:P(t)}):j.jsx(d.StaticField,{label:"Measurement Name",value:e.name,format:null,xs:4}),s?j.jsx(u.InputText,{type:"distance",label:"M. Point distance (".concat(p.getUnitDisplay("length"),")"),value:e.distance,error:x[t]&&x[t].distance,xs:3,onChangeField:P(t)}):j.jsx(d.StaticField,{label:"Measure Point distance to Bit",unit:"length",value:e.distance,xs:4}),s&&j.jsx(i.Grid,{item:!0,xs:3,className:h.default({},b.cellInnerMobile,f.isMobileDetected),children:j.jsx(i.IconButton,{"data-not-migrated-muiiconbutton":!0,className:b.addButton,onClick:O(t),children:j.jsx(v.default,{className:b.addIcon})})})]},t)}))})]}):null}P.propTypes={isEditing:x.default.bool.isRequired,data:x.default.arrayOf(x.default.shape({type:x.default.string,name:x.default.string,distance:x.default.number})),errors:x.default.arrayOf(x.default.shape({type:x.default.string,name:x.default.string,distance:x.default.string})),onChange:x.default.func},P.defaultProps={data:[],errors:[],onChange:null};var S=r.memo(P);module.exports=S;
//# sourceMappingURL=Measurement.js.map
