1var tt=Object.defineProperty,et=(t,e)=>{for(var i in e)tt(t,i,{get:e[i],enumerable:!0})},it={};et(it,{Clock:()=>Y,EVENT_SIZE:()=>B,EventReadWriteFlags:()=>rt,EventType:()=>$,FILESTAT_SIZE:()=>F,FileDescriptorFlags:()=>T,FileStatTimestampFlags:()=>b,FileType:()=>G,LookupFlags:()=>st,OpenFlags:()=>p,PreopenType:()=>z,Result:()=>V,RightsFlags:()=>_,SUBSCRIPTION_SIZE:()=>C,SubscriptionClockFlags:()=>j,Whence:()=>W});var V=(t=>(t[t.SUCCESS=0]="SUCCESS",t[t.E2BIG=1]="E2BIG",t[t.EACCESS=2]="EACCESS",t[t.EADDRINUSE=3]="EADDRINUSE",t[t.EADDRNOTAVAIL=4]="EADDRNOTAVAIL",t[t.EAFNOSUPPORT=5]="EAFNOSUPPORT",t[t.EAGAIN=6]="EAGAIN",t[t.EALREADY=7]="EALREADY",t[t.EBADF=8]="EBADF",t[t.EBADMSG=9]="EBADMSG",t[t.EBUSY=10]="EBUSY",t[t.ECANCELED=11]="ECANCELED",t[t.ECHILD=12]="ECHILD",t[t.ECONNABORTED=13]="ECONNABORTED",t[t.ECONNREFUSED=14]="ECONNREFUSED",t[t.ECONNRESET=15]="ECONNRESET",t[t.EDEADLK=16]="EDEADLK",t[t.EDESTADDRREQ=17]="EDESTADDRREQ",t[t.EDOM=18]="EDOM",t[t.EDQUOT=19]="EDQUOT",t[t.EEXIST=20]="EEXIST",t[t.EFAULT=21]="EFAULT",t[t.EFBIG=22]="EFBIG",t[t.EHOSTUNREACH=23]="EHOSTUNREACH",t[t.EIDRM=24]="EIDRM",t[t.EILSEQ=25]="EILSEQ",t[t.EINPROGRESS=26]="EINPROGRESS",t[t.EINTR=27]="EINTR",t[t.EINVAL=28]="EINVAL",t[t.EIO=29]="EIO",t[t.EISCONN=30]="EISCONN",t[t.EISDIR=31]="EISDIR",t[t.ELOOP=32]="ELOOP",t[t.EMFILE=33]="EMFILE",t[t.EMLINK=34]="EMLINK",t[t.EMSGSIZE=35]="EMSGSIZE",t[t.EMULTIHOP=36]="EMULTIHOP",t[t.ENAMETOOLONG=37]="ENAMETOOLONG",t[t.ENETDOWN=38]="ENETDOWN",t[t.ENETRESET=39]="ENETRESET",t[t.ENETUNREACH=40]="ENETUNREACH",t[t.ENFILE=41]="ENFILE",t[t.ENOBUFS=42]="ENOBUFS",t[t.ENODEV=43]="ENODEV",t[t.ENOENT=44]="ENOENT",t[t.ENOEXEC=45]="ENOEXEC",t[t.ENOLCK=46]="ENOLCK",t[t.ENOLINK=47]="ENOLINK",t[t.ENOMEM=48]="ENOMEM",t[t.ENOMSG=49]="ENOMSG",t[t.ENOPROTOOPT=50]="ENOPROTOOPT",t[t.ENOSPC=51]="ENOSPC",t[t.ENOSYS=52]="ENOSYS",t[t.ENOTCONN=53]="ENOTCONN",t[t.ENOTDIR=54]="ENOTDIR",t[t.ENOTEMPTY=55]="ENOTEMPTY",t[t.ENOTRECOVERABLE=56]="ENOTRECOVERABLE",t[t.ENOTSOCK=57]="ENOTSOCK",t[t.ENOTSUP=58]="ENOTSUP",t[t.ENOTTY=59]="ENOTTY",t[t.ENXIO=60]="ENXIO",t[t.EOVERFLOW=61]="EOVERFLOW",t[t.EOWNERDEAD=62]="EOWNERDEAD",t[t.EPERM=63]="EPERM",t[t.EPIPE=64]="EPIPE",t[t.EPROTO=65]="EPROTO",t[t.EPROTONOSUPPORT=66]="EPROTONOSUPPORT",t[t.EPROTOTYPE=67]="EPROTOTYPE",t[t.ERANGE=68]="ERANGE",t[t.EROFS=69]="EROFS",t[t.ESPIPE=70]="ESPIPE",t[t.ESRCH=71]="ESRCH",t[t.ESTALE=72]="ESTALE",t[t.ETIMEDOUT=73]="ETIMEDOUT",t[t.ETXTBSY=74]="ETXTBSY",t[t.EXDEV=75]="EXDEV",t[t.ENOTCAPABLE=76]="ENOTCAPABLE",t))(V||{}),Y=(t=>(t[t.REALTIME=0]="REALTIME",t[t.MONOTONIC=1]="MONOTONIC",t[t.PROCESS_CPUTIME_ID=2]="PROCESS_CPUTIME_ID",t[t.THREAD_CPUTIME_ID=3]="THREAD_CPUTIME_ID",t))(Y||{}),W=(t=>(t[t.SET=0]="SET",t[t.CUR=1]="CUR",t[t.END=2]="END",t))(W||{}),G=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.BLOCK_DEVICE=1]="BLOCK_DEVICE",t[t.CHARACTER_DEVICE=2]="CHARACTER_DEVICE",t[t.DIRECTORY=3]="DIRECTORY",t[t.REGULAR_FILE=4]="REGULAR_FILE",t[t.SOCKET_DGRAM=5]="SOCKET_DGRAM",t[t.SOCKET_STREAM=6]="SOCKET_STREAM",t[t.SYMBOLIC_LINK=7]="SYMBOLIC_LINK",t))(G||{}),z=(t=>(t[t.DIR=0]="DIR",t))(z||{}),$=(t=>(t[t.CLOCK=0]="CLOCK",t[t.FD_READ=1]="FD_READ",t[t.FD_WRITE=2]="FD_WRITE",t))($||{}),st={SYMLINK_FOLLOW:1},p={CREAT:1,DIRECTORY:2,EXCL:4,TRUNC:8},T={APPEND:1,DSYNC:2,NONBLOCK:4,RSYNC:8,SYNC:16},_={FD_DATASYNC:BigInt(1)<<BigInt(0),FD_READ:BigInt(1)<<BigInt(1),FD_SEEK:BigInt(1)<<BigInt(2),FD_FDSTAT_SET_FLAGS:BigInt(1)<<BigInt(3),FD_SYNC:BigInt(1)<<BigInt(4),FD_TELL:BigInt(1)<<BigInt(5),FD_WRITE:BigInt(1)<<BigInt(6),FD_ADVISE:BigInt(1)<<BigInt(7),FD_ALLOCATE:BigInt(1)<<BigInt(8),PATH_CREATE_DIRECTORY:BigInt(1)<<BigInt(9),PATH_CREATE_FILE:BigInt(1)<<BigInt(10),PATH_LINK_SOURCE:BigInt(1)<<BigInt(11),PATH_LINK_TARGET:BigInt(1)<<BigInt(12),PATH_OPEN:BigInt(1)<<BigInt(13),FD_READDIR:BigInt(1)<<BigInt(14),PATH_READLINK:BigInt(1)<<BigInt(15),PATH_RENAME_SOURCE:BigInt(1)<<BigInt(16),PATH_RENAME_TARGET:BigInt(1)<<BigInt(17),PATH_FILESTAT_GET:BigInt(1)<<BigInt(18),PATH_FILESTAT_SET_SIZE:BigInt(1)<<BigInt(19),PATH_FILESTAT_SET_TIMES:BigInt(1)<<BigInt(20),FD_FILESTAT_GET:BigInt(1)<<BigInt(21),FD_FILESTAT_SET_SIZE:BigInt(1)<<BigInt(22),FD_FILESTAT_SET_TIMES:BigInt(1)<<BigInt(23),PATH_SYMLINK:BigInt(1)<<BigInt(24),PATH_REMOVE_DIRECTORY:BigInt(1)<<BigInt(25),PATH_UNLINK_FILE:BigInt(1)<<BigInt(26),POLL_FD_READWRITE:BigInt(1)<<BigInt(27),SOCK_SHUTDOWN:BigInt(1)<<BigInt(28),SOCK_ACCEPT:BigInt(1)<<BigInt(29)},b={ATIM:1,ATIM_NOW:2,MTIM:4,MTIM_NOW:8},j={SUBSCRIPTION_CLOCK_ABSTIME:1},rt={FD_READWRITE_HANGUP:1},F=64,C=48,B=32,nt=class{constructor(t){this.fs=t?.fs??{},this.args=t?.args??[],this.env=t?.env??{},this.stdin=t?.stdin??(()=>null),this.stdout=t?.stdout??(()=>{}),this.stderr=t?.stderr??(()=>{}),this.debug=t?.debug,this.isTTY=!!t?.isTTY}},at=class{constructor(t){this.nextFD=10,this.openMap=new Map,this.fs={...t},this.openMap.set(3,new u(this.fs,"/"))}
1openFile(t,e,i){let s=new g(t,i);e&&(s.buffer=new Uint8Array(new ArrayBuffer(1024),0,0));let r=this.nextFD;return this.openMap.set(r,s),this.nextFD++,[0,r]}openDir(t,e){let i=new u(t,e),s=this.nextFD;return this.openMap.set(s,i),this.nextFD++,[0,s]}hasDir(t,e){return e==="."?!0:t.containsDirectory(e)}open(t,e,i,s){let r=!!(i&p.CREAT),n=!!(i&p.DIRECTORY),a=!!(i&p.EXCL),h=!!(i&p.TRUNC),f=this.openMap.get(t);if(!(f instanceof u))return[8];if(f.containsFile(e))return n?[54]:a?[20]:this.openFile(f.get(e),h,s);if(this.hasDir(f,e)){if(e===".")return this.openDir(this.fs,"/");let o=`/${e}/`,E=Object.entries(this.fs).filter(([l])=>l.startsWith(o));return this.openDir(Object.fromEntries(E),o)}else{if(r){let o=f.fullPath(e);return this.fs[o]={path:o,mode:"binary",content:new Uint8Array,timestamps:{access:new Date,modification:new Date,change:new Date}},this.openFile(this.fs[o],h,s)}return[76]}}close(t){if(!this.openMap.has(t))return 8;let e=this.openMap.get(t);return e instanceof g&&e.sync(),this.openMap.delete(t),0}read(t,e){let i=this.openMap.get(t);return!i||i instanceof u?[8]:[0,i.read(e)]}pread(t,e,i){let s=this.openMap.get(t);return!s||s instanceof u?[8]:[0,s.pread(e,i)]}write(t,e){let i=this.openMap.get(t);return!i||i instanceof u?8:(i.write(e),0)}pwrite(t,e,i){let s=this.openMap.get(t);return!s||s instanceof u?8:(s.pwrite(e,i),0)}sync(t){let e=this.openMap.get(t);return!e||e instanceof u?8:(e.sync(),0)}seek(t,e,i){let s=this.openMap.get(t);return!s||s instanceof u?[8]:[0,s.seek(e,i)]}tell(t){let e=this.openMap.get(t);return!e||e instanceof u?[8]:[0,e.tell()]}renumber(t,e){return!this.exists(t)||!this.exists(e)?8:(t===e||(this.close(e),this.openMap.set(e,this.openMap.get(t))),0)}unlink(t,e){let i=this.openMap.get(t);if(!(i instanceof u))return 8;if(!i.contains(e))return 44;for(let s of Object.keys(this.fs))(s===i.fullPath(e)||s.startsWith(`${i.fullPath(e)}/`))&&delete this.fs[s];return 0}rename(t,e,i,s){let r=this.openMap.get(t),n=this.openMap.get(i);if(!(r instanceof u)||!(n instanceof u))return 8;if(!r.contains(e))return 44;if(n.contains(s))return 20;let a=r.fullPath(e),h=n.fullPath(s);for(let f of Object.keys(this.fs))if(f.startsWith(a)){let o=f.replace(a,h);this.fs[o]=this.fs[f],this.fs[o].path=o,delete this.fs[f]}return 0}list(t){let e=this.openMap.get(t);return e instanceof u?[0,e.list()]:[8]}stat(t){let e=this.openMap.get(t);return e instanceof g?[0,e.stat()]:[8]}pathStat(t,e){let i=this.openMap.get(t);if(!(i instanceof u))return[8];if(i.containsFile(e)){let s=i.fullPath(e);return[0,new g(this.fs[s],0).stat()]}else if(this.hasDir(i,e)){if(e===".")return[0,new u(this.fs,"/").stat()];let s=`/${e}/`,r=Object.entries(this.fs).filter(([a])=>a.startsWith(s));return[0,new u(Object.fromEntries(r),s).stat()]}else return[76]}setFlags(t,e){let i=this.openMap.get(t);return i instanceof g?(i.setFlags(e),0):8}setSize(t,e){let i=this.openMap.get(t);return i instanceof g?(i.setSize(Number(e)),0):8}setAccessTime(t,e){let i=this.openMap.get(t);return i instanceof g?(i.setAccessTime(e),0):8}setModificationTime(t,e){let i=this.openMap.get(t);return i instanceof g?(i.setModificationTime(e),0):8}pathSetAccessTime(t,e,i){let s=this.openMap.get(t);if(!(s instanceof u))return 8;let r=s.get(e);if(!r)return 76;let n=new g(r,0);return n.setAccessTime(i),n.sync(),0}pathSetModificationTime(t,e,i){let s=this.openMap.get(t);if(!(s instanceof u))return 8;let r=s.get(e);if(!r)return 76;let n=new g(r,0);return n.setModificationTime(i),n.sync(),0}pathCreateDir(t,e){let i=this.openMap.get(t);if(!(i instanceof u))return 8;if(i.contains(e))return 76;let s=`${i.fullPath(e)}/.runno`;return this.fs[s]={path:s,timestamps:{access:new Date,modification:new Date,change:new Date},mode:"string",content:""},0}exists(t){return this.openMap.has(t)}fileType(t){let e=this.openMap.get(t);return e?e instanceof g?4:3:0}fileFdflags(t){let e=this.openMap.get(t);return e instanceof g?e.fdflags:0}},g=class{constructor(t,e){if(this._offset=BigInt(0),this.isDirty=!1,this.file=t,this.file.mode==="string"){let i=new TextEncoder;this.buffer=i.encode(this.file.content)}else this.buffer=this.file.content;this.fdflags=e,this.flagAppend=!!(e&T.APPEND),this.flagDSync=!!(e&T.DSYNC),this.flagNonBlock=!!(e&T.NONBLOCK),this.flagRSync=!!(e&T.RSYNC),this.flagSync=!!(e&T.SYNC)}get offset(){return Number(this._offset)}read(t){let e=this.buffer.subarray(this.offset,this.offset+t);return this._offset+=BigInt(e.length),e}pread(t,e){return this.buffer.subarray(e,e+t)}write(t){if(this.isDirty=!0,this.flagAppend){let e=this.buffer.length;this.resize(e+t.byteLength),this.buffer.set(t,e)}else{let e=Math.max(this.offset+t.byteLength,this.buffer.byteLength);this.resize(e),this.buffer.set(t,this.offset),this._offset+=BigInt(t.byteLength)}(this.flagDSync||this.flagSync)&&this.sync()}pwrite(t,e){if(this.isDirty=!0,this.flagAppend){let i=this.buffer.length;this.resize(i+t.byteLength),this.buffer.set(t,i)}else{let i=Math.max(e+t.byteLength,this.buffer.byteLength);this.resize(i),this.buffer.set(t,e)}(this.flagDSync||this.flagSync)&&this.sync()}sync(){if(!this.isDirty)return;if(this.isDirty=!1,this.file.mode==="binary"){this.file.content=new Uint8Array(this.buffer);return}let t=new TextDecoder;this.file.content=t.decode(this.buffer)}seek(t,e){switch(e){case 0:this._offset=t;break;case 1:this._offset+=t;break;case 2:this._offset=BigInt(this.buffer.length)+t;break}return this._offset}tell(){return this._offset}stat(){return{path:this.file.path,timestamps:this.file.timestamps,type:4,byteLength:this.buffer.length}}setFlags(t){this.fdflags=t}setSize(t){this.resize(t)}setAccessTime(t){this.file.timestamps.access=t}setModificationTime(t){this.file.timestamps.modification=t}resize(t){if(t<=this.buffer.buffer.byteLength){this.buffer=new Uint8Array(this.buffer.buffer,0,t);return}let e;
1this.buffer.buffer.byteLength===0?e=new ArrayBuffer(t<1024?1024:t*2):t>this.buffer.buffer.byteLength*2?e=new ArrayBuffer(t*2):e=new ArrayBuffer(this.buffer.buffer.byteLength*2);let i=new Uint8Array(e,0,t);i.set(this.buffer),this.buffer=i}};function N(t,e){let i=e.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&"),s=new RegExp(`^${i}`);return t.replace(s,"")}var u=class{constructor(t,e){this.dir=t,this.prefix=e}containsFile(t){for(let e of Object.keys(this.dir))if(N(e,this.prefix)===t)return!0;return!1}containsDirectory(t){for(let e of Object.keys(this.dir))if(N(e,this.prefix).startsWith(`${t}/`))return!0;return!1}contains(t){for(let e of Object.keys(this.dir)){let i=N(e,this.prefix);if(i===t||i.startsWith(`${t}/`))return!0}return!1}get(t){return this.dir[this.fullPath(t)]}fullPath(t){return`${this.prefix}${t}`}list(){let t=[],e=new Set;for(let i of Object.keys(this.dir)){let s=N(i,this.prefix);if(s.includes("/")){let r=s.split("/")[0];if(e.has(r))continue;e.add(r),t.push({name:r,type:3})}else t.push({name:s,type:4})}return t}stat(){return{path:this.prefix,timestamps:{access:new Date,modification:new Date,change:new Date},type:3,byteLength:0}}},U=[];function A(t){U.push(t)}function ft(){let t=U;return U=[],t}var lt=class X{static async start(e,i={}){let s=new X(i),r=await WebAssembly.instantiateStreaming(e,s.getImportObject());return s.start(r)}constructor(e){this.context=new nt(e),this.drive=new at(this.context.fs)}getImportObject(){return{wasi_snapshot_preview1:this.getImports("preview1",this.context.debug),wasi_unstable:this.getImports("unstable",this.context.debug)}}start(e,i={}){this.instance=e.instance,this.module=e.module,this.memory=i.memory??this.instance.exports.memory;let s=this.instance.exports._start;try{s()}catch(r){if(r instanceof v)return{exitCode:r.code,fs:this.drive.fs};if(r instanceof WebAssembly.RuntimeError)return{exitCode:134,fs:this.drive.fs};throw r}return{exitCode:0,fs:this.drive.fs}}getImports(e,i){let s={args_get:this.args_get.bind(this),args_sizes_get:this.args_sizes_get.bind(this),clock_res_get:this.clock_res_get.bind(this),clock_time_get:this.clock_time_get.bind(this),environ_get:this.environ_get.bind(this),environ_sizes_get:this.environ_sizes_get.bind(this),proc_exit:this.proc_exit.bind(this),random_get:this.random_get.bind(this),sched_yield:this.sched_yield.bind(this),fd_advise:this.fd_advise.bind(this),fd_allocate:this.fd_allocate.bind(this),fd_close:this.fd_close.bind(this),fd_datasync:this.fd_datasync.bind(this),fd_fdstat_get:this.fd_fdstat_get.bind(this),fd_fdstat_set_flags:this.fd_fdstat_set_flags.bind(this),fd_fdstat_set_rights:this.fd_fdstat_set_rights.bind(this),fd_filestat_get:this.fd_filestat_get.bind(this),fd_filestat_set_size:this.fd_filestat_set_size.bind(this),fd_filestat_set_times:this.fd_filestat_set_times.bind(this),fd_pread:this.fd_pread.bind(this),fd_prestat_dir_name:this.fd_prestat_dir_name.bind(this),fd_prestat_get:this.fd_prestat_get.bind(this),fd_pwrite:this.fd_pwrite.bind(this),fd_read:this.fd_read.bind(this),fd_readdir:this.fd_readdir.bind(this),fd_renumber:this.fd_renumber.bind(this),fd_seek:this.fd_seek.bind(this),fd_sync:this.fd_sync.bind(this),fd_tell:this.fd_tell.bind(this),fd_write:this.fd_write.bind(this),path_filestat_get:this.path_filestat_get.bind(this),path_filestat_set_times:this.path_filestat_set_times.bind(this),path_open:this.path_open.bind(this),path_rename:this.path_rename.bind(this),path_unlink_file:this.path_unlink_file.bind(this),path_create_directory:this.path_create_directory.bind(this),path_link:this.path_link.bind(this),path_readlink:this.path_readlink.bind(this),path_remove_directory:this.path_remove_directory.bind(this),path_symlink:this.path_symlink.bind(this),poll_oneoff:this.poll_oneoff.bind(this),proc_raise:this.proc_raise.bind(this),sock_accept:this.sock_accept.bind(this),sock_recv:this.sock_recv.bind(this),sock_send:this.sock_send.bind(this),sock_shutdown:this.sock_shutdown.bind(this),sock_open:this.sock_open.bind(this),sock_listen:this.sock_listen.bind(this),sock_connect:this.sock_connect.bind(this),sock_setsockopt:this.sock_setsockopt.bind(this),sock_bind:this.sock_bind.bind(this),sock_getlocaladdr:this.sock_getlocaladdr.bind(this),sock_getpeeraddr:this.sock_getpeeraddr.bind(this),sock_getaddrinfo:this.sock_getaddrinfo.bind(this)};e==="unstable"&&(s.path_filestat_get=this.unstable_path_filestat_get.bind(this),s.fd_filestat_get=this.unstable_fd_filestat_get.bind(this),s.fd_seek=this.unstable_fd_seek.bind(this));for(let[r,n]of Object.entries(s))s[r]=function(){let a=n.apply(this,arguments);if(i){let h=ft();a=i(r,[...arguments],a,h)??a}return a};return s}get envArray(){return Object.entries(this.context.env).map(([e,i])=>`${e}=${i}`)}args_get(e,i){let s=new DataView(this.memory.buffer);for(let r of this.context.args){s.setUint32(e,i,!0),e+=4;let n=new TextEncoder().encode(`${r}\0`);new Uint8Array(this.memory.buffer,i,n.byteLength).set(n),i+=n.byteLength}return 0}args_sizes_get(e,i){let s=this.context.args,r=s.reduce((a,h)=>a+new TextEncoder().encode(`${h}\0`).byteLength,0),n=new DataView(this.memory.buffer);return n.setUint32(e,s.length,!0),n.setUint32(i,r,!0),0}clock_res_get(e,i){switch(e){case 0:case 1:case 2:case 3:return new DataView(this.memory.buffer).setBigUint64(i,BigInt(1e6),!0),0}return 28}clock_time_get(e,i,s){switch(e){case 0:case 1:case 2:case 3:return new DataView(this.memory.buffer).setBigUint64(s,D(new Date),!0),0}return 28}environ_get(e,i){let s=new DataView(this.memory.buffer);for(let r of this.envArray){s.setUint32(e,i,!0),e+=4;let n=new TextEncoder().encode(`${r}\0`);new Uint8Array(this.memory.buffer,i,n.byteLength).set(n),i+=n.byteLength}return 0}environ_sizes_get(e,i){let s=this.envArray.reduce((n,a)=>n+new TextEncoder().encode(`${a}\0`).byteLength,0),r=new DataView(this.memory.buffer);return r.setUint32(e,this.envArray.length,!0),r.setUint32(i,s,!0),0}proc_exit(e){throw new v(e)}random_get(e,i){let s=new Uint8Array(this.memory.buffer,e,i);return globalThis.crypto.getRandomValues(s),0}sched_yield(){return 0}fd_read(e,i,s,r){if(e===1||e===2)return 58;let n=new DataView(this.memory.buffer),a=w(n,i,s),h=new TextEncoder,f=0,o=0;for(let E of a){let l;if(e===0){let c=this.context.stdin(E.byteLength);if(!c)break;l=h.encode(c)}else{let[c,m]=this.drive.read(e,E.byteLength);if(c){o=c;break}else l=m}let d=Math.min(E.byteLength,l.byteLength);E.set(l.subarray(0,d)),f+=d}return A({bytesRead:f}),n.setUint32(r,f,!0),o}fd_write(e,i,s,r){if(e===0)return 58;let n=new DataView(this.memory.buffer),a=w(n,i,s),h=new TextDecoder,f=0,o=0;for(let E of a)if(E.byteLength!==0){if(e===1||e===2){let l=e===1?this.context.stdout:this.context.stderr,d=h.decode(E);l(d),A({output:d})}else if(o=this.drive.write(e,E),o!=0)break;f+=E.byteLength}return n.setUint32(r,f,!0),o}fd_advise(){return 0}fd_allocate(e,i,s){return this.drive.pwrite(e,new Uint8Array(Number(s)),Number(i))}fd_close(e){return this.drive.close(e)}fd_datasync(e){return this.drive.sync(e)}fd_fdstat_get(e,i){if(e<3){let a;
1if(this.context.isTTY){let h=M^_.FD_SEEK^_.FD_TELL;a=L(2,0,h)}else a=L(2,0);return new Uint8Array(this.memory.buffer,i,a.byteLength).set(a),0}if(!this.drive.exists(e))return 8;let s=this.drive.fileType(e),r=this.drive.fileFdflags(e),n=L(s,r);return new Uint8Array(this.memory.buffer,i,n.byteLength).set(n),0}fd_fdstat_set_flags(e,i){return this.drive.setFlags(e,i)}fd_fdstat_set_rights(){return 0}fd_filestat_get(e,i){return this.shared_fd_filestat_get(e,i,"preview1")}unstable_fd_filestat_get(e,i){return this.shared_fd_filestat_get(e,i,"unstable")}shared_fd_filestat_get(e,i,s){let r=s==="unstable"?H:x;if(e<3){let f;switch(e){case 0:f="/dev/stdin";break;case 1:f="/dev/stdout";break;case 2:f="/dev/stderr";break;default:f="/dev/undefined";break}let o=r({path:f,byteLength:0,timestamps:{access:new Date,modification:new Date,change:new Date},type:2});return new Uint8Array(this.memory.buffer,i,o.byteLength).set(o),0}let[n,a]=this.drive.stat(e);if(n!=0)return n;A({resolvedPath:a.path,stat:a});let h=r(a);return new Uint8Array(this.memory.buffer,i,h.byteLength).set(h),0}fd_filestat_set_size(e,i){return this.drive.setSize(e,i)}fd_filestat_set_times(e,i,s,r){let n=null;r&b.ATIM&&(n=y(i)),r&b.ATIM_NOW&&(n=new Date);let a=null;if(r&b.MTIM&&(a=y(s)),r&b.MTIM_NOW&&(a=new Date),n){let h=this.drive.setAccessTime(e,n);if(h!=0)return h}if(a){let h=this.drive.setModificationTime(e,a);if(h!=0)return h}return 0}fd_pread(e,i,s,r,n){if(e===1||e===2)return 58;if(e===0)return this.fd_read(e,i,s,n);let a=new DataView(this.memory.buffer),h=w(a,i,s),f=0,o=0;for(let E of h){let[l,d]=this.drive.pread(e,E.byteLength,Number(r)+f);if(l!==0){o=l;break}let c=Math.min(E.byteLength,d.byteLength);E.set(d.subarray(0,c)),f+=c}return a.setUint32(n,f,!0),o}fd_prestat_dir_name(e,i,s){if(e!==3)return 8;let r=new TextEncoder().encode("/");return new Uint8Array(this.memory.buffer,i,s).set(r.subarray(0,s)),0}fd_prestat_get(e,i){if(e!==3)return 8;let s=new TextEncoder().encode("."),r=new DataView(this.memory.buffer,i);return r.setUint8(0,0),r.setUint32(4,s.byteLength,!0),0}fd_pwrite(e,i,s,r,n){if(e===0)return 58;if(e===1||e===2)return this.fd_write(e,i,s,n);let a=new DataView(this.memory.buffer),h=w(a,i,s),f=0,o=0;for(let E of h)if(E.byteLength!==0){if(o=this.drive.pwrite(e,E,Number(r)),o!=0)break;f+=E.byteLength}return a.setUint32(n,f,!0),o}fd_readdir(e,i,s,r,n){let[a,h]=this.drive.list(e);if(a!=0)return a;let f=[],o=0;for(let{name:I,type:O}of h){let R=ot(I,O,o);f.push(R),o++}f=f.slice(Number(r));let E=f.reduce((I,O)=>I+O.byteLength,0),l=new Uint8Array(E),d=0;for(let I of f)l.set(I,d),d+=I.byteLength;let c=new Uint8Array(this.memory.buffer,i,s),m=l.subarray(0,s);return c.set(m),new DataView(this.memory.buffer).setUint32(n,m.byteLength,!0),0}fd_renumber(e,i){return this.drive.renumber(e,i)}fd_seek(e,i,s,r){let[n,a]=this.drive.seek(e,i,s);return n!==0||(A({newOffset:a.toString()}),new DataView(this.memory.buffer).setBigUint64(r,a,!0)),n}unstable_fd_seek(e,i,s,r){let n=_t[s];return this.fd_seek(e,i,n,r)}fd_sync(e){return this.drive.sync(e)}fd_tell(e,i){let[s,r]=this.drive.tell(e);return s!==0||new DataView(this.memory.buffer).setBigUint64(i,r,!0),s}path_filestat_get(e,i,s,r,n){return this.shared_path_filestat_get(e,i,s,r,n,"preview1")}unstable_path_filestat_get(e,i,s,r,n){return this.shared_path_filestat_get(e,i,s,r,n,"unstable")}shared_path_filestat_get(e,i,s,r,n,a){let h=a==="unstable"?H:x,f=new TextDecoder().decode(new Uint8Array(this.memory.buffer,s,r));A({path:f});let[o,E]=this.drive.pathStat(e,f);if(o!=0)return o;let l=h(E);return new Uint8Array(this.memory.buffer,n,l.byteLength).set(l),o}path_filestat_set_times(e,i,s,r,n,a,h){let f=null;h&b.ATIM&&(f=y(n)),h&b.ATIM_NOW&&(f=new Date);let o=null;h&b.MTIM&&(o=y(a)),h&b.MTIM_NOW&&(o=new Date);let E=new TextDecoder().decode(new Uint8Array(this.memory.buffer,s,r));if(f){let l=this.drive.pathSetAccessTime(e,E,f);if(l!=0)return l}if(o){let l=this.drive.pathSetModificationTime(e,E,o);if(l!=0)return l}return 0}path_open(e,i,s,r,n,a,h,f,o){let E=new DataView(this.memory.buffer),l=S(this.memory,s,r),d=!!(n&p.CREAT),c=!!(n&p.DIRECTORY),m=!!(n&p.EXCL),I=!!(n&p.TRUNC),O=!!(f&T.APPEND),R=!!(f&T.DSYNC),Z=!!(f&T.NONBLOCK),Q=!!(f&T.RSYNC),q=!!(f&T.SYNC);A({path:l,openFlags:{createFileIfNone:d,failIfNotDir:c,failIfFileExists:m,truncateFile:I},fileDescriptorFlags:{flagAppend:O,flagDSync:R,flagNonBlock:Z,flagRSync:Q,flagSync:q}});let[k,J]=this.drive.open(e,l,n,f);return k||(E.setUint32(o,J,!0),k)}path_rename(e,i,s,r,n,a){let h=S(this.memory,i,s),f=S(this.memory,n,a);return A({oldPath:h,newPath:f}),this.drive.rename(e,h,r,f)}path_unlink_file(e,i,s){let r=S(this.memory,i,s);return A({path:r}),this.drive.unlink(e,r)}poll_oneoff(e,i,s,r){for(let n=0;n<s;n++){let a=new Uint8Array(this.memory.buffer,e+n*C,C),h=ht(a),f=new Uint8Array(this.memory.buffer,i+n*B,B),o=0,E=0;switch(h.type){case 0:for(;new Date<h.timeout;);f.set(Et(h.userdata,0));break;case 1:if(h.fd<3)h.fd===0?(E=0,o=32):E=8;else{let[l,d]=this.drive.stat(h.fd);E=l,o=d?d.byteLength:0}f.set(K(h.userdata,E,1,BigInt(o)));break;case 2:if(o=0,E=0,h.fd<3)h.fd===0?E=8:(E=0,o=1024);else{let[l,d]=this.drive.stat(h.fd);E=l,o=d?d.byteLength:0}f.set(K(h.userdata,E,1,BigInt(o)));break}}return new DataView(this.memory.buffer,r,4).setUint32(0,s,!0),0}path_create_directory(e,i,s){let r=S(this.memory,i,s);return this.drive.pathCreateDir(e,r)}path_link(){return 52}path_readlink(){return 52}path_remove_directory(){return 52}path_symlink(){return 52}proc_raise(){return 52}sock_accept(){return 52}sock_recv(){return 52}sock_send(){return 52}sock_shutdown(){return 52}sock_open(){return 52}sock_listen(){return 52}sock_connect(){return 52}sock_setsockopt(){return 52}sock_bind(){return 52}sock_getlocaladdr(){return 52}sock_getpeeraddr(){return 52}sock_getaddrinfo(){return 52}},M=_.FD_DATASYNC|_.FD_READ|_.FD_SEEK|_.FD_FDSTAT_SET_FLAGS|_.FD_
1SYNC|_.FD_TELL|_.FD_WRITE|_.FD_ADVISE|_.FD_ALLOCATE|_.PATH_CREATE_DIRECTORY|_.PATH_CREATE_FILE|_.PATH_LINK_SOURCE|_.PATH_LINK_TARGET|_.PATH_OPEN|_.FD_READDIR|_.PATH_READLINK|_.PATH_RENAME_SOURCE|_.PATH_RENAME_TARGET|_.PATH_FILESTAT_GET|_.PATH_FILESTAT_SET_SIZE|_.PATH_FILESTAT_SET_TIMES|_.FD_FILESTAT_GET|_.FD_FILESTAT_SET_SIZE|_.FD_FILESTAT_SET_TIMES|_.PATH_SYMLINK|_.PATH_REMOVE_DIRECTORY|_.PATH_UNLINK_FILE|_.POLL_FD_READWRITE|_.SOCK_SHUTDOWN|_.SOCK_ACCEPT,v=class extends Error{constructor(t){super(),this.code=t}};function S(t,e,i){return new TextDecoder().decode(new Uint8Array(t.buffer,e,i))}function w(t,e,i){let s=Array(i);for(let r=0;r<i;r++){let n=t.getUint32(e,!0);e+=4;let a=t.getUint32(e,!0);e+=4,s[r]=new Uint8Array(t.buffer,n,a)}return s}function ht(t){let e=new Uint8Array(8);e.set(t.subarray(0,8));let i=t[8],s=new DataView(t.buffer,t.byteOffset+9);switch(i){case 1:case 2:return{userdata:e,type:i,fd:s.getUint32(0,!0)};case 0:let r=s.getUint16(24,!0),n=D(new Date),a=s.getBigUint64(8,!0),h=s.getBigUint64(16,!0),f=r&j.SUBSCRIPTION_CLOCK_ABSTIME?a:n+a;return{userdata:e,type:i,id:s.getUint32(0,!0),timeout:y(f),precision:y(f+h)}}}function x(t){let e=new Uint8Array(F),i=new DataView(e.buffer);return i.setBigUint64(0,BigInt(0),!0),i.setBigUint64(8,BigInt(P(t.path)),!0),i.setUint8(16,t.type),i.setBigUint64(24,BigInt(1),!0),i.setBigUint64(32,BigInt(t.byteLength),!0),i.setBigUint64(40,D(t.timestamps.access),!0),i.setBigUint64(48,D(t.timestamps.modification),!0),i.setBigUint64(56,D(t.timestamps.change),!0),e}function H(t){let e=new Uint8Array(F),i=new DataView(e.buffer);return i.setBigUint64(0,BigInt(0),!0),i.setBigUint64(8,BigInt(P(t.path)),!0),i.setUint8(16,t.type),i.setUint32(20,1,!0),i.setBigUint64(24,BigInt(t.byteLength),!0),i.setBigUint64(32,D(t.timestamps.access),!0),i.setBigUint64(40,D(t.timestamps.modification),!0),i.setBigUint64(48,D(t.timestamps.change),!0),e}function L(t,e,i){let s=i??M,r=i??M,n=new Uint8Array(24),a=new DataView(n.buffer,0,24);return a.setUint8(0,t),a.setUint32(2,e,!0),a.setBigUint64(8,s,!0),a.setBigUint64(16,r,!0),n}function ot(t,e,i){let s=new TextEncoder().encode(t),r=24+s.byteLength,n=new Uint8Array(r),a=new DataView(n.buffer);return a.setBigUint64(0,BigInt(i+1),!0),a.setBigUint64(8,BigInt(P(t)),!0),a.setUint32(16,s.length,!0),a.setUint8(20,e),n.set(s,24),n}function Et(t,e){let i=new Uint8Array(32);i.set(t,0);let s=new DataView(i.buffer);return s.setUint16(8,e,!0),s.setUint16(10,0,!0),i}function K(t,e,i,s){let r=new Uint8Array(32);r.set(t,0);let n=new DataView(r.buffer);return n.setUint16(8,e,!0),n.setUint16(10,i,!0),n.setBigUint64(16,s,!0),r}function P(t,e=0){let i=3735928559^e,s=1103547991^e;for(let r=0,n;r<t.length;r++)n=t.charCodeAt(r),i=Math.imul(i^n,2654435761),s=Math.imul(s^n,1597334677);return i=Math.imul(i^i>>>16,2246822507)^Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507)^Math.imul(i^i>>>13,3266489909),4294967296*(2097151&s)+(i>>>0)}function D(t){return BigInt(t.getTime())*BigInt(1e6)}function y(t){return new Date(Number(t/BigInt(1e6)))}var _t={0:1,1:2,2:0};export{lt as WASI,nt as WASIContext,it as WASISnapshotPreview1};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.