import{set as t}from"lodash";import{COMPLETION_APP_TYPES as e,COMPLETION_MODES as n,COMPLETION_APPTYPE_MODES_DICT as a}from"../constants/completion.js";import{STREAM_SOURCE_TYPES as r,STREAM_STATUS as i}from"../constants/streamSourceType.js";var o=function(t,e,n){return t?"pad--".concat(t.current_pad_id||n):e?"well--".concat(e.id):"common"},s=function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.fracMultiWellApp,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s={};if(t){var u,c,l=(null===(u=t.pad_frac_fleets)||void 0===u||null===(c=u.find((function(t){return t.current})))||void 0===c?void 0:c.frac_fleet_lines)||[],_=o&&l.length;s={mode:_?n.padLine:a[i][0],selectedLine:_?l[0].id:void 0}}else r&&(s={mode:"custom",selectedAssets:[r.id]});return s},u=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.reduce((function(e,a){var o=(a.app_streams||[]).find((function(t){return t.source_type===r.FRAC&&(n||t.status===i.ACTIVE)}));return!o||!o.last_active_at||e&&e.last_frac_at>o.last_active_at?e:t(a,"last_frac_at",o.last_active_at)}),null)},c=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.reduce((function(e,a){var o=(a.app_streams||[]).find((function(t){return t.source_type===r.WIRELINE&&(n||t.status===i.ACTIVE)}));return!o||e&&e.last_wireline_at>o.last_active_at?e:t(a,"last_wireline_at",o.last_active_at)}),null)},l=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.reduce((function(e,a){var o=(a.app_streams||[]).find((function(t){return t.source_type===r.PUMPDOWN&&(n||t.status===i.ACTIVE)}));return!o||e&&e.last_pumpdown_at>o.last_active_at?e:t(a,"last_pumpdown_at",o.last_active_at)}),null)};export{o as getAssetKey,s as getDefaultPadModeSetting,u as resolveActiveFracAsset,l as resolveActivePumpdownAsset,c as resolveActiveWirelineAsset};
