import{i as e}from"./errors-pXKbCKbL.js";import{r as t}from"./runner-DYk4q6mP.js";import{t as n}from"./utils-DMbpVz3Q.js";const r={chrome:{darwin:`Google Chrome`,linux:`google-chrome`,win32:`chrome`},safari:{darwin:`Safari`},firefox:{darwin:`Firefox`,linux:`firefox`,win32:`firefox`},arc:{darwin:`Arc`,win32:`Arc`},edge:{darwin:`Microsoft Edge`,linux:`microsoft-edge`,win32:`msedge`},dia:{darwin:`Dia`,linux:`dia`,win32:`dia`}};function i(e){let t=process.platform,n=r[e]?.[t];return n?t===`darwin`?`open -a "${n}"`:n:null}async function a(r,a){let{id:o,browser:s=`chrome`,openFlags:c=[]}=r;if(!await n())throw new e(`gh`,`Install GitHub CLI: https://cli.github.com/`);let l=i(s);if(!l)throw Error(`Browser "${s}" is not available on ${process.platform}. Supported browsers: chrome, safari (macOS only), firefox, arc, edge, dia`);let u={GH_BROWSER:l},d=await t(`gh`,[`pr`,`view`,o,`--web`,...c],{cwd:a,env:u,throwOnError:!1});if(!d.success)throw Error(`Failed to open PR #${o}: ${d.stderr}`);return{success:!0,message:`Opened PR #${o} in ${s}`,details:{id:o,browser:s,platform:process.platform}}}export{a as t};