@gjsify/example-node-express-webserver 0.46.0 → 0.48.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/index.gjs.js CHANGED
@@ -194,7 +194,7 @@ var n=Uo()(`finalhandler`),r=kl(),i=Al(),o=Ms(),s=jl(),c=qo(),l=o.isFinished;fun
194
194
  </body>
195
195
  </html>
196
196
  `}t.exports=finalhandler;function finalhandler(e,t,i){var o=i||{},s=o.env||process.env.NODE_ENV||`development`,c=o.onerror;return function(i){var o,l,u;if(!i&&t.headersSent){n(`cannot 404 after headers sent`);return}if(i?(u=getErrorStatusCode(i),u===void 0?u=getResponseStatusCode(t):o=getErrorHeaders(i),l=getErrorMessage(i,u,s)):(u=404,l=`Cannot `+e.method+` `+r(getResourceName(e))),n(`default %s`,u),i&&c&&setImmediate(c,i,e,t),t.headersSent){n(`cannot %d after headers sent`,u),e.socket&&e.socket.destroy();return}send(e,t,u,o,l)}}function getErrorHeaders(e){if(!(!e.headers||typeof e.headers!=`object`))return{...e.headers}}function getErrorMessage(e,t,n){var r;return n!==`production`&&(r=e.stack,!r&&typeof e.toString==`function`&&(r=e.toString())),r||c.message[t]}function getErrorStatusCode(e){if(typeof e.status==`number`&&e.status>=400&&e.status<600)return e.status;if(typeof e.statusCode==`number`&&e.statusCode>=400&&e.statusCode<600)return e.statusCode}function getResourceName(e){try{return s.original(e).pathname}catch{return`resource`}}function getResponseStatusCode(e){var t=e.statusCode;return(typeof t!=`number`||t<400||t>599)&&(t=500),t}function send(e,t,n,r,i){function write(){var o=createHtmlDocument(i);t.statusCode=n,e.httpVersionMajor<2&&(t.statusMessage=c.message[n]),t.removeHeader(`Content-Encoding`),t.removeHeader(`Content-Language`),t.removeHeader(`Content-Range`);for(let[e,n]of Object.entries(r??{}))t.setHeader(e,n);if(t.setHeader(`Content-Security-Policy`,`default-src 'none'`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.setHeader(`Content-Type`,`text/html; charset=utf-8`),t.setHeader(`Content-Length`,Buffer.byteLength(o,`utf8`)),e.method===`HEAD`){t.end();return}t.end(o,`utf8`)}if(l(e)){write();return}e.unpipe(),o(e,write),e.resume()}})),Nl,__exportAll,Pl=__esmMin(()=>{Nl=Object.defineProperty,__exportAll=(e,t)=>{let n={};for(var r in e)Nl(n,r,{get:e[r],enumerable:!0});return t||Nl(n,Symbol.toStringTag,{value:`Module`}),n}});function normalizePath(e){return e instanceof URL||e instanceof Y?fileURLToPath(e):typeof e==`string`?e:e.toString()}function randomName(){return[...[,,,,,,]].map(()=>`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`[Math.floor(Math.random()*62)]).join(``)}var Fl=__esmMin(()=>{Gn()});function createNodeError(e,t,n,r){return typeof e?.code==`string`?e:createNodeError$1(e,t,{path:n.toString(),dest:r?.toString()})}function requireCallback(e,t=`cb`){if(typeof e==`function`)return e;let n=TypeError(`The "${t}" argument must be of type function. Received ${describeReceived(e)}`);throw n.code=`ERR_INVALID_ARG_TYPE`,n}function describeReceived(e){if(e==null)return String(e);if(typeof e==`object`){let t=e.constructor?.name;return`an instance of ${t&&t.length>0?t:`Object`}`}if(typeof e==`string`){let t=e.length>25?`${e.slice(0,25)}...`:e;return t.includes(`'`)?`type string ("${t}")`:`type string ('${t}')`}return typeof e==`bigint`?`type bigint (${e}n)`:typeof e==`symbol`?`type symbol (${e.toString()})`:`type ${typeof e} (${String(e)})`}function invalidState(e){let t=Error(`Invalid state: ${e}`);return t.code=`ERR_INVALID_STATE`,t}var Il=__esmMin(()=>{P()});function gioEventToNodeType(e){switch(e){case Q.FileMonitorEvent.CHANGED:case Q.FileMonitorEvent.CHANGES_DONE_HINT:return`change`;case Q.FileMonitorEvent.DELETED:case Q.FileMonitorEvent.CREATED:case Q.FileMonitorEvent.RENAMED:case Q.FileMonitorEvent.MOVED_IN:case Q.FileMonitorEvent.MOVED_OUT:return`rename`;default:return null}}var WatchTree,Ll=__esmMin(()=>{Il(),$(),Bo(),P(),WatchTree=class{_monitors=new Map;_fileMonitors=new Map;_closed=!1;_root;_recursive;_fanOut;_budget;_budgetReported=!1;_onEvent;_onError;constructor(e,t,n,r,i){this._recursive=t,this._onEvent=n,this._onError=r,this._fanOut=i?.fanOut??isDarwin(),this._budget=i?.budget??(this._fanOut?4096:1/0);let o=Q.File.new_for_path(e);this._root=o.get_path()??e,this._open(this._root,o),o.query_file_type(Q.FileQueryInfoFlags.NONE,null)===Q.FileType.DIRECTORY&&(t||this._fanOut)&&this._descend(this._root,!1)}get monitorCount(){return this._monitors.size+this._fileMonitors.size}close(){this._closed=!0;for(let e of this._monitors.values())e.cancel();this._monitors.clear();for(let e of this._fileMonitors.values())e.cancel();this._fileMonitors.clear()}_open(e,t){let n=t.monitor(Q.FileMonitorFlags.NONE,null);n.connect(`changed`,(e,t,n,r)=>{this._dispatch(t,r)}),this._monitors.set(e,n)}_watchFile(e){if(this._closed||this._fileMonitors.has(e)||!this._admit(e))return;let t;try{t=Q.File.new_for_path(e).monitor(Q.FileMonitorFlags.NONE,null)}catch(e){isNotFoundError(e)||this._onError(e);return}t.connect(`changed`,(e,t,n,r)=>{if(gioEventToNodeType(r)!==`change`)return;let i=t.get_path();i!==null&&this._emit(`change`,i)}),this._fileMonitors.set(e,t)}_admit(e){if(this.monitorCount<this._budget)return!0;if(this._budgetReported)return!1;this._budgetReported=!0;let t=Error(`fs.watch: this watch holds its whole budget of ${this._budget} monitors and stopped at ${e}. Anything under ${this._root} that is not already attached is NOT being watched, and no further event will arrive for it. The budget is finite because this host needs a monitor per FILE rather than per directory, and unbounded growth of a shared process resource surfaces as an unrelated allocation failing elsewhere, in a trace that never mentions fs.watch. Watch a narrower directory.`);return t.code=`ERR_FS_WATCH_MONITOR_BUDGET`,t.path=e,this._onError(t),!1}_dispatch(e,t){let n=e.get_path();if(n===null)return;let r=gioEventToNodeType(t);if(r!==null&&this._emit(r,n),!(!this._recursive&&!this._fanOut))switch(t){case Q.FileMonitorEvent.CREATED:case Q.FileMonitorEvent.MOVED_IN:{let t=e.query_file_type(Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);t===Q.FileType.DIRECTORY?this._recursive&&this._addSubtree(n,!0):this._fanOut&&t===Q.FileType.REGULAR&&this._watchFile(n);break}case Q.FileMonitorEvent.DELETED:case Q.FileMonitorEvent.MOVED_OUT:this._dropSubtree(n);break}}_emit(e,t){let n=Ao(this._root,t);this._onEvent(e,n===``?No(t):n)}_addSubtree(e,t){if(!(this._closed||this._monitors.has(e))&&this._admit(e)){try{this._open(e,Q.File.new_for_path(e))}catch(e){isNotFoundError(e)||this._onError(e);return}this._descend(e,t)}}_descend(e,t){for(let n of this._children(e)){if(this._closed)return;if(n.isDirectory){if(!this._recursive)continue;t&&this._emit(`rename`,n.path),this._addSubtree(n.path,t)}else t&&this._emit(`rename`,n.path),this._fanOut&&n.isFile&&this._watchFile(n.path)}}_dropSubtree(e){this._fileMonitors.get(e)?.cancel(),this._fileMonitors.delete(e);let t=e+Lo;for(let[e,n]of this._fileMonitors)e.startsWith(t)&&(n.cancel(),this._fileMonitors.delete(e));for(let[n,r]of this._monitors)n!==e&&!n.startsWith(t)||(r.cancel(),this._monitors.delete(n))}_children(e){let t;try{t=Q.File.new_for_path(e).enumerate_children(`standard::name,standard::type`,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){return isNotFoundError(e)||this._onError(e),[]}let n=[];try{let r=t.next_file(null);for(;r!==null;){let i=r.get_file_type();n.push({path:ko(e,r.get_name()),isDirectory:i===Q.FileType.DIRECTORY,isFile:i===Q.FileType.REGULAR}),r=t.next_file(null)}}catch(e){isNotFoundError(e)||this._onError(e)}finally{try{t.close(null)}catch{}}return n}}});async function*watchAsync(e,t){let n=t?.signal;if(n?.aborted)return;let r=normalizePath(e),i=[],o=[],s=!1,c=null;function enqueue(e){s||(o.length>0?o.shift().resolve({value:e,done:!1}):i.push(e))}function terminate(){if(!s)for(s=!0;o.length>0;)o.shift().resolve({value:void 0,done:!0})}let l;try{l=new WatchTree(r,t?.recursive===!0,(e,t)=>{enqueue({eventType:e,filename:t})},e=>{c=e,terminate()})}catch{return}let abortHandler=()=>terminate();n?.addEventListener(`abort`,abortHandler);try{for(;!s;){if(i.length>0){yield i.shift();continue}let e=await new Promise(e=>{o.push({resolve:e})});if(e.done)break;yield e.value}if(c!==null)throw c}finally{n?.removeEventListener(`abort`,abortHandler),l.close()}}var Rl,FSWatcher,zl=__esmMin(()=>{Fl(),Ll(),K(),jn(),Rl=new WeakMap,FSWatcher=class extends q{constructor(e,t,n){super(),(!t||typeof t!=`object`)&&(t={persistent:!0});let r=t.persistent!==!1,i=new WatchTree(normalizePath(e),t.recursive===!0,(e,t)=>{this.emit(`change`,e,t)},e=>{this.emit(`error`,e)}),o=null;r&&(o=G.timeout_add(G.PRIORITY_LOW,2147483647,()=>G.SOURCE_CONTINUE)),Rl.set(this,{persistent:r,closed:!1,sourceId:o,tree:i}),n&&this.on(`change`,n)}close(){let e=Rl.get(this);e.closed||(e.closed=!0,e.tree.close(),e.sourceId!==null&&(G.source_remove(e.sourceId),e.sourceId=null))}ref(){let e=Rl.get(this);return!e.persistent&&!e.closed&&(e.persistent=!0,e.sourceId=G.timeout_add(G.PRIORITY_LOW,2147483647,()=>G.SOURCE_CONTINUE)),this}unref(){let e=Rl.get(this);return e.persistent&&(e.persistent=!1,e.sourceId!==null&&(G.source_remove(e.sourceId),e.sourceId=null)),this}}}),Bl=__exportAll$4({lchmod:()=>void 0,lchmodAsync:()=>lchmodAsync,lchmodSync:()=>void 0,lchown:()=>lchown,lchownAsync:()=>lchownAsync,lchownSync:()=>lchownSync,lutimes:()=>lutimes,lutimesAsync:()=>lutimesAsync,lutimesSync:()=>lutimesSync,utimes:()=>utimes,utimesAsync:()=>utimesAsync,utimesSync:()=>utimesSync});function toGLibDateTime(e){let t=e instanceof Date?e.getTime():typeof e==`bigint`?Number(e):typeof e==`string`?Date.parse(e):e*1e3;return G.DateTime.new_from_unix_utc(Math.floor(t/1e3))}function setTimestamps(e,t,n,r){let i=Q.File.new_for_path(e),o=new Q.FileInfo;o.set_modification_date_time(toGLibDateTime(n)),o.set_access_date_time(toGLibDateTime(t)),i.set_attributes_from_info(o,r,null)}function utimesSync(e,t,n){setTimestamps(normalizePath(e),t,n,Q.FileQueryInfoFlags.NONE)}function utimes(e,t,n,r){requireCallback(r),Promise.resolve().then(()=>utimesSync(e,t,n)).then(()=>r(null),r)}async function utimesAsync(e,t,n){utimesSync(e,t,n)}function lutimesSync(e,t,n){setTimestamps(normalizePath(e),t,n,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS)}function lutimes(e,t,n,r){requireCallback(r),Promise.resolve().then(()=>lutimesSync(e,t,n)).then(()=>r(null),r)}async function lutimesAsync(e,t,n){lutimesSync(e,t,n)}function lchownSync(e,t,n){let r=normalizePath(e),i=Q.File.new_for_path(r),o=new Q.FileInfo;t!==-1&&o.set_attribute_uint32(`unix::uid`,t),n!==-1&&o.set_attribute_uint32(`unix::gid`,n),i.set_attributes_from_info(o,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}function lchown(e,t,n,r){requireCallback(r),Promise.resolve().then(()=>lchownSync(e,t,n)).then(()=>r(null),r)}async function lchownAsync(e,t,n){lchownSync(e,t,n)}function lchmodUnsupported(){let e=Error(`The lchmod() method is not implemented`);return e.code=`ERR_METHOD_NOT_IMPLEMENTED`,e}async function lchmodAsync(e,t){throw lchmodUnsupported()}var Vl=__esmMin(()=>{Fl(),Il(),K(),$()}),Hl,Ul=__esmMin(()=>{Hl=l}),Wl,Gl=__esmMin(()=>{Ul(),Wl=Hl});function isStdFd(e){return e===0||e===1||e===2}function stdinInput(){return Kl||=Wl.InputStream.new(0,!1),Kl}function stdOutput(e){return ql[e]||(ql[e]=Wl.OutputStream.new(e,!1)),ql[e]}function readStdFdAll(e){try{let t=e===0?stdinInput():Wl.InputStream.new(e,!1),n=[],r=0;for(;;){let e=t.read_bytes(64*1024,null).get_data();if(!e||e.length===0)break;n.push(e),r+=e.length}return concat(n,r)}catch(t){if(e!==0)throw t;let[n,r]=Q.File.new_for_path(`/dev/stdin`).load_contents(null);if(!n)throw t;return r}}function readStdFdSync(e,t,n,r){let i=(e===0?stdinInput():Wl.InputStream.new(e,!1)).read_bytes(r,null).get_data();return i&&i.length>0?(new Uint8Array(t.buffer,t.byteOffset+n).set(i),i.length):0}function writeStdFdSync(e,t){return stdOutput(e).write_bytes(G.Bytes.new(t),null)}function concat(e,t){if(e.length===1)return e[0];let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Kl,ql,Jl=__esmMin(()=>{K(),$(),Gl(),Kl=null,ql={}});function getEncodingFromOptions(e={encoding:null,flag:`r`},t=`utf8`){return e===null?t:typeof e==`string`?e:typeof e==`object`&&typeof e.encoding==`string`?e.encoding:t}function encodeUint8Array(e,t){return e===`buffer`?U.from(t):new TextDecoder(e).decode(t)}function decode(e,t){if(t){let n=new TextDecoder(t),r=new TextEncoder;return n.decode(r.encode(e))}else return e}var Yl=__esmMin(()=>{W()});function createReadStream(e,t){return new ReadStream(e,t)}var ReadStream,Xl=__esmMin(()=>{Fl(),Lu(),Iu(),K(),$(),W(),gi(),ReadStream=class extends ui{bytesRead=0;path;pending=!0;fd=null;_ownFd=null;_autoCloseFd=!0;_positional=!1;_gioFile;_inputStream=null;_cancellable=new Q.Cancellable;_start;_end;_pos;_reading=!1;_readAgain=!1;_lastSize=64*1024;close(e){this._cancellable.cancel(),this._release(),this.destroy(),e&&e(null)}constructor(e,t){let n=normalizePath(e);super({highWaterMark:t?.highWaterMark??64*1024,encoding:t?.encoding,objectMode:!1}),this.path=n,this._gioFile=Q.File.new_for_path(n),this._start=t?.start??0,this._end=t?.end??1/0,this._pos=this._start,this._positional=t?.start!==void 0,typeof t?.fd==`number`&&(this._ownFd=t.fd,this.fd=t.fd,this._autoCloseFd=t.autoClose!==!1),this.once(`end`,()=>this._release())}_construct(e){if(this._ownFd!==null){this.pending=!1,e(),this.emit(`open`,this._ownFd),this.emit(`ready`);return}this._gioFile.read_async(G.PRIORITY_DEFAULT,this._cancellable,(t,n)=>{if(this.destroyed){e();return}try{this._inputStream=this._gioFile.read_finish(n),this.pending=!1,this.emit(`open`,0),this.emit(`ready`),this._start>0&&this._inputStream.can_seek()&&this._inputStream.seek(this._start,G.SeekType.SET,null),e()}catch(t){this._cancellable.is_cancelled()||e(t)}})}_read(e){if(this._lastSize=e,this._reading){this._readAgain=!0;return}this._doRead(e)}_doRead(e){if(this._ownFd!==null){if(this._reading||this.destroyed)return;this._reading=!0,G.timeout_add(G.PRIORITY_DEFAULT,0,()=>(this._reading=!1,this.destroyed||this._readThroughFd(e),G.SOURCE_REMOVE));return}let t=e;if(this._end!==1/0){let n=this._end-this._pos+1;if(n<=0){this.push(null);return}t=Math.min(e,n)}let n=this._inputStream;!n||this.destroyed||(this._reading=!0,n.read_bytes_async(t,G.PRIORITY_DEFAULT,this._cancellable,(e,t)=>{this._reading=!1;try{let e=n.read_bytes_finish(t).get_data();if(!e||e.length===0){this._readAgain=!1,this.push(null);return}this.bytesRead+=e.length,this._pos+=e.length,this.push(U.from(e)),this._readAgain&&!this._reading&&(this._readAgain=!1,this._doRead(this._lastSize))}catch(e){this._readAgain=!1,this._cancellable.is_cancelled()||this.destroy(e)}}))}_readThroughFd(e){try{let t=e;if(this._end!==1/0){let n=this._end-this._pos+1;if(n<=0){this._readAgain=!1,this.push(null);return}t=Math.min(e,n)}let n=Fu.getInstance(this._ownFd,`read`),r=U.alloc(t),i=n._readSync(r,0,t,this._positional?this._pos:null);if(i===0){this._readAgain=!1,this.push(null);return}this.bytesRead+=i,this._pos+=i,this.push(r.subarray(0,i))}catch(e){this._readAgain=!1,this.destroy(e)}}_release(){this._inputStream&&=(this._inputStream.close_async(G.PRIORITY_DEFAULT,null,()=>{}),null),this._releaseFd()}_releaseFd(){if(this._ownFd===null||!this._autoCloseFd)return;let e=this._ownFd;this._ownFd=null,this.fd=null;try{closeSync(e)}catch{}}_destroy(e,t){this._cancellable.cancel(),this._release(),t(e)}}});function openFlagValues(){return isWin32()?$l:isDarwin()?Ql:Zl}function stringFlagBits(e,t){switch(e){case`r`:return t.O_RDONLY;case`rs`:case`sr`:return t.O_RDONLY|t.O_SYNC;case`r+`:return t.O_RDWR;case`rs+`:case`sr+`:return t.O_RDWR|t.O_SYNC;case`w`:return t.O_TRUNC|t.O_CREAT|t.O_WRONLY;case`wx`:case`xw`:return t.O_TRUNC|t.O_CREAT|t.O_WRONLY|t.O_EXCL;case`w+`:return t.O_TRUNC|t.O_CREAT|t.O_RDWR;case`wx+`:case`xw+`:return t.O_TRUNC|t.O_CREAT|t.O_RDWR|t.O_EXCL;case`a`:return t.O_APPEND|t.O_CREAT|t.O_WRONLY;case`ax`:case`xa`:return t.O_APPEND|t.O_CREAT|t.O_WRONLY|t.O_EXCL;case`as`:case`sa`:return t.O_APPEND|t.O_CREAT|t.O_WRONLY|t.O_SYNC;case`a+`:return t.O_APPEND|t.O_CREAT|t.O_RDWR;case`ax+`:case`xa+`:return t.O_APPEND|t.O_CREAT|t.O_RDWR|t.O_EXCL;case`as+`:case`sa+`:return t.O_APPEND|t.O_CREAT|t.O_RDWR|t.O_SYNC;default:return}}function parseOpenFlags(e){let t=openFlagValues(),n;if(e==null)n=t.O_RDONLY;else if(typeof e==`number`)n=e;else{let r=stringFlagBits(e,t);if(r===void 0){let t=TypeError(`Unknown file open flag: ${e}`);throw t.code=`ERR_INVALID_ARG_VALUE`,t}n=r}let r=n&(t.O_RDONLY|t.O_WRONLY|t.O_RDWR);return{posix:n,readable:r===t.O_RDONLY||r===t.O_RDWR,writable:r===t.O_WRONLY||r===t.O_RDWR,append:(n&t.O_APPEND)!==0,creat:(n&t.O_CREAT)!==0,excl:(n&t.O_CREAT)!==0&&(n&t.O_EXCL)!==0,trunc:(n&t.O_TRUNC)!==0,nofollow:t.O_NOFOLLOW!==0&&(n&t.O_NOFOLLOW)!==0,directory:t.O_DIRECTORY!==0&&(n&t.O_DIRECTORY)!==0}}function normalizeMode(e,t){let n=e??t,r=n;if(typeof n==`string`){if(!/^[0-7]+$/.test(n))throw invalidMode(n);r=parseInt(n,8)}if(typeof r!=`number`)throw modeNotANumber(r);if(!Number.isInteger(r))throw modeOutOfRange(`an integer`,r);if(r<0||r>4294967295)throw modeOutOfRange(`>= 0 && <= 4294967295`,r);return r}function invalidMode(e){let t=TypeError(`The argument 'mode' must be a 32-bit unsigned integer or an octal string. Received '${e}'`);return t.code=`ERR_INVALID_ARG_VALUE`,t}function modeNotANumber(e){let t=e==null?String(e):`type ${typeof e} (${describeValue(e)})`,n=TypeError(`The "mode" argument must be of type number. Received ${t}`);return n.code=`ERR_INVALID_ARG_TYPE`,n}function describeValue(e){try{return typeof e==`object`?Object.prototype.toString.call(e):String(e)}catch{return`<unprintable>`}}function modeOutOfRange(e,t){let n=RangeError(`The value of "mode" is out of range. It must be ${e}. Received ${t}`);return n.code=`ERR_OUT_OF_RANGE`,n}var Zl,Ql,$l,eu=__esmMin(()=>{P(),Zl={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:64,O_EXCL:128,O_NOCTTY:256,O_TRUNC:512,O_APPEND:1024,O_NONBLOCK:2048,O_DSYNC:4096,O_SYNC:1052672,O_DIRECTORY:65536,O_NOFOLLOW:131072},Ql={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:512,O_EXCL:2048,O_NOCTTY:131072,O_TRUNC:1024,O_APPEND:8,O_NONBLOCK:4,O_DSYNC:4194304,O_SYNC:128,O_DIRECTORY:1048576,O_NOFOLLOW:256},$l={O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:256,O_EXCL:1024,O_NOCTTY:0,O_TRUNC:512,O_APPEND:8,O_NONBLOCK:0,O_DSYNC:0,O_SYNC:0,O_DIRECTORY:0,O_NOFOLLOW:0}}),Dirent,tu=__esmMin(()=>{$(),Bo(),Dirent=class{name;parentPath;_isFile=!1;_isDirectory=!1;_isBlockDevice=!1;_isCharacterDevice=!1;_isSymbolicLink=!1;_isFIFO=!1;_isSocket=!1;_file;constructor(e,t,n,r){switch(t||=No(e),this.name=t,this.parentPath=Mo(e),this._file=Q.File.new_for_path(e),n??this._file.query_file_type(Q.FileQueryInfoFlags.NONE,null)){case Q.FileType.DIRECTORY:this._isDirectory=!0;break;case Q.FileType.MOUNTABLE:break;case Q.FileType.REGULAR:this._isFile=!0;break;case Q.FileType.SYMBOLIC_LINK:case Q.FileType.SHORTCUT:this._isSymbolicLink=!0;break;case Q.FileType.SPECIAL:this._classifySpecialFile(e,r);break}}_classifySpecialFile(e,t){try{let n=t?.has_attribute(`unix::mode`)===!0?t:Q.File.new_for_path(e).query_info(`unix::mode`,Q.FileQueryInfoFlags.NONE,null),r=n.has_attribute(`unix::mode`)?n.get_attribute_uint32(`unix::mode`):0;if(r===0)return;switch(r&61440){case 24576:this._isBlockDevice=!0;break;case 8192:this._isCharacterDevice=!0;break;case 49152:this._isSocket=!0;break;case 4096:this._isFIFO=!0;break}}catch{}}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isBlockDevice(){return this._isBlockDevice}isCharacterDevice(){return this._isCharacterDevice}isSymbolicLink(){return this._isSymbolicLink}isFIFO(){return this._isFIFO}isSocket(){return this._isSocket}}});function fsError(e,t,n,r){let i=`${e}: ${describe(e)}, ${t}`;n&&(i+=` '${n}'`),r&&(i+=` -> '${r}'`);let o=Error(i);return o.code=e,o.errno=nu[e]??-1,o.syscall=t,n&&(o.path=n),r&&(o.dest=r),o}function describe(e){switch(e){case`ENOENT`:return`no such file or directory`;case`EEXIST`:return`file already exists`;case`EACCES`:return`permission denied`;case`EISDIR`:return`illegal operation on a directory`;case`ENOTDIR`:return`not a directory`;case`EBADF`:return`bad file descriptor`;case`EPERM`:return`operation not permitted`;case`EINVAL`:return`invalid argument`;case`ELOOP`:return`too many symbolic links encountered`;case`ENAMETOOLONG`:return`name too long`;case`EMFILE`:return`too many open files`;case`ENFILE`:return`file table overflow`;case`EROFS`:return`read-only file system`;case`ESPIPE`:return`invalid seek`;case`ENXIO`:return`no such device or address`;default:return`i/o error`}}function hasProcFd(){return ru===null&&(ru=G.file_test(`/proc/self/fd`,G.FileTest.IS_DIR)),ru}function fdPath(e){return hasProcFd()?`/proc/self/fd/${e}`:null}function openFd(e,t,n){let r=G.open(e,t.posix,n);if(r<0)throw classifyOpenFailure(e,t);return r}function closeFd(e){G.close(e)}function classifyOpenFailure(e,t){let n=nameTooLong(e,`open`);if(n)return n;let r=Q.File.new_for_path(e),i=null,o=!1;try{let e=r.query_info(`standard::type,standard::symlink-target,unix::mode,access::can-read,access::can-write`,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);answered(e)?i=e:o=!0}catch{i=null}if(o)return refusalNotAboutThePath(e,t,r,null);if(i){if(t.excl)return fsError(`EEXIST`,`open`,e);if(i.get_file_type()===Q.FileType.SYMBOLIC_LINK&&!t.nofollow){let n=walkSymlinkChain(r);if(n===`loop`)return fsError(`ELOOP`,`open`,e);if(n===`too-long`)return fsError(`ENAMETOOLONG`,`open`,e);if(n===`dangling`&&!t.creat)return fsError(`ENOENT`,`open`,e)}return i.get_file_type()===Q.FileType.DIRECTORY&&t.writable?fsError(`EISDIR`,`open`,e):t.directory&&i.get_file_type()!==Q.FileType.DIRECTORY?fsError(`ENOTDIR`,`open`,e):refusalNotAboutThePath(e,t,r,i)}if(ancestorIsNotADirectory(r))return fsError(`ENOTDIR`,`open`,e);if(!t.creat)return fsError(`ENOENT`,`open`,e);let s=r.get_parent();if(!s)return fsError(`ENOENT`,`open`,e);try{s.query_info(`standard::type`,Q.FileQueryInfoFlags.NONE,null)}catch{return fsError(`ENOENT`,`open`,e)}return refusalNotAboutThePath(e,t,r,null)}function ancestorIsNotADirectory(e){for(let t=e.get_parent();t;t=t.get_parent()){let e;try{e=t.query_info(`standard::type`,Q.FileQueryInfoFlags.NONE,null)}catch{continue}return answered(e)?e.get_file_type()!==Q.FileType.DIRECTORY:!1}return!1}function answered(e){return e!==null&&e.has_attribute(`standard::type`)}function nameTooLong(e,t){let n=new TextEncoder;if(n.encode(e).length>4096)return fsError(`ENAMETOOLONG`,t,e);for(let r of splitPathComponents(e))if(n.encode(r).length>255)return fsError(`ENAMETOOLONG`,t,e);return null}function walkSymlinkChain(e){let t=new TextEncoder,n=e;for(let e=0;e<40;e++){let e;try{e=n.query_info(`standard::type,standard::symlink-target`,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch{return`dangling`}if(!answered(e)||e.get_file_type()!==Q.FileType.SYMBOLIC_LINK)return`resolved`;let r=e.get_symlink_target();if(!r)return`dangling`;if(t.encode(r).length>4096)return`too-long`;let i=n.get_parent();n=r.startsWith(`/`)?Q.File.new_for_path(r):i?.resolve_relative_path(r)??Q.File.new_for_path(r)}return`loop`}function refusalNotAboutThePath(e,t,n,r){let i=G.open(`/dev/null`,0,0);if(i<0)return fsError(`EMFILE`,`open`,e);G.close(i);let o=r!==null&&(r.get_attribute_uint32(`unix::mode`)&146)==0;if((t.writable||t.creat)&&!o)try{if(n.query_filesystem_info(`filesystem::readonly`,null).get_attribute_boolean(`filesystem::readonly`))return fsError(`EROFS`,`open`,e)}catch{}return r&&nothingOnTheOtherEnd(t,r)?fsError(`ENXIO`,`open`,e):fsError(`EACCES`,`open`,e)}function nothingOnTheOtherEnd(e,t){if(!t.has_attribute(`unix::mode`))return!1;let n=t.get_attribute_uint32(`unix::mode`)&61440;if(!(n===8192||n===24576||n===4096))return!1;let permits=e=>t.has_attribute(e)&&t.get_attribute_boolean(e);return!(e.readable&&!permits(`access::can-read`)||e.writable&&!permits(`access::can-write`))}function classifyMkdirFailure(e){let t=nameTooLong(e,`mkdir`);if(t)return t;let n=Q.File.new_for_path(e);try{return answered(n.query_info(`standard::type`,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null))?fsError(`EEXIST`,`mkdir`,e):fsError(`EACCES`,`mkdir`,e)}catch{}let r=n.get_parent();if(!r)return fsError(`ENOENT`,`mkdir`,e);try{let t=r.query_info(`standard::type`,Q.FileQueryInfoFlags.NONE,null);if(answered(t)&&t.get_file_type()!==Q.FileType.DIRECTORY)return fsError(`ENOTDIR`,`mkdir`,e)}catch{return fsError(`ENOENT`,`mkdir`,e)}return fsError(`EACCES`,`mkdir`,e)}function seekHandle(e){let t=iu.get(e);return t||(t=G.IOChannel.unix_new(e),t.set_encoding(null),t.set_buffered(!1),t.set_close_on_unref(!1),iu.set(e,t)),t}function input(e){let t=au.get(e);return t||(t=Wl.InputStream.new(e,!1),au.set(e,t)),t}function output(e){let t=ou.get(e);return t||(t=Wl.OutputStream.new(e,!1),ou.set(e,t)),t}function isSeekableFd(e,t){let n=su.get(e);return n===void 0&&(n=probeSeekable(e,t),su.set(e,n)),n}function probeSeekable(e,t){try{let n=Q.File.new_for_path(fdPath(e)??t).query_info(`unix::mode`,Q.FileQueryInfoFlags.NONE,null);if(n.has_attribute(`unix::mode`)){let e=n.get_attribute_uint32(`unix::mode`)&61440;if(e===4096||e===49152)return!1}}catch{}try{return seekHandle(e).seek_position(0,G.SeekType.CUR),!0}catch{return!1}}function seekFd(e,t){seekHandle(e).seek_position(t,G.SeekType.SET)}function tellFd(e){if(!hasProcFd())return null;try{let[t,n]=G.file_get_contents(`/proc/self/fdinfo/${e}`);if(!t)return null;let r=/^pos:\s*(\d+)/m.exec(new TextDecoder().decode(n));return r?Number(r[1]):null}catch{return null}}function readFd(e,t){return t<=0?new Uint8Array:input(e).read_bytes(t,null).get_data()??new Uint8Array}function writeFd(e,t){if(t.length===0)return 0;let[,n]=output(e).write_all(t,null);return n}function fsyncFd(e){output(e).flush(null),G.fsync(e)}function releaseFd(e){let t=ou.get(e);if(t)try{t.flush(null)}catch{}iu.delete(e),au.delete(e),ou.delete(e),su.delete(e)}function sizeOfFd(e,t){let n=fdPath(e)??t,r=Q.File.new_for_path(n).query_info(`standard::size`,Q.FileQueryInfoFlags.NONE,null);return Number(r.get_size())}function truncateFd(e,t,n){let r=Q.File.new_for_path(fdPath(e)??n),i;try{let e=r.append_to(Q.FileCreateFlags.NONE,null);try{e.truncate(t,null)}finally{e.close(null)}return}catch(e){i=e}try{let e=r.open_readwrite(null);try{e.get_output_stream().truncate(t,null)}finally{e.close(null)}return}catch{}throw createNodeError(i,`ftruncate`,n)}var nu,ru,iu,au,ou,su,cu=__esmMin(()=>{Il(),K(),$(),P(),Gl(),nu={EPERM:-1,ENOENT:-2,EIO:-5,ENXIO:-6,EBADF:-9,EACCES:-13,EEXIST:-17,ENOTDIR:-20,EISDIR:-21,EINVAL:-22,ENFILE:-23,EMFILE:-24,ETXTBSY:-26,ENOSPC:-28,ESPIPE:-29,EROFS:-30,ENAMETOOLONG:-36,ENOTEMPTY:-39,ELOOP:-40},ru=null,iu=new Map,au=new Map,ou=new Map,su=new Map});function populateFromInfo(e){let t=e.get_attribute_uint64(`time::access`),n=e.get_attribute_uint32(`time::access-usec`)||0,r=e.get_attribute_uint64(`time::modified`),i=e.get_attribute_uint32(`time::modified-usec`)||0,o=e.get_attribute_uint64(`time::changed`),s=e.get_attribute_uint32(`time::changed-usec`)||0,c=e.get_attribute_uint64(`time::created`),l=e.get_attribute_uint32(`time::created-usec`)||0,u=t*1e3+n/1e3,d=r*1e3+i/1e3,p=o?o*1e3+s/1e3:d,m=c?c*1e3+l/1e3:p;return{dev:e.get_attribute_uint32(`unix::device`)||0,ino:Number(e.get_attribute_uint64(`unix::inode`)||0),mode:e.get_attribute_uint32(`unix::mode`)||0,nlink:e.get_attribute_uint32(`unix::nlink`)||0,uid:e.get_attribute_uint32(`unix::uid`)||0,gid:e.get_attribute_uint32(`unix::gid`)||0,rdev:e.get_attribute_uint32(`unix::rdev`)||0,size:Number(e.get_size()||0),blksize:e.get_attribute_uint32(`unix::block-size`)||4096,blocks:Number(e.get_attribute_uint64(`unix::blocks`)||0),atimeMs:u,mtimeMs:d,ctimeMs:p,birthtimeMs:m,atime:new Date(u),mtime:new Date(d),ctime:new Date(p),birthtime:new Date(m)}}function statsFrom(e,t,n,r){if(!answered(e))throw fsError(`EACCES`,n,t);return r?new BigIntStats(e,t):new Stats(e,t)}var lu,Stats,BigIntStats,uu=__esmMin(()=>{tu(),cu(),$(),Bo(),lu=`standard::*,time::*,unix::*`,Stats=class extends Dirent{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atime;mtime;ctime;birthtime;_info;constructor(e,t,n){let r,i;e instanceof Q.FileInfo?(r=e,i=t.toString(),n||=No(i)):(i=e.toString(),typeof t==`string`&&(n=t),n||=No(i),r=Q.File.new_for_path(i).query_info(lu,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(i,n,r.get_file_type(),r),this._info=r;let o=populateFromInfo(r);this.dev=o.dev,this.ino=o.ino,this.mode=o.mode,this.nlink=o.nlink,this.uid=o.uid,this.gid=o.gid,this.rdev=o.rdev,this.size=o.size,this.blksize=o.blksize,this.blocks=o.blocks,this.atimeMs=o.atimeMs,this.mtimeMs=o.mtimeMs,this.ctimeMs=o.ctimeMs,this.birthtimeMs=o.birthtimeMs,this.atime=o.atime,this.mtime=o.mtime,this.ctime=o.ctime,this.birthtime=o.birthtime}},BigIntStats=class extends Dirent{dev;ino;mode;nlink;uid;gid;rdev;size;blksize;blocks;atimeMs;mtimeMs;ctimeMs;birthtimeMs;atimeNs;mtimeNs;ctimeNs;birthtimeNs;atime;mtime;ctime;birthtime;_info;constructor(e,t,n){let r,i;e instanceof Q.FileInfo?(r=e,i=t.toString(),n||=No(i)):(i=e.toString(),typeof t==`string`&&(n=t),n||=No(i),r=Q.File.new_for_path(i).query_info(lu,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)),super(i,n,r.get_file_type(),r),this._info=r;let o=populateFromInfo(r);this.dev=BigInt(o.dev),this.ino=BigInt(o.ino),this.mode=BigInt(o.mode),this.nlink=BigInt(o.nlink),this.uid=BigInt(o.uid),this.gid=BigInt(o.gid),this.rdev=BigInt(o.rdev),this.size=BigInt(o.size),this.blksize=BigInt(o.blksize),this.blocks=BigInt(o.blocks),this.atimeMs=BigInt(Math.trunc(o.atimeMs)),this.mtimeMs=BigInt(Math.trunc(o.mtimeMs)),this.ctimeMs=BigInt(Math.trunc(o.ctimeMs)),this.birthtimeMs=BigInt(Math.trunc(o.birthtimeMs)),this.atimeNs=this.atimeMs*1000000n,this.mtimeNs=this.mtimeMs*1000000n,this.ctimeNs=this.ctimeMs*1000000n,this.birthtimeNs=this.birthtimeMs*1000000n,this.atime=o.atime,this.mtime=o.mtime,this.ctime=o.ctime,this.birthtime=o.birthtime}}});function gbytesToUint8Array(e){return e.toArray()}var du=__esmMin(()=>{});function existsSync(e){return typeof e!=`string`||e===``?!1:Q.File.new_for_path(e).query_exists(null)}var fu=__esmMin(()=>{$(),Gl()});async function readBytesAsync(e,t=4096,n=G.PRIORITY_DEFAULT,r=null){return new Promise((i,o)=>{e.read_bytes_async(t,n,r,(t,n)=>{try{let t=e.read_bytes_finish(n);return t.get_size()===0?i(null):i(gbytesToUint8Array(t))}catch(e){let t=e;if(typeof t.matches==`function`&&(t.matches(Q.IOErrorEnum,Q.IOErrorEnum.PARTIAL_INPUT)||t.matches(Q.IOErrorEnum,Q.IOErrorEnum.CONNECTION_CLOSED)||t.matches(Q.IOErrorEnum,Q.IOErrorEnum.BROKEN_PIPE)||t.matches(Q.IOErrorEnum,Q.IOErrorEnum.CLOSED)))return i(null);o(e)}})})}var pu=__esmMin(()=>{du(),K(),$()}),mu=__esmMin(()=>{du(),k(),fu(),pu()});function statSync(e,t){let n=normalizePath(e);try{return statsFrom(Q.File.new_for_path(n).query_info(lu,Q.FileQueryInfoFlags.NONE,null),n,`stat`,t?.bigint)}catch(e){if(t?.throwIfNoEntry===!1&&isNotFoundError(e))return;throw createNodeError(e,`stat`,n)}}function lstatSync(e,t){let n=normalizePath(e);try{return statsFrom(Q.File.new_for_path(n).query_info(lu,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),n,`lstat`,t?.bigint)}catch(e){if(t?.throwIfNoEntry===!1&&isNotFoundError(e))return;throw createNodeError(e,`lstat`,n)}}function readdirSync(e,t){let n=normalizePath(e),r=Q.File.new_for_path(n).enumerate_children(`standard::name,standard::type`,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null),i=[];try{let e=r.next_file(null);for(;e!==null;)i.push({name:e.get_name(),type:e.get_file_type()}),e=r.next_file(null)}finally{try{r.close(null)}catch{}}let o=[];for(let e of i){let r=ko(n,e.name);if(t?.withFileTypes?o.push(new Dirent(r,e.name,e.type)):o.push(e.name),t?.recursive&&e.type===Q.FileType.DIRECTORY){let n=readdirSync(r,t);for(let t of n)typeof t==`string`?o.push(ko(e.name,t)):o.push(t)}}return o}function realpathSync(e){let t=normalizePath(e);return resolveEveryComponent(Q.File.new_for_path(t),{left:40},t)}function resolveEveryComponent(e,t,n){let r=e.get_parent();return expandSymlinks(r===null?e:Q.File.new_for_path(resolveEveryComponent(r,t,n)).get_child(e.get_basename()),t,n)}function expandSymlinks(e,t,n){let r=e;for(;;){let e=r.query_info(`standard::is-symlink,standard::symlink-target`,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(!e.get_is_symlink())return r.get_path();if(--t.left<0)throw Error(`ELOOP: too many levels of symbolic links, realpath '${n}'`);let i=e.get_symlink_target(),o=r.get_parent(),s=G.path_is_absolute(i)?Q.File.new_for_path(i):(o??r).resolve_relative_path(i);r=Q.File.new_for_path(resolveEveryComponent(s,t,n))}}function symlinkSync(e,t,n){let r=normalizePath(t),i=normalizePath(e);Q.File.new_for_path(r).make_symbolic_link(i,null)}function readFileSync(e,t={encoding:null,flag:`r`}){if(e instanceof Fu&&(e=e.fd),typeof e==`number`&&isStdFd(e))return encodeUint8Array(getEncodingFromOptions(t,`buffer`),readStdFdAll(e));if(typeof e==`number`)return encodeUint8Array(getEncodingFromOptions(t,`buffer`),Fu.getInstance(e,`read`)._readToEndSync());let n=normalizePath(e),r=Q.File.new_for_path(n);try{let[e,i]=r.load_contents(null);if(!e)throw createNodeError(Error(`failed to read file`),`read`,n);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),i)}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`read`,n)}}function mkdirSync(e,t){let n=!1,r;t!=null&&(typeof t==`object`?(t.recursive&&(n=t.recursive),t.mode!==void 0&&(r=t.mode)):r=t),e=normalizePath(e);let i=normalizeMode(r,511);if(n)return mkdirSyncRecursive(e,i);mkdirWithMode(e,i)}function mkdirWithMode(e,t){if(G.mkdir(e,t)!==0)throw classifyMkdirFailure(e)}function mkdirSyncRecursive(e,t){if(G.mkdir(e,t)===0)return e;let n=classifyMkdirFailure(e);if(n.code===`EEXIST`){if(G.file_test(e,G.FileTest.IS_DIR))return;throw n}if(n.code!==`ENOENT`)throw n;let r=ko(e,`..`),i=Q.File.new_for_path(r).get_path();if(i===e)throw n;let o=mkdirSyncRecursive(i,t);return mkdirWithMode(e,t),o??e}function rmdirSync(e,t){let n=normalizePath(e),r=Q.File.new_for_path(n);try{if(r.query_info(`standard::type`,Q.FileQueryInfoFlags.NONE,null).get_file_type()!==Q.FileType.DIRECTORY)throw createNodeError(Object.assign(Error(),{code:4}),`rmdir`,n);if(r.enumerate_children(`standard::name`,Q.FileQueryInfoFlags.NONE,null).next_file(null)!==null)throw createNodeError(Object.assign(Error(),{code:5}),`rmdir`,n);r.delete(null)}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`rmdir`,n)}}function unlinkSync(e){let t=normalizePath(e),n=Q.File.new_for_path(t);try{n.delete(null)}catch(e){throw createNodeError(e,`unlink`,t)}}function writeWholeFile(e,t,n,r){let i=getEncodingFromOptions(n,`utf8`),o=typeof n==`object`&&n?n:{},s=typeof t==`string`?U.from(t,i||`utf8`):t;if(typeof e==`number`||e instanceof Fu){if(typeof e==`number`&&isStdFd(e)){writeStdFdSync(e,s);return}Fu.getInstance(e,`write`)._writeSync(s,null);return}let c=new Fu({path:normalizePath(e),flags:o.flag??r,mode:o.mode??438});try{c._writeSync(s,null)}finally{c._closeSync()}}function writeFileSync(e,t,n){writeWholeFile(e,t,n??null,`w`)}function renameSync(e,t){let n=normalizePath(e),r=normalizePath(t),i=Q.File.new_for_path(n),o=Q.File.new_for_path(r);try{i.move(o,Q.FileCopyFlags.OVERWRITE,null,null)}catch(e){throw createNodeError(e,`rename`,n,r)}}function copyFileSync(e,t,n){let r=normalizePath(e),i=normalizePath(t),o=Q.File.new_for_path(r),s=Q.File.new_for_path(i),c=Q.FileCopyFlags.NONE;n&&!(n&1)?c=Q.FileCopyFlags.OVERWRITE:n||(c=Q.FileCopyFlags.OVERWRITE);try{o.copy(s,c,null,null)}catch(e){throw createNodeError(e,`copyfile`,r,i)}stripPrivilegeBitsAfterCopy(s,r,i)}function stripPrivilegeBitsAfterCopy(e,t,n){try{let t=e.query_info(`unix::mode,standard::size`,Q.FileQueryInfoFlags.NONE,null);if(t.get_size()===0)return;let n=t.get_attribute_uint32(`unix::mode`),r=n&-2049;if((isDarwin()||n&8)&&(r&=-1025),r===n)return;e.set_attribute_uint32(`unix::mode`,r,Q.FileQueryInfoFlags.NONE,null)}catch(e){throw createNodeError(e,`copyfile`,t,n)}}function accessSync(e,t){let n=normalizePath(e),r=Q.File.new_for_path(n);try{let e=r.query_info(`access::*`,Q.FileQueryInfoFlags.NONE,null);if(t!==void 0&&t!==0){let r={code:14,message:`permission denied, access '${n}'`};if(t&4&&!e.get_attribute_boolean(`access::can-read`)||t&2&&!e.get_attribute_boolean(`access::can-write`)||t&1&&!e.get_attribute_boolean(`access::can-execute`))throw createNodeError(r,`access`,n)}}catch(e){throw e.code&&typeof e.code==`string`?e:createNodeError(e,`access`,n)}}function appendFileSync(e,t,n){writeWholeFile(e,t,n??null,`a`)}function readlinkSync(e,t){let n=normalizePath(e),r=Q.File.new_for_path(n);try{let e=r.query_info(`standard::symlink-target`,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_symlink_target();if(!e)throw Object.assign(Error(`EINVAL: invalid argument, readlink '${n}'`),{code:`EINVAL`,errno:-22,syscall:`readlink`,path:n});return(typeof t==`string`?t:t?.encoding)===`buffer`?U.from(e):e}catch(e){throw typeof e.code==`string`?e:createNodeError(e,`readlink`,n)}}function linkSync(e,t){let n=normalizePath(e),r=normalizePath(t);if(Q.File.new_for_path(n).query_file_type(Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)===Q.FileType.UNKNOWN)throw Object.assign(Error(`ENOENT: no such file or directory, link '${n}' -> '${r}'`),{code:`ENOENT`,errno:-2,syscall:`link`,path:n,dest:r});if(Q.File.new_for_path(r).query_file_type(Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)!==Q.FileType.UNKNOWN)throw Object.assign(Error(`EEXIST: file already exists, link '${n}' -> '${r}'`),{code:`EEXIST`,errno:-17,syscall:`link`,path:n,dest:r});let i=``;try{let[,,e,t]=G.spawn_sync(null,[`ln`,`--`,n,r],null,G.SpawnFlags.SEARCH_PATH,null);if(i=e?new TextDecoder().decode(e).trim():``,!G.spawn_check_wait_status(t))throw Error(`ln exited non-zero (${t})`);return}catch(e){throw i===``&&e instanceof Error&&(i=e.message),Object.assign(Error(`EPERM: operation not permitted, link '${n}' -> '${r}'`+(i?` (${i})`:``)),{code:`EPERM`,errno:-1,syscall:`link`,path:n,dest:r})}}function truncateSync(e,t){let n=normalizePath(e),r=Q.File.new_for_path(n);try{let e=r.open_readwrite(null);try{e.get_output_stream().truncate(Math.max(0,t??0),null)}finally{e.close(null)}}catch(e){throw createNodeError(e,`truncate`,n)}}function chmodSync(e,t){let n=normalizePath(e),r=normalizeMode(t);try{Q.File.new_for_path(n).set_attribute_uint32(`unix::mode`,r,Q.FileQueryInfoFlags.NONE,null)}catch(e){throw createNodeError(e,`chmod`,n)}}function chownSync(e,t,n){let r=normalizePath(e);try{let e=Q.File.new_for_path(r),i=new Q.FileInfo;t!==-1&&i.set_attribute_uint32(`unix::uid`,t),n!==-1&&i.set_attribute_uint32(`unix::gid`,n),e.set_attributes_from_info(i,Q.FileQueryInfoFlags.NONE,null)}catch(e){throw createNodeError(e,`chown`,r)}}function watch(e,t,n){return typeof t==`function`&&(n=t,t=void 0),new FSWatcher(normalizePath(e),t,n)}function openSync(e,t,n){return new Fu({path:e,flags:t,mode:n})}function mkdtempSync(e,t){let n=getEncodingFromOptions(t),r=mkdtempAt(e);return n===`buffer`?U.from(r):decode(r,n)}function mkdtempAt(e){for(let t=0;t<64;t++){let t=e+randomName();if(G.mkdir(t,448)===0)return t;let n=classifyMkdirFailure(t);if(n.code!==`EEXIST`)throw n.syscall=`mkdtemp`,n}throw fsError(`EEXIST`,`mkdtemp`,e+`XXXXXX`)}function rmSync(e,t){let n=normalizePath(e),r=Q.File.new_for_path(n),i=t?.recursive||!1,o=t?.force||!1,s;try{s=r.query_file_type(Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(o&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}if(s===Q.FileType.SYMBOLIC_LINK){try{r.delete(null)}catch(t){if(o&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}return}if(s===Q.FileType.DIRECTORY){let r=readdirSync(e);if(!i&&r.length)throw createNodeError(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)rmSync(ko(n,e),t)}try{r.delete(null)}catch(t){if(o&&isNotFoundError(t))return;throw createNodeError(t,`rm`,e)}}var hu=__esmMin(()=>{Yl(),Fl(),Il(),zl(),Jl(),eu(),tu(),cu(),uu(),Iu(),K(),$(),Bo(),W(),mu(),P(),realpathSync.native=realpathSync});function makeEEXIST(e){let t=Error(`ERR_FS_CP_EEXIST: file already exists, copyfile '${e}'`);return t.code=`ERR_FS_CP_EEXIST`,t.syscall=`copyfile`,t.path=e,t}function makeEISDIR(e){let t=Error(`ERR_FS_EISDIR: illegal operation on a directory, copyfile '${e}'`);return t.code=`ERR_FS_EISDIR`,t.syscall=`copyfile`,t.path=e,t}function makeENOTDIR(e,t){let n=Error(`ENOTDIR: not a directory, copyfile '${e}' -> '${t}'`);return n.code=`ENOTDIR`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function makeSYMLINKLOOP(e,t){let n=Error(`ELOOP: too many levels of symbolic links, copyfile '${e}' -> '${t}'`);return n.code=`ELOOP`,n.syscall=`copyfile`,n.path=e,n.dest=t,n}function queryCopyFlags(e){let t=e.force??!0,n=Q.FileCopyFlags.NONE;return t&&(n|=Q.FileCopyFlags.OVERWRITE),e.preserveTimestamps&&(n|=Q.FileCopyFlags.TARGET_DEFAULT_MODIFIED_TIME),e.dereference||(n|=Q.FileCopyFlags.NOFOLLOW_SYMLINKS),n}function copyOneSyncFile(e,t,n,r,i){let o=i.force??!0;try{if(t.query_info(`standard::type`,Q.FileQueryInfoFlags.NONE,null).get_file_type()===Q.FileType.DIRECTORY)throw makeENOTDIR(n,r);if(!o){if(i.errorOnExist)throw makeEEXIST(r);return}}catch(e){if(typeof e.code==`string`)throw e}let s=queryCopyFlags(i);try{e.copy(t,s,null,null)}catch(e){throw createNodeError(e,`copyfile`,n,r)}}function cpOneDirSync(e,t,n,r,i){let o=n.endsWith(`/`)?``:`/`;if(r.startsWith(n+o)&&r!==n)throw makeSYMLINKLOOP(n,r);if(t.query_exists(null))try{if(t.query_info(`standard::type`,Q.FileQueryInfoFlags.NONE,null).get_file_type()!==Q.FileType.DIRECTORY)throw makeENOTDIR(r,n)}catch(e){if(typeof e.code==`string`)throw e}else try{t.make_directory_with_parents(null)}catch(e){throw createNodeError(e,`mkdir`,r)}let s;try{s=e.enumerate_children(`standard::name,standard::type,standard::is-symlink`,i.dereference?Q.FileQueryInfoFlags.NONE:Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw createNodeError(e,`scandir`,n)}let c=s.next_file(null);for(;c!==null;){let e=c.get_name(),t=ko(n,e),o=ko(r,e),l=i.filter;if(l&&!l(t,o)){c=s.next_file(null);continue}cpSyncInternal(t,o,i),c=s.next_file(null)}}function cpSyncInternal(e,t,n){let r=Q.File.new_for_path(e),i=Q.File.new_for_path(t),o;try{o=r.query_info(`standard::type,standard::is-symlink`,n.dereference?Q.FileQueryInfoFlags.NONE:Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`stat`,e)}if(o.get_file_type()===Q.FileType.DIRECTORY){if(!n.recursive)throw makeEISDIR(e);cpOneDirSync(r,i,e,t,n)}else copyOneSyncFile(r,i,e,t,n)}function cpSync(e,t,n){let r=normalizePath(e),i=normalizePath(t),o=n??{},s=Q.File.new_for_path(r),c=o.filter;if(!(c&&!c(r,i))){try{if(s.query_info(`standard::type`,o.dereference?Q.FileQueryInfoFlags.NONE:Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null).get_file_type()===Q.FileType.DIRECTORY&&!o.recursive)throw makeEISDIR(r)}catch(e){throw typeof e.code==`string`?e:createNodeError(e,`stat`,r)}cpSyncInternal(r,i,o)}}function cp(e,t,n,r){let i,o;typeof n==`function`?(o=n,i={}):(o=requireCallback(r),i=n);let s=i.filter;if(s){Promise.resolve(s(normalizePath(e),normalizePath(t))).then(n=>{if(!n){o(null);return}try{cpPromises(e,t,i).then(()=>o(null)).catch(o)}catch(e){o(e)}}).catch(o);return}Promise.resolve().then(()=>{try{cpSync(e,t,i),o(null)}catch(e){o(e)}})}async function cpPromisesDir(e,t,n){let r=e.endsWith(`/`)?``:`/`;if(t.startsWith(e+r)&&t!==e)throw makeSYMLINKLOOP(e,t);let i=Q.File.new_for_path(t);if(!i.query_exists(null))try{i.make_directory_with_parents(null)}catch(e){throw createNodeError(e,`mkdir`,t)}let o=Q.File.new_for_path(e),s;try{s=o.enumerate_children(`standard::name,standard::type`,n.dereference?Q.FileQueryInfoFlags.NONE:Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`scandir`,e)}let c=s.next_file(null);for(;c!==null;){let r=c.get_name(),i=ko(e,r),o=ko(t,r),l=n.filter;if(l&&!await Promise.resolve(l(i,o))){c=s.next_file(null);continue}await cpPromises(i,o,n),c=s.next_file(null)}}async function cpPromises(e,t,n={}){let r=normalizePath(e),i=normalizePath(t),o=Q.File.new_for_path(r),s;try{s=o.query_info(`standard::type`,n.dereference?Q.FileQueryInfoFlags.NONE:Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(e){throw createNodeError(e,`stat`,r)}if(s.get_file_type()===Q.FileType.DIRECTORY){if(!n.recursive)throw makeEISDIR(r);await cpPromisesDir(r,i,n)}else copyOneSyncFile(o,Q.File.new_for_path(i),r,i,n)}var gu=__esmMin(()=>{Fl(),Il(),$(),Bo()});function _openDir(e){let t=Q.File.new_for_path(e),n;try{n=t.enumerate_children(_u,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){throw createNodeError(t,`opendir`,e)}return new Dir(e,n)}function opendirSync(e){return _openDir(normalizePath(e))}function opendir(e,t,n){let r;if(r=typeof t==`function`?t:requireCallback(n,`callback`),typeof r!=`function`)throw TypeError(`The "callback" argument must be of type function`);Promise.resolve().then(()=>{try{let t=opendirSync(e);r(null,t)}catch(e){r(e,null)}})}async function opendirAsync(e,t){return new Promise((t,n)=>{let r=normalizePath(e),i=Q.File.new_for_path(r);i.enumerate_children_async(_u,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,G.PRIORITY_DEFAULT,null,(e,o)=>{try{let e=i.enumerate_children_finish(o);t(new Dir(r,e))}catch(e){n(createNodeError(e,`opendir`,r))}})})}var _u,Dir,vu=__esmMin(()=>{Fl(),Il(),tu(),K(),$(),_u=`standard::name,standard::type,standard::is-symlink,standard::size,standard::symlink-target,unix::uid,unix::gid,unix::mode,time::modified,time::access,time::created`,Dir=class{path;_enumerator;_closed=!1;constructor(e,t){this.path=e,this._enumerator=t}_assertOpen(){if(this._closed){let e=Error(`Directory handle was closed`);throw e.code=`ERR_DIR_CLOSED`,e}}readSync(){this._assertOpen();try{let e=this._enumerator.next_file(null);if(e===null)return null;let t=e.get_name(),n=e.get_file_type();return new Dirent(this.path.endsWith(`/`)?this.path+t:this.path+`/`+t,t,n)}catch(e){throw createNodeError(e,`readdir`,this.path)}}read(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this._assertOpen();let t=this.readSync();Promise.resolve().then(()=>e(null,t))}catch(t){Promise.resolve().then(()=>e(t,null))}return}return new Promise((e,t)=>{try{this._assertOpen(),e(this.readSync())}catch(e){t(e)}})}closeSync(){this._assertOpen(),this._closed=!0;try{this._enumerator.close(null)}catch{}this._enumerator=null}close(e){if(e!==void 0){if(typeof e!=`function`)throw TypeError(`The "callback" argument must be of type function`);try{this.closeSync(),Promise.resolve().then(()=>e(null))}catch(t){Promise.resolve().then(()=>e(t))}return}return new Promise((e,t)=>{try{this.closeSync(),e()}catch(e){t(e)}})}async*[Symbol.asyncIterator](){try{for(;;){let e=await this.read();if(e===null)break;yield e}}finally{this._closed||await this.close()}}}});function segmentToRegexSrc(e){let t=/^([!*+?@])\((.+)\)$/.exec(e);if(t){let[,e,n]=t,r=n.split(`|`).map(e=>segmentToRegexSrc(e)),i=`(?:`+r.join(`|`)+`)`;switch(e){case`!`:return`(?!(?:`+r.join(`|`)+`))[^/]*`;case`*`:return i+`*`;case`+`:return i+`+`;case`?`:return i+`?`;case`@`:return i}}let n=``,r=0;for(;r<e.length;){let t=e[r];if(t===`*`){n+=`[^/]*`,r++;continue}if(t===`?`){n+=`[^/]`,r++;continue}if(t===`[`){let t=e.indexOf(`]`,r+1);if(t===-1){n+=`\\[`,r++;continue}n+=e.slice(r,t+1),r=t+1;continue}if(t===`{`){let t=e.indexOf(`}`,r+1);if(t===-1){n+=`\\{`,r++;continue}let i=e.slice(r+1,t).split(`,`).map(e=>segmentToRegexSrc(e.trim()));n+=`(?:`+i.join(`|`)+`)`,r=t+1;continue}`.+^$|()[]{}`.includes(t)?n+=`\\`+t:n+=t,r++}return n}function globToRegex(e){e=e.replace(/\/+/g,`/`).replace(/^\.\//,``);let t=e.split(`/`),n=[];for(let e=0;e<t.length;e++){let r=t[e],i=e===t.length-1;r===`**`?i?n.length>0&&n[n.length-1]===`/`?(n.pop(),n.push(`(?:/.+)?`)):n.push(`(?:.+)?`):n.push(`(?:[^/]+/)*`):(n.push(segmentToRegexSrc(r)),i||n.push(`/`))}return RegExp(`^(?:`+n.join(``)+`)$`)}function buildExcludePredicate(e){if(!e)return null;if(typeof e==`function`)return e;let t=(Array.isArray(e)?e:[e]).map(e=>globToRegex(e));return e=>t.some(t=>t.test(e))}function matchAll(e,t,n){let r=globToRegex(e),i=buildExcludePredicate(n),o;try{o=readdirSync(t,{recursive:!0})}catch{return[]}let s=[`.`,...o],c=[];for(let e of s){let t=e.replace(/\\/g,`/`);r.test(t)&&(i&&i(t)||c.push(e))}return c}function globSync(e,t){let n=Array.isArray(e)?e:[e],r=t?.cwd?normalizePath(t.cwd):globalThis.process?.cwd?.()??`/`,i=t?.exclude,o=new Set,s=[];for(let e of n)for(let t of matchAll(e,r,i))o.has(t)||(o.add(t),s.push(t));return s}function glob(e,t,n){let r,i;typeof t==`function`?(i=t,r={}):(i=requireCallback(n),r=t||{}),Promise.resolve().then(()=>{try{let t=globSync(e,r);i(null,t)}catch(e){i(e,[])}})}async function*globAsync(e,t){let n=globSync(e,t);for(let e of n)yield e}var yu=__esmMin(()=>{Fl(),Il(),hu()});function buildStatFs(e){let t=Number(e.get_attribute_uint64(`filesystem::size`)??0),n=Number(e.get_attribute_uint64(`filesystem::free`)??0),r=Math.floor(t/xu),i=Math.floor(n/xu);return{type:0,bsize:xu,blocks:r,bfree:i,bavail:i,files:0,ffree:0}}function buildBigIntStatFs(e){let t=BigInt(e.get_attribute_uint64(`filesystem::size`)??0),n=BigInt(e.get_attribute_uint64(`filesystem::free`)??0),r=BigInt(xu),i=t/r,o=n/r;return{type:0n,bsize:r,blocks:i,bfree:o,bavail:o,files:0n,ffree:0n}}function statfsSync(e,t){let n=Q.File.new_for_path(normalizePath(e)).query_filesystem_info(bu,null);return t?.bigint===!0?buildBigIntStatFs(n):buildStatFs(n)}function queryFsInfoAsync(e,t){return new Promise((n,r)=>{let i=Q.File.new_for_path(normalizePath(e));i.query_filesystem_info_async(bu,G.PRIORITY_DEFAULT,null,(e,o)=>{try{let e=i.query_filesystem_info_finish(o);n(t?buildBigIntStatFs(e):buildStatFs(e))}catch(e){r(e)}})})}function statfs(e,t,n){let r=typeof t==`function`?t:requireCallback(n);queryFsInfoAsync(e,(typeof t==`function`?{}:t)?.bigint===!0).then(e=>r(null,e),e=>r(e,null))}async function statfsAsync(e,t){return queryFsInfoAsync(e,t?.bigint===!0)}var bu,xu,Su=__esmMin(()=>{Fl(),Il(),K(),$(),bu=[`filesystem::size`,`filesystem::free`].join(`,`),xu=4096});async function mkdir$1(e,t){return mkdirSync(normalizePath(e),t)}async function readFile$1(e,t={encoding:null,flag:`r`}){if(e instanceof Fu||typeof e==`number`){let n=Fu.getInstance(e,`read`);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),n._readToEndSync())}let n=normalizePath(e),r=Q.File.new_for_path(n),i,o;try{[i,o]=await new Promise((e,t)=>{r.load_contents_async(null,(n,i)=>{try{e(r.load_contents_finish(i))}catch(e){t(e)}})})}catch(e){throw createNodeError(e,`open`,n)}if(!i)throw createNodeError(Error(`failed to read file`),`open`,n);return encodeUint8Array(getEncodingFromOptions(t,`buffer`),o)}async function mkdtemp$1(e,t){let n=getEncodingFromOptions(t);return decode(mkdtempAt(e),n)}async function writeFile$1(e,t,n){writeFileSync(e,typeof t==`string`||t instanceof Uint8Array?t:String(t),n??null)}async function rmdir$1(e,t){let n=normalizePath(e),r=Q.File.new_for_path(n);if((await new Promise((e,t)=>{r.query_info_async(`standard::type`,Q.FileQueryInfoFlags.NONE,G.PRIORITY_DEFAULT,null,(i,o)=>{try{e(r.query_info_finish(o))}catch(e){t(createNodeError(e,`rmdir`,n))}})})).get_file_type()!==Q.FileType.DIRECTORY)throw createNodeError(Object.assign(Error(),{code:4}),`rmdir`,n);if((await new Promise((e,t)=>{r.enumerate_children_async(`standard::name`,Q.FileQueryInfoFlags.NONE,G.PRIORITY_DEFAULT,null,(i,o)=>{try{e(r.enumerate_children_finish(o))}catch(e){t(createNodeError(e,`rmdir`,n))}})})).next_file(null)!==null)throw createNodeError(Object.assign(Error(),{code:5}),`rmdir`,n);await new Promise((e,t)=>{r.delete_async(G.PRIORITY_DEFAULT,null,(i,o)=>{try{r.delete_finish(o),e()}catch(e){t(createNodeError(e,`rmdir`,n))}})})}async function unlink$1(e){let t=normalizePath(e),n=Q.File.new_for_path(t);await new Promise((e,r)=>{n.delete_async(G.PRIORITY_DEFAULT,null,(i,o)=>{try{n.delete_finish(o),e()}catch(e){r(createNodeError(e,`unlink`,t))}})})}async function open$1(e,t,n){return new Fu({path:e,flags:t,mode:n})}async function write$1(e,t,n,r,i){return typeof t==`string`?_writeStr(e,t,n,r):_writeBuf(e,t,n,r,i)}async function _writeBuf(e,t,n,r,i){return{bytesWritten:(await Fu.getInstance(e,`write`).write(t,n,r,i)).bytesWritten,buffer:t}}async function _writeStr(e,t,n,r){return{bytesWritten:(await Fu.getInstance(e,`write`).write(t,n,r)).bytesWritten,buffer:t}}function queryInfoAsync(e,t,n,r){let i=normalizePath(e);return new Promise((e,o)=>{let s=Q.File.new_for_path(i);s.query_info_async(lu,t,G.PRIORITY_DEFAULT,null,(t,c)=>{try{e(statsFrom(s.query_info_finish(c),i,n,r?.bigint))}catch(e){o(createNodeError(e,n,i))}})})}async function stat$1(e,t){return queryInfoAsync(e,Q.FileQueryInfoFlags.NONE,`stat`,t)}async function lstat$1(e,t){return queryInfoAsync(e,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,t)}async function readdir$1(e,t){try{return readdirSync(e,t)}catch(t){throw createNodeError(t,`scandir`,e)}}async function realpath$1(e){return realpathSync(e)}async function symlink$1(e,t,n){let r=normalizePath(t),i=normalizePath(e);return new Promise((e,t)=>{let n=Q.File.new_for_path(r);n.make_symbolic_link_async(i,G.PRIORITY_DEFAULT,null,(o,s)=>{try{n.make_symbolic_link_finish(s),e()}catch(e){t(createNodeError(e,`symlink`,i,r))}})})}async function rm$1(e,t){let n=normalizePath(e),r=Q.File.new_for_path(n),i=t?.recursive||!1,o=t?.force||!1,s;try{s=r.query_file_type(Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null)}catch(t){if(o)return;throw createNodeError(t,`rm`,e)}if(s===Q.FileType.SYMBOLIC_LINK){await new Promise((t,n)=>{r.delete_async(G.PRIORITY_DEFAULT,null,(i,s)=>{try{r.delete_finish(s),t()}catch(r){if(o){t();return}n(createNodeError(r,`rm`,e))}})});return}if(s===Q.FileType.DIRECTORY){let r=await readdir$1(e,{withFileTypes:!0});if(!i&&r.length)throw createNodeError(Object.assign(Error(),{code:5}),`rm`,e);for(let e of r)typeof e!=`string`&&await rm$1(ko(n,e.name),t)}await new Promise((t,n)=>{r.delete_async(G.PRIORITY_DEFAULT,null,(i,s)=>{try{r.delete_finish(s),t()}catch(r){if(o){t();return}n(createNodeError(r,`rm`,e))}})})}async function rename$1(e,t){renameSync(e,t)}async function copyFile$1(e,t,n){copyFileSync(e,t,n)}async function access$1(e,t){accessSync(e,t)}async function appendFile$1(e,t,n){appendFileSync(e,t,n)}async function readlink$1(e,t){return readlinkSync(e,t)}async function truncate$1(e,t){truncateSync(e,t)}async function chmod$1(e,t){chmodSync(e,t)}async function chown$1(e,t,n){chownSync(e,t,n)}async function link$1(e,t){linkSync(e,t)}var Cu,wu,Tu=__esmMin(()=>{Pl(),Yl(),Fl(),Il(),zl(),Vl(),Lu(),uu(),Iu(),hu(),gu(),vu(),yu(),Su(),K(),$(),Bo(),Cu=__exportAll({access:()=>access$1,appendFile:()=>appendFile$1,chmod:()=>chmod$1,chown:()=>chown$1,copyFile:()=>copyFile$1,cp:()=>cpPromises,default:()=>wu,fchmod:()=>fchmodAsync,fchown:()=>fchownAsync,fdatasync:()=>fdatasyncAsync,fstat:()=>fstatAsync,fsync:()=>fsyncAsync,ftruncate:()=>ftruncateAsync,futimes:()=>futimesAsync,glob:()=>globAsync,lchmod:()=>lchmodAsync,lchown:()=>lchownAsync,link:()=>link$1,lstat:()=>lstat$1,lutimes:()=>lutimesAsync,mkdir:()=>mkdir$1,mkdtemp:()=>mkdtemp$1,open:()=>open$1,openAsBlob:()=>openAsBlob,opendir:()=>opendirAsync,readFile:()=>readFile$1,readdir:()=>readdir$1,readlink:()=>readlink$1,readv:()=>readvAsync,realpath:()=>realpath$1,rename:()=>rename$1,rm:()=>rm$1,rmdir:()=>rmdir$1,stat:()=>stat$1,statfs:()=>statfsAsync,symlink:()=>symlink$1,truncate:()=>truncate$1,unlink:()=>unlink$1,utimes:()=>utimesAsync,watch:()=>watchAsync,write:()=>write$1,writeFile:()=>writeFile$1,writev:()=>writevAsync}),__name(mkdir$1,`mkdir`),__name(readFile$1,`readFile`),__name(mkdtemp$1,`mkdtemp`),__name(writeFile$1,`writeFile`),__name(rmdir$1,`rmdir`),__name(unlink$1,`unlink`),__name(open$1,`open`),__name(write$1,`write`),__name(stat$1,`stat`),__name(lstat$1,`lstat`),__name(readdir$1,`readdir`),__name(realpath$1,`realpath`),__name(symlink$1,`symlink`),__name(rm$1,`rm`),__name(rename$1,`rename`),__name(copyFile$1,`copyFile`),__name(access$1,`access`),__name(appendFile$1,`appendFile`),__name(readlink$1,`readlink`),__name(truncate$1,`truncate`),__name(chmod$1,`chmod`),__name(chown$1,`chown`),__name(link$1,`link`),wu={readFile:readFile$1,mkdir:mkdir$1,mkdtemp:mkdtemp$1,realpath:realpath$1,readdir:readdir$1,writeFile:writeFile$1,rmdir:rmdir$1,unlink:unlink$1,open:open$1,write:write$1,rm:rm$1,lstat:lstat$1,symlink:symlink$1,stat:stat$1,rename:rename$1,copyFile:copyFile$1,access:access$1,appendFile:appendFile$1,readlink:readlink$1,truncate:truncate$1,chmod:chmod$1,chown:chown$1,link:link$1,cp:cpPromises,opendir:opendirAsync,glob:globAsync,watch:watchAsync,statfs:statfsAsync,utimes:utimesAsync,lutimes:lutimesAsync,lchown:lchownAsync,lchmod:lchmodAsync,fstat:fstatAsync,ftruncate:ftruncateAsync,fdatasync:fdatasyncAsync,fsync:fsyncAsync,fchmod:fchmodAsync,fchown:fchownAsync,futimes:futimesAsync,readv:readvAsync,writev:writevAsync,openAsBlob}});function withHandle(e,t,n){try{return Fu.getInstance(e,t)}catch(e){return Promise.resolve().then(()=>n(e)),null}}function parseOptsCb(e,t){return typeof e==`function`?{options:{},callback:e}:{options:e??{},callback:requireCallback(t)}}function statImpl(e,t,n,r,i){let o=normalizePath(e),s=Q.File.new_for_path(o);s.query_info_async(lu,t,G.PRIORITY_DEFAULT,null,(e,t)=>{try{i(null,statsFrom(s.query_info_finish(t),o,n,r?.bigint))}catch(e){i(createNodeError(e,n,o))}})}function stat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,Q.FileQueryInfoFlags.NONE,`stat`,r,i)}function lstat(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);statImpl(e,Q.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,`lstat`,r,i)}function readdir(e,t,n){let{options:r,callback:i}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{i(null,readdirSync(e,r))}catch(t){i(createNodeError(t,`readdir`,e))}})}function realpath(e,t,n){let{callback:r}=parseOptsCb(t,n);Promise.resolve().then(()=>{try{r(null,realpathSync(e))}catch(e){r(e)}})}function symlink(e,t,n,r){let i=typeof n==`function`?n:requireCallback(r);if(typeof i!=`function`)throw TypeError(`Callback must be a function. Received `+typeof i);let o=normalizePath(t),s=normalizePath(e),c=Q.File.new_for_path(o);c.make_symbolic_link_async(s,G.PRIORITY_DEFAULT,null,(e,t)=>{try{c.make_symbolic_link_finish(t),i(null)}catch(e){i(createNodeError(e,`symlink`,s,o))}})}function open(e,...t){let n,r,i;switch(t.length){case 1:i=t[0];break;case 2:n=t[0],i=t[1];break;case 3:n=t[0],r=t[1],i=t[2];break;default:break}let o=requireCallback(i);open$1(e,n,r).then(e=>{o(null,e.fd)}).catch(e=>{o(e,-1)})}function write(e,t,...n){requireCallback(n[n.length-1]);let r=withHandle(e,`write`,e=>{let r=n[n.length-1];typeof t==`string`?r(e,0,``):r(e,0,U.from([]))});if(!r)return;if(typeof t==`string`){let e=n.pop(),i=n[0],o=n[1];r.write(t,i,o).then(t=>{e(null,t.bytesWritten,t.buffer)}).catch(t=>{e(t,0,``)});return}let i=n[n.length-1],o=n[0],s=n[1],c=n[2];r.write(t,o,s,c).then(e=>{i(null,e.bytesWritten,e.buffer)}).catch(e=>{i(e,0,U.from([]))})}function read(e,...t){let n=requireCallback(t[t.length-1]),r=withHandle(e,`read`,e=>{typeof n==`function`&&n(e,0,U.from([]))});if(!r)return;let i,o,s,c;if(!(t.length<=1))if(typeof t[0]==`object`&&!ArrayBuffer.isView(t[0])){let e=t[0];i=e.buffer,o=e.offset,s=e.length,c=e.position}else i=t[0],o=t[1],s=t[2],c=t[3];r.read(i,o,s,c).then(e=>{n(null,e.bytesRead,e.buffer)}).catch(e=>{n(e,0,U.from([]))})}function close(e,t){let done=e=>{typeof t==`function`&&t(e)},n=withHandle(e,`close`,done);n&&n.close().then(()=>done(null)).catch(e=>done(e))}function rm(e,...t){let n={},r=t[t.length-1];t.length>=2&&(n=t[0]),rm$1(e,n).then(()=>{r(null)}).catch(e=>{r(e)})}function rename(e,t,n){requireCallback(n),Promise.resolve().then(()=>{try{renameSync(e,t),n(null)}catch(e){n(e)}})}function copyFile(e,t,n,r){let i=typeof n==`function`?0:n,o=typeof n==`function`?n:requireCallback(r);Promise.resolve().then(()=>{try{copyFileSync(e,t,i),o(null)}catch(e){o(e)}})}function access(e,t,n){let r=typeof t==`function`?void 0:t,i=typeof t==`function`?t:requireCallback(n);Promise.resolve().then(()=>{try{accessSync(e,r),i(null)}catch(e){i(e)}})}function appendFile(e,t,n,r){let i=typeof n==`function`?n:requireCallback(r),o=typeof n==`function`?void 0:n;Promise.resolve().then(()=>{try{appendFileSync(e,t,o),i(null)}catch(e){i(e)}})}function readlink(e,t,n){let r=typeof t==`function`?t:requireCallback(n),i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{r(null,readlinkSync(e,i))}catch(e){r(e,``)}})}function truncate(e,t,n){let r=typeof t==`function`?0:t,i=typeof t==`function`?t:requireCallback(n);Promise.resolve().then(()=>{try{truncateSync(e,r),i(null)}catch(e){i(e)}})}function chmod(e,t,n){requireCallback(n),Promise.resolve().then(()=>{try{chmodSync(e,t),n(null)}catch(e){n(e)}})}function chown(e,t,n,r){requireCallback(r),Promise.resolve().then(()=>{try{chownSync(e,t,n),r(null)}catch(e){r(e)}})}function mkdir(e,t,n){let r=typeof t==`function`?t:requireCallback(n),i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{mkdirSync(e,i),r(null)}catch(e){r(e)}})}function mkdtemp(e,t,n){let r=typeof t==`function`?t:requireCallback(n),i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{let t;try{t=mkdtempSync(e,i)}catch(e){r(e,void 0);return}r(null,t)})}function rmdir(e,t,n){let r=typeof t==`function`?t:requireCallback(n),i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{rmdirSync(e,i),r(null)}catch(e){r(e)}})}function readFile(e,t,n){let r=typeof t==`function`?t:requireCallback(n),i=typeof t==`function`?void 0:t;Promise.resolve().then(()=>{try{let t=typeof i==`string`?{encoding:i,flag:`r`}:{encoding:i?.encoding??null,flag:i?.flag??`r`};r(null,readFileSync(e,t))}catch(e){r(e,null)}})}function writeFile(e,t,n,r){let i=typeof n==`function`?n:requireCallback(r),o=typeof n==`function`?void 0:n;Promise.resolve().then(()=>{try{writeFileSync(e,t,o),i(null)}catch(e){i(e)}})}function link(e,t,n){requireCallback(n),Promise.resolve().then(()=>{try{linkSync(e,t),n(null)}catch(e){n(e)}})}function unlink(e,t){requireCallback(t);let n=normalizePath(e);Promise.resolve().then(()=>{G.unlink(n),t(null)})}var Eu=__esmMin(()=>{Fl(),Il(),uu(),Iu(),hu(),Tu(),K(),$(),W()});function toPathIfFileURL(e){return normalizePath(e)}function createWriteStream(e,t){return new WriteStream(e,t)}var Du,Ou,WriteStream,ku=__esmMin(()=>{Fl(),eu(),Eu(),gi(),Du=Symbol(`kIsPerformingIO`),Ou=Symbol(`kIoDone`),WriteStream=class extends di{close(e,t=null){let done=t=>{typeof e==`function`&&e(t)};if(this.fd===null||!this._autoClose)this.fd=null,done(t);else{let e=this._fdFromHandle;close(this.fd,n=>{let r=e&&n?.code===`EBADF`?null:n;done(r||t)}),this.fd=null}}bytesWritten=0;path;pending;fd=null;flags=`w`;mode=438;pos=void 0;_autoClose=!0;_fdFromHandle=!1;[Du]=!1;constructor(e,t={}){super(t),this.path=toPathIfFileURL(e),t.flags!==void 0&&(this.flags=t.flags),t.mode!==void 0&&(this.mode=normalizeMode(t.mode,438)),t.start!==void 0&&(this.pos=t.start),t.encoding&&this.setDefaultEncoding(t.encoding),typeof t.fd==`number`?(this.fd=t.fd,this._autoClose=t.autoClose??!0,this._fdFromHandle=t.fdFromHandle===!0):t.autoClose!==void 0&&(this._autoClose=t.autoClose),this.pending=this.fd===null}_construct(e){if(this.fd!==null){e(),this.emit(`open`,this.fd),this.emit(`ready`);return}open(this.path.toString(),this.flags,this.mode,(t,n)=>{if(t){e(t);return}this.fd=n,this.pending=!1,e(),this.emit(`open`,this.fd),this.emit(`ready`)})}_write(e,t,n){this[Du]=!0,write(this.fd,e,0,e.length,this.pos??null,(e,t)=>{if(this[Du]=!1,this.destroyed)return n(e),this.emit(Ou,e);if(e)return n(e);this.bytesWritten+=t,n()}),this.pos!==void 0&&(this.pos+=e.length)}_destroy(e,t){this[Du]?this.once(Ou,n=>this.close(t,e||n)):this.close(t,e)}}});function createInterface(e,t,n,r){return typeof e==`object`&&e&&!(`read`in e&&typeof e.read==`function`)?new Interface(e):new Interface({input:e,output:t,completer:n,terminal:r})}function*emitKeys(e){for(;;){let t=yield,n=t,r=!1,i={sequence:``,name:void 0,ctrl:!1,meta:!1,shift:!1};if(t===`\x1B`&&(r=!0,n+=t=yield,t===`\x1B`&&(n+=t=yield)),r&&(t===`O`||t===`[`)){let e=t,r=0;if(t===`O`)n+=t=yield,t>=`0`&&t<=`9`&&(r=t.charCodeAt(0)-1,n+=t=yield),e+=t;else if(t===`[`){n+=t=yield,t===`[`&&(e+=t,n+=t=yield);let i=n.length-1;t>=`0`&&t<=`9`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=t=yield))),t===`;`&&(n+=t=yield,t>=`0`&&t<=`9`&&(n+=yield));let o=n.slice(i),s;(s=/^(?:(\d\d?)(?:;(\d))?([~^$])|(\d{3}~))$/.exec(o))?s[4]?e+=s[4]:(e+=s[1]+s[3],r=(parseInt(s[2]??`1`,10)||1)-1):(s=/^((\d;)?(\d))?([A-Za-z])$/.exec(o))?(e+=s[4],r=(parseInt(s[3]??`1`,10)||1)-1):e+=o}switch(i.ctrl=!!(r&4),i.meta=!!(r&10),i.shift=!!(r&1),i.code=e,e){case`[P`:case`OP`:case`[11~`:case`[[A`:i.name=`f1`;break;case`[Q`:case`OQ`:case`[12~`:case`[[B`:i.name=`f2`;break;case`[R`:case`OR`:case`[13~`:case`[[C`:i.name=`f3`;break;case`[S`:case`OS`:case`[14~`:case`[[D`:i.name=`f4`;break;case`[15~`:case`[[E`:i.name=`f5`;break;case`[17~`:i.name=`f6`;break;case`[18~`:i.name=`f7`;break;case`[19~`:i.name=`f8`;break;case`[20~`:i.name=`f9`;break;case`[21~`:i.name=`f10`;break;case`[23~`:i.name=`f11`;break;case`[24~`:i.name=`f12`;break;case`[200~`:i.name=`paste-start`;break;case`[201~`:i.name=`paste-end`;break;case`[A`:case`OA`:i.name=`up`;break;case`[B`:case`OB`:i.name=`down`;break;case`[C`:case`OC`:i.name=`right`;break;case`[D`:case`OD`:i.name=`left`;break;case`[E`:case`OE`:i.name=`clear`;break;case`[F`:case`OF`:i.name=`end`;break;case`[H`:case`OH`:i.name=`home`;break;case`[1~`:i.name=`home`;break;case`[2~`:i.name=`insert`;break;case`[3~`:i.name=`delete`;break;case`[4~`:i.name=`end`;break;case`[5~`:case`[[5~`:i.name=`pageup`;break;case`[6~`:case`[[6~`:i.name=`pagedown`;break;case`[7~`:i.name=`home`;break;case`[8~`:i.name=`end`;break;case`[a`:i.name=`up`,i.shift=!0;break;case`[b`:i.name=`down`,i.shift=!0;break;case`[c`:i.name=`right`,i.shift=!0;break;case`[d`:i.name=`left`,i.shift=!0;break;case`[2$`:i.name=`insert`,i.shift=!0;break;case`[3$`:i.name=`delete`,i.shift=!0;break;case`[5$`:i.name=`pageup`,i.shift=!0;break;case`[6$`:i.name=`pagedown`,i.shift=!0;break;case`[7$`:i.name=`home`,i.shift=!0;break;case`[8$`:i.name=`end`,i.shift=!0;break;case`Oa`:i.name=`up`,i.ctrl=!0;break;case`Ob`:i.name=`down`,i.ctrl=!0;break;case`Oc`:i.name=`right`,i.ctrl=!0;break;case`Od`:i.name=`left`,i.ctrl=!0;break;case`[2^`:i.name=`insert`,i.ctrl=!0;break;case`[3^`:i.name=`delete`,i.ctrl=!0;break;case`[5^`:i.name=`pageup`,i.ctrl=!0;break;case`[6^`:i.name=`pagedown`,i.ctrl=!0;break;case`[7^`:i.name=`home`,i.ctrl=!0;break;case`[8^`:i.name=`end`,i.ctrl=!0;break;case`[Z`:i.name=`tab`,i.shift=!0;break;default:i.name=`undefined`;break}}else t===`\r`?(i.name=`return`,i.meta=r):t===`
