brsh 3.0.0 → 3.1.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,11 +1,11 @@
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.fs.isRealFilesystem?{useRealFilesystem:!0}:{filesystem:this.context.fs.getRaw(),permissions:this.context.fs.getRawPermissions()};this.sandbox=new globalThis.shell({cwd:this.context.fs.cwd,...e,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 t=this.script.split(/\r?\n/);if(!r(t[0])){let e=t[0].startsWith(`#!`)?t[0].slice(2).split(/\s/)[0]:t[0];return Promise.reject(`${e}: bad interpreter: No such file or directory`)}let n=this._parseLines(t.slice(1));return this._executeNodes(n).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){if(this.context.fs.isRealFilesystem&&t)try{let n=t.readFileSync(this.context.fs.absolutePath(e)),r=new Uint8Array(n);return Promise.resolve({bytes:r,isWat:this._isWat(e,r)})}catch(t){return Promise.reject(Error(`${e}: ${t.message}`))}let n=this.context.fs.getFileByPath(e);if(n==null)return Promise.reject(Error(`${e}: No such file or directory`));let r=this._contentToBytes(n);return Promise.resolve({bytes:r,isWat:this._isWat(e,r)})}_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,v=new TextEncoder,y=null,C=(e,n)=>{t[e]=(t[e]||``)+n;let r=t[e].split(`
4
- `);t[e]=r.pop();for(let t of r)e===1?this.stdOut=t:this.stdErr=t},w=()=>{t[1]&&=(this.stdOut=t[1],``),t[2]&&=(this.stdErr=t[2],``)},T=v.encode(this.stdin||``),E=0,D=this.context&&this.context.fs?this.context.fs:this.fs,O=5,j=new Map([[3,{type:`preopen`,path:`/`,guestName:`/`}],[4,{type:`preopen`,path:D&&D.cwd||`/`,guestName:`.`}]]),M=(e,t)=>{let n=j.get(e);if(!n||n.type!==`preopen`&&n.type!==`dir`)return null;if(t.startsWith(`/`))return D.absolutePath(t);let r=n.path.endsWith(`/`)?n.path:n.path+`/`;return D.absolutePath(r+t)},N=e=>{if(!(!e||e.type!==`file`||!e.dirty||!D))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);D.setFileByPath(e.path,t,!0)}else{let t=new Uint8Array(e.bytes.length);t.set(e.bytes),D.setFileByPath(e.path,new r(t.buffer,`application/octet-stream`),!0)}e.dirty=!1}catch{}},P=Object.entries(this.context&&this.context.vars||{}).map(([e,t])=>`${e}=${t}`),F=new Proxy({fd_write:(e,t,r,o)=>{if(!y)return a;let s=new DataView(y.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&&C(e,n.decode(new Uint8Array(y.buffer,r,o))),a+=o}return s.setUint32(o,a,!0),i}let c=j.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(y.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(!y)return a;let o=new DataView(y.buffer);if(e===0){let e=0;for(let r=0;r<n&&E<T.length;r++){let n=o.getUint32(t+r*8,!0),i=o.getUint32(t+r*8+4,!0),a=Math.min(i,T.length-E);new Uint8Array(y.buffer).set(T.slice(E,E+a),n),E+=a,e+=a}return o.setUint32(r,e,!0),i}let s=j.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(y.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(!y)return a;if(e<=2)return d;let c=j.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(y.buffer).setBigUint64(f,BigInt(c.pos),!0),i)},fd_tell:(e,t)=>{if(!y)return a;let n=j.get(e);return!n||n.type!==`file`?a:(new DataView(y.buffer).setBigUint64(t,BigInt(n.pos),!0),i)},fd_close:e=>{if(e<=2)return i;let t=j.get(e);return t?(N(t),j.delete(e),i):a},fd_sync:e=>{let t=j.get(e);return t&&N(t),i},fd_datasync:e=>{let t=j.get(e);return t&&N(t),i},fd_prestat_get:(e,t)=>{if(!y)return a;let n=j.get(e);if(!n||n.type!==`preopen`)return a;let r=new DataView(y.buffer),o=v.encode(n.guestName);return r.setUint8(t,0),r.setUint32(t+4,o.length,!0),i},fd_prestat_dir_name:(e,t,n)=>{if(!y)return a;let r=j.get(e);if(!r||r.type!==`preopen`)return a;let o=v.encode(r.guestName);return new Uint8Array(y.buffer,t,Math.min(n,o.length)).set(o.subarray(0,n)),i},fd_fdstat_get:(e,t)=>{if(!y)return a;let n=new DataView(y.buffer),r=f;if(e<=2)r=p;else{let t=j.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(!y)return a;let n=new DataView(y.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=j.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(!y||!D)return a;let C=M(e,n.decode(new Uint8Array(y.buffer,r,s)));if(!C)return a;let w=D.stat(C),T=w!==null;if(d&b&&d&g&&T)return o;if(d&_){if(!T)return l;if(!w.isDirectory)return u;let e=O++;return j.set(e,{type:`dir`,path:C}),new DataView(y.buffer).setUint32(h,e,!0),i}if(T&&w.isDirectory)return c;if(!T&&!(d&g))return l;let E=new Uint8Array,k=!1;if(T&&!(d&x)){let e=D.getFileByPath(C);e!=null&&(E=typeof e==`string`?v.encode(e):new Uint8Array(this._contentToBytes(e)))}else k=!0;let A=O++;return j.set(A,{type:`file`,path:C,bytes:E,pos:m&S?E.length:0,append:!!(m&S),dirty:k}),new DataView(y.buffer).setUint32(h,A,!0),i},path_filestat_get:(e,t,r,o,s)=>{if(!y||!D)return a;let c=M(e,n.decode(new Uint8Array(y.buffer,r,o)));if(!c)return a;let u=D.stat(c);if(!u)return l;let d=new DataView(y.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(D.getSize(c)||0),!0),i},path_create_directory:(e,t,r)=>{if(!y||!D)return a;let o=M(e,n.decode(new Uint8Array(y.buffer,t,r)));if(!o)return a;try{return D.setFileByPath(o,{},!0),i}catch{return s}},path_unlink_file:(e,t,r)=>{if(!y||!D)return a;let o=M(e,n.decode(new Uint8Array(y.buffer,t,r)));if(!o||!D.exists(o))return l;try{return D.deleteFileByPath(o),i}catch{return s}},path_remove_directory:(e,t,r)=>{if(!y||!D)return a;let o=M(e,n.decode(new Uint8Array(y.buffer,t,r)));if(!o||!D.exists(o))return l;try{return D.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(!y)return s;let n=[this.script,...this.arguments||[]],r=new DataView(y.buffer);return r.setUint32(e,n.length,!0),r.setUint32(t,n.reduce((e,t)=>e+v.encode(t).length+1,0),!0),i},args_get:(e,t)=>{if(!y)return s;let n=[this.script,...this.arguments||[]],r=new DataView(y.buffer),a=t;for(let t=0;t<n.length;t++){r.setUint32(e+t*4,a,!0);let i=v.encode(n[t]+`\0`);new Uint8Array(y.buffer).set(i,a),a+=i.length}return i},environ_sizes_get:(e,t)=>{if(!y)return s;let n=new DataView(y.buffer);n.setUint32(e,P.length,!0);let r=P.reduce((e,t)=>e+v.encode(t).length+1,0);return n.setUint32(t,r,!0),i},environ_get:(e,t)=>{if(!y)return s;let n=new DataView(y.buffer),r=t;for(let t=0;t<P.length;t++){n.setUint32(e+t*4,r,!0);let i=v.encode(P[t]+`\0`);new Uint8Array(y.buffer).set(i,r),r+=i.length}return i},clock_time_get:(e,t,n)=>{if(y){let e=BigInt(Date.now())*1000000n;new DataView(y.buffer).setBigUint64(n,e,!0)}return i},random_get:(e,t)=>{if(y){let n=new Uint8Array(y.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}}),I=e=>{if(!y||!e)return``;try{let t=new DataView(y.buffer).getUint32(e-4,!0),n=new Uint16Array(y.buffer,e,t>>>1);return String.fromCharCode(...n)}catch{return``}},L={wasi_snapshot_preview1:F,wasi_unstable:F,env:new Proxy({print:(e,t)=>{y&&C(1,n.decode(new Uint8Array(y.buffer,e,t)))},eprint:(e,t)=>{y&&C(2,n.decode(new Uint8Array(y.buffer,e,t)))},log:e=>{C(1,I(e)+`
5
- `)},logi:e=>{C(1,String(e)+`
6
- `)},logf:e=>{C(1,String(e)+`
7
- `)},trace:(e,t,...n)=>{let r=t>0?` `+n.slice(0,t).join(`, `):``;C(1,`trace: ${I(e)}${r}\n`)},seed:()=>Date.now()*Math.random(),abort:(e,t,n,r)=>{let i=I(e),a=I(t);throw(i||a)&&C(2,`abort: ${i||`aborted`} at ${a||this.script}:${n||0}:${r||0}\n`),this.exitCode=134,{_wasmExit:!0,code:134}}},{get(e,t){return t in e?e[t]:()=>0}})};try{let t=await WebAssembly.compile(e);for(let e of WebAssembly.Module.imports(t))if(e.kind===`memory`){let t=new WebAssembly.Memory({initial:1,maximum:256});y=t,L[e.module]||(L[e.module]={}),L[e.module][e.name]=t}let n=await WebAssembly.instantiate(t,L);n.exports.memory&&(y=n.exports.memory);let r=n.exports._start||n.exports.__wasi_command||n.exports.main||n.exports.run;if(r)try{await r()}catch(e){(!e||!e._wasmExit)&&(this.stdErr=`${this.script}: runtime error: ${e?.message||String(e)}`,this.exitCode=1)}else{let e=Object.entries(n.exports).filter(([,e])=>typeof e==`function`).map(([e])=>e),t=e.length>0?` (module is a library exporting: ${e.join(`, `)})`:``;this.stdErr=`${this.script}: no CLI entry point found (expected _start, main, or run)${t}`,this.exitCode=1}}catch(e){(!e||!e._wasmExit)&&(this.stdErr=`${this.script}: ${e?.message||String(e)}`,this.exitCode=1)}finally{for(let e of j.values())N(e)}w();let R=this.arguments||[];if(!(this.result&&this.result.getStdOutput&&this.result.getStdOutput().length>0)&&(this.exitCode===0||this.exitCode===void 0)){let t=(this.script||`wasm`).split(`/`).pop(),n=Object.assign({name:t,version:`wasi`,description:`WebAssembly WASI binary (${this.script})`},this._pkgMeta||{});if(R.includes(`--help`)||R.includes(`-h`)){let r=k(e);for(let e of A(t,n,r))this.stdOut=e}else (R.includes(`--version`)||R.includes(`-V`)||R.includes(`-v`))&&(this.stdOut=`${t} (${n.name} ${n.version} wasm)`)}}},w=new Map;function T(e,t){if(!e||!e.exists(t))return null;if(e.isRealFilesystem)try{let n=G();return new Uint8Array(n.readFileSync(e.absolutePath(t)))}catch{}let n=e.getFileByPath(t);if(n==null)return null;if(n instanceof Uint8Array||v!==void 0&&v.isBuffer(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(n instanceof ArrayBuffer)return new Uint8Array(n);if(typeof n==`string`){if(n.startsWith(`data:`)){let e=n.indexOf(`,`);if(e!==-1){let t=n.slice(e+1);if(v!==void 0)return new Uint8Array(v.from(t,`base64`));let r=atob(t),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}}let e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t)&255;return e}return null}function E(e,t,n,i=`application/octet-stream`){let a=n instanceof Uint8Array?n:new Uint8Array(n),o=new Uint8Array(a.byteLength);o.set(a);let s=new r(o.buffer,i);if(e.isRealFilesystem)try{let n=G(),r=ie(),i=e.absolutePath(t);n.mkdirSync(r.dirname(i),{recursive:!0}),n.writeFileSync(i,v.from(a.buffer,a.byteOffset,a.byteLength));return}catch{if(typeof e._setFileRaw==`function`){e._setFileRaw(t,s,!0);return}}if(typeof e._setFileRaw==`function`&&t.startsWith(`/var/lib/wbt/`)){e._setFileRaw(t,s,!0);return}e.setFileByPath(t,s,!0)}async function D(e,t,n=null){if(typeof n==`function`){let r=await n(e,t);if(r)return r}try{let t=await import(e);if(t)return t}catch{}if(t)try{return await import(t)}catch(n){if(!/^https?:\/\/esm\.sh\//i.test(t))try{return await import(`https://esm.sh/${e}`)}catch{}throw Error(`Failed to load WASM package '${e}' from ${t}: ${n.message||n}`)}throw Error(`Package '${e}' could not be loaded`)}function O(e,t=!1){let n={usage:null,options:[]};if(!e||typeof e!=`string`)return n;let r=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),i=new Set,a=t?r.findIndex(e=>/^usage:\s*(.+)/i.test(e)):-1,o=a>=0?a:0;for(let e=o;e<r.length;e++){let a=r[e];!n.usage&&/^usage:\s*(.+)/i.test(a)?n.usage=a.replace(/^usage:\s*/i,``).trim():/^(?:-[a-zA-Z0-9?]|--[a-zA-Z0-9][-a-zA-Z0-9]*)(?:\s|,|=|<|\[|$)/.test(a)&&a.length<=120&&!/^(?:-[hHvV],\s*)?--(?:help|version)\b/i.test(a)&&(!t||/^(?:-[a-zA-Z?]|--[a-zA-Z][a-zA-Z0-9-]*)(?:,\s*--?[a-zA-Z0-9-]+)?(?:\s+[<\[a-zA-Z0-9_.->\]]+)*(?:\s+[A-Za-z`'"(][A-Za-z0-9 ,.;:()'"`/<>\[\]=+$\t_-]*|)$/.test(a))&&(i.has(a)||(i.add(a),n.options.push(a)))}if(t&&n.options.length===0){let t=e.match(/--[a-z][a-z0-9-]{1,24}/g)||[];for(let e of Array.from(new Set(t)).slice(0,12))e!==`--help`&&e!==`--version`&&n.options.push(e)}return n}function k(e){let t={usage:null,options:[],exports:[],wasiImports:[]};if(!(e instanceof Uint8Array)||e.length<8)return t;try{if(typeof WebAssembly<`u`&&WebAssembly.Module){let n=new WebAssembly.Module(e);t.exports=WebAssembly.Module.exports(n).filter(e=>e.kind===`function`).map(e=>e.name),t.wasiImports=WebAssembly.Module.imports(n).filter(e=>e.module.startsWith(`wasi_`)).map(e=>e.name)}}catch{}try{let n=[],r=``;for(let t=0;t<e.length;t++){let i=e[t];i>=32&&i<=126||i===9||i===10?r+=String.fromCharCode(i):(r.length>=4&&n.push(r),r=``)}r.length>=4&&n.push(r);let i=O(n.join(`
8
- `),!0);t.usage=i.usage,t.options=i.options}catch{}return t}function A(e,t={},n=null){let r=t.name||e,i=t.version||`wasm`,a=t.description||`WebAssembly binary`,o=t&&typeof t.repl==`object`?t.repl:t.repl?{}:null,s=n&&n.usage||t.usage,c=s?s.replace(/%s/g,e):null,l=o?`${e} [options] ${o.evalFlag?`[${o.evalFlag} <code>] `:``}[file] [args...]`:`${e} [options] [args...]`,u=[`${e} (${r} ${i} wasm) — ${a}`,`Usage: ${c||l}`];t.details&&u.push(``,t.details),u.push(``,`Options:`);let d=n&&n.options&&n.options.length>0?n.options:Array.isArray(t.options)?t.options:[];if(d.length>0)for(let e of d)u.push(` ${e}`);else o&&(o.evalFlag&&u.push(` ${o.evalFlag.padEnd(20)}Evaluate inline code and print result`),u.push(` (no arguments) Start interactive ${e} REPL shell`));return u.push(` -h, --help Show this help message and exit`),u.push(` -V, --version Show WebAssembly binary version and exit`),n&&n.exports&&n.exports.length>0&&u.push(``,`WASM Exports: ${n.exports.join(`, `)}`),Array.isArray(t.aliases)&&t.aliases.length>0&&u.push(``,`Aliases: ${t.aliases.join(`, `)}`),(t.homepage||t.cdnUrl||t.wasmUrl)&&u.push(`Source: ${t.homepage||t.cdnUrl||t.wasmUrl}`),u}function j(e,t={},n=null){let r=q(),i=(n||e.bin||e.name).toLowerCase();class a extends r{static get name(){return i}get name(){return i}get requiresFilesystem(){return!0}async run(){let n=[...this.arguments||[]],r=n.includes(`--help`)||n.includes(`-h`),a=!r&&(n.includes(`--version`)||n.includes(`-V`)||n.includes(`-v`));this._inspectedWasm=null,this._persistedWasmBytes=e.wasmPath?T(this.context&&this.context.fs||this.fs,e.wasmPath):null,r&&this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0&&(this._inspectedWasm=k(this._persistedWasmBytes));try{if(e.type===`wasm`&&(this._persistedWasmBytes||e.wasmUrl)&&!t.moduleLoader){let t=this._persistedWasmBytes||await this._fetchWasmBytes(e.wasmUrl);r&&(this._inspectedWasm=k(t)),await this._runRawWasmBytes(t,n)}else{let o=e.cdnUrl||e.wasmUrl||`https://esm.sh/${e.name}`,s=typeof globalThis.fetch==`function`?globalThis.fetch:null;if(s&&this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0&&typeof Response<`u`){let t=this._persistedWasmBytes,n=e.wasmUrl||``;globalThis.fetch=async(e,r)=>{let i=typeof e==`string`?e:e&&e.url?e.url:``;return i&&(i===n||!/^https?:\/\//i.test(i)&&/\.wasm(\?.*)?$/i.test(i))?new Response(t,{status:200,headers:{"Content-Type":`application/wasm`}}):s(e,r)}}let c,l;try{c=await D(e.name,o,t.moduleLoader),l=c&&c.default!==void 0?c.default:c,l&&typeof l.then==`function`&&(l=await l)}finally{s&&(globalThis.fetch=s)}if(l instanceof Uint8Array||l instanceof ArrayBuffer){let e=l instanceof Uint8Array?l:new Uint8Array(l);r&&(this._inspectedWasm=k(e)),await this._runRawWasmBytes(e,n)}else if(l&&(l.wasmBytes instanceof Uint8Array||l.wasm instanceof Uint8Array)){let e=l.wasmBytes||l.wasm;r&&(this._inspectedWasm=k(e)),await this._runRawWasmBytes(e,n)}else if(typeof l==`function`)await this._runFunctionOrEmscripten(l,n,r);else if(l&&typeof l==`object`){l.ready&&await l.ready,r&&(l.HEAPU8 instanceof Uint8Array||l.wasmBinary instanceof Uint8Array)&&(this._inspectedWasm=k(l.wasmBinary||l.HEAPU8));let t=l.main||l.run||l.callMain||l.exec;if(typeof t==`function`)await this._invokeCliFunction(t.bind(l),n);else if(l.promised||typeof l.raw==`function`||typeof l.json==`function`){let e=l.promised?await l.promised:l,t=n.filter(e=>e.startsWith(`-`)),i=n.filter(e=>!e.startsWith(`-`)),o=i.shift()||`.`,s=this._createIoBridge(n,[],[]),c=i.length>0?s.readFile(i[0])||``:s.stdin||(r||a?`{}`:``),u=typeof e.raw==`function`?e.raw(c,o,t):!r&&!a?JSON.stringify(e.json(JSON.parse(c||`null`),o)):null;u!=null&&String(u).replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>{this.stdOut=e})}else if(!r&&!a){this.stdErr=`${i}: unsupported WASM module format for '${e.name}'`,this.exitCode=1;return}}else if(!r&&!a){this.stdErr=`${i}: unsupported WASM module format for '${e.name}'`,this.exitCode=1;return}}}catch(e){if(!r&&!a){if(e&&typeof e.status==`number`){this.exitCode=e.status;return}this.stdErr=`${i}: ${e.message||e}`,this.exitCode=1;return}}if(r||a){let t=this.result&&this.result.getStdOutput?this.result.getStdOutput():[],n=t.map(e=>e.string).join(`
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.fs.isRealFilesystem?{useRealFilesystem:!0}:{filesystem:this.context.fs.getRaw(),permissions:this.context.fs.getRawPermissions()};this.sandbox=new globalThis.shell({cwd:this.context.fs.cwd,...e,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 t=this.script.split(/\r?\n/);if(!r(t[0])){let e=t[0].startsWith(`#!`)?t[0].slice(2).split(/\s/)[0]:t[0];return Promise.reject(`${e}: bad interpreter: No such file or directory`)}let n=this._parseLines(t.slice(1));return this._executeNodes(n).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){if(this.context.fs.isRealFilesystem&&t)try{let n=t.readFileSync(this.context.fs.absolutePath(e)),r=new Uint8Array(n);return Promise.resolve({bytes:r,isWat:this._isWat(e,r)})}catch(t){return Promise.reject(Error(`${e}: ${t.message}`))}let n=this.context.fs.getFileByPath(e);if(n==null)return Promise.reject(Error(`${e}: No such file or directory`));let r=this._contentToBytes(n);return Promise.resolve({bytes:r,isWat:this._isWat(e,r)})}_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
+ `);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
+ `)},logi:e=>{w(1,String(e)+`
6
+ `)},logf:e=>{w(1,String(e)+`
7
+ `)},trace:(e,t,...n)=>{let r=t>0?` `+n.slice(0,t).join(`, `):``;w(1,`trace: ${L(e)}${r}\n`)},seed:()=>Date.now()*Math.random(),abort:(e,t,n,r)=>{let i=L(e),a=L(t);throw(i||a)&&w(2,`abort: ${i||`aborted`} at ${a||this.script}:${n||0}:${r||0}\n`),this.exitCode=134,{_wasmExit:!0,code:134}}},{get(e,t){return t in e?e[t]:()=>0}})};try{let t=await WebAssembly.compile(e);for(let e of WebAssembly.Module.imports(t))if(e.kind===`memory`){let t=new WebAssembly.Memory({initial:1,maximum:256});C=t,R[e.module]||(R[e.module]={}),R[e.module][e.name]=t}let n=await WebAssembly.instantiate(t,R);n.exports.memory&&(C=n.exports.memory);let r=n.exports._start||n.exports.__wasi_command||n.exports.main||n.exports.run;if(r)try{await r()}catch(e){(!e||!e._wasmExit)&&(this.stdErr=`${this.script}: runtime error: ${e?.message||String(e)}`,this.exitCode=1)}else{let e=Object.entries(n.exports).filter(([,e])=>typeof e==`function`).map(([e])=>e),t=e.length>0?` (module is a library exporting: ${e.join(`, `)})`:``;this.stdErr=`${this.script}: no CLI entry point found (expected _start, main, or run)${t}`,this.exitCode=1}}catch(e){(!e||!e._wasmExit)&&(this.stdErr=`${this.script}: ${e?.message||String(e)}`,this.exitCode=1)}finally{for(let e of M.values())P(e)}T();let z=this.arguments||[];if(!(this.result&&this.result.getStdOutput&&this.result.getStdOutput().length>0)&&(this.exitCode===0||this.exitCode===void 0)){let t=(this.script||`wasm`).split(`/`).pop(),n=Object.assign({name:t,version:`wasi`,description:`WebAssembly WASI binary (${this.script})`},this._pkgMeta||{});if(z.includes(`--help`)||z.includes(`-h`)){let r=k(e);for(let e of A(t,n,r))this.stdOut=e}else (z.includes(`--version`)||z.includes(`-V`)||z.includes(`-v`))&&(this.stdOut=`${t} (${n.name} ${n.version} wasm)`)}}},w=new Map;function T(e,t){if(!e||!e.exists(t))return null;if(e.isRealFilesystem)try{let n=G();return new Uint8Array(n.readFileSync(e.absolutePath(t)))}catch{}let n=e.getFileByPath(t);if(n==null)return null;if(n instanceof Uint8Array||v!==void 0&&v.isBuffer(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(n instanceof ArrayBuffer)return new Uint8Array(n);if(typeof n==`string`){if(n.startsWith(`data:`)){let e=n.indexOf(`,`);if(e!==-1){let t=n.slice(e+1);if(v!==void 0)return new Uint8Array(v.from(t,`base64`));let r=atob(t),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}}let e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t)&255;return e}return null}function E(e,t,n,i=`application/octet-stream`){let a=n instanceof Uint8Array?n:new Uint8Array(n),o=new Uint8Array(a.byteLength);o.set(a);let s=new r(o.buffer,i);if(e.isRealFilesystem)try{let n=G(),r=ie(),i=e.absolutePath(t);n.mkdirSync(r.dirname(i),{recursive:!0}),n.writeFileSync(i,v.from(a.buffer,a.byteOffset,a.byteLength));return}catch{if(typeof e._setFileRaw==`function`){e._setFileRaw(t,s,!0);return}}if(typeof e._setFileRaw==`function`&&t.startsWith(`/var/lib/wbt/`)){e._setFileRaw(t,s,!0);return}e.setFileByPath(t,s,!0)}async function D(e,t,n=null){if(typeof n==`function`){let r=await n(e,t);if(r)return r}try{let t=await import(e);if(t)return t}catch{}if(t)try{return await import(t)}catch(n){if(!/^https?:\/\/esm\.sh\//i.test(t))try{return await import(`https://esm.sh/${e}`)}catch{}throw Error(`Failed to load WASM package '${e}' from ${t}: ${n.message||n}`)}throw Error(`Package '${e}' could not be loaded`)}function O(e,t=!1){let n={usage:null,options:[]};if(!e||typeof e!=`string`)return n;let r=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),i=new Set,a=t?r.findIndex(e=>/^usage:\s*(.+)/i.test(e)):-1,o=a>=0?a:0;for(let e=o;e<r.length;e++){let a=r[e];!n.usage&&/^usage:\s*(.+)/i.test(a)?n.usage=a.replace(/^usage:\s*/i,``).trim():/^(?:-[a-zA-Z0-9?]|--[a-zA-Z0-9][-a-zA-Z0-9]*)(?:\s|,|=|<|\[|$)/.test(a)&&a.length<=120&&!/^(?:-[hHvV],\s*)?--(?:help|version)\b/i.test(a)&&(!t||/^(?:-[a-zA-Z?]|--[a-zA-Z][a-zA-Z0-9-]*)(?:,\s*--?[a-zA-Z0-9-]+)?(?:\s+[<\[a-zA-Z0-9_.->\]]+)*(?:\s+[A-Za-z`'"(][A-Za-z0-9 ,.;:()'"`/<>\[\]=+$\t_-]*|)$/.test(a))&&(i.has(a)||(i.add(a),n.options.push(a)))}if(t&&n.options.length===0){let t=e.match(/--[a-z][a-z0-9-]{1,24}/g)||[];for(let e of Array.from(new Set(t)).slice(0,12))e!==`--help`&&e!==`--version`&&n.options.push(e)}return n}function k(e){let t={usage:null,options:[],exports:[],wasiImports:[]};if(!(e instanceof Uint8Array)||e.length<8)return t;try{if(typeof WebAssembly<`u`&&WebAssembly.Module){let n=new WebAssembly.Module(e);t.exports=WebAssembly.Module.exports(n).filter(e=>e.kind===`function`).map(e=>e.name),t.wasiImports=WebAssembly.Module.imports(n).filter(e=>e.module.startsWith(`wasi_`)).map(e=>e.name)}}catch{}try{let n=[],r=``;for(let t=0;t<e.length;t++){let i=e[t];i>=32&&i<=126||i===9||i===10?r+=String.fromCharCode(i):(r.length>=4&&n.push(r),r=``)}r.length>=4&&n.push(r);let i=O(n.join(`
8
+ `),!0);t.usage=i.usage,t.options=i.options}catch{}return t}function A(e,t={},n=null){let r=t.name||e,i=t.version||`wasm`,a=t.description||`WebAssembly binary`,o=t&&typeof t.repl==`object`?t.repl:t.repl?{}:null,s=n&&n.usage||t.usage,c=s?s.replace(/%s/g,e):null,l=o?`${e} [options] ${o.evalFlag?`[${o.evalFlag} <code>] `:``}[file] [args...]`:`${e} [options] [args...]`,u=[`${e} (${r} ${i} wasm) — ${a}`,`Usage: ${c||l}`];t.details&&u.push(``,t.details),u.push(``,`Options:`);let d=n&&n.options&&n.options.length>0?n.options:Array.isArray(t.options)?t.options:[];if(d.length>0)for(let e of d)u.push(` ${e}`);else o&&(o.evalFlag&&u.push(` ${o.evalFlag.padEnd(20)}Evaluate inline code and print result`),u.push(` (no arguments) Start interactive ${e} REPL shell`));return u.push(` -h, --help Show this help message and exit`),u.push(` -V, --version Show WebAssembly binary version and exit`),n&&n.exports&&n.exports.length>0&&u.push(``,`WASM Exports: ${n.exports.join(`, `)}`),Array.isArray(t.aliases)&&t.aliases.length>0&&u.push(``,`Aliases: ${t.aliases.join(`, `)}`),(t.homepage||t.cdnUrl||t.wasmUrl)&&u.push(`Source: ${t.homepage||t.cdnUrl||t.wasmUrl}`),u}function j(e,t={},n=null){let r=q(),i=(n||e.bin||e.name).toLowerCase();class a extends r{static get name(){return i}get name(){return i}get requiresFilesystem(){return!0}async run(){let n=[...this.arguments||[]],r=n.includes(`--help`)||n.includes(`-h`),a=!r&&(n.includes(`--version`)||n.includes(`-V`)||n.includes(`-v`));this._inspectedWasm=null,this._persistedWasmBytes=e.wasmPath?T(this.context&&this.context.fs||this.fs,e.wasmPath):null,r&&this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0&&(this._inspectedWasm=k(this._persistedWasmBytes));try{if((e.type===`wasm`||e.type===`custom-wasm`)&&(this._persistedWasmBytes||e.wasmUrl)){let i=this._persistedWasmBytes;if(!i&&t.moduleLoader)try{let n=await t.moduleLoader(e.name,e.cdnUrl);n instanceof Uint8Array||n instanceof ArrayBuffer?i=n instanceof Uint8Array?n:new Uint8Array(n):n&&(n.wasmBytes||n.wasm||n.wasmBinary)&&(i=n.wasmBytes||n.wasm||n.wasmBinary)}catch{}if(!i&&e.wasmUrl&&(i=await this._fetchWasmBytes(e.wasmUrl)),i){r&&(this._inspectedWasm=k(i)),await this._runRawWasmBytes(i,n);return}}else{let o=e.cdnUrl||e.wasmUrl||`https://esm.sh/${e.name}`,s=typeof globalThis.fetch==`function`?globalThis.fetch:null;if(s&&this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0&&typeof Response<`u`){let t=this._persistedWasmBytes,n=e.wasmUrl||``;globalThis.fetch=async(e,r)=>{let i=typeof e==`string`?e:e&&e.url?e.url:``;return i&&(i===n||!/^https?:\/\//i.test(i)&&/\.wasm(\?.*)?$/i.test(i))?new Response(t,{status:200,headers:{"Content-Type":`application/wasm`}}):s(e,r)}}let c,l;try{c=await D(e.name,o,t.moduleLoader),l=c&&c.default!==void 0?c.default:c,l&&typeof l.then==`function`&&(l=await l)}finally{s&&(globalThis.fetch=s)}if(l instanceof Uint8Array||l instanceof ArrayBuffer){let e=l instanceof Uint8Array?l:new Uint8Array(l);r&&(this._inspectedWasm=k(e)),await this._runRawWasmBytes(e,n)}else if(l&&(l.wasmBytes instanceof Uint8Array||l.wasm instanceof Uint8Array)){let e=l.wasmBytes||l.wasm;r&&(this._inspectedWasm=k(e)),await this._runRawWasmBytes(e,n)}else if(typeof l==`function`)await this._runFunctionOrEmscripten(l,n,r);else if(l&&typeof l==`object`){l.ready&&await l.ready,r&&(l.HEAPU8 instanceof Uint8Array||l.wasmBinary instanceof Uint8Array)&&(this._inspectedWasm=k(l.wasmBinary||l.HEAPU8));let t=l.main||l.run||l.callMain||l.exec;if(typeof t==`function`)await this._invokeCliFunction(t.bind(l),n);else if(l.promised||typeof l.raw==`function`||typeof l.json==`function`){let e=l.promised?await l.promised:l,t=n.filter(e=>e.startsWith(`-`)),i=n.filter(e=>!e.startsWith(`-`)),o=i.shift()||`.`,s=this._createIoBridge(n,[],[]),c=i.length>0?s.readFile(i[0])||``:s.stdin||(r||a?`{}`:``),u=typeof e.raw==`function`?e.raw(c,o,t):!r&&!a?JSON.stringify(e.json(JSON.parse(c||`null`),o)):null;u!=null&&String(u).replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>{this.stdOut=e})}else if(!r&&!a){this.stdErr=`${i}: unsupported WASM module format for '${e.name}'`,this.exitCode=1;return}}else if(!r&&!a){this.stdErr=`${i}: unsupported WASM module format for '${e.name}'`,this.exitCode=1;return}}}catch(e){if(!r&&!a){if(e&&typeof e.status==`number`){this.exitCode=e.status;return}this.stdErr=`${i}: ${e.message||e}`,this.exitCode=1;return}}if(r||a){let t=this.result&&this.result.getStdOutput?this.result.getStdOutput():[],n=t.map(e=>e.string).join(`
9
9
  `),o=r?O(n):null,s=r&&!!(o&&(o.usage||o.options.length>0)||t.some(e=>/\b(usage|options):/i.test(e.string))),c=t.filter(e=>e.type===`out`).map(e=>e.string),l=a&&c.length>0&&(this.exitCode===0||this.exitCode===void 0);if(r)if(s){let e=t.map(e=>e.string);this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0;for(let t of e)this.stdOut=t}else{this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0;for(let t of A(i,e,this._inspectedWasm))this.stdOut=t}else a&&!l?(this.result&&Array.isArray(this.result.std)&&(this.result.std.length=0),this.exitCode=0,this.stdOut=`${i} (${e.name} ${e.version||`wasm`} wasm)`):this.exitCode=0}}async _fetchWasmBytes(e){if(w.has(e))return w.get(e);let n=t.fetch||(typeof fetch==`function`?fetch:null);if(!n)throw Error(`fetch is not available in this environment`);let r=await n(e);if(!r||!r.ok)throw Error(`HTTP ${r?r.status:`error`} fetching ${e}`);let i=new Uint8Array(await r.arrayBuffer());return w.set(e,i),i}async _runRawWasmBytes(t,n){let r=new C(i,n,this.context);r.script=i,r.arguments=n,r.context=this.context,r.fs=this.fs,r._pkgMeta=e,this.stdin!==void 0&&(r.stdin=this.stdin),await r._runWasm(t);for(let e of r.result.getStdOutput())e.type===`out`?this.stdOut=e.string:e.type===`err`&&(this.stdErr=e.string);this.exitCode=r.result.getExitCode()}_createIoBridge(t,n,r){let a=e=>({write(t){(t instanceof Uint8Array?new TextDecoder().decode(t):String(t??``)).replace(/\r?\n$/,``).split(/\r?\n/).forEach(t=>e.push(t))}});return{binName:i,args:t,stdin:this.stdin!==void 0&&this.stdin!==null?String(this.stdin):``,fs:this.fs,context:this.context,wasmPath:e.wasmPath||null,wasmBytes:this._persistedWasmBytes||null,stdout:Object.assign(e=>n.push(String(e)),a(n)),stderr:Object.assign(e=>r.push(String(e)),a(r)),readFile:(e,t)=>{if(!this.fs)return null;let n=t&&t!==`.`&&!e.startsWith(`/`)?`${t.replace(/\/+$/,``)}/${e}`:e,r=this.fs.getFileByPath(n)??this.fs.getFileByPath(e);return r==null?null:typeof r==`string`?r:new TextDecoder().decode(r)},readBytes:e=>T(this.fs,e),writeFile:(e,t,n)=>{if(!this.fs)return;let r=n&&n!==`.`&&!e.startsWith(`/`)?`${n.replace(/\/+$/,``)}/${e}`:e;if(t instanceof Uint8Array||ArrayBuffer.isView(t)){let e=r.endsWith(`.wasm`)?`application/wasm`:`application/octet-stream`;E(this.fs,r,t,e)}else this.fs.setFileByPath(r,String(t),!0);if(r.endsWith(`.wasm`)||r.endsWith(`.wat`))try{this.context&&this.context.fs?this.context.fs.setMode(r,493):this.fs.setMode(r,493)}catch{}},listFiles:(e,t)=>{if(!this.fs)return[];let n=t&&t!==`.`&&!e.startsWith(`/`)?`${t.replace(/\/+$/,``)}/${e}`:e,r=this.fs.getFileByPath(n);return r&&typeof r==`object`&&!(r instanceof Uint8Array)?Object.keys(r):[]}}}async _runFunctionOrEmscripten(t,n,r=!1){let i=[],a=[],o=new TextEncoder().encode(this.stdin||``),s=0,c=new Set,l={arguments:n,noInitialRun:!0,...this._persistedWasmBytes&&this._persistedWasmBytes.byteLength>0?{wasmBinary:this._persistedWasmBytes}:{},...e.wasmUrl?{locateFile:t=>t.endsWith(`.wasm`)?e.wasmUrl:t}:{},print:e=>{i.push(String(e))},printErr:e=>{a.push(String(e))},stdin:()=>s<o.length?o[s++]:null,preRun:[e=>{e&&e.FS&&(c=this._syncBrshToEmscriptenFs(e.FS,n))}]},u=this._createIoBridge(n,i,a),d;try{d=t.prototype&&t.prototype.constructor===t&&Object.getOwnPropertyNames(t.prototype).length>1?new t(l,u):await t(l,u)}catch(e){if(e&&typeof e.status==`number`)this.exitCode=e.status;else throw e}if(d&&typeof d==`object`)if(r&&(d.wasmBinary instanceof Uint8Array||d.HEAPU8 instanceof Uint8Array)&&(this._inspectedWasm=k(d.wasmBinary||d.HEAPU8)),typeof d.callMain==`function`){d.FS&&c.size===0&&(c=this._syncBrshToEmscriptenFs(d.FS,n));try{let e=await d.callMain(n);typeof e==`number`&&e!==0&&(this.exitCode=e)}catch(e){e&&typeof e.status==`number`?this.exitCode=e.status:(a.push(e.message||String(e)),this.exitCode=1)}d.FS&&this._syncEmscriptenFsToBrsh(d.FS,n,c)}else if(typeof d.exec==`function`&&typeof d.writeFile==`function`)await this._runVirtualFsInstance(d,n,i,a);else if(typeof d.main==`function`||typeof d.run==`function`){let e=(d.main||d.run).bind(d);await this._invokeCliFunction(e,n,i,a)}else !r&&!isVersion&&typeof d.Database==`function`?this._runSqlJsDatabase(d,n,u,i):(typeof d.stdout==`string`&&d.stdout&&d.stdout.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)),typeof d.stderr==`string`&&d.stderr&&d.stderr.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>a.push(e)),d.error&&a.length===0&&(a.push(d.error.message||String(d.error)),this.exitCode=1),typeof d.exitCode==`number`&&(this.exitCode=d.exitCode));else typeof d==`string`?d.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)):typeof d==`number`&&(this.exitCode=d);i.forEach(e=>{this.stdOut=e}),a.forEach(e=>{this.stdErr=e})}_runSqlJsDatabase(e,t,n,r){let i=`list`,a=`:memory:`,o=null,s=[];for(let e=0;e<t.length;e++){let n=t[e];n===`-table`||n===`--table`||n===`-box`?i=`table`:n===`-csv`||n===`--csv`?i=`csv`:n===`-cmd`&&e+1<t.length?o=t[++e]:n.startsWith(`-`)||s.push(n)}if(s.length===1?/^\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|PRAGMA|WITH|BEGIN|EXPLAIN|\.)\b/i.test(s[0])?o=s[0]:a=s[0]:s.length>=2&&(a=s[0],o=s.slice(1).join(` `)),!o&&n.stdin&&n.stdin.trim()&&(o=n.stdin.trim()),!o)return;let c=a===`:memory:`?null:n.readBytes(a),l=c&&c.byteLength>0?new e.Database(c):new e.Database;try{if(o.trim()===`.tables`){let e=l.exec(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name`),t=e[0]&&e[0].values?e[0].values.map(e=>e[0]):[];t.length>0&&r.push(t.join(` `))}else{let e=l.exec(o);for(let t of e){let e=(t.columns||[]).map(String),n=t.values||[];if(i===`table`&&e.length>0){let t=e.map(e=>e.length),i=n.map(n=>e.map((e,r)=>{let i=n[r]==null?`NULL`:String(n[r]);return i.length>t[r]&&(t[r]=i.length),i}));r.push(e.map((e,n)=>` `+e.padEnd(t[n])+` `).join(`|`)),r.push(t.map(e=>`-`.repeat(e+2)).join(`+`)),i.forEach(e=>r.push(e.map((e,n)=>` `+e.padEnd(t[n])+` `).join(`|`)))}else if(i===`csv`){let t=e=>{let t=e==null?``:String(e);return/[",\r\n]/.test(t)?`"`+t.replace(/"/g,`""`)+`"`:t};e.length>0&&r.push(e.map(t).join(`,`)),n.forEach(n=>r.push(e.map((e,r)=>t(n[r])).join(`,`)))}else n.forEach(t=>r.push(e.map((e,n)=>t[n]==null?``:String(t[n])).join(`|`)))}}a!==`:memory:`&&n.writeFile(a,l.export())}finally{l.close()}}async _runVirtualFsInstance(t,n,r,i){typeof t.on==`function`&&t.on(`log`,({message:e})=>{e&&r.push(e)}),!t.loaded&&typeof t.load==`function`&&await t.load(e.coreUrl?{coreURL:e.coreUrl}:void 0);let a=new Set,o=[];for(let e of n)if(!e.startsWith(`-`)&&(o.push(e),this.fs.exists(e))){let n=T(this.fs,e);n&&(await t.writeFile(e,n),a.add(e))}let s=await t.exec(n);for(let e of o)if(!a.has(e))try{if(typeof t.readFile==`function`){let n=await t.readFile(e);n&&E(this.fs,e,n)}}catch{}typeof s==`number`&&s!==0&&(this.exitCode=s,i.length===0&&r.length>0&&i.push(...r.splice(0,r.length)))}async _invokeCliFunction(e,t,n=null,r=null){let i=n||[],a=r||[],o=await e(t,this._createIoBridge(t,i,a));typeof o==`string`?o.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)):typeof o==`number`?this.exitCode=o:o&&typeof o==`object`&&(typeof o.stdout==`string`&&o.stdout&&o.stdout.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>i.push(e)),typeof o.stderr==`string`&&o.stderr&&o.stderr.replace(/\r?\n$/,``).split(/\r?\n/).forEach(e=>a.push(e)),o.error?(a.length===0&&a.push(o.error.message||String(o.error)),this.exitCode=typeof o.exitCode==`number`?o.exitCode:1):typeof o.exitCode==`number`&&(this.exitCode=o.exitCode)),n||(i.forEach(e=>{this.stdOut=e}),a.forEach(e=>{this.stdErr=e}))}_syncBrshToEmscriptenFs(e,t){let n=new Set;if(!this.fs||!e||typeof e.writeFile!=`function`)return n;for(let r of t)if(!r.startsWith(`-`)&&this.fs.exists(r)){let t=T(this.fs,r);if(t)try{e.writeFile(r,t),n.add(r)}catch{}}return n}_syncEmscriptenFsToBrsh(e,t,n){if(!(!this.fs||!e||typeof e.readFile!=`function`)){for(let r of t)if(!(r.startsWith(`-`)||n.has(r)))try{let t=e.readFile(r);if(t){let e=r.endsWith(`.wasm`)?`application/wasm`:`application/octet-stream`;if(E(this.fs,r,t,e),r.endsWith(`.wasm`)||r.endsWith(`.wat`))try{this.context&&this.context.fs?this.context.fs.setMode(r,493):this.fs.setMode(r,493)}catch{}}}catch{}}}}return a}C.readBytesFromFs=T,C.writeBytesToFs=E,C.loadModule=D,C.extractHelpFromText=O,C.inspectWasmBytes=k,C.formatWasmHelp=A,C.createGenericWasmCommand=j,C.createCommand=j,t.exports=C})),se=t(((e,t)=>{var n=W(),r=class extends n{static get name(){return`test`}get requiresFilesystem(){return!0}run(){let e=[...this.arguments];return e[e.length-1]===`]`&&e.pop(),this._evaluate(e)||(this.exitCode=1),Promise.resolve()}_evaluate(e){if(e.length===0)return!1;let t=e.indexOf(`-o`);if(t!==-1)return this._evaluate(e.slice(0,t))||this._evaluate(e.slice(t+1));let n=e.indexOf(`-a`);if(n!==-1)return this._evaluate(e.slice(0,n))&&this._evaluate(e.slice(n+1));if(e[0]===`!`)return!this._evaluate(e.slice(1));if(e.length===1)return e[0].length>0;if(e.length===2){let[t,n]=e;switch(t){case`-n`:return n.length>0;case`-z`:return n.length===0;case`-e`:return this.fs?this.fs.getFileByPath(n)!=null:!1;case`-f`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e!=null&&e.constructor!==Object}case`-d`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e!=null&&e.constructor===Object}case`-r`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&292)!=0}case`-w`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&146)!=0}case`-x`:{if(!this.fs)return!1;let e=this.fs.getMode(n);return e!==null&&(e&73)!=0}case`-s`:{if(!this.fs)return!1;let e=this.fs.getFileByPath(n);return e==null||e.constructor===Object?!1:e.toString().length>0}default:return!1}}if(e.length===3){let[t,n,r]=e;switch(n){case`=`:case`==`:return t===r;case`!=`:return t!==r;case`-eq`:return parseInt(t)===parseInt(r);case`-ne`:return parseInt(t)!==parseInt(r);case`-lt`:return parseInt(t)<parseInt(r);case`-le`:return parseInt(t)<=parseInt(r);case`-gt`:return parseInt(t)>parseInt(r);case`-ge`:return parseInt(t)>=parseInt(r);default:return!1}}return!1}};t.exports={Test:r,TestBracket:class extends r{static get name(){return`[`}}}})),ce=t(((e,t)=>{var n=W();t.exports=class extends n{static get name(){return`cat`}get requiresFilesystem(){return!0}run(){let e=!1,t=!1,n=!1,r=[];for(let i of this.arguments)if(i.startsWith(`-`)&&i.length>1)for(let r of i.slice(1))r===`n`?e=!0:r===`b`?(t=!0,e=!1):r===`s`&&(n=!0);else r.push(i);let i=[];if(r.length===0){let e=typeof this.stdin==`string`?this.stdin:null;if(e==null)return this.stdErr=`cat: no file specified`,this.exitCode=1,Promise.resolve();i.push(e)}else for(let e of r){if(e===`-`){i.push(typeof this.stdin==`string`?this.stdin:``);continue}let t=this.fs.getFileByPath(e);if(t==null){let t=this.fs.exists(e)?`Permission denied`:`No such file or directory`;return this.stdErr=`${e}: ${t}`,this.exitCode=1,Promise.resolve()}if(t.constructor===Object)return this.stdErr=`${e}: Is a directory`,this.exitCode=1,Promise.resolve();i.push(t.toString())}let a=i.join(``);a.endsWith(`
10
10
  `)&&(a=a.slice(0,-1));let o=a.split(`
11
11
  `);if(n&&(o=o.reduce((e,t)=>(t===``&&e.length>0&&e[e.length-1]===``||e.push(t),e),[])),t||e){let e=0;o=o.map(n=>t&&n===``?n:(e++,`${String(e).padStart(6)}\t${n}`))}return o.forEach(e=>this.stdOut=e),Promise.resolve()}}})),le=t(((e,t)=>{function n(e){return typeof e==`object`&&!!e}function r(e){return n(e)&&typeof e.length==`number`}function i(e){return Array.isArray(e)?e:e===void 0?[]:r(e)||e instanceof Set?Array.from(e):[e]}t.exports=i})),ue=t(((e,t)=>{function n(e,t,...n){let r=[];if(!Array.isArray(e))throw Error(`Input must be an array`);for(let[i,a]of e.entries()){let e=[];n.forEach(t=>{typeof t==`function`?e=e.concat(t(a)):e.push(t)}),t(a)&&r.push({index:i,replaceWithValue:e})}for(let t of r.reverse()){let n=[t.index,1].concat(t.replaceWithValue);e.splice.apply(e,n)}return e}t.exports=n})),de=t((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){return!isNaN(parseFloat(e))}function n(e){return!isNaN(parseFloat(e))&&isFinite(e)}function r(e){return typeof e==`object`&&!!e&&e.constructor===Object}function i(e){return a(e)&&typeof e.length==`number`}function a(e){return typeof e==`object`&&!!e}function o(e){return e!==void 0}function s(e){return!o(e)}function c(e){return e===null}function l(e){return o(e)&&!c(e)&&!Number.isNaN(e)}function u(e){return typeof e==`function`?/^class /.test(Function.prototype.toString.call(e)):!1}function d(e){if(e===null)return!0;switch(typeof e){case`string`:case`number`:case`symbol`:case`undefined`:case`boolean`:return!0;default:return!1}}function f(e){if(e){let t=o(Promise)&&e instanceof Promise,n=e.then&&typeof e.then==`function`;return!!(t||n)}else return!1}function p(e){return e===null||!o(e)?!1:typeof e[Symbol.iterator]==`function`||typeof e[Symbol.asyncIterator]==`function`}function m(e){return typeof e==`string`}function h(e){return typeof e==`function`}function g(e){return typeof e==`function`&&e.constructor.name===`AsyncFunction`}e.default={isNumber:t,isFiniteNumber:n,isPlainObject:r,isArrayLike:i,isObject:a,isDefined:o,isUndefined:s,isNull:c,isDefinedValue:l,isClass:u,isPrimitive:d,isPromise:f,isIterable:p,isString:m,isFunction:h,isAsyncFunction:g},e.isArrayLike=i,e.isAsyncFunction=g,e.isClass=u,e.isDefined=o,e.isDefinedValue=l,e.isFiniteNumber=n,e.isFunction=h,e.isIterable=p,e.isNull=c,e.isNumber=t,e.isObject=a,e.isPlainObject=r,e.isPrimitive=d,e.isPromise=f,e.isString=m,e.isUndefined=s})),fe,pe=e((()=>{fe=globalThis||self})),Y=t(((e,t)=>{pe();var n=1/0,r=`[object Symbol]`,i=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,a=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,o=`\\ud800-\\udfff`,s=`\\u0300-\\u036f\\ufe20-\\ufe23`,c=`\\u20d0-\\u20f0`,l=`\\u2700-\\u27bf`,u=`a-z\\xdf-\\xf6\\xf8-\\xff`,d=`\\xac\\xb1\\xd7\\xf7`,f=`\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf`,p=`\\u2000-\\u206f`,m=` \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000`,h=`A-Z\\xc0-\\xd6\\xd8-\\xde`,g=`\\ufe0e\\ufe0f`,_=d+f+p+m,v=`['’]`,y=`[`+o+`]`,b=`[`+_+`]`,x=`[`+s+c+`]`,S=`\\d+`,C=`[`+l+`]`,w=`[`+u+`]`,T=`[^`+o+_+S+l+u+h+`]`,E=`\\ud83c[\\udffb-\\udfff]`,D=`(?:`+x+`|`+E+`)`,O=`[^`+o+`]`,k=`(?:\\ud83c[\\udde6-\\uddff]){2}`,A=`[\\ud800-\\udbff][\\udc00-\\udfff]`,j=`[`+h+`]`,M=`\\u200d`,N=`(?:`+w+`|`+T+`)`,P=`(?:`+j+`|`+T+`)`,F=`(?:`+v+`(?:d|ll|m|re|s|t|ve))?`,I=`(?:`+v+`(?:D|LL|M|RE|S|T|VE))?`,L=D+`?`,R=`[`+g+`]?`,z=`(?:`+M+`(?:`+[O,k,A].join(`|`)+`)`+R+L+`)*`,B=R+L+z,V=`(?:`+[C,k,A].join(`|`)+`)`+B,H=`(?:`+[O+x+`?`,x,k,A,y].join(`|`)+`)`,U=RegExp(v,`g`),ee=RegExp(x,`g`),W=RegExp(E+`(?=`+E+`)|`+H+B,`g`),te=RegExp([j+`?`+w+`+`+F+`(?=`+[b,j,`$`].join(`|`)+`)`,P+`+`+I+`(?=`+[b,j+N,`$`].join(`|`)+`)`,j+`?`+N+`+`+F,j+`+`+I,S,V].join(`|`),`g`),ne=RegExp(`[`+M+o+s+c+g+`]`),re=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,G={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`Ae`,æ:`ae`,Þ:`Th`,þ:`th`,ß:`ss`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`IJ`,ij:`ij`,Œ:`Oe`,œ:`oe`,ʼn:`'n`,ſ:`ss`},ie=typeof fe==`object`&&fe&&fe.Object===Object&&fe,ae=typeof self==`object`&&self&&self.Object===Object&&self,K=ie||ae||Function(`return this`)();function q(e,t,n,r){var i=-1,a=e?e.length:0;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function J(e){return e.split(``)}function oe(e){return e.match(i)||[]}function se(e){return function(t){return e?.[t]}}var ce=se(G);function le(e){return ne.test(e)}function ue(e){return re.test(e)}function de(e){return le(e)?Y(e):J(e)}function Y(e){return e.match(W)||[]}function me(e){return e.match(te)||[]}var he=Object.prototype.toString,X=K.Symbol,ge=X?X.prototype:void 0,_e=ge?ge.toString:void 0;function ve(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=Array(i);++r<i;)a[r]=e[r+t];return a}function ye(e){if(typeof e==`string`)return e;if(we(e))return _e?_e.call(e):``;var t=e+``;return t==`0`&&1/e==-n?`-0`:t}function be(e,t,n){var r=e.length;return n=n===void 0?r:n,!t&&n>=r?e:ve(e,t,n)}function xe(e){return function(t){t=Te(t);var n=le(t)?de(t):void 0,r=n?n[0]:t.charAt(0),i=n?be(n,1).join(``):t.slice(1);return r[e]()+i}}function Se(e){return function(t){return q(Ae(Oe(t).replace(U,``)),e,``)}}function Ce(e){return!!e&&typeof e==`object`}function we(e){return typeof e==`symbol`||Ce(e)&&he.call(e)==r}function Te(e){return e==null?``:ye(e)}var Ee=Se(function(e,t,n){return t=t.toLowerCase(),e+(n?De(t):t)});function De(e){return ke(Te(e).toLowerCase())}function Oe(e){return e=Te(e),e&&e.replace(a,ce).replace(ee,``)}var ke=xe(`toUpperCase`);function Ae(e,t,n){return e=Te(e),t=n?void 0:t,t===void 0?ue(e)?me(e):oe(e):e.match(t)||[]}t.exports=Ee})),me=t(((e,t)=>{B();var n=le(),r=ue(),i=de(),a=Y(),o={short:/^-([^\d-])$/,long:/^--(\S+)/,combinedShort:/^-[^\d-]{2,}$/,optEquals:/^(--\S+?)=(.*)/},s=class extends Array{load(e){if(this.clear(),e&&e!==z.argv)e=n(e);else{e=z.argv.slice(0);let t=z.execArgv.some(m)?1:2;e.splice(0,t)}e.forEach(e=>this.push(String(e)))}clear(){this.length=0}expandOptionEqualsNotation(){if(this.some(e=>o.optEquals.test(e))){let e=[];this.forEach(t=>{let n=t.match(o.optEquals);n?e.push(n[1],n[2]):e.push(t)}),this.clear(),this.load(e)}}expandGetoptNotation(){this.hasCombinedShortOptions()&&r(this,o.combinedShort,c)}hasCombinedShortOptions(){return this.some(e=>o.combinedShort.test(e))}static from(e){let t=new this;return t.load(e),t}};function c(e){return e=e.slice(1),e.split(``).map(e=>`-`+e)}function l(e){return o.optEquals.test(e)}function u(e){return(o.short.test(e)||o.long.test(e))&&!o.optEquals.test(e)}function d(e){return o.long.test(e)&&!l(e)}function f(e){return o.short.test(e)?e.match(o.short)[1]:d(e)?e.match(o.long)[1]:l(e)?e.match(o.optEquals)[1].replace(/^--/,``):null}function p(e){return!(u(e)||o.combinedShort.test(e)||o.optEquals.test(e))}function m(e){return[`--eval`,`-e`].indexOf(e)>-1||e.startsWith(`--eval=`)}var h=class{constructor(e){this.name=e.name,this.type=e.type||String,this.alias=e.alias,this.multiple=e.multiple,this.lazyMultiple=e.lazyMultiple,this.defaultOption=e.defaultOption,this.defaultValue=e.defaultValue,this.group=e.group;for(let t in e)this[t]||(this[t]=e[t])}isBoolean(){return this.type===Boolean||i.isFunction(this.type)&&this.type.name===`Boolean`}isMultiple(){return this.multiple||this.lazyMultiple}static create(e){return new this(e)}},g=class extends Array{validate(e){this.some(e=>!e.name)&&_(`INVALID_DEFINITIONS`,"Invalid option definitions: the `name` property is required on each definition"),this.some(e=>e.type&&typeof e.type!=`function`)&&_(`INVALID_DEFINITIONS`,"Invalid option definitions: the `type` property must be a setter fuction (default: `Boolean`)");let t;this.some(e=>(t=e,i.isDefined(e.alias)&&i.isNumber(e.alias)))&&_(`INVALID_DEFINITIONS`,`Invalid option definition: to avoid ambiguity an alias cannot be numeric [--`+t.name+` alias is -`+t.alias+`]`),this.some(e=>(t=e,i.isDefined(e.alias)&&e.alias.length!==1))&&_(`INVALID_DEFINITIONS`,`Invalid option definition: an alias must be a single character`),this.some(e=>(t=e,e.alias===`-`))&&_(`INVALID_DEFINITIONS`,`Invalid option definition: an alias cannot be "-"`),y(this.map(t=>e?t.name.toLowerCase():t.name))&&_(`INVALID_DEFINITIONS`,`Two or more option definitions have the same name`),y(this.map(t=>e&&i.isDefined(t.alias)?t.alias.toLowerCase():t.alias))&&_(`INVALID_DEFINITIONS`,`Two or more option definitions have the same alias`),this.filter(e=>e.defaultOption===!0).length>1&&_(`INVALID_DEFINITIONS`,`Only one option definition can be the defaultOption`),this.some(e=>(t=e,e.isBoolean()&&e.defaultOption))&&_(`INVALID_DEFINITIONS`,`A boolean option ["${t.name}"] can not also be the defaultOption.`)}get(e,t){if(u(e))if(o.short.test(e)){let n=f(e);if(t){let e=n.toLowerCase();return this.find(t=>i.isDefined(t.alias)&&t.alias.toLowerCase()===e)}else return this.find(e=>e.alias===n)}else{let n=f(e);if(t){let e=n.toLowerCase();return this.find(t=>t.name.toLowerCase()===e)}else return this.find(e=>e.name===n)}else return this.find(t=>t.name===e)}getDefault(){return this.find(e=>e.defaultOption===!0)}isGrouped(){return this.some(e=>e.group)}whereGrouped(){return this.filter(v)}whereNotGrouped(){return this.filter(e=>!v(e))}whereDefaultValueSet(){return this.filter(e=>i.isDefined(e.defaultValue))}static from(e,t){if(e instanceof this)return e;let r=super.from(n(e),e=>h.create(e));return r.validate(t),r}};function _(e,t){let n=Error(t);throw n.name=e,n}function v(e){return n(e.group).some(e=>e)}function y(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(t[r])return!0;i.isDefined(r)&&(t[r]=!0)}}var b=class{constructor(e,t){this.options=Object.assign({},t),this.definitions=g.from(e,this.options.caseInsensitive),this.argv=s.from(this.options.argv),this.argv.hasCombinedShortOptions()&&r(this.argv,o.combinedShort.test.bind(o.combinedShort),e=>(e=e.slice(1),e.split(``).map(t=>({origArg:`-${e}`,arg:`-`+t}))))}*[Symbol.iterator](){let e=this.definitions,t,n,r,a,s=!1,c=!1,d;for(let f of this.argv){if(i.isPlainObject(f)&&(d=f.origArg,f=f.arg),c&&this.options.stopAtFirstUnknown){yield{event:`unknown_value`,arg:f,name:`_unknown`,value:void 0};continue}if(u(f))t=e.get(f,this.options.caseInsensitive),n=void 0,t?(n=t.isBoolean()?!0:null,a=`set`):a=`unknown_option`;else if(l(f)){let r=f.match(o.optEquals);t=e.get(r[1],this.options.caseInsensitive),t?t.isBoolean()?(yield{event:`unknown_value`,arg:f,name:`_unknown`,value:n,def:t},a=`set`,n=!0):(a=`set`,n=r[2]):a=`unknown_option`}else p(f)&&(t?(n=f,a=`set`):(t=this.definitions.getDefault(),t&&!s?(n=f,a=`set`):(a=`unknown_value`,t=void 0)));r=t?t.name:`_unknown`;let m={event:a,arg:f,name:r,value:n,def:t};d&&(m.subArg=f,m.arg=d),yield m,r===`_unknown`&&(c=!0),t&&t.defaultOption&&!t.isMultiple()&&a===`set`&&(s=!0),t&&t.isBoolean()&&(t=void 0),t&&!t.multiple&&i.isDefined(n)&&n!==null&&(t=void 0),n=void 0,a=void 0,r=void 0,d=void 0}}},x=new WeakMap,S=class{constructor(e){this.definition=new h(e),this.state=null,this.resetToDefault()}get(){return x.get(this)}set(e){this._set(e,`set`)}_set(e,t){let n=this.definition;if(n.isMultiple()){if(e!=null){let r=this.get();this.state===`default`&&(r.length=0),r.push(n.type(e)),this.state=t}}else if(!n.isMultiple()&&this.state===`set`){let t=Error(`Singular option already set [${this.definition.name}=${this.get()}]`);throw t.name=`ALREADY_SET`,t.value=e,t.optionName=n.name,t}else e==null?x.set(this,e):(x.set(this,n.type(e)),this.state=t)}resetToDefault(){i.isDefined(this.definition.defaultValue)?this.definition.isMultiple()?x.set(this,n(this.definition.defaultValue).slice()):x.set(this,this.definition.defaultValue):this.definition.isMultiple()?x.set(this,[]):x.set(this,null),this.state=`default`}static create(e){return e=new h(e),e.isBoolean()?C.create(e):new this(e)}},C=class extends S{set(e){super.set(!0)}static create(e){return new this(e)}},w=class extends Map{constructor(e){super(),this.definitions=g.from(e),this.set(`_unknown`,S.create({name:`_unknown`,multiple:!0}));for(let e of this.definitions.whereDefaultValueSet())this.set(e.name,S.create(e))}toObject(e){e||={};let t={};for(let n of this){let r=e.camelCase&&n[0]!==`_unknown`?a(n[0]):n[0],i=n[1];r===`_unknown`&&!i.get().length||(t[r]=i.get())}return e.skipUnknown&&delete t._unknown,t}},T=class extends w{toObject(e){let t=super.toObject({skipUnknown:e.skipUnknown}),r=super.toObject(e),o=r._unknown;delete r._unknown;let s={_all:r};return o&&o.length&&(s._unknown=o),this.definitions.whereGrouped().forEach(r=>{let o=e.camelCase?a(r.name):r.name,c=t[r.name];for(let e of n(r.group))s[e]=s[e]||{},i.isDefined(c)&&(s[e][o]=c)}),this.definitions.whereNotGrouped().forEach(n=>{let r=e.camelCase?a(n.name):n.name,o=t[n.name];i.isDefined(o)&&(s._none||={},s._none[r]=o)}),s}};function E(e,t){t||={},t.stopAtFirstUnknown&&(t.partial=!0),e=g.from(e,t.caseInsensitive);let n=new b(e,{argv:t.argv,stopAtFirstUnknown:t.stopAtFirstUnknown,caseInsensitive:t.caseInsensitive}),r=new(e.isGrouped()?T:w)(e);for(let e of n){let n=e.subArg||e.arg;if(!t.partial){if(e.event===`unknown_value`){let e=Error(`Unknown value: ${n}`);throw e.name=`UNKNOWN_VALUE`,e.value=n,e}else if(e.event===`unknown_option`){let e=Error(`Unknown option: ${n}`);throw e.name=`UNKNOWN_OPTION`,e.optionName=n,e}}let i;r.has(e.name)?i=r.get(e.name):(i=S.create(e.def),r.set(e.name,i)),e.name===`_unknown`?i.set(n):i.set(e.value)}return r.toObject({skipUnknown:!t.partial,camelCase:t.camelCase})}t.exports=E})),he=t(((e,t)=>{var n=W(),r=me();t.exports=class extends n{static get name(){return`ls`}get requiresFilesystem(){return!0}run(){let e=this.arguments.filter(e=>e!==`-1`),t=e.length!==this.arguments.length,n;try{n=this.parseArgs(e)}catch(e){return this.printHelp(e),Promise.reject()}if(n.one=n.one||t,n.help)return this.printHelp(),Promise.resolve();let r=this.fs.getFileByPath(n.path);if(!r){let e=this.fs.exists(n.path)?`Permission denied`:`No such file or directory`;return Promise.reject(`${n.path}: ${e}`)}if(r.constructor===Object){let e=r;n.all||(e=Object.entries(e).reduce((e,[t,n])=>(t.startsWith(`.`)||(e[t]=n),e),{}));let t=this.fs.absolutePath(n.path);return n.long?this.printLong(e,t):n.one?Object.entries(e).forEach(([e,t])=>{this.stdOut=this._applyIndicator(e,t,n.classify)}):this.printSimple(e,n.classify),n.recursive&&Object.entries(e).forEach(([e,r])=>{if(r&&r.constructor===Object){let r=t.endsWith(`/`)?t+e:t+`/`+e;this.stdOut=``,this.stdOut=r+`:`,this.run.call(Object.create(this,{arguments:{value:[...this.arguments.filter(e=>e!==n.path&&e!==`./`),r]}}))}}),Promise.resolve()}return Promise.resolve(n.path)}printHelp(e){e&&(this.stdOut=e.message),this.stdOut=`usage: ls [-alRF1h] [file ...]`}printSimple(e,t){this.stdOut=Object.entries(e).reduce((e,[n,r])=>e+this.padString(this._applyIndicator(n,r,t)),``)}printLong(e,t){let n=t.endsWith(`/`)?t.slice(0,-1):t;Object.entries(e).forEach(([e,t])=>{let r=n+`/`+e,i=t!=null&&t.constructor===Object,a=this.fs.getMode(r),o=a===null?i?493:420:a,s=this._modeToString(o,i),c=this.fs.getSize(r);return this.stdOut=`${s} root users ${this.padString(c,10)} ${e}`})}_applyIndicator(e,t,n){return n?t&&t.constructor===Object?e+`/`:typeof t==`function`||this.fs.isExecutable(e)?e+`*`:e:e}_modeToString(e,t){return(t?`d`:`-`)+(e&256?`r`:`-`)+(e&128?`w`:`-`)+(e&64?`x`:`-`)+(e&32?`r`:`-`)+(e&16?`w`:`-`)+(e&8?`x`:`-`)+(e&4?`r`:`-`)+(e&2?`w`:`-`)+(e&1?`x`:`-`)}padString(e,t=16){let n=t-e.toString().length,r=``;for(let e=0;e<n;e++)r+=` `;return e.toString()+r}parseArgs(e=this.arguments){return r([{name:`path`,defaultOption:!0,defaultValue:`./`,type:String},{name:`all`,alias:`a`,type:Boolean},{name:`long`,alias:`l`,type:Boolean},{name:`recursive`,alias:`R`,type:Boolean},{name:`one`,type:Boolean},{name:`classify`,alias:`F`,type:Boolean},{name:`help`,alias:`h`,type:Boolean}],{argv:e})}}})),X=t(((e,t)=>{var n=W();t.exports=class extends n{static get name(){return`echo`}run(){let e=[...this.arguments],t=!1,n=!1;for(;e.length>0&&/^-[neE]+$/.test(e[0]);){let r=e.shift();r.includes(`n`)&&(t=!0),r.includes(`e`)&&(n=!0),r===`-E`&&(n=!1)}let r=e.join(` `);return n&&(r=r.replace(/\\c.*$/s,()=>(t=!0,``)).replace(/\\0([0-7]{1,3})/g,(e,t)=>String.fromCharCode(parseInt(t,8))).replace(/\\x([0-9a-fA-F]{1,2})/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/\\n/g,`