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