@capgo/cli 7.84.3 → 7.84.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
3
  "type": "module",
4
- "version": "7.84.3",
4
+ "version": "7.84.5",
5
5
  "description": "A CLI to upload to capgo servers",
6
6
  "author": "Martin martin@capgo.app",
7
7
  "license": "Apache 2.0",
package/dist/src/sdk.js CHANGED
@@ -127,7 +127,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
127
127
  `)}),$.__defineSetter__("stack",function(X){return[X].concat($.stack).join(`
128
128
 
129
129
  `)}),$}});var Fx=T((gyD,Qx)=>{var c6=i("constants"),tYD=process.cwd,GY=null,sYD=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!GY)GY=tYD.call(process);return GY};try{process.cwd()}catch(D){}if(typeof process.chdir==="function"){if(UY=process.chdir,process.chdir=function(D){GY=null,UY.call(process,D)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,UY)}var UY;Qx.exports=eYD;function eYD(D){if(c6.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./))$(D);if(!D.lutimes)X(D);if(D.chown=Q(D.chown),D.fchown=Q(D.fchown),D.lchown=Q(D.lchown),D.chmod=Y(D.chmod),D.fchmod=Y(D.fchmod),D.lchmod=Y(D.lchmod),D.chownSync=F(D.chownSync),D.fchownSync=F(D.fchownSync),D.lchownSync=F(D.lchownSync),D.chmodSync=J(D.chmodSync),D.fchmodSync=J(D.fchmodSync),D.lchmodSync=J(D.lchmodSync),D.stat=Z(D.stat),D.fstat=Z(D.fstat),D.lstat=Z(D.lstat),D.statSync=w(D.statSync),D.fstatSync=w(D.fstatSync),D.lstatSync=w(D.lstatSync),D.chmod&&!D.lchmod)D.lchmod=function(U,O,z){if(z)process.nextTick(z)},D.lchmodSync=function(){};if(D.chown&&!D.lchown)D.lchown=function(U,O,z,q){if(q)process.nextTick(q)},D.lchownSync=function(){};if(sYD==="win32")D.rename=typeof D.rename!=="function"?D.rename:function(U){function O(z,q,B){var W=Date.now(),L=0;U(z,q,function M(I){if(I&&(I.code==="EACCES"||I.code==="EPERM"||I.code==="EBUSY")&&Date.now()-W<60000){if(setTimeout(function(){D.stat(q,function(K,N){if(K&&K.code==="ENOENT")U(z,q,M);else B(I)})},L),L<100)L+=10;return}if(B)B(I)})}if(Object.setPrototypeOf)Object.setPrototypeOf(O,U);return O}(D.rename);D.read=typeof D.read!=="function"?D.read:function(U){function O(z,q,B,W,L,M){var I;if(M&&typeof M==="function"){var K=0;I=function(N,V,R){if(N&&N.code==="EAGAIN"&&K<10)return K++,U.call(D,z,q,B,W,L,I);M.apply(this,arguments)}}return U.call(D,z,q,B,W,L,I)}if(Object.setPrototypeOf)Object.setPrototypeOf(O,U);return O}(D.read),D.readSync=typeof D.readSync!=="function"?D.readSync:function(U){return function(O,z,q,B,W){var L=0;while(!0)try{return U.call(D,O,z,q,B,W)}catch(M){if(M.code==="EAGAIN"&&L<10){L++;continue}throw M}}}(D.readSync);function $(U){U.lchmod=function(O,z,q){U.open(O,c6.O_WRONLY|c6.O_SYMLINK,z,function(B,W){if(B){if(q)q(B);return}U.fchmod(W,z,function(L){U.close(W,function(M){if(q)q(L||M)})})})},U.lchmodSync=function(O,z){var q=U.openSync(O,c6.O_WRONLY|c6.O_SYMLINK,z),B=!0,W;try{W=U.fchmodSync(q,z),B=!1}finally{if(B)try{U.closeSync(q)}catch(L){}else U.closeSync(q)}return W}}function X(U){if(c6.hasOwnProperty("O_SYMLINK")&&U.futimes)U.lutimes=function(O,z,q,B){U.open(O,c6.O_SYMLINK,function(W,L){if(W){if(B)B(W);return}U.futimes(L,z,q,function(M){U.close(L,function(I){if(B)B(M||I)})})})},U.lutimesSync=function(O,z,q){var B=U.openSync(O,c6.O_SYMLINK),W,L=!0;try{W=U.futimesSync(B,z,q),L=!1}finally{if(L)try{U.closeSync(B)}catch(M){}else U.closeSync(B)}return W};else if(U.futimes)U.lutimes=function(O,z,q,B){if(B)process.nextTick(B)},U.lutimesSync=function(){}}function Y(U){if(!U)return U;return function(O,z,q){return U.call(D,O,z,function(B){if(G(B))B=null;if(q)q.apply(this,arguments)})}}function J(U){if(!U)return U;return function(O,z){try{return U.call(D,O,z)}catch(q){if(!G(q))throw q}}}function Q(U){if(!U)return U;return function(O,z,q,B){return U.call(D,O,z,q,function(W){if(G(W))W=null;if(B)B.apply(this,arguments)})}}function F(U){if(!U)return U;return function(O,z,q){try{return U.call(D,O,z,q)}catch(B){if(!G(B))throw B}}}function Z(U){if(!U)return U;return function(O,z,q){if(typeof z==="function")q=z,z=null;function B(W,L){if(L){if(L.uid<0)L.uid+=4294967296;if(L.gid<0)L.gid+=4294967296}if(q)q.apply(this,arguments)}return z?U.call(D,O,z,B):U.call(D,O,B)}}function w(U){if(!U)return U;return function(O,z){var q=z?U.call(D,O,z):U.call(D,O);if(q){if(q.uid<0)q.uid+=4294967296;if(q.gid<0)q.gid+=4294967296}return q}}function G(U){if(!U)return!0;if(U.code==="ENOSYS")return!0;var O=!process.getuid||process.getuid()!==0;if(O){if(U.code==="EINVAL"||U.code==="EPERM")return!0}return!1}}});var Gx=T((myD,wx)=>{var Zx=i("stream").Stream;wx.exports=DQD;function DQD(D){return{ReadStream:$,WriteStream:X};function $(Y,J){if(!(this instanceof $))return new $(Y,J);Zx.call(this);var Q=this;this.path=Y,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,J=J||{};var F=Object.keys(J);for(var Z=0,w=F.length;Z<w;Z++){var G=F[Z];this[G]=J[G]}if(this.encoding)this.setEncoding(this.encoding);if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!=="number")throw TypeError("end must be a Number");if(this.start>this.end)throw Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){Q._read()});return}D.open(this.path,this.flags,this.mode,function(U,O){if(U){Q.emit("error",U),Q.readable=!1;return}Q.fd=O,Q.emit("open",O),Q._read()})}function X(Y,J){if(!(this instanceof X))return new X(Y,J);Zx.call(this),this.path=Y,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,J=J||{};var Q=Object.keys(J);for(var F=0,Z=Q.length;F<Z;F++){var w=Q[F];this[w]=J[w]}if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.start<0)throw Error("start must be >= zero");this.pos=this.start}if(this.busy=!1,this._queue=[],this.fd===null)this._open=D.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush()}}});var Ox=T((cyD,Ux)=>{Ux.exports=XQD;var $QD=Object.getPrototypeOf||function(D){return D.__proto__};function XQD(D){if(D===null||typeof D!=="object")return D;if(D instanceof Object)var $={__proto__:$QD(D)};else var $=Object.create(null);return Object.getOwnPropertyNames(D).forEach(function(X){Object.defineProperty($,X,Object.getOwnPropertyDescriptor(D,X))}),$}});var S0=T((dyD,WO)=>{var M0=i("fs"),JQD=Fx(),YQD=Gx(),QQD=Ox(),OY=i("util"),o0,zY;if(typeof Symbol==="function"&&typeof Symbol.for==="function")o0=Symbol.for("graceful-fs.queue"),zY=Symbol.for("graceful-fs.previous");else o0="___graceful-fs.queue",zY="___graceful-fs.previous";function FQD(){}function zx(D,$){Object.defineProperty(D,o0,{get:function(){return $}})}var D8=FQD;if(OY.debuglog)D8=OY.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))D8=function(){var D=OY.format.apply(OY,arguments);D="GFS4: "+D.split(/\n/).join(`
