import e from"@babel/runtime/helpers/defineProperty";import o from"classnames";import{string as a,number as r,shape as i,bool as s}from"prop-types";import{useTheme as m}from"@material-ui/core";import l from"./ComparisonBar/ComparisonBar.js";import n from"./ComparisonTable.css.js";import{getUnitDisplay as c}from"../../utils/convert.js";import{getElemActualColor as t,getFormattedValue as p,getIsGreaterThanTenPercent as u,getDifference as d}from"../../utils/StageDesignVActualUtils.js";import{CHEMICALS_TYPES as h}from"../../constants/completion.js";import{jsxs as v,jsx as f}from"react/jsx-runtime";var C=function(a){var r=a.rowKey,i=a.label,s=a.elemKey,C=a.unitType,y=a.elemMax,N=a.summaries,w=a.showBar,g=a.viewMode,T=m(),b=N.designSummary,M=N.actualSummary,S=N.predictionSummary,j=b&&b[r],x=M&&M[r],A=S&&S[r],B=C?c(C):"",K=t(r,s);(s&&(j=j&&j[s]&&j[s].amount,x=x&&x[s]&&x[s].amount),"volumeChemicals"===r||"massChemicals"===r)&&(A=S[(h.find((function(e){return e.name===s}))||{}).key||null]);"flush_volume"===r&&(j=S?S.flush_volume_design:0);var R=A?(A-x)/A*100:"-",_=d(j,"calc"===g?A:x);return v("div",{className:o(n.comparisonRow,e({},n.comparisonRowLightTheme,T.isLightTheme)),children:[v("div",{className:n.comparisonNameCol,children:[i," ",B?"(".concat(B,")"):""]}),v("div",{className:n.comparisonDesignCol,children:[p(j),f("div",{className:n.comparisonSortIcon})]}),v("div",{"data-testid":"".concat("comparisonRow","_strapsColumn"),className:n.comparisonActualCol,children:[p(x),f("div",{className:n.comparisonSortIcon})]}),v("div",{className:n.comparisonActualCol,children:[p(A),f("div",{className:n.comparisonSortIcon})]}),f("div",{className:n.comparisonActualCol,children:p(R)}),f("div",{className:o(n.comparisonActualCol,e({},n.comparisonGreaterThanTenPercent,u(_))),children:_}),w&&f("div",{className:n.comparisonChartCol,children:(Number.isFinite(x)||Number.isFinite(j))&&f(l,{designVal:j,actualVal:x,designColor:"#eee",actualColor:K,elemMax:y})})]},"".concat(r).concat(s))};C.propTypes={rowKey:a.isRequired,label:a,elemKey:a,unitType:a,elemMax:r,summaries:i,showBar:s,viewMode:a},C.defaultProps={label:"",elemKey:"",unitType:"",elemMax:null,summaries:{},showBar:!0,viewMode:null};export{C as default};
