@capgo/cli 7.89.5 → 7.89.6

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.89.5",
4
+ "version": "7.89.6",
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 Nx=E((Ip0,Vx)=>{var e6=l("constants"),tO0=process.cwd,aY=null,aO0=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!aY)aY=tO0.call(process);return aY};try{process.cwd()}catch(D){}if(typeof process.chdir==="function"){if(sY=process.chdir,process.chdir=function(D){aY=null,sY.call(process,D)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,sY)}var sY;Vx.exports=sO0;function sO0(D){if(e6.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=J(D.chmod),D.fchmod=J(D.fchmod),D.lchmod=J(D.lchmod),D.chownSync=U(D.chownSync),D.fchownSync=U(D.fchownSync),D.lchownSync=U(D.lchownSync),D.chmodSync=Y(D.chmodSync),D.fchmodSync=Y(D.fchmodSync),D.lchmodSync=Y(D.lchmodSync),D.stat=F(D.stat),D.fstat=F(D.fstat),D.lstat=F(D.lstat),D.statSync=Z(D.statSync),D.fstatSync=Z(D.fstatSync),D.lstatSync=Z(D.lstatSync),D.chmod&&!D.lchmod)D.lchmod=function(G,q,w){if(w)process.nextTick(w)},D.lchmodSync=function(){};if(D.chown&&!D.lchown)D.lchown=function(G,q,w,B){if(B)process.nextTick(B)},D.lchownSync=function(){};if(aO0==="win32")D.rename=typeof D.rename!=="function"?D.rename:function(G){function q(w,B,K){var H=Date.now(),W=0;G(w,B,function M(I){if(I&&(I.code==="EACCES"||I.code==="EPERM"||I.code==="EBUSY")&&Date.now()-H<60000){if(setTimeout(function(){D.stat(B,function(z,V){if(z&&z.code==="ENOENT")G(w,B,M);else K(I)})},W),W<100)W+=10;return}if(K)K(I)})}if(Object.setPrototypeOf)Object.setPrototypeOf(q,G);return q}(D.rename);D.read=typeof D.read!=="function"?D.read:function(G){function q(w,B,K,H,W,M){var I;if(M&&typeof M==="function"){var z=0;I=function(V,L,R){if(V&&V.code==="EAGAIN"&&z<10)return z++,G.call(D,w,B,K,H,W,I);M.apply(this,arguments)}}return G.call(D,w,B,K,H,W,I)}if(Object.setPrototypeOf)Object.setPrototypeOf(q,G);return q}(D.read),D.readSync=typeof D.readSync!=="function"?D.readSync:function(G){return function(q,w,B,K,H){var W=0;while(!0)try{return G.call(D,q,w,B,K,H)}catch(M){if(M.code==="EAGAIN"&&W<10){W++;continue}throw M}}}(D.readSync);function $(G){G.lchmod=function(q,w,B){G.open(q,e6.O_WRONLY|e6.O_SYMLINK,w,function(K,H){if(K){if(B)B(K);return}G.fchmod(H,w,function(W){G.close(H,function(M){if(B)B(W||M)})})})},G.lchmodSync=function(q,w){var B=G.openSync(q,e6.O_WRONLY|e6.O_SYMLINK,w),K=!0,H;try{H=G.fchmodSync(B,w),K=!1}finally{if(K)try{G.closeSync(B)}catch(W){}else G.closeSync(B)}return H}}function X(G){if(e6.hasOwnProperty("O_SYMLINK")&&G.futimes)G.lutimes=function(q,w,B,K){G.open(q,e6.O_SYMLINK,function(H,W){if(H){if(K)K(H);return}G.futimes(W,w,B,function(M){G.close(W,function(I){if(K)K(M||I)})})})},G.lutimesSync=function(q,w,B){var K=G.openSync(q,e6.O_SYMLINK),H,W=!0;try{H=G.futimesSync(K,w,B),W=!1}finally{if(W)try{G.closeSync(K)}catch(M){}else G.closeSync(K)}return H};else if(G.futimes)G.lutimes=function(q,w,B,K){if(K)process.nextTick(K)},G.lutimesSync=function(){}}function J(G){if(!G)return G;return function(q,w,B){return G.call(D,q,w,function(K){if(O(K))K=null;if(B)B.apply(this,arguments)})}}function Y(G){if(!G)return G;return function(q,w){try{return G.call(D,q,w)}catch(B){if(!O(B))throw B}}}function Q(G){if(!G)return G;return function(q,w,B,K){return G.call(D,q,w,B,function(H){if(O(H))H=null;if(K)K.apply(this,arguments)})}}function U(G){if(!G)return G;return function(q,w,B){try{return G.call(D,q,w,B)}catch(K){if(!O(K))throw K}}}function F(G){if(!G)return G;return function(q,w,B){if(typeof w==="function")B=w,w=null;function K(H,W){if(W){if(W.uid<0)W.uid+=4294967296;if(W.gid<0)W.gid+=4294967296}if(B)B.apply(this,arguments)}return w?G.call(D,q,w,K):G.call(D,q,K)}}function Z(G){if(!G)return G;return function(q,w){var B=w?G.call(D,q,w):G.call(D,q);if(B){if(B.uid<0)B.uid+=4294967296;if(B.gid<0)B.gid+=4294967296}return B}}function O(G){if(!G)return!0;if(G.code==="ENOSYS")return!0;var q=!process.getuid||process.getuid()!==0;if(q){if(G.code==="EINVAL"||G.code==="EPERM")return!0}return!1}}});var Ix=E((Ap0,Mx)=>{var Lx=l("stream").Stream;Mx.exports=eO0;function eO0(D){return{ReadStream:$,WriteStream:X};function $(J,Y){if(!(this instanceof $))return new $(J,Y);Lx.call(this);var Q=this;this.path=J,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,Y=Y||{};var U=Object.keys(Y);for(var F=0,Z=U.length;F<Z;F++){var O=U[F];this[O]=Y[O]}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(G,q){if(G){Q.emit("error",G),Q.readable=!1;return}Q.fd=q,Q.emit("open",q),Q._read()})}function X(J,Y){if(!(this instanceof X))return new X(J,Y);Lx.call(this),this.path=J,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,Y=Y||{};var Q=Object.keys(Y);for(var U=0,F=Q.length;U<F;U++){var Z=Q[U];this[Z]=Y[Z]}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 Rx=E((Rp0,Ax)=>{Ax.exports=$G0;var DG0=Object.getPrototypeOf||function(D){return D.__proto__};function $G0(D){if(D===null||typeof D!=="object")return D;if(D instanceof Object)var $={__proto__:DG0(D)};else var $=Object.create(null);return Object.getOwnPropertyNames(D).forEach(function(X){Object.defineProperty($,X,Object.getOwnPropertyDescriptor(D,X))}),$}});var xD=E((Ep0,Aw)=>{var ID=l("fs"),XG0=Nx(),JG0=Ix(),YG0=Rx(),eY=l("util"),eD,$Q;if(typeof Symbol==="function"&&typeof Symbol.for==="function")eD=Symbol.for("graceful-fs.queue"),$Q=Symbol.for("graceful-fs.previous");else eD="___graceful-fs.queue",$Q="___graceful-fs.previous";function QG0(){}function jx(D,$){Object.defineProperty(D,eD,{get:function(){return $}})}var W8=QG0;if(eY.debuglog)W8=eY.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))W8=function(){var D=eY.format.apply(eY,arguments);D="GFS4: "+D.split(/\n/).join(`
130
- GFS4: `),console.error(D)};if(!ID[eD]){if(Lw=global[eD]||[],jx(ID,Lw),ID.close=function(D){function $(X,J){return D.call(ID,X,function(Y){if(!Y)Ex();if(typeof J==="function")J.apply(this,arguments)})}return Object.defineProperty($,$Q,{value:D}),$}(ID.close),ID.closeSync=function(D){function $(X){D.apply(ID,arguments),Ex()}return Object.defineProperty($,$Q,{value:D}),$}(ID.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){W8(ID[eD]),l("assert").equal(ID[eD].length,0)})}var Lw;if(!global[eD])jx(global,ID[eD]);Aw.exports=Mw(YG0(ID));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!ID.__patched)Aw.exports=Mw(ID),ID.__patched=!0;function Mw(D){XG0(D),D.gracefulify=Mw,D.createReadStream=L,D.createWriteStream=R;var $=D.readFile;D.readFile=X;function X(_,x,S){if(typeof x==="function")S=x,x=null;return h(_,x,S);function h(b,n,f,j){return $(b,n,function(u){if(u&&(u.code==="EMFILE"||u.code==="ENFILE"))e9([h,[b,n,f],u,j||Date.now(),Date.now()]);else if(typeof f==="function")f.apply(this,arguments)})}}var J=D.writeFile;D.writeFile=Y;function Y(_,x,S,h){if(typeof S==="function")h=S,S=null;return b(_,x,S,h);function b(n,f,j,u,v){return J(n,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))e9([b,[n,f,j,u],y,v||Date.now(),Date.now()]);else if(typeof u==="function")u.apply(this,arguments)})}}var Q=D.appendFile;if(Q)D.appendFile=U;function U(_,x,S,h){if(typeof S==="function")h=S,S=null;return b(_,x,S,h);function b(n,f,j,u,v){return Q(n,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))e9([b,[n,f,j,u],y,v||Date.now(),Date.now()]);else if(typeof u==="function")u.apply(this,arguments)})}}var F=D.copyFile;if(F)D.copyFile=Z;function Z(_,x,S,h){if(typeof S==="function")h=S,S=0;return b(_,x,S,h);function b(n,f,j,u,v){return F(n,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))e9([b,[n,f,j,u],y,v||Date.now(),Date.now()]);else if(typeof u==="function")u.apply(this,arguments)})}}var O=D.readdir;D.readdir=q;var G=/^v[0-5]\./;function q(_,x,S){if(typeof x==="function")S=x,x=null;var h=G.test(process.version)?function(f,j,u,v){return O(f,b(f,j,u,v))}:function(f,j,u,v){return O(f,j,b(f,j,u,v))};return h(_,x,S);function b(n,f,j,u){return function(v,y){if(v&&(v.code==="EMFILE"||v.code==="ENFILE"))e9([h,[n,f,j],v,u||Date.now(),Date.now()]);else{if(y&&y.sort)y.sort();if(typeof j==="function")j.call(this,v,y)}}}}if(process.version.substr(0,4)==="v0.8"){var w=JG0(D);M=w.ReadStream,z=w.WriteStream}var B=D.ReadStream;if(B)M.prototype=Object.create(B.prototype),M.prototype.open=I;var K=D.WriteStream;if(K)z.prototype=Object.create(K.prototype),z.prototype.open=V;Object.defineProperty(D,"ReadStream",{get:function(){return M},set:function(_){M=_},enumerable:!0,configurable:!0}),Object.defineProperty(D,"WriteStream",{get:function(){return z},set:function(_){z=_},enumerable:!0,configurable:!0});var H=M;Object.defineProperty(D,"FileReadStream",{get:function(){return H},set:function(_){H=_},enumerable:!0,configurable:!0});var W=z;Object.defineProperty(D,"FileWriteStream",{get:function(){return W},set:function(_){W=_},enumerable:!0,configurable:!0});function M(_,x){if(this instanceof M)return B.apply(this,arguments),this;else return M.apply(Object.create(M.prototype),arguments)}function I(){var _=this;A(_.path,_.flags,_.mode,function(x,S){if(x){if(_.autoClose)_.destroy();_.emit("error",x)}else _.fd=S,_.emit("open",S),_.read()})}function z(_,x){if(this instanceof z)return K.apply(this,arguments),this;else return z.apply(Object.create(z.prototype),arguments)}function V(){var _=this;A(_.path,_.flags,_.mode,function(x,S){if(x)_.destroy(),_.emit("error",x);else _.fd=S,_.emit("open",S)})}function L(_,x){return new D.ReadStream(_,x)}function R(_,x){return new D.WriteStream(_,x)}var C=D.open;D.open=A;function A(_,x,S,h){if(typeof S==="function")h=S,S=null;return b(_,x,S,h);function b(n,f,j,u,v){return C(n,f,j,function(y,g){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))e9([b,[n,f,j,u],y,v||Date.now(),Date.now()]);else if(typeof u==="function")u.apply(this,arguments)})}}return D}function e9(D){W8("ENQUEUE",D[0].name,D[1]),ID[eD].push(D),Iw()}var DQ;function Ex(){var D=Date.now();for(var $=0;$<ID[eD].length;++$)if(ID[eD][$].length>2)ID[eD][$][3]=D,ID[eD][$][4]=D;Iw()}function Iw(){if(clearTimeout(DQ),DQ=void 0,ID[eD].length===0)return;var D=ID[eD].shift(),$=D[0],X=D[1],J=D[2],Y=D[3],Q=D[4];if(Y===void 0)W8("RETRY",$.name,X),$.apply(null,X);else if(Date.now()-Y>=60000){W8("TIMEOUT",$.name,X);var U=X.pop();if(typeof U==="function")U.call(null,J)}else{var F=Date.now()-Q,Z=Math.max(Q-Y,1),O=Math.min(Z*1.2,100);if(F>=O)W8("RETRY",$.name,X),$.apply(null,X.concat([Y]));else ID[eD].push(D)}if(DQ===void 0)DQ=setTimeout(Iw,0)}});var Cx=E((jp0,Tx)=>{function Q$(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)}Tx.exports=Q$;Q$.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Q$.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};Q$.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 J=this,Y=setTimeout(function(){if(J._attempts++,J._operationTimeoutCb){if(J._timeout=setTimeout(function(){J._operationTimeoutCb(J._attempts)},J._operationTimeout),J._options.unref)J._timeout.unref()}J._fn(J._attempts)},X);if(this._options.unref)Y.unref();return!0};Q$.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)};Q$.prototype.try=function(D){console.log("Using RetryOperation.try() is deprecated"),this.attempt(D)};Q$.prototype.start=function(D){console.log("Using RetryOperation.start() is deprecated"),this.attempt(D)};Q$.prototype.start=Q$.prototype.try;Q$.prototype.errors=function(){return this._errors};Q$.prototype.attempts=function(){return this._attempts};Q$.prototype.mainError=function(){if(this._errors.length===0)return null;var D={},$=null,X=0;for(var J=0;J<this._errors.length;J++){var Y=this._errors[J],Q=Y.message,U=(D[Q]||0)+1;if(D[Q]=U,U>=X)$=Y,X=U}return $}});var Sx=E((FG0)=>{var UG0=Cx();FG0.operation=function(D){var $=FG0.timeouts(D);return new UG0($,{forever:D&&D.forever,unref:D&&D.unref,maxRetryTime:D&&D.maxRetryTime})};FG0.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 J=[];for(var Y=0;Y<$.retries;Y++)J.push(this.createTimeout(Y,$));if(D&&D.forever&&!J.length)J.push(this.createTimeout(Y,$));return J.sort(function(Q,U){return Q-U}),J};FG0.createTimeout=function(D,$){var X=$.randomize?Math.random()+1:1,J=Math.round(X*$.minTimeout*Math.pow($.factor,D));return J=Math.min(J,$.maxTimeout),J};FG0.wrap=function(D,$,X){if($ instanceof Array)X=$,$=null;if(!X){X=[];for(var J in D)if(typeof D[J]==="function")X.push(J)}for(var Y=0;Y<X.length;Y++){var Q=X[Y],U=D[Q];D[Q]=function(Z){var O=FG0.operation($),G=Array.prototype.slice.call(arguments,1),q=G.pop();G.push(function(w){if(O.retry(w))return;if(w)arguments[0]=O.mainError();q.apply(this,arguments)}),O.attempt(function(){Z.apply(D,G)})}.bind(D,U),D[Q].options=$}}});var ux=E((Cp0,XQ)=>{XQ.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")XQ.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")XQ.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var QQ=E((Pp0,$5)=>{var VD=global.process,V8=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(!V8(VD))$5.exports=function(){return function(){}};else{if(Rw=l("assert"),N8=ux(),Ew=/^win/i.test(VD.platform),D5=l("events"),typeof D5!=="function")D5=D5.EventEmitter;if(VD.__signal_exit_emitter__)dD=VD.__signal_exit_emitter__;else dD=VD.__signal_exit_emitter__=new D5,dD.count=0,dD.emitted={};if(!dD.infinite)dD.setMaxListeners(1/0),dD.infinite=!0;$5.exports=function(D,$){if(!V8(global.process))return function(){};if(Rw.equal(typeof D,"function","a callback must be provided for exit handler"),L8===!1)JQ();var X="exit";if($&&$.alwaysLast)X="afterexit";var J=function(){if(dD.removeListener(X,D),dD.listeners("exit").length===0&&dD.listeners("afterexit").length===0)m3()};return dD.on(X,D),J},m3=function(){if(!L8||!V8(global.process))return;L8=!1,N8.forEach(function($){try{VD.removeListener($,c3[$])}catch(X){}}),VD.emit=d3,VD.reallyExit=YQ,dD.count-=1},$5.exports.unload=m3,D4=function($,X,J){if(dD.emitted[$])return;dD.emitted[$]=!0,dD.emit($,X,J)},c3={},N8.forEach(function(D){c3[D]=function(){if(!V8(global.process))return;var X=VD.listeners(D);if(X.length===dD.count){if(m3(),D4("exit",null,D),D4("afterexit",null,D),Ew&&D==="SIGHUP")D="SIGINT";VD.kill(VD.pid,D)}}}),$5.exports.signals=function(){return N8},L8=!1,JQ=function(){if(L8||!V8(global.process))return;L8=!0,dD.count+=1,N8=N8.filter(function($){try{return VD.on($,c3[$]),!0}catch(X){return!1}}),VD.emit=Tw,VD.reallyExit=jw},$5.exports.load=JQ,YQ=VD.reallyExit,jw=function($){if(!V8(global.process))return;VD.exitCode=$||0,D4("exit",VD.exitCode,null),D4("afterexit",VD.exitCode,null),YQ.call(VD,VD.exitCode)},d3=VD.emit,Tw=function($,X){if($==="exit"&&V8(global.process)){if(X!==void 0)VD.exitCode=X;var J=d3.apply(this,arguments);return D4("exit",VD.exitCode,null),D4("afterexit",VD.exitCode,null),J}else return d3.apply(this,arguments)}}var Rw,N8,Ew,D5,dD,m3,D4,c3,L8,JQ,YQ,jw,d3,Tw});var vx=E((BG0,Cw)=>{var xx=Symbol();function qG0(D,$,X){let J=$[xx];if(J)return $.stat(D,(Q,U)=>{if(Q)return X(Q);X(null,U.mtime,J)});let Y=new Date(Math.ceil(Date.now()/1000)*1000+5);$.utimes(D,Y,Y,(Q)=>{if(Q)return X(Q);$.stat(D,(U,F)=>{if(U)return X(U);let Z=F.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty($,xx,{value:Z}),X(null,F.mtime,Z)})})}function wG0(D){let $=Date.now();if(D==="s")$=Math.ceil($/1000)*1000;return new Date($)}BG0.probe=qG0;BG0.getMtime=wG0});var bx=E((IG0,n3)=>{var zG0=l("path"),uw=xD(),WG0=Sx(),VG0=QQ(),_x=vx(),W6={};function l3(D,$){return $.lockfilePath||`${D}.lock`}function xw(D,$,X){if(!$.realpath)return X(null,zG0.resolve(D));$.fs.realpath(D,X)}function Sw(D,$,X){let J=l3(D,$);$.fs.mkdir(J,(Y)=>{if(!Y)return _x.probe(J,$.fs,(Q,U,F)=>{if(Q)return $.fs.rmdir(J,()=>{}),X(Q);X(null,U,F)});if(Y.code!=="EEXIST")return X(Y);if($.stale<=0)return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));$.fs.stat(J,(Q,U)=>{if(Q){if(Q.code==="ENOENT")return Sw(D,{...$,stale:0},X);return X(Q)}if(!kx(U,$))return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));fx(D,$,(F)=>{if(F)return X(F);Sw(D,{...$,stale:0},X)})})})}function kx(D,$){return D.mtime.getTime()<Date.now()-$.stale}function fx(D,$,X){$.fs.rmdir(l3(D,$),(J)=>{if(J&&J.code!=="ENOENT")return X(J);X()})}function UQ(D,$){let X=W6[D];if(X.updateTimeout)return;if(X.updateDelay=X.updateDelay||$.update,X.updateTimeout=setTimeout(()=>{X.updateTimeout=null,$.fs.stat(X.lockfilePath,(J,Y)=>{let Q=X.lastUpdate+$.stale<Date.now();if(J){if(J.code==="ENOENT"||Q)return Pw(D,X,Object.assign(J,{code:"ECOMPROMISED"}));return X.updateDelay=1000,UQ(D,$)}if(X.mtime.getTime()!==Y.mtime.getTime())return Pw(D,X,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let F=_x.getMtime(X.mtimePrecision);$.fs.utimes(X.lockfilePath,F,F,(Z)=>{let O=X.lastUpdate+$.stale<Date.now();if(X.released)return;if(Z){if(Z.code==="ENOENT"||O)return Pw(D,X,Object.assign(Z,{code:"ECOMPROMISED"}));return X.updateDelay=1000,UQ(D,$)}X.mtime=F,X.lastUpdate=Date.now(),X.updateDelay=null,UQ(D,$)})})},X.updateDelay),X.updateTimeout.unref)X.updateTimeout.unref()}function Pw(D,$,X){if($.released=!0,$.updateTimeout)clearTimeout($.updateTimeout);if(W6[D]===$)delete W6[D];$.options.onCompromised(X)}function NG0(D,$,X){$={stale:1e4,update:null,realpath:!0,retries:0,fs:uw,onCompromised:(J)=>{throw J},...$},$.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),xw(D,$,(J,Y)=>{if(J)return X(J);let Q=WG0.operation($.retries);Q.attempt(()=>{Sw(Y,$,(U,F,Z)=>{if(Q.retry(U))return;if(U)return X(Q.mainError());let O=W6[Y]={lockfilePath:l3(Y,$),mtime:F,mtimePrecision:Z,options:$,lastUpdate:Date.now()};UQ(Y,$),X(null,(G)=>{if(O.released)return G&&G(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));yx(Y,{...$,realpath:!1},G)})})})})}function yx(D,$,X){$={fs:uw,realpath:!0,...$},xw(D,$,(J,Y)=>{if(J)return X(J);let Q=W6[Y];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 W6[Y],fx(Y,$,X)})}function LG0(D,$,X){$={stale:1e4,realpath:!0,fs:uw,...$},$.stale=Math.max($.stale||0,2000),xw(D,$,(J,Y)=>{if(J)return X(J);$.fs.stat(l3(Y,$),(Q,U)=>{if(Q)return Q.code==="ENOENT"?X(null,!1):X(Q);return X(null,!kx(U,$))})})}function MG0(){return W6}VG0(()=>{for(let D in W6){let $=W6[D].options;try{$.fs.rmdirSync(l3(D,$))}catch(X){}}});IG0.lock=NG0;IG0.unlock=yx;IG0.check=LG0;IG0.getLocks=MG0});var gx=E((Sp0,hx)=>{var TG0=xD();function CG0(D){let $=["mkdir","realpath","stat","rmdir","utimes"],X={...D};return $.forEach((J)=>{X[J]=(...Y)=>{let Q=Y.pop(),U;try{U=D[`${J}Sync`](...Y)}catch(F){return Q(F)}Q(null,U)}}),X}function PG0(D){return(...$)=>new Promise((X,J)=>{$.push((Y,Q)=>{if(Y)J(Y);else X(Q)}),D(...$)})}function SG0(D){return(...$)=>{let X,J;if($.push((Y,Q)=>{X=Y,J=Q}),D(...$),X)throw X;return J}}function uG0(D){if(D={...D},D.fs=CG0(D.fs||TG0),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}hx.exports={toPromise:PG0,toSync:SG0,toSyncOptions:uG0}});var cx=E((up0,$4)=>{var X5=bx(),{toPromise:FQ,toSync:ZQ,toSyncOptions:vw}=gx();async function mx(D,$){let X=await FQ(X5.lock)(D,$);return FQ(X)}function xG0(D,$){let X=ZQ(X5.lock)(D,vw($));return ZQ(X)}function vG0(D,$){return FQ(X5.unlock)(D,$)}function _G0(D,$){return ZQ(X5.unlock)(D,vw($))}function kG0(D,$){return FQ(X5.check)(D,$)}function fG0(D,$){return ZQ(X5.check)(D,vw($))}$4.exports=mx;$4.exports.lock=mx;$4.exports.unlock=vG0;$4.exports.lockSync=xG0;$4.exports.unlockSync=_G0;$4.exports.check=kG0;$4.exports.checkSync=fG0});var ox=E((px)=>{Object.defineProperty(px,"__esModule",{value:!0});px.canStoreURLs=px.FileUrlStorage=void 0;var dx=l("fs"),yG0=hG0(Wx()),lx=bG0(cx());function ix(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(ix=function(J){return J?X:$})(D)}function bG0(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=ix($);if(X&&X.has(D))return X.get(D);var J={__proto__:null},Y=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var U=Y?Object.getOwnPropertyDescriptor(D,Q):null;U&&(U.get||U.set)?Object.defineProperty(J,Q,U):J[Q]=D[Q]}return J.default=D,X&&X.set(D,J),J}function hG0(D){return D&&D.__esModule?D:{default:D}}function i3(D){return i3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},i3(D)}function gG0(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function nx(D,$){for(var X=0;X<$.length;X++){var J=$[X];if(J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J)J.writable=!0;Object.defineProperty(D,cG0(J.key),J)}}function mG0(D,$,X){if($)nx(D.prototype,$);if(X)nx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function cG0(D){var $=dG0(D,"string");return i3($)=="symbol"?$:$+""}function dG0(D,$){if(i3(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var J=X.call(D,$||"default");if(i3(J)!="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var xp0=px.canStoreURLs=!0,vp0=px.FileUrlStorage=function(){function D($){gG0(this,D),this.path=$}return mG0(D,[{key:"findAllUploads",value:function(){var X=this;return new Promise(function(J,Y){X._getItems("tus::",function(Q,U){if(Q)Y(Q);else J(U)})})}},{key:"findUploadsByFingerprint",value:function(X){var J=this;return new Promise(function(Y,Q){J._getItems("tus::".concat(X),function(U,F){if(U)Q(U);else Y(F)})})}},{key:"removeUpload",value:function(X){var J=this;return new Promise(function(Y,Q){J._removeItem(X,function(U){if(U)Q(U);else Y()})})}},{key:"addUpload",value:function(X,J){var Y=this,Q=Math.round(Math.random()*1000000000000),U="tus::".concat(X,"::").concat(Q);return new Promise(function(F,Z){Y._setItem(U,J,function(O){if(O)Z(O);else F(U)})})}},{key:"_setItem",value:function(X,J,Y){var Q=this;lx.lock(this.path,this._lockfileOptions()).then(function(U){Y=Q._releaseAndCb(U,Y),Q._getData(function(F,Z){if(F){Y(F);return}Z[X]=J,Q._writeData(Z,function(O){return Y(O)})})}).catch(Y)}},{key:"_getItems",value:function(X,J){this._getData(function(Y,Q){if(Y){J(Y);return}var U=Object.keys(Q).filter(function(F){return F.startsWith(X)}).map(function(F){var Z=Q[F];return Z.urlStorageKey=F,Z});J(null,U)})}},{key:"_removeItem",value:function(X,J){var Y=this;lx.lock(this.path,this._lockfileOptions()).then(function(Q){J=Y._releaseAndCb(Q,J),Y._getData(function(U,F){if(U){J(U);return}delete F[X],Y._writeData(F,function(Z){return J(Z)})})}).catch(J)}},{key:"_lockfileOptions",value:function(){return{realpath:!1,retries:{retries:5,minTimeout:20}}}},{key:"_releaseAndCb",value:function(X,J){return function(Y){if(Y){X().then(function(){return J(Y)}).catch(function(Q){return J((0,yG0.default)([Y,Q]))});return}X().then(J).catch(J)}}},{key:"_writeData",value:function(X,J){var Y={encoding:"utf8",mode:432,flag:"w"};(0,dx.writeFile)(this.path,JSON.stringify(X),Y,function(Q){return J(Q)})}},{key:"_getData",value:function(X){(0,dx.readFile)(this.path,"utf8",function(J,Y){if(J){if(J.code==="ENOENT")X(null,{});else X(J);return}try{Y=!Y.trim().length?{}:JSON.parse(Y)}catch(Q){X(Q);return}X(null,Y)})}}])}()});var GQ=E((X4)=>{Object.defineProperty(X4,"__esModule",{value:!0});Object.defineProperty(X4,"DefaultHttpStack",{enumerable:!0,get:function(){return ex.default}});Object.defineProperty(X4,"DetailedError",{enumerable:!0,get:function(){return nG0.default}});Object.defineProperty(X4,"FileUrlStorage",{enumerable:!0,get:function(){return Dv.FileUrlStorage}});Object.defineProperty(X4,"StreamSource",{enumerable:!0,get:function(){return tG0.default}});X4.Upload=void 0;Object.defineProperty(X4,"canStoreURLs",{enumerable:!0,get:function(){return Dv.canStoreURLs}});X4.defaultOptions=void 0;Object.defineProperty(X4,"enableDebugLog",{enumerable:!0,get:function(){return iG0.enableDebugLog}});X4.isSupported=void 0;var nG0=M8(vq()),iG0=_q(),pG0=M8(cP()),_w=M8(MS()),rG0=M8(mS()),oG0=M8(iS()),ex=M8(Zu()),tG0=M8(nq()),Dv=ox();function M8(D){return D&&D.__esModule?D:{default:D}}function Y5(D){return Y5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},Y5(D)}function aG0(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function tx(D,$){for(var X=0;X<$.length;X++){var J=$[X];if(J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J)J.writable=!0;Object.defineProperty(D,Xv(J.key),J)}}function sG0(D,$,X){if($)tx(D.prototype,$);if(X)tx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function eG0(D,$,X){return $=OQ($),Dq0(D,$v()?Reflect.construct($,X||[],OQ(D).constructor):$.apply(D,X))}function Dq0(D,$){if($&&(Y5($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return $q0(D)}function $q0(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function $v(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return($v=function(){return!!D})()}function OQ(D){return OQ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},OQ(D)}function Xq0(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}),$)kw(D,$)}function kw(D,$){return kw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(J,Y){return J.__proto__=Y,J},kw(D,$)}function ax(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(D);$&&(J=J.filter(function(Y){return Object.getOwnPropertyDescriptor(D,Y).enumerable})),X.push.apply(X,J)}return X}function J5(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?ax(Object(X),!0).forEach(function(J){Jq0(D,J,X[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):ax(Object(X)).forEach(function(J){Object.defineProperty(D,J,Object.getOwnPropertyDescriptor(X,J))})}return D}function Jq0(D,$,X){if($=Xv($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function Xv(D){var $=Yq0(D,"string");return Y5($)=="symbol"?$:$+""}function Yq0(D,$){if(Y5(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var J=X.call(D,$||"default");if(Y5(J)!="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var sx=X4.defaultOptions=J5(J5({},_w.default.defaultOptions),{},{httpStack:new ex.default,fileReader:new rG0.default,urlStorage:new pG0.default,fingerprint:oG0.default}),kp0=X4.Upload=function(D){function $(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return aG0(this,$),J=J5(J5({},sx),J),eG0(this,$,[X,J])}return Xq0($,D),sG0($,null,[{key:"terminate",value:function(J){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Y=J5(J5({},sx),Y),_w.default.terminate(J,Y)}}])}(_w.default),fp0=X4.isSupported=!0});var R$;var p3=o(()=>{R$={name:"@capgo/cli",type:"module",version:"7.89.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","tanstack-intent"],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"},files:["!skills/_artifacts","dist","skills"],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:ci-prompts":"bun test/test-ci-prompts.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.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:ci-prompts && bun run test:prompt-preferences && 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.5","@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","@tanstack/intent":"^0.0.23","@types/adm-zip":"^0.5.7","@types/jsonwebtoken":"^9.0.10","@types/node":"^25.0.0","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^18.3.28","@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",partysocket:"^1.1.11",prettyjson:"^1.2.5",tmp:"^0.2.5","tus-js-client":"^4.3.1",typescript:"^5.9.3",ws:"^8.18.3",zod:"^4.3.6"},dependencies:{"@inkjs/ui":"^2.0.0",ink:"^5.2.1","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.3.3",qrcode:"^1.5.4",react:"^18.3.1"}}});async function qQ(D){try{let X=`https://registry.npmjs.org/${encodeURIComponent(D.toLowerCase())}`,J=await fetch(X,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});if(!J.ok)return null;return(await J.json())["dist-tags"]?.latest||null}catch{return null}}async function Uq0(){let D=await qQ("@capgo/cli")??"",$=D?.split(".")[0]??"";return{currentVersion:R$.version,latestVersion:D,isOutdated:!!D&&D!==R$.version,majorVersion:$}}async function FD(){let{isOutdated:D,currentVersion:$,latestVersion:X,majorVersion:J}=await Uq0();if(D)N.warning(`\uD83D\uDEA8 You are using @capgo/cli@${$} it's not the latest version.
130
+ GFS4: `),console.error(D)};if(!ID[eD]){if(Lw=global[eD]||[],jx(ID,Lw),ID.close=function(D){function $(X,J){return D.call(ID,X,function(Y){if(!Y)Ex();if(typeof J==="function")J.apply(this,arguments)})}return Object.defineProperty($,$Q,{value:D}),$}(ID.close),ID.closeSync=function(D){function $(X){D.apply(ID,arguments),Ex()}return Object.defineProperty($,$Q,{value:D}),$}(ID.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){W8(ID[eD]),l("assert").equal(ID[eD].length,0)})}var Lw;if(!global[eD])jx(global,ID[eD]);Aw.exports=Mw(YG0(ID));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!ID.__patched)Aw.exports=Mw(ID),ID.__patched=!0;function Mw(D){XG0(D),D.gracefulify=Mw,D.createReadStream=L,D.createWriteStream=R;var $=D.readFile;D.readFile=X;function X(_,x,S){if(typeof x==="function")S=x,x=null;return h(_,x,S);function h(b,n,f,j){return $(b,n,function(u){if(u&&(u.code==="EMFILE"||u.code==="ENFILE"))e9([h,[b,n,f],u,j||Date.now(),Date.now()]);else if(typeof f==="function")f.apply(this,arguments)})}}var J=D.writeFile;D.writeFile=Y;function Y(_,x,S,h){if(typeof S==="function")h=S,S=null;return b(_,x,S,h);function b(n,f,j,u,v){return J(n,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))e9([b,[n,f,j,u],y,v||Date.now(),Date.now()]);else if(typeof u==="function")u.apply(this,arguments)})}}var Q=D.appendFile;if(Q)D.appendFile=U;function U(_,x,S,h){if(typeof S==="function")h=S,S=null;return b(_,x,S,h);function b(n,f,j,u,v){return Q(n,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))e9([b,[n,f,j,u],y,v||Date.now(),Date.now()]);else if(typeof u==="function")u.apply(this,arguments)})}}var F=D.copyFile;if(F)D.copyFile=Z;function Z(_,x,S,h){if(typeof S==="function")h=S,S=0;return b(_,x,S,h);function b(n,f,j,u,v){return F(n,f,j,function(y){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))e9([b,[n,f,j,u],y,v||Date.now(),Date.now()]);else if(typeof u==="function")u.apply(this,arguments)})}}var O=D.readdir;D.readdir=q;var G=/^v[0-5]\./;function q(_,x,S){if(typeof x==="function")S=x,x=null;var h=G.test(process.version)?function(f,j,u,v){return O(f,b(f,j,u,v))}:function(f,j,u,v){return O(f,j,b(f,j,u,v))};return h(_,x,S);function b(n,f,j,u){return function(v,y){if(v&&(v.code==="EMFILE"||v.code==="ENFILE"))e9([h,[n,f,j],v,u||Date.now(),Date.now()]);else{if(y&&y.sort)y.sort();if(typeof j==="function")j.call(this,v,y)}}}}if(process.version.substr(0,4)==="v0.8"){var w=JG0(D);M=w.ReadStream,z=w.WriteStream}var B=D.ReadStream;if(B)M.prototype=Object.create(B.prototype),M.prototype.open=I;var K=D.WriteStream;if(K)z.prototype=Object.create(K.prototype),z.prototype.open=V;Object.defineProperty(D,"ReadStream",{get:function(){return M},set:function(_){M=_},enumerable:!0,configurable:!0}),Object.defineProperty(D,"WriteStream",{get:function(){return z},set:function(_){z=_},enumerable:!0,configurable:!0});var H=M;Object.defineProperty(D,"FileReadStream",{get:function(){return H},set:function(_){H=_},enumerable:!0,configurable:!0});var W=z;Object.defineProperty(D,"FileWriteStream",{get:function(){return W},set:function(_){W=_},enumerable:!0,configurable:!0});function M(_,x){if(this instanceof M)return B.apply(this,arguments),this;else return M.apply(Object.create(M.prototype),arguments)}function I(){var _=this;A(_.path,_.flags,_.mode,function(x,S){if(x){if(_.autoClose)_.destroy();_.emit("error",x)}else _.fd=S,_.emit("open",S),_.read()})}function z(_,x){if(this instanceof z)return K.apply(this,arguments),this;else return z.apply(Object.create(z.prototype),arguments)}function V(){var _=this;A(_.path,_.flags,_.mode,function(x,S){if(x)_.destroy(),_.emit("error",x);else _.fd=S,_.emit("open",S)})}function L(_,x){return new D.ReadStream(_,x)}function R(_,x){return new D.WriteStream(_,x)}var C=D.open;D.open=A;function A(_,x,S,h){if(typeof S==="function")h=S,S=null;return b(_,x,S,h);function b(n,f,j,u,v){return C(n,f,j,function(y,g){if(y&&(y.code==="EMFILE"||y.code==="ENFILE"))e9([b,[n,f,j,u],y,v||Date.now(),Date.now()]);else if(typeof u==="function")u.apply(this,arguments)})}}return D}function e9(D){W8("ENQUEUE",D[0].name,D[1]),ID[eD].push(D),Iw()}var DQ;function Ex(){var D=Date.now();for(var $=0;$<ID[eD].length;++$)if(ID[eD][$].length>2)ID[eD][$][3]=D,ID[eD][$][4]=D;Iw()}function Iw(){if(clearTimeout(DQ),DQ=void 0,ID[eD].length===0)return;var D=ID[eD].shift(),$=D[0],X=D[1],J=D[2],Y=D[3],Q=D[4];if(Y===void 0)W8("RETRY",$.name,X),$.apply(null,X);else if(Date.now()-Y>=60000){W8("TIMEOUT",$.name,X);var U=X.pop();if(typeof U==="function")U.call(null,J)}else{var F=Date.now()-Q,Z=Math.max(Q-Y,1),O=Math.min(Z*1.2,100);if(F>=O)W8("RETRY",$.name,X),$.apply(null,X.concat([Y]));else ID[eD].push(D)}if(DQ===void 0)DQ=setTimeout(Iw,0)}});var Cx=E((jp0,Tx)=>{function Q$(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)}Tx.exports=Q$;Q$.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Q$.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};Q$.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 J=this,Y=setTimeout(function(){if(J._attempts++,J._operationTimeoutCb){if(J._timeout=setTimeout(function(){J._operationTimeoutCb(J._attempts)},J._operationTimeout),J._options.unref)J._timeout.unref()}J._fn(J._attempts)},X);if(this._options.unref)Y.unref();return!0};Q$.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)};Q$.prototype.try=function(D){console.log("Using RetryOperation.try() is deprecated"),this.attempt(D)};Q$.prototype.start=function(D){console.log("Using RetryOperation.start() is deprecated"),this.attempt(D)};Q$.prototype.start=Q$.prototype.try;Q$.prototype.errors=function(){return this._errors};Q$.prototype.attempts=function(){return this._attempts};Q$.prototype.mainError=function(){if(this._errors.length===0)return null;var D={},$=null,X=0;for(var J=0;J<this._errors.length;J++){var Y=this._errors[J],Q=Y.message,U=(D[Q]||0)+1;if(D[Q]=U,U>=X)$=Y,X=U}return $}});var Sx=E((FG0)=>{var UG0=Cx();FG0.operation=function(D){var $=FG0.timeouts(D);return new UG0($,{forever:D&&D.forever,unref:D&&D.unref,maxRetryTime:D&&D.maxRetryTime})};FG0.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 J=[];for(var Y=0;Y<$.retries;Y++)J.push(this.createTimeout(Y,$));if(D&&D.forever&&!J.length)J.push(this.createTimeout(Y,$));return J.sort(function(Q,U){return Q-U}),J};FG0.createTimeout=function(D,$){var X=$.randomize?Math.random()+1:1,J=Math.round(X*$.minTimeout*Math.pow($.factor,D));return J=Math.min(J,$.maxTimeout),J};FG0.wrap=function(D,$,X){if($ instanceof Array)X=$,$=null;if(!X){X=[];for(var J in D)if(typeof D[J]==="function")X.push(J)}for(var Y=0;Y<X.length;Y++){var Q=X[Y],U=D[Q];D[Q]=function(Z){var O=FG0.operation($),G=Array.prototype.slice.call(arguments,1),q=G.pop();G.push(function(w){if(O.retry(w))return;if(w)arguments[0]=O.mainError();q.apply(this,arguments)}),O.attempt(function(){Z.apply(D,G)})}.bind(D,U),D[Q].options=$}}});var ux=E((Cp0,XQ)=>{XQ.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")XQ.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")XQ.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var QQ=E((Pp0,$5)=>{var VD=global.process,V8=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(!V8(VD))$5.exports=function(){return function(){}};else{if(Rw=l("assert"),N8=ux(),Ew=/^win/i.test(VD.platform),D5=l("events"),typeof D5!=="function")D5=D5.EventEmitter;if(VD.__signal_exit_emitter__)dD=VD.__signal_exit_emitter__;else dD=VD.__signal_exit_emitter__=new D5,dD.count=0,dD.emitted={};if(!dD.infinite)dD.setMaxListeners(1/0),dD.infinite=!0;$5.exports=function(D,$){if(!V8(global.process))return function(){};if(Rw.equal(typeof D,"function","a callback must be provided for exit handler"),L8===!1)JQ();var X="exit";if($&&$.alwaysLast)X="afterexit";var J=function(){if(dD.removeListener(X,D),dD.listeners("exit").length===0&&dD.listeners("afterexit").length===0)m3()};return dD.on(X,D),J},m3=function(){if(!L8||!V8(global.process))return;L8=!1,N8.forEach(function($){try{VD.removeListener($,c3[$])}catch(X){}}),VD.emit=d3,VD.reallyExit=YQ,dD.count-=1},$5.exports.unload=m3,D4=function($,X,J){if(dD.emitted[$])return;dD.emitted[$]=!0,dD.emit($,X,J)},c3={},N8.forEach(function(D){c3[D]=function(){if(!V8(global.process))return;var X=VD.listeners(D);if(X.length===dD.count){if(m3(),D4("exit",null,D),D4("afterexit",null,D),Ew&&D==="SIGHUP")D="SIGINT";VD.kill(VD.pid,D)}}}),$5.exports.signals=function(){return N8},L8=!1,JQ=function(){if(L8||!V8(global.process))return;L8=!0,dD.count+=1,N8=N8.filter(function($){try{return VD.on($,c3[$]),!0}catch(X){return!1}}),VD.emit=Tw,VD.reallyExit=jw},$5.exports.load=JQ,YQ=VD.reallyExit,jw=function($){if(!V8(global.process))return;VD.exitCode=$||0,D4("exit",VD.exitCode,null),D4("afterexit",VD.exitCode,null),YQ.call(VD,VD.exitCode)},d3=VD.emit,Tw=function($,X){if($==="exit"&&V8(global.process)){if(X!==void 0)VD.exitCode=X;var J=d3.apply(this,arguments);return D4("exit",VD.exitCode,null),D4("afterexit",VD.exitCode,null),J}else return d3.apply(this,arguments)}}var Rw,N8,Ew,D5,dD,m3,D4,c3,L8,JQ,YQ,jw,d3,Tw});var vx=E((BG0,Cw)=>{var xx=Symbol();function qG0(D,$,X){let J=$[xx];if(J)return $.stat(D,(Q,U)=>{if(Q)return X(Q);X(null,U.mtime,J)});let Y=new Date(Math.ceil(Date.now()/1000)*1000+5);$.utimes(D,Y,Y,(Q)=>{if(Q)return X(Q);$.stat(D,(U,F)=>{if(U)return X(U);let Z=F.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty($,xx,{value:Z}),X(null,F.mtime,Z)})})}function wG0(D){let $=Date.now();if(D==="s")$=Math.ceil($/1000)*1000;return new Date($)}BG0.probe=qG0;BG0.getMtime=wG0});var bx=E((IG0,n3)=>{var zG0=l("path"),uw=xD(),WG0=Sx(),VG0=QQ(),_x=vx(),W6={};function l3(D,$){return $.lockfilePath||`${D}.lock`}function xw(D,$,X){if(!$.realpath)return X(null,zG0.resolve(D));$.fs.realpath(D,X)}function Sw(D,$,X){let J=l3(D,$);$.fs.mkdir(J,(Y)=>{if(!Y)return _x.probe(J,$.fs,(Q,U,F)=>{if(Q)return $.fs.rmdir(J,()=>{}),X(Q);X(null,U,F)});if(Y.code!=="EEXIST")return X(Y);if($.stale<=0)return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));$.fs.stat(J,(Q,U)=>{if(Q){if(Q.code==="ENOENT")return Sw(D,{...$,stale:0},X);return X(Q)}if(!kx(U,$))return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));fx(D,$,(F)=>{if(F)return X(F);Sw(D,{...$,stale:0},X)})})})}function kx(D,$){return D.mtime.getTime()<Date.now()-$.stale}function fx(D,$,X){$.fs.rmdir(l3(D,$),(J)=>{if(J&&J.code!=="ENOENT")return X(J);X()})}function UQ(D,$){let X=W6[D];if(X.updateTimeout)return;if(X.updateDelay=X.updateDelay||$.update,X.updateTimeout=setTimeout(()=>{X.updateTimeout=null,$.fs.stat(X.lockfilePath,(J,Y)=>{let Q=X.lastUpdate+$.stale<Date.now();if(J){if(J.code==="ENOENT"||Q)return Pw(D,X,Object.assign(J,{code:"ECOMPROMISED"}));return X.updateDelay=1000,UQ(D,$)}if(X.mtime.getTime()!==Y.mtime.getTime())return Pw(D,X,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let F=_x.getMtime(X.mtimePrecision);$.fs.utimes(X.lockfilePath,F,F,(Z)=>{let O=X.lastUpdate+$.stale<Date.now();if(X.released)return;if(Z){if(Z.code==="ENOENT"||O)return Pw(D,X,Object.assign(Z,{code:"ECOMPROMISED"}));return X.updateDelay=1000,UQ(D,$)}X.mtime=F,X.lastUpdate=Date.now(),X.updateDelay=null,UQ(D,$)})})},X.updateDelay),X.updateTimeout.unref)X.updateTimeout.unref()}function Pw(D,$,X){if($.released=!0,$.updateTimeout)clearTimeout($.updateTimeout);if(W6[D]===$)delete W6[D];$.options.onCompromised(X)}function NG0(D,$,X){$={stale:1e4,update:null,realpath:!0,retries:0,fs:uw,onCompromised:(J)=>{throw J},...$},$.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),xw(D,$,(J,Y)=>{if(J)return X(J);let Q=WG0.operation($.retries);Q.attempt(()=>{Sw(Y,$,(U,F,Z)=>{if(Q.retry(U))return;if(U)return X(Q.mainError());let O=W6[Y]={lockfilePath:l3(Y,$),mtime:F,mtimePrecision:Z,options:$,lastUpdate:Date.now()};UQ(Y,$),X(null,(G)=>{if(O.released)return G&&G(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));yx(Y,{...$,realpath:!1},G)})})})})}function yx(D,$,X){$={fs:uw,realpath:!0,...$},xw(D,$,(J,Y)=>{if(J)return X(J);let Q=W6[Y];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 W6[Y],fx(Y,$,X)})}function LG0(D,$,X){$={stale:1e4,realpath:!0,fs:uw,...$},$.stale=Math.max($.stale||0,2000),xw(D,$,(J,Y)=>{if(J)return X(J);$.fs.stat(l3(Y,$),(Q,U)=>{if(Q)return Q.code==="ENOENT"?X(null,!1):X(Q);return X(null,!kx(U,$))})})}function MG0(){return W6}VG0(()=>{for(let D in W6){let $=W6[D].options;try{$.fs.rmdirSync(l3(D,$))}catch(X){}}});IG0.lock=NG0;IG0.unlock=yx;IG0.check=LG0;IG0.getLocks=MG0});var gx=E((Sp0,hx)=>{var TG0=xD();function CG0(D){let $=["mkdir","realpath","stat","rmdir","utimes"],X={...D};return $.forEach((J)=>{X[J]=(...Y)=>{let Q=Y.pop(),U;try{U=D[`${J}Sync`](...Y)}catch(F){return Q(F)}Q(null,U)}}),X}function PG0(D){return(...$)=>new Promise((X,J)=>{$.push((Y,Q)=>{if(Y)J(Y);else X(Q)}),D(...$)})}function SG0(D){return(...$)=>{let X,J;if($.push((Y,Q)=>{X=Y,J=Q}),D(...$),X)throw X;return J}}function uG0(D){if(D={...D},D.fs=CG0(D.fs||TG0),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}hx.exports={toPromise:PG0,toSync:SG0,toSyncOptions:uG0}});var cx=E((up0,$4)=>{var X5=bx(),{toPromise:FQ,toSync:ZQ,toSyncOptions:vw}=gx();async function mx(D,$){let X=await FQ(X5.lock)(D,$);return FQ(X)}function xG0(D,$){let X=ZQ(X5.lock)(D,vw($));return ZQ(X)}function vG0(D,$){return FQ(X5.unlock)(D,$)}function _G0(D,$){return ZQ(X5.unlock)(D,vw($))}function kG0(D,$){return FQ(X5.check)(D,$)}function fG0(D,$){return ZQ(X5.check)(D,vw($))}$4.exports=mx;$4.exports.lock=mx;$4.exports.unlock=vG0;$4.exports.lockSync=xG0;$4.exports.unlockSync=_G0;$4.exports.check=kG0;$4.exports.checkSync=fG0});var ox=E((px)=>{Object.defineProperty(px,"__esModule",{value:!0});px.canStoreURLs=px.FileUrlStorage=void 0;var dx=l("fs"),yG0=hG0(Wx()),lx=bG0(cx());function ix(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(ix=function(J){return J?X:$})(D)}function bG0(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=ix($);if(X&&X.has(D))return X.get(D);var J={__proto__:null},Y=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var Q in D)if(Q!=="default"&&{}.hasOwnProperty.call(D,Q)){var U=Y?Object.getOwnPropertyDescriptor(D,Q):null;U&&(U.get||U.set)?Object.defineProperty(J,Q,U):J[Q]=D[Q]}return J.default=D,X&&X.set(D,J),J}function hG0(D){return D&&D.__esModule?D:{default:D}}function i3(D){return i3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},i3(D)}function gG0(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function nx(D,$){for(var X=0;X<$.length;X++){var J=$[X];if(J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J)J.writable=!0;Object.defineProperty(D,cG0(J.key),J)}}function mG0(D,$,X){if($)nx(D.prototype,$);if(X)nx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function cG0(D){var $=dG0(D,"string");return i3($)=="symbol"?$:$+""}function dG0(D,$){if(i3(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var J=X.call(D,$||"default");if(i3(J)!="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var xp0=px.canStoreURLs=!0,vp0=px.FileUrlStorage=function(){function D($){gG0(this,D),this.path=$}return mG0(D,[{key:"findAllUploads",value:function(){var X=this;return new Promise(function(J,Y){X._getItems("tus::",function(Q,U){if(Q)Y(Q);else J(U)})})}},{key:"findUploadsByFingerprint",value:function(X){var J=this;return new Promise(function(Y,Q){J._getItems("tus::".concat(X),function(U,F){if(U)Q(U);else Y(F)})})}},{key:"removeUpload",value:function(X){var J=this;return new Promise(function(Y,Q){J._removeItem(X,function(U){if(U)Q(U);else Y()})})}},{key:"addUpload",value:function(X,J){var Y=this,Q=Math.round(Math.random()*1000000000000),U="tus::".concat(X,"::").concat(Q);return new Promise(function(F,Z){Y._setItem(U,J,function(O){if(O)Z(O);else F(U)})})}},{key:"_setItem",value:function(X,J,Y){var Q=this;lx.lock(this.path,this._lockfileOptions()).then(function(U){Y=Q._releaseAndCb(U,Y),Q._getData(function(F,Z){if(F){Y(F);return}Z[X]=J,Q._writeData(Z,function(O){return Y(O)})})}).catch(Y)}},{key:"_getItems",value:function(X,J){this._getData(function(Y,Q){if(Y){J(Y);return}var U=Object.keys(Q).filter(function(F){return F.startsWith(X)}).map(function(F){var Z=Q[F];return Z.urlStorageKey=F,Z});J(null,U)})}},{key:"_removeItem",value:function(X,J){var Y=this;lx.lock(this.path,this._lockfileOptions()).then(function(Q){J=Y._releaseAndCb(Q,J),Y._getData(function(U,F){if(U){J(U);return}delete F[X],Y._writeData(F,function(Z){return J(Z)})})}).catch(J)}},{key:"_lockfileOptions",value:function(){return{realpath:!1,retries:{retries:5,minTimeout:20}}}},{key:"_releaseAndCb",value:function(X,J){return function(Y){if(Y){X().then(function(){return J(Y)}).catch(function(Q){return J((0,yG0.default)([Y,Q]))});return}X().then(J).catch(J)}}},{key:"_writeData",value:function(X,J){var Y={encoding:"utf8",mode:432,flag:"w"};(0,dx.writeFile)(this.path,JSON.stringify(X),Y,function(Q){return J(Q)})}},{key:"_getData",value:function(X){(0,dx.readFile)(this.path,"utf8",function(J,Y){if(J){if(J.code==="ENOENT")X(null,{});else X(J);return}try{Y=!Y.trim().length?{}:JSON.parse(Y)}catch(Q){X(Q);return}X(null,Y)})}}])}()});var GQ=E((X4)=>{Object.defineProperty(X4,"__esModule",{value:!0});Object.defineProperty(X4,"DefaultHttpStack",{enumerable:!0,get:function(){return ex.default}});Object.defineProperty(X4,"DetailedError",{enumerable:!0,get:function(){return nG0.default}});Object.defineProperty(X4,"FileUrlStorage",{enumerable:!0,get:function(){return Dv.FileUrlStorage}});Object.defineProperty(X4,"StreamSource",{enumerable:!0,get:function(){return tG0.default}});X4.Upload=void 0;Object.defineProperty(X4,"canStoreURLs",{enumerable:!0,get:function(){return Dv.canStoreURLs}});X4.defaultOptions=void 0;Object.defineProperty(X4,"enableDebugLog",{enumerable:!0,get:function(){return iG0.enableDebugLog}});X4.isSupported=void 0;var nG0=M8(vq()),iG0=_q(),pG0=M8(cP()),_w=M8(MS()),rG0=M8(mS()),oG0=M8(iS()),ex=M8(Zu()),tG0=M8(nq()),Dv=ox();function M8(D){return D&&D.__esModule?D:{default:D}}function Y5(D){return Y5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},Y5(D)}function aG0(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function tx(D,$){for(var X=0;X<$.length;X++){var J=$[X];if(J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J)J.writable=!0;Object.defineProperty(D,Xv(J.key),J)}}function sG0(D,$,X){if($)tx(D.prototype,$);if(X)tx(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function eG0(D,$,X){return $=OQ($),Dq0(D,$v()?Reflect.construct($,X||[],OQ(D).constructor):$.apply(D,X))}function Dq0(D,$){if($&&(Y5($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return $q0(D)}function $q0(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function $v(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return($v=function(){return!!D})()}function OQ(D){return OQ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},OQ(D)}function Xq0(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}),$)kw(D,$)}function kw(D,$){return kw=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(J,Y){return J.__proto__=Y,J},kw(D,$)}function ax(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(D);$&&(J=J.filter(function(Y){return Object.getOwnPropertyDescriptor(D,Y).enumerable})),X.push.apply(X,J)}return X}function J5(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?ax(Object(X),!0).forEach(function(J){Jq0(D,J,X[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):ax(Object(X)).forEach(function(J){Object.defineProperty(D,J,Object.getOwnPropertyDescriptor(X,J))})}return D}function Jq0(D,$,X){if($=Xv($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function Xv(D){var $=Yq0(D,"string");return Y5($)=="symbol"?$:$+""}function Yq0(D,$){if(Y5(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var J=X.call(D,$||"default");if(Y5(J)!="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var sx=X4.defaultOptions=J5(J5({},_w.default.defaultOptions),{},{httpStack:new ex.default,fileReader:new rG0.default,urlStorage:new pG0.default,fingerprint:oG0.default}),kp0=X4.Upload=function(D){function $(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return aG0(this,$),J=J5(J5({},sx),J),eG0(this,$,[X,J])}return Xq0($,D),sG0($,null,[{key:"terminate",value:function(J){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Y=J5(J5({},sx),Y),_w.default.terminate(J,Y)}}])}(_w.default),fp0=X4.isSupported=!0});var R$;var p3=o(()=>{R$={name:"@capgo/cli",type:"module",version:"7.89.6",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","tanstack-intent"],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"},files:["!skills/_artifacts","dist","skills"],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:ci-prompts":"bun test/test-ci-prompts.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.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:ci-prompts && bun run test:prompt-preferences && 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.5","@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","@tanstack/intent":"^0.0.23","@types/adm-zip":"^0.5.7","@types/jsonwebtoken":"^9.0.10","@types/node":"^25.0.0","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^18.3.28","@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",partysocket:"^1.1.11",prettyjson:"^1.2.5",tmp:"^0.2.5","tus-js-client":"^4.3.1",typescript:"^5.9.3",ws:"^8.18.3",zod:"^4.3.6"},dependencies:{"@inkjs/ui":"^2.0.0",ink:"^5.2.1","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.3.3",qrcode:"^1.5.4",react:"^18.3.1"}}});async function qQ(D){try{let X=`https://registry.npmjs.org/${encodeURIComponent(D.toLowerCase())}`,J=await fetch(X,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});if(!J.ok)return null;return(await J.json())["dist-tags"]?.latest||null}catch{return null}}async function Uq0(){let D=await qQ("@capgo/cli")??"",$=D?.split(".")[0]??"";return{currentVersion:R$.version,latestVersion:D,isOutdated:!!D&&D!==R$.version,majorVersion:$}}async function FD(){let{isOutdated:D,currentVersion:$,latestVersion:X,majorVersion:J}=await Uq0();if(D)N.warning(`\uD83D\uDEA8 You are using @capgo/cli@${$} it's not the latest version.
131
131
  Please use @capgo/cli@${X}" or @capgo/cli@${J} to keep up to date with the latest features and bug fixes.`)}var z1=o(()=>{x0();p3()});async function Uv(D,$,X,J,Y,Q="✅"){await A0(X,{channel:D,event:J,icon:Q,user_id:$,...Y?{tags:{"app-id":Y}}:{},notify:!1})}var Fv=o(()=>{x0();G6();z1();_0()});import{Buffer as Zv}from"node:buffer";import{createHash as Fq0}from"node:crypto";function Oq0(D){let $=4294967295;for(let X=0;X<D.length;X++){let J=D[X];$=Zq0[($^J)&255]^$>>>8}return $=$^4294967295,($>>>0).toString(16).padStart(8,"0")}async function J4(D,$="sha256"){let X=Zv.isBuffer(D)?D:Zv.from(D);if($==="crc32")return Oq0(X);let J=Fq0($);return J.update(X),J.digest("hex")}var Zq0;var r3=o(()=>{Zq0=(()=>{let D=[];for(let $=0;$<256;$++){let X=$;for(let J=0;J<8;J++)X=X&1?3988292384^X>>>1:X>>>1;D[$]=X}return D})()});var Gv=E((sp0,Ov)=>{var Q5=1000,U5=Q5*60,F5=U5*60,I8=F5*24,Gq0=I8*7,qq0=I8*365.25;Ov.exports=function(D,$){$=$||{};var X=typeof D;if(X==="string"&&D.length>0)return wq0(D);else if(X==="number"&&isFinite(D))return $.long?Kq0(D):Bq0(D);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(D))};function wq0(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]),J=($[2]||"ms").toLowerCase();switch(J){case"years":case"year":case"yrs":case"yr":case"y":return X*qq0;case"weeks":case"week":case"w":return X*Gq0;case"days":case"day":case"d":return X*I8;case"hours":case"hour":case"hrs":case"hr":case"h":return X*F5;case"minutes":case"minute":case"mins":case"min":case"m":return X*U5;case"seconds":case"second":case"secs":case"sec":case"s":return X*Q5;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return X;default:return}}function Bq0(D){var $=Math.abs(D);if($>=I8)return Math.round(D/I8)+"d";if($>=F5)return Math.round(D/F5)+"h";if($>=U5)return Math.round(D/U5)+"m";if($>=Q5)return Math.round(D/Q5)+"s";return D+"ms"}function Kq0(D){var $=Math.abs(D);if($>=I8)return wQ(D,$,I8,"day");if($>=F5)return wQ(D,$,F5,"hour");if($>=U5)return wQ(D,$,U5,"minute");if($>=Q5)return wQ(D,$,Q5,"second");return D+" ms"}function wQ(D,$,X,J){var Y=$>=X*1.5;return Math.round(D/X)+" "+J+(Y?"s":"")}});var fw=E((ep0,qv)=>{function Hq0(D){X.debug=X,X.default=X,X.coerce=Z,X.disable=U,X.enable=Y,X.enabled=F,X.humanize=Gv(),X.destroy=O,Object.keys(D).forEach((G)=>{X[G]=D[G]}),X.names=[],X.skips=[],X.formatters={};function $(G){let q=0;for(let w=0;w<G.length;w++)q=(q<<5)-q+G.charCodeAt(w),q|=0;return X.colors[Math.abs(q)%X.colors.length]}X.selectColor=$;function X(G){let q,w=null,B,K;function H(...W){if(!H.enabled)return;let M=H,I=Number(new Date),z=I-(q||I);if(M.diff=z,M.prev=q,M.curr=I,q=I,W[0]=X.coerce(W[0]),typeof W[0]!=="string")W.unshift("%O");let V=0;W[0]=W[0].replace(/%([a-zA-Z%])/g,(R,C)=>{if(R==="%%")return"%";V++;let A=X.formatters[C];if(typeof A==="function"){let _=W[V];R=A.call(M,_),W.splice(V,1),V--}return R}),X.formatArgs.call(M,W),(M.log||X.log).apply(M,W)}if(H.namespace=G,H.useColors=X.useColors(),H.color=X.selectColor(G),H.extend=J,H.destroy=X.destroy,Object.defineProperty(H,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(w!==null)return w;if(B!==X.namespaces)B=X.namespaces,K=X.enabled(G);return K},set:(W)=>{w=W}}),typeof X.init==="function")X.init(H);return H}function J(G,q){let w=X(this.namespace+(typeof q>"u"?":":q)+G);return w.log=this.log,w}function Y(G){X.save(G),X.namespaces=G,X.names=[],X.skips=[];let q=(typeof G==="string"?G:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let w of q)if(w[0]==="-")X.skips.push(w.slice(1));else X.names.push(w)}function Q(G,q){let w=0,B=0,K=-1,H=0;while(w<G.length)if(B<q.length&&(q[B]===G[w]||q[B]==="*"))if(q[B]==="*")K=B,H=w,B++;else w++,B++;else if(K!==-1)B=K+1,H++,w=H;else return!1;while(B<q.length&&q[B]==="*")B++;return B===q.length}function U(){let G=[...X.names,...X.skips.map((q)=>"-"+q)].join(",");return X.enable(""),G}function F(G){for(let q of X.skips)if(Q(G,q))return!1;for(let q of X.names)if(Q(G,q))return!0;return!1}function Z(G){if(G instanceof Error)return G.stack||G.message;return G}function O(){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}qv.exports=Hq0});var Bv=E((wv,BQ)=>{wv.formatArgs=Wq0;wv.save=Vq0;wv.load=Nq0;wv.useColors=zq0;wv.storage=Lq0();wv.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`.")}})();wv.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 zq0(){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 Wq0(D){if(D[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+D[0]+(this.useColors?"%c ":" ")+"+"+BQ.exports.humanize(this.diff),!this.useColors)return;let $="color: "+this.color;D.splice(1,0,$,"color: inherit");let X=0,J=0;D[0].replace(/%[a-zA-Z%]/g,(Y)=>{if(Y==="%%")return;if(X++,Y==="%c")J=X}),D.splice(J,0,$)}wv.log=console.debug||console.log||(()=>{});function Vq0(D){try{if(D)wv.storage.setItem("debug",D);else wv.storage.removeItem("debug")}catch($){}}function Nq0(){let D;try{D=wv.storage.getItem("debug")||wv.storage.getItem("DEBUG")}catch($){}if(!D&&typeof process<"u"&&"env"in process)D=process.env.DEBUG;return D}function Lq0(){try{return localStorage}catch(D){}}BQ.exports=fw()(wv);var{formatters:Mq0}=BQ.exports;Mq0.j=function(D){try{return JSON.stringify(D)}catch($){return"[UnexpectedJSONParseError]: "+$.message}}});var Hv=E(($r0,Kv)=>{Kv.exports=(D,$=process.argv)=>{let X=D.startsWith("-")?"":D.length===1?"-":"--",J=$.indexOf(X+D),Y=$.indexOf("--");return J!==-1&&(Y===-1||J<Y)}});var Vv=E((Xr0,Wv)=>{var Pq0=l("os"),zv=l("tty"),U$=Hv(),{env:rD}=process,Y4;if(U$("no-color")||U$("no-colors")||U$("color=false")||U$("color=never"))Y4=0;else if(U$("color")||U$("colors")||U$("color=true")||U$("color=always"))Y4=1;if("FORCE_COLOR"in rD)if(rD.FORCE_COLOR==="true")Y4=1;else if(rD.FORCE_COLOR==="false")Y4=0;else Y4=rD.FORCE_COLOR.length===0?1:Math.min(parseInt(rD.FORCE_COLOR,10),3);function yw(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function bw(D,$){if(Y4===0)return 0;if(U$("color=16m")||U$("color=full")||U$("color=truecolor"))return 3;if(U$("color=256"))return 2;if(D&&!$&&Y4===void 0)return 0;let X=Y4||0;if(rD.TERM==="dumb")return X;if(process.platform==="win32"){let J=Pq0.release().split(".");if(Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}if("CI"in rD){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((J)=>(J in rD))||rD.CI_NAME==="codeship")return 1;return X}if("TEAMCITY_VERSION"in rD)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(rD.TEAMCITY_VERSION)?1:0;if(rD.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in rD){let J=parseInt((rD.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(rD.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(rD.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(rD.TERM))return 1;if("COLORTERM"in rD)return 1;return X}function Sq0(D){let $=bw(D,D&&D.isTTY);return yw($)}Wv.exports={supportsColor:Sq0,stdout:yw(bw(!0,zv.isatty(1))),stderr:yw(bw(!0,zv.isatty(2)))}});var Iv=E((Lv,HQ)=>{var uq0=l("tty"),KQ=l("util");Lv.init=bq0;Lv.log=kq0;Lv.formatArgs=vq0;Lv.save=fq0;Lv.load=yq0;Lv.useColors=xq0;Lv.destroy=KQ.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Lv.colors=[6,2,3,4,5,1];try{let D=Vv();if(D&&(D.stderr||D).level>=2)Lv.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){}Lv.inspectOpts=Object.keys(process.env).filter((D)=>{return/^debug_/i.test(D)}).reduce((D,$)=>{let X=$.substring(6).toLowerCase().replace(/_([a-z])/g,(Y,Q)=>{return Q.toUpperCase()}),J=process.env[$];if(/^(yes|on|true|enabled)$/i.test(J))J=!0;else if(/^(no|off|false|disabled)$/i.test(J))J=!1;else if(J==="null")J=null;else J=Number(J);return D[X]=J,D},{});function xq0(){return"colors"in Lv.inspectOpts?Boolean(Lv.inspectOpts.colors):uq0.isatty(process.stderr.fd)}function vq0(D){let{namespace:$,useColors:X}=this;if(X){let J=this.color,Y="\x1B[3"+(J<8?J:"8;5;"+J),Q=` ${Y};1m${$} \x1B[0m`;D[0]=Q+D[0].split(`
132
132
  `).join(`
133
133
  `+Q),D.push(Y+"m+"+HQ.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=_q0()+$+" "+D[0]}function _q0(){if(Lv.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function kq0(...D){return process.stderr.write(KQ.formatWithOptions(Lv.inspectOpts,...D)+`
@@ -376,7 +376,7 @@ Please generate a new API key with a shorter expiration:
376
376
  4. Try this command again`}});import Us from"node:fs";function rS0(){try{return Us.statSync("/.dockerenv"),!0}catch{return!1}}function oS0(){try{return Us.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function LM(){if(NM===void 0)NM=rS0()||oS0();return NM}var NM;var Fs=()=>{};import tS0 from"node:fs";function p8(){if(MM===void 0)MM=aS0()||LM();return MM}var MM,aS0=()=>{try{return tS0.statSync("/run/.containerenv"),!0}catch{return!1}};var IM=o(()=>{Fs()});import Os from"node:process";import sS0 from"node:os";import AM from"node:fs";var Zs=()=>{if(Os.platform!=="linux")return!1;if(sS0.release().toLowerCase().includes("microsoft")){if(p8())return!1;return!0}try{if(AM.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!p8()}catch{}if(AM.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||AM.existsSync("/run/WSL"))return!p8();return!1},x6;var RM=o(()=>{IM();x6=Os.env.__IS_WSL_TEST__?Zs:Zs()});import Gs from"node:process";import{Buffer as eS0}from"node:buffer";import{promisify as Du0}from"node:util";import $u0 from"node:child_process";var Xu0,EM=()=>`${Gs.env.SYSTEMROOT||Gs.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,a1=async(D,$={})=>{let{powerShellPath:X,...J}=$,Y=a1.encodeCommand(D);return Xu0(X??EM(),[...a1.argumentsPrefix,Y],{encoding:"utf8",...J})};var jM=o(()=>{Xu0=Du0($u0.execFile);a1.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];a1.encodeCommand=(D)=>eS0.from(D,"utf16le").toString("base64");a1.escapeArgument=(D)=>`'${String(D).replaceAll("'","''")}'`});function qs(D){for(let $ of D.split(`
377
377
  `)){if(/^\s*#/.test($))continue;let X=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec($);if(!X)continue;return X.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}import{promisify as Ju0}from"node:util";import Yu0 from"node:child_process";import TM,{constants as Bs}from"node:fs/promises";var Qu0,Uu0,Fu0=async()=>{return`${await Uu0()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},gZ,ws,Ks=async()=>{return ws??=(async()=>{try{let D=await gZ();return await TM.access(D,Bs.X_OK),!0}catch{return!1}})(),ws},Hs=async()=>{let D=await gZ(),$=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:X}=await a1($,{powerShellPath:D});return X.trim()},zs=async(D)=>{if(/^[a-z]+:\/\//i.test(D))return D;try{let{stdout:$}=await Qu0("wslpath",["-aw",D],{encoding:"utf8"});return $.trim()}catch{return D}};var Ws=o(()=>{RM();jM();RM();Qu0=Ju0(Yu0.execFile),Uu0=(()=>{let $;return async function(){if($)return $;let X="/etc/wsl.conf",J=!1;try{await TM.access(X,Bs.F_OK),J=!0}catch{}if(!J)return"/mnt/";let Y=await TM.readFile(X,{encoding:"utf8"}),Q=qs(Y);if(Q===void 0)return"/mnt/";return $=Q,$=$.endsWith("/")?$:`${$}/`,$}})(),gZ=x6?Fu0:EM});function r8(D,$,X){let J=(Y)=>Object.defineProperty(D,$,{value:Y,enumerable:!0,writable:!0});return Object.defineProperty(D,$,{configurable:!0,enumerable:!0,get(){let Y=X();return J(Y),Y},set(Y){J(Y)}}),D}import{promisify as Zu0}from"node:util";import Ou0 from"node:process";import{execFile as Gu0}from"node:child_process";async function CM(){if(Ou0.platform!=="darwin")throw Error("macOS only");let{stdout:D}=await qu0("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),X=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(D)?.groups.id??"com.apple.Safari";if(X==="com.apple.safari")return"com.apple.Safari";return X}var qu0;var Vs=o(()=>{qu0=Zu0(Gu0)});import wu0 from"node:process";import{promisify as Bu0}from"node:util";import{execFile as Ku0,execFileSync as n1D}from"node:child_process";async function Ns(D,{humanReadableOutput:$=!0,signal:X}={}){if(wu0.platform!=="darwin")throw Error("macOS only");let J=$?[]:["-ss"],Y={};if(X)Y.signal=X;let{stdout:Q}=await Hu0("osascript",["-e",D,J],Y);return Q.trim()}var Hu0;var Ls=o(()=>{Hu0=Bu0(Ku0)});async function PM(D){return Ns(`tell application "Finder" to set app_path to application file id "${D}" as string
378
378
  tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var Ms=o(()=>{Ls()});import{promisify as zu0}from"node:util";import{execFile as Wu0}from"node:child_process";async function SM(D=Vu0){let{stdout:$}=await D("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),X=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec($);if(!X)throw new Is(`Cannot find Windows browser in stdout: ${JSON.stringify($)}`);let{id:J}=X.groups,Y=J.lastIndexOf("."),Q=J.lastIndexOf("-"),U=Y===-1?void 0:J.slice(0,Y),F=Q===-1?void 0:J.slice(0,Q);return mZ[J]??mZ[U]??mZ[F]??{name:J,id:J}}var Vu0,mZ,cZ,Is;var uM=o(()=>{Vu0=zu0(Wu0),mZ={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},cZ=new Map(Object.entries(mZ));Is=class Is extends Error{}});import{promisify as Nu0}from"node:util";import xM from"node:process";import{execFile as Lu0}from"node:child_process";async function vM(){if(xM.platform==="darwin"){let D=await CM();return{name:await PM(D),id:D}}if(xM.platform==="linux"){let{stdout:D}=await Mu0("xdg-mime",["query","default","x-scheme-handler/http"]),$=D.trim();return{name:Iu0($.replace(/.desktop$/,"").replace("-"," ")),id:$}}if(xM.platform==="win32")return SM();throw Error("Only macOS, Linux, and Windows are supported")}var Mu0,Iu0=(D)=>D.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,($)=>$.toUpperCase());var As=o(()=>{Vs();Ms();uM();uM();Mu0=Nu0(Lu0)});import _M from"node:process";var Au0,Rs;var Es=o(()=>{Au0=Boolean(_M.env.SSH_CONNECTION||_M.env.SSH_CLIENT||_M.env.SSH_TTY),Rs=Au0});var yM={};X$(yM,{openApp:()=>Pu0,default:()=>Su0,apps:()=>o8});import kM from"node:process";import Ss from"node:path";import{fileURLToPath as Ru0}from"node:url";import Eu0 from"node:child_process";import ju0,{constants as Tu0}from"node:fs/promises";function Ps(D){if(typeof D==="string"||Array.isArray(D))return D;let{[Ts]:$}=D;if(!$)throw Error(`${Ts} is not supported`);return $}function kX({[B7]:D},{wsl:$}={}){if($&&x6)return Ps($);if(!D)throw Error(`${B7} is not supported`);return Ps(D)}var dZ,fM,js,B7,Ts,Cs=async(D,$)=>{if(D.length===0)return;let X=[];for(let J of D)try{return await $(J)}catch(Y){X.push(Y)}throw AggregateError(X,"Failed to open in all supported apps")},_X=async(D)=>{D={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...D};let $=D[dZ]===!0;if(delete D[dZ],Array.isArray(D.app))return Cs(D.app,(O)=>_X({...D,app:O,[dZ]:!0}));let{name:X,arguments:J=[]}=D.app??{};if(J=[...J],Array.isArray(X))return Cs(X,(O)=>_X({...D,app:{name:O,arguments:J},[dZ]:!0}));if(X==="browser"||X==="browserPrivate"){let O={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},G={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},q;if(x6){let w=await Hs();q=cZ.get(w)??{}}else q=await vM();if(q.id in O){let w=O[q.id.toLowerCase()];if(X==="browserPrivate"){if(w==="safari")throw Error("Safari doesn't support opening in private mode via command line");J.push(G[w])}return _X({...D,app:{name:o8[w],arguments:J}})}throw Error(`${q.name} is not supported as a default browser`)}let Y,Q=[],U={},F=!1;if(x6&&!p8()&&!Rs&&!X)F=await Ks();if(B7==="darwin"){if(Y="open",D.wait)Q.push("--wait-apps");if(D.background)Q.push("--background");if(D.newInstance)Q.push("--new");if(X)Q.push("-a",X)}else if(B7==="win32"||F){if(Y=await gZ(),Q.push(...a1.argumentsPrefix),!x6)U.windowsVerbatimArguments=!0;if(x6&&D.target)D.target=await zs(D.target);let O=["$ProgressPreference = 'SilentlyContinue';","Start"];if(D.wait)O.push("-Wait");if(X){if(O.push(a1.escapeArgument(X)),D.target)J.push(D.target)}else if(D.target)O.push(a1.escapeArgument(D.target));if(J.length>0)J=J.map((G)=>a1.escapeArgument(G)),O.push("-ArgumentList",J.join(","));if(D.target=a1.encodeCommand(O.join(" ")),!D.wait)U.stdio="ignore"}else{if(X)Y=X;else{let O=!fM||fM==="/",G=!1;try{await ju0.access(js,Tu0.X_OK),G=!0}catch{}Y=kM.versions.electron??(B7==="android"||O||!G)?"xdg-open":js}if(J.length>0)Q.push(...J);if(!D.wait)U.stdio="ignore",U.detached=!0}if(B7==="darwin"&&J.length>0)Q.push("--args",...J);if(D.target)Q.push(D.target);let Z=Eu0.spawn(Y,Q,U);if(D.wait)return new Promise((O,G)=>{Z.once("error",G),Z.once("close",(q)=>{if(!D.allowNonzeroExitCode&&q!==0){G(Error(`Exited with code ${q}`));return}O(Z)})});if($)return new Promise((O,G)=>{Z.once("error",G),Z.once("spawn",()=>{Z.once("close",(q)=>{if(Z.off("error",G),q!==0){G(Error(`Exited with code ${q}`));return}Z.unref(),O(Z)})})});return Z.unref(),new Promise((O,G)=>{Z.once("error",G),Z.once("spawn",()=>{Z.off("error",G),O(Z)})})},Cu0=(D,$)=>{if(typeof D!=="string")throw TypeError("Expected a `target`");return _X({...$,target:D})},Pu0=(D,$)=>{if(typeof D!=="string"&&!Array.isArray(D))throw TypeError("Expected a valid `name`");let{arguments:X=[]}=$??{};if(X!==void 0&&X!==null&&!Array.isArray(X))throw TypeError("Expected `appArguments` as Array type");return _X({...$,app:{name:D,arguments:X}})},o8,Su0;var bM=o(()=>{Ws();jM();As();IM();Es();dZ=Symbol("fallbackAttempt"),fM=import.meta.url?Ss.dirname(Ru0(import.meta.url)):"",js=Ss.join(fM,"xdg-open"),{platform:B7,arch:Ts}=kM;o8={browser:"browser",browserPrivate:"browserPrivate"};r8(o8,"chrome",()=>kX({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));r8(o8,"brave",()=>kX({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));r8(o8,"firefox",()=>kX({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));r8(o8,"edge",()=>kX({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));r8(o8,"safari",()=>kX({darwin:"Safari"}));Su0=Cu0});import{spawn as uu0}from"node:child_process";import{existsSync as GD,readdirSync as bX,readFileSync as gD,statSync as xu0}from"node:fs";import{homedir as vu0,platform as _u0}from"node:os";import hX,{dirname as yX,join as f0,relative as fs,resolve as H7,sep as ys}from"node:path";import{cwd as Q6,env as ku0,stdin as fu0,stdout as yu0}from"node:process";function s(D){if(!D)return"Unknown error";if(w7(D).isSecurityPolicyError)return VM(D);let X=D;if(typeof D==="string")return D;if(D instanceof Error){let J=X.message||X.cause?.message||X.stack||D.name,Y=X.cause?.name,Q=J.toLowerCase();if(Q.includes("fetch failed")||Q.includes("failed to fetch")||Q.includes("connect timeout")||Q.includes("network")||Y?.startsWith("UND_ERR"))return`Network error: ${J}${X.code?` (code ${X.code})`:""}. Check your network connection and API endpoint availability.`;let U=X.status||X.statusCode;return[J,X.code?`Code: ${X.code}`:void 0,U?`Status: ${U}`:void 0].filter(Boolean).join(" | ")||D.name}if(X.message){let J=[X.message,X.code?`Code: ${X.code}`:void 0,X.status||X.statusCode?`Status: ${X.status||X.statusCode}`:void 0].filter(Boolean).join(" | "),Y=X.message.toLowerCase();if(Y.includes("fetch failed")||Y.includes("failed to fetch")||X.error==="Failed to fetch")return`Network error: ${J}. Check your network connection and API endpoint availability.`;if(X.details||X.hint||X.error)return`${J}${J?" | ":""}${X.error?typeof X.error==="string"?X.error:X.error.message??"":""}${X.details?`Details: ${X.details}`:""}${X.hint?`Hint: ${X.hint}`:""}`.trim();return J}if(typeof X.error==="string"&&X.error.length>0)return X.error;if(X.error&&typeof X.error==="object"&&typeof X.error.message==="string"&&X.error.message.length>0)return X.error.message;return`
379
- ${hs.default.render(D)}`}async function rZ(D,$,X=!1){let{data:J,error:Y}=await D.rpc("reject_access_due_to_2fa_for_org",{org_id:$});if(Y){if(!X)N.error(`Cannot check 2FA compliance: ${Y.message}`);throw Error(`Cannot check 2FA compliance: ${Y.message}`)}if(J){if(!X)N.error("\uD83D\uDD10 Access Denied: 2FA Required. Enable 2FA at https://web.capgo.app/settings/account");throw Error("2FA required for this organization")}}function nZ(D){return new Promise(($)=>{setTimeout($,D)})}function gs({silent:D=!1,stdinIsTTY:$=!!fu0.isTTY,stdoutIsTTY:X=!!yu0.isTTY,ci:J=bs.isCI}={}){return!D&&$&&X&&!J}function J1(D){if(C4.isMonorepo(D))return C4.findMonorepoRoot(D);else if(C4.isNXMonorepo(D))return C4.findNXMonorepoRoot(D);return D}function mu0(D=J1(Q6()),$=void 0){let X=$?.split(",")[0];if(X){if(!GD(X)){let Y=`Package.json at ${X} does not exist`;throw N.error(Y),Error(Y)}}let J=gD(X??f0(D,v6));return JSON.parse(J)}function P4(D=J1(Q6()),$=void 0){return mu0(D,$).version??""}function cu0(D){let $=D.replace("^","").replace("~","");if(oR($))try{let X=DD($);return N$(X)}catch{return $}return $}async function d1(D,$=Q6(),X){let J=X?X.split(",").map((U)=>U.trim()).filter(Boolean):[],Y=[],Q=(U)=>{let F=H7(U);if(!Y.includes(F))Y.push(F)};for(let U of J){let F=H7($,U);if(GD(F))Q(yX(F))}Q(H7($)),Q(Q6());for(let U of Y)try{let F=`${D}/package.json`,{createRequire:Z}=await import("node:module"),G=Z(f0(U,"package.json")).resolve(F),q=JSON.parse(gD(G,"utf-8"));if(q.version)return q.version}catch{}for(let U of Y){let F=U,Z=hX.parse(F).root;while(F!==Z){let O=f0(F,"node_modules",D,v6);if(GD(O))try{let q=JSON.parse(gD(O,"utf-8"));if(q.version)return q.version}catch{}let G=yX(F);if(G===F)break;F=G}}if(D==="@capgo/capacitor-updater"){let U=null,F=f0($,"ios","App","Podfile");if(GD(F))try{let O=gD(F,"utf-8").match(/pod\s+['"]CapgoCapacitorUpdater['"],\s*:path\s*=>\s*['"]([^'"]+)['"]/);if(O?.[1])U=H7(f0($,"ios","App",O[1]))}catch{}if(!U){let Z=f0($,"android","capacitor.settings.gradle");if(GD(Z))try{let G=gD(Z,"utf-8").match(/project\(':capgo-capacitor-updater'\)\.projectDir\s*=\s*new\s+File\(['"]([^'"]+)['"]/);if(G?.[1])U=H7(f0($,"android",G[1])).replace(/\/android$/,"")}catch{}}if(U){let Z=f0(U,v6);if(GD(Z))try{let O=JSON.parse(gD(Z,"utf-8"));if(O.version)return O.version}catch{}}}try{let U=X?X.split(",").map((O)=>O.trim()).filter(Boolean).join(","):X,Z=(await oZ($,U)).get(D);if(Z)return Z}catch{}return null}async function oZ(D=J1(Q6()),$=void 0){let X=$?.split(",").map((Q)=>Q.trim()).filter(Boolean);if(X??=[f0(D,v6)],X){for(let Q of X)if(!GD(Q)){let U=`Package.json at ${Q} does not exist`;throw N.error(U),Error(U)}}let J=new Map,{createRequire:Y}=await import("node:module");for(let Q of X){let U=gD(Q),F=JSON.parse(U),Z=yX(Q),O=(G,q)=>{try{let H=Y(f0(Z,"package.json")).resolve(`${G}/package.json`),W=JSON.parse(gD(H,"utf-8"));if(W.version)return W.version}catch{}let w=Z,B=hX.parse(w).root;while(w!==B){let K=f0(w,"node_modules",G,v6);if(GD(K))try{let W=JSON.parse(gD(K,"utf-8"));if(W.version)return W.version}catch{}let H=yX(w);if(H===w)break;w=H}return cu0(q)};for(let G in F.dependencies)J.set(G,O(G,F.dependencies[G]));for(let G in F.devDependencies)J.set(G,O(G,F.devDependencies[G]))}return J}async function I0(){try{let D=await Yo();if(!D)throw N.error("No capacitor config file found, run `cap init` first"),Error("No capacitor config file found, run `cap init` first");return D}catch(D){let $=`No capacitor config file found, run \`cap init\` first ${s(D)}`;throw N.error($),Error($)}}async function du0(D,$){let X=await I0();if(X?.config)X.config.plugins??={},X.config.plugins.extConfig??={},X.config.plugins[D]??={},X.config.plugins[D]={...X.config.plugins[D],...$},await KH(D,X);return X}async function ms(D){return du0("CapacitorUpdater",D)}async function c$(){try{let D=await I0(),$={host:D?.config?.plugins?.CapacitorUpdater?.localHost||us,hostWeb:D?.config?.plugins?.CapacitorUpdater?.localWebHost||_s,hostFilesApi:D?.config?.plugins?.CapacitorUpdater?.localApiFiles||xs,hostApi:D?.config?.plugins?.CapacitorUpdater?.localApi||vs};if(D?.config?.plugins?.CapacitorUpdater?.localSupa&&D?.config?.plugins?.CapacitorUpdater?.localSupaAnon)N.info("Using custom supabase instance from capacitor.config.json"),$.supaKey=D?.config?.plugins?.CapacitorUpdater?.localSupaAnon,$.supaHost=D?.config?.plugins?.CapacitorUpdater?.localSupa;return $}catch{return{host:us,hostWeb:_s,hostFilesApi:xs,hostApi:vs}}}async function tZ(){let D=await c$();try{let $=await fetch(`${D.hostApi}/private/config`);if(!$.ok)throw Error(`HTTP error! status: ${$.status}`);return{...await $.json(),...D}}catch{return N.info(`Local config ${s(D)}`),D}}async function ds(){let D=await c$();try{let $=await fetch(`${D.hostFilesApi}/files/config`);if(!$.ok)throw Error(`HTTP error! status: ${$.status}`);return await $.json()}catch{return{partialUpload:!1,TUSUpload:!1,partialUploadForced:!1,TUSUploadForced:!1,maxUploadLength:hu0,maxChunkSize:gu0,alertUploadSize:bu0}}}async function E0(D,$,X){let J=await tZ();if($&&X)N.info("Using custom supabase instance from provided options"),J.supaHost=$,J.supaKey=X;if(!J.supaHost||!J.supaKey)throw N.error("Cannot connect to server please try again later"),Error("Cannot connect to server please try again later");return Nq(J.supaHost,J.supaKey,{auth:{persistSession:!1},global:{headers:{capgkey:D}}})}async function lu0(D,$,X){let{data:J}=await D.rpc("is_allowed_capgkey",{apikey:$,keymode:X}).single();if(!J){N.error("Invalid API key or insufficient permissions.");let Q=`Your key should be: ${X.map((U,F)=>{if(X.length===1)return`"${U}"`;if(F===X.length-1)return`or "${U}"`;return`"${U}", `}).join("")} mode.`;throw N.error(Q),Error("Invalid API key or insufficient permissions.")}}async function ls(D,$){let{data:X}=await D.rpc("is_paying_org",{orgid:$}).single();return X||!1}async function ns(D,$){let{data:X}=await D.rpc("is_trial_org",{orgid:$}).single();return X||0}async function nu0(D,$){let{data:X}=await D.rpc("is_allowed_action_org",{orgid:$}).single();return!!X}async function iu0(D,$,X){let{data:J}=await D.rpc("is_allowed_action",{apikey:X,appid:$}).single();return!!J}async function is(D,$,X){let{data:J,error:Y}=await D.rpc("get_org_perm_for_apikey",{apikey:$,app_id:X}).single();if(Y)throw N.error("Cannot get permissions for organization!"),N.error(s(Y)),Error("Cannot get permissions for organization");if(J.includes("perm")){let F=null;switch(J){case"perm_none":{F=0;break}case"perm_read":{F=1;break}case"perm_upload":{F=2;break}case"perm_write":{F=3;break}case"perm_admin":{F=4;break}case"perm_owner":{F=5;break}default:{if(J.includes("invite"))throw N.info("Please accept/deny the organization invitation before trying to access the app"),Error("Organization invitation pending");throw N.error(`Invalid output when fetching organization permission. Response: ${J}`),Error(`Invalid output when fetching organization permission. Response: ${J}`)}}return{okay:!0,data:F}}let U=null;switch(J){case"INVALID_APIKEY":{U="INVALID_APIKEY";break}case"NO_APP":{U="NO_APP";break}case"NO_ORG":{U="NO_ORG";break}default:throw N.error(`Invalid error when fetching organization permission. Response: ${J}`),Error(`Invalid error when fetching organization permission. Response: ${J}`)}return{okay:!1,error:U}}async function ps(D,$,X){let{data:J,error:Y}=await D.rpc("get_organization_cli_warnings",{orgid:$,cli_version:X});if(Y){N.error(`Cannot get cli warnings: ${s(Y)}`);return}if(J.length>0){N.warn(`Found ${J.length} cli warnings for your organization.`);let Q=null;for(let U of J){if(typeof U!=="object"||typeof U.message!=="string"||typeof U.fatal!=="boolean"){N.error(`Invalid cli warning: ${U}`);continue}let F=U;if(F.fatal)N.error(`${F.message.replaceAll("\\n",`
379
+ ${hs.default.render(D)}`}async function rZ(D,$,X=!1){let{data:J,error:Y}=await D.rpc("reject_access_due_to_2fa_for_org",{org_id:$});if(Y){if(!X)N.error(`Cannot check 2FA compliance: ${Y.message}`);throw Error(`Cannot check 2FA compliance: ${Y.message}`)}if(J){if(!X)N.error("\uD83D\uDD10 Access Denied: 2FA Required. Enable 2FA at https://web.capgo.app/settings/account");throw Error("2FA required for this organization")}}function nZ(D){return new Promise(($)=>{setTimeout($,D)})}function gs({silent:D=!1,stdinIsTTY:$=!!fu0.isTTY,stdoutIsTTY:X=!!yu0.isTTY,ci:J=bs.isCI}={}){return!D&&$&&X&&!J}function J1(D){if(C4.isMonorepo(D))return C4.findMonorepoRoot(D);else if(C4.isNXMonorepo(D))return C4.findNXMonorepoRoot(D);return D}function mu0(D=J1(Q6()),$=void 0){let X=$?.split(",")[0];if(X){if(!GD(X)){let Y=`Package.json at ${X} does not exist`;throw N.error(Y),Error(Y)}}let J=gD(X??f0(D,v6));return JSON.parse(J)}function P4(D=J1(Q6()),$=void 0){return mu0(D,$).version??""}function cu0(D){let $=D.replace("^","").replace("~","");if(oR($))try{let X=DD($);return N$(X)}catch{return $}return $}async function d1(D,$=Q6(),X){let J=X?X.split(",").map((U)=>U.trim()).filter(Boolean):[],Y=[],Q=(U)=>{let F=H7(U);if(!Y.includes(F))Y.push(F)};for(let U of J){let F=H7($,U);if(GD(F))Q(yX(F))}Q(H7($)),Q(Q6());for(let U of Y)try{let F=`${D}/package.json`,{createRequire:Z}=await import("node:module"),G=Z(f0(U,"package.json")).resolve(F),q=JSON.parse(gD(G,"utf-8"));if(q.version)return q.version}catch{}for(let U of Y){let F=U,Z=hX.parse(F).root;while(F!==Z){let O=f0(F,"node_modules",D,v6);if(GD(O))try{let q=JSON.parse(gD(O,"utf-8"));if(q.version)return q.version}catch{}let G=yX(F);if(G===F)break;F=G}}if(D==="@capgo/capacitor-updater"){let U=null,F=f0($,"ios","App","Podfile");if(GD(F))try{let O=gD(F,"utf-8").match(/pod\s+['"]CapgoCapacitorUpdater['"],\s*:path\s*=>\s*['"]([^'"]+)['"]/);if(O?.[1])U=H7(f0($,"ios","App",O[1]))}catch{}if(!U){let Z=f0($,"android","capacitor.settings.gradle");if(GD(Z))try{let G=gD(Z,"utf-8").match(/project\(':capgo-capacitor-updater'\)\.projectDir\s*=\s*new\s+File\(['"]([^'"]+)['"]/);if(G?.[1])U=H7(f0($,"android",G[1])).replace(/\/android$/,"")}catch{}}if(U){let Z=f0(U,v6);if(GD(Z))try{let O=JSON.parse(gD(Z,"utf-8"));if(O.version)return O.version}catch{}}}try{let U=X?X.split(",").map((O)=>O.trim()).filter(Boolean).join(","):X,Z=(await oZ($,U)).get(D);if(Z)return Z}catch{}return null}async function oZ(D=J1(Q6()),$=void 0){let X=$?.split(",").map((Q)=>Q.trim()).filter(Boolean);if(X??=[f0(D,v6)],X){for(let Q of X)if(!GD(Q)){let U=`Package.json at ${Q} does not exist`;throw N.error(U),Error(U)}}let J=new Map,{createRequire:Y}=await import("node:module");for(let Q of X){let U=gD(Q),F=JSON.parse(U),Z=yX(Q),O=(G,q)=>{try{let H=Y(f0(Z,"package.json")).resolve(`${G}/package.json`),W=JSON.parse(gD(H,"utf-8"));if(W.version)return W.version}catch{}let w=Z,B=hX.parse(w).root;while(w!==B){let K=f0(w,"node_modules",G,v6);if(GD(K))try{let W=JSON.parse(gD(K,"utf-8"));if(W.version)return W.version}catch{}let H=yX(w);if(H===w)break;w=H}return cu0(q)};for(let G in F.dependencies)J.set(G,O(G,F.dependencies[G]));for(let G in F.devDependencies)J.set(G,O(G,F.devDependencies[G]))}return J}async function I0(D=!1){try{let $=await Yo();if(!$){if(!D)N.error("No capacitor config file found, run `cap init` first");throw Error("No capacitor config file found, run `cap init` first")}return $}catch($){let X=`No capacitor config file found, run \`cap init\` first ${s($)}`;if(!D)N.error(X);throw Error(X)}}async function du0(D,$){let X=await I0();if(X?.config)X.config.plugins??={},X.config.plugins.extConfig??={},X.config.plugins[D]??={},X.config.plugins[D]={...X.config.plugins[D],...$},await KH(D,X);return X}async function ms(D){return du0("CapacitorUpdater",D)}async function c$(D=!1){try{let $=await I0(D),X={host:$?.config?.plugins?.CapacitorUpdater?.localHost||us,hostWeb:$?.config?.plugins?.CapacitorUpdater?.localWebHost||_s,hostFilesApi:$?.config?.plugins?.CapacitorUpdater?.localApiFiles||xs,hostApi:$?.config?.plugins?.CapacitorUpdater?.localApi||vs};if($?.config?.plugins?.CapacitorUpdater?.localSupa&&$?.config?.plugins?.CapacitorUpdater?.localSupaAnon){if(!D)N.info("Using custom supabase instance from capacitor.config.json");X.supaKey=$?.config?.plugins?.CapacitorUpdater?.localSupaAnon,X.supaHost=$?.config?.plugins?.CapacitorUpdater?.localSupa}return X}catch{return{host:us,hostWeb:_s,hostFilesApi:xs,hostApi:vs}}}async function tZ(D=!1){let $=await c$(D);try{let X=await fetch(`${$.hostApi}/private/config`);if(!X.ok)throw Error(`HTTP error! status: ${X.status}`);return{...await X.json(),...$}}catch{if(!D)N.info(`Local config ${s($)}`);return $}}async function ds(){let D=await c$();try{let $=await fetch(`${D.hostFilesApi}/files/config`);if(!$.ok)throw Error(`HTTP error! status: ${$.status}`);return await $.json()}catch{return{partialUpload:!1,TUSUpload:!1,partialUploadForced:!1,TUSUploadForced:!1,maxUploadLength:hu0,maxChunkSize:gu0,alertUploadSize:bu0}}}async function E0(D,$,X,J=!1){let Y=await tZ(J);if($&&X){if(!J)N.info("Using custom supabase instance from provided options");Y.supaHost=$,Y.supaKey=X}if(!Y.supaHost||!Y.supaKey){if(!J)N.error("Cannot connect to server please try again later");throw Error("Cannot connect to server please try again later")}return Nq(Y.supaHost,Y.supaKey,{auth:{persistSession:!1},global:{headers:{capgkey:D}}})}async function lu0(D,$,X){let{data:J}=await D.rpc("is_allowed_capgkey",{apikey:$,keymode:X}).single();if(!J){N.error("Invalid API key or insufficient permissions.");let Q=`Your key should be: ${X.map((U,F)=>{if(X.length===1)return`"${U}"`;if(F===X.length-1)return`or "${U}"`;return`"${U}", `}).join("")} mode.`;throw N.error(Q),Error("Invalid API key or insufficient permissions.")}}async function ls(D,$){let{data:X}=await D.rpc("is_paying_org",{orgid:$}).single();return X||!1}async function ns(D,$){let{data:X}=await D.rpc("is_trial_org",{orgid:$}).single();return X||0}async function nu0(D,$){let{data:X}=await D.rpc("is_allowed_action_org",{orgid:$}).single();return!!X}async function iu0(D,$,X){let{data:J}=await D.rpc("is_allowed_action",{apikey:X,appid:$}).single();return!!J}async function is(D,$,X){let{data:J,error:Y}=await D.rpc("get_org_perm_for_apikey",{apikey:$,app_id:X}).single();if(Y)throw N.error("Cannot get permissions for organization!"),N.error(s(Y)),Error("Cannot get permissions for organization");if(J.includes("perm")){let F=null;switch(J){case"perm_none":{F=0;break}case"perm_read":{F=1;break}case"perm_upload":{F=2;break}case"perm_write":{F=3;break}case"perm_admin":{F=4;break}case"perm_owner":{F=5;break}default:{if(J.includes("invite"))throw N.info("Please accept/deny the organization invitation before trying to access the app"),Error("Organization invitation pending");throw N.error(`Invalid output when fetching organization permission. Response: ${J}`),Error(`Invalid output when fetching organization permission. Response: ${J}`)}}return{okay:!0,data:F}}let U=null;switch(J){case"INVALID_APIKEY":{U="INVALID_APIKEY";break}case"NO_APP":{U="NO_APP";break}case"NO_ORG":{U="NO_ORG";break}default:throw N.error(`Invalid error when fetching organization permission. Response: ${J}`),Error(`Invalid error when fetching organization permission. Response: ${J}`)}return{okay:!1,error:U}}async function ps(D,$,X){let{data:J,error:Y}=await D.rpc("get_organization_cli_warnings",{orgid:$,cli_version:X});if(Y){N.error(`Cannot get cli warnings: ${s(Y)}`);return}if(J.length>0){N.warn(`Found ${J.length} cli warnings for your organization.`);let Q=null;for(let U of J){if(typeof U!=="object"||typeof U.message!=="string"||typeof U.fatal!=="boolean"){N.error(`Invalid cli warning: ${U}`);continue}let F=U;if(F.fatal)N.error(`${F.message.replaceAll("\\n",`
380
380
  `)}`),Q=Error(F.message);else N.warn(`${F.message.replaceAll("\\n",`
381
381
  `)}`)}if(Q)throw N.error("Please fix the warnings and try again."),Q;N.info("End of cli warnings.")}}async function rs(D,$,X,J,Y=!0){let Q=await tZ();if(!await(J?iu0(D,J,X):nu0(D,$)))throw N.error(`You need to upgrade your plan to continue to use capgo.
382
382
  Upgrade here: ${Q.hostWeb}/settings/organization/plans
@@ -386,7 +386,7 @@ Trial expires in ${F} days, upgrade here: ${Q.hostWeb}/settings/organization/pla
386
386
  Upgrade here: ${Q.hostWeb}/settings/organization/plans
387
387
  `),nZ(100),Promise.resolve().then(() => (bM(),yM)).then((O)=>{O.default(`${Q.hostWeb}/settings/organization/plans`)}),nZ(500),Error("Plan upgrade required for upload");let[F,Z]=await Promise.all([ns(D,$),ls(D,$)]);if(F>0&&Y&&!Z)N.warn(`WARNING !!
388
388
  Trial expires in ${F} days, upgrade here: ${Q.hostWeb}/settings/organization/plans
389
- `)}function H0(D=!1){let $=ku0.CAPGO_TOKEN?.trim();if($){if(!D)N.info("Use CAPGO_TOKEN environment variable");return $}let X=vu0(),J,Y=`${X}/.capgo`;if(GD(Y)){if(!D)N.info(`Use global API key ${Y}`);J=gD(Y,"utf8").trim()}if(Y=".capgo",!J&&GD(Y)){if(!D)N.info(`Use local API key ${Y}`);J=gD(Y,"utf8").trim()}if(!J){let Q=`Cannot find API key in local folder or global, please login first with ${t8().runner} @capgo/cli login`;throw N.error(Q),Error(Q)}return J}function S4(D){let X=(D.endsWith(".br")?D.slice(0,-3):D).split(".").pop()?.toLowerCase()||"";return{html:"text/html",htm:"text/html",js:"application/javascript",mjs:"application/javascript",cjs:"application/javascript",css:"text/css",json:"application/json",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",mp4:"video/mp4",webm:"video/webm",xml:"application/xml",txt:"text/plain",md:"text/markdown",pdf:"application/pdf",wasm:"application/wasm",map:"application/json"}[X]||"application/octet-stream"}async function cM(D,$){return D.from("app_versions").upsert($,{onConflict:"name,app_id"}).eq("app_id",$.app_id).eq("name",$.name)}async function ts(D,$,X){let J={app_id:$,name:X,version:0};try{let Q=await D.functions.invoke("files/upload_link",{body:JSON.stringify(J)});if(Q.error){if(Q.error instanceof U1.FunctionsHttpError){let U=await Q.error.context.json();N.error(`Upload URL error: ${U.status||JSON.stringify(U)}`)}else N.error(`Cannot get upload url: ${Q.error.message}`);return""}return Q.data.url}catch(Y){N.error(`Cannot get upload url ${s(Y)}`)}return""}async function*as(D){let $=bX(D,{withFileTypes:!0});for(let X of $){let J=f0(D,X.name);if(X.isDirectory())yield*as(J);else yield J}}function K$(D,$="5.10.0",X="6.25.0",J="7.25.0"){if(D.major===5&&p4(D,DD($)))return!0;if(D.major===6&&p4(D,DD(X)))return!0;if(D.major===7&&p4(D,DD(J)))return!0;return!1}async function ss(D){let $=[],X=[".DS_Store",".git",".gitignore","node_modules","package-lock.json","tsconfig.json","tsconfig.app.json","tsconfig.spec.json","tsconfig.app.json","tsconfig.spec.json","tsconfig.app.json","tsconfig.spec.json"];for await(let J of as(D)){if(X.some((F)=>J.includes(F))){N.info(`Ignoring file ${J}, please ensure you have only required files in your dist folder`);continue}let Y=gD(J);if(Y.length===0){N.info(`Ignoring empty file ${J}, please ensure you have only required files in your dist folder`);continue}let Q=await J4(Y,"sha256"),U=fs(D,J);if(U.startsWith("/"))U=U.substring(1);$.push({file:U,hash:Q})}return $}async function eZ(D){if(_u0()==="win32")return ru0(D);else return pu0(D)}function pu0(D){let $=new gM.default;return $.addLocalFolder(D),$.toBuffer()}async function ru0(D){N.info("Zipping file windows mode");let $=new gM.default,X=(J,Y)=>{let Q=bX(J);for(let U of Q){let F=f0(J,U),Z=xu0(F);if(Z.isFile()){let O=gD(F);$.addFile(f0(Y,U).split(ys).join("/"),O)}else if(Z.isDirectory())X(F,f0(Y,U))}};return X(D,""),$.toBuffer()}async function es(D,$,X,J,Y,Q,U,F){return new Promise((Z,O)=>{A0(D,{channel:"app",event:"App TUS upload",icon:"⏫",user_id:X,tags:{"app-id":J},notify:!1}),new iZ.Upload($,{endpoint:`${U.hostFilesApi}/files/upload/attachments/`,chunkSize:F,metadataForPartialUploads:{filename:`orgs/${X}/apps/${J}/${Y}.zip`,filetype:"application/gzip"},metadata:{filename:`orgs/${X}/apps/${J}/${Y}.zip`,filetype:"application/zip"},headers:{Authorization:D},onError(q){if(N.error(`Error uploading bundle: ${q.message}`),q instanceof iZ.DetailedError){let w=q.originalResponse?.getBody(),B=JSON.parse(w||'{"error": "unknown error"}');O(B.status||B.error||B.message||"unknown error")}else O(q.message||q.toString()||"unknown error")},onProgress(q,w){let B=(q/w*100).toFixed(2);Q.message(`Uploaded ${B}%`)},async onSuccess(){await A0(D,{channel:"app",event:"App TUS done",icon:"⏫",user_id:X,tags:{"app-id":J},notify:!1}).catch(),Z(!0)}}).start()})}async function De(D,$,X){let J={app_id:$,name:X};try{let Q=await D.functions.invoke("private/delete_failed_version",{body:JSON.stringify(J),method:"DELETE"});if(Q.error){if(Q.error instanceof U1.FunctionsHttpError){let U=await Q.error.context.json();N.error(`Cannot delete failed version: ${U.status||JSON.stringify(U)}`)}else N.error(`Cannot delete failed version: ${Q.error.message}`);return}return Q.data?.status}catch(Y){if(Y instanceof U1.FunctionsHttpError){let Q=await Y.context.json();N.error(`Cannot delete failed version: ${Q.message||JSON.stringify(Q)}`)}else N.error(`Cannot delete failed version: ${s(Y)}`)}}async function DO(D,$){if(!$.app_id||!$.name||!$.created_by)return N.error("missing app_id, name, or created_by"),Promise.reject(Error("missing app_id, name, or created_by"));let{data:X,error:J}=await D.from("channels").select().eq("app_id",$.app_id).eq("name",$.name).single();if(X&&!J)return D.from("channels").update($).eq("app_id",$.app_id).eq("name",$.name).select().single();return D.from("channels").insert($).select().single()}async function A0(D,$,X){try{if(X)N.info(`Get remove config: for ${$.event}`);let J=await tZ();if(X)N.info(`Sending LogSnag event: ${JSON.stringify($)}`);let Y=new AbortController,Q=setTimeout(()=>Y.abort(),1e4);try{let U=await fetch(`${J.hostApi}/private/events`,{method:"POST",body:JSON.stringify($),headers:{"Content-Type":"application/json",capgkey:D},signal:Y.signal});if(clearTimeout(Q),!U.ok)throw Error(`HTTP error! status: ${U.status}`);let F=await U.json();if(F.error)N.error(`Failed to send LogSnag event: ${F.error}`)}finally{clearTimeout(Q)}}catch(J){if(X)N.error("Failed to send Stats event details:"),N.error(s(J))}}function dM(D){if(N.error(`
389
+ `)}function H0(D=!1){let $=ku0.CAPGO_TOKEN?.trim();if($){if(!D)N.info("Use CAPGO_TOKEN environment variable");return $}let X=vu0(),J,Y=`${X}/.capgo`;if(GD(Y)){if(!D)N.info(`Use global API key ${Y}`);J=gD(Y,"utf8").trim()}if(Y=".capgo",!J&&GD(Y)){if(!D)N.info(`Use local API key ${Y}`);J=gD(Y,"utf8").trim()}if(!J){let Q=`Cannot find API key in local folder or global, please login first with ${t8().runner} @capgo/cli login`;throw N.error(Q),Error(Q)}return J}function S4(D){let X=(D.endsWith(".br")?D.slice(0,-3):D).split(".").pop()?.toLowerCase()||"";return{html:"text/html",htm:"text/html",js:"application/javascript",mjs:"application/javascript",cjs:"application/javascript",css:"text/css",json:"application/json",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",mp4:"video/mp4",webm:"video/webm",xml:"application/xml",txt:"text/plain",md:"text/markdown",pdf:"application/pdf",wasm:"application/wasm",map:"application/json"}[X]||"application/octet-stream"}async function cM(D,$){return D.from("app_versions").upsert($,{onConflict:"name,app_id"}).eq("app_id",$.app_id).eq("name",$.name)}async function ts(D,$,X){let J={app_id:$,name:X,version:0};try{let Q=await D.functions.invoke("files/upload_link",{body:JSON.stringify(J)});if(Q.error){if(Q.error instanceof U1.FunctionsHttpError){let U=await Q.error.context.json();N.error(`Upload URL error: ${U.status||JSON.stringify(U)}`)}else N.error(`Cannot get upload url: ${Q.error.message}`);return""}return Q.data.url}catch(Y){N.error(`Cannot get upload url ${s(Y)}`)}return""}async function*as(D){let $=bX(D,{withFileTypes:!0});for(let X of $){let J=f0(D,X.name);if(X.isDirectory())yield*as(J);else yield J}}function K$(D,$="5.10.0",X="6.25.0",J="7.25.0"){if(D.major===5&&p4(D,DD($)))return!0;if(D.major===6&&p4(D,DD(X)))return!0;if(D.major===7&&p4(D,DD(J)))return!0;return!1}async function ss(D){let $=[],X=[".DS_Store",".git",".gitignore","node_modules","package-lock.json","tsconfig.json","tsconfig.app.json","tsconfig.spec.json","tsconfig.app.json","tsconfig.spec.json","tsconfig.app.json","tsconfig.spec.json"];for await(let J of as(D)){if(X.some((F)=>J.includes(F))){N.info(`Ignoring file ${J}, please ensure you have only required files in your dist folder`);continue}let Y=gD(J);if(Y.length===0){N.info(`Ignoring empty file ${J}, please ensure you have only required files in your dist folder`);continue}let Q=await J4(Y,"sha256"),U=fs(D,J);if(U.startsWith("/"))U=U.substring(1);$.push({file:U,hash:Q})}return $}async function eZ(D){if(_u0()==="win32")return ru0(D);else return pu0(D)}function pu0(D){let $=new gM.default;return $.addLocalFolder(D),$.toBuffer()}async function ru0(D){N.info("Zipping file windows mode");let $=new gM.default,X=(J,Y)=>{let Q=bX(J);for(let U of Q){let F=f0(J,U),Z=xu0(F);if(Z.isFile()){let O=gD(F);$.addFile(f0(Y,U).split(ys).join("/"),O)}else if(Z.isDirectory())X(F,f0(Y,U))}};return X(D,""),$.toBuffer()}async function es(D,$,X,J,Y,Q,U,F){return new Promise((Z,O)=>{A0(D,{channel:"app",event:"App TUS upload",icon:"⏫",user_id:X,tags:{"app-id":J},notify:!1}),new iZ.Upload($,{endpoint:`${U.hostFilesApi}/files/upload/attachments/`,chunkSize:F,metadataForPartialUploads:{filename:`orgs/${X}/apps/${J}/${Y}.zip`,filetype:"application/gzip"},metadata:{filename:`orgs/${X}/apps/${J}/${Y}.zip`,filetype:"application/zip"},headers:{Authorization:D},onError(q){if(N.error(`Error uploading bundle: ${q.message}`),q instanceof iZ.DetailedError){let w=q.originalResponse?.getBody(),B=JSON.parse(w||'{"error": "unknown error"}');O(B.status||B.error||B.message||"unknown error")}else O(q.message||q.toString()||"unknown error")},onProgress(q,w){let B=(q/w*100).toFixed(2);Q.message(`Uploaded ${B}%`)},async onSuccess(){await A0(D,{channel:"app",event:"App TUS done",icon:"⏫",user_id:X,tags:{"app-id":J},notify:!1}).catch(),Z(!0)}}).start()})}async function De(D,$,X){let J={app_id:$,name:X};try{let Q=await D.functions.invoke("private/delete_failed_version",{body:JSON.stringify(J),method:"DELETE"});if(Q.error){if(Q.error instanceof U1.FunctionsHttpError){let U=await Q.error.context.json();N.error(`Cannot delete failed version: ${U.status||JSON.stringify(U)}`)}else N.error(`Cannot delete failed version: ${Q.error.message}`);return}return Q.data?.status}catch(Y){if(Y instanceof U1.FunctionsHttpError){let Q=await Y.context.json();N.error(`Cannot delete failed version: ${Q.message||JSON.stringify(Q)}`)}else N.error(`Cannot delete failed version: ${s(Y)}`)}}async function DO(D,$){if(!$.app_id||!$.name||!$.created_by)return N.error("missing app_id, name, or created_by"),Promise.reject(Error("missing app_id, name, or created_by"));let{data:X,error:J}=await D.from("channels").select().eq("app_id",$.app_id).eq("name",$.name).single();if(X&&!J)return D.from("channels").update($).eq("app_id",$.app_id).eq("name",$.name).select().single();return D.from("channels").insert($).select().single()}async function A0(D,$,X){try{if(X)N.info(`Get remove config: for ${$.event}`);let J=await tZ(!0);if(X)N.info(`Sending LogSnag event: ${JSON.stringify($)}`);let Y=new AbortController,Q=setTimeout(()=>Y.abort(),1e4);try{let U=await fetch(`${J.hostApi}/private/events`,{method:"POST",body:JSON.stringify($),headers:{"Content-Type":"application/json",capgkey:D},signal:Y.signal});if(clearTimeout(Q),!U.ok)throw Error(`HTTP error! status: ${U.status}`);let F=await U.json();if(F.error&&X)N.error(`Failed to send LogSnag event: ${F.error}`)}finally{clearTimeout(Q)}}catch(J){if(X)N.error("Failed to send Stats event details:"),N.error(s(J))}}function dM(D){if(N.error(`
390
390
  \uD83D\uDD10 Access Denied: Two-Factor Authentication Required`),N.error("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),D)N.error(`
391
391
  The organization "${D}" requires all members to have 2FA enabled.`);else N.error(`
392
392
  This organization requires all members to have 2FA enabled.`);throw N.error(`
@@ -501,7 +501,7 @@ The bundle size is ${A} Mb, this may take a while to download for users
501
501
  Bundle uploaded \uD83D\uDCAA in 0 seconds`),U.verbose)N.info("[Verbose] Dry upload mode - skipping actual upload");return}try{let B=await c$();if(U.verbose)N.info("[Verbose] Local config retrieved for upload");if(U.multipart!==void 0&&U.multipart||U.tus!==void 0&&U.tus){if(U.multipart)N.info("Uploading bundle with multipart is deprecated, we upload with TUS instead");else N.info("Uploading bundle with TUS protocol");if(U.verbose)N.info("[Verbose] Starting TUS resumable upload..."),N.info(` - Host: ${B.hostWeb}`),N.info(` - Chunk size: ${Math.floor(F/1024/1024)} MB`);if(await es(D,Q,Y,X,J,Z,B,F),G=!0,U.verbose)N.info("[Verbose] TUS upload completed, updating database with R2 path...");let K=`orgs/${Y}/apps/${X}/${J}.zip`,{error:H}=await $.from("app_versions").update({r2_path:K}).eq("name",J).eq("app_id",X);if(H){if(N.error(`Cannot finish TUS upload ${s(H)}`),U.verbose)N.info(`[Verbose] Database update failed: ${s(H)}`);return Promise.reject(Error("Cannot finish TUS upload"))}if(U.verbose)N.info(`[Verbose] Database updated with R2 path: ${K}`)}else{if(U.verbose)N.info("[Verbose] Using standard upload (non-TUS), getting presigned URL...");let K=await ts($,X,J);if(!K){if(N.error("Cannot get upload url"),U.verbose)N.info("[Verbose] Failed to retrieve presigned upload URL from database");return Promise.reject(Error("Cannot get upload url"))}if(U.verbose)N.info("[Verbose] Presigned URL obtained, uploading via HTTP PUT..."),N.info(` - Timeout: ${U.timeout||mM}ms`),N.info(" - Retry attempts: 5"),N.info(" - Content-Type: application/zip");let H=new AbortController,W=setTimeout(()=>H.abort(),U.timeout||mM);try{let M=await fetch(K,{method:"PUT",body:Q,headers:{"Content-Type":"application/zip"},signal:H.signal});if(!M.ok)throw Error(`HTTP error! status: ${M.status}`)}finally{clearTimeout(W)}if(U.verbose)N.info("[Verbose] HTTP PUT upload completed successfully")}}catch(B){let H=((performance.now()-O)/1000).toFixed(2);if(Z.error(`Failed to upload bundle ( after ${H} seconds)`),U.verbose)N.info(`[Verbose] Upload failed after ${H} seconds`),N.info(`[Verbose] Error type: ${B instanceof Error?"Error":typeof B}`);if(B instanceof Error&&B.message.includes("HTTP error"))try{let W=B.message.match(/status: (\d+)/),M=W?W[1]:"unknown";N.error(`Upload failed with status ${M}: ${B.message}`)}catch{N.error(`Upload failed: ${B.message}`)}else{if(U.verbose)N.info(`[Verbose] Non-HTTP error: ${s(B)}`);if(!U.tus)N.error(`Cannot upload bundle ( try again with --tus option) ${s(B)}`);else N.error(`Cannot upload bundle please contact support if the issue persists ${s(B)}`)}if(U.verbose)N.info("[Verbose] Cleaning up failed version from database...");if(await De($,X,J),U.verbose)N.info("[Verbose] Failed version cleaned up");throw B instanceof Error?B:Error(String(B))}let w=((performance.now()-O)/1000).toFixed(2);if(Z.stop(`Bundle uploaded \uD83D\uDCAA in (${w} seconds)`),U.verbose)N.info("[Verbose] Upload successful:"),N.info(` - Upload time: ${w} seconds`),N.info(` - Upload method: ${G?"TUS (resumable)":"Standard HTTP PUT"}`),N.info(` - Bundle size: ${Math.floor(Q.byteLength/1024)} KB`),N.info("[Verbose] Sending performance event...");if(await A0(D,{channel:"performance",event:G?"TUS upload zip performance":"Upload zip performance",icon:"\uD83D\uDE84",user_id:Y,tags:{"app-id":X,time:w},notify:!1},U.verbose),U.verbose)N.info("[Verbose] Performance event sent successfully")}async function ym0(D,$,X){let{data:J,error:Y}=await D.from("channels").select("version ( id, name, deleted )").eq("app_id",$).eq("name",X);if(Y){N.error(`Cannot delete linked bundle on upload ${s(Y)}`);return}if(J.length===0){N.warn("No linked bundle found in the channel you are trying to upload to");return}let Q=J[0].version;if(Q.deleted){N.warn("The linked bundle is already deleted");return}let{error:U}=await D.from("app_versions").update({deleted:!0}).eq("id",Q.id);if(U){N.error(`Cannot delete linked bundle on upload ${s(U)}`);return}N.info("Linked bundle deleted")}async function bm0(D,$,X,J,Y,Q,U,F,Z,O){let{data:G}=await D.rpc("get_app_versions",{apikey:$,name_version:J,appid:F}).single();if(!G)ND("Cannot get version id, cannot set channel");let{data:q}=await D.rpc("is_allowed_capgkey",{apikey:$,keymode:["write","all"]}).single();if(q){let{error:w,data:B}=await DO(D,{name:Y,app_id:F,created_by:Q,version:G,owner_org:U,...O?{allow_device_self_set:!0}:{}});if(w)ND(`Cannot set channel, the upload key is not allowed to do that, use the "all" for this. ${s(w)}`);let K=`${Z.hostWeb}/app/${F}/channel/${B.id}`;if(B?.public)N.info("Your update is now available in your public channel \uD83C\uDF89");else if(B?.id)N.info(`Link device to this bundle to try it: ${K}`);if(X)N.info(`Bundle url: ${K}`)}else N.warn("The upload key is not allowed to set the version in the channel")}async function hm0(D,$,X){let{error:J,data:Y}=await $.from("apps").select("default_upload_channel").eq("app_id",D).single();if(J)return N.warn("Cannot find default upload channel"),N.info(`You can set it here: ${X}/app/${D}/info`),null;return Y.default_upload_channel}async function pA(D,$,X=!1){if(!X)V0(`Uploading with CLI version ${R$.version}`);let J,Y=t8();await FD();let{s3Region:Q,s3Apikey:U,s3Apisecret:F,s3BucketName:Z,s3Endpoint:O,s3Port:G,s3SSL:q}=$;if($.verbose)N.info("[Verbose] Starting upload process with options:"),N.info(` - API key: ${$.apikey?"provided":"from saved key"}`),N.info(` - Path: ${$.path||"from capacitor config"}`),N.info(` - Channel: ${$.channel||"from default upload channel"}`),N.info(` - Bundle: ${$.bundle||"auto-detected"}`),N.info(` - External: ${$.external||"false"}`),N.info(` - Encryption: ${$.keyV2||$.keyDataV2?"v2":$.key===!1?"disabled":"auto"}`),N.info(` - Upload method: ${$.tus?"TUS":$.zip?"ZIP":"auto"}`),N.info(` - Delta updates: ${$.delta||$.partial?"enabled":"disabled"}`);let w=Sm0($);if($.verbose)N.info("[Verbose] API key retrieved successfully");let B=await I0();if($.verbose)N.info("[Verbose] Capacitor config loaded successfully");let K=B?.config?.plugins?.CapacitorUpdater?.directUpdate==="always",H=gs({silent:X});if(K&&$.delta===void 0){if(H){N.info("\uD83D\uDCA1 Direct Update (instant updates) is enabled in your config"),N.info(" Delta updates send only changed files instead of the full bundle");let Y0=await hD({message:"Enable delta updates for this upload? (Recommended with Direct Update)",initialValue:!0});if(!y0(Y0)&&Y0){if($.delta=!0,$.verbose)N.info("[Verbose] Delta updates auto-enabled due to Direct Update configuration")}}else if(!X){if($.delta!==!1){if($.delta=!0,$.verbose)N.info("[Verbose] Delta updates auto-enabled in CI/CD mode due to Direct Update configuration")}}}let W=await ds();if($.verbose)N.info("[Verbose] Remote file config retrieved:"),N.info(` - Max upload length: ${Math.floor(W.maxUploadLength/1024/1024)} MB`),N.info(` - Alert upload size: ${Math.floor(W.alertUploadSize/1024/1024)} MB`),N.info(` - TUS upload: ${W.TUSUpload?"enabled":"disabled"}`),N.info(` - TUS upload forced: ${W.TUSUploadForced?"yes":"no"}`),N.info(` - Partial upload: ${W.partialUpload?"enabled":"disabled"}`),N.info(` - Max chunk size: ${Math.floor(W.maxChunkSize/1024/1024)} MB`);let{appid:M,path:I}=um0(D,$,B.config);if($.verbose)N.info(`[Verbose] App ID: ${M}, Build path: ${I}`);let z=await Pm0(B.config,$);if($.verbose)N.info(`[Verbose] Bundle version: ${z}`);let V=$.external?"external":"r2-direct",L="none";if($.autoSetBundle){if(await ms({version:z}),$.verbose)N.info("[Verbose] Auto-set bundle version in capacitor.config.json")}if(xm0($,I),$.verbose)N.info("[Verbose] Code check passed (notifyAppReady found and index.html present)");N.info(`Upload ${M}@${z} started from path "${I}" to Capgo cloud`);let R=await c$();if($.verbose)N.info(`[Verbose] Local config loaded: host=${R.hostWeb}`);if($.supaHost&&$.supaAnon){if(N.info("Using custom supabase instance from provided options"),R.supaHost=$.supaHost,R.supaKey=$.supaAnon,$.verbose)N.info(`[Verbose] Custom Supabase host: ${$.supaHost}`)}let C=await E0(w,$.supaHost,$.supaAnon);if($.verbose)N.info("[Verbose] Supabase client created successfully");await lD(C,M,X);let A=await S0(C,w,["write","all","upload"]);if($.verbose)N.info(`[Verbose] User verified successfully, user_id: ${A}`);let _=$.channel||await hm0(M,C,R.hostWeb)||"production";if($.verbose)N.info(`[Verbose] Target channel: ${_}`);let x=await pD(C,M);if($.verbose)N.info(`[Verbose] Organization ID: ${x}`);if(await ps(C,x,R$.version),$.verbose)N.info("[Verbose] Remote CLI messages checked");if(await os(C,x,w,M,!0),$.verbose)N.info("[Verbose] Plan validation passed");if($.verbose)N.info("[Verbose] Trial check completed");if($.verbose)N.info(`[Verbose] Checking compatibility with channel ${_}...`);let{nativePackages:S,minUpdateVersion:h}=await vm0(C,Y,$,_,M,z);if($.verbose)N.info("[Verbose] Compatibility check completed:"),N.info(` - Native packages: ${S?S.length:0}`),N.info(` - Min update version: ${h||"none"}`);if($.verbose)N.info(`[Verbose] Checking if version ${z} already exists...`);let b=await _m0(C,M,z,$.versionExistsOk,H);if($.verbose)N.info(`[Verbose] Version exists check: ${b?typeof b==="string"?`retry with ${b}`:"yes (skipping)":"no (continuing)"}`);if(b===!0)return{success:!0,skipped:!0,reason:"VERSION_EXISTS",bundle:z,checksum:null,encryptionMethod:L,storageProvider:V};if(typeof b==="string")return N.info(`Retrying upload with new version: ${b}`),pA(D,{...$,bundle:b},X);if($.external&&!$.external.startsWith("https://"))ND(`External link should should start with "https://" current is "${$.external}"`);if($.deleteLinkedBundleOnUpload)N.warn("Deleting linked bundle on upload is destructive, it will delete the currently linked bundle in the channel you are trying to upload to."),N.warn("Please make sure you want to do this, if you are not sure, please do not use this option.");let n={name:z,app_id:M,session_key:void 0,external_url:$.external,storage_provider:V,min_update_version:h,native_packages:S,owner_org:x,user_id:A,checksum:void 0,link:$.link||null,comment:$.comment||null,key_id:void 0,cli_version:R$.version},f=null,j="";if(!$.external){if($.verbose)N.info(`[Verbose] Preparing bundle file from path: ${I}`);let Y0=B.config?.plugins?.CapacitorUpdater?.publicKey,{zipped:P,ivSessionKey:T,checksum:i,sessionKey:k,encryptionMethod:B0,finalKeyData:a,keyId:K0}=await km0(I,$,w,x,M,W.maxUploadLength,W.alertUploadSize,Y0);if(n.session_key=T,n.checksum=i,n.key_id=K0||void 0,J=k,f=P,L=B0,j=a,$.verbose)N.info("[Verbose] Bundle prepared:"),N.info(` - Size: ${Math.floor((P?.byteLength??0)/1024)} KB`),N.info(` - Checksum: ${i}`),N.info(` - Encryption: ${B0}`),N.info(` - IV Session Key: ${T?"present":"none"}`),N.info(` - Key ID: ${K0||"none"}`);if(!$.ignoreChecksumCheck){if($.verbose)N.info("[Verbose] Checking for duplicate checksum...");if(await Ye(C,M,_,i),$.verbose)N.info("[Verbose] Checksum is unique")}}else{if($.verbose)N.info(`[Verbose] Using external URL: ${$.external}`);if(await A0(w,{channel:"app",event:"App external",icon:"\uD83D\uDCE4",user_id:x,tags:{"app-id":M},notify:!1},$.verbose),n.session_key=$.ivSessionKey,n.checksum=$.encryptedChecksum,$.verbose)N.info("[Verbose] External bundle configured:"),N.info(` - URL: ${$.external}`),N.info(` - IV Session Key: ${$.ivSessionKey?"provided":"none"}`),N.info(` - Encrypted Checksum: ${$.encryptedChecksum?"provided":"none"}`)}if($.zip){if($.tus=!1,$.verbose)N.info("[Verbose] Upload method: ZIP (explicitly set via --zip)")}else if(!W.TUSUpload||$.external){if($.tus=!1,$.verbose)N.info("[Verbose] Upload method: Standard (TUS not available or external URL)")}else if($.tus=$.tus||W.TUSUploadForced,$.verbose)N.info(`[Verbose] Upload method: ${$.tus?"TUS (resumable)":"Standard"}`);if(!W.partialUpload||$.external){if($.delta=!1,$.verbose&&$.external)N.info("[Verbose] Delta updates disabled (not available with external URLs)")}else if($.delta=$.delta||$.partial||$.deltaOnly||$.partialOnly||W.partialUploadForced,$.verbose)N.info(`[Verbose] Delta updates: ${$.delta?"enabled":"disabled"}`);if($.encryptPartial&&L==="v1")ND("You cannot encrypt the partial update if you are not using the v2 encryption method");let u="5.30.0",v="6.30.0",y="7.30.0",g=!1;if($.delta&&L==="v2"&&!$.encryptPartial){let Y0=J1(iA()),P=await d1("@capgo/capacitor-updater",Y0,$.packageJson),T;try{T=P?DD(P):void 0}catch{T=void 0}if(P&&T&&XE(T,DD("6.14.4"))){if(N.info(`Auto-enabling partial update encryption for updater version ${T} (> 6.14.4)`),$.verbose)N.info("[Verbose] Partial encryption auto-enabled for updater >= 6.14.4");$.encryptPartial=!0}}if($.delta&&($.encryptPartial||L==="v2")){let Y0=J1(iA()),P=await d1("@capgo/capacitor-updater",Y0,$.packageJson),T;try{T=P?DD(P):void 0}catch{T=void 0}if(P&&T){if(g=!K$(T,u,v,y),$.verbose&&g)N.info(`[Verbose] Using hex checksum format for updater version ${T}`)}}if($.verbose&&$.delta)N.info("[Verbose] Preparing delta/partial update manifest...");let d=$.delta?await K40(I,w,x,M,$.encryptPartial?L:"none",j,g):[];if($.verbose&&$.delta)N.info(`[Verbose] Delta manifest prepared with ${d.length} files`);if($.verbose)N.info("[Verbose] Creating version record in database...");let{error:t}=await cM(C,n);if(t)ND(`Cannot add bundle ${s(t)}`);if($.verbose)N.info("[Verbose] Version record created successfully");if($.tusChunkSize&&$.tusChunkSize>W.maxChunkSize)N.error(`Chunk size ${$.tusChunkSize} is greater than the maximum chunk size ${W.maxChunkSize}, using the maximum chunk size`),$.tusChunkSize=W.maxChunkSize;else if(!$.tusChunkSize)$.tusChunkSize=W.maxChunkSize;if($.verbose)N.info(`[Verbose] TUS chunk size: ${Math.floor($.tusChunkSize/1024/1024)} MB`);if(f&&(Z||O||Q||U||F||G||q)){if(!Z||!O||!Q||!U||!F||!G)ND("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret");if(N.info("Uploading to S3"),$.verbose)N.info("[Verbose] S3 configuration:"),N.info(` - Endpoint: ${O}`),N.info(` - Region: ${Q}`),N.info(` - Bucket: ${Z}`),N.info(` - Port: ${G}`),N.info(` - SSL: ${q?"enabled":"disabled"}`);let Y0=q?`https://${O}`:`http://${O}`,P=new hO({endPoint:O,region:Q,port:G,pathStyle:!0,bucket:Z,accessKey:U,secretKey:F}),T=`${M}-${z}`,i=encodeURIComponent(T);if($.verbose)N.info(`[Verbose] Uploading to S3 as: ${T}`);if(await P.putObject(T,Uint8Array.from(f)),n.external_url=`${Y0}/${i}`,n.storage_provider="external",$.verbose)N.info(`[Verbose] S3 upload complete, external URL: ${n.external_url}`)}else if(f){if(!$.partialOnly&&!$.deltaOnly){if($.verbose)N.info("[Verbose] Starting full bundle upload to Capgo Cloud...");await fm0(w,C,M,z,x,f,$,$.tusChunkSize)}else if($.verbose)N.info("[Verbose] Skipping full bundle upload (delta-only mode)");let Y0=null;try{if($.dryUpload){if($.delta=!1,$.verbose)N.info("[Verbose] Dry upload mode: skipping delta upload")}let T=n.session_key&&$.encryptPartial&&J?{sessionKey:J,ivSessionKey:n.session_key}:void 0;if($.verbose&&$.delta)N.info("[Verbose] Starting delta/partial file upload..."),N.info(` - Manifest entries: ${d.length}`),N.info(` - Encryption: ${T?"enabled":"disabled"}`);if(Y0=$.delta?await H40(w,d,I,M,x,T,$):null,$.verbose&&Y0)N.info(`[Verbose] Delta upload complete with ${Y0.length} files`)}catch(T){if(!!($.partial||$.delta||$.partialOnly||$.deltaOnly))throw T;if(N.info(`Failed to upload partial files to capgo cloud. Error: ${s(T)}. This is not a critical error, the bundle has been uploaded without the partial files`),$.verbose)N.info(`[Verbose] Delta upload error details: ${s(T)}`)}if(n.storage_provider="r2",n.manifest=Y0,$.verbose)N.info("[Verbose] Updating version record with storage provider and manifest...");let{error:P}=await cM(C,n);if(P)ND(`Cannot update bundle ${s(P)}`);if($.verbose)N.info("[Verbose] Version record updated successfully")}if($.verbose)N.info("[Verbose] Checking app permissions...");let m=await vD(C,w,M,2,!1,!0);if($.verbose)N.info("[Verbose] Permissions:"),N.info(` - Upload: ${V7(m,2)?"yes":"no"}`),N.info(` - Write: ${V7(m,3)?"yes":"no"}`),N.info(` - Admin: ${V7(m,4)?"yes":"no"}`);if($.deleteLinkedBundleOnUpload&&V7(m,3)){if($.verbose)N.info(`[Verbose] Deleting linked bundle in channel ${_}...`);await ym0(C,M,_)}else if($.deleteLinkedBundleOnUpload)N.warn("Cannot delete linked bundle on upload as a upload organization member");if(V7(m,3)){if($.verbose)N.info(`[Verbose] Setting bundle ${z} to channel ${_}...`);if(await bm0(C,w,!!$.bundleUrl,z,_,A,x,M,R,$.selfAssign),$.verbose)N.info("[Verbose] Channel updated successfully")}else N.warn("Cannot set channel as a upload organization member");if($.verbose)N.info("[Verbose] Sending upload event...");await A0(w,{channel:"app",event:"App Uploaded",icon:"⏫",user_id:x,tags:{"app-id":M,bundle:z},notify:!1},$.verbose),await A0(w,{channel:"app",event:"Bundle Uploaded",icon:"⏫",user_id:x,tags:{"app-id":M,bundle:z},notify:!1,notifyConsole:!0}).catch(()=>{});let r={success:!0,bundle:z,checksum:n.checksum??null,encryptionMethod:L,sessionKey:J?J.toString("base64"):void 0,ivSessionKey:typeof n.session_key==="string"?n.session_key:void 0,storageProvider:n.storage_provider};if($.verbose)N.info("[Verbose] Upload completed successfully:"),N.info(` - Bundle: ${r.bundle}`),N.info(` - Checksum: ${r.checksum}`),N.info(` - Encryption: ${r.encryptionMethod}`),N.info(` - Storage: ${r.storageProvider}`);if(H&&!r.skipped){let Y0=$.showReplicationProgress;if(Y0===void 0)Y0=await s$0({preferenceKey:"uploadShowReplicationProgress",message:"Show Capgo global replication progress for this upload so you can confirm rollout in all regions?",initialValue:!1,rememberMessage:"Remember this replication progress preference for future uploads on this machine?"});if(Y0)await $60({title:"Replicating your bundle in all regions to guarantee fast updates.",completeMessage:"Replication complete. Your update is now globally available.",interactive:H})}if(X&&!r.skipped)N0("Time to share your update to the world \uD83C\uDF0D");return r}x0();w6();z1();r3();_0();import{randomUUID as gm0}from"node:crypto";import{existsSync as mm0,writeFileSync as cm0}from"node:fs";import{cwd as dm0}from"node:process";var lm0=20;function nm0(D){console.log(JSON.stringify(D,null,2))}function zJ(D){console.error(s(D))}async function z40(D,$,X=!1){let{json:J}=$,{bundle:Y,path:Q}=$,U=!J&&!X;try{if(U)await FD();let F=await I0(),Z=m0(D,F?.config),O=gm0().split("-")[0],G=P4("",$.packageJson);if(Y=Y||G||`0.0.1-beta.${O}`,U)V0(`Zipping ${Z}@${Y}`);if(Y&&!W7.test(Y)){let R=`Your bundle name ${Y}, is not valid it should follow semver convention : https://semver.org/`;if(!X)if(J)zJ({error:"invalid_semver"});else N.error(R);throw Error("Invalid bundle version format")}if(Q=Q||F?.config?.webDir,!Z||!Y||!Q){if(!X)if(J)zJ({error:"missing_argument"});else N.error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project");throw Error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project")}if(U)N.info(`Started from path "${Q}"`);if(typeof $.codeCheck>"u"?!0:$.codeCheck){if(!qJ(Q,"notifyAppReady")){if(!X)if(J)zJ({error:"notifyAppReady_not_in_source_code"});else N.error("notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugin/api/#notifyappready");throw Error("notifyAppReady() is missing in build folder")}if(!lO(Q)){if(!X)if(J)zJ({error:"index_html_not_found"});else N.error(`index.html is missing in the root folder of ${Q}`);throw Error("index.html is missing in root folder")}}let w=await eZ(Q);if(U)N.info(`Zipped ${w.byteLength} bytes`);let B=U?RD():null;if(B)B.start("Calculating checksum");let K=J1(dm0()),H=await d1("@capgo/capacitor-updater",K,$.packageJson);if(!H){if(!X)N.warn("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");throw Error("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager")}let W=!1,M;try{M=H?DD(H):void 0}catch{M=void 0}if(M)W=!K$(M,void 0,void 0,"7.0.0");else if(H==="link:@capgo/capacitor-updater"){if(!X)N.warn("Using local @capgo/capacitor-updater. Assuming v7");W=!0}let I=await J4(w,$.keyV2||mm0(s1)||W?"sha256":"crc32");if(B)B.stop(`Checksum ${W?"SHA256":"CRC32"}: ${I}`);let z=Math.floor(w.byteLength/1024/1024);if(z>lm0&&U)N.warn(`WARNING !!
502
502
  The bundle size is ${z} Mb, this may take a while to download for users
503
503
  `),N.warn(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
504
- `);let V=U?RD():null,L=$.name||`${Z}_${Y}.zip`;if(V)V.start(`Saving to ${L}`);if(cm0(L,w),V)V.stop(`Saved to ${L}`);if(U)N0("Done ✅");if(!X&&J)nm0({bundle:Y,filename:L,checksum:I});return{bundle:Y,filename:L,checksum:I}}catch(F){if(!X)if(J)zJ(F);else N.error(s(F));throw F instanceof Error?F:Error(String(F))}}x0();_0();async function W40(D,$,X,J=!1){if(!J)V0("Create channel");X.apikey=X.apikey||H0();let Y=await I0().catch(()=>{return});if($=m0($,Y?.config),!X.apikey){if(!J)N.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!J)N.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Q=await E0(X.apikey,X.supaHost,X.supaAnon);if(await lD(Q,$,J),await S0(Q,X.apikey,["write","all"]),await vD(Q,X.apikey,$,4,J,!0),!J)N.info(`Creating channel ${$}#${D} to Capgo`);let U=await iM(Q,$);if(!U){if(!J)N.error("Cannot find default version for channel creation, please contact Capgo support \uD83E\uDD28");throw Error("Cannot find default version for channel creation")}let F=await pD(Q,$),Z=await S0(Q,X.apikey,["write","all"]),O=await Ze(Q,{name:D,app_id:$,version:U.id,created_by:Z,owner_org:F,allow_device_self_set:X.selfAssign??!1,public:X.default??!1});if(O.error){if(!J)N.error(`Cannot create Channel \uD83D\uDE40
504
+ `);let V=U?RD():null,L=$.name||`${Z}_${Y}.zip`;if(V)V.start(`Saving to ${L}`);if(cm0(L,w),V)V.stop(`Saved to ${L}`);if(U)N0("Done ✅");if(!X&&J)nm0({bundle:Y,filename:L,checksum:I});return{bundle:Y,filename:L,checksum:I}}catch(F){if(!X)if(J)zJ(F);else N.error(s(F));throw F instanceof Error?F:Error(String(F))}}x0();_0();async function W40(D,$,X,J=!1){if(!J)V0("Create channel");X.apikey=X.apikey||H0();let Y=await I0(J).catch(()=>{return});if($=m0($,Y?.config),!X.apikey){if(!J)N.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!J)N.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Q=await E0(X.apikey,X.supaHost,X.supaAnon,J);if(await lD(Q,$,J),await S0(Q,X.apikey,["write","all"]),await vD(Q,X.apikey,$,4,J,!0),!J)N.info(`Creating channel ${$}#${D} to Capgo`);let U=await iM(Q,$,{silent:J});if(!U){if(!J)N.error("Cannot find default version for channel creation, please contact Capgo support \uD83E\uDD28");throw Error("Cannot find default version for channel creation")}let F=await pD(Q,$),Z=await S0(Q,X.apikey,["write","all"]),O=await Ze(Q,{name:D,app_id:$,version:U.id,created_by:Z,owner_org:F,allow_device_self_set:X.selfAssign??!1,public:X.default??!1});if(O.error){if(!J)N.error(`Cannot create Channel \uD83D\uDE40
505
505
  ${s(O.error)}`);throw Error(`Cannot create channel: ${s(O.error)}`)}if(await A0(X.apikey,{channel:"channel",event:"Create channel",icon:"✅",user_id:F,tags:{"app-id":$,channel:D},notify:!1}).catch(()=>{}),!J)N.success("Channel created ✅"),N0("Done ✅");return O.data??!0}x0();_0();async function V40(D,$,X,J=!1){let{quiet:Y}=X;if(!Y&&!J)V0("List current bundle");X.apikey=X.apikey||H0(Y);let Q=await I0();if($=m0($,Q?.config),!X.apikey){if(!J)N.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!J)N.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let U=await E0(X.apikey,X.supaHost,X.supaAnon);if(await lD(U,$,J),await S0(U,X.apikey,["write","all","read"]),await vD(U,X.apikey,$,1,J,!0),!D){if(!J)N.error("Please provide a channel to get the bundle from.");throw Error("Channel name missing")}let{data:F,error:Z}=await U.from("channels").select("version ( name )").eq("name",D).eq("app_id",$).limit(1);if(Z||!F?.length){if(!J)N.error(`Error retrieving channel ${D} for app ${$}. Perhaps the channel does not exist?`);throw Error(`Channel ${D} not found for app ${$}`)}let{version:O}=F[0];if(!O){if(!J)N.error(`Error retrieving channel ${D} for app ${$}. Perhaps the channel does not exist?`);throw Error(`Channel ${D} does not have a bundle linked`)}if(!J)if(!Y)N.info(`Current bundle for channel ${D} is ${O.name}`);else N.info(O.name);return O.name}x0();_0();async function N40(D,$,X,J=!1){if(!J)V0("Delete channel");X.apikey=X.apikey||H0();let Y=await I0();if($=m0($,Y?.config),!X.apikey){if(!J)N.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!J)N.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Q=await E0(X.apikey,X.supaHost,X.supaAnon);await lD(Q,$,J);let U=await S0(Q,X.apikey,["all"]);if(await vD(Q,X.apikey,$,4,J,!0),X.deleteBundle&&!J)N.info(`Deleting bundle ${$}#${D} from Capgo`);if(X.deleteBundle){let w=await we(Q,$,D);if(w?.name&&!J)N.info(`Deleting bundle ${w.name} from Capgo`);if(w?.name)await pM(Q,$,w.name)}let{data:F,error:Z}=await Ge(Q,$,D);if(Z||!F){if(!J)N.error(`Channel ${D} not found`);if(X.successIfNotFound){if(!J)N.success(`Channel ${D} not found and successIfNotFound is true`);return!0}throw Error(`Channel ${D} not found`)}let{error:O}=await qe(Q,$,F.id);if(O){if(!J)N.error(`Cannot delete channel devices: ${s(O)}`);throw Error(`Cannot delete channel devices: ${s(O)}`)}if(!J)N.info(`Deleting channel ${$}#${D} from Capgo`);let G=await Oe(Q,D,$,U);if(G.error){if(!J)N.error(`Cannot delete Channel \uD83D\uDE40 ${s(G.error)}`);throw Error(`Cannot delete channel: ${s(G.error)}`)}let q=await pD(Q,$);if(await A0(X.apikey,{channel:"channel",event:"Delete channel",icon:"✅",user_id:q,tags:{"app-id":$,channel:D},notify:!1}).catch(()=>{}),!J)N.success("Channel deleted"),N0("Done ✅");return!0}x0();_0();async function L40(D,$,X=!1){if(!X)V0("List channels");$.apikey=$.apikey||H0();let J=await I0();if(D=m0(D,J?.config),!$.apikey){if(!X)N.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!X)N.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Y=await E0($.apikey,$.supaHost,$.supaAnon);await lD(Y,D,X);let Q=await S0(Y,$.apikey,["write","all","read","upload"]);if(await vD(Y,$.apikey,D,1,X,!0),!X)N.info("Querying available channels in Capgo");let U=await Ke(Y,D);if(!X)N.info(`Active channels in Capgo: ${U?.length??0}`),Be(U);if(await A0($.apikey,{channel:"channel",event:"List channel",icon:"✅",user_id:Q,tags:{"app-id":D},notify:!1}).catch(()=>{}),!X)N0("Done ✅");return U}x0();G6();_0();function M40(D){let $=new ED;$.headers=["Package","Local","Remote","Status","Details"],$.theme=ED.roundTheme,$.rows=[];for(let X of D){let{name:J,localVersion:Y,remoteVersion:Q}=X,U=a8(X),F=U.compatible?"✅":"❌";$.rows.push([J,Y||"-",Q||"-",F,U.message])}N.info($.toString())}var I40=["major","minor","metadata","patch","none"];async function A40(D,$,X,J=!1){if(!J)V0("Set channel");X.apikey=X.apikey||H0();let Y=await I0();if($=m0($,Y?.config),!X.apikey){if(!J)N.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!J)N.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}if(!D){if(!J)N.error("Missing argument, you need to provide a channel");throw Error("Missing channel id")}let Q=await E0(X.apikey,X.supaHost,X.supaAnon);await lD(Q,$,J);let U=await S0(Q,X.apikey,["write","all"]);await vD(Q,X.apikey,$,4,J,!0);let F=await pD(Q,$),{bundle:Z,state:O,downgrade:G,latest:q,latestRemote:w,ios:B,android:K,selfAssign:H,disableAutoUpdate:W,dev:M,emulator:I,device:z,prod:V}=X;if(q&&Z){if(!J)N.error("Cannot set latest and bundle at the same time");throw Error("Cannot set both latest and bundle simultaneously")}if(w&&Z){if(!J)N.error("Cannot set latest remote and bundle at the same time");throw Error("Cannot set both latest remote and bundle simultaneously")}if(w&&q){if(!J)N.error("Cannot set latest remote and latest at the same time");throw Error("Cannot set both latest remote and latest simultaneously")}if(Z==null&&O==null&&q==null&&w==null&&G==null&&B==null&&K==null&&H==null&&M==null&&I==null&&z==null&&V==null&&W==null){if(!J)N.error("Missing argument, you need to provide a option to set");throw Error("No channel option provided")}await rs(Q,F,X.apikey,$);let L={created_by:U,app_id:$,name:D,owner_org:F,version:void 0},{error:R}=await Q.from("channels").select().eq("app_id",$).eq("name",D).single();if(R){if(!J)N.error(`Cannot find channel ${D}`);throw Error(`Cannot find channel ${D}`)}let C=q?Y?.config?.plugins?.CapacitorUpdater?.version||P4("",X.packageJson):Z;if(C!=null){let{data:_,error:x}=await Q.from("app_versions").select().eq("app_id",$).eq("name",C).eq("user_id",U).eq("deleted",!1).single();if(x||!_){if(!J)N.error(`Cannot find version ${C}`);throw Error(`Cannot find version ${C}`)}if(!X.ignoreMetadataCheck){let{finalCompatibility:S,localDependencies:h}=await nM(Q,$,D,_.native_packages??[]),b=S.filter((n)=>!u4(n));if(h.length>0&&b.length>0){if(!J)N.warn(`Bundle NOT compatible with ${D} channel`),N.warn(""),M40(S),N.warn(""),N.warn("An app store update may be required for these changes to take effect.");throw Error(`Bundle is not compatible with ${D} channel`)}if(!J)if(h.length===0&&S.length>0)N.info(`Ignoring check compatibility with ${D} channel because the bundle does not contain any native packages`);else N.info(`Bundle is compatible with ${D} channel`)}if(!J)N.info(`Set ${$} channel: ${D} to @${C}`);L.version=_.id}if(w){let{data:_,error:x}=await Q.from("app_versions").select().eq("app_id",$).eq("user_id",U).eq("deleted",!1).order("created_at",{ascending:!1}).single();if(x||!_){if(!J)N.error("Cannot find latest remote version");throw Error("Cannot find latest remote version")}if(!X.ignoreMetadataCheck){let{finalCompatibility:S}=await nM(Q,$,D,_.native_packages??[]);if(S.filter((b)=>!u4(b)).length>0){if(!J)N.warn(`Bundle NOT compatible with ${D} channel`),N.warn(""),M40(S),N.warn(""),N.warn("An app store update may be required for these changes to take effect.");throw Error(`Latest remote bundle is not compatible with ${D} channel`)}}if(!J)N.info(`Set ${$} channel: ${D} to @${_.name}`);L.version=_.id}if(O!=null){if(O!=="normal"&&O!=="default"){if(!J)N.error(`State ${O} is not known. The possible values are: normal, default.`);throw Error(`Unknown state ${O}. Expected normal or default`)}if(!J)N.info(`Set ${$} channel: ${D} to ${O}`);L.public=O==="default"}if(G!=null){if(!J)N.info(`Set ${$} channel: ${D} to ${G?"allow":"disallow"} downgrade`);L.disable_auto_update_under_native=!G}if(B!=null){if(!J)N.info(`Set ${$} channel: ${D} to ${B?"allow":"disallow"} ios update`);L.ios=!!B}if(K!=null){if(!J)N.info(`Set ${$} channel: ${D} to ${K?"allow":"disallow"} android update`);L.android=!!K}if(H!=null){if(!J)N.info(`Set ${$} channel: ${D} to ${H?"allow":"disallow"} self assign to this channel`);L.allow_device_self_set=!!H}if(M!=null){if(!J)N.info(`Set ${$} channel: ${D} to ${M?"allow":"disallow"} dev devices`);L.allow_dev=!!M}if(I!=null){if(!J)N.info(`Set ${$} channel: ${D} to ${I?"allow":"disallow"} emulator devices`);L.allow_emulator=!!I}if(z!=null){if(!J)N.info(`Set ${$} channel: ${D} to ${z?"allow":"disallow"} physical devices`);L.allow_device=!!z}if(V!=null){if(!J)N.info(`Set ${$} channel: ${D} to ${V?"allow":"disallow"} prod builds`);L.allow_prod=!!V}if(W!=null){let _=W.toLowerCase();if(!I40.includes(_)){if(!J)N.error(`Channel strategy ${_} is not known. The possible values are: ${I40.join(", ")}.`);throw Error(`Unknown channel strategy ${_}`)}if(_==="metadata")_="version_number";if(L.disable_auto_update=_,!J)N.info(`Set ${$} channel: ${D} to ${_} disable update strategy to this channel`)}let{error:A}=await DO(Q,L);if(A){if(!J)N.error('Cannot set channel the upload key is not allowed to do that, use the "all" for this.');throw Error("Upload key is not allowed to set this channel")}if(await A0(X.apikey,{channel:"channel",event:"Set channel",icon:"✅",user_id:F,tags:{"app-id":$},notify:!1}).catch(()=>{}),!J)N0("Done ✅");return!0}x0();import{existsSync as n7,readFileSync as im0,unlinkSync as R40,writeFileSync as E40}from"node:fs";z1();DF();_0();function j40(D){return D.plugins??={},D.plugins.extConfig??={},D.plugins.CapacitorUpdater??={},D.plugins.CapacitorUpdater}async function T40(D,$=!1){if(!$)V0("Save keys \uD83D\uDD11");let X=await I0(),J=D.key||_6,Y=D.keyData||"";if(!n7(J)&&!Y){if(!$)N.error(`Cannot find a public key at ${J} or as keyData option or in ${X.path}`);throw Error("Missing public key")}if(n7(J))Y=im0(J,"utf8");if(!Y.startsWith("-----BEGIN RSA PUBLIC KEY-----")){if(!$)N.error("The public key provided is not a valid RSA Public key");throw Error("Invalid RSA public key")}if(X?.config){let Q=j40(X.config);if(Q.privateKey){if(delete Q.privateKey,!$)N.info("Old private key deleted from config file");if($?D.setupChannel??!1:D.setupChannel??await hD({message:"Do you want to setup encryption with the new channel in order to support old apps and facilitate the migration?"}))Q.defaultChannel="encryption_v2"}Q.publicKey=Y,await _5(X)}if(!$)N.success(`Public key saved into ${X.path} file in local directory`),N.success("Your app will decode the zip archive with this key");return!0}async function C40(D,$=!1){if(!$)V0("Deleting old private key \uD83D\uDDD1️");let X=await I0(),J=X?.config?.plugins?.CapacitorUpdater;if(J?.privateKey){if(delete J.privateKey,await _5(X),n7(z7))try{if(R40(z7),!$)N.success(`Old private key file deleted: ${z7}`)}catch(Y){if(!$)N.error(`Failed to delete old private key file: ${z7} (${String(Y)})`)}if(n7(pZ))try{if(R40(pZ),!$)N.success(`Old public key file deleted: ${pZ}`)}catch(Y){if(!$)N.error(`Failed to delete old public key file: ${_6} (${String(Y)})`)}if(!$)N.success(`Old private key deleted from ${X.path} file`),N0("Done ✅");return!0}if(!$)N.info("No old private key found in config file");return!1}async function P40(D,$=!1){if(!$)V0("Create keys \uD83D\uDD11");let{publicKey:X,privateKey:J}=I$0();if(n7(_6)&&!D.force){if(!$)N.error("Public Key already exists, use --force to overwrite");throw Error("Public key already exists")}if(E40(_6,X),n7(s1)&&!D.force){if(!$)N.error("Private Key already exists, use --force to overwrite");throw Error("Private key already exists")}E40(s1,J);let Y=await I0();if(Y){let Q=j40(Y.config);if(Q.privateKey){if(delete Q.privateKey,!$)N.info("Old private key deleted from config file");if($?D.setupChannel??!1:D.setupChannel??await hD({message:"Do you want to setup encryption with the new channel in order to support old apps and facilitate the migration?"}))Q.defaultChannel="encryption_v2"}Q.publicKey=X,await _5(Y)}if(!$){N.success("Your RSA key has been generated"),N.success(`Private key saved in ${s1}`),N.success("This key will be used to encrypt your bundle before sending it to Capgo"),N.success("Keep it safe"),N.success("Then make it unreadable by Capgo and unmodifiable by anyone"),N.success(`Public key saved in ${Y.path}`),N.success("Your app will be the only one having it"),N.success("Only your users can decrypt your update"),N.success("Only you can send them an update");try{await Ue(void 0,void 0,void 0,{validateIosUpdater:!0}),N0("Done ✅")}catch(Q){if(Q instanceof Error&&Q.message==="Capacitor sync cancelled")return!0;throw Q}}return!0}x0();z1();_0();import{existsSync as pm0}from"node:fs";import{homedir as rm0}from"node:os";async function S40(D,$,X=!1){if(!X)V0("Login to Capgo");if(!D&&!X){let U=await AR({message:"Enter your API key:",mask:"*"});if(y0(U))throw N.error("Login cancelled"),Error("Login cancelled");D=U}if(!D){if(!X)N.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!X)await FD();let{local:J}=$;if(J&&!pm0(".git")){if(!X)N.error("To use local you should be in a git repository");throw Error("Not in a git repository")}let Y=await E0(D,$.supaHost,$.supaAnon),Q=await S0(Y,D,["write","all","upload"]);if(J)await P7(".capgo",`${D}
506
506
  `,{mode:384}),await f00(".gitignore",`.capgo
507
507
  `,384);else{let U=rm0();await P7(`${U}/.capgo`,`${D}
@@ -107,7 +107,7 @@ export declare function getBundleVersion(f?: string, file?: string | undefined):
107
107
  */
108
108
  export declare function getInstalledVersion(packageName: string, rootDir?: string, packageJsonPath?: string): Promise<string | null>;
109
109
  export declare function getAllPackagesDependencies(f?: string, file?: string | undefined): Promise<Map<string, string>>;
110
- export declare function getConfig(): Promise<{
110
+ export declare function getConfig(silent?: boolean): Promise<{
111
111
  config: {
112
112
  [x: string]: unknown;
113
113
  appId: string;
@@ -120,7 +120,7 @@ export declare function getConfig(): Promise<{
120
120
  }>;
121
121
  export declare function updateConfigbyKey(key: string, newConfig: any): Promise<ExtConfigPairs>;
122
122
  export declare function updateConfigUpdater(newConfig: any): Promise<ExtConfigPairs>;
123
- export declare function getLocalConfig(): Promise<CapgoConfig>;
123
+ export declare function getLocalConfig(silent?: boolean): Promise<CapgoConfig>;
124
124
  interface CapgoConfig {
125
125
  supaHost?: string;
126
126
  supaKey?: string;
@@ -129,7 +129,7 @@ interface CapgoConfig {
129
129
  hostFilesApi: string;
130
130
  hostApi: string;
131
131
  }
132
- export declare function getRemoteConfig(): Promise<CapgoConfig>;
132
+ export declare function getRemoteConfig(silent?: boolean): Promise<CapgoConfig>;
133
133
  interface CapgoFilesConfig {
134
134
  partialUpload: boolean;
135
135
  partialUploadForced: boolean;
@@ -140,7 +140,7 @@ interface CapgoFilesConfig {
140
140
  alertUploadSize: number;
141
141
  }
142
142
  export declare function getRemoteFileConfig(): Promise<CapgoFilesConfig>;
143
- export declare function createSupabaseClient(apikey: string, supaHost?: string, supaKey?: string): Promise<SupabaseClient<Database, "public", "public", {
143
+ export declare function createSupabaseClient(apikey: string, supaHost?: string, supaKey?: string, silent?: boolean): Promise<SupabaseClient<Database, "public", "public", {
144
144
  Tables: {
145
145
  apikeys: {
146
146
  Row: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
3
  "type": "module",
4
- "version": "7.89.5",
4
+ "version": "7.89.6",
5
5
  "description": "A CLI to upload to capgo servers",
6
6
  "author": "Martin martin@capgo.app",
7
7
  "license": "Apache 2.0",