import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/slicedToArray";import{useRef as o,useState as n}from"react";import r from"moment";import i from"classnames";import{makeStyles as a,Grid as c,Typography as s}from"@material-ui/core";import{getUnitDisplay as l}from"../../../../utils/index.js";import m from"../../../Modal/Modal.js";import p from"../../../PostInput/PostInput.js";import d from"../../../IconButton/index.js";import{Regular14 as u}from"../../../Typography.js";import h from"../../../Icons/SendIcon.js";import{isSuggestionsListOpened as f}from"../../../UserMention/utils/index.js";import{FEED_ITEM_TYPES as g,MENTION_STYLE as b}from"../../../../constants/feed.js";import{jsxs as y,jsx as v}from"react/jsx-runtime";function j(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function w(e){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?j(Object(n),!0).forEach((function(o){t(e,o,n[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var x=a((function(t){return{postInput:{paddingBottom:8},filePreviewWrapper:{width:"100%",marginLeft:0,maxHeight:251},modal:{maxWidth:450,width:"100vw"},info:{marginTop:16},text:{color:t.palette.primary.text6},value:{color:"#fff"},inputMain:{marginBottom:0,fontSize:"11px",color:t.palette.primary.text8},inputHelper:{display:"flex",paddingRight:5},cancelText:{cursor:"pointer"},highlightedLabel:{color:t.palette.primary.main},modalActions:{paddingTop:16},actions:{height:36},sendRow:{display:"flex"},sendIcon:{"&.Mui-disabled":{cursor:"not-allowed!important"}}}}));function O(a){var j=a.feedItem.context[g.TRACES_MEMO],O=j.body,C=j.attachment,N=j.bitDepth,P=j.holeDepth,D=j.timestamp,I=a.onClose,M=a.onSave,E=a.userCompanyId,B=x(),S=o(),T=n({body:O,attachment:C}),H=e(T,2),A=H[0],k=H[1],R=function(){M({context:t({},g.TRACES_MEMO,w(w({},A),{},{bitDepth:N,holeDepth:P,timestamp:D}))})};return y(m,{open:!0,onClose:I,title:"Edit Comment",contentClassName:B.modal,actionsClassName:B.modalActions,onClick:function(t){t.stopPropagation()},actions:y(c,{container:!0,direction:"row",justify:"space-between",alignItems:"center",className:B.actions,children:[v(c,{item:!0,children:v(s,{variant:"caption",className:i(B.inputMain,B.cancelText,B.highlightedLabel),"data-testid":"".concat("EditComment","_cancel"),component:"div",gutterBottom:!0,onClick:I,children:"Cancel"})}),y(c,{item:!0,direction:"row",alignItems:"center",className:B.sendRow,children:[y(s,{variant:"caption",className:i(B.inputMain,B.inputHelper),component:"div",gutterBottom:!0,children:["Press ",v(s,{variant:"caption",color:"primary",className:i(B.inputMain,B.highlightedLabel),children:"Enter"})," to send"]}),v(d,{onClick:R,className:B.sendIcon,"data-testid":"".concat("EditComment","_send"),disabled:!A||!A.body&&!A.attachment,children:v(h,{})})]})]}),ref:S,children:[v(p,{initialValue:{body:O,attachment:C},userCompanyId:E,onChange:k,filePreviewWrapperClass:B.filePreviewWrapper,className:B.postInput,onKeyDown:function(t){"Enter"!==t.key||t.shiftKey||f()||(t.preventDefault(),R())},mentionStyle:b,suggestionsPortalHost:S.current,allowSuggestionsAboveCursor:!0}),y("div",{className:B.info,children:[D&&y(u,{className:B.text,gutterBottom:!0,children:["Time:"," ",v("span",{className:B.value,children:r(D).format("MM/DD/YY, HH:mm")})," "]}),Number.isFinite(N)&&y(u,{className:B.text,gutterBottom:!0,children:["Bit Depth:"," ",v("span",{className:B.value,children:"".concat(N," ").concat(l("length"))})]}),Number.isFinite(P)&&y(u,{className:B.text,gutterBottom:!0,children:["Hole Depth:"," ",v("span",{className:B.value,children:"".concat(P," ").concat(l("length"))})]})]})]})}export{O as default};
