UNPKG

@omer-x/buttler

Version:

automates CI/CD workflows using Docker and GitHub webhooks

1 lines 82.1 kB
exports.id=277,exports.ids=[277],exports.modules={6408:(e,t,r)=>{var i=r(27910),n=r(28354),o=i.Transform;function s(e){if(!(this instanceof s))return new s(e);this._toSkip=e.skip,o.call(this,e)}n.inherits(s,o),s.prototype._transform=function(e,t,r){0==this._toSkip?this.push(e):this._toSkip>e.length?this._toSkip-=e.length:(this._toSkip!==e.length&&this.push(e.slice(this._toSkip)),this._toSkip=0),r()},e.exports=s},7341:(e,t,r)=>{"use strict";e.exports=k,k.ReadableState=S,r(94735).EventEmitter;var i,n,o,s,a,l=function(e,t){return e.listeners(t).length},h=r(92815),u=r(79428).Buffer,f=("undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},d=r(28354);n=d&&d.debuglog?d.debuglog("stream"):function(){};var c=r(69656),p=r(75161),y=r(45934).getHighWaterMark,g=r(83796).F,b=g.ERR_INVALID_ARG_TYPE,m=g.ERR_STREAM_PUSH_AFTER_EOF,w=g.ERR_METHOD_NOT_IMPLEMENTED,_=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(59610)(k,h);var v=p.errorOrDestroy,E=["error","close","destroy","pause","resume"];function S(e,t,n){i=i||r(28947),e=e||{},"boolean"!=typeof n&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=y(this,e,"readableHighWaterMark",n),this.buffer=new c,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(o||(o=r(42638).I),this.decoder=new o(e.encoding),this.encoding=e.encoding)}function k(e){if(i=i||r(28947),!(this instanceof k))return new k(e);var t=this instanceof i;this._readableState=new S(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),h.call(this)}function R(e,t,r,i,o){n("readableAddChunk",t);var s,a,l=e._readableState;if(null===t)l.reading=!1,function(e,t){if(n("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?x(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,C(e)))}}(e,l);else if(o||(a=function(e,t){var r;return u.isBuffer(t)||t instanceof f||"string"==typeof t||void 0===t||e.objectMode||(r=new b("chunk",["string","Buffer","Uint8Array"],t)),r}(l,t)),a)v(e,a);else if(l.objectMode||t&&t.length>0)if("string"==typeof t||l.objectMode||Object.getPrototypeOf(t)===u.prototype||(s=t,t=u.from(s)),i)l.endEmitted?v(e,new _):A(e,l,t,!0);else if(l.ended)v(e,new m);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!r?(t=l.decoder.write(t),l.objectMode||0!==t.length?A(e,l,t,!1):I(e,l)):A(e,l,t,!1)}else i||(l.reading=!1,I(e,l));return!l.ended&&(l.length<l.highWaterMark||0===l.length)}function A(e,t,r,i){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&x(e)),I(e,t)}function T(e,t){var r;if(e<=0||0===t.length&&t.ended)return 0;if(t.objectMode)return 1;if(e!=e)if(t.flowing&&t.length)return t.buffer.head.data.length;else return t.length;return(e>t.highWaterMark&&((r=e)>=0x40000000?r=0x40000000:(r--,r|=r>>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r++),t.highWaterMark=r),e<=t.length)?e:t.ended?t.length:(t.needReadable=!0,0)}function x(e){var t=e._readableState;n("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(n("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(C,e))}function C(e){var t=e._readableState;n("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,L(e)}function I(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(M,e,t))}function M(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(n("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function O(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function B(e){n("readable nexttick read 0"),e.read(0)}function P(e,t){n("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),L(e),t.flowing&&!t.reading&&e.read(0)}function L(e){var t=e._readableState;for(n("flow",t.flowing);t.flowing&&null!==e.read(););}function j(e,t){var r;return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r)}function N(e){var t=e._readableState;n("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(D,t,e))}function D(e,t){if(n("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function U(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return -1}Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),k.prototype.destroy=p.destroy,k.prototype._undestroy=p.undestroy,k.prototype._destroy=function(e,t){t(e)},k.prototype.push=function(e,t){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof e&&((t=t||i.defaultEncoding)!==i.encoding&&(e=u.from(e,t),t=""),r=!0),R(this,e,t,!1,r)},k.prototype.unshift=function(e){return R(this,e,null,!0,!1)},k.prototype.isPaused=function(){return!1===this._readableState.flowing},k.prototype.setEncoding=function(e){o||(o=r(42638).I);var t=new o(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var i=this._readableState.buffer.head,n="";null!==i;)n+=t.write(i.data),i=i.next;return this._readableState.buffer.clear(),""!==n&&this._readableState.buffer.push(n),this._readableState.length=n.length,this},k.prototype.read=function(e){n("read",e),e=parseInt(e,10);var t,r=this._readableState,i=e;if(0!==e&&(r.emittedReadable=!1),0===e&&r.needReadable&&((0!==r.highWaterMark?r.length>=r.highWaterMark:r.length>0)||r.ended))return n("read: emitReadable",r.length,r.ended),0===r.length&&r.ended?N(this):x(this),null;if(0===(e=T(e,r))&&r.ended)return 0===r.length&&N(this),null;var o=r.needReadable;return n("need readable",o),(0===r.length||r.length-e<r.highWaterMark)&&n("length less than watermark",o=!0),r.ended||r.reading?n("reading or ended",o=!1):o&&(n("do read"),r.reading=!0,r.sync=!0,0===r.length&&(r.needReadable=!0),this._read(r.highWaterMark),r.sync=!1,r.reading||(e=T(i,r))),null===(t=e>0?j(e,r):null)?(r.needReadable=r.length<=r.highWaterMark,e=0):(r.length-=e,r.awaitDrain=0),0===r.length&&(r.ended||(r.needReadable=!0),i!==e&&r.ended&&N(this)),null!==t&&this.emit("data",t),t},k.prototype._read=function(e){v(this,new w("_read()"))},k.prototype.pipe=function(e,t){var r,i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,n("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===process.stdout||e===process.stderr?y:a;function a(){n("onend"),e.end()}o.endEmitted?process.nextTick(s):i.once("end",s),e.on("unpipe",function t(r,s){n("onunpipe"),r===i&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,n("cleanup"),e.removeListener("close",c),e.removeListener("finish",p),e.removeListener("drain",h),e.removeListener("error",d),e.removeListener("unpipe",t),i.removeListener("end",a),i.removeListener("end",y),i.removeListener("data",f),u=!0,o.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&h())});var h=(r=i,function(){var e=r._readableState;n("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&l(r,"data")&&(e.flowing=!0,L(r))});e.on("drain",h);var u=!1;function f(t){n("ondata");var r=e.write(t);n("dest.write",r),!1===r&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==U(o.pipes,e))&&!u&&(n("false write response, pause",o.awaitDrain),o.awaitDrain++),i.pause())}function d(t){n("onerror",t),y(),e.removeListener("error",d),0===l(e,"error")&&v(e,t)}function c(){e.removeListener("finish",p),y()}function p(){n("onfinish"),e.removeListener("close",c),y()}function y(){n("unpipe"),i.unpipe(e)}return i.on("data",f),!function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",c),e.once("finish",p),e.emit("pipe",i),o.flowing||(n("pipe resume"),i.resume()),e},k.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=U(t.pipes,e);return -1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},k.prototype.on=function(e,t){var r=h.prototype.on.call(this,e,t),i=this._readableState;return"data"===e?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"!==e||i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,n("on readable",i.length,i.reading),i.length?x(this):i.reading||process.nextTick(B,this)),r},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(e,t){var r=h.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(O,this),r},k.prototype.removeAllListeners=function(e){var t=h.prototype.removeAllListeners.apply(this,arguments);return("readable"===e||void 0===e)&&process.nextTick(O,this),t},k.prototype.resume=function(){var e,t,r=this._readableState;return r.flowing||(n("resume"),r.flowing=!r.readableListening,e=this,(t=r).resumeScheduled||(t.resumeScheduled=!0,process.nextTick(P,e,t))),r.paused=!1,this},k.prototype.pause=function(){return n("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(n("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;for(var o in e.on("end",function(){if(n("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(o){if(n("wrapped data"),r.decoder&&(o=r.decoder.write(o)),!r.objectMode||null!=o)(r.objectMode||o&&o.length)&&(t.push(o)||(i=!0,e.pause()))}),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var s=0;s<E.length;s++)e.on(E[s],this.emit.bind(this,E[s]));return this._read=function(t){n("wrapped _read",t),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(k.prototype[Symbol.asyncIterator]=function(){return void 0===s&&(s=r(93724)),s(this)}),Object.defineProperty(k.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),k._fromList=j,Object.defineProperty(k.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(k.from=function(e,t){return void 0===a&&(a=r(49807)),a(k,e,t)})},10365:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},11953:e=>{e.exports=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(function(e){if(e.buffer.length){var t=e.bufferIndex||0;if(e.buffer.head)return e.buffer.head.data.length;if(e.buffer.length-t>0&&e.buffer[t])return e.buffer[t].length}return e.length}(t)):null}},20429:(e,t,r)=>{"use strict";function i(e){var t=this;this.next=null,this.entry=null,this.finish=function(){var r,i=t,n=e,o=i.entry;for(i.entry=null;o;){var s=o.callback;n.pendingcb--,s(void 0),o=o.next}n.corkedRequestsFree.next=i}}e.exports=k,k.WritableState=S;var n,o,s={deprecate:r(87464)},a=r(92815),l=r(79428).Buffer,h=("undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},u=r(75161),f=r(45934).getHighWaterMark,d=r(83796).F,c=d.ERR_INVALID_ARG_TYPE,p=d.ERR_METHOD_NOT_IMPLEMENTED,y=d.ERR_MULTIPLE_CALLBACK,g=d.ERR_STREAM_CANNOT_PIPE,b=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,w=d.ERR_STREAM_WRITE_AFTER_END,_=d.ERR_UNKNOWN_ENCODING,v=u.errorOrDestroy;function E(){}function S(e,t,o){n=n||r(28947),e=e||{},"boolean"!=typeof o&&(o=t instanceof n),this.objectMode=!!e.objectMode,o&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=f(this,e,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if("function"!=typeof n)throw new y;if(r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,t)--r.pendingcb,i?(process.nextTick(n,t),process.nextTick(I,e,r),e._writableState.errorEmitted=!0,v(e,t)):(n(t),e._writableState.errorEmitted=!0,v(e,t),I(e,r));else{var o=x(r)||e.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||T(e,r),i?process.nextTick(A,e,r,o,n):A(e,r,o,n)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}r(59610)(k,a),S.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t};try{Object.defineProperty(S.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}function k(e){var t=this instanceof(n=n||r(28947));if(!t&&!o.call(k,this))return new k(e);this._writableState=new S(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),a.call(this)}function R(e,t,r,i,n,o,s){t.writelen=i,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new b("write")):r?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function A(e,t,r,i){var n,o;r||(n=e,0===(o=t).length&&o.needDrain&&(o.needDrain=!1,n.emit("drain"))),t.pendingcb--,i(),I(e,t)}function T(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=Array(t.bufferedRequestCount),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)n[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;n.allBuffers=a,R(e,t,!0,t.length,n,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new i(t),t.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,h=r.encoding,u=r.callback,f=t.objectMode?1:l.length;if(R(e,t,!1,f,l,h,u),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function x(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function C(e,t){e._final(function(r){t.pendingcb--,r&&v(e,r),t.prefinished=!0,e.emit("prefinish"),I(e,t)})}function I(e,t){var r=x(t);if(r&&(t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,process.nextTick(C,e,t))),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var i=e._readableState;(!i||i.autoDestroy&&i.endEmitted)&&e.destroy()}return r}"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(o=Function.prototype[Symbol.hasInstance],Object.defineProperty(k,Symbol.hasInstance,{value:function(e){return!!o.call(this,e)||this===k&&e&&e._writableState instanceof S}})):o=function(e){return e instanceof this},k.prototype.pipe=function(){v(this,new g)},k.prototype.write=function(e,t,r){var i,n,o,s,a,u,f,d=this._writableState,p=!1,y=!d.objectMode&&(i=e,l.isBuffer(i)||i instanceof h);return(y&&!l.isBuffer(e)&&(n=e,e=l.from(n)),"function"==typeof t&&(r=t,t=null),y?t="buffer":t||(t=d.defaultEncoding),"function"!=typeof r&&(r=E),d.ending)?(o=r,v(this,s=new w),process.nextTick(o,s)):(y||(a=e,u=r,null===a?f=new m:"string"==typeof a||d.objectMode||(f=new c("chunk",["string","Buffer"],a)),!f||(v(this,f),process.nextTick(u,f),0)))&&(d.pendingcb++,p=function(e,t,r,i,n,o){if(!r){var s,a,h=(s=i,a=n,t.objectMode||!1===t.decodeStrings||"string"!=typeof s||(s=l.from(s,a)),s);i!==h&&(r=!0,n="buffer",i=h)}var u=t.objectMode?1:i.length;t.length+=u;var f=t.length<t.highWaterMark;if(f||(t.needDrain=!0),t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else R(e,t,!1,u,i,n,o);return f}(this,d,y,e,t,r)),p},k.prototype.cork=function(){this._writableState.corked++},k.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||T(this,e))},k.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new _(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(e,t,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(e,t,r){var i,n,o,s=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),s.corked&&(s.corked=1,this.uncork()),s.ending||(i=this,n=s,o=r,n.ending=!0,I(i,n),o&&(n.finished?process.nextTick(o):i.once("finish",o)),n.ended=!0,i.writable=!1),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),k.prototype.destroy=u.destroy,k.prototype._undestroy=u.undestroy,k.prototype._destroy=function(e,t){t(e)}},28947:(e,t,r)=>{"use strict";var i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=h;var n=r(7341),o=r(20429);r(59610)(h,n);for(var s=i(o.prototype),a=0;a<s.length;a++){var l=s[a];h.prototype[l]||(h.prototype[l]=o.prototype[l])}function h(e){if(!(this instanceof h))return new h(e);n.call(this,e),o.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",u)))}function u(){this._writableState.ended||process.nextTick(f,this)}function f(e){e.end()}Object.defineProperty(h.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(h.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(h.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(h.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})},32248:(e,t,r)=>{var i=r(54735),n=r(81584),o=r(59610),s=r(11953),a=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},h=function(e,t){e._autoDestroy&&e.destroy(t)},u=function(e,t){return function(r){r?h(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},f=function(){},d=function(e,t,r){if(!(this instanceof d))return new d(e,t,r);i.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};o(d,i.Duplex),d.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new d(e,t,r)},d.prototype.cork=function(){1==++this._corked&&this.emit("cork")},d.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},d.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed){e&&e.destroy&&e.destroy();return}if(null===e||!1===e)return void this.end();var t=this,r=n(e,{writable:!0,readable:!1},u(this,this._forwardEnd)),i=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&process.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=function(){t._writable.removeListener("drain",i),r()},this.uncork()},d.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed){e&&e.destroy&&e.destroy();return}if(null===e||!1===e){this.push(null),this.resume();return}var t=this,r=n(e,{writable:!1,readable:!0},u(this)),o=function(){t._forward()},s=function(){t.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:new i.Readable({objectMode:!0,highWaterMark:16}).wrap(e),this._readable2.on("readable",o),this._readable2.on("end",s),this._unread=function(){t._readable2.removeListener("readable",o),t._readable2.removeListener("end",s),r()},this._forward()},d.prototype._read=function(){this._drained=!0,this._forward()},d.prototype._forward=function(){var e;if(!this._forwarding&&this._readable2&&this._drained){for(this._forwarding=!0;this._drained&&null!==(e=s(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},d.prototype.destroy=function(e,t){if(t||(t=f),this.destroyed)return t(null);this.destroyed=!0;var r=this;process.nextTick(function(){r._destroy(e),t(null)})},d.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},d.prototype._write=function(e,t,r){if(!this.destroyed){if(this._corked)return l(this,this._write.bind(this,e,t,r));if(e===a)return this._finish(r);if(!this._writable)return r();!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()}},d.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,function(){var r,i;r=t._forwardEnd&&t._writable,i=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)},!r||r._writableState&&r._writableState.finished?i():r._writableState?r.end(i):(r.end(),i())})},d.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(a),i.Writable.prototype.end.call(this,r))},e.exports=d},42638:(e,t,r)=>{"use strict";var i=r(45158).Buffer,n=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){var t;if(!e)return"utf8";for(;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===n||!n(e)))throw Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=h,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=u,this.end=f,t=3;break;default:this.write=d,this.end=c;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if((192&t[0])!=128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((192&t[1])!=128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(192&t[2])!=128)return e.lastNeed=2,"�"}}(this,e,0);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length)}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function h(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function c(e){return e&&e.length?this.write(e):""}t.I=o,o.prototype.write=function(e){var t,r;if(0===e.length)return"";if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},o.prototype.text=function(e,t){var r=function(e,t,r){var i=t.length-1;if(i<r)return 0;var n=s(t[i]);return n>=0?(n>0&&(e.lastNeed=n-1),n):--i<r||-2===n?0:(n=s(t[i]))>=0?(n>0&&(e.lastNeed=n-2),n):--i<r||-2===n?0:(n=s(t[i]))>=0?(n>0&&(2===n?n=0:e.lastNeed=n-3),n):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},45158:(e,t,r)=>{var i=r(79428),n=i.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=i:(o(i,t),t.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(e,t,r){if("number"==typeof e)throw TypeError("Argument must not be a number");return n(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},s.allocUnsafe=function(e){if("number"!=typeof e)throw TypeError("Argument must be a number");return n(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw TypeError("Argument must be a number");return i.SlowBuffer(e)}},45934:(e,t,r)=>{"use strict";var i=r(83796).F.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,r,n){var o=null!=t.highWaterMark?t.highWaterMark:n?t[r]:null;if(null!=o){if(!(isFinite(o)&&Math.floor(o)===o)||o<0)throw new i(n?r:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},47535:(e,t,r)=>{"use strict";e.exports=n;var i=r(65225);function n(e){if(!(this instanceof n))return new n(e);i.call(this,e)}r(59610)(n,i),n.prototype._transform=function(e,t,r){r(null,e)}},49807:(e,t,r)=>{"use strict";function i(e,t,r,i,n,o,s){try{var a=e[o](s),l=a.value}catch(e){r(e);return}a.done?t(l):Promise.resolve(l).then(i,n)}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}var o=r(83796).F.ERR_INVALID_ARG_TYPE;e.exports=function(e,t,r){if(t&&"function"==typeof t.next)s=t;else if(t&&t[Symbol.asyncIterator])s=t[Symbol.asyncIterator]();else if(t&&t[Symbol.iterator])s=t[Symbol.iterator]();else throw new o("iterable",["Iterable"],t);var s,a=new e(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){var i,n,o;i=e,n=t,o=r[t],(n=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(n))in i?Object.defineProperty(i,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):i[n]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({objectMode:!0},r)),l=!1;function h(){return u.apply(this,arguments)}function u(){var e;return e=function*(){try{var e=yield s.next(),t=e.value;e.done?a.push(null):a.push((yield t))?h():l=!1}catch(e){a.destroy(e)}},(u=function(){var t=this,r=arguments;return new Promise(function(n,o){var s=e.apply(t,r);function a(e){i(s,n,o,a,l,"next",e)}function l(e){i(s,n,o,a,l,"throw",e)}a(void 0)})}).apply(this,arguments)}return a._read=function(){l||(l=!0,h())},a}},50277:(e,t,r)=>{"use strict";r.d(t,{wc:()=>G});var i=r(27910),n=r(96848),o=r(55511),s=r(94735),a=r(81630),l=r(55591),h=r(6408);function u(e,t){let r,i=[];e.on("data",e=>i.push(e)),e.on("end",()=>{r||(r=!0,t(null,Buffer.concat(i)))}),e.on("error",e=>{r||(r=!0,t(e))})}function f(e){let t;return new i.Transform({transform(r,i,n){t&&(r=Buffer.concat([t,r]));let o=Math.floor(r.length/e)*e;o?r.length>o?(t=r.slice(o),this.push(r.slice(0,o))):(t=void 0,this.push(r)):t=t?Buffer.concat([t,r]):r,n()},flush(e){t&&this.push(t),e()}})}function d(e){let t,r=new Promise((e,r)=>{t=(t,i)=>{t?r(t):e(i)}});return e&&r.then(t=>e(null,t),e),[t,r]}var c=class{constructor(e){if(16!==e.length)throw Error("Wrong key length. Key must be 128bit.");this.key=e}encryptCBC(e){let t=Buffer.alloc(16,0),r=o.createCipheriv("aes-128-cbc",this.key,t).setAutoPadding(!1),i=Buffer.concat([r.update(e),r.final()]);return i.copy(e),i}decryptCBC(e){let t=Buffer.alloc(16,0),r=o.createDecipheriv("aes-128-cbc",this.key,t).setAutoPadding(!1),i=Buffer.concat([r.update(e),r.final()]);return i.copy(e),i}stringhash(e){let t=[0,0,0,0];for(let r=0;r<e.length;r+=4)if(e.length-r<4){let i=e.length-r;t[r/4&3]^=e.readIntBE(r,i)<<(4-i)*8}else t[r/4&3]^=e.readInt32BE(r);let r=Buffer.allocUnsafe(16);for(let e=0;e<4;e++)r.writeInt32BE(t[e],4*e,!0);let i=o.createCipheriv("aes-128-ecb",this.key,Buffer.alloc(0));for(let e=16384;e--;)r=i.update(r);let n=Buffer.allocUnsafe(8);return r.copy(n,0,0,4),r.copy(n,4,8,12),n}encryptECB(e){let t=o.createCipheriv("aes-128-ecb",this.key,Buffer.alloc(0)).setAutoPadding(!1).update(e);return t.copy(e),t}decryptECB(e){let t=o.createDecipheriv("aes-128-ecb",this.key,Buffer.alloc(0)).setAutoPadding(!1).update(e);return t.copy(e),t}},p=class{constructor(e,t,r=0){this.key=e.key,this.nonce=t.slice(0,8);let i=Buffer.alloc(16);this.nonce.copy(i,0),0!==r&&this.incrementCTRBuffer(i,r/16),this.encrypt=e=>(this.encryptCipher=o.createCipheriv("aes-128-ctr",this.key,i),this.encrypt=this._encrypt,this.encrypt(e)),this.decrypt=e=>(this.decryptCipher=o.createDecipheriv("aes-128-ctr",this.key,i),this.decrypt=this._decrypt,this.decrypt(e))}_encrypt(e){return this.encryptCipher.update(e).copy(e),e}_decrypt(e){return this.decryptCipher.update(e).copy(e),e}incrementCTRBuffer(e,t){let r,i=e.length,n=i-1;for(;0!==t;)r=(t+e[n])%256,t=Math.floor((t+e[n])/256),e[n]=r,(n-=1)<0&&(n=i-1)}},y=class{constructor(e,t){this.key=e.key,this.nonce=t.slice(0,8),this.macCipher=o.createCipheriv("aes-128-ecb",this.key,Buffer.alloc(0)),this.posNext=this.increment=131072,this.pos=0,this.macs=[],this.mac=Buffer.alloc(16),this.nonce.copy(this.mac,0),this.nonce.copy(this.mac,8)}condense(){this.mac&&(this.macs.push(this.mac),this.mac=void 0);let e=Buffer.alloc(16,0);for(let t of this.macs){for(let r=0;r<16;r++)e[r]^=t[r];e=this.macCipher.update(e)}let t=Buffer.allocUnsafe(8);return t.writeInt32BE(e.readInt32BE(0)^e.readInt32BE(4),0),t.writeInt32BE(e.readInt32BE(8)^e.readInt32BE(12),4),t}update(e){for(let t=0;t<e.length;t+=16){for(let r=0;r<16;r++)this.mac[r]^=e[t+r];this.mac=this.macCipher.update(this.mac),this.checkBounding()}}checkBounding(){this.pos+=16,this.pos>=this.posNext&&(this.macs.push(Buffer.from(this.mac)),this.nonce.copy(this.mac,0),this.nonce.copy(this.mac,8),this.increment<1048576&&(this.increment+=131072),this.posNext+=this.increment)}};function g(e){return"string"==typeof e?m(e):e}function b(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function m(e){return Buffer.from(e,"base64")}function w(e){return new c(_(e).slice(0,16))}function _(e){let t=Buffer.alloc(32);e.copy(t);for(let e=0;e<16;e++)t.writeUInt8(t.readUInt8(e)^t.readUInt8(16+e,!0),e);return t}async function v(e){let[t,r,,i]=e.split(":");if(1!==Number(t))throw Error("hashcash challenge is not version 1");let n=Number(r),o=((63&n)<<1)+1<<(n>>6)*7+3,s=m(i),a=Buffer.alloc(0xc00004);for(let e=0;e<262144;e++)a.set(s,4+48*e);for(;;){if(new DataView(await globalThis.crypto.subtle.digest("SHA-256",a)).getUint32(0)<=o)return`1:${i}:${b(a.slice(0,4))}`;let e=0;for(;a[e]++,!a[e++];);}}var E={},S=Math.log(2);function k(e){let t=[];for(;e-- >0;)t[e]=0;return t}function R(e){let t=e.length;if(e[t-1])return e;for(;t>1&&0===e[t-1];)t--;return e.slice(0,t)}function A(e,t){let r,i=e.length,n=t.length;if(n>i)return[];if(n===i){if(t[n-1]>e[n-1])return[];if(1===n)return[e[0]-t[0]]}let o=[],s=0;for(r=0;r<n;r++)s+=e[r]-t[r],o[r]=0xfffffff&s,s>>=28;for(;r<i;r++)s+=e[r],o[r]=0xfffffff&s,s>>=28;return s?[]:R(o)}function T(e,t,r,i,n){let o=16383&r,s=r>>14,a=16383&i,l=i>>14,h=s*a+l*o,u=o*a+((16383&h)<<14)+e[t]+n;return e[t]=0xfffffff&u,n=s*l+(h>>14)+(u>>28)}function x(e,t){let r,i,n,o=e.length,s=t.length,a=k(o+s-1);for(i=0;i<s;i++){for(n=0,r=0;n<o;n++)r=T(a,i+n,e[n],t[i],r);a[i+o]=r}return R(a)}function C(e,t,r){let i=0;for(;t>=0&&r-- >0;)i=0x10000000*i+e[t--];return i}function I(e,t){let r,i,n,o,s,a,l=e.length-1,h=t.length-1,u=l-h;if(l<h||l===h&&(e[l]<t[l]||l>0&&e[l]===t[l]&&e[l-1]<t[l-1]))return E.q=[0],E.mod=e,E;if(l===h&&C(e,h,2)/C(t,h,2)<4){for(r=e.concat(),i=0;0!==(n=A(r,t)).length;)r=n,i++;return E.q=[i],E.mod=r,E}let f=Math.floor(Math.log(t[h])/S)+1,d=28-f;r=e.concat();let c=t.concat();if(d){for(o=h;o>0;o--)c[o]=c[o]<<d&0xfffffff|c[o-1]>>f;for(c[0]=c[0]<<d&0xfffffff,r[l]&(0xfffffff<<f&0xfffffff)&&(r[++l]=0,u++),o=l;o>0;o--)r[o]=r[o]<<d&0xfffffff|r[o-1]>>f;r[0]=r[0]<<d&0xfffffff}let p=k(u+1),y=k(u).concat(c);for(;0!==(s=A(r,y)).length;)p[u]++,r=s;let g=c[h],b=C(c,h,2);for(o=l;o>h;o--){a=o-h-1,o>=r.length?p[a]=1:r[o]===g?p[a]=0xfffffff:p[a]=Math.floor(C(r,o,2)/g);let e=C(r,o,3);for(;p[a]*b>e;)p[a]--;y=y.slice(1),0===(s=A(r,x([p[a]],y))).length&&(p[a]--,s=A(r,x([p[a]],y))),r=s}if(d){for(o=0;o<r.length-1;o++)r[o]=r[o]>>d|r[o+1]<<f&0xfffffff;r[r.length-1]>>=d}return E.q=R(p),E.mod=R(r),E}function M(e,t){if(1===t.length){if(1===e.length)return[e[0]%t[0]];if(t[0]<16383)return[function(e,t){let r,i=0;for(let n=e.length-1;n>=0;n--)i=(((r=e[n])>>14)+(i<<14))%t,i=((16383&r)+(i<<14))%t;return i}(e,t[0])]}return I(e,t).mod}function O(e,t,r){let i,n=e.length-(t.length<<1);if(n>0)return O(e.slice(0,n).concat(O(e.slice(n),t,r)),t,r);let o=t.length+1,s=t.length-1,a=x(e.slice(s),r).slice(o),l=e.slice(0,o),h=x(a,t).slice(0,o),u=A(l,h);0===u.length&&(l[o]=1,u=A(l,h));for(let e=0;0!==(i=A(u,t)).length;e++)if(u=i,e>=3)return O(u,t,r);return u}function B(e,t,r){var i;let n,o,s=e.concat(),a=t.length-1,l=2*r.length,h=k(l+1);for(h[l]=1,h=I(h,r).q,i=t[a],o=1,0!=(n=i>>>16)&&(i=n,o+=16),0!=(n=i>>8)&&(i=n,o+=8),0!=(n=i>>4)&&(i=n,o+=4),0!=(n=i>>2)&&(i=n,o+=2),0!=(n=i>>1)&&(i=n,o+=1),l=o-2;a>=0;a--){for(;l>=0;l-=1)s=O(function(e){let t,r,i=e.length,n=k(2*i),o=0;for(t=0;t<i;t++){for(o=T(n,2*t,e[t],e[t],0),r=t+1;r<i;r++)o=T(n,t+r,2*e[r],e[t],o);n[t+i]=o}return R(n)}(s),r,h),t[a]&1<<l&&(s=O(x(s,e),r,h));l=27}return s}function P(e){let t,r=1,i=[0],n=0,o=256,s=e.length;if(s<2)return 0;let a=(s-2)*8,l=256*e.charCodeAt(0)+e.charCodeAt(1);if(l>a||l<a-8)return 0;for(let l=0;l<a;l++)(o<<=1)>255&&(o=1,t=e.charCodeAt(--s)),r>0xfffffff&&(r=1,i[++n]=0),t&o&&(i[n]|=r),r<<=1;return i}function L(e,t){let r=function(e){let t,r=1,i=0,n=[0],o=1,s=0,a=28*e.length,l="";for(t=0;t<a;t++)e[i]&r&&(n[s]|=o),(o<<=1)>255&&(o=1,n[++s]=0),(r<<=1)>0xfffffff&&(r=1,i++);for(;s>=0&&0===n[s];)s--;for(t=0;t<=s;t++)l=String.fromCharCode(n[t])+l;return l}(function(e,t,r,i,n){let o=B(M(e,r),M(t,A(r,[1])),r),s=B(M(e,i),M(t,A(i,[1])),i),a=A(s,o);return 0===a.length?(a=M(x(a=A(o,s),n),i),a=A(i,a)):a=M(x(a,n),i),function e(t,r){let i=t.length,n=r.length;if(i<n)return e(r,t);let o=[],s=0,a=0;for(;a<n;a++)s+=t[a]+r[a],o[a]=0xfffffff&s,s>>>=28;for(;a<i;a++)s+=t[a],o[a]=0xfffffff&s,s>>>=28;return s&&(o[a]=s),o}(x(a,r),o)}(P(e.toString("binary")),t[2],t[0],t[1],t[3]));return Buffer.from(r,"binary")}var j={1:"EINTERNAL (-1): An internal error has occurred. Please submit a bug report, detailing the exact circumstances in which this error occurred.",2:"EARGS (-2): You have passed invalid arguments to this command.",3:"EAGAIN (-3): A temporary congestion or server malfunction prevented your request from being processed. No data was altered. Retried 4 times.",4:"ERATELIMIT (-4): You have exceeded your command weight per time quota. Please wait a few seconds, then try again (this should never happen in sane real-life applications).",5:"EFAILED (-5): The upload failed. Please restart it from scratch.",6:"ETOOMANY (-6): Too many concurrent IP addresses are accessing this upload target URL.",7:"ERANGE (-7): The upload file packet is out of range or not starting and ending on a chunk boundary.",8:"EEXPIRED (-8): The upload target URL you are trying to access has expired. Please request a fresh one.",9:"ENOENT (-9): Object (typically, node or user) not found. Wrong password?",10:"ECIRCULAR (-10): Circular linkage attempted",11:"EACCESS (-11): Access violation (e.g., trying to write to a read-only share)",12:"EEXIST (-12): Trying to create an object that already exists",13:"EINCOMPLETE (-13): Trying to access an incomplete resource",14:"EKEY (-14): A decryption operation failed (never returned by the API)",15:"ESID (-15): Invalid or expired user session, please relogin",16:"EBLOCKED (-16): User blocked",17:"EOVERQUOTA (-17): Request over quota",18:"ETEMPUNAVAIL (-18): Resource temporarily not available, please try again later",19:"ETOOMANYCONNECTIONS (-19)",24:"EGOINGOVERQUOTA (-24)",25:"EROLLEDBACK (-25)",26:"EMFAREQUIRED (-26): Multi-Factor Authentication Required",27:"EMASTERONLY (-27)",28:"EBUSINESSPASTDUE (-28)",29:"EPAYWALL (-29): ODQ paywall state",400:"ETOOERR (-400)",401:"ESHAREROVERQUOTA (-401)"},N=new a.Agent({keepAlive:!0}),D=new l.Agent({keepAlive:!0}),U=class e extends s.EventEmitter{constructor(t,r={}){super(),this.keepalive=t,this.counterId=Math.random().toString().substr(2,10),this.gateway=r.gateway||"https://g.api.mega.co.nz/";let i=e.getShouldAvoidUA();this.userAgent=null===r.userAgent||i?null:`${r.userAgent||""} megajs/1.3.6`.trim(),this.httpAgent=r.httpAgent||N,this.httpsAgent=r.httpsAgent||D,this.fetch=r.fetch||this.defaultFetch.bind(this),this.closed=!1}async defaultFetch(t,r){if(r||(r={}),r.agent||(r.agent=e=>"http:"===e.protocol?this.httpAgent:this.httpsAgent),this.userAgent&&(r.headers||(r.headers={}),r.headers["user-agent"]||(r.headers["user-agent"]=this.userAgent)),!e.fetchModule)if("function"==typeof globalThis.fetch)e.fetchModule=globalThis.fetch.bind(globalThis);else throw Error("globalThis.fetch not found!");return e.fetchModule(t,r)}request(e,t,r=0){let i="sml"===e.a;if(this.closed&&!i)throw Error("API is closed");let[n,o]=d(t);"string"!=typeof e._hashcash&&this.counterId++;let s={id:this.counterId.toString()};this.sid&&(s.sid=this.sid),"object"==typeof e._querystring&&(Object.assign(s,e._querystring),delete e._querystring);let a={"Content-Type":"application/json"};return"string"==typeof e._hashcash&&(a["X-Hashcash"]=e._hashcash,delete e._hashcash),this.fetch(`${this.gateway}cs?${new URLSearchParams(s)}`,{method:"POST",headers:a,body:JSON.stringify([e])}).then(async t=>{let r=t.headers.get("X-Hashcash");return r?(e._hashcash=await v(r),-3):q(t)}).then(t=>{let o;if(!this.closed||i){if(!t)return n(Error("Empty response"));if(t.length&&(t=t[0]),"number"==typeof t&&t<0){if(-3===t&&r<4)return setTimeout(()=>{this.request(e,n,r+1)},1e3*Math.pow(2,r+1));o=Error(j[-t])}else this.keepalive&&t&&t.sn&&this.pull(t.sn);n(o,t)}}).catch(e=>{n(e)}),o}pull(t,r=0){let i=new AbortController,n=+!!e.handleForceHttps();this.sn=i,this.fetch(`${this.gateway}sc?${new URLSearchParams({sn:t,ssl:n,sid:this.sid})}`,{method:"POST",signal:i.signal}).then(q).then(e=>{if(this.sn=void 0,!this.closed){if("number"==typeof e&&e<0){if(-3===e&&r<4)return setTimeout(()=>{this.pull(t,r+1)},1e3*Math.pow(2,r+1));this.emit("error",Error(j[-e]))}e.w?this.wait(e.w,t):e.sn&&(e.a&&this.emit("sc",e.a),this.pull(e.sn))}}).catch(F).catch(e=>{this.emit("error",e)})}wait(e,t){let r=new AbortController;this.sn=r,this.fetch(e,{method:"POST",signal:r.signal}).catch(()=>{}).then(()=>{this.sn=void 0,this.pull(t)})}close(){this.sn&&this.sn.abort(),this.closed=!0}static getGlobalApi(){return e.globalApi||(e.globalApi=new e),e.globalApi}static handleForceHttps(e){return null!=e?e:!!globalThis.isSecureContext}static getShouldAvoidUA(){let e;try{globalThis.Headers()}catch(t){e=t.message}return!(38===(globalThis.fetch+"").length&&e.includes("Headers"))}};function q(e){if("Server Too Busy"===e.statusText)return -3;if(!e.ok)throw Error(`Server returned error: ${e.statusText}`);return e.json()}function F(e){if("AbortError"!==e.name)throw e}var W=["","red","orange","yellow","green","blue","purple","grey"],H=class e extends s.EventEmitter{constructor(e){if(super(),this.checkConstructorArgument(e.downloadId),this.checkConstructorArgument(e.key),this.checkConstructorArgument(e.loadedFile),this.downloadId=e.downloadId,this.key=e.key?g(e.key):null,this.type=+!!e.directory,this.directory=!!e.directory,this.directory&&!this.children&&(this.children=[]),this.api=e.api||U.getGlobalApi(),!(this.api instanceof U))throw Error("api must be a instance of API");this.loadedFile=e.loadedFile}get createdAt(){if(void 0!==this.timestamp)return 1e3*this.timestamp}checkConstructorArgument(e){if("string"==typeof e&&!/^[\w-]+$/.test(e))throw Error(`Invalid argument: "${e}"`)}loadMetadata(e,t){if(this.size=t.s||0,this.timestamp=t.ts||0,this.type=t.t,this.directory=!!t.t,this.owner=t.u,this.name=null,this.directory&&!this.children&&(this.children=[]),!e||!t.k)return;let r=t.k.split(":");this.key=g(r[r.length-1]),this.key.length<=32?e.decryptECB(this.key):this.storage?this.key=this.storage.decryptRsaKey(this.key).slice(0,this.directory?16:32):this.key=null,t.a&&this.decryptAttributes(t.a)}decryptAttributes(t){if(!this.key)return this;t=m(t),w(this.key).decryptCBC(t);let r=e.unpackAttributes(t);r&&this.parseAttributes(r)}parseAttributes(e){this.attributes=e,this.name=e.n,this.label=W[e.lbl||0],this.favorited=!!e.fav}loadAttributes(t){let[r,i]=d(t),n=this.directory?{a:"f",c:1,ca:1,r:1,_querystring:{n:this.downloadId}}:{a:"g",p:this.downloadId};return this.api.request(n,(t,i)=>{if(t)return r(t);if(this.directory){let t=Object.create(null),n=i.f,o=n.find(e=>e.k&&e.h===e.k.split(":")[0]),s=this.key?new c(this.key):null;for(let r of(this.nodeId=o.h,this.timestamp=o.ts,t[o.h]=this,n)){if(r===o)continue;let i=new e(r,this.storage);i.loadMetadata(s,r),i.downloadId=[this.downloadId,r.h],t[r.h]=i}for(let e of n){let r=t[e.p];if(r){let i=t[e.h];r.children.push(i),i.parent=r}}if(this.loadMetadata(s,o),this.key&&!this.attributes)return r(Error("Attributes could not be decrypted with provided key."));if(this.loadedFile){let e=t[this.loadedFile];void 0===e?r(Error("Node (file or folder) not found in folder")):r(null,e)}else r(null,this)}else{if(this.size=i.s,this.decryptAttributes(i.at),this.key&&!this.attributes)return r(Error("Attributes could not be decrypted with provided key."));r(null,this)}}),i}download(t,r){"function"==typeof t&&(r=t,t={}),t||(t={});let o=t.start||0,s=t.returnCiphertext?o:o-o%16,a=t.end||null,l=t.maxConnections||4,d=t.initialChunkSize||131072,c=t.chunkSizeIncrement||131072,b=t.maxChunkSize||1048576,m={a:"g",g:1,ssl:2*!!U.handleForceHttps(t.forceHttps)};if(this.nodeId?m.n=this.nodeId:Array.isArray(this.downloadId)?(m._querystring={n:this.downloadId[0]},m.n=this.downloadId[1]):m.p=this.downloadId,this.directory)throw Error("Can't download: folder download isn't supported");if(!this.key&&!t.returnCiphertext)throw Error("Can't download: key isn't defined");let _=this.key&&!t.returnCiphertext?function(e,t={}){let r=t.start||0;if(0!==r&&(t.disableVerification=!0),r%16!=0)throw Error("start argument of megaDecrypt must be a multiple of 16");(e=g(e))instanceof Buffer||(e=Buffer.from(e));let o=w(e),s=new p(o,e.slice(16),r),a=!t.disableVerification&&new y(o,e.slice(16)),l=new i.Transform({transform(e,t,r){let i=s.decrypt(e);a&&a.update(i),r(null,Buffer.from(i))},flush(r){if(a&&(l.mac=a.condense()),!t.disableVerification&&!l.mac.equals(e.slice(24)))return void r(Error("MAC verification failed"));r()}});return l=n(f(16),l)}(this.key,{start:s,disableVerification:0!==s||null!==a}):new i.PassThrough,v=s===o?_:_.pipe(new h({skip:o-s})),E=t.handleRetries||e.defaultHandleRetries;return this.api.request(m,(e,t)=>{if(e)return v.emit("error",e);if("string"!=typeof t.g||"http"!==t.g.substr(0,4))return v.emit("error",Error("MEGA servers returned an invalid response, maybe caused by rate limit"));if(0===t.s)return v.end();if(a||(a=t.s-1),o>a)return v.emit("error",Error("You can't download past the end of the file."));function r(e){if(200!==e.status){if(509===e.status){let t=e.headers.get("x-mega-time-left"),r=Error("Bandwidth limit reached: "+t+" seconds until it resets");r.timeLimit=t,v.emit("error",r);return}v.emit("error",Error("MEGA returned a "+e.status+" status code"))}}function i(e){v.emit("error",e)}let n=0;if(v.on("data",e=>{n+=e.length,v.emit("progress",{bytesLoaded:n,bytesTotal:t.s})}),1===l){let e=new AbortController;v.on("close",()=>{e.abort()}),this.api.fetch(t.g+"/"+s+"-"+a,{signal:e.signal}).then(e=>{r(e);let t=e.body;if(t)if(t.pipe)e.body.pipe(_);else if(t.getReader){let e=t.getReader(),r=({done:t,value:i})=>{if(!t)return _.write(i),e.read().then(r);_.end()};e.read().then(r)}else throw Error("Single connection streaming not supported by fetch");else throw Error("Missing response body")}).catch(i);return}let h={},u=0,f=0,p=!1,y=s,g=d;v.on("error",()=>{p=!0}),v.on("close",()=>{p=!0});let m=()=>{if(y>a){p=!0,u===f&&_.end();return}let e=y,n=Math.min(a,e+g-1),o=u++,s=0,l=()=>{s++,this.api.fetch(t.g+"/"+e+"-"+n).then(e=>(r(e),e.arrayBuffer())).then(e=>{let t=Buffer.from(e);h[o]=t,f===o&&w()},e=>{E(s,e,e=>{e?i(e):l()})})};l(),y=n+1,g<b&&(g+=c)},w=()=>{let e;for(;;){let t=h[f];if(!t||(e=!_.write(t),delete h[f],f++,e))break}p&&u===f&&_.end(),e?_.once("drain",w):m()};for(let e=0;e<l;e++)m()}),r&&u(v,r),v}downloadBuffer(e,t){let[r,i]=d(t);return this.download(e,r),i}link(e,t){1==arguments.length&&"function"==typeof e&&(t=e,e={noKey:!1});let[r,i]=d(t);"boolean"==typeof e&&(e={noKey:e});let n=`https://mega.nz/${this.directory?"folder":"file"}/${this.downloadId}`;return!e.noKey&&this.key&&(n+=`#${b(this.key)}`),!e.noKey&&this.loade