@turbo/gen 2.8.5 → 2.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +1 -1
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -77,7 +77,7 @@ ${n.count} ${n.noun} ${n.is} pending:
77
77
 
78
78
  ${e.format(t)}
79
79
  `.trim())}};t.exports=S}),ph=o((exports,t)=>{let n=Symbol.for(`undici.globalDispatcher.1`),{InvalidArgumentError:r}=dm(),i=Wm();o()===void 0&&a(new i);function a(e){if(!e||typeof e.dispatch!=`function`)throw new r(`Argument agent must implement Agent`);Object.defineProperty(globalThis,n,{value:e,writable:!0,enumerable:!1,configurable:!1})}function o(){return globalThis[n]}t.exports={setGlobalDispatcher:a,getGlobalDispatcher:o}}),mh=o((exports,t)=>{t.exports=class{#handler;constructor(e){if(typeof e!=`object`||!e)throw TypeError(`handler must be an object`);this.#handler=e}onConnect(...e){return this.#handler.onConnect?.(...e)}onError(...e){return this.#handler.onError?.(...e)}onUpgrade(...e){return this.#handler.onUpgrade?.(...e)}onResponseStarted(...e){return this.#handler.onResponseStarted?.(...e)}onHeaders(...e){return this.#handler.onHeaders?.(...e)}onData(...e){return this.#handler.onData?.(...e)}onComplete(...e){return this.#handler.onComplete?.(...e)}onBodySent(...e){return this.#handler.onBodySent?.(...e)}}}),hh=o((exports,t)=>{let n=Im();t.exports=e=>{let t=e?.maxRedirections;return e=>function(r,i){let{maxRedirections:a=t,...o}=r;if(!a)return e(r,i);let s=new n(e,a,r,i);return e(o,s)}}}),gh=o((exports,t)=>{let n=qm();t.exports=e=>t=>function(r,i){return t(r,new n({...r,retryOptions:{...e,...r.retryOptions}},{handler:i,dispatch:t}))}}),_h=o((exports,t)=>{let n=$(),{InvalidArgumentError:r,RequestAbortedError:i}=dm(),a=mh();var o=class extends a{#maxSize=1024*1024;#abort=null;#dumped=!1;#aborted=!1;#size=0;#reason=null;#handler=null;constructor({maxSize:e},t){if(super(t),e!=null&&(!Number.isFinite(e)||e<1))throw new r(`maxSize must be a number greater than 0`);this.#maxSize=e??this.#maxSize,this.#handler=t}onConnect(e){this.#abort=e,this.#handler.onConnect(this.#customAbort.bind(this))}#customAbort(e){this.#aborted=!0,this.#reason=e}onHeaders(e,t,r,a){let o=n.parseHeaders(t),s=o[`content-length`];if(s!=null&&s>this.#maxSize)throw new i(`Response size (${s}) larger than maxSize (${this.#maxSize})`);return this.#aborted?!0:this.#handler.onHeaders(e,t,r,a)}onError(e){this.#dumped||(e=this.#reason??e,this.#handler.onError(e))}onData(e){return this.#size+=e.length,this.#size>=this.#maxSize&&(this.#dumped=!0,this.#aborted?this.#handler.onError(this.#reason):this.#handler.onComplete([])),!0}onComplete(e){if(!this.#dumped){if(this.#aborted){this.#handler.onError(this.reason);return}this.#handler.onComplete(e)}}};function s({maxSize:e}={maxSize:1024*1024}){return t=>function(n,r){let{dumpMaxSize:i=e}=n,a=new o({maxSize:i},r);return t(n,a)}}t.exports=s}),vh=o((exports,t)=>{let{isIP:n}=require(`node:net`),{lookup:r}=require(`node:dns`),i=mh(),{InvalidArgumentError:a,InformationalError:o}=dm(),s=2**31-1;var c=class{#maxTTL=0;#maxItems=0;#records=new Map;dualStack=!0;affinity=null;lookup=null;pick=null;constructor(e){this.#maxTTL=e.maxTTL,this.#maxItems=e.maxItems,this.dualStack=e.dualStack,this.affinity=e.affinity,this.lookup=e.lookup??this.#defaultLookup,this.pick=e.pick??this.#defaultPick}get full(){return this.#records.size===this.#maxItems}runLookup(e,t,n){let r=this.#records.get(e.hostname);if(r==null&&this.full){n(null,e.origin);return}let i={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#maxTTL,maxItems:this.#maxItems};if(r==null)this.lookup(e,i,(t,r)=>{if(t||r==null||r.length===0){n(t??new o(`No DNS entries found`));return}this.setRecords(e,r);let a=this.#records.get(e.hostname),s=this.pick(e,a,i.affinity),c;c=typeof s.port==`number`?`:${s.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${s.family===6?`[${s.address}]`:s.address}${c}`)});else{let a=this.pick(e,r,i.affinity);if(a==null){this.#records.delete(e.hostname),this.runLookup(e,t,n);return}let o;o=typeof a.port==`number`?`:${a.port}`:e.port===``?``:`:${e.port}`,n(null,`${e.protocol}//${a.family===6?`[${a.address}]`:a.address}${o}`)}}#defaultLookup(e,t,n){r(e.hostname,{all:!0,family:this.dualStack===!1?this.affinity:0,order:`ipv4first`},(e,t)=>{if(e)return n(e);let r=new Map;for(let e of t)r.set(`${e.address}:${e.family}`,e);n(null,r.values())})}#defaultPick(e,t,n){let r=null,{records:i,offset:a}=t,o;if(this.dualStack?(n??(a==null||a===s?(t.offset=0,n=4):(t.offset++,n=(t.offset&1)==1?6:4)),o=i[n]!=null&&i[n].ips.length>0?i[n]:i[n===4?6:4]):o=i[n],o==null||o.ips.length===0)return r;o.offset==null||o.offset===s?o.offset=0:o.offset++;let c=o.offset%o.ips.length;return r=o.ips[c]??null,r==null?r:Date.now()-r.timestamp>r.ttl?(o.ips.splice(c,1),this.pick(e,t,n)):r}setRecords(e,t){let n=Date.now(),r={records:{4:null,6:null}};for(let e of t){e.timestamp=n,typeof e.ttl==`number`?e.ttl=Math.min(e.ttl,this.#maxTTL):e.ttl=this.#maxTTL;let t=r.records[e.family]??{ips:[]};t.ips.push(e),r.records[e.family]=t}this.#records.set(e.hostname,r)}getHandler(e,t){return new l(this,e,t)}},l=class extends i{#state=null;#opts=null;#dispatch=null;#handler=null;#origin=null;constructor(e,{origin:t,handler:n,dispatch:r},i){super(n),this.#origin=t,this.#handler=n,this.#opts={...i},this.#state=e,this.#dispatch=r}onError(e){switch(e.code){case`ETIMEDOUT`:case`ECONNREFUSED`:if(this.#state.dualStack){this.#state.runLookup(this.#origin,this.#opts,(e,t)=>{if(e)return this.#handler.onError(e);let n={...this.#opts,origin:t};this.#dispatch(n,this)});return}this.#handler.onError(e);return;case`ENOTFOUND`:this.#state.deleteRecord(this.#origin);default:this.#handler.onError(e);break}}};t.exports=e=>{if(e?.maxTTL!=null&&(typeof e?.maxTTL!=`number`||e?.maxTTL<0))throw new a(`Invalid maxTTL. Must be a positive number`);if(e?.maxItems!=null&&(typeof e?.maxItems!=`number`||e?.maxItems<1))throw new a(`Invalid maxItems. Must be a positive number and greater than zero`);if(e?.affinity!=null&&e?.affinity!==4&&e?.affinity!==6)throw new a(`Invalid affinity. Must be either 4 or 6`);if(e?.dualStack!=null&&typeof e?.dualStack!=`boolean`)throw new a(`Invalid dualStack. Must be a boolean`);if(e?.lookup!=null&&typeof e?.lookup!=`function`)throw new a(`Invalid lookup. Must be a function`);if(e?.pick!=null&&typeof e?.pick!=`function`)throw new a(`Invalid pick. Must be a function`);let t=e?.dualStack??!0,r;r=t?e?.affinity??null:e?.affinity??4;let i={maxTTL:e?.maxTTL??1e4,lookup:e?.lookup??null,pick:e?.pick??null,dualStack:t,affinity:r,maxItems:e?.maxItems??1/0},o=new c(i);return e=>function(t,r){let i=t.origin.constructor===URL?t.origin:new URL(t.origin);return n(i.hostname)===0?(o.runLookup(i,t,(n,a)=>{if(n)return r.onError(n);let s=null;s={...t,servername:i.hostname,origin:a,headers:{host:i.hostname,...t.headers}},e(s,o.getHandler({origin:i,dispatch:e,handler:r},t))}),!0):e(t,r)}}}),yh=o((exports,t)=>{let{kConstruct:n}=um(),{kEnumerableProperty:r}=$(),{iteratorMixin:i,isValidHeaderName:a,isValidHeaderValue:o}=Om(),{webidl:s}=Dm(),c=require(`node:assert`),l=require(`node:util`),u=Symbol(`headers map`),d=Symbol(`headers map sorted`);function f(e){return e===10||e===13||e===9||e===32}function p(e){let t=0,n=e.length;for(;n>t&&f(e.charCodeAt(n-1));)--n;for(;n>t&&f(e.charCodeAt(t));)++t;return t===0&&n===e.length?e:e.substring(t,n)}function m(e,t){if(Array.isArray(t))for(let n=0;n<t.length;++n){let r=t[n];if(r.length!==2)throw s.errors.exception({header:`Headers constructor`,message:`expected name/value pair to be length 2, found ${r.length}.`});h(e,r[0],r[1])}else if(typeof t==`object`&&t){let n=Object.keys(t);for(let r=0;r<n.length;++r)h(e,n[r],t[n[r]])}else throw s.errors.conversionFailed({prefix:`Headers constructor`,argument:`Argument 1`,types:[`sequence<sequence<ByteString>>`,`record<ByteString, ByteString>`]})}function h(e,t,n){if(n=p(n),a(t)){if(!o(n))throw s.errors.invalidArgument({prefix:`Headers.append`,value:n,type:`header value`})}else throw s.errors.invalidArgument({prefix:`Headers.append`,value:t,type:`header name`});if(y(e)===`immutable`)throw TypeError(`immutable`);return x(e).append(t,n,!1)}function g(e,t){return e[0]<t[0]?-1:1}var _=class e{cookies=null;constructor(t){t instanceof e?(this[u]=new Map(t[u]),this[d]=t[d],this.cookies=t.cookies===null?null:[...t.cookies]):(this[u]=new Map(t),this[d]=null)}contains(e,t){return this[u].has(t?e:e.toLowerCase())}clear(){this[u].clear(),this[d]=null,this.cookies=null}append(e,t,n){this[d]=null;let r=n?e:e.toLowerCase(),i=this[u].get(r);if(i){let e=r===`cookie`?`; `:`, `;this[u].set(r,{name:i.name,value:`${i.value}${e}${t}`})}else this[u].set(r,{name:e,value:t});r===`set-cookie`&&(this.cookies??=[]).push(t)}set(e,t,n){this[d]=null;let r=n?e:e.toLowerCase();r===`set-cookie`&&(this.cookies=[t]),this[u].set(r,{name:e,value:t})}delete(e,t){this[d]=null,t||(e=e.toLowerCase()),e===`set-cookie`&&(this.cookies=null),this[u].delete(e)}get(e,t){return this[u].get(t?e:e.toLowerCase())?.value??null}*[Symbol.iterator](){for(let{0:e,1:{value:t}}of this[u])yield[e,t]}get entries(){let e={};if(this[u].size!==0)for(let{name:t,value:n}of this[u].values())e[t]=n;return e}rawValues(){return this[u].values()}get entriesList(){let e=[];if(this[u].size!==0)for(let{0:t,1:{name:n,value:r}}of this[u])if(t===`set-cookie`)for(let t of this.cookies)e.push([n,t]);else e.push([n,r]);return e}toSortedArray(){let e=this[u].size,t=Array(e);if(e<=32){if(e===0)return t;let n=this[u][Symbol.iterator](),r=n.next().value;t[0]=[r[0],r[1].value],c(r[1].value!==null);for(let r=1,i=0,a=0,o=0,s=0,l,u;r<e;++r){for(u=n.next().value,l=t[r]=[u[0],u[1].value],c(l[1]!==null),o=0,a=r;o<a;)s=o+(a-o>>1),t[s][0]<=l[0]?o=s+1:a=s;if(r!==s){for(i=r;i>o;)t[i]=t[--i];t[o]=l}}if(!n.next().done)throw TypeError(`Unreachable`);return t}else{let e=0;for(let{0:n,1:{value:r}}of this[u])t[e++]=[n,r],c(r!==null);return t.sort(g)}}},v=class e{#guard;#headersList;constructor(e=void 0){s.util.markAsUncloneable(this),e!==n&&(this.#headersList=new _,this.#guard=`none`,e!==void 0&&(e=s.converters.HeadersInit(e,`Headers contructor`,`init`),m(this,e)))}append(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.append`);let r=`Headers.append`;return t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),h(this,t,n)}delete(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.delete`);let n=`Headers.delete`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:`Headers.delete`,value:t,type:`header name`});if(this.#guard===`immutable`)throw TypeError(`immutable`);this.#headersList.contains(t,!1)&&this.#headersList.delete(t,!1)}get(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.get`);let n=`Headers.get`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#headersList.get(t,!1)}has(t){s.brandCheck(this,e),s.argumentLengthCheck(arguments,1,`Headers.has`);let n=`Headers.has`;if(t=s.converters.ByteString(t,n,`name`),!a(t))throw s.errors.invalidArgument({prefix:n,value:t,type:`header name`});return this.#headersList.contains(t,!1)}set(t,n){s.brandCheck(this,e),s.argumentLengthCheck(arguments,2,`Headers.set`);let r=`Headers.set`;if(t=s.converters.ByteString(t,r,`name`),n=s.converters.ByteString(n,r,`value`),n=p(n),a(t)){if(!o(n))throw s.errors.invalidArgument({prefix:r,value:n,type:`header value`})}else throw s.errors.invalidArgument({prefix:r,value:t,type:`header name`});if(this.#guard===`immutable`)throw TypeError(`immutable`);this.#headersList.set(t,n,!1)}getSetCookie(){s.brandCheck(this,e);let t=this.#headersList.cookies;return t?[...t]:[]}get[d](){if(this.#headersList[d])return this.#headersList[d];let e=[],t=this.#headersList.toSortedArray(),n=this.#headersList.cookies;if(n===null||n.length===1)return this.#headersList[d]=t;for(let r=0;r<t.length;++r){let{0:i,1:a}=t[r];if(i===`set-cookie`)for(let t=0;t<n.length;++t)e.push([i,n[t]]);else e.push([i,a])}return this.#headersList[d]=e}[l.inspect.custom](e,t){return t.depth??=e,`Headers ${l.formatWithOptions(t,this.#headersList.entries)}`}static getHeadersGuard(e){return e.#guard}static setHeadersGuard(e,t){e.#guard=t}static getHeadersList(e){return e.#headersList}static setHeadersList(e,t){e.#headersList=t}};let{getHeadersGuard:y,setHeadersGuard:b,getHeadersList:x,setHeadersList:S}=v;Reflect.deleteProperty(v,`getHeadersGuard`),Reflect.deleteProperty(v,`setHeadersGuard`),Reflect.deleteProperty(v,`getHeadersList`),Reflect.deleteProperty(v,`setHeadersList`),i(`Headers`,v,d,0,1),Object.defineProperties(v.prototype,{append:r,delete:r,get:r,has:r,set:r,getSetCookie:r,[Symbol.toStringTag]:{value:`Headers`,configurable:!0},[l.inspect.custom]:{enumerable:!1}}),s.converters.HeadersInit=function(e,t,n){if(s.util.Type(e)===`Object`){let r=Reflect.get(e,Symbol.iterator);if(!l.types.isProxy(e)&&r===v.prototype.entries)try{return x(e).entriesList}catch{}return typeof r==`function`?s.converters[`sequence<sequence<ByteString>>`](e,t,n,r.bind(e)):s.converters[`record<ByteString, ByteString>`](e,t,n)}throw s.errors.conversionFailed({prefix:`Headers constructor`,argument:`Argument 1`,types:[`sequence<sequence<ByteString>>`,`record<ByteString, ByteString>`]})},t.exports={fill:m,compareHeaderName:g,Headers:v,HeadersList:_,getHeadersGuard:y,setHeadersGuard:b,setHeadersList:S,getHeadersList:x}}),bh=o((exports,t)=>{let{Headers:n,HeadersList:r,fill:i,getHeadersGuard:a,setHeadersGuard:o,setHeadersList:s}=yh(),{extractBody:c,cloneBody:l,mixinBody:u,hasFinalizationRegistry:d,streamRegistry:f,bodyUnusable:p}=Nm(),m=$(),h=require(`node:util`),{kEnumerableProperty:g}=m,{isValidReasonPhrase:_,isCancelled:v,isAborted:y,isBlobLike:b,serializeJavascriptValueToJSONString:x,isErrorLike:S,isomorphicEncode:C,environmentSettingsObject:w}=Om(),{redirectStatusSet:T,nullBodyStatus:E}=wm(),{kState:D,kHeaders:O}=km(),{webidl:k}=Dm(),{FormData:A}=jm(),{URLSerializer:j}=Em(),{kConstruct:M}=um(),N=require(`node:assert`),{types:P}=require(`node:util`),F=new TextEncoder(`utf-8`);var I=class e{static error(){let e=G(z(),`immutable`);return e}static json(e,t={}){k.argumentLengthCheck(arguments,1,`Response.json`),t!==null&&(t=k.converters.ResponseInit(t));let n=F.encode(x(e)),r=c(n),i=G(R({}),`response`);return W(i,t,{body:r[0],type:`application/json`}),i}static redirect(e,t=302){k.argumentLengthCheck(arguments,1,`Response.redirect`),e=k.converters.USVString(e),t=k.converters[`unsigned short`](t);let n;try{n=new URL(e,w.settingsObject.baseUrl)}catch(t){throw TypeError(`Failed to parse URL from ${e}`,{cause:t})}if(!T.has(t))throw RangeError(`Invalid status code ${t}`);let r=G(R({}),`immutable`);r[D].status=t;let i=C(j(n));return r[D].headersList.append(`location`,i,!0),r}constructor(e=null,t={}){if(k.util.markAsUncloneable(this),e===M)return;e!==null&&(e=k.converters.BodyInit(e)),t=k.converters.ResponseInit(t),this[D]=R({}),this[O]=new n(M),o(this[O],`response`),s(this[O],this[D].headersList);let r=null;if(e!=null){let[t,n]=c(e);r={body:t,type:n}}W(this,t,r)}get type(){return k.brandCheck(this,e),this[D].type}get url(){k.brandCheck(this,e);let t=this[D].urlList,n=t[t.length-1]??null;return n===null?``:j(n,!0)}get redirected(){return k.brandCheck(this,e),this[D].urlList.length>1}get status(){return k.brandCheck(this,e),this[D].status}get ok(){return k.brandCheck(this,e),this[D].status>=200&&this[D].status<=299}get statusText(){return k.brandCheck(this,e),this[D].statusText}get headers(){return k.brandCheck(this,e),this[O]}get body(){return k.brandCheck(this,e),this[D].body?this[D].body.stream:null}get bodyUsed(){return k.brandCheck(this,e),!!this[D].body&&m.isDisturbed(this[D].body.stream)}clone(){if(k.brandCheck(this,e),p(this))throw k.errors.exception({header:`Response.clone`,message:`Body has already been consumed.`});let t=L(this[D]);return d&&this[D].body?.stream&&f.register(this,new WeakRef(this[D].body.stream)),G(t,a(this[O]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${h.formatWithOptions(t,n)}`}};u(I),Object.defineProperties(I.prototype,{type:g,url:g,status:g,ok:g,redirected:g,statusText:g,headers:g,clone:g,body:g,bodyUsed:g,[Symbol.toStringTag]:{value:`Response`,configurable:!0}}),Object.defineProperties(I,{json:g,redirect:g,error:g});function L(e){if(e.internalResponse)return H(L(e.internalResponse),e.type);let t=R({...e,body:null});return e.body!=null&&(t.body=l(t,e.body)),t}function R(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:`default`,status:200,timingInfo:null,cacheState:``,statusText:``,...e,headersList:e?.headersList?new r(e?.headersList):new r,urlList:e?.urlList?[...e.urlList]:[]}}function z(e){let t=S(e);return R({type:`error`,status:0,error:t?e:Error(e&&String(e)),aborted:e&&e.name===`AbortError`})}function B(e){return e.type===`error`&&e.status===0}function V(e,t){return t={internalResponse:e,...t},new Proxy(e,{get(e,n){return n in t?t[n]:e[n]},set(e,n,r){return N(!(n in t)),e[n]=r,!0}})}function H(e,t){if(t===`basic`)return V(e,{type:`basic`,headersList:e.headersList});if(t===`cors`)return V(e,{type:`cors`,headersList:e.headersList});if(t===`opaque`)return V(e,{type:`opaque`,urlList:Object.freeze([]),status:0,statusText:``,body:null});if(t===`opaqueredirect`)return V(e,{type:`opaqueredirect`,status:0,statusText:``,headersList:[],body:null});N(!1)}function U(e,t=null){return N(v(e)),y(e)?z(Object.assign(new DOMException(`The operation was aborted.`,`AbortError`),{cause:t})):z(Object.assign(new DOMException(`Request was cancelled.`),{cause:t}))}function W(e,t,n){if(t.status!==null&&(t.status<200||t.status>599))throw RangeError(`init["status"] must be in the range of 200 to 599, inclusive.`);if(`statusText`in t&&t.statusText!=null&&!_(String(t.statusText)))throw TypeError(`Invalid statusText`);if(`status`in t&&t.status!=null&&(e[D].status=t.status),`statusText`in t&&t.statusText!=null&&(e[D].statusText=t.statusText),`headers`in t&&t.headers!=null&&i(e[O],t.headers),n){if(E.includes(e.status))throw k.errors.exception({header:`Response constructor`,message:`Invalid response status code ${e.status}`});e[D].body=n.body,n.type!=null&&!e[D].headersList.contains(`content-type`,!0)&&e[D].headersList.append(`content-type`,n.type,!0)}}function G(e,t){let r=new I(M);return r[D]=e,r[O]=new n(M),s(r[O],e.headersList),o(r[O],t),d&&e.body?.stream&&f.register(r,new WeakRef(e.body.stream)),r}k.converters.ReadableStream=k.interfaceConverter(ReadableStream),k.converters.FormData=k.interfaceConverter(A),k.converters.URLSearchParams=k.interfaceConverter(URLSearchParams),k.converters.XMLHttpRequestBodyInit=function(e,t,n){return typeof e==`string`?k.converters.USVString(e,t,n):b(e)?k.converters.Blob(e,t,n,{strict:!1}):ArrayBuffer.isView(e)||P.isArrayBuffer(e)?k.converters.BufferSource(e,t,n):m.isFormDataLike(e)?k.converters.FormData(e,t,n,{strict:!1}):e instanceof URLSearchParams?k.converters.URLSearchParams(e,t,n):k.converters.DOMString(e,t,n)},k.converters.BodyInit=function(e,t,n){return e instanceof ReadableStream?k.converters.ReadableStream(e,t,n):e?.[Symbol.asyncIterator]?e:k.converters.XMLHttpRequestBodyInit(e,t,n)},k.converters.ResponseInit=k.dictionaryConverter([{key:`status`,converter:k.converters[`unsigned short`],defaultValue:()=>200},{key:`statusText`,converter:k.converters.ByteString,defaultValue:()=>``},{key:`headers`,converter:k.converters.HeadersInit}]),t.exports={isNetworkError:B,makeNetworkError:z,makeResponse:R,makeAppropriateNetworkError:U,filterResponse:H,Response:I,cloneResponse:L,fromInnerResponse:G}}),xh=o((exports,t)=>{let{kConnected:n,kSize:r}=um();var i=class{constructor(e){this.value=e}deref(){return this.value[n]===0&&this.value[r]===0?void 0:this.value}},a=class{constructor(e){this.finalizer=e}register(e,t){e.on&&e.on(`disconnect`,()=>{e[n]===0&&e[r]===0&&this.finalizer(t)})}unregister(e){}};t.exports=function(){return process.env.NODE_V8_COVERAGE&&process.version.startsWith(`v18`)?(process._rawDebug(`Using compatibility WeakRef and FinalizationRegistry`),{WeakRef:i,FinalizationRegistry:a}):{WeakRef,FinalizationRegistry}}}),Sh=o((exports,t)=>{let{extractBody:n,mixinBody:r,cloneBody:i,bodyUnusable:a}=Nm(),{Headers:o,fill:s,HeadersList:c,setHeadersGuard:l,getHeadersGuard:u,setHeadersList:d,getHeadersList:f}=yh(),{FinalizationRegistry:p}=xh()(),m=$(),h=require(`node:util`),{isValidHTTPToken:g,sameOrigin:_,environmentSettingsObject:v}=Om(),{forbiddenMethodsSet:y,corsSafeListedMethodsSet:b,referrerPolicy:x,requestRedirect:S,requestMode:C,requestCredentials:w,requestCache:T,requestDuplex:E}=wm(),{kEnumerableProperty:D,normalizedMethodRecordsBase:O,normalizedMethodRecords:k}=m,{kHeaders:A,kSignal:j,kState:M,kDispatcher:N}=km(),{webidl:P}=Dm(),{URLSerializer:F}=Em(),{kConstruct:I}=um(),L=require(`node:assert`),{getMaxListeners:R,setMaxListeners:z,getEventListeners:B,defaultMaxListeners:V}=require(`node:events`),H=Symbol(`abortController`),U=new p(({signal:e,abort:t})=>{e.removeEventListener(`abort`,t)}),W=new WeakMap;function G(e){return t;function t(){let n=e.deref();if(n!==void 0){U.unregister(t),this.removeEventListener(`abort`,t),n.abort(this.reason);let e=W.get(n.signal);if(e!==void 0){if(e.size!==0){for(let t of e){let e=t.deref();e!==void 0&&e.abort(this.reason)}e.clear()}W.delete(n.signal)}}}}let K=!1;var q=class e{constructor(t,r={}){if(P.util.markAsUncloneable(this),t===I)return;let i=`Request constructor`;P.argumentLengthCheck(arguments,1,i),t=P.converters.RequestInfo(t,i,`input`),r=P.converters.RequestInit(r,i,`init`);let u=null,p=null,h=v.settingsObject.baseUrl,x=null;if(typeof t==`string`){this[N]=r.dispatcher;let e;try{e=new URL(t,h)}catch(e){throw TypeError(`Failed to parse URL from `+t,{cause:e})}if(e.username||e.password)throw TypeError(`Request cannot be constructed from a URL that includes credentials: `+t);u=ee({urlList:[e]}),p=`cors`}else this[N]=r.dispatcher||t[N],L(t instanceof e),u=t[M],x=t[j];let S=v.settingsObject.origin,C=`client`;if(u.window?.constructor?.name===`EnvironmentSettingsObject`&&_(u.window,S)&&(C=u.window),r.window!=null)throw TypeError(`'window' option '${C}' must be null`);`window`in r&&(C=`no-window`),u=ee({method:u.method,headersList:u.headersList,unsafeRequest:u.unsafeRequest,client:v.settingsObject,window:C,priority:u.priority,origin:u.origin,referrer:u.referrer,referrerPolicy:u.referrerPolicy,mode:u.mode,credentials:u.credentials,cache:u.cache,redirect:u.redirect,integrity:u.integrity,keepalive:u.keepalive,reloadNavigation:u.reloadNavigation,historyNavigation:u.historyNavigation,urlList:[...u.urlList]});let w=Object.keys(r).length!==0;if(w&&(u.mode===`navigate`&&(u.mode=`same-origin`),u.reloadNavigation=!1,u.historyNavigation=!1,u.origin=`client`,u.referrer=`client`,u.referrerPolicy=``,u.url=u.urlList[u.urlList.length-1],u.urlList=[u.url]),r.referrer!==void 0){let e=r.referrer;if(e===``)u.referrer=`no-referrer`;else{let t;try{t=new URL(e,h)}catch(t){throw TypeError(`Referrer "${e}" is not a valid URL.`,{cause:t})}t.protocol===`about:`&&t.hostname===`client`||S&&!_(t,v.settingsObject.baseUrl)?u.referrer=`client`:u.referrer=t}}r.referrerPolicy!==void 0&&(u.referrerPolicy=r.referrerPolicy);let T;if(T=r.mode===void 0?p:r.mode,T===`navigate`)throw P.errors.exception({header:`Request constructor`,message:`invalid request mode navigate.`});if(T!=null&&(u.mode=T),r.credentials!==void 0&&(u.credentials=r.credentials),r.cache!==void 0&&(u.cache=r.cache),u.cache===`only-if-cached`&&u.mode!==`same-origin`)throw TypeError(`'only-if-cached' can be set only with 'same-origin' mode`);if(r.redirect!==void 0&&(u.redirect=r.redirect),r.integrity!=null&&(u.integrity=String(r.integrity)),r.keepalive!==void 0&&(u.keepalive=!!r.keepalive),r.method!==void 0){let e=r.method,t=k[e];if(t!==void 0)u.method=t;else{if(!g(e))throw TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(y.has(t))throw TypeError(`'${e}' HTTP method is unsupported.`);e=O[t]??e,u.method=e}!K&&u.method===`patch`&&(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:`UNDICI-FETCH-patch`}),K=!0)}r.signal!==void 0&&(x=r.signal),this[M]=u;let E=new AbortController;if(this[j]=E.signal,x!=null){if(!x||typeof x.aborted!=`boolean`||typeof x.addEventListener!=`function`)throw TypeError(`Failed to construct 'Request': member signal is not of type AbortSignal.`);if(x.aborted)E.abort(x.reason);else{this[H]=E;let e=new WeakRef(E),t=G(e);try{(typeof R==`function`&&R(x)===V||B(x,`abort`).length>=V)&&z(1500,x)}catch{}m.addAbortListener(x,t),U.register(E,{signal:x,abort:t},t)}}if(this[A]=new o(I),d(this[A],u.headersList),l(this[A],`request`),T===`no-cors`){if(!b.has(u.method))throw TypeError(`'${u.method} is unsupported in no-cors mode.`);l(this[A],`request-no-cors`)}if(w){let e=f(this[A]),t=r.headers===void 0?new c(e):r.headers;if(e.clear(),t instanceof c){for(let{name:n,value:r}of t.rawValues())e.append(n,r,!1);e.cookies=t.cookies}else s(this[A],t)}let D=t instanceof e?t[M].body:null;if((r.body!=null||D!=null)&&(u.method===`GET`||u.method===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body.`);let F=null;if(r.body!=null){let[e,t]=n(r.body,u.keepalive);F=e,t&&!f(this[A]).contains(`content-type`,!0)&&this[A].append(`content-type`,t)}let W=F??D;if(W!=null&&W.source==null){if(F!=null&&r.duplex==null)throw TypeError(`RequestInit: duplex option is required when sending a body.`);if(u.mode!==`same-origin`&&u.mode!==`cors`)throw TypeError(`If request is made from ReadableStream, mode should be "same-origin" or "cors"`);u.useCORSPreflightFlag=!0}let q=W;if(F==null&&D!=null){if(a(t))throw TypeError(`Cannot construct a Request with a Request object that has already been used.`);let e=new TransformStream;D.stream.pipeThrough(e),q={source:D.source,length:D.length,stream:e.readable}}this[M].body=q}get method(){return P.brandCheck(this,e),this[M].method}get url(){return P.brandCheck(this,e),F(this[M].url)}get headers(){return P.brandCheck(this,e),this[A]}get destination(){return P.brandCheck(this,e),this[M].destination}get referrer(){return P.brandCheck(this,e),this[M].referrer===`no-referrer`?``:this[M].referrer===`client`?`about:client`:this[M].referrer.toString()}get referrerPolicy(){return P.brandCheck(this,e),this[M].referrerPolicy}get mode(){return P.brandCheck(this,e),this[M].mode}get credentials(){return this[M].credentials}get cache(){return P.brandCheck(this,e),this[M].cache}get redirect(){return P.brandCheck(this,e),this[M].redirect}get integrity(){return P.brandCheck(this,e),this[M].integrity}get keepalive(){return P.brandCheck(this,e),this[M].keepalive}get isReloadNavigation(){return P.brandCheck(this,e),this[M].reloadNavigation}get isHistoryNavigation(){return P.brandCheck(this,e),this[M].historyNavigation}get signal(){return P.brandCheck(this,e),this[j]}get body(){return P.brandCheck(this,e),this[M].body?this[M].body.stream:null}get bodyUsed(){return P.brandCheck(this,e),!!this[M].body&&m.isDisturbed(this[M].body.stream)}get duplex(){return P.brandCheck(this,e),`half`}clone(){if(P.brandCheck(this,e),a(this))throw TypeError(`unusable`);let t=te(this[M]),n=new AbortController;if(this.signal.aborted)n.abort(this.signal.reason);else{let e=W.get(this.signal);e===void 0&&(e=new Set,W.set(this.signal,e));let t=new WeakRef(n);e.add(t),m.addAbortListener(n.signal,G(t))}return J(t,n.signal,u(this[A]))}[h.inspect.custom](e,t){t.depth===null&&(t.depth=2),t.colors??=!0;let n={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${h.formatWithOptions(t,n)}`}};r(q);function ee(e){return{method:e.method??`GET`,localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??``,window:e.window??`client`,keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??`all`,initiator:e.initiator??``,destination:e.destination??``,priority:e.priority??null,origin:e.origin??`client`,policyContainer:e.policyContainer??`client`,referrer:e.referrer??`client`,referrerPolicy:e.referrerPolicy??``,mode:e.mode??`no-cors`,useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??`same-origin`,useCredentials:e.useCredentials??!1,cache:e.cache??`default`,redirect:e.redirect??`follow`,integrity:e.integrity??``,cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??``,parserMetadata:e.parserMetadata??``,reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??`basic`,preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new c(e.headersList):new c}}function te(e){let t=ee({...e,body:null});return e.body!=null&&(t.body=i(t,e.body)),t}function J(e,t,n){let r=new q(I);return r[M]=e,r[j]=t,r[A]=new o(I),d(r[A],e.headersList),l(r[A],n),r}Object.defineProperties(q.prototype,{method:D,url:D,headers:D,redirect:D,clone:D,signal:D,duplex:D,destination:D,body:D,bodyUsed:D,isHistoryNavigation:D,isReloadNavigation:D,keepalive:D,integrity:D,cache:D,credentials:D,attribute:D,referrerPolicy:D,referrer:D,mode:D,[Symbol.toStringTag]:{value:`Request`,configurable:!0}}),P.converters.Request=P.interfaceConverter(q),P.converters.RequestInfo=function(e,t,n){return typeof e==`string`?P.converters.USVString(e,t,n):e instanceof q?P.converters.Request(e,t,n):P.converters.USVString(e,t,n)},P.converters.AbortSignal=P.interfaceConverter(AbortSignal),P.converters.RequestInit=P.dictionaryConverter([{key:`method`,converter:P.converters.ByteString},{key:`headers`,converter:P.converters.HeadersInit},{key:`body`,converter:P.nullableConverter(P.converters.BodyInit)},{key:`referrer`,converter:P.converters.USVString},{key:`referrerPolicy`,converter:P.converters.DOMString,allowedValues:x},{key:`mode`,converter:P.converters.DOMString,allowedValues:C},{key:`credentials`,converter:P.converters.DOMString,allowedValues:w},{key:`cache`,converter:P.converters.DOMString,allowedValues:T},{key:`redirect`,converter:P.converters.DOMString,allowedValues:S},{key:`integrity`,converter:P.converters.DOMString},{key:`keepalive`,converter:P.converters.boolean},{key:`signal`,converter:P.nullableConverter(e=>P.converters.AbortSignal(e,`RequestInit`,`signal`,{strict:!1}))},{key:`window`,converter:P.converters.any},{key:`duplex`,converter:P.converters.DOMString,allowedValues:E},{key:`dispatcher`,converter:P.converters.any}]),t.exports={Request:q,makeRequest:ee,fromInnerRequest:J,cloneRequest:te}}),Ch=o((exports,t)=>{let{makeNetworkError:n,makeAppropriateNetworkError:r,filterResponse:i,makeResponse:a,fromInnerResponse:o}=bh(),{HeadersList:s}=yh(),{Request:c,cloneRequest:l}=Sh(),u=require(`node:zlib`),{bytesMatch:d,makePolicyContainer:f,clonePolicyContainer:p,requestBadPort:m,TAOCheck:h,appendRequestOriginHeader:g,responseLocationURL:_,requestCurrentURL:v,setRequestReferrerPolicyOnRedirect:y,tryUpgradeRequestToAPotentiallyTrustworthyURL:b,createOpaqueTimingInfo:x,appendFetchMetadata:S,corsCheck:C,crossOriginResourcePolicyCheck:w,determineRequestsReferrer:T,coarsenedSharedCurrentTime:E,createDeferredPromise:D,isBlobLike:O,sameOrigin:k,isCancelled:A,isAborted:j,isErrorLike:M,fullyReadBody:N,readableStreamClose:P,isomorphicEncode:F,urlIsLocal:I,urlIsHttpHttpsScheme:L,urlHasHttpsScheme:R,clampAndCoarsenConnectionTimingInfo:z,simpleRangeHeaderValue:B,buildContentRange:V,createInflate:H,extractMimeType:U}=Om(),{kState:W,kDispatcher:G}=km(),K=require(`node:assert`),{safelyExtractBody:q,extractBody:ee}=Nm(),{redirectStatusSet:te,nullBodyStatus:J,safeMethodsSet:ne,requestBodyHeader:Y,subresourceSet:re}=wm(),ie=require(`node:events`),{Readable:ae,pipeline:X,finished:oe}=require(`node:stream`),{addAbortListener:se,isErrored:ce,isReadable:le,bufferToLowerCasedHeaderName:ue}=$(),{dataURLProcessor:de,serializeAMimeType:fe,minimizeSupportedMimeType:pe}=Em(),{getGlobalDispatcher:me}=ph(),{webidl:he}=Dm(),{STATUS_CODES:ge}=require(`node:http`),_e=[`GET`,`HEAD`],ve=typeof __UNDICI_IS_NODE__<`u`||typeof esbuildDetection<`u`?`node`:`undici`,ye;var be=class extends ie{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state=`ongoing`}terminate(e){this.state===`ongoing`&&(this.state=`terminated`,this.connection?.destroy(e),this.emit(`terminated`,e))}abort(e){this.state===`ongoing`&&(this.state=`aborted`,e||=new DOMException(`The operation was aborted.`,`AbortError`),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit(`terminated`,e))}};function xe(e){Ce(e,`fetch`)}function Se(e,t=void 0){he.argumentLengthCheck(arguments,1,`globalThis.fetch`);let n=D(),r;try{r=new c(e,t)}catch(e){return n.reject(e),n.promise}let i=r[W];if(r.signal.aborted)return Te(n,i,null,r.signal.reason),n.promise;let a=i.client.globalObject;a?.constructor?.name===`ServiceWorkerGlobalScope`&&(i.serviceWorkers=`none`);let s=null,l=!1,u=null;se(r.signal,()=>{l=!0,K(u!=null),u.abort(r.signal.reason);let e=s?.deref();Te(n,i,e,r.signal.reason)});let d=e=>{if(!l){if(e.aborted){Te(n,i,s,u.serializedAbortReason);return}if(e.type===`error`){n.reject(TypeError(`fetch failed`,{cause:e.error}));return}s=new WeakRef(o(e,`immutable`)),n.resolve(s.deref()),n=null}};return u=Ee({request:i,processResponseEndOfBody:xe,processResponse:d,dispatcher:r[G]}),n.promise}function Ce(e,t=`other`){if(e.type===`error`&&e.aborted||!e.urlList?.length)return;let n=e.urlList[0],r=e.timingInfo,i=e.cacheState;L(n)&&r!==null&&(e.timingAllowPassed||(r=x({startTime:r.startTime}),i=``),r.endTime=E(),e.timingInfo=r,we(r,n.href,t,globalThis,i))}let we=performance.markResourceTiming;function Te(e,t,n,r){if(e&&e.reject(r),t.body!=null&&le(t.body?.stream)&&t.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e}),n==null)return;let i=n[W];i.body!=null&&le(i.body?.stream)&&i.body.stream.cancel(r).catch(e=>{if(e.code!==`ERR_INVALID_STATE`)throw e})}function Ee({request:e,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseEndOfBody:i,processResponseConsumeBody:a,useParallelQueue:o=!1,dispatcher:s=me()}){K(s);let c=null,l=!1;e.client!=null&&(c=e.client.globalObject,l=e.client.crossOriginIsolatedCapability);let u=E(l),d=x({startTime:u}),m={controller:new be(s),request:e,timingInfo:d,processRequestBodyChunkLength:t,processRequestEndOfBody:n,processResponse:r,processResponseConsumeBody:a,processResponseEndOfBody:i,taskDestination:c,crossOriginIsolatedCapability:l};if(K(!e.body||e.body.stream),e.window===`client`&&(e.window=e.client?.globalObject?.constructor?.name===`Window`?e.client:`no-window`),e.origin===`client`&&(e.origin=e.client.origin),e.policyContainer===`client`&&(e.client==null?e.policyContainer=f():e.policyContainer=p(e.client.policyContainer)),!e.headersList.contains(`accept`,!0)){let t=`*/*`;e.headersList.append(`accept`,t,!0)}return e.headersList.contains(`accept-language`,!0)||e.headersList.append(`accept-language`,`*`,!0),e.priority,re.has(e.destination),De(m).catch(e=>{m.controller.terminate(e)}),m.controller}async function De(e,t=!1){let r=e.request,a=null;if(r.localURLsOnly&&!I(v(r))&&(a=n(`local URLs only`)),b(r),m(r)===`blocked`&&(a=n(`bad port`)),r.referrerPolicy===``&&(r.referrerPolicy=r.policyContainer.referrerPolicy),r.referrer!==`no-referrer`&&(r.referrer=T(r)),a===null&&(a=await(async()=>{let t=v(r);return k(t,r.url)&&r.responseTainting===`basic`||t.protocol===`data:`||r.mode===`navigate`||r.mode===`websocket`?(r.responseTainting=`basic`,await Oe(e)):r.mode===`same-origin`?n(`request mode cannot be "same-origin"`):r.mode===`no-cors`?r.redirect===`follow`?(r.responseTainting=`opaque`,await Oe(e)):n(`redirect mode cannot be "follow" for "no-cors" request`):L(v(r))?(r.responseTainting=`cors`,await je(e)):n(`URL scheme must be a HTTP(S) scheme`)})()),t)return a;a.status!==0&&!a.internalResponse&&(r.responseTainting,r.responseTainting===`basic`?a=i(a,`basic`):r.responseTainting===`cors`?a=i(a,`cors`):r.responseTainting===`opaque`?a=i(a,`opaque`):K(!1));let o=a.status===0?a:a.internalResponse;if(o.urlList.length===0&&o.urlList.push(...r.urlList),r.timingAllowFailed||(a.timingAllowPassed=!0),a.type===`opaque`&&o.status===206&&o.rangeRequested&&!r.headers.contains(`range`,!0)&&(a=o=n()),a.status!==0&&(r.method===`HEAD`||r.method===`CONNECT`||J.includes(o.status))&&(o.body=null,e.controller.dump=!0),r.integrity){let t=t=>Ae(e,n(t));if(r.responseTainting===`opaque`||a.body==null){t(a.error);return}let i=n=>{if(!d(n,r.integrity)){t(`integrity mismatch`);return}a.body=q(n)[0],Ae(e,a)};await N(a.body,i,t)}else Ae(e,a)}function Oe(e){if(A(e)&&e.request.redirectCount===0)return Promise.resolve(r(e));let{request:t}=e,{protocol:i}=v(t);switch(i){case`about:`:return Promise.resolve(n(`about scheme is not supported`));case`blob:`:{ye||=require(`node:buffer`).resolveObjectURL;let e=v(t);if(e.search.length!==0)return Promise.resolve(n(`NetworkError when attempting to fetch resource.`));let r=ye(e.toString());if(t.method!==`GET`||!O(r))return Promise.resolve(n(`invalid method`));let i=a(),o=r.size,s=F(`${o}`),c=r.type;if(t.headersList.contains(`range`,!0)){i.rangeRequested=!0;let e=t.headersList.get(`range`,!0),a=B(e,!0);if(a===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let{rangeStartValue:s,rangeEndValue:l}=a;if(s===null)s=o-l,l=s+l-1;else{if(s>=o)return Promise.resolve(n(`Range start is greater than the blob's size.`));(l===null||l>=o)&&(l=o-1)}let u=r.slice(s,l,c),d=ee(u);i.body=d[0];let f=F(`${u.size}`),p=V(s,l,o);i.status=206,i.statusText=`Partial Content`,i.headersList.set(`content-length`,f,!0),i.headersList.set(`content-type`,c,!0),i.headersList.set(`content-range`,p,!0)}else{let e=ee(r);i.statusText=`OK`,i.body=e[0],i.headersList.set(`content-length`,s,!0),i.headersList.set(`content-type`,c,!0)}return Promise.resolve(i)}case`data:`:{let e=v(t),r=de(e);if(r===`failure`)return Promise.resolve(n(`failed to fetch the data URL`));let i=fe(r.mimeType);return Promise.resolve(a({statusText:`OK`,headersList:[[`content-type`,{name:`Content-Type`,value:i}]],body:q(r.body)[0]}))}case`file:`:return Promise.resolve(n(`not implemented... yet...`));case`http:`:case`https:`:return je(e).catch(e=>n(e));default:return Promise.resolve(n(`unknown scheme`))}}function ke(e,t){e.request.done=!0,e.processResponseDone!=null&&queueMicrotask(()=>e.processResponseDone(t))}function Ae(e,t){let n=e.timingInfo,r=()=>{let r=Date.now();e.request.destination===`document`&&(e.controller.fullTimingInfo=n),e.controller.reportTimingSteps=()=>{if(e.request.url.protocol!==`https:`)return;n.endTime=r;let i=t.cacheState,a=t.bodyInfo;t.timingAllowPassed||(n=x(n),i=``);let o=0;if(e.request.mode!==`navigator`||!t.hasCrossOriginRedirects){o=t.status;let e=U(t.headersList);e!==`failure`&&(a.contentType=pe(e))}e.request.initiatorType!=null&&we(n,e.request.url.href,e.request.initiatorType,globalThis,i,a,o)};let i=()=>{e.request.done=!0,e.processResponseEndOfBody!=null&&queueMicrotask(()=>e.processResponseEndOfBody(t)),e.request.initiatorType!=null&&e.controller.reportTimingSteps()};queueMicrotask(()=>i())};e.processResponse!=null&&queueMicrotask(()=>{e.processResponse(t),e.processResponse=null});let i=t.type===`error`?t:t.internalResponse??t;i.body==null?r():oe(i.body.stream,()=>{r()})}async function je(e){let t=e.request,r=null,i=null,a=e.timingInfo;if(t.serviceWorkers,r===null){if(t.redirect===`follow`&&(t.serviceWorkers=`none`),i=r=await Ne(e),t.responseTainting===`cors`&&C(t,r)===`failure`)return n(`cors failure`);h(t,r)===`failure`&&(t.timingAllowFailed=!0)}return(t.responseTainting===`opaque`||r.type===`opaque`)&&w(t.origin,t.client,t.destination,i)===`blocked`?n(`blocked`):(te.has(i.status)&&(t.redirect!==`manual`&&e.controller.connection.destroy(void 0,!1),t.redirect===`error`?r=n(`unexpected redirect`):t.redirect===`manual`?r=i:t.redirect===`follow`?r=await Me(e,r):K(!1)),r.timingInfo=a,r)}function Me(e,t){let r=e.request,i=t.internalResponse?t.internalResponse:t,a;try{if(a=_(i,v(r).hash),a==null)return t}catch(e){return Promise.resolve(n(e))}if(!L(a))return Promise.resolve(n(`URL scheme must be a HTTP(S) scheme`));if(r.redirectCount===20)return Promise.resolve(n(`redirect count exceeded`));if(r.redirectCount+=1,r.mode===`cors`&&(a.username||a.password)&&!k(r,a))return Promise.resolve(n(`cross origin not allowed for request mode "cors"`));if(r.responseTainting===`cors`&&(a.username||a.password))return Promise.resolve(n(`URL cannot contain credentials for request mode "cors"`));if(i.status!==303&&r.body!=null&&r.body.source==null)return Promise.resolve(n());if([301,302].includes(i.status)&&r.method===`POST`||i.status===303&&!_e.includes(r.method)){r.method=`GET`,r.body=null;for(let e of Y)r.headersList.delete(e)}k(v(r),a)||(r.headersList.delete(`authorization`,!0),r.headersList.delete(`proxy-authorization`,!0),r.headersList.delete(`cookie`,!0),r.headersList.delete(`host`,!0)),r.body!=null&&(K(r.body.source!=null),r.body=q(r.body.source)[0]);let o=e.timingInfo;return o.redirectEndTime=o.postRedirectStartTime=E(e.crossOriginIsolatedCapability),o.redirectStartTime===0&&(o.redirectStartTime=o.startTime),r.urlList.push(a),y(r,i),De(e,!0)}async function Ne(e,t=!1,i=!1){let a=e.request,o=null,s=null,c=null,u=null,d=!1;a.window===`no-window`&&a.redirect===`error`?(o=e,s=a):(s=l(a),o={...e},o.request=s);let f=a.credentials===`include`||a.credentials===`same-origin`&&a.responseTainting===`basic`,p=s.body?s.body.length:null,m=null;if(s.body==null&&[`POST`,`PUT`].includes(s.method)&&(m=`0`),p!=null&&(m=F(`${p}`)),m!=null&&s.headersList.append(`content-length`,m,!0),p!=null&&s.keepalive,s.referrer instanceof URL&&s.headersList.append(`referer`,F(s.referrer.href),!0),g(s),S(s),s.headersList.contains(`user-agent`,!0)||s.headersList.append(`user-agent`,ve),s.cache===`default`&&(s.headersList.contains(`if-modified-since`,!0)||s.headersList.contains(`if-none-match`,!0)||s.headersList.contains(`if-unmodified-since`,!0)||s.headersList.contains(`if-match`,!0)||s.headersList.contains(`if-range`,!0))&&(s.cache=`no-store`),s.cache===`no-cache`&&!s.preventNoCacheCacheControlHeaderModification&&!s.headersList.contains(`cache-control`,!0)&&s.headersList.append(`cache-control`,`max-age=0`,!0),(s.cache===`no-store`||s.cache===`reload`)&&(s.headersList.contains(`pragma`,!0)||s.headersList.append(`pragma`,`no-cache`,!0),s.headersList.contains(`cache-control`,!0)||s.headersList.append(`cache-control`,`no-cache`,!0)),s.headersList.contains(`range`,!0)&&s.headersList.append(`accept-encoding`,`identity`,!0),s.headersList.contains(`accept-encoding`,!0)||(R(v(s))?s.headersList.append(`accept-encoding`,`br, gzip, deflate`,!0):s.headersList.append(`accept-encoding`,`gzip, deflate`,!0)),s.headersList.delete(`host`,!0),u??(s.cache=`no-store`),s.cache!==`no-store`&&s.cache,c==null){if(s.cache===`only-if-cached`)return n(`only if cached`);let e=await Pe(o,f,i);!ne.has(s.method)&&e.status>=200&&e.status,d&&e.status,c??=e}if(c.urlList=[...s.urlList],s.headersList.contains(`range`,!0)&&(c.rangeRequested=!0),c.requestIncludesCredentials=f,c.status===407)return a.window===`no-window`?n():A(e)?r(e):n(`proxy authentication required`);if(c.status===421&&!i&&(a.body==null||a.body.source!=null)){if(A(e))return r(e);e.controller.connection.destroy(),c=await Ne(e,t,!0)}return c}async function Pe(e,t=!1,i=!1){K(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,t=!0){this.destroyed||(this.destroyed=!0,t&&this.abort?.(e??new DOMException(`The operation was aborted.`,`AbortError`)))}};let o=e.request,c=null,l=e.timingInfo,d=null;d??(o.cache=`no-store`);let f=i?`yes`:`no`;o.mode;let p=null;if(o.body==null&&e.processRequestEndOfBody)queueMicrotask(()=>e.processRequestEndOfBody());else if(o.body!=null){let t=async function*(t){A(e)||(yield t,e.processRequestBodyChunkLength?.(t.byteLength))},n=()=>{A(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},r=t=>{A(e)||(t.name===`AbortError`?e.controller.abort():e.controller.terminate(t))};p=async function*(){try{for await(let e of o.body.stream)yield*t(e);n()}catch(e){r(e)}}()}try{let{body:t,status:n,statusText:r,headersList:i,socket:o}=await y({body:p});if(o)c=a({status:n,statusText:r,headersList:i,socket:o});else{let o=t[Symbol.asyncIterator]();e.controller.next=()=>o.next(),c=a({status:n,statusText:r,headersList:i})}}catch(t){return t.name===`AbortError`?(e.controller.connection.destroy(),r(e,t)):n(t)}let m=async()=>{await e.controller.resume()},h=t=>{A(e)||e.controller.abort(t)},g=new ReadableStream({async start(t){e.controller.controller=t},async pull(e){await m(e)},async cancel(e){await h(e)},type:`bytes`});c.body={stream:g,source:null,length:null},e.controller.onAborted=_,e.controller.on(`terminated`,_),e.controller.resume=async()=>{for(;;){let t,n;try{let{done:n,value:r}=await e.controller.next();if(j(e))break;t=n?void 0:r}catch(r){e.controller.ended&&!l.encodedBodySize?t=void 0:(t=r,n=!0)}if(t===void 0){P(e.controller.controller),ke(e,c);return}if(l.decodedBodySize+=t?.byteLength??0,n){e.controller.terminate(t);return}let r=new Uint8Array(t);if(r.byteLength&&e.controller.controller.enqueue(r),ce(g)){e.controller.terminate();return}if(e.controller.controller.desiredSize<=0)return}};function _(t){j(e)?(c.aborted=!0,le(g)&&e.controller.controller.error(e.controller.serializedAbortReason)):le(g)&&e.controller.controller.error(TypeError(`terminated`,{cause:M(t)?t:void 0})),e.controller.connection.destroy()}return c;function y({body:t}){let n=v(o),r=e.controller.dispatcher;return new Promise((i,a)=>r.dispatch({path:n.pathname+n.search,origin:n.origin,method:o.method,body:r.isMockActive?o.body&&(o.body.source||o.body.stream):t,headers:o.headersList.entries,maxRedirections:0,upgrade:o.mode===`websocket`?`websocket`:void 0},{body:null,abort:null,onConnect(t){let{connection:n}=e.controller;l.finalConnectionTimingInfo=z(void 0,l.postRedirectStartTime,e.crossOriginIsolatedCapability),n.destroyed?t(new DOMException(`The operation was aborted.`,`AbortError`)):(e.controller.on(`terminated`,t),this.abort=n.abort=t),l.finalNetworkRequestStartTime=E(e.crossOriginIsolatedCapability)},onResponseStarted(){l.finalNetworkResponseStartTime=E(e.crossOriginIsolatedCapability)},onHeaders(e,t,n,r){if(e<200)return;let c=``,l=new s;for(let e=0;e<t.length;e+=2)l.append(ue(t[e]),t[e+1].toString(`latin1`),!0);c=l.get(`location`,!0),this.body=new ae({read:n});let d=[],f=c&&o.redirect===`follow`&&te.has(e);if(o.method!==`HEAD`&&o.method!==`CONNECT`&&!J.includes(e)&&!f){let e=l.get(`content-encoding`,!0),t=e?e.toLowerCase().split(`,`):[],n=5;if(t.length>n)return a(Error(`too many content-encodings in response: ${t.length}, maximum allowed is ${n}`)),!0;for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n===`x-gzip`||n===`gzip`)d.push(u.createGunzip({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`deflate`)d.push(H({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if(n===`br`)d.push(u.createBrotliDecompress({flush:u.constants.BROTLI_OPERATION_FLUSH,finishFlush:u.constants.BROTLI_OPERATION_FLUSH}));else{d.length=0;break}}}let p=this.onError.bind(this);return i({status:e,statusText:r,headersList:l,body:d.length?X(this.body,...d,e=>{e&&this.onError(e)}).on(`error`,p):this.body.on(`error`,p)}),!0},onData(t){if(e.controller.dump)return;let n=t;return l.encodedBodySize+=n.byteLength,this.body.push(n)},onComplete(){this.abort&&e.controller.off(`terminated`,this.abort),e.controller.onAborted&&e.controller.off(`terminated`,e.controller.onAborted),e.controller.ended=!0,this.body.push(null)},onError(t){this.abort&&e.controller.off(`terminated`,this.abort),this.body?.destroy(t),e.controller.terminate(t),a(t)},onUpgrade(e,t,n){if(e!==101)return;let r=new s;for(let e=0;e<t.length;e+=2)r.append(ue(t[e]),t[e+1].toString(`latin1`),!0);return i({status:e,statusText:ge[e],headersList:r,socket:n}),!0}}))}}t.exports={fetch:Se,Fetch:be,fetching:Ee,finalizeAndReportTiming:Ce}}),wh=o((exports,t)=>{t.exports={kState:Symbol(`FileReader state`),kResult:Symbol(`FileReader result`),kError:Symbol(`FileReader error`),kLastProgressEventFired:Symbol(`FileReader last progress event fired timestamp`),kEvents:Symbol(`FileReader events`),kAborted:Symbol(`FileReader aborted`)}}),Th=o((exports,t)=>{let{webidl:n}=Dm(),r=Symbol(`ProgressEvent state`);var i=class e extends Event{constructor(e,t={}){e=n.converters.DOMString(e,`ProgressEvent constructor`,`type`),t=n.converters.ProgressEventInit(t??{}),super(e,t),this[r]={lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total}}get lengthComputable(){return n.brandCheck(this,e),this[r].lengthComputable}get loaded(){return n.brandCheck(this,e),this[r].loaded}get total(){return n.brandCheck(this,e),this[r].total}};n.converters.ProgressEventInit=n.dictionaryConverter([{key:`lengthComputable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`loaded`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`total`,converter:n.converters[`unsigned long long`],defaultValue:()=>0},{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}]),t.exports={ProgressEvent:i}}),Eh=o((exports,t)=>{function n(e){if(!e)return`failure`;switch(e.trim().toLowerCase()){case`unicode-1-1-utf-8`:case`unicode11utf8`:case`unicode20utf8`:case`utf-8`:case`utf8`:case`x-unicode20utf8`:return`UTF-8`;case`866`:case`cp866`:case`csibm866`:case`ibm866`:return`IBM866`;case`csisolatin2`:case`iso-8859-2`:case`iso-ir-101`:case`iso8859-2`:case`iso88592`:case`iso_8859-2`:case`iso_8859-2:1987`:case`l2`:case`latin2`:return`ISO-8859-2`;case`csisolatin3`:case`iso-8859-3`:case`iso-ir-109`:case`iso8859-3`:case`iso88593`:case`iso_8859-3`:case`iso_8859-3:1988`:case`l3`:case`latin3`:return`ISO-8859-3`;case`csisolatin4`:case`iso-8859-4`:case`iso-ir-110`:case`iso8859-4`:case`iso88594`:case`iso_8859-4`:case`iso_8859-4:1988`:case`l4`:case`latin4`:return`ISO-8859-4`;case`csisolatincyrillic`:case`cyrillic`:case`iso-8859-5`:case`iso-ir-144`:case`iso8859-5`:case`iso88595`:case`iso_8859-5`:case`iso_8859-5:1988`:return`ISO-8859-5`;case`arabic`:case`asmo-708`:case`csiso88596e`:case`csiso88596i`:case`csisolatinarabic`:case`ecma-114`:case`iso-8859-6`:case`iso-8859-6-e`:case`iso-8859-6-i`:case`iso-ir-127`:case`iso8859-6`:case`iso88596`:case`iso_8859-6`:case`iso_8859-6:1987`:return`ISO-8859-6`;case`csisolatingreek`:case`ecma-118`:case`elot_928`:case`greek`:case`greek8`:case`iso-8859-7`:case`iso-ir-126`:case`iso8859-7`:case`iso88597`:case`iso_8859-7`:case`iso_8859-7:1987`:case`sun_eu_greek`:return`ISO-8859-7`;case`csiso88598e`:case`csisolatinhebrew`:case`hebrew`:case`iso-8859-8`:case`iso-8859-8-e`:case`iso-ir-138`:case`iso8859-8`:case`iso88598`:case`iso_8859-8`:case`iso_8859-8:1988`:case`visual`:return`ISO-8859-8`;case`csiso88598i`:case`iso-8859-8-i`:case`logical`:return`ISO-8859-8-I`;case`csisolatin6`:case`iso-8859-10`:case`iso-ir-157`:case`iso8859-10`:case`iso885910`:case`l6`:case`latin6`:return`ISO-8859-10`;case`iso-8859-13`:case`iso8859-13`:case`iso885913`:return`ISO-8859-13`;case`iso-8859-14`:case`iso8859-14`:case`iso885914`:return`ISO-8859-14`;case`csisolatin9`:case`iso-8859-15`:case`iso8859-15`:case`iso885915`:case`iso_8859-15`:case`l9`:return`ISO-8859-15`;case`iso-8859-16`:return`ISO-8859-16`;case`cskoi8r`:case`koi`:case`koi8`:case`koi8-r`:case`koi8_r`:return`KOI8-R`;case`koi8-ru`:case`koi8-u`:return`KOI8-U`;case`csmacintosh`:case`mac`:case`macintosh`:case`x-mac-roman`:return`macintosh`;case`iso-8859-11`:case`iso8859-11`:case`iso885911`:case`tis-620`:case`windows-874`:return`windows-874`;case`cp1250`:case`windows-1250`:case`x-cp1250`:return`windows-1250`;case`cp1251`:case`windows-1251`:case`x-cp1251`:return`windows-1251`;case`ansi_x3.4-1968`:case`ascii`:case`cp1252`:case`cp819`:case`csisolatin1`:case`ibm819`:case`iso-8859-1`:case`iso-ir-100`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`iso_8859-1:1987`:case`l1`:case`latin1`:case`us-ascii`:case`windows-1252`:case`x-cp1252`:return`windows-1252`;case`cp1253`:case`windows-1253`:case`x-cp1253`:return`windows-1253`;case`cp1254`:case`csisolatin5`:case`iso-8859-9`:case`iso-ir-148`:case`iso8859-9`:case`iso88599`:case`iso_8859-9`:case`iso_8859-9:1989`:case`l5`:case`latin5`:case`windows-1254`:case`x-cp1254`:return`windows-1254`;case`cp1255`:case`windows-1255`:case`x-cp1255`:return`windows-1255`;case`cp1256`:case`windows-1256`:case`x-cp1256`:return`windows-1256`;case`cp1257`:case`windows-1257`:case`x-cp1257`:return`windows-1257`;case`cp1258`:case`windows-1258`:case`x-cp1258`:return`windows-1258`;case`x-mac-cyrillic`:case`x-mac-ukrainian`:return`x-mac-cyrillic`;case`chinese`:case`csgb2312`:case`csiso58gb231280`:case`gb2312`:case`gb_2312`:case`gb_2312-80`:case`gbk`:case`iso-ir-58`:case`x-gbk`:return`GBK`;case`gb18030`:return`gb18030`;case`big5`:case`big5-hkscs`:case`cn-big5`:case`csbig5`:case`x-x-big5`:return`Big5`;case`cseucpkdfmtjapanese`:case`euc-jp`:case`x-euc-jp`:return`EUC-JP`;case`csiso2022jp`:case`iso-2022-jp`:return`ISO-2022-JP`;case`csshiftjis`:case`ms932`:case`ms_kanji`:case`shift-jis`:case`shift_jis`:case`sjis`:case`windows-31j`:case`x-sjis`:return`Shift_JIS`;case`cseuckr`:case`csksc56011987`:case`euc-kr`:case`iso-ir-149`:case`korean`:case`ks_c_5601-1987`:case`ks_c_5601-1989`:case`ksc5601`:case`ksc_5601`:case`windows-949`:return`EUC-KR`;case`csiso2022kr`:case`hz-gb-2312`:case`iso-2022-cn`:case`iso-2022-cn-ext`:case`iso-2022-kr`:case`replacement`:return`replacement`;case`unicodefffe`:case`utf-16be`:return`UTF-16BE`;case`csunicode`:case`iso-10646-ucs-2`:case`ucs-2`:case`unicode`:case`unicodefeff`:case`utf-16`:case`utf-16le`:return`UTF-16LE`;case`x-user-defined`:return`x-user-defined`;default:return`failure`}}t.exports={getEncoding:n}}),Dh=o((exports,t)=>{let{kState:n,kError:r,kResult:i,kAborted:a,kLastProgressEventFired:o}=wh(),{ProgressEvent:s}=Th(),{getEncoding:c}=Eh(),{serializeAMimeType:l,parseMIMEType:u}=Em(),{types:d}=require(`node:util`),{StringDecoder:f}=require(`string_decoder`),{btoa:p}=require(`node:buffer`),m={enumerable:!0,writable:!1,configurable:!1};function h(e,t,s,c){if(e[n]===`loading`)throw new DOMException(`Invalid state`,`InvalidStateError`);e[n]=`loading`,e[i]=null,e[r]=null;let l=t.stream(),u=l.getReader(),f=[],p=u.read(),m=!0;(async()=>{for(;!e[a];)try{let{done:l,value:h}=await p;if(m&&!e[a]&&queueMicrotask(()=>{g(`loadstart`,e)}),m=!1,!l&&d.isUint8Array(h))f.push(h),(e[o]===void 0||Date.now()-e[o]>=50)&&!e[a]&&(e[o]=Date.now(),queueMicrotask(()=>{g(`progress`,e)})),p=u.read();else if(l){queueMicrotask(()=>{e[n]=`done`;try{let n=_(f,s,t.type,c);if(e[a])return;e[i]=n,g(`load`,e)}catch(t){e[r]=t,g(`error`,e)}e[n]!==`loading`&&g(`loadend`,e)});break}}catch(t){if(e[a])return;queueMicrotask(()=>{e[n]=`done`,e[r]=t,g(`error`,e),e[n]!==`loading`&&g(`loadend`,e)});break}})()}function g(e,t){let n=new s(e,{bubbles:!1,cancelable:!1});t.dispatchEvent(n)}function _(e,t,n,r){switch(t){case`DataURL`:{let t=`data:`,r=u(n||`application/octet-stream`);r!==`failure`&&(t+=l(r)),t+=`;base64,`;let i=new f(`latin1`);for(let n of e)t+=p(i.write(n));return t+=p(i.end()),t}case`Text`:{let t=`failure`;if(r&&(t=c(r)),t===`failure`&&n){let e=u(n);e!==`failure`&&(t=c(e.parameters.get(`charset`)))}return t===`failure`&&(t=`UTF-8`),v(e,t)}case`ArrayBuffer`:{let t=b(e);return t.buffer}case`BinaryString`:{let t=``,n=new f(`latin1`);for(let r of e)t+=n.write(r);return t+=n.end(),t}}}function v(e,t){let n=b(e),r=y(n),i=0;r!==null&&(t=r,i=r===`UTF-8`?3:2);let a=n.slice(i);return new TextDecoder(t).decode(a)}function y(e){let[t,n,r]=e;return t===239&&n===187&&r===191?`UTF-8`:t===254&&n===255?`UTF-16BE`:t===255&&n===254?`UTF-16LE`:null}function b(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=0;return e.reduce((e,t)=>(e.set(t,n),n+=t.byteLength,e),new Uint8Array(t))}t.exports={staticPropertyDescriptors:m,readOperation:h,fireAProgressEvent:g}}),Oh=o((exports,t)=>{let{staticPropertyDescriptors:n,readOperation:r,fireAProgressEvent:i}=Dh(),{kState:a,kError:o,kResult:s,kEvents:c,kAborted:l}=wh(),{webidl:u}=Dm(),{kEnumerableProperty:d}=$();var f=class e extends EventTarget{constructor(){super(),this[a]=`empty`,this[s]=null,this[o]=null,this[c]={loadend:null,error:null,abort:null,load:null,progress:null,loadstart:null}}readAsArrayBuffer(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsArrayBuffer`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`ArrayBuffer`)}readAsBinaryString(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsBinaryString`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`BinaryString`)}readAsText(t,n=void 0){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsText`),t=u.converters.Blob(t,{strict:!1}),n!==void 0&&(n=u.converters.DOMString(n,`FileReader.readAsText`,`encoding`)),r(this,t,`Text`,n)}readAsDataURL(t){u.brandCheck(this,e),u.argumentLengthCheck(arguments,1,`FileReader.readAsDataURL`),t=u.converters.Blob(t,{strict:!1}),r(this,t,`DataURL`)}abort(){if(this[a]===`empty`||this[a]===`done`){this[s]=null;return}this[a]===`loading`&&(this[a]=`done`,this[s]=null),this[l]=!0,i(`abort`,this),this[a]!==`loading`&&i(`loadend`,this)}get readyState(){switch(u.brandCheck(this,e),this[a]){case`empty`:return this.EMPTY;case`loading`:return this.LOADING;case`done`:return this.DONE}}get result(){return u.brandCheck(this,e),this[s]}get error(){return u.brandCheck(this,e),this[o]}get onloadend(){return u.brandCheck(this,e),this[c].loadend}set onloadend(t){u.brandCheck(this,e),this[c].loadend&&this.removeEventListener(`loadend`,this[c].loadend),typeof t==`function`?(this[c].loadend=t,this.addEventListener(`loadend`,t)):this[c].loadend=null}get onerror(){return u.brandCheck(this,e),this[c].error}set onerror(t){u.brandCheck(this,e),this[c].error&&this.removeEventListener(`error`,this[c].error),typeof t==`function`?(this[c].error=t,this.addEventListener(`error`,t)):this[c].error=null}get onloadstart(){return u.brandCheck(this,e),this[c].loadstart}set onloadstart(t){u.brandCheck(this,e),this[c].loadstart&&this.removeEventListener(`loadstart`,this[c].loadstart),typeof t==`function`?(this[c].loadstart=t,this.addEventListener(`loadstart`,t)):this[c].loadstart=null}get onprogress(){return u.brandCheck(this,e),this[c].progress}set onprogress(t){u.brandCheck(this,e),this[c].progress&&this.removeEventListener(`progress`,this[c].progress),typeof t==`function`?(this[c].progress=t,this.addEventListener(`progress`,t)):this[c].progress=null}get onload(){return u.brandCheck(this,e),this[c].load}set onload(t){u.brandCheck(this,e),this[c].load&&this.removeEventListener(`load`,this[c].load),typeof t==`function`?(this[c].load=t,this.addEventListener(`load`,t)):this[c].load=null}get onabort(){return u.brandCheck(this,e),this[c].abort}set onabort(t){u.brandCheck(this,e),this[c].abort&&this.removeEventListener(`abort`,this[c].abort),typeof t==`function`?(this[c].abort=t,this.addEventListener(`abort`,t)):this[c].abort=null}};f.EMPTY=f.prototype.EMPTY=0,f.LOADING=f.prototype.LOADING=1,f.DONE=f.prototype.DONE=2,Object.defineProperties(f.prototype,{EMPTY:n,LOADING:n,DONE:n,readAsArrayBuffer:d,readAsBinaryString:d,readAsText:d,readAsDataURL:d,abort:d,readyState:d,result:d,error:d,onloadstart:d,onprogress:d,onload:d,onabort:d,onerror:d,onloadend:d,[Symbol.toStringTag]:{value:`FileReader`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(f,{EMPTY:n,LOADING:n,DONE:n}),t.exports={FileReader:f}}),kh=o((exports,t)=>{t.exports={kConstruct:um().kConstruct}}),Ah=o((exports,t)=>{let n=require(`node:assert`),{URLSerializer:r}=Em(),{isValidHeaderName:i}=Om();function a(e,t,n=!1){let i=r(e,n),a=r(t,n);return i===a}function o(e){n(e!==null);let t=[];for(let n of e.split(`,`))n=n.trim(),i(n)&&t.push(n);return t}t.exports={urlEquals:a,getFieldValues:o}}),jh=o((exports,t)=>{let{kConstruct:n}=kh(),{urlEquals:r,getFieldValues:i}=Ah(),{kEnumerableProperty:a,isDisturbed:o}=$(),{webidl:s}=Dm(),{Response:c,cloneResponse:l,fromInnerResponse:u}=bh(),{Request:d,fromInnerRequest:f}=Sh(),{kState:p}=km(),{fetching:m}=Ch(),{urlIsHttpHttpsScheme:h,createDeferredPromise:g,readAllBytes:_}=Om(),v=require(`node:assert`);var y=class e{#relevantRequestResponseList;constructor(){arguments[0]!==n&&s.illegalConstructor(),s.util.markAsUncloneable(this),this.#relevantRequestResponseList=arguments[1]}async match(t,n={}){s.brandCheck(this,e);let r=`Cache.match`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=this.#internalMatchAll(t,n,1);if(i.length!==0)return i[0]}async matchAll(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.matchAll`;return t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`),this.#internalMatchAll(t,n)}async add(t){s.brandCheck(this,e);let n=`Cache.add`;s.argumentLengthCheck(arguments,1,n),t=s.converters.RequestInfo(t,n,`request`);let r=[t],i=this.addAll(r);return await i}async addAll(t){s.brandCheck(this,e);let n=`Cache.addAll`;s.argumentLengthCheck(arguments,1,n);let r=[],a=[];for(let e of t){if(e===void 0)throw s.errors.conversionFailed({prefix:n,argument:`Argument 1`,types:[`undefined is not allowed`]});if(e=s.converters.RequestInfo(e),typeof e==`string`)continue;let t=e[p];if(!h(t.url)||t.method!==`GET`)throw s.errors.exception({header:n,message:`Expected http/s scheme when method is not GET.`})}let o=[];for(let e of t){let t=new d(e)[p];if(!h(t.url))throw s.errors.exception({header:n,message:`Expected http/s scheme.`});t.initiator=`fetch`,t.destination=`subresource`,a.push(t);let c=g();o.push(m({request:t,processResponse(e){if(e.type===`error`||e.status===206||e.status<200||e.status>299)c.reject(s.errors.exception({header:`Cache.addAll`,message:`Received an invalid status code or the request failed.`}));else if(e.headersList.contains(`vary`)){let t=i(e.headersList.get(`vary`));for(let e of t)if(e===`*`){c.reject(s.errors.exception({header:`Cache.addAll`,message:`invalid vary field value`}));for(let e of o)e.abort();return}}},processResponseEndOfBody(e){if(e.aborted){c.reject(new DOMException(`aborted`,`AbortError`));return}c.resolve(e)}})),r.push(c.promise)}let c=Promise.all(r),l=await c,u=[],f=0;for(let e of l){let t={type:`put`,request:a[f],response:e};u.push(t),f++}let _=g(),v=null;try{this.#batchCacheOperations(u)}catch(e){v=e}return queueMicrotask(()=>{v===null?_.resolve(void 0):_.reject(v)}),_.promise}async put(t,n){s.brandCheck(this,e);let r=`Cache.put`;s.argumentLengthCheck(arguments,2,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.Response(n,r,`response`);let a=null;if(a=t instanceof d?t[p]:new d(t)[p],!h(a.url)||a.method!==`GET`)throw s.errors.exception({header:r,message:`Expected an http/s scheme when method is not GET`});let c=n[p];if(c.status===206)throw s.errors.exception({header:r,message:`Got 206 status`});if(c.headersList.contains(`vary`)){let e=i(c.headersList.get(`vary`));for(let t of e)if(t===`*`)throw s.errors.exception({header:r,message:`Got * vary field value`})}if(c.body&&(o(c.body.stream)||c.body.stream.locked))throw s.errors.exception({header:r,message:`Response body is locked or disturbed`});let u=l(c),f=g();if(c.body!=null){let e=c.body.stream,t=e.getReader();_(t).then(f.resolve,f.reject)}else f.resolve(void 0);let m=[],v={type:`put`,request:a,response:u};m.push(v);let y=await f.promise;u.body!=null&&(u.body.source=y);let b=g(),x=null;try{this.#batchCacheOperations(m)}catch(e){x=e}return queueMicrotask(()=>{x===null?b.resolve():b.reject(x)}),b.promise}async delete(t,n={}){s.brandCheck(this,e);let r=`Cache.delete`;s.argumentLengthCheck(arguments,1,r),t=s.converters.RequestInfo(t,r,`request`),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return!1}else v(typeof t==`string`),i=new d(t)[p];let a=[],o={type:`delete`,request:i,options:n};a.push(o);let c=g(),l=null,u;try{u=this.#batchCacheOperations(a)}catch(e){l=e}return queueMicrotask(()=>{l===null?c.resolve(!!u?.length):c.reject(l)}),c.promise}async keys(t=void 0,n={}){s.brandCheck(this,e);let r=`Cache.keys`;t!==void 0&&(t=s.converters.RequestInfo(t,r,`request`)),n=s.converters.CacheQueryOptions(n,r,`options`);let i=null;if(t!==void 0)if(t instanceof d){if(i=t[p],i.method!==`GET`&&!n.ignoreMethod)return[]}else typeof t==`string`&&(i=new d(t)[p]);let a=g(),o=[];if(t===void 0)for(let e of this.#relevantRequestResponseList)o.push(e[0]);else{let e=this.#queryCache(i,n);for(let t of e)o.push(t[0])}return queueMicrotask(()=>{let e=[];for(let t of o){let n=f(t,new AbortController().signal,`immutable`);e.push(n)}a.resolve(Object.freeze(e))}),a.promise}#batchCacheOperations(e){let t=this.#relevantRequestResponseList,n=[...t],r=[],i=[];try{for(let n of e){if(n.type!==`delete`&&n.type!==`put`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`operation type does not match "delete" or "put"`});if(n.type===`delete`&&n.response!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`delete operation should not have an associated response`});if(this.#queryCache(n.request,n.options,r).length)throw new DOMException(`???`,`InvalidStateError`);let e;if(n.type===`delete`){if(e=this.#queryCache(n.request,n.options),e.length===0)return[];for(let n of e){let e=t.indexOf(n);v(e!==-1),t.splice(e,1)}}else if(n.type===`put`){if(n.response==null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`put operation should have an associated response`});let i=n.request;if(!h(i.url))throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`expected http or https scheme`});if(i.method!==`GET`)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`not get method`});if(n.options!=null)throw s.errors.exception({header:`Cache.#batchCacheOperations`,message:`options must not be defined`});e=this.#queryCache(n.request);for(let n of e){let e=t.indexOf(n);v(e!==-1),t.splice(e,1)}t.push([n.request,n.response]),r.push([n.request,n.response])}i.push([n.request,n.response])}return i}catch(e){throw this.#relevantRequestResponseList.length=0,this.#relevantRequestResponseList=n,e}}#queryCache(e,t,n){let r=[],i=n??this.#relevantRequestResponseList;for(let n of i){let[i,a]=n;this.#requestMatchesCachedItem(e,i,a,t)&&r.push(n)}return r}#requestMatchesCachedItem(e,t,n=null,a){let o=new URL(e.url),s=new URL(t.url);if(a?.ignoreSearch&&(s.search=``,o.search=``),!r(o,s,!0))return!1;if(n==null||a?.ignoreVary||!n.headersList.contains(`vary`))return!0;let c=i(n.headersList.get(`vary`));for(let n of c){if(n===`*`)return!1;let r=t.headersList.get(n),i=e.headersList.get(n);if(r!==i)return!1}return!0}#internalMatchAll(e,t,n=1/0){let r=null;if(e!==void 0)if(e instanceof d){if(r=e[p],r.method!==`GET`&&!t.ignoreMethod)return[]}else typeof e==`string`&&(r=new d(e)[p]);let i=[];if(e===void 0)for(let e of this.#relevantRequestResponseList)i.push(e[1]);else{let e=this.#queryCache(r,t);for(let t of e)i.push(t[1])}let a=[];for(let e of i){let t=u(e,`immutable`);if(a.push(t.clone()),a.length>=n)break}return Object.freeze(a)}};Object.defineProperties(y.prototype,{[Symbol.toStringTag]:{value:`Cache`,configurable:!0},match:a,matchAll:a,add:a,addAll:a,put:a,delete:a,keys:a});let b=[{key:`ignoreSearch`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreMethod`,converter:s.converters.boolean,defaultValue:()=>!1},{key:`ignoreVary`,converter:s.converters.boolean,defaultValue:()=>!1}];s.converters.CacheQueryOptions=s.dictionaryConverter(b),s.converters.MultiCacheQueryOptions=s.dictionaryConverter([...b,{key:`cacheName`,converter:s.converters.DOMString}]),s.converters.Response=s.interfaceConverter(c),s.converters[`sequence<RequestInfo>`]=s.sequenceConverter(s.converters.RequestInfo),t.exports={Cache:y}}),Mh=o((exports,t)=>{let{kConstruct:n}=kh(),{Cache:r}=jh(),{webidl:i}=Dm(),{kEnumerableProperty:a}=$();var o=class e{#caches=new Map;constructor(){arguments[0]!==n&&i.illegalConstructor(),i.util.markAsUncloneable(this)}async match(t,a={}){if(i.brandCheck(this,e),i.argumentLengthCheck(arguments,1,`CacheStorage.match`),t=i.converters.RequestInfo(t),a=i.converters.MultiCacheQueryOptions(a),a.cacheName!=null){if(this.#caches.has(a.cacheName)){let e=this.#caches.get(a.cacheName),i=new r(n,e);return await i.match(t,a)}}else for(let e of this.#caches.values()){let i=new r(n,e),o=await i.match(t,a);if(o!==void 0)return o}}async has(t){i.brandCheck(this,e);let n=`CacheStorage.has`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#caches.has(t)}async open(t){i.brandCheck(this,e);let a=`CacheStorage.open`;if(i.argumentLengthCheck(arguments,1,a),t=i.converters.DOMString(t,a,`cacheName`),this.#caches.has(t)){let e=this.#caches.get(t);return new r(n,e)}let o=[];return this.#caches.set(t,o),new r(n,o)}async delete(t){i.brandCheck(this,e);let n=`CacheStorage.delete`;return i.argumentLengthCheck(arguments,1,n),t=i.converters.DOMString(t,n,`cacheName`),this.#caches.delete(t)}async keys(){i.brandCheck(this,e);let t=this.#caches.keys();return[...t]}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`CacheStorage`,configurable:!0},match:a,has:a,open:a,delete:a,keys:a}),t.exports={CacheStorage:o}}),Nh=o((exports,t)=>{let n=1024,r=4096;t.exports={maxAttributeValueSize:n,maxNameValuePairSize:r}}),Ph=o((exports,t)=>{function n(e){for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n>=0&&n<=8||n>=10&&n<=31||n===127)return!0}return!1}function r(e){for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n<33||n>126||n===34||n===40||n===41||n===60||n===62||n===64||n===44||n===59||n===58||n===92||n===47||n===91||n===93||n===63||n===61||n===123||n===125)throw Error(`Invalid cookie name`)}}function i(e){let t=e.length,n=0;if(e[0]===`"`){if(t===1||e[t-1]!==`"`)throw Error(`Invalid cookie value`);--t,++n}for(;n<t;){let t=e.charCodeAt(n++);if(t<33||t>126||t===34||t===44||t===59||t===92)throw Error(`Invalid cookie value`)}}function a(e){for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n<32||n===127||n===59)throw Error(`Invalid cookie path`)}}function o(e){if(e.startsWith(`-`)||e.endsWith(`.`)||e.endsWith(`-`))throw Error(`Invalid cookie domain`)}let s=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],c=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],l=Array(61).fill(0).map((e,t)=>t.toString().padStart(2,`0`));function u(e){return typeof e==`number`&&(e=new Date(e)),`${s[e.getUTCDay()]}, ${l[e.getUTCDate()]} ${c[e.getUTCMonth()]} ${e.getUTCFullYear()} ${l[e.getUTCHours()]}:${l[e.getUTCMinutes()]}:${l[e.getUTCSeconds()]} GMT`}function d(e){if(e<0)throw Error(`Invalid cookie max-age`)}function f(e){if(e.name.length===0)return null;r(e.name),i(e.value);let t=[`${e.name}=${e.value}`];e.name.startsWith(`__Secure-`)&&(e.secure=!0),e.name.startsWith(`__Host-`)&&(e.secure=!0,e.domain=null,e.path=`/`),e.secure&&t.push(`Secure`),e.httpOnly&&t.push(`HttpOnly`),typeof e.maxAge==`number`&&(d(e.maxAge),t.push(`Max-Age=${e.maxAge}`)),e.domain&&(o(e.domain),t.push(`Domain=${e.domain}`)),e.path&&(a(e.path),t.push(`Path=${e.path}`)),e.expires&&e.expires.toString()!==`Invalid Date`&&t.push(`Expires=${u(e.expires)}`),e.sameSite&&t.push(`SameSite=${e.sameSite}`);for(let n of e.unparsed){if(!n.includes(`=`))throw Error(`Invalid unparsed`);let[e,...r]=n.split(`=`);t.push(`${e.trim()}=${r.join(`=`)}`)}return t.join(`; `)}t.exports={isCTLExcludingHtab:n,validateCookieName:r,validateCookiePath:a,validateCookieValue:i,toIMFDate:u,stringify:f}}),Fh=o((exports,t)=>{let{maxNameValuePairSize:n,maxAttributeValueSize:r}=Nh(),{isCTLExcludingHtab:i}=Ph(),{collectASequenceOfCodePointsFast:a}=Em(),o=require(`node:assert`);function s(e){if(i(e))return null;let t=``,r=``,o=``,s=``;if(e.includes(`;`)){let n={position:0};t=a(`;`,e,n),r=e.slice(n.position)}else t=e;if(!t.includes(`=`))s=t;else{let e={position:0};o=a(`=`,t,e),s=t.slice(e.position+1)}return o=o.trim(),s=s.trim(),o.length+s.length>n?null:{name:o,value:s,...c(r)}}function c(e,t={}){if(e.length===0)return t;o(e[0]===`;`),e=e.slice(1);let n=``;e.includes(`;`)?(n=a(`;`,e,{position:0}),e=e.slice(n.length)):(n=e,e=``);let i=``,s=``;if(n.includes(`=`)){let e={position:0};i=a(`=`,n,e),s=n.slice(e.position+1)}else i=n;if(i=i.trim(),s=s.trim(),s.length>r)return c(e,t);let l=i.toLowerCase();if(l===`expires`){let e=new Date(s);t.expires=e}else if(l===`max-age`){let n=s.charCodeAt(0);if((n<48||n>57)&&s[0]!==`-`||!/^\d+$/.test(s))return c(e,t);let r=Number(s);t.maxAge=r}else if(l===`domain`){let e=s;e[0]===`.`&&(e=e.slice(1)),e=e.toLowerCase(),t.domain=e}else if(l===`path`){let e=``;e=s.length===0||s[0]!==`/`?`/`:s,t.path=e}else if(l===`secure`)t.secure=!0;else if(l===`httponly`)t.httpOnly=!0;else if(l===`samesite`){let e=`Default`,n=s.toLowerCase();n.includes(`none`)&&(e=`None`),n.includes(`strict`)&&(e=`Strict`),n.includes(`lax`)&&(e=`Lax`),t.sameSite=e}else t.unparsed??=[],t.unparsed.push(`${i}=${s}`);return c(e,t)}t.exports={parseSetCookie:s,parseUnparsedAttributes:c}}),Ih=o((exports,t)=>{let{parseSetCookie:n}=Fh(),{stringify:r}=Ph(),{webidl:i}=Dm(),{Headers:a}=yh();function o(e){i.argumentLengthCheck(arguments,1,`getCookies`),i.brandCheck(e,a,{strict:!1});let t=e.get(`cookie`),n={};if(!t)return n;for(let e of t.split(`;`)){let[t,...r]=e.split(`=`);n[t.trim()]=r.join(`=`)}return n}function s(e,t,n){i.brandCheck(e,a,{strict:!1});let r=`deleteCookie`;i.argumentLengthCheck(arguments,2,r),t=i.converters.DOMString(t,r,`name`),n=i.converters.DeleteCookieAttributes(n),l(e,{name:t,value:``,expires:new Date(0),...n})}function c(e){i.argumentLengthCheck(arguments,1,`getSetCookies`),i.brandCheck(e,a,{strict:!1});let t=e.getSetCookie();return t?t.map(e=>n(e)):[]}function l(e,t){i.argumentLengthCheck(arguments,2,`setCookie`),i.brandCheck(e,a,{strict:!1}),t=i.converters.Cookie(t);let n=r(t);n&&e.append(`Set-Cookie`,n)}i.converters.DeleteCookieAttributes=i.dictionaryConverter([{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null}]),i.converters.Cookie=i.dictionaryConverter([{converter:i.converters.DOMString,key:`name`},{converter:i.converters.DOMString,key:`value`},{converter:i.nullableConverter(e=>typeof e==`number`?i.converters[`unsigned long long`](e):new Date(e)),key:`expires`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters[`long long`]),key:`maxAge`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`domain`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.DOMString),key:`path`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`secure`,defaultValue:()=>null},{converter:i.nullableConverter(i.converters.boolean),key:`httpOnly`,defaultValue:()=>null},{converter:i.converters.USVString,key:`sameSite`,allowedValues:[`Strict`,`Lax`,`None`]},{converter:i.sequenceConverter(i.converters.DOMString),key:`unparsed`,defaultValue:()=>[]}]),t.exports={getCookies:o,deleteCookie:s,getSetCookies:c,setCookie:l}}),Lh=o((exports,t)=>{let{webidl:n}=Dm(),{kEnumerableProperty:r}=$(),{kConstruct:i}=um(),{MessagePort:a}=require(`node:worker_threads`);var o=class e extends Event{#eventInit;constructor(e,t={}){if(e===i){super(arguments[1],arguments[2]),n.util.markAsUncloneable(this);return}let r=`MessageEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.MessageEventInit(t,r,`eventInitDict`),super(e,t),this.#eventInit=t,n.util.markAsUncloneable(this)}get data(){return n.brandCheck(this,e),this.#eventInit.data}get origin(){return n.brandCheck(this,e),this.#eventInit.origin}get lastEventId(){return n.brandCheck(this,e),this.#eventInit.lastEventId}get source(){return n.brandCheck(this,e),this.#eventInit.source}get ports(){return n.brandCheck(this,e),Object.isFrozen(this.#eventInit.ports)||Object.freeze(this.#eventInit.ports),this.#eventInit.ports}initMessageEvent(t,r=!1,i=!1,a=null,o=``,s=``,c=null,l=[]){return n.brandCheck(this,e),n.argumentLengthCheck(arguments,1,`MessageEvent.initMessageEvent`),new e(t,{bubbles:r,cancelable:i,data:a,origin:o,lastEventId:s,source:c,ports:l})}static createFastMessageEvent(t,n){let r=new e(i,t,n);return r.#eventInit=n,r.#eventInit.data??=null,r.#eventInit.origin??=``,r.#eventInit.lastEventId??=``,r.#eventInit.source??=null,r.#eventInit.ports??=[],r}};let{createFastMessageEvent:s}=o;delete o.createFastMessageEvent;var c=class e extends Event{#eventInit;constructor(e,t={}){let r=`CloseEvent constructor`;n.argumentLengthCheck(arguments,1,r),e=n.converters.DOMString(e,r,`type`),t=n.converters.CloseEventInit(t),super(e,t),this.#eventInit=t,n.util.markAsUncloneable(this)}get wasClean(){return n.brandCheck(this,e),this.#eventInit.wasClean}get code(){return n.brandCheck(this,e),this.#eventInit.code}get reason(){return n.brandCheck(this,e),this.#eventInit.reason}},l=class e extends Event{#eventInit;constructor(e,t){let r=`ErrorEvent constructor`;n.argumentLengthCheck(arguments,1,r),super(e,t),n.util.markAsUncloneable(this),e=n.converters.DOMString(e,r,`type`),t=n.converters.ErrorEventInit(t??{}),this.#eventInit=t}get message(){return n.brandCheck(this,e),this.#eventInit.message}get filename(){return n.brandCheck(this,e),this.#eventInit.filename}get lineno(){return n.brandCheck(this,e),this.#eventInit.lineno}get colno(){return n.brandCheck(this,e),this.#eventInit.colno}get error(){return n.brandCheck(this,e),this.#eventInit.error}};Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:`MessageEvent`,configurable:!0},data:r,origin:r,lastEventId:r,source:r,ports:r,initMessageEvent:r}),Object.defineProperties(c.prototype,{[Symbol.toStringTag]:{value:`CloseEvent`,configurable:!0},reason:r,code:r,wasClean:r}),Object.defineProperties(l.prototype,{[Symbol.toStringTag]:{value:`ErrorEvent`,configurable:!0},message:r,filename:r,lineno:r,colno:r,error:r}),n.converters.MessagePort=n.interfaceConverter(a),n.converters[`sequence<MessagePort>`]=n.sequenceConverter(n.converters.MessagePort);let u=[{key:`bubbles`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`cancelable`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`composed`,converter:n.converters.boolean,defaultValue:()=>!1}];n.converters.MessageEventInit=n.dictionaryConverter([...u,{key:`data`,converter:n.converters.any,defaultValue:()=>null},{key:`origin`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lastEventId`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`source`,converter:n.nullableConverter(n.converters.MessagePort),defaultValue:()=>null},{key:`ports`,converter:n.converters[`sequence<MessagePort>`],defaultValue:()=>[]}]),n.converters.CloseEventInit=n.dictionaryConverter([...u,{key:`wasClean`,converter:n.converters.boolean,defaultValue:()=>!1},{key:`code`,converter:n.converters[`unsigned short`],defaultValue:()=>0},{key:`reason`,converter:n.converters.USVString,defaultValue:()=>``}]),n.converters.ErrorEventInit=n.dictionaryConverter([...u,{key:`message`,converter:n.converters.DOMString,defaultValue:()=>``},{key:`filename`,converter:n.converters.USVString,defaultValue:()=>``},{key:`lineno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`colno`,converter:n.converters[`unsigned long`],defaultValue:()=>0},{key:`error`,converter:n.converters.any}]),t.exports={MessageEvent:o,CloseEvent:c,ErrorEvent:l,createFastMessageEvent:s}}),Rh=o((exports,t)=>{let n=`258EAFA5-E914-47DA-95CA-C5AB0DC85B11`,r={enumerable:!0,writable:!1,configurable:!1},i={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},a={NOT_SENT:0,PROCESSING:1,SENT:2},o={CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},s=2**16-1,c={INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},l=Buffer.allocUnsafe(0),u={string:1,typedArray:2,arrayBuffer:3,blob:4};t.exports={uid:n,sentCloseFrameState:a,staticPropertyDescriptors:r,states:i,opcodes:o,maxUnsigned16Bit:s,parserStates:c,emptyBuffer:l,sendHints:u}}),zh=o((exports,t)=>{t.exports={kWebSocketURL:Symbol(`url`),kReadyState:Symbol(`ready state`),kController:Symbol(`controller`),kResponse:Symbol(`response`),kBinaryType:Symbol(`binary type`),kSentClose:Symbol(`sent close`),kReceivedClose:Symbol(`received close`),kByteParser:Symbol(`byte parser`)}}),Bh=o((exports,t)=>{let{kReadyState:n,kController:r,kResponse:i,kBinaryType:a,kWebSocketURL:o}=zh(),{states:s,opcodes:c}=Rh(),{ErrorEvent:l,createFastMessageEvent:u}=Lh(),{isUtf8:d}=require(`node:buffer`),{collectASequenceOfCodePointsFast:f,removeHTTPWhitespace:p}=Em();function m(e){return e[n]===s.CONNECTING}function h(e){return e[n]===s.OPEN}function g(e){return e[n]===s.CLOSING}function _(e){return e[n]===s.CLOSED}function v(e,t,n=(e,t)=>new Event(e,t),r={}){let i=n(e,r);t.dispatchEvent(i)}function y(e,t,r){if(e[n]!==s.OPEN)return;let i;if(t===c.TEXT)try{i=M(r)}catch{C(e,`Received invalid UTF-8 in text frame.`);return}else t===c.BINARY&&(i=e[a]===`blob`?new Blob([r]):b(r));v(`message`,e,u,{origin:e[o].origin,data:i})}function b(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function x(e){if(e.length===0)return!1;for(let t=0;t<e.length;++t){let n=e.charCodeAt(t);if(n<33||n>126||n===34||n===40||n===41||n===44||n===47||n===58||n===59||n===60||n===61||n===62||n===63||n===64||n===91||n===92||n===93||n===123||n===125)return!1}return!0}function S(e){return e>=1e3&&e<1015?e!==1004&&e!==1005&&e!==1006:e>=3e3&&e<=4999}function C(e,t){let{[r]:n,[i]:a}=e;n.abort(),a?.socket&&!a.socket.destroyed&&a.socket.destroy(),t&&v(`error`,e,(e,t)=>new l(e,t),{error:Error(t),message:t})}function w(e){return e===c.CLOSE||e===c.PING||e===c.PONG}function T(e){return e===c.CONTINUATION}function E(e){return e===c.TEXT||e===c.BINARY}function D(e){return E(e)||T(e)||w(e)}function O(e){let t={position:0},n=new Map;for(;t.position<e.length;){let r=f(`;`,e,t),[i,a=``]=r.split(`=`);n.set(p(i,!0,!1),p(a,!1,!0)),t.position++}return n}function k(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}let A=typeof process.versions.icu==`string`,j=A?new TextDecoder(`utf-8`,{fatal:!0}):void 0,M=A?j.decode.bind(j):function(e){if(d(e))return e.toString(`utf-8`);throw TypeError(`Invalid utf-8 received.`)};t.exports={isConnecting:m,isEstablished:h,isClosing:g,isClosed:_,fireEvent:v,isValidSubprotocol:x,isValidStatusCode:S,failWebsocketConnection:C,websocketMessageReceived:y,utf8Decode:M,isControlFrame:w,isContinuationFrame:T,isTextBinaryFrame:E,isValidOpcode:D,parseExtensions:O,isValidClientWindowBits:k}}),Vh=o((exports,t)=>{let{maxUnsigned16Bit:n}=Rh(),r=16386,i,a=null,o=r;try{i=require(`node:crypto`)}catch{i={randomFillSync:function(e,t,n){for(let t=0;t<e.length;++t)e[t]=Math.random()*255|0;return e}}}function s(){return o===r&&(o=0,i.randomFillSync(a??=Buffer.allocUnsafe(r),0,r)),[a[o++],a[o++],a[o++],a[o++]]}var c=class{constructor(e){this.frameData=e}createFrame(e){let t=this.frameData,r=s(),i=t?.byteLength??0,a=i,o=6;i>n?(o+=8,a=127):i>125&&(o+=2,a=126);let c=Buffer.allocUnsafe(i+o);c[0]=c[1]=0,c[0]|=128,c[0]=(c[0]&240)+e,c[o-4]=r[0],c[o-3]=r[1],c[o-2]=r[2],c[o-1]=r[3],c[1]=a,a===126?c.writeUInt16BE(i,2):a===127&&(c[2]=c[3]=0,c.writeUIntBE(i,4,6)),c[1]|=128;for(let e=0;e<i;++e)c[o+e]=t[e]^r[e&3];return c}};t.exports={WebsocketFrameSend:c}}),Hh=o((exports,t)=>{let{uid:n,states:r,sentCloseFrameState:i,emptyBuffer:a,opcodes:o}=Rh(),{kReadyState:s,kSentClose:c,kByteParser:l,kReceivedClose:u,kResponse:d}=zh(),{fireEvent:f,failWebsocketConnection:p,isClosing:m,isClosed:h,isEstablished:g,parseExtensions:_}=Bh(),{channels:v}=mm(),{CloseEvent:y}=Lh(),{makeRequest:b}=Sh(),{fetching:x}=Ch(),{Headers:S,getHeadersList:C}=yh(),{getDecodeSplit:w}=Om(),{WebsocketFrameSend:T}=Vh(),E;try{E=require(`node:crypto`)}catch{}function D(e,t,r,i,a,o){let s=e;s.protocol=e.protocol===`ws:`?`http:`:`https:`;let c=b({urlList:[s],client:r,serviceWorkers:`none`,referrer:`no-referrer`,mode:`websocket`,credentials:`include`,cache:`no-store`,redirect:`error`});if(o.headers){let e=C(new S(o.headers));c.headersList=e}let l=E.randomBytes(16).toString(`base64`);c.headersList.append(`sec-websocket-key`,l),c.headersList.append(`sec-websocket-version`,`13`);for(let e of t)c.headersList.append(`sec-websocket-protocol`,e);let u=`permessage-deflate; client_max_window_bits`;c.headersList.append(`sec-websocket-extensions`,u);let d=x({request:c,useParallelQueue:!0,dispatcher:o.dispatcher,processResponse(e){if(e.type===`error`||e.status!==101){p(i,`Received network error or non-101 status code.`);return}if(t.length!==0&&!e.headersList.get(`Sec-WebSocket-Protocol`)){p(i,`Server did not respond with sent protocols.`);return}if(e.headersList.get(`Upgrade`)?.toLowerCase()!==`websocket`){p(i,`Server did not set Upgrade header to "websocket".`);return}if(e.headersList.get(`Connection`)?.toLowerCase()!==`upgrade`){p(i,`Server did not set Connection header to "upgrade".`);return}let r=e.headersList.get(`Sec-WebSocket-Accept`),o=E.createHash(`sha1`).update(l+n).digest(`base64`);if(r!==o){p(i,`Incorrect hash received in Sec-WebSocket-Accept header.`);return}let s=e.headersList.get(`Sec-WebSocket-Extensions`),u;if(s!==null&&(u=_(s),!u.has(`permessage-deflate`))){p(i,`Sec-WebSocket-Extensions header does not match.`);return}let d=e.headersList.get(`Sec-WebSocket-Protocol`);if(d!==null){let e=w(`sec-websocket-protocol`,c.headersList);if(!e.includes(d)){p(i,`Protocol was not set in the opening handshake.`);return}}e.socket.on(`data`,k),e.socket.on(`close`,A),e.socket.on(`error`,j),v.open.hasSubscribers&&v.open.publish({address:e.socket.address(),protocol:d,extensions:s}),a(e,u)}});return d}function O(e,t,n,l){if(!(m(e)||h(e)))if(!g(e))p(e,`Connection was closed before it was established.`),e[s]=r.CLOSING;else if(e[c]===i.NOT_SENT){e[c]=i.PROCESSING;let u=new T;t!==void 0&&n===void 0?(u.frameData=Buffer.allocUnsafe(2),u.frameData.writeUInt16BE(t,0)):t!==void 0&&n!==void 0?(u.frameData=Buffer.allocUnsafe(2+l),u.frameData.writeUInt16BE(t,0),u.frameData.write(n,2,`utf-8`)):u.frameData=a;let f=e[d].socket;f.write(u.createFrame(o.CLOSE)),e[c]=i.SENT,e[s]=r.CLOSING}else e[s]=r.CLOSING}function k(e){this.ws[l].write(e)||this.pause()}function A(){let{ws:e}=this,{[d]:t}=e;t.socket.off(`data`,k),t.socket.off(`close`,A),t.socket.off(`error`,j);let n=e[c]===i.SENT&&e[u],a=1005,o=``,p=e[l].closingInfo;p&&!p.error?(a=p.code??1005,o=p.reason):e[u]||(a=1006),e[s]=r.CLOSED,f(`close`,e,(e,t)=>new y(e,t),{wasClean:n,code:a,reason:o}),v.close.hasSubscribers&&v.close.publish({websocket:e,code:a,reason:o})}function j(e){let{ws:t}=this;t[s]=r.CLOSING,v.socketError.hasSubscribers&&v.socketError.publish(e),this.destroy()}t.exports={establishWebSocketConnection:D,closeWebSocketConnection:O}}),Uh=o((exports,t)=>{let{createInflateRaw:n,Z_DEFAULT_WINDOWBITS:r}=require(`node:zlib`),{isValidClientWindowBits:i}=Bh(),a=Buffer.from([0,0,255,255]),o=Symbol(`kBuffer`),s=Symbol(`kLength`);var c=class{#inflate;#options={};constructor(e){this.#options.serverNoContextTakeover=e.has(`server_no_context_takeover`),this.#options.serverMaxWindowBits=e.get(`server_max_window_bits`)}decompress(e,t,c){if(!this.#inflate){let e=r;if(this.#options.serverMaxWindowBits){if(!i(this.#options.serverMaxWindowBits)){c(Error(`Invalid server_max_window_bits`));return}e=Number.parseInt(this.#options.serverMaxWindowBits)}this.#inflate=n({windowBits:e}),this.#inflate[o]=[],this.#inflate[s]=0,this.#inflate.on(`data`,e=>{this.#inflate[o].push(e),this.#inflate[s]+=e.length}),this.#inflate.on(`error`,e=>{this.#inflate=null,c(e)})}this.#inflate.write(e),t&&this.#inflate.write(a),this.#inflate.flush(()=>{let e=Buffer.concat(this.#inflate[o],this.#inflate[s]);this.#inflate[o].length=0,this.#inflate[s]=0,c(null,e)})}};t.exports={PerMessageDeflate:c}}),Wh=o((exports,t)=>{let{Writable:n}=require(`node:stream`),r=require(`node:assert`),{parserStates:i,opcodes:a,states:o,emptyBuffer:s,sentCloseFrameState:c}=Rh(),{kReadyState:l,kSentClose:u,kResponse:d,kReceivedClose:f}=zh(),{channels:p}=mm(),{isValidStatusCode:m,isValidOpcode:h,failWebsocketConnection:g,websocketMessageReceived:_,utf8Decode:v,isControlFrame:y,isTextBinaryFrame:b,isContinuationFrame:x}=Bh(),{WebsocketFrameSend:S}=Vh(),{closeWebSocketConnection:C}=Hh(),{PerMessageDeflate:w}=Uh();var T=class extends n{#buffers=[];#byteOffset=0;#loop=!1;#state=i.INFO;#info={};#fragments=[];#extensions;constructor(e,t){super(),this.ws=e,this.#extensions=t??new Map,this.#extensions.has(`permessage-deflate`)&&this.#extensions.set(`permessage-deflate`,new w(t))}_write(e,t,n){this.#buffers.push(e),this.#byteOffset+=e.length,this.#loop=!0,this.run(n)}run(e){for(;this.#loop;)if(this.#state===i.INFO){if(this.#byteOffset<2)return e();let t=this.consume(2),n=(t[0]&128)!=0,r=t[0]&15,o=(t[1]&128)==128,s=!n&&r!==a.CONTINUATION,c=t[1]&127,l=t[0]&64,u=t[0]&32,d=t[0]&16;if(!h(r))return g(this.ws,`Invalid opcode received`),e();if(o)return g(this.ws,`Frame cannot be masked`),e();if(l!==0&&!this.#extensions.has(`permessage-deflate`)){g(this.ws,`Expected RSV1 to be clear.`);return}if(u!==0||d!==0){g(this.ws,`RSV1, RSV2, RSV3 must be clear`);return}if(s&&!b(r)){g(this.ws,`Invalid frame type was fragmented.`);return}if(b(r)&&this.#fragments.length>0){g(this.ws,`Expected continuation frame`);return}if(this.#info.fragmented&&s){g(this.ws,`Fragmented frame exceeded 125 bytes.`);return}if((c>125||s)&&y(r)){g(this.ws,`Control frame either too large or fragmented`);return}if(x(r)&&this.#fragments.length===0&&!this.#info.compressed){g(this.ws,`Unexpected continuation frame`);return}c<=125?(this.#info.payloadLength=c,this.#state=i.READ_DATA):c===126?this.#state=i.PAYLOADLENGTH_16:c===127&&(this.#state=i.PAYLOADLENGTH_64),b(r)&&(this.#info.binaryType=r,this.#info.compressed=l!==0),this.#info.opcode=r,this.#info.masked=o,this.#info.fin=n,this.#info.fragmented=s}else if(this.#state===i.PAYLOADLENGTH_16){if(this.#byteOffset<2)return e();let t=this.consume(2);this.#info.payloadLength=t.readUInt16BE(0),this.#state=i.READ_DATA}else if(this.#state===i.PAYLOADLENGTH_64){if(this.#byteOffset<8)return e();let t=this.consume(8),n=t.readUInt32BE(0);if(n>2**31-1){g(this.ws,`Received payload length > 2^31 bytes.`);return}let r=t.readUInt32BE(4);this.#info.payloadLength=(n<<8)+r,this.#state=i.READ_DATA}else if(this.#state===i.READ_DATA){if(this.#byteOffset<this.#info.payloadLength)return e();let t=this.consume(this.#info.payloadLength);if(y(this.#info.opcode))this.#loop=this.parseControlFrame(t),this.#state=i.INFO;else if(this.#info.compressed){this.#extensions.get(`permessage-deflate`).decompress(t,this.#info.fin,(t,n)=>{if(t){C(this.ws,1007,t.message,t.message.length);return}if(this.#fragments.push(n),!this.#info.fin){this.#state=i.INFO,this.#loop=!0,this.run(e);return}_(this.ws,this.#info.binaryType,Buffer.concat(this.#fragments)),this.#loop=!0,this.#state=i.INFO,this.#fragments.length=0,this.run(e)}),this.#loop=!1;break}else{if(this.#fragments.push(t),!this.#info.fragmented&&this.#info.fin){let e=Buffer.concat(this.#fragments);_(this.ws,this.#info.binaryType,e),this.#fragments.length=0}this.#state=i.INFO}}}consume(e){if(e>this.#byteOffset)throw Error(`Called consume() before buffers satiated.`);if(e===0)return s;if(this.#buffers[0].length===e)return this.#byteOffset-=this.#buffers[0].length,this.#buffers.shift();let t=Buffer.allocUnsafe(e),n=0;for(;n!==e;){let r=this.#buffers[0],{length:i}=r;if(i+n===e){t.set(this.#buffers.shift(),n);break}else if(i+n>e){t.set(r.subarray(0,e-n),n),this.#buffers[0]=r.subarray(e-n);break}else t.set(this.#buffers.shift(),n),n+=r.length}return this.#byteOffset-=e,t}parseCloseBody(e){r(e.length!==1);let t;if(e.length>=2&&(t=e.readUInt16BE(0)),t!==void 0&&!m(t))return{code:1002,reason:`Invalid status code`,error:!0};let n=e.subarray(2);n[0]===239&&n[1]===187&&n[2]===191&&(n=n.subarray(3));try{n=v(n)}catch{return{code:1007,reason:`Invalid UTF-8`,error:!0}}return{code:t,reason:n,error:!1}}parseControlFrame(e){let{opcode:t,payloadLength:n}=this.#info;if(t===a.CLOSE){if(n===1)return g(this.ws,`Received close frame with a 1-byte body.`),!1;if(this.#info.closeInfo=this.parseCloseBody(e),this.#info.closeInfo.error){let{code:e,reason:t}=this.#info.closeInfo;return C(this.ws,e,t,t.length),g(this.ws,t),!1}if(this.ws[u]!==c.SENT){let e=s;this.#info.closeInfo.code&&(e=Buffer.allocUnsafe(2),e.writeUInt16BE(this.#info.closeInfo.code,0));let t=new S(e);this.ws[d].socket.write(t.createFrame(a.CLOSE),e=>{e||(this.ws[u]=c.SENT)})}return this.ws[l]=o.CLOSING,this.ws[f]=!0,!1}else if(t===a.PING){if(!this.ws[f]){let t=new S(e);this.ws[d].socket.write(t.createFrame(a.PONG)),p.ping.hasSubscribers&&p.ping.publish({payload:e})}}else t===a.PONG&&p.pong.hasSubscribers&&p.pong.publish({payload:e});return!0}get closingInfo(){return this.#info.closeInfo}};t.exports={ByteParser:T}}),Gh=o((exports,t)=>{let{WebsocketFrameSend:n}=Vh(),{opcodes:r,sendHints:i}=Rh(),a=zm(),o=Buffer[Symbol.species];var s=class{#queue=new a;#running=!1;#socket;constructor(e){this.#socket=e}add(e,t,n){if(n!==i.blob){let r=c(e,n);if(!this.#running)this.#socket.write(r,t);else{let e={promise:null,callback:t,frame:r};this.#queue.push(e)}return}let r={promise:e.arrayBuffer().then(e=>{r.promise=null,r.frame=c(e,n)}),callback:t,frame:null};this.#queue.push(r),this.#running||this.#run()}async#run(){this.#running=!0;let e=this.#queue;for(;!e.isEmpty();){let t=e.shift();t.promise!==null&&await t.promise,this.#socket.write(t.frame,t.callback),t.callback=t.frame=null}this.#running=!1}};function c(e,t){return new n(l(e,t)).createFrame(t===i.string?r.TEXT:r.BINARY)}function l(e,t){switch(t){case i.string:return Buffer.from(e);case i.arrayBuffer:case i.blob:return new o(e);case i.typedArray:return new o(e.buffer,e.byteOffset,e.byteLength)}}t.exports={SendQueue:s}}),Kh=o((exports,t)=>{let{webidl:n}=Dm(),{URLSerializer:r}=Em(),{environmentSettingsObject:i}=Om(),{staticPropertyDescriptors:a,states:o,sentCloseFrameState:s,sendHints:c}=Rh(),{kWebSocketURL:l,kReadyState:u,kController:d,kBinaryType:f,kResponse:p,kSentClose:m,kByteParser:h}=zh(),{isConnecting:g,isEstablished:_,isClosing:v,isValidSubprotocol:y,fireEvent:b}=Bh(),{establishWebSocketConnection:x,closeWebSocketConnection:S}=Hh(),{ByteParser:C}=Wh(),{kEnumerableProperty:w,isBlobLike:T}=$(),{getGlobalDispatcher:E}=ph(),{types:D}=require(`node:util`),{ErrorEvent:O,CloseEvent:k}=Lh(),{SendQueue:A}=Gh();var j=class e extends EventTarget{#events={open:null,error:null,close:null,message:null};#bufferedAmount=0;#protocol=``;#extensions=``;#sendQueue;constructor(t,r=[]){super(),n.util.markAsUncloneable(this);let a=`WebSocket constructor`;n.argumentLengthCheck(arguments,1,a);let o=n.converters[`DOMString or sequence<DOMString> or WebSocketInit`](r,a,`options`);t=n.converters.USVString(t,a,`url`),r=o.protocols;let c=i.settingsObject.baseUrl,p;try{p=new URL(t,c)}catch(e){throw new DOMException(e,`SyntaxError`)}if(p.protocol===`http:`?p.protocol=`ws:`:p.protocol===`https:`&&(p.protocol=`wss:`),p.protocol!==`ws:`&&p.protocol!==`wss:`)throw new DOMException(`Expected a ws: or wss: protocol, got ${p.protocol}`,`SyntaxError`);if(p.hash||p.href.endsWith(`#`))throw new DOMException(`Got fragment`,`SyntaxError`);if(typeof r==`string`&&(r=[r]),r.length!==new Set(r.map(e=>e.toLowerCase())).size||r.length>0&&!r.every(e=>y(e)))throw new DOMException(`Invalid Sec-WebSocket-Protocol value`,`SyntaxError`);this[l]=new URL(p.href);let h=i.settingsObject;this[d]=x(p,r,h,this,(e,t)=>this.#onConnectionEstablished(e,t),o),this[u]=e.CONNECTING,this[m]=s.NOT_SENT,this[f]=`blob`}close(t=void 0,r=void 0){n.brandCheck(this,e);let i=`WebSocket.close`;if(t!==void 0&&(t=n.converters[`unsigned short`](t,i,`code`,{clamp:!0})),r!==void 0&&(r=n.converters.USVString(r,i,`reason`)),t!==void 0&&t!==1e3&&(t<3e3||t>4999))throw new DOMException(`invalid code`,`InvalidAccessError`);let a=0;if(r!==void 0&&(a=Buffer.byteLength(r),a>123))throw new DOMException(`Reason must be less than 123 bytes; received ${a}`,`SyntaxError`);S(this,t,r,a)}send(t){n.brandCheck(this,e);let r=`WebSocket.send`;if(n.argumentLengthCheck(arguments,1,r),t=n.converters.WebSocketSendData(t,r,`data`),g(this))throw new DOMException(`Sent before connected.`,`InvalidStateError`);if(!(!_(this)||v(this)))if(typeof t==`string`){let e=Buffer.byteLength(t);this.#bufferedAmount+=e,this.#sendQueue.add(t,()=>{this.#bufferedAmount-=e},c.string)}else D.isArrayBuffer(t)?(this.#bufferedAmount+=t.byteLength,this.#sendQueue.add(t,()=>{this.#bufferedAmount-=t.byteLength},c.arrayBuffer)):ArrayBuffer.isView(t)?(this.#bufferedAmount+=t.byteLength,this.#sendQueue.add(t,()=>{this.#bufferedAmount-=t.byteLength},c.typedArray)):T(t)&&(this.#bufferedAmount+=t.size,this.#sendQueue.add(t,()=>{this.#bufferedAmount-=t.size},c.blob))}get readyState(){return n.brandCheck(this,e),this[u]}get bufferedAmount(){return n.brandCheck(this,e),this.#bufferedAmount}get url(){return n.brandCheck(this,e),r(this[l])}get extensions(){return n.brandCheck(this,e),this.#extensions}get protocol(){return n.brandCheck(this,e),this.#protocol}get onopen(){return n.brandCheck(this,e),this.#events.open}set onopen(t){n.brandCheck(this,e),this.#events.open&&this.removeEventListener(`open`,this.#events.open),typeof t==`function`?(this.#events.open=t,this.addEventListener(`open`,t)):this.#events.open=null}get onerror(){return n.brandCheck(this,e),this.#events.error}set onerror(t){n.brandCheck(this,e),this.#events.error&&this.removeEventListener(`error`,this.#events.error),typeof t==`function`?(this.#events.error=t,this.addEventListener(`error`,t)):this.#events.error=null}get onclose(){return n.brandCheck(this,e),this.#events.close}set onclose(t){n.brandCheck(this,e),this.#events.close&&this.removeEventListener(`close`,this.#events.close),typeof t==`function`?(this.#events.close=t,this.addEventListener(`close`,t)):this.#events.close=null}get onmessage(){return n.brandCheck(this,e),this.#events.message}set onmessage(t){n.brandCheck(this,e),this.#events.message&&this.removeEventListener(`message`,this.#events.message),typeof t==`function`?(this.#events.message=t,this.addEventListener(`message`,t)):this.#events.message=null}get binaryType(){return n.brandCheck(this,e),this[f]}set binaryType(t){n.brandCheck(this,e),t!==`blob`&&t!==`arraybuffer`?this[f]=`blob`:this[f]=t}#onConnectionEstablished(e,t){this[p]=e;let n=new C(this,t);n.on(`drain`,M),n.on(`error`,N.bind(this)),e.socket.ws=this,this[h]=n,this.#sendQueue=new A(e.socket),this[u]=o.OPEN;let r=e.headersList.get(`sec-websocket-extensions`);r!==null&&(this.#extensions=r);let i=e.headersList.get(`sec-websocket-protocol`);i!==null&&(this.#protocol=i),b(`open`,this)}};j.CONNECTING=j.prototype.CONNECTING=o.CONNECTING,j.OPEN=j.prototype.OPEN=o.OPEN,j.CLOSING=j.prototype.CLOSING=o.CLOSING,j.CLOSED=j.prototype.CLOSED=o.CLOSED,Object.defineProperties(j.prototype,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a,url:w,readyState:w,bufferedAmount:w,onopen:w,onerror:w,onclose:w,close:w,onmessage:w,binaryType:w,send:w,extensions:w,protocol:w,[Symbol.toStringTag]:{value:`WebSocket`,writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(j,{CONNECTING:a,OPEN:a,CLOSING:a,CLOSED:a}),n.converters[`sequence<DOMString>`]=n.sequenceConverter(n.converters.DOMString),n.converters[`DOMString or sequence<DOMString>`]=function(e,t,r){return n.util.Type(e)===`Object`&&Symbol.iterator in e?n.converters[`sequence<DOMString>`](e):n.converters.DOMString(e,t,r)},n.converters.WebSocketInit=n.dictionaryConverter([{key:`protocols`,converter:n.converters[`DOMString or sequence<DOMString>`],defaultValue:()=>[]},{key:`dispatcher`,converter:n.converters.any,defaultValue:()=>E()},{key:`headers`,converter:n.nullableConverter(n.converters.HeadersInit)}]),n.converters[`DOMString or sequence<DOMString> or WebSocketInit`]=function(e){return n.util.Type(e)===`Object`&&!(Symbol.iterator in e)?n.converters.WebSocketInit(e):{protocols:n.converters[`DOMString or sequence<DOMString>`](e)}},n.converters.WebSocketSendData=function(e){if(n.util.Type(e)===`Object`){if(T(e))return n.converters.Blob(e,{strict:!1});if(ArrayBuffer.isView(e)||D.isArrayBuffer(e))return n.converters.BufferSource(e)}return n.converters.USVString(e)};function M(){this.ws[p].socket.resume()}function N(e){let t,n;e instanceof k?(t=e.reason,n=e.code):t=e.message,b(`error`,this,()=>new O(`error`,{error:e,message:t})),S(this,n)}t.exports={WebSocket:j}}),qh=o((exports,t)=>{function n(e){return e.indexOf(`\0`)===-1}function r(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)<48||e.charCodeAt(t)>57)return!1;return!0}function i(e){return new Promise(t=>{setTimeout(t,e).unref()})}t.exports={isValidLastEventId:n,isASCIINumber:r,delay:i}}),Jh=o((exports,t)=>{let{Transform:n}=require(`node:stream`),{isASCIINumber:r,isValidLastEventId:i}=qh(),a=[239,187,191],o=10,s=13,c=58,l=32;var u=class extends n{state=null;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,t,n){if(e.length===0){n();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===a[0]){n();return}this.checkBOM=!1,n();return;case 2:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]){n();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,n();return}this.checkBOM=!1;break;default:this.buffer[0]===a[0]&&this.buffer[1]===a[1]&&this.buffer[2]===a[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos<this.buffer.length;){if(this.eventEndCheck){if(this.crlfCheck){if(this.buffer[this.pos]===o){this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.crlfCheck=!1;continue}this.crlfCheck=!1}if(this.buffer[this.pos]===o||this.buffer[this.pos]===s){this.buffer[this.pos]===s&&(this.crlfCheck=!0),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,(this.event.data!==void 0||this.event.event||this.event.id||this.event.retry)&&this.processEvent(this.event),this.clearEvent();continue}this.eventEndCheck=!1;continue}if(this.buffer[this.pos]===o||this.buffer[this.pos]===s){this.buffer[this.pos]===s&&(this.crlfCheck=!0),this.parseLine(this.buffer.subarray(0,this.pos),this.event),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.eventEndCheck=!0;continue}this.pos++}n()}parseLine(e,t){if(e.length===0)return;let n=e.indexOf(c);if(n===0)return;let a=``,o=``;if(n!==-1){a=e.subarray(0,n).toString(`utf8`);let t=n+1;e[t]===l&&++t,o=e.subarray(t).toString(`utf8`)}else a=e.toString(`utf8`),o=``;switch(a){case`data`:t[a]===void 0?t[a]=o:t[a]+=`\n${o}`;break;case`retry`:r(o)&&(t[a]=o);break;case`id`:i(o)&&(t[a]=o);break;case`event`:o.length>0&&(t[a]=o);break}}processEvent(e){e.retry&&r(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id&&i(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||`message`,options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};t.exports={EventSourceStream:u}}),Yh=o((exports,t)=>{let{pipeline:n}=require(`node:stream`),{fetching:r}=Ch(),{makeRequest:i}=Sh(),{webidl:a}=Dm(),{EventSourceStream:o}=Jh(),{parseMIMEType:s}=Em(),{createFastMessageEvent:c}=Lh(),{isNetworkError:l}=bh(),{delay:u}=qh(),{kEnumerableProperty:d}=$(),{environmentSettingsObject:f}=Om(),p=!1,m=3e3,h=0,g=1,_=2,v=`anonymous`,y=`use-credentials`;var b=class e extends EventTarget{#events={open:null,error:null,message:null};#url=null;#withCredentials=!1;#readyState=h;#request=null;#controller=null;#dispatcher;#state;constructor(e,t={}){super(),a.util.markAsUncloneable(this);let n=`EventSource constructor`;a.argumentLengthCheck(arguments,1,n),p||(p=!0,process.emitWarning(`EventSource is experimental, expect them to change at any time.`,{code:`UNDICI-ES`})),e=a.converters.USVString(e,n,`url`),t=a.converters.EventSourceInitDict(t,n,`eventSourceInitDict`),this.#dispatcher=t.dispatcher,this.#state={lastEventId:``,reconnectionTime:m};let r=f,o;try{o=new URL(e,r.settingsObject.baseUrl),this.#state.origin=o.origin}catch(e){throw new DOMException(e,`SyntaxError`)}this.#url=o.href;let s=v;t.withCredentials&&(s=y,this.#withCredentials=!0);let c={redirect:`follow`,keepalive:!0,mode:`cors`,credentials:s===`anonymous`?`same-origin`:`omit`,referrer:`no-referrer`};c.client=f.settingsObject,c.headersList=[[`accept`,{name:`accept`,value:`text/event-stream`}]],c.cache=`no-store`,c.initiator=`other`,c.urlList=[new URL(this.#url)],this.#request=i(c),this.#connect()}get readyState(){return this.#readyState}get url(){return this.#url}get withCredentials(){return this.#withCredentials}#connect(){if(this.#readyState===_)return;this.#readyState=h;let e={request:this.#request,dispatcher:this.#dispatcher},t=e=>{l(e)&&(this.dispatchEvent(new Event(`error`)),this.close()),this.#reconnect()};e.processResponseEndOfBody=t,e.processResponse=e=>{if(l(e))if(e.aborted){this.close(),this.dispatchEvent(new Event(`error`));return}else{this.#reconnect();return}let t=e.headersList.get(`content-type`,!0),r=t===null?`failure`:s(t),i=r!==`failure`&&r.essence===`text/event-stream`;if(e.status!==200||i===!1){this.close(),this.dispatchEvent(new Event(`error`));return}this.#readyState=g,this.dispatchEvent(new Event(`open`)),this.#state.origin=e.urlList[e.urlList.length-1].origin;let a=new o({eventSourceSettings:this.#state,push:e=>{this.dispatchEvent(c(e.type,e.options))}});n(e.body.stream,a,e=>{e?.aborted===!1&&(this.close(),this.dispatchEvent(new Event(`error`)))})},this.#controller=r(e)}async#reconnect(){this.#readyState!==_&&(this.#readyState=h,this.dispatchEvent(new Event(`error`)),await u(this.#state.reconnectionTime),this.#readyState===h&&(this.#state.lastEventId.length&&this.#request.headersList.set(`last-event-id`,this.#state.lastEventId,!0),this.#connect()))}close(){a.brandCheck(this,e),this.#readyState!==_&&(this.#readyState=_,this.#controller.abort(),this.#request=null)}get onopen(){return this.#events.open}set onopen(e){this.#events.open&&this.removeEventListener(`open`,this.#events.open),typeof e==`function`?(this.#events.open=e,this.addEventListener(`open`,e)):this.#events.open=null}get onmessage(){return this.#events.message}set onmessage(e){this.#events.message&&this.removeEventListener(`message`,this.#events.message),typeof e==`function`?(this.#events.message=e,this.addEventListener(`message`,e)):this.#events.message=null}get onerror(){return this.#events.error}set onerror(e){this.#events.error&&this.removeEventListener(`error`,this.#events.error),typeof e==`function`?(this.#events.error=e,this.addEventListener(`error`,e)):this.#events.error=null}};let x={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:h,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:g,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:_,writable:!1}};Object.defineProperties(b,x),Object.defineProperties(b.prototype,x),Object.defineProperties(b.prototype,{close:d,onerror:d,onmessage:d,onopen:d,readyState:d,url:d,withCredentials:d}),a.converters.EventSourceInitDict=a.dictionaryConverter([{key:`withCredentials`,converter:a.converters.boolean,defaultValue:()=>!1},{key:`dispatcher`,converter:a.converters.any}]),t.exports={EventSource:b,defaultReconnectionTime:m}}),Xh=o((exports,t)=>{let n=Rm(),r=gm(),i=Hm(),a=Um(),o=Wm(),s=Gm(),c=Km(),l=Jm(),u=dm(),d=$(),{InvalidArgumentError:f}=u,p=rh(),m=ym(),h=ch(),g=fh(),_=lh(),v=ih(),y=qm(),{getGlobalDispatcher:b,setGlobalDispatcher:x}=ph(),S=mh(),C=Im(),w=Lm();Object.assign(r.prototype,p),t.exports.Dispatcher=r,t.exports.Client=n,t.exports.Pool=i,t.exports.BalancedPool=a,t.exports.Agent=o,t.exports.ProxyAgent=s,t.exports.EnvHttpProxyAgent=c,t.exports.RetryAgent=l,t.exports.RetryHandler=y,t.exports.DecoratorHandler=S,t.exports.RedirectHandler=C,t.exports.createRedirectInterceptor=w,t.exports.interceptors={redirect:hh(),retry:gh(),dump:_h(),dns:vh()},t.exports.buildConnector=m,t.exports.errors=u,t.exports.util={parseHeaders:d.parseHeaders,headerNameToString:d.headerNameToString};function T(e){return(t,n,r)=>{if(typeof n==`function`&&(r=n,n=null),!t||typeof t!=`string`&&typeof t!=`object`&&!(t instanceof URL))throw new f(`invalid url`);if(n!=null&&typeof n!=`object`)throw new f(`invalid opts`);if(n&&n.path!=null){if(typeof n.path!=`string`)throw new f(`invalid opts.path`);let e=n.path;n.path.startsWith(`/`)||(e=`/${e}`),t=new URL(d.parseOrigin(t).origin+e)}else n||=typeof t==`object`?t:{},t=d.parseURL(t);let{agent:i,dispatcher:a=b()}=n;if(i)throw new f(`unsupported opts.agent. Did you mean opts.client?`);return e.call(a,{...n,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:n.method||(n.body?`PUT`:`GET`)},r)}}t.exports.setGlobalDispatcher=x,t.exports.getGlobalDispatcher=b;let E=Ch().fetch;t.exports.fetch=async function(e,t=void 0){try{return await E(e,t)}catch(e){throw e&&typeof e==`object`&&Error.captureStackTrace(e),e}},t.exports.Headers=yh().Headers,t.exports.Response=bh().Response,t.exports.Request=Sh().Request,t.exports.FormData=jm().FormData,t.exports.File=globalThis.File??require(`node:buffer`).File,t.exports.FileReader=Oh().FileReader;let{setGlobalOrigin:D,getGlobalOrigin:O}=Tm();t.exports.setGlobalOrigin=D,t.exports.getGlobalOrigin=O;let{CacheStorage:k}=Mh(),{kConstruct:A}=kh();t.exports.caches=new k(A);let{deleteCookie:j,getCookies:M,getSetCookies:N,setCookie:P}=Ih();t.exports.deleteCookie=j,t.exports.getCookies=M,t.exports.getSetCookies=N,t.exports.setCookie=P;let{parseMIMEType:F,serializeAMimeType:I}=Em();t.exports.parseMIMEType=F,t.exports.serializeAMimeType=I;let{CloseEvent:L,ErrorEvent:R,MessageEvent:z}=Lh();t.exports.WebSocket=Kh().WebSocket,t.exports.CloseEvent=L,t.exports.ErrorEvent=R,t.exports.MessageEvent=z,t.exports.request=T(p.request),t.exports.stream=T(p.stream),t.exports.pipeline=T(p.pipeline),t.exports.connect=T(p.connect),t.exports.upgrade=T(p.upgrade),t.exports.MockClient=h,t.exports.MockPool=_,t.exports.MockAgent=g,t.exports.mockErrors=v;let{EventSource:B}=Yh();t.exports.EventSource=B}),Zh=c(Xh());const Qh=1e4,$h=12e4;function eg(e){let t=new URL(e),n=t.protocol===`https:`;return n?process.env.https_proxy||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.HTTP_PROXY:process.env.http_proxy||process.env.HTTP_PROXY}let tg,ng;function rg(e){return tg&&ng===e?tg:(ng=e,tg=new Zh.ProxyAgent(e),tg)}async function ig(e,t={},n=Qh){let r=new AbortController,i=setTimeout(()=>{r.abort()},n);try{let n=eg(e),i=n?rg(n):void 0;return await fetch(e,{...t,signal:r.signal,dispatcher:i})}finally{clearTimeout(i)}}async function ag(e){try{let t=await ig(e,{method:`HEAD`});return t.ok}catch{return!1}}async function og(e,t){let[,n,r,i,a,...o]=e.pathname.split(`/`),s=t?t.replace(/^\//,``):o.join(`/`);if(i===void 0||i===``&&a===void 0)try{let e=await ig(`https://api.github.com/repos/${n}/${r}`);if(!e.ok)return;let t=await e.json();return{username:n,name:r,branch:t.default_branch,filePath:s}}catch{return}let c=t?`${a}/${o.join(`/`)}`.replace(RegExp(`/${s}|/$`),``):a;if(n&&r&&c&&i===`tree`)return{username:n,name:r,branch:c,filePath:s}}function sg({username:e,name:t,branch:n,filePath:r}){let i=`https://api.github.com/repos/${e}/${t}/contents`,a=`${r?`/${r}`:``}/package.json`;return ag(`${i+a}?ref=${n}`)}function cg(e){try{let t=new URL(e);return ag(t.href)}catch{return ag(`https://api.github.com/repos/vercel/turborepo/contents/examples/${encodeURIComponent(e)}`)}}function lg(e,t,n){if(t.includes(`\0`))return!1;let r=t.replace(/\\/g,`/`),i=r.normalize(`NFC`),a=n??(0,_.resolve)(e),o=(0,_.resolve)(a,i),s=(0,_.relative)(a,o);return!s.startsWith(`..`)&&(0,_.resolve)(o)===o}function ug(e){return e===`SymbolicLink`||e===`Link`}async function dg({url:e,root:t,strip:n,filter:r}){let i=new AbortController,a=setTimeout(()=>{i.abort()},$h),o=[],s=(0,_.resolve)(t),c=new Set;try{let a=eg(e),l=a?rg(a):void 0,u=await fetch(e,{signal:i.signal,dispatcher:l});if(!u.ok||!u.body)throw Error(`Failed to download: ${u.status}`);let d=S.Readable.fromWeb(u.body),f=null,p=[],m=new gd({filter:e=>{if(f===null){let t=e.split(`/`);f=t.length?t[0]:null}return r(e,f)},onReadEntry:e=>{let r=e.path.split(`/`),i=r.slice(n).join(`/`);if(!i){e.resume();return}if(!lg(t,i,s)){vs(`Blocked path traversal attempt: ${e.path}`),e.resume();return}if(e.type&&ug(e.type)){_s(`Blocked symlink: ${e.path}`),e.resume();return}let a=(0,_.resolve)(s,i);if(e.type===`Directory`)c.has(a)||((0,g.mkdirSync)(a,{recursive:!0}),c.add(a)),e.resume();else if(e.type===`File`){let t=(0,_.dirname)(a);c.has(t)||((0,g.mkdirSync)(t,{recursive:!0}),c.add(t));let n=(0,g.createWriteStream)(a);o.push(n),p.push(new Promise((e,t)=>{n.on(`finish`,e),n.on(`error`,t)})),e.pipe(n)}else e.resume()}});await(0,C.pipeline)(d,(0,w.createGunzip)(),m),await Promise.all(p)}finally{clearTimeout(a);for(let e of o)e.destroy()}}async function fg(e,{username:t,name:n,branch:r,filePath:i}){let a=`https://codeload.github.com/${t}/${n}/tar.gz/${r}`,o=(0,_.join)((0,b.tmpdir)(),`turbo-download-${Date.now()}.tar.gz`),s=await ig(a,{},$h);if(!s.ok||!s.body)throw Error(`Failed to download: ${s.status}`);let c=Buffer.from(await s.arrayBuffer());await(0,T.writeFile)(o,c);let l=null;try{await tm({file:o,cwd:e,strip:i?i.split(`/`).length+1:1,filter:e=>{if(l===null){let t=e.split(`/`);l=t.length?t[0]:null}return e.startsWith(`${l}${i?`/${i}/`:`/`}`)}})}finally{await(0,T.unlink)(o)}}function pg(e,t){if(!e||typeof e!=`string`||e.includes(`\0`)||e.startsWith(`-`))throw Error(`Invalid ${t}: path must be a non-empty string without NUL bytes and cannot start with "-"`)}async function mg(e,t){if(!t||!/^[a-zA-Z0-9_-]+$/.test(t))throw Error(`Invalid example name: ${t}`);let n=(0,_.resolve)(e);pg(n,`project root`);let r=(0,_.join)(n,`.turbo-clone-temp`);pg(r,`temporary directory`);try{(0,E.execFileSync)(`git`,[`clone`,`--filter=blob:none`,`--no-checkout`,`--depth`,`1`,`--sparse`,`https://github.com/vercel/turborepo.git`,r],{stdio:`pipe`}),(0,E.execFileSync)(`git`,[`sparse-checkout`,`set`,`examples/${t}`],{cwd:r,stdio:`pipe`}),(0,E.execFileSync)(`git`,[`checkout`],{cwd:r,stdio:`pipe`});let e=(0,_.join)(r,`examples`,t);(0,g.cpSync)(e,n,{recursive:!0})}catch{(0,g.rmSync)(r,{recursive:!0,force:!0}),_s(`Git is not available. Downloading example via tarball (slower).
80
- For faster downloads, install git: https://git-scm.com/downloads`),await dg({url:`https://codeload.github.com/vercel/turborepo/tar.gz/main`,root:n,strip:3,filter:(e,n)=>e.startsWith(`${n}/examples/${t}/`)});return}(0,g.rmSync)(r,{recursive:!0,force:!0})}async function hg(e){try{return await h.default.access(e,h.default.constants.W_OK),!0}catch{return!1}}var gg=o((exports,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}}),_g=o(exports=>{var t=gg();exports.operation=function(n){var r=exports.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},exports.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},exports.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},exports.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=exports.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}}),vg=o((exports,t)=>{t.exports=_g()}),yg=o((exports,t)=>{var n=vg();function r(e,t){function r(r,i){var a=t||{},o;`randomize`in a||(a.randomize=!0),o=n.operation(a);function s(e){i(e||Error(`Aborted`))}function c(e,t){if(e.bail){s(e);return}o.retry(e)?a.onRetry&&a.onRetry(e,t):i(o.mainError())}function l(t){var n;try{n=e(s,t)}catch(e){c(e,t);return}Promise.resolve(n).then(r).catch(function(e){c(e,t)})}o.attempt(l)}return new Promise(r)}t.exports=r}),bg=c(yg());function xg(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}var Sg=class extends Error{};function Cg(e){return e.hostname===`github.com`}async function wg({appPath:e,example:t,isDefaultExample:n,examplePath:r}){let i,a;gs();let o=ds(`Downloading files...`);o.start();try{if(!n){try{a=new URL(t)}catch(e){let t=e;t.code!==`ERR_INVALID_URL`&&(o.stop(),vs(e),process.exit(1))}if(a){Cg(a)||(o.stop(),vs(`Invalid URL: ${d.default.red(`"${t}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`),process.exit(1)),i=await og(a,r),i||(o.stop(),vs(`Unable to fetch repository information from: ${d.default.red(`"${t}"`)}. Please fix the URL and try again.`),process.exit(1));let e=await sg(i);e||(o.stop(),vs(`Could not locate the repository for ${d.default.red(`"${t}"`)}. Please check that the repository exists and try again.`),process.exit(1))}else{let e=await cg(t);e||(o.stop(),vs(`Could not locate an example named ${d.default.red(`"${t}"`)}. It could be due to the following:\n`,`1. Your spelling of example ${d.default.red(`"${t}"`)} might be incorrect.\n`,`2. You might not be connected to the internet or you are behind a proxy.`),process.exit(1)),i={username:`vercel`,name:`turborepo`,branch:`main`,filePath:`examples/${t}`}}}let s=_.default.resolve(e);await hg(_.default.dirname(s))||(o.stop(),vs(`The application path is not writable, please check folder permissions and try again.`),vs(`It is likely you do not have write permissions for this folder.`),process.exit(1));let c=_.default.basename(s);try{await h.default.mkdir(s,{recursive:!0})}catch(e){o.stop(),vs(`Unable to create project directory`),vs(e),process.exit(1)}let{isEmpty:l,conflicts:u}=tc(s);l||(o.stop(),vs(`${d.default.dim(s)} has ${u.length} conflicting ${u.length===1?`file`:`files`} - please try a different location`),process.exit(1));let f=process.cwd();process.chdir(s),n||i?await(0,bg.default)(()=>fg(s,i??{username:`vercel`,name:`turborepo`,branch:`main`,filePath:`examples/basic`}),{retries:3}):await(0,bg.default)(()=>mg(s,t),{retries:3}),o.stop();let p=_.default.join(s,`package.json`),m=h.default.existsSync(p),g=[];if(m){let e;try{e=h.default.readJsonSync(p)}catch{}e&&g.push(...Object.keys(e.scripts||{}))}let v=e;return _.default.join(f,c)===e&&(v=c),{cdPath:v,hasPackageJson:m,availableScripts:g,repoInfo:i}}catch(e){throw o.stop(),new Sg(xg(e)?e.message:String(e))}}function Tg(e,t={to:`camel`}){switch(t.to){case`camel`:return e.replace(/(?:[-_][a-z])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``));default:throw Error(`Not implemented`)}}function Eg(e){let{packageInfo:t,upgradeCommand:n}=e,r=(0,M.default)(t).catch(()=>null);return async function(e=0){try{let i=await r;if(i?.latest){gs(),gs(d.default.yellow(d.default.bold(`A new version of \`${t.name}\` is available!`)));let e=typeof n==`function`?await n():n;e&&gs(`You can update by running: ${d.default.cyan(e)}`),gs()}process.exit(e)}catch(t){process.env.DEBUG&&vs(`Update check failed:`,t),process.exit(e)}}}var Dg=`@turbo/gen`,Og=`2.8.5`,kg=`Extend a Turborepo`,Ag=`commonjs`,jg=`https://turborepo.dev`,Mg=`MIT`,Ng={type:`git`,url:`git+https://github.com/vercel/turborepo.git`,directory:`packages/turbo-gen`},Pg={url:`https://github.com/vercel/turborepo/issues`},Fg=`dist/cli.js`,Ig=`dist/types.d.ts`,Lg={build:`tsdown`,test:`jest`,"check-types":`tsc --noEmit`,"package:types":`attw --profile node16 --pack`},Rg={"@turbo/workspaces":`workspace:*`,commander:`10.0.0`,"fs-extra":`10.1.0`,"@inquirer/prompts":`^7.10.1`,minimatch:`9.0.0`,"node-plop":`0.26.3`,picocolors:`1.0.1`,"proxy-agent":`6.5.0`,tsx:`4.21.0`,"update-check":`1.5.4`,"validate-npm-package-name":`5.0.0`},zg={"@arethetypeswrong/cli":`0.18.2`,"@jest/globals":`30.2.0`,"@turbo/test-utils":`workspace:*`,"@turbo/tsconfig":`workspace:*`,"@turbo/utils":`workspace:*`,"@types/fs-extra":`9.0.13`,"@types/node":`18.17.4`,"@types/validate-npm-package-name":`4.0.0`,jest:`30.2.0`,"ts-jest":`29.4.6`,"ts-node":`10.9.2`,tsdown:`0.9.3`,typescript:`5.5.4`},Bg=[`dist`],Vg={access:`public`},Hg={name:Dg,version:Og,description:kg,type:Ag,homepage:jg,license:Mg,repository:Ng,bugs:Pg,bin:Fg,types:Ig,scripts:Lg,dependencies:Rg,devDependencies:zg,files:Bg,publishConfig:Vg};async function Ug({root:e}){let t=e||process.cwd(),n=ke(t);if(!n)vs(`Unable to infer repository root - override with --root`);else try{return(0,P.getWorkspaceDetails)({root:n})}catch{vs(`Unable to determine workspace details. Make sure "${t}" is the root, or add "packageManager" to "package.json" or ensure a lockfile is present.`)}process.exit(1)}var Wg=class e extends Error{type;constructor(t,n){super(t),this.name=`GenerateError`,this.type=n?.type??`unknown`,Error.captureStackTrace(this,e)}};const Gg=[`ts`,`js`,`cjs`],Kg=_.default.join(`turbo`,`generators`),qg=Gg.map(e=>_.default.join(Kg,`config.${e}`)),Jg=[...qg,...Gg.map(e=>_.default.join(`plopfile.${e}`))];function Yg({project:e,configPath:t}){let n=require(`tsx/cjs/api`);n.register();let r=Qg({project:e}),i;if(t){if(!h.default.existsSync(t))throw new Wg(`No config at "${t}"`,{type:`plop_no_config`});try{i=(0,F.default)(t,{destBasePath:t,force:!1})}catch(e){vs(e)}}else{for(let t of Jg){let n=_.default.join(e.paths.root,t);if(!h.default.existsSync(n))continue;try{i=(0,F.default)(n,{destBasePath:e.paths.root,force:!1});break}catch(e){vs(e)}}!i&&r.length>0&&(i=(0,F.default)(r[0].config,{destBasePath:r[0].root,force:!1}),r.shift())}return i&&r.forEach(e=>{try{i.load(e.config,{destBasePath:e.root,force:!1})}catch(e){vs(e)}}),i}function Xg({project:e,configPath:t}){let n=Yg({project:e,configPath:t});if(!n)return[];let r=n.getGeneratorList(),i=r.map(e=>n.getGenerator(e.name)),a={};i.forEach(t=>{let n=t,r=e.workspaceData.workspaces.find(t=>{if(n.basePath===e.paths.root)return!1;let r=n.basePath.split(_.default.sep);r.pop(),r.pop();let i=_.default.join(`/`,...r);return i===t.paths.root});r?(r.name in a||(a[r.name]=[]),a[r.name].push(n)):(`root`in a||(a.root=[]),a.root.push(n))});let o=[];return Object.keys(a).forEach(e=>{o.push(new I.Separator(e)),o.push(...a[e])}),o}function Zg({project:e,generator:t}){let n={cwd:process.cwd(),root:e.paths.root,workspace:t.basePath?Ee({cwd:t.basePath,target:`package.json`}):void 0},r={};try{r=Cs(t.basePath)}catch{}return{turbo:{paths:n,configs:r}}}function Qg({project:e}){let t=[];return e.workspaceData.workspaces.forEach(e=>{for(let n of qg)h.default.existsSync(_.default.join(e.paths.root,n))&&t.push({config:_.default.join(e.paths.root,n),root:e.paths.root})}),t}async function $g({project:e,generator:t,bypassArgs:n,configPath:r}){let i=Yg({project:e,configPath:r});if(!i)throw new Wg(`Unable to load generators`,{type:`plop_unable_to_load_config`});let a=i.getGenerator(t);if(!a)throw new Wg(`Generator ${t} not found`,{type:`plop_generator_not_found`});let o=await a.runPrompts(n),s=await a.runActions({...o,...Zg({project:e,generator:a})},{onComment:e=>{ms(e)}});if(s.failures.length>0)throw s.failures.forEach(e=>{e instanceof Error?vs(`Error - ${e.message}`):vs(`Error - ${e.error}. Unable to ${e.type} to "${e.path}"`)}),new Wg(`Failed to run "${t}" generator`,{type:`plop_error_running_generator`});s.changes.length>0&&(fs(`Changes made:`),s.changes.forEach(e=>{e.path&&hs(`${e.path} (${e.type})`)}))}async function e_({generators:e,generator:t}){if(t){if(e.find(e=>!(e instanceof I.Separator)&&e.name===t))return{selectedGenerator:t};_s(`Generator "${t}" not found`),gs()}let n=await(0,I.select)({message:`Select generator to run`,choices:e.map(e=>e instanceof I.Separator?e:{name:e.description?` ${e.name}: ${e.description}`:` ${e.name}`,value:e.name})});return{selectedGenerator:n}}async function t_(){let e=await(0,I.select)({message:`Should the generator config be created with TS or JS?`,default:`ts`,choices:[{name:`JavaScript`,value:`js`},{name:`TypeScript`,value:`ts`}]});return{answer:e}}async function n_({message:e}){let t=await(0,I.confirm)({message:e});return{answer:t}}async function r_({project:e,template:t}){let n=_.default.join(e.paths.root,`turbo`,`generators`),r=`simple-${t}`;if(await h.default.pathExists(n))throw new Wg(`Generator config directory already exists at ${n}`,{type:`config_directory_already_exists`});await h.default.copy(_.default.join(__dirname,`templates`,r),n,{recursive:!0})}async function i_({generator:e,project:t,opts:n}){let r=!1,i=Xg({project:t,configPath:n.config});if(!i.length){vs(`No generators found.`),gs();let{answer:e}=await n_({message:`Would you like to add a config with a sample custom generator to ${t.name}?`});if(e){r=!0;let{answer:e}=await t_();try{await r_({project:t,template:e})}catch(e){throw e instanceof Wg||vs(`Failed to create generator config`),e}if(gs(),fs(`Generator config successfully created!`),fs(`Loading generator config...`),gs(),i=Xg({project:t,configPath:n.config}),!i.length){vs(`Error loading generator`);return}}else{gs(),ms(`Learn more about custom Turborepo generators - https://turborepo.dev/docs/guides/generating-code#custom-generators`);return}}let{selectedGenerator:a}=await e_({generators:i,generator:e});try{await $g({project:t,generator:a,bypassArgs:n.args,configPath:n.config})}catch(e){if(e instanceof Wg)throw e;let t=`Failed to run generator`;throw e instanceof Error&&(t=e.message),new Wg(t,{type:`plop_error_running_generator`})}finally{r&&(gs(),fs(`Congrats! You just ran your first Turborepo generator`),ms(`Learn more about custom Turborepo generators - https://turborepo.dev/docs/guides/generating-code#custom-generators`))}gs(),ps(ss(`>>> Success!`))}function a_({project:e}){let t=e.workspaceData.workspaces,n=t.map(t=>_.default.relative(e.paths.root,t.paths.root)),r=new Set;return e.workspaceData.globs.forEach(e=>{if(!n.includes(e)&&!e.startsWith(`!`)){let t=e.split(`/`),n=t[0];r.add(n)}}),Array.from(r)}function o_({project:e,workspace:t}){return _.default.relative(e.paths.root,t.paths.root).split(_.default.sep)[0]}function s_({project:e}){let t=a_({project:e}),n=t.includes(`apps`),r=t.includes(`packages`),i={},a=[];return e.workspaceData.workspaces.forEach(t=>{let n=o_({project:e,workspace:t});n!==`apps`&&a.push(t),n in i||(i[n]=[]),i[n].push(t)}),{hasRootApps:n,hasRootPackages:r,workspacesByGroup:i,nonAppWorkspaces:a}}function c_({project:e,type:t,showAllDependencies:n}){let r=s_({project:e}),i=[],a=e.workspaceData.workspaces;n||(t===`app`&&r.hasRootApps?a=r.workspacesByGroup.apps:t===`package`&&r.nonAppWorkspaces.length>0&&(a=r.nonAppWorkspaces));let o;return a.forEach(t=>{let n=o_({project:e,workspace:t});n!==o&&i.push(new I.Separator(n)),o=n,i.push(t)}),i}async function l_({override:e,suggestion:t,workspaceType:n}){let{validForNewPackages:r}=(0,R.default)(e||``);if(e&&r)return{answer:e};let i=await(0,I.input)({message:`What is the name of the ${n}?`,default:t,validate:e=>{let{validForNewPackages:t}=(0,R.default)(e);return t||`Invalid ${n} name`}});return{answer:i}}async function u_({override:e,message:t}){if(e)return{answer:e};let n=await(0,I.select)({message:t??`What type of workspace should be added?`,choices:[{name:`app`,value:`app`},{name:`package`,value:`package`}]});return{answer:n}}async function d_({workspaceType:e,workspaceName:t,destination:n,project:r}){let i=t.includes(`/`)?t.split(`/`)[1]:t;if(n){let{valid:e,root:t}=nc(n);if(e)return{absolute:t,relative:_.default.relative(r.paths.root,t)}}let a,o=s_({project:r});e===`app`&&o.hasRootApps?a=`${r.paths.root}/apps/${i}`:e===`package`&&o.hasRootPackages&&(a=`${r.paths.root}/packages/${i}`);let s=await(0,I.input)({message:`Where should "${t}" be added?`,default:a?_.default.relative(r.paths.root,a):void 0,validate:e=>{let t=_.default.join(r.paths.root,e),{valid:n,error:i}=nc(t),a=r.workspaceData.globs.some(t=>(0,L.minimatch)(e,t));return n&&a?!0:a?i??`Invalid directory`:`${e} is not a valid workspace location`}});return{absolute:_.default.join(r.paths.root,s),relative:s}}async function f_({override:e,workspaces:t,workspaceName:n}){if(e){let n=t.find(t=>t instanceof I.Separator?!1:t.name===e);if(n)return{answer:n};_s(`Workspace "${e}" not found`),gs()}let r=await(0,I.select)({message:`Which workspace should "${n}" start from?`,loop:!1,pageSize:25,choices:t.map(e=>e instanceof I.Separator?e:{name:` ${e.name}`,value:e})});return{answer:r}}async function p_({workspaceName:e,project:t,workspaceSource:n,showAllDependencies:r}){let i={dependencies:{},devDependencies:{},peerDependencies:{},optionalDependencies:{}},{answer:a}=await m_({message:`Add workspace dependencies to "${e}"?`});if(!a)return i;let o=await(0,I.checkbox)({message:`Select all dependencies types to modify for "${e}"`,loop:!1,choices:[{name:`dependencies`,value:`dependencies`},{name:`devDependencies`,value:`devDependencies`},{name:`peerDependencies`,value:`peerDependencies`},{name:`optionalDependencies`,value:`optionalDependencies`}]}),s=c_({project:t,type:`package`,showAllDependencies:r}),c=n?h.default.readJsonSync(n.paths.packageJson):void 0;for(let n of o){let r=await(0,I.checkbox)({message:`Which packages should be added as ${n} to "${e}?`,pageSize:15,loop:!1,choices:s.map(e=>e instanceof I.Separator?e:{name:` ${e.name}`,value:e.name})}),a=c?.[n]||{};if(Object.keys(a).length){let e=new Set(Object.keys(a));r.forEach(n=>{e.has(n)||(a[n]=t.packageManager===`pnpm`?`workspace:*`:`*`)}),i[n]=a}else i[n]=r.reduce((e,n)=>({...e,[n]:t.packageManager===`pnpm`?`workspace:*`:`*`}),{})}return i}async function m_({message:e}){let t=await(0,I.confirm)({message:e});return{answer:t}}async function h_({project:e,opts:t}){let n,r=t.method===`copy`&&t.copy.type===`external`?t.examplePath?.split(`/`).pop()||t.copy.source.split(`/`).pop():void 0,{answer:i}=await u_({override:t.type,message:t.method===`copy`&&t.copy.source===`external`&&r?`What type of workspace should "${r}" be created as?`:void 0}),{answer:a}=await l_({override:t.name,workspaceType:i,suggestion:r});if(t.method===`copy`&&t.copy.type===`internal`){let{answer:r}=await f_({override:t.copy.source,workspaces:c_({project:e,type:i}),workspaceName:a});n=r}let o=await d_({workspaceType:i,workspaceName:a,project:e,destination:t.destination}),s=await p_({workspaceName:a,project:e,workspaceSource:n,showAllDependencies:t.showAllDependencies});return{type:i,name:a,location:o,source:n,dependencies:s}}async function g_({project:e,opts:t}){let{name:n,location:r,dependencies:i}=await h_({project:e,opts:t}),a={name:n,version:`0.0.0`,private:!0,scripts:{dev:`echo 'Add dev script here'`,build:`echo 'Add build script here'`,test:`echo 'Add test script here'`,lint:`echo 'Add lint script here'`}};Object.keys(i).forEach(e=>{let t=i[e];t&&Object.keys(t).length>0&&(a[e]=t)}),h.default.mkdirSync(r.absolute,{recursive:!0}),h.default.writeFileSync(_.default.join(r.absolute,`package.json`),JSON.stringify(a,null,2)),h.default.writeFileSync(_.default.join(r.absolute,`README.md`),`# \`${n}\``),gs(),gs(`${d.default.bold(ss(`>>> Success!`))} Created ${n} at "${r.relative}"`)}async function __({project:e,opts:t}){let{name:n,type:r,location:i,source:a,dependencies:o}=await h_({project:e,opts:t}),s=_.default.join(i.absolute,`package.json`);if(t.copy.type===`external`){gs(),_s(`Some manual modifications may be required.`),ms(`This ${r} may require local dependencies or a different package manager than what is available in this repo`),await wg({appPath:i.absolute,example:t.copy.source,examplePath:t.examplePath});try{if(h.default.existsSync(s)){let e=await h.default.readJSON(s);if(e.workspaces)throw Error(`New workspace root detected - unexpected 'workspaces' field in package.json`)}else throw Error(`New workspace is missing a package.json file`);if(h.default.existsSync(_.default.join(i.absolute,`pnpm-workspace.yaml`)))throw Error(`New workspace root detected - unexpected pnpm-workspace.yaml`)}catch(e){let t=`UNKNOWN_ERROR`;e instanceof Error&&(t=e.message),vs(t),await h.default.rm(i.absolute,{recursive:!0,force:!0});return}}else if(a){let e=async e=>Promise.resolve(!e.includes(`node_modules`)),t=ds(`Creating "${n}" from "${a.name}"...`);t.start(),await h.default.copy(a.paths.root,i.absolute,{filter:e}),t.stop()}let c=await h.default.readJSON(s);c.name=n,Object.keys(o).forEach(e=>{let t=o[e];t&&Object.keys(t).length>0&&(c[e]=t)}),await h.default.writeJSON(s,c,{spaces:2}),gs(),gs(`${d.default.bold(ss(`>>> Success!`))} Created ${n} at "${i.relative}"`)}function v_(e){let{copy:t,...n}=e,r=t===!0||typeof t==`string`?`copy`:`empty`,i=typeof t==`string`?t:``,a=typeof t==`string`&&t.startsWith(`https://`)?`external`:`internal`;return{method:r,copy:{type:a,source:i},...n}}async function y_(e){let t=await Ug(e),n=v_(e);gs();let r={project:t,opts:n};n.method===`copy`?(n.copy.type===`external`?fs(`Copy a remote workspace from ${n.copy.source}`):fs(`Copy an existing workspace from "${t.name}"`),gs(),await __(r)):(fs(`Add an empty workspace to "${t.name}"`),gs(),await g_(r))}async function b_(e,t){let n=await Ug(t);gs(),fs(`Modify "${n.name}" using custom generators`),gs(),await i_({generator:e,project:n,opts:t})}function x_(e){try{let t=JSON.parse(e),n={};for(let e in t){let r=Tg(e,{to:`camel`});n[r]=t[e]}return n}catch(e){vs(`Error parsing arguments`,e),process.exit(1)}}async function S_(e,t){if(e===`workspace`){let e=x_(t.json);e.showAllDependencies=e.showAllDependencies??!1;let n=!1,r=e.empty||!0;e.copy===``||e.copy===!0?(n=!0,r=!1):e.copy&&e.copy.length>0&&(n=e.copy,r=!1),e.copy=n,e.empty=r,await y_(e)}else if(e===`run`){let e=x_(t.json),{generatorName:n,...r}=e;await b_(n,r)}else vs(`Received unknown command - "${e}" (must be one of "workspace" | "run")`),process.exit(1)}const C_=Eg({packageInfo:Hg}),w_=new N.ProxyAgent;l.default.globalAgent=w_,u.default.globalAgent=w_;const T_=new f.Command;T_.name(d.default.bold(ss(`@turbo/gen`))).description(`Extend your Turborepo`).version(Hg.version,`-v, --version`,`Output the current version`).helpOption(`-h, --help`,`Display help for command`).showHelpAfterError(!1),T_.command(`run`,{isDefault:!0}).alias(`r`).description(`Run custom generators`).addArgument(new f.Argument(`[generator-name]`,`The name of the generator to run`)).addOption(new f.Option(`-c, --config <config>`,`Generator configuration file (default: turbo/generators/config.js`)).addOption(new f.Option(`-r, --root <dir>`,`The root of your repository (default: directory with root turbo.json)`)).addOption(new f.Option(`-a, --args <args...>`,`Arguments passed directly to generator`).default([])).action(b_),T_.command(`workspace`).aliases([`w`]).description(`Add a new package or app to your project`).addOption(new f.Option(`-n, --name <workspace-name>`,`Name for the new workspace`)).addOption(new f.Option(`-b, --empty`,`Generate an empty workspace`).conflicts(`copy`).default(!0)).addOption(new f.Option(`-c, --copy [source]`,`Generate a workspace using an existing workspace as a template. Can be the name of a local workspace
80
+ For faster downloads, install git: https://git-scm.com/downloads`),await dg({url:`https://codeload.github.com/vercel/turborepo/tar.gz/main`,root:n,strip:3,filter:(e,n)=>e.startsWith(`${n}/examples/${t}/`)});return}(0,g.rmSync)(r,{recursive:!0,force:!0})}async function hg(e){try{return await h.default.access(e,h.default.constants.W_OK),!0}catch{return!1}}var gg=o((exports,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}}),_g=o(exports=>{var t=gg();exports.operation=function(n){var r=exports.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},exports.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},exports.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},exports.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=exports.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}}),vg=o((exports,t)=>{t.exports=_g()}),yg=o((exports,t)=>{var n=vg();function r(e,t){function r(r,i){var a=t||{},o;`randomize`in a||(a.randomize=!0),o=n.operation(a);function s(e){i(e||Error(`Aborted`))}function c(e,t){if(e.bail){s(e);return}o.retry(e)?a.onRetry&&a.onRetry(e,t):i(o.mainError())}function l(t){var n;try{n=e(s,t)}catch(e){c(e,t);return}Promise.resolve(n).then(r).catch(function(e){c(e,t)})}o.attempt(l)}return new Promise(r)}t.exports=r}),bg=c(yg());function xg(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}var Sg=class extends Error{};function Cg(e){return e.hostname===`github.com`}async function wg({appPath:e,example:t,isDefaultExample:n,examplePath:r}){let i,a;gs();let o=ds(`Downloading files...`);o.start();try{if(!n){try{a=new URL(t)}catch(e){let t=e;t.code!==`ERR_INVALID_URL`&&(o.stop(),vs(e),process.exit(1))}if(a){Cg(a)||(o.stop(),vs(`Invalid URL: ${d.default.red(`"${t}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`),process.exit(1)),i=await og(a,r),i||(o.stop(),vs(`Unable to fetch repository information from: ${d.default.red(`"${t}"`)}. Please fix the URL and try again.`),process.exit(1));let e=await sg(i);e||(o.stop(),vs(`Could not locate the repository for ${d.default.red(`"${t}"`)}. Please check that the repository exists and try again.`),process.exit(1))}else{let e=await cg(t);e||(o.stop(),vs(`Could not locate an example named ${d.default.red(`"${t}"`)}. It could be due to the following:\n`,`1. Your spelling of example ${d.default.red(`"${t}"`)} might be incorrect.\n`,`2. You might not be connected to the internet or you are behind a proxy.`),process.exit(1)),i={username:`vercel`,name:`turborepo`,branch:`main`,filePath:`examples/${t}`}}}let s=_.default.resolve(e);await hg(_.default.dirname(s))||(o.stop(),vs(`The application path is not writable, please check folder permissions and try again.`),vs(`It is likely you do not have write permissions for this folder.`),process.exit(1));let c=_.default.basename(s);try{await h.default.mkdir(s,{recursive:!0})}catch(e){o.stop(),vs(`Unable to create project directory`),vs(e),process.exit(1)}let{isEmpty:l,conflicts:u}=tc(s);l||(o.stop(),vs(`${d.default.dim(s)} has ${u.length} conflicting ${u.length===1?`file`:`files`} - please try a different location`),process.exit(1));let f=process.cwd();process.chdir(s),n||i?await(0,bg.default)(()=>fg(s,i??{username:`vercel`,name:`turborepo`,branch:`main`,filePath:`examples/basic`}),{retries:3}):await(0,bg.default)(()=>mg(s,t),{retries:3}),o.stop();let p=_.default.join(s,`package.json`),m=h.default.existsSync(p),g=[];if(m){let e;try{e=h.default.readJsonSync(p)}catch{}e&&g.push(...Object.keys(e.scripts||{}))}let v=e;return _.default.join(f,c)===e&&(v=c),{cdPath:v,hasPackageJson:m,availableScripts:g,repoInfo:i}}catch(e){throw o.stop(),new Sg(xg(e)?e.message:String(e))}}function Tg(e,t={to:`camel`}){switch(t.to){case`camel`:return e.replace(/(?:[-_][a-z])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``));default:throw Error(`Not implemented`)}}function Eg(e){let{packageInfo:t,upgradeCommand:n}=e,r=(0,M.default)(t).catch(()=>null);return async function(e=0){try{let i=await r;if(i?.latest){gs(),gs(d.default.yellow(d.default.bold(`A new version of \`${t.name}\` is available!`)));let e=typeof n==`function`?await n():n;e&&gs(`You can update by running: ${d.default.cyan(e)}`),gs()}process.exit(e)}catch(t){process.env.DEBUG&&vs(`Update check failed:`,t),process.exit(e)}}}var Dg=`@turbo/gen`,Og=`2.8.6`,kg=`Extend a Turborepo`,Ag=`commonjs`,jg=`https://turborepo.dev`,Mg=`MIT`,Ng={type:`git`,url:`git+https://github.com/vercel/turborepo.git`,directory:`packages/turbo-gen`},Pg={url:`https://github.com/vercel/turborepo/issues`},Fg=`dist/cli.js`,Ig=`dist/types.d.ts`,Lg={build:`tsdown`,test:`jest`,"check-types":`tsc --noEmit`,"package:types":`attw --profile node16 --pack`},Rg={"@turbo/workspaces":`workspace:*`,commander:`10.0.0`,"fs-extra":`10.1.0`,"@inquirer/prompts":`^7.10.1`,minimatch:`9.0.0`,"node-plop":`0.26.3`,picocolors:`1.0.1`,"proxy-agent":`6.5.0`,tsx:`4.21.0`,"update-check":`1.5.4`,"validate-npm-package-name":`5.0.0`},zg={"@arethetypeswrong/cli":`0.18.2`,"@jest/globals":`30.2.0`,"@turbo/test-utils":`workspace:*`,"@turbo/tsconfig":`workspace:*`,"@turbo/utils":`workspace:*`,"@types/fs-extra":`9.0.13`,"@types/node":`18.17.4`,"@types/validate-npm-package-name":`4.0.0`,jest:`30.2.0`,"ts-jest":`29.4.6`,"ts-node":`10.9.2`,tsdown:`0.9.3`,typescript:`5.5.4`},Bg=[`dist`],Vg={access:`public`},Hg={name:Dg,version:Og,description:kg,type:Ag,homepage:jg,license:Mg,repository:Ng,bugs:Pg,bin:Fg,types:Ig,scripts:Lg,dependencies:Rg,devDependencies:zg,files:Bg,publishConfig:Vg};async function Ug({root:e}){let t=e||process.cwd(),n=ke(t);if(!n)vs(`Unable to infer repository root - override with --root`);else try{return(0,P.getWorkspaceDetails)({root:n})}catch{vs(`Unable to determine workspace details. Make sure "${t}" is the root, or add "packageManager" to "package.json" or ensure a lockfile is present.`)}process.exit(1)}var Wg=class e extends Error{type;constructor(t,n){super(t),this.name=`GenerateError`,this.type=n?.type??`unknown`,Error.captureStackTrace(this,e)}};const Gg=[`ts`,`js`,`cjs`],Kg=_.default.join(`turbo`,`generators`),qg=Gg.map(e=>_.default.join(Kg,`config.${e}`)),Jg=[...qg,...Gg.map(e=>_.default.join(`plopfile.${e}`))];function Yg({project:e,configPath:t}){let n=require(`tsx/cjs/api`);n.register();let r=Qg({project:e}),i;if(t){if(!h.default.existsSync(t))throw new Wg(`No config at "${t}"`,{type:`plop_no_config`});try{i=(0,F.default)(t,{destBasePath:t,force:!1})}catch(e){vs(e)}}else{for(let t of Jg){let n=_.default.join(e.paths.root,t);if(!h.default.existsSync(n))continue;try{i=(0,F.default)(n,{destBasePath:e.paths.root,force:!1});break}catch(e){vs(e)}}!i&&r.length>0&&(i=(0,F.default)(r[0].config,{destBasePath:r[0].root,force:!1}),r.shift())}return i&&r.forEach(e=>{try{i.load(e.config,{destBasePath:e.root,force:!1})}catch(e){vs(e)}}),i}function Xg({project:e,configPath:t}){let n=Yg({project:e,configPath:t});if(!n)return[];let r=n.getGeneratorList(),i=r.map(e=>n.getGenerator(e.name)),a={};i.forEach(t=>{let n=t,r=e.workspaceData.workspaces.find(t=>{if(n.basePath===e.paths.root)return!1;let r=n.basePath.split(_.default.sep);r.pop(),r.pop();let i=_.default.join(`/`,...r);return i===t.paths.root});r?(r.name in a||(a[r.name]=[]),a[r.name].push(n)):(`root`in a||(a.root=[]),a.root.push(n))});let o=[];return Object.keys(a).forEach(e=>{o.push(new I.Separator(e)),o.push(...a[e])}),o}function Zg({project:e,generator:t}){let n={cwd:process.cwd(),root:e.paths.root,workspace:t.basePath?Ee({cwd:t.basePath,target:`package.json`}):void 0},r={};try{r=Cs(t.basePath)}catch{}return{turbo:{paths:n,configs:r}}}function Qg({project:e}){let t=[];return e.workspaceData.workspaces.forEach(e=>{for(let n of qg)h.default.existsSync(_.default.join(e.paths.root,n))&&t.push({config:_.default.join(e.paths.root,n),root:e.paths.root})}),t}async function $g({project:e,generator:t,bypassArgs:n,configPath:r}){let i=Yg({project:e,configPath:r});if(!i)throw new Wg(`Unable to load generators`,{type:`plop_unable_to_load_config`});let a=i.getGenerator(t);if(!a)throw new Wg(`Generator ${t} not found`,{type:`plop_generator_not_found`});let o=await a.runPrompts(n),s=await a.runActions({...o,...Zg({project:e,generator:a})},{onComment:e=>{ms(e)}});if(s.failures.length>0)throw s.failures.forEach(e=>{e instanceof Error?vs(`Error - ${e.message}`):vs(`Error - ${e.error}. Unable to ${e.type} to "${e.path}"`)}),new Wg(`Failed to run "${t}" generator`,{type:`plop_error_running_generator`});s.changes.length>0&&(fs(`Changes made:`),s.changes.forEach(e=>{e.path&&hs(`${e.path} (${e.type})`)}))}async function e_({generators:e,generator:t}){if(t){if(e.find(e=>!(e instanceof I.Separator)&&e.name===t))return{selectedGenerator:t};_s(`Generator "${t}" not found`),gs()}let n=await(0,I.select)({message:`Select generator to run`,choices:e.map(e=>e instanceof I.Separator?e:{name:e.description?` ${e.name}: ${e.description}`:` ${e.name}`,value:e.name})});return{selectedGenerator:n}}async function t_(){let e=await(0,I.select)({message:`Should the generator config be created with TS or JS?`,default:`ts`,choices:[{name:`JavaScript`,value:`js`},{name:`TypeScript`,value:`ts`}]});return{answer:e}}async function n_({message:e}){let t=await(0,I.confirm)({message:e});return{answer:t}}async function r_({project:e,template:t}){let n=_.default.join(e.paths.root,`turbo`,`generators`),r=`simple-${t}`;if(await h.default.pathExists(n))throw new Wg(`Generator config directory already exists at ${n}`,{type:`config_directory_already_exists`});await h.default.copy(_.default.join(__dirname,`templates`,r),n,{recursive:!0})}async function i_({generator:e,project:t,opts:n}){let r=!1,i=Xg({project:t,configPath:n.config});if(!i.length){vs(`No generators found.`),gs();let{answer:e}=await n_({message:`Would you like to add a config with a sample custom generator to ${t.name}?`});if(e){r=!0;let{answer:e}=await t_();try{await r_({project:t,template:e})}catch(e){throw e instanceof Wg||vs(`Failed to create generator config`),e}if(gs(),fs(`Generator config successfully created!`),fs(`Loading generator config...`),gs(),i=Xg({project:t,configPath:n.config}),!i.length){vs(`Error loading generator`);return}}else{gs(),ms(`Learn more about custom Turborepo generators - https://turborepo.dev/docs/guides/generating-code#custom-generators`);return}}let{selectedGenerator:a}=await e_({generators:i,generator:e});try{await $g({project:t,generator:a,bypassArgs:n.args,configPath:n.config})}catch(e){if(e instanceof Wg)throw e;let t=`Failed to run generator`;throw e instanceof Error&&(t=e.message),new Wg(t,{type:`plop_error_running_generator`})}finally{r&&(gs(),fs(`Congrats! You just ran your first Turborepo generator`),ms(`Learn more about custom Turborepo generators - https://turborepo.dev/docs/guides/generating-code#custom-generators`))}gs(),ps(ss(`>>> Success!`))}function a_({project:e}){let t=e.workspaceData.workspaces,n=t.map(t=>_.default.relative(e.paths.root,t.paths.root)),r=new Set;return e.workspaceData.globs.forEach(e=>{if(!n.includes(e)&&!e.startsWith(`!`)){let t=e.split(`/`),n=t[0];r.add(n)}}),Array.from(r)}function o_({project:e,workspace:t}){return _.default.relative(e.paths.root,t.paths.root).split(_.default.sep)[0]}function s_({project:e}){let t=a_({project:e}),n=t.includes(`apps`),r=t.includes(`packages`),i={},a=[];return e.workspaceData.workspaces.forEach(t=>{let n=o_({project:e,workspace:t});n!==`apps`&&a.push(t),n in i||(i[n]=[]),i[n].push(t)}),{hasRootApps:n,hasRootPackages:r,workspacesByGroup:i,nonAppWorkspaces:a}}function c_({project:e,type:t,showAllDependencies:n}){let r=s_({project:e}),i=[],a=e.workspaceData.workspaces;n||(t===`app`&&r.hasRootApps?a=r.workspacesByGroup.apps:t===`package`&&r.nonAppWorkspaces.length>0&&(a=r.nonAppWorkspaces));let o;return a.forEach(t=>{let n=o_({project:e,workspace:t});n!==o&&i.push(new I.Separator(n)),o=n,i.push(t)}),i}async function l_({override:e,suggestion:t,workspaceType:n}){let{validForNewPackages:r}=(0,R.default)(e||``);if(e&&r)return{answer:e};let i=await(0,I.input)({message:`What is the name of the ${n}?`,default:t,validate:e=>{let{validForNewPackages:t}=(0,R.default)(e);return t||`Invalid ${n} name`}});return{answer:i}}async function u_({override:e,message:t}){if(e)return{answer:e};let n=await(0,I.select)({message:t??`What type of workspace should be added?`,choices:[{name:`app`,value:`app`},{name:`package`,value:`package`}]});return{answer:n}}async function d_({workspaceType:e,workspaceName:t,destination:n,project:r}){let i=t.includes(`/`)?t.split(`/`)[1]:t;if(n){let{valid:e,root:t}=nc(n);if(e)return{absolute:t,relative:_.default.relative(r.paths.root,t)}}let a,o=s_({project:r});e===`app`&&o.hasRootApps?a=`${r.paths.root}/apps/${i}`:e===`package`&&o.hasRootPackages&&(a=`${r.paths.root}/packages/${i}`);let s=await(0,I.input)({message:`Where should "${t}" be added?`,default:a?_.default.relative(r.paths.root,a):void 0,validate:e=>{let t=_.default.join(r.paths.root,e),{valid:n,error:i}=nc(t),a=r.workspaceData.globs.some(t=>(0,L.minimatch)(e,t));return n&&a?!0:a?i??`Invalid directory`:`${e} is not a valid workspace location`}});return{absolute:_.default.join(r.paths.root,s),relative:s}}async function f_({override:e,workspaces:t,workspaceName:n}){if(e){let n=t.find(t=>t instanceof I.Separator?!1:t.name===e);if(n)return{answer:n};_s(`Workspace "${e}" not found`),gs()}let r=await(0,I.select)({message:`Which workspace should "${n}" start from?`,loop:!1,pageSize:25,choices:t.map(e=>e instanceof I.Separator?e:{name:` ${e.name}`,value:e})});return{answer:r}}async function p_({workspaceName:e,project:t,workspaceSource:n,showAllDependencies:r}){let i={dependencies:{},devDependencies:{},peerDependencies:{},optionalDependencies:{}},{answer:a}=await m_({message:`Add workspace dependencies to "${e}"?`});if(!a)return i;let o=await(0,I.checkbox)({message:`Select all dependencies types to modify for "${e}"`,loop:!1,choices:[{name:`dependencies`,value:`dependencies`},{name:`devDependencies`,value:`devDependencies`},{name:`peerDependencies`,value:`peerDependencies`},{name:`optionalDependencies`,value:`optionalDependencies`}]}),s=c_({project:t,type:`package`,showAllDependencies:r}),c=n?h.default.readJsonSync(n.paths.packageJson):void 0;for(let n of o){let r=await(0,I.checkbox)({message:`Which packages should be added as ${n} to "${e}?`,pageSize:15,loop:!1,choices:s.map(e=>e instanceof I.Separator?e:{name:` ${e.name}`,value:e.name})}),a=c?.[n]||{};if(Object.keys(a).length){let e=new Set(Object.keys(a));r.forEach(n=>{e.has(n)||(a[n]=t.packageManager===`pnpm`?`workspace:*`:`*`)}),i[n]=a}else i[n]=r.reduce((e,n)=>({...e,[n]:t.packageManager===`pnpm`?`workspace:*`:`*`}),{})}return i}async function m_({message:e}){let t=await(0,I.confirm)({message:e});return{answer:t}}async function h_({project:e,opts:t}){let n,r=t.method===`copy`&&t.copy.type===`external`?t.examplePath?.split(`/`).pop()||t.copy.source.split(`/`).pop():void 0,{answer:i}=await u_({override:t.type,message:t.method===`copy`&&t.copy.source===`external`&&r?`What type of workspace should "${r}" be created as?`:void 0}),{answer:a}=await l_({override:t.name,workspaceType:i,suggestion:r});if(t.method===`copy`&&t.copy.type===`internal`){let{answer:r}=await f_({override:t.copy.source,workspaces:c_({project:e,type:i}),workspaceName:a});n=r}let o=await d_({workspaceType:i,workspaceName:a,project:e,destination:t.destination}),s=await p_({workspaceName:a,project:e,workspaceSource:n,showAllDependencies:t.showAllDependencies});return{type:i,name:a,location:o,source:n,dependencies:s}}async function g_({project:e,opts:t}){let{name:n,location:r,dependencies:i}=await h_({project:e,opts:t}),a={name:n,version:`0.0.0`,private:!0,scripts:{dev:`echo 'Add dev script here'`,build:`echo 'Add build script here'`,test:`echo 'Add test script here'`,lint:`echo 'Add lint script here'`}};Object.keys(i).forEach(e=>{let t=i[e];t&&Object.keys(t).length>0&&(a[e]=t)}),h.default.mkdirSync(r.absolute,{recursive:!0}),h.default.writeFileSync(_.default.join(r.absolute,`package.json`),JSON.stringify(a,null,2)),h.default.writeFileSync(_.default.join(r.absolute,`README.md`),`# \`${n}\``),gs(),gs(`${d.default.bold(ss(`>>> Success!`))} Created ${n} at "${r.relative}"`)}async function __({project:e,opts:t}){let{name:n,type:r,location:i,source:a,dependencies:o}=await h_({project:e,opts:t}),s=_.default.join(i.absolute,`package.json`);if(t.copy.type===`external`){gs(),_s(`Some manual modifications may be required.`),ms(`This ${r} may require local dependencies or a different package manager than what is available in this repo`),await wg({appPath:i.absolute,example:t.copy.source,examplePath:t.examplePath});try{if(h.default.existsSync(s)){let e=await h.default.readJSON(s);if(e.workspaces)throw Error(`New workspace root detected - unexpected 'workspaces' field in package.json`)}else throw Error(`New workspace is missing a package.json file`);if(h.default.existsSync(_.default.join(i.absolute,`pnpm-workspace.yaml`)))throw Error(`New workspace root detected - unexpected pnpm-workspace.yaml`)}catch(e){let t=`UNKNOWN_ERROR`;e instanceof Error&&(t=e.message),vs(t),await h.default.rm(i.absolute,{recursive:!0,force:!0});return}}else if(a){let e=async e=>Promise.resolve(!e.includes(`node_modules`)),t=ds(`Creating "${n}" from "${a.name}"...`);t.start(),await h.default.copy(a.paths.root,i.absolute,{filter:e}),t.stop()}let c=await h.default.readJSON(s);c.name=n,Object.keys(o).forEach(e=>{let t=o[e];t&&Object.keys(t).length>0&&(c[e]=t)}),await h.default.writeJSON(s,c,{spaces:2}),gs(),gs(`${d.default.bold(ss(`>>> Success!`))} Created ${n} at "${i.relative}"`)}function v_(e){let{copy:t,...n}=e,r=t===!0||typeof t==`string`?`copy`:`empty`,i=typeof t==`string`?t:``,a=typeof t==`string`&&t.startsWith(`https://`)?`external`:`internal`;return{method:r,copy:{type:a,source:i},...n}}async function y_(e){let t=await Ug(e),n=v_(e);gs();let r={project:t,opts:n};n.method===`copy`?(n.copy.type===`external`?fs(`Copy a remote workspace from ${n.copy.source}`):fs(`Copy an existing workspace from "${t.name}"`),gs(),await __(r)):(fs(`Add an empty workspace to "${t.name}"`),gs(),await g_(r))}async function b_(e,t){let n=await Ug(t);gs(),fs(`Modify "${n.name}" using custom generators`),gs(),await i_({generator:e,project:n,opts:t})}function x_(e){try{let t=JSON.parse(e),n={};for(let e in t){let r=Tg(e,{to:`camel`});n[r]=t[e]}return n}catch(e){vs(`Error parsing arguments`,e),process.exit(1)}}async function S_(e,t){if(e===`workspace`){let e=x_(t.json);e.showAllDependencies=e.showAllDependencies??!1;let n=!1,r=e.empty||!0;e.copy===``||e.copy===!0?(n=!0,r=!1):e.copy&&e.copy.length>0&&(n=e.copy,r=!1),e.copy=n,e.empty=r,await y_(e)}else if(e===`run`){let e=x_(t.json),{generatorName:n,...r}=e;await b_(n,r)}else vs(`Received unknown command - "${e}" (must be one of "workspace" | "run")`),process.exit(1)}const C_=Eg({packageInfo:Hg}),w_=new N.ProxyAgent;l.default.globalAgent=w_,u.default.globalAgent=w_;const T_=new f.Command;T_.name(d.default.bold(ss(`@turbo/gen`))).description(`Extend your Turborepo`).version(Hg.version,`-v, --version`,`Output the current version`).helpOption(`-h, --help`,`Display help for command`).showHelpAfterError(!1),T_.command(`run`,{isDefault:!0}).alias(`r`).description(`Run custom generators`).addArgument(new f.Argument(`[generator-name]`,`The name of the generator to run`)).addOption(new f.Option(`-c, --config <config>`,`Generator configuration file (default: turbo/generators/config.js`)).addOption(new f.Option(`-r, --root <dir>`,`The root of your repository (default: directory with root turbo.json)`)).addOption(new f.Option(`-a, --args <args...>`,`Arguments passed directly to generator`).default([])).action(b_),T_.command(`workspace`).aliases([`w`]).description(`Add a new package or app to your project`).addOption(new f.Option(`-n, --name <workspace-name>`,`Name for the new workspace`)).addOption(new f.Option(`-b, --empty`,`Generate an empty workspace`).conflicts(`copy`).default(!0)).addOption(new f.Option(`-c, --copy [source]`,`Generate a workspace using an existing workspace as a template. Can be the name of a local workspace
81
81
  within your monorepo, or a fully qualified GitHub URL with any branch and/or subdirectory.
82
82
  `).conflicts(`empty`)).addOption(new f.Option(`-d, --destination <dir>`,`Where the new workspace should be created`)).addOption(new f.Option(`-t, --type <type>`,`The type of workspace to create`).choices([`app`,`package`])).addOption(new f.Option(`-r, --root <dir>`,`The root of your repository (default: directory with root turbo.json)`)).addOption(new f.Option(`-p, --example-path <path-to-example>`,`In a rare case, your GitHub URL might contain a branch name with
83
83
  a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turbo/gen",
3
- "version": "2.8.5",
3
+ "version": "2.8.6",
4
4
  "description": "Extend a Turborepo",
5
5
  "type": "commonjs",
6
6
  "homepage": "https://turborepo.dev",
@@ -26,7 +26,7 @@
26
26
  "tsx": "4.21.0",
27
27
  "update-check": "1.5.4",
28
28
  "validate-npm-package-name": "5.0.0",
29
- "@turbo/workspaces": "2.8.5"
29
+ "@turbo/workspaces": "2.8.6"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@arethetypeswrong/cli": "0.18.2",