#!/usr/bin/env node

/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------------------------------------------*/

import{spawnSync as o}from"node:child_process";import{fileURLToPath as i}from"node:url";async function n(){for(const r of c())try{const t=i(import.meta.resolve(`@github/copilot-${r}-${process.arch}`)),s=o(t,process.argv.slice(2),{stdio:"inherit"});if(s.error)throw s.error;process.exit(s.status??1)}catch{}parseInt(process.versions.node.split(".")[0],10)<24&&(console.error(`GitHub Copilot CLI requires Node.js v24 or higher. Currently using v${process.versions.node}.`),process.exit(1));try{await import("./index.js")}catch(r){console.error("Failed to load GitHub Copilot CLI:",r),process.exit(1)}}n().catch(()=>{});function c(){return process.platform==="linux"?a()?["linuxmusl","linux"]:["linux"]:[process.platform]}function a(){if(process.platform!=="linux")return!1;try{const e=process.report?.getReport?.();return e?.header?.glibcVersionRuntime?!1:Array.isArray(e?.sharedObjects)?e.sharedObjects.some(r=>r.includes("libc.musl-")||r.includes("ld-musl-")):!0}catch{return!0}}
