function a(n){return n?.recordKind==="progress"}function u(n){let t=Number(n)||0;return t<=0?0:t<1e12?t*1e3:t}function d(n,t={}){let s=t.maxProgressAgeMs!=null&&Number.isFinite(t.maxProgressAgeMs)?Math.max(0,t.maxProgressAgeMs):21e5,e=typeof t.now=="number"?t.now:Date.now(),{summary:r,progress:i}=n||{};if(!i)return!1;let o=u(i.ts);if(s>0&&o>0&&e-o>s)return!1;if(!r)return o>0;let c=u(r.ts);return o>c}function l(n){let t=p(n),s=new Set;for(let[e,r]of t){if(!d(r))continue;let i=r.progress,o=String((i?.studioTestCaseId!=null&&String(i.studioTestCaseId).trim()!==""?i.studioTestCaseId:null)||e).trim();o&&s.add(o)}return[...s]}function p(n){let t=new Map;for(let s of n||[]){if(!s?.sessionId)continue;let e=t.get(s.sessionId);e||(e={summary:null,progress:null});let r=Number(s.ts)||0;a(s)?(!e.progress||r>=(Number(e.progress.ts)||0))&&(e.progress=s):(!e.summary||r>=(Number(e.summary.ts)||0))&&(e.summary=s),t.set(s.sessionId,e)}return t}function m(n){let{summary:t,progress:s}=n||{},e=t?{...t}:{},r=s&&Number(s.ts)||0,i=t&&Number(t.ts)||0;return s&&(!t||r>=i)&&(e.pipelineActiveNode=s.activeNode,e.pipelineStageIndex=s.activeStageIndex,e.runIndexProgressTs=s.ts,s.specRel!=null&&String(s.specRel).trim()!==""&&(e.specRel=s.specRel),s.taskDescription!=null&&String(s.taskDescription).trim()!==""&&(e.taskDescription=s.taskDescription),s.studioTestCaseId!=null&&s.studioTestCaseId!==""&&(e.studioTestCaseId=s.studioTestCaseId)),!t&&s&&(e.sessionId=s.sessionId,e.cwd=s.cwd,e.outputBase=s.outputBase,e.sessionPathAbs=s.sessionPathAbs,e.source=s.source,s.specRel!=null&&String(s.specRel).trim()!==""&&(e.specRel=s.specRel),s.taskDescription!=null&&String(s.taskDescription).trim()!==""&&(e.taskDescription=s.taskDescription)),t&&(e.runIndexSummaryTs=t.ts),e}export{l as listLiveRunIndexCorrelationIds,m as mergedRunIndexEntryForSession,p as partitionRunIndexBySession,d as runIndexSessionEntryIsLive};
