const t="undefined"!=typeof WebAssembly?WebAssembly:"undefined"!=typeof WXWebAssembly?WXWebAssembly:void 0;if(!t)throw new Error("WebAssembly is not supported in this environment");function e(t,e){if(null===t||"object"!=typeof t)throw new TypeError(`${e} must be an object. Received ${null===t?"null":typeof t}`)}function n(t,e){if("string"!=typeof t)throw new TypeError(`${e} must be a string. Received ${null===t?"null":typeof t}`)}function r(t,e){if("function"!=typeof t)throw new TypeError(`${e} must be a function. Received ${null===t?"null":typeof t}`)}function i(t,e){if(void 0!==t)throw new TypeError(`${e} must be undefined. Received ${null===t?"null":typeof t}`)}function s(t){return!(!t||"object"!=typeof t&&"function"!=typeof t||"function"!=typeof t.then)}function o(t,e){const n=Object.create(null);return Object.keys(t).forEach((r=>{const i=t[r];Object.defineProperty(n,r,{enumerable:!0,value:e(i,r)})})),n}function a(t,e,n){return"function"==typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer||"[object SharedArrayBuffer]"===Object.prototype.toString.call(t.buffer.constructor)?t.slice(e,n):t.subarray(e,n)}const c=["asyncify_get_state","asyncify_start_rewind","asyncify_start_unwind","asyncify_stop_rewind","asyncify_stop_unwind"];function u(t,e,n,r){if("function"!=typeof t.exports[r]||n<=0)return{wasm64:e,dataPtr:16,start:e?32:24,end:1024};const i=t.exports[r],s=e?Number(i(BigInt(16)+BigInt(n))):i(8+n);if(0===s)throw new Error("Allocate asyncify data failed");return e?{wasm64:e,dataPtr:s,start:s+16,end:s+16+n}:{wasm64:e,dataPtr:s,start:s+8,end:s+8+n}}class f{constructor(){this.value=void 0,this.exports=void 0,this.dataPtr=0}init(e,n,r){var i,s;if(this.exports)throw new Error("Asyncify has been initialized");if(!(e instanceof t.Memory))throw new TypeError("Require WebAssembly.Memory object");const o=n.exports;for(let t=0;t{const r=t[n],i={};Object.keys(r).forEach((t=>{const e=r[t];i[t]="function"==typeof e?this.wrapImportFunction(e):e})),e[n]=i})),e}wrapExportFunction(t){const e=this;return async function(){e.assertState();let n=t.apply(this,arguments);for(;1===e.exports.asyncify_get_state();)e.exports.asyncify_stop_unwind(),e.value=await e.value,e.assertState(),e.exports.asyncify_start_rewind(e.dataPtr),n=t.call(this);return e.assertState(),n}}wrapExports(t,e){return o(t,((t,n)=>{let r=-1!==c.indexOf(n)||"function"!=typeof t;return Array.isArray(e)&&(r=r||-1===e.indexOf(n)),r?t:this.wrapExportFunction(t)}))}}function h(t){if(t&&"object"!=typeof t)throw new TypeError("imports must be an object or undefined")}function d(e,n){return"undefined"!=typeof wx&&"undefined"!=typeof __wxConfig?t.instantiate(e,n):fetch(e).then((t=>t.arrayBuffer())).then((e=>t.instantiate(e,n)))}function g(e,n){let r;if(h(n),n=null!=n?n:{},e instanceof ArrayBuffer||ArrayBuffer.isView(e))return t.instantiate(e,n);if(e instanceof t.Module)return t.instantiate(e,n).then((t=>({instance:t,module:e})));if("string"!=typeof e&&!(e instanceof URL))throw new TypeError("Invalid source");if("function"==typeof t.instantiateStreaming){let i;try{i=fetch(e),r=t.instantiateStreaming(i,n).catch((()=>d(e,n)))}catch(t){r=d(e,n)}}else r=d(e,n);return r}function l(t,e,n){h(n),n=null!=n?n:{};const r=new f;return g(e,n=r.wrapImports(n)).then((e=>{var i;const s=e.instance.exports.memory||(null===(i=n.env)||void 0===i?void 0:i.memory);return{module:e.module,instance:r.init(s,e.instance,t)}}))}function _(e,n){let r;if(h(n),n=null!=n?n:{},e instanceof ArrayBuffer||ArrayBuffer.isView(e))r=new t.Module(e);else{if(!(e instanceof WebAssembly.Module))throw new TypeError("Invalid source");r=e}return{instance:new t.Instance(r,n),module:r}}function p(t,e,n){var r;h(n),n=null!=n?n:{};const i=new f,s=_(e,n=i.wrapImports(n)),o=s.instance.exports.memory||(null===(r=n.env)||void 0===r?void 0:r.memory);return{module:s.module,instance:i.init(o,s.instance,t)}}const y=46,E=47,I=92,m=58,A=65,b=90,T=97,w=122;function B(t){return t===E||t===I}function N(t){return t>=A&&t<=b||t>=T&&t<=w}const S="undefined"!=typeof process&&"win32"===process.platform;function P(t){return t===E}function D(t,e,n,r){let i="",s=0,o=-1,a=0,c=0;for(let u=0;u<=t.length;++u){if(u2){const t=i.indexOf(n);-1===t?(i="",s=0):(i=i.slice(0,t),s=i.length-1-i.indexOf(n)),o=u,a=0;continue}if(0!==i.length){i="",s=0,o=u,a=0;continue}}e&&(i+=i.length>0?`${n}..`:"..",s=2)}else i.length>0?i+=`${n}${t.slice(o+1,u)}`:i=t.slice(o+1,u),s=u-o-1;o=u,a=0}else c===y&&-1!==a?++a:a=-1}return i}function F(...t){if(S)return function(t){let e="",r="",i=!1;for(let s=t.length-1;s>=-1;s--){let o;if(s>=0){if(o=t[s],n(o,"path"),0===o.length)continue}else if(0===e.length)o="undefined"!=typeof process&&"function"==typeof process.cwd?process.cwd():"";else{const t=`=${e}`,n="undefined"!=typeof process?process.env:void 0;o=n&&"string"==typeof n[t]?n[t]:"undefined"!=typeof process&&"function"==typeof process.cwd?process.cwd():"",(void 0===o||o.slice(0,2).toLowerCase()!==e.toLowerCase()&&o.charCodeAt(2)===I)&&(o=`${e}\\`)}const a=o.length;let c=0,u="",f=!1;const h=o.charCodeAt(0);if(1===a)B(h)&&(c=1,f=!0);else if(B(h))if(f=!0,B(o.charCodeAt(1))){let t=2,e=t;for(;t2&&B(o.charCodeAt(2))&&(f=!0,c=3));if(u.length>0)if(e.length>0){if(u.toLowerCase()!==e.toLowerCase())continue}else e=u;if(i){if(e.length>0)break}else if(r=`${o.slice(c)}\\${r}`,i=f,f&&e.length>0)break}return r=D(r,!i,"\\",B),e+(i?"\\":"")+r||"."}(t);let e="",r=!1;for(let i=t.length-1;i>=-1&&!r;i--){const s=i>=0?t[i]:"/";n(s,"path"),0!==s.length&&(e=`${s}/${e}`,r=s.charCodeAt(0)===E)}return e=D(e,!r,"/",P),r?`/${e}`:e.length>0?e:"."}const v={FD_DATASYNC:BigInt(1)<=0)n=e;else for(let e=0;e"),this.insertStdio(t.out,1,""),this.insertStdio(t.err,2,"")}insertStdio(t,e,n){const{base:r,inheriting:i}=G(this.stdio,t,2,2),s=this.insert(t,n,n,2,r,i,0);if(s.id!==e)throw new U(`id: ${s.id} !== expected: ${e}`,8);return s}insert(t,e,n,r,i,s,o){var a,c;let u,f=-1;if(this.used>=this.size){const t=2*this.size;this.fds.length=t,f=this.size,this.size=t}else for(let t=0;t"===e?new Z(null!==(c=this.printErr)&&void 0!==c?c:console.error,f,t,e,n,r,i,s,o):new V(f,t,e,n,r,i,s,o),this.fds[f]=u,this.used++,u}get(t,e,n){if(t>=this.size)throw new U("Invalid fd",8);const r=this.fds[t];if(!r||r.id!==t)throw new U("Bad file descriptor",8);if((~r.rightsBase&e)!==BigInt(0)||(~r.rightsInheriting&n)!==BigInt(0))throw new U("Capabilities insufficient",76);return r}remove(t){if(t>=this.size)throw new U("Invalid fd",8);const e=this.fds[t];if(!e||e.id!==t)throw new U("Bad file descriptor",8);this.fds[t]=void 0,this.used--}}class J extends Q{constructor(t){super(t),this.fs=t.fs}getFileTypeByFd(t){return q(this.fs.fstatSync(t,{bigint:!0}))}insertPreopen(t,e,n){const r=this.getFileTypeByFd(t);if(3!==r)throw new U(`Preopen not dir: ["${e}", "${n}"]`,54);const i=G(this.stdio,t,0,r);return this.insert(t,e,n,r,i.base,i.inheriting,1)}renumber(t,e){if(t===e)return;if(t>=this.size||e>=this.size)throw new U("Invalid fd",8);const n=this.fds[t],r=this.fds[e];if(!n||!r||n.id!==t||r.id!==e)throw new U("Invalid fd",8);this.fs.closeSync(n.fd),this.fds[t]=this.fds[e],this.fds[t].id=t,this.fds[e]=void 0,this.used--}}class tt extends Q{constructor(t){super(t)}async getFileTypeByFd(t){return q(await t.stat({bigint:!0}))}async insertPreopen(t,e,n){const r=await this.getFileTypeByFd(t);if(3!==r)throw new U(`Preopen not dir: ["${e}", "${n}"]`,54);const i=G(this.stdio,t.fd,0,r);return this.insert(t,e,n,r,i.base,i.inheriting,1)}async renumber(t,e){if(t===e)return;if(t>=this.size||e>=this.size)throw new U("Invalid fd",8);const n=this.fds[t],r=this.fds[e];if(!n||!r||n.id!==t||r.id!==e)throw new U("Invalid fd",8);await n.fd.close(),this.fds[t]=this.fds[e],this.fds[t].id=t,this.fds[e]=void 0,this.used--}}const et=function(){return t.Memory}();class nt extends et{constructor(t){super(t)}get HEAP8(){return new Int8Array(super.buffer)}get HEAPU8(){return new Uint8Array(super.buffer)}get HEAP16(){return new Int16Array(super.buffer)}get HEAPU16(){return new Uint16Array(super.buffer)}get HEAP32(){return new Int32Array(super.buffer)}get HEAPU32(){return new Uint32Array(super.buffer)}get HEAP64(){return new BigInt64Array(super.buffer)}get HEAPU64(){return new BigUint64Array(super.buffer)}get HEAPF32(){return new Float32Array(super.buffer)}get HEAPF64(){return new Float64Array(super.buffer)}get view(){return new DataView(super.buffer)}}function rt(e){return Object.getPrototypeOf(e)===t.Memory.prototype&&Object.setPrototypeOf(e,nt.prototype),e}function it(){const e=t.Function;if("function"!=typeof e)throw new Error('WebAssembly.Function is not supported in this environment. If you are using V8 based browser like Chrome, try to specify --js-flags="--wasm-staging --experimental-wasm-stack-switching"');return e}function st(t,e,n){const r=it();if("function"!=typeof t)throw new TypeError("Function required");const i=e.slice(0);return i.unshift("externref"),new r({parameters:i,results:n},t,{suspending:"first"})}function ot(t){const e=it();if("function"!=typeof t)throw new TypeError("Function required");return new e({parameters:[...e.type(t).parameters.slice(1)],results:["externref"]},t,{promising:"first"})}function at(t,e){return o(t,((t,n)=>{let r="function"!=typeof t;return Array.isArray(e)&&(r=r||-1===e.indexOf(n)),r?t:ot(t)}))}const ct="undefined"!=typeof process&&"win32"===process.platform;function ut(t){let e=3&t;return 0!=(64&t)&&(e|=256),0!=(128&t)&&(e|=1024),0!=(512&t)&&(e|=512),0!=(1024&t)&&(e|=8),e}function ft(t,e){if(0===t.length||0===e.length)return 0;let n=0,r=e.length-n;for(let i=0;it),pt):r}function It(t,e,n){let r=!1;const i=(()=>{try{return}catch(t){return}})();return"string"==typeof i&&i.split(",").includes("wasi")&&(r=!0),yt(e,r?function(){const r=Array.prototype.slice.call(arguments);let i=[`${e}(${Array.from({length:arguments.length}).map((()=>"%d")).join(", ")})`];return i=i.concat(r),console.debug.apply(console,i),Et(n,t,r)}:function(){return Et(n,t,arguments)})}function mt(t,e,n,r){let i=F(e.realPath,n);if(1==(1&r))try{i=t.readlinkSync(i)}catch(t){if("EINVAL"!==t.code&&"ENOENT"!==t.code)throw t}return i}async function At(t,e,n,r){let i=F(e.realPath,n);if(1==(1&r))try{i=await t.promises.readlink(i)}catch(t){if("EINVAL"!==t.code&&"ENOENT"!==t.code)throw t}return i}const bt=new TextEncoder,Tt=new TextDecoder,wt=(BigInt(1)<r.rightsBase||(n|r.rightsInheriting)>r.rightsInheriting?76:(r.rightsBase=e,r.rightsInheriting=n,0)})),this.fd_prestat_get=It(this,"fd_prestat_get",(function(t,e){if(0===(e=Number(e)))return 28;const n=dt.get(this);let r;try{r=n.fds.get(t,BigInt(0),BigInt(0))}catch(t){if(t instanceof U)return t.errno;throw t}if(1!==r.preopen)return 28;const{view:i}=lt(this);return i.setUint32(e,0,!0),i.setUint32(e+4,bt.encode(r.path).length,!0),0})),this.fd_prestat_dir_name=It(this,"fd_prestat_dir_name",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const r=dt.get(this).fds.get(t,BigInt(0),BigInt(0));if(1!==r.preopen)return 8;const i=bt.encode(r.path);if(i.length>n)return 42;const{HEAPU8:s}=lt(this);return s.set(i,e),0})),this.fd_seek=It(this,"fd_seek",(function(t,e,n,r){if(0===(r=Number(r)))return 28;if(0===t||1===t||2===t)return 0;const i=dt.get(this).fds.get(t,v.FD_SEEK,BigInt(0)).seek(e,n),{view:s}=lt(this);return s.setBigUint64(r,i,!0),0})),this.fd_tell=It(this,"fd_tell",(function(t,e){const n=dt.get(this).fds.get(t,v.FD_TELL,BigInt(0)),r=BigInt(n.pos),{view:i}=lt(this);return i.setBigUint64(Number(e),r,!0),0})),this.poll_oneoff=It(this,"poll_oneoff",(function(t,e,n,r){if(t=Number(t),e=Number(e),r=Number(r),n=Number(n),n>>>=0,0===t||0===e||0===n||0===r)return 28;const{view:i}=lt(this);i.setUint32(r,0,!0);let s,o=0,a=BigInt(0),c=BigInt(0),u=0,f=BigInt(0);const h=Array(n);for(o=0;o0){for(o=0;o!1));const t=e;i.setBigUint64(t,a,!0),i.setUint32(t+8,0,!0),i.setUint32(t+12,0,!0),i.setUint32(r,1,!0)}return 0})),this.proc_exit=It(this,"proc_exit",(function(t){return"object"==typeof process&&null!==process&&"function"==typeof process.exit&&process.exit(t),0})),this.proc_raise=It(this,"proc_raise",(function(t){return 52})),this.sched_yield=It(this,"sched_yield",(function(){return 0})),this.random_get="undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues?It(this,"random_get",(function(t,e){if(0===(t=Number(t)))return 28;e=Number(e);const{HEAPU8:n,view:r}=lt(this);if("function"==typeof SharedArrayBuffer&&n.buffer instanceof SharedArrayBuffer||"[object SharedArrayBuffer]"===Object.prototype.toString.call(n.buffer)){for(let n=t;nwt)return 28;const{HEAPU8:s,view:o}=lt(this),a=dt.get(this).fds.get(t,v.FD_READ|v.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;let c=0;const u=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return c+=a,s.subarray(i,i+a)}));let f=0;const h=(()=>{try{return new Uint8Array(new SharedArrayBuffer(c))}catch(t){return new Uint8Array(c)}})();h._isBuffer=!0;const d=_t(this).readSync(a.fd,h,0,h.length,Number(r));return f=h?ft(u,h.subarray(0,d)):0,o.setUint32(i,f,!0),0}),(async function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>wt)return 28;const{HEAPU8:s,view:o}=lt(this),a=dt.get(this).fds.get(t,v.FD_READ|v.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;let c=0;const u=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return c+=a,s.subarray(i,i+a)}));let f=0;const h=new Uint8Array(c);h._isBuffer=!0;const{bytesRead:d}=await a.fd.read(h,0,h.length,Number(r));return f=h?ft(u,h.subarray(0,d)):0,o.setUint32(i,f,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_pwrite",(function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>wt)return 28;const{HEAPU8:s,view:o}=lt(this),a=dt.get(this).fds.get(t,v.FD_WRITE|v.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;const c=Y(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return s.subarray(i,i+a)}))),u=_t(this).writeSync(a.fd,c,0,c.length,Number(r));return o.setUint32(i,u,!0),0}),(async function(t,e,n,r,i){if(e=Number(e),i=Number(i),0===e&&n||0===i||r>wt)return 28;const{HEAPU8:s,view:o}=lt(this),a=dt.get(this).fds.get(t,v.FD_WRITE|v.FD_SEEK,BigInt(0));if(!n)return o.setUint32(i,0,!0),0;const c=Y(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,i=o.getInt32(r,!0),a=o.getUint32(r+4,!0);return s.subarray(i,i+a)}))),{bytesWritten:u}=await a.fd.write(c,0,c.length,Number(r));return o.setUint32(i,u,!0),0}),["i32","i32","i32","i64","i32"],["i32"]),u("fd_read",(function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=lt(this),o=dt.get(this).fds.get(t,v.FD_READ,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;let a=0;const c=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),c=s.getUint32(r+4,!0);return a+=c,i.subarray(o,o+c)}));let u,f=0;if(0===t){if("undefined"==typeof window||"function"!=typeof window.prompt)return 58;u=Bt(),f=u?ft(c,u):0}else{u=(()=>{try{return new Uint8Array(new SharedArrayBuffer(a))}catch(t){return new Uint8Array(a)}})(),u._isBuffer=!0;const t=_t(this).readSync(o.fd,u,0,u.length,Number(o.pos));f=u?ft(c,u.subarray(0,t)):0,o.pos+=BigInt(f)}return s.setUint32(r,f,!0),0}),(async function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=lt(this),o=dt.get(this).fds.get(t,v.FD_READ,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;let a=0;const c=Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),c=s.getUint32(r+4,!0);return a+=c,i.subarray(o,o+c)}));let u,f=0;if(0===t){if("undefined"==typeof window||"function"!=typeof window.prompt)return 58;u=Bt(),f=u?ft(c,u):0}else{u=new Uint8Array(a),u._isBuffer=!0;const{bytesRead:t}=await o.fd.read(u,0,u.length,Number(o.pos));f=u?ft(c,u.subarray(0,t)):0,o.pos+=BigInt(f)}return s.setUint32(r,f,!0),0}),["i32","i32","i32","i32"],["i32"]),u("fd_readdir",(function(t,e,n,r,i){if(e=Number(e),n=Number(n),i=Number(i),0===e||0===i)return 0;const s=dt.get(this).fds.get(t,v.FD_READDIR,BigInt(0)),o=_t(this),a=o.readdirSync(s.realPath,{withFileTypes:!0}),{HEAPU8:c,view:u}=lt(this);let f=0;for(let t=Number(r);t{const r=e+8*n,o=s.getInt32(r,!0),a=s.getUint32(r+4,!0);return i.subarray(o,o+a)})));let c;if(1===t||2===t)c=o.write(a);else{c=_t(this).writeSync(o.fd,a,0,a.length,Number(o.pos)),o.pos+=BigInt(c)}return s.setUint32(r,c,!0),0}),(async function(t,e,n,r){if(e=Number(e),r=Number(r),0===e&&n||0===r)return 28;const{HEAPU8:i,view:s}=lt(this),o=dt.get(this).fds.get(t,v.FD_WRITE,BigInt(0));if(!n)return s.setUint32(r,0,!0),0;const a=Y(Array.from({length:Number(n)},((t,n)=>{const r=e+8*n,o=s.getInt32(r,!0),a=s.getUint32(r+4,!0);return i.subarray(o,o+a)})));let c;return 1===t||2===t?c=o.write(a):(c=await(await o.fd.write(a,0,a.length,Number(o.pos))).bytesWritten,o.pos+=BigInt(c)),s.setUint32(r,c,!0),0}),["i32","i32","i32","i32"],["i32"]),u("path_create_directory",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=lt(this),i=dt.get(this).fds.get(t,v.PATH_CREATE_DIRECTORY,BigInt(0));let s=Tt.decode(a(r,e,e+n));s=F(i.realPath,s);return _t(this).mkdirSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=lt(this),i=dt.get(this).fds.get(t,v.PATH_CREATE_DIRECTORY,BigInt(0));let s=Tt.decode(a(r,e,e+n));s=F(i.realPath,s);const o=_t(this);return await o.promises.mkdir(s),0}),["i32","i32","i32"],["i32"]),u("path_filestat_get",(function(t,e,n,r,i){if(n=Number(n),r=Number(r),i=Number(i),0===n||0===i)return 28;const{HEAPU8:s,view:o}=lt(this),c=dt.get(this).fds.get(t,v.PATH_FILESTAT_GET,BigInt(0));let u=Tt.decode(a(s,n,n+r));const f=_t(this);let h;return u=F(c.realPath,u),h=1==(1&e)?f.statSync(u,{bigint:!0}):f.lstatSync(u,{bigint:!0}),X(o,i,h),0}),(async function(t,e,n,r,i){if(n=Number(n),r=Number(r),i=Number(i),0===n||0===i)return 28;const{HEAPU8:s,view:o}=lt(this),c=dt.get(this).fds.get(t,v.PATH_FILESTAT_GET,BigInt(0));let u=Tt.decode(a(s,n,n+r));const f=_t(this);let h;return u=F(c.realPath,u),h=1==(1&e)?await f.promises.stat(u,{bigint:!0}):await f.promises.lstat(u,{bigint:!0}),X(o,i,h),0}),["i32","i32","i32","i32","i32"],["i32"]),u("path_filestat_set_times",(function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),0===n)return 28;const{HEAPU8:c}=lt(this),u=dt.get(this).fds.get(t,v.PATH_FILESTAT_SET_TIMES,BigInt(0));if(Nt(o))return 28;const f=_t(this),h=mt(f,u,Tt.decode(a(c,n,n+r)),e);return 2==(2&o)&&(i=BigInt(1e6*Date.now())),8==(8&o)&&(s=BigInt(1e6*Date.now())),f.utimesSync(h,Number(i),Number(s)),0}),(async function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),0===n)return 28;const{HEAPU8:c}=lt(this),u=dt.get(this).fds.get(t,v.PATH_FILESTAT_SET_TIMES,BigInt(0));if(Nt(o))return 28;const f=_t(this),h=await At(f,u,Tt.decode(a(c,n,n+r)),e);return 2==(2&o)&&(i=BigInt(1e6*Date.now())),8==(8&o)&&(s=BigInt(1e6*Date.now())),await f.promises.utimes(h,Number(i),Number(s)),0}),["i32","i32","i32","i32","i64","i64","i32"],["i32"]),u("path_link",(function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),s=Number(s),o=Number(o),0===n||0===s)return 28;const c=dt.get(this);let u,f;t===i?u=f=c.fds.get(t,v.PATH_LINK_SOURCE|v.PATH_LINK_TARGET,BigInt(0)):(u=c.fds.get(t,v.PATH_LINK_SOURCE,BigInt(0)),f=c.fds.get(i,v.PATH_LINK_TARGET,BigInt(0)));const{HEAPU8:h}=lt(this),d=_t(this),g=mt(d,u,Tt.decode(a(h,n,n+r)),e),l=F(f.realPath,Tt.decode(a(h,s,s+o)));return d.linkSync(g,l),0}),(async function(t,e,n,r,i,s,o){if(n=Number(n),r=Number(r),s=Number(s),o=Number(o),0===n||0===s)return 28;const c=dt.get(this);let u,f;t===i?u=f=c.fds.get(t,v.PATH_LINK_SOURCE|v.PATH_LINK_TARGET,BigInt(0)):(u=c.fds.get(t,v.PATH_LINK_SOURCE,BigInt(0)),f=c.fds.get(i,v.PATH_LINK_TARGET,BigInt(0)));const{HEAPU8:h}=lt(this),d=_t(this),g=await At(d,u,Tt.decode(a(h,n,n+r)),e),l=F(f.realPath,Tt.decode(a(h,s,s+o)));return await d.promises.link(g,l),0}),["i32","i32","i32","i32","i32","i32","i32"],["i32"]),u("path_open",(function(t,e,n,r,i,s,o,c,u){if(n=Number(n),u=Number(u),0===n||0===u)return 28;r=Number(r),s=BigInt(s),o=BigInt(o);const{flags:f,needed_base:d,needed_inheriting:g}=h(i,s,o,c),l=dt.get(this),_=l.fds.get(t,d,g),p=lt(this),y=p.HEAPU8,E=Tt.decode(a(y,n,n+r)),I=_t(this),m=mt(I,_,E,e),A=I.openSync(m,ct?ut(f):f,438),b=l.fds.getFileTypeByFd(A);if(3!==b&&(0!=(2&i)||m.endsWith("/")))return 54;const{base:T,inheriting:w}=G(l.fds.stdio,A,f,b),B=l.fds.insert(A,m,m,b,s&T,o&w,0),N=I.fstatSync(A,{bigint:!0});N.isFile()&&(B.size=N.size,0!=(1024&f)&&(B.pos=N.size));return p.view.setInt32(u,B.id,!0),0}),(async function(t,e,n,r,i,s,o,c,u){if(n=Number(n),u=Number(u),0===n||0===u)return 28;r=Number(r),s=BigInt(s),o=BigInt(o);const{flags:f,needed_base:d,needed_inheriting:g}=h(i,s,o,c),l=dt.get(this),_=l.fds.get(t,d,g),p=lt(this),y=p.HEAPU8,E=Tt.decode(a(y,n,n+r)),I=_t(this),m=await At(I,_,E,e),A=await I.promises.open(m,ct?ut(f):f,438),b=await l.fds.getFileTypeByFd(A);if(0!=(2&i)&&3!==b)return 54;const{base:T,inheriting:w}=G(l.fds.stdio,A.fd,f,b),B=l.fds.insert(A,m,m,b,s&T,o&w,0),N=await A.stat({bigint:!0});N.isFile()&&(B.size=N.size,0!=(1024&f)&&(B.pos=N.size));return p.view.setInt32(u,B.id,!0),0}),["i32","i32","i32","i32","i32","i64","i64","i32","i32"],["i32"]),u("path_readlink",(function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),r=Number(r),i=Number(i),s=Number(s),0===e||0===r||0===s)return 28;const{HEAPU8:o,view:c}=lt(this),u=dt.get(this).fds.get(t,v.PATH_READLINK,BigInt(0));let f=Tt.decode(a(o,e,e+n));f=F(u.realPath,f);const h=_t(this).readlinkSync(f),d=bt.encode(h),g=Math.min(d.length,i);return g>=i?42:(o.set(d.subarray(0,g),r),o[r+g]=0,c.setUint32(s,g,!0),0)}),(async function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),r=Number(r),i=Number(i),s=Number(s),0===e||0===r||0===s)return 28;const{HEAPU8:o,view:c}=lt(this),u=dt.get(this).fds.get(t,v.PATH_READLINK,BigInt(0));let f=Tt.decode(a(o,e,e+n));f=F(u.realPath,f);const h=_t(this),d=await h.promises.readlink(f),g=bt.encode(d),l=Math.min(g.length,i);return l>=i?42:(o.set(g.subarray(0,l),r),o[r+l]=0,c.setUint32(s,l,!0),0)}),["i32","i32","i32","i32","i32","i32"],["i32"]),u("path_remove_directory",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=lt(this),i=dt.get(this).fds.get(t,v.PATH_REMOVE_DIRECTORY,BigInt(0));let s=Tt.decode(a(r,e,e+n));s=F(i.realPath,s);return _t(this).rmdirSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=lt(this),i=dt.get(this).fds.get(t,v.PATH_REMOVE_DIRECTORY,BigInt(0));let s=Tt.decode(a(r,e,e+n));s=F(i.realPath,s);const o=_t(this);return await o.promises.rmdir(s),0}),["i32","i32","i32"],["i32"]),u("path_rename",(function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),i=Number(i),s=Number(s),0===e||0===i)return 28;const o=dt.get(this);let c,u;t===r?c=u=o.fds.get(t,v.PATH_RENAME_SOURCE|v.PATH_RENAME_TARGET,BigInt(0)):(c=o.fds.get(t,v.PATH_RENAME_SOURCE,BigInt(0)),u=o.fds.get(r,v.PATH_RENAME_TARGET,BigInt(0)));const{HEAPU8:f}=lt(this),h=F(c.realPath,Tt.decode(a(f,e,e+n))),d=F(u.realPath,Tt.decode(a(f,i,i+s)));return _t(this).renameSync(h,d),0}),(async function(t,e,n,r,i,s){if(e=Number(e),n=Number(n),i=Number(i),s=Number(s),0===e||0===i)return 28;const o=dt.get(this);let c,u;t===r?c=u=o.fds.get(t,v.PATH_RENAME_SOURCE|v.PATH_RENAME_TARGET,BigInt(0)):(c=o.fds.get(t,v.PATH_RENAME_SOURCE,BigInt(0)),u=o.fds.get(r,v.PATH_RENAME_TARGET,BigInt(0)));const{HEAPU8:f}=lt(this),h=F(c.realPath,Tt.decode(a(f,e,e+n))),d=F(u.realPath,Tt.decode(a(f,i,i+s))),g=_t(this);return await g.promises.rename(h,d),0}),["i32","i32","i32","i32","i32","i32"],["i32"]),u("path_symlink",(function(t,e,n,r,i){if(t=Number(t),e=Number(e),r=Number(r),i=Number(i),0===t||0===r)return 28;const{HEAPU8:s}=lt(this),o=dt.get(this).fds.get(n,v.PATH_SYMLINK,BigInt(0)),c=Tt.decode(a(s,t,t+e));if(c.length>0&&"/"===c[0])return 63;let u=Tt.decode(a(s,r,r+i));u=F(o.realPath,u);return _t(this).symlinkSync(c,u),0}),(async function(t,e,n,r,i){if(t=Number(t),e=Number(e),r=Number(r),i=Number(i),0===t||0===r)return 28;const{HEAPU8:s}=lt(this),o=dt.get(this).fds.get(n,v.PATH_SYMLINK,BigInt(0)),c=Tt.decode(a(s,t,t+e));let u=Tt.decode(a(s,r,r+i));u=F(o.realPath,u);const f=_t(this);return await f.promises.symlink(c,u),0}),["i32","i32","i32","i32","i32"],["i32"]),u("path_unlink_file",(function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=lt(this),i=dt.get(this).fds.get(t,v.PATH_UNLINK_FILE,BigInt(0));let s=Tt.decode(a(r,e,e+n));s=F(i.realPath,s);return _t(this).unlinkSync(s),0}),(async function(t,e,n){if(e=Number(e),n=Number(n),0===e)return 28;const{HEAPU8:r}=lt(this),i=dt.get(this).fds.get(t,v.PATH_UNLINK_FILE,BigInt(0));let s=Tt.decode(a(r,e,e+n));s=F(i.realPath,s);const o=_t(this);return await o.promises.unlink(s),0}),["i32","i32","i32"],["i32"]),this._setMemory=function(e){if(!(e instanceof t.Memory))throw new TypeError('"instance.exports.memory" property must be a WebAssembly.Memory');ht.set(c,rt(e))}}static createSync(t,e,n,r,i,s,o){const a=new J({size:3,in:r[0],out:r[1],err:r[2],fs:i,print:s,printErr:o}),c=new St(t,e,a,!1,i);if(n.length>0)for(let t=0;t0)for(let t=0;t{void 0!==e&&a.push(`${t}=${e}`)})));const c=[];if(void 0!==t.preopens&&(e(t.preopens,"options.preopens"),Object.entries(t.preopens).forEach((({0:t,1:e})=>c.push({mappedPath:String(t),realPath:String(e)})))),c.length>0){if(void 0===t.fs)throw new Error("filesystem is disabled, can not preopen directory");try{e(t.fs,"options.fs")}catch(t){throw new TypeError("Node.js fs like implementation is not provided")}}void 0!==t.print&&r(t.print,"options.print"),void 0!==t.printErr&&r(t.printErr,"options.printErr"),void 0!==t.returnOnExit&&function(t,e){if("boolean"!=typeof t)throw new TypeError(`${e} must be a boolean. Received ${null===t?"null":typeof t}`)}(t.returnOnExit,"options.returnOnExit");return{args:o,env:a,preopens:c,stdio:[0,1,2],_WASI:s}}function Ht(t,e){this[Ft]=t,this.wasiImport=e,this[vt]=!1,this[Dt]=0,this[Ut]=void 0}class Ot{constructor(t=Pt){const{args:e,env:n,preopens:r,stdio:i,_WASI:s}=Lt.call(this,t),o=s.createSync(e,n,r,i,t.fs,t.print,t.printErr),a=o._setMemory;delete o._setMemory,Ht.call(this,a,o),t.returnOnExit&&(o.proc_exit=Ct.bind(this))}finalizeBindings(t,n){var r,{memory:i=(null===(r=null==t?void 0:t.exports)||void 0===r?void 0:r.memory)}=void 0===n?{}:n;if(this[vt])throw new Error("WASI instance has already started");e(t,"instance"),e(t.exports,"instance.exports"),this[Ft](i),this[Ut]=t,this[vt]=!0}start(t){this.finalizeBindings(t);const{_start:e,_initialize:n}=this[Ut].exports;let s;r(e,"instance.exports._start"),i(n,"instance.exports._initialize");try{s=e()}catch(t){if(t!==Dt)throw t}return s instanceof Promise?s.then((()=>this[Dt]),(t=>{if(t!==Dt)throw t;return this[Dt]})):this[Dt]}initialize(t){this.finalizeBindings(t);const{_start:e,_initialize:n}=this[Ut].exports;if(i(e,"instance.exports._start"),void 0!==n)return r(n,"instance.exports._initialize"),n()}getImportObject(){return{[this[Rt]]:this.wasiImport}}}function Ct(t){throw this[Dt]=t,Dt}async function kt(t=Pt){const n=Object.create(Ot.prototype),{args:i,env:s,preopens:o,stdio:a,_WASI:c}=Lt.call(n,t);void 0!==t.asyncify&&(e(t.asyncify,"options.asyncify"),r(t.asyncify.wrapImportFunction,"options.asyncify.wrapImportFunction"));const u=await c.createAsync(i,s,o,a,t.fs,t.print,t.printErr,t.asyncify),f=u._setMemory;return delete u._setMemory,Ht.call(n,f,u),t.returnOnExit&&(u.proc_exit=Ct.bind(n)),n}export{f as Asyncify,nt as Memory,Ot as WASI,et as WebAssemblyMemory,l as asyncifyLoad,p as asyncifyLoadSync,kt as createAsyncWASI,rt as extendMemory,g as load,_ as loadSync,ot as wrapAsyncExport,st as wrapAsyncImport,at as wrapExports};