Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`node:fs`),l=require(`node:path`);l=s(l);function u(e){try{return(0,c.statSync)(e).isFile()}catch{return!1}}function d(e,t){if(e.includes(`/`)||e.includes(`\\`)||l.default.isAbsolute(e))return e;let n=(t.PATH??t.Path??process.env.PATH??process.env.Path??``).split(`;`).map(e=>e.trim()).filter(Boolean),r=l.default.extname(e).length>0,i=t.PATHEXT??t.Pathext??process.env.PATHEXT??process.env.Pathext??`.EXE;.CMD;.BAT;.COM`,a=r?[``]:i.split(`;`).map(e=>e.trim()).filter(Boolean).map(e=>e.startsWith(`.`)?e:`.${e}`);for(let t of n)for(let n of a)for(let r of[n,n.toLowerCase(),n.toUpperCase()]){let n=l.default.join(t,`${e}${r}`);if(u(n))return n}return e}function f(e){if(!u(e))return null;try{let t=(0,c.readFileSync)(e,`utf8`),n=[];for(let r of t.matchAll(/"([^"\r\n]*)"/g)){let t=(r[1]??``).match(/%~?dp0%?\s*[\\/]*(.*)$/i)?.[1]?.trim();if(!t)continue;let i=t.replace(/[\\/]+/g,l.default.sep).replace(/^[\\/]+/,``),a=l.default.resolve(l.default.dirname(e),i);u(a)&&n.push(a)}return n.find(e=>{let t=l.default.basename(e).toLowerCase();return t!==`node.exe`&&t!==`node`})??null}catch{return null}}function p(e,t){if(typeof t==`string`)return t.trim()||null;if(!t||typeof t!=`object`)return null;if(e){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}for(let e of Object.values(t))if(typeof e==`string`&&e.trim())return e.trim();return null}function m(e,t){if(!t)return null;let n=l.default.dirname(e),r=[l.default.resolve(n,`..`,t),l.default.resolve(n,`node_modules`,t)];for(let e of r){let n=l.default.join(e,`package.json`);if(u(n))try{let r=p(t,JSON.parse((0,c.readFileSync)(n,`utf8`)).bin);if(!r)continue;let i=l.default.resolve(e,r);if(u(i))return i}catch{}}return null}function h(e){let t=e.platform??process.platform,n=e.env??process.env,r=e.execPath??process.execPath;if(t!==`win32`)return{command:e.command,leadingArgv:[],resolution:`direct`};let i=d(e.command,n),a=l.default.extname(i).toLowerCase();if(a===`.js`||a===`.cjs`||a===`.mjs`)return{command:r,leadingArgv:[i],resolution:`node-entrypoint`,windowsHide:!0};if(a===`.cmd`||a===`.bat`){let t=f(i)??m(i,e.packageName);return t?l.default.extname(t).toLowerCase()===`.exe`?{command:t,leadingArgv:[],resolution:`exe-entrypoint`,windowsHide:!0}:{command:r,leadingArgv:[t],resolution:`node-entrypoint`,windowsHide:!0}:{command:i,leadingArgv:[],resolution:`unresolved-wrapper`}}return{command:i,leadingArgv:[],resolution:`direct`}}function g(e){if(e.candidate.resolution!==`unresolved-wrapper`)return{command:e.candidate.command,leadingArgv:e.candidate.leadingArgv,resolution:e.candidate.resolution,windowsHide:e.candidate.windowsHide};if(e.allowShellFallback!==!1)return{command:e.candidate.command,leadingArgv:[],resolution:`shell-fallback`,shell:!0};throw Error(`${l.default.basename(e.candidate.command)} wrapper resolved, but no executable/Node entrypoint could be resolved without shell execution.`)}function _(e,t){return{command:e.command,argv:[...e.leadingArgv,...t],resolution:e.resolution,shell:e.shell,windowsHide:e.windowsHide}}exports.applyWindowsSpawnProgramPolicy=g,exports.materializeWindowsSpawnProgram=_,exports.resolveWindowsSpawnProgramCandidate=h;
