@visulima/vis 4.3.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +505 -0
  2. package/LICENSE.md +55 -129
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/config/index.d.ts +27 -2
  6. package/dist/packem_chunks/bloom-sync.js +1 -1
  7. package/dist/packem_chunks/catalog.js +52 -49
  8. package/dist/packem_chunks/cli-exec.js +1 -1
  9. package/dist/packem_chunks/cli-main.js +164 -164
  10. package/dist/packem_chunks/fix.js +1 -1
  11. package/dist/packem_chunks/handler.js +1 -1
  12. package/dist/packem_chunks/handler11.js +1 -1
  13. package/dist/packem_chunks/handler12.js +1 -1
  14. package/dist/packem_chunks/handler13.js +1 -1
  15. package/dist/packem_chunks/handler14.js +1 -1
  16. package/dist/packem_chunks/handler15.js +1 -1
  17. package/dist/packem_chunks/handler16.js +1 -1
  18. package/dist/packem_chunks/handler17.js +1 -1
  19. package/dist/packem_chunks/handler18.js +1 -1
  20. package/dist/packem_chunks/handler19.js +1 -1
  21. package/dist/packem_chunks/handler2.js +1 -1
  22. package/dist/packem_chunks/handler20.js +1 -1
  23. package/dist/packem_chunks/handler21.js +1 -1
  24. package/dist/packem_chunks/handler24.js +1 -1
  25. package/dist/packem_chunks/handler26.js +5 -5
  26. package/dist/packem_chunks/handler27.js +1 -1
  27. package/dist/packem_chunks/handler28.js +1 -1
  28. package/dist/packem_chunks/handler29.js +1 -1
  29. package/dist/packem_chunks/handler3.js +1 -1
  30. package/dist/packem_chunks/handler4.js +1 -1
  31. package/dist/packem_chunks/handler5.js +2 -2
  32. package/dist/packem_chunks/handler50.js +1 -1
  33. package/dist/packem_chunks/handler51.js +1 -1
  34. package/dist/packem_chunks/handler54.js +2 -2
  35. package/dist/packem_chunks/handler55.js +1 -1
  36. package/dist/packem_chunks/handler58.js +1 -1
  37. package/dist/packem_chunks/handler59.js +1 -1
  38. package/dist/packem_chunks/handler6.js +6 -6
  39. package/dist/packem_chunks/handler61.js +1 -1
  40. package/dist/packem_chunks/handler62.js +10 -10
  41. package/dist/packem_chunks/handler63.js +1 -1
  42. package/dist/packem_chunks/handler64.js +6 -3
  43. package/dist/packem_chunks/handler65.js +8 -6
  44. package/dist/packem_chunks/handler66.js +1 -1
  45. package/dist/packem_chunks/handler68.js +4 -4
  46. package/dist/packem_chunks/handler69.js +22 -153
  47. package/dist/packem_chunks/handler7.js +1 -1
  48. package/dist/packem_chunks/handler70.js +9 -9
  49. package/dist/packem_chunks/handler71.js +153 -22
  50. package/dist/packem_chunks/handler72.js +1 -1
  51. package/dist/packem_chunks/handler73.js +1 -1
  52. package/dist/packem_chunks/handler74.js +1 -1
  53. package/dist/packem_chunks/handler75.js +28 -28
  54. package/dist/packem_chunks/handler76.js +7 -7
  55. package/dist/packem_chunks/handler77.js +2 -2
  56. package/dist/packem_chunks/handler78.js +70 -68
  57. package/dist/packem_chunks/handler8.js +1 -1
  58. package/dist/packem_chunks/handler9.js +1 -1
  59. package/dist/packem_chunks/heal-accept.js +1 -1
  60. package/dist/packem_chunks/heal.js +1 -1
  61. package/dist/packem_chunks/help-command.js +7 -7
  62. package/dist/packem_chunks/index6.js +1 -1
  63. package/dist/packem_chunks/list.js +1 -1
  64. package/dist/packem_chunks/loader.js +1 -1
  65. package/dist/packem_chunks/run.js +1 -1
  66. package/dist/packem_chunks/sync.js +1 -1
  67. package/dist/packem_chunks/sync2.js +1 -1
  68. package/dist/packem_chunks/tar.js +1 -1
  69. package/dist/packem_chunks/tripwire.js +1 -1
  70. package/dist/packem_chunks/ts-loader.js +1 -1
  71. package/dist/packem_chunks/verify-lockfile.js +1 -1
  72. package/dist/packem_shared/{affected-selection-BzIbfpA1.js → affected-selection-BJXJW_3Q.js} +1 -1
  73. package/dist/packem_shared/affected-shas-B_kfSKss.js +1 -0
  74. package/dist/packem_shared/{ai-analysis-Cfj24UAy.js → ai-analysis-pldoS_N4.js} +2 -2
  75. package/dist/packem_shared/{ai-fix-DeRUtT-s.js → ai-fix-BC6aIRJT.js} +4 -4
  76. package/dist/packem_shared/{bin-D9TsVhq2.js → bin-Dx8mjl3g.js} +1 -1
  77. package/dist/packem_shared/{ecosystem-gate-1M3wnsTr.js → ecosystem-gate-CeV20GSB.js} +1 -1
  78. package/dist/packem_shared/env-consistency-Dt_uDbSP.js +1 -0
  79. package/dist/packem_shared/git-source-DExWbfN0.js +2 -0
  80. package/dist/packem_shared/{index-CNYv9D8g.js → index-C_ScJMpb.js} +1 -1
  81. package/dist/packem_shared/{index-BO8qIogg.js → index-nEyN71oX.js} +1 -1
  82. package/dist/packem_shared/{missing-package-json-DnHMxRnG.js → missing-package-json-Cu5YVAot.js} +1 -1
  83. package/dist/packem_shared/{multi-eco-lockfiles-CUUxUjHK.js → multi-eco-lockfiles-B2X3yhyo.js} +1 -1
  84. package/dist/packem_shared/{package-version-DUcG-b7S.js → package-version-CiRZecQu.js} +1 -1
  85. package/dist/packem_shared/{packument-CyGSNquL.js → packument-Df46y5MY.js} +1 -1
  86. package/dist/packem_shared/pm-runner-3iiQayy-.js +1 -0
  87. package/dist/packem_shared/{project-name-filter--bq-FL2f.js → project-name-filter-CH8Ih7Qr.js} +1 -1
  88. package/dist/packem_shared/{provenance-DyF0b6KX.js → provenance-DKeR0Ig1.js} +1 -1
  89. package/dist/packem_shared/{resolve-explicit-BjCEm0s-.js → resolve-explicit-BmV8YBE-.js} +1 -1
  90. package/dist/packem_shared/{s1ngularity-YfmkD_AH.js → s1ngularity-DZhkIqL4.js} +1 -1
  91. package/dist/packem_shared/{scan-progress-C_zaZjyY.js → scan-progress-CkumcBG-.js} +2 -2
  92. package/dist/packem_shared/{signatures-CL3ckp_Y.js → signatures-BxTMck2l.js} +1 -1
  93. package/dist/packem_shared/spinner-ukDEdGvp.js +1 -0
  94. package/dist/packem_shared/tabs--uxJGL8N.js +1 -0
  95. package/dist/packem_shared/task-env-DzR4RkOj.js +2 -0
  96. package/dist/packem_shared/use-measured-height-DUZyyias.js +1 -0
  97. package/dist/packem_shared/{vis-update-app-D73C__fx.js → vis-update-app-BCIccZfA.js} +1 -1
  98. package/dist/packem_shared/{vis-user-error-Cpg2FqA4.js → vis-user-error-Dd7hwxlW.js} +15 -15
  99. package/dist/packem_shared/{watch-loop-qRn0IHPG.js → watch-loop-BBkg02-Q.js} +2 -2
  100. package/index.js +52 -52
  101. package/package.json +12 -12
  102. package/schemas/project.schema.json +44 -1
  103. package/schemas/vis-config.schema.json +122 -7
  104. package/skills/vis/SKILL.md +24 -12
  105. package/dist/packem_shared/affected-shas-B2V84O0g.js +0 -1
  106. package/dist/packem_shared/giget-D8Kwb0kD.js +0 -2
  107. package/dist/packem_shared/pm-runner-CMSml1Bj.js +0 -1
  108. package/dist/packem_shared/spinner-DuB0K0Am.js +0 -1
  109. package/dist/packem_shared/tabs-RZd_e1M0.js +0 -1
  110. package/dist/packem_shared/use-measured-height-DWkDV9Dj.js +0 -1
