(!jt||!jt.has(V.reference)){for(let Oi=0,$s=c.length;Oi<$s;++Oi){let jn=b(c[Oi]).packageDependencies.get(ve);if(jn!=null){t?fe=jn:le=jn;break}}if(r.enableTopLevelFallback&&le==null&&fe===null){let Oi=r.fallbackPool.get(ve);Oi!=null&&(fe=Oi)}}}let gt=null;if(le===null)if(v(V))gt=ai(ur.MISSING_PEER_DEPENDENCY,`Your application tried to access ${ve} (a peer dependency); this isn't allowed as there is no ancestor to satisfy the requirement. Use a devDependency if needed. Required package: ${ve}${ve!==he?` (via "${he}")`:""} Required by: ${Fe} `,{request:he,issuer:Fe,dependencyName:ve});else{let jt=ce(ve,V);jt.every(Qr=>v(Qr))?gt=ai(ur.MISSING_PEER_DEPENDENCY,`${V.name} tried to access ${ve} (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound. Required package: ${ve}${ve!==he?` (via "${he}")`:""} Required by: ${V.name}@${V.reference} (via ${Fe}) ${jt.map(Qr=>`Ancestor breaking the chain: ${Qr.name}@${Qr.reference} `).join("")} `,{request:he,issuer:Fe,issuerLocator:Object.assign({},V),dependencyName:ve,brokenAncestors:jt}):gt=ai(ur.MISSING_PEER_DEPENDENCY,`${V.name} tried to access ${ve} (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound. Required package: ${ve}${ve!==he?` (via "${he}")`:""} Required by: ${V.name}@${V.reference} (via ${Fe}) ${jt.map(Qr=>`Ancestor breaking the chain: ${Qr.name}@${Qr.reference} `).join("")} `,{request:he,issuer:Fe,issuerLocator:Object.assign({},V),dependencyName:ve,brokenAncestors:jt})}else le===void 0&&(!be&&rb(re)?v(V)?gt=ai(ur.UNDECLARED_DEPENDENCY,`Your application tried to access ${ve}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since ${ve} isn't otherwise declared in your dependencies, this makes the require call ambiguous and unsound. Required package: ${ve}${ve!==he?` (via "${he}")`:""} Required by: ${Fe} `,{request:he,issuer:Fe,dependencyName:ve}):gt=ai(ur.UNDECLARED_DEPENDENCY,`${V.name} tried to access ${ve}. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since ${ve} isn't otherwise declared in ${V.name}'s dependencies, this makes the require call ambiguous and unsound. Required package: ${ve}${ve!==he?` (via "${he}")`:""} Required by: ${Fe} `,{request:he,issuer:Fe,issuerLocator:Object.assign({},V),dependencyName:ve}):v(V)?gt=ai(ur.UNDECLARED_DEPENDENCY,`Your application tried to access ${ve}, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound. Required package: ${ve}${ve!==he?` (via "${he}")`:""} Required by: ${Fe} `,{request:he,issuer:Fe,dependencyName:ve}):gt=ai(ur.UNDECLARED_DEPENDENCY,`${V.name} tried to access ${ve}, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound. Required package: ${ve}${ve!==he?` (via "${he}")`:""} Required by: ${V.name}@${V.reference} (via ${Fe}) `,{request:he,issuer:Fe,issuerLocator:Object.assign({},V),dependencyName:ve}));if(le==null){if(fe===null||gt===null)throw gt||new Error("Assertion failed: Expected an error to have been set");le=fe;let jt=gt.message.replace(/\n.*/g,"");gt.message=jt,!u.has(jt)&&i!==0&&(u.add(jt),process.emitWarning(gt))}let Ht=Array.isArray(le)?{name:le[0],reference:le[1]}:{name:ve,reference:le},Mt=b(Ht);if(!Mt.packageLocation)throw ai(ur.MISSING_DEPENDENCY,`A dependency seems valid but didn't get installed for some reason. This might be caused by a partial install, such as dev vs prod. Required package: ${Ht.name}@${Ht.reference}${Ht.name!==he?` (via "${he}")`:""} Required by: ${V.name}@${V.reference} (via ${Fe}) `,{request:he,issuer:Fe,dependencyLocator:Object.assign({},Ht)});let Ei=Mt.packageLocation;pe?Ue=x.join(Ei,pe):Ue=Ei}else if(x.isAbsolute(re))Ue=x.normalize(re);else{if(!se)throw ai(ur.API_ERROR,"The resolveToUnqualified function must be called with a valid issuer when the path isn't a builtin nor absolute",{request:he,issuer:Fe});let ve=x.resolve(se);se.match(o)?Ue=x.normalize(x.join(ve,re)):Ue=x.normalize(x.join(x.dirname(ve),re))}return x.normalize(Ue)}function L(re,se,be=k){if(s.test(re))return se;let he=T(se,be);return he?x.normalize(he):se}function de(re,{extensions:se=Object.keys(Hm.Module._extensions)}={}){var Fe,Ue;let be=[],he=Y(re,be,{extensions:se});if(he)return x.normalize(he);{let xe=Qo(re),ve=Z(re);if(ve){let{packageLocation:pe}=b(ve),V=!0;try{e.fakeFs.accessSync(pe)}catch(Qe){if((Qe==null?void 0:Qe.code)==="ENOENT")V=!1;else{let le=((Ue=(Fe=Qe==null?void 0:Qe.message)!=null?Fe:Qe)!=null?Ue:"empty exception thrown").replace(/^[A-Z]/,fe=>fe.toLowerCase());throw ai(ur.QUALIFIED_PATH_RESOLUTION_FAILED,`Required package exists but could not be accessed (${le}). Missing package: ${ve.name}@${ve.reference} Expected package location: ${Qo(pe)} `,{unqualifiedPath:xe,extensions:se})}}if(!V){let Qe=pe.includes("/unplugged/")?"Required unplugged package missing from disk. This may happen when switching branches without running installs (unplugged packages must be fully materialized on disk to work).":"Required package missing from disk. If you keep your packages inside your repository then restarting the Node process may be enough. Otherwise, try to run an install first.";throw ai(ur.QUALIFIED_PATH_RESOLUTION_FAILED,`${Qe} Missing package: ${ve.name}@${ve.reference} Expected package location: ${Qo(pe)} `,{unqualifiedPath:xe,extensions:se})}}throw ai(ur.QUALIFIED_PATH_RESOLUTION_FAILED,`Qualified path resolution failed: we looked for the following paths, but none could be accessed. Source path: ${xe} ${be.map(pe=>`Not found: ${Qo(pe)} `).join("")}`,{unqualifiedPath:xe,extensions:se})}}function Be(re,se,{considerBuiltins:be,extensions:he,conditions:Fe}={}){try{let Ue=O(re,se,{considerBuiltins:be});if(re==="pnpapi")return Ue;if(Ue===null)return null;let xe=()=>se!==null?z(se):!1,ve=(!be||!rb(re))&&!xe()?L(re,Ue,Fe):Ue;return de(ve,{extensions:he})}catch(Ue){throw Object.prototype.hasOwnProperty.call(Ue,"pnpCode")&&Object.assign(Ue.data,{request:Qo(re),issuer:se&&Qo(se)}),Ue}}function Ge(re){let se=x.normalize(re),be=Wr.resolveVirtual(se);return be!==se?be:null}return{VERSIONS:ne,topLevel:ee,getLocator:(re,se)=>Array.isArray(se)?{name:se[0],reference:se[1]}:{name:re,reference:se},getDependencyTreeRoots:()=>[...r.dependencyTreeRoots],getAllLocators(){let re=[];for(let[se,be]of f)for(let he of be.keys())se!==null&&he!==null&&re.push({name:se,reference:he});return re},getPackageInformation:re=>{let se=A(re);if(se===null)return null;let be=H.fromPortablePath(se.packageLocation);return te(N({},se),{packageLocation:be})},findPackageLocator:re=>Z(H.toPortablePath(re)),resolveToUnqualified:y("resolveToUnqualified",(re,se,be)=>{let he=se!==null?H.toPortablePath(se):null,Fe=O(H.toPortablePath(re),he,be);return Fe===null?null:H.fromPortablePath(Fe)}),resolveUnqualified:y("resolveUnqualified",(re,se)=>H.fromPortablePath(de(H.toPortablePath(re),se))),resolveRequest:y("resolveRequest",(re,se,be)=>{let he=se!==null?H.toPortablePath(se):null,Fe=Be(H.toPortablePath(re),he,be);return Fe===null?null:H.fromPortablePath(Fe)}),resolveVirtual:y("resolveVirtual",re=>{let se=Ge(H.toPortablePath(re));return se!==null?H.fromPortablePath(se):null})}}var U0t=(0,OAe.promisify)(TAe.readFile);var MAe=(r,e,t)=>{let i=Km(r),n=vL(i,{basePath:e}),s=H.join(e,xt.pnpCjs);return xL(n,{fakeFs:t,pnpapiResolution:s})};var DL=ge(KAe());var ma={};ft(ma,{checkAndReportManifestCompatibility:()=>jAe,checkManifestCompatibility:()=>HAe,extractBuildScripts:()=>ib,getExtractHint:()=>RL,hasBindingGyp:()=>FL});function HAe(r){return P.isPackageCompatible(r,Xg.getArchitectureSet())}function jAe(r,e,{configuration:t,report:i}){return HAe(r)?!0:(i==null||i.reportWarningOnce(X.INCOMPATIBLE_ARCHITECTURE,`${P.prettyLocator(t,r)} The ${Xg.getArchitectureName()} architecture is incompatible with this package, ${e} skipped.`),!1)}function ib(r,e,t,{configuration:i,report:n}){let s=[];for(let a of["preinstall","install","postinstall"])e.manifest.scripts.has(a)&&s.push([cs.SCRIPT,a]);return!e.manifest.scripts.has("install")&&e.misc.hasBindingGyp&&s.push([cs.SHELLCODE,"node-gyp rebuild"]),s.length===0?[]:r.linkType!==Qt.HARD?(n==null||n.reportWarningOnce(X.SOFT_LINK_BUILD,`${P.prettyLocator(i,r)} lists build scripts, but is referenced through a soft link. Soft links don't support build scripts, so they'll be ignored.`),[]):t&&t.built===!1?(n==null||n.reportInfoOnce(X.BUILD_DISABLED,`${P.prettyLocator(i,r)} lists build scripts, but its build has been explicitly disabled through configuration.`),[]):!i.get("enableScripts")&&!t.built?(n==null||n.reportWarningOnce(X.DISABLED_BUILD_SCRIPTS,`${P.prettyLocator(i,r)} lists build scripts, but all build scripts have been disabled.`),[]):jAe(r,"build",{configuration:i,report:n})?s:[]}var fze=new Set([".exe",".h",".hh",".hpp",".c",".cc",".cpp",".java",".jar",".node"]);function RL(r){return r.packageFs.getExtractHint({relevantExtensions:fze})}function FL(r){let e=x.join(r.prefixPath,"binding.gyp");return r.packageFs.existsSync(e)}var NL={};ft(NL,{getUnpluggedPath:()=>jm});function jm(r,{configuration:e}){return x.resolve(e.get("pnpUnpluggedFolder"),P.slugifyLocator(r))}var hze=new Set([P.makeIdent(null,"nan").identHash,P.makeIdent(null,"node-gyp").identHash,P.makeIdent(null,"node-pre-gyp").identHash,P.makeIdent(null,"node-addon-api").identHash,P.makeIdent(null,"fsevents").identHash,P.makeIdent(null,"open").identHash,P.makeIdent(null,"opn").identHash]),xu=class{constructor(){this.mode="strict";this.pnpCache=new Map}supportsPackage(e,t){return this.isEnabled(t)}async findPackageLocation(e,t){if(!this.isEnabled(t))throw new Error("Assertion failed: Expected the PnP linker to be enabled");let i=Ol(t.project).cjs;if(!U.existsSync(i))throw new Pe(`The project in ${ae.pretty(t.project.configuration,`${t.project.cwd}/package.json`,ae.Type.PATH)} doesn't seem to have been installed - running an install there might help`);let n=Se.getFactoryWithDefault(this.pnpCache,i,()=>Se.dynamicRequire(i,{cachingStrategy:Se.CachingStrategy.FsTime})),s={name:P.stringifyIdent(e),reference:e.reference},o=n.getPackageInformation(s);if(!o)throw new Pe(`Couldn't find ${P.prettyLocator(t.project.configuration,e)} in the currently installed PnP map - running an install might help`);return H.toPortablePath(o.packageLocation)}async findPackageLocator(e,t){if(!this.isEnabled(t))return null;let i=Ol(t.project).cjs;if(!U.existsSync(i))return null;let s=Se.getFactoryWithDefault(this.pnpCache,i,()=>Se.dynamicRequire(i,{cachingStrategy:Se.CachingStrategy.FsTime})).findPackageLocator(H.fromPortablePath(e));return s?P.makeLocator(P.parseIdent(s.name),s.reference):null}makeInstaller(e){return new ah(e)}isEnabled(e){return!(e.project.configuration.get("nodeLinker")!=="pnp"||e.project.configuration.get("pnpMode")!==this.mode)}},ah=class{constructor(e){this.opts=e;this.mode="strict";this.asyncActions=new Se.AsyncActions(10);this.packageRegistry=new Map;this.virtualTemplates=new Map;this.isESMLoaderRequired=!1;this.customData={store:new Map};this.unpluggedPaths=new Set;this.opts=e}getCustomDataKey(){return JSON.stringify({name:"PnpInstaller",version:2})}attachCustomData(e){this.customData=e}async installPackage(e,t,i){let n=P.stringifyIdent(e),s=e.reference,o=!!this.opts.project.tryWorkspaceByLocator(e),a=P.isVirtualLocator(e),l=e.peerDependencies.size>0&&!a,c=!l&&!o,u=!l&&e.linkType!==Qt.SOFT,g,f;if(c||u){let k=a?P.devirtualizeLocator(e):e;g=this.customData.store.get(k.locatorHash),typeof g=="undefined"&&(g=await pze(t),e.linkType===Qt.HARD&&this.customData.store.set(k.locatorHash,g)),g.manifest.type==="module"&&(this.isESMLoaderRequired=!0),f=this.opts.project.getDependencyMeta(k,e.version)}let h=c?ib(e,g,f,{configuration:this.opts.project.configuration,report:this.opts.report}):[],p=u?await this.unplugPackageIfNeeded(e,g,t,f,i):t.packageFs;if(x.isAbsolute(t.prefixPath))throw new Error(`Assertion failed: Expected the prefix path (${t.prefixPath}) to be relative to the parent`);let m=x.resolve(p.getRealPath(),t.prefixPath),y=LL(this.opts.project.cwd,m),b=new Map,v=new Set;if(a){for(let k of e.peerDependencies.values())b.set(P.stringifyIdent(k),null),v.add(P.stringifyIdent(k));if(!o){let k=P.devirtualizeLocator(e);this.virtualTemplates.set(k.locatorHash,{location:LL(this.opts.project.cwd,Wr.resolveVirtual(m)),locator:k})}}return Se.getMapWithDefault(this.packageRegistry,n).set(s,{packageLocation:y,packageDependencies:b,packagePeers:v,linkType:e.linkType,discardFromLookup:t.discardFromLookup||!1}),{packageLocation:m,buildDirective:h.length>0?h:null}}async attachInternalDependencies(e,t){let i=this.getPackageInformation(e);for(let[n,s]of t){let o=P.areIdentsEqual(n,s)?s.reference:[P.stringifyIdent(s),s.reference];i.packageDependencies.set(P.stringifyIdent(n),o)}}async attachExternalDependents(e,t){for(let i of t)this.getDiskInformation(i).packageDependencies.set(P.stringifyIdent(e),e.reference)}async finalizeInstall(){if(this.opts.project.configuration.get("pnpMode")!==this.mode)return;let e=Ol(this.opts.project);if(U.existsSync(e.cjsLegacy)&&(this.opts.report.reportWarning(X.UNNAMED,`Removing the old ${ae.pretty(this.opts.project.configuration,xt.pnpJs,ae.Type.PATH)} file. You might need to manually update existing references to reference the new ${ae.pretty(this.opts.project.configuration,xt.pnpCjs,ae.Type.PATH)} file. If you use Editor SDKs, you'll have to rerun ${ae.pretty(this.opts.project.configuration,"yarn sdks",ae.Type.CODE)}.`),await U.removePromise(e.cjsLegacy)),this.isEsmEnabled()||await U.removePromise(e.esmLoader),this.opts.project.configuration.get("nodeLinker")!=="pnp"){await U.removePromise(e.cjs),await U.removePromise(this.opts.project.configuration.get("pnpDataPath")),await U.removePromise(e.esmLoader);return}for(let{locator:u,location:g}of this.virtualTemplates.values())Se.getMapWithDefault(this.packageRegistry,P.stringifyIdent(u)).set(u.reference,{packageLocation:g,packageDependencies:new Map,packagePeers:new Set,linkType:Qt.SOFT,discardFromLookup:!1});this.packageRegistry.set(null,new Map([[null,this.getPackageInformation(this.opts.project.topLevelWorkspace.anchoredLocator)]]));let t=this.opts.project.configuration.get("pnpFallbackMode"),i=this.opts.project.workspaces.map(({anchoredLocator:u})=>({name:P.stringifyIdent(u),reference:u.reference})),n=t!=="none",s=[],o=new Map,a=Se.buildIgnorePattern([".yarn/sdks/**",...this.opts.project.configuration.get("pnpIgnorePatterns")]),l=this.packageRegistry,c=this.opts.project.configuration.get("pnpShebang");if(t==="dependencies-only")for(let u of this.opts.project.storedPackages.values())this.opts.project.tryWorkspaceByLocator(u)&&s.push({name:P.stringifyIdent(u),reference:u.reference});return await this.asyncActions.wait(),await this.finalizeInstallWithPnp({dependencyTreeRoots:i,enableTopLevelFallback:n,fallbackExclusionList:s,fallbackPool:o,ignorePattern:a,packageRegistry:l,shebang:c}),{customData:this.customData}}async transformPnpSettings(e){}isEsmEnabled(){if(this.opts.project.configuration.sources.has("pnpEnableEsmLoader"))return this.opts.project.configuration.get("pnpEnableEsmLoader");if(this.isESMLoaderRequired)return!0;for(let e of this.opts.project.workspaces)if(e.manifest.type==="module")return!0;return!1}async finalizeInstallWithPnp(e){let t=Ol(this.opts.project),i=this.opts.project.configuration.get("pnpDataPath"),n=await this.locateNodeModules(e.ignorePattern);if(n.length>0){this.opts.report.reportWarning(X.DANGEROUS_NODE_MODULES,"One or more node_modules have been detected and will be removed. This operation may take some time.");for(let o of n)await U.removePromise(o)}if(await this.transformPnpSettings(e),this.opts.project.configuration.get("pnpEnableInlining")){let o=RAe(e);await U.changeFilePromise(t.cjs,o,{automaticNewlines:!0,mode:493}),await U.removePromise(i)}else{let o=x.relative(x.dirname(t.cjs),i),{dataFile:a,loaderFile:l}=FAe(te(N({},e),{dataLocation:o}));await U.changeFilePromise(t.cjs,l,{automaticNewlines:!0,mode:493}),await U.changeFilePromise(i,a,{automaticNewlines:!0,mode:420})}this.isEsmEnabled()&&(this.opts.report.reportWarning(X.UNNAMED,"ESM support for PnP uses the experimental loader API and is therefore experimental"),await U.changeFilePromise(t.esmLoader,(0,DL.default)(),{automaticNewlines:!0,mode:420}));let s=this.opts.project.configuration.get("pnpUnpluggedFolder");if(this.unpluggedPaths.size===0)await U.removePromise(s);else for(let o of await U.readdirPromise(s)){let a=x.resolve(s,o);this.unpluggedPaths.has(a)||await U.removePromise(a)}}async locateNodeModules(e){let t=[],i=e?new RegExp(e):null;for(let n of this.opts.project.workspaces){let s=x.join(n.cwd,"node_modules");if(i&&i.test(x.relative(this.opts.project.cwd,n.cwd))||!U.existsSync(s))continue;let o=await U.readdirPromise(s,{withFileTypes:!0}),a=o.filter(l=>!l.isDirectory()||l.name===".bin"||!l.name.startsWith("."));if(a.length===o.length)t.push(s);else for(let l of a)t.push(x.join(s,l.name))}return t}async unplugPackageIfNeeded(e,t,i,n,s){return this.shouldBeUnplugged(e,t,n)?this.unplugPackage(e,i,s):i.packageFs}shouldBeUnplugged(e,t,i){return typeof i.unplugged!="undefined"?i.unplugged:hze.has(e.identHash)||e.conditions!=null?!0:t.manifest.preferUnplugged!==null?t.manifest.preferUnplugged:!!(ib(e,t,i,{configuration:this.opts.project.configuration}).length>0||t.misc.extractHint)}async unplugPackage(e,t,i){let n=jm(e,{configuration:this.opts.project.configuration});return this.opts.project.disabledLocators.has(e.locatorHash)?new La(n,{baseFs:t.packageFs,pathUtils:x}):(this.unpluggedPaths.add(n),i.holdFetchResult(this.asyncActions.set(e.locatorHash,async()=>{let s=x.join(n,t.prefixPath,".ready");await U.existsPromise(s)||(this.opts.project.storedBuildState.delete(e.locatorHash),await U.mkdirPromise(n,{recursive:!0}),await U.copyPromise(n,Me.dot,{baseFs:t.packageFs,overwrite:!1}),await U.writeFilePromise(s,""))})),new _t(n))}getPackageInformation(e){let t=P.stringifyIdent(e),i=e.reference,n=this.packageRegistry.get(t);if(!n)throw new Error(`Assertion failed: The package information store should have been available (for ${P.prettyIdent(this.opts.project.configuration,e)})`);let s=n.get(i);if(!s)throw new Error(`Assertion failed: The package information should have been available (for ${P.prettyLocator(this.opts.project.configuration,e)})`);return s}getDiskInformation(e){let t=Se.getMapWithDefault(this.packageRegistry,"@@disk"),i=LL(this.opts.project.cwd,e);return Se.getFactoryWithDefault(t,i,()=>({packageLocation:i,packageDependencies:new Map,packagePeers:new Set,linkType:Qt.SOFT,discardFromLookup:!1}))}};function LL(r,e){let t=x.relative(r,e);return t.match(/^\.{0,2}\//)||(t=`./${t}`),t.replace(/\/?$/,"/")}async function pze(r){var i;let e=(i=await At.tryFind(r.prefixPath,{baseFs:r.packageFs}))!=null?i:new At,t=new Set(["preinstall","install","postinstall"]);for(let n of e.scripts.keys())t.has(n)||e.scripts.delete(n);return{manifest:{scripts:e.scripts,preferUnplugged:e.preferUnplugged,type:e.type},misc:{extractHint:RL(r),hasBindingGyp:FL(r)}}}var GAe=ge(ns());var Gm=class extends Le{constructor(){super(...arguments);this.all=J.Boolean("-A,--all",!1,{description:"Unplug direct dependencies from the entire project"});this.recursive=J.Boolean("-R,--recursive",!1,{description:"Unplug both direct and transitive dependencies"});this.json=J.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.patterns=J.Rest()}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),{project:t,workspace:i}=await ze.find(e,this.context.cwd),n=await Nt.find(e);if(!i)throw new ht(t.cwd,this.context.cwd);if(e.get("nodeLinker")!=="pnp")throw new Pe("This command can only be used if the `nodeLinker` option is set to `pnp`");await t.restoreInstallState();let s=new Set(this.patterns),o=this.patterns.map(f=>{let h=P.parseDescriptor(f),p=h.range!=="unknown"?h:P.makeDescriptor(h,"*");if(!Wt.validRange(p.range))throw new Pe(`The range of the descriptor patterns must be a valid semver range (${P.prettyDescriptor(e,p)})`);return m=>{let y=P.stringifyIdent(m);return!GAe.default.isMatch(y,P.stringifyIdent(p))||m.version&&!Wt.satisfiesWithPrereleases(m.version,p.range)?!1:(s.delete(f),!0)}}),a=()=>{let f=[];for(let h of t.storedPackages.values())!t.tryWorkspaceByLocator(h)&&!P.isVirtualLocator(h)&&o.some(p=>p(h))&&f.push(h);return f},l=f=>{let h=new Set,p=[],m=(y,b)=>{if(!h.has(y.locatorHash)&&(h.add(y.locatorHash),!t.tryWorkspaceByLocator(y)&&o.some(v=>v(y))&&p.push(y),!(b>0&&!this.recursive)))for(let v of y.dependencies.values()){let k=t.storedResolutions.get(v.descriptorHash);if(!k)throw new Error("Assertion failed: The resolution should have been registered");let T=t.storedPackages.get(k);if(!T)throw new Error("Assertion failed: The package should have been registered");m(T,b+1)}};for(let y of f){let b=t.storedPackages.get(y.anchoredLocator.locatorHash);if(!b)throw new Error("Assertion failed: The package should have been registered");m(b,0)}return p},c,u;if(this.all&&this.recursive?(c=a(),u="the project"):this.all?(c=l(t.workspaces),u="any workspace"):(c=l([i]),u="this workspace"),s.size>1)throw new Pe(`Patterns ${ae.prettyList(e,s,ae.Type.CODE)} don't match any packages referenced by ${u}`);if(s.size>0)throw new Pe(`Pattern ${ae.prettyList(e,s,ae.Type.CODE)} doesn't match any packages referenced by ${u}`);return c=Se.sortMap(c,f=>P.stringifyLocator(f)),(await Je.start({configuration:e,stdout:this.context.stdout,json:this.json},async f=>{var h;for(let p of c){let m=(h=p.version)!=null?h:"unknown",y=t.topLevelWorkspace.manifest.ensureDependencyMeta(P.makeDescriptor(p,m));y.unplugged=!0,f.reportInfo(X.UNNAMED,`Will unpack ${P.prettyLocator(e,p)} to ${ae.pretty(e,jm(p,{configuration:e}),ae.Type.PATH)}`),f.reportJson({locator:P.stringifyLocator(p),version:m})}await t.topLevelWorkspace.persistManifest(),f.reportSeparator(),await t.install({cache:n,report:f})})).exitCode()}};Gm.paths=[["unplug"]],Gm.usage=Re.Usage({description:"force the unpacking of a list of packages",details:"\n This command will add the selectors matching the specified patterns to the list of packages that must be unplugged when installed.\n\n A package being unplugged means that instead of being referenced directly through its archive, it will be unpacked at install time in the directory configured via `pnpUnpluggedFolder`. Note that unpacking packages this way is generally not recommended because it'll make it harder to store your packages within the repository. However, it's a good approach to quickly and safely debug some packages, and can even sometimes be required depending on the context (for example when the package contains shellscripts).\n\n Running the command will set a persistent flag inside your top-level `package.json`, in the `dependenciesMeta` field. As such, to undo its effects, you'll need to revert the changes made to the manifest and run `yarn install` to apply the modification.\n\n By default, only direct dependencies from the current workspace are affected. If `-A,--all` is set, direct dependencies from the entire project are affected. Using the `-R,--recursive` flag will affect transitive dependencies as well as direct ones.\n\n This command accepts glob patterns inside the scope and name components (not the range). Make sure to escape the patterns to prevent your own shell from trying to expand them.\n ",examples:[["Unplug the lodash dependency from the active workspace","yarn unplug lodash"],["Unplug all instances of lodash referenced by any workspace","yarn unplug lodash -A"],["Unplug all instances of lodash referenced by the active workspace and its dependencies","yarn unplug lodash -R"],["Unplug all instances of lodash, anywhere","yarn unplug lodash -AR"],["Unplug one specific version of lodash","yarn unplug lodash@1.2.3"],["Unplug all packages with the `@babel` scope","yarn unplug '@babel/*'"],["Unplug all packages (only for testing, not recommended)","yarn unplug -R '*'"]]});var YAe=Gm;var Ol=r=>({cjs:x.join(r.cwd,xt.pnpCjs),cjsLegacy:x.join(r.cwd,xt.pnpJs),esmLoader:x.join(r.cwd,".pnp.loader.mjs")}),WAe=r=>/\s/.test(r)?JSON.stringify(r):r;async function dze(r,e,t){let i=Ol(r),n=`--require ${WAe(H.fromPortablePath(i.cjs))}`;if(U.existsSync(i.esmLoader)&&(n=`${n} --experimental-loader ${(0,JAe.pathToFileURL)(H.fromPortablePath(i.esmLoader)).href}`),i.cjs.includes(" ")&&qAe.default.lt(process.versions.node,"12.0.0"))throw new Error(`Expected the build location to not include spaces when using Node < 12.0.0 (${process.versions.node})`);if(U.existsSync(i.cjs)){let s=e.NODE_OPTIONS||"",o=/\s*--require\s+\S*\.pnp\.c?js\s*/g,a=/\s*--experimental-loader\s+\S*\.pnp\.loader\.mjs\s*/;s=s.replace(o," ").replace(a," ").trim(),s=s?`${n} ${s}`:n,e.NODE_OPTIONS=s}}async function Cze(r,e){let t=Ol(r);e(t.cjs),e(t.esmLoader),e(r.configuration.get("pnpDataPath")),e(r.configuration.get("pnpUnpluggedFolder"))}var mze={hooks:{populateYarnPaths:Cze,setupScriptEnvironment:dze},configuration:{nodeLinker:{description:'The linker used for installing Node packages, one of: "pnp", "node-modules"',type:Ie.STRING,default:"pnp"},pnpMode:{description:"If 'strict', generates standard PnP maps. If 'loose', merges them with the n_m resolution.",type:Ie.STRING,default:"strict"},pnpShebang:{description:"String to prepend to the generated PnP script",type:Ie.STRING,default:"#!/usr/bin/env node"},pnpIgnorePatterns:{description:"Array of glob patterns; files matching them will use the classic resolution",type:Ie.STRING,default:[],isArray:!0},pnpEnableEsmLoader:{description:"If true, Yarn will generate an ESM loader (`.pnp.loader.mjs`). If this is not explicitly set Yarn tries to automatically detect whether ESM support is required.",type:Ie.BOOLEAN,default:!1},pnpEnableInlining:{description:"If true, the PnP data will be inlined along with the generated loader",type:Ie.BOOLEAN,default:!0},pnpFallbackMode:{description:"If true, the generated PnP loader will follow the top-level fallback rule",type:Ie.STRING,default:"dependencies-only"},pnpUnpluggedFolder:{description:"Folder where the unplugged packages must be stored",type:Ie.ABSOLUTE_PATH,default:"./.yarn/unplugged"},pnpDataPath:{description:"Path of the file where the PnP data (used by the loader) must be written",type:Ie.ABSOLUTE_PATH,default:"./.pnp.data.json"}},linkers:[xu],commands:[YAe]},Eze=mze;var $Ae=ge(ZAe());var HL=ge(require("crypto")),ele=ge(require("fs")),tle=1,jr="node_modules",nb=".bin",rle=".yarn-state.yml",Ti;(function(i){i.CLASSIC="classic",i.HARDLINKS_LOCAL="hardlinks-local",i.HARDLINKS_GLOBAL="hardlinks-global"})(Ti||(Ti={}));var jL=class{constructor(){this.installStateCache=new Map}supportsPackage(e,t){return this.isEnabled(t)}async findPackageLocation(e,t){if(!this.isEnabled(t))throw new Error("Assertion failed: Expected the node-modules linker to be enabled");let i=t.project.tryWorkspaceByLocator(e);if(i)return i.cwd;let n=await Se.getFactoryWithDefault(this.installStateCache,t.project.cwd,async()=>await GL(t.project,{unrollAliases:!0}));if(n===null)throw new Pe("Couldn't find the node_modules state file - running an install might help (findPackageLocation)");let s=n.locatorMap.get(P.stringifyLocator(e));if(!s){let a=new Pe(`Couldn't find ${P.prettyLocator(t.project.configuration,e)} in the currently installed node_modules map - running an install might help`);throw a.code="LOCATOR_NOT_INSTALLED",a}let o=t.project.configuration.startingCwd;return s.locations.find(a=>x.contains(o,a))||s.locations[0]}async findPackageLocator(e,t){if(!this.isEnabled(t))return null;let i=await Se.getFactoryWithDefault(this.installStateCache,t.project.cwd,async()=>await GL(t.project,{unrollAliases:!0}));if(i===null)return null;let{locationRoot:n,segments:s}=sb(x.resolve(e),{skipPrefix:t.project.cwd}),o=i.locationTree.get(n);if(!o)return null;let a=o.locator;for(let l of s){if(o=o.children.get(l),!o)break;a=o.locator||a}return P.parseLocator(a)}makeInstaller(e){return new ile(e)}isEnabled(e){return e.project.configuration.get("nodeLinker")==="node-modules"}},ile=class{constructor(e){this.opts=e;this.localStore=new Map;this.realLocatorChecksums=new Map;this.customData={store:new Map}}getCustomDataKey(){return JSON.stringify({name:"NodeModulesInstaller",version:2})}attachCustomData(e){this.customData=e}async installPackage(e,t){var u;let i=x.resolve(t.packageFs.getRealPath(),t.prefixPath),n=this.customData.store.get(e.locatorHash);if(typeof n=="undefined"&&(n=await Tze(e,t),e.linkType===Qt.HARD&&this.customData.store.set(e.locatorHash,n)),!P.isPackageCompatible(e,this.opts.project.configuration.getSupportedArchitectures()))return{packageLocation:null,buildDirective:null};let s=new Map,o=new Set;s.has(P.stringifyIdent(e))||s.set(P.stringifyIdent(e),e.reference);let a=e;if(P.isVirtualLocator(e)){a=P.devirtualizeLocator(e);for(let g of e.peerDependencies.values())s.set(P.stringifyIdent(g),null),o.add(P.stringifyIdent(g))}let l={packageLocation:`${H.fromPortablePath(i)}/`,packageDependencies:s,packagePeers:o,linkType:e.linkType,discardFromLookup:(u=t.discardFromLookup)!=null?u:!1};this.localStore.set(e.locatorHash,{pkg:e,customPackageData:n,dependencyMeta:this.opts.project.getDependencyMeta(e,e.version),pnpNode:l});let c=t.checksum?t.checksum.substring(t.checksum.indexOf("/")+1):null;return this.realLocatorChecksums.set(a.locatorHash,c),{packageLocation:i,buildDirective:null}}async attachInternalDependencies(e,t){let i=this.localStore.get(e.locatorHash);if(typeof i=="undefined")throw new Error("Assertion failed: Expected information object to have been registered");for(let[n,s]of t){let o=P.areIdentsEqual(n,s)?s.reference:[P.stringifyIdent(s),s.reference];i.pnpNode.packageDependencies.set(P.stringifyIdent(n),o)}}async attachExternalDependents(e,t){throw new Error("External dependencies haven't been implemented for the node-modules linker")}async finalizeInstall(){if(this.opts.project.configuration.get("nodeLinker")!=="node-modules")return;let e=new Wr({baseFs:new ys({libzip:await fn(),maxOpenFiles:80,readOnlyArchives:!0})}),t=await GL(this.opts.project),i=this.opts.project.configuration.get("nmMode");(t===null||i!==t.nmMode)&&(this.opts.project.storedBuildState.clear(),t={locatorMap:new Map,binSymlinks:new Map,locationTree:new Map,nmMode:i,mtimeMs:0});let n=new Map(this.opts.project.workspaces.map(f=>{var p,m;let h=this.opts.project.configuration.get("nmHoistingLimits");try{h=Se.validateEnum(Kn,(m=(p=f.manifest.installConfig)==null?void 0:p.hoistingLimits)!=null?m:h)}catch(y){let b=P.prettyWorkspace(this.opts.project.configuration,f);this.opts.report.reportWarning(X.INVALID_MANIFEST,`${b}: Invalid 'installConfig.hoistingLimits' value. Expected one of ${Object.values(Kn).join(", ")}, using default: "${h}"`)}return[f.relativeCwd,h]})),s=new Map(this.opts.project.workspaces.map(f=>{var p,m;let h=this.opts.project.configuration.get("nmSelfReferences");return h=(m=(p=f.manifest.installConfig)==null?void 0:p.selfReferences)!=null?m:h,[f.relativeCwd,h]})),o={VERSIONS:{std:1},topLevel:{name:null,reference:null},getLocator:(f,h)=>Array.isArray(h)?{name:h[0],reference:h[1]}:{name:f,reference:h},getDependencyTreeRoots:()=>this.opts.project.workspaces.map(f=>{let h=f.anchoredLocator;return{name:P.stringifyIdent(f.locator),reference:h.reference}}),getPackageInformation:f=>{let h=f.reference===null?this.opts.project.topLevelWorkspace.anchoredLocator:P.makeLocator(P.parseIdent(f.name),f.reference),p=this.localStore.get(h.locatorHash);if(typeof p=="undefined")throw new Error("Assertion failed: Expected the package reference to have been registered");return p.pnpNode},findPackageLocator:f=>{let h=this.opts.project.tryWorkspaceByCwd(H.toPortablePath(f));if(h!==null){let p=h.anchoredLocator;return{name:P.stringifyIdent(p),reference:p.reference}}throw new Error("Assertion failed: Unimplemented")},resolveToUnqualified:()=>{throw new Error("Assertion failed: Unimplemented")},resolveUnqualified:()=>{throw new Error("Assertion failed: Unimplemented")},resolveRequest:()=>{throw new Error("Assertion failed: Unimplemented")},resolveVirtual:f=>H.fromPortablePath(Wr.resolveVirtual(H.toPortablePath(f)))},{tree:a,errors:l,preserveSymlinksRequired:c}=Mm(o,{pnpifyFs:!1,validateExternalSoftLinks:!0,hoistingLimitsByCwd:n,project:this.opts.project,selfReferencesByCwd:s});if(!a){for(let{messageName:f,text:h}of l)this.opts.report.reportError(f,h);return}let u=bL(a);await Oze(t,u,{baseFs:e,project:this.opts.project,report:this.opts.report,realLocatorChecksums:this.realLocatorChecksums,loadManifest:async f=>{let h=P.parseLocator(f),p=this.localStore.get(h.locatorHash);if(typeof p=="undefined")throw new Error("Assertion failed: Expected the slot to exist");return p.customPackageData.manifest}});let g=[];for(let[f,h]of u.entries()){if(nle(f))continue;let p=P.parseLocator(f),m=this.localStore.get(p.locatorHash);if(typeof m=="undefined")throw new Error("Assertion failed: Expected the slot to exist");if(this.opts.project.tryWorkspaceByLocator(m.pkg))continue;let y=ma.extractBuildScripts(m.pkg,m.customPackageData,m.dependencyMeta,{configuration:this.opts.project.configuration,report:this.opts.report});y.length!==0&&g.push({buildLocations:h.locations,locatorHash:p.locatorHash,buildDirective:y})}return c&&this.opts.report.reportWarning(X.NM_PRESERVE_SYMLINKS_REQUIRED,`The application uses portals and that's why ${ae.pretty(this.opts.project.configuration,"--preserve-symlinks",ae.Type.CODE)} Node option is required for launching it`),{customData:this.customData,records:g}}};async function Tze(r,e){var n;let t=(n=await At.tryFind(e.prefixPath,{baseFs:e.packageFs}))!=null?n:new At,i=new Set(["preinstall","install","postinstall"]);for(let s of t.scripts.keys())i.has(s)||t.scripts.delete(s);return{manifest:{bin:t.bin,scripts:t.scripts},misc:{extractHint:ma.getExtractHint(e),hasBindingGyp:ma.hasBindingGyp(e)}}}async function Mze(r,e,t,i,{installChangedByUser:n}){let s="";s+=`# Warning: This file is automatically generated. Removing it is fine, but will `,s+=`# cause your node_modules installation to become invalidated. `,s+=` `,s+=`__metadata: `,s+=` version: ${tle} `,s+=` nmMode: ${i.value} `;let o=Array.from(e.keys()).sort(),a=P.stringifyLocator(r.topLevelWorkspace.anchoredLocator);for(let u of o){let g=e.get(u);s+=` `,s+=`${JSON.stringify(u)}: `,s+=` locations: `;for(let f of g.locations){let h=x.contains(r.cwd,f);if(h===null)throw new Error(`Assertion failed: Expected the path to be within the project (${f})`);s+=` - ${JSON.stringify(h)} `}if(g.aliases.length>0){s+=` aliases: `;for(let f of g.aliases)s+=` - ${JSON.stringify(f)} `}if(u===a&&t.size>0){s+=` bin: `;for(let[f,h]of t){let p=x.contains(r.cwd,f);if(p===null)throw new Error(`Assertion failed: Expected the path to be within the project (${f})`);s+=` ${JSON.stringify(p)}: `;for(let[m,y]of h){let b=x.relative(x.join(f,jr),y);s+=` ${JSON.stringify(m)}: ${JSON.stringify(b)} `}}}}let l=r.cwd,c=x.join(l,jr,rle);n&&await U.removePromise(c),await U.changeFilePromise(c,s,{automaticNewlines:!0})}async function GL(r,{unrollAliases:e=!1}={}){let t=r.cwd,i=x.join(t,jr,rle),n;try{n=await U.statPromise(i)}catch(c){}if(!n)return null;let s=Si(await U.readFilePromise(i,"utf8"));if(s.__metadata.version>tle)return null;let o=s.__metadata.nmMode||Ti.CLASSIC,a=new Map,l=new Map;delete s.__metadata;for(let[c,u]of Object.entries(s)){let g=u.locations.map(h=>x.join(t,h)),f=u.bin;if(f)for(let[h,p]of Object.entries(f)){let m=x.join(t,H.toPortablePath(h)),y=Se.getMapWithDefault(l,m);for(let[b,v]of Object.entries(p))y.set(Jr(b),H.toPortablePath([m,jr,v].join(x.sep)))}if(a.set(c,{target:Me.dot,linkType:Qt.HARD,locations:g,aliases:u.aliases||[]}),e&&u.aliases)for(let h of u.aliases){let{scope:p,name:m}=P.parseLocator(c),y=P.makeLocator(P.makeIdent(p,m),h),b=P.stringifyLocator(y);a.set(b,{target:Me.dot,linkType:Qt.HARD,locations:g,aliases:[]})}}return{locatorMap:a,binSymlinks:l,locationTree:sle(a,{skipPrefix:r.cwd}),nmMode:o,mtimeMs:n.mtimeMs}}var lh=async(r,e)=>{if(r.split(x.sep).indexOf(jr)<0)throw new Error(`Assertion failed: trying to remove dir that doesn't contain node_modules: ${r}`);try{if(!e.innerLoop){let i=e.allowSymlink?await U.statPromise(r):await U.lstatPromise(r);if(e.allowSymlink&&!i.isDirectory()||!e.allowSymlink&&i.isSymbolicLink()){await U.unlinkPromise(r);return}}let t=await U.readdirPromise(r,{withFileTypes:!0});for(let i of t){let n=x.join(r,Jr(i.name));i.isDirectory()?(i.name!==jr||e&&e.innerLoop)&&await lh(n,{innerLoop:!0,contentsOnly:!1}):await U.unlinkPromise(n)}e.contentsOnly||await U.rmdirPromise(r)}catch(t){if(t.code!=="ENOENT"&&t.code!=="ENOTEMPTY")throw t}},ole=4,sb=(r,{skipPrefix:e})=>{let t=x.contains(e,r);if(t===null)throw new Error(`Assertion failed: Writing attempt prevented to ${r} which is outside project root: ${e}`);let i=t.split(x.sep).filter(l=>l!==""),n=i.indexOf(jr),s=i.slice(0,n).join(x.sep),o=x.join(e,s),a=i.slice(n);return{locationRoot:o,segments:a}},sle=(r,{skipPrefix:e})=>{let t=new Map;if(r===null)return t;let i=()=>({children:new Map,linkType:Qt.HARD});for(let[n,s]of r.entries()){if(s.linkType===Qt.SOFT&&x.contains(e,s.target)!==null){let a=Se.getFactoryWithDefault(t,s.target,i);a.locator=n,a.linkType=s.linkType}for(let o of s.locations){let{locationRoot:a,segments:l}=sb(o,{skipPrefix:e}),c=Se.getFactoryWithDefault(t,a,i);for(let u=0;u{let t;try{process.platform==="win32"&&(t=await U.lstatPromise(r))}catch(i){}process.platform=="win32"&&(!t||t.isDirectory())?await U.symlinkPromise(r,e,"junction"):await U.symlinkPromise(x.relative(x.dirname(e),r),e)};async function ale(r,e,t){let i=x.join(r,Jr(`${HL.default.randomBytes(16).toString("hex")}.tmp`));try{await U.writeFilePromise(i,t);try{await U.linkPromise(i,e)}catch(n){}}finally{await U.unlinkPromise(i)}}async function Uze({srcPath:r,dstPath:e,srcMode:t,globalHardlinksStore:i,baseFs:n,nmMode:s,digest:o}){if(s.value===Ti.HARDLINKS_GLOBAL&&i&&o){let l=x.join(i,o.substring(0,2),`${o.substring(2)}.dat`),c;try{if(await Rn.checksumFile(l,{baseFs:U,algorithm:"sha1"})!==o){let g=x.join(i,Jr(`${HL.default.randomBytes(16).toString("hex")}.tmp`));await U.renamePromise(l,g);let f=await n.readFilePromise(r);await U.writeFilePromise(g,f);try{await U.linkPromise(g,l),await U.unlinkPromise(g)}catch(h){}}await U.linkPromise(l,e),c=!0}catch(u){c=!1}if(!c){let u=await n.readFilePromise(r);await ale(i,l,u);try{await U.linkPromise(l,e)}catch(g){g&&g.code&&g.code=="EXDEV"&&(s.value=Ti.HARDLINKS_LOCAL,await n.copyFilePromise(r,e))}}}else await n.copyFilePromise(r,e);let a=t&511;a!==420&&await U.chmodPromise(e,a)}var Ml;(function(i){i.FILE="file",i.DIRECTORY="directory",i.SYMLINK="symlink"})(Ml||(Ml={}));var Kze=async(r,e,{baseFs:t,globalHardlinksStore:i,nmMode:n,packageChecksum:s})=>{await U.mkdirPromise(r,{recursive:!0});let o=async(l=Me.dot)=>{let c=x.join(e,l),u=await t.readdirPromise(c,{withFileTypes:!0}),g=new Map;for(let f of u){let h=x.join(l,f.name),p,m=x.join(c,f.name);if(f.isFile()){if(p={kind:Ml.FILE,mode:(await t.lstatPromise(m)).mode},n.value===Ti.HARDLINKS_GLOBAL){let y=await Rn.checksumFile(m,{baseFs:t,algorithm:"sha1"});p.digest=y}}else if(f.isDirectory())p={kind:Ml.DIRECTORY};else if(f.isSymbolicLink())p={kind:Ml.SYMLINK,symlinkTo:await t.readlinkPromise(m)};else throw new Error(`Unsupported file type (file: ${m}, mode: 0o${await t.statSync(m).mode.toString(8).padStart(6,"0")})`);if(g.set(h,p),f.isDirectory()&&h!==jr){let y=await o(h);for(let[b,v]of y)g.set(b,v)}}return g},a;if(n.value===Ti.HARDLINKS_GLOBAL&&i&&s){let l=x.join(i,s.substring(0,2),`${s.substring(2)}.json`);try{a=new Map(Object.entries(JSON.parse(await U.readFilePromise(l,"utf8"))))}catch(c){a=await o(),await ale(i,l,Buffer.from(JSON.stringify(Object.fromEntries(a))))}}else a=await o();for(let[l,c]of a){let u=x.join(e,l),g=x.join(r,l);c.kind===Ml.DIRECTORY?await U.mkdirPromise(g,{recursive:!0}):c.kind===Ml.FILE?await Uze({srcPath:u,dstPath:g,srcMode:c.mode,digest:c.digest,nmMode:n,baseFs:t,globalHardlinksStore:i}):c.kind===Ml.SYMLINK&&await YL(x.resolve(x.dirname(g),c.symlinkTo),g)}};function Hze(r,e,t,i){let n=new Map,s=new Map,o=new Map,a=!1,l=(c,u,g,f,h)=>{let p=!0,m=x.join(c,u),y=new Set;if(u===jr||u.startsWith("@")){let v;try{v=U.statSync(m)}catch(T){}p=!!v,v?v.mtimeMs>t?(a=!0,y=new Set(U.readdirSync(m))):y=new Set(g.children.get(u).children.keys()):a=!0;let k=e.get(c);if(k){let T=x.join(c,jr,nb),Y;try{Y=U.statSync(T)}catch(q){}if(!Y)a=!0;else if(Y.mtimeMs>t){a=!0;let q=new Set(U.readdirSync(T)),$=new Map;s.set(c,$);for(let[z,ne]of k)q.has(z)&&$.set(z,ne)}else s.set(c,k)}}else p=h.has(u);let b=g.children.get(u);if(p){let{linkType:v,locator:k}=b,T={children:new Map,linkType:v,locator:k};if(f.children.set(u,T),k){let Y=Se.getSetWithDefault(o,k);Y.add(m),o.set(k,Y)}for(let Y of b.children.keys())l(m,Y,b,T,y)}else b.locator&&i.storedBuildState.delete(P.parseLocator(b.locator).locatorHash)};for(let[c,u]of r){let{linkType:g,locator:f}=u,h={children:new Map,linkType:g,locator:f};if(n.set(c,h),f){let p=Se.getSetWithDefault(o,u.locator);p.add(c),o.set(u.locator,p)}u.children.has(jr)&&l(c,jr,u,h,new Set)}return{locationTree:n,binSymlinks:s,locatorLocations:o,installChangedByUser:a}}function nle(r){let e=P.parseDescriptor(r);return P.isVirtualDescriptor(e)&&(e=P.devirtualizeDescriptor(e)),e.range.startsWith("link:")}async function jze(r,e,t,{loadManifest:i}){let n=new Map;for(let[a,{locations:l}]of r){let c=nle(a)?null:await i(a,l[0]),u=new Map;if(c)for(let[g,f]of c.bin){let h=x.join(l[0],f);f!==""&&U.existsSync(h)&&u.set(g,f)}n.set(a,u)}let s=new Map,o=(a,l,c)=>{let u=new Map,g=x.contains(t,a);if(c.locator&&g!==null){let f=n.get(c.locator);for(let[h,p]of f){let m=x.join(a,H.toPortablePath(p));u.set(Jr(h),m)}for(let[h,p]of c.children){let m=x.join(a,h),y=o(m,m,p);y.size>0&&s.set(a,new Map([...s.get(a)||new Map,...y]))}}else for(let[f,h]of c.children){let p=o(x.join(a,f),l,h);for(let[m,y]of p)u.set(m,y)}return u};for(let[a,l]of e){let c=o(a,a,l);c.size>0&&s.set(a,new Map([...s.get(a)||new Map,...c]))}return s}var Ale=(r,e)=>{if(!r||!e)return r===e;let t=P.parseLocator(r);P.isVirtualLocator(t)&&(t=P.devirtualizeLocator(t));let i=P.parseLocator(e);return P.isVirtualLocator(i)&&(i=P.devirtualizeLocator(i)),P.areLocatorsEqual(t,i)};function qL(r){return x.join(r.get("globalFolder"),"store")}async function Oze(r,e,{baseFs:t,project:i,report:n,loadManifest:s,realLocatorChecksums:o}){let a=x.join(i.cwd,jr),{locationTree:l,binSymlinks:c,locatorLocations:u,installChangedByUser:g}=Hze(r.locationTree,r.binSymlinks,r.mtimeMs,i),f=sle(e,{skipPrefix:i.cwd}),h=[],p=async({srcDir:z,dstDir:ne,linkType:ee,globalHardlinksStore:A,nmMode:oe,packageChecksum:ce})=>{let Z=(async()=>{try{ee===Qt.SOFT?(await U.mkdirPromise(x.dirname(ne),{recursive:!0}),await YL(x.resolve(z),ne)):await Kze(ne,z,{baseFs:t,globalHardlinksStore:A,nmMode:oe,packageChecksum:ce})}catch(O){throw O.message=`While persisting ${z} -> ${ne} ${O.message}`,O}finally{T.tick()}})().then(()=>h.splice(h.indexOf(Z),1));h.push(Z),h.length>ole&&await Promise.race(h)},m=async(z,ne,ee)=>{let A=(async()=>{let oe=async(ce,Z,O)=>{try{O.innerLoop||await U.mkdirPromise(Z,{recursive:!0});let L=await U.readdirPromise(ce,{withFileTypes:!0});for(let de of L){if(!O.innerLoop&&de.name===nb)continue;let Be=x.join(ce,de.name),Ge=x.join(Z,de.name);de.isDirectory()?(de.name!==jr||O&&O.innerLoop)&&(await U.mkdirPromise(Ge,{recursive:!0}),await oe(Be,Ge,te(N({},O),{innerLoop:!0}))):$.value===Ti.HARDLINKS_LOCAL||$.value===Ti.HARDLINKS_GLOBAL?await U.linkPromise(Be,Ge):await U.copyFilePromise(Be,Ge,ele.default.constants.COPYFILE_FICLONE)}}catch(L){throw O.innerLoop||(L.message=`While cloning ${ce} -> ${Z} ${L.message}`),L}finally{O.innerLoop||T.tick()}};await oe(z,ne,ee)})().then(()=>h.splice(h.indexOf(A),1));h.push(A),h.length>ole&&await Promise.race(h)},y=async(z,ne,ee)=>{if(ee)for(let[A,oe]of ne.children){let ce=ee.children.get(A);await y(x.join(z,A),oe,ce)}else{ne.children.has(jr)&&await lh(x.join(z,jr),{contentsOnly:!1});let A=x.basename(z)===jr&&f.has(x.join(x.dirname(z),x.sep));await lh(z,{contentsOnly:z===a,allowSymlink:A})}};for(let[z,ne]of l){let ee=f.get(z);for(let[A,oe]of ne.children){if(A===".")continue;let ce=ee&&ee.children.get(A),Z=x.join(z,A);await y(Z,oe,ce)}}let b=async(z,ne,ee)=>{if(ee){Ale(ne.locator,ee.locator)||await lh(z,{contentsOnly:ne.linkType===Qt.HARD});for(let[A,oe]of ne.children){let ce=ee.children.get(A);await b(x.join(z,A),oe,ce)}}else{ne.children.has(jr)&&await lh(x.join(z,jr),{contentsOnly:!0});let A=x.basename(z)===jr&&f.has(x.join(x.dirname(z),x.sep));await lh(z,{contentsOnly:ne.linkType===Qt.HARD,allowSymlink:A})}};for(let[z,ne]of f){let ee=l.get(z);for(let[A,oe]of ne.children){if(A===".")continue;let ce=ee&&ee.children.get(A);await b(x.join(z,A),oe,ce)}}let v=new Map,k=[];for(let[z,ne]of u)for(let ee of ne){let{locationRoot:A,segments:oe}=sb(ee,{skipPrefix:i.cwd}),ce=f.get(A),Z=A;if(ce){for(let O of oe)if(Z=x.join(Z,O),ce=ce.children.get(O),!ce)break;if(ce){let O=Ale(ce.locator,z),L=e.get(ce.locator),de=L.target,Be=Z,Ge=L.linkType;if(O)v.has(de)||v.set(de,Be);else if(de!==Be){let re=P.parseLocator(ce.locator);P.isVirtualLocator(re)&&(re=P.devirtualizeLocator(re)),k.push({srcDir:de,dstDir:Be,linkType:Ge,realLocatorHash:re.locatorHash})}}}}for(let[z,{locations:ne}]of e.entries())for(let ee of ne){let{locationRoot:A,segments:oe}=sb(ee,{skipPrefix:i.cwd}),ce=l.get(A),Z=f.get(A),O=A,L=e.get(z),de=P.parseLocator(z);P.isVirtualLocator(de)&&(de=P.devirtualizeLocator(de));let Be=de.locatorHash,Ge=L.target,re=ee;if(Ge===re)continue;let se=L.linkType;for(let be of oe)Z=Z.children.get(be);if(!ce)k.push({srcDir:Ge,dstDir:re,linkType:se,realLocatorHash:Be});else for(let be of oe)if(O=x.join(O,be),ce=ce.children.get(be),!ce){k.push({srcDir:Ge,dstDir:re,linkType:se,realLocatorHash:Be});break}}let T=Ji.progressViaCounter(k.length),Y=n.reportProgress(T),q=i.configuration.get("nmMode"),$={value:q};try{let z=$.value===Ti.HARDLINKS_GLOBAL?`${qL(i.configuration)}/v1`:null;if(z&&!await U.existsPromise(z)){await U.mkdirpPromise(z);for(let ee=0;ee<256;ee++)await U.mkdirPromise(x.join(z,ee.toString(16).padStart(2,"0")))}for(let ee of k)(ee.linkType===Qt.SOFT||!v.has(ee.srcDir))&&(v.set(ee.srcDir,ee.dstDir),await p(te(N({},ee),{globalHardlinksStore:z,nmMode:$,packageChecksum:o.get(ee.realLocatorHash)||null})));await Promise.all(h),h.length=0;for(let ee of k){let A=v.get(ee.srcDir);ee.linkType!==Qt.SOFT&&ee.dstDir!==A&&await m(A,ee.dstDir,{nmMode:$})}await Promise.all(h),await U.mkdirPromise(a,{recursive:!0});let ne=await jze(e,f,i.cwd,{loadManifest:s});await Gze(c,ne,i.cwd),await Mze(i,e,ne,$,{installChangedByUser:g}),q==Ti.HARDLINKS_GLOBAL&&$.value==Ti.HARDLINKS_LOCAL&&n.reportWarningOnce(X.NM_HARDLINKS_MODE_DOWNGRADED,"'nmMode' has been downgraded to 'hardlinks-local' due to global cache and install folder being on different devices")}finally{Y.stop()}}async function Gze(r,e,t){for(let i of r.keys()){if(x.contains(t,i)===null)throw new Error(`Assertion failed. Excepted bin symlink location to be inside project dir, instead it was at ${i}`);if(!e.has(i)){let n=x.join(i,jr,nb);await U.removePromise(n)}}for(let[i,n]of e){if(x.contains(t,i)===null)throw new Error(`Assertion failed. Excepted bin symlink location to be inside project dir, instead it was at ${i}`);let s=x.join(i,jr,nb),o=r.get(i)||new Map;await U.mkdirPromise(s,{recursive:!0});for(let a of o.keys())n.has(a)||(await U.removePromise(x.join(s,a)),process.platform==="win32"&&await U.removePromise(x.join(s,Jr(`${a}.cmd`))));for(let[a,l]of n){let c=o.get(a),u=x.join(s,a);c!==l&&(process.platform==="win32"?await(0,$Ae.default)(H.fromPortablePath(l),H.fromPortablePath(u),{createPwshFile:!1}):(await U.removePromise(u),await YL(l,u),x.contains(t,await U.realpathPromise(l))!==null&&await U.chmodPromise(l,493)))}}}var JL=class extends xu{constructor(){super(...arguments);this.mode="loose"}makeInstaller(e){return new lle(e)}},lle=class extends ah{constructor(){super(...arguments);this.mode="loose"}async transformPnpSettings(e){let t=new Wr({baseFs:new ys({libzip:await fn(),maxOpenFiles:80,readOnlyArchives:!0})}),i=MAe(e,this.opts.project.cwd,t),{tree:n,errors:s}=Mm(i,{pnpifyFs:!1,project:this.opts.project});if(!n){for(let{messageName:u,text:g}of s)this.opts.report.reportError(u,g);return}let o=new Map;e.fallbackPool=o;let a=(u,g)=>{let f=P.parseLocator(g.locator),h=P.stringifyIdent(f);h===u?o.set(u,f.reference):o.set(u,[h,f.reference])},l=x.join(this.opts.project.cwd,xt.nodeModules),c=n.get(l);if(typeof c!="undefined"){if("target"in c)throw new Error("Assertion failed: Expected the root junction point to be a directory");for(let u of c.dirList){let g=x.join(l,u),f=n.get(g);if(typeof f=="undefined")throw new Error("Assertion failed: Expected the child to have been registered");if("target"in f)a(u,f);else for(let h of f.dirList){let p=x.join(g,h),m=n.get(p);if(typeof m=="undefined")throw new Error("Assertion failed: Expected the subchild to have been registered");if("target"in m)a(`${u}/${h}`,m);else throw new Error("Assertion failed: Expected the leaf junction to be a package")}}}}};var Yze={hooks:{cleanGlobalArtifacts:async r=>{let e=qL(r);await U.removePromise(e)}},configuration:{nmHoistingLimits:{description:"Prevent packages to be hoisted past specific levels",type:Ie.STRING,values:[Kn.WORKSPACES,Kn.DEPENDENCIES,Kn.NONE],default:Kn.NONE},nmMode:{description:'If set to "hardlinks-local" Yarn will utilize hardlinks to reduce disk space consumption inside "node_modules" directories. With "hardlinks-global" Yarn will use global content addressable storage to reduce "node_modules" size across all the projects using this option.',type:Ie.STRING,values:[Ti.CLASSIC,Ti.HARDLINKS_LOCAL,Ti.HARDLINKS_GLOBAL],default:Ti.CLASSIC},nmSelfReferences:{description:"If set to 'false' the workspace will not be allowed to require itself and corresponding self-referencing symlink will not be created",type:Ie.BOOLEAN,default:!0}},linkers:[jL,JL]},qze=Yze;var JT={};ft(JT,{default:()=>$9e,npmConfigUtils:()=>br,npmHttpUtils:()=>zt,npmPublishUtils:()=>Bh});var hle=ge(ri());var Cr="npm:";var zt={};ft(zt,{AuthType:()=>us,customPackageError:()=>zze,del:()=>Xze,get:()=>So,getIdentUrl:()=>Kl,handleInvalidAuthenticationError:()=>Ul,post:()=>_ze,put:()=>Vze});var gle=ge(zC()),fle=ge(require("url"));var br={};ft(br,{RegistryType:()=>SA,getAuditRegistry:()=>Jze,getAuthConfiguration:()=>_L,getDefaultRegistry:()=>ob,getPublishRegistry:()=>cle,getRegistryConfiguration:()=>ule,getScopeConfiguration:()=>zL,getScopeRegistry:()=>vA,normalizeRegistry:()=>Ea});var SA;(function(i){i.AUDIT_REGISTRY="npmAuditRegistry",i.FETCH_REGISTRY="npmRegistryServer",i.PUBLISH_REGISTRY="npmPublishRegistry"})(SA||(SA={}));function Ea(r){return r.replace(/\/$/,"")}function Jze(r,{configuration:e}){let t=e.get(SA.AUDIT_REGISTRY);return t!==null?Ea(t):cle(r,{configuration:e})}function cle(r,{configuration:e}){var t;return((t=r.publishConfig)==null?void 0:t.registry)?Ea(r.publishConfig.registry):r.name?vA(r.name.scope,{configuration:e,type:SA.PUBLISH_REGISTRY}):ob({configuration:e,type:SA.PUBLISH_REGISTRY})}function vA(r,{configuration:e,type:t=SA.FETCH_REGISTRY}){let i=zL(r,{configuration:e});if(i===null)return ob({configuration:e,type:t});let n=i.get(t);return n===null?ob({configuration:e,type:t}):Ea(n)}function ob({configuration:r,type:e=SA.FETCH_REGISTRY}){let t=r.get(e);return Ea(t!==null?t:r.get(SA.FETCH_REGISTRY))}function ule(r,{configuration:e}){let t=e.get("npmRegistries"),i=Ea(r),n=t.get(i);if(typeof n!="undefined")return n;let s=t.get(i.replace(/^[a-z]+:/,""));return typeof s!="undefined"?s:null}function zL(r,{configuration:e}){if(r===null)return null;let i=e.get("npmScopes").get(r);return i||null}function _L(r,{configuration:e,ident:t}){let i=t&&zL(t.scope,{configuration:e});return(i==null?void 0:i.get("npmAuthIdent"))||(i==null?void 0:i.get("npmAuthToken"))?i:ule(r,{configuration:e})||e}var us;(function(n){n[n.NO_AUTH=0]="NO_AUTH",n[n.BEST_EFFORT=1]="BEST_EFFORT",n[n.CONFIGURATION=2]="CONFIGURATION",n[n.ALWAYS_AUTH=3]="ALWAYS_AUTH"})(us||(us={}));async function Ul(r,{attemptedAs:e,registry:t,headers:i,configuration:n}){var s,o;if(ab(r))throw new ct(X.AUTHENTICATION_INVALID,"Invalid OTP token");if(((s=r.originalError)==null?void 0:s.name)==="HTTPError"&&((o=r.originalError)==null?void 0:o.response.statusCode)===401)throw new ct(X.AUTHENTICATION_INVALID,`Invalid authentication (${typeof e!="string"?`as ${await Wze(t,i,{configuration:n})}`:`attempted as ${e}`})`)}function zze(r){var e;return((e=r.response)==null?void 0:e.statusCode)===404?"Package not found":null}function Kl(r){return r.scope?`/@${r.scope}%2f${r.name}`:`/${r.name}`}async function So(r,a){var l=a,{configuration:e,headers:t,ident:i,authType:n,registry:s}=l,o=Or(l,["configuration","headers","ident","authType","registry"]);if(i&&typeof s=="undefined"&&(s=vA(i.scope,{configuration:e})),i&&i.scope&&typeof n=="undefined"&&(n=1),typeof s!="string")throw new Error("Assertion failed: The registry should be a string");let c=await Ab(s,{authType:n,configuration:e,ident:i});c&&(t=te(N({},t),{authorization:c}));try{return await ir.get(r.charAt(0)==="/"?`${s}${r}`:r,N({configuration:e,headers:t},o))}catch(u){throw await Ul(u,{registry:s,configuration:e,headers:t}),u}}async function _ze(r,e,u){var g=u,{attemptedAs:t,configuration:i,headers:n,ident:s,authType:o=3,registry:a,otp:l}=g,c=Or(g,["attemptedAs","configuration","headers","ident","authType","registry","otp"]);if(s&&typeof a=="undefined"&&(a=vA(s.scope,{configuration:i})),typeof a!="string")throw new Error("Assertion failed: The registry should be a string");let f=await Ab(a,{authType:o,configuration:i,ident:s});f&&(n=te(N({},n),{authorization:f})),l&&(n=N(N({},n),ch(l)));try{return await ir.post(a+r,e,N({configuration:i,headers:n},c))}catch(h){if(!ab(h)||l)throw await Ul(h,{attemptedAs:t,registry:a,configuration:i,headers:n}),h;l=await VL();let p=N(N({},n),ch(l));try{return await ir.post(`${a}${r}`,e,N({configuration:i,headers:p},c))}catch(m){throw await Ul(m,{attemptedAs:t,registry:a,configuration:i,headers:n}),m}}}async function Vze(r,e,u){var g=u,{attemptedAs:t,configuration:i,headers:n,ident:s,authType:o=3,registry:a,otp:l}=g,c=Or(g,["attemptedAs","configuration","headers","ident","authType","registry","otp"]);if(s&&typeof a=="undefined"&&(a=vA(s.scope,{configuration:i})),typeof a!="string")throw new Error("Assertion failed: The registry should be a string");let f=await Ab(a,{authType:o,configuration:i,ident:s});f&&(n=te(N({},n),{authorization:f})),l&&(n=N(N({},n),ch(l)));try{return await ir.put(a+r,e,N({configuration:i,headers:n},c))}catch(h){if(!ab(h))throw await Ul(h,{attemptedAs:t,registry:a,configuration:i,headers:n}),h;l=await VL();let p=N(N({},n),ch(l));try{return await ir.put(`${a}${r}`,e,N({configuration:i,headers:p},c))}catch(m){throw await Ul(m,{attemptedAs:t,registry:a,configuration:i,headers:n}),m}}}async function Xze(r,c){var u=c,{attemptedAs:e,configuration:t,headers:i,ident:n,authType:s=3,registry:o,otp:a}=u,l=Or(u,["attemptedAs","configuration","headers","ident","authType","registry","otp"]);if(n&&typeof o=="undefined"&&(o=vA(n.scope,{configuration:t})),typeof o!="string")throw new Error("Assertion failed: The registry should be a string");let g=await Ab(o,{authType:s,configuration:t,ident:n});g&&(i=te(N({},i),{authorization:g})),a&&(i=N(N({},i),ch(a)));try{return await ir.del(o+r,N({configuration:t,headers:i},l))}catch(f){if(!ab(f)||a)throw await Ul(f,{attemptedAs:e,registry:o,configuration:t,headers:i}),f;a=await VL();let h=N(N({},i),ch(a));try{return await ir.del(`${o}${r}`,N({configuration:t,headers:h},l))}catch(p){throw await Ul(p,{attemptedAs:e,registry:o,configuration:t,headers:i}),p}}}async function Ab(r,{authType:e=2,configuration:t,ident:i}){let n=_L(r,{configuration:t,ident:i}),s=Zze(n,e);if(!s)return null;let o=await t.reduceHook(a=>a.getNpmAuthenticationHeader,void 0,r,{configuration:t,ident:i});if(o)return o;if(n.get("npmAuthToken"))return`Bearer ${n.get("npmAuthToken")}`;if(n.get("npmAuthIdent")){let a=n.get("npmAuthIdent");return a.includes(":")?`Basic ${Buffer.from(a).toString("base64")}`:`Basic ${a}`}if(s&&e!==1)throw new ct(X.AUTHENTICATION_NOT_FOUND,"No authentication configured for request");return null}function Zze(r,e){switch(e){case 2:return r.get("npmAlwaysAuth");case 1:case 3:return!0;case 0:return!1;default:throw new Error("Unreachable")}}async function Wze(r,e,{configuration:t}){var i;if(typeof e=="undefined"||typeof e.authorization=="undefined")return"an anonymous user";try{return(i=(await ir.get(new fle.URL(`${r}/-/whoami`).href,{configuration:t,headers:e,jsonResponse:!0})).username)!=null?i:"an unknown user"}catch{return"an unknown user"}}async function VL(){if(process.env.TEST_ENV)return process.env.TEST_NPM_2FA_TOKEN||"";let{otp:r}=await(0,gle.prompt)({type:"password",name:"otp",message:"One-time password:",required:!0,onCancel:()=>process.exit(130)});return r}function ab(r){var e,t;if(((e=r.originalError)==null?void 0:e.name)!=="HTTPError")return!1;try{return((t=r.originalError)==null?void 0:t.response.headers["www-authenticate"].split(/,\s*/).map(n=>n.toLowerCase())).includes("otp")}catch(i){return!1}}function ch(r){return{["npm-otp"]:r}}var XL=class{supports(e,t){if(!e.reference.startsWith(Cr))return!1;let{selector:i,params:n}=P.parseRange(e.reference);return!(!hle.default.valid(i)||n===null||typeof n.__archiveUrl!="string")}getLocalPath(e,t){return null}async fetch(e,t){let i=t.checksums.get(e.locatorHash)||null,[n,s,o]=await t.cache.fetchPackageFromCache(e,i,N({onHit:()=>t.report.reportCacheHit(e),onMiss:()=>t.report.reportCacheMiss(e,`${P.prettyLocator(t.project.configuration,e)} can't be found in the cache and will be fetched from the remote server`),loader:()=>this.fetchFromNetwork(e,t),skipIntegrityCheck:t.skipIntegrityCheck},t.cacheOptions));return{packageFs:n,releaseFs:s,prefixPath:P.getIdentVendorPath(e),checksum:o}}async fetchFromNetwork(e,t){let{params:i}=P.parseRange(e.reference);if(i===null||typeof i.__archiveUrl!="string")throw new Error("Assertion failed: The archiveUrl querystring parameter should have been available");let n=await So(i.__archiveUrl,{configuration:t.project.configuration,ident:e});return await Bi.convertToZip(n,{compressionLevel:t.project.configuration.get("compressionLevel"),prefixPath:P.getIdentVendorPath(e),stripComponents:1})}};var ZL=class{supportsDescriptor(e,t){return!(!e.range.startsWith(Cr)||!P.tryParseDescriptor(e.range.slice(Cr.length),!0))}supportsLocator(e,t){return!1}shouldPersistResolution(e,t){throw new Error("Unreachable")}bindDescriptor(e,t,i){return e}getResolutionDependencies(e,t){let i=P.parseDescriptor(e.range.slice(Cr.length),!0);return t.resolver.getResolutionDependencies(i,t)}async getCandidates(e,t,i){let n=P.parseDescriptor(e.range.slice(Cr.length),!0);return await i.resolver.getCandidates(n,t,i)}async getSatisfying(e,t,i){let n=P.parseDescriptor(e.range.slice(Cr.length),!0);return i.resolver.getSatisfying(n,t,i)}resolve(e,t){throw new Error("Unreachable")}};var ple=ge(ri()),dle=ge(require("url"));var vo=class{supports(e,t){if(!e.reference.startsWith(Cr))return!1;let i=new dle.URL(e.reference);return!(!ple.default.valid(i.pathname)||i.searchParams.has("__archiveUrl"))}getLocalPath(e,t){return null}async fetch(e,t){let i=t.checksums.get(e.locatorHash)||null,[n,s,o]=await t.cache.fetchPackageFromCache(e,i,N({onHit:()=>t.report.reportCacheHit(e),onMiss:()=>t.report.reportCacheMiss(e,`${P.prettyLocator(t.project.configuration,e)} can't be found in the cache and will be fetched from the remote registry`),loader:()=>this.fetchFromNetwork(e,t),skipIntegrityCheck:t.skipIntegrityCheck},t.cacheOptions));return{packageFs:n,releaseFs:s,prefixPath:P.getIdentVendorPath(e),checksum:o}}async fetchFromNetwork(e,t){let i;try{i=await So(vo.getLocatorUrl(e),{configuration:t.project.configuration,ident:e})}catch(n){i=await So(vo.getLocatorUrl(e).replace(/%2f/g,"/"),{configuration:t.project.configuration,ident:e})}return await Bi.convertToZip(i,{compressionLevel:t.project.configuration.get("compressionLevel"),prefixPath:P.getIdentVendorPath(e),stripComponents:1})}static isConventionalTarballUrl(e,t,{configuration:i}){let n=vA(e.scope,{configuration:i}),s=vo.getLocatorUrl(e);return t=t.replace(/^https?:(\/\/(?:[^/]+\.)?npmjs.org(?:$|\/))/,"https:$1"),n=n.replace(/^https:\/\/registry\.npmjs\.org($|\/)/,"https://registry.yarnpkg.com$1"),t=t.replace(/^https:\/\/registry\.npmjs\.org($|\/)/,"https://registry.yarnpkg.com$1"),t===n+s||t===n+s.replace(/%2f/g,"/")}static getLocatorUrl(e){let t=Wt.clean(e.reference.slice(Cr.length));if(t===null)throw new ct(X.RESOLVER_NOT_FOUND,"The npm semver resolver got selected, but the version isn't semver");return`${Kl(e)}/-/${e.name}-${t}.tgz`}};var Cle=ge(ri());var lb=P.makeIdent(null,"node-gyp"),$ze=/\b(node-gyp|prebuild-install)\b/,$L=class{supportsDescriptor(e,t){return e.range.startsWith(Cr)?!!Wt.validRange(e.range.slice(Cr.length)):!1}supportsLocator(e,t){if(!e.reference.startsWith(Cr))return!1;let{selector:i}=P.parseRange(e.reference);return!!Cle.default.valid(i)}shouldPersistResolution(e,t){return!0}bindDescriptor(e,t,i){return e}getResolutionDependencies(e,t){return[]}async getCandidates(e,t,i){let n=Wt.validRange(e.range.slice(Cr.length));if(n===null)throw new Error(`Expected a valid range, got ${e.range.slice(Cr.length)}`);let s=await So(Kl(e),{configuration:i.project.configuration,ident:e,jsonResponse:!0}),o=Se.mapAndFilter(Object.keys(s.versions),c=>{try{let u=new Wt.SemVer(c);if(n.test(u))return u}catch{}return Se.mapAndFilter.skip}),a=o.filter(c=>!s.versions[c.raw].deprecated),l=a.length>0?a:o;return l.sort((c,u)=>-c.compare(u)),l.map(c=>{let u=P.makeLocator(e,`${Cr}${c.raw}`),g=s.versions[c.raw].dist.tarball;return vo.isConventionalTarballUrl(u,g,{configuration:i.project.configuration})?u:P.bindLocator(u,{__archiveUrl:g})})}async getSatisfying(e,t,i){let n=Wt.validRange(e.range.slice(Cr.length));if(n===null)throw new Error(`Expected a valid range, got ${e.range.slice(Cr.length)}`);return Se.mapAndFilter(t,s=>{try{let{selector:o}=P.parseRange(s,{requireProtocol:Cr}),a=new Wt.SemVer(o);if(n.test(a))return{reference:s,version:a}}catch{}return Se.mapAndFilter.skip}).sort((s,o)=>-s.version.compare(o.version)).map(({reference:s})=>P.makeLocator(e,s))}async resolve(e,t){let{selector:i}=P.parseRange(e.reference),n=Wt.clean(i);if(n===null)throw new ct(X.RESOLVER_NOT_FOUND,"The npm semver resolver got selected, but the version isn't semver");let s=await So(Kl(e),{configuration:t.project.configuration,ident:e,jsonResponse:!0});if(!Object.prototype.hasOwnProperty.call(s,"versions"))throw new ct(X.REMOTE_INVALID,'Registry returned invalid data for - missing "versions" field');if(!Object.prototype.hasOwnProperty.call(s.versions,n))throw new ct(X.REMOTE_NOT_FOUND,`Registry failed to return reference "${n}"`);let o=new At;if(o.load(s.versions[n]),!o.dependencies.has(lb.identHash)&&!o.peerDependencies.has(lb.identHash)){for(let a of o.scripts.values())if(a.match($ze)){o.dependencies.set(lb.identHash,P.makeDescriptor(lb,"latest")),t.report.reportWarningOnce(X.NODE_GYP_INJECTED,`${P.prettyLocator(t.project.configuration,e)}: Implicit dependencies on node-gyp are discouraged`);break}}if(typeof o.raw.deprecated=="string"&&o.raw.deprecated!==""){let a=P.prettyLocator(t.project.configuration,e),l=o.raw.deprecated.match(/\S/)?`${a} is deprecated: ${o.raw.deprecated}`:`${a} is deprecated`;t.report.reportWarningOnce(X.DEPRECATED_PACKAGE,l)}return te(N({},e),{version:n,languageName:"node",linkType:Qt.HARD,conditions:o.getConditions(),dependencies:o.dependencies,peerDependencies:o.peerDependencies,dependenciesMeta:o.dependenciesMeta,peerDependenciesMeta:o.peerDependenciesMeta,bin:o.bin})}};var eT=class{supportsDescriptor(e,t){return!(!e.range.startsWith(Cr)||!_g.test(e.range.slice(Cr.length)))}supportsLocator(e,t){return!1}shouldPersistResolution(e,t){throw new Error("Unreachable")}bindDescriptor(e,t,i){return e}getResolutionDependencies(e,t){return[]}async getCandidates(e,t,i){let n=e.range.slice(Cr.length),s=await So(Kl(e),{configuration:i.project.configuration,ident:e,jsonResponse:!0});if(!Object.prototype.hasOwnProperty.call(s,"dist-tags"))throw new ct(X.REMOTE_INVALID,'Registry returned invalid data - missing "dist-tags" field');let o=s["dist-tags"];if(!Object.prototype.hasOwnProperty.call(o,n))throw new ct(X.REMOTE_NOT_FOUND,`Registry failed to return tag "${n}"`);let a=o[n],l=P.makeLocator(e,`${Cr}${a}`),c=s.versions[a].dist.tarball;return vo.isConventionalTarballUrl(l,c,{configuration:i.project.configuration})?[l]:[P.bindLocator(l,{__archiveUrl:c})]}async getSatisfying(e,t,i){return null}async resolve(e,t){throw new Error("Unreachable")}};var Bh={};ft(Bh,{getGitHead:()=>X9e,makePublishBody:()=>V9e});var jT={};ft(jT,{default:()=>R9e,packUtils:()=>DA});var DA={};ft(DA,{genPackList:()=>Db,genPackStream:()=>HT,genPackageManifest:()=>qce,hasPackScripts:()=>UT,prepareForPack:()=>KT});var MT=ge(ns()),Gce=ge(jce()),Yce=ge(require("zlib")),y9e=["/package.json","/readme","/readme.*","/license","/license.*","/licence","/licence.*","/changelog","/changelog.*"],w9e=["/package.tgz",".github",".git",".hg","node_modules",".npmignore",".gitignore",".#*",".DS_Store"];async function UT(r){return!!(Zt.hasWorkspaceScript(r,"prepack")||Zt.hasWorkspaceScript(r,"postpack"))}async function KT(r,{report:e},t){await Zt.maybeExecuteWorkspaceLifecycleScript(r,"prepack",{report:e});try{let i=x.join(r.cwd,At.fileName);await U.existsPromise(i)&&await r.manifest.loadFile(i,{baseFs:U}),await t()}finally{await Zt.maybeExecuteWorkspaceLifecycleScript(r,"postpack",{report:e})}}async function HT(r,e){var s,o;typeof e=="undefined"&&(e=await Db(r));let t=new Set;for(let a of(o=(s=r.manifest.publishConfig)==null?void 0:s.executableFiles)!=null?o:new Set)t.add(x.normalize(a));for(let a of r.manifest.bin.values())t.add(x.normalize(a));let i=Gce.default.pack();process.nextTick(async()=>{for(let a of e){let l=x.normalize(a),c=x.resolve(r.cwd,l),u=x.join("package",l),g=await U.lstatPromise(c),f={name:u,mtime:new Date(Rr.SAFE_TIME*1e3)},h=t.has(l)?493:420,p,m,y=new Promise((v,k)=>{p=v,m=k}),b=v=>{v?m(v):p()};if(g.isFile()){let v;l==="package.json"?v=Buffer.from(JSON.stringify(await qce(r),null,2)):v=await U.readFilePromise(c),i.entry(te(N({},f),{mode:h,type:"file"}),v,b)}else g.isSymbolicLink()?i.entry(te(N({},f),{mode:h,type:"symlink",linkname:await U.readlinkPromise(c)}),b):b(new Error(`Unsupported file type ${g.mode} for ${H.fromPortablePath(l)}`));await y}i.finalize()});let n=(0,Yce.createGzip)();return i.pipe(n),n}async function qce(r){let e=JSON.parse(JSON.stringify(r.manifest.raw));return await r.project.configuration.triggerHook(t=>t.beforeWorkspacePacking,r,e),e}async function Db(r){var g,f,h,p,m,y,b,v;let e=r.project,t=e.configuration,i={accept:[],reject:[]};for(let k of w9e)i.reject.push(k);for(let k of y9e)i.accept.push(k);i.reject.push(t.get("rcFilename"));let n=k=>{if(k===null||!k.startsWith(`${r.cwd}/`))return;let T=x.relative(r.cwd,k),Y=x.resolve(Me.root,T);i.reject.push(Y)};n(x.resolve(e.cwd,t.get("lockfileFilename"))),n(t.get("cacheFolder")),n(t.get("globalFolder")),n(t.get("installStatePath")),n(t.get("virtualFolder")),n(t.get("yarnPath")),await t.triggerHook(k=>k.populateYarnPaths,e,k=>{n(k)});for(let k of e.workspaces){let T=x.relative(r.cwd,k.cwd);T!==""&&!T.match(/^(\.\.)?\//)&&i.reject.push(`/${T}`)}let s={accept:[],reject:[]},o=(f=(g=r.manifest.publishConfig)==null?void 0:g.main)!=null?f:r.manifest.main,a=(p=(h=r.manifest.publishConfig)==null?void 0:h.module)!=null?p:r.manifest.module,l=(y=(m=r.manifest.publishConfig)==null?void 0:m.browser)!=null?y:r.manifest.browser,c=(v=(b=r.manifest.publishConfig)==null?void 0:b.bin)!=null?v:r.manifest.bin;o!=null&&s.accept.push(x.resolve(Me.root,o)),a!=null&&s.accept.push(x.resolve(Me.root,a)),typeof l=="string"&&s.accept.push(x.resolve(Me.root,l));for(let k of c.values())s.accept.push(x.resolve(Me.root,k));if(l instanceof Map)for(let[k,T]of l.entries())s.accept.push(x.resolve(Me.root,k)),typeof T=="string"&&s.accept.push(x.resolve(Me.root,T));let u=r.manifest.files!==null;if(u){s.reject.push("/*");for(let k of r.manifest.files)Jce(s.accept,k,{cwd:Me.root})}return await B9e(r.cwd,{hasExplicitFileList:u,globalList:i,ignoreList:s})}async function B9e(r,{hasExplicitFileList:e,globalList:t,ignoreList:i}){let n=[],s=new Ta(r),o=[[Me.root,[i]]];for(;o.length>0;){let[a,l]=o.pop(),c=await s.lstatPromise(a);if(!zce(a,{globalList:t,ignoreLists:c.isDirectory()?null:l}))if(c.isDirectory()){let u=await s.readdirPromise(a),g=!1,f=!1;if(!e||a!==Me.root)for(let m of u)g=g||m===".gitignore",f=f||m===".npmignore";let h=f?await Wce(s,a,".npmignore"):g?await Wce(s,a,".gitignore"):null,p=h!==null?[h].concat(l):l;zce(a,{globalList:t,ignoreLists:l})&&(p=[...l,{accept:[],reject:["**/*"]}]);for(let m of u)o.push([x.resolve(a,m),p])}else(c.isFile()||c.isSymbolicLink())&&n.push(x.relative(Me.root,a))}return n.sort()}async function Wce(r,e,t){let i={accept:[],reject:[]},n=await r.readFilePromise(x.join(e,t),"utf8");for(let s of n.split(/\n/g))Jce(i.reject,s,{cwd:e});return i}function b9e(r,{cwd:e}){let t=r[0]==="!";return t&&(r=r.slice(1)),r.match(/\.{0,1}\//)&&(r=x.resolve(e,r)),t&&(r=`!${r}`),r}function Jce(r,e,{cwd:t}){let i=e.trim();i===""||i[0]==="#"||r.push(b9e(i,{cwd:t}))}var gs;(function(i){i[i.None=0]="None",i[i.Match=1]="Match",i[i.NegatedMatch=2]="NegatedMatch"})(gs||(gs={}));function zce(r,{globalList:e,ignoreLists:t}){let i=Rb(r,e.accept);if(i!==0)return i===2;let n=Rb(r,e.reject);if(n!==0)return n===1;if(t!==null)for(let s of t){let o=Rb(r,s.accept);if(o!==0)return o===2;let a=Rb(r,s.reject);if(a!==0)return a===1}return!1}function Rb(r,e){let t=e,i=[];for(let n=0;n{await KT(i,{report:l},async()=>{l.reportJson({base:H.fromPortablePath(i.cwd)});let c=await Db(i);for(let u of c)l.reportInfo(null,H.fromPortablePath(u)),l.reportJson({location:H.fromPortablePath(u)});if(!this.dryRun){let u=await HT(i,c),g=U.createWriteStream(s);u.pipe(g),await new Promise(f=>{g.on("finish",f)})}}),this.dryRun||(l.reportInfo(X.UNNAMED,`Package archive generated in ${ae.pretty(e,s,ae.Type.PATH)}`),l.reportJson({output:H.fromPortablePath(s)}))})).exitCode()}};iE.paths=[["pack"]],iE.usage=Re.Usage({description:"generate a tarball from the active workspace",details:"\n This command will turn the active workspace into a compressed archive suitable for publishing. The archive will by default be stored at the root of the workspace (`package.tgz`).\n\n If the `-o,---out` is set the archive will be created at the specified path. The `%s` and `%v` variables can be used within the path and will be respectively replaced by the package name and version.\n ",examples:[["Create an archive from the active workspace","yarn pack"],["List the files that would be made part of the workspace's archive","yarn pack --dry-run"],["Name and output the archive in a dedicated folder","yarn pack --out /artifacts/%s-%v.tgz"]]});var Vce=iE;function Q9e(r,{workspace:e}){let t=r.replace("%s",S9e(e)).replace("%v",v9e(e));return H.toPortablePath(t)}function S9e(r){return r.manifest.name!==null?P.slugifyIdent(r.manifest.name):"package"}function v9e(r){return r.manifest.version!==null?r.manifest.version:"unknown"}var k9e=["dependencies","devDependencies","peerDependencies"],x9e="workspace:",P9e=(r,e)=>{var i,n;e.publishConfig&&(e.publishConfig.main&&(e.main=e.publishConfig.main),e.publishConfig.browser&&(e.browser=e.publishConfig.browser),e.publishConfig.module&&(e.module=e.publishConfig.module),e.publishConfig.browser&&(e.browser=e.publishConfig.browser),e.publishConfig.exports&&(e.exports=e.publishConfig.exports),e.publishConfig.bin&&(e.bin=e.publishConfig.bin));let t=r.project;for(let s of k9e)for(let o of r.manifest.getForScope(s).values()){let a=t.tryWorkspaceByDescriptor(o),l=P.parseRange(o.range);if(l.protocol===x9e)if(a===null){if(t.tryWorkspaceByIdent(o)===null)throw new ct(X.WORKSPACE_NOT_FOUND,`${P.prettyDescriptor(t.configuration,o)}: No local workspace found for this range`)}else{let c;P.areDescriptorsEqual(o,a.anchoredDescriptor)||l.selector==="*"?c=(i=a.manifest.version)!=null?i:"0.0.0":l.selector==="~"||l.selector==="^"?c=`${l.selector}${(n=a.manifest.version)!=null?n:"0.0.0"}`:c=l.selector;let u=s==="dependencies"?P.makeDescriptor(o,"unknown"):null,g=u!==null&&r.manifest.ensureDependencyMeta(u).optional?"optionalDependencies":s;e[g][P.stringifyIdent(o)]=c}}},D9e={hooks:{beforeWorkspacePacking:P9e},commands:[Vce]},R9e=D9e;var sue=ge(require("crypto")),oue=ge(nue()),aue=ge(require("url"));async function V9e(r,e,{access:t,tag:i,registry:n,gitHead:s}){let o=r.project.configuration,a=r.manifest.name,l=r.manifest.version,c=P.stringifyIdent(a),u=(0,sue.createHash)("sha1").update(e).digest("hex"),g=oue.default.fromData(e).toString();typeof t=="undefined"&&(r.manifest.publishConfig&&typeof r.manifest.publishConfig.access=="string"?t=r.manifest.publishConfig.access:o.get("npmPublishAccess")!==null?t=o.get("npmPublishAccess"):a.scope?t="restricted":t="public");let f=await DA.genPackageManifest(r),h=`${c}-${l}.tgz`,p=new aue.URL(`${Ea(n)}/${c}/-/${h}`);return{_id:c,_attachments:{[h]:{content_type:"application/octet-stream",data:e.toString("base64"),length:e.length}},name:c,access:t,["dist-tags"]:{[i]:l},versions:{[l]:te(N({},f),{_id:`${c}@${l}`,name:c,version:l,gitHead:s,dist:{shasum:u,integrity:g,tarball:p.toString()}})}}}async function X9e(r){try{let{stdout:e}=await Nr.execvp("git",["rev-parse","--revs-only","HEAD"],{cwd:r});return e.trim()===""?void 0:e.trim()}catch{return}}var WT={npmAlwaysAuth:{description:"URL of the selected npm registry (note: npm enterprise isn't supported)",type:Ie.BOOLEAN,default:!1},npmAuthIdent:{description:"Authentication identity for the npm registry (_auth in npm and yarn v1)",type:Ie.SECRET,default:null},npmAuthToken:{description:"Authentication token for the npm registry (_authToken in npm and yarn v1)",type:Ie.SECRET,default:null}},Aue={npmAuditRegistry:{description:"Registry to query for audit reports",type:Ie.STRING,default:null},npmPublishRegistry:{description:"Registry to push packages to",type:Ie.STRING,default:null},npmRegistryServer:{description:"URL of the selected npm registry (note: npm enterprise isn't supported)",type:Ie.STRING,default:"https://registry.yarnpkg.com"}},Z9e={configuration:te(N(N({},WT),Aue),{npmScopes:{description:"Settings per package scope",type:Ie.MAP,valueDefinition:{description:"",type:Ie.SHAPE,properties:N(N({},WT),Aue)}},npmRegistries:{description:"Settings per registry",type:Ie.MAP,normalizeKeys:Ea,valueDefinition:{description:"",type:Ie.SHAPE,properties:N({},WT)}}}),fetchers:[XL,vo],resolvers:[ZL,$L,eT]},$9e=Z9e;var XT={};ft(XT,{default:()=>A_e});ws();var ba;(function(i){i.All="all",i.Production="production",i.Development="development"})(ba||(ba={}));var xo;(function(s){s.Info="info",s.Low="low",s.Moderate="moderate",s.High="high",s.Critical="critical"})(xo||(xo={}));var Fb=[xo.Info,xo.Low,xo.Moderate,xo.High,xo.Critical];function lue(r,e){let t=[],i=new Set,n=o=>{i.has(o)||(i.add(o),t.push(o))};for(let o of e)n(o);let s=new Set;for(;t.length>0;){let o=t.shift(),a=r.storedResolutions.get(o);if(typeof a=="undefined")throw new Error("Assertion failed: Expected the resolution to have been registered");let l=r.storedPackages.get(a);if(!!l){s.add(o);for(let c of l.dependencies.values())n(c.descriptorHash)}}return s}function e_e(r,e){return new Set([...r].filter(t=>!e.has(t)))}function t_e(r,e,{all:t}){let i=t?r.workspaces:[e],n=i.map(f=>f.manifest),s=new Set(n.map(f=>[...f.dependencies].map(([h,p])=>h)).flat()),o=new Set(n.map(f=>[...f.devDependencies].map(([h,p])=>h)).flat()),a=i.map(f=>[...f.dependencies.values()]).flat(),l=a.filter(f=>s.has(f.identHash)).map(f=>f.descriptorHash),c=a.filter(f=>o.has(f.identHash)).map(f=>f.descriptorHash),u=lue(r,l),g=lue(r,c);return e_e(g,u)}function cue(r){let e={};for(let t of r)e[P.stringifyIdent(t)]=P.parseRange(t.range).selector;return e}function uue(r){if(typeof r=="undefined")return new Set;let e=Fb.indexOf(r),t=Fb.slice(e);return new Set(t)}function r_e(r,e){let t=uue(e),i={};for(let n of t)i[n]=r[n];return i}function gue(r,e){var i;let t=r_e(r,e);for(let n of Object.keys(t))if((i=t[n])!=null?i:0>0)return!0;return!1}function fue(r,e){var s;let t={},i={children:t},n=Object.values(r.advisories);if(e!=null){let o=uue(e);n=n.filter(a=>o.has(a.severity))}for(let o of Se.sortMap(n,a=>a.module_name))t[o.module_name]={label:o.module_name,value:ae.tuple(ae.Type.RANGE,o.findings.map(a=>a.version).join(", ")),children:{Issue:{label:"Issue",value:ae.tuple(ae.Type.NO_HINT,o.title)},URL:{label:"URL",value:ae.tuple(ae.Type.URL,o.url)},Severity:{label:"Severity",value:ae.tuple(ae.Type.NO_HINT,o.severity)},["Vulnerable Versions"]:{label:"Vulnerable Versions",value:ae.tuple(ae.Type.RANGE,o.vulnerable_versions)},["Patched Versions"]:{label:"Patched Versions",value:ae.tuple(ae.Type.RANGE,o.patched_versions)},Via:{label:"Via",value:ae.tuple(ae.Type.NO_HINT,Array.from(new Set(o.findings.map(a=>a.paths).flat().map(a=>a.split(">")[0]))).join(", "))},Recommendation:{label:"Recommendation",value:ae.tuple(ae.Type.NO_HINT,(s=o.recommendation)==null?void 0:s.replace(/\n/g," "))}}};return i}function hue(r,e,{all:t,environment:i}){let n=t?r.workspaces:[e],s=[ba.All,ba.Production].includes(i),o=[];if(s)for(let c of n)for(let u of c.manifest.dependencies.values())o.push(u);let a=[ba.All,ba.Development].includes(i),l=[];if(a)for(let c of n)for(let u of c.manifest.devDependencies.values())l.push(u);return cue([...o,...l].filter(c=>P.parseRange(c.range).protocol===null))}function pue(r,e,{all:t}){var s;let i=t_e(r,e,{all:t}),n={};for(let o of r.storedPackages.values())n[P.stringifyIdent(o)]={version:(s=o.version)!=null?s:"0.0.0",integrity:o.identHash,requires:cue(o.dependencies.values()),dev:i.has(P.convertLocatorToDescriptor(o).descriptorHash)};return n}var oE=class extends Le{constructor(){super(...arguments);this.all=J.Boolean("-A,--all",!1,{description:"Audit dependencies from all workspaces"});this.recursive=J.Boolean("-R,--recursive",!1,{description:"Audit transitive dependencies as well"});this.environment=J.String("--environment",ba.All,{description:"Which environments to cover",validator:nn(ba)});this.json=J.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.severity=J.String("--severity",xo.Info,{description:"Minimal severity requested for packages to be displayed",validator:nn(xo)})}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),{project:t,workspace:i}=await ze.find(e,this.context.cwd);if(!i)throw new ht(t.cwd,this.context.cwd);await t.restoreInstallState();let n=hue(t,i,{all:this.all,environment:this.environment}),s=pue(t,i,{all:this.all});if(!this.recursive)for(let f of Object.keys(s))Object.prototype.hasOwnProperty.call(n,f)?s[f].requires={}:delete s[f];let o={requires:n,dependencies:s},a=br.getAuditRegistry(i.manifest,{configuration:e}),l,c=await dA.start({configuration:e,stdout:this.context.stdout},async()=>{l=await zt.post("/-/npm/v1/security/audits/quick",o,{authType:zt.AuthType.BEST_EFFORT,configuration:e,jsonResponse:!0,registry:a})});if(c.hasErrors())return c.exitCode();let u=gue(l.metadata.vulnerabilities,this.severity);return!this.json&&u?(ls.emitTree(fue(l,this.severity),{configuration:e,json:this.json,stdout:this.context.stdout,separators:2}),1):(await Je.start({configuration:e,includeFooter:!1,json:this.json,stdout:this.context.stdout},async f=>{f.reportJson(l),u||f.reportInfo(X.EXCEPTION,"No audit suggestions")})).exitCode()}};oE.paths=[["npm","audit"]],oE.usage=Re.Usage({description:"perform a vulnerability audit against the installed packages",details:` This command checks for known security reports on the packages you use. The reports are by default extracted from the npm registry, and may or may not be relevant to your actual program (not all vulnerabilities affect all code paths). For consistency with our other commands the default is to only check the direct dependencies for the active workspace. To extend this search to all workspaces, use \`-A,--all\`. To extend this search to both direct and transitive dependencies, use \`-R,--recursive\`. Applying the \`--severity\` flag will limit the audit table to vulnerabilities of the corresponding severity and above. Valid values are ${Fb.map(e=>`\`${e}\``).join(", ")}. If the \`--json\` flag is set, Yarn will print the output exactly as received from the registry. Regardless of this flag, the process will exit with a non-zero exit code if a report is found for the selected packages. To understand the dependency tree requiring vulnerable packages, check the raw report with the \`--json\` flag or use \`yarn why \` to get more information as to who depends on them. `,examples:[["Checks for known security issues with the installed packages. The output is a list of known issues.","yarn npm audit"],["Audit dependencies in all workspaces","yarn npm audit --all"],["Limit auditing to `dependencies` (excludes `devDependencies`)","yarn npm audit --environment production"],["Show audit report as valid JSON","yarn npm audit --json"],["Audit all direct and transitive dependencies","yarn npm audit --recursive"],["Output moderate (or more severe) vulnerabilities","yarn npm audit --severity moderate"]]});var due=oE;var zT=ge(ri()),_T=ge(require("util")),aE=class extends Le{constructor(){super(...arguments);this.fields=J.String("-f,--fields",{description:"A comma-separated list of manifest fields that should be displayed"});this.json=J.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.packages=J.Rest()}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),{project:t}=await ze.find(e,this.context.cwd),i=typeof this.fields!="undefined"?new Set(["name",...this.fields.split(/\s*,\s*/)]):null,n=[],s=!1,o=await Je.start({configuration:e,includeFooter:!1,json:this.json,stdout:this.context.stdout},async a=>{for(let l of this.packages){let c;if(l==="."){let k=t.topLevelWorkspace;if(!k.manifest.name)throw new Pe(`Missing ${ae.pretty(e,"name",ae.Type.CODE)} field in ${H.fromPortablePath(x.join(k.cwd,xt.manifest))}`);c=P.makeDescriptor(k.manifest.name,"unknown")}else c=P.parseDescriptor(l);let u=zt.getIdentUrl(c),g=VT(await zt.get(u,{configuration:e,ident:c,jsonResponse:!0,customErrorMessage:zt.customPackageError})),f=Object.keys(g.versions).sort(zT.default.compareLoose),p=g["dist-tags"].latest||f[f.length-1],m=Wt.validRange(c.range);if(m){let k=zT.default.maxSatisfying(f,m);k!==null?p=k:(a.reportWarning(X.UNNAMED,`Unmet range ${P.prettyRange(e,c.range)}; falling back to the latest version`),s=!0)}else Object.prototype.hasOwnProperty.call(g["dist-tags"],c.range)?p=g["dist-tags"][c.range]:c.range!=="unknown"&&(a.reportWarning(X.UNNAMED,`Unknown tag ${P.prettyRange(e,c.range)}; falling back to the latest version`),s=!0);let y=g.versions[p],b=te(N(N({},g),y),{version:p,versions:f}),v;if(i!==null){v={};for(let k of i){let T=b[k];if(typeof T!="undefined")v[k]=T;else{a.reportWarning(X.EXCEPTION,`The ${ae.pretty(e,k,ae.Type.CODE)} field doesn't exist inside ${P.prettyIdent(e,c)}'s information`),s=!0;continue}}}else this.json||(delete b.dist,delete b.readme,delete b.users),v=b;a.reportJson(v),this.json||n.push(v)}});_T.inspect.styles.name="cyan";for(let a of n)(a!==n[0]||s)&&this.context.stdout.write(` `),this.context.stdout.write(`${(0,_T.inspect)(a,{depth:Infinity,colors:!0,compact:!1})} `);return o.exitCode()}};aE.paths=[["npm","info"]],aE.usage=Re.Usage({category:"Npm-related commands",description:"show information about a package",details:"\n This command fetches information about a package from the npm registry and prints it in a tree format.\n\n The package does not have to be installed locally, but needs to have been published (in particular, local changes will be ignored even for workspaces).\n\n Append `@` to the package argument to provide information specific to the latest version that satisfies the range or to the corresponding tagged version. If the range is invalid or if there is no version satisfying the range, the command will print a warning and fall back to the latest version.\n\n If the `-f,--fields` option is set, it's a comma-separated list of fields which will be used to only display part of the package information.\n\n By default, this command won't return the `dist`, `readme`, and `users` fields, since they are often very long. To explicitly request those fields, explicitly list them with the `--fields` flag or request the output in JSON mode.\n ",examples:[["Show all available information about react (except the `dist`, `readme`, and `users` fields)","yarn npm info react"],["Show all available information about react as valid JSON (including the `dist`, `readme`, and `users` fields)","yarn npm info react --json"],["Show all available information about react@16.12.0","yarn npm info react@16.12.0"],["Show all available information about react@next","yarn npm info react@next"],["Show the description of react","yarn npm info react --fields description"],["Show all available versions of react","yarn npm info react --fields versions"],["Show the readme of react","yarn npm info react --fields readme"],["Show a few fields of react","yarn npm info react --fields homepage,repository"]]});var Cue=aE;function VT(r){if(Array.isArray(r)){let e=[];for(let t of r)t=VT(t),t&&e.push(t);return e}else if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r)){if(t.startsWith("_"))continue;let i=VT(r[t]);i&&(e[t]=i)}return e}else return r||null}var mue=ge(zC()),AE=class extends Le{constructor(){super(...arguments);this.scope=J.String("-s,--scope",{description:"Login to the registry configured for a given scope"});this.publish=J.Boolean("--publish",!1,{description:"Login to the publish registry"})}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),t=await Nb({configuration:e,cwd:this.context.cwd,publish:this.publish,scope:this.scope});return(await Je.start({configuration:e,stdout:this.context.stdout},async n=>{let s=await n_e({registry:t,report:n,stdin:this.context.stdin,stdout:this.context.stdout}),o=`/-/user/org.couchdb.user:${encodeURIComponent(s.name)}`,a=await zt.put(o,s,{attemptedAs:s.name,configuration:e,registry:t,jsonResponse:!0,authType:zt.AuthType.NO_AUTH});return await i_e(t,a.token,{configuration:e,scope:this.scope}),n.reportInfo(X.UNNAMED,"Successfully logged in")})).exitCode()}};AE.paths=[["npm","login"]],AE.usage=Re.Usage({category:"Npm-related commands",description:"store new login info to access the npm registry",details:"\n This command will ask you for your username, password, and 2FA One-Time-Password (when it applies). It will then modify your local configuration (in your home folder, never in the project itself) to reference the new tokens thus generated.\n\n Adding the `-s,--scope` flag will cause the authentication to be done against whatever registry is configured for the associated scope (see also `npmScopes`).\n\n Adding the `--publish` flag will cause the authentication to be done against the registry used when publishing the package (see also `publishConfig.registry` and `npmPublishRegistry`).\n ",examples:[["Login to the default registry","yarn npm login"],["Login to the registry linked to the @my-scope registry","yarn npm login --scope my-scope"],["Login to the publish registry for the current package","yarn npm login --publish"]]});var Eue=AE;async function Nb({scope:r,publish:e,configuration:t,cwd:i}){return r&&e?br.getScopeRegistry(r,{configuration:t,type:br.RegistryType.PUBLISH_REGISTRY}):r?br.getScopeRegistry(r,{configuration:t}):e?br.getPublishRegistry((await zf(t,i)).manifest,{configuration:t}):br.getDefaultRegistry({configuration:t})}async function i_e(r,e,{configuration:t,scope:i}){let n=o=>a=>{let l=Se.isIndexableObject(a)?a:{},c=l[o],u=Se.isIndexableObject(c)?c:{};return te(N({},l),{[o]:te(N({},u),{npmAuthToken:e})})},s=i?{npmScopes:n(i)}:{npmRegistries:n(r)};return await ye.updateHomeConfiguration(s)}async function n_e({registry:r,report:e,stdin:t,stdout:i}){if(process.env.TEST_ENV)return{name:process.env.TEST_NPM_USER||"",password:process.env.TEST_NPM_PASSWORD||""};e.reportInfo(X.UNNAMED,`Logging in to ${r}`);let n=!1;r.match(/^https:\/\/npm\.pkg\.github\.com(\/|$)/)&&(e.reportInfo(X.UNNAMED,"You seem to be using the GitHub Package Registry. Tokens must be generated with the 'repo', 'write:packages', and 'read:packages' permissions."),n=!0),e.reportSeparator();let{username:s,password:o}=await(0,mue.prompt)([{type:"input",name:"username",message:"Username:",required:!0,onCancel:()=>process.exit(130),stdin:t,stdout:i},{type:"password",name:"password",message:n?"Token:":"Password:",required:!0,onCancel:()=>process.exit(130),stdin:t,stdout:i}]);return e.reportSeparator(),{name:s,password:o}}var bh=new Set(["npmAuthIdent","npmAuthToken"]),lE=class extends Le{constructor(){super(...arguments);this.scope=J.String("-s,--scope",{description:"Logout of the registry configured for a given scope"});this.publish=J.Boolean("--publish",!1,{description:"Logout of the publish registry"});this.all=J.Boolean("-A,--all",!1,{description:"Logout of all registries"})}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),t=async()=>{var l;let n=await Nb({configuration:e,cwd:this.context.cwd,publish:this.publish,scope:this.scope}),s=await ye.find(this.context.cwd,this.context.plugins),o=P.makeIdent((l=this.scope)!=null?l:null,"pkg");return!br.getAuthConfiguration(n,{configuration:s,ident:o}).get("npmAuthToken")};return(await Je.start({configuration:e,stdout:this.context.stdout},async n=>{if(this.all&&(await s_e(),n.reportInfo(X.UNNAMED,"Successfully logged out from everything")),this.scope){await Iue("npmScopes",this.scope),await t()?n.reportInfo(X.UNNAMED,`Successfully logged out from ${this.scope}`):n.reportWarning(X.UNNAMED,"Scope authentication settings removed, but some other ones settings still apply to it");return}let s=await Nb({configuration:e,cwd:this.context.cwd,publish:this.publish});await Iue("npmRegistries",s),await t()?n.reportInfo(X.UNNAMED,`Successfully logged out from ${s}`):n.reportWarning(X.UNNAMED,"Registry authentication settings removed, but some other ones settings still apply to it")})).exitCode()}};lE.paths=[["npm","logout"]],lE.usage=Re.Usage({category:"Npm-related commands",description:"logout of the npm registry",details:"\n This command will log you out by modifying your local configuration (in your home folder, never in the project itself) to delete all credentials linked to a registry.\n\n Adding the `-s,--scope` flag will cause the deletion to be done against whatever registry is configured for the associated scope (see also `npmScopes`).\n\n Adding the `--publish` flag will cause the deletion to be done against the registry used when publishing the package (see also `publishConfig.registry` and `npmPublishRegistry`).\n\n Adding the `-A,--all` flag will cause the deletion to be done against all registries and scopes.\n ",examples:[["Logout of the default registry","yarn npm logout"],["Logout of the @my-scope scope","yarn npm logout --scope my-scope"],["Logout of the publish registry for the current package","yarn npm logout --publish"],["Logout of all registries","yarn npm logout --all"]]});var yue=lE;function o_e(r,e){let t=r[e];if(!Se.isIndexableObject(t))return!1;let i=new Set(Object.keys(t));if([...bh].every(s=>!i.has(s)))return!1;for(let s of bh)i.delete(s);if(i.size===0)return r[e]=void 0,!0;let n=N({},t);for(let s of bh)delete n[s];return r[e]=n,!0}async function s_e(){let r=e=>{let t=!1,i=Se.isIndexableObject(e)?N({},e):{};i.npmAuthToken&&(delete i.npmAuthToken,t=!0);for(let n of Object.keys(i))o_e(i,n)&&(t=!0);if(Object.keys(i).length!==0)return t?i:e};return await ye.updateHomeConfiguration({npmRegistries:r,npmScopes:r})}async function Iue(r,e){return await ye.updateHomeConfiguration({[r]:t=>{let i=Se.isIndexableObject(t)?t:{};if(!Object.prototype.hasOwnProperty.call(i,e))return t;let n=i[e],s=Se.isIndexableObject(n)?n:{},o=new Set(Object.keys(s));if([...bh].every(l=>!o.has(l)))return t;for(let l of bh)o.delete(l);if(o.size===0)return Object.keys(i).length===1?void 0:te(N({},i),{[e]:void 0});let a={};for(let l of bh)a[l]=void 0;return te(N({},i),{[e]:N(N({},s),a)})}})}var cE=class extends Le{constructor(){super(...arguments);this.access=J.String("--access",{description:"The access for the published package (public or restricted)"});this.tag=J.String("--tag","latest",{description:"The tag on the registry that the package should be attached to"});this.tolerateRepublish=J.Boolean("--tolerate-republish",!1,{description:"Warn and exit when republishing an already existing version of a package"});this.otp=J.String("--otp",{description:"The OTP token to use with the command"})}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),{project:t,workspace:i}=await ze.find(e,this.context.cwd);if(!i)throw new ht(t.cwd,this.context.cwd);if(i.manifest.private)throw new Pe("Private workspaces cannot be published");if(i.manifest.name===null||i.manifest.version===null)throw new Pe("Workspaces must have valid names and versions to be published on an external registry");await t.restoreInstallState();let n=i.manifest.name,s=i.manifest.version,o=br.getPublishRegistry(i.manifest,{configuration:e});return(await Je.start({configuration:e,stdout:this.context.stdout},async l=>{var c,u;if(this.tolerateRepublish)try{let g=await zt.get(zt.getIdentUrl(n),{configuration:e,registry:o,ident:n,jsonResponse:!0});if(!Object.prototype.hasOwnProperty.call(g,"versions"))throw new ct(X.REMOTE_INVALID,'Registry returned invalid data for - missing "versions" field');if(Object.prototype.hasOwnProperty.call(g.versions,s)){l.reportWarning(X.UNNAMED,`Registry already knows about version ${s}; skipping.`);return}}catch(g){if(((u=(c=g.originalError)==null?void 0:c.response)==null?void 0:u.statusCode)!==404)throw g}await Zt.maybeExecuteWorkspaceLifecycleScript(i,"prepublish",{report:l}),await DA.prepareForPack(i,{report:l},async()=>{let g=await DA.genPackList(i);for(let y of g)l.reportInfo(null,y);let f=await DA.genPackStream(i,g),h=await Se.bufferStream(f),p=await Bh.getGitHead(i.cwd),m=await Bh.makePublishBody(i,h,{access:this.access,tag:this.tag,registry:o,gitHead:p});await zt.put(zt.getIdentUrl(n),m,{configuration:e,registry:o,ident:n,otp:this.otp,jsonResponse:!0})}),l.reportInfo(X.UNNAMED,"Package archive published")})).exitCode()}};cE.paths=[["npm","publish"]],cE.usage=Re.Usage({category:"Npm-related commands",description:"publish the active workspace to the npm registry",details:'\n This command will pack the active workspace into a fresh archive and upload it to the npm registry.\n\n The package will by default be attached to the `latest` tag on the registry, but this behavior can be overriden by using the `--tag` option.\n\n Note that for legacy reasons scoped packages are by default published with an access set to `restricted` (aka "private packages"). This requires you to register for a paid npm plan. In case you simply wish to publish a public scoped package to the registry (for free), just add the `--access public` flag. This behavior can be enabled by default through the `npmPublishAccess` settings.\n ',examples:[["Publish the active workspace","yarn npm publish"]]});var wue=cE;var bue=ge(ri());var uE=class extends Le{constructor(){super(...arguments);this.json=J.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.package=J.String({required:!1})}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),{project:t,workspace:i}=await ze.find(e,this.context.cwd),n;if(typeof this.package!="undefined")n=P.parseIdent(this.package);else{if(!i)throw new ht(t.cwd,this.context.cwd);if(!i.manifest.name)throw new Pe(`Missing 'name' field in ${H.fromPortablePath(x.join(i.cwd,xt.manifest))}`);n=i.manifest.name}let s=await gE(n,e),a={children:Se.sortMap(Object.entries(s),([l])=>l).map(([l,c])=>({value:ae.tuple(ae.Type.RESOLUTION,{descriptor:P.makeDescriptor(n,l),locator:P.makeLocator(n,c)})}))};return ls.emitTree(a,{configuration:e,json:this.json,stdout:this.context.stdout})}};uE.paths=[["npm","tag","list"]],uE.usage=Re.Usage({category:"Npm-related commands",description:"list all dist-tags of a package",details:` This command will list all tags of a package from the npm registry. If the package is not specified, Yarn will default to the current workspace. `,examples:[["List all tags of package `my-pkg`","yarn npm tag list my-pkg"]]});var Bue=uE;async function gE(r,e){let t=`/-/package${zt.getIdentUrl(r)}/dist-tags`;return zt.get(t,{configuration:e,ident:r,jsonResponse:!0,customErrorMessage:zt.customPackageError})}var fE=class extends Le{constructor(){super(...arguments);this.package=J.String();this.tag=J.String()}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),{project:t,workspace:i}=await ze.find(e,this.context.cwd);if(!i)throw new ht(t.cwd,this.context.cwd);let n=P.parseDescriptor(this.package,!0),s=n.range;if(!bue.default.valid(s))throw new Pe(`The range ${ae.pretty(e,n.range,ae.Type.RANGE)} must be a valid semver version`);let o=br.getPublishRegistry(i.manifest,{configuration:e}),a=ae.pretty(e,n,ae.Type.IDENT),l=ae.pretty(e,s,ae.Type.RANGE),c=ae.pretty(e,this.tag,ae.Type.CODE);return(await Je.start({configuration:e,stdout:this.context.stdout},async g=>{let f=await gE(n,e);Object.prototype.hasOwnProperty.call(f,this.tag)&&f[this.tag]===s&&g.reportWarning(X.UNNAMED,`Tag ${c} is already set to version ${l}`);let h=`/-/package${zt.getIdentUrl(n)}/dist-tags/${encodeURIComponent(this.tag)}`;await zt.put(h,s,{configuration:e,registry:o,ident:n,jsonRequest:!0,jsonResponse:!0}),g.reportInfo(X.UNNAMED,`Tag ${c} added to version ${l} of package ${a}`)})).exitCode()}};fE.paths=[["npm","tag","add"]],fE.usage=Re.Usage({category:"Npm-related commands",description:"add a tag for a specific version of a package",details:` This command will add a tag to the npm registry for a specific version of a package. If the tag already exists, it will be overwritten. `,examples:[["Add a `beta` tag for version `2.3.4-beta.4` of package `my-pkg`","yarn npm tag add my-pkg@2.3.4-beta.4 beta"]]});var Que=fE;var hE=class extends Le{constructor(){super(...arguments);this.package=J.String();this.tag=J.String()}async execute(){if(this.tag==="latest")throw new Pe("The 'latest' tag cannot be removed.");let e=await ye.find(this.context.cwd,this.context.plugins),{project:t,workspace:i}=await ze.find(e,this.context.cwd);if(!i)throw new ht(t.cwd,this.context.cwd);let n=P.parseIdent(this.package),s=br.getPublishRegistry(i.manifest,{configuration:e}),o=ae.pretty(e,this.tag,ae.Type.CODE),a=ae.pretty(e,n,ae.Type.IDENT),l=await gE(n,e);if(!Object.prototype.hasOwnProperty.call(l,this.tag))throw new Pe(`${o} is not a tag of package ${a}`);return(await Je.start({configuration:e,stdout:this.context.stdout},async u=>{let g=`/-/package${zt.getIdentUrl(n)}/dist-tags/${encodeURIComponent(this.tag)}`;await zt.del(g,{configuration:e,registry:s,ident:n,jsonResponse:!0}),u.reportInfo(X.UNNAMED,`Tag ${o} removed from package ${a}`)})).exitCode()}};hE.paths=[["npm","tag","remove"]],hE.usage=Re.Usage({category:"Npm-related commands",description:"remove a tag from a package",details:` This command will remove a tag from a package from the npm registry. `,examples:[["Remove the `beta` tag from package `my-pkg`","yarn npm tag remove my-pkg beta"]]});var Sue=hE;var pE=class extends Le{constructor(){super(...arguments);this.scope=J.String("-s,--scope",{description:"Print username for the registry configured for a given scope"});this.publish=J.Boolean("--publish",!1,{description:"Print username for the publish registry"})}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),t;return this.scope&&this.publish?t=br.getScopeRegistry(this.scope,{configuration:e,type:br.RegistryType.PUBLISH_REGISTRY}):this.scope?t=br.getScopeRegistry(this.scope,{configuration:e}):this.publish?t=br.getPublishRegistry((await zf(e,this.context.cwd)).manifest,{configuration:e}):t=br.getDefaultRegistry({configuration:e}),(await Je.start({configuration:e,stdout:this.context.stdout},async n=>{var o,a;let s;try{s=await zt.get("/-/whoami",{configuration:e,registry:t,authType:zt.AuthType.ALWAYS_AUTH,jsonResponse:!0,ident:this.scope?P.makeIdent(this.scope,""):void 0})}catch(l){if(((o=l.response)==null?void 0:o.statusCode)===401||((a=l.response)==null?void 0:a.statusCode)===403){n.reportError(X.AUTHENTICATION_INVALID,"Authentication failed - your credentials may have expired");return}else throw l}n.reportInfo(X.UNNAMED,s.username)})).exitCode()}};pE.paths=[["npm","whoami"]],pE.usage=Re.Usage({category:"Npm-related commands",description:"display the name of the authenticated user",details:"\n Print the username associated with the current authentication settings to the standard output.\n\n When using `-s,--scope`, the username printed will be the one that matches the authentication settings of the registry associated with the given scope (those settings can be overriden using the `npmRegistries` map, and the registry associated with the scope is configured via the `npmScopes` map).\n\n When using `--publish`, the registry we'll select will by default be the one used when publishing packages (`publishConfig.registry` or `npmPublishRegistry` if available, otherwise we'll fallback to the regular `npmRegistryServer`).\n ",examples:[["Print username for the default registry","yarn npm whoami"],["Print username for the registry on a given scope","yarn npm whoami --scope company"]]});var vue=pE;var a_e={configuration:{npmPublishAccess:{description:"Default access of the published packages",type:Ie.STRING,default:null}},commands:[due,Cue,Eue,yue,wue,Que,Bue,Sue,vue]},A_e=a_e;var AO={};ft(AO,{default:()=>B_e,patchUtils:()=>ZT});var ZT={};ft(ZT,{applyPatchFile:()=>Ob,diffFolders:()=>sO,ensureUnpatchedDescriptor:()=>eO,extractPackageToDisk:()=>nO,extractPatchFlags:()=>Nue,isParentRequired:()=>iO,loadPatchFiles:()=>EE,makeDescriptor:()=>tO,makeLocator:()=>rO,parseDescriptor:()=>CE,parseLocator:()=>mE,parsePatchFile:()=>Tb});var dE=class extends Error{constructor(e,t){super(`Cannot apply hunk #${e+1}`);this.hunk=t}};var l_e=/^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@.*/;function Qh(r){return x.relative(Me.root,x.resolve(Me.root,H.toPortablePath(r)))}function c_e(r){let e=r.trim().match(l_e);if(!e)throw new Error(`Bad header line: '${r}'`);return{original:{start:Math.max(Number(e[1]),1),length:Number(e[3]||1)},patched:{start:Math.max(Number(e[4]),1),length:Number(e[6]||1)}}}var u_e=420,g_e=493,Zr;(function(i){i.Context="context",i.Insertion="insertion",i.Deletion="deletion"})(Zr||(Zr={}));var kue=()=>({semverExclusivity:null,diffLineFromPath:null,diffLineToPath:null,oldMode:null,newMode:null,deletedFileMode:null,newFileMode:null,renameFrom:null,renameTo:null,beforeHash:null,afterHash:null,fromPath:null,toPath:null,hunks:null}),f_e=r=>({header:c_e(r),parts:[]}),h_e={["@"]:"header",["-"]:Zr.Deletion,["+"]:Zr.Insertion,[" "]:Zr.Context,["\\"]:"pragma",undefined:Zr.Context};function d_e(r){let e=[],t=kue(),i="parsing header",n=null,s=null;function o(){n&&(s&&(n.parts.push(s),s=null),t.hunks.push(n),n=null)}function a(){o(),e.push(t),t=kue()}for(let l=0;l0?"patch":"mode change",v=null;switch(b){case"rename":{if(!u||!g)throw new Error("Bad parser state: rename from & to not given");e.push({type:"rename",semverExclusivity:i,fromPath:Qh(u),toPath:Qh(g)}),v=g}break;case"file deletion":{let k=n||p;if(!k)throw new Error("Bad parse state: no path given for file deletion");e.push({type:"file deletion",semverExclusivity:i,hunk:y&&y[0]||null,path:Qh(k),mode:Lb(l),hash:f})}break;case"file creation":{let k=s||m;if(!k)throw new Error("Bad parse state: no path given for file creation");e.push({type:"file creation",semverExclusivity:i,hunk:y&&y[0]||null,path:Qh(k),mode:Lb(c),hash:h})}break;case"patch":case"mode change":v=m||s;break;default:Se.assertNever(b);break}v&&o&&a&&o!==a&&e.push({type:"mode change",semverExclusivity:i,path:Qh(v),oldMode:Lb(o),newMode:Lb(a)}),v&&y&&y.length&&e.push({type:"patch",semverExclusivity:i,path:Qh(v),hunks:y,beforeHash:f,afterHash:h})}if(e.length===0)throw new Error("Unable to parse patch file: No changes found. Make sure the patch is a valid UTF8 encoded string");return e}function Lb(r){let e=parseInt(r,8)&511;if(e!==u_e&&e!==g_e)throw new Error(`Unexpected file mode string: ${r}`);return e}function Tb(r){let e=r.split(/\n/g);return e[e.length-1]===""&&e.pop(),C_e(d_e(e))}function p_e(r){let e=0,t=0;for(let{type:i,lines:n}of r.parts)switch(i){case Zr.Context:t+=n.length,e+=n.length;break;case Zr.Deletion:e+=n.length;break;case Zr.Insertion:t+=n.length;break;default:Se.assertNever(i);break}if(e!==r.header.original.length||t!==r.header.patched.length){let i=n=>n<0?n:`+${n}`;throw new Error(`hunk header integrity check failed (expected @@ ${i(r.header.original.length)} ${i(r.header.patched.length)} @@, got @@ ${i(e)} ${i(t)} @@)`)}}async function Sh(r,e,t){let i=await r.lstatPromise(e),n=await t();if(typeof n!="undefined"&&(e=n),r.lutimesPromise)await r.lutimesPromise(e,i.atime,i.mtime);else if(!i.isSymbolicLink())await r.utimesPromise(e,i.atime,i.mtime);else throw new Error("Cannot preserve the time values of a symlink")}async function Ob(r,{baseFs:e=new ar,dryRun:t=!1,version:i=null}={}){for(let n of r)if(!(n.semverExclusivity!==null&&i!==null&&!Wt.satisfiesWithPrereleases(i,n.semverExclusivity)))switch(n.type){case"file deletion":if(t){if(!e.existsSync(n.path))throw new Error(`Trying to delete a file that doesn't exist: ${n.path}`)}else await Sh(e,x.dirname(n.path),async()=>{await e.unlinkPromise(n.path)});break;case"rename":if(t){if(!e.existsSync(n.fromPath))throw new Error(`Trying to move a file that doesn't exist: ${n.fromPath}`)}else await Sh(e,x.dirname(n.fromPath),async()=>{await Sh(e,x.dirname(n.toPath),async()=>{await Sh(e,n.fromPath,async()=>(await e.movePromise(n.fromPath,n.toPath),n.toPath))})});break;case"file creation":if(t){if(e.existsSync(n.path))throw new Error(`Trying to create a file that already exists: ${n.path}`)}else{let s=n.hunk?n.hunk.parts[0].lines.join(` `)+(n.hunk.parts[0].noNewlineAtEndOfFile?"":` `):"";await e.mkdirpPromise(x.dirname(n.path),{chmod:493,utimes:[Rr.SAFE_TIME,Rr.SAFE_TIME]}),await e.writeFilePromise(n.path,s,{mode:n.mode}),await e.utimesPromise(n.path,Rr.SAFE_TIME,Rr.SAFE_TIME)}break;case"patch":await Sh(e,n.path,async()=>{await m_e(n,{baseFs:e,dryRun:t})});break;case"mode change":{let o=(await e.statPromise(n.path)).mode;if(xue(n.newMode)!==xue(o))continue;await Sh(e,n.path,async()=>{await e.chmodPromise(n.path,n.newMode)})}break;default:Se.assertNever(n);break}}function xue(r){return(r&64)>0}function Pue(r){return r.replace(/\s+$/,"")}function E_e(r,e){return Pue(r)===Pue(e)}async function m_e({hunks:r,path:e},{baseFs:t,dryRun:i=!1}){let n=await t.statSync(e).mode,o=(await t.readFileSync(e,"utf8")).split(/\n/),a=[],l=0,c=0;for(let g of r){let f=Math.max(c,g.header.patched.start+l),h=Math.max(0,f-c),p=Math.max(0,o.length-f-g.header.original.length),m=Math.max(h,p),y=0,b=0,v=null;for(;y<=m;){if(y<=h&&(b=f-y,v=Due(g,o,b),v!==null)){y=-y;break}if(y<=p&&(b=f+y,v=Due(g,o,b),v!==null))break;y+=1}if(v===null)throw new dE(r.indexOf(g),g);a.push(v),l+=y,c=b+g.header.original.length}if(i)return;let u=0;for(let g of a)for(let f of g)switch(f.type){case"splice":{let h=f.index+u;o.splice(h,f.numToDelete,...f.linesToInsert),u+=f.linesToInsert.length-f.numToDelete}break;case"pop":o.pop();break;case"push":o.push(f.line);break;default:Se.assertNever(f);break}await t.writeFilePromise(e,o.join(` `),{mode:n})}function Due(r,e,t){let i=[];for(let n of r.parts)switch(n.type){case Zr.Context:case Zr.Deletion:{for(let s of n.lines){let o=e[t];if(o==null||!E_e(o,s))return null;t+=1}n.type===Zr.Deletion&&(i.push({type:"splice",index:t-n.lines.length,numToDelete:n.lines.length,linesToInsert:[]}),n.noNewlineAtEndOfFile&&i.push({type:"push",line:""}))}break;case Zr.Insertion:i.push({type:"splice",index:t,numToDelete:0,linesToInsert:n.lines}),n.noNewlineAtEndOfFile&&i.push({type:"pop"});break;default:Se.assertNever(n.type);break}return i}var I_e=/^builtin<([^>]+)>$/;function $T(r,e){let{source:t,selector:i,params:n}=P.parseRange(r);if(t===null)throw new Error("Patch locators must explicitly define their source");let s=i?i.split(/&/).map(c=>H.toPortablePath(c)):[],o=n&&typeof n.locator=="string"?P.parseLocator(n.locator):null,a=n&&typeof n.version=="string"?n.version:null,l=e(t);return{parentLocator:o,sourceItem:l,patchPaths:s,sourceVersion:a}}function CE(r){let i=$T(r.range,P.parseDescriptor),{sourceItem:e}=i,t=Or(i,["sourceItem"]);return te(N({},t),{sourceDescriptor:e})}function mE(r){let i=$T(r.reference,P.parseLocator),{sourceItem:e}=i,t=Or(i,["sourceItem"]);return te(N({},t),{sourceLocator:e})}function eO(r){if(!r.range.startsWith("patch:"))return r;let{sourceItem:e}=$T(r.range,P.parseDescriptor);return e}function Rue({parentLocator:r,sourceItem:e,patchPaths:t,sourceVersion:i,patchHash:n},s){let o=r!==null?{locator:P.stringifyLocator(r)}:{},a=typeof i!="undefined"?{version:i}:{},l=typeof n!="undefined"?{hash:n}:{};return P.makeRange({protocol:"patch:",source:s(e),selector:t.join("&"),params:N(N(N({},a),l),o)})}function tO(r,{parentLocator:e,sourceDescriptor:t,patchPaths:i}){return P.makeDescriptor(r,Rue({parentLocator:e,sourceItem:t,patchPaths:i},P.stringifyDescriptor))}function rO(r,{parentLocator:e,sourcePackage:t,patchPaths:i,patchHash:n}){return P.makeLocator(r,Rue({parentLocator:e,sourceItem:t,sourceVersion:t.version,patchPaths:i,patchHash:n},P.stringifyLocator))}function Fue({onAbsolute:r,onRelative:e,onBuiltin:t},i){i.startsWith("~")&&(i=i.slice(1));let s=i.match(I_e);return s!==null?t(s[1]):x.isAbsolute(i)?r(i):e(i)}function Nue(r){let e=r.startsWith("~");return e&&(r=r.slice(1)),{optional:e}}function iO(r){return Fue({onAbsolute:()=>!1,onRelative:()=>!0,onBuiltin:()=>!1},r)}async function EE(r,e,t){let i=r!==null?await t.fetcher.fetch(r,t):null,n=i&&i.localPath?{packageFs:new _t(Me.root),prefixPath:x.relative(Me.root,i.localPath)}:i;i&&i!==n&&i.releaseFs&&i.releaseFs();let s=await Se.releaseAfterUseAsync(async()=>await Promise.all(e.map(async o=>{let a=Nue(o),l=await Fue({onAbsolute:async()=>await U.readFilePromise(o,"utf8"),onRelative:async()=>{if(n===null)throw new Error("Assertion failed: The parent locator should have been fetched");return await n.packageFs.readFilePromise(x.join(n.prefixPath,o),"utf8")},onBuiltin:async c=>await t.project.configuration.firstHook(u=>u.getBuiltinPatch,t.project,c)},o);return te(N({},a),{source:l})})));for(let o of s)typeof o.source=="string"&&(o.source=o.source.replace(/\r\n?/g,` `));return s}async function nO(r,{cache:e,project:t}){let i=t.storedPackages.get(r.locatorHash);if(typeof i=="undefined")throw new Error("Assertion failed: Expected the package to be registered");let n=t.storedChecksums,s=new di,o=t.configuration.makeFetcher(),a=await o.fetch(r,{cache:e,project:t,fetcher:o,checksums:n,report:s}),l=await U.mktempPromise(),c=x.join(l,"source"),u=x.join(l,"user"),g=x.join(l,".yarn-patch.json");return await Promise.all([U.copyPromise(c,a.prefixPath,{baseFs:a.packageFs}),U.copyPromise(u,a.prefixPath,{baseFs:a.packageFs}),U.writeJsonPromise(g,{locator:P.stringifyLocator(r),version:i.version})]),U.detachTemp(l),u}async function sO(r,e){let t=H.fromPortablePath(r).replace(/\\/g,"/"),i=H.fromPortablePath(e).replace(/\\/g,"/"),{stdout:n,stderr:s}=await Nr.execvp("git",["-c","core.safecrlf=false","diff","--src-prefix=a/","--dst-prefix=b/","--ignore-cr-at-eol","--full-index","--no-index","--no-renames","--text",t,i],{cwd:H.toPortablePath(process.cwd()),env:te(N({},process.env),{GIT_CONFIG_NOSYSTEM:"1",HOME:"",XDG_CONFIG_HOME:"",USERPROFILE:""})});if(s.length>0)throw new Error(`Unable to diff directories. Make sure you have a recent version of 'git' available in PATH. The following error was reported by 'git': ${s}`);let o=t.startsWith("/")?a=>a.slice(1):a=>a;return n.replace(new RegExp(`(a|b)(${Se.escapeRegExp(`/${o(t)}/`)})`,"g"),"$1/").replace(new RegExp(`(a|b)${Se.escapeRegExp(`/${o(i)}/`)}`,"g"),"$1/").replace(new RegExp(Se.escapeRegExp(`${t}/`),"g"),"").replace(new RegExp(Se.escapeRegExp(`${i}/`),"g"),"")}function Lue(r,{configuration:e,report:t}){for(let i of r.parts)for(let n of i.lines)switch(i.type){case Zr.Context:t.reportInfo(null,` ${ae.pretty(e,n,"grey")}`);break;case Zr.Deletion:t.reportError(X.FROZEN_LOCKFILE_EXCEPTION,`- ${ae.pretty(e,n,ae.Type.REMOVED)}`);break;case Zr.Insertion:t.reportError(X.FROZEN_LOCKFILE_EXCEPTION,`+ ${ae.pretty(e,n,ae.Type.ADDED)}`);break;default:Se.assertNever(i.type)}}var oO=class{supports(e,t){return!!e.reference.startsWith("patch:")}getLocalPath(e,t){return null}async fetch(e,t){let i=t.checksums.get(e.locatorHash)||null,[n,s,o]=await t.cache.fetchPackageFromCache(e,i,N({onHit:()=>t.report.reportCacheHit(e),onMiss:()=>t.report.reportCacheMiss(e,`${P.prettyLocator(t.project.configuration,e)} can't be found in the cache and will be fetched from the disk`),loader:()=>this.patchPackage(e,t),skipIntegrityCheck:t.skipIntegrityCheck},t.cacheOptions));return{packageFs:n,releaseFs:s,prefixPath:P.getIdentVendorPath(e),localPath:this.getLocalPath(e,t),checksum:o}}async patchPackage(e,t){let{parentLocator:i,sourceLocator:n,sourceVersion:s,patchPaths:o}=mE(e),a=await EE(i,o,t),l=await U.mktempPromise(),c=x.join(l,"current.zip"),u=await t.fetcher.fetch(n,t),g=P.getIdentVendorPath(e),f=await fn(),h=new li(c,{libzip:f,create:!0,level:t.project.configuration.get("compressionLevel")});await Se.releaseAfterUseAsync(async()=>{await h.copyPromise(g,u.prefixPath,{baseFs:u.packageFs,stableSort:!0})},u.releaseFs),h.saveAndClose();for(let{source:p,optional:m}of a){if(p===null)continue;let y=new li(c,{libzip:f,level:t.project.configuration.get("compressionLevel")}),b=new _t(x.resolve(Me.root,g),{baseFs:y});try{await Ob(Tb(p),{baseFs:b,version:s})}catch(v){if(!(v instanceof dE))throw v;let k=t.project.configuration.get("enableInlineHunks"),T=!k&&!m?" (set enableInlineHunks for details)":"",Y=`${P.prettyLocator(t.project.configuration,e)}: ${v.message}${T}`,q=$=>{!k||Lue(v.hunk,{configuration:t.project.configuration,report:$})};if(y.discardAndClose(),m){t.report.reportWarningOnce(X.PATCH_HUNK_FAILED,Y,{reportExtra:q});continue}else throw new ct(X.PATCH_HUNK_FAILED,Y,q)}y.saveAndClose()}return new li(c,{libzip:f,level:t.project.configuration.get("compressionLevel")})}};var y_e=3,aO=class{supportsDescriptor(e,t){return!!e.range.startsWith("patch:")}supportsLocator(e,t){return!!e.reference.startsWith("patch:")}shouldPersistResolution(e,t){return!1}bindDescriptor(e,t,i){let{patchPaths:n}=CE(e);return n.every(s=>!iO(s))?e:P.bindDescriptor(e,{locator:P.stringifyLocator(t)})}getResolutionDependencies(e,t){let{sourceDescriptor:i}=CE(e);return[i]}async getCandidates(e,t,i){if(!i.fetchOptions)throw new Error("Assertion failed: This resolver cannot be used unless a fetcher is configured");let{parentLocator:n,sourceDescriptor:s,patchPaths:o}=CE(e),a=await EE(n,o,i.fetchOptions),l=t.get(s.descriptorHash);if(typeof l=="undefined")throw new Error("Assertion failed: The dependency should have been resolved");let c=Rn.makeHash(`${y_e}`,...a.map(u=>JSON.stringify(u))).slice(0,6);return[rO(e,{parentLocator:n,sourcePackage:l,patchPaths:o,patchHash:c})]}async getSatisfying(e,t,i){return null}async resolve(e,t){let{sourceLocator:i}=mE(e),n=await t.resolver.resolve(i,t);return N(N({},n),e)}};var IE=class extends Le{constructor(){super(...arguments);this.save=J.Boolean("-s,--save",!1,{description:"Add the patch to your resolution entries"});this.patchFolder=J.String()}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),{project:t,workspace:i}=await ze.find(e,this.context.cwd);if(!i)throw new ht(t.cwd,this.context.cwd);await t.restoreInstallState();let n=x.resolve(this.context.cwd,H.toPortablePath(this.patchFolder)),s=x.join(n,"../source"),o=x.join(n,"../.yarn-patch.json");if(!U.existsSync(s))throw new Pe("The argument folder didn't get created by 'yarn patch'");let a=await sO(s,n),l=await U.readJsonPromise(o),c=P.parseLocator(l.locator,!0);if(!t.storedPackages.has(c.locatorHash))throw new Pe("No package found in the project for the given locator");if(!this.save){this.context.stdout.write(a);return}let u=e.get("patchFolder"),g=x.join(u,`${P.slugifyLocator(c)}.patch`);await U.mkdirPromise(u,{recursive:!0}),await U.writeFilePromise(g,a);let f=new Map;for(let h of t.storedPackages.values()){if(P.isVirtualLocator(h))continue;let p=h.dependencies.get(c.identHash);if(!p)continue;let m=P.isVirtualDescriptor(p)?P.devirtualizeDescriptor(p):p,y=eO(m),b=t.storedResolutions.get(y.descriptorHash);if(!b)throw new Error("Assertion failed: Expected the resolution to have been registered");if(!t.storedPackages.get(b))throw new Error("Assertion failed: Expected the package to have been registered");let k=t.originalPackages.get(h.locatorHash);if(!k)throw new Error("Assertion failed: Expected the original package to have been registered");let T=k.dependencies.get(p.identHash);if(!T)throw new Error("Assertion failed: Expected the original dependency to have been registered");f.set(T.descriptorHash,T)}for(let h of f.values()){let p=tO(h,{parentLocator:null,sourceDescriptor:P.convertLocatorToDescriptor(c),sourceVersion:null,patchPaths:[`./${x.relative(t.cwd,g)}`]});t.topLevelWorkspace.manifest.resolutions.push({pattern:{descriptor:{fullName:P.stringifyIdent(p),description:h.range}},reference:p.range})}await t.persist()}};IE.paths=[["patch-commit"]],IE.usage=Re.Usage({description:"generate a patch out of a directory",details:"\n By default, this will print a patchfile on stdout based on the diff between the folder passed in and the original version of the package. Such file is suitable for consumption with the `patch:` protocol.\n\n With the `-s,--save` option set, the patchfile won't be printed on stdout anymore and will instead be stored within a local file (by default kept within `.yarn/patches`, but configurable via the `patchFolder` setting). A `resolutions` entry will also be added to your top-level manifest, referencing the patched package via the `patch:` protocol.\n\n Note that only folders generated by `yarn patch` are accepted as valid input for `yarn patch-commit`.\n "});var Tue=IE;var yE=class extends Le{constructor(){super(...arguments);this.json=J.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.package=J.String()}async execute(){let e=await ye.find(this.context.cwd,this.context.plugins),{project:t,workspace:i}=await ze.find(e,this.context.cwd),n=await Nt.find(e);if(!i)throw new ht(t.cwd,this.context.cwd);await t.restoreInstallState();let s=P.parseLocator(this.package);if(s.reference==="unknown"){let o=Se.mapAndFilter([...t.storedPackages.values()],a=>a.identHash!==s.identHash?Se.mapAndFilter.skip:P.isVirtualLocator(a)?Se.mapAndFilter.skip:a);if(o.length===0)throw new Pe("No package found in the project for the given locator");if(o.length>1)throw new Pe(`Multiple candidate packages found; explicitly choose one of them (use \`yarn why \` to get more information as to who depends on them): ${o.map(a=>` - ${P.prettyLocator(e,a)}`).join("")}`);s=o[0]}if(!t.storedPackages.has(s.locatorHash))throw new Pe("No package found in the project for the given locator");await Je.start({configuration:e,json:this.json,stdout:this.context.stdout},async o=>{let a=await nO(s,{cache:n,project:t});o.reportJson({locator:P.stringifyLocator(s),path:H.fromPortablePath(a)}),o.reportInfo(X.UNNAMED,`Package ${P.prettyLocator(e,s)} got extracted with success!`),o.reportInfo(X.UNNAMED,`You can now edit the following folder: ${ae.pretty(e,H.fromPortablePath(a),"magenta")}`),o.reportInfo(X.UNNAMED,`Once you are done run ${ae.pretty(e,`yarn patch-commit -s ${process.platform==="win32"?'"':""}${H.fromPortablePath(a)}${process.platform==="win32"?'"':""}`,"cyan")} and Yarn will store a patchfile based on your changes.`)})}};yE.paths=[["patch"]],yE.usage=Re.Usage({description:"prepare a package for patching",details:"\n This command will cause a package to be extracted in a temporary directory intended to be editable at will.\n \n Once you're done with your changes, run `yarn patch-commit -s ` (with `` being the temporary directory you received) to generate a patchfile and register it into your top-level manifest via the `patch:` protocol. Run `yarn patch-commit -h` for more details.\n "});var Oue=yE;var w_e={configuration:{enableInlineHunks:{description:"If true, the installs will print unmatched patch hunks",type:Ie.BOOLEAN,default:!1},patchFolder:{description:"Folder where the patch files must be written",type:Ie.ABSOLUTE_PATH,default:"./.yarn/patches"}},commands:[Tue,Oue],fetchers:[oO],resolvers:[aO]},B_e=w_e;var gO={};ft(gO,{default:()=>S_e});var lO=class{supportsPackage(e,t){return this.isEnabled(t)}async findPackageLocation(e,t){if(!this.isEnabled(t))throw new Error("Assertion failed: Expected the pnpm linker to be enabled");let i=cO(),n=t.project.installersCustomData.get(i);if(!n)throw new Pe(`The project in ${ae.pretty(t.project.configuration,`${t.project.cwd}/package.json`,ae.Type.PATH)} doesn't seem to have been installed - running an install there might help`);let s=n.pathByLocator.get(e.locatorHash);if(typeof s=="undefined")throw new Pe(`Couldn't find ${P.prettyLocator(t.project.configuration,e)} in the currently installed pnpm map - running an install might help`);return s}async findPackageLocator(e,t){if(!this.isEnabled(t))return null;let i=cO(),n=t.project.installersCustomData.get(i);if(!n)throw new Pe(`The project in ${ae.pretty(t.project.configuration,`${t.project.cwd}/package.json`,ae.Type.PATH)} doesn't seem to have been installed - running an install there might help`);let s=e.match(/(^.*\/node_modules\/(@[^/]*\/)?[^/]+)(\/.*$)/);if(s){let l=n.locatorByPath.get(s[1]);if(l)return l}let o=e,a=e;do{a=o,o=x.dirname(a);let l=n.locatorByPath.get(a);if(l)return l}while(o!==a);return null}makeInstaller(e){return new Mue(e)}isEnabled(e){return e.project.configuration.get("nodeLinker")==="pnpm"}},Mue=class{constructor(e){this.opts=e;this.asyncActions=new Se.AsyncActions(10);this.customData={pathByLocator:new Map,locatorByPath:new Map}}getCustomDataKey(){return cO()}attachCustomData(e){}async installPackage(e,t,i){switch(e.linkType){case Qt.SOFT:return this.installPackageSoft(e,t,i);case Qt.HARD:return this.installPackageHard(e,t,i)}throw new Error("Assertion failed: Unsupported package link type")}async installPackageSoft(e,t,i){let n=x.resolve(t.packageFs.getRealPath(),t.prefixPath);return this.customData.pathByLocator.set(e.locatorHash,n),{packageLocation:n,buildDirective:null}}async installPackageHard(e,t,i){var u;let n=b_e(e,{project:this.opts.project});this.customData.locatorByPath.set(n,P.stringifyLocator(e)),this.customData.pathByLocator.set(e.locatorHash,n),i.holdFetchResult(this.asyncActions.set(e.locatorHash,async()=>{await U.mkdirPromise(n,{recursive:!0}),await U.copyPromise(n,t.prefixPath,{baseFs:t.packageFs,overwrite:!1})}));let o=P.isVirtualLocator(e)?P.devirtualizeLocator(e):e,a={manifest:(u=await At.tryFind(t.prefixPath,{baseFs:t.packageFs}))!=null?u:new At,misc:{hasBindingGyp:ma.hasBindingGyp(t)}},l=this.opts.project.getDependencyMeta(o,e.version),c=ma.extractBuildScripts(e,a,l,{configuration:this.opts.project.configuration,report:this.opts.report});return{packageLocation:n,buildDirective:c}}async attachInternalDependencies(e,t){this.opts.project.configuration.get("nodeLinker")==="pnpm"&&(!Hue(e,{project:this.opts.project})||this.asyncActions.reduce(e.locatorHash,async i=>{await i;let n=this.customData.pathByLocator.get(e.locatorHash);if(typeof n=="undefined")throw new Error(`Assertion failed: Expected the package to have been registered (${P.stringifyLocator(e)})`);let s=x.join(n,xt.nodeModules),o=[],a=await jue(s);for(let[l,c]of t){let u=c;Hue(c,{project:this.opts.project})||(this.opts.report.reportWarning(X.UNNAMED,"The pnpm linker doesn't support providing different versions to workspaces' peer dependencies"),u=P.devirtualizeLocator(c));let g=this.customData.pathByLocator.get(u.locatorHash);if(typeof g=="undefined")throw new Error(`Assertion failed: Expected the package to have been registered (${P.stringifyLocator(c)})`);let f=P.stringifyIdent(l),h=x.join(s,f),p=x.relative(x.dirname(h),g),m=a.get(f);a.delete(f),o.push(Promise.resolve().then(async()=>{if(m){if(m.isSymbolicLink()&&await U.readlinkPromise(h)===p)return;await U.removePromise(h)}await U.mkdirpPromise(x.dirname(h)),process.platform=="win32"?await U.symlinkPromise(g,h,"junction"):await U.symlinkPromise(p,h)}))}o.push(Gue(s,a)),await Promise.all(o)}))}async attachExternalDependents(e,t){throw new Error("External dependencies haven't been implemented for the pnpm linker")}async finalizeInstall(){let e=Kue(this.opts.project);if(this.opts.project.configuration.get("nodeLinker")!=="pnpm")await U.removePromise(e);else{let t=[],i=new Set;for(let s of this.customData.pathByLocator.values()){let o=x.contains(e,s);if(o!==null){let[a,,...l]=o.split(x.sep);i.add(a);let c=x.join(e,a);t.push(U.readdirPromise(c).then(u=>Promise.all(u.map(async g=>{let f=x.join(c,g);if(g===xt.nodeModules){let h=await jue(f);return h.delete(l.join(x.sep)),Gue(f,h)}else return U.removePromise(f)}))).catch(u=>{if(u.code!=="ENOENT")throw u}))}}let n;try{n=await U.readdirPromise(e)}catch{n=[]}for(let s of n)i.has(s)||t.push(U.removePromise(x.join(e,s)));await Promise.all(t)}return await this.asyncActions.wait(),await uO(e),this.opts.project.configuration.get("nodeLinker")!=="node-modules"&&await uO(Uue(this.opts.project)),{customData:this.customData}}};function cO(){return JSON.stringify({name:"PnpmInstaller",version:2})}function Uue(r){return x.join(r.cwd,xt.nodeModules)}function Kue(r){return x.join(Uue(r),".store")}function b_e(r,{project:e}){let t=P.slugifyLocator(r),i=P.getIdentVendorPath(r);return x.join(Kue(e),t,i)}function Hue(r,{project:e}){return!P.isVirtualLocator(r)||!e.tryWorkspaceByLocator(r)}async function jue(r){let e=new Map,t=[];try{t=await U.readdirPromise(r,{withFileTypes:!0})}catch(i){if(i.code!=="ENOENT")throw i}try{for(let i of t)if(!i.name.startsWith("."))if(i.name.startsWith("@")){let n=await U.readdirPromise(x.join(r,i.name),{withFileTypes:!0});if(n.length===0)e.set(i.name,i);else for(let s of n)e.set(`${i.name}/${s.name}`,s)}else e.set(i.name,i)}catch(i){if(i.code!=="ENOENT")throw i}return e}async function Gue(r,e){var n;let t=[],i=new Set;for(let s of e.keys()){t.push(U.removePromise(x.join(r,s)));let o=(n=P.tryParseIdent(s))==null?void 0:n.scope;o&&i.add(`@${o}`)}return Promise.all(t).then(()=>Promise.all([...i].map(s=>uO(x.join(r,s)))))}async function uO(r){try{await U.rmdirPromise(r)}catch(e){if(e.code!=="ENOENT"&&e.code!=="ENOTEMPTY")throw e}}var Q_e={linkers:[lO]},S_e=Q_e;var T0=()=>({modules:new Map([["@yarnpkg/cli",YC],["@yarnpkg/core",IC],["@yarnpkg/fslib",$h],["@yarnpkg/libzip",Ud],["@yarnpkg/parsers",ap],["@yarnpkg/shell",Hd],["clipanion",hZ(mp)],["semver",v_e],["typanion",ug],["yup",k_e],["@yarnpkg/plugin-essentials",YN],["@yarnpkg/plugin-compat",_N],["@yarnpkg/plugin-dlx",VN],["@yarnpkg/plugin-file",sL],["@yarnpkg/plugin-git",GN],["@yarnpkg/plugin-github",aL],["@yarnpkg/plugin-http",cL],["@yarnpkg/plugin-init",hL],["@yarnpkg/plugin-link",EL],["@yarnpkg/plugin-nm",WL],["@yarnpkg/plugin-npm",JT],["@yarnpkg/plugin-npm-cli",XT],["@yarnpkg/plugin-pack",jT],["@yarnpkg/plugin-patch",AO],["@yarnpkg/plugin-pnp",TL],["@yarnpkg/plugin-pnpm",gO]]),plugins:new Set(["@yarnpkg/plugin-essentials","@yarnpkg/plugin-compat","@yarnpkg/plugin-dlx","@yarnpkg/plugin-file","@yarnpkg/plugin-git","@yarnpkg/plugin-github","@yarnpkg/plugin-http","@yarnpkg/plugin-init","@yarnpkg/plugin-link","@yarnpkg/plugin-nm","@yarnpkg/plugin-npm","@yarnpkg/plugin-npm-cli","@yarnpkg/plugin-pack","@yarnpkg/plugin-patch","@yarnpkg/plugin-pnp","@yarnpkg/plugin-pnpm"])});o0({binaryVersion:Kr||"",pluginConfiguration:T0()});})(); /*! * buildToken * Builds OAuth token prefix (helper function) * * @name buildToken * @function * @param {GitUrl} obj The parsed Git url object. * @return {String} token prefix */ /*! * fill-range * * Copyright (c) 2014-present, Jon Schlinkert. * Licensed under the MIT License. */ /*! * is-extglob * * Copyright (c) 2014-2016, Jon Schlinkert. * Licensed under the MIT License. */ /*! * is-glob * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ /*! * is-number * * Copyright (c) 2014-present, Jon Schlinkert. * Released under the MIT License. */ /*! * is-windows * * Copyright © 2015-2018, Jon Schlinkert. * Released under the MIT License. */ /*! * to-regex-range * * Copyright (c) 2015-present, Jon Schlinkert. * Released under the MIT License. */