import{o as e}from"./errors-pXKbCKbL.js";import{r as t}from"./runner-DYk4q6mP.js";import{t as n}from"./utils-DMbpVz3Q.js";async function r(r,i){let{id:a,branch:o=`pr/${a}`,strategy:s,remote:c=`origin`}=r;if(s!==`git`&&await n())try{if((await t(`gh`,[`pr`,`checkout`,a],{cwd:i,throwOnError:!1})).success)return{success:!0,message:`Checked out PR #${a} using GitHub CLI`,details:{strategy:`gh`,branch:o}}}catch{}let l=`pull/${a}/head:${o}`,u=await t(`git`,[`fetch`,c,l],{cwd:i,throwOnError:!1});if(!u.success)throw new e(`git fetch ${c} ${l}`,u.stderr);let d=await t(`git`,[`switch`,o],{cwd:i,throwOnError:!1});if(!d.success)throw new e(`git switch ${o}`,d.stderr);return{success:!0,message:`Checked out PR #${a} to branch '${o}' using git`,details:{strategy:`git`,branch:o,remote:c}}}export{r as t};