const n=(n,...t)=>new Promise(i=>require("child_process").execFile(n,t,{maxBuffer:8388608},(n,t)=>i(String(t||""))))
module.exports={getDarwinMainBundleIdHackAsync:async()=>{const t=await(async()=>{const[t,...i]=(await n("/bin/ps","x","-ww","-o","pid,ppid,comm")).split("\n")
const[s,e]=(n=>{let t=" "===n.charAt(0)
let i=2
const s=[]
for(let e=0,r=n.length;e<r;e++){if(t!==(" "===n.charAt(e))){t=!t
i--
if(0===i){s.push(e)
i=2}}}return s})(t)
const r={}
for(const n of i){if(!n)continue
const t=parseInt(n.slice(0,s))
const i=parseInt(n.slice(s,e))
const o=n.slice(e).trim()
r[t]={pid:t,ppid:i,comm:o}}return r})()
let i=t[process.pid]
for(;i&&1!==i.ppid;)i=t[i.ppid]
if(!i)throw new Error("missing mainProcessPid")
const s=i.comm.trim()
const e=s.slice(0,s.indexOf("/Contents/MacOS"))
const r=(await n("/usr/bin/defaults","read",`${e}/Contents/Info`,"CFBundleIdentifier")).trim()
if(!i)throw new Error("missing mainBundleId")
return r}}