130
- GFS4: `),console.error(D)};if(!M0[o0]){if(qO=global[o0]||[],zx(M0,qO),M0.close=function(D){function $(X,Y){return D.call(M0,X,function(J){if(!J)qx();if(typeof Y==="function")Y.apply(this,arguments)})}return Object.defineProperty($,zY,{value:D}),$}(M0.close),M0.closeSync=function(D){function $(X){D.apply(M0,arguments),qx()}return Object.defineProperty($,zY,{value:D}),$}(M0.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){D8(M0[o0]),i("assert").equal(M0[o0].length,0)})}var qO;if(!global[o0])zx(global,M0[o0]);WO.exports=zO(QQD(M0));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!M0.__patched)WO.exports=zO(M0),M0.__patched=!0;function zO(D){JQD(D),D.gracefulify=zO,D.createReadStream=V,D.createWriteStream=R;var $=D.readFile;D.readFile=X;function X(_,v,S){if(typeof v==="function")S=v,v=null;return h(_,v,S);function h(b,l,f,j){return $(b,l,function(P){if(P&&(P.code==="EMFILE"||P.code==="ENFILE"))u9([h,[b,l,f],P,j||Date.now(),Date.now()]);else if(typeof f==="function")f.apply(this,arguments)})}}var Y=D.writeFile;D.writeFile=J;function J(_,v,S,h){if(typeof S==="function")h=S,S=null;return b(_,v,S,h);function b(l,f,j,P,u){return Y(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([b,[l,f,j,P],y,u||Date.now(),Date.now()]);else if(typeof P==="function")P.apply(this,arguments)})}}var Q=D.appendFile;if(Q)D.appendFile=F;function F(_,v,S,h){if(typeof S==="function")h=S,S=null;return b(_,v,S,h);function b(l,f,j,P,u){return Q(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([b,[l,f,j,P],y,u||Date.now(),Date.now()]);else if(typeof P==="function")P.apply(this,arguments)})}}var Z=D.copyFile;if(Z)D.copyFile=w;function w(_,v,S,h){if(typeof S==="function")h=S,S=0;return b(_,v,S,h);function b(l,f,j,P,u){return Z(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([b,[l,f,j,P],y,u||Date.now(),Date.now()]);else if(typeof P==="function")P.apply(this,arguments)})}}var G=D.readdir;D.readdir=O;var U=/^v[0-5]\./;function O(_,v,S){if(typeof v==="function")S=v,v=null;var h=U.test(process.version)?function(f,j,P,u){return G(f,b(f,j,P,u))}:function(f,j,P,u){return G(f,j,b(f,j,P,u))};return h(_,v,S);function b(l,f,j,P){return function(u,y){if(u&&(u.code==="EMFILE"||u.code==="ENFILE"))u9([h,[l,f,j],u,P||Date.now(),Date.now()]);else{if(y&&y.sort)y.sort();if(typeof j==="function")j.call(this,u,y)}}}}if(process.version.substr(0,4)==="v0.8"){var z=YQD(D);M=z.ReadStream,K=z.WriteStream}var q=D.ReadStream;if(q)M.prototype=Object.create(q.prototype),M.prototype.open=I;var B=D.WriteStream;if(B)K.prototype=Object.create(B.prototype),K.prototype.open=N;Object.defineProperty(D,"ReadStream",{get:function(){return M},set:function(_){M=_},enumerable:!0,configurable:!0}),Object.defineProperty(D,"WriteStream",{get:function(){return K},set:function(_){K=_},enumerable:!0,configurable:!0});var W=M;Object.defineProperty(D,"FileReadStream",{get:function(){return W},set:function(_){W=_},enumerable:!0,configurable:!0});var L=K;Object.defineProperty(D,"FileWriteStream",{get:function(){return L},set:function(_){L=_},enumerable:!0,configurable:!0});function M(_,v){if(this instanceof M)return q.apply(this,arguments),this;else return M.apply(Object.create(M.prototype),arguments)}function I(){var _=this;A(_.path,_.flags,_.mode,function(v,S){if(v){if(_.autoClose)_.destroy();_.emit("error",v)}else _.fd=S,_.emit("open",S),_.read()})}function K(_,v){if(this instanceof K)return B.apply(this,arguments),this;else return K.apply(Object.create(K.prototype),arguments)}function N(){var _=this;A(_.path,_.flags,_.mode,function(v,S){if(v)_.destroy(),_.emit("error",v);else _.fd=S,_.emit("open",S)})}function V(_,v){return new D.ReadStream(_,v)}function R(_,v){return new D.WriteStream(_,v)}var x=D.open;D.open=A;function A(_,v,S,h){if(typeof S==="function")h=S,S=null;return b(_,v,S,h);function b(l,f,j,P,u){return x(l,f,j,function(y,c){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([b,[l,f,j,P],y,u||Date.now(),Date.now()]);else if(typeof P==="function")P.apply(this,arguments)})}}return D}function u9(D){D8("ENQUEUE",D[0].name,D[1]),M0[o0].push(D),BO()}var qY;function qx(){var D=Date.now();for(var $=0;$<M0[o0].length;++$)if(M0[o0][$].length>2)M0[o0][$][3]=D,M0[o0][$][4]=D;BO()}function BO(){if(clearTimeout(qY),qY=void 0,M0[o0].length===0)return;var D=M0[o0].shift(),$=D[0],X=D[1],Y=D[2],J=D[3],Q=D[4];if(J===void 0)D8("RETRY",$.name,X),$.apply(null,X);else if(Date.now()-J>=60000){D8("TIMEOUT",$.name,X);var F=X.pop();if(typeof F==="function")F.call(null,Y)}else{var Z=Date.now()-Q,w=Math.max(Q-J,1),G=Math.min(w*1.2,100);if(Z>=G)D8("RETRY",$.name,X),$.apply(null,X.concat([J]));else M0[o0].push(D)}if(qY===void 0)qY=setTimeout(BO,0)}});var Wx=T((lyD,Bx)=>{function e1(D,$){if(typeof $==="boolean")$={forever:$};if(this._originalTimeouts=JSON.parse(JSON.stringify(D)),this._timeouts=D,this._options=$||{},this._maxRetryTime=$&&$.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Bx.exports=e1;e1.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};e1.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};e1.prototype.retry=function(D){if(this._timeout)clearTimeout(this._timeout);if(!D)return!1;var $=new Date().getTime();if(D&&$-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(D);var X=this._timeouts.shift();if(X===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),X=this._timeouts.shift();else return!1;var Y=this,J=setTimeout(function(){if(Y._attempts++,Y._operationTimeoutCb){if(Y._timeout=setTimeout(function(){Y._operationTimeoutCb(Y._attempts)},Y._operationTimeout),Y._options.unref)Y._timeout.unref()}Y._fn(Y._attempts)},X);if(this._options.unref)J.unref();return!0};e1.prototype.attempt=function(D,$){if(this._fn=D,$){if($.timeout)this._operationTimeout=$.timeout;if($.cb)this._operationTimeoutCb=$.cb}var X=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){X._operationTimeoutCb()},X._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};e1.prototype.try=function(D){console.log("Using RetryOperation.try() is deprecated"),this.attempt(D)};e1.prototype.start=function(D){console.log("Using RetryOperation.start() is deprecated"),this.attempt(D)};e1.prototype.start=e1.prototype.try;e1.prototype.errors=function(){return this._errors};e1.prototype.attempts=function(){return this._attempts};e1.prototype.mainError=function(){if(this._errors.length===0)return null;var D={},$=null,X=0;for(var Y=0;Y<this._errors.length;Y++){var J=this._errors[Y],Q=J.message,F=(D[Q]||0)+1;if(D[Q]=F,F>=X)$=J,X=F}return $}});var Hx=T((wQD)=>{var ZQD=Wx();wQD.operation=function(D){var $=wQD.timeouts(D);return new ZQD($,{forever:D&&D.forever,unref:D&&D.unref,maxRetryTime:D&&D.maxRetryTime})};wQD.timeouts=function(D){if(D instanceof Array)return[].concat(D);var $={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var X in D)$[X]=D[X];if($.minTimeout>$.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var Y=[];for(var J=0;J<$.retries;J++)Y.push(this.createTimeout(J,$));if(D&&D.forever&&!Y.length)Y.push(this.createTimeout(J,$));return Y.sort(function(Q,F){return Q-F}),Y};wQD.createTimeout=function(D,$){var X=$.randomize?Math.random()+1:1,Y=Math.round(X*$.minTimeout*Math.pow($.factor,D));return Y=Math.min(Y,$.maxTimeout),Y};wQD.wrap=function(D,$,X){if($ instanceof Array)X=$,$=null;if(!X){X=[];for(var Y in D)if(typeof D[Y]==="function")X.push(Y)}for(var J=0;J<X.length;J++){var Q=X[J],F=D[Q];D[Q]=function(w){var G=wQD.operation($),U=Array.prototype.slice.call(arguments,1),O=U.pop();U.push(function(z){if(G.retry(z))return;if(z)arguments[0]=G.mainError();O.apply(this,arguments)}),G.attempt(function(){w.apply(D,U)})}.bind(D,F),D[Q].options=$}}});var Vx=T((iyD,BY)=>{BY.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")BY.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")BY.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var HY=T((pyD,_9)=>{var W0=global.process,$8=function(D){return D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function"};if(!$8(W0))_9.exports=function(){return function(){}};else{if(KO=i("assert"),X8=Vx(),HO=/^win/i.test(W0.platform),v9=i("events"),typeof v9!=="function")v9=v9.EventEmitter;if(W0.__signal_exit_emitter__)g0=W0.__signal_exit_emitter__;else g0=W0.__signal_exit_emitter__=new v9,g0.count=0,g0.emitted={};if(!g0.infinite)g0.setMaxListeners(1/0),g0.infinite=!0;_9.exports=function(D,$){if(!$8(global.process))return function(){};if(KO.equal(typeof D,"function","a callback must be provided for exit handler"),J8===!1)WY();var X="exit";if($&&$.alwaysLast)X="afterexit";var Y=function(){if(g0.removeListener(X,D),g0.listeners("exit").length===0&&g0.listeners("afterexit").length===0)w3()};return g0.on(X,D),Y},w3=function(){if(!J8||!$8(global.process))return;J8=!1,X8.forEach(function($){try{W0.removeListener($,G3[$])}catch(X){}}),W0.emit=U3,W0.reallyExit=KY,g0.count-=1},_9.exports.unload=w3,d6=function($,X,Y){if(g0.emitted[$])return;g0.emitted[$]=!0,g0.emit($,X,Y)},G3={},X8.forEach(function(D){G3[D]=function(){if(!$8(global.process))return;var X=W0.listeners(D);if(X.length===g0.count){if(w3(),d6("exit",null,D),d6("afterexit",null,D),HO&&D==="SIGHUP")D="SIGINT";W0.kill(W0.pid,D)}}}),_9.exports.signals=function(){return X8},J8=!1,WY=function(){if(J8||!$8(global.process))return;J8=!0,g0.count+=1,X8=X8.filter(function($){try{return W0.on($,G3[$]),!0}catch(X){return!1}}),W0.emit=NO,W0.reallyExit=VO},_9.exports.load=WY,KY=W0.reallyExit,VO=function($){if(!$8(global.process))return;W0.exitCode=$||0,d6("exit",W0.exitCode,null),d6("afterexit",W0.exitCode,null),KY.call(W0,W0.exitCode)},U3=W0.emit,NO=function($,X){if($==="exit"&&$8(global.process)){if(X!==void 0)W0.exitCode=X;var Y=U3.apply(this,arguments);return d6("exit",W0.exitCode,null),d6("afterexit",W0.exitCode,null),Y}else return U3.apply(this,arguments)}}var KO,X8,HO,v9,g0,w3,d6,G3,J8,WY,KY,VO,U3,NO});var Lx=T((BQD,LO)=>{var Nx=Symbol();function qQD(D,$,X){let Y=$[Nx];if(Y)return $.stat(D,(Q,F)=>{if(Q)return X(Q);X(null,F.mtime,Y)});let J=new Date(Math.ceil(Date.now()/1000)*1000+5);$.utimes(D,J,J,(Q)=>{if(Q)return X(Q);$.stat(D,(F,Z)=>{if(F)return X(F);let w=Z.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty($,Nx,{value:w}),X(null,Z.mtime,w)})})}function zQD(D){let $=Date.now();if(D==="s")$=Math.ceil($/1000)*1000;return new Date($)}BQD.probe=qQD;BQD.getMtime=zQD});var jx=T((AQD,q3)=>{var HQD=i("path"),AO=S0(),VQD=Hx(),NQD=HY(),Mx=Lx(),Z6={};function O3(D,$){return $.lockfilePath||`${D}.lock`}function RO(D,$,X){if(!$.realpath)return X(null,HQD.resolve(D));$.fs.realpath(D,X)}function IO(D,$,X){let Y=O3(D,$);$.fs.mkdir(Y,(J)=>{if(!J)return Mx.probe(Y,$.fs,(Q,F,Z)=>{if(Q)return $.fs.rmdir(Y,()=>{}),X(Q);X(null,F,Z)});if(J.code!=="EEXIST")return X(J);if($.stale<=0)return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));$.fs.stat(Y,(Q,F)=>{if(Q){if(Q.code==="ENOENT")return IO(D,{...$,stale:0},X);return X(Q)}if(!Ix(F,$))return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));Ax(D,$,(Z)=>{if(Z)return X(Z);IO(D,{...$,stale:0},X)})})})}function Ix(D,$){return D.mtime.getTime()<Date.now()-$.stale}function Ax(D,$,X){$.fs.rmdir(O3(D,$),(Y)=>{if(Y&&Y.code!=="ENOENT")return X(Y);X()})}function VY(D,$){let X=Z6[D];if(X.updateTimeout)return;if(X.updateDelay=X.updateDelay||$.update,X.updateTimeout=setTimeout(()=>{X.updateTimeout=null,$.fs.stat(X.lockfilePath,(Y,J)=>{let Q=X.lastUpdate+$.stale<Date.now();if(Y){if(Y.code==="ENOENT"||Q)return MO(D,X,Object.assign(Y,{code:"ECOMPROMISED"}));return X.updateDelay=1000,VY(D,$)}if(X.mtime.getTime()!==J.mtime.getTime())return MO(D,X,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let Z=Mx.getMtime(X.mtimePrecision);$.fs.utimes(X.lockfilePath,Z,Z,(w)=>{let G=X.lastUpdate+$.stale<Date.now();if(X.released)return;if(w){if(w.code==="ENOENT"||G)return MO(D,X,Object.assign(w,{code:"ECOMPROMISED"}));return X.updateDelay=1000,VY(D,$)}X.mtime=Z,X.lastUpdate=Date.now(),X.updateDelay=null,VY(D,$)})})},X.updateDelay),X.updateTimeout.unref)X.updateTimeout.unref()}function MO(D,$,X){if($.released=!0,$.updateTimeout)clearTimeout($.updateTimeout);if(Z6[D]===$)delete Z6[D];$.options.onCompromised(X)}function LQD(D,$,X){$={stale:1e4,update:null,realpath:!0,retries:0,fs:AO,onCompromised:(Y)=>{throw Y},...$},$.retries=$.retries||0,$.retries=typeof $.retries==="number"?{retries:$.retries}:$.retries,$.stale=Math.max($.stale||0,2000),$.update=$.update==null?$.stale/2:$.update||0,$.update=Math.max(Math.min($.update,$.stale/2),1000),RO(D,$,(Y,J)=>{if(Y)return X(Y);let Q=VQD.operation($.retries);Q.attempt(()=>{IO(J,$,(F,Z,w)=>{if(Q.retry(F))return;if(F)return X(Q.mainError());let G=Z6[J]={lockfilePath:O3(J,$),mtime:Z,mtimePrecision:w,options:$,lastUpdate:Date.now()};VY(J,$),X(null,(U)=>{if(G.released)return U&&U(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));Rx(J,{...$,realpath:!1},U)})})})})}function Rx(D,$,X){$={fs:AO,realpath:!0,...$},RO(D,$,(Y,J)=>{if(Y)return X(Y);let Q=Z6[J];if(!Q)return X(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));Q.updateTimeout&&clearTimeout(Q.updateTimeout),Q.released=!0,delete Z6[J],Ax(J,$,X)})}function MQD(D,$,X){$={stale:1e4,realpath:!0,fs:AO,...$},$.stale=Math.max($.stale||0,2000),RO(D,$,(Y,J)=>{if(Y)return X(Y);$.fs.stat(O3(J,$),(Q,F)=>{if(Q)return Q.code==="ENOENT"?X(null,!1):X(Q);return X(null,!Ix(F,$))})})}function IQD(){return Z6}NQD(()=>{for(let D in Z6){let $=Z6[D].options;try{$.fs.rmdirSync(O3(D,$))}catch(X){}}});AQD.lock=LQD;AQD.unlock=Rx;AQD.check=MQD;AQD.getLocks=IQD});var Tx=T((ryD,Ex)=>{var CQD=S0();function PQD(D){let $=["mkdir","realpath","stat","rmdir","utimes"],X={...D};return $.forEach((Y)=>{X[Y]=(...J)=>{let Q=J.pop(),F;try{F=D[`${Y}Sync`](...J)}catch(Z){return Q(Z)}Q(null,F)}}),X}function xQD(D){return(...$)=>new Promise((X,Y)=>{$.push((J,Q)=>{if(J)Y(J);else X(Q)}),D(...$)})}function SQD(D){return(...$)=>{let X,Y;if($.push((J,Q)=>{X=J,Y=Q}),D(...$),X)throw X;return Y}}function uQD(D){if(D={...D},D.fs=PQD(D.fs||CQD),typeof D.retries==="number"&&D.retries>0||D.retries&&typeof D.retries.retries==="number"&&D.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return D}Ex.exports={toPromise:xQD,toSync:SQD,toSyncOptions:uQD}});var Px=T((oyD,l6)=>{var k9=jx(),{toPromise:NY,toSync:LY,toSyncOptions:jO}=Tx();async function Cx(D,$){let X=await NY(k9.lock)(D,$);return NY(X)}function vQD(D,$){let X=LY(k9.lock)(D,jO($));return LY(X)}function _QD(D,$){return NY(k9.unlock)(D,$)}function kQD(D,$){return LY(k9.unlock)(D,jO($))}function fQD(D,$){return NY(k9.check)(D,$)}function yQD(D,$){return LY(k9.check)(D,jO($))}l6.exports=Cx;l6.exports.lock=Cx;l6.exports.unlock=_QD;l6.exports.lockSync=vQD;l6.exports.unlockSync=kQD;l6.exports.check=fQD;l6.exports.checkSync=yQD});var fx=T((_x)=>{Object.defineProperty(_x,"__esModule",{value:!0});_x.canStoreURLs=_x.FileUrlStorage=void 0;var xx=i("fs"),bQD=gQD(Yx()),Sx=hQD(Px());function vx(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(vx=function(Y){return Y?X:$})(D)}function hQD(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=vx($);if(X&&X.has(D))return X.get(D);var Y={__proto__:null},J=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var F=J?Object.getOwnPropertyDescriptor(D,Q):null;F&&(F.get||F.set)?Object.defineProperty(Y,Q,F):Y[Q]=D[Q]}return Y.default=D,X&&X.set(D,Y),Y}function gQD(D){return D&&D.__esModule?D:{default:D}}function z3(D){return z3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},z3(D)}function mQD(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function ux(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,dQD(Y.key),Y)}}function cQD(D,$,X){if($)ux(D.prototype,$);if(X)ux(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function dQD(D){var $=lQD(D,"string");return z3($)=="symbol"?$:$+""}function lQD(D,$){if(z3(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(z3(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var ayD=_x.canStoreURLs=!0,tyD=_x.FileUrlStorage=function(){function D($){mQD(this,D),this.path=$}return cQD(D,[{key:"findAllUploads",value:function(){var X=this;return new Promise(function(Y,J){X._getItems("tus::",function(Q,F){if(Q)J(Q);else Y(F)})})}},{key:"findUploadsByFingerprint",value:function(X){var Y=this;return new Promise(function(J,Q){Y._getItems("tus::".concat(X),function(F,Z){if(F)Q(F);else J(Z)})})}},{key:"removeUpload",value:function(X){var Y=this;return new Promise(function(J,Q){Y._removeItem(X,function(F){if(F)Q(F);else J()})})}},{key:"addUpload",value:function(X,Y){var J=this,Q=Math.round(Math.random()*1000000000000),F="tus::".concat(X,"::").concat(Q);return new Promise(function(Z,w){J._setItem(F,Y,function(G){if(G)w(G);else Z(F)})})}},{key:"_setItem",value:function(X,Y,J){var Q=this;Sx.lock(this.path,this._lockfileOptions()).then(function(F){J=Q._releaseAndCb(F,J),Q._getData(function(Z,w){if(Z){J(Z);return}w[X]=Y,Q._writeData(w,function(G){return J(G)})})}).catch(J)}},{key:"_getItems",value:function(X,Y){this._getData(function(J,Q){if(J){Y(J);return}var F=Object.keys(Q).filter(function(Z){return Z.startsWith(X)}).map(function(Z){var w=Q[Z];return w.urlStorageKey=Z,w});Y(null,F)})}},{key:"_removeItem",value:function(X,Y){var J=this;Sx.lock(this.path,this._lockfileOptions()).then(function(Q){Y=J._releaseAndCb(Q,Y),J._getData(function(F,Z){if(F){Y(F);return}delete Z[X],J._writeData(Z,function(w){return Y(w)})})}).catch(Y)}},{key:"_lockfileOptions",value:function(){return{realpath:!1,retries:{retries:5,minTimeout:20}}}},{key:"_releaseAndCb",value:function(X,Y){return function(J){if(J){X().then(function(){return Y(J)}).catch(function(Q){return Y((0,bQD.default)([J,Q]))});return}X().then(Y).catch(Y)}}},{key:"_writeData",value:function(X,Y){var J={encoding:"utf8",mode:432,flag:"w"};(0,xx.writeFile)(this.path,JSON.stringify(X),J,function(Q){return Y(Q)})}},{key:"_getData",value:function(X){(0,xx.readFile)(this.path,"utf8",function(Y,J){if(Y){if(Y.code==="ENOENT")X(null,{});else X(Y);return}try{J=!J.trim().length?{}:JSON.parse(J)}catch(Q){X(Q);return}X(null,J)})}}])}()});var IY=T((n6)=>{Object.defineProperty(n6,"__esModule",{value:!0});Object.defineProperty(n6,"DefaultHttpStack",{enumerable:!0,get:function(){return gx.default}});Object.defineProperty(n6,"DetailedError",{enumerable:!0,get:function(){return iQD.default}});Object.defineProperty(n6,"FileUrlStorage",{enumerable:!0,get:function(){return mx.FileUrlStorage}});Object.defineProperty(n6,"StreamSource",{enumerable:!0,get:function(){return tQD.default}});n6.Upload=void 0;Object.defineProperty(n6,"canStoreURLs",{enumerable:!0,get:function(){return mx.canStoreURLs}});n6.defaultOptions=void 0;Object.defineProperty(n6,"enableDebugLog",{enumerable:!0,get:function(){return pQD.enableDebugLog}});n6.isSupported=void 0;var iQD=Y8(jU()),pQD=EU(),rQD=Y8(PT()),EO=Y8(wC()),oQD=Y8(CC()),aQD=Y8(vC()),gx=Y8(oC()),tQD=Y8(yU()),mx=fx();function Y8(D){return D&&D.__esModule?D:{default:D}}function y9(D){return y9=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},y9(D)}function sQD(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function yx(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,dx(Y.key),Y)}}function eQD(D,$,X){if($)yx(D.prototype,$);if(X)yx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function DFD(D,$,X){return $=MY($),$FD(D,cx()?Reflect.construct($,X||[],MY(D).constructor):$.apply(D,X))}function $FD(D,$){if($&&(y9($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return XFD(D)}function XFD(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function cx(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(cx=function(){return!!D})()}function MY(D){return MY=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},MY(D)}function JFD(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)TO(D,$)}function TO(D,$){return TO=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,J){return Y.__proto__=J,Y},TO(D,$)}function bx(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function f9(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?bx(Object(X),!0).forEach(function(Y){YFD(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):bx(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function YFD(D,$,X){if($=dx($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function dx(D){var $=QFD(D,"string");return y9($)=="symbol"?$:$+""}function QFD(D,$){if(y9(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(y9(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var hx=n6.defaultOptions=f9(f9({},EO.default.defaultOptions),{},{httpStack:new gx.default,fileReader:new oQD.default,urlStorage:new rQD.default,fingerprint:aQD.default}),eyD=n6.Upload=function(D){function $(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return sQD(this,$),Y=f9(f9({},hx),Y),DFD(this,$,[X,Y])}return JFD($,D),eQD($,null,[{key:"terminate",value:function(Y){var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return J=f9(f9({},hx),J),EO.default.terminate(Y,J)}}])}(EO.default),DbD=n6.isSupported=!0});var H$;var B3=o(()=>{H$={name:"@capgo/cli",type:"module",version:"7.84.3",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/CLI#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/CLI.git"},bugs:{url:"https://github.com/Cap-go/CLI/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"npx --yes supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsc --noEmit",lint:'eslint "src/**/*.ts" --fix',"check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:mcp":"node test/test-mcp.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs","test:payload-split":"bun test/test-payload-split.mjs",test:"bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:credentials && bun run test:credentials-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:esm-sdk && bun run test:mcp && bun run test:version-detection && bun run test:platform-paths && bun run test:payload-split"},devDependencies:{"@antfu/eslint-config":"^7.0.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.4","@capacitor/cli":"^8.0.0","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.0.0","@modelcontextprotocol/sdk":"^1.25.3","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.79.0","@types/adm-zip":"^0.5.7","@types/node":"^25.0.0","@types/prettyjson":"^0.0.33","@types/tmp":"^0.2.6","@vercel/ncc":"^0.38.4","adm-zip":"^0.5.16","ci-info":"^4.3.1",commander:"^14.0.2",eslint:"^9.38.0","git-format-staged":"4.0.1",husky:"^9.1.7","is-wsl":"^3.1.0",micromatch:"^4.0.8",open:"^11.0.0",prettyjson:"^1.2.5",tmp:"^0.2.5","tus-js-client":"^4.3.1",typescript:"^5.9.3",partysocket:"^1.1.11",ws:"^8.18.3",zod:"^4.3.6"}}});async function AY(D){try{let X=`https://registry.npmjs.org/${encodeURIComponent(D.toLowerCase())}`,Y=await fetch(X,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});if(!Y.ok)return null;return(await Y.json())["dist-tags"]?.latest||null}catch{return null}}async function Z0(){let D=await AY("@capgo/cli")??"",$=D?.split(".")[0];if(D!==H$.version)H.warning(`\uD83D\uDEA8 You are using @capgo/cli@${H$.version} it's not the latest version.
130
+ GFS4: `),console.error(D)};if(!M0[o0]){if(qO=global[o0]||[],zx(M0,qO),M0.close=function(D){function $(X,Y){return D.call(M0,X,function(J){if(!J)qx();if(typeof Y==="function")Y.apply(this,arguments)})}return Object.defineProperty($,zY,{value:D}),$}(M0.close),M0.closeSync=function(D){function $(X){D.apply(M0,arguments),qx()}return Object.defineProperty($,zY,{value:D}),$}(M0.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){D8(M0[o0]),i("assert").equal(M0[o0].length,0)})}var qO;if(!global[o0])zx(global,M0[o0]);WO.exports=zO(QQD(M0));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!M0.__patched)WO.exports=zO(M0),M0.__patched=!0;function zO(D){JQD(D),D.gracefulify=zO,D.createReadStream=V,D.createWriteStream=R;var $=D.readFile;D.readFile=X;function X(_,v,S){if(typeof v==="function")S=v,v=null;return h(_,v,S);function h(b,l,f,j){return $(b,l,function(P){if(P&&(P.code==="EMFILE"||P.code==="ENFILE"))u9([h,[b,l,f],P,j||Date.now(),Date.now()]);else if(typeof f==="function")f.apply(this,arguments)})}}var Y=D.writeFile;D.writeFile=J;function J(_,v,S,h){if(typeof S==="function")h=S,S=null;return b(_,v,S,h);function b(l,f,j,P,u){return Y(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([b,[l,f,j,P],y,u||Date.now(),Date.now()]);else if(typeof P==="function")P.apply(this,arguments)})}}var Q=D.appendFile;if(Q)D.appendFile=F;function F(_,v,S,h){if(typeof S==="function")h=S,S=null;return b(_,v,S,h);function b(l,f,j,P,u){return Q(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([b,[l,f,j,P],y,u||Date.now(),Date.now()]);else if(typeof P==="function")P.apply(this,arguments)})}}var Z=D.copyFile;if(Z)D.copyFile=w;function w(_,v,S,h){if(typeof S==="function")h=S,S=0;return b(_,v,S,h);function b(l,f,j,P,u){return Z(l,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([b,[l,f,j,P],y,u||Date.now(),Date.now()]);else if(typeof P==="function")P.apply(this,arguments)})}}var G=D.readdir;D.readdir=O;var U=/^v[0-5]\./;function O(_,v,S){if(typeof v==="function")S=v,v=null;var h=U.test(process.version)?function(f,j,P,u){return G(f,b(f,j,P,u))}:function(f,j,P,u){return G(f,j,b(f,j,P,u))};return h(_,v,S);function b(l,f,j,P){return function(u,y){if(u&&(u.code==="EMFILE"||u.code==="ENFILE"))u9([h,[l,f,j],u,P||Date.now(),Date.now()]);else{if(y&&y.sort)y.sort();if(typeof j==="function")j.call(this,u,y)}}}}if(process.version.substr(0,4)==="v0.8"){var z=YQD(D);M=z.ReadStream,K=z.WriteStream}var q=D.ReadStream;if(q)M.prototype=Object.create(q.prototype),M.prototype.open=I;var B=D.WriteStream;if(B)K.prototype=Object.create(B.prototype),K.prototype.open=N;Object.defineProperty(D,"ReadStream",{get:function(){return M},set:function(_){M=_},enumerable:!0,configurable:!0}),Object.defineProperty(D,"WriteStream",{get:function(){return K},set:function(_){K=_},enumerable:!0,configurable:!0});var W=M;Object.defineProperty(D,"FileReadStream",{get:function(){return W},set:function(_){W=_},enumerable:!0,configurable:!0});var L=K;Object.defineProperty(D,"FileWriteStream",{get:function(){return L},set:function(_){L=_},enumerable:!0,configurable:!0});function M(_,v){if(this instanceof M)return q.apply(this,arguments),this;else return M.apply(Object.create(M.prototype),arguments)}function I(){var _=this;A(_.path,_.flags,_.mode,function(v,S){if(v){if(_.autoClose)_.destroy();_.emit("error",v)}else _.fd=S,_.emit("open",S),_.read()})}function K(_,v){if(this instanceof K)return B.apply(this,arguments),this;else return K.apply(Object.create(K.prototype),arguments)}function N(){var _=this;A(_.path,_.flags,_.mode,function(v,S){if(v)_.destroy(),_.emit("error",v);else _.fd=S,_.emit("open",S)})}function V(_,v){return new D.ReadStream(_,v)}function R(_,v){return new D.WriteStream(_,v)}var x=D.open;D.open=A;function A(_,v,S,h){if(typeof S==="function")h=S,S=null;return b(_,v,S,h);function b(l,f,j,P,u){return x(l,f,j,function(y,c){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))u9([b,[l,f,j,P],y,u||Date.now(),Date.now()]);else if(typeof P==="function")P.apply(this,arguments)})}}return D}function u9(D){D8("ENQUEUE",D[0].name,D[1]),M0[o0].push(D),BO()}var qY;function qx(){var D=Date.now();for(var $=0;$<M0[o0].length;++$)if(M0[o0][$].length>2)M0[o0][$][3]=D,M0[o0][$][4]=D;BO()}function BO(){if(clearTimeout(qY),qY=void 0,M0[o0].length===0)return;var D=M0[o0].shift(),$=D[0],X=D[1],Y=D[2],J=D[3],Q=D[4];if(J===void 0)D8("RETRY",$.name,X),$.apply(null,X);else if(Date.now()-J>=60000){D8("TIMEOUT",$.name,X);var F=X.pop();if(typeof F==="function")F.call(null,Y)}else{var Z=Date.now()-Q,w=Math.max(Q-J,1),G=Math.min(w*1.2,100);if(Z>=G)D8("RETRY",$.name,X),$.apply(null,X.concat([J]));else M0[o0].push(D)}if(qY===void 0)qY=setTimeout(BO,0)}});var Wx=T((lyD,Bx)=>{function e1(D,$){if(typeof $==="boolean")$={forever:$};if(this._originalTimeouts=JSON.parse(JSON.stringify(D)),this._timeouts=D,this._options=$||{},this._maxRetryTime=$&&$.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Bx.exports=e1;e1.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};e1.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};e1.prototype.retry=function(D){if(this._timeout)clearTimeout(this._timeout);if(!D)return!1;var $=new Date().getTime();if(D&&$-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(D);var X=this._timeouts.shift();if(X===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),X=this._timeouts.shift();else return!1;var Y=this,J=setTimeout(function(){if(Y._attempts++,Y._operationTimeoutCb){if(Y._timeout=setTimeout(function(){Y._operationTimeoutCb(Y._attempts)},Y._operationTimeout),Y._options.unref)Y._timeout.unref()}Y._fn(Y._attempts)},X);if(this._options.unref)J.unref();return!0};e1.prototype.attempt=function(D,$){if(this._fn=D,$){if($.timeout)this._operationTimeout=$.timeout;if($.cb)this._operationTimeoutCb=$.cb}var X=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){X._operationTimeoutCb()},X._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};e1.prototype.try=function(D){console.log("Using RetryOperation.try() is deprecated"),this.attempt(D)};e1.prototype.start=function(D){console.log("Using RetryOperation.start() is deprecated"),this.attempt(D)};e1.prototype.start=e1.prototype.try;e1.prototype.errors=function(){return this._errors};e1.prototype.attempts=function(){return this._attempts};e1.prototype.mainError=function(){if(this._errors.length===0)return null;var D={},$=null,X=0;for(var Y=0;Y<this._errors.length;Y++){var J=this._errors[Y],Q=J.message,F=(D[Q]||0)+1;if(D[Q]=F,F>=X)$=J,X=F}return $}});var Hx=T((wQD)=>{var ZQD=Wx();wQD.operation=function(D){var $=wQD.timeouts(D);return new ZQD($,{forever:D&&D.forever,unref:D&&D.unref,maxRetryTime:D&&D.maxRetryTime})};wQD.timeouts=function(D){if(D instanceof Array)return[].concat(D);var $={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var X in D)$[X]=D[X];if($.minTimeout>$.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var Y=[];for(var J=0;J<$.retries;J++)Y.push(this.createTimeout(J,$));if(D&&D.forever&&!Y.length)Y.push(this.createTimeout(J,$));return Y.sort(function(Q,F){return Q-F}),Y};wQD.createTimeout=function(D,$){var X=$.randomize?Math.random()+1:1,Y=Math.round(X*$.minTimeout*Math.pow($.factor,D));return Y=Math.min(Y,$.maxTimeout),Y};wQD.wrap=function(D,$,X){if($ instanceof Array)X=$,$=null;if(!X){X=[];for(var Y in D)if(typeof D[Y]==="function")X.push(Y)}for(var J=0;J<X.length;J++){var Q=X[J],F=D[Q];D[Q]=function(w){var G=wQD.operation($),U=Array.prototype.slice.call(arguments,1),O=U.pop();U.push(function(z){if(G.retry(z))return;if(z)arguments[0]=G.mainError();O.apply(this,arguments)}),G.attempt(function(){w.apply(D,U)})}.bind(D,F),D[Q].options=$}}});var Vx=T((iyD,BY)=>{BY.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")BY.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")BY.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var HY=T((pyD,_9)=>{var W0=global.process,$8=function(D){return D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function"};if(!$8(W0))_9.exports=function(){return function(){}};else{if(KO=i("assert"),X8=Vx(),HO=/^win/i.test(W0.platform),v9=i("events"),typeof v9!=="function")v9=v9.EventEmitter;if(W0.__signal_exit_emitter__)g0=W0.__signal_exit_emitter__;else g0=W0.__signal_exit_emitter__=new v9,g0.count=0,g0.emitted={};if(!g0.infinite)g0.setMaxListeners(1/0),g0.infinite=!0;_9.exports=function(D,$){if(!$8(global.process))return function(){};if(KO.equal(typeof D,"function","a callback must be provided for exit handler"),J8===!1)WY();var X="exit";if($&&$.alwaysLast)X="afterexit";var Y=function(){if(g0.removeListener(X,D),g0.listeners("exit").length===0&&g0.listeners("afterexit").length===0)w3()};return g0.on(X,D),Y},w3=function(){if(!J8||!$8(global.process))return;J8=!1,X8.forEach(function($){try{W0.removeListener($,G3[$])}catch(X){}}),W0.emit=U3,W0.reallyExit=KY,g0.count-=1},_9.exports.unload=w3,d6=function($,X,Y){if(g0.emitted[$])return;g0.emitted[$]=!0,g0.emit($,X,Y)},G3={},X8.forEach(function(D){G3[D]=function(){if(!$8(global.process))return;var X=W0.listeners(D);if(X.length===g0.count){if(w3(),d6("exit",null,D),d6("afterexit",null,D),HO&&D==="SIGHUP")D="SIGINT";W0.kill(W0.pid,D)}}}),_9.exports.signals=function(){return X8},J8=!1,WY=function(){if(J8||!$8(global.process))return;J8=!0,g0.count+=1,X8=X8.filter(function($){try{return W0.on($,G3[$]),!0}catch(X){return!1}}),W0.emit=NO,W0.reallyExit=VO},_9.exports.load=WY,KY=W0.reallyExit,VO=function($){if(!$8(global.process))return;W0.exitCode=$||0,d6("exit",W0.exitCode,null),d6("afterexit",W0.exitCode,null),KY.call(W0,W0.exitCode)},U3=W0.emit,NO=function($,X){if($==="exit"&&$8(global.process)){if(X!==void 0)W0.exitCode=X;var Y=U3.apply(this,arguments);return d6("exit",W0.exitCode,null),d6("afterexit",W0.exitCode,null),Y}else return U3.apply(this,arguments)}}var KO,X8,HO,v9,g0,w3,d6,G3,J8,WY,KY,VO,U3,NO});var Lx=T((BQD,LO)=>{var Nx=Symbol();function qQD(D,$,X){let Y=$[Nx];if(Y)return $.stat(D,(Q,F)=>{if(Q)return X(Q);X(null,F.mtime,Y)});let J=new Date(Math.ceil(Date.now()/1000)*1000+5);$.utimes(D,J,J,(Q)=>{if(Q)return X(Q);$.stat(D,(F,Z)=>{if(F)return X(F);let w=Z.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty($,Nx,{value:w}),X(null,Z.mtime,w)})})}function zQD(D){let $=Date.now();if(D==="s")$=Math.ceil($/1000)*1000;return new Date($)}BQD.probe=qQD;BQD.getMtime=zQD});var jx=T((AQD,q3)=>{var HQD=i("path"),AO=S0(),VQD=Hx(),NQD=HY(),Mx=Lx(),Z6={};function O3(D,$){return $.lockfilePath||`${D}.lock`}function RO(D,$,X){if(!$.realpath)return X(null,HQD.resolve(D));$.fs.realpath(D,X)}function IO(D,$,X){let Y=O3(D,$);$.fs.mkdir(Y,(J)=>{if(!J)return Mx.probe(Y,$.fs,(Q,F,Z)=>{if(Q)return $.fs.rmdir(Y,()=>{}),X(Q);X(null,F,Z)});if(J.code!=="EEXIST")return X(J);if($.stale<=0)return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));$.fs.stat(Y,(Q,F)=>{if(Q){if(Q.code==="ENOENT")return IO(D,{...$,stale:0},X);return X(Q)}if(!Ix(F,$))return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));Ax(D,$,(Z)=>{if(Z)return X(Z);IO(D,{...$,stale:0},X)})})})}function Ix(D,$){return D.mtime.getTime()<Date.now()-$.stale}function Ax(D,$,X){$.fs.rmdir(O3(D,$),(Y)=>{if(Y&&Y.code!=="ENOENT")return X(Y);X()})}function VY(D,$){let X=Z6[D];if(X.updateTimeout)return;if(X.updateDelay=X.updateDelay||$.update,X.updateTimeout=setTimeout(()=>{X.updateTimeout=null,$.fs.stat(X.lockfilePath,(Y,J)=>{let Q=X.lastUpdate+$.stale<Date.now();if(Y){if(Y.code==="ENOENT"||Q)return MO(D,X,Object.assign(Y,{code:"ECOMPROMISED"}));return X.updateDelay=1000,VY(D,$)}if(X.mtime.getTime()!==J.mtime.getTime())return MO(D,X,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let Z=Mx.getMtime(X.mtimePrecision);$.fs.utimes(X.lockfilePath,Z,Z,(w)=>{let G=X.lastUpdate+$.stale<Date.now();if(X.released)return;if(w){if(w.code==="ENOENT"||G)return MO(D,X,Object.assign(w,{code:"ECOMPROMISED"}));return X.updateDelay=1000,VY(D,$)}X.mtime=Z,X.lastUpdate=Date.now(),X.updateDelay=null,VY(D,$)})})},X.updateDelay),X.updateTimeout.unref)X.updateTimeout.unref()}function MO(D,$,X){if($.released=!0,$.updateTimeout)clearTimeout($.updateTimeout);if(Z6[D]===$)delete Z6[D];$.options.onCompromised(X)}function LQD(D,$,X){$={stale:1e4,update:null,realpath:!0,retries:0,fs:AO,onCompromised:(Y)=>{throw Y},...$},$.retries=$.retries||0,$.retries=typeof $.retries==="number"?{retries:$.retries}:$.retries,$.stale=Math.max($.stale||0,2000),$.update=$.update==null?$.stale/2:$.update||0,$.update=Math.max(Math.min($.update,$.stale/2),1000),RO(D,$,(Y,J)=>{if(Y)return X(Y);let Q=VQD.operation($.retries);Q.attempt(()=>{IO(J,$,(F,Z,w)=>{if(Q.retry(F))return;if(F)return X(Q.mainError());let G=Z6[J]={lockfilePath:O3(J,$),mtime:Z,mtimePrecision:w,options:$,lastUpdate:Date.now()};VY(J,$),X(null,(U)=>{if(G.released)return U&&U(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));Rx(J,{...$,realpath:!1},U)})})})})}function Rx(D,$,X){$={fs:AO,realpath:!0,...$},RO(D,$,(Y,J)=>{if(Y)return X(Y);let Q=Z6[J];if(!Q)return X(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));Q.updateTimeout&&clearTimeout(Q.updateTimeout),Q.released=!0,delete Z6[J],Ax(J,$,X)})}function MQD(D,$,X){$={stale:1e4,realpath:!0,fs:AO,...$},$.stale=Math.max($.stale||0,2000),RO(D,$,(Y,J)=>{if(Y)return X(Y);$.fs.stat(O3(J,$),(Q,F)=>{if(Q)return Q.code==="ENOENT"?X(null,!1):X(Q);return X(null,!Ix(F,$))})})}function IQD(){return Z6}NQD(()=>{for(let D in Z6){let $=Z6[D].options;try{$.fs.rmdirSync(O3(D,$))}catch(X){}}});AQD.lock=LQD;AQD.unlock=Rx;AQD.check=MQD;AQD.getLocks=IQD});var Tx=T((ryD,Ex)=>{var CQD=S0();function PQD(D){let $=["mkdir","realpath","stat","rmdir","utimes"],X={...D};return $.forEach((Y)=>{X[Y]=(...J)=>{let Q=J.pop(),F;try{F=D[`${Y}Sync`](...J)}catch(Z){return Q(Z)}Q(null,F)}}),X}function xQD(D){return(...$)=>new Promise((X,Y)=>{$.push((J,Q)=>{if(J)Y(J);else X(Q)}),D(...$)})}function SQD(D){return(...$)=>{let X,Y;if($.push((J,Q)=>{X=J,Y=Q}),D(...$),X)throw X;return Y}}function uQD(D){if(D={...D},D.fs=PQD(D.fs||CQD),typeof D.retries==="number"&&D.retries>0||D.retries&&typeof D.retries.retries==="number"&&D.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return D}Ex.exports={toPromise:xQD,toSync:SQD,toSyncOptions:uQD}});var Px=T((oyD,l6)=>{var k9=jx(),{toPromise:NY,toSync:LY,toSyncOptions:jO}=Tx();async function Cx(D,$){let X=await NY(k9.lock)(D,$);return NY(X)}function vQD(D,$){let X=LY(k9.lock)(D,jO($));return LY(X)}function _QD(D,$){return NY(k9.unlock)(D,$)}function kQD(D,$){return LY(k9.unlock)(D,jO($))}function fQD(D,$){return NY(k9.check)(D,$)}function yQD(D,$){return LY(k9.check)(D,jO($))}l6.exports=Cx;l6.exports.lock=Cx;l6.exports.unlock=_QD;l6.exports.lockSync=vQD;l6.exports.unlockSync=kQD;l6.exports.check=fQD;l6.exports.checkSync=yQD});var fx=T((_x)=>{Object.defineProperty(_x,"__esModule",{value:!0});_x.canStoreURLs=_x.FileUrlStorage=void 0;var xx=i("fs"),bQD=gQD(Yx()),Sx=hQD(Px());function vx(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(vx=function(Y){return Y?X:$})(D)}function hQD(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=vx($);if(X&&X.has(D))return X.get(D);var Y={__proto__:null},J=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var F=J?Object.getOwnPropertyDescriptor(D,Q):null;F&&(F.get||F.set)?Object.defineProperty(Y,Q,F):Y[Q]=D[Q]}return Y.default=D,X&&X.set(D,Y),Y}function gQD(D){return D&&D.__esModule?D:{default:D}}function z3(D){return z3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},z3(D)}function mQD(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function ux(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,dQD(Y.key),Y)}}function cQD(D,$,X){if($)ux(D.prototype,$);if(X)ux(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function dQD(D){var $=lQD(D,"string");return z3($)=="symbol"?$:$+""}function lQD(D,$){if(z3(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(z3(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var ayD=_x.canStoreURLs=!0,tyD=_x.FileUrlStorage=function(){function D($){mQD(this,D),this.path=$}return cQD(D,[{key:"findAllUploads",value:function(){var X=this;return new Promise(function(Y,J){X._getItems("tus::",function(Q,F){if(Q)J(Q);else Y(F)})})}},{key:"findUploadsByFingerprint",value:function(X){var Y=this;return new Promise(function(J,Q){Y._getItems("tus::".concat(X),function(F,Z){if(F)Q(F);else J(Z)})})}},{key:"removeUpload",value:function(X){var Y=this;return new Promise(function(J,Q){Y._removeItem(X,function(F){if(F)Q(F);else J()})})}},{key:"addUpload",value:function(X,Y){var J=this,Q=Math.round(Math.random()*1000000000000),F="tus::".concat(X,"::").concat(Q);return new Promise(function(Z,w){J._setItem(F,Y,function(G){if(G)w(G);else Z(F)})})}},{key:"_setItem",value:function(X,Y,J){var Q=this;Sx.lock(this.path,this._lockfileOptions()).then(function(F){J=Q._releaseAndCb(F,J),Q._getData(function(Z,w){if(Z){J(Z);return}w[X]=Y,Q._writeData(w,function(G){return J(G)})})}).catch(J)}},{key:"_getItems",value:function(X,Y){this._getData(function(J,Q){if(J){Y(J);return}var F=Object.keys(Q).filter(function(Z){return Z.startsWith(X)}).map(function(Z){var w=Q[Z];return w.urlStorageKey=Z,w});Y(null,F)})}},{key:"_removeItem",value:function(X,Y){var J=this;Sx.lock(this.path,this._lockfileOptions()).then(function(Q){Y=J._releaseAndCb(Q,Y),J._getData(function(F,Z){if(F){Y(F);return}delete Z[X],J._writeData(Z,function(w){return Y(w)})})}).catch(Y)}},{key:"_lockfileOptions",value:function(){return{realpath:!1,retries:{retries:5,minTimeout:20}}}},{key:"_releaseAndCb",value:function(X,Y){return function(J){if(J){X().then(function(){return Y(J)}).catch(function(Q){return Y((0,bQD.default)([J,Q]))});return}X().then(Y).catch(Y)}}},{key:"_writeData",value:function(X,Y){var J={encoding:"utf8",mode:432,flag:"w"};(0,xx.writeFile)(this.path,JSON.stringify(X),J,function(Q){return Y(Q)})}},{key:"_getData",value:function(X){(0,xx.readFile)(this.path,"utf8",function(Y,J){if(Y){if(Y.code==="ENOENT")X(null,{});else X(Y);return}try{J=!J.trim().length?{}:JSON.parse(J)}catch(Q){X(Q);return}X(null,J)})}}])}()});var IY=T((n6)=>{Object.defineProperty(n6,"__esModule",{value:!0});Object.defineProperty(n6,"DefaultHttpStack",{enumerable:!0,get:function(){return gx.default}});Object.defineProperty(n6,"DetailedError",{enumerable:!0,get:function(){return iQD.default}});Object.defineProperty(n6,"FileUrlStorage",{enumerable:!0,get:function(){return mx.FileUrlStorage}});Object.defineProperty(n6,"StreamSource",{enumerable:!0,get:function(){return tQD.default}});n6.Upload=void 0;Object.defineProperty(n6,"canStoreURLs",{enumerable:!0,get:function(){return mx.canStoreURLs}});n6.defaultOptions=void 0;Object.defineProperty(n6,"enableDebugLog",{enumerable:!0,get:function(){return pQD.enableDebugLog}});n6.isSupported=void 0;var iQD=Y8(jU()),pQD=EU(),rQD=Y8(PT()),EO=Y8(wC()),oQD=Y8(CC()),aQD=Y8(vC()),gx=Y8(oC()),tQD=Y8(yU()),mx=fx();function Y8(D){return D&&D.__esModule?D:{default:D}}function y9(D){return y9=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},y9(D)}function sQD(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function yx(D,$){for(var X=0;X<$.length;X++){var Y=$[X];if(Y.enumerable=Y.enumerable||!1,Y.configurable=!0,"value"in Y)Y.writable=!0;Object.defineProperty(D,dx(Y.key),Y)}}function eQD(D,$,X){if($)yx(D.prototype,$);if(X)yx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function DFD(D,$,X){return $=MY($),$FD(D,cx()?Reflect.construct($,X||[],MY(D).constructor):$.apply(D,X))}function $FD(D,$){if($&&(y9($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return XFD(D)}function XFD(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function cx(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(cx=function(){return!!D})()}function MY(D){return MY=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},MY(D)}function JFD(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)TO(D,$)}function TO(D,$){return TO=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Y,J){return Y.__proto__=J,Y},TO(D,$)}function bx(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(D);$&&(Y=Y.filter(function(J){return Object.getOwnPropertyDescriptor(D,J).enumerable})),X.push.apply(X,Y)}return X}function f9(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?bx(Object(X),!0).forEach(function(Y){YFD(D,Y,X[Y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):bx(Object(X)).forEach(function(Y){Object.defineProperty(D,Y,Object.getOwnPropertyDescriptor(X,Y))})}return D}function YFD(D,$,X){if($=dx($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function dx(D){var $=QFD(D,"string");return y9($)=="symbol"?$:$+""}function QFD(D,$){if(y9(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var Y=X.call(D,$||"default");if(y9(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var hx=n6.defaultOptions=f9(f9({},EO.default.defaultOptions),{},{httpStack:new gx.default,fileReader:new oQD.default,urlStorage:new rQD.default,fingerprint:aQD.default}),eyD=n6.Upload=function(D){function $(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return sQD(this,$),Y=f9(f9({},hx),Y),DFD(this,$,[X,Y])}return JFD($,D),eQD($,null,[{key:"terminate",value:function(Y){var J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return J=f9(f9({},hx),J),EO.default.terminate(Y,J)}}])}(EO.default),DbD=n6.isSupported=!0});var H$;var B3=o(()=>{H$={name:"@capgo/cli",type:"module",version:"7.84.5",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/CLI#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/CLI.git"},bugs:{url:"https://github.com/Cap-go/CLI/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"npx --yes supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsc --noEmit",lint:'eslint "src/**/*.ts" --fix',"check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:mcp":"node test/test-mcp.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs","test:payload-split":"bun test/test-payload-split.mjs",test:"bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:credentials && bun run test:credentials-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:esm-sdk && bun run test:mcp && bun run test:version-detection && bun run test:platform-paths && bun run test:payload-split"},devDependencies:{"@antfu/eslint-config":"^7.0.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.4","@capacitor/cli":"^8.0.0","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.0.0","@modelcontextprotocol/sdk":"^1.25.3","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.79.0","@types/adm-zip":"^0.5.7","@types/node":"^25.0.0","@types/prettyjson":"^0.0.33","@types/tmp":"^0.2.6","@vercel/ncc":"^0.38.4","adm-zip":"^0.5.16","ci-info":"^4.3.1",commander:"^14.0.2",eslint:"^9.38.0","git-format-staged":"4.0.1",husky:"^9.1.7","is-wsl":"^3.1.0",micromatch:"^4.0.8",open:"^11.0.0",prettyjson:"^1.2.5",tmp:"^0.2.5","tus-js-client":"^4.3.1",typescript:"^5.9.3",partysocket:"^1.1.11",ws:"^8.18.3",zod:"^4.3.6"}}});async function AY(D){try{let X=`https://registry.npmjs.org/${encodeURIComponent(D.toLowerCase())}`,Y=await fetch(X,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});if(!Y.ok)return null;return(await Y.json())["dist-tags"]?.latest||null}catch{return null}}async function Z0(){let D=await AY("@capgo/cli")??"",$=D?.split(".")[0];if(D!==H$.version)H.warning(`\uD83D\uDEA8 You are using @capgo/cli@${H$.version} it's not the latest version.
131
131
  Please use @capgo/cli@${D}" or @capgo/cli@${$} to keep up to date with the latest features and bug fixes.`)}var O1=o(()=>{vD();B3()});async function px(D,$,X,Y,J,Q="✅"){await AD(X,{channel:D,event:Y,icon:Q,user_id:$,...J?{tags:{"app-id":J}}:{},notify:!1})}var rx=o(()=>{vD();D6();O1();kD()});import{Buffer as ox}from"node:buffer";import{createHash as ZFD}from"node:crypto";function GFD(D){let $=4294967295;for(let X=0;X<D.length;X++){let Y=D[X];$=wFD[($^Y)&255]^$>>>8}return $=$^4294967295,($>>>0).toString(16).padStart(8,"0")}async function i6(D,$="sha256"){let X=ox.isBuffer(D)?D:ox.from(D);if($==="crc32")return GFD(X);let Y=ZFD($);return Y.update(X),Y.digest("hex")}var wFD;var W3=o(()=>{wFD=(()=>{let D=[];for(let $=0;$<256;$++){let X=$;for(let Y=0;Y<8;Y++)X=X&1?3988292384^X>>>1:X>>>1;D[$]=X}return D})()});var tx=T((KbD,ax)=>{var b9=1000,h9=b9*60,g9=h9*60,Q8=g9*24,UFD=Q8*7,OFD=Q8*365.25;ax.exports=function(D,$){$=$||{};var X=typeof D;if(X==="string"&&D.length>0)return qFD(D);else if(X==="number"&&isFinite(D))return $.long?BFD(D):zFD(D);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(D))};function qFD(D){if(D=String(D),D.length>100)return;var $=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(D);if(!$)return;var X=parseFloat($[1]),Y=($[2]||"ms").toLowerCase();switch(Y){case"years":case"year":case"yrs":case"yr":case"y":return X*OFD;case"weeks":case"week":case"w":return X*UFD;case"days":case"day":case"d":return X*Q8;case"hours":case"hour":case"hrs":case"hr":case"h":return X*g9;case"minutes":case"minute":case"mins":case"min":case"m":return X*h9;case"seconds":case"second":case"secs":case"sec":case"s":return X*b9;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return X;default:return}}function zFD(D){var $=Math.abs(D);if($>=Q8)return Math.round(D/Q8)+"d";if($>=g9)return Math.round(D/g9)+"h";if($>=h9)return Math.round(D/h9)+"m";if($>=b9)return Math.round(D/b9)+"s";return D+"ms"}function BFD(D){var $=Math.abs(D);if($>=Q8)return RY(D,$,Q8,"day");if($>=g9)return RY(D,$,g9,"hour");if($>=h9)return RY(D,$,h9,"minute");if($>=b9)return RY(D,$,b9,"second");return D+" ms"}function RY(D,$,X,Y){var J=$>=X*1.5;return Math.round(D/X)+" "+Y+(J?"s":"")}});var CO=T((HbD,sx)=>{function WFD(D){X.debug=X,X.default=X,X.coerce=w,X.disable=F,X.enable=J,X.enabled=Z,X.humanize=tx(),X.destroy=G,Object.keys(D).forEach((U)=>{X[U]=D[U]}),X.names=[],X.skips=[],X.formatters={};function $(U){let O=0;for(let z=0;z<U.length;z++)O=(O<<5)-O+U.charCodeAt(z),O|=0;return X.colors[Math.abs(O)%X.colors.length]}X.selectColor=$;function X(U){let O,z=null,q,B;function W(...L){if(!W.enabled)return;let M=W,I=Number(new Date),K=I-(O||I);if(M.diff=K,M.prev=O,M.curr=I,O=I,L[0]=X.coerce(L[0]),typeof L[0]!=="string")L.unshift("%O");let N=0;L[0]=L[0].replace(/%([a-zA-Z%])/g,(R,x)=>{if(R==="%%")return"%";N++;let A=X.formatters[x];if(typeof A==="function"){let _=L[N];R=A.call(M,_),L.splice(N,1),N--}return R}),X.formatArgs.call(M,L),(M.log||X.log).apply(M,L)}if(W.namespace=U,W.useColors=X.useColors(),W.color=X.selectColor(U),W.extend=Y,W.destroy=X.destroy,Object.defineProperty(W,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(z!==null)return z;if(q!==X.namespaces)q=X.namespaces,B=X.enabled(U);return B},set:(L)=>{z=L}}),typeof X.init==="function")X.init(W);return W}function Y(U,O){let z=X(this.namespace+(typeof O>"u"?":":O)+U);return z.log=this.log,z}function J(U){X.save(U),X.namespaces=U,X.names=[],X.skips=[];let O=(typeof U==="string"?U:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let z of O)if(z[0]==="-")X.skips.push(z.slice(1));else X.names.push(z)}function Q(U,O){let z=0,q=0,B=-1,W=0;while(z<U.length)if(q<O.length&&(O[q]===U[z]||O[q]==="*"))if(O[q]==="*")B=q,W=z,q++;else z++,q++;else if(B!==-1)q=B+1,W++,z=W;else return!1;while(q<O.length&&O[q]==="*")q++;return q===O.length}function F(){let U=[...X.names,...X.skips.map((O)=>"-"+O)].join(",");return X.enable(""),U}function Z(U){for(let O of X.skips)if(Q(U,O))return!1;for(let O of X.names)if(Q(U,O))return!0;return!1}function w(U){if(U instanceof Error)return U.stack||U.message;return U}function G(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return X.enable(X.load()),X}sx.exports=WFD});var DS=T((ex,jY)=>{ex.formatArgs=HFD;ex.save=VFD;ex.load=NFD;ex.useColors=KFD;ex.storage=LFD();ex.destroy=(()=>{let D=!1;return()=>{if(!D)D=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();ex.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function KFD(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let D;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(D=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(D[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function HFD(D){if(D[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+D[0]+(this.useColors?"%c ":" ")+"+"+jY.exports.humanize(this.diff),!this.useColors)return;let $="color: "+this.color;D.splice(1,0,$,"color: inherit");let X=0,Y=0;D[0].replace(/%[a-zA-Z%]/g,(J)=>{if(J==="%%")return;if(X++,J==="%c")Y=X}),D.splice(Y,0,$)}ex.log=console.debug||console.log||(()=>{});function VFD(D){try{if(D)ex.storage.setItem("debug",D);else ex.storage.removeItem("debug")}catch($){}}function NFD(){let D;try{D=ex.storage.getItem("debug")||ex.storage.getItem("DEBUG")}catch($){}if(!D&&typeof process<"u"&&"env"in process)D=process.env.DEBUG;return D}function LFD(){try{return localStorage}catch(D){}}jY.exports=CO()(ex);var{formatters:MFD}=jY.exports;MFD.j=function(D){try{return JSON.stringify(D)}catch($){return"[UnexpectedJSONParseError]: "+$.message}}});var XS=T((NbD,$S)=>{$S.exports=(D,$=process.argv)=>{let X=D.startsWith("-")?"":D.length===1?"-":"--",Y=$.indexOf(X+D),J=$.indexOf("--");return Y!==-1&&(J===-1||Y<J)}});var QS=T((LbD,YS)=>{var PFD=i("os"),JS=i("tty"),D$=XS(),{env:l0}=process,p6;if(D$("no-color")||D$("no-colors")||D$("color=false")||D$("color=never"))p6=0;else if(D$("color")||D$("colors")||D$("color=true")||D$("color=always"))p6=1;if("FORCE_COLOR"in l0)if(l0.FORCE_COLOR==="true")p6=1;else if(l0.FORCE_COLOR==="false")p6=0;else p6=l0.FORCE_COLOR.length===0?1:Math.min(parseInt(l0.FORCE_COLOR,10),3);function PO(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function xO(D,$){if(p6===0)return 0;if(D$("color=16m")||D$("color=full")||D$("color=truecolor"))return 3;if(D$("color=256"))return 2;if(D&&!$&&p6===void 0)return 0;let X=p6||0;if(l0.TERM==="dumb")return X;if(process.platform==="win32"){let Y=PFD.release().split(".");if(Number(Y[0])>=10&&Number(Y[2])>=10586)return Number(Y[2])>=14931?3:2;return 1}if("CI"in l0){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((Y)=>(Y in l0))||l0.CI_NAME==="codeship")return 1;return X}if("TEAMCITY_VERSION"in l0)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(l0.TEAMCITY_VERSION)?1:0;if(l0.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in l0){let Y=parseInt((l0.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(l0.TERM_PROGRAM){case"iTerm.app":return Y>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(l0.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(l0.TERM))return 1;if("COLORTERM"in l0)return 1;return X}function xFD(D){let $=xO(D,D&&D.isTTY);return PO($)}YS.exports={supportsColor:xFD,stdout:PO(xO(!0,JS.isatty(1))),stderr:PO(xO(!0,JS.isatty(2)))}});var GS=T((ZS,TY)=>{var SFD=i("tty"),EY=i("util");ZS.init=bFD;ZS.log=kFD;ZS.formatArgs=vFD;ZS.save=fFD;ZS.load=yFD;ZS.useColors=uFD;ZS.destroy=EY.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");ZS.colors=[6,2,3,4,5,1];try{let D=QS();if(D&&(D.stderr||D).level>=2)ZS.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(D){}ZS.inspectOpts=Object.keys(process.env).filter((D)=>{return/^debug_/i.test(D)}).reduce((D,$)=>{let X=$.substring(6).toLowerCase().replace(/_([a-z])/g,(J,Q)=>{return Q.toUpperCase()}),Y=process.env[$];if(/^(yes|on|true|enabled)$/i.test(Y))Y=!0;else if(/^(no|off|false|disabled)$/i.test(Y))Y=!1;else if(Y==="null")Y=null;else Y=Number(Y);return D[X]=Y,D},{});function uFD(){return"colors"in ZS.inspectOpts?Boolean(ZS.inspectOpts.colors):SFD.isatty(process.stderr.fd)}function vFD(D){let{namespace:$,useColors:X}=this;if(X){let Y=this.color,J="\x1B[3"+(Y<8?Y:"8;5;"+Y),Q=` ${J};1m${$} \x1B[0m`;D[0]=Q+D[0].split(`
132
132
  `).join(`
133
133
  `+Q),D.push(J+"m+"+TY.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=_FD()+$+" "+D[0]}function _FD(){if(ZS.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function kFD(...D){return process.stderr.write(EY.formatWithOptions(ZS.inspectOpts,...D)+`
@@ -392,7 +392,7 @@ The organization "${D}" requires all members to have 2FA enabled.`);else H.error
392
392
  This organization requires all members to have 2FA enabled.`);throw H.error(`
393
393
  To regain access:`),H.error(" 1. Go to https://web.capgo.app/settings/account"),H.error(" 2. Enable Two-Factor Authentication on your account"),H.error(" 3. Try your command again"),H.error(`
394
394
  For more information, visit: https://capgo.app/docs/webapp/2fa-enforcement/
395
- `),Error("2FA required for this organization")}async function Ow(D,$){let{error:X,data:Y}=await D.rpc("get_orgs_v7");if(X)throw H.error("Cannot get the list of organizations - exiting"),H.error(`Error ${JSON.stringify(X)}`),Error("Cannot get the list of organizations");let J=Y.filter((w)=>!!$.find((G)=>G===w.role));if(Y.length===0)throw H.error("Could not get organization please create an organization first"),Error("No organizations available");if(J.length===0)throw H.error(`Could not find organization with roles: ${$.join(" or ")} please create an organization or ask the admin to add you to the organization with this roles`),Error("Could not find organization with required roles");let Q=J.length>1?await t1({message:"Please pick the organization that you want to insert to",options:J.map((w)=>{let G=w.enforcing_2fa&&!w["2fa_has_access"]?" ⚠️ (2FA required)":"";return{value:w.gid,label:`${w.name}${G}`}})}):J[0].gid;if(yD(Q))throw H.error("Canceled organization selection, exiting"),Error("Organization selection cancelled");let F=Q,Z=Y.find((w)=>w.gid===F);if(Z.enforcing_2fa&&!Z["2fa_has_access"])_L(Z.name);return H.info(`Using the organization "${Z.name}" as the app owner`),Z}async function xD(D,$,X=["all"]){await mED(D,$,X);let{data:Y,error:J}=await D.rpc("get_user_id",{apikey:$}).single(),Q=(Y||"").toString();if(!Q||J)throw H.error("Cannot auth user with apikey"),Error("Cannot authenticate user with provided API key");return Q}async function d0(D,$){let{data:X,error:Y}=await D.from("apps").select("owner_org").eq("app_id",$).single();if(!X||Y)throw H.error(`Cannot get organization id for app id ${$}`),t(Y),Error(`Cannot get organization id for app id ${$}`);return X.owner_org}function a5(D){return new Date(D||"").toLocaleString()}function v8(){if(za)return{pm:n5,command:J2,installCommand:`${n5} ${J2}`,runner:xL};let D=e0(a$());return n5=N7(D,"npm"),J2=p2(n5),za=!0,xL=MI(D),{pm:n5,command:J2,installCommand:`${n5} ${J2}`,runner:xL}}function Sa(D){return F2(D,{withFileTypes:!0}).flatMap((Y)=>{let J=fD(D,Y.name);if(Y.isDirectory())return Sa(J);else return J.split(`node_modules${Wa}`)[1]||J})}function ua(D){if(!X0(D))return[];try{return F2(D,{withFileTypes:!0}).flatMap((Y)=>{let J=fD(D,Y.name);if(Y.isDirectory())return ua(J);else return J})}catch{return[]}}function iED(D,$){let X=[];if($==="ios"){try{let Q=F2(D);for(let F of Q)if(F.endsWith(".podspec"))X.push(fD(D,F))}catch{}let Y=fD(D,"Package.swift"),J=fD(D,"ios","Package.swift");if(X0(Y))X.push(Y);if(X0(J))X.push(J)}else if($==="android"){let Y=fD(D,"android"),J=fD(Y,"build.gradle"),Q=fD(Y,"build.gradle.kts");if(X0(J))X.push(J);if(X0(Q))X.push(Q)}return X}async function pED(D){let $=fD(D,"ios"),X=fD(D,"android"),Y=async(F,Z)=>{let w=X0(F)?ua(F).filter((q)=>Va.test(q)):[],G=iED(D,Z),U=[...w,...G].sort((q,B)=>q.localeCompare(B));if(U.length===0)return;let{createHash:O}=await import("node:crypto"),z=O("sha256");for(let q of U)try{let B=Ba(D,q);z.update(B);let W=f0(q);z.update(W)}catch{}return z.digest("hex")},[J,Q]=await Promise.all([Y($,"ios"),Y(X,"android")]);return{ios_checksum:J,android_checksum:Q}}async function kL(D,$){let X=$?$.split(",").map((U)=>U.trim()).filter(Boolean):[],Y;try{Y=await Qw("",D)}catch(U){throw H.error("Invalid package.json, JSON parsing failed"),H.error(`json parse error: ${t(U)}`),U instanceof Error?U:Error("Invalid package.json")}let J=D?D.split(",")[0].trim():void 0,Q=!J?e0(a$()):Z2.resolve(J).replace(A6,"");if(!Y)throw H.error("Missing dependencies section in package.json"),Error("Missing dependencies section in package.json");for(let[U,O]of Object.entries(Y))if(typeof O!=="string")throw H.error(`Invalid dependency ${U}: ${O}, expected string, got ${typeof O}`),Error(`Invalid dependency ${U}: expected string version`);let F=X.length===0?[fD(a$(),"node_modules")]:X;if(!F.some((U)=>X0(U))){let U=N7(Q,"npm"),O=p2(U);throw H.error(`Missing node_modules folder at ${F.join(", ")}, please run ${U} ${O}`),Error("Missing node_modules folder")}let w=!1,G=await Promise.all(Array.from(Y.entries()).map(async([U,O])=>{let z=!1,q=!1,B=O,W;for(let I of F){let K=fD(I,U);if(X0(K)){z=!0,W=K;try{let N=fD(K,A6);if(X0(N)){let V=JSON.parse(f0(N,"utf-8"));if(V.version)B=V.version}}catch{}try{if(Sa(K).some((V)=>Va.test(V))){q=!0;break}}catch(N){throw H.error(`Error reading node_modules files for ${U} package in ${I}`),H.error(t(N)),N instanceof Error?N:Error(`Error reading node_modules files for ${U}`)}}}if(!z){w=!0;let I=N7(Q,"npm"),K=p2(I);return H.error(`Missing dependency ${U}, please run ${I} ${K}`),{name:U,version:O}}let L,M;if(q&&W){let I=await pED(W);L=I.ios_checksum,M=I.android_checksum}return{name:U,version:B,native:q,ios_checksum:L,android_checksum:M}})).catch(()=>[]);if(w||G.find((U)=>U.native===void 0))throw H.error("Missing dependencies or invalid dependencies"),H.error("If you use monorepo, workspace or any special package manager you can use the --package-json [path,] and --node-modules [path,] options to make the command work properly"),Error("Missing dependencies or invalid dependencies");return G}async function rED(D,$,X){let{data:Y,error:J}=await D.from("channels").select("version(checksum)").eq("name",X).eq("app_id",$).single(),Q=Y;if(J||Q===null||!Q.version||!Q.version.checksum)return null;return Q.version.checksum}function oED(D){if(!D)throw H.error("Error parsing native packages, perhaps the metadata does not exist in Capgo?"),Error("Error parsing native packages");for(let X of D){let Y=_o.safeParse(X);if(!Y.success){let J=Y.error.issues.map((Q)=>`${Q.path.join(".")}: ${Q.message}`).join(", ");throw H.error(`Invalid remote native package data: ${J}`),Error(`Invalid remote native package data: ${J}`)}}return new Map(D.map((X)=>[X.name,X]))}async function va(D,$,X){let{data:Y,error:J}=await D.from("channels").select(`version (
395
+ `),Error("2FA required for this organization")}async function Ow(D,$){let{error:X,data:Y}=await D.rpc("get_orgs_v7");if(X)throw H.error("Cannot get the list of organizations - exiting"),H.error(`Error ${JSON.stringify(X)}`),Error("Cannot get the list of organizations");let J=(U)=>U?.replace(/^org_/,"")??"",Q=$.map((U)=>J(U)),F=Y.filter((U)=>Q.includes(J(U.role)));if(Y.length===0)throw H.error("Could not get organization please create an organization first"),Error("No organizations available");if(F.length===0)throw H.error(`Could not find organization with roles: ${$.join(" or ")} please create an organization or ask the admin to add you to the organization with this roles`),Error("Could not find organization with required roles");let Z=F.length>1?await t1({message:"Please pick the organization that you want to insert to",options:F.map((U)=>{let O=U.enforcing_2fa&&!U["2fa_has_access"]?" ⚠️ (2FA required)":"";return{value:U.gid,label:`${U.name}${O}`}})}):F[0].gid;if(yD(Z))throw H.error("Canceled organization selection, exiting"),Error("Organization selection cancelled");let w=Z,G=Y.find((U)=>U.gid===w);if(G.enforcing_2fa&&!G["2fa_has_access"])_L(G.name);return H.info(`Using the organization "${G.name}" as the app owner`),G}async function xD(D,$,X=["all"]){await mED(D,$,X);let{data:Y,error:J}=await D.rpc("get_user_id",{apikey:$}).single(),Q=(Y||"").toString();if(!Q||J)throw H.error("Cannot auth user with apikey"),Error("Cannot authenticate user with provided API key");return Q}async function d0(D,$){let{data:X,error:Y}=await D.from("apps").select("owner_org").eq("app_id",$).single();if(!X||Y)throw H.error(`Cannot get organization id for app id ${$}`),t(Y),Error(`Cannot get organization id for app id ${$}`);return X.owner_org}function a5(D){return new Date(D||"").toLocaleString()}function v8(){if(za)return{pm:n5,command:J2,installCommand:`${n5} ${J2}`,runner:xL};let D=e0(a$());return n5=N7(D,"npm"),J2=p2(n5),za=!0,xL=MI(D),{pm:n5,command:J2,installCommand:`${n5} ${J2}`,runner:xL}}function Sa(D){return F2(D,{withFileTypes:!0}).flatMap((Y)=>{let J=fD(D,Y.name);if(Y.isDirectory())return Sa(J);else return J.split(`node_modules${Wa}`)[1]||J})}function ua(D){if(!X0(D))return[];try{return F2(D,{withFileTypes:!0}).flatMap((Y)=>{let J=fD(D,Y.name);if(Y.isDirectory())return ua(J);else return J})}catch{return[]}}function iED(D,$){let X=[];if($==="ios"){try{let Q=F2(D);for(let F of Q)if(F.endsWith(".podspec"))X.push(fD(D,F))}catch{}let Y=fD(D,"Package.swift"),J=fD(D,"ios","Package.swift");if(X0(Y))X.push(Y);if(X0(J))X.push(J)}else if($==="android"){let Y=fD(D,"android"),J=fD(Y,"build.gradle"),Q=fD(Y,"build.gradle.kts");if(X0(J))X.push(J);if(X0(Q))X.push(Q)}return X}async function pED(D){let $=fD(D,"ios"),X=fD(D,"android"),Y=async(F,Z)=>{let w=X0(F)?ua(F).filter((q)=>Va.test(q)):[],G=iED(D,Z),U=[...w,...G].sort((q,B)=>q.localeCompare(B));if(U.length===0)return;let{createHash:O}=await import("node:crypto"),z=O("sha256");for(let q of U)try{let B=Ba(D,q);z.update(B);let W=f0(q);z.update(W)}catch{}return z.digest("hex")},[J,Q]=await Promise.all([Y($,"ios"),Y(X,"android")]);return{ios_checksum:J,android_checksum:Q}}async function kL(D,$){let X=$?$.split(",").map((U)=>U.trim()).filter(Boolean):[],Y;try{Y=await Qw("",D)}catch(U){throw H.error("Invalid package.json, JSON parsing failed"),H.error(`json parse error: ${t(U)}`),U instanceof Error?U:Error("Invalid package.json")}let J=D?D.split(",")[0].trim():void 0,Q=!J?e0(a$()):Z2.resolve(J).replace(A6,"");if(!Y)throw H.error("Missing dependencies section in package.json"),Error("Missing dependencies section in package.json");for(let[U,O]of Object.entries(Y))if(typeof O!=="string")throw H.error(`Invalid dependency ${U}: ${O}, expected string, got ${typeof O}`),Error(`Invalid dependency ${U}: expected string version`);let F=X.length===0?[fD(a$(),"node_modules")]:X;if(!F.some((U)=>X0(U))){let U=N7(Q,"npm"),O=p2(U);throw H.error(`Missing node_modules folder at ${F.join(", ")}, please run ${U} ${O}`),Error("Missing node_modules folder")}let w=!1,G=await Promise.all(Array.from(Y.entries()).map(async([U,O])=>{let z=!1,q=!1,B=O,W;for(let I of F){let K=fD(I,U);if(X0(K)){z=!0,W=K;try{let N=fD(K,A6);if(X0(N)){let V=JSON.parse(f0(N,"utf-8"));if(V.version)B=V.version}}catch{}try{if(Sa(K).some((V)=>Va.test(V))){q=!0;break}}catch(N){throw H.error(`Error reading node_modules files for ${U} package in ${I}`),H.error(t(N)),N instanceof Error?N:Error(`Error reading node_modules files for ${U}`)}}}if(!z){w=!0;let I=N7(Q,"npm"),K=p2(I);return H.error(`Missing dependency ${U}, please run ${I} ${K}`),{name:U,version:O}}let L,M;if(q&&W){let I=await pED(W);L=I.ios_checksum,M=I.android_checksum}return{name:U,version:B,native:q,ios_checksum:L,android_checksum:M}})).catch(()=>[]);if(w||G.find((U)=>U.native===void 0))throw H.error("Missing dependencies or invalid dependencies"),H.error("If you use monorepo, workspace or any special package manager you can use the --package-json [path,] and --node-modules [path,] options to make the command work properly"),Error("Missing dependencies or invalid dependencies");return G}async function rED(D,$,X){let{data:Y,error:J}=await D.from("channels").select("version(checksum)").eq("name",X).eq("app_id",$).single(),Q=Y;if(J||Q===null||!Q.version||!Q.version.checksum)return null;return Q.version.checksum}function oED(D){if(!D)throw H.error("Error parsing native packages, perhaps the metadata does not exist in Capgo?"),Error("Error parsing native packages");for(let X of D){let Y=_o.safeParse(X);if(!Y.success){let J=Y.error.issues.map((Q)=>`${Q.path.join(".")}: ${Q.message}`).join(", ");throw H.error(`Invalid remote native package data: ${J}`),Error(`Invalid remote native package data: ${J}`)}}return new Map(D.map((X)=>[X.name,X]))}async function va(D,$,X){let{data:Y,error:J}=await D.from("channels").select(`version (
396
396
  native_packages
397
397
  )`).eq("name",X).eq("app_id",$).single();if(J)throw H.error(`Error fetching native packages: ${J.message}`),Error(`Error fetching native packages: ${J.message}`);return oED(Y.version.native_packages??[])}async function _a(D,$,X,Y){let J=A0();J.start(`Checking bundle checksum compatibility with channel ${X}`);let Q=await rED(D,$,X);if(!Q){J.stop(`No checksum found for channel ${X}, the bundle will be uploaded`);return}if(Q&&Q===Y)throw J.stop("Checksum check failed"),H.error(`Cannot upload the same bundle content.
398
398
  Current bundle checksum matches remote bundle for channel ${X}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
3
  "type": "module",
4
- "version": "7.84.3",
4
+ "version": "7.84.5",
5
5
  "description": "A CLI to upload to capgo servers",
6
6
  "author": "Martin martin@capgo.app",
7
7
  "license": "Apache 2.0",