#!/usr/bin/env node
"use strict";var he=Object.defineProperty;var c=(h,x)=>he(h,"name",{value:x,configurable:!0});var index=require("../chunks/index2.cjs"),index$2=require("../chunks/index8.cjs"),require$$0$4=require("os"),sysPath=require("path"),S=require("fs"),require$$0$5=require("child_process"),require$$0$1=require("buffer"),require$$0=require("stream"),require$$0$3=require("util"),zlib=require("zlib"),index$1=require("../chunks/index3.cjs"),require$$0$2=require("events");require("node:url");require("node:fs");require("node:fs/promises");require("node:util");require("node:path");require("node:os");require("tty");require("node:perf_hooks");require("url");require("node:readline");require("node:process");require("node:tty");require("node:assert");require("readline");require("assert");require("../chunks/index4.cjs");require("string_decoder");require("crypto");require("node:stream");const smyth_banner=`
\x1B[38;5;0m                .\x1B[38;5;23m:\x1B[38;5;29m=\x1B[38;5;36m==\x1B[38;5;29m=\x1B[38;5;23m:\x1B[38;5;0m.                {{LINE01}}
\x1B[0m\x1B[38;5;0m             \x1B[38;5;23m:\x1B[38;5;29m-\x1B[38;5;30m=\x1B[38;5;36m++++++++\x1B[38;5;30m=\x1B[38;5;23m-\x1B[38;5;22m.\x1B[38;5;0m             {{LINE02}}
\x1B[0m\x1B[38;5;0m         .\x1B[38;5;23m:\x1B[38;5;66m=\x1B[38;5;73m++\x1B[38;5;36m+++++++++++++=\x1B[38;5;29m-\x1B[38;5;23m:\x1B[38;5;0m          {{LINE03}}
\x1B[0m\x1B[38;5;0m      \x1B[38;5;23m:\x1B[38;5;29m-\x1B[38;5;72m+\x1B[38;5;79m***\x1B[38;5;73m+\x1B[38;5;36m=++++++++++===\x1B[38;5;30m====\x1B[38;5;29m-\x1B[38;5;23m:\x1B[38;5;22m.\x1B[38;5;0m      {{LINE04}}
\x1B[0m\x1B[38;5;0m    \x1B[38;5;23m:\x1B[38;5;72m+\x1B[38;5;79m******\x1B[38;5;36m+++++++++==\x1B[38;5;30m============\x1B[38;5;29m-\x1B[38;5;23m:\x1B[38;5;0m   {{LINE05}}
\x1B[0m\x1B[38;5;0m   \x1B[38;5;66m=\x1B[38;5;79m*******+\x1B[38;5;36m+++++=\x1B[38;5;29m-\x1B[38;5;23m:::\x1B[38;5;29m-\x1B[38;5;30m===========\x1B[38;5;29m-\x1B[38;5;23m:\x1B[38;5;0m.   {{LINE06}}
\x1B[0m\x1B[38;5;0m  \x1B[38;5;23m-\x1B[38;5;79m********+\x1B[38;5;36m++\x1B[38;5;29m=\x1B[38;5;23m:\x1B[38;5;0m.      .\x1B[38;5;23m:\x1B[38;5;29m-\x1B[38;5;30m====\x1B[38;5;29m-\x1B[38;5;23m:.\x1B[38;5;0m       {{LINE07}}
\x1B[0m\x1B[38;5;0m  \x1B[38;5;72m=\x1B[38;5;79m********\x1B[38;5;73m+\x1B[38;5;23m:\x1B[38;5;0m#111111111111#\x1B[38;5;23m:\x1B[38;5;29m-\x1B[38;5;22m.\x1B[38;5;0m          {{LINE08}}
\x1B[0m\x1B[38;5;0m  \x1B[38;5;66m=\x1B[38;5;79m********\x1B[38;5;72m=\x1B[38;5;0m #222222222222# \x1B[38;5;72m=+\x1B[38;5;29m=\x1B[38;5;23m:\x1B[38;5;0m.       {{LINE09}}
\x1B[0m\x1B[38;5;0m  .\x1B[38;5;72m+\x1B[38;5;79m*******\x1B[38;5;72m=\x1B[38;5;0m #333333333333# \x1B[38;5;72m=\x1B[38;5;79m****\x1B[38;5;72m=\x1B[38;5;23m-\x1B[38;5;22m.\x1B[38;5;0m    {{LINE10}}
\x1B[0m\x1B[38;5;0m    \x1B[38;5;22m.\x1B[38;5;23m-\x1B[38;5;72m=\x1B[38;5;79m****\x1B[38;5;72m=\x1B[38;5;0m #444444444444# \x1B[38;5;72m=\x1B[38;5;79m*******\x1B[38;5;72m+\x1B[38;5;0m.  {{LINE11}}
\x1B[0m\x1B[38;5;0m        \x1B[38;5;23m:\x1B[38;5;29m=\x1B[38;5;72m+=\x1B[38;5;0m #555555555555# \x1B[38;5;72m=\x1B[38;5;79m********\x1B[38;5;66m=\x1B[38;5;0m  {{LINE12}}
\x1B[0m\x1B[38;5;0m          \x1B[38;5;22m.\x1B[38;5;29m-\x1B[38;5;23m:\x1B[38;5;0m#666666666666#\x1B[38;5;23m:\x1B[38;5;73m+\x1B[38;5;79m********\x1B[38;5;72m=\x1B[38;5;0m  {{LINE13}}
\x1B[0m\x1B[38;5;0m       \x1B[38;5;23m.:\x1B[38;5;30m-====\x1B[38;5;29m-\x1B[38;5;23m:\x1B[38;5;0m.      .\x1B[38;5;23m:\x1B[38;5;30m=\x1B[38;5;36m++\x1B[38;5;79m+********\x1B[38;5;23m-\x1B[38;5;0m  {{LINE14}}
\x1B[0m\x1B[38;5;0m   \x1B[38;5;22m.\x1B[38;5;23m:\x1B[38;5;29m-\x1B[38;5;30m===========\x1B[38;5;29m-\x1B[38;5;23m:::\x1B[38;5;29m-\x1B[38;5;36m=+++++\x1B[38;5;79m+*******\x1B[38;5;66m=\x1B[38;5;0m   {{LINE15}}
\x1B[0m\x1B[38;5;0m   \x1B[38;5;23m:\x1B[38;5;29m-\x1B[38;5;30m============\x1B[38;5;36m==+++++++++\x1B[38;5;79m******\x1B[38;5;72m+\x1B[38;5;23m:\x1B[38;5;0m    {{LINE16}}
\x1B[0m\x1B[38;5;0m      \x1B[38;5;22m.\x1B[38;5;23m:\x1B[38;5;29m-\x1B[38;5;30m====\x1B[38;5;36m===++++++++++=\x1B[38;5;73m+\x1B[38;5;79m***\x1B[38;5;72m+\x1B[38;5;29m-\x1B[38;5;23m.\x1B[38;5;0m      {{LINE17}}
\x1B[0m\x1B[38;5;0m         .\x1B[38;5;23m:\x1B[38;5;29m-\x1B[38;5;36m=+++++++++++++\x1B[38;5;73m++\x1B[38;5;66m=\x1B[38;5;23m:\x1B[38;5;0m.         {{LINE18}}
\x1B[0m\x1B[38;5;0m             \x1B[38;5;23m.-\x1B[38;5;30m=\x1B[38;5;36m++++++++\x1B[38;5;30m=\x1B[38;5;29m-\x1B[38;5;23m:\x1B[38;5;0m             {{LINE19}}
\x1B[0m\x1B[38;5;0m                .\x1B[38;5;23m:\x1B[38;5;29m=\x1B[38;5;36m==\x1B[38;5;29m=\x1B[38;5;23m:\x1B[38;5;0m.                {{LINE20}}
\x1B[0m
`;var i=Object.defineProperty,o=c((h,x)=>i(h,"name",{value:x,configurable:!0}),"o");function banner(h,x){let m=smyth_banner;for(let p=0;p<7;p++){let d="";for(let g=0;g<12;g++)d+=p;m=m.replace(`#${d}#`,h[p]||"              ")}for(let p=0;p<20;p++)m=m.replace(`{{LINE${(p+1).toString().padStart(2,"0")}}}`,x[p]||"");return m}c(banner,"banner");o(banner,"banner");var getStream={exports:{}},once={exports:{}},wrappy_1,hasRequiredWrappy;function requireWrappy(){if(hasRequiredWrappy)return wrappy_1;hasRequiredWrappy=1,wrappy_1=h;function h(x,m){if(x&&m)return h(x)(m);if(typeof x!="function")throw new TypeError("need wrapper function");return Object.keys(x).forEach(function(d){p[d]=x[d]}),p;function p(){for(var d=new Array(arguments.length),g=0;g<d.length;g++)d[g]=arguments[g];var f=x.apply(this,d),q=d[d.length-1];return typeof f=="function"&&f!==q&&Object.keys(q).forEach(function(w){f[w]=q[w]}),f}c(p,"wrapper")}return c(h,"wrappy"),wrappy_1}c(requireWrappy,"requireWrappy");var hasRequiredOnce;function requireOnce(){if(hasRequiredOnce)return once.exports;hasRequiredOnce=1;var h=requireWrappy();once.exports=h(x),once.exports.strict=h(m),x.proto=x(function(){Object.defineProperty(Function.prototype,"once",{value:c(function(){return x(this)},"value"),configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:c(function(){return m(this)},"value"),configurable:!0})});function x(p){var d=c(function(){return d.called?d.value:(d.called=!0,d.value=p.apply(this,arguments))},"f");return d.called=!1,d}c(x,"once$1");function m(p){var d=c(function(){if(d.called)throw new Error(d.onceError);return d.called=!0,d.value=p.apply(this,arguments)},"f"),g=p.name||"Function wrapped with `once`";return d.onceError=g+" shouldn't be called more than once",d.called=!1,d}return c(m,"onceStrict"),once.exports}c(requireOnce,"requireOnce");var endOfStream,hasRequiredEndOfStream;function requireEndOfStream(){if(hasRequiredEndOfStream)return endOfStream;hasRequiredEndOfStream=1;var h=requireOnce(),x=c(function(){},"noop"),m=index.commonjsGlobal.Bare?queueMicrotask:process.nextTick.bind(process),p=c(function(f){return f.setHeader&&typeof f.abort=="function"},"isRequest"),d=c(function(f){return f.stdio&&Array.isArray(f.stdio)&&f.stdio.length===3},"isChildProcess"),g=c(function(f,q,w){if(typeof q=="function")return g(f,null,q);q||(q={}),w=h(w||x);var M=f._writableState,R=f._readableState,U=q.readable||q.readable!==!1&&f.readable,u=q.writable||q.writable!==!1&&f.writable,E=!1,n=c(function(){f.writable||a()},"onlegacyfinish"),a=c(function(){u=!1,U||w.call(f)},"onfinish"),s=c(function(){U=!1,u||w.call(f)},"onend"),v=c(function(V){w.call(f,V?new Error("exited with error code: "+V):null)},"onexit"),j=c(function(V){w.call(f,V)},"onerror"),N=c(function(){m(A)},"onclose"),A=c(function(){if(!E){if(U&&!(R&&R.ended&&!R.destroyed))return w.call(f,new Error("premature close"));if(u&&!(M&&M.ended&&!M.destroyed))return w.call(f,new Error("premature close"))}},"onclosenexttick"),k=c(function(){f.req.on("finish",a)},"onrequest");return p(f)?(f.on("complete",a),f.on("abort",N),f.req?k():f.on("request",k)):u&&!M&&(f.on("end",n),f.on("close",n)),d(f)&&f.on("exit",v),f.on("end",s),f.on("finish",a),q.error!==!1&&f.on("error",j),f.on("close",N),function(){E=!0,f.removeListener("complete",a),f.removeListener("abort",N),f.removeListener("request",k),f.req&&f.req.removeListener("finish",a),f.removeListener("end",n),f.removeListener("close",n),f.removeListener("finish",a),f.removeListener("exit",v),f.removeListener("end",s),f.removeListener("error",j),f.removeListener("close",N)}},"eos");return endOfStream=g,endOfStream}c(requireEndOfStream,"requireEndOfStream");var pump_1,hasRequiredPump;function requirePump(){if(hasRequiredPump)return pump_1;hasRequiredPump=1;var h=requireOnce(),x=requireEndOfStream(),m;try{m=require("fs")}catch{}var p=c(function(){},"noop"),d=typeof process>"u"?!1:/^v?\.0/.test(process.version),g=c(function(u){return typeof u=="function"},"isFn"),f=c(function(u){return!d||!m?!1:(u instanceof(m.ReadStream||p)||u instanceof(m.WriteStream||p))&&g(u.close)},"isFS"),q=c(function(u){return u.setHeader&&g(u.abort)},"isRequest"),w=c(function(u,E,n,a){a=h(a);var s=!1;u.on("close",function(){s=!0}),x(u,{readable:E,writable:n},function(j){if(j)return a(j);s=!0,a()});var v=!1;return function(j){if(!s&&!v){if(v=!0,f(u))return u.close(p);if(q(u))return u.abort();if(g(u.destroy))return u.destroy();a(j||new Error("stream was destroyed"))}}},"destroyer"),M=c(function(u){u()},"call"),R=c(function(u,E){return u.pipe(E)},"pipe"),U=c(function(){var u=Array.prototype.slice.call(arguments),E=g(u[u.length-1]||p)&&u.pop()||p;if(Array.isArray(u[0])&&(u=u[0]),u.length<2)throw new Error("pump requires two streams per minimum");var n,a=u.map(function(s,v){var j=v<u.length-1,N=v>0;return w(s,j,N,function(A){n||(n=A),A&&a.forEach(M),!j&&(a.forEach(M),E(n))})});return u.reduce(R)},"pump");return pump_1=U,pump_1}c(requirePump,"requirePump");var bufferStream,hasRequiredBufferStream;function requireBufferStream(){if(hasRequiredBufferStream)return bufferStream;hasRequiredBufferStream=1;const{PassThrough:h}=require$$0;return bufferStream=c(x=>{x={...x};const{array:m}=x;let{encoding:p}=x;const d=p==="buffer";let g=!1;m?g=!(p||d):p=p||"utf8",d&&(p=null);const f=new h({objectMode:g});p&&f.setEncoding(p);let q=0;const w=[];return f.on("data",M=>{w.push(M),g?q=w.length:q+=M.length}),f.getBufferedValue=()=>m?w:d?Buffer.concat(w,q):w.join(""),f.getBufferedLength=()=>q,f},"bufferStream"),bufferStream}c(requireBufferStream,"requireBufferStream");var hasRequiredGetStream;function requireGetStream(){if(hasRequiredGetStream)return getStream.exports;hasRequiredGetStream=1;const{constants:h}=require$$0$1,x=requirePump(),m=requireBufferStream();class p extends Error{static{c(this,"MaxBufferError")}constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function d(g,f){if(!g)return Promise.reject(new Error("Expected a stream"));f={maxBuffer:1/0,...f};const{maxBuffer:q}=f;let w;return await new Promise((M,R)=>{const U=c(u=>{u&&w.getBufferedLength()<=h.MAX_LENGTH&&(u.bufferedData=w.getBufferedValue()),R(u)},"rejectPromise");w=x(g,m(f),u=>{if(u){U(u);return}M()}),w.on("data",()=>{w.getBufferedLength()>q&&U(new p)})}),w.getBufferedValue()}return c(d,"getStream$1"),getStream.exports=d,getStream.exports.default=d,getStream.exports.buffer=(g,f)=>d(g,{...f,encoding:"buffer"}),getStream.exports.array=(g,f)=>d(g,{...f,array:!0}),getStream.exports.MaxBufferError=p,getStream.exports}c(requireGetStream,"requireGetStream");var yauzl={},fdSlicer={},hasRequiredFdSlicer;function requireFdSlicer(){if(hasRequiredFdSlicer)return fdSlicer;hasRequiredFdSlicer=1;var h=S,x=require$$0$3,m=require$$0,p=m.Readable,d=m.Writable,g=m.PassThrough,f=index$1.requirePend(),q=require$$0$2.EventEmitter;fdSlicer.createFromBuffer=u,fdSlicer.createFromFd=E,fdSlicer.BufferSlicer=U,fdSlicer.FdSlicer=w,x.inherits(w,q);function w(n,a){a=a||{},q.call(this),this.fd=n,this.pend=new f,this.pend.max=1,this.refCount=0,this.autoClose=!!a.autoClose}c(w,"FdSlicer"),w.prototype.read=function(n,a,s,v,j){var N=this;N.pend.go(function(A){h.read(N.fd,n,a,s,v,function(k,V,ie){A(),j(k,V,ie)})})},w.prototype.write=function(n,a,s,v,j){var N=this;N.pend.go(function(A){h.write(N.fd,n,a,s,v,function(k,V,ie){A(),j(k,V,ie)})})},w.prototype.createReadStream=function(n){return new M(this,n)},w.prototype.createWriteStream=function(n){return new R(this,n)},w.prototype.ref=function(){this.refCount+=1},w.prototype.unref=function(){var n=this;if(n.refCount-=1,n.refCount>0)return;if(n.refCount<0)throw new Error("invalid unref");n.autoClose&&h.close(n.fd,a);function a(s){s?n.emit("error",s):n.emit("close")}c(a,"onCloseDone")},x.inherits(M,p);function M(n,a){a=a||{},p.call(this,a),this.context=n,this.context.ref(),this.start=a.start||0,this.endOffset=a.end,this.pos=this.start,this.destroyed=!1}c(M,"ReadStream"),M.prototype._read=function(n){var a=this;if(!a.destroyed){var s=Math.min(a._readableState.highWaterMark,n);if(a.endOffset!=null&&(s=Math.min(s,a.endOffset-a.pos)),s<=0){a.destroyed=!0,a.push(null),a.context.unref();return}a.context.pend.go(function(v){if(a.destroyed)return v();var j=new Buffer(s);h.read(a.context.fd,j,0,s,a.pos,function(N,A){N?a.destroy(N):A===0?(a.destroyed=!0,a.push(null),a.context.unref()):(a.pos+=A,a.push(j.slice(0,A))),v()})})}},M.prototype.destroy=function(n){this.destroyed||(n=n||new Error("stream destroyed"),this.destroyed=!0,this.emit("error",n),this.context.unref())},x.inherits(R,d);function R(n,a){a=a||{},d.call(this,a),this.context=n,this.context.ref(),this.start=a.start||0,this.endOffset=a.end==null?1/0:+a.end,this.bytesWritten=0,this.pos=this.start,this.destroyed=!1,this.on("finish",this.destroy.bind(this))}c(R,"WriteStream"),R.prototype._write=function(n,a,s){var v=this;if(!v.destroyed){if(v.pos+n.length>v.endOffset){var j=new Error("maximum file length exceeded");j.code="ETOOBIG",v.destroy(),s(j);return}v.context.pend.go(function(N){if(v.destroyed)return N();h.write(v.context.fd,n,0,n.length,v.pos,function(A,k){A?(v.destroy(),N(),s(A)):(v.bytesWritten+=k,v.pos+=k,v.emit("progress"),N(),s())})})}},R.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.context.unref())},x.inherits(U,q);function U(n,a){q.call(this),a=a||{},this.refCount=0,this.buffer=n,this.maxChunkSize=a.maxChunkSize||Number.MAX_SAFE_INTEGER}c(U,"BufferSlicer"),U.prototype.read=function(n,a,s,v,j){var N=v+s,A=N-this.buffer.length,k=A>0?A:s;this.buffer.copy(n,a,v,N),setImmediate(function(){j(null,k)})},U.prototype.write=function(n,a,s,v,j){n.copy(this.buffer,v,a,a+s),setImmediate(function(){j(null,s,n)})},U.prototype.createReadStream=function(n){n=n||{};var a=new g(n);a.destroyed=!1,a.start=n.start||0,a.endOffset=n.end,a.pos=a.endOffset||this.buffer.length;for(var s=this.buffer.slice(a.start,a.pos),v=0;;){var j=v+this.maxChunkSize;if(j>=s.length){v<s.length&&a.write(s.slice(v,s.length));break}a.write(s.slice(v,j)),v=j}return a.end(),a.destroy=function(){a.destroyed=!0},a},U.prototype.createWriteStream=function(n){var a=this;n=n||{};var s=new d(n);return s.start=n.start||0,s.endOffset=n.end==null?this.buffer.length:+n.end,s.bytesWritten=0,s.pos=s.start,s.destroyed=!1,s._write=function(v,j,N){if(!s.destroyed){var A=s.pos+v.length;if(A>s.endOffset){var k=new Error("maximum file length exceeded");k.code="ETOOBIG",s.destroyed=!0,N(k);return}v.copy(a.buffer,s.pos,0,v.length),s.bytesWritten+=v.length,s.pos=A,s.emit("progress"),N()}},s.destroy=function(){s.destroyed=!0},s},U.prototype.ref=function(){this.refCount+=1},U.prototype.unref=function(){if(this.refCount-=1,this.refCount<0)throw new Error("invalid unref")};function u(n,a){return new U(n,a)}c(u,"createFromBuffer");function E(n,a){return new w(n,a)}return c(E,"createFromFd"),fdSlicer}c(requireFdSlicer,"requireFdSlicer");var hasRequiredYauzl;function requireYauzl(){if(hasRequiredYauzl)return yauzl;hasRequiredYauzl=1;var h=S,x=zlib,m=requireFdSlicer(),p=index$1.requireBufferCrc32(),d=require$$0$3,g=require$$0$2.EventEmitter,f=require$$0.Transform,q=require$$0.PassThrough,w=require$$0.Writable;yauzl.open=M,yauzl.fromFd=R,yauzl.fromBuffer=U,yauzl.fromRandomAccessReader=u,yauzl.dosDateTimeToDate=v,yauzl.validateFileName=j,yauzl.ZipFile=E,yauzl.Entry=s,yauzl.RandomAccessReader=k;function M(r,e,l){typeof e=="function"&&(l=e,e=null),e==null&&(e={}),e.autoClose==null&&(e.autoClose=!0),e.lazyEntries==null&&(e.lazyEntries=!1),e.decodeStrings==null&&(e.decodeStrings=!0),e.validateEntrySizes==null&&(e.validateEntrySizes=!0),e.strictFileNames==null&&(e.strictFileNames=!1),l==null&&(l=ce),h.open(r,"r",function(t,$){if(t)return l(t);R($,e,function(b,P){b&&h.close($,ce),l(b,P)})})}c(M,"open");function R(r,e,l){typeof e=="function"&&(l=e,e=null),e==null&&(e={}),e.autoClose==null&&(e.autoClose=!1),e.lazyEntries==null&&(e.lazyEntries=!1),e.decodeStrings==null&&(e.decodeStrings=!0),e.validateEntrySizes==null&&(e.validateEntrySizes=!0),e.strictFileNames==null&&(e.strictFileNames=!1),l==null&&(l=ce),h.fstat(r,function(t,$){if(t)return l(t);var b=m.createFromFd(r,{autoClose:!0});u(b,$.size,e,l)})}c(R,"fromFd");function U(r,e,l){typeof e=="function"&&(l=e,e=null),e==null&&(e={}),e.autoClose=!1,e.lazyEntries==null&&(e.lazyEntries=!1),e.decodeStrings==null&&(e.decodeStrings=!0),e.validateEntrySizes==null&&(e.validateEntrySizes=!0),e.strictFileNames==null&&(e.strictFileNames=!1);var t=m.createFromBuffer(r,{maxChunkSize:65536});u(t,r.length,e,l)}c(U,"fromBuffer");function u(r,e,l,t){typeof l=="function"&&(t=l,l=null),l==null&&(l={}),l.autoClose==null&&(l.autoClose=!0),l.lazyEntries==null&&(l.lazyEntries=!1),l.decodeStrings==null&&(l.decodeStrings=!0);var $=!!l.decodeStrings;if(l.validateEntrySizes==null&&(l.validateEntrySizes=!0),l.strictFileNames==null&&(l.strictFileNames=!1),t==null&&(t=ce),typeof e!="number")throw new Error("expected totalSize parameter to be a number");if(e>Number.MAX_SAFE_INTEGER)throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");r.ref();var b=22,P=65535,W=Math.min(b+P,e),D=ne(W),K=e-D.length;N(r,D,0,W,K,function(_){if(_)return t(_);for(var ee=W-b;ee>=0;ee-=1)if(D.readUInt32LE(ee)===101010256){var X=D.slice(ee),te=X.readUInt16LE(4);if(te!==0)return t(new Error("multi-disk zip files are not supported: found disk number: "+te));var ae=X.readUInt16LE(10),Z=X.readUInt32LE(16),H=X.readUInt16LE(20),J=X.length-b;if(H!==J)return t(new Error("invalid comment length. expected: "+J+". found: "+H));var Q=$?se(X,22,X.length,!1):X.slice(22);if(!(ae===65535||Z===4294967295))return t(null,new E(r,Z,e,ae,Q,l.autoClose,l.lazyEntries,$,l.validateEntrySizes,l.strictFileNames));var re=ne(20),le=K+ee-re.length;N(r,re,0,re.length,le,function(ue){if(ue)return t(ue);if(re.readUInt32LE(0)!==117853008)return t(new Error("invalid zip64 end of central directory locator signature"));var me=oe(re,8),fe=ne(56);N(r,fe,0,fe.length,me,function(de){return de?t(de):fe.readUInt32LE(0)!==101075792?t(new Error("invalid zip64 end of central directory record signature")):(ae=oe(fe,32),Z=oe(fe,48),t(null,new E(r,Z,e,ae,Q,l.autoClose,l.lazyEntries,$,l.validateEntrySizes,l.strictFileNames)))})});return}t(new Error("end of central directory record signature not found"))})}c(u,"fromRandomAccessReader"),d.inherits(E,g);function E(r,e,l,t,$,b,P,W,D,K){var _=this;g.call(_),_.reader=r,_.reader.on("error",function(ee){a(_,ee)}),_.reader.once("close",function(){_.emit("close")}),_.readEntryCursor=e,_.fileSize=l,_.entryCount=t,_.comment=$,_.entriesRead=0,_.autoClose=!!b,_.lazyEntries=!!P,_.decodeStrings=!!W,_.validateEntrySizes=!!D,_.strictFileNames=!!K,_.isOpen=!0,_.emittedError=!1,_.lazyEntries||_._readEntry()}c(E,"ZipFile"),E.prototype.close=function(){this.isOpen&&(this.isOpen=!1,this.reader.unref())};function n(r,e){r.autoClose&&r.close(),a(r,e)}c(n,"emitErrorAndAutoClose");function a(r,e){r.emittedError||(r.emittedError=!0,r.emit("error",e))}c(a,"emitError"),E.prototype.readEntry=function(){if(!this.lazyEntries)throw new Error("readEntry() called without lazyEntries:true");this._readEntry()},E.prototype._readEntry=function(){var r=this;if(r.entryCount===r.entriesRead){setImmediate(function(){r.autoClose&&r.close(),!r.emittedError&&r.emit("end")});return}if(!r.emittedError){var e=ne(46);N(r.reader,e,0,e.length,r.readEntryCursor,function(l){if(l)return n(r,l);if(!r.emittedError){var t=new s,$=e.readUInt32LE(0);if($!==33639248)return n(r,new Error("invalid central directory file header signature: 0x"+$.toString(16)));if(t.versionMadeBy=e.readUInt16LE(4),t.versionNeededToExtract=e.readUInt16LE(6),t.generalPurposeBitFlag=e.readUInt16LE(8),t.compressionMethod=e.readUInt16LE(10),t.lastModFileTime=e.readUInt16LE(12),t.lastModFileDate=e.readUInt16LE(14),t.crc32=e.readUInt32LE(16),t.compressedSize=e.readUInt32LE(20),t.uncompressedSize=e.readUInt32LE(24),t.fileNameLength=e.readUInt16LE(28),t.extraFieldLength=e.readUInt16LE(30),t.fileCommentLength=e.readUInt16LE(32),t.internalFileAttributes=e.readUInt16LE(36),t.externalFileAttributes=e.readUInt32LE(38),t.relativeOffsetOfLocalHeader=e.readUInt32LE(42),t.generalPurposeBitFlag&64)return n(r,new Error("strong encryption is not supported"));r.readEntryCursor+=46,e=ne(t.fileNameLength+t.extraFieldLength+t.fileCommentLength),N(r.reader,e,0,e.length,r.readEntryCursor,function(b){if(b)return n(r,b);if(!r.emittedError){var P=(t.generalPurposeBitFlag&2048)!==0;t.fileName=r.decodeStrings?se(e,0,t.fileNameLength,P):e.slice(0,t.fileNameLength);var W=t.fileNameLength+t.extraFieldLength,D=e.slice(t.fileNameLength,W);t.extraFields=[];for(var K=0;K<D.length-3;){var _=D.readUInt16LE(K+0),ee=D.readUInt16LE(K+2),X=K+4,te=X+ee;if(te>D.length)return n(r,new Error("extra field length exceeds extra field buffer size"));var ae=ne(ee);D.copy(ae,0,X,te),t.extraFields.push({id:_,data:ae}),K=te}if(t.fileComment=r.decodeStrings?se(e,W,W+t.fileCommentLength,P):e.slice(W,W+t.fileCommentLength),t.comment=t.fileComment,r.readEntryCursor+=e.length,r.entriesRead+=1,t.uncompressedSize===4294967295||t.compressedSize===4294967295||t.relativeOffsetOfLocalHeader===4294967295){for(var Z=null,K=0;K<t.extraFields.length;K++){var H=t.extraFields[K];if(H.id===1){Z=H.data;break}}if(Z==null)return n(r,new Error("expected zip64 extended information extra field"));var J=0;if(t.uncompressedSize===4294967295){if(J+8>Z.length)return n(r,new Error("zip64 extended information extra field does not include uncompressed size"));t.uncompressedSize=oe(Z,J),J+=8}if(t.compressedSize===4294967295){if(J+8>Z.length)return n(r,new Error("zip64 extended information extra field does not include compressed size"));t.compressedSize=oe(Z,J),J+=8}if(t.relativeOffsetOfLocalHeader===4294967295){if(J+8>Z.length)return n(r,new Error("zip64 extended information extra field does not include relative header offset"));t.relativeOffsetOfLocalHeader=oe(Z,J),J+=8}}if(r.decodeStrings)for(var K=0;K<t.extraFields.length;K++){var H=t.extraFields[K];if(H.id===28789){if(H.data.length<6||H.data.readUInt8(0)!==1)continue;var Q=H.data.readUInt32LE(1);if(p.unsigned(e.slice(0,t.fileNameLength))!==Q)continue;t.fileName=se(H.data,5,H.data.length,!0);break}}if(r.validateEntrySizes&&t.compressionMethod===0){var re=t.uncompressedSize;if(t.isEncrypted()&&(re+=12),t.compressedSize!==re){var le="compressed/uncompressed size mismatch for stored file: "+t.compressedSize+" != "+t.uncompressedSize;return n(r,new Error(le))}}if(r.decodeStrings){r.strictFileNames||(t.fileName=t.fileName.replace(/\\/g,"/"));var ue=j(t.fileName,r.validateFileNameOptions);if(ue!=null)return n(r,new Error(ue))}r.emit("entry",t),r.lazyEntries||r._readEntry()}})}})}},E.prototype.openReadStream=function(r,e,l){var t=this,$=0,b=r.compressedSize;if(l==null)l=e,e={};else{if(e.decrypt!=null){if(!r.isEncrypted())throw new Error("options.decrypt can only be specified for encrypted entries");if(e.decrypt!==!1)throw new Error("invalid options.decrypt value: "+e.decrypt);if(r.isCompressed()&&e.decompress!==!1)throw new Error("entry is encrypted and compressed, and options.decompress !== false")}if(e.decompress!=null){if(!r.isCompressed())throw new Error("options.decompress can only be specified for compressed entries");if(!(e.decompress===!1||e.decompress===!0))throw new Error("invalid options.decompress value: "+e.decompress)}if(e.start!=null||e.end!=null){if(r.isCompressed()&&e.decompress!==!1)throw new Error("start/end range not allowed for compressed entry without options.decompress === false");if(r.isEncrypted()&&e.decrypt!==!1)throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false")}if(e.start!=null){if($=e.start,$<0)throw new Error("options.start < 0");if($>r.compressedSize)throw new Error("options.start > entry.compressedSize")}if(e.end!=null){if(b=e.end,b<0)throw new Error("options.end < 0");if(b>r.compressedSize)throw new Error("options.end > entry.compressedSize");if(b<$)throw new Error("options.end < options.start")}}if(!t.isOpen)return l(new Error("closed"));if(r.isEncrypted()&&e.decrypt!==!1)return l(new Error("entry is encrypted, and options.decrypt !== false"));t.reader.ref();var P=ne(30);N(t.reader,P,0,P.length,r.relativeOffsetOfLocalHeader,function(W){try{if(W)return l(W);var D=P.readUInt32LE(0);if(D!==67324752)return l(new Error("invalid local file header signature: 0x"+D.toString(16)));var K=P.readUInt16LE(26),_=P.readUInt16LE(28),ee=r.relativeOffsetOfLocalHeader+P.length+K+_,X;if(r.compressionMethod===0)X=!1;else if(r.compressionMethod===8)X=e.decompress!=null?e.decompress:!0;else return l(new Error("unsupported compression method: "+r.compressionMethod));var te=ee,ae=te+r.compressedSize;if(r.compressedSize!==0&&ae>t.fileSize)return l(new Error("file data overflows file bounds: "+te+" + "+r.compressedSize+" > "+t.fileSize));var Z=t.reader.createReadStream({start:te+$,end:te+b}),H=Z;if(X){var J=!1,Q=x.createInflateRaw();Z.on("error",function(re){setImmediate(function(){J||Q.emit("error",re)})}),Z.pipe(Q),t.validateEntrySizes?(H=new A(r.uncompressedSize),Q.on("error",function(re){setImmediate(function(){J||H.emit("error",re)})}),Q.pipe(H)):H=Q,H.destroy=function(){J=!0,Q!==H&&Q.unpipe(H),Z.unpipe(Q),Z.destroy()}}l(null,H)}finally{t.reader.unref()}})};function s(){}c(s,"Entry"),s.prototype.getLastModDate=function(){return v(this.lastModFileDate,this.lastModFileTime)},s.prototype.isEncrypted=function(){return(this.generalPurposeBitFlag&1)!==0},s.prototype.isCompressed=function(){return this.compressionMethod===8};function v(r,e){var l=r&31,t=(r>>5&15)-1,$=(r>>9&127)+1980,b=0,P=(e&31)*2,W=e>>5&63,D=e>>11&31;return new Date($,t,l,D,W,P,b)}c(v,"dosDateTimeToDate");function j(r){return r.indexOf("\\")!==-1?"invalid characters in fileName: "+r:/^[a-zA-Z]:/.test(r)||/^\//.test(r)?"absolute path: "+r:r.split("/").indexOf("..")!==-1?"invalid relative path: "+r:null}c(j,"validateFileName");function N(r,e,l,t,$,b){if(t===0)return setImmediate(function(){b(null,ne(0))});r.read(e,l,t,$,function(P,W){if(P)return b(P);if(W<t)return b(new Error("unexpected EOF"));b()})}c(N,"readAndAssertNoEof"),d.inherits(A,f);function A(r){f.call(this),this.actualByteCount=0,this.expectedByteCount=r}c(A,"AssertByteCountStream"),A.prototype._transform=function(r,e,l){if(this.actualByteCount+=r.length,this.actualByteCount>this.expectedByteCount){var t="too many bytes in the stream. expected "+this.expectedByteCount+". got at least "+this.actualByteCount;return l(new Error(t))}l(null,r)},A.prototype._flush=function(r){if(this.actualByteCount<this.expectedByteCount){var e="not enough bytes in the stream. expected "+this.expectedByteCount+". got only "+this.actualByteCount;return r(new Error(e))}r()},d.inherits(k,g);function k(){g.call(this),this.refCount=0}c(k,"RandomAccessReader"),k.prototype.ref=function(){this.refCount+=1},k.prototype.unref=function(){var r=this;if(r.refCount-=1,r.refCount>0)return;if(r.refCount<0)throw new Error("invalid unref");r.close(e);function e(l){if(l)return r.emit("error",l);r.emit("close")}c(e,"onCloseDone")},k.prototype.createReadStream=function(r){var e=r.start,l=r.end;if(e===l){var t=new q;return setImmediate(function(){t.end()}),t}var $=this._readStreamForRange(e,l),b=!1,P=new V(this);$.on("error",function(D){setImmediate(function(){b||P.emit("error",D)})}),P.destroy=function(){$.unpipe(P),P.unref(),$.destroy()};var W=new A(l-e);return P.on("error",function(D){setImmediate(function(){b||W.emit("error",D)})}),W.destroy=function(){b=!0,P.unpipe(W),P.destroy()},$.pipe(P).pipe(W)},k.prototype._readStreamForRange=function(r,e){throw new Error("not implemented")},k.prototype.read=function(r,e,l,t,$){var b=this.createReadStream({start:t,end:t+l}),P=new w,W=0;P._write=function(D,K,_){D.copy(r,e+W,0,D.length),W+=D.length,_()},P.on("finish",$),b.on("error",function(D){$(D)}),b.pipe(P)},k.prototype.close=function(r){setImmediate(r)},d.inherits(V,q);function V(r){q.call(this),this.context=r,this.context.ref(),this.unreffedYet=!1}c(V,"RefUnrefFilter"),V.prototype._flush=function(r){this.unref(),r()},V.prototype.unref=function(r){this.unreffedYet||(this.unreffedYet=!0,this.context.unref())};var ie="\0\u263A\u263B\u2665\u2666\u2663\u2660\u2022\u25D8\u25CB\u25D9\u2642\u2640\u266A\u266B\u263C\u25BA\u25C4\u2195\u203C\xB6\xA7\u25AC\u21A8\u2191\u2193\u2192\u2190\u221F\u2194\u25B2\u25BC !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";function se(r,e,l,t){if(t)return r.toString("utf8",e,l);for(var $="",b=e;b<l;b++)$+=ie[r[b]];return $}c(se,"decodeBuffer");function oe(r,e){var l=r.readUInt32LE(e),t=r.readUInt32LE(e+4);return t*4294967296+l}c(oe,"readUInt64LE");var ne;typeof Buffer.allocUnsafe=="function"?ne=c(function(r){return Buffer.allocUnsafe(r)},"newBuffer"):ne=c(function(r){return new Buffer(r)},"newBuffer");function ce(r){if(r)throw r}return c(ce,"defaultCallback"),yauzl}c(requireYauzl,"requireYauzl");var extractZip,hasRequiredExtractZip;function requireExtractZip(){if(hasRequiredExtractZip)return extractZip;hasRequiredExtractZip=1;const h=index.requireSrc()("extract-zip"),{createWriteStream:x,promises:m}=S,p=requireGetStream(),d=sysPath,{promisify:g}=require$$0$3,f=require$$0,q=requireYauzl(),w=g(q.open),M=g(f.pipeline);class R{static{c(this,"Extractor")}constructor(u,E){this.zipPath=u,this.opts=E}async extract(){return h("opening",this.zipPath,"with opts",this.opts),this.zipfile=await w(this.zipPath,{lazyEntries:!0}),this.canceled=!1,new Promise((u,E)=>{this.zipfile.on("error",n=>{this.canceled=!0,E(n)}),this.zipfile.readEntry(),this.zipfile.on("close",()=>{this.canceled||(h("zip extraction complete"),u())}),this.zipfile.on("entry",async n=>{if(this.canceled){h("skipping entry",n.fileName,{cancelled:this.canceled});return}if(h("zipfile entry",n.fileName),n.fileName.startsWith("__MACOSX/")){this.zipfile.readEntry();return}const a=d.dirname(d.join(this.opts.dir,n.fileName));try{await m.mkdir(a,{recursive:!0});const s=await m.realpath(a);if(d.relative(this.opts.dir,s).split(d.sep).includes(".."))throw new Error(`Out of bound path "${s}" found while processing file ${n.fileName}`);await this.extractEntry(n),h("finished processing",n.fileName),this.zipfile.readEntry()}catch(s){this.canceled=!0,this.zipfile.close(),E(s)}})})}async extractEntry(u){if(this.canceled){h("skipping entry extraction",u.fileName,{cancelled:this.canceled});return}this.opts.onEntry&&this.opts.onEntry(u,this.zipfile);const E=d.join(this.opts.dir,u.fileName),n=u.externalFileAttributes>>16&65535,a=61440,s=16384,j=(n&a)===40960;let N=(n&a)===s;!N&&u.fileName.endsWith("/")&&(N=!0);const A=u.versionMadeBy>>8;N||(N=A===0&&u.externalFileAttributes===16),h("extracting entry",{filename:u.fileName,isDir:N,isSymlink:j});const k=this.getExtractedMode(n,N)&511,V=N?E:d.dirname(E),ie={recursive:!0};if(N&&(ie.mode=k),h("mkdir",{dir:V,...ie}),await m.mkdir(V,ie),N)return;h("opening read stream",E);const se=await g(this.zipfile.openReadStream.bind(this.zipfile))(u);if(j){const oe=await p(se);h("creating symlink",oe,E),await m.symlink(oe,E)}else await M(se,x(E,{mode:k}))}getExtractedMode(u,E){let n=u;return n===0&&(E?(this.opts.defaultDirMode&&(n=parseInt(this.opts.defaultDirMode,10)),n||(n=493)):(this.opts.defaultFileMode&&(n=parseInt(this.opts.defaultFileMode,10)),n||(n=420))),n}}return extractZip=c(async function(U,u){if(h("creating target directory",u.dir),!d.isAbsolute(u.dir))throw new Error("Target directory is expected to be absolute");return await m.mkdir(u.dir,{recursive:!0}),u.dir=await m.realpath(u.dir),new R(U,u).extract()},"extractZip"),extractZip}c(requireExtractZip,"requireExtractZip");var extractZipExports=requireExtractZip(),L=index.getDefaultExportFromCjs(extractZipExports),O=Object.defineProperty,y=c((h,x)=>O(h,"name",{value:x,configurable:!0}),"y");index$1.D.config();const C=y(h=>h.trim().toLowerCase().replace(/\s+/g,"-"),"normalizeProjectName"),T={default:{echo:"",openai:"",anthropic:"",googleai:"",groq:"",togetherai:"",xai:"",deepseek:"",tavily:"",scrapfly:""}},Y=y(()=>{const h={openai:process.env.OPENAI_API_KEY?"$env(OPENAI_API_KEY)":void 0,anthropic:process.env.ANTHROPIC_API_KEY?"$env(ANTHROPIC_API_KEY)":void 0,googleai:process.env.GOOGLE_API_KEY?"$env(GOOGLE_API_KEY)":process.env.GEMINI_API_KEY?"$env(GEMINI_API_KEY)":void 0};return Object.entries(h).reduce((x,[m,p])=>(p&&(x[m]=p),x),{})},"detectApiKeys");function z(h=require$$0$4.homedir()){const x=sysPath.join(h,".smyth");S.existsSync(x)||S.mkdirSync(x,{recursive:!0});const m=sysPath.join(x,".sre");S.existsSync(m)||S.mkdirSync(m,{recursive:!0});const p=sysPath.join(x,"storage");S.existsSync(p)||S.mkdirSync(p,{recursive:!0});const d=sysPath.join(m,"vault.json"),g=S.existsSync(d);return{smythDir:x,sreDir:m,storageDir:p,vaultFile:g?d:null}}c(z,"z");y(z,"prepareSmythDirectory");function I(h,x){S.existsSync(x)||S.mkdirSync(x,{recursive:!0}),S.readdirSync(h).forEach(m=>{const p=sysPath.join(h,m),d=sysPath.join(x,m);S.statSync(p).isDirectory()?I(p,d):S.copyFileSync(p,d)})}c(I,"I");y(I,"copyDirectoryRecursiveSync");class F extends index.libExports.Command{static{c(this,"F")}static{y(this,"CreateCmd")}static description="Create a new SmythOS project";static examples=["<%= config.bin %> <%= command.id %>",'<%= config.bin %> <%= command.id %> "My Awesome Project"'];static flags={help:index.libExports.Flags.help({char:"h"})};static args={projectName:index.libExports.Args.string({name:"projectName",description:"Name of the new SmythOS project",required:!1})};async run(){const{args:x}=await this.parse(F);await B(x.projectName)}}async function B(h){console.log(banner([],["","","","","","","","","","",index.chalk.white("\u{1F680} Welcome to the SRE Project Builder! \u2728"),index.chalk.white("\u{1F9D1}\u200D\u{1F4BB} Let's build something amazing together...")])),console.log(index.chalk.yellowBright("===[ Let's configure your project ]==="));const{smythDir:x,sreDir:m,storageDir:p,vaultFile:d}=z(),g=Y(),f=Object.keys(g).length>0;Object.keys(g).map(s=>index.chalk.cyan(s)).join(", ");const q=S.existsSync(d)?JSON.parse(S.readFileSync(d,"utf8")):null,w=await index$2.inquirer.prompt([{type:"input",name:"projectName",message:"Project name",validate:y(s=>s.trim().length>0?!0:"Project name cannot be empty.","validate"),when:!h}]),M=h||w.projectName;let R=await index$2.inquirer.prompt([{type:"input",name:"targetFolder",message:"Project folder",default:sysPath.join(process.cwd(),C(M)),suffix:`
${index.chalk.magenta("If it does not exist it will be created.")}
`},{type:"list",name:"templateType",message:"Project template",suffix:`
${index.chalk.magenta("Choose the project template. (Use arrow keys \u2191\u2193)")}
`,choices:[{name:"Empty Project",value:"sdk-empty"},{name:"Minimal : Just the basics to get started",value:"code-agent-minimal"},{name:"Interactive : Chat with one agent",value:"code-agent-book-assistant"},{name:"Interactive chat with agent selection",value:"interactive-chat-agent-select"}]}]);R.projectName=M,console.log(index.chalk.yellowBright(`
===[ Now let's configure Smyth Resources folder ]===`)),console.log(`${index.chalk.gray(`Some connectors in SmythOS might need to store data locally, in order to keep things clean, we store all SmythOS related data in a single place.
`)}`);const U=await index$2.inquirer.prompt([{type:"list",name:"smythResources",message:"Smyth Resources Folder",suffix:`
${index.chalk.magenta("Location where we can store data like logs, cache, etc. (Use arrow keys \u2191\u2193)")}
`,choices:[{name:`Shared folder in the ${index.chalk.underline("user home directory")} (~/.smyth)`,value:sysPath.join(require$$0$4.homedir(),".smyth")},{name:`Local folder under ${index.chalk.underline("project root")} (./${sysPath.basename(R.targetFolder)}/.smyth)`,value:sysPath.join(R.targetFolder,".smyth")}],default:0}]);let u=U.smythResources===sysPath.join(require$$0$4.homedir(),".smyth"),E={};if(console.log(index.chalk.yellowBright(`
===[ Now let's set your secrets ]===`)),console.log(`${index.chalk.gray(`SmythOS uses a vault to store your secrets. Set your secrets once, they\u2019ll be securely stored and loaded by the SDK only when needed.This keeps LLM API keys out of your code.
`)}`),u&&d){console.log(index.chalk.magenta(`  \u2139  We will use Vault file found in your shared folder ${d}`));const s=Object.keys(q?.default).filter(v=>q?.default[v]);s.length>0&&console.log(index.chalk.magenta(`  \u2139  API keys already present in your shared vault: ${s.join(", ")}`)),E={openai:"#",anthropic:"#",googleai:"#",groq:"#",togetherai:"#",xai:"#",deepseek:"#",tavily:"#",scrapfly:"#",...q?.default||{}}}const n=["openai","anthropic","googleai"].filter(s=>!E[s]||E[s]==="#").map(s=>f&&g[s]?{type:"confirm",name:s,message:`We detected that ${s} API Key is present in your environment variables. Do you want to use the environment variable in your project's vault?`,default:!0}:{type:"input",name:s,message:`Enter your ${s.charAt(0).toUpperCase()+s.slice(1)} API Key (Enter value, or press Enter to skip)
`});if(n.length>0){const s=await index$2.inquirer.prompt(n);for(const[v,j]of Object.entries(s))j&&(E[v]=j===!0?g[v]:j)}R={...R,...U};const a={projectName:R.projectName,targetFolder:R.targetFolder,projectType:R.projectType,templateType:R.templateType,smythResources:R.smythResources,vault:E,useSharedVault:u};try{if(!G(a)){console.log(index.chalk.red("\u{1F6A8} Error creating project."));return}console.log(`
\u{1F389} Project created successfully! \u{1F38A}
`);const s=a.useSharedVault?sysPath.join(require$$0$4.homedir(),".smyth",".sre","vault.json"):sysPath.join(a.smythResources,".sre","vault.json");console.log(index.chalk.magentaBright(`
\u{1F510} Your vault file is located at: ${index.chalk.cyan(s)}
You can edit it later if you want to add more keys.`)),console.log(`

\u{1F680} Next steps :`),console.log(`
${index.chalk.green("cd")} ${index.chalk.underline(a.targetFolder)}`),console.log(`${index.chalk.green("npm install")}`),console.log(`${index.chalk.green("npm run build")}`),console.log(`${index.chalk.green("npm start")}

`)}catch(s){console.error(index.chalk.red("\u{1F6A8} Error creating project:"),s)}}c(B,"B");y(B,"RunProject");async function G(h){let x=!1,m="";try{console.log("Creating project...");const p="https://github.com/SmythOS/sre-project-templates",d=h.templateType;if(m=h.targetFolder,S.existsSync(m)&&S.readdirSync(m).length>0)return console.log(index.chalk.red("Project folder already exists and is not empty.")),!1;S.existsSync(m)||S.mkdirSync(m,{recursive:!0}),x=!0;const g=sysPath.basename(m);try{const E=`git clone --depth 1 --branch ${d} ${p} ${m}`;require$$0$5.execSync(E,{stdio:"pipe"})}catch{console.log(index.chalk.yellow("git clone failed, using alternative method."));const E=`${p}/archive/refs/heads/${d}.zip`,n=sysPath.join(require$$0$4.tmpdir(),`${d}.zip`);try{const a=await fetch(E);if(!a.ok)throw new Error(`Failed to download zip: ${a.statusText}`);const s=await a.arrayBuffer(),v=Buffer.from(s);S.writeFileSync(n,v),await L(n,{dir:require$$0$4.tmpdir()});const j=sysPath.join(require$$0$4.tmpdir(),`sre-project-templates-${d}`);I(j,m),S.unlinkSync(n),S.rmSync(j,{recursive:!0,force:!0})}catch(a){return console.error(index.chalk.red("Error downloading or extracting project zip:"),a),x&&m&&S.rmSync(m,{recursive:!0,force:!0}),!1}}const f=sysPath.join(h.smythResources,".sre");S.existsSync(f)||S.mkdirSync(f,{recursive:!0});const q=sysPath.join(h.smythResources,".sre","vault.json");if(S.existsSync(q)){const E=sysPath.join(h.smythResources,".sre","vault.json.backup");S.copyFileSync(q,E)}const w={default:{...T.default,...h.vault}};S.writeFileSync(q,JSON.stringify(w,null,2));const M=sysPath.join(m,"package.json"),R=JSON.parse(S.readFileSync(M,"utf8"));R.name=g,S.writeFileSync(M,JSON.stringify(R,null,2));const U=sysPath.join(m,".env");S.writeFileSync(U,`LOG_LEVEL=""
LOG_FILTER=""
`);const u=sysPath.join(m,".git");return S.existsSync(u)&&S.rmSync(u,{recursive:!0}),!0}catch(p){return console.error(index.chalk.red("An unexpected error occurred:"),p),x&&m&&S.rmSync(m,{recursive:!0,force:!0}),!1}}c(G,"G");y(G,"createProject");module.exports=F;
