create-mugnavo 0.0.0 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nathaniel John Tampus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # create-mugnavo
2
+
3
+ CLI for creating projects with Mugnavo templates.
4
+
5
+ ```bash
6
+ pnpm create mugnavo@latest
7
+ ```
8
+
9
+ ## Templates
10
+
11
+ - [`tanstarter`](https://github.com/mugnavo/tanstarter)
12
+ - [`tanstarter-monorepo`](https://github.com/mugnavo/tanstarter/tree/next)
13
+
14
+ ## License
15
+
16
+ [MIT](./LICENSE)
package/dist/index.mjs ADDED
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ import{t as e}from"./rolldown-runtime-Bbnr-mUN.mjs";import{constants as t,createWriteStream as n,existsSync as r,readdirSync as i,renameSync as a}from"node:fs";import{copyFile as o,mkdir as s,readFile as c,rm as l,writeFile as u}from"node:fs/promises";import{delimiter as d,dirname as f,join as p,normalize as m,resolve as h}from"node:path";import{parseArgs as g,promisify as _,stripVTControlCharacters as v,styleText as y}from"node:util";import b,{cwd as x,stdin as S,stdout as C}from"node:process";import*as w from"node:readline";import T from"node:readline";import{ReadStream as ee}from"node:tty";import{PassThrough as te,pipeline as ne}from"node:stream";import{spawn as re}from"node:child_process";import{createRequire as E}from"module";import{homedir as ie,tmpdir as ae}from"node:os";var oe=Object.defineProperty,se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ce=(e,t)=>{let n={};for(var r in e)oe(n,r,{get:e[r],enumerable:!0});return t||oe(n,Symbol.toStringTag,{value:`Module`}),n},D=se(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}}))();function le(e,t,n){if(!n.some(e=>!e.disabled))return e;let r=e+t,i=Math.max(n.length-1,0),a=r<0?i:r>i?0:r;return n[a].disabled?le(a,t<0?-1:1,n):a}const ue=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,de=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,fe=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,pe=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,me=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,he=/\t{1,1000}/y,ge=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,_e=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ve=/\p{M}+/gu,ye={limit:1/0,ellipsis:``},be=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?be(i,ye,n).width:0),o=n.ansiWidth??0,s=n.controlWidth??0,c=n.tabWidth??8,l=n.ambiguousWidth??1,u=n.emojiWidth??2,d=n.fullWidthWidth??2,f=n.regularWidth??1,p=n.wideWidth??2,m=0,h=0,g=e.length,_=0,v=!1,y=g,b=Math.max(0,r-a),x=0,S=0,C=0,w=0;t:for(;;){if(S>x||h>=g&&h>m){let t=e.slice(x,S)||e.slice(m,h);_=0;for(let e of t.replaceAll(ve,``)){let t=e.codePointAt(0)||0;if(w=de(t)?d:fe(t)?p:l!==f&&ue(t)?l:f,C+w>b&&(y=Math.min(y,Math.max(x,m)+_)),C+w>r){v=!0;break t}_+=e.length,C+=w}x=S=0}if(h>=g)break;if(_e.lastIndex=h,_e.test(e)){if(_=_e.lastIndex-h,w=_*f,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/f))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=_e.lastIndex;continue}if(pe.lastIndex=h,pe.test(e)){if(C+o>b&&(y=Math.min(y,h)),C+o>r){v=!0;break}C+=o,x=m,S=h,h=m=pe.lastIndex;continue}if(me.lastIndex=h,me.test(e)){if(_=me.lastIndex-h,w=_*s,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/s))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=me.lastIndex;continue}if(he.lastIndex=h,he.test(e)){if(_=he.lastIndex-h,w=_*c,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/c))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=he.lastIndex;continue}if(ge.lastIndex=h,ge.test(e)){if(C+u>b&&(y=Math.min(y,h)),C+u>r){v=!0;break}C+=u,x=m,S=h,h=m=ge.lastIndex;continue}h+=1}return{width:v?b:C,index:v?y:g,truncated:v,ellipsed:v&&r>=a}},xe={limit:1/0,ellipsis:``,ellipsisWidth:0},O=(e,t={})=>be(e,xe,t).width,Se=`]8;;`,Ce=RegExp(`(?:\\[(?<code>\\d+)m|\\${Se}(?<uri>.*))`,`y`),we=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Te=e=>`[${e}m`,Ee=e=>`${Se}${e}`,De=e=>e.map(e=>O(e)),Oe=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:O(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=O(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Se,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ke=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(O(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ae=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=De(o),c=[``];for(let[e,r]of o.entries()){n.trim!==!1&&(c[c.length-1]=(c.at(-1)??``).trimStart());let i=O(c.at(-1)??``);if(e!==0&&(i>=t&&(n.wordWrap===!1||n.trim===!1)&&(c.push(``),i=0),(i>0||n.trim===!1)&&(c[c.length-1]+=` `,i++)),n.hard&&s[e]>t){let n=t-i,a=1+Math.floor((s[e]-n-1)/t);Math.floor((s[e]-1)/t)<a&&c.push(``),Oe(c,r,t);continue}if(i+s[e]>t&&i>0&&s[e]>0){if(n.wordWrap===!1&&i<t){Oe(c,r,t);continue}c.push(``)}if(i+s[e]>t&&n.wordWrap===!1){Oe(c,r,t);continue}c[c.length-1]+=r}n.trim!==!1&&(c=c.map(e=>ke(e)));let l=c.join(`
3
+ `),u=l[Symbol.iterator](),d=u.next(),f=u.next(),p=0;for(;!d.done;){let e=d.value,t=f.value;if(r+=e,e===`\x1B`||e===`›`){Ce.lastIndex=p+1;let e=Ce.exec(l)?.groups;if(e?.code!==void 0){let t=Number.parseFloat(e.code);i=t===39?void 0:t}else e?.uri!==void 0&&(a=e.uri.length===0?void 0:e.uri)}let n=i?we(i):void 0;t===`
4
+ `?(a&&(r+=Ee(``)),i&&n&&(r+=Te(n))):e===`
5
+ `&&(i&&n&&(r+=Te(i)),a&&(r+=Ee(a))),p+=e.length,d=f,f=u.next()}return r};function je(e,t,n){return String(e).normalize().replaceAll(`\r
6
+ `,`
7
+ `).split(`
8
+ `).map(e=>Ae(e,t,n)).join(`
9
+ `)}const k={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]]),messages:{cancel:`Canceled`,error:`Something went wrong`},withGuide:!0};function Me(e,t){if(typeof e==`string`)return k.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Me(n,t))return!0;return!1}function Ne(e,t){if(e===t)return;let n=e.split(`
10
+ `),r=t.split(`
11
+ `),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}const Pe=globalThis.process.platform.startsWith(`win`),Fe=Symbol(`clack:cancel`);function A(e){return e===Fe}function Ie(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Le({input:e=S,output:t=C,overwrite:n=!0,hideCursor:r=!0}={}){let i=w.createInterface({input:e,output:t,prompt:``,tabSize:1});w.emitKeypressEvents(e,i),e instanceof ee&&e.isTTY&&e.setRawMode(!0);let a=(i,{name:o,sequence:s})=>{if(Me([String(i),o,s],`cancel`)){r&&t.write(D.cursor.show),process.exit(0);return}if(!n)return;let c=o===`return`?0:-1,l=o===`return`?-1:0;w.moveCursor(t,c,l,()=>{w.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(D.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(D.cursor.show),e instanceof ee&&e.isTTY&&!Pe&&e.setRawMode(!1),i.terminal=!1,i.close()}}const j=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,Re=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function ze(e,t,n,r=n){return je(t,j(e??C)-n.length,{hard:!0,trim:!1}).split(`
12
+ `).map((e,t)=>`${t===0?r:n}${e}`).join(`
13
+ `)}var Be=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;constructor(e,t=!0){let{input:n=S,output:r=C,render:i,signal:a,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(Fe);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=T.createInterface({input:this.input,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(`keypress`,this.onKeypress),Ie(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(D.cursor.show),this.output.off(`resize`,this.render),Ie(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(D.cursor.show),this.output.off(`resize`,this.render),Ie(this.input,!1),e(Fe)})})}_isActionKey(e,t){return e===` `}_setValue(e){this.value=e,this.emit(`value`,this.value)}_setUserInput(e,t){this.userInput=e??``,this.emit(`userInput`,this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:`u`}),this._setUserInput(``)}onKeypress(e,t){if(this._track&&t.name!==`return`&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:`h`}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&k.aliases.has(t.name)&&this.emit(`cursor`,k.aliases.get(t.name)),k.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),this.emit(`key`,e?.toLowerCase(),t),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}Me([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
14
+ `),Ie(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=je(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
15
+ `).length-1;this.output.write(D.cursor.move(-999,e*-1))}render(){let e=je(this._render(this)??``,process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(D.cursor.hide);else{let t=Ne(this._prevFrame,e),n=Re(this.output);if(this.restoreCursor(),t){let r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n),a=t.lines.find(e=>e>=r);if(a===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(D.cursor.move(0,a-i)),this.output.write(D.erase.lines(1));let t=e.split(`
16
+ `);this.output.write(t[a]),this._prevFrame=e,this.output.write(D.cursor.move(0,t.length-a-1));return}else if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(D.cursor.move(0,e))}this.output.write(D.erase.down());let t=e.split(`
17
+ `).slice(a);this.output.write(t.join(`
18
+ `)),this._prevFrame=e;return}}this.output.write(D.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},Ve=class extends Be{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(D.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},He=class extends Be{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n].disabled?le(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=le(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=le(this.cursor,1,this.options);break}this.changeValue()})}},Ue=class extends Be{get userInputWithCursor(){if(this.state===`submit`)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let t=e.slice(0,this.cursor),[n,...r]=e.slice(this.cursor);return`${t}${y(`inverse`,n)}${r.join(``)}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on(`userInput`,e=>{this._setValue(e)}),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.value===void 0&&(this.value=``)})}};function We(){return b.platform===`win32`?!!b.env.CI||!!b.env.WT_SESSION||!!b.env.TERMINUS_SUBLIME||b.env.ConEmuTask===`{cmd::Cmder}`||b.env.TERM_PROGRAM===`Terminus-Sublime`||b.env.TERM_PROGRAM===`vscode`||b.env.TERM===`xterm-256color`||b.env.TERM===`alacritty`||b.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:b.env.TERM!==`linux`}const Ge=We(),Ke=()=>process.env.CI===`true`,qe=e=>e.isTTY===!0,M=(e,t)=>Ge?e:t,Je=M(`◆`,`*`),Ye=M(`■`,`x`),Xe=M(`▲`,`x`),N=M(`◇`,`o`),P=M(`│`,`|`),F=M(`└`,`—`),Ze=M(`●`,`>`),I=M(`○`,` `),Qe=M(`─`,`-`),$e=M(`╮`,`+`),et=M(`├`,`+`),tt=M(`╯`,`+`),nt=M(`╰`,`+`),rt=M(`●`,`•`),it=M(`◆`,`*`),at=M(`▲`,`!`),ot=M(`■`,`x`),st=e=>{switch(e){case`initial`:case`active`:return y(`cyan`,Je);case`cancel`:return y(`red`,Ye);case`error`:return y(`yellow`,Xe);case`submit`:return y(`green`,N)}},ct=e=>{switch(e){case`initial`:case`active`:return y(`cyan`,P);case`cancel`:return y(`red`,P);case`error`:return y(`yellow`,P);case`submit`:return y(`green`,P)}},lt=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,ut=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,dt=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,ft=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,L=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,pt=/\t{1,1000}/y,mt=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,ht=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,gt=/\p{M}+/gu,_t={limit:1/0,ellipsis:``},vt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?vt(i,_t,n).width:0),o=n.ansiWidth??0,s=n.controlWidth??0,c=n.tabWidth??8,l=n.ambiguousWidth??1,u=n.emojiWidth??2,d=n.fullWidthWidth??2,f=n.regularWidth??1,p=n.wideWidth??2,m=0,h=0,g=e.length,_=0,v=!1,y=g,b=Math.max(0,r-a),x=0,S=0,C=0,w=0;e:for(;;){if(S>x||h>=g&&h>m){let t=e.slice(x,S)||e.slice(m,h);_=0;for(let e of t.replaceAll(gt,``)){let t=e.codePointAt(0)||0;if(w=ut(t)?d:dt(t)?p:l!==f&&lt(t)?l:f,C+w>b&&(y=Math.min(y,Math.max(x,m)+_)),C+w>r){v=!0;break e}_+=e.length,C+=w}x=S=0}if(h>=g)break;if(ht.lastIndex=h,ht.test(e)){if(_=ht.lastIndex-h,w=_*f,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/f))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=ht.lastIndex;continue}if(ft.lastIndex=h,ft.test(e)){if(C+o>b&&(y=Math.min(y,h)),C+o>r){v=!0;break}C+=o,x=m,S=h,h=m=ft.lastIndex;continue}if(L.lastIndex=h,L.test(e)){if(_=L.lastIndex-h,w=_*s,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/s))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=L.lastIndex;continue}if(pt.lastIndex=h,pt.test(e)){if(_=pt.lastIndex-h,w=_*c,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/c))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=pt.lastIndex;continue}if(mt.lastIndex=h,mt.test(e)){if(C+u>b&&(y=Math.min(y,h)),C+u>r){v=!0;break}C+=u,x=m,S=h,h=m=mt.lastIndex;continue}h+=1}return{width:v?b:C,index:v?y:g,truncated:v,ellipsed:v&&r>=a}},yt={limit:1/0,ellipsis:``,ellipsisWidth:0},R=(e,t={})=>vt(e,yt,t).width,bt=`]8;;`,xt=RegExp(`(?:\\[(?<code>\\d+)m|\\${bt}(?<uri>.*))`,`y`),St=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Ct=e=>`[${e}m`,wt=e=>`${bt}${e}`,Tt=e=>e.map(e=>R(e)),Et=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:R(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=R(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(bt,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Dt=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(R(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ot=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=Tt(o),c=[``];for(let[e,r]of o.entries()){n.trim!==!1&&(c[c.length-1]=(c.at(-1)??``).trimStart());let i=R(c.at(-1)??``);if(e!==0&&(i>=t&&(n.wordWrap===!1||n.trim===!1)&&(c.push(``),i=0),(i>0||n.trim===!1)&&(c[c.length-1]+=` `,i++)),n.hard&&s[e]>t){let n=t-i,a=1+Math.floor((s[e]-n-1)/t);Math.floor((s[e]-1)/t)<a&&c.push(``),Et(c,r,t);continue}if(i+s[e]>t&&i>0&&s[e]>0){if(n.wordWrap===!1&&i<t){Et(c,r,t);continue}c.push(``)}if(i+s[e]>t&&n.wordWrap===!1){Et(c,r,t);continue}c[c.length-1]+=r}n.trim!==!1&&(c=c.map(e=>Dt(e)));let l=c.join(`
19
+ `),u=l[Symbol.iterator](),d=u.next(),f=u.next(),p=0;for(;!d.done;){let e=d.value,t=f.value;if(r+=e,e===`\x1B`||e===`›`){xt.lastIndex=p+1;let e=xt.exec(l)?.groups;if(e?.code!==void 0){let t=Number.parseFloat(e.code);i=t===39?void 0:t}else e?.uri!==void 0&&(a=e.uri.length===0?void 0:e.uri)}let n=i?St(i):void 0;t===`
20
+ `?(a&&(r+=wt(``)),i&&n&&(r+=Ct(n))):e===`
21
+ `&&(i&&n&&(r+=Ct(i)),a&&(r+=wt(a))),p+=e.length,d=f,f=u.next()}return r};function z(e,t,n){return String(e).normalize().replaceAll(`\r
22
+ `,`
23
+ `).split(`
24
+ `).map(e=>Ot(e,t,n)).join(`
25
+ `)}const kt=(e,t,n,r,i)=>{let a=t,o=0;for(let t=n;t<r;t++){let n=e[t];if(a-=n.length,o++,a<=i)break}return{lineCount:a,removals:o}},At=({cursor:e,options:t,style:n,output:r=process.stdout,maxItems:i=1/0,columnPadding:a=0,rowPadding:o=4})=>{let s=j(r)-a,c=Re(r),l=y(`dim`,`...`),u=Math.max(c-o,0),d=Math.max(Math.min(i,u),5),f=0;e>=d-3&&(f=Math.max(Math.min(e-d+3,t.length-d),0));let p=d<t.length&&f>0,m=d<t.length&&f+d<t.length,h=Math.min(f+d,t.length),g=[],_=0;p&&_++,m&&_++;let v=f+(p?1:0),b=h-(m?1:0);for(let r=v;r<b;r++){let i=z(n(t[r],r===e),s,{hard:!0,trim:!1}).split(`
26
+ `);g.push(i),_+=i.length}if(_>u){let t=0,n=0,r=_,i=e-v,a=(e,t)=>kt(g,r,e,t,u);p?({lineCount:r,removals:t}=a(0,i),r>u&&({lineCount:r,removals:n}=a(i+1,g.length))):({lineCount:r,removals:n}=a(i+1,g.length),r>u&&({lineCount:r,removals:t}=a(0,i))),t>0&&(p=!0,g.splice(0,t)),n>0&&(m=!0,g.splice(g.length-n,n))}let x=[];p&&x.push(l);for(let e of g)for(let t of e)x.push(t);return m&&x.push(l),x},jt=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new Ve({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let r=e.withGuide??k.withGuide,i=`${r?`${y(`gray`,P)}
27
+ `:``}${st(this.state)} ${e.message}
28
+ `,a=this.value?t:n;switch(this.state){case`submit`:return`${i}${r?`${y(`gray`,P)} `:``}${y(`dim`,a)}`;case`cancel`:return`${i}${r?`${y(`gray`,P)} `:``}${y([`strikethrough`,`dim`],a)}${r?`
29
+ ${y(`gray`,P)}`:``}`;default:{let a=r?`${y(`cyan`,P)} `:``,o=r?y(`cyan`,F):``;return`${i}${a}${this.value?`${y(`green`,Ze)} ${t}`:`${y(`dim`,I)} ${y(`dim`,t)}`}${e.vertical?r?`
30
+ ${y(`cyan`,P)} `:`
31
+ `:` ${y(`dim`,`/`)} `}${this.value?`${y(`dim`,I)} ${y(`dim`,n)}`:`${y(`green`,Ze)} ${n}`}
32
+ ${o}
33
+ `}}}}).prompt()},B={message:(e=[],{symbol:t=y(`gray`,P),secondarySymbol:n=y(`gray`,P),output:r=process.stdout,spacing:i=1,withGuide:a}={})=>{let o=[],s=a??k.withGuide,c=s?n:``,l=s?`${t} `:``,u=s?`${n} `:``;for(let e=0;e<i;e++)o.push(c);let d=Array.isArray(e)?e:e.split(`
34
+ `);if(d.length>0){let[e,...r]=d;e.length>0?o.push(`${l}${e}`):o.push(s?t:``);for(let e of r)e.length>0?o.push(`${u}${e}`):o.push(s?n:``)}r.write(`${o.join(`
35
+ `)}
36
+ `)},info:(e,t)=>{B.message(e,{...t,symbol:y(`blue`,rt)})},success:(e,t)=>{B.message(e,{...t,symbol:y(`green`,it)})},step:(e,t)=>{B.message(e,{...t,symbol:y(`green`,N)})},warn:(e,t)=>{B.message(e,{...t,symbol:y(`yellow`,at)})},warning:(e,t)=>{B.warn(e,t)},error:(e,t)=>{B.message(e,{...t,symbol:y(`red`,ot)})}},Mt=(e=``,t)=>{let n=t?.output??process.stdout,r=t?.withGuide??k.withGuide?`${y(`gray`,F)} `:``;n.write(`${r}${y(`red`,e)}
37
+
38
+ `)},Nt=(e=``,t)=>{let n=t?.output??process.stdout,r=t?.withGuide??k.withGuide?`${y(`gray`,P)}
39
+ ${y(`gray`,F)} `:``;n.write(`${r}${e}
40
+
41
+ `)},Pt=e=>y(`dim`,e),Ft=(e,t,n)=>{let r={hard:!0,trim:!1},i=z(e,t,r).split(`
42
+ `),a=i.reduce((e,t)=>Math.max(R(t),e),0);return z(e,t-(i.map(n).reduce((e,t)=>Math.max(R(t),e),0)-a),r)},It=(e=``,t=``,n)=>{let r=n?.output??b.stdout,i=n?.withGuide??k.withGuide,a=n?.format??Pt,o=[``,...Ft(e,j(r)-6,a).split(`
43
+ `).map(a),``],s=R(t),c=Math.max(o.reduce((e,t)=>{let n=R(t);return n>e?n:e},0),s)+2,l=o.map(e=>`${y(`gray`,P)} ${e}${` `.repeat(c-R(e))}${y(`gray`,P)}`).join(`
44
+ `),u=i?`${y(`gray`,P)}
45
+ `:``,d=i?et:nt;r.write(`${u}${y(`green`,N)} ${y(`reset`,t)} ${y(`gray`,Qe.repeat(Math.max(c-s-1,1))+$e)}
46
+ ${l}
47
+ ${y(`gray`,d+Qe.repeat(c+2)+tt)}
48
+ `)},Lt=e=>y(`magenta`,e),Rt=({indicator:e=`dots`,onCancel:t,output:n=process.stdout,cancelMessage:r,errorMessage:i,frames:a=Ge?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],delay:o=Ge?80:120,signal:s,...c}={})=>{let l=Ke(),u,d,f=!1,p=!1,m=``,h,g=performance.now(),_=j(n),v=c?.styleFrame??Lt,b=e=>{let n=e>1?i??k.messages.error:r??k.messages.cancel;p=e===1,f&&(E(n,e),p&&typeof t==`function`&&t())},x=()=>b(2),S=()=>b(1),C=()=>{process.on(`uncaughtExceptionMonitor`,x),process.on(`unhandledRejection`,x),process.on(`SIGINT`,S),process.on(`SIGTERM`,S),process.on(`exit`,b),s&&s.addEventListener(`abort`,S)},w=()=>{process.removeListener(`uncaughtExceptionMonitor`,x),process.removeListener(`unhandledRejection`,x),process.removeListener(`SIGINT`,S),process.removeListener(`SIGTERM`,S),process.removeListener(`exit`,b),s&&s.removeEventListener(`abort`,S)},T=()=>{if(h===void 0)return;l&&n.write(`
49
+ `);let e=z(h,_,{hard:!0,trim:!1}).split(`
50
+ `);e.length>1&&n.write(D.cursor.up(e.length-1)),n.write(D.cursor.to(0)),n.write(D.erase.down())},ee=e=>e.replace(/\.+$/,``),te=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},ne=c.withGuide??k.withGuide,re=(t=``)=>{f=!0,u=Le({output:n}),m=ee(t),g=performance.now(),ne&&n.write(`${y(`gray`,P)}
51
+ `);let r=0,i=0;C(),d=setInterval(()=>{if(l&&m===h)return;T(),h=m;let t=v(a[r]),o;if(l)o=`${t} ${m}...`;else if(e===`timer`)o=`${t} ${m} ${te(g)}`;else{let e=`.`.repeat(Math.floor(i)).slice(0,3);o=`${t} ${m}${e}`}let s=z(o,_,{hard:!0,trim:!1});n.write(s),r=r+1<a.length?r+1:0,i=i<4?i+.125:0},o)},E=(t=``,r=0,i=!1)=>{if(!f)return;f=!1,clearInterval(d),T();let a=r===0?y(`green`,N):r===1?y(`red`,Ye):y(`red`,Xe);m=t??m,i||(e===`timer`?n.write(`${a} ${m} ${te(g)}
52
+ `):n.write(`${a} ${m}
53
+ `)),w(),u()};return{start:re,stop:(e=``)=>E(e,0),message:(e=``)=>{m=ee(e??m)},cancel:(e=``)=>E(e,1),error:(e=``)=>E(e,2),clear:()=>E(``,0,!0),get isCancelled(){return p}}},zt=(e,t)=>e.includes(`
54
+ `)?e.split(`
55
+ `).map(e=>t(e)).join(`
56
+ `):t(e),Bt=e=>{let t=(e,t)=>{let n=e.label??String(e.value);switch(t){case`disabled`:return`${y(`gray`,I)} ${zt(n,e=>y(`gray`,e))}${e.hint?` ${y(`dim`,`(${e.hint??`disabled`})`)}`:``}`;case`selected`:return`${zt(n,e=>y(`dim`,e))}`;case`active`:return`${y(`green`,Ze)} ${n}${e.hint?` ${y(`dim`,`(${e.hint})`)}`:``}`;case`cancelled`:return`${zt(n,e=>y([`strikethrough`,`dim`],e))}`;default:return`${y(`dim`,I)} ${zt(n,e=>y(`dim`,e))}`}};return new He({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=e.withGuide??k.withGuide,r=`${st(this.state)} `,i=`${ct(this.state)} `,a=ze(e.output,e.message,i,r),o=`${n?`${y(`gray`,P)}
57
+ `:``}${a}
58
+ `;switch(this.state){case`submit`:{let r=n?`${y(`gray`,P)} `:``;return`${o}${ze(e.output,t(this.options[this.cursor],`selected`),r)}`}case`cancel`:{let r=n?`${y(`gray`,P)} `:``;return`${o}${ze(e.output,t(this.options[this.cursor],`cancelled`),r)}${n?`
59
+ ${y(`gray`,P)}`:``}`}default:{let r=n?`${y(`cyan`,P)} `:``,i=n?y(`cyan`,F):``,a=o.split(`
60
+ `).length,s=n?2:1;return`${o}${r}${At({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:r.length,rowPadding:a+s,style:(e,n)=>t(e,e.disabled?`disabled`:n?`active`:`inactive`)}).join(`
61
+ ${r}`)}
62
+ ${i}
63
+ `}}}}).prompt()},Vt=`${y(`gray`,P)} `,V={message:async(e,{symbol:t=y(`gray`,P)}={})=>{process.stdout.write(`${y(`gray`,P)}
64
+ ${t} `);let n=3;for await(let t of e){t=t.replace(/\n/g,`
65
+ ${Vt}`),t.includes(`
66
+ `)&&(n=3+v(t.slice(t.lastIndexOf(`
67
+ `))).length);let e=v(t).length;n+e<process.stdout.columns?(n+=e,process.stdout.write(t)):(process.stdout.write(`
68
+ ${Vt}${t.trimStart()}`),n=3+v(t.trimStart()).length)}process.stdout.write(`
69
+ `)},info:e=>V.message(e,{symbol:y(`blue`,rt)}),success:e=>V.message(e,{symbol:y(`green`,it)}),step:e=>V.message(e,{symbol:y(`green`,N)}),warn:e=>V.message(e,{symbol:y(`yellow`,at)}),warning:e=>V.warn(e),error:e=>V.message(e,{symbol:y(`red`,ot)})},Ht=e=>e.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,``),Ut=e=>{let t=e.output??process.stdout,n=j(t),r=y(`gray`,P),i=e.spacing??1,a=e.retainLog===!0,o=!Ke()&&qe(t);t.write(`${r}
70
+ `),t.write(`${y(`green`,N)} ${e.title}
71
+ `);for(let e=0;e<i;e++)t.write(`${r}
72
+ `);let s=[{value:``,full:``}],c=!1,l=e=>{if(s.length===0)return;let r=0;e&&(r+=i+2);for(let e of s){let{value:t,result:i}=e,a=i?.message??t;if(a.length===0)continue;i===void 0&&e.header!==void 0&&e.header!==``&&(a+=`
73
+ ${e.header}`);let o=a.split(`
74
+ `).reduce((e,t)=>t===``?e+1:e+Math.ceil((t.length+3)/n),0);r+=o}r>0&&(r+=1,t.write(D.erase.lines(r)))},u=(e,n,a)=>{let o=a?`${e.full}
75
+ ${e.value}`:e.value;e.header!==void 0&&e.header!==``&&B.message(e.header.split(`
76
+ `).map(e=>y(`bold`,e)),{output:t,secondarySymbol:r,symbol:r,spacing:0}),B.message(o.split(`
77
+ `).map(e=>y(`dim`,e)),{output:t,secondarySymbol:r,symbol:r,spacing:n??i})},d=()=>{for(let e of s){let{header:t,value:n,full:r}=e;(t===void 0||t.length===0)&&n.length===0||u(e,void 0,a===!0&&r.length>0)}},f=(t,n,r)=>{if(l(!1),(r?.raw!==!0||!c)&&t.value!==``&&(t.value+=`
78
+ `),t.value+=Ht(n),c=r?.raw===!0,e.limit!==void 0){let n=t.value.split(`
79
+ `),r=n.length-e.limit;if(r>0){let e=n.splice(0,r);a&&(t.full+=(t.full===``?``:`
80
+ `)+e.join(`
81
+ `))}t.value=n.join(`
82
+ `)}o&&p()},p=()=>{for(let e of s)e.result?e.result.status===`error`?B.error(e.result.message,{output:t,secondarySymbol:r,spacing:0}):B.success(e.result.message,{output:t,secondarySymbol:r,spacing:0}):e.value!==``&&u(e,0)},m=(e,t)=>{l(!1),e.result=t,o&&p()};return{message(e,t){f(s[0],e,t)},group(e){let t={header:e,value:``,full:``};return s.push(t),{message(e,n){f(t,e,n)},error(e){m(t,{status:`error`,message:e})},success(e){m(t,{status:`success`,message:e})}}},error(e,n){l(!0),B.error(e,{output:t,secondarySymbol:r,spacing:1}),n?.showLog!==!1&&d(),s.splice(1,s.length-1),s[0].value=``,s[0].full=``},success(e,n){l(!0),B.success(e,{output:t,secondarySymbol:r,spacing:1}),n?.showLog===!0&&d(),s.splice(1,s.length-1),s[0].value=``,s[0].full=``}}},Wt=e=>new Ue({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??k.withGuide,n=`${`${t?`${y(`gray`,P)}
83
+ `:``}${st(this.state)} `}${e.message}
84
+ `,r=e.placeholder?y(`inverse`,e.placeholder[0])+y(`dim`,e.placeholder.slice(1)):y([`inverse`,`hidden`],`_`),i=this.userInput?this.userInputWithCursor:r,a=this.value??``;switch(this.state){case`error`:{let e=this.error?` ${y(`yellow`,this.error)}`:``,r=t?`${y(`yellow`,P)} `:``,a=t?y(`yellow`,F):``;return`${n.trim()}
85
+ ${r}${i}
86
+ ${a}${e}
87
+ `}case`submit`:{let e=a?` ${y(`dim`,a)}`:``;return`${n}${t?y(`gray`,P):``}${e}`}case`cancel`:{let e=a?` ${y([`strikethrough`,`dim`],a)}`:``,r=t?y(`gray`,P):``;return`${n}${r}${e}${a.trim()?`
88
+ ${r}`:``}`}default:return`${n}${t?`${y(`cyan`,P)} `:``}${i}
89
+ ${t?y(`cyan`,F):``}
90
+ `}}}).prompt(),Gt=/\d/,Kt=[`-`,`_`,`/`,`.`];function qt(e=``){if(!Gt.test(e))return e!==e.toLowerCase()}function Jt(e,t){let n=t??Kt,r=[];if(!e||typeof e!=`string`)return r;let i=``,a,o;for(let t of e){let e=n.includes(t);if(e===!0){r.push(i),i=``,a=void 0;continue}let s=qt(t);if(o===!1){if(a===!1&&s===!0){r.push(i),i=t,a=s;continue}if(a===!0&&s===!1&&i.length>1){let e=i.at(-1);r.push(i.slice(0,Math.max(0,i.length-1))),i=e+t,a=s;continue}}i+=t,a=s,o=e}return r.push(i),r}function Yt(e){return e?e[0].toUpperCase()+e.slice(1):``}function Xt(e){return e?e[0].toLowerCase()+e.slice(1):``}function Zt(e,t){return e?(Array.isArray(e)?e:Jt(e)).map(e=>Yt(t?.normalize?e.toLowerCase():e)).join(``):``}function Qt(e,t){return Xt(Zt(e||``,t))}function $t(e,t){return e?(Array.isArray(e)?e:Jt(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function en(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function tn(e,t=``){let n=[];for(let t of e)for(let[e,r]of t.entries())n[e]=Math.max(n[e]||0,r.length);return e.map(e=>e.map((e,r)=>t+e[r===0?`padStart`:`padEnd`](n[r])).join(` `)).join(`
91
+ `)}function H(e){return typeof e==`function`?e():e}var U=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function nn(e=[],t={}){let n=new Set(t.boolean||[]),r=new Set(t.string||[]),i=t.alias||{},a=t.default||{},o=new Map,s=new Map;for(let[e,t]of Object.entries(i)){let n=t;for(let t of n)o.set(e,t),s.has(t)||s.set(t,[]),s.get(t).push(e),o.set(t,e),s.has(e)||s.set(e,[]),s.get(e).push(t)}let c={};function l(e){if(n.has(e))return`boolean`;let t=s.get(e)||[];for(let e of t)if(n.has(e))return`boolean`;return`string`}let u=new Set([...n,...r,...Object.keys(i),...Object.values(i).flat(),...Object.keys(a)]);for(let e of u)c[e]||(c[e]={type:l(e),default:a[e]});for(let[e,t]of o.entries())e.length===1&&c[t]&&!c[t].short&&(c[t].short=e);let d=[],f={};for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`){d.push(...e.slice(t));break}if(n.startsWith(`--no-`)){let e=n.slice(5);f[e]=!0;continue}d.push(n)}let p;try{p=g({args:d,options:Object.keys(c).length>0?c:void 0,allowPositionals:!0,strict:!1})}catch{p={values:{},positionals:d}}let m={_:[]};m._=p.positionals;for(let[e,t]of Object.entries(p.values))m[e]=t;for(let[e]of Object.entries(f)){m[e]=!1;let t=o.get(e);t&&(m[t]=!1);let n=s.get(e);if(n)for(let e of n)m[e]=!1}for(let[e,t]of o.entries())m[e]!==void 0&&m[t]===void 0&&(m[t]=m[e]),m[t]!==void 0&&m[e]===void 0&&(m[e]=m[t]);return m}const rn=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),an=(e,t=39)=>n=>rn?n:`\u001B[${e}m${n}\u001B[${t}m`,on=an(1,22),W=an(36),sn=an(90),cn=an(4,24);function ln(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=un(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=Qt(e.name),r=$t(e.name);if(t!==e.name||r!==e.name){let i=en(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=nn(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[Qt(t)]??e[$t(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)o[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new U(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else o[e.name]=e.default}else if(e.type===`enum`){let t=o[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new U(`Invalid value for argument: ${W(`--${e.name}`)} (${W(t)}). Expected one of: ${n.map(e=>W(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new U(`Missing required argument: --${e.name}`,`EARG`);return o}function un(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:en(r.alias)});return t}function dn(e){return e}async function fn(e,t){let n=await H(e.args||{}),r=ln(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e};typeof e.setup==`function`&&await e.setup(i);let a;try{let n=await H(e.subCommands);if(n&&Object.keys(n).length>0){let r=t.rawArgs.findIndex(e=>!e.startsWith(`-`)),i=t.rawArgs[r];if(i){if(!n[i])throw new U(`Unknown command ${W(i)}`,`E_UNKNOWN_COMMAND`);let e=await H(n[i]);e&&await fn(e,{rawArgs:t.rawArgs.slice(r+1)})}else if(!e.run)throw new U(`No command specified.`,`E_NO_COMMAND`)}typeof e.run==`function`&&(a=await e.run(i))}finally{typeof e.cleanup==`function`&&await e.cleanup(i)}return{result:a}}async function pn(e,t,n){let r=await H(e.subCommands);if(r&&Object.keys(r).length>0){let n=t.findIndex(e=>!e.startsWith(`-`)),i=t[n],a=await H(r[i]);if(a)return pn(a,t.slice(n+1),e)}return[e,n]}async function mn(e,t){try{console.log(await gn(e,t)+`
92
+ `)}catch(e){console.error(e)}}const hn=/^no[-A-Z]/;async function gn(e,t){let n=await H(e.meta||{}),r=un(await H(e.args||{})),i=await H(t?.meta||{}),a=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),o=[],s=[],c=[],l=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0,r=e.default?`="${e.default}"`:``;s.push([W(t+r),e.description||``,e.valueHint?`<${e.valueHint}>`:``]),l.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+(e.type===`string`&&(e.valueHint||e.default)?`=${e.valueHint?`<${e.valueHint}>`:`"${e.default||``}"`}`:``)+(e.type===`enum`&&e.options?`=<${e.options.join(`|`)}>`:``);if(o.push([W(n+(t?` (required)`:``)),e.description||``]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!hn.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([W(n+(t?` (required)`:``)),e.negativeDescription||``])}t&&l.push(n)}if(e.subCommands){let t=[],n=await H(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await H((await H(r))?.meta);n?.hidden||(c.push([W(e),n?.description||``]),t.push(e))}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(sn(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${cn(on(`USAGE`))} ${W(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(cn(on(`ARGUMENTS`)),``),u.push(tn(s,` `)),u.push(``)),o.length>0&&(u.push(cn(on(`OPTIONS`)),``),u.push(tn(o,` `)),u.push(``)),c.length>0&&(u.push(cn(on(`COMMANDS`)),``),u.push(tn(c,` `)),u.push(``,`Use ${W(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
93
+ `)}async function _n(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||mn;try{if(n.includes(`--help`)||n.includes(`-h`))await r(...await pn(e,n)),process.exit(0);else if(n.length===1&&n[0]===`--version`){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new U(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await fn(e,{rawArgs:n})}catch(t){t instanceof U?(await r(...await pn(e,n)),console.error(t.message)):console.error(t,`
94
+ `),process.exit(1)}}var vn=ce({a:()=>G,n:()=>kn,r:()=>On,t:()=>fr});const yn=/^[A-Za-z]:\//;function bn(e=``){return e&&e.replace(/\\/g,`/`).replace(yn,e=>e.toUpperCase())}const xn=/^[/\\]{2}/,Sn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,Cn=/^[A-Za-z]:$/,wn=function(e){if(e.length===0)return`.`;e=bn(e);let t=e.match(xn),n=K(e),r=e[e.length-1]===`/`;return e=Dn(e,!n),e.length===0?n?`/`:r?`./`:`.`:(r&&(e+=`/`),Cn.test(e)&&(e+=`/`),t?n?`//${e}`:`//./${e}`:n&&!K(e)?`/${e}`:e)},Tn=function(...e){let t=``;for(let n of e)if(n)if(t.length>0){let e=t[t.length-1]===`/`,r=n[0]===`/`;e&&r?t+=n.slice(1):t+=e||r?n:`/${n}`}else t+=n;return wn(t)};function En(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const G=function(...e){e=e.map(e=>bn(e));let t=``,n=!1;for(let r=e.length-1;r>=-1&&!n;r--){let i=r>=0?e[r]:En();!i||i.length===0||(t=`${i}/${t}`,n=K(i))}return t=Dn(t,!n),n&&!K(t)?`/${t}`:t.length>0?t:`.`};function Dn(e,t){let n=``,r=0,i=-1,a=0,o=null;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o===`/`)break;else o=`/`;if(o===`/`){if(!(i===s-1||a===1))if(a===2){if(n.length<2||r!==2||n[n.length-1]!==`.`||n[n.length-2]!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length>0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}const K=function(e){return Sn.test(e)},On=function(e){let t=bn(e).replace(/\/$/,``).split(`/`).slice(0,-1);return t.length===1&&Cn.test(t[0])&&(t[0]+=`/`),t.join(`/`)||(K(e)?`/`:`.`)},kn=function(e,t){let n=bn(e).split(`/`),r=``;for(let e=n.length-1;e>=0;e--){let t=n[e];if(t){r=t;break}}return t&&r.endsWith(t)?r.slice(0,-t.length):r};var An=Object.create,jn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,Nn=Object.getOwnPropertyNames,Pn=Object.getPrototypeOf,Fn=Object.prototype.hasOwnProperty,q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),In=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Nn(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Fn.call(e,s)&&s!==n&&jn(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Mn(t,s))||r.enumerable});return e},Ln=(e,t,n)=>(n=e==null?{}:An(Pn(e)),In(t||!e||!e.__esModule?jn(n,`default`,{value:e,enumerable:!0}):n,e)),J=E(import.meta.url);const Rn=/^path$/i,zn={key:`PATH`,value:``};function Bn(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Rn.test(t))continue;let n=e[t];return n?{key:t,value:n}:zn}return zn}function Vn(e,t){let n=t.value.split(d),r=e,i;do n.push(h(r,`node_modules`,`.bin`)),i=r,r=f(r);while(r!==i);return{key:t.key,value:n.join(d)}}function Hn(e,t){let n={...process.env,...t},r=Vn(e,Bn(n));return n[r.key]=r.value,n}const Un=e=>{let t=e.length,n=new te,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var Wn=q((e,t)=>{t.exports=a,a.sync=o;var n=J(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}}),Gn=q((e,t)=>{t.exports=r,r.sync=i;var n=J(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}}),Kn=q((e,t)=>{J(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Wn():Gn();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}}),qn=q((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=J(`path`),i=n?`;`:`:`,a=Kn(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}}),Jn=q((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n}),Yn=q((e,t)=>{let n=J(`path`),r=qn(),i=Jn();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o}),Xn=q((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,`$1$1\\"`),e=e.replace(/(\\*)$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i}),Zn=q((e,t)=>{t.exports=/^#!(.*)/}),Qn=q((e,t)=>{let n=Zn();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}}),$n=q((e,t)=>{let n=J(`fs`),r=Qn();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i}),er=q((e,t)=>{let n=J(`path`),r=Yn(),i=Xn(),a=$n(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d}),tr=q((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t,`spawn`);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}}),nr=Ln(q((e,t)=>{let n=J(`child_process`),r=er(),i=tr();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i})(),1),rr=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const ir={timeout:void 0,persist:!1},ar={windowsHide:!0};function or(e,t){return{command:m(e),args:t??[]}}function sr(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function cr(e){let t=``;for await(let n of e)t+=n.toString();return t}var lr=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...ir,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return dr(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=Un(t),r=T.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new rr(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?cr(this._streamOut):``,this._streamErr?cr(this._streamErr):``]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new rr(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=x(),t=this._options,n={...ar,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=sr(r)),n.env=Hn(e,n.env);let{command:i,args:a}=or(this._command,this._args),o=(0,nr._parse)(i,a,n),s=re(o.command,o.args,o.options);if(s.stderr&&(this._streamErr=s.stderr),s.stdout&&(this._streamOut=s.stdout),this._process=s,s.once(`error`,this._onError),s.once(`close`,this._onClose),t.stdin!==void 0&&s.stdin&&t.stdin.process){let{stdout:e}=t.stdin.process;e&&e.pipe(s.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const ur=(e,t,n)=>{let r=new lr(e,t,n);return r.spawn(),r},dr=ur;var fr=e({detectPackageManager:()=>yr,installDependencies:()=>br,packageManagers:()=>Y});async function pr(e,t,n={}){let r=wn(e).split(`/`);for(;r.length>0;){let e=await t(r.join(`/`)||`/`);if(e||!n.includeParentDirs)return e;r.pop()}}function mr(e){let t;return()=>(t===void 0&&(t=e().then(e=>(t=e,t))),t)}const hr=mr(async()=>{if(globalThis.process?.versions?.webcontainer)return!1;try{let{exitCode:e}=await ur(`corepack`,[`--version`]);return e===0}catch{return!1}});async function gr(e,t,n={}){let r=e!==`npm`&&e!==`bun`&&e!==`deno`&&n.corepack!==!1&&await hr()?[`corepack`,[e,...t]]:[e,t],{exitCode:i,stdout:a,stderr:o}=await ur(r[0],r[1],{nodeOptions:{cwd:G(n.cwd||process.cwd()),env:n.env,stdio:n.silent?`pipe`:`inherit`}});if(i!==0)throw Error(`\`${r.flat().join(` `)}\` failed.${n.silent?[``,a,o].join(`
95
+ `):``}`)}async function _r(e={}){let t=e.cwd||process.cwd(),n={...process.env,...e.env},r=(typeof e.packageManager==`string`?Y.find(t=>t.name===e.packageManager):e.packageManager)||await yr(e.cwd||process.cwd());if(!r)throw Error(`No package manager auto-detected.`);return{cwd:t,env:n,silent:e.silent??!1,packageManager:r,dev:e.dev??!1,workspace:e.workspace,global:e.global??!1,dry:e.dry??!1,corepack:e.corepack??!0}}function vr(e){let[t,n]=(e||``).split(`@`),[r,i]=n?.split(`+`)||[];if(t&&t!==`-`&&/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t))return{name:t,version:r,buildMeta:i};let a=(t||``).replace(/\W+/g,``);return{name:a,version:r,buildMeta:i,warnings:[`Abnormal characters found in \`packageManager\` field, sanitizing from \`${t}\` to \`${a}\``]}}const Y=[{name:`npm`,command:`npm`,lockFile:`package-lock.json`},{name:`pnpm`,command:`pnpm`,lockFile:`pnpm-lock.yaml`,files:[`pnpm-workspace.yaml`]},{name:`bun`,command:`bun`,lockFile:[`bun.lockb`,`bun.lock`]},{name:`yarn`,command:`yarn`,lockFile:`yarn.lock`,files:[`.yarnrc.yml`]},{name:`deno`,command:`deno`,lockFile:`deno.lock`,files:[`deno.json`]}];async function yr(e,t={}){let n=await pr(G(e||`.`),async e=>{if(!t.ignorePackageJSON){let t=Tn(e,`package.json`);if(r(t)){let e=JSON.parse(await c(t,`utf8`));if(e?.packageManager){let{name:t,version:n=`0.0.0`,buildMeta:r,warnings:i}=vr(e.packageManager);if(t){let e=n.split(`.`)[0],a=Y.find(n=>n.name===t&&n.majorVersion===e)||Y.find(e=>e.name===t);return{name:t,command:t,version:n,majorVersion:e,buildMeta:r,warnings:i,files:a?.files,lockFile:a?.lockFile}}}}if(r(Tn(e,`deno.json`)))return Y.find(e=>e.name===`deno`)}if(!t.ignoreLockFile){for(let t of Y)if([t.lockFile,t.files].flat().filter(Boolean).some(t=>r(G(e,t))))return{...t}}},{includeParentDirs:t.includeParentDirs??!0});if(!n&&!t.ignoreArgv){let e=process.argv[1];if(e){for(let t of Y)if(RegExp(`[/\\\\]\\.?${t.command}`).test(e))return t}}return n}async function br(e={}){let t=await _r(e),n=e.frozenLockFile?{npm:[`ci`],yarn:[`install`,`--immutable`],bun:[`install`,`--frozen-lockfile`],pnpm:[`install`,`--frozen-lockfile`],deno:[`install`,`--frozen`]}[t.packageManager.name]:[`install`];return e.ignoreWorkspace&&t.packageManager.name===`pnpm`&&n.push(`--ignore-workspace`),t.dry||await gr(t.packageManager.command,n,{cwd:t.cwd,silent:t.silent,corepack:t.corepack}),{exec:{command:t.packageManager.command,args:n}}}async function xr(e,t,i={}){let a=t+`.json`,o=JSON.parse(await c(a,`utf8`).catch(()=>`{}`)),s=(await Z(e,{method:`HEAD`,headers:i.headers}).catch(()=>void 0))?.headers.get(`etag`);if(o.etag===s&&r(t))return;typeof s==`string`&&(o.etag=s);let l=await Z(e,{headers:i.headers});if(l.status>=400)throw Error(`Failed to download ${e}: ${l.status} ${l.statusText}`);let d=n(t);await _(ne)(l.body,d),await u(a,JSON.stringify(o),`utf8`)}const Sr=/^(?<repo>[\w.-]+\/[\w.-]+)(?<subdir>[^#]+)?(?<ref>#[\w./@-]+)?/;function Cr(e){let t=e.match(Sr)?.groups||{};return{repo:t.repo||``,subdir:t.subdir||`/`,ref:t.ref?t.ref.slice(1):`main`}}function X(...e){process.env.DEBUG&&console.debug(`[giget]`,...e)}async function Z(e,t={}){t.headers?.[`sec-fetch-mode`]&&(t.mode=t.headers[`sec-fetch-mode`]);let n=await fetch(e,{...t,headers:Tr(t.headers)}).catch(t=>{throw Error(`Failed to download ${e}: ${t}`,{cause:t})});if(t.validateStatus&&n.status>=400)throw Error(`Failed to fetch ${e}: ${n.status} ${n.statusText}`);return n}function wr(){let e=process.env.XDG_CACHE_HOME?G(process.env.XDG_CACHE_HOME,`giget`):G(ie(),`.cache/giget`);if(process.platform===`win32`){let t=G(ae(),`giget`);if(!r(t)&&r(e))try{a(e,t)}catch{}return t}return e}function Tr(e={}){let t={};for(let[n,r]of Object.entries(e))r&&(t[n.toLowerCase()]=r);return t}const Er=async(e,t)=>{if(e.endsWith(`.json`))return await Dr(e,t);let n=new URL(e),r=kn(n.pathname);try{let i=await Z(n.href,{method:`HEAD`,validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if((i.headers.get(`content-type`)||``).includes(`application/json`))return await Dr(e,t);let a=i.headers.get(`content-disposition`)?.match(/filename="?(.+)"?/)?.[1];a&&(r=a.split(`.`)[0])}catch(e){X(`Failed to fetch HEAD for ${n.href}:`,e)}return{name:`${r}-${n.href.slice(0,8)}`,version:``,subdir:``,tar:n.href,defaultDir:r,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0}}},Dr=async(e,t)=>{let n=await(await Z(e,{validateStatus:!0,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}})).json();if(!n.tar||!n.name)throw Error(`Invalid template info from ${e}. name or tar fields are missing!`);return n},Or=(e,t)=>{let n=Cr(e),r=process.env.GIGET_GITHUB_URL||`https://api.github.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`},url:`${r.replace(`api.github.com`,`github.com`)}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/repos/${n.repo}/tarball/${n.ref}`}},kr={http:Er,https:Er,github:Or,gh:Or,gitlab:(e,t)=>{let n=Cr(e),r=process.env.GIGET_GITLAB_URL||`https://gitlab.com`;return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0,"sec-fetch-mode":`same-origin`},url:`${r}/${n.repo}/tree/${n.ref}${n.subdir}`,tar:`${r}/${n.repo}/-/archive/${n.ref}.tar.gz`}},bitbucket:(e,t)=>{let n=Cr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://bitbucket.com/${n.repo}/src/${n.ref}${n.subdir}`,tar:`https://bitbucket.org/${n.repo}/get/${n.ref}.tar.gz`}},sourcehut:(e,t)=>{let n=Cr(e);return{name:n.repo.replace(`/`,`-`),version:n.ref,subdir:n.subdir,headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0},url:`https://git.sr.ht/~${n.repo}/tree/${n.ref}/item${n.subdir}`,tar:`https://git.sr.ht/~${n.repo}/archive/${n.ref}.tar.gz`}}},Ar=(e=`https://raw.githubusercontent.com/unjs/giget/main/templates`,t={})=>(async n=>{let r=Date.now(),i=`${e}/${n}.json`,a=await Z(i,{headers:{authorization:t.auth?`Bearer ${t.auth}`:void 0}});if(a.status>=400)throw Error(`Failed to download ${n} template info from ${i}: ${a.status} ${a.statusText}`);let o=await a.json();if(!o.tar||!o.name)throw Error(`Invalid template info from ${i}. name or tar fields are missing!`);return X(`Fetched ${n} template info from ${i} in ${Date.now()-r}ms`),o}),jr=/^([\w-.]+):/;async function Mr(e,t={}){t.registry=process.env.GIGET_REGISTRY??t.registry,t.auth=process.env.GIGET_AUTH??t.auth;let n=t.registry===!1?void 0:Ar(t.registry,{auth:t.auth}),a=t.provider||(n?`registry`:`github`),o=e,c=e.match(jr);c&&(a=c[1],o=e.slice(c[0].length),(a===`http`||a===`https`)&&(o=e));let u=t.providers?.[a]||kr[a]||n;if(!u)throw Error(`Unsupported provider: ${a}`);let d=await Promise.resolve().then(()=>u(o,{auth:t.auth})).catch(e=>{throw Error(`Failed to download template from ${a}: ${e.message}`)});if(!d)throw Error(`Failed to resolve template from ${a}`);d.name=(d.name||`template`).replace(/[^\da-z-]/gi,`-`),d.defaultDir=(d.defaultDir||d.name).replace(/[^\da-z-]/gi,`-`);let f=G(G(wr(),a,d.name),(d.version||d.name)+`.tar.gz`);if(t.preferOffline&&r(f)&&(t.offline=!0),!t.offline){await s(On(f),{recursive:!0});let e=Date.now();await xr(d.tar,f,{headers:{Authorization:t.auth?`Bearer ${t.auth}`:void 0,...Tr(d.headers)}}).catch(e=>{if(!r(f))throw e;X(`Download error. Using cached version:`,e),t.offline=!0}),X(`Downloaded ${d.tar} to ${f} in ${Date.now()-e}ms`)}if(!r(f))throw Error(`Tarball not found: ${f} (offline: ${t.offline})`);let p=G(G(t.cwd||`.`),t.dir||d.defaultDir);if(t.forceClean&&await l(p,{recursive:!0,force:!0}),!t.force&&r(p)&&i(p).length>0)throw Error(`Destination ${p} already exists.`);await s(p,{recursive:!0});let m=Date.now(),h=d.subdir?.replace(/^\//,``)||``,{extract:g}=await import(`./tar-B68WOji2.mjs`).then(e=>e.t);if(await g({file:f,cwd:p,onReadEntry(e){e.path=e.path.split(`/`).splice(1).join(`/`),h&&(e.path.startsWith(h+`/`)?e.path=e.path.slice(h.length):e.path=``)}}),X(`Extracted to ${p} in ${Date.now()-m}ms`),t.install){X(`Installing dependencies...`);let{installDependencies:e}=await Promise.resolve().then(()=>vn).then(e=>e.t);await e({cwd:p,silent:t.silent,...typeof t.install==`object`?t.install:{}})}return{...d,source:o,dir:p}}var Nr=Object.create,Pr=Object.defineProperty,Fr=Object.getOwnPropertyDescriptor,Ir=Object.getOwnPropertyNames,Lr=Object.getPrototypeOf,Rr=Object.prototype.hasOwnProperty,Q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zr=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Ir(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Rr.call(e,s)&&s!==n&&Pr(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Fr(t,s))||r.enumerable});return e},Br=(e,t,n)=>(n=e==null?{}:Nr(Lr(e)),zr(t||!e||!e.__esModule?Pr(n,`default`,{value:e,enumerable:!0}):n,e)),$=E(import.meta.url);const Vr=/^path$/i,Hr={key:`PATH`,value:``};function Ur(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Vr.test(t))continue;let n=e[t];return n?{key:t,value:n}:Hr}return Hr}function Wr(e,t){let n=t.value.split(d),r=e,i;do n.push(h(r,`node_modules`,`.bin`)),i=r,r=f(r);while(r!==i);return{key:t.key,value:n.join(d)}}function Gr(e,t){let n={...process.env,...t},r=Wr(e,Ur(n));return n[r.key]=r.value,n}const Kr=e=>{let t=e.length,n=new te,r=()=>{--t===0&&n.emit(`end`)};for(let t of e)t.pipe(n,{end:!1}),t.on(`end`,r);return n};var qr=Q((e,t)=>{t.exports=a,a.sync=o;var n=$(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}}),Jr=Q((e,t)=>{t.exports=r,r.sync=i;var n=$(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}}),Yr=Q((e,t)=>{$(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?qr():Jr();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}}),Xr=Q((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=$(`path`),i=n?`;`:`:`,a=Yr(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}}),Zr=Q((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n}),Qr=Q((e,t)=>{let n=$(`path`),r=Xr(),i=Zr();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o}),$r=Q((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,`$1$1\\"`),e=e.replace(/(\\*)$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i}),ei=Q((e,t)=>{t.exports=/^#!(.*)/}),ti=Q((e,t)=>{let n=ei();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}}),ni=Q((e,t)=>{let n=$(`fs`),r=ti();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i}),ri=Q((e,t)=>{let n=$(`path`),r=Qr(),i=$r(),a=ni(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d}),ii=Q((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t,`spawn`);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}}),ai=Br(Q((e,t)=>{let n=$(`child_process`),r=ri(),i=ii();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i})(),1),oi=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t}};const si={timeout:void 0,persist:!1},ci={windowsHide:!0};function li(e,t){return{command:m(e),args:t??[]}}function ui(e){let t=new AbortController;for(let n of e){if(n.aborted)return t.abort(),n;n.addEventListener(`abort`,()=>{t.abort(n.reason)},{signal:t.signal})}return t.signal}async function di(e){let t=``;for await(let n of e)t+=n.toString();return t}var fi=class{_process;_aborted=!1;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,n){this._options={...si,...n},this._command=e,this._args=t??[],this._processClosed=new Promise(e=>{this._resolveClose=e})}kill(e){return this._process?.kill(e)===!0}get aborted(){return this._aborted}get killed(){return this._process?.killed===!0}pipe(e,t,n){return mi(e,t,{...n,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let n=Kr(t),r=T.createInterface({input:n});for await(let e of r)yield e.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new oi(this)}async _waitForOutput(){let e=this._process;if(!e)throw Error(`No process was started`);let[t,n]=await Promise.all([this._streamOut?di(this._streamOut):``,this._streamErr?di(this._streamErr):``]);if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:n,stdout:t,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new oi(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=x(),t=this._options,n={...ci,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===!0&&(n.detached=!0),r.length>0&&(n.signal=ui(r)),n.env=Gr(e,n.env);let{command:i,args:a}=li(this._command,this._args),o=(0,ai._parse)(i,a,n),s=re(o.command,o.args,o.options);if(s.stderr&&(this._streamErr=s.stderr),s.stdout&&(this._streamOut=s.stdout),this._process=s,s.once(`error`,this._onError),s.once(`close`,this._onClose),t.stdin!==void 0&&s.stdin&&t.stdin.process){let{stdout:e}=t.stdin.process;e&&e.pipe(s.stdin)}}_resetState(){this._aborted=!1,this._processClosed=new Promise(e=>{this._resolveClose=e}),this._thrownError=void 0}_onError=e=>{if(e.name===`AbortError`&&(!(e.cause instanceof Error)||e.cause.name!==`TimeoutError`)){this._aborted=!0;return}this._thrownError=e};_onClose=()=>{this._resolveClose&&this._resolveClose()}};const pi=(e,t,n)=>{let r=new fi(e,t,n);return r.spawn(),r},mi=pi;function hi(){let e=process.env.npm_config_user_agent??``;return e.startsWith(`pnpm/`)?`pnpm`:e.startsWith(`yarn/`)?`yarn`:e.startsWith(`bun/`)?`bun`:e.startsWith(`deno/`)?`deno`:`npm`}async function gi(){try{return await pi(`pnpm`,[`--version`],{throwOnError:!0}),!0}catch{return!1}}_n(dn({meta:{name:`create-mugnavo`,version:`0.1.1`},args:{name:{type:`positional`,description:`Project name`,required:!1},template:{type:`enum`,description:`Template to use`,options:[`tanstarter`,`tanstarter-monorepo`],required:!1},install:{type:`boolean`,description:`Install dependencies`,required:!1},packageManager:{type:`enum`,description:`Package manager to use`,options:[`pnpm`,`npm`,`bun`,`yarn`],required:!1}},async run({args:e}){let n=e.name,r=e.template,i=e.install,a=e.packageManager,s=await gi()?`pnpm`:hi();if(!n&&(n=await Wt({message:`Project name?`,placeholder:`my-project`,defaultValue:`my-project`,validate(e){if(e&&e.includes(` `))return`Project name cannot contain spaces`}}),A(n))){Mt(`Operation cancelled.`);return}if(!r&&(r=await Bt({message:`Select a template to use`,options:[{value:`tanstarter`,label:`TanStarter`},{value:`tanstarter-monorepo`,label:`TanStarter (Monorepo)`,hint:`Turborepo`}]}),A(r))){Mt(`Operation cancelled.`);return}if(i===void 0&&(i=await jt({message:`Install dependencies after scaffolding?`,initialValue:!0}),A(i))){Mt(`Operation cancelled.`);return}if(i&&!a&&(a=await Bt({message:`Select a package manager`,options:[{value:`pnpm`,label:`pnpm (Recommended)`},{value:`npm`,label:`npm`},{value:`bun`,label:`bun`},{value:`yarn`,label:`yarn`},{value:`deno`,label:`deno`}],initialValue:s}),A(a))){Mt(`Operation cancelled.`);return}let c=Rt();try{c.start(`Cloning project...`);let{dir:e,source:u}=await Mr(`github:mugnavo/tanstarter${r===`tanstarter-monorepo`?`#next`:``}`,{dir:String(n)});try{await l(p(e,`LICENSE`),{force:!0})}catch{}try{r===`tanstarter`?await o(p(e,`.env.example`),p(e,`.env`),t.COPYFILE_EXCL):r===`tanstarter-monorepo`&&(await o(p(e,`apps`,`web`,`.env.example`),p(e,`apps`,`web`,`.env`),t.COPYFILE_EXCL),await o(p(e,`packages`,`db`,`.env.example`),p(e,`packages`,`db`,`.env`),t.COPYFILE_EXCL))}catch{}let d=String(a||s);if(c.stop(`Project cloned from ${u}`),await pi(`git`,[`init`],{throwOnError:!1,nodeOptions:{cwd:e,stdio:`inherit`}}),i){let t=Ut({title:`Installing dependencies with ${d}...`,limit:5,retainLog:!1}),n=pi(d,[`install`],{throwOnError:!1,nodeOptions:{cwd:e}});for await(let e of n){let n=e.trim();n&&t.message(n)}(await n).exitCode===0?t.success(`Dependencies installed`):(i=!1,t.error(`Dependency installation failed. You can run ${d} install manually.`))}let f=d===`npm`?`npm run dev`:d===`deno`?`deno task dev`:`${d} dev`,m=`https://github.com/mugnavo/tanstarter${r===`tanstarter-monorepo`?`/tree/next`:``}`;It(`cd ${String(n)}${i?``:`\n${d} install`}\n${f}\n\nSee README.md for next steps\n${m}`,`Next steps`),Nt(`Project created successfully`)}catch(e){c.stop(),Nt(`Failed to download template. Please try again later.`),console.error(e);return}}}));export{};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&&e(r,Symbol.toStringTag,{value:`Module`}),r};export{t};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{t as e}from"./rolldown-runtime-Bbnr-mUN.mjs";import t from"node:fs";import n from"node:fs/promises";import r,{basename as i,join as a,posix as o,win32 as s}from"node:path";import c from"node:stream";import l,{EventEmitter as u}from"events";import d from"fs";import{EventEmitter as f}from"node:events";import{StringDecoder as ee}from"node:string_decoder";import p from"assert";import{Buffer as m}from"buffer";import*as te from"zlib";import ne from"zlib";import re,{dirname as ie,parse as ae}from"path";import oe from"node:assert";import{randomBytes as se}from"node:crypto";const ce=typeof process==`object`&&process?process:{stdout:null,stderr:null},le=e=>!!e&&typeof e==`object`&&(e instanceof Be||e instanceof c||ue(e)||de(e)),ue=e=>!!e&&typeof e==`object`&&e instanceof f&&typeof e.pipe==`function`&&e.pipe!==c.Writable.prototype.pipe,de=e=>!!e&&typeof e==`object`&&e instanceof f&&typeof e.write==`function`&&typeof e.end==`function`,h=Symbol(`EOF`),g=Symbol(`maybeEmitEnd`),_=Symbol(`emittedEnd`),fe=Symbol(`emittingEnd`),pe=Symbol(`emittedError`),me=Symbol(`closed`),he=Symbol(`read`),ge=Symbol(`flush`),_e=Symbol(`flushChunk`),v=Symbol(`encoding`),ve=Symbol(`decoder`),y=Symbol(`flowing`),ye=Symbol(`paused`),be=Symbol(`resume`),b=Symbol(`buffer`),x=Symbol(`pipes`),S=Symbol(`bufferLength`),xe=Symbol(`bufferPush`),Se=Symbol(`bufferShift`),C=Symbol(`objectMode`),w=Symbol(`destroyed`),Ce=Symbol(`error`),we=Symbol(`emitData`),Te=Symbol(`emitEnd`),Ee=Symbol(`emitEnd2`),T=Symbol(`async`),De=Symbol(`abort`),Oe=Symbol(`aborted`),ke=Symbol(`signal`),Ae=Symbol(`dataListeners`),E=Symbol(`discarded`),je=e=>Promise.resolve().then(e),Me=e=>e(),Ne=e=>e===`end`||e===`finish`||e===`prefinish`,Pe=e=>e instanceof ArrayBuffer||!!e&&typeof e==`object`&&e.constructor&&e.constructor.name===`ArrayBuffer`&&e.byteLength>=0,Fe=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e);var Ie=class{src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[be](),this.dest.on(`drain`,this.ondrain)}unpipe(){this.dest.removeListener(`drain`,this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Le=class extends Ie{unpipe(){this.src.removeListener(`error`,this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=e=>t.emit(`error`,e),e.on(`error`,this.proxyErrors)}};const Re=e=>!!e.objectMode,ze=e=>!e.objectMode&&!!e.encoding&&e.encoding!==`buffer`;var Be=class extends f{[y]=!1;[ye]=!1;[x]=[];[b]=[];[C];[v];[T];[ve];[h]=!1;[_]=!1;[fe]=!1;[me]=!1;[pe]=null;[S]=0;[w]=!1;[ke];[Oe]=!1;[Ae]=0;[E]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding==`string`)throw TypeError(`Encoding and objectMode may not be used together`);Re(t)?(this[C]=!0,this[v]=null):ze(t)?(this[v]=t.encoding,this[C]=!1):(this[C]=!1,this[v]=null),this[T]=!!t.async,this[ve]=this[v]?new ee(this[v]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,`buffer`,{get:()=>this[b]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,`pipes`,{get:()=>this[x]});let{signal:n}=t;n&&(this[ke]=n,n.aborted?this[De]():n.addEventListener(`abort`,()=>this[De]()))}get bufferLength(){return this[S]}get encoding(){return this[v]}set encoding(e){throw Error(`Encoding must be set at instantiation time`)}setEncoding(e){throw Error(`Encoding must be set at instantiation time`)}get objectMode(){return this[C]}set objectMode(e){throw Error(`objectMode must be set at instantiation time`)}get async(){return this[T]}set async(e){this[T]=this[T]||!!e}[De](){this[Oe]=!0,this.emit(`abort`,this[ke]?.reason),this.destroy(this[ke]?.reason)}get aborted(){return this[Oe]}set aborted(e){}write(e,t,n){if(this[Oe])return!1;if(this[h])throw Error(`write after end`);if(this[w])return this.emit(`error`,Object.assign(Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`})),!0;typeof t==`function`&&(n=t,t=`utf8`),t||=`utf8`;let r=this[T]?je:Me;if(!this[C]&&!Buffer.isBuffer(e)){if(Fe(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(Pe(e))e=Buffer.from(e);else if(typeof e!=`string`)throw Error(`Non-contiguous data written to non-objectMode stream`)}return this[C]?(this[y]&&this[S]!==0&&this[ge](!0),this[y]?this.emit(`data`,e):this[xe](e),this[S]!==0&&this.emit(`readable`),n&&r(n),this[y]):e.length?(typeof e==`string`&&!(t===this[v]&&!this[ve]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[v]&&(e=this[ve].write(e)),this[y]&&this[S]!==0&&this[ge](!0),this[y]?this.emit(`data`,e):this[xe](e),this[S]!==0&&this.emit(`readable`),n&&r(n),this[y]):(this[S]!==0&&this.emit(`readable`),n&&r(n),this[y])}read(e){if(this[w])return null;if(this[E]=!1,this[S]===0||e===0||e&&e>this[S])return this[g](),null;this[C]&&(e=null),this[b].length>1&&!this[C]&&(this[b]=[this[v]?this[b].join(``):Buffer.concat(this[b],this[S])]);let t=this[he](e||null,this[b][0]);return this[g](),t}[he](e,t){if(this[C])this[Se]();else{let n=t;e===n.length||e===null?this[Se]():typeof n==`string`?(this[b][0]=n.slice(e),t=n.slice(0,e),this[S]-=e):(this[b][0]=n.subarray(e),t=n.subarray(0,e),this[S]-=e)}return this.emit(`data`,t),!this[b].length&&!this[h]&&this.emit(`drain`),t}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=`utf8`),e!==void 0&&this.write(e,t),n&&this.once(`end`,n),this[h]=!0,this.writable=!1,(this[y]||!this[ye])&&this[g](),this}[be](){this[w]||(!this[Ae]&&!this[x].length&&(this[E]=!0),this[ye]=!1,this[y]=!0,this.emit(`resume`),this[b].length?this[ge]():this[h]?this[g]():this.emit(`drain`))}resume(){return this[be]()}pause(){this[y]=!1,this[ye]=!0,this[E]=!1}get destroyed(){return this[w]}get flowing(){return this[y]}get paused(){return this[ye]}[xe](e){this[C]?this[S]+=1:this[S]+=e.length,this[b].push(e)}[Se](){return this[C]?--this[S]:this[S]-=this[b][0].length,this[b].shift()}[ge](e=!1){do;while(this[_e](this[Se]())&&this[b].length);!e&&!this[b].length&&!this[h]&&this.emit(`drain`)}[_e](e){return this.emit(`data`,e),this[y]}pipe(e,t){if(this[w])return e;this[E]=!1;let n=this[_];return t||={},e===ce.stdout||e===ce.stderr?t.end=!1:t.end=t.end!==!1,t.proxyErrors=!!t.proxyErrors,n?t.end&&e.end():(this[x].push(t.proxyErrors?new Le(this,e,t):new Ie(this,e,t)),this[T]?je(()=>this[be]()):this[be]()),e}unpipe(e){let t=this[x].find(t=>t.dest===e);t&&(this[x].length===1?(this[y]&&this[Ae]===0&&(this[y]=!1),this[x]=[]):this[x].splice(this[x].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e===`data`)this[E]=!1,this[Ae]++,!this[x].length&&!this[y]&&this[be]();else if(e===`readable`&&this[S]!==0)super.emit(`readable`);else if(Ne(e)&&this[_])super.emit(e),this.removeAllListeners(e);else if(e===`error`&&this[pe]){let e=t;this[T]?je(()=>e.call(this,this[pe])):e.call(this,this[pe])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e===`data`&&(this[Ae]=this.listeners(`data`).length,this[Ae]===0&&!this[E]&&!this[x].length&&(this[y]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e===`data`||e===void 0)&&(this[Ae]=0,!this[E]&&!this[x].length&&(this[y]=!1)),t}get emittedEnd(){return this[_]}[g](){!this[fe]&&!this[_]&&!this[w]&&this[b].length===0&&this[h]&&(this[fe]=!0,this.emit(`end`),this.emit(`prefinish`),this.emit(`finish`),this[me]&&this.emit(`close`),this[fe]=!1)}emit(e,...t){let n=t[0];if(e!==`error`&&e!==`close`&&e!==w&&this[w])return!1;if(e===`data`)return!this[C]&&!n?!1:this[T]?(je(()=>this[we](n)),!0):this[we](n);if(e===`end`)return this[Te]();if(e===`close`){if(this[me]=!0,!this[_]&&!this[w])return!1;let e=super.emit(`close`);return this.removeAllListeners(`close`),e}else if(e===`error`){this[pe]=n,super.emit(Ce,n);let e=!this[ke]||this.listeners(`error`).length?super.emit(`error`,n):!1;return this[g](),e}else if(e===`resume`){let e=super.emit(`resume`);return this[g](),e}else if(e===`finish`||e===`prefinish`){let t=super.emit(e);return this.removeAllListeners(e),t}let r=super.emit(e,...t);return this[g](),r}[we](e){for(let t of this[x])t.dest.write(e)===!1&&this.pause();let t=this[E]?!1:super.emit(`data`,e);return this[g](),t}[Te](){return this[_]?!1:(this[_]=!0,this.readable=!1,this[T]?(je(()=>this[Ee]()),!0):this[Ee]())}[Ee](){if(this[ve]){let e=this[ve].end();if(e){for(let t of this[x])t.dest.write(e);this[E]||super.emit(`data`,e)}}for(let e of this[x])e.end();let e=super.emit(`end`);return this.removeAllListeners(`end`),e}async collect(){let e=Object.assign([],{dataLength:0});this[C]||(e.dataLength=0);let t=this.promise();return this.on(`data`,t=>{e.push(t),this[C]||(e.dataLength+=t.length)}),await t,e}async concat(){if(this[C])throw Error(`cannot concat in objectMode`);let e=await this.collect();return this[v]?e.join(``):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(w,()=>t(Error(`stream destroyed`))),this.on(`error`,e=>t(e)),this.on(`end`,()=>e())})}[Symbol.asyncIterator](){this[E]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[h])return t();let r,i,a=e=>{this.off(`data`,o),this.off(`end`,s),this.off(w,c),t(),i(e)},o=e=>{this.off(`error`,a),this.off(`end`,s),this.off(w,c),this.pause(),r({value:e,done:!!this[h]})},s=()=>{this.off(`error`,a),this.off(`data`,o),this.off(w,c),t(),r({done:!0,value:void 0})},c=()=>a(Error(`stream destroyed`));return new Promise((e,t)=>{i=t,r=e,this.once(w,c),this.once(`error`,a),this.once(`end`,s),this.once(`data`,o)})},throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[E]=!1;let e=!1,t=()=>(this.pause(),this.off(Ce,t),this.off(w,t),this.off(`end`,t),e=!0,{done:!0,value:void 0});return this.once(`end`,t),this.once(Ce,t),this.once(w,t),{next:()=>{if(e)return t();let n=this.read();return n===null?t():{done:!1,value:n}},throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[w])return e?this.emit(`error`,e):this.emit(w),this;this[w]=!0,this[E]=!0,this[b].length=0,this[S]=0;let t=this;return typeof t.close==`function`&&!this[me]&&t.close(),e?this.emit(`error`,e):this.emit(w),this}static get isStream(){return le}};const Ve=d.writev,D=Symbol(`_autoClose`),O=Symbol(`_close`),He=Symbol(`_ended`),k=Symbol(`_fd`),Ue=Symbol(`_finished`),A=Symbol(`_flags`),We=Symbol(`_flush`),Ge=Symbol(`_handleChunk`),Ke=Symbol(`_makeBuf`),qe=Symbol(`_mode`),Je=Symbol(`_needDrain`),Ye=Symbol(`_onerror`),Xe=Symbol(`_onopen`),Ze=Symbol(`_onread`),Qe=Symbol(`_onwrite`),j=Symbol(`_open`),M=Symbol(`_path`),N=Symbol(`_pos`),P=Symbol(`_queue`),$e=Symbol(`_read`),et=Symbol(`_readSize`),F=Symbol(`_reading`),tt=Symbol(`_remain`),nt=Symbol(`_size`),rt=Symbol(`_write`),it=Symbol(`_writing`),at=Symbol(`_defaultFlag`),ot=Symbol(`_errored`);var st=class extends Be{[ot]=!1;[k];[M];[et];[F]=!1;[nt];[tt];[D];constructor(e,t){if(t||={},super(t),this.readable=!0,this.writable=!1,typeof e!=`string`)throw TypeError(`path must be a string`);this[ot]=!1,this[k]=typeof t.fd==`number`?t.fd:void 0,this[M]=e,this[et]=t.readSize||16*1024*1024,this[F]=!1,this[nt]=typeof t.size==`number`?t.size:1/0,this[tt]=this[nt],this[D]=typeof t.autoClose==`boolean`?t.autoClose:!0,typeof this[k]==`number`?this[$e]():this[j]()}get fd(){return this[k]}get path(){return this[M]}write(){throw TypeError(`this is a readable stream`)}end(){throw TypeError(`this is a readable stream`)}[j](){d.open(this[M],`r`,(e,t)=>this[Xe](e,t))}[Xe](e,t){e?this[Ye](e):(this[k]=t,this.emit(`open`,t),this[$e]())}[Ke](){return Buffer.allocUnsafe(Math.min(this[et],this[tt]))}[$e](){if(!this[F]){this[F]=!0;let e=this[Ke]();if(e.length===0)return process.nextTick(()=>this[Ze](null,0,e));d.read(this[k],e,0,e.length,null,(e,t,n)=>this[Ze](e,t,n))}}[Ze](e,t,n){this[F]=!1,e?this[Ye](e):this[Ge](t,n)&&this[$e]()}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.close(e,e=>e?this.emit(`error`,e):this.emit(`close`))}}[Ye](e){this[F]=!0,this[O](),this.emit(`error`,e)}[Ge](e,t){let n=!1;return this[tt]-=e,e>0&&(n=super.write(e<t.length?t.subarray(0,e):t)),(e===0||this[tt]<=0)&&(n=!1,this[O](),super.end()),n}emit(e,...t){switch(e){case`prefinish`:case`finish`:return!1;case`drain`:return typeof this[k]==`number`&&this[$e](),!1;case`error`:return this[ot]?!1:(this[ot]=!0,super.emit(e,...t));default:return super.emit(e,...t)}}},ct=class extends st{[j](){let e=!0;try{this[Xe](null,d.openSync(this[M],`r`)),e=!1}finally{e&&this[O]()}}[$e](){let e=!0;try{if(!this[F]){this[F]=!0;do{let e=this[Ke](),t=e.length===0?0:d.readSync(this[k],e,0,e.length,null);if(!this[Ge](t,e))break}while(!0);this[F]=!1}e=!1}finally{e&&this[O]()}}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.closeSync(e),this.emit(`close`)}}},lt=class extends l{readable=!1;writable=!0;[ot]=!1;[it]=!1;[He]=!1;[P]=[];[Je]=!1;[M];[qe];[D];[k];[at];[A];[Ue]=!1;[N];constructor(e,t){t||={},super(t),this[M]=e,this[k]=typeof t.fd==`number`?t.fd:void 0,this[qe]=t.mode===void 0?438:t.mode,this[N]=typeof t.start==`number`?t.start:void 0,this[D]=typeof t.autoClose==`boolean`?t.autoClose:!0;let n=this[N]===void 0?`w`:`r+`;this[at]=t.flags===void 0,this[A]=t.flags===void 0?n:t.flags,this[k]===void 0&&this[j]()}emit(e,...t){if(e===`error`){if(this[ot])return!1;this[ot]=!0}return super.emit(e,...t)}get fd(){return this[k]}get path(){return this[M]}[Ye](e){this[O](),this[it]=!0,this.emit(`error`,e)}[j](){d.open(this[M],this[A],this[qe],(e,t)=>this[Xe](e,t))}[Xe](e,t){this[at]&&this[A]===`r+`&&e&&e.code===`ENOENT`?(this[A]=`w`,this[j]()):e?this[Ye](e):(this[k]=t,this.emit(`open`,t),this[it]||this[We]())}end(e,t){return e&&this.write(e,t),this[He]=!0,!this[it]&&!this[P].length&&typeof this[k]==`number`&&this[Qe](null,0),this}write(e,t){return typeof e==`string`&&(e=Buffer.from(e,t)),this[He]?(this.emit(`error`,Error(`write() after end()`)),!1):this[k]===void 0||this[it]||this[P].length?(this[P].push(e),this[Je]=!0,!1):(this[it]=!0,this[rt](e),!0)}[rt](e){d.write(this[k],e,0,e.length,this[N],(e,t)=>this[Qe](e,t))}[Qe](e,t){e?this[Ye](e):(this[N]!==void 0&&typeof t==`number`&&(this[N]+=t),this[P].length?this[We]():(this[it]=!1,this[He]&&!this[Ue]?(this[Ue]=!0,this[O](),this.emit(`finish`)):this[Je]&&(this[Je]=!1,this.emit(`drain`))))}[We](){if(this[P].length===0)this[He]&&this[Qe](null,0);else if(this[P].length===1)this[rt](this[P].pop());else{let e=this[P];this[P]=[],Ve(this[k],e,this[N],(e,t)=>this[Qe](e,t))}}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.close(e,e=>e?this.emit(`error`,e):this.emit(`close`))}}},ut=class extends lt{[j](){let e;if(this[at]&&this[A]===`r+`)try{e=d.openSync(this[M],this[A],this[qe])}catch(e){if(e?.code===`ENOENT`)return this[A]=`w`,this[j]();throw e}else e=d.openSync(this[M],this[A],this[qe]);this[Xe](null,e)}[O](){if(this[D]&&typeof this[k]==`number`){let e=this[k];this[k]=void 0,d.closeSync(e),this.emit(`close`)}}[rt](e){let t=!0;try{this[Qe](null,d.writeSync(this[k],e,0,e.length,this[N])),t=!1}finally{if(t)try{this[O]()}catch{}}}};const dt=ne.constants||{ZLIB_VERNUM:4736},I=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},dt)),ft=m.concat,pt=Object.getOwnPropertyDescriptor(m,`concat`),mt=e=>e,ht=pt?.writable===!0||pt?.set!==void 0?e=>{m.concat=e?mt:ft}:e=>{},gt=Symbol(`_superWrite`);var _t=class extends Error{code;errno;constructor(e,t){super(`zlib: `+e.message,{cause:e}),this.code=e.code,this.errno=e.errno,this.code||=`ZLIB_ERROR`,this.message=`zlib: `+e.message,Error.captureStackTrace(this,t??this.constructor)}get name(){return`ZlibError`}};const vt=Symbol(`flushFlag`);var yt=class extends Be{#e=!1;#t=!1;#n;#r;#i;#a;#o;get sawError(){return this.#e}get handle(){return this.#a}get flushFlag(){return this.#n}constructor(e,t){if(!e||typeof e!=`object`)throw TypeError(`invalid options for ZlibBase constructor`);if(super(e),this.#n=e.flush??0,this.#r=e.finishFlush??0,this.#i=e.fullFlushFlag??0,typeof te[t]!=`function`)throw TypeError(`Compression method not supported: `+t);try{this.#a=new te[t](e)}catch(e){throw new _t(e,this.constructor)}this.#o=e=>{this.#e||(this.#e=!0,this.close(),this.emit(`error`,e))},this.#a?.on(`error`,e=>this.#o(new _t(e))),this.once(`end`,()=>this.close)}close(){this.#a&&(this.#a.close(),this.#a=void 0,this.emit(`close`))}reset(){if(!this.#e)return p(this.#a,`zlib binding closed`),this.#a.reset?.()}flush(e){this.ended||(typeof e!=`number`&&(e=this.#i),this.write(Object.assign(m.alloc(0),{[vt]:e})))}end(e,t,n){return typeof e==`function`&&(n=e,t=void 0,e=void 0),typeof t==`function`&&(n=t,t=void 0),e&&(t?this.write(e,t):this.write(e)),this.flush(this.#r),this.#t=!0,super.end(n)}get ended(){return this.#t}[gt](e){return super.write(e)}write(e,t,n){if(typeof t==`function`&&(n=t,t=`utf8`),typeof e==`string`&&(e=m.from(e,t)),this.#e)return;p(this.#a,`zlib binding closed`);let r=this.#a._handle,i=r.close;r.close=()=>{};let a=this.#a.close;this.#a.close=()=>{},ht(!0);let o;try{let t=typeof e[vt]==`number`?e[vt]:this.#n;o=this.#a._processChunk(e,t),ht(!1)}catch(e){ht(!1),this.#o(new _t(e,this.write))}finally{this.#a&&(this.#a._handle=r,r.close=i,this.#a.close=a,this.#a.removeAllListeners(`error`))}this.#a&&this.#a.on(`error`,e=>this.#o(new _t(e,this.write)));let s;if(o)if(Array.isArray(o)&&o.length>0){let e=o[0];s=this[gt](m.from(e));for(let e=1;e<o.length;e++)s=this[gt](o[e])}else s=this[gt](m.from(o));return n&&n(),s}},bt=class extends yt{#e;#t;constructor(e,t){e||={},e.flush=e.flush||I.Z_NO_FLUSH,e.finishFlush=e.finishFlush||I.Z_FINISH,e.fullFlushFlag=I.Z_FULL_FLUSH,super(e,t),this.#e=e.level,this.#t=e.strategy}params(e,t){if(!this.sawError){if(!this.handle)throw Error(`cannot switch params when binding is closed`);if(!this.handle.params)throw Error(`not supported in this implementation`);if(this.#e!==e||this.#t!==t){this.flush(I.Z_SYNC_FLUSH),p(this.handle,`zlib binding closed`);let n=this.handle.flush;this.handle.flush=(e,t)=>{typeof e==`function`&&(t=e,e=this.flushFlag),this.flush(e),t?.()};try{this.handle.params(e,t)}finally{this.handle.flush=n}this.handle&&(this.#e=e,this.#t=t)}}}},xt=class extends bt{#e;constructor(e){super(e,`Gzip`),this.#e=e&&!!e.portable}[gt](e){return this.#e?(this.#e=!1,e[9]=255,super[gt](e)):super[gt](e)}},St=class extends bt{constructor(e){super(e,`Unzip`)}},Ct=class extends yt{constructor(e,t){e||={},e.flush=e.flush||I.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||I.BROTLI_OPERATION_FINISH,e.fullFlushFlag=I.BROTLI_OPERATION_FLUSH,super(e,t)}},wt=class extends Ct{constructor(e){super(e,`BrotliCompress`)}},Tt=class extends Ct{constructor(e){super(e,`BrotliDecompress`)}},Et=class extends yt{constructor(e,t){e||={},e.flush=e.flush||I.ZSTD_e_continue,e.finishFlush=e.finishFlush||I.ZSTD_e_end,e.fullFlushFlag=I.ZSTD_e_flush,super(e,t)}},Dt=class extends Et{constructor(e){super(e,`ZstdCompress`)}},Ot=class extends Et{constructor(e){super(e,`ZstdDecompress`)}};const kt=(e,n,r)=>{try{return t.lchownSync(e,n,r)}catch(e){if(e?.code!==`ENOENT`)throw e}},At=(e,n,r,i)=>{t.lchown(e,n,r,e=>{i(e&&e?.code!==`ENOENT`?e:null)})},jt=(e,t,n,i,a)=>{t.isDirectory()?Mt(r.resolve(e,t.name),n,i,o=>{if(o)return a(o);At(r.resolve(e,t.name),n,i,a)}):At(r.resolve(e,t.name),n,i,a)},Mt=(e,n,r,i)=>{t.readdir(e,{withFileTypes:!0},(t,a)=>{if(t){if(t.code===`ENOENT`)return i();if(t.code!==`ENOTDIR`&&t.code!==`ENOTSUP`)return i(t)}if(t||!a.length)return At(e,n,r,i);let o=a.length,s=null,c=t=>{if(!s){if(t)return i(s=t);if(--o===0)return At(e,n,r,i)}};for(let t of a)jt(e,t,n,r,c)})},Nt=(e,t,n,i)=>{t.isDirectory()&&Pt(r.resolve(e,t.name),n,i),kt(r.resolve(e,t.name),n,i)},Pt=(e,n,r)=>{let i;try{i=t.readdirSync(e,{withFileTypes:!0})}catch(t){let i=t;if(i?.code===`ENOENT`)return;if(i?.code===`ENOTDIR`||i?.code===`ENOTSUP`)return kt(e,n,r);throw i}for(let t of i)Nt(e,t,n,r);return kt(e,n,r)},Ft=new Map([[`C`,`cwd`],[`f`,`file`],[`z`,`gzip`],[`P`,`preservePaths`],[`U`,`unlink`],[`strip-components`,`strip`],[`stripComponents`,`strip`],[`keep-newer`,`newer`],[`keepNewer`,`newer`],[`keep-newer-files`,`newer`],[`keepNewerFiles`,`newer`],[`k`,`keep`],[`keep-existing`,`keep`],[`keepExisting`,`keep`],[`m`,`noMtime`],[`no-mtime`,`noMtime`],[`p`,`preserveOwner`],[`L`,`follow`],[`h`,`follow`],[`onentry`,`onReadEntry`]]),It=e=>!!e.sync&&!!e.file,Lt=e=>!e.sync&&!!e.file,Rt=e=>!!e.sync&&!e.file,zt=e=>!e.sync&&!e.file,Bt=e=>!!e.file,Vt=e=>Ft.get(e)||e,Ht=(e={})=>{if(!e)return{};let t={};for(let[n,r]of Object.entries(e)){let e=Vt(n);t[e]=r}return t.chmod===void 0&&t.noChmod===!1&&(t.chmod=!0),delete t.noChmod,t},Ut=(e,t,n,r,i)=>Object.assign((a=[],o,s)=>{Array.isArray(a)&&(o=a,a={}),typeof o==`function`&&(s=o,o=void 0),o=o?Array.from(o):[];let c=Ht(a);if(i?.(c,o),It(c)){if(typeof s==`function`)throw TypeError(`callback not supported for sync tar functions`);return e(c,o)}else if(Lt(c)){let e=t(c,o),n=s||void 0;return n?e.then(()=>n(),n):e}else if(Rt(c)){if(typeof s==`function`)throw TypeError(`callback not supported for sync tar functions`);return n(c,o)}else if(zt(c)){if(typeof s==`function`)throw TypeError(`callback only supported with file option`);return r(c,o)}else throw Error(`impossible options??`)},{syncFile:e,asyncFile:t,syncNoFile:n,asyncNoFile:r,validate:i}),Wt=(e,t)=>{if(Number.isSafeInteger(e))e<0?Kt(e,t):Gt(e,t);else throw Error(`cannot encode number outside of javascript safe integer range`);return t},Gt=(e,t)=>{t[0]=128;for(var n=t.length;n>1;n--)t[n-1]=e&255,e=Math.floor(e/256)},Kt=(e,t)=>{t[0]=255;var n=!1;e*=-1;for(var r=t.length;r>1;r--){var i=e&255;e=Math.floor(e/256),n?t[r-1]=Xt(i):i===0?t[r-1]=0:(n=!0,t[r-1]=Zt(i))}},qt=e=>{let t=e[0],n=t===128?Yt(e.subarray(1,e.length)):t===255?Jt(e):null;if(n===null)throw Error(`invalid base256 encoding`);if(!Number.isSafeInteger(n))throw Error(`parsed number outside of javascript safe integer range`);return n},Jt=e=>{for(var t=e.length,n=0,r=!1,i=t-1;i>-1;i--){var a=Number(e[i]),o;r?o=Xt(a):a===0?o=a:(r=!0,o=Zt(a)),o!==0&&(n-=o*256**(t-i-1))}return n},Yt=e=>{for(var t=e.length,n=0,r=t-1;r>-1;r--){var i=Number(e[r]);i!==0&&(n+=i*256**(t-r-1))}return n},Xt=e=>(255^e)&255,Zt=e=>(255^e)+1&255,Qt=e=>$t.has(e),$t=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`]]),en=new Map(Array.from($t).map(e=>[e[1],e[0]]));var L=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,n,r){Buffer.isBuffer(e)?this.decode(e,t||0,n,r):e&&this.#t(e)}decode(e,t,n,r){if(t||=0,!e||!(e.length>=t+512))throw Error(`need 512 bytes for header`);this.path=n?.path??nn(e,t,100),this.mode=n?.mode??r?.mode??R(e,t+100,8),this.uid=n?.uid??r?.uid??R(e,t+108,8),this.gid=n?.gid??r?.gid??R(e,t+116,8),this.size=n?.size??r?.size??R(e,t+124,12),this.mtime=n?.mtime??r?.mtime??rn(e,t+136,12),this.cksum=R(e,t+148,12),r&&this.#t(r,!0),n&&this.#t(n);let i=nn(e,t+156,1);if(Qt(i)&&(this.#e=i||`0`),this.#e===`0`&&this.path.slice(-1)===`/`&&(this.#e=`5`),this.#e===`5`&&(this.size=0),this.linkpath=nn(e,t+157,100),e.subarray(t+257,t+265).toString()===`ustar\x0000`)if(this.uname=n?.uname??r?.uname??nn(e,t+265,32),this.gname=n?.gname??r?.gname??nn(e,t+297,32),this.devmaj=n?.devmaj??r?.devmaj??R(e,t+329,8)??0,this.devmin=n?.devmin??r?.devmin??R(e,t+337,8)??0,e[t+475]!==0)this.path=nn(e,t+345,155)+`/`+this.path;else{let i=nn(e,t+345,130);i&&(this.path=i+`/`+this.path),this.atime=n?.atime??r?.atime??rn(e,t+476,12),this.ctime=n?.ctime??r?.ctime??rn(e,t+488,12)}let a=256;for(let n=t;n<t+148;n++)a+=e[n];for(let n=t+156;n<t+512;n++)a+=e[n];this.cksumValid=a===this.cksum,this.cksum===void 0&&a===256&&(this.nullBlock=!0)}#t(e,t=!1){Object.assign(this,Object.fromEntries(Object.entries(e).filter(([e,n])=>!(n==null||e===`path`&&t||e===`linkpath`&&t||e===`global`))))}encode(e,t=0){if(e||=this.block=Buffer.alloc(512),this.#e===`Unsupported`&&(this.#e=`0`),!(e.length>=t+512))throw Error(`need 512 bytes for header`);let n=this.ctime||this.atime?130:155,r=tn(this.path||``,n),i=r[0],a=r[1];this.needPax=!!r[2],this.needPax=mn(e,t,100,i)||this.needPax,this.needPax=z(e,t+100,8,this.mode)||this.needPax,this.needPax=z(e,t+108,8,this.uid)||this.needPax,this.needPax=z(e,t+116,8,this.gid)||this.needPax,this.needPax=z(e,t+124,12,this.size)||this.needPax,this.needPax=fn(e,t+136,12,this.mtime)||this.needPax,e[t+156]=this.#e.charCodeAt(0),this.needPax=mn(e,t+157,100,this.linkpath)||this.needPax,e.write(`ustar\x0000`,t+257,8),this.needPax=mn(e,t+265,32,this.uname)||this.needPax,this.needPax=mn(e,t+297,32,this.gname)||this.needPax,this.needPax=z(e,t+329,8,this.devmaj)||this.needPax,this.needPax=z(e,t+337,8,this.devmin)||this.needPax,this.needPax=mn(e,t+345,n,a)||this.needPax,e[t+475]===0?(this.needPax=mn(e,t+345,130,a)||this.needPax,this.needPax=fn(e,t+476,12,this.atime)||this.needPax,this.needPax=fn(e,t+488,12,this.ctime)||this.needPax):this.needPax=mn(e,t+345,155,a)||this.needPax;let o=256;for(let n=t;n<t+148;n++)o+=e[n];for(let n=t+156;n<t+512;n++)o+=e[n];return this.cksum=o,z(e,t+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e===`Unsupported`?this.#e:$t.get(this.#e)}get typeKey(){return this.#e}set type(e){let t=String(en.get(e));if(Qt(t)||t===`Unsupported`)this.#e=t;else if(Qt(e))this.#e=e;else throw TypeError(`invalid entry type: `+e)}};const tn=(e,t)=>{let n=e,r=``,i,a=o.parse(e).root||`.`;if(Buffer.byteLength(n)<100)i=[n,r,!1];else{r=o.dirname(n),n=o.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(r)<=t?i=[n,r,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(r)<=t?i=[n.slice(0,99),r,!0]:(n=o.join(o.basename(r),n),r=o.dirname(r));while(r!==a&&i===void 0);i||=[e.slice(0,99),``,!0]}return i},nn=(e,t,n)=>e.subarray(t,t+n).toString(`utf8`).replace(/\0.*/,``),rn=(e,t,n)=>an(R(e,t,n)),an=e=>e===void 0?void 0:new Date(e*1e3),R=(e,t,n)=>Number(e[t])&128?qt(e.subarray(t,t+n)):sn(e,t,n),on=e=>isNaN(e)?void 0:e,sn=(e,t,n)=>on(parseInt(e.subarray(t,t+n).toString(`utf8`).replace(/\0.*$/,``).trim(),8)),cn={12:8589934591,8:2097151},z=(e,t,n,r)=>r===void 0?!1:r>cn[n]||r<0?(Wt(r,e.subarray(t,t+n)),!0):(ln(e,t,n,r),!1),ln=(e,t,n,r)=>e.write(un(r,n),t,n,`ascii`),un=(e,t)=>dn(Math.floor(e).toString(8),t),dn=(e,t)=>(e.length===t-1?e:Array(t-e.length-1).join(`0`)+e+` `)+`\0`,fn=(e,t,n,r)=>r===void 0?!1:z(e,t,n,r.getTime()/1e3),pn=Array(156).join(`\0`),mn=(e,t,n,r)=>r===void 0?!1:(e.write(r+pn,t,n,`utf8`),r.length!==Buffer.byteLength(r)||r.length>n);var hn=class e{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 Buffer.allocUnsafe(0);let t=Buffer.byteLength(e),n=512*Math.ceil(1+t/512),r=Buffer.allocUnsafe(n);for(let e=0;e<512;e++)r[e]=0;new L({path:(`PaxHeader/`+i(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(r),r.write(e,512,t,`utf8`);for(let e=t+512;e<r.length;e++)r[e]=0;return r}encodeBody(){return this.encodeField(`path`)+this.encodeField(`ctime`)+this.encodeField(`atime`)+this.encodeField(`dev`)+this.encodeField(`ino`)+this.encodeField(`nlink`)+this.encodeField(`charset`)+this.encodeField(`comment`)+this.encodeField(`gid`)+this.encodeField(`gname`)+this.encodeField(`linkpath`)+this.encodeField(`mtime`)+this.encodeField(`size`)+this.encodeField(`uid`)+this.encodeField(`uname`)}encodeField(e){if(this[e]===void 0)return``;let t=this[e],n=t instanceof Date?t.getTime()/1e3:t,r=` `+(e===`dev`||e===`ino`||e===`nlink`?`SCHILY.`:``)+e+`=`+n+`
3
+ `,i=Buffer.byteLength(r),a=Math.floor(Math.log(i)/Math.log(10))+1;return i+a>=10**a&&(a+=1),a+i+r}static parse(t,n,r=!1){return new e(gn(_n(t),n),r)}};const gn=(e,t)=>t?Object.assign({},t,e):e,_n=e=>e.replace(/\n$/,``).split(`
4
+ `).reduce(vn,Object.create(null)),vn=(e,t)=>{let n=parseInt(t,10);if(n!==Buffer.byteLength(t)+1)return e;t=t.slice((n+` `).length);let r=t.split(`=`),i=r.shift();if(!i)return e;let a=i.replace(/^SCHILY\.(dev|ino|nlink)/,`$1`),o=r.join(`=`);return e[a]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(a)?new Date(Number(o)*1e3):/^[0-9]+$/.test(o)?+o:o,e},B=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`?e=>e&&e.replace(/\\/g,`/`):e=>e;var yn=class extends Be{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,t,n){switch(super({}),this.pause(),this.extended=t,this.globalExtended=n,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case`File`:case`OldFile`:case`Link`:case`SymbolicLink`:case`CharacterDevice`:case`BlockDevice`:case`Directory`:case`FIFO`:case`ContiguousFile`:case`GNUDumpDir`:break;case`NextFileHasLongLinkpath`:case`NextFileHasLongPath`:case`OldGnuLongPath`:case`GlobalExtendedHeader`:case`ExtendedHeader`:case`OldExtendedHeader`:this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw Error(`no path provided for tar.ReadEntry`);this.path=B(e.path),this.mode=e.mode,this.mode&&(this.mode&=4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?B(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,t&&this.#e(t),n&&this.#e(n,!0)}write(e){let t=e.length;if(t>this.blockRemain)throw Error(`writing more to entry than is appropriate`);let n=this.remain,r=this.blockRemain;return this.remain=Math.max(0,n-t),this.blockRemain=Math.max(0,r-t),this.ignore?!0:n>=t?super.write(e):super.write(e.subarray(0,n))}#e(e,t=!1){e.path&&=B(e.path),e.linkpath&&=B(e.linkpath),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([e,n])=>!(n==null||e===`path`&&t))))}};const bn=(e,t,n,r={})=>{e.file&&(r.file=e.file),e.cwd&&(r.cwd=e.cwd),r.code=n instanceof Error&&n.code||t,r.tarCode=t,!e.strict&&r.recoverable!==!1?(n instanceof Error&&(r=Object.assign(n,r),n=n.message),e.emit(`warn`,t,n,r)):n instanceof Error?e.emit(`error`,Object.assign(n,r)):e.emit(`error`,Object.assign(Error(`${t}: ${n}`),r))},xn=Buffer.from([31,139]),Sn=Buffer.from([40,181,47,253]),Cn=Math.max(xn.length,Sn.length),V=Symbol(`state`),wn=Symbol(`writeEntry`),H=Symbol(`readEntry`),Tn=Symbol(`nextEntry`),En=Symbol(`processEntry`),U=Symbol(`extendedHeader`),Dn=Symbol(`globalExtendedHeader`),W=Symbol(`meta`),On=Symbol(`emitMeta`),G=Symbol(`buffer`),K=Symbol(`queue`),q=Symbol(`ended`),kn=Symbol(`emittedEnd`),An=Symbol(`emit`),J=Symbol(`unzip`),jn=Symbol(`consumeChunk`),Mn=Symbol(`consumeChunkSub`),Nn=Symbol(`consumeBody`),Pn=Symbol(`consumeMeta`),Fn=Symbol(`consumeHeader`),In=Symbol(`consuming`),Ln=Symbol(`bufferConcat`),Rn=Symbol(`maybeEnd`),zn=Symbol(`writing`),Bn=Symbol(`aborted`),Vn=Symbol(`onDone`),Hn=Symbol(`sawValidEntry`),Un=Symbol(`sawNullBlock`),Wn=Symbol(`sawEOF`),Gn=Symbol(`closeStream`),Kn=()=>!0;var qn=class extends u{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[K]=[];[G];[H];[wn];[V]=`begin`;[W]=``;[U];[Dn];[q]=!1;[J];[Bn]=!1;[Hn];[Un]=!1;[Wn]=!1;[zn]=!1;[In]=!1;[kn]=!1;constructor(e={}){super(),this.file=e.file||``,this.on(Vn,()=>{(this[V]===`begin`||this[Hn]===!1)&&this.warn(`TAR_BAD_ARCHIVE`,`Unrecognized archive format`)}),e.ondone?this.on(Vn,e.ondone):this.on(Vn,()=>{this.emit(`prefinish`),this.emit(`finish`),this.emit(`end`)}),this.strict=!!e.strict,this.maxMetaEntrySize=e.maxMetaEntrySize||1048576,this.filter=typeof e.filter==`function`?e.filter:Kn;let t=e.file&&(e.file.endsWith(`.tar.br`)||e.file.endsWith(`.tbr`));this.brotli=!(e.gzip||e.zstd)&&e.brotli!==void 0?e.brotli:t?void 0:!1;let n=e.file&&(e.file.endsWith(`.tar.zst`)||e.file.endsWith(`.tzst`));this.zstd=!(e.gzip||e.brotli)&&e.zstd!==void 0?e.zstd:n?!0:void 0,this.on(`end`,()=>this[Gn]()),typeof e.onwarn==`function`&&this.on(`warn`,e.onwarn),typeof e.onReadEntry==`function`&&this.on(`entry`,e.onReadEntry)}warn(e,t,n={}){bn(this,e,t,n)}[Fn](e,t){this[Hn]===void 0&&(this[Hn]=!1);let n;try{n=new L(e,t,this[U],this[Dn])}catch(e){return this.warn(`TAR_ENTRY_INVALID`,e)}if(n.nullBlock)this[Un]?(this[Wn]=!0,this[V]===`begin`&&(this[V]=`header`),this[An](`eof`)):(this[Un]=!0,this[An](`nullBlock`));else if(this[Un]=!1,!n.cksumValid)this.warn(`TAR_ENTRY_INVALID`,`checksum failure`,{header:n});else if(!n.path)this.warn(`TAR_ENTRY_INVALID`,`path is required`,{header:n});else{let e=n.type;if(/^(Symbolic)?Link$/.test(e)&&!n.linkpath)this.warn(`TAR_ENTRY_INVALID`,`linkpath required`,{header:n});else if(!/^(Symbolic)?Link$/.test(e)&&!/^(Global)?ExtendedHeader$/.test(e)&&n.linkpath)this.warn(`TAR_ENTRY_INVALID`,`linkpath forbidden`,{header:n});else{let e=this[wn]=new yn(n,this[U],this[Dn]);this[Hn]||(e.remain?e.on(`end`,()=>{e.invalid||(this[Hn]=!0)}):this[Hn]=!0),e.meta?e.size>this.maxMetaEntrySize?(e.ignore=!0,this[An](`ignoredEntry`,e),this[V]=`ignore`,e.resume()):e.size>0&&(this[W]=``,e.on(`data`,e=>this[W]+=e),this[V]=`meta`):(this[U]=void 0,e.ignore=e.ignore||!this.filter(e.path,e),e.ignore?(this[An](`ignoredEntry`,e),this[V]=e.remain?`ignore`:`header`,e.resume()):(e.remain?this[V]=`body`:(this[V]=`header`,e.end()),this[H]?this[K].push(e):(this[K].push(e),this[Tn]())))}}}[Gn](){queueMicrotask(()=>this.emit(`close`))}[En](e){let t=!0;if(!e)this[H]=void 0,t=!1;else if(Array.isArray(e)){let[t,...n]=e;this.emit(t,...n)}else this[H]=e,this.emit(`entry`,e),e.emittedEnd||(e.on(`end`,()=>this[Tn]()),t=!1);return t}[Tn](){do;while(this[En](this[K].shift()));if(!this[K].length){let e=this[H];!e||e.flowing||e.size===e.remain?this[zn]||this.emit(`drain`):e.once(`drain`,()=>this.emit(`drain`))}}[Nn](e,t){let n=this[wn];if(!n)throw Error(`attempt to consume body without entry??`);let r=n.blockRemain??0,i=r>=e.length&&t===0?e:e.subarray(t,t+r);return n.write(i),n.blockRemain||(this[V]=`header`,this[wn]=void 0,n.end()),i.length}[Pn](e,t){let n=this[wn],r=this[Nn](e,t);return!this[wn]&&n&&this[On](n),r}[An](e,t,n){!this[K].length&&!this[H]?this.emit(e,t,n):this[K].push([e,t,n])}[On](e){switch(this[An](`meta`,this[W]),e.type){case`ExtendedHeader`:case`OldExtendedHeader`:this[U]=hn.parse(this[W],this[U],!1);break;case`GlobalExtendedHeader`:this[Dn]=hn.parse(this[W],this[Dn],!0);break;case`NextFileHasLongPath`:case`OldGnuLongPath`:{let e=this[U]??Object.create(null);this[U]=e,e.path=this[W].replace(/\0.*/,``);break}case`NextFileHasLongLinkpath`:{let e=this[U]||Object.create(null);this[U]=e,e.linkpath=this[W].replace(/\0.*/,``);break}default:throw Error(`unknown meta: `+e.type)}}abort(e){this[Bn]=!0,this.emit(`abort`,e),this.warn(`TAR_ABORT`,e,{recoverable:!1})}write(e,t,n){if(typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,typeof t==`string`?t:`utf8`)),this[Bn])return n?.(),!1;if((this[J]===void 0||this.brotli===void 0&&this[J]===!1)&&e){if(this[G]&&(e=Buffer.concat([this[G],e]),this[G]=void 0),e.length<Cn)return this[G]=e,n?.(),!0;for(let t=0;this[J]===void 0&&t<xn.length;t++)e[t]!==xn[t]&&(this[J]=!1);let t=!1;if(this[J]===!1&&this.zstd!==!1){t=!0;for(let n=0;n<Sn.length;n++)if(e[n]!==Sn[n]){t=!1;break}}let r=this.brotli===void 0&&!t;if(this[J]===!1&&r)if(e.length<512)if(this[q])this.brotli=!0;else return this[G]=e,n?.(),!0;else try{new L(e.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[J]===void 0||this[J]===!1&&(this.brotli||t)){let r=this[q];this[q]=!1,this[J]=this[J]===void 0?new St({}):t?new Ot({}):new Tt({}),this[J].on(`data`,e=>this[jn](e)),this[J].on(`error`,e=>this.abort(e)),this[J].on(`end`,()=>{this[q]=!0,this[jn]()}),this[zn]=!0;let i=!!this[J][r?`end`:`write`](e);return this[zn]=!1,n?.(),i}}this[zn]=!0,this[J]?this[J].write(e):this[jn](e),this[zn]=!1;let r=this[K].length?!1:this[H]?this[H].flowing:!0;return!r&&!this[K].length&&this[H]?.once(`drain`,()=>this.emit(`drain`)),n?.(),r}[Ln](e){e&&!this[Bn]&&(this[G]=this[G]?Buffer.concat([this[G],e]):e)}[Rn](){if(this[q]&&!this[kn]&&!this[Bn]&&!this[In]){this[kn]=!0;let e=this[wn];if(e&&e.blockRemain){let t=this[G]?this[G].length:0;this.warn(`TAR_BAD_ARCHIVE`,`Truncated input (needed ${e.blockRemain} more bytes, only ${t} available)`,{entry:e}),this[G]&&e.write(this[G]),e.end()}this[An](Vn)}}[jn](e){if(this[In]&&e)this[Ln](e);else if(!e&&!this[G])this[Rn]();else if(e){if(this[In]=!0,this[G]){this[Ln](e);let t=this[G];this[G]=void 0,this[Mn](t)}else this[Mn](e);for(;this[G]&&this[G]?.length>=512&&!this[Bn]&&!this[Wn];){let e=this[G];this[G]=void 0,this[Mn](e)}this[In]=!1}(!this[G]||this[q])&&this[Rn]()}[Mn](e){let t=0,n=e.length;for(;t+512<=n&&!this[Bn]&&!this[Wn];)switch(this[V]){case`begin`:case`header`:this[Fn](e,t),t+=512;break;case`ignore`:case`body`:t+=this[Nn](e,t);break;case`meta`:t+=this[Pn](e,t);break;default:throw Error(`invalid state: `+this[V])}t<n&&(this[G]?this[G]=Buffer.concat([e.subarray(t),this[G]]):this[G]=e.subarray(t))}end(e,t,n){return typeof e==`function`&&(n=e,t=void 0,e=void 0),typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,t)),n&&this.once(`finish`,n),this[Bn]||(this[J]?(e&&this[J].write(e),this[J].end()):(this[q]=!0,(this.brotli===void 0||this.zstd===void 0)&&(e||=Buffer.alloc(0)),e&&this.write(e),this[Rn]())),this}};const Jn=e=>{let t=e.length-1,n=-1;for(;t>-1&&e.charAt(t)===`/`;)n=t,t--;return n===-1?e:e.slice(0,n)},Yn=e=>{let t=e.onReadEntry;e.onReadEntry=t?e=>{t(e),e.resume()}:e=>e.resume()},Xn=(e,t)=>{let n=new Map(t.map(e=>[Jn(e),!0])),r=e.filter,i=(e,t=``)=>{let r=t||ae(e).root||`.`,a;if(e===r)a=!1;else{let t=n.get(e);a=t===void 0?i(ie(e),r):t}return n.set(e,a),a};e.filter=r?(e,t)=>r(e,t)&&i(Jn(e)):e=>i(Jn(e))},Zn=Ut(e=>{let n=new qn(e),r=e.file,i;try{i=t.openSync(r,`r`);let a=t.fstatSync(i),o=e.maxReadSize||16*1024*1024;if(a.size<o){let e=Buffer.allocUnsafe(a.size),r=t.readSync(i,e,0,a.size,0);n.end(r===e.byteLength?e:e.subarray(0,r))}else{let e=0,r=Buffer.allocUnsafe(o);for(;e<a.size;){let a=t.readSync(i,r,0,o,e);if(a===0)break;e+=a,n.write(r.subarray(0,a))}n.end()}}finally{if(typeof i==`number`)try{t.closeSync(i)}catch{}}},(e,n)=>{let r=new qn(e),i=e.maxReadSize||16*1024*1024,a=e.file;return new Promise((e,n)=>{r.on(`error`,n),r.on(`end`,e),t.stat(a,(e,t)=>{if(e)n(e);else{let e=new st(a,{readSize:i,size:t.size});e.on(`error`,n),e.pipe(r)}})})},e=>new qn(e),e=>new qn(e),(e,t)=>{t?.length&&Xn(e,t),e.noResume||Yn(e)}),Qn=(e,t,n)=>(e&=4095,n&&(e=(e|384)&-19),t&&(e&256&&(e|=64),e&32&&(e|=8),e&4&&(e|=1)),e),{isAbsolute:$n,parse:er}=s,tr=e=>{let t=``,n=er(e);for(;$n(e)||n.root;){let r=e.charAt(0)===`/`&&e.slice(0,4)!==`//?/`?`/`:n.root;e=e.slice(r.length),t+=r,n=er(e)}return[t,e]},nr=[`|`,`<`,`>`,`?`,`:`],rr=nr.map(e=>String.fromCharCode(61440+e.charCodeAt(0))),ir=new Map(nr.map((e,t)=>[e,rr[t]])),ar=new Map(rr.map((e,t)=>[e,nr[t]])),or=e=>nr.reduce((e,t)=>e.split(t).join(ir.get(t)),e),sr=e=>rr.reduce((e,t)=>e.split(t).join(ar.get(t)),e),cr=(e,t)=>t?(e=B(e).replace(/^\.(\/|$)/,``),Jn(t)+`/`+e):B(e),lr=Symbol(`process`),ur=Symbol(`file`),dr=Symbol(`directory`),fr=Symbol(`symlink`),pr=Symbol(`hardlink`),mr=Symbol(`header`),hr=Symbol(`read`),gr=Symbol(`lstat`),_r=Symbol(`onlstat`),vr=Symbol(`onread`),yr=Symbol(`onreadlink`),br=Symbol(`openfile`),xr=Symbol(`onopenfile`),Sr=Symbol(`close`),Cr=Symbol(`mode`),wr=Symbol(`awaitDrain`),Tr=Symbol(`ondrain`),Y=Symbol(`prefix`);var Er=class extends Be{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||``;maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(e,t={}){let n=Ht(t);super(),this.path=B(e),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||16777216,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=B(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?B(n.prefix):void 0,this.onWriteEntry=n.onWriteEntry,typeof n.onwarn==`function`&&this.on(`warn`,n.onwarn);let r=!1;if(!this.preservePaths){let[e,t]=tr(this.path);e&&typeof t==`string`&&(this.path=t,r=e)}this.win32=!!n.win32||process.platform===`win32`,this.win32&&(this.path=sr(this.path.replace(/\\/g,`/`)),e=e.replace(/\\/g,`/`)),this.absolute=B(n.absolute||re.resolve(this.cwd,e)),this.path===``&&(this.path=`./`),r&&this.warn(`TAR_ENTRY_INFO`,`stripping ${r} from absolute path`,{entry:this,path:r+this.path});let i=this.statCache.get(this.absolute);i?this[_r](i):this[gr]()}warn(e,t,n={}){return bn(this,e,t,n)}emit(e,...t){return e===`error`&&(this.#e=!0),super.emit(e,...t)}[gr](){d.lstat(this.absolute,(e,t)=>{if(e)return this.emit(`error`,e);this[_r](t)})}[_r](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=kr(e),this.emit(`stat`,e),this[lr]()}[lr](){switch(this.type){case`File`:return this[ur]();case`Directory`:return this[dr]();case`SymbolicLink`:return this[fr]();default:return this.end()}}[Cr](e){return Qn(e,this.type===`Directory`,this.portable)}[Y](e){return cr(e,this.prefix)}[mr](){if(!this.stat)throw Error(`cannot write header before stat`);this.type===`Directory`&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new L({path:this[Y](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[Y](this.linkpath):this.linkpath,mode:this[Cr](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type===`Unsupported`?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:``,atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new hn({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Y](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[Y](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw Error(`failed to encode header`);super.write(e)}[dr](){if(!this.stat)throw Error(`cannot create directory entry without stat`);this.path.slice(-1)!==`/`&&(this.path+=`/`),this.stat.size=0,this[mr](),this.end()}[fr](){d.readlink(this.absolute,(e,t)=>{if(e)return this.emit(`error`,e);this[yr](t)})}[yr](e){this.linkpath=B(e),this[mr](),this.end()}[pr](e){if(!this.stat)throw Error(`cannot create link entry without stat`);this.type=`Link`,this.linkpath=B(re.relative(this.cwd,e)),this.stat.size=0,this[mr](),this.end()}[ur](){if(!this.stat)throw Error(`cannot create file entry without stat`);if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,t=this.linkCache.get(e);if(t?.indexOf(this.cwd)===0)return this[pr](t);this.linkCache.set(e,this.absolute)}if(this[mr](),this.stat.size===0)return this.end();this[br]()}[br](){d.open(this.absolute,`r`,(e,t)=>{if(e)return this.emit(`error`,e);this[xr](t)})}[xr](e){if(this.fd=e,this.#e)return this[Sr]();if(!this.stat)throw Error(`should stat before calling onopenfile`);this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let t=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(t),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[hr]()}[hr](){let{fd:e,buf:t,offset:n,length:r,pos:i}=this;if(e===void 0||t===void 0)throw Error(`cannot read file without first opening`);d.read(e,t,n,r,i,(e,t)=>{if(e)return this[Sr](()=>this.emit(`error`,e));this[vr](t)})}[Sr](e=()=>{}){this.fd!==void 0&&d.close(this.fd,e)}[vr](e){if(e<=0&&this.remain>0){let e=Object.assign(Error(`encountered unexpected EOF`),{path:this.absolute,syscall:`read`,code:`EOF`});return this[Sr](()=>this.emit(`error`,e))}if(e>this.remain){let e=Object.assign(Error(`did not encounter expected EOF`),{path:this.absolute,syscall:`read`,code:`EOF`});return this[Sr](()=>this.emit(`error`,e))}if(!this.buf)throw Error(`should have created buffer prior to reading`);if(e===this.remain)for(let t=e;t<this.length&&e<this.blockRemain;t++)this.buf[t+this.offset]=0,e++,this.remain++;let t=this.offset===0&&e===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+e);this.write(t)?this[Tr]():this[wr](()=>this[Tr]())}[wr](e){this.once(`drain`,e)}write(e,t,n){if(typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,typeof t==`string`?t:`utf8`)),this.blockRemain<e.length){let e=Object.assign(Error(`writing more data than expected`),{path:this.absolute});return this.emit(`error`,e)}return this.remain-=e.length,this.blockRemain-=e.length,this.pos+=e.length,this.offset+=e.length,super.write(e,null,n)}[Tr](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[Sr](e=>e?this.emit(`error`,e):this.end());if(!this.buf)throw Error(`buffer lost somehow in ONDRAIN`);this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[hr]()}},Dr=class extends Er{sync=!0;[gr](){this[_r](d.lstatSync(this.absolute))}[fr](){this[yr](d.readlinkSync(this.absolute))}[br](){this[xr](d.openSync(this.absolute,`r`))}[hr](){let e=!0;try{let{fd:t,buf:n,offset:r,length:i,pos:a}=this;if(t===void 0||n===void 0)throw Error(`fd and buf must be set in READ method`);let o=d.readSync(t,n,r,i,a);this[vr](o),e=!1}finally{if(e)try{this[Sr](()=>{})}catch{}}}[wr](e){e()}[Sr](e=()=>{}){this.fd!==void 0&&d.closeSync(this.fd),e()}},Or=class extends Be{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(e,t,n={}){return bn(this,e,t,n)}constructor(e,t={}){let n=Ht(t);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.onWriteEntry=n.onWriteEntry,this.readEntry=e;let{type:r}=e;if(r===`Unsupported`)throw Error(`writing entry that should be ignored`);this.type=r,this.type===`Directory`&&this.portable&&(this.noMtime=!0),this.prefix=n.prefix,this.path=B(e.path),this.mode=e.mode===void 0?void 0:this[Cr](e.mode),this.uid=this.portable?void 0:e.uid,this.gid=this.portable?void 0:e.gid,this.uname=this.portable?void 0:e.uname,this.gname=this.portable?void 0:e.gname,this.size=e.size,this.mtime=this.noMtime?void 0:n.mtime||e.mtime,this.atime=this.portable?void 0:e.atime,this.ctime=this.portable?void 0:e.ctime,this.linkpath=e.linkpath===void 0?void 0:B(e.linkpath),typeof n.onwarn==`function`&&this.on(`warn`,n.onwarn);let i=!1;if(!this.preservePaths){let[e,t]=tr(this.path);e&&typeof t==`string`&&(this.path=t,i=e)}this.remain=e.size,this.blockRemain=e.startBlockSize,this.onWriteEntry?.(this),this.header=new L({path:this[Y](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[Y](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),i&&this.warn(`TAR_ENTRY_INFO`,`stripping ${i} from absolute path`,{entry:this,path:i+this.path}),this.header.encode()&&!this.noPax&&super.write(new hn({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Y](this.path),linkpath:this.type===`Link`&&this.linkpath!==void 0?this[Y](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let a=this.header?.block;if(!a)throw Error(`failed to encode header`);super.write(a),e.pipe(this)}[Y](e){return cr(e,this.prefix)}[Cr](e){return Qn(e,this.type===`Directory`,this.portable)}write(e,t,n){typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,typeof t==`string`?t:`utf8`));let r=e.length;if(r>this.blockRemain)throw Error(`writing more to entry than is appropriate`);return this.blockRemain-=r,super.write(e,n)}end(e,t,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof e==`function`&&(n=e,t=void 0,e=void 0),typeof t==`function`&&(n=t,t=void 0),typeof e==`string`&&(e=Buffer.from(e,t??`utf8`)),n&&this.once(`finish`,n),e?super.end(e,n):super.end(n),this}};const kr=e=>e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:`Unsupported`;var Ar=class e{tail;head;length=0;static create(t=[]){return new e(t)}constructor(e=[]){for(let t of e)this.push(t)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw Error(`removing node which does not belong to this list`);let t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,t}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||=e,this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||=e,this.length++}push(...e){for(let t=0,n=e.length;t<n;t++)Mr(this,e[t]);return this.length}unshift(...e){for(var t=0,n=e.length;t<n;t++)Nr(this,e[t]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,t=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,t.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,t=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,t.list=void 0,this.length--,e}forEach(e,t){t||=this;for(let n=this.head,r=0;n;r++)e.call(t,n.value,r,this),n=n.next}forEachReverse(e,t){t||=this;for(let n=this.tail,r=this.length-1;n;r--)e.call(t,n.value,r,this),n=n.prev}get(e){let t=0,n=this.head;for(;n&&t<e;t++)n=n.next;if(t===e&&n)return n.value}getReverse(e){let t=0,n=this.tail;for(;n&&t<e;t++)n=n.prev;if(t===e&&n)return n.value}map(t,n){n||=this;let r=new e;for(let e=this.head;e;)r.push(t.call(n,e.value,this)),e=e.next;return r}mapReverse(t,n){n||=this;var r=new e;for(let e=this.tail;e;)r.push(t.call(n,e.value,this)),e=e.prev;return r}reduce(e,t){let n,r=this.head;if(arguments.length>1)n=t;else if(this.head)r=this.head.next,n=this.head.value;else throw TypeError(`Reduce of empty list with no initial value`);for(var i=0;r;i++)n=e(n,r.value,i),r=r.next;return n}reduceReverse(e,t){let n,r=this.tail;if(arguments.length>1)n=t;else if(this.tail)r=this.tail.prev,n=this.tail.value;else throw TypeError(`Reduce of empty list with no initial value`);for(let t=this.length-1;r;t--)n=e(n,r.value,t),r=r.prev;return n}toArray(){let e=Array(this.length);for(let t=0,n=this.head;n;t++)e[t]=n.value,n=n.next;return e}toArrayReverse(){let e=Array(this.length);for(let t=0,n=this.tail;n;t++)e[t]=n.value,n=n.prev;return e}slice(t=0,n=this.length){n<0&&(n+=this.length),t<0&&(t+=this.length);let r=new e;if(n<t||n<0)return r;t<0&&(t=0),n>this.length&&(n=this.length);let i=this.head,a=0;for(a=0;i&&a<t;a++)i=i.next;for(;i&&a<n;a++,i=i.next)r.push(i.value);return r}sliceReverse(t=0,n=this.length){n<0&&(n+=this.length),t<0&&(t+=this.length);let r=new e;if(n<t||n<0)return r;t<0&&(t=0),n>this.length&&(n=this.length);let i=this.length,a=this.tail;for(;a&&i>n;i--)a=a.prev;for(;a&&i>t;i--,a=a.prev)r.push(a.value);return r}splice(e,t=0,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let r=this.head;for(let t=0;r&&t<e;t++)r=r.next;let i=[];for(let e=0;r&&e<t;e++)i.push(r.value),r=this.removeNode(r);r?r!==this.tail&&(r=r.prev):r=this.tail;for(let e of n)r=jr(this,r,e);return i}reverse(){let e=this.head,t=this.tail;for(let t=e;t;t=t.prev){let e=t.prev;t.prev=t.next,t.next=e}return this.head=t,this.tail=e,this}};function jr(e,t,n){let r=new Pr(n,t,t?t.next:e.head,e);return r.next===void 0&&(e.tail=r),r.prev===void 0&&(e.head=r),e.length++,r}function Mr(e,t){e.tail=new Pr(t,e.tail,void 0,e),e.head||=e.tail,e.length++}function Nr(e,t){e.head=new Pr(t,void 0,e.head,e),e.tail||=e.head,e.length++}var Pr=class{list;next;prev;value;constructor(e,t,n,r){this.list=r,this.value=e,t?(t.next=this,this.prev=t):this.prev=void 0,n?(n.prev=this,this.next=n):this.next=void 0}},Fr=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(e,t){this.path=e||`./`,this.absolute=t}};const Ir=Buffer.alloc(1024),Lr=Symbol(`onStat`),Rr=Symbol(`ended`),X=Symbol(`queue`),zr=Symbol(`current`),Br=Symbol(`process`),Vr=Symbol(`processing`),Hr=Symbol(`processJob`),Z=Symbol(`jobs`),Ur=Symbol(`jobDone`),Wr=Symbol(`addFSEntry`),Gr=Symbol(`addTarEntry`),Kr=Symbol(`stat`),qr=Symbol(`readdir`),Jr=Symbol(`onreaddir`),Yr=Symbol(`pipe`),Xr=Symbol(`entry`),Zr=Symbol(`entryOpt`),Qr=Symbol(`writeEntryClass`),$r=Symbol(`write`),ei=Symbol(`ondrain`);var ti=class extends Be{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Qr];onWriteEntry;[X];[Z]=0;[Vr]=!1;[Rr]=!1;constructor(e={}){if(super(),this.opt=e,this.file=e.file||``,this.cwd=e.cwd||process.cwd(),this.maxReadSize=e.maxReadSize,this.preservePaths=!!e.preservePaths,this.strict=!!e.strict,this.noPax=!!e.noPax,this.prefix=B(e.prefix||``),this.linkCache=e.linkCache||new Map,this.statCache=e.statCache||new Map,this.readdirCache=e.readdirCache||new Map,this.onWriteEntry=e.onWriteEntry,this[Qr]=Er,typeof e.onwarn==`function`&&this.on(`warn`,e.onwarn),this.portable=!!e.portable,e.gzip||e.brotli||e.zstd){if((e.gzip?1:0)+(e.brotli?1:0)+(e.zstd?1:0)>1)throw TypeError(`gzip, brotli, zstd are mutually exclusive`);if(e.gzip&&(typeof e.gzip!=`object`&&(e.gzip={}),this.portable&&(e.gzip.portable=!0),this.zip=new xt(e.gzip)),e.brotli&&(typeof e.brotli!=`object`&&(e.brotli={}),this.zip=new wt(e.brotli)),e.zstd&&(typeof e.zstd!=`object`&&(e.zstd={}),this.zip=new Dt(e.zstd)),!this.zip)throw Error(`impossible`);let t=this.zip;t.on(`data`,e=>super.write(e)),t.on(`end`,()=>super.end()),t.on(`drain`,()=>this[ei]()),this.on(`resume`,()=>t.resume())}else this.on(`drain`,this[ei]);this.noDirRecurse=!!e.noDirRecurse,this.follow=!!e.follow,this.noMtime=!!e.noMtime,e.mtime&&(this.mtime=e.mtime),this.filter=typeof e.filter==`function`?e.filter:()=>!0,this[X]=new Ar,this[Z]=0,this.jobs=Number(e.jobs)||4,this[Vr]=!1,this[Rr]=!1}[$r](e){return super.write(e)}add(e){return this.write(e),this}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e&&this.add(e),this[Rr]=!0,this[Br](),n&&n(),this}write(e){if(this[Rr])throw Error(`write after end`);return e instanceof yn?this[Gr](e):this[Wr](e),this.flowing}[Gr](e){let t=B(re.resolve(this.cwd,e.path));if(!this.filter(e.path,e))e.resume();else{let n=new Fr(e.path,t);n.entry=new Or(e,this[Zr](n)),n.entry.on(`end`,()=>this[Ur](n)),this[Z]+=1,this[X].push(n)}this[Br]()}[Wr](e){let t=B(re.resolve(this.cwd,e));this[X].push(new Fr(e,t)),this[Br]()}[Kr](e){e.pending=!0,this[Z]+=1,d[this.follow?`stat`:`lstat`](e.absolute,(t,n)=>{e.pending=!1,--this[Z],t?this.emit(`error`,t):this[Lr](e,n)})}[Lr](e,t){this.statCache.set(e.absolute,t),e.stat=t,this.filter(e.path,t)?t.isFile()&&t.nlink>1&&e===this[zr]&&!this.linkCache.get(`${t.dev}:${t.ino}`)&&!this.sync&&this[Hr](e):e.ignore=!0,this[Br]()}[qr](e){e.pending=!0,this[Z]+=1,d.readdir(e.absolute,(t,n)=>{if(e.pending=!1,--this[Z],t)return this.emit(`error`,t);this[Jr](e,n)})}[Jr](e,t){this.readdirCache.set(e.absolute,t),e.readdir=t,this[Br]()}[Br](){if(!this[Vr]){this[Vr]=!0;for(let e=this[X].head;e&&this[Z]<this.jobs;e=e.next)if(this[Hr](e.value),e.value.ignore){let t=e.next;this[X].removeNode(e),e.next=t}this[Vr]=!1,this[Rr]&&!this[X].length&&this[Z]===0&&(this.zip?this.zip.end(Ir):(super.write(Ir),super.end()))}}get[zr](){return this[X]&&this[X].head&&this[X].head.value}[Ur](e){this[X].shift(),--this[Z],this[Br]()}[Hr](e){if(!e.pending){if(e.entry){e===this[zr]&&!e.piped&&this[Yr](e);return}if(!e.stat){let t=this.statCache.get(e.absolute);t?this[Lr](e,t):this[Kr](e)}if(e.stat&&!e.ignore){if(!this.noDirRecurse&&e.stat.isDirectory()&&!e.readdir){let t=this.readdirCache.get(e.absolute);if(t?this[Jr](e,t):this[qr](e),!e.readdir)return}if(e.entry=this[Xr](e),!e.entry){e.ignore=!0;return}e===this[zr]&&!e.piped&&this[Yr](e)}}}[Zr](e){return{onwarn:(e,t,n)=>this.warn(e,t,n),noPax:this.noPax,cwd:this.cwd,absolute:e.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Xr](e){this[Z]+=1;try{return new this[Qr](e.path,this[Zr](e)).on(`end`,()=>this[Ur](e)).on(`error`,e=>this.emit(`error`,e))}catch(e){this.emit(`error`,e)}}[ei](){this[zr]&&this[zr].entry&&this[zr].entry.resume()}[Yr](e){e.piped=!0,e.readdir&&e.readdir.forEach(t=>{let n=e.path,r=n===`./`?``:n.replace(/\/*$/,`/`);this[Wr](r+t)});let t=e.entry,n=this.zip;if(!t)throw Error(`cannot pipe without source`);n?t.on(`data`,e=>{n.write(e)||t.pause()}):t.on(`data`,e=>{super.write(e)||t.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(e,t,n={}){bn(this,e,t,n)}},ni=class extends ti{sync=!0;constructor(e){super(e),this[Qr]=Dr}pause(){}resume(){}[Kr](e){let t=this.follow?`statSync`:`lstatSync`;this[Lr](e,d[t](e.absolute))}[qr](e){this[Jr](e,d.readdirSync(e.absolute))}[Yr](e){let t=e.entry,n=this.zip;if(e.readdir&&e.readdir.forEach(t=>{let n=e.path,r=n===`./`?``:n.replace(/\/*$/,`/`);this[Wr](r+t)}),!t)throw Error(`Cannot pipe without source`);n?t.on(`data`,e=>{n.write(e)}):t.on(`data`,e=>{super[$r](e)})}};const ri=(e,t)=>{let n=new ni(e),r=new ut(e.file,{mode:e.mode||438});n.pipe(r),ai(n,t)},ii=(e,t)=>{let n=new ti(e),r=new lt(e.file,{mode:e.mode||438});n.pipe(r);let i=new Promise((e,t)=>{r.on(`error`,t),r.on(`close`,e),n.on(`error`,t)});return oi(n,t),i},ai=(e,t)=>{t.forEach(t=>{t.charAt(0)===`@`?Zn({file:r.resolve(e.cwd,t.slice(1)),sync:!0,noResume:!0,onReadEntry:t=>e.add(t)}):e.add(t)}),e.end()},oi=async(e,t)=>{for(let n=0;n<t.length;n++){let i=String(t[n]);i.charAt(0)===`@`?await Zn({file:r.resolve(String(e.cwd),i.slice(1)),noResume:!0,onReadEntry:t=>{e.add(t)}}):e.add(i)}e.end()};Ut(ri,ii,(e,t)=>{let n=new ni(e);return ai(n,t),n},(e,t)=>{let n=new ti(e);return oi(n,t),n},(e,t)=>{if(!t?.length)throw TypeError(`no paths specified to add to archive`)});const si=(process.env.__FAKE_PLATFORM__||process.platform)===`win32`,{O_CREAT:ci,O_TRUNC:li,O_WRONLY:ui}=d.constants,di=Number(process.env.__FAKE_FS_O_FILENAME__)||d.constants.UV_FS_O_FILEMAP||0,fi=si&&!!di,pi=di|li|ci|ui,mi=fi?e=>e<524288?pi:`w`:()=>`w`;var hi=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`}},gi=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`}};const _i=(e,n)=>{t.stat(e,(t,r)=>{(t||!r.isDirectory())&&(t=new hi(e,t?.code||`ENOTDIR`)),n(t)})},vi=(e,i,a)=>{e=B(e);let o=i.umask??18,s=i.mode|448,c=(s&o)!==0,l=i.uid,u=i.gid,d=typeof l==`number`&&typeof u==`number`&&(l!==i.processUid||u!==i.processGid),f=i.preserve,ee=i.unlink,p=B(i.cwd),m=(n,r)=>{n?a(n):r&&d?Mt(r,l,u,e=>m(e)):c?t.chmod(e,s,a):a()};if(e===p)return _i(e,m);if(f)return n.mkdir(e,{mode:s,recursive:!0}).then(e=>m(null,e??void 0),m);yi(p,B(r.relative(p,e)).split(`/`),s,ee,p,void 0,m)},yi=(e,n,i,a,o,s,c)=>{if(!n.length)return c(null,s);let l=n.shift(),u=B(r.resolve(e+`/`+l));t.mkdir(u,i,bi(u,n,i,a,o,s,c))},bi=(e,n,r,i,a,o,s)=>c=>{c?t.lstat(e,(l,u)=>{if(l)l.path=l.path&&B(l.path),s(l);else if(u.isDirectory())yi(e,n,r,i,a,o,s);else if(i)t.unlink(e,c=>{if(c)return s(c);t.mkdir(e,r,bi(e,n,r,i,a,o,s))});else if(u.isSymbolicLink())return s(new gi(e,e+`/`+n.join(`/`)));else s(c)}):(o||=e,yi(e,n,r,i,a,o,s))},xi=e=>{let n=!1,r;try{n=t.statSync(e).isDirectory()}catch(e){r=e?.code}finally{if(!n)throw new hi(e,r??`ENOTDIR`)}},Si=(e,n)=>{e=B(e);let i=n.umask??18,a=n.mode|448,o=(a&i)!==0,s=n.uid,c=n.gid,l=typeof s==`number`&&typeof c==`number`&&(s!==n.processUid||c!==n.processGid),u=n.preserve,d=n.unlink,f=B(n.cwd),ee=n=>{n&&l&&Pt(n,s,c),o&&t.chmodSync(e,a)};if(e===f)return xi(f),ee();if(u)return ee(t.mkdirSync(e,{mode:a,recursive:!0})??void 0);let p=B(r.relative(f,e)).split(`/`),m;for(let e=p.shift(),n=f;e&&(n+=`/`+e);e=p.shift()){n=B(r.resolve(n));try{t.mkdirSync(n,a),m||=n}catch{let e=t.lstatSync(n);if(e.isDirectory())continue;if(d){t.unlinkSync(n),t.mkdirSync(n,a),m||=n;continue}else if(e.isSymbolicLink())return new gi(n,n+`/`+p.join(`/`))}}return ee(m)},Ci=Object.create(null),wi=1e4,Ti=new Set,Ei=e=>{Ti.has(e)?Ti.delete(e):Ci[e]=e.normalize(`NFD`).toLocaleLowerCase(`en`).toLocaleUpperCase(`en`),Ti.add(e);let t=Ci[e],n=Ti.size-wi;if(n>wi/10){for(let e of Ti)if(Ti.delete(e),delete Ci[e],--n<=0)break}return t},Di=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`,Oi=e=>e.split(`/`).slice(0,-1).reduce((e,t)=>{let n=e[e.length-1];return n!==void 0&&(t=a(n,t)),e.push(t||`/`),e},[]);var ki=class{#e=new Map;#t=new Map;#n=new Set;reserve(e,t){e=Di?[`win32 parallelization disabled`]:e.map(e=>Jn(a(Ei(e))));let n=new Set(e.map(e=>Oi(e)).reduce((e,t)=>e.concat(t)));this.#t.set(t,{dirs:n,paths:e});for(let n of e){let e=this.#e.get(n);e?e.push(t):this.#e.set(n,[t])}for(let e of n){let n=this.#e.get(e);if(!n)this.#e.set(e,[new Set([t])]);else{let e=n[n.length-1];e instanceof Set?e.add(t):n.push(new Set([t]))}}return this.#i(t)}#r(e){let t=this.#t.get(e);if(!t)throw Error(`function does not have any path reservations`);return{paths:t.paths.map(e=>this.#e.get(e)),dirs:[...t.dirs].map(e=>this.#e.get(e))}}check(e){let{paths:t,dirs:n}=this.#r(e);return t.every(t=>t&&t[0]===e)&&n.every(t=>t&&t[0]instanceof Set&&t[0].has(e))}#i(e){return this.#n.has(e)||!this.check(e)?!1:(this.#n.add(e),e(()=>this.#a(e)),!0)}#a(e){if(!this.#n.has(e))return!1;let t=this.#t.get(e);if(!t)throw Error(`invalid reservation`);let{paths:n,dirs:r}=t,i=new Set;for(let t of n){let n=this.#e.get(t);if(!n||n?.[0]!==e)continue;let r=n[1];if(!r){this.#e.delete(t);continue}if(n.shift(),typeof r==`function`)i.add(r);else for(let e of r)i.add(e)}for(let t of r){let n=this.#e.get(t),r=n?.[0];if(!(!n||!(r instanceof Set)))if(r.size===1&&n.length===1){this.#e.delete(t);continue}else if(r.size===1){n.shift();let e=n[0];typeof e==`function`&&i.add(e)}else r.delete(e)}return this.#n.delete(e),i.forEach(e=>this.#i(e)),!0}};const Ai=Symbol(`onEntry`),ji=Symbol(`checkFs`),Mi=Symbol(`checkFs2`),Ni=Symbol(`isReusable`),Q=Symbol(`makeFs`),Pi=Symbol(`file`),Fi=Symbol(`directory`),Ii=Symbol(`link`),Li=Symbol(`symlink`),Ri=Symbol(`hardlink`),zi=Symbol(`unsupported`),Bi=Symbol(`checkPath`),Vi=Symbol(`stripAbsolutePath`),Hi=Symbol(`mkdir`),$=Symbol(`onError`),Ui=Symbol(`pending`),Wi=Symbol(`pend`),Gi=Symbol(`unpend`),Ki=Symbol(`ended`),qi=Symbol(`maybeClose`),Ji=Symbol(`skip`),Yi=Symbol(`doChown`),Xi=Symbol(`uid`),Zi=Symbol(`gid`),Qi=Symbol(`checkedCwd`),$i=(process.env.TESTING_TAR_FAKE_PLATFORM||process.platform)===`win32`,ea=(e,n)=>{if(!$i)return t.unlink(e,n);let r=e+`.DELETE.`+se(16).toString(`hex`);t.rename(e,r,e=>{if(e)return n(e);t.unlink(r,n)})},ta=e=>{if(!$i)return t.unlinkSync(e);let n=e+`.DELETE.`+se(16).toString(`hex`);t.renameSync(e,n),t.unlinkSync(n)},na=(e,t,n)=>e!==void 0&&e===e>>>0?e:t!==void 0&&t===t>>>0?t:n;var ra=class extends qn{[Ki]=!1;[Qi]=!1;[Ui]=0;reservations=new ki;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(e={}){if(e.ondone=()=>{this[Ki]=!0,this[qi]()},super(e),this.transform=e.transform,this.chmod=!!e.chmod,typeof e.uid==`number`||typeof e.gid==`number`){if(typeof e.uid!=`number`||typeof e.gid!=`number`)throw TypeError(`cannot set owner without number uid and gid`);if(e.preserveOwner)throw TypeError(`cannot preserve owner in archive and also set owner explicitly`);this.uid=e.uid,this.gid=e.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;e.preserveOwner===void 0&&typeof e.uid!=`number`?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!e.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof e.maxDepth==`number`?e.maxDepth:1024,this.forceChown=e.forceChown===!0,this.win32=!!e.win32||$i,this.newer=!!e.newer,this.keep=!!e.keep,this.noMtime=!!e.noMtime,this.preservePaths=!!e.preservePaths,this.unlink=!!e.unlink,this.cwd=B(r.resolve(e.cwd||process.cwd())),this.strip=Number(e.strip)||0,this.processUmask=this.chmod?typeof e.processUmask==`number`?e.processUmask:process.umask():0,this.umask=typeof e.umask==`number`?e.umask:this.processUmask,this.dmode=e.dmode||511&~this.umask,this.fmode=e.fmode||438&~this.umask,this.on(`entry`,e=>this[Ai](e))}warn(e,t,n={}){return(e===`TAR_BAD_ARCHIVE`||e===`TAR_ABORT`)&&(n.recoverable=!1),super.warn(e,t,n)}[qi](){this[Ki]&&this[Ui]===0&&(this.emit(`prefinish`),this.emit(`finish`),this.emit(`end`))}[Vi](e,t){let n=e[t],{type:i}=e;if(!n||this.preservePaths)return!0;let a=n.split(`/`);if(a.includes(`..`)||$i&&/^[a-z]:\.\.$/i.test(a[0]??``)){if(t===`path`||i===`Link`)return this.warn(`TAR_ENTRY_ERROR`,`${t} contains '..'`,{entry:e,[t]:n}),!1;{let i=r.posix.dirname(e.path),a=r.posix.normalize(r.posix.join(i,n));if(a.startsWith(`../`)||a===`..`)return this.warn(`TAR_ENTRY_ERROR`,`${t} escapes extraction directory`,{entry:e,[t]:n}),!1}}let[o,s]=tr(n);return o&&(e[t]=String(s),this.warn(`TAR_ENTRY_INFO`,`stripping ${o} from absolute ${t}`,{entry:e,[t]:n})),!0}[Bi](e){let t=B(e.path),n=t.split(`/`);if(this.strip){if(n.length<this.strip)return!1;if(e.type===`Link`){let t=B(String(e.linkpath)).split(`/`);if(t.length>=this.strip)e.linkpath=t.slice(this.strip).join(`/`);else return!1}n.splice(0,this.strip),e.path=n.join(`/`)}if(isFinite(this.maxDepth)&&n.length>this.maxDepth)return this.warn(`TAR_ENTRY_ERROR`,`path excessively deep`,{entry:e,path:t,depth:n.length,maxDepth:this.maxDepth}),!1;if(!this[Vi](e,`path`)||!this[Vi](e,`linkpath`))return!1;if(r.isAbsolute(e.path)?e.absolute=B(r.resolve(e.path)):e.absolute=B(r.resolve(this.cwd,e.path)),!this.preservePaths&&typeof e.absolute==`string`&&e.absolute.indexOf(this.cwd+`/`)!==0&&e.absolute!==this.cwd)return this.warn(`TAR_ENTRY_ERROR`,`path escaped extraction target`,{entry:e,path:B(e.path),resolvedPath:e.absolute,cwd:this.cwd}),!1;if(e.absolute===this.cwd&&e.type!==`Directory`&&e.type!==`GNUDumpDir`)return!1;if(this.win32){let{root:t}=r.win32.parse(String(e.absolute));e.absolute=t+or(String(e.absolute).slice(t.length));let{root:n}=r.win32.parse(e.path);e.path=n+or(e.path.slice(n.length))}return!0}[Ai](e){if(!this[Bi](e))return e.resume();switch(oe.equal(typeof e.absolute,`string`),e.type){case`Directory`:case`GNUDumpDir`:e.mode&&(e.mode|=448);case`File`:case`OldFile`:case`ContiguousFile`:case`Link`:case`SymbolicLink`:return this[ji](e);default:return this[zi](e)}}[$](e,t){e.name===`CwdError`?this.emit(`error`,e):(this.warn(`TAR_ENTRY_ERROR`,e,{entry:t}),this[Gi](),t.resume())}[Hi](e,t,n){vi(B(e),{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:t},n)}[Yi](e){return 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}[Xi](e){return na(this.uid,e.uid,this.processUid)}[Zi](e){return na(this.gid,e.gid,this.processGid)}[Pi](e,n){let r=typeof e.mode==`number`?e.mode&4095:this.fmode,i=new lt(String(e.absolute),{flags:mi(e.size),mode:r,autoClose:!1});i.on(`error`,r=>{i.fd&&t.close(i.fd,()=>{}),i.write=()=>!0,this[$](r,e),n()});let a=1,o=r=>{if(r){i.fd&&t.close(i.fd,()=>{}),this[$](r,e),n();return}--a===0&&i.fd!==void 0&&t.close(i.fd,t=>{t?this[$](t,e):this[Gi](),n()})};i.on(`finish`,()=>{let n=String(e.absolute),r=i.fd;if(typeof r==`number`&&e.mtime&&!this.noMtime){a++;let i=e.atime||new Date,s=e.mtime;t.futimes(r,i,s,e=>e?t.utimes(n,i,s,t=>o(t&&e)):o())}if(typeof r==`number`&&this[Yi](e)){a++;let i=this[Xi](e),s=this[Zi](e);typeof i==`number`&&typeof s==`number`&&t.fchown(r,i,s,e=>e?t.chown(n,i,s,t=>o(t&&e)):o())}o()});let s=this.transform&&this.transform(e)||e;s!==e&&(s.on(`error`,t=>{this[$](t,e),n()}),e.pipe(s)),s.pipe(i)}[Fi](e,n){let r=typeof e.mode==`number`?e.mode&4095:this.dmode;this[Hi](String(e.absolute),r,r=>{if(r){this[$](r,e),n();return}let i=1,a=()=>{--i===0&&(n(),this[Gi](),e.resume())};e.mtime&&!this.noMtime&&(i++,t.utimes(String(e.absolute),e.atime||new Date,e.mtime,a)),this[Yi](e)&&(i++,t.chown(String(e.absolute),Number(this[Xi](e)),Number(this[Zi](e)),a)),a()})}[zi](e){e.unsupported=!0,this.warn(`TAR_ENTRY_UNSUPPORTED`,`unsupported entry type: ${e.type}`,{entry:e}),e.resume()}[Li](e,t){this[Ii](e,String(e.linkpath),`symlink`,t)}[Ri](e,t){let n=B(r.resolve(this.cwd,String(e.linkpath)));this[Ii](e,n,`link`,t)}[Wi](){this[Ui]++}[Gi](){this[Ui]--,this[qi]()}[Ji](e){this[Gi](),e.resume()}[Ni](e,t){return e.type===`File`&&!this.unlink&&t.isFile()&&t.nlink<=1&&!$i}[ji](e){this[Wi]();let t=[e.path];e.linkpath&&t.push(e.linkpath),this.reservations.reserve(t,t=>this[Mi](e,t))}[Mi](e,n){let i=e=>{n(e)},a=()=>{this[Hi](this.cwd,this.dmode,t=>{if(t){this[$](t,e),i();return}this[Qi]=!0,o()})},o=()=>{if(e.absolute!==this.cwd){let t=B(r.dirname(String(e.absolute)));if(t!==this.cwd)return this[Hi](t,this.dmode,t=>{if(t){this[$](t,e),i();return}s()})}s()},s=()=>{t.lstat(String(e.absolute),(n,r)=>{if(r&&(this.keep||this.newer&&r.mtime>(e.mtime??r.mtime))){this[Ji](e),i();return}if(n||this[Ni](e,r))return this[Q](null,e,i);if(r.isDirectory()){if(e.type===`Directory`){let n=this.chmod&&e.mode&&(r.mode&4095)!==e.mode,a=t=>this[Q](t??null,e,i);return n?t.chmod(String(e.absolute),Number(e.mode),a):a()}if(e.absolute!==this.cwd)return t.rmdir(String(e.absolute),t=>this[Q](t??null,e,i))}if(e.absolute===this.cwd)return this[Q](null,e,i);ea(String(e.absolute),t=>this[Q](t??null,e,i))})};this[Qi]?o():a()}[Q](e,t,n){if(e){this[$](e,t),n();return}switch(t.type){case`File`:case`OldFile`:case`ContiguousFile`:return this[Pi](t,n);case`Link`:return this[Ri](t,n);case`SymbolicLink`:return this[Li](t,n);case`Directory`:case`GNUDumpDir`:return this[Fi](t,n)}}[Ii](e,n,r,i){t[r](n,String(e.absolute),t=>{t?this[$](t,e):(this[Gi](),e.resume()),i()})}};const ia=e=>{try{return[null,e()]}catch(e){return[e,null]}};var aa=class extends ra{sync=!0;[Q](e,t){return super[Q](e,t,()=>{})}[ji](e){if(!this[Qi]){let t=this[Hi](this.cwd,this.dmode);if(t)return this[$](t,e);this[Qi]=!0}if(e.absolute!==this.cwd){let t=B(r.dirname(String(e.absolute)));if(t!==this.cwd){let n=this[Hi](t,this.dmode);if(n)return this[$](n,e)}}let[n,i]=ia(()=>t.lstatSync(String(e.absolute)));if(i&&(this.keep||this.newer&&i.mtime>(e.mtime??i.mtime)))return this[Ji](e);if(n||this[Ni](e,i))return this[Q](null,e);if(i.isDirectory()){if(e.type===`Directory`){let[n]=this.chmod&&e.mode&&(i.mode&4095)!==e.mode?ia(()=>{t.chmodSync(String(e.absolute),Number(e.mode))}):[];return this[Q](n,e)}let[n]=ia(()=>t.rmdirSync(String(e.absolute)));this[Q](n,e)}let[a]=e.absolute===this.cwd?[]:ia(()=>ta(String(e.absolute)));this[Q](a,e)}[Pi](e,n){let r=typeof e.mode==`number`?e.mode&4095:this.fmode,i=r=>{let i;try{t.closeSync(a)}catch(e){i=e}(r||i)&&this[$](r||i,e),n()},a;try{a=t.openSync(String(e.absolute),mi(e.size),r)}catch(e){return i(e)}let o=this.transform&&this.transform(e)||e;o!==e&&(o.on(`error`,t=>this[$](t,e)),e.pipe(o)),o.on(`data`,e=>{try{t.writeSync(a,e,0,e.length)}catch(e){i(e)}}),o.on(`end`,()=>{let n=null;if(e.mtime&&!this.noMtime){let r=e.atime||new Date,i=e.mtime;try{t.futimesSync(a,r,i)}catch(a){try{t.utimesSync(String(e.absolute),r,i)}catch{n=a}}}if(this[Yi](e)){let r=this[Xi](e),i=this[Zi](e);try{t.fchownSync(a,Number(r),Number(i))}catch(a){try{t.chownSync(String(e.absolute),Number(r),Number(i))}catch{n||=a}}}i(n)})}[Fi](e,n){let r=typeof e.mode==`number`?e.mode&4095:this.dmode,i=this[Hi](String(e.absolute),r);if(i){this[$](i,e),n();return}if(e.mtime&&!this.noMtime)try{t.utimesSync(String(e.absolute),e.atime||new Date,e.mtime)}catch{}if(this[Yi](e))try{t.chownSync(String(e.absolute),Number(this[Xi](e)),Number(this[Zi](e)))}catch{}n(),e.resume()}[Hi](e,t){try{return Si(B(e),{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:t})}catch(e){return e}}[Ii](e,n,r,i){let a=`${r}Sync`;try{t[a](n,String(e.absolute)),i(),e.resume()}catch(t){return this[$](t,e)}}};const oa=Ut(e=>{let n=new aa(e),r=e.file,i=t.statSync(r);new ct(r,{readSize:e.maxReadSize||16*1024*1024,size:i.size}).pipe(n)},(e,n)=>{let r=new ra(e),i=e.maxReadSize||16*1024*1024,a=e.file;return new Promise((e,n)=>{r.on(`error`,n),r.on(`close`,e),t.stat(a,(e,t)=>{if(e)n(e);else{let e=new st(a,{readSize:i,size:t.size});e.on(`error`,n),e.pipe(r)}})})},e=>new aa(e),e=>new ra(e),(e,t)=>{t?.length&&Xn(e,t)}),sa=(e,n)=>{let r=new ni(e),i=!0,a,o;try{try{a=t.openSync(e.file,`r+`)}catch(n){if(n?.code===`ENOENT`)a=t.openSync(e.file,`w+`);else throw n}let s=t.fstatSync(a),c=Buffer.alloc(512);POSITION:for(o=0;o<s.size;o+=512){for(let e=0,n=0;e<512;e+=n){if(n=t.readSync(a,c,e,c.length-e,o+e),o===0&&c[0]===31&&c[1]===139)throw Error(`cannot append to compressed archives`);if(!n)break POSITION}let n=new L(c);if(!n.cksumValid)break;let r=512*Math.ceil((n.size||0)/512);if(o+r+512>s.size)break;o+=r,e.mtimeCache&&n.mtime&&e.mtimeCache.set(String(n.path),n.mtime)}i=!1,ca(e,r,o,a,n)}finally{if(i)try{t.closeSync(a)}catch{}}},ca=(e,t,n,r,i)=>{let a=new ut(e.file,{fd:r,start:n});t.pipe(a),ua(t,i)},la=(e,n)=>{n=Array.from(n);let r=new ti(e),i=(n,r,i)=>{let a=(e,r)=>{e?t.close(n,t=>i(e)):i(null,r)},o=0;if(r===0)return a(null,0);let s=0,c=Buffer.alloc(512),l=(i,u)=>{if(i||u===void 0)return a(i);if(s+=u,s<512&&u)return t.read(n,c,s,c.length-s,o+s,l);if(o===0&&c[0]===31&&c[1]===139)return a(Error(`cannot append to compressed archives`));if(s<512)return a(null,o);let d=new L(c);if(!d.cksumValid)return a(null,o);let f=512*Math.ceil((d.size??0)/512);if(o+f+512>r||(o+=f+512,o>=r))return a(null,o);e.mtimeCache&&d.mtime&&e.mtimeCache.set(String(d.path),d.mtime),s=0,t.read(n,c,0,512,o,l)};t.read(n,c,0,512,o,l)};return new Promise((a,o)=>{r.on(`error`,o);let s=`r+`,c=(l,u)=>{if(l&&l.code===`ENOENT`&&s===`r+`)return s=`w+`,t.open(e.file,s,c);if(l||!u)return o(l);t.fstat(u,(s,c)=>{if(s)return t.close(u,()=>o(s));i(u,c.size,(t,i)=>{if(t)return o(t);let s=new lt(e.file,{fd:u,start:i});r.pipe(s),s.on(`error`,o),s.on(`close`,a),da(r,n)})})};t.open(e.file,s,c)})},ua=(e,t)=>{t.forEach(t=>{t.charAt(0)===`@`?Zn({file:r.resolve(e.cwd,t.slice(1)),sync:!0,noResume:!0,onReadEntry:t=>e.add(t)}):e.add(t)}),e.end()},da=async(e,t)=>{for(let n=0;n<t.length;n++){let i=String(t[n]);i.charAt(0)===`@`?await Zn({file:r.resolve(String(e.cwd),i.slice(1)),noResume:!0,onReadEntry:t=>e.add(t)}):e.add(i)}e.end()},fa=Ut(sa,la,()=>{throw TypeError(`file is required`)},()=>{throw TypeError(`file is required`)},(e,t)=>{if(!Bt(e))throw TypeError(`file is required`);if(e.gzip||e.brotli||e.zstd||e.file.endsWith(`.br`)||e.file.endsWith(`.tbr`))throw TypeError(`cannot append to compressed archives`);if(!t?.length)throw TypeError(`no paths specified to add/replace`)});Ut(fa.syncFile,fa.asyncFile,fa.syncNoFile,fa.asyncNoFile,(e,t=[])=>{fa.validate?.(e,t),pa(e)});const pa=e=>{let t=e.filter;e.mtimeCache||=new Map,e.filter=t?(n,r)=>t(n,r)&&!((e.mtimeCache?.get(n)??r.mtime??0)>(r.mtime??0)):(t,n)=>!((e.mtimeCache?.get(t)??n.mtime??0)>(n.mtime??0))};var ma=e({Header:()=>L,Pack:()=>ti,PackJob:()=>Fr,PackSync:()=>ni,Parser:()=>qn,Pax:()=>hn,ReadEntry:()=>yn,Unpack:()=>ra,UnpackSync:()=>aa,WriteEntry:()=>Er,WriteEntrySync:()=>Dr,WriteEntryTar:()=>Or,extract:()=>oa,filesFilter:()=>Xn,list:()=>Zn,replace:()=>fa});export{ma as t};
package/package.json CHANGED
@@ -1,12 +1,48 @@
1
1
  {
2
2
  "name": "create-mugnavo",
3
- "version": "0.0.0",
4
- "description": "",
5
- "license": "ISC",
6
- "author": "",
7
- "type": "commonjs",
8
- "main": "index.js",
3
+ "version": "0.1.1",
4
+ "description": "Create a project using Mugnavo templates.",
5
+ "homepage": "https://github.com/mugnavo/create-mugnavo#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/mugnavo/create-mugnavo/issues"
8
+ },
9
+ "license": "MIT",
10
+ "author": "Nathaniel Tampus <nat@nize.ph>",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/mugnavo/create-mugnavo.git"
14
+ },
15
+ "bin": "./dist/index.mjs",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "type": "module",
20
+ "devDependencies": {
21
+ "@clack/prompts": "^1.1.0",
22
+ "@types/node": "^24.12.0",
23
+ "bumpp": "^10.4.1",
24
+ "citty": "^0.2.1",
25
+ "giget": "^3.1.2",
26
+ "oxfmt": "^0.36.0",
27
+ "oxlint": "^1.51.0",
28
+ "oxlint-tsgolint": "^0.16.0",
29
+ "tinyexec": "^1.0.2",
30
+ "tsdown": "^0.21.0",
31
+ "typescript": "^5.9.3",
32
+ "vitest": "^4.0.18"
33
+ },
34
+ "engines": {
35
+ "node": ">=24"
36
+ },
9
37
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
38
+ "build": "tsdown",
39
+ "dev": "tsdown --watch",
40
+ "lint": "oxlint --type-aware --type-check",
41
+ "lint:fix": "oxlint --type-aware --type-check --fix",
42
+ "format": "oxfmt",
43
+ "format:check": "oxfmt --check",
44
+ "check": "pnpm run format && pnpm run lint",
45
+ "deps": "pnpm dlx taze@latest -Ilw",
46
+ "test": "vitest"
11
47
  }
12
- }
48
+ }