import{s as e}from"./DrKWWDpL.js";import{t}from"./DYP3EJMY.js";import"./DIQmuJJZ.js";import"./CxlOpib82.js";import{r as n}from"./DVQI6VOy.js";import"./VsmLQChN.js";var r=e(t(),1);(0,r.promisify)(r.execFile);async function i(e,t){let r=(await(await n(e)).loadSessions()).filter(e=>e.status===`ended`&&e.endedAt);t&&(r=r.filter(e=>{if(t.type===`global`)return e.scope.type===`global`;let n=t.epicId??t.rootTaskId,r=e.scope.rootTaskId??e.scope.epicId;return e.scope.type===t.type&&r===n})),r.sort((e,t)=>new Date(t.endedAt).getTime()-new Date(e.endedAt).getTime());for(let e of r){if(typeof e.handoffJson==`string`)try{let t=JSON.parse(e.handoffJson);return{sessionId:e.id,handoff:t}}catch{}if(typeof e.debriefJson==`string`)try{let t=JSON.parse(e.debriefJson);if(t?.handoff)return{sessionId:e.id,handoff:t.handoff}}catch{}}return null}export{i as t};