@@ -1,3 +1,3 @@
1
- import{createRequire as lr}from"node:module";import{_ as fr}from"../packem_shared/giget-D8Kwb0kD.js";let dr;const ur=t=>(dr??=lr(import.meta.url))(t),Ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=t=>{if(typeof Ft<"u"&&Ft.versions&&Ft.versions.node){const[e,i]=Ft.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return Ft.getBuiltinModule(t)}return ur(t)},d=D("node:fs"),cr=D("node:fs/promises"),As=D("node:stream"),c=D("node:path"),{posix:Rt,basename:mr,win32:pr,join:Ns}=c,Is=D("events"),{EventEmitter:vr}=Is,p=D("fs"),{EventEmitter:zi}=D("node:events"),{StringDecoder:yr}=D("node:string_decoder"),re=D("path"),{parse:br,dirname:gr}=re,vi=D("assert"),{Buffer:bt}=D("buffer"),Xi=D("zlib"),qi={...Xi,default:Xi},Er=D("zlib"),wr=D("node:assert"),{randomBytes:Bs}=D("node:crypto");var an=fr({Header:()=>ot,Pack:()=>ae,PackJob:()=>Li,PackSync:()=>je,Parser:()=>At,Pax:()=>he,ReadEntry:()=>Gs,Unpack:()=>Me,UnpackSync:()=>Pi,WriteEntry:()=>Yi,WriteEntrySync:()=>Vs,WriteEntryTar:()=>Ks,c:()=>bs,create:()=>bs,extract:()=>Ds,filesFilter:()=>Wi,list:()=>Bt,r:()=>yt,replace:()=>yt,t:()=>Bt,types:()=>Hs,x:()=>Ds}),Rr=Object.defineProperty,_r=(t,e)=>{for(var i in e)Rr(t,i,{get:e[i],enumerable:!0})},Qi=process||{stdout:null,stderr:null},Sr=t=>!!t&&typeof t=="object"&&(t instanceof wt||t instanceof As||Or(t)||kr(t)),Or=t=>!!t&&typeof t=="object"&&t instanceof zi&&typeof t.pipe=="function"&&t.pipe!==As.Writable.prototype.pipe,kr=t=>!!t&&typeof t=="object"&&t instanceof zi&&typeof t.write=="function"&&typeof t.end=="function",G=Symbol("EOF"),$=Symbol("maybeEmitEnd"),q=Symbol("emittedEnd"),oe=Symbol("emittingEnd"),Mt=Symbol("emittedError"),le=Symbol("closed"),Ji=Symbol("read"),de=Symbol("flush"),ts=Symbol("flushChunk"),B=Symbol("encoding"),_t=Symbol("decoder"),R=Symbol("flowing"),Ct=Symbol("paused"),Tt=Symbol("resume"),_=Symbol("buffer"),x=Symbol("pipes"),S=Symbol("bufferLength"),Ze=Symbol("bufferPush"),ue=Symbol("bufferShift"),L=Symbol("objectMode"),E=Symbol("destroyed"),We=Symbol("error"),Ge=Symbol("emitData"),es=Symbol("emitEnd"),$e=Symbol("emitEnd2"),z=Symbol("async"),Ye=Symbol("abort"),fe=Symbol("aborted"),Pt=Symbol("signal"),lt=Symbol("dataListeners"),A=Symbol("discarded"),zt=t=>Promise.resolve().then(t),Tr=t=>t(),Lr=t=>t==="end"||t==="finish"||t==="prefinish",xr=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Dr=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Fs=class{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[Tt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ar=class extends Fs{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=s=>this.dest.emit("error",s),t.on("error",this.proxyErrors)}},Nr=t=>!!t.objectMode,Ir=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",wt=class extends zi{[R]=!1;[Ct]=!1;[x]=[];[_]=[];[L];[B];[z];[_t];[G]=!1;[q]=!1;[oe]=!1;[le]=!1;[Mt]=null;[S]=0;[E]=!1;[Pt];[fe]=!1;[lt]=0;[A]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw TypeError("Encoding and objectMode may not be used together");Nr(e)?(this[L]=!0,this[B]=null):Ir(e)?(this[B]=e.encoding,this[L]=!1):(this[L]=!1,this[B]=null),this[z]=!!e.async,this[_t]=this[B]?new yr(this[B]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[_]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[x]});let{signal:i}=e;i&&(this[Pt]=i,i.aborted?this[Ye]():i.addEventListener("abort",()=>this[Ye]()))}get bufferLength(){return this[S]}get encoding(){return this[B]}set encoding(t){throw Error("Encoding must be set at instantiation time")}setEncoding(t){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[L]}set objectMode(t){throw Error("objectMode must be set at instantiation time")}get async(){return this[z]}set async(t){this[z]=this[z]||!!t}[Ye](){this[fe]=!0,this.emit("abort",this[Pt]?.reason),this.destroy(this[Pt]?.reason)}get aborted(){return this[fe]}set aborted(t){}write(t,e,i){if(this[fe])return!1;if(this[G])throw Error("write after end");if(this[E])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(i=e,e="utf8"),e||="utf8";let s=this[z]?zt:Tr;if(!this[L]&&!Buffer.isBuffer(t)){if(Dr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(xr(t))t=Buffer.from(t);else if(typeof t!="string")throw Error("Non-contiguous data written to non-objectMode stream")}return this[L]?(this[R]&&this[S]!==0&&this[de](!0),this[R]?this.emit("data",t):this[Ze](t),this[S]!==0&&this.emit("readable"),i&&s(i),this[R]):t.length?(typeof t=="string"&&!(e===this[B]&&!this[_t]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[B]&&(t=this[_t].write(t)),this[R]&&this[S]!==0&&this[de](!0),this[R]?this.emit("data",t):this[Ze](t),this[S]!==0&&this.emit("readable"),i&&s(i),this[R]):(this[S]!==0&&this.emit("readable"),i&&s(i),this[R])}read(t){if(this[E])return null;if(this[A]=!1,this[S]===0||t===0||t&&t>this[S])return this[$](),null;this[L]&&(t=null),this[_].length>1&&!this[L]&&(this[_]=[this[B]?this[_].join(""):Buffer.concat(this[_],this[S])]);let e=this[Ji](t||null,this[_][0]);return this[$](),e}[Ji](t,e){if(this[L])this[ue]();else{let i=e;t===i.length||t===null?this[ue]():typeof i=="string"?(this[_][0]=i.slice(t),e=i.slice(0,t),this[S]-=t):(this[_][0]=i.subarray(t),e=i.subarray(0,t),this[S]-=t)}return this.emit("data",e),!this[_].length&&!this[G]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[G]=!0,this.writable=!1,(this[R]||!this[Ct])&&this[$](),this}[Tt](){this[E]||(!this[lt]&&!this[x].length&&(this[A]=!0),this[Ct]=!1,this[R]=!0,this.emit("resume"),this[_].length?this[de]():this[G]?this[$]():this.emit("drain"))}resume(){return this[Tt]()}pause(){this[R]=!1,this[Ct]=!0,this[A]=!1}get destroyed(){return this[E]}get flowing(){return this[R]}get paused(){return this[Ct]}[Ze](t){this[L]?this[S]+=1:this[S]+=t.length,this[_].push(t)}[ue](){return this[L]?--this[S]:this[S]-=this[_][0].length,this[_].shift()}[de](t=!1){do;while(this[ts](this[ue]())&&this[_].length);!t&&!this[_].length&&!this[G]&&this.emit("drain")}[ts](t){return this.emit("data",t),this[R]}pipe(t,e){if(this[E])return t;this[A]=!1;let i=this[q];return e||={},t===Qi.stdout||t===Qi.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[x].push(e.proxyErrors?new Ar(this,t,e):new Fs(this,t,e)),this[z]?zt(()=>this[Tt]()):this[Tt]()),t}unpipe(t){let e=this[x].find(i=>i.dest===t);e&&(this[x].length===1?(this[R]&&this[lt]===0&&(this[R]=!1),this[x]=[]):this[x].splice(this[x].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[A]=!1,this[lt]++,!this[x].length&&!this[R]&&this[Tt]();else if(t==="readable"&&this[S]!==0)super.emit("readable");else if(Lr(t)&&this[q])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Mt]){let s=e;this[z]?zt(()=>s.call(this,this[Mt])):s.call(this,this[Mt])}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[lt]=this.listeners("data").length,this[lt]===0&&!this[A]&&!this[x].length&&(this[R]=!1)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[lt]=0,!this[A]&&!this[x].length&&(this[R]=!1)),e}get emittedEnd(){return this[q]}[$](){!this[oe]&&!this[q]&&!this[E]&&this[_].length===0&&this[G]&&(this[oe]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[le]&&this.emit("close"),this[oe]=!1)}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==E&&this[E])return!1;if(t==="data")return!this[L]&&!i?!1:this[z]?(zt(()=>this[Ge](i)),!0):this[Ge](i);if(t==="end")return this[es]();if(t==="close"){if(this[le]=!0,!this[q]&&!this[E])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[Mt]=i,super.emit(We,i);let r=!this[Pt]||this.listeners("error").length?super.emit("error",i):!1;return this[$](),r}else if(t==="resume"){let r=super.emit("resume");return this[$](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let s=super.emit(t,...e);return this[$](),s}[Ge](t){for(let i of this[x])i.dest.write(t)===!1&&this.pause();let e=!this[A]&&super.emit("data",t);return this[$](),e}[es](){return this[q]?!1:(this[q]=!0,this.readable=!1,this[z]?(zt(()=>this[$e]()),!0):this[$e]())}[$e](){if(this[_t]){let e=this[_t].end();if(e){for(let i of this[x])i.dest.write(e);this[A]||super.emit("data",e)}}for(let e of this[x])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[L]||(t.dataLength=0);let e=this.promise();return this.on("data",i=>{t.push(i),this[L]||(t.dataLength+=i.length)}),await e,t}async concat(){if(this[L])throw Error("cannot concat in objectMode");let t=await this.collect();return this[B]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(E,()=>e(Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[A]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[G])return e();let s,r,h=l=>{this.off("data",n),this.off("end",a),this.off(E,o),e(),r(l)},n=l=>{this.off("error",h),this.off("end",a),this.off(E,o),this.pause(),s({value:l,done:!!this[G]})},a=()=>{this.off("error",h),this.off("data",n),this.off(E,o),e(),s({done:!0,value:void 0})},o=()=>h(Error("stream destroyed"));return new Promise((l,u)=>{r=u,s=l,this.once(E,o),this.once("error",h),this.once("end",a),this.once("data",n)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[A]=!1;let t=!1,e=()=>(this.pause(),this.off(We,e),this.off(E,e),this.off("end",e),t=!0,{done:!0,value:void 0});return this.once("end",e),this.once(We,e),this.once(E,e),{next:()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}},throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[E])return t?this.emit("error",t):this.emit(E),this;this[E]=!0,this[A]=!0,this[_].length=0,this[S]=0;let e=this;return typeof e.close=="function"&&!this[le]&&e.close(),t?this.emit("error",t):this.emit(E),this}static get isStream(){return Sr}},Br=p.writev,nt=Symbol("_autoClose"),P=Symbol("_close"),Ut=Symbol("_ended"),m=Symbol("_fd"),Ve=Symbol("_finished"),X=Symbol("_flags"),Ke=Symbol("_flush"),yi=Symbol("_handleChunk"),bi=Symbol("_makeBuf"),qt=Symbol("_mode"),ce=Symbol("_needDrain"),Nt=Symbol("_onerror"),It=Symbol("_onopen"),Xe=Symbol("_onread"),Lt=Symbol("_onwrite"),at=Symbol("_open"),C=Symbol("_path"),et=Symbol("_pos"),U=Symbol("_queue"),xt=Symbol("_read"),qe=Symbol("_readSize"),K=Symbol("_reading"),jt=Symbol("_remain"),Qe=Symbol("_size"),_e=Symbol("_write"),dt=Symbol("_writing"),Se=Symbol("_defaultFlag"),gt=Symbol("_errored"),Ui=class extends wt{[gt]=!1;[m];[C];[qe];[K]=!1;[Qe];[jt];[nt];constructor(t,e){if(e||={},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw TypeError("path must be a string");this[gt]=!1,this[m]=typeof e.fd=="number"?e.fd:void 0,this[C]=t,this[qe]=e.readSize||16*1024*1024,this[K]=!1,this[Qe]=typeof e.size=="number"?e.size:1/0,this[jt]=this[Qe],this[nt]=typeof e.autoClose!="boolean"||e.autoClose,typeof this[m]=="number"?this[xt]():this[at]()}get fd(){return this[m]}get path(){return this[C]}write(){throw TypeError("this is a readable stream")}end(){throw TypeError("this is a readable stream")}[at](){p.open(this[C],"r",(t,e)=>this[It](t,e))}[It](t,e){t?this[Nt](t):(this[m]=e,this.emit("open",e),this[xt]())}[bi](){return Buffer.allocUnsafe(Math.min(this[qe],this[jt]))}[xt](){if(!this[K]){this[K]=!0;let t=this[bi]();if(t.length===0)return process.nextTick(()=>this[Xe](null,0,t));p.read(this[m],t,0,t.length,null,(e,i,s)=>this[Xe](e,i,s))}}[Xe](t,e,i){this[K]=!1,t?this[Nt](t):this[yi](e,i)&&this[xt]()}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Nt](t){this[K]=!0,this[P](),this.emit("error",t)}[yi](t,e){let i=!1;return this[jt]-=t,t>0&&(i=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[jt]<=0)&&(i=!1,this[P](),super.end()),i}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[m]=="number"&&this[xt](),!1;case"error":return this[gt]?!1:(this[gt]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Fr=class extends Ui{[at](){let t=!0;try{this[It](null,p.openSync(this[C],"r")),t=!1}finally{t&&this[P]()}}[xt](){let t=!0;try{if(!this[K]){this[K]=!0;do{let e=this[bi](),i=e.length===0?0:p.readSync(this[m],e,0,e.length,null);if(!this[yi](i,e))break}while(!0);this[K]=!1}t=!1}finally{t&&this[P]()}}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.closeSync(t),this.emit("close")}}},Ce=class extends Is{readable=!1;writable=!0;[gt]=!1;[dt]=!1;[Ut]=!1;[U]=[];[ce]=!1;[C];[qt];[nt];[m];[Se];[X];[Ve]=!1;[et];constructor(t,e){e||={},super(e),this[C]=t,this[m]=typeof e.fd=="number"?e.fd:void 0,this[qt]=e.mode===void 0?438:e.mode,this[et]=typeof e.start=="number"?e.start:void 0,this[nt]=typeof e.autoClose!="boolean"||e.autoClose;let i=this[et]===void 0?"w":"r+";this[Se]=e.flags===void 0,this[X]=e.flags===void 0?i:e.flags,this[m]===void 0&&this[at]()}emit(t,...e){if(t==="error"){if(this[gt])return!1;this[gt]=!0}return super.emit(t,...e)}get fd(){return this[m]}get path(){return this[C]}[Nt](t){this[P](),this[dt]=!0,this.emit("error",t)}[at](){p.open(this[C],this[X],this[qt],(t,e)=>this[It](t,e))}[It](t,e){this[Se]&&this[X]==="r+"&&t&&t.code==="ENOENT"?(this[X]="w",this[at]()):t?this[Nt](t):(this[m]=e,this.emit("open",e),this[dt]||this[Ke]())}end(t,e){return t&&this.write(t,e),this[Ut]=!0,!this[dt]&&!this[U].length&&typeof this[m]=="number"&&this[Lt](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[Ut]?(this.emit("error",Error("write() after end()")),!1):this[m]===void 0||this[dt]||this[U].length?(this[U].push(t),this[ce]=!0,!1):(this[dt]=!0,this[_e](t),!0)}[_e](t){p.write(this[m],t,0,t.length,this[et],(e,i)=>this[Lt](e,i))}[Lt](t,e){t?this[Nt](t):(this[et]!==void 0&&typeof e=="number"&&(this[et]+=e),this[U].length?this[Ke]():(this[dt]=!1,this[Ut]&&!this[Ve]?(this[Ve]=!0,this[P](),this.emit("finish")):this[ce]&&(this[ce]=!1,this.emit("drain"))))}[Ke](){if(this[U].length===0)this[Ut]&&this[Lt](null,0);else if(this[U].length===1)this[_e](this[U].pop());else{let t=this[U];this[U]=[],Br(this[m],t,this[et],(e,i)=>this[Lt](e,i))}}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Ms=class extends Ce{[at](){let t;if(this[Se]&&this[X]==="r+")try{t=p.openSync(this[C],this[X],this[qt])}catch(e){if(e?.code==="ENOENT")return this[X]="w",this[at]();throw e}else t=p.openSync(this[C],this[X],this[qt]);this[It](null,t)}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.closeSync(t),this.emit("close")}}[_e](t){let e=!0;try{this[Lt](null,p.writeSync(this[m],t,0,t.length,this[et])),e=!1}finally{if(e)try{this[P]()}catch{}}}},Mr=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),Cr=t=>!!t.sync&&!!t.file,Pr=t=>!t.sync&&!!t.file,zr=t=>!!t.sync&&!t.file,Ur=t=>!t.sync&&!t.file,jr=t=>!!t.file,Hr=t=>Mr.get(t)||t,ji=(t={})=>{if(!t)return{};let e={};for(let[i,s]of Object.entries(t)){let r=Hr(i);e[r]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},ne=(t,e,i,s,r)=>Object.assign((h=[],n,a)=>{Array.isArray(h)&&(n=h,h={}),typeof n=="function"&&(a=n,n=void 0),n=n?Array.from(n):[];let o=ji(h);if(r?.(o,n),Cr(o)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return t(o,n)}else if(Pr(o)){let l=e(o,n);return a?l.then(()=>a(),a):l}else if(zr(o)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return i(o,n)}else if(Ur(o)){if(typeof a=="function")throw TypeError("callback only supported with file option");return s(o,n)}throw Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:i,asyncNoFile:s,validate:r}),Zr=Er.constants||{ZLIB_VERNUM:4736},W=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Zr)),Wr=bt.concat,is=Object.getOwnPropertyDescriptor(bt,"concat"),Gr=t=>t,Je=is?.writable===!0||is?.set!==void 0?t=>{bt.concat=t?Gr:Wr}:t=>{},Et=Symbol("_superWrite"),me=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||="ZLIB_ERROR",this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ti=Symbol("flushFlag"),Hi=class extends wt{#t=!1;#i=!1;#s;#h;#r;#e;#n;get sawError(){return this.#t}get handle(){return this.#e}get flushFlag(){return this.#s}constructor(t,e){if(!t||typeof t!="object")throw TypeError("invalid options for ZlibBase constructor");if(super(t),this.#s=t.flush??0,this.#h=t.finishFlush??0,this.#r=t.fullFlushFlag??0,typeof qi[e]!="function")throw TypeError("Compression method not supported: "+e);try{this.#e=new qi[e](t)}catch(i){throw new me(i,this.constructor)}this.#n=i=>{this.#t||(this.#t=!0,this.close(),this.emit("error",i))},this.#e?.on("error",i=>this.#n(new me(i))),this.once("end",()=>this.close)}close(){this.#e&&(this.#e.close(),this.#e=void 0,this.emit("close"))}reset(){if(!this.#t)return vi(this.#e,"zlib binding closed"),this.#e.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#r),this.write(Object.assign(bt.alloc(0),{[ti]:t})))}end(t,e,i){return typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#h),this.#i=!0,super.end(i)}get ended(){return this.#i}[Et](t){return super.write(t)}write(t,e,i){if(typeof e=="function"&&(i=e,e="utf8"),typeof t=="string"&&(t=bt.from(t,e)),this.#t)return;vi(this.#e,"zlib binding closed");let s=this.#e._handle,r=s.close;s.close=()=>{};let h=this.#e.close;this.#e.close=()=>{},Je(!0);let n;try{let o=typeof t[ti]=="number"?t[ti]:this.#s;n=this.#e._processChunk(t,o),Je(!1)}catch(o){Je(!1),this.#n(new me(o,this.write))}finally{this.#e&&(this.#e._handle=s,s.close=r,this.#e.close=h,this.#e.removeAllListeners("error"))}this.#e&&this.#e.on("error",o=>this.#n(new me(o,this.write)));let a;if(n)if(Array.isArray(n)&&n.length>0){let o=n[0];a=this[Et](bt.from(o));for(let l=1;l<n.length;l++)a=this[Et](n[l])}else a=this[Et](bt.from(n));return i&&i(),a}},Cs=class extends Hi{#t;#i;constructor(t,e){t||={},t.flush=t.flush||W.Z_NO_FLUSH,t.finishFlush=t.finishFlush||W.Z_FINISH,t.fullFlushFlag=W.Z_FULL_FLUSH,super(t,e),this.#t=t.level,this.#i=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw Error("cannot switch params when binding is closed");if(!this.handle.params)throw Error("not supported in this implementation");if(this.#t!==t||this.#i!==e){this.flush(W.Z_SYNC_FLUSH),vi(this.handle,"zlib binding closed");let i=this.handle.flush;this.handle.flush=(s,r)=>{typeof s=="function"&&(r=s,s=this.flushFlag),this.flush(s),r?.()};try{this.handle.params(t,e)}finally{this.handle.flush=i}this.handle&&(this.#t=t,this.#i=e)}}}},$r=class extends Cs{#t;constructor(t){super(t,"Gzip"),this.#t=t&&!!t.portable}[Et](t){return this.#t?(this.#t=!1,t[9]=255,super[Et](t)):super[Et](t)}},Yr=class extends Cs{constructor(t){super(t,"Unzip")}},Ps=class extends Hi{constructor(t,e){t||={},t.flush=t.flush||W.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||W.BROTLI_OPERATION_FINISH,t.fullFlushFlag=W.BROTLI_OPERATION_FLUSH,super(t,e)}},Vr=class extends Ps{constructor(t){super(t,"BrotliCompress")}},Kr=class extends Ps{constructor(t){super(t,"BrotliDecompress")}},zs=class extends Hi{constructor(t,e){t||={},t.flush=t.flush||W.ZSTD_e_continue,t.finishFlush=t.finishFlush||W.ZSTD_e_end,t.fullFlushFlag=W.ZSTD_e_flush,super(t,e)}},Xr=class extends zs{constructor(t){super(t,"ZstdCompress")}},qr=class extends zs{constructor(t){super(t,"ZstdDecompress")}},Qr=(t,e)=>{if(Number.isSafeInteger(t))t<0?th(t,e):Jr(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Jr=(t,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=t&255,t=Math.floor(t/256)},th=(t,e)=>{e[0]=255;var i=!1;t*=-1;for(var s=e.length;s>1;s--){var r=t&255;t=Math.floor(t/256),i?e[s-1]=Us(r):r===0?e[s-1]=0:(i=!0,e[s-1]=js(r))}},eh=t=>{let e=t[0],i=e===128?sh(t.subarray(1,t.length)):e===255?ih(t):null;if(i===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(i))throw Error("parsed number outside of javascript safe integer range");return i},ih=t=>{for(var e=t.length,i=0,s=!1,r=e-1;r>-1;r--){var h=Number(t[r]),n;s?n=Us(h):h===0?n=h:(s=!0,n=js(h)),n!==0&&(i-=n*256**(e-r-1))}return i},sh=t=>{for(var e=t.length,i=0,s=e-1;s>-1;s--){var r=Number(t[s]);r!==0&&(i+=r*256**(e-s-1))}return i},Us=t=>(255^t)&255,js=t=>(255^t)+1&255,Hs={};_r(Hs,{code:()=>Zi,isCode:()=>Oe,isName:()=>rh,name:()=>Pe,normalFsTypes:()=>Zs});var Oe=t=>Pe.has(t),rh=t=>Zi.has(t),Zs=new Set(["0","","1","2","3","4","5","6","7","D"]),Pe=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Zi=new Map(Array.from(Pe).map(t=>[t[1],t[0]])),hh=t=>t===void 0||t<0?void 0:t,ot=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#t="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,i,s){Buffer.isBuffer(t)?this.decode(t,e||0,i,s):t&&this.#i(t)}decode(t,e,i,s){if(e||=0,!t||!(t.length>=e+512))throw Error("need 512 bytes for header");let r=ut(t,e+156,1),h=Zs.has(r),n=h?i:void 0,a=h?s:void 0;if(this.path=n?.path??ut(t,e,100),this.mode=n?.mode??a?.mode??it(t,e+100,8),this.uid=n?.uid??a?.uid??it(t,e+108,8),this.gid=n?.gid??a?.gid??it(t,e+116,8),this.size=hh(n?.size??a?.size??it(t,e+124,12)),this.mtime=n?.mtime??a?.mtime??ei(t,e+136,12),this.cksum=it(t,e+148,12),a&&this.#i(a,!0),n&&this.#i(n),Oe(r)&&(this.#t=r||"0"),this.#t==="0"&&this.path.slice(-1)==="/"&&(this.#t="5"),this.#t==="5"&&(this.size=0),this.linkpath=ut(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=n?.uname??a?.uname??ut(t,e+265,32),this.gname=n?.gname??a?.gname??ut(t,e+297,32),this.devmaj=n?.devmaj??a?.devmaj??it(t,e+329,8)??0,this.devmin=n?.devmin??a?.devmin??it(t,e+337,8)??0,t[e+475]!==0){let l=ut(t,e+345,155);this.path=l+"/"+this.path}else{let l=ut(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=i?.atime??s?.atime??ei(t,e+476,12),this.ctime=i?.ctime??s?.ctime??ei(t,e+488,12)}let o=256;for(let l=e;l<e+148;l++)o+=t[l];for(let l=e+156;l<e+512;l++)o+=t[l];this.cksumValid=o===this.cksum,this.cksum===void 0&&o===256&&(this.nullBlock=!0)}#i(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,s])=>!(s==null||i==="size"&&Number(s)<0||i==="path"&&e||i==="linkpath"&&e||i==="global"))))}encode(t,e=0){if(t||=this.block=Buffer.alloc(512),this.#t==="Unsupported"&&(this.#t="0"),!(t.length>=e+512))throw Error("need 512 bytes for header");let i=this.ctime||this.atime?130:155,s=nh(this.path||"",i),r=s[0],h=s[1];this.needPax=!!s[2],this.needPax=ft(t,e,100,r)||this.needPax,this.needPax=st(t,e+100,8,this.mode)||this.needPax,this.needPax=st(t,e+108,8,this.uid)||this.needPax,this.needPax=st(t,e+116,8,this.gid)||this.needPax,this.needPax=st(t,e+124,12,this.size)||this.needPax,this.needPax=ii(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#t.codePointAt(0)),this.needPax=ft(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=ft(t,e+265,32,this.uname)||this.needPax,this.needPax=ft(t,e+297,32,this.gname)||this.needPax,this.needPax=st(t,e+329,8,this.devmaj)||this.needPax,this.needPax=st(t,e+337,8,this.devmin)||this.needPax,this.needPax=ft(t,e+345,i,h)||this.needPax,t[e+475]===0?(this.needPax=ft(t,e+345,130,h)||this.needPax,this.needPax=ii(t,e+476,12,this.atime)||this.needPax,this.needPax=ii(t,e+488,12,this.ctime)||this.needPax):this.needPax=ft(t,e+345,155,h)||this.needPax;let n=256;for(let a=e;a<e+148;a++)n+=t[a];for(let a=e+156;a<e+512;a++)n+=t[a];return this.cksum=n,st(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#t==="Unsupported"?this.#t:Pe.get(this.#t)}get typeKey(){return this.#t}set type(t){let e=String(Zi.get(t));if(Oe(e)||e==="Unsupported")this.#t=e;else if(Oe(t))this.#t=t;else throw TypeError("invalid entry type: "+t)}},nh=(t,e)=>{let i=t,s="",r,h=Rt.parse(t).root||".";if(Buffer.byteLength(i)<100)r=[i,s,!1];else{s=Rt.dirname(i),i=Rt.basename(i);do Buffer.byteLength(i)<=100&&Buffer.byteLength(s)<=e?r=[i,s,!1]:Buffer.byteLength(i)>100&&Buffer.byteLength(s)<=e?r=[i.slice(0,99),s,!0]:(i=Rt.join(Rt.basename(s),i),s=Rt.dirname(s));while(s!==h&&r===void 0);r||=[t.slice(0,99),"",!0]}return r},ut=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),ei=(t,e,i)=>ah(it(t,e,i)),ah=t=>t===void 0?void 0:new Date(t*1e3),it=(t,e,i)=>Number(t[e])&128?eh(t.subarray(e,e+i)):lh(t,e,i),oh=t=>isNaN(t)?void 0:t,lh=(t,e,i)=>oh(parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8)),dh={12:8589934591,8:2097151},st=(t,e,i,s)=>s===void 0?!1:s>dh[i]||s<0?(Qr(s,t.subarray(e,e+i)),!0):(uh(t,e,i,s),!1),uh=(t,e,i,s)=>t.write(fh(s,i),e,i,"ascii"),fh=(t,e)=>ch(Math.floor(t).toString(8),e),ch=(t,e)=>(t.length===e-1?t:Array(e-t.length-1).join("0")+t+" ")+"\0",ii=(t,e,i,s)=>s!==void 0&&st(t,e,i,s.getTime()/1e3),mh=Array(156).join("\0"),ft=(t,e,i,s)=>s===void 0?!1:(t.write(s+mh,e,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i),he=class Ws{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,i=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=i,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let i=Buffer.byteLength(e),s=512*Math.ceil(1+i/512),r=Buffer.allocUnsafe(s);for(let h=0;h<512;h++)r[h]=0;new ot({path:("PaxHeader/"+mr(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:i,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(r),r.write(e,512,i,"utf8");for(let h=i+512;h<r.length;h++)r[h]=0;return r}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let i=this[e],s=i instanceof Date?i.getTime()/1e3:i,r=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+s+`
1
+ import{createRequire as lr}from"node:module";import{_ as fr}from"../packem_shared/git-source-DExWbfN0.js";let dr;const ur=t=>(dr??=lr(import.meta.url))(t),Ft=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=t=>{if(typeof Ft<"u"&&Ft.versions&&Ft.versions.node){const[e,i]=Ft.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return Ft.getBuiltinModule(t)}return ur(t)},d=D("node:fs"),cr=D("node:fs/promises"),As=D("node:stream"),c=D("node:path"),{posix:Rt,basename:mr,win32:pr,join:Ns}=c,Is=D("events"),{EventEmitter:vr}=Is,p=D("fs"),{EventEmitter:zi}=D("node:events"),{StringDecoder:yr}=D("node:string_decoder"),re=D("path"),{parse:br,dirname:gr}=re,vi=D("assert"),{Buffer:bt}=D("buffer"),Xi=D("zlib"),qi={...Xi,default:Xi},Er=D("zlib"),wr=D("node:assert"),{randomBytes:Bs}=D("node:crypto");var an=fr({Header:()=>ot,Pack:()=>ae,PackJob:()=>Li,PackSync:()=>je,Parser:()=>At,Pax:()=>he,ReadEntry:()=>Gs,Unpack:()=>Me,UnpackSync:()=>Pi,WriteEntry:()=>Yi,WriteEntrySync:()=>Vs,WriteEntryTar:()=>Ks,c:()=>bs,create:()=>bs,extract:()=>Ds,filesFilter:()=>Wi,list:()=>Bt,r:()=>yt,replace:()=>yt,t:()=>Bt,types:()=>Hs,x:()=>Ds}),Rr=Object.defineProperty,_r=(t,e)=>{for(var i in e)Rr(t,i,{get:e[i],enumerable:!0})},Qi=process||{stdout:null,stderr:null},Sr=t=>!!t&&typeof t=="object"&&(t instanceof wt||t instanceof As||Or(t)||kr(t)),Or=t=>!!t&&typeof t=="object"&&t instanceof zi&&typeof t.pipe=="function"&&t.pipe!==As.Writable.prototype.pipe,kr=t=>!!t&&typeof t=="object"&&t instanceof zi&&typeof t.write=="function"&&typeof t.end=="function",G=Symbol("EOF"),$=Symbol("maybeEmitEnd"),q=Symbol("emittedEnd"),oe=Symbol("emittingEnd"),Mt=Symbol("emittedError"),le=Symbol("closed"),Ji=Symbol("read"),de=Symbol("flush"),ts=Symbol("flushChunk"),B=Symbol("encoding"),_t=Symbol("decoder"),R=Symbol("flowing"),Ct=Symbol("paused"),Tt=Symbol("resume"),_=Symbol("buffer"),x=Symbol("pipes"),S=Symbol("bufferLength"),Ze=Symbol("bufferPush"),ue=Symbol("bufferShift"),L=Symbol("objectMode"),E=Symbol("destroyed"),We=Symbol("error"),Ge=Symbol("emitData"),es=Symbol("emitEnd"),$e=Symbol("emitEnd2"),z=Symbol("async"),Ye=Symbol("abort"),fe=Symbol("aborted"),Pt=Symbol("signal"),lt=Symbol("dataListeners"),A=Symbol("discarded"),zt=t=>Promise.resolve().then(t),Tr=t=>t(),Lr=t=>t==="end"||t==="finish"||t==="prefinish",xr=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Dr=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Fs=class{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[Tt](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Ar=class extends Fs{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=s=>this.dest.emit("error",s),t.on("error",this.proxyErrors)}},Nr=t=>!!t.objectMode,Ir=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",wt=class extends zi{[R]=!1;[Ct]=!1;[x]=[];[_]=[];[L];[B];[z];[_t];[G]=!1;[q]=!1;[oe]=!1;[le]=!1;[Mt]=null;[S]=0;[E]=!1;[Pt];[fe]=!1;[lt]=0;[A]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw TypeError("Encoding and objectMode may not be used together");Nr(e)?(this[L]=!0,this[B]=null):Ir(e)?(this[B]=e.encoding,this[L]=!1):(this[L]=!1,this[B]=null),this[z]=!!e.async,this[_t]=this[B]?new yr(this[B]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[_]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[x]});let{signal:i}=e;i&&(this[Pt]=i,i.aborted?this[Ye]():i.addEventListener("abort",()=>this[Ye]()))}get bufferLength(){return this[S]}get encoding(){return this[B]}set encoding(t){throw Error("Encoding must be set at instantiation time")}setEncoding(t){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[L]}set objectMode(t){throw Error("objectMode must be set at instantiation time")}get async(){return this[z]}set async(t){this[z]=this[z]||!!t}[Ye](){this[fe]=!0,this.emit("abort",this[Pt]?.reason),this.destroy(this[Pt]?.reason)}get aborted(){return this[fe]}set aborted(t){}write(t,e,i){if(this[fe])return!1;if(this[G])throw Error("write after end");if(this[E])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(i=e,e="utf8"),e||="utf8";let s=this[z]?zt:Tr;if(!this[L]&&!Buffer.isBuffer(t)){if(Dr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(xr(t))t=Buffer.from(t);else if(typeof t!="string")throw Error("Non-contiguous data written to non-objectMode stream")}return this[L]?(this[R]&&this[S]!==0&&this[de](!0),this[R]?this.emit("data",t):this[Ze](t),this[S]!==0&&this.emit("readable"),i&&s(i),this[R]):t.length?(typeof t=="string"&&!(e===this[B]&&!this[_t]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[B]&&(t=this[_t].write(t)),this[R]&&this[S]!==0&&this[de](!0),this[R]?this.emit("data",t):this[Ze](t),this[S]!==0&&this.emit("readable"),i&&s(i),this[R]):(this[S]!==0&&this.emit("readable"),i&&s(i),this[R])}read(t){if(this[E])return null;if(this[A]=!1,this[S]===0||t===0||t&&t>this[S])return this[$](),null;this[L]&&(t=null),this[_].length>1&&!this[L]&&(this[_]=[this[B]?this[_].join(""):Buffer.concat(this[_],this[S])]);let e=this[Ji](t||null,this[_][0]);return this[$](),e}[Ji](t,e){if(this[L])this[ue]();else{let i=e;t===i.length||t===null?this[ue]():typeof i=="string"?(this[_][0]=i.slice(t),e=i.slice(0,t),this[S]-=t):(this[_][0]=i.subarray(t),e=i.subarray(0,t),this[S]-=t)}return this.emit("data",e),!this[_].length&&!this[G]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[G]=!0,this.writable=!1,(this[R]||!this[Ct])&&this[$](),this}[Tt](){this[E]||(!this[lt]&&!this[x].length&&(this[A]=!0),this[Ct]=!1,this[R]=!0,this.emit("resume"),this[_].length?this[de]():this[G]?this[$]():this.emit("drain"))}resume(){return this[Tt]()}pause(){this[R]=!1,this[Ct]=!0,this[A]=!1}get destroyed(){return this[E]}get flowing(){return this[R]}get paused(){return this[Ct]}[Ze](t){this[L]?this[S]+=1:this[S]+=t.length,this[_].push(t)}[ue](){return this[L]?--this[S]:this[S]-=this[_][0].length,this[_].shift()}[de](t=!1){do;while(this[ts](this[ue]())&&this[_].length);!t&&!this[_].length&&!this[G]&&this.emit("drain")}[ts](t){return this.emit("data",t),this[R]}pipe(t,e){if(this[E])return t;this[A]=!1;let i=this[q];return e||={},t===Qi.stdout||t===Qi.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[x].push(e.proxyErrors?new Ar(this,t,e):new Fs(this,t,e)),this[z]?zt(()=>this[Tt]()):this[Tt]()),t}unpipe(t){let e=this[x].find(i=>i.dest===t);e&&(this[x].length===1?(this[R]&&this[lt]===0&&(this[R]=!1),this[x]=[]):this[x].splice(this[x].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[A]=!1,this[lt]++,!this[x].length&&!this[R]&&this[Tt]();else if(t==="readable"&&this[S]!==0)super.emit("readable");else if(Lr(t)&&this[q])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Mt]){let s=e;this[z]?zt(()=>s.call(this,this[Mt])):s.call(this,this[Mt])}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[lt]=this.listeners("data").length,this[lt]===0&&!this[A]&&!this[x].length&&(this[R]=!1)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[lt]=0,!this[A]&&!this[x].length&&(this[R]=!1)),e}get emittedEnd(){return this[q]}[$](){!this[oe]&&!this[q]&&!this[E]&&this[_].length===0&&this[G]&&(this[oe]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[le]&&this.emit("close"),this[oe]=!1)}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==E&&this[E])return!1;if(t==="data")return!this[L]&&!i?!1:this[z]?(zt(()=>this[Ge](i)),!0):this[Ge](i);if(t==="end")return this[es]();if(t==="close"){if(this[le]=!0,!this[q]&&!this[E])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[Mt]=i,super.emit(We,i);let r=!this[Pt]||this.listeners("error").length?super.emit("error",i):!1;return this[$](),r}else if(t==="resume"){let r=super.emit("resume");return this[$](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let s=super.emit(t,...e);return this[$](),s}[Ge](t){for(let i of this[x])i.dest.write(t)===!1&&this.pause();let e=!this[A]&&super.emit("data",t);return this[$](),e}[es](){return this[q]?!1:(this[q]=!0,this.readable=!1,this[z]?(zt(()=>this[$e]()),!0):this[$e]())}[$e](){if(this[_t]){let e=this[_t].end();if(e){for(let i of this[x])i.dest.write(e);this[A]||super.emit("data",e)}}for(let e of this[x])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[L]||(t.dataLength=0);let e=this.promise();return this.on("data",i=>{t.push(i),this[L]||(t.dataLength+=i.length)}),await e,t}async concat(){if(this[L])throw Error("cannot concat in objectMode");let t=await this.collect();return this[B]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(E,()=>e(Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[A]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[G])return e();let s,r,h=l=>{this.off("data",n),this.off("end",a),this.off(E,o),e(),r(l)},n=l=>{this.off("error",h),this.off("end",a),this.off(E,o),this.pause(),s({value:l,done:!!this[G]})},a=()=>{this.off("error",h),this.off("data",n),this.off(E,o),e(),s({done:!0,value:void 0})},o=()=>h(Error("stream destroyed"));return new Promise((l,u)=>{r=u,s=l,this.once(E,o),this.once("error",h),this.once("end",a),this.once("data",n)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[A]=!1;let t=!1,e=()=>(this.pause(),this.off(We,e),this.off(E,e),this.off("end",e),t=!0,{done:!0,value:void 0});return this.once("end",e),this.once(We,e),this.once(E,e),{next:()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}},throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[E])return t?this.emit("error",t):this.emit(E),this;this[E]=!0,this[A]=!0,this[_].length=0,this[S]=0;let e=this;return typeof e.close=="function"&&!this[le]&&e.close(),t?this.emit("error",t):this.emit(E),this}static get isStream(){return Sr}},Br=p.writev,nt=Symbol("_autoClose"),P=Symbol("_close"),Ut=Symbol("_ended"),m=Symbol("_fd"),Ve=Symbol("_finished"),X=Symbol("_flags"),Ke=Symbol("_flush"),yi=Symbol("_handleChunk"),bi=Symbol("_makeBuf"),qt=Symbol("_mode"),ce=Symbol("_needDrain"),Nt=Symbol("_onerror"),It=Symbol("_onopen"),Xe=Symbol("_onread"),Lt=Symbol("_onwrite"),at=Symbol("_open"),C=Symbol("_path"),et=Symbol("_pos"),U=Symbol("_queue"),xt=Symbol("_read"),qe=Symbol("_readSize"),K=Symbol("_reading"),jt=Symbol("_remain"),Qe=Symbol("_size"),_e=Symbol("_write"),dt=Symbol("_writing"),Se=Symbol("_defaultFlag"),gt=Symbol("_errored"),Ui=class extends wt{[gt]=!1;[m];[C];[qe];[K]=!1;[Qe];[jt];[nt];constructor(t,e){if(e||={},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw TypeError("path must be a string");this[gt]=!1,this[m]=typeof e.fd=="number"?e.fd:void 0,this[C]=t,this[qe]=e.readSize||16*1024*1024,this[K]=!1,this[Qe]=typeof e.size=="number"?e.size:1/0,this[jt]=this[Qe],this[nt]=typeof e.autoClose!="boolean"||e.autoClose,typeof this[m]=="number"?this[xt]():this[at]()}get fd(){return this[m]}get path(){return this[C]}write(){throw TypeError("this is a readable stream")}end(){throw TypeError("this is a readable stream")}[at](){p.open(this[C],"r",(t,e)=>this[It](t,e))}[It](t,e){t?this[Nt](t):(this[m]=e,this.emit("open",e),this[xt]())}[bi](){return Buffer.allocUnsafe(Math.min(this[qe],this[jt]))}[xt](){if(!this[K]){this[K]=!0;let t=this[bi]();if(t.length===0)return process.nextTick(()=>this[Xe](null,0,t));p.read(this[m],t,0,t.length,null,(e,i,s)=>this[Xe](e,i,s))}}[Xe](t,e,i){this[K]=!1,t?this[Nt](t):this[yi](e,i)&&this[xt]()}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Nt](t){this[K]=!0,this[P](),this.emit("error",t)}[yi](t,e){let i=!1;return this[jt]-=t,t>0&&(i=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[jt]<=0)&&(i=!1,this[P](),super.end()),i}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[m]=="number"&&this[xt](),!1;case"error":return this[gt]?!1:(this[gt]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Fr=class extends Ui{[at](){let t=!0;try{this[It](null,p.openSync(this[C],"r")),t=!1}finally{t&&this[P]()}}[xt](){let t=!0;try{if(!this[K]){this[K]=!0;do{let e=this[bi](),i=e.length===0?0:p.readSync(this[m],e,0,e.length,null);if(!this[yi](i,e))break}while(!0);this[K]=!1}t=!1}finally{t&&this[P]()}}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.closeSync(t),this.emit("close")}}},Ce=class extends Is{readable=!1;writable=!0;[gt]=!1;[dt]=!1;[Ut]=!1;[U]=[];[ce]=!1;[C];[qt];[nt];[m];[Se];[X];[Ve]=!1;[et];constructor(t,e){e||={},super(e),this[C]=t,this[m]=typeof e.fd=="number"?e.fd:void 0,this[qt]=e.mode===void 0?438:e.mode,this[et]=typeof e.start=="number"?e.start:void 0,this[nt]=typeof e.autoClose!="boolean"||e.autoClose;let i=this[et]===void 0?"w":"r+";this[Se]=e.flags===void 0,this[X]=e.flags===void 0?i:e.flags,this[m]===void 0&&this[at]()}emit(t,...e){if(t==="error"){if(this[gt])return!1;this[gt]=!0}return super.emit(t,...e)}get fd(){return this[m]}get path(){return this[C]}[Nt](t){this[P](),this[dt]=!0,this.emit("error",t)}[at](){p.open(this[C],this[X],this[qt],(t,e)=>this[It](t,e))}[It](t,e){this[Se]&&this[X]==="r+"&&t&&t.code==="ENOENT"?(this[X]="w",this[at]()):t?this[Nt](t):(this[m]=e,this.emit("open",e),this[dt]||this[Ke]())}end(t,e){return t&&this.write(t,e),this[Ut]=!0,!this[dt]&&!this[U].length&&typeof this[m]=="number"&&this[Lt](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[Ut]?(this.emit("error",Error("write() after end()")),!1):this[m]===void 0||this[dt]||this[U].length?(this[U].push(t),this[ce]=!0,!1):(this[dt]=!0,this[_e](t),!0)}[_e](t){p.write(this[m],t,0,t.length,this[et],(e,i)=>this[Lt](e,i))}[Lt](t,e){t?this[Nt](t):(this[et]!==void 0&&typeof e=="number"&&(this[et]+=e),this[U].length?this[Ke]():(this[dt]=!1,this[Ut]&&!this[Ve]?(this[Ve]=!0,this[P](),this.emit("finish")):this[ce]&&(this[ce]=!1,this.emit("drain"))))}[Ke](){if(this[U].length===0)this[Ut]&&this[Lt](null,0);else if(this[U].length===1)this[_e](this[U].pop());else{let t=this[U];this[U]=[],Br(this[m],t,this[et],(e,i)=>this[Lt](e,i))}}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Ms=class extends Ce{[at](){let t;if(this[Se]&&this[X]==="r+")try{t=p.openSync(this[C],this[X],this[qt])}catch(e){if(e?.code==="ENOENT")return this[X]="w",this[at]();throw e}else t=p.openSync(this[C],this[X],this[qt]);this[It](null,t)}[P](){if(this[nt]&&typeof this[m]=="number"){let t=this[m];this[m]=void 0,p.closeSync(t),this.emit("close")}}[_e](t){let e=!0;try{this[Lt](null,p.writeSync(this[m],t,0,t.length,this[et])),e=!1}finally{if(e)try{this[P]()}catch{}}}},Mr=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),Cr=t=>!!t.sync&&!!t.file,Pr=t=>!t.sync&&!!t.file,zr=t=>!!t.sync&&!t.file,Ur=t=>!t.sync&&!t.file,jr=t=>!!t.file,Hr=t=>Mr.get(t)||t,ji=(t={})=>{if(!t)return{};let e={};for(let[i,s]of Object.entries(t)){let r=Hr(i);e[r]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},ne=(t,e,i,s,r)=>Object.assign((h=[],n,a)=>{Array.isArray(h)&&(n=h,h={}),typeof n=="function"&&(a=n,n=void 0),n=n?Array.from(n):[];let o=ji(h);if(r?.(o,n),Cr(o)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return t(o,n)}else if(Pr(o)){let l=e(o,n);return a?l.then(()=>a(),a):l}else if(zr(o)){if(typeof a=="function")throw TypeError("callback not supported for sync tar functions");return i(o,n)}else if(Ur(o)){if(typeof a=="function")throw TypeError("callback only supported with file option");return s(o,n)}throw Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:i,asyncNoFile:s,validate:r}),Zr=Er.constants||{ZLIB_VERNUM:4736},W=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Zr)),Wr=bt.concat,is=Object.getOwnPropertyDescriptor(bt,"concat"),Gr=t=>t,Je=is?.writable===!0||is?.set!==void 0?t=>{bt.concat=t?Gr:Wr}:t=>{},Et=Symbol("_superWrite"),me=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||="ZLIB_ERROR",this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ti=Symbol("flushFlag"),Hi=class extends wt{#t=!1;#i=!1;#s;#h;#r;#e;#n;get sawError(){return this.#t}get handle(){return this.#e}get flushFlag(){return this.#s}constructor(t,e){if(!t||typeof t!="object")throw TypeError("invalid options for ZlibBase constructor");if(super(t),this.#s=t.flush??0,this.#h=t.finishFlush??0,this.#r=t.fullFlushFlag??0,typeof qi[e]!="function")throw TypeError("Compression method not supported: "+e);try{this.#e=new qi[e](t)}catch(i){throw new me(i,this.constructor)}this.#n=i=>{this.#t||(this.#t=!0,this.close(),this.emit("error",i))},this.#e?.on("error",i=>this.#n(new me(i))),this.once("end",()=>this.close)}close(){this.#e&&(this.#e.close(),this.#e=void 0,this.emit("close"))}reset(){if(!this.#t)return vi(this.#e,"zlib binding closed"),this.#e.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#r),this.write(Object.assign(bt.alloc(0),{[ti]:t})))}end(t,e,i){return typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#h),this.#i=!0,super.end(i)}get ended(){return this.#i}[Et](t){return super.write(t)}write(t,e,i){if(typeof e=="function"&&(i=e,e="utf8"),typeof t=="string"&&(t=bt.from(t,e)),this.#t)return;vi(this.#e,"zlib binding closed");let s=this.#e._handle,r=s.close;s.close=()=>{};let h=this.#e.close;this.#e.close=()=>{},Je(!0);let n;try{let o=typeof t[ti]=="number"?t[ti]:this.#s;n=this.#e._processChunk(t,o),Je(!1)}catch(o){Je(!1),this.#n(new me(o,this.write))}finally{this.#e&&(this.#e._handle=s,s.close=r,this.#e.close=h,this.#e.removeAllListeners("error"))}this.#e&&this.#e.on("error",o=>this.#n(new me(o,this.write)));let a;if(n)if(Array.isArray(n)&&n.length>0){let o=n[0];a=this[Et](bt.from(o));for(let l=1;l<n.length;l++)a=this[Et](n[l])}else a=this[Et](bt.from(n));return i&&i(),a}},Cs=class extends Hi{#t;#i;constructor(t,e){t||={},t.flush=t.flush||W.Z_NO_FLUSH,t.finishFlush=t.finishFlush||W.Z_FINISH,t.fullFlushFlag=W.Z_FULL_FLUSH,super(t,e),this.#t=t.level,this.#i=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw Error("cannot switch params when binding is closed");if(!this.handle.params)throw Error("not supported in this implementation");if(this.#t!==t||this.#i!==e){this.flush(W.Z_SYNC_FLUSH),vi(this.handle,"zlib binding closed");let i=this.handle.flush;this.handle.flush=(s,r)=>{typeof s=="function"&&(r=s,s=this.flushFlag),this.flush(s),r?.()};try{this.handle.params(t,e)}finally{this.handle.flush=i}this.handle&&(this.#t=t,this.#i=e)}}}},$r=class extends Cs{#t;constructor(t){super(t,"Gzip"),this.#t=t&&!!t.portable}[Et](t){return this.#t?(this.#t=!1,t[9]=255,super[Et](t)):super[Et](t)}},Yr=class extends Cs{constructor(t){super(t,"Unzip")}},Ps=class extends Hi{constructor(t,e){t||={},t.flush=t.flush||W.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||W.BROTLI_OPERATION_FINISH,t.fullFlushFlag=W.BROTLI_OPERATION_FLUSH,super(t,e)}},Vr=class extends Ps{constructor(t){super(t,"BrotliCompress")}},Kr=class extends Ps{constructor(t){super(t,"BrotliDecompress")}},zs=class extends Hi{constructor(t,e){t||={},t.flush=t.flush||W.ZSTD_e_continue,t.finishFlush=t.finishFlush||W.ZSTD_e_end,t.fullFlushFlag=W.ZSTD_e_flush,super(t,e)}},Xr=class extends zs{constructor(t){super(t,"ZstdCompress")}},qr=class extends zs{constructor(t){super(t,"ZstdDecompress")}},Qr=(t,e)=>{if(Number.isSafeInteger(t))t<0?th(t,e):Jr(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Jr=(t,e)=>{e[0]=128;for(var i=e.length;i>1;i--)e[i-1]=t&255,t=Math.floor(t/256)},th=(t,e)=>{e[0]=255;var i=!1;t*=-1;for(var s=e.length;s>1;s--){var r=t&255;t=Math.floor(t/256),i?e[s-1]=Us(r):r===0?e[s-1]=0:(i=!0,e[s-1]=js(r))}},eh=t=>{let e=t[0],i=e===128?sh(t.subarray(1,t.length)):e===255?ih(t):null;if(i===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(i))throw Error("parsed number outside of javascript safe integer range");return i},ih=t=>{for(var e=t.length,i=0,s=!1,r=e-1;r>-1;r--){var h=Number(t[r]),n;s?n=Us(h):h===0?n=h:(s=!0,n=js(h)),n!==0&&(i-=n*256**(e-r-1))}return i},sh=t=>{for(var e=t.length,i=0,s=e-1;s>-1;s--){var r=Number(t[s]);r!==0&&(i+=r*256**(e-s-1))}return i},Us=t=>(255^t)&255,js=t=>(255^t)+1&255,Hs={};_r(Hs,{code:()=>Zi,isCode:()=>Oe,isName:()=>rh,name:()=>Pe,normalFsTypes:()=>Zs});var Oe=t=>Pe.has(t),rh=t=>Zi.has(t),Zs=new Set(["0","","1","2","3","4","5","6","7","D"]),Pe=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Zi=new Map(Array.from(Pe).map(t=>[t[1],t[0]])),hh=t=>t===void 0||t<0?void 0:t,ot=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#t="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,i,s){Buffer.isBuffer(t)?this.decode(t,e||0,i,s):t&&this.#i(t)}decode(t,e,i,s){if(e||=0,!t||!(t.length>=e+512))throw Error("need 512 bytes for header");let r=ut(t,e+156,1),h=Zs.has(r),n=h?i:void 0,a=h?s:void 0;if(this.path=n?.path??ut(t,e,100),this.mode=n?.mode??a?.mode??it(t,e+100,8),this.uid=n?.uid??a?.uid??it(t,e+108,8),this.gid=n?.gid??a?.gid??it(t,e+116,8),this.size=hh(n?.size??a?.size??it(t,e+124,12)),this.mtime=n?.mtime??a?.mtime??ei(t,e+136,12),this.cksum=it(t,e+148,12),a&&this.#i(a,!0),n&&this.#i(n),Oe(r)&&(this.#t=r||"0"),this.#t==="0"&&this.path.slice(-1)==="/"&&(this.#t="5"),this.#t==="5"&&(this.size=0),this.linkpath=ut(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=n?.uname??a?.uname??ut(t,e+265,32),this.gname=n?.gname??a?.gname??ut(t,e+297,32),this.devmaj=n?.devmaj??a?.devmaj??it(t,e+329,8)??0,this.devmin=n?.devmin??a?.devmin??it(t,e+337,8)??0,t[e+475]!==0){let l=ut(t,e+345,155);this.path=l+"/"+this.path}else{let l=ut(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=i?.atime??s?.atime??ei(t,e+476,12),this.ctime=i?.ctime??s?.ctime??ei(t,e+488,12)}let o=256;for(let l=e;l<e+148;l++)o+=t[l];for(let l=e+156;l<e+512;l++)o+=t[l];this.cksumValid=o===this.cksum,this.cksum===void 0&&o===256&&(this.nullBlock=!0)}#i(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,s])=>!(s==null||i==="size"&&Number(s)<0||i==="path"&&e||i==="linkpath"&&e||i==="global"))))}encode(t,e=0){if(t||=this.block=Buffer.alloc(512),this.#t==="Unsupported"&&(this.#t="0"),!(t.length>=e+512))throw Error("need 512 bytes for header");let i=this.ctime||this.atime?130:155,s=nh(this.path||"",i),r=s[0],h=s[1];this.needPax=!!s[2],this.needPax=ft(t,e,100,r)||this.needPax,this.needPax=st(t,e+100,8,this.mode)||this.needPax,this.needPax=st(t,e+108,8,this.uid)||this.needPax,this.needPax=st(t,e+116,8,this.gid)||this.needPax,this.needPax=st(t,e+124,12,this.size)||this.needPax,this.needPax=ii(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#t.codePointAt(0)),this.needPax=ft(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=ft(t,e+265,32,this.uname)||this.needPax,this.needPax=ft(t,e+297,32,this.gname)||this.needPax,this.needPax=st(t,e+329,8,this.devmaj)||this.needPax,this.needPax=st(t,e+337,8,this.devmin)||this.needPax,this.needPax=ft(t,e+345,i,h)||this.needPax,t[e+475]===0?(this.needPax=ft(t,e+345,130,h)||this.needPax,this.needPax=ii(t,e+476,12,this.atime)||this.needPax,this.needPax=ii(t,e+488,12,this.ctime)||this.needPax):this.needPax=ft(t,e+345,155,h)||this.needPax;let n=256;for(let a=e;a<e+148;a++)n+=t[a];for(let a=e+156;a<e+512;a++)n+=t[a];return this.cksum=n,st(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#t==="Unsupported"?this.#t:Pe.get(this.#t)}get typeKey(){return this.#t}set type(t){let e=String(Zi.get(t));if(Oe(e)||e==="Unsupported")this.#t=e;else if(Oe(t))this.#t=t;else throw TypeError("invalid entry type: "+t)}},nh=(t,e)=>{let i=t,s="",r,h=Rt.parse(t).root||".";if(Buffer.byteLength(i)<100)r=[i,s,!1];else{s=Rt.dirname(i),i=Rt.basename(i);do Buffer.byteLength(i)<=100&&Buffer.byteLength(s)<=e?r=[i,s,!1]:Buffer.byteLength(i)>100&&Buffer.byteLength(s)<=e?r=[i.slice(0,99),s,!0]:(i=Rt.join(Rt.basename(s),i),s=Rt.dirname(s));while(s!==h&&r===void 0);r||=[t.slice(0,99),"",!0]}return r},ut=(t,e,i)=>t.subarray(e,e+i).toString("utf8").replace(/\0.*/,""),ei=(t,e,i)=>ah(it(t,e,i)),ah=t=>t===void 0?void 0:new Date(t*1e3),it=(t,e,i)=>Number(t[e])&128?eh(t.subarray(e,e+i)):lh(t,e,i),oh=t=>isNaN(t)?void 0:t,lh=(t,e,i)=>oh(parseInt(t.subarray(e,e+i).toString("utf8").replace(/\0.*$/,"").trim(),8)),dh={12:8589934591,8:2097151},st=(t,e,i,s)=>s===void 0?!1:s>dh[i]||s<0?(Qr(s,t.subarray(e,e+i)),!0):(uh(t,e,i,s),!1),uh=(t,e,i,s)=>t.write(fh(s,i),e,i,"ascii"),fh=(t,e)=>ch(Math.floor(t).toString(8),e),ch=(t,e)=>(t.length===e-1?t:Array(e-t.length-1).join("0")+t+" ")+"\0",ii=(t,e,i,s)=>s!==void 0&&st(t,e,i,s.getTime()/1e3),mh=Array(156).join("\0"),ft=(t,e,i,s)=>s===void 0?!1:(t.write(s+mh,e,i,"utf8"),s.length!==Buffer.byteLength(s)||s.length>i),he=class Ws{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,i=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=i,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let i=Buffer.byteLength(e),s=512*Math.ceil(1+i/512),r=Buffer.allocUnsafe(s);for(let h=0;h<512;h++)r[h]=0;new ot({path:("PaxHeader/"+mr(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:i,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(r),r.write(e,512,i,"utf8");for(let h=i+512;h<r.length;h++)r[h]=0;return r}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let i=this[e],s=i instanceof Date?i.getTime()/1e3:i,r=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+s+`
2
2
  `,h=Buffer.byteLength(r),n=Math.floor(Math.log(h)/Math.log(10))+1;return h+n>=10**n&&(n+=1),n+h+r}static parse(e,i,s=!1){return new Ws(ph(vh(e),i),s)}},ph=(t,e)=>e?Object.assign({},e,t):t,vh=t=>t.replace(/\n$/,"").split(`
3
3
  `).reduce(yh,Object.create(null)),yh=(t,e)=>{let i=parseInt(e,10);if(i!==Buffer.byteLength(e)+1)return t;e=e.slice((i+" ").length);let s=e.split("="),r=s.shift();if(!r)return t;let h=r.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),n=s.join("=").replace(/\0.*/,"");switch(h){case"path":case"linkpath":case"type":case"charset":case"comment":case"gname":case"uname":t[h]=n;break;case"ctime":case"atime":case"mtime":t[h]=new Date(Number(n)*1e3);break;case"size":let a=+n;a>=0&&(t[h]=a);break;case"gid":case"uid":case"dev":case"ino":case"nlink":case"mode":t[h]=+n;break}return t},f=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32"?t=>String(t).replaceAll(/\\/g,"/"):t=>String(t),Gs=class extends wt{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,i){switch(super({}),this.pause(),this.extended=e,this.globalExtended=i,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw Error("no path provided for tar.ReadEntry");this.path=f(t.path),this.mode=t.mode,this.mode&&(this.mode&=4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?f(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#t(e),i&&this.#t(i,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw Error("writing more to entry than is appropriate");let i=this.remain,s=this.blockRemain;return this.remain=Math.max(0,i-e),this.blockRemain=Math.max(0,s-e),this.ignore?!0:i>=e?super.write(t):super.write(t.subarray(0,i))}#t(t,e=!1){t.path&&=f(t.path),t.linkpath&&=f(t.linkpath),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([i,s])=>!(s==null||i==="path"&&e))))}},ze=(t,e,i,s={})=>{t.file&&(s.file=t.file),t.cwd&&(s.cwd=t.cwd),s.code=i instanceof Error&&i.code||e,s.tarCode=e,!t.strict&&s.recoverable!==!1?(i instanceof Error&&(s=Object.assign(i,s),i=i.message),t.emit("warn",e,i,s)):i instanceof Error?t.emit("error",Object.assign(i,s)):t.emit("error",Object.assign(Error(`${e}: ${i}`),s))},bh=1024*1024,gi=Buffer.from([31,139]),Ei=Buffer.from([40,181,47,253]),gh=Math.max(gi.length,Ei.length),N=Symbol("state"),ct=Symbol("writeEntry"),Y=Symbol("readEntry"),si=Symbol("nextEntry"),ss=Symbol("processEntry"),j=Symbol("extendedHeader"),Ht=Symbol("globalExtendedHeader"),Q=Symbol("meta"),rs=Symbol("emitMeta"),v=Symbol("buffer"),V=Symbol("queue"),J=Symbol("ended"),ri=Symbol("emittedEnd"),mt=Symbol("emit"),g=Symbol("unzip"),pe=Symbol("consumeChunk"),ve=Symbol("consumeChunkSub"),hi=Symbol("consumeBody"),hs=Symbol("consumeMeta"),ns=Symbol("consumeHeader"),Zt=Symbol("consuming"),ni=Symbol("bufferConcat"),ye=Symbol("maybeEnd"),St=Symbol("writing"),H=Symbol("aborted"),be=Symbol("onDone"),pt=Symbol("sawValidEntry"),ge=Symbol("sawNullBlock"),Ee=Symbol("sawEOF"),as=Symbol("closeStream"),Eh=1e3,Wt=Symbol("compressedBytesRead"),ai=Symbol("decompressedBytesRead"),os=Symbol("checkDecompressionRatio"),wh=()=>!0,At=class extends vr{file;strict;maxMetaEntrySize;filter;brotli;zstd;maxDecompressionRatio;writable=!0;readable=!1;[V]=[];[v];[Y];[ct];[N]="begin";[Q]="";[j];[Ht];[J]=!1;[g];[H]=!1;[pt];[ge]=!1;[Ee]=!1;[St]=!1;[Zt]=!1;[ri]=!1;[Wt]=0;[ai]=0;constructor(t={}){super(),this.file=t.file||"",this.on(be,()=>{(this[N]==="begin"||this[pt]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(be,t.ondone):this.on(be,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxDecompressionRatio=typeof t.maxDecompressionRatio=="number"?t.maxDecompressionRatio:Eh,this.maxMetaEntrySize=t.maxMetaEntrySize||bh,this.filter=typeof t.filter=="function"?t.filter:wh;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let i=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:i?!0:void 0,this.on("end",()=>this[as]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,i={}){ze(this,t,e,i)}[ns](t,e){this[pt]===void 0&&(this[pt]=!1);let i;try{i=new ot(t,e,this[j],this[Ht])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(i.nullBlock)this[ge]?(this[Ee]=!0,this[N]==="begin"&&(this[N]="header"),this[mt]("eof")):(this[ge]=!0,this[mt]("nullBlock"));else if(this[ge]=!1,!i.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:i});else if(!i.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:i});else{let s=i.type;if(/^(Symbolic)?Link$/.test(s)&&!i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:i});else if(!/^(Symbolic)?Link$/.test(s)&&!/^(Global)?ExtendedHeader$/.test(s)&&i.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:i});else{let r=this[ct]=new Gs(i,this[j],this[Ht]);this[pt]||(r.remain?r.on("end",()=>{r.invalid||(this[pt]=!0)}):this[pt]=!0),r.meta?r.size>this.maxMetaEntrySize?(r.ignore=!0,this[mt]("ignoredEntry",r),this[N]="ignore",r.resume()):r.size>0&&(this[Q]="",r.on("data",h=>this[Q]+=h),this[N]="meta"):(this[j]=void 0,r.ignore=r.ignore||!this.filter(r.path,r),r.ignore?(this[mt]("ignoredEntry",r),this[N]=r.remain?"ignore":"header",r.resume()):(r.remain?this[N]="body":(this[N]="header",r.end()),this[Y]?this[V].push(r):(this[V].push(r),this[si]())))}}}[as](){queueMicrotask(()=>this.emit("close"))}[ss](t){let e=!0;if(!t)this[Y]=void 0,e=!1;else if(Array.isArray(t)){let[i,...s]=t;this.emit(i,...s)}else this[Y]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[si]()),e=!1);return e}[si](){do;while(this[ss](this[V].shift()));if(this[V].length===0){let t=this[Y];!t||t.flowing||t.size===t.remain?this[St]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[hi](t,e){let i=this[ct];if(!i)throw Error("attempt to consume body without entry??");let s=i.blockRemain??0,r=s>=t.length&&e===0?t:t.subarray(e,e+s);return i.write(r),i.blockRemain||(this[N]="header",this[ct]=void 0,i.end()),r.length}[hs](t,e){let i=this[ct],s=this[hi](t,e);return!this[ct]&&i&&this[rs](i),s}[mt](t,e,i){this[V].length===0&&!this[Y]?this.emit(t,e,i):this[V].push([t,e,i])}[rs](t){switch(this[mt]("meta",this[Q]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[j]=he.parse(this[Q],this[j],!1);break;case"GlobalExtendedHeader":this[Ht]=he.parse(this[Q],this[Ht],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[j]??Object.create(null);this[j]=e,e.path=this[Q].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[j]||Object.create(null);this[j]=e,e.linkpath=this[Q].replace(/\0.*/,"");break}default:throw Error("unknown meta: "+t.type)}}abort(t){if(!this[H]){if(this[g]){let e=this[g];e.write=()=>!0,e.end=()=>e,e.emit=()=>!1,e.destroy?.()}this[H]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}}[os](t){this[ai]+=t.length;let e=this[ai]/this[Wt];return e>this.maxDecompressionRatio?(this.abort(Error(`max decompression ratio exceeded: ${e.toFixed(2)} > ${this.maxDecompressionRatio}`)),!1):!0}write(t,e,i){if(typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[H])return i?.(),!1;if((this[g]===void 0||this.brotli===void 0&&this[g]===!1)&&t){if(this[v]&&(t=Buffer.concat([this[v],t]),this[v]=void 0),t.length<gh)return this[v]=t,i?.(),!0;for(let n=0;this[g]===void 0&&n<gi.length;n++)t[n]!==gi[n]&&(this[g]=!1);let r=!1;if(this[g]===!1&&this.zstd!==!1){r=!0;for(let n=0;n<Ei.length;n++)if(t[n]!==Ei[n]){r=!1;break}}let h=this.brotli===void 0&&!r;if(this[g]===!1&&h)if(t.length<512)if(this[J])this.brotli=!0;else return this[v]=t,i?.(),!0;else try{new ot(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[g]===void 0||this[g]===!1&&(this.brotli||r)){let n=this[J];this[J]=!1,this[g]=this[g]===void 0?new Yr({}):r?new qr({}):new Kr({}),this[g].on("data",o=>{this[os](o)&&this[pe](o)}),this[g].on("error",o=>{this[H]||this.abort(o)}),this[g].on("end",()=>{this[J]=!0,this[pe]()}),this[St]=!0,this[Wt]+=t.length;let a=!!this[g][n?"end":"write"](t);return this[St]=!1,i?.(),a}}this[St]=!0,this[g]?(this[Wt]+=t.length,this[g].write(t)):this[pe](t),this[St]=!1;let s=this[V].length>0?!1:!this[Y]||this[Y].flowing;return!s&&this[V].length===0&&this[Y]?.once("drain",()=>this.emit("drain")),i?.(),s}[ni](t){t&&!this[H]&&(this[v]=this[v]?Buffer.concat([this[v],t]):t)}[ye](){if(this[J]&&!this[ri]&&!this[H]&&!this[Zt]){this[ri]=!0;let t=this[ct];if(t?.blockRemain){let e=this[v]?this[v].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[v]&&t.write(this[v]),t.end()}this[mt](be)}}[pe](t){if(this[Zt]&&t)this[ni](t);else if(!t&&!this[v])this[ye]();else if(t){if(this[Zt]=!0,this[v]){this[ni](t);let e=this[v];this[v]=void 0,this[ve](e)}else this[ve](t);for(;this[v]&&this[v]?.length>=512&&!this[H]&&!this[Ee];){let e=this[v];this[v]=void 0,this[ve](e)}this[Zt]=!1}(!this[v]||this[J])&&this[ye]()}[ve](t){let e=0,i=t.length;for(;e+512<=i&&!this[H]&&!this[Ee];)switch(this[N]){case"begin":case"header":this[ns](t,e),e+=512;break;case"ignore":case"body":e+=this[hi](t,e);break;case"meta":e+=this[hs](t,e);break;default:throw Error("invalid state: "+this[N])}e<i&&(this[v]=this[v]?Buffer.concat([t.subarray(e),this[v]]):t.subarray(e))}end(t,e,i){return typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),i&&this.once("finish",i),this[H]||(this[g]?(t&&(this[Wt]+=t.length,this[g].write(t)),this[g].end()):(this[J]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t||=Buffer.alloc(0)),t&&this.write(t),this[ye]())),this}},Qt=t=>{let e=t.length-1,i=-1;for(;e>-1&&t.charAt(e)==="/";)i=e,e--;return i===-1?t:t.slice(0,i)},Rh=t=>{let e=t.onReadEntry;t.onReadEntry=e?i=>{e(i),i.resume()}:i=>i.resume()},Wi=(t,e)=>{let i=new Map(e.map(h=>[Qt(h),!0])),s=t.filter,r=(h,n="",a=0)=>{if(a>=100)return i.set(h,!1),!1;let o=n||br(h).root||".",l;if(h===o)l=!1;else{let u=i.get(h);l=u===void 0?r(gr(h),o,a+1):u}return i.set(h,l),l};t.filter=s?(h,n)=>s(h,n)&&r(Qt(h)):h=>r(Qt(h))},Bt=ne(t=>{let e=new At(t),i=t.file,s;try{s=d.openSync(i,"r");let r=d.fstatSync(s),h=t.maxReadSize||16*1024*1024;if(r.size<h){let n=Buffer.allocUnsafe(r.size),a=d.readSync(s,n,0,r.size,0);e.end(a===n.byteLength?n:n.subarray(0,a))}else{let n=0,a=Buffer.allocUnsafe(h);for(;n<r.size;){let o=d.readSync(s,a,0,h,n);if(o===0)break;n+=o,e.write(a.subarray(0,o))}e.end()}}finally{if(typeof s=="number")try{d.closeSync(s)}catch{}}},(t,e)=>{let i=new At(t),s=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((h,n)=>{i.on("error",n),i.on("end",h),d.stat(r,(a,o)=>{if(a)n(a);else{let l=new Ui(r,{readSize:s,size:o.size});l.on("error",n),l.pipe(i)}})})},t=>new At(t),t=>new At(t),(t,e)=>{e?.length&&Wi(t,e),t.noResume||Rh(t)}),$s=(t,e,i)=>(t&=4095,i&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:_h,parse:ls}=pr,Gi=t=>{let e="",i=ls(t);for(;_h(t)||i.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":i.root;t=t.slice(s.length),e+=s,i=ls(t)}return[e,t]},Ue=["|","<",">","?",":"],$i=Ue.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Sh=new Map(Ue.map((t,e)=>[t,$i[e]])),Oh=new Map($i.map((t,e)=>[t,Ue[e]])),ds=t=>Ue.reduce((e,i)=>e.split(i).join(Sh.get(i)),t),kh=t=>$i.reduce((e,i)=>e.split(i).join(Oh.get(i)),t),Ys=(t,e)=>e?(t=f(t).replace(/^\.(\/|$)/,""),Qt(e)+"/"+t):f(t),Th=16*1024*1024,us=Symbol("process"),fs=Symbol("file"),cs=Symbol("directory"),wi=Symbol("symlink"),ms=Symbol("hardlink"),Gt=Symbol("header"),ke=Symbol("read"),Ri=Symbol("lstat"),Te=Symbol("onlstat"),_i=Symbol("onread"),Si=Symbol("onreadlink"),Oi=Symbol("openfile"),ki=Symbol("onopenfile"),rt=Symbol("close"),Be=Symbol("mode"),Ti=Symbol("awaitDrain"),oi=Symbol("ondrain"),Z=Symbol("prefix"),Yi=class extends wt{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#t=!1;constructor(t,e={}){let i=ji(e);super(),this.path=f(t),this.portable=!!i.portable,this.maxReadSize=i.maxReadSize||Th,this.linkCache=i.linkCache||new Map,this.statCache=i.statCache||new Map,this.preservePaths=!!i.preservePaths,this.cwd=f(i.cwd||process.cwd()),this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.mtime=i.mtime,this.prefix=i.prefix?f(i.prefix):void 0,this.onWriteEntry=i.onWriteEntry,typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let s=!1;if(!this.preservePaths){let[h,n]=Gi(this.path);h&&typeof n=="string"&&(this.path=n,s=h)}this.win32=!!i.win32||process.platform==="win32",this.win32&&(this.path=kh(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=f(i.absolute||re.resolve(this.cwd,t)),this.path===""&&(this.path="./"),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path});let r=this.statCache.get(this.absolute);r?this[Te](r):this[Ri]()}warn(t,e,i={}){return ze(this,t,e,i)}emit(t,...e){return t==="error"&&(this.#t=!0),super.emit(t,...e)}[Ri](){p.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Te](e)})}[Te](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Lh(t),this.emit("stat",t),this[us]()}[us](){switch(this.type){case"File":return this[fs]();case"Directory":return this[cs]();case"SymbolicLink":return this[wi]();default:return this.end()}}[Be](t){return $s(t,this.type==="Directory",this.portable)}[Z](t){return Ys(t,this.prefix)}[Gt](){if(!this.stat)throw Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new ot({path:this[Z](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Z](this.linkpath):this.linkpath,mode:this[Be](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new he({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Z](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Z](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw Error("failed to encode header");super.write(t)}[cs](){if(!this.stat)throw Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Gt](),this.end()}[wi](){p.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Si](e)})}[Si](t){this.linkpath=f(t),this[Gt](),this.end()}[ms](t){if(!this.stat)throw Error("cannot create link entry without stat");this.type="Link",this.linkpath=f(re.relative(this.cwd,t)),this.stat.size=0,this[Gt](),this.end()}[fs](){if(!this.stat)throw Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[ms](e);this.linkCache.set(t,this.absolute)}if(this[Gt](),this.stat.size===0)return this.end();this[Oi]()}[Oi](){p.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[ki](e)})}[ki](t){if(this.fd=t,this.#t)return this[rt]();if(!this.stat)throw Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[ke]()}[ke](){let{fd:t,buf:e,offset:i,length:s,pos:r}=this;if(t===void 0||e===void 0)throw Error("cannot read file without first opening");p.read(t,e,i,s,r,(h,n)=>{if(h)return this[rt](()=>this.emit("error",h));this[_i](n)})}[rt](t=()=>{}){this.fd!==void 0&&p.close(this.fd,t)}[_i](t){if(t<=0&&this.remain>0){let i=Object.assign(Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rt](()=>this.emit("error",i))}if(t>this.remain){let i=Object.assign(Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[rt](()=>this.emit("error",i))}if(!this.buf)throw Error("should have created buffer prior to reading");if(t===this.remain)for(let i=t;i<this.length&&t<this.blockRemain;i++)this.buf[i+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[oi]():this[Ti](()=>this[oi]())}[Ti](t){this.once("drain",t)}write(t,e,i){if(typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let s=Object.assign(Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,i)}[oi](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[rt](t=>t?this.emit("error",t):this.end());if(!this.buf)throw Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[ke]()}},Vs=class extends Yi{sync=!0;[Ri](){this[Te](p.lstatSync(this.absolute))}[wi](){this[Si](p.readlinkSync(this.absolute))}[Oi](){this[ki](p.openSync(this.absolute,"r"))}[ke](){let t=!0;try{let{fd:e,buf:i,offset:s,length:r,pos:h}=this;if(e===void 0||i===void 0)throw Error("fd and buf must be set in READ method");let n=p.readSync(e,i,s,r,h);this[_i](n),t=!1}finally{if(t)try{this[rt](()=>{})}catch{}}}[Ti](t){t()}[rt](t=()=>{}){this.fd!==void 0&&p.closeSync(this.fd),t()}},Ks=class extends wt{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,i={}){return ze(this,t,e,i)}constructor(t,e={}){let i=ji(e);super(),this.preservePaths=!!i.preservePaths,this.portable=!!i.portable,this.strict=!!i.strict,this.noPax=!!i.noPax,this.noMtime=!!i.noMtime,this.onWriteEntry=i.onWriteEntry,this.readEntry=t;let{type:s}=t;if(s==="Unsupported")throw Error("writing entry that should be ignored");this.type=s,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=i.prefix,this.path=f(t.path),this.mode=t.mode===void 0?void 0:this[Be](t.mode),this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:i.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath===void 0?void 0:f(t.linkpath),typeof i.onwarn=="function"&&this.on("warn",i.onwarn);let r=!1;if(!this.preservePaths){let[n,a]=Gi(this.path);n&&typeof a=="string"&&(this.path=a,r=n)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new ot({path:this[Z](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Z](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),r&&this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute path`,{entry:this,path:r+this.path}),this.header.encode()&&!this.noPax&&super.write(new he({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Z](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Z](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let h=this.header?.block;if(!h)throw Error("failed to encode header");super.write(h),t.pipe(this)}[Z](t){return Ys(t,this.prefix)}[Be](t){return $s(t,this.type==="Directory",this.portable)}write(t,e,i){typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let s=t.length;if(s>this.blockRemain)throw Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(t,i)}end(t,e,i){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(i=t,e=void 0,t=void 0),typeof e=="function"&&(i=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),i&&this.once("finish",i),t?super.end(t,i):super.end(i),this}},Lh=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",xh=class Dt{tail;head;length=0;static create(e=[]){return new Dt(e)}constructor(e=[]){for(let i of e)this.push(i)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw Error("removing node which does not belong to this list");let i=e.next,s=e.prev;return i&&(i.prev=s),s&&(s.next=i),e===this.head&&(this.head=i),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,i}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let i=this.head;e.list=this,e.next=i,i&&(i.prev=e),this.head=e,this.tail||=e,this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let i=this.tail;e.list=this,e.prev=i,i&&(i.next=e),this.tail=e,this.head||=e,this.length++}push(...e){for(let i=0,s=e.length;i<s;i++)Ah(this,e[i]);return this.length}unshift(...e){for(var i=0,s=e.length;i<s;i++)Nh(this,e[i]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,i=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,i.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,i=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,i.list=void 0,this.length--,e}forEach(e,i){i||=this;for(let s=this.head,r=0;s;r++)e.call(i,s.value,r,this),s=s.next}forEachReverse(e,i){i||=this;for(let s=this.tail,r=this.length-1;s;r--)e.call(i,s.value,r,this),s=s.prev}get(e){let i=0,s=this.head;for(;s&&i<e;i++)s=s.next;if(i===e&&s)return s.value}getReverse(e){let i=0,s=this.tail;for(;s&&i<e;i++)s=s.prev;if(i===e&&s)return s.value}map(e,i){i||=this;let s=new Dt;for(let r=this.head;r;)s.push(e.call(i,r.value,this)),r=r.next;return s}mapReverse(e,i){i||=this;var s=new Dt;for(let r=this.tail;r;)s.push(e.call(i,r.value,this)),r=r.prev;return s}reduce(e,i){let s,r=this.head;if(arguments.length>1)s=i;else if(this.head)r=this.head.next,s=this.head.value;else throw TypeError("Reduce of empty list with no initial value");for(var h=0;r;h++)s=e(s,r.value,h),r=r.next;return s}reduceReverse(e,i){let s,r=this.tail;if(arguments.length>1)s=i;else if(this.tail)r=this.tail.prev,s=this.tail.value;else throw TypeError("Reduce of empty list with no initial value");for(let h=this.length-1;r;h--)s=e(s,r.value,h),r=r.prev;return s}toArray(){let e=Array(this.length);for(let i=0,s=this.head;s;i++)e[i]=s.value,s=s.next;return e}toArrayReverse(){let e=Array(this.length);for(let i=0,s=this.tail;s;i++)e[i]=s.value,s=s.prev;return e}slice(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let s=new Dt;if(i<e||i<0)return s;e<0&&(e=0),i>this.length&&(i=this.length);let r=this.head,h=0;for(h=0;r&&h<e;h++)r=r.next;for(;r&&h<i;h++,r=r.next)s.push(r.value);return s}sliceReverse(e=0,i=this.length){i<0&&(i+=this.length),e<0&&(e+=this.length);let s=new Dt;if(i<e||i<0)return s;e<0&&(e=0),i>this.length&&(i=this.length);let r=this.length,h=this.tail;for(;h&&r>i;r--)h=h.prev;for(;h&&r>e;r--,h=h.prev)s.push(h.value);return s}splice(e,i=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let r=this.head;for(let n=0;r&&n<e;n++)r=r.next;let h=[];for(let n=0;r&&n<i;n++)h.push(r.value),r=this.removeNode(r);r?r!==this.tail&&(r=r.prev):r=this.tail;for(let n of s)r=Dh(this,r,n);return h}reverse(){let e=this.head,i=this.tail;for(let s=e;s;s=s.prev){let r=s.prev;s.prev=s.next,s.next=r}return this.head=i,this.tail=e,this}};function Dh(t,e,i){let s=new Vi(i,e,e?e.next:t.head,t);return s.next===void 0&&(t.tail=s),s.prev===void 0&&(t.head=s),t.length++,s}function Ah(t,e){t.tail=new Vi(e,t.tail,void 0,t),t.head||=t.tail,t.length++}function Nh(t,e){t.head=new Vi(e,void 0,t.head,t),t.tail||=t.head,t.length++}var Vi=class{list;next;prev;value;constructor(t,e,i,s){this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,i?(i.prev=this,this.next=i):this.next=void 0}},Li=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},ps=Buffer.alloc(1024),Le=Symbol("onStat"),$t=Symbol("ended"),F=Symbol("queue"),Yt=Symbol("pendingLinks"),tt=Symbol("current"),vt=Symbol("process"),Vt=Symbol("processing"),we=Symbol("processJob"),M=Symbol("jobs"),li=Symbol("jobDone"),xe=Symbol("addFSEntry"),vs=Symbol("addTarEntry"),xi=Symbol("stat"),Di=Symbol("readdir"),De=Symbol("onreaddir"),Ae=Symbol("pipe"),ys=Symbol("entry"),di=Symbol("entryOpt"),Ne=Symbol("writeEntryClass"),Xs=Symbol("write"),ui=Symbol("ondrain"),ae=class extends wt{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Ne];onWriteEntry;[F];[Yt]=new Map;[M]=0;[Vt]=!1;[$t]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=f(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Ne]=Yi,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if(+!!t.gzip+ +!!t.brotli+ +!!t.zstd>1)throw TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new $r(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Vr(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Xr(t.zstd)),!this.zip)throw Error("impossible");let e=this.zip;e.on("data",i=>super.write(i)),e.on("end",()=>super.end()),e.on("drain",()=>this[ui]()),this.on("resume",()=>e.resume())}else this.on("drain",this[ui]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[F]=new xh,this[M]=0,this.jobs=Number(t.jobs)||4,this[Vt]=!1,this[$t]=!1}[Xs](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e=void 0),t&&this.add(t),this[$t]=!0,this[vt](),i&&i(),this}write(t){if(this[$t])throw Error("write after end");return typeof t=="string"?this[xe](t):this[vs](t),this.flowing}[vs](t){let e=f(re.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let i=new Li(t.path,e);i.entry=new Ks(t,this[di](i)),i.entry.on("end",()=>this[li](i)),this[M]+=1,this[F].push(i)}this[vt]()}[xe](t){let e=f(re.resolve(this.cwd,t));this[F].push(new Li(t,e)),this[vt]()}[xi](t){t.pending=!0,this[M]+=1,p[this.follow?"stat":"lstat"](t.absolute,(e,i)=>{t.pending=!1,--this[M],e?this.emit("error",e):this[Le](t,i)})}[Le](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[tt])this[we](t);else{let i=`${e.dev}:${e.ino}`,s=this[Yt].get(i);s?s.push(t):this[Yt].set(i,[t]),t.pendingLink=!0,t.pending=!0}this[vt]()}[Di](t){t.pending=!0,this[M]+=1,p.readdir(t.absolute,(e,i)=>{if(t.pending=!1,--this[M],e)return this.emit("error",e);this[De](t,i)})}[De](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[vt]()}[vt](){if(!this[Vt]){this[Vt]=!0;for(let t=this[F].head;t&&this[M]<this.jobs;t=t.next)if(this[we](t.value),t.value.ignore){let e=t.next;this[F].removeNode(t),t.next=e}this[Vt]=!1,this[$t]&&this[F].length===0&&this[M]===0&&(this.zip?this.zip.end(ps):(super.write(ps),super.end()))}}get[tt](){return this[F]&&this[F].head&&this[F].head.value}[li](t){this[F].shift(),--this[M];let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let i=`${e.dev}:${e.ino}`,s=this[Yt].get(i);if(s){this[Yt].delete(i);for(let r of s)r.pending=!1,this[we](r)}}this[vt]()}[we](t){if(t.pending&&t.pendingLink&&t===this[tt]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[tt]&&!t.piped&&this[Ae](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Le](t,e):this[xi](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[De](t,e):this[Di](t),!t.readdir)return}if(t.entry=this[ys](t),!t.entry){t.ignore=!0;return}t===this[tt]&&!t.piped&&this[Ae](t)}}}[di](t){return{onwarn:(e,i,s)=>this.warn(e,i,s),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[ys](t){this[M]+=1;try{return new this[Ne](t.path,this[di](t)).on("end",()=>this[li](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[ui](){this[tt]&&this[tt].entry&&this[tt].entry.resume()}[Ae](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let r=t.path,h=r==="./"?"":r.replace(/\/*$/,"/");this[xe](h+s)});let e=t.entry,i=this.zip;if(!e)throw Error("cannot pipe without source");i?e.on("data",s=>{i.write(s)||e.pause()}):e.on("data",s=>{super.write(s)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,i={}){ze(this,t,e,i)}},je=class extends ae{sync=!0;constructor(t){super(t),this[Ne]=Vs}pause(){}resume(){}[xi](t){let e=this.follow?"statSync":"lstatSync";this[Le](t,p[e](t.absolute))}[Di](t){this[De](t,p.readdirSync(t.absolute))}[Ae](t){let e=t.entry,i=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let r=t.path,h=r==="./"?"":r.replace(/\/*$/,"/");this[xe](h+s)}),!e)throw Error("Cannot pipe without source");i?e.on("data",s=>{i.write(s)}):e.on("data",s=>{super[Xs](s)})}},Ih=(t,e)=>{let i=new je(t),s=new Ms(t.file,{mode:t.mode||438});i.pipe(s),qs(i,e)},Bh=(t,e)=>{let i=new ae(t),s=new Ce(t.file,{mode:t.mode||438});i.pipe(s);let r=new Promise((h,n)=>{s.on("error",n),s.on("close",h),i.on("error",n)});return Qs(i,e).catch(h=>i.emit("error",h)),r},qs=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?Bt({file:c.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i)}),t.end()},Qs=async(t,e)=>{for(let i of e)i.charAt(0)==="@"?await Bt({file:c.resolve(String(t.cwd),i.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(i);t.end()},bs=ne(Ih,Bh,(t,e)=>{let i=new je(t);return qs(i,e),i},(t,e)=>{let i=new ae(t);return Qs(i,e).catch(s=>i.emit("error",s)),i},(t,e)=>{if(!e?.length)throw TypeError("no paths specified to add to archive")}),Js=(process.env.__FAKE_PLATFORM__||process.platform)==="win32",{O_CREAT:tr,O_NOFOLLOW:gs,O_TRUNC:er,O_WRONLY:ir}=p.constants,sr=Number(process.env.__FAKE_FS_O_FILENAME__)||p.constants.UV_FS_O_FILEMAP||0,Fh=Js&&!!sr,Mh=512*1024,Ch=sr|er|tr|ir,Es=!Js&&typeof gs=="number"?gs|er|tr|ir:null,rr=Es===null?Fh?t=>t<Mh?Ch:"w":()=>"w":()=>Es,Ai=(t,e,i)=>{try{return d.lchownSync(t,e,i)}catch(s){if(s?.code!=="ENOENT")throw s}},Fe=(t,e,i,s)=>{d.lchown(t,e,i,r=>{s(r&&r?.code!=="ENOENT"?r:null)})},Ph=(t,e,i,s,r)=>{e.isDirectory()?hr(c.resolve(t,e.name),i,s,h=>{if(h)return r(h);Fe(c.resolve(t,e.name),i,s,r)}):Fe(c.resolve(t,e.name),i,s,r)},hr=(t,e,i,s)=>{d.readdir(t,{withFileTypes:!0},(r,h)=>{if(r){if(r.code==="ENOENT")return s();if(r.code!=="ENOTDIR"&&r.code!=="ENOTSUP")return s(r)}if(r||!h.length)return Fe(t,e,i,s);let n=h.length,a=null,o=l=>{if(!a){if(l)return s(a=l);if(--n===0)return Fe(t,e,i,s)}};for(let l of h)Ph(t,l,e,i,o)})},zh=(t,e,i,s)=>{e.isDirectory()&&nr(c.resolve(t,e.name),i,s),Ai(c.resolve(t,e.name),i,s)},nr=(t,e,i)=>{let s;try{s=d.readdirSync(t,{withFileTypes:!0})}catch(r){let h=r;if(h?.code==="ENOENT")return;if(h?.code==="ENOTDIR"||h?.code==="ENOTSUP")return Ai(t,e,i);throw h}for(let r of s)zh(t,r,e,i);return Ai(t,e,i)},ar=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},He=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Uh=(t,e)=>{d.stat(t,(i,s)=>{(i||!s.isDirectory())&&(i=new ar(t,i?.code||"ENOTDIR")),e(i)})},jh=(t,e,i)=>{t=f(t);let s=e.umask??18,r=e.mode|448,h=(r&s)!==0,n=e.uid,a=e.gid,o=typeof n=="number"&&typeof a=="number"&&(n!==e.processUid||a!==e.processGid),l=e.preserve,u=e.unlink,y=f(e.cwd),b=(k,w)=>{k?i(k):w&&o?hr(w,n,a,T=>b(T)):h?d.chmod(t,r,i):i()};if(t===y)return Uh(t,b);if(l)return cr.mkdir(t,{mode:r,recursive:!0}).then(k=>b(null,k??void 0),b);Ni(y,f(c.relative(y,t)).split("/"),r,u,y,void 0,b)},Ni=(t,e,i,s,r,h,n)=>{if(e.length===0)return n(null,h);let a=e.shift(),o=f(c.resolve(t+"/"+a));d.mkdir(o,i,or(o,e,i,s,r,h,n))},or=(t,e,i,s,r,h,n)=>a=>{a?d.lstat(t,(o,l)=>{if(o)o.path=o.path&&f(o.path),n(o);else if(l.isDirectory())Ni(t,e,i,s,r,h,n);else if(s)d.unlink(t,u=>{if(u)return n(u);d.mkdir(t,i,or(t,e,i,s,r,h,n))});else{if(l.isSymbolicLink())return n(new He(t,t+"/"+e.join("/")));n(a)}}):(h||=t,Ni(t,e,i,s,r,h,n))},Hh=t=>{let e=!1,i;try{e=d.statSync(t).isDirectory()}catch(s){i=s?.code}finally{if(!e)throw new ar(t,i??"ENOTDIR")}},Zh=(t,e)=>{t=f(t);let i=e.umask??18,s=e.mode|448,r=(s&i)!==0,h=e.uid,n=e.gid,a=typeof h=="number"&&typeof n=="number"&&(h!==e.processUid||n!==e.processGid),o=e.preserve,l=e.unlink,u=f(e.cwd),y=w=>{w&&a&&nr(w,h,n),r&&d.chmodSync(t,s)};if(t===u)return Hh(u),y();if(o)return y(d.mkdirSync(t,{mode:s,recursive:!0})??void 0);let b=f(c.relative(u,t)).split("/"),k;for(let w=b.shift(),T=u;w&&(T+="/"+w);w=b.shift()){T=f(c.resolve(T));try{d.mkdirSync(T,s),k||=T}catch{let Ki=d.lstatSync(T);if(Ki.isDirectory())continue;if(l){d.unlinkSync(T),d.mkdirSync(T,s),k||=T;continue}else if(Ki.isSymbolicLink())return new He(T,T+"/"+b.join("/"))}}return y(k)},fi=Object.create(null),ws=1e4,Ot=new Set,Wh=t=>{Ot.has(t)?Ot.delete(t):fi[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),Ot.add(t);let e=fi[t],i=Ot.size-ws;if(i>ws/10){for(let s of Ot)if(Ot.delete(s),delete fi[s],--i<=0)break}return e},Gh=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",$h=t=>t.split("/").slice(0,-1).reduce((e,i)=>{let s=e.at(-1);return s!==void 0&&(i=Ns(s,i)),e.push(i||"/"),e},[]),Yh=class{#t=new Map;#i=new Map;#s=new Set;reserve(t,e){t=Gh?["win32 parallelization disabled"]:t.map(s=>Qt(Ns(Wh(s))));let i=new Set(t.map(s=>$h(s)).reduce((s,r)=>s.concat(r)));this.#i.set(e,{dirs:i,paths:t});for(let s of t){let r=this.#t.get(s);r?r.push(e):this.#t.set(s,[e])}for(let s of i){let r=this.#t.get(s);if(!r)this.#t.set(s,[new Set([e])]);else{let h=r.at(-1);h instanceof Set?h.add(e):r.push(new Set([e]))}}return this.#r(e)}#h(t){let e=this.#i.get(t);if(!e)throw Error("function does not have any path reservations");return{paths:e.paths.map(i=>this.#t.get(i)),dirs:[...e.dirs].map(i=>this.#t.get(i))}}check(t){let{paths:e,dirs:i}=this.#h(t);return e.every(s=>s&&s[0]===t)&&i.every(s=>s&&s[0]instanceof Set&&s[0].has(t))}#r(t){return this.#s.has(t)||!this.check(t)?!1:(this.#s.add(t),t(()=>this.#e(t)),!0)}#e(t){if(!this.#s.has(t))return!1;let e=this.#i.get(t);if(!e)throw Error("invalid reservation");let{paths:i,dirs:s}=e,r=new Set;for(let h of i){let n=this.#t.get(h);if(!n||n?.[0]!==t)continue;let a=n[1];if(!a){this.#t.delete(h);continue}if(n.shift(),typeof a=="function")r.add(a);else for(let o of a)r.add(o)}for(let h of s){let n=this.#t.get(h),a=n?.[0];if(!(!n||!(a instanceof Set)))if(a.size===1&&n.length===1){this.#t.delete(h);continue}else if(a.size===1){n.shift();let o=n[0];typeof o=="function"&&r.add(o)}else a.delete(t)}return this.#s.delete(t),r.forEach(h=>this.#r(h)),!0}},Vh=()=>process.umask(),Rs=Symbol("onEntry"),Ii=Symbol("checkFs"),_s=Symbol("checkFs2"),Bi=Symbol("isReusable"),I=Symbol("makeFs"),Fi=Symbol("file"),Mi=Symbol("directory"),Ie=Symbol("link"),Ss=Symbol("symlink"),Os=Symbol("hardlink"),Xt=Symbol("ensureNoSymlink"),ks=Symbol("unsupported"),Ts=Symbol("checkPath"),ci=Symbol("stripAbsolutePath"),ht=Symbol("mkdir"),O=Symbol("onError"),Re=Symbol("pending"),Ls=Symbol("pend"),kt=Symbol("unpend"),mi=Symbol("ended"),pi=Symbol("maybeClose"),Ci=Symbol("skip"),Jt=Symbol("doChown"),te=Symbol("uid"),ee=Symbol("gid"),ie=Symbol("checkedCwd"),se=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)==="win32",Kh=1024,Xh=(t,e)=>{if(!se)return d.unlink(t,e);let i=t+".DELETE."+Bs(16).toString("hex");d.rename(t,i,s=>{if(s)return e(s);d.unlink(i,e)})},qh=t=>{if(!se)return d.unlinkSync(t);let e=t+".DELETE."+Bs(16).toString("hex");d.renameSync(t,e),d.unlinkSync(e)},xs=(t,e,i)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:i,Me=class extends At{[mi]=!1;[ie]=!1;[Re]=0;reservations=new Yh;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[mi]=!0,this[pi]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?process.getuid?.()===0:!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Kh,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||se,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=f(c.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Vh():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Rs](e))}warn(t,e,i={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(i.recoverable=!1),super.warn(t,e,i)}[pi](){this[mi]&&this[Re]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[ci](t,e){let i=t[e],{type:s}=t;if(!i||this.preservePaths)return!0;let[r,h]=Gi(i),n=h.replaceAll(/\\/g,"/").split("/");if(n.includes("..")||se&&/^[a-z]:\.\.$/i.test(n[0]??"")){if(e==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:i}),!1;let a=c.posix.dirname(t.path),o=c.posix.normalize(c.posix.join(a,n.join("/")));if(o.startsWith("../")||o==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:i}),!1}return r&&(t[e]=String(h),this.warn("TAR_ENTRY_INFO",`stripping ${r} from absolute ${e}`,{entry:t,[e]:i})),!0}[Ts](t){let e=f(t.path),i=e.split("/");if(this.strip){if(i.length<this.strip)return!1;if(t.type==="Link"){let s=f(String(t.linkpath)).split("/");if(s.length>=this.strip)t.linkpath=s.slice(this.strip).join("/");else return!1}i.splice(0,this.strip),t.path=i.join("/")}if(isFinite(this.maxDepth)&&i.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:i.length,maxDepth:this.maxDepth}),!1;if(!this[ci](t,"path")||!this[ci](t,"linkpath"))return!1;if(t.absolute=c.isAbsolute(t.path)?f(c.resolve(t.path)):f(c.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:f(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=c.win32.parse(String(t.absolute));t.absolute=s+ds(String(t.absolute).slice(s.length));let{root:r}=c.win32.parse(t.path);t.path=r+ds(t.path.slice(r.length))}return!0}[Rs](t){if(!this[Ts](t))return t.resume();switch(wr.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode|=448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ii](t);default:return this[ks](t)}}[O](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[kt](),e.resume())}[ht](t,e,i){jh(f(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},i)}[Jt](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[te](t){return xs(this.uid,t.uid,this.processUid)}[ee](t){return xs(this.gid,t.gid,this.processGid)}[Fi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new Ce(String(t.absolute),{flags:rr(t.size),mode:i,autoClose:!1});s.on("error",a=>{s.fd&&d.close(s.fd,()=>{}),s.write=()=>!0,this[O](a,t),e()});let r=1,h=a=>{if(a){s.fd&&d.close(s.fd,()=>{}),this[O](a,t),e();return}--r===0&&s.fd!==void 0&&d.close(s.fd,o=>{o?this[O](o,t):this[kt](),e()})};s.on("finish",()=>{let a=String(t.absolute),o=s.fd;if(typeof o=="number"&&t.mtime&&!this.noMtime){r++;let l=t.atime||new Date,u=t.mtime;d.futimes(o,l,u,y=>y?d.utimes(a,l,u,b=>h(b&&y)):h())}if(typeof o=="number"&&this[Jt](t)){r++;let l=this[te](t),u=this[ee](t);typeof l=="number"&&typeof u=="number"&&d.fchown(o,l,u,y=>y?d.chown(a,l,u,b=>h(b&&y)):h())}h()});let n=this.transform&&this.transform(t)||t;n!==t&&(n.on("error",a=>{this[O](a,t),e()}),t.pipe(n)),n.pipe(s)}[Mi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.dmode;this[ht](String(t.absolute),i,s=>{if(s){this[O](s,t),e();return}let r=1,h=()=>{--r===0&&(e(),this[kt](),t.resume())};t.mtime&&!this.noMtime&&(r++,d.utimes(String(t.absolute),t.atime||new Date,t.mtime,h)),this[Jt](t)&&(r++,d.chown(String(t.absolute),Number(this[te](t)),Number(this[ee](t)),h)),h()})}[ks](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Ss](t,e){let i=f(c.relative(this.cwd,c.resolve(c.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Xt](t,this.cwd,i,()=>this[Ie](t,String(t.linkpath),"symlink",e),s=>{this[O](s,t),e()})}[Os](t,e){let i=f(c.resolve(this.cwd,String(t.linkpath))),s=f(String(t.linkpath)).split("/");this[Xt](t,this.cwd,s,()=>this[Ie](t,i,"link",e),r=>{this[O](r,t),e()})}[Xt](t,e,i,s,r){let h=i.shift();if(this.preservePaths||h===void 0)return s();let n=c.resolve(e,h);d.lstat(n,(a,o)=>{if(a)return s();if(o?.isSymbolicLink())return r(new He(n,c.resolve(n,i.join("/"))));this[Xt](t,n,i,s,r)})}[Ls](){this[Re]++}[kt](){this[Re]--,this[pi]()}[Ci](t){this[kt](),t.resume()}[Bi](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!se}[Ii](t){this[Ls]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,i=>this[_s](t,i))}[_s](t,e){let i=n=>{e(n)},s=()=>{this[ht](this.cwd,this.dmode,n=>{if(n){this[O](n,t),i();return}this[ie]=!0,r()})},r=()=>{if(t.absolute!==this.cwd){let n=f(c.dirname(String(t.absolute)));if(n!==this.cwd)return this[ht](n,this.dmode,a=>{if(a){this[O](a,t),i();return}h()})}h()},h=()=>{d.lstat(String(t.absolute),(n,a)=>{if(a&&(this.keep||this.newer&&a.mtime>(t.mtime??a.mtime))){this[Ci](t),i();return}if(n||this[Bi](t,a))return this[I](null,t,i);if(a.isDirectory()){if(t.type==="Directory"){let o=this.chmod&&t.mode&&(a.mode&4095)!==t.mode,l=u=>this[I](u??null,t,i);return o?d.chmod(String(t.absolute),Number(t.mode),l):l()}if(t.absolute!==this.cwd)return d.rmdir(String(t.absolute),o=>this[I](o??null,t,i))}if(t.absolute===this.cwd)return this[I](null,t,i);Xh(String(t.absolute),o=>this[I](o??null,t,i))})};this[ie]?r():s()}[I](t,e,i){if(t){this[O](t,e),i();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Fi](e,i);case"Link":return this[Os](e,i);case"SymbolicLink":return this[Ss](e,i);case"Directory":case"GNUDumpDir":return this[Mi](e,i)}}[Ie](t,e,i,s){d[i](e,String(t.absolute),r=>{r?this[O](r,t):(this[kt](),t.resume()),s()})}},Kt=t=>{try{return[null,t()]}catch(e){return[e,null]}},Pi=class extends Me{sync=!0;[I](t,e){return super[I](t,e,()=>{})}[Ii](t){if(!this[ie]){let r=this[ht](this.cwd,this.dmode);if(r)return this[O](r,t);this[ie]=!0}if(t.absolute!==this.cwd){let r=f(c.dirname(String(t.absolute)));if(r!==this.cwd){let h=this[ht](r,this.dmode);if(h)return this[O](h,t)}}let[e,i]=Kt(()=>d.lstatSync(String(t.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(t.mtime??i.mtime)))return this[Ci](t);if(e||this[Bi](t,i))return this[I](null,t);if(i.isDirectory()){if(t.type==="Directory"){let[h]=this.chmod&&t.mode&&(i.mode&4095)!==t.mode?Kt(()=>{d.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[I](h,t)}let[r]=Kt(()=>d.rmdirSync(String(t.absolute)));this[I](r,t)}let[s]=t.absolute===this.cwd?[]:Kt(()=>qh(String(t.absolute)));this[I](s,t)}[Fi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.fmode,s=n=>{let a;try{d.closeSync(r)}catch(o){a=o}(n||a)&&this[O](n||a,t),e()},r;try{r=d.openSync(String(t.absolute),rr(t.size),i)}catch(n){return s(n)}let h=this.transform&&this.transform(t)||t;h!==t&&(h.on("error",n=>this[O](n,t)),t.pipe(h)),h.on("data",n=>{try{d.writeSync(r,n,0,n.length)}catch(a){s(a)}}),h.on("end",()=>{let n=null;if(t.mtime&&!this.noMtime){let a=t.atime||new Date,o=t.mtime;try{d.futimesSync(r,a,o)}catch(l){try{d.utimesSync(String(t.absolute),a,o)}catch{n=l}}}if(this[Jt](t)){let a=this[te](t),o=this[ee](t);try{d.fchownSync(r,Number(a),Number(o))}catch(l){try{d.chownSync(String(t.absolute),Number(a),Number(o))}catch{n||=l}}}s(n)})}[Mi](t,e){let i=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[ht](String(t.absolute),i);if(s){this[O](s,t),e();return}if(t.mtime&&!this.noMtime)try{d.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Jt](t))try{d.chownSync(String(t.absolute),Number(this[te](t)),Number(this[ee](t)))}catch{}e(),t.resume()}[ht](t,e){try{return Zh(f(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(i){return i}}[Xt](t,e,i,s,r){if(this.preservePaths||i.length===0)return s();let h=e;for(let n of i){h=c.resolve(h,n);let[a,o]=Kt(()=>d.lstatSync(h));if(a)return s();if(o.isSymbolicLink())return r(new He(h,c.resolve(e,i.join("/"))))}s()}[Ie](t,e,i,s){let r=`${i}Sync`;try{d[r](e,String(t.absolute)),s(),t.resume()}catch(h){return this[O](h,t)}}},Ds=ne(t=>{let e=new Pi(t),i=t.file,s=d.statSync(i);new Fr(i,{readSize:t.maxReadSize||16*1024*1024,size:s.size}).pipe(e)},(t,e)=>{let i=new Me(t),s=t.maxReadSize||16*1024*1024,r=t.file;return new Promise((h,n)=>{i.on("error",n),i.on("close",h),d.stat(r,(a,o)=>{if(a)n(a);else{let l=new Ui(r,{readSize:s,size:o.size});l.on("error",n),l.pipe(i)}})})},t=>new Pi(t),t=>new Me(t),(t,e)=>{e?.length&&Wi(t,e)}),Qh=(t,e)=>{let i=new je(t),s=!0,r,h;try{try{r=d.openSync(t.file,"r+")}catch(o){if(o?.code==="ENOENT")r=d.openSync(t.file,"w+");else throw o}let n=d.fstatSync(r),a=Buffer.alloc(512);t:for(h=0;h<n.size;h+=512){for(let u=0,y=0;u<512;u+=y){if(y=d.readSync(r,a,u,a.length-u,h+u),h===0&&a[0]===31&&a[1]===139)throw Error("cannot append to compressed archives");if(!y)break t}let o=new ot(a);if(!o.cksumValid)break;let l=512*Math.ceil((o.size||0)/512);if(h+l+512>n.size)break;h+=l,t.mtimeCache&&o.mtime&&t.mtimeCache.set(String(o.path),o.mtime)}s=!1,Jh(t,i,h,r,e)}finally{if(s)try{d.closeSync(r)}catch{}}},Jh=(t,e,i,s,r)=>{let h=new Ms(t.file,{fd:s,start:i});e.pipe(h),en(e,r)},tn=(t,e)=>{e=Array.from(e);let i=new ae(t),s=(r,h,n)=>{let a=(b,k)=>{b?d.close(r,w=>n(b)):n(null,k)},o=0;if(h===0)return a(null,0);let l=0,u=Buffer.alloc(512),y=(b,k)=>{if(b||k===void 0)return a(b);if(l+=k,l<512&&k)return d.read(r,u,l,u.length-l,o+l,y);if(o===0&&u[0]===31&&u[1]===139)return a(Error("cannot append to compressed archives"));if(l<512)return a(null,o);let w=new ot(u);if(!w.cksumValid)return a(null,o);let T=512*Math.ceil((w.size??0)/512);if(o+T+512>h||(o+=T+512,o>=h))return a(null,o);t.mtimeCache&&w.mtime&&t.mtimeCache.set(String(w.path),w.mtime),l=0,d.read(r,u,0,512,o,y)};d.read(r,u,0,512,o,y)};return new Promise((r,h)=>{i.on("error",h);let n="r+",a=(o,l)=>{if(o&&o.code==="ENOENT"&&n==="r+")return n="w+",d.open(t.file,n,a);if(o||!l)return h(o);d.fstat(l,(u,y)=>{if(u)return d.close(l,()=>h(u));s(l,y.size,(b,k)=>{if(b)return h(b);let w=new Ce(t.file,{fd:l,start:k});i.pipe(w),w.on("error",h),w.on("close",r),sn(i,e)})})};d.open(t.file,n,a)})},en=(t,e)=>{e.forEach(i=>{i.charAt(0)==="@"?Bt({file:c.resolve(t.cwd,i.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i)}),t.end()},sn=async(t,e)=>{for(let i of e)i.charAt(0)==="@"?await Bt({file:c.resolve(String(t.cwd),i.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(i);t.end()},yt=ne(Qh,tn,()=>{throw TypeError("file is required")},()=>{throw TypeError("file is required")},(t,e)=>{if(!jr(t))throw TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw TypeError("cannot append to compressed archives");if(!e?.length)throw TypeError("no paths specified to add/replace")});ne(yt.syncFile,yt.asyncFile,yt.syncNoFile,yt.asyncNoFile,(t,e=[])=>{yt.validate?.(t,e),rn(t)});var rn=t=>{let e=t.filter;t.mtimeCache||=new Map,t.filter=e?(i,s)=>e(i,s)&&!((t.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0)):(i,s)=>!((t.mtimeCache?.get(i)??s.mtime??0)>(s.mtime??0))};export{an as index_min_exports};
@@ -1,2 +1,2 @@
1
- import{createRequire as g}from"node:module";import{e as p}from"../packem_shared/index-BzhrR_iC.js";import{p as e}from"./cli-main.js";import{d as _}from"../packem_shared/pm-runner-CMSml1Bj.js";import{y as u}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as m}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{U as $}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let y;const w=r=>(y??=g(import.meta.url))(r),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=r=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[n,s]=c.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return c.getBuiltinModule(r)}return w(r)},{spawnSync:h}=v("node:child_process"),t="@lavamoat/preinstall-always-fail",d=r=>{const n=p(r,"package.json");if(!u(n))return"no-package-json";try{const s=m(n);if(s.devDependencies?.[t]||s.dependencies?.[t])return"installed"}catch{}return"missing"},k=r=>{const n=p(r,"package.json");if(!u(n))return!1;try{const s=m(n);let i=!1;const l=a=>!a||!(t in a)?a:(i=!0,Object.fromEntries(Object.entries(a).filter(([o])=>o!==t)));return s.devDependencies=l(s.devDependencies),s.dependencies=l(s.dependencies),i&&$(n,`${JSON.stringify(s,null,2)}
1
+ import{createRequire as g}from"node:module";import{e as p}from"../packem_shared/index-BzhrR_iC.js";import{p as e}from"./cli-main.js";import{d as _}from"../packem_shared/pm-runner-3iiQayy-.js";import{y as u}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as m}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{U as $}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let y;const w=r=>(y??=g(import.meta.url))(r),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=r=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[n,s]=c.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return c.getBuiltinModule(r)}return w(r)},{spawnSync:h}=v("node:child_process"),t="@lavamoat/preinstall-always-fail",d=r=>{const n=p(r,"package.json");if(!u(n))return"no-package-json";try{const s=m(n);if(s.devDependencies?.[t]||s.dependencies?.[t])return"installed"}catch{}return"missing"},k=r=>{const n=p(r,"package.json");if(!u(n))return!1;try{const s=m(n);let i=!1;const l=a=>!a||!(t in a)?a:(i=!0,Object.fromEntries(Object.entries(a).filter(([o])=>o!==t)));return s.devDependencies=l(s.devDependencies),s.dependencies=l(s.dependencies),i&&$(n,`${JSON.stringify(s,null,2)}
2
2
  `),i}catch{return!1}},I=({options:r,workspaceRoot:n})=>{const s=n??process.cwd();if(r.status){switch(d(s)){case"installed":{e.success(`Preinstall tripwire is installed (${t}).`),e.info("Removing 'ignore-scripts=true' will cause future installs to fail loudly.");break}case"missing":{e.warn("Preinstall tripwire is not installed."),e.info(`Run 'vis security tripwire' to add ${t} as a devDependency.`);break}default:e.error("No package.json found at the workspace root."),process.exitCode=1}return}if(r.remove){k(s)?e.success(`Removed ${t} from package.json. Run your PM's install to clean node_modules.`):e.info(`${t} was not present in package.json.`);return}if(d(s)==="installed"){e.info(`${t} is already installed.`);return}const i=_(s),a={bun:["add","-d",t],npm:["install","--save-dev",t],pnpm:["add","-D","-w",t],yarn:["add","-D",t]}[i.name];if(!a){e.error(`Cannot install tripwire — unsupported package manager '${i.name}'.`),process.exitCode=1;return}e.info(`Installing ${t} via ${i.name}…`);const o=h(i.name,a,{cwd:s,stdio:"inherit"});if(o.error){e.error(`Failed to install tripwire: ${o.error.message}`),process.exitCode=1;return}if(o.signal!==null){e.error(`${i.name} was terminated by signal ${o.signal}`),process.exitCode=1;return}if(o.status!==0){e.error(`${i.name} exited with code ${String(o.status)}`),process.exitCode=o.status??1;return}e.success(`Installed ${t} as a devDependency.`),e.notice(""),e.notice("How the tripwire works:"),e.notice(` ${t} declares a preinstall script that always fails.`),e.notice(" When 'ignore-scripts=true' is set (.npmrc / bunfig.toml / .yarnrc.yml),"),e.notice(" the script is skipped and installs succeed normally. If someone deletes"),e.notice(" that setting, the next install fails — loudly — instead of silently"),e.notice(" running every dependency's lifecycle scripts.")};export{I as default};
@@ -2,4 +2,4 @@ import{createRequire as ze}from"node:module";import{z as D,f as Ke,c as Ce,r as
2
2
  `;break;case 114:l+="\r";break;case 116:l+=" ";break;case 117:const p=v(4);p>=0?l+=String.fromCharCode(p):m=4;break;default:m=5}O=t;continue}if(k>=0&&k<=31)if(x(k)){l+=e.substring(O,t),m=2;break}else m=6;t++}return l}function N(){if(o="",m=0,r=t,c=f,a=u,t>=i)return r=i,s=17;let l=e.charCodeAt(t);if(ee(l)){do t++,o+=String.fromCharCode(l),l=e.charCodeAt(t);while(ee(l));return s=15}if(x(l))return t++,o+=String.fromCharCode(l),l===13&&e.charCodeAt(t)===10&&(t++,o+=`
3
3
  `),f++,u=t,s=14;switch(l){case 123:return t++,s=1;case 125:return t++,s=2;case 91:return t++,s=3;case 93:return t++,s=4;case 58:return t++,s=6;case 44:return t++,s=5;case 34:return t++,o=A(),s=10;case 47:const O=t-1;if(e.charCodeAt(t+1)===47){for(t+=2;t<i&&!x(e.charCodeAt(t));)t++;return o=e.substring(O,t),s=12}if(e.charCodeAt(t+1)===42){t+=2;const k=i-1;let g=!1;for(;t<k;){const p=e.charCodeAt(t);if(p===42&&e.charCodeAt(t+1)===47){t+=2,g=!0;break}t++,x(p)&&(p===13&&e.charCodeAt(t)===10&&t++,f++,u=t)}return g||(t++,m=1),o=e.substring(O,t),s=13}return o+=String.fromCharCode(l),t++,s=16;case 45:if(o+=String.fromCharCode(l),t++,t===i||!R(e.charCodeAt(t)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return o+=y(),s=11;default:for(;t<i&&_(l);)t++,l=e.charCodeAt(t);if(r!==t){switch(o=e.substring(r,t),o){case"true":return s=8;case"false":return s=9;case"null":return s=7}return s=16}return o+=String.fromCharCode(l),t++,s=16}}function _(l){if(ee(l)||x(l))return!1;switch(l){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function d(){let l;do l=N();while(l>=12&&l<=15);return l}return{setPosition:b,getPosition:()=>t,scan:n?d:N,getToken:()=>s,getTokenValue:()=>o,getTokenOffset:()=>r,getTokenLength:()=>t-r,getTokenStartLine:()=>c,getTokenStartCharacter:()=>r-a,getTokenError:()=>m}}function ee(e){return e===32||e===9}function x(e){return e===10||e===13}function R(e){return e>=48&&e<=57}var Oe;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(Oe||(Oe={}));var Z;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Z||(Z={}));function ct(e,n=[],i=Z.DEFAULT){let t=null,o=[];const r=[];function s(c){Array.isArray(o)?o.push(c):t!==null&&(o[t]=c)}return ut(e,{onObjectBegin:()=>{const c={};s(c),r.push(o),o=c,t=null},onObjectProperty:c=>{t=c},onObjectEnd:()=>{o=r.pop()},onArrayBegin:()=>{const c=[];s(c),r.push(o),o=c,t=null},onArrayEnd:()=>{o=r.pop()},onLiteralValue:s,onError:(c,u,a)=>{n.push({error:c,offset:u,length:a})}},i),o[0]}function ut(e,n,i=Z.DEFAULT){const t=lt(e,!1),o=[];let r=0;function s(w){return w?()=>r===0&&w(t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter()):()=>!0}function f(w){return w?T=>r===0&&w(T,t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter()):()=>!0}function c(w){return w?T=>r===0&&w(T,t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter(),()=>o.slice()):()=>!0}function u(w){return w?()=>{r>0?r++:w(t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter(),()=>o.slice())===!1&&(r=1)}:()=>!0}function a(w){return w?()=>{r>0&&r--,r===0&&w(t.getTokenOffset(),t.getTokenLength(),t.getTokenStartLine(),t.getTokenStartCharacter())}:()=>!0}const m=u(n.onObjectBegin),v=c(n.onObjectProperty),b=a(n.onObjectEnd),y=u(n.onArrayBegin),A=a(n.onArrayEnd),N=c(n.onLiteralValue),_=f(n.onSeparator),d=s(n.onComment),l=f(n.onError),O=i&&i.disallowComments,k=i&&i.allowTrailingComma;function g(){for(;;){const w=t.scan();switch(t.getTokenError()){case 4:p(14);break;case 5:p(15);break;case 3:p(13);break;case 1:O||p(11);break;case 2:p(12);break;case 6:p(16);break}switch(w){case 12:case 13:O?p(10):d();break;case 16:p(1);break;case 15:case 14:break;default:return w}}}function p(w,T=[],de=[]){if(l(w),T.length+de.length>0){let q=t.getToken();for(;q!==17;){if(T.indexOf(q)!==-1){g();break}else if(de.indexOf(q)!==-1)break;q=g()}}}function I(w){const T=t.getTokenValue();return w?N(T):(v(T),o.push(T)),g(),!0}function B(){switch(t.getToken()){case 11:const w=t.getTokenValue();let T=Number(w);isNaN(T)&&(p(2),T=0),N(T);break;case 7:N(null);break;case 8:N(!0);break;case 9:N(!1);break;default:return!1}return g(),!0}function J(){return t.getToken()!==10?(p(3,[],[2,5]),!1):(I(!1),t.getToken()===6?(_(":"),g(),C()||p(4,[],[2,5])):p(5,[],[2,5]),o.pop(),!0)}function Ge(){m(),g();let w=!1;for(;t.getToken()!==2&&t.getToken()!==17;){if(t.getToken()===5){if(w||p(4,[],[]),_(","),g(),t.getToken()===2&&k)break}else w&&p(6,[],[]);J()||p(4,[],[2,5]),w=!0}return b(),t.getToken()!==2?p(7,[2],[]):g(),!0}function He(){y(),g();let w=!0,T=!1;for(;t.getToken()!==4&&t.getToken()!==17;){if(t.getToken()===5){if(T||p(4,[],[]),_(","),g(),t.getToken()===4&&k)break}else T&&p(6,[],[]);w?(o.push(0),w=!1):o[o.length-1]++,C()||p(4,[],[4,5]),T=!0}return A(),w||o.pop(),t.getToken()!==4?p(8,[4],[]):g(),!0}function C(){switch(t.getToken()){case 3:return He();case 1:return Ge();case 10:return I(!0);default:return B()}}return g(),t.getToken()===17?i.allowEmptyContent?!0:(p(4,[],[]),!1):C()?(t.getToken()!==17&&p(9,[],[]),!0):(p(4,[],[]),!1)}var be;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(be||(be={}));var ke;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(ke||(ke={}));const K=ct;var we;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(we||(we={}));function pt(e){switch(e){case 1:return"InvalidSymbol";case 2:return"InvalidNumberFormat";case 3:return"PropertyNameExpected";case 4:return"ValueExpected";case 5:return"ColonExpected";case 6:return"CommaExpected";case 7:return"CloseBraceExpected";case 8:return"CloseBracketExpected";case 9:return"EndOfFileExpected";case 10:return"InvalidCommentToken";case 11:return"UnexpectedEndOfComment";case 12:return"UnexpectedEndOfString";case 13:return"UnexpectedEndOfNumber";case 14:return"InvalidUnicode";case 15:return"InvalidEscapeCharacter";case 16:return"InvalidCharacter"}return"<unknown ParseErrorCode>"}const ft=(e,n,i,t)=>{if(e.length===0)return;const o=e[0],r=Ce(n,o.offset),s=new et(`${pt(o.error)} at offset ${o.offset}`);throw s.fileName=i,s.codeFrame=tt(n,{start:r},{tabWidth:!1,...t}),s},at=(e,n)=>{const{allowEmptyContent:i,allowTrailingComma:t=!0,beforeParse:o,buffer:r,color:s,compression:f,disallowComments:c,encoding:u="utf8",flag:a}=n??{},m=D(e,{buffer:r,compression:f,encoding:u,flag:a}),v=typeof o=="function"?o(m):m,b=[],y=K(v,b,{allowEmptyContent:i,allowTrailingComma:t,disallowComments:c});return ft(b,v,nt(e),{color:s}),y},le=e=>Array.isArray(e)?e.map(n=>le(n)):e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null?Object.fromEntries(Object.entries(e).map(([n,i])=>[n,le(i)])):e,mt=(e,n)=>{const i=D(e,{encoding:"utf8",...n});return le(st(i))};function dt(e,n,i){const t={},{buffer:o,compression:r,encoding:s="utf8",flag:f,...c}=t,u=D(e,{buffer:o,compression:r,encoding:s,flag:f});return typeof n=="function"?ge(u,n,c):ge(u,c)}var S={},ye;function gt(){if(ye)return S;ye=1,Object.defineProperty(S,"__esModule",{value:!0});const e=d=>d!==null&&typeof d=="object",n=(d,l)=>Object.assign(new Error(`[${d}]: ${l}`),{code:d}),i="ERR_INVALID_PACKAGE_CONFIG",t="ERR_INVALID_PACKAGE_TARGET",o="ERR_PACKAGE_PATH_NOT_EXPORTED",r="ERR_PACKAGE_IMPORT_NOT_DEFINED",s=/^\d+$/,f=/^(\.{1,2}|node_modules)$/i,c=/\/|\\/;var u=(d=>(d.Export="exports",d.Import="imports",d))(u||{});const a=(d,l,O,k,g)=>{if(l==null)return[];if(typeof l=="string"){const[p,...I]=l.split(c);if(p===".."||I.some(B=>f.test(B)))throw n(t,`Invalid "${d}" target "${l}" defined in the package config`);return[g?l.replace(/\*/g,g):l]}if(Array.isArray(l))return l.flatMap(p=>a(d,p,O,k,g));if(e(l)){for(const p of Object.keys(l)){if(s.test(p))throw n(i,"Cannot contain numeric property keys");if(p==="default"||k.includes(p))return a(d,l[p],O,k,g)}return[]}throw n(t,`Invalid "${d}" target "${l}"`)},m="*",v=(d,l)=>{const O=d.indexOf(m),k=l.indexOf(m);return O===k?l.length>d.length:k>O};function b(d,l){if(!l.includes(m)&&d.hasOwnProperty(l))return[l];let O,k;for(const g of Object.keys(d))if(g.includes(m)){const[p,I,B]=g.split(m);if(B===void 0&&l.startsWith(p)&&l.endsWith(I)){const J=l.slice(p.length,-I.length||void 0);J&&(!O||v(O,g))&&(O=g,k=J)}}return[O,k]}const y=d=>Object.keys(d).reduce((l,O)=>{const k=O===""||O[0]!==".";if(l===void 0||l===k)return k;throw n(i,'"exports" cannot contain some keys starting with "." and some not')},void 0),A=/^\w+:/,N=(d,l,O)=>{if(!d)throw new Error('"exports" is required');l=l===""?".":`./${l}`,(typeof d=="string"||Array.isArray(d)||e(d)&&y(d))&&(d={".":d});const[k,g]=b(d,l),p=a(u.Export,d[k],l,O,g);if(p.length===0)throw n(o,l==="."?'No "exports" main defined':`Package subpath '${l}' is not defined by "exports"`);for(const I of p)if(!I.startsWith("./")&&!A.test(I))throw n(t,`Invalid "exports" target "${I}" defined in the package config`);return p},_=(d,l,O)=>{if(!d)throw new Error('"imports" is required');const[k,g]=b(d,l),p=a(u.Import,d[k],l,O,g);if(p.length===0)throw n(r,`Package import specifier "${l}" is not defined in package`);return p};return S.resolveExports=N,S.resolveImports=_,S}var Ot=gt();let bt;const kt=e=>(bt??=je(import.meta.url))(e),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_e=e=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[n,i]=W.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return W.getBuiltinModule(e)}return kt(e)},{statSync:H}=_e("node:fs"),wt=_e("node:module"),De=(e=process.cwd())=>{const{findPnpApi:n}=wt;return n?n(e):void 0},yt=e=>K(D(e,{buffer:!1})),te=(e,n,i,t)=>{const o=`resolveFromPackageJsonPath:${e}:${n}:${i?"yes":"no"}`;if(t?.has(o))return t.get(o);const r=yt(e);if(!r)return;let s=n||"tsconfig.json";if(!i&&r.exports)try{const[f]=Ot.resolveExports(r.exports,n,["require","types"]);s=f}catch{return!1}else!n&&r.tsconfig&&(s=r.tsconfig);return s=h(e,"..",s),t?.set(o,s),s},ne="package.json",oe="tsconfig.json",vt=(e,n,i)=>{let t=e;if(e===".."&&(t=h(t,oe)),e.startsWith(".")&&(t=j(n,t)),me(t)){if($(t)){if(H(t).isFile())return t}else if(!t.endsWith(".json")){const b=`${t}.json`;if($(b))return b}return}const[o="",...r]=e.split("/"),s=o.startsWith("@")?`${o}/${String(r.shift())}`:o,f=r.join("/"),c=De(n);if(c){const{resolveRequest:b}=c;try{if(s===e){const y=b(h(s,ne),n);if(y){const A=te(y,f,!1,i);if(A&&$(A))return A}}else{let y;try{y=b(e,n,{extensions:[".json"]})}catch{y=b(h(e,oe),n)}if(y)return y}}catch{}}const u=X(b=>{const y=h(j(b),"node_modules",s);if($(y))return h("node_modules",s)},{cwd:n,type:"directory"});if(!u||!H(u).isDirectory())return;const a=h(u,ne);if($(a)){const b=te(a,f,!1,i);if(b===!1)return;if(b&&$(b)&&H(b).isFile())return b}const m=h(u,f),v=m.endsWith(".json");if(!v){const b=`${m}.json`;if($(b))return b}if($(m)){if(H(m).isDirectory()){const b=h(m,ne);if($(b)){const A=te(b,"",!0,i);if(A&&$(A))return A}const y=h(m,oe);if($(y))return y}else if(v)return m}},Re=e=>{const n=j(e);let i;const t=De(n);if(t)try{i=t.resolveRequest("typescript/package.json",n)??void 0}catch{}if(i??=X(o=>h(o,"node_modules","typescript","package.json"),{cwd:n,type:"file"}),!!i)try{const o=K(D(i,{buffer:!1}));if(typeof o?.version=="string")return o.version}catch{}},Fe=new Set(["node16","node18","node20","nodenext"]),Be=e=>e!==void 0&&Fe.has(e),Tt=e=>{switch(e){case"node20":return"es2023";case"nodenext":return"esnext";default:return"es2022"}},ht=e=>e==="nodenext"?"nodenext":"node16",At=e=>{if(e==="nodenext")return"nodenext";if(e==="node16")return"node16"},Ue=(e,n,i)=>{const t=n.has("module")?e.module:void 0,o=n.has("moduleResolution")?e.moduleResolution:void 0;let r;t!==void 0&&Fe.has(t)?r=t:o!==void 0&&(r=At(o)),i.target!==void 0&&!n.has("target")&&(e.target=r?Tt(r):i.target),n.has("module")||(e.module=r??i.module),n.has("moduleResolution")||(e.moduleResolution=r?ht(r):"bundler")},Et=(e,n)=>{!n.has("target")&&!Be(e.module)&&(e.target="es3")},It=(e,n)=>{!n.has("target")&&!Be(e.module)&&(e.target="es5")},$t=(e,n)=>{n.has("strict")||(e.strict=!0),Ue(e,n,{module:"es2022",target:"es2025"}),n.has("rootDir")||(e.rootDir="."),n.has("types")||(e.types=[]),n.has("noUncheckedSideEffectImports")||(e.noUncheckedSideEffectImports=!0),n.has("libReplacement")||(e.libReplacement=!1),n.has("alwaysStrict")||(e.alwaysStrict=!0)},jt=(e,n)=>{Ue(e,n,{module:"esnext"}),n.has("stableTypeOrdering")||(e.stableTypeOrdering=!0)},Nt=[[4,Et],[5,It],[6,$t],[7,jt]],Lt=/^v?(\d+)/,_t=e=>{const n=Lt.exec(e);return n?Number(n[1]):void 0},Dt=(e,n)=>{const i=_t(n);if(i===void 0)return;const t=new Set(Object.keys(e));for(const[o,r]of Nt)o<=i&&r(e,t)},Rt=e=>K(D(e,{buffer:!1})),Ft=e=>e.replaceAll("\\","/"),M=e=>{const n=ot(e);return it(n)?n:`./${n}`},ce=["files","include","exclude"],ve=(e,n,i)=>{const t=h(n,i),o=P(e,t);return Y(o)||"./"},Bt=(e,n,i)=>{const t=P(e,n);if(!t)return i;const o=i.startsWith("./")?i.slice(2):i;return`${t}/${o}`},Ut=(e,n,i,t,o)=>{if(i.has(e))throw new Error(`Circularity detected while resolving configuration: ${e}`);i.add(e);const r=L(e),s=xe(e,t,i,o);delete s.references;const{compilerOptions:f}=s;if(f){const{baseUrl:c}=f;c&&!c.startsWith(E)&&(f.baseUrl=ve(n,r,c));const{outDir:u}=f;u&&!u.startsWith(E)&&(f.outDir=ve(n,r,u))}for(const c of ce){const u=s[c];u&&(s[c]=u.map(a=>a.startsWith(E)||me(a)?a:Bt(n,r,a)))}return s},xe=(e,n,i=new Set,t=new Map)=>{let o;try{o=Rt(e)??{}}catch(s){throw new Error(`Cannot resolve tsconfig at path: ${e}`,{cause:s})}if(typeof o!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const r=L(e);if(o.compilerOptions){const{compilerOptions:s}=o;s.paths&&!s.baseUrl&&(s[Se]=r)}if(o.extends){const s=Array.isArray(o.extends)?o.extends:[o.extends];delete o.extends;const f=s.toReversed();for(let c=0;c<f.length;c++){const u=f[c],a=vt(u,r,t);if(!a)throw new Ne(`No such file or directory, for '${u}' found.`);const m=Ut(a,r,new Set(i),n,t);m.compilerOptions?.rootDir!==void 0&&!m.compilerOptions.rootDir.startsWith(E)&&(m.compilerOptions.rootDir=h(L(a),m.compilerOptions.rootDir));const v={...m,...o,compilerOptions:{...m.compilerOptions,...o.compilerOptions}};m.watchOptions&&(v.watchOptions={...m.watchOptions,...o.watchOptions}),o=v}}if(o.compilerOptions){const{compilerOptions:s}=o;for(const f of["baseUrl","rootDir"]){const c=s[f];if(c&&!c.startsWith(E)){const u=j(r,c);s[f]=M(P(r,u))}}for(const f of["outDir","declarationDir"]){let c=s[f];c&&(Array.isArray(o.exclude)||(o.exclude=["outDir","declarationDir"].map(u=>{const a=s[u];if(a)return a.startsWith(E)||me(a)?a:h(r,a)}).filter(Boolean)),c.startsWith(E)||(c=M(c)),s[f]=c)}}else o.compilerOptions={};if(o.include&&(o.include=o.include.map(s=>Ft(s))),o.files&&(o.files=o.files.map(s=>s.startsWith(E)?s:M(s))),o.watchOptions){const{watchOptions:s}=o;s.excludeDirectories&&(s.excludeDirectories=s.excludeDirectories.map(f=>Y(j(r,f)))),s.excludeFiles&&(s.excludeFiles=s.excludeFiles.map(f=>Y(j(r,f)))),s.watchFile&&(s.watchFile=s.watchFile.toLowerCase()),s.watchDirectory&&(s.watchDirectory=s.watchDirectory.toLowerCase()),s.fallbackPolling&&(s.fallbackPolling=s.fallbackPolling.toLowerCase())}if(o.compilerOptions.lib&&(o.compilerOptions.lib=o.compilerOptions.lib.map(s=>s.toLowerCase())),o.compilerOptions.module){let s=o.compilerOptions.module.toLowerCase();s==="es2015"&&(s="es6"),o.compilerOptions.module=s}if(o.compilerOptions.target){let s=o.compilerOptions.target.toLowerCase();s==="es2015"&&(s="es6"),o.compilerOptions.target=s}if(o.compilerOptions.moduleResolution){let s=o.compilerOptions.moduleResolution.toLowerCase();s==="node"&&(s="node10"),o.compilerOptions.moduleResolution=s}return o.compilerOptions.jsx&&(o.compilerOptions.jsx=o.compilerOptions.jsx.toLowerCase()),o.compilerOptions.moduleDetection&&(o.compilerOptions.moduleDetection=o.compilerOptions.moduleDetection.toLowerCase()),o.compilerOptions.importsNotUsedAsValues&&(o.compilerOptions.importsNotUsedAsValues=o.compilerOptions.importsNotUsedAsValues.toLowerCase()),o.compilerOptions.newLine&&(o.compilerOptions.newLine=o.compilerOptions.newLine.toLowerCase()),o},z=(e,n)=>{if(e.startsWith(E))return Y(h(n,e.slice(E.length)))},xt=["outDir","declarationDir","outFile","rootDir","baseUrl","tsBuildInfoFile"],Te=e=>e==="es2022"||e==="es2023"||e==="es2024"||e==="es2025"||e==="esnext",St=(e,n)=>{if(e.compilerOptions===void 0)return e;if(e.compilerOptions.rewriteRelativeImportExtensions&&(e.compilerOptions.allowImportingTsExtensions??=!0),e.compilerOptions.composite&&(e.compilerOptions.declaration??=!0,e.compilerOptions.incremental??=!0),e.compilerOptions.checkJs&&(e.compilerOptions.allowJs??=!0),e.compilerOptions.verbatimModuleSyntax&&(e.compilerOptions.isolatedModules??=!0,e.compilerOptions.preserveConstEnums??=!0),["5.4","5.5","5.6","5.7","5.8","5.9"].includes(String(n?.tscCompatible))){if(e.compilerOptions.esModuleInterop===void 0&&(e.compilerOptions.module==="node16"||e.compilerOptions.module==="node18"||e.compilerOptions.module==="node20"||e.compilerOptions.module==="nodenext"||e.compilerOptions.module==="preserve")&&(e.compilerOptions.esModuleInterop=!0),e.compilerOptions.moduleDetection===void 0&&e.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(e.compilerOptions.module)&&(e.compilerOptions.moduleDetection="force"),e.compilerOptions.moduleResolution===void 0){let i="classic";if(e.compilerOptions.module!==void 0)switch(e.compilerOptions.module.toLocaleLowerCase()){case"commonjs":{i="node10";break}case"node16":case"node18":{i="node16";break}case"node20":{i="node16";break}case"nodenext":{i="nodenext";break}case"preserve":{i="bundler";break}}i!=="classic"&&(e.compilerOptions.moduleResolution=i)}if(e.compilerOptions.moduleResolution==="bundler"&&(e.compilerOptions.resolveJsonModule??=!0),e.compilerOptions.module&&["node20","nodenext"].includes(e.compilerOptions.module)&&(e.compilerOptions.resolveJsonModule??=!0),(e.compilerOptions.esModuleInterop||e.compilerOptions.module==="system"||e.compilerOptions.moduleResolution==="bundler")&&e.compilerOptions.allowSyntheticDefaultImports===void 0&&(e.compilerOptions.allowSyntheticDefaultImports=!0),["5.7","5.8","5.9"].includes(String(n?.tscCompatible))&&e.compilerOptions.moduleResolution){let i=!1;["bundler","node16","nodenext"].includes(e.compilerOptions.moduleResolution.toLocaleLowerCase())&&(i=!0),e.compilerOptions.resolvePackageJsonExports===void 0&&i&&(e.compilerOptions.resolvePackageJsonExports=!0),e.compilerOptions.resolvePackageJsonImports===void 0&&i&&(e.compilerOptions.resolvePackageJsonImports=!0)}if(e.compilerOptions.target===void 0){let i="es5";switch(e.compilerOptions.module){case"node16":case"node18":{i="es2022";break}case"node20":{i="es2023";break}case"nodenext":{i="esnext";break}}i!=="es5"&&(e.compilerOptions.target=i)}e.compilerOptions.useDefineForClassFields===void 0&&e.compilerOptions.target&&Te(e.compilerOptions.target)&&(e.compilerOptions.useDefineForClassFields=!0)}if(["5.6","5.7","5.8","5.9"].includes(String(n?.tscCompatible))&&e.compilerOptions.strict&&e.compilerOptions.strictBuiltinIteratorReturn===void 0&&(e.compilerOptions.strictBuiltinIteratorReturn=!0),["5.4","5.5","5.6","5.7","5.8","5.9"].includes(String(n?.tscCompatible))&&(e.compilerOptions.strict&&(e.compilerOptions.noImplicitAny=e.compilerOptions.noImplicitAny??!0,e.compilerOptions.noImplicitThis=e.compilerOptions.noImplicitThis??!0,e.compilerOptions.strictNullChecks=e.compilerOptions.strictNullChecks??!0,e.compilerOptions.strictFunctionTypes=e.compilerOptions.strictFunctionTypes??!0,e.compilerOptions.strictBindCallApply=e.compilerOptions.strictBindCallApply??!0,e.compilerOptions.strictPropertyInitialization=e.compilerOptions.strictPropertyInitialization??!0,e.compilerOptions.alwaysStrict=e.compilerOptions.alwaysStrict??!0),e.compilerOptions.strict&&e.compilerOptions.useUnknownInCatchVariables===void 0&&(e.compilerOptions.useUnknownInCatchVariables=!0),e.compilerOptions.isolatedModules&&(e.compilerOptions.preserveConstEnums=e.compilerOptions.preserveConstEnums??!0)),["6.0","7.0","true"].includes(String(n?.tscCompatible))){if(e.compilerOptions.moduleDetection===void 0&&e.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(e.compilerOptions.module)&&(e.compilerOptions.moduleDetection="force"),e.compilerOptions.moduleResolution===void 0&&e.compilerOptions.module){const i=e.compilerOptions.module.toLocaleLowerCase();i==="node16"||i==="node18"||i==="node20"?e.compilerOptions.moduleResolution="node16":i==="nodenext"&&(e.compilerOptions.moduleResolution="nodenext")}if(e.compilerOptions.useDefineForClassFields===void 0&&e.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(e.compilerOptions.module)&&e.compilerOptions.target&&!Te(e.compilerOptions.target)&&(e.compilerOptions.useDefineForClassFields=!1),e.compilerOptions.isolatedModules&&e.compilerOptions.preserveConstEnums===void 0&&(e.compilerOptions.preserveConstEnums=!0),e.compilerOptions.resolveJsonModule===void 0){const i=e.compilerOptions.module,t=e.compilerOptions.moduleResolution?.toLocaleLowerCase();!(i!==void 0&&["node20","nodenext"].includes(i)||t==="bundler")&&t&&(e.compilerOptions.resolveJsonModule=!1)}if(e.compilerOptions.moduleResolution){const i=e.compilerOptions.moduleResolution.toLocaleLowerCase();["bundler","node16","nodenext"].includes(i)||(e.compilerOptions.resolvePackageJsonExports??=!1,e.compilerOptions.resolvePackageJsonImports??=!1)}}return e.compileOnSave===!1&&delete e.compileOnSave,e},Wt=(e,n)=>{const i=e?.typescriptVersion;if(!(i===!1||i===void 0))return i==="auto"?Re(n):i},E="${configDir}",Se=Symbol("implicitBaseUrl"),Vt=(e,n)=>{const i=j(e),t=xe(i,n),o=L(i),r=Wt(n,o);r&&t.compilerOptions&&Dt(t.compilerOptions,r);const{compilerOptions:s}=t;if(s){for(const c of xt){const u=s[c];if(u){const a=z(u,o);s[c]=a?M(P(o,a)):u}}for(const c of["rootDirs","typeRoots"]){const u=s[c];u&&(s[c]=u.map(a=>{const m=z(a,o);return m?M(P(o,m)):a}))}const{paths:f}=s;if(f){const c=Object.keys(f);for(let u=0;u<c.length;u++){const a=c[u];f[a]=f[a].map(m=>z(m,o)??m)}}}for(let f=0;f<ce.length;f++){const c=ce[f],u=t[c];u&&(t[c]=u.map(a=>z(a,o)??a))}return St(t,n)};let Mt;const Pt=e=>(Mt??=je(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Jt=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[n,i]=V.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return V.getBuiltinModule(e)}return Pt(e)},{statSync:qt}=Jt("node:fs"),Gt=new Map,ue=new WeakMap,Ht="tsconfig.json",We=e=>{try{return qt(e).mtimeMs}catch{return 0}},zt=(e,n)=>{let i=String(n.typescriptVersion);return n.typescriptVersion==="auto"&&(i=`auto:${String(Re(L(e)))}`),`${e}::${String(n.tscCompatible)}::${i}`},Qt=(e,n,i)=>{if(e.has(n)&&ue.get(e)?.get(n)===We(i))return e.get(n)},Xt=(e,n,i,t)=>{e.set(n,t);let o=ue.get(e);o||(o=new Map,ue.set(e,o)),o.set(n,We(i))},Yt=(e,n={})=>{const i=n.configFileName??Ht,t=n.configFileName===void 0;let o=X(i,{...e&&{cwd:e},type:"file"});if(!o&&t&&(o=X("jsconfig.json",{...e&&{cwd:e},type:"file"})),!o)throw new Ne(t?`No such file or directory, for '${i}' or 'jsconfig.json' found.`:`No such file or directory, for '${i}' found.`);const r=n.cache&&typeof n.cache!="boolean"?n.cache:Gt,s=zt(o,n);if(n.cache){const c=Qt(r,s,o);if(c)return c}const f={config:Vt(o,{tscCompatible:n.tscCompatible,typescriptVersion:n.typescriptVersion}),path:o};return n.cache&&Xt(r,s,o,f),f},Zt=/\.[cm]?tsx?$/,Kt=[".yaml",".yml",".toml",".jsonc",".json5",".txt"],Ve=/\.(?:ya?ml|toml|jsonc|json5|txt)$/,Ct=e=>e.endsWith(".yaml")||e.endsWith(".yml")?dt(e):e.endsWith(".toml")?mt(e):e.endsWith(".jsonc")?at(e,{allowTrailingComma:!0}):e.endsWith(".json5")?rt(e):ae(e,"utf8"),pe=e=>e===void 0?"undefined":e===null?"null":typeof e=="number"?Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":String(e):typeof e=="bigint"?`${e}n`:typeof e=="boolean"?String(e):typeof e=="string"?JSON.stringify(e):e instanceof Date?`new Date(${JSON.stringify(e.toISOString())})`:Array.isArray(e)?`[${e.map(n=>pe(n)).join(",")}]`:typeof e=="object"?`{${Object.entries(e).map(([i,t])=>`${JSON.stringify(i)}:${pe(t)}`).join(",")}}`:"null",ie=new Map,en=(e,n)=>e.startsWith(E)?h(n,e.slice(E.length)):e,tn=e=>{if(ie.has(e))return ie.get(e);let n;try{const{config:i,path:t}=Yt(e,{cache:!1}),o=L(t),r=i.compilerOptions,s=r?.paths??{};if(r!==void 0){const{baseUrl:f}=r;let c,u=!1;if(f===void 0){const a=r[Se];c=typeof a=="string"?a:o}else u=!0,c=j(o,en(f,o));n={hasBaseUrl:u,paths:s,pathsBase:c}}}catch{n=void 0}return ie.set(e,n),n},Me=(e,n)=>{const i=tn(n);if(i===void 0)return;const{hasBaseUrl:t,pathsBase:o}=i,r=s=>Pe(s)??Je(s);for(const[s,f]of Object.entries(i.paths)){const c=s.indexOf("*");if(c===-1){if(s===e)for(const m of f){const v=r(j(o,m));if(v!==void 0)return v}continue}const u=s.slice(0,c),a=s.slice(c+1);if(e.startsWith(u)&&e.endsWith(a)&&e.length>=u.length+a.length){const m=e.slice(u.length,e.length-a.length);for(const v of f){const b=v.replace("*",m),y=r(j(o,b));if(y!==void 0)return y}}}if(t){const s=r(j(o,e));if(s!==void 0)return s}};let he=!1,se=0,Ae=!1,Ee=!1;const nn=()=>{Ee||(Ee=!0,process.setSourceMapsEnabled?.(!0))},on=e=>{const n=e.indexOf("?");return n===-1?e:e.slice(0,n)},sn=e=>e.endsWith(".cts")?"commonjs":"module",Ie=[".ts",".tsx",".mts",".cts",".js",".mjs",".cjs",".json"],F=e=>{try{return $e(e).isFile()}catch{return!1}},rn=e=>{try{return $e(e).isDirectory()}catch{return!1}},ln=e=>{if(e.endsWith(".js"))return`${e.slice(0,-3)}.ts`;if(e.endsWith(".mjs"))return`${e.slice(0,-4)}.mts`;if(e.endsWith(".cjs"))return`${e.slice(0,-4)}.cts`},Pe=e=>{if(F(e))return e;const n=ln(e);if(n!==void 0&&F(n))return n;for(const i of Ie)if(F(e+i))return e+i;if(rn(e))for(const i of Ie){const t=`${e}/index${i}`;if(F(t))return t}},Je=e=>{if(F(e)&&Ve.test(e))return e;for(const n of Kt)if(F(e+n))return e+n},qe=()=>{nn();const{registerHooks:e}=re;return typeof e!="function"?!1:(he||(e({load(n,i,t){const o=on(n);if(o.startsWith("file:")&&Zt.test(o)){const r=G(o),{code:s}=Le(r,ae(r,"utf8"));return{format:sn(r),shortCircuit:!0,source:s}}if(o.startsWith("file:")&&Ve.test(o)){const r=G(o),s=Ct(r);return{format:"module",shortCircuit:!0,source:`export default ${pe(s)};
4
4
  `}}return t(n,i)},resolve(n,i,t){if((n.startsWith(".")||n.startsWith("/"))&&i.parentURL!==void 0){let o;try{o=new URL(n,i.parentURL)}catch{o=void 0}if(o?.protocol==="file:"){const r=G(o),s=Pe(r)??Je(r);if(s!==void 0)return{shortCircuit:!0,url:Q(s).href}}}if(i.parentURL!==void 0&&!n.startsWith(".")&&!n.startsWith("/")&&!n.startsWith("#")&&!n.startsWith("node:")&&!re.isBuiltin?.(n)){let o;try{o=L(G(i.parentURL))}catch{o=void 0}if(o!==void 0){const r=Me(n,o);if(r!==void 0)return{shortCircuit:!0,url:Q(r).href}}}return t(n,i)}}),he=!0),!0)},cn=()=>qe(),un=async e=>{if(se+=1,qe())return await import(`${Q(e).href}?v=${String(se)}`);Ae||(Ae=!0,process.stderr.write(`vis: Node < 22.15 has no module.registerHooks — only the entry file is transpiled; local TypeScript imports won't load. Upgrade to Node >= 22.15 for full support.
5
- `));const{code:n}=Le(e,ae(e,"utf8")),i=h(L(e),`.vis-ts-${String(se)}-${String(process.pid)}.mjs`);Ye(i,n);try{return await import(Q(i).href)}finally{try{Ze(i)}catch{}}},On=Object.defineProperty({__proto__:null,importTs:un,registerTsHooks:cn,resolveTsConfigPaths:Me},Symbol.toStringTag,{value:"Module"});export{mt as f,un as i,dt as l,cn as r,On as t};
5
+ `));const{code:n}=Le(e,ae(e,"utf8")),i=h(L(e),`.vis-ts-${String(se)}-${String(process.pid)}.mjs`);Ye(i,n);try{return await import(Q(i).href)}finally{try{Ze(i)}catch{}}},On=Object.defineProperty({__proto__:null,importTs:un,registerTsHooks:cn,resolveTsConfigPaths:Me},Symbol.toStringTag,{value:"Module"});export{Yt as R,mt as f,un as i,dt as l,cn as r,On as t};
@@ -1,2 +1,2 @@
1
- import{p}from"./cli-main.js";import{d as b}from"../packem_shared/pm-runner-CMSml1Bj.js";import{r as m,l as w,L as v}from"../packem_shared/dependency-scan-B8jroa1D.js";import{z as S,e as g}from"../packem_shared/index-BzhrR_iC.js";import{S as $}from"../packem_shared/lockfile-DhHAaHN5.js";import{e as x}from"../packem_shared/index-BO8qIogg.js";import{y as C}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";const E=e=>{const o=e.trim();return o===""?!1:/^(?:git\+|git:\/\/|git@|ssh:\/\/)/i.test(o)||/^(?:github|gitlab|bitbucket|gist):/i.test(o)||/^[\w.-]+\/[\w.-]+(?:#.+)?$/.test(o)&&!o.includes("@")?!0:/^https?:\/\//i.test(o)},M=(e,o)=>{for(const i of o)if(i===e||i.endsWith("*")&&e.startsWith(i.slice(0,-1)))return!0;return!1},L=(e,o,i={})=>{const t=m(e,o);if(!t)return[];let s;try{s=S(g(e,t.file))}catch{return[]}const n=$(s,t.type);if(n.length===0)return[];const r=i.allow??[],l=[],f=new Set;for(const c of n){const a=`${c.name}@${c.version}`;for(const d of[c.dependencies,c.optionalDependencies])if(d){for(const[u,h]of Object.entries(d))if(!M(u,r))for(const k of h){if(!E(k))continue;const y=`${a}->${u}@${k}`;f.has(y)||(f.add(y),l.push({declaredBy:a,packageName:u,source:k}))}}}return l.sort((c,a)=>c.packageName.localeCompare(a.packageName)||c.declaredBy.localeCompare(a.declaredBy))},D=new Set(["firstSeen","publisherChange"]),I=e=>e.severity==="block"&&e.acceptedRisk===void 0,N=e=>{const o=e.security?.policies?.firstSeen?.minutes,i=typeof o=="number"&&o>0,t=e.security?.policies?.publisherChange?.mode==="no-downgrade",s=e.security?.blockExoticSubdeps===!0;return i||t||s},O=async e=>{const{offline:o=!1,packageManager:i,visConfig:t,workspaceRoot:s}=e,n=Date.now();if(!N(t))return{decisions:[],durationMs:Date.now()-n,entryCount:0,exoticViolations:[],lockfileMissing:!1,status:"skipped"};const r=m(s,i);if(!r||!C(g(s,r.file)))return{decisions:[],durationMs:Date.now()-n,entryCount:0,exoticViolations:[],lockfileMissing:!0,status:"fail"};const l=w(s,i,{includeDev:!0}),f=l.length,c=await x({offline:o,packageManager:i,packages:l,workspaceRoot:s},"install",{enabledPolicies:new Set(D),visConfig:t}),a=t.security?.blockExoticSubdeps===!0?L(s,i,{allow:t.security.exoticSubdepsAllow}):[],d=c.some(u=>I(u))||a.length>0;return{decisions:c,durationMs:Date.now()-n,entryCount:f,exoticViolations:a,lockfileMissing:!1,status:d?"fail":"pass"}},P=e=>e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`,V=e=>{if(e.status==="skipped")return["– Lockfile supply-chain verification skipped (no firstSeen / publisherChange / blockExoticSubdeps policy configured)"];if(e.lockfileMissing)return["✗ Lockfile supply-chain verification failed — no lockfile found, the resolved closure cannot be attested"];const o=`(${String(e.entryCount)} ${e.entryCount===1?"entry":"entries"}, ${P(e.durationMs)})`;if(e.status==="pass")return[`✓ Lockfile passes supply-chain policies ${o}`];const i=[`✗ Lockfile failed supply-chain policy check ${o}`];for(const t of e.decisions)t.severity==="block"&&t.acceptedRisk===void 0&&i.push(` [${t.policy}] ${t.reason}`);for(const t of e.exoticViolations)i.push(` [blockExoticSubdeps] ${t.packageName} pulled from exotic source by ${t.declaredBy}: ${t.source}`);return i},z=async({options:e,visConfig:o,workspaceRoot:i})=>{const t=i??process.cwd(),s=b(t);if(!v[s.name]){p.warn(`Package manager '${s.name}' has no lockfile vis can verify.`);return}const n=await O({offline:!!e.offline,packageManager:s.name,visConfig:o??{},workspaceRoot:t});if(e.json){process.stdout.write(`${JSON.stringify(n,void 0,2)}
1
+ import{p}from"./cli-main.js";import{d as b}from"../packem_shared/pm-runner-3iiQayy-.js";import{r as m,l as w,L as v}from"../packem_shared/dependency-scan-B8jroa1D.js";import{z as S,e as g}from"../packem_shared/index-BzhrR_iC.js";import{S as $}from"../packem_shared/lockfile-DhHAaHN5.js";import{e as x}from"../packem_shared/index-nEyN71oX.js";import{y as C}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";const E=e=>{const o=e.trim();return o===""?!1:/^(?:git\+|git:\/\/|git@|ssh:\/\/)/i.test(o)||/^(?:github|gitlab|bitbucket|gist):/i.test(o)||/^[\w.-]+\/[\w.-]+(?:#.+)?$/.test(o)&&!o.includes("@")?!0:/^https?:\/\//i.test(o)},M=(e,o)=>{for(const i of o)if(i===e||i.endsWith("*")&&e.startsWith(i.slice(0,-1)))return!0;return!1},L=(e,o,i={})=>{const t=m(e,o);if(!t)return[];let s;try{s=S(g(e,t.file))}catch{return[]}const n=$(s,t.type);if(n.length===0)return[];const r=i.allow??[],l=[],f=new Set;for(const c of n){const a=`${c.name}@${c.version}`;for(const d of[c.dependencies,c.optionalDependencies])if(d){for(const[u,h]of Object.entries(d))if(!M(u,r))for(const k of h){if(!E(k))continue;const y=`${a}->${u}@${k}`;f.has(y)||(f.add(y),l.push({declaredBy:a,packageName:u,source:k}))}}}return l.sort((c,a)=>c.packageName.localeCompare(a.packageName)||c.declaredBy.localeCompare(a.declaredBy))},D=new Set(["firstSeen","publisherChange"]),I=e=>e.severity==="block"&&e.acceptedRisk===void 0,N=e=>{const o=e.security?.policies?.firstSeen?.minutes,i=typeof o=="number"&&o>0,t=e.security?.policies?.publisherChange?.mode==="no-downgrade",s=e.security?.blockExoticSubdeps===!0;return i||t||s},O=async e=>{const{offline:o=!1,packageManager:i,visConfig:t,workspaceRoot:s}=e,n=Date.now();if(!N(t))return{decisions:[],durationMs:Date.now()-n,entryCount:0,exoticViolations:[],lockfileMissing:!1,status:"skipped"};const r=m(s,i);if(!r||!C(g(s,r.file)))return{decisions:[],durationMs:Date.now()-n,entryCount:0,exoticViolations:[],lockfileMissing:!0,status:"fail"};const l=w(s,i,{includeDev:!0}),f=l.length,c=await x({offline:o,packageManager:i,packages:l,workspaceRoot:s},"install",{enabledPolicies:new Set(D),visConfig:t}),a=t.security?.blockExoticSubdeps===!0?L(s,i,{allow:t.security.exoticSubdepsAllow}):[],d=c.some(u=>I(u))||a.length>0;return{decisions:c,durationMs:Date.now()-n,entryCount:f,exoticViolations:a,lockfileMissing:!1,status:d?"fail":"pass"}},P=e=>e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`,V=e=>{if(e.status==="skipped")return["– Lockfile supply-chain verification skipped (no firstSeen / publisherChange / blockExoticSubdeps policy configured)"];if(e.lockfileMissing)return["✗ Lockfile supply-chain verification failed — no lockfile found, the resolved closure cannot be attested"];const o=`(${String(e.entryCount)} ${e.entryCount===1?"entry":"entries"}, ${P(e.durationMs)})`;if(e.status==="pass")return[`✓ Lockfile passes supply-chain policies ${o}`];const i=[`✗ Lockfile failed supply-chain policy check ${o}`];for(const t of e.decisions)t.severity==="block"&&t.acceptedRisk===void 0&&i.push(` [${t.policy}] ${t.reason}`);for(const t of e.exoticViolations)i.push(` [blockExoticSubdeps] ${t.packageName} pulled from exotic source by ${t.declaredBy}: ${t.source}`);return i},z=async({options:e,visConfig:o,workspaceRoot:i})=>{const t=i??process.cwd(),s=b(t);if(!v[s.name]){p.warn(`Package manager '${s.name}' has no lockfile vis can verify.`);return}const n=await O({offline:!!e.offline,packageManager:s.name,visConfig:o??{},workspaceRoot:t});if(e.json){process.stdout.write(`${JSON.stringify(n,void 0,2)}
2
2
  `),n.status==="fail"&&(process.exitCode=1);return}const[r,...l]=V(n);if(n.status==="skipped"){p.info(r);return}if(n.status==="pass"){p.success(r);return}p.error(r);for(const f of l)p.error(f);process.exitCode=1};export{z as default};
@@ -1 +1 @@
1
- import{createRequire as T}from"node:module";import{getAffectedProjects as W}from"@visulima/task-runner";import{i as A}from"./index-BjdW45xX.js";import{V as k}from"./vis-user-error-Cpg2FqA4.js";import{r as B}from"./affected-shas-B2V84O0g.js";let I;const R=e=>(I??=T(import.meta.url))(e),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,F=e=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,s]=f.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return f.getBuiltinModule(e)}return R(e)},{spawnSync:S}=F("node:child_process"),b=new Set(["deep","direct","none"]),O=e=>{const t=[],s=e.split("\0");for(let n=0;n<s.length;n++){const o=s[n];if(!o||o.length<4)continue;const c=o.slice(0,2),p=o.slice(3);if(p&&t.push(p),c.includes("R")||c.includes("C")){n+=1;const l=s[n];l&&t.push(l)}}return t},P=e=>{const t=S("git",["status","--porcelain","-z"],{cwd:e,encoding:"utf8"});return t.error||t.status!==0||typeof t.stdout!="string"?[]:O(t.stdout)},D=async(e,t,s={})=>{const n=e.downstream??"deep",o=e.upstream??"none";if(!b.has(n))throw new k(`Invalid --downstream value: "${n}". Must be "none", "direct", or "deep".`);if(!b.has(o))throw new k(`Invalid --upstream value: "${o}". Must be "none", "direct", or "deep".`);const{fileOwners:c,projectGraph:p,projects:l,workspaceRoot:h}=t,a=[];let{base:g}=e,{head:i}=e;if(!g||!i){const u=B({defaultBase:s.defaultBase,workspaceRoot:h});g=g||u.base,i=i||u.head,a.push(`Resolved affected refs from ${u.provider} (${u.notes.join("; ")})`)}const y=s.runningInCi??A,w=i==="HEAD"||i==="",$=e.uncommitted??(!y&&w);let d=[];if($)if(w){const j=(s.readWorkingTreeChanges??P)(h),C=Object.values(l).map(r=>r.root?.replace(/\/$/,"")).filter(r=>!!r&&r!==".");d=j.filter(r=>c!==void 0&&Object.hasOwn(c,r)||C.some(v=>r===v||r.startsWith(`${v}/`)));const _=j.length-d.length;d.length>0&&a.push(`including ${d.length} uncommitted working-tree file(s)`),_>0&&a.push(`ignoring ${_} uncommitted path(s) outside any project (untracked scratch would otherwise mark every project affected)`)}else a.push(`ignoring --uncommitted: --head=${i} pins the comparison to a commit, not the working tree`);const m=await W({additionalChangedFiles:d,base:g,downstream:n,fileOwners:c,head:i,ignoredFiles:s.affectedIgnore,projectGraph:p,projects:l,upstream:o,workspaceRoot:h});return m.ignoredFiles.length>0&&a.push(`ignoring ${m.ignoredFiles.length} changed path(s) outside any project matching affectedIgnore`),{...m,notes:a,uncommittedFileCount:d.length}};export{D as s};
1
+ import{createRequire as T}from"node:module";import{getAffectedProjects as W}from"@visulima/task-runner";import{i as A}from"./index-BjdW45xX.js";import{V as k}from"./vis-user-error-Dd7hwxlW.js";import{r as B}from"./affected-shas-B_kfSKss.js";let I;const R=e=>(I??=T(import.meta.url))(e),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,F=e=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,s]=f.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return f.getBuiltinModule(e)}return R(e)},{spawnSync:S}=F("node:child_process"),b=new Set(["deep","direct","none"]),O=e=>{const t=[],s=e.split("\0");for(let n=0;n<s.length;n++){const o=s[n];if(!o||o.length<4)continue;const c=o.slice(0,2),p=o.slice(3);if(p&&t.push(p),c.includes("R")||c.includes("C")){n+=1;const l=s[n];l&&t.push(l)}}return t},P=e=>{const t=S("git",["status","--porcelain","-z"],{cwd:e,encoding:"utf8"});return t.error||t.status!==0||typeof t.stdout!="string"?[]:O(t.stdout)},D=async(e,t,s={})=>{const n=e.downstream??"deep",o=e.upstream??"none";if(!b.has(n))throw new k(`Invalid --downstream value: "${n}". Must be "none", "direct", or "deep".`);if(!b.has(o))throw new k(`Invalid --upstream value: "${o}". Must be "none", "direct", or "deep".`);const{fileOwners:c,projectGraph:p,projects:l,workspaceRoot:h}=t,a=[];let{base:g}=e,{head:i}=e;if(!g||!i){const u=B({defaultBase:s.defaultBase,workspaceRoot:h});g=g||u.base,i=i||u.head,a.push(`Resolved affected refs from ${u.provider} (${u.notes.join("; ")})`)}const y=s.runningInCi??A,w=i==="HEAD"||i==="",$=e.uncommitted??(!y&&w);let d=[];if($)if(w){const j=(s.readWorkingTreeChanges??P)(h),C=Object.values(l).map(r=>r.root?.replace(/\/$/,"")).filter(r=>!!r&&r!==".");d=j.filter(r=>c!==void 0&&Object.hasOwn(c,r)||C.some(v=>r===v||r.startsWith(`${v}/`)));const _=j.length-d.length;d.length>0&&a.push(`including ${d.length} uncommitted working-tree file(s)`),_>0&&a.push(`ignoring ${_} uncommitted path(s) outside any project (untracked scratch would otherwise mark every project affected)`)}else a.push(`ignoring --uncommitted: --head=${i} pins the comparison to a commit, not the working tree`);const m=await W({additionalChangedFiles:d,base:g,downstream:n,fileOwners:c,head:i,ignoredFiles:s.affectedIgnore,projectGraph:p,projects:l,upstream:o,workspaceRoot:h});return m.ignoredFiles.length>0&&a.push(`ignoring ${m.ignoredFiles.length} changed path(s) outside any project matching affectedIgnore`),{...m,notes:a,uncommittedFileCount:d.length}};export{D as s};
@@ -0,0 +1 @@
1
+ import{createRequire as l}from"node:module";import{z as g}from"./index-BzhrR_iC.js";import{y as b}from"./isAccessibleSync-DYKTrrvc-C-_5cgwu.js";let E;const d=e=>(E??=l(import.meta.url))(e),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[t,r]=u.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return u.getBuiltinModule(e)}return d(e)},{spawnSync:p}=h("node:child_process"),A="0000000000000000000000000000000000000000",f=e=>{if(b(e))try{const t=g(e);return JSON.parse(t)}catch{return}},R=(e,t)=>{const r=p("git",e,{cwd:t,encoding:"utf8"});if(!(r.error||typeof r.status!="number"||r.status!==0))return typeof r.stdout=="string"?r.stdout.trim():void 0},_=e=>typeof e=="string"&&e.length>0&&e!==A,S=(e,t,r)=>{const o=[],s=e.GITHUB_BASE_REF,n=e.GITHUB_SHA??"HEAD";if(s&&s.length>0)return o.push(`pull_request: $GITHUB_BASE_REF=${s}`),{base:`origin/${s}`,head:n,notes:o,provider:"github"};const i=e.GITHUB_EVENT_PATH,c=i?r(i):void 0;if(c){const a=typeof c.before=="string"?c.before:void 0;if(_(a))return o.push(`push: event.before=${a}`),{base:a,head:n,notes:o,provider:"github"}}return o.push(`fallback: origin/${t}`),{base:`origin/${t}`,head:n,notes:o,provider:"github"}},I=(e,t)=>{const r=[],o=e.CI_COMMIT_SHA??"HEAD";if(e.CI_PIPELINE_SOURCE==="merge_request_event"){const c=e.CI_MERGE_REQUEST_DIFF_BASE_SHA;if(_(c))return r.push(`merge_request: $CI_MERGE_REQUEST_DIFF_BASE_SHA=${c}`),{base:c,head:o,notes:r,provider:"gitlab"};const a=e.CI_MERGE_REQUEST_TARGET_BRANCH_NAME;if(a&&a.length>0)return r.push(`merge_request: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME=${a}`),{base:`origin/${a}`,head:o,notes:r,provider:"gitlab"}}const n=e.CI_COMMIT_BEFORE_SHA;if(_(n))return r.push(`push: $CI_COMMIT_BEFORE_SHA=${n}`),{base:n,head:o,notes:r,provider:"gitlab"};const i=e.CI_DEFAULT_BRANCH??t;return r.push(`fallback: origin/${i}`),{base:`origin/${i}`,head:o,notes:r,provider:"gitlab"}},T=(e,t)=>{const r=[],o=e.BUILD_SOURCEVERSION??"HEAD",s=e.SYSTEM_PULLREQUEST_TARGETBRANCHNAME,n=e.SYSTEM_PULLREQUEST_TARGETBRANCH,i=s&&s.length>0?s:n?.replace(/^refs\/heads\//,"");return i&&i.length>0?(r.push(`pull_request: target branch ${i}`),{base:`origin/${i}`,head:o,notes:r,provider:"azure"}):(r.push(`fallback: origin/${t} (azure has no canonical previous-build SHA env)`),{base:`origin/${t}`,head:o,notes:r,provider:"azure"})},C=(e,t)=>{const r=[],o=e.BUILDKITE_COMMIT??"HEAD",s=e.BUILDKITE_PULL_REQUEST_BASE_BRANCH;return s&&s.length>0?(r.push(`pull_request: $BUILDKITE_PULL_REQUEST_BASE_BRANCH=${s}`),{base:`origin/${s}`,head:o,notes:r,provider:"buildkite"}):(r.push(`fallback: origin/${t} (buildkite has no canonical previous-build SHA env)`),{base:`origin/${t}`,head:o,notes:r,provider:"buildkite"})},B=(e,t)=>{const r=[],o=e.CIRCLE_SHA1??"HEAD",s=e.CIRCLE_PR_BASE_BRANCH;return s&&s.length>0?(r.push(`pull_request: $CIRCLE_PR_BASE_BRANCH=${s}`),{base:`origin/${s}`,head:o,notes:r,provider:"circleci"}):(r.push(`fallback: origin/${t} (circleci has no canonical previous-build SHA env)`),{base:`origin/${t}`,head:o,notes:r,provider:"circleci"})},H=(e,t,r)=>{const o=[],s=t(["merge-base","HEAD",`origin/${e}`],r);return s&&s.length>0?(o.push(`local: git merge-base HEAD origin/${e}=${s}`),{base:s,head:"HEAD",notes:o,provider:"local"}):(o.push(`local fallback: origin/${e} (no merge-base available)`),{base:`origin/${e}`,head:"HEAD",notes:o,provider:"local"})},m=e=>{const t=e?.env??process.env,r=e?.defaultBase??"main",o=e?.readEventPayload??f,s=e?.runGit??R,n=e?.workspaceRoot??process.cwd();return t.GITHUB_ACTIONS==="true"?S(t,r,o):t.GITLAB_CI==="true"?I(t,r):t.TF_BUILD?.toLowerCase()==="true"?T(t,r):t.BUILDKITE==="true"?C(t,r):t.CIRCLECI==="true"?B(t,r):H(r,s,n)};export{m as r};
@@ -1,5 +1,5 @@
1
- import{createRequire as Z}from"node:module";import{E as ie,R as v,X as ce,o as k,q as de}from"../packem_chunks/catalog.js";import{a0 as le,a1 as ue,a2 as pe,a3 as me}from"../packem_chunks/cli-main.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[n,t]=y.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return y.getBuiltinModule(e)}return te(e)},{spawn:ne,execFileSync:G,execFile:se}=E("node:child_process"),{existsSync:_,readFileSync:oe}=E("node:fs"),{platform:re,homedir:q}=E("node:os"),{join:h,win32:R}=E("node:path"),{StringDecoder:D}=E("node:string_decoder"),{promisify:ae}=E("node:util"),fe=/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/,he=5e3,ge=1e4,ve=3e5,be=4096,T=re()==="win32",U=["amp","claude","codex","copilot","crush","cursor","droid","gemini","kimi","opencode","qwen"],ke={alternateCommands:[],buildArgs:(e,{dangerous:n})=>{const t=["-x",e];return n&&t.push("--dangerously-allow-all"),t},command:"amp",defaultModel:"",displayName:"Amp",envVariable:"AMP_PATH",sessionMarkers:[{confidence:"definite",variable:"AMP_CURRENT_THREAD_ID"},{confidence:"definite",equals:"amp",variable:"AGENT"}],supportsMaxTokens:!1,supportsModel:!1},Ae={alternateCommands:[],buildArgs:(e,{dangerous:n,model:t})=>{const s=[];return n&&s.push("--dangerously-skip-permissions"),t&&s.push("--model",t),s.push("--output-format","text","-p",e),s},command:"claude",defaultModel:"",displayName:"Claude Code",envVariable:"CLAUDE_PATH",sessionMarkers:[{confidence:"definite",variable:"CLAUDECODE"},{confidence:"definite",variable:"CLAUDE_CODE"}],supportsMaxTokens:!1,supportsModel:!0},Ee={alternateCommands:["openai-codex"],buildArgs:(e,{dangerous:n,model:t})=>{const s=["exec"];return t&&s.push("--model",t),n&&s.push("--dangerously-bypass-approvals-and-sandbox"),s.push("--",e),s},command:"codex",defaultModel:"",displayName:"Codex",envVariable:"CODEX_PATH",sessionMarkers:[{confidence:"definite",variable:"CODEX_SANDBOX"},{confidence:"definite",variable:"CODEX_THREAD_ID"},{confidence:"definite",variable:"CODEX_CI"}],supportsMaxTokens:!1,supportsModel:!0},Ce={alternateCommands:[],buildArgs:(e,{dangerous:n,model:t})=>{const s=["-p",e];return n&&s.push("--allow-all-tools"),t&&s.push("--model",t),s},command:"copilot",defaultModel:"",displayName:"GitHub Copilot CLI",envVariable:"COPILOT_PATH",sessionMarkers:[{confidence:"definite",variable:"COPILOT_MODEL"},{confidence:"definite",variable:"COPILOT_ALLOW_ALL"},{confidence:"definite",variable:"COPILOT_GITHUB_TOKEN"},{agent:"GitHub Copilot in VS Code",confidence:"definite",label:"TERM_PROGRAM+GIT_PAGER",match:{all:[["TERM_PROGRAM","vscode"],["GIT_PAGER","cat"]],none:["CURSOR_TRACE_ID"]}}],supportsMaxTokens:!1,supportsModel:!0},ye={alternateCommands:[],buildArgs:(e,{dangerous:n,model:t})=>{const s=["run"];return n&&s.push("--yolo"),t&&s.push("-m",t),s.push("--",e),s},command:"crush",defaultModel:"",displayName:"Crush",envVariable:"CRUSH_PATH",sessionMarkers:[{confidence:"definite",equals:"1",variable:"CRUSH"},{confidence:"definite",equals:"crush",variable:"AGENT"}],supportsMaxTokens:!1,supportsModel:!0},we={alternateCommands:["cursor"],buildArgs:(e,{dangerous:n,model:t})=>{const s=["-p"];return n&&s.push("--force"),s.push("--output-format","text"),t&&s.push("--model",t),s.push("--",e),s},command:"agent",defaultModel:"",displayName:"Cursor Agent",envVariable:"CURSOR_PATH",sessionMarkers:[{confidence:"definite",variable:"CURSOR_AGENT"},{confidence:"definite",label:"CURSOR_TRACE_ID+PAGER",match:{all:["CURSOR_TRACE_ID",["PAGER","head -n 10000 | cat"]]}},{agent:"Cursor editor",confidence:"ambient",variable:"CURSOR_TRACE_ID"}],supportsMaxTokens:!1,supportsModel:!0},Se={alternateCommands:[],buildArgs:(e,{dangerous:n,model:t})=>{const s=[];return n&&s.push("--skip-permissions-unsafe"),s.push("-o","text"),t&&s.push("-m",t),s.push("--",e),s},command:"droid",defaultModel:"",displayName:"Droid",envVariable:"DROID_PATH",sessionMarkers:[],supportsMaxTokens:!1,supportsModel:!0},Me={alternateCommands:["gemini-cli"],buildArgs:(e,{dangerous:n,maxTokens:t,model:s})=>{const o=[];return n||o.push("--sandbox"),s&&o.push("--model",s),o.push("--max-output-tokens",String(t),"-p",e),o},command:"gemini",defaultModel:"gemini-2.5-pro",displayName:"Gemini CLI",envVariable:"GEMINI_PATH",sessionMarkers:[{confidence:"definite",label:"GEMINI_CLI",match:{all:["GEMINI_CLI"],none:["QWEN_CODE"]}}],supportsMaxTokens:!0,supportsModel:!0},_e={alternateCommands:[],buildArgs:(e,{model:n})=>{const t=["--quiet","-p",e];return n&&t.push("-m",n),t},command:"kimi",defaultModel:"",displayName:"Kimi CLI",envVariable:"KIMI_PATH",sessionMarkers:[],supportsMaxTokens:!1,supportsModel:!0},Re={alternateCommands:[],buildArgs:(e,{model:n})=>{const t=["run"];return n&&t.push("-m",n),t.push("--",e),t},command:"opencode",defaultModel:"",displayName:"opencode",envVariable:"OPENCODE_PATH",sessionMarkers:[{confidence:"definite",label:"OPENCODE",match:{any:["OPENCODE","OPENCODE_BIN_PATH","OPENCODE_SERVER","OPENCODE_APP_INFO","OPENCODE_MODES","OPENCODE_CLIENT"]}}],supportsMaxTokens:!1,supportsModel:!0},Te={alternateCommands:["qwen-code"],buildArgs:(e,{dangerous:n,model:t})=>{const s=["-p",e];return n&&s.push("--yolo"),s.push("-o","text"),t&&s.push("-m",t),s},command:"qwen",defaultModel:"",displayName:"Qwen Code",envVariable:"QWEN_PATH",sessionMarkers:[{confidence:"definite",equals:"1",variable:"QWEN_CODE"}],supportsMaxTokens:!1,supportsModel:!0},F={amp:ke,claude:Ae,codex:Ee,copilot:Ce,crush:ye,cursor:we,droid:Se,gemini:Me,kimi:_e,opencode:Re,qwen:Te};class A extends Error{exitCode;durationMs;provider;stderr;stdout;timedOut;aborted;constructor(n,t){super(n),this.name="AiRunError",this.provider=t.provider,this.exitCode=t.exitCode??null,this.durationMs=t.durationMs,this.stdout=t.stdout??"",this.stderr=t.stderr??"",this.timedOut=t.timedOut??!1,this.aborted=t.aborted??!1}}const Oe=/"%~?dp0%?\\?([^"]+?\.[cm]?js)"/i,Ie=(e,n)=>{const t=Oe.exec(e)?.[1];if(t!==void 0)return R.resolve(R.dirname(n),t)},Ne=e=>{let n;try{n=oe(e,"utf8")}catch{return}const t=Ie(n,e);if(t!==void 0)return _(t)?t:void 0},Le=e=>{const n=R.join(R.dirname(e),"node.exe");return _(n)?n:"node"};ae(se);const xe=/\.(?:bat|cmd)$/i,j=e=>`"${e.replaceAll('"','""')}"`,B=(e,n=T)=>{if(!n||!xe.test(e))return{file:e,mode:"direct",prefixArguments:[]};const t=Ne(e);return t!==void 0?{file:Le(e),mode:"direct",prefixArguments:[t]}:{commandPath:e,mode:"shell"}},K=(e,n)=>e.mode==="shell"?{file:j(e.commandPath),shell:!0,spawnArguments:n.map(t=>j(t))}:{file:e.file,shell:!1,spawnArguments:[...e.prefixArguments,...n]},V=e=>e==="~"||e.startsWith("~/")||T&&e.startsWith("~\\")?h(q(),e.slice(2)):e,Pe=e=>{try{const n=G(T?"where":"which",[e],{encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:he}).trim().split(`
2
- `)[0]?.trim();return n&&n.length>0?n:void 0}catch{return}},$e=e=>{const n=q();if(T){const t=process.env.APPDATA??"",s=process.env.LOCALAPPDATA??"",o=process.env.ProgramFiles??"";return[h(t,"npm",`${e}.cmd`),h(t,"npm",e),h(s,"Programs",e,`${e}.exe`),h(o,e,`${e}.exe`),h(n,".npm-global","bin",`${e}.cmd`)]}return[`/opt/homebrew/bin/${e}`,`/usr/local/bin/${e}`,h(n,".npm-global","bin",e),h(n,".local","bin",e),h(n,".cargo","bin",e)]},De=e=>{try{const{file:n,shell:t,spawnArguments:s}=K(B(e),["--version"]),o=G(n,s,{encoding:"utf8",shell:t,stdio:["pipe","pipe","pipe"],timeout:ge}),r=fe.exec(o);return r?r[1]:void 0}catch{return}},X=(e,n={})=>{const t=F[e],s={available:!1,name:e},o=n.version!==!1,r=i=>{if(o)return De(i)},a=process.env[t.envVariable];if(a&&_(V(a))){const i=V(a);return{...s,available:!0,detectionMethod:"envvar",path:i,version:r(i)}}const l=[t.command,...t.alternateCommands];for(const i of l){const c=Pe(i);if(c)return{...s,available:!0,detectionMethod:"which",path:c,version:r(c)}}for(const i of l)for(const c of $e(i))if(_(c))return{...s,available:!0,detectionMethod:"known-path",path:c,version:r(c)};return s},je=(e={})=>U.map(n=>X(n,e)),Ve=(e={})=>je(e).filter(n=>n.available),He=(e,n,t={})=>{const s=F[e],o=t.model??s.defaultModel,r=t.maxTokens!==void 0&&Number.isFinite(t.maxTokens)?t.maxTokens:be;return s.buildArgs(n,{dangerous:t.dangerous===!0,maxTokens:r,model:o})},Ge=async(e,n,t={})=>{if(!e.available||!e.path)throw new A(`AI provider "${e.name}" is not available.`,{durationMs:0,provider:e.name});const s=He(e.name,n,t),o=t.timeoutMs!==void 0&&Number.isFinite(t.timeoutMs)?t.timeoutMs:ve,r=e.path,a=K(B(r),s),l=Date.now();if(t.signal?.aborted)throw new A(`${e.name} CLI run was aborted.`,{aborted:!0,durationMs:0,provider:e.name});return new Promise((i,c)=>{const f={cwd:t.cwd,env:{...process.env,...t.env,FORCE_COLOR:"0",NO_COLOR:"1"},shell:a.shell,stdio:["pipe","pipe","pipe"]},d=ne(a.file,a.spawnArguments,f);d.stdin?.end();let m="",g="",b=!1;const N=new D("utf8"),L=new D("utf8");let w,x,S;const O=()=>{clearTimeout(x),S&&t.signal?.removeEventListener("abort",S)},Q=()=>{d.kill("SIGKILL")},P=p=>{if(b)return;b=!0,d.kill("SIGTERM"),w=setTimeout(Q,5e3),w.unref(),O();const u=Date.now()-l,C=p?new A(`${e.name} CLI run was aborted.`,{aborted:!0,durationMs:u,provider:e.name,stderr:g,stdout:m}):new A(`${e.name} CLI timed out after ${String(o)}ms`,{durationMs:u,provider:e.name,stderr:g,stdout:m,timedOut:!0});c(C)};x=setTimeout(P,o,!1),S=()=>{P(!0)},t.signal?.addEventListener("abort",S,{once:!0}),d.stdout?.on("data",p=>{const u=N.write(p);u&&(m+=u,t.onStdout?.(u))}),d.stderr?.on("data",p=>{const u=L.write(p);u&&(g+=u,t.onStderr?.(u))}),d.on("close",p=>{clearTimeout(w);const u=N.end();u&&(m+=u,t.onStdout?.(u));const C=L.end();if(C&&(g+=C,t.onStderr?.(C)),b)return;b=!0,O();const $=Date.now()-l;p===0?i({durationMs:$,exitCode:p,provider:e.name,stderr:g,stdout:m}):c(new A(`${e.name} CLI exited with code ${String(p)}: ${g||m}`,{durationMs:$,exitCode:p,provider:e.name,stderr:g,stdout:m}))}),d.on("error",p=>{clearTimeout(w),!b&&(b=!0,O(),c(new A(`Failed to spawn ${e.name} CLI: ${p.message}`,{durationMs:Date.now()-l,provider:e.name,stderr:g,stdout:m})))})})},qe=12e4,Ue=2,Fe=1e3,Be=e=>new Promise(n=>{setTimeout(n,e)}),J=async(e,n,t=Ue)=>{let s;for(let o=0;o<=t;o+=1)try{return(await Ge(e,n,{timeoutMs:qe})).stdout}catch(r){if(s=r instanceof Error?r:new Error(String(r)),s.message.includes("timed out"))throw s;if(o<t){const a=Fe*2**o;await Be(a)}}throw s??new Error("AI request failed after retries")},Ke={amp:30,claude:80,codex:60,copilot:50,crush:35,cursor:40,droid:20,gemini:100,kimi:25,opencode:35,qwen:30},Xe=e=>{if(e?.provider){if(!U.includes(e.provider))return;const s=X(e.provider);return s.available?s:void 0}const n=Ve();if(n.length===0)return;const t={...Ke,...e?.priority};return n.toSorted((s,o)=>(t[o.name]??0)-(t[s.name]??0))[0]},Je=new Set(["defer","review","skip","update"]),We=new Set(["critical","high","low","medium"]),Ye=new Set(["high","low","medium"]),ze=50,I=30,Qe=e=>e.map(n=>{const t=n.vulnerabilities&&n.vulnerabilities.length>0?` [VULNERABILITIES: ${n.vulnerabilities.map(o=>`${o.severity} ${o.id}`).join(", ")}]`:"";let s="";if(n.socketReport){const o=Math.round(n.socketReport.score.overall*100),r=[`score:${String(o)}%`];if(n.socketReport.alerts.length>0){const a={};for(const i of n.socketReport.alerts)a[i.severity]=(a[i.severity]??0)+1;const l=Object.entries(a).map(([i,c])=>`${String(c)} ${i}`).join(", ");r.push(`alerts: ${l}`)}r.push(`supply-chain:${String(Math.round(n.socketReport.score.supplyChain*100))}%`),r.push(`quality:${String(Math.round(n.socketReport.score.quality*100))}%`),s=` [SOCKET.DEV: ${r.join(", ")}]`}return`- ${n.packageName}: ${n.currentRange} → ${n.newRange} (${n.updateType})${t}${s}`}).join(`
1
+ import{createRequire as Z}from"node:module";import{O as ie,R as v,X as ce,o as k,q as de}from"../packem_chunks/catalog.js";import{a0 as le,a1 as ue,a2 as pe,a3 as me}from"../packem_chunks/cli-main.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[n,t]=y.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return y.getBuiltinModule(e)}return te(e)},{spawn:ne,execFileSync:G,execFile:se}=E("node:child_process"),{existsSync:_,readFileSync:oe}=E("node:fs"),{platform:re,homedir:q}=E("node:os"),{join:h,win32:R}=E("node:path"),{StringDecoder:$}=E("node:string_decoder"),{promisify:ae}=E("node:util"),fe=/v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/,he=5e3,ge=1e4,ve=3e5,be=4096,O=re()==="win32",U=["amp","claude","codex","copilot","crush","cursor","droid","gemini","kimi","opencode","qwen"],ke={alternateCommands:[],buildArgs:(e,{dangerous:n})=>{const t=["-x",e];return n&&t.push("--dangerously-allow-all"),t},command:"amp",defaultModel:"",displayName:"Amp",envVariable:"AMP_PATH",sessionMarkers:[{confidence:"definite",variable:"AMP_CURRENT_THREAD_ID"},{confidence:"definite",equals:"amp",variable:"AGENT"}],supportsMaxTokens:!1,supportsModel:!1},Ae={alternateCommands:[],buildArgs:(e,{dangerous:n,model:t})=>{const s=[];return n&&s.push("--dangerously-skip-permissions"),t&&s.push("--model",t),s.push("--output-format","text","-p",e),s},command:"claude",defaultModel:"",displayName:"Claude Code",envVariable:"CLAUDE_PATH",sessionMarkers:[{confidence:"definite",variable:"CLAUDECODE"},{confidence:"definite",variable:"CLAUDE_CODE"}],supportsMaxTokens:!1,supportsModel:!0},Ee={alternateCommands:["openai-codex"],buildArgs:(e,{dangerous:n,model:t})=>{const s=["exec"];return t&&s.push("--model",t),n&&s.push("--dangerously-bypass-approvals-and-sandbox"),s.push("--",e),s},command:"codex",defaultModel:"",displayName:"Codex",envVariable:"CODEX_PATH",sessionMarkers:[{confidence:"definite",variable:"CODEX_SANDBOX"},{confidence:"definite",variable:"CODEX_THREAD_ID"},{confidence:"definite",variable:"CODEX_CI"}],supportsMaxTokens:!1,supportsModel:!0},Ce={alternateCommands:[],buildArgs:(e,{dangerous:n,model:t})=>{const s=["-p",e];return n&&s.push("--allow-all-tools"),t&&s.push("--model",t),s},command:"copilot",defaultModel:"",displayName:"GitHub Copilot CLI",envVariable:"COPILOT_PATH",sessionMarkers:[{confidence:"definite",variable:"COPILOT_MODEL"},{confidence:"definite",variable:"COPILOT_ALLOW_ALL"},{confidence:"definite",variable:"COPILOT_GITHUB_TOKEN"},{agent:"GitHub Copilot in VS Code",confidence:"definite",label:"TERM_PROGRAM+GIT_PAGER",match:{all:[["TERM_PROGRAM","vscode"],["GIT_PAGER","cat"]],none:["CURSOR_TRACE_ID"]}}],supportsMaxTokens:!1,supportsModel:!0},ye={alternateCommands:[],buildArgs:(e,{dangerous:n,model:t})=>{const s=["run"];return n&&s.push("--yolo"),t&&s.push("-m",t),s.push("--",e),s},command:"crush",defaultModel:"",displayName:"Crush",envVariable:"CRUSH_PATH",sessionMarkers:[{confidence:"definite",equals:"1",variable:"CRUSH"},{confidence:"definite",equals:"crush",variable:"AGENT"}],supportsMaxTokens:!1,supportsModel:!0},we={alternateCommands:["cursor"],buildArgs:(e,{dangerous:n,model:t})=>{const s=["-p"];return n&&s.push("--force"),s.push("--output-format","text"),t&&s.push("--model",t),s.push("--",e),s},command:"agent",defaultModel:"",displayName:"Cursor Agent",envVariable:"CURSOR_PATH",sessionMarkers:[{confidence:"definite",variable:"CURSOR_AGENT"},{confidence:"definite",label:"CURSOR_TRACE_ID+PAGER",match:{all:["CURSOR_TRACE_ID",["PAGER","head -n 10000 | cat"]]}},{agent:"Cursor editor",confidence:"ambient",variable:"CURSOR_TRACE_ID"}],supportsMaxTokens:!1,supportsModel:!0},Se={alternateCommands:[],buildArgs:(e,{dangerous:n,model:t})=>{const s=[];return n&&s.push("--skip-permissions-unsafe"),s.push("-o","text"),t&&s.push("-m",t),s.push("--",e),s},command:"droid",defaultModel:"",displayName:"Droid",envVariable:"DROID_PATH",sessionMarkers:[],supportsMaxTokens:!1,supportsModel:!0},Me={alternateCommands:["gemini-cli"],buildArgs:(e,{dangerous:n,maxTokens:t,model:s})=>{const o=[];return n||o.push("--sandbox"),s&&o.push("--model",s),o.push("--max-output-tokens",String(t),"-p",e),o},command:"gemini",defaultModel:"gemini-2.5-pro",displayName:"Gemini CLI",envVariable:"GEMINI_PATH",sessionMarkers:[{confidence:"definite",label:"GEMINI_CLI",match:{all:["GEMINI_CLI"],none:["QWEN_CODE"]}}],supportsMaxTokens:!0,supportsModel:!0},_e={alternateCommands:[],buildArgs:(e,{model:n})=>{const t=["--quiet","-p",e];return n&&t.push("-m",n),t},command:"kimi",defaultModel:"",displayName:"Kimi CLI",envVariable:"KIMI_PATH",sessionMarkers:[],supportsMaxTokens:!1,supportsModel:!0},Re={alternateCommands:[],buildArgs:(e,{model:n})=>{const t=["run"];return n&&t.push("-m",n),t.push("--",e),t},command:"opencode",defaultModel:"",displayName:"opencode",envVariable:"OPENCODE_PATH",sessionMarkers:[{confidence:"definite",label:"OPENCODE",match:{any:["OPENCODE","OPENCODE_BIN_PATH","OPENCODE_SERVER","OPENCODE_APP_INFO","OPENCODE_MODES","OPENCODE_CLIENT"]}}],supportsMaxTokens:!1,supportsModel:!0},Oe={alternateCommands:["qwen-code"],buildArgs:(e,{dangerous:n,model:t})=>{const s=["-p",e];return n&&s.push("--yolo"),s.push("-o","text"),t&&s.push("-m",t),s},command:"qwen",defaultModel:"",displayName:"Qwen Code",envVariable:"QWEN_PATH",sessionMarkers:[{confidence:"definite",equals:"1",variable:"QWEN_CODE"}],supportsMaxTokens:!1,supportsModel:!0},F={amp:ke,claude:Ae,codex:Ee,copilot:Ce,crush:ye,cursor:we,droid:Se,gemini:Me,kimi:_e,opencode:Re,qwen:Oe};class A extends Error{exitCode;durationMs;provider;stderr;stdout;timedOut;aborted;constructor(n,t){super(n),this.name="AiRunError",this.provider=t.provider,this.exitCode=t.exitCode??null,this.durationMs=t.durationMs,this.stdout=t.stdout??"",this.stderr=t.stderr??"",this.timedOut=t.timedOut??!1,this.aborted=t.aborted??!1}}const Te=/"%~?dp0%?\\?([^"]+?\.[cm]?js)"/i,Ie=(e,n)=>{const t=Te.exec(e)?.[1];if(t!==void 0)return R.resolve(R.dirname(n),t)},Ne=e=>{let n;try{n=oe(e,"utf8")}catch{return}const t=Ie(n,e);if(t!==void 0)return _(t)?t:void 0},Le=e=>{const n=R.join(R.dirname(e),"node.exe");return _(n)?n:"node"};ae(se);const xe=/\.(?:bat|cmd)$/i,j=e=>`"${e.replaceAll('"','""')}"`,B=(e,n=O)=>{if(!n||!xe.test(e))return{file:e,mode:"direct",prefixArguments:[]};const t=Ne(e);return t!==void 0?{file:Le(e),mode:"direct",prefixArguments:[t]}:{commandPath:e,mode:"shell"}},K=(e,n)=>e.mode==="shell"?{file:j(e.commandPath),shell:!0,spawnArguments:n.map(t=>j(t))}:{file:e.file,shell:!1,spawnArguments:[...e.prefixArguments,...n]},V=e=>e==="~"||e.startsWith("~/")||O&&e.startsWith("~\\")?h(q(),e.slice(2)):e,Pe=e=>{try{const n=G(O?"where":"which",[e],{encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:he}).trim().split(`
2
+ `)[0]?.trim();return n&&n.length>0?n:void 0}catch{return}},De=e=>{const n=q();if(O){const t=process.env.APPDATA??"",s=process.env.LOCALAPPDATA??"",o=process.env.ProgramFiles??"";return[h(t,"npm",`${e}.cmd`),h(t,"npm",e),h(s,"Programs",e,`${e}.exe`),h(o,e,`${e}.exe`),h(n,".npm-global","bin",`${e}.cmd`)]}return[`/opt/homebrew/bin/${e}`,`/usr/local/bin/${e}`,h(n,".npm-global","bin",e),h(n,".local","bin",e),h(n,".cargo","bin",e)]},$e=e=>{try{const{file:n,shell:t,spawnArguments:s}=K(B(e),["--version"]),o=G(n,s,{encoding:"utf8",shell:t,stdio:["pipe","pipe","pipe"],timeout:ge}),r=fe.exec(o);return r?r[1]:void 0}catch{return}},X=(e,n={})=>{const t=F[e],s={available:!1,name:e},o=n.version!==!1,r=i=>{if(o)return $e(i)},a=process.env[t.envVariable];if(a&&_(V(a))){const i=V(a);return{...s,available:!0,detectionMethod:"envvar",path:i,version:r(i)}}const l=[t.command,...t.alternateCommands];for(const i of l){const c=Pe(i);if(c)return{...s,available:!0,detectionMethod:"which",path:c,version:r(c)}}for(const i of l)for(const c of De(i))if(_(c))return{...s,available:!0,detectionMethod:"known-path",path:c,version:r(c)};return s},je=(e={})=>U.map(n=>X(n,e)),Ve=(e={})=>je(e).filter(n=>n.available),He=(e,n,t={})=>{const s=F[e],o=t.model??s.defaultModel,r=t.maxTokens!==void 0&&Number.isFinite(t.maxTokens)?t.maxTokens:be;return s.buildArgs(n,{dangerous:t.dangerous===!0,maxTokens:r,model:o})},Ge=async(e,n,t={})=>{if(!e.available||!e.path)throw new A(`AI provider "${e.name}" is not available.`,{durationMs:0,provider:e.name});const s=He(e.name,n,t),o=t.timeoutMs!==void 0&&Number.isFinite(t.timeoutMs)?t.timeoutMs:ve,r=e.path,a=K(B(r),s),l=Date.now();if(t.signal?.aborted)throw new A(`${e.name} CLI run was aborted.`,{aborted:!0,durationMs:0,provider:e.name});return new Promise((i,c)=>{const f={cwd:t.cwd,env:{...process.env,...t.env,FORCE_COLOR:"0",NO_COLOR:"1"},shell:a.shell,stdio:["pipe","pipe","pipe"]},d=ne(a.file,a.spawnArguments,f);d.stdin?.end();let m="",g="",b=!1;const N=new $("utf8"),L=new $("utf8");let w,x,S;const T=()=>{clearTimeout(x),S&&t.signal?.removeEventListener("abort",S)},Q=()=>{d.kill("SIGKILL")},P=p=>{if(b)return;b=!0,d.kill("SIGTERM"),w=setTimeout(Q,5e3),w.unref(),T();const u=Date.now()-l,C=p?new A(`${e.name} CLI run was aborted.`,{aborted:!0,durationMs:u,provider:e.name,stderr:g,stdout:m}):new A(`${e.name} CLI timed out after ${String(o)}ms`,{durationMs:u,provider:e.name,stderr:g,stdout:m,timedOut:!0});c(C)};x=setTimeout(P,o,!1),S=()=>{P(!0)},t.signal?.addEventListener("abort",S,{once:!0}),d.stdout?.on("data",p=>{const u=N.write(p);u&&(m+=u,t.onStdout?.(u))}),d.stderr?.on("data",p=>{const u=L.write(p);u&&(g+=u,t.onStderr?.(u))}),d.on("close",p=>{clearTimeout(w);const u=N.end();u&&(m+=u,t.onStdout?.(u));const C=L.end();if(C&&(g+=C,t.onStderr?.(C)),b)return;b=!0,T();const D=Date.now()-l;p===0?i({durationMs:D,exitCode:p,provider:e.name,stderr:g,stdout:m}):c(new A(`${e.name} CLI exited with code ${String(p)}: ${g||m}`,{durationMs:D,exitCode:p,provider:e.name,stderr:g,stdout:m}))}),d.on("error",p=>{clearTimeout(w),!b&&(b=!0,T(),c(new A(`Failed to spawn ${e.name} CLI: ${p.message}`,{durationMs:Date.now()-l,provider:e.name,stderr:g,stdout:m})))})})},qe=12e4,Ue=2,Fe=1e3,Be=e=>new Promise(n=>{setTimeout(n,e)}),J=async(e,n,t=Ue)=>{let s;for(let o=0;o<=t;o+=1)try{return(await Ge(e,n,{timeoutMs:qe})).stdout}catch(r){if(s=r instanceof Error?r:new Error(String(r)),s.message.includes("timed out"))throw s;if(o<t){const a=Fe*2**o;await Be(a)}}throw s??new Error("AI request failed after retries")},Ke={amp:30,claude:80,codex:60,copilot:50,crush:35,cursor:40,droid:20,gemini:100,kimi:25,opencode:35,qwen:30},Xe=e=>{if(e?.provider){if(!U.includes(e.provider))return;const s=X(e.provider);return s.available?s:void 0}const n=Ve();if(n.length===0)return;const t={...Ke,...e?.priority};return n.toSorted((s,o)=>(t[o.name]??0)-(t[s.name]??0))[0]},Je=new Set(["defer","review","skip","update"]),We=new Set(["critical","high","low","medium"]),Ye=new Set(["high","low","medium"]),ze=50,I=30,Qe=e=>e.map(n=>{const t=n.vulnerabilities&&n.vulnerabilities.length>0?` [VULNERABILITIES: ${n.vulnerabilities.map(o=>`${o.severity} ${o.id}`).join(", ")}]`:"";let s="";if(n.socketReport){const o=Math.round(n.socketReport.score.overall*100),r=[`score:${String(o)}%`];if(n.socketReport.alerts.length>0){const a={};for(const i of n.socketReport.alerts)a[i.severity]=(a[i.severity]??0)+1;const l=Object.entries(a).map(([i,c])=>`${String(c)} ${i}`).join(", ");r.push(`alerts: ${l}`)}r.push(`supply-chain:${String(Math.round(n.socketReport.score.supplyChain*100))}%`),r.push(`quality:${String(Math.round(n.socketReport.score.quality*100))}%`),s=` [SOCKET.DEV: ${r.join(", ")}]`}return`- ${n.packageName}: ${n.currentRange} → ${n.newRange} (${n.updateType})${t}${s}`}).join(`
3
3
  `),M=`Respond ONLY with valid JSON in this exact structure:
4
4
  {
5
5
  "summary": "Brief overall summary",