brsh 3.8.1 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/shell.min.js CHANGED
@@ -1,13 +1,13 @@
1
- "use strict";var Shell=(function(){var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);function n(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function r(e){var t=n(e),r=t[0],i=t[1];return(r+i)*3/4-i}function i(e,t,n){return(t+n)*3/4-n}function a(e){var t,r=n(e),a=r[0],o=r[1],s=new p(i(e,a,o)),c=0,l=o>0?a-4:a,u;for(u=0;u<l;u+=4)t=f[e.charCodeAt(u)]<<18|f[e.charCodeAt(u+1)]<<12|f[e.charCodeAt(u+2)]<<6|f[e.charCodeAt(u+3)],s[c++]=t>>16&255,s[c++]=t>>8&255,s[c++]=t&255;return o===2&&(t=f[e.charCodeAt(u)]<<2|f[e.charCodeAt(u+1)]>>4,s[c++]=t&255),o===1&&(t=f[e.charCodeAt(u)]<<10|f[e.charCodeAt(u+1)]<<4|f[e.charCodeAt(u+2)]>>2,s[c++]=t>>8&255,s[c++]=t&255),s}function o(e){return d[e>>18&63]+d[e>>12&63]+d[e>>6&63]+d[e&63]}function s(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(o(r));return i.join(``)}function c(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,c=n-r;o<c;o+=a)i.push(s(e,o,o+a>c?c:o+a));return r===1?(t=e[n-1],i.push(d[t>>2]+d[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(d[t>>10]+d[t>>4&63]+d[t<<2&63]+`=`)),i.join(``)}var l,u,d,f,p,m,h,g,_,v,y=e((()=>{for(l={},u={},u.byteLength=r,u.toByteArray=a,u.fromByteArray=c,d=[],f=[],p=typeof Uint8Array<`u`?Uint8Array:Array,m=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,h=0,g=m.length;h<g;++h)d[h]=m[h],f[m.charCodeAt(h)]=h;f[45]=62,f[95]=63,_={},_.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},_.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=u,n=_,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=d,e.SlowBuffer=C,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;d.TYPED_ARRAY_SUPPORT=c(),!d.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,d.prototype),t}function d(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return h(e)}return f(e,t,n)}d.poolSize=8192;function f(e,t,n){if(typeof e==`string`)return g(e,t);if(o.isView(e))return y(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(fe(e,o)||e&&fe(e.buffer,o)||s!==void 0&&(fe(e,s)||e&&fe(e.buffer,s)))return b(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return d.from(r,t,n);let i=x(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return d.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}d.from=function(e,t,n){return f(e,t,n)},Object.setPrototypeOf(d.prototype,a.prototype),Object.setPrototypeOf(d,a);function p(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function m(e,t,n){return p(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}d.alloc=function(e,t,n){return m(e,t,n)};function h(e){return p(e),l(e<0?0:S(e)|0)}d.allocUnsafe=function(e){return h(e)},d.allocUnsafeSlow=function(e){return h(e)};function g(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!d.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=w(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function v(e){let t=e.length<0?0:S(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function y(e){if(fe(e,a)){let t=new a(e);return b(t.buffer,t.byteOffset,t.byteLength)}return v(e)}function b(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,d.prototype),r}function x(e){if(d.isBuffer(e)){let t=S(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||pe(e.length)?l(0):v(e);if(e.type===`Buffer`&&Array.isArray(e.data))return v(e.data)}function S(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function C(e){return+e!=e&&(e=0),d.alloc(+e)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype},d.compare=function(e,t){if(fe(e,a)&&(e=d.from(e,e.offset,e.byteLength)),fe(t,a)&&(t=d.from(t,t.offset,t.byteLength)),!d.isBuffer(e)||!d.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},d.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},d.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return d.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=d.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(fe(t,a))i+t.length>r.length?(d.isBuffer(t)||(t=d.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(d.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function w(e,t){if(d.isBuffer(e))return e.length;if(o.isView(e)||fe(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return se(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return ue(e).length;default:if(i)return r?-1:se(e).length;t=(``+t).toLowerCase(),i=!0}}d.byteLength=w;function T(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return B(this,t,n);case`utf8`:case`utf-8`:return F(this,t,n);case`ascii`:return R(this,t,n);case`latin1`:case`binary`:return z(this,t,n);case`base64`:return P(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return V(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function E(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}d.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)E(this,t,t+1);return this},d.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)E(this,t,t+3),E(this,t+1,t+2);return this},d.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)E(this,t,t+7),E(this,t+1,t+6),E(this,t+2,t+5),E(this,t+3,t+4);return this},d.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?F(this,0,e):T.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(e){if(!d.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:d.compare(this,e)===0},d.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(d.prototype[r]=d.prototype.inspect),d.prototype.compare=function(e,t,n,r,i){if(fe(e,a)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),u=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==u[e]){o=l[e],s=u[e];break}return o<s?-1:+(s<o)};function D(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,pe(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=d.from(t,r)),d.isBuffer(t))return t.length===0?-1:O(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):O(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function O(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}d.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},d.prototype.indexOf=function(e,t,n){return D(this,e,t,n,!0)},d.prototype.lastIndexOf=function(e,t,n){return D(this,e,t,n,!1)};function k(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(pe(r))return o;e[n+o]=r}return o}function A(e,t,n,r){return de(se(t,e.length-n),e,n,r)}function j(e,t,n,r){return de(ce(t),e,n,r)}function M(e,t,n,r){return de(ue(t),e,n,r)}function N(e,t,n,r){return de(le(t,e.length-n),e,n,r)}d.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return k(this,e,t,n);case`utf8`:case`utf-8`:return A(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return j(this,e,t,n);case`base64`:return M(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return N(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},d.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function P(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function F(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return L(r)}let I=4096;function L(e){let t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}function R(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function z(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function B(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=me[e[r]];return i}function V(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}d.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,d.prototype),r};function H(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},d.prototype.readUintBE=d.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},d.prototype.readUint8=d.prototype.readUInt8=function(e,t){return e>>>=0,t||H(e,1,this.length),this[e]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,t){return e>>>=0,t||H(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,t){return e>>>=0,t||H(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,t){return e>>>=0,t||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readBigUInt64LE=Z(function(e){e>>>=0,re(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ie(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),d.prototype.readBigUInt64BE=Z(function(e){e>>>=0,re(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ie(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),d.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},d.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},d.prototype.readInt8=function(e,t){return e>>>=0,t||H(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},d.prototype.readInt16LE=function(e,t){e>>>=0,t||H(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},d.prototype.readInt16BE=function(e,t){e>>>=0,t||H(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},d.prototype.readInt32LE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},d.prototype.readInt32BE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readBigInt64LE=Z(function(e){e>>>=0,re(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ie(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),d.prototype.readBigInt64BE=Z(function(e){e>>>=0,re(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ie(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),d.prototype.readFloatLE=function(e,t){return e>>>=0,t||H(e,4,this.length),n.read(this,e,!0,23,4)},d.prototype.readFloatBE=function(e,t){return e>>>=0,t||H(e,4,this.length),n.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function(e,t){return e>>>=0,t||H(e,8,this.length),n.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function(e,t){return e>>>=0,t||H(e,8,this.length),n.read(this,e,!1,52,8)};function U(e,t,n,r,i,a){if(!d.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;U(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;U(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},d.prototype.writeUint8=d.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,255,0),this[t]=e&255,t+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function W(e,t,n,r,i){X(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function G(e,t,n,r,i){X(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}d.prototype.writeBigUInt64LE=Z(function(e,t=0){return W(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeBigUInt64BE=Z(function(e,t=0){return G(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);U(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},d.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);U(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},d.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},d.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},d.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},d.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},d.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},d.prototype.writeBigInt64LE=Z(function(e,t=0){return W(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),d.prototype.writeBigInt64BE=Z(function(e,t=0){return G(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ee(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function K(e,t,r,i,a){return t=+t,r>>>=0,a||ee(e,t,r,4),n.write(e,t,r,i,23,4),r+4}d.prototype.writeFloatLE=function(e,t,n){return K(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return K(this,e,t,!1,n)};function q(e,t,r,i,a){return t=+t,r>>>=0,a||ee(e,t,r,8),n.write(e,t,r,i,52,8),r+8}d.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},d.prototype.copy=function(e,t,n,r){if(!d.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},d.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!d.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=d.isBuffer(e)?e:d.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let J={};function te(e,t,n){J[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}te(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),te(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),te(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=ne(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=ne(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function ne(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function Y(e,t,n){re(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&ie(t,e.length-(n+1))}function X(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new J.ERR_OUT_OF_RANGE(`value`,i,e)}Y(r,i,a)}function re(e,t){if(typeof e!=`number`)throw new J.ERR_INVALID_ARG_TYPE(t,`number`,e)}function ie(e,t,n){throw Math.floor(e)===e?t<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(re(e,n),new J.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let ae=/[^+/0-9A-Za-z-_]/g;function oe(e){if(e=e.split(`=`)[0],e=e.trim().replace(ae,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function se(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function ce(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function le(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function ue(e){return t.toByteArray(oe(e))}function de(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function fe(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function pe(e){return e!==e}let me=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function Z(e){return typeof BigInt>`u`?he:e}function he(){throw Error(`BigInt not supported`)}})(l),v=l.Buffer,l.Blob,l.BlobOptions,l.Buffer,l.File,l.FileOptions,l.INSPECT_MAX_BYTES,l.SlowBuffer,l.TranscodeEncoding,l.atob,l.btoa,l.constants,l.isAscii,l.isUtf8,l.kMaxLength,l.kStringMaxLength,l.resolveObjectURL,l.transcode})),b=t(((e,t)=>{y();var n=new Set([`cwd`,`getFileByPath`,`setFileByPath`,`deleteFileByPath`,`exists`,`stat`,`absolutePath`,`getMode`,`setMode`,`isReadable`,`isWritable`,`isExecutable`,`getSize`,`autoComplete`,`isRealFilesystem`,`isSymlink`,`readSymlink`,`createSymlink`]),r=class{isReadable(e){let t=this.getMode(e);return t===null?!1:(t&256)!=0}isWritable(e){let t=this.getMode(e);return t===null?!1:(t&128)!=0}isExecutable(e){let t=this.getMode(e);return t===null?!1:(t&64)!=0}sandbox(){let e=this;return new Proxy(Object.create(null),{get(t,r){if(!n.has(r))return;let i=e[r];return typeof i==`function`?i.bind(e):i},set(){return!1},has(e,t){return n.has(t)}})}_triggerChange(){!this._onChange||this._changeScheduled||(this._changeScheduled=!0,Promise.resolve().then(()=>{this._changeScheduled=!1,typeof this._onChange==`function`&&this._onChange(this.getRaw(),this.getRawPermissions())}))}},i=class extends Uint8Array{constructor(e,t){super(e),Object.defineProperty(this,"mimeType",{value:t,enumerable:!1,configurable:!1,writable:!1})}toString(){if(v!==void 0)return`data:${this.mimeType};base64,${v.from(this).toString(`base64`)}`;let e=``,t=8192;for(let n=0;n<this.length;n+=t)e+=String.fromCharCode(...this.subarray(n,n+t));return`data:${this.mimeType};base64,${btoa(e)}`}},a=class{constructor(e){this.target=e}};t.exports=r,t.exports.BinaryFile=i,t.exports.SymlinkRef=a}));function x(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function S(){throw Error(`setTimeout has not been defined`)}function C(){throw Error(`clearTimeout has not been defined`)}function w(e){if(M===setTimeout)return setTimeout(e,0);if((M===S||!M)&&setTimeout)return M=setTimeout,setTimeout(e,0);try{return M(e,0)}catch{try{return M.call(null,e,0)}catch{return M.call(this,e,0)}}}function T(e){if(N===clearTimeout)return clearTimeout(e);if((N===C||!N)&&clearTimeout)return N=clearTimeout,clearTimeout(e);try{return N(e)}catch{try{return N.call(null,e)}catch{return N.call(this,e)}}}function E(){!F||!I||(F=!1,I.length?P=I.concat(P):L=-1,P.length&&D())}function D(){if(!F){var e=w(E);F=!0;for(var t=P.length;t;){for(I=P,P=[];++L<t;)I&&I[L].run();L=-1,t=P.length}I=null,F=!1,T(e)}}function O(e,t){this.fun=e,this.array=t}function k(){}var A,j,M,N,P,F,I,L,R,z,B=e((()=>{A={exports:{}},j=A.exports={},(function(){try{M=typeof setTimeout==`function`?setTimeout:S}catch{M=S}try{N=typeof clearTimeout==`function`?clearTimeout:C}catch{N=C}})(),P=[],F=!1,L=-1,j.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];P.push(new O(e,t)),P.length===1&&!F&&w(D)},O.prototype.run=function(){this.fun.apply(null,this.array)},j.title=`browser`,j.browser=!0,j.env={},j.argv=[],j.version=``,j.versions={},j.on=k,j.addListener=k,j.once=k,j.off=k,j.removeListener=k,j.removeAllListeners=k,j.emit=k,j.prependListener=k,j.prependOnceListener=k,j.listeners=function(e){return[]},j.binding=function(e){throw Error(`process.binding is not supported`)},j.cwd=function(){return`/`},j.chdir=function(e){throw Error(`process.chdir is not supported`)},j.umask=function(){return 0},R=A.exports,z=x(R)})),V=t(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),H=t(((e,t)=>{var n=[`out`,`err`];t.exports=class{constructor(e,t){if(!n.includes(e))throw Error(`incorrect std output type`);this.type=e,this.string=t}}})),U=t(((e,t)=>{var n=H();t.exports=class{constructor(e=[],t=0){if(typeof t!=`number`)throw Error(`Command Result ExitCode must be a number`);if(!Array.isArray(e))throw Error(`Command Result be array`);this.std=e,this.exitCode=t}addStdOutLine(e){this.std.push(new n(`out`,e))}addStdErrLine(e){this.std.push(new n(`err`,e))}getStdOutput(){return this.std}getExitCode(){return this.exitCode}flush(){let e=this.std;return this.std=[],e}}})),W=t(((e,t)=>{y();var n=V(),r=n.EventEmitter||n.default||n;function i(e){if(!e)return[];let t=typeof e==`string`?e:e instanceof Uint8Array||v!==void 0&&v.isBuffer(e)?new TextDecoder().decode(e):String(e),n=[],r=0;for(;r<t.length;){let e=t[r],i=t.charCodeAt(r);if(i===27){if(t.charCodeAt(r+1)===127||t.charCodeAt(r+1)===8){n.push(`^W`),r+=2;continue}if(t[r+1]===`[`||t[r+1]===`O`){let e=r+2;for(;e<t.length&&t.charCodeAt(e)>=32&&t.charCodeAt(e)<=63;)e++;if(e<t.length){let i=t.slice(r+2,e+1),a={A:`ArrowUp`,B:`ArrowDown`,C:`ArrowRight`,D:`ArrowLeft`,H:`Home`,F:`End`,"1~":`Home`,"3~":`Delete`,"4~":`End`,"5~":`PageUp`,"6~":`PageDown`,"7~":`Home`,"8~":`End`};a[i]&&n.push(a[i]),r=e+1;continue}}n.push(`Escape`),r++;continue}if(i===13||i===10){n.push(`Enter`),i===13&&t[r+1]===`
2
- `&&r++,r++;continue}if(i===127||i===8){n.push(`Backspace`),r++;continue}if(i===9){n.push(`Tab`),r++;continue}if(i>=1&&i<=26){n.push(`^`+String.fromCharCode(i+64)),r++;continue}n.push(e),r++}return n}t.exports={TtyStream:class extends r{constructor(e={}){super(),this.isTTY=e.isTTY!==!1,this.readable=!0,this.writable=!0,this.columns=e.columns||80,this.rows=e.rows||24,this.isRaw=!1,this._encoding=null,this._onWrite=e.onWrite||null}write(e,t,n){if(e==null)return!0;typeof this._onWrite==`function`&&this._onWrite(e),this._isPushing=!0;try{this.emit(`data`,this._formatChunk(e))}finally{this._isPushing=!1}return typeof t==`function`?t():typeof n==`function`&&n(),!0}pushData(e){if(e!=null){this._isPushing=!0;try{this.emit(`data`,this._formatChunk(e))}finally{this._isPushing=!1}}}_formatChunk(e){return this._encoding?typeof e==`string`?e:e instanceof Uint8Array||v!==void 0&&v.isBuffer(e)?new TextDecoder().decode(e):String(e):e}setRawMode(e){return this.isRaw=!!e,this}setEncoding(e){return this._encoding=e,this}getWindowSize(){return[this.columns,this.rows]}resize(e,t){this.columns=e,this.rows=t,this.emit(`resize`)}resume(){return this}pause(){return this}pipe(e){return this.on(`data`,t=>e.write(t)),e}unpipe(){return this}end(e,t,n){return e!=null&&this.write(e,typeof t==`string`?t:void 0),this.emit(`end`),typeof t==`function`?t():typeof n==`function`&&n(),this}destroy(){this.removeAllListeners()}toString(){return``}valueOf(){return``}},parseVtKeys:i}})),G=t(((e,t)=>{var n=V(),r=U(),{TtyStream:i,parseVtKeys:a}=W(),o=n.EventEmitter||n.default||n;t.exports=class extends o{constructor(e,t){super(),this.arguments=e,this.result=new r,this.context=t||null;let n=this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`COLUMNS`),10)||80,o=this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`LINES`),10)||24;this.stdinStream=new i({columns:n,rows:o}),this.stdin=this.stdinStream,this.stdout=new i({columns:n,rows:o,onWrite:e=>this.emit(`stdout`,e)}),this.stderr=new i({columns:n,rows:o,onWrite:e=>this.emit(`stderr`,e)}),this._onStdinStreamData=e=>{if(!this.captureInput)return;let t=a(e);for(let e of t)!this.interactive&&!this.stdinStream.isRaw&&(e===`Enter`?this.stdout.write(`\r
3
- `):e===`Backspace`?this.stdout.write(`\b \b`):e.length===1&&this.stdout.write(e)),this.onInput(e)},this.stdinStream.on(`data`,this._onStdinStreamData)}get name(){return`unnamed`}run(){return Promise.reject(`Command not implemented...`)}runCommand(){return Promise.resolve().then(()=>this.run()).then(e=>(e&&e.split(/\r?\n/).forEach(e=>this.stdOut=e),this.result)).catch(e=>{if(e&&e.__type)throw e;return e&&(this.stdErr=e.message||e),this.exitCode=127,this.result})}onInput(e){}set exitCode(e){this.result.exitCode=e}set stdOut(e){this.result.addStdOutLine(e)}set stdErr(e){this.result.addStdErrLine(e)}flush(){this.emit(`flush`,this.result.flush())}}})),ee=t(((e,t)=>{var n=G();t.exports=class extends n{get captureInput(){return!0}get interactive(){return!0}get terminalSize(){return this.stdout&&this.stdout.columns&&this.stdout.rows?{cols:parseInt(this.context&&this.context.getVar&&this.context.getVar(`COLUMNS`),10)||this.stdout.columns||80,rows:parseInt(this.context&&this.context.getVar&&this.context.getVar(`LINES`),10)||this.stdout.rows||24}:{cols:parseInt(this.context.getVar(`COLUMNS`),10)||80,rows:parseInt(this.context.getVar(`LINES`),10)||24}}_enterAltScreen(){this._inAltScreen||(this._inAltScreen=!0,this.stdinStream&&this.stdinStream.setRawMode(!0),this.stdout&&this.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`))}_exitAltScreen(){this._inAltScreen&&(this._inAltScreen=!1,this.stdinStream&&this.stdinStream.setRawMode(!1),this.stdout&&this.stdout.write(`\x1B[?1049l\x1B[?25h`))}runCommand(){return this.interactive&&this._enterAltScreen(),super.runCommand().finally(()=>{this._exitAltScreen()})}}})),K=t(((e,t)=>{y(),B();var{BinaryFile:n,SymlinkRef:r}=b(),i=new Uint8Array([66,82,70,83]),a=2;function o(e){if(!e)return!1;let t=e instanceof Uint8Array?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new Uint8Array(e.buffer||e,e.byteOffset||0,e.byteLength):null;return!t||t.length<12?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}function s(e={},t={},n={}){let o=new TextEncoder,s=[],c=0,l=e=>{let t=e instanceof Uint8Array?e:new Uint8Array(e),n=c;return s.push(t),c+=t.byteLength,[n,t.byteLength]},u={},d=(e,t)=>{if(e==null)return null;if(e instanceof r)return{$l:e.target};if(e instanceof Uint8Array||v!==void 0&&v.isBuffer(e)){let n=e instanceof Uint8Array?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=e.mimeType||(t.endsWith(`.wasm`)?`application/wasm`:`application/octet-stream`),[i,a]=l(n);return{$b:[i,a,r]}}if(typeof e==`function`)return n.commandsBundle||(u[t]=e.toString()),{$c:t};if(typeof e==`string`){if(e.startsWith(`data:`)){let t=e.indexOf(`;`),n=e.indexOf(`,`,t);if(t!==-1&&n!==-1&&e.slice(t+1,n)===`base64`){let r=e.slice(5,t),i=e.slice(n+1),a;if(v!==void 0)a=new Uint8Array(v.from(i,`base64`));else{let e=atob(i);a=new Uint8Array(e.length);for(let t=0;t<e.length;t++)a[t]=e.charCodeAt(t)}let[o,s]=l(a);return{$b:[o,s,r]}}}let[t,n]=l(o.encode(e));return{$t:[t,n]}}if(typeof e==`object`){let n={};for(let r of Object.keys(e)){let i=`${t}/${r}`,a=d(e[r],i);a!==null&&(n[r]=a)}return{$d:n}}return null},f=d(e,``)||{$d:{}},p=null;n.commandsBundle&&typeof n.commandsBundle==`string`&&(p=l(o.encode(n.commandsBundle)));let m={v:a,tree:f,permissions:Object.assign({},t)};p&&(m.commandsSlice=p),Object.keys(u).length>0&&(m.inlineCommands=u);let h=o.encode(JSON.stringify(m)),g=12+h.byteLength+c,_=new Uint8Array(g);_.set(i,0);let y=new DataView(_.buffer,_.byteOffset,_.byteLength);y.setUint32(4,a,!0),y.setUint32(8,h.byteLength,!0),_.set(h,12);let b=12+h.byteLength;for(let e of s)_.set(e,b),b+=e.byteLength;return _}function c(e,t={}){let i=e instanceof Uint8Array?e:new Uint8Array(e.buffer||e,e.byteOffset||0,e.byteLength);if(!o(i))throw Error(`Invalid BRFS binary container (missing BRFS magic header)`);let s=new DataView(i.buffer,i.byteOffset,i.byteLength),c=s.getUint32(4,!0);if(c>a)throw Error(`Unsupported BRFS container version: ${c}`);let l=12+s.getUint32(8,!0);if(l>i.byteLength)throw Error(`Corrupt BRFS binary container (header length exceeds buffer)`);let u=new TextDecoder,d=u.decode(i.subarray(12,l)),f=JSON.parse(d),p=i.subarray(l),m=Object.assign({},t);if(Array.isArray(f.commandsSlice)){let[e,t]=f.commandsSlice,n=u.decode(p.subarray(e,e+t));try{let e=Function(n)();e&&typeof e==`object`&&Object.assign(m,e)}catch{}}let h=e=>{if(!e||typeof e!=`object`)return e;if(`$t`in e){let[t,n]=e.$t;return u.decode(p.subarray(t,t+n))}if(`$b`in e){let[t,r,i]=e.$b;return new n(p.slice(t,t+r).buffer,i||`application/octet-stream`)}if(`$l`in e)return new r(e.$l);if(`$c`in e){let t=e.$c;if(m[t])return m[t];if(f.inlineCommands&&f.inlineCommands[t])try{let e=G(),n=ee();return Function(`Command`,`InteractiveCommand`,`return (${f.inlineCommands[t]});`)(e,n)}catch{return null}return null}if(`$d`in e){let t={};for(let[n,r]of Object.entries(e.$d)){let e=h(r);e!==null&&(t[n]=e)}return t}return e};return{filesystem:h(f.tree)||{},permissions:Object.assign({},f.permissions||{})}}function l(e){if(!e)return!1;let t=e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null;return!!(t&&t.byteLength>=2&&t[0]===31&&t[1]===139)}async function u(e){if(typeof DecompressionStream<`u`&&typeof Response<`u`){let t=new DecompressionStream(`gzip`),n=new Blob([e]).stream().pipeThrough(t),r=await new Response(n).arrayBuffer();return new Uint8Array(r)}if(z!==void 0&&typeof z.getBuiltinModule==`function`){let t=z.getBuiltinModule(`zlib`);if(t)return new Uint8Array(t.gunzipSync(v.from(e.buffer,e.byteOffset,e.byteLength)))}throw Error(`Gzip decompression is not supported in this environment`)}function d(e){return e?!!(typeof e==`string`||typeof e.then==`function`||typeof e.arrayBuffer==`function`||l(e)):!1}async function f(e,t={}){if(!e)return{filesystem:{},permissions:t};if(typeof e.then==`function`)return f(await e,t);if(typeof e.arrayBuffer==`function`){let n=await e.arrayBuffer();return f(new Uint8Array(n),t)}if(typeof e==`string`){if(!/^https?:\/\//i.test(e)&&z!==void 0&&typeof z.getBuiltinModule==`function`&&typeof window>`u`)try{let n=z.getBuiltinModule(`fs`);if(n&&n.existsSync(e)){let r=await n.promises.readFile(e);return f(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),t)}}catch{}let n=await fetch(e);if(!n.ok)throw Error(`Failed to load filesystem from ${e}: HTTP ${n.status}`);let r=await n.arrayBuffer();return f(new Uint8Array(r),t)}if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(l(n)&&(n=await u(n)),o(n)){let e=c(n);return{filesystem:e.filesystem,permissions:Object.assign({},e.permissions,t)}}let r=new TextDecoder(`utf-8`).decode(n);try{let e=JSON.parse(r);return e&&typeof e==`object`&&e.filesystem&&typeof e.permissions==`object`?{filesystem:e.filesystem,permissions:Object.assign({},e.permissions,t)}:{filesystem:e,permissions:t}}catch{let e=Function(`return `+r)();return e&&typeof e==`object`&&e.filesystem&&typeof e.permissions==`object`?{filesystem:e.filesystem,permissions:Object.assign({},e.permissions,t)}:{filesystem:e||{},permissions:t}}}return typeof e==`object`&&e.filesystem&&typeof e.permissions==`object`?d(e.filesystem)||o(e.filesystem)?f(e.filesystem,Object.assign({},e.permissions,t)):{filesystem:e.filesystem,permissions:Object.assign({},e.permissions,t)}:{filesystem:e,permissions:t}}t.exports={MAGIC:i,FORMAT_VERSION:a,isBinaryContainer:o,isGzipBytes:l,isAsyncFilesystemSource:d,resolveFilesystemSource:f,serializeBinaryFilesystem:s,deserializeBinaryFilesystem:c,FilesystemStorage:class{static async save(e,t=`brsh-rootfs`){let n=e.context?e.context.fs:e,r=s(n.getRaw(),n.getRawPermissions());return typeof indexedDB<`u`&&await this._idbPut(t,r),r}static async load(e=`brsh-rootfs`){if(e instanceof Uint8Array||e instanceof ArrayBuffer||typeof e==`string`&&(/^https?:\/\//i.test(e)||e.endsWith(`.brfs`)))return f(e);if(typeof indexedDB<`u`&&typeof e==`string`){let t=await this._idbGet(e);if(t&&o(t))return c(t)}return null}static async loadOrFetch(e=`brsh-rootfs`,t={}){return await this.load(e)||f(t)}static createAutoSave(e=`brsh-rootfs`,t=null){return(n,r)=>{let i=s(n,r);typeof indexedDB<`u`&&this._idbPut(e,i).catch(()=>{}),typeof t==`function`&&t(i,n,r)}}static _openIdb(){return new Promise((e,t)=>{let n=indexedDB.open(`brsh_fs_storage`,1);n.onupgradeneeded=()=>{n.result.createObjectStore(`snapshots`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}static async _idbPut(e,t){let n=await this._openIdb();return new Promise((r,i)=>{let a=n.transaction(`snapshots`,`readwrite`);a.objectStore(`snapshots`).put(t,e),a.oncomplete=()=>{n.close(),r()},a.onerror=()=>{n.close(),i(a.error)}})}static async _idbGet(e){let t=await this._openIdb();return new Promise((n,r)=>{let i=t.transaction(`snapshots`,`readonly`).objectStore(`snapshots`).get(e);i.onsuccess=()=>{t.close(),n(i.result||null)},i.onerror=()=>{t.close(),r(i.error)}})}}}})),q=t(((e,t)=>{y();var n=b(),{BinaryFile:r,SymlinkRef:i}=n;function a(e){for(let t of Object.keys(e)){let n=e[t];if(typeof n==`object`&&n&&!(n instanceof Uint8Array)&&!(n instanceof i))a(n);else if(typeof n==`string`&&n.startsWith(`data:`)){let i=n.indexOf(`;`),a=n.indexOf(`,`,i);if(i!==-1&&a!==-1&&n.slice(i+1,a)===`base64`){let o=n.slice(5,i),s=n.slice(a+1),c;if(v!==void 0)c=new Uint8Array(v.from(s,`base64`));else{let e=atob(s);c=new Uint8Array(e.length);for(let t=0;t<e.length;t++)c[t]=e.charCodeAt(t)}e[t]=new r(c.buffer,o)}}}}t.exports=class extends n{constructor(e=`/`,t={},n={},r=null){if(super(),t instanceof Uint8Array||t instanceof ArrayBuffer){let{deserializeBinaryFilesystem:e}=K(),r=e(t);t=r.filesystem,n=Object.assign({},r.permissions,n)}else if(t&&typeof t==`object`&&t.filesystem&&(t.filesystem instanceof Uint8Array||typeof t.filesystem==`object`)&&(n=Object.assign({},t.permissions||{},n),t=t.filesystem,t instanceof Uint8Array||t instanceof ArrayBuffer)){let{deserializeBinaryFilesystem:e}=K(),r=e(t);t=r.filesystem,n=Object.assign({},r.permissions,n)}a(t),this.fileSystem=t,this.permissions=Object.assign({},n),this.cwd=e.endsWith(`/`)?e:e+`/`,this._onChange=r,this._changeScheduled=!1}toBinaryContainer(e={}){let{serializeBinaryFilesystem:t}=K();return t(this.fileSystem,this.permissions,e)}static fromBinaryContainer(e,t={}){let{deserializeBinaryFilesystem:n}=K();return n(e,t)}getFileByPath(e){let t=this._resolveByAbsolutePath(this._pathToAbsolute(e),!0);return t==null||!this.isReadable(e)?null:t}_getFileRaw(e){return this._getFileByAbsolutePath(this._pathToAbsolute(e))}exists(e){return this._resolveByAbsolutePath(this._pathToAbsolute(e),!0)!=null}isSymlink(e){return this._resolveByAbsolutePath(this._pathToAbsolute(e),!1)instanceof i}readSymlink(e){let t=this._resolveByAbsolutePath(this._pathToAbsolute(e),!1);return t instanceof i?t.target:null}createSymlink(e,t){this._setFileRaw(t,new i(e))}stat(e){let t=this._resolveByAbsolutePath(this._pathToAbsolute(e),!1);return t==null?null:t instanceof i?{isDirectory:!1,isFile:!1,isCommand:!1,isBinary:!1,isSymlink:!0}:{isDirectory:t.constructor===Object,isFile:typeof t==`string`||t instanceof Uint8Array,isCommand:typeof t==`function`,isBinary:t instanceof Uint8Array,isSymlink:!1}}_pathToAbsolute(e){return e.startsWith(`./`)&&(e=e.substring(2)),e.startsWith(`/`)||(e=(this.cwd&&this.cwd.endsWith(`/`)?this.cwd:this.cwd?this.cwd+`/`:`/`)+e),this._traverseComplexAbsolutePath(e)}_traverseComplexAbsolutePath(e){let t=e.split(`/`);for(;t.includes(`..`);){let e=t.indexOf(`..`)-1;t.splice(e,2)}return t.join(`/`)}absolutePath(e){return this._pathToAbsolute(e)}setFileByPath(e,t,n=!1){let r=this._pathToAbsolute(e);if(this._getFileByAbsolutePath(r)!=null){if(!this.isWritable(e))throw Error(`Permission denied`)}else{let e=r.split(`/`);e.pop();let t=e.join(`/`)||`/`,n=this.getMode(t);if(n!==null&&!(n&128))throw Error(`Permission denied`)}this._setFileByAbsolutePath(r,t,n),this._triggerChange()}_setFileRaw(e,t,n=!1){let r=this._pathToAbsolute(e);this._setFileByAbsolutePath(r,t,n),this._triggerChange()}_setFileByAbsolutePath(e,t,n=!0){let r=e.split(`/`);r.shift();let a=r.pop(),o=this.fileSystem,s=[];for(let e of r){if(s.push(e),!Object.prototype.hasOwnProperty.call(o,e)){if(!n)throw Error(`${e}: No such file or directory`);o[e]={}}let t=o[e];if(t instanceof i){let n=`/`+s.slice(0,-1).join(`/`),r=t.target.startsWith(`/`)?this._traverseComplexAbsolutePath(t.target):this._traverseComplexAbsolutePath(n+`/`+t.target);if(t=this._resolveByAbsolutePath(r,!0),typeof t!=`object`||!t||t instanceof i)throw Error(`${e}: Not a directory`)}o=t}o[a]=t}_resolveByAbsolutePath(e,t=!0,n=0){if(n>10)return null;let r=e.split(`/`);r.shift(),r.length>0&&r[r.length-1].length<1&&r.pop();let a=this.fileSystem,o=[];for(let e=0;e<r.length;e++){let s=r[e],c=e===r.length-1;if(typeof a!=`object`||!a||a instanceof i||!Object.prototype.hasOwnProperty.call(a,s))return null;if(a=a[s],o.push(s),a instanceof i&&(!c||t)){let e=`/`+o.slice(0,-1).join(`/`),t=a.target.startsWith(`/`)?this._traverseComplexAbsolutePath(a.target):this._traverseComplexAbsolutePath(e+`/`+a.target);if(a=this._resolveByAbsolutePath(t,!0,n+1),a==null)return null}}return a}_getFileByAbsolutePath(e){let t=e.split(`/`);return t.shift(),t[t.length-1].length<1&&t.pop(),t.reduce((e,t)=>typeof e!=`object`||!e||!Object.prototype.hasOwnProperty.call(e,t)?null:e[t],this.fileSystem)}deleteFileByPath(e){let t=this._pathToAbsolute(e),n=t.split(`/`);n.pop();let r=n.join(`/`)||`/`,i=this.getMode(r);if(i!==null&&!(i&128))throw Error(`${e}: Permission denied`);this._deleteByAbsolutePath(t);let a=t+`/`;Object.keys(this.permissions).forEach(e=>{(e===t||e.startsWith(a))&&delete this.permissions[e]}),this._triggerChange()}_deleteByAbsolutePath(e){let t=e.split(`/`);t.shift(),t[t.length-1]===``&&t.pop();let n=t.pop();if(!n)return;let r=this.fileSystem,a=[];for(let e of t){if(a.push(e),!Object.prototype.hasOwnProperty.call(r,e))return;let t=r[e];if(t instanceof i){let e=`/`+a.slice(0,-1).join(`/`),n=t.target.startsWith(`/`)?this._traverseComplexAbsolutePath(t.target):this._traverseComplexAbsolutePath(e+`/`+t.target);if(t=this._resolveByAbsolutePath(n,!0),typeof t!=`object`||!t||t instanceof i)return}r=t}r&&n in r&&delete r[n]}getMode(e){let t=this._pathToAbsolute(e);if(this.permissions[t]!==void 0)return this.permissions[t];let n=this._resolveByAbsolutePath(t,!0);return n==null?null:n.constructor===Object?493:typeof n==`function`?365:420}setMode(e,t){let n=this._pathToAbsolute(e);this.permissions[n]=t,this._triggerChange()}getSize(e){let t=this._pathToAbsolute(e),n=this._resolveByAbsolutePath(t,!0);return n==null?0:n.constructor===Object?JSON.stringify(n).length:n instanceof Uint8Array?n.length:n.toString().length}getRawPermissions(){return Object.assign({},this.permissions)}setCwd(e){this.cwd=this._pathToAbsolute(e.endsWith(`/`)?e:e+`/`)}getRaw(){return this.fileSystem}addFiles(e){Object.entries(e).forEach(([e,t])=>{this._setFileRaw(e,t,!0)})}autoComplete(e,t){let n=this._pathToAbsolute(e).split(`/`),r=n.pop(),i=this._getFileRaw(n.length>1?n.join(`/`):`/`),a=this._getFileRaw(t);if(i&&i.constructor===Object){let t=Object.keys(i).filter(e=>e.startsWith(r));r.length<1&&(t=t.filter(e=>!e.startsWith(`.`)));let n=e.split(`/`);n.pop();let o=i;if(t.length<1&&n.length<1&&a&&(t=Object.keys(a).filter(e=>e.startsWith(r)),o=a),t.length)return{path:n.length?n.join(`/`):null,options:t.map(e=>o[e]&&o[e].constructor===Object?e.concat(`/`):e)}}return null}},t.exports.BinaryFile=r,t.exports.SymlinkRef=i})),J=t(((e,t)=>{t.exports=null})),te=t(((e,t)=>{B();function n(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}function r(e,t){for(var n=``,r=0,i=-1,a=0,o,s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(!(i===s-1||a===1))if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var c=n.lastIndexOf(`/`);if(c!==n.length-1){c===-1?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function i(e,t){var n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}var a={resolve:function(){for(var e=``,t=!1,i,a=arguments.length-1;a>=-1&&!t;a--){var o;a>=0?o=arguments[a]:(i===void 0&&(i=z.cwd()),o=i),n(o),o.length!==0&&(e=o+`/`+e,t=o.charCodeAt(0)===47)}return e=r(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`},normalize:function(e){if(n(e),e.length===0)return`.`;var t=e.charCodeAt(0)===47,i=e.charCodeAt(e.length-1)===47;return e=r(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&i&&(e+=`/`),t?`/`+e:e},isAbsolute:function(e){return n(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return`.`;for(var e,t=0;t<arguments.length;++t){var r=arguments[t];n(r),r.length>0&&(e===void 0?e=r:e+=`/`+r)}return e===void 0?`.`:a.normalize(e)},relative:function(e,t){if(n(e),n(t),e===t||(e=a.resolve(e),t=a.resolve(t),e===t))return``;for(var r=1;r<e.length&&e.charCodeAt(r)===47;++r);for(var i=e.length,o=i-r,s=1;s<t.length&&t.charCodeAt(s)===47;++s);for(var c=t.length-s,l=o<c?o:c,u=-1,d=0;d<=l;++d){if(d===l){if(c>l){if(t.charCodeAt(s+d)===47)return t.slice(s+d+1);if(d===0)return t.slice(s+d)}else o>l&&(e.charCodeAt(r+d)===47?u=d:d===0&&(u=0));break}var f=e.charCodeAt(r+d);if(f!==t.charCodeAt(s+d))break;f===47&&(u=d)}var p=``;for(d=r+u+1;d<=i;++d)(d===i||e.charCodeAt(d)===47)&&(p.length===0?p+=`..`:p+=`/..`);return p.length>0?p+t.slice(s+u):(s+=u,t.charCodeAt(s)===47&&++s,t.slice(s))},_makeLong:function(e){return e},dirname:function(e){if(n(e),e.length===0)return`.`;for(var t=e.charCodeAt(0),r=t===47,i=-1,a=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!a){i=o;break}}else a=!1;return i===-1?r?`/`:`.`:r&&i===1?`//`:e.slice(0,i)},basename:function(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);n(e);var r=0,i=-1,a=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;var s=t.length-1,c=-1;for(o=e.length-1;o>=0;--o){var l=e.charCodeAt(o);if(l===47){if(!a){r=o+1;break}}else c===-1&&(a=!1,c=o+1),s>=0&&(l===t.charCodeAt(s)?--s===-1&&(i=o):(s=-1,i=c))}return r===i?i=c:i===-1&&(i=e.length),e.slice(r,i)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!a){r=o+1;break}}else i===-1&&(a=!1,i=o+1);return i===-1?``:e.slice(r,i)}},extname:function(e){n(e);for(var t=-1,r=0,i=-1,a=!0,o=0,s=e.length-1;s>=0;--s){var c=e.charCodeAt(s);if(c===47){if(!a){r=s+1;break}continue}i===-1&&(a=!1,i=s+1),c===46?t===-1?t=s:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||i===-1||o===0||o===1&&t===i-1&&t===r+1?``:e.slice(t,i)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return i(`/`,e)},parse:function(e){n(e);var t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;var r=e.charCodeAt(0),i=r===47,a;i?(t.root=`/`,a=1):a=0;for(var o=-1,s=0,c=-1,l=!0,u=e.length-1,d=0;u>=a;--u){if(r=e.charCodeAt(u),r===47){if(!l){s=u+1;break}continue}c===-1&&(l=!1,c=u+1),r===46?o===-1?o=u:d!==1&&(d=1):o!==-1&&(d=-1)}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===s+1?c!==-1&&(s===0&&i?t.base=t.name=e.slice(1,c):t.base=t.name=e.slice(s,c)):(s===0&&i?(t.name=e.slice(1,o),t.base=e.slice(1,c)):(t.name=e.slice(s,o),t.base=e.slice(s,c)),t.ext=e.slice(o,c)),s>0?t.dir=e.slice(0,s-1):i&&(t.dir=`/`),t},sep:`/`,delimiter:`:`,win32:null,posix:null};a.posix=a,t.exports=a})),ne=t(((e,t)=>{B();var n=J(),r=te(),i=b();t.exports=class extends i{constructor(e,t=null){super(),this._onChange=t,this._changeScheduled=!1,this._virtualFiles={},this.cwd=this._normalizeCwd(e||z.cwd())}get isRealFilesystem(){return!0}_normalizeCwd(e){let t=r.resolve(e);return t===`/`?`/`:t+`/`}absolutePath(e){e.startsWith(`./`)&&(e=e.slice(2));let t=e.startsWith(`/`)?e:r.join(this.cwd,e);return r.normalize(t)}setCwd(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=this.absolutePath(t);this.cwd=n===`/`?`/`:n+`/`}getFileByPath(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0)return this._virtualFiles[t];let i;try{i=n.statSync(t)}catch{return null}if(i.isDirectory()){let e={};try{for(let i of n.readdirSync(t)){let a=r.join(t,i);if(this._virtualFiles[a]!==void 0)e[i]=this._virtualFiles[a];else try{e[i]=n.statSync(a).isDirectory()?{}:``}catch{}}}catch{}let i=t===`/`?`/`:t+`/`;for(let t of Object.keys(this._virtualFiles))if(t.startsWith(i)&&!t.slice(i.length).includes(`/`)){let n=t.slice(i.length);n in e||(e[n]=this._virtualFiles[t])}return e}try{return n.readFileSync(t,`utf8`)}catch{return null}}setFileByPath(e,t,i=!1){let a=this.absolutePath(e);if(typeof t==`function`||t instanceof Uint8Array){this._virtualFiles[a]=t;return}if(t!=null&&t.constructor===Object){try{n.mkdirSync(a,{recursive:i}),this._triggerChange()}catch{this._virtualFiles[a]=t}return}try{i&&n.mkdirSync(r.dirname(a),{recursive:!0}),n.writeFileSync(a,String(t)),this._triggerChange()}catch{this._virtualFiles[a]=String(t)}}deleteFileByPath(e){let t=this.absolutePath(e);delete this._virtualFiles[t];try{n.lstatSync(t).isDirectory()?n.rmdirSync(t):n.unlinkSync(t),this._triggerChange()}catch{}}getMode(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0)return typeof this._virtualFiles[t]==`function`?493:420;try{return n.statSync(t).mode&511}catch{return null}}setMode(e,t){let r=this.absolutePath(e);if(this._virtualFiles[r]===void 0)try{n.chmodSync(r,t),this._triggerChange()}catch{}}getSize(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0)return 0;try{return n.statSync(t).size}catch{return 0}}isSymlink(e){let t=this.absolutePath(e);try{return n.lstatSync(t).isSymbolicLink()}catch{return!1}}readSymlink(e){let t=this.absolutePath(e);try{return n.readlinkSync(t)}catch{return null}}createSymlink(e,t){let i=this.absolutePath(t);n.mkdirSync(r.dirname(i),{recursive:!0}),n.symlinkSync(e,i),this._triggerChange()}getRaw(){return null}getRawPermissions(){return{}}addFiles(e){Object.entries(e).forEach(([e,t])=>{this.setFileByPath(e,t,!0)})}autoComplete(e,t){let i=this.absolutePath(e).split(`/`),a=i.pop(),o=i.join(`/`)||`/`,s=[];try{s=n.readdirSync(o)}catch{}let c=o===`/`?`/`:o+`/`;for(let e of Object.keys(this._virtualFiles))if(e.startsWith(c)&&!e.slice(c.length).includes(`/`)){let t=e.slice(c.length);s.includes(t)||s.push(t)}let l=s.filter(e=>e.startsWith(a));if(l.length===0&&!e.includes(`/`)){let n=this.getFileByPath(t);if(n&&n.constructor===Object&&(l=Object.keys(n).filter(t=>t.startsWith(e)),l.length))return{path:null,options:l}}if(!l.length)return null;let u=e.split(`/`);return u.pop(),{path:u.length?u.join(`/`):null,options:l.map(e=>{let t=r.join(o,e);if(this._virtualFiles[t]!==void 0)return e;try{return n.statSync(t).isDirectory()?e+`/`:e}catch{return e}})}}_getFileRaw(e){return this.getFileByPath(e)}_setFileRaw(e,t,n=!1){return this.setFileByPath(e,t,n)}exists(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0)return!0;try{return n.statSync(t),!0}catch{return!1}}stat(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0){let e=this._virtualFiles[t];return{isDirectory:e!=null&&e.constructor===Object,isFile:typeof e==`string`||e instanceof Uint8Array,isCommand:typeof e==`function`,isBinary:e instanceof Uint8Array}}try{let e=n.statSync(t);return{isDirectory:e.isDirectory(),isFile:e.isFile(),isCommand:!1}}catch{return null}}}})),Y=t(((e,t)=>{var n=q();t.exports=class{constructor(e){this.options=e;let{cwd:t=`/`,clearFn:r,destroyFn:i,onFsChange:a}=this.options;this.vars={},this.aliases={},this.fs=new n(t,{},{},a||null),this._clearFn=r,this._destroyFn=i}setVar(e,t){t?this.vars[e]=t:delete this.vars[e]}unsetVar(e){this.setVar(e)}getVar(e){return this.vars[e]||``}setAlias(e,t){t?this.aliases[e]=t:delete this.aliases[e]}unsetAlias(e){this.setAlias(e)}getAlias(e){return this.aliases[e]||null}setCommand(e){let t=`${this.getVar(`PATH`)}/${e.name.toLowerCase()}`;this.fs.addFiles({[t]:e}),this.fs.setMode(t,365)}getCommand(e){let t=`${this.getVar(`PATH`)}/${e}`;return this.fs._getFileRaw(t)||null}setNodeFilesystem(e){let t=ne(),n=this.fs._onChange;this.fs=new t(e,n)}setFilesystem(e,t={}){let r=this.fs._getFileRaw(this.getVar(`PATH`))||{},i=this.fs.getRawPermissions(),a=this.fs._onChange;this.fs=new n(this.fs.cwd,e,Object.assign({},i,t),a),this.fs.addFiles(r)}setCwd(e){this.fs.setCwd(e)}source(e){this.vars=Object.assign({},this.vars,e.vars),this.aliases=Object.assign({},this.aliases,e.aliases)}clear(){typeof this._clearFn==`function`&&this._clearFn()}destroy(e=0){typeof this._destroyFn==`function`&&this._destroyFn(e)}}})),X=t(((e,t)=>{var n=G();t.exports=class extends n{constructor(e,t){super(e,t)}}})),re=t(((e,t)=>{var n=X();function r(e){return/^#!\/(sh\.js|bin\/(sh|brsh))/.test(e)}t.exports=class extends n{constructor(e,t,n,r=!1){super(t,n),this.script=e,this.source=r}get captureInput(){return!!(this.sandbox&&this.sandbox.runningCommand&&this.sandbox.runningCommand.captureInput)}onInput(e){this.sandbox&&this.sandbox.onInput(e)}run(){let e=this.context&&this.context.fs||this.fs,t=e&&e.isRealFilesystem?{useRealFilesystem:!0}:{filesystem:e&&e.getRaw()||{},permissions:e&&e.getRawPermissions()||{}};this.sandbox=new globalThis.shell({cwd:e&&e.cwd||`/`,...t,subshell:!0}),this.sandbox.context.source(this.context),Array.isArray(this.arguments)&&(this.arguments.forEach((e,t)=>this.sandbox.context.setVar(String(t+1),e)),this.sandbox.context.setVar(`#`,String(this.arguments.length)),this.sandbox.context.setVar(`@`,this.arguments.join(` `)),this.sandbox.context.setVar(`*`,this.arguments.join(` `))),this.sandbox.on(`stdOut`,e=>{this.stdOut=e,this.flush()}),this.sandbox.on(`stdErr`,e=>{this.stdErr=e,this.flush()}),this._scriptFunctions={};let n=this.script.split(/\r?\n/);if(!r(n[0])){let e=n[0].startsWith(`#!`)?n[0].slice(2).split(/\s/)[0]:n[0];return Promise.reject(`${e}: bad interpreter: No such file or directory`)}let i=this._parseLines(n.slice(1));return this._executeNodes(i).catch(e=>{if(e&&e.__type===`return`)this.sandbox.lastCode=e.code;else if(e&&e.__type===`errexit`)this.sandbox.lastCode=e.code;else if(e&&(e.__type===`break`||e.__type===`continue`))this.stdErr=`${e.__type}: only meaningful in a for or while loop`,this.sandbox.lastCode=1;else return Promise.reject(e)}).then(()=>{this.exitCode=this.sandbox.lastCode,this.source&&this.context.source(this.sandbox.context)})}_accumulateLines(e){let t=[],n=null,r=!1,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];n===null?n=s:a?n+=s:r||i?n+=`
4
- `+s:n+=s;let c=0,l=!1,u=!1;for(;c<s.length;){let e=s[c];if(r)e===`'`&&(r=!1),c++;else if(i)e===`\\`&&c+1<s.length?c+=2:e===`\\`&&c+1===s.length?(l=!0,c++):(e===`"`&&(i=!1),c++);else{if(e===`#`&&(c===0||/\s/.test(s[c-1]))){u=!0;break}e===`\\`&&c+1<s.length?c+=2:e===`\\`&&c+1===s.length?(l=!0,c++):e===`'`?(r=!0,c++):(e===`"`&&(i=!0),c++)}}if(!r&&!l&&!u){let e=s.match(/(\\+)\s*$/);e&&e[1].length%2==1&&(l=!0)}a=l,l&&(n=n.replace(/\\\s*$/,``)),!r&&!i&&!l&&(t.push(n),n=null,a=!1)}return n!==null&&t.push(n),t}_parseLines(e){e=this._accumulateLines(e);let t=[],n=0;for(;n<e.length;){let r=e[n].trim();if(!r||r.startsWith(`#`)){n++;continue}if(r.startsWith(`if `)||r===`if`){let r=this._parseIf(e,n);t.push(r.node),n+=r.consumed;continue}if(r.startsWith(`while `)){let r=this._parseWhile(e,n);t.push(r.node),n+=r.consumed;continue}if(r.startsWith(`for `)){let r=this._parseFor(e,n);t.push(r.node),n+=r.consumed;continue}if(r.startsWith(`case `)||r===`case`){let r=this._parseCase(e,n);t.push(r.node),n+=r.consumed;continue}if(/^(?:function\s+[\w\d_]+|[\w\d_]+\s*\(\s*\))\s*(?:\{.*)?$/.test(r)){let r=this._parseFunction(e,n);t.push(r.node),n+=r.consumed;continue}t.push({type:`command`,line:r}),n++}return t}_parseIf(e,t){let n=e=>e.replace(/^(?:if|elif)\s+/,``).replace(/\s*;\s*then\s*$/,``).replace(/\s+then\s*$/,``).trim(),r=[{condition:n(e[t].trim()),bodyLines:[]}],i=[],a=r[0],o=!1,s=1,c=t+1;for(c<e.length&&e[c].trim()===`then`&&c++;c<e.length;){let t=e[c].trim();if((t.startsWith(`if `)||t===`if`)&&s++,t===`fi`&&(s--,s===0)){c++;break}if(s===1&&t.startsWith(`elif `)){let i={condition:n(t),bodyLines:[]};r.push(i),a=i,c++,c<e.length&&e[c].trim()===`then`&&c++;continue}if(s===1&&t===`else`){o=!0,c++;continue}o?i.push(e[c]):a.bodyLines.push(e[c]),c++}return{node:{type:`if`,clauses:r,elseLines:i},consumed:c-t}}_parseWhile(e,t){let n=e[t].trim().replace(/^while\s+/,``).replace(/\s*;\s*do\s*$/,``).replace(/\s+do\s*$/,``).trim(),r=t+1;r<e.length&&e[r].trim()===`do`&&r++;let i=[],a=1;for(;r<e.length;){let t=e[r].trim();if((t.startsWith(`while `)||t.startsWith(`for `))&&a++,t===`done`&&(a--,a===0)){r++;break}i.push(e[r]),r++}return{node:{type:`while`,condition:n,bodyLines:i},consumed:r-t}}_parseFor(e,t){let n=e[t].trim().replace(/\s*;\s*do\s*$/,``).replace(/\s+do\s*$/,``).match(/^for\s+(\w+)\s+in\s+(.+)$/),r=n?n[1]:``,i=n?n[2].trim():``,a=t+1;a<e.length&&e[a].trim()===`do`&&a++;let o=[],s=1;for(;a<e.length;){let t=e[a].trim();if((t.startsWith(`while `)||t.startsWith(`for `))&&s++,t===`done`&&(s--,s===0)){a++;break}o.push(e[a]),a++}return{node:{type:`for`,variable:r,list:i,bodyLines:o},consumed:a-t}}async _executeNodes(e){for(let t of e)await this._executeNode(t)}_executeNode(e){if(e.type===`function`){let t=e.name,n=e.bodyLines,r=this,i=X(),a=class extends i{static get name(){return t}run(){let e=this.arguments.map((e,t)=>({key:String(t+1),prev:r.sandbox.context.getVar(String(t+1))}));this.arguments.forEach((e,t)=>r.sandbox.context.setVar(String(t+1),e));let t=()=>e.forEach(({key:e,prev:t})=>t?r.sandbox.context.setVar(e,t):r.sandbox.context.unsetVar(e));return r._executeFunctionBody(n).then(()=>{t()}).catch(e=>{if(t(),e&&e.__type===`return`){this.exitCode=e.code;return}return Promise.reject(e)})}};return this.sandbox.context.setCommand(a),Promise.resolve()}if(e.type===`command`){if(/^return(\s+\d+)?\s*$/.test(e.line.trim())){let t=e.line.trim().match(/^return\s+(\d+)/),n=t?parseInt(t[1],10):0;return Promise.reject({__type:`return`,code:n})}if(/^break(\s+\d+)?\s*$/.test(e.line.trim())){let t=e.line.trim().match(/^break\s+(\d+)/),n=t?parseInt(t[1],10):1;return Promise.reject({__type:`break`,count:n})}if(/^continue(\s+\d+)?\s*$/.test(e.line.trim())){let t=e.line.trim().match(/^continue\s+(\d+)/),n=t?parseInt(t[1],10):1;return Promise.reject({__type:`continue`,count:n})}return(this.sandbox.context.getVar(`-`)||``).includes(`x`)&&(this.stdErr=`+ ${e.line.trim()}`,this.flush()),this.sandbox.onCommand(e.line,!1).then(()=>{if((this.sandbox.context.getVar(`-`)||``).includes(`e`)&&this.sandbox.lastCode!==0)return Promise.reject({__type:`errexit`,code:this.sandbox.lastCode})})}return e.type===`if`?this._executeIf(e):e.type===`while`?this._executeWhile(e):e.type===`for`?this._executeFor(e):e.type===`case`?this._executeCase(e):Promise.resolve()}async _executeIf(e){for(let t of e.clauses)if(await this.sandbox.onCommand(t.condition,!1),this.sandbox.lastCode===0)return this._executeNodes(this._parseLines(t.bodyLines));if(e.elseLines.length>0)return this._executeNodes(this._parseLines(e.elseLines))}async _executeWhile(e){for(;await this.sandbox.onCommand(e.condition,!1),this.sandbox.lastCode===0;)try{await this._executeNodes(this._parseLines(e.bodyLines))}catch(e){if(e&&e.__type===`break`){if(e.count<=1)break;throw{__type:`break`,count:e.count-1}}if(e&&e.__type===`continue`){if(e.count<=1)continue;throw{__type:`continue`,count:e.count-1}}throw e}}async _executeFor(e){let t=e.list.replace(/\${?([\w\d]+)}?/g,(e,t)=>this.sandbox.context.getVar(t)||``).split(/\s+/).filter(Boolean);for(let n of t){this.sandbox.context.setVar(e.variable,n);try{await this._executeNodes(this._parseLines(e.bodyLines))}catch(e){if(e&&e.__type===`break`){if(e.count<=1)break;throw{__type:`break`,count:e.count-1}}if(e&&e.__type===`continue`){if(e.count<=1)continue;throw{__type:`continue`,count:e.count-1}}throw e}}}_parseFunction(e,t){let n=e[t].trim(),r=n.match(/^function\s+([\w\d_]+)/)||n.match(/^([\w\d_]+)\s*\(/),i=r?r[1]:``,a=t+1;if(!n.includes(`{`)){for(;a<e.length&&!e[a].includes(`{`);)a++;a++}let o=[],s=1;for(;a<e.length;){if(e[a].trim()===`}`){a++;break}let t=(e[a].match(/\{/g)||[]).length,n=(e[a].match(/\}/g)||[]).length;if(s+=t-n,s<=0){a++;break}o.push(e[a]),a++}return{node:{type:`function`,name:i,bodyLines:o},consumed:a-t}}_parseCase(e,t){let n=e[t].trim().match(/^case\s+(.+?)\s+in\s*$/),r=n?n[1]:``,i=t+1,a=[],o=null,s=[];for(;i<e.length;){let t=e[i],n=t.trim();if(i++,!(!n||n.startsWith(`#`))){if(n===`esac`)break;if(o===null){let e=n.match(/^(.+?)\)\s*(.*)$/);if(e){o=e[1].trim();let t=e[2].trim();if(t===`;;`)a.push({pattern:o,bodyLines:[]}),o=null;else if(t.endsWith(`;;`)){let e=t.slice(0,-2).trim();a.push({pattern:o,bodyLines:e?[e]:[]}),o=null}else s=t?[t]:[]}}else n===`;;`?(a.push({pattern:o,bodyLines:s}),o=null,s=[]):n.endsWith(`;;`)?(s.push(n.slice(0,-2).trim()),a.push({pattern:o,bodyLines:s}),o=null,s=[]):s.push(t)}}return o!==null&&a.push({pattern:o,bodyLines:s}),{node:{type:`case`,word:r,clauses:a},consumed:i-t}}_executeFunctionBody(e){return this._executeNodes(this._parseLines(e))}async _executeCase(e){let t=await this.sandbox._replaceVariables(e.word),n=t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t;for(let t of e.clauses)if(this._matchPattern(t.pattern,n))return this._executeNodes(this._parseLines(t.bodyLines))}_matchPattern(e,t){let n=``,r=0;for(;r<e.length;){let t=e[r];if(t===`[`){let t=e.indexOf(`]`,r+1);t===-1?(n+=`\\[`,r++):(n+=e.slice(r,t+1),r=t+1)}else t===`*`?(n+=`.*`,r++):t===`?`?(n+=`.`,r++):/[.+^${}()|\\]/.test(t)?(n+=`\\`+t,r++):(n+=t,r++)}try{return RegExp(`^`+n+`$`).test(t)}catch{return!1}}},t.exports.isKnownInterpreter=r})),ie=t(((e,t)=>{y();var n=re(),{BinaryFile:r}=q(),i=0,a=6,o=8,s=20,c=28,l=31,u=44,d=54,f=70,p=0,m=2,h=3,g=4,_=1,b=2,x=4,S=8,C=1,w=4,T=class extends n{get name(){return`wasm`}get requiresFilesystem(){return!0}get interactive(){if((this.arguments||[]).some(e=>e===`--help`||e===`-h`||e===`--version`||e===`-V`||e===`-v`))return!1;if(this._isInteractive!==void 0)return!!this._isInteractive;if(this._pkgMeta&&this._pkgMeta.interactive!==void 0)return!!this._pkgMeta.interactive;let e=(this.script||this.name||``).toLowerCase();return e===`nano`||e.endsWith(`/nano`)||e.endsWith(`nano.wasm`)}get captureInput(){return this.interactive}_enterAltScreen(){this._inAltScreen||(this._inAltScreen=!0,this.stdinStream&&typeof this.stdinStream.setRawMode==`function`&&this.stdinStream.setRawMode(!0),this.stdout&&typeof this.stdout.write==`function`&&this.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`))}_exitAltScreen(){this._inAltScreen&&(this._inAltScreen=!1,this.stdinStream&&typeof this.stdinStream.setRawMode==`function`&&this.stdinStream.setRawMode(!1),this.stdout&&typeof this.stdout.write==`function`&&this.stdout.write(`\x1B[?1049l\x1B[?25h`))}_keyToBytes(e){if(!e)return null;if(typeof e!=`string`)return e instanceof Uint8Array?e:new Uint8Array([Number(e)&255]);let t=e.match(/^\^([A-Za-z@\[\\\]^_?])$/);if(t){let e=t[1].toUpperCase();return e===`?`?new Uint8Array([127]):new Uint8Array([e.charCodeAt(0)-64])}let n={Enter:`\r`,Return:`\r`,Backspace:``,Tab:` `,Escape:`\x1B`,ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Home:`\x1B[H`,End:`\x1B[F`,PageUp:`\x1B[5~`,PageDown:`\x1B[6~`,Delete:`\x1B[3~`,Insert:`\x1B[2~`};return n[e]?new TextEncoder().encode(n[e]):new TextEncoder().encode(e)}onInput(e){if(!this._handlingStreamData&&!(this.stdinStream&&this.stdinStream._isPushing)){if(typeof this._externalKeyHandler==`function`){this._externalKeyHandler(e);return}this.stdinStream&&this.stdinStream.isRaw}}runCommand(){return super.runCommand().finally(()=>{this._inAltScreen&&this._exitAltScreen()})}run(){let e=this.script,t=(()=>{try{return J()}catch{return null}})();return this._loadBytes(e,t).then(({bytes:e,isWat:t})=>t?this._runWat(e):this._runWasm(e)).catch(e=>{this.stdErr=e.message||String(e),this.exitCode=1})}_loadBytes(e,t){let n=this.context&&this.context.fs||this.fs;if(!n)return Promise.reject(Error(`${e}: Filesystem is not available`));if(n.isRealFilesystem&&t)try{let r=t.readFileSync(n.absolutePath(e)),i=new Uint8Array(r);return Promise.resolve({bytes:i,isWat:this._isWat(e,i)})}catch(t){return Promise.reject(Error(`${e}: ${t.message}`))}let r=n.getFileByPath(e);if(r==null)return Promise.reject(Error(`${e}: No such file or directory`));let i=this._contentToBytes(r);return Promise.resolve({bytes:i,isWat:this._isWat(e,i)})}_isWat(e,t){return e.endsWith(`.wat`)?!0:t.length>0&&t[0]===40}_contentToBytes(e){if(e instanceof Uint8Array)return e;if(v!==void 0&&v.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}async _runWat(e){let t=new TextDecoder().decode(e),n,r;try{r=await import(`wabt`)}catch{this.stdErr=`${this.script}: WAT execution requires the 'wabt' package\nInstall it with: npm install wabt`,this.exitCode=1;return}try{let e=r.default??r,{buffer:i}=(typeof e==`function`?await e():e).parseWat(this.script,t,{mutable_globals:!0}).toBinary({});n=new Uint8Array(i)}catch(e){this.stdErr=`${this.script}: WAT compilation error: ${e.message}`,this.exitCode=1;return}return this._runWasm(n)}async _runWasm(e){if(typeof WebAssembly>`u`){this.stdErr=`${this.script}: WebAssembly is not available in this environment`,this.exitCode=1;return}let t={1:``,2:``},n=new TextDecoder,y=new TextEncoder,T=null,E=null,D=!1,O=0,k=null,A=null,N=null,P=null,F=this.stdin===void 0||this.stdin===null||this.stdin===this.stdinStream||this.stdin&&this.stdin.isTTY,I=!!(this.interactive&&F),L=()=>{I||!F||(I=!0,this._isInteractive=!0,t[1]&&=(this.stdout&&typeof this.stdout.write==`function`&&this.stdout.write(t[1]),``),t[2]&&=(this.stderr&&typeof this.stderr.write==`function`&&this.stderr.write(t[2]),``),this.stdinStream&&typeof this.stdinStream.setRawMode==`function`&&this.stdinStream.setRawMode(!0))},R=(e,n)=>{if(I&&(e===1||e===2)){if(e===1&&this.stdout){this.stdout.write(n);return}if(e===2&&this.stderr){this.stderr.write(n);return}}t[e]=(t[e]||``)+n;let r=t[e].split(`
5
- `);t[e]=r.pop();for(let t of r)e===1?this.stdOut=t:this.stdErr=t},z=()=>{t[1]&&=(I&&this.stdout?this.stdout.write(t[1]):this.stdOut=t[1],``),t[2]&&=(I&&this.stderr?this.stderr.write(t[2]):this.stdErr=t[2],``)},B=[],V=e=>{if(!(!e||e.length===0)){for(let t=0;t<e.length;t++)B.push(e[t]);if(A){let e=A;A=null,e()}}};P=e=>{this._handlingStreamData=!0;try{V(typeof e==`string`?y.encode(e):e instanceof Uint8Array?e:v!==void 0&&v.isBuffer(e)?new Uint8Array(e):y.encode(String(e??``)))}finally{this._handlingStreamData=!1}},this._externalKeyHandler=e=>{if(this._handlingStreamData)return;let t=this._keyToBytes(e);t&&V(t)},this._onStdinStreamData&&this.stdinStream&&typeof this.stdinStream.off==`function`&&this.stdinStream.off(`data`,this._onStdinStreamData),F&&this.stdinStream&&typeof this.stdinStream.on==`function`&&this.stdinStream.on(`data`,P),F&&this.stdin&&this.stdin!==this.stdinStream&&typeof this.stdin.on==`function`&&this.stdin.on(`data`,P);let H=!F&&typeof this.stdin==`string`?y.encode(this.stdin):!F&&this.stdin instanceof Uint8Array?this.stdin:!F&&v!==void 0&&v.isBuffer(this.stdin)?new Uint8Array(this.stdin):new Uint8Array,U=0,W=this.context&&this.context.fs?this.context.fs:this.fs,G=this.context&&this.context.fs&&this.context.fs.cwd||this.fs&&this.fs.cwd||this.context&&typeof this.context.getVar==`function`&&this.context.getVar(`PWD`)||W&&W.cwd||`/`,ee=G.length>1&&G.endsWith(`/`)?G.slice(0,-1):G,K=5,q=new Map([[3,{type:`preopen`,path:`/`,guestName:`/`}],[4,{type:`preopen`,path:ee,guestName:`.`}]]),J=new Map([[0,0],[1,0],[2,0]]),te=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),`/`+t.join(`/`)},ne=(e,t)=>{let n=q.get(e);if(!n||n.type!==`preopen`&&n.type!==`dir`)return null;if(t.startsWith(`/`))return W.absolutePath(t);if(!t||t===`.`)return W.absolutePath(n.path);let r=n.path.endsWith(`/`)?n.path:n.path+`/`,i=W.absolutePath(r+t),a=W.absolutePath(`/`+t);if(n.path!==`/`){if(W.exists(i))return i;if(W.exists(a))return a;let e=W.exists(te(i));return W.exists(te(a))&&!e?a:i}if(W.exists(i))return i;let o=W.absolutePath(t);return W.exists(o)?o:i},Y=e=>{if(!(!e||e.type!==`file`||!e.dirty||!W))try{let t=!0;for(let n=0;n<e.bytes.length;n++)if(e.bytes[n]===0){t=!1;break}if(t){let t=n.decode(e.bytes);W.setFileByPath(e.path,t,!0)}else{let t=new Uint8Array(e.bytes.length);t.set(e.bytes),W.setFileByPath(e.path,new r(t.buffer,`application/octet-stream`),!0)}e.dirty=!1}catch{}},X={TERM:`xterm-256color`,COLORTERM:`truecolor`,COLUMNS:String(this.stdout&&this.stdout.columns||this.context&&typeof this.context.getVar==`function`&&this.context.getVar(`COLUMNS`)||80),LINES:String(this.stdout&&this.stdout.rows||this.context&&typeof this.context.getVar==`function`&&this.context.getVar(`LINES`)||24),...this.context&&this.context.vars||{}},re=Object.entries(X).map(([e,t])=>`${e}=${t}`),ie=new Proxy({fd_write:(e,t,r,a)=>{if(!T)return o;let s=new DataView(T.buffer);if(e===1||e===2){let o=0;for(let i=0;i<r;i++){let r=s.getUint32(t+i*8,!0),a=s.getUint32(t+i*8+4,!0);a>0&&R(e,n.decode(new Uint8Array(T.buffer,r,a))),o+=a}return s.setUint32(a,o,!0),i}let c=q.get(e);if(!c)return o;if(c.type===`dev_null`||c.type===`dev_zero`){let e=0;for(let n=0;n<r;n++)e+=s.getUint32(t+n*8+4,!0);return s.setUint32(a,e,!0),i}if(c.type===`dev_tty`){let e=0;for(let i=0;i<r;i++){let r=s.getUint32(t+i*8,!0),a=s.getUint32(t+i*8+4,!0);a>0&&R(1,n.decode(new Uint8Array(T.buffer,r,a))),e+=a}return s.setUint32(a,e,!0),i}if(c.type!==`file`)return o;let l=0;for(let e=0;e<r;e++){let n=s.getUint32(t+e*8,!0),r=s.getUint32(t+e*8+4,!0);if(r>0){let e=new Uint8Array(T.buffer,n,r),t=c.append?c.bytes.length:c.pos,i=t+r;if(i>c.bytes.length){let e=new Uint8Array(i);e.set(c.bytes),c.bytes=e}c.bytes.set(e,t),c.pos=t+r,c.dirty=!0,l+=r}}return s.setUint32(a,l,!0),i},fd_read:(e,t,n,r)=>{if(!T)return o;let s=new DataView(T.buffer),c=q.get(e),l=!!(c&&c.type===`dev_tty`);if(e===0||I&&e===2||l){(l||e===2)&&L();let o=!!((J.get(e)||0)&w);if(D){if((typeof E?.exports?.asyncify_get_state==`function`?E.exports.asyncify_get_state():0)===2){E.exports.asyncify_stop_rewind();let e=0;for(let r=0;r<n&&B.length>0;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0),a=Math.min(i,B.length),o=B.splice(0,a);new Uint8Array(T.buffer).set(o,n),e+=a}return s.setUint32(r,e,!0),i}if(B.length>0){let e=0;for(let r=0;r<n&&B.length>0;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0),a=Math.min(i,B.length),o=B.splice(0,a);new Uint8Array(T.buffer).set(o,n),e+=a}return s.setUint32(r,e,!0),i}return o?(s.setUint32(r,0,!0),a):(E.exports.asyncify_start_unwind(O),k=new Promise(e=>{A=e}),s.setUint32(r,0,!0),i)}if(B.length>0){let e=0;for(let r=0;r<n&&B.length>0;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0),a=Math.min(i,B.length),o=B.splice(0,a);new Uint8Array(T.buffer).set(o,n),e+=a}return s.setUint32(r,e,!0),i}let c=0;for(let e=0;e<n&&U<H.length;e++){let n=s.getUint32(t+e*8,!0),r=s.getUint32(t+e*8+4,!0),i=Math.min(r,H.length-U);new Uint8Array(T.buffer).set(H.slice(U,U+i),n),U+=i,c+=i}return c===0&&o&&U>=H.length?(s.setUint32(r,0,!0),a):(s.setUint32(r,c,!0),i)}if(!c)return o;if(c.type===`dev_null`)return s.setUint32(r,0,!0),i;if(c.type===`dev_zero`){let e=0;for(let r=0;r<n;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0);new Uint8Array(T.buffer,n,i).fill(0),e+=i}return s.setUint32(r,e,!0),i}if(c.type===`dev_urandom`){let e=0;for(let r=0;r<n;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0),a=new Uint8Array(T.buffer,n,i);if(typeof crypto<`u`&&crypto.getRandomValues)crypto.getRandomValues(a);else for(let e=0;e<i;e++)a[e]=Math.floor(Math.random()*256);e+=i}return s.setUint32(r,e,!0),i}if(c.type!==`file`)return o;let u=0;for(let e=0;e<n&&c.pos<c.bytes.length;e++){let n=s.getUint32(t+e*8,!0),r=s.getUint32(t+e*8+4,!0),i=Math.min(r,c.bytes.length-c.pos);new Uint8Array(T.buffer).set(c.bytes.subarray(c.pos,c.pos+i),n),c.pos+=i,u+=i}return s.setUint32(r,u,!0),i},fd_seek:(e,t,n,r,a)=>{if(!T)return o;if(e<=2)return f;let s=q.get(e);if(!s)return o;if(s.type===`dev_tty`||s.type===`dev_null`||s.type===`dev_zero`||s.type===`dev_urandom`)return f;if(s.type!==`file`)return o;let l,u,d;typeof t==`bigint`?(l=Number(t),u=n,d=r):(l=t,u=r,d=a);let p=s.pos;if(u===0)p=l;else if(u===1)p=s.pos+l;else if(u===2)p=s.bytes.length+l;else return c;return p<0?c:(s.pos=p,d&&new DataView(T.buffer).setBigUint64(d,BigInt(s.pos),!0),i)},fd_tell:(e,t)=>{if(!T)return o;let n=q.get(e);return!n||n.type!==`file`?o:(new DataView(T.buffer).setBigUint64(t,BigInt(n.pos),!0),i)},fd_close:e=>{if(e<=2)return i;let t=q.get(e);return t?(t.type===`file`&&Y(t),q.delete(e),J.delete(e),i):o},fd_sync:e=>{let t=q.get(e);return t&&Y(t),i},fd_datasync:e=>{let t=q.get(e);return t&&Y(t),i},fd_prestat_get:(e,t)=>{if(!T)return o;let n=q.get(e);if(!n||n.type!==`preopen`)return o;let r=new DataView(T.buffer),a=y.encode(n.guestName);return r.setUint8(t,0),r.setUint32(t+4,a.length,!0),i},fd_prestat_dir_name:(e,t,n)=>{if(!T)return o;let r=q.get(e);if(!r||r.type!==`preopen`)return o;let a=y.encode(r.guestName);return new Uint8Array(T.buffer,t,Math.min(n,a.length)).set(a.subarray(0,n)),i},fd_fdstat_get:(e,t)=>{if(!T)return o;let n=new DataView(T.buffer),r=p;if(e<=2)r=m;else{let t=q.get(e);if(!t)return o;r=t.type===`dev_null`||t.type===`dev_zero`||t.type===`dev_urandom`||t.type===`dev_tty`?m:t.type===`preopen`||t.type===`dir`?h:g}for(let e=0;e<24;e++)n.setUint8(t+e,0);n.setUint8(t,r);let a=J.get(e)||(q.get(e)?.append?C:0);return n.setUint16(t+2,a,!0),n.setBigUint64(t+8,18446744073709551615n,!0),n.setBigUint64(t+16,18446744073709551615n,!0),i},fd_fdstat_set_flags:(e,t)=>{if(!T||e>2&&!q.has(e))return o;J.set(e,t);let n=q.get(e);return n&&(n.append=!!(t&C)),(e===0||e===2||n&&n.type===`dev_tty`)&&t&w&&L(),i},fd_filestat_get:(e,t)=>{if(!T)return o;let n=new DataView(T.buffer);for(let e=0;e<64;e++)n.setUint8(t+e,0);if(e<=2)return n.setUint8(t+16,m),i;let r=q.get(e);if(!r)return o;if(r.type===`dev_null`||r.type===`dev_zero`||r.type===`dev_urandom`||r.type===`dev_tty`)return n.setUint8(t+16,m),n.setBigUint64(t+24,1n,!0),i;let a=r.type===`preopen`||r.type===`dir`;return n.setUint8(t+16,a?h:g),n.setBigUint64(t+24,1n,!0),n.setBigUint64(t+32,BigInt(r.bytes?r.bytes.length:0),!0),i},path_open:(e,t,r,a,c,f,p,m,h)=>{if(!T||!W)return o;let g=ne(e,n.decode(new Uint8Array(T.buffer,r,a)));if(!g)return o;let v=g.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`;if(v===`/dev/null`){let e=K++;return q.set(e,{type:`dev_null`,path:`/dev/null`}),new DataView(T.buffer).setUint32(h,e,!0),i}if(v===`/dev/zero`){let e=K++;return q.set(e,{type:`dev_zero`,path:`/dev/zero`}),new DataView(T.buffer).setUint32(h,e,!0),i}if(v===`/dev/urandom`||v===`/dev/random`){let e=K++;return q.set(e,{type:`dev_urandom`,path:v}),new DataView(T.buffer).setUint32(h,e,!0),i}if(v===`/dev/tty`){L();let e=K++;return q.set(e,{type:`dev_tty`,path:`/dev/tty`}),new DataView(T.buffer).setUint32(h,e,!0),i}let w=W.stat(g),E=w!==null;if(c&x&&c&_&&E)return s;if(c&b){if(!E)return u;if(!w.isDirectory)return d;let e=K++;return q.set(e,{type:`dir`,path:g}),new DataView(T.buffer).setUint32(h,e,!0),i}if(E&&w.isDirectory)return l;if(!E&&!(c&_))return u;let D=new Uint8Array,O=!1;if(E&&!(c&S)){let e=W.getFileByPath(g);e!=null&&(D=typeof e==`string`?y.encode(e):new Uint8Array(this._contentToBytes(e)))}else O=!0;let k=K++;return q.set(k,{type:`file`,path:g,bytes:D,pos:m&C?D.length:0,append:!!(m&C),dirty:O}),new DataView(T.buffer).setUint32(h,k,!0),i},path_filestat_get:(e,t,r,a,s)=>{if(!T||!W)return o;let c=ne(e,n.decode(new Uint8Array(T.buffer,r,a)));if(!c)return o;let l=c.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`;if(l===`/dev/null`||l===`/dev/zero`||l===`/dev/urandom`||l===`/dev/random`||l===`/dev/tty`){let e=new DataView(T.buffer);for(let t=0;t<64;t++)e.setUint8(s+t,0);return e.setUint8(s+16,m),e.setBigUint64(s+24,1n,!0),i}let d=W.stat(c);if(!d)return u;let f=new DataView(T.buffer);for(let e=0;e<64;e++)f.setUint8(s+e,0);return f.setUint8(s+16,d.isDirectory?h:g),f.setBigUint64(s+24,1n,!0),f.setBigUint64(s+32,BigInt(W.getSize(c)||0),!0),i},path_create_directory:(e,t,r)=>{if(!T||!W)return o;let a=ne(e,n.decode(new Uint8Array(T.buffer,t,r)));if(!a)return o;try{return W.setFileByPath(a,{},!0),i}catch{return c}},path_unlink_file:(e,t,r)=>{if(!T||!W)return o;let a=ne(e,n.decode(new Uint8Array(T.buffer,t,r)));if(!a||!W.exists(a))return u;try{return W.deleteFileByPath(a),i}catch{return c}},path_remove_directory:(e,t,r)=>{if(!T||!W)return o;let a=ne(e,n.decode(new Uint8Array(T.buffer,t,r)));if(!a||!W.exists(a))return u;try{return W.deleteFileByPath(a),i}catch{return c}},path_rename:(e,t,r,a,s,l)=>{if(!T||!W)return o;let d=n.decode(new Uint8Array(T.buffer,t,r)),f=n.decode(new Uint8Array(T.buffer,s,l)),p=ne(e,d),m=ne(a,f);if(!p||!m)return o;if(!W.exists(p))return u;for(let e of q.values())e.path===p&&(Y(e),e.path=m);try{let e=W.getFileByPath(p);return W.setFileByPath(m,e,!0),W.deleteFileByPath(p),i}catch{return c}},proc_exit:e=>{throw e!==0&&(this.exitCode=e),{_wasmExit:!0,code:e}},args_sizes_get:(e,t)=>{if(!T)return c;let n=[this.script,...this.arguments||[]],r=new DataView(T.buffer);return r.setUint32(e,n.length,!0),r.setUint32(t,n.reduce((e,t)=>e+y.encode(t).length+1,0),!0),i},args_get:(e,t)=>{if(!T)return c;let n=[this.script,...this.arguments||[]],r=new DataView(T.buffer),a=t;for(let t=0;t<n.length;t++){r.setUint32(e+t*4,a,!0);let i=y.encode(n[t]+`\0`);new Uint8Array(T.buffer).set(i,a),a+=i.length}return i},environ_sizes_get:(e,t)=>{if(!T)return c;let n=new DataView(T.buffer);n.setUint32(e,re.length,!0);let r=re.reduce((e,t)=>e+y.encode(t).length+1,0);return n.setUint32(t,r,!0),i},environ_get:(e,t)=>{if(!T)return c;let n=new DataView(T.buffer),r=t;for(let t=0;t<re.length;t++){n.setUint32(e+t*4,r,!0);let i=y.encode(re[t]+`\0`);new Uint8Array(T.buffer).set(i,r),r+=i.length}return i},clock_time_get:(e,t,n)=>{if(T){let e=BigInt(Date.now())*1000000n;new DataView(T.buffer).setBigUint64(n,e,!0)}return i},random_get:(e,t)=>{if(T){let n=new Uint8Array(T.buffer,e,t);for(let e=0;e<t;e++)n[e]=Math.random()*256|0}return i},clock_nanosleep:(e,t,n,r,a)=>{if(!T)return o;let s=new DataView(T.buffer).getBigUint64(n,!0),c=0;if(t&1){let e=BigInt(Date.now())*1000000n;c=s>e?Number((s-e)/1000000n):0}else c=Number(s/1000000n);return D&&c>0?(typeof E?.exports?.asyncify_get_state==`function`?E.exports.asyncify_get_state():0)===2?(E.exports.asyncify_stop_rewind(),i):(E.exports.asyncify_start_unwind(O),k=new Promise(e=>setTimeout(e,Math.max(1,c))),i):i},poll_oneoff:(e,t,n,r)=>{if(!T)return o;let a=new DataView(T.buffer);if(D){if((typeof E?.exports?.asyncify_get_state==`function`?E.exports.asyncify_get_state():0)===2){E.exports.asyncify_stop_rewind();let o=0;for(let r=0;r<n;r++){let n=e+r*48,s=a.getBigUint64(n,!0),c=a.getUint8(n+8),l=t+o*32;a.setBigUint64(l,s,!0),a.setUint16(l+8,i,!0),a.setUint8(l+10,c);for(let e=11;e<32;e++)a.setUint8(l+e,0);c===1&&a.setBigUint64(l+16,BigInt(B.length),!0),o++}return a.setUint32(r,o,!0),i}let o=0,s=1/0;for(let t=0;t<n;t++){let n=e+t*48,r=a.getUint8(n+8);if(r===0){let e=a.getBigUint64(n+24,!0),t=a.getUint16(n+40,!0),r=0;if(t&1){let t=BigInt(Date.now())*1000000n;r=e>t?Number((e-t)/1000000n):0}else r=Number(e/1000000n);r<s&&(s=r)}else if(r===1){let e=a.getUint32(n+16,!0),t=q.get(e),r=!!(t&&t.type===`dev_tty`);(e===0||e===2||r)&&L(),(e===0||I&&e===2||r)&&B.length>0&&o++}else r===2&&o++}if(o>0||s===0){let o=0;for(let r=0;r<n;r++){let n=e+r*48,c=a.getBigUint64(n,!0),l=a.getUint8(n+8),u=!1;if(l===0&&s===0)u=!0;else if(l===1){let e=a.getUint32(n+16,!0),t=q.get(e),r=!!(t&&t.type===`dev_tty`);(e===0||I&&e===2||r)&&B.length>0&&(u=!0)}else l===2&&(u=!0);if(u){let e=t+o*32;a.setBigUint64(e,c,!0),a.setUint16(e+8,i,!0),a.setUint8(e+10,l);for(let t=11;t<32;t++)a.setUint8(e+t,0);l===1&&a.setBigUint64(e+16,BigInt(B.length),!0),o++}}return a.setUint32(r,o,!0),i}return E.exports.asyncify_start_unwind(O),k=new Promise(e=>{let t=null;A=()=>{t&&clearTimeout(t),A=null,e()},s!==1/0&&(t=setTimeout(()=>{A=null,e()},Math.max(1,s)))}),a.setUint32(r,0,!0),i}return a.setUint32(r,0,!0),i}},{get(e,t){return t in e?e[t]:()=>0}}),ae=e=>{if(!T||!e)return``;try{let t=new DataView(T.buffer).getUint32(e-4,!0),n=new Uint16Array(T.buffer,e,t>>>1);return String.fromCharCode(...n)}catch{return``}},oe={wasi_snapshot_preview1:ie,wasi_unstable:ie,env:new Proxy({print:(e,t)=>{T&&R(1,n.decode(new Uint8Array(T.buffer,e,t)))},eprint:(e,t)=>{T&&R(2,n.decode(new Uint8Array(T.buffer,e,t)))},log:e=>{R(1,ae(e)+`
1
+ "use strict";var Shell=(function(){var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);function n(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function r(e){var t=n(e),r=t[0],i=t[1];return(r+i)*3/4-i}function i(e,t,n){return(t+n)*3/4-n}function a(e){var t,r=n(e),a=r[0],o=r[1],s=new p(i(e,a,o)),c=0,l=o>0?a-4:a,u;for(u=0;u<l;u+=4)t=f[e.charCodeAt(u)]<<18|f[e.charCodeAt(u+1)]<<12|f[e.charCodeAt(u+2)]<<6|f[e.charCodeAt(u+3)],s[c++]=t>>16&255,s[c++]=t>>8&255,s[c++]=t&255;return o===2&&(t=f[e.charCodeAt(u)]<<2|f[e.charCodeAt(u+1)]>>4,s[c++]=t&255),o===1&&(t=f[e.charCodeAt(u)]<<10|f[e.charCodeAt(u+1)]<<4|f[e.charCodeAt(u+2)]>>2,s[c++]=t>>8&255,s[c++]=t&255),s}function o(e){return d[e>>18&63]+d[e>>12&63]+d[e>>6&63]+d[e&63]}function s(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(o(r));return i.join(``)}function c(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,c=n-r;o<c;o+=a)i.push(s(e,o,o+a>c?c:o+a));return r===1?(t=e[n-1],i.push(d[t>>2]+d[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(d[t>>10]+d[t>>4&63]+d[t<<2&63]+`=`)),i.join(``)}var l,u,d,f,p,m,h,g,_,v,y=e((()=>{for(l={},u={},u.byteLength=r,u.toByteArray=a,u.fromByteArray=c,d=[],f=[],p=typeof Uint8Array<`u`?Uint8Array:Array,m=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,h=0,g=m.length;h<g;++h)d[h]=m[h],f[m.charCodeAt(h)]=h;f[45]=62,f[95]=63,_={},_.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},_.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=u,n=_,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=d,e.SlowBuffer=C,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;d.TYPED_ARRAY_SUPPORT=c(),!d.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,d.prototype),t}function d(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return h(e)}return f(e,t,n)}d.poolSize=8192;function f(e,t,n){if(typeof e==`string`)return g(e,t);if(o.isView(e))return y(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(fe(e,o)||e&&fe(e.buffer,o)||s!==void 0&&(fe(e,s)||e&&fe(e.buffer,s)))return b(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return d.from(r,t,n);let i=x(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return d.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}d.from=function(e,t,n){return f(e,t,n)},Object.setPrototypeOf(d.prototype,a.prototype),Object.setPrototypeOf(d,a);function p(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function m(e,t,n){return p(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}d.alloc=function(e,t,n){return m(e,t,n)};function h(e){return p(e),l(e<0?0:S(e)|0)}d.allocUnsafe=function(e){return h(e)},d.allocUnsafeSlow=function(e){return h(e)};function g(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!d.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=w(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function v(e){let t=e.length<0?0:S(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function y(e){if(fe(e,a)){let t=new a(e);return b(t.buffer,t.byteOffset,t.byteLength)}return v(e)}function b(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,d.prototype),r}function x(e){if(d.isBuffer(e)){let t=S(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||pe(e.length)?l(0):v(e);if(e.type===`Buffer`&&Array.isArray(e.data))return v(e.data)}function S(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function C(e){return+e!=e&&(e=0),d.alloc(+e)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype},d.compare=function(e,t){if(fe(e,a)&&(e=d.from(e,e.offset,e.byteLength)),fe(t,a)&&(t=d.from(t,t.offset,t.byteLength)),!d.isBuffer(e)||!d.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},d.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},d.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return d.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=d.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(fe(t,a))i+t.length>r.length?(d.isBuffer(t)||(t=d.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(d.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function w(e,t){if(d.isBuffer(e))return e.length;if(o.isView(e)||fe(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return se(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return ue(e).length;default:if(i)return r?-1:se(e).length;t=(``+t).toLowerCase(),i=!0}}d.byteLength=w;function T(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return B(this,t,n);case`utf8`:case`utf-8`:return F(this,t,n);case`ascii`:return R(this,t,n);case`latin1`:case`binary`:return z(this,t,n);case`base64`:return P(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return V(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function E(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}d.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)E(this,t,t+1);return this},d.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)E(this,t,t+3),E(this,t+1,t+2);return this},d.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)E(this,t,t+7),E(this,t+1,t+6),E(this,t+2,t+5),E(this,t+3,t+4);return this},d.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?F(this,0,e):T.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(e){if(!d.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:d.compare(this,e)===0},d.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(d.prototype[r]=d.prototype.inspect),d.prototype.compare=function(e,t,n,r,i){if(fe(e,a)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),u=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==u[e]){o=l[e],s=u[e];break}return o<s?-1:+(s<o)};function D(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,pe(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=d.from(t,r)),d.isBuffer(t))return t.length===0?-1:O(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):O(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function O(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}d.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},d.prototype.indexOf=function(e,t,n){return D(this,e,t,n,!0)},d.prototype.lastIndexOf=function(e,t,n){return D(this,e,t,n,!1)};function k(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(pe(r))return o;e[n+o]=r}return o}function A(e,t,n,r){return de(se(t,e.length-n),e,n,r)}function j(e,t,n,r){return de(ce(t),e,n,r)}function M(e,t,n,r){return de(ue(t),e,n,r)}function N(e,t,n,r){return de(le(t,e.length-n),e,n,r)}d.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return k(this,e,t,n);case`utf8`:case`utf-8`:return A(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return j(this,e,t,n);case`base64`:return M(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return N(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},d.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function P(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function F(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return L(r)}let I=4096;function L(e){let t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}function R(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function z(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function B(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=me[e[r]];return i}function V(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}d.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,d.prototype),r};function H(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},d.prototype.readUintBE=d.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},d.prototype.readUint8=d.prototype.readUInt8=function(e,t){return e>>>=0,t||H(e,1,this.length),this[e]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,t){return e>>>=0,t||H(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,t){return e>>>=0,t||H(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,t){return e>>>=0,t||H(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readBigUInt64LE=Z(function(e){e>>>=0,re(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ie(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),d.prototype.readBigUInt64BE=Z(function(e){e>>>=0,re(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ie(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),d.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},d.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||H(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},d.prototype.readInt8=function(e,t){return e>>>=0,t||H(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},d.prototype.readInt16LE=function(e,t){e>>>=0,t||H(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},d.prototype.readInt16BE=function(e,t){e>>>=0,t||H(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},d.prototype.readInt32LE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},d.prototype.readInt32BE=function(e,t){return e>>>=0,t||H(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readBigInt64LE=Z(function(e){e>>>=0,re(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ie(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),d.prototype.readBigInt64BE=Z(function(e){e>>>=0,re(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ie(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),d.prototype.readFloatLE=function(e,t){return e>>>=0,t||H(e,4,this.length),n.read(this,e,!0,23,4)},d.prototype.readFloatBE=function(e,t){return e>>>=0,t||H(e,4,this.length),n.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function(e,t){return e>>>=0,t||H(e,8,this.length),n.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function(e,t){return e>>>=0,t||H(e,8,this.length),n.read(this,e,!1,52,8)};function U(e,t,n,r,i,a){if(!d.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;U(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;U(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},d.prototype.writeUint8=d.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,255,0),this[t]=e&255,t+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function W(e,t,n,r,i){X(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function G(e,t,n,r,i){X(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}d.prototype.writeBigUInt64LE=Z(function(e,t=0){return W(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeBigUInt64BE=Z(function(e,t=0){return G(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);U(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},d.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);U(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},d.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},d.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},d.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},d.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},d.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},d.prototype.writeBigInt64LE=Z(function(e,t=0){return W(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),d.prototype.writeBigInt64BE=Z(function(e,t=0){return G(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ee(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function K(e,t,r,i,a){return t=+t,r>>>=0,a||ee(e,t,r,4),n.write(e,t,r,i,23,4),r+4}d.prototype.writeFloatLE=function(e,t,n){return K(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return K(this,e,t,!1,n)};function q(e,t,r,i,a){return t=+t,r>>>=0,a||ee(e,t,r,8),n.write(e,t,r,i,52,8),r+8}d.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},d.prototype.copy=function(e,t,n,r){if(!d.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},d.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!d.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=d.isBuffer(e)?e:d.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let J={};function te(e,t,n){J[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}te(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),te(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),te(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=ne(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=ne(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function ne(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function Y(e,t,n){re(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&ie(t,e.length-(n+1))}function X(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new J.ERR_OUT_OF_RANGE(`value`,i,e)}Y(r,i,a)}function re(e,t){if(typeof e!=`number`)throw new J.ERR_INVALID_ARG_TYPE(t,`number`,e)}function ie(e,t,n){throw Math.floor(e)===e?t<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(re(e,n),new J.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let ae=/[^+/0-9A-Za-z-_]/g;function oe(e){if(e=e.split(`=`)[0],e=e.trim().replace(ae,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function se(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function ce(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function le(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function ue(e){return t.toByteArray(oe(e))}function de(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function fe(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function pe(e){return e!==e}let me=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function Z(e){return typeof BigInt>`u`?he:e}function he(){throw Error(`BigInt not supported`)}})(l),v=l.Buffer,l.Blob,l.BlobOptions,l.Buffer,l.File,l.FileOptions,l.INSPECT_MAX_BYTES,l.SlowBuffer,l.TranscodeEncoding,l.atob,l.btoa,l.constants,l.isAscii,l.isUtf8,l.kMaxLength,l.kStringMaxLength,l.resolveObjectURL,l.transcode})),b=t(((e,t)=>{y();var n=new Set([`cwd`,`getFileByPath`,`setFileByPath`,`deleteFileByPath`,`exists`,`stat`,`absolutePath`,`getMode`,`setMode`,`isReadable`,`isWritable`,`isExecutable`,`getSize`,`autoComplete`,`isRealFilesystem`,`isSymlink`,`readSymlink`,`createSymlink`,`setTtyDevice`]),r=class{isReadable(e){let t=this.getMode(e);return t===null?!1:(t&256)!=0}isWritable(e){let t=this.getMode(e);return t===null?!1:(t&128)!=0}isExecutable(e){let t=this.getMode(e);return t===null?!1:(t&64)!=0}sandbox(){let e=this;return new Proxy(Object.create(null),{get(t,r){if(!n.has(r))return;let i=e[r];return typeof i==`function`?i.bind(e):i},set(){return!1},has(e,t){return n.has(t)}})}_triggerChange(){!this._onChange||this._changeScheduled||(this._changeScheduled=!0,Promise.resolve().then(()=>{this._changeScheduled=!1,typeof this._onChange==`function`&&this._onChange(this.getRaw(),this.getRawPermissions())}))}},i=class extends Uint8Array{constructor(e,t){super(e),Object.defineProperty(this,"mimeType",{value:t,enumerable:!1,configurable:!1,writable:!1})}toString(){if(v!==void 0)return`data:${this.mimeType};base64,${v.from(this).toString(`base64`)}`;let e=``,t=8192;for(let n=0;n<this.length;n+=t)e+=String.fromCharCode(...this.subarray(n,n+t));return`data:${this.mimeType};base64,${btoa(e)}`}},a=class{constructor(e){this.target=e}},o=class{constructor(e,t={}){this.name=e,this.read=typeof t.read==`function`?t.read:(()=>``),this.write=typeof t.write==`function`?t.write:(()=>{}),this.mode=t.mode===void 0?438:t.mode,this.isCharacterDevice=!0}toString(){let e=this.read();return e==null?``:typeof e==`string`?e:e.toString()}};t.exports=r,t.exports.BinaryFile=i,t.exports.SymlinkRef=a,t.exports.DeviceFile=o}));function x(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function S(){throw Error(`setTimeout has not been defined`)}function C(){throw Error(`clearTimeout has not been defined`)}function w(e){if(M===setTimeout)return setTimeout(e,0);if((M===S||!M)&&setTimeout)return M=setTimeout,setTimeout(e,0);try{return M(e,0)}catch{try{return M.call(null,e,0)}catch{return M.call(this,e,0)}}}function T(e){if(N===clearTimeout)return clearTimeout(e);if((N===C||!N)&&clearTimeout)return N=clearTimeout,clearTimeout(e);try{return N(e)}catch{try{return N.call(null,e)}catch{return N.call(this,e)}}}function E(){!F||!I||(F=!1,I.length?P=I.concat(P):L=-1,P.length&&D())}function D(){if(!F){var e=w(E);F=!0;for(var t=P.length;t;){for(I=P,P=[];++L<t;)I&&I[L].run();L=-1,t=P.length}I=null,F=!1,T(e)}}function O(e,t){this.fun=e,this.array=t}function k(){}var A,j,M,N,P,F,I,L,R,z,B=e((()=>{A={exports:{}},j=A.exports={},(function(){try{M=typeof setTimeout==`function`?setTimeout:S}catch{M=S}try{N=typeof clearTimeout==`function`?clearTimeout:C}catch{N=C}})(),P=[],F=!1,L=-1,j.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];P.push(new O(e,t)),P.length===1&&!F&&w(D)},O.prototype.run=function(){this.fun.apply(null,this.array)},j.title=`browser`,j.browser=!0,j.env={},j.argv=[],j.version=``,j.versions={},j.on=k,j.addListener=k,j.once=k,j.off=k,j.removeListener=k,j.removeAllListeners=k,j.emit=k,j.prependListener=k,j.prependOnceListener=k,j.listeners=function(e){return[]},j.binding=function(e){throw Error(`process.binding is not supported`)},j.cwd=function(){return`/`},j.chdir=function(e){throw Error(`process.chdir is not supported`)},j.umask=function(){return 0},R=A.exports,z=x(R)})),V=t(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),H=t(((e,t)=>{var n=[`out`,`err`];t.exports=class{constructor(e,t){if(!n.includes(e))throw Error(`incorrect std output type`);this.type=e,this.string=t}}})),U=t(((e,t)=>{var n=H();t.exports=class{constructor(e=[],t=0){if(typeof t!=`number`)throw Error(`Command Result ExitCode must be a number`);if(!Array.isArray(e))throw Error(`Command Result be array`);this.std=e,this.exitCode=t}addStdOutLine(e){this.std.push(new n(`out`,e))}addStdErrLine(e){this.std.push(new n(`err`,e))}getStdOutput(){return this.std}getExitCode(){return this.exitCode}flush(){let e=this.std;return this.std=[],e}}})),W=t(((e,t)=>{y();var n=V(),r=n.EventEmitter||n.default||n;function i(e){if(!e)return[];let t=typeof e==`string`?e:e instanceof Uint8Array||v!==void 0&&v.isBuffer(e)?new TextDecoder().decode(e):String(e),n=[],r=0;for(;r<t.length;){let e=t[r],i=t.charCodeAt(r);if(i===27){if(t.charCodeAt(r+1)===127||t.charCodeAt(r+1)===8){n.push(`^W`),r+=2;continue}if(t[r+1]===`[`||t[r+1]===`O`){let e=r+2;for(;e<t.length&&t.charCodeAt(e)>=32&&t.charCodeAt(e)<=63;)e++;if(e<t.length){let i=t.slice(r+2,e+1),a={A:`ArrowUp`,B:`ArrowDown`,C:`ArrowRight`,D:`ArrowLeft`,H:`Home`,F:`End`,"1~":`Home`,"3~":`Delete`,"4~":`End`,"5~":`PageUp`,"6~":`PageDown`,"7~":`Home`,"8~":`End`};a[i]&&n.push(a[i]),r=e+1;continue}}n.push(`Escape`),r++;continue}if(i===13||i===10){n.push(`Enter`),i===13&&t[r+1]===`
2
+ `&&r++,r++;continue}if(i===127||i===8){n.push(`Backspace`),r++;continue}if(i===9){n.push(`Tab`),r++;continue}if(i>=1&&i<=26){n.push(`^`+String.fromCharCode(i+64)),r++;continue}n.push(e),r++}return n}t.exports={TtyStream:class extends r{constructor(e={}){super(),this.isTTY=e.isTTY!==!1,this.readable=!0,this.writable=!0,this.columns=e.columns||80,this.rows=e.rows||24,this.isRaw=!1,this._encoding=null,this._onWrite=e.onWrite||null}write(e,t,n){if(e==null)return!0;typeof this._onWrite==`function`&&this._onWrite(e),this._isPushing=!0;try{this.emit(`data`,this._formatChunk(e))}finally{this._isPushing=!1}return typeof t==`function`?t():typeof n==`function`&&n(),!0}pushData(e){if(e!=null){this._isPushing=!0;try{this.emit(`data`,this._formatChunk(e))}finally{this._isPushing=!1}}}_formatChunk(e){return this._encoding?typeof e==`string`?e:e instanceof Uint8Array||v!==void 0&&v.isBuffer(e)?new TextDecoder().decode(e):String(e):e}setRawMode(e){return this.isRaw=!!e,this}setEncoding(e){return this._encoding=e,this}getWindowSize(){return[this.columns,this.rows]}resize(e,t){this.columns=e,this.rows=t,this.emit(`resize`)}resume(){return this}pause(){return this}pipe(e){return this.on(`data`,t=>e.write(t)),e}unpipe(){return this}end(e,t,n){return e!=null&&this.write(e,typeof t==`string`?t:void 0),this.emit(`end`),typeof t==`function`?t():typeof n==`function`&&n(),this}destroy(){this.removeAllListeners()}toString(){return``}valueOf(){return``}},parseVtKeys:i}})),G=t(((e,t)=>{var n=V(),r=U(),{TtyStream:i,parseVtKeys:a}=W(),o=n.EventEmitter||n.default||n;t.exports=class extends o{constructor(e,t){super(),this.arguments=e,this.result=new r,this.context=t||null;let n=this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`COLUMNS`),10)||80,o=this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`LINES`),10)||24;this.stdinStream=new i({columns:n,rows:o}),this.stdin=this.stdinStream,this.stdout=new i({columns:n,rows:o,onWrite:e=>this.emit(`stdout`,e)}),this.stderr=new i({columns:n,rows:o,onWrite:e=>this.emit(`stderr`,e)}),this._onStdinStreamData=e=>{if(!this.captureInput)return;let t=a(e);for(let e of t){if(e===`^C`){this.kill(`SIGINT`);return}!this.interactive&&!this.stdinStream.isRaw&&(e===`Enter`?this.stdout.write(`\r
3
+ `):e===`Backspace`?this.stdout.write(`\b \b`):e.length===1&&this.stdout.write(e)),this.onInput(e)}},this.stdinStream.on(`data`,this._onStdinStreamData)}get name(){return`unnamed`}run(){return Promise.reject(`Command not implemented...`)}kill(e=`SIGINT`){let t=typeof e==`number`?e:{SIGHUP:129,SIGINT:130,SIGQUIT:131,SIGKILL:137,SIGTERM:143,SIGWINCH:156}[e]||130;this.exitCode=t,this.emit(`signal`,e),(e===`SIGINT`||e===`SIGTERM`||e===`SIGKILL`||e===`SIGQUIT`)&&(this.emit(`abort`),this._abortController&&this._abortController.abort())}runCommand(){return new Promise(e=>{let t=!1,n=()=>{t||(t=!0,e(this.result))};this.once(`abort`,n),Promise.resolve().then(()=>this.run()).then(r=>{t||(t=!0,this.removeListener(`abort`,n),r&&r.split(/\r?\n/).forEach(e=>this.stdOut=e),e(this.result))}).catch(r=>{if(!t){if(t=!0,this.removeListener(`abort`,n),r&&r.__type)throw r;r&&(this.stdErr=r.message||r),this.result.getExitCode()===0&&(this.exitCode=127),e(this.result)}})})}onInput(e){}set exitCode(e){this.result.exitCode=e}set stdOut(e){this.result.addStdOutLine(e)}set stdErr(e){this.result.addStdErrLine(e)}flush(){this.emit(`flush`,this.result.flush())}}})),ee=t(((e,t)=>{var n=G();t.exports=class extends n{get captureInput(){return!0}get interactive(){return!0}get terminalSize(){return this.stdout&&this.stdout.columns&&this.stdout.rows?{cols:parseInt(this.context&&this.context.getVar&&this.context.getVar(`COLUMNS`),10)||this.stdout.columns||80,rows:parseInt(this.context&&this.context.getVar&&this.context.getVar(`LINES`),10)||this.stdout.rows||24}:{cols:parseInt(this.context.getVar(`COLUMNS`),10)||80,rows:parseInt(this.context.getVar(`LINES`),10)||24}}_enterAltScreen(){this._inAltScreen||(this._inAltScreen=!0,this.stdinStream&&this.stdinStream.setRawMode(!0),this.stdout&&this.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`))}_exitAltScreen(){this._inAltScreen&&(this._inAltScreen=!1,this.stdinStream&&this.stdinStream.setRawMode(!1),this.stdout&&this.stdout.write(`\x1B[?1049l\x1B[?25h`))}kill(e=`SIGINT`){this._exitAltScreen(),super.kill(e)}runCommand(){return this.interactive&&this._enterAltScreen(),super.runCommand().finally(()=>{this._exitAltScreen()})}}})),K=t(((e,t)=>{y(),B();var{BinaryFile:n,SymlinkRef:r,DeviceFile:i}=b(),a=new Uint8Array([66,82,70,83]),o=2;function s(e){if(!e)return!1;let t=e instanceof Uint8Array?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new Uint8Array(e.buffer||e,e.byteOffset||0,e.byteLength):null;return!t||t.length<12?!1:t[0]===a[0]&&t[1]===a[1]&&t[2]===a[2]&&t[3]===a[3]}function c(e={},t={},n={}){let s=new TextEncoder,c=[],l=0,u=e=>{let t=e instanceof Uint8Array?e:new Uint8Array(e),n=l;return c.push(t),l+=t.byteLength,[n,t.byteLength]},d={},f=(e,t)=>{if(e==null)return null;if(e instanceof r)return{$l:e.target};if(e instanceof i)return null;if(e instanceof Uint8Array||v!==void 0&&v.isBuffer(e)){let n=e instanceof Uint8Array?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=e.mimeType||(t.endsWith(`.wasm`)?`application/wasm`:`application/octet-stream`),[i,a]=u(n);return{$b:[i,a,r]}}if(typeof e==`function`)return n.commandsBundle||(d[t]=e.toString()),{$c:t};if(typeof e==`string`){if(e.startsWith(`data:`)){let t=e.indexOf(`;`),n=e.indexOf(`,`,t);if(t!==-1&&n!==-1&&e.slice(t+1,n)===`base64`){let r=e.slice(5,t),i=e.slice(n+1),a;if(v!==void 0)a=new Uint8Array(v.from(i,`base64`));else{let e=atob(i);a=new Uint8Array(e.length);for(let t=0;t<e.length;t++)a[t]=e.charCodeAt(t)}let[o,s]=u(a);return{$b:[o,s,r]}}}let[t,n]=u(s.encode(e));return{$t:[t,n]}}if(typeof e==`object`){let n={};for(let r of Object.keys(e)){let i=`${t}/${r}`,a=f(e[r],i);a!==null&&(n[r]=a)}return{$d:n}}return null},p=f(e,``)||{$d:{}},m=null;n.commandsBundle&&typeof n.commandsBundle==`string`&&(m=u(s.encode(n.commandsBundle)));let h={v:o,tree:p,permissions:Object.assign({},t)};m&&(h.commandsSlice=m),Object.keys(d).length>0&&(h.inlineCommands=d);let g=s.encode(JSON.stringify(h)),_=12+g.byteLength+l,y=new Uint8Array(_);y.set(a,0);let b=new DataView(y.buffer,y.byteOffset,y.byteLength);b.setUint32(4,o,!0),b.setUint32(8,g.byteLength,!0),y.set(g,12);let x=12+g.byteLength;for(let e of c)y.set(e,x),x+=e.byteLength;return y}function l(e,t={}){let a=e instanceof Uint8Array?e:new Uint8Array(e.buffer||e,e.byteOffset||0,e.byteLength);if(!s(a))throw Error(`Invalid BRFS binary container (missing BRFS magic header)`);let c=new DataView(a.buffer,a.byteOffset,a.byteLength),l=c.getUint32(4,!0);if(l>o)throw Error(`Unsupported BRFS container version: ${l}`);let u=12+c.getUint32(8,!0);if(u>a.byteLength)throw Error(`Corrupt BRFS binary container (header length exceeds buffer)`);let d=new TextDecoder,f=d.decode(a.subarray(12,u)),p=JSON.parse(f),m=a.subarray(u),h=Object.assign({},t);if(Array.isArray(p.commandsSlice)){let[e,t]=p.commandsSlice,n=d.decode(m.subarray(e,e+t));try{let e=Function(n)();e&&typeof e==`object`&&Object.assign(h,e)}catch{}}let g=e=>{if(!e||typeof e!=`object`)return e;if(`$t`in e){let[t,n]=e.$t;return d.decode(m.subarray(t,t+n))}if(`$b`in e){let[t,r,i]=e.$b;return new n(m.slice(t,t+r).buffer,i||`application/octet-stream`)}if(`$l`in e)return new r(e.$l);if(`$dev`in e)return new i(e.$dev);if(`$c`in e){let t=e.$c;if(h[t])return h[t];if(p.inlineCommands&&p.inlineCommands[t])try{let e=G(),n=ee();return Function(`Command`,`InteractiveCommand`,`return (${p.inlineCommands[t]});`)(e,n)}catch{return null}return null}if(`$d`in e){let t={};for(let[n,r]of Object.entries(e.$d)){let e=g(r);e!==null&&(t[n]=e)}return t}return e};return{filesystem:g(p.tree)||{},permissions:Object.assign({},p.permissions||{})}}function u(e){if(!e)return!1;let t=e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):null;return!!(t&&t.byteLength>=2&&t[0]===31&&t[1]===139)}async function d(e){if(typeof DecompressionStream<`u`&&typeof Response<`u`){let t=new DecompressionStream(`gzip`),n=new Blob([e]).stream().pipeThrough(t),r=await new Response(n).arrayBuffer();return new Uint8Array(r)}if(z!==void 0&&typeof z.getBuiltinModule==`function`){let t=z.getBuiltinModule(`zlib`);if(t)return new Uint8Array(t.gunzipSync(v.from(e.buffer,e.byteOffset,e.byteLength)))}throw Error(`Gzip decompression is not supported in this environment`)}function f(e){return e?!!(typeof e==`string`||typeof e.then==`function`||typeof e.arrayBuffer==`function`||u(e)):!1}async function p(e,t={}){if(!e)return{filesystem:{},permissions:t};if(typeof e.then==`function`)return p(await e,t);if(typeof e.arrayBuffer==`function`){let n=await e.arrayBuffer();return p(new Uint8Array(n),t)}if(typeof e==`string`){if(!/^https?:\/\//i.test(e)&&z!==void 0&&typeof z.getBuiltinModule==`function`&&typeof window>`u`)try{let n=z.getBuiltinModule(`fs`);if(n&&n.existsSync(e)){let r=await n.promises.readFile(e);return p(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),t)}}catch{}let n=await fetch(e);if(!n.ok)throw Error(`Failed to load filesystem from ${e}: HTTP ${n.status}`);let r=await n.arrayBuffer();return p(new Uint8Array(r),t)}if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){let n=e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(u(n)&&(n=await d(n)),s(n)){let e=l(n);return{filesystem:e.filesystem,permissions:Object.assign({},e.permissions,t)}}let r=new TextDecoder(`utf-8`).decode(n);try{let e=JSON.parse(r);return e&&typeof e==`object`&&e.filesystem&&typeof e.permissions==`object`?{filesystem:e.filesystem,permissions:Object.assign({},e.permissions,t)}:{filesystem:e,permissions:t}}catch{let e=Function(`return `+r)();return e&&typeof e==`object`&&e.filesystem&&typeof e.permissions==`object`?{filesystem:e.filesystem,permissions:Object.assign({},e.permissions,t)}:{filesystem:e||{},permissions:t}}}return typeof e==`object`&&e.filesystem&&typeof e.permissions==`object`?f(e.filesystem)||s(e.filesystem)?p(e.filesystem,Object.assign({},e.permissions,t)):{filesystem:e.filesystem,permissions:Object.assign({},e.permissions,t)}:{filesystem:e,permissions:t}}t.exports={MAGIC:a,FORMAT_VERSION:o,isBinaryContainer:s,isGzipBytes:u,isAsyncFilesystemSource:f,resolveFilesystemSource:p,serializeBinaryFilesystem:c,deserializeBinaryFilesystem:l,FilesystemStorage:class{static async save(e,t=`brsh-rootfs`){let n=e.context?e.context.fs:e,r=c(n.getRaw(),n.getRawPermissions());return typeof indexedDB<`u`&&await this._idbPut(t,r),r}static async load(e=`brsh-rootfs`){if(e instanceof Uint8Array||e instanceof ArrayBuffer||typeof e==`string`&&(/^https?:\/\//i.test(e)||e.endsWith(`.brfs`)))return p(e);if(typeof indexedDB<`u`&&typeof e==`string`){let t=await this._idbGet(e);if(t&&s(t))return l(t)}return null}static async loadOrFetch(e=`brsh-rootfs`,t={}){return await this.load(e)||p(t)}static createAutoSave(e=`brsh-rootfs`,t=null){return(n,r)=>{let i=c(n,r);typeof indexedDB<`u`&&this._idbPut(e,i).catch(()=>{}),typeof t==`function`&&t(i,n,r)}}static _openIdb(){return new Promise((e,t)=>{let n=indexedDB.open(`brsh_fs_storage`,1);n.onupgradeneeded=()=>{n.result.createObjectStore(`snapshots`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}static async _idbPut(e,t){let n=await this._openIdb();return new Promise((r,i)=>{let a=n.transaction(`snapshots`,`readwrite`);a.objectStore(`snapshots`).put(t,e),a.oncomplete=()=>{n.close(),r()},a.onerror=()=>{n.close(),i(a.error)}})}static async _idbGet(e){let t=await this._openIdb();return new Promise((n,r)=>{let i=t.transaction(`snapshots`,`readonly`).objectStore(`snapshots`).get(e);i.onsuccess=()=>{t.close(),n(i.result||null)},i.onerror=()=>{t.close(),r(i.error)}})}}}})),q=t(((e,t)=>{y();var n=b(),{BinaryFile:r,SymlinkRef:i,DeviceFile:a}=n;function o(e){for(let t of Object.keys(e)){let n=e[t];if(typeof n==`object`&&n&&!(n instanceof Uint8Array)&&!(n instanceof i)&&!(n instanceof a))o(n);else if(typeof n==`string`&&n.startsWith(`data:`)){let i=n.indexOf(`;`),a=n.indexOf(`,`,i);if(i!==-1&&a!==-1&&n.slice(i+1,a)===`base64`){let o=n.slice(5,i),s=n.slice(a+1),c;if(v!==void 0)c=new Uint8Array(v.from(s,`base64`));else{let e=atob(s);c=new Uint8Array(e.length);for(let t=0;t<e.length;t++)c[t]=e.charCodeAt(t)}e[t]=new r(c.buffer,o)}}}}t.exports=class extends n{constructor(e=`/`,t={},n={},r=null){if(super(),t instanceof Uint8Array||t instanceof ArrayBuffer){let{deserializeBinaryFilesystem:e}=K(),r=e(t);t=r.filesystem,n=Object.assign({},r.permissions,n)}else if(t&&typeof t==`object`&&t.filesystem&&(t.filesystem instanceof Uint8Array||typeof t.filesystem==`object`)&&(n=Object.assign({},t.permissions||{},n),t=t.filesystem,t instanceof Uint8Array||t instanceof ArrayBuffer)){let{deserializeBinaryFilesystem:e}=K(),r=e(t);t=r.filesystem,n=Object.assign({},r.permissions,n)}o(t),this.fileSystem=t,this.permissions=Object.assign({},n),this.cwd=e.endsWith(`/`)?e:e+`/`,this._onChange=r,this._changeScheduled=!1,this._initDevices()}_initDevices(){this._devices={};let e=this._devices;e.null=new a(`null`,{read:()=>``,write:()=>{}}),e.zero=new a(`zero`,{read:()=>new Uint8Array(4096),write:()=>{}}),e.urandom=new a(`urandom`,{read:()=>{let e=new Uint8Array(256);if(typeof crypto<`u`&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);return e},write:()=>{}}),e.random=e.urandom,e.tty=new a(`tty`,{read:()=>``,write:()=>{}}),e.stdin=new i(`/dev/tty`),e.stdout=new i(`/dev/tty`),e.stderr=new i(`/dev/tty`)}_getDevDir(){return this._devices||this._initDevices(),this.fileSystem&&this.fileSystem.dev&&typeof this.fileSystem.dev==`object`&&!(this.fileSystem.dev instanceof i)&&!(this.fileSystem.dev instanceof Uint8Array)?Object.assign({},this.fileSystem.dev,this._devices):this._devices}_getRootOverlay(){let e=Object.assign({},this.fileSystem);return e.dev=this._getDevDir(),e}setTtyDevice(e={}){this._devices||this._initDevices(),this._devices.tty=new a(`tty`,{read:e.read||(()=>``),write:e.write||(()=>{}),mode:438}),this._devices.stdin=new i(`/dev/tty`),this._devices.stdout=new i(`/dev/tty`),this._devices.stderr=new i(`/dev/tty`)}toBinaryContainer(e={}){let{serializeBinaryFilesystem:t}=K();return t(this.fileSystem,this.permissions,e)}static fromBinaryContainer(e,t={}){let{deserializeBinaryFilesystem:n}=K();return n(e,t)}getFileByPath(e){let t=this._resolveByAbsolutePath(this._pathToAbsolute(e),!0);return t==null||!this.isReadable(e)?null:t instanceof a?t.read():t}_getFileRaw(e){let t=this._getFileByAbsolutePath(this._pathToAbsolute(e));return t instanceof a?t.read():t}exists(e){return this._resolveByAbsolutePath(this._pathToAbsolute(e),!0)!=null}isSymlink(e){return this._resolveByAbsolutePath(this._pathToAbsolute(e),!1)instanceof i}readSymlink(e){let t=this._resolveByAbsolutePath(this._pathToAbsolute(e),!1);return t instanceof i?t.target:null}createSymlink(e,t){this._setFileRaw(t,new i(e))}stat(e){let t=this._resolveByAbsolutePath(this._pathToAbsolute(e),!1);return t==null?null:t instanceof i?{isDirectory:!1,isFile:!1,isCommand:!1,isBinary:!1,isSymlink:!0,isDevice:!1,isCharacterDevice:!1}:t instanceof a?{isDirectory:!1,isFile:!0,isCommand:!1,isBinary:t.read()instanceof Uint8Array,isSymlink:!1,isDevice:!0,isCharacterDevice:!0}:{isDirectory:t.constructor===Object,isFile:typeof t==`string`||t instanceof Uint8Array,isCommand:typeof t==`function`,isBinary:t instanceof Uint8Array,isSymlink:!1,isDevice:!1,isCharacterDevice:!1}}_pathToAbsolute(e){return e.startsWith(`./`)&&(e=e.substring(2)),e.startsWith(`/`)||(e=(this.cwd&&this.cwd.endsWith(`/`)?this.cwd:this.cwd?this.cwd+`/`:`/`)+e),this._traverseComplexAbsolutePath(e)}_traverseComplexAbsolutePath(e){let t=e.split(`/`);for(;t.includes(`..`);){let e=t.indexOf(`..`)-1;t.splice(e,2)}return t.join(`/`)}absolutePath(e){return this._pathToAbsolute(e)}setFileByPath(e,t,n=!1){let r=this._pathToAbsolute(e),i=this._getFileByAbsolutePath(r);if(i!=null){if(!this.isWritable(e))throw Error(`Permission denied`);if(i instanceof a){i.write(t),this._triggerChange();return}}else{let e=r.split(`/`);e.pop();let t=e.join(`/`)||`/`,n=this.getMode(t);if(n!==null&&!(n&128))throw Error(`Permission denied`)}this._setFileByAbsolutePath(r,t,n),this._triggerChange()}_setFileRaw(e,t,n=!1){let r=this._pathToAbsolute(e);this._setFileByAbsolutePath(r,t,n),this._triggerChange()}_setFileByAbsolutePath(e,t,n=!0){let r=e.split(`/`);r.shift();let o=r.pop();if(r.length>0&&r[0]===`dev`){let e=this._getDevDir(),i=r.slice(1);for(let t of i){if(!Object.prototype.hasOwnProperty.call(e,t)){if(!n)throw Error(`${t}: No such file or directory`);e[t]={}}e=e[t]}if(e[o]instanceof a){e[o].write(t);return}e[o]=t;return}if(r.length===0&&o===`dev`)throw Error(`dev: File exists`);let s=this.fileSystem,c=[];for(let e of r){if(c.push(e),!Object.prototype.hasOwnProperty.call(s,e)){if(!n)throw Error(`${e}: No such file or directory`);s[e]={}}let t=s[e];if(t instanceof i){let n=`/`+c.slice(0,-1).join(`/`),r=t.target.startsWith(`/`)?this._traverseComplexAbsolutePath(t.target):this._traverseComplexAbsolutePath(n+`/`+t.target);if(t=this._resolveByAbsolutePath(r,!0),typeof t!=`object`||!t||t instanceof i)throw Error(`${e}: Not a directory`)}s=t}if(s[o]instanceof a){s[o].write(t);return}s[o]=t}_resolveByAbsolutePath(e,t=!0,n=0){if(n>10)return null;let r=e.split(`/`);if(r.shift(),r.length>0&&r[r.length-1].length<1&&r.pop(),r.length===0)return this._getRootOverlay();let a=this.fileSystem,o=[];for(let e=0;e<r.length;e++){let s=r[e],c=e===r.length-1;if(e===0&&s===`dev`){a=this._getDevDir(),o.push(s);continue}if(typeof a!=`object`||!a||a instanceof i||!Object.prototype.hasOwnProperty.call(a,s))return null;if(a=a[s],o.push(s),a instanceof i&&(!c||t)){let e=`/`+o.slice(0,-1).join(`/`),t=a.target.startsWith(`/`)?this._traverseComplexAbsolutePath(a.target):this._traverseComplexAbsolutePath(e+`/`+a.target);if(a=this._resolveByAbsolutePath(t,!0,n+1),a==null)return null}}return a}_getFileByAbsolutePath(e){let t=e.split(`/`);if(t.shift(),t.length>0&&t[t.length-1].length<1&&t.pop(),t.length===0)return this._getRootOverlay();if(t[0]===`dev`){let e=this._getDevDir();for(let n=1;n<t.length;n++){if(typeof e!=`object`||!e||!Object.prototype.hasOwnProperty.call(e,t[n]))return null;e=e[t[n]]}return e}return t.reduce((e,t)=>typeof e!=`object`||!e||!Object.prototype.hasOwnProperty.call(e,t)?null:e[t],this.fileSystem)}deleteFileByPath(e){let t=this._pathToAbsolute(e),n=t.split(`/`);n.pop();let r=n.join(`/`)||`/`,i=this.getMode(r);if(i!==null&&!(i&128))throw Error(`${e}: Permission denied`);this._deleteByAbsolutePath(t);let a=t+`/`;Object.keys(this.permissions).forEach(e=>{(e===t||e.startsWith(a))&&delete this.permissions[e]}),this._triggerChange()}_deleteByAbsolutePath(e){let t=e.split(`/`);t.shift(),t[t.length-1]===``&&t.pop();let n=t.pop();if(!n)return;if(t.length>0&&t[0]===`dev`){let e=this._getDevDir();for(let n=1;n<t.length;n++){if(!e||typeof e!=`object`)return;e=e[t[n]]}e&&n in e&&delete e[n];return}if(t.length===0&&n===`dev`)return;let r=this.fileSystem,a=[];for(let e of t){if(a.push(e),!Object.prototype.hasOwnProperty.call(r,e))return;let t=r[e];if(t instanceof i){let e=`/`+a.slice(0,-1).join(`/`),n=t.target.startsWith(`/`)?this._traverseComplexAbsolutePath(t.target):this._traverseComplexAbsolutePath(e+`/`+t.target);if(t=this._resolveByAbsolutePath(n,!0),typeof t!=`object`||!t||t instanceof i)return}r=t}r&&n in r&&delete r[n]}getMode(e){let t=this._pathToAbsolute(e);if(this.permissions[t]!==void 0)return this.permissions[t];let n=this._resolveByAbsolutePath(t,!0);return n==null?null:n instanceof a?n.mode||438:n.constructor===Object?493:typeof n==`function`?365:420}setMode(e,t){let n=this._pathToAbsolute(e);this.permissions[n]=t,this._triggerChange()}getSize(e){let t=this._pathToAbsolute(e),n=this._resolveByAbsolutePath(t,!0);if(n==null)return 0;if(n instanceof a){let e=n.read();return e instanceof Uint8Array||typeof e==`string`?e.length:0}return n.constructor===Object?JSON.stringify(n).length:n instanceof Uint8Array?n.length:n.toString().length}getRawPermissions(){return Object.assign({},this.permissions)}setCwd(e){this.cwd=this._pathToAbsolute(e.endsWith(`/`)?e:e+`/`)}getRaw(){return this.fileSystem}addFiles(e){Object.entries(e).forEach(([e,t])=>{this._setFileRaw(e,t,!0)})}autoComplete(e,t){let n=this._pathToAbsolute(e).split(`/`),r=n.pop(),i=this._getFileRaw(n.length>1?n.join(`/`):`/`),a=this._getFileRaw(t);if(i&&i.constructor===Object){let t=Object.keys(i).filter(e=>e.startsWith(r));r.length<1&&(t=t.filter(e=>!e.startsWith(`.`)));let n=e.split(`/`);n.pop();let o=i;if(t.length<1&&n.length<1&&a&&(t=Object.keys(a).filter(e=>e.startsWith(r)),o=a),t.length)return{path:n.length?n.join(`/`):null,options:t.map(e=>o[e]&&o[e].constructor===Object?e.concat(`/`):e)}}return null}},t.exports.BinaryFile=r,t.exports.SymlinkRef=i})),J=t(((e,t)=>{t.exports=null})),te=t(((e,t)=>{B();function n(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}function r(e,t){for(var n=``,r=0,i=-1,a=0,o,s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(!(i===s-1||a===1))if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var c=n.lastIndexOf(`/`);if(c!==n.length-1){c===-1?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function i(e,t){var n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}var a={resolve:function(){for(var e=``,t=!1,i,a=arguments.length-1;a>=-1&&!t;a--){var o;a>=0?o=arguments[a]:(i===void 0&&(i=z.cwd()),o=i),n(o),o.length!==0&&(e=o+`/`+e,t=o.charCodeAt(0)===47)}return e=r(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`},normalize:function(e){if(n(e),e.length===0)return`.`;var t=e.charCodeAt(0)===47,i=e.charCodeAt(e.length-1)===47;return e=r(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&i&&(e+=`/`),t?`/`+e:e},isAbsolute:function(e){return n(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return`.`;for(var e,t=0;t<arguments.length;++t){var r=arguments[t];n(r),r.length>0&&(e===void 0?e=r:e+=`/`+r)}return e===void 0?`.`:a.normalize(e)},relative:function(e,t){if(n(e),n(t),e===t||(e=a.resolve(e),t=a.resolve(t),e===t))return``;for(var r=1;r<e.length&&e.charCodeAt(r)===47;++r);for(var i=e.length,o=i-r,s=1;s<t.length&&t.charCodeAt(s)===47;++s);for(var c=t.length-s,l=o<c?o:c,u=-1,d=0;d<=l;++d){if(d===l){if(c>l){if(t.charCodeAt(s+d)===47)return t.slice(s+d+1);if(d===0)return t.slice(s+d)}else o>l&&(e.charCodeAt(r+d)===47?u=d:d===0&&(u=0));break}var f=e.charCodeAt(r+d);if(f!==t.charCodeAt(s+d))break;f===47&&(u=d)}var p=``;for(d=r+u+1;d<=i;++d)(d===i||e.charCodeAt(d)===47)&&(p.length===0?p+=`..`:p+=`/..`);return p.length>0?p+t.slice(s+u):(s+=u,t.charCodeAt(s)===47&&++s,t.slice(s))},_makeLong:function(e){return e},dirname:function(e){if(n(e),e.length===0)return`.`;for(var t=e.charCodeAt(0),r=t===47,i=-1,a=!0,o=e.length-1;o>=1;--o)if(t=e.charCodeAt(o),t===47){if(!a){i=o;break}}else a=!1;return i===-1?r?`/`:`.`:r&&i===1?`//`:e.slice(0,i)},basename:function(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);n(e);var r=0,i=-1,a=!0,o;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;var s=t.length-1,c=-1;for(o=e.length-1;o>=0;--o){var l=e.charCodeAt(o);if(l===47){if(!a){r=o+1;break}}else c===-1&&(a=!1,c=o+1),s>=0&&(l===t.charCodeAt(s)?--s===-1&&(i=o):(s=-1,i=c))}return r===i?i=c:i===-1&&(i=e.length),e.slice(r,i)}else{for(o=e.length-1;o>=0;--o)if(e.charCodeAt(o)===47){if(!a){r=o+1;break}}else i===-1&&(a=!1,i=o+1);return i===-1?``:e.slice(r,i)}},extname:function(e){n(e);for(var t=-1,r=0,i=-1,a=!0,o=0,s=e.length-1;s>=0;--s){var c=e.charCodeAt(s);if(c===47){if(!a){r=s+1;break}continue}i===-1&&(a=!1,i=s+1),c===46?t===-1?t=s:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||i===-1||o===0||o===1&&t===i-1&&t===r+1?``:e.slice(t,i)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return i(`/`,e)},parse:function(e){n(e);var t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;var r=e.charCodeAt(0),i=r===47,a;i?(t.root=`/`,a=1):a=0;for(var o=-1,s=0,c=-1,l=!0,u=e.length-1,d=0;u>=a;--u){if(r=e.charCodeAt(u),r===47){if(!l){s=u+1;break}continue}c===-1&&(l=!1,c=u+1),r===46?o===-1?o=u:d!==1&&(d=1):o!==-1&&(d=-1)}return o===-1||c===-1||d===0||d===1&&o===c-1&&o===s+1?c!==-1&&(s===0&&i?t.base=t.name=e.slice(1,c):t.base=t.name=e.slice(s,c)):(s===0&&i?(t.name=e.slice(1,o),t.base=e.slice(1,c)):(t.name=e.slice(s,o),t.base=e.slice(s,c)),t.ext=e.slice(o,c)),s>0?t.dir=e.slice(0,s-1):i&&(t.dir=`/`),t},sep:`/`,delimiter:`:`,win32:null,posix:null};a.posix=a,t.exports=a})),ne=t(((e,t)=>{B();var n=J(),r=te(),i=b();t.exports=class extends i{constructor(e,t=null){super(),this._onChange=t,this._changeScheduled=!1,this._virtualFiles={},this.cwd=this._normalizeCwd(e||z.cwd())}get isRealFilesystem(){return!0}_normalizeCwd(e){let t=r.resolve(e);return t===`/`?`/`:t+`/`}absolutePath(e){e.startsWith(`./`)&&(e=e.slice(2));let t=e.startsWith(`/`)?e:r.join(this.cwd,e);return r.normalize(t)}setCwd(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=this.absolutePath(t);this.cwd=n===`/`?`/`:n+`/`}getFileByPath(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0)return this._virtualFiles[t];let i;try{i=n.statSync(t)}catch{return null}if(i.isDirectory()){let e={};try{for(let i of n.readdirSync(t)){let a=r.join(t,i);if(this._virtualFiles[a]!==void 0)e[i]=this._virtualFiles[a];else try{e[i]=n.statSync(a).isDirectory()?{}:``}catch{}}}catch{}let i=t===`/`?`/`:t+`/`;for(let t of Object.keys(this._virtualFiles))if(t.startsWith(i)&&!t.slice(i.length).includes(`/`)){let n=t.slice(i.length);n in e||(e[n]=this._virtualFiles[t])}return e}try{return n.readFileSync(t,`utf8`)}catch{return null}}setFileByPath(e,t,i=!1){let a=this.absolutePath(e);if(typeof t==`function`||t instanceof Uint8Array){this._virtualFiles[a]=t;return}if(t!=null&&t.constructor===Object){try{n.mkdirSync(a,{recursive:i}),this._triggerChange()}catch{this._virtualFiles[a]=t}return}try{i&&n.mkdirSync(r.dirname(a),{recursive:!0}),n.writeFileSync(a,String(t)),this._triggerChange()}catch{this._virtualFiles[a]=String(t)}}deleteFileByPath(e){let t=this.absolutePath(e);delete this._virtualFiles[t];try{n.lstatSync(t).isDirectory()?n.rmdirSync(t):n.unlinkSync(t),this._triggerChange()}catch{}}getMode(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0)return typeof this._virtualFiles[t]==`function`?493:420;try{return n.statSync(t).mode&511}catch{return null}}setMode(e,t){let r=this.absolutePath(e);if(this._virtualFiles[r]===void 0)try{n.chmodSync(r,t),this._triggerChange()}catch{}}getSize(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0)return 0;try{return n.statSync(t).size}catch{return 0}}isSymlink(e){let t=this.absolutePath(e);try{return n.lstatSync(t).isSymbolicLink()}catch{return!1}}readSymlink(e){let t=this.absolutePath(e);try{return n.readlinkSync(t)}catch{return null}}createSymlink(e,t){let i=this.absolutePath(t);n.mkdirSync(r.dirname(i),{recursive:!0}),n.symlinkSync(e,i),this._triggerChange()}getRaw(){return null}getRawPermissions(){return{}}addFiles(e){Object.entries(e).forEach(([e,t])=>{this.setFileByPath(e,t,!0)})}autoComplete(e,t){let i=this.absolutePath(e).split(`/`),a=i.pop(),o=i.join(`/`)||`/`,s=[];try{s=n.readdirSync(o)}catch{}let c=o===`/`?`/`:o+`/`;for(let e of Object.keys(this._virtualFiles))if(e.startsWith(c)&&!e.slice(c.length).includes(`/`)){let t=e.slice(c.length);s.includes(t)||s.push(t)}let l=s.filter(e=>e.startsWith(a));if(l.length===0&&!e.includes(`/`)){let n=this.getFileByPath(t);if(n&&n.constructor===Object&&(l=Object.keys(n).filter(t=>t.startsWith(e)),l.length))return{path:null,options:l}}if(!l.length)return null;let u=e.split(`/`);return u.pop(),{path:u.length?u.join(`/`):null,options:l.map(e=>{let t=r.join(o,e);if(this._virtualFiles[t]!==void 0)return e;try{return n.statSync(t).isDirectory()?e+`/`:e}catch{return e}})}}_getFileRaw(e){return this.getFileByPath(e)}_setFileRaw(e,t,n=!1){return this.setFileByPath(e,t,n)}exists(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0)return!0;try{return n.statSync(t),!0}catch{return!1}}stat(e){let t=this.absolutePath(e);if(this._virtualFiles[t]!==void 0){let e=this._virtualFiles[t];return{isDirectory:e!=null&&e.constructor===Object,isFile:typeof e==`string`||e instanceof Uint8Array,isCommand:typeof e==`function`,isBinary:e instanceof Uint8Array}}try{let e=n.statSync(t);return{isDirectory:e.isDirectory(),isFile:e.isFile(),isCommand:!1}}catch{return null}}}})),Y=t(((e,t)=>{var n=q();t.exports=class{constructor(e){this.options=e;let{cwd:t=`/`,clearFn:r,destroyFn:i,onFsChange:a}=this.options;this.vars={},this.aliases={},this.fs=new n(t,{},{},a||null),this._clearFn=r,this._destroyFn=i}setVar(e,t){t?this.vars[e]=t:delete this.vars[e]}unsetVar(e){this.setVar(e)}getVar(e){return this.vars[e]||``}setAlias(e,t){t?this.aliases[e]=t:delete this.aliases[e]}unsetAlias(e){this.setAlias(e)}getAlias(e){return this.aliases[e]||null}setCommand(e){let t=`${this.getVar(`PATH`)}/${e.name.toLowerCase()}`;this.fs.addFiles({[t]:e}),this.fs.setMode(t,365)}getCommand(e){let t=`${this.getVar(`PATH`)}/${e}`;return this.fs._getFileRaw(t)||null}setNodeFilesystem(e){let t=ne(),n=this.fs._onChange;this.fs=new t(e,n)}setFilesystem(e,t={}){let r=this.fs._getFileRaw(this.getVar(`PATH`))||{},i=this.fs.getRawPermissions(),a=this.fs._onChange;this.fs=new n(this.fs.cwd,e,Object.assign({},i,t),a),this.fs.addFiles(r)}setCwd(e){this.fs.setCwd(e)}source(e){this.vars=Object.assign({},this.vars,e.vars),this.aliases=Object.assign({},this.aliases,e.aliases)}clear(){typeof this._clearFn==`function`&&this._clearFn()}destroy(e=0){typeof this._destroyFn==`function`&&this._destroyFn(e)}}})),X=t(((e,t)=>{var n=G();t.exports=class extends n{constructor(e,t){super(e,t)}}})),re=t(((e,t)=>{var n=X();function r(e){return/^#!\/(sh\.js|bin\/(sh|brsh))/.test(e)}t.exports=class extends n{constructor(e,t,n,r=!1){super(t,n),this.script=e,this.source=r}get captureInput(){return!!(this.sandbox&&this.sandbox.runningCommand&&this.sandbox.runningCommand.captureInput)}onInput(e){this.sandbox&&this.sandbox.onInput(e)}kill(e=`SIGINT`){this.sandbox&&this.sandbox.runningCommand&&typeof this.sandbox.runningCommand.kill==`function`&&this.sandbox.runningCommand.kill(e),this.sandbox&&typeof this.sandbox.destroy==`function`&&this.sandbox.destroy(130),super.kill(e)}run(){let e=this.context&&this.context.fs||this.fs,t=e&&e.isRealFilesystem?{useRealFilesystem:!0}:{filesystem:e&&e.getRaw()||{},permissions:e&&e.getRawPermissions()||{}};this.sandbox=new globalThis.shell({cwd:e&&e.cwd||`/`,...t,subshell:!0}),this.sandbox.context.source(this.context),Array.isArray(this.arguments)&&(this.arguments.forEach((e,t)=>this.sandbox.context.setVar(String(t+1),e)),this.sandbox.context.setVar(`#`,String(this.arguments.length)),this.sandbox.context.setVar(`@`,this.arguments.join(` `)),this.sandbox.context.setVar(`*`,this.arguments.join(` `))),this.sandbox.on(`stdOut`,e=>{this.stdOut=e,this.flush()}),this.sandbox.on(`stdErr`,e=>{this.stdErr=e,this.flush()}),this._scriptFunctions={};let n=this.script.split(/\r?\n/);if(!r(n[0])){let e=n[0].startsWith(`#!`)?n[0].slice(2).split(/\s/)[0]:n[0];return Promise.reject(`${e}: bad interpreter: No such file or directory`)}let i=this._parseLines(n.slice(1));return this._executeNodes(i).catch(e=>{if(e&&e.__type===`return`)this.sandbox.lastCode=e.code;else if(e&&e.__type===`errexit`)this.sandbox.lastCode=e.code;else if(e&&(e.__type===`break`||e.__type===`continue`))this.stdErr=`${e.__type}: only meaningful in a for or while loop`,this.sandbox.lastCode=1;else return Promise.reject(e)}).then(()=>{this.exitCode=this.sandbox.lastCode,this.source&&this.context.source(this.sandbox.context)})}_accumulateLines(e){let t=[],n=null,r=!1,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];n===null?n=s:a?n+=s:r||i?n+=`
4
+ `+s:n+=s;let c=0,l=!1,u=!1;for(;c<s.length;){let e=s[c];if(r)e===`'`&&(r=!1),c++;else if(i)e===`\\`&&c+1<s.length?c+=2:e===`\\`&&c+1===s.length?(l=!0,c++):(e===`"`&&(i=!1),c++);else{if(e===`#`&&(c===0||/\s/.test(s[c-1]))){u=!0;break}e===`\\`&&c+1<s.length?c+=2:e===`\\`&&c+1===s.length?(l=!0,c++):e===`'`?(r=!0,c++):(e===`"`&&(i=!0),c++)}}if(!r&&!l&&!u){let e=s.match(/(\\+)\s*$/);e&&e[1].length%2==1&&(l=!0)}a=l,l&&(n=n.replace(/\\\s*$/,``)),!r&&!i&&!l&&(t.push(n),n=null,a=!1)}return n!==null&&t.push(n),t}_parseLines(e){e=this._accumulateLines(e);let t=[],n=0;for(;n<e.length;){let r=e[n].trim();if(!r||r.startsWith(`#`)){n++;continue}if(r.startsWith(`if `)||r===`if`){let r=this._parseIf(e,n);t.push(r.node),n+=r.consumed;continue}if(r.startsWith(`while `)){let r=this._parseWhile(e,n);t.push(r.node),n+=r.consumed;continue}if(r.startsWith(`for `)){let r=this._parseFor(e,n);t.push(r.node),n+=r.consumed;continue}if(r.startsWith(`case `)||r===`case`){let r=this._parseCase(e,n);t.push(r.node),n+=r.consumed;continue}if(/^(?:function\s+[\w\d_]+|[\w\d_]+\s*\(\s*\))\s*(?:\{.*)?$/.test(r)){let r=this._parseFunction(e,n);t.push(r.node),n+=r.consumed;continue}t.push({type:`command`,line:r}),n++}return t}_parseIf(e,t){let n=e=>e.replace(/^(?:if|elif)\s+/,``).replace(/\s*;\s*then\s*$/,``).replace(/\s+then\s*$/,``).trim(),r=[{condition:n(e[t].trim()),bodyLines:[]}],i=[],a=r[0],o=!1,s=1,c=t+1;for(c<e.length&&e[c].trim()===`then`&&c++;c<e.length;){let t=e[c].trim();if((t.startsWith(`if `)||t===`if`)&&s++,t===`fi`&&(s--,s===0)){c++;break}if(s===1&&t.startsWith(`elif `)){let i={condition:n(t),bodyLines:[]};r.push(i),a=i,c++,c<e.length&&e[c].trim()===`then`&&c++;continue}if(s===1&&t===`else`){o=!0,c++;continue}o?i.push(e[c]):a.bodyLines.push(e[c]),c++}return{node:{type:`if`,clauses:r,elseLines:i},consumed:c-t}}_parseWhile(e,t){let n=e[t].trim().replace(/^while\s+/,``).replace(/\s*;\s*do\s*$/,``).replace(/\s+do\s*$/,``).trim(),r=t+1;r<e.length&&e[r].trim()===`do`&&r++;let i=[],a=1;for(;r<e.length;){let t=e[r].trim();if((t.startsWith(`while `)||t.startsWith(`for `))&&a++,t===`done`&&(a--,a===0)){r++;break}i.push(e[r]),r++}return{node:{type:`while`,condition:n,bodyLines:i},consumed:r-t}}_parseFor(e,t){let n=e[t].trim().replace(/\s*;\s*do\s*$/,``).replace(/\s+do\s*$/,``).match(/^for\s+(\w+)\s+in\s+(.+)$/),r=n?n[1]:``,i=n?n[2].trim():``,a=t+1;a<e.length&&e[a].trim()===`do`&&a++;let o=[],s=1;for(;a<e.length;){let t=e[a].trim();if((t.startsWith(`while `)||t.startsWith(`for `))&&s++,t===`done`&&(s--,s===0)){a++;break}o.push(e[a]),a++}return{node:{type:`for`,variable:r,list:i,bodyLines:o},consumed:a-t}}async _executeNodes(e){for(let t of e)await this._executeNode(t)}_executeNode(e){if(e.type===`function`){let t=e.name,n=e.bodyLines,r=this,i=X(),a=class extends i{static get name(){return t}run(){let e=this.arguments.map((e,t)=>({key:String(t+1),prev:r.sandbox.context.getVar(String(t+1))}));this.arguments.forEach((e,t)=>r.sandbox.context.setVar(String(t+1),e));let t=()=>e.forEach(({key:e,prev:t})=>t?r.sandbox.context.setVar(e,t):r.sandbox.context.unsetVar(e));return r._executeFunctionBody(n).then(()=>{t()}).catch(e=>{if(t(),e&&e.__type===`return`){this.exitCode=e.code;return}return Promise.reject(e)})}};return this.sandbox.context.setCommand(a),Promise.resolve()}if(e.type===`command`){if(/^return(\s+\d+)?\s*$/.test(e.line.trim())){let t=e.line.trim().match(/^return\s+(\d+)/),n=t?parseInt(t[1],10):0;return Promise.reject({__type:`return`,code:n})}if(/^break(\s+\d+)?\s*$/.test(e.line.trim())){let t=e.line.trim().match(/^break\s+(\d+)/),n=t?parseInt(t[1],10):1;return Promise.reject({__type:`break`,count:n})}if(/^continue(\s+\d+)?\s*$/.test(e.line.trim())){let t=e.line.trim().match(/^continue\s+(\d+)/),n=t?parseInt(t[1],10):1;return Promise.reject({__type:`continue`,count:n})}return(this.sandbox.context.getVar(`-`)||``).includes(`x`)&&(this.stdErr=`+ ${e.line.trim()}`,this.flush()),this.sandbox.onCommand(e.line,!1).then(()=>{if((this.sandbox.context.getVar(`-`)||``).includes(`e`)&&this.sandbox.lastCode!==0)return Promise.reject({__type:`errexit`,code:this.sandbox.lastCode})})}return e.type===`if`?this._executeIf(e):e.type===`while`?this._executeWhile(e):e.type===`for`?this._executeFor(e):e.type===`case`?this._executeCase(e):Promise.resolve()}async _executeIf(e){for(let t of e.clauses)if(await this.sandbox.onCommand(t.condition,!1),this.sandbox.lastCode===0)return this._executeNodes(this._parseLines(t.bodyLines));if(e.elseLines.length>0)return this._executeNodes(this._parseLines(e.elseLines))}async _executeWhile(e){for(;await this.sandbox.onCommand(e.condition,!1),this.sandbox.lastCode===0;)try{await this._executeNodes(this._parseLines(e.bodyLines))}catch(e){if(e&&e.__type===`break`){if(e.count<=1)break;throw{__type:`break`,count:e.count-1}}if(e&&e.__type===`continue`){if(e.count<=1)continue;throw{__type:`continue`,count:e.count-1}}throw e}}async _executeFor(e){let t=e.list.replace(/\${?([\w\d]+)}?/g,(e,t)=>this.sandbox.context.getVar(t)||``).split(/\s+/).filter(Boolean);for(let n of t){this.sandbox.context.setVar(e.variable,n);try{await this._executeNodes(this._parseLines(e.bodyLines))}catch(e){if(e&&e.__type===`break`){if(e.count<=1)break;throw{__type:`break`,count:e.count-1}}if(e&&e.__type===`continue`){if(e.count<=1)continue;throw{__type:`continue`,count:e.count-1}}throw e}}}_parseFunction(e,t){let n=e[t].trim(),r=n.match(/^function\s+([\w\d_]+)/)||n.match(/^([\w\d_]+)\s*\(/),i=r?r[1]:``,a=t+1;if(!n.includes(`{`)){for(;a<e.length&&!e[a].includes(`{`);)a++;a++}let o=[],s=1;for(;a<e.length;){if(e[a].trim()===`}`){a++;break}let t=(e[a].match(/\{/g)||[]).length,n=(e[a].match(/\}/g)||[]).length;if(s+=t-n,s<=0){a++;break}o.push(e[a]),a++}return{node:{type:`function`,name:i,bodyLines:o},consumed:a-t}}_parseCase(e,t){let n=e[t].trim().match(/^case\s+(.+?)\s+in\s*$/),r=n?n[1]:``,i=t+1,a=[],o=null,s=[];for(;i<e.length;){let t=e[i],n=t.trim();if(i++,!(!n||n.startsWith(`#`))){if(n===`esac`)break;if(o===null){let e=n.match(/^(.+?)\)\s*(.*)$/);if(e){o=e[1].trim();let t=e[2].trim();if(t===`;;`)a.push({pattern:o,bodyLines:[]}),o=null;else if(t.endsWith(`;;`)){let e=t.slice(0,-2).trim();a.push({pattern:o,bodyLines:e?[e]:[]}),o=null}else s=t?[t]:[]}}else n===`;;`?(a.push({pattern:o,bodyLines:s}),o=null,s=[]):n.endsWith(`;;`)?(s.push(n.slice(0,-2).trim()),a.push({pattern:o,bodyLines:s}),o=null,s=[]):s.push(t)}}return o!==null&&a.push({pattern:o,bodyLines:s}),{node:{type:`case`,word:r,clauses:a},consumed:i-t}}_executeFunctionBody(e){return this._executeNodes(this._parseLines(e))}async _executeCase(e){let t=await this.sandbox._replaceVariables(e.word),n=t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t;for(let t of e.clauses)if(this._matchPattern(t.pattern,n))return this._executeNodes(this._parseLines(t.bodyLines))}_matchPattern(e,t){let n=``,r=0;for(;r<e.length;){let t=e[r];if(t===`[`){let t=e.indexOf(`]`,r+1);t===-1?(n+=`\\[`,r++):(n+=e.slice(r,t+1),r=t+1)}else t===`*`?(n+=`.*`,r++):t===`?`?(n+=`.`,r++):/[.+^${}()|\\]/.test(t)?(n+=`\\`+t,r++):(n+=t,r++)}try{return RegExp(`^`+n+`$`).test(t)}catch{return!1}}},t.exports.isKnownInterpreter=r})),ie=t(((e,t)=>{y();var n=re(),{BinaryFile:r}=q(),i=0,a=6,o=8,s=20,c=28,l=31,u=44,d=54,f=70,p=0,m=2,h=3,g=4,_=1,b=2,x=4,S=8,C=1,w=4,T=class extends n{get name(){return`wasm`}get requiresFilesystem(){return!0}get interactive(){return(this.arguments||[]).some(e=>e===`--help`||e===`-h`||e===`--version`||e===`-V`||e===`-v`)?!1:this._isInteractive===void 0?!!(this._pkgMeta&&(this._pkgMeta.interactive||this._pkgMeta.wasm?.interactive)||this._inspectedWasm&&this._inspectedWasm.isInteractive):!!this._isInteractive}get captureInput(){return this.interactive}kill(e=`SIGINT`){if(this._killed=!0,this.exitCode=130,this._exitAltScreen(),this._asyncifyReject){try{this._asyncifyReject(Error(`Interrupted by SIGINT`))}catch{}this._asyncifyReject=null}if(this._pendingReadResolve){let e=this._pendingReadResolve;this._pendingReadResolve=null;try{e()}catch{}}super.kill(e)}_enterAltScreen(){this._inAltScreen||(this._inAltScreen=!0,this.stdinStream&&typeof this.stdinStream.setRawMode==`function`&&this.stdinStream.setRawMode(!0),this.stdout&&typeof this.stdout.write==`function`&&this.stdout.write(`\x1B[?1049h\x1B[2J\x1B[H`))}_exitAltScreen(){this._inAltScreen&&(this._inAltScreen=!1,this.stdinStream&&typeof this.stdinStream.setRawMode==`function`&&this.stdinStream.setRawMode(!1),this.stdout&&typeof this.stdout.write==`function`&&this.stdout.write(`\x1B[?1049l\x1B[?25h`))}_keyToBytes(e){if(!e)return null;if(typeof e!=`string`)return e instanceof Uint8Array?e:new Uint8Array([Number(e)&255]);let t=e.match(/^\^([A-Za-z@\[\\\]^_?])$/);if(t){let e=t[1].toUpperCase();return e===`?`?new Uint8Array([127]):new Uint8Array([e.charCodeAt(0)-64])}let n={Enter:`\r`,Return:`\r`,Backspace:``,Tab:` `,Escape:`\x1B`,ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Home:`\x1B[H`,End:`\x1B[F`,PageUp:`\x1B[5~`,PageDown:`\x1B[6~`,Delete:`\x1B[3~`,Insert:`\x1B[2~`};return n[e]?new TextEncoder().encode(n[e]):new TextEncoder().encode(e)}onInput(e){if(!this._handlingStreamData&&!(this.stdinStream&&this.stdinStream._isPushing)){if(typeof this._externalKeyHandler==`function`){this._externalKeyHandler(e);return}this.stdinStream&&this.stdinStream.isRaw}}runCommand(){return super.runCommand().finally(()=>{this._inAltScreen&&this._exitAltScreen()})}run(){let e=this.script,t=(()=>{try{return J()}catch{return null}})();return this._loadBytes(e,t).then(({bytes:e,isWat:t})=>t?this._runWat(e):this._runWasm(e)).catch(e=>{this.stdErr=e.message||String(e),this.exitCode=1})}_loadBytes(e,t){let n=this.context&&this.context.fs||this.fs;if(!n)return Promise.reject(Error(`${e}: Filesystem is not available`));let r;if(n.isRealFilesystem&&t)try{let i=t.readFileSync(n.absolutePath(e)),a=new Uint8Array(i);r=Promise.resolve({bytes:a,isWat:this._isWat(e,a)})}catch(t){return Promise.reject(Error(`${e}: ${t.message}`))}else{let t=n.getFileByPath(e);if(t==null)return Promise.reject(Error(`${e}: No such file or directory`));let i=this._contentToBytes(t);r=Promise.resolve({bytes:i,isWat:this._isWat(e,i)})}return r.then(e=>(!e.isWat&&e.bytes&&(this._inspectedWasm=j(e.bytes),this._inspectedWasm.isInteractive&&(this._isInteractive=!0)),e))}_isWat(e,t){return e.endsWith(`.wat`)?!0:t.length>0&&t[0]===40}_contentToBytes(e){if(e instanceof Uint8Array)return e;if(v!==void 0&&v.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}async _runWat(e){let t=new TextDecoder().decode(e),n,r;try{r=await import(`wabt`)}catch{this.stdErr=`${this.script}: WAT execution requires the 'wabt' package\nInstall it with: npm install wabt`,this.exitCode=1;return}try{let e=r.default??r,{buffer:i}=(typeof e==`function`?await e():e).parseWat(this.script,t,{mutable_globals:!0}).toBinary({});n=new Uint8Array(i)}catch(e){this.stdErr=`${this.script}: WAT compilation error: ${e.message}`,this.exitCode=1;return}return this._runWasm(n)}async _runWasm(e){if(typeof WebAssembly>`u`){this.stdErr=`${this.script}: WebAssembly is not available in this environment`,this.exitCode=1;return}let t={1:``,2:``},n=new TextDecoder,y=new TextEncoder,T=null,E=null,D=!1,O=0,k=null,A=null,N=null,P=null,F=this.stdin===void 0||this.stdin===null||this.stdin===this.stdinStream||this.stdin&&this.stdin.isTTY,I=!!(this.interactive&&F),L=()=>{I||!F||(I=!0,this._isInteractive=!0,this._enterAltScreen(),t[1]&&=(this.stdout&&typeof this.stdout.write==`function`&&this.stdout.write(t[1]),``),t[2]&&=(this.stderr&&typeof this.stderr.write==`function`&&this.stderr.write(t[2]),``),this.stdinStream&&typeof this.stdinStream.setRawMode==`function`&&this.stdinStream.setRawMode(!0))},R=(e,n)=>{if(I&&(e===1||e===2)){if(e===1&&this.stdout){this.stdout.write(n);return}if(e===2&&this.stderr){this.stderr.write(n);return}}t[e]=(t[e]||``)+n;let r=t[e].split(`
5
+ `);t[e]=r.pop();for(let t of r)e===1?this.stdOut=t:this.stdErr=t},z=()=>{t[1]&&=(I&&this.stdout?this.stdout.write(t[1]):this.stdOut=t[1],``),t[2]&&=(I&&this.stderr?this.stderr.write(t[2]):this.stdErr=t[2],``)},B=[],V=e=>{if(!(!e||e.length===0)){for(let t=0;t<e.length;t++)B.push(e[t]);if(A){let e=A;A=null,e()}}};P=e=>{this._handlingStreamData=!0;try{V(typeof e==`string`?y.encode(e):e instanceof Uint8Array?e:v!==void 0&&v.isBuffer(e)?new Uint8Array(e):y.encode(String(e??``)))}finally{this._handlingStreamData=!1}},this._externalKeyHandler=e=>{if(this._handlingStreamData)return;let t=this._keyToBytes(e);t&&V(t)},this._onStdinStreamData&&this.stdinStream&&typeof this.stdinStream.off==`function`&&this.stdinStream.off(`data`,this._onStdinStreamData),F&&this.stdinStream&&typeof this.stdinStream.on==`function`&&this.stdinStream.on(`data`,P),F&&this.stdin&&this.stdin!==this.stdinStream&&typeof this.stdin.on==`function`&&this.stdin.on(`data`,P);let H=!F&&typeof this.stdin==`string`?y.encode(this.stdin):!F&&this.stdin instanceof Uint8Array?this.stdin:!F&&v!==void 0&&v.isBuffer(this.stdin)?new Uint8Array(this.stdin):new Uint8Array,U=0,W=this.context&&this.context.fs?this.context.fs:this.fs,G=this.context&&this.context.fs&&this.context.fs.cwd||this.fs&&this.fs.cwd||this.context&&typeof this.context.getVar==`function`&&this.context.getVar(`PWD`)||W&&W.cwd||`/`,ee=G.length>1&&G.endsWith(`/`)?G.slice(0,-1):G,K=5,q=new Map([[3,{type:`preopen`,path:`/`,guestName:`/`}],[4,{type:`preopen`,path:ee,guestName:`.`}]]),J=new Map([[0,0],[1,0],[2,0]]),te=e=>{let t=e.split(`/`).filter(Boolean);return t.pop(),`/`+t.join(`/`)},ne=(e,t)=>{let n=q.get(e);if(!n||n.type!==`preopen`&&n.type!==`dir`)return null;if(t.startsWith(`/`))return W.absolutePath(t);if(!t||t===`.`)return W.absolutePath(n.path);let r=n.path.endsWith(`/`)?n.path:n.path+`/`,i=W.absolutePath(r+t),a=W.absolutePath(`/`+t);if(n.path!==`/`){if(W.exists(i))return i;if(W.exists(a))return a;let e=W.exists(te(i));return W.exists(te(a))&&!e?a:i}if(W.exists(i))return i;let o=W.absolutePath(t);return W.exists(o)?o:i},Y=e=>{if(!(!e||e.type!==`file`||!e.dirty||!W))try{let t=!0;for(let n=0;n<e.bytes.length;n++)if(e.bytes[n]===0){t=!1;break}if(t){let t=n.decode(e.bytes);W.setFileByPath(e.path,t,!0)}else{let t=new Uint8Array(e.bytes.length);t.set(e.bytes),W.setFileByPath(e.path,new r(t.buffer,`application/octet-stream`),!0)}e.dirty=!1}catch{}},X={TERM:`xterm-256color`,COLORTERM:`truecolor`,COLUMNS:String(this.stdout&&this.stdout.columns||this.context&&typeof this.context.getVar==`function`&&this.context.getVar(`COLUMNS`)||80),LINES:String(this.stdout&&this.stdout.rows||this.context&&typeof this.context.getVar==`function`&&this.context.getVar(`LINES`)||24),...this.context&&this.context.vars||{}},re=Object.entries(X).map(([e,t])=>`${e}=${t}`),ie=new Proxy({fd_write:(e,t,r,a)=>{if(!T)return o;let s=new DataView(T.buffer);if(e===1||e===2){let o=0;for(let i=0;i<r;i++){let r=s.getUint32(t+i*8,!0),a=s.getUint32(t+i*8+4,!0);a>0&&R(e,n.decode(new Uint8Array(T.buffer,r,a))),o+=a}return s.setUint32(a,o,!0),i}let c=q.get(e);if(!c)return o;if(c.type===`dev_null`||c.type===`dev_zero`){let e=0;for(let n=0;n<r;n++)e+=s.getUint32(t+n*8+4,!0);return s.setUint32(a,e,!0),i}if(c.type===`dev_tty`){let e=0;for(let i=0;i<r;i++){let r=s.getUint32(t+i*8,!0),a=s.getUint32(t+i*8+4,!0);a>0&&R(1,n.decode(new Uint8Array(T.buffer,r,a))),e+=a}return s.setUint32(a,e,!0),i}if(c.type!==`file`)return o;let l=0;for(let e=0;e<r;e++){let n=s.getUint32(t+e*8,!0),r=s.getUint32(t+e*8+4,!0);if(r>0){let e=new Uint8Array(T.buffer,n,r),t=c.append?c.bytes.length:c.pos,i=t+r;if(i>c.bytes.length){let e=new Uint8Array(i);e.set(c.bytes),c.bytes=e}c.bytes.set(e,t),c.pos=t+r,c.dirty=!0,l+=r}}return s.setUint32(a,l,!0),i},fd_read:(e,t,n,r)=>{if(!T)return o;let s=new DataView(T.buffer),c=q.get(e),l=!!(c&&c.type===`dev_tty`);if(e===0||I&&e===2||l){(l||e===2)&&L();let o=!!((J.get(e)||0)&w);if(D){if((typeof E?.exports?.asyncify_get_state==`function`?E.exports.asyncify_get_state():0)===2){E.exports.asyncify_stop_rewind();let e=0;for(let r=0;r<n&&B.length>0;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0),a=Math.min(i,B.length),o=B.splice(0,a);new Uint8Array(T.buffer).set(o,n),e+=a}return s.setUint32(r,e,!0),i}if(B.length>0){let e=0;for(let r=0;r<n&&B.length>0;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0),a=Math.min(i,B.length),o=B.splice(0,a);new Uint8Array(T.buffer).set(o,n),e+=a}return s.setUint32(r,e,!0),i}return o?(s.setUint32(r,0,!0),a):(E.exports.asyncify_start_unwind(O),k=new Promise((e,t)=>{A=e,this._pendingReadResolve=e,this._asyncifyReject=t}),s.setUint32(r,0,!0),i)}if(B.length>0){let e=0;for(let r=0;r<n&&B.length>0;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0),a=Math.min(i,B.length),o=B.splice(0,a);new Uint8Array(T.buffer).set(o,n),e+=a}return s.setUint32(r,e,!0),i}let c=0;for(let e=0;e<n&&U<H.length;e++){let n=s.getUint32(t+e*8,!0),r=s.getUint32(t+e*8+4,!0),i=Math.min(r,H.length-U);new Uint8Array(T.buffer).set(H.slice(U,U+i),n),U+=i,c+=i}return c===0&&o&&U>=H.length?(s.setUint32(r,0,!0),a):(s.setUint32(r,c,!0),i)}if(!c)return o;if(c.type===`dev_null`)return s.setUint32(r,0,!0),i;if(c.type===`dev_zero`){let e=0;for(let r=0;r<n;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0);new Uint8Array(T.buffer,n,i).fill(0),e+=i}return s.setUint32(r,e,!0),i}if(c.type===`dev_urandom`){let e=0;for(let r=0;r<n;r++){let n=s.getUint32(t+r*8,!0),i=s.getUint32(t+r*8+4,!0),a=new Uint8Array(T.buffer,n,i);if(typeof crypto<`u`&&crypto.getRandomValues)crypto.getRandomValues(a);else for(let e=0;e<i;e++)a[e]=Math.floor(Math.random()*256);e+=i}return s.setUint32(r,e,!0),i}if(c.type!==`file`)return o;let u=0;for(let e=0;e<n&&c.pos<c.bytes.length;e++){let n=s.getUint32(t+e*8,!0),r=s.getUint32(t+e*8+4,!0),i=Math.min(r,c.bytes.length-c.pos);new Uint8Array(T.buffer).set(c.bytes.subarray(c.pos,c.pos+i),n),c.pos+=i,u+=i}return s.setUint32(r,u,!0),i},fd_seek:(e,t,n,r,a)=>{if(!T)return o;if(e<=2)return f;let s=q.get(e);if(!s)return o;if(s.type===`dev_tty`||s.type===`dev_null`||s.type===`dev_zero`||s.type===`dev_urandom`)return f;if(s.type!==`file`)return o;let l,u,d;typeof t==`bigint`?(l=Number(t),u=n,d=r):(l=t,u=r,d=a);let p=s.pos;if(u===0)p=l;else if(u===1)p=s.pos+l;else if(u===2)p=s.bytes.length+l;else return c;return p<0?c:(s.pos=p,d&&new DataView(T.buffer).setBigUint64(d,BigInt(s.pos),!0),i)},fd_tell:(e,t)=>{if(!T)return o;let n=q.get(e);return!n||n.type!==`file`?o:(new DataView(T.buffer).setBigUint64(t,BigInt(n.pos),!0),i)},fd_close:e=>{if(e<=2)return i;let t=q.get(e);return t?(t.type===`file`&&Y(t),q.delete(e),J.delete(e),i):o},fd_sync:e=>{let t=q.get(e);return t&&Y(t),i},fd_datasync:e=>{let t=q.get(e);return t&&Y(t),i},fd_prestat_get:(e,t)=>{if(!T)return o;let n=q.get(e);if(!n||n.type!==`preopen`)return o;let r=new DataView(T.buffer),a=y.encode(n.guestName);return r.setUint8(t,0),r.setUint32(t+4,a.length,!0),i},fd_prestat_dir_name:(e,t,n)=>{if(!T)return o;let r=q.get(e);if(!r||r.type!==`preopen`)return o;let a=y.encode(r.guestName);return new Uint8Array(T.buffer,t,Math.min(n,a.length)).set(a.subarray(0,n)),i},fd_fdstat_get:(e,t)=>{if(!T)return o;let n=new DataView(T.buffer),r=p;if(e<=2)r=m;else{let t=q.get(e);if(!t)return o;r=t.type===`dev_null`||t.type===`dev_zero`||t.type===`dev_urandom`||t.type===`dev_tty`?m:t.type===`preopen`||t.type===`dir`?h:g}for(let e=0;e<24;e++)n.setUint8(t+e,0);n.setUint8(t,r);let a=J.get(e)||(q.get(e)?.append?C:0);return n.setUint16(t+2,a,!0),n.setBigUint64(t+8,18446744073709551615n,!0),n.setBigUint64(t+16,18446744073709551615n,!0),i},fd_fdstat_set_flags:(e,t)=>{if(!T||e>2&&!q.has(e))return o;J.set(e,t);let n=q.get(e);return n&&(n.append=!!(t&C)),(e===0||e===2||n&&n.type===`dev_tty`)&&t&w&&L(),i},fd_filestat_get:(e,t)=>{if(!T)return o;let n=new DataView(T.buffer);for(let e=0;e<64;e++)n.setUint8(t+e,0);if(e<=2)return n.setUint8(t+16,m),i;let r=q.get(e);if(!r)return o;if(r.type===`dev_null`||r.type===`dev_zero`||r.type===`dev_urandom`||r.type===`dev_tty`)return n.setUint8(t+16,m),n.setBigUint64(t+24,1n,!0),i;let a=r.type===`preopen`||r.type===`dir`;return n.setUint8(t+16,a?h:g),n.setBigUint64(t+24,1n,!0),n.setBigUint64(t+32,BigInt(r.bytes?r.bytes.length:0),!0),i},path_open:(e,t,r,a,c,f,p,m,h)=>{if(!T||!W)return o;let g=ne(e,n.decode(new Uint8Array(T.buffer,r,a)));if(!g)return o;let v=g.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`;if(v===`/dev/null`){let e=K++;return q.set(e,{type:`dev_null`,path:`/dev/null`}),new DataView(T.buffer).setUint32(h,e,!0),i}if(v===`/dev/zero`){let e=K++;return q.set(e,{type:`dev_zero`,path:`/dev/zero`}),new DataView(T.buffer).setUint32(h,e,!0),i}if(v===`/dev/urandom`||v===`/dev/random`){let e=K++;return q.set(e,{type:`dev_urandom`,path:v}),new DataView(T.buffer).setUint32(h,e,!0),i}if(v===`/dev/tty`||v===`/dev/stdin`){L();let e=K++;return q.set(e,{type:`dev_tty`,path:v}),new DataView(T.buffer).setUint32(h,e,!0),i}if(v===`/dev/stdout`)return new DataView(T.buffer).setUint32(h,1,!0),i;if(v===`/dev/stderr`)return new DataView(T.buffer).setUint32(h,2,!0),i;let w=W.stat(g),E=w!==null;if(c&x&&c&_&&E)return s;if(c&b){if(!E)return u;if(!w.isDirectory)return d;let e=K++;return q.set(e,{type:`dir`,path:g}),new DataView(T.buffer).setUint32(h,e,!0),i}if(E&&w.isDirectory)return l;if(!E&&!(c&_))return u;let D=new Uint8Array,O=!1;if(E&&!(c&S)){let e=W.getFileByPath(g);e!=null&&(D=typeof e==`string`?y.encode(e):new Uint8Array(this._contentToBytes(e)))}else O=!0;let k=K++;return q.set(k,{type:`file`,path:g,bytes:D,pos:m&C?D.length:0,append:!!(m&C),dirty:O}),new DataView(T.buffer).setUint32(h,k,!0),i},path_filestat_get:(e,t,r,a,s)=>{if(!T||!W)return o;let c=ne(e,n.decode(new Uint8Array(T.buffer,r,a)));if(!c)return o;let l=c.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`,d=W.stat(c);if(l===`/dev/null`||l===`/dev/zero`||l===`/dev/urandom`||l===`/dev/random`||l===`/dev/tty`||l===`/dev/stdin`||l===`/dev/stdout`||l===`/dev/stderr`||d&&(d.isDevice||d.isCharacterDevice)){let e=new DataView(T.buffer);for(let t=0;t<64;t++)e.setUint8(s+t,0);return e.setUint8(s+16,m),e.setBigUint64(s+24,1n,!0),i}if(!d)return u;let f=new DataView(T.buffer);for(let e=0;e<64;e++)f.setUint8(s+e,0);return f.setUint8(s+16,d.isDirectory?h:g),f.setBigUint64(s+24,1n,!0),f.setBigUint64(s+32,BigInt(W.getSize(c)||0),!0),i},path_create_directory:(e,t,r)=>{if(!T||!W)return o;let a=ne(e,n.decode(new Uint8Array(T.buffer,t,r)));if(!a)return o;if(W.exists(a))return s;try{return W.setFileByPath(a,{},!0),i}catch{return c}},path_unlink_file:(e,t,r)=>{if(!T||!W)return o;let a=ne(e,n.decode(new Uint8Array(T.buffer,t,r)));if(!a||!W.exists(a))return u;try{return W.deleteFileByPath(a),i}catch{return c}},path_remove_directory:(e,t,r)=>{if(!T||!W)return o;let a=ne(e,n.decode(new Uint8Array(T.buffer,t,r)));if(!a||!W.exists(a))return u;try{return W.deleteFileByPath(a),i}catch{return c}},path_rename:(e,t,r,a,s,l)=>{if(!T||!W)return o;let d=n.decode(new Uint8Array(T.buffer,t,r)),f=n.decode(new Uint8Array(T.buffer,s,l)),p=ne(e,d),m=ne(a,f);if(!p||!m)return o;if(!W.exists(p))return u;for(let e of q.values())e.path===p&&(Y(e),e.path=m);try{let e=W.getFileByPath(p);return W.setFileByPath(m,e,!0),W.deleteFileByPath(p),i}catch{return c}},proc_exit:e=>{throw e!==0&&(this.exitCode=e),{_wasmExit:!0,code:e}},args_sizes_get:(e,t)=>{if(!T)return c;let n=[this.script,...this.arguments||[]],r=new DataView(T.buffer);return r.setUint32(e,n.length,!0),r.setUint32(t,n.reduce((e,t)=>e+y.encode(t).length+1,0),!0),i},args_get:(e,t)=>{if(!T)return c;let n=[this.script,...this.arguments||[]],r=new DataView(T.buffer),a=t;for(let t=0;t<n.length;t++){r.setUint32(e+t*4,a,!0);let i=y.encode(n[t]+`\0`);new Uint8Array(T.buffer).set(i,a),a+=i.length}return i},environ_sizes_get:(e,t)=>{if(!T)return c;let n=new DataView(T.buffer);n.setUint32(e,re.length,!0);let r=re.reduce((e,t)=>e+y.encode(t).length+1,0);return n.setUint32(t,r,!0),i},environ_get:(e,t)=>{if(!T)return c;let n=new DataView(T.buffer),r=t;for(let t=0;t<re.length;t++){n.setUint32(e+t*4,r,!0);let i=y.encode(re[t]+`\0`);new Uint8Array(T.buffer).set(i,r),r+=i.length}return i},clock_time_get:(e,t,n)=>{if(T){let e=BigInt(Date.now())*1000000n;new DataView(T.buffer).setBigUint64(n,e,!0)}return i},random_get:(e,t)=>{if(T){let n=new Uint8Array(T.buffer,e,t);for(let e=0;e<t;e++)n[e]=Math.random()*256|0}return i},clock_nanosleep:(e,t,n,r,a)=>{if(!T)return o;let s=new DataView(T.buffer).getBigUint64(n,!0),c=0;if(t&1){let e=BigInt(Date.now())*1000000n;c=s>e?Number((s-e)/1000000n):0}else c=Number(s/1000000n);return D&&c>0?(typeof E?.exports?.asyncify_get_state==`function`?E.exports.asyncify_get_state():0)===2?(E.exports.asyncify_stop_rewind(),i):(E.exports.asyncify_start_unwind(O),k=new Promise(e=>setTimeout(e,Math.max(1,c))),i):i},poll_oneoff:(e,t,n,r)=>{if(!T)return o;let a=new DataView(T.buffer);if(D){if((typeof E?.exports?.asyncify_get_state==`function`?E.exports.asyncify_get_state():0)===2){E.exports.asyncify_stop_rewind();let o=0;for(let r=0;r<n;r++){let n=e+r*48,s=a.getBigUint64(n,!0),c=a.getUint8(n+8),l=t+o*32;a.setBigUint64(l,s,!0),a.setUint16(l+8,i,!0),a.setUint8(l+10,c);for(let e=11;e<32;e++)a.setUint8(l+e,0);c===1&&a.setBigUint64(l+16,BigInt(B.length),!0),o++}return a.setUint32(r,o,!0),i}let o=0,s=1/0;for(let t=0;t<n;t++){let n=e+t*48,r=a.getUint8(n+8);if(r===0){let e=a.getBigUint64(n+24,!0),t=a.getUint16(n+40,!0),r=0;if(t&1){let t=BigInt(Date.now())*1000000n;r=e>t?Number((e-t)/1000000n):0}else r=Number(e/1000000n);r<s&&(s=r)}else if(r===1){let e=a.getUint32(n+16,!0),t=q.get(e),r=!!(t&&t.type===`dev_tty`);(e===0||e===2||r)&&L(),(e===0||I&&e===2||r)&&B.length>0&&o++}else r===2&&o++}if(o>0||s===0){let o=0;for(let r=0;r<n;r++){let n=e+r*48,c=a.getBigUint64(n,!0),l=a.getUint8(n+8),u=!1;if(l===0&&s===0)u=!0;else if(l===1){let e=a.getUint32(n+16,!0),t=q.get(e),r=!!(t&&t.type===`dev_tty`);(e===0||I&&e===2||r)&&B.length>0&&(u=!0)}else l===2&&(u=!0);if(u){let e=t+o*32;a.setBigUint64(e,c,!0),a.setUint16(e+8,i,!0),a.setUint8(e+10,l);for(let t=11;t<32;t++)a.setUint8(e+t,0);l===1&&a.setBigUint64(e+16,BigInt(B.length),!0),o++}}return a.setUint32(r,o,!0),i}return E.exports.asyncify_start_unwind(O),k=new Promise((e,t)=>{let n=null;this._asyncifyReject=t;let r=()=>{n&&clearTimeout(n),A=null,this._pendingReadResolve=null,this._asyncifyReject=null,e()};A=r,this._pendingReadResolve=r,s!==1/0&&(n=setTimeout(()=>{A=null,this._pendingReadResolve=null,this._asyncifyReject=null,e()},Math.max(1,s)))}),a.setUint32(r,0,!0),i}return a.setUint32(r,0,!0),i}},{get(e,t){return t in e?e[t]:()=>0}}),ae=e=>{if(!T||!e)return``;try{let t=new DataView(T.buffer).getUint32(e-4,!0),n=new Uint16Array(T.buffer,e,t>>>1);return String.fromCharCode(...n)}catch{return``}},oe={wasi_snapshot_preview1:ie,wasi_unstable:ie,env:new Proxy({print:(e,t)=>{T&&R(1,n.decode(new Uint8Array(T.buffer,e,t)))},eprint:(e,t)=>{T&&R(2,n.decode(new Uint8Array(T.buffer,e,t)))},log:e=>{R(1,ae(e)+`
6
6
  `)},logi:e=>{R(1,String(e)+`
7
7
  `)},logf:e=>{R(1,String(e)+`
8
- `)},trace:(e,t,...n)=>{let r=t>0?` `+n.slice(0,t).join(`, `):``;R(1,`trace: ${ae(e)}${r}\n`)},seed:()=>Date.now()*Math.random(),abort:(e,t,n,r)=>{let i=ae(e),a=ae(t);throw(i||a)&&R(2,`abort: ${i||`aborted`} at ${a||this.script}:${n||0}:${r||0}\n`),this.exitCode=134,{_wasmExit:!0,code:134}}},{get(e,t){return t in e?e[t]:()=>0}})};try{let t=await WebAssembly.compile(e);for(let e of WebAssembly.Module.imports(t))if(e.kind===`memory`){let t=new WebAssembly.Memory({initial:1,maximum:256});T=t,oe[e.module]||(oe[e.module]={}),oe[e.module][e.name]=t}if(E=await WebAssembly.instantiate(t,oe),E.exports.memory&&(T=E.exports.memory),D=!!(E.exports.asyncify_start_unwind&&E.exports.asyncify_stop_unwind),D&&T){try{O=T.grow(1)*65536}catch{O=16}let e=O+8,t=O+65536-8;new Int32Array(T.buffer,O,2).set([e,t])}typeof E.exports.set_terminal_size==`function`&&L(),I&&this._enterAltScreen();let n=this.stdout&&this.stdout.columns||this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`COLUMNS`),10)||80,r=this.stdout&&this.stdout.rows||this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`LINES`),10)||24;if(typeof E.exports.set_terminal_size==`function`)try{E.exports.set_terminal_size(n,r)}catch{}N=()=>{let e=this.stdout&&this.stdout.columns||this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`COLUMNS`),10)||80,t=this.stdout&&this.stdout.rows||this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`LINES`),10)||24;if(typeof E?.exports?.set_terminal_size==`function`)try{E.exports.set_terminal_size(e,t)}catch{}},this.stdout&&typeof this.stdout.on==`function`&&this.stdout.on(`resize`,N),this.stdinStream&&typeof this.stdinStream.on==`function`&&this.stdinStream.on(`resize`,N);let i=E.exports._start||E.exports.__wasi_command||E.exports.main||E.exports.run;if(i)try{let e=i();for(e&&typeof e.then==`function`&&(e=await e);D&&typeof E.exports.asyncify_get_state==`function`&&E.exports.asyncify_get_state()===1;)E.exports.asyncify_stop_unwind(),k&&=(await k,null),E.exports.asyncify_start_rewind(O),e=i(),e&&typeof e.then==`function`&&(e=await e)}catch(e){(!e||!e._wasmExit)&&(this.stdErr=`${this.script}: runtime error: ${e?.message||String(e)}`,this.exitCode=1)}else{let e=Object.entries(E.exports).filter(([,e])=>typeof e==`function`).map(([e])=>e),t=e.length>0?` (module is a library exporting: ${e.join(`, `)})`:``;this.stdErr=`${this.script}: no CLI entry point found (expected _start, main, or run)${t}`,this.exitCode=1}}catch(e){(!e||!e._wasmExit)&&(this.stdErr=`${this.script}: ${e?.message||String(e)}`,this.exitCode=1)}finally{I&&this._exitAltScreen(),P&&(this.stdinStream&&typeof this.stdinStream.off==`function`&&this.stdinStream.off(`data`,P),this.stdin&&typeof this.stdin.off==`function`&&this.stdin.off(`data`,P)),this._onStdinStreamData&&this.stdinStream&&typeof this.stdinStream.on==`function`&&this.stdinStream.on(`data`,this._onStdinStreamData),N&&(this.stdout&&typeof this.stdout.off==`function`&&this.stdout.off(`resize`,N),this.stdinStream&&typeof this.stdinStream.off==`function`&&this.stdinStream.off(`resize`,N)),this._externalKeyHandler=null;for(let e of q.values())Y(e)}z();let se=this.arguments||[];if(!(this.result&&this.result.getStdOutput&&this.result.getStdOutput().length>0)&&(this.exitCode===0||this.exitCode===void 0)){let t=(this.script||`wasm`).split(`/`).pop(),n=Object.assign({name:t,version:`wasi`,description:`WebAssembly WASI binary (${this.script})`},this._pkgMeta||{});if(se.includes(`--help`)||se.includes(`-h`)){let r=j(e);for(let e of M(t,n,r))this.stdOut=e}else (se.includes(`--version`)||se.includes(`-V`)||se.includes(`-v`))&&(this.stdOut=`${t} (${n.name} ${n.version} wasm)`)}}},E=new Map;function D(e,t){if(!e||!e.exists(t))return null;if(e.isRealFilesystem)try{let n=J();return new Uint8Array(n.readFileSync(e.absolutePath(t)))}catch{}let n=e.getFileByPath(t);if(n==null)return null;if(n instanceof Uint8Array||v!==void 0&&v.isBuffer(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(n instanceof ArrayBuffer)return new Uint8Array(n);if(typeof n==`string`){if(n.startsWith(`data:`)){let e=n.indexOf(`,`);if(e!==-1){let t=n.slice(e+1);if(v!==void 0)return new Uint8Array(v.from(t,`base64`));let r=atob(t),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}}let e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t)&255;return e}return null}function O(e,t,n,i=`application/octet-stream`){let a=n instanceof Uint8Array?n:new Uint8Array(n),o=new Uint8Array(a.byteLength);o.set(a);let s=new r(o.buffer,i);if(e.isRealFilesystem)try{let n=J(),r=te(),i=e.absolutePath(t);n.mkdirSync(r.dirname(i),{recursive:!0}),n.writeFileSync(i,v.from(a.buffer,a.byteOffset,a.byteLength));return}catch{if(typeof e._setFileRaw==`function`){e._setFileRaw(t,s,!0);return}}if(typeof e._setFileRaw==`function`&&t.startsWith(`/var/lib/wbt/`)){e._setFileRaw(t,s,!0);return}e.setFileByPath(t,s,!0)}async function k(e,t,n=null){if(typeof n==`function`){let r=await n(e,t);if(r)return r}try{let t=await import(e);if(t)return t}catch{}if(t)try{return await import(t)}catch(n){if(!/^https?:\/\/esm\.sh\//i.test(t))try{return await import(`https://esm.sh/${e}`)}catch{}throw Error(`Failed to load WASM package '${e}' from ${t}: ${n.message||n}`)}throw Error(`Package '${e}' could not be loaded`)}function A(e,t=!1){let n={usage:null,options:[]};if(!e||typeof e!=`string`)return n;let r=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),i=new Set,a=t?r.findIndex(e=>/^usage:\s*(.+)/i.test(e)):-1,o=a>=0?a:0;for(let e=o;e<r.length;e++){let a=r[e];!n.usage&&/^usage:\s*(.+)/i.test(a)?n.usage=a.replace(/^usage:\s*/i,``).trim():/^(?:-[a-zA-Z0-9?]|--[a-zA-Z0-9][-a-zA-Z0-9]*)(?:\s|,|=|<|\[|$)/.test(a)&&a.length<=120&&!/^(?:-[hHvV],\s*)?--(?:help|version)\b/i.test(a)&&(!t||/^(?:-[a-zA-Z?]|--[a-zA-Z][a-zA-Z0-9-]*)(?:,\s*--?[a-zA-Z0-9-]+)?(?:\s+[<\[a-zA-Z0-9_.->\]]+)*(?:\s+[A-Za-z`'"(][A-Za-z0-9 ,.;:()'"`/<>\[\]=+$\t_-]*|)$/.test(a))&&(i.has(a)||(i.add(a),n.options.push(a)))}if(t&&n.options.length===0){let t=e.match(/--[a-z][a-z0-9-]{1,24}/g)||[];for(let e of Array.from(new Set(t)).slice(0,12))e!==`--help`&&e!==`--version`&&n.options.push(e)}return n}function j(e){let t={usage:null,options:[],exports:[],wasiImports:[]};if(!(e instanceof Uint8Array)||e.length<8)return t;try{if(typeof WebAssembly<`u`&&WebAssembly.Module){let n=new WebAssembly.Module(e);t.exports=WebAssembly.Module.exports(n).filter(e=>e.kind===`function`).map(e=>e.name),t.wasiImports=WebAssembly.Module.imports(n).filter(e=>e.module.startsWith(`wasi_`)).map(e=>e.name)}}catch{}try{let n=[],r=``;for(let t=0;t<e.length;t++){let i=e[t];i>=32&&i<=126||i===9||i===10?r+=String.fromCharCode(i):(r.length>=4&&n.push(r),r=``)}r.length>=4&&n.push(r);let i=A(n.join(`
9
- `),!0);t.usage=i.usage,t.options=i.options}catch{}return t}function M(e,t={},n=null){let r=t.name||e,i=t.version||`wasm`,a=t.description||`WebAssembly binary`,o=t&&typeof t.repl==`object`?t.repl:t.repl?{}:null,s=n&&n.usage||t.usage,c=s?s.replace(/%s/g,e):null,l=o?`${e} [options] ${o.evalFlag?`[${o.evalFlag} <code>] `:``}[file] [args...]`:`${e} [options] [args...]`,u=[`${e} (${r} ${i} wasm) — ${a}`,`Usage: ${c||l}`];t.details&&u.push(``,t.details),u.push(``,`Options:`);let d=n&&n.options&&n.options.length>0?n.options:Array.isArray(t.options)?t.options:[];if(d.length>0)for(let e of d)u.push(` ${e}`);else o&&(o.evalFlag&&u.push(` ${o.evalFlag.padEnd(20)}Evaluate inline code and print result`),u.push(` (no arguments) Start interactive ${e} REPL shell`));return u.push(` -h, --help Show this help message and exit`),u.push(` -V, --version Show WebAssembly binary version and exit`),n&&n.exports&&n.exports.length>0&&u.push(``,`WASM Exports: ${n.exports.join(`, `)}`),Array.isArray(t.aliases)&&t.aliases.length>0&&u.push(``,`Aliases: ${t.aliases.join(`, `)}`),(t.homepage||t.cdnUrl||t.wasmUrl)&&u.push(`Source: ${t.homepage||t.cdnUrl||t.wasmUrl}`),u}function N(e,t={},n=null){let r=X(),i=(n||e.bin||e.name).toLowerCase();class a extends r{static get name(){return i}get name(){return i}get requiresFilesystem(){return!0}async run(){let n=[...this.arguments||[]],r=n.includes(`--help`)||n.includes(`-h`),a=!r&&(n.includes(`--version`)||n.includes(`-V`)||n.includes(`-v`));this._inspectedWasm=null,this._persistedWasmBytes=e.wasmPath?D(this.context&&this.context.fs||this.fs,e.wasmPath):null,r&&this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0&&(this._inspectedWasm=j(this._persistedWasmBytes));try{if((e.type===`wasm`||e.type===`custom-wasm`)&&(this._persistedWasmBytes||e.wasmUrl)){let i=this._persistedWasmBytes;if(!i&&t.moduleLoader)try{let n=await t.moduleLoader(e.name,e.cdnUrl);n instanceof Uint8Array||n instanceof ArrayBuffer?i=n instanceof Uint8Array?n:new Uint8Array(n):n&&(n.wasmBytes||n.wasm||n.wasmBinary)&&(i=n.wasmBytes||n.wasm||n.wasmBinary)}catch{}if(!i&&e.wasmUrl&&(i=await this._fetchWasmBytes(e.wasmUrl)),i){r&&(this._inspectedWasm=j(i)),await this._runRawWasmBytes(i,n);return}}else{let o=e.cdnUrl||e.wasmUrl||`https://esm.sh/${e.name}`,s=typeof globalThis.fetch==`function`?globalThis.fetch:null;if(s&&this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0&&typeof Response<`u`){let t=this._persistedWasmBytes,n=e.wasmUrl||``;globalThis.fetch=async(e,r)=>{let i=typeof e==`string`?e:e&&e.url?e.url:``;return i&&(i===n||!/^https?:\/\//i.test(i)&&/\.wasm(\?.*)?$/i.test(i))?new Response(t,{status:200,headers:{"Content-Type":`application/wasm`}}):s(e,r)}}let c,l;try{c=await k(e.name,o,t.moduleLoader),l=c&&c.default!==void 0?c.default:c,l&&typeof l.then==`function`&&(l=await l)}finally{s&&(globalThis.fetch=s)}if(l instanceof Uint8Array||l instanceof ArrayBuffer){let e=l instanceof Uint8Array?l:new Uint8Array(l);r&&(this._inspectedWasm=j(e)),await this._runRawWasmBytes(e,n)}else if(l&&(l.wasmBytes instanceof Uint8Array||l.wasm instanceof Uint8Array)){let e=l.wasmBytes||l.wasm;r&&(this._inspectedWasm=j(e)),await this._runRawWasmBytes(e,n)}else if(typeof l==`function`)await this._runFunctionOrEmscripten(l,n,r);else if(l&&typeof l==`object`){l.ready&&await l.ready,r&&(l.HEAPU8 instanceof Uint8Array||l.wasmBinary instanceof Uint8Array)&&(this._inspectedWasm=j(l.wasmBinary||l.HEAPU8));let t=l.main||l.run||l.callMain||l.exec;if(typeof t==`function`)await this._invokeCliFunction(t.bind(l),n);else if(l.promised||typeof l.raw==`function`||typeof l.json==`function`){let e=l.promised?await l.promised:l,t=n.filter(e=>e.startsWith(`-`)),i=n.filter(e=>!e.startsWith(`-`)),o=i.shift()||`.`,s=this._createIoBridge(n,[],[]),c=i.length>0?s.readFile(i[0])||``:s.stdin||(r||a?`{}`:``),u=typeof e.raw==`function`?e.raw(c,o,t):!r&&!a?JSON.stringify(e.json(JSON.parse(c||`null`),o)):null;u!=null&&String(u).replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>{this.stdOut=e})}else if(!r&&!a){this.stdErr=`${i}: unsupported WASM module format for '${e.name}'`,this.exitCode=1;return}}else if(!r&&!a){this.stdErr=`${i}: unsupported WASM module format for '${e.name}'`,this.exitCode=1;return}}}catch(e){if(!r&&!a){if(e&&typeof e.status==`number`){this.exitCode=e.status;return}this.stdErr=`${i}: ${e.message||e}`,this.exitCode=1;return}}if(r||a){let t=this.result&&this.result.getStdOutput?this.result.getStdOutput():[],n=t.map(e=>e.string).join(`
10
- `),o=r?A(n):null,s=r&&!!(o&&(o.usage||o.options.length>0)||t.some(e=>/\b(usage|options):/i.test(e.string))),c=t.filter(e=>e.type===`out`).map(e=>e.string),l=a&&c.length>0&&(this.exitCode===0||this.exitCode===void 0);if(r)if(s){let e=t.map(e=>e.string);this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0;for(let t of e)this.stdOut=t}else{this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0;for(let t of M(i,e,this._inspectedWasm))this.stdOut=t}else a&&!l?(this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0,this.stdOut=`${i} (${e.name} ${e.version||`wasm`} wasm)`):this.exitCode=0}}async _fetchWasmBytes(e){if(E.has(e))return E.get(e);let n=t.fetch||(typeof fetch==`function`?fetch:null);if(!n)throw Error(`fetch is not available in this environment`);let r=await n(e);if(!r||!r.ok)throw Error(`HTTP ${r?r.status:`error`} fetching ${e}`);let i=new Uint8Array(await r.arrayBuffer());return E.set(e,i),i}async _runRawWasmBytes(t,n){let r=new T(i,n,this.context);r.script=i,r.arguments=n,r.context=this.context,r.fs=this.fs,r._pkgMeta=e,this.stdin!==void 0&&(r.stdin=this.stdin),await r._runWasm(t);for(let e of r.result.getStdOutput())e.type===`out`?this.stdOut=e.string:e.type===`err`&&(this.stdErr=e.string);this.exitCode=r.result.getExitCode()}_createIoBridge(t,n,r){let a=e=>({write(t){(t instanceof Uint8Array?new TextDecoder().decode(t):String(t??``)).replace(/\r?\n$/,``).split(/\r?\n/).forEach(t=>e.push(t))}});return{binName:i,args:t,stdin:this.stdin!==void 0&&this.stdin!==null?String(this.stdin):``,fs:this.fs,context:this.context,wasmPath:e.wasmPath||null,wasmBytes:this._persistedWasmBytes||null,stdout:Object.assign(e=>n.push(String(e)),a(n)),stderr:Object.assign(e=>r.push(String(e)),a(r)),readFile:(e,t)=>{if(!this.fs)return null;let n=t&&t!==`.`&&!e.startsWith(`/`)?`${t.replace(/\/+$/,``)}/${e}`:e,r=this.fs.getFileByPath(n)??this.fs.getFileByPath(e);return r==null?null:typeof r==`string`?r:new TextDecoder().decode(r)},readBytes:e=>D(this.fs,e),writeFile:(e,t,n)=>{if(!this.fs)return;let r=n&&n!==`.`&&!e.startsWith(`/`)?`${n.replace(/\/+$/,``)}/${e}`:e;if(t instanceof Uint8Array||ArrayBuffer.isView(t)){let e=r.endsWith(`.wasm`)?`application/wasm`:`application/octet-stream`;O(this.fs,r,t,e)}else this.fs.setFileByPath(r,String(t),!0);if(r.endsWith(`.wasm`)||r.endsWith(`.wat`))try{this.context&&this.context.fs?this.context.fs.setMode(r,493):this.fs.setMode(r,493)}catch{}},listFiles:(e,t)=>{if(!this.fs)return[];let n=t&&t!==`.`&&!e.startsWith(`/`)?`${t.replace(/\/+$/,``)}/${e}`:e,r=this.fs.getFileByPath(n);return r&&typeof r==`object`&&!(r instanceof Uint8Array)?Object.keys(r):[]}}}async _runFunctionOrEmscripten(t,n,r=!1){let i=[],a=[],o=new TextEncoder().encode(this.stdin||``),s=0,c=new Set,l={arguments:n,noInitialRun:!0,...this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0?{wasmBinary:this._persistedWasmBytes}:{},...e.wasmUrl?{locateFile:t=>t.endsWith(`.wasm`)?e.wasmUrl:t}:{},print:e=>{i.push(String(e))},printErr:e=>{a.push(String(e))},stdin:()=>s<o.length?o[s++]:null,preRun:[e=>{e&&e.FS&&(c=this._syncBrshToEmscriptenFs(e.FS,n))}]},u=this._createIoBridge(n,i,a),d;try{d=t.prototype&&t.prototype.constructor===t&&Object.getOwnPropertyNames(t.prototype).length>1?new t(l,u):await t(l,u)}catch(e){if(e&&typeof e.status==`number`)this.exitCode=e.status;else throw e}if(d&&typeof d==`object`)if(r&&(d.wasmBinary instanceof Uint8Array||d.HEAPU8 instanceof Uint8Array)&&(this._inspectedWasm=j(d.wasmBinary||d.HEAPU8)),typeof d.callMain==`function`){d.FS&&c.size===0&&(c=this._syncBrshToEmscriptenFs(d.FS,n));try{let e=await d.callMain(n);typeof e==`number`&&e!==0&&(this.exitCode=e)}catch(e){e&&typeof e.status==`number`?this.exitCode=e.status:(a.push(e.message||String(e)),this.exitCode=1)}d.FS&&this._syncEmscriptenFsToBrsh(d.FS,n,c)}else if(typeof d.exec==`function`&&typeof d.writeFile==`function`)await this._runVirtualFsInstance(d,n,i,a);else if(typeof d.main==`function`||typeof d.run==`function`){let e=(d.main||d.run).bind(d);await this._invokeCliFunction(e,n,i,a)}else !r&&!isVersion&&typeof d.Database==`function`?this._runSqlJsDatabase(d,n,u,i):(typeof d.stdout==`string`&&d.stdout&&d.stdout.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)),typeof d.stderr==`string`&&d.stderr&&d.stderr.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>a.push(e)),d.error&&a.length===0&&(a.push(d.error.message||String(d.error)),this.exitCode=1),typeof d.exitCode==`number`&&(this.exitCode=d.exitCode));else typeof d==`string`?d.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)):typeof d==`number`&&(this.exitCode=d);i.forEach(e=>{this.stdOut=e}),a.forEach(e=>{this.stdErr=e})}_runSqlJsDatabase(e,t,n,r){let i=`list`,a=`:memory:`,o=null,s=[];for(let e=0;e<t.length;e++){let n=t[e];n===`-table`||n===`--table`||n===`-box`?i=`table`:n===`-csv`||n===`--csv`?i=`csv`:n===`-cmd`&&e+1<t.length?o=t[++e]:n.startsWith(`-`)||s.push(n)}if(s.length===1?/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|PRAGMA|WITH|BEGIN|EXPLAIN|\.)\b/i.test(s[0])?o=s[0]:a=s[0]:s.length>=2&&(a=s[0],o=s.slice(1).join(` `)),!o&&n.stdin&&n.stdin.trim()&&(o=n.stdin.trim()),!o)return;let c=a===`:memory:`?null:n.readBytes(a),l=c&&c.byteLength>0?new e.Database(c):new e.Database;try{if(o.trim()===`.tables`){let e=l.exec(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name`),t=e[0]&&e[0].values?e[0].values.map(e=>e[0]):[];t.length>0&&r.push(t.join(` `))}else{let e=l.exec(o);for(let t of e){let e=(t.columns||[]).map(String),n=t.values||[];if(i===`table`&&e.length>0){let t=e.map(e=>e.length),i=n.map(n=>e.map((e,r)=>{let i=n[r]==null?`NULL`:String(n[r]);return i.length>t[r]&&(t[r]=i.length),i}));r.push(e.map((e,n)=>` `+e.padEnd(t[n])+` `).join(`|`)),r.push(t.map(e=>`-`.repeat(e+2)).join(`+`)),i.forEach(e=>r.push(e.map((e,n)=>` `+e.padEnd(t[n])+` `).join(`|`)))}else if(i===`csv`){let t=e=>{let t=e==null?``:String(e);return/[",\r\n]/.test(t)?`"`+t.replace(/"/g,`""`)+`"`:t};e.length>0&&r.push(e.map(t).join(`,`)),n.forEach(n=>r.push(e.map((e,r)=>t(n[r])).join(`,`)))}else n.forEach(t=>r.push(e.map((e,n)=>t[n]==null?``:String(t[n])).join(`|`)))}}a!==`:memory:`&&n.writeFile(a,l.export())}finally{l.close()}}async _runVirtualFsInstance(t,n,r,i){typeof t.on==`function`&&t.on(`log`,({message:e})=>{e&&r.push(e)}),!t.loaded&&typeof t.load==`function`&&await t.load(e.coreUrl?{coreURL:e.coreUrl}:void 0);let a=new Set,o=[];for(let e of n)if(!e.startsWith(`-`)&&(o.push(e),this.fs.exists(e))){let n=D(this.fs,e);n&&(await t.writeFile(e,n),a.add(e))}let s=await t.exec(n);for(let e of o)if(!a.has(e))try{if(typeof t.readFile==`function`){let n=await t.readFile(e);n&&O(this.fs,e,n)}}catch{}typeof s==`number`&&s!==0&&(this.exitCode=s,i.length===0&&r.length>0&&i.push(...r.splice(0,r.length)))}async _invokeCliFunction(e,t,n=null,r=null){let i=n||[],a=r||[],o=await e(t,this._createIoBridge(t,i,a));typeof o==`string`?o.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)):typeof o==`number`?this.exitCode=o:o&&typeof o==`object`&&(typeof o.stdout==`string`&&o.stdout&&o.stdout.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)),typeof o.stderr==`string`&&o.stderr&&o.stderr.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>a.push(e)),o.error?(a.length===0&&a.push(o.error.message||String(o.error)),this.exitCode=typeof o.exitCode==`number`?o.exitCode:1):typeof o.exitCode==`number`&&(this.exitCode=o.exitCode)),n||(i.forEach(e=>{this.stdOut=e}),a.forEach(e=>{this.stdErr=e}))}_syncBrshToEmscriptenFs(e,t){let n=new Set;if(!this.fs||!e||typeof e.writeFile!=`function`)return n;for(let r of t)if(!r.startsWith(`-`)&&this.fs.exists(r)){let t=D(this.fs,r);if(t)try{e.writeFile(r,t),n.add(r)}catch{}}return n}_syncEmscriptenFsToBrsh(e,t,n){if(!(!this.fs||!e||typeof e.readFile!=`function`)){for(let r of t)if(!(r.startsWith(`-`)||n.has(r)))try{let t=e.readFile(r);if(t){let e=r.endsWith(`.wasm`)?`application/wasm`:`application/octet-stream`;if(O(this.fs,r,t,e),r.endsWith(`.wasm`)||r.endsWith(`.wat`))try{this.context&&this.context.fs?this.context.fs.setMode(r,493):this.fs.setMode(r,493)}catch{}}}catch{}}}}return a}T.readBytesFromFs=D,T.writeBytesToFs=O,T.loadModule=k,T.extractHelpFromText=A,T.inspectWasmBytes=j,T.formatWasmHelp=M,T.createGenericWasmCommand=N,T.createCommand=N,t.exports=T})),ae=t(((e,t)=>{var n=G(),r=class extends n{static get name(){return`test`}get requiresFilesystem(){return!0}run(){let e=[...this.arguments];return e[e.length-1]===`]`&&e.pop(),this._evaluate(e)||(this.exitCode=1),Promise.resolve()}_evaluate(e){if(e.length===0)return!1;let t=e.indexOf(`-o`);if(t!==-1)return this._evaluate(e.slice(0,t))||this._evaluate(e.slice(t+1));let n=e.indexOf(`-a`);if(n!==-1)return this._evaluate(e.slice(0,n))&&this._evaluate(e.slice(n+1));if(e[0]===`!`)return!this._evaluate(e.slice(1));if(e.length===1)return e[0].length>0;if(e.length===2){let[t,n]=e;switch(t){case`-n`:return n.length>0;case`-z`:return n.length===0;case`-e`:return this.fs?this.fs.getFileByPath(n)!=null:!1;case`-f`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e!=null&&e.constructor!==Object}case`-d`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e!=null&&e.constructor===Object}case`-r`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&292)!=0}case`-w`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&146)!=0}case`-x`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&73)!=0}case`-s`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e==null||e.constructor===Object?!1:e.toString().length>0}default:return!1}}if(e.length===3){let[t,n,r]=e;switch(n){case`=`:case`==`:return t===r;case`!=`:return t!==r;case`-eq`:return parseInt(t)===parseInt(r);case`-ne`:return parseInt(t)!==parseInt(r);case`-lt`:return parseInt(t)<parseInt(r);case`-le`:return parseInt(t)<=parseInt(r);case`-gt`:return parseInt(t)>parseInt(r);case`-ge`:return parseInt(t)>=parseInt(r);default:return!1}}return!1}};t.exports={Test:r,TestBracket:class extends r{static get name(){return`[`}}}})),oe=t(((e,t)=>{var n=G();t.exports=class extends n{static get name(){return`cat`}get requiresFilesystem(){return!0}run(){let e=!1,t=!1,n=!1,r=[];for(let i of this.arguments)if(i.startsWith(`-`)&&i.length>1)for(let r of i.slice(1))r===`n`?e=!0:r===`b`?(t=!0,e=!1):r===`s`&&(n=!0);else r.push(i);let i=[];if(r.length===0){let e=typeof this.stdin==`string`?this.stdin:null;if(e==null)return this.stdErr=`cat: no file specified`,this.exitCode=1,Promise.resolve();i.push(e)}else for(let e of r){if(e===`-`){i.push(typeof this.stdin==`string`?this.stdin:``);continue}let t=this.fs.getFileByPath(e);if(t==null){let t=this.fs.exists(e)?`Permission denied`:`No such file or directory`;return this.stdErr=`${e}: ${t}`,this.exitCode=1,Promise.resolve()}if(t.constructor===Object)return this.stdErr=`${e}: Is a directory`,this.exitCode=1,Promise.resolve();i.push(t.toString())}let a=i.join(``);a.endsWith(`
8
+ `)},trace:(e,t,...n)=>{let r=t>0?` `+n.slice(0,t).join(`, `):``;R(1,`trace: ${ae(e)}${r}\n`)},seed:()=>Date.now()*Math.random(),abort:(e,t,n,r)=>{let i=ae(e),a=ae(t);throw(i||a)&&R(2,`abort: ${i||`aborted`} at ${a||this.script}:${n||0}:${r||0}\n`),this.exitCode=134,{_wasmExit:!0,code:134}}},{get(e,t){return t in e?e[t]:()=>0}})};try{let t=await WebAssembly.compile(e);for(let e of WebAssembly.Module.imports(t))if(e.kind===`memory`){let t=new WebAssembly.Memory({initial:1,maximum:256});T=t,oe[e.module]||(oe[e.module]={}),oe[e.module][e.name]=t}if(E=await WebAssembly.instantiate(t,oe),E.exports.memory&&(T=E.exports.memory),D=!!(E.exports.asyncify_start_unwind&&E.exports.asyncify_stop_unwind),D&&T){try{O=T.grow(1)*65536}catch{O=16}let e=O+8,t=O+65536-8;new Int32Array(T.buffer,O,2).set([e,t])}typeof E.exports.set_terminal_size==`function`&&L(),I&&this._enterAltScreen();let n=this.stdout&&this.stdout.columns||this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`COLUMNS`),10)||80,r=this.stdout&&this.stdout.rows||this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`LINES`),10)||24;if(typeof E.exports.set_terminal_size==`function`)try{E.exports.set_terminal_size(n,r)}catch{}N=()=>{let e=this.stdout&&this.stdout.columns||this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`COLUMNS`),10)||80,t=this.stdout&&this.stdout.rows||this.context&&typeof this.context.getVar==`function`&&parseInt(this.context.getVar(`LINES`),10)||24;if(typeof E?.exports?.set_terminal_size==`function`)try{E.exports.set_terminal_size(e,t)}catch{}},this.stdout&&typeof this.stdout.on==`function`&&this.stdout.on(`resize`,N),this.stdinStream&&typeof this.stdinStream.on==`function`&&this.stdinStream.on(`resize`,N);let i=E.exports._start||E.exports.__wasi_command||E.exports.main||E.exports.run;if(i)try{let e=i();for(e&&typeof e.then==`function`&&(e=await e);D&&typeof E.exports.asyncify_get_state==`function`&&E.exports.asyncify_get_state()===1;){if(this._killed){this.exitCode=130;break}if(E.exports.asyncify_stop_unwind(),k){try{await k}catch{if(this._killed){this.exitCode=130;break}}k=null}if(this._killed){this.exitCode=130;break}E.exports.asyncify_start_rewind(O),e=i(),e&&typeof e.then==`function`&&(e=await e)}}catch(e){this._killed?this.exitCode=130:(!e||!e._wasmExit)&&(this.stdErr=`${this.script}: runtime error: ${e?.message||String(e)}`,this.exitCode=1)}else{let e=Object.entries(E.exports).filter(([,e])=>typeof e==`function`).map(([e])=>e),t=e.length>0?` (module is a library exporting: ${e.join(`, `)})`:``;this.stdErr=`${this.script}: no CLI entry point found (expected _start, main, or run)${t}`,this.exitCode=1}}catch(e){this._killed?this.exitCode=130:(!e||!e._wasmExit)&&(this.stdErr=`${this.script}: ${e?.message||String(e)}`,this.exitCode=1)}finally{I&&this._exitAltScreen(),P&&(this.stdinStream&&typeof this.stdinStream.off==`function`&&this.stdinStream.off(`data`,P),this.stdin&&typeof this.stdin.off==`function`&&this.stdin.off(`data`,P)),this._onStdinStreamData&&this.stdinStream&&typeof this.stdinStream.on==`function`&&this.stdinStream.on(`data`,this._onStdinStreamData),N&&(this.stdout&&typeof this.stdout.off==`function`&&this.stdout.off(`resize`,N),this.stdinStream&&typeof this.stdinStream.off==`function`&&this.stdinStream.off(`resize`,N)),this._externalKeyHandler=null;for(let e of q.values())Y(e)}z();let se=this.arguments||[];if(!(this.result&&this.result.getStdOutput&&this.result.getStdOutput().length>0)&&(this.exitCode===0||this.exitCode===void 0)){let t=(this.script||`wasm`).split(`/`).pop(),n=Object.assign({name:t,version:`wasi`,description:`WebAssembly WASI binary (${this.script})`},this._pkgMeta||{});if(se.includes(`--help`)||se.includes(`-h`)){let r=j(e);for(let e of M(t,n,r))this.stdOut=e}else (se.includes(`--version`)||se.includes(`-V`)||se.includes(`-v`))&&(this.stdOut=`${t} (${n.name} ${n.version} wasm)`)}}},E=new Map;function D(e,t){if(!e||!e.exists(t))return null;if(e.isRealFilesystem)try{let n=J();return new Uint8Array(n.readFileSync(e.absolutePath(t)))}catch{}let n=e.getFileByPath(t);if(n==null)return null;if(n instanceof Uint8Array||v!==void 0&&v.isBuffer(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(n instanceof ArrayBuffer)return new Uint8Array(n);if(typeof n==`string`){if(n.startsWith(`data:`)){let e=n.indexOf(`,`);if(e!==-1){let t=n.slice(e+1);if(v!==void 0)return new Uint8Array(v.from(t,`base64`));let r=atob(t),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}}let e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t)&255;return e}return null}function O(e,t,n,i=`application/octet-stream`){let a=n instanceof Uint8Array?n:new Uint8Array(n),o=new Uint8Array(a.byteLength);o.set(a);let s=new r(o.buffer,i);if(e.isRealFilesystem)try{let n=J(),r=te(),i=e.absolutePath(t);n.mkdirSync(r.dirname(i),{recursive:!0}),n.writeFileSync(i,v.from(a.buffer,a.byteOffset,a.byteLength));return}catch{if(typeof e._setFileRaw==`function`){e._setFileRaw(t,s,!0);return}}if(typeof e._setFileRaw==`function`&&t.startsWith(`/var/lib/wbt/`)){e._setFileRaw(t,s,!0);return}e.setFileByPath(t,s,!0)}async function k(e,t,n=null){if(typeof n==`function`){let r=await n(e,t);if(r)return r}try{let t=await import(e);if(t)return t}catch{}if(t)try{return await import(t)}catch(n){if(!/^https?:\/\/esm\.sh\//i.test(t))try{return await import(`https://esm.sh/${e}`)}catch{}throw Error(`Failed to load WASM package '${e}' from ${t}: ${n.message||n}`)}throw Error(`Package '${e}' could not be loaded`)}function A(e,t=!1){let n={usage:null,options:[]};if(!e||typeof e!=`string`)return n;let r=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),i=new Set,a=t?r.findIndex(e=>/^usage:\s*(.+)/i.test(e)):-1,o=a>=0?a:0;for(let e=o;e<r.length;e++){let a=r[e];!n.usage&&/^usage:\s*(.+)/i.test(a)?n.usage=a.replace(/^usage:\s*/i,``).trim():/^(?:-[a-zA-Z0-9?]|--[a-zA-Z0-9][-a-zA-Z0-9]*)(?:\s|,|=|<|\[|$)/.test(a)&&a.length<=120&&!/^(?:-[hHvV],\s*)?--(?:help|version)\b/i.test(a)&&(!t||/^(?:-[a-zA-Z?]|--[a-zA-Z][a-zA-Z0-9-]*)(?:,\s*--?[a-zA-Z0-9-]+)?(?:\s+[<\[a-zA-Z0-9_.->\]]+)*(?:\s+[A-Za-z`'"(][A-Za-z0-9 ,.;:()'"`/<>\[\]=+$\t_-]*|)$/.test(a))&&(i.has(a)||(i.add(a),n.options.push(a)))}if(t&&n.options.length===0){let t=e.match(/--[a-z][a-z0-9-]{1,24}/g)||[];for(let e of Array.from(new Set(t)).slice(0,12))e!==`--help`&&e!==`--version`&&n.options.push(e)}return n}function j(e){let t={usage:null,options:[],exports:[],wasiImports:[],hasAsyncify:!1,isInteractive:!1};if(!(e instanceof Uint8Array)||e.length<8)return t;try{if(typeof WebAssembly<`u`&&WebAssembly.Module){let n=new WebAssembly.Module(e);t.exports=WebAssembly.Module.exports(n).filter(e=>e.kind===`function`).map(e=>e.name),t.wasiImports=WebAssembly.Module.imports(n).filter(e=>e.module.startsWith(`wasi_`)).map(e=>e.name),t.hasAsyncify=t.exports.includes(`asyncify_start_unwind`)&&t.exports.includes(`asyncify_stop_unwind`),t.exports.includes(`set_terminal_size`)&&(t.isInteractive=!0)}}catch{}try{let n=[],r=``;for(let t=0;t<e.length;t++){let i=e[t];i>=32&&i<=126||i===9||i===10?r+=String.fromCharCode(i):(r.length>=4&&n.push(r),r=``)}r.length>=4&&n.push(r);let i=n.join(`
9
+ `);t.isInteractive||(i.includes(`/dev/tty`)||i.includes(`\x1B[?1049h`)||i.includes(`smcup`)||i.includes(`xterm`))&&(t.isInteractive=!0);let a=A(i,!0);t.usage=a.usage,t.options=a.options}catch{}return t}function M(e,t={},n=null){let r=t.name||e,i=t.version||`wasm`,a=t.description||`WebAssembly binary`,o=t&&typeof t.repl==`object`?t.repl:t.repl?{}:null,s=n&&n.usage||t.usage,c=s?s.replace(/%s/g,e):null,l=o?`${e} [options] ${o.evalFlag?`[${o.evalFlag} <code>] `:``}[file] [args...]`:`${e} [options] [args...]`,u=[`${e} (${r} ${i} wasm) — ${a}`,`Usage: ${c||l}`];t.details&&u.push(``,t.details),u.push(``,`Options:`);let d=n&&n.options&&n.options.length>0?n.options:Array.isArray(t.options)?t.options:[];if(d.length>0)for(let e of d)u.push(` ${e}`);else o&&(o.evalFlag&&u.push(` ${o.evalFlag.padEnd(20)}Evaluate inline code and print result`),u.push(` (no arguments) Start interactive ${e} REPL shell`));return u.push(` -h, --help Show this help message and exit`),u.push(` -V, --version Show WebAssembly binary version and exit`),n&&n.exports&&n.exports.length>0&&u.push(``,`WASM Exports: ${n.exports.join(`, `)}`),Array.isArray(t.aliases)&&t.aliases.length>0&&u.push(``,`Aliases: ${t.aliases.join(`, `)}`),(t.homepage||t.cdnUrl||t.wasmUrl)&&u.push(`Source: ${t.homepage||t.cdnUrl||t.wasmUrl}`),u}function N(e,t={},n=null){let r=X(),i=(n||e.bin||e.name).toLowerCase();class a extends r{static get name(){return i}get name(){return i}get requiresFilesystem(){return!0}get interactive(){return this._subCommand?this._subCommand.interactive:this._isInteractive===void 0?!!(e&&(e.interactive||e.wasm?.interactive)||this._inspectedWasm&&this._inspectedWasm.isInteractive):!!this._isInteractive}get captureInput(){return this.interactive}kill(e=`SIGINT`){this._subCommand&&typeof this._subCommand.kill==`function`&&this._subCommand.kill(e),super.kill(e)}onInput(e){this._subCommand&&typeof this._subCommand.onInput==`function`&&this._subCommand.onInput(e)}async run(){let n=[...this.arguments||[]],r=n.includes(`--help`)||n.includes(`-h`),a=!r&&(n.includes(`--version`)||n.includes(`-V`)||n.includes(`-v`));this._inspectedWasm=null,this._persistedWasmBytes=e.wasmPath?D(this.context&&this.context.fs||this.fs,e.wasmPath):null,r&&this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0&&(this._inspectedWasm=j(this._persistedWasmBytes));try{if((e.type===`wasm`||e.type===`custom-wasm`)&&(this._persistedWasmBytes||e.wasmUrl)){let i=this._persistedWasmBytes;if(!i&&t.moduleLoader)try{let n=await t.moduleLoader(e.name,e.cdnUrl);n instanceof Uint8Array||n instanceof ArrayBuffer?i=n instanceof Uint8Array?n:new Uint8Array(n):n&&(n.wasmBytes||n.wasm||n.wasmBinary)&&(i=n.wasmBytes||n.wasm||n.wasmBinary)}catch{}if(!i&&e.wasmUrl&&(i=await this._fetchWasmBytes(e.wasmUrl)),i){r&&(this._inspectedWasm=j(i)),await this._runRawWasmBytes(i,n);return}}else{let o=e.cdnUrl||e.wasmUrl||`https://esm.sh/${e.name}`,s=typeof globalThis.fetch==`function`?globalThis.fetch:null;if(s&&this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0&&typeof Response<`u`){let t=this._persistedWasmBytes,n=e.wasmUrl||``;globalThis.fetch=async(e,r)=>{let i=typeof e==`string`?e:e&&e.url?e.url:``;return i&&(i===n||!/^https?:\/\//i.test(i)&&/\.wasm(\?.*)?$/i.test(i))?new Response(t,{status:200,headers:{"Content-Type":`application/wasm`}}):s(e,r)}}let c,l;try{c=await k(e.name,o,t.moduleLoader),l=c&&c.default!==void 0?c.default:c,l&&typeof l.then==`function`&&(l=await l)}finally{s&&(globalThis.fetch=s)}if(l instanceof Uint8Array||l instanceof ArrayBuffer){let e=l instanceof Uint8Array?l:new Uint8Array(l);r&&(this._inspectedWasm=j(e)),await this._runRawWasmBytes(e,n)}else if(l&&(l.wasmBytes instanceof Uint8Array||l.wasm instanceof Uint8Array)){let e=l.wasmBytes||l.wasm;r&&(this._inspectedWasm=j(e)),await this._runRawWasmBytes(e,n)}else if(typeof l==`function`)await this._runFunctionOrEmscripten(l,n,r);else if(l&&typeof l==`object`){l.ready&&await l.ready,r&&(l.HEAPU8 instanceof Uint8Array||l.wasmBinary instanceof Uint8Array)&&(this._inspectedWasm=j(l.wasmBinary||l.HEAPU8));let t=l.main||l.run||l.callMain||l.exec;if(typeof t==`function`)await this._invokeCliFunction(t.bind(l),n);else if(l.promised||typeof l.raw==`function`||typeof l.json==`function`){let e=l.promised?await l.promised:l,t=n.filter(e=>e.startsWith(`-`)),i=n.filter(e=>!e.startsWith(`-`)),o=i.shift()||`.`,s=this._createIoBridge(n,[],[]),c=i.length>0?s.readFile(i[0])||``:s.stdin||(r||a?`{}`:``),u=typeof e.raw==`function`?e.raw(c,o,t):!r&&!a?JSON.stringify(e.json(JSON.parse(c||`null`),o)):null;u!=null&&String(u).replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>{this.stdOut=e})}else if(!r&&!a){this.stdErr=`${i}: unsupported WASM module format for '${e.name}'`,this.exitCode=1;return}}else if(!r&&!a){this.stdErr=`${i}: unsupported WASM module format for '${e.name}'`,this.exitCode=1;return}}}catch(e){if(!r&&!a){if(e&&typeof e.status==`number`){this.exitCode=e.status;return}this.stdErr=`${i}: ${e.message||e}`,this.exitCode=1;return}}if(r||a){let t=this.result&&this.result.getStdOutput?this.result.getStdOutput():[],n=t.map(e=>e.string).join(`
10
+ `),o=r?A(n):null,s=r&&!!(o&&(o.usage||o.options.length>0)||t.some(e=>/\b(usage|options):/i.test(e.string))),c=t.filter(e=>e.type===`out`).map(e=>e.string),l=a&&c.length>0&&(this.exitCode===0||this.exitCode===void 0);if(r)if(s){let e=t.map(e=>e.string);this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0;for(let t of e)this.stdOut=t}else{this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0;for(let t of M(i,e,this._inspectedWasm))this.stdOut=t}else a&&!l?(this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0,this.stdOut=`${i} (${e.name} ${e.version||`wasm`} wasm)`):this.exitCode=0}}async _fetchWasmBytes(e){if(E.has(e))return E.get(e);let n=t.fetch||(typeof fetch==`function`?fetch:null);if(!n)throw Error(`fetch is not available in this environment`);let r=await n(e);if(!r||!r.ok)throw Error(`HTTP ${r?r.status:`error`} fetching ${e}`);let i=new Uint8Array(await r.arrayBuffer());return E.set(e,i),i}async _runRawWasmBytes(t,n){let r=new T(i,n,this.context);r.script=i,r.arguments=n,r.context=this.context,r.fs=this.fs,r._pkgMeta=e,this.stdin!==void 0&&(r.stdin=this.stdin),this._subCommand=r;try{await r._runWasm(t)}finally{this._subCommand=null}for(let e of r.result.getStdOutput())e.type===`out`?this.stdOut=e.string:e.type===`err`&&(this.stdErr=e.string);this.exitCode=r.result.getExitCode()}_createIoBridge(t,n,r){let a=e=>({write(t){(t instanceof Uint8Array?new TextDecoder().decode(t):String(t??``)).replace(/\r?\n$/,``).split(/\r?\n/).forEach(t=>e.push(t))}});return{binName:i,args:t,stdin:this.stdin!==void 0&&this.stdin!==null?String(this.stdin):``,fs:this.fs,context:this.context,wasmPath:e.wasmPath||null,wasmBytes:this._persistedWasmBytes||null,stdout:Object.assign(e=>n.push(String(e)),a(n)),stderr:Object.assign(e=>r.push(String(e)),a(r)),readFile:(e,t)=>{if(!this.fs)return null;let n=t&&t!==`.`&&!e.startsWith(`/`)?`${t.replace(/\/+$/,``)}/${e}`:e,r=this.fs.getFileByPath(n)??this.fs.getFileByPath(e);return r==null?null:typeof r==`string`?r:new TextDecoder().decode(r)},readBytes:e=>D(this.fs,e),writeFile:(e,t,n)=>{if(!this.fs)return;let r=n&&n!==`.`&&!e.startsWith(`/`)?`${n.replace(/\/+$/,``)}/${e}`:e;if(t instanceof Uint8Array||ArrayBuffer.isView(t)){let e=r.endsWith(`.wasm`)?`application/wasm`:`application/octet-stream`;O(this.fs,r,t,e)}else this.fs.setFileByPath(r,String(t),!0);if(r.endsWith(`.wasm`)||r.endsWith(`.wat`))try{this.context&&this.context.fs?this.context.fs.setMode(r,493):this.fs.setMode(r,493)}catch{}},listFiles:(e,t)=>{if(!this.fs)return[];let n=t&&t!==`.`&&!e.startsWith(`/`)?`${t.replace(/\/+$/,``)}/${e}`:e,r=this.fs.getFileByPath(n);return r&&typeof r==`object`&&!(r instanceof Uint8Array)?Object.keys(r):[]}}}async _runFunctionOrEmscripten(t,n,r=!1){let i=[],a=[],o=new TextEncoder().encode(this.stdin||``),s=0,c=new Set,l={arguments:n,noInitialRun:!0,...this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0?{wasmBinary:this._persistedWasmBytes}:{},...e.wasmUrl?{locateFile:t=>t.endsWith(`.wasm`)?e.wasmUrl:t}:{},print:e=>{i.push(String(e))},printErr:e=>{a.push(String(e))},stdin:()=>s<o.length?o[s++]:null,preRun:[e=>{e&&e.FS&&(c=this._syncBrshToEmscriptenFs(e.FS,n))}]},u=this._createIoBridge(n,i,a),d;try{d=t.prototype&&t.prototype.constructor===t&&Object.getOwnPropertyNames(t.prototype).length>1?new t(l,u):await t(l,u)}catch(e){if(e&&typeof e.status==`number`)this.exitCode=e.status;else throw e}if(d&&typeof d==`object`)if(r&&(d.wasmBinary instanceof Uint8Array||d.HEAPU8 instanceof Uint8Array)&&(this._inspectedWasm=j(d.wasmBinary||d.HEAPU8)),typeof d.callMain==`function`){d.FS&&c.size===0&&(c=this._syncBrshToEmscriptenFs(d.FS,n));try{let e=await d.callMain(n);typeof e==`number`&&e!==0&&(this.exitCode=e)}catch(e){e&&typeof e.status==`number`?this.exitCode=e.status:(a.push(e.message||String(e)),this.exitCode=1)}d.FS&&this._syncEmscriptenFsToBrsh(d.FS,n,c)}else if(typeof d.exec==`function`&&typeof d.writeFile==`function`)await this._runVirtualFsInstance(d,n,i,a);else if(typeof d.main==`function`||typeof d.run==`function`){let e=(d.main||d.run).bind(d);await this._invokeCliFunction(e,n,i,a)}else !r&&!isVersion&&typeof d.Database==`function`?this._runSqlJsDatabase(d,n,u,i):(typeof d.stdout==`string`&&d.stdout&&d.stdout.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)),typeof d.stderr==`string`&&d.stderr&&d.stderr.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>a.push(e)),d.error&&a.length===0&&(a.push(d.error.message||String(d.error)),this.exitCode=1),typeof d.exitCode==`number`&&(this.exitCode=d.exitCode));else typeof d==`string`?d.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)):typeof d==`number`&&(this.exitCode=d);i.forEach(e=>{this.stdOut=e}),a.forEach(e=>{this.stdErr=e})}_runSqlJsDatabase(e,t,n,r){let i=`list`,a=`:memory:`,o=null,s=[];for(let e=0;e<t.length;e++){let n=t[e];n===`-table`||n===`--table`||n===`-box`?i=`table`:n===`-csv`||n===`--csv`?i=`csv`:n===`-cmd`&&e+1<t.length?o=t[++e]:n.startsWith(`-`)||s.push(n)}if(s.length===1?/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|PRAGMA|WITH|BEGIN|EXPLAIN|\.)\b/i.test(s[0])?o=s[0]:a=s[0]:s.length>=2&&(a=s[0],o=s.slice(1).join(` `)),!o&&n.stdin&&n.stdin.trim()&&(o=n.stdin.trim()),!o)return;let c=a===`:memory:`?null:n.readBytes(a),l=c&&c.byteLength>0?new e.Database(c):new e.Database;try{if(o.trim()===`.tables`){let e=l.exec(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name`),t=e[0]&&e[0].values?e[0].values.map(e=>e[0]):[];t.length>0&&r.push(t.join(` `))}else{let e=l.exec(o);for(let t of e){let e=(t.columns||[]).map(String),n=t.values||[];if(i===`table`&&e.length>0){let t=e.map(e=>e.length),i=n.map(n=>e.map((e,r)=>{let i=n[r]==null?`NULL`:String(n[r]);return i.length>t[r]&&(t[r]=i.length),i}));r.push(e.map((e,n)=>` `+e.padEnd(t[n])+` `).join(`|`)),r.push(t.map(e=>`-`.repeat(e+2)).join(`+`)),i.forEach(e=>r.push(e.map((e,n)=>` `+e.padEnd(t[n])+` `).join(`|`)))}else if(i===`csv`){let t=e=>{let t=e==null?``:String(e);return/[",\r\n]/.test(t)?`"`+t.replace(/"/g,`""`)+`"`:t};e.length>0&&r.push(e.map(t).join(`,`)),n.forEach(n=>r.push(e.map((e,r)=>t(n[r])).join(`,`)))}else n.forEach(t=>r.push(e.map((e,n)=>t[n]==null?``:String(t[n])).join(`|`)))}}a!==`:memory:`&&n.writeFile(a,l.export())}finally{l.close()}}async _runVirtualFsInstance(t,n,r,i){typeof t.on==`function`&&t.on(`log`,({message:e})=>{e&&r.push(e)}),!t.loaded&&typeof t.load==`function`&&await t.load(e.coreUrl?{coreURL:e.coreUrl}:void 0);let a=new Set,o=[];for(let e of n)if(!e.startsWith(`-`)&&(o.push(e),this.fs.exists(e))){let n=D(this.fs,e);n&&(await t.writeFile(e,n),a.add(e))}let s=await t.exec(n);for(let e of o)if(!a.has(e))try{if(typeof t.readFile==`function`){let n=await t.readFile(e);n&&O(this.fs,e,n)}}catch{}typeof s==`number`&&s!==0&&(this.exitCode=s,i.length===0&&r.length>0&&i.push(...r.splice(0,r.length)))}async _invokeCliFunction(e,t,n=null,r=null){let i=n||[],a=r||[],o=await e(t,this._createIoBridge(t,i,a));typeof o==`string`?o.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)):typeof o==`number`?this.exitCode=o:o&&typeof o==`object`&&(typeof o.stdout==`string`&&o.stdout&&o.stdout.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)),typeof o.stderr==`string`&&o.stderr&&o.stderr.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>a.push(e)),o.error?(a.length===0&&a.push(o.error.message||String(o.error)),this.exitCode=typeof o.exitCode==`number`?o.exitCode:1):typeof o.exitCode==`number`&&(this.exitCode=o.exitCode)),n||(i.forEach(e=>{this.stdOut=e}),a.forEach(e=>{this.stdErr=e}))}_syncBrshToEmscriptenFs(e,t){let n=new Set;if(!this.fs||!e||typeof e.writeFile!=`function`)return n;for(let r of t)if(!r.startsWith(`-`)&&this.fs.exists(r)){let t=D(this.fs,r);if(t)try{e.writeFile(r,t),n.add(r)}catch{}}return n}_syncEmscriptenFsToBrsh(e,t,n){if(!(!this.fs||!e||typeof e.readFile!=`function`)){for(let r of t)if(!(r.startsWith(`-`)||n.has(r)))try{let t=e.readFile(r);if(t){let e=r.endsWith(`.wasm`)?`application/wasm`:`application/octet-stream`;if(O(this.fs,r,t,e),r.endsWith(`.wasm`)||r.endsWith(`.wat`))try{this.context&&this.context.fs?this.context.fs.setMode(r,493):this.fs.setMode(r,493)}catch{}}}catch{}}}}return a}T.readBytesFromFs=D,T.writeBytesToFs=O,T.loadModule=k,T.extractHelpFromText=A,T.inspectWasmBytes=j,T.formatWasmHelp=M,T.createGenericWasmCommand=N,T.createCommand=N,t.exports=T})),ae=t(((e,t)=>{var n=G(),r=class extends n{static get name(){return`test`}get requiresFilesystem(){return!0}run(){let e=[...this.arguments];return e[e.length-1]===`]`&&e.pop(),this._evaluate(e)||(this.exitCode=1),Promise.resolve()}_evaluate(e){if(e.length===0)return!1;let t=e.indexOf(`-o`);if(t!==-1)return this._evaluate(e.slice(0,t))||this._evaluate(e.slice(t+1));let n=e.indexOf(`-a`);if(n!==-1)return this._evaluate(e.slice(0,n))&&this._evaluate(e.slice(n+1));if(e[0]===`!`)return!this._evaluate(e.slice(1));if(e.length===1)return e[0].length>0;if(e.length===2){let[t,n]=e;switch(t){case`-n`:return n.length>0;case`-z`:return n.length===0;case`-e`:return this.fs?this.fs.getFileByPath(n)!=null:!1;case`-f`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e!=null&&e.constructor!==Object}case`-d`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e!=null&&e.constructor===Object}case`-r`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&292)!=0}case`-w`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&146)!=0}case`-x`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&73)!=0}case`-s`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e==null||e.constructor===Object?!1:e.toString().length>0}default:return!1}}if(e.length===3){let[t,n,r]=e;switch(n){case`=`:case`==`:return t===r;case`!=`:return t!==r;case`-eq`:return parseInt(t)===parseInt(r);case`-ne`:return parseInt(t)!==parseInt(r);case`-lt`:return parseInt(t)<parseInt(r);case`-le`:return parseInt(t)<=parseInt(r);case`-gt`:return parseInt(t)>parseInt(r);case`-ge`:return parseInt(t)>=parseInt(r);default:return!1}}return!1}};t.exports={Test:r,TestBracket:class extends r{static get name(){return`[`}}}})),oe=t(((e,t)=>{var n=G();t.exports=class extends n{static get name(){return`cat`}get requiresFilesystem(){return!0}run(){let e=!1,t=!1,n=!1,r=[];for(let i of this.arguments)if(i.startsWith(`-`)&&i.length>1)for(let r of i.slice(1))r===`n`?e=!0:r===`b`?(t=!0,e=!1):r===`s`&&(n=!0);else r.push(i);let i=[];if(r.length===0){let e=typeof this.stdin==`string`?this.stdin:null;if(e==null)return this.stdErr=`cat: no file specified`,this.exitCode=1,Promise.resolve();i.push(e)}else for(let e of r){if(e===`-`){i.push(typeof this.stdin==`string`?this.stdin:``);continue}let t=this.fs.getFileByPath(e);if(t==null){let t=this.fs.exists(e)?`Permission denied`:`No such file or directory`;return this.stdErr=`${e}: ${t}`,this.exitCode=1,Promise.resolve()}if(t.constructor===Object)return this.stdErr=`${e}: Is a directory`,this.exitCode=1,Promise.resolve();i.push(t.toString())}let a=i.join(``);a.endsWith(`
11
11
  `)&&(a=a.slice(0,-1));let o=a.split(`
12
12
  `);if(n&&(o=o.reduce((e,t)=>(t===``&&e.length>0&&e[e.length-1]===``||e.push(t),e),[])),t||e){let e=0;o=o.map(n=>t&&n===``?n:(e++,`${String(e).padStart(6)}\t${n}`))}return o.forEach(e=>this.stdOut=e),Promise.resolve()}}})),se=t(((e,t)=>{function n(e){return typeof e==`object`&&!!e}function r(e){return n(e)&&typeof e.length==`number`}function i(e){return Array.isArray(e)?e:e===void 0?[]:r(e)||e instanceof Set?Array.from(e):[e]}t.exports=i})),ce=t(((e,t)=>{function n(e,t,...n){let r=[];if(!Array.isArray(e))throw Error(`Input must be an array`);for(let[i,a]of e.entries()){let e=[];n.forEach(t=>{typeof t==`function`?e=e.concat(t(a)):e.push(t)}),t(a)&&r.push({index:i,replaceWithValue:e})}for(let t of r.reverse()){let n=[t.index,1].concat(t.replaceWithValue);e.splice.apply(e,n)}return e}t.exports=n})),le=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){return!isNaN(parseFloat(e))}function n(e){return!isNaN(parseFloat(e))&&isFinite(e)}function r(e){return typeof e==`object`&&!!e&&e.constructor===Object}function i(e){return a(e)&&typeof e.length==`number`}function a(e){return typeof e==`object`&&!!e}function o(e){return e!==void 0}function s(e){return!o(e)}function c(e){return e===null}function l(e){return o(e)&&!c(e)&&!Number.isNaN(e)}function u(e){return typeof e==`function`?/^class /.test(Function.prototype.toString.call(e)):!1}function d(e){if(e===null)return!0;switch(typeof e){case`string`:case`number`:case`symbol`:case`undefined`:case`boolean`:return!0;default:return!1}}function f(e){if(e){let t=o(Promise)&&e instanceof Promise,n=e.then&&typeof e.then==`function`;return!!(t||n)}else return!1}function p(e){return e===null||!o(e)?!1:typeof e[Symbol.iterator]==`function`||typeof e[Symbol.asyncIterator]==`function`}function m(e){return typeof e==`string`}function h(e){return typeof e==`function`}function g(e){return typeof e==`function`&&e.constructor.name===`AsyncFunction`}e.default={isNumber:t,isFiniteNumber:n,isPlainObject:r,isArrayLike:i,isObject:a,isDefined:o,isUndefined:s,isNull:c,isDefinedValue:l,isClass:u,isPrimitive:d,isPromise:f,isIterable:p,isString:m,isFunction:h,isAsyncFunction:g},e.isArrayLike=i,e.isAsyncFunction=g,e.isClass=u,e.isDefined=o,e.isDefinedValue=l,e.isFiniteNumber=n,e.isFunction=h,e.isIterable=p,e.isNull=c,e.isNumber=t,e.isObject=a,e.isPlainObject=r,e.isPrimitive=d,e.isPromise=f,e.isString=m,e.isUndefined=s})),ue,de=e((()=>{ue=globalThis||self})),fe=t(((e,t)=>{de();var n=1/0,r=`[object Symbol]`,i=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,a=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,o=`\\ud800-\\udfff`,s=`\\u0300-\\u036f\\ufe20-\\ufe23`,c=`\\u20d0-\\u20f0`,l=`\\u2700-\\u27bf`,u=`a-z\\xdf-\\xf6\\xf8-\\xff`,d=`\\xac\\xb1\\xd7\\xf7`,f=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,p=`\\u2000-\\u206f`,m=` \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000`,h=`A-Z\\xc0-\\xd6\\xd8-\\xde`,g=`\\ufe0e\\ufe0f`,_=d+f+p+m,v=`['’]`,y=`[`+o+`]`,b=`[`+_+`]`,x=`[`+s+c+`]`,S=`\\d+`,C=`[`+l+`]`,w=`[`+u+`]`,T=`[^`+o+_+S+l+u+h+`]`,E=`\\ud83c[\\udffb-\\udfff]`,D=`(?:`+x+`|`+E+`)`,O=`[^`+o+`]`,k=`(?:\\ud83c[\\udde6-\\uddff]){2}`,A=`[\\ud800-\\udbff][\\udc00-\\udfff]`,j=`[`+h+`]`,M=`\\u200d`,N=`(?:`+w+`|`+T+`)`,P=`(?:`+j+`|`+T+`)`,F=`(?:`+v+`(?:d|ll|m|re|s|t|ve))?`,I=`(?:`+v+`(?:D|LL|M|RE|S|T|VE))?`,L=D+`?`,R=`[`+g+`]?`,z=`(?:`+M+`(?:`+[O,k,A].join(`|`)+`)`+R+L+`)*`,B=R+L+z,V=`(?:`+[C,k,A].join(`|`)+`)`+B,H=`(?:`+[O+x+`?`,x,k,A,y].join(`|`)+`)`,U=RegExp(v,`g`),W=RegExp(x,`g`),G=RegExp(E+`(?=`+E+`)|`+H+B,`g`),ee=RegExp([j+`?`+w+`+`+F+`(?=`+[b,j,`$`].join(`|`)+`)`,P+`+`+I+`(?=`+[b,j+N,`$`].join(`|`)+`)`,j+`?`+N+`+`+F,j+`+`+I,S,V].join(`|`),`g`),K=RegExp(`[`+M+o+s+c+g+`]`),q=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,J={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`Ae`,æ:`ae`,Þ:`Th`,þ:`th`,ß:`ss`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`IJ`,ij:`ij`,Œ:`Oe`,œ:`oe`,ʼn:`'n`,ſ:`ss`},te=typeof ue==`object`&&ue&&ue.Object===Object&&ue,ne=typeof self==`object`&&self&&self.Object===Object&&self,Y=te||ne||Function(`return this`)();function X(e,t,n,r){var i=-1,a=e?e.length:0;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function re(e){return e.split(``)}function ie(e){return e.match(i)||[]}function ae(e){return function(t){return e?.[t]}}var oe=ae(J);function se(e){return K.test(e)}function ce(e){return q.test(e)}function le(e){return se(e)?fe(e):re(e)}function fe(e){return e.match(G)||[]}function pe(e){return e.match(ee)||[]}var me=Object.prototype.toString,Z=Y.Symbol,he=Z?Z.prototype:void 0,ge=he?he.toString:void 0;function _e(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}function ve(e){if(typeof e==`string`)return e;if(Ce(e))return ge?ge.call(e):``;var t=e+``;return t==`0`&&1/e==-n?`-0`:t}function ye(e,t,n){var r=e.length;return n=n===void 0?r:n,!t&&n>=r?e:_e(e,t,n)}function be(e){return function(t){t=we(t);var n=se(t)?le(t):void 0,r=n?n[0]:t.charAt(0),i=n?ye(n,1).join(``):t.slice(1);return r[e]()+i}}function xe(e){return function(t){return X(ke(De(t).replace(U,``)),e,``)}}function Se(e){return!!e&&typeof e==`object`}function Ce(e){return typeof e==`symbol`||Se(e)&&me.call(e)==r}function we(e){return e==null?``:ve(e)}var Te=xe(function(e,t,n){return t=t.toLowerCase(),e+(n?Ee(t):t)});function Ee(e){return Oe(we(e).toLowerCase())}function De(e){return e=we(e),e&&e.replace(a,oe).replace(W,``)}var Oe=be(`toUpperCase`);function ke(e,t,n){return e=we(e),t=n?void 0:t,t===void 0?ce(e)?pe(e):ie(e):e.match(t)||[]}t.exports=Te})),pe=t(((e,t)=>{B();var n=se(),r=ce(),i=le(),a=fe(),o={short:/^-([^\d-])$/,long:/^--(\S+)/,combinedShort:/^-[^\d-]{2,}$/,optEquals:/^(--\S+?)=(.*)/},s=class extends Array{load(e){if(this.clear(),e&&e!==z.argv)e=n(e);else{e=z.argv.slice(0);let t=z.execArgv.some(m)?1:2;e.splice(0,t)}e.forEach(e=>this.push(String(e)))}clear(){this.length=0}expandOptionEqualsNotation(){if(this.some(e=>o.optEquals.test(e))){let e=[];this.forEach(t=>{let n=t.match(o.optEquals);n?e.push(n[1],n[2]):e.push(t)}),this.clear(),this.load(e)}}expandGetoptNotation(){this.hasCombinedShortOptions()&&r(this,o.combinedShort,c)}hasCombinedShortOptions(){return this.some(e=>o.combinedShort.test(e))}static from(e){let t=new this;return t.load(e),t}};function c(e){return e=e.slice(1),e.split(``).map(e=>`-`+e)}function l(e){return o.optEquals.test(e)}function u(e){return(o.short.test(e)||o.long.test(e))&&!o.optEquals.test(e)}function d(e){return o.long.test(e)&&!l(e)}function f(e){return o.short.test(e)?e.match(o.short)[1]:d(e)?e.match(o.long)[1]:l(e)?e.match(o.optEquals)[1].replace(/^--/,``):null}function p(e){return!(u(e)||o.combinedShort.test(e)||o.optEquals.test(e))}function m(e){return[`--eval`,`-e`].indexOf(e)>-1||e.startsWith(`--eval=`)}var h=class{constructor(e){this.name=e.name,this.type=e.type||String,this.alias=e.alias,this.multiple=e.multiple,this.lazyMultiple=e.lazyMultiple,this.defaultOption=e.defaultOption,this.defaultValue=e.defaultValue,this.group=e.group;for(let t in e)this[t]||(this[t]=e[t])}isBoolean(){return this.type===Boolean||i.isFunction(this.type)&&this.type.name===`Boolean`}isMultiple(){return this.multiple||this.lazyMultiple}static create(e){return new this(e)}},g=class extends Array{validate(e){this.some(e=>!e.name)&&_(`INVALID_DEFINITIONS`,"Invalid option definitions: the `name` property is required on each definition"),this.some(e=>e.type&&typeof e.type!=`function`)&&_(`INVALID_DEFINITIONS`,"Invalid option definitions: the `type` property must be a setter fuction (default: `Boolean`)");let t;this.some(e=>(t=e,i.isDefined(e.alias)&&i.isNumber(e.alias)))&&_(`INVALID_DEFINITIONS`,`Invalid option definition: to avoid ambiguity an alias cannot be numeric [--`+t.name+` alias is -`+t.alias+`]`),this.some(e=>(t=e,i.isDefined(e.alias)&&e.alias.length!==1))&&_(`INVALID_DEFINITIONS`,`Invalid option definition: an alias must be a single character`),this.some(e=>(t=e,e.alias===`-`))&&_(`INVALID_DEFINITIONS`,`Invalid option definition: an alias cannot be "-"`),y(this.map(t=>e?t.name.toLowerCase():t.name))&&_(`INVALID_DEFINITIONS`,`Two or more option definitions have the same name`),y(this.map(t=>e&&i.isDefined(t.alias)?t.alias.toLowerCase():t.alias))&&_(`INVALID_DEFINITIONS`,`Two or more option definitions have the same alias`),this.filter(e=>e.defaultOption===!0).length>1&&_(`INVALID_DEFINITIONS`,`Only one option definition can be the defaultOption`),this.some(e=>(t=e,e.isBoolean()&&e.defaultOption))&&_(`INVALID_DEFINITIONS`,`A boolean option ["${t.name}"] can not also be the defaultOption.`)}get(e,t){if(u(e))if(o.short.test(e)){let n=f(e);if(t){let e=n.toLowerCase();return this.find(t=>i.isDefined(t.alias)&&t.alias.toLowerCase()===e)}else return this.find(e=>e.alias===n)}else{let n=f(e);if(t){let e=n.toLowerCase();return this.find(t=>t.name.toLowerCase()===e)}else return this.find(e=>e.name===n)}else return this.find(t=>t.name===e)}getDefault(){return this.find(e=>e.defaultOption===!0)}isGrouped(){return this.some(e=>e.group)}whereGrouped(){return this.filter(v)}whereNotGrouped(){return this.filter(e=>!v(e))}whereDefaultValueSet(){return this.filter(e=>i.isDefined(e.defaultValue))}static from(e,t){if(e instanceof this)return e;let r=super.from(n(e),e=>h.create(e));return r.validate(t),r}};function _(e,t){let n=Error(t);throw n.name=e,n}function v(e){return n(e.group).some(e=>e)}function y(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(t[r])return!0;i.isDefined(r)&&(t[r]=!0)}}var b=class{constructor(e,t){this.options=Object.assign({},t),this.definitions=g.from(e,this.options.caseInsensitive),this.argv=s.from(this.options.argv),this.argv.hasCombinedShortOptions()&&r(this.argv,o.combinedShort.test.bind(o.combinedShort),e=>(e=e.slice(1),e.split(``).map(t=>({origArg:`-${e}`,arg:`-`+t}))))}*[Symbol.iterator](){let e=this.definitions,t,n,r,a,s=!1,c=!1,d;for(let f of this.argv){if(i.isPlainObject(f)&&(d=f.origArg,f=f.arg),c&&this.options.stopAtFirstUnknown){yield{event:`unknown_value`,arg:f,name:`_unknown`,value:void 0};continue}if(u(f))t=e.get(f,this.options.caseInsensitive),n=void 0,t?(n=t.isBoolean()?!0:null,a=`set`):a=`unknown_option`;else if(l(f)){let r=f.match(o.optEquals);t=e.get(r[1],this.options.caseInsensitive),t?t.isBoolean()?(yield{event:`unknown_value`,arg:f,name:`_unknown`,value:n,def:t},a=`set`,n=!0):(a=`set`,n=r[2]):a=`unknown_option`}else p(f)&&(t?(n=f,a=`set`):(t=this.definitions.getDefault(),t&&!s?(n=f,a=`set`):(a=`unknown_value`,t=void 0)));r=t?t.name:`_unknown`;let m={event:a,arg:f,name:r,value:n,def:t};d&&(m.subArg=f,m.arg=d),yield m,r===`_unknown`&&(c=!0),t&&t.defaultOption&&!t.isMultiple()&&a===`set`&&(s=!0),t&&t.isBoolean()&&(t=void 0),t&&!t.multiple&&i.isDefined(n)&&n!==null&&(t=void 0),n=void 0,a=void 0,r=void 0,d=void 0}}},x=new WeakMap,S=class{constructor(e){this.definition=new h(e),this.state=null,this.resetToDefault()}get(){return x.get(this)}set(e){this._set(e,`set`)}_set(e,t){let n=this.definition;if(n.isMultiple()){if(e!=null){let r=this.get();this.state===`default`&&(r.length=0),r.push(n.type(e)),this.state=t}}else if(!n.isMultiple()&&this.state===`set`){let t=Error(`Singular option already set [${this.definition.name}=${this.get()}]`);throw t.name=`ALREADY_SET`,t.value=e,t.optionName=n.name,t}else e==null?x.set(this,e):(x.set(this,n.type(e)),this.state=t)}resetToDefault(){i.isDefined(this.definition.defaultValue)?this.definition.isMultiple()?x.set(this,n(this.definition.defaultValue).slice()):x.set(this,this.definition.defaultValue):this.definition.isMultiple()?x.set(this,[]):x.set(this,null),this.state=`default`}static create(e){return e=new h(e),e.isBoolean()?C.create(e):new this(e)}},C=class extends S{set(e){super.set(!0)}static create(e){return new this(e)}},w=class extends Map{constructor(e){super(),this.definitions=g.from(e),this.set(`_unknown`,S.create({name:`_unknown`,multiple:!0}));for(let e of this.definitions.whereDefaultValueSet())this.set(e.name,S.create(e))}toObject(e){e||={};let t={};for(let n of this){let r=e.camelCase&&n[0]!==`_unknown`?a(n[0]):n[0],i=n[1];r===`_unknown`&&!i.get().length||(t[r]=i.get())}return e.skipUnknown&&delete t._unknown,t}},T=class extends w{toObject(e){let t=super.toObject({skipUnknown:e.skipUnknown}),r=super.toObject(e),o=r._unknown;delete r._unknown;let s={_all:r};return o&&o.length&&(s._unknown=o),this.definitions.whereGrouped().forEach(r=>{let o=e.camelCase?a(r.name):r.name,c=t[r.name];for(let e of n(r.group))s[e]=s[e]||{},i.isDefined(c)&&(s[e][o]=c)}),this.definitions.whereNotGrouped().forEach(n=>{let r=e.camelCase?a(n.name):n.name,o=t[n.name];i.isDefined(o)&&(s._none||={},s._none[r]=o)}),s}};function E(e,t){t||={},t.stopAtFirstUnknown&&(t.partial=!0),e=g.from(e,t.caseInsensitive);let n=new b(e,{argv:t.argv,stopAtFirstUnknown:t.stopAtFirstUnknown,caseInsensitive:t.caseInsensitive}),r=new(e.isGrouped()?T:w)(e);for(let e of n){let n=e.subArg||e.arg;if(!t.partial){if(e.event===`unknown_value`){let e=Error(`Unknown value: ${n}`);throw e.name=`UNKNOWN_VALUE`,e.value=n,e}else if(e.event===`unknown_option`){let e=Error(`Unknown option: ${n}`);throw e.name=`UNKNOWN_OPTION`,e.optionName=n,e}}let i;r.has(e.name)?i=r.get(e.name):(i=S.create(e.def),r.set(e.name,i)),e.name===`_unknown`?i.set(n):i.set(e.value)}return r.toObject({skipUnknown:!t.partial,camelCase:t.camelCase})}t.exports=E})),me=t(((e,t)=>{var n=G(),r=pe();t.exports=class extends n{static get name(){return`ls`}get requiresFilesystem(){return!0}run(){let e=this.arguments.filter(e=>e!==`-1`),t=e.length!==this.arguments.length,n;try{n=this.parseArgs(e)}catch(e){return this.printHelp(e),Promise.reject()}if(n.one=n.one||t,n.help)return this.printHelp(),Promise.resolve();let r=this.fs.getFileByPath(n.path);if(!r){let e=this.fs.exists(n.path)?`Permission denied`:`No such file or directory`;return Promise.reject(`${n.path}: ${e}`)}if(r.constructor===Object){let e=r;n.all||(e=Object.entries(e).reduce((e,[t,n])=>(t.startsWith(`.`)||(e[t]=n),e),{}));let t=this.fs.absolutePath(n.path);return n.long?this.printLong(e,t):n.one?Object.entries(e).forEach(([e,t])=>{this.stdOut=this._applyIndicator(e,t,n.classify)}):this.printSimple(e,n.classify),n.recursive&&Object.entries(e).forEach(([e,r])=>{if(r&&r.constructor===Object){let r=t.endsWith(`/`)?t+e:t+`/`+e;this.stdOut=``,this.stdOut=r+`:`,this.run.call(Object.create(this,{arguments:{value:[...this.arguments.filter(e=>e!==n.path&&e!==`./`),r]}}))}}),Promise.resolve()}return Promise.resolve(n.path)}printHelp(e){e&&(this.stdOut=e.message),this.stdOut=`usage: ls [-alRF1h] [file ...]`}printSimple(e,t){this.stdOut=Object.entries(e).reduce((e,[n,r])=>e+this.padString(this._applyIndicator(n,r,t)),``)}printLong(e,t){let n=t.endsWith(`/`)?t.slice(0,-1):t;Object.entries(e).forEach(([e,t])=>{let r=n+`/`+e,i=t!=null&&t.constructor===Object,a=this.fs.getMode(r),o=a===null?i?493:420:a,s=this._modeToString(o,i),c=this.fs.getSize(r);return this.stdOut=`${s} root users ${this.padString(c,10)} ${e}`})}_applyIndicator(e,t,n){return n?t&&t.constructor===Object?e+`/`:typeof t==`function`||this.fs.isExecutable(e)?e+`*`:e:e}_modeToString(e,t){return(t?`d`:`-`)+(e&256?`r`:`-`)+(e&128?`w`:`-`)+(e&64?`x`:`-`)+(e&32?`r`:`-`)+(e&16?`w`:`-`)+(e&8?`x`:`-`)+(e&4?`r`:`-`)+(e&2?`w`:`-`)+(e&1?`x`:`-`)}padString(e,t=16){let n=t-e.toString().length,r=``;for(let e=0;e<n;e++)r+=` `;return e.toString()+r}parseArgs(e=this.arguments){return r([{name:`path`,defaultOption:!0,defaultValue:`./`,type:String},{name:`all`,alias:`a`,type:Boolean},{name:`long`,alias:`l`,type:Boolean},{name:`recursive`,alias:`R`,type:Boolean},{name:`one`,type:Boolean},{name:`classify`,alias:`F`,type:Boolean},{name:`help`,alias:`h`,type:Boolean}],{argv:e})}}})),Z=t(((e,t)=>{var n=G();t.exports=class extends n{static get name(){return`echo`}run(){let e=[...this.arguments],t=!1,n=!1;for(;e.length>0&&/^-[neE]+$/.test(e[0]);){let r=e.shift();r.includes(`n`)&&(t=!0),r.includes(`e`)&&(n=!0),r===`-E`&&(n=!1)}let r=e.join(` `);return n&&(r=r.replace(/\\c.*$/s,()=>(t=!0,``)).replace(/\\0([0-7]{1,3})/g,(e,t)=>String.fromCharCode(parseInt(t,8))).replace(/\\x([0-9a-fA-F]{1,2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/\\n/g,`
13
13
  `).replace(/\\t/g,` `).replace(/\\r/g,`\r`).replace(/\\a/g,`\x07`).replace(/\\b/g,`\b`).replace(/\\e/g,`\x1B`).replace(/\\f/g,`\f`).replace(/\\v/g,`\v`).replace(/\\\\/g,`\\`)),t?(r.split(/\r?\n/).forEach(e=>this.stdOut=e),Promise.resolve()):Promise.resolve(r)}}})),he=t(((e,t)=>{var n=G();t.exports=class extends n{static get name(){return`printf`}run(){let e=[...this.arguments];if(!e.length)return Promise.resolve();let t=e.shift();t=t.replace(/\\n/g,`
@@ -22,7 +22,7 @@
22
22
  `+t.prev+t.base;return n+C.call(e,`,`+n)+`
23
23
  `+t.prev}function be(e,t){var n=H(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=Y(e,i)?t(e[i],e):``}var a=typeof D==`function`?D(e):[],o;if(k){o={};for(var s=0;s<a.length;s++)o[`$`+a[s]]=a[s]}for(var c in e)Y(e,c)&&(n&&String(Number(c))===c&&c<e.length||k&&o[`$`+c]instanceof Symbol||(x.call(/[^\w$]/,c)?r.push(t(c,e)+`: `+t(e[c],e)):r.push(c+`: `+t(e[c],e))));if(typeof D==`function`)for(var l=0;l<a.length;l++)j.call(e,a[l])&&r.push(`[`+t(a[l])+`]: `+t(e[a[l]],e));return r}})),Ft=t(((e,t)=>{t.exports=function(e){return typeof e==`string`||typeof e==`symbol`}})),It=t(((e,t)=>{t.exports=function(e){return!!e&&(typeof e==`function`||typeof e==`object`)}})),Lt=t(((e,t)=>{var n=Q(),r=Pt(),i=Ft(),a=It();t.exports=function(e,t){if(!a(e))throw new n(`Assertion failed: Type(O) is not Object`);if(!i(t))throw new n(`Assertion failed: P is not a Property Key, got `+r(t));return e[t]}})),Rt=t(((e,t)=>{var n=Q(),r=Pt(),i=Ft();t.exports=function(e,t){if(!i(t))throw new n(`Assertion failed: P is not a Property Key, got `+r(t));return e[t]}})),zt=t(((e,t)=>{var n=Function.prototype.toString,r=typeof Reflect==`object`&&Reflect!==null&&Reflect.apply,i,a;if(typeof r==`function`&&typeof Object.defineProperty==`function`)try{i=Object.defineProperty({},"length",{get:function(){throw a}}),a={},r(function(){throw 42},null,i)}catch(e){e!==a&&(r=null)}else r=null;var o=/^\s*class\b/,s=function(e){try{var t=n.call(e);return o.test(t)}catch{return!1}},c=function(e){try{return s(e)?!1:(n.call(e),!0)}catch{return!1}},l=Object.prototype.toString,u=`[object Object]`,d=`[object Function]`,f=`[object GeneratorFunction]`,p=`[object HTMLAllCollection]`,m=`[object HTML document.all class]`,h=`[object HTMLCollection]`,g=typeof Symbol==`function`&&!!Symbol.toStringTag,_=!(0 in[,]),v=function(){return!1};if(typeof document==`object`){var y=document.all;l.call(y)===l.call(document.all)&&(v=function(e){if((_||!e)&&(e===void 0||typeof e==`object`))try{var t=l.call(e);return(t===p||t===m||t===h||t===u)&&e(``)==null}catch{}return!1})}t.exports=r?function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;try{r(e,null,i)}catch(e){if(e!==a)return!1}return!s(e)&&c(e)}:function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;if(g)return c(e);if(s(e))return!1;var t=l.call(e);return t!==d&&t!==f&&!/^\[object HTML/.test(t)?!1:c(e)}})),Bt=t(((e,t)=>{t.exports=zt()})),Vt=t(((e,t)=>{var n=Q(),r=Rt(),i=Bt(),a=Ft(),o=Pt();t.exports=function(e,t){if(!a(t))throw new n(`Assertion failed: P is not a Property Key`);var s=r(e,t);if(s!=null){if(!i(s))throw new n(o(t)+` is not a function: `+o(s));return s}}})),Ht=t(((e,t)=>{var n=ot();t.exports=function(){return n()&&!!Symbol.toStringTag}})),Ut=t(((e,t)=>{var n=kt(),r=Ht()(),i=yt(),a=it(),o;if(r){var s=n(`RegExp.prototype.exec`),c={},l=function(){throw c},u={toString:l,valueOf:l};typeof Symbol.toPrimitive==`symbol`&&(u[Symbol.toPrimitive]=l),o=function(e){if(!e||typeof e!=`object`)return!1;var t=a(e,`lastIndex`);if(!(t&&i(t,`value`)))return!1;try{s(e,u)}catch(e){return e===c}}}else{var d=n(`Object.prototype.toString`),f=`[object RegExp]`;o=function(e){return!e||typeof e!=`object`&&typeof e!=`function`?!1:d(e)===f}}t.exports=o})),Wt=t(((e,t)=>{t.exports=function(e){return!!e}})),Gt=t(((e,t)=>{var n=$()(`%Symbol.match%`,!0),r=Ut(),i=It(),a=Wt();t.exports=function(e){if(!i(e))return!1;if(n){var t=e[n];if(t!==void 0)return a(t)}return r(e)}})),Kt=t(((e,t)=>{var n=$()(`%String%`),r=Q();t.exports=function(e){if(typeof e==`symbol`)throw new r(`Cannot convert a Symbol value to a string`);return n(e)}})),qt=t(((e,t)=>{var n=Q();t.exports=function(e){if(e==null)throw new n(arguments.length>0&&arguments[1]||`Cannot call method on `+e);return e}})),Jt=t(((e,t)=>{var n=function(){return typeof function(){}.name==`string`},r=Object.getOwnPropertyDescriptor;if(r)try{r([],`length`)}catch{r=null}n.functionsHaveConfigurableNames=function(){if(!n()||!r)return!1;var e=r(function(){},`name`);return!!e&&!!e.configurable};var i=Function.prototype.bind;n.boundFunctionsHaveNames=function(){return n()&&typeof i==`function`&&function(){}.bind().name!==``},t.exports=n})),Yt=t(((e,t)=>{var n=bt(),r=xt()(),i=Jt().functionsHaveConfigurableNames(),a=Q();t.exports=function(e,t){if(typeof e!=`function`)throw new a("`fn` is not a function");return(!(arguments.length>2&&arguments[2])||i)&&(r?n(e,`name`,t,!0,!0):n(e,`name`,t)),e}})),Xt=t(((e,t)=>{var n=Yt(),r=Q(),i=Object;t.exports=n(function(){if(this==null||this!==i(this))throw new r(`RegExp.prototype.flags getter called on non-object`);var e=``;return this.hasIndices&&(e+=`d`),this.global&&(e+=`g`),this.ignoreCase&&(e+=`i`),this.multiline&&(e+=`m`),this.dotAll&&(e+=`s`),this.unicode&&(e+=`u`),this.unicodeSets&&(e+=`v`),this.sticky&&(e+=`y`),e},`get flags`,!0)})),Zt=t(((e,t)=>{var n=Xt(),r=Ot().supportsDescriptors,i=Object.getOwnPropertyDescriptor;t.exports=function(){if(r&&/a/gim.flags===`gim`){var e=i(RegExp.prototype,`flags`);if(e&&typeof e.get==`function`&&`dotAll`in RegExp.prototype&&`hasIndices`in RegExp.prototype){var t=``,a={};if(Object.defineProperty(a,"hasIndices",{get:function(){t+=`d`}}),Object.defineProperty(a,"sticky",{get:function(){t+=`y`}}),e.get.call(a),t===`dy`)return e.get}}return n}})),Qt=t(((e,t)=>{var n=Ot().supportsDescriptors,r=Zt(),i=it(),a=Object.defineProperty,o=Ue(),s=vt(),c=/a/;t.exports=function(){if(!n||!s)throw new o(`RegExp.prototype.flags requires a true ES5 environment that supports property descriptors`);var e=r(),t=s(c),l=i(t,`flags`);return(!l||l.get!==e)&&a(t,`flags`,{configurable:!0,enumerable:!1,get:e}),e}})),$t=t(((e,t)=>{var n=Ot(),r=wt(),i=Xt(),a=Zt(),o=Qt(),s=r(a());n(s,{getPolyfill:a,implementation:i,shim:o}),t.exports=s})),en=t(((e,t)=>{t.exports=function(e){return typeof e==`number`&&e>=55296&&e<=56319}})),tn=t(((e,t)=>{t.exports=function(e){return typeof e==`number`&&e>=56320&&e<=57343}})),nn=t(((e,t)=>{var n=$(),r=Q(),i=n(`%String.fromCharCode%`),a=en(),o=tn();t.exports=function(e,t){if(!a(e)||!o(t))throw new r("Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code");return i(e)+i(t)}})),rn=t(((e,t)=>{var n=Q(),r=kt(),i=en(),a=tn(),o=nn(),s=r(`String.prototype.charAt`),c=r(`String.prototype.charCodeAt`);t.exports=function(e,t){if(typeof e!=`string`)throw new n("Assertion failed: `string` must be a String");var r=e.length;if(t<0||t>=r)throw new n("Assertion failed: `position` must be >= 0, and < the length of `string`");var l=c(e,t),u=s(e,t),d=i(l),f=a(l);if(!d&&!f)return{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!1};if(f||t+1===r)return{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!0};var p=c(e,t+1);return a(p)?{"[[CodePoint]]":o(l,p),"[[CodeUnitCount]]":2,"[[IsUnpairedSurrogate]]":!1}:{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!0}}})),an=t(((e,t)=>{var n=tt();t.exports=function(e){return(typeof e==`number`||typeof e==`bigint`)&&!n(e)&&e!==1/0&&e!==-1/0}})),on=t(((e,t)=>{var n=Ye(),r=Xe(),i=tt(),a=an();t.exports=function(e){if(typeof e!=`number`||i(e)||!a(e))return!1;var t=n(e);return r(t)===t}})),sn=t(((e,t)=>{t.exports=2**53-1||9007199254740991})),cn=t(((e,t)=>{var n=rn(),r=Q(),i=on(),a=sn();t.exports=function(e,t,o){if(typeof e!=`string`)throw new r("Assertion failed: `S` must be a String");if(!i(t)||t<0||t>a)throw new r("Assertion failed: `length` must be an integer >= 0 and <= 2**53");if(typeof o!=`boolean`)throw new r("Assertion failed: `unicode` must be a Boolean");if(!o)return t+1;var s=e.length;return t+1>=s?t+1:t+n(e,t)[`[[CodeUnitCount]]`]}})),ln=t(((e,t)=>{var n=Q();t.exports=function(e,t){if(typeof t!=`boolean`)throw new n(`Assertion failed: Type(done) is not Boolean`);return{value:e,done:t}}})),un=t(((e,t)=>{var n=Q(),r=yt(),i={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};t.exports=function(e){if(!e||typeof e!=`object`)return!1;for(var t in e)if(r(e,t)&&!i[t])return!1;var a=r(e,`[[Value]]`)||r(e,`[[Writable]]`),o=r(e,`[[Get]]`)||r(e,`[[Set]]`);if(a&&o)throw new n(`Property Descriptors may not be both accessor and data descriptors`);return!0}})),dn=t(((e,t)=>{var n=xt(),r=at(),i=n.hasArrayLengthDefineBug(),a=i&&At(),o=kt()(`Object.prototype.propertyIsEnumerable`);t.exports=function(e,t,n,s,c,l){if(!r){if(!e(l)||!l[`[[Configurable]]`]||!l[`[[Writable]]`]||c in s&&o(s,c)!==!!l[`[[Enumerable]]`])return!1;var u=l[`[[Value]]`];return s[c]=u,t(s[c],u)}return i&&c===`length`&&`[[Value]]`in l&&a(s)&&s.length!==l[`[[Value]]`]?(s.length=l[`[[Value]]`],s.length===l[`[[Value]]`]):(r(s,c,n(l)),!0)}})),fn=t(((e,t)=>{t.exports=function(e){if(e===void 0)return e;var t={};return`[[Value]]`in e&&(t.value=e[`[[Value]]`]),`[[Writable]]`in e&&(t.writable=!!e[`[[Writable]]`]),`[[Get]]`in e&&(t.get=e[`[[Get]]`]),`[[Set]]`in e&&(t.set=e[`[[Set]]`]),`[[Enumerable]]`in e&&(t.enumerable=!!e[`[[Enumerable]]`]),`[[Configurable]]`in e&&(t.configurable=!!e[`[[Configurable]]`]),t}})),pn=t(((e,t)=>{var n=Q(),r=un(),i=fn();t.exports=function(e){if(e!==void 0&&!r(e))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return i(e)}})),mn=t(((e,t)=>{var n=Q(),r=yt(),i=un();t.exports=function(e){if(e===void 0)return!1;if(!i(e))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return!(!r(e,`[[Value]]`)&&!r(e,`[[Writable]]`))}})),hn=t(((e,t)=>{var n=tt();t.exports=function(e,t){return e===t?e===0?1/e==1/t:!0:n(e)&&n(t)}})),gn=t(((e,t)=>{var n=yt(),r=Q(),i=It(),a=Bt(),o=Wt();t.exports=function(e){if(!i(e))throw new r(`ToPropertyDescriptor requires an object`);var t={};if(n(e,`enumerable`)&&(t[`[[Enumerable]]`]=o(e.enumerable)),n(e,`configurable`)&&(t[`[[Configurable]]`]=o(e.configurable)),n(e,`value`)&&(t[`[[Value]]`]=e.value),n(e,`writable`)&&(t[`[[Writable]]`]=o(e.writable)),n(e,`get`)){var s=e.get;if(s!==void 0&&!a(s))throw new r(`getter must be a function`);t[`[[Get]]`]=s}if(n(e,`set`)){var c=e.set;if(c!==void 0&&!a(c))throw new r(`setter must be a function`);t[`[[Set]]`]=c}if((n(t,`[[Get]]`)||n(t,`[[Set]]`))&&(n(t,`[[Value]]`)||n(t,`[[Writable]]`)))throw new r(`Invalid property descriptor. Cannot both specify accessors and a value or writable attribute`);return t}})),_n=t(((e,t)=>{var n=Q(),r=It(),i=un(),a=dn(),o=pn(),s=mn(),c=Ft(),l=hn(),u=gn();t.exports=function(e,t,d){if(!r(e))throw new n(`Assertion failed: Type(O) is not Object`);if(!c(t))throw new n(`Assertion failed: P is not a Property Key`);var f=i(d)?d:u(d);if(!i(f))throw new n(`Assertion failed: Desc is not a valid Property Descriptor`);return a(s,l,o,e,t,f)}})),vn=t(((e,t)=>{t.exports=function(e){return e===null||typeof e!=`function`&&typeof e!=`object`}})),yn=t(((e,t)=>{var n=$(),r=n(`%Object.preventExtensions%`,!0),i=n(`%Object.isExtensible%`,!0),a=vn();t.exports=r?function(e){return!a(e)&&i(e)}:function(e){return!a(e)}})),bn=t(((e,t)=>{var n=Q(),r=It(),i=_n(),a=yn(),o=Ft();t.exports=function(e,t,s,c){if(!r(e))throw new n("Assertion failed: `homeObject` is not an Object");if(!o(t))throw new n("Assertion failed: `key` is not a Property Key or a Private Name");if(typeof s!=`function`)throw new n("Assertion failed: `closure` is not a function");if(typeof c!=`boolean`)throw new n("Assertion failed: `enumerable` is not a Boolean");if(!a(e))throw new n("Assertion failed: `homeObject` is not an ordinary, extensible object, with no non-configurable properties");i(e,t,{"[[Value]]":s,"[[Writable]]":!0,"[[Enumerable]]":c,"[[Configurable]]":!0})}})),xn=t(((e,t)=>{t.exports=function(e,t){for(var n=0;n<e.length;n+=1)t(e[n],n,e)}})),Sn=t(((e,t)=>{var n=Pt(),r=Q(),i=function(e,t,n){for(var r=e,i;(i=r.next)!=null;r=i)if(i.key===t)return r.next=i.next,n||(i.next=e.next,e.next=i),i},a=function(e,t){if(e){var n=i(e,t);return n&&n.value}},o=function(e,t,n){var r=i(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}},s=function(e,t){return e?!!i(e,t):!1},c=function(e,t){if(e)return i(e,t,!0)};t.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new r(`Side channel does not contain `+n(e))},delete:function(t){var n=c(e,t);return n&&e&&!e.next&&(e=void 0),!!n},get:function(t){return a(e,t)},has:function(t){return s(e,t)},set:function(t,n){e||={next:void 0},o(e,t,n)}};return t}})),Cn=t(((e,t)=>{var n=$(),r=kt(),i=Pt(),a=Q(),o=n(`%Map%`,!0),s=r(`Map.prototype.get`,!0),c=r(`Map.prototype.set`,!0),l=r(`Map.prototype.has`,!0),u=r(`Map.prototype.delete`,!0),d=r(`Map.prototype.size`,!0);t.exports=!!o&&function(){var e,t={assert:function(e){if(!t.has(e))throw new a(`Side channel does not contain `+i(e))},delete:function(t){if(e){var n=u(e,t);return d(e)===0&&(e=void 0),n}return!1},get:function(t){if(e)return s(e,t)},has:function(t){return e?l(e,t):!1},set:function(t,n){e||=new o,c(e,t,n)}};return t}})),wn=t(((e,t)=>{var n=$(),r=kt(),i=Pt(),a=Cn(),o=Q(),s=n(`%WeakMap%`,!0),c=r(`WeakMap.prototype.get`,!0),l=r(`WeakMap.prototype.set`,!0),u=r(`WeakMap.prototype.has`,!0),d=r(`WeakMap.prototype.delete`,!0);t.exports=s?function(){var e,t,n={assert:function(e){if(!n.has(e))throw new o(`Side channel does not contain `+i(e))},delete:function(n){if(s&&n&&(typeof n==`object`||typeof n==`function`)){if(e)return d(e,n)}else if(a&&t)return t.delete(n);return!1},get:function(n){return s&&n&&(typeof n==`object`||typeof n==`function`)&&e?c(e,n):t&&t.get(n)},has:function(n){return s&&n&&(typeof n==`object`||typeof n==`function`)&&e?u(e,n):!!t&&t.has(n)},set:function(n,r){s&&n&&(typeof n==`object`||typeof n==`function`)?(e||=new s,l(e,n,r)):a&&(t||=a(),t.set(n,r))}};return n}:a})),Tn=t(((e,t)=>{var n=Q(),r=Pt(),i=Sn(),a=Cn(),o=wn()||a||i;t.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new n(`Side channel does not contain `+r(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,n){e||=o(),e.set(t,n)}};return t}})),En=t(((e,t)=>{var n=yt(),r=Tn()(),i=Q(),a={assert:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");if(r.assert(e),!a.has(e,t))throw new i("`"+t+"` is not present on `O`")},get:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var n=r.get(e);return n&&n[`$`+t]},has:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var a=r.get(e);return!!a&&n(a,`$`+t)},set:function(e,t,n){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var a=r.get(e);a||(a={},r.set(e,a)),a[`$`+t]=n}};Object.freeze&&Object.freeze(a),t.exports=a})),Dn=t(((e,t)=>{var n={__proto__:null,foo:{}},r={__proto__:n}.foo===n.foo&&!(n instanceof Object);t.exports=function(){return r}})),On=t(((e,t)=>{var n=$()(`%Object.create%`,!0),r=Q(),i=qe(),a=It(),o=jt(),s=xn(),c=En(),l=Dn()();t.exports=function(e){if(e!==null&&!a(e))throw new r("Assertion failed: `proto` must be null or an object");var t=arguments.length<2?[]:arguments[1];if(!o(t))throw new r("Assertion failed: `additionalInternalSlotsList` must be an Array");var u;if(l)u={__proto__:e};else if(n)u=n(e);else{if(e===null)throw new i(`native Object.create support is required to create null objects`);var d=function(){};d.prototype=e,u=new d}return t.length>0&&s(t,function(e){c.set(u,e,void 0)}),u}})),kn=t(((e,t)=>{var n=Q(),r=It(),i=kt()(`RegExp.prototype.exec`),a=Mt(),o=Lt(),s=Bt();t.exports=function(e,t){if(!r(e))throw new n("Assertion failed: `R` must be an Object");if(typeof t!=`string`)throw new n("Assertion failed: `S` must be a String");var c=o(e,`exec`);if(s(c)){var l=a(c,e,[t]);if(l===null||r(l))return l;throw new n('"exec" method must return `null` or an Object')}return i(e,t)}})),An=t(((e,t)=>{var n=Q(),r=It(),i=Ft(),a=hn(),o=function(){try{return delete 0,!0}catch{return!1}}();t.exports=function(e,t,s,c){if(!r(e))throw new n("Assertion failed: `O` must be an Object");if(!i(t))throw new n("Assertion failed: `P` must be a Property Key");if(typeof c!=`boolean`)throw new n("Assertion failed: `Throw` must be a Boolean");if(c){if(e[t]=s,o&&!a(e[t],s))throw new n(`Attempted to assign to readonly property.`);return!0}try{return e[t]=s,o?a(e[t],s):!0}catch{return!1}}})),jn=t(((e,t)=>{t.exports=function(e){return e===null||typeof e!=`function`&&typeof e!=`object`}})),Mn=t(((e,t)=>{var n=kt(),r=n(`Date.prototype.getDay`),i=function(e){try{return r(e),!0}catch{return!1}},a=n(`Object.prototype.toString`),o=`[object Date]`,s=Ht()();t.exports=function(e){return typeof e!=`object`||!e?!1:s?i(e):a(e)===o}})),Nn=t(((e,t)=>{var n=kt(),r=Ut(),i=n(`RegExp.prototype.exec`),a=Q();t.exports=function(e){if(!r(e))throw new a("`regex` must be a RegExp");return function(t){return i(e,t)!==null}}})),Pn=t(((e,t)=>{var n=kt(),r=n(`Object.prototype.toString`),i=st()(),a=Nn();if(i){var o=n(`Symbol.prototype.toString`),s=a(/^Symbol\(.*\)$/),c=function(e){return typeof e.valueOf()==`symbol`?s(o(e)):!1};t.exports=function(e){if(typeof e==`symbol`)return!0;if(!e||typeof e!=`object`||r(e)!==`[object Symbol]`)return!1;try{return c(e)}catch{return!1}}}else t.exports=function(e){return!1}})),Fn=t(((e,t)=>{var n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`,r=jn(),i=zt(),a=Mn(),o=Pn(),s=function(e,t){if(e==null)throw TypeError(`Cannot call method on `+e);if(typeof t!=`string`||t!==`number`&&t!==`string`)throw TypeError(`hint must be "string" or "number"`);var n=t===`string`?[`toString`,`valueOf`]:[`valueOf`,`toString`],a,o,s;for(s=0;s<n.length;++s)if(a=e[n[s]],i(a)&&(o=a.call(e),r(o)))return o;throw TypeError(`No default value`)},c=function(e,t){var n=e[t];if(n!=null){if(!i(n))throw TypeError(n+` returned for property `+String(t)+` of object `+e+` is not a function`);return n}};t.exports=function(e){if(r(e))return e;var t=`default`;arguments.length>1&&(arguments[1]===String?t=`string`:arguments[1]===Number&&(t=`number`));var i;if(n&&(Symbol.toPrimitive?i=c(e,Symbol.toPrimitive):o(e)&&(i=Symbol.prototype.valueOf)),i!==void 0){var l=i.call(e,t);if(r(l))return l;throw TypeError(`unable to convert exotic object to primitive`)}return t===`default`&&(a(e)||o(e))&&(t=`string`),s(e,t===`default`?`number`:t)}})),In=t(((e,t)=>{var n=Fn();t.exports=function(e){return arguments.length>1?n(e,arguments[1]):n(e)}})),Ln=t(((e,t)=>{var n=qt(),r=Kt(),i=kt()(`String.prototype.replace`),a=/^\s$/.test(`᠎`),o=a?/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/:/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/,s=a?/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/:/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/;t.exports=function(){return i(i(r(n(this)),o,``),s,``)}})),Rn=t(((e,t)=>{var n=Ln(),r=`​`,i=`᠎`;t.exports=function(){return String.prototype.trim&&r.trim()===r&&i.trim()===i&&(`_`+i).trim()===`_`+i&&(i+`_`).trim()===i+`_`?String.prototype.trim:n}})),zn=t(((e,t)=>{var n=xt()(),r=bt(),i=Rn();t.exports=function(){var e=i();return String.prototype.trim!==e&&(n?r(String.prototype,`trim`,e,!0):r(String.prototype,`trim`,e)),e}})),Bn=t(((e,t)=>{var n=wt(),r=Ot(),i=qt(),a=Ln(),o=Rn(),s=zn(),c=n(o()),l=function(e){return i(e),c(e)};r(l,{getPolyfill:o,implementation:a,shim:s}),t.exports=l})),Vn=t(((e,t)=>{var n=$(),r=n(`%RegExp%`),i=Q(),a=n(`%parseInt%`),o=kt(),s=Nn(),c=o(`String.prototype.slice`),l=s(/^0b[01]+$/i),u=s(/^0o[0-7]+$/i),d=s(/^[-+]0x[0-9a-f]+$/i),f=s(new r(`[`+[`…`,`​`,`￾`].join(``)+`]`,`g`)),p=Bn();t.exports=function e(t){if(typeof t!=`string`)throw new i("Assertion failed: `argument` is not a String");if(l(t))return+a(c(t,2),2);if(u(t))return+a(c(t,2),8);if(f(t)||d(t))return NaN;var n=p(t);return n===t?+t:e(n)}})),Hn=t(((e,t)=>{var n=$(),r=Q(),i=n(`%Number%`),a=vn(),o=In(),s=Vn();t.exports=function(e){var t=a(e)?e:o(e,i);if(typeof t==`symbol`)throw new r(`Cannot convert a Symbol value to a number`);if(typeof t==`bigint`)throw new r(`Conversion from 'BigInt' to 'number' is not allowed.`);return typeof t==`string`?s(t):+t}})),Un=t(((e,t)=>{var n=Xe();t.exports=function(e){return typeof e==`bigint`?e:n(e)}})),Wn=t(((e,t)=>{var n=Un(),r=Q();t.exports=function(e){if(typeof e!=`number`&&typeof e!=`bigint`)throw new r(`argument must be a Number or a BigInt`);var t=e<0?-n(-e):n(e);return t===0?0:t}})),Gn=t(((e,t)=>{var n=Hn(),r=Wn(),i=tt(),a=an();t.exports=function(e){var t=n(e);return i(t)||t===0?0:a(t)?r(t):t}})),Kn=t(((e,t)=>{var n=sn(),r=Gn();t.exports=function(e){var t=r(e);return t<=0?0:t>n?n:t}})),qn=t(((e,t)=>{var n=$()(`%Object.defineProperty%`,!0),r=Ht()(),i=yt(),a=Q(),o=r?Symbol.toStringTag:null;t.exports=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,s=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(r!==void 0&&typeof r!=`boolean`||s!==void 0&&typeof s!=`boolean`)throw new a("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");o&&(r||!i(e,o))&&(n?n(e,o,{configurable:!s,enumerable:!1,value:t,writable:!1}):e[o]=t)}})),Jn=t(((e,t)=>{var n=$(),r=st()(),i=Q(),a=It(),o=n(`%IteratorPrototype%`,!0),s=cn(),c=ln(),l=bn(),u=Lt(),d=On(),f=kn(),p=An(),m=Kn(),h=Kt(),g=En(),_=qn(),v=function(e,t,n,r){if(typeof t!=`string`)throw new i("`S` must be a string");if(typeof n!=`boolean`)throw new i("`global` must be a boolean");if(typeof r!=`boolean`)throw new i("`fullUnicode` must be a boolean");g.set(this,`[[IteratingRegExp]]`,e),g.set(this,`[[IteratedString]]`,t),g.set(this,`[[Global]]`,n),g.set(this,`[[Unicode]]`,r),g.set(this,`[[Done]]`,!1)};o&&(v.prototype=d(o)),l(v.prototype,`next`,function(){var e=this;if(!a(e))throw new i(`receiver must be an object`);if(!(e instanceof v)||!g.has(e,`[[IteratingRegExp]]`)||!g.has(e,`[[IteratedString]]`)||!g.has(e,`[[Global]]`)||!g.has(e,`[[Unicode]]`)||!g.has(e,`[[Done]]`))throw new i(`"this" value must be a RegExpStringIterator instance`);if(g.get(e,`[[Done]]`))return c(void 0,!0);var t=g.get(e,`[[IteratingRegExp]]`),n=g.get(e,`[[IteratedString]]`),r=g.get(e,`[[Global]]`),o=g.get(e,`[[Unicode]]`),l=f(t,n);return l===null?(g.set(e,`[[Done]]`,!0),c(void 0,!0)):r?(h(u(l,`0`))===``&&p(t,`lastIndex`,s(n,m(u(t,`lastIndex`)),o),!0),c(l,!1)):(g.set(e,`[[Done]]`,!0),c(l,!1))},!1),r&&(_(v.prototype,`RegExp String Iterator`),Symbol.iterator&&typeof v.prototype[Symbol.iterator]!=`function`&&l(v.prototype,Symbol.iterator,function(){return this},!1)),t.exports=function(e,t,n,r){return new v(e,t,n,r)}})),Yn=t(((e,t)=>{t.exports=$()})),Xn=t(((e,t)=>{var n=Yn()(`%Reflect.construct%`,!0),r=_n();try{r({},``,{"[[Get]]":function(){}})}catch{r=null}if(r&&n){var i={},a={};r(a,`length`,{"[[Get]]":function(){throw i},"[[Enumerable]]":!0}),t.exports=function(e){try{n(e,a)}catch(e){return e===i}}}else t.exports=function(e){return typeof e==`function`&&!!e.prototype}})),Zn=t(((e,t)=>{var n=$()(`%Symbol.species%`,!0),r=Q(),i=It(),a=Xn();t.exports=function(e,t){if(!i(e))throw new r(`Assertion failed: Type(O) is not Object`);var o=e.constructor;if(o===void 0)return t;if(!i(o))throw new r(`O.constructor is not an Object`);var s=n?o[n]:void 0;if(s==null)return t;if(a(s))return s;throw new r(`no constructor found`)}})),Qn=t(((e,t)=>{var n=It();t.exports=function(e){if(e===null)return`Null`;if(e===void 0)return`Undefined`;if(n(e))return`Object`;if(typeof e==`number`)return`Number`;if(typeof e==`boolean`)return`Boolean`;if(typeof e==`string`)return`String`}})),$n=t(((e,t)=>{var n=Qn();t.exports=function(e){return typeof e==`symbol`?`Symbol`:typeof e==`bigint`?`BigInt`:n(e)}})),er=t(((e,t)=>{var n=Jn(),r=Lt(),i=An(),a=Zn(),o=Kn(),s=Kt(),c=$n(),l=$t(),u=Yt(),d=kt(),f=$(),p=Q(),m=d(`String.prototype.indexOf`),h=f(`%RegExp%`),g=`flags`in h.prototype,_=function(e,t){var n,i=`flags`in t?r(t,`flags`):s(l(t));return n=g&&typeof i==`string`?new e(t,i):e===h?new e(t.source,i):new e(t,i),{flags:i,matcher:n}};t.exports=u(function(e){var t=this;if(c(t)!==`Object`)throw new p(`"this" value must be an Object`);var l=s(e),u=_(a(t,h),t),d=u.flags,f=u.matcher;return i(f,`lastIndex`,o(r(t,`lastIndex`)),!0),n(f,l,m(d,`g`)>-1,m(d,`u`)>-1)},`[Symbol.matchAll]`,!0)})),tr=t(((e,t)=>{var n=st()(),r=er();t.exports=function(){return!n||typeof Symbol.matchAll!=`symbol`||typeof RegExp.prototype[Symbol.matchAll]!=`function`?r:RegExp.prototype[Symbol.matchAll]}})),nr=t(((e,t)=>{var n=Mt(),r=Lt(),i=Vt(),a=Gt(),o=Kt(),s=qt(),c=kt(),l=st()(),u=$t(),d=$(),f=Q(),p=d(`%RegExp%`),m=c(`String.prototype.indexOf`),h=tr(),g=function(e){var t=h();if(l&&typeof Symbol.matchAll==`symbol`){var n=i(e,Symbol.matchAll);return n===p.prototype[Symbol.matchAll]&&n!==t?t:n}if(a(e))return t};t.exports=function(e){var t=s(this);if(e!=null){if(a(e)){var i=`flags`in e?r(e,`flags`):u(e);if(s(i),m(o(i),`g`)<0)throw new f(`matchAll requires a global regular expression`)}var c=g(e);if(c!==void 0)return n(c,e,[t])}var l=o(t),d=new p(e,`g`);return n(g(d),d,[l])}})),rr=t(((e,t)=>{var n=nr();t.exports=function(){if(String.prototype.matchAll)try{``.matchAll(RegExp.prototype)}catch{return String.prototype.matchAll}return n}})),ir=t(((e,t)=>{var n=Ot(),r=st()(),i=it(),a=rr(),o=tr(),s=Object.defineProperty;t.exports=function(){var e=a();if(n(String.prototype,{matchAll:e},{matchAll:function(){return String.prototype.matchAll!==e}}),r){var t=Symbol.matchAll||(Symbol.for?Symbol.for(`Symbol.matchAll`):Symbol(`Symbol.matchAll`));if(n(Symbol,{matchAll:t},{matchAll:function(){return Symbol.matchAll!==t}}),s&&i){var c=i(Symbol,t);(!c||c.configurable)&&s(Symbol,t,{configurable:!1,enumerable:!1,value:t,writable:!1})}var l=o(),u={};u[t]=l;var d={};d[t]=function(){return RegExp.prototype[t]!==l},n(RegExp.prototype,u,d)}return e}})),ar=t(((e,t)=>{var n=wt(),r=Ot(),i=nr(),a=rr(),o=ir(),s=n(i);r(s,{getPolyfill:a,implementation:i,shim:o}),t.exports=s})),or=t(((e,t)=>{var n=ee(),{createGenericWasmCommand:r}=ie(),i=`\x1B[2J\x1B[H`,a=`\x1B[0m`,o=`\x1B[7m`,s=`\x1B[1m`,c=`\x1B[2m`,l=`\x1B[36m`,u=`\x1B[31m`,d=`\x1B[32m`,f=class extends n{get requiresFilesystem(){return!0}get interactive(){return this.shouldBeInteractive()}get captureInput(){return this.shouldBeInteractive()}shouldBeInteractive(){return!!this._dynamicReplActive}getReplTitle(){return this._dynamicReplOpts&&this._dynamicReplOpts.title||`${this.name} interactive shell`}getReplPrompt(){return this._dynamicReplMultiline&&this._dynamicReplOpts&&this._dynamicReplOpts.continuePrompt?this._dynamicReplOpts.continuePrompt:this._dynamicReplOpts&&this._dynamicReplOpts.prompt||`${this.name}> `}getReplWelcome(){return this._dynamicReplOpts&&this._dynamicReplOpts.banner||[`Welcome to ${this.name}. Type .exit or Ctrl+D to quit.`]}async initRepl(){}async evaluateReplLine(e){if(this._dynamicReplOpts&&typeof this._dynamicReplOpts.onEvaluate==`function`){let t=await this._dynamicReplOpts.onEvaluate(e);return{output:Array.isArray(t)?t:t==null?[]:[String(t)]}}return{output:[]}}async cleanupRepl(){this._dynamicReplOpts&&typeof this._dynamicReplOpts.onClose==`function`&&await this._dynamicReplOpts.onClose()}async runNonInteractive(){}startRepl(e={}){return this._dynamicReplActive=!0,this._dynamicReplOpts=e,this._dynamicReplBuffer=``,this._dynamicReplMultiline=!1,typeof this._enterAltScreen==`function`&&this._enterAltScreen(),this._launchInteractiveReplLoop()}run(){return this.shouldBeInteractive()?this._launchInteractiveReplLoop():Promise.resolve(this.runNonInteractive())}_launchInteractiveReplLoop(){return this._replHistory=[],this._replHistoryIdx=null,this._replInput=``,this._replCursor=0,this._replLog=[],this._replBusy=!0,this._replStatus=`Initializing WASM runtime...`,this._scrollOffset=0,this._renderRepl(),new Promise(e=>{this._replResolve=e,Promise.resolve().then(()=>this.initRepl()).then(()=>{this._replBusy=!1,this._replStatus=`^D / .exit: Quit | ^L: Clear | Up/Down: History`;for(let e of this.getReplWelcome())this._appendReplLog(e,`info`);this._renderRepl()}).catch(e=>{this._replBusy=!1,this.stdErr=e.message||String(e),this.exitCode=1,this._exitRepl()})})}_appendReplLog(e,t=`out`){let n=String(e??``).split(/\r?\n/);for(let e of n)this._replLog.push({text:e,type:t});this._scrollOffset=0}streamReplChunk(e,t=`out`){if(!e)return;(this._replLog.length===0||this._replLog[this._replLog.length-1].type!==t||!this._replStreamingActive)&&(this._replLog.push({text:``,type:t}),this._replStreamingActive=!0);let n=this._replLog[this._replLog.length-1],r=(n.text+e).split(/\r?\n/);n.text=r[0];for(let e=1;e<r.length;e++)this._replLog.push({text:r[e],type:t});this._scrollOffset=0,this._renderRepl()}onInput(e){if(this.shouldBeInteractive()){if(e===`^D`||e===`^X`){this._exitRepl();return}if(e===`^C`){this._replInput.length>0||this._dynamicReplBuffer?(this._appendReplLog(`${this.getReplPrompt()}${this._replInput}^C`,`prompt`),this._replInput=``,this._replCursor=0,this._dynamicReplBuffer=``,this._dynamicReplMultiline=!1,this._renderRepl()):this._exitRepl();return}if(!this._replBusy){if(e===`^L`){this._replLog=[],this._scrollOffset=0,this._renderRepl();return}if(e===`Enter`){let e=this._replInput;this._replInput=``,this._replCursor=0,this._replHistoryIdx=null,e.trim()&&this._replHistory.push(e),this._appendReplLog(`${this.getReplPrompt()}${e}`,`prompt`);let t=e.trim();if(this._dynamicReplOpts&&typeof this._dynamicReplOpts.isExitCommand==`function`&&this._dynamicReplOpts.isExitCommand(t)||t===`.exit`||t===`.quit`||t===`\\q`||t===`exit`||t===`quit`||t===`exit()`||t===`quit()`){this._exitRepl();return}if(t===`.clear`||t===`\\! clear`){this._replLog=[],this._renderRepl();return}if(this._dynamicReplOpts&&typeof this._dynamicReplOpts.needsMoreInput==`function`&&(this._dynamicReplBuffer=this._dynamicReplBuffer?`${this._dynamicReplBuffer}\n${e}`:e,this._dynamicReplOpts.needsMoreInput(this._dynamicReplBuffer))){this._dynamicReplMultiline=!0,this._renderRepl();return}let n=this._dynamicReplBuffer||e;this._dynamicReplBuffer=``,this._dynamicReplMultiline=!1,this._replBusy=!0,this._replStatus=`Running...`,this._renderRepl(),Promise.resolve().then(()=>this.evaluateReplLine(n)).then(e=>{if(this._replBusy=!1,this._replStreamingActive=!1,this._replStatus=`^D / .exit: Quit | ^L: Clear | Up/Down: History`,e){if(e.clear&&(this._replLog=[]),!e.streamed)if(Array.isArray(e.output))for(let t of e.output)this._appendReplLog(t,`out`);else typeof e.output==`string`&&e.output.length>0&&this._appendReplLog(e.output,`out`);if(e.error&&this._appendReplLog(e.error,`err`),e.exit){this._exitRepl();return}}this._renderRepl()}).catch(e=>{this._replBusy=!1,this._replStatus=`^D / .exit: Quit | ^L: Clear | Up/Down: History`,this._appendReplLog(`Error: ${e.message||e}`,`err`),this._renderRepl()});return}if(e===`Backspace`){this._replCursor>0&&(this._replInput=this._replInput.slice(0,this._replCursor-1)+this._replInput.slice(this._replCursor),this._replCursor--,this._renderRepl());return}if(e===`^W`){let e=this._replCursor;for(;e>0&&this._replInput[e-1]===` `;)e--;for(;e>0&&this._replInput[e-1]!==` `;)e--;this._replInput=this._replInput.slice(0,e)+this._replInput.slice(this._replCursor),this._replCursor=e,this._renderRepl();return}if(e===`Delete`){this._replCursor<this._replInput.length&&(this._replInput=this._replInput.slice(0,this._replCursor)+this._replInput.slice(this._replCursor+1),this._renderRepl());return}if(e===`ArrowLeft`){this._replCursor>0&&(this._replCursor--,this._renderRepl());return}if(e===`ArrowRight`){this._replCursor<this._replInput.length&&(this._replCursor++,this._renderRepl());return}if(e===`Home`||e===`^A`){this._replCursor=0,this._renderRepl();return}if(e===`End`||e===`^E`){this._replCursor=this._replInput.length,this._renderRepl();return}if(e===`ArrowUp`){if(this._replHistory.length===0)return;this._replHistoryIdx===null?this._replHistoryIdx=this._replHistory.length-1:this._replHistoryIdx>0&&this._replHistoryIdx--,this._replInput=this._replHistory[this._replHistoryIdx],this._replCursor=this._replInput.length,this._renderRepl();return}if(e===`ArrowDown`){if(this._replHistoryIdx===null)return;this._replHistoryIdx<this._replHistory.length-1?(this._replHistoryIdx++,this._replInput=this._replHistory[this._replHistoryIdx]):(this._replHistoryIdx=null,this._replInput=``),this._replCursor=this._replInput.length,this._renderRepl();return}if(e===`PageUp`){let e=Math.max(0,this._replLog.length-5);this._scrollOffset=Math.min(e,this._scrollOffset+5),this._renderRepl();return}if(e===`PageDown`){this._scrollOffset=Math.max(0,this._scrollOffset-5),this._renderRepl();return}e.length===1&&!e.startsWith(`^`)&&(this._replInput=this._replInput.slice(0,this._replCursor)+e+this._replInput.slice(this._replCursor),this._replCursor++,this._renderRepl())}}}_renderRepl(){let{cols:e,rows:t}=this.terminalSize,n=Math.max(3,t-3),r=`${o}${s}${` ${this.getReplTitle()} `.padEnd(e).slice(0,e)}${a}`,f=this._replLog.length,p=Math.max(0,f-this._scrollOffset),m=Math.max(0,p-n),h=this._replLog.slice(m,p),g=[];for(let e=0;e<n;e++){let t=h[e];if(!t){g.push(``);continue}t.type===`prompt`?g.push(`${l}${t.text}${a}`):t.type===`err`?g.push(`${u}${t.text}${a}`):t.type===`info`?g.push(`${c}${t.text}${a}`):g.push(t.text)}let _=this.getReplPrompt(),v=this._replInput.slice(0,this._replCursor),y=this._replCursor<this._replInput.length?this._replInput[this._replCursor]:` `,b=this._replCursor<this._replInput.length?this._replInput.slice(this._replCursor+1):``,x=this._replBusy?`${c}${this._replStatus}${a}`:`${d}${s}${_}${a}${v}${o}${y}${a}${b}`,S=`${o}${` ${this._replStatus} `.padEnd(e).slice(0,e)}${a}`,C=[i+r,...g,x,S].join(`
24
24
  `);this.stdOut=C,this.flush()}_exitRepl(){Promise.resolve().then(()=>this.cleanupRepl()).catch(()=>{}).finally(()=>{if(this._replResolve){let e=this._replResolve;this._replResolve=null,e()}})}};function p(e,t={},n=null){let i=(n||e.bin||e.name).toLowerCase(),a=r(e,t,i),o=e&&typeof e.repl==`object`?e.repl:{};class s extends f{static get name(){return i}get name(){return i}constructor(e,t){super(e,t),this._sessionArgs=[],this._isInteractiveMode=this._detectInteractiveMode(e||[])}_detectInteractiveMode(e){if(e.includes(`--help`)||e.includes(`-h`)||e.includes(`--version`)||e.includes(`-V`)||e.includes(`-v`))return!1;if(e.length===0)return!0;if(o.sessionArg&&e.length===1&&!e[0].startsWith(`-`)){let t=e[0].trim();if(!/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|PRAGMA|WITH|BEGIN|EXPLAIN|\.)\b/i.test(t))return this._sessionArgs=[e[0]],!0}return!1}shouldBeInteractive(){return this._dynamicReplActive?!0:this.stdin!==void 0&&this.stdin!==null&&String(this.stdin).trim().length>0?!1:this._isInteractiveMode}getReplTitle(){let t=this._sessionArgs.length>0?` — ${this._sessionArgs.join(` `)}`:``;return o.title||`${i} (${e.name} ${e.version||`wasm`})${t}`}getReplPrompt(){return this._dynamicReplMultiline&&o.continuePrompt?o.continuePrompt:o.prompt||`${i}> `}getReplWelcome(){return o.banner||[`${e.name} (${e.version||`wasm`}) interactive shell`,`Type ".exit" or Ctrl+D to quit.`]}async evaluateReplLine(e){let t=o.evalFlag,n=t?[...this._sessionArgs,t,e]:[...this._sessionArgs,e],r=t?void 0:e,{out:i,err:a}=await this._captureBaseWasmOutput(n,r);return{output:i,error:a.length>0?a.join(`
25
- `):void 0}}async runNonInteractive(){await this._delegateToBaseWasm([...this.arguments||[]])}async _delegateToBaseWasm(e){let t=new a(e,this.context);t.fs=this.fs,this.stdin!==void 0&&(t.stdin=this.stdin),await t.run();for(let e of t.result.getStdOutput())e.type===`out`?this.stdOut=e.string:e.type===`err`&&(this.stdErr=e.string);this.exitCode=t.exitCode||t.result.getExitCode()}async _captureBaseWasmOutput(e,t){let n=new a(e,this.context);n.fs=this.fs,t!==void 0&&(n.stdin=t),await n.run();let r=[],i=[];for(let e of n.result.getStdOutput())e.type===`err`?i.push(e.string):r.push(e.string);return{out:r,err:i}}}return s}f.createReplWasmCommand=p,f.createCommand=p,t.exports=f}));return t(((e,t)=>{y();var n=Y(),r=X(),i=re(),a=ie(),o=G(),s=ee(),{TtyStream:c}=W(),l=`/.brsh_history`,u=ye(),d=Ve(),f=V(),p=b(),{isAsyncFilesystemSource:m,resolveFilesystemSource:h}=K(),g=/\$(?:\{([\w\d?#@*-]+)\}|([\w\d]+|[?#@*-]))/g,_=f.EventEmitter||f.default||f;String.prototype.regexIndexOf=function(e,t){let n=this.substring(t||0).search(e);return n>=0?n+(t||0):n},ar().shim();var x=class e extends _{constructor(e){super();let{path:t=`/bin`,profile:r,motd:i,command:a,interactive:o=!0,subshell:s=!1,hostname:l=`browser`,filesystem:u={},permissions:d={},cwd:f=`/`,onFsChange:p,useRealFilesystem:h=!1}=e;if(this.context=new n(Object.assign({},e,{clearFn:this.clear.bind(this),destroyFn:this.destroy.bind(this),onFsChange:typeof p==`function`?p:null})),this._readonlyContext=Object.freeze({getVar:e=>this.context.getVar(e),getAlias:e=>this.context.getAlias(e),getCommand:e=>this.context.getCommand(e)}),this.context.setVar(`PATH`,t),this.context.setVar(`HOST`,l),!s){let e=(o?`i`:``)+(a?`c`:``);e&&this.context.setVar(`-`,e)}if(this._lastCode=0,this._subshell=s,this._useRealFilesystem=h,this._profile=r,this._motd=i,this._initialCommand=a||null,this._suppressMotd=!!a,this._loadingFs=null,this._queuedWhileLoading=!1,this.stdinStream=new c({columns:80,rows:24}),this.stdout=new c({columns:80,rows:24,onWrite:e=>this.emit(`data`,e)}),this.stderr=new c({columns:80,rows:24,onWrite:e=>this.emit(`data`,e)}),this._lineBuffer=[],this._cursorPos=0,this._history=[],this._historyPos=null,this._savedInput=null,this._historyLoaded=!1,this._working=!0,this._promptReady=!1,this._inProgressLine=!1,this._fromLineEditor=!1,this._lastPromptRowOffset=0,this._pendingCommands=[],s||this._setupTtyStreams(),h)this.context.setNodeFilesystem(f),this.context.setCwd(f),this._loadDefaultCommands(),this._loadBuiltinCommands(!0),this.ready=Promise.resolve(this),s?this._initializing=!1:(this._initializing=!0,setTimeout(()=>this._init(),0));else if(m(u)||u&&typeof u==`object`&&m(u.filesystem))this.context.setFilesystem({},d),this._loadDefaultCommands(),this._loadBuiltinCommands(!1),this._initializing=!s,this._loadingFs=this._initAsyncFilesystem(u,d,f,r),this.ready=this._loadingFs;else{this.context.setFilesystem(u,d),this.context.setCwd(f);let e=this.context.fs.exists(this.context.getVar(`PATH`));this._loadDefaultCommands(),this._loadBuiltinCommands(e),this.ready=Promise.resolve(this),s?this._initializing=!1:(this._initializing=!0,setTimeout(()=>this._init(),0))}}async _initAsyncFilesystem(t,n,r){let i=this.context.getVar(`PATH`)||`/bin`,a=()=>{try{let e=this.context.fs.getRaw(),t=i.replace(/^\/+|\/+$/g,``).split(`/`).filter(Boolean),n=e;for(let e of t)n&&=n[e];return n&&typeof n==`object`?Object.assign({},n):{}}catch{return{}}},o=a();try{let e=await h(t,n),s=a(),c=[];for(let[e,t]of Object.entries(s))o[e]!==t&&typeof t==`function`&&c.push(t);let l=this.context._onFsChange;this.context._onFsChange=null,this.context.setFilesystem(e.filesystem,e.permissions);let u=this.context.fs.exists(i);this._loadDefaultCommands(),this._loadBuiltinCommands(u);for(let e of c)this.context.setCommand(e);this.context.setCwd(r),this.context._onFsChange=l,l&&this.context.fs&&(this.context.fs._onChange=()=>l(this.context.fs.getRaw(),this.context.fs.getRawPermissions()))}catch(e){this.emit(`stdErr`,e.message||String(e))}finally{this._loadingFs=null}return this._subshell?(this._initializing=!1,!this._queuedWhileLoading&&!this.destroyed&&this.emit(`status`,e.STATUS_READY)):await this._init(),this}get path(){return this.context.getVar(`PATH`)}set lastCode(e){this.context.setVar(`?`,String(e)),this._lastCode=e}get lastCode(){return this._lastCode}get stdin(){return this._stdin===void 0?this.stdinStream:this._stdin}set stdin(e){this._stdin=e}write(e){return this.stdinStream.pushData(e),!0}resize(e,t){this.setTerminalSize(e,t)}onInput(e){if(this.runningCommand&&this.runningCommand.onInput&&this.runningCommand.captureInput)return this.runningCommand.onInput(e),!0}setTerminalSize(e,t){this._terminalSize={cols:e,rows:t},this.context.setVar(`COLUMNS`,String(e)),this.context.setVar(`LINES`,String(t)),this.stdinStream.resize(e,t),this.stdout.resize(e,t),this.stderr.resize(e,t),this.runningCommand&&(this.runningCommand.stdinStream&&this.runningCommand.stdinStream.resize(e,t),this.runningCommand.stdout&&this.runningCommand.stdout.resize(e,t),this.runningCommand.stderr&&this.runningCommand.stderr.resize(e,t)),this.emit(`resize`,{cols:e,rows:t})}get terminalSize(){return this._terminalSize||{cols:80,rows:24}}_loadDefaultCommands(){d.forEach(e=>{this.context.setCommand(e)})}_loadBuiltinCommands(e=!1){u.forEach(e=>{this.context.setCommand(e)}),e||this.context.fs.setMode(this.context.getVar(`PATH`),365)}suppressMotd(){this._suppressMotd=!0;let e=this.context.getVar(`-`);e.includes(`c`)||this.context.setVar(`-`,e+`c`)}async _init(){try{if(!this._suppressMotd&&!this._initialCommand&&await this._runMotd(),await this._loadProfile(this._profile),this._initialCommand){await this.onCommand(this._initialCommand,!1);let e=this.context.getVar(`-`);e.includes(`c`)&&this.context.setVar(`-`,e.replace(/c/g,``))}}finally{this._initializing=!1,!this._queuedWhileLoading&&!this.destroyed&&this.emit(`status`,e.STATUS_READY)}}_hasHushlogin(){if(this.context.fs.exists(`.hushlogin`))return!0;let e=this.context.getVar(`HOME`);return!!(e&&this.context.fs.exists(`${e.replace(/\/$/,``)}/.hushlogin`))}async _runMotd(){if(!(this._motd===!1||this._hasHushlogin())){if(typeof this._motd==`string`){await this._renderMotdPath(this._motd);return}this._useRealFilesystem||(this.context.fs.exists(`/etc/update-motd.d`)&&await this._runMotdDir(`/etc/update-motd.d`),this.context.fs.exists(`/etc/motd`)&&await this._renderMotdPath(`/etc/motd`))}}async _runMotdDir(e){let t=this.context.fs.getFileByPath(e);if(!t||t.constructor!==Object)return;let n=Object.keys(t).sort(),r=e.endsWith(`/`)?e.slice(0,-1):e;for(let e of n){let t=`${r}/${e}`,n=this.context.fs.stat(t);!n||n.isDirectory||this.context.fs.isExecutable(t)&&await this.onCommand(t,!1)}}async _renderMotdPath(e){if(!this.context.fs.exists(e))return;let t=this.context.fs.stat(e);if(!t)return;if(t.isDirectory){await this._runMotdDir(e);return}let n=this.context.fs.getFileByPath(e);if(n==null)return;if(typeof n==`function`){this.context.fs.isExecutable(e)&&await this.onCommand(e,!1);return}if(typeof n==`string`&&n.startsWith(`#!`)){this.context.fs.isExecutable(e)?await this.onCommand(e,!1):await this.onCommand(`source ${e}`,!1);return}let r=n.toString();r.endsWith(`
25
+ `):void 0}}async runNonInteractive(){await this._delegateToBaseWasm([...this.arguments||[]])}async _delegateToBaseWasm(e){let t=new a(e,this.context);t.fs=this.fs,this.stdin!==void 0&&(t.stdin=this.stdin),await t.run();for(let e of t.result.getStdOutput())e.type===`out`?this.stdOut=e.string:e.type===`err`&&(this.stdErr=e.string);this.exitCode=t.exitCode||t.result.getExitCode()}async _captureBaseWasmOutput(e,t){let n=new a(e,this.context);n.fs=this.fs,t!==void 0&&(n.stdin=t),await n.run();let r=[],i=[];for(let e of n.result.getStdOutput())e.type===`err`?i.push(e.string):r.push(e.string);return{out:r,err:i}}}return s}f.createReplWasmCommand=p,f.createCommand=p,t.exports=f}));return t(((e,t)=>{y();var n=Y(),r=X(),i=re(),a=ie(),o=G(),s=ee(),{TtyStream:c}=W(),l=`/.brsh_history`,u=ye(),d=Ve(),f=V(),p=b(),{isAsyncFilesystemSource:m,resolveFilesystemSource:h}=K(),g=/\$(?:\{([\w\d?#@*-]+)\}|([\w\d]+|[?#@*-]))/g,_=f.EventEmitter||f.default||f;String.prototype.regexIndexOf=function(e,t){let n=this.substring(t||0).search(e);return n>=0?n+(t||0):n},ar().shim();var x=class e extends _{constructor(e){super();let{path:t=`/bin`,profile:r,motd:i,command:a,interactive:o=!0,subshell:s=!1,hostname:l=`browser`,filesystem:u={},permissions:d={},cwd:f=`/`,onFsChange:p,useRealFilesystem:h=!1}=e;if(this.context=new n(Object.assign({},e,{clearFn:this.clear.bind(this),destroyFn:this.destroy.bind(this),onFsChange:typeof p==`function`?p:null})),this._readonlyContext=Object.freeze({getVar:e=>this.context.getVar(e),getAlias:e=>this.context.getAlias(e),getCommand:e=>this.context.getCommand(e)}),this.context.setVar(`PATH`,t),this.context.setVar(`HOST`,l),!s){let e=(o?`i`:``)+(a?`c`:``);e&&this.context.setVar(`-`,e)}if(this._lastCode=0,this._subshell=s,this._useRealFilesystem=h,this._profile=r,this._motd=i,this._initialCommand=a||null,this._suppressMotd=!!a,this._loadingFs=null,this._queuedWhileLoading=!1,this.stdinStream=new c({columns:80,rows:24}),this.stdout=new c({columns:80,rows:24,onWrite:e=>this.emit(`data`,e)}),this.stderr=new c({columns:80,rows:24,onWrite:e=>this.emit(`data`,e)}),this._lineBuffer=[],this._cursorPos=0,this._history=[],this._historyPos=null,this._savedInput=null,this._historyLoaded=!1,this._working=!0,this._promptReady=!1,this._inProgressLine=!1,this._fromLineEditor=!1,this._lastPromptRowOffset=0,this._pendingCommands=[],s||this._setupTtyStreams(),h)this.context.setNodeFilesystem(f),this.context.setCwd(f),this._loadDefaultCommands(),this._loadBuiltinCommands(!0),this.ready=Promise.resolve(this),s?this._initializing=!1:(this._initializing=!0,setTimeout(()=>this._init(),0));else if(m(u)||u&&typeof u==`object`&&m(u.filesystem))this.context.setFilesystem({},d),this._loadDefaultCommands(),this._loadBuiltinCommands(!1),this._initializing=!s,this._loadingFs=this._initAsyncFilesystem(u,d,f,r),this.ready=this._loadingFs;else{this.context.setFilesystem(u,d),this.context.setCwd(f);let e=this.context.fs.exists(this.context.getVar(`PATH`));this._loadDefaultCommands(),this._loadBuiltinCommands(e),this.ready=Promise.resolve(this),s?this._initializing=!1:(this._initializing=!0,setTimeout(()=>this._init(),0))}this.context.fs&&typeof this.context.fs.setTtyDevice==`function`&&this.context.fs.setTtyDevice({write:e=>this.stdout.write(e),read:()=>``})}async _initAsyncFilesystem(t,n,r){let i=this.context.getVar(`PATH`)||`/bin`,a=()=>{try{let e=this.context.fs.getRaw(),t=i.replace(/^\/+|\/+$/g,``).split(`/`).filter(Boolean),n=e;for(let e of t)n&&=n[e];return n&&typeof n==`object`?Object.assign({},n):{}}catch{return{}}},o=a();try{let e=await h(t,n),s=a(),c=[];for(let[e,t]of Object.entries(s))o[e]!==t&&typeof t==`function`&&c.push(t);let l=this.context._onFsChange;this.context._onFsChange=null,this.context.setFilesystem(e.filesystem,e.permissions);let u=this.context.fs.exists(i);this._loadDefaultCommands(),this._loadBuiltinCommands(u);for(let e of c)this.context.setCommand(e);this.context.setCwd(r),this.context._onFsChange=l,l&&this.context.fs&&(this.context.fs._onChange=()=>l(this.context.fs.getRaw(),this.context.fs.getRawPermissions())),this.context.fs&&typeof this.context.fs.setTtyDevice==`function`&&this.context.fs.setTtyDevice({write:e=>this.stdout.write(e),read:()=>``})}catch(e){this.emit(`stdErr`,e.message||String(e))}finally{this._loadingFs=null}return this._subshell?(this._initializing=!1,!this._queuedWhileLoading&&!this.destroyed&&this.emit(`status`,e.STATUS_READY)):await this._init(),this}get path(){return this.context.getVar(`PATH`)}set lastCode(e){this.context.setVar(`?`,String(e)),this._lastCode=e}get lastCode(){return this._lastCode}get stdin(){return this._stdin===void 0?this.stdinStream:this._stdin}set stdin(e){this._stdin=e}write(e){return this.stdinStream.pushData(e),!0}resize(e,t){this.setTerminalSize(e,t)}onInput(e){if(this.runningCommand&&this.runningCommand.onInput&&this.runningCommand.captureInput)return this.runningCommand.onInput(e),!0}setTerminalSize(e,t){this._terminalSize={cols:e,rows:t},this.context.setVar(`COLUMNS`,String(e)),this.context.setVar(`LINES`,String(t)),this.stdinStream.resize(e,t),this.stdout.resize(e,t),this.stderr.resize(e,t),this.runningCommand&&(this.runningCommand.stdinStream&&this.runningCommand.stdinStream.resize(e,t),this.runningCommand.stdout&&this.runningCommand.stdout.resize(e,t),this.runningCommand.stderr&&this.runningCommand.stderr.resize(e,t)),this.emit(`resize`,{cols:e,rows:t})}get terminalSize(){return this._terminalSize||{cols:80,rows:24}}_loadDefaultCommands(){d.forEach(e=>{this.context.setCommand(e)})}_loadBuiltinCommands(e=!1){u.forEach(e=>{this.context.setCommand(e)}),e||this.context.fs.setMode(this.context.getVar(`PATH`),365)}suppressMotd(){this._suppressMotd=!0;let e=this.context.getVar(`-`);e.includes(`c`)||this.context.setVar(`-`,e+`c`)}async _init(){try{if(!this._suppressMotd&&!this._initialCommand&&await this._runMotd(),await this._loadProfile(this._profile),this._initialCommand){await this.onCommand(this._initialCommand,!1);let e=this.context.getVar(`-`);e.includes(`c`)&&this.context.setVar(`-`,e.replace(/c/g,``))}}finally{this._initializing=!1,!this._queuedWhileLoading&&!this.destroyed&&this.emit(`status`,e.STATUS_READY)}}_hasHushlogin(){if(this.context.fs.exists(`.hushlogin`))return!0;let e=this.context.getVar(`HOME`);return!!(e&&this.context.fs.exists(`${e.replace(/\/$/,``)}/.hushlogin`))}async _runMotd(){if(!(this._motd===!1||this._hasHushlogin())){if(typeof this._motd==`string`){await this._renderMotdPath(this._motd);return}this._useRealFilesystem||(this.context.fs.exists(`/etc/update-motd.d`)&&await this._runMotdDir(`/etc/update-motd.d`),this.context.fs.exists(`/etc/motd`)&&await this._renderMotdPath(`/etc/motd`))}}async _runMotdDir(e){let t=this.context.fs.getFileByPath(e);if(!t||t.constructor!==Object)return;let n=Object.keys(t).sort(),r=e.endsWith(`/`)?e.slice(0,-1):e;for(let e of n){let t=`${r}/${e}`,n=this.context.fs.stat(t);!n||n.isDirectory||this.context.fs.isExecutable(t)&&await this.onCommand(t,!1)}}async _renderMotdPath(e){if(!this.context.fs.exists(e))return;let t=this.context.fs.stat(e);if(!t)return;if(t.isDirectory){await this._runMotdDir(e);return}let n=this.context.fs.getFileByPath(e);if(n==null)return;if(typeof n==`function`){this.context.fs.isExecutable(e)&&await this.onCommand(e,!1);return}if(typeof n==`string`&&n.startsWith(`#!`)){this.context.fs.isExecutable(e)?await this.onCommand(e,!1):await this.onCommand(`source ${e}`,!1);return}let r=n.toString();r.endsWith(`
26
26
  `)&&(r=r.slice(0,-1)),r.split(/\r?\n/).forEach(e=>{this.emit(`stdOut`,e)})}async _loadProfile(e){if(!this._useRealFilesystem&&e!==`/etc/profile`&&this.context.fs.exists(`/etc/profile`)){let e=this.context.fs.getFileByPath(`/etc/profile`);typeof e==`string`&&e.startsWith(`#!`)&&await this.onCommand(`source /etc/profile`,!1)}e&&await this.onCommand(`source ${e}`,!1)}onCommand(t,n=!0){n&&!this._subshell&&this._promptReady&&!this._fromLineEditor&&(this.stdout.write(`\r${this.getPrompt()} ${t}\x1b[K\r\n`),this._lineBuffer=[],this._cursorPos=0),this._fromLineEditor=!1;let r=this._splitInput(t),i=this._groupPipes(r),a=!0;this._loadingFs&&n&&(this._queuedWhileLoading=!0);let o=this._loadingFs?Promise.resolve(this._loadingFs):Promise.resolve(),s=i.reduce((e,{commands:t,op:n})=>e.then(()=>{if(!a){n===`&&`?a=this._lastCode===0:n===`||`?a=this._lastCode!==0:n===`;`&&(a=!0);return}return this._runPipeChain(t).then(()=>{n===`&&`?a=this._lastCode===0:n===`||`?a=this._lastCode!==0:n===`;`&&(a=!0)})}),o);return n?s.then(()=>{this.destroyed||this.emit(`status`,e.STATUS_READY)}).catch(()=>this.emit(`status`,e.STATUS_READY)):s}tabCompletion(e){return this.context.fs.autoComplete(e,this.path)}async _runCommand(t){if(!t||t.length<1)return;this._initializing||this.emit(`status`,e.STATUS_WORKING);let n;try{n=await this._parseCommandLine(t)}catch(e){this.emit(`stdErr`,e.message||String(e)),this.lastCode=1,this.emit(`exitCode`,this.lastCode);return}if(!n.length)return;let a=!1;for(;n.length>0&&!n[0].hasQuote&&n[0].value===`!`;)a=!a,n.shift();if(!n.length){this.lastCode=+!!a,this.emit(`exitCode`,this.lastCode);return}let o={type:`stdout`},s={type:`stderr`},c=[];for(let e=0;e<n.length;e++){let{value:t,hasQuote:r}=n[e];if(r){c.push(t);continue}if(t===`2>&1`){s={...o};continue}if(t===`1>&2`){o={...s};continue}if(t===`2>&-`){s={type:`null`};continue}if(t===`1>&-`||t===`>&-`){o={type:`null`};continue}if(t===`&>>`){if(e+1<n.length){let t=n[++e].value,r=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!0};o=r,s=r}continue}if(t===`&>`||t===`>&`){if(e+1<n.length){let t=n[++e].value,r=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!1};o=r,s=r}continue}if(t.startsWith(`&>>`)&&t.length>3){let e=t.slice(3),n=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!0};o=n,s=n;continue}if((t.startsWith(`&>`)||t.startsWith(`>&`))&&t.length>2){let e=t.slice(2),n=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!1};o=n,s=n;continue}if(t===`2>>`){if(e+1<n.length){let t=n[++e].value;s=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!0}}continue}if(t===`2>`){if(e+1<n.length){let t=n[++e].value;s=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!1}}continue}if(t.startsWith(`2>>`)&&t.length>3){let e=t.slice(3);s=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!0};continue}if(t.startsWith(`2>`)&&t.length>2){let e=t.slice(2);s=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!1};continue}if(t===`1>>`||t===`>>`){if(e+1<n.length){let t=n[++e].value;o=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!0}}continue}if(t===`1>`||t===`>`){if(e+1<n.length){let t=n[++e].value;o=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!1}}continue}if((t.startsWith(`1>>`)||t.startsWith(`>>`))&&t.length>(t.startsWith(`1>>`)?3:2)){let e=t.slice(t.startsWith(`1>>`)?3:2);o=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!0};continue}if((t.startsWith(`1>`)||t.startsWith(`>`))&&t.length>(t.startsWith(`1>`)?2:1)){let e=t.slice(t.startsWith(`1>`)?2:1);o=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!1};continue}c.push(t)}if(!c.length){for(let e of[o,s])if(e.type===`file`&&e.file!==`/dev/null`)try{let t=this.context.fs.absolutePath(e.file),n=this.context.fs._getFileRaw(t);(!e.append||n===void 0)&&this.context.fs.setFileByPath(t,n||``,!0)}catch{this.emit(`stdErr`,`${e.file}: Permission denied`),this.lastCode=+!a,this.emit(`exitCode`,this.lastCode);return}this.lastCode=+!!a,this.emit(`exitCode`,this.lastCode);return}let l=c.shift();if(n=c,n.length===0&&/^[A-Za-z_]\w*=/.test(l)){let e=l.indexOf(`=`);this.context.setVar(l.slice(0,e),l.slice(e+1)),this.lastCode=+!!a,this.emit(`exitCode`,this.lastCode);return}let u=this.context.getAlias(l);if(u)return this.onCommand(u,!1).then(()=>{a&&(this.lastCode=+(this.lastCode===0),this.emit(`exitCode`,this.lastCode))});let d;try{d=this._parseCommand(l.startsWith(`/`)||l.startsWith(`./`)?l:l.toLowerCase())}catch(e){this._handleCommandError(e.message,s,a);return}let f=e=>typeof e==`function`&&typeof e.prototype.run==`function`&&typeof e.prototype.runCommand==`function`,p;if(d.prototype instanceof r||new d instanceof i)p=new d(n,this.context);else if(f(d))p=new d(n,this._readonlyContext);else{this._handleCommandError(`${l}: Command not found`,s,a);return}p.requiresFilesystem&&(p.fs=this.context.fs.sandbox()),this._stdin!==void 0&&(p.stdin=this._stdin);let m=new Map,h=({type:e,string:t})=>{let n=e===`out`?o:s;if(n.type===`stdout`)this.emit(`stdOut`,t);else if(n.type===`stderr`)this.emit(`stdErr`,t);else if(n.type===`file`&&n.file!==`/dev/null`){let e=m.get(n.file);e||(e={append:n.append,lines:[]},m.set(n.file,e)),e.lines.push(t)}};return this.runningCommand=p,this.runningCommand.on&&(this.runningCommand.on(`flush`,e=>{e.forEach(h)}),this.runningCommand.on(`stdout`,e=>{o.type===`file`?p._streamedStdout||(p.stdOut=String(e??``)):o.type===`stderr`?this.stderr.write(e):o.type===`null`||(this.stdout.write(e),this.emit(`stdOutRaw`,e))}),this.runningCommand.on(`token`,e=>{this.emit(`token`,e)}),this.runningCommand.on(`stderr`,e=>{s.type===`file`?p.stdErr=String(e??``):s.type===`stdout`?o.type===`file`?p.stdOut=String(e??``):o.type===`null`||(this.stdout.write(e),this.emit(`stdOutRaw`,e)):s.type===`null`||this.stderr.write(e)})),p.interactive&&this.emit(`interactive`),p.runCommand().then(e=>{e.getStdOutput().forEach(h);for(let e of[o,s])e.type===`file`&&e.file!==`/dev/null`&&!m.has(e.file)&&m.set(e.file,{append:e.append,lines:[]});for(let[e,{append:t,lines:n}]of m){let r=this.context.fs.absolutePath(e),i=n.join(`
27
27
  `),o=i;if(t){let e=this.context.fs._getFileRaw(r);o=typeof e==`string`&&e.length>0?e+`
28
28
  `+i:i}try{this.context.fs.setFileByPath(r,o,!0)}catch{this.emit(`stdErr`,`${e}: Permission denied`),this.lastCode=+!a,this.emit(`exitCode`,this.lastCode),delete this.runningCommand;return}}let t=e.getExitCode();this.lastCode=a?+(t===0):t,this.emit(`exitCode`,this.lastCode),delete this.runningCommand})}_handleCommandError(e,t,n){if(t.type===`stdout`)this.emit(`stdOut`,e);else if(t.type===`file`){if(t.file!==`/dev/null`)try{let n=this.context.fs.absolutePath(t.file),r=this.context.fs._getFileRaw(n),i=t.append&&typeof r==`string`&&r.length>0?r+`
@@ -33,7 +33,8 @@
33
33
  `))}),this.on(`status`,t=>{if(t===e.STATUS_READY){if(this._inProgressLine&&=(this.stdout.write(`\r
34
34
  `),!1),this._working=!1,this._promptReady=!0,this._historyLoaded||=(this._loadHistory(),!0),this._redrawPromptLine(),this._pendingCommands.length>0){let e=this._pendingCommands.shift();if(this._pendingCommands.length===0){let e=this.context.getVar(`-`);e&&e.includes(`c`)&&this.context.setVar(`-`,e.replace(/c/g,``))}this.sendCommand(e)}}else this._working=!0}),this.stdinStream.on(`data`,e=>this._handleStdinData(e)),this.stdinStream.on(`end`,()=>{this.destroyed||this.destroy(0)})}sendCommand(e){if(!this._promptReady){this.suppressMotd(),this._pendingCommands.push(e);return}this.onCommand(e)}_redrawPromptLine(){if(this._working||this.runningCommand&&(this.runningCommand.interactive||this.runningCommand._inAltScreen))return;let e=`${this.getPrompt()} `,t=this._lineBuffer.join(``),n=this._terminalSize&&this._terminalSize.cols||80,r=this._lastPromptRowOffset||0,i=``;r>0&&(i+=`\x1b[${r}A`),i+=`\r\x1b[J${e}${t}`;let a=Math.min(this._cursorPos,this._lineBuffer.length),o=e.length+this._lineBuffer.length,s=e.length+a,c=Math.floor(o/n),l=Math.floor(s/n),u=s%n;if(c>l)i+=`\x1b[${c-l}A\r`,u>0&&(i+=`\x1b[${u}C`);else if(o>s){let e=o-s;i+=`\x1b[${e}D`}this._lastPromptRowOffset=l,this.stdout.write(i)}_loadHistory(){try{let e=this.context.fs._getFileRaw(l);e&&typeof e==`string`&&e.length>0&&(this._history=e.split(`
35
35
  `).filter(e=>e.length>0))}catch{}}_saveHistory(){try{this.context.fs._setFileRaw(l,this._history.join(`
36
- `),!0)}catch{}}_navigateHistory(e){if(this._history.length!==0){if(e===-1){if(this._historyPos===null)this._savedInput=[...this._lineBuffer],this._historyPos=this._history.length-1;else if(this._historyPos>0)this._historyPos--;else return;this._lineBuffer=Array.from(this._history[this._historyPos])}else{if(this._historyPos===null)return;this._historyPos<this._history.length-1?(this._historyPos++,this._lineBuffer=Array.from(this._history[this._historyPos])):(this._historyPos=null,this._lineBuffer=this._savedInput?[...this._savedInput]:[],this._savedInput=null)}this._cursorPos=this._lineBuffer.length,this._redrawPromptLine()}}_wordLeft(){let e=this._cursorPos;for(;e>0&&this._lineBuffer[e-1]===` `;)e--;for(;e>0&&this._lineBuffer[e-1]!==` `;)e--;return e}_wordRight(){let e=this._cursorPos,t=this._lineBuffer.length;for(;e<t&&this._lineBuffer[e]===` `;)e++;for(;e<t&&this._lineBuffer[e]!==` `;)e++;return e}_handleStdinData(e){let t=typeof e==`string`?e:e instanceof Uint8Array||v!==void 0&&v.isBuffer(e)?new TextDecoder().decode(e):String(e??``);if(this.runningCommand){let t=this.runningCommand,n=t.stdinStream&&t.stdinStream.listenerCount(`data`)>1;if(t.captureInput||t.interactive||t._inAltScreen||n){t.stdinStream.pushData(e);return}}if(this._working)return;let n=0;for(;n<t.length;){let e=t[n],r=t.charCodeAt(n);if(r===27){if(t[n+1]===`b`){this._cursorPos=this._wordLeft(),this._redrawPromptLine(),n+=2;continue}if(t[n+1]===`f`){this._cursorPos=this._wordRight(),this._redrawPromptLine(),n+=2;continue}if(t.charCodeAt(n+1)===127||t.charCodeAt(n+1)===8){let e=this._wordLeft();this._lineBuffer.splice(e,this._cursorPos-e),this._cursorPos=e,this._redrawPromptLine(),n+=2;continue}if(t[n+1]===`d`){let e=this._wordRight();this._lineBuffer.splice(this._cursorPos,e-this._cursorPos),this._redrawPromptLine(),n+=2;continue}if(t[n+1]===`[`||t[n+1]===`O`){let e=n+2;for(;e<t.length&&t.charCodeAt(e)>=32&&t.charCodeAt(e)<=63;)e++;if(e<t.length){this._handleEscapeSeq(t.slice(n+2,e+1)),n=e+1;continue}}n++;continue}if(r===4){if(this._lineBuffer.length===0){this.stdout.write(`exit\r
36
+ `),!0)}catch{}}_navigateHistory(e){if(this._history.length!==0){if(e===-1){if(this._historyPos===null)this._savedInput=[...this._lineBuffer],this._historyPos=this._history.length-1;else if(this._historyPos>0)this._historyPos--;else return;this._lineBuffer=Array.from(this._history[this._historyPos])}else{if(this._historyPos===null)return;this._historyPos<this._history.length-1?(this._historyPos++,this._lineBuffer=Array.from(this._history[this._historyPos])):(this._historyPos=null,this._lineBuffer=this._savedInput?[...this._savedInput]:[],this._savedInput=null)}this._cursorPos=this._lineBuffer.length,this._redrawPromptLine()}}_wordLeft(){let e=this._cursorPos;for(;e>0&&this._lineBuffer[e-1]===` `;)e--;for(;e>0&&this._lineBuffer[e-1]!==` `;)e--;return e}_wordRight(){let e=this._cursorPos,t=this._lineBuffer.length;for(;e<t&&this._lineBuffer[e]===` `;)e++;for(;e<t&&this._lineBuffer[e]!==` `;)e++;return e}_handleStdinData(e){let t=typeof e==`string`?e:e instanceof Uint8Array||v!==void 0&&v.isBuffer(e)?new TextDecoder().decode(e):String(e??``);if(this.runningCommand){let t=this.runningCommand;if((typeof e==`string`&&e===``||e instanceof Uint8Array&&e.length===1&&e[0]===3||v!==void 0&&v.isBuffer(e)&&e.length===1&&e[0]===3)&&(!t.stdinStream||!t.stdinStream.isRaw)){typeof t.kill==`function`&&t.kill(`SIGINT`),!t.interactive&&!t._inAltScreen&&this.stdout.write(`^C\r
37
+ `);return}let n=t.stdinStream&&t.stdinStream.listenerCount(`data`)>1;if(t.captureInput||t.interactive||t._inAltScreen||n){t.stdinStream.pushData(e);return}}if(this._working)return;let n=0;for(;n<t.length;){let e=t[n],r=t.charCodeAt(n);if(r===27){if(t[n+1]===`b`){this._cursorPos=this._wordLeft(),this._redrawPromptLine(),n+=2;continue}if(t[n+1]===`f`){this._cursorPos=this._wordRight(),this._redrawPromptLine(),n+=2;continue}if(t.charCodeAt(n+1)===127||t.charCodeAt(n+1)===8){let e=this._wordLeft();this._lineBuffer.splice(e,this._cursorPos-e),this._cursorPos=e,this._redrawPromptLine(),n+=2;continue}if(t[n+1]===`d`){let e=this._wordRight();this._lineBuffer.splice(this._cursorPos,e-this._cursorPos),this._redrawPromptLine(),n+=2;continue}if(t[n+1]===`[`||t[n+1]===`O`){let e=n+2;for(;e<t.length&&t.charCodeAt(e)>=32&&t.charCodeAt(e)<=63;)e++;if(e<t.length){this._handleEscapeSeq(t.slice(n+2,e+1)),n=e+1;continue}}n++;continue}if(r===4){if(this._lineBuffer.length===0){this.stdout.write(`exit\r
37
38
  `),this.destroy(0);return}this._cursorPos<this._lineBuffer.length&&(this._lineBuffer.splice(this._cursorPos,1),this._redrawPromptLine()),n++;continue}if(r===13||r===10){let e=this._lineBuffer.join(``);this._lineBuffer=[],this._cursorPos=0,this._historyPos=null,this._savedInput=null,this.stdout.write(`\r
38
39
  `),e.trim()&&(this._history[this._history.length-1]!==e&&this._history.push(e),this._saveHistory()),this._fromLineEditor=!0,this.onCommand(e),r===13&&t[n+1]===`
39
40
  `&&n++,n++;continue}if(r===127||r===8){this._cursorPos>0&&(this._lineBuffer.splice(this._cursorPos-1,1),this._cursorPos--,this._redrawPromptLine()),n++;continue}if(r===9){this._handleTab(),n++;continue}if(r===1){this._cursorPos=0,this._redrawPromptLine(),n++;continue}if(r===5){this._cursorPos=this._lineBuffer.length,this._redrawPromptLine(),n++;continue}if(r===21){this._lineBuffer.splice(0,this._cursorPos),this._cursorPos=0,this._redrawPromptLine(),n++;continue}if(r===11){this._lineBuffer.splice(this._cursorPos),this._redrawPromptLine(),n++;continue}if(r===23){let e=this._wordLeft();this._lineBuffer.splice(e,this._cursorPos-e),this._cursorPos=e,this._redrawPromptLine(),n++;continue}if(r===12){this.stdout.write(`\x1B[2J\x1B[H`),this._redrawPromptLine(),n++;continue}if(r===3){this._lineBuffer=[],this._cursorPos=0,this._historyPos=null,this._savedInput=null,this.stdout.write(`^C\r