import{qe as i,re as Eq,se as a,te as fq,ue as g,ve as Fq}from"./cli-0.5.4-vx712nyx.mjs";import"./cli-0.5.4-nf79eb6z.mjs";import"./cli-0.5.4-mstdpmw9.mjs";import"./cli-0.5.4-bey1wxde.mjs";import"./cli-0.5.4-p0wkhwp2.mjs";import"./cli-0.5.4-ycyamscp.mjs";import"./cli-0.5.4-gw8qa07r.mjs";import{Aj as d,Bj as Uq,LO as l,OO as A,PO as b,QO as C,Qw as R,RO as n,Sw as _q,_O as t,aP as I,cP as o,eP as bq,kF as k,lF as Bq,yL as $,zL as Wq}from"./cli-0.5.4-k5fz4zd3.mjs";import"./cli-0.5.4-wbqf44ym.mjs";import"./cli-0.5.4-9ewg9gfs.mjs";import"./cli-0.5.4-we3mspgg.mjs";import"./cli-0.5.4-jzhazry0.mjs";import"./cli-0.5.4-82sw3hrw.mjs";import"./cli-0.5.4-31v143kt.mjs";import"./cli-0.5.4-1cy7wd6s.mjs";import"./cli-0.5.4-5e0pk96f.mjs";import"./cli-0.5.4-z154a7bp.mjs";import"./cli-0.5.4-ng5p0zjs.mjs";import"./cli-0.5.4-5hp7ks3t.mjs";import"./cli-0.5.4-8hdwp78f.mjs";import"./cli-0.5.4-mr9aznxx.mjs";import"./cli-0.5.4-jevfk5q7.mjs";import"./cli-0.5.4-27dzbzdy.mjs";import"./cli-0.5.4-a5bkdqqb.mjs";import"./cli-0.5.4-j2hnw539.mjs";import"./cli-0.5.4-9w59nnw4.mjs";import"./cli-0.5.4-z5d3q8kh.mjs";import"./cli-0.5.4-c0r12dqp.mjs";import"./cli-0.5.4-kqh172jk.mjs";import{AU as Oq,RU as u,UU as Vq,zU as m}from"./cli-0.5.4-vv4jbgkc.mjs";import{KW as T,MW as y,lV as c,pX as Hq,qV as Zq,rV as vq}from"./cli-0.5.4-s7k1f0wc.mjs";import"./cli-0.5.4-0h0yz2k5.mjs";import"./cli-0.5.4-942dm5q1.mjs";import"./cli-0.5.4-rcmp5h4y.mjs";import"./cli-0.5.4-xdcww3x8.mjs";import"./cli-0.5.4-fq32ny1h.mjs";import"./cli-0.5.4-h1m67ngp.mjs";import"./cli-0.5.4-49erze3e.mjs";import"./cli-0.5.4-jytjks37.mjs";import{PY as Y,QY as F,RY as P}from"./cli-0.5.4-mn22gk7g.mjs";import{SY as zq}from"./cli-0.5.4-5t3jj85n.mjs";import"./cli-0.5.4-5shjmmkz.mjs";import"./cli-0.5.4-zb412kkm.mjs";import"./cli-0.5.4-prfn3sxd.mjs";import"./cli-0.5.4-6xmgebmk.mjs";import"./cli-0.5.4-vjgejcrz.mjs";import"./cli-0.5.4-jqt00ywx.mjs";import"./cli-0.5.4-9e7rkd8e.mjs";import{X3 as p,Y3 as Yq}from"./cli-0.5.4-jp4wtw87.mjs";import"./cli-0.5.4-hambpq58.mjs";import"./cli-0.5.4-syvgmg9g.mjs";import"./cli-0.5.4-w8ttefr5.mjs";import"./cli-0.5.4-j7kkqxv6.mjs";import"./cli-0.5.4-qrwczx7j.mjs";import"./cli-0.5.4-v2z6p9td.mjs";import{B6 as j,J6 as Qq,K6 as L,L6 as Xq}from"./cli-0.5.4-cbq01zg3.mjs";import"./cli-0.5.4-37v5fhf1.mjs";import"./cli-0.5.4-7grzwf6q.mjs";import"./cli-0.5.4-9qmek5dq.mjs";import"./cli-0.5.4-9c6r1fjg.mjs";import"./cli-0.5.4-2dw33ms6.mjs";import"./cli-0.5.4-x1fzfxmm.mjs";import"./cli-0.5.4-e822fzaq.mjs";import"./cli-0.5.4-09dvrzcr.mjs";import"./cli-0.5.4-end8wj9r.mjs";import"./cli-0.5.4-4x206j04.mjs";import"./cli-0.5.4-yd3rd9qt.mjs";import"./cli-0.5.4-sgcaw17t.mjs";import{ima as Nq,ria as h,xia as w}from"./cli-0.5.4-jmc3bzbn.mjs";import"./cli-0.5.4-959vxhhb.mjs";import{Vma as D,Zma as Kq}from"./cli-0.5.4-aacw1src.mjs";function S(G){switch(G.resultType){case"sessionNotFound":return`Session ${p.bold(G.arg)} was not found.`;case"multipleMatches":return`Found ${G.count} sessions matching ${p.bold(G.arg)}. Please use /resume to pick a specific session.`}}function M(G){let q=r.c(10),{message:O,args:U,onDone:K}=G,_,V;if(q[0]!==K)_=()=>{let J=setTimeout(K,0);return()=>clearTimeout(J)},V=[K],q[0]=K,q[1]=_,q[2]=V;else _=q[1],V=q[2];Z.useEffect(_,V);let Q;if(q[3]!==U)Q=F(y,{dimColor:!0,children:[L.pointer," /resume ",U]}),q[3]=U,q[4]=Q;else Q=q[4];let z;if(q[5]!==O)z=Y(d,{children:Y(y,{children:O})}),q[5]=O,q[6]=z;else z=q[6];let N;if(q[7]!==Q||q[8]!==z)N=F(T,{flexDirection:"column",children:[Q,z]}),q[7]=Q,q[8]=z,q[9]=N;else N=q[9];return N}function yq({onDone:G,onResume:q}){let[O,U]=Z.useState([]),[K,_]=Z.useState([]),[V,Q]=Z.useState(!0),[z,N]=Z.useState(!1),[J,X]=Z.useState(!1),{rows:v}=m(),s=u(),f=Z.useCallback(async(H,B)=>{Q(!0);try{let E=H?await t():await I(B),W=Aq(E,h());if(W.length===0){G("No conversations found to resume");return}U(W)}catch(E){G("Failed to load conversations")}finally{Q(!1)}},[G]);Z.useEffect(()=>{async function H(){let B=await $(w());_(B),f(!1,B)}H()},[f]);let e=Z.useCallback(()=>{let H=!J;X(H),f(H,K)},[J,f,K]);async function qq(H){let B=R(A(H));if(!B){G("Failed to resume conversation");return}let E=b(H)?await C(H):H,W=g(E,J,K);if(W.isCrossProject){if(W.isSameRepoWorktree){N(!0),q(B,E,"slash_command_picker");return}let x=await c(W.command);if(x)process.stdout.write(x);let Jq=["","This conversation is from a different directory.","","To resume, run:",`  ${W.command}`,"","(Command copied to clipboard)",""].join(`
`);G(Jq,{display:"user"});return}N(!0),q(B,E,"slash_command_picker")}function Gq(){G("Resume cancelled",{display:"system"})}if(V)return F(T,{children:[Y(k,{}),Y(y,{children:" Loading conversations…"})]});if(z)return F(T,{children:[Y(k,{}),Y(y,{children:" Resuming conversation…"})]});return Y(i,{logs:O,maxHeight:s?Math.floor(v/2):v-2,onCancel:Gq,onSelect:qq,onLogsChanged:()=>f(J,K),showAllProjects:J,onToggleAllProjects:e,onAgenticSearch:a})}function Aq(G,q){return G.filter((O)=>!O.isSidechain&&A(O)!==q)}var r,Z,mq=async(G,q,O)=>{let U=async(N,J,X)=>{try{await q.resume?.(N,J,X),G(void 0,{display:"skip"})}catch(v){j(v),G(`Failed to resume: ${v.message}`)}},K=O?.trim();if(!K)return Y(yq,{onDone:G,onResume:U},Date.now());let _=await $(w()),V=await I(_);if(V.length===0)return Y(M,{message:"No conversations found to resume.",args:K,onDone:()=>G("No conversations found to resume.")});let Q=R(K);if(Q){let N=V.filter((X)=>A(X)===Q).sort((X,v)=>v.modified.getTime()-X.modified.getTime());if(N.length>0){let X=N[0],v=b(X)?await C(X):X;return U(Q,v,"slash_command_session_id"),null}let J=await n(Q);if(J)return U(Q,J,"slash_command_session_id"),null}if(l()){let N=await o(K,{exact:!0});if(N.length===1){let J=N[0],X=A(J);if(X){let v=b(J)?await C(J):J;return U(X,v,"slash_command_title"),null}}if(N.length>1){let J=S({resultType:"multipleMatches",arg:K,count:N.length});return Y(M,{message:J,args:K,onDone:()=>G(J)})}}let z=S({resultType:"sessionNotFound",arg:K});return Y(M,{message:z,args:K,onDone:()=>G(z)})};var Tq=Kq(()=>{Yq();Xq();Nq();Eq();Uq();Bq();Vq();Oq();Zq();Hq();fq();Fq();Wq();Qq();bq();_q();P();r=D(vq(),1),Z=D(zq(),1)});Tq();export{Aq as filterResumableSessions,mq as call};
