import{s as e}from"./DrKWWDpL.js";import{t}from"./DYP3EJMY.js";import{a as n}from"./DOqzs8kl2.js";var r=e(t(),1),i=(0,r.promisify)(r.execFile);async function a(e){try{let{stdout:t}=await i(`git`,[`rev-parse`,`--show-toplevel`],{cwd:(0,r.resolve)(e)});return(0,r.resolve)(t.trim())}catch{return null}}async function o(e){try{let{stdout:t}=await i(`git`,[`remote`,`get-url`,`origin`],{cwd:(0,r.resolve)(e)});return t.trim()||null}catch{return null}}async function s(e){try{let t=await(0,r.readFile)((0,r.join)(e,`.cleo`,`project-info.json`),`utf8`),n=JSON.parse(t);return(typeof n.name==`string`?n.name:void 0)||void 0}catch{return}}async function c(e){let t=(0,r.resolve)(e),[n,i,c]=await Promise.all([a(t),o(t),(async()=>s(await a(t)||t))()]),l=n??t,u=[l,c??``,i??``].join(`|`);return{id:(0,r.createHash)(`sha256`).update(u).digest(`hex`).substring(0,12),components:{gitRoot:l,...c!==void 0&&{projectName:c},...i!=null&&{remoteUrl:i}}}}export{c as canonicalProjectId,o as findGitRemoteUrl,n as legacyProjectId};