/* Socket Lib - Built with esbuild */
var x=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var w=(t,r)=>{for(var e in r)x(t,e,{get:r[e],enumerable:!0})},S=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of k(r))!v.call(t,s)&&s!==e&&x(t,s,{get:()=>r[s],enumerable:!(i=P(r,s))||i.enumerable});return t};var b=t=>S(x({},"__esModule",{value:!0}),t);var z={};w(z,{clearDlx:()=>j,clearDlxSync:()=>E,dlxDirExists:()=>I,dlxDirExistsAsync:()=>q,ensureDlxDir:()=>A,ensureDlxDirSync:()=>F,getDlxInstalledPackageDir:()=>l,getDlxPackageDir:()=>p,getDlxPackageJsonPath:()=>L,getDlxPackageNodeModulesDir:()=>D,isDlxPackageInstalled:()=>_,isDlxPackageInstalledAsync:()=>$,isInSocketDlx:()=>X,listDlxPackages:()=>d,listDlxPackagesAsync:()=>m,removeDlxPackage:()=>h,removeDlxPackageSync:()=>y});module.exports=b(z);var o=require("node:fs"),u=require("./fs"),a=require("./path"),n=require("./paths"),g=require("./promises");let f;function c(){return f===void 0&&(f=require("node:path")),f}async function j(){const t=await m();await(0,g.pEach)(t,r=>h(r))}function E(){const t=d();for(const r of t)y(r)}function I(){return(0,o.existsSync)((0,n.getSocketDlxDir)())}async function q(){try{return await o.promises.access((0,n.getSocketDlxDir)()),!0}catch{return!1}}async function A(){await o.promises.mkdir((0,n.getSocketDlxDir)(),{recursive:!0})}function F(){const{mkdirSync:t}=require("node:fs");t((0,n.getSocketDlxDir)(),{recursive:!0})}function l(t){return(0,a.normalizePath)(c().join(D(t),t))}function p(t){return(0,a.normalizePath)(c().join((0,n.getSocketDlxDir)(),t))}function L(t){return(0,a.normalizePath)(c().join(l(t),"package.json"))}function D(t){return(0,a.normalizePath)(c().join(p(t),"node_modules"))}function X(t){if(!t)return!1;const r=c(),e=(0,n.getSocketDlxDir)();return r.resolve(t).startsWith(e+r.sep)}function _(t){return(0,o.existsSync)(l(t))}async function $(t){try{return await o.promises.access(l(t)),!0}catch{return!1}}function d(){try{return(0,u.readDirNamesSync)((0,n.getSocketDlxDir)(),{sort:!0})}catch{return[]}}async function m(){try{return(await o.promises.readdir((0,n.getSocketDlxDir)(),{withFileTypes:!0})).filter(r=>r.isDirectory()).map(r=>r.name).sort()}catch{return[]}}async function h(t){const r=p(t);try{await(0,u.safeDelete)(r,{recursive:!0,force:!0})}catch(e){throw new Error(`Failed to remove DLX package "${t}"`,{cause:e})}}function y(t){const{rmSync:r}=require("node:fs"),e=p(t);try{r(e,{recursive:!0,force:!0})}catch(i){throw new Error(`Failed to remove DLX package "${t}"`,{cause:i})}}0&&(module.exports={clearDlx,clearDlxSync,dlxDirExists,dlxDirExistsAsync,ensureDlxDir,ensureDlxDirSync,getDlxInstalledPackageDir,getDlxPackageDir,getDlxPackageJsonPath,getDlxPackageNodeModulesDir,isDlxPackageInstalled,isDlxPackageInstalledAsync,isInSocketDlx,listDlxPackages,listDlxPackagesAsync,removeDlxPackage,removeDlxPackageSync});
//# sourceMappingURL=dlx.js.map
