brsh 3.1.3 → 3.2.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,6 +1,6 @@
1
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(Y(e,o)||e&&Y(e.buffer,o)||s!==void 0&&(Y(e,s)||e&&Y(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(Y(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`||me(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(Y(e,a)&&(e=d.from(e,e.offset,e.byteLength)),Y(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(Y(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)||Y(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 le(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return fe(e).length;default:if(i)return r?-1:le(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(Y(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,me(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(me(r))return o;e[n+o]=r}return o}function A(e,t,n,r){return pe(le(t,e.length-n),e,n,r)}function j(e,t,n,r){return pe(ue(t),e,n,r)}function M(e,t,n,r){return pe(fe(t),e,n,r)}function N(e,t,n,r){return pe(de(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+=he[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=X(function(e){e>>>=0,J(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&oe(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=X(function(e){e>>>=0,J(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&oe(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=X(function(e){e>>>=0,J(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&oe(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=X(function(e){e>>>=0,J(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&oe(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 ee(e,t,n,r,i){q(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 W(e,t,n,r,i){q(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=X(function(e,t=0){return ee(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeBigUInt64BE=X(function(e,t=0){return W(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=X(function(e,t=0){return ee(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),d.prototype.writeBigInt64BE=X(function(e,t=0){return W(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function te(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function ne(e,t,r,i,a){return t=+t,r>>>=0,a||te(e,t,r,4),n.write(e,t,r,i,23,4),r+4}d.prototype.writeFloatLE=function(e,t,n){return ne(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return ne(this,e,t,!1,n)};function re(e,t,r,i,a){return t=+t,r>>>=0,a||te(e,t,r,8),n.write(e,t,r,i,52,8),r+8}d.prototype.writeDoubleLE=function(e,t,n){return re(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return re(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 G={};function ie(e,t,n){G[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}`}}}ie(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),ie(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),ie(`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=ae(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=ae(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function ae(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 K(e,t,n){J(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&oe(t,e.length-(n+1))}function q(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 G.ERR_OUT_OF_RANGE(`value`,i,e)}K(r,i,a)}function J(e,t){if(typeof e!=`number`)throw new G.ERR_INVALID_ARG_TYPE(t,`number`,e)}function oe(e,t,n){throw Math.floor(e)===e?t<0?new G.ERR_BUFFER_OUT_OF_BOUNDS:new G.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(J(e,n),new G.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let se=/[^+/0-9A-Za-z-_]/g;function ce(e){if(e=e.split(`=`)[0],e=e.trim().replace(se,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function le(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 ue(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function de(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 fe(e){return t.toByteArray(ce(e))}function pe(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 Y(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function me(e){return e!==e}let he=(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 X(e){return typeof BigInt>`u`?ge:e}function ge(){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([`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}}})),ee=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
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){return e==null?!0:(typeof this._onWrite==`function`&&this._onWrite(e),this.emit(`data`,this._formatChunk(e)),typeof t==`function`?t():typeof n==`function`&&n(),!0)}pushData(e){e!=null&&this.emit(`data`,this._formatChunk(e))}_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}})),W=t(((e,t)=>{var n=V(),r=U(),{TtyStream:i,parseVtKeys:a}=ee(),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.stdinStream.on(`data`,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)})}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())}}})),te=t(((e,t)=>{var n=W();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()})}}})),ne=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=W(),n=te();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)}})}}}})),re=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}=ne(),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}=ne(),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,this._onChange=r,this._changeScheduled=!1}toBinaryContainer(e={}){let{serializeBinaryFilesystem:t}=ne();return t(this.fileSystem,this.permissions,e)}static fromBinaryContainer(e,t={}){let{deserializeBinaryFilesystem:n}=ne();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+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})),G=t(((e,t)=>{t.exports=null})),ie=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})),ae=t(((e,t)=>{B();var n=G(),r=ie(),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}}}})),K=t(((e,t)=>{var n=re();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=ae(),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)}}})),q=t(((e,t)=>{var n=W();t.exports=class extends n{constructor(e,t){super(e,t)}}})),J=t(((e,t)=>{var n=q();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),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)})}_parseLines(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=q(),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})),oe=t(((e,t)=>{y();var n=J(),{BinaryFile:r}=re(),i=0,a=8,o=20,s=28,c=31,l=44,u=54,d=70,f=0,p=2,m=3,h=4,g=1,_=2,b=4,x=8,S=1,C=class extends n{get name(){return`wasm`}get requiresFilesystem(){return!0}run(){let e=this.script,t=(()=>{try{return G()}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,C=null,w=(e,n)=>{t[e]=(t[e]||``)+n;let r=t[e].split(`
3
+ `):e===`Backspace`?this.stdout.write(`\b \b`):e.length===1&&this.stdout.write(e)),this.onInput(e)})}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())}}})),te=t(((e,t)=>{var n=W();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()})}}})),ne=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=W(),n=te();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)}})}}}})),re=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}=ne(),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}=ne(),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,this._onChange=r,this._changeScheduled=!1}toBinaryContainer(e={}){let{serializeBinaryFilesystem:t}=ne();return t(this.fileSystem,this.permissions,e)}static fromBinaryContainer(e,t={}){let{deserializeBinaryFilesystem:n}=ne();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+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})),G=t(((e,t)=>{t.exports=null})),ie=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})),ae=t(((e,t)=>{B();var n=G(),r=ie(),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}}}})),K=t(((e,t)=>{var n=re();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=ae(),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)}}})),q=t(((e,t)=>{var n=W();t.exports=class extends n{constructor(e,t){super(e,t)}}})),J=t(((e,t)=>{var n=q();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)})}_parseLines(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=q(),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})),oe=t(((e,t)=>{y();var n=J(),{BinaryFile:r}=re(),i=0,a=8,o=20,s=28,c=31,l=44,u=54,d=70,f=0,p=2,m=3,h=4,g=1,_=2,b=4,x=8,S=1,C=class extends n{get name(){return`wasm`}get requiresFilesystem(){return!0}run(){let e=this.script,t=(()=>{try{return G()}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,C=null,w=(e,n)=>{t[e]=(t[e]||``)+n;let r=t[e].split(`
4
4
  `);t[e]=r.pop();for(let t of r)e===1?this.stdOut=t:this.stdErr=t},T=()=>{t[1]&&=(this.stdOut=t[1],``),t[2]&&=(this.stdErr=t[2],``)},E=typeof this.stdin==`string`?y.encode(this.stdin):this.stdin instanceof Uint8Array?this.stdin:v!==void 0&&v.isBuffer(this.stdin)?new Uint8Array(this.stdin):new Uint8Array,D=0,O=this.context&&this.context.fs?this.context.fs:this.fs,j=5,M=new Map([[3,{type:`preopen`,path:`/`,guestName:`/`}],[4,{type:`preopen`,path:O&&O.cwd||`/`,guestName:`.`}]]),N=(e,t)=>{let n=M.get(e);if(!n||n.type!==`preopen`&&n.type!==`dir`)return null;if(t.startsWith(`/`))return O.absolutePath(t);let r=n.path.endsWith(`/`)?n.path:n.path+`/`;return O.absolutePath(r+t)},P=e=>{if(!(!e||e.type!==`file`||!e.dirty||!O))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);O.setFileByPath(e.path,t,!0)}else{let t=new Uint8Array(e.bytes.length);t.set(e.bytes),O.setFileByPath(e.path,new r(t.buffer,`application/octet-stream`),!0)}e.dirty=!1}catch{}},F=Object.entries(this.context&&this.context.vars||{}).map(([e,t])=>`${e}=${t}`),I=new Proxy({fd_write:(e,t,r,o)=>{if(!C)return a;let s=new DataView(C.buffer);if(e===1||e===2){let a=0;for(let i=0;i<r;i++){let r=s.getUint32(t+i*8,!0),o=s.getUint32(t+i*8+4,!0);o>0&&w(e,n.decode(new Uint8Array(C.buffer,r,o))),a+=o}return s.setUint32(o,a,!0),i}let c=M.get(e);if(!c||c.type!==`file`)return a;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(C.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(o,l,!0),i},fd_read:(e,t,n,r)=>{if(!C)return a;let o=new DataView(C.buffer);if(e===0){let e=0;for(let r=0;r<n&&D<E.length;r++){let n=o.getUint32(t+r*8,!0),i=o.getUint32(t+r*8+4,!0),a=Math.min(i,E.length-D);new Uint8Array(C.buffer).set(E.slice(D,D+a),n),D+=a,e+=a}return o.setUint32(r,e,!0),i}let s=M.get(e);if(!s||s.type!==`file`)return a;let c=0;for(let e=0;e<n&&s.pos<s.bytes.length;e++){let n=o.getUint32(t+e*8,!0),r=o.getUint32(t+e*8+4,!0),i=Math.min(r,s.bytes.length-s.pos);new Uint8Array(C.buffer).set(s.bytes.subarray(s.pos,s.pos+i),n),s.pos+=i,c+=i}return o.setUint32(r,c,!0),i},fd_seek:(e,t,n,r,o)=>{if(!C)return a;if(e<=2)return d;let c=M.get(e);if(!c||c.type!==`file`)return a;let l,u,f;typeof t==`bigint`?(l=Number(t),u=n,f=r):(l=t,u=r,f=o);let p=c.pos;if(u===0)p=l;else if(u===1)p=c.pos+l;else if(u===2)p=c.bytes.length+l;else return s;return p<0?s:(c.pos=p,f&&new DataView(C.buffer).setBigUint64(f,BigInt(c.pos),!0),i)},fd_tell:(e,t)=>{if(!C)return a;let n=M.get(e);return!n||n.type!==`file`?a:(new DataView(C.buffer).setBigUint64(t,BigInt(n.pos),!0),i)},fd_close:e=>{if(e<=2)return i;let t=M.get(e);return t?(P(t),M.delete(e),i):a},fd_sync:e=>{let t=M.get(e);return t&&P(t),i},fd_datasync:e=>{let t=M.get(e);return t&&P(t),i},fd_prestat_get:(e,t)=>{if(!C)return a;let n=M.get(e);if(!n||n.type!==`preopen`)return a;let r=new DataView(C.buffer),o=y.encode(n.guestName);return r.setUint8(t,0),r.setUint32(t+4,o.length,!0),i},fd_prestat_dir_name:(e,t,n)=>{if(!C)return a;let r=M.get(e);if(!r||r.type!==`preopen`)return a;let o=y.encode(r.guestName);return new Uint8Array(C.buffer,t,Math.min(n,o.length)).set(o.subarray(0,n)),i},fd_fdstat_get:(e,t)=>{if(!C)return a;let n=new DataView(C.buffer),r=f;if(e<=2)r=p;else{let t=M.get(e);if(!t)return a;r=t.type===`preopen`||t.type===`dir`?m:h}for(let e=0;e<24;e++)n.setUint8(t+e,0);return n.setUint8(t,r),n.setBigUint64(t+8,18446744073709551615n,!0),n.setBigUint64(t+16,18446744073709551615n,!0),i},fd_fdstat_set_flags:()=>i,fd_filestat_get:(e,t)=>{if(!C)return a;let n=new DataView(C.buffer);for(let e=0;e<64;e++)n.setUint8(t+e,0);if(e<=2)return n.setUint8(t+16,p),i;let r=M.get(e);if(!r)return a;let o=r.type===`preopen`||r.type===`dir`;return n.setUint8(t+16,o?m:h),n.setBigUint64(t+24,1n,!0),n.setBigUint64(t+32,BigInt(r.bytes?r.bytes.length:0),!0),i},path_open:(e,t,r,s,d,f,p,m,h)=>{if(!C||!O)return a;let v=N(e,n.decode(new Uint8Array(C.buffer,r,s)));if(!v)return a;let w=O.stat(v),T=w!==null;if(d&b&&d&g&&T)return o;if(d&_){if(!T)return l;if(!w.isDirectory)return u;let e=j++;return M.set(e,{type:`dir`,path:v}),new DataView(C.buffer).setUint32(h,e,!0),i}if(T&&w.isDirectory)return c;if(!T&&!(d&g))return l;let E=new Uint8Array,D=!1;if(T&&!(d&x)){let e=O.getFileByPath(v);e!=null&&(E=typeof e==`string`?y.encode(e):new Uint8Array(this._contentToBytes(e)))}else D=!0;let k=j++;return M.set(k,{type:`file`,path:v,bytes:E,pos:m&S?E.length:0,append:!!(m&S),dirty:D}),new DataView(C.buffer).setUint32(h,k,!0),i},path_filestat_get:(e,t,r,o,s)=>{if(!C||!O)return a;let c=N(e,n.decode(new Uint8Array(C.buffer,r,o)));if(!c)return a;let u=O.stat(c);if(!u)return l;let d=new DataView(C.buffer);for(let e=0;e<64;e++)d.setUint8(s+e,0);return d.setUint8(s+16,u.isDirectory?m:h),d.setBigUint64(s+24,1n,!0),d.setBigUint64(s+32,BigInt(O.getSize(c)||0),!0),i},path_create_directory:(e,t,r)=>{if(!C||!O)return a;let o=N(e,n.decode(new Uint8Array(C.buffer,t,r)));if(!o)return a;try{return O.setFileByPath(o,{},!0),i}catch{return s}},path_unlink_file:(e,t,r)=>{if(!C||!O)return a;let o=N(e,n.decode(new Uint8Array(C.buffer,t,r)));if(!o||!O.exists(o))return l;try{return O.deleteFileByPath(o),i}catch{return s}},path_remove_directory:(e,t,r)=>{if(!C||!O)return a;let o=N(e,n.decode(new Uint8Array(C.buffer,t,r)));if(!o||!O.exists(o))return l;try{return O.deleteFileByPath(o),i}catch{return s}},proc_exit:e=>{throw e!==0&&(this.exitCode=e),{_wasmExit:!0,code:e}},args_sizes_get:(e,t)=>{if(!C)return s;let n=[this.script,...this.arguments||[]],r=new DataView(C.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(!C)return s;let n=[this.script,...this.arguments||[]],r=new DataView(C.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(C.buffer).set(i,a),a+=i.length}return i},environ_sizes_get:(e,t)=>{if(!C)return s;let n=new DataView(C.buffer);n.setUint32(e,F.length,!0);let r=F.reduce((e,t)=>e+y.encode(t).length+1,0);return n.setUint32(t,r,!0),i},environ_get:(e,t)=>{if(!C)return s;let n=new DataView(C.buffer),r=t;for(let t=0;t<F.length;t++){n.setUint32(e+t*4,r,!0);let i=y.encode(F[t]+`\0`);new Uint8Array(C.buffer).set(i,r),r+=i.length}return i},clock_time_get:(e,t,n)=>{if(C){let e=BigInt(Date.now())*1000000n;new DataView(C.buffer).setBigUint64(n,e,!0)}return i},random_get:(e,t)=>{if(C){let n=new Uint8Array(C.buffer,e,t);for(let e=0;e<t;e++)n[e]=Math.random()*256|0}return i}},{get(e,t){return t in e?e[t]:()=>0}}),L=e=>{if(!C||!e)return``;try{let t=new DataView(C.buffer).getUint32(e-4,!0),n=new Uint16Array(C.buffer,e,t>>>1);return String.fromCharCode(...n)}catch{return``}},R={wasi_snapshot_preview1:I,wasi_unstable:I,env:new Proxy({print:(e,t)=>{C&&w(1,n.decode(new Uint8Array(C.buffer,e,t)))},eprint:(e,t)=>{C&&w(2,n.decode(new Uint8Array(C.buffer,e,t)))},log:e=>{w(1,L(e)+`
5
5
  `)},logi:e=>{w(1,String(e)+`
6
6
  `)},logf:e=>{w(1,String(e)+`
@@ -21,7 +21,7 @@
21
21
  `+t.prev+t.base;return n+C.call(e,`,`+n)+`
22
22
  `+t.prev}function xe(e,t){var n=H(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=K(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)K(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=Z(),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=Z(),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=Z(),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=st();t.exports=function(){return n()&&!!Symbol.toStringTag}})),Ut=t(((e,t)=>{var n=$(),r=Ht()(),i=bt(),a=at(),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=Q()(`%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=Q()(`%String%`),r=Z();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=Z();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=xt(),r=St()(),i=Jt().functionsHaveConfigurableNames(),a=Z();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=Z(),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=kt().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=kt().supportsDescriptors,r=Zt(),i=at(),a=Object.defineProperty,o=We(),s=yt(),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=kt(),r=Tt(),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=Q(),r=Z(),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=Z(),r=$(),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=nt();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=Xe(),r=Ze(),i=nt(),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=Z(),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=Z();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=Z(),r=bt(),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=St(),r=ot(),i=n.hasArrayLengthDefineBug(),a=i&&At(),o=$()(`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=Z(),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=Z(),r=bt(),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=nt();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=bt(),r=Z(),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=Z(),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=Q(),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=Z(),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=Z(),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=Q(),r=$(),i=Pt(),a=Z(),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=Q(),r=$(),i=Pt(),a=Cn(),o=Z(),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=Z(),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=bt(),r=Tn()(),i=Z(),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=Q()(`%Object.create%`,!0),r=Z(),i=Je(),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=Z(),r=It(),i=$()(`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=Z(),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=$(),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=$(),r=Ut(),i=n(`RegExp.prototype.exec`),a=Z();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=$(),r=n(`Object.prototype.toString`),i=ct()(),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=$()(`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=St()(),r=xt(),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=Tt(),r=kt(),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=Q(),r=n(`%RegExp%`),i=Z(),a=n(`%parseInt%`),o=$(),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=Q(),r=Z(),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=Ze();t.exports=function(e){return typeof e==`bigint`?e:n(e)}})),Wn=t(((e,t)=>{var n=Un(),r=Z();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=nt(),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=Q()(`%Object.defineProperty%`,!0),r=Ht()(),i=bt(),a=Z(),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=Q(),r=ct()(),i=Z(),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=Q()})),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=Q()(`%Symbol.species%`,!0),r=Z(),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=$(),f=Q(),p=Z(),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=ct()(),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=$(),l=ct()(),u=$t(),d=Q(),f=Z(),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=kt(),r=ct()(),i=at(),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=Tt(),r=kt(),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=te(),{createGenericWasmCommand:r}=oe(),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}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._replStatus=`^D / .exit: Quit | ^L: Clear | Up/Down: History`,e){if(e.clear&&(this._replLog=[]),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(`
23
23
  `);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(`
24
- `):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=K(),r=q(),i=J(),a=oe(),o=W(),s=te(),{TtyStream:c}=ee(),l=`/.brsh_history`,u=be(),d=He(),f=V(),p=b(),{isAsyncFilesystemSource:m,resolveFilesystemSource:h}=ne(),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(`
24
+ `):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=K(),r=q(),i=J(),a=oe(),o=W(),s=te(),{TtyStream:c}=ee(),l=`/.brsh_history`,u=be(),d=He(),f=V(),p=b(),{isAsyncFilesystemSource:m,resolveFilesystemSource:h}=ne(),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
25
  `)&&(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=n.shift().value;if(n.length===0&&/^[A-Za-z_]\w*=/.test(a)){let e=a.indexOf(`=`);this.context.setVar(a.slice(0,e),a.slice(e+1)),this.lastCode=0,this.emit(`exitCode`,0);return}let o=null,s=!1,c=[];for(let e=0;e<n.length;e++){let{value:t,hasQuote:r}=n[e];!r&&(t===`>>`||t===`>`)&&e+1<n.length?(s=t===`>>`,o=n[++e].value):!r&&t.startsWith(`>>`)&&t.length>2?(s=!0,o=t.slice(2)):!r&&t.startsWith(`>`)&&t.length>1?(s=!1,o=t.slice(1)):c.push(t)}n=c;let l=this.context.getAlias(a);if(l)return this.onCommand(l,!1);let u;try{u=this._parseCommand(a.startsWith(`/`)||a.startsWith(`./`)?a:a.toLowerCase())}catch(e){this.emit(`stdErr`,e.message),this.lastCode=1,this.emit(`exitCode`,this.lastCode);return}let d=e=>typeof e==`function`&&typeof e.prototype.run==`function`&&typeof e.prototype.runCommand==`function`,f;if(u.prototype instanceof r||new u instanceof i)f=new u(n,this.context);else if(d(u))f=new u(n,this._readonlyContext);else{this.emit(`stdErr`,`${a}: Command not found`),this.lastCode=1,this.emit(`exitCode`,this.lastCode);return}return f.requiresFilesystem&&(f.fs=this.context.fs.sandbox()),this._stdin!==void 0&&(f.stdin=this._stdin),this.runningCommand=f,this.runningCommand.on&&(this.runningCommand.on(`flush`,e=>{this._emitOutput(e)}),this.runningCommand.on(`stdout`,e=>{o?f.stdOut=String(e??``):(this.stdout.write(e),this.emit(`stdOutRaw`,e))}),this.runningCommand.on(`stderr`,e=>{this.stderr.write(e)})),f.interactive&&this.emit(`interactive`),f.runCommand().then(e=>{let t=e.getStdOutput();if(o){let e=this.context.fs.absolutePath(o),n=t.filter(e=>e.type===`out`).map(e=>e.string),r=s?(()=>{let t=this.context.fs._getFileRaw(e);return typeof t==`string`?t+`
26
26
  `+n.join(`
27
27
  `):n.join(`
@@ -39,7 +39,8 @@
39
39
  `&&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
40
40
  `),this._redrawPromptLine(),n++;continue}r>=32&&(this._lineBuffer.splice(this._cursorPos,0,e),this._cursorPos++,this._redrawPromptLine()),n++}}_handleEscapeSeq(e){e===`A`?this._navigateHistory(-1):e===`B`?this._navigateHistory(1):e===`C`?this._cursorPos<this._lineBuffer.length&&(this._cursorPos++,this._redrawPromptLine()):e===`D`?this._cursorPos>0&&(this._cursorPos--,this._redrawPromptLine()):e===`1;3D`||e===`1;5D`?(this._cursorPos=this._wordLeft(),this._redrawPromptLine()):e===`1;3C`||e===`1;5C`?(this._cursorPos=this._wordRight(),this._redrawPromptLine()):e===`H`||e===`1~`||e===`7~`?(this._cursorPos=0,this._redrawPromptLine()):e===`F`||e===`4~`||e===`8~`?(this._cursorPos=this._lineBuffer.length,this._redrawPromptLine()):e===`3~`&&this._cursorPos<this._lineBuffer.length&&(this._lineBuffer.splice(this._cursorPos,1),this._redrawPromptLine())}_handleTab(){let e=this._lineBuffer.join(``).split(` `),t=e.pop(),n=this.tabCompletion(t);if(!n)return;let{options:r,path:i}=n;r.length===1?(e.push(`${i==null?``:i.concat(`/`)}${r[0]}`),this._lineBuffer=e.join(` `).split(``),this._cursorPos=this._lineBuffer.length,this._redrawPromptLine()):r.length>1&&(this.stdout.write(`\r
41
41
  `+r.join(` `)+`\r
42
- `),this._redrawPromptLine())}_splitInput(e){let t=e.split(`#`)[0];return this._parseOperators(t)}_parseOperators(e){let t=[],n=``,r=0,i=!1,a=!1;for(;r<e.length;){let o=e[r];if(o===`'`&&!a){i=!i,n+=o,r++;continue}if(o===`"`&&!i){a=!a,n+=o,r++;continue}if(!i&&!a){if(o===`&`&&e[r+1]===`&`){t.push({command:n.trim(),op:`&&`}),n=``,r+=2;continue}if(o===`|`&&e[r+1]===`|`){t.push({command:n.trim(),op:`||`}),n=``,r+=2;continue}if(o===`|`){t.push({command:n.trim(),op:`|`}),n=``,r++;continue}if(o===`;`){t.push({command:n.trim(),op:`;`}),n=``,r++;continue}}n+=o,r++}return n.trim()&&t.push({command:n.trim(),op:null}),t}_parseCommand(e){if(e.startsWith(`./`)||e.startsWith(`/`)){let t=this.context.fs._getFileRaw(e);if(!t)throw Error(`${e}: No such file or directory`);if(t.constructor===Object)throw Error(`${e}: is a directory`);if(t.prototype&&typeof t.prototype.run==`function`&&typeof t.prototype.runCommand==`function`){if(!this.context.fs.isExecutable(e))throw Error(`${e}: permission denied`);return t}if(t.constructor===String&&t.startsWith(`#!`)){if(!this.context.fs.isExecutable(e))throw Error(`${e}: permission denied`);return i.bind(this,t)}if(this._isWasmFile(e,t)){if(!this.context.fs.isExecutable(e))throw Error(`${e}: permission denied`);return a.bind(null,e)}if(this.context.fs.isRealFilesystem&&typeof t==`string`&&e.endsWith(`.js`)){if(!this.context.fs.isExecutable(e))throw Error(`${e}: permission denied`);let t=this.context.fs.absolutePath(e);try{let e=require(t),n=e.default||e;if(typeof n==`function`&&typeof n.prototype.run==`function`&&typeof n.prototype.runCommand==`function`)return n}catch{}}throw Error(`${e}: permission denied`)}let t=this.context.getCommand(e),n=e;if(!t&&!e.endsWith(`.wasm`)&&(t=this.context.getCommand(`${e}.wasm`),t&&(n=`${e}.wasm`)),!t)throw Error(`${e}: Command not found`);let r=`${this.path}/${n}`;if(this._isWasmFile(r,t)){if(!this.context.fs.isExecutable(r))throw Error(`${e}: permission denied`);return a.bind(null,r)}return typeof t==`string`&&t.startsWith(`#!`)?i.bind(this,t):t}async _parseCommandLine(t){let n=e._splitCommand(t);return(await Promise.all(n.map(({value:e,hasQuote:t})=>this._replaceVariables(e).then(e=>({value:e,hasQuote:t}))))).filter(({value:e,hasQuote:t})=>e.length>0||t)}static _sanitiseCommandPart(e){return e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.substring(1,e.length-1):e}static _sanitiseArray(e){return e.filter(e=>e.length>0)}async _replaceVariables(t){let n=[...t.matchAll(/\$\(\(([^)]+)\)\)/g)];for(let e of n)t=t.replace(e[0],String(this._evalArithmetic(e[1])));let r=[...t.matchAll(/\$\((?!\()([^)]+)\)/g)];for(let e of r){let n=await this._runAndCapture(e[1]);t=t.replace(e[0],n)}let i=t.matchAll(g),a=i.next();for(;!a.done;){let n=a.value[1]||a.value[2],r=this.context.getVar(n);t=t.replace(new RegExp(e._escapeRegExp(a.value[0]),`g`),String(r)),a=i.next()}return t}_evalArithmetic(e){let t=e.replace(/\${?([\w\d]+)}?/g,(e,t)=>String(parseInt(this.context.getVar(t))||0));if(t=t.replace(/\b([A-Za-z_]\w*)\b/g,(e,t)=>String(parseInt(this.context.getVar(t))||0)),!/^[\d\s+\-*/%()]+$/.test(t.trim()))return 0;try{return Function(`return (`+t+`)`)()}catch{return 0}}async _runAndCapture(e){let t=new globalThis.shell({cwd:this.context.fs.cwd,filesystem:this.context.fs.getRaw(),permissions:this.context.fs.getRawPermissions(),subshell:!0});t.context.source(this.context);let n=[];return t.on(`stdOut`,e=>n.push(e)),await t.onCommand(e,!1),n.join(`
42
+ `),this._redrawPromptLine())}_splitInput(e){return this._parseOperators(e)}_parseOperators(e){let t=[],n=``,r=0,i=!1,a=!1;for(;r<e.length;){let o=e[r];if(o===`'`&&!a){i=!i,n+=o,r++;continue}if(o===`"`&&!i){a=!a,n+=o,r++;continue}if(!i&&!a){if(o===`#`&&(n.trim()===``||/\s/.test(e[r-1]))){let t=e.indexOf(`
43
+ `,r);if(t===-1)break;r=t;continue}if(o===`&`&&e[r+1]===`&`){t.push({command:n.trim(),op:`&&`}),n=``,r+=2;continue}if(o===`|`&&e[r+1]===`|`){t.push({command:n.trim(),op:`||`}),n=``,r+=2;continue}if(o===`|`){t.push({command:n.trim(),op:`|`}),n=``,r++;continue}if(o===`;`){t.push({command:n.trim(),op:`;`}),n=``,r++;continue}}n+=o,r++}return n.trim()&&t.push({command:n.trim(),op:null}),t}_parseCommand(e){if(e.startsWith(`./`)||e.startsWith(`/`)){let t=this.context.fs._getFileRaw(e);if(!t)throw Error(`${e}: No such file or directory`);if(t.constructor===Object)throw Error(`${e}: is a directory`);if(t.prototype&&typeof t.prototype.run==`function`&&typeof t.prototype.runCommand==`function`){if(!this.context.fs.isExecutable(e))throw Error(`${e}: permission denied`);return t}if(t.constructor===String&&t.startsWith(`#!`)){if(!this.context.fs.isExecutable(e))throw Error(`${e}: permission denied`);return i.bind(this,t)}if(this._isWasmFile(e,t)){if(!this.context.fs.isExecutable(e))throw Error(`${e}: permission denied`);return a.bind(null,e)}if(this.context.fs.isRealFilesystem&&typeof t==`string`&&e.endsWith(`.js`)){if(!this.context.fs.isExecutable(e))throw Error(`${e}: permission denied`);let t=this.context.fs.absolutePath(e);try{let e=require(t),n=e.default||e;if(typeof n==`function`&&typeof n.prototype.run==`function`&&typeof n.prototype.runCommand==`function`)return n}catch{}}throw Error(`${e}: permission denied`)}let t=this.context.getCommand(e),n=e;if(!t&&!e.endsWith(`.wasm`)&&(t=this.context.getCommand(`${e}.wasm`),t&&(n=`${e}.wasm`)),!t)throw Error(`${e}: Command not found`);let r=`${this.path}/${n}`;if(this._isWasmFile(r,t)){if(!this.context.fs.isExecutable(r))throw Error(`${e}: permission denied`);return a.bind(null,r)}return typeof t==`string`&&t.startsWith(`#!`)?i.bind(this,t):t}async _parseCommandLine(t){let n=e._splitCommand(t);return(await Promise.all(n.map(({value:e,hasQuote:t})=>this._replaceVariables(e).then(e=>({value:e,hasQuote:t}))))).filter(({value:e,hasQuote:t})=>e.length>0||t)}static _sanitiseCommandPart(e){return e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.substring(1,e.length-1):e}static _sanitiseArray(e){return e.filter(e=>e.length>0)}async _replaceVariables(t){let n=[...t.matchAll(/\$\(\(([^)]+)\)\)/g)];for(let e of n)t=t.replace(e[0],String(this._evalArithmetic(e[1])));let r=[...t.matchAll(/\$\((?!\()([^)]+)\)/g)];for(let e of r){let n=await this._runAndCapture(e[1]);t=t.replace(e[0],n)}let i=t.matchAll(g),a=i.next();for(;!a.done;){let n=a.value[1]||a.value[2],r=this.context.getVar(n);t=t.replace(new RegExp(e._escapeRegExp(a.value[0]),`g`),String(r)),a=i.next()}return t}_evalArithmetic(e){let t=e.replace(/\${?([\w\d]+)}?/g,(e,t)=>String(parseInt(this.context.getVar(t))||0));if(t=t.replace(/\b([A-Za-z_]\w*)\b/g,(e,t)=>String(parseInt(this.context.getVar(t))||0)),!/^[\d\s+\-*/%()]+$/.test(t.trim()))return 0;try{return Function(`return (`+t+`)`)()}catch{return 0}}async _runAndCapture(e){let t=new globalThis.shell({cwd:this.context.fs.cwd,filesystem:this.context.fs.getRaw(),permissions:this.context.fs.getRawPermissions(),subshell:!0});t.context.source(this.context);let n=[];return t.on(`stdOut`,e=>n.push(e)),await t.onCommand(e,!1),n.join(`
43
44
  `).trimEnd()}_groupPipes(e){let t=[],n=[];for(let{command:r,op:i}of e)n.push(r),i!==`|`&&(t.push({commands:n,op:i}),n=[]);return n.length&&t.push({commands:n,op:null}),t}async _runPipeChain(e){if(e.length===1)return this._runCommand(e[0]);let t;for(let n=0;n<e.length;n++)if(n===e.length-1){t!==void 0&&(this._stdin=t);try{await this._runCommand(e[n])}finally{delete this._stdin}}else t=await this._captureForPipe(e[n],t)}async _captureForPipe(e,t){let n=new globalThis.shell({cwd:this.context.fs.cwd,filesystem:this.context.fs.getRaw(),permissions:this.context.fs.getRawPermissions(),subshell:!0});n.context.source(this.context),t!==void 0&&(n.stdin=t);let r=[];return n.on(`stdOut`,e=>r.push(e)),n.on(`stdErr`,e=>this.emit(`stdErr`,e)),await n.onCommand(e,!1),this.lastCode=n.lastCode,r.join(`
44
45
  `)}static _splitCommand(e){let t=/\s/g,n=!1,r=!1,i=0,a=[],o=!1,s=[];for(let c=0;c<e.length;c++){let l=e[c];if(i>0){a.push(l),l===`(`?i++:l===`)`&&i--;continue}if(r&&l===`\\`&&c+1<e.length){let t=e[c+1];if(t===`"`||t===`\\`||t===`$`){a.push(t),c++;continue}}if(!n&&!r&&l===`\\`&&c+1<e.length){let t=e[++c];a.push(t),(t===`"`||t===`'`)&&(o=!0);continue}if(l===`'`&&!r){n=!n,o=!0;continue}if(l===`"`&&!n){r=!r,o=!0;continue}if(!n&&!r){if(l===`$`&&c+1<e.length&&e[c+1]===`(`){i=1,a.push(`$`),a.push(`(`),c++;continue}if(l.match(t)){(a.length>0||o)&&(s.push({value:a.join(``),hasQuote:o}),a=[],o=!1);continue}}a.push(l)}if((a.length>0||o)&&s.push({value:a.join(``),hasQuote:o}),n||r)throw Error(`quote expression not closed`);return s}_isWasmFile(e,t){return e.endsWith(`.wasm`)||e.endsWith(`.wat`)?!0:t instanceof Uint8Array?t.length>=4&&t[0]===0&&t[1]===97&&t[2]===115&&t[3]===109:typeof t==`string`?t.charCodeAt(0)===0&&t.slice(1,4)===`asm`?!0:t.trimStart().startsWith(`(module`):!1}static _escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}static async create(t={}){let{filesystem:n,permissions:r,...i}=t;if(m(n)||n&&typeof n==`object`&&m(n.filesystem)){let e=await h(n,r);n=e.filesystem,r=e.permissions}let a=new e(Object.assign({},i,{filesystem:n,permissions:r}));return await a.ready,a}static async fromContainer(t,n={}){return e.create(Object.assign({},n,{filesystem:t}))}};x.STATUS_READY=`READY`,x.STATUS_WORKING=`WORKING`,x.STATUS_DESTROYED=`DESTROYED`,x.Command=o,x.InteractiveCommand=s,x.WasmCommand=a,x.createWasmCommand=a.createGenericWasmCommand||a.createCommand,x.ReplCommand=or(),x.FS=p,x.BinaryContainer=ne(),x.Storage=x.BinaryContainer.FilesystemStorage,globalThis.shell=x,globalThis.Shell=x,t.exports=x}))()})();
45
46
  //# sourceMappingURL=shell.min.js.map