197
- `?(i.name=`enter`,i.meta=r):t===` `?(i.name=`tab`,i.meta=r):t===`\b`||t===``?(i.name=`backspace`,i.meta=r):t===`\x1B`?(i.name=`escape`,i.meta=r):t===` `?(i.name=`space`,i.meta=r):!r&&t<=``?(i.name=String.fromCharCode(t.charCodeAt(0)+97-1),i.ctrl=!0):/^[0-9A-Za-z]$/.test(t)?(i.name=t.toLowerCase(),i.shift=/^[A-Z]$/.test(t),i.meta=r):r&&(i.name=t.length?void 0:`escape`,i.meta=!0);i.sequence=n,n.length!==0&&(i.name!==void 0||r)?e.emit(`keypress`,r?void 0:n,i):n.length===1&&e.emit(`keypress`,n,i)}}function emitKeypressEvents(e,t={}){let n=e;if(n[Mu])return;n[Mu]=new Nn(`utf8`),n[Nu]=emitKeys(e),n[Nu].next();let r=t.escapeCodeTimeout??500,i,triggerEscape=()=>n[Nu].next(``);function onData(t){if(e.listenerCount(`keypress`)>0){let o=n[Mu].write(typeof t==`string`?Buffer.from(t):t);if(o){clearTimeout(i);for(let t of o)try{n[Nu].next(t),t===`\x1B`&&(i=setTimeout(triggerEscape,r))}catch{n[Nu]=emitKeys(e),n[Nu].next()}}}else e.removeListener(`data`,onData),delete n[Mu],delete n[Nu]}e.on(`data`,onData)}var Au,Interface,ju,Mu,Nu,Pu=__esmMin(()=>{jn(),Fn(),Au=/\r\n|\r|\n/,Interface=class extends q{terminal;line=``;cursor=0;escapeCodeTimeout;_input;_output;get input(){return this._input}get output(){return this._output}_prompt;_closed=!1;_paused=!1;history;_historySize;_crlfDelay;_lineBuffer=``;_questionCallback=null;_boundOnData=null;_boundOnEnd=null;_boundOnError=null;_boundOnKeypress=null;constructor(e,t){super();let n;if(n=e&&typeof e==`object`&&!(`read`in e&&typeof e.read==`function`)?e:{input:e,output:t},this._input=n.input||null,this._output=n.output||null,this._prompt=n.prompt||`> `,this.terminal=n.terminal??this._output!==null,this._historySize=n.historySize??30,this.history=[],this._crlfDelay=n.crlfDelay??100,this.escapeCodeTimeout=n.escapeCodeTimeout,this._input&&(this._boundOnData=e=>this._onData(e),this._boundOnEnd=()=>this._onEnd(),this._boundOnError=e=>this.emit(`error`,e),this._input.on(`data`,this._boundOnData),this._input.on(`end`,this._boundOnEnd),this._input.on(`error`,this._boundOnError),`setEncoding`in this._input&&typeof this._input.setEncoding==`function`&&this._input.setEncoding(`utf8`),this.terminal)){emitKeypressEvents(this._input,this);let e=this._input;typeof e.setRawMode==`function`&&(e.isRaw||e.setRawMode(!0)),typeof this._input.resume==`function`&&this._input.resume(),this._boundOnKeypress=(e,t)=>{t&&(t.name===`backspace`||t.name===`delete`?this.cursor>0&&(this.line=this.line.slice(0,this.cursor-1)+this.line.slice(this.cursor),this.cursor--):e&&e.length===1&&!t.ctrl&&!t.meta&&t.name!==`return`&&t.name!==`enter`&&t.name!==`escape`&&(this.line=this.line.slice(0,this.cursor)+e+this.line.slice(this.cursor),this.cursor++))},this._input.on(`keypress`,this._boundOnKeypress)}}_onData(e){if(this._closed||this._paused)return;let t=typeof e==`string`?e:e.toString(`utf8`);this._lineBuffer+=t;let n;for(;(n=Au.exec(this._lineBuffer))!==null;){let e=this._lineBuffer.substring(0,n.index);this._lineBuffer=this._lineBuffer.substring(n.index+n[0].length),this._onLine(e)}}_onLine(e){if(e.length>0&&this._historySize>0&&(this.history.length===0||this.history[0]!==e)&&(this.history.unshift(e),this.history.length>this._historySize&&this.history.pop()),this._questionCallback){let t=this._questionCallback;this._questionCallback=null,t(e)}this.emit(`line`,e)}_onEnd(){this._lineBuffer.length>0&&(this._onLine(this._lineBuffer),this._lineBuffer=``),this.close()}setPrompt(e){this._prompt=e}getPrompt(){return this._prompt}prompt(e){if(this._closed)throw Error(`readline was closed`);this._output?.write(this._prompt)}question(e,t,n){if(this._closed)throw Error(`readline was closed`);let r=typeof t==`function`?t:n;this._questionCallback=r,this._output?.write(e)}clearLine(e,t){return this.line=``,this.cursor=0,t&&t(),!0}write(e,t){if(!this._closed){if(t){this._input&&this._input.emit(`keypress`,e??``,t);return}if(e!=null){let t=typeof e==`string`?e:e.toString(`utf8`);t&&(this.line=this.line.slice(0,this.cursor)+t+this.line.slice(this.cursor),this.cursor+=t.length),this._output?.write(e)}}}close(){if(!this._closed){if(this._closed=!0,this._input){this._boundOnData&&this._input.removeListener(`data`,this._boundOnData),this._boundOnEnd&&this._input.removeListener(`end`,this._boundOnEnd),this._boundOnError&&this._input.removeListener(`error`,this._boundOnError),this._boundOnKeypress&&this._input.removeListener(`keypress`,this._boundOnKeypress),this._boundOnData=null,this._boundOnEnd=null,this._boundOnError=null,this._boundOnKeypress=null;let e=this._input;this.terminal&&e.isRaw&&typeof e.setRawMode==`function`&&e.setRawMode(!1),typeof this._input.pause==`function`&&this._input.pause()}this.emit(`close`)}}pause(){return this._closed?this:(this._paused=!0,this._input&&`pause`in this._input&&typeof this._input.pause==`function`&&this._input.pause(),this.emit(`pause`),this)}resume(){return this._closed?this:(this._paused=!1,this._input&&`resume`in this._input&&typeof this._input.resume==`function`&&this._input.resume(),this.emit(`resume`),this)}getCursorPos(){let e=this._output?.columns??80,t=this._prompt.length+this.cursor;return{rows:Math.floor(t/e),cols:t%e}}[Symbol.asyncIterator](){let e=[],t=null,n=!1,onLine=n=>{if(t){let e=t;t=null,e({value:n,done:!1})}else e.push(n)},onClose=()=>{if(n=!0,t){let e=t;t=null,e({value:void 0,done:!0})}};return this.on(`line`,onLine),this.on(`close`,onClose),{next:()=>e.length>0?Promise.resolve({value:e.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise(e=>{t=e}),return:()=>(n=!0,this.removeListener(`line`,onLine),this.removeListener(`close`,onClose),Promise.resolve({value:void 0,done:!0})),[Symbol.asyncIterator](){return this}}}},ju=Symbol.dispose??Symbol.for(`Symbol.dispose`),Interface.prototype[ju]=function(){this.close()},Mu=Symbol(`keypress-decoder`),Nu=Symbol(`escape-decoder`)}),Fu,Iu=__esmMin(()=>{Yl(),Fl(),Il(),Xl(),eu(),ku(),cu(),uu(),hu(),K(),$(),W(),Pu(),Fu=class FileHandle{options;_gFile;_pathStr;_spec;_pos=0;_closed=!1;_webStreamLocked=!1;static instances={};constructor(e){this.options=e,this.options.flags??=`r`;let t=normalizePath(e.path);this._spec=parseOpenFlags(this.options.flags),this.options.mode??=438;let n=normalizeMode(this.options.mode,438);return this.fd=openFd(t,this._spec,n),this._pathStr=t,this._gFile=Q.File.new_for_path(t),FileHandle.instances[this.fd]=this,FileHandle.getInstance(this.fd)}_readCore(e,t,n,r){if(this._assertOpen(`read`),!this._spec.readable)throw fsError(`EBADF`,`read`,this._pathStr);if(n>e.byteLength-t){let r=RangeError(`The value of "length" is out of range. It must be <= ${e.byteLength-t}. Received ${n}`);throw r.code=`ERR_OUT_OF_RANGE`,r}let i=r!=null&&r>=0,o=isSeekableFd(this.fd,this._pathStr);if(i&&!o)throw fsError(`ESPIPE`,`read`,this._pathStr);let s=i?r:this._pos;o&&seekFd(this.fd,s);let c=readFd(this.fd,n);return c.length>0&&new Uint8Array(e.buffer,e.byteOffset+t,c.length).set(c),!i&&o&&(this._pos=s+c.length),c.length}_writeCore(e,t){if(this._assertOpen(`write`),!this._spec.writable)throw fsError(`EBADF`,`write`,this._pathStr);if(this._spec.append){let t=writeFd(this.fd,e);return this._pos=tellFd(this.fd)??sizeOfFd(this.fd,this._pathStr),t}let n=t!=null&&t>=0,r=isSeekableFd(this.fd,this._pathStr);if(n&&!r)throw fsError(`ESPIPE`,`write`,this._pathStr);let i=n?t:this._pos;r&&seekFd(this.fd,i);let o=writeFd(this.fd,e);return!n&&r&&(this._pos=i+o),o}_assertOpen(e){if(this._closed)throw fsError(`EBADF`,e,this._pathStr)}_truncateCore(e){if(this._assertOpen(`ftruncate`),!this._spec.writable)throw fsError(`EINVAL`,`ftruncate`,this._pathStr);truncateFd(this.fd,Math.max(0,e),this._pathStr)}_readToEnd(){let e=[],t=0;for(;;){let n=new Uint8Array(64*1024),r=this._readCore(n,0,n.length,null);if(r===0)break;e.push(n.subarray(0,r)),t+=r}let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}_fdTarget(){return fdPath(this.fd)??this._pathStr}fd;static getInstance(e,t=`read`){let n=e instanceof FileHandle?e.fd:e,r=FileHandle.instances[n];if(!r)throw fsError(`EBADF`,t);return r}async appendFile(e,t){await this.writeFile(e,t)}async chown(e,t){this._assertOpen(`fchown`),chownSync(normalizePath(this.options.path),e,t)}async chmod(e){this._assertOpen(`fchmod`),chmodSync(this._fdTarget(),e)}createReadStream(e){return new ReadStream(this.options.path,{...e,fd:this.fd})}createWriteStream(e){return new WriteStream(this.options.path,{...e,fd:this.fd,fdFromHandle:!0})}async datasync(){this._assertOpen(`fdatasync`),fsyncFd(this.fd)}async sync(){this._assertOpen(`fsync`),fsyncFd(this.fd)}async read(...e){let t,n,r,i;if(typeof e[0]==`object`&&!(e[0]instanceof Uint8Array)&&!(e[0]instanceof U)){let o=e[0];t=o.buffer,n=o.offset,r=o.length,i=o.position}else t=e[0],n=e[1],r=e[2],i=e[3];let o=t,s=n??0,c=r??(o?o.byteLength-s:65536);return{bytesRead:this._readCore(t,s,c,i??null),buffer:t}}readableWebStream(){if(this._closed)throw invalidState(`The FileHandle is closed`);if(this._webStreamLocked)throw invalidState(`The FileHandle is locked`);let e=globalThis.ReadableStream;if(typeof e!=`function`)throw Error(`readableWebStream() requires a global ReadableStream. Import "node:stream/web" or "@gjsify/web-streams/register" before calling this method.`);return this._webStreamLocked=!0,new e({type:`bytes`,pull:e=>{if(this._closed){e.close(),e.byobRequest?.respond(0);return}let t=e.byobRequest?.view,n=t?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(64*1024),r;try{r=this._readCore(n,0,n.length,null)}catch(t){e.error(t);return}if(r===0){e.close(),e.byobRequest?.respond(0);return}if(e.byobRequest){e.byobRequest.respond(r);return}e.enqueue(n.subarray(0,r))}})}async readFile(e){return encodeUint8Array(getEncodingFromOptions(e,`buffer`),this._readToEnd())}readLines(e){return createInterface({input:this.createReadStream(e),crlfDelay:1/0})}async stat(e){this._assertOpen(`fstat`);let t=Q.File.new_for_path(this._fdTarget());return statsFrom(await new Promise((e,n)=>{t.query_info_async(lu,Q.FileQueryInfoFlags.NONE,G.PRIORITY_DEFAULT,null,(r,i)=>{try{e(t.query_info_finish(i))}catch(e){n(e)}})}),this._pathStr,`fstat`,e?.bigint)}async truncate(e=0){this._truncateCore(e)}async utimes(e,t){this._assertOpen(`futimes`);let{utimesSync:n}=await Promise.resolve().then(()=>(Vl(),Bl));n(normalizePath(this.options.path),e,t)}async writeFile(e,t){let n=getEncodingFromOptions(t),r;r=typeof e==`string`?U.from(e,n||`utf8`):e,this._writeCore(r,null)}async write(e,...t){let n=null,r=null,i=null,o=null;typeof e==`string`?(n=t[0],r=t[1]):(i=t[0],o=t[1],n=t[2]),r=getEncodingFromOptions(r,typeof e==`string`?`utf8`:null);let s;s=typeof e==`string`?new TextEncoder().encode(e):e;let c=i??0,l=o??s.byteLength-c,u=s.subarray(c,c+l);return{bytesWritten:this._writeCore(u,n??null),buffer:e}}async writev(e,t){let n=0;for(let r of e){let e=U.from(r.buffer,r.byteOffset,r.byteLength),i=await this.write(e,0,e.byteLength,t==null?null:t+n);n+=i.bytesWritten}return{bytesWritten:n,buffers:e}}async readv(e,t){let n=0;for(let r of e){let e=await this.read({buffer:U.from(r.buffer,r.byteOffset,r.byteLength),position:t==null?null:t+n});if(n+=e.bytesRead,e.bytesRead<r.byteLength)break}return{bytesRead:n,buffers:e}}_flushSync(){fsyncFd(this.fd)}_closeSync(){this._teardown()}_readSync(e,t,n,r){return this._readCore(e,t,n,r)}_writeSync(e,t){return this._writeCore(e,t)}_readToEndSync(){return this._readToEnd()}_truncateSync(e){this._truncateCore(e)}_fdStatTarget(){return this._fdTarget()}_teardown(){if(this._closed)return;this._closed=!0,releaseFd(this.fd),closeFd(this.fd);let e=FileHandle;delete e.instances[this.fd]}async close(){this._teardown()}async[Symbol.asyncDispose](){await this.close()}pull(...e){throw Error('FileHandle.pull() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}writer(e){throw Error('FileHandle.writer() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}}});function getFH(e,t){return Fu.getInstance(e,t)}function fstatSync(e,t){return statSync(getFH(e,`fstat`)._fdStatTarget(),t)}function fstat(e,t,n){let r=typeof t==`function`?t:requireCallback(n);fstatAsync(e,typeof t==`function`?{}:t).then(e=>r(null,e),e=>r(e,void 0))}async function fstatAsync(e,t){return t?.bigint,fstatSync(e,t)}function ftruncateSync(e,t=0){getFH(e,`ftruncate`)._truncateSync(t)}function ftruncate(e,t,n){let r=typeof t==`function`?t:requireCallback(n);ftruncateAsync(e,typeof t==`function`?0:t).then(()=>r(null),r)}async function ftruncateAsync(e,t=0){ftruncateSync(e,t)}function fdatasyncSync(e){getFH(e,`fdatasync`)._flushSync()}function fdatasync(e,t){requireCallback(t),Promise.resolve().then(()=>fdatasyncSync(e)).then(()=>t(null),t)}async function fdatasyncAsync(e){fdatasyncSync(e)}function fsyncSync(e){getFH(e,`fsync`)._flushSync()}function fsync(e,t){requireCallback(t),Promise.resolve().then(()=>fsyncSync(e)).then(()=>t(null),t)}async function fsyncAsync(e){fsyncSync(e)}function fchmodSync(e,t){chmodSync(getFH(e,`fchmod`)._fdStatTarget(),t)}function fchmod(e,t,n){requireCallback(n),Promise.resolve().then(()=>fchmodSync(e,t)).then(()=>n(null),n)}async function fchmodAsync(e,t){fchmodSync(e,t)}function fchownSync(e,t,n){chownSync(normalizePath(getFH(e,`fchown`).options.path),t,n)}function fchown(e,t,n,r){requireCallback(r),Promise.resolve().then(()=>fchownSync(e,t,n)).then(()=>r(null),r)}async function fchownAsync(e,t,n){fchownSync(e,t,n)}function futimesSync(e,t,n){utimesSync(normalizePath(getFH(e,`futimes`).options.path),t,n)}function futimes(e,t,n,r){requireCallback(r),Promise.resolve().then(()=>futimesSync(e,t,n)).then(()=>r(null),r)}async function futimesAsync(e,t,n){futimesSync(e,t,n)}function closeSync(e){isStdFd(e)||getFH(e,`close`)._closeSync()}function readSync(e,t,n,r,i){let o=0;return typeof n==`object`&&n?(o=n.offset??0,r=n.length??t.byteLength-o,i=n.position??null):(o=n??0,r??=t.byteLength-o),isStdFd(e)?readStdFdSync(e,t,o,r):getFH(e,`read`)._readSync(t,o,r,i??null)}function writeSync(e,t,n,r,i){let o;if(typeof t==`string`)o=new TextEncoder().encode(t),typeof n==`number`&&(i=n);else{let e=typeof n==`number`?n:0,i=typeof r==`number`?r:t.byteLength-e;o=new Uint8Array(t.buffer,t.byteOffset+e,i)}return isStdFd(e)?writeStdFdSync(e,o):getFH(e,`write`)._writeSync(o,i??null)}function readvSync(e,t,n){let r=0;for(let i of t){let t=readSync(e,i,0,i.byteLength,n==null?null:n+r);if(r+=t,t<i.byteLength)break}return r}function readv(e,t,n,r){let i=typeof n==`function`?n:requireCallback(r);readvAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesRead,e.buffers),e=>i(e,0,t))}async function readvAsync(e,t,n){return{bytesRead:readvSync(e,t,n),buffers:t}}function writevSync(e,t,n){let r=0;for(let i of t){let t=writeSync(e,i,0,i.byteLength,n==null?null:n+r);r+=t}return r}function writev(e,t,n,r){let i=typeof n==`function`?n:requireCallback(r);writevAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesWritten,e.buffers),e=>i(e,0,t))}async function writevAsync(e,t,n){return{bytesWritten:writevSync(e,t,n),buffers:t}}function exists(e,t){requireCallback(t);try{statSync(normalizePath(e)),t(!0)}catch{t(!1)}}async function openAsBlob(e,t){let n=readFileSync(normalizePath(e));return new Blob([n],{type:t?.type??``})}var Lu=__esmMin(()=>{Fl(),Il(),Vl(),Jl(),Iu(),hu()});function zeroedStat(){return{dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0),isFile:()=>!1,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1}}function watchFile(e,t,n){typeof t==`function`&&(n=t,t={}),requireCallback(n,`listener`);let r=t.interval??5007,i=e.toString(),o=Ru.get(i);return o||(o=new StatWatcher(i,r),o.start(),Ru.set(i,o)),n&&o.addChangeListener(n),o}function unwatchFile(e,t){let n=e.toString(),r=Ru.get(n);r&&(t?r.removeChangeListener(t):r.removeAllChangeListeners(),r.changeListenerCount===0&&(r.stop(),Ru.delete(n)))}var StatWatcher,Ru,zu=__esmMin(()=>{Il(),hu(),jn(),StatWatcher=class extends q{_path;_interval;_timerId=null;_prev;_changeCount=0;constructor(e,t){super(),this._path=e,this._interval=t,this._prev=zeroedStat()}start(){try{this._prev=statSync(this._path)}catch{}this._timerId=setInterval(()=>{let e;try{e=statSync(this._path)}catch{e=zeroedStat()}let t=this._prev;(e.mtimeMs!==t.mtimeMs||e.size!==t.size||e.ino!==t.ino)&&(this._prev=e,this.emit(`change`,e,t))},this._interval)}stop(){this._timerId!==null&&(clearInterval(this._timerId),this._timerId=null),this.emit(`stop`)}addChangeListener(e){this._changeCount++,this.on(`change`,e)}removeChangeListener(e){this._changeCount--,this.removeListener(`change`,e)}removeAllChangeListeners(){this._changeCount=0,this.removeAllListeners(`change`)}get changeListenerCount(){return this._changeCount}},Ru=new Map}),Bu=__exportAll$4({BigIntStats:()=>BigIntStats,Dir:()=>Dir,Dirent:()=>Dirent,FSWatcher:()=>FSWatcher,ReadStream:()=>ReadStream,StatWatcher:()=>StatWatcher,Stats:()=>Stats,WriteStream:()=>WriteStream,access:()=>access,accessSync:()=>accessSync,appendFile:()=>appendFile,appendFileSync:()=>appendFileSync,chmod:()=>chmod,chmodSync:()=>chmodSync,chown:()=>chown,chownSync:()=>chownSync,close:()=>close,closeSync:()=>closeSync,constants:()=>Vu,copyFile:()=>copyFile,copyFileSync:()=>copyFileSync,cp:()=>cp,cpSync:()=>cpSync,createReadStream:()=>createReadStream,createWriteStream:()=>createWriteStream,default:()=>Hu,exists:()=>exists,existsSync:()=>existsSync,fchmod:()=>fchmod,fchmodSync:()=>fchmodSync,fchown:()=>fchown,fchownSync:()=>fchownSync,fdatasync:()=>fdatasync,fdatasyncSync:()=>fdatasyncSync,fstat:()=>fstat,fstatSync:()=>fstatSync,fsync:()=>fsync,fsyncSync:()=>fsyncSync,ftruncate:()=>ftruncate,ftruncateSync:()=>ftruncateSync,futimes:()=>futimes,futimesSync:()=>futimesSync,glob:()=>glob,globSync:()=>globSync,lchmod:()=>void 0,lchmodSync:()=>void 0,lchown:()=>lchown,lchownSync:()=>lchownSync,link:()=>link,linkSync:()=>linkSync,lstat:()=>lstat,lstatSync:()=>lstatSync,lutimes:()=>lutimes,lutimesSync:()=>lutimesSync,mkdir:()=>mkdir,mkdirSync:()=>mkdirSync,mkdtemp:()=>mkdtemp,mkdtempSync:()=>mkdtempSync,open:()=>open,openAsBlob:()=>openAsBlob,openSync:()=>openSync,opendir:()=>opendir,opendirSync:()=>opendirSync,promises:()=>Cu,read:()=>read,readFile:()=>readFile,readFileSync:()=>readFileSync,readSync:()=>readSync,readdir:()=>readdir,readdirSync:()=>readdirSync,readlink:()=>readlink,readlinkSync:()=>readlinkSync,readv:()=>readv,readvSync:()=>readvSync,realpath:()=>realpath,realpathSync:()=>realpathSync,rename:()=>rename,renameSync:()=>renameSync,rm:()=>rm,rmSync:()=>rmSync,rmdir:()=>rmdir,rmdirSync:()=>rmdirSync,stat:()=>stat,statSync:()=>statSync,statfs:()=>statfs,statfsSync:()=>statfsSync,symlink:()=>symlink,symlinkSync:()=>symlinkSync,truncate:()=>truncate,truncateSync:()=>truncateSync,unlink:()=>unlink,unlinkSync:()=>unlinkSync,unwatchFile:()=>unwatchFile,utimes:()=>utimes,utimesSync:()=>utimesSync,watch:()=>watch,watchFile:()=>watchFile,write:()=>write,writeFile:()=>writeFile,writeFileSync:()=>writeFileSync,writeSync:()=>writeSync,writev:()=>writev,writevSync:()=>writevSync});function openFlagDescriptors(){let e={};for(let t of Object.keys(openFlagValues()))e[t]={enumerable:!0,configurable:!0,get:()=>openFlagValues()[t]};return e}var Vu,Hu,Uu=__esmMin(()=>{zl(),Vl(),Lu(),Xl(),eu(),ku(),tu(),uu(),hu(),gu(),vu(),yu(),Su(),Tu(),Eu(),zu(),Vu=Object.defineProperties({F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1},openFlagDescriptors()),Hu={FSWatcher,StatWatcher,Stats,BigIntStats,Dirent,Dir,constants:Vu,existsSync,readdirSync,readFileSync,writeFileSync,mkdirSync,rmdirSync,unlinkSync,mkdtemp,mkdtempSync,rmSync,statSync,openSync,realpathSync,symlinkSync,lstatSync,renameSync,copyFileSync,accessSync,appendFileSync,readlinkSync,linkSync,truncateSync,chmodSync,chownSync,cpSync,opendirSync,globSync,glob,watch,watchFile,unwatchFile,statfsSync,statfs,utimesSync,utimes,lutimesSync,lutimes,lchownSync,lchown,lchmodSync:void 0,lchmod:void 0,fstatSync,fstat,ftruncateSync,ftruncate,fdatasyncSync,fdatasync,fsyncSync,fsync,fchmodSync,fchmod,fchownSync,fchown,futimesSync,futimes,closeSync,readSync,writeSync,readvSync,readv,writevSync,writev,exists,openAsBlob,createReadStream,ReadStream,createWriteStream,WriteStream,promises:Cu,open,close,read,write,rm,realpath,readdir,symlink,lstat,stat,rename,copyFile,cp,access,appendFile,readlink,truncate,chmod,chown,mkdir,rmdir,readFile,writeFile,unlink,link,opendir}}),Wu=__commonJSMin(((e,t)=>{
197
+ `?(i.name=`enter`,i.meta=r):t===` `?(i.name=`tab`,i.meta=r):t===`\b`||t===``?(i.name=`backspace`,i.meta=r):t===`\x1B`?(i.name=`escape`,i.meta=r):t===` `?(i.name=`space`,i.meta=r):!r&&t<=``?(i.name=String.fromCharCode(t.charCodeAt(0)+97-1),i.ctrl=!0):/^[0-9A-Za-z]$/.test(t)?(i.name=t.toLowerCase(),i.shift=/^[A-Z]$/.test(t),i.meta=r):r&&(i.name=t.length?void 0:`escape`,i.meta=!0);i.sequence=n,n.length!==0&&(i.name!==void 0||r)?e.emit(`keypress`,r?void 0:n,i):n.length===1&&e.emit(`keypress`,n,i)}}function emitKeypressEvents(e,t={}){let n=e;if(n[Mu])return;n[Mu]=new Nn(`utf8`),n[Nu]=emitKeys(e),n[Nu].next();let r=t.escapeCodeTimeout??500,i,triggerEscape=()=>n[Nu].next(``);function onData(t){if(e.listenerCount(`keypress`)>0){let o=n[Mu].write(typeof t==`string`?Buffer.from(t):t);if(o){clearTimeout(i);for(let t of o)try{n[Nu].next(t),t===`\x1B`&&(i=setTimeout(triggerEscape,r))}catch{n[Nu]=emitKeys(e),n[Nu].next()}}}else e.removeListener(`data`,onData),delete n[Mu],delete n[Nu]}e.on(`data`,onData)}var Au,Interface,ju,Mu,Nu,Pu=__esmMin(()=>{jn(),Fn(),Au=/\r\n|\r|\n/,Interface=class extends q{terminal;line=``;cursor=0;escapeCodeTimeout;_input;_output;get input(){return this._input}get output(){return this._output}_prompt;_closed=!1;_paused=!1;history;_historySize;_crlfDelay;_lineBuffer=``;_questionCallback=null;_boundOnData=null;_boundOnEnd=null;_boundOnError=null;_boundOnKeypress=null;constructor(e,t){super();let n;if(n=e&&typeof e==`object`&&!(`read`in e&&typeof e.read==`function`)?e:{input:e,output:t},this._input=n.input||null,this._output=n.output||null,this._prompt=n.prompt||`> `,this.terminal=n.terminal??this._output!==null,this._historySize=n.historySize??30,this.history=[],this._crlfDelay=n.crlfDelay??100,this.escapeCodeTimeout=n.escapeCodeTimeout,this._input&&(this._boundOnData=e=>this._onData(e),this._boundOnEnd=()=>this._onEnd(),this._boundOnError=e=>this.emit(`error`,e),this._input.on(`data`,this._boundOnData),this._input.on(`end`,this._boundOnEnd),this._input.on(`error`,this._boundOnError),`setEncoding`in this._input&&typeof this._input.setEncoding==`function`&&this._input.setEncoding(`utf8`),this.terminal)){emitKeypressEvents(this._input,this);let e=this._input;typeof e.setRawMode==`function`&&(e.isRaw||e.setRawMode(!0)),typeof this._input.resume==`function`&&this._input.resume(),this._boundOnKeypress=(e,t)=>{t&&(t.name===`backspace`||t.name===`delete`?this.cursor>0&&(this.line=this.line.slice(0,this.cursor-1)+this.line.slice(this.cursor),this.cursor--):e&&e.length===1&&!t.ctrl&&!t.meta&&t.name!==`return`&&t.name!==`enter`&&t.name!==`escape`&&(this.line=this.line.slice(0,this.cursor)+e+this.line.slice(this.cursor),this.cursor++))},this._input.on(`keypress`,this._boundOnKeypress)}}_onData(e){if(this._closed||this._paused)return;let t=typeof e==`string`?e:e.toString(`utf8`);this._lineBuffer+=t;let n;for(;(n=Au.exec(this._lineBuffer))!==null;){let e=this._lineBuffer.substring(0,n.index);this._lineBuffer=this._lineBuffer.substring(n.index+n[0].length),this._onLine(e)}}_onLine(e){if(e.length>0&&this._historySize>0&&(this.history.length===0||this.history[0]!==e)&&(this.history.unshift(e),this.history.length>this._historySize&&this.history.pop()),this._questionCallback){let t=this._questionCallback;this._questionCallback=null,t(e)}this.emit(`line`,e)}_onEnd(){this._lineBuffer.length>0&&(this._onLine(this._lineBuffer),this._lineBuffer=``),this.close()}setPrompt(e){this._prompt=e}getPrompt(){return this._prompt}prompt(e){if(this._closed)throw Error(`readline was closed`);this._output?.write(this._prompt)}question(e,t,n){if(this._closed)throw Error(`readline was closed`);let r=typeof t==`function`?t:n;this._questionCallback=r,this._output?.write(e)}clearLine(e,t){return this.line=``,this.cursor=0,t&&t(),!0}write(e,t){if(!this._closed){if(t){this._input&&this._input.emit(`keypress`,e??``,t);return}if(e!=null){let t=typeof e==`string`?e:e.toString(`utf8`);t&&(this.line=this.line.slice(0,this.cursor)+t+this.line.slice(this.cursor),this.cursor+=t.length),this._output?.write(e)}}}close(){if(!this._closed){if(this._closed=!0,this._input){this._boundOnData&&this._input.removeListener(`data`,this._boundOnData),this._boundOnEnd&&this._input.removeListener(`end`,this._boundOnEnd),this._boundOnError&&this._input.removeListener(`error`,this._boundOnError),this._boundOnKeypress&&this._input.removeListener(`keypress`,this._boundOnKeypress),this._boundOnData=null,this._boundOnEnd=null,this._boundOnError=null,this._boundOnKeypress=null;let e=this._input;this.terminal&&e.isRaw&&typeof e.setRawMode==`function`&&e.setRawMode(!1),typeof this._input.pause==`function`&&this._input.pause()}this.emit(`close`)}}pause(){return this._closed?this:(this._paused=!0,this._input&&`pause`in this._input&&typeof this._input.pause==`function`&&this._input.pause(),this.emit(`pause`),this)}resume(){return this._closed?this:(this._paused=!1,this._input&&`resume`in this._input&&typeof this._input.resume==`function`&&this._input.resume(),this.emit(`resume`),this)}getCursorPos(){let e=this._output?.columns??80,t=this._prompt.length+this.cursor;return{rows:Math.floor(t/e),cols:t%e}}[Symbol.asyncIterator](){let e=[],t=null,n=!1,onLine=n=>{if(t){let e=t;t=null,e({value:n,done:!1})}else e.push(n)},onClose=()=>{if(n=!0,t){let e=t;t=null,e({value:void 0,done:!0})}};return this.on(`line`,onLine),this.on(`close`,onClose),{next:()=>e.length>0?Promise.resolve({value:e.shift(),done:!1}):n?Promise.resolve({value:void 0,done:!0}):new Promise(e=>{t=e}),return:()=>(n=!0,this.removeListener(`line`,onLine),this.removeListener(`close`,onClose),Promise.resolve({value:void 0,done:!0})),[Symbol.asyncIterator](){return this}}}},ju=Symbol.dispose??Symbol.for(`Symbol.dispose`),Interface.prototype[ju]=function(){this.close()},Mu=Symbol(`keypress-decoder`),Nu=Symbol(`escape-decoder`)}),Fu,Iu=__esmMin(()=>{Yl(),Fl(),Il(),Xl(),eu(),ku(),cu(),uu(),hu(),K(),$(),W(),Pu(),Fu=class FileHandle{options;_gFile;_pathStr;_spec;_pos=0;_closed=!1;_webStreamLocked=!1;static instances={};constructor(e){this.options=e,this.options.flags??=`r`;let t=normalizePath(e.path);this._spec=parseOpenFlags(this.options.flags),this.options.mode??=438;let n=normalizeMode(this.options.mode,438);return this.fd=openFd(t,this._spec,n),this._pathStr=t,this._gFile=Q.File.new_for_path(t),FileHandle.instances[this.fd]=this,FileHandle.getInstance(this.fd)}_readCore(e,t,n,r){if(this._assertOpen(`read`),!this._spec.readable)throw fsError(`EBADF`,`read`,this._pathStr);if(n>e.byteLength-t){let r=RangeError(`The value of "length" is out of range. It must be <= ${e.byteLength-t}. Received ${n}`);throw r.code=`ERR_OUT_OF_RANGE`,r}let i=r!=null&&r>=0,o=isSeekableFd(this.fd,this._pathStr);if(i&&!o)throw fsError(`ESPIPE`,`read`,this._pathStr);let s=i?r:this._pos;o&&seekFd(this.fd,s);let c=readFd(this.fd,n);return c.length>0&&new Uint8Array(e.buffer,e.byteOffset+t,c.length).set(c),!i&&o&&(this._pos=s+c.length),c.length}_writeCore(e,t){if(this._assertOpen(`write`),!this._spec.writable)throw fsError(`EBADF`,`write`,this._pathStr);if(this._spec.append){let t=writeFd(this.fd,e);return this._pos=tellFd(this.fd)??sizeOfFd(this.fd,this._pathStr),t}let n=t!=null&&t>=0,r=isSeekableFd(this.fd,this._pathStr);if(n&&!r)throw fsError(`ESPIPE`,`write`,this._pathStr);let i=n?t:this._pos;r&&seekFd(this.fd,i);let o=writeFd(this.fd,e);return!n&&r&&(this._pos=i+o),o}_assertOpen(e){if(this._closed)throw fsError(`EBADF`,e,this._pathStr)}_truncateCore(e){if(this._assertOpen(`ftruncate`),!this._spec.writable)throw fsError(`EINVAL`,`ftruncate`,this._pathStr);truncateFd(this.fd,Math.max(0,e),this._pathStr)}_readToEnd(){let e=[],t=0;for(;;){let n=new Uint8Array(64*1024),r=this._readCore(n,0,n.length,null);if(r===0)break;e.push(n.subarray(0,r)),t+=r}let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}_fdTarget(){return fdPath(this.fd)??this._pathStr}fd;static getInstance(e,t=`read`){let n=e instanceof FileHandle?e.fd:e,r=FileHandle.instances[n];if(!r)throw fsError(`EBADF`,t);return r}async appendFile(e,t){await this.writeFile(e,t)}async chown(e,t){this._assertOpen(`fchown`),chownSync(normalizePath(this.options.path),e,t)}async chmod(e){this._assertOpen(`fchmod`),chmodSync(this._fdTarget(),e)}createReadStream(e){return new ReadStream(this.options.path,{...e,fd:this.fd})}createWriteStream(e){return new WriteStream(this.options.path,{...e,fd:this.fd,fdFromHandle:!0})}async datasync(){this._assertOpen(`fdatasync`),fsyncFd(this.fd)}async sync(){this._assertOpen(`fsync`),fsyncFd(this.fd)}async read(...e){let t,n,r,i;if(typeof e[0]==`object`&&!(e[0]instanceof Uint8Array)&&!(e[0]instanceof U)){let o=e[0];t=o.buffer,n=o.offset,r=o.length,i=o.position}else t=e[0],n=e[1],r=e[2],i=e[3];let o=t,s=n??0,c=r??(o?o.byteLength-s:65536);return{bytesRead:this._readCore(t,s,c,i??null),buffer:t}}readableWebStream(){if(this._closed)throw invalidState(`The FileHandle is closed`);if(this._webStreamLocked)throw invalidState(`The FileHandle is locked`);let e=globalThis.ReadableStream;if(typeof e!=`function`)throw Error(`readableWebStream() requires a global ReadableStream. Import "node:stream/web" or "@gjsify/web-streams/register" before calling this method.`);return this._webStreamLocked=!0,new e({type:`bytes`,pull:e=>{if(this._closed){e.close(),e.byobRequest?.respond(0);return}let t=e.byobRequest?.view,n=t?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(64*1024),r;try{r=this._readCore(n,0,n.length,null)}catch(t){e.error(t);return}if(r===0){e.close(),e.byobRequest?.respond(0);return}if(e.byobRequest){e.byobRequest.respond(r);return}e.enqueue(n.subarray(0,r))}})}async readFile(e){return encodeUint8Array(getEncodingFromOptions(e,`buffer`),this._readToEnd())}readLines(e){return createInterface({input:this.createReadStream(e),crlfDelay:1/0})}async stat(e){this._assertOpen(`fstat`);let t=Q.File.new_for_path(this._fdTarget());return statsFrom(await new Promise((e,n)=>{t.query_info_async(lu,Q.FileQueryInfoFlags.NONE,G.PRIORITY_DEFAULT,null,(r,i)=>{try{e(t.query_info_finish(i))}catch(e){n(e)}})}),this._pathStr,`fstat`,e?.bigint)}async truncate(e=0){this._truncateCore(e)}async utimes(e,t){this._assertOpen(`futimes`);let{utimesSync:n}=await Promise.resolve().then(()=>(Vl(),Bl));n(normalizePath(this.options.path),e,t)}async writeFile(e,t){let n=getEncodingFromOptions(t),r;r=typeof e==`string`?U.from(e,n||`utf8`):e,this._writeCore(r,null)}async write(e,...t){let n=null,r=null,i=null,o=null;typeof e==`string`?(n=t[0],r=t[1]):(i=t[0],o=t[1],n=t[2]),r=getEncodingFromOptions(r,typeof e==`string`?`utf8`:null);let s;s=typeof e==`string`?new TextEncoder().encode(e):e;let c=i??0,l=o??s.byteLength-c,u=s.subarray(c,c+l);return{bytesWritten:this._writeCore(u,n??null),buffer:e}}async writev(e,t){let n=0;for(let r of e){let e=U.from(r.buffer,r.byteOffset,r.byteLength),i=await this.write(e,0,e.byteLength,t==null?null:t+n);n+=i.bytesWritten}return{bytesWritten:n,buffers:e}}async readv(e,t){let n=0;for(let r of e){let e=await this.read({buffer:U.from(r.buffer,r.byteOffset,r.byteLength),position:t==null?null:t+n});if(n+=e.bytesRead,e.bytesRead<r.byteLength)break}return{bytesRead:n,buffers:e}}_flushSync(){fsyncFd(this.fd)}_closeSync(){this._teardown()}_readSync(e,t,n,r){return this._readCore(e,t,n,r)}_writeSync(e,t){return this._writeCore(e,t)}_readToEndSync(){return this._readToEnd()}_truncateSync(e){this._truncateCore(e)}_fdStatTarget(){return this._fdTarget()}_teardown(){if(this._closed)return;this._closed=!0,releaseFd(this.fd),closeFd(this.fd);let e=FileHandle;delete e.instances[this.fd]}async close(){this._teardown()}async[Symbol.asyncDispose](){await this.close()}pull(...e){throw Error('FileHandle.pull() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}writer(e){throw Error('FileHandle.writer() is not implemented in @gjsify/fs yet — requires `node:stream/iter` (Node 25.9+) which @gjsify/stream has not ported. Track gjsify Open TODO "Node 25 stream/iter integration".')}}});function getFH(e,t){return Fu.getInstance(e,t)}function fstatSync(e,t){return statSync(getFH(e,`fstat`)._fdStatTarget(),t)}function fstat(e,t,n){let r=typeof t==`function`?t:requireCallback(n);fstatAsync(e,typeof t==`function`?{}:t).then(e=>r(null,e),e=>r(e,void 0))}async function fstatAsync(e,t){return t?.bigint,fstatSync(e,t)}function ftruncateSync(e,t=0){getFH(e,`ftruncate`)._truncateSync(t)}function ftruncate(e,t,n){let r=typeof t==`function`?t:requireCallback(n);ftruncateAsync(e,typeof t==`function`?0:t).then(()=>r(null),r)}async function ftruncateAsync(e,t=0){ftruncateSync(e,t)}function fdatasyncSync(e){getFH(e,`fdatasync`)._flushSync()}function fdatasync(e,t){requireCallback(t),Promise.resolve().then(()=>fdatasyncSync(e)).then(()=>t(null),t)}async function fdatasyncAsync(e){fdatasyncSync(e)}function fsyncSync(e){getFH(e,`fsync`)._flushSync()}function fsync(e,t){requireCallback(t),Promise.resolve().then(()=>fsyncSync(e)).then(()=>t(null),t)}async function fsyncAsync(e){fsyncSync(e)}function fchmodSync(e,t){chmodSync(getFH(e,`fchmod`)._fdStatTarget(),t)}function fchmod(e,t,n){requireCallback(n),Promise.resolve().then(()=>fchmodSync(e,t)).then(()=>n(null),n)}async function fchmodAsync(e,t){fchmodSync(e,t)}function fchownSync(e,t,n){chownSync(normalizePath(getFH(e,`fchown`).options.path),t,n)}function fchown(e,t,n,r){requireCallback(r),Promise.resolve().then(()=>fchownSync(e,t,n)).then(()=>r(null),r)}async function fchownAsync(e,t,n){fchownSync(e,t,n)}function futimesSync(e,t,n){utimesSync(normalizePath(getFH(e,`futimes`).options.path),t,n)}function futimes(e,t,n,r){requireCallback(r),Promise.resolve().then(()=>futimesSync(e,t,n)).then(()=>r(null),r)}async function futimesAsync(e,t,n){futimesSync(e,t,n)}function closeSync(e){isStdFd(e)||getFH(e,`close`)._closeSync()}function readSync(e,t,n,r,i){let o=0;return typeof n==`object`&&n?(o=n.offset??0,r=n.length??t.byteLength-o,i=n.position??null):(o=n??0,r??=t.byteLength-o),isStdFd(e)?readStdFdSync(e,t,o,r):getFH(e,`read`)._readSync(t,o,r,i??null)}function writeSync(e,t,n,r,i){let o;if(typeof t==`string`)o=new TextEncoder().encode(t),typeof n==`number`&&(i=n);else{let e=typeof n==`number`?n:0,i=typeof r==`number`?r:t.byteLength-e;o=new Uint8Array(t.buffer,t.byteOffset+e,i)}return isStdFd(e)?writeStdFdSync(e,o):getFH(e,`write`)._writeSync(o,i??null)}function readvSync(e,t,n){let r=0;for(let i of t){let t=readSync(e,i,0,i.byteLength,n==null?null:n+r);if(r+=t,t<i.byteLength)break}return r}function readv(e,t,n,r){let i=typeof n==`function`?n:requireCallback(r);readvAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesRead,e.buffers),e=>i(e,0,t))}async function readvAsync(e,t,n){return{bytesRead:readvSync(e,t,n),buffers:t}}function writevSync(e,t,n){let r=0;for(let i of t){let t=writeSync(e,i,0,i.byteLength,n==null?null:n+r);r+=t}return r}function writev(e,t,n,r){let i=typeof n==`function`?n:requireCallback(r);writevAsync(e,t,typeof n==`function`?null:n).then(e=>i(null,e.bytesWritten,e.buffers),e=>i(e,0,t))}async function writevAsync(e,t,n){return{bytesWritten:writevSync(e,t,n),buffers:t}}function exists(e,t){requireCallback(t);let n;try{statSync(normalizePath(e)),n=!0}catch{n=!1}Promise.resolve().then(()=>t(n))}async function openAsBlob(e,t){let n=readFileSync(normalizePath(e));return new Blob([n],{type:t?.type??``})}var Lu=__esmMin(()=>{Fl(),Il(),Vl(),Jl(),Iu(),hu(),Object.defineProperty(exists,Symbol.for(`nodejs.util.promisify.custom`),{value:e=>new Promise(t=>exists(e,t))})});function zeroedStat(){return{dev:0,ino:0,mode:0,nlink:0,uid:0,gid:0,rdev:0,size:0,blksize:0,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:new Date(0),mtime:new Date(0),ctime:new Date(0),birthtime:new Date(0),isFile:()=>!1,isDirectory:()=>!1,isBlockDevice:()=>!1,isCharacterDevice:()=>!1,isSymbolicLink:()=>!1,isFIFO:()=>!1,isSocket:()=>!1}}function watchFile(e,t,n){typeof t==`function`&&(n=t,t={}),requireCallback(n,`listener`);let r=t.interval??5007,i=e.toString(),o=Ru.get(i);return o||(o=new StatWatcher(i,r),o.start(),Ru.set(i,o)),n&&o.addChangeListener(n),o}function unwatchFile(e,t){let n=e.toString(),r=Ru.get(n);r&&(t?r.removeChangeListener(t):r.removeAllChangeListeners(),r.changeListenerCount===0&&(r.stop(),Ru.delete(n)))}var StatWatcher,Ru,zu=__esmMin(()=>{Il(),hu(),jn(),StatWatcher=class extends q{_path;_interval;_timerId=null;_prev;_changeCount=0;constructor(e,t){super(),this._path=e,this._interval=t,this._prev=zeroedStat()}start(){try{this._prev=statSync(this._path)}catch{}this._timerId=setInterval(()=>{let e;try{e=statSync(this._path)}catch{e=zeroedStat()}let t=this._prev;(e.mtimeMs!==t.mtimeMs||e.size!==t.size||e.ino!==t.ino)&&(this._prev=e,this.emit(`change`,e,t))},this._interval)}stop(){this._timerId!==null&&(clearInterval(this._timerId),this._timerId=null),this.emit(`stop`)}addChangeListener(e){this._changeCount++,this.on(`change`,e)}removeChangeListener(e){this._changeCount--,this.removeListener(`change`,e)}removeAllChangeListeners(){this._changeCount=0,this.removeAllListeners(`change`)}get changeListenerCount(){return this._changeCount}},Ru=new Map}),Bu=__exportAll$4({BigIntStats:()=>BigIntStats,Dir:()=>Dir,Dirent:()=>Dirent,FSWatcher:()=>FSWatcher,ReadStream:()=>ReadStream,StatWatcher:()=>StatWatcher,Stats:()=>Stats,WriteStream:()=>WriteStream,access:()=>access,accessSync:()=>accessSync,appendFile:()=>appendFile,appendFileSync:()=>appendFileSync,chmod:()=>chmod,chmodSync:()=>chmodSync,chown:()=>chown,chownSync:()=>chownSync,close:()=>close,closeSync:()=>closeSync,constants:()=>Vu,copyFile:()=>copyFile,copyFileSync:()=>copyFileSync,cp:()=>cp,cpSync:()=>cpSync,createReadStream:()=>createReadStream,createWriteStream:()=>createWriteStream,default:()=>Hu,exists:()=>exists,existsSync:()=>existsSync,fchmod:()=>fchmod,fchmodSync:()=>fchmodSync,fchown:()=>fchown,fchownSync:()=>fchownSync,fdatasync:()=>fdatasync,fdatasyncSync:()=>fdatasyncSync,fstat:()=>fstat,fstatSync:()=>fstatSync,fsync:()=>fsync,fsyncSync:()=>fsyncSync,ftruncate:()=>ftruncate,ftruncateSync:()=>ftruncateSync,futimes:()=>futimes,futimesSync:()=>futimesSync,glob:()=>glob,globSync:()=>globSync,lchmod:()=>void 0,lchmodSync:()=>void 0,lchown:()=>lchown,lchownSync:()=>lchownSync,link:()=>link,linkSync:()=>linkSync,lstat:()=>lstat,lstatSync:()=>lstatSync,lutimes:()=>lutimes,lutimesSync:()=>lutimesSync,mkdir:()=>mkdir,mkdirSync:()=>mkdirSync,mkdtemp:()=>mkdtemp,mkdtempSync:()=>mkdtempSync,open:()=>open,openAsBlob:()=>openAsBlob,openSync:()=>openSync,opendir:()=>opendir,opendirSync:()=>opendirSync,promises:()=>Cu,read:()=>read,readFile:()=>readFile,readFileSync:()=>readFileSync,readSync:()=>readSync,readdir:()=>readdir,readdirSync:()=>readdirSync,readlink:()=>readlink,readlinkSync:()=>readlinkSync,readv:()=>readv,readvSync:()=>readvSync,realpath:()=>realpath,realpathSync:()=>realpathSync,rename:()=>rename,renameSync:()=>renameSync,rm:()=>rm,rmSync:()=>rmSync,rmdir:()=>rmdir,rmdirSync:()=>rmdirSync,stat:()=>stat,statSync:()=>statSync,statfs:()=>statfs,statfsSync:()=>statfsSync,symlink:()=>symlink,symlinkSync:()=>symlinkSync,truncate:()=>truncate,truncateSync:()=>truncateSync,unlink:()=>unlink,unlinkSync:()=>unlinkSync,unwatchFile:()=>unwatchFile,utimes:()=>utimes,utimesSync:()=>utimesSync,watch:()=>watch,watchFile:()=>watchFile,write:()=>write,writeFile:()=>writeFile,writeFileSync:()=>writeFileSync,writeSync:()=>writeSync,writev:()=>writev,writevSync:()=>writevSync});function openFlagDescriptors(){let e={};for(let t of Object.keys(openFlagValues()))e[t]={enumerable:!0,configurable:!0,get:()=>openFlagValues()[t]};return e}var Vu,Hu,Uu=__esmMin(()=>{zl(),Vl(),Lu(),Xl(),eu(),ku(),tu(),uu(),hu(),gu(),vu(),yu(),Su(),Tu(),Eu(),zu(),Vu=Object.defineProperties({F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1},openFlagDescriptors()),Hu={FSWatcher,StatWatcher,Stats,BigIntStats,Dirent,Dir,constants:Vu,existsSync,readdirSync,readFileSync,writeFileSync,mkdirSync,rmdirSync,unlinkSync,mkdtemp,mkdtempSync,rmSync,statSync,openSync,realpathSync,symlinkSync,lstatSync,renameSync,copyFileSync,accessSync,appendFileSync,readlinkSync,linkSync,truncateSync,chmodSync,chownSync,cpSync,opendirSync,globSync,glob,watch,watchFile,unwatchFile,statfsSync,statfs,utimesSync,utimes,lutimesSync,lutimes,lchownSync,lchown,lchmodSync:void 0,lchmod:void 0,fstatSync,fstat,ftruncateSync,ftruncate,fdatasyncSync,fdatasync,fsyncSync,fsync,fchmodSync,fchmod,fchownSync,fchown,futimesSync,futimes,closeSync,readSync,writeSync,readvSync,readv,writevSync,writev,exists,openAsBlob,createReadStream,ReadStream,createWriteStream,WriteStream,promises:Cu,open,close,read,write,rm,realpath,readdir,symlink,lstat,stat,rename,copyFile,cp,access,appendFile,readlink,truncate,chmod,chown,mkdir,rmdir,readFile,writeFile,unlink,link,opendir}}),Wu=__commonJSMin(((e,t)=>{
198
198
  /*!
199
199
  * express
200
200
  * Copyright(c) 2009-2013 TJ Holowaychuk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/example-node-express-webserver",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "description": "Express.js blog showcase with JSON API and static frontend — a real Node.js web app running on GJS",
5
5
  "main": "dist/index.gjs.js",
6
6
  "type": "module",
@@ -21,12 +21,12 @@
21
21
  "build:public": "gjsify copy src/public dist/public"
22
22
  },
23
23
  "dependencies": {
24
- "@gjsify/http-soup-bridge": "^0.46.0"
24
+ "@gjsify/http-soup-bridge": "^0.48.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@gjsify/cli": "^0.46.0",
28
- "@gjsify/node-globals": "^0.46.0",
29
- "@gjsify/runtime": "^0.46.0",
27
+ "@gjsify/cli": "^0.48.0",
28
+ "@gjsify/node-globals": "^0.48.0",
29
+ "@gjsify/runtime": "^0.48.0",
30
30
  "@types/express": "^5.0.6",
31
31
  "@types/node": "^25.9.2",
32
32
  "express": "^5.2.1",