tar 8.0.0 → 8.0.1
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.
- package/README.md +8 -1
- package/dist/commonjs/index.min.js +2 -2
- package/dist/commonjs/index.min.js.map +3 -3
- package/dist/commonjs/server/index.min.js +2 -2
- package/dist/commonjs/server/index.min.js.map +3 -3
- package/dist/commonjs/unpack.d.ts +8 -0
- package/dist/commonjs/unpack.d.ts.map +1 -1
- package/dist/commonjs/unpack.js +38 -14
- package/dist/commonjs/unpack.js.map +1 -1
- package/dist/esm/index.min.js +2 -2
- package/dist/esm/index.min.js.map +3 -3
- package/dist/esm/server/index.min.js +2 -2
- package/dist/esm/server/index.min.js.map +3 -3
- package/dist/esm/unpack.d.ts +8 -0
- package/dist/esm/unpack.d.ts.map +1 -1
- package/dist/esm/unpack.js +38 -14
- package/dist/esm/unpack.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var Ti=Object.defineProperty;var Oi=(i,e)=>{for(var t in e)Ti(i,t,{get:e[t],enumerable:!0})};import*as
|
|
2
|
-
`,r=A(n),o=Math.floor(Math.log(r)/Math.log(10))+1;return r+o>=Math.pow(10,o)&&(o+=1),o+r+n}static parse(e,t,s=!1){return i.parseBytes(new TextEncoder().encode(e),t,s)}static parseBytes(e,t,s=!1){return new i(Vi(qi(e),t),s)}},Vi=(i,e)=>e?Object.assign({},e,i):i,qi=i=>{let e=Object.create(null),t=0;for(;t<i.length;){let s=t;for(;s<i.length&&i[s]>=48&&i[s]<=57;)s++;if(s===t||i[s]!==32)break;let n=Number(U(i,t,s)),r=t+n;if(r<=s+1||r>i.length||i[r-1]!==10)break;Ki(e,U(i,s+1,r-1)),t=r}return e},Ki=(i,e)=>{let t=e.split("="),s=t.shift();if(!s)return i;let n=s.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),r=t.join("="),o=r.indexOf("\0"),a=o===-1?r:r.slice(0,o);switch(n){case"path":case"linkpath":case"type":case"charset":case"comment":case"gname":case"uname":i[n]=a;break;case"ctime":case"atime":case"mtime":let c=new Date(Number(a)*1e3);isNaN(c.getTime())||(i[n]=c);break;case"size":case"gid":case"uid":case"dev":case"ino":case"nlink":case"mode":if(!Yi.test(a.trim()))break;let h=+a;if(!Number.isSafeInteger(h))break;i[n]=h;break}return i};var T={name:"gzip",headLength:2,detect:i=>i[0]===31&&i[1]===139,decompress:()=>new DecompressionStream("gzip"),compress:i=>{let e=new CompressionStream("gzip");if(!i?.portable)return e;let t=0;return{writable:e.writable,readable:e.readable.pipeThrough(new TransformStream({transform:(s,n)=>{t<=9&&t+s.length>9&&(s[9-t]=255),t+=s.length,n.enqueue(s)}}))}}};var Ot={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:"onEntry",onReadEntry:"onEntry"},y=i=>{let e=Object.assign(Object.create(null),i);for(let[t,s]of Object.entries(Ot))e[t]!==void 0&&(e[s]??=e[t]),delete e[t];return e.noChmod===!1&&(e.chmod??=!0),delete e.noChmod,e};var P=i=>{if(i.length===1)return i[0].slice();let e=0;for(let n of i)e+=n.length;let t=new Uint8Array(e),s=0;for(let n of i)t.set(n,s),s+=n.length;return t};var k=(i,e)=>Object.assign(Object.create(null),i,e),V=(i,e,t)=>{if(e==null||e===0)return t;if(e===1/0||Number.isInteger(e)&&Number(e)>0)return e;throw new TypeError(`${i} must be a positive integer`)};var Xi=new Set(["File","OldFile","Link","SymbolicLink","CharacterDevice","BlockDevice","Directory","FIFO","ContiguousFile","GNUDumpDir"]),Ne=i=>i.replaceAll("\\","/"),q=class{header;extended;globalExtended;type;path;mode;uid;gid;uname;gname;size;mtime;atime;ctime;linkpath;devmaj;devmin;dev;ino;nlink;absolute;ignore;invalid=!1;unsupported=!1;constructor(e,t,s,n=!1){if(!e.path)throw new Error("no path provided for tar.ReadEntry");this.header=e,this.extended=t,this.globalExtended=s,this.type=e.type,this.ignore=!Xi.has(this.type),this.path=n?Ne(e.path):e.path,this.mode=e.mode&&e.mode&4095,this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=e.size??0,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?n?Ne(e.linkpath):e.linkpath:void 0,this.devmaj=e.devmaj,this.devmin=e.devmin,s&&this.#e(s),t&&(this.#e(t),t.path!=null&&(this.path=n?Ne(t.path):t.path),t.linkpath!=null&&(this.linkpath=n?Ne(t.linkpath):t.linkpath))}#e(e){e.uid!=null&&(this.uid=e.uid),e.gid!=null&&(this.gid=e.gid),e.uname!=null&&(this.uname=e.uname),e.gname!=null&&(this.gname=e.gname),e.mtime!=null&&(this.mtime=e.mtime),e.atime!=null&&(this.atime=e.atime),e.ctime!=null&&(this.ctime=e.ctime),e.dev!=null&&(this.dev=e.dev),e.ino!=null&&(this.ino=e.ino),e.nlink!=null&&(this.nlink=e.nlink)}},zt=new TextDecoder,Pt=i=>{let e="";for(let t of i)e+=zt.decode(t,{stream:!0});return e+zt.decode()},Ft=()=>new TypeError("Body has already been consumed"),pe=class extends q{#e;#t=!1;#i;constructor(e,t,s,n,r){super(e,t,s,n),this.#e=r}get bodyUsed(){return this.#t}get body(){if(this.#i)return this.#i;let e=!1;return this.#i=new ReadableStream({pull:async t=>{e||(this.#s(),e=!0);let[s]=await this.#n(1);s?t.enqueue(s):t.close()}},{highWaterMark:0})}#s(){if(this.#t)throw Ft();this.#t=!0}#r(e,t=1/0){let s=this.#e;for(;s&&e.length<t;){let n=s.readBody(this);if(n===null)break;if(n===void 0)return!1;e.push(n)}return!0}async#n(e){let t=[];for(;!this.#r(t,e);)await this.#e?.fill();return t}async bytes(){this.#s();let e=[];for(;!this.#r(e);)await this.#e?.fill();return P(e)}async arrayBuffer(){return(await this.bytes()).buffer}async text(){return this.#s(),Pt(await this.#n())}async blob(){return this.#s(),new Blob(await this.#n())}},ue=class extends q{#e;#t=!1;#i;constructor(e,t,s,n,r){super(e,t,s,n),this.#e=r}get bodyUsed(){return this.#t}get body(){return this.#i??=this.#s()}*#s(){this.#r();for(let e;e=this.#e?.readBody(this);)yield e}#r(){if(this.#t)throw Ft();this.#t=!0}#n(){this.#r();let e=[];for(let t;t=this.#e?.readBody(this);)e.push(t);return e}bytes(){return P(this.#n())}arrayBuffer(){return this.bytes().buffer}text(){return Pt(this.#n())}};var Nt=(i,e,t,s)=>(i.file&&(s.file=i.file),s.code=typeof t=="object"&&t.code||e,s.tarCode=e,s),at=(i,e,t,s={})=>Object.assign(typeof t=="object"?t:new Error(`${e}: ${t}`),Nt(i,e,t,s)),S=(i,e,t,s={})=>{let n=Object.hasOwn(s,"recoverable")&&s.recoverable===!1;if(i.strict||n)throw at(i,e,t,s);Nt(i,e,t,s),typeof t=="object"&&(s=Object.assign(t,s),t=t.message),i.onwarn?.(e,t,s)};var Ut=0,ie=1,Ue=2,Ce=3,Ct=4,ct={type:"entryEnd"},Zi={type:"end"},Ji=new Set(["ExtendedHeader","OldExtendedHeader","GlobalExtendedHeader","NextFileHasLongPath","OldGnuLongPath","NextFileHasLongLinkpath"]),Lt=i=>{let e=i.indexOf(0);return U(i,0,e===-1?i.length:e)},I=class{maxMetaEntrySize;position=0;offset=0;#e;#t;#i;#s=[];#r;#n=0;#o;#a=0;#c=Ut;#h;#d;#w;#y=0;#p=0;#l=0;#u;#g;#b;#x;#k=!1;#m;#f=!1;#S=0;constructor(e={},t){e=this.#e=k(e),this.maxMetaEntrySize=e.maxMetaEntrySize||1024*1024,this.#t=e.filter;let s=e.platform==="win32";this.#i=t??((n,r,o)=>new q(n,r,o,s))}warn(e,t,s){S(this.#e,e,t,s)}push(e){this.#k||this.#s.push(e)}end(){this.#k=!0}get bodyRemain(){let e=this.#r,t=this.#c;return t!==Ue&&t!==Ce||this.#s.length||e&&this.#n<e.length?0:this.#l}skipBody(){this.#f=this.#c===Ue,this.offset+=this.#l,this.#p=this.#l=0,this.#E()}next(){if(this.#f)return this.#f=!1,ct;for(;;){let e=this.#r,t=this.#n;if(!e||t===e.length){if(e=this.#r=this.#s.shift(),t=this.#n=0,!e){if(!this.#k||this.#S===2)return;let l=this.#R();if(l)return l}continue}let s=e.length-t,n=this.#c;if(n<=ie){let l;if(this.#a===0&&s>=512)this.#n=t+512,l=this.#v(e,t);else{let d=this.#o??=new Uint8Array(512),f=Math.min(512-this.#a,s);if(d.set(e.subarray(t,t+f),this.#a),this.#n=t+f,this.#a+=f,this.#a<512)continue;this.#a=0,l=this.#v(d,0)}if(l)return l;continue}let r=this.#l,o=s<r?s:r,a=this.#p,c=o<a?o:a;this.#n=t+o,this.offset+=o,this.#l=r-o,this.#p=a-c;let h=o===r;if(n===Ct){let l=this.#w;l.set(e.subarray(t,t+c),this.#y),this.#y+=c,h&&(this.#E(),this.#A(l));continue}if(h&&this.#E(),n!==Ce){if(c===0){if(h)return ct;continue}return this.#f=h,{type:"body",data:c===e.length?e:e.subarray(t,t+c)}}}}#E(){let e=this.#h;e&&(this.position=this.offset,this.#h=void 0),e?.invalid||(this.#m=!0),this.#c=ie}#R(){let e=this.#c;if(e>ie){let t=this.#h,s=(512-this.#l%512)%512,n=this.#l+s;this.#h=void 0,this.#w=void 0,this.#c=ie,t?.invalid||(this.#m=!0),this.#f=e===Ue,this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${n} more bytes, only ${s} available)`,{entry:t,header:this.#d});return}return this.#f?(this.#f=!1,ct):(this.#S===0&&(this.#S=1,(e===Ut||this.#m===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")),this.#S=2,Zi)}#v(e,t){this.offset+=512,this.#m===void 0&&(this.#m=!1);let s=this.#u,n=this.#g,r=this.#b;(n!==void 0||r!==void 0)&&(s=Object.assign(Object.create(null),s),s.path??=n,s.linkpath??=r);let o;try{o=new R(e,t,s,this.#x)}catch(d){this.warn("TAR_ENTRY_INVALID",d);return}if(o.nullBlock){this.#k=!0,this.#r=void 0,this.#s.length=0,this.#a=0,this.#c=ie;return}if(!o.cksumValid){this.warn("TAR_ENTRY_INVALID","checksum failure",{header:o});return}if(!o.path){this.warn("TAR_ENTRY_INVALID","path is required",{header:o});return}let a=o.type,c=a==="Link"||a==="SymbolicLink";if(c&&!o.linkpath){this.warn("TAR_ENTRY_INVALID","linkpath required",{header:o});return}if(!c&&o.linkpath&&a!=="ExtendedHeader"&&a!=="GlobalExtendedHeader"){this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:o});return}let h=o.size??0;if(this.#d=o,this.#p=h,this.#l=512*Math.ceil(h/512),h||(this.#m=!0),Ji.has(a)){h>this.maxMetaEntrySize?this.#c=Ce:h>0&&(this.#w=new Uint8Array(h),this.#y=0,this.#c=Ct);return}this.#u=this.#g=this.#b=void 0;let l=this.#i(o,s,this.#x);return!l.ignore&&this.#t&&!this.#t(l.path,l)&&(l.ignore=!0),h?(this.#h=l,this.#c=l.ignore?Ce:Ue):(this.#c=ie,this.position=this.offset,this.#f=!l.ignore),{type:"entry",entry:l}}#A(e){switch(this.#d.type){case"ExtendedHeader":case"OldExtendedHeader":this.#u=M.parseBytes(e,this.#u,!1);break;case"GlobalExtendedHeader":this.#x=M.parseBytes(e,this.#x,!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":this.#g=Lt(e);break;default:this.#b=Lt(e)}}};var Qi=16*1024*1024,Dt=64*1024,es=1024*1024,De=Symbol.for("tar.readFile.skip"),Le=class{pos=0;size=0;#e;#t=Dt;constructor(e){this.#e=V("maxReadSize",e,Qi)}next(){let e=Math.min(this.#t,this.#e,this.size-this.pos);return this.#t*=2,e}skip(e){return e<es||this.pos+e>this.size?!1:(this.pos+=e,this.#t=Dt,!0)}};async function*ts(i,e,t){let s=await i.open(e,"r");try{t.size=(await s.stat()).size;for(let n;n=t.next();){let r=new Uint8Array(n),{bytesRead:o}=await s.read(r,0,n,t.pos);if(!o)break;t.pos+=o,yield o<n?r.subarray(0,o):r}}finally{await s.close().catch(()=>{})}}function*is(i,e,t){let s=i.openSync(e,"r");try{t.size=i.fstatSync(s).size;for(let n;n=t.next();){let r=new Uint8Array(n),o=i.readSync(s,r,0,n,t.pos);if(!o)break;t.pos+=o,yield o<n?r.subarray(0,o):r}}finally{try{i.closeSync(s)}catch{}}}var B=(i,e,t)=>{let s=new Le(t);return Object.assign(ts(i,e,s),{[De]:n=>s.skip(n)})},H=(i,e,t)=>{let s=new Le(t);return Object.assign(is(i,e,s),{[De]:n=>s.skip(n)})};var ht=()=>{},we=i=>Math.max(512,...i.map(e=>e.headLength)),ss=i=>{try{let e=new R(i);return e.cksumValid||e.nullBlock}catch{return!1}},ye=(i,e,t="")=>i.find(s=>s.detect(e))??(ss(e)?void 0:i.find(s=>s.extensions?.some(n=>t.endsWith(n)))),_t=i=>typeof i.maxDecompressionRatio=="number"?i.maxDecompressionRatio:1e3,_e=(i,e)=>at(i,"TAR_ABORT",e,{recoverable:!1}),Mt=(i,e,t)=>_e(i,new Error(`max decompression ratio exceeded: ${e.toFixed(2)} > ${t}`)),ns=()=>new TypeError("The body of an entry cannot be read after a later entry"),me=class{parser;current;ended=!1;constructor(e){this.parser=e}entry(){if(this.current=void 0,this.ended)return null;for(let e;e=this.parser.next();){if(e.type==="end")return this.ended=!0,null;if(e.type==="entry"&&!e.entry.ignore)return this.current=e.entry}}body(e){if(e!==this.current)throw ns();let t=this.parser.next();if(t)return t.type==="body"?t.data:(this.current=void 0,null)}},It=(i,e)=>{if(i.current)return;let t=i.parser.bodyRemain;t&&e[De]?.(t)&&i.parser.skipBody()},rs=i=>{if(v(i))return[i].values();if(tt(i))return[new Uint8Array(i)].values();if(N(i)&&(i=i.stream()),ze(i)){let e=i.getReader();return{next:()=>e.read(),return:()=>e.cancel()}}return Symbol.asyncIterator in i?i[Symbol.asyncIterator]():i[Symbol.iterator]()},b=class{parser;#e;#t;#i;#s;#r;#n;#o=!1;constructor(e,t={}){t=k(t);let s=t.platform==="win32";this.parser=new I(t,(n,r,o)=>new pe(n,r,o,s,this)),this.#e=new me(this.parser),this.#t=t,this.#i=rs(e)}poll(){return this.#o?null:this.#e.entry()}readBody(e){return this.#e.body(e)}fill(){return this.#n??=this.#a()}async#a(){try{let e=this.#s??=await this.#c(this.#i),t=this.#r;this.#r=void 0,e===this.#i&&It(this.#e,e);let s=t?{value:t,done:!1}:await e.next();s.done?this.parser.end():this.parser.push(s.value)}finally{this.#n=void 0}}async#c(e){let t=this.#t,s=[...t.codecs??[],T],n=we(s),r;for(;!r||r.length<n;){let m=await e.next();if(m.done)break;r=r?P([r,m.value]):m.value}let o=r&&ye(s,r,t.file);if(!o)return this.#r=r,e;let a=0,c=0,{readable:h,writable:l}=o.decompress(),d=l.getWriter(),f=h.getReader(),p=!1;(async()=>{try{for(;;){if(await d.ready,p)return;let m=r?{value:r,done:!1}:await e.next();if(r=void 0,p)return;if(m.done)return await d.close();a+=m.value.length,await d.write(m.value)}}catch(m){p||await d.abort(m).catch(ht)}})();let u=_t(t);return{next:async()=>{let m=await f.read().catch(g=>{throw _e(t,g)});if(!m.done){c+=m.value.length;let g=c/a;if(g>u)throw Mt(t,g,u)}return m},return:async()=>(p=!0,await f.cancel().catch(ht),await d.abort().catch(ht),await e.return?.(),{value:void 0,done:!0})}}async next(){try{for(;;){let e=this.poll();if(e)return{value:e,done:!1};if(e===null)break;await this.fill()}}catch(e){throw await this.return(),e}return this.return()}async return(){return this.#o||(this.#o=!0,this.#e.current=void 0,await(this.#s??this.#i).return?.()),{value:void 0,done:!0}}[Symbol.asyncIterator](){return this}},E=class{parser;#e;#t;#i;#s;#r;#n=!1;constructor(e,t={}){t=k(t);let s=t.platform==="win32";this.parser=new I(t,(n,r,o)=>new ue(n,r,o,s,this)),this.#e=new me(this.parser),this.#t=t,this.#i=v(e)?[e].values():tt(e)?[new Uint8Array(e)].values():e[Symbol.iterator]()}readBody(e){for(;;){let t=this.#e.body(e);if(t!==void 0)return t;this.#o()}}#o(){let e=this.#s??=this.#a(this.#i),t=this.#r;this.#r=void 0,e===this.#i&&It(this.#e,e);let s=t?{value:t,done:!1}:e.next();s.done?this.parser.end():this.parser.push(s.value)}#a(e){let t=this.#t,s=[...t.codecs??[],T],n=we(s),r,o;for(;(!r||r.length<n)&&!(o=e.next()).done;)r=r?P([r,o.value]):o.value;let a=r&&ye(s,r,t.file);if(!r||!a)return this.#r=r,e;let{decompressSync:c}=a;if(!c)throw _e(t,new Error(`the ${a.name} codec has no decompressSync function`));let h=[r];for(;!(o=e.next()).done;)h.push(o.value);let l=P(h),d=_t(t),f;try{f=c(l,{maxOutputLength:l.length*d})}catch(w){throw _e(t,w)}let p=f.length/l.length;if(p>d)throw Mt(t,p,d);return[f].values()}next(){try{for(;;){let e=this.#n?null:this.#e.entry();if(e)return{value:e,done:!1};if(e===null)break;this.#o()}}catch(e){throw this.return(),e}return this.return()}return(){return this.#n||(this.#n=!0,this.#e.current=void 0,(this.#s??this.#i).return?.()),{value:void 0,done:!0}}[Symbol.iterator](){return this}},lt=(i,e)=>new b(i,e),Bt=(i,e)=>new E(i,e);var Ht=(i,e,t)=>(i&=4095,t&&(i=(i|384)&-19),e&&(i&256&&(i|=64),i&32&&(i|=8),i&4&&(i|=1)),i);var Me=["|","<",">","?",":"],dt=Me.map(i=>String.fromCodePoint(61440+Number(i.codePointAt(0)))),os=new Map(Me.map((i,e)=>[i,dt[e]])),as=new Map(dt.map((i,e)=>[i,Me[e]])),ft=i=>Me.reduce((e,t)=>e.split(t).join(os.get(t)),i),$t=i=>dt.reduce((e,t)=>e.split(t).join(as.get(t)),i);var K=i=>i===47||i===92,cs=i=>i>=65&&i<=90||i>=97&&i<=122,$=i=>{let e=i.length,t=0;if(K(i.charCodeAt(0))){if(t=1,K(i.charCodeAt(1))){let s=2,n=s;for(;s<e&&!K(i.charCodeAt(s));)s++;if(s<e&&s!==n){for(n=s;s<e&&K(i.charCodeAt(s));)s++;if(s<e&&s!==n){for(n=s;s<e&&!K(i.charCodeAt(s));)s++;s===e?t=s:s!==n&&(t=s+1)}}}}else cs(i.charCodeAt(0))&&i.charCodeAt(1)===58&&(t=K(i.charCodeAt(2))?3:2);return i.slice(0,t)},ge=i=>K(i.charCodeAt(0))||$(i).length===3,Ie=(i,e)=>{let t=ge(e)?e:i+"/"+e,s=$(t);return s+C("/",t.slice(s.length)).slice(1)},Gt=i=>{let e=$(i),t=z(i.slice(e.length));return t==="."?e:e+t};var Be=i=>{let e="";for(let t;t=$(i);)i.charAt(0)==="/"&&i.slice(0,4)!=="//?/"&&(t="/"),i=i.slice(t.length),e+=t;return[e,i]};var He=i=>new ReadableStream({pull:async e=>{let t=await i.next();t.done?e.close():e.enqueue(t.value)},cancel:async()=>{await i.return?.()}},{highWaterMark:0});var X=i=>{let e=i.length-1,t=-1;for(;e>-1&&i.charAt(e)==="/";)t=e,e--;return t===-1?i:i.slice(0,t)};var hs=new TextEncoder,Wt=(i,e)=>e?X(e)+"/"+i.replace(/^\.(\/|$)/,""):i,se=class{path;type;mode;uid;gid;uname;gname;size;mtime;atime;ctime;linkpath;dev;ino;nlink;body;absolute;header;constructor(e,t){if(e.type==="Unsupported")throw new Error("writing entry that should be ignored");if(typeof t=="string"&&(t=hs.encode(t)),this.path=e.path,this.type=e.type??"File",this.mode=e.mode,this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,e.size===void 0&&t!==void 0&&!v(t)&&!N(t))throw new TypeError("a stream body needs the size option");this.size=e.size??(v(t)?t.length:N(t)?t.size:0),this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath,this.dev=e.dev,this.ino=e.ino,this.nlink=e.nlink,this.body=t}encode(e={},t=new Uint8Array(512)){e=k(e);let s=Wt(this.path,e.prefix),n=this.type==="Link"&&this.linkpath!==void 0?Wt(this.linkpath,e.prefix):this.linkpath,{uid:r,gid:o,uname:a,gname:c,size:h,mtime:l,atime:d,ctime:f}=this;if(this.header=new R({path:s,linkpath:n,mode:this.mode,uid:r,gid:o,size:h,mtime:l,type:this.type,uname:a,gname:c,atime:d,ctime:f}),!this.header.encode(t)||e.noPax)return[t];let{dev:p,ino:w,nlink:u}=this;return[new M({atime:d,ctime:f,gid:o,gname:c,mtime:l,path:s,linkpath:n,size:h,uid:r,uname:a,dev:p,ino:w,nlink:u}).encode(),t]}};var ls=16*1024*1024,O=()=>{},xe=i=>512*Math.ceil(i/512),Z=i=>i.replaceAll("\\","/"),pt=i=>`${i.dev}:${i.ino}`,$e={bigint:!0},ds=({dev:i,ino:e})=>!Number.isSafeInteger(i)||!Number.isSafeInteger(e),je=(i,e)=>i.dev===e.dev&&i.ino===e.ino,ut=(i,e)=>Object.assign(new Error(i),{path:e,syscall:"read",code:"EOF"}),Xt=(i,e)=>ut(`encountered unexpected EOF: ${i} has fewer than the ${e} bytes of its stat`,i),Zt=(i,e)=>ut(`did not encounter expected EOF: ${i} has more than the ${e} bytes of its stat`,i),Jt=i=>i.absolute??i.path,fs=i=>Object.assign(new Error("writing more data than expected"),{path:Jt(i)}),Qt=i=>Symbol.asyncIterator in i||Symbol.iterator in i,ps=i=>typeof i.encode=="function",F=class{path;absolute;up;linkpath;ready;constructor(e,t){this.path=e,this.absolute=t}},ke=class{opt;fs;cwd;win32;maxReadSize;header;codec;codecOptions;ended=!1;head;tail;wake;#e=new Map;constructor(e,t){e=this.opt=k(e),this.fs=e.fs,this.win32=e.platform==="win32",this.maxReadSize=V("maxReadSize",e.maxReadSize,ls);let{prefix:s,noPax:n}=e;this.header={prefix:s&&this.win32?Z(s):s,noPax:n};let r=e.cwd&&(this.win32?Z(e.cwd):e.cwd);if(r&&!(this.win32?ge:te)(r))throw new TypeError("cwd must be an absolute path");this.cwd=r&&this.#t(r,"");let o=e,a=["gzip","brotli","zstd","compress"].filter(h=>o[h]);if(a.length>1)throw new TypeError(`${a.join(", ")} are mutually exclusive`);let[c]=a;if(c){let h=e.compress,[l,d]=h?Array.isArray(h)?h:[h]:[[...e.codecs??[],T].find(f=>f.name===c),o[c]];if(!l?.[t])throw new TypeError(`no codec named ${l?.name??c} has a ${t} function`);this.codec=l,this.codecOptions={...typeof d=="object"?d:void 0,...l.name==="gzip"&&e.portable?{portable:!0}:void 0}}}#t(e,t){return this.win32?Ie(e,t):C(e,t)}resolve(e){if(!this.cwd||!this.fs)throw new TypeError("a path needs the cwd and fs options");return this.#t(this.cwd,this.win32?Z(e):e)}add(e){if(this.ended)throw new Error("write after end");if(typeof e!="string")this.push(e);else{let t=this.win32?Z(e):e;this.push(new F(t||"./",this.resolve(t)))}return this}end(){return this.ended=!0,this.wake?.(),this}push(e){let t={item:e};this.tail?this.tail.next=t:this.head=t,this.tail=t,this.wake?.()}shift(){this.head=this.head?.next,this.head||(this.tail=void 0)}needsExact(e){return ds(e)&&(e.isDirectory()?!!this.opt.follow:e.isFile()&&e.nlink>1)}plan(e,t,s){let{filter:n}=this.opt;if(!(n&&!n(e.path,t))){if(t.isDirectory()){for(let r=e.up;r;r=r.up)if(r.key===pt(s)){S(this.opt,"TAR_ENTRY_ERROR","directory is its own ancestor",{path:e.path,absolute:e.absolute});return}return"Directory"}if(t.isSymbolicLink())return"SymbolicLink";if(!t.isFile()){S(this.opt,"TAR_ENTRY_UNSUPPORTED","unsupported file type",{path:e.path,absolute:e.absolute});return}if(t.nlink>1){let r=pt(s),o=this.#e.get(r),a=this.cwd;if(o!==e.absolute&&o?.startsWith(a.endsWith("/")?a:a+"/"))return e.linkpath=W(a,o),"Link";this.#e.set(r,e.absolute)}return"File"}}children(e,t,s){let n=e.path==="./"?"":e.path.replace(/\/*$/,"/"),r=e.absolute.endsWith("/")?e.absolute:e.absolute+"/",o=this.opt.follow?{key:pt(s),up:e.up}:void 0;return[...t].sort().map(a=>{let c=new F(n+a,r+a);return c.up=o,c})}missing(e,t){if(t?.code!=="ENOENT")throw t;S(this.opt,"TAR_ENTRY_ERROR",t,{path:e.path,absolute:e.absolute})}changed(e,t){S(this.opt,"TAR_ENTRY_ERROR",t==="Directory"?"directory changed between lstat and readdir":"file changed between lstat and open",{path:e.path,absolute:e.absolute})}pathEntry(e,t,s,n,r){let{processUid:o,processUname:a=""}=this.opt,c=new se({path:e.path,type:s,mode:t.mode,uid:t.uid,gid:t.gid,uname:t.uid===o?a:"",size:s==="File"?t.size:0,mtime:t.mtime,atime:t.atime,ctime:t.ctime,linkpath:n&&this.win32?Z(n):n,dev:t.dev,ino:t.ino,nlink:t.nlink},r);return c.absolute=e.absolute,this.#i(c,!0)}addedEntry(e){if(ps(e))return this.#i(e,!1);let{filter:t}=this.opt;if(!(t&&!t(e.path,e)))return this.#i(new se(e,e.body),!1)}#i(e,t){let{opt:s,win32:n}=this,r=e.type==="Directory";n&&!t&&(e.path=Z(e.path),e.linkpath&&(e.linkpath=Z(e.linkpath)));let[o,a]=s.preservePaths?["",e.path]:Be(e.path);return e.path=a,t&&(n&&(e.path=$t(e.path)),e.path===""&&(e.path="./")),o&&S(s,"TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:e,path:o+e.path}),t&&r&&!e.path.endsWith("/")&&(e.path+="/"),s.portable&&(e.uid=e.gid=e.dev=e.ino=e.nlink=void 0,e.uname=e.gname=void 0,e.atime=e.ctime=void 0),e.mode!==void 0&&(e.mode=Ht(e.mode,r,!!s.portable)),e.mtime=s.noMtime||s.portable&&r?void 0:s.mtime||e.mtime,e}},Yt=async(i,e,t,s,n,r)=>{for(;t<e.length&&s<n;){let{bytesRead:o}=await i.read(e,t,e.length-t,s);if(o<=0)throw Xt(r,n);if(o>n-s)throw Zt(r,n);t+=o,s+=o}return s},Vt=(i,e,t,s,n,r,o)=>{for(;s<t.length&&n<r;){let a=i.readSync(e,t,s,t.length-s,n);if(a<=0)throw Xt(o,r);if(a>r-n)throw Zt(o,r);s+=a,n+=a}return n};async function*us(i){if(v(i))yield i;else if(N(i)||ze(i)){let e=(N(i)?i.stream():i).getReader();try{for(;;){let t=await e.read();if(t.done)break;yield t.value}}finally{await e.cancel().catch(O)}}else i&&(yield*i)}function*ms(i){if(v(i))yield i;else if(i&&Symbol.iterator in i)yield*i;else if(i)throw new TypeError("PackSync needs a body that is a string, a Uint8Array, or an iterable")}var ei=(i,e,t)=>{if(t.length>e)throw fs(i);return e-t.length},ti=(i,e)=>{if(e)throw ut("encountered unexpected EOF",Jt(i));return new Uint8Array(xe(i.size)-i.size)};async function*qt(i){if(!i.size)return;let e=i.size;for await(let s of us(i.body))e=ei(i,e,s),yield s;let t=ti(i,e);t.length&&(yield t)}function*Kt(i){if(!i.size)return;let e=i.size;for(let s of ms(i.body))e=ei(i,e,s),yield s;let t=ti(i,e);t.length&&(yield t)}var Se=class extends ke{jobs;#e;#t=Promise.resolve();constructor(e={}){super(e,"compress"),this.jobs=V("jobs",this.opt.jobs,4)}async next(){let e=await(this.#e??=this.#i()).next();return e.done?{value:void 0,done:!0}:e}async return(){return this.end(),await this.#e?.return(),{value:void 0,done:!0}}[Symbol.asyncIterator](){return this}#i(){let{codec:e}=this;return e?.compress?this.#s(e.compress(this.codecOptions)):this.#r()}async*#s(e){let t=this.#r(),s,n=He({next:()=>t.next().catch(r=>{throw s={er:r},n.cancel().catch(O),r})}).pipeThrough(e).getReader();try{for(;;){let r=await n.read();if(s)throw s.er;if(r.done)break;yield r.value}}finally{await n.cancel().catch(O),await t.return()}}async*#r(){try{for(;;){let e=this.head;if(!e){if(this.ended)break;await new Promise(s=>this.wake=s);continue}this.#n();let{item:t}=e;if(t instanceof F)yield*this.#c(t);else if(!Qt(t))yield*this.#d(t);else for await(let s of t)yield*this.#d(s);this.shift()}yield new Uint8Array(1024)}finally{for(let e=this.head;e;e=e.next){let{item:t}=e;if(!(t instanceof F)||!t.ready)break;await(await t.ready.catch(O))?.handle?.close().catch(O)}}}#n(){let e=this.fs,t=this.head;for(let s=0;t&&s<this.jobs;s++,t=t.next){let n=t.item;if(!(n instanceof F))break;if(n.ready)continue;let r=this.#o(e,n.absolute);r.catch(O);let o=this.#t.then(()=>r).then(([a,c])=>{let h=this.plan(n,a,c);return h&&{load:this.#a(e,n,a,c,h)}},a=>this.missing(n,a));this.#t=o.catch(O),n.ready=o.then(a=>a?.load),n.ready.catch(O)}}async#o(e,t){let{follow:s}=this.opt,n=await(s?e.stat(t):e.lstat(t)),r=this.needsExact(n)?await(s?e.stat(t,$e):e.lstat(t,$e)):n;return[n,r]}async#a(e,t,s,n,r){let{absolute:o}=t,{follow:a,noDirRecurse:c}=this.opt,h={stat:s,id:n,type:r};if(r==="SymbolicLink")h.linkpath=await e.readlink(o);else if(r==="Directory"&&!c)h.names=await e.readdir(o),h.changed=!a&&!je(s,await e.lstat(o));else if(r==="File"&&s.size){let l=await e.open(o,"r");try{let{size:d}=s,f=xe(d);!a&&!je(s,await l.stat())?h.changed=!0:f>this.maxReadSize?h.handle=l:(h.buf=new Uint8Array(512+f),await Yt(l,h.buf,512,0,d,o))}catch(d){throw await l.close().catch(O),d}h.handle||await l.close()}return h}async*#c(e){let t=await e.ready;if(!t)return;let{stat:s,id:n,type:r,names:o,buf:a,handle:c}=t;if(t.changed)return this.changed(e,r);let h=!1;try{let l=a?a.subarray(512,512+s.size):c&&this.#h(c,s.size,e.absolute),d=this.pathEntry(e,s,r,t.linkpath??e.linkpath,l);if(o)for(let p of this.children(e,o,n))this.push(p);await this.opt.onWriteEntry?.(d);let f=a&&d.body===l&&d.size===s.size;yield*d.encode(this.header,f?a:void 0),f||(yield*qt(d)),h=!0}finally{if(c){t.handle=void 0;let l=c.close();await(h?l:l.catch(O))}}}async*#h(e,t,s){let n=xe(t);for(let r=0;r<t;){let o=new Uint8Array(Math.min(n-r,this.maxReadSize)),a=await Yt(e,o,0,r,t,s);yield o.subarray(0,a-r),r=a}}async*#d(e){let t=this.addedEntry(e);t&&(await this.opt.onWriteEntry?.(t),yield*t.encode(this.header),yield*qt(t))}},be=class extends ke{#e;constructor(e={}){super(e,"compressSync")}next(){let e=(this.#e??=this.#t()).next();return e.done?{value:void 0,done:!0}:e}return(){return this.ended=!0,this.#e?.return(),{value:void 0,done:!0}}[Symbol.iterator](){return this}*#t(){let{codec:e}=this;if(!e?.compressSync)return yield*this.#i();yield e.compressSync(P([...this.#i()]),this.codecOptions)}*#i(){for(let e;e=this.head;this.shift()){let{item:t}=e;if(t instanceof F){let s=[t];for(let n of s)yield*this.#s(n,s)}else if(!Qt(t))yield*this.#n(t);else for(let s of t)yield*this.#n(s)}this.ended=!0,yield new Uint8Array(1024)}*#s(e,t){let s=this.fs,{absolute:n}=e,{follow:r,noDirRecurse:o}=this.opt,a;try{a=r?s.statSync(n):s.lstatSync(n)}catch(u){return this.missing(e,u)}let c=this.needsExact(a)?r?s.statSync(n,$e):s.lstatSync(n,$e):a,h=this.plan(e,a,c);if(!h)return;let{linkpath:l}=e,d,f,p,w=!1;try{if(h==="SymbolicLink")l=s.readlinkSync(n);else if(h==="Directory"&&!o){let g=s.readdirSync(n);if(!r&&!je(a,s.lstatSync(n)))return this.changed(e,h);t.push(...this.children(e,g,c))}else if(h==="File"&&a.size){let{size:g}=a,Et=xe(g);if(p=s.openSync(n,"r"),!r&&!je(a,s.fstatSync(p)))return this.changed(e,h);Et>this.maxReadSize?f=this.#r(s,p,g,n):(d=new Uint8Array(512+Et),Vt(s,p,d,512,0,g,n),f=d.subarray(512,512+g))}let u=this.pathEntry(e,a,h,l,f);this.opt.onWriteEntry?.(u);let m=d&&u.body===f&&u.size===a.size;yield*u.encode(this.header,m?d:void 0),m||(yield*Kt(u)),w=!0}finally{if(p!==void 0&&!w)try{s.closeSync(p)}catch{}}p!==void 0&&s.closeSync(p)}*#r(e,t,s,n){let r=xe(s);for(let o=0;o<s;){let a=new Uint8Array(Math.min(r-o,this.maxReadSize)),c=Vt(e,t,a,0,o,s,n);yield a.subarray(0,c-o),o=c}}*#n(e){let t=this.addedEntry(e);t&&(this.opt.onWriteEntry?.(t),yield*t.encode(this.header),yield*Kt(t))}};var Ee=64*1024,Ge=4*Ee,ws=()=>{},mt=(i,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive");if(i.file&&!i.fs)throw new TypeError("the file option needs the fs option")},ii=async(i,e,t,s)=>{for(let n=0;n<t;)n+=(await i.write(e,n,t-n,s+n)).bytesWritten},wt=async(i,e,t)=>{let s=new Uint8Array(Ge),n=0,r=async()=>{await ii(i,s,n,t),t+=n,n=0};for await(let o of e)(n+o.length>Ge||o.length>=Ee)&&await r(),o.length>=Ee?(await ii(i,o,o.length,t),t+=o.length):(s.set(o,n),n+=o.length);await r()},yt=(i,e,t,s)=>{let n=new Uint8Array(Ge),r=0,o=(a,c)=>{for(let h=0;h<c;)h+=i.writeSync(e,a,h,c-h,s+h);s+=c};for(let a of t)(r+a.length>Ge||a.length>=Ee)&&(o(n,r),r=0),a.length>=Ee?o(a,a.length):(n.set(a,r),r+=a.length);o(n,r)},ys=async(i,e,t,s)=>{let n=await e.open(t,"w",s),r=!1;try{await wt(n,i,0),r=!0}finally{let o=n.close();await(r?o:o.catch(ws))}},We=(i,e)=>{let{fs:t,strict:s,onwarn:n,codecs:r,platform:o}=i,a=new Se(i);for(let c of e)if(typeof c!="string"||c.charAt(0)!=="@")a.add(c);else{let h=a.resolve(c.slice(1));a.add(new b(B(t,h,i.maxReadSize),{strict:s,onwarn:n,codecs:r,platform:o,file:h}))}return a.end()},gt=(i,e)=>{let{strict:t,onwarn:s,codecs:n,platform:r}=i,o=new be(i);for(let a of e)if(typeof a!="string"||a.charAt(0)!=="@")o.add(a);else{let c=o.resolve(a.slice(1));o.add(new E(H(i.fs,c,i.maxReadSize),{strict:t,onwarn:s,codecs:n,platform:r,file:c}))}return o};function ne(i,e){let t=y(i);if(!t.file)return mt(t,e),He(We(t,e));try{return mt(t,e),ys(We(t,e),t.fs,t.file,t.mode||438)}catch(s){return Promise.reject(s)}}function Ye(i,e){let t=y(i);mt(t,e);let{file:s}=t,n=t.fs,r=gt(t,e);if(!s)return r;let o=n.openSync(s,"w",t.mode||438);try{yt(n,o,r,0)}catch(a){try{n.closeSync(o)}catch{}throw a}n.closeSync(o)}var J=(i,e)=>{let t=new Set(i.map(o=>X(o))),s=new Set(t),n=0;for(let o of t)n=Math.max(n,o.length);let r=o=>{let a=X(o),c=a.charAt(0)==="/"?"/":".",h=!1;for(let l=a.length;l>0;l=a.lastIndexOf("/",l-1)){if(l>n)continue;let d=a.slice(0,l);if(!(d===c||!t.has(d))&&(h=!0,s.delete(d),!s.size))break}return h};return[(o,a)=>{let c=!e||e(o,a);return r(o)&&c},o=>{for(let a of s)S(o,"TAR_ENTRY_ERROR",`${a}: not found in archive`,{path:a})}]},si=()=>new TypeError("list needs input, or file and fs"),Ve=async(i,e)=>{let t=y(i),{input:s,file:n,fs:r,onEntry:o}=t,a=s??(n&&r?B(r,n,t.maxReadSize):void 0);if(!a)throw si();let[c,h]=e?.length?J(e,t.filter):[];c&&(t.filter=c);let l=new b(a,t);try{for(;;){let d=l.poll();if(d===null)break;d===void 0?await l.fill():o&&await o(d)}}finally{await l.return()}h?.(t)},ni=(i,e)=>{let t=y(i),{input:s,file:n,fs:r,onEntry:o}=t,a=s??(n&&r?H(r,n,t.maxReadSize):void 0);if(!a)throw si();let[c,h]=e?.length?J(e,t.filter):[];c&&(t.filter=c);let l=new E(a,t);for(let d of l)o?.(d);h?.(t)};var gs=()=>{},ri=(i,e)=>{if(!i.file)throw new TypeError("file is required");if(!i.fs)throw new TypeError("the file option needs the fs option");let t=[...i.codecs??[],T];if(e?.length)return[t,...J(e,i.filter)];if(i.filter)return[t,i.filter];throw new TypeError("no paths specified to delete")},oi=i=>`${i}.${Math.random().toString(36).slice(2)}.tmp`,xt=async(i,e)=>{let t=y(i),[s,n,r]=ri(t,e),{fs:o,file:a,filter:c,maxReadSize:h,...l}=t,d=new Uint8Array(we(s)),f=0,p=await o.open(a,"r");try{for(let m=1;m>0&&f<d.length;f+=m)m=(await p.read(d,f,d.length-f,f)).bytesRead}finally{await p.close()}let{mode:w}=await o.stat(a),u=oi(a);try{await ne({...l,fs:o,file:u,mode:w&511,compress:ye(s,d.subarray(0,f),a),preservePaths:!0,filter:(m,g)=>!n(m,g)},[new b(B(o,a,h),{...l,file:a})]),r?.(t),await o.rename(u,a)}catch(m){throw await o.unlink(u).catch(gs),m}},ai=(i,e)=>{let t=y(i),[s,n,r]=ri(t,e),{fs:o,file:a,filter:c,maxReadSize:h,...l}=t,d=new Uint8Array(we(s)),f=0,p=o.openSync(a,"r");try{for(let m=1;m>0&&f<d.length;f+=m)m=o.readSync(p,d,f,d.length-f,f)}finally{o.closeSync(p)}let{mode:w}=o.statSync(a),u=oi(a);try{Ye({...l,fs:o,file:u,mode:w&511,compress:ye(s,d.subarray(0,f),a),preservePaths:!0,filter:(m,g)=>!n(m,g)},[new E(H(o,a,h),{...l,file:a})]),r?.(t),o.renameSync(u,a)}catch(m){try{o.unlinkSync(u)}catch{}throw m}};var re=class extends Error{path;code;syscall="chdir";constructor(e,t){super(`${t}: Cannot cd into '${e}'`),this.path=e,this.code=t}get name(){return"CwdError"}};var j=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(e,t){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=e,this.path=t}get name(){return"SymlinkError"}};var ci=i=>{let e=i.mode|448,{uid:t,gid:s}=i;return{mode:e,needChmod:(e&i.umask)!==0,owner:typeof t=="number"&&typeof s=="number"&&(t!==i.processUid||s!==i.processGid)?{uid:t,gid:s}:void 0}},hi=(i,e)=>i.endsWith("/")?i+e:i+"/"+e,li=(i,e)=>{let t=i.replaceAll("\\","/"),s=[e];for(let n=e.length;!t.endsWith(e.slice(0,n));){if(n=e.lastIndexOf("/",n-1),n<=0)return[e];s.push(e.slice(0,n))}return s},di=async(i,e,t)=>{let{mode:s,needChmod:n,owner:r}=ci(t),{cwd:o}=t,a=[];if(e===o){let c="ENOTDIR";if(!await i.stat(e).then(l=>l.isDirectory(),l=>(c=l?.code||c,!1)))throw new re(e,c)}else if(t.preserve){let c=await i.mkdir(e,{mode:s,recursive:!0});c&&(a=li(c,e))}else{let c=W(o,e).split("/"),h=o;for(let l=0;l<c.length;l++){h=hi(h,c[l]);try{await i.mkdir(h,{mode:s})}catch(d){let f=await i.lstat(h);if(f.isDirectory())continue;if(!t.unlink)throw f.isSymbolicLink()?new j(h,h+"/"+c.slice(l+1).join("/")):d;await i.unlink(h),await i.mkdir(h,{mode:s})}a.push(h)}}if(r)for(let c of a)await i.lchown(c,r.uid,r.gid);n&&await i.chmod(e,s)},fi=(i,e,t)=>{let{mode:s,needChmod:n,owner:r}=ci(t),{cwd:o}=t,a=[];if(e===o){let c="ENOTDIR",h=!1;try{h=i.statSync(e).isDirectory()}catch(l){c=l?.code||c}if(!h)throw new re(e,c)}else if(t.preserve){let c=i.mkdirSync(e,{mode:s,recursive:!0});c&&(a=li(c,e))}else{let c=W(o,e).split("/"),h=o;for(let l=0;l<c.length;l++){h=hi(h,c[l]);try{i.mkdirSync(h,{mode:s})}catch(d){let f=i.lstatSync(h);if(f.isDirectory())continue;if(!t.unlink)throw f.isSymbolicLink()?new j(h,h+"/"+c.slice(l+1).join("/")):d;i.unlinkSync(h),i.mkdirSync(h,{mode:s})}a.push(h)}}if(r)for(let c of a)i.lchownSync(c,r.uid,r.gid);n&&i.chmodSync(e,s)};var kt=Object.create(null),pi=1e4,oe=new Set,ui=i=>{oe.has(i)?oe.delete(i):kt[i]=i.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),oe.add(i);let e=kt[i],t=oe.size-pi;if(t>pi/10){for(let s of oe)if(oe.delete(s),delete kt[s],--t<=0)break}return e};var xs=i=>{let e=[];for(let t=i.indexOf("/");t!==-1;t=i.indexOf("/",t+1))e.push(i.slice(0,t)||"/");return e},ve=class{#e=new Map;#t=new Map;#i=new Set;#s;constructor(e=!1){this.#s=e}reserve(e,t){return new Promise((s,n)=>{let r=()=>{t().then(()=>{this.#o(r),s()},o=>{this.#o(r),n(o)})};this.#r(e,r)})}#r(e,t){e=this.#s?["win32 parallelization disabled"]:[...new Set(e.map(n=>X(G(ui(n)))))];let s=new Set(e.flatMap(xs));for(let n of e)s.delete(n);this.#t.set(t,{dirs:s,paths:e});for(let n of e){let r=this.#e.get(n);r?r.push(t):this.#e.set(n,[t])}for(let n of s){let r=this.#e.get(n),o=r?.[r.length-1];r?o instanceof Set?o.add(t):r.push(new Set([t])):this.#e.set(n,[new Set([t])])}this.#n(t)}#n(e){let{paths:t,dirs:s}=this.#t.get(e);for(let n of t)if(this.#e.get(n)?.[0]!==e)return;for(let n of s){let r=this.#e.get(n)?.[0];if(!(r instanceof Set)||!r.has(e))return}this.#i.add(e),e()}#o(e){let{paths:t,dirs:s}=this.#t.get(e),n=new Set;for(let r of t){let o=this.#e.get(r),a=o[1];if(!a){this.#e.delete(r);continue}if(o.shift(),typeof a=="function")n.add(a);else for(let c of a)n.add(c)}for(let r of s){let o=this.#e.get(r),a=o[0];a.size>1?a.delete(e):o.length===1?this.#e.delete(r):(o.shift(),n.add(o[0]))}this.#i.delete(e),this.#t.delete(e);for(let r of n)this.#n(r)}};var mi=(i,e)=>{if(!i)return()=>"w";let{O_CREAT:t,O_TRUNC:s,O_WRONLY:n,O_NOFOLLOW:r,UV_FS_O_FILEMAP:o}=i,a=s|t|n;if(!e){let h=typeof r=="number"?r|a:"w";return()=>h}if(!o)return()=>"w";let c=o|a;return h=>h<524288?c:"w"};var ks=1024,wi=32768,Ss=16,qe=new Set(["File","OldFile","ContiguousFile"]),ae=new Set(["Directory","GNUDumpDir"]),bs=new Set(["Link","SymbolicLink"]),yi=(i,e,t)=>i!==void 0?i:e!==void 0&&e===e>>>0?e:t,Re=class{opt;cwd;win32;strip;maxDepth;preservePaths;unlink;keep;newer;noMtime;chmod;uid;gid;preserveOwner;forceChown;processUid;processGid;processUmask;umask;dmode;fmode;writeFlag;resolve;dirname;fatal;constructor(e){let t=this.opt=k(e),s=this.win32=t.platform==="win32";if(this.resolve=s?Ie:C,this.dirname=s?Gt:z,typeof t.cwd!="string")throw new TypeError("cwd is required");let n=s?t.cwd.replaceAll("\\","/"):t.cwd;if(!(s?ge:te)(n))throw new TypeError("cwd must be an absolute path");if(this.cwd=this.resolve(n,""),typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.uid!==t.uid>>>0||t.gid!==t.gid>>>0)throw new TypeError("uid and gid must be unsigned 32-bit integers");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid}this.processUid=t.processUid,this.processGid=t.processGid,this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?t.processUid===0:!!t.preserveOwner,this.forceChown=t.forceChown===!0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:ks,this.strip=Number(t.strip)||0,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.keep=!!t.keep,this.newer=!!t.newer,this.noMtime=!!t.noMtime,this.chmod=!!t.chmod,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:18: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.writeFlag=mi(t.fs.constants,s)}warn(e,t,s={}){(e==="TAR_BAD_ARCHIVE"||e==="TAR_ABORT")&&(s.recoverable=!1),s.cwd=this.cwd,S(this.opt,e,t,s)}readerOptions(){return k(this.opt,{strict:!1,onwarn:(e,t,s)=>s instanceof Error?this.warn(e,s):this.warn(e,t,s)})}entryError(e,t){if(this.fatal?.error===e||e?.name==="CwdError")throw e;this.warn("TAR_ENTRY_ERROR",e,{entry:t})}fail(e){return this.fatal??={error:e},e}#e(e,t){let s=e[t];if(!s||this.preservePaths)return!0;let[n,r]=Be(s),o=r.replaceAll("\\","/").split("/");if(o.includes("..")){if(t==="path"||e.type==="Link")return this.warn("TAR_ENTRY_ERROR",`${t} contains '..'`,{entry:e,[t]:s}),!1;let a=o.findIndex(l=>l!==".."&&l!=="."&&l!=="");if(a!==-1&&o.includes("..",a))return this.warn("TAR_ENTRY_ERROR",`${t} contains '..' after a path portion`,{entry:e,[t]:s}),!1;let c=z(he(e.path)),h=he(G(c,o.join("/")));if(h.startsWith("../")||h==="..")return this.warn("TAR_ENTRY_ERROR",`${t} escapes extraction directory`,{entry:e,[t]:s}),!1}return n&&(e[t]=r,this.warn("TAR_ENTRY_INFO",`stripping ${n} from absolute ${t}`,{entry:e,[t]:s})),!0}check(e){let t=e.path,s=t.split("/");if(this.strip){if(s.length<this.strip)return!1;if(e.type==="Link"){let c=String(e.linkpath).split("/");if(c.length<this.strip)return!1;e.linkpath=c.slice(this.strip).join("/")}if(s.splice(0,this.strip),s.every(c=>c===""))return!1;e.path=s.join("/")}let{maxDepth:n}=this;if(isFinite(n)&&s.length>n)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:e,path:t,depth:s.length,maxDepth:n}),!1;let{linkpath:r}=e;if(r&&isFinite(n)&&r.split("/").length>n)return this.warn("TAR_ENTRY_ERROR","linkpath excessively deep",{entry:e,path:t,linkpath:r,maxDepth:n}),!1;for(let c of["path","linkpath"]){let{length:h}=e[c]??"";if(h>wi)return this.warn("TAR_ENTRY_ERROR",`${c} excessively long`,{entry:e,path:t,length:h,maxLength:wi}),!1}if(!this.#e(e,"path")||!this.#e(e,"linkpath"))return!1;let{cwd:o}=this,a=this.resolve(o,e.path);if(!this.preservePaths&&a!==o&&!a.startsWith(o.endsWith("/")?o:o+"/"))return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:e,path:e.path,resolvedPath:a,cwd:o}),!1;if(a===o&&!ae.has(e.type))return!1;if(this.win32){let c=$(a);a=c+ft(a.slice(c.length));let h=$(e.path);e.path=h+ft(e.path.slice(h.length))}if(e.absolute=a,typeof e.mode=="number"&&(e.mode&=511),ae.has(e.type))e.mode&&(e.mode|=448);else if(!qe.has(e.type)&&!bs.has(e.type))return e.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${e.type}`,{entry:e}),!1;return!0}reservedPaths(e){let{path:t,linkpath:s}=e;return s?[t,e.type==="SymbolicLink"&&!te(s)?G(z(t),s):s]:[t]}mkdirOptions(e){return{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}}owner(e){let t=this.forceChown||this.preserveOwner&&(typeof e.uid=="number"&&e.uid!==this.processUid||typeof e.gid=="number"&&e.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid,s=yi(this.uid,e.uid,this.processUid),n=yi(this.gid,e.gid,this.processGid);return t&&typeof s=="number"&&typeof n=="number"?{uid:s,gid:n}:void 0}times(e){return e.mtime&&!this.noMtime?{atime:e.atime||new Date,mtime:e.mtime}:void 0}skip(e,t){return this.keep||this.newer&&t.mtime>(e.mtime??t.mtime)}isReusable(e,t){return e.type==="File"&&!this.unlink&&t.isFile()&&t.nlink<=1&&!this.win32}linkParts(e,t){let s=String(e.linkpath);return e.type==="Link"?s.split("/"):W(this.cwd,this.resolve(this.dirname(t),s)).split("/")}symlinkError(e,t){return new j(e,this.resolve(this.cwd,t.join("/")))}},gi=i=>i+".DELETE."+Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,"0")).join(""),Ae=class extends Re{#e;#t;#i;#s=0;#r;#n=!1;#o;constructor(e){super(e),this.#e=this.opt.fs,this.#t=new ve(this.win32),this.#i=V("jobs",this.opt.jobs,Ss)}async extract(e){let t=new b(e,this.readerOptions()),{onEntry:s}=this.opt,n=!!this.opt.transform;try{for(;!this.fatal;){let r=t.poll();if(r===null)break;if(r===void 0){await t.fill();continue}if(s&&await s(r),r.bodyUsed||!this.check(r))continue;let o=[],a=!n;if(a&&qe.has(r.type))for(;;){let h=t.readBody(r);if(h===null)break;if(h===void 0){a=!1;break}o.push(h)}let c=this.#c(r,o,a?void 0:t);for(a||await c;this.#s>=this.#i;)await this.#a()}}catch(r){this.fail(r)}for(await t.return().catch(r=>this.fail(r));this.#s>0;)await this.#a();if(this.fatal){let{error:r}=this.fatal;throw r&&typeof r=="object"&&"tarCode"in r&&Object.assign(r,{cwd:this.cwd}),r}}#a(){return new Promise(e=>{this.#r=e})}#c(e,t,s){return this.#s++,this.#t.reserve(this.reservedPaths(e),async()=>{try{this.fatal||await this.#w(e,t,s)}catch(n){try{this.entryError(n,e)}catch(r){this.fail(r)}}this.#s--,this.#r?.()})}#h(e,t){return di(this.#e,e,this.mkdirOptions(t))}#d(){return this.#o??=this.#h(this.cwd,this.dmode).then(()=>{this.#n=!0},e=>{throw this.#o=void 0,e})}async#w(e,t,s){let n=this.#e,r=e.absolute,{cwd:o}=this;if(this.#n||await this.#d(),r!==o){let h=this.dirname(r);h!==o&&await this.#h(h,this.dmode)}let a=await n.lstat(r).catch(()=>{});if(a&&this.skip(e,a))return;if(a&&!this.isReusable(e,a)&&(a.isDirectory()&&ae.has(e.type)?this.chmod&&e.mode&&(a.mode&4095)!==e.mode&&await n.chmod(r,e.mode):r!==o&&(a.isDirectory()?await n.rmdir(r):await this.#y(r))),qe.has(e.type))return this.#u(e,r,t,s);if(ae.has(e.type))return this.#l(e,r);await this.#p(this.linkParts(e,r));let c=String(e.linkpath);e.type==="Link"?await n.link(this.resolve(o,c),r):await n.symlink(c,r)}async#y(e){let t=this.#e;if(!this.win32)return t.unlink(e);let s=gi(e);await t.rename(e,s),await t.unlink(s)}async#p(e){if(this.preservePaths)return;let t=this.cwd;for(let s of e){t=this.resolve(t,s);let n=await this.#e.lstat(t).catch(()=>{});if(!n)return;if(n.isSymbolicLink())throw this.symlinkError(t,e)}}async#l(e,t){let s=this.#e;await this.#h(t,e.mode??this.dmode);let n=this.times(e);n&&await s.lutimes(t,n.atime,n.mtime).catch(()=>{});let r=this.owner(e);r&&await s.lchown(t,r.uid,r.gid).catch(()=>{})}async#u(e,t,s,n){let r=this.#e,o=await r.open(t,this.writeFlag(e.size),e.mode??this.fmode);try{if(n)await this.#g(e,s,n,o);else for(let h of s)await o.write(h);let a=this.times(e);if(a){let{atime:h,mtime:l}=a;await o.utimes(h,l).catch(async d=>{await r.utimes(t,h,l).catch(()=>{throw d})})}let c=this.owner(e);if(c){let{uid:h,gid:l}=c;await o.chown(h,l).catch(async d=>{await r.chown(t,h,l).catch(()=>{throw d})})}}catch(a){throw await o.close().catch(()=>{}),a}await o.close()}async#g(e,t,s,n){let r=0,o=async()=>{if(r<t.length)return t[r++];try{for(;;){let p=s.readBody(e);if(p!==void 0)return p;await s.fill()}}catch(p){throw this.fail(p)}},a=this.opt.transform?.(e);if(!a){let p,w;try{for(let u;(u=await o())&&(await p,!w);)p=n.write(u).then(()=>{},m=>{w={error:m}})}finally{await p}if(w)throw w.error;return}let c=a.writable.getWriter(),h=a.readable.getReader(),l,d=async p=>{l??={error:p},await h.cancel(p).catch(()=>{}),await c.abort(p).catch(()=>{})},f=(async()=>{try{for(let p;p=await o();)await c.write(p);await c.close()}catch(p){await d(p)}})();try{for(;;){let{done:p,value:w}=await h.read();if(p)break;await n.write(w)}}catch(p){await d(p)}if(await f,l)throw l.error}},Te=class extends Re{#e;#t=!1;constructor(e){super(e),this.#e=this.opt.fs}extract(e){let t=new E(e,this.readerOptions()),{onEntry:s}=this.opt;try{for(let n of t)if(s?.(n),!n.bodyUsed&&this.check(n))try{this.#s(n,t)}catch(r){this.entryError(r,n)}}catch(n){throw n&&typeof n=="object"&&"tarCode"in n&&Object.assign(n,{cwd:this.cwd}),n}}#i(e,t){fi(this.#e,e,this.mkdirOptions(t))}#s(e,t){let s=this.#e,n=e.absolute,{cwd:r}=this;if(this.#t||(this.#i(r,this.dmode),this.#t=!0),n!==r){let c=this.dirname(n);c!==r&&this.#i(c,this.dmode)}let o;try{o=s.lstatSync(n)}catch{}if(o&&this.skip(e,o))return;if(o&&!this.isReusable(e,o)&&(o.isDirectory()&&ae.has(e.type)?this.chmod&&e.mode&&(o.mode&4095)!==e.mode&&s.chmodSync(n,e.mode):n!==r&&(o.isDirectory()?s.rmdirSync(n):this.#r(n))),qe.has(e.type))return this.#a(e,n,t);if(ae.has(e.type))return this.#o(e,n);this.#n(this.linkParts(e,n));let a=String(e.linkpath);e.type==="Link"?s.linkSync(this.resolve(r,a),n):s.symlinkSync(a,n)}#r(e){let t=this.#e;if(!this.win32)return t.unlinkSync(e);let s=gi(e);t.renameSync(e,s),t.unlinkSync(s)}#n(e){if(this.preservePaths)return;let t=this.cwd;for(let s of e){t=this.resolve(t,s);let n;try{n=this.#e.lstatSync(t)}catch{return}if(n.isSymbolicLink())throw this.symlinkError(t,e)}}#o(e,t){let s=this.#e;this.#i(t,e.mode??this.dmode);let n=this.times(e);if(n)try{s.lutimesSync(t,n.atime,n.mtime)}catch{}let r=this.owner(e);if(r)try{s.lchownSync(t,r.uid,r.gid)}catch{}}#a(e,t,s){let n=this.#e,r=n.openSync(t,this.writeFlag(e.size),e.mode??this.fmode);try{let o=this.opt.transform?.(e);for(;;){let h;try{h=s.readBody(e)}catch(l){throw this.fail(l)}if(!h)break;n.writeSync(r,o?o(h):h)}let a=this.times(e);if(a){let{atime:h,mtime:l}=a;try{n.futimesSync(r,h,l)}catch(d){try{n.utimesSync(t,h,l)}catch{throw d}}}let c=this.owner(e);if(c){let{uid:h,gid:l}=c;try{n.fchownSync(r,h,l)}catch(d){try{n.chownSync(t,h,l)}catch{throw d}}}}catch(o){try{n.closeSync(r)}catch{}throw o}n.closeSync(r)}};var xi=()=>new TypeError("extract needs input or file"),Ke=async(i,e)=>{let t=y(i),s=t.input??(t.file?B(t.fs,t.file,t.maxReadSize):void 0);if(!s)throw xi();let[n,r]=e?.length?J(e,t.filter):[];n&&(t.filter=n),await new Ae(t).extract(s),r?.(t)},ki=(i,e)=>{let t=y(i),s=t.input??(t.file?H(t.fs,t.file,t.maxReadSize):void 0);if(!s)throw xi();let[n,r]=e?.length?J(e,t.filter):[];n&&(t.filter=n),new Te(t).extract(s),r?.(t)};var Si=64*1024,bi={},Es=()=>{},Xe=()=>new Error("cannot append to compressed archives"),Ei=(i,e)=>{let{file:t}=i;if(!t)throw new TypeError("file is required");if(i.gzip||i.brotli||i.zstd||t.endsWith(".br")||t.endsWith(".tbr"))throw new TypeError(Xe().message);if(!e?.length)throw new TypeError("no paths specified to add/replace")},Oe=class{buf=new Uint8Array(Si);pos=0;#e;#t;#i;#s;constructor(e,t=[],s){this.#e=e,this.#i=[...t,T],this.#s=s,this.#t=new I({filter:()=>!1,onwarn:(n,r,o)=>{throw o instanceof Error?o:bi}})}get position(){return this.#t.position}get want(){return Math.min(Si,this.#e-this.pos)}push(e){let t=this.buf.subarray(0,e);if(this.pos===0&&this.#i.some(r=>r.detect(t)))throw Xe();let s=this.#t;this.pos+=e;let n=0;s.push(t);try{for(let r;r=s.next();){if(r.type!=="entry")return!1;let{entry:o}=r;if(n=s.offset+512*Math.ceil(o.size/512),n>this.#e)return!1;o.mtime&&this.#s?.set(o.path,o.mtime)}this.pos<n&&(s.skipBody(),this.pos=n)}catch(r){if(r!==bi)throw r;return!1}return e>0&&this.pos<this.#e}},ce=async(i,e)=>{let t=y(i);Ei(t,e);let{fs:s,file:n}=t,r=We(t,e);if(r.codec)throw new TypeError(Xe().message);let o=await s.open(n,"r+").catch(c=>{if(c?.code!=="ENOENT")throw c;return s.open(n,"w+",t.mode||438)}),a=!1;try{let{size:c}=await o.stat(),h=new Oe(c,t.codecs,t.mtimeCache);for(;h.push((await o.read(h.buf,0,h.want,h.pos)).bytesRead););await wt(o,r,h.position),a=!0}finally{let c=o.close();await(a?c:c.catch(Es))}},Ze=(i,e)=>{let t=y(i);Ei(t,e);let{fs:s,file:n}=t,r=gt(t,e);if(r.codec)throw new TypeError(Xe().message);let o;try{o=s.openSync(n,"r+")}catch(a){if(a?.code!=="ENOENT")throw a;o=s.openSync(n,"w+",t.mode||438)}try{let{size:a}=s.fstatSync(o),c=new Oe(a,t.codecs,t.mtimeCache);for(;c.push(s.readSync(o,c.buf,0,c.want,c.pos)););yt(s,o,r,c.position)}catch(a){try{s.closeSync(o)}catch{}throw a}s.closeSync(o)};var vs=(i,e)=>{let t=e.getTime(),s=i.getTime();return(t%1e3===0?s-s%1e3:s)>t},vi=i=>{let{filter:e}=i,t=i.mtimeCache??new Map;return{...i,mtimeCache:t,filter:(s,n)=>{if(e&&!e(s,n))return!1;if("isDirectory"in n&&n.isDirectory())return!0;let r=t.get(s);return!r||!n.mtime||vs(n.mtime,r)}}},Je=(i,e)=>ce(vi(i),e),Ri=(i,e)=>Ze(vi(i),e);import{constants as As}from"node:buffer";import*as Ts from"node:zlib";var Qe=64*1024,et=(i,e=!1,t)=>{let s,n,r=!1,o=!1,a,c,h=e?new Uint8Array(Qe):void 0,l=0,d=u=>new Promise(m=>{a=m,i.write(u,()=>m())}),f=async u=>{l&&await d(u.subarray(0,l)),l=0},p=()=>{o=!0,a?.(),c?.()},w=()=>{p(),i.destroy()};return i.pause(),i.on("data",u=>{t?.(u),t=void 0,r=!1,i.pause(),s.enqueue(u)}),i.on("end",()=>{o||s.close()}),i.on("error",u=>{s.error(u),n.error(u),p()}),i.on("close",p),{readable:new ReadableStream({start:u=>{s=u},pull:()=>{r=!0,c?.(),i.resume()},cancel:u=>{n.error(u),w()}},{highWaterMark:0}),writable:new WritableStream({start:u=>{n=u;let{signal:m}=u;m.addEventListener("abort",()=>{s.error(m.reason),w()})},write:async u=>{h?(l+u.length>Qe&&await f(h),u.length>Qe?await d(u):(h.set(u,l),l+=u.length)):await d(u),!r&&!o&&await new Promise(m=>c=m)},close:async()=>{h&&await f(h),await new Promise(u=>{a=u,i.end()})}})}},Os=i=>i>=As.MAX_LENGTH?{}:{maxOutputLength:Math.max(1,Math.floor(i))},St=(i,e,t,s,n)=>({...i,decompress:()=>et(t({chunkSize:Qe})),compress:r=>et(e(r),!0),decompressSync:(r,{maxOutputLength:o})=>{try{return n(r,Os(o))}catch(a){throw a?.code!=="ERR_BUFFER_TOO_LARGE"?a:new Error(`max decompression ratio exceeded: the output is larger than ${o} bytes`)}},compressSync:s}),Ai=i=>{i[9]=255},bt=(i=Ts)=>{let{createBrotliCompress:e,createBrotliDecompress:t,brotliCompressSync:s,brotliDecompressSync:n,createZstdCompress:r,createZstdDecompress:o,zstdCompressSync:a,zstdDecompressSync:c}=i,l=[{...St({name:"gzip",headLength:2,detect:d=>d[0]===31&&d[1]===139},i.createGzip,i.createGunzip,i.gzipSync,i.gunzipSync),compress:({portable:d,...f}={})=>et(i.createGzip(f),!0,d?Ai:void 0),compressSync:(d,{portable:f,...p}={})=>{let w=i.gzipSync(d,p);return f&&Ai(w),w}}];return e&&t&&s&&n&&l.push(St({name:"brotli",headLength:0,detect:()=>!1,extensions:[".tar.br",".tbr"]},e,t,s,n)),r&&o&&a&&c&&l.push(St({name:"zstd",headLength:4,detect:d=>d[0]===40&&d[1]===181&&d[2]===47&&d[3]===253},r,o,a,c)),l};var Q=Ps,ee=zs,Ns=process.platform==="win32"?"win32":"posix",Us=bt(),x=(i,e,t)=>{let s=y(i);return s.fs??=e,s.platform??=Ns,s.codecs=[...s.codecs??[],...Us],t&&(s.cwd=Fs(s.cwd??""),s.processUid??=process.getuid?.(),s.processGid??=process.getgid?.(),s.processUname??=process.env.USER,s.chmod&&(s.processUmask??=process.umask())),s},ko=(i,e={})=>lt(i,x(e,Q,!1)),So=(i,e={})=>Bt(i,x(e,ee,!1)),bo=(i,e)=>Ve(x(i,Q,!1),e),Eo=(i,e)=>ni(x(i,ee,!1),e),vo=(i,e)=>Ke(x(i,Q,!0),e),Ro=(i,e)=>ki(x(i,ee,!0),e);function Ao(i,e){return ne(x(i,Q,!0),e)}function To(i,e){return Ye(x(i,ee,!0),e)}var Oo=(i,e)=>ce(x(i,Q,!0),e),zo=(i,e)=>Ze(x(i,ee,!0),e),Po=(i,e)=>Je(x(i,Q,!0),e),Fo=(i,e)=>Ri(x(i,ee,!0),e),No=(i,e)=>xt(x(i,Q,!1),e),Uo=(i,e)=>ai(x(i,ee,!1),e);export{Oe as AppendScan,re as CwdError,me as EntryCursor,q as EntryData,R as Header,Se as Pack,ke as PackBase,F as PackJob,be as PackSync,I as Parser,ve as PathReservations,M as Pax,pe as ReadEntry,ue as ReadEntrySync,j as SymlinkError,b as TarReader,E as TarReaderSync,Ae as Unpack,Re as UnpackBase,Te as UnpackSync,se as WriteEntry,Ot as aliases,Ao as c,et as codecStream,Ao as create,To as createSync,No as delete,Uo as deleteSync,ko as entries,So as entriesSync,vo as extract,Ro as extractSync,T as gzip,bo as list,Eo as listSync,Oo as r,Oo as replace,zo as replaceSync,bo as t,nt as types,Po as u,Po as update,Fo as updateSync,vo as x,bt as zlibCodecs};
|
|
1
|
+
var Ti=Object.defineProperty;var Oi=(i,e)=>{for(var t in e)Ti(i,t,{get:e[t],enumerable:!0})};import*as Ps from"node:fs";import*as zs from"node:fs/promises";import{resolve as Fs}from"node:path";var v=i=>ArrayBuffer.isView(i)&&i[Symbol.toStringTag]==="Uint8Array",tt=i=>Object.prototype.toString.call(i)==="[object ArrayBuffer]",N=i=>typeof i?.size=="number"&&typeof i.stream=="function",Pe=i=>typeof i?.getReader=="function",Pi=new TextDecoder("utf-8",{ignoreBOM:!0}),zi=new TextEncoder,A=i=>{let e=i.length;for(let t=0;t<i.length;t++){let s=i.charCodeAt(t);s<128||(s<2048?e+=1:s>=55296&&s<=56319&&(i.charCodeAt(t+1)&64512)===56320?(e+=2,t++):e+=2)}return e},U=(i,e=0,t=i.length)=>{let s="";for(let n=e;n<t;n++){let r=i[n];if(r>=128)return Pi.decode(i.subarray(e,t));s+=String.fromCharCode(r)}return s},ze=(i,e,t,s)=>{let{written:n}=zi.encodeInto(i,e.subarray(t,t+s));e.fill(0,t+n,t+s)},it=(i,e,t)=>{for(let s=0;s<i.length;s++)e[t+s]=i.charCodeAt(s)};var vt=(i,e)=>{if(Number.isSafeInteger(i))i<0?Ni(i,e):Fi(i,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Fi=(i,e)=>{e[0]=128;for(var t=e.length;t>1;t--)e[t-1]=i&255,i=Math.floor(i/256)},Ni=(i,e)=>{e[0]=255;var t=!1;i=i*-1;for(var s=e.length;s>1;s--){var n=i&255;i=Math.floor(i/256),t?e[s-1]=At(n):n===0?e[s-1]=0:(t=!0,e[s-1]=Tt(n))}},Rt=i=>{let e=i[0],t=e===128?Ci(i.subarray(1,i.length)):e===255?Ui(i):null;if(t===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(t))throw Error("parsed number outside of javascript safe integer range");return t},Ui=i=>{for(var e=i.length,t=0,s=!1,n=e-1;n>-1;n--){var r=Number(i[n]),o;s?o=At(r):r===0?o=r:(s=!0,o=Tt(r)),o!==0&&(t-=o*Math.pow(256,e-n-1))}return t},Ci=i=>{for(var e=i.length,t=0,s=e-1;s>-1;s--){var n=Number(i[s]);n!==0&&(t+=n*Math.pow(256,e-s-1))}return t},At=i=>(255^i)&255,Tt=i=>(255^i)+1&255;var he=i=>{let e=i.charCodeAt(0)===47,t=[];for(let r of i.split("/"))r===""||r==="."||(r!==".."?t.push(r):t.length&&t[t.length-1]!==".."?t.pop():e||t.push(r));let s=t.length&&i.charCodeAt(i.length-1)===47,n=t.join("/")+(s?"/":"");return e?"/"+n:n||(i.endsWith("/")?"./":".")},W=(...i)=>he(i.filter(e=>e).join("/")),P=i=>{let e=i.length;for(;e>1&&i.charCodeAt(e-1)===47;)e--;let t=i.lastIndexOf("/",e-1);return t===-1?".":t===0?"/":t===1&&i.charCodeAt(0)===47?"//":i.slice(0,t)},le=i=>{let e=i.length;for(;e>0&&i.charCodeAt(e-1)===47;)e--;return i.slice(i.lastIndexOf("/",e-1)+1,e)},te=i=>i.charCodeAt(0)===47,C=(...i)=>{let e="";for(let s=i.length-1;s>=0&&!te(e);s--){let n=i[s];n&&(e=e?n+"/"+e:n)}let t=he(e);return t.length>1&&t.endsWith("/")?t.slice(0,-1):t},L=(i,e)=>{let t=C(i).split("/"),s=C(e).split("/");t[t.length-1]||t.pop(),s[s.length-1]||s.pop();let n=0;for(;n<t.length&&n<s.length&&t[n]===s[n];)n++;return[...Array.from({length:t.length-n},()=>".."),...s.slice(n)].join("/")};var nt={};Oi(nt,{code:()=>Fe,isCode:()=>de,isName:()=>Di,name:()=>pe,normalFsTypes:()=>st});var de=i=>pe.has(i),Di=i=>Fe.has(i),st=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"]]),Fe=new Map(Array.from(pe).map(i=>[i[1],i[0]]));var _i=i=>i===void 0||i<0?void 0:i,R=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,t=0,s,n){v(e)?this.decode(e,t||0,s,n):e&&this.#t(e)}decode(e,t,s,n){if(t||(t=0),!e||!(e.length>=t+512))throw new Error("need 512 bytes for header");let r=D(e,t+156,1),o=st.has(r),a=o?s:void 0,c=o?n:void 0;if(this.path=a?.path??D(e,t,100),this.mode=a?.mode??c?.mode??_(e,t+100,8),this.uid=a?.uid??c?.uid??_(e,t+108,8),this.gid=a?.gid??c?.gid??_(e,t+116,8),this.size=_i(a?.size??c?.size??_(e,t+124,12)),this.mtime=a?.mtime??c?.mtime??rt(e,t+136,12),this.cksum=_(e,t+148,12),c&&this.#t(c,!0),a&&this.#t(a),de(r)&&(this.#e=r||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=D(e,t+157,100),U(e,t+257,t+265)==="ustar\x0000")if(this.uname=a?.uname??c?.uname??D(e,t+265,32),this.gname=a?.gname??c?.gname??D(e,t+297,32),this.devmaj=a?.devmaj??c?.devmaj??_(e,t+329,8)??0,this.devmin=a?.devmin??c?.devmin??_(e,t+337,8)??0,e[t+475]!==0){let l=D(e,t+345,155);this.path=l+"/"+this.path}else{let l=D(e,t+345,130);l&&(this.path=l+"/"+this.path),this.atime=s?.atime??n?.atime??rt(e,t+476,12),this.ctime=s?.ctime??n?.ctime??rt(e,t+488,12)}let h=256;for(let l=t;l<t+148;l++)h+=e[l];for(let l=t+156;l<t+512;l++)h+=e[l];this.cksumValid=h===this.cksum,this.cksum===void 0&&h===256&&(this.nullBlock=!0)}#t(e,t=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([s,n])=>!(n==null||s==="size"&&Number(n)<0||s==="path"&&t||s==="linkpath"&&t||s==="global"))))}encode(e,t=0){if(e||(e=this.block=new Uint8Array(512)),this.#e==="Unsupported"&&(this.#e="0"),!(e.length>=t+512))throw new Error("need 512 bytes for header");let s=this.ctime||this.atime?130:155,n=Mi(this.path||"",s),r=n[0],o=n[1];this.needPax=!!n[2],this.needPax=Y(e,t,100,r)||this.needPax,this.needPax=M(e,t+100,8,this.mode)||this.needPax,this.needPax=M(e,t+108,8,this.uid)||this.needPax,this.needPax=M(e,t+116,8,this.gid)||this.needPax,this.needPax=M(e,t+124,12,this.size)||this.needPax,this.needPax=ot(e,t+136,12,this.mtime)||this.needPax,e[t+156]=Number(this.#e.codePointAt(0)),this.needPax=Y(e,t+157,100,this.linkpath)||this.needPax,it("ustar\x0000",e,t+257),this.needPax=Y(e,t+265,32,this.uname)||this.needPax,this.needPax=Y(e,t+297,32,this.gname)||this.needPax,this.needPax=M(e,t+329,8,this.devmaj)||this.needPax,this.needPax=M(e,t+337,8,this.devmin)||this.needPax,this.needPax=Y(e,t+345,s,o)||this.needPax,e[t+475]!==0?this.needPax=Y(e,t+345,155,o)||this.needPax:(this.needPax=Y(e,t+345,130,o)||this.needPax,this.needPax=ot(e,t+476,12,this.atime)||this.needPax,this.needPax=ot(e,t+488,12,this.ctime)||this.needPax);let a=256;for(let c=t;c<t+148;c++)a+=e[c];for(let c=t+156;c<t+512;c++)a+=e[c];return this.cksum=a,M(e,t+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:pe.get(this.#e)}get typeKey(){return this.#e}set type(e){let t=String(Fe.get(e));if(de(t)||t==="Unsupported")this.#e=t;else if(de(e))this.#e=e;else throw new TypeError("invalid entry type: "+e)}},Mi=(i,e)=>{let s=i,n="",r,o=i.charAt(0)==="/"?"/":".";if(A(s)<100)r=[s,n,!1];else{n=P(s),s=le(s);do A(s)<=100&&A(n)<=e?r=[s,n,!1]:A(s)>100&&A(n)<=e?r=[s.slice(0,99),n,!0]:(s=W(le(n),s),n=P(n));while(n!==o&&r===void 0);r||(r=[i.slice(0,99),"",!0])}return r},D=(i,e,t)=>{let s=e,n=Math.min(e+t,i.length);for(;s<n&&i[s]!==0;)s++;return U(i,e,s)},rt=(i,e,t)=>Ii(_(i,e,t)),Ii=i=>i===void 0?void 0:new Date(i*1e3),_=(i,e,t)=>Number(i[e])&128?Rt(i.subarray(e,e+t)):Hi(i,e,t),Bi=i=>isNaN(i)?void 0:i,Hi=(i,e,t)=>Bi(parseInt(D(i,e,t).trim(),8)),$i={12:8589934591,8:2097151},M=(i,e,t,s)=>s===void 0?!1:s>$i[t]||s<0?(vt(s,i.subarray(e,e+t)),!0):(ji(i,e,t,s),!1),ji=(i,e,t,s)=>it(Gi(s,t),i,e),Gi=(i,e)=>Wi(Math.floor(i).toString(8),e),Wi=(i,e)=>(i.length===e-1?i:"0".repeat(e-i.length-2)+i+" ")+"\0",ot=(i,e,t,s)=>s===void 0?!1:M(i,e,t,s.getTime()/1e3),Y=(i,e,t,s)=>s===void 0?!1:(ze(s,i,e,t),s.length!==A(s)||s.length>t);var Yi=/^\d+$/,I=class i{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,t=!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=t,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 new Uint8Array(0);let t=A(e),s=512*Math.ceil(1+t/512),n=new Uint8Array(s);return new R({path:("PaxHeader/"+le(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:t,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(n),ze(e,n,512,t),n}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 t=this[e],s=typeof t=="object"?t.getTime()/1e3:t,n=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+s+`
|
|
2
|
+
`,r=A(n),o=Math.floor(Math.log(r)/Math.log(10))+1;return r+o>=Math.pow(10,o)&&(o+=1),o+r+n}static parse(e,t,s=!1){return i.parseBytes(new TextEncoder().encode(e),t,s)}static parseBytes(e,t,s=!1){return new i(Vi(qi(e),t),s)}},Vi=(i,e)=>e?Object.assign({},e,i):i,qi=i=>{let e=Object.create(null),t=0;for(;t<i.length;){let s=t;for(;s<i.length&&i[s]>=48&&i[s]<=57;)s++;if(s===t||i[s]!==32)break;let n=Number(U(i,t,s)),r=t+n;if(r<=s+1||r>i.length||i[r-1]!==10)break;Ki(e,U(i,s+1,r-1)),t=r}return e},Ki=(i,e)=>{let t=e.split("="),s=t.shift();if(!s)return i;let n=s.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),r=t.join("="),o=r.indexOf("\0"),a=o===-1?r:r.slice(0,o);switch(n){case"path":case"linkpath":case"type":case"charset":case"comment":case"gname":case"uname":i[n]=a;break;case"ctime":case"atime":case"mtime":let c=new Date(Number(a)*1e3);isNaN(c.getTime())||(i[n]=c);break;case"size":case"gid":case"uid":case"dev":case"ino":case"nlink":case"mode":if(!Yi.test(a.trim()))break;let h=+a;if(!Number.isSafeInteger(h))break;i[n]=h;break}return i};var T={name:"gzip",headLength:2,detect:i=>i[0]===31&&i[1]===139,decompress:()=>new DecompressionStream("gzip"),compress:i=>{let e=new CompressionStream("gzip");if(!i?.portable)return e;let t=0;return{writable:e.writable,readable:e.readable.pipeThrough(new TransformStream({transform:(s,n)=>{t<=9&&t+s.length>9&&(s[9-t]=255),t+=s.length,n.enqueue(s)}}))}}};var Ot={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:"onEntry",onReadEntry:"onEntry"},y=i=>{let e=Object.assign(Object.create(null),i);for(let[t,s]of Object.entries(Ot))e[t]!==void 0&&(e[s]??=e[t]),delete e[t];return e.noChmod===!1&&(e.chmod??=!0),delete e.noChmod,e};var z=i=>{if(i.length===1)return i[0].slice();let e=0;for(let n of i)e+=n.length;let t=new Uint8Array(e),s=0;for(let n of i)t.set(n,s),s+=n.length;return t};var k=(i,e)=>Object.assign(Object.create(null),i,e),V=(i,e,t)=>{if(e==null||e===0)return t;if(e===1/0||Number.isInteger(e)&&Number(e)>0)return e;throw new TypeError(`${i} must be a positive integer`)};var Xi=new Set(["File","OldFile","Link","SymbolicLink","CharacterDevice","BlockDevice","Directory","FIFO","ContiguousFile","GNUDumpDir"]),Ne=i=>i.replaceAll("\\","/"),q=class{header;extended;globalExtended;type;path;mode;uid;gid;uname;gname;size;mtime;atime;ctime;linkpath;devmaj;devmin;dev;ino;nlink;absolute;ignore;invalid=!1;unsupported=!1;constructor(e,t,s,n=!1){if(!e.path)throw new Error("no path provided for tar.ReadEntry");this.header=e,this.extended=t,this.globalExtended=s,this.type=e.type,this.ignore=!Xi.has(this.type),this.path=n?Ne(e.path):e.path,this.mode=e.mode&&e.mode&4095,this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=e.size??0,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?n?Ne(e.linkpath):e.linkpath:void 0,this.devmaj=e.devmaj,this.devmin=e.devmin,s&&this.#e(s),t&&(this.#e(t),t.path!=null&&(this.path=n?Ne(t.path):t.path),t.linkpath!=null&&(this.linkpath=n?Ne(t.linkpath):t.linkpath))}#e(e){e.uid!=null&&(this.uid=e.uid),e.gid!=null&&(this.gid=e.gid),e.uname!=null&&(this.uname=e.uname),e.gname!=null&&(this.gname=e.gname),e.mtime!=null&&(this.mtime=e.mtime),e.atime!=null&&(this.atime=e.atime),e.ctime!=null&&(this.ctime=e.ctime),e.dev!=null&&(this.dev=e.dev),e.ino!=null&&(this.ino=e.ino),e.nlink!=null&&(this.nlink=e.nlink)}},Pt=new TextDecoder,zt=i=>{let e="";for(let t of i)e+=Pt.decode(t,{stream:!0});return e+Pt.decode()},Ft=()=>new TypeError("Body has already been consumed"),fe=class extends q{#e;#t=!1;#i;constructor(e,t,s,n,r){super(e,t,s,n),this.#e=r}get bodyUsed(){return this.#t}get body(){if(this.#i)return this.#i;let e=!1;return this.#i=new ReadableStream({pull:async t=>{e||(this.#n(),e=!0);let[s]=await this.#s(1);s?t.enqueue(s):t.close()}},{highWaterMark:0})}#n(){if(this.#t)throw Ft();this.#t=!0}#r(e,t=1/0){let s=this.#e;for(;s&&e.length<t;){let n=s.readBody(this);if(n===null)break;if(n===void 0)return!1;e.push(n)}return!0}async#s(e){let t=[];for(;!this.#r(t,e);)await this.#e?.fill();return t}async bytes(){this.#n();let e=[];for(;!this.#r(e);)await this.#e?.fill();return z(e)}async arrayBuffer(){return(await this.bytes()).buffer}async text(){return this.#n(),zt(await this.#s())}async blob(){return this.#n(),new Blob(await this.#s())}},me=class extends q{#e;#t=!1;#i;constructor(e,t,s,n,r){super(e,t,s,n),this.#e=r}get bodyUsed(){return this.#t}get body(){return this.#i??=this.#n()}*#n(){this.#r();for(let e;e=this.#e?.readBody(this);)yield e}#r(){if(this.#t)throw Ft();this.#t=!0}#s(){this.#r();let e=[];for(let t;t=this.#e?.readBody(this);)e.push(t);return e}bytes(){return z(this.#s())}arrayBuffer(){return this.bytes().buffer}text(){return zt(this.#s())}};var Nt=(i,e,t,s)=>(i.file&&(s.file=i.file),s.code=typeof t=="object"&&t.code||e,s.tarCode=e,s),at=(i,e,t,s={})=>Object.assign(typeof t=="object"?t:new Error(`${e}: ${t}`),Nt(i,e,t,s)),S=(i,e,t,s={})=>{let n=Object.hasOwn(s,"recoverable")&&s.recoverable===!1;if(i.strict||n)throw at(i,e,t,s);Nt(i,e,t,s),typeof t=="object"&&(s=Object.assign(t,s),t=t.message),i.onwarn?.(e,t,s)};var Ut=0,ie=1,Ue=2,Ce=3,Ct=4,ct={type:"entryEnd"},Zi={type:"end"},Ji=new Set(["ExtendedHeader","OldExtendedHeader","GlobalExtendedHeader","NextFileHasLongPath","OldGnuLongPath","NextFileHasLongLinkpath"]),Lt=i=>{let e=i.indexOf(0);return U(i,0,e===-1?i.length:e)},B=class{maxMetaEntrySize;position=0;offset=0;#e;#t;#i;#n=[];#r;#s=0;#o;#a=0;#c=Ut;#h;#d;#w;#y=0;#p=0;#l=0;#m;#g;#b;#x;#k=!1;#u;#f=!1;#S=0;constructor(e={},t){e=this.#e=k(e),this.maxMetaEntrySize=e.maxMetaEntrySize||1024*1024,this.#t=e.filter;let s=e.platform==="win32";this.#i=t??((n,r,o)=>new q(n,r,o,s))}warn(e,t,s){S(this.#e,e,t,s)}push(e){this.#k||this.#n.push(e)}end(){this.#k=!0}get bodyRemain(){let e=this.#r,t=this.#c;return t!==Ue&&t!==Ce||this.#n.length||e&&this.#s<e.length?0:this.#l}skipBody(){this.#f=this.#c===Ue,this.offset+=this.#l,this.#p=this.#l=0,this.#E()}next(){if(this.#f)return this.#f=!1,ct;for(;;){let e=this.#r,t=this.#s;if(!e||t===e.length){if(e=this.#r=this.#n.shift(),t=this.#s=0,!e){if(!this.#k||this.#S===2)return;let l=this.#R();if(l)return l}continue}let s=e.length-t,n=this.#c;if(n<=ie){let l;if(this.#a===0&&s>=512)this.#s=t+512,l=this.#v(e,t);else{let d=this.#o??=new Uint8Array(512),p=Math.min(512-this.#a,s);if(d.set(e.subarray(t,t+p),this.#a),this.#s=t+p,this.#a+=p,this.#a<512)continue;this.#a=0,l=this.#v(d,0)}if(l)return l;continue}let r=this.#l,o=s<r?s:r,a=this.#p,c=o<a?o:a;this.#s=t+o,this.offset+=o,this.#l=r-o,this.#p=a-c;let h=o===r;if(n===Ct){let l=this.#w;l.set(e.subarray(t,t+c),this.#y),this.#y+=c,h&&(this.#E(),this.#A(l));continue}if(h&&this.#E(),n!==Ce){if(c===0){if(h)return ct;continue}return this.#f=h,{type:"body",data:c===e.length?e:e.subarray(t,t+c)}}}}#E(){let e=this.#h;e&&(this.position=this.offset,this.#h=void 0),e?.invalid||(this.#u=!0),this.#c=ie}#R(){let e=this.#c;if(e>ie){let t=this.#h,s=(512-this.#l%512)%512,n=this.#l+s;this.#h=void 0,this.#w=void 0,this.#c=ie,t?.invalid||(this.#u=!0),this.#f=e===Ue,this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${n} more bytes, only ${s} available)`,{entry:t,header:this.#d});return}return this.#f?(this.#f=!1,ct):(this.#S===0&&(this.#S=1,(e===Ut||this.#u===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")),this.#S=2,Zi)}#v(e,t){this.offset+=512,this.#u===void 0&&(this.#u=!1);let s=this.#m,n=this.#g,r=this.#b;(n!==void 0||r!==void 0)&&(s=Object.assign(Object.create(null),s),s.path??=n,s.linkpath??=r);let o;try{o=new R(e,t,s,this.#x)}catch(d){this.warn("TAR_ENTRY_INVALID",d);return}if(o.nullBlock){this.#k=!0,this.#r=void 0,this.#n.length=0,this.#a=0,this.#c=ie;return}if(!o.cksumValid){this.warn("TAR_ENTRY_INVALID","checksum failure",{header:o});return}if(!o.path){this.warn("TAR_ENTRY_INVALID","path is required",{header:o});return}let a=o.type,c=a==="Link"||a==="SymbolicLink";if(c&&!o.linkpath){this.warn("TAR_ENTRY_INVALID","linkpath required",{header:o});return}if(!c&&o.linkpath&&a!=="ExtendedHeader"&&a!=="GlobalExtendedHeader"){this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:o});return}let h=o.size??0;if(this.#d=o,this.#p=h,this.#l=512*Math.ceil(h/512),h||(this.#u=!0),Ji.has(a)){h>this.maxMetaEntrySize?this.#c=Ce:h>0&&(this.#w=new Uint8Array(h),this.#y=0,this.#c=Ct);return}this.#m=this.#g=this.#b=void 0;let l=this.#i(o,s,this.#x);return!l.ignore&&this.#t&&!this.#t(l.path,l)&&(l.ignore=!0),h?(this.#h=l,this.#c=l.ignore?Ce:Ue):(this.#c=ie,this.position=this.offset,this.#f=!l.ignore),{type:"entry",entry:l}}#A(e){switch(this.#d.type){case"ExtendedHeader":case"OldExtendedHeader":this.#m=I.parseBytes(e,this.#m,!1);break;case"GlobalExtendedHeader":this.#x=I.parseBytes(e,this.#x,!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":this.#g=Lt(e);break;default:this.#b=Lt(e)}}};var Qi=16*1024*1024,Dt=64*1024,es=1024*1024,De=Symbol.for("tar.readFile.skip"),Le=class{pos=0;size=0;#e;#t=Dt;constructor(e){this.#e=V("maxReadSize",e,Qi)}next(){let e=Math.min(this.#t,this.#e,this.size-this.pos);return this.#t*=2,e}skip(e){return e<es||this.pos+e>this.size?!1:(this.pos+=e,this.#t=Dt,!0)}};async function*ts(i,e,t){let s=await i.open(e,"r");try{t.size=(await s.stat()).size;for(let n;n=t.next();){let r=new Uint8Array(n),{bytesRead:o}=await s.read(r,0,n,t.pos);if(!o)break;t.pos+=o,yield o<n?r.subarray(0,o):r}}finally{await s.close().catch(()=>{})}}function*is(i,e,t){let s=i.openSync(e,"r");try{t.size=i.fstatSync(s).size;for(let n;n=t.next();){let r=new Uint8Array(n),o=i.readSync(s,r,0,n,t.pos);if(!o)break;t.pos+=o,yield o<n?r.subarray(0,o):r}}finally{try{i.closeSync(s)}catch{}}}var H=(i,e,t)=>{let s=new Le(t);return Object.assign(ts(i,e,s),{[De]:n=>s.skip(n)})},$=(i,e,t)=>{let s=new Le(t);return Object.assign(is(i,e,s),{[De]:n=>s.skip(n)})};var ht=()=>{},we=i=>Math.max(512,...i.map(e=>e.headLength)),ss=i=>{try{let e=new R(i);return e.cksumValid||e.nullBlock}catch{return!1}},ye=(i,e,t="")=>i.find(s=>s.detect(e))??(ss(e)?void 0:i.find(s=>s.extensions?.some(n=>t.endsWith(n)))),_t=i=>typeof i.maxDecompressionRatio=="number"?i.maxDecompressionRatio:1e3,_e=(i,e)=>at(i,"TAR_ABORT",e,{recoverable:!1}),Mt=(i,e,t)=>_e(i,new Error(`max decompression ratio exceeded: ${e.toFixed(2)} > ${t}`)),ns=()=>new TypeError("The body of an entry cannot be read after a later entry"),ue=class{parser;current;ended=!1;constructor(e){this.parser=e}entry(){if(this.current=void 0,this.ended)return null;for(let e;e=this.parser.next();){if(e.type==="end")return this.ended=!0,null;if(e.type==="entry"&&!e.entry.ignore)return this.current=e.entry}}body(e){if(e!==this.current)throw ns();let t=this.parser.next();if(t)return t.type==="body"?t.data:(this.current=void 0,null)}},It=(i,e)=>{if(i.current)return;let t=i.parser.bodyRemain;t&&e[De]?.(t)&&i.parser.skipBody()},rs=i=>{if(v(i))return[i].values();if(tt(i))return[new Uint8Array(i)].values();if(N(i)&&(i=i.stream()),Pe(i)){let e=i.getReader();return{next:()=>e.read(),return:()=>e.cancel()}}return Symbol.asyncIterator in i?i[Symbol.asyncIterator]():i[Symbol.iterator]()},b=class{parser;#e;#t;#i;#n;#r;#s;#o=!1;constructor(e,t={}){t=k(t);let s=t.platform==="win32";this.parser=new B(t,(n,r,o)=>new fe(n,r,o,s,this)),this.#e=new ue(this.parser),this.#t=t,this.#i=rs(e)}poll(){return this.#o?null:this.#e.entry()}readBody(e){return this.#e.body(e)}fill(){return this.#s??=this.#a()}async#a(){try{let e=this.#n??=await this.#c(this.#i),t=this.#r;this.#r=void 0,e===this.#i&&It(this.#e,e);let s=t?{value:t,done:!1}:await e.next();s.done?this.parser.end():this.parser.push(s.value)}finally{this.#s=void 0}}async#c(e){let t=this.#t,s=[...t.codecs??[],T],n=we(s),r;for(;!r||r.length<n;){let u=await e.next();if(u.done)break;r=r?z([r,u.value]):u.value}let o=r&&ye(s,r,t.file);if(!o)return this.#r=r,e;let a=0,c=0,{readable:h,writable:l}=o.decompress(),d=l.getWriter(),p=h.getReader(),f=!1;(async()=>{try{for(;;){if(await d.ready,f)return;let u=r?{value:r,done:!1}:await e.next();if(r=void 0,f)return;if(u.done)return await d.close();a+=u.value.length,await d.write(u.value)}}catch(u){f||await d.abort(u).catch(ht)}})();let m=_t(t);return{next:async()=>{let u=await p.read().catch(g=>{throw _e(t,g)});if(!u.done){c+=u.value.length;let g=c/a;if(g>m)throw Mt(t,g,m)}return u},return:async()=>(f=!0,await p.cancel().catch(ht),await d.abort().catch(ht),await e.return?.(),{value:void 0,done:!0})}}async next(){try{for(;;){let e=this.poll();if(e)return{value:e,done:!1};if(e===null)break;await this.fill()}}catch(e){throw await this.return(),e}return this.return()}async return(){return this.#o||(this.#o=!0,this.#e.current=void 0,await(this.#n??this.#i).return?.()),{value:void 0,done:!0}}[Symbol.asyncIterator](){return this}},E=class{parser;#e;#t;#i;#n;#r;#s=!1;constructor(e,t={}){t=k(t);let s=t.platform==="win32";this.parser=new B(t,(n,r,o)=>new me(n,r,o,s,this)),this.#e=new ue(this.parser),this.#t=t,this.#i=v(e)?[e].values():tt(e)?[new Uint8Array(e)].values():e[Symbol.iterator]()}readBody(e){for(;;){let t=this.#e.body(e);if(t!==void 0)return t;this.#o()}}#o(){let e=this.#n??=this.#a(this.#i),t=this.#r;this.#r=void 0,e===this.#i&&It(this.#e,e);let s=t?{value:t,done:!1}:e.next();s.done?this.parser.end():this.parser.push(s.value)}#a(e){let t=this.#t,s=[...t.codecs??[],T],n=we(s),r,o;for(;(!r||r.length<n)&&!(o=e.next()).done;)r=r?z([r,o.value]):o.value;let a=r&&ye(s,r,t.file);if(!r||!a)return this.#r=r,e;let{decompressSync:c}=a;if(!c)throw _e(t,new Error(`the ${a.name} codec has no decompressSync function`));let h=[r];for(;!(o=e.next()).done;)h.push(o.value);let l=z(h),d=_t(t),p;try{p=c(l,{maxOutputLength:l.length*d})}catch(w){throw _e(t,w)}let f=p.length/l.length;if(f>d)throw Mt(t,f,d);return[p].values()}next(){try{for(;;){let e=this.#s?null:this.#e.entry();if(e)return{value:e,done:!1};if(e===null)break;this.#o()}}catch(e){throw this.return(),e}return this.return()}return(){return this.#s||(this.#s=!0,this.#e.current=void 0,(this.#n??this.#i).return?.()),{value:void 0,done:!0}}[Symbol.iterator](){return this}},lt=(i,e)=>new b(i,e),Bt=(i,e)=>new E(i,e);var Ht=(i,e,t)=>(i&=4095,t&&(i=(i|384)&-19),e&&(i&256&&(i|=64),i&32&&(i|=8),i&4&&(i|=1)),i);var Me=["|","<",">","?",":"],dt=Me.map(i=>String.fromCodePoint(61440+Number(i.codePointAt(0)))),os=new Map(Me.map((i,e)=>[i,dt[e]])),as=new Map(dt.map((i,e)=>[i,Me[e]])),pt=i=>Me.reduce((e,t)=>e.split(t).join(os.get(t)),i),$t=i=>dt.reduce((e,t)=>e.split(t).join(as.get(t)),i);var K=i=>i===47||i===92,cs=i=>i>=65&&i<=90||i>=97&&i<=122,j=i=>{let e=i.length,t=0;if(K(i.charCodeAt(0))){if(t=1,K(i.charCodeAt(1))){let s=2,n=s;for(;s<e&&!K(i.charCodeAt(s));)s++;if(s<e&&s!==n){for(n=s;s<e&&K(i.charCodeAt(s));)s++;if(s<e&&s!==n){for(n=s;s<e&&!K(i.charCodeAt(s));)s++;s===e?t=s:s!==n&&(t=s+1)}}}}else cs(i.charCodeAt(0))&&i.charCodeAt(1)===58&&(t=K(i.charCodeAt(2))?3:2);return i.slice(0,t)},ge=i=>K(i.charCodeAt(0))||j(i).length===3,Ie=(i,e)=>{let t=ge(e)?e:i+"/"+e,s=j(t);return s+C("/",t.slice(s.length)).slice(1)},Gt=i=>{let e=j(i),t=P(i.slice(e.length));return t==="."?e:e+t};var Be=i=>{let e="";for(let t;t=j(i);)i.charAt(0)==="/"&&i.slice(0,4)!=="//?/"&&(t="/"),i=i.slice(t.length),e+=t;return[e,i]};var He=i=>new ReadableStream({pull:async e=>{let t=await i.next();t.done?e.close():e.enqueue(t.value)},cancel:async()=>{await i.return?.()}},{highWaterMark:0});var X=i=>{let e=i.length-1,t=-1;for(;e>-1&&i.charAt(e)==="/";)t=e,e--;return t===-1?i:i.slice(0,t)};var hs=new TextEncoder,Wt=(i,e)=>e?X(e)+"/"+i.replace(/^\.(\/|$)/,""):i,se=class{path;type;mode;uid;gid;uname;gname;size;mtime;atime;ctime;linkpath;dev;ino;nlink;body;absolute;header;constructor(e,t){if(e.type==="Unsupported")throw new Error("writing entry that should be ignored");if(typeof t=="string"&&(t=hs.encode(t)),this.path=e.path,this.type=e.type??"File",this.mode=e.mode,this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,e.size===void 0&&t!==void 0&&!v(t)&&!N(t))throw new TypeError("a stream body needs the size option");this.size=e.size??(v(t)?t.length:N(t)?t.size:0),this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath,this.dev=e.dev,this.ino=e.ino,this.nlink=e.nlink,this.body=t}encode(e={},t=new Uint8Array(512)){e=k(e);let s=Wt(this.path,e.prefix),n=this.type==="Link"&&this.linkpath!==void 0?Wt(this.linkpath,e.prefix):this.linkpath,{uid:r,gid:o,uname:a,gname:c,size:h,mtime:l,atime:d,ctime:p}=this;if(this.header=new R({path:s,linkpath:n,mode:this.mode,uid:r,gid:o,size:h,mtime:l,type:this.type,uname:a,gname:c,atime:d,ctime:p}),!this.header.encode(t)||e.noPax)return[t];let{dev:f,ino:w,nlink:m}=this;return[new I({atime:d,ctime:p,gid:o,gname:c,mtime:l,path:s,linkpath:n,size:h,uid:r,uname:a,dev:f,ino:w,nlink:m}).encode(),t]}};var ls=16*1024*1024,O=()=>{},xe=i=>512*Math.ceil(i/512),Z=i=>i.replaceAll("\\","/"),ft=i=>`${i.dev}:${i.ino}`,$e={bigint:!0},ds=({dev:i,ino:e})=>!Number.isSafeInteger(i)||!Number.isSafeInteger(e),je=(i,e)=>i.dev===e.dev&&i.ino===e.ino,mt=(i,e)=>Object.assign(new Error(i),{path:e,syscall:"read",code:"EOF"}),Xt=(i,e)=>mt(`encountered unexpected EOF: ${i} has fewer than the ${e} bytes of its stat`,i),Zt=(i,e)=>mt(`did not encounter expected EOF: ${i} has more than the ${e} bytes of its stat`,i),Jt=i=>i.absolute??i.path,ps=i=>Object.assign(new Error("writing more data than expected"),{path:Jt(i)}),Qt=i=>Symbol.asyncIterator in i||Symbol.iterator in i,fs=i=>typeof i.encode=="function",F=class{path;absolute;up;linkpath;ready;constructor(e,t){this.path=e,this.absolute=t}},ke=class{opt;fs;cwd;win32;maxReadSize;header;codec;codecOptions;ended=!1;head;tail;wake;#e=new Map;constructor(e,t){e=this.opt=k(e),this.fs=e.fs,this.win32=e.platform==="win32",this.maxReadSize=V("maxReadSize",e.maxReadSize,ls);let{prefix:s,noPax:n}=e;this.header={prefix:s&&this.win32?Z(s):s,noPax:n};let r=e.cwd&&(this.win32?Z(e.cwd):e.cwd);if(r&&!(this.win32?ge:te)(r))throw new TypeError("cwd must be an absolute path");this.cwd=r&&this.#t(r,"");let o=e,a=["gzip","brotli","zstd","compress"].filter(h=>o[h]);if(a.length>1)throw new TypeError(`${a.join(", ")} are mutually exclusive`);let[c]=a;if(c){let h=e.compress,[l,d]=h?Array.isArray(h)?h:[h]:[[...e.codecs??[],T].find(p=>p.name===c),o[c]];if(!l?.[t])throw new TypeError(`no codec named ${l?.name??c} has a ${t} function`);this.codec=l,this.codecOptions={...typeof d=="object"?d:void 0,...l.name==="gzip"&&e.portable?{portable:!0}:void 0}}}#t(e,t){return this.win32?Ie(e,t):C(e,t)}resolve(e){if(!this.cwd||!this.fs)throw new TypeError("a path needs the cwd and fs options");return this.#t(this.cwd,this.win32?Z(e):e)}add(e){if(this.ended)throw new Error("write after end");if(typeof e!="string")this.push(e);else{let t=this.win32?Z(e):e;this.push(new F(t||"./",this.resolve(t)))}return this}end(){return this.ended=!0,this.wake?.(),this}push(e){let t={item:e};this.tail?this.tail.next=t:this.head=t,this.tail=t,this.wake?.()}shift(){this.head=this.head?.next,this.head||(this.tail=void 0)}needsExact(e){return ds(e)&&(e.isDirectory()?!!this.opt.follow:e.isFile()&&e.nlink>1)}plan(e,t,s){let{filter:n}=this.opt;if(!(n&&!n(e.path,t))){if(t.isDirectory()){for(let r=e.up;r;r=r.up)if(r.key===ft(s)){S(this.opt,"TAR_ENTRY_ERROR","directory is its own ancestor",{path:e.path,absolute:e.absolute});return}return"Directory"}if(t.isSymbolicLink())return"SymbolicLink";if(!t.isFile()){S(this.opt,"TAR_ENTRY_UNSUPPORTED","unsupported file type",{path:e.path,absolute:e.absolute});return}if(t.nlink>1){let r=ft(s),o=this.#e.get(r),a=this.cwd;if(o!==e.absolute&&o?.startsWith(a.endsWith("/")?a:a+"/"))return e.linkpath=L(a,o),"Link";this.#e.set(r,e.absolute)}return"File"}}children(e,t,s){let n=e.path==="./"?"":e.path.replace(/\/*$/,"/"),r=e.absolute.endsWith("/")?e.absolute:e.absolute+"/",o=this.opt.follow?{key:ft(s),up:e.up}:void 0;return[...t].sort().map(a=>{let c=new F(n+a,r+a);return c.up=o,c})}missing(e,t){if(t?.code!=="ENOENT")throw t;S(this.opt,"TAR_ENTRY_ERROR",t,{path:e.path,absolute:e.absolute})}changed(e,t){S(this.opt,"TAR_ENTRY_ERROR",t==="Directory"?"directory changed between lstat and readdir":"file changed between lstat and open",{path:e.path,absolute:e.absolute})}pathEntry(e,t,s,n,r){let{processUid:o,processUname:a=""}=this.opt,c=new se({path:e.path,type:s,mode:t.mode,uid:t.uid,gid:t.gid,uname:t.uid===o?a:"",size:s==="File"?t.size:0,mtime:t.mtime,atime:t.atime,ctime:t.ctime,linkpath:n&&this.win32?Z(n):n,dev:t.dev,ino:t.ino,nlink:t.nlink},r);return c.absolute=e.absolute,this.#i(c,!0)}addedEntry(e){if(fs(e))return this.#i(e,!1);let{filter:t}=this.opt;if(!(t&&!t(e.path,e)))return this.#i(new se(e,e.body),!1)}#i(e,t){let{opt:s,win32:n}=this,r=e.type==="Directory";n&&!t&&(e.path=Z(e.path),e.linkpath&&(e.linkpath=Z(e.linkpath)));let[o,a]=s.preservePaths?["",e.path]:Be(e.path);return e.path=a,t&&(n&&(e.path=$t(e.path)),e.path===""&&(e.path="./")),o&&S(s,"TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:e,path:o+e.path}),t&&r&&!e.path.endsWith("/")&&(e.path+="/"),s.portable&&(e.uid=e.gid=e.dev=e.ino=e.nlink=void 0,e.uname=e.gname=void 0,e.atime=e.ctime=void 0),e.mode!==void 0&&(e.mode=Ht(e.mode,r,!!s.portable)),e.mtime=s.noMtime||s.portable&&r?void 0:s.mtime||e.mtime,e}},Yt=async(i,e,t,s,n,r)=>{for(;t<e.length&&s<n;){let{bytesRead:o}=await i.read(e,t,e.length-t,s);if(o<=0)throw Xt(r,n);if(o>n-s)throw Zt(r,n);t+=o,s+=o}return s},Vt=(i,e,t,s,n,r,o)=>{for(;s<t.length&&n<r;){let a=i.readSync(e,t,s,t.length-s,n);if(a<=0)throw Xt(o,r);if(a>r-n)throw Zt(o,r);s+=a,n+=a}return n};async function*ms(i){if(v(i))yield i;else if(N(i)||Pe(i)){let e=(N(i)?i.stream():i).getReader();try{for(;;){let t=await e.read();if(t.done)break;yield t.value}}finally{await e.cancel().catch(O)}}else i&&(yield*i)}function*us(i){if(v(i))yield i;else if(i&&Symbol.iterator in i)yield*i;else if(i)throw new TypeError("PackSync needs a body that is a string, a Uint8Array, or an iterable")}var ei=(i,e,t)=>{if(t.length>e)throw ps(i);return e-t.length},ti=(i,e)=>{if(e)throw mt("encountered unexpected EOF",Jt(i));return new Uint8Array(xe(i.size)-i.size)};async function*qt(i){if(!i.size)return;let e=i.size;for await(let s of ms(i.body))e=ei(i,e,s),yield s;let t=ti(i,e);t.length&&(yield t)}function*Kt(i){if(!i.size)return;let e=i.size;for(let s of us(i.body))e=ei(i,e,s),yield s;let t=ti(i,e);t.length&&(yield t)}var Se=class extends ke{jobs;#e;#t=Promise.resolve();constructor(e={}){super(e,"compress"),this.jobs=V("jobs",this.opt.jobs,4)}async next(){let e=await(this.#e??=this.#i()).next();return e.done?{value:void 0,done:!0}:e}async return(){return this.end(),await this.#e?.return(),{value:void 0,done:!0}}[Symbol.asyncIterator](){return this}#i(){let{codec:e}=this;return e?.compress?this.#n(e.compress(this.codecOptions)):this.#r()}async*#n(e){let t=this.#r(),s,n=He({next:()=>t.next().catch(r=>{throw s={er:r},n.cancel().catch(O),r})}).pipeThrough(e).getReader();try{for(;;){let r=await n.read();if(s)throw s.er;if(r.done)break;yield r.value}}finally{await n.cancel().catch(O),await t.return()}}async*#r(){try{for(;;){let e=this.head;if(!e){if(this.ended)break;await new Promise(s=>this.wake=s);continue}this.#s();let{item:t}=e;if(t instanceof F)yield*this.#c(t);else if(!Qt(t))yield*this.#d(t);else for await(let s of t)yield*this.#d(s);this.shift()}yield new Uint8Array(1024)}finally{for(let e=this.head;e;e=e.next){let{item:t}=e;if(!(t instanceof F)||!t.ready)break;await(await t.ready.catch(O))?.handle?.close().catch(O)}}}#s(){let e=this.fs,t=this.head;for(let s=0;t&&s<this.jobs;s++,t=t.next){let n=t.item;if(!(n instanceof F))break;if(n.ready)continue;let r=this.#o(e,n.absolute);r.catch(O);let o=this.#t.then(()=>r).then(([a,c])=>{let h=this.plan(n,a,c);return h&&{load:this.#a(e,n,a,c,h)}},a=>this.missing(n,a));this.#t=o.catch(O),n.ready=o.then(a=>a?.load),n.ready.catch(O)}}async#o(e,t){let{follow:s}=this.opt,n=await(s?e.stat(t):e.lstat(t)),r=this.needsExact(n)?await(s?e.stat(t,$e):e.lstat(t,$e)):n;return[n,r]}async#a(e,t,s,n,r){let{absolute:o}=t,{follow:a,noDirRecurse:c}=this.opt,h={stat:s,id:n,type:r};if(r==="SymbolicLink")h.linkpath=await e.readlink(o);else if(r==="Directory"&&!c)h.names=await e.readdir(o),h.changed=!a&&!je(s,await e.lstat(o));else if(r==="File"&&s.size){let l=await e.open(o,"r");try{let{size:d}=s,p=xe(d);!a&&!je(s,await l.stat())?h.changed=!0:p>this.maxReadSize?h.handle=l:(h.buf=new Uint8Array(512+p),await Yt(l,h.buf,512,0,d,o))}catch(d){throw await l.close().catch(O),d}h.handle||await l.close()}return h}async*#c(e){let t=await e.ready;if(!t)return;let{stat:s,id:n,type:r,names:o,buf:a,handle:c}=t;if(t.changed)return this.changed(e,r);let h=!1;try{let l=a?a.subarray(512,512+s.size):c&&this.#h(c,s.size,e.absolute),d=this.pathEntry(e,s,r,t.linkpath??e.linkpath,l);if(o)for(let f of this.children(e,o,n))this.push(f);await this.opt.onWriteEntry?.(d);let p=a&&d.body===l&&d.size===s.size;yield*d.encode(this.header,p?a:void 0),p||(yield*qt(d)),h=!0}finally{if(c){t.handle=void 0;let l=c.close();await(h?l:l.catch(O))}}}async*#h(e,t,s){let n=xe(t);for(let r=0;r<t;){let o=new Uint8Array(Math.min(n-r,this.maxReadSize)),a=await Yt(e,o,0,r,t,s);yield o.subarray(0,a-r),r=a}}async*#d(e){let t=this.addedEntry(e);t&&(await this.opt.onWriteEntry?.(t),yield*t.encode(this.header),yield*qt(t))}},be=class extends ke{#e;constructor(e={}){super(e,"compressSync")}next(){let e=(this.#e??=this.#t()).next();return e.done?{value:void 0,done:!0}:e}return(){return this.ended=!0,this.#e?.return(),{value:void 0,done:!0}}[Symbol.iterator](){return this}*#t(){let{codec:e}=this;if(!e?.compressSync)return yield*this.#i();yield e.compressSync(z([...this.#i()]),this.codecOptions)}*#i(){for(let e;e=this.head;this.shift()){let{item:t}=e;if(t instanceof F){let s=[t];for(let n of s)yield*this.#n(n,s)}else if(!Qt(t))yield*this.#s(t);else for(let s of t)yield*this.#s(s)}this.ended=!0,yield new Uint8Array(1024)}*#n(e,t){let s=this.fs,{absolute:n}=e,{follow:r,noDirRecurse:o}=this.opt,a;try{a=r?s.statSync(n):s.lstatSync(n)}catch(m){return this.missing(e,m)}let c=this.needsExact(a)?r?s.statSync(n,$e):s.lstatSync(n,$e):a,h=this.plan(e,a,c);if(!h)return;let{linkpath:l}=e,d,p,f,w=!1;try{if(h==="SymbolicLink")l=s.readlinkSync(n);else if(h==="Directory"&&!o){let g=s.readdirSync(n);if(!r&&!je(a,s.lstatSync(n)))return this.changed(e,h);t.push(...this.children(e,g,c))}else if(h==="File"&&a.size){let{size:g}=a,Et=xe(g);if(f=s.openSync(n,"r"),!r&&!je(a,s.fstatSync(f)))return this.changed(e,h);Et>this.maxReadSize?p=this.#r(s,f,g,n):(d=new Uint8Array(512+Et),Vt(s,f,d,512,0,g,n),p=d.subarray(512,512+g))}let m=this.pathEntry(e,a,h,l,p);this.opt.onWriteEntry?.(m);let u=d&&m.body===p&&m.size===a.size;yield*m.encode(this.header,u?d:void 0),u||(yield*Kt(m)),w=!0}finally{if(f!==void 0&&!w)try{s.closeSync(f)}catch{}}f!==void 0&&s.closeSync(f)}*#r(e,t,s,n){let r=xe(s);for(let o=0;o<s;){let a=new Uint8Array(Math.min(r-o,this.maxReadSize)),c=Vt(e,t,a,0,o,s,n);yield a.subarray(0,c-o),o=c}}*#s(e){let t=this.addedEntry(e);t&&(this.opt.onWriteEntry?.(t),yield*t.encode(this.header),yield*Kt(t))}};var Ee=64*1024,Ge=4*Ee,ws=()=>{},ut=(i,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive");if(i.file&&!i.fs)throw new TypeError("the file option needs the fs option")},ii=async(i,e,t,s)=>{for(let n=0;n<t;)n+=(await i.write(e,n,t-n,s+n)).bytesWritten},wt=async(i,e,t)=>{let s=new Uint8Array(Ge),n=0,r=async()=>{await ii(i,s,n,t),t+=n,n=0};for await(let o of e)(n+o.length>Ge||o.length>=Ee)&&await r(),o.length>=Ee?(await ii(i,o,o.length,t),t+=o.length):(s.set(o,n),n+=o.length);await r()},yt=(i,e,t,s)=>{let n=new Uint8Array(Ge),r=0,o=(a,c)=>{for(let h=0;h<c;)h+=i.writeSync(e,a,h,c-h,s+h);s+=c};for(let a of t)(r+a.length>Ge||a.length>=Ee)&&(o(n,r),r=0),a.length>=Ee?o(a,a.length):(n.set(a,r),r+=a.length);o(n,r)},ys=async(i,e,t,s)=>{let n=await e.open(t,"w",s),r=!1;try{await wt(n,i,0),r=!0}finally{let o=n.close();await(r?o:o.catch(ws))}},We=(i,e)=>{let{fs:t,strict:s,onwarn:n,codecs:r,platform:o}=i,a=new Se(i);for(let c of e)if(typeof c!="string"||c.charAt(0)!=="@")a.add(c);else{let h=a.resolve(c.slice(1));a.add(new b(H(t,h,i.maxReadSize),{strict:s,onwarn:n,codecs:r,platform:o,file:h}))}return a.end()},gt=(i,e)=>{let{strict:t,onwarn:s,codecs:n,platform:r}=i,o=new be(i);for(let a of e)if(typeof a!="string"||a.charAt(0)!=="@")o.add(a);else{let c=o.resolve(a.slice(1));o.add(new E($(i.fs,c,i.maxReadSize),{strict:t,onwarn:s,codecs:n,platform:r,file:c}))}return o};function ne(i,e){let t=y(i);if(!t.file)return ut(t,e),He(We(t,e));try{return ut(t,e),ys(We(t,e),t.fs,t.file,t.mode||438)}catch(s){return Promise.reject(s)}}function Ye(i,e){let t=y(i);ut(t,e);let{file:s}=t,n=t.fs,r=gt(t,e);if(!s)return r;let o=n.openSync(s,"w",t.mode||438);try{yt(n,o,r,0)}catch(a){try{n.closeSync(o)}catch{}throw a}n.closeSync(o)}var J=(i,e)=>{let t=new Set(i.map(o=>X(o))),s=new Set(t),n=0;for(let o of t)n=Math.max(n,o.length);let r=o=>{let a=X(o),c=a.charAt(0)==="/"?"/":".",h=!1;for(let l=a.length;l>0;l=a.lastIndexOf("/",l-1)){if(l>n)continue;let d=a.slice(0,l);if(!(d===c||!t.has(d))&&(h=!0,s.delete(d),!s.size))break}return h};return[(o,a)=>{let c=!e||e(o,a);return r(o)&&c},o=>{for(let a of s)S(o,"TAR_ENTRY_ERROR",`${a}: not found in archive`,{path:a})}]},si=()=>new TypeError("list needs input, or file and fs"),Ve=async(i,e)=>{let t=y(i),{input:s,file:n,fs:r,onEntry:o}=t,a=s??(n&&r?H(r,n,t.maxReadSize):void 0);if(!a)throw si();let[c,h]=e?.length?J(e,t.filter):[];c&&(t.filter=c);let l=new b(a,t);try{for(;;){let d=l.poll();if(d===null)break;d===void 0?await l.fill():o&&await o(d)}}finally{await l.return()}h?.(t)},ni=(i,e)=>{let t=y(i),{input:s,file:n,fs:r,onEntry:o}=t,a=s??(n&&r?$(r,n,t.maxReadSize):void 0);if(!a)throw si();let[c,h]=e?.length?J(e,t.filter):[];c&&(t.filter=c);let l=new E(a,t);for(let d of l)o?.(d);h?.(t)};var gs=()=>{},ri=(i,e)=>{if(!i.file)throw new TypeError("file is required");if(!i.fs)throw new TypeError("the file option needs the fs option");let t=[...i.codecs??[],T];if(e?.length)return[t,...J(e,i.filter)];if(i.filter)return[t,i.filter];throw new TypeError("no paths specified to delete")},oi=i=>`${i}.${Math.random().toString(36).slice(2)}.tmp`,xt=async(i,e)=>{let t=y(i),[s,n,r]=ri(t,e),{fs:o,file:a,filter:c,maxReadSize:h,...l}=t,d=new Uint8Array(we(s)),p=0,f=await o.open(a,"r");try{for(let u=1;u>0&&p<d.length;p+=u)u=(await f.read(d,p,d.length-p,p)).bytesRead}finally{await f.close()}let{mode:w}=await o.stat(a),m=oi(a);try{await ne({...l,fs:o,file:m,mode:w&511,compress:ye(s,d.subarray(0,p),a),preservePaths:!0,filter:(u,g)=>!n(u,g)},[new b(H(o,a,h),{...l,file:a})]),r?.(t),await o.rename(m,a)}catch(u){throw await o.unlink(m).catch(gs),u}},ai=(i,e)=>{let t=y(i),[s,n,r]=ri(t,e),{fs:o,file:a,filter:c,maxReadSize:h,...l}=t,d=new Uint8Array(we(s)),p=0,f=o.openSync(a,"r");try{for(let u=1;u>0&&p<d.length;p+=u)u=o.readSync(f,d,p,d.length-p,p)}finally{o.closeSync(f)}let{mode:w}=o.statSync(a),m=oi(a);try{Ye({...l,fs:o,file:m,mode:w&511,compress:ye(s,d.subarray(0,p),a),preservePaths:!0,filter:(u,g)=>!n(u,g)},[new E($(o,a,h),{...l,file:a})]),r?.(t),o.renameSync(m,a)}catch(u){try{o.unlinkSync(m)}catch{}throw u}};var re=class extends Error{path;code;syscall="chdir";constructor(e,t){super(`${t}: Cannot cd into '${e}'`),this.path=e,this.code=t}get name(){return"CwdError"}};var G=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(e,t){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=e,this.path=t}get name(){return"SymlinkError"}};var ci=i=>{let e=i.mode|448,{uid:t,gid:s}=i;return{mode:e,needChmod:(e&i.umask)!==0,owner:typeof t=="number"&&typeof s=="number"&&(t!==i.processUid||s!==i.processGid)?{uid:t,gid:s}:void 0}},hi=(i,e)=>i.endsWith("/")?i+e:i+"/"+e,li=(i,e)=>{let t=i.replaceAll("\\","/"),s=[e];for(let n=e.length;!t.endsWith(e.slice(0,n));){if(n=e.lastIndexOf("/",n-1),n<=0)return[e];s.push(e.slice(0,n))}return s},di=async(i,e,t)=>{let{mode:s,needChmod:n,owner:r}=ci(t),{cwd:o}=t,a=[];if(e===o){let c="ENOTDIR";if(!await i.stat(e).then(l=>l.isDirectory(),l=>(c=l?.code||c,!1)))throw new re(e,c)}else if(t.preserve){let c=await i.mkdir(e,{mode:s,recursive:!0});c&&(a=li(c,e))}else{let c=L(o,e).split("/"),h=o;for(let l=0;l<c.length;l++){h=hi(h,c[l]);try{await i.mkdir(h,{mode:s})}catch(d){let p=await i.lstat(h);if(p.isDirectory())continue;if(!t.unlink)throw p.isSymbolicLink()?new G(h,h+"/"+c.slice(l+1).join("/")):d;await i.unlink(h),await i.mkdir(h,{mode:s})}a.push(h)}}if(r)for(let c of a)await i.lchown(c,r.uid,r.gid);n&&await i.chmod(e,s)},pi=(i,e,t)=>{let{mode:s,needChmod:n,owner:r}=ci(t),{cwd:o}=t,a=[];if(e===o){let c="ENOTDIR",h=!1;try{h=i.statSync(e).isDirectory()}catch(l){c=l?.code||c}if(!h)throw new re(e,c)}else if(t.preserve){let c=i.mkdirSync(e,{mode:s,recursive:!0});c&&(a=li(c,e))}else{let c=L(o,e).split("/"),h=o;for(let l=0;l<c.length;l++){h=hi(h,c[l]);try{i.mkdirSync(h,{mode:s})}catch(d){let p=i.lstatSync(h);if(p.isDirectory())continue;if(!t.unlink)throw p.isSymbolicLink()?new G(h,h+"/"+c.slice(l+1).join("/")):d;i.unlinkSync(h),i.mkdirSync(h,{mode:s})}a.push(h)}}if(r)for(let c of a)i.lchownSync(c,r.uid,r.gid);n&&i.chmodSync(e,s)};var kt=Object.create(null),fi=1e4,oe=new Set,mi=i=>{oe.has(i)?oe.delete(i):kt[i]=i.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),oe.add(i);let e=kt[i],t=oe.size-fi;if(t>fi/10){for(let s of oe)if(oe.delete(s),delete kt[s],--t<=0)break}return e};var xs=i=>{let e=[];for(let t=i.indexOf("/");t!==-1;t=i.indexOf("/",t+1))e.push(i.slice(0,t)||"/");return e},ve=class{#e=new Map;#t=new Map;#i=new Set;#n;constructor(e=!1){this.#n=e}reserve(e,t){return new Promise((s,n)=>{let r=()=>{t().then(()=>{this.#o(r),s()},o=>{this.#o(r),n(o)})};this.#r(e,r)})}#r(e,t){e=this.#n?["win32 parallelization disabled"]:[...new Set(e.map(n=>X(W(mi(n)))))];let s=new Set(e.flatMap(xs));for(let n of e)s.delete(n);this.#t.set(t,{dirs:s,paths:e});for(let n of e){let r=this.#e.get(n);r?r.push(t):this.#e.set(n,[t])}for(let n of s){let r=this.#e.get(n),o=r?.[r.length-1];r?o instanceof Set?o.add(t):r.push(new Set([t])):this.#e.set(n,[new Set([t])])}this.#s(t)}#s(e){let{paths:t,dirs:s}=this.#t.get(e);for(let n of t)if(this.#e.get(n)?.[0]!==e)return;for(let n of s){let r=this.#e.get(n)?.[0];if(!(r instanceof Set)||!r.has(e))return}this.#i.add(e),e()}#o(e){let{paths:t,dirs:s}=this.#t.get(e),n=new Set;for(let r of t){let o=this.#e.get(r),a=o[1];if(!a){this.#e.delete(r);continue}if(o.shift(),typeof a=="function")n.add(a);else for(let c of a)n.add(c)}for(let r of s){let o=this.#e.get(r),a=o[0];a.size>1?a.delete(e):o.length===1?this.#e.delete(r):(o.shift(),n.add(o[0]))}this.#i.delete(e),this.#t.delete(e);for(let r of n)this.#s(r)}};var ui=(i,e)=>{if(!i)return()=>"w";let{O_CREAT:t,O_TRUNC:s,O_WRONLY:n,O_NOFOLLOW:r,UV_FS_O_FILEMAP:o}=i,a=s|t|n;if(!e){let h=typeof r=="number"?r|a:"w";return()=>h}if(!o)return()=>"w";let c=o|a;return h=>h<524288?c:"w"};var ks=1024,wi=32768,Ss=16,qe=new Set(["File","OldFile","ContiguousFile"]),ae=new Set(["Directory","GNUDumpDir"]),bs=new Set(["Link","SymbolicLink"]),yi=(i,e,t)=>i!==void 0?i:e!==void 0&&e===e>>>0?e:t,Re=class{opt;cwd;win32;strip;maxDepth;preservePaths;unlink;keep;newer;noMtime;chmod;uid;gid;preserveOwner;forceChown;processUid;processGid;processUmask;umask;dmode;fmode;writeFlag;resolve;dirname;fatal;constructor(e){let t=this.opt=k(e),s=this.win32=t.platform==="win32";if(this.resolve=s?Ie:C,this.dirname=s?Gt:P,typeof t.cwd!="string")throw new TypeError("cwd is required");let n=s?t.cwd.replaceAll("\\","/"):t.cwd;if(!(s?ge:te)(n))throw new TypeError("cwd must be an absolute path");if(this.cwd=this.resolve(n,""),typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.uid!==t.uid>>>0||t.gid!==t.gid>>>0)throw new TypeError("uid and gid must be unsigned 32-bit integers");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid}this.processUid=t.processUid,this.processGid=t.processGid,this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?t.processUid===0:!!t.preserveOwner,this.forceChown=t.forceChown===!0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:ks,this.strip=Number(t.strip)||0,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.keep=!!t.keep,this.newer=!!t.newer,this.noMtime=!!t.noMtime,this.chmod=!!t.chmod,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:18: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.writeFlag=ui(t.fs.constants,s)}warn(e,t,s={}){(e==="TAR_BAD_ARCHIVE"||e==="TAR_ABORT")&&(s.recoverable=!1),s.cwd=this.cwd,S(this.opt,e,t,s)}readerOptions(){return k(this.opt,{strict:!1,onwarn:(e,t,s)=>s instanceof Error?this.warn(e,s):this.warn(e,t,s)})}entryError(e,t){if(this.fatal?.error===e||e?.name==="CwdError")throw e;this.warn("TAR_ENTRY_ERROR",e,{entry:t})}fail(e){return this.fatal??={error:e},e}#e(e,t){let s=e[t];if(!s||this.preservePaths)return!0;let[n,r]=Be(s),o=r.replaceAll("\\","/").split("/");if(o.includes("..")){if(t==="path"||e.type==="Link")return this.warn("TAR_ENTRY_ERROR",`${t} contains '..'`,{entry:e,[t]:s}),!1;let a=o.findIndex(l=>l!==".."&&l!=="."&&l!=="");if(a!==-1&&o.includes("..",a))return this.warn("TAR_ENTRY_ERROR",`${t} contains '..' after a path portion`,{entry:e,[t]:s}),!1;let c=P(he(e.path)),h=he(W(c,o.join("/")));if(h.startsWith("../")||h==="..")return this.warn("TAR_ENTRY_ERROR",`${t} escapes extraction directory`,{entry:e,[t]:s}),!1}return n&&(e[t]=r,this.warn("TAR_ENTRY_INFO",`stripping ${n} from absolute ${t}`,{entry:e,[t]:s})),!0}check(e){let t=e.path,s=t.split("/");if(this.strip){if(s.length<this.strip)return!1;if(e.type==="Link"){let c=String(e.linkpath).split("/");if(c.length<this.strip)return!1;e.linkpath=c.slice(this.strip).join("/")}if(s.splice(0,this.strip),s.every(c=>c===""))return!1;e.path=s.join("/")}let{maxDepth:n}=this;if(isFinite(n)&&s.length>n)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:e,path:t,depth:s.length,maxDepth:n}),!1;let{linkpath:r}=e;if(r&&isFinite(n)&&r.split("/").length>n)return this.warn("TAR_ENTRY_ERROR","linkpath excessively deep",{entry:e,path:t,linkpath:r,maxDepth:n}),!1;for(let c of["path","linkpath"]){let{length:h}=e[c]??"";if(h>wi)return this.warn("TAR_ENTRY_ERROR",`${c} excessively long`,{entry:e,path:t,length:h,maxLength:wi}),!1}if(!this.#e(e,"path")||!this.#e(e,"linkpath"))return!1;let{cwd:o}=this,a=this.resolve(o,e.path);if(!this.preservePaths&&a!==o&&!a.startsWith(o.endsWith("/")?o:o+"/"))return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:e,path:e.path,resolvedPath:a,cwd:o}),!1;if(a===o&&!ae.has(e.type))return!1;if(this.win32){let c=j(a);a=c+pt(a.slice(c.length));let h=j(e.path);e.path=h+pt(e.path.slice(h.length))}if(e.absolute=a,typeof e.mode=="number"&&(e.mode&=511),ae.has(e.type))e.mode&&(e.mode|=448);else if(!qe.has(e.type)&&!bs.has(e.type))return e.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${e.type}`,{entry:e}),!1;return!0}reservedPaths(e){let{path:t,linkpath:s}=e;return s?[t,e.type==="SymbolicLink"&&!te(s)?W(P(t),s):s]:[t]}mkdirOptions(e){return{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}}owner(e){let t=this.forceChown||this.preserveOwner&&(typeof e.uid=="number"&&e.uid!==this.processUid||typeof e.gid=="number"&&e.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid,s=yi(this.uid,e.uid,this.processUid),n=yi(this.gid,e.gid,this.processGid);return t&&typeof s=="number"&&typeof n=="number"?{uid:s,gid:n}:void 0}times(e){return e.mtime&&!this.noMtime?{atime:e.atime||new Date,mtime:e.mtime}:void 0}skip(e,t){return this.keep||this.newer&&t.mtime>(e.mtime??t.mtime)}isReusable(e,t){return e.type==="File"&&!this.unlink&&t.isFile()&&t.nlink<=1&&!this.win32}linkParts(e,t){let s=String(e.linkpath);return e.type==="Link"?s.split("/"):L(this.cwd,this.resolve(this.dirname(t),s)).split("/")}parentParts(e){let{cwd:t}=this,s=e===t?t:this.dirname(e);return s===t?[]:L(t,s).split("/")}symlinkError(e,t){return new G(e,this.resolve(this.cwd,t.join("/")))}},gi=i=>i+".DELETE."+Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,"0")).join(""),Ae=class extends Re{#e;#t;#i;#n=0;#r;#s=!1;#o;constructor(e){super(e),this.#e=this.opt.fs,this.#t=new ve(this.win32),this.#i=V("jobs",this.opt.jobs,Ss)}async extract(e){let t=new b(e,this.readerOptions()),{onEntry:s}=this.opt,n=!!this.opt.transform;try{for(;!this.fatal;){let r=t.poll();if(r===null)break;if(r===void 0){await t.fill();continue}if(s&&await s(r),r.bodyUsed||!this.check(r))continue;let o=[],a=!n;if(a&&qe.has(r.type))for(;;){let h=t.readBody(r);if(h===null)break;if(h===void 0){a=!1;break}o.push(h)}let c=this.#c(r,o,a?void 0:t);for(a||await c;this.#n>=this.#i;)await this.#a()}}catch(r){this.fail(r)}for(await t.return().catch(r=>this.fail(r));this.#n>0;)await this.#a();if(this.fatal){let{error:r}=this.fatal;throw r&&typeof r=="object"&&"tarCode"in r&&Object.assign(r,{cwd:this.cwd}),r}}#a(){return new Promise(e=>{this.#r=e})}#c(e,t,s){return this.#n++,this.#t.reserve(this.reservedPaths(e),async()=>{try{this.fatal||await this.#w(e,t,s)}catch(n){try{this.entryError(n,e)}catch(r){this.fail(r)}}this.#n--,this.#r?.()})}#h(e,t){return di(this.#e,e,this.mkdirOptions(t))}#d(){return this.#o??=this.#h(this.cwd,this.dmode).then(()=>{this.#s=!0},e=>{throw this.#o=void 0,e})}async#w(e,t,s){let n=this.#e,r=e.absolute,{cwd:o}=this;if(this.#s||await this.#d(),r!==o){let c=this.dirname(r);c!==o&&await this.#h(c,this.dmode)}let a=await n.lstat(r).catch(()=>{});if(!(a&&this.skip(e,a))){if(a&&!this.isReusable(e,a)&&(a.isDirectory()&&ae.has(e.type)?this.chmod&&e.mode&&(a.mode&4095)!==e.mode&&await n.chmod(r,e.mode):r!==o&&(a.isDirectory()?await n.rmdir(r):await this.#y(r))),qe.has(e.type))return this.#m(e,r,t,s);if(ae.has(e.type))await this.#l(e,r);else{await this.#p(this.linkParts(e,r));let c=String(e.linkpath);e.type==="Link"?await n.link(this.resolve(o,c),r):await n.symlink(c,r)}await this.#p(this.parentParts(r))}}async#y(e){let t=this.#e;if(!this.win32)return t.unlink(e);let s=gi(e);await t.rename(e,s),await t.unlink(s)}async#p(e){if(this.preservePaths)return;let t=this.cwd;for(let s of e){t=this.resolve(t,s);let n=await this.#e.lstat(t).catch(()=>{});if(!n)return;if(n.isSymbolicLink())throw this.symlinkError(t,e)}}async#l(e,t){let s=this.#e;await this.#h(t,e.mode??this.dmode);let n=this.times(e);n&&await s.lutimes(t,n.atime,n.mtime).catch(()=>{});let r=this.owner(e);r&&await s.lchown(t,r.uid,r.gid).catch(()=>{})}async#m(e,t,s,n){let r=this.#e,o=await r.open(t,this.writeFlag(e.size),e.mode??this.fmode);try{if(await this.#p(this.parentParts(t)),n)await this.#g(e,s,n,o);else for(let h of s)await o.write(h);let a=this.times(e);if(a){let{atime:h,mtime:l}=a;await o.utimes(h,l).catch(async d=>{await r.utimes(t,h,l).catch(()=>{throw d})})}let c=this.owner(e);if(c){let{uid:h,gid:l}=c;await o.chown(h,l).catch(async d=>{await r.chown(t,h,l).catch(()=>{throw d})})}}catch(a){throw await o.close().catch(()=>{}),a}await o.close()}async#g(e,t,s,n){let r=0,o=async()=>{if(r<t.length)return t[r++];try{for(;;){let f=s.readBody(e);if(f!==void 0)return f;await s.fill()}}catch(f){throw this.fail(f)}},a=this.opt.transform?.(e);if(!a){let f,w;try{for(let m;(m=await o())&&(await f,!w);)f=n.write(m).then(()=>{},u=>{w={error:u}})}finally{await f}if(w)throw w.error;return}let c=a.writable.getWriter(),h=a.readable.getReader(),l,d=async f=>{l??={error:f},await h.cancel(f).catch(()=>{}),await c.abort(f).catch(()=>{})},p=(async()=>{try{for(let f;f=await o();)await c.write(f);await c.close()}catch(f){await d(f)}})();try{for(;;){let{done:f,value:w}=await h.read();if(f)break;await n.write(w)}}catch(f){await d(f)}if(await p,l)throw l.error}},Te=class extends Re{#e;#t=!1;constructor(e){super(e),this.#e=this.opt.fs}extract(e){let t=new E(e,this.readerOptions()),{onEntry:s}=this.opt;try{for(let n of t)if(s?.(n),!n.bodyUsed&&this.check(n))try{this.#n(n,t)}catch(r){this.entryError(r,n)}}catch(n){throw n&&typeof n=="object"&&"tarCode"in n&&Object.assign(n,{cwd:this.cwd}),n}}#i(e,t){pi(this.#e,e,this.mkdirOptions(t))}#n(e,t){let s=this.#e,n=e.absolute,{cwd:r}=this;if(this.#t||(this.#i(r,this.dmode),this.#t=!0),n!==r){let a=this.dirname(n);a!==r&&this.#i(a,this.dmode)}let o;try{o=s.lstatSync(n)}catch{}if(!(o&&this.skip(e,o))){if(o&&!this.isReusable(e,o)&&(o.isDirectory()&&ae.has(e.type)?this.chmod&&e.mode&&(o.mode&4095)!==e.mode&&s.chmodSync(n,e.mode):n!==r&&(o.isDirectory()?s.rmdirSync(n):this.#r(n))),qe.has(e.type))return this.#a(e,n,t);if(ae.has(e.type))this.#o(e,n);else{this.#s(this.linkParts(e,n));let a=String(e.linkpath);e.type==="Link"?s.linkSync(this.resolve(r,a),n):s.symlinkSync(a,n)}this.#s(this.parentParts(n))}}#r(e){let t=this.#e;if(!this.win32)return t.unlinkSync(e);let s=gi(e);t.renameSync(e,s),t.unlinkSync(s)}#s(e){if(this.preservePaths)return;let t=this.cwd;for(let s of e){t=this.resolve(t,s);let n;try{n=this.#e.lstatSync(t)}catch{return}if(n.isSymbolicLink())throw this.symlinkError(t,e)}}#o(e,t){let s=this.#e;this.#i(t,e.mode??this.dmode);let n=this.times(e);if(n)try{s.lutimesSync(t,n.atime,n.mtime)}catch{}let r=this.owner(e);if(r)try{s.lchownSync(t,r.uid,r.gid)}catch{}}#a(e,t,s){let n=this.#e,r=n.openSync(t,this.writeFlag(e.size),e.mode??this.fmode);try{this.#s(this.parentParts(t));let o=this.opt.transform?.(e);for(;;){let h;try{h=s.readBody(e)}catch(l){throw this.fail(l)}if(!h)break;n.writeSync(r,o?o(h):h)}let a=this.times(e);if(a){let{atime:h,mtime:l}=a;try{n.futimesSync(r,h,l)}catch(d){try{n.utimesSync(t,h,l)}catch{throw d}}}let c=this.owner(e);if(c){let{uid:h,gid:l}=c;try{n.fchownSync(r,h,l)}catch(d){try{n.chownSync(t,h,l)}catch{throw d}}}}catch(o){try{n.closeSync(r)}catch{}throw o}n.closeSync(r)}};var xi=()=>new TypeError("extract needs input or file"),Ke=async(i,e)=>{let t=y(i),s=t.input??(t.file?H(t.fs,t.file,t.maxReadSize):void 0);if(!s)throw xi();let[n,r]=e?.length?J(e,t.filter):[];n&&(t.filter=n),await new Ae(t).extract(s),r?.(t)},ki=(i,e)=>{let t=y(i),s=t.input??(t.file?$(t.fs,t.file,t.maxReadSize):void 0);if(!s)throw xi();let[n,r]=e?.length?J(e,t.filter):[];n&&(t.filter=n),new Te(t).extract(s),r?.(t)};var Si=64*1024,bi={},Es=()=>{},Xe=()=>new Error("cannot append to compressed archives"),Ei=(i,e)=>{let{file:t}=i;if(!t)throw new TypeError("file is required");if(i.gzip||i.brotli||i.zstd||t.endsWith(".br")||t.endsWith(".tbr"))throw new TypeError(Xe().message);if(!e?.length)throw new TypeError("no paths specified to add/replace")},Oe=class{buf=new Uint8Array(Si);pos=0;#e;#t;#i;#n;constructor(e,t=[],s){this.#e=e,this.#i=[...t,T],this.#n=s,this.#t=new B({filter:()=>!1,onwarn:(n,r,o)=>{throw o instanceof Error?o:bi}})}get position(){return this.#t.position}get want(){return Math.min(Si,this.#e-this.pos)}push(e){let t=this.buf.subarray(0,e);if(this.pos===0&&this.#i.some(r=>r.detect(t)))throw Xe();let s=this.#t;this.pos+=e;let n=0;s.push(t);try{for(let r;r=s.next();){if(r.type!=="entry")return!1;let{entry:o}=r;if(n=s.offset+512*Math.ceil(o.size/512),n>this.#e)return!1;o.mtime&&this.#n?.set(o.path,o.mtime)}this.pos<n&&(s.skipBody(),this.pos=n)}catch(r){if(r!==bi)throw r;return!1}return e>0&&this.pos<this.#e}},ce=async(i,e)=>{let t=y(i);Ei(t,e);let{fs:s,file:n}=t,r=We(t,e);if(r.codec)throw new TypeError(Xe().message);let o=await s.open(n,"r+").catch(c=>{if(c?.code!=="ENOENT")throw c;return s.open(n,"w+",t.mode||438)}),a=!1;try{let{size:c}=await o.stat(),h=new Oe(c,t.codecs,t.mtimeCache);for(;h.push((await o.read(h.buf,0,h.want,h.pos)).bytesRead););await wt(o,r,h.position),a=!0}finally{let c=o.close();await(a?c:c.catch(Es))}},Ze=(i,e)=>{let t=y(i);Ei(t,e);let{fs:s,file:n}=t,r=gt(t,e);if(r.codec)throw new TypeError(Xe().message);let o;try{o=s.openSync(n,"r+")}catch(a){if(a?.code!=="ENOENT")throw a;o=s.openSync(n,"w+",t.mode||438)}try{let{size:a}=s.fstatSync(o),c=new Oe(a,t.codecs,t.mtimeCache);for(;c.push(s.readSync(o,c.buf,0,c.want,c.pos)););yt(s,o,r,c.position)}catch(a){try{s.closeSync(o)}catch{}throw a}s.closeSync(o)};var vs=(i,e)=>{let t=e.getTime(),s=i.getTime();return(t%1e3===0?s-s%1e3:s)>t},vi=i=>{let{filter:e}=i,t=i.mtimeCache??new Map;return{...i,mtimeCache:t,filter:(s,n)=>{if(e&&!e(s,n))return!1;if("isDirectory"in n&&n.isDirectory())return!0;let r=t.get(s);return!r||!n.mtime||vs(n.mtime,r)}}},Je=(i,e)=>ce(vi(i),e),Ri=(i,e)=>Ze(vi(i),e);import{constants as As}from"node:buffer";import*as Ts from"node:zlib";var Qe=64*1024,et=(i,e=!1,t)=>{let s,n,r=!1,o=!1,a,c,h=e?new Uint8Array(Qe):void 0,l=0,d=m=>new Promise(u=>{a=u,i.write(m,()=>u())}),p=async m=>{l&&await d(m.subarray(0,l)),l=0},f=()=>{o=!0,a?.(),c?.()},w=()=>{f(),i.destroy()};return i.pause(),i.on("data",m=>{t?.(m),t=void 0,r=!1,i.pause(),s.enqueue(m)}),i.on("end",()=>{o||s.close()}),i.on("error",m=>{s.error(m),n.error(m),f()}),i.on("close",f),{readable:new ReadableStream({start:m=>{s=m},pull:()=>{r=!0,c?.(),i.resume()},cancel:m=>{n.error(m),w()}},{highWaterMark:0}),writable:new WritableStream({start:m=>{n=m;let{signal:u}=m;u.addEventListener("abort",()=>{s.error(u.reason),w()})},write:async m=>{h?(l+m.length>Qe&&await p(h),m.length>Qe?await d(m):(h.set(m,l),l+=m.length)):await d(m),!r&&!o&&await new Promise(u=>c=u)},close:async()=>{h&&await p(h),await new Promise(m=>{a=m,i.end()})}})}},Os=i=>i>=As.MAX_LENGTH?{}:{maxOutputLength:Math.max(1,Math.floor(i))},St=(i,e,t,s,n)=>({...i,decompress:()=>et(t({chunkSize:Qe})),compress:r=>et(e(r),!0),decompressSync:(r,{maxOutputLength:o})=>{try{return n(r,Os(o))}catch(a){throw a?.code!=="ERR_BUFFER_TOO_LARGE"?a:new Error(`max decompression ratio exceeded: the output is larger than ${o} bytes`)}},compressSync:s}),Ai=i=>{i[9]=255},bt=(i=Ts)=>{let{createBrotliCompress:e,createBrotliDecompress:t,brotliCompressSync:s,brotliDecompressSync:n,createZstdCompress:r,createZstdDecompress:o,zstdCompressSync:a,zstdDecompressSync:c}=i,l=[{...St({name:"gzip",headLength:2,detect:d=>d[0]===31&&d[1]===139},i.createGzip,i.createGunzip,i.gzipSync,i.gunzipSync),compress:({portable:d,...p}={})=>et(i.createGzip(p),!0,d?Ai:void 0),compressSync:(d,{portable:p,...f}={})=>{let w=i.gzipSync(d,f);return p&&Ai(w),w}}];return e&&t&&s&&n&&l.push(St({name:"brotli",headLength:0,detect:()=>!1,extensions:[".tar.br",".tbr"]},e,t,s,n)),r&&o&&a&&c&&l.push(St({name:"zstd",headLength:4,detect:d=>d[0]===40&&d[1]===181&&d[2]===47&&d[3]===253},r,o,a,c)),l};var Q=zs,ee=Ps,Ns=process.platform==="win32"?"win32":"posix",Us=bt(),x=(i,e,t)=>{let s=y(i);return s.fs??=e,s.platform??=Ns,s.codecs=[...s.codecs??[],...Us],t&&(s.cwd=Fs(s.cwd??""),s.processUid??=process.getuid?.(),s.processGid??=process.getgid?.(),s.processUname??=process.env.USER,s.chmod&&(s.processUmask??=process.umask())),s},ko=(i,e={})=>lt(i,x(e,Q,!1)),So=(i,e={})=>Bt(i,x(e,ee,!1)),bo=(i,e)=>Ve(x(i,Q,!1),e),Eo=(i,e)=>ni(x(i,ee,!1),e),vo=(i,e)=>Ke(x(i,Q,!0),e),Ro=(i,e)=>ki(x(i,ee,!0),e);function Ao(i,e){return ne(x(i,Q,!0),e)}function To(i,e){return Ye(x(i,ee,!0),e)}var Oo=(i,e)=>ce(x(i,Q,!0),e),Po=(i,e)=>Ze(x(i,ee,!0),e),zo=(i,e)=>Je(x(i,Q,!0),e),Fo=(i,e)=>Ri(x(i,ee,!0),e),No=(i,e)=>xt(x(i,Q,!1),e),Uo=(i,e)=>ai(x(i,ee,!1),e);export{Oe as AppendScan,re as CwdError,ue as EntryCursor,q as EntryData,R as Header,Se as Pack,ke as PackBase,F as PackJob,be as PackSync,B as Parser,ve as PathReservations,I as Pax,fe as ReadEntry,me as ReadEntrySync,G as SymlinkError,b as TarReader,E as TarReaderSync,Ae as Unpack,Re as UnpackBase,Te as UnpackSync,se as WriteEntry,Ot as aliases,Ao as c,et as codecStream,Ao as create,To as createSync,No as delete,Uo as deleteSync,ko as entries,So as entriesSync,vo as extract,Ro as extractSync,T as gzip,bo as list,Eo as listSync,Oo as r,Oo as replace,Po as replaceSync,bo as t,nt as types,zo as u,zo as update,Fo as updateSync,vo as x,bt as zlibCodecs};
|
|
3
3
|
//# sourceMappingURL=index.min.js.map
|