"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),l=require("@babel/runtime/helpers/defineProperty"),t=require("react/jsx-runtime"),s=require("react"),i=require("lodash"),o=require("@material-ui/core"),r=require("../../../../constants.js"),a=require("../../../../stores/view-store/useViewStore.js");require("../../../../viewport/ViewportProvider.js");var n=require("../../../../viewport/useViewType.js"),c=require("../../cells/WellNameCell/WellNameCell.js"),u=require("../../cells/StatusCell/StatusCell.js"),m=require("../../cells/CompanyCell/CompanyCell.js"),d=require("../../cells/RigCell/RigCell.js"),C=require("../../cells/InterventionAssetCell/InterventionAssetCell.js"),p=require("../../cells/PadNameCell/PadNameCell.js"),y=require("../../cells/FormationCell/FormationCell.js"),b=require("../../cells/DistanceCell/DistanceCell.js"),f=require("../../cells/TaScoreCell/TaScoreCell.js"),h=require("../../cells/LastActiveCell/LastActiveCell.js"),w=require("../../cells/MetricsCells/MetricsCells.js"),S=require("../../cells/WellSectionCell/WellSectionCell.js"),j=require("../../useRowMemoizedMaps.js"),M=require("../../useRowInteractions.js"),W=require("./OffsetWellsTableRow.module.css.js"),v=require("../../../../../../utils/index.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=x(e),T=x(l),g=function(e,l){var t=i.get(e,r.ColumnType.distance);return"number"==typeof t&&Number.isFinite(t)?l?t:v.convertValue(t,"length","mi","km"):"—"},R=s.memo((function(e){var l=e.columnsWithDict,i=e.data,v=e.subjectWellId,x=e.metricsKeys,R=e.metricsColumns,N=e.handleChangeOffsetWell,O=e.wellNameStyle,k=e.wellNameWidth,I=e.isImperial,A=e.isLimitedOffsetWells,V=e.maxOffsetWellNumber,L=e.wellSections,D=e.setActiveWellId,P=e.onRowClick,E=e.taScores,F=e.isWellSectionColumnVisible,_=e.loadingWellIds,z=e.registerRow,K=n.useViewType().isMobile,H=a.useViewStore((function(e){return e.isWellNameExpand})),B=v===i.id,G=T.default({},W.subjectWellRow,B),J=null==l?void 0:l.some((function(e){return e.key===r.ColumnType.company})),Q=j.useRowMemoizedMaps({columnsWithDict:l,metricsColumns:R,taScores:E,wellSections:L}),U=Q.columnsMap,X=Q.metricsMap,Y=Q.taScoresMap,Z=Q.wellSectionsMap,$=Q.statusOptionsMap,ee=M.useRowInteractions({data:i,isLimitedOffsetWells:A,maxOffsetWellNumber:V,metricsKeys:x,isWellSectionColumnVisible:F,handleChangeOffsetWell:N,setActiveWellId:D,onRowClick:P,registerRow:z}),le=ee.isViewOnly,te=ee.isMapHidden,se=ee.isChecked,ie=ee.rowRef,oe=ee.handleChangeCheckbox,re=ee.checkboxTooltipText,ae=ee.lastCellColumn,ne=ee.handleMouseEnter,ce=ee.handleMouseLeave,ue=ee.handleRowClick,me=!1,de=i[r.ColumnType.name]||"—",Ce=de;if(!H&&2*k<8*de.length){var pe=function(e){var l=document.createElement("span");document.body.appendChild(l),l.style.font="Roboto",l.style.fontSize="14px",l.style.letterSpacing="0.01071em",l.style.height="auto",l.style.width="auto",l.style.position="absolute",l.style.whiteSpace="nowrap",l.innerHTML=e;var t=Math.ceil(l.clientWidth);return document.body.removeChild(l),t}(de);if(pe>2*k){var ye=2*k/(pe/de.length);Ce="".concat(de.substring(0,ye/2-2),"\n... ").concat(de.substring(de.length-ye/2+6)),me=!0}}var be=s.useMemo((function(){return i[r.ColumnType.wellSection]}),[i]);return t.jsxs(o.TableRow,{ref:ie,"data-testid":"".concat("OffsetWellsTableRow","_row_").concat(de),"data-well-id":i.id,className:W.bodyRow,title:te?void 0:"Click to show on map",onClick:ue,onMouseEnter:ne,onMouseLeave:ce,children:[t.jsx(c.WellNameCell,{data:i,isSubjectWell:B,borderStyle:G,wellNameStyle:O,isWellNameExpand:H,columnsMap:U,checkboxTooltipText:re,isViewOnly:le,isLimitedOffsetWells:A,isChecked:se,handleChangeCheckbox:oe,isOverFlowWellName:me,wellName:de,truncWellName:Ce}),t.jsx(u.StatusCell,{data:i,isSubjectWell:B,borderStyle:G,columnsMap:U,isMobile:K,statusOptionsMap:$}),J&&t.jsx(m.CompanyCell,{data:i,borderStyle:G,columnsMap:U}),U.has(r.ColumnType.interventionAsset)&&t.jsx(C.InterventionAssetCell,{data:i,borderStyle:G,columnsMap:U}),U.has(r.ColumnType.padName)&&t.jsx(p.PadNameCell,{data:i,borderStyle:G,columnsMap:U}),U.has(r.ColumnType.formation)&&t.jsx(y.FormationCell,{data:i,borderStyle:G,columnsMap:U}),U.has(r.ColumnType.rig)&&t.jsx(d.RigCell,{data:i,borderStyle:G,columnsMap:U}),U.has(r.ColumnType.distance)&&t.jsx(b.DistanceCell,{borderStyle:G,columnsMap:U,formattedDistance:g(i,I)}),!!E.length&&t.jsx(f.TaScoreCell,{data:i,borderStyle:G,columnsMap:U,taScoresMap:Y}),t.jsx(h.LastActiveCell,{data:i,borderStyle:G,columnsMap:U,lastCellColumn:ae}),t.jsx(w.MetricsCells,{data:i,metricsKeys:x,metricsMap:X,borderStyle:G,columnsMap:U,lastCellColumn:ae,loadingWellIds:_}),F&&t.jsx(S.WellSectionCell,{borderStyle:G,columnsMap:U,wellSectionData:be,getSectionColor:function(e){var l=q.default(e,1)[0];return Z.get(l)}})]})}));R.displayName="OffsetWellsTableRow",exports.OffsetWellsTableRow=R;
//# sourceMappingURL=OffsetWellsTableRow.js.map
