@gjsify/cli 0.16.4 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.gjs.mjs +3 -3
- package/lib/commands/run.d.ts +1 -0
- package/lib/commands/run.js +56 -5
- package/package.json +17 -17
package/dist/cli.gjs.mjs
CHANGED
|
@@ -3,7 +3,7 @@ if(globalThis.__gjsifyBundleUrl??=import.meta.url,Symbol.dispose||(Symbol.dispos
|
|
|
3
3
|
`)}else if(we){let S=` `.repeat(this._groupDepth*this._groupIndentation)+_formatArgs(...a);n===`stderr`?printerr(S):print(S)}else{let S=globalThis.console;n===`stderr`?S.error(...a):S.log(...a)}}log(...n){this._write(`stdout`,...n)}info(...n){this._write(`stdout`,...n)}debug(...n){this._write(`stdout`,...n)}warn(...n){this._write(`stderr`,...n)}error(...n){this._write(`stderr`,...n)}dir(n,a){this._write(`stdout`,n)}dirxml(...n){this.log(...n)}assert(n,...a){n||this.error(`Assertion failed:`,...a)}clear(){this._stdout?this._stdout.write(`\x1Bc`):we?print(`\x1Bc`):globalThis.console.clear()}count(n=`default`){let a=(this._counters.get(n)||0)+1;this._counters.set(n,a),this.log(`${n}: ${a}`)}countReset(n=`default`){this._counters.delete(n)}group(...n){n.length>0&&this.log(...n),this._groupDepth++}groupCollapsed(...n){this.group(...n)}groupEnd(){this._groupDepth>0&&this._groupDepth--}table(n,a){this._stdout?this._write(`stdout`,n):we?print(JSON.stringify(n,null,2)):globalThis.console.table(n,a)}time(n=`default`){this._timers.set(n,Date.now())}timeEnd(n=`default`){let a=this._timers.get(n);a===void 0?this.warn(`Warning: No such label '${n}' for console.timeEnd()`):(this.log(`${n}: ${Date.now()-a}ms`),this._timers.delete(n))}timeLog(n=`default`,...a){let S=this._timers.get(n);S===void 0?this.warn(`Warning: No such label '${n}' for console.timeLog()`):this.log(`${n}: ${Date.now()-S}ms`,...a)}trace(...n){let a=Error().stack?.split(`
|
|
4
4
|
`).slice(1).join(`
|
|
5
5
|
`)||``;this._write(`stderr`,`Trace:`,...n,`
|
|
6
|
-
`+a)}profile(n){}profileEnd(n){}timeStamp(n){}},Te=new Console,log=(...n)=>Te.log(...n),info=(...n)=>Te.info(...n),Ee=__name$1((...n)=>Te.debug(...n),`debug`),warn=(...n)=>Te.warn(...n),error=(...n)=>Te.error(...n),dir=(n,a)=>Te.dir(n,a),dirxml=(...n)=>Te.dirxml(...n),table=(n,a)=>Te.table(n,a),clear=()=>Te.clear(),assert=(n,...a)=>Te.assert(n,...a),trace=(...n)=>Te.trace(...n),time=n=>Te.time(n),timeEnd=n=>Te.timeEnd(n),timeLog=(n,...a)=>Te.timeLog(n,...a),De=__name$1(n=>Te.count(n),`count`),countReset=n=>Te.countReset(n),group=(...n)=>Te.group(...n),groupCollapsed=(...n)=>Te.groupCollapsed(...n),groupEnd=()=>Te.groupEnd(),profile=n=>{},profileEnd=n=>{},timeStamp=n=>{}}),ke,Ae=__esmMin(()=>{Oe(),ke={log,info,debug:Ee,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count:De,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),je=__esmMin(()=>{Ae()}),Me,Fe=__esmMin(()=>{Me=__name$1(n=>{Promise.resolve().then(n)},`queueMicrotask`)});function drainOnce(n){let a=Math.min(64,Ie.length);for(let S=0;S<a;S++){let a=Ie.shift();try{a()}catch(a){try{n.log_default_handler(`gjsify-nextTick`,n.LogLevelFlags.LEVEL_WARNING,String(a?.stack||a),null)}catch{}}}Ie.length>0?n.timeout_add(n.PRIORITY_DEFAULT,1,()=>(drainOnce(n),!1)):Le=!1}function tryGLibTimeout(n){let a=globalThis.imports?.gi?.GLib;return a?.timeout_add?(Ie.push(n),Le||(Le=!0,a.timeout_add(a.PRIORITY_DEFAULT,0,()=>(drainOnce(a),!1))),!0):!1}var Ie,Le,nextTick,Re=__esmMin(()=>{Ie=[],Le=!1,nextTick=(n,...a)=>{let S=a.length>0?()=>n(...a):n;if(!tryGLibTimeout(S)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(n,...a);return}if(typeof queueMicrotask==`function`){queueMicrotask(S);return}Promise.resolve().then(S)}}}),ze,Be,getPathSeparator,Ve=__esmMin(()=>{se(),he(),{File:ze}=me,Be=__name$1((n,...a)=>{let S=ze.new_for_path(n);for(let n of a)S=S.resolve_relative_path(n);return S},`resolve`),getPathSeparator=()=>Z.get_current_dir().startsWith(`/`)?`/`:`\\`});function classOf(n){return He.call(n).slice(8,-1)}function throwDataCloneError(n){let a=globalThis.DOMException;if(typeof a==`function`)throw new a(n,`DataCloneError`);let S=Error(n);throw S.name=`DataCloneError`,S}function internalClone(n,a,S){if(n==null)return n;let C=typeof n;if(C===`boolean`||C===`number`||C===`string`||C===`bigint`)return n;C===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),C===`function`&&throwDataCloneError(`Function cannot be cloned`);let N=n;if(a.has(N))return a.get(N);let F=classOf(N);if(F===`Date`)return new Date(N.getTime());if(F===`RegExp`)return new RegExp(N.source,N.flags);if(F===`Boolean`||F===`Number`||F===`String`)return Object(N.valueOf());if(F===`BigInt`)return Object(BigInt.prototype.valueOf.call(N));if(N instanceof Error){let n=N,C=n.constructor?.name,F=new(C&&Ue[C]||Ue[n.name]||Error)(n.message);return F.name=n.name,`cause`in n&&Object.defineProperty(F,"cause",{value:internalClone(n.cause,a,S),writable:!0,enumerable:!1,configurable:!0}),F}if(F===`DOMException`){let n=globalThis.DOMException;if(typeof n==`function`){let a=N;return new n(a.message,a.name)}}if(F===`ArrayBuffer`){let n=N;if(S&&S.transferred.has(n)){let C=S.transferred.get(n);return a.set(N,C),C}(n.detached===!0||n.byteLength===0&&n.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let C=n.slice(0);return a.set(N,C),C}if(F===`SharedArrayBuffer`||N&&typeof N==`object`&&N.constructor?.name===`SharedBuffer`)return N;if(F===`DataView`){let n=N,C=S?.viewSnapshots.get(N),F=internalClone(n.buffer,a,S),I=C?C.byteOffset:n.byteOffset,H=C?C.byteLength:n.byteLength,W=new DataView(F,I,H);return a.set(N,W),W}if(Ge.has(F)){let n=N,C=S?.viewSnapshots.get(N),F=internalClone(n.buffer,a,S),I=n.constructor,H=new I(F,C?C.byteOffset:n.byteOffset,C?C.length:n.length);return a.set(N,H),H}if(F===`Map`){let n=new Map;a.set(N,n);for(let[C,F]of N)n.set(internalClone(C,a,S),internalClone(F,a,S));return n}if(F===`Set`){let n=new Set;a.set(N,n);for(let C of N)n.add(internalClone(C,a,S));return n}{let n=globalThis,a=n.Blob,S=n.File;if(typeof S==`function`&&N instanceof S){let n=N;return new S([N],n.name,{type:n.type,lastModified:n.lastModified})}if(typeof a==`function`&&N instanceof a)return new a([N],{type:N.type})}if(N instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),N instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),N instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&N instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),F===`Array`){let n=N,C=[];a.set(N,C);for(let N=0;N<n.length;N++)N in n&&(C[N]=internalClone(n[N],a,S));return C}if(F===`Object`||typeof N==`object`){let n={};a.set(N,n);for(let C of Object.keys(N))n[C]=internalClone(N[C],a,S);return n}throwDataCloneError(`${F} cannot be cloned`)}function structuredClone$1(n,a){let S=a?.transfer;if(!S||S.length===0)return internalClone(n,new Map);let C=new Set;for(let n of S)if(classOf(n)===`ArrayBuffer`){let a=n;a.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),C.add(a)}let N=new Map;C.size>0&&snapshotViewsBackedByTransferredBuffers(n,C,N,new Set);let F=new Map;for(let n of C){let a=n;typeof a.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),F.set(n,a.transfer())}return internalClone(n,new Map,{transferred:F,viewSnapshots:N})}function snapshotViewsBackedByTransferredBuffers(n,a,S,C){if(typeof n!=`object`||!n)return;let N=n;if(C.has(N))return;C.add(N);let F=classOf(N);if(F===`DataView`){let n=N;a.has(n.buffer)&&S.set(N,{byteOffset:n.byteOffset,length:0,byteLength:n.byteLength});return}if(Ge.has(F)){let n=N;a.has(n.buffer)&&S.set(N,{byteOffset:n.byteOffset,length:n.length,byteLength:n.byteLength});return}if(Array.isArray(N)){for(let n=0;n<N.length;n++)n in N&&snapshotViewsBackedByTransferredBuffers(N[n],a,S,C);return}if(F===`Map`){for(let[n,F]of N)snapshotViewsBackedByTransferredBuffers(n,a,S,C),snapshotViewsBackedByTransferredBuffers(F,a,S,C);return}if(F===`Set`){for(let n of N)snapshotViewsBackedByTransferredBuffers(n,a,S,C);return}if(F===`Object`)for(let n of Object.keys(N))snapshotViewsBackedByTransferredBuffers(N[n],a,S,C)}var He,Ue,Ge,Ke=__esmMin(()=>{({toString:He}=Object.prototype),Ue={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Ge=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),__name$1(structuredClone$1,`structuredClone`)});function ensureMainLoop(){let n=globalThis.imports;if(!n)return;if(qe)return Je;let a=n.gi?.GLib;if(a){if(Je=new a.MainLoop(null,!1),qe=!0,a.main_depth()===0)try{Je.runAsync()}catch{}return Je}}function quitMainLoop(){Je&&=(Je.quit(),qe=!1,null)}var qe,Je,Ye=__esmMin(()=>{qe=!1,Je=null}),Xe=__esmMin(()=>{re(),ie(),ce(),le(),ue(),de(),ve(),xe(),Se(),Ce(),je(),Fe(),Re(),Ve(),Ke(),Ye()});ne(),Xe(),registerGlobal(`Blob`,X),registerGlobal(`File`,te);function atobPolyfill(n){if(typeof globalThis.atob==`function`)return globalThis.atob(n);let a=n.replace(/[=\s]/g,``),S=``,C=0,N=0;for(let n=0;n<a.length;n++)C=C<<6|Qe[a.charCodeAt(n)],N+=6,N>=8&&(N-=8,S+=String.fromCharCode(C>>N&255));return S}function btoaPolyfill(n){if(typeof globalThis.btoa==`function`)return globalThis.btoa(n);let a=``,S=0;for(;S+2<n.length;S+=3){let C=n.charCodeAt(S)<<16|n.charCodeAt(S+1)<<8|n.charCodeAt(S+2);a+=Ze[C>>18&63]+Ze[C>>12&63]+Ze[C>>6&63]+Ze[C&63]}if(S+1===n.length){let C=n.charCodeAt(S)<<16;a+=Ze[C>>18&63]+Ze[C>>12&63]+`==`}else if(S+2===n.length){let C=n.charCodeAt(S)<<16|n.charCodeAt(S+1)<<8;a+=Ze[C>>18&63]+Ze[C>>12&63]+Ze[C>>6&63]+`=`}return a}function base64Decode$1(n){let a=n.replace(/[=\s]/g,``),S=new Uint8Array(a.length*3>>2),C=0,N=0,F=0;for(let n=0;n<a.length;n++)C=C<<6|Qe[a.charCodeAt(n)],N+=6,N>=8&&(N-=8,S[F++]=C>>N&255);return S.subarray(0,F)}function base64Encode$1(n){let a=``,S=n.length;for(let C=0;C<S;C+=3){let N=n[C],F=C+1<S?n[C+1]:0,I=C+2<S?n[C+2]:0;a+=Ze[N>>2],a+=Ze[(N&3)<<4|F>>4],a+=C+1<S?Ze[(F&15)<<2|I>>6]:`=`,a+=C+2<S?Ze[I&63]:`=`}return a}var Ze,Qe,$e=__esmMin(()=>{Ze=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Qe=new Uint8Array(256);for(let n=0;n<64;n++)Qe[Ze.charCodeAt(n)]=n;__name$1(base64Decode$1,`base64Decode`),__name$1(base64Encode$1,`base64Encode`)});function normalizeEncoding(n){if(!n||n===`utf8`||n===`utf-8`)return`utf8`;switch((``+n).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function checkEncoding(n){let a=(``+n).toLowerCase().replace(/-/g,``);if(!et.includes(a))throw TypeError(`Unknown encoding: ${n}`)}var et,tt=__esmMin(()=>{et=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`]});function encodeString(n,a){switch(a){case`utf8`:return it().encode(n);case`ascii`:{let a=new Uint8Array(n.length);for(let S=0;S<n.length;S++)a[S]=n.charCodeAt(S)&127;return a}case`latin1`:{let a=new Uint8Array(n.length);for(let S=0;S<n.length;S++)a[S]=n.charCodeAt(S)&255;return a}case`base64`:return base64Decode$1(n.replace(/-/g,`+`).replace(/_/g,`/`));case`base64url`:return encodeString(n.replace(/-/g,`+`).replace(/_/g,`/`),`base64`);case`hex`:{let a=n.length>>>1,S=new Uint8Array(a);for(let C=0;C<a;C++){let a=parseInt(n[C*2],16),N=parseInt(n[C*2+1],16);if(Number.isNaN(a)||Number.isNaN(N))break;S[C]=a<<4|N}return S}case`utf16le`:{let a=new Uint8Array(n.length*2);for(let S=0;S<n.length;S++){let C=n.charCodeAt(S);a[S*2]=C&255,a[S*2+1]=C>>8&255}return a}default:return it().encode(n)}}function decodeString(n,a,S,C){let N=S!==void 0||C!==void 0?n.subarray(S??0,C??n.length):n;switch(a){case`utf8`:return ot().decode(N);case`ascii`:{let n=``;for(let a=0;a<N.length;a++)n+=String.fromCharCode(N[a]&127);return n}case`latin1`:{let n=``;for(let a=0;a<N.length;a++)n+=String.fromCharCode(N[a]);return n}case`base64`:{let n=``;for(let a=0;a<N.length;a++)n+=String.fromCharCode(N[a]);return btoaPolyfill(n)}case`base64url`:return decodeString(N,`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);case`hex`:{let n=``;for(let a=0;a<N.length;a++)n+=N[a].toString(16).padStart(2,`0`);return n}case`utf16le`:{let n=``;for(let a=0;a+1<N.length;a+=2)n+=String.fromCharCode(N[a]|N[a+1]<<8);return n}default:return ot().decode(N)}}function checkOffset(n,a,S){if(n+a>S)throw RangeError(`Attempt to access memory outside buffer bounds`)}var nt,rt,it,ot,st=__esmMin(()=>{$e(),it=__name$1(()=>nt??=new TextEncoder,`textEncoder`),ot=__name$1(()=>rt??=new TextDecoder,`textDecoder`)}),ct,lt,ut,dt,ft,SlowBuffer,pt=__esmMin(()=>{st(),tt(),ct=typeof SharedArrayBuffer<`u`,lt=class Buffer extends Uint8Array{static _isBuffer=!0;static alloc(n,a,S){if(typeof n!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof n}`);if(n<0)throw RangeError(`The value "${n}" is invalid for option "size"`);let C=new Buffer(n);return a!==void 0&&a!==0&&C.fill(a,0,n,S),C}static allocUnsafe(n){if(typeof n!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof n}`);return new Buffer(n)}static allocUnsafeSlow(n){return Buffer.allocUnsafe(n)}static from(n,a,S){if(typeof n==`string`){let S=normalizeEncoding(a);if(a&&typeof a==`string`){let n=(``+a).toLowerCase().replace(/-/g,``);[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`,``].includes(n)||checkEncoding(a)}let C=encodeString(n,S);return new Buffer(C.buffer,C.byteOffset,C.byteLength)}if(ArrayBuffer.isView(n)){let a=new Buffer(n.buffer,n.byteOffset,n.byteLength),S=new Buffer(a.length);return S.set(a),S}if(n instanceof ArrayBuffer){let C=a||0;return new Buffer(n,C,S===void 0?n.byteLength-C:S)}if(ct&&n instanceof SharedArrayBuffer){let C=a||0,N=S===void 0?n.byteLength-C:S;return new Buffer(new Uint8Array(n,C,N))}if(typeof n==`object`&&n&&typeof n.viewBytes==`function`&&typeof n.byteLength==`number`&&n.constructor?.name===`SharedBuffer`){let C=n,N=a||0,F=S===void 0?C.byteLength-N:S,I=C.viewBytes(N,F);return new Buffer(I.buffer,I.byteOffset,I.byteLength)}if(Array.isArray(n)){let a=new Buffer(n.length);for(let S=0;S<n.length;S++)a[S]=n[S]&255;return a}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(n){return n instanceof Buffer}static isEncoding(n){if(typeof n!=`string`)return!1;let a=n.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(a)}static byteLength(n,a){if(typeof n!=`string`){if(ArrayBuffer.isView(n)||n instanceof ArrayBuffer||ct&&n instanceof SharedArrayBuffer)return n.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(a)){case`utf8`:return new TextEncoder().encode(n).byteLength;case`ascii`:case`latin1`:return n.length;case`base64`:case`base64url`:{let a=n.length;for(;a>0&&(n[a-1]===`=`||n[a-1]===` `);)a--;return a*3>>>2}case`hex`:return n.length>>>1;case`utf16le`:return n.length*2;default:return new TextEncoder().encode(n).byteLength}}static compare(n,a){if(!(n instanceof Uint8Array)||!(a instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let S=Math.min(n.length,a.length);for(let C=0;C<S;C++){if(n[C]<a[C])return-1;if(n[C]>a[C])return 1}return n.length<a.length?-1:+(n.length>a.length)}static concat(n,a){if(n.length===0)return Buffer.alloc(0);if(a===void 0){a=0;for(let S=0;S<n.length;S++)a+=n[S].length}let S=Buffer.alloc(a),C=0;for(let N=0;N<n.length;N++){let F=n[N],I=Math.min(F.length,a-C);I<=0||(S.set(F.subarray(0,I),C),C+=I)}return S}static poolSize=65536;toString(n,a,S){let C=normalizeEncoding(n);return decodeString(this,C,a,S)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(n){if(!(n instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==n.length)return!1;for(let a=0;a<this.length;a++)if(this[a]!==n[a])return!1;return!0}compare(n,a,S,C,N){if(!(n instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let F=C!==void 0||N!==void 0?this.subarray(C??0,N??this.length):this,I=a!==void 0||S!==void 0?n.subarray(a??0,S??n.length):n;return Buffer.compare(F,I)}copy(n,a=0,S=0,C){let N=C??this.length,F=Math.min(N-S,n.length-a);return F<=0?0:(n.set(this.subarray(S,S+F),a),F)}slice(n,a){let S=n??0,C=a??this.length,N=super.subarray(S,C);return new Buffer(N.buffer,N.byteOffset,N.byteLength)}subarray(n,a){let S=super.subarray(n,a);return new Buffer(S.buffer,S.byteOffset,S.byteLength)}write(n,a,S,C){a??=0;let N=encodeString(n,normalizeEncoding(C||(typeof S==`string`?S:void 0))),F=S!==void 0&&typeof S==`number`?Math.min(S,this.length-a):this.length-a,I=Math.min(N.length,F);return this.set(N.subarray(0,I),a),I}fill(n,a,S,C){let N=a??0,F=S??this.length;if(typeof n==`number`)super.fill(n&255,N,F);else if(typeof n==`string`){let a=encodeString(n,normalizeEncoding(C));if(a.length===0)super.fill(0,N,F);else if(a.length===1)super.fill(a[0],N,F);else for(let n=N;n<F;n++)this[n]=a[(n-N)%a.length]}else if(n instanceof Uint8Array)if(n.length===0)super.fill(0,N,F);else for(let a=N;a<F;a++)this[a]=n[(a-N)%n.length];return this}indexOf(n,a,S){if(typeof n==`number`)return super.indexOf(n&255,a);let C=typeof n==`string`?encodeString(n,normalizeEncoding(S)):n,N=a??0;outer:for(let n=N;n<=this.length-C.length;n++){for(let a=0;a<C.length;a++)if(this[n+a]!==C[a])continue outer;return n}return-1}lastIndexOf(n,a,S){if(typeof n==`number`)return a===void 0?super.lastIndexOf(n&255):super.lastIndexOf(n&255,a);let C=typeof n==`string`?encodeString(n,normalizeEncoding(S)):n,N=a===void 0?this.length-C.length:Math.min(a,this.length-C.length);outer:for(let n=N;n>=0;n--){for(let a=0;a<C.length;a++)if(this[n+a]!==C[a])continue outer;return n}return-1}includes(n,a,S){return this.indexOf(n,a,S)!==-1}readUInt8(n=0){return checkOffset(n,1,this.length),this[n]}readUInt16BE(n=0){return checkOffset(n,2,this.length),this[n]<<8|this[n+1]}readUInt16LE(n=0){return checkOffset(n,2,this.length),this[n]|this[n+1]<<8}readUInt32BE(n=0){return checkOffset(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])}readUInt32LE(n=0){return checkOffset(n,4,this.length),this[n+3]*16777216+(this[n+2]<<16|this[n+1]<<8|this[n])>>>0}readInt8(n=0){return checkOffset(n,1,this.length),this[n]|(this[n]&128?4294967040:0)}readInt16BE(n=0){checkOffset(n,2,this.length);let a=this[n]<<8|this[n+1];return a&32768?a|4294901760:a}readInt16LE(n=0){checkOffset(n,2,this.length);let a=this[n]|this[n+1]<<8;return a&32768?a|4294901760:a}readInt32BE(n=0){return checkOffset(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]}readInt32LE(n=0){return checkOffset(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24}readFloatBE(n=0){return checkOffset(n,4,this.length),new DataView(this.buffer,this.byteOffset+n,4).getFloat32(0,!1)}readFloatLE(n=0){return checkOffset(n,4,this.length),new DataView(this.buffer,this.byteOffset+n,4).getFloat32(0,!0)}readDoubleBE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getFloat64(0,!1)}readDoubleLE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getFloat64(0,!0)}readBigInt64BE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getBigInt64(0,!1)}readBigInt64LE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getBigInt64(0,!0)}readBigUInt64BE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getBigUint64(0,!1)}readBigUInt64LE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getBigUint64(0,!0)}readUIntBE(n,a){checkOffset(n,a,this.length);let S=0;for(let C=0;C<a;C++)S=S*256+this[n+C];return S}readUIntLE(n,a){checkOffset(n,a,this.length);let S=0,C=1;for(let N=0;N<a;N++)S+=this[n+N]*C,C*=256;return S}readIntBE(n,a){checkOffset(n,a,this.length);let S=0;for(let C=0;C<a;C++)S=S*256+this[n+C];return S>=2**(8*a-1)&&(S-=2**(8*a)),S}readIntLE(n,a){checkOffset(n,a,this.length);let S=0,C=1;for(let N=0;N<a;N++)S+=this[n+N]*C,C*=256;return S>=2**(8*a-1)&&(S-=2**(8*a)),S}writeUInt8(n,a=0){return checkOffset(a,1,this.length),this[a]=n&255,a+1}writeUInt16BE(n,a=0){return checkOffset(a,2,this.length),this[a]=n>>>8&255,this[a+1]=n&255,a+2}writeUInt16LE(n,a=0){return checkOffset(a,2,this.length),this[a]=n&255,this[a+1]=n>>>8&255,a+2}writeUInt32BE(n,a=0){return checkOffset(a,4,this.length),this[a]=n>>>24&255,this[a+1]=n>>>16&255,this[a+2]=n>>>8&255,this[a+3]=n&255,a+4}writeUInt32LE(n,a=0){return checkOffset(a,4,this.length),this[a]=n&255,this[a+1]=n>>>8&255,this[a+2]=n>>>16&255,this[a+3]=n>>>24&255,a+4}writeInt8(n,a=0){return checkOffset(a,1,this.length),n<0&&(n=255+n+1),this[a]=n&255,a+1}writeInt16BE(n,a=0){return checkOffset(a,2,this.length),this[a]=n>>>8&255,this[a+1]=n&255,a+2}writeInt16LE(n,a=0){return checkOffset(a,2,this.length),this[a]=n&255,this[a+1]=n>>>8&255,a+2}writeInt32BE(n,a=0){return checkOffset(a,4,this.length),this[a]=n>>>24&255,this[a+1]=n>>>16&255,this[a+2]=n>>>8&255,this[a+3]=n&255,a+4}writeInt32LE(n,a=0){return checkOffset(a,4,this.length),this[a]=n&255,this[a+1]=n>>>8&255,this[a+2]=n>>>16&255,this[a+3]=n>>>24&255,a+4}writeFloatBE(n,a=0){return checkOffset(a,4,this.length),new DataView(this.buffer,this.byteOffset+a,4).setFloat32(0,n,!1),a+4}writeFloatLE(n,a=0){return checkOffset(a,4,this.length),new DataView(this.buffer,this.byteOffset+a,4).setFloat32(0,n,!0),a+4}writeDoubleBE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setFloat64(0,n,!1),a+8}writeDoubleLE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setFloat64(0,n,!0),a+8}writeBigInt64BE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setBigInt64(0,n,!1),a+8}writeBigInt64LE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setBigInt64(0,n,!0),a+8}writeBigUInt64BE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setBigUint64(0,n,!1),a+8}writeBigUInt64LE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setBigUint64(0,n,!0),a+8}swap16(){let n=this.length;if(n%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let a=0;a<n;a+=2){let n=this[a];this[a]=this[a+1],this[a+1]=n}return this}swap32(){let n=this.length;if(n%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let a=0;a<n;a+=4){let n=this[a],S=this[a+1];this[a]=this[a+3],this[a+1]=this[a+2],this[a+2]=S,this[a+3]=n}return this}swap64(){let n=this.length;if(n%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let a=0;a<n;a+=8){let n=this[a],S=this[a+1],C=this[a+2],N=this[a+3];this[a]=this[a+7],this[a+1]=this[a+6],this[a+2]=this[a+5],this[a+3]=this[a+4],this[a+4]=N,this[a+5]=C,this[a+6]=S,this[a+7]=n}return this}},ut=2**31-1,dt=2**28-16,ft={MAX_LENGTH:ut,MAX_STRING_LENGTH:dt},SlowBuffer=class extends lt{constructor(n){super(n)}}}),mt=__exportAll$3({Blob:()=>X,Buffer:()=>lt,File:()=>te,INSPECT_MAX_BYTES:()=>50,SlowBuffer:()=>SlowBuffer,atob:()=>ht,atobPolyfill:()=>atobPolyfill,base64Decode:()=>base64Decode$1,base64Encode:()=>base64Encode$1,btoa:()=>gt,btoaPolyfill:()=>btoaPolyfill,checkEncoding:()=>checkEncoding,constants:()=>ft,default:()=>_t,kMaxLength:()=>ut,kStringMaxLength:()=>dt,normalizeEncoding:()=>normalizeEncoding}),ht,gt,_t,vt=__esmMin(()=>{$e(),ne(),tt(),pt(),ht=globalThis.atob,gt=globalThis.btoa,_t={Buffer:lt,SlowBuffer,Blob:X,File:te,atob:ht,btoa:gt,kMaxLength:ut,kStringMaxLength:dt,constants:ft,INSPECT_MAX_BYTES:50}});vt(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:lt,enumerable:!1,writable:!0,configurable:!0}),se(),typeof globalThis.btoa!=`function`&&Object.defineProperty(globalThis,"btoa",{value:function btoa(n){let a=new Uint8Array(n.length);for(let S=0;S<n.length;S++)a[S]=n.charCodeAt(S)&255;return Z.base64_encode(a)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(n){let a=Z.base64_decode(n),S=``;for(let n=0;n<a.length;n++)S+=String.fromCharCode(a[n]);return S},enumerable:!0,writable:!0,configurable:!0}),Xe(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:Me,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let n=getGjsGlobal().imports?.gi;if(!n)return null;let a=null;try{a=n.GioUnix??null}catch{}if(!a)try{a=n.Gio??null}catch{}return a}var yt=__esmMin(()=>{});function getMonotonicTime(){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n?.get_monotonic_time)return BigInt(n.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}function hrtime(n){let a=getMonotonicTime()-bt,S=Number(a/1000000000n),C=Number(a%1000000000n);if(n){let a=S-n[0],N=C-n[1];return N<0&&(a--,N+=1e9),[a,N]}return[S,C]}function hrtimeBigint(){return getMonotonicTime()-bt}var bt,xt=__esmMin(()=>{yt(),bt=getMonotonicTime()});function detectGjsVersion(){try{let n=getGjsGlobal().imports?.system;if(n?.version!==void 0){let a=Number(n.version);return`${Math.floor(a/1e4)}.${Math.floor(a%1e4/100)}.${a%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let n=detectGjsVersion(),a={node:`20.0.0`};return n&&(a.gjs=n),{version:`v20.0.0`,versions:a,title:`gjs`}}function detectPpid(){if(typeof globalThis.process?.ppid==`number`)return globalThis.process.ppid;try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let[,a]=n.file_get_contents(`/proc/self/status`);if(a){let n=new TextDecoder().decode(a).match(/PPid:\s+(\d+)/);if(n)return parseInt(n[1],10)}}}catch{}return 0}function detectPlatform(){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n&&n.get_os_info(`ID`))return`linux`}catch{}return getGjsGlobal().imports?.system===void 0&&typeof globalThis.process?.platform==`string`?globalThis.process.platform:`linux`}function detectArch(){return typeof globalThis.process?.arch==`string`?globalThis.process.arch:`x64`}function getPid$1(){if(typeof globalThis.process?.pid==`number`)return globalThis.process.pid;try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let[,a]=n.file_get_contents(`/proc/self/stat`);if(a){let n=new TextDecoder().decode(a),S=parseInt(n,10);if(!isNaN(S))return S}}}catch{}return 0}var St=__esmMin(()=>{yt(),__name$1(getPid$1,`getPid`)});function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let n=getGjsGlobal().imports?.gi?.GLib;if(n)return new Proxy({},{get(a,S){if(typeof S==`string`)return n.getenv(S)??void 0},set(a,S,C){return typeof S==`string`?(n.setenv(S,String(C),!0),!0):!1},deleteProperty(a,S){return typeof S==`string`?(n.unsetenv(S),!0):!1},has(a,S){return typeof S==`string`?n.getenv(S)!==null:!1},ownKeys(a){return n.listenv()},getOwnPropertyDescriptor(a,S){if(typeof S!=`string`)return;let C=n.getenv(S);if(C!==null)return{configurable:!0,enumerable:!0,writable:!0,value:C}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let n=getGjsGlobal().imports?.system;if(n?.programArgs)return[`gjs`,n.programInvocationName||``,...n.programArgs]}catch{}return[`gjs`]}function getExecPath(){if(typeof globalThis.process?.execPath==`string`)return globalThis.process.execPath;try{let n=getGjsGlobal().imports?.system;if(n?.programInvocationName)return n.programInvocationName}catch{}return`/usr/bin/gjs`}function getCwd(){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n?.get_current_dir)return n.get_current_dir()}catch{}return`/`}function chdir(n){let a=getGjsGlobal().imports?.gi?.GLib;try{if(a?.chdir){if(!a.file_test(n,16)){let a=Error(`ENOENT: no such file or directory, chdir '${n}'`);throw a.code=`ENOENT`,a.syscall=`chdir`,a.path=n,a}a.chdir(n);return}}catch(n){if(n&&typeof n==`object`&&n.code===`ENOENT`)throw n}if(!a){let a=globalThis.process;if(a&&typeof a.chdir==`function`){a.chdir(n);return}}throw Error(`process.chdir() is not supported in this environment`)}var Ct=__esmMin(()=>{yt()});function exitProcess(n){let a=getGjsGlobal().imports,S=a?.gi?.GLib,C=a?.system,N=S?.idle_add,F=S?.SOURCE_REMOVE,I=S?.PRIORITY_DEFAULT;if(C?.exit&&N&&typeof I==`number`&&typeof F==`boolean`)return ensureMainLoop(),N(I,()=>(quitMainLoop(),C.exit(n),F)),new Promise(()=>{});try{C?.exit&&C.exit(n)}catch{}let H=globalThis.process;throw H&&typeof H.exit==`function`&&H.exit(n),Error(`process.exit(${n})`)}var wt=__esmMin(()=>{yt(),Xe()});function isGjs$1(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(n,a){try{let S=getGjsGlobal().imports?.gi?.GLib;if(S){let C=typeof a==`number`?String(a):a||`SIGTERM`,N=C.startsWith(`SIG`)?`-${C.slice(3)}`:`-${C}`;return S.spawn_command_line_sync(`kill ${N} ${n}`),!0}}catch{}if(!isGjs$1()){let S=globalThis.process;if(S&&typeof S.kill==`function`)return S.kill(n,a)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let[,a]=n.file_get_contents(`/proc/self/status`);if(a){let n=new TextDecoder().decode(a).match(/VmRSS:\s+(\d+)/),S=n?parseInt(n[1],10)*1024:0;return{rss:S,heapTotal:S,heapUsed:S,external:0,arrayBuffers:0}}}}catch{}if(!isGjs$1()){let n=globalThis.process;if(n&&typeof n.memoryUsage==`function`)return n.memoryUsage()}return{rss:0,heapTotal:0,heapUsed:0,external:0,arrayBuffers:0}}function cpuUsage(n){if(!isGjs$1()){let a=globalThis.process;if(a&&typeof a.cpuUsage==`function`)return a.cpuUsage(n)}return{user:0,system:0}}var Tt=__esmMin(()=>{yt(),__name$1(isGjs$1,`isGjs`)}),Et,Dt,Ot,kt=__esmMin(()=>{if(Et=null,Dt=globalThis.imports?.gi,Dt)try{Et=Dt.GjsifyTerminal}catch{}Ot=Et});function onceWrapper(){let{target:n,type:a,listener:S}=this;return this.wrapperFn&&n.removeListener(a,this.wrapperFn),S.apply(n,Array.from(arguments))}function _onceWrap(n,a,S){let C={target:n,type:a,listener:S,wrapperFn:void 0},N=onceWrapper.bind(C);return C.wrapperFn=N,N.listener=S,N}function arrayClone(n){switch(n.length){case 0:return[];case 1:return[n[0]];case 2:return[n[0],n[1]];case 3:return[n[0],n[1],n[2]];default:return n.slice()}}function checkListener(n){if(typeof n!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof n)}function validateNumber(n,a){if(typeof n!=`number`||n!==n)throw TypeError(`The "${a}" argument must be of type number. Received type ${typeof n}`)}function spliceOne(n,a){for(;a+1<n.length;a++)n[a]=n[a+1];n.pop()}function unwrapListeners(n){let a=Array.from({length:n.length});for(let S=0;S<a.length;++S)a[S]=n[S].listener??n[S];return a}function createAbortError$2(n){let a=Error(`The operation was aborted`);return a.name=`AbortError`,a.code=`ABORT_ERR`,n?.reason&&(a.cause=n.reason),a}var At,jt,Mt,Nt=__esmMin(()=>{Ae(),At=Symbol(`kCapture`),jt=Symbol.for(`nodejs.rejection`),Mt=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=jt;static _captureRejections=!1;static get captureRejections(){return EventEmitter._captureRejections}static set captureRejections(n){if(typeof n!=`boolean`)throw TypeError(`The "captureRejections" argument must be of type boolean.`);EventEmitter._captureRejections=n}_events;_eventsCount;_maxListeners;[At];constructor(n){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[At]=n?.captureRejections??EventEmitter._captureRejections}setMaxListeners(n){if(validateNumber(n,`n`),n<0)throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+n);return this._maxListeners=n,this}getMaxListeners(){return this._maxListeners??EventEmitter.defaultMaxListeners}emit(n,...a){let S=this._events,C=n===`error`;if(S!==void 0)C&&S[EventEmitter.errorMonitor]!==void 0&&this.emit(EventEmitter.errorMonitor,...a),C&&=S.error===void 0;else if(!C)return!1;if(C){let n;if(n=a.length>0?a[0]:Error(`Unhandled error.`),n instanceof Error)throw n;let S=Error(`Unhandled error. (`+n+`)`);throw S.context=n,S}let N=S[n];if(N===void 0)return!1;if(typeof N==`function`){let S=N.apply(this,a);S!=null&&this[At]&&this._addCatch(S,n,a)}else{let S=arrayClone(N),C=S.length;for(let N=0;N<C;++N){let C=S[N].apply(this,a);C!=null&&this[At]&&this._addCatch(C,n,a)}}return!0}_addCatch(n,a,S){typeof n?.then==`function`&&n.then(void 0,n=>{let C=this[jt];if(typeof C==`function`)C.call(this,n,a,...S);else{let a=this[At];try{this[At]=!1,this.emit(`error`,n)}finally{this[At]=a}}})}addListener(n,a){return this._addListener(n,a,!1)}on(n,a){return this._addListener(n,a,!1)}prependListener(n,a){return this._addListener(n,a,!0)}_addListener(n,a,S){checkListener(a);let C=this._events;C===void 0?(C=this._events=Object.create(null),this._eventsCount=0):C.newListener!==void 0&&(this.emit(`newListener`,n,a.listener??a),C=this._events);let N=C[n];N===void 0?(C[n]=a,++this._eventsCount):typeof N==`function`?C[n]=S?[a,N]:[N,a]:S?N.unshift(a):N.push(a);let F=this.getMaxListeners();if(F>0){let a=typeof C[n]==`function`?1:C[n].length;if(a>F&&!C[n].warned){typeof C[n]!=`function`&&(C[n].warned=!0);let S=Error(`Possible EventEmitter memory leak detected. ${a} ${String(n)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);S.name=`MaxListenersExceededWarning`,ke.warn(S.message)}}return this}once(n,a){return checkListener(a),this.on(n,_onceWrap(this,n,a)),this}prependOnceListener(n,a){return checkListener(a),this.prependListener(n,_onceWrap(this,n,a)),this}removeListener(n,a){checkListener(a);let S=this._events;if(S===void 0)return this;let C=S[n];if(C===void 0)return this;if(C===a||C.listener===a)--this._eventsCount===0?this._events=Object.create(null):(delete S[n],S.removeListener&&this.emit(`removeListener`,n,C.listener??a));else if(typeof C!=`function`){let N=-1;for(let n=C.length-1;n>=0;n--)if(C[n]===a||C[n].listener===a){N=n;break}if(N<0)return this;N===0?C.shift():spliceOne(C,N),C.length===1&&(S[n]=C[0]),S.removeListener!==void 0&&this.emit(`removeListener`,n,a.listener??a)}return this}off(n,a){return this.removeListener(n,a)}removeAllListeners(n){let a=this._events;if(a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[n]),this;if(arguments.length===0){let n=Object.keys(a);for(let a=0;a<n.length;++a){let S=n[a];S!==`removeListener`&&this.removeAllListeners(S)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let S=a[n];if(typeof S==`function`)this.removeListener(n,S);else if(S!==void 0)for(let a=S.length-1;a>=0;a--)this.removeListener(n,S[a]);return this}listeners(n){let a=this._events;if(a===void 0)return[];let S=a[n];return S===void 0?[]:typeof S==`function`?[S.listener??S]:unwrapListeners(S)}rawListeners(n){let a=this._events;if(a===void 0)return[];let S=a[n];return S===void 0?[]:typeof S==`function`?[S]:arrayClone(S)}listenerCount(n){let a=this._events;if(a===void 0)return 0;let S=a[n];return S===void 0?0:typeof S==`function`?1:S.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(n,a,S){return new Promise((C,N)=>{let F=S?.signal;if(F?.aborted){N(createAbortError$2(F));return}if(typeof n.addEventListener==`function`){let S=n,handler=(...n)=>{F&&F.removeEventListener(`abort`,abortHandler),C(n)},errorHandler=n=>{F&&F.removeEventListener(`abort`,abortHandler),S.removeEventListener(`error`,errorHandler),N(n)},abortHandler=()=>{S.removeEventListener(a,handler),S.removeEventListener(`error`,errorHandler),N(createAbortError$2(F))};S.addEventListener(a,handler,{once:!0}),a!==`error`&&S.addEventListener(`error`,errorHandler,{once:!0}),F&&F.addEventListener(`abort`,abortHandler,{once:!0});return}let I=n,eventHandler=(...n)=>{F&&F.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&I.removeListener(`error`,errorHandler),C(n)},errorHandler;a!==`error`&&(errorHandler=n=>{I.removeListener(a,eventHandler),F&&F.removeEventListener(`abort`,abortHandler),N(n)},I.once(`error`,errorHandler)),I.once(a,eventHandler);let abortHandler=()=>{I.removeListener(a,eventHandler),errorHandler&&I.removeListener(`error`,errorHandler),N(createAbortError$2(F))};F&&F.addEventListener(`abort`,abortHandler,{once:!0})})}static on(n,a,S){let C=S?.signal;if(C?.aborted)throw createAbortError$2(C);let N=S?.highWaterMark??2**53-1,F=S?.lowWaterMark??1;validateNumber(N,`highWaterMark`),validateNumber(F,`lowWaterMark`);let I=[],H=[],W=null,K=!1,q=!1,eventHandler=(...a)=>{if(H.length>0){let{resolve:n}=H.shift();n({value:a,done:!1})}else I.push(a),I.length>=N&&!q&&(q=!0,typeof n.pause==`function`&&n.pause())},errorHandler=n=>{if(W=n,H.length>0){let{reject:a}=H.shift();a(n)}Y.return()},abortHandler=()=>{errorHandler(createAbortError$2(C))};n.on(a,eventHandler),a!==`error`&&n.on(`error`,errorHandler),C&&C.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{n.removeListener(a,eventHandler),n.removeListener(`error`,errorHandler),C&&C.removeEventListener(`abort`,abortHandler),K=!0;for(let{resolve:n}of H)n({value:void 0,done:!0});H.length=0,I.length=0},Y={next(){if(I.length>0){let a=I.shift();return q&&I.length<F&&(q=!1,typeof n.resume==`function`&&n.resume()),Promise.resolve({value:a,done:!1})}if(W){let n=Promise.reject(W);return W=null,n}return K?Promise.resolve({value:void 0,done:!0}):new Promise((n,a)=>{H.push({resolve:n,reject:a})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(n){return K||(W=n,cleanup()),Promise.reject(n)},[Symbol.asyncIterator](){return this}};return Y}static listenerCount(n,a){return n.listenerCount(a)}static getEventListeners(n,a){return typeof n.listeners==`function`?n.listeners(a):[]}static setMaxListeners(n,...a){if(validateNumber(n,`n`),n<0)throw RangeError(`The value of "n" is out of range.`);if(a.length===0)EventEmitter.defaultMaxListeners=n;else for(let S of a)typeof S.setMaxListeners==`function`&&S.setMaxListeners(n)}static getMaxListeners(n){return typeof n.getMaxListeners==`function`?n.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(n,a){n.aborted&&Promise.resolve().then(()=>a());let handler=()=>a();return n.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){n.removeEventListener(`abort`,handler)}}}},Mt.EventEmitter=Mt;for(let n of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let a=Mt.prototype[n];typeof a==`function`&&Object.defineProperty(Mt.prototype,n,{enumerable:!0,configurable:!0,writable:!0,value:a})}Object.defineProperty(Mt.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(Mt.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(Mt.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name$1(createAbortError$2,`createAbortError`)}),Pt=__exportAll$3({EventEmitter:()=>Ft,addAbortListener:()=>Gt,captureRejectionSymbol:()=>It,default:()=>Ft,defaultMaxListeners:()=>Rt,errorMonitor:()=>Lt,getEventListeners:()=>Ut,getMaxListeners:()=>Bt,listenerCount:()=>Wt,on:()=>Ht,once:()=>Vt,setMaxListeners:()=>zt}),Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt=__esmMin(()=>{Nt(),Xe(),Ft=makeCallable(Mt),Ft.EventEmitter=Ft,It=Ft.captureRejectionSymbol,Lt=Ft.errorMonitor,Rt=Ft.defaultMaxListeners,zt=Ft.setMaxListeners,Bt=Ft.getMaxListeners,Vt=Ft.once,Ht=Ft.on,Ut=Ft.getEventListeners,Wt=Ft.listenerCount,Gt=Ft.addAbortListener});function normalizeAndValidateEncoding(n){return n&&checkEncoding(n),normalizeEncoding(n)}function utf8DecodeMaximalSubpart(n,a,S){let C=``,N=a;for(;N<S;){let a=n[N];if(a<=127){C+=String.fromCharCode(a),N++;continue}if(a>=194&&a<=223){N+1<S&&n[N+1]>=128&&n[N+1]<=191?(C+=String.fromCharCode((a&31)<<6|n[N+1]&63),N+=2):(C+=`�`,N++);continue}if(a>=224&&a<=239){let F,I;if(a===224?(F=160,I=191):a===237?(F=128,I=159):(F=128,I=191),N+1>=S){C+=`�`,N++;continue}let H=n[N+1];if(H<F||H>I){C+=`�`,N++;continue}if(N+2>=S){C+=`�`,N+=2;continue}let W=n[N+2];if(W<128||W>191){C+=`�`,N+=2;continue}let K=(a&15)<<12|(H&63)<<6|W&63;C+=String.fromCharCode(K),N+=3;continue}if(a>=240&&a<=244){let F,I;if(a===240?(F=144,I=191):a===244?(F=128,I=143):(F=128,I=191),N+1>=S){C+=`�`,N++;continue}let H=n[N+1];if(H<F||H>I){C+=`�`,N++;continue}if(N+2>=S){C+=`�`,N+=2;continue}let W=n[N+2];if(W<128||W>191){C+=`�`,N+=2;continue}if(N+3>=S){C+=`�`,N+=3;continue}let K=n[N+3];if(K<128||K>191){C+=`�`,N+=3;continue}let q=(a&7)<<18|(H&63)<<12|(W&63)<<6|K&63;C+=String.fromCharCode(55296+(q-65536>>10),56320+(q-65536&1023)),N+=4;continue}C+=`�`,N++}return C}function utf8CharLength(n){return n&128?n>=194&&n<=223?2:n>=224&&n<=239?3:n>=240&&n<=244?4:0:1}function isValidContinuation(n,a,S,C){if(S===1){if(a===3)return n===224?C>=160&&C<=191:n===237?C>=128&&C<=159:C>=128&&C<=191;if(a===4)return n===240?C>=144&&C<=191:n===244?C>=128&&C<=143:C>=128&&C<=191}return C>=128&&C<=191}function writeUtf8(n,a){let S=0,C=``;if(n._lastNeed>0){for(;S<a.length&&n._lastNeed>0;){let N=a[S],F=n._lastTotal-n._lastNeed;if(isValidContinuation(n._lastLeadByte,n._lastTotal,F,N))n._lastChar[F]=N,n._lastNeed--,S++;else{C+=`�`,n._lastNeed=0,n._lastTotal=0,n._lastLeadByte=0;break}}if(n._lastNeed===0&&n._lastTotal>0&&(C+=utf8DecodeMaximalSubpart(n._lastChar,0,n._lastTotal),n._lastTotal=0,n._lastLeadByte=0),n._lastNeed>0)return C}let N=a.length;for(let C=0;C<Math.min(4,a.length-S);C++){let F=a.length-1-C;if(F<S)break;let I=a[F];if((I&192)!=128){let S=utf8CharLength(I);if(S>0&&I>=128){let C=a.length-F;if(C<S){let H=!0;for(let n=1;n<C;n++)if(!isValidContinuation(I,S,n,a[F+n])){H=!1;break}if(H){N=F;for(let S=0;S<C;S++)n._lastChar[S]=a[F+S];n._lastNeed=S-C,n._lastTotal=S,n._lastLeadByte=I}}}break}}return N>S&&(C+=utf8DecodeMaximalSubpart(a,S,N)),C}function writeUtf16le(n,a){let S=``,C=0;if(n._lastNeed>0){let N=n._lastTotal-n._lastNeed,F=Math.min(n._lastNeed,a.length);for(let S=0;S<F;S++)n._lastChar[N+S]=a[S];if(n._lastNeed-=F,C=F,n._lastNeed>0)return``;let I=n._lastTotal,H=0;for(;H+1<I;){let N=n._lastChar[H]|n._lastChar[H+1]<<8;if(H+=2,N>=55296&&N<=56319){if(H+1<I){let a=n._lastChar[H]|n._lastChar[H+1]<<8;if(a>=56320&&a<=57343){S+=String.fromCharCode(N,a),H+=2;continue}}if(C+1<a.length){let n=a[C]|a[C+1]<<8;if(n>=56320&&n<=57343){S+=String.fromCharCode(N,n),C+=2;continue}}else if(C>=a.length)return n._lastChar[0]=n._lastChar[H-2],n._lastChar[1]=n._lastChar[H-1],n._lastNeed=2,n._lastTotal=4,S}S+=String.fromCharCode(N)}n._lastTotal=0}for(;C+1<a.length;){let N=a[C]|a[C+1]<<8;if(C+=2,N>=55296&&N<=56319)if(C+1<a.length){let n=a[C]|a[C+1]<<8;if(n>=56320&&n<=57343){S+=String.fromCharCode(N,n),C+=2;continue}}else if(C<a.length)return S+=String.fromCharCode(N),n._lastChar[0]=a[C],n._lastNeed=1,n._lastTotal=2,S;else return n._lastChar[0]=a[C-2],n._lastChar[1]=a[C-1],n._lastNeed=2,n._lastTotal=4,S;S+=String.fromCharCode(N)}return C<a.length&&(n._lastChar[0]=a[C],n._lastNeed=1,n._lastTotal=2),S}function writeBase64(n,a){let S=0;if(n._lastNeed>0){let C=Math.min(n._lastNeed,a.length);for(let S=0;S<C;S++)n._lastChar[n._lastTotal-n._lastNeed+S]=a[S],n._lastNeed--;if(S=C,n._lastNeed>0)return``}let C=a.length-S,N=C-C%3,F=``;n._lastTotal>0&&n._lastNeed===0&&(F+=base64Encode$1(n._lastChar.subarray(0,n._lastTotal)),n._lastTotal=0),N>0&&(F+=base64Encode$1(a.subarray(S,S+N)));let I=C-N;if(I>0){for(let C=0;C<I;C++)n._lastChar[C]=a[S+N+C];n._lastNeed=3-I,n._lastTotal=3}return F}function decodeAscii(n){let a=``;for(let S=0;S<n.length;S++)a+=String.fromCharCode(n[S]&127);return a}function decodeLatin1(n){let a=``;for(let S=0;S<n.length;S++)a+=String.fromCharCode(n[S]);return a}function decodeHex(n){let a=``;for(let S=0;S<n.length;S++)a+=n[S].toString(16).padStart(2,`0`);return a}var qt,Jt=__esmMin(()=>{vt(),qt=function StringDecoder(n){this.encoding=normalizeAndValidateEncoding(n),this._lastNeed=0,this._lastTotal=0,this._lastLeadByte=0,this.encoding===`utf8`||this.encoding===`utf16le`?this._lastChar=new Uint8Array(4):this.encoding===`base64`?this._lastChar=new Uint8Array(3):this._lastChar=new Uint8Array},qt.prototype.write=function write(n){if(n.length===0)return``;switch(this.encoding){case`utf8`:return writeUtf8(this,n);case`utf16le`:return writeUtf16le(this,n);case`base64`:return writeBase64(this,n);case`ascii`:return decodeAscii(n);case`latin1`:return decodeLatin1(n);case`hex`:return decodeHex(n);default:return decodeAscii(n)}},qt.prototype.end=function end(n){let a=``;if(n&&n.length>0&&(a=this.write(n)),this.encoding===`utf8`&&this._lastNeed>0)a+=`�`,this._lastNeed=0,this._lastTotal=0;else if(this.encoding===`utf16le`&&this._lastNeed>0){let n=this._lastTotal-this._lastNeed;for(let S=0;S+1<n;S+=2)a+=String.fromCharCode(this._lastChar[S]|this._lastChar[S+1]<<8);this._lastNeed=0,this._lastTotal=0}else if(this.encoding===`base64`&&this._lastNeed>0){let n=this._lastChar.subarray(0,this._lastTotal-this._lastNeed);a+=base64Encode$1(n),this._lastNeed=0,this._lastTotal=0}return a}}),Yt,ProcessWriteStream,ProcessReadStream,Xt=__esmMin(()=>{Ae(),yt(),kt(),Kt(),Xe(),Jt(),Yt=new TextEncoder,ProcessWriteStream=class extends Ft{fd;writable=!0;_outGio=null;constructor(n){super(),this.fd=n;let a=getGioNamespace();if(a){let n=a.UnixOutputStream??a.OutputStream;if(n)try{this._outGio=n.new(this.fd,!1)}catch{}}}write(n){if(this._outGio)try{let a=typeof n==`string`?Yt.encode(n):n;return this._outGio.write_all(a,null),!0}catch{}return this.fd===2?ke.error(n):ke.log(n),!0}get isTTY(){if(Ot)return Ot.Terminal.is_tty(this.fd);try{let n=getGjsGlobal().imports?.gi?.GLib;if(n)return!!n.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(Ot){let[n,,a]=Ot.Terminal.get_size(this.fd);if(n&&a>0)return a}try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let a=parseInt(n.getenv(`COLUMNS`)??`0`,10);if(a>0)return a}}catch{}return 80}end(){}destroy(){}get rows(){if(Ot){let[n,a]=Ot.Terminal.get_size(this.fd);if(n&&a>0)return a}try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let a=parseInt(n.getenv(`LINES`)??`0`,10);if(a>0)return a}}catch{}return 24}},ProcessReadStream=class extends Ft{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;_decoder=null;constructor(n){super(),this.fd=n,this._gio=getGioNamespace()}get isTTY(){return Ot?Ot.Terminal.is_tty(this.fd):!1}setRawMode(n){return Ot&&Ot.Terminal.set_raw_mode(this.fd,n)?(this.isRaw=n,this):(this._setRawModeViaStty(n),this.isRaw=n,this)}_setRawModeViaStty(n){try{let a=globalThis.imports?.gi,S=a?.Gio??a?.Gio;if(!S)return;let C=S.SubprocessFlags?.STDIN_INHERIT??2,N=n?[`stty`,`-icanon`,`-echo`,`-icrnl`,`-isig`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`,`isig`];if(new S.SubprocessLauncher({flags:C}).spawnv(N).wait(null),n&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let n=globalThis.process;n?.once&&typeof n.once==`function`&&n.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(n){return this._decoder=new qt(n),this}_pushData(n){if(this._decoder){let a=this._decoder.write(n);a.length>0&&this.emit(`data`,a)}else this.emit(`data`,n)}on(n,a){let S=n===`data`&&this.listenerCount(`data`)===0;return super.on(n,a),S&&n===`data`&&this.resume(),this}addListener(n,a){return this.on(n,a)}once(n,a){return super.once(n,a),this}removeListener(n,a){return super.removeListener(n,a),n===`data`&&this.listenerCount(`data`)===0&&this.pause(),this}off(n,a){return this.removeListener(n,a)}removeAllListeners(n){let a=n===void 0||n===`data`?this.listenerCount(`data`)>0:!1;return super.removeAllListeners(n),a&&this.listenerCount(`data`)===0&&this.pause(),this}resume(){return this._flowing=!0,this._gio&&this.fd===0&&!this._reading&&this._startReading(),this}pause(){if(this._flowing=!1,this._reading=!1,this._mainLoopHeld){this._mainLoopHeld=!1;let n=globalThis.imports?.gi,a=n?.GLib??n?.GLib;a?.idle_add?a.idle_add(300,()=>(this._mainLoopHeld||quitMainLoop(),!1)):quitMainLoop()}return this}read(){return null}_startReading(){if(!this._gio||this._reading)return;if(this._pendingRead){this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop());return}if(this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop()),!this._stdinGio){let n=this._gio.UnixInputStream??this._gio.InputStream;if(!n){this._reading=!1;return}try{this._stdinGio=n.new(this.fd,!1)}catch{this._reading=!1;return}}let loop=()=>{if(!this._reading){this._pendingRead=!1;return}this._pendingRead=!0,this._stdinGio.read_bytes_async(4096,0,null,(n,a)=>{this._pendingRead=!1;try{let S=n.read_bytes_finish(a)?.get_data?.()??null;if(S&&S.byteLength>0)this._pushData(Buffer.from(S));else if(S!==null&&S.byteLength===0){if(this._reading=!1,this._decoder){let n=this._decoder.end();n.length>0&&this.emit(`data`,n)}this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}}}),Zt,Process,Qt=__esmMin(()=>{Ae(),St(),Ct(),wt(),xt(),Tt(),Xt(),Kt(),Zt=Date.now(),Process=class extends Ft{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.platform=detectPlatform(),this.arch=detectArch(),this.env=getEnvProxy(),this.argv=getArgv(),this.argv0=this.argv[0]||`gjs`,this.execPath=getExecPath(),this.execArgv=globalThis.process?.execArgv??[],this.config=globalThis.process?.config??{target_defaults:{},variables:{}},this.pid=getPid$1(),this.ppid=detectPpid();let n=detectVersionInfo();this.version=n.version,this.versions=n.versions,this.title=n.title}cwd(){return getCwd()}chdir(n){chdir(n)}kill(n,a){return killPid(n,a)}exit(n){return this.exitCode=n??this.exitCode??0,this.emit(`exit`,this.exitCode),exitProcess(this.exitCode)}nextTick(n,...a){typeof queueMicrotask==`function`?queueMicrotask(()=>n(...a)):Promise.resolve().then(()=>n(...a))}hrtime(n){return hrtime(n)}uptime(){return(Date.now()-Zt)/1e3}memoryUsage(){return memoryUsage()}cpuUsage(n){return cpuUsage(n)}stdout=new ProcessWriteStream(1);stderr=new ProcessWriteStream(2);stdin=new ProcessReadStream(0);abort(){this.exit(1)}umask(n){return 18}emitWarning(n,a){ke.warn(typeof n==`string`?`(${a||`Warning`}): ${n}`:n.message)}},Process.prototype.hrtime.bigint=function(){return hrtimeBigint()}}),$t,en,tn,nn,rn,an,on,sn=__esmMin(()=>{if(xt(),Qt(),kt(),$t=new Process,Ot)try{let n=new Ot.ResizeWatcher;n.connect(`resized`,(n,a,S)=>{$t.stdout.emit(`resize`),$t.stderr.emit(`resize`)}),n.start()}catch{}en=$t.platform,$t.arch,$t.env,$t.argv,$t.argv0,tn=$t.execPath,$t.pid,$t.ppid,$t.version,$t.versions,$t.cwd.bind($t),$t.chdir.bind($t),$t.exit.bind($t),$t.nextTick.bind($t),nn=Object.assign($t.hrtime.bind($t),{bigint:hrtimeBigint}),$t.uptime.bind($t),$t.memoryUsage.bind($t),$t.cpuUsage.bind($t),$t.kill.bind($t),$t.abort.bind($t),$t.umask.bind($t),$t.emitWarning.bind($t),rn=$t.execArgv,$t.config,an=$t.stdout,$t.stderr,on=$t.stdin});Xe(),sn(),typeof Promise.withResolvers!=`function`&&(Promise.withResolvers=function(){let n,a;return{promise:new Promise((S,C)=>{n=S,a=C}),resolve:n,reject:a}}),initErrorV8Methods(Error),`global`in globalThis||Object.defineProperty(globalThis,"global",{value:globalThis,writable:!1,enumerable:!1,configurable:!0}),Object.defineProperty(globalThis,"process",{value:$t,enumerable:!1,writable:!0,configurable:!0}),Xe(),typeof globalThis.structuredClone!=`function`&&Object.defineProperty(globalThis,"structuredClone",{value:structuredClone$1,enumerable:!0,writable:!0,configurable:!0});function getGLib(){return globalThis.imports?.gi?.GLib}const cn=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(n,a,S,C){this._callback=n,this._delay=a,this._args=S,this._repeat=C,this._schedule()}_schedule(){let n=getGLib();if(!n)return;let a=n.timeout_add.bind(n);this._id=a(n.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(n){setTimeout(()=>{throw n},0)}return this._repeat?n.SOURCE_CONTINUE:(this._id=null,n.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){if(this._id!==null){try{getGLib()?.Source.remove(this._id)}catch{}this._id=null}}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(n){if(n instanceof GjsifyTimeout)n._cancel();else if(typeof n==`number`)try{getGLib()?.Source.remove(n)}catch{}}if(cn){let setT=(n,a=0,...S)=>new GjsifyTimeout(n,Math.max(0,a|0),S,!1),setI=(n,a=0,...S)=>new GjsifyTimeout(n,Math.max(0,a|0),S,!0),n=globalThis;n.setTimeout=setT,n.clearTimeout=removeById,n.setInterval=setI,n.clearInterval=removeById}function setImmediate$2(n,...a){return setTimeout(n,0,...a)}__name$1(setImmediate$2,`setImmediate`);function clearImmediate(n){clearTimeout(n)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate$2,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0});var ln=__exportAll$3({URL:()=>fn,URLSearchParams:()=>dn,default:()=>pn,domainToASCII:()=>domainToASCII,domainToUnicode:()=>domainToUnicode,fileURLToPath:()=>fileURLToPath,format:()=>format$4,parse:()=>parse$4,pathToFileURL:()=>pathToFileURL,resolve:()=>resolve$3});function decodeComponent(n){try{return decodeURIComponent(n.replace(/\+/g,` `))}catch{return n}}function encodeComponent(n){return encodeURIComponent(n).replace(/%20/g,`+`)}function parse$4(n,a,S){if(typeof n!=`string`)throw TypeError(`The "url" argument must be of type string. Received type `+typeof n);let C={protocol:null,slashes:null,auth:null,host:null,port:null,hostname:null,hash:null,search:null,query:null,pathname:null,path:null,href:n},N=n.trim(),F=N.indexOf(`#`);F!==-1&&(C.hash=N.slice(F),N=N.slice(0,F));let I=N.indexOf(`?`);I!==-1&&(C.search=N.slice(I),C.query=a?Object.fromEntries(new dn(N.slice(I+1))):N.slice(I+1),N=N.slice(0,I));let H=/^([a-z][a-z0-9.+-]*:)/i.exec(N);if(H&&(C.protocol=H[1].toLowerCase(),N=N.slice(C.protocol.length)),(S||C.protocol)&&N.startsWith(`//`)&&(C.slashes=!0,N=N.slice(2)),C.slashes||C.protocol&&![`javascript:`,`data:`,`mailto:`].includes(C.protocol)){let n=-1;for(let a=0;a<N.length;a++){let S=N[a];if(S===`/`||S===`\\`){n=a;break}}let a=n===-1?N:N.slice(0,n);N=n===-1?``:N.slice(n);let S=a.lastIndexOf(`@`);S===-1?parseHostPort(a,C):(C.auth=decodeURIComponent(a.slice(0,S)),parseHostPort(a.slice(S+1),C))}return C.pathname=N||(C.slashes?`/`:null),(C.pathname!==null||C.search!==null)&&(C.path=(C.pathname||``)+(C.search||``)),C.href=format$4(C),C}function parseHostPort(n,a){if(!n)return;let S=n.indexOf(`[`);if(S!==-1){let C=n.indexOf(`]`,S);if(C!==-1){let N=n.slice(C+1);N.startsWith(`:`)&&(a.port=N.slice(1)),a.hostname=n.slice(S,C+1),a.host=a.hostname+(a.port?`:`+a.port:``);return}}let C=n.lastIndexOf(`:`);if(C!==-1){let S=n.slice(C+1);/^\d*$/.test(S)?(a.port=S||null,a.hostname=n.slice(0,C).toLowerCase()):a.hostname=n.toLowerCase()}else a.hostname=n.toLowerCase();a.host=a.hostname+(a.port?`:`+a.port:``)}function format$4(n){if(typeof n==`string`)return n;if(n instanceof fn)return n.href;let a=n,S=``;if(a.protocol&&(S+=a.protocol),(a.slashes||a.protocol&&![`javascript:`,`data:`,`mailto:`].includes(a.protocol||``))&&(S+=`//`),a.auth&&(S+=encodeURIComponent(a.auth)+`@`),a.host?S+=a.host:(a.hostname&&(S+=a.hostname),a.port&&(S+=`:`+a.port)),a.pathname&&(S+=a.pathname),a.search)S+=a.search;else if(a.query&&typeof a.query==`object`){let n=new dn(a.query).toString();n&&(S+=`?`+n)}return a.hash&&(S+=a.hash),S}function resolve$3(n,a){return new fn(a,new fn(n,`resolve://`)).href.replace(/^resolve:\/\//,``)}function fileURLToPath(n){if(typeof n==`string`&&(n=new fn(n)),!(n instanceof fn))throw TypeError(`The "url" argument must be of type string or URL. Received type `+typeof n);if(n.protocol!==`file:`)throw TypeError(`The URL must be of scheme file`);if(n.hostname!==``&&n.hostname!==`localhost`)throw TypeError(`File URL host must be "localhost" or empty on linux`);let a=n.pathname;for(let n=0;n<a.length;n++)if(a[n]===`%`){let S=a.codePointAt(n+2)|32;if(a[n+1]===`2`&&S===102)throw TypeError(`File URL path must not include encoded / characters`)}return decodeURIComponent(a)}function pathToFileURL(n){let a=n;if(n[0]!==`/`)if(typeof globalThis.process?.cwd==`function`)a=globalThis.process.cwd()+`/`+n;else try{Z?.get_current_dir&&(a=Z.get_current_dir()+`/`+n)}catch{}return new fn(`file://`+encodePathForURL(a))}function encodePathForURL(n){let a=``;for(let S=0;S<n.length;S++){let C=n[S];C>=`a`&&C<=`z`||C>=`A`&&C<=`Z`||C>=`0`&&C<=`9`||C===`/`||C===`-`||C===`_`||C===`.`||C===`~`||C===`:`||C===`@`||C===`!`?a+=C:a+=encodeURIComponent(C)}return a}function domainToASCII(n){try{return new fn(`http://${n}`).hostname}catch{return``}}function domainToUnicode(n){try{return new fn(`http://${n}`).hostname}catch{return``}}var un,dn,fn,pn,mn=__esmMin(()=>{se(),un=Z.UriFlags.HAS_PASSWORD|Z.UriFlags.ENCODED|Z.UriFlags.SCHEME_NORMALIZE,dn=class URLSearchParams{_entries=[];constructor(n){if(n)if(typeof n==`string`){let a=n.startsWith(`?`)?n.slice(1):n;if(a)for(let n of a.split(`&`)){let a=n.indexOf(`=`);a===-1?this._entries.push([decodeComponent(n),``]):this._entries.push([decodeComponent(n.slice(0,a)),decodeComponent(n.slice(a+1))])}}else if(Array.isArray(n))for(let[a,S]of n)this._entries.push([String(a),String(S)]);else if(n instanceof URLSearchParams)this._entries=n._entries.map(([n,a])=>[n,a]);else for(let a of Object.keys(n))this._entries.push([a,String(n[a])])}get(n){for(let[a,S]of this._entries)if(a===n)return S;return null}getAll(n){return this._entries.filter(([a])=>a===n).map(([,n])=>n)}set(n,a){let S=!1;if(this._entries=this._entries.filter(([a])=>a===n?S?!1:(S=!0,!0):!0),S){for(let S=0;S<this._entries.length;S++)if(this._entries[S][0]===n){this._entries[S][1]=a;break}}else this._entries.push([n,a])}has(n){return this._entries.some(([a])=>a===n)}delete(n){this._entries=this._entries.filter(([a])=>a!==n)}append(n,a){this._entries.push([n,a])}sort(){this._entries.sort((n,a)=>n[0]<a[0]?-1:+(n[0]>a[0]))}toString(){return this._entries.map(([n,a])=>encodeComponent(n)+`=`+encodeComponent(a)).join(`&`)}forEach(n){for(let[a,S]of this._entries)n(S,a,this)}*entries(){yield*this._entries}*keys(){for(let[n]of this._entries)yield n}*values(){for(let[,n]of this._entries)yield n}[Symbol.iterator](){return this.entries()}get size(){return this._entries.length}},fn=class URL{#e;#t;constructor(n,a){let S=n instanceof URL?n.href:String(n);try{if(a!==void 0){let n=a instanceof URL?a.href:String(a),C=Z.Uri.parse(n,un);this.#e=C.parse_relative(S,un)}else this.#e=Z.Uri.parse(S,un)}catch{throw TypeError(`Invalid URL: ${S}`)}if(!this.#e)throw TypeError(`Invalid URL: ${S}`);this.#t=new dn(this.#e.get_query()||``)}get protocol(){return this.#e.get_scheme()+`:`}get hostname(){return(this.#e.get_host()||``).toLowerCase()}get port(){let n=this.#e.get_port();if(n===-1)return``;let a=this.#e.get_scheme();return(a===`http`||a===`ws`)&&n===80||(a===`https`||a===`wss`)&&n===443||a===`ftp`&&n===21?``:String(n)}get host(){let n=this.hostname,a=this.port;return a?`${n}:${a}`:n}get pathname(){return this.#e.get_path()||`/`}get search(){let n=this.#e.get_query();return n?`?`+n:``}get hash(){let n=this.#e.get_fragment();return n?`#`+n:``}get origin(){let n=this.protocol;return n===`http:`||n===`https:`||n===`ftp:`?`${n}//${this.host}`:`null`}get username(){return this.#e.get_user()||``}get password(){return this.#e.get_password()||``}get href(){let n=this.protocol,a=this.#e.get_scheme();(a===`http`||a===`https`||a===`ftp`||a===`file`||a===`ws`||a===`wss`||this.hostname)&&(n+=`//`);let S=this.username,C=this.password;S&&(n+=S,C&&(n+=`:`+C),n+=`@`),n+=this.hostname,this.port&&(n+=`:`+this.port);let N=this.pathname;return n+=N,n+=this.search,n+=this.hash,n}get searchParams(){return this.#t}toString(){return this.href}toJSON(){return this.href}static _objectURLPaths=new Map;static _objectURLCounter=0;static createObjectURL(n){let a=n?._tmpPath;if(typeof a==`string`&&a.length>0){let n=`file://${a}`;return URL._objectURLPaths.set(n,a),n}return`file:///dev/null`}static revokeObjectURL(n){let a=URL._objectURLPaths.get(n);if(a){try{Z.unlink(a)}catch{}URL._objectURLPaths.delete(n)}}},__name$1(parse$4,`parse`),__name$1(format$4,`format`),__name$1(resolve$3,`resolve`),pn={URL:fn,URLSearchParams:dn,parse:parse$4,format:format$4,resolve:resolve$3,fileURLToPath,pathToFileURL,domainToASCII,domainToUnicode}});mn(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:fn,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:dn,enumerable:!1,writable:!0,configurable:!0});var hn=__exportAll$3({PerformanceEntry:()=>yn,PerformanceMark:()=>xn,PerformanceMeasure:()=>Sn,PerformanceObserver:()=>vn,PerformanceObserverEntryList:()=>bn,default:()=>Cn,eventLoopUtilization:()=>eventLoopUtilization,monitorEventLoopDelay:()=>monitorEventLoopDelay,performance:()=>gn,timerify:()=>timerify});function eventLoopUtilization(n,a){return{idle:0,active:0,utilization:0}}function timerify(n){let wrapped=function(...a){let S=gn.now(),C=n.apply(this,a);return gn.now()-S,C};return Object.defineProperty(wrapped,"name",{value:n.name}),wrapped}function monitorEventLoopDelay(n){let a=new Map;return{enable(){},disable(){},reset(){},percentile(n){return 0},get min(){return 0},get max(){return 0},get mean(){return 0},get stddev(){return 0},get percentiles(){return a}}}var gn,PerformanceObserverStub,PerformanceEntryStub,PerformanceObserverEntryListStub,_n,vn,yn,bn,xn,Sn,Cn,wn=__esmMin(()=>{if(globalThis.performance)gn=globalThis.performance;else{let n,_now;try{let a=globalThis.imports?.gi?.GLib;if(!a)throw Error(`GJS imports.gi.GLib not available`);n=a.get_monotonic_time(),_now=()=>(a.get_monotonic_time()-n)/1e3}catch{let a=Date.now();n=0,_now=()=>Date.now()-a}let a=[],S=Date.now()-_now();gn={timeOrigin:S,now:_now,mark(n){let S={name:n,entryType:`mark`,startTime:_now(),duration:0};return a.push(S),S},measure(n,S,C){let N=0,F=_now();if(S){let n=a.find(n=>n.entryType===`mark`&&n.name===S);n&&(N=n.startTime)}if(C){let n=a.find(n=>n.entryType===`mark`&&n.name===C);n&&(F=n.startTime)}let I={name:n,entryType:`measure`,startTime:N,duration:F-N};return a.push(I),I},getEntries(){return[...a]},getEntriesByName(n){return a.filter(a=>a.name===n)},getEntriesByType(n){return a.filter(a=>a.entryType===n)},clearMarks(n){for(let S=a.length-1;S>=0;S--)a[S].entryType===`mark`&&(!n||a[S].name===n)&&a.splice(S,1)},clearMeasures(n){for(let S=a.length-1;S>=0;S--)a[S].entryType===`measure`&&(!n||a[S].name===n)&&a.splice(S,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:S}}}}PerformanceObserverStub=class{_callback;constructor(n){this._callback=n}observe(n){}disconnect(){}takeRecords(){return[]}},PerformanceEntryStub=class{name=``;entryType=``;startTime=0;duration=0;toJSON(){return{name:this.name,entryType:this.entryType,startTime:this.startTime,duration:this.duration}}},PerformanceObserverEntryListStub=class{getEntries(){return[]}getEntriesByName(n){return[]}getEntriesByType(n){return[]}},_n=globalThis,vn=_n.PerformanceObserver||PerformanceObserverStub,yn=_n.PerformanceEntry||PerformanceEntryStub,bn=_n.PerformanceObserverEntryList||PerformanceObserverEntryListStub,xn=_n.PerformanceMark||class PerformanceMark extends PerformanceEntryStub{},Sn=_n.PerformanceMeasure||class PerformanceMeasure extends PerformanceEntryStub{},Cn={performance:gn,PerformanceObserver:vn,PerformanceEntry:yn,PerformanceObserverEntryList:bn,PerformanceMark:xn,PerformanceMeasure:Sn,eventLoopUtilization,timerify,monitorEventLoopDelay}});wn();const Tn=globalThis;globalThis.performance===void 0&&(Tn.performance=gn),typeof Tn.PerformanceObserver!=`function`&&(Tn.PerformanceObserver=vn);const En={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25};var _DOMExceptionPolyfill=class extends Error{code;constructor(n,a){super(n),this.name=a||`Error`,this.code=Object.hasOwn(En,this.name)?En[this.name]:0}};const Q=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;Ae();const Dn=Symbol(`type`),On=Symbol(`bubbles`),kn=Symbol(`cancelable`),An=Symbol(`composed`),jn=Symbol(`target`),Mn=Symbol(`currentTarget`),Nn=Symbol(`eventPhase`),Pn=Symbol(`defaultPrevented`),Fn=Symbol(`isTrusted`),In=Symbol(`timeStamp`),Ln=Symbol(`stop`),Rn=Symbol(`immediateStop`),zn=Symbol(`dispatching`),Bn=Symbol(`inPassiveListener`);var Event=class{[Dn];[On];[kn];[An];[jn]=null;[Mn]=null;[Nn]=0;[Pn]=!1;[Fn]=!1;[In];[Ln]=!1;[Rn]=!1;[zn]=!1;[Bn]=!1;get type(){return this[Dn]}get bubbles(){return this[On]}get cancelable(){return this[kn]}get composed(){return this[An]}get target(){return this[jn]}get currentTarget(){return this[Mn]}get eventPhase(){return this[Nn]}get defaultPrevented(){return this[Pn]}get timeStamp(){return this[In]}get cancelBubble(){return this[Ln]}set cancelBubble(n){n&&this.stopPropagation()}get returnValue(){return!this[Pn]}set returnValue(n){n||this.preventDefault()}get srcElement(){return this[jn]}static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;get[Symbol.toStringTag](){return`Event`}constructor(n,a){this[Dn]=n,this[On]=a?.bubbles??!1,this[kn]=a?.cancelable??!1,this[An]=a?.composed??!1,this[In]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[Fn],enumerable:!0,configurable:!1})}composedPath(){return this[Mn]?[this[Mn]]:[]}preventDefault(){this[kn]&&!this[Bn]&&(this[Pn]=!0)}stopPropagation(){this[Ln]=!0}stopImmediatePropagation(){this[Ln]=!0,this[Rn]=!0}},EventTarget=class{_listeners=new Map;get[Symbol.toStringTag](){return`EventTarget`}addEventListener(n,a,S){if(a===null)return;let C=typeof S==`boolean`?S:S?.capture??!1,N=typeof S==`object`?S?.once??!1:!1,F=typeof S==`object`?S?.passive??!1:!1,I=this._listeners.get(n);I||(I=[],this._listeners.set(n,I));for(let n of I)if(n.listener===a&&n.capture===C)return;let H={listener:a,capture:C,once:N,passive:F,removed:!1};I.push(H),typeof S==`object`&&S?.signal&&S.signal.addEventListener(`abort`,()=>{this.removeEventListener(n,a,{capture:C})},{once:!0})}removeEventListener(n,a,S){if(a===null)return;let C=typeof S==`boolean`?S:S?.capture??!1,N=this._listeners.get(n);if(!N)return;let F=N.findIndex(n=>n.listener===a&&n.capture===C);F!==-1&&(N[F].removed=!0,N.splice(F,1),N.length===0&&this._listeners.delete(n))}dispatchEvent(n){let a=n;if(a[zn])throw new Q(`The event is already being dispatched.`,`InvalidStateError`);a[zn]=!0,a[jn]=this,a[Mn]=this,a[Nn]=Event.AT_TARGET;let S=this._listeners.get(n.type);if(S){let C=[...S];for(let S of C)if(!S.removed){if(a[Rn]||a[Ln])break;S.once&&this.removeEventListener(n.type,S.listener,{capture:S.capture});try{S.passive&&(a[Bn]=!0),typeof S.listener==`function`?S.listener.call(this,n):typeof S.listener.handleEvent==`function`&&S.listener.handleEvent.call(S.listener,n)}catch(n){let a=globalThis;if(typeof a.reportError==`function`)try{a.reportError(n)}catch{}else if(n instanceof Error){let a=`${n.name}: ${n.message}`;ke.error(n.stack?`${a}\n${n.stack}`:a)}else ke.error(String(n))}finally{a[Bn]=!1}}}return a[Nn]=Event.NONE,a[Mn]=null,a[zn]=!1,!n.defaultPrevented}};for(let[n,a]of[[`NONE`,0],[`CAPTURING_PHASE`,1],[`AT_TARGET`,2],[`BUBBLING_PHASE`,3]])Object.defineProperty(Event.prototype,n,{value:a,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Event,n,{value:a,writable:!1,enumerable:!0,configurable:!1});const Vn=Symbol(`abort`),Hn=Symbol(`internal`);var Un=class AbortSignal extends EventTarget{#e=!1;reason=void 0;onabort=null;constructor(n){if(super(),n!==Hn)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.reason}[Vn](n){if(this.#e)return;this.#e=!0,this.reason=n??new Q(`The operation was aborted.`,`AbortError`);let a=new Event(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,a),this.dispatchEvent(a)}static abort(n){let a=new AbortSignal(Hn);return a[Vn](n),a}static timeout(n){let a=new AbortSignal(Hn);return setTimeout(()=>{a[Vn](new Q(`The operation timed out.`,`TimeoutError`))},n),a}static any(n){let a=new AbortSignal(Hn);for(let S of n)if(S.aborted)return a[Vn](S.reason),a;let onAbort=()=>{if(!a.aborted){let S=n.find(n=>n.aborted);a[Vn](S?.reason)}};for(let a of n)a.addEventListener(`abort`,onAbort,{once:!0});return a}},Wn=class AbortController{signal;constructor(){this.signal=new Un(Hn)}abort(n){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[Vn](n)}};const Gn=globalThis;globalThis.AbortController===void 0&&(Gn.AbortController=Wn),globalThis.AbortSignal===void 0&&(Gn.AbortSignal=Un);const Kn=Symbol(`kState`),qn=Symbol(`kType`);function isBrandCheck(n){return a=>typeof a==`object`&&!!a&&a[Kn]!==void 0&&a[qn]===n}function dequeueValue(n){let a=n[Kn].queue.shift();if(a===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:S,size:C}=a;return n[Kn].queueTotalSize=Math.max(0,n[Kn].queueTotalSize-C),S}function resetQueue(n){n[Kn].queue=[],n[Kn].queueTotalSize=0}function peekQueueValue(n){return n[Kn].queue[0].value}function enqueueValueWithSize(n,a,S){if(S=+S,typeof S!=`number`||S<0||Number.isNaN(S)||S===1/0)throw RangeError(`Invalid size: ${S}`);n[Kn].queue.push({value:a,size:S}),n[Kn].queueTotalSize+=S}function extractHighWaterMark(n,a){if(n===void 0)return a;if(n=+n,typeof n!=`number`||Number.isNaN(n)||n<0)throw RangeError(`Invalid highWaterMark: ${n}`);return n}function extractSizeAlgorithm(n){if(n===void 0)return()=>1;if(typeof n!=`function`)throw TypeError(`strategy.size must be a function`);return n}function transferArrayBuffer(n){return typeof ArrayBuffer.prototype.transfer==`function`?n.transfer():n.slice(0)}function isDetachedBuffer(n){if(typeof SharedArrayBuffer<`u`&&n instanceof SharedArrayBuffer||n.byteLength!==0)return!1;try{return n.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(n){switch(n){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(n){switch(n){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(n){n.then(()=>{},()=>{})}function createPromiseCallback(n,a,S){if(typeof a!=`function`)throw TypeError(`${n} must be a function`);return async(...n)=>a.call(S,...n)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const Jn={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(n){let a={[Symbol.iterator]:()=>n.iterator},S=(async function*(){return yield*a})();return{iterator:S,nextMethod:S.next,done:!1}}function getIterator(n,a=`sync`,S){if(S===void 0)if(a===`async`){if(S=n[Symbol.asyncIterator],S==null){let a=n[Symbol.iterator];if(a===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(n,`sync`,a))}}else S=n[Symbol.iterator];if(S===void 0)throw TypeError(`Object is not iterable`);let C=S.call(n);if(typeof C!=`object`||!C)throw TypeError(`The iterator method must return an object`);return{iterator:C,nextMethod:C.next,done:!1}}function iteratorNext(n,a){let S;if(S=a===void 0?n.nextMethod.call(n.iterator):n.nextMethod.call(n.iterator,a),typeof S!=`object`||!S)throw TypeError(`The iterator.next() method must return an object`);return S}const Yn=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(n){this.signal.aborted=!0,this.signal.reason=n}},Xn=Symbol(`kAbort`),Zn=Symbol(`kCloseSentinel`),Qn=Symbol(`kError`),$n=Symbol(`kSkipThrow`);var WritableStream=class{[qn]=`WritableStream`;[Kn];constructor(n={},a={}){if(n!=null&&typeof n!=`object`)throw TypeError(`sink must be an object`);if(a!=null&&typeof a!=`object`)throw TypeError(`strategy must be an object`);let S=n?.type;if(S!==void 0)throw RangeError(`Invalid type: ${S}`);this[Kn]=createWritableStreamState();let C=extractSizeAlgorithm(a?.size),N=extractHighWaterMark(a?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,n,N,C)}get locked(){if(!er(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(n){return er(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,n):Promise.reject(TypeError(`Invalid this`))}close(){return er(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!er(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[qn]=`WritableStreamDefaultWriter`;[Kn];constructor(n){if(!er(n))throw TypeError(`Expected a WritableStream`);this[Kn]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,n)}get closed(){return tr(this)?this[Kn].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!tr(this))throw TypeError(`Invalid this`);if(this[Kn].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return tr(this)?this[Kn].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(n){return tr(this)?this[Kn].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,n):Promise.reject(TypeError(`Invalid this`))}close(){if(!tr(this))return Promise.reject(TypeError(`Invalid this`));let{stream:n}=this[Kn];return n===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(n)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!tr(this))throw TypeError(`Invalid this`);let{stream:n}=this[Kn];n!==void 0&&writableStreamDefaultWriterRelease(this)}write(n){return tr(this)?this[Kn].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,n):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[qn]=`WritableStreamDefaultController`;[Kn];constructor(n){if(n!==$n)throw TypeError(`Illegal constructor`)}[Xn](n){let a=this[Kn].abortAlgorithm(n);return writableStreamDefaultControllerClearAlgorithms(this),a}[Qn](){resetQueue(this)}get signal(){if(!nr(this))throw TypeError(`Invalid this`);return this[Kn].abortController.signal}error(n){if(!nr(this))throw TypeError(`Invalid this`);this[Kn].stream[Kn].state===`writable`&&writableStreamDefaultControllerError(this,n)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const er=isBrandCheck(`WritableStream`),tr=isBrandCheck(`WritableStreamDefaultWriter`),nr=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(n){return n[Kn].writer!==void 0}function setupWritableStreamDefaultWriter(n,a){if(isWritableStreamLocked(a))throw TypeError(`WritableStream is locked`);switch(n[Kn].stream=a,a[Kn].writer=n,a[Kn].state){case`writable`:!writableStreamCloseQueuedOrInFlight(a)&&a[Kn].backpressure?n[Kn].ready=Promise.withResolvers():n[Kn].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},n[Kn].close=Promise.withResolvers();break;case`erroring`:n[Kn].ready={promise:Promise.reject(a[Kn].storedError),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].ready.promise),n[Kn].close=Promise.withResolvers();break;case`closed`:n[Kn].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},n[Kn].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:n[Kn].ready={promise:Promise.reject(a[Kn].storedError),resolve:void 0,reject:void 0},n[Kn].close={promise:Promise.reject(a[Kn].storedError),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].ready.promise),setPromiseHandled(n[Kn].close.promise)}}function writableStreamAbort(n,a){let{state:S,controller:C}=n[Kn];if(S===`closed`||S===`errored`)return Promise.resolve();if(C[Kn].abortController.abort(a),n[Kn].pendingAbortRequest.abort.promise!==void 0)return n[Kn].pendingAbortRequest.abort.promise;let N=!1;S===`erroring`&&(N=!0,a=void 0);let F=Promise.withResolvers();return n[Kn].pendingAbortRequest={abort:F,reason:a,wasAlreadyErroring:N},N||writableStreamStartErroring(n,a),F.promise}function writableStreamClose(n){let{state:a,writer:S,backpressure:C,controller:N}=n[Kn];if(a===`closed`||a===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));n[Kn].closeRequest=Promise.withResolvers();let{promise:F}=n[Kn].closeRequest;return S!==void 0&&C&&a===`writable`&&S[Kn].ready.resolve?.(),writableStreamDefaultControllerClose(N),F}function writableStreamUpdateBackpressure(n,a){let{writer:S}=n[Kn];S!==void 0&&n[Kn].backpressure!==a&&(a?S[Kn].ready=Promise.withResolvers():S[Kn].ready.resolve?.()),n[Kn].backpressure=a}function writableStreamStartErroring(n,a){let{controller:S,writer:C}=n[Kn];n[Kn].state=`erroring`,n[Kn].storedError=a,C!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(C,a),!writableStreamHasOperationMarkedInFlight(n)&&S[Kn].started&&writableStreamFinishErroring(n)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(n){n[Kn].closeRequest.promise!==void 0&&(n[Kn].closeRequest.reject?.(n[Kn].storedError),n[Kn].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(n[Kn].close.promise),n[Kn].close.reject?.(n[Kn].storedError);let{writer:a}=n[Kn];a!==void 0&&(setPromiseHandled(a[Kn].close.promise),a[Kn].close.reject?.(n[Kn].storedError))}function writableStreamMarkFirstWriteRequestInFlight(n){let a=n[Kn].writeRequests.shift();n[Kn].inFlightWriteRequest=a}function writableStreamMarkCloseRequestInFlight(n){n[Kn].inFlightCloseRequest=n[Kn].closeRequest,n[Kn].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(n){return n[Kn].inFlightWriteRequest.promise!==void 0||n[Kn].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(n,a){n[Kn].inFlightWriteRequest.reject?.(a),n[Kn].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(n,a)}function writableStreamFinishInFlightWrite(n){n[Kn].inFlightWriteRequest.resolve?.(),n[Kn].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(n,a){n[Kn].inFlightCloseRequest.reject?.(a),n[Kn].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},n[Kn].pendingAbortRequest.abort.promise!==void 0&&(n[Kn].pendingAbortRequest.abort.reject?.(a),n[Kn].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(n,a)}function writableStreamFinishInFlightClose(n){n[Kn].inFlightCloseRequest.resolve?.(),n[Kn].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},n[Kn].state===`erroring`&&(n[Kn].storedError=void 0,n[Kn].pendingAbortRequest.abort.promise!==void 0&&(n[Kn].pendingAbortRequest.abort.resolve?.(),n[Kn].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),n[Kn].state=`closed`,n[Kn].writer!==void 0&&n[Kn].writer[Kn].close.resolve?.(),n[Kn].close.resolve?.()}function writableStreamFinishErroring(n){n[Kn].state=`errored`,n[Kn].controller[Qn]();let a=n[Kn].storedError;for(let S of n[Kn].writeRequests)S.reject?.(a);if(n[Kn].writeRequests=[],n[Kn].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(n);return}let S=n[Kn].pendingAbortRequest;if(n[Kn].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},S.wasAlreadyErroring){S.abort.reject?.(a),writableStreamRejectCloseAndClosedPromiseIfNeeded(n);return}n[Kn].controller[Xn](S.reason).then(()=>{S.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(n)},a=>{S.abort.reject?.(a),writableStreamRejectCloseAndClosedPromiseIfNeeded(n)})}function writableStreamDealWithRejection(n,a){if(n[Kn].state===`writable`){writableStreamStartErroring(n,a);return}writableStreamFinishErroring(n)}function writableStreamCloseQueuedOrInFlight(n){return n[Kn].closeRequest.promise!==void 0||n[Kn].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(n){let{promise:a,resolve:S,reject:C}=Promise.withResolvers();return n[Kn].writeRequests.push({promise:a,resolve:S,reject:C}),a}function writableStreamDefaultWriterWrite(n,a){let{stream:S}=n[Kn],{controller:C}=S[Kn],N=writableStreamDefaultControllerGetChunkSize(C,a);if(S!==n[Kn].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:F}=S[Kn];if(F===`errored`)return Promise.reject(S[Kn].storedError);if(writableStreamCloseQueuedOrInFlight(S)||F===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(F===`erroring`)return Promise.reject(S[Kn].storedError);let I=writableStreamAddWriteRequest(S);return writableStreamDefaultControllerWrite(C,a,N),I}function writableStreamDefaultWriterRelease(n){let{stream:a}=n[Kn],S=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(n,S),writableStreamDefaultWriterEnsureClosedPromiseRejected(n,S),a[Kn].writer=void 0,n[Kn].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(n){let{stream:a}=n[Kn];switch(a[Kn].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(a[Kn].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(n,a){n[Kn].ready.reject?(n[Kn].ready.reject(a),n[Kn].ready.resolve=void 0,n[Kn].ready.reject=void 0):n[Kn].ready={promise:Promise.reject(a),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(n,a){n[Kn].close.reject?(n[Kn].close.reject(a),n[Kn].close.resolve=void 0,n[Kn].close.reject=void 0):n[Kn].close={promise:Promise.reject(a),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(n){let{stream:a}=n[Kn],{state:S}=a[Kn];return writableStreamCloseQueuedOrInFlight(a)||S===`closed`?Promise.resolve():S===`errored`?Promise.reject(a[Kn].storedError):writableStreamDefaultWriterClose(n)}function writableStreamDefaultWriterClose(n){return writableStreamClose(n[Kn].stream)}function writableStreamDefaultWriterAbort(n,a){return writableStreamAbort(n[Kn].stream,a)}function writableStreamDefaultControllerWrite(n,a,S){try{enqueueValueWithSize(n,a,S)}catch(a){writableStreamDefaultControllerErrorIfNeeded(n,a);return}let{stream:C}=n[Kn];!writableStreamCloseQueuedOrInFlight(C)&&C[Kn].state===`writable`&&writableStreamUpdateBackpressure(C,writableStreamDefaultControllerGetBackpressure(n)),writableStreamDefaultControllerAdvanceQueueIfNeeded(n)}function writableStreamDefaultControllerProcessWrite(n,a){let{stream:S,writeAlgorithm:C}=n[Kn];writableStreamMarkFirstWriteRequestInFlight(S),C(a,n).then(()=>{writableStreamFinishInFlightWrite(S);let{state:a}=S[Kn];dequeueValue(n),!writableStreamCloseQueuedOrInFlight(S)&&a===`writable`&&writableStreamUpdateBackpressure(S,writableStreamDefaultControllerGetBackpressure(n)),writableStreamDefaultControllerAdvanceQueueIfNeeded(n)},a=>{S[Kn].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(n),writableStreamFinishInFlightWriteWithError(S,a)})}function writableStreamDefaultControllerProcessClose(n){let{closeAlgorithm:a,stream:S}=n[Kn];writableStreamMarkCloseRequestInFlight(S),dequeueValue(n);let C=a();writableStreamDefaultControllerClearAlgorithms(n),C.then(()=>writableStreamFinishInFlightClose(S),n=>writableStreamFinishInFlightCloseWithError(S,n))}function writableStreamDefaultControllerGetDesiredSize(n){return n[Kn].highWaterMark-n[Kn].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(n,a){let{sizeAlgorithm:S}=n[Kn];if(S===void 0)return 1;try{return S(a)}catch(a){return writableStreamDefaultControllerErrorIfNeeded(n,a),1}}function writableStreamDefaultControllerErrorIfNeeded(n,a){n[Kn].stream[Kn].state===`writable`&&writableStreamDefaultControllerError(n,a)}function writableStreamDefaultControllerError(n,a){writableStreamDefaultControllerClearAlgorithms(n),writableStreamStartErroring(n[Kn].stream,a)}function writableStreamDefaultControllerClose(n){enqueueValueWithSize(n,Zn,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(n)}function writableStreamDefaultControllerClearAlgorithms(n){n[Kn].writeAlgorithm=void 0,n[Kn].closeAlgorithm=void 0,n[Kn].abortAlgorithm=void 0,n[Kn].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(n){return writableStreamDefaultControllerGetDesiredSize(n)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(n){let{queue:a,started:S,stream:C}=n[Kn];if(!S||C[Kn].inFlightWriteRequest.promise!==void 0)return;if(C[Kn].state===`erroring`){writableStreamFinishErroring(C);return}if(!a.length)return;let N=peekQueueValue(n);N===Zn?writableStreamDefaultControllerProcessClose(n):writableStreamDefaultControllerProcessWrite(n,N)}function setupWritableStreamDefaultControllerFromSink(n,a,S,C){let N=new WritableStreamDefaultController($n),F=a?.start,I=a?.write,H=a?.close,W=a?.abort;setupWritableStreamDefaultController(n,N,F?F.bind(a,N):nonOpStart,I?createPromiseCallback(`sink.write`,I,a):nonOpWrite,H?createPromiseCallback(`sink.close`,H,a):nonOpCancel,W?createPromiseCallback(`sink.abort`,W,a):nonOpCancel,S,C)}function setupWritableStreamDefaultController(n,a,S,C,N,F,I,H){a[Kn]={abortAlgorithm:F,closeAlgorithm:N,highWaterMark:I,queue:[],queueTotalSize:0,abortController:new Yn,sizeAlgorithm:H,started:!1,stream:n,writeAlgorithm:C},n[Kn].controller=a,writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(a));let W=S();new Promise(n=>n(W)).then(()=>{a[Kn].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(a)},S=>{a[Kn].started=!0,writableStreamDealWithRejection(n,S)})}function createWritableStream(n,a,S,C,N=1,F=()=>1){let I=Object.create(WritableStream.prototype);return I[qn]=`WritableStream`,I[Kn]=createWritableStreamState(),setupWritableStreamDefaultController(I,new WritableStreamDefaultController($n),n,a,S,C,N,F),I}Xe();const rr=Symbol(`kCancel`),ir=Symbol(`kClose`),ar=Symbol(`kChunk`),sr=Symbol(`kError`),cr=Symbol(`kPull`),lr=Symbol(`kRelease`),ur=Symbol(`kSkipThrow`);let dr,fr;function lazyReadableReleasedError(){return dr||(dr=TypeError(`Reader released`),dr)}function lazyReadableReleasingError(){return fr||(fr=TypeError(`Releasing reader`),fr)}function createAbortError$1(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let n=Error(`The operation was aborted`);return n.name=`AbortError`,n}__name$1(createAbortError$1,`createAbortError`);function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name$1(this,`ReadableStream`)}[qn]=`ReadableStream`;[Kn];constructor(n={},a={}){if(n!=null&&typeof n!=`object`)throw TypeError(`source must be an object`);if(a!=null&&typeof a!=`object`)throw TypeError(`strategy must be an object`);this[Kn]=createReadableStreamState();let S=a?.size,C=a?.highWaterMark,N=n?.type;if(N!==void 0){if(`${N}`==`bytes`){if(S!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,n,extractHighWaterMark(C,0));return}throw RangeError(`Invalid type: ${N}`)}setupReadableStreamDefaultControllerFromSource(this,n,extractHighWaterMark(C,1),extractSizeAlgorithm(S))}get locked(){if(!pr(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(n){return readableStreamFromIterable(n)}cancel(n=void 0){return pr(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,n):Promise.reject(TypeError(`Invalid this`))}getReader(n={}){if(!pr(this))throw TypeError(`Invalid this`);if(n!=null&&typeof n!=`object`)throw TypeError(`options must be an object`);let a=n?.mode;if(a===void 0)return new ReadableStreamDefaultReader(this);if(`${a}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${a}`)}pipeThrough(n,a={}){if(!pr(this))throw TypeError(`Invalid this`);let S=n?.readable;if(!pr(S))throw TypeError(`transform.readable must be a ReadableStream`);let C=n?.writable;if(!er(C))throw TypeError(`transform.writable must be a WritableStream`);if(a!=null&&typeof a!=`object`)throw TypeError(`options must be an object`);let N=a?.preventAbort,F=a?.preventCancel,I=a?.preventClose,H=a?.signal;if(H!==void 0&&!(H instanceof Object&&`aborted`in H))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(C))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,C,!!I,!!N,!!F,H)),S}pipeTo(n,a={}){try{if(!pr(this))throw TypeError(`Invalid this`);if(!er(n))throw TypeError(`destination must be a WritableStream`);if(a!=null&&typeof a!=`object`)throw TypeError(`options must be an object`);let S=a?.preventAbort,C=a?.preventCancel,N=a?.preventClose,F=a?.signal;if(F!==void 0&&!(F instanceof Object&&`aborted`in F))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(n))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,n,!!N,!!S,!!C,F)}catch(n){return Promise.reject(n)}}tee(){if(!pr(this))throw TypeError(`Invalid this`);let n=this[Kn].controller;return gr(n)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(n={}){if(!pr(this))throw TypeError(`Invalid this`);if(n!=null&&typeof n!=`object`)throw TypeError(`options must be an object`);let a=!!n?.preventCancel,S=new ReadableStreamDefaultReader(this),C={done:!1,current:void 0},N=!1;function nextSteps(){if(C.done)return Promise.resolve({done:!0,value:void 0});if(S[Kn].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:n,resolve:a,reject:N}=Promise.withResolvers();return readableStreamDefaultReaderRead(S,{[ar](n){C.current=void 0,a({value:n,done:!1})},[ir](){C.current=void 0,C.done=!0,readableStreamReaderGenericRelease(S),a({done:!0,value:void 0})},[sr](n){C.current=void 0,C.done=!0,readableStreamReaderGenericRelease(S),N(n)}}),n}async function returnSteps(n){if(C.done)return{done:!0,value:n};if(C.done=!0,S[Kn].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!a){let a=readableStreamReaderGenericCancel(S,n);return readableStreamReaderGenericRelease(S),await a,{done:!0,value:n}}return readableStreamReaderGenericRelease(S),{done:!0,value:n}}return Object.setPrototypeOf({next(){return N||=(C.current=Promise.resolve(),!0),C.current=C.current===void 0?nextSteps():C.current.then(nextSteps,nextSteps),C.current},return(n){return N=!0,C.current=C.current===void 0?returnSteps(n):C.current.then(()=>returnSteps(n),()=>returnSteps(n)),C.current},[Symbol.asyncIterator](){return this}},Jn)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Kn];constructor(){this[Kn]=Promise.withResolvers()}[ar](n){this[Kn].resolve?.({value:n,done:!1})}[ir](){this[Kn].resolve?.({value:void 0,done:!0})}[sr](n){this[Kn].reject?.(n)}get promise(){return this[Kn].promise}},ReadableStreamDefaultReader=class{[qn]=`ReadableStreamDefaultReader`;[Kn];constructor(n){if(!pr(n))throw TypeError(`Expected a ReadableStream`);this[Kn]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,n)}read(){if(!hr(this))return Promise.reject(TypeError(`Invalid this`));if(this[Kn].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let n=this[Kn].stream,a=n[Kn].controller;if(n[Kn].state===`readable`&&mr(a)&&a[Kn].queue.length>0){n[Kn].disturbed=!0;let S=dequeueValue(a);return a[Kn].closeRequested&&!a[Kn].queue.length?(readableStreamDefaultControllerClearAlgorithms(a),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(a),Promise.resolve({value:S,done:!1})}let S=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,S),S.promise}releaseLock(){if(!hr(this))throw TypeError(`Invalid this`);this[Kn].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return hr(this)?this[Kn].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(n=void 0){return hr(this)?this[Kn].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,n):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[qn]=`ReadableStreamDefaultController`;[Kn];constructor(n){if(n!==ur)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(n=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,n)}error(n=void 0){readableStreamDefaultControllerError(this,n)}[rr](n){return readableStreamDefaultControllerCancelSteps(this,n)}[cr](n){readableStreamDefaultControllerPullSteps(this,n)}[lr](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const pr=isBrandCheck(`ReadableStream`),mr=isBrandCheck(`ReadableStreamDefaultController`),hr=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(n){return n[Kn].reader!==void 0}function readableStreamCancel(n,a){switch(n[Kn].disturbed=!0,n[Kn].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(n[Kn].storedError)}readableStreamClose(n);let S=n[Kn].reader;if(S!==void 0&&readableStreamHasBYOBReader(n)){let n=S[Kn].readIntoRequests;S[Kn].readIntoRequests=[];for(let a=0;a<n.length;a++)n[a][ir](void 0)}return n[Kn].controller[rr](a).then(()=>{})}function readableStreamClose(n){n[Kn].state=`closed`,n[Kn].closedPromise.resolve();let{reader:a}=n[Kn];if(a!==void 0&&(a[Kn].close.resolve?.(),readableStreamHasDefaultReader(n))){for(let n=0;n<a[Kn].readRequests.length;n++)a[Kn].readRequests[n][ir]();a[Kn].readRequests=[]}}function readableStreamError(n,a){n[Kn].state=`errored`,n[Kn].storedError=a,setPromiseHandled(n[Kn].closedPromise.promise),n[Kn].closedPromise.reject(a);let{reader:S}=n[Kn];if(S!==void 0){if(setPromiseHandled(S[Kn].close.promise),S[Kn].close.reject?.(a),readableStreamHasDefaultReader(n)){for(let n=0;n<S[Kn].readRequests.length;n++)S[Kn].readRequests[n][sr](a);S[Kn].readRequests=[]}else if(readableStreamHasBYOBReader(n)){for(let n=0;n<S[Kn].readIntoRequests.length;n++)S[Kn].readIntoRequests[n][sr](a);S[Kn].readIntoRequests=[]}}}function readableStreamHasDefaultReader(n){let{reader:a}=n[Kn];return a===void 0?!1:a[Kn]!==void 0&&a[qn]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(n){return n[Kn].reader[Kn].readRequests.length}function readableStreamFulfillReadRequest(n,a,S){let{reader:C}=n[Kn],N=C[Kn].readRequests.shift();S?N[ir]():N[ar](a)}function readableStreamAddReadRequest(n,a){n[Kn].reader[Kn].readRequests.push(a)}function readableStreamReaderGenericCancel(n,a){let{stream:S}=n[Kn];return readableStreamCancel(S,a)}function readableStreamReaderGenericInitialize(n,a){switch(n[Kn].stream=a,a[Kn].reader=n,a[Kn].state){case`readable`:n[Kn].close=Promise.withResolvers();break;case`closed`:n[Kn].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:n[Kn].close={promise:Promise.reject(a[Kn].storedError),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].close.promise);break}}function readableStreamReaderGenericRelease(n){let{stream:a}=n[Kn],S=lazyReadableReleasedError();a[Kn].state===`readable`?n[Kn].close.reject?.(S):n[Kn].close={promise:Promise.reject(S),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].close.promise),a[Kn].controller[lr](),a[Kn].reader=void 0,n[Kn].stream=void 0}function readableStreamDefaultReaderRelease(n){readableStreamReaderGenericRelease(n),readableStreamDefaultReaderErrorReadRequests(n,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(n,a){for(let S=0;S<n[Kn].readRequests.length;++S)n[Kn].readRequests[S][sr](a);n[Kn].readRequests=[]}function readableStreamDefaultReaderRead(n,a){let{stream:S}=n[Kn];switch(S[Kn].disturbed=!0,S[Kn].state){case`closed`:a[ir]();break;case`errored`:a[sr](S[Kn].storedError);break;case`readable`:S[Kn].controller[cr](a);break}}function setupReadableStreamDefaultReader(n,a){if(isReadableStreamLocked(a))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(n,a),n[Kn].readRequests=[]}function readableStreamDefaultControllerClose(n){readableStreamDefaultControllerCanCloseOrEnqueue(n)&&(n[Kn].closeRequested=!0,n[Kn].queue.length||(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(n[Kn].stream)))}function readableStreamDefaultControllerEnqueue(n,a){if(!readableStreamDefaultControllerCanCloseOrEnqueue(n))return;let{stream:S}=n[Kn];if(isReadableStreamLocked(S)&&readableStreamGetNumReadRequests(S))readableStreamFulfillReadRequest(S,a,!1);else try{enqueueValueWithSize(n,a,n[Kn].sizeAlgorithm(a))}catch(a){throw readableStreamDefaultControllerError(n,a),a}readableStreamDefaultControllerCallPullIfNeeded(n)}function readableStreamDefaultControllerCanCloseOrEnqueue(n){let{stream:a}=n[Kn];return!n[Kn].closeRequested&&a[Kn].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(n){let{stream:a,highWaterMark:S,queueTotalSize:C}=n[Kn];switch(a[Kn].state){case`errored`:return null;case`closed`:return 0;default:return S-C}}function readableStreamDefaultControllerHasBackpressure(n){return!readableStreamDefaultControllerShouldCallPull(n)}function readableStreamDefaultControllerShouldCallPull(n){let{stream:a}=n[Kn];if(!readableStreamDefaultControllerCanCloseOrEnqueue(n)||!n[Kn].started)return!1;if(isReadableStreamLocked(a)&&readableStreamGetNumReadRequests(a))return!0;let S=readableStreamDefaultControllerGetDesiredSize(n);return S!==null&&S>0}function readableStreamDefaultControllerCallPullIfNeeded(n){if(readableStreamDefaultControllerShouldCallPull(n)){if(n[Kn].pulling){n[Kn].pullAgain=!0;return}n[Kn].pulling=!0,n[Kn].pullAlgorithm(n).then(()=>{n[Kn].pulling=!1,n[Kn].pullAgain&&(n[Kn].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(n))},a=>readableStreamDefaultControllerError(n,a))}}function readableStreamDefaultControllerClearAlgorithms(n){n[Kn].pullAlgorithm=void 0,n[Kn].cancelAlgorithm=void 0,n[Kn].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(n,a){let{stream:S}=n[Kn];S[Kn].state===`readable`&&(resetQueue(n),readableStreamDefaultControllerClearAlgorithms(n),readableStreamError(S,a))}function readableStreamDefaultControllerCancelSteps(n,a){resetQueue(n);let S=n[Kn].cancelAlgorithm?.(a)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(n),S}function readableStreamDefaultControllerPullSteps(n,a){let{stream:S,queue:C}=n[Kn];if(C.length){let N=dequeueValue(n);n[Kn].closeRequested&&!C.length?(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(S)):readableStreamDefaultControllerCallPullIfNeeded(n),a[ar](N);return}readableStreamAddReadRequest(S,a),readableStreamDefaultControllerCallPullIfNeeded(n)}function setupReadableStreamDefaultController(n,a,S,C,N,F,I){a[Kn]={cancelAlgorithm:N,closeRequested:!1,highWaterMark:F,pullAgain:!1,pullAlgorithm:C,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:I,stream:n},n[Kn].controller=a;let H=S();new Promise(n=>n(H)).then(()=>{a[Kn].started=!0,readableStreamDefaultControllerCallPullIfNeeded(a)},n=>readableStreamDefaultControllerError(a,n))}function setupReadableStreamDefaultControllerFromSource(n,a,S,C){let N=new ReadableStreamDefaultController(ur),F=a?.start,I=a?.pull,H=a?.cancel;setupReadableStreamDefaultController(n,N,F?F.bind(a,N):nonOpStart,I?createPromiseCallback(`source.pull`,I,a):nonOpPull,H?createPromiseCallback(`source.cancel`,H,a):nonOpCancel,S,C)}function createReadableStream(n,a,S,C=1,N=()=>1){let F=Object.create(ReadableStream$1.prototype);return F[qn]=`ReadableStream`,F[Kn]=createReadableStreamState(),setupReadableStreamDefaultController(F,new ReadableStreamDefaultController(ur),n,a,S,C,N),F}function readableStreamFromIterable(n){let a,S=getIterator(n,`async`),C=nonOpStart;async function pullAlgorithm(){let n=iteratorNext(S);return Promise.resolve(n).then(n=>{if(typeof n!=`object`||!n)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);n.done?readableStreamDefaultControllerClose(a[Kn].controller):readableStreamDefaultControllerEnqueue(a[Kn].controller,n.value)})}async function cancelAlgorithm(n){let a=S.iterator,C=a.return;if(C===void 0)return Promise.resolve();let N=C.call(a,n);return Promise.resolve(N).then(n=>{if(typeof n!=`object`||!n)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return a=createReadableStream(C,pullAlgorithm,cancelAlgorithm,0),a}function readableStreamPipeTo(n,a,S,C,N,F){let I,H;try{I=new ReadableStreamDefaultReader(n),H=new WritableStreamDefaultWriter(a)}catch(n){return Promise.reject(n)}n[Kn].disturbed=!0;let W=!1,{promise:K,resolve:q,reject:Y}=Promise.withResolvers(),X={currentWrite:Promise.resolve()},te;function finalize(n,a){writableStreamDefaultWriterRelease(H),readableStreamReaderGenericRelease(I),F!==void 0&&te&&(F.removeEventListener(`abort`,te),te=void 0),n?Y(a):q()}async function waitForCurrentWrite(){let n=X.currentWrite;await n,n!==X.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(n,S,C){if(W)return;if(W=!0,a[Kn].state===`writable`&&!writableStreamCloseQueuedOrInFlight(a)){waitForCurrentWrite().then(complete,n=>finalize(!0,n));return}complete();function complete(){n().then(()=>finalize(!!S,C),n=>finalize(!0,n))}}function shutdown(n,S){if(!W){if(W=!0,a[Kn].state===`writable`&&!writableStreamCloseQueuedOrInFlight(a)){waitForCurrentWrite().then(()=>finalize(!!n,S),n=>finalize(!0,n));return}finalize(!!n,S)}}function abortAlgorithm(){let S;S=F.reason&&F.reason.name===`AbortError`?createAbortError$1():F.reason;let I=[];C||I.push(()=>a[Kn].state===`writable`?writableStreamAbort(a,S):Promise.resolve()),N||I.push(()=>n[Kn].state===`readable`?readableStreamCancel(n,S):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(I.map(n=>n())).then(()=>void 0),!0,S)}function watchErrored(n,a,S){n[Kn].state===`errored`?S(n[Kn].storedError):a.then(void 0,S)}function watchClosed(n,a,S){n[Kn].state===`closed`?S():a.then(S,()=>{})}class PipeToReadRequest{[ar](n){Me(()=>{X.currentWrite=writableStreamDefaultWriterWrite(H,n),setPromiseHandled(X.currentWrite),ne.resolve(!1)})}[ir](){ne.resolve(!0)}[sr](n){ne.reject(n)}}let ne={resolve:null,reject:null};async function step(){if(W||a[Kn].backpressure&&(await H[Kn].ready.promise,W))return!0;let S=n[Kn].controller;if(n[Kn].state===`readable`&&mr(S)&&S[Kn].queue.length>0){for(;S[Kn].queue.length>0;){if(W)return!0;let C=dequeueValue(S);if(S[Kn].closeRequested&&!S[Kn].queue.length&&(readableStreamDefaultControllerClearAlgorithms(S),readableStreamClose(n)),X.currentWrite=writableStreamDefaultWriterWrite(H,C),setPromiseHandled(X.currentWrite),a[Kn].backpressure||a[Kn].state!==`writable`||writableStreamCloseQueuedOrInFlight(a))break}return readableStreamDefaultControllerCallPullIfNeeded(S),n[Kn].state===`closed`}let{promise:C,resolve:N,reject:F}=Promise.withResolvers();return ne={resolve:N,reject:F},readableStreamDefaultReaderRead(I,new PipeToReadRequest),C}async function run(){for(;!await step(););}if(F!==void 0){if(F.aborted)return abortAlgorithm(),K;te=abortAlgorithm,F.addEventListener(`abort`,te,{once:!0})}if(setPromiseHandled(run()),watchErrored(n,I[Kn].close.promise,n=>{if(!C)return shutdownWithAnAction(()=>writableStreamAbort(a,n),!0,n);shutdown(!0,n)}),watchErrored(a,H[Kn].close.promise,a=>{if(!N)return shutdownWithAnAction(()=>readableStreamCancel(n,a),!0,a);shutdown(!0,a)}),watchClosed(n,I[Kn].close.promise,()=>{if(!S)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(H));shutdown()}),writableStreamCloseQueuedOrInFlight(a)||a[Kn].state===`closed`){let a=TypeError(`Destination WritableStream is closed`);N?shutdown(!0,a):shutdownWithAnAction(()=>readableStreamCancel(n,a),!0,a)}return K}function readableStreamDefaultTee(n,a){let S=new ReadableStreamDefaultReader(n),C=!1,N=!1,F=!1,I,H,W,K,q=Promise.withResolvers();async function pullAlgorithm(){C||(C=!0,readableStreamDefaultReaderRead(S,{[ar](n){Me(()=>{C=!1;let S=n,I=n;if(!F&&a)try{I=structuredClone(I)}catch{}N||readableStreamDefaultControllerEnqueue(W[Kn].controller,S),F||readableStreamDefaultControllerEnqueue(K[Kn].controller,I)})},[ir](){Me(()=>{C=!1,N||readableStreamDefaultControllerClose(W[Kn].controller),F||readableStreamDefaultControllerClose(K[Kn].controller),(!N||!F)&&q.resolve(void 0)})},[sr](){C=!1}}))}function cancel1Algorithm(a){if(N=!0,I=a,F){let a=[I,H];q.resolve(readableStreamCancel(n,a))}return q.promise}function cancel2Algorithm(a){if(F=!0,H=a,N){let a=[I,H];q.resolve(readableStreamCancel(n,a))}return q.promise}return W=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),K=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),S[Kn].close.promise.then(void 0,n=>{readableStreamDefaultControllerError(W[Kn].controller,n),readableStreamDefaultControllerError(K[Kn].controller,n),(!N||!F)&&q.resolve(void 0)}),[W,K]}var BYOBReadIntoRequest=class{[Kn];constructor(){this[Kn]=Promise.withResolvers()}[ar](n){this[Kn].resolve?.({value:n,done:!1})}[ir](n){this[Kn].resolve?.({value:n,done:!0})}[sr](n){this[Kn].reject?.(n)}get promise(){return this[Kn].promise}},ReadableStreamBYOBReader=class{[qn]=`ReadableStreamBYOBReader`;[Kn];constructor(n){if(!pr(n))throw TypeError(`Expected a ReadableStream`);this[Kn]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,n)}read(n,a={}){if(!_r(this))return Promise.reject(TypeError(`Invalid this`));if(typeof n!=`object`||!n||!ArrayBuffer.isView(n))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let S=n.buffer,C=n.byteLength;if(C===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(S.byteLength===0)return isDetachedBuffer(S)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let N=a?.min??1;if(typeof N!=`number`||N<1||!Number.isInteger(N)||Number.isNaN(N))return Promise.reject(TypeError(`options.min must be a positive integer`));let F=n[Symbol.toStringTag];if(F!==void 0&&F!==`DataView`){if(N>n.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(N>C)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[Kn].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let I=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,n,N,I),I.promise}releaseLock(){if(!_r(this))throw TypeError(`Invalid this`);this[Kn].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return _r(this)?this[Kn].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(n=void 0){return _r(this)?this[Kn].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,n):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[qn]=`ReadableStreamBYOBRequest`;[Kn];constructor(n){if(n!==ur)throw TypeError(`Illegal constructor`)}get view(){if(!vr(this))throw TypeError(`Invalid this`);return this[Kn].view}respond(n){if(!vr(this))throw TypeError(`Invalid this`);if(this[Kn].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(n=+n,!Number.isInteger(n)||n<0||!Number.isFinite(n))throw RangeError(`bytesWritten must be a non-negative integer`);let a=this[Kn].view;if(isDetachedBuffer(a.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Kn].controller,n)}respondWithNewView(n){if(!vr(this))throw TypeError(`Invalid this`);if(this[Kn].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof n!=`object`||!n||!ArrayBuffer.isView(n))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(n.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[Kn].controller,n)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[qn]=`ReadableByteStreamController`;[Kn];constructor(n){if(n!==ur)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!gr(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!gr(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!gr(this))throw TypeError(`Invalid this`);if(this[Kn].closeRequested)throw TypeError(`Close already requested`);if(this[Kn].stream[Kn].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(n){if(!gr(this))throw TypeError(`Invalid this`);if(typeof n!=`object`||!n||!ArrayBuffer.isView(n))throw TypeError(`chunk must be an ArrayBufferView`);if(n.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(n.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[Kn].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Kn].stream[Kn].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,n)}error(n=void 0){if(!gr(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,n)}[rr](n){return readableByteStreamControllerCancelSteps(this,n)}[cr](n){readableByteStreamControllerPullSteps(this,n)}[lr](){if(this[Kn].pendingPullIntos.length>0){let n=this[Kn].pendingPullIntos[0];n.readerType=`none`,this[Kn].pendingPullIntos=[n]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const gr=isBrandCheck(`ReadableByteStreamController`),_r=isBrandCheck(`ReadableStreamBYOBReader`),vr=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(n){let{reader:a}=n[Kn];return a===void 0?!1:a[Kn]!==void 0&&a[qn]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(n){return n[Kn].reader[Kn].readIntoRequests.length}function readableStreamAddReadIntoRequest(n,a){n[Kn].reader[Kn].readIntoRequests.push(a)}function readableStreamFulfillReadIntoRequest(n,a,S){let{reader:C}=n[Kn],N=C[Kn].readIntoRequests.shift();S?N[ir](a):N[ar](a)}function setupReadableStreamBYOBReader(n,a){if(isReadableStreamLocked(a))throw TypeError(`ReadableStream is locked`);if(!gr(a[Kn].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(n,a),n[Kn].readIntoRequests=[]}function readableStreamBYOBReaderRead(n,a,S,C){let{stream:N}=n[Kn];N[Kn].disturbed=!0,N[Kn].state===`errored`?C[sr](N[Kn].storedError):readableByteStreamControllerPullInto(N[Kn].controller,a,S,C)}function readableStreamBYOBReaderRelease(n){readableStreamReaderGenericRelease(n);let a=TypeError(`Reader was released`);for(let S=0;S<n[Kn].readIntoRequests.length;S++)n[Kn].readIntoRequests[S][sr](a);n[Kn].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(n){n[Kn].pullAlgorithm=void 0,n[Kn].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(n){readableByteStreamControllerInvalidateBYOBRequest(n),n[Kn].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(n){let a=n[Kn].byobRequest;a!=null&&(a[Kn].controller=void 0,a[Kn].view=null,n[Kn].byobRequest=null)}function readableByteStreamControllerError(n,a){let{stream:S}=n[Kn];S[Kn].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(n),resetQueue(n),readableByteStreamControllerClearAlgorithms(n),readableStreamError(S,a))}function readableByteStreamControllerGetDesiredSize(n){let a=n[Kn].stream[Kn].state;return a===`errored`?null:a===`closed`?0:n[Kn].highWaterMark-n[Kn].queueTotalSize}function readableByteStreamControllerShouldCallPull(n){let{stream:a}=n[Kn];if(a[Kn].state!==`readable`||n[Kn].closeRequested||!n[Kn].started)return!1;if(readableStreamHasDefaultReader(a)&&readableStreamGetNumReadRequests(a)>0||readableStreamHasBYOBReader(a)&&readableStreamGetNumReadIntoRequests(a)>0)return!0;let S=readableByteStreamControllerGetDesiredSize(n);return S!==null&&S>0}function readableByteStreamControllerCallPullIfNeeded(n){if(readableByteStreamControllerShouldCallPull(n)){if(n[Kn].pulling){n[Kn].pullAgain=!0;return}n[Kn].pulling=!0,n[Kn].pullAlgorithm(n).then(()=>{n[Kn].pulling=!1,n[Kn].pullAgain&&(n[Kn].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(n))},a=>readableByteStreamControllerError(n,a))}}function readableByteStreamControllerHandleQueueDrain(n){n[Kn].queueTotalSize===0&&n[Kn].closeRequested?(readableByteStreamControllerClearAlgorithms(n),readableStreamClose(n[Kn].stream)):readableByteStreamControllerCallPullIfNeeded(n)}function readableByteStreamControllerEnqueueChunkToQueue(n,a,S,C){n[Kn].queue.push({buffer:a,byteOffset:S,byteLength:C}),n[Kn].queueTotalSize+=C}function readableByteStreamControllerEnqueueClonedChunkToQueue(n,a,S,C){let N;try{N=a.slice(S,S+C)}catch(a){readableByteStreamControllerError(n,a);return}readableByteStreamControllerEnqueueChunkToQueue(n,N,0,C)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(n,a){a.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(n,a.buffer,a.byteOffset,a.bytesFilled),readableByteStreamControllerShiftPendingPullInto(n)}function readableByteStreamControllerShiftPendingPullInto(n){return n[Kn].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(n,a,S){S.bytesFilled+=a}function readableByteStreamControllerConvertPullIntoDescriptor(n){let a=n.bytesFilled,S=n.elementSize,C=transferArrayBuffer(n.buffer);return n.buffer=C,new n.viewConstructor(C,n.byteOffset,a/S)}function readableByteStreamControllerCommitPullIntoDescriptor(n,a){let S=!1;n[Kn].state===`closed`&&(S=!0);let C=readableByteStreamControllerConvertPullIntoDescriptor(a);a.readerType==="default"?readableStreamFulfillReadRequest(n,C,S):readableStreamFulfillReadIntoRequest(n,C,S)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(n,a){let S=Math.min(n[Kn].queueTotalSize,a.byteLength-a.bytesFilled),C=a.bytesFilled+S,N=S,F=!1,I=C-C%a.elementSize;I>=a.minimumFill&&(N=I-a.bytesFilled,F=!0);let H=n[Kn].queue;for(;N>0;){let S=H[0],C=Math.min(N,S.byteLength),F=a.byteOffset+a.bytesFilled,I=new Uint8Array(a.buffer,F,C),W=new Uint8Array(S.buffer,S.byteOffset,C);I.set(W),S.byteLength===C?H.shift():(S.byteOffset+=C,S.byteLength-=C),n[Kn].queueTotalSize-=C,readableByteStreamControllerFillHeadPullIntoDescriptor(n,C,a),N-=C}return F}function readableByteStreamControllerFillReadRequestFromQueue(n,a){let S=n[Kn].queue.shift();n[Kn].queueTotalSize-=S.byteLength,readableByteStreamControllerHandleQueueDrain(n);let C=new Uint8Array(S.buffer,S.byteOffset,S.byteLength);a[ar](C)}function readableByteStreamControllerProcessReadRequestsUsingQueue(n){let a=n[Kn].stream[Kn].reader;for(;a[Kn].readRequests.length!==0;){if(n[Kn].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(n,a[Kn].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n){for(;n[Kn].pendingPullIntos.length!==0;){if(n[Kn].queueTotalSize===0)return;let a=n[Kn].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(n,a)&&(readableByteStreamControllerShiftPendingPullInto(n),readableByteStreamControllerCommitPullIntoDescriptor(n[Kn].stream,a))}}function readableByteStreamControllerGetBYOBRequest(n){if(n[Kn].byobRequest===null&&n[Kn].pendingPullIntos.length!==0){let a=n[Kn].pendingPullIntos[0],S=new Uint8Array(a.buffer,a.byteOffset+a.bytesFilled,a.byteLength-a.bytesFilled),C=new ReadableStreamBYOBRequest(ur);C[Kn]={controller:n,view:S},n[Kn].byobRequest=C}return n[Kn].byobRequest}function readableByteStreamControllerEnqueue(n,a){let{stream:S}=n[Kn];if(n[Kn].closeRequested||S[Kn].state!==`readable`)return;let C=a.buffer,N=a.byteLength,F=a.byteOffset;if(isDetachedBuffer(C))throw TypeError(`chunk's buffer is detached`);let I=transferArrayBuffer(C);if(n[Kn].pendingPullIntos.length!==0){let a=n[Kn].pendingPullIntos[0];if(isDetachedBuffer(a.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(n),a.buffer=transferArrayBuffer(a.buffer),a.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(n,a)}readableStreamHasDefaultReader(S)?(readableByteStreamControllerProcessReadRequestsUsingQueue(n),readableStreamGetNumReadRequests(S)===0?readableByteStreamControllerEnqueueChunkToQueue(n,I,F,N):(n[Kn].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(n),readableStreamFulfillReadRequest(S,new Uint8Array(I,F,N),!1))):readableStreamHasBYOBReader(S)?(readableByteStreamControllerEnqueueChunkToQueue(n,I,F,N),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n)):readableByteStreamControllerEnqueueChunkToQueue(n,I,F,N),readableByteStreamControllerCallPullIfNeeded(n)}function readableByteStreamControllerClose(n){let{stream:a}=n[Kn];if(!(n[Kn].closeRequested||a[Kn].state!==`readable`)){if(n[Kn].queueTotalSize>0){n[Kn].closeRequested=!0;return}if(n[Kn].pendingPullIntos.length!==0){let a=n[Kn].pendingPullIntos[0];if(a.bytesFilled%a.elementSize!==0){let a=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(n,a),a}}readableByteStreamControllerClearAlgorithms(n),readableStreamClose(a)}}function readableByteStreamControllerPullInto(n,a,S,C){let N=n[Kn].stream,F=a[Symbol.toStringTag],I,H;if(F===void 0||F===`DataView`)I=DataView,H=1;else{let n=typedArrayConstructorByTag(F);if(!n){C[sr](TypeError(`Unsupported typed array: ${F}`));return}I=n,H=elementSizeByTag(F)}let W=a.buffer,K=a.byteLength,q=a.byteOffset,Y=S*H,X;try{X=transferArrayBuffer(W)}catch(n){C[sr](n);return}let te={buffer:X,bufferByteLength:X.byteLength,byteOffset:q,byteLength:K,bytesFilled:0,minimumFill:Y,elementSize:H,viewConstructor:I,readerType:`byob`};if(n[Kn].pendingPullIntos.length!==0){n[Kn].pendingPullIntos.push(te),readableStreamAddReadIntoRequest(N,C);return}if(N[Kn].state===`closed`){let n=new I(te.buffer,te.byteOffset,0);C[ir](n);return}if(n[Kn].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(n,te)){let a=readableByteStreamControllerConvertPullIntoDescriptor(te);readableByteStreamControllerHandleQueueDrain(n),C[ar](a);return}if(n[Kn].closeRequested){let a=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(n,a),C[sr](a);return}}n[Kn].pendingPullIntos.push(te),readableStreamAddReadIntoRequest(N,C),readableByteStreamControllerCallPullIfNeeded(n)}function readableByteStreamControllerRespond(n,a){let S=n[Kn].pendingPullIntos[0];if(n[Kn].stream[Kn].state===`closed`){if(a!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(a===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(S.bytesFilled+a>S.byteLength)throw RangeError(`bytesWritten out of range`)}S.buffer=transferArrayBuffer(S.buffer),readableByteStreamControllerRespondInternal(n,a)}function readableByteStreamControllerRespondWithNewView(n,a){let S=n[Kn].pendingPullIntos[0],C=n[Kn].stream[Kn].state,N=a.byteLength,F=a.byteOffset,I=a.buffer;if(C===`closed`){if(N!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(N===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(S.byteOffset+S.bytesFilled!==F)throw RangeError(`The region specified by view does not match byobRequest`);if(S.bufferByteLength!==I.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(S.bytesFilled+N>S.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);S.buffer=transferArrayBuffer(I),readableByteStreamControllerRespondInternal(n,N)}function readableByteStreamControllerRespondInternal(n,a){let S=n[Kn].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(n),n[Kn].stream[Kn].state===`closed`?readableByteStreamControllerRespondInClosedState(n,S):readableByteStreamControllerRespondInReadableState(n,a,S),readableByteStreamControllerCallPullIfNeeded(n)}function readableByteStreamControllerRespondInClosedState(n,a){a.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(n);let S=n[Kn].stream;if(readableStreamHasBYOBReader(S))for(;readableStreamGetNumReadIntoRequests(S)>0;)readableByteStreamControllerCommitPullIntoDescriptor(S,readableByteStreamControllerShiftPendingPullInto(n))}function readableByteStreamControllerRespondInReadableState(n,a,S){if(readableByteStreamControllerFillHeadPullIntoDescriptor(n,a,S),S.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(n,S),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n);return}if(S.bytesFilled<S.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(n);let C=S.bytesFilled%S.elementSize;if(C>0){let a=S.byteOffset+S.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(n,S.buffer,a-C,C)}S.bytesFilled-=C,readableByteStreamControllerCommitPullIntoDescriptor(n[Kn].stream,S),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n)}function readableByteStreamControllerCancelSteps(n,a){readableByteStreamControllerClearPendingPullIntos(n),resetQueue(n);let S=n[Kn].cancelAlgorithm?.(a)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(n),S}function readableByteStreamControllerPullSteps(n,a){let S=n[Kn].stream;if(n[Kn].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(n,a);return}let C=n[Kn].autoAllocateChunkSize;if(C!==void 0){let S;try{S=new ArrayBuffer(C)}catch(n){a[sr](n);return}let N={buffer:S,bufferByteLength:C,byteOffset:0,byteLength:C,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};n[Kn].pendingPullIntos.push(N)}readableStreamAddReadRequest(S,a),readableByteStreamControllerCallPullIfNeeded(n)}function setupReadableByteStreamController(n,a,S,C,N,F,I){a[Kn]={cancelAlgorithm:N,closeRequested:!1,highWaterMark:F,pullAgain:!1,pullAlgorithm:C,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:n,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:I},n[Kn].controller=a;let H=S();new Promise(n=>n(H)).then(()=>{a[Kn].started=!0,readableByteStreamControllerCallPullIfNeeded(a)},n=>readableByteStreamControllerError(a,n))}function setupReadableByteStreamControllerFromSource(n,a,S){let C=new ReadableByteStreamController(ur),N=a?.start,F=a?.pull,I=a?.cancel,H=a?.autoAllocateChunkSize;if(H!==void 0&&(H===0||!Number.isInteger(H)||H<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(n,C,N?N.bind(a,C):nonOpStart,F?createPromiseCallback(`source.pull`,F,a):nonOpPull,I?createPromiseCallback(`source.cancel`,I,a):nonOpCancel,S,H)}function readableByteStreamTee(n){let a=new ReadableStreamDefaultReader(n),S=!1,C=!1,N=!1,F,I,H=Promise.withResolvers(),W,K,q,Y;function pullAlgorithm(){return S?Promise.resolve():(S=!0,a.read().then(n=>{if(S=!1,n.done){C||q.close(),N||Y.close();return}let a=n.value,F=new Uint8Array(a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength));C||q.enqueue(F),N||Y.enqueue(new Uint8Array(F))},()=>{}),Promise.resolve())}return W=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(a){if(C=!0,F=a,N){let a=readableStreamCancel(n,[F,I]);return H.resolve(),a}return H.promise}}),K=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(a){if(N=!0,I=a,C){let a=readableStreamCancel(n,[F,I]);return H.resolve(),a}return H.promise}}),q=W[Kn].controller,Y=K[Kn].controller,a.closed.catch(n=>{q.error(n),Y.error(n),(!C||!N)&&H.resolve()}),[W,K]}const yr=Symbol(`kSkipThrow`);var TransformStream=class{[qn]=`TransformStream`;[Kn];constructor(n={},a={},S={}){if(n!=null&&typeof n!=`object`)throw TypeError(`transformer must be an object`);if(a!=null&&typeof a!=`object`)throw TypeError(`writableStrategy must be an object`);if(S!=null&&typeof S!=`object`)throw TypeError(`readableStrategy must be an object`);let C=n?.readableType,N=n?.writableType,F=n?.start;if(C!==void 0)throw RangeError(`Invalid readableType: ${C}`);if(N!==void 0)throw RangeError(`Invalid writableType: ${N}`);let I=extractHighWaterMark(S?.highWaterMark,0),H=extractSizeAlgorithm(S?.size),W=extractHighWaterMark(a?.highWaterMark,1),K=extractSizeAlgorithm(a?.size),q=Promise.withResolvers();initializeTransformStream(this,q,W,K,I,H),setupTransformStreamDefaultControllerFromTransformer(this,n),F===void 0?q.resolve():q.resolve(F.call(n,this[Kn].controller))}get readable(){if(!br(this))throw TypeError(`Invalid this`);return this[Kn].readable}get writable(){if(!br(this))throw TypeError(`Invalid this`);return this[Kn].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[qn]=`TransformStreamDefaultController`;[Kn];constructor(n){if(n!==yr)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!Sr(this))throw TypeError(`Invalid this`);let{stream:n}=this[Kn],{readable:a}=n[Kn],S=a[Kn].controller;return readableStreamDefaultControllerGetDesiredSize(S)}enqueue(n){if(!Sr(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,n)}error(n){if(!Sr(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,n)}terminate(){if(!Sr(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const br=isBrandCheck(`TransformStream`),Sr=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(n,a){transformStreamDefaultControllerEnqueue(a,n)}function initializeTransformStream(n,a,S,C,N,F){let startAlgorithm=()=>a.promise,I=createWritableStream(startAlgorithm,a=>transformStreamDefaultSinkWriteAlgorithm(n,a),()=>transformStreamDefaultSinkCloseAlgorithm(n),a=>transformStreamDefaultSinkAbortAlgorithm(n,a),S,C);n[Kn]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(n),a=>transformStreamDefaultSourceCancelAlgorithm(n,a),N,F),writable:I,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(n,!0)}function transformStreamError(n,a){let{readable:S}=n[Kn];readableStreamDefaultControllerError(S[Kn].controller,a),transformStreamErrorWritableAndUnblockWrite(n,a)}function transformStreamErrorWritableAndUnblockWrite(n,a){let{controller:S,writable:C}=n[Kn];transformStreamDefaultControllerClearAlgorithms(S),writableStreamDefaultControllerErrorIfNeeded(C[Kn].controller,a),transformStreamUnblockWrite(n)}function transformStreamUnblockWrite(n){n[Kn].backpressure&&transformStreamSetBackpressure(n,!1)}function transformStreamSetBackpressure(n,a){n[Kn].backpressureChange.promise!==void 0&&n[Kn].backpressureChange.resolve?.(),n[Kn].backpressureChange=Promise.withResolvers(),n[Kn].backpressure=a}function setupTransformStreamDefaultController(n,a,S,C,N){a[Kn]={stream:n,transformAlgorithm:S,flushAlgorithm:C,cancelAlgorithm:N,finishPromise:void 0},n[Kn].controller=a}function setupTransformStreamDefaultControllerFromTransformer(n,a){let S=new TransformStreamDefaultController(yr),C=a?.transform,N=a?.flush,F=a?.cancel;setupTransformStreamDefaultController(n,S,C?createPromiseCallback(`transformer.transform`,C,a):defaultTransformAlgorithm,N?createPromiseCallback(`transformer.flush`,N,a):nonOpFlush,F?createPromiseCallback(`transformer.cancel`,F,a):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(n){n[Kn].transformAlgorithm=void 0,n[Kn].flushAlgorithm=void 0,n[Kn].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(n,a){let{stream:S}=n[Kn],{readable:C}=S[Kn],N=C[Kn].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(N))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(N,a)}catch(n){throw transformStreamErrorWritableAndUnblockWrite(S,n),C[Kn].storedError}readableStreamDefaultControllerHasBackpressure(N)!==S[Kn].backpressure&&transformStreamSetBackpressure(S,!0)}function transformStreamDefaultControllerError(n,a){transformStreamError(n[Kn].stream,a)}async function transformStreamDefaultControllerPerformTransform(n,a){try{let S=n[Kn].transformAlgorithm;if(S===void 0)return;await S(a,n)}catch(a){throw transformStreamError(n[Kn].stream,a),a}}function transformStreamDefaultControllerTerminate(n){let{stream:a}=n[Kn],{readable:S}=a[Kn];readableStreamDefaultControllerClose(S[Kn].controller),transformStreamErrorWritableAndUnblockWrite(a,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(n,a){let{controller:S}=n[Kn];return n[Kn].backpressure?n[Kn].backpressureChange.promise.then(()=>{let{writable:C}=n[Kn];if(C[Kn].state===`erroring`)throw C[Kn].storedError;return transformStreamDefaultControllerPerformTransform(S,a)}):transformStreamDefaultControllerPerformTransform(S,a)}async function transformStreamDefaultSinkAbortAlgorithm(n,a){let{controller:S,readable:C}=n[Kn];if(S[Kn].finishPromise!==void 0)return S[Kn].finishPromise;let{promise:N,resolve:F,reject:I}=Promise.withResolvers();S[Kn].finishPromise=N;let H=S[Kn].cancelAlgorithm(a);return transformStreamDefaultControllerClearAlgorithms(S),H.then(()=>{C[Kn].state===`errored`?I(C[Kn].storedError):(readableStreamDefaultControllerError(C[Kn].controller,a),F())},n=>{readableStreamDefaultControllerError(C[Kn].controller,n),I(n)}),S[Kn].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(n){let{readable:a,controller:S}=n[Kn];if(S[Kn].finishPromise!==void 0)return S[Kn].finishPromise;let{promise:C,resolve:N,reject:F}=Promise.withResolvers();S[Kn].finishPromise=C;let I=S[Kn].flushAlgorithm(S);return transformStreamDefaultControllerClearAlgorithms(S),I.then(()=>{a[Kn].state===`errored`?F(a[Kn].storedError):(readableStreamDefaultControllerClose(a[Kn].controller),N())},n=>{readableStreamDefaultControllerError(a[Kn].controller,n),F(n)}),S[Kn].finishPromise}function transformStreamDefaultSourcePullAlgorithm(n){return transformStreamSetBackpressure(n,!1),n[Kn].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(n,a){let{controller:S,writable:C}=n[Kn];if(S[Kn].finishPromise!==void 0)return S[Kn].finishPromise;let{promise:N,resolve:F,reject:I}=Promise.withResolvers();S[Kn].finishPromise=N;let H=S[Kn].cancelAlgorithm(a);return transformStreamDefaultControllerClearAlgorithms(S),H.then(()=>{C[Kn].state===`errored`?I(C[Kn].storedError):(writableStreamDefaultControllerErrorIfNeeded(C[Kn].controller,a),transformStreamUnblockWrite(n),F())},a=>{writableStreamDefaultControllerErrorIfNeeded(C[Kn].controller,a),transformStreamUnblockWrite(n),I(a)}),S[Kn].finishPromise}const Cr=Object.defineProperty(n=>n.byteLength,"name",{value:`size`}),wr=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(n){if(typeof n!=`object`||!n)throw TypeError(`init must be an object`);if(n.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+n.highWaterMark}get highWaterMark(){return this.#e}get size(){return Cr}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(n){if(typeof n!=`object`||!n)throw TypeError(`init must be an object`);if(n.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+n.highWaterMark}get highWaterMark(){return this.#e}get size(){return wr}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(n,a)=>{if(n=String(n),n===``)return;this.#e!==null&&(n=this.#e+n);let S=n.charCodeAt(n.length-1);55296<=S&&S<=56319?(this.#e=n.slice(-1),n=n.slice(0,-1)):this.#e=null,n&&a.enqueue(this.#t.encode(n))},flush:n=>{this.#e!==null&&n.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const Tr=hasStreamingSupport();function incompleteUtf8Tail$1(n){let a=n.length;if(a===0)return 0;for(let S=1;S<=Math.min(3,a);S++){let C=n[a-S];if(!(C&128))return 0;if((C&192)!=128){let n;if((C&224)==192)n=2;else if((C&240)==224)n=3;else if((C&248)==240)n=4;else return 0;return S<n?S:0}}return 0}__name$1(incompleteUtf8Tail$1,`incompleteUtf8Tail`);var TextDecoderStream=class{#e;#t;constructor(n,a){if(this.#e=new TextDecoder(n,a),Tr)this.#t=new TransformStream({transform:(n,a)=>{let S=toUint8Array$3(n),C=this.#e.decode(S,{stream:!0});C&&a.enqueue(C)},flush:n=>{let a=this.#e.decode();a&&n.enqueue(a)},cancel:()=>{this.#e.decode()}});else{let n=new Uint8Array;this.#t=new TransformStream({transform:(a,S)=>{let C=toUint8Array$3(a),N;n.length>0?(N=new Uint8Array(n.length+C.length),N.set(n,0),N.set(C,n.length)):N=C;let F=incompleteUtf8Tail$1(N),I;if(F>0?(I=N.slice(0,N.length-F),n=N.slice(N.length-F)):(I=N,n=new Uint8Array),I.length>0){let n=this.#e.decode(I);n&&S.enqueue(n)}},flush:a=>{if(n.length>0){let S=this.#e.decode(n);S&&a.enqueue(S),n=new Uint8Array}},cancel:()=>{n=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$3(n){if(n instanceof Uint8Array)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name$1(toUint8Array$3,`toUint8Array`);function isNativeStreamUsable$3(n,a){try{return typeof n==`function`?typeof n.prototype?.[a]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$3,`isNativeStreamUsable`);const Er=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,Dr=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Or=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,kr=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Ar=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,jr=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,Mr=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var Nr=__esmMin(()=>{Xe()});function _setPipeImpl(n){Pr=n}var Pr,Stream_,Fr=__esmMin(()=>{Kt(),Stream_=class extends Ft{constructor(n){super(n)}pipe(n,a){return Pr(this,n,a)}}});function finished$1(n,a,S){let C;C=typeof a==`function`?a:S;let N=!1;function done(n){N||(N=!0,C(n))}let onFinish=()=>done(),onEnd=()=>done(),onError=n=>done(n),onClose=()=>{let a=n,S=n;!a.writableFinished&&!S.readableEnded&&done(Error(`premature close`))};n.on(`finish`,onFinish),n.on(`end`,onEnd),n.on(`error`,onError),n.on(`close`,onClose);let F=n,I=typeof n.write==`function`,H=typeof n.read==`function`,W=F.writableFinished===!0,K=F.readableEnded===!0;if(F.destroyed===!0){let n=F._err;Me(n?()=>done(n):I&&W||H&&K?()=>done():()=>done(Error(`premature close`)))}else(I&&!H&&W||!I&&H&&K||I&&H&&W&&K)&&Me(()=>done());return function cleanup(){n.removeListener(`finish`,onFinish),n.removeListener(`end`,onEnd),n.removeListener(`error`,onError),n.removeListener(`close`,onClose)}}function addAbortSignal(n,a){if(!(n instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(a instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let S=a;if(n.aborted)S.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{S.destroy(Error(`The operation was aborted`))};n.addEventListener(`abort`,onAbort,{once:!0}),a.once(`close`,()=>{n.removeEventListener(`abort`,onAbort)})}return a}function isReadable(n){if(n==null)return!1;let a=n;return typeof a.readable!=`boolean`||typeof a.read!=`function`||a.destroyed===!0||a.readableEnded===!0?!1:a.readable===!0}function isWritable(n){if(n==null)return!1;let a=n;return typeof a.writable!=`boolean`||typeof a.write!=`function`||a.destroyed===!0||a.writableEnded===!0?!1:a.writable===!0}function isDestroyed(n){return n==null?!1:n.destroyed===!0}function isDisturbed(n){if(n==null)return!1;let a=n;return a.readableDidRead===!0||a.readableFlowing!==null&&a.readableFlowing!==void 0}function isErrored(n){if(n==null)return!1;let a=n;return a.destroyed===!0&&typeof a.readable==`boolean`&&a.readable===!1||a.destroyed===!0&&typeof a.writable==`boolean`&&a.writable===!1}var Ir=__esmMin(()=>{Fr(),Xe(),__name$1(finished$1,`finished`)});function getDefaultHighWaterMark(n){return n?Rr:Lr}function setDefaultHighWaterMark(n,a){if(typeof a!=`number`||a<0||Number.isNaN(a))throw TypeError(`Invalid highWaterMark: ${a}`);n?Rr=a:Lr=a}function validateHighWaterMark(n,a){if(a!==void 0&&(typeof a!=`number`||Number.isNaN(a))){let S=TypeError(`The value of "${n}" is invalid. Received ${a}`);throw S.code=`ERR_INVALID_ARG_VALUE`,S}}var Lr,Rr,zr=__esmMin(()=>{Lr=16384,Rr=16});function createAbortError(){let n=Error(`The operation was aborted`);return n.name=`AbortError`,n.code=`ABORT_ERR`,n}async function streamAsyncDispose(n,a){let S;n.destroyed||(S=a?void 0:createAbortError(),n.destroy(S)),await new Promise((a,C)=>{finished$1(n,n=>{n&&n!==S?C(n):a()})})}var Br,Vr=__esmMin(()=>{Ir(),Br=Symbol.asyncDispose??Symbol.for(`Symbol.asyncDispose`)});function chunkLength(n){if(n==null)return 1;let a=n.length;return typeof a==`number`?a:1}function sliceChunk(n,a,S){if(typeof n==`string`)return S===void 0?n.slice(a):n.slice(a,S);let C=n.slice;return typeof C==`function`?C.call(n,a,S):n}var Hr,Ur=__esmMin(()=>{Fr(),Vr(),zr(),Xe(),Hr=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(n){super(n),this.readableHighWaterMark=n?.highWaterMark??getDefaultHighWaterMark(n?.objectMode??!1),this.readableEncoding=n?.encoding??null,this.readableObjectMode=n?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,n?.read&&(this._readImpl=n.read),n?.destroy&&(this._destroyImpl=n.destroy),n?.construct&&(this._constructImpl=n.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(n=>{this._readableState.constructed=!0,n?this.destroy(n):this.readableFlowing===!0&&this._flow()})}))}_construct(n){this._constructImpl?this._constructImpl.call(this,n):n()}_read(n){this._readImpl&&this._readImpl.call(this,n)}read(n){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(n??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||n===0)return null;if(this.readableObjectMode){if(n===void 0){let n=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),n}if(n>this.readableLength)return null;let a=this._buffer.shift();return--this.readableLength,a}if(n!=null)return n>this.readableLength?null:this._readBytes(n);let a=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),a.length===1)return a[0];if(a.length===0)return null;if(typeof a[0]==`string`)return a.join(``);let S=globalThis.Buffer;return S?.concat?S.concat(a):a}_readBytes(n){let a=0,S=[];for(;a<n&&this._buffer.length>0;){let C=this._buffer[0],N=chunkLength(C);if(a+N<=n)S.push(this._buffer.shift()),a+=N,this.readableLength-=N;else{let N=n-a;S.push(sliceChunk(C,0,N)),this._buffer[0]=sliceChunk(C,N),this.readableLength-=N,a+=N}}if(S.length===1)return S[0];let C=globalThis.Buffer;return C?.concat?C.concat(S):S}push(n,a){if(n===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof n==`string`||ArrayBuffer.isView(n))){let a=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof n}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,a)),!1}return this._buffer.push(n),this.readableLength+=this.readableObjectMode?1:chunkLength(n),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(n,a){return super.on(n,a),n===`data`&&this.readableFlowing!==!1&&this.resume(),n===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(n){this._buffer.unshift(n),this.readableLength+=this.readableObjectMode?1:chunkLength(n)}setEncoding(n){return this.readableEncoding=n,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let n=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(n),this.readableEncoding&&typeof n!=`string`){let a=globalThis.Buffer;a?.isBuffer&&a.isBuffer(n)?n=n.toString(this.readableEncoding):n instanceof Uint8Array&&(n=new TextDecoder(this.readableEncoding).decode(n))}this.emit(`data`,n)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(n){if(n){let a=this._pipeDests.findIndex(a=>a.dest===n);if(a!==-1){this._pipeDests[a].cleanup(),this._pipeDests.splice(a,1);let S=this._readableState.pipes.indexOf(n);S!==-1&&this._readableState.pipes.splice(S,1),n.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let n of this._pipeDests)n.cleanup(),n.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(n,a){this._destroyImpl?this._destroyImpl.call(this,n,a):a(n??void 0)}destroy(n){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,n&&(this._err=n);let cb=n=>{n&&nextTick(()=>this.emit(`error`,n)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(n??null,cb):this._destroyImpl?this._destroyImpl.call(this,n??null,cb):cb(n),this}static toWeb(n){return new ReadableStream({start(a){n.on(`data`,n=>{typeof n==`string`?a.enqueue(new TextEncoder().encode(n)):n instanceof Uint8Array?a.enqueue(n):n&&typeof n.length==`number`&&a.enqueue(new Uint8Array(n))}),n.on(`end`,()=>{a.close()}),n.on(`error`,n=>{a.error(n)})},cancel(){n.destroy()}})}static fromWeb(n,a){let S=n.getReader();return new Readable_({...a,read(){S.read().then(({done:n,value:a})=>{n?this.push(null):this.push(a)},n=>{this.destroy(n)})},destroy(n,a){S.cancel(n?.message).then(()=>a(null),a)}})}[Symbol.asyncIterator](){let n=this,a=[],S=!1,C=null,N=null,F=null;return n.on(`data`,n=>{if(N){let a=N;N=null,F=null,a({value:n,done:!1})}else a.push(n)}),n.on(`end`,()=>{if(S=!0,N){let n=N;N=null,F=null,n({value:void 0,done:!0})}}),n.on(`error`,n=>{if(C=n,S=!0,F){let a=F;N=null,F=null,a(n)}}),{next(){return C?Promise.reject(C):a.length>0?Promise.resolve({value:a.shift(),done:!1}):S?Promise.resolve({value:void 0,done:!0}):new Promise((n,a)=>{N=n,F=a})},return(){return n.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(n,a){let S=new Readable_({objectMode:!0,...a,read(){}});return typeof n==`string`||ArrayBuffer.isView(n)?(S.push(n),S.push(null),S):((async()=>{try{for await(let a of n)S.push(a)||await new Promise(n=>S.once(`drain`,n));S.push(null)}catch(n){S.destroy(n)}})(),S)}},Hr.prototype[Br]=function(){return streamAsyncDispose(this,this.readableEnded)}});function chunkLen$1(n){if(n==null)return 1;let a=n.length;return typeof a==`number`?a:1}var Duplex_,Wr=__esmMin(()=>{zr(),Ur(),Xe(),Duplex_=class extends Hr{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(n){super(n),validateHighWaterMark(`writableHighWaterMark`,n?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,n?.readableHighWaterMark),this.writableObjectMode=n?.writableObjectMode??n?.objectMode??!1,this.writableHighWaterMark=n?.highWaterMark??n?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,n?.highWaterMark===void 0&&n?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=n.readableHighWaterMark,this._readableState.highWaterMark=n.readableHighWaterMark),n?.readableObjectMode!==void 0&&(this.readableObjectMode=n.readableObjectMode,this._readableState.objectMode=n.readableObjectMode,n?.readableHighWaterMark===void 0&&n?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(n.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=n?.allowHalfOpen!==!1,this._decodeStrings=n?.decodeStrings!==!1,n?.write&&(this._writeImpl=n.write),n?.final&&(this._finalImpl=n.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(n,a,S){this._writeImpl?this._writeImpl.call(this,n,a,S):S()}_final(n){this._finalImpl?this._finalImpl.call(this,n):n()}destroy(n){return this.destroyed?this:(this.writable=!1,super.destroy(n))}write(n,a,S){let C,N;if(typeof a==`function`?(C=a,N=this._defaultEncoding):(N=a??this._defaultEncoding,C=S??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof n==`string`){let a=globalThis.Buffer;a&&(n=a.from(n,N),N=`buffer`)}if(typeof n!=`string`&&!this.writableObjectMode){let a=globalThis.Buffer;(a&&a.isBuffer(n)||n instanceof Uint8Array)&&(N=`buffer`)}if(this.writableEnded){let n=Error(`write after end`);return nextTick(()=>{C(n),this.emit(`error`,n)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(n),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:n,encoding:N,callback:C}),this.writableLength<this.writableHighWaterMark;let F=this.writableLength<this.writableHighWaterMark;return F||(this.writableNeedDrain=!0),this._duplexDoWrite(n,N,C),F}_duplexDoWrite(n,a,S){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:n,encoding:a,callback:S});return}this._duplexWriting=!0,this._duplexStartWrite(n,a,S)}_duplexStartWrite(n,a,S){this._pendingWrites++,this._write(n,a,a=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(n),nextTick(a?()=>{if(S(a),this._duplexWriting=!1,this.emit(`error`,a),this._duplexWriteQueue.length>0){let n=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(n.chunk,n.encoding,n.callback)}}:()=>{if(S(),this._duplexWriteQueue.length>0){let n=this._duplexWriteQueue.shift();this._duplexStartWrite(n.chunk,n.encoding,n.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let n=this._pendingEndCb;this._pendingEndCb=null,n()}})})}end(n,a,S){typeof n==`function`&&(S=n,n=void 0),typeof a==`function`&&(S=a,a=void 0),n!=null&&this.write(n,a),this.writableEnded=!0;let doFinal=()=>{this._final(n=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{n&&this.emit(`error`,n),this.emit(`finish`),nextTick(()=>this.emit(`close`)),S&&S()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(n){n()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let n=this._duplexCorkedBuffer.splice(0);for(let{chunk:a,encoding:S,callback:C}of n)this._write(a,S,n=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(a),n?(C(n),this.emit(`error`,n)):C()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(n){return this._defaultEncoding=n,this}},__name$1(chunkLen$1,`chunkLen`)});function pipe(n,a,S){let C=n,N=S?.end!==!1,F=!1,ondrain=()=>{F=!1,a.removeListener(`drain`,ondrain);let n=C;typeof n.resume==`function`&&n.resume()},ondata=n=>{if(a.writable){let S=C;a.write(n)===!1&&typeof S.pause==`function`&&(S.pause(),F||(F=!0,a.on(`drain`,ondrain)))}};C.on(`data`,ondata);let I=!1,onend=()=>{I||(I=!0,N&&a.end())},onclose=()=>{if(!I&&(I=!0,N&&!(C instanceof Hr))){let n=a;typeof n.destroy==`function`&&n.destroy()}};N&&(C.on(`end`,onend),C.on(`close`,onclose));let cleanup=()=>{C.removeListener(`data`,ondata),F&&a.removeListener(`drain`,ondrain),C.removeListener(`end`,onend),C.removeListener(`close`,onclose),C.removeListener(`end`,cleanup),C.removeListener(`close`,cleanup),a.removeListener(`close`,cleanup)};return C.on(`end`,cleanup),C.on(`close`,cleanup),a.on(`close`,cleanup),C instanceof Hr&&(C._pipeDests.push({dest:a,cleanup}),C._readableState.pipes.push(a)),a.emit(`pipe`,C),a}var Gr=__esmMin(()=>{Fr(),Ur(),_setPipeImpl(pipe)});function chunkLen(n){if(n==null)return 1;let a=n.length;return typeof a==`number`?a:1}var Kr,qr=__esmMin(()=>{Fr(),Vr(),zr(),Xe(),Kr=class Writable_ extends Stream_{static[Symbol.hasInstance](n){let a=this;return a.prototype!==void 0&&Object.prototype.isPrototypeOf.call(a.prototype,n)?!0:a.prototype!==Writable_.prototype||n==null?!1:typeof n.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;constructor(n){super(n),this.writableHighWaterMark=n?.highWaterMark??getDefaultHighWaterMark(n?.objectMode??!1),this.writableObjectMode=n?.objectMode??!1,this._decodeStrings=n?.decodeStrings!==!1,n?.write&&(this._writeImpl=n.write),n?.writev&&(this._writev=n.writev),n?.final&&(this._finalImpl=n.final),n?.destroy&&(this._destroyImpl=n.destroy),n?.construct&&(this._constructImpl=n.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(n=>{this._writableState.constructed=!0,n?this.destroy(n):this._maybeFlush()})}))}_construct(n){this._constructImpl?this._constructImpl.call(this,n):n()}_write(n,a,S){this._writeImpl?this._writeImpl.call(this,n,a,S):S()}_final(n){this._finalImpl?this._finalImpl.call(this,n):n()}_destroy(n,a){this._destroyImpl?this._destroyImpl.call(this,n,a):a(n)}_maybeFlush(){let n=this._pendingConstruct.splice(0);if(n.length>0){let[a,...S]=n;this._writeBuffer.push(...S),this._doWrite(a.chunk,a.encoding,a.callback)}if(this._pendingEnd){let{chunk:n,encoding:a,callback:S}=this._pendingEnd;this._pendingEnd=null,this._doEnd(n,a,S)}}_doWrite(n,a,S){this._writableState.writing=!0;let C=!0;this._write(n,a,a=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(n),C){nextTick(()=>{if(a){S(a),this.emit(`error`,a);return}S(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),a||this._drainWriteBuffer();return}nextTick(a?()=>{S(a),this.emit(`error`,a),this._drainWriteBuffer()}:()=>{S(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),C=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let n=this._writeBuffer.shift();this._doWrite(n.chunk,n.encoding,n.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(n=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{n&&this.emit(`error`,n),this.emit(`finish`),nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(n,a,S){let C,N;if(typeof a==`function`?(C=a,N=this._defaultEncoding):(N=a??this._defaultEncoding,C=S??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof n==`string`){let a=globalThis.Buffer;a&&(n=a.from(n,N),N=`buffer`)}if(typeof n!=`string`&&!this.writableObjectMode){let a=globalThis.Buffer;(a&&a.isBuffer(n)||n instanceof Uint8Array)&&(N=`buffer`)}if(this.writableEnded){let n=Error(`write after end`);return nextTick(()=>{C(n),this.emit(`error`,n)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(n),this.writableCorked>0)return this._corkedBuffer.push({chunk:n,encoding:N,callback:C}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:n,encoding:N,callback:C}),this.writableLength<this.writableHighWaterMark;let F=this.writableLength<this.writableHighWaterMark;return F||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:n,encoding:N,callback:C}):this._doWrite(n,N,C),F}_doEnd(n,a,S){n!=null&&this.write(n,a),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=S,this._maybeFinish()}end(n,a,S){return typeof n==`function`&&(S=n,n=void 0),typeof a==`function`&&(S=a,a=void 0),this.writableEnded?(S&&nextTick(S),this):this._writableState.constructed?(this._doEnd(n,a,S),this):(this._pendingEnd={chunk:n,encoding:a,callback:S},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let n=this._corkedBuffer.splice(0),a=n.map(n=>({chunk:n.chunk,encoding:n.encoding}));this._writev.call(this,a,a=>{for(let a of n)this.writableLength-=this.writableObjectMode?1:chunkLen(a.chunk);if(a){for(let S of n)S.callback(a);this.emit(`error`,a)}else{for(let a of n)a.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let n=this._corkedBuffer.splice(0);if(n.length>0){let[a,...S]=n;this._writeBuffer.push(...S),this._doWrite(a.chunk,a.encoding,a.callback)}}}setDefaultEncoding(n){return this._defaultEncoding=n,this}destroy(n){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,n&&(this._err=n);let cb=n=>{n&&nextTick(()=>this.emit(`error`,n)),nextTick(()=>this.emit(`close`))};return this._destroy(n??null,cb),this}},Kr.prototype[Br]=function(){return streamAsyncDispose(this,this.writableFinished)}}),Jr,Yr=__esmMin(()=>{Wr(),Xe(),Jr=class Transform_ extends Duplex_{constructor(n){super({...n,write:void 0,final:void 0});let a=this;n?.transform&&(a._transform=n.transform),n?.flush&&(a._flush=n.flush),n?.final&&(a._final=n.final)}_transform(n,a,S){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(n){n()}_write(n,a,S){let C=!1;try{this._transform(n,a,(n,a)=>{if(C){let n=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,n));return}if(C=!0,n){S(n);return}a!=null&&this.push(a),S()})}catch(n){if(n?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw n;S(n)}}_final(n){this._flush((a,S)=>{if(a){n(a);return}S!=null&&this.push(S),this.push(null),n()})}_doPrefinishHooks(n){let a=Transform_.prototype._final;this._final===a?n():a.call(this,n)}}}),PassThrough_,Xr=__esmMin(()=>{Yr(),PassThrough_=class extends Jr{constructor(n){super({...n,transform(n,a,S){S(null,n)}})}}});function pipeline(...n){let a=n,S=typeof a[a.length-1]==`function`?a.pop():void 0,C=a;if(C.length<2)throw Error(`pipeline requires at least 2 streams`);let N=null;function onError(n){if(!N){N=n;for(let n of C)typeof n.destroy==`function`&&n.destroy();S&&S(n)}}let F=C[0];for(let n=1;n<C.length;n++){let a=C[n];F.pipe(a),F.on(`error`,onError),F=a}let I=C[C.length-1];return I.on(`error`,onError),I.on(`finish`,()=>{S&&!N&&S(null)}),I}var Zr=__esmMin(()=>{}),Qr=__exportAll$3({Duplex:()=>ni,PassThrough:()=>ii,Readable:()=>ei,Stream:()=>$r,Transform:()=>ri,Writable:()=>ti,addAbortSignal:()=>addAbortSignal,default:()=>ai,finished:()=>finished$1,getDefaultHighWaterMark:()=>getDefaultHighWaterMark,isDestroyed:()=>isDestroyed,isDisturbed:()=>isDisturbed,isErrored:()=>isErrored,isReadable:()=>isReadable,isWritable:()=>isWritable,pipeline:()=>pipeline,setDefaultHighWaterMark:()=>setDefaultHighWaterMark}),$r,ei,ti,ni,ri,ii,ai,oi=__esmMin(()=>{Nr(),Fr(),Ir(),zr(),Ur(),Wr(),Gr(),qr(),Yr(),Xr(),Zr(),$r=makeCallable(Stream_),ei=makeCallable(Hr),ti=makeCallable(Kr),ni=makeCallable(Duplex_),ri=makeCallable(Jr),ii=makeCallable(PassThrough_),ai=Object.assign($r,{Stream:$r,Readable:ei,Writable:ti,Duplex:ni,Transform:ri,PassThrough:ii,pipeline,finished:finished$1,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function getGioCompressorFormat(n){switch(n){case`gzip`:return me.ZlibCompressorFormat.GZIP;case`deflate`:return me.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return me.ZlibCompressorFormat.RAW}}function toUint8Array$2(n){return typeof n==`string`?new TextEncoder().encode(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}function concat(n){let a=n.reduce((n,a)=>n+a.length,0),S=new Uint8Array(a),C=0;for(let a of n)S.set(a,C),C+=a.length;return S}function compressWithGio$1(n,a){let S=new me.ZlibCompressor({format:getGioCompressorFormat(a)}),C=new me.ConverterOutputStream({base_stream:me.MemoryOutputStream.new_resizable(),converter:S});C.write_bytes(new Z.Bytes(n),null),C.close(null);let N=C.get_base_stream().steal_as_bytes();return new Uint8Array(N.get_data()??[])}function decompressMemberWithGio(n,a){let S=new me.ZlibDecompressor({format:getGioCompressorFormat(a)}),C=me.MemoryInputStream.new_from_bytes(new Z.Bytes(n)),N=new me.ConverterInputStream({base_stream:C,converter:S}),F=[];for(;;){let n=N.read_bytes(4096,null);if(n.get_size()===0)break;F.push(new Uint8Array(n.get_data()))}return N.close(null),concat(F)}function findGzipMemberEnd$1(n){let a=new me.ZlibDecompressor({format:me.ZlibCompressorFormat.GZIP}),S=new Uint8Array(65536),C=0,N=!1;for(;!N;){let F=n.subarray(C);try{let[n,I]=a.convert(F,S,me.ConverterFlags.NONE);C+=I,n===me.ConverterResult.FINISHED&&(N=!0)}catch{N=!0}}return C}function gunzipWithGio(n){let a=[],S=0;for(;S<n.length&&!(n.length-S<2||n[S]!==31||n[S+1]!==139);){let C=n.subarray(S),N=findGzipMemberEnd$1(C);if(N<=0)break;a.push(decompressMemberWithGio(C.subarray(0,N),`gzip`)),S+=N}return a.length===0?decompressMemberWithGio(n,`gzip`):concat(a)}function createGzip(n){return new Gzip(n)}function createGunzip(n){return new Gunzip(n)}function createDeflate(n){return new Deflate(n)}function createInflate(n){return new Inflate(n)}function createDeflateRaw(n){return new DeflateRaw(n)}function createInflateRaw(n){return new InflateRaw(n)}function createUnzip(n){return new Unzip(n)}function createBrotliCompress(n){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(n){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}function createZstdCompress(n){let a=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw a.code=`ERR_UNSUPPORTED_OPERATION`,a}function createZstdDecompress(n){let a=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw a.code=`ERR_UNSUPPORTED_OPERATION`,a}var ZlibBase,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,si=__esmMin(()=>{he(),se(),oi(),__name$1(toUint8Array$2,`toUint8Array`),__name$1(compressWithGio$1,`compressWithGio`),__name$1(findGzipMemberEnd$1,`findGzipMemberEnd`),ZlibBase=class extends ri{_mode;_chunks=[];constructor(n,a){super(a),this._mode=n}_transform(n,a,S){this._chunks.push(toUint8Array$2(n)),S()}_flush(n){let a=concat(this._chunks);this._chunks=[];try{this.push(Buffer.from(this._run(a))),n()}catch(a){n(a instanceof Error?a:Error(String(a)))}}_run(n){let a=this._mode;switch(a.kind){case`compress`:return compressWithGio$1(n,a.format);case`decompress`:return decompressMemberWithGio(n,a.format);case`gunzip`:return gunzipWithGio(n);case`unzip`:return n.length>=2&&n[0]===31&&n[1]===139?gunzipWithGio(n):decompressMemberWithGio(n,`deflate`)}}},Gzip=class extends ZlibBase{constructor(n){super({kind:`compress`,format:`gzip`},n)}},Gunzip=class extends ZlibBase{constructor(n){super({kind:`gunzip`},n)}},Deflate=class extends ZlibBase{constructor(n){super({kind:`compress`,format:`deflate`},n)}},Inflate=class extends ZlibBase{constructor(n){super({kind:`decompress`,format:`deflate`},n)}},DeflateRaw=class extends ZlibBase{constructor(n){super({kind:`compress`,format:`deflate-raw`},n)}},InflateRaw=class extends ZlibBase{constructor(n){super({kind:`decompress`,format:`deflate-raw`},n)}},Unzip=class extends ZlibBase{constructor(n){super({kind:`unzip`},n)}},BrotliCompress=class extends ri{constructor(){throw super(),Error(`BrotliCompress is not supported on GJS (no Brotli in GLib)`)}},BrotliDecompress=class extends ri{constructor(){throw super(),Error(`BrotliDecompress is not supported on GJS (no Brotli in GLib)`)}},ZstdCompress=class extends ri{constructor(){super();let n=Error(`ZstdCompress is not supported on GJS (no Zstd in GLib)`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}},ZstdDecompress=class extends ri{constructor(){super();let n=Error(`ZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}}}),ci=__exportAll$3({BrotliCompress:()=>BrotliCompress,BrotliDecompress:()=>BrotliDecompress,Deflate:()=>Deflate,DeflateRaw:()=>DeflateRaw,Gunzip:()=>Gunzip,Gzip:()=>Gzip,Inflate:()=>Inflate,InflateRaw:()=>InflateRaw,Unzip:()=>Unzip,ZlibTransform:()=>ZlibBase,ZstdCompress:()=>ZstdCompress,ZstdDecompress:()=>ZstdDecompress,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>fi,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,createZstdCompress:()=>createZstdCompress,createZstdDecompress:()=>createZstdDecompress,default:()=>pi,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip$1,gunzipSync:()=>gunzipSync,gzip:()=>gzip$1,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync,zstdCompress:()=>zstdCompress,zstdCompressSync:()=>zstdCompressSync,zstdDecompress:()=>zstdDecompress,zstdDecompressSync:()=>zstdDecompressSync});function getGioFormat(n){switch(n){case`gzip`:return me.ZlibCompressorFormat.GZIP;case`deflate`:return me.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return me.ZlibCompressorFormat.RAW}}function compressWithGio(n,a){let S=new me.ZlibCompressor({format:getGioFormat(a)}),C=new me.ConverterOutputStream({base_stream:me.MemoryOutputStream.new_resizable(),converter:S});C.write_bytes(new Z.Bytes(n),null),C.close(null);let N=C.get_base_stream().steal_as_bytes();return new Uint8Array(N.get_data()??[])}function decompressStreamWithGio(n,a){let S=new me.ZlibDecompressor({format:getGioFormat(a)}),C=me.MemoryInputStream.new_from_bytes(new Z.Bytes(n)),N=new me.ConverterInputStream({base_stream:C,converter:S}),F=[];for(;;){let n=N.read_bytes(4096,null);if(n.get_size()===0)break;F.push(new Uint8Array(n.get_data()))}N.close(null);let I=F.reduce((n,a)=>n+a.length,0),H=new Uint8Array(I),W=0;for(let n of F)H.set(n,W),W+=n.length;return H}function findGzipMemberEnd(n){let a=new me.ZlibDecompressor({format:me.ZlibCompressorFormat.GZIP}),S=new Uint8Array(65536),C=0,N=!1;for(;!N;){let F=n.subarray(C);try{let[n,I]=a.convert(F,S,me.ConverterFlags.NONE);C+=I,n===me.ConverterResult.FINISHED&&(N=!0)}catch{N=!0}}return C}function decompressWithGio(n,a){if(a!==`gzip`)return decompressStreamWithGio(n,a);let S=[],C=0;for(;C<n.length&&!(n.length-C<2||n[C]!==31||n[C+1]!==139);){let a=n.subarray(C),N=findGzipMemberEnd(a);if(N<=0)break;let F=decompressStreamWithGio(a.subarray(0,N),`gzip`);S.push(F),C+=N}if(S.length===0)return decompressStreamWithGio(n,`gzip`);let N=S.reduce((n,a)=>n+a.length,0),F=new Uint8Array(N),I=0;for(let n of S)F.set(n,I),I+=n.length;return F}async function runWebTransform(n,a){let S=new ReadableStream({start(a){a.enqueue(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),a.close()}}),C=[],N=S.pipeThrough(a).getReader();for(;;){let{done:n,value:a}=await N.read();if(n)break;C.push(a)}let F=C.reduce((n,a)=>n+a.length,0),I=new Uint8Array(F),H=0;for(let n of C)I.set(n,H),H+=n.length;return I}async function compressWithWeb(n,a){return runWebTransform(n,new CompressionStream(a))}async function decompressWithWeb(n,a){return runWebTransform(n,new DecompressionStream(a))}async function compress(n,a){return li?compressWithWeb(n,a):compressWithGio(n,a)}async function decompress(n,a){return li?decompressWithWeb(n,a):decompressWithGio(n,a)}function toUint8Array$1(n){return typeof n==`string`?new TextEncoder().encode(n):n instanceof ArrayBuffer?new Uint8Array(n):n}function gzip$1(n,a,S){let C=typeof a==`function`?a:S;compress(toUint8Array$1(n),`gzip`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function gunzip$1(n,a,S){let C=typeof a==`function`?a:S;decompress(toUint8Array$1(n),`gzip`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function deflate(n,a,S){let C=typeof a==`function`?a:S;compress(toUint8Array$1(n),`deflate`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function inflate(n,a,S){let C=typeof a==`function`?a:S;decompress(toUint8Array$1(n),`deflate`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function deflateRaw(n,a,S){let C=typeof a==`function`?a:S;compress(toUint8Array$1(n),`deflate-raw`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function inflateRaw(n,a,S){let C=typeof a==`function`?a:S;decompress(toUint8Array$1(n),`deflate-raw`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function gzipSync(n,a){return compressWithGio(toUint8Array$1(n),`gzip`)}function gunzipSync(n,a){return decompressWithGio(toUint8Array$1(n),`gzip`)}function deflateSync(n,a){return compressWithGio(toUint8Array$1(n),`deflate`)}function inflateSync(n,a){return decompressWithGio(toUint8Array$1(n),`deflate`)}function deflateRawSync(n,a){return compressWithGio(toUint8Array$1(n),`deflate-raw`)}function inflateRawSync(n,a){return decompressWithGio(toUint8Array$1(n),`deflate-raw`)}function brotliCompress(n,a,S){(typeof a==`function`?a:S)(Error(`brotliCompress: Brotli is not supported in this environment`),di)}function brotliDecompress(n,a,S){(typeof a==`function`?a:S)(Error(`brotliDecompress: Brotli is not supported in this environment`),di)}function brotliCompressSync(n,a){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(n,a){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}function zstdCompress(n,a,S){let C=typeof a==`function`?a:S,N=Error(`zstdCompress: Zstd is not supported in this environment`);N.code=`ERR_UNSUPPORTED_OPERATION`,C(N,di)}function zstdDecompress(n,a,S){let C=typeof a==`function`?a:S,N=Error(`zstdDecompress: Zstd is not supported in this environment`);N.code=`ERR_UNSUPPORTED_OPERATION`,C(N,di)}function zstdCompressSync(n,a){let S=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw S.code=`ERR_UNSUPPORTED_OPERATION`,S}function zstdDecompressSync(n,a){let S=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw S.code=`ERR_UNSUPPORTED_OPERATION`,S}var li,di,fi,pi,mi=__esmMin(()=>{si(),he(),se(),li=globalThis.CompressionStream!==void 0,__name$1(toUint8Array$1,`toUint8Array`),__name$1(gzip$1,`gzip`),__name$1(gunzip$1,`gunzip`),di=new Uint8Array,fi={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},pi={gzip:gzip$1,gunzip:gunzip$1,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,createZstdCompress,createZstdDecompress,constants:fi}});const hi=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(n){if(!hi.has(n))throw TypeError(`Unsupported compression format: '${n}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return n}const gi=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let _i=!1,vi,yi,bi,xi,Si,Ci;async function loadZlib(){if(_i)return;let n=await Promise.resolve().then(()=>(mi(),ci));vi=n.gzipSync,yi=n.gunzipSync,bi=n.deflateSync,xi=n.inflateSync,Si=n.deflateRawSync,Ci=n.inflateRawSync,_i=!0}function getCompressFn(n){switch(n){case`gzip`:return n=>vi(n);case`deflate`:return n=>bi(n);case`deflate-raw`:return n=>Si(n)}}function getDecompressFn(n){switch(n){case`gzip`:return n=>yi(n);case`deflate`:return n=>xi(n);case`deflate-raw`:return n=>Ci(n)}}function concatChunks$1(n){if(n.length===1)return n[0];let a=0;for(let S of n)a+=S.length;let S=new Uint8Array(a),C=0;for(let a of n)S.set(a,C),C+=a.length;return S}__name$1(concatChunks$1,`concatChunks`);let wi,Ti;if(gi)wi=globalThis.CompressionStream,Ti=globalThis.DecompressionStream;else{let n=loadZlib();wi=class CompressionStream{readable;writable;constructor(a){let S=validateFormat(a),C=[],N=new Or({transform(n){C.push(n)},async flush(a){try{await n;let N=getCompressFn(S)(concatChunks$1(C));N.length>0&&a.enqueue(N)}catch(n){a.error(n)}}});this.readable=N.readable,this.writable=N.writable}},Ti=class DecompressionStream{readable;writable;constructor(a){let S=validateFormat(a),C=[],N=new Or({transform(n){C.push(n)},async flush(a){try{await n;let N=getDecompressFn(S)(concatChunks$1(C));N.length>0&&a.enqueue(N)}catch(n){a.error(n)}}});this.readable=N.readable,this.writable=N.writable}}}const Ei=globalThis;globalThis.CompressionStream===void 0&&(Ei.CompressionStream=wi),globalThis.DecompressionStream===void 0&&(Ei.DecompressionStream=Ti);const Di=globalThis;globalThis.DOMException===void 0&&(Di.DOMException=Q);var Oi,__name,ki=__esmMin(()=>{Oi=Object.defineProperty,__name=(n,a)=>Oi(n,`name`,{value:a,configurable:!0})}),Ai=S;function validateHeaderName(n){if(typeof n!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(n)){let a=TypeError(`Header name must be a valid HTTP token ["${n}"]`);throw Object.defineProperty(a,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),a}}function validateHeaderValue(n,a){if(a===void 0){let a=TypeError(`Header "${n}" value must not be undefined`);throw Object.defineProperty(a,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),a}if(typeof a==`string`&&/[^\t -~-ÿ]/.test(a)){let a=TypeError(`Invalid character in header content ["${n}"]`);throw Object.defineProperty(a,"code",{value:`ERR_INVALID_CHAR`}),a}}const ji=Symbol(`Headers.headers`);function isBoxedPrimitive$2(n){return n instanceof String||n instanceof Number||n instanceof Boolean||typeof Symbol<`u`&&n instanceof Symbol||typeof BigInt<`u`&&n instanceof BigInt}__name$1(isBoxedPrimitive$2,`isBoxedPrimitive`);var Mi=class Headers{[ji];constructor(n){if(this[ji]=new Map,n!=null){if(n instanceof Headers){for(let[a,S]of n[ji])this[ji].set(a,[...S]);return}if(typeof n==`object`&&!isBoxedPrimitive$2(n)){let a=n[Symbol.iterator];if(a==null)for(let[a,S]of Object.entries(n))validateHeaderName(a),validateHeaderValue(a,String(S)),this.append(a,String(S));else{if(typeof a!=`function`)throw TypeError(`Header pairs must be iterable`);for(let a of n){if(typeof a!=`object`||isBoxedPrimitive$2(a))throw TypeError(`Each header pair must be an iterable object`);let n=[...a];if(n.length!==2)throw TypeError(`Each header pair must be a name/value tuple`);validateHeaderName(n[0]),validateHeaderValue(n[0],String(n[1])),this.append(n[0],String(n[1]))}}}else throw TypeError(`Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)'`)}}append(n,a){validateHeaderName(n),validateHeaderValue(n,a);let S=String(n).toLowerCase(),C=String(a),N=this[ji].get(S);N?N.push(C):this[ji].set(S,[C])}set(n,a){validateHeaderName(n),validateHeaderValue(n,a);let S=String(n).toLowerCase();this[ji].set(S,[String(a)])}delete(n){this[ji].delete(String(n).toLowerCase())}has(n){return this[ji].has(String(n).toLowerCase())}get(n){let a=this[ji].get(String(n).toLowerCase());if(!a||a.length===0)return null;let S=a.join(`, `);return/^content-encoding$/i.test(n)&&(S=S.toLowerCase()),S}getAll(n){return this[ji].get(String(n).toLowerCase())??[]}getSetCookie(){return this[ji].get(`set-cookie`)??[]}forEach(n,a){for(let S of this.keys())Reflect.apply(n,a,[this.get(S),S,this])}*keys(){let n=[...this[ji].keys()].sort(),a=new Set;for(let S of n)a.has(S)||(a.add(S),yield S)}*values(){for(let n of this.keys())yield this.get(n)}*entries(){for(let n of this.keys())yield[n,this.get(n)]}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`Headers`}toString(){return Object.prototype.toString.call(this)}raw(){let n={};for(let a of this.keys())n[a]=this.getAll(a);return n}_appendToSoupMessage(n,a=Ai.MessageHeadersType.REQUEST){let S=n?n.get_request_headers():new Ai.MessageHeaders(a);for(let[n,a]of this.entries())S.append(n,a);return S}static _newFromSoupMessage(n,a=Ai.MessageHeadersType.RESPONSE){let S=new Headers,C;return C=a===Ai.MessageHeadersType.RESPONSE?n.get_response_headers():n.get_request_headers(),C.foreach((n,a)=>{S.append(n,a)}),S}[Symbol.for(`nodejs.util.inspect.custom`)](){let n={};for(let a of this.keys()){let S=this.getAll(a);a===`host`?n[a]=S[0]:n[a]=S.length>1?S:S[0]}return n}};Object.defineProperties(Mi.prototype,[`get`,`entries`,`forEach`,`values`].reduce((n,a)=>(n[a]={enumerable:!0},n),{}));var Ni=__esmMin(()=>{vt()});Ni();var FetchBaseError=class extends Error{type;constructor(n,a){super(n),typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,this.constructor),this.type=a}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}},FetchError=class extends FetchBaseError{code;errno;erroredSysCall;constructor(n,a,S){super(n,a),S&&(this.code=this.errno=S.code,this.erroredSysCall=S.syscall)}};mn();const Pi=Symbol.toStringTag,isURLSearchParameters=n=>typeof n==`object`&&typeof n.append==`function`&&typeof n.delete==`function`&&typeof n.get==`function`&&typeof n.getAll==`function`&&typeof n.has==`function`&&typeof n.set==`function`&&typeof n.sort==`function`&&n[Pi]===`URLSearchParams`,isBlob=n=>{if(!n||typeof n!=`object`)return!1;let a=n;return typeof a.arrayBuffer==`function`&&typeof a.type==`string`&&typeof a.stream==`function`&&typeof a.constructor==`function`&&/^(Blob|File)$/.test(a[Pi])},isAbortSignal=n=>{if(typeof n!=`object`||!n)return!1;let a=n;return a[Pi]===`AbortSignal`||a[Pi]===`EventTarget`},isDomainOrSubdomain=(n,a)=>{let S=new fn(a).hostname,C=new fn(n).hostname;return S===C||S.endsWith(`.${C}`)},isSameProtocol=(n,a)=>new fn(a).protocol===new fn(n).protocol;var $,Fi,File,Ii=__esmMin(()=>{$=Symbol(`File.name`),Fi=Symbol(`File.lastModified`),File=class extends Blob{[$];[Fi];webkitRelativePath=``;constructor(n,a,S){super(n,S),this[$]=String(a),this[Fi]=S?.lastModified??Date.now()}get name(){return this[$]}get lastModified(){return this[Fi]}get[Symbol.toStringTag](){return`File`}}});function generateBoundary(){let n=`----formdata-`;for(let a=0;a<24;a++)n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62));return n}function escape(n){return n.replace(/\n/g,`%0A`).replace(/\r/g,`%0D`).replace(/"/g,`%22`)}function formDataToBlob(n,a){a??=generateBoundary();let S=[],C=`--${a}\r\nContent-Disposition: form-data; name="`;for(let[a,N]of n.entries())if(typeof N==`string`)S.push(`${C}${escape(a)}"\r\n\r\n${N.replace(/\r(?!\n)|(?<!\r)\n/g,`\r
|
|
6
|
+
`+a)}profile(n){}profileEnd(n){}timeStamp(n){}},Te=new Console,log=(...n)=>Te.log(...n),info=(...n)=>Te.info(...n),Ee=__name$1((...n)=>Te.debug(...n),`debug`),warn=(...n)=>Te.warn(...n),error=(...n)=>Te.error(...n),dir=(n,a)=>Te.dir(n,a),dirxml=(...n)=>Te.dirxml(...n),table=(n,a)=>Te.table(n,a),clear=()=>Te.clear(),assert=(n,...a)=>Te.assert(n,...a),trace=(...n)=>Te.trace(...n),time=n=>Te.time(n),timeEnd=n=>Te.timeEnd(n),timeLog=(n,...a)=>Te.timeLog(n,...a),De=__name$1(n=>Te.count(n),`count`),countReset=n=>Te.countReset(n),group=(...n)=>Te.group(...n),groupCollapsed=(...n)=>Te.groupCollapsed(...n),groupEnd=()=>Te.groupEnd(),profile=n=>{},profileEnd=n=>{},timeStamp=n=>{}}),ke,Ae=__esmMin(()=>{Oe(),ke={log,info,debug:Ee,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count:De,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp}}),je=__esmMin(()=>{Ae()}),Me,Fe=__esmMin(()=>{Me=__name$1(n=>{Promise.resolve().then(n)},`queueMicrotask`)});function drainOnce(n){let a=Math.min(64,Ie.length);for(let S=0;S<a;S++){let a=Ie.shift();try{a()}catch(a){try{n.log_default_handler(`gjsify-nextTick`,n.LogLevelFlags.LEVEL_WARNING,String(a?.stack||a),null)}catch{}}}Ie.length>0?n.timeout_add(n.PRIORITY_DEFAULT,1,()=>(drainOnce(n),!1)):Le=!1}function tryGLibTimeout(n){let a=globalThis.imports?.gi?.GLib;return a?.timeout_add?(Ie.push(n),Le||(Le=!0,a.timeout_add(a.PRIORITY_DEFAULT,0,()=>(drainOnce(a),!1))),!0):!1}var Ie,Le,nextTick,Re=__esmMin(()=>{Ie=[],Le=!1,nextTick=(n,...a)=>{let S=a.length>0?()=>n(...a):n;if(!tryGLibTimeout(S)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(n,...a);return}if(typeof queueMicrotask==`function`){queueMicrotask(S);return}Promise.resolve().then(S)}}}),ze,Be,getPathSeparator,Ve=__esmMin(()=>{se(),he(),{File:ze}=me,Be=__name$1((n,...a)=>{let S=ze.new_for_path(n);for(let n of a)S=S.resolve_relative_path(n);return S},`resolve`),getPathSeparator=()=>Z.get_current_dir().startsWith(`/`)?`/`:`\\`});function classOf(n){return He.call(n).slice(8,-1)}function throwDataCloneError(n){let a=globalThis.DOMException;if(typeof a==`function`)throw new a(n,`DataCloneError`);let S=Error(n);throw S.name=`DataCloneError`,S}function internalClone(n,a,S){if(n==null)return n;let C=typeof n;if(C===`boolean`||C===`number`||C===`string`||C===`bigint`)return n;C===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),C===`function`&&throwDataCloneError(`Function cannot be cloned`);let N=n;if(a.has(N))return a.get(N);let F=classOf(N);if(F===`Date`)return new Date(N.getTime());if(F===`RegExp`)return new RegExp(N.source,N.flags);if(F===`Boolean`||F===`Number`||F===`String`)return Object(N.valueOf());if(F===`BigInt`)return Object(BigInt.prototype.valueOf.call(N));if(N instanceof Error){let n=N,C=n.constructor?.name,F=new(C&&Ue[C]||Ue[n.name]||Error)(n.message);return F.name=n.name,`cause`in n&&Object.defineProperty(F,"cause",{value:internalClone(n.cause,a,S),writable:!0,enumerable:!1,configurable:!0}),F}if(F===`DOMException`){let n=globalThis.DOMException;if(typeof n==`function`){let a=N;return new n(a.message,a.name)}}if(F===`ArrayBuffer`){let n=N;if(S&&S.transferred.has(n)){let C=S.transferred.get(n);return a.set(N,C),C}(n.detached===!0||n.byteLength===0&&n.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let C=n.slice(0);return a.set(N,C),C}if(F===`SharedArrayBuffer`||N&&typeof N==`object`&&N.constructor?.name===`SharedBuffer`)return N;if(F===`DataView`){let n=N,C=S?.viewSnapshots.get(N),F=internalClone(n.buffer,a,S),I=C?C.byteOffset:n.byteOffset,H=C?C.byteLength:n.byteLength,W=new DataView(F,I,H);return a.set(N,W),W}if(Ge.has(F)){let n=N,C=S?.viewSnapshots.get(N),F=internalClone(n.buffer,a,S),I=n.constructor,H=new I(F,C?C.byteOffset:n.byteOffset,C?C.length:n.length);return a.set(N,H),H}if(F===`Map`){let n=new Map;a.set(N,n);for(let[C,F]of N)n.set(internalClone(C,a,S),internalClone(F,a,S));return n}if(F===`Set`){let n=new Set;a.set(N,n);for(let C of N)n.add(internalClone(C,a,S));return n}{let n=globalThis,a=n.Blob,S=n.File;if(typeof S==`function`&&N instanceof S){let n=N;return new S([N],n.name,{type:n.type,lastModified:n.lastModified})}if(typeof a==`function`&&N instanceof a)return new a([N],{type:N.type})}if(N instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),N instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),N instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&N instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),F===`Array`){let n=N,C=[];a.set(N,C);for(let N=0;N<n.length;N++)N in n&&(C[N]=internalClone(n[N],a,S));return C}if(F===`Object`||typeof N==`object`){let n={};a.set(N,n);for(let C of Object.keys(N))n[C]=internalClone(N[C],a,S);return n}throwDataCloneError(`${F} cannot be cloned`)}function structuredClone$1(n,a){let S=a?.transfer;if(!S||S.length===0)return internalClone(n,new Map);let C=new Set;for(let n of S)if(classOf(n)===`ArrayBuffer`){let a=n;a.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),C.add(a)}let N=new Map;C.size>0&&snapshotViewsBackedByTransferredBuffers(n,C,N,new Set);let F=new Map;for(let n of C){let a=n;typeof a.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),F.set(n,a.transfer())}return internalClone(n,new Map,{transferred:F,viewSnapshots:N})}function snapshotViewsBackedByTransferredBuffers(n,a,S,C){if(typeof n!=`object`||!n)return;let N=n;if(C.has(N))return;C.add(N);let F=classOf(N);if(F===`DataView`){let n=N;a.has(n.buffer)&&S.set(N,{byteOffset:n.byteOffset,length:0,byteLength:n.byteLength});return}if(Ge.has(F)){let n=N;a.has(n.buffer)&&S.set(N,{byteOffset:n.byteOffset,length:n.length,byteLength:n.byteLength});return}if(Array.isArray(N)){for(let n=0;n<N.length;n++)n in N&&snapshotViewsBackedByTransferredBuffers(N[n],a,S,C);return}if(F===`Map`){for(let[n,F]of N)snapshotViewsBackedByTransferredBuffers(n,a,S,C),snapshotViewsBackedByTransferredBuffers(F,a,S,C);return}if(F===`Set`){for(let n of N)snapshotViewsBackedByTransferredBuffers(n,a,S,C);return}if(F===`Object`)for(let n of Object.keys(N))snapshotViewsBackedByTransferredBuffers(N[n],a,S,C)}var He,Ue,Ge,Ke=__esmMin(()=>{({toString:He}=Object.prototype),Ue={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Ge=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),__name$1(structuredClone$1,`structuredClone`)});function ensureMainLoop(){let n=globalThis.imports;if(!n)return;if(qe)return Je;let a=n.gi?.GLib;if(a){if(Je=new a.MainLoop(null,!1),qe=!0,a.main_depth()===0)try{Je.runAsync()}catch{}return Je}}function quitMainLoop(){Je&&=(Je.quit(),qe=!1,null)}var qe,Je,Ye=__esmMin(()=>{qe=!1,Je=null}),Xe=__esmMin(()=>{re(),ie(),ce(),le(),ue(),de(),ve(),xe(),Se(),Ce(),je(),Fe(),Re(),Ve(),Ke(),Ye()});ne(),Xe(),registerGlobal(`Blob`,X),registerGlobal(`File`,te);function atobPolyfill(n){if(typeof globalThis.atob==`function`)return globalThis.atob(n);let a=n.replace(/[=\s]/g,``),S=``,C=0,N=0;for(let n=0;n<a.length;n++)C=C<<6|Qe[a.charCodeAt(n)],N+=6,N>=8&&(N-=8,S+=String.fromCharCode(C>>N&255));return S}function btoaPolyfill(n){if(typeof globalThis.btoa==`function`)return globalThis.btoa(n);let a=``,S=0;for(;S+2<n.length;S+=3){let C=n.charCodeAt(S)<<16|n.charCodeAt(S+1)<<8|n.charCodeAt(S+2);a+=Ze[C>>18&63]+Ze[C>>12&63]+Ze[C>>6&63]+Ze[C&63]}if(S+1===n.length){let C=n.charCodeAt(S)<<16;a+=Ze[C>>18&63]+Ze[C>>12&63]+`==`}else if(S+2===n.length){let C=n.charCodeAt(S)<<16|n.charCodeAt(S+1)<<8;a+=Ze[C>>18&63]+Ze[C>>12&63]+Ze[C>>6&63]+`=`}return a}function base64Decode$1(n){let a=n.replace(/[=\s]/g,``),S=new Uint8Array(a.length*3>>2),C=0,N=0,F=0;for(let n=0;n<a.length;n++)C=C<<6|Qe[a.charCodeAt(n)],N+=6,N>=8&&(N-=8,S[F++]=C>>N&255);return S.subarray(0,F)}function base64Encode$1(n){let a=``,S=n.length;for(let C=0;C<S;C+=3){let N=n[C],F=C+1<S?n[C+1]:0,I=C+2<S?n[C+2]:0;a+=Ze[N>>2],a+=Ze[(N&3)<<4|F>>4],a+=C+1<S?Ze[(F&15)<<2|I>>6]:`=`,a+=C+2<S?Ze[I&63]:`=`}return a}var Ze,Qe,$e=__esmMin(()=>{Ze=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Qe=new Uint8Array(256);for(let n=0;n<64;n++)Qe[Ze.charCodeAt(n)]=n;__name$1(base64Decode$1,`base64Decode`),__name$1(base64Encode$1,`base64Encode`)});function normalizeEncoding(n){if(!n||n===`utf8`||n===`utf-8`)return`utf8`;switch((``+n).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function checkEncoding(n){let a=(``+n).toLowerCase().replace(/-/g,``);if(!et.includes(a))throw TypeError(`Unknown encoding: ${n}`)}var et,tt=__esmMin(()=>{et=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`]});function encodeString(n,a){switch(a){case`utf8`:return it().encode(n);case`ascii`:{let a=new Uint8Array(n.length);for(let S=0;S<n.length;S++)a[S]=n.charCodeAt(S)&127;return a}case`latin1`:{let a=new Uint8Array(n.length);for(let S=0;S<n.length;S++)a[S]=n.charCodeAt(S)&255;return a}case`base64`:return base64Decode$1(n.replace(/-/g,`+`).replace(/_/g,`/`));case`base64url`:return encodeString(n.replace(/-/g,`+`).replace(/_/g,`/`),`base64`);case`hex`:{let a=n.length>>>1,S=new Uint8Array(a);for(let C=0;C<a;C++){let a=parseInt(n[C*2],16),N=parseInt(n[C*2+1],16);if(Number.isNaN(a)||Number.isNaN(N))break;S[C]=a<<4|N}return S}case`utf16le`:{let a=new Uint8Array(n.length*2);for(let S=0;S<n.length;S++){let C=n.charCodeAt(S);a[S*2]=C&255,a[S*2+1]=C>>8&255}return a}default:return it().encode(n)}}function decodeString(n,a,S,C){let N=S!==void 0||C!==void 0?n.subarray(S??0,C??n.length):n;switch(a){case`utf8`:return ot().decode(N);case`ascii`:{let n=``;for(let a=0;a<N.length;a++)n+=String.fromCharCode(N[a]&127);return n}case`latin1`:{let n=``;for(let a=0;a<N.length;a++)n+=String.fromCharCode(N[a]);return n}case`base64`:{let n=``;for(let a=0;a<N.length;a++)n+=String.fromCharCode(N[a]);return btoaPolyfill(n)}case`base64url`:return decodeString(N,`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);case`hex`:{let n=``;for(let a=0;a<N.length;a++)n+=N[a].toString(16).padStart(2,`0`);return n}case`utf16le`:{let n=``;for(let a=0;a+1<N.length;a+=2)n+=String.fromCharCode(N[a]|N[a+1]<<8);return n}default:return ot().decode(N)}}function checkOffset(n,a,S){if(n+a>S)throw RangeError(`Attempt to access memory outside buffer bounds`)}var nt,rt,it,ot,st=__esmMin(()=>{$e(),it=__name$1(()=>nt??=new TextEncoder,`textEncoder`),ot=__name$1(()=>rt??=new TextDecoder,`textDecoder`)}),ct,lt,ut,dt,ft,SlowBuffer,pt=__esmMin(()=>{st(),tt(),ct=typeof SharedArrayBuffer<`u`,lt=class Buffer extends Uint8Array{static _isBuffer=!0;static alloc(n,a,S){if(typeof n!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof n}`);if(n<0)throw RangeError(`The value "${n}" is invalid for option "size"`);let C=new Buffer(n);return a!==void 0&&a!==0&&C.fill(a,0,n,S),C}static allocUnsafe(n){if(typeof n!=`number`)throw TypeError(`The "size" argument must be of type number. Received type ${typeof n}`);return new Buffer(n)}static allocUnsafeSlow(n){return Buffer.allocUnsafe(n)}static from(n,a,S){if(typeof n==`string`){let S=normalizeEncoding(a);if(a&&typeof a==`string`){let n=(``+a).toLowerCase().replace(/-/g,``);[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`,``].includes(n)||checkEncoding(a)}let C=encodeString(n,S);return new Buffer(C.buffer,C.byteOffset,C.byteLength)}if(ArrayBuffer.isView(n)){let a=new Buffer(n.buffer,n.byteOffset,n.byteLength),S=new Buffer(a.length);return S.set(a),S}if(n instanceof ArrayBuffer){let C=a||0;return new Buffer(n,C,S===void 0?n.byteLength-C:S)}if(ct&&n instanceof SharedArrayBuffer){let C=a||0,N=S===void 0?n.byteLength-C:S;return new Buffer(new Uint8Array(n,C,N))}if(typeof n==`object`&&n&&typeof n.viewBytes==`function`&&typeof n.byteLength==`number`&&n.constructor?.name===`SharedBuffer`){let C=n,N=a||0,F=S===void 0?C.byteLength-N:S,I=C.viewBytes(N,F);return new Buffer(I.buffer,I.byteOffset,I.byteLength)}if(Array.isArray(n)){let a=new Buffer(n.length);for(let S=0;S<n.length;S++)a[S]=n[S]&255;return a}throw TypeError(`The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array`)}static isBuffer(n){return n instanceof Buffer}static isEncoding(n){if(typeof n!=`string`)return!1;let a=n.toLowerCase().replace(/-/g,``);return[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`].includes(a)}static byteLength(n,a){if(typeof n!=`string`){if(ArrayBuffer.isView(n)||n instanceof ArrayBuffer||ct&&n instanceof SharedArrayBuffer)return n.byteLength;throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer`)}switch(normalizeEncoding(a)){case`utf8`:return new TextEncoder().encode(n).byteLength;case`ascii`:case`latin1`:return n.length;case`base64`:case`base64url`:{let a=n.length;for(;a>0&&(n[a-1]===`=`||n[a-1]===` `);)a--;return a*3>>>2}case`hex`:return n.length>>>1;case`utf16le`:return n.length*2;default:return new TextEncoder().encode(n).byteLength}}static compare(n,a){if(!(n instanceof Uint8Array)||!(a instanceof Uint8Array))throw TypeError(`Arguments must be Buffers or Uint8Arrays`);let S=Math.min(n.length,a.length);for(let C=0;C<S;C++){if(n[C]<a[C])return-1;if(n[C]>a[C])return 1}return n.length<a.length?-1:+(n.length>a.length)}static concat(n,a){if(n.length===0)return Buffer.alloc(0);if(a===void 0){a=0;for(let S=0;S<n.length;S++)a+=n[S].length}let S=Buffer.alloc(a),C=0;for(let N=0;N<n.length;N++){let F=n[N],I=Math.min(F.length,a-C);I<=0||(S.set(F.subarray(0,I),C),C+=I)}return S}static poolSize=65536;toString(n,a,S){let C=normalizeEncoding(n);return decodeString(this,C,a,S)}toJSON(){return{type:`Buffer`,data:Array.from(this)}}equals(n){if(!(n instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);if(this.length!==n.length)return!1;for(let a=0;a<this.length;a++)if(this[a]!==n[a])return!1;return!0}compare(n,a,S,C,N){if(!(n instanceof Uint8Array))throw TypeError(`Argument must be a Buffer or Uint8Array`);let F=C!==void 0||N!==void 0?this.subarray(C??0,N??this.length):this,I=a!==void 0||S!==void 0?n.subarray(a??0,S??n.length):n;return Buffer.compare(F,I)}copy(n,a=0,S=0,C){let N=C??this.length,F=Math.min(N-S,n.length-a);return F<=0?0:(n.set(this.subarray(S,S+F),a),F)}slice(n,a){let S=n??0,C=a??this.length,N=super.subarray(S,C);return new Buffer(N.buffer,N.byteOffset,N.byteLength)}subarray(n,a){let S=super.subarray(n,a);return new Buffer(S.buffer,S.byteOffset,S.byteLength)}write(n,a,S,C){a??=0;let N=encodeString(n,normalizeEncoding(C||(typeof S==`string`?S:void 0))),F=S!==void 0&&typeof S==`number`?Math.min(S,this.length-a):this.length-a,I=Math.min(N.length,F);return this.set(N.subarray(0,I),a),I}fill(n,a,S,C){let N=a??0,F=S??this.length;if(typeof n==`number`)super.fill(n&255,N,F);else if(typeof n==`string`){let a=encodeString(n,normalizeEncoding(C));if(a.length===0)super.fill(0,N,F);else if(a.length===1)super.fill(a[0],N,F);else for(let n=N;n<F;n++)this[n]=a[(n-N)%a.length]}else if(n instanceof Uint8Array)if(n.length===0)super.fill(0,N,F);else for(let a=N;a<F;a++)this[a]=n[(a-N)%n.length];return this}indexOf(n,a,S){if(typeof n==`number`)return super.indexOf(n&255,a);let C=typeof n==`string`?encodeString(n,normalizeEncoding(S)):n,N=a??0;outer:for(let n=N;n<=this.length-C.length;n++){for(let a=0;a<C.length;a++)if(this[n+a]!==C[a])continue outer;return n}return-1}lastIndexOf(n,a,S){if(typeof n==`number`)return a===void 0?super.lastIndexOf(n&255):super.lastIndexOf(n&255,a);let C=typeof n==`string`?encodeString(n,normalizeEncoding(S)):n,N=a===void 0?this.length-C.length:Math.min(a,this.length-C.length);outer:for(let n=N;n>=0;n--){for(let a=0;a<C.length;a++)if(this[n+a]!==C[a])continue outer;return n}return-1}includes(n,a,S){return this.indexOf(n,a,S)!==-1}readUInt8(n=0){return checkOffset(n,1,this.length),this[n]}readUInt16BE(n=0){return checkOffset(n,2,this.length),this[n]<<8|this[n+1]}readUInt16LE(n=0){return checkOffset(n,2,this.length),this[n]|this[n+1]<<8}readUInt32BE(n=0){return checkOffset(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])}readUInt32LE(n=0){return checkOffset(n,4,this.length),this[n+3]*16777216+(this[n+2]<<16|this[n+1]<<8|this[n])>>>0}readInt8(n=0){return checkOffset(n,1,this.length),this[n]|(this[n]&128?4294967040:0)}readInt16BE(n=0){checkOffset(n,2,this.length);let a=this[n]<<8|this[n+1];return a&32768?a|4294901760:a}readInt16LE(n=0){checkOffset(n,2,this.length);let a=this[n]|this[n+1]<<8;return a&32768?a|4294901760:a}readInt32BE(n=0){return checkOffset(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]}readInt32LE(n=0){return checkOffset(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24}readFloatBE(n=0){return checkOffset(n,4,this.length),new DataView(this.buffer,this.byteOffset+n,4).getFloat32(0,!1)}readFloatLE(n=0){return checkOffset(n,4,this.length),new DataView(this.buffer,this.byteOffset+n,4).getFloat32(0,!0)}readDoubleBE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getFloat64(0,!1)}readDoubleLE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getFloat64(0,!0)}readBigInt64BE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getBigInt64(0,!1)}readBigInt64LE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getBigInt64(0,!0)}readBigUInt64BE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getBigUint64(0,!1)}readBigUInt64LE(n=0){return checkOffset(n,8,this.length),new DataView(this.buffer,this.byteOffset+n,8).getBigUint64(0,!0)}readUIntBE(n,a){checkOffset(n,a,this.length);let S=0;for(let C=0;C<a;C++)S=S*256+this[n+C];return S}readUIntLE(n,a){checkOffset(n,a,this.length);let S=0,C=1;for(let N=0;N<a;N++)S+=this[n+N]*C,C*=256;return S}readIntBE(n,a){checkOffset(n,a,this.length);let S=0;for(let C=0;C<a;C++)S=S*256+this[n+C];return S>=2**(8*a-1)&&(S-=2**(8*a)),S}readIntLE(n,a){checkOffset(n,a,this.length);let S=0,C=1;for(let N=0;N<a;N++)S+=this[n+N]*C,C*=256;return S>=2**(8*a-1)&&(S-=2**(8*a)),S}writeUInt8(n,a=0){return checkOffset(a,1,this.length),this[a]=n&255,a+1}writeUInt16BE(n,a=0){return checkOffset(a,2,this.length),this[a]=n>>>8&255,this[a+1]=n&255,a+2}writeUInt16LE(n,a=0){return checkOffset(a,2,this.length),this[a]=n&255,this[a+1]=n>>>8&255,a+2}writeUInt32BE(n,a=0){return checkOffset(a,4,this.length),this[a]=n>>>24&255,this[a+1]=n>>>16&255,this[a+2]=n>>>8&255,this[a+3]=n&255,a+4}writeUInt32LE(n,a=0){return checkOffset(a,4,this.length),this[a]=n&255,this[a+1]=n>>>8&255,this[a+2]=n>>>16&255,this[a+3]=n>>>24&255,a+4}writeInt8(n,a=0){return checkOffset(a,1,this.length),n<0&&(n=255+n+1),this[a]=n&255,a+1}writeInt16BE(n,a=0){return checkOffset(a,2,this.length),this[a]=n>>>8&255,this[a+1]=n&255,a+2}writeInt16LE(n,a=0){return checkOffset(a,2,this.length),this[a]=n&255,this[a+1]=n>>>8&255,a+2}writeInt32BE(n,a=0){return checkOffset(a,4,this.length),this[a]=n>>>24&255,this[a+1]=n>>>16&255,this[a+2]=n>>>8&255,this[a+3]=n&255,a+4}writeInt32LE(n,a=0){return checkOffset(a,4,this.length),this[a]=n&255,this[a+1]=n>>>8&255,this[a+2]=n>>>16&255,this[a+3]=n>>>24&255,a+4}writeFloatBE(n,a=0){return checkOffset(a,4,this.length),new DataView(this.buffer,this.byteOffset+a,4).setFloat32(0,n,!1),a+4}writeFloatLE(n,a=0){return checkOffset(a,4,this.length),new DataView(this.buffer,this.byteOffset+a,4).setFloat32(0,n,!0),a+4}writeDoubleBE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setFloat64(0,n,!1),a+8}writeDoubleLE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setFloat64(0,n,!0),a+8}writeBigInt64BE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setBigInt64(0,n,!1),a+8}writeBigInt64LE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setBigInt64(0,n,!0),a+8}writeBigUInt64BE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setBigUint64(0,n,!1),a+8}writeBigUInt64LE(n,a=0){return checkOffset(a,8,this.length),new DataView(this.buffer,this.byteOffset+a,8).setBigUint64(0,n,!0),a+8}swap16(){let n=this.length;if(n%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let a=0;a<n;a+=2){let n=this[a];this[a]=this[a+1],this[a+1]=n}return this}swap32(){let n=this.length;if(n%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let a=0;a<n;a+=4){let n=this[a],S=this[a+1];this[a]=this[a+3],this[a+1]=this[a+2],this[a+2]=S,this[a+3]=n}return this}swap64(){let n=this.length;if(n%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let a=0;a<n;a+=8){let n=this[a],S=this[a+1],C=this[a+2],N=this[a+3];this[a]=this[a+7],this[a+1]=this[a+6],this[a+2]=this[a+5],this[a+3]=this[a+4],this[a+4]=N,this[a+5]=C,this[a+6]=S,this[a+7]=n}return this}},ut=2**31-1,dt=2**28-16,ft={MAX_LENGTH:ut,MAX_STRING_LENGTH:dt},SlowBuffer=class extends lt{constructor(n){super(n)}}}),mt=__exportAll$3({Blob:()=>X,Buffer:()=>lt,File:()=>te,INSPECT_MAX_BYTES:()=>50,SlowBuffer:()=>SlowBuffer,atob:()=>ht,atobPolyfill:()=>atobPolyfill,base64Decode:()=>base64Decode$1,base64Encode:()=>base64Encode$1,btoa:()=>gt,btoaPolyfill:()=>btoaPolyfill,checkEncoding:()=>checkEncoding,constants:()=>ft,default:()=>_t,kMaxLength:()=>ut,kStringMaxLength:()=>dt,normalizeEncoding:()=>normalizeEncoding}),ht,gt,_t,vt=__esmMin(()=>{$e(),ne(),tt(),pt(),ht=globalThis.atob,gt=globalThis.btoa,_t={Buffer:lt,SlowBuffer,Blob:X,File:te,atob:ht,btoa:gt,kMaxLength:ut,kStringMaxLength:dt,constants:ft,INSPECT_MAX_BYTES:50}});vt(),`Buffer`in globalThis||Object.defineProperty(globalThis,"Buffer",{value:lt,enumerable:!1,writable:!0,configurable:!0}),se(),typeof globalThis.btoa!=`function`&&Object.defineProperty(globalThis,"btoa",{value:function btoa(n){let a=new Uint8Array(n.length);for(let S=0;S<n.length;S++)a[S]=n.charCodeAt(S)&255;return Z.base64_encode(a)},enumerable:!0,writable:!0,configurable:!0}),typeof globalThis.atob!=`function`&&Object.defineProperty(globalThis,"atob",{value:function atob(n){let a=Z.base64_decode(n),S=``;for(let n=0;n<a.length;n++)S+=String.fromCharCode(a[n]);return S},enumerable:!0,writable:!0,configurable:!0}),Xe(),typeof queueMicrotask!=`function`&&Object.defineProperty(globalThis,"queueMicrotask",{value:Me,enumerable:!0,writable:!0,configurable:!0});function getGjsGlobal(){return globalThis}function getGioNamespace(){let n=getGjsGlobal().imports?.gi;if(!n)return null;let a=null;try{a=n.GioUnix??null}catch{}if(!a)try{a=n.Gio??null}catch{}return a}var yt=__esmMin(()=>{});function getMonotonicTime(){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n?.get_monotonic_time)return BigInt(n.get_monotonic_time())*1000n}catch{}return typeof performance?.now==`function`?BigInt(Math.round(performance.now()*1e6)):BigInt(Date.now())*1000000n}function hrtime(n){let a=getMonotonicTime()-bt,S=Number(a/1000000000n),C=Number(a%1000000000n);if(n){let a=S-n[0],N=C-n[1];return N<0&&(a--,N+=1e9),[a,N]}return[S,C]}function hrtimeBigint(){return getMonotonicTime()-bt}var bt,xt=__esmMin(()=>{yt(),bt=getMonotonicTime()});function detectGjsVersion(){try{let n=getGjsGlobal().imports?.system;if(n?.version!==void 0){let a=Number(n.version);return`${Math.floor(a/1e4)}.${Math.floor(a%1e4/100)}.${a%100}`}}catch{}}function detectNodeVersion(){if(typeof globalThis.process?.versions?.node==`string`)return globalThis.process.versions.node}function detectVersionInfo(){if(detectNodeVersion())return{version:globalThis.process.version,versions:{...globalThis.process.versions},title:globalThis.process?.title||`node`};let n=detectGjsVersion(),a={node:`20.0.0`};return n&&(a.gjs=n),{version:`v20.0.0`,versions:a,title:`gjs`}}function detectPpid(){if(typeof globalThis.process?.ppid==`number`)return globalThis.process.ppid;try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let[,a]=n.file_get_contents(`/proc/self/status`);if(a){let n=new TextDecoder().decode(a).match(/PPid:\s+(\d+)/);if(n)return parseInt(n[1],10)}}}catch{}return 0}function detectPlatform(){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n&&n.get_os_info(`ID`))return`linux`}catch{}return getGjsGlobal().imports?.system===void 0&&typeof globalThis.process?.platform==`string`?globalThis.process.platform:`linux`}function detectArch(){return typeof globalThis.process?.arch==`string`?globalThis.process.arch:`x64`}function getPid$1(){if(typeof globalThis.process?.pid==`number`)return globalThis.process.pid;try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let[,a]=n.file_get_contents(`/proc/self/stat`);if(a){let n=new TextDecoder().decode(a),S=parseInt(n,10);if(!isNaN(S))return S}}}catch{}return 0}var St=__esmMin(()=>{yt(),__name$1(getPid$1,`getPid`)});function getEnvProxy(){if(typeof globalThis.process?.env==`object`)return globalThis.process.env;try{let n=getGjsGlobal().imports?.gi?.GLib;if(n)return new Proxy({},{get(a,S){if(typeof S==`string`)return n.getenv(S)??void 0},set(a,S,C){return typeof S==`string`?(n.setenv(S,String(C),!0),!0):!1},deleteProperty(a,S){return typeof S==`string`?(n.unsetenv(S),!0):!1},has(a,S){return typeof S==`string`?n.getenv(S)!==null:!1},ownKeys(a){return n.listenv()},getOwnPropertyDescriptor(a,S){if(typeof S!=`string`)return;let C=n.getenv(S);if(C!==null)return{configurable:!0,enumerable:!0,writable:!0,value:C}}})}catch{}return{}}function getArgv(){if(globalThis.process?.argv!==void 0)return globalThis.process.argv;try{let n=getGjsGlobal().imports?.system;if(n?.programArgs)return[`gjs`,n.programInvocationName||``,...n.programArgs]}catch{}return[`gjs`]}function getExecPath(){if(typeof globalThis.process?.execPath==`string`)return globalThis.process.execPath;try{let n=getGjsGlobal().imports?.system;if(n?.programInvocationName)return n.programInvocationName}catch{}return`/usr/bin/gjs`}function getCwd(){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n?.get_current_dir)return n.get_current_dir()}catch{}return`/`}function chdir(n){let a=getGjsGlobal().imports?.gi?.GLib;try{if(a?.chdir){if(!a.file_test(n,16)){let a=Error(`ENOENT: no such file or directory, chdir '${n}'`);throw a.code=`ENOENT`,a.syscall=`chdir`,a.path=n,a}a.chdir(n);return}}catch(n){if(n&&typeof n==`object`&&n.code===`ENOENT`)throw n}if(!a){let a=globalThis.process;if(a&&typeof a.chdir==`function`){a.chdir(n);return}}throw Error(`process.chdir() is not supported in this environment`)}var Ct=__esmMin(()=>{yt()});function exitProcess(n){let a=getGjsGlobal().imports,S=a?.gi?.GLib,C=a?.system,N=S?.idle_add,F=S?.SOURCE_REMOVE,I=S?.PRIORITY_DEFAULT;if(C?.exit&&N&&typeof I==`number`&&typeof F==`boolean`)return ensureMainLoop(),N(I,()=>(quitMainLoop(),C.exit(n),F)),new Promise(()=>{});try{C?.exit&&C.exit(n)}catch{}let H=globalThis.process;throw H&&typeof H.exit==`function`&&H.exit(n),Error(`process.exit(${n})`)}var wt=__esmMin(()=>{yt(),Xe()});function isGjs$1(){return getGjsGlobal().imports?.gi?.GLib!==void 0}function killPid(n,a){try{let S=getGjsGlobal().imports?.gi?.GLib;if(S){let C=typeof a==`number`?String(a):a||`SIGTERM`,N=C.startsWith(`SIG`)?`-${C.slice(3)}`:`-${C}`;return S.spawn_command_line_sync(`kill ${N} ${n}`),!0}}catch{}if(!isGjs$1()){let S=globalThis.process;if(S&&typeof S.kill==`function`)return S.kill(n,a)}throw Error(`process.kill() is not supported in this environment`)}function memoryUsage(){try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let[,a]=n.file_get_contents(`/proc/self/status`);if(a){let n=new TextDecoder().decode(a).match(/VmRSS:\s+(\d+)/),S=n?parseInt(n[1],10)*1024:0;return{rss:S,heapTotal:S,heapUsed:S,external:0,arrayBuffers:0}}}}catch{}if(!isGjs$1()){let n=globalThis.process;if(n&&typeof n.memoryUsage==`function`)return n.memoryUsage()}return{rss:0,heapTotal:0,heapUsed:0,external:0,arrayBuffers:0}}function cpuUsage(n){if(!isGjs$1()){let a=globalThis.process;if(a&&typeof a.cpuUsage==`function`)return a.cpuUsage(n)}return{user:0,system:0}}var Tt=__esmMin(()=>{yt(),__name$1(isGjs$1,`isGjs`)}),Et,Dt,Ot,kt=__esmMin(()=>{if(Et=null,Dt=globalThis.imports?.gi,Dt)try{Et=Dt.GjsifyTerminal}catch{}Ot=Et});function onceWrapper(){let{target:n,type:a,listener:S}=this;return this.wrapperFn&&n.removeListener(a,this.wrapperFn),S.apply(n,Array.from(arguments))}function _onceWrap(n,a,S){let C={target:n,type:a,listener:S,wrapperFn:void 0},N=onceWrapper.bind(C);return C.wrapperFn=N,N.listener=S,N}function arrayClone(n){switch(n.length){case 0:return[];case 1:return[n[0]];case 2:return[n[0],n[1]];case 3:return[n[0],n[1],n[2]];default:return n.slice()}}function checkListener(n){if(typeof n!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof n)}function validateNumber(n,a){if(typeof n!=`number`||n!==n)throw TypeError(`The "${a}" argument must be of type number. Received type ${typeof n}`)}function spliceOne(n,a){for(;a+1<n.length;a++)n[a]=n[a+1];n.pop()}function unwrapListeners(n){let a=Array.from({length:n.length});for(let S=0;S<a.length;++S)a[S]=n[S].listener??n[S];return a}function createAbortError$2(n){let a=Error(`The operation was aborted`);return a.name=`AbortError`,a.code=`ABORT_ERR`,n?.reason&&(a.cause=n.reason),a}var At,jt,Mt,Nt=__esmMin(()=>{Ae(),At=Symbol(`kCapture`),jt=Symbol.for(`nodejs.rejection`),Mt=class EventEmitter{static defaultMaxListeners=10;static errorMonitor=Symbol(`events.errorMonitor`);static captureRejectionSymbol=jt;static _captureRejections=!1;static get captureRejections(){return EventEmitter._captureRejections}static set captureRejections(n){if(typeof n!=`boolean`)throw TypeError(`The "captureRejections" argument must be of type boolean.`);EventEmitter._captureRejections=n}_events;_eventsCount;_maxListeners;[At];constructor(n){this._events=Object.create(null),this._eventsCount=0,this._maxListeners=void 0,this[At]=n?.captureRejections??EventEmitter._captureRejections}setMaxListeners(n){if(validateNumber(n,`n`),n<0)throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+n);return this._maxListeners=n,this}getMaxListeners(){return this._maxListeners??EventEmitter.defaultMaxListeners}emit(n,...a){let S=this._events,C=n===`error`;if(S!==void 0)C&&S[EventEmitter.errorMonitor]!==void 0&&this.emit(EventEmitter.errorMonitor,...a),C&&=S.error===void 0;else if(!C)return!1;if(C){let n;if(n=a.length>0?a[0]:Error(`Unhandled error.`),n instanceof Error)throw n;let S=Error(`Unhandled error. (`+n+`)`);throw S.context=n,S}let N=S[n];if(N===void 0)return!1;if(typeof N==`function`){let S=N.apply(this,a);S!=null&&this[At]&&this._addCatch(S,n,a)}else{let S=arrayClone(N),C=S.length;for(let N=0;N<C;++N){let C=S[N].apply(this,a);C!=null&&this[At]&&this._addCatch(C,n,a)}}return!0}_addCatch(n,a,S){typeof n?.then==`function`&&n.then(void 0,n=>{let C=this[jt];if(typeof C==`function`)C.call(this,n,a,...S);else{let a=this[At];try{this[At]=!1,this.emit(`error`,n)}finally{this[At]=a}}})}addListener(n,a){return this._addListener(n,a,!1)}on(n,a){return this._addListener(n,a,!1)}prependListener(n,a){return this._addListener(n,a,!0)}_addListener(n,a,S){checkListener(a);let C=this._events;C===void 0?(C=this._events=Object.create(null),this._eventsCount=0):C.newListener!==void 0&&(this.emit(`newListener`,n,a.listener??a),C=this._events);let N=C[n];N===void 0?(C[n]=a,++this._eventsCount):typeof N==`function`?C[n]=S?[a,N]:[N,a]:S?N.unshift(a):N.push(a);let F=this.getMaxListeners();if(F>0){let a=typeof C[n]==`function`?1:C[n].length;if(a>F&&!C[n].warned){typeof C[n]!=`function`&&(C[n].warned=!0);let S=Error(`Possible EventEmitter memory leak detected. ${a} ${String(n)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);S.name=`MaxListenersExceededWarning`,ke.warn(S.message)}}return this}once(n,a){return checkListener(a),this.on(n,_onceWrap(this,n,a)),this}prependOnceListener(n,a){return checkListener(a),this.prependListener(n,_onceWrap(this,n,a)),this}removeListener(n,a){checkListener(a);let S=this._events;if(S===void 0)return this;let C=S[n];if(C===void 0)return this;if(C===a||C.listener===a)--this._eventsCount===0?this._events=Object.create(null):(delete S[n],S.removeListener&&this.emit(`removeListener`,n,C.listener??a));else if(typeof C!=`function`){let N=-1;for(let n=C.length-1;n>=0;n--)if(C[n]===a||C[n].listener===a){N=n;break}if(N<0)return this;N===0?C.shift():spliceOne(C,N),C.length===1&&(S[n]=C[0]),S.removeListener!==void 0&&this.emit(`removeListener`,n,a.listener??a)}return this}off(n,a){return this.removeListener(n,a)}removeAllListeners(n){let a=this._events;if(a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[n]),this;if(arguments.length===0){let n=Object.keys(a);for(let a=0;a<n.length;++a){let S=n[a];S!==`removeListener`&&this.removeAllListeners(S)}return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}let S=a[n];if(typeof S==`function`)this.removeListener(n,S);else if(S!==void 0)for(let a=S.length-1;a>=0;a--)this.removeListener(n,S[a]);return this}listeners(n){let a=this._events;if(a===void 0)return[];let S=a[n];return S===void 0?[]:typeof S==`function`?[S.listener??S]:unwrapListeners(S)}rawListeners(n){let a=this._events;if(a===void 0)return[];let S=a[n];return S===void 0?[]:typeof S==`function`?[S]:arrayClone(S)}listenerCount(n){let a=this._events;if(a===void 0)return 0;let S=a[n];return S===void 0?0:typeof S==`function`?1:S.length}eventNames(){return(this._eventsCount??0)>0?Reflect.ownKeys(this._events):[]}static once(n,a,S){return new Promise((C,N)=>{let F=S?.signal;if(F?.aborted){N(createAbortError$2(F));return}if(typeof n.addEventListener==`function`){let S=n,handler=(...n)=>{F&&F.removeEventListener(`abort`,abortHandler),C(n)},errorHandler=n=>{F&&F.removeEventListener(`abort`,abortHandler),S.removeEventListener(`error`,errorHandler),N(n)},abortHandler=()=>{S.removeEventListener(a,handler),S.removeEventListener(`error`,errorHandler),N(createAbortError$2(F))};S.addEventListener(a,handler,{once:!0}),a!==`error`&&S.addEventListener(`error`,errorHandler,{once:!0}),F&&F.addEventListener(`abort`,abortHandler,{once:!0});return}let I=n,eventHandler=(...n)=>{F&&F.removeEventListener(`abort`,abortHandler),errorHandler!==void 0&&I.removeListener(`error`,errorHandler),C(n)},errorHandler;a!==`error`&&(errorHandler=n=>{I.removeListener(a,eventHandler),F&&F.removeEventListener(`abort`,abortHandler),N(n)},I.once(`error`,errorHandler)),I.once(a,eventHandler);let abortHandler=()=>{I.removeListener(a,eventHandler),errorHandler&&I.removeListener(`error`,errorHandler),N(createAbortError$2(F))};F&&F.addEventListener(`abort`,abortHandler,{once:!0})})}static on(n,a,S){let C=S?.signal;if(C?.aborted)throw createAbortError$2(C);let N=S?.highWaterMark??2**53-1,F=S?.lowWaterMark??1;validateNumber(N,`highWaterMark`),validateNumber(F,`lowWaterMark`);let I=[],H=[],W=null,K=!1,q=!1,eventHandler=(...a)=>{if(H.length>0){let{resolve:n}=H.shift();n({value:a,done:!1})}else I.push(a),I.length>=N&&!q&&(q=!0,typeof n.pause==`function`&&n.pause())},errorHandler=n=>{if(W=n,H.length>0){let{reject:a}=H.shift();a(n)}Y.return()},abortHandler=()=>{errorHandler(createAbortError$2(C))};n.on(a,eventHandler),a!==`error`&&n.on(`error`,errorHandler),C&&C.addEventListener(`abort`,abortHandler,{once:!0});let cleanup=()=>{n.removeListener(a,eventHandler),n.removeListener(`error`,errorHandler),C&&C.removeEventListener(`abort`,abortHandler),K=!0;for(let{resolve:n}of H)n({value:void 0,done:!0});H.length=0,I.length=0},Y={next(){if(I.length>0){let a=I.shift();return q&&I.length<F&&(q=!1,typeof n.resume==`function`&&n.resume()),Promise.resolve({value:a,done:!1})}if(W){let n=Promise.reject(W);return W=null,n}return K?Promise.resolve({value:void 0,done:!0}):new Promise((n,a)=>{H.push({resolve:n,reject:a})})},return(){return cleanup(),Promise.resolve({value:void 0,done:!0})},throw(n){return K||(W=n,cleanup()),Promise.reject(n)},[Symbol.asyncIterator](){return this}};return Y}static listenerCount(n,a){return n.listenerCount(a)}static getEventListeners(n,a){return typeof n.listeners==`function`?n.listeners(a):[]}static setMaxListeners(n,...a){if(validateNumber(n,`n`),n<0)throw RangeError(`The value of "n" is out of range.`);if(a.length===0)EventEmitter.defaultMaxListeners=n;else for(let S of a)typeof S.setMaxListeners==`function`&&S.setMaxListeners(n)}static getMaxListeners(n){return typeof n.getMaxListeners==`function`?n.getMaxListeners():EventEmitter.defaultMaxListeners}static addAbortListener(n,a){n.aborted&&Promise.resolve().then(()=>a());let handler=()=>a();return n.addEventListener(`abort`,handler,{once:!0}),{[Symbol.dispose](){n.removeEventListener(`abort`,handler)}}}},Mt.EventEmitter=Mt;for(let n of[`setMaxListeners`,`getMaxListeners`,`emit`,`addListener`,`on`,`prependListener`,`once`,`prependOnceListener`,`removeListener`,`off`,`removeAllListeners`,`listeners`,`rawListeners`,`listenerCount`,`eventNames`]){let a=Mt.prototype[n];typeof a==`function`&&Object.defineProperty(Mt.prototype,n,{enumerable:!0,configurable:!0,writable:!0,value:a})}Object.defineProperty(Mt.prototype,"_events",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(Mt.prototype,"_eventsCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(Mt.prototype,"_maxListeners",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),__name$1(createAbortError$2,`createAbortError`)}),Pt=__exportAll$3({EventEmitter:()=>Ft,addAbortListener:()=>Gt,captureRejectionSymbol:()=>It,default:()=>Ft,defaultMaxListeners:()=>Rt,errorMonitor:()=>Lt,getEventListeners:()=>Ut,getMaxListeners:()=>Bt,listenerCount:()=>Wt,"module.exports":()=>Ft,on:()=>Ht,once:()=>Vt,setMaxListeners:()=>zt}),Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt=__esmMin(()=>{Nt(),Xe(),Ft=makeCallable(Mt),Ft.EventEmitter=Ft,It=Ft.captureRejectionSymbol,Lt=Ft.errorMonitor,Rt=Ft.defaultMaxListeners,zt=Ft.setMaxListeners,Bt=Ft.getMaxListeners,Vt=Ft.once,Ht=Ft.on,Ut=Ft.getEventListeners,Wt=Ft.listenerCount,Gt=Ft.addAbortListener});function normalizeAndValidateEncoding(n){return n&&checkEncoding(n),normalizeEncoding(n)}function utf8DecodeMaximalSubpart(n,a,S){let C=``,N=a;for(;N<S;){let a=n[N];if(a<=127){C+=String.fromCharCode(a),N++;continue}if(a>=194&&a<=223){N+1<S&&n[N+1]>=128&&n[N+1]<=191?(C+=String.fromCharCode((a&31)<<6|n[N+1]&63),N+=2):(C+=`�`,N++);continue}if(a>=224&&a<=239){let F,I;if(a===224?(F=160,I=191):a===237?(F=128,I=159):(F=128,I=191),N+1>=S){C+=`�`,N++;continue}let H=n[N+1];if(H<F||H>I){C+=`�`,N++;continue}if(N+2>=S){C+=`�`,N+=2;continue}let W=n[N+2];if(W<128||W>191){C+=`�`,N+=2;continue}let K=(a&15)<<12|(H&63)<<6|W&63;C+=String.fromCharCode(K),N+=3;continue}if(a>=240&&a<=244){let F,I;if(a===240?(F=144,I=191):a===244?(F=128,I=143):(F=128,I=191),N+1>=S){C+=`�`,N++;continue}let H=n[N+1];if(H<F||H>I){C+=`�`,N++;continue}if(N+2>=S){C+=`�`,N+=2;continue}let W=n[N+2];if(W<128||W>191){C+=`�`,N+=2;continue}if(N+3>=S){C+=`�`,N+=3;continue}let K=n[N+3];if(K<128||K>191){C+=`�`,N+=3;continue}let q=(a&7)<<18|(H&63)<<12|(W&63)<<6|K&63;C+=String.fromCharCode(55296+(q-65536>>10),56320+(q-65536&1023)),N+=4;continue}C+=`�`,N++}return C}function utf8CharLength(n){return n&128?n>=194&&n<=223?2:n>=224&&n<=239?3:n>=240&&n<=244?4:0:1}function isValidContinuation(n,a,S,C){if(S===1){if(a===3)return n===224?C>=160&&C<=191:n===237?C>=128&&C<=159:C>=128&&C<=191;if(a===4)return n===240?C>=144&&C<=191:n===244?C>=128&&C<=143:C>=128&&C<=191}return C>=128&&C<=191}function writeUtf8(n,a){let S=0,C=``;if(n._lastNeed>0){for(;S<a.length&&n._lastNeed>0;){let N=a[S],F=n._lastTotal-n._lastNeed;if(isValidContinuation(n._lastLeadByte,n._lastTotal,F,N))n._lastChar[F]=N,n._lastNeed--,S++;else{C+=`�`,n._lastNeed=0,n._lastTotal=0,n._lastLeadByte=0;break}}if(n._lastNeed===0&&n._lastTotal>0&&(C+=utf8DecodeMaximalSubpart(n._lastChar,0,n._lastTotal),n._lastTotal=0,n._lastLeadByte=0),n._lastNeed>0)return C}let N=a.length;for(let C=0;C<Math.min(4,a.length-S);C++){let F=a.length-1-C;if(F<S)break;let I=a[F];if((I&192)!=128){let S=utf8CharLength(I);if(S>0&&I>=128){let C=a.length-F;if(C<S){let H=!0;for(let n=1;n<C;n++)if(!isValidContinuation(I,S,n,a[F+n])){H=!1;break}if(H){N=F;for(let S=0;S<C;S++)n._lastChar[S]=a[F+S];n._lastNeed=S-C,n._lastTotal=S,n._lastLeadByte=I}}}break}}return N>S&&(C+=utf8DecodeMaximalSubpart(a,S,N)),C}function writeUtf16le(n,a){let S=``,C=0;if(n._lastNeed>0){let N=n._lastTotal-n._lastNeed,F=Math.min(n._lastNeed,a.length);for(let S=0;S<F;S++)n._lastChar[N+S]=a[S];if(n._lastNeed-=F,C=F,n._lastNeed>0)return``;let I=n._lastTotal,H=0;for(;H+1<I;){let N=n._lastChar[H]|n._lastChar[H+1]<<8;if(H+=2,N>=55296&&N<=56319){if(H+1<I){let a=n._lastChar[H]|n._lastChar[H+1]<<8;if(a>=56320&&a<=57343){S+=String.fromCharCode(N,a),H+=2;continue}}if(C+1<a.length){let n=a[C]|a[C+1]<<8;if(n>=56320&&n<=57343){S+=String.fromCharCode(N,n),C+=2;continue}}else if(C>=a.length)return n._lastChar[0]=n._lastChar[H-2],n._lastChar[1]=n._lastChar[H-1],n._lastNeed=2,n._lastTotal=4,S}S+=String.fromCharCode(N)}n._lastTotal=0}for(;C+1<a.length;){let N=a[C]|a[C+1]<<8;if(C+=2,N>=55296&&N<=56319)if(C+1<a.length){let n=a[C]|a[C+1]<<8;if(n>=56320&&n<=57343){S+=String.fromCharCode(N,n),C+=2;continue}}else if(C<a.length)return S+=String.fromCharCode(N),n._lastChar[0]=a[C],n._lastNeed=1,n._lastTotal=2,S;else return n._lastChar[0]=a[C-2],n._lastChar[1]=a[C-1],n._lastNeed=2,n._lastTotal=4,S;S+=String.fromCharCode(N)}return C<a.length&&(n._lastChar[0]=a[C],n._lastNeed=1,n._lastTotal=2),S}function writeBase64(n,a){let S=0;if(n._lastNeed>0){let C=Math.min(n._lastNeed,a.length);for(let S=0;S<C;S++)n._lastChar[n._lastTotal-n._lastNeed+S]=a[S],n._lastNeed--;if(S=C,n._lastNeed>0)return``}let C=a.length-S,N=C-C%3,F=``;n._lastTotal>0&&n._lastNeed===0&&(F+=base64Encode$1(n._lastChar.subarray(0,n._lastTotal)),n._lastTotal=0),N>0&&(F+=base64Encode$1(a.subarray(S,S+N)));let I=C-N;if(I>0){for(let C=0;C<I;C++)n._lastChar[C]=a[S+N+C];n._lastNeed=3-I,n._lastTotal=3}return F}function decodeAscii(n){let a=``;for(let S=0;S<n.length;S++)a+=String.fromCharCode(n[S]&127);return a}function decodeLatin1(n){let a=``;for(let S=0;S<n.length;S++)a+=String.fromCharCode(n[S]);return a}function decodeHex(n){let a=``;for(let S=0;S<n.length;S++)a+=n[S].toString(16).padStart(2,`0`);return a}var qt,Jt=__esmMin(()=>{vt(),qt=function StringDecoder(n){this.encoding=normalizeAndValidateEncoding(n),this._lastNeed=0,this._lastTotal=0,this._lastLeadByte=0,this.encoding===`utf8`||this.encoding===`utf16le`?this._lastChar=new Uint8Array(4):this.encoding===`base64`?this._lastChar=new Uint8Array(3):this._lastChar=new Uint8Array},qt.prototype.write=function write(n){if(n.length===0)return``;switch(this.encoding){case`utf8`:return writeUtf8(this,n);case`utf16le`:return writeUtf16le(this,n);case`base64`:return writeBase64(this,n);case`ascii`:return decodeAscii(n);case`latin1`:return decodeLatin1(n);case`hex`:return decodeHex(n);default:return decodeAscii(n)}},qt.prototype.end=function end(n){let a=``;if(n&&n.length>0&&(a=this.write(n)),this.encoding===`utf8`&&this._lastNeed>0)a+=`�`,this._lastNeed=0,this._lastTotal=0;else if(this.encoding===`utf16le`&&this._lastNeed>0){let n=this._lastTotal-this._lastNeed;for(let S=0;S+1<n;S+=2)a+=String.fromCharCode(this._lastChar[S]|this._lastChar[S+1]<<8);this._lastNeed=0,this._lastTotal=0}else if(this.encoding===`base64`&&this._lastNeed>0){let n=this._lastChar.subarray(0,this._lastTotal-this._lastNeed);a+=base64Encode$1(n),this._lastNeed=0,this._lastTotal=0}return a}}),Yt,ProcessWriteStream,ProcessReadStream,Xt=__esmMin(()=>{Ae(),yt(),kt(),Kt(),Xe(),Jt(),Yt=new TextEncoder,ProcessWriteStream=class extends Ft{fd;writable=!0;_outGio=null;constructor(n){super(),this.fd=n;let a=getGioNamespace();if(a){let n=a.UnixOutputStream??a.OutputStream;if(n)try{this._outGio=n.new(this.fd,!1)}catch{}}}write(n){if(this._outGio)try{let a=typeof n==`string`?Yt.encode(n):n;return this._outGio.write_all(a,null),!0}catch{}return this.fd===2?ke.error(n):ke.log(n),!0}get isTTY(){if(Ot)return Ot.Terminal.is_tty(this.fd);try{let n=getGjsGlobal().imports?.gi?.GLib;if(n)return!!n.log_writer_supports_color(this.fd)}catch{}return!1}get columns(){if(Ot){let[n,,a]=Ot.Terminal.get_size(this.fd);if(n&&a>0)return a}try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let a=parseInt(n.getenv(`COLUMNS`)??`0`,10);if(a>0)return a}}catch{}return 80}end(){}destroy(){}get rows(){if(Ot){let[n,a]=Ot.Terminal.get_size(this.fd);if(n&&a>0)return a}try{let n=getGjsGlobal().imports?.gi?.GLib;if(n){let a=parseInt(n.getenv(`LINES`)??`0`,10);if(a>0)return a}}catch{}return 24}},ProcessReadStream=class extends Ft{fd;isRaw=!1;_gio=null;_stdinGio=null;_reading=!1;_flowing=!1;_sttyCleanupRegistered=!1;_mainLoopHeld=!1;_pendingRead=!1;_decoder=null;constructor(n){super(),this.fd=n,this._gio=getGioNamespace()}get isTTY(){return Ot?Ot.Terminal.is_tty(this.fd):!1}setRawMode(n){return Ot&&Ot.Terminal.set_raw_mode(this.fd,n)?(this.isRaw=n,this):(this._setRawModeViaStty(n),this.isRaw=n,this)}_setRawModeViaStty(n){try{let a=globalThis.imports?.gi,S=a?.Gio??a?.Gio;if(!S)return;let C=S.SubprocessFlags?.STDIN_INHERIT??2,N=n?[`stty`,`-icanon`,`-echo`,`-icrnl`,`-isig`,`min`,`1`,`time`,`0`]:[`stty`,`icanon`,`echo`,`icrnl`,`isig`];if(new S.SubprocessLauncher({flags:C}).spawnv(N).wait(null),n&&!this._sttyCleanupRegistered){this._sttyCleanupRegistered=!0;let n=globalThis.process;n?.once&&typeof n.once==`function`&&n.once(`exit`,()=>this._setRawModeViaStty(!1))}}catch{}}setEncoding(n){return this._decoder=new qt(n),this}_pushData(n){if(this._decoder){let a=this._decoder.write(n);a.length>0&&this.emit(`data`,a)}else this.emit(`data`,n)}on(n,a){let S=n===`data`&&this.listenerCount(`data`)===0;return super.on(n,a),S&&n===`data`&&this.resume(),this}addListener(n,a){return this.on(n,a)}once(n,a){return super.once(n,a),this}removeListener(n,a){return super.removeListener(n,a),n===`data`&&this.listenerCount(`data`)===0&&this.pause(),this}off(n,a){return this.removeListener(n,a)}removeAllListeners(n){let a=n===void 0||n===`data`?this.listenerCount(`data`)>0:!1;return super.removeAllListeners(n),a&&this.listenerCount(`data`)===0&&this.pause(),this}resume(){return this._flowing=!0,this._gio&&this.fd===0&&!this._reading&&this._startReading(),this}pause(){if(this._flowing=!1,this._reading=!1,this._mainLoopHeld){this._mainLoopHeld=!1;let n=globalThis.imports?.gi,a=n?.GLib??n?.GLib;a?.idle_add?a.idle_add(300,()=>(this._mainLoopHeld||quitMainLoop(),!1)):quitMainLoop()}return this}read(){return null}_startReading(){if(!this._gio||this._reading)return;if(this._pendingRead){this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop());return}if(this._reading=!0,this._mainLoopHeld||(this._mainLoopHeld=!0,ensureMainLoop()),!this._stdinGio){let n=this._gio.UnixInputStream??this._gio.InputStream;if(!n){this._reading=!1;return}try{this._stdinGio=n.new(this.fd,!1)}catch{this._reading=!1;return}}let loop=()=>{if(!this._reading){this._pendingRead=!1;return}this._pendingRead=!0,this._stdinGio.read_bytes_async(4096,0,null,(n,a)=>{this._pendingRead=!1;try{let S=n.read_bytes_finish(a)?.get_data?.()??null;if(S&&S.byteLength>0)this._pushData(Buffer.from(S));else if(S!==null&&S.byteLength===0){if(this._reading=!1,this._decoder){let n=this._decoder.end();n.length>0&&this.emit(`data`,n)}this.emit(`end`);return}}catch{this._reading=!1;return}this._reading&&loop()})};loop()}}}),Zt,Process,Qt=__esmMin(()=>{Ae(),St(),Ct(),wt(),xt(),Tt(),Xt(),Kt(),Zt=Date.now(),Process=class extends Ft{platform;arch;env;argv;argv0;execPath;pid;ppid;version;versions;title;execArgv;config;exitCode;constructor(){super(),this.platform=detectPlatform(),this.arch=detectArch(),this.env=getEnvProxy(),this.argv=getArgv(),this.argv0=this.argv[0]||`gjs`,this.execPath=getExecPath(),this.execArgv=globalThis.process?.execArgv??[],this.config=globalThis.process?.config??{target_defaults:{},variables:{}},this.pid=getPid$1(),this.ppid=detectPpid();let n=detectVersionInfo();this.version=n.version,this.versions=n.versions,this.title=n.title}cwd(){return getCwd()}chdir(n){chdir(n)}kill(n,a){return killPid(n,a)}exit(n){return this.exitCode=n??this.exitCode??0,this.emit(`exit`,this.exitCode),exitProcess(this.exitCode)}nextTick(n,...a){typeof queueMicrotask==`function`?queueMicrotask(()=>n(...a)):Promise.resolve().then(()=>n(...a))}hrtime(n){return hrtime(n)}uptime(){return(Date.now()-Zt)/1e3}memoryUsage(){return memoryUsage()}cpuUsage(n){return cpuUsage(n)}stdout=new ProcessWriteStream(1);stderr=new ProcessWriteStream(2);stdin=new ProcessReadStream(0);abort(){this.exit(1)}umask(n){return 18}emitWarning(n,a){ke.warn(typeof n==`string`?`(${a||`Warning`}): ${n}`:n.message)}},Process.prototype.hrtime.bigint=function(){return hrtimeBigint()}}),$t,en,tn,nn,rn,an,on,sn=__esmMin(()=>{if(xt(),Qt(),kt(),$t=new Process,Ot)try{let n=new Ot.ResizeWatcher;n.connect(`resized`,(n,a,S)=>{$t.stdout.emit(`resize`),$t.stderr.emit(`resize`)}),n.start()}catch{}en=$t.platform,$t.arch,$t.env,$t.argv,$t.argv0,tn=$t.execPath,$t.pid,$t.ppid,$t.version,$t.versions,$t.cwd.bind($t),$t.chdir.bind($t),$t.exit.bind($t),$t.nextTick.bind($t),nn=Object.assign($t.hrtime.bind($t),{bigint:hrtimeBigint}),$t.uptime.bind($t),$t.memoryUsage.bind($t),$t.cpuUsage.bind($t),$t.kill.bind($t),$t.abort.bind($t),$t.umask.bind($t),$t.emitWarning.bind($t),rn=$t.execArgv,$t.config,an=$t.stdout,$t.stderr,on=$t.stdin});Xe(),sn(),typeof Promise.withResolvers!=`function`&&(Promise.withResolvers=function(){let n,a;return{promise:new Promise((S,C)=>{n=S,a=C}),resolve:n,reject:a}}),initErrorV8Methods(Error),`global`in globalThis||Object.defineProperty(globalThis,"global",{value:globalThis,writable:!1,enumerable:!1,configurable:!0}),Object.defineProperty(globalThis,"process",{value:$t,enumerable:!1,writable:!0,configurable:!0}),Xe(),typeof globalThis.structuredClone!=`function`&&Object.defineProperty(globalThis,"structuredClone",{value:structuredClone$1,enumerable:!0,writable:!0,configurable:!0});function getGLib(){return globalThis.imports?.gi?.GLib}const cn=getGLib()!==void 0;var GjsifyTimeout=class{_id=null;_refed=!0;_callback;_delay;_args;_repeat;constructor(n,a,S,C){this._callback=n,this._delay=a,this._args=S,this._repeat=C,this._schedule()}_schedule(){let n=getGLib();if(!n)return;let a=n.timeout_add.bind(n);this._id=a(n.PRIORITY_DEFAULT,this._delay,()=>{try{this._callback.apply(globalThis,this._args)}catch(n){setTimeout(()=>{throw n},0)}return this._repeat?n.SOURCE_CONTINUE:(this._id=null,n.SOURCE_REMOVE)})}ref(){return this._refed=!0,this}unref(){return this._refed=!1,this}hasRef(){return this._refed}refresh(){return this._cancel(),this._schedule(),this}_cancel(){if(this._id!==null){try{getGLib()?.Source.remove(this._id)}catch{}this._id=null}}[Symbol.toPrimitive](){return this._id}[Symbol.dispose](){this._cancel()}};function removeById(n){if(n instanceof GjsifyTimeout)n._cancel();else if(typeof n==`number`)try{getGLib()?.Source.remove(n)}catch{}}if(cn){let setT=(n,a=0,...S)=>new GjsifyTimeout(n,Math.max(0,a|0),S,!1),setI=(n,a=0,...S)=>new GjsifyTimeout(n,Math.max(0,a|0),S,!0),n=globalThis;n.setTimeout=setT,n.clearTimeout=removeById,n.setInterval=setI,n.clearInterval=removeById}function setImmediate$2(n,...a){return setTimeout(n,0,...a)}__name$1(setImmediate$2,`setImmediate`);function clearImmediate(n){clearTimeout(n)}`setImmediate`in globalThis||Object.defineProperty(globalThis,"setImmediate",{value:setImmediate$2,enumerable:!0,writable:!0,configurable:!0}),`clearImmediate`in globalThis||Object.defineProperty(globalThis,"clearImmediate",{value:clearImmediate,enumerable:!0,writable:!0,configurable:!0});var ln=__exportAll$3({URL:()=>fn,URLSearchParams:()=>dn,default:()=>pn,domainToASCII:()=>domainToASCII,domainToUnicode:()=>domainToUnicode,fileURLToPath:()=>fileURLToPath,format:()=>format$4,parse:()=>parse$4,pathToFileURL:()=>pathToFileURL,resolve:()=>resolve$3});function decodeComponent(n){try{return decodeURIComponent(n.replace(/\+/g,` `))}catch{return n}}function encodeComponent(n){return encodeURIComponent(n).replace(/%20/g,`+`)}function parse$4(n,a,S){if(typeof n!=`string`)throw TypeError(`The "url" argument must be of type string. Received type `+typeof n);let C={protocol:null,slashes:null,auth:null,host:null,port:null,hostname:null,hash:null,search:null,query:null,pathname:null,path:null,href:n},N=n.trim(),F=N.indexOf(`#`);F!==-1&&(C.hash=N.slice(F),N=N.slice(0,F));let I=N.indexOf(`?`);I!==-1&&(C.search=N.slice(I),C.query=a?Object.fromEntries(new dn(N.slice(I+1))):N.slice(I+1),N=N.slice(0,I));let H=/^([a-z][a-z0-9.+-]*:)/i.exec(N);if(H&&(C.protocol=H[1].toLowerCase(),N=N.slice(C.protocol.length)),(S||C.protocol)&&N.startsWith(`//`)&&(C.slashes=!0,N=N.slice(2)),C.slashes||C.protocol&&![`javascript:`,`data:`,`mailto:`].includes(C.protocol)){let n=-1;for(let a=0;a<N.length;a++){let S=N[a];if(S===`/`||S===`\\`){n=a;break}}let a=n===-1?N:N.slice(0,n);N=n===-1?``:N.slice(n);let S=a.lastIndexOf(`@`);S===-1?parseHostPort(a,C):(C.auth=decodeURIComponent(a.slice(0,S)),parseHostPort(a.slice(S+1),C))}return C.pathname=N||(C.slashes?`/`:null),(C.pathname!==null||C.search!==null)&&(C.path=(C.pathname||``)+(C.search||``)),C.href=format$4(C),C}function parseHostPort(n,a){if(!n)return;let S=n.indexOf(`[`);if(S!==-1){let C=n.indexOf(`]`,S);if(C!==-1){let N=n.slice(C+1);N.startsWith(`:`)&&(a.port=N.slice(1)),a.hostname=n.slice(S,C+1),a.host=a.hostname+(a.port?`:`+a.port:``);return}}let C=n.lastIndexOf(`:`);if(C!==-1){let S=n.slice(C+1);/^\d*$/.test(S)?(a.port=S||null,a.hostname=n.slice(0,C).toLowerCase()):a.hostname=n.toLowerCase()}else a.hostname=n.toLowerCase();a.host=a.hostname+(a.port?`:`+a.port:``)}function format$4(n){if(typeof n==`string`)return n;if(n instanceof fn)return n.href;let a=n,S=``;if(a.protocol&&(S+=a.protocol),(a.slashes||a.protocol&&![`javascript:`,`data:`,`mailto:`].includes(a.protocol||``))&&(S+=`//`),a.auth&&(S+=encodeURIComponent(a.auth)+`@`),a.host?S+=a.host:(a.hostname&&(S+=a.hostname),a.port&&(S+=`:`+a.port)),a.pathname&&(S+=a.pathname),a.search)S+=a.search;else if(a.query&&typeof a.query==`object`){let n=new dn(a.query).toString();n&&(S+=`?`+n)}return a.hash&&(S+=a.hash),S}function resolve$3(n,a){return new fn(a,new fn(n,`resolve://`)).href.replace(/^resolve:\/\//,``)}function fileURLToPath(n){if(typeof n==`string`&&(n=new fn(n)),!(n instanceof fn))throw TypeError(`The "url" argument must be of type string or URL. Received type `+typeof n);if(n.protocol!==`file:`)throw TypeError(`The URL must be of scheme file`);if(n.hostname!==``&&n.hostname!==`localhost`)throw TypeError(`File URL host must be "localhost" or empty on linux`);let a=n.pathname;for(let n=0;n<a.length;n++)if(a[n]===`%`){let S=a.codePointAt(n+2)|32;if(a[n+1]===`2`&&S===102)throw TypeError(`File URL path must not include encoded / characters`)}return decodeURIComponent(a)}function pathToFileURL(n){let a=n;if(n[0]!==`/`)if(typeof globalThis.process?.cwd==`function`)a=globalThis.process.cwd()+`/`+n;else try{Z?.get_current_dir&&(a=Z.get_current_dir()+`/`+n)}catch{}return new fn(`file://`+encodePathForURL(a))}function encodePathForURL(n){let a=``;for(let S=0;S<n.length;S++){let C=n[S];C>=`a`&&C<=`z`||C>=`A`&&C<=`Z`||C>=`0`&&C<=`9`||C===`/`||C===`-`||C===`_`||C===`.`||C===`~`||C===`:`||C===`@`||C===`!`?a+=C:a+=encodeURIComponent(C)}return a}function domainToASCII(n){try{return new fn(`http://${n}`).hostname}catch{return``}}function domainToUnicode(n){try{return new fn(`http://${n}`).hostname}catch{return``}}var un,dn,fn,pn,mn=__esmMin(()=>{se(),un=Z.UriFlags.HAS_PASSWORD|Z.UriFlags.ENCODED|Z.UriFlags.SCHEME_NORMALIZE,dn=class URLSearchParams{_entries=[];constructor(n){if(n)if(typeof n==`string`){let a=n.startsWith(`?`)?n.slice(1):n;if(a)for(let n of a.split(`&`)){let a=n.indexOf(`=`);a===-1?this._entries.push([decodeComponent(n),``]):this._entries.push([decodeComponent(n.slice(0,a)),decodeComponent(n.slice(a+1))])}}else if(Array.isArray(n))for(let[a,S]of n)this._entries.push([String(a),String(S)]);else if(n instanceof URLSearchParams)this._entries=n._entries.map(([n,a])=>[n,a]);else for(let a of Object.keys(n))this._entries.push([a,String(n[a])])}get(n){for(let[a,S]of this._entries)if(a===n)return S;return null}getAll(n){return this._entries.filter(([a])=>a===n).map(([,n])=>n)}set(n,a){let S=!1;if(this._entries=this._entries.filter(([a])=>a===n?S?!1:(S=!0,!0):!0),S){for(let S=0;S<this._entries.length;S++)if(this._entries[S][0]===n){this._entries[S][1]=a;break}}else this._entries.push([n,a])}has(n){return this._entries.some(([a])=>a===n)}delete(n){this._entries=this._entries.filter(([a])=>a!==n)}append(n,a){this._entries.push([n,a])}sort(){this._entries.sort((n,a)=>n[0]<a[0]?-1:+(n[0]>a[0]))}toString(){return this._entries.map(([n,a])=>encodeComponent(n)+`=`+encodeComponent(a)).join(`&`)}forEach(n){for(let[a,S]of this._entries)n(S,a,this)}*entries(){yield*this._entries}*keys(){for(let[n]of this._entries)yield n}*values(){for(let[,n]of this._entries)yield n}[Symbol.iterator](){return this.entries()}get size(){return this._entries.length}},fn=class URL{#e;#t;constructor(n,a){let S=n instanceof URL?n.href:String(n);try{if(a!==void 0){let n=a instanceof URL?a.href:String(a),C=Z.Uri.parse(n,un);this.#e=C.parse_relative(S,un)}else this.#e=Z.Uri.parse(S,un)}catch{throw TypeError(`Invalid URL: ${S}`)}if(!this.#e)throw TypeError(`Invalid URL: ${S}`);this.#t=new dn(this.#e.get_query()||``)}get protocol(){return this.#e.get_scheme()+`:`}get hostname(){return(this.#e.get_host()||``).toLowerCase()}get port(){let n=this.#e.get_port();if(n===-1)return``;let a=this.#e.get_scheme();return(a===`http`||a===`ws`)&&n===80||(a===`https`||a===`wss`)&&n===443||a===`ftp`&&n===21?``:String(n)}get host(){let n=this.hostname,a=this.port;return a?`${n}:${a}`:n}get pathname(){return this.#e.get_path()||`/`}get search(){let n=this.#e.get_query();return n?`?`+n:``}get hash(){let n=this.#e.get_fragment();return n?`#`+n:``}get origin(){let n=this.protocol;return n===`http:`||n===`https:`||n===`ftp:`?`${n}//${this.host}`:`null`}get username(){return this.#e.get_user()||``}get password(){return this.#e.get_password()||``}get href(){let n=this.protocol,a=this.#e.get_scheme();(a===`http`||a===`https`||a===`ftp`||a===`file`||a===`ws`||a===`wss`||this.hostname)&&(n+=`//`);let S=this.username,C=this.password;S&&(n+=S,C&&(n+=`:`+C),n+=`@`),n+=this.hostname,this.port&&(n+=`:`+this.port);let N=this.pathname;return n+=N,n+=this.search,n+=this.hash,n}get searchParams(){return this.#t}toString(){return this.href}toJSON(){return this.href}static _objectURLPaths=new Map;static _objectURLCounter=0;static createObjectURL(n){let a=n?._tmpPath;if(typeof a==`string`&&a.length>0){let n=`file://${a}`;return URL._objectURLPaths.set(n,a),n}return`file:///dev/null`}static revokeObjectURL(n){let a=URL._objectURLPaths.get(n);if(a){try{Z.unlink(a)}catch{}URL._objectURLPaths.delete(n)}}},__name$1(parse$4,`parse`),__name$1(format$4,`format`),__name$1(resolve$3,`resolve`),pn={URL:fn,URLSearchParams:dn,parse:parse$4,format:format$4,resolve:resolve$3,fileURLToPath,pathToFileURL,domainToASCII,domainToUnicode}});mn(),typeof globalThis.URL!=`function`&&Object.defineProperty(globalThis,"URL",{value:fn,enumerable:!1,writable:!0,configurable:!0}),typeof globalThis.URLSearchParams!=`function`&&Object.defineProperty(globalThis,"URLSearchParams",{value:dn,enumerable:!1,writable:!0,configurable:!0});var hn=__exportAll$3({PerformanceEntry:()=>yn,PerformanceMark:()=>xn,PerformanceMeasure:()=>Sn,PerformanceObserver:()=>vn,PerformanceObserverEntryList:()=>bn,default:()=>Cn,eventLoopUtilization:()=>eventLoopUtilization,monitorEventLoopDelay:()=>monitorEventLoopDelay,performance:()=>gn,timerify:()=>timerify});function eventLoopUtilization(n,a){return{idle:0,active:0,utilization:0}}function timerify(n){let wrapped=function(...a){let S=gn.now(),C=n.apply(this,a);return gn.now()-S,C};return Object.defineProperty(wrapped,"name",{value:n.name}),wrapped}function monitorEventLoopDelay(n){let a=new Map;return{enable(){},disable(){},reset(){},percentile(n){return 0},get min(){return 0},get max(){return 0},get mean(){return 0},get stddev(){return 0},get percentiles(){return a}}}var gn,PerformanceObserverStub,PerformanceEntryStub,PerformanceObserverEntryListStub,_n,vn,yn,bn,xn,Sn,Cn,wn=__esmMin(()=>{if(globalThis.performance)gn=globalThis.performance;else{let n,_now;try{let a=globalThis.imports?.gi?.GLib;if(!a)throw Error(`GJS imports.gi.GLib not available`);n=a.get_monotonic_time(),_now=()=>(a.get_monotonic_time()-n)/1e3}catch{let a=Date.now();n=0,_now=()=>Date.now()-a}let a=[],S=Date.now()-_now();gn={timeOrigin:S,now:_now,mark(n){let S={name:n,entryType:`mark`,startTime:_now(),duration:0};return a.push(S),S},measure(n,S,C){let N=0,F=_now();if(S){let n=a.find(n=>n.entryType===`mark`&&n.name===S);n&&(N=n.startTime)}if(C){let n=a.find(n=>n.entryType===`mark`&&n.name===C);n&&(F=n.startTime)}let I={name:n,entryType:`measure`,startTime:N,duration:F-N};return a.push(I),I},getEntries(){return[...a]},getEntriesByName(n){return a.filter(a=>a.name===n)},getEntriesByType(n){return a.filter(a=>a.entryType===n)},clearMarks(n){for(let S=a.length-1;S>=0;S--)a[S].entryType===`mark`&&(!n||a[S].name===n)&&a.splice(S,1)},clearMeasures(n){for(let S=a.length-1;S>=0;S--)a[S].entryType===`measure`&&(!n||a[S].name===n)&&a.splice(S,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:S}}}}PerformanceObserverStub=class{_callback;constructor(n){this._callback=n}observe(n){}disconnect(){}takeRecords(){return[]}},PerformanceEntryStub=class{name=``;entryType=``;startTime=0;duration=0;toJSON(){return{name:this.name,entryType:this.entryType,startTime:this.startTime,duration:this.duration}}},PerformanceObserverEntryListStub=class{getEntries(){return[]}getEntriesByName(n){return[]}getEntriesByType(n){return[]}},_n=globalThis,vn=_n.PerformanceObserver||PerformanceObserverStub,yn=_n.PerformanceEntry||PerformanceEntryStub,bn=_n.PerformanceObserverEntryList||PerformanceObserverEntryListStub,xn=_n.PerformanceMark||class PerformanceMark extends PerformanceEntryStub{},Sn=_n.PerformanceMeasure||class PerformanceMeasure extends PerformanceEntryStub{},Cn={performance:gn,PerformanceObserver:vn,PerformanceEntry:yn,PerformanceObserverEntryList:bn,PerformanceMark:xn,PerformanceMeasure:Sn,eventLoopUtilization,timerify,monitorEventLoopDelay}});wn();const Tn=globalThis;globalThis.performance===void 0&&(Tn.performance=gn),typeof Tn.PerformanceObserver!=`function`&&(Tn.PerformanceObserver=vn);const En={IndexSizeError:1,HierarchyRequestError:3,WrongDocumentError:4,InvalidCharacterError:5,NoModificationAllowedError:7,NotFoundError:8,NotSupportedError:9,InUseAttributeError:10,InvalidStateError:11,SyntaxError:12,InvalidModificationError:13,NamespaceError:14,InvalidAccessError:15,TypeMismatchError:17,SecurityError:18,NetworkError:19,AbortError:20,URLMismatchError:21,QuotaExceededError:22,TimeoutError:23,InvalidNodeTypeError:24,DataCloneError:25};var _DOMExceptionPolyfill=class extends Error{code;constructor(n,a){super(n),this.name=a||`Error`,this.code=Object.hasOwn(En,this.name)?En[this.name]:0}};const Q=globalThis.DOMException===void 0?_DOMExceptionPolyfill:globalThis.DOMException;Ae();const Dn=Symbol(`type`),On=Symbol(`bubbles`),kn=Symbol(`cancelable`),An=Symbol(`composed`),jn=Symbol(`target`),Mn=Symbol(`currentTarget`),Nn=Symbol(`eventPhase`),Pn=Symbol(`defaultPrevented`),Fn=Symbol(`isTrusted`),In=Symbol(`timeStamp`),Ln=Symbol(`stop`),Rn=Symbol(`immediateStop`),zn=Symbol(`dispatching`),Bn=Symbol(`inPassiveListener`);var Event=class{[Dn];[On];[kn];[An];[jn]=null;[Mn]=null;[Nn]=0;[Pn]=!1;[Fn]=!1;[In];[Ln]=!1;[Rn]=!1;[zn]=!1;[Bn]=!1;get type(){return this[Dn]}get bubbles(){return this[On]}get cancelable(){return this[kn]}get composed(){return this[An]}get target(){return this[jn]}get currentTarget(){return this[Mn]}get eventPhase(){return this[Nn]}get defaultPrevented(){return this[Pn]}get timeStamp(){return this[In]}get cancelBubble(){return this[Ln]}set cancelBubble(n){n&&this.stopPropagation()}get returnValue(){return!this[Pn]}set returnValue(n){n||this.preventDefault()}get srcElement(){return this[jn]}static NONE=0;static CAPTURING_PHASE=1;static AT_TARGET=2;static BUBBLING_PHASE=3;get[Symbol.toStringTag](){return`Event`}constructor(n,a){this[Dn]=n,this[On]=a?.bubbles??!1,this[kn]=a?.cancelable??!1,this[An]=a?.composed??!1,this[In]=Date.now(),Object.defineProperty(this,"isTrusted",{get:()=>this[Fn],enumerable:!0,configurable:!1})}composedPath(){return this[Mn]?[this[Mn]]:[]}preventDefault(){this[kn]&&!this[Bn]&&(this[Pn]=!0)}stopPropagation(){this[Ln]=!0}stopImmediatePropagation(){this[Ln]=!0,this[Rn]=!0}},EventTarget=class{_listeners=new Map;get[Symbol.toStringTag](){return`EventTarget`}addEventListener(n,a,S){if(a===null)return;let C=typeof S==`boolean`?S:S?.capture??!1,N=typeof S==`object`?S?.once??!1:!1,F=typeof S==`object`?S?.passive??!1:!1,I=this._listeners.get(n);I||(I=[],this._listeners.set(n,I));for(let n of I)if(n.listener===a&&n.capture===C)return;let H={listener:a,capture:C,once:N,passive:F,removed:!1};I.push(H),typeof S==`object`&&S?.signal&&S.signal.addEventListener(`abort`,()=>{this.removeEventListener(n,a,{capture:C})},{once:!0})}removeEventListener(n,a,S){if(a===null)return;let C=typeof S==`boolean`?S:S?.capture??!1,N=this._listeners.get(n);if(!N)return;let F=N.findIndex(n=>n.listener===a&&n.capture===C);F!==-1&&(N[F].removed=!0,N.splice(F,1),N.length===0&&this._listeners.delete(n))}dispatchEvent(n){let a=n;if(a[zn])throw new Q(`The event is already being dispatched.`,`InvalidStateError`);a[zn]=!0,a[jn]=this,a[Mn]=this,a[Nn]=Event.AT_TARGET;let S=this._listeners.get(n.type);if(S){let C=[...S];for(let S of C)if(!S.removed){if(a[Rn]||a[Ln])break;S.once&&this.removeEventListener(n.type,S.listener,{capture:S.capture});try{S.passive&&(a[Bn]=!0),typeof S.listener==`function`?S.listener.call(this,n):typeof S.listener.handleEvent==`function`&&S.listener.handleEvent.call(S.listener,n)}catch(n){let a=globalThis;if(typeof a.reportError==`function`)try{a.reportError(n)}catch{}else if(n instanceof Error){let a=`${n.name}: ${n.message}`;ke.error(n.stack?`${a}\n${n.stack}`:a)}else ke.error(String(n))}finally{a[Bn]=!1}}}return a[Nn]=Event.NONE,a[Mn]=null,a[zn]=!1,!n.defaultPrevented}};for(let[n,a]of[[`NONE`,0],[`CAPTURING_PHASE`,1],[`AT_TARGET`,2],[`BUBBLING_PHASE`,3]])Object.defineProperty(Event.prototype,n,{value:a,writable:!1,enumerable:!0,configurable:!1}),Object.defineProperty(Event,n,{value:a,writable:!1,enumerable:!0,configurable:!1});const Vn=Symbol(`abort`),Hn=Symbol(`internal`);var Un=class AbortSignal extends EventTarget{#e=!1;reason=void 0;onabort=null;constructor(n){if(super(),n!==Hn)throw TypeError(`Illegal constructor.`)}get aborted(){if(!(this instanceof AbortSignal))throw TypeError(`'get aborted' called on an object that is not a valid instance of AbortSignal.`);return this.#e}get[Symbol.toStringTag](){return`AbortSignal`}throwIfAborted(){if(this.#e)throw this.reason}[Vn](n){if(this.#e)return;this.#e=!0,this.reason=n??new Q(`The operation was aborted.`,`AbortError`);let a=new Event(`abort`);typeof this.onabort==`function`&&this.onabort.call(this,a),this.dispatchEvent(a)}static abort(n){let a=new AbortSignal(Hn);return a[Vn](n),a}static timeout(n){let a=new AbortSignal(Hn);return setTimeout(()=>{a[Vn](new Q(`The operation timed out.`,`TimeoutError`))},n),a}static any(n){let a=new AbortSignal(Hn);for(let S of n)if(S.aborted)return a[Vn](S.reason),a;let onAbort=()=>{if(!a.aborted){let S=n.find(n=>n.aborted);a[Vn](S?.reason)}};for(let a of n)a.addEventListener(`abort`,onAbort,{once:!0});return a}},Wn=class AbortController{signal;constructor(){this.signal=new Un(Hn)}abort(n){if(!(this instanceof AbortController))throw TypeError(`'abort' called on an object that is not a valid instance of AbortController.`);this.signal[Vn](n)}};const Gn=globalThis;globalThis.AbortController===void 0&&(Gn.AbortController=Wn),globalThis.AbortSignal===void 0&&(Gn.AbortSignal=Un);const Kn=Symbol(`kState`),qn=Symbol(`kType`);function isBrandCheck(n){return a=>typeof a==`object`&&!!a&&a[Kn]!==void 0&&a[qn]===n}function dequeueValue(n){let a=n[Kn].queue.shift();if(a===void 0)throw Error(`dequeueValue called on an empty queue`);let{value:S,size:C}=a;return n[Kn].queueTotalSize=Math.max(0,n[Kn].queueTotalSize-C),S}function resetQueue(n){n[Kn].queue=[],n[Kn].queueTotalSize=0}function peekQueueValue(n){return n[Kn].queue[0].value}function enqueueValueWithSize(n,a,S){if(S=+S,typeof S!=`number`||S<0||Number.isNaN(S)||S===1/0)throw RangeError(`Invalid size: ${S}`);n[Kn].queue.push({value:a,size:S}),n[Kn].queueTotalSize+=S}function extractHighWaterMark(n,a){if(n===void 0)return a;if(n=+n,typeof n!=`number`||Number.isNaN(n)||n<0)throw RangeError(`Invalid highWaterMark: ${n}`);return n}function extractSizeAlgorithm(n){if(n===void 0)return()=>1;if(typeof n!=`function`)throw TypeError(`strategy.size must be a function`);return n}function transferArrayBuffer(n){return typeof ArrayBuffer.prototype.transfer==`function`?n.transfer():n.slice(0)}function isDetachedBuffer(n){if(typeof SharedArrayBuffer<`u`&&n instanceof SharedArrayBuffer||n.byteLength!==0)return!1;try{return n.slice(0,0),!1}catch{return!0}}function typedArrayConstructorByTag(n){switch(n){case`Int8Array`:return Int8Array;case`Uint8Array`:return Uint8Array;case`Uint8ClampedArray`:return Uint8ClampedArray;case`Int16Array`:return Int16Array;case`Uint16Array`:return Uint16Array;case`Int32Array`:return Int32Array;case`Uint32Array`:return Uint32Array;case`Float32Array`:return Float32Array;case`Float64Array`:return Float64Array;case`BigInt64Array`:return typeof BigInt64Array<`u`?BigInt64Array:void 0;case`BigUint64Array`:return typeof BigUint64Array<`u`?BigUint64Array:void 0;default:return}}function elementSizeByTag(n){switch(n){case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:return 1;case`Int16Array`:case`Uint16Array`:return 2;case`Int32Array`:case`Uint32Array`:case`Float32Array`:return 4;case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:return 8;default:return 1}}function setPromiseHandled(n){n.then(()=>{},()=>{})}function createPromiseCallback(n,a,S){if(typeof a!=`function`)throw TypeError(`${n} must be a function`);return async(...n)=>a.call(S,...n)}async function nonOpFlush(){}function nonOpStart(){}async function nonOpPull(){}async function nonOpCancel(){}async function nonOpWrite(){}const Jn={__proto__:Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),next:void 0,return:void 0};function createAsyncFromSyncIterator(n){let a={[Symbol.iterator]:()=>n.iterator},S=(async function*(){return yield*a})();return{iterator:S,nextMethod:S.next,done:!1}}function getIterator(n,a=`sync`,S){if(S===void 0)if(a===`async`){if(S=n[Symbol.asyncIterator],S==null){let a=n[Symbol.iterator];if(a===void 0)throw TypeError(`Object is not iterable`);return createAsyncFromSyncIterator(getIterator(n,`sync`,a))}}else S=n[Symbol.iterator];if(S===void 0)throw TypeError(`Object is not iterable`);let C=S.call(n);if(typeof C!=`object`||!C)throw TypeError(`The iterator method must return an object`);return{iterator:C,nextMethod:C.next,done:!1}}function iteratorNext(n,a){let S;if(S=a===void 0?n.nextMethod.call(n.iterator):n.nextMethod.call(n.iterator,a),typeof S!=`object`||!S)throw TypeError(`The iterator.next() method must return an object`);return S}const Yn=typeof globalThis.AbortController==`function`?globalThis.AbortController:class AbortControllerShim{signal={aborted:!1,reason:void 0,addEventListener(){},removeEventListener(){}};abort(n){this.signal.aborted=!0,this.signal.reason=n}},Xn=Symbol(`kAbort`),Zn=Symbol(`kCloseSentinel`),Qn=Symbol(`kError`),$n=Symbol(`kSkipThrow`);var WritableStream=class{[qn]=`WritableStream`;[Kn];constructor(n={},a={}){if(n!=null&&typeof n!=`object`)throw TypeError(`sink must be an object`);if(a!=null&&typeof a!=`object`)throw TypeError(`strategy must be an object`);let S=n?.type;if(S!==void 0)throw RangeError(`Invalid type: ${S}`);this[Kn]=createWritableStreamState();let C=extractSizeAlgorithm(a?.size),N=extractHighWaterMark(a?.highWaterMark,1);setupWritableStreamDefaultControllerFromSink(this,n,N,C)}get locked(){if(!er(this))throw TypeError(`Invalid this`);return isWritableStreamLocked(this)}abort(n){return er(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamAbort(this,n):Promise.reject(TypeError(`Invalid this`))}close(){return er(this)?isWritableStreamLocked(this)?Promise.reject(TypeError(`WritableStream is locked`)):writableStreamCloseQueuedOrInFlight(this)?Promise.reject(TypeError(`Failure closing WritableStream`)):writableStreamClose(this):Promise.reject(TypeError(`Invalid this`))}getWriter(){if(!er(this))throw TypeError(`Invalid this`);return new WritableStreamDefaultWriter(this)}get[Symbol.toStringTag](){return`WritableStream`}},WritableStreamDefaultWriter=class{[qn]=`WritableStreamDefaultWriter`;[Kn];constructor(n){if(!er(n))throw TypeError(`Expected a WritableStream`);this[Kn]={stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0},ready:{promise:void 0,resolve:void 0,reject:void 0}},setupWritableStreamDefaultWriter(this,n)}get closed(){return tr(this)?this[Kn].close.promise:Promise.reject(TypeError(`Invalid this`))}get desiredSize(){if(!tr(this))throw TypeError(`Invalid this`);if(this[Kn].stream===void 0)throw TypeError(`Writer is not bound to a WritableStream`);return writableStreamDefaultWriterGetDesiredSize(this)}get ready(){return tr(this)?this[Kn].ready.promise:Promise.reject(TypeError(`Invalid this`))}abort(n){return tr(this)?this[Kn].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterAbort(this,n):Promise.reject(TypeError(`Invalid this`))}close(){if(!tr(this))return Promise.reject(TypeError(`Invalid this`));let{stream:n}=this[Kn];return n===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamCloseQueuedOrInFlight(n)?Promise.reject(TypeError(`Failure to close WritableStream`)):writableStreamDefaultWriterClose(this)}releaseLock(){if(!tr(this))throw TypeError(`Invalid this`);let{stream:n}=this[Kn];n!==void 0&&writableStreamDefaultWriterRelease(this)}write(n){return tr(this)?this[Kn].stream===void 0?Promise.reject(TypeError(`Writer is not bound to a WritableStream`)):writableStreamDefaultWriterWrite(this,n):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`WritableStreamDefaultWriter`}},WritableStreamDefaultController=class{[qn]=`WritableStreamDefaultController`;[Kn];constructor(n){if(n!==$n)throw TypeError(`Illegal constructor`)}[Xn](n){let a=this[Kn].abortAlgorithm(n);return writableStreamDefaultControllerClearAlgorithms(this),a}[Qn](){resetQueue(this)}get signal(){if(!nr(this))throw TypeError(`Invalid this`);return this[Kn].abortController.signal}error(n){if(!nr(this))throw TypeError(`Invalid this`);this[Kn].stream[Kn].state===`writable`&&writableStreamDefaultControllerError(this,n)}get[Symbol.toStringTag](){return`WritableStreamDefaultController`}};const er=isBrandCheck(`WritableStream`),tr=isBrandCheck(`WritableStreamDefaultWriter`),nr=isBrandCheck(`WritableStreamDefaultController`);function createEmptyPromiseRecord(){return{promise:void 0,resolve:void 0,reject:void 0}}function createWritableStreamState(){return{close:Promise.withResolvers(),closeRequest:createEmptyPromiseRecord(),inFlightWriteRequest:createEmptyPromiseRecord(),inFlightCloseRequest:createEmptyPromiseRecord(),pendingAbortRequest:{abort:createEmptyPromiseRecord(),reason:void 0,wasAlreadyErroring:!1},backpressure:!1,controller:void 0,state:`writable`,storedError:void 0,writeRequests:[],writer:void 0}}function isWritableStreamLocked(n){return n[Kn].writer!==void 0}function setupWritableStreamDefaultWriter(n,a){if(isWritableStreamLocked(a))throw TypeError(`WritableStream is locked`);switch(n[Kn].stream=a,a[Kn].writer=n,a[Kn].state){case`writable`:!writableStreamCloseQueuedOrInFlight(a)&&a[Kn].backpressure?n[Kn].ready=Promise.withResolvers():n[Kn].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},n[Kn].close=Promise.withResolvers();break;case`erroring`:n[Kn].ready={promise:Promise.reject(a[Kn].storedError),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].ready.promise),n[Kn].close=Promise.withResolvers();break;case`closed`:n[Kn].ready={promise:Promise.resolve(),resolve:void 0,reject:void 0},n[Kn].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;default:n[Kn].ready={promise:Promise.reject(a[Kn].storedError),resolve:void 0,reject:void 0},n[Kn].close={promise:Promise.reject(a[Kn].storedError),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].ready.promise),setPromiseHandled(n[Kn].close.promise)}}function writableStreamAbort(n,a){let{state:S,controller:C}=n[Kn];if(S===`closed`||S===`errored`)return Promise.resolve();if(C[Kn].abortController.abort(a),n[Kn].pendingAbortRequest.abort.promise!==void 0)return n[Kn].pendingAbortRequest.abort.promise;let N=!1;S===`erroring`&&(N=!0,a=void 0);let F=Promise.withResolvers();return n[Kn].pendingAbortRequest={abort:F,reason:a,wasAlreadyErroring:N},N||writableStreamStartErroring(n,a),F.promise}function writableStreamClose(n){let{state:a,writer:S,backpressure:C,controller:N}=n[Kn];if(a===`closed`||a===`errored`)return Promise.reject(TypeError(`WritableStream is closed`));n[Kn].closeRequest=Promise.withResolvers();let{promise:F}=n[Kn].closeRequest;return S!==void 0&&C&&a===`writable`&&S[Kn].ready.resolve?.(),writableStreamDefaultControllerClose(N),F}function writableStreamUpdateBackpressure(n,a){let{writer:S}=n[Kn];S!==void 0&&n[Kn].backpressure!==a&&(a?S[Kn].ready=Promise.withResolvers():S[Kn].ready.resolve?.()),n[Kn].backpressure=a}function writableStreamStartErroring(n,a){let{controller:S,writer:C}=n[Kn];n[Kn].state=`erroring`,n[Kn].storedError=a,C!==void 0&&writableStreamDefaultWriterEnsureReadyPromiseRejected(C,a),!writableStreamHasOperationMarkedInFlight(n)&&S[Kn].started&&writableStreamFinishErroring(n)}function writableStreamRejectCloseAndClosedPromiseIfNeeded(n){n[Kn].closeRequest.promise!==void 0&&(n[Kn].closeRequest.reject?.(n[Kn].storedError),n[Kn].closeRequest={promise:void 0,resolve:void 0,reject:void 0}),setPromiseHandled(n[Kn].close.promise),n[Kn].close.reject?.(n[Kn].storedError);let{writer:a}=n[Kn];a!==void 0&&(setPromiseHandled(a[Kn].close.promise),a[Kn].close.reject?.(n[Kn].storedError))}function writableStreamMarkFirstWriteRequestInFlight(n){let a=n[Kn].writeRequests.shift();n[Kn].inFlightWriteRequest=a}function writableStreamMarkCloseRequestInFlight(n){n[Kn].inFlightCloseRequest=n[Kn].closeRequest,n[Kn].closeRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamHasOperationMarkedInFlight(n){return n[Kn].inFlightWriteRequest.promise!==void 0||n[Kn].inFlightCloseRequest.promise!==void 0}function writableStreamFinishInFlightWriteWithError(n,a){n[Kn].inFlightWriteRequest.reject?.(a),n[Kn].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0},writableStreamDealWithRejection(n,a)}function writableStreamFinishInFlightWrite(n){n[Kn].inFlightWriteRequest.resolve?.(),n[Kn].inFlightWriteRequest={promise:void 0,resolve:void 0,reject:void 0}}function writableStreamFinishInFlightCloseWithError(n,a){n[Kn].inFlightCloseRequest.reject?.(a),n[Kn].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},n[Kn].pendingAbortRequest.abort.promise!==void 0&&(n[Kn].pendingAbortRequest.abort.reject?.(a),n[Kn].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1}),writableStreamDealWithRejection(n,a)}function writableStreamFinishInFlightClose(n){n[Kn].inFlightCloseRequest.resolve?.(),n[Kn].inFlightCloseRequest={promise:void 0,resolve:void 0,reject:void 0},n[Kn].state===`erroring`&&(n[Kn].storedError=void 0,n[Kn].pendingAbortRequest.abort.promise!==void 0&&(n[Kn].pendingAbortRequest.abort.resolve?.(),n[Kn].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1})),n[Kn].state=`closed`,n[Kn].writer!==void 0&&n[Kn].writer[Kn].close.resolve?.(),n[Kn].close.resolve?.()}function writableStreamFinishErroring(n){n[Kn].state=`errored`,n[Kn].controller[Qn]();let a=n[Kn].storedError;for(let S of n[Kn].writeRequests)S.reject?.(a);if(n[Kn].writeRequests=[],n[Kn].pendingAbortRequest.abort.promise===void 0){writableStreamRejectCloseAndClosedPromiseIfNeeded(n);return}let S=n[Kn].pendingAbortRequest;if(n[Kn].pendingAbortRequest={abort:{promise:void 0,resolve:void 0,reject:void 0},reason:void 0,wasAlreadyErroring:!1},S.wasAlreadyErroring){S.abort.reject?.(a),writableStreamRejectCloseAndClosedPromiseIfNeeded(n);return}n[Kn].controller[Xn](S.reason).then(()=>{S.abort.resolve?.(),writableStreamRejectCloseAndClosedPromiseIfNeeded(n)},a=>{S.abort.reject?.(a),writableStreamRejectCloseAndClosedPromiseIfNeeded(n)})}function writableStreamDealWithRejection(n,a){if(n[Kn].state===`writable`){writableStreamStartErroring(n,a);return}writableStreamFinishErroring(n)}function writableStreamCloseQueuedOrInFlight(n){return n[Kn].closeRequest.promise!==void 0||n[Kn].inFlightCloseRequest.promise!==void 0}function writableStreamAddWriteRequest(n){let{promise:a,resolve:S,reject:C}=Promise.withResolvers();return n[Kn].writeRequests.push({promise:a,resolve:S,reject:C}),a}function writableStreamDefaultWriterWrite(n,a){let{stream:S}=n[Kn],{controller:C}=S[Kn],N=writableStreamDefaultControllerGetChunkSize(C,a);if(S!==n[Kn].stream)return Promise.reject(TypeError(`Mismatched WritableStreams`));let{state:F}=S[Kn];if(F===`errored`)return Promise.reject(S[Kn].storedError);if(writableStreamCloseQueuedOrInFlight(S)||F===`closed`)return Promise.reject(TypeError(`WritableStream is closed`));if(F===`erroring`)return Promise.reject(S[Kn].storedError);let I=writableStreamAddWriteRequest(S);return writableStreamDefaultControllerWrite(C,a,N),I}function writableStreamDefaultWriterRelease(n){let{stream:a}=n[Kn],S=TypeError(`Writer has been released`);writableStreamDefaultWriterEnsureReadyPromiseRejected(n,S),writableStreamDefaultWriterEnsureClosedPromiseRejected(n,S),a[Kn].writer=void 0,n[Kn].stream=void 0}function writableStreamDefaultWriterGetDesiredSize(n){let{stream:a}=n[Kn];switch(a[Kn].state){case`errored`:case`erroring`:return null;case`closed`:return 0}return writableStreamDefaultControllerGetDesiredSize(a[Kn].controller)}function writableStreamDefaultWriterEnsureReadyPromiseRejected(n,a){n[Kn].ready.reject?(n[Kn].ready.reject(a),n[Kn].ready.resolve=void 0,n[Kn].ready.reject=void 0):n[Kn].ready={promise:Promise.reject(a),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].ready.promise)}function writableStreamDefaultWriterEnsureClosedPromiseRejected(n,a){n[Kn].close.reject?(n[Kn].close.reject(a),n[Kn].close.resolve=void 0,n[Kn].close.reject=void 0):n[Kn].close={promise:Promise.reject(a),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].close.promise)}function writableStreamDefaultWriterCloseWithErrorPropagation(n){let{stream:a}=n[Kn],{state:S}=a[Kn];return writableStreamCloseQueuedOrInFlight(a)||S===`closed`?Promise.resolve():S===`errored`?Promise.reject(a[Kn].storedError):writableStreamDefaultWriterClose(n)}function writableStreamDefaultWriterClose(n){return writableStreamClose(n[Kn].stream)}function writableStreamDefaultWriterAbort(n,a){return writableStreamAbort(n[Kn].stream,a)}function writableStreamDefaultControllerWrite(n,a,S){try{enqueueValueWithSize(n,a,S)}catch(a){writableStreamDefaultControllerErrorIfNeeded(n,a);return}let{stream:C}=n[Kn];!writableStreamCloseQueuedOrInFlight(C)&&C[Kn].state===`writable`&&writableStreamUpdateBackpressure(C,writableStreamDefaultControllerGetBackpressure(n)),writableStreamDefaultControllerAdvanceQueueIfNeeded(n)}function writableStreamDefaultControllerProcessWrite(n,a){let{stream:S,writeAlgorithm:C}=n[Kn];writableStreamMarkFirstWriteRequestInFlight(S),C(a,n).then(()=>{writableStreamFinishInFlightWrite(S);let{state:a}=S[Kn];dequeueValue(n),!writableStreamCloseQueuedOrInFlight(S)&&a===`writable`&&writableStreamUpdateBackpressure(S,writableStreamDefaultControllerGetBackpressure(n)),writableStreamDefaultControllerAdvanceQueueIfNeeded(n)},a=>{S[Kn].state===`writable`&&writableStreamDefaultControllerClearAlgorithms(n),writableStreamFinishInFlightWriteWithError(S,a)})}function writableStreamDefaultControllerProcessClose(n){let{closeAlgorithm:a,stream:S}=n[Kn];writableStreamMarkCloseRequestInFlight(S),dequeueValue(n);let C=a();writableStreamDefaultControllerClearAlgorithms(n),C.then(()=>writableStreamFinishInFlightClose(S),n=>writableStreamFinishInFlightCloseWithError(S,n))}function writableStreamDefaultControllerGetDesiredSize(n){return n[Kn].highWaterMark-n[Kn].queueTotalSize}function writableStreamDefaultControllerGetChunkSize(n,a){let{sizeAlgorithm:S}=n[Kn];if(S===void 0)return 1;try{return S(a)}catch(a){return writableStreamDefaultControllerErrorIfNeeded(n,a),1}}function writableStreamDefaultControllerErrorIfNeeded(n,a){n[Kn].stream[Kn].state===`writable`&&writableStreamDefaultControllerError(n,a)}function writableStreamDefaultControllerError(n,a){writableStreamDefaultControllerClearAlgorithms(n),writableStreamStartErroring(n[Kn].stream,a)}function writableStreamDefaultControllerClose(n){enqueueValueWithSize(n,Zn,0),writableStreamDefaultControllerAdvanceQueueIfNeeded(n)}function writableStreamDefaultControllerClearAlgorithms(n){n[Kn].writeAlgorithm=void 0,n[Kn].closeAlgorithm=void 0,n[Kn].abortAlgorithm=void 0,n[Kn].sizeAlgorithm=void 0}function writableStreamDefaultControllerGetBackpressure(n){return writableStreamDefaultControllerGetDesiredSize(n)<=0}function writableStreamDefaultControllerAdvanceQueueIfNeeded(n){let{queue:a,started:S,stream:C}=n[Kn];if(!S||C[Kn].inFlightWriteRequest.promise!==void 0)return;if(C[Kn].state===`erroring`){writableStreamFinishErroring(C);return}if(!a.length)return;let N=peekQueueValue(n);N===Zn?writableStreamDefaultControllerProcessClose(n):writableStreamDefaultControllerProcessWrite(n,N)}function setupWritableStreamDefaultControllerFromSink(n,a,S,C){let N=new WritableStreamDefaultController($n),F=a?.start,I=a?.write,H=a?.close,W=a?.abort;setupWritableStreamDefaultController(n,N,F?F.bind(a,N):nonOpStart,I?createPromiseCallback(`sink.write`,I,a):nonOpWrite,H?createPromiseCallback(`sink.close`,H,a):nonOpCancel,W?createPromiseCallback(`sink.abort`,W,a):nonOpCancel,S,C)}function setupWritableStreamDefaultController(n,a,S,C,N,F,I,H){a[Kn]={abortAlgorithm:F,closeAlgorithm:N,highWaterMark:I,queue:[],queueTotalSize:0,abortController:new Yn,sizeAlgorithm:H,started:!1,stream:n,writeAlgorithm:C},n[Kn].controller=a,writableStreamUpdateBackpressure(n,writableStreamDefaultControllerGetBackpressure(a));let W=S();new Promise(n=>n(W)).then(()=>{a[Kn].started=!0,writableStreamDefaultControllerAdvanceQueueIfNeeded(a)},S=>{a[Kn].started=!0,writableStreamDealWithRejection(n,S)})}function createWritableStream(n,a,S,C,N=1,F=()=>1){let I=Object.create(WritableStream.prototype);return I[qn]=`WritableStream`,I[Kn]=createWritableStreamState(),setupWritableStreamDefaultController(I,new WritableStreamDefaultController($n),n,a,S,C,N,F),I}Xe();const rr=Symbol(`kCancel`),ir=Symbol(`kClose`),ar=Symbol(`kChunk`),sr=Symbol(`kError`),cr=Symbol(`kPull`),lr=Symbol(`kRelease`),ur=Symbol(`kSkipThrow`);let dr,fr;function lazyReadableReleasedError(){return dr||(dr=TypeError(`Reader released`),dr)}function lazyReadableReleasingError(){return fr||(fr=TypeError(`Releasing reader`),fr)}function createAbortError$1(){if(typeof globalThis.DOMException==`function`)return new DOMException(`The operation was aborted`,`AbortError`);let n=Error(`The operation was aborted`);return n.name=`AbortError`,n}__name$1(createAbortError$1,`createAbortError`);function createReadableStreamState(){return{disturbed:!1,reader:void 0,state:`readable`,storedError:void 0,controller:void 0,closedPromise:Promise.withResolvers()}}var ReadableStream$1=class{static{__name$1(this,`ReadableStream`)}[qn]=`ReadableStream`;[Kn];constructor(n={},a={}){if(n!=null&&typeof n!=`object`)throw TypeError(`source must be an object`);if(a!=null&&typeof a!=`object`)throw TypeError(`strategy must be an object`);this[Kn]=createReadableStreamState();let S=a?.size,C=a?.highWaterMark,N=n?.type;if(N!==void 0){if(`${N}`==`bytes`){if(S!==void 0)throw RangeError(`strategy.size must not be set for a byte stream`);setupReadableByteStreamControllerFromSource(this,n,extractHighWaterMark(C,0));return}throw RangeError(`Invalid type: ${N}`)}setupReadableStreamDefaultControllerFromSource(this,n,extractHighWaterMark(C,1),extractSizeAlgorithm(S))}get locked(){if(!pr(this))throw TypeError(`Invalid this`);return isReadableStreamLocked(this)}static from(n){return readableStreamFromIterable(n)}cancel(n=void 0){return pr(this)?isReadableStreamLocked(this)?Promise.reject(TypeError(`ReadableStream is locked`)):readableStreamCancel(this,n):Promise.reject(TypeError(`Invalid this`))}getReader(n={}){if(!pr(this))throw TypeError(`Invalid this`);if(n!=null&&typeof n!=`object`)throw TypeError(`options must be an object`);let a=n?.mode;if(a===void 0)return new ReadableStreamDefaultReader(this);if(`${a}`==`byob`)return new ReadableStreamBYOBReader(this);throw RangeError(`Invalid mode: ${a}`)}pipeThrough(n,a={}){if(!pr(this))throw TypeError(`Invalid this`);let S=n?.readable;if(!pr(S))throw TypeError(`transform.readable must be a ReadableStream`);let C=n?.writable;if(!er(C))throw TypeError(`transform.writable must be a WritableStream`);if(a!=null&&typeof a!=`object`)throw TypeError(`options must be an object`);let N=a?.preventAbort,F=a?.preventCancel,I=a?.preventClose,H=a?.signal;if(H!==void 0&&!(H instanceof Object&&`aborted`in H))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(C))throw TypeError(`The WritableStream is locked`);return setPromiseHandled(readableStreamPipeTo(this,C,!!I,!!N,!!F,H)),S}pipeTo(n,a={}){try{if(!pr(this))throw TypeError(`Invalid this`);if(!er(n))throw TypeError(`destination must be a WritableStream`);if(a!=null&&typeof a!=`object`)throw TypeError(`options must be an object`);let S=a?.preventAbort,C=a?.preventCancel,N=a?.preventClose,F=a?.signal;if(F!==void 0&&!(F instanceof Object&&`aborted`in F))throw TypeError(`options.signal must be an AbortSignal`);if(isReadableStreamLocked(this))throw TypeError(`The ReadableStream is locked`);if(isWritableStreamLocked(n))throw TypeError(`The WritableStream is locked`);return readableStreamPipeTo(this,n,!!N,!!S,!!C,F)}catch(n){return Promise.reject(n)}}tee(){if(!pr(this))throw TypeError(`Invalid this`);let n=this[Kn].controller;return gr(n)?readableByteStreamTee(this):readableStreamDefaultTee(this,!1)}values(n={}){if(!pr(this))throw TypeError(`Invalid this`);if(n!=null&&typeof n!=`object`)throw TypeError(`options must be an object`);let a=!!n?.preventCancel,S=new ReadableStreamDefaultReader(this),C={done:!1,current:void 0},N=!1;function nextSteps(){if(C.done)return Promise.resolve({done:!0,value:void 0});if(S[Kn].stream===void 0)return Promise.reject(TypeError(`The reader is not bound to a ReadableStream`));let{promise:n,resolve:a,reject:N}=Promise.withResolvers();return readableStreamDefaultReaderRead(S,{[ar](n){C.current=void 0,a({value:n,done:!1})},[ir](){C.current=void 0,C.done=!0,readableStreamReaderGenericRelease(S),a({done:!0,value:void 0})},[sr](n){C.current=void 0,C.done=!0,readableStreamReaderGenericRelease(S),N(n)}}),n}async function returnSteps(n){if(C.done)return{done:!0,value:n};if(C.done=!0,S[Kn].stream===void 0)throw TypeError(`The reader is not bound to a ReadableStream`);if(!a){let a=readableStreamReaderGenericCancel(S,n);return readableStreamReaderGenericRelease(S),await a,{done:!0,value:n}}return readableStreamReaderGenericRelease(S),{done:!0,value:n}}return Object.setPrototypeOf({next(){return N||=(C.current=Promise.resolve(),!0),C.current=C.current===void 0?nextSteps():C.current.then(nextSteps,nextSteps),C.current},return(n){return N=!0,C.current=C.current===void 0?returnSteps(n):C.current.then(()=>returnSteps(n),()=>returnSteps(n)),C.current},[Symbol.asyncIterator](){return this}},Jn)}[Symbol.asyncIterator](){return this.values()}get[Symbol.toStringTag](){return`ReadableStream`}},DefaultReadRequest=class{[Kn];constructor(){this[Kn]=Promise.withResolvers()}[ar](n){this[Kn].resolve?.({value:n,done:!1})}[ir](){this[Kn].resolve?.({value:void 0,done:!0})}[sr](n){this[Kn].reject?.(n)}get promise(){return this[Kn].promise}},ReadableStreamDefaultReader=class{[qn]=`ReadableStreamDefaultReader`;[Kn];constructor(n){if(!pr(n))throw TypeError(`Expected a ReadableStream`);this[Kn]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamDefaultReader(this,n)}read(){if(!hr(this))return Promise.reject(TypeError(`Invalid this`));if(this[Kn].stream===void 0)return Promise.reject(TypeError(`The reader is not attached to a stream`));let n=this[Kn].stream,a=n[Kn].controller;if(n[Kn].state===`readable`&&mr(a)&&a[Kn].queue.length>0){n[Kn].disturbed=!0;let S=dequeueValue(a);return a[Kn].closeRequested&&!a[Kn].queue.length?(readableStreamDefaultControllerClearAlgorithms(a),readableStreamClose(n)):readableStreamDefaultControllerCallPullIfNeeded(a),Promise.resolve({value:S,done:!1})}let S=new DefaultReadRequest;return readableStreamDefaultReaderRead(this,S),S.promise}releaseLock(){if(!hr(this))throw TypeError(`Invalid this`);this[Kn].stream!==void 0&&readableStreamDefaultReaderRelease(this)}get closed(){return hr(this)?this[Kn].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(n=void 0){return hr(this)?this[Kn].stream===void 0?Promise.reject(TypeError(`The reader is not attached to a stream`)):readableStreamReaderGenericCancel(this,n):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamDefaultReader`}},ReadableStreamDefaultController=class{[qn]=`ReadableStreamDefaultController`;[Kn];constructor(n){if(n!==ur)throw TypeError(`Illegal constructor`)}get desiredSize(){return readableStreamDefaultControllerGetDesiredSize(this)}close(){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerClose(this)}enqueue(n=void 0){if(!readableStreamDefaultControllerCanCloseOrEnqueue(this))throw TypeError(`Controller is already closed`);readableStreamDefaultControllerEnqueue(this,n)}error(n=void 0){readableStreamDefaultControllerError(this,n)}[rr](n){return readableStreamDefaultControllerCancelSteps(this,n)}[cr](n){readableStreamDefaultControllerPullSteps(this,n)}[lr](){}get[Symbol.toStringTag](){return`ReadableStreamDefaultController`}};const pr=isBrandCheck(`ReadableStream`),mr=isBrandCheck(`ReadableStreamDefaultController`),hr=isBrandCheck(`ReadableStreamDefaultReader`);function isReadableStreamLocked(n){return n[Kn].reader!==void 0}function readableStreamCancel(n,a){switch(n[Kn].disturbed=!0,n[Kn].state){case`closed`:return Promise.resolve();case`errored`:return Promise.reject(n[Kn].storedError)}readableStreamClose(n);let S=n[Kn].reader;if(S!==void 0&&readableStreamHasBYOBReader(n)){let n=S[Kn].readIntoRequests;S[Kn].readIntoRequests=[];for(let a=0;a<n.length;a++)n[a][ir](void 0)}return n[Kn].controller[rr](a).then(()=>{})}function readableStreamClose(n){n[Kn].state=`closed`,n[Kn].closedPromise.resolve();let{reader:a}=n[Kn];if(a!==void 0&&(a[Kn].close.resolve?.(),readableStreamHasDefaultReader(n))){for(let n=0;n<a[Kn].readRequests.length;n++)a[Kn].readRequests[n][ir]();a[Kn].readRequests=[]}}function readableStreamError(n,a){n[Kn].state=`errored`,n[Kn].storedError=a,setPromiseHandled(n[Kn].closedPromise.promise),n[Kn].closedPromise.reject(a);let{reader:S}=n[Kn];if(S!==void 0){if(setPromiseHandled(S[Kn].close.promise),S[Kn].close.reject?.(a),readableStreamHasDefaultReader(n)){for(let n=0;n<S[Kn].readRequests.length;n++)S[Kn].readRequests[n][sr](a);S[Kn].readRequests=[]}else if(readableStreamHasBYOBReader(n)){for(let n=0;n<S[Kn].readIntoRequests.length;n++)S[Kn].readIntoRequests[n][sr](a);S[Kn].readIntoRequests=[]}}}function readableStreamHasDefaultReader(n){let{reader:a}=n[Kn];return a===void 0?!1:a[Kn]!==void 0&&a[qn]===`ReadableStreamDefaultReader`}function readableStreamGetNumReadRequests(n){return n[Kn].reader[Kn].readRequests.length}function readableStreamFulfillReadRequest(n,a,S){let{reader:C}=n[Kn],N=C[Kn].readRequests.shift();S?N[ir]():N[ar](a)}function readableStreamAddReadRequest(n,a){n[Kn].reader[Kn].readRequests.push(a)}function readableStreamReaderGenericCancel(n,a){let{stream:S}=n[Kn];return readableStreamCancel(S,a)}function readableStreamReaderGenericInitialize(n,a){switch(n[Kn].stream=a,a[Kn].reader=n,a[Kn].state){case`readable`:n[Kn].close=Promise.withResolvers();break;case`closed`:n[Kn].close={promise:Promise.resolve(),resolve:void 0,reject:void 0};break;case`errored`:n[Kn].close={promise:Promise.reject(a[Kn].storedError),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].close.promise);break}}function readableStreamReaderGenericRelease(n){let{stream:a}=n[Kn],S=lazyReadableReleasedError();a[Kn].state===`readable`?n[Kn].close.reject?.(S):n[Kn].close={promise:Promise.reject(S),resolve:void 0,reject:void 0},setPromiseHandled(n[Kn].close.promise),a[Kn].controller[lr](),a[Kn].reader=void 0,n[Kn].stream=void 0}function readableStreamDefaultReaderRelease(n){readableStreamReaderGenericRelease(n),readableStreamDefaultReaderErrorReadRequests(n,lazyReadableReleasingError())}function readableStreamDefaultReaderErrorReadRequests(n,a){for(let S=0;S<n[Kn].readRequests.length;++S)n[Kn].readRequests[S][sr](a);n[Kn].readRequests=[]}function readableStreamDefaultReaderRead(n,a){let{stream:S}=n[Kn];switch(S[Kn].disturbed=!0,S[Kn].state){case`closed`:a[ir]();break;case`errored`:a[sr](S[Kn].storedError);break;case`readable`:S[Kn].controller[cr](a);break}}function setupReadableStreamDefaultReader(n,a){if(isReadableStreamLocked(a))throw TypeError(`ReadableStream is locked`);readableStreamReaderGenericInitialize(n,a),n[Kn].readRequests=[]}function readableStreamDefaultControllerClose(n){readableStreamDefaultControllerCanCloseOrEnqueue(n)&&(n[Kn].closeRequested=!0,n[Kn].queue.length||(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(n[Kn].stream)))}function readableStreamDefaultControllerEnqueue(n,a){if(!readableStreamDefaultControllerCanCloseOrEnqueue(n))return;let{stream:S}=n[Kn];if(isReadableStreamLocked(S)&&readableStreamGetNumReadRequests(S))readableStreamFulfillReadRequest(S,a,!1);else try{enqueueValueWithSize(n,a,n[Kn].sizeAlgorithm(a))}catch(a){throw readableStreamDefaultControllerError(n,a),a}readableStreamDefaultControllerCallPullIfNeeded(n)}function readableStreamDefaultControllerCanCloseOrEnqueue(n){let{stream:a}=n[Kn];return!n[Kn].closeRequested&&a[Kn].state===`readable`}function readableStreamDefaultControllerGetDesiredSize(n){let{stream:a,highWaterMark:S,queueTotalSize:C}=n[Kn];switch(a[Kn].state){case`errored`:return null;case`closed`:return 0;default:return S-C}}function readableStreamDefaultControllerHasBackpressure(n){return!readableStreamDefaultControllerShouldCallPull(n)}function readableStreamDefaultControllerShouldCallPull(n){let{stream:a}=n[Kn];if(!readableStreamDefaultControllerCanCloseOrEnqueue(n)||!n[Kn].started)return!1;if(isReadableStreamLocked(a)&&readableStreamGetNumReadRequests(a))return!0;let S=readableStreamDefaultControllerGetDesiredSize(n);return S!==null&&S>0}function readableStreamDefaultControllerCallPullIfNeeded(n){if(readableStreamDefaultControllerShouldCallPull(n)){if(n[Kn].pulling){n[Kn].pullAgain=!0;return}n[Kn].pulling=!0,n[Kn].pullAlgorithm(n).then(()=>{n[Kn].pulling=!1,n[Kn].pullAgain&&(n[Kn].pullAgain=!1,readableStreamDefaultControllerCallPullIfNeeded(n))},a=>readableStreamDefaultControllerError(n,a))}}function readableStreamDefaultControllerClearAlgorithms(n){n[Kn].pullAlgorithm=void 0,n[Kn].cancelAlgorithm=void 0,n[Kn].sizeAlgorithm=void 0}function readableStreamDefaultControllerError(n,a){let{stream:S}=n[Kn];S[Kn].state===`readable`&&(resetQueue(n),readableStreamDefaultControllerClearAlgorithms(n),readableStreamError(S,a))}function readableStreamDefaultControllerCancelSteps(n,a){resetQueue(n);let S=n[Kn].cancelAlgorithm?.(a)??Promise.resolve();return readableStreamDefaultControllerClearAlgorithms(n),S}function readableStreamDefaultControllerPullSteps(n,a){let{stream:S,queue:C}=n[Kn];if(C.length){let N=dequeueValue(n);n[Kn].closeRequested&&!C.length?(readableStreamDefaultControllerClearAlgorithms(n),readableStreamClose(S)):readableStreamDefaultControllerCallPullIfNeeded(n),a[ar](N);return}readableStreamAddReadRequest(S,a),readableStreamDefaultControllerCallPullIfNeeded(n)}function setupReadableStreamDefaultController(n,a,S,C,N,F,I){a[Kn]={cancelAlgorithm:N,closeRequested:!1,highWaterMark:F,pullAgain:!1,pullAlgorithm:C,pulling:!1,queue:[],queueTotalSize:0,started:!1,sizeAlgorithm:I,stream:n},n[Kn].controller=a;let H=S();new Promise(n=>n(H)).then(()=>{a[Kn].started=!0,readableStreamDefaultControllerCallPullIfNeeded(a)},n=>readableStreamDefaultControllerError(a,n))}function setupReadableStreamDefaultControllerFromSource(n,a,S,C){let N=new ReadableStreamDefaultController(ur),F=a?.start,I=a?.pull,H=a?.cancel;setupReadableStreamDefaultController(n,N,F?F.bind(a,N):nonOpStart,I?createPromiseCallback(`source.pull`,I,a):nonOpPull,H?createPromiseCallback(`source.cancel`,H,a):nonOpCancel,S,C)}function createReadableStream(n,a,S,C=1,N=()=>1){let F=Object.create(ReadableStream$1.prototype);return F[qn]=`ReadableStream`,F[Kn]=createReadableStreamState(),setupReadableStreamDefaultController(F,new ReadableStreamDefaultController(ur),n,a,S,C,N),F}function readableStreamFromIterable(n){let a,S=getIterator(n,`async`),C=nonOpStart;async function pullAlgorithm(){let n=iteratorNext(S);return Promise.resolve(n).then(n=>{if(typeof n!=`object`||!n)throw TypeError(`The promise returned by the iterator.next() method must fulfill with an object`);n.done?readableStreamDefaultControllerClose(a[Kn].controller):readableStreamDefaultControllerEnqueue(a[Kn].controller,n.value)})}async function cancelAlgorithm(n){let a=S.iterator,C=a.return;if(C===void 0)return Promise.resolve();let N=C.call(a,n);return Promise.resolve(N).then(n=>{if(typeof n!=`object`||!n)throw TypeError(`The promise returned by the iterator.return() method must fulfill with an object`)})}return a=createReadableStream(C,pullAlgorithm,cancelAlgorithm,0),a}function readableStreamPipeTo(n,a,S,C,N,F){let I,H;try{I=new ReadableStreamDefaultReader(n),H=new WritableStreamDefaultWriter(a)}catch(n){return Promise.reject(n)}n[Kn].disturbed=!0;let W=!1,{promise:K,resolve:q,reject:Y}=Promise.withResolvers(),X={currentWrite:Promise.resolve()},te;function finalize(n,a){writableStreamDefaultWriterRelease(H),readableStreamReaderGenericRelease(I),F!==void 0&&te&&(F.removeEventListener(`abort`,te),te=void 0),n?Y(a):q()}async function waitForCurrentWrite(){let n=X.currentWrite;await n,n!==X.currentWrite&&await waitForCurrentWrite()}function shutdownWithAnAction(n,S,C){if(W)return;if(W=!0,a[Kn].state===`writable`&&!writableStreamCloseQueuedOrInFlight(a)){waitForCurrentWrite().then(complete,n=>finalize(!0,n));return}complete();function complete(){n().then(()=>finalize(!!S,C),n=>finalize(!0,n))}}function shutdown(n,S){if(!W){if(W=!0,a[Kn].state===`writable`&&!writableStreamCloseQueuedOrInFlight(a)){waitForCurrentWrite().then(()=>finalize(!!n,S),n=>finalize(!0,n));return}finalize(!!n,S)}}function abortAlgorithm(){let S;S=F.reason&&F.reason.name===`AbortError`?createAbortError$1():F.reason;let I=[];C||I.push(()=>a[Kn].state===`writable`?writableStreamAbort(a,S):Promise.resolve()),N||I.push(()=>n[Kn].state===`readable`?readableStreamCancel(n,S):Promise.resolve()),shutdownWithAnAction(()=>Promise.all(I.map(n=>n())).then(()=>void 0),!0,S)}function watchErrored(n,a,S){n[Kn].state===`errored`?S(n[Kn].storedError):a.then(void 0,S)}function watchClosed(n,a,S){n[Kn].state===`closed`?S():a.then(S,()=>{})}class PipeToReadRequest{[ar](n){Me(()=>{X.currentWrite=writableStreamDefaultWriterWrite(H,n),setPromiseHandled(X.currentWrite),ne.resolve(!1)})}[ir](){ne.resolve(!0)}[sr](n){ne.reject(n)}}let ne={resolve:null,reject:null};async function step(){if(W||a[Kn].backpressure&&(await H[Kn].ready.promise,W))return!0;let S=n[Kn].controller;if(n[Kn].state===`readable`&&mr(S)&&S[Kn].queue.length>0){for(;S[Kn].queue.length>0;){if(W)return!0;let C=dequeueValue(S);if(S[Kn].closeRequested&&!S[Kn].queue.length&&(readableStreamDefaultControllerClearAlgorithms(S),readableStreamClose(n)),X.currentWrite=writableStreamDefaultWriterWrite(H,C),setPromiseHandled(X.currentWrite),a[Kn].backpressure||a[Kn].state!==`writable`||writableStreamCloseQueuedOrInFlight(a))break}return readableStreamDefaultControllerCallPullIfNeeded(S),n[Kn].state===`closed`}let{promise:C,resolve:N,reject:F}=Promise.withResolvers();return ne={resolve:N,reject:F},readableStreamDefaultReaderRead(I,new PipeToReadRequest),C}async function run(){for(;!await step(););}if(F!==void 0){if(F.aborted)return abortAlgorithm(),K;te=abortAlgorithm,F.addEventListener(`abort`,te,{once:!0})}if(setPromiseHandled(run()),watchErrored(n,I[Kn].close.promise,n=>{if(!C)return shutdownWithAnAction(()=>writableStreamAbort(a,n),!0,n);shutdown(!0,n)}),watchErrored(a,H[Kn].close.promise,a=>{if(!N)return shutdownWithAnAction(()=>readableStreamCancel(n,a),!0,a);shutdown(!0,a)}),watchClosed(n,I[Kn].close.promise,()=>{if(!S)return shutdownWithAnAction(()=>writableStreamDefaultWriterCloseWithErrorPropagation(H));shutdown()}),writableStreamCloseQueuedOrInFlight(a)||a[Kn].state===`closed`){let a=TypeError(`Destination WritableStream is closed`);N?shutdown(!0,a):shutdownWithAnAction(()=>readableStreamCancel(n,a),!0,a)}return K}function readableStreamDefaultTee(n,a){let S=new ReadableStreamDefaultReader(n),C=!1,N=!1,F=!1,I,H,W,K,q=Promise.withResolvers();async function pullAlgorithm(){C||(C=!0,readableStreamDefaultReaderRead(S,{[ar](n){Me(()=>{C=!1;let S=n,I=n;if(!F&&a)try{I=structuredClone(I)}catch{}N||readableStreamDefaultControllerEnqueue(W[Kn].controller,S),F||readableStreamDefaultControllerEnqueue(K[Kn].controller,I)})},[ir](){Me(()=>{C=!1,N||readableStreamDefaultControllerClose(W[Kn].controller),F||readableStreamDefaultControllerClose(K[Kn].controller),(!N||!F)&&q.resolve(void 0)})},[sr](){C=!1}}))}function cancel1Algorithm(a){if(N=!0,I=a,F){let a=[I,H];q.resolve(readableStreamCancel(n,a))}return q.promise}function cancel2Algorithm(a){if(F=!0,H=a,N){let a=[I,H];q.resolve(readableStreamCancel(n,a))}return q.promise}return W=createReadableStream(nonOpStart,pullAlgorithm,cancel1Algorithm),K=createReadableStream(nonOpStart,pullAlgorithm,cancel2Algorithm),S[Kn].close.promise.then(void 0,n=>{readableStreamDefaultControllerError(W[Kn].controller,n),readableStreamDefaultControllerError(K[Kn].controller,n),(!N||!F)&&q.resolve(void 0)}),[W,K]}var BYOBReadIntoRequest=class{[Kn];constructor(){this[Kn]=Promise.withResolvers()}[ar](n){this[Kn].resolve?.({value:n,done:!1})}[ir](n){this[Kn].resolve?.({value:n,done:!0})}[sr](n){this[Kn].reject?.(n)}get promise(){return this[Kn].promise}},ReadableStreamBYOBReader=class{[qn]=`ReadableStreamBYOBReader`;[Kn];constructor(n){if(!pr(n))throw TypeError(`Expected a ReadableStream`);this[Kn]={readRequests:[],readIntoRequests:[],stream:void 0,close:{promise:void 0,resolve:void 0,reject:void 0}},setupReadableStreamBYOBReader(this,n)}read(n,a={}){if(!_r(this))return Promise.reject(TypeError(`Invalid this`));if(typeof n!=`object`||!n||!ArrayBuffer.isView(n))return Promise.reject(TypeError(`view must be an ArrayBufferView`));let S=n.buffer,C=n.byteLength;if(C===0)return Promise.reject(TypeError(`view must have non-zero byteLength`));if(S.byteLength===0)return isDetachedBuffer(S)?Promise.reject(TypeError(`view's buffer has been detached`)):Promise.reject(TypeError(`view's buffer must have non-zero byteLength`));let N=a?.min??1;if(typeof N!=`number`||N<1||!Number.isInteger(N)||Number.isNaN(N))return Promise.reject(TypeError(`options.min must be a positive integer`));let F=n[Symbol.toStringTag];if(F!==void 0&&F!==`DataView`){if(N>n.length)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`))}else if(N>C)return Promise.reject(RangeError(`options.min must be smaller or equal to view size`));if(this[Kn].stream===void 0)return Promise.reject(TypeError(`Reader has no associated stream`));let I=new BYOBReadIntoRequest;return readableStreamBYOBReaderRead(this,n,N,I),I.promise}releaseLock(){if(!_r(this))throw TypeError(`Invalid this`);this[Kn].stream!==void 0&&readableStreamBYOBReaderRelease(this)}get closed(){return _r(this)?this[Kn].close.promise:Promise.reject(TypeError(`Invalid this`))}cancel(n=void 0){return _r(this)?this[Kn].stream===void 0?Promise.reject(TypeError(`Reader has no associated stream`)):readableStreamReaderGenericCancel(this,n):Promise.reject(TypeError(`Invalid this`))}get[Symbol.toStringTag](){return`ReadableStreamBYOBReader`}},ReadableStreamBYOBRequest=class{[qn]=`ReadableStreamBYOBRequest`;[Kn];constructor(n){if(n!==ur)throw TypeError(`Illegal constructor`)}get view(){if(!vr(this))throw TypeError(`Invalid this`);return this[Kn].view}respond(n){if(!vr(this))throw TypeError(`Invalid this`);if(this[Kn].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(n=+n,!Number.isInteger(n)||n<0||!Number.isFinite(n))throw RangeError(`bytesWritten must be a non-negative integer`);let a=this[Kn].view;if(isDetachedBuffer(a.buffer))throw TypeError(`The BYOB request's buffer has been detached`);readableByteStreamControllerRespond(this[Kn].controller,n)}respondWithNewView(n){if(!vr(this))throw TypeError(`Invalid this`);if(this[Kn].controller===void 0)throw TypeError(`BYOB request has been invalidated`);if(typeof n!=`object`||!n||!ArrayBuffer.isView(n))throw TypeError(`view must be an ArrayBufferView`);if(isDetachedBuffer(n.buffer))throw TypeError(`The given view's buffer has been detached`);readableByteStreamControllerRespondWithNewView(this[Kn].controller,n)}get[Symbol.toStringTag](){return`ReadableStreamBYOBRequest`}},ReadableByteStreamController=class{[qn]=`ReadableByteStreamController`;[Kn];constructor(n){if(n!==ur)throw TypeError(`Illegal constructor`)}get byobRequest(){if(!gr(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetBYOBRequest(this)}get desiredSize(){if(!gr(this))throw TypeError(`Invalid this`);return readableByteStreamControllerGetDesiredSize(this)}close(){if(!gr(this))throw TypeError(`Invalid this`);if(this[Kn].closeRequested)throw TypeError(`Close already requested`);if(this[Kn].stream[Kn].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerClose(this)}enqueue(n){if(!gr(this))throw TypeError(`Invalid this`);if(typeof n!=`object`||!n||!ArrayBuffer.isView(n))throw TypeError(`chunk must be an ArrayBufferView`);if(n.byteLength===0)throw TypeError(`chunk length must be non-zero`);if(n.buffer.byteLength===0)throw TypeError(`chunk's buffer length must be non-zero`);if(this[Kn].closeRequested)throw TypeError(`Cannot enqueue after close has been requested`);if(this[Kn].stream[Kn].state!==`readable`)throw TypeError(`Stream is not in a readable state`);readableByteStreamControllerEnqueue(this,n)}error(n=void 0){if(!gr(this))throw TypeError(`Invalid this`);readableByteStreamControllerError(this,n)}[rr](n){return readableByteStreamControllerCancelSteps(this,n)}[cr](n){readableByteStreamControllerPullSteps(this,n)}[lr](){if(this[Kn].pendingPullIntos.length>0){let n=this[Kn].pendingPullIntos[0];n.readerType=`none`,this[Kn].pendingPullIntos=[n]}}get[Symbol.toStringTag](){return`ReadableByteStreamController`}};const gr=isBrandCheck(`ReadableByteStreamController`),_r=isBrandCheck(`ReadableStreamBYOBReader`),vr=isBrandCheck(`ReadableStreamBYOBRequest`);function readableStreamHasBYOBReader(n){let{reader:a}=n[Kn];return a===void 0?!1:a[Kn]!==void 0&&a[qn]===`ReadableStreamBYOBReader`}function readableStreamGetNumReadIntoRequests(n){return n[Kn].reader[Kn].readIntoRequests.length}function readableStreamAddReadIntoRequest(n,a){n[Kn].reader[Kn].readIntoRequests.push(a)}function readableStreamFulfillReadIntoRequest(n,a,S){let{reader:C}=n[Kn],N=C[Kn].readIntoRequests.shift();S?N[ir](a):N[ar](a)}function setupReadableStreamBYOBReader(n,a){if(isReadableStreamLocked(a))throw TypeError(`ReadableStream is locked`);if(!gr(a[Kn].controller))throw TypeError(`Cannot use a BYOB reader with a non-byte stream`);readableStreamReaderGenericInitialize(n,a),n[Kn].readIntoRequests=[]}function readableStreamBYOBReaderRead(n,a,S,C){let{stream:N}=n[Kn];N[Kn].disturbed=!0,N[Kn].state===`errored`?C[sr](N[Kn].storedError):readableByteStreamControllerPullInto(N[Kn].controller,a,S,C)}function readableStreamBYOBReaderRelease(n){readableStreamReaderGenericRelease(n);let a=TypeError(`Reader was released`);for(let S=0;S<n[Kn].readIntoRequests.length;S++)n[Kn].readIntoRequests[S][sr](a);n[Kn].readIntoRequests=[]}function readableByteStreamControllerClearAlgorithms(n){n[Kn].pullAlgorithm=void 0,n[Kn].cancelAlgorithm=void 0}function readableByteStreamControllerClearPendingPullIntos(n){readableByteStreamControllerInvalidateBYOBRequest(n),n[Kn].pendingPullIntos=[]}function readableByteStreamControllerInvalidateBYOBRequest(n){let a=n[Kn].byobRequest;a!=null&&(a[Kn].controller=void 0,a[Kn].view=null,n[Kn].byobRequest=null)}function readableByteStreamControllerError(n,a){let{stream:S}=n[Kn];S[Kn].state===`readable`&&(readableByteStreamControllerClearPendingPullIntos(n),resetQueue(n),readableByteStreamControllerClearAlgorithms(n),readableStreamError(S,a))}function readableByteStreamControllerGetDesiredSize(n){let a=n[Kn].stream[Kn].state;return a===`errored`?null:a===`closed`?0:n[Kn].highWaterMark-n[Kn].queueTotalSize}function readableByteStreamControllerShouldCallPull(n){let{stream:a}=n[Kn];if(a[Kn].state!==`readable`||n[Kn].closeRequested||!n[Kn].started)return!1;if(readableStreamHasDefaultReader(a)&&readableStreamGetNumReadRequests(a)>0||readableStreamHasBYOBReader(a)&&readableStreamGetNumReadIntoRequests(a)>0)return!0;let S=readableByteStreamControllerGetDesiredSize(n);return S!==null&&S>0}function readableByteStreamControllerCallPullIfNeeded(n){if(readableByteStreamControllerShouldCallPull(n)){if(n[Kn].pulling){n[Kn].pullAgain=!0;return}n[Kn].pulling=!0,n[Kn].pullAlgorithm(n).then(()=>{n[Kn].pulling=!1,n[Kn].pullAgain&&(n[Kn].pullAgain=!1,readableByteStreamControllerCallPullIfNeeded(n))},a=>readableByteStreamControllerError(n,a))}}function readableByteStreamControllerHandleQueueDrain(n){n[Kn].queueTotalSize===0&&n[Kn].closeRequested?(readableByteStreamControllerClearAlgorithms(n),readableStreamClose(n[Kn].stream)):readableByteStreamControllerCallPullIfNeeded(n)}function readableByteStreamControllerEnqueueChunkToQueue(n,a,S,C){n[Kn].queue.push({buffer:a,byteOffset:S,byteLength:C}),n[Kn].queueTotalSize+=C}function readableByteStreamControllerEnqueueClonedChunkToQueue(n,a,S,C){let N;try{N=a.slice(S,S+C)}catch(a){readableByteStreamControllerError(n,a);return}readableByteStreamControllerEnqueueChunkToQueue(n,N,0,C)}function readableByteStreamControllerEnqueueDetachedPullIntoToQueue(n,a){a.bytesFilled>0&&readableByteStreamControllerEnqueueClonedChunkToQueue(n,a.buffer,a.byteOffset,a.bytesFilled),readableByteStreamControllerShiftPendingPullInto(n)}function readableByteStreamControllerShiftPendingPullInto(n){return n[Kn].pendingPullIntos.shift()}function readableByteStreamControllerFillHeadPullIntoDescriptor(n,a,S){S.bytesFilled+=a}function readableByteStreamControllerConvertPullIntoDescriptor(n){let a=n.bytesFilled,S=n.elementSize,C=transferArrayBuffer(n.buffer);return n.buffer=C,new n.viewConstructor(C,n.byteOffset,a/S)}function readableByteStreamControllerCommitPullIntoDescriptor(n,a){let S=!1;n[Kn].state===`closed`&&(S=!0);let C=readableByteStreamControllerConvertPullIntoDescriptor(a);a.readerType==="default"?readableStreamFulfillReadRequest(n,C,S):readableStreamFulfillReadIntoRequest(n,C,S)}function readableByteStreamControllerFillPullIntoDescriptorFromQueue(n,a){let S=Math.min(n[Kn].queueTotalSize,a.byteLength-a.bytesFilled),C=a.bytesFilled+S,N=S,F=!1,I=C-C%a.elementSize;I>=a.minimumFill&&(N=I-a.bytesFilled,F=!0);let H=n[Kn].queue;for(;N>0;){let S=H[0],C=Math.min(N,S.byteLength),F=a.byteOffset+a.bytesFilled,I=new Uint8Array(a.buffer,F,C),W=new Uint8Array(S.buffer,S.byteOffset,C);I.set(W),S.byteLength===C?H.shift():(S.byteOffset+=C,S.byteLength-=C),n[Kn].queueTotalSize-=C,readableByteStreamControllerFillHeadPullIntoDescriptor(n,C,a),N-=C}return F}function readableByteStreamControllerFillReadRequestFromQueue(n,a){let S=n[Kn].queue.shift();n[Kn].queueTotalSize-=S.byteLength,readableByteStreamControllerHandleQueueDrain(n);let C=new Uint8Array(S.buffer,S.byteOffset,S.byteLength);a[ar](C)}function readableByteStreamControllerProcessReadRequestsUsingQueue(n){let a=n[Kn].stream[Kn].reader;for(;a[Kn].readRequests.length!==0;){if(n[Kn].queueTotalSize===0)return;readableByteStreamControllerFillReadRequestFromQueue(n,a[Kn].readRequests.shift())}}function readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n){for(;n[Kn].pendingPullIntos.length!==0;){if(n[Kn].queueTotalSize===0)return;let a=n[Kn].pendingPullIntos[0];readableByteStreamControllerFillPullIntoDescriptorFromQueue(n,a)&&(readableByteStreamControllerShiftPendingPullInto(n),readableByteStreamControllerCommitPullIntoDescriptor(n[Kn].stream,a))}}function readableByteStreamControllerGetBYOBRequest(n){if(n[Kn].byobRequest===null&&n[Kn].pendingPullIntos.length!==0){let a=n[Kn].pendingPullIntos[0],S=new Uint8Array(a.buffer,a.byteOffset+a.bytesFilled,a.byteLength-a.bytesFilled),C=new ReadableStreamBYOBRequest(ur);C[Kn]={controller:n,view:S},n[Kn].byobRequest=C}return n[Kn].byobRequest}function readableByteStreamControllerEnqueue(n,a){let{stream:S}=n[Kn];if(n[Kn].closeRequested||S[Kn].state!==`readable`)return;let C=a.buffer,N=a.byteLength,F=a.byteOffset;if(isDetachedBuffer(C))throw TypeError(`chunk's buffer is detached`);let I=transferArrayBuffer(C);if(n[Kn].pendingPullIntos.length!==0){let a=n[Kn].pendingPullIntos[0];if(isDetachedBuffer(a.buffer))throw TypeError(`BYOB request's buffer has been detached`);readableByteStreamControllerInvalidateBYOBRequest(n),a.buffer=transferArrayBuffer(a.buffer),a.readerType===`none`&&readableByteStreamControllerEnqueueDetachedPullIntoToQueue(n,a)}readableStreamHasDefaultReader(S)?(readableByteStreamControllerProcessReadRequestsUsingQueue(n),readableStreamGetNumReadRequests(S)===0?readableByteStreamControllerEnqueueChunkToQueue(n,I,F,N):(n[Kn].pendingPullIntos.length!==0&&readableByteStreamControllerShiftPendingPullInto(n),readableStreamFulfillReadRequest(S,new Uint8Array(I,F,N),!1))):readableStreamHasBYOBReader(S)?(readableByteStreamControllerEnqueueChunkToQueue(n,I,F,N),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n)):readableByteStreamControllerEnqueueChunkToQueue(n,I,F,N),readableByteStreamControllerCallPullIfNeeded(n)}function readableByteStreamControllerClose(n){let{stream:a}=n[Kn];if(!(n[Kn].closeRequested||a[Kn].state!==`readable`)){if(n[Kn].queueTotalSize>0){n[Kn].closeRequested=!0;return}if(n[Kn].pendingPullIntos.length!==0){let a=n[Kn].pendingPullIntos[0];if(a.bytesFilled%a.elementSize!==0){let a=TypeError(`Insufficient bytes to fill elements in the given buffer`);throw readableByteStreamControllerError(n,a),a}}readableByteStreamControllerClearAlgorithms(n),readableStreamClose(a)}}function readableByteStreamControllerPullInto(n,a,S,C){let N=n[Kn].stream,F=a[Symbol.toStringTag],I,H;if(F===void 0||F===`DataView`)I=DataView,H=1;else{let n=typedArrayConstructorByTag(F);if(!n){C[sr](TypeError(`Unsupported typed array: ${F}`));return}I=n,H=elementSizeByTag(F)}let W=a.buffer,K=a.byteLength,q=a.byteOffset,Y=S*H,X;try{X=transferArrayBuffer(W)}catch(n){C[sr](n);return}let te={buffer:X,bufferByteLength:X.byteLength,byteOffset:q,byteLength:K,bytesFilled:0,minimumFill:Y,elementSize:H,viewConstructor:I,readerType:`byob`};if(n[Kn].pendingPullIntos.length!==0){n[Kn].pendingPullIntos.push(te),readableStreamAddReadIntoRequest(N,C);return}if(N[Kn].state===`closed`){let n=new I(te.buffer,te.byteOffset,0);C[ir](n);return}if(n[Kn].queueTotalSize>0){if(readableByteStreamControllerFillPullIntoDescriptorFromQueue(n,te)){let a=readableByteStreamControllerConvertPullIntoDescriptor(te);readableByteStreamControllerHandleQueueDrain(n),C[ar](a);return}if(n[Kn].closeRequested){let a=TypeError(`Insufficient bytes to fill elements in the given buffer`);readableByteStreamControllerError(n,a),C[sr](a);return}}n[Kn].pendingPullIntos.push(te),readableStreamAddReadIntoRequest(N,C),readableByteStreamControllerCallPullIfNeeded(n)}function readableByteStreamControllerRespond(n,a){let S=n[Kn].pendingPullIntos[0];if(n[Kn].stream[Kn].state===`closed`){if(a!==0)throw TypeError(`bytesWritten must be 0 when calling respond() on a closed stream`)}else{if(a===0)throw TypeError(`bytesWritten must be greater than 0 when calling respond() on a readable stream`);if(S.bytesFilled+a>S.byteLength)throw RangeError(`bytesWritten out of range`)}S.buffer=transferArrayBuffer(S.buffer),readableByteStreamControllerRespondInternal(n,a)}function readableByteStreamControllerRespondWithNewView(n,a){let S=n[Kn].pendingPullIntos[0],C=n[Kn].stream[Kn].state,N=a.byteLength,F=a.byteOffset,I=a.buffer;if(C===`closed`){if(N!==0)throw TypeError(`view's length must be 0 when calling respondWithNewView() on a closed stream`)}else if(N===0)throw TypeError(`view's length must be greater than 0 when calling respondWithNewView() on a readable stream`);if(S.byteOffset+S.bytesFilled!==F)throw RangeError(`The region specified by view does not match byobRequest`);if(S.bufferByteLength!==I.byteLength)throw RangeError(`The buffer of view has different capacity than byobRequest`);if(S.bytesFilled+N>S.byteLength)throw RangeError(`The region specified by view is larger than byobRequest`);S.buffer=transferArrayBuffer(I),readableByteStreamControllerRespondInternal(n,N)}function readableByteStreamControllerRespondInternal(n,a){let S=n[Kn].pendingPullIntos[0];readableByteStreamControllerInvalidateBYOBRequest(n),n[Kn].stream[Kn].state===`closed`?readableByteStreamControllerRespondInClosedState(n,S):readableByteStreamControllerRespondInReadableState(n,a,S),readableByteStreamControllerCallPullIfNeeded(n)}function readableByteStreamControllerRespondInClosedState(n,a){a.readerType===`none`&&readableByteStreamControllerShiftPendingPullInto(n);let S=n[Kn].stream;if(readableStreamHasBYOBReader(S))for(;readableStreamGetNumReadIntoRequests(S)>0;)readableByteStreamControllerCommitPullIntoDescriptor(S,readableByteStreamControllerShiftPendingPullInto(n))}function readableByteStreamControllerRespondInReadableState(n,a,S){if(readableByteStreamControllerFillHeadPullIntoDescriptor(n,a,S),S.readerType===`none`){readableByteStreamControllerEnqueueDetachedPullIntoToQueue(n,S),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n);return}if(S.bytesFilled<S.minimumFill)return;readableByteStreamControllerShiftPendingPullInto(n);let C=S.bytesFilled%S.elementSize;if(C>0){let a=S.byteOffset+S.bytesFilled;readableByteStreamControllerEnqueueClonedChunkToQueue(n,S.buffer,a-C,C)}S.bytesFilled-=C,readableByteStreamControllerCommitPullIntoDescriptor(n[Kn].stream,S),readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n)}function readableByteStreamControllerCancelSteps(n,a){readableByteStreamControllerClearPendingPullIntos(n),resetQueue(n);let S=n[Kn].cancelAlgorithm?.(a)??Promise.resolve();return readableByteStreamControllerClearAlgorithms(n),S}function readableByteStreamControllerPullSteps(n,a){let S=n[Kn].stream;if(n[Kn].queueTotalSize>0){readableByteStreamControllerFillReadRequestFromQueue(n,a);return}let C=n[Kn].autoAllocateChunkSize;if(C!==void 0){let S;try{S=new ArrayBuffer(C)}catch(n){a[sr](n);return}let N={buffer:S,bufferByteLength:C,byteOffset:0,byteLength:C,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:`default`};n[Kn].pendingPullIntos.push(N)}readableStreamAddReadRequest(S,a),readableByteStreamControllerCallPullIfNeeded(n)}function setupReadableByteStreamController(n,a,S,C,N,F,I){a[Kn]={cancelAlgorithm:N,closeRequested:!1,highWaterMark:F,pullAgain:!1,pullAlgorithm:C,pulling:!1,queue:[],queueTotalSize:0,started:!1,stream:n,byobRequest:null,pendingPullIntos:[],autoAllocateChunkSize:I},n[Kn].controller=a;let H=S();new Promise(n=>n(H)).then(()=>{a[Kn].started=!0,readableByteStreamControllerCallPullIfNeeded(a)},n=>readableByteStreamControllerError(a,n))}function setupReadableByteStreamControllerFromSource(n,a,S){let C=new ReadableByteStreamController(ur),N=a?.start,F=a?.pull,I=a?.cancel,H=a?.autoAllocateChunkSize;if(H!==void 0&&(H===0||!Number.isInteger(H)||H<0))throw TypeError(`autoAllocateChunkSize must be a positive integer`);setupReadableByteStreamController(n,C,N?N.bind(a,C):nonOpStart,F?createPromiseCallback(`source.pull`,F,a):nonOpPull,I?createPromiseCallback(`source.cancel`,I,a):nonOpCancel,S,H)}function readableByteStreamTee(n){let a=new ReadableStreamDefaultReader(n),S=!1,C=!1,N=!1,F,I,H=Promise.withResolvers(),W,K,q,Y;function pullAlgorithm(){return S?Promise.resolve():(S=!0,a.read().then(n=>{if(S=!1,n.done){C||q.close(),N||Y.close();return}let a=n.value,F=new Uint8Array(a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength));C||q.enqueue(F),N||Y.enqueue(new Uint8Array(F))},()=>{}),Promise.resolve())}return W=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(a){if(C=!0,F=a,N){let a=readableStreamCancel(n,[F,I]);return H.resolve(),a}return H.promise}}),K=new ReadableStream$1({type:`bytes`,pull:pullAlgorithm,cancel(a){if(N=!0,I=a,C){let a=readableStreamCancel(n,[F,I]);return H.resolve(),a}return H.promise}}),q=W[Kn].controller,Y=K[Kn].controller,a.closed.catch(n=>{q.error(n),Y.error(n),(!C||!N)&&H.resolve()}),[W,K]}const yr=Symbol(`kSkipThrow`);var TransformStream=class{[qn]=`TransformStream`;[Kn];constructor(n={},a={},S={}){if(n!=null&&typeof n!=`object`)throw TypeError(`transformer must be an object`);if(a!=null&&typeof a!=`object`)throw TypeError(`writableStrategy must be an object`);if(S!=null&&typeof S!=`object`)throw TypeError(`readableStrategy must be an object`);let C=n?.readableType,N=n?.writableType,F=n?.start;if(C!==void 0)throw RangeError(`Invalid readableType: ${C}`);if(N!==void 0)throw RangeError(`Invalid writableType: ${N}`);let I=extractHighWaterMark(S?.highWaterMark,0),H=extractSizeAlgorithm(S?.size),W=extractHighWaterMark(a?.highWaterMark,1),K=extractSizeAlgorithm(a?.size),q=Promise.withResolvers();initializeTransformStream(this,q,W,K,I,H),setupTransformStreamDefaultControllerFromTransformer(this,n),F===void 0?q.resolve():q.resolve(F.call(n,this[Kn].controller))}get readable(){if(!br(this))throw TypeError(`Invalid this`);return this[Kn].readable}get writable(){if(!br(this))throw TypeError(`Invalid this`);return this[Kn].writable}get[Symbol.toStringTag](){return`TransformStream`}},TransformStreamDefaultController=class{[qn]=`TransformStreamDefaultController`;[Kn];constructor(n){if(n!==yr)throw TypeError(`Illegal constructor`)}get desiredSize(){if(!Sr(this))throw TypeError(`Invalid this`);let{stream:n}=this[Kn],{readable:a}=n[Kn],S=a[Kn].controller;return readableStreamDefaultControllerGetDesiredSize(S)}enqueue(n){if(!Sr(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerEnqueue(this,n)}error(n){if(!Sr(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerError(this,n)}terminate(){if(!Sr(this))throw TypeError(`Invalid this`);transformStreamDefaultControllerTerminate(this)}get[Symbol.toStringTag](){return`TransformStreamDefaultController`}};const br=isBrandCheck(`TransformStream`),Sr=isBrandCheck(`TransformStreamDefaultController`);async function defaultTransformAlgorithm(n,a){transformStreamDefaultControllerEnqueue(a,n)}function initializeTransformStream(n,a,S,C,N,F){let startAlgorithm=()=>a.promise,I=createWritableStream(startAlgorithm,a=>transformStreamDefaultSinkWriteAlgorithm(n,a),()=>transformStreamDefaultSinkCloseAlgorithm(n),a=>transformStreamDefaultSinkAbortAlgorithm(n,a),S,C);n[Kn]={readable:createReadableStream(startAlgorithm,()=>transformStreamDefaultSourcePullAlgorithm(n),a=>transformStreamDefaultSourceCancelAlgorithm(n,a),N,F),writable:I,controller:void 0,backpressure:void 0,backpressureChange:{promise:void 0,resolve:void 0,reject:void 0}},transformStreamSetBackpressure(n,!0)}function transformStreamError(n,a){let{readable:S}=n[Kn];readableStreamDefaultControllerError(S[Kn].controller,a),transformStreamErrorWritableAndUnblockWrite(n,a)}function transformStreamErrorWritableAndUnblockWrite(n,a){let{controller:S,writable:C}=n[Kn];transformStreamDefaultControllerClearAlgorithms(S),writableStreamDefaultControllerErrorIfNeeded(C[Kn].controller,a),transformStreamUnblockWrite(n)}function transformStreamUnblockWrite(n){n[Kn].backpressure&&transformStreamSetBackpressure(n,!1)}function transformStreamSetBackpressure(n,a){n[Kn].backpressureChange.promise!==void 0&&n[Kn].backpressureChange.resolve?.(),n[Kn].backpressureChange=Promise.withResolvers(),n[Kn].backpressure=a}function setupTransformStreamDefaultController(n,a,S,C,N){a[Kn]={stream:n,transformAlgorithm:S,flushAlgorithm:C,cancelAlgorithm:N,finishPromise:void 0},n[Kn].controller=a}function setupTransformStreamDefaultControllerFromTransformer(n,a){let S=new TransformStreamDefaultController(yr),C=a?.transform,N=a?.flush,F=a?.cancel;setupTransformStreamDefaultController(n,S,C?createPromiseCallback(`transformer.transform`,C,a):defaultTransformAlgorithm,N?createPromiseCallback(`transformer.flush`,N,a):nonOpFlush,F?createPromiseCallback(`transformer.cancel`,F,a):nonOpCancel)}function transformStreamDefaultControllerClearAlgorithms(n){n[Kn].transformAlgorithm=void 0,n[Kn].flushAlgorithm=void 0,n[Kn].cancelAlgorithm=void 0}function transformStreamDefaultControllerEnqueue(n,a){let{stream:S}=n[Kn],{readable:C}=S[Kn],N=C[Kn].controller;if(!readableStreamDefaultControllerCanCloseOrEnqueue(N))throw TypeError(`Unable to enqueue`);try{readableStreamDefaultControllerEnqueue(N,a)}catch(n){throw transformStreamErrorWritableAndUnblockWrite(S,n),C[Kn].storedError}readableStreamDefaultControllerHasBackpressure(N)!==S[Kn].backpressure&&transformStreamSetBackpressure(S,!0)}function transformStreamDefaultControllerError(n,a){transformStreamError(n[Kn].stream,a)}async function transformStreamDefaultControllerPerformTransform(n,a){try{let S=n[Kn].transformAlgorithm;if(S===void 0)return;await S(a,n)}catch(a){throw transformStreamError(n[Kn].stream,a),a}}function transformStreamDefaultControllerTerminate(n){let{stream:a}=n[Kn],{readable:S}=a[Kn];readableStreamDefaultControllerClose(S[Kn].controller),transformStreamErrorWritableAndUnblockWrite(a,TypeError(`TransformStream has been terminated`))}function transformStreamDefaultSinkWriteAlgorithm(n,a){let{controller:S}=n[Kn];return n[Kn].backpressure?n[Kn].backpressureChange.promise.then(()=>{let{writable:C}=n[Kn];if(C[Kn].state===`erroring`)throw C[Kn].storedError;return transformStreamDefaultControllerPerformTransform(S,a)}):transformStreamDefaultControllerPerformTransform(S,a)}async function transformStreamDefaultSinkAbortAlgorithm(n,a){let{controller:S,readable:C}=n[Kn];if(S[Kn].finishPromise!==void 0)return S[Kn].finishPromise;let{promise:N,resolve:F,reject:I}=Promise.withResolvers();S[Kn].finishPromise=N;let H=S[Kn].cancelAlgorithm(a);return transformStreamDefaultControllerClearAlgorithms(S),H.then(()=>{C[Kn].state===`errored`?I(C[Kn].storedError):(readableStreamDefaultControllerError(C[Kn].controller,a),F())},n=>{readableStreamDefaultControllerError(C[Kn].controller,n),I(n)}),S[Kn].finishPromise}function transformStreamDefaultSinkCloseAlgorithm(n){let{readable:a,controller:S}=n[Kn];if(S[Kn].finishPromise!==void 0)return S[Kn].finishPromise;let{promise:C,resolve:N,reject:F}=Promise.withResolvers();S[Kn].finishPromise=C;let I=S[Kn].flushAlgorithm(S);return transformStreamDefaultControllerClearAlgorithms(S),I.then(()=>{a[Kn].state===`errored`?F(a[Kn].storedError):(readableStreamDefaultControllerClose(a[Kn].controller),N())},n=>{readableStreamDefaultControllerError(a[Kn].controller,n),F(n)}),S[Kn].finishPromise}function transformStreamDefaultSourcePullAlgorithm(n){return transformStreamSetBackpressure(n,!1),n[Kn].backpressureChange.promise}function transformStreamDefaultSourceCancelAlgorithm(n,a){let{controller:S,writable:C}=n[Kn];if(S[Kn].finishPromise!==void 0)return S[Kn].finishPromise;let{promise:N,resolve:F,reject:I}=Promise.withResolvers();S[Kn].finishPromise=N;let H=S[Kn].cancelAlgorithm(a);return transformStreamDefaultControllerClearAlgorithms(S),H.then(()=>{C[Kn].state===`errored`?I(C[Kn].storedError):(writableStreamDefaultControllerErrorIfNeeded(C[Kn].controller,a),transformStreamUnblockWrite(n),F())},a=>{writableStreamDefaultControllerErrorIfNeeded(C[Kn].controller,a),transformStreamUnblockWrite(n),I(a)}),S[Kn].finishPromise}const Cr=Object.defineProperty(n=>n.byteLength,"name",{value:`size`}),wr=Object.defineProperty(()=>1,"name",{value:`size`});var ByteLengthQueuingStrategy=class{#e;constructor(n){if(typeof n!=`object`||!n)throw TypeError(`init must be an object`);if(n.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+n.highWaterMark}get highWaterMark(){return this.#e}get size(){return Cr}get[Symbol.toStringTag](){return`ByteLengthQueuingStrategy`}},CountQueuingStrategy=class{#e;constructor(n){if(typeof n!=`object`||!n)throw TypeError(`init must be an object`);if(n.highWaterMark===void 0)throw TypeError(`init.highWaterMark is required`);this.#e=+n.highWaterMark}get highWaterMark(){return this.#e}get size(){return wr}get[Symbol.toStringTag](){return`CountQueuingStrategy`}},TextEncoderStream=class{#e=null;#t=new TextEncoder;#n;constructor(){this.#n=new TransformStream({transform:(n,a)=>{if(n=String(n),n===``)return;this.#e!==null&&(n=this.#e+n);let S=n.charCodeAt(n.length-1);55296<=S&&S<=56319?(this.#e=n.slice(-1),n=n.slice(0,-1)):this.#e=null,n&&a.enqueue(this.#t.encode(n))},flush:n=>{this.#e!==null&&n.enqueue(new Uint8Array([239,191,189]))}})}get encoding(){return`utf-8`}get readable(){return this.#n.readable}get writable(){return this.#n.writable}};function hasStreamingSupport(){try{return new TextDecoder().decode(new Uint8Array([195]),{stream:!0}),!0}catch{return!1}}const Tr=hasStreamingSupport();function incompleteUtf8Tail$1(n){let a=n.length;if(a===0)return 0;for(let S=1;S<=Math.min(3,a);S++){let C=n[a-S];if(!(C&128))return 0;if((C&192)!=128){let n;if((C&224)==192)n=2;else if((C&240)==224)n=3;else if((C&248)==240)n=4;else return 0;return S<n?S:0}}return 0}__name$1(incompleteUtf8Tail$1,`incompleteUtf8Tail`);var TextDecoderStream=class{#e;#t;constructor(n,a){if(this.#e=new TextDecoder(n,a),Tr)this.#t=new TransformStream({transform:(n,a)=>{let S=toUint8Array$3(n),C=this.#e.decode(S,{stream:!0});C&&a.enqueue(C)},flush:n=>{let a=this.#e.decode();a&&n.enqueue(a)},cancel:()=>{this.#e.decode()}});else{let n=new Uint8Array;this.#t=new TransformStream({transform:(a,S)=>{let C=toUint8Array$3(a),N;n.length>0?(N=new Uint8Array(n.length+C.length),N.set(n,0),N.set(C,n.length)):N=C;let F=incompleteUtf8Tail$1(N),I;if(F>0?(I=N.slice(0,N.length-F),n=N.slice(N.length-F)):(I=N,n=new Uint8Array),I.length>0){let n=this.#e.decode(I);n&&S.enqueue(n)}},flush:a=>{if(n.length>0){let S=this.#e.decode(n);S&&a.enqueue(S),n=new Uint8Array}},cancel:()=>{n=new Uint8Array}})}}get encoding(){return this.#e.encoding}get fatal(){return this.#e.fatal}get ignoreBOM(){return this.#e.ignoreBOM}get readable(){return this.#t.readable}get writable(){return this.#t.writable}};function toUint8Array$3(n){if(n instanceof Uint8Array)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw TypeError(`chunk must be a BufferSource`)}__name$1(toUint8Array$3,`toUint8Array`);function isNativeStreamUsable$3(n,a){try{return typeof n==`function`?typeof n.prototype?.[a]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$3,`isNativeStreamUsable`);const Er=isNativeStreamUsable$3(globalThis.ReadableStream,`getReader`)?globalThis.ReadableStream:ReadableStream$1,Dr=isNativeStreamUsable$3(globalThis.WritableStream,`getWriter`)?globalThis.WritableStream:WritableStream,Or=isNativeStreamUsable$3(globalThis.TransformStream,`readable`)?globalThis.TransformStream:TransformStream,kr=typeof globalThis.ByteLengthQueuingStrategy==`function`?globalThis.ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,Ar=typeof globalThis.CountQueuingStrategy==`function`?globalThis.CountQueuingStrategy:CountQueuingStrategy,jr=typeof globalThis.TextEncoderStream==`function`?globalThis.TextEncoderStream:TextEncoderStream,Mr=typeof globalThis.TextDecoderStream==`function`?globalThis.TextDecoderStream:TextDecoderStream;var Nr=__esmMin(()=>{Xe()});function _setPipeImpl(n){Pr=n}var Pr,Stream_,Fr=__esmMin(()=>{Kt(),Stream_=class extends Ft{constructor(n){super(n)}pipe(n,a){return Pr(this,n,a)}}});function finished$1(n,a,S){let C;C=typeof a==`function`?a:S;let N=!1;function done(n){N||(N=!0,C(n))}let onFinish=()=>done(),onEnd=()=>done(),onError=n=>done(n),onClose=()=>{let a=n,S=n;!a.writableFinished&&!S.readableEnded&&done(Error(`premature close`))};n.on(`finish`,onFinish),n.on(`end`,onEnd),n.on(`error`,onError),n.on(`close`,onClose);let F=n,I=typeof n.write==`function`,H=typeof n.read==`function`,W=F.writableFinished===!0,K=F.readableEnded===!0;if(F.destroyed===!0){let n=F._err;Me(n?()=>done(n):I&&W||H&&K?()=>done():()=>done(Error(`premature close`)))}else(I&&!H&&W||!I&&H&&K||I&&H&&W&&K)&&Me(()=>done());return function cleanup(){n.removeListener(`finish`,onFinish),n.removeListener(`end`,onEnd),n.removeListener(`error`,onError),n.removeListener(`close`,onClose)}}function addAbortSignal(n,a){if(!(n instanceof AbortSignal))throw TypeError(`The first argument must be an AbortSignal`);if(!(a instanceof Stream_))throw TypeError(`The second argument must be a Stream`);let S=a;if(n.aborted)S.destroy(Error(`The operation was aborted`));else{let onAbort=()=>{S.destroy(Error(`The operation was aborted`))};n.addEventListener(`abort`,onAbort,{once:!0}),a.once(`close`,()=>{n.removeEventListener(`abort`,onAbort)})}return a}function isReadable(n){if(n==null)return!1;let a=n;return typeof a.readable!=`boolean`||typeof a.read!=`function`||a.destroyed===!0||a.readableEnded===!0?!1:a.readable===!0}function isWritable(n){if(n==null)return!1;let a=n;return typeof a.writable!=`boolean`||typeof a.write!=`function`||a.destroyed===!0||a.writableEnded===!0?!1:a.writable===!0}function isDestroyed(n){return n==null?!1:n.destroyed===!0}function isDisturbed(n){if(n==null)return!1;let a=n;return a.readableDidRead===!0||a.readableFlowing!==null&&a.readableFlowing!==void 0}function isErrored(n){if(n==null)return!1;let a=n;return a.destroyed===!0&&typeof a.readable==`boolean`&&a.readable===!1||a.destroyed===!0&&typeof a.writable==`boolean`&&a.writable===!1}var Ir=__esmMin(()=>{Fr(),Xe(),__name$1(finished$1,`finished`)});function getDefaultHighWaterMark(n){return n?Rr:Lr}function setDefaultHighWaterMark(n,a){if(typeof a!=`number`||a<0||Number.isNaN(a))throw TypeError(`Invalid highWaterMark: ${a}`);n?Rr=a:Lr=a}function validateHighWaterMark(n,a){if(a!==void 0&&(typeof a!=`number`||Number.isNaN(a))){let S=TypeError(`The value of "${n}" is invalid. Received ${a}`);throw S.code=`ERR_INVALID_ARG_VALUE`,S}}var Lr,Rr,zr=__esmMin(()=>{Lr=16384,Rr=16});function createAbortError(){let n=Error(`The operation was aborted`);return n.name=`AbortError`,n.code=`ABORT_ERR`,n}async function streamAsyncDispose(n,a){let S;n.destroyed||(S=a?void 0:createAbortError(),n.destroy(S)),await new Promise((a,C)=>{finished$1(n,n=>{n&&n!==S?C(n):a()})})}var Br,Vr=__esmMin(()=>{Ir(),Br=Symbol.asyncDispose??Symbol.for(`Symbol.asyncDispose`)});function chunkLength(n){if(n==null)return 1;let a=n.length;return typeof a==`number`?a:1}function sliceChunk(n,a,S){if(typeof n==`string`)return S===void 0?n.slice(a):n.slice(a,S);let C=n.slice;return typeof C==`function`?C.call(n,a,S):n}var Hr,Ur=__esmMin(()=>{Fr(),Vr(),zr(),Xe(),Hr=class Readable_ extends Stream_{readable=!0;readableFlowing=null;readableLength=0;readableHighWaterMark;readableEncoding;readableObjectMode;readableEnded=!1;readableAborted=!1;destroyed=!1;_pipeDests=[];_buffer=[];_readableState={ended:!1,endEmitted:!1,reading:!1,constructed:!0,highWaterMark:0,objectMode:!1,pipes:[]};_err;_readablePending=!1;_readImpl;_destroyImpl;_constructImpl;constructor(n){super(n),this.readableHighWaterMark=n?.highWaterMark??getDefaultHighWaterMark(n?.objectMode??!1),this.readableEncoding=n?.encoding??null,this.readableObjectMode=n?.objectMode??!1,this._readableState.highWaterMark=this.readableHighWaterMark,this._readableState.objectMode=this.readableObjectMode,n?.read&&(this._readImpl=n.read),n?.destroy&&(this._destroyImpl=n.destroy),n?.construct&&(this._constructImpl=n.construct),(this._constructImpl||this._construct!==Readable_.prototype._construct)&&(this._readableState.constructed=!1,nextTick(()=>{this._construct(n=>{this._readableState.constructed=!0,n?this.destroy(n):this.readableFlowing===!0&&this._flow()})}))}_construct(n){this._constructImpl?this._constructImpl.call(this,n):n()}_read(n){this._readImpl&&this._readImpl.call(this,n)}read(n){if(!this._readableState.constructed)return null;if(this._buffer.length===0){if(this._readableState.ended)return null;this._readableState.reading=!0,this._read(n??this.readableHighWaterMark),this._readableState.reading=!1}if(this._buffer.length===0||n===0)return null;if(this.readableObjectMode){if(n===void 0){let n=this._buffer.shift();return--this.readableLength,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),n}if(n>this.readableLength)return null;let a=this._buffer.shift();return--this.readableLength,a}if(n!=null)return n>this.readableLength?null:this._readBytes(n);let a=this._buffer.splice(0);if(this.readableLength=0,this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted&&this._emitEnd(),a.length===1)return a[0];if(a.length===0)return null;if(typeof a[0]==`string`)return a.join(``);let S=globalThis.Buffer;return S?.concat?S.concat(a):a}_readBytes(n){let a=0,S=[];for(;a<n&&this._buffer.length>0;){let C=this._buffer[0],N=chunkLength(C);if(a+N<=n)S.push(this._buffer.shift()),a+=N,this.readableLength-=N;else{let N=n-a;S.push(sliceChunk(C,0,N)),this._buffer[0]=sliceChunk(C,N),this.readableLength-=N,a+=N}}if(S.length===1)return S[0];let C=globalThis.Buffer;return C?.concat?C.concat(S):S}push(n,a){if(n===null)return this._readableState.ended=!0,this.readableEnded=!0,this._buffer.length===0&&!this._readableState.endEmitted&&nextTick(()=>this._emitEnd()),this._scheduleReadable(),!1;if(!this.readableObjectMode&&!(typeof n==`string`||ArrayBuffer.isView(n))){let a=Object.assign(TypeError(`Invalid non-string/buffer chunk type: ${typeof n}`),{code:`ERR_INVALID_ARG_TYPE`});return nextTick(()=>this.emit(`error`,a)),!1}return this._buffer.push(n),this.readableLength+=this.readableObjectMode?1:chunkLength(n),this.readableFlowing&&!this._flowing&&nextTick(()=>this._flow()),this.readableFlowing!==!0&&this._scheduleReadable(),this.readableLength<this.readableHighWaterMark}_emitEnd(){this._readableState.endEmitted||(this._readableState.endEmitted=!0,this.emit(`end`),nextTick(()=>this._autoClose()))}_autoClose(){this.emit(`close`)}_scheduleReadable(){this._readablePending||this.listenerCount(`readable`)===0||(this._readablePending=!0,nextTick(()=>{this._readablePending=!1,this.destroyed||this.emit(`readable`)}))}on(n,a){return super.on(n,a),n===`data`&&this.readableFlowing!==!1&&this.resume(),n===`readable`&&(this._buffer.length>0||this._readableState.ended)&&this._scheduleReadable(),this}unshift(n){this._buffer.unshift(n),this.readableLength+=this.readableObjectMode?1:chunkLength(n)}setEncoding(n){return this.readableEncoding=n,this}pause(){return this.readableFlowing=!1,this.emit(`pause`),this}resume(){return this.readableFlowing!==!0&&(this.readableFlowing=!0,this.emit(`resume`),this._readableState.constructed&&this._flow()),this}_flowing=!1;_flow(){if(!(this.readableFlowing!==!0||this._flowing||this.destroyed)&&this._readableState.constructed){this._flowing=!0;try{for(;this._buffer.length>0&&this.readableFlowing&&!this.destroyed;){let n=this._buffer.shift();if(this.readableLength-=this.readableObjectMode?1:chunkLength(n),this.readableEncoding&&typeof n!=`string`){let a=globalThis.Buffer;a?.isBuffer&&a.isBuffer(n)?n=n.toString(this.readableEncoding):n instanceof Uint8Array&&(n=new TextDecoder(this.readableEncoding).decode(n))}this.emit(`data`,n)}if(this.destroyed)return;if(this._readableState.ended&&this._buffer.length===0&&!this._readableState.endEmitted){nextTick(()=>this._emitEnd());return}!this._readableState.ended&&!this._readableState.reading&&!this.destroyed&&(this._readableState.reading=!0,this._read(this.readableHighWaterMark),this._readableState.reading=!1)}finally{this._flowing=!1}this._buffer.length>0&&this.readableFlowing&&!this.destroyed&&nextTick(()=>this._flow())}}isPaused(){return this.readableFlowing===!1}unpipe(n){if(n){let a=this._pipeDests.findIndex(a=>a.dest===n);if(a!==-1){this._pipeDests[a].cleanup(),this._pipeDests.splice(a,1);let S=this._readableState.pipes.indexOf(n);S!==-1&&this._readableState.pipes.splice(S,1),n.emit(`unpipe`,this),this._pipeDests.length===0&&(this.readableFlowing=!1)}}else{for(let n of this._pipeDests)n.cleanup(),n.dest.emit(`unpipe`,this);this._pipeDests=[],this._readableState.pipes=[],this.readableFlowing=!1}return this}_destroy(n,a){this._destroyImpl?this._destroyImpl.call(this,n,a):a(n??void 0)}destroy(n){if(this.destroyed)return this;this.destroyed=!0,this.readable=!1,this.readableAborted=!this.readableEnded,n&&(this._err=n);let cb=n=>{n&&nextTick(()=>this.emit(`error`,n)),nextTick(()=>this.emit(`close`))};return Object.prototype.hasOwnProperty.call(this,`_destroy`)?this._destroy(n??null,cb):this._destroyImpl?this._destroyImpl.call(this,n??null,cb):cb(n),this}static toWeb(n){return new ReadableStream({start(a){n.on(`data`,n=>{typeof n==`string`?a.enqueue(new TextEncoder().encode(n)):n instanceof Uint8Array?a.enqueue(n):n&&typeof n.length==`number`&&a.enqueue(new Uint8Array(n))}),n.on(`end`,()=>{a.close()}),n.on(`error`,n=>{a.error(n)})},cancel(){n.destroy()}})}static fromWeb(n,a){let S=n.getReader();return new Readable_({...a,read(){S.read().then(({done:n,value:a})=>{n?this.push(null):this.push(a)},n=>{this.destroy(n)})},destroy(n,a){S.cancel(n?.message).then(()=>a(null),a)}})}[Symbol.asyncIterator](){let n=this,a=[],S=!1,C=null,N=null,F=null;return n.on(`data`,n=>{if(N){let a=N;N=null,F=null,a({value:n,done:!1})}else a.push(n)}),n.on(`end`,()=>{if(S=!0,N){let n=N;N=null,F=null,n({value:void 0,done:!0})}}),n.on(`error`,n=>{if(C=n,S=!0,F){let a=F;N=null,F=null,a(n)}}),{next(){return C?Promise.reject(C):a.length>0?Promise.resolve({value:a.shift(),done:!1}):S?Promise.resolve({value:void 0,done:!0}):new Promise((n,a)=>{N=n,F=a})},return(){return n.destroy(),Promise.resolve({value:void 0,done:!0})},[Symbol.asyncIterator](){return this}}}static from(n,a){let S=new Readable_({objectMode:!0,...a,read(){}});return typeof n==`string`||ArrayBuffer.isView(n)?(S.push(n),S.push(null),S):((async()=>{try{for await(let a of n)S.push(a)||await new Promise(n=>S.once(`drain`,n));S.push(null)}catch(n){S.destroy(n)}})(),S)}},Hr.prototype[Br]=function(){return streamAsyncDispose(this,this.readableEnded)}});function chunkLen$1(n){if(n==null)return 1;let a=n.length;return typeof a==`number`?a:1}var Duplex_,Wr=__esmMin(()=>{zr(),Ur(),Xe(),Duplex_=class extends Hr{writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;allowHalfOpen;_decodeStrings;_writableState={highWaterMark:0,objectMode:!1};_duplexCorkedBuffer=[];_duplexWriting=!1;_duplexWriteQueue=[];_writeImpl;_finalImpl;_defaultEncoding=`utf8`;_pendingWrites=0;_pendingEndCb=null;constructor(n){super(n),validateHighWaterMark(`writableHighWaterMark`,n?.writableHighWaterMark),validateHighWaterMark(`readableHighWaterMark`,n?.readableHighWaterMark),this.writableObjectMode=n?.writableObjectMode??n?.objectMode??!1,this.writableHighWaterMark=n?.highWaterMark??n?.writableHighWaterMark??getDefaultHighWaterMark(this.writableObjectMode),this._writableState.highWaterMark=this.writableHighWaterMark,this._writableState.objectMode=this.writableObjectMode,n?.highWaterMark===void 0&&n?.readableHighWaterMark!==void 0&&(this.readableHighWaterMark=n.readableHighWaterMark,this._readableState.highWaterMark=n.readableHighWaterMark),n?.readableObjectMode!==void 0&&(this.readableObjectMode=n.readableObjectMode,this._readableState.objectMode=n.readableObjectMode,n?.readableHighWaterMark===void 0&&n?.highWaterMark===void 0&&(this.readableHighWaterMark=getDefaultHighWaterMark(n.readableObjectMode),this._readableState.highWaterMark=this.readableHighWaterMark)),this.allowHalfOpen=n?.allowHalfOpen!==!1,this._decodeStrings=n?.decodeStrings!==!1,n?.write&&(this._writeImpl=n.write),n?.final&&(this._finalImpl=n.final),this.allowHalfOpen||this.once(`end`,()=>{this.writableEnded||nextTick(()=>this.end())})}_write(n,a,S){this._writeImpl?this._writeImpl.call(this,n,a,S):S()}_final(n){this._finalImpl?this._finalImpl.call(this,n):n()}destroy(n){return this.destroyed?this:(this.writable=!1,super.destroy(n))}write(n,a,S){let C,N;if(typeof a==`function`?(C=a,N=this._defaultEncoding):(N=a??this._defaultEncoding,C=S??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof n==`string`){let a=globalThis.Buffer;a&&(n=a.from(n,N),N=`buffer`)}if(typeof n!=`string`&&!this.writableObjectMode){let a=globalThis.Buffer;(a&&a.isBuffer(n)||n instanceof Uint8Array)&&(N=`buffer`)}if(this.writableEnded){let n=Error(`write after end`);return nextTick(()=>{C(n),this.emit(`error`,n)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen$1(n),this.writableCorked>0)return this._duplexCorkedBuffer.push({chunk:n,encoding:N,callback:C}),this.writableLength<this.writableHighWaterMark;let F=this.writableLength<this.writableHighWaterMark;return F||(this.writableNeedDrain=!0),this._duplexDoWrite(n,N,C),F}_duplexDoWrite(n,a,S){if(this._duplexWriting){this._duplexWriteQueue.push({chunk:n,encoding:a,callback:S});return}this._duplexWriting=!0,this._duplexStartWrite(n,a,S)}_duplexStartWrite(n,a,S){this._pendingWrites++,this._write(n,a,a=>{this._pendingWrites--,this.writableLength-=this.writableObjectMode?1:chunkLen$1(n),nextTick(a?()=>{if(S(a),this._duplexWriting=!1,this.emit(`error`,a),this._duplexWriteQueue.length>0){let n=this._duplexWriteQueue.shift();this._duplexWriting=!0,this._duplexStartWrite(n.chunk,n.encoding,n.callback)}}:()=>{if(S(),this._duplexWriteQueue.length>0){let n=this._duplexWriteQueue.shift();this._duplexStartWrite(n.chunk,n.encoding,n.callback);return}if(this._duplexWriting=!1,this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._pendingWrites===0&&this._pendingEndCb){let n=this._pendingEndCb;this._pendingEndCb=null,n()}})})}end(n,a,S){typeof n==`function`&&(S=n,n=void 0),typeof a==`function`&&(S=a,a=void 0),n!=null&&this.write(n,a),this.writableEnded=!0;let doFinal=()=>{this._final(n=>{this.writableFinished=!0,this._doPrefinishHooks(()=>{nextTick(()=>{n&&this.emit(`error`,n),this.emit(`finish`),nextTick(()=>this.emit(`close`)),S&&S()})})})};return this._pendingWrites>0||this._duplexWriting||this._duplexWriteQueue.length>0?this._pendingEndCb=doFinal:doFinal(),this}_doPrefinishHooks(n){n()}cork(){this.writableCorked++}uncork(){if(this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._duplexCorkedBuffer.length>0)){let n=this._duplexCorkedBuffer.splice(0);for(let{chunk:a,encoding:S,callback:C}of n)this._write(a,S,n=>{this.writableLength-=this.writableObjectMode?1:chunkLen$1(a),n?(C(n),this.emit(`error`,n)):C()});this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,nextTick(()=>this.emit(`drain`)))}}setDefaultEncoding(n){return this._defaultEncoding=n,this}},__name$1(chunkLen$1,`chunkLen`)});function pipe(n,a,S){let C=n,N=S?.end!==!1,F=!1,ondrain=()=>{F=!1,a.removeListener(`drain`,ondrain);let n=C;typeof n.resume==`function`&&n.resume()},ondata=n=>{if(a.writable){let S=C;a.write(n)===!1&&typeof S.pause==`function`&&(S.pause(),F||(F=!0,a.on(`drain`,ondrain)))}};C.on(`data`,ondata);let I=!1,onend=()=>{I||(I=!0,N&&a.end())},onclose=()=>{if(!I&&(I=!0,N&&!(C instanceof Hr))){let n=a;typeof n.destroy==`function`&&n.destroy()}};N&&(C.on(`end`,onend),C.on(`close`,onclose));let cleanup=()=>{C.removeListener(`data`,ondata),F&&a.removeListener(`drain`,ondrain),C.removeListener(`end`,onend),C.removeListener(`close`,onclose),C.removeListener(`end`,cleanup),C.removeListener(`close`,cleanup),a.removeListener(`close`,cleanup)};return C.on(`end`,cleanup),C.on(`close`,cleanup),a.on(`close`,cleanup),C instanceof Hr&&(C._pipeDests.push({dest:a,cleanup}),C._readableState.pipes.push(a)),a.emit(`pipe`,C),a}var Gr=__esmMin(()=>{Fr(),Ur(),_setPipeImpl(pipe)});function chunkLen(n){if(n==null)return 1;let a=n.length;return typeof a==`number`?a:1}var Kr,qr=__esmMin(()=>{Fr(),Vr(),zr(),Xe(),Kr=class Writable_ extends Stream_{static[Symbol.hasInstance](n){let a=this;return a.prototype!==void 0&&Object.prototype.isPrototypeOf.call(a.prototype,n)?!0:a.prototype!==Writable_.prototype||n==null?!1:typeof n.writableHighWaterMark==`number`}writable=!0;writableHighWaterMark;writableLength=0;writableObjectMode;writableEnded=!1;writableFinished=!1;writableCorked=0;writableNeedDrain=!1;destroyed=!1;_err;_writableState={ended:!1,finished:!1,constructed:!0,writing:!1};_corkedBuffer=[];_writeBuffer=[];_pendingConstruct=[];_ending=!1;_endCallback;_pendingEnd=null;_writeImpl;_writev;_finalImpl;_destroyImpl;_constructImpl;_decodeStrings;_defaultEncoding=`utf8`;constructor(n){super(n),this.writableHighWaterMark=n?.highWaterMark??getDefaultHighWaterMark(n?.objectMode??!1),this.writableObjectMode=n?.objectMode??!1,this._decodeStrings=n?.decodeStrings!==!1,n?.write&&(this._writeImpl=n.write),n?.writev&&(this._writev=n.writev),n?.final&&(this._finalImpl=n.final),n?.destroy&&(this._destroyImpl=n.destroy),n?.construct&&(this._constructImpl=n.construct),(this._constructImpl||this._construct!==Writable_.prototype._construct)&&(this._writableState.constructed=!1,nextTick(()=>{this._construct(n=>{this._writableState.constructed=!0,n?this.destroy(n):this._maybeFlush()})}))}_construct(n){this._constructImpl?this._constructImpl.call(this,n):n()}_write(n,a,S){this._writeImpl?this._writeImpl.call(this,n,a,S):S()}_final(n){this._finalImpl?this._finalImpl.call(this,n):n()}_destroy(n,a){this._destroyImpl?this._destroyImpl.call(this,n,a):a(n)}_maybeFlush(){let n=this._pendingConstruct.splice(0);if(n.length>0){let[a,...S]=n;this._writeBuffer.push(...S),this._doWrite(a.chunk,a.encoding,a.callback)}if(this._pendingEnd){let{chunk:n,encoding:a,callback:S}=this._pendingEnd;this._pendingEnd=null,this._doEnd(n,a,S)}}_doWrite(n,a,S){this._writableState.writing=!0;let C=!0;this._write(n,a,a=>{if(this.writableLength-=this.writableObjectMode?1:chunkLen(n),C){nextTick(()=>{if(a){S(a),this.emit(`error`,a);return}S(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}),a||this._drainWriteBuffer();return}nextTick(a?()=>{S(a),this.emit(`error`,a),this._drainWriteBuffer()}:()=>{S(),this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`)),this._drainWriteBuffer()})}),C=!1}_drainWriteBuffer(){if(this._writeBuffer.length>0){let n=this._writeBuffer.shift();this._doWrite(n.chunk,n.encoding,n.callback)}else this._writableState.writing=!1,this._maybeFinish()}_maybeFinish(){!this._ending||this._writableState.finished||this._writableState.writing||this._writeBuffer.length>0||(this._ending=!1,this._final(n=>{this.writableFinished=!0,this._writableState.finished=!0,nextTick(()=>{n&&this.emit(`error`,n),this.emit(`finish`),nextTick(()=>this.emit(`close`)),this._endCallback&&this._endCallback()})}))}write(n,a,S){let C,N;if(typeof a==`function`?(C=a,N=this._defaultEncoding):(N=a??this._defaultEncoding,C=S??(()=>{})),this._decodeStrings&&!this.writableObjectMode&&typeof n==`string`){let a=globalThis.Buffer;a&&(n=a.from(n,N),N=`buffer`)}if(typeof n!=`string`&&!this.writableObjectMode){let a=globalThis.Buffer;(a&&a.isBuffer(n)||n instanceof Uint8Array)&&(N=`buffer`)}if(this.writableEnded){let n=Error(`write after end`);return nextTick(()=>{C(n),this.emit(`error`,n)}),!1}if(this.writableLength+=this.writableObjectMode?1:chunkLen(n),this.writableCorked>0)return this._corkedBuffer.push({chunk:n,encoding:N,callback:C}),this.writableLength<this.writableHighWaterMark;if(!this._writableState.constructed)return this._pendingConstruct.push({chunk:n,encoding:N,callback:C}),this.writableLength<this.writableHighWaterMark;let F=this.writableLength<this.writableHighWaterMark;return F||(this.writableNeedDrain=!0),this._writableState.writing?this._writeBuffer.push({chunk:n,encoding:N,callback:C}):this._doWrite(n,N,C),F}_doEnd(n,a,S){n!=null&&this.write(n,a),this.writableEnded=!0,this._writableState.ended=!0,this._ending=!0,this._endCallback=S,this._maybeFinish()}end(n,a,S){return typeof n==`function`&&(S=n,n=void 0),typeof a==`function`&&(S=a,a=void 0),this.writableEnded?(S&&nextTick(S),this):this._writableState.constructed?(this._doEnd(n,a,S),this):(this._pendingEnd={chunk:n,encoding:a,callback:S},this)}cork(){this.writableCorked++}uncork(){this.writableCorked>0&&(this.writableCorked--,this.writableCorked===0&&this._corkedBuffer.length>0&&this._flushCorkedBuffer())}_flushCorkedBuffer(){if(this._writev&&this._corkedBuffer.length>1){let n=this._corkedBuffer.splice(0),a=n.map(n=>({chunk:n.chunk,encoding:n.encoding}));this._writev.call(this,a,a=>{for(let a of n)this.writableLength-=this.writableObjectMode?1:chunkLen(a.chunk);if(a){for(let S of n)S.callback(a);this.emit(`error`,a)}else{for(let a of n)a.callback();this.writableNeedDrain&&this.writableLength<=this.writableHighWaterMark&&(this.writableNeedDrain=!1,this.emit(`drain`))}})}else{let n=this._corkedBuffer.splice(0);if(n.length>0){let[a,...S]=n;this._writeBuffer.push(...S),this._doWrite(a.chunk,a.encoding,a.callback)}}}setDefaultEncoding(n){return this._defaultEncoding=n,this}destroy(n){if(this.destroyed)return this;this.destroyed=!0,this.writable=!1,n&&(this._err=n);let cb=n=>{n&&nextTick(()=>this.emit(`error`,n)),nextTick(()=>this.emit(`close`))};return this._destroy(n??null,cb),this}},Kr.prototype[Br]=function(){return streamAsyncDispose(this,this.writableFinished)}}),Jr,Yr=__esmMin(()=>{Wr(),Xe(),Jr=class Transform_ extends Duplex_{constructor(n){super({...n,write:void 0,final:void 0});let a=this;n?.transform&&(a._transform=n.transform),n?.flush&&(a._flush=n.flush),n?.final&&(a._final=n.final)}_transform(n,a,S){throw Object.assign(Error(`The _transform() method is not implemented`),{code:`ERR_METHOD_NOT_IMPLEMENTED`})}_flush(n){n()}_write(n,a,S){let C=!1;try{this._transform(n,a,(n,a)=>{if(C){let n=Object.assign(Error(`Callback called multiple times`),{code:`ERR_MULTIPLE_CALLBACK`});nextTick(()=>this.emit(`error`,n));return}if(C=!0,n){S(n);return}a!=null&&this.push(a),S()})}catch(n){if(n?.code===`ERR_METHOD_NOT_IMPLEMENTED`)throw n;S(n)}}_final(n){this._flush((a,S)=>{if(a){n(a);return}S!=null&&this.push(S),this.push(null),n()})}_doPrefinishHooks(n){let a=Transform_.prototype._final;this._final===a?n():a.call(this,n)}}}),PassThrough_,Xr=__esmMin(()=>{Yr(),PassThrough_=class extends Jr{constructor(n){super({...n,transform(n,a,S){S(null,n)}})}}});function pipeline(...n){let a=n,S=typeof a[a.length-1]==`function`?a.pop():void 0,C=a;if(C.length<2)throw Error(`pipeline requires at least 2 streams`);let N=null;function onError(n){if(!N){N=n;for(let n of C)typeof n.destroy==`function`&&n.destroy();S&&S(n)}}let F=C[0];for(let n=1;n<C.length;n++){let a=C[n];F.pipe(a),F.on(`error`,onError),F=a}let I=C[C.length-1];return I.on(`error`,onError),I.on(`finish`,()=>{S&&!N&&S(null)}),I}var Zr=__esmMin(()=>{}),Qr=__exportAll$3({Duplex:()=>ni,PassThrough:()=>ii,Readable:()=>ei,Stream:()=>$r,Transform:()=>ri,Writable:()=>ti,addAbortSignal:()=>addAbortSignal,default:()=>ai,finished:()=>finished$1,getDefaultHighWaterMark:()=>getDefaultHighWaterMark,isDestroyed:()=>isDestroyed,isDisturbed:()=>isDisturbed,isErrored:()=>isErrored,isReadable:()=>isReadable,isWritable:()=>isWritable,"module.exports":()=>ai,pipeline:()=>pipeline,setDefaultHighWaterMark:()=>setDefaultHighWaterMark}),$r,ei,ti,ni,ri,ii,ai,oi=__esmMin(()=>{Nr(),Fr(),Ir(),zr(),Ur(),Wr(),Gr(),qr(),Yr(),Xr(),Zr(),$r=makeCallable(Stream_),ei=makeCallable(Hr),ti=makeCallable(Kr),ni=makeCallable(Duplex_),ri=makeCallable(Jr),ii=makeCallable(PassThrough_),ai=Object.assign($r,{Stream:$r,Readable:ei,Writable:ti,Duplex:ni,Transform:ri,PassThrough:ii,pipeline,finished:finished$1,addAbortSignal,isReadable,isWritable,isDestroyed,isDisturbed,isErrored,getDefaultHighWaterMark,setDefaultHighWaterMark})});function getGioCompressorFormat(n){switch(n){case`gzip`:return me.ZlibCompressorFormat.GZIP;case`deflate`:return me.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return me.ZlibCompressorFormat.RAW}}function toUint8Array$2(n){return typeof n==`string`?new TextEncoder().encode(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}function concat(n){let a=n.reduce((n,a)=>n+a.length,0),S=new Uint8Array(a),C=0;for(let a of n)S.set(a,C),C+=a.length;return S}function compressWithGio$1(n,a){let S=new me.ZlibCompressor({format:getGioCompressorFormat(a)}),C=new me.ConverterOutputStream({base_stream:me.MemoryOutputStream.new_resizable(),converter:S});C.write_bytes(new Z.Bytes(n),null),C.close(null);let N=C.get_base_stream().steal_as_bytes();return new Uint8Array(N.get_data()??[])}function decompressMemberWithGio(n,a){let S=new me.ZlibDecompressor({format:getGioCompressorFormat(a)}),C=me.MemoryInputStream.new_from_bytes(new Z.Bytes(n)),N=new me.ConverterInputStream({base_stream:C,converter:S}),F=[];for(;;){let n=N.read_bytes(4096,null);if(n.get_size()===0)break;F.push(new Uint8Array(n.get_data()))}return N.close(null),concat(F)}function findGzipMemberEnd$1(n){let a=new me.ZlibDecompressor({format:me.ZlibCompressorFormat.GZIP}),S=new Uint8Array(65536),C=0,N=!1;for(;!N;){let F=n.subarray(C);try{let[n,I]=a.convert(F,S,me.ConverterFlags.NONE);C+=I,n===me.ConverterResult.FINISHED&&(N=!0)}catch{N=!0}}return C}function gunzipWithGio(n){let a=[],S=0;for(;S<n.length&&!(n.length-S<2||n[S]!==31||n[S+1]!==139);){let C=n.subarray(S),N=findGzipMemberEnd$1(C);if(N<=0)break;a.push(decompressMemberWithGio(C.subarray(0,N),`gzip`)),S+=N}return a.length===0?decompressMemberWithGio(n,`gzip`):concat(a)}function createGzip(n){return new Gzip(n)}function createGunzip(n){return new Gunzip(n)}function createDeflate(n){return new Deflate(n)}function createInflate(n){return new Inflate(n)}function createDeflateRaw(n){return new DeflateRaw(n)}function createInflateRaw(n){return new InflateRaw(n)}function createUnzip(n){return new Unzip(n)}function createBrotliCompress(n){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(n){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}function createZstdCompress(n){let a=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw a.code=`ERR_UNSUPPORTED_OPERATION`,a}function createZstdDecompress(n){let a=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw a.code=`ERR_UNSUPPORTED_OPERATION`,a}var ZlibBase,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,si=__esmMin(()=>{he(),se(),oi(),__name$1(toUint8Array$2,`toUint8Array`),__name$1(compressWithGio$1,`compressWithGio`),__name$1(findGzipMemberEnd$1,`findGzipMemberEnd`),ZlibBase=class extends ri{_mode;_chunks=[];constructor(n,a){super(a),this._mode=n}_transform(n,a,S){this._chunks.push(toUint8Array$2(n)),S()}_flush(n){let a=concat(this._chunks);this._chunks=[];try{this.push(Buffer.from(this._run(a))),n()}catch(a){n(a instanceof Error?a:Error(String(a)))}}_run(n){let a=this._mode;switch(a.kind){case`compress`:return compressWithGio$1(n,a.format);case`decompress`:return decompressMemberWithGio(n,a.format);case`gunzip`:return gunzipWithGio(n);case`unzip`:return n.length>=2&&n[0]===31&&n[1]===139?gunzipWithGio(n):decompressMemberWithGio(n,`deflate`)}}},Gzip=class extends ZlibBase{constructor(n){super({kind:`compress`,format:`gzip`},n)}},Gunzip=class extends ZlibBase{constructor(n){super({kind:`gunzip`},n)}},Deflate=class extends ZlibBase{constructor(n){super({kind:`compress`,format:`deflate`},n)}},Inflate=class extends ZlibBase{constructor(n){super({kind:`decompress`,format:`deflate`},n)}},DeflateRaw=class extends ZlibBase{constructor(n){super({kind:`compress`,format:`deflate-raw`},n)}},InflateRaw=class extends ZlibBase{constructor(n){super({kind:`decompress`,format:`deflate-raw`},n)}},Unzip=class extends ZlibBase{constructor(n){super({kind:`unzip`},n)}},BrotliCompress=class extends ri{constructor(){throw super(),Error(`BrotliCompress is not supported on GJS (no Brotli in GLib)`)}},BrotliDecompress=class extends ri{constructor(){throw super(),Error(`BrotliDecompress is not supported on GJS (no Brotli in GLib)`)}},ZstdCompress=class extends ri{constructor(){super();let n=Error(`ZstdCompress is not supported on GJS (no Zstd in GLib)`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}},ZstdDecompress=class extends ri{constructor(){super();let n=Error(`ZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}}}),ci=__exportAll$3({BrotliCompress:()=>BrotliCompress,BrotliDecompress:()=>BrotliDecompress,Deflate:()=>Deflate,DeflateRaw:()=>DeflateRaw,Gunzip:()=>Gunzip,Gzip:()=>Gzip,Inflate:()=>Inflate,InflateRaw:()=>InflateRaw,Unzip:()=>Unzip,ZlibTransform:()=>ZlibBase,ZstdCompress:()=>ZstdCompress,ZstdDecompress:()=>ZstdDecompress,brotliCompress:()=>brotliCompress,brotliCompressSync:()=>brotliCompressSync,brotliDecompress:()=>brotliDecompress,brotliDecompressSync:()=>brotliDecompressSync,constants:()=>fi,createBrotliCompress:()=>createBrotliCompress,createBrotliDecompress:()=>createBrotliDecompress,createDeflate:()=>createDeflate,createDeflateRaw:()=>createDeflateRaw,createGunzip:()=>createGunzip,createGzip:()=>createGzip,createInflate:()=>createInflate,createInflateRaw:()=>createInflateRaw,createUnzip:()=>createUnzip,createZstdCompress:()=>createZstdCompress,createZstdDecompress:()=>createZstdDecompress,default:()=>pi,deflate:()=>deflate,deflateRaw:()=>deflateRaw,deflateRawSync:()=>deflateRawSync,deflateSync:()=>deflateSync,gunzip:()=>gunzip$1,gunzipSync:()=>gunzipSync,gzip:()=>gzip$1,gzipSync:()=>gzipSync,inflate:()=>inflate,inflateRaw:()=>inflateRaw,inflateRawSync:()=>inflateRawSync,inflateSync:()=>inflateSync,zstdCompress:()=>zstdCompress,zstdCompressSync:()=>zstdCompressSync,zstdDecompress:()=>zstdDecompress,zstdDecompressSync:()=>zstdDecompressSync});function getGioFormat(n){switch(n){case`gzip`:return me.ZlibCompressorFormat.GZIP;case`deflate`:return me.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return me.ZlibCompressorFormat.RAW}}function compressWithGio(n,a){let S=new me.ZlibCompressor({format:getGioFormat(a)}),C=new me.ConverterOutputStream({base_stream:me.MemoryOutputStream.new_resizable(),converter:S});C.write_bytes(new Z.Bytes(n),null),C.close(null);let N=C.get_base_stream().steal_as_bytes();return new Uint8Array(N.get_data()??[])}function decompressStreamWithGio(n,a){let S=new me.ZlibDecompressor({format:getGioFormat(a)}),C=me.MemoryInputStream.new_from_bytes(new Z.Bytes(n)),N=new me.ConverterInputStream({base_stream:C,converter:S}),F=[];for(;;){let n=N.read_bytes(4096,null);if(n.get_size()===0)break;F.push(new Uint8Array(n.get_data()))}N.close(null);let I=F.reduce((n,a)=>n+a.length,0),H=new Uint8Array(I),W=0;for(let n of F)H.set(n,W),W+=n.length;return H}function findGzipMemberEnd(n){let a=new me.ZlibDecompressor({format:me.ZlibCompressorFormat.GZIP}),S=new Uint8Array(65536),C=0,N=!1;for(;!N;){let F=n.subarray(C);try{let[n,I]=a.convert(F,S,me.ConverterFlags.NONE);C+=I,n===me.ConverterResult.FINISHED&&(N=!0)}catch{N=!0}}return C}function decompressWithGio(n,a){if(a!==`gzip`)return decompressStreamWithGio(n,a);let S=[],C=0;for(;C<n.length&&!(n.length-C<2||n[C]!==31||n[C+1]!==139);){let a=n.subarray(C),N=findGzipMemberEnd(a);if(N<=0)break;let F=decompressStreamWithGio(a.subarray(0,N),`gzip`);S.push(F),C+=N}if(S.length===0)return decompressStreamWithGio(n,`gzip`);let N=S.reduce((n,a)=>n+a.length,0),F=new Uint8Array(N),I=0;for(let n of S)F.set(n,I),I+=n.length;return F}async function runWebTransform(n,a){let S=new ReadableStream({start(a){a.enqueue(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),a.close()}}),C=[],N=S.pipeThrough(a).getReader();for(;;){let{done:n,value:a}=await N.read();if(n)break;C.push(a)}let F=C.reduce((n,a)=>n+a.length,0),I=new Uint8Array(F),H=0;for(let n of C)I.set(n,H),H+=n.length;return I}async function compressWithWeb(n,a){return runWebTransform(n,new CompressionStream(a))}async function decompressWithWeb(n,a){return runWebTransform(n,new DecompressionStream(a))}async function compress(n,a){return li?compressWithWeb(n,a):compressWithGio(n,a)}async function decompress(n,a){return li?decompressWithWeb(n,a):decompressWithGio(n,a)}function toUint8Array$1(n){return typeof n==`string`?new TextEncoder().encode(n):n instanceof ArrayBuffer?new Uint8Array(n):n}function gzip$1(n,a,S){let C=typeof a==`function`?a:S;compress(toUint8Array$1(n),`gzip`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function gunzip$1(n,a,S){let C=typeof a==`function`?a:S;decompress(toUint8Array$1(n),`gzip`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function deflate(n,a,S){let C=typeof a==`function`?a:S;compress(toUint8Array$1(n),`deflate`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function inflate(n,a,S){let C=typeof a==`function`?a:S;decompress(toUint8Array$1(n),`deflate`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function deflateRaw(n,a,S){let C=typeof a==`function`?a:S;compress(toUint8Array$1(n),`deflate-raw`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function inflateRaw(n,a,S){let C=typeof a==`function`?a:S;decompress(toUint8Array$1(n),`deflate-raw`).then(n=>C(null,n),n=>C(n instanceof Error?n:Error(String(n)),new Uint8Array))}function gzipSync(n,a){return compressWithGio(toUint8Array$1(n),`gzip`)}function gunzipSync(n,a){return decompressWithGio(toUint8Array$1(n),`gzip`)}function deflateSync(n,a){return compressWithGio(toUint8Array$1(n),`deflate`)}function inflateSync(n,a){return decompressWithGio(toUint8Array$1(n),`deflate`)}function deflateRawSync(n,a){return compressWithGio(toUint8Array$1(n),`deflate-raw`)}function inflateRawSync(n,a){return decompressWithGio(toUint8Array$1(n),`deflate-raw`)}function brotliCompress(n,a,S){(typeof a==`function`?a:S)(Error(`brotliCompress: Brotli is not supported in this environment`),di)}function brotliDecompress(n,a,S){(typeof a==`function`?a:S)(Error(`brotliDecompress: Brotli is not supported in this environment`),di)}function brotliCompressSync(n,a){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(n,a){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}function zstdCompress(n,a,S){let C=typeof a==`function`?a:S,N=Error(`zstdCompress: Zstd is not supported in this environment`);N.code=`ERR_UNSUPPORTED_OPERATION`,C(N,di)}function zstdDecompress(n,a,S){let C=typeof a==`function`?a:S,N=Error(`zstdDecompress: Zstd is not supported in this environment`);N.code=`ERR_UNSUPPORTED_OPERATION`,C(N,di)}function zstdCompressSync(n,a){let S=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw S.code=`ERR_UNSUPPORTED_OPERATION`,S}function zstdDecompressSync(n,a){let S=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw S.code=`ERR_UNSUPPORTED_OPERATION`,S}var li,di,fi,pi,mi=__esmMin(()=>{si(),he(),se(),li=globalThis.CompressionStream!==void 0,__name$1(toUint8Array$1,`toUint8Array`),__name$1(gzip$1,`gzip`),__name$1(gunzip$1,`gunzip`),di=new Uint8Array,fi={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_DEFLATED:8},pi={gzip:gzip$1,gunzip:gunzip$1,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,Unzip,BrotliCompress,BrotliDecompress,ZstdCompress,ZstdDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createUnzip,createBrotliCompress,createBrotliDecompress,createZstdCompress,createZstdDecompress,constants:fi}});const hi=new Set([`gzip`,`deflate`,`deflate-raw`]);function validateFormat(n){if(!hi.has(n))throw TypeError(`Unsupported compression format: '${n}'. Supported formats: 'gzip', 'deflate', 'deflate-raw'.`);return n}const gi=typeof globalThis.CompressionStream==`function`&&typeof globalThis.DecompressionStream==`function`;let _i=!1,vi,yi,bi,xi,Si,Ci;async function loadZlib(){if(_i)return;let n=await Promise.resolve().then(()=>(mi(),ci));vi=n.gzipSync,yi=n.gunzipSync,bi=n.deflateSync,xi=n.inflateSync,Si=n.deflateRawSync,Ci=n.inflateRawSync,_i=!0}function getCompressFn(n){switch(n){case`gzip`:return n=>vi(n);case`deflate`:return n=>bi(n);case`deflate-raw`:return n=>Si(n)}}function getDecompressFn(n){switch(n){case`gzip`:return n=>yi(n);case`deflate`:return n=>xi(n);case`deflate-raw`:return n=>Ci(n)}}function concatChunks$1(n){if(n.length===1)return n[0];let a=0;for(let S of n)a+=S.length;let S=new Uint8Array(a),C=0;for(let a of n)S.set(a,C),C+=a.length;return S}__name$1(concatChunks$1,`concatChunks`);let wi,Ti;if(gi)wi=globalThis.CompressionStream,Ti=globalThis.DecompressionStream;else{let n=loadZlib();wi=class CompressionStream{readable;writable;constructor(a){let S=validateFormat(a),C=[],N=new Or({transform(n){C.push(n)},async flush(a){try{await n;let N=getCompressFn(S)(concatChunks$1(C));N.length>0&&a.enqueue(N)}catch(n){a.error(n)}}});this.readable=N.readable,this.writable=N.writable}},Ti=class DecompressionStream{readable;writable;constructor(a){let S=validateFormat(a),C=[],N=new Or({transform(n){C.push(n)},async flush(a){try{await n;let N=getDecompressFn(S)(concatChunks$1(C));N.length>0&&a.enqueue(N)}catch(n){a.error(n)}}});this.readable=N.readable,this.writable=N.writable}}}const Ei=globalThis;globalThis.CompressionStream===void 0&&(Ei.CompressionStream=wi),globalThis.DecompressionStream===void 0&&(Ei.DecompressionStream=Ti);const Di=globalThis;globalThis.DOMException===void 0&&(Di.DOMException=Q);var Oi,__name,ki=__esmMin(()=>{Oi=Object.defineProperty,__name=(n,a)=>Oi(n,`name`,{value:a,configurable:!0})}),Ai=S;function validateHeaderName(n){if(typeof n!=`string`||!/^[\^`\-\w!#$%&'*+.|~]+$/.test(n)){let a=TypeError(`Header name must be a valid HTTP token ["${n}"]`);throw Object.defineProperty(a,"code",{value:`ERR_INVALID_HTTP_TOKEN`}),a}}function validateHeaderValue(n,a){if(a===void 0){let a=TypeError(`Header "${n}" value must not be undefined`);throw Object.defineProperty(a,"code",{value:`ERR_HTTP_INVALID_HEADER_VALUE`}),a}if(typeof a==`string`&&/[^\t -~-ÿ]/.test(a)){let a=TypeError(`Invalid character in header content ["${n}"]`);throw Object.defineProperty(a,"code",{value:`ERR_INVALID_CHAR`}),a}}const ji=Symbol(`Headers.headers`);function isBoxedPrimitive$2(n){return n instanceof String||n instanceof Number||n instanceof Boolean||typeof Symbol<`u`&&n instanceof Symbol||typeof BigInt<`u`&&n instanceof BigInt}__name$1(isBoxedPrimitive$2,`isBoxedPrimitive`);var Mi=class Headers{[ji];constructor(n){if(this[ji]=new Map,n!=null){if(n instanceof Headers){for(let[a,S]of n[ji])this[ji].set(a,[...S]);return}if(typeof n==`object`&&!isBoxedPrimitive$2(n)){let a=n[Symbol.iterator];if(a==null)for(let[a,S]of Object.entries(n))validateHeaderName(a),validateHeaderValue(a,String(S)),this.append(a,String(S));else{if(typeof a!=`function`)throw TypeError(`Header pairs must be iterable`);for(let a of n){if(typeof a!=`object`||isBoxedPrimitive$2(a))throw TypeError(`Each header pair must be an iterable object`);let n=[...a];if(n.length!==2)throw TypeError(`Each header pair must be a name/value tuple`);validateHeaderName(n[0]),validateHeaderValue(n[0],String(n[1])),this.append(n[0],String(n[1]))}}}else throw TypeError(`Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)'`)}}append(n,a){validateHeaderName(n),validateHeaderValue(n,a);let S=String(n).toLowerCase(),C=String(a),N=this[ji].get(S);N?N.push(C):this[ji].set(S,[C])}set(n,a){validateHeaderName(n),validateHeaderValue(n,a);let S=String(n).toLowerCase();this[ji].set(S,[String(a)])}delete(n){this[ji].delete(String(n).toLowerCase())}has(n){return this[ji].has(String(n).toLowerCase())}get(n){let a=this[ji].get(String(n).toLowerCase());if(!a||a.length===0)return null;let S=a.join(`, `);return/^content-encoding$/i.test(n)&&(S=S.toLowerCase()),S}getAll(n){return this[ji].get(String(n).toLowerCase())??[]}getSetCookie(){return this[ji].get(`set-cookie`)??[]}forEach(n,a){for(let S of this.keys())Reflect.apply(n,a,[this.get(S),S,this])}*keys(){let n=[...this[ji].keys()].sort(),a=new Set;for(let S of n)a.has(S)||(a.add(S),yield S)}*values(){for(let n of this.keys())yield this.get(n)}*entries(){for(let n of this.keys())yield[n,this.get(n)]}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`Headers`}toString(){return Object.prototype.toString.call(this)}raw(){let n={};for(let a of this.keys())n[a]=this.getAll(a);return n}_appendToSoupMessage(n,a=Ai.MessageHeadersType.REQUEST){let S=n?n.get_request_headers():new Ai.MessageHeaders(a);for(let[n,a]of this.entries())S.append(n,a);return S}static _newFromSoupMessage(n,a=Ai.MessageHeadersType.RESPONSE){let S=new Headers,C;return C=a===Ai.MessageHeadersType.RESPONSE?n.get_response_headers():n.get_request_headers(),C.foreach((n,a)=>{S.append(n,a)}),S}[Symbol.for(`nodejs.util.inspect.custom`)](){let n={};for(let a of this.keys()){let S=this.getAll(a);a===`host`?n[a]=S[0]:n[a]=S.length>1?S:S[0]}return n}};Object.defineProperties(Mi.prototype,[`get`,`entries`,`forEach`,`values`].reduce((n,a)=>(n[a]={enumerable:!0},n),{}));var Ni=__esmMin(()=>{vt()});Ni();var FetchBaseError=class extends Error{type;constructor(n,a){super(n),typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,this.constructor),this.type=a}get name(){return this.constructor.name}get[Symbol.toStringTag](){return this.constructor.name}},FetchError=class extends FetchBaseError{code;errno;erroredSysCall;constructor(n,a,S){super(n,a),S&&(this.code=this.errno=S.code,this.erroredSysCall=S.syscall)}};mn();const Pi=Symbol.toStringTag,isURLSearchParameters=n=>typeof n==`object`&&typeof n.append==`function`&&typeof n.delete==`function`&&typeof n.get==`function`&&typeof n.getAll==`function`&&typeof n.has==`function`&&typeof n.set==`function`&&typeof n.sort==`function`&&n[Pi]===`URLSearchParams`,isBlob=n=>{if(!n||typeof n!=`object`)return!1;let a=n;return typeof a.arrayBuffer==`function`&&typeof a.type==`string`&&typeof a.stream==`function`&&typeof a.constructor==`function`&&/^(Blob|File)$/.test(a[Pi])},isAbortSignal=n=>{if(typeof n!=`object`||!n)return!1;let a=n;return a[Pi]===`AbortSignal`||a[Pi]===`EventTarget`},isDomainOrSubdomain=(n,a)=>{let S=new fn(a).hostname,C=new fn(n).hostname;return S===C||S.endsWith(`.${C}`)},isSameProtocol=(n,a)=>new fn(a).protocol===new fn(n).protocol;var $,Fi,File,Ii=__esmMin(()=>{$=Symbol(`File.name`),Fi=Symbol(`File.lastModified`),File=class extends Blob{[$];[Fi];webkitRelativePath=``;constructor(n,a,S){super(n,S),this[$]=String(a),this[Fi]=S?.lastModified??Date.now()}get name(){return this[$]}get lastModified(){return this[Fi]}get[Symbol.toStringTag](){return`File`}}});function generateBoundary(){let n=`----formdata-`;for(let a=0;a<24;a++)n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(Math.floor(Math.random()*62));return n}function escape(n){return n.replace(/\n/g,`%0A`).replace(/\r/g,`%0D`).replace(/"/g,`%22`)}function formDataToBlob(n,a){a??=generateBoundary();let S=[],C=`--${a}\r\nContent-Disposition: form-data; name="`;for(let[a,N]of n.entries())if(typeof N==`string`)S.push(`${C}${escape(a)}"\r\n\r\n${N.replace(/\r(?!\n)|(?<!\r)\n/g,`\r
|
|
7
7
|
`)}\r\n`);else{let n=N instanceof File?N:new File([N],`blob`,{type:N.type});S.push(`${C}${escape(a)}"; filename="${escape(n.name)}"\r\nContent-Type: ${n.type||`application/octet-stream`}\r\n\r\n`),S.push(n),S.push(`\r
|
|
8
8
|
`)}return S.push(`--${a}--`),new Blob(S,{type:`multipart/form-data; boundary=${a}`})}var Li=__esmMin(()=>{Ii()});function normalizeValue(n,a,S){return typeof a==`string`?a:(a instanceof Blob&&!(a instanceof File)&&(a=new File([a],S??`blob`,{type:a.type})),a instanceof File&&S!==void 0&&(a=new File([a],S,{type:a.type,lastModified:a.lastModified})),a)}var Ri,FormData,zi=__esmMin(()=>{Ii(),Ri=Symbol(`FormData.entries`),FormData=class{[Ri]=[];constructor(){}append(n,a,S){this[Ri].push({name:String(n),value:normalizeValue(n,a,S)})}delete(n){let a=String(n);this[Ri]=this[Ri].filter(n=>n.name!==a)}get(n){let a=String(n),S=this[Ri].find(n=>n.name===a);return S?S.value:null}getAll(n){let a=String(n);return this[Ri].filter(n=>n.name===a).map(n=>n.value)}has(n){let a=String(n);return this[Ri].some(n=>n.name===a)}set(n,a,S){let C=String(n),N=normalizeValue(C,a,S),F=!1;this[Ri]=this[Ri].filter(n=>n.name===C?F?!1:(F=!0,n.value=N,!0):!0),F||this[Ri].push({name:C,value:N})}forEach(n,a){for(let S of this[Ri])n.call(a,S.value,S.name,this)}*entries(){for(let n of this[Ri])yield[n.name,n.value]}*keys(){for(let n of this[Ri])yield n.name}*values(){for(let n of this[Ri])yield n.value}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return`FormData`}}}),Bi=__esmMin(()=>{Li(),zi()}),Vi=__exportAll$3({toFormData:()=>toFormData});function _fileName(n){let a=n.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!a)return;let S=a[2]||a[3]||``,C=S.slice(S.lastIndexOf(`\\`)+1);return C=C.replace(/%22/g,`"`),C=C.replace(/&#(\d{4});/g,(n,a)=>String.fromCharCode(a)),C}async function toFormData(n,a){if(!/multipart/i.test(a))throw TypeError(`Failed to fetch`);let S=a.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!S)throw TypeError(`no or bad content-type header, no multipart boundary`);let C=new MultipartParser(S[1]||S[2]),N,F,I,H,W,K,q=[],Y=new FormData,onPartData=n=>{I+=X.decode(n,{stream:!0})},appendToFile=n=>{q.push(n)},appendFileToFormData=()=>{let n=new te(q,K,{type:W});Y.append(H,n)},appendEntryToFormData=()=>{Y.append(H,I)},X=new TextDecoder(`utf-8`);X.decode(),C.onPartBegin=function(){C.onPartData=onPartData,C.onPartEnd=appendEntryToFormData,N=``,F=``,I=``,H=``,W=``,K=null,q.length=0},C.onHeaderField=function(n){N+=X.decode(n,{stream:!0})},C.onHeaderValue=function(n){F+=X.decode(n,{stream:!0})},C.onHeaderEnd=function(){if(F+=X.decode(),N=N.toLowerCase(),N===`content-disposition`){let n=F.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);n&&(H=n[2]||n[3]||``),K=_fileName(F),K&&(C.onPartData=appendToFile,C.onPartEnd=appendFileToFormData)}else N===`content-type`&&(W=F);F=``,N=``};for await(let a of n)C.write(a);return C.end(),Y}var Hi,Ui,Wi,lower,Gi,MultipartParser,Ki=__esmMin(()=>{Bi(),Hi=function(n){return n[n.START_BOUNDARY=0]=`START_BOUNDARY`,n[n.HEADER_FIELD_START=1]=`HEADER_FIELD_START`,n[n.HEADER_FIELD=2]=`HEADER_FIELD`,n[n.HEADER_VALUE_START=3]=`HEADER_VALUE_START`,n[n.HEADER_VALUE=4]=`HEADER_VALUE`,n[n.HEADER_VALUE_ALMOST_DONE=5]=`HEADER_VALUE_ALMOST_DONE`,n[n.HEADERS_ALMOST_DONE=6]=`HEADERS_ALMOST_DONE`,n[n.PART_DATA_START=7]=`PART_DATA_START`,n[n.PART_DATA=8]=`PART_DATA`,n[n.END=9]=`END`,n}(Hi||{}),Ui=1,Wi={PART_BOUNDARY:Ui,LAST_BOUNDARY:Ui*=2},lower=n=>n|32,Gi=__name$1((...n)=>{},`noop`),MultipartParser=class{index=0;flags=0;boundary;lookbehind;state=0;onHeaderEnd=Gi;onHeaderField=Gi;onHeadersEnd=Gi;onHeaderValue=Gi;onPartBegin=Gi;onPartData=Gi;onPartEnd=Gi;boundaryChars={};constructor(n){n=`\r
|
|
9
9
|
--`+n;let a=new Uint8Array(n.length);for(let S=0;S<n.length;S++)a[S]=n.charCodeAt(S),this.boundaryChars[a[S]]=!0;this.boundary=a,this.lookbehind=new Uint8Array(this.boundary.length+8)}write(n){let a=0,S=n.length,C=this.index,{lookbehind:N,boundary:F,boundaryChars:I,index:H,state:W,flags:K}=this,q=this.boundary.length,Y=q-1,X=n.length,te,ne,mark=n=>{this[n+`Mark`]=a},clear=n=>{delete this[n+`Mark`]},callback=(n,a,S,C)=>{(a===void 0||a!==S)&&this[n](C&&C.subarray(a,S))},dataCallback=(S,C=!1)=>{let N=S+`Mark`;N in this&&(C?(callback(S,this[N],a,n),delete this[N]):(callback(S,this[N],n.length,n),this[N]=0))};for(a=0;a<S;a++)switch(te=n[a],W){case 0:if(H===F.length-2){if(te===45)K|=Wi.LAST_BOUNDARY;else if(te!==13)return;H++;break}else if(H-1==F.length-2){if(K&Wi.LAST_BOUNDARY&&te===45)W=9,K=0;else if(!(K&Wi.LAST_BOUNDARY)&&te===10)H=0,callback(`onPartBegin`),W=1;else return;break}te!==F[H+2]&&(H=-2),te===F[H+2]&&H++;break;case 1:W=2,mark(`onHeaderField`),H=0;case 2:if(te===13){clear(`onHeaderField`),W=6;break}if(H++,te===45)break;if(te===58){if(H===1)return;dataCallback(`onHeaderField`,!0),W=3;break}if(ne=lower(te),ne<97||ne>122)return;break;case 3:if(te===32)break;mark(`onHeaderValue`),W=4;case 4:te===13&&(dataCallback(`onHeaderValue`,!0),callback(`onHeaderEnd`),W=5);break;case 5:if(te!==10)return;W=1;break;case 6:if(te!==10)return;callback(`onHeadersEnd`),W=7;break;case 7:W=8,mark(`onPartData`);case 8:if(C=H,H===0){for(a+=Y;a<X&&!(n[a]in I);)a+=q;a-=Y,te=n[a]}if(H<F.length)F[H]===te?(H===0&&dataCallback(`onPartData`,!0),H++):H=0;else if(H===F.length)H++,te===13?K|=Wi.PART_BOUNDARY:te===45?K|=Wi.LAST_BOUNDARY:H=0;else if(H-1===F.length)if(K&Wi.PART_BOUNDARY){if(H=0,te===10){K&=~Wi.PART_BOUNDARY,callback(`onPartEnd`),callback(`onPartBegin`),W=1;break}}else K&Wi.LAST_BOUNDARY&&te===45?(callback(`onPartEnd`),W=9,K=0):H=0;if(H>0)N[H-1]=te;else if(C>0){let n=new Uint8Array(N.buffer,N.byteOffset,N.byteLength);callback(`onPartData`,0,C,n),C=0,mark(`onPartData`),a--}break;case 9:break;default:throw Error(`Unexpected state entered: ${W}`)}dataCallback(`onHeaderField`),dataCallback(`onHeaderValue`),dataCallback(`onPartData`),this.index=H,this.state=W,this.flags=K}end(){if(this.state===1&&this.index===0||this.state===8&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==9)throw Error(`MultipartParser.end(): stream ended unexpectedly`)}}});Ae(),ki(),Ni(),mn(),vt(),oi(),Bi(),__name((n,a)=>new Promise((S,C)=>{pipeline(n,a,n=>{n?C(n):S()})}),`pipeline`);const qi=Symbol(`Body internals`);function isAnyArrayBuffer$2(n){return n instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&n instanceof SharedArrayBuffer}__name$1(isAnyArrayBuffer$2,`isAnyArrayBuffer`);var Body=class{[qi]={body:null,stream:null,boundary:``,disturbed:!1,error:null};size=0;constructor(n,a={size:0}){if(this.size=a.size||0,n==null)this[qi].body=null;else if(isURLSearchParameters(n))this[qi].body=lt.from(n.toString());else if(isBlob(n))this[qi].body=n;else if(lt.isBuffer(n))this[qi].body=n;else if(isAnyArrayBuffer$2(n))this[qi].body=lt.from(n);else if(ArrayBuffer.isView(n))this[qi].body=lt.from(n.buffer,n.byteOffset,n.byteLength);else if(n instanceof ei)this[qi].body=n;else if(typeof ReadableStream<`u`&&n instanceof ReadableStream)this[qi].body=readableStreamToReadable(n);else if(n instanceof FormData){let a=formDataToBlob(n);this[qi].body=a,this[qi].boundary=a.type?.split(`boundary=`)?.[1]??``}else typeof n==`string`?this[qi].body=lt.from(n):n instanceof dn?this[qi].body=lt.from(n.toString()):(ke.warn(`Unknown body type "${typeof n}", try to parse the body to string!`),this[qi].body=lt.from(String(n)));let S=this[qi].body;lt.isBuffer(S)?this[qi].stream=ei.from(S):isBlob(S)?this[qi].stream=ei.from(blobToAsyncIterable(S)):S instanceof ei&&(this[qi].stream=S),S instanceof $r&&S.on(`error`,n=>{let a=n instanceof FetchBaseError?n:new FetchError(`Invalid response body while trying to fetch ${this.url}: ${n.message}`,`system`,n);this[qi].error=a})}get body(){let n=this[qi].stream;if(!n)return null;if(typeof ReadableStream<`u`){let a=!1;return new ReadableStream({start(S){n.on(`data`,n=>{if(!a)try{S.enqueue(n instanceof Uint8Array?n:new Uint8Array(n))}catch{}}),n.on(`end`,()=>{if(!a){a=!0;try{S.close()}catch{}}}),n.on(`error`,n=>{if(!a){a=!0;try{S.error(n)}catch{}}})},cancel(){a=!0,n.destroy()}})}return null}get _stream(){return this[qi].stream}get _rawBodyBuffer(){let n=this[qi].body;return n===null?null:lt.isBuffer(n)?n:n instanceof Uint8Array?lt.from(n.buffer,n.byteOffset,n.byteLength):null}get bodyUsed(){return this[qi].disturbed}async arrayBuffer(){let{buffer:n,byteOffset:a,byteLength:S}=await consumeBody(this);return n.slice(a,a+S)}async formData(){let n=this.headers?.get(`content-type`);if(n?.startsWith(`application/x-www-form-urlencoded`)){let n=new FormData,a=new dn(await this.text());for(let[S,C]of a)n.append(S,C);return n}let{toFormData:a}=await Promise.resolve().then(()=>(Ki(),Vi));return a(this.body,n)}async blob(){let n=this.headers?.get(`content-type`)||this[qi].body&&this[qi].body.type||``;return new X([await this.arrayBuffer()],{type:n})}async json(){let n=await this.text();return JSON.parse(n)}async text(){let n=await consumeBody(this);return new TextDecoder().decode(n)}};Object.defineProperties(Body.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}});async function consumeBody(n){if(n[qi].disturbed)throw TypeError(`body used already for: ${n.url}`);if(n[qi].disturbed=!0,n[qi].error)throw n[qi].error;let{_stream:a}=n;if(a===null||!(a instanceof $r))return lt.alloc(0);let S=[],C=0;try{for await(let N of a){if(n.size>0&&C+N.length>n.size){let S=new FetchError(`content size at ${n.url} over limit: ${n.size}`,`max-size`);throw a.destroy(S),S}C+=N.length,S.push(N)}}catch(a){let S=a instanceof Error?a:Error(String(a));throw a instanceof FetchBaseError?a:new FetchError(`Invalid response body while trying to fetch ${n.url}: ${S.message}`,`system`,S)}try{return S.every(n=>typeof n==`string`)?lt.from(S.join(``)):lt.concat(S,C)}catch(a){let S=a instanceof Error?a:Error(String(a));throw new FetchError(`Could not create Buffer from response body for ${n.url}: ${S.message}`,`system`,S)}}const clone=(n,a)=>{let S,C,{body:N}=n[qi];if(n.bodyUsed)throw Error(`cannot clone body after it is used`);return N instanceof $r&&typeof N.getBoundary!=`function`&&(S=new ii({highWaterMark:a}),C=new ii({highWaterMark:a}),N.pipe(S),N.pipe(C),n[qi].stream=S,N=C),N},extractContentType=(n,a)=>n===null?null:typeof n==`string`?`text/plain;charset=UTF-8`:isURLSearchParameters(n)?`application/x-www-form-urlencoded;charset=UTF-8`:isBlob(n)?n.type||null:lt.isBuffer(n)||isAnyArrayBuffer$2(n)||ArrayBuffer.isView(n)?null:n instanceof FormData?`multipart/form-data; boundary=${a[qi].boundary}`:n instanceof $r?null:`text/plain;charset=UTF-8`,getTotalBytes=n=>{let{body:a}=n[qi];if(a===null)return 0;if(isBlob(a))return a.size;if(lt.isBuffer(a))return a.length;if(a&&typeof a.getLengthSync==`function`){let n=a;return n.hasKnownLength&&n.hasKnownLength()?n.getLengthSync():null}return null};function readableStreamToReadable(n){let a=n.getReader();return new ei({async read(){try{let{done:n,value:S}=await a.read();n?this.push(null):this.push(lt.from(S))}catch(n){this.destroy(n)}},destroy(n,S){a.cancel().then(()=>S(null),S)}})}async function*blobToAsyncIterable(n){if(typeof n.stream==`function`){let a=n.stream().getReader();for(;;){let{done:n,value:S}=await a.read();if(n)break;yield S}}else yield new Uint8Array(await n.arrayBuffer())}const Ji=new Set([301,302,303,307,308]),isRedirect=n=>Ji.has(n);mn(),se(),he();const Yi=Symbol(`Response internals`);var Xi=class Response extends Body{[Yi];_inputStream=null;constructor(n=null,a={}){super(n,a);let S=a.status==null?200:a.status,C=new Mi(a.headers);if(n!==null&&!C.has(`Content-Type`)){let a=extractContentType(n,this);a&&C.append(`Content-Type`,a)}this[Yi]={type:`default`,url:a.url,status:S,statusText:a.statusText||``,headers:C,counter:a.counter,highWaterMark:a.highWaterMark}}get type(){return this[Yi].type}get url(){return this[Yi].url||``}get status(){return this[Yi].status}get ok(){return this[Yi].status>=200&&this[Yi].status<300}get redirected(){return this[Yi].counter>0}get statusText(){return this[Yi].statusText}get headers(){return this[Yi].headers}get highWaterMark(){return this[Yi].highWaterMark}clone(){return new Response(clone(this,this.highWaterMark),{type:this.type,url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected,size:this.size,highWaterMark:this.highWaterMark})}static redirect(n,a=302){if(!isRedirect(a))throw RangeError(`Failed to execute "redirect" on "response": Invalid status code`);return new Response(null,{headers:{location:new fn(n).toString()},status:a})}static error(){let n=new Response(null,{status:0,statusText:``});return n[Yi].type=`error`,n}static json(n,a){let S=JSON.stringify(n),C={...a},N=new Mi(C.headers);return N.has(`content-type`)||N.set(`content-type`,`application/json`),C.headers=N,new Response(S,C)}get[Symbol.toStringTag](){return`Response`}async text(){if(!this._inputStream)return super.text();let n=me.MemoryOutputStream.new_resizable();await new Promise((a,S)=>{n.splice_async(this._inputStream,me.OutputStreamSpliceFlags.CLOSE_TARGET|me.OutputStreamSpliceFlags.CLOSE_SOURCE,Z.PRIORITY_DEFAULT,null,(C,N)=>{try{a(n.splice_finish(N))}catch(n){S(n)}})});let a=n.steal_as_bytes();return new TextDecoder().decode(a.toArray())}};Object.defineProperties(Xi.prototype,{type:{enumerable:!0},url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}}),oi(),se(),Xe();async function soupSendAsync(n,a,S=Z.PRIORITY_DEFAULT,C=null){return new Promise((N,F)=>{n.send_async(a,S,C,(a,S)=>{try{N(n.send_finish(S))}catch(n){F(n)}})})}function inputStreamToReadable(n,a={}){return ei.from(inputStreamAsyncIterator(n),a)}he(),se(),oi(),Xe(),he(),Xe(),Kt(),he();function isIP(n){if(typeof n!=`string`)return 0;let a=n.includes(`%`)?n.split(`%`)[0]:n,S=me.InetAddress.new_from_string(a);if(!S)return 0;switch(S.get_family()){case me.SocketFamily.INVALID:return 0;case me.SocketFamily.IPV4:return 4;case me.SocketFamily.IPV6:return 6}}mn();function stripURLForUseAsAReferrer(n,a=!1){if(n==null||n===`no-referrer`)return`no-referrer`;let S=new fn(n);return/^(about|blob|data):$/.test(S.protocol)?`no-referrer`:(S.username=``,S.password=``,S.hash=``,a&&(S.pathname=``,S.search=``),S)}const Zi=new Set([``,`no-referrer`,`no-referrer-when-downgrade`,`same-origin`,`origin`,`strict-origin`,`origin-when-cross-origin`,`strict-origin-when-cross-origin`,`unsafe-url`]);function validateReferrerPolicy(n){if(!Zi.has(n))throw TypeError(`Invalid referrerPolicy: ${n}`);return n}function isOriginPotentiallyTrustworthy(n){if(/^(http|ws)s:$/.test(n.protocol))return!0;let a=n.host.replace(/(^\[)|(]$)/g,``),S=isIP(a);return S===4&&a.startsWith(`127.`)||S===6&&/^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(a)?!0:n.host===`localhost`||n.host.endsWith(`.localhost`)?!1:n.protocol===`file:`}function isUrlPotentiallyTrustworthy(n){return/^about:(blank|srcdoc)$/.test(n.toString())||(typeof n==`string`&&(n=new fn(n)),n.protocol===`data:`)||/^(blob|filesystem):$/.test(n.protocol)?!0:isOriginPotentiallyTrustworthy(n)}function determineRequestsReferrer(n,a={}){let{referrerURLCallback:S,referrerOriginCallback:C}=a;if(n.referrer===`no-referrer`||n.referrerPolicy===``)return null;let N=n.referrerPolicy;if(n.referrer===`about:client`)return`no-referrer`;let F=new fn(n.referrer),I=stripURLForUseAsAReferrer(F),H=stripURLForUseAsAReferrer(F,!0);I.toString().length>4096&&(I=H),S&&(I=S(I)),C&&(H=C(H));let W=new fn(n.url);switch(N){case`no-referrer`:return`no-referrer`;case`origin`:return H;case`unsafe-url`:return I;case`strict-origin`:return isUrlPotentiallyTrustworthy(I)&&!isUrlPotentiallyTrustworthy(W)?`no-referrer`:H.toString();case`strict-origin-when-cross-origin`:return I.origin===W.origin?I:isUrlPotentiallyTrustworthy(I)&&!isUrlPotentiallyTrustworthy(W)?`no-referrer`:H;case`same-origin`:return I.origin===W.origin?I:`no-referrer`;case`origin-when-cross-origin`:return I.origin===W.origin?I:H;case`no-referrer-when-downgrade`:return isUrlPotentiallyTrustworthy(I)&&!isUrlPotentiallyTrustworthy(W)?`no-referrer`:I;default:throw TypeError(`Invalid referrerPolicy: ${N}`)}}function parseReferrerPolicyFromHeader(n){let a=(n.get(`referrer-policy`)||``).split(/[,\s]+/),S=``;for(let n of a)n&&Zi.has(n)&&(S=n);return S}mn(),se(),he();const Qi=Symbol(`Request internals`);let $i=null;function envPositiveInt(n,a){let S=Z.getenv(n);if(!S)return a;let C=Number.parseInt(S,10);return Number.isFinite(C)&&C>0?C:a}function getSharedSession(){if($i===null){let n=envPositiveInt(`GJSIFY_FETCH_MAX_CONNS_PER_HOST`,16),a=Math.max(envPositiveInt(`GJSIFY_FETCH_MAX_CONNS`,64),n);$i=new Ai.Session({maxConns:a,maxConnsPerHost:n});try{$i.remove_feature_by_type(Ai.ContentDecoder.$gtype)}catch{}}return $i}const isRequest=n=>typeof n==`object`&&typeof n.url==`string`;var ea=class Request extends Body{cache;credentials;destination;get headers(){return this[Qi].headers}integrity;keepalive;get method(){return this[Qi].method}mode;get redirect(){return this[Qi].redirect}get referrer(){if(this[Qi].referrer===`no-referrer`)return``;if(this[Qi].referrer===`client`)return`about:client`;if(this[Qi].referrer)return this[Qi].referrer.toString()}get referrerPolicy(){return this[Qi].referrerPolicy}set referrerPolicy(n){this[Qi].referrerPolicy=validateReferrerPolicy(n)}get signal(){return this[Qi].signal}get url(){return this[Qi].parsedURL.toString()}get _uri(){return Z.Uri.parse(this.url,Z.UriFlags.ENCODED)}get _session(){return this[Qi].session}get _message(){return this[Qi].message}get _inputStream(){return this[Qi].inputStream}get[Symbol.toStringTag](){return`Request`}[Qi];follow;compress=!1;counter=0;agent=``;highWaterMark=16384;insecureHTTPParser=!1;constructor(n,a){let S=n,C=a||{},N,F={};if(isRequest(n)?(N=new fn(S.url),F=S):N=new fn(n),N.username!==``||N.password!==``)throw TypeError(`${N} is an url with embedded credentials.`);let I=C.method||F.method||`GET`;if(/^(delete|get|head|options|post|put)$/i.test(I)&&(I=I.toUpperCase()),(a?.body!=null||isRequest(n)&&S.body!==null)&&(I===`GET`||I===`HEAD`))throw TypeError(`Request with GET/HEAD method cannot have body`);let H=a?.body?a.body:isRequest(n)&&S.body!==null?clone(n):null;super(H,{size:C.size||0});let W=new Mi(a?.headers||S.headers||{});if(H!==null&&!W.has(`Content-Type`)){let n=extractContentType(H,this);n&&W.set(`Content-Type`,n)}let K=isRequest(n)?S.signal:null;if(a&&`signal`in a&&(K=a.signal),K!=null&&!isAbortSignal(K))throw TypeError(`Expected signal to be an instanceof AbortSignal or EventTarget`);let q=a?.referrer==null?S.referrer:a.referrer;if(q===``)q=`no-referrer`;else if(q){let n=new fn(q);q=/^about:(\/\/)?client$/.test(n.toString())?`client`:n}else q=void 0;let Y=N.protocol,X=null,te=null;(Y===`http:`||Y===`https:`)&&(X=getSharedSession(),te=new Ai.Message({method:I,uri:Z.Uri.parse(N.toString(),Z.UriFlags.ENCODED)})),this[Qi]={method:I,redirect:a?.redirect||S.redirect||`follow`,headers:W,parsedURL:N,signal:K,referrer:q,referrerPolicy:``,session:X,message:te},this.follow=C.follow===void 0?S.follow===void 0?20:S.follow:C.follow,this.compress=C.compress===void 0?S.compress===void 0?!0:S.compress:C.compress,this.counter=C.counter||S.counter||0,this.agent=C.agent||S.agent,this.highWaterMark=C.highWaterMark||S.highWaterMark||16384,this.insecureHTTPParser=C.insecureHTTPParser||S.insecureHTTPParser||!1,this.referrerPolicy=a?.referrerPolicy||S.referrerPolicy||``}async _send(n){let{session:a,message:S}=this[Qi];if(!a||!S)throw Error(`Cannot send request: no Soup session (non-HTTP URL?)`);n.headers._appendToSoupMessage(S);let C=this._rawBodyBuffer;if(C!==null&&C.byteLength>0){let a=n.headers.get(`content-type`)||null;S.set_request_body_from_bytes(a,new Z.Bytes(C))}let N=new me.Cancellable;return this[Qi].inputStream=await soupSendAsync(a,S,Z.PRIORITY_DEFAULT,N),this[Qi].readable=inputStreamToReadable(this[Qi].inputStream),{inputStream:this[Qi].inputStream,readable:this[Qi].readable,cancellable:N}}clone(){return new Request(this)}async arrayBuffer(){return super.arrayBuffer()}async blob(){return super.blob()}async formData(){return super.formData()}async json(){return super.json()}async text(){return super.text()}};Object.defineProperties(ea.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0},referrer:{enumerable:!0},referrerPolicy:{enumerable:!0}});const getSoupRequestOptions=n=>{let{parsedURL:a}=n[Qi],S=new Mi(n[Qi].headers);S.has(`Accept`)||S.set(`Accept`,`*/*`);let C=null;if(n.body===null&&/^(post|put)$/i.test(n.method)&&(C=`0`),n.body!==null){let a=getTotalBytes(n);typeof a==`number`&&!Number.isNaN(a)&&(C=String(a))}C&&S.set(`Content-Length`,C),n.referrerPolicy===``&&(n.referrerPolicy=`strict-origin-when-cross-origin`),n.referrer&&n.referrer!==`no-referrer`?n[Qi].referrer=determineRequestsReferrer(n):n[Qi].referrer=`no-referrer`,n[Qi].referrer instanceof fn&&S.set(`Referer`,n.referrer),S.has(`User-Agent`)||S.set(`User-Agent`,`gjsify-fetch`),n.compress&&!S.has(`Accept-Encoding`)&&S.set(`Accept-Encoding`,`gzip, deflate`);let{agent:N}=n;return typeof N==`function`&&(N=N(a)),!S.has(`Connection`)&&!N&&S.set(`Connection`,`close`),{parsedURL:a,options:{headers:S}}};function parseDataUri(n){let a=n.match(/^data:([^,]*?)(;base64)?,(.*)$/s);if(!a)throw TypeError(`Invalid data URI: ${n.slice(0,50)}...`);let S=a[1]||`text/plain;charset=US-ASCII`,C=!!a[2],N=a[3],F;if(C){let n=atob(N);F=new Uint8Array(n.length);for(let a=0;a<n.length;a++)F[a]=n.charCodeAt(a)}else F=new TextEncoder().encode(decodeURIComponent(N));return{buffer:F,typeFull:S}}var AbortError=class extends FetchBaseError{constructor(n,a=`aborted`){super(n,a)}};Ae(),Ni(),mn(),oi(),se();const ta=new Set([`data:`,`http:`,`https:`,`file:`]);function rewriteRootRelativeUrl(n){if(typeof n!=`string`||!n.startsWith(`/`)||n.startsWith(`//`))return n;let a=globalThis,S=a.__GJSIFY_DEBUG_FETCH===!0;try{let C=a.imports?.system?.programPath??a.imports?.system?.programInvocationName??``;if(!C)return n;let N=`file://${Z.path_get_dirname(C)}${n}`;return S&&ke.log(`[fetch] rewrite ${n} → ${N}`),N}catch(a){return S&&ke.warn(`[fetch] rewrite FAILED: ${a instanceof Error?a.message:String(a)}`),n}}async function fetch$1(n,a={}){n=rewriteRootRelativeUrl(n);let S=new ea(n,a),{parsedURL:C,options:N}=getSoupRequestOptions(S);if(!ta.has(C.protocol))throw TypeError(`@gjsify/fetch cannot load ${n}. URL scheme "${C.protocol.replace(/:$/,``)}" is not supported.`);if(C.protocol===`data:`){let{buffer:n,typeFull:a}=parseDataUri(S.url);return new Xi(Buffer.from(n),{headers:{"Content-Type":a}})}if(C.protocol===`file:`){let n=globalThis.__GJSIFY_DEBUG_FETCH===!0;n&&ke.log(`[fetch] file:// ${S.url}`);try{let a=Z.filename_from_uri(S.url)[0];n&&ke.log(`[fetch] file:// path=${a}`);let[C,N]=Z.file_get_contents(a);if(n&&ke.log(`[fetch] file:// ok=${C} bytes=${N?.byteLength??`?`}`),!C)throw new FetchError(`Failed to read file: ${a}`,`system`);let F=N,I=new Uint8Array(F.byteLength);I.set(F);let H=new Xi(I);return n&&ke.log(`[fetch] file:// response created`),H}catch(a){let C=a instanceof Error?a:Error(String(a));throw n&&ke.warn(`[fetch] file:// FAIL: ${C.message}`),new FetchError(`request to ${S.url} failed, reason: ${C.message}`,`system`,C)}}let{signal:F}=S;if(F&&F.aborted)throw new AbortError(`The operation was aborted.`);let I,H;try{let n=await S._send(N);I=n.readable,H=n.cancellable}catch(n){let a=n instanceof Error?n:Error(String(n));throw new FetchError(`request to ${S.url} failed, reason: ${a.message}`,`system`,a)}let abortHandler=()=>{H.cancel()};F&&F.addEventListener(`abort`,abortHandler,{once:!0});let finalize=()=>{F&&F.removeEventListener(`abort`,abortHandler)};H.connect(()=>{I.destroy(new AbortError(`The operation was aborted.`))}),I.on(`error`,n=>{finalize()});let W=S._message,K=Mi._newFromSoupMessage(W),q=W.status_code,Y=W.get_reason_phrase();if(isRedirect(q)){let n=K.get(`Location`),C=null;try{C=n===null?null:new fn(n,S.url)}catch{if(S.redirect!==`manual`)throw finalize(),new FetchError(`uri requested responds with an invalid redirect URL: ${n}`,`invalid-redirect`)}switch(S.redirect){case`error`:throw finalize(),new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${S.url}`,`no-redirect`);case`manual`:break;case`follow`:{if(C===null)break;if(S.counter>=S.follow)throw finalize(),new FetchError(`maximum redirect reached at: ${S.url}`,`max-redirect`);let n={headers:new Mi(S.headers),follow:S.follow,counter:S.counter+1,agent:S.agent,compress:S.compress,method:S.method,body:clone(S),signal:S.signal,size:S.size,referrer:S.referrer,referrerPolicy:S.referrerPolicy};if(!isDomainOrSubdomain(S.url,C)||!isSameProtocol(S.url,C))for(let a of[`authorization`,`www-authenticate`,`cookie`,`cookie2`])n.headers.delete(a);if(q!==303&&S.body&&a.body instanceof ai.Readable)throw finalize(),new FetchError(`Cannot follow redirect with body being a readable stream`,`unsupported-redirect`);(q===303||(q===301||q===302)&&S.method===`POST`)&&(n.method=`GET`,n.body=void 0,n.headers.delete(`content-length`));let N=parseReferrerPolicyFromHeader(K);return N&&(n.referrerPolicy=N),finalize(),fetch$1(new ea(C,n))}default:throw TypeError(`Redirect option '${S.redirect}' is not a valid value of RequestRedirect`)}}let te={url:S.url,status:q,statusText:Y,headers:K,size:S.size,counter:S.counter,highWaterMark:S.highWaterMark},ne=K.get(`Content-Encoding`);if(!S.compress||S.method===`HEAD`||ne===null||q===204||q===304)return finalize(),new Xi(I,te);if(typeof DecompressionStream<`u`){let n=null;if(ne===`gzip`||ne===`x-gzip`?n=`gzip`:(ne===`deflate`||ne===`x-deflate`)&&(n=`deflate`),n){let a=new X([await new Xi(I,te).arrayBuffer()]).stream().pipeThrough(new DecompressionStream(n));return finalize(),new Xi(a,te)}}return finalize(),new Xi(I,te)}__name$1(fetch$1,`fetch`);const na=globalThis;globalThis.fetch===void 0&&(na.fetch=fetch$1),globalThis.Headers===void 0&&(na.Headers=Mi),globalThis.Request===void 0&&(na.Request=ea),globalThis.Response===void 0&&(na.Response=Xi);const ra=globalThis;globalThis.ByteLengthQueuingStrategy===void 0&&(ra.ByteLengthQueuingStrategy=kr),globalThis.CountQueuingStrategy===void 0&&(ra.CountQueuingStrategy=Ar);const ia=globalThis;function isNativeStreamUsable$2(n,a){try{return typeof n==`function`?typeof n.prototype?.[a]==`function`:!1}catch{return!1}}__name$1(isNativeStreamUsable$2,`isNativeStreamUsable`),isNativeStreamUsable$2(globalThis.ReadableStream,`getReader`)||(ia.ReadableStream=Er),ia.ReadableStreamBYOBReader===void 0&&(ia.ReadableStreamBYOBReader=ReadableStreamBYOBReader),ia.ReadableStreamBYOBRequest===void 0&&(ia.ReadableStreamBYOBRequest=ReadableStreamBYOBRequest),ia.ReadableByteStreamController===void 0&&(ia.ReadableByteStreamController=ReadableByteStreamController),ia.ReadableStreamDefaultController===void 0&&(ia.ReadableStreamDefaultController=ReadableStreamDefaultController),ia.ReadableStreamDefaultReader===void 0&&(ia.ReadableStreamDefaultReader=ReadableStreamDefaultReader);const aa=globalThis;globalThis.TextEncoderStream===void 0&&(aa.TextEncoderStream=jr),globalThis.TextDecoderStream===void 0&&(aa.TextDecoderStream=Mr);function isNativeStreamUsable$1(n,a){try{return typeof n==`function`?typeof n.prototype?.[a]==`function`:!1}catch{return!1}}if(__name$1(isNativeStreamUsable$1,`isNativeStreamUsable`),!isNativeStreamUsable$1(globalThis.TransformStream,`readable`)){let n=globalThis;n.TransformStream=Or}function isNativeStreamUsable(n,a){try{return typeof n==`function`?typeof n.prototype?.[a]==`function`:!1}catch{return!1}}if(!isNativeStreamUsable(globalThis.WritableStream,`getWriter`)){let n=globalThis;n.WritableStream=Dr}var CryptoKey=class{type;extractable;algorithm;usages;_handle;constructor(n,a,S,C,N){this.type=n,this.extractable=a,this.algorithm=Object.freeze({...S}),this.usages=Object.freeze([...C]),this._handle=N}get[Symbol.toStringTag](){return`CryptoKey`}};function normalizeAlgorithm$1(n){if(typeof n==`string`)return{name:n};if(!n||typeof n.name!=`string`)throw TypeError(`Algorithm must have a name property`);return n}__name$1(normalizeAlgorithm$1,`normalizeAlgorithm`);const oa={"SHA-1":`sha1`,"SHA-256":`sha256`,"SHA-384":`sha384`,"SHA-512":`sha512`};function toNodeHashName(n){let a=oa[n.toUpperCase()]||oa[n];if(!a)throw new Q(`Unrecognized hash name: ${n}`,`NotSupportedError`);return a}const sa={"P-256":`prime256v1`,"P-384":`secp384r1`,"P-521":`secp521r1`};function toNodeCurveName(n){let a=sa[n];if(!a)throw new Q(`Unrecognized curve name: ${n}`,`NotSupportedError`);return a}function hashSize$1(n){switch(toNodeHashName(n)){case`sha1`:return 20;case`sha256`:return 32;case`sha384`:return 48;case`sha512`:return 64;default:throw new Q(`Unsupported hash: ${n}`,`NotSupportedError`)}}__name$1(hashSize$1,`hashSize`);function validateUsages(n,a){for(let S of n)if(!a.includes(S))throw new Q(`Invalid key usage: ${S}`,`SyntaxError`);if(n.length===0)throw new Q(`Key usages must not be empty`,`SyntaxError`)}function checkUsage(n,a){if(!n.usages.includes(a))throw new Q(`Key does not support the '${a}' usage`,`InvalidAccessError`)}const ca=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,la=new Uint8Array(128);for(let n=0;n<64;n++)la[ca.charCodeAt(n)]=n;function bytesToBase64$1(n){let a=``,S=n.length;for(let C=0;C<S;C+=3){let N=n[C],F=C+1<S?n[C+1]:0,I=C+2<S?n[C+2]:0;a+=ca[N>>2&63],a+=ca[(N<<4|F>>4)&63],a+=C+1<S?ca[(F<<2|I>>6)&63]:`=`,a+=C+2<S?ca[I&63]:`=`}return a}__name$1(bytesToBase64$1,`bytesToBase64`);function base64ToBytes(n){let a=n;for(;a.endsWith(`=`);)a=a.slice(0,-1);let S=[],C=0,N=0;for(let n=0;n<a.length;n++)N=N<<6|la[a.charCodeAt(n)],C+=6,C>=8&&(C-=8,S.push(N>>C&255));return new Uint8Array(S)}function base64urlEncode(n){return bytesToBase64$1(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function base64urlDecode(n){let a=n.replace(/-/g,`+`).replace(/_/g,`/`);for(;a.length%4;)a+=`=`;return base64ToBytes(a)}function toUint8Array(n){if(n instanceof Uint8Array)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw TypeError(`Expected BufferSource`)}var ua,da=__esmMin(()=>{ua={RSA_PKCS1_PADDING:1,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_PKCS1_PSS_PADDING:6,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8}});function timingSafeEqual(n,a){if(n.length!==a.length)throw RangeError(`Input buffers must have the same byte length`);let S=0;for(let C=0;C<n.length;C++)S|=n[C]^a[C];return S===0}var fa=__esmMin(()=>{});function gmul(n,a){let S=0;for(let C=0;C<8;C++){a&1&&(S^=n);let C=n&128;n=n<<1&255,C&&(n^=27),a>>=1}return S}function keyExpansion(n){let a=n.length/4,S=a+6,C=4*(S+1),N=Array.from({length:C});for(let S=0;S<a;S++)N[S]=new Uint8Array([n[4*S],n[4*S+1],n[4*S+2],n[4*S+3]]);for(let n=a;n<C;n++){let S=new Uint8Array(N[n-1]);n%a===0?S=new Uint8Array([pa[S[1]]^ha[n/a-1],pa[S[2]],pa[S[3]],pa[S[0]]]):a>6&&n%a===4&&(S=new Uint8Array([pa[S[0]],pa[S[1]],pa[S[2]],pa[S[3]]])),N[n]=new Uint8Array(4);for(let C=0;C<4;C++)N[n][C]=N[n-a][C]^S[C]}let F=[];for(let n=0;n<=S;n++){let a=new Uint8Array(16);for(let S=0;S<4;S++)a[4*S]=N[4*n+S][0],a[4*S+1]=N[4*n+S][1],a[4*S+2]=N[4*n+S][2],a[4*S+3]=N[4*n+S][3];F.push(a)}return F}function aesEncryptBlock(n,a){let S=new Uint8Array(n),C=a.length-1;for(let n=0;n<16;n++)S[n]^=a[0][n];for(let n=1;n<C;n++){for(let n=0;n<16;n++)S[n]=pa[S[n]];let C=S[1];S[1]=S[5],S[5]=S[9],S[9]=S[13],S[13]=C;let N=S[2],F=S[6];S[2]=S[10],S[6]=S[14],S[10]=N,S[14]=F;let I=S[15];S[15]=S[11],S[11]=S[7],S[7]=S[3],S[3]=I;for(let n=0;n<4;n++){let a=n*4,C=S[a],N=S[a+1],F=S[a+2],I=S[a+3];S[a]=gmul(2,C)^gmul(3,N)^F^I,S[a+1]=C^gmul(2,N)^gmul(3,F)^I,S[a+2]=C^N^gmul(2,F)^gmul(3,I),S[a+3]=gmul(3,C)^N^F^gmul(2,I)}for(let C=0;C<16;C++)S[C]^=a[n][C]}for(let n=0;n<16;n++)S[n]=pa[S[n]];let N=S[1];S[1]=S[5],S[5]=S[9],S[9]=S[13],S[13]=N;let F=S[2],I=S[6];S[2]=S[10],S[6]=S[14],S[10]=F,S[14]=I;let H=S[15];S[15]=S[11],S[11]=S[7],S[7]=S[3],S[3]=H;for(let n=0;n<16;n++)S[n]^=a[C][n];return S}function aesDecryptBlock(n,a){let S=new Uint8Array(n),C=a.length-1;for(let n=0;n<16;n++)S[n]^=a[C][n];for(let n=C-1;n>0;n--){let C=S[13];S[13]=S[9],S[9]=S[5],S[5]=S[1],S[1]=C;let N=S[10],F=S[14];S[10]=S[2],S[14]=S[6],S[2]=N,S[6]=F;let I=S[3];S[3]=S[7],S[7]=S[11],S[11]=S[15],S[15]=I;for(let n=0;n<16;n++)S[n]=ma[S[n]];for(let C=0;C<16;C++)S[C]^=a[n][C];for(let n=0;n<4;n++){let a=n*4,C=S[a],N=S[a+1],F=S[a+2],I=S[a+3];S[a]=gmul(14,C)^gmul(11,N)^gmul(13,F)^gmul(9,I),S[a+1]=gmul(9,C)^gmul(14,N)^gmul(11,F)^gmul(13,I),S[a+2]=gmul(13,C)^gmul(9,N)^gmul(14,F)^gmul(11,I),S[a+3]=gmul(11,C)^gmul(13,N)^gmul(9,F)^gmul(14,I)}}let N=S[13];S[13]=S[9],S[9]=S[5],S[5]=S[1],S[1]=N;let F=S[10],I=S[14];S[10]=S[2],S[14]=S[6],S[2]=F,S[6]=I;let H=S[3];S[3]=S[7],S[7]=S[11],S[11]=S[15],S[15]=H;for(let n=0;n<16;n++)S[n]=ma[S[n]];for(let n=0;n<16;n++)S[n]^=a[0][n];return S}function incrementCounter(n){for(let a=15;a>=0&&++n[a]===0;a--);}function gcmIncrementCounter(n){for(let a=15;a>=12&&++n[a]===0;a--);}function gfMul(n,a){let S=new Uint8Array(16),C=new Uint8Array(n);for(let n=0;n<128;n++){if(a[n>>>3]&1<<7-(n&7))for(let n=0;n<16;n++)S[n]^=C[n];let N=C[15]&1;for(let n=15;n>0;n--)C[n]=C[n]>>>1|(C[n-1]&1)<<7;C[0]>>>=1,N&&(C[0]^=225)}return S}function ghash(n,a,S){let C=new Uint8Array(16),N=Math.ceil(a.length/16)||0;for(let S=0;S<N;S++){let N=S*16,F=Math.min(N+16,a.length);for(let n=0;n<16;n++){let S=N+n;S<F&&(C[n]^=a[S])}let I=gfMul(C,n);C.set(I)}let F=Math.ceil(S.length/16)||0;for(let a=0;a<F;a++){let N=a*16,F=Math.min(N+16,S.length);for(let n=0;n<16;n++){let a=N+n;a<F&&(C[n]^=S[a])}let I=gfMul(C,n);C.set(I)}let I=new Uint8Array(16),H=a.length*8,W=S.length*8,K=Math.floor(H/4294967296),q=H>>>0;I[0]=K>>>24&255,I[1]=K>>>16&255,I[2]=K>>>8&255,I[3]=K&255,I[4]=q>>>24&255,I[5]=q>>>16&255,I[6]=q>>>8&255,I[7]=q&255;let Y=Math.floor(W/4294967296),X=W>>>0;I[8]=Y>>>24&255,I[9]=Y>>>16&255,I[10]=Y>>>8&255,I[11]=Y&255,I[12]=X>>>24&255,I[13]=X>>>16&255,I[14]=X>>>8&255,I[15]=X&255;for(let n=0;n<16;n++)C[n]^=I[n];let te=gfMul(C,n);return C.set(te),C}var pa,ma,ha,ga=__esmMin(()=>{pa=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),ma=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),ha=[1,2,4,8,16,32,64,128,27,54]});function parseAlgorithm(n){let a=n.toLowerCase().match(/^aes-(128|192|256)-(cbc|ctr|ecb|cfb|ofb|gcm)$/);if(!a)throw Error(`Unsupported cipher algorithm: ${n}`);let S=parseInt(a[1]),C=a[2];return{keySize:S/8,ivSize:C===`ecb`?0:C===`gcm`?12:16,mode:C}}function toBuffer$2(n,a){return typeof n==`string`?lt.from(n,a||`utf8`):lt.from(n)}function encodeOutput(n,a){return a?lt.from(n).toString(a):lt.from(n)}function incompleteUtf8Tail(n){if(n.length===0)return 0;let a=n.length;for(let S=1;S<=Math.min(4,a);S++){let C=n[a-S];if(!(C&128))return 0;if((C&192)==128)continue;let N;if((C&224)==192)N=2;else if((C&240)==224)N=3;else if((C&248)==240)N=4;else return 0;return S<N?S:0}return 0}function pkcs7Pad(n){let a=16-n.length%16,S=new Uint8Array(n.length+a);S.set(n);for(let C=n.length;C<S.length;C++)S[C]=a;return S}function pkcs7Unpad(n){if(n.length===0||n.length%16!=0)throw Error(`bad decrypt`);let a=n[n.length-1];if(a===0||a>16)throw Error(`bad decrypt`);for(let S=n.length-a;S<n.length;S++)if(n[S]!==a)throw Error(`bad decrypt`);return new Uint8Array(n.slice(0,n.length-a))}var _a=__esmMin(()=>{vt(),__name$1(toBuffer$2,`toBuffer`)});function createCipher(n,a){throw Error(`crypto.createCipher() is deprecated. Use createCipheriv() instead.`)}function createCipheriv(n,a,S){return new Cipher(n,typeof a==`string`?lt.from(a):new Uint8Array(a),S==null?null:typeof S==`string`?lt.from(S):new Uint8Array(S))}function createDecipher(n,a){throw Error(`crypto.createDecipher() is deprecated. Use createDecipheriv() instead.`)}function createDecipheriv(n,a,S){return new Decipher(n,typeof a==`string`?lt.from(a):new Uint8Array(a),S==null?null:typeof S==`string`?lt.from(S):new Uint8Array(S))}function getCiphers(){return[`aes-128-cbc`,`aes-128-ecb`,`aes-192-cbc`,`aes-192-ecb`,`aes-256-cbc`,`aes-256-ecb`,`aes-128-ctr`,`aes-192-ctr`,`aes-256-ctr`,`aes-128-cfb`,`aes-192-cfb`,`aes-256-cfb`,`aes-128-gcm`,`aes-192-gcm`,`aes-256-gcm`]}var CipherBase,Cipher,Decipher,va=__esmMin(()=>{ga(),_a(),vt(),CipherBase=class{_roundKeys;_iv;_mode;_buffer=new Uint8Array;_autoPadding=!0;_finalized=!1;constructor(n,a,S){let C=parseAlgorithm(n);if(a.length!==C.keySize)throw Error(`Invalid key length ${a.length}, expected ${C.keySize} for ${n}`);if(C.ivSize>0&&(!S||S.length!==C.ivSize))throw Error(`Invalid IV length ${S?.length??0}, expected ${C.ivSize} for ${n}`);this._roundKeys=keyExpansion(a),this._iv=S?new Uint8Array(S):new Uint8Array(16),this._mode=C.mode}setAutoPadding(n){return this._autoPadding=n,this}},Cipher=class extends CipherBase{_prevBlock;_counter;_gcmH=null;_gcmJ0=null;_gcmAAD=new Uint8Array;_gcmCiphertext=[];_gcmCiphertextLen=0;_gcmAuthTag=null;_gcmAADSet=!1;constructor(n,a,S){super(n,a,S),this._prevBlock=new Uint8Array(this._iv),this._mode===`gcm`?(this._gcmH=aesEncryptBlock(new Uint8Array(16),this._roundKeys),this._gcmJ0=new Uint8Array(16),this._gcmJ0.set(this._iv.subarray(0,12)),this._gcmJ0[15]=1,this._counter=new Uint8Array(this._gcmJ0),gcmIncrementCounter(this._counter)):this._counter=new Uint8Array(this._iv)}setAAD(n){if(this._mode!==`gcm`)throw Error(`setAAD is only supported in GCM mode`);if(this._gcmCiphertextLen>0)throw Error(`setAAD must be called before update()`);return this._gcmAAD=new Uint8Array(n),this._gcmAADSet=!0,this}getAuthTag(){if(this._mode!==`gcm`)throw Error(`getAuthTag is only supported in GCM mode`);if(!this._gcmAuthTag)throw Error(`getAuthTag must be called after final()`);return lt.from(this._gcmAuthTag)}update(n,a,S){let C=toBuffer$2(n,a),N=new Uint8Array(this._buffer.length+C.length);if(N.set(this._buffer),N.set(C,this._buffer.length),this._mode===`gcm`){let n=this._processGcmEncrypt(N);return this._buffer=new Uint8Array,encodeOutput(n,S)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){let n=this._processStream(N);return this._buffer=new Uint8Array,encodeOutput(n,S)}let F=Math.floor(N.length/16)*16,I=[];for(let n=0;n<F;n+=16){let a=N.slice(n,n+16);I.push(this._encryptBlock(a))}this._buffer=N.slice(F);let H=new Uint8Array(I.length*16);for(let n=0;n<I.length;n++)H.set(I[n],n*16);return encodeOutput(H,S)}final(n){if(this._finalized)throw Error(`Cipher already finalized`);if(this._finalized=!0,this._mode===`gcm`){let a=new Uint8Array;this._buffer.length>0&&(a=this._processGcmEncrypt(this._buffer),this._buffer=new Uint8Array);let S=new Uint8Array(this._gcmCiphertextLen),C=0;for(let n of this._gcmCiphertext)S.set(n,C),C+=n.length;let N=ghash(this._gcmH,this._gcmAAD,S),F=aesEncryptBlock(this._gcmJ0,this._roundKeys),I=new Uint8Array(16);for(let n=0;n<16;n++)I[n]=N[n]^F[n];return this._gcmAuthTag=lt.from(I),encodeOutput(a,n)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){if(this._buffer.length>0){let a=this._processStream(this._buffer);return this._buffer=new Uint8Array,encodeOutput(a,n)}return encodeOutput(new Uint8Array,n)}let a=this._buffer;if(this._autoPadding)a=pkcs7Pad(a);else if(a.length%16!=0)throw Error(`data not multiple of block size`);let S=[];for(let n=0;n<a.length;n+=16)S.push(this._encryptBlock(a.slice(n,n+16)));if(this._buffer=new Uint8Array,S.length===0)return encodeOutput(new Uint8Array,n);let C=new Uint8Array(S.length*16);for(let n=0;n<S.length;n++)C.set(S[n],n*16);return encodeOutput(C,n)}_encryptBlock(n){if(this._mode===`cbc`){let a=new Uint8Array(16);for(let S=0;S<16;S++)a[S]=n[S]^this._prevBlock[S];let S=aesEncryptBlock(a,this._roundKeys);return this._prevBlock=S,S}else if(this._mode===`ecb`)return aesEncryptBlock(n,this._roundKeys);throw Error(`Block encryption not supported for mode: ${this._mode}`)}_processStream(n){let a=new Uint8Array(n.length);for(let S=0;S<n.length;S+=16){let C=aesEncryptBlock(this._counter,this._roundKeys),N=Math.min(16,n.length-S);for(let F=0;F<N;F++)a[S+F]=n[S+F]^C[F];incrementCounter(this._counter)}return a}_processGcmEncrypt(n){let a=new Uint8Array(n.length);for(let S=0;S<n.length;S+=16){let C=aesEncryptBlock(this._counter,this._roundKeys),N=Math.min(16,n.length-S);for(let F=0;F<N;F++)a[S+F]=n[S+F]^C[F];gcmIncrementCounter(this._counter)}return this._gcmCiphertext.push(new Uint8Array(a)),this._gcmCiphertextLen+=a.length,a}},Decipher=class extends CipherBase{_prevBlock;_counter;_pendingUtf8=new Uint8Array;_gcmH=null;_gcmJ0=null;_gcmAAD=new Uint8Array;_gcmCiphertext=[];_gcmCiphertextLen=0;_gcmExpectedTag=null;_gcmAADSet=!1;constructor(n,a,S){super(n,a,S),this._prevBlock=new Uint8Array(this._iv),this._mode===`gcm`?(this._gcmH=aesEncryptBlock(new Uint8Array(16),this._roundKeys),this._gcmJ0=new Uint8Array(16),this._gcmJ0.set(this._iv.subarray(0,12)),this._gcmJ0[15]=1,this._counter=new Uint8Array(this._gcmJ0),gcmIncrementCounter(this._counter)):this._counter=new Uint8Array(this._iv)}setAAD(n){if(this._mode!==`gcm`)throw Error(`setAAD is only supported in GCM mode`);if(this._gcmCiphertextLen>0)throw Error(`setAAD must be called before update()`);return this._gcmAAD=new Uint8Array(n),this._gcmAADSet=!0,this}setAuthTag(n){if(this._mode!==`gcm`)throw Error(`setAuthTag is only supported in GCM mode`);return this._gcmExpectedTag=lt.from(n),this}_encodeWithUtf8Handling(n,a,S){if(!a||a!==`utf8`&&a!==`utf-8`)return encodeOutput(n,a);let C;if(this._pendingUtf8.length>0?(C=new Uint8Array(this._pendingUtf8.length+n.length),C.set(this._pendingUtf8),C.set(n,this._pendingUtf8.length),this._pendingUtf8=new Uint8Array):C=n,!S){let n=incompleteUtf8Tail(C);n>0&&(this._pendingUtf8=new Uint8Array(C.slice(C.length-n)),C=new Uint8Array(C.slice(0,C.length-n)))}return lt.from(C).toString(`utf8`)}update(n,a,S){let C=toBuffer$2(n,a),N=new Uint8Array(this._buffer.length+C.length);if(N.set(this._buffer),N.set(C,this._buffer.length),this._mode===`gcm`){this._gcmCiphertext.push(new Uint8Array(N)),this._gcmCiphertextLen+=N.length;let n=this._processGcmDecrypt(N);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(n,S,!1)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){let n=this._processStream(N);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(n,S,!1)}let F=Math.floor(N.length/16);if(F===0)return this._buffer=N,this._encodeWithUtf8Handling(new Uint8Array,S,!1);let I=(this._autoPadding?F-1:F)*16,H=[];for(let n=0;n<I;n+=16){let a=N.slice(n,n+16);H.push(this._decryptBlock(a))}this._buffer=N.slice(I);let W=new Uint8Array(H.length*16);for(let n=0;n<H.length;n++)W.set(H[n],n*16);return this._encodeWithUtf8Handling(W,S,!1)}final(n){if(this._finalized)throw Error(`Decipher already finalized`);if(this._finalized=!0,this._mode===`gcm`){let a=new Uint8Array;if(this._buffer.length>0&&(this._gcmCiphertext.push(new Uint8Array(this._buffer)),this._gcmCiphertextLen+=this._buffer.length,a=this._processGcmDecrypt(this._buffer),this._buffer=new Uint8Array),!this._gcmExpectedTag)throw Error(`Unsupported state or unable to authenticate data`);let S=new Uint8Array(this._gcmCiphertextLen),C=0;for(let n of this._gcmCiphertext)S.set(n,C),C+=n.length;let N=ghash(this._gcmH,this._gcmAAD,S),F=aesEncryptBlock(this._gcmJ0,this._roundKeys),I=new Uint8Array(16);for(let n=0;n<16;n++)I[n]=N[n]^F[n];let H=this._gcmExpectedTag,W=Math.min(H.length,16),K=0;for(let n=0;n<W;n++)K|=I[n]^H[n];if(K!==0)throw Error(`Unsupported state or unable to authenticate data`);return this._encodeWithUtf8Handling(a,n,!0)}if(this._mode===`ctr`||this._mode===`cfb`||this._mode===`ofb`){if(this._buffer.length>0){let a=this._processStream(this._buffer);return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(a,n,!0)}return this._encodeWithUtf8Handling(new Uint8Array,n,!0)}if(this._buffer.length===0)return this._encodeWithUtf8Handling(new Uint8Array,n,!0);if(this._buffer.length%16!=0)throw Error(`bad decrypt`);let a=[];for(let n=0;n<this._buffer.length;n+=16)a.push(this._decryptBlock(this._buffer.slice(n,n+16)));let S=new Uint8Array(a.length*16);for(let n=0;n<a.length;n++)S.set(a[n],n*16);let C=this._autoPadding?pkcs7Unpad(S):S;return this._buffer=new Uint8Array,this._encodeWithUtf8Handling(C,n,!0)}_decryptBlock(n){if(this._mode===`cbc`){let a=aesDecryptBlock(n,this._roundKeys),S=new Uint8Array(16);for(let n=0;n<16;n++)S[n]=a[n]^this._prevBlock[n];return this._prevBlock=new Uint8Array(n),S}else if(this._mode===`ecb`)return aesDecryptBlock(n,this._roundKeys);throw Error(`Block decryption not supported for mode: ${this._mode}`)}_processStream(n){let a=new Uint8Array(n.length);for(let S=0;S<n.length;S+=16){let C=aesEncryptBlock(this._counter,this._roundKeys),N=Math.min(16,n.length-S);for(let F=0;F<N;F++)a[S+F]=n[S+F]^C[F];incrementCounter(this._counter)}return a}_processGcmDecrypt(n){let a=new Uint8Array(n.length);for(let S=0;S<n.length;S+=16){let C=aesEncryptBlock(this._counter,this._roundKeys),N=Math.min(16,n.length-S);for(let F=0;F<N;F++)a[S+F]=n[S+F]^C[F];gcmIncrementCounter(this._counter)}return a}}});function fillRandom(n){if(ya)for(let a=0;a<n.length;a+=65536){let S=Math.min(n.length-a,65536),C=new Uint8Array(n.buffer,n.byteOffset+a,S);globalThis.crypto.getRandomValues(C)}else try{let a=imports.gi.GLib;for(let S=0;S<n.length;S++)n[S]=a.random_int_range(0,256)}catch{for(let a=0;a<n.length;a++)n[a]=Math.floor(Math.random()*256)}}function randomBytes(n,a){if(typeof n!=`number`||n<0||!Number.isInteger(n))throw TypeError(`The "size" argument must be a non-negative integer. Received ${n}`);try{let S=lt.alloc(n);if(n>0&&fillRandom(new Uint8Array(S.buffer,S.byteOffset,S.byteLength)),a)a(null,S);else return S}catch(n){if(a)a(n,lt.alloc(0));else throw n}}function randomFillSync(n,a=0,S){let C=S??n.length-a;if(a<0||a>n.length)throw RangeError(`The value of "offset" is out of range. Received ${a}`);if(C<0||a+C>n.length)throw RangeError(`The value of "size" is out of range. Received ${C}`);if(C>0){let S=(n instanceof lt,n.byteOffset);fillRandom(new Uint8Array(n.buffer,S+a,C))}return n}function randomFill(n,a,S,C){let N,F,I;typeof a==`function`?(I=a,N=0,F=n.length):typeof S==`function`?(I=S,N=a,F=n.length-a):(I=C,N=a,F=S);try{randomFillSync(n,N,F),I(null,n)}catch(a){I(a,n)}}function randomUUID(){if(ya&&typeof globalThis.crypto.randomUUID==`function`)return globalThis.crypto.randomUUID();let n=new Uint8Array(16);fillRandom(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;let a=Array.from(n,n=>n.toString(16).padStart(2,`0`)).join(``);return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`}function randomInt(n,a,S){let C,N,F;if(typeof a==`function`?(F=a,N=n,C=0):typeof a==`number`?(C=n,N=a,F=S):(N=n,C=0,F=S),!Number.isInteger(C))throw TypeError(`The "min" argument must be a safe integer. Received ${C}`);if(!Number.isInteger(N))throw TypeError(`The "max" argument must be a safe integer. Received ${N}`);if(C>=N)throw RangeError(`The value of "min" must be less than "max". Received min: ${C}, max: ${N}`);let I=N-C,H=new Uint32Array(1);fillRandom(new Uint8Array(H.buffer));let W=C+H[0]%I;if(F)F(null,W);else return W}var ya,ba=__esmMin(()=>{vt(),ya=globalThis.crypto!==void 0&&typeof globalThis.crypto.getRandomValues==`function`});function modPow(n,a,S){if(S===1n)return 0n;n=(n%S+S)%S;let C=1n;for(;a>0n;)a&1n&&(C=C*n%S),a>>=1n,n=n*n%S;return C}function bigIntToBytes(n,a){let S=new Uint8Array(a),C=n;for(let n=a-1;n>=0;n--)S[n]=Number(C&255n),C>>=8n;return S}function bytesToBigInt(n){let a=0n;for(let S=0;S<n.length;S++)a=a<<8n|BigInt(n[S]);return a}var xa=__esmMin(()=>{});function bigIntToBuffer(n){if(n===0n)return lt.from([0]);let a=n.toString(16);return a.length%2!=0&&(a=`0`+a),lt.from(a,`hex`)}function bufferToBigInt(n){if(n.length===0)return 0n;let a=lt.from(n).toString(`hex`);return a.length===0?0n:BigInt(`0x`+a)}function bitLength(n){return n===0n?0:n.toString(2).length}function simpleSieve(n){for(let a of Ca){let S=BigInt(a);if(n%S===0n)return n===S}return!0}function fermatTest(n){return modPow(2n,n-1n,n)===1n}function millerRabinTest(n){if(n<2n)return!1;if(n===2n||n===3n)return!0;if(n%2n==0n)return!1;let a=n-1n,S=0;for(;a%2n==0n;)a/=2n,S++;for(let C of[2n,3n,5n,7n,11n,13n]){if(C>=n)continue;let N=modPow(C,a,n);if(N===1n||N===n-1n)continue;let F=!0;for(let a=0;a<S-1;a++)if(N=modPow(N,2n,n),N===n-1n){F=!1;break}if(F)return!1}return!0}function checkPrime(n,a){let S=a.toString(`hex`),C=0;if(n%2n==0n||!simpleSieve(n)||!fermatTest(n)||!millerRabinTest(n))return C+=1,S===`02`||S===`05`?C+=8:C+=4,C;switch(millerRabinTest(n>>1n)||(C+=2),S){case`02`:n%24n!=11n&&(C+=8);break;case`05`:{let a=n%10n;a!==3n&&a!==7n&&(C+=8)}break;default:C+=4}return C}function getCachedCheckPrime(n,a){let S=a.toString(`hex`)+`_`+n.toString(16);if(S in wa)return wa[S];let C=checkPrime(n,a);return wa[S]=C,C}function formatReturnValue$1(n,a){let S=bigIntToBuffer(n);return a?S.toString(a):S}function generatePrime(n,a){let S=bufferToBigInt(a);if(n<16)return S===2n||S===5n?lt.from([140,123]):lt.from([140,39]);let C=Math.ceil(n/8),N=2n,F=4n;for(;;){let a=bufferToBigInt(randomBytes(C));for(;bitLength(a)>n;)a>>=1n;if(a%N==0n&&(a+=1n),a&N||(a+=N),S===N)for(;a%24n!=11n;)a+=F;else if(S===5n)for(;a%10n!=3n;)a+=F;let I=a>>1n;if(simpleSieve(I)&&simpleSieve(a)&&fermatTest(I)&&fermatTest(a)&&millerRabinTest(I)&&millerRabinTest(a))return bigIntToBuffer(a)}}function createDiffieHellman(n,a,S,C){if(a!==void 0&&typeof a!=`number`&&(lt.isBuffer(a)||a instanceof Uint8Array||typeof a==`string`&&!(a in Ta)))return createDiffieHellman(n,`binary`,a,S);let N=a||`binary`,F=C||`binary`,I=lt.from([2]);if(S!==void 0&&(typeof S==`number`?(I=lt.alloc(1),I[0]=S):I=lt.isBuffer(S)?S:lt.from(S,F)),typeof n==`number`)return new DiffieHellman(generatePrime(n,I),I,!0);let H;return H=lt.isBuffer(n)?n:n instanceof Uint8Array?lt.from(n):lt.from(n,N),new DiffieHellman(H,I,!0)}function getDiffieHellman(n){let a=Sa[n];if(!a)throw Error(`Unknown group: ${n}. Supported groups: ${Object.keys(Sa).join(`, `)}`);return new DiffieHellman(lt.from(a.prime,`hex`),lt.from(a.gen,`hex`),!1)}var Sa,Ca,wa,DiffieHellman,Ta,Ea,Da,Oa=__esmMin(()=>{xa(),ba(),vt(),Sa={modp1:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff`},modp2:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff`},modp5:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff`},modp14:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff`},modp15:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff`},modp16:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff`},modp17:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff`},modp18:{gen:`02`,prime:`ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff`}},Ca=[];{let n=1e3,a=new Uint8Array(1001);for(let S=2;S*S<=n;S++)if(!a[S])for(let C=S*S;C<=n;C+=S)a[C]=1;for(let S=2;S<=n;S++)a[S]||Ca.push(S)}wa={},__name$1(formatReturnValue$1,`formatReturnValue`),DiffieHellman=class{_prime;_generator;_generatorBuf;_primeByteLength;_pubKey;_privKey;_primeCode;_malleable;constructor(n,a,S=!1){this._prime=bufferToBigInt(n),this._generatorBuf=a,this._generator=bufferToBigInt(a),this._primeByteLength=n.length,this._pubKey=void 0,this._privKey=void 0,this._primeCode=void 0,this._malleable=S,S||(this._primeCode=0,this.setPublicKey=void 0,this.setPrivateKey=void 0)}get verifyError(){return typeof this._primeCode!=`number`&&(this._primeCode=getCachedCheckPrime(this._prime,this._generatorBuf)),this._primeCode}generateKeys(n){if(!this._privKey){let n=randomBytes(this._primeByteLength);this._privKey=bufferToBigInt(n)}return this._pubKey=modPow(this._generator,this._privKey,this._prime),this.getPublicKey(n)}computeSecret(n,a,S){let C;C=typeof n==`string`?lt.from(n,a||`utf8`):lt.from(n);let N=bufferToBigInt(C);if(!this._privKey)throw Error(`You must generate keys before computing a secret`);if(N<=0n||N>=this._prime)throw Error(`Supplied key is too large`);let F=bigIntToBuffer(modPow(N,this._privKey,this._prime)),I=this._primeByteLength;if(F.length<I){let n=lt.alloc(I);F.copy(n,I-F.length),F=n}return S?F.toString(S):F}getPrime(n){return formatReturnValue$1(this._prime,n)}getGenerator(n){return formatReturnValue$1(this._generator,n)}getPublicKey(n){if(!this._pubKey)throw Error(`No public key - call generateKeys() first`);return formatReturnValue$1(this._pubKey,n)}getPrivateKey(n){if(!this._privKey)throw Error(`No private key - call generateKeys() first`);return formatReturnValue$1(this._privKey,n)}setPublicKey(n,a){if(!this._malleable)throw Error(`setPublicKey is not available for predefined DH groups`);let S=typeof n==`string`?lt.from(n,a||`utf8`):lt.from(n);this._pubKey=bufferToBigInt(S)}setPrivateKey(n,a){if(!this._malleable)throw Error(`setPrivateKey is not available for predefined DH groups`);let S=typeof n==`string`?lt.from(n,a||`utf8`):lt.from(n);this._privKey=bufferToBigInt(S)}},Ta={binary:!0,hex:!0,base64:!0,latin1:!0,utf8:!0,"utf-8":!0,base64url:!0,ascii:!0,ucs2:!0,"ucs-2":!0,utf16le:!0,"utf-16le":!0},Ea=getDiffieHellman,Da=getDiffieHellman});function mod(n,a){let S=n%a;return S<0n?S+a:S}function modInverse$2(n,a){if(n=mod(n,a),n===0n)throw Error(`No modular inverse for zero`);let[S,C]=[n,a],[N,F]=[1n,0n];for(;C!==0n;){let n=S/C;[S,C]=[C,S-n*C],[N,F]=[F,N-n*F]}if(S!==1n)throw Error(`Modular inverse does not exist`);return mod(N,a)}function pointAdd(n,a,S){if(n===null)return a;if(a===null)return n;let{p:C}=S;if(n.x===a.x)return mod(n.y+a.y,C)===0n?null:pointDouble(n,S);let N=mod(a.x-n.x,C),F=mod(mod(a.y-n.y,C)*modInverse$2(N,C),C),I=mod(F*F-n.x-a.x,C);return{x:I,y:mod(F*(n.x-I)-n.y,C)}}function pointDouble(n,a){if(n===null)return null;let{a:S,p:C}=a;if(n.y===0n)return null;let N=mod(mod(3n*n.x*n.x+S,C)*modInverse$2(mod(2n*n.y,C),C),C),F=mod(N*N-2n*n.x,C);return{x:F,y:mod(N*(n.x-F)-n.y,C)}}function scalarMul(n,a,S){if(a===null||n===0n)return null;let{n:C}=S;if(n=mod(n,C),n===0n)return null;let N=null,F=a,I=n.toString(2);for(let n=0;n<I.length;n++)I[n]===`1`?(N=pointAdd(N,F,S),F=pointDouble(F,S)):(F=pointAdd(N,F,S),N=pointDouble(N,S));return N}function bigintToBuffer(n,a){let S=n.toString(16).padStart(a*2,`0`);return lt.from(S,`hex`)}function bufferToBigint(n){let a=lt.from(n).toString(`hex`);return a.length===0?0n:BigInt(`0x`+a)}function encodePublicKey(n,a,S=`uncompressed`){if(n===null)throw Error(`Cannot encode the point at infinity`);let C=bigintToBuffer(n.x,a);if(S===`compressed`){let a=n.y%2n==0n?2:3;return lt.concat([lt.from([a]),C])}let N=bigintToBuffer(n.y,a);if(S===`hybrid`){let a=n.y%2n==0n?6:7;return lt.concat([lt.from([a]),C,N])}return lt.concat([lt.from([4]),C,N])}function decodePublicKey(n,a){let S=lt.from(n);if(S.length===0)throw Error(`Invalid public key: empty buffer`);let C=S[0],{p:N,a:F,b:I,byteLength:H}=a;if(C===4||C===6||C===7){if(S.length!==1+2*H)throw Error(`Invalid public key length: expected ${1+2*H} bytes, got ${S.length}`);let n=bufferToBigint(S.subarray(1,1+H)),a=bufferToBigint(S.subarray(1+H));if(mod(a*a,N)!==mod(n*n*n+F*n+I,N))throw Error(`Invalid public key: point is not on the curve`);return{x:n,y:a}}if(C===2||C===3){if(S.length!==1+H)throw Error(`Invalid public key length: expected ${1+H} bytes, got ${S.length}`);let n=bufferToBigint(S.subarray(1,1+H)),a=sqrtMod(mod(n*n*n+F*n+I,N),N);if(a===null)throw Error(`Invalid public key: no valid y coordinate for the given x`);let W=C===3;return{x:n,y:a%2n!=0n===W?a:mod(N-a,N)}}throw Error(`Invalid public key prefix: 0x${C.toString(16).padStart(2,`0`)}`)}function sqrtMod(n,a){if(n=mod(n,a),n===0n)return 0n;if(modPow(n,(a-1n)/2n,a)!==1n)return null;if(mod(a,4n)===3n)return modPow(n,(a+1n)/4n,a);let S=0n,C=a-1n;for(;mod(C,2n)===0n;)C/=2n,S++;let N=2n;for(;modPow(N,(a-1n)/2n,a)!==a-1n;)N++;let F=S,I=modPow(N,C,a),H=modPow(n,C,a),W=modPow(n,(C+1n)/2n,a);for(;;){if(H===0n)return 0n;if(H===1n)return W;let n=1n,S=mod(H*H,a);for(;S!==1n;)S=mod(S*S,a),n++;let C=modPow(I,modPow(2n,F-n-1n,a-1n),a);F=n,I=mod(C*C,a),H=mod(H*I,a),W=mod(W*C,a)}}function toBuffer$1(n,a){if(lt.isBuffer(n))return n;if(n instanceof Uint8Array)return lt.from(n);if(typeof n==`string`)return lt.from(n,a||`utf8`);if(ArrayBuffer.isView(n))return lt.from(n.buffer,n.byteOffset,n.byteLength);throw TypeError(`The "key" argument must be of type string or an instance of Buffer, TypedArray, or DataView.`)}function formatReturnValue(n,a){return a?n.toString(a):n}function resolveCurve(n){let a=Aa[n.toLowerCase()];if(!a)throw Error(`Unsupported curve: ${n}`);let S=ka[a];if(!S)throw Error(`Unsupported curve: ${n}`);return{canonical:a,params:S}}function createECDH(n){return new ECDH(n)}function getCurves(){return[`secp256k1`,`prime256v1`,`secp256r1`,`secp384r1`,`secp521r1`]}var ka,Aa,ECDH,ja=__esmMin(()=>{xa(),ba(),vt(),ka={secp256k1:{p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,byteLength:32},prime256v1:{p:115792089210356248762697446949407573530086143415290314195533631308867097853951n,a:115792089210356248762697446949407573530086143415290314195533631308867097853951n-3n,b:41058363725152142129326129780047268409114441015993725554835256314039467401291n,Gx:48439561293906451759052585252797914202762949526041747995844080717082404635286n,Gy:36134250956749795798585127919587881956611106672985015071877198253568414405109n,n:115792089210356248762697446949407573529996955224135760342422259061068512044369n,byteLength:32},secp384r1:{p:39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319n,a:39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319n-3n,b:27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,Gx:26247035095799689268623156744566981891852923491109213387815615900925518854738050089022388053975719786650872476732087n,Gy:8325710961489029985546751289520108179287853048861315594709205902480503199884419224438643760392947333078086511627871n,n:39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942643n,byteLength:48},secp521r1:{p:6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151n,a:6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151n-3n,b:1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,Gx:2661740802050217063228768716723360960729859168756973147706671368418802944996427808491545080627771902352094241225065558662157113545570916814161637315895999846n,Gy:3757180025770020463545507224491183603594455134769762486694567779615544477440556316691234405012945539562144444537289428522585666729196580810124344277578376784n,n:6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449n,byteLength:66}},Aa={secp256k1:`secp256k1`,prime256v1:`prime256v1`,secp256r1:`prime256v1`,"p-256":`prime256v1`,p256:`prime256v1`,secp384r1:`secp384r1`,"p-384":`secp384r1`,p384:`secp384r1`,secp521r1:`secp521r1`,"p-521":`secp521r1`,p521:`secp521r1`},__name$1(modInverse$2,`modInverse`),__name$1(toBuffer$1,`toBuffer`),ECDH=class{_curve;_curveName;_privateKey=null;_publicKey=null;constructor(n){let a=resolveCurve(n);this._curve=a.params,this._curveName=a.canonical}generateKeys(n,a){let{n:S,byteLength:C}=this._curve,N;do N=bufferToBigint(randomBytes(C));while(N===0n||N>=S);this._privateKey=N;let F={x:this._curve.Gx,y:this._curve.Gy};return this._publicKey=scalarMul(N,F,this._curve),n===void 0?this.getPublicKey():this.getPublicKey(n,a)}computeSecret(n,a,S){if(this._privateKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);let C=decodePublicKey(toBuffer$1(n,a),this._curve);if(C===null)throw Error(`Invalid public key: point at infinity`);let N=scalarMul(this._privateKey,C,this._curve);if(N===null)throw Error(`Shared secret computation resulted in the point at infinity`);return formatReturnValue(bigintToBuffer(N.x,this._curve.byteLength),S)}getPublicKey(n,a){if(this._publicKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);return formatReturnValue(encodePublicKey(this._publicKey,this._curve.byteLength,a||`uncompressed`),n)}getPrivateKey(n){if(this._privateKey===null)throw Error(`ECDH key not generated. Call generateKeys() or setPrivateKey() first.`);return formatReturnValue(bigintToBuffer(this._privateKey,this._curve.byteLength),n)}setPublicKey(n,a){let S=toBuffer$1(n,a);this._publicKey=decodePublicKey(S,this._curve)}setPrivateKey(n,a){let S=bufferToBigint(toBuffer$1(n,a));if(S===0n||S>=this._curve.n)throw Error(`Private key is out of range [1, n-1]`);this._privateKey=S;let C={x:this._curve.Gx,y:this._curve.Gy};this._publicKey=scalarMul(S,C,this._curve)}}});function normalizeAlgorithm(n){return n.toLowerCase().replace(/-/g,``)}function hashSize(n){let a=Ma[normalizeAlgorithm(n)];if(a===void 0)throw Error(`Unknown hash algorithm: ${n}`);return a}function toBuffer(n,a){return typeof n==`string`?lt.from(n,a||`utf8`):n instanceof DataView?lt.from(n.buffer,n.byteOffset,n.byteLength):(n instanceof ArrayBuffer,lt.from(n))}var Ma,Na,Pa,Fa=__esmMin(()=>{vt(),Ma={md5:16,sha1:20,sha256:32,sha384:48,sha512:64},Na={md5:64,sha1:64,sha256:64,sha384:128,sha512:128},Pa=new Set([`md5`,`sha1`,`sha256`,`sha384`,`sha512`])});function getChecksumType(n){let a=Ia[normalizeAlgorithm(n)];if(a===void 0){let a=Error(`Unknown message digest: ${n}`);throw a.code=`ERR_CRYPTO_HASH_UNKNOWN`,a}return a}function getHashes(){return[`md5`,`sha1`,`sha256`,`sha384`,`sha512`]}function hash(n,a,S){return new La(n).update(a).digest(S)}var Ia,La,Ra=__esmMin(()=>{Fa(),vt(),se(),oi(),Ia={md5:Z.ChecksumType.MD5,sha1:Z.ChecksumType.SHA1,sha256:Z.ChecksumType.SHA256,sha384:Z.ChecksumType.SHA384,sha512:Z.ChecksumType.SHA512},La=class Hash extends ri{_algorithm;_checksum;_finalized=!1;constructor(n){super();let a=normalizeAlgorithm(n),S=getChecksumType(a);this._algorithm=a,this._checksum=new Z.Checksum(S)}update(n,a){if(this._finalized)throw Error(`Digest already called`);let S;if(typeof n==`string`){let C=normalizeEncoding(a);S=lt.from(n,C)}else S=n instanceof Uint8Array?n:lt.from(n);return this._checksum.update(S),this}digest(n){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let a=this._checksum.get_string(),S=lt.from(a,`hex`);return n?S.toString(n):S}copy(){if(this._finalized)throw Error(`Digest already called`);let n=Object.create(Hash.prototype);return ri.call(n),n._algorithm=this._algorithm,n._finalized=!1,n._checksum=this._checksum.copy(),n}_transform(n,a,S){try{this.update(n,a),S()}catch(n){S(n)}}_flush(n){try{this.push(this.digest()),n()}catch(a){n(a)}}}}),Hmac,za=__esmMin(()=>{Fa(),Ra(),vt(),oi(),Hmac=class extends ri{_algorithm;_innerHash;_outerKeyPad;_finalized=!1;constructor(n,a){super();let S=normalizeAlgorithm(n);if(!Pa.has(S)){let a=Error(`Unknown message digest: ${n}`);throw a.code=`ERR_CRYPTO_HASH_UNKNOWN`,a}this._algorithm=S;let C;C=typeof a==`string`?lt.from(a,`utf8`):a instanceof Uint8Array?a:lt.from(a);let N=Na[S];if(C.length>N){let n=new La(S);n.update(C),C=n.digest()}let F=new Uint8Array(N);F.set(C);let I=new Uint8Array(N),H=new Uint8Array(N);for(let n=0;n<N;n++)I[n]=F[n]^54,H[n]=F[n]^92;this._outerKeyPad=H,this._innerHash=new La(S),this._innerHash.update(I)}update(n,a){if(this._finalized)throw Error(`Digest already called`);let S;if(typeof n==`string`){let C=normalizeEncoding(a);S=lt.from(n,C)}else S=n instanceof Uint8Array?n:lt.from(n);return this._innerHash.update(S),this}digest(n){if(this._finalized)throw Error(`Digest already called`);this._finalized=!0;let a=this._innerHash.digest(),S=new La(this._algorithm);S.update(this._outerKeyPad),S.update(a);let C=S.digest();return n?C.toString(n):C}_transform(n,a,S){try{this.update(n,a),S()}catch(n){S(n)}}_flush(n){try{this.push(this.digest()),n()}catch(a){n(a)}}}});function getCurve(n){let a=Aa[n.toLowerCase()];if(!a)throw Error(`Unsupported curve: ${n}`);return ka[a]}function truncateHash(n,a){let S=a.n.toString(2).length,C=bytesToBigInt(n),N=n.length*8;return N>S&&(C>>=BigInt(N-S)),C}function hmacDigest$2(n,a,S){let C=new Hmac(n,a);return C.update(S),new Uint8Array(C.digest())}function rfc6979(n,a,S,C){let N=C.byteLength,F=S.length,I=new Uint8Array(F).fill(1),H=new Uint8Array(F).fill(0),W=bigIntToBytes(a,N),K=bigIntToBytes(mod(truncateHash(S,C),C.n),N),q=new Uint8Array(F+1+N+N);q.set(I,0),q[F]=0,q.set(W,F+1),q.set(K,F+1+N),H=hmacDigest$2(n,H,q),I=hmacDigest$2(n,H,I);let Y=new Uint8Array(F+1+N+N);Y.set(I,0),Y[F]=1,Y.set(W,F+1),Y.set(K,F+1+N),H=hmacDigest$2(n,H,Y),I=hmacDigest$2(n,H,I);for(let a=0;a<100;a++){let a=new Uint8Array;for(;a.length<N;){I=hmacDigest$2(n,H,I);let S=new Uint8Array(a.length+I.length);S.set(a,0),S.set(I,a.length),a=S}let S=truncateHash(a.slice(0,N),C);if(S>=1n&&S<C.n)return S;let W=new Uint8Array(F+1);W.set(I,0),W[F]=0,H=hmacDigest$2(n,H,W),I=hmacDigest$2(n,H,I)}throw Error(`RFC 6979: failed to generate valid k after 100 attempts`)}function ecdsaSign(n,a,S,C){let N=getCurve(C),F={x:N.Gx,y:N.Gy},I=bytesToBigInt(a),H=new La(n);H.update(S);let W=new Uint8Array(H.digest()),K=truncateHash(W,N),q=rfc6979(n,I,W,N),Y=scalarMul(q,F,N);if(Y===null)throw Error(`ECDSA: k * G is point at infinity`);let X=mod(Y.x,N.n);if(X===0n)throw Error(`ECDSA: r is zero`);let te=mod(modInverse$2(q,N.n)*(K+X*I),N.n);if(te===0n)throw Error(`ECDSA: s is zero`);let ne=N.byteLength,re=new Uint8Array(ne*2);return re.set(bigIntToBytes(X,ne),0),re.set(bigIntToBytes(te,ne),ne),re}function ecdsaVerify(n,a,S,C,N){let F=getCurve(N),I={x:F.Gx,y:F.Gy},H=F.byteLength;if(a[0]!==4||a.length!==1+H*2)return!1;let W={x:bytesToBigInt(a.slice(1,1+H)),y:bytesToBigInt(a.slice(1+H))};if(S.length!==H*2)return!1;let K=bytesToBigInt(S.slice(0,H)),q=bytesToBigInt(S.slice(H));if(K<1n||K>=F.n||q<1n||q>=F.n)return!1;let Y=new La(n);Y.update(C);let X=truncateHash(new Uint8Array(Y.digest()),F),te=modInverse$2(q,F.n),ne=mod(X*te,F.n),re=mod(K*te,F.n),ie=pointAdd(scalarMul(ne,I,F),scalarMul(re,W,F),F);return ie===null?!1:mod(ie.x,F.n)===K}var Ba=__esmMin(()=>{xa(),ja(),Ra(),za(),__name$1(hmacDigest$2,`hmacDigest`)});function hmacDigest$1(n,a,S){let C=new Hmac(n,a);return C.update(S),C.digest()}function hkdfExtract(n,a,S){return hmacDigest$1(n,S,a)}function hkdfExpand(n,a,S,C,N){let F=Math.ceil(C/N);if(F>255)throw Error(`HKDF cannot generate more than 255 * HashLen bytes`);let I=lt.allocUnsafe(F*N),H=lt.alloc(0);for(let C=1;C<=F;C++)H=hmacDigest$1(n,a,lt.concat([H,S,lt.from([C])])),H.copy(I,(C-1)*N);return lt.from(I.buffer,I.byteOffset,C)}function hkdfSync(n,a,S,C,N){let F=normalizeAlgorithm(n),I=Ma[F];if(!Pa.has(F)||I===void 0)throw TypeError(`Unknown message digest: ${n}`);if(typeof N!=`number`||N<0)throw TypeError(`keylen must be a non-negative number`);let H=toBuffer(a),W=toBuffer(S),K=toBuffer(C),q=hkdfExpand(F,hkdfExtract(F,H,W.length===0?lt.alloc(I,0):W),K,N,I),Y=new ArrayBuffer(q.length);return new Uint8Array(Y).set(q),Y}function hkdf(n,a,S,C,N,F){setTimeout(()=>{try{F(null,hkdfSync(n,a,S,C,N))}catch(n){F(n instanceof Error?n:Error(String(n)))}},0)}var Va=__esmMin(()=>{Fa(),za(),vt(),__name$1(hmacDigest$1,`hmacDigest`)});function hmacDigest(n,a,S){let C=new Hmac(n,a);return C.update(S),C.digest()}function validateParameters(n,a){if(typeof n!=`number`||n<0||!Number.isFinite(n)||n===0)throw TypeError(`iterations must be a positive number`);if(typeof a!=`number`||a<0||!Number.isFinite(a)||a>2147483647)throw TypeError(`keylen must be a positive number`)}function pbkdf2Sync(n,a,S,C,N){validateParameters(S,C);let F=toBuffer(n),I=toBuffer(a),H=normalizeAlgorithm(N||`sha1`),W=Ma[H];if(!Pa.has(H)||W===void 0)throw TypeError(`Unknown message digest: ${N||`sha1`}`);if(C===0)return lt.alloc(0);let K=Math.ceil(C/W),q=lt.allocUnsafe(K*W);for(let n=1;n<=K;n++){let a=lt.allocUnsafe(I.length+4);I.copy(a,0),a.writeUInt32BE(n,I.length);let C=hmacDigest(H,F,a),N=lt.from(C);for(let n=1;n<S;n++){C=hmacDigest(H,F,C);for(let n=0;n<W;n++)N[n]^=C[n]}N.copy(q,(n-1)*W)}return lt.from(q.buffer,q.byteOffset,C)}function pbkdf2(n,a,S,C,N,F){validateParameters(S,C),setTimeout(()=>{try{F(null,pbkdf2Sync(n,a,S,C,N))}catch(n){F(n instanceof Error?n:Error(String(n)))}},0)}var Ha=__esmMin(()=>{Fa(),za(),vt()});function R$2(n,a){return(n<<a|n>>>32-a)>>>0}function salsa20_8(n){let a=new Uint32Array(16);for(let S=0;S<16;S++)a[S]=n[S];for(let n=0;n<4;n++)a[4]^=R$2(a[0]+a[12],7),a[8]^=R$2(a[4]+a[0],9),a[12]^=R$2(a[8]+a[4],13),a[0]^=R$2(a[12]+a[8],18),a[9]^=R$2(a[5]+a[1],7),a[13]^=R$2(a[9]+a[5],9),a[1]^=R$2(a[13]+a[9],13),a[5]^=R$2(a[1]+a[13],18),a[14]^=R$2(a[10]+a[6],7),a[2]^=R$2(a[14]+a[10],9),a[6]^=R$2(a[2]+a[14],13),a[10]^=R$2(a[6]+a[2],18),a[3]^=R$2(a[15]+a[11],7),a[7]^=R$2(a[3]+a[15],9),a[11]^=R$2(a[7]+a[3],13),a[15]^=R$2(a[11]+a[7],18),a[1]^=R$2(a[0]+a[3],7),a[2]^=R$2(a[1]+a[0],9),a[3]^=R$2(a[2]+a[1],13),a[0]^=R$2(a[3]+a[2],18),a[6]^=R$2(a[5]+a[4],7),a[7]^=R$2(a[6]+a[5],9),a[4]^=R$2(a[7]+a[6],13),a[5]^=R$2(a[4]+a[7],18),a[11]^=R$2(a[10]+a[9],7),a[8]^=R$2(a[11]+a[10],9),a[9]^=R$2(a[8]+a[11],13),a[10]^=R$2(a[9]+a[8],18),a[12]^=R$2(a[15]+a[14],7),a[13]^=R$2(a[12]+a[15],9),a[14]^=R$2(a[13]+a[12],13),a[15]^=R$2(a[14]+a[13],18);for(let S=0;S<16;S++)n[S]=n[S]+a[S]>>>0}function blockMix(n,a){let S=2*a*16,C=new Uint32Array(16);for(let a=0;a<16;a++)C[a]=n[S-16+a];let N=new Uint32Array(S);for(let S=0;S<2*a;S++){for(let a=0;a<16;a++)C[a]^=n[S*16+a];salsa20_8(C);for(let n=0;n<16;n++)N[S*16+n]=C[n]}for(let S=0;S<a;S++)for(let a=0;a<16;a++)n[S*16+a]=N[2*S*16+a];for(let S=0;S<a;S++)for(let C=0;C<16;C++)n[(a+S)*16+C]=N[(2*S+1)*16+C]}function roMix(n,a,S){let C=2*S*16,N=Array.from({length:a});for(let C=0;C<a;C++)N[C]=new Uint32Array(n),blockMix(n,S);for(let F=0;F<a;F++){let F=n[C-16]&a-1;for(let a=0;a<C;a++)n[a]^=N[F][a];blockMix(n,S)}}function bytesToWords(n){let a=new Uint32Array(n.length/4);for(let S=0;S<a.length;S++)a[S]=n[S*4]|n[S*4+1]<<8|n[S*4+2]<<16|n[S*4+3]<<24;return a}function wordsToBytes(n){let a=new Uint8Array(n.length*4);for(let S=0;S<n.length;S++)a[S*4]=n[S]&255,a[S*4+1]=n[S]>>8&255,a[S*4+2]=n[S]>>16&255,a[S*4+3]=n[S]>>24&255;return a}function scryptCore(n,a,S,C,N,F){let I=128*C,H=pbkdf2Sync(n,a,1,N*I,`sha256`);for(let n=0;n<N;n++){let a=new Uint8Array(H.buffer,H.byteOffset+n*I,I),N=bytesToWords(a);roMix(N,S,C);let F=wordsToBytes(N);a.set(F)}return pbkdf2Sync(n,H,1,F,`sha256`)}function scryptSync(n,a,S,C){let N=lt.from(n),F=lt.from(a),I=C?.N??16384,H=C?.r??8,W=C?.p??1;if(I<=0||I&I-1)throw Error(`N must be a positive power of 2`);return scryptCore(N,F,I,H,W,S)}function scrypt(n,a,S,C,N){let F={},I;typeof C==`function`?I=C:(F=C,I=N);try{let C=scryptSync(n,a,S,F);setTimeout(()=>I(null,C),0)}catch(n){setTimeout(()=>I(n instanceof Error?n:Error(String(n)),lt.alloc(0)),0)}}var Ua=__esmMin(()=>{Ha(),vt(),__name$1(R$2,`R`)});function pemToDer(n){let a=n.trim().split(/\r?\n/),S=a.findIndex(n=>n.startsWith(`-----BEGIN `));if(S===-1)throw Error(`Invalid PEM: no BEGIN line found`);let C=a[S].match(/^-----BEGIN (.+)-----$/);if(!C)throw Error(`Invalid PEM header format`);let N=C[1],F=a.findIndex((n,a)=>a>S&&n.startsWith(`-----END `));if(F===-1)throw Error(`Invalid PEM: no END line found`);let I=a.slice(S+1,F).join(``),H=lt.from(I,`base64`);return{type:N,der:new Uint8Array(H.buffer,H.byteOffset,H.byteLength)}}function parseTlv(n,a){if(a>=n.length)throw Error(`ASN.1 parse error: unexpected end of data`);let S=n[a++],C,N=n[a++];if(N<128)C=N;else{let S=N&127;if(S===0)throw Error(`ASN.1 parse error: indefinite length not supported`);C=0;for(let N=0;N<S;N++)C=C<<8|n[a++]}let F=n.slice(a,a+C),I=a+C,H={tag:S,data:F};return S===48&&(H.children=parseSequenceChildren(F)),{value:H,next:I}}function parseSequenceChildren(n){let a=[],S=0;for(;S<n.length;){let{value:C,next:N}=parseTlv(n,S);a.push(C),S=N}return a}function parseDer(n){let{value:a}=parseTlv(n,0);return a}function integerToBigInt(n){let a=0;for(;a<n.length-1&&n[a]===0;)a++;let S=0n;for(let C=a;C<n.length;C++)S=S<<8n|BigInt(n[C]);return S}function oidsEqual(n,a){if(n.length!==a.length)return!1;for(let S=0;S<n.length;S++)if(n[S]!==a[S])return!1;return!0}function parseRsaPublicKeyPkcs1(n){let a=n.children;if(!a||a.length<2)throw Error(`Invalid PKCS#1 RSAPublicKey structure`);return{n:integerToBigInt(a[0].data),e:integerToBigInt(a[1].data)}}function parseRsaPrivateKeyPkcs1(n){let a=n.children;if(!a||a.length<6)throw Error(`Invalid PKCS#1 RSAPrivateKey structure`);return{n:integerToBigInt(a[1].data),e:integerToBigInt(a[2].data),d:integerToBigInt(a[3].data),p:integerToBigInt(a[4].data),q:integerToBigInt(a[5].data)}}function parseSubjectPublicKeyInfo(n){let a=n.children;if(!a||a.length<2)throw Error(`Invalid SubjectPublicKeyInfo structure`);let S=a[0];if(!S.children||S.children.length<1)throw Error(`Invalid AlgorithmIdentifier`);let C=S.children[0];if(C.tag!==6||!oidsEqual(C.data,Wa))throw Error(`Unsupported algorithm: only RSA is supported`);let N=a[1];if(N.tag!==3)throw Error(`Expected BIT STRING for public key data`);return parseRsaPublicKeyPkcs1(parseDer(N.data.slice(1)))}function parsePrivateKeyInfo(n){let a=n.children;if(!a||a.length<3)throw Error(`Invalid PrivateKeyInfo structure`);let S=a[1];if(!S.children||S.children.length<1)throw Error(`Invalid AlgorithmIdentifier`);let C=S.children[0];if(C.tag!==6||!oidsEqual(C.data,Wa))throw Error(`Unsupported algorithm: only RSA is supported`);let N=a[2];if(N.tag!==4)throw Error(`Expected OCTET STRING for private key data`);return parseRsaPrivateKeyPkcs1(parseDer(N.data))}function encodeLength(n){if(n<128)return new Uint8Array([n]);let a=[],S=n;for(;S>0;)a.unshift(S&255),S>>=8;return new Uint8Array([128|a.length,...a])}function encodeTlv(n,a){let S=encodeLength(a.length),C=new Uint8Array(1+S.length+a.length);return C[0]=n,C.set(S,1),C.set(a,1+S.length),C}function bigintToAsn1Integer(n){if(n===0n)return encodeTlv(2,new Uint8Array([0]));let a=n.toString(16),S=a.length%2?`0`+a:a,C=[];for(let n=0;n<S.length;n+=2)C.push(parseInt(S.substring(n,n+2),16));return C[0]&128&&C.unshift(0),encodeTlv(2,new Uint8Array(C))}function encodeSequence(n){let a=0;for(let S of n)a+=S.length;let S=new Uint8Array(a),C=0;for(let a of n)S.set(a,C),C+=a.length;return encodeTlv(48,S)}function encodeBitString(n){let a=new Uint8Array(1+n.length);return a[0]=0,a.set(n,1),encodeTlv(3,a)}function encodeOctetString(n){return encodeTlv(4,n)}function encodeOid(n){return encodeTlv(6,n)}function encodeNull(){return new Uint8Array([5,0])}function encodeRsaPublicKeyPkcs1(n){return encodeSequence([bigintToAsn1Integer(n.n),bigintToAsn1Integer(n.e)])}function encodeSubjectPublicKeyInfo(n){return encodeSequence([encodeSequence([encodeOid(Wa),encodeNull()]),encodeBitString(encodeRsaPublicKeyPkcs1(n))])}function encodeRsaPrivateKeyPkcs1(n){let a=n.d%(n.p-1n),S=n.d%(n.q-1n),C=modInverse$1(n.q,n.p);return encodeSequence([bigintToAsn1Integer(0n),bigintToAsn1Integer(n.n),bigintToAsn1Integer(n.e),bigintToAsn1Integer(n.d),bigintToAsn1Integer(n.p),bigintToAsn1Integer(n.q),bigintToAsn1Integer(a),bigintToAsn1Integer(S),bigintToAsn1Integer(C)])}function encodePrivateKeyInfo(n){let a=encodeSequence([encodeOid(Wa),encodeNull()]),S=encodeOctetString(encodeRsaPrivateKeyPkcs1(n));return encodeSequence([bigintToAsn1Integer(0n),a,S])}function derToPem(n,a){let S=lt.from(n).toString(`base64`),C=[`-----BEGIN ${a}-----`];for(let n=0;n<S.length;n+=64)C.push(S.substring(n,n+64));return C.push(`-----END ${a}-----`),C.join(`
|
|
@@ -743,8 +743,8 @@ function load() {
|
|
|
743
743
|
cached = require('@gjsify/node-gi/gi').requireGi(${JSON.stringify(n)}${S});\n }\n return cached;\n}\nexport default new Proxy(Object.create(null), {\n get(_target, prop) { return load()[prop]; },\n has(_target, prop) { return prop in load(); },\n});\n`}function gjsGiNodePlugin(){return{name:`gjsify-gi-node`,resolveId:{order:`pre`,filter:{id:/^gi:\/\//},handler(n){let a=parseGiSpecifier(n);if(a===null)return null;let S=a.version?`@${a.version}`:``;return{id:`${bA}${a.namespace}${S}`}}},load(n){if(!n.startsWith(bA))return null;let a=n.slice(16),S=a.lastIndexOf(`@`);return{code:giNodeShimSource(S===-1?a:a.slice(0,S),S===-1?void 0:a.slice(S+1)),moduleSideEffects:!1}}}}function gjsBuiltinModulesNodePlugin(n){let a=Object.keys(n),S=a.length>0?{id:RegExp(`^(?:${a.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})$`)}:void 0;return{name:`gjsify-builtin-modules-node`,resolveId:{order:`pre`,...S?{filter:S}:{},handler(a){let S=n[a];return S?{id:S,external:!0}:null}}}}var bA,xA=__esmMin(()=>{bA=`\0gjsify-gi-node:`});function flattenAliases$3(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}var SA,CA,setupForNode,wA=__esmMin(()=>{Yb(),tC(),c_(),l_(),Nv(),Fk(),uA(),yA(),xA(),hA(),SA=`@gjsify/node-gi/globals`,CA=[`@gjsify/node-gi/system`,`@gjsify/node-gi/gettext`],setupForNode=async n=>{let a=n.userExternal??[],S=[...Qg,`node-datachannel`,`@gjsify/node-gi`,`@gjsify/node-gi/gi`,SA,...CA,...a],external=n=>!!(S.includes(n)||n===`@gjsify/node-gi`||n.startsWith(`@gjsify/node-gi/`)),C=n.pluginOptions.format??`esm`,N=n.pluginOptions.exclude??[],F=await globToEntryPoints(n.input,N),I=[];n.pluginOptions.nodeGiGlobalsInject&&I.push(SA);let H=wrapInputWithSideEffects(F,I),W=H.input,K={...getAliasesForNode({external}),...n.pluginOptions.aliases,...n.userAliases},q=getBundleDirFromOutput(n.output);return{options:{input:W,platform:`node`,external:S,resolve:{mainFields:C===`esm`?[`module`,`main`,`browser`]:[`main`,`module`,`browser`],conditionNames:C===`esm`?[`require`,`node`,`module`]:[`require`]},transform:{target:`node24`,define:{global:`globalThis`,window:`globalThis`}},output:{...n.output,format:C,sourcemap:!1,banner:void 0,codeSplitting:!1},treeshake:!0},plugins:[...H.plugin?[H.plugin]:[],gjsGiNodePlugin(),gjsBuiltinModulesNodePlugin(o_),gjsImportsEmptyPlugin({emptyGirs:!n.pluginOptions.nodeGiGlobalsInject}),aliasPlugin({entries:flattenAliases$3(K)}),deepkitPlugin({reflection:n.pluginOptions.reflection}),cssAsStringPlugin(),nodeModulesPathRewritePlugin({bundleDir:q})]}},__name$1(flattenAliases$3,`flattenAliases`)});function flattenAliases$2(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}var setupForBrowser,TA=__esmMin(()=>{Yb(),tC(),kk(),c_(),Nv(),yA(),uA(),setupForBrowser=async n=>{let a=[...n.userExternal??[]],S=n.pluginOptions.exclude??[],C=await globToEntryPoints(n.input,S),N={};for(let[n,a]of Object.entries(n_))N[n]=a,N[`node:${n}`]=a;let F={},I={...getDerivedAliasesSync(`browser`),...N,...F,...n.pluginOptions.aliases,...n.userAliases};return{options:{input:C,platform:`browser`,external:a,resolve:{mainFields:[`browser`,`module`,`main`],conditionNames:[`import`,`browser`]},transform:{target:`esnext`,define:{global:`globalThis`,window:`globalThis`}},output:{...n.output,format:`esm`,sourcemap:!1,codeSplitting:!1},treeshake:!0},plugins:[gjsImportsEmptyPlugin(),aliasPlugin({entries:flattenAliases$2(I)}),blueprintPlugin(),deepkitPlugin({reflection:n.pluginOptions.reflection}),cssAsStringPlugin()]}},__name$1(flattenAliases$2,`flattenAliases`)});function isPlatform(n){return EA.includes(n)}function platformResolvePlugin(n={}){let a=n.platform,S=a?[a,`native`]:[`native`];return{name:`gjsify-nativescript-platform-resolve`,resolveId:{order:`pre`,async handler(n,a,C){if(!a||!n.startsWith(`./`)&&!n.startsWith(`../`))return null;let N=DA.exec(n),F=N?N[0]:``,I=F?n.slice(0,-F.length):n;for(let N of S){let S=F&&`${I}.${N}`!=`${I}.${N}${F}`?[`${I}.${N}`,`${I}.${N}${F}`]:[`${I}.${N}`];for(let N of S){if(N===n)continue;let S=await this.resolve(N,a,{skipSelf:!0,...C?.kind?{kind:C.kind}:{}});if(S&&!S.external)return S}}return null}}}}function detectNativescriptPlatform(n=process.env){let a=n.NATIVESCRIPT_PLATFORM??n.NS_PLATFORM;if(a&&isPlatform(a))return a;let S=n.NATIVESCRIPT_BUNDLER_ENV??n.NATIVESCRIPT_WEBPACK_ENV;if(S)try{let n=JSON.parse(S);if(n.android===!0)return`android`;if(n.ios===!0)return`ios`;if(n.visionos===!0)return`visionos`;if(typeof n.platform==`string`&&isPlatform(n.platform))return n.platform}catch{}}function nativescriptPlatformDefines(n,a={}){let S=n===`android`,C=n===`ios`,N=n===`visionos`;return{__ANDROID__:String(S),__IOS__:String(C),__VISIONOS__:String(N),__APPLE__:String(C||N),__DEV__:String(a.dev??!1)}}var EA,DA,OA=__esmMin(()=>{EA=[`android`,`ios`,`visionos`],DA=/\.(tsx?|jsx?|mts|cts|mjs|cjs)$/});function flattenAliases$1(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}var setupForNativescript,kA=__esmMin(()=>{Yb(),tC(),c_(),Nv(),yA(),OA(),setupForNativescript=async n=>{let a=[...n.userExternal??[]],S=n.pluginOptions.exclude??[],C=await globToEntryPoints(n.input,S),N=detectNativescriptPlatform(),F={};for(let[n,a]of Object.entries(r_))F[n]=a,F[`node:${n}`]=a;let I={},H={...getDerivedAliasesSync(`nativescript`),...F,...I,...n.pluginOptions.aliases,...n.userAliases};return{options:{input:C,platform:`browser`,external:a,resolve:{mainFields:[`nativescript`,`module`,`main`],conditionNames:[`import`,`nativescript`]},transform:{target:`esnext`,define:{global:`globalThis`,...nativescriptPlatformDefines(N,{dev:!1})}},output:{...n.output,format:`esm`,sourcemap:!1,codeSplitting:!1},treeshake:!0},plugins:[gjsImportsEmptyPlugin(),platformResolvePlugin({platform:N}),aliasPlugin({entries:flattenAliases$1(H)}),deepkitPlugin({reflection:n.pluginOptions.reflection})]}},__name$1(flattenAliases$1,`flattenAliases`)}),AA=__esmMin(()=>{_A(),wA(),TA(),kA()});function isExternalSpecifier(n){return!(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`/`)||n.startsWith(`\0`)||n.startsWith(`data:`))}function computeCommonRoot(n){let a=n===void 0?[]:typeof n==`string`?[n]:Array.isArray(n)?n:Object.values(n);if(a.length===0)return`src`;let S=a.map(n=>n.split(`/`).filter(Boolean)),C=S[0],N=0;for(;N<C.length;N++){let n=C[N];if(!S.every(a=>a[N]===n))break}if(N===0)return`src`;let F=C.slice(0,N);return S.some(n=>n.length>N)?F.join(`/`):F.slice(0,-1).join(`/`)||`src`}function flattenAliases(n){let a={};for(let[S,C]of Object.entries(n))C&&(a[S]=C);return a}var setupLib,jA=__esmMin(()=>{Yb(),uA(),Xb(),Nv(),setupLib=async n=>{let a=n.pluginOptions.format??n.pluginOptions.library??`esm`,S=n.pluginOptions.exclude??[],C=await globToEntryPoints(n.input,S),N=computeCommonRoot(C),F={...n.pluginOptions.aliases,...n.userAliases};return{options:{input:C,platform:`neutral`,resolve:{mainFields:a===`esm`?[`module`,`main`]:[`main`],conditionNames:a===`esm`?[`module`,`import`]:[`require`]},transform:{target:`esnext`},output:{...n.output,format:a,preserveModules:!0,preserveModulesRoot:N,sourcemap:!1},treeshake:!1},plugins:[aliasPlugin({entries:flattenAliases(F)}),externalsPlugin(isExternalSpecifier,{name:`gjsify-lib-externalize`}),cssAsStringPlugin()]}}}),MA=__esmMin(()=>{jA()});function mimeForExtension(n){return NA[n.toLowerCase()]??`application/octet-stream`}function textLoaderPlugin(n={}){let a=n.loaders??{},S=Object.entries(a),C=S.filter(([,n])=>n===`text`).map(([n])=>n),N=S.filter(([,n])=>n===`dataurl`).map(([n])=>n),F=[...C,...N];if(F.length===0)return null;let I=F.map(n=>n.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)),H=RegExp(`\\.(?:${I.join(`|`)})$`),W=new Map(S.map(([n,a])=>[n.toLowerCase(),a]));return{name:`gjsify-asset-loader`,async load(n){if(!H.test(n))return null;let a=n.lastIndexOf(`.`),S=a>=0?n.slice(a).toLowerCase():``;if((W.get(S)??`text`)===`dataurl`){let a=await readFile$1(n),C=mimeForExtension(S),N=a.toString(`base64`);return{code:`export default ${JSON.stringify(`data:${C};base64,${N}`)};`,moduleType:`js`}}let C=await readFile$1(n,`utf8`);return{code:`export default ${JSON.stringify(C)};`,moduleType:`js`}}}}var NA,PA=__esmMin(()=>{kc(),NA={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".svg":`image/svg+xml`,".ico":`image/x-icon`,".avif":`image/avif`,".bmp":`image/bmp`,".tiff":`image/tiff`,".tif":`image/tiff`,".wasm":`application/wasm`}}),gjsifyPlugin,FA=__esmMin(()=>{AA(),MA(),gjsifyPlugin=async(n,a={})=>{if(a.library)switch(a.library){case`esm`:case`cjs`:return await setupLib({input:n.input,output:n.output,userAliases:n.userAliases,pluginOptions:a});default:throw TypeError(`Unknown library type: `+a.library)}let S=a.app??`gjs`;switch(S){case`gjs`:return await setupForGjs({input:n.input,output:n.output,userExternal:n.userExternal,userBanner:n.userBanner,userAliases:n.userAliases,shebang:n.shebang,pluginOptions:a});case`node`:return await setupForNode({input:n.input,output:n.output,userExternal:n.userExternal,userAliases:n.userAliases,pluginOptions:a});case`browser`:return await setupForBrowser({input:n.input,output:n.output,userExternal:n.userExternal,userAliases:n.userAliases,pluginOptions:a});case`nativescript`:return await setupForNativescript({input:n.input,output:n.output,userExternal:n.userExternal,userAliases:n.userAliases,pluginOptions:a});default:throw TypeError(`Unknown app platform: `+S)}}}),IA=__esmMin(()=>{Kg(),Jb(),AA(),MA(),Fk(),Vk(),uA(),PA(),mA(),yA(),Xb(),OA(),FA(),FA(),c_()});function isPluginByName(n){return typeof n==`object`&&!!n&&typeof n.name==`string`&&!(`apply`in n)&&!(`resolveId`in n)&&!(`load`in n)&&!(`transform`in n)&&!(`renderChunk`in n)&&!(`generateBundle`in n)}async function resolveUserPlugins(n,a,S={}){let C=S.loadModule??defaultLoadModule,N=createRequire(ns(a,`package.json`)),F=[];for(let S of n){if(!isPluginByName(S)){F.push(S);continue}let n;try{n=N.resolve(S.name)}catch(n){throw Error(`gjsify config: failed to resolve plugin "${S.name}" from ${a}. Add it to your project's dependencies, or pass a Plugin object directly. (${n.message})`)}let I=await C(n,S.name),H=S.export??`default`,W=I[H];if(typeof W!=`function`){let n=Object.keys(I).filter(n=>typeof I[n]==`function`);throw Error(`gjsify config: plugin "${S.name}" has no function export "${H}". Available function exports: ${n.length?n.join(`, `):`(none)`}.`)}let K=await W(S.options);if(K==null)throw Error(`gjsify config: plugin "${S.name}" factory returned ${K}. Check the plugin's signature — it should return a Rolldown/Vite plugin object.`);F.push(K)}return F}var defaultLoadModule,LA=__esmMin(()=>{Uo(),ps(),mn(),defaultLoadModule=async n=>await import(pathToFileURL(n).href)}),RA,zA=__esmMin(()=>{RA={"@gjsify/buffer/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/canvas":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`HTMLCanvasElement`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`document`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/document":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`HTMLCanvasElement`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`document`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/font-face":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/image":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`HTMLCanvasElement`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`document`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/location":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/match-media":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/navigator":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`navigator`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/dom-elements/register/observers":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/domparser/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/gamepad/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/buffer":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/encoding":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/microtask":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/process":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/structured-clone":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/timers":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/node-globals/register/url":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`URL`,`URLSearchParams`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/web-globals/register/formdata":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`FormData`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/web-globals/register/performance":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webaudio/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/data-channel":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`Event`,`EventTarget`,`File`,`MessageEvent`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/error":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`Event`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/media":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`Event`,`EventTarget`,`File`,`MediaStream`,`MediaStreamTrack`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/media-devices":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`Event`,`EventTarget`,`File`,`MediaStream`,`MediaStreamTrack`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"@gjsify/webrtc/register/peer-connection":`AbortController.AbortSignal.Blob.Buffer.ByteLengthQueuingStrategy.CountQueuingStrategy.DOMException.Event.EventTarget.File.MediaStream.MediaStreamTrack.MessageEvent.RTCSessionDescription.ReadableStream.TextDecoderStream.TextEncoderStream.TransformStream.WritableStream.atob.btoa.clearTimeout.performance.process.queueMicrotask.setTimeout.structuredClone`.split(`.`),"abort-controller/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"compression-streams/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CompressionStream`,`CountQueuingStrategy`,`DOMException`,`DecompressionStream`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"dom-events/register/custom-events":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"dom-events/register/event-target":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"dom-events/register/ui-events":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"dom-exception/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"eventsource/register":`AbortController.AbortSignal.Blob.Buffer.ByteLengthQueuingStrategy.CompressionStream.CountQueuingStrategy.DOMException.DecompressionStream.Event.EventSource.EventTarget.File.Headers.MessageEvent.ReadableStream.Request.Response.TextDecoderStream.TextEncoderStream.TransformStream.URL.URLSearchParams.WritableStream.atob.btoa.clearTimeout.fetch.performance.process.queueMicrotask.setTimeout.structuredClone`.split(`.`),"fetch/register/fetch":`AbortController.AbortSignal.Blob.Buffer.ByteLengthQueuingStrategy.CompressionStream.CountQueuingStrategy.DOMException.DecompressionStream.File.Headers.ReadableStream.Request.Response.TextDecoderStream.TextEncoderStream.TransformStream.URL.URLSearchParams.WritableStream.atob.btoa.clearTimeout.fetch.performance.process.queueMicrotask.setTimeout.structuredClone`.split(`.`),"fetch/register/xhr":`AbortController.AbortSignal.Blob.Buffer.ByteLengthQueuingStrategy.CompressionStream.CountQueuingStrategy.DOMException.DecompressionStream.Event.EventTarget.File.Headers.ProgressEvent.ReadableStream.Request.Response.TextDecoderStream.TextEncoderStream.TransformStream.URL.URLSearchParams.WritableStream.XMLHttpRequest.XMLHttpRequestUpload.atob.btoa.clearTimeout.fetch.performance.process.queueMicrotask.setTimeout.structuredClone`.split(`.`),"message-channel/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`MessageChannel`,`MessagePort`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/queuing":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/readable":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/text-streams":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/transform":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"web-streams/register/writable":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"webassembly/register/promise":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WebAssembly`,`WritableStream`,`atob`,`btoa`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"webcrypto/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`crypto`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`],"websocket/register":[`AbortController`,`AbortSignal`,`Blob`,`Buffer`,`ByteLengthQueuingStrategy`,`CountQueuingStrategy`,`DOMException`,`File`,`ReadableStream`,`TextDecoderStream`,`TextEncoderStream`,`TransformStream`,`WritableStream`,`atob`,`btoa`,`clearTimeout`,`performance`,`process`,`queueMicrotask`,`setTimeout`,`structuredClone`]}});function expandWithClosure(n,a){let S=new Set(n),C=[...n];for(;C.length>0;){let n=C.pop(),N=BA[n];if(!N)continue;let F=VA[N];if(F)for(let n of F)a.has(n)||BA[n]&&(S.has(n)||(S.add(n),C.push(n)))}return S}function isSubset(n,a){for(let S of n)if(!a.has(S))return!1;return!0}async function applyExcludeGlobals(n,a,S,C,N){if(C?.length)for(let a of C)n.delete(a);let F=detectedToRegisterPaths(n);for(let n of S)F.add(n);if(emitGiBackedDiagnostic(F,n,N),!C?.length)return{detected:n,injectPath:a};let I=N?filterResolvableRegisterPaths(F,N):F;return{detected:n,injectPath:I.size>0?await writeRegisterInjectFile(I,N)??void 0:void 0}}function detectedToRegisterPaths(n){let a=new Set;for(let S of n){let n=BA[S];n&&a.add(n)}return a}function giNamespacesForRegister(n){for(let a of Object.keys(HA))if(n===a||n.startsWith(a+`/`))return HA[a];return null}function describeGiBackedInjection(n,a){let S=new Set,C=new Set;for(let a of n){let n=giNamespacesForRegister(a);if(n){S.add(a);for(let a of n)C.add(a)}}if(S.size===0)return null;let N=[...a].filter(n=>{let a=BA[n];return!!a&&S.has(a)}).sort();return`[gjsify] note: --globals auto injected GTK/GNOME-backed register(s) — this bundle now requires ${[...C].sort().map(n=>`gi://${n}`).join(`, `)} at load.`+(N.length?` Triggered by: ${N.join(`, `)}.`:``)+` If it runs headless / SSR / in a GTK-less container it will throw "Typelib … not found"; drop those globals via excludeGlobals or pin an explicit --globals allowlist (e.g. node).`}function emitGiBackedDiagnostic(n,a,S){if(WA)return;let C=new Set;for(let a of n)giNamespacesForRegister(a)&&(S&&!isRegisterPathResolvable(a,S)||C.add(a));let N=describeGiBackedInjection(C,a);N&&(WA=!0,ke.warn(N))}function isFullConfig(n){return typeof n==`object`&&!!n&&!Array.isArray(n)&&`plugins`in n&&`options`in n}async function detectAutoGlobals(n,a,S,C,N={},F=defaultBundler){let I=N.extraGlobalsList?resolveGlobalsList(N.extraGlobalsList):new Set,H=new Set(N.excludeGlobals??[]),W=N.cwd,K=new Set,q;I.size>0&&(q=await writeRegisterInjectFile(W?filterResolvableRegisterPaths(I,W):I,W)??void 0);let Y=(n.plugins??[]).filter(n=>{let a=n&&typeof n==`object`&&`name`in n?n.name:void 0;return a!==`gjsify`&&a!==`gjsify-orchestrator`});for(let X=1;X<=UA;X++){let te=await S({...a,autoGlobalsInject:q}),ne,re;isFullConfig(te)?(re=te.options,ne=te.plugins):ne=te;let ie=q?appendInjectAsEntry(n.input,q):n.input,ae=n.resolve??re?.resolve,oe=n.external??re?.external,Z=n.transform??re?.transform,se=re?.treeshake,ce=Array.isArray(ne)?ne:[ne],le=await F({rolldownInput:{input:ie,external:oe,resolve:ae,transform:Z,plugins:[...Y,...ce],logLevel:`silent`,...se===void 0?{}:{treeshake:se}},format:n.format??`esm`});if(le.length===0)return{detected:new Set,injectPath:q};let ue=new Set;for(let n=0;n<le.length;n++){let a=le[n]??``;try{for(let n of detectFreeGlobals(a))ue.add(n)}catch(S){if(globalThis.process?.env?.GJSIFY_DEBUG_AUTO_GLOBALS){let S=`/tmp/gjsify-auto-globals-failed-chunk-${n}.mjs`;try{(await Promise.resolve().then(()=>(Zc(),Jc))).writeFileSync(S,a),ke.error(`[gjsify-auto-globals] parse failed on chunk #${n} — wrote ${S} for inspection`)}catch{}}throw S}}if(H.size>0)for(let n of H)ue.delete(n);if(isSubset(ue,K)){if(C){let n=[...K].sort(),a=I.size>0?` (+ ${I.size} extra register module(s))`:``;ke.debug(`[gjsify] --globals auto: converged after ${X-1} iteration(s), ${K.size} global(s)${n.length?`: `+n.join(`, `):``}${a}`)}return applyExcludeGlobals(K,q,I,N.excludeGlobals,W)}let de=N.disableClosureExpansion?ue:expandWithClosure(ue,H);C&&de.size>ue.size&&ke.debug(`[gjsify] --globals auto: closure map expanded ${ue.size} → ${de.size} global(s)`),X>1&&C&&ke.debug("[gjsify] --globals auto: detection grew past the closure-map expansion — the committed register-globals-closure map looks stale. Regenerate via `node packages/infra/cli/scripts/generate-register-closure.mjs`."),K=new Set([...K,...de]);let fe=detectedToRegisterPaths(K);for(let n of I)fe.add(n);if(W&&(fe=filterResolvableRegisterPaths(fe,W)),fe.size===0)return{detected:K,injectPath:void 0};if(q=await writeRegisterInjectFile(fe,W)??void 0,C){let n=[...K].sort();ke.debug(`[gjsify] --globals auto: iteration ${X}, ${K.size} global(s)${n.length?`: `+n.join(`, `):``}`)}}return C&&ke.debug(`[gjsify] --globals auto: hit max iterations (${UA}), using last detected set`),applyExcludeGlobals(K,q,I,N.excludeGlobals,W)}async function detectNodeGiGlobals(n,a,S,C=defaultBundler){let N=await S(a),F,I;isFullConfig(N)?(I=N.options,F=N.plugins):F=N;let H=(n.plugins??[]).filter(n=>{let a=n&&typeof n==`object`&&`name`in n?n.name:void 0;return a!==`gjsify`&&a!==`gjsify-orchestrator`}),W=Array.isArray(F)?F:[F],K=I?{...I}:{};delete K.output;let q;try{q=await C({rolldownInput:{...K,input:n.input,external:n.external??K.external,resolve:n.resolve??K.resolve,transform:n.transform??K.transform,plugins:[...H,...W],logLevel:`silent`},format:n.format??`esm`})}catch(n){return ke.warn(`[gjsify] --app node: could not analyse the bundle for GJS ambient globals (${n instanceof Error?n.message:String(n)}); skipping @gjsify/node-gi/globals injection. If this build uses print/imports/ARGV, add \`import '@gjsify/node-gi/globals'\` to the entry or pass --globals.`),!1}for(let n of q)if(detectGjsAmbientGlobals(n).size>0)return!0;return!1}function appendInjectAsEntry(n,a){return n===void 0?[a]:typeof n==`string`?[n,a]:Array.isArray(n)?[...n,a]:{...n,__gjsify_inject:a}}var defaultBundler,BA,VA,HA,UA,WA,GA=__esmMin(()=>{Ae(),Vb(),Gb(),Fb(),zA(),defaultBundler=async({rolldownInput:n,format:a})=>{let S=await(await import(`rolldown`)).rolldown(n);try{let n=await S.generate({format:a,minify:!1,sourcemap:!1}),C=[];for(let a of n.output)a.type===`chunk`&&C.push(a.code);return C}finally{await S.close()}},BA=Nb,VA=RA,HA=Pb,UA=5,WA=!1}),KA=__esmMin(()=>{Gb(),Vb(),GA()});function findPnpRoot(n){let a=n;for(;;){if(existsSync(ns(a,`.pnp.cjs`)))return a;let n=as(a);if(n===a)return null;a=n}}async function loadPnpApi(){try{let n=await import(`pnpapi`);return n.default??n}catch{return null}}async function pnpPlugin(n={}){let a=n.issuerUrl??import.meta.url;if(!findPnpRoot(process.cwd()))return null;let S=await loadPnpApi();if(S===null)return null;let C=fileURLToPath(a),N=createRequire(C),F=n.relayPackages??[`@gjsify/node-polyfills`,`@gjsify/web-polyfills`],I=[];for(let n of F)try{I.push(N.resolve(`${n}/package.json`))}catch{}return{name:`gjsify-pnp`,resolveId:{order:`pre`,async handler(n,a){if(n.startsWith(`.`)||n.startsWith(`/`))return null;if(n.startsWith(`gi://`))return{id:n,external:!0};if(n.startsWith(`node:`))return await this.resolve(n,a,{skipSelf:!0});if(!a)return null;let N=a.startsWith(`file://`)?fileURLToPath(a):a;try{let a=S.resolveRequest(n,N);return a===null?null:{id:a}}catch(a){if(!isUndeclaredDependency(a))throw a;try{let a=S.resolveRequest(n,C);if(a!==null)return{id:a}}catch(n){if(!isUndeclaredDependency(n))throw n}for(let a of I)try{let C=S.resolveRequest(n,a);if(C!==null)return{id:C}}catch(n){if(!isUndeclaredDependency(n))throw n}return null}}},async load(n){if(!n.includes(`/.yarn/`)&&!n.includes(`.zip/`))return null;try{return{code:await readFile$1(n,`utf8`)}}catch(a){let S=a instanceof Error?a.message:String(a);this.error(`gjsify-pnp: failed to read ${n}: ${S}`)}}}}function isUndeclaredDependency(n){return typeof n==`object`&&!!n&&`pnpCode`in n&&n.pnpCode===`UNDECLARED_DEPENDENCY`}var qA=__esmMin(()=>{Uo(),mn(),ps(),Zc(),kc()});function normalizeBundlerOptions(n){let a=n.bundler??{},S=a;if(typeof a.define==`object`&&a.define!==null){YA||(YA=!0,ke.warn(`[gjsify] WARNING: 'bundler.define' is not a valid Rolldown option and would be silently ignored — it has been auto-mapped to 'bundler.transform.define'. Move 'define' under 'bundler.transform.define' in your config to suppress this warning and avoid a ReferenceError at GJS load time.`));let{define:n,...C}=a;S={...C,transform:{...C.transform,define:{...n,...C.transform?.define}}}}if(!n.esbuild)return S;JA||(JA=!0,ke.warn(`[gjsify] DEPRECATION: the 'esbuild' config key is deprecated and will be removed in 0.5.0. Rename it to 'bundler' (typed as RolldownOptions). See the migration notes in the gjsify CHANGELOG.`));let C=legacyEsbuildToRolldown(n.esbuild),N={...C,...S};return(C.output||S.output)&&(N.output={...C.output,...S.output}),(C.transform||S.transform)&&(N.transform={...C.transform,...S.transform},(C.transform?.define||S.transform?.define)&&(N.transform.define={...C.transform?.define,...S.transform?.define})),(C.resolve||S.resolve)&&(N.resolve={...C.resolve,...S.resolve}),N}function legacyEsbuildToRolldown(n){let a={},S={},C={},N={};return n.outfile!==void 0&&(S.file=n.outfile),n.outdir!==void 0&&(S.dir=n.outdir),n.format!==void 0&&(S.format=n.format),n.minify!==void 0&&(S.minify=n.minify),n.sourcemap!==void 0&&(S.sourcemap=n.sourcemap===`inline`?`inline`:!!n.sourcemap),n.banner?.js!==void 0&&(S.banner=n.banner.js),n.target!==void 0&&(C.target=Array.isArray(n.target)?n.target.join(`,`):n.target),n.define!==void 0&&(C.define=n.define),n.mainFields!==void 0&&(N.mainFields=n.mainFields),n.conditions!==void 0&&(N.conditionNames=n.conditions),n.external!==void 0&&(a.external=n.external),n.platform!==void 0&&(a.platform=n.platform),Object.keys(S).length>0&&(a.output=S),Object.keys(C).length>0&&(a.transform=C),Object.keys(N).length>0&&(a.resolve=N),a}function mergeBundlerOptions(n,a){let{input:S,external:C,...N}=a,F={...n,...N};return(n.output||a.output)&&(F.output={...n.output,...a.output}),(n.transform||a.transform)&&(F.transform={...n.transform,...a.transform},(n.transform?.define||a.transform?.define)&&(F.transform.define={...n.transform?.define,...a.transform?.define})),(n.resolve||a.resolve)&&(F.resolve={...n.resolve,...a.resolve}),F}var JA,YA,XA=__esmMin(()=>{Ae(),JA=!1,YA=!1});function inputSourceDirs(n,a){let S=[],push=n=>{typeof n==`string`&&n.length>0&&S.push(n)};typeof n==`string`?push(n):Array.isArray(n)?n.forEach(push):n&&typeof n==`object`&&Object.values(n).forEach(push);let C=$o(a),N=new Set;for(let n of S){let a=n.replace(/\\/g,`/`),S=a.search(/[*?{}[\]()!+@]/),F=S===-1?a:a.slice(0,S);F=S===-1?ss(F)?as(F):F:F.replace(/\/[^/]*$/,``);let I=$o(C,F||`.`);I!==C&&N.add(I)}return[...N]}function isInsideOrEqual(n,a){let S=rs(a,n);return S===``||!S.startsWith(`..`)&&!ts(S)}function isOutdirInsideSource(n,a,S){let C=$o(S,n);return a.some(n=>isInsideOrEqual(C,n))}function libraryOutputLeakError(n){return Error(`gjsify build --library: refusing to write output into "${n}", which holds the input source — a library build there produces src/*.js duplicates, *2.js, a _virtual/ helper dir, and a nested preserve-modules tree, silently corrupting the sources. This output dir was derived from package.json "main"/"module" pointing at a source path. Fix it by pointing "main"/"module" at the built library (e.g. lib/index.js) or by passing an explicit --outdir <dir> outside the source tree.`)}var ZA=__esmMin(()=>{ps()});function detectHtmlEntry(n){if(!n)return null;let isHtml=n=>typeof n==`string`&&/\.html?$/i.test(n);if(typeof n==`string`)return isHtml(n)?n:null;if(Array.isArray(n))return n.length===1&&isHtml(n[0])?n[0]:null;if(typeof n==`object`){let a=Object.values(n);return a.length===1&&isHtml(a[0])?a[0]:null}return null}function parseHtmlEntry(n,a){for(let S of a.matchAll(QA)){let a=S[0],C=$A.exec(a);if(!C)continue;let N=C[1];if(!ej.test(N))return{moduleEntry:ts(N)?N:$o(as(n),N),scriptTag:a,scriptSrc:N}}throw Error(`gjsify build: ${n} has no local <script type="module" src="…"> to bundle. Add one pointing at your app entry (e.g. <script type="module" src="./main.ts">).`)}function emitBrowserHtml(n){let{htmlSource:a,scriptTag:S,scriptSrc:C,jsOutPath:N,outHtmlPath:F}=n,I=rs(as(F),N).split(/[\\/]/).join(`/`);I.startsWith(`.`)||(I=`./${I}`);let H=S.replace($A,n=>n.replace(C,I));return a.replace(S,H)}function htmlOutPathFor(n){return $o(as(n),`index.html`)}var QA,$A,ej,tj=__esmMin(()=>{ps(),QA=/<script\b[^>]*\btype\s*=\s*["']module["'][^>]*>(?:<\/script>)?/gi,$A=/\bsrc\s*=\s*["']([^"']+)["']/i,ej=/^(?:https?:)?\/\//i});function isUnsafeDefaultOutput(n){if(/\.[cm]?tsx?$/i.test(n))return!0;let a=n.replace(/\\/g,`/`);return!!/(?:^|\/)src\//.test(a)}async function buildPnpPlugin(){return pnpPlugin({issuerUrl:import.meta.url})}function shortHash(n){let a=5381;for(let S=0;S<n.length;S++)a=(a<<5)+a+n.charCodeAt(S)>>>0;return a.toString(16).padStart(8,`0`)}function isTruthyEnv(n){return n===`1`||n===`true`||n===`yes`}async function newestLockfileMtime(n){let a=0;for(let S of rj)try{let C=await stat$1(ns(n,S));C.mtimeMs>a&&(a=C.mtimeMs)}catch{}return a}async function runOneLibraryBuild(n){let a=await gjsifyPlugin({input:n.userBundler.input,output:n.output,userAliases:n.userAliases},n.pluginOpts);return await runBundle({...mergeBundlerOptions(a.options,n.userBundler),plugins:[...n.pnpPlugins,...a.plugins]})}var nj,rj,ij,aj=__esmMin(()=>{Ae(),Hg(),IA(),zg(),LA(),KA(),qA(),ps(),mn(),kc(),XA(),ZA(),tj(),nj=`#!/usr/bin/env -S gjs -m`,rj=[`gjsify-lock.json`,`package-lock.json`,`yarn.lock`,`pnpm-lock.yaml`],ij=class BuildAction{configData;constructor(n={}){this.configData=n}async buildLibrary(){let{verbose:n,library:a,typescript:S,exclude:C,aliases:N}=this.configData,F=a??{},I=normalizeBundlerOptions(this.configData),H=process.cwd(),W=inputSourceDirs(I.input,H),assertDerivedOutdirSafe=n=>{if(n&&isOutdirInsideSource(n,W,H))throw libraryOutputLeakError(n)},K=F.module?as(F.module):void 0,q=F.main?as(F.main):void 0,Y=F.module?ss(F.module):`.js`,X=F.main?ss(F.main):`.js`,te=K&&q&&K!==q,ne=await buildPnpPlugin(),re=ne?[ne]:[],ie=[];if(te){assertDerivedOutdirSafe(K),assertDerivedOutdirSafe(q);let a=K.includes(`/cjs`)||Y===`.cjs`?`cjs`:`esm`;ie.push(await runOneLibraryBuild({pluginOpts:{debug:n,library:a,exclude:C,reflection:S?.reflection,jsExtension:Y},userBundler:I,output:{dir:K},userAliases:N,pnpPlugins:re}));let F=q.includes(`/cjs`)||X===`.cjs`?`cjs`:`esm`;ie.push(await runOneLibraryBuild({pluginOpts:{debug:n,library:F,exclude:C,reflection:S?.reflection,jsExtension:X},userBundler:I,output:{dir:q},userAliases:N,pnpPlugins:re}))}else{let a=I.output?.dir,H=I.output?.file??F.module??F.main,W=H?ss(H):`.js`,K=a??(H?as(H):void 0);a===void 0&&assertDerivedOutdirSafe(K);let q=I.output?.format??(K?.includes(`/cjs`)||W===`.cjs`?`cjs`:`esm`);ie.push(await runOneLibraryBuild({pluginOpts:{debug:n,library:q,exclude:C,reflection:S?.reflection,jsExtension:W},userBundler:I,output:{dir:K},userAliases:N,pnpPlugins:re}))}return ie}parseGlobalsValue(n){if(n===void 0)return{autoMode:!0,extras:``};if(n===`none`||n===``)return{autoMode:!1,extras:``};let a=n.split(`,`).map(n=>n.trim()).filter(Boolean);return{autoMode:a.includes(`auto`),extras:a.filter(n=>n!==`auto`).join(`,`)}}async resolveGlobalsInject(n,a,S){if(n!==`gjs`||!a)return;let C=resolveGlobalsList(a);if(C.size===0)return;let N=await writeRegisterInjectFile(C,process.cwd());return S&&N&&ke.debug(`[gjsify] globals: injected ${C.size} register module(s) from --globals ${a}`),N??void 0}async applyShebang(n,a,S){if(!a){S&&ke.warn(`[gjsify] --shebang skipped: no single outfile (use --outfile for executables)`);return}let C=n===`node`?fA:nj,N=resolveShebangLine(this.configData.shebang,C)??C,F=await readFile$1(a,`utf-8`);F.startsWith(`#!`)?S&&ke.debug(`[gjsify] --shebang skipped: ${a} already starts with a shebang`):await writeFile$1(a,N+`
|
|
744
744
|
`+F),await chmod$1(a,493),S&&ke.debug(`[gjsify] --shebang: wrote ${N} + chmod 0o755 to ${a}`)}async applyBrowserHtml(n,a,S){let C=$o(a),N=htmlOutPathFor(C),F=emitBrowserHtml({htmlSource:n.htmlSource,scriptTag:n.scriptTag,scriptSrc:n.scriptSrc,jsOutPath:C,outHtmlPath:N});await mkdir$1(as(N),{recursive:!0}),await writeFile$1(N,F),S&&ke.debug(`[gjsify] --app browser: wrote ${N}`)}async loadPluginViaGjsBundle(n,a,S){let C=await this.bundlePluginForGjs(n,a,S);try{return await import(pathToFileURL(C).href)}catch(n){throw Error(`gjsify config: failed to import the GJS bundle for plugin "${a}" (bundled to ${C}). (${n.message})`)}}async bundlePluginForGjs(n,a,S){let C=process.cwd(),N=ns(C,`node_modules`,`.cache`,`gjsify`,`plugins`),F=ns(N,`${a.replace(/[^a-zA-Z0-9._-]/g,`_`)}-${shortHash(n)}.mjs`);if(!isTruthyEnv(process.env.GJSIFY_NO_PLUGIN_CACHE)&&await this.isPluginBundleFresh(F,n,C))return S&&ke.debug(`[gjsify] plugin "${a}": reusing cached GJS bundle ${F}`),F;S&&ke.debug(`[gjsify] plugin "${a}": bundling for GJS → ${F}`);try{await mkdir$1(N,{recursive:!0}),await new BuildAction({verbose:S,bundler:{input:n,output:{file:F}}}).buildApp(`gjs`,{preserveDefaultExport:!0})}catch(n){throw Error(`gjsify config: failed to bundle plugin "${a}" for GJS (needed because GJS can't import packages that use exports-map subpaths directly; cache dir ${N}). (${n.message})`)}return F}async isPluginBundleFresh(n,a,S){try{let C=await stat$1(n),N=await stat$1(a),F=await newestLockfileMtime(S);return C.mtimeMs>=Math.max(N.mtimeMs,F)}catch{return!1}}async buildApp(n=`gjs`,a={}){let{verbose:S,typescript:C,exclude:N,library:F,aliases:I,excludeGlobals:H}=this.configData,W=normalizeBundlerOptions(this.configData),K=null;if(n===`browser`){let n=detectHtmlEntry(W.input);if(n){let a=await readFile$1(n,`utf-8`),{moduleEntry:S,scriptTag:C,scriptSrc:N}=parseHtmlEntry(n,a);W.input=S,K={htmlSource:a,scriptTag:C,scriptSrc:N}}}let q=W.output?.format??(W.output?.file?.endsWith(`.cjs`)?`cjs`:`esm`),Y=q===`iife`?`esm`:q,X=W.output?.file,te=W.output?.dir;if(!X&&!te&&(F?.main||F?.module)){let n=Y===`cjs`?F.main??F.module:F.module??F.main;if(n&&isUnsafeDefaultOutput(n))throw Error(`gjsify build: refusing to default --outfile to ${n} (would overwrite a TypeScript source file). Pass --outfile/--outdir explicitly, or set "gjsify.bundler.output.file" in package.json.`);X=n}if(K&&!X)throw Error(`gjsify build: an .html entry needs an explicit --outfile (e.g. --outfile dist-app/app.js); the emitted index.html is written beside it.`);let{consoleShim:ne,globals:re}=this.configData,ie=Array.isArray(W.external)?W.external:void 0,ae=typeof W.output?.banner==`string`?W.output.banner:void 0,oe={debug:S,app:n,format:Y,exclude:N,reflection:C?.reflection,consoleShim:ne,...I?{aliases:I}:{},...a.preserveDefaultExport?{preserveDefaultExport:!0}:{}},{autoMode:Z,extras:se}=this.parseGlobalsValue(re),ce=await buildPnpPlugin(),le=ce?[ce]:[],ue=textLoaderPlugin({loaders:this.configData.loaders}),de=ue?[ue]:[];if(W.plugins?.length){let n=await resolveUserPlugins(W.plugins,process.cwd(),isGjs()?{loadModule:(n,a)=>this.loadPluginViaGjsBundle(n,a,S)}:{});de.push(...n)}if(n===`gjs`&&Z){let gjsifyPluginFactory=async n=>{let a=await gjsifyPlugin({input:W.input,output:{file:X,dir:te},userExternal:ie,userBanner:ae,userAliases:I,shebang:this.configData.shebang},n);return{options:a.options,plugins:a.plugins}},{injectPath:n}=await detectAutoGlobals({input:W.input,plugins:[...le,...de],external:W.external,transform:W.transform,format:Y},oe,gjsifyPluginFactory,S,{extraGlobalsList:se,excludeGlobals:H,cwd:process.cwd()},bundleToChunks);oe.autoGlobalsInject=n}else if(n===`node`&&Z){let gjsifyPluginFactory=async n=>{let a=await gjsifyPlugin({input:W.input,output:{file:X,dir:te},userExternal:ie,userBanner:ae,userAliases:I,shebang:this.configData.shebang},n);return{options:a.options,plugins:a.plugins}};await detectNodeGiGlobals({input:W.input,plugins:[...le,...de],external:W.external,transform:W.transform,format:Y},oe,gjsifyPluginFactory,bundleToChunks)&&(oe.nodeGiGlobalsInject=!0)}else se&&(oe.autoGlobalsInject=await this.resolveGlobalsInject(n,se,S));let fe=await gjsifyPlugin({input:W.input,output:{file:X,dir:te},userExternal:ie,userBanner:ae,userAliases:I,shebang:this.configData.shebang},oe),pe={...mergeBundlerOptions(fe.options,W),plugins:[...le,...de,...fe.plugins]};if(a.watch)return await this.runWatchLoop(pe,n,X,S),[];let me=await runBundle(pe);return(n===`gjs`||n===`node`)&&this.configData.shebang&&await this.applyShebang(n,X,S),n===`browser`&&K&&X&&await this.applyBrowserHtml(K,X,S),[me]}async runWatchLoop(n,a,S,C){let N=await runWatch(n),F=new Promise(n=>{N.on(`close`,()=>n())}),I=!1,shutdown=async()=>{if(!I){I=!0,ke.log(`
|
|
745
745
|
[gjsify build --watch] stopping watcher…`);try{await N.close()}catch(n){ke.error(`[gjsify build --watch] watcher close error:`,n)}}};process.on(`SIGINT`,shutdown),process.on(`SIGTERM`,shutdown),N.on(`event`,async n=>{switch(n.code){case`START`:C&&ke.log(`[gjsify build --watch] rebuild start`);break;case`BUNDLE_START`:ke.log(`[gjsify build --watch] building…`);break;case`BUNDLE_END`:ke.log(`[gjsify build --watch] built in ${n.duration}ms`);try{(a===`gjs`||a===`node`)&&this.configData.shebang&&await this.applyShebang(a,S,C)}finally{await n.result.close()}break;case`END`:ke.log(`[gjsify build --watch] waiting for changes…`);break;case`ERROR`:ke.error(`[gjsify build --watch] build failed:`,n.error?.message??n.error),C&&n.error?.stack&&ke.error(n.error.stack);try{await n.result.close()}catch{}break}}),C&&N.on(`change`,(n,a)=>{ke.log(`[gjsify build --watch] ${a.event}: ${n}`)}),await F}async start(n={app:`gjs`}){if(n.library){if(n.watch)throw Error(`gjsify build: --watch is not supported with --library (library mode would emit watcher rebuilds for every produced format; use --app gjs|node|browser instead).`);return await this.buildLibrary()}return await this.buildApp(n.app,{watch:n.watch})}}}),oj,sj=__esmMin(()=>{Fg(),aj(),oj={command:`build [entryPoints..]`,description:`Build and bundle your Gjs project`,builder:n=>n.option(`entry-points`,{description:`The entry points you want to bundle. Defaults to bundler.input from package.json#gjsify or .gjsifyrc.js, falling back to src/index.ts when neither is set.`,array:!0,type:`string`,normalize:!0,defaultDescription:`src/index.ts (fallback)`,coerce:n=>[...new Set(n)]}).option(`exclude`,{description:`An array of glob patterns to exclude entry-points and aliases`,array:!0,type:`string`,normalize:!0,default:[]}).option(`verbose`,{description:`Switch on the verbose mode`,type:`boolean`,normalize:!0,default:!1}).option(`app`,{description:`Use this if you want to build an application, the platform node is usually only used for tests`,type:`string`,choices:[`gjs`,`node`,`browser`,`nativescript`],normalize:!0,default:`gjs`}).option(`format`,{description:`Override the default output format`,type:`string`,choices:[`iife`,`esm`,`cjs`],normalize:!0}).option(`minify`,{description:`Minify the bundled output. Defaults to true; use --no-minify to emit pretty-printed code (e.g. for debugging or readable bundle review).`,type:`boolean`,normalize:!0,defaultDescription:`true`}).option(`library`,{description:`Use this if you want to build a library for Gjsify`,type:`boolean`,normalize:!0,default:!1}).option(`outfile`,{alias:`o`,description:`Sets the output file name for the build operation. If no outfile is specified, the outfile will be parsed from the package.json. Only used if application mode is active`,type:`string`,normalize:!0}).option(`outdir`,{alias:`d`,description:`Sets the output directory for the build operation. If no outdir is specified, the outdir will be parsed from the package.json. Only used if library mode is active`,type:`string`,normalize:!0}).option(`reflection`,{alias:`r`,description:`Enables TypeScript types on runtime using Deepkit's type compiler`,type:`boolean`,normalize:!0,default:!1}).option(`log-level`,{description:`The log level can be changed to prevent esbuild from printing warning and/or error messages to the terminal`,type:`string`,choices:[`silent`,`error`,`warning`,`info`,`debug`,`verbose`],normalize:!0,default:`warning`}).option(`console-shim`,{description:`Inject a console shim into GJS builds for clean output without the GLib prefix and with working ANSI colors. Use --no-console-shim to disable. Only applies to GJS app builds.`,type:`boolean`,normalize:!0,default:!0}).option(`globals`,{description:"Comma-separated list of global identifiers, 'auto' (default) to detect automatically from the bundled output, or 'none' to disable. The 'auto' token may be combined with explicit identifiers/groups (e.g. 'auto,dom') for cases where the detector cannot statically see a global because it's accessed via indirection. Each identifier is mapped to the corresponding `@gjsify/<pkg>/register` module and injected into the bundle. See the CLI Reference docs for the full list of known identifiers. Only applies to GJS app builds.",type:`string`,normalize:!0}).option(`shebang`,{description:"Prepend a target-appropriate shebang to the output and mark it executable (chmod 755): `#!/usr/bin/env -S gjs -m` for --app gjs, `#!/usr/bin/env node` for --app node. Applies to GJS and Node app builds with a single --outfile. Default: false (use --shebang to enable, or set `shebang: true` in `.gjsifyrc.js`).",type:`boolean`,normalize:!0}).option(`external`,{description:"Module names that should NOT be bundled — EXACT package names only, matched literally on both bundler engines (no globs). Repeat the flag or pass a comma-separated list (e.g. --external typedoc,prettier). Appended to the per-app built-in externals; register subpaths (`<pkg>/register[/…]`) are always force-inlined for --app gjs regardless of this flag.",array:!0,type:`string`,default:[],coerce:n=>n.flatMap(n=>n.split(`,`).map(n=>n.trim()).filter(Boolean))}).option(`define`,{description:`Substitute compile-time constants. Each entry is KEY=VALUE where VALUE is a JS expression (string literals must be quoted: --define VERSION='"1.2.3"'). Repeat the flag or pass comma-separated. See https://esbuild.github.io/api/#define`,array:!0,type:`string`,default:[]}).option(`alias`,{description:`Map module specifiers at bundle time. Each entry is FROM=TO (e.g. --alias typedoc=@gjsify/empty). Layered on top of the built-in alias map. Useful for stubbing heavy deps the test scenario never executes.`,array:!0,type:`string`,default:[],coerce:n=>n.flatMap(n=>n.split(`,`).map(n=>n.trim()).filter(Boolean))}).option(`exclude-globals`,{description:`Comma-separated global identifiers to remove from auto-detection results. Use for false positives from dead browser-compat code whose polyfills require unavailable native libraries (e.g. --exclude-globals fetch,XMLHttpRequest).`,type:`string`,normalize:!0}).option(`watch`,{alias:`w`,description:"Watch source files and rebuild on change. Logs each rebuild with duration; clean SIGINT shutdown. Only valid with --app gjs|node|browser (rejected with --library). Requires the npm `rolldown` engine — run under Node, not the GJS-bundled CLI.",type:`boolean`,normalize:!0,default:!1}),handler:async n=>{await new ij(await new Config().forBuild(n)).start({library:n.library,app:n.app,watch:n.watch})}}});function nodeArchToLinuxArch(n){return{x64:`x86_64`,arm64:`aarch64`,arm:`armv7`,ia32:`i686`}[n]??n}function readPackageJson$3(n){try{return JSON.parse(readFileSync(n,`utf-8`))}catch{return null}}function scanNodeModules(n,a){let S=[];if(!existsSync(n))return S;let C;try{C=readdirSync(n)}catch{return S}for(let N of C)if(!N.startsWith(`.`))if(N.startsWith(`@`)){let C=ns(n,N),F;try{F=readdirSync(C)}catch{continue}for(let n of F){let F=checkPackage(ns(C,n),`${N}/${n}`,a);F&&S.push(F)}}else{let C=checkPackage(ns(n,N),N,a);C&&S.push(C)}return S}function checkPackage(n,a,S){let C=readPackageJson$3(ns(n,`package.json`));if(!C)return null;let N=C.gjsify;if(!N||typeof N!=`object`)return null;let F=N.prebuilds;if(typeof F!=`string`)return null;let I=ns(n,F,`linux-${S}`);return existsSync(I)?{name:a,prebuildsDir:I}:null}function detectNativePackages(n){let a=nodeArchToLinuxArch(process.arch),S=[],C=new Set,N=$o(n);for(;;){let n=ns(N,`node_modules`);if(existsSync(n))for(let N of scanNodeModules(n,a))C.has(N.name)||(C.add(N.name),S.push(N));let F=$o(N,`..`);if(F===N)break;N=F}return S}function buildNativeEnv(n){let a=n.map(n=>n.prebuildsDir),S=process.env.LD_LIBRARY_PATH??``,C=process.env.GI_TYPELIB_PATH??``;return{LD_LIBRARY_PATH:[...a,...S?[S]:[]].join(`:`),GI_TYPELIB_PATH:[...a,...C?[C]:[]].join(`:`)}}var cj=__esmMin(()=>{Zc(),ps(),__name$1(readPackageJson$3,`readPackageJson`)}),lj=__exportAll$3({computeNativeEnvForBundle:()=>computeNativeEnvForBundle,runGjsBundle:()=>runGjsBundle});function computeNativeEnvForBundle(n,a=process.cwd()){let S=$o(n),C=detectNativePackages(a),N=detectNativePackages(as(S)),F=new Set(C.map(n=>n.name)),I=buildNativeEnv([...C,...N.filter(n=>!F.has(n.name))]);return{env:I,envPrefix:Object.entries(I).filter(([,n])=>n!==void 0&&n!==``).map(([n,a])=>`${n}=${a}`).join(` `)}}async function runGjsBundle(n,a=[],S={}){let{env:C,envPrefix:N}=computeNativeEnvForBundle(n),F={...process.env,...C},I=[`-m`,n,...a],H=[`gjs`,...I.map(n=>n.includes(` `)?`"${n}"`:n)].join(` `);ke.error(`$ ${N?`${N} `:``}${H}`);let W=spawn(`gjs`,I,{env:F,stdio:`inherit`});await new Promise((n,a)=>{W.on(`close`,S=>{S===0?n():a(Error(`gjs exited with code ${S}`))}),W.on(`error`,a)}).catch(n=>{ke.error(n.message),process.exit(1)}),S.exitOnSuccess&&process.exit(0)}var uj=__esmMin(()=>{Ae(),cC(),ps(),cj()});async function buildTestBundle(n,a,S,C){let N=await new Config().forBuild({entryPoints:[n],outfile:a,app:S,verbose:C??!1,logLevel:`warning`,exclude:[]});N.library={...N.library},N.bundler={...N.bundler,input:[n],output:{...N.bundler?.output,file:a}},await new ij(N).start({app:S,library:!1})}async function runTestBundle(n,a){if(a===`gjs`){await runGjsBundle(n);return}await new Promise((a,S)=>{let C=spawn(`node`,[n],{stdio:`inherit`});C.on(`error`,S),C.on(`exit`,n=>{n===0?a():S(Error(`node exited with code ${n}`))})})}function isFresh(n,a){if(!existsSync(n))return!1;let S=statSync(n).mtimeMs,C=as(a);try{return S>=newestMtimeUnder(existsSync(C)?C:a)}catch{return!1}}function newestMtimeUnder(n){let a=statSync(n);if(a.isFile())return a.mtimeMs;let S=a.mtimeMs;for(let a of readdirSync(n,{withFileTypes:!0})){if(a.name===`node_modules`||a.name===`dist`||a.name===`lib`||a.name.startsWith(`.`))continue;let C=newestMtimeUnder(ns(n,a.name));C>S&&(S=C)}return S}var dj,fj=__esmMin(()=>{Ae(),Zc(),ps(),cC(),Fg(),aj(),uj(),dj={command:`test`,description:"Build + run the package’s `src/test.mts` suite on GJS and Node and aggregate the results. Replaces the per-package `build:test:{gjs,node}` + `test:{gjs,node}` script boilerplate.",builder:n=>n.option(`runtime`,{description:`Target runtime. Default: both.`,type:`string`,choices:[`gjs`,`node`,`all`],default:`all`}).option(`entry`,{description:"Path to the test entry. Default: `src/test.mts` (or `gjsify.test.entry`).",type:`string`,normalize:!0}).option(`outdir`,{description:"Output directory for the built test bundles. Default: `dist/`.",type:`string`,normalize:!0}).option(`rebuild`,{description:`Always rebuild the test bundles, even when they look up-to-date.`,type:`boolean`,default:!1}).option(`build`,{description:`Build before running. Default: true (use --no-build to skip when bundles already exist).`,type:`boolean`,default:!0}).option(`verbose`,{description:`Print resolved entry/outdir + per-step timing.`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=(await new Config().forBuild({}).catch(()=>({}))).test??{},C=$o(a,n.entry??S.entry??`src/test.mts`),N=$o(a,n.outdir??S.outdir??`dist`);existsSync(C)||(ke.error(`[gjsify test] no test entry at ${rs(a,C)} — add an \`src/test.mts\` that aggregates your \`@gjsify/unit\` suites, or set \`gjsify.test.entry\` in package.json.`),process.exit(1));let F=n.runtime===`gjs`?[`gjs`]:n.runtime===`node`?[`node`]:S.runtimes&&S.runtimes.length>0?S.runtimes:[`gjs`,`node`],I=[];for(let S of F){let F=ns(N,`test.${S}.mjs`);if(n.build!==!1)if(n.rebuild||!isFresh(F,C)){let N=Date.now();n.verbose&&ke.log(`[gjsify test] building → ${rs(a,F)} (—app ${S})`);try{await buildTestBundle(C,F,S,n.verbose),n.verbose&&ke.log(`[gjsify test] built ${S} in ${Date.now()-N}ms`)}catch(n){ke.error(`[gjsify test] build failed for ${S}:`,n.message),I.push({runtime:S,ok:!1,durationMs:0,error:`build failed`});continue}}else n.verbose&&ke.log(`[gjsify test] ${S}: bundle is up-to-date — skipping build (use --rebuild to force)`);else if(!existsSync(F)){ke.error(`[gjsify test] --no-build but ${rs(a,F)} doesn't exist. Build first or drop --no-build.`),I.push({runtime:S,ok:!1,durationMs:0,error:`no bundle`});continue}let H=Date.now();try{await runTestBundle(F,S),I.push({runtime:S,ok:!0,durationMs:Date.now()-H})}catch(n){I.push({runtime:S,ok:!1,durationMs:Date.now()-H,error:n.message})}}let H=I.map(n=>`${n.ok?`✅`:`❌`} ${n.runtime} (${n.durationMs}ms)${n.error?` — ${n.error}`:``}`).join(` `);ke.log(`[gjsify test] ${H}`),I.some(n=>!n.ok)&&process.exit(1),process.exit(0)}}});function readPackageJson$2(n){if(!existsSync(n))return null;let a=readFileSync(n,`utf-8`);try{return JSON.parse(a)}catch(a){throw Error(`gjsify install: ${n} is not valid JSON: ${a.message}`)}}function writePackageJson(n,a){let S=sortKnownDepFields(a);writeFileSync(n,JSON.stringify(S,null,2)+`
|
|
746
|
-
`,`utf-8`)}function parseSpec$2(n){if(n.startsWith(`@`)){let a=n.indexOf(`/`);if(a===-1)return{name:n};let S=n.indexOf(`@`,a+1);return S===-1?{name:n}:{name:n.slice(0,S),range:n.slice(S+1)}}let a=n.indexOf(`@`);return a===-1?{name:n}:{name:n.slice(0,a),range:n.slice(a+1)}}function projectSpecsFromPackageJson(n){let a=[];for(let S of[`dependencies`,`devDependencies`,`optionalDependencies`]){let C=n[S];if(C)for(let[n,S]of Object.entries(C))typeof S==`string`&&(/^(workspace|link|file|portal|git\+|https?):/.test(S)||a.push(`${n}@${S}`))}return a}function addDependencyEntry(n,a,S,C){n[C]===void 0&&(n[C]={}),n[C][a]=S}function defaultRangeFromVersion(n){return`^${n}`}function sortKnownDepFields(n){let a={...n};for(let n of[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`]){let S=a[n];S&&(a[n]=Object.fromEntries(Object.entries(S).sort(([n],[a])=>n<a?-1:+(n>a))))}return a}var pj=__esmMin(()=>{Zc(),__name$1(readPackageJson$2,`readPackageJson`),__name$1(parseSpec$2,`parseSpec`)});function looksLikeFile(n){if(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`/`)||n.includes(`/`)||n.includes(`\\`)||/\.(c?js|mjs|cjs|gjs)$/.test(n))return!0;try{return statSync(n).isFile()}catch{return!1}}async function
|
|
747
|
-
\r*?{}[]~#!`.includes(I))return null;S+=I,C=!0}return N?null:(C&&a.push(S),a)}var mj,hj=__esmMin(()=>{Ae(),Zc(),ps(),cC(),uj(),pj(),Lg(),zg(),mj={command:`run <target> [args..]`,description:"Run a script from package.json (yarn-run-style) or a GJS bundle file. If <target> resolves to a file on disk (or has a path-like prefix), it is launched via gjs with LD_LIBRARY_PATH + GI_TYPELIB_PATH set for native packages. Otherwise it is looked up in the current package.json `scripts`.",builder:n=>n.positional(`target`,{description:"Either a script name (looked up in package.json `scripts`) or a path to a GJS bundle (e.g. dist/gjs.js).",type:`string`,demandOption:!0}).positional(`args`,{description:`Extra arguments passed through to the script / gjs.`,type:`string`,array:!0,default:[]}).parserConfiguration({"populate--":!0,"unknown-options-as-args":!0}),handler:async n=>{let a=n.target,S=n.args??[],C=(n[`--`]??[]).filter(n=>typeof n==`string`),N=[...S,...C],F=readPackageJson$2(ns(process.cwd(),`package.json`));if(!(F?.scripts&&typeof F.scripts[a]==`string`)&&looksLikeFile(a)){await runGjsBundle($o(a),N,{exitOnSuccess:!0});return}await runScript(a,N)}}}),gj,_j=__esmMin(()=>{Ae(),ps(),cj(),gj={command:`info [file]`,description:`Show native gjsify packages detected in node_modules and the env vars needed to run a GJS bundle directly with gjs.`,builder:n=>n.positional(`file`,{description:`Optional: the GJS bundle path to include in the example command (e.g. dist/gjs.js)`,type:`string`,normalize:!0}).option(`export`,{description:`Output only shell export statements suitable for eval (eval $(gjsify info --export))`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=n.file?$o(n.file):null,C=detectNativePackages(a),{LD_LIBRARY_PATH:N,GI_TYPELIB_PATH:F}=buildNativeEnv(C);if(n.export){ke.log(`export LD_LIBRARY_PATH="${N}"`),ke.log(`export GI_TYPELIB_PATH="${F}"`);return}if(C.length===0){ke.log(`No native gjsify packages detected in node_modules.`),ke.log(`Native packages declare "gjsify": { "prebuilds": "<dir>" } in their package.json.`);return}ke.log(`Native packages detected:`);for(let n of C)ke.log(` ${n.name} → ${n.prebuildsDir}`);ke.log(``),ke.log(`To run your app directly with gjs, set:`),ke.log(` export LD_LIBRARY_PATH="${N}"`),ke.log(` export GI_TYPELIB_PATH="${F}"`),S?ke.log(` gjs -m ${S}`):ke.log(` gjs -m <your-bundle.js>`),ke.log(``),ke.log(`Or use gjsify run to handle this automatically:`),S?ke.log(` gjsify run ${n.file}`):ke.log(` gjsify run <your-bundle.js>`)}}});function tryExecFile(n,a){try{return execFileSync(n,a,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function checkBinary(n,a,S,C,N,F,I){let H=tryExecFile(S,C);return H===null?{id:n,name:a,found:!1,severity:N,requiredBy:I}:{id:n,name:a,found:!0,version:F?F(H):H.split(`
|
|
746
|
+
`,`utf-8`)}function parseSpec$2(n){if(n.startsWith(`@`)){let a=n.indexOf(`/`);if(a===-1)return{name:n};let S=n.indexOf(`@`,a+1);return S===-1?{name:n}:{name:n.slice(0,S),range:n.slice(S+1)}}let a=n.indexOf(`@`);return a===-1?{name:n}:{name:n.slice(0,a),range:n.slice(a+1)}}function projectSpecsFromPackageJson(n){let a=[];for(let S of[`dependencies`,`devDependencies`,`optionalDependencies`]){let C=n[S];if(C)for(let[n,S]of Object.entries(C))typeof S==`string`&&(/^(workspace|link|file|portal|git\+|https?):/.test(S)||a.push(`${n}@${S}`))}return a}function addDependencyEntry(n,a,S,C){n[C]===void 0&&(n[C]={}),n[C][a]=S}function defaultRangeFromVersion(n){return`^${n}`}function sortKnownDepFields(n){let a={...n};for(let n of[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`]){let S=a[n];S&&(a[n]=Object.fromEntries(Object.entries(S).sort(([n],[a])=>n<a?-1:+(n>a))))}return a}var pj=__esmMin(()=>{Zc(),__name$1(readPackageJson$2,`readPackageJson`),__name$1(parseSpec$2,`parseSpec`)});function looksLikeFile(n){if(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`/`)||n.includes(`/`)||n.includes(`\\`)||/\.(c?js|mjs|cjs|gjs)$/.test(n))return!0;try{return statSync(n).isFile()}catch{return!1}}async function runScriptInWorkspace(n,a,S){let C=findWorkspaceRoot(process.cwd())??process.cwd(),N;try{N=discoverWorkspaces(C)}catch(n){return ke.error(`gjsify run: could not read workspaces at ${C}: ${n.message}`),process.exit(1)}let F=N.find(a=>a.name===n||a.relativeLocation===n||os(a.location)===n);if(!F){let a=N.map(n=>n.relativeLocation).join(`, `)||`<none>`;return ke.error(`gjsify run: no workspace "${n}" under ${C} (available: ${a})`),process.exit(1)}await runScript(a,S,F.location)}async function runScript(n,a,S=process.cwd()){let C=ns(S,`package.json`),N=readPackageJson$2(C);if(!N)return ke.error(`gjsify run: no package.json in ${S}`),process.exit(1);let F=N.scripts??{},I=F[n];if(typeof I!=`string`){let a=Object.keys(F).join(`, `)||`<none>`;return ke.error(`gjsify run: no script "${n}" in ${C} (available: ${a})`),process.exit(1)}let H=findWorkspaceRoot(S),W=[ns(S,`node_modules`,`.bin`)];H&&H!==S&&W.push(ns(H,`node_modules`,`.bin`)),process.env.GJSIFY_SHIM_DIR&&W.unshift(process.env.GJSIFY_SHIM_DIR);let K=process.env.FORCE_COLOR!==void 0||process.env.NO_COLOR!==void 0?{}:{FORCE_COLOR:`1`},q={...process.env,...K,PATH:[...W,process.env.PATH??``].filter(Boolean).join(ds),npm_lifecycle_event:n,npm_package_name:N.name??``,npm_package_version:N.version??``},Y=isGjs()?gjsifyInProcessArgv(I,a):null;if(Y){process.env.PATH=q.PATH,process.env.npm_lifecycle_event=q.npm_lifecycle_event,process.env.npm_package_name=q.npm_package_name,process.env.npm_package_version=q.npm_package_version,q.FORCE_COLOR!==void 0&&(process.env.FORCE_COLOR=q.FORCE_COLOR);try{let{runCli:n}=await Promise.resolve().then(()=>(nF(),tF));await n(Y)}catch(n){ke.error(n.message),process.exit(1)}process.exit(process.exitCode==null?0:Number(process.exitCode));return}let X=a.length>0?`${I} ${a.map(shellEscape).join(` `)}`:I;await new Promise((a,C)=>{let N=spawn(X,[],{cwd:S,env:q,stdio:`inherit`,shell:!0});N.on(`close`,S=>{S===0?a():C(Error(`script "${n}" exited with code ${S}`))}),N.on(`error`,C)}).catch(n=>{ke.error(n.message),process.exit(1)}),process.exit(0)}function shellEscape(n){return/^[a-zA-Z0-9_\-./=:@,]+$/.test(n)?n:`'${n.replace(/'/g,`'\\''`)}'`}function gjsifyInProcessArgv(n,a){let S=tokenizeSimpleCommand(n);return!S||S.length<2||S[0]!==`gjsify`?null:[...S.slice(1),...a]}function tokenizeSimpleCommand(n){let a=[],S=``,C=!1,N=null;for(let F=0;F<n.length;F++){let I=n[F];if(N===`'`){I===`'`?N=null:S+=I;continue}if(N===`"`){if(I===`"`)N=null;else if(I===`\\`&&(n[F+1]===`"`||n[F+1]===`\\`))S+=n[++F];else if(I===`$`||I==="`")return null;else S+=I;continue}if(I===`'`||I===`"`){N=I,C=!0;continue}if(I===` `||I===` `){C&&=(a.push(S),S=``,!1);continue}if(`|&;<>\`$()\\
|
|
747
|
+
\r*?{}[]~#!`.includes(I))return null;S+=I,C=!0}return N?null:(C&&a.push(S),a)}var mj,hj=__esmMin(()=>{Ae(),Zc(),ps(),cC(),uj(),pj(),Lg(),Ig(),zg(),mj={command:`run <target> [args..]`,description:"Run a script from package.json (yarn-run-style) or a GJS bundle file. If <target> resolves to a file on disk (or has a path-like prefix), it is launched via gjs with LD_LIBRARY_PATH + GI_TYPELIB_PATH set for native packages. Otherwise it is looked up in the current package.json `scripts`.",builder:n=>n.positional(`target`,{description:"Either a script name (looked up in package.json `scripts`) or a path to a GJS bundle (e.g. dist/gjs.js).",type:`string`,demandOption:!0}).positional(`args`,{description:`Extra arguments passed through to the script / gjs.`,type:`string`,array:!0,default:[]}).option(`workspace`,{alias:`w`,type:`string`,description:"Run <target> as a script in the named workspace (by name or path), like `npm run <script> -w <name>`."}).parserConfiguration({"populate--":!0,"unknown-options-as-args":!0}),handler:async n=>{let a=n.target,S=n.args??[],C=(n[`--`]??[]).filter(n=>typeof n==`string`),N=[...S,...C];if(typeof n.workspace==`string`&&n.workspace.length>0){await runScriptInWorkspace(n.workspace,a,N);return}let F=readPackageJson$2(ns(process.cwd(),`package.json`));if(!(F?.scripts&&typeof F.scripts[a]==`string`)&&looksLikeFile(a)){await runGjsBundle($o(a),N,{exitOnSuccess:!0});return}await runScript(a,N)}}}),gj,_j=__esmMin(()=>{Ae(),ps(),cj(),gj={command:`info [file]`,description:`Show native gjsify packages detected in node_modules and the env vars needed to run a GJS bundle directly with gjs.`,builder:n=>n.positional(`file`,{description:`Optional: the GJS bundle path to include in the example command (e.g. dist/gjs.js)`,type:`string`,normalize:!0}).option(`export`,{description:`Output only shell export statements suitable for eval (eval $(gjsify info --export))`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=n.file?$o(n.file):null,C=detectNativePackages(a),{LD_LIBRARY_PATH:N,GI_TYPELIB_PATH:F}=buildNativeEnv(C);if(n.export){ke.log(`export LD_LIBRARY_PATH="${N}"`),ke.log(`export GI_TYPELIB_PATH="${F}"`);return}if(C.length===0){ke.log(`No native gjsify packages detected in node_modules.`),ke.log(`Native packages declare "gjsify": { "prebuilds": "<dir>" } in their package.json.`);return}ke.log(`Native packages detected:`);for(let n of C)ke.log(` ${n.name} → ${n.prebuildsDir}`);ke.log(``),ke.log(`To run your app directly with gjs, set:`),ke.log(` export LD_LIBRARY_PATH="${N}"`),ke.log(` export GI_TYPELIB_PATH="${F}"`),S?ke.log(` gjs -m ${S}`):ke.log(` gjs -m <your-bundle.js>`),ke.log(``),ke.log(`Or use gjsify run to handle this automatically:`),S?ke.log(` gjsify run ${n.file}`):ke.log(` gjsify run <your-bundle.js>`)}}});function tryExecFile(n,a){try{return execFileSync(n,a,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return null}}function checkBinary(n,a,S,C,N,F,I){let H=tryExecFile(S,C);return H===null?{id:n,name:a,found:!1,severity:N,requiredBy:I}:{id:n,name:a,found:!0,version:F?F(H):H.split(`
|
|
748
748
|
`)[0]??H,severity:N,requiredBy:I}}function checkPkgConfig(n,a,S,C,N){let F=tryExecFile(`pkg-config`,[`--modversion`,S]);return F===null?{id:n,name:a,found:!1,severity:C,requiredBy:N}:{id:n,name:a,found:!0,version:F.split(`
|
|
749
749
|
`)[0],severity:C,requiredBy:N}}function checkNpmPackage(n,a,S,C,N,F){try{return createRequire(pathToFileURL(ns(C,`_check_.js`)).href).resolve(S),{id:n,name:a,found:!0,severity:N,requiredBy:F}}catch{}try{return createRequire(import.meta.url).resolve(S),{id:n,name:a,found:!0,severity:N,requiredBy:F}}catch{return{id:n,name:a,found:!1,severity:N,requiredBy:F}}}function detectPackageManager$2(){for(let n of[`apt`,`dnf`,`pacman`,`zypper`,`apk`])if(tryExecFile(`which`,[n])!==null)return n;return`unknown`}function findProjectRoot(n){let a=$o(n);for(;;){if(existsSync(ns(a,`package.json`)))return a;let n=$o(a,`..`);if(n===a)return null;a=n}}function discoverGjsifyPackages(n){let a=findProjectRoot(n);if(!a)return null;let S=ns(a,`node_modules`,`@gjsify`);if(!existsSync(S))return new Set;let C=ns(a,`package.json`),N={};try{N=JSON.parse(readFileSync(C,`utf-8`))}catch{}let F={...N.dependencies,...N.devDependencies},I=new Set;try{for(let n of readdirSync(S,{withFileTypes:!0}))(n.isDirectory()||n.isSymbolicLink())&&I.add(`@gjsify/${n.name}`)}catch{}for(let n of Object.keys(F))n.startsWith(`@gjsify/`)&&I.add(n);return I}function computeNeededOptionalDeps(n){let a=discoverGjsifyPackages(n);if(a===null)return null;let S=new Set;for(let n of a){let a=yj[n];if(a)for(let n of a)S.add(n)}return S}function runAllChecks(n){let a=computeNeededOptionalDeps(n);return[...runMinimalChecks(),...runRequiredChecks(n),...runOptionalChecks(a,n)]}function runMinimalChecks(){let n=[];return n.push({id:`nodejs`,name:`Node.js`,found:!0,version:process.version,severity:`required`}),n.push(checkBinary(`gjs`,`GJS`,`gjs`,[`--version`],`required`,n=>n.replace(/^GJS\s+/i,``).split(`
|
|
750
750
|
`)[0]??n)),n}function checkGwebgl(n){return checkNpmPackage(`gwebgl`,`gwebgl (@gjsify/webgl)`,`@gjsify/webgl`,n,`optional`,[`@gjsify/webgl`])}function runRequiredChecks(n){let a=[];return a.push(checkBinary(`blueprint-compiler`,`Blueprint Compiler`,`blueprint-compiler`,[`--version`],`required`)),a.push(checkBinary(`pkg-config`,`pkg-config`,`pkg-config`,[`--version`],`required`)),a.push(checkBinary(`meson`,`Meson`,`meson`,[`--version`],`required`)),a.push(checkPkgConfig(`gtk4`,`GTK4`,`gtk4`,`required`)),a.push(checkPkgConfig(`libadwaita`,`libadwaita`,`libadwaita-1`,`required`)),a.push(checkPkgConfig(`libsoup3`,`libsoup3`,`libsoup-3.0`,`required`)),a.push(checkPkgConfig(`gobject-introspection`,`GObject Introspection`,`gobject-introspection-1.0`,`required`)),a}function runOptionalChecks(n,a){let S=[];for(let[a,C]of Object.entries(vj)){if(n!==null&&!n.has(a))continue;let N=Object.entries(yj).filter(([,n])=>n.includes(a)).map(([n])=>n);S.push(checkPkgConfig(C.id,C.name,C.pkgName,`optional`,N))}return(n===null||n.has(`gwebgl`))&&S.push(checkGwebgl(a)),S}function buildInstallCommand(n,a){if(n===`unknown`)return null;let S=bj[n],C=[],N=[];for(let n of a){if(n.id===`gwebgl`){N.push(`@gjsify/webgl`);continue}if(n.id===`nodejs`)continue;let a=S[n.id];a&&C.push(a)}let F=[];return C.length>0&&F.push(`${xj[n]} ${C.join(` `)}`),N.length>0&&F.push(`npm install ${N.join(` `)}`),F.length>0?F.join(`
|