import{useMemo as e}from"react";import t from"lodash/get";import l from"lodash/isEmpty";import r from"lodash/sortBy";import{getAssetKey as n,getDefaultPadModeSetting as i}from"../utils/completion.js";import{COMPLETION_APP_TYPES as o}from"../constants/completion.js";function d(d){var f=d.padId,s=d.well,u=d.wells,a=d.fracFleet,c=d.settingsByAsset,v=function(e,r,d,f){var s=n(d,r,e);return l(t(f,[s]))?i(d,r,o.fracMultiWellApp,!0):t(f,[s])}(f,s,a,c),m=e((function(){var e,t;if(s)return[s];var l=(null===(e=null==a?void 0:a.pad_frac_fleets)||void 0===e?void 0:e.find((function(e){return e.pad.id===f||e.current})))||(null===(t=r(null==a?void 0:a.pad_frac_fleets,"last_current_at"))||void 0===t?void 0:t[0]),n=(null==l?void 0:l.frac_fleet_lines)||[];if(!n.length)return(null==u?void 0:u.length)?u:[];var i=v.selectedLine;if("custom"===v.mode){var o=v.selectedAssets[0],d=n.find((function(e){var t=e.frac_fleet_line_wells;return(void 0===t?[]:t).find((function(e){return+e.id===o}))}));i=null==d?void 0:d.id}var c=n.find((function(e){return e.id===i}))||n[0];return(null==c?void 0:c.frac_fleet_line_wells)||[]}),[v.mode,v.selectedLine,v.selectedAssets,null==a?void 0:a.pad_frac_fleets,f,s,u]);return m}export{d as default};
