@omer-x/buttler 1.3.15 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/bin/cli.js +4 -4
  2. package/package.json +32 -34
  3. package/ui/.next/BUILD_ID +1 -1
  4. package/ui/.next/app-build-manifest.json +72 -72
  5. package/ui/.next/app-path-routes-manifest.json +1 -1
  6. package/ui/.next/build-manifest.json +9 -9
  7. package/ui/.next/prerender-manifest.json +3 -3
  8. package/ui/.next/required-server-files.json +10 -9
  9. package/ui/.next/server/app/_not-found/page.js +1 -1
  10. package/ui/.next/server/app/_not-found/page.js.nft.json +1 -1
  11. package/ui/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/ui/.next/server/app/_not-found.html +1 -1
  13. package/ui/.next/server/app/_not-found.meta +1 -1
  14. package/ui/.next/server/app/_not-found.rsc +19 -14
  15. package/ui/.next/server/app/api/db/backup/route.js +1 -1
  16. package/ui/.next/server/app/api/db/backup/route.js.nft.json +1 -1
  17. package/ui/.next/server/app/api/db/backup/route_client-reference-manifest.js +1 -1
  18. package/ui/.next/server/app/api/logs/route.js +1 -1
  19. package/ui/.next/server/app/api/logs/route.js.nft.json +1 -1
  20. package/ui/.next/server/app/api/logs/route_client-reference-manifest.js +1 -1
  21. package/ui/.next/server/app/index.html +1 -1
  22. package/ui/.next/server/app/index.meta +1 -1
  23. package/ui/.next/server/app/index.rsc +19 -14
  24. package/ui/.next/server/app/page.js +1 -1
  25. package/ui/.next/server/app/page.js.nft.json +1 -1
  26. package/ui/.next/server/app/page_client-reference-manifest.js +1 -1
  27. package/ui/.next/server/app/services/[id]/databases/page.js +1 -1
  28. package/ui/.next/server/app/services/[id]/databases/page.js.nft.json +1 -1
  29. package/ui/.next/server/app/services/[id]/databases/page_client-reference-manifest.js +1 -1
  30. package/ui/.next/server/app/services/[id]/edit/page.js +1 -1
  31. package/ui/.next/server/app/services/[id]/edit/page.js.nft.json +1 -1
  32. package/ui/.next/server/app/services/[id]/edit/page_client-reference-manifest.js +1 -1
  33. package/ui/.next/server/app/services/[id]/networks/page.js +1 -1
  34. package/ui/.next/server/app/services/[id]/networks/page.js.nft.json +1 -1
  35. package/ui/.next/server/app/services/[id]/networks/page_client-reference-manifest.js +1 -1
  36. package/ui/.next/server/app/services/[id]/page.js +1 -1
  37. package/ui/.next/server/app/services/[id]/page.js.nft.json +1 -1
  38. package/ui/.next/server/app/services/[id]/page_client-reference-manifest.js +1 -1
  39. package/ui/.next/server/app/services/page.js +1 -1
  40. package/ui/.next/server/app/services/page.js.nft.json +1 -1
  41. package/ui/.next/server/app/services/page_client-reference-manifest.js +1 -1
  42. package/ui/.next/server/app/settings/page.js +1 -1
  43. package/ui/.next/server/app/settings/page.js.nft.json +1 -1
  44. package/ui/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  45. package/ui/.next/server/app/settings.html +1 -1
  46. package/ui/.next/server/app/settings.meta +1 -1
  47. package/ui/.next/server/app/settings.rsc +28 -23
  48. package/ui/.next/server/app/webhook/route.js +1 -1
  49. package/ui/.next/server/app/webhook/route.js.nft.json +1 -1
  50. package/ui/.next/server/app/webhook/route_client-reference-manifest.js +1 -1
  51. package/ui/.next/server/app-paths-manifest.json +1 -1
  52. package/ui/.next/server/chunks/15.js +1 -0
  53. package/ui/.next/server/chunks/230.js +1 -1
  54. package/ui/.next/server/chunks/256.js +1 -1
  55. package/ui/.next/server/chunks/277.js +1 -1
  56. package/ui/.next/server/chunks/298.js +1 -1
  57. package/ui/.next/server/chunks/312.js +13 -0
  58. package/ui/.next/server/chunks/54.js +1 -1
  59. package/ui/.next/server/chunks/548.js +3 -3
  60. package/ui/.next/server/chunks/629.js +1 -1
  61. package/ui/.next/server/chunks/664.js +4 -4
  62. package/ui/.next/server/chunks/704.js +1 -1
  63. package/ui/.next/server/chunks/719.js +10 -3
  64. package/ui/.next/server/chunks/744.js +1 -1
  65. package/ui/.next/server/chunks/754.js +3 -3
  66. package/ui/.next/server/middleware-build-manifest.js +1 -1
  67. package/ui/.next/server/pages/404.html +1 -1
  68. package/ui/.next/server/pages/500.html +1 -1
  69. package/ui/.next/server/pages/_error.js +1 -1
  70. package/ui/.next/server/server-reference-manifest.js +1 -1
  71. package/ui/.next/server/server-reference-manifest.json +1 -1
  72. package/ui/.next/static/chunks/101-f8060fad2a86c89b.js +1 -0
  73. package/ui/.next/static/chunks/188-fbd648b10be73507.js +1 -0
  74. package/ui/.next/static/chunks/198-1027f3b62c561202.js +1 -1
  75. package/ui/.next/static/chunks/273-e344e36fb8554c48.js +1 -0
  76. package/ui/.next/static/chunks/31-3e15c585dc25c05a.js +1 -0
  77. package/ui/.next/static/chunks/381-c5d8207a0006622e.js +1 -0
  78. package/ui/.next/static/chunks/4bd1b696-f26b251b6bbb8917.js +1 -0
  79. package/ui/.next/static/chunks/547-b14e6bfc25a27f08.js +1 -0
  80. package/ui/.next/static/chunks/684-37e9ad3bebe7dd4c.js +1 -0
  81. package/ui/.next/static/chunks/app/layout-9358e1d1f80d47da.js +1 -0
  82. package/ui/.next/static/chunks/app/services/[id]/databases/page-2d47fa6f7e3b072f.js +1 -0
  83. package/ui/.next/static/chunks/app/services/[id]/edit/page-14ef4a07ef0b420a.js +1 -0
  84. package/ui/.next/static/chunks/app/services/[id]/networks/page-26483518bd55b083.js +1 -0
  85. package/ui/.next/static/chunks/app/services/[id]/{page-1f692e8237d83cbc.js → page-9e92684b9072449e.js} +1 -1
  86. package/ui/.next/static/chunks/app/services/page-ee27acd5d4c38a6b.js +1 -0
  87. package/ui/.next/static/chunks/app/settings/page-e7d6be120bd70470.js +1 -0
  88. package/ui/.next/static/chunks/framework-52167c1502110d79.js +1 -0
  89. package/ui/.next/static/chunks/main-2b7fe41c42f3f521.js +1 -0
  90. package/ui/.next/static/chunks/main-app-eddb5e8f0a78bf63.js +1 -0
  91. package/ui/.next/static/chunks/webpack-500a50586ea029a7.js +1 -1
  92. package/ui/.next/static/css/3b7050fdbfea86d9.css +1 -0
  93. package/ui/package.json +32 -34
  94. package/ui/server.js +1 -1
  95. package/ui/.next/server/chunks/337.js +0 -1
  96. package/ui/.next/server/chunks/474.js +0 -13
  97. package/ui/.next/static/chunks/101-11d7a90211cf06c8.js +0 -1
  98. package/ui/.next/static/chunks/188-26d3c20f6f1391c8.js +0 -1
  99. package/ui/.next/static/chunks/273-59722515f618a8e4.js +0 -1
  100. package/ui/.next/static/chunks/31-153d921d0cba4f93.js +0 -1
  101. package/ui/.next/static/chunks/381-7c30e2fdbeea1fb9.js +0 -1
  102. package/ui/.next/static/chunks/4bd1b696-3ae59b01373b2d67.js +0 -1
  103. package/ui/.next/static/chunks/547-1eeed2fd9562d566.js +0 -1
  104. package/ui/.next/static/chunks/684-3c377b20c09294d6.js +0 -1
  105. package/ui/.next/static/chunks/app/layout-76400243bd387a23.js +0 -1
  106. package/ui/.next/static/chunks/app/services/[id]/databases/page-d94f4e1fb9d3e3d4.js +0 -1
  107. package/ui/.next/static/chunks/app/services/[id]/edit/page-99013ca1269c89a2.js +0 -1
  108. package/ui/.next/static/chunks/app/services/[id]/networks/page-ce78eda0d5e1201a.js +0 -1
  109. package/ui/.next/static/chunks/app/services/page-185cbf2f323554c5.js +0 -1
  110. package/ui/.next/static/chunks/app/settings/page-c4a867bc1ec0c46f.js +0 -1
  111. package/ui/.next/static/chunks/framework-66dcb5289ae9d888.js +0 -1
  112. package/ui/.next/static/chunks/main-6aa06e33ef96de85.js +0 -1
  113. package/ui/.next/static/chunks/main-app-b2de39e5cafbfc23.js +0 -1
  114. package/ui/.next/static/css/342be0ac832f6156.css +0 -1
  115. /package/ui/.next/static/{O87a1onvOAbV-_EDU_1bz → umf8fzleKBuB_bkoXqQnP}/_buildManifest.js +0 -0
  116. /package/ui/.next/static/{O87a1onvOAbV-_EDU_1bz → umf8fzleKBuB_bkoXqQnP}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- 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):M(e,l)):A(e,l,t,!1)}}else i||(l.reading=!1,M(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)),M(e,t)}function T(e,t){if(e<=0||0===t.length&&t.ended)return 0;if(t.objectMode)return 1;if(e!=e)return t.flowing&&t.length?t.buffer.head.data.length:t.length;if(e>t.highWaterMark){var r;(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}return 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 M(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(I,e,t))}function I(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(){(function(e,t,r){var i=e.entry;for(e.entry=null;i;){var n=i.callback;t.pendingcb--,n(void 0),i=i.next}t.corkedRequestsFree.next=e})(t,e)}}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(M,e,r),e._writableState.errorEmitted=!0,v(e,t)):(n(t),e._writableState.errorEmitted=!0,v(e,t),M(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)}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(),M(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"),M(e,t)})}function M(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}r(59610)(k,a),S.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){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"==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,M(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){this.end();return}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:()=>V});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;let 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;let 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;let 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}var v={},E=Math.log(2);function S(e){let t=[];for(;e-- >0;)t[e]=0;return t}function k(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 R(e,t){let r;let 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?[]:k(o)}function A(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 T(e,t){let r,i,n;let o=e.length,s=t.length,a=S(o+s-1);for(i=0;i<s;i++){for(n=0,r=0;n<o;n++)r=A(a,i+n,e[n],t[i],r);a[i+o]=r}return k(a)}function x(e,t,r){let i=0;for(;t>=0&&r-- >0;)i=0x10000000*i+e[t--];return i}function C(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 v.q=[0],v.mod=e,v;if(l===h&&x(e,h,2)/x(t,h,2)<4){for(r=e.concat(),i=0;0!==(n=R(r,t)).length;)r=n,i++;return v.q=[i],v.mod=r,v}let f=Math.floor(Math.log(t[h])/E)+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=S(u+1),y=S(u).concat(c);for(;0!==(s=R(r,y)).length;)p[u]++,r=s;let g=c[h],b=x(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(x(r,o,2)/g);let e=x(r,o,3);for(;p[a]*b>e;)p[a]--;y=y.slice(1),0===(s=R(r,T([p[a]],y))).length&&(p[a]--,s=R(r,T([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 v.q=k(p),v.mod=k(r),v}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 C(e,t).mod}function I(e,t,r){let i;let n=e.length-(t.length<<1);if(n>0)return I(e.slice(0,n).concat(I(e.slice(n),t,r)),t,r);let o=t.length+1,s=t.length-1,a=T(e.slice(s),r).slice(o),l=e.slice(0,o),h=T(a,t).slice(0,o),u=R(l,h);0===u.length&&(l[o]=1,u=R(l,h));for(let e=0;0!==(i=R(u,t)).length;e++)if(u=i,e>=3)return I(u,t,r);return u}function O(e,t,r){var i;let n,o,s=e.concat(),a=t.length-1,l=2*r.length,h=S(l+1);for(h[l]=1,h=C(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=I(function(e){let t,r;let i=e.length,n=S(2*i),o=0;for(t=0;t<i;t++){for(o=A(n,2*t,e[t],e[t],0),r=t+1;r<i;r++)o=A(n,t+r,2*e[r],e[t],o);n[t+i]=o}return k(n)}(s),r,h),t[a]&1<<l&&(s=I(T(s,e),r,h));l=27}return s}function B(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 P(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=O(M(e,r),M(t,R(r,[1])),r),s=O(M(e,i),M(t,R(i,[1])),i),a=R(s,o);return 0===a.length?(a=M(T(a=R(o,s),n),i),a=R(i,a)):a=M(T(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}(T(a,r),o)}(B(e.toString("binary")),t[2],t[0],t[1],t[3]));return Buffer.from(r,"binary")}var L={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)"},j=new a.Agent({keepAlive:!0}),N=new l.Agent({keepAlive:!0}),D=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.5`.trim(),this.httpAgent=r.httpAgent||j,this.httpsAgent=r.httpsAgent||N,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),s={id:(this.counterId++).toString()};return this.sid&&(s.sid=this.sid),"object"==typeof e._querystring&&(Object.assign(s,e._querystring),delete e._querystring),this.fetch(`${this.gateway}cs?${new URLSearchParams(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([e])}).then(U).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(L[-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(U).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(L[-e]))}e.w?this.wait(e.w,t):e.sn&&(e.a&&this.emit("sc",e.a),this.pull(e.sn))}}).catch(q).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 U(e){if("Server Too Busy"===e.statusText)return -3;if(!e.ok)throw Error(`Server returned error: ${e.statusText}`);return e.json()}function q(e){if("AbortError"!==e.name)throw e}var F=["","red","orange","yellow","green","blue","purple","grey"],W=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||D.getGlobalApi(),!(this.api instanceof D))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=F[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*!!D.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))){r(Error("MAC verification failed"));return}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.loadedFile&&(n+=`/file/${this.loadedFile}`),r(null,n),i}find(e,t){if(!this.children)throw Error("You can only call .find on directories");if("string"==typeof e){let t=e;e=e=>e.name===t}else if(Array.isArray(e)){let t=e;e=e=>t.includes(e.name)}if("function"!=typeof e)throw Error("Query must be a file matching function, an array of valid file names or a string with a file name");return this.children.reduce((r,i)=>r||(e(i)?i:i.children&&t?i.find(e,t):null),null)}filter(e,t){if(!this.children)throw Error("You can only call .filter on directories");if("string"==typeof e){let t=e;e=e=>e.name===t}else if(Array.isArray(e)){let t=e;e=e=>t.includes(e.name)}if("function"!=typeof e)throw Error("Query must be a file matching function, an array of valid file names or a string with a file name");return this.children.reduce((r,i)=>(e(i)&&r.push(i),i.children&&t)?r.concat(i.filter(e,t)):r,[])}navigate(e){if(!this.children)throw Error("You can only call .navigate on directories");if("string"==typeof e)e=e.split("/");else if(!Array.isArray(e))throw Error("Query must be an array or a string");return e.reduce((e,t)=>e&&e.children&&e.children.find(e=>e.name===t),this)}static fromURL(t,r={}){if("object"==typeof t)return new e(t);let i=new URL(t);if("mega.nz"!==i.hostname&&"mega.co.nz"!==i.hostname)throw Error("Invalid URL: wrong hostname");if(!i.hash)throw Error("Invalid URL: no hash");if(null!==i.pathname.match(/\/(file|folder)\//)){let t=i.hash.substr(1).split("/file/"),n=i.pathname.substring(i.pathname.lastIndexOf("/")+1,i.pathname.length+1),o=t[0];if(n&&!o||!n&&o)throw Error("Invalid URL: too few arguments");return new e({downloadId:n,key:o,directory:i.pathname.indexOf("/folder/")>=0,loadedFile:t[1],...r})}{let t=i.hash.split("!");if("#"!==t[0]&&"#F"!==t[0])throw Error("Invalid URL: format not recognized");if(t.length<=1)throw Error("Invalid URL: too few arguments");if(t.length>=("#"===t[0]?4:5))throw Error("Invalid URL: too many arguments");return new e({downloadId:t[1],key:t[2],directory:"#F"===t[0],loadedFile:t[3],...r})}}static unpackAttributes(e){let t=0;for(;t<e.length&&e.readUInt8(t);)t++;if('MEGA{"'===(e=e.slice(0,t).toString()).substr(0,6))try{return JSON.parse(e.substr(4))}catch(e){}}static defaultHandleRetries(e,t,r){e>8?r(t):setTimeout(r,1e3*Math.pow(2,e))}},H={},K=class e extends W{constructor(e,t){if(super(e),this.storage=t,this.api=t.api,this.nodeId=e.h,this.timestamp=e.ts,this.type=e.t,this.directory=!!this.type,this.directory&&!this.children&&(this.children=[]),e.k){let r=e.k.split("/"),i=t.aes;for(let n of r){let r=n.split(":")[0];if(r===t.user){e.k=n;break}let o=t.shareKeys[r];if(o){e.k=n,(i=H[r])||(i=H[r]=new c(o));break}}this.loadMetadata(i,e)}}loadAttributes(){throw Error("This is not needed for files loaded from logged in sessions")}mkdir(t,r){if(!this.directory)throw Error("node isn't a directory");let[i,n]=d(r);if("string"==typeof t&&(t={name:t}),t.attributes||(t.attributes={}),t.name&&(t.attributes.n=t.name),!t.attributes.n)throw Error("file name is required");if(t.target||(t.target=this),t.key||(t.key=Buffer.from(globalThis.crypto.getRandomValues(new Uint8Array(16)))),16!==t.key.length)throw Error("wrong key length, must be 128bit");let o=t.key,s=e.packAttributes(t.attributes);w(o).encryptCBC(s);let a=Buffer.from(o);this.storage.aes.encryptECB(a);let l={a:"p",t:t.target.nodeId?t.target.nodeId:t.target,n:[{h:"xxxxxxxx",t:1,a:b(s),k:b(a)}]},h=z(this.storage.shareKeys,this);return h.length>0&&(l.cr=$(this.storage,[{nodeId:"xxxxxxxx",key:o}],h)),this.api.request(l,(e,t)=>{if(e)return i(e);let r=this.storage._importFile(t.f[0]);this.storage.emit("add",r),i(null,r)}),n}upload(t,r,i){let n;if(!this.directory)throw Error("node is not a directory");2==arguments.length&&"function"==typeof r&&([i,r]=[r,null]);let[o,s]=d(i);if("string"==typeof t&&(t={name:t}),t.attributes||(t.attributes={}),t.name&&(t.attributes.n=t.name),!t.attributes.n)throw Error("File name is required.");if(!("number"==typeof t.size&&t.size>=0)&&!(r&&"function"!=typeof r.pipe&&"number"==typeof r.length)&&!t.allowUploadBuffering)throw Error("Specify a file size or set allowUploadBuffering to true");t.target||(t.target=this);let a=g(t.key);a||(a=globalThis.crypto.getRandomValues(new Uint8Array(24))),a instanceof Buffer||(a=Buffer.from(a));let l=t.uploadCiphertext?32:24;if(a.length!==l)throw Error("Wrong key length. Key must be 192bit");t.uploadCiphertext&&(n=a,a=_(a).slice(0,24)),t.key=a;let h=[],u=(r,i,s,a)=>{if(r)return c(r);if(!s||0===s.length){c(Error("Server returned a invalid response while uploading"));return}let l=Number(s.toString());if(l<0){c(Error("Server returned error "+l+" while uploading"));return}if(h[i]=s,0!==i||n||(n=a.key),t.thumbnailImage&&!h[1]||t.previewImage&&!h[2]||!h[0])return;let u=e.packAttributes(t.attributes);w(n).encryptCBC(u);let d=Buffer.from(n);this.storage.aes.encryptECB(d);let p={h:b(h[0]),t:0,a:b(u),k:b(d)};1!==h.length&&(p.fa=h.slice(1).map((e,t)=>t+"*"+b(e)).filter(e=>e).join("/"));let y={a:"p",t:t.target.nodeId?t.target.nodeId:t.target,n:[p]},g=z(this.storage.shareKeys,this);g.length>0&&(y.cr=$(this.storage,[{nodeId:p.h,key:n}],g)),this.api.request(y,(e,t)=>{if(e)return c(e);let r=this.storage._importFile(t.f[0]);this.storage.emit("add",r),f.emit("complete",r),o&&o(null,r)})};t.thumbnailImage&&this._uploadAttribute(t,t.thumbnailImage,1,u),t.previewImage&&this._uploadAttribute(t,t.previewImage,2,u);let f=this._upload(t,r,0,u);function c(e){f.listenerCount("error")?f.emit("error",e):o(e)}return f.complete=s,f}_upload(e,t,r,o){let s=e.uploadCiphertext?new i.PassThrough:function(e,t={}){let r=t.start||0;if(0!==r)throw Error("Encryption cannot start midstream otherwise MAC verification will fail.");(e=g(e))||(e=globalThis.crypto.getRandomValues(new Uint8Array(24))),e instanceof Buffer||(e=Buffer.from(e));let o=new i.Transform({transform(e,t,r){l.update(e);let i=a.encrypt(e);r(null,Buffer.from(i))},flush(t){o.mac=l.condense(),o.key=function(e,t){let r=Buffer.alloc(32);e.copy(r),t.copy(r,24);for(let e=0;e<16;e++)r.writeUInt8(r.readUInt8(e)^r.readUInt8(16+e),e);return r}(e,o.mac),t()}});if(24!==e.length)throw Error("Wrong key length. Key must be 192bit.");let s=new c(e.slice(0,16)),a=new p(s,e.slice(16),r),l=new y(s,e.slice(16));return o=n(f(16),o)}(e.key),a=s,l=e.size;return t&&"function"!=typeof t.pipe&&(l=t.length,a.end(t)),null!=l?(0===l&&s.end(),this._uploadWithSize(a,l,s,r,e,o)):a=function(e,t){let r=[],n=0;return new i.Transform({transform(e,t,i){r.push(e),n+=e.length,i()},flush(i){t(n),!function t(){for(;r.length;)if(!e.write(r.shift()))return e.once("drain",t);e.end(),i()}()}})}(a,t=>{this._uploadWithSize(a,t,s,r,e,o)}),t&&"function"==typeof t.pipe&&t.pipe(a),a}_uploadAttribute(e,t,r,n){let o=(t,o)=>{if(t)return n(t);let s=o.length,a=16*Math.ceil(s/16)-s;0!==a&&(o=Buffer.concat([o,Buffer.alloc(a)])),(e.handle?w(e.key):new c(e.key.slice(0,16))).encryptCBC(o);let l=new i.PassThrough;l.end(o),this._uploadWithSize(l,o.length,l,r,e,n)};if(t instanceof Buffer){o(null,t);return}u(t,o)}_uploadWithSize(e,t,r,i,n,o){let s,a,l,h,u;let f=2*!!D.handleForceHttps(n.forceHttps),d=0===i?{a:"u",ssl:f,s:t,ms:0,r:0,e:0,v:2}:{a:"ufa",ssl:f,s:t};n.handle&&(d.h=n.handle);let c=0===i?n.initialChunkSize||131072:t,p=n.chunkSizeIncrement||131072,y=n.maxChunkSize||1048576,g=n.maxConnections||4,b=n.handleRetries||W.defaultHandleRetries,m=c,w=0,_=!1,v=0,E=0,S=()=>{h=Math.min(m,t-v),a=Buffer.alloc(h),w++,m<y&&(m+=p),u=0,s&&(s.copy(a),u=Math.min(s.length,h),s=s.length>h?s.slice(h):null),u===h?k():(_=!0,A())},k=()=>{let n=v,s=a,u=0,f=()=>{u++,this.api.fetch(l+"/"+(0===i?n:i-1),{method:"POST",body:s,headers:{"content-length":s.length}}).then(e=>{if(200!==e.status)throw Error("MEGA returned a "+e.status+" status code");return e.arrayBuffer()}).then(n=>{E+=s.length,e.emit("progress",{bytesLoaded:R,bytesUploaded:E,bytesTotal:t});let a=Buffer.from(n);a.length>0?(r.end(),process.nextTick(()=>{o(null,i,a,r)})):v<t&&!_&&S()},t=>{b(u,t,t=>{t?e.emit("error",t):f()})})};f(),a=null,(v+=h)<t&&!_&&w<g&&S()},R=0,A=()=>{for(;;){let e=r.read();if(null===e){r.once("readable",A);break}if(R+=e.length,e.copy(a,u),(u+=e.length)>=h){_=!1,s=e.slice(e.length-(u-h)),k();break}}};r.on("end",()=>{t&&R!==t&&e.emit("error",Error("Specified data size does not match: "+t+" !== "+R))}),this.api.request(d,(e,t)=>{if(e)return o(e);l=t.p,S()})}uploadAttribute(e,t,r){let[i,n]=d(r);if("string"==typeof e&&(e=["thumbnail","preview"].indexOf(e)),0!==e&&1!==e)throw Error("Invalid attribute type");return this._uploadAttribute({key:this.key,handle:this.nodeId},t,e+1,(t,r,n,o)=>{if(t)return i(t);let s={a:"pfa",n:this.nodeId,fa:e+"*"+b(n)};this.api.request(s,(e,t)=>{if(e)return i(e);i(null,this)})}),n}delete(e,t){return("function"==typeof e&&(t=e,e=void 0),void 0===e&&(e=this.parent===this.storage.trash),e)?this.api.request({a:"d",n:this.nodeId},t):this.moveTo(this.storage.trash,t)}moveTo(e,t){if("string"==typeof e&&(e=this.storage.files[e]),!(e instanceof W))throw Error("target must be a folder or a nodeId");let r={a:"m",n:this.nodeId,t:e.nodeId},i=z(this.storage.shareKeys,e);return i.length>0&&(r.cr=$(this.storage,[this],i)),this.api.request(r,t)}setAttributes(t,r){let[i,n]=d(r);Object.assign(this.attributes,t);let o=e.packAttributes(this.attributes);return w(this.key).encryptCBC(o),this.api.request({a:"a",n:this.nodeId,at:b(o)},e=>{this.parseAttributes(this.attributes),i(e)}),n}rename(e,t){return this.setAttributes({n:e},t)}setLabel(e,t){if("string"==typeof e&&(e=F.indexOf(e)),"number"!=typeof e||Math.floor(e)!==e||e<0||e>7)throw Error("label must be a integer between 0 and 7 or a valid label name");return this.setAttributes({lbl:e},t)}setFavorite(e,t){return this.setAttributes({fav:+!!e},t)}link(e,t){1==arguments.length&&"function"==typeof e&&(t=e,e={noKey:!1}),"boolean"==typeof e&&(e={noKey:e}),e||(e={});let r=e.__folderKey;if(this.directory&&!r)return this.shareFolder(e,t);let[i,n]=d(t);return this.api.request({a:"l",n:this.nodeId},(t,n)=>{if(t)return i(t);let o=`https://mega.nz/${r?"folder":"file"}/${n}`;!e.noKey&&this.key&&(o+=`#${b(r||this.key)}`),i(null,o)}),n}shareFolder(e,t){if(!this.directory)throw Error("node isn't a folder");let r=this.nodeId,i=this.storage.shareKeys[r];if(i)return this.link(Object.assign({__folderKey:i},e),t);let n=g(e.key);n||(n=globalThis.crypto.getRandomValues(new Uint8Array(16))),n instanceof Buffer||(n=Buffer.from(n));let[o,s]=d(t);if(16!==n.length)return o(Error("share key must be 16 byte / 22 characters")),s;this.storage.shareKeys[r]=n;let a=Buffer.from(r+r);this.storage.aes.encryptECB(a);let l={a:"s2",n:r,s:[{u:"EXP",r:0}],ok:b(this.storage.aes.encryptECB(Buffer.from(n))),ha:b(a),cr:$(this.storage,this)};return this.api.request(l,t=>{if(t)return o(t);this.link(Object.assign({__folderKey:n},e),o)}),s}unshare(e){return this.directory?this.unshareFolder(e):this.api.request({a:"l",n:this.nodeId,d:1},e)}unshareFolder(e){if(!this.directory)throw Error("node isn't a folder");return delete this.storage.shareKeys[this.nodeId],this.api.request({a:"s2",n:this.nodeId,s:[{u:"EXP",r:""}]},e)}importFile(t,r){let[i,n]=d(r);if(!this.directory)throw Error("importFile can only be called on directories");if("string"==typeof t&&(t=W.fromURL(t)),!(t instanceof W))throw Error("First argument of importFile should be a File or a URL string");if(!t.key)return i(Error("Can't import files without encryption keys")),n;let o=(t,r)=>{if(t)return i(t);let n=e.packAttributes(r.attributes);w(r.key).encryptCBC(n);let o=Array.isArray(r.downloadId)?r.downloadId[1]:r.downloadId,s={a:"p",t:this.nodeId,n:[{ph:o,t:0,a:b(n),k:b(this.storage.aes.encryptECB(r.key))}]};this.api.request(s,(e,t)=>{if(e)return i(e);let r=this.storage._importFile(t.f[0]);this.storage.emit("add",r),i(null,r)})};return t.attributes?o(null,t):t.loadAttributes(o),n}static packAttributes(e){let t=JSON.stringify(e);t=Buffer.from(`MEGA${t}`);let r=Buffer.alloc(16*Math.ceil(t.length/16));return t.copy(r),r}};function $(e,t,r){let i=e.shareKeys;Array.isArray(t)||(t=function e(t){return[t].concat((t.children||[]).map(e).reduce((e,t)=>e.concat(t),[]))}(t)),r||(r=t.map(e=>z(i,e)).reduce((e,t)=>e.concat(t)).filter((e,t,r)=>t===r.indexOf(e)));let n=[r,t.map(e=>e.nodeId),[]];for(let e=r.length;e--;){let o=new c(i[r[e]]);for(let r=t.length;r--;){let i=Buffer.from(t[r].key);i&&(32===i.length||16===i.length)&&n[2].push(e,r,b(o.encryptECB(i)))}}return n}function z(e,t){let r=t.nodeId,i=t.parent,n=[];return e[r]&&n.push(r),i?n.concat(z(e,i)):n}var V=class e extends s.EventEmitter{constructor(e,t){super(),1==arguments.length&&"function"==typeof e&&(t=e,e={});let[r,i]=d(t);this.ready=i,e.keepalive=void 0===e.keepalive||!!e.keepalive,e.autoload=void 0===e.autoload||!!e.autoload,e.autologin=void 0===e.autologin||!!e.autologin,this.api=new D(e.keepalive,e),this.files={},this.options=e,this.status="closed",e.autologin?this.login(r):process.nextTick(()=>{r(null,this)})}login(e){let[t,r]=d(e);if("string"!=typeof this.options.email)return process.nextTick(()=>{t(Error("starting a session without credentials isn't supported"))}),r;let i=()=>{this.status="ready",t(null,this),this.emit("ready",this)},n=e=>{this.api.request({a:"ug"},(t,r)=>{if(t)return e(t);this.name=r.name,this.user=r.u,this.options.autoload?this.reload(!0,t=>{if(t)return e(t);i()}):i()})};this.email=this.options.email.toLowerCase();let s=()=>{let e=new c(function(e){let t,r,i;let n=Buffer.from([147,196,103,227,125,176,199,164,209,190,63,129,1,82,203,86]);for(i=65536;i--;)for(r=0;r<e.length;r+=16){let i=Buffer.alloc(16);for(t=0;t<16;t+=4)t+r<e.length&&e.copy(i,t,t+r,t+r+4);n=o.createCipheriv("aes-128-ecb",i,Buffer.alloc(0)).setAutoPadding(!1).update(n)}return n}(Buffer.from(this.options.password))),t=b(e.stringhash(Buffer.from(this.email)));l({a:"us",user:this.email,uh:t},e)},a=e=>{!function(e,t,r){let i=Buffer.from(t.s,"base64");o.pbkdf2(e,i,1e5,32,"sha512",r)}(Buffer.from(this.options.password),e,(e,r)=>{if(e)return t(e);let i=new c(r.slice(0,16)),n=b(r.slice(16));l({a:"us",user:this.email,uh:n},i)})},l=(e,r)=>{delete this.options.password,this.options.secondFactorCode&&(e.mfa=this.options.secondFactorCode.toString()),this.api.request(e,(e,i)=>{if(e)return t(e);this.key=g(i.k),r.decryptECB(this.key),this.aes=new c(this.key);let o=g(i.csid),s=function(e){let t=[];for(let r=0;r<4;r++){let i=(256*e[0]+e[1]+7>>3)+2;if(t[r]=B(e.toString("binary").substr(0,i)),"number"==typeof t[r]){if(4!==r||e.length>=16)return!1;break}e=e.slice(i)}return t}(this.aes.decryptECB(g(i.privk)));if(!s)throw Error("invalid credentials");let a=b(P(o,s).slice(0,43));this.api.sid=this.sid=a,this.RSAPrivateKey=s,n(t)})};return this.api.request({a:"us0",user:this.email},(e,r)=>e?t(e):1===r.v?s():2===r.v?a(r):void t(Error("Account version not supported"))),this.status="connecting",r}reload(e,t){"function"==typeof e&&([e,t]=[t,e]);let[r,i]=d(t);return"connecting"!==this.status||e?(this.mounts=[],this.api.request({a:"f",c:1},(e,t)=>{if(e)return r(e);for(let e of(this.shareKeys=t.ok.reduce((e,t)=>{let r=t.h,i=this.aes.encryptECB(Buffer.from(r+r));return function(e,t){if(e.length!==t.length)return!1;let r=e.length,i=0;for(let n=0;n<r;n++)i|=e[n]^t[n];return 0===i}(g(t.ha),i)&&(e[r]=this.aes.decryptECB(g(t.k))),e},{}),t.f))if(e=this._importFile(e),void 0!==t.ph&&(e.shareId=t.ph.find(t=>t.h===e.nodeId)?.ph,e.shared=!!e.shareId,e.shared)){e.shareURL=`https://mega.nz/${e.directory?"folder":"file"}/${e.shareId}`;let t=e.directory?this.shareKeys[e.nodeId]:e.key;t&&(e.shareURL+="#"+b(t))}r(null,this.mounts)}),this.api.on("sc",e=>{let t={};e.forEach(e=>{if("u"===e.a){let t=this.files[e.n];t&&(t.timestamp=e.ts,t.decryptAttributes(e.at),t.emit("update"),this.emit("update",t))}else"d"===e.a?t[e.n]=!0:"t"===e.a&&e.t.f.forEach(e=>{let r=this.files[e.h];if(r){delete t[e.h];let i=r.parent;if(i.nodeId===e.p)return;i.children.splice(i.children.indexOf(r),1),r.parent=this.files[e.p],r.parent.children.push(r),r.emit("move",i),this.emit("move",r,i)}else this.emit("add",this._importFile(e))})}),Object.keys(t).forEach(e=>{let t=this.files[e],r=t.parent;r.children.splice(r.children.indexOf(t),1),this.emit("delete",t),t.emit("delete")})})):this.once("ready",()=>{this.reload(e,r)}),i}_importFile(e){if(!this.files[e.h]){let t=this.files[e.h]=new K(e,this);if(2===e.t&&(this.root=t,t.name="Cloud Drive"),4===e.t&&(this.trash=t,t.name="Rubbish Bin"),3===e.t&&(this.inbox=t,t.name="Inbox"),e.t>1&&this.mounts.push(t),e.p){let r=this.files[e.p];r&&(r.children.push(t),t.parent=r)}}return this.files[e.h]}mkdir(e,t){if("ready"!==this.status)throw Error("storage is not ready");return this.root.mkdir(e,t)}upload(e,t,r){if("ready"!==this.status)throw Error("storage is not ready");return this.root.upload(e,t,r)}find(e,t){if("ready"!==this.status)throw Error("storage is not ready");return this.root.find(e,t)}filter(e,t){if("ready"!==this.status)throw Error("storage is not ready");return this.root.filter(e,t)}navigate(e,t){if("ready"!==this.status)throw Error("storage is not ready");return this.root.navigate(e,t)}close(e){return this.status="closed",this.api.close(),this.api.request({a:"sml"},e)}getAccountInfo(e){let[t,r]=d(e);return this.api.request({a:"uq",strg:1,xfer:1,pro:1},(e,r)=>{e&&t(e);let i={};i.type=r.utype,i.spaceUsed=r.cstrg,i.spaceTotal=r.mstrg,i.downloadBandwidthTotal=r.mxfer||0x28000000000000,i.downloadBandwidthUsed=r.caxfer||0,i.sharedBandwidthUsed=r.csxfer||0,i.sharedBandwidthLimit=r.srvratio,t(null,i)}),r}toJSON(){return{key:b(this.key),sid:this.sid,name:this.name,user:this.user,options:this.options}}static fromJSON(t){let r=new e(Object.assign(t.options,{autoload:!1,autologin:!1}));return r.key=m(t.key),r.aes=new c(r.key),r.api.sid=r.sid=t.sid,r.name=t.name,r.user=t.user,r}decryptRsaKey(e){return P(e,this.RSAPrivateKey)}};W.fromURL},54735:(e,t,r)=>{var i=r(27910);"disable"===process.env.READABLE_STREAM&&i?(e.exports=i.Readable,Object.assign(e.exports,i),e.exports.Stream=i):((t=e.exports=r(7341)).Stream=i||t,t.Readable=t,t.Writable=r(20429),t.Duplex=r(28947),t.Transform=r(65225),t.PassThrough=r(47535),t.finished=r(97427),t.pipeline=r(67869))},59610:(e,t,r)=>{try{var i=r(28354);if("function"!=typeof i.inherits)throw"";e.exports=i.inherits}catch(t){e.exports=r(10365)}},65225:(e,t,r)=>{"use strict";e.exports=u;var i=r(83796).F,n=i.ERR_METHOD_NOT_IMPLEMENTED,o=i.ERR_MULTIPLE_CALLBACK,s=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,l=r(28947);function h(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);l.call(this,e),this._transformState={afterTransform:h.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",f)}function f(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?d(this,null,null):this._flush(function(t,r){d(e,t,r)})}function d(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}r(59610)(u,l),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,l.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,r){r(new n("_transform()"))},u.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},u.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},u.prototype._destroy=function(e,t){l.prototype._destroy.call(this,e,function(e){t(e)})}},67869:(e,t,r)=>{"use strict";var i,n=r(83796).F,o=n.ERR_MISSING_ARGS,s=n.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function l(e){e()}function h(e,t){return e.pipe(t)}e.exports=function(){for(var e,t,n=arguments.length,u=Array(n),f=0;f<n;f++)u[f]=arguments[f];var d=(e=u).length&&"function"==typeof e[e.length-1]?e.pop():a;if(Array.isArray(u[0])&&(u=u[0]),u.length<2)throw new o("streams");var c=u.map(function(e,n){var o,a,h,f,p,y=n<u.length-1;return a=o=function(e){t||(t=e),e&&c.forEach(l),y||(c.forEach(l),d(t))},h=!1,o=function(){h||(h=!0,a.apply(void 0,arguments))},f=!1,e.on("close",function(){f=!0}),void 0===i&&(i=r(97427)),i(e,{readable:y,writable:n>0},function(e){if(e)return o(e);f=!0,o()}),p=!1,function(t){if(!f&&!p){if(p=!0,e.setHeader&&"function"==typeof e.abort)return e.abort();if("function"==typeof e.destroy)return e.destroy();o(t||new s("pipe"))}}});return u.reduce(h)}},69656:(e,t,r)=>{"use strict";function i(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}function n(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach(function(t){var i,n,s;i=e,n=t,s=r[t],(n=o(n))in i?Object.defineProperty(i,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[n]=s}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(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)}var s=r(79428).Buffer,a=r(28354).inspect,l=a&&a.custom||"inspect";e.exports=function(){var e;function t(){(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,t),this.head=null,this.tail=null,this.length=0}return e=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t,r,i=s.allocUnsafe(e>>>0),n=this.head,o=0;n;)t=n.data,r=o,s.prototype.copy.call(t,i,r),o+=n.data.length,n=n.next;return i}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,i=t.data;for(e-=i.length;t=t.next;){var n=t.data,o=e>n.length?n.length:e;if(o===n.length?i+=n:i+=n.slice(0,e),0==(e-=o)){o===n.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(o));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,i=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var n=r.data,o=e>n.length?n.length:e;if(n.copy(t,t.length-e,0,o),0==(e-=o)){o===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(o));break}++i}return this.length-=i,t}},{key:l,value:function(e,t){return a(this,n(n({},t),{},{depth:0,customInspect:!1}))}}],function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}()},75161:e=>{"use strict";function t(e,t){i(e,t),r(e)}function r(e){(!e._writableState||e._writableState.emitClose)&&(!e._readableState||e._readableState.emitClose)&&e.emit("close")}function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,n){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?n?n(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(i,this,e)):process.nextTick(i,this,e)):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!n&&e?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(t,o,e)):process.nextTick(t,o,e):n?(process.nextTick(r,o),n(e)):process.nextTick(r,o)})),this},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}}},83796:e=>{"use strict";let t={};function r(e,r,i){i||(i=Error);class n extends i{constructor(e,t,i){super("string"==typeof r?r:r(e,t,i))}}n.prototype.name=i.name,n.prototype.code=e,t[e]=n}function i(e,t){if(!Array.isArray(e))return`of ${t} ${String(e)}`;{let r=e.length;return(e=e.map(e=>String(e)),r>2)?`one of ${t} ${e.slice(0,r-1).join(", ")}, or `+e[r-1]:2===r?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}}r("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(e,t,r){var n,o,s,a;let l,h;if("string"==typeof t&&(n="not ",t.substr(0,n.length)===n)?(l="must not be",t=t.replace(/^not /,"")):l="must be",o=" argument",(void 0===s||s>e.length)&&(s=e.length),e.substring(s-o.length,s)===o)h=`The ${e} ${l} ${i(t,"type")}`;else{let r=("number"!=typeof a&&(a=0),a+1>e.length||-1===e.indexOf(".",a))?"argument":"property";h=`The "${e}" ${r} ${l} ${i(t,"type")}`}return h+`. Received type ${typeof r}`},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.F=t},87464:(e,t,r)=>{e.exports=r(28354).deprecate},92815:(e,t,r)=>{e.exports=r(27910)},93724:(e,t,r)=>{"use strict";function i(e,t,r){var i;return(t="symbol"==typeof(i=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)}(t,"string"))?i:String(i))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var n,o=r(97427),s=Symbol("lastResolve"),a=Symbol("lastReject"),l=Symbol("error"),h=Symbol("ended"),u=Symbol("lastPromise"),f=Symbol("handlePromise"),d=Symbol("stream");function c(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var r=e[d].read();null!==r&&(e[u]=null,e[s]=null,e[a]=null,t(c(r,!1)))}}function y(e){process.nextTick(p,e)}var g=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((i(n={get stream(){return this[d]},next:function(){var e,t,r=this,i=this[l];if(null!==i)return Promise.reject(i);if(this[h])return Promise.resolve(c(void 0,!0));if(this[d].destroyed)return new Promise(function(e,t){process.nextTick(function(){r[l]?t(r[l]):e(c(void 0,!0))})});var n=this[u];if(n)t=new Promise((e=this,function(t,r){n.then(function(){if(e[h]){t(c(void 0,!0));return}e[f](t,r)},r)}));else{var o=this[d].read();if(null!==o)return Promise.resolve(c(o,!1));t=new Promise(this[f])}return this[u]=t,t}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var e=this;return new Promise(function(t,r){e[d].destroy(null,function(e){if(e){r(e);return}t(c(void 0,!0))})})}),n),g);e.exports=function(e){var t,r=Object.create(b,(i(t={},d,{value:e,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,l,{value:null,writable:!0}),i(t,h,{value:e._readableState.endEmitted,writable:!0}),i(t,f,{value:function(e,t){var i=r[d].read();i?(r[u]=null,r[s]=null,r[a]=null,e(c(i,!1))):(r[s]=e,r[a]=t)},writable:!0}),t));return r[u]=null,o(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[a];null!==t&&(r[u]=null,r[s]=null,r[a]=null,t(e)),r[l]=e;return}var i=r[s];null!==i&&(r[u]=null,r[s]=null,r[a]=null,i(c(void 0,!0))),r[h]=!0}),e.on("readable",y.bind(null,r)),r}},96848:(e,t,r)=>{var i=r(64686),n=r(59610),o=r(32248),s=function(e){return e.length?Array.isArray(e[0])?e[0]:Array.prototype.slice.call(e):[]},a=function(e){var t=function(){var r=s(arguments);if(!(this instanceof t))return new t(r);o.call(this,null,null,e),r.length&&this.setPipeline(r)};return n(t,o),t.prototype.setPipeline=function(){var e=s(arguments),t=this,r=!1,n=e[0],o=e[e.length-1];o=o.readable?o:null,n=n.writable?n:null;var a=function(){e[0].emit("error",Error("stream was destroyed"))};if(this.on("close",a),this.on("prefinish",function(){r||t.cork()}),i(e,function(e){if(t.removeListener("close",a),e)return t.destroy("premature close"===e.message?null:e);r=!0,!1===t._autoDestroy&&(t._autoDestroy=!0),t.uncork()}),this.destroyed)return a();this.setWritable(n),this.setReadable(o)},t};e.exports=a({autoDestroy:!1,destroy:!1}),e.exports.obj=a({autoDestroy:!1,destroy:!1,objectMode:!0,highWaterMark:16}),e.exports.ctor=a},97427:(e,t,r)=>{"use strict";var i=r(83796).F.ERR_STREAM_PREMATURE_CLOSE;function n(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),s=o||n,a=!1,o=function(){if(!a){a=!0;for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];s.apply(this,t)}};var s,a,l=r.readable||!1!==r.readable&&t.readable,h=r.writable||!1!==r.writable&&t.writable,u=function(){t.writable||d()},f=t._writableState&&t._writableState.finished,d=function(){h=!1,f=!0,l||o.call(t)},c=t._readableState&&t._readableState.endEmitted,p=function(){l=!1,c=!0,h||o.call(t)},y=function(e){o.call(t,e)},g=function(){var e;return l&&!c?(t._readableState&&t._readableState.ended||(e=new i),o.call(t,e)):h&&!f?(t._writableState&&t._writableState.ended||(e=new i),o.call(t,e)):void 0},b=function(){t.req.on("finish",d)};return t.setHeader&&"function"==typeof t.abort?(t.on("complete",d),t.on("abort",g),t.req?b():t.on("request",b)):h&&!t._writableState&&(t.on("end",u),t.on("close",u)),t.on("end",p),t.on("finish",d),!1!==r.error&&t.on("error",y),t.on("close",g),function(){t.removeListener("complete",d),t.removeListener("abort",g),t.removeListener("request",b),t.req&&t.req.removeListener("finish",d),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",d),t.removeListener("end",p),t.removeListener("error",y),t.removeListener("close",g)}}}};
1
+ 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.loadedFile&&(n+=`/file/${this.loadedFile}`),r(null,n),i}find(e,t){if(!this.children)throw Error("You can only call .find on directories");if("string"==typeof e){let t=e;e=e=>e.name===t}else if(Array.isArray(e)){let t=e;e=e=>t.includes(e.name)}if("function"!=typeof e)throw Error("Query must be a file matching function, an array of valid file names or a string with a file name");return this.children.reduce((r,i)=>r||(e(i)?i:i.children&&t?i.find(e,t):null),null)}filter(e,t){if(!this.children)throw Error("You can only call .filter on directories");if("string"==typeof e){let t=e;e=e=>e.name===t}else if(Array.isArray(e)){let t=e;e=e=>t.includes(e.name)}if("function"!=typeof e)throw Error("Query must be a file matching function, an array of valid file names or a string with a file name");return this.children.reduce((r,i)=>(e(i)&&r.push(i),i.children&&t)?r.concat(i.filter(e,t)):r,[])}navigate(e){if(!this.children)throw Error("You can only call .navigate on directories");if("string"==typeof e)e=e.split("/");else if(!Array.isArray(e))throw Error("Query must be an array or a string");return e.reduce((e,t)=>e&&e.children&&e.children.find(e=>e.name===t),this)}static fromURL(t,r={}){if("object"==typeof t)return new e(t);let i=new URL(t);if("mega.nz"!==i.hostname&&"mega.co.nz"!==i.hostname)throw Error("Invalid URL: wrong hostname");if(!i.hash)throw Error("Invalid URL: no hash");if(null!==i.pathname.match(/\/(file|folder)\//)){let t=i.hash.substr(1).split("/file/"),n=i.pathname.substring(i.pathname.lastIndexOf("/")+1,i.pathname.length+1),o=t[0];if(n&&!o||!n&&o)throw Error("Invalid URL: too few arguments");return new e({downloadId:n,key:o,directory:i.pathname.indexOf("/folder/")>=0,loadedFile:t[1],...r})}{let t=i.hash.split("!");if("#"!==t[0]&&"#F"!==t[0])throw Error("Invalid URL: format not recognized");if(t.length<=1)throw Error("Invalid URL: too few arguments");if(t.length>=("#"===t[0]?4:5))throw Error("Invalid URL: too many arguments");return new e({downloadId:t[1],key:t[2],directory:"#F"===t[0],loadedFile:t[3],...r})}}static unpackAttributes(e){let t=0;for(;t<e.length&&e.readUInt8(t);)t++;if('MEGA{"'===(e=e.slice(0,t).toString()).substr(0,6))try{return JSON.parse(e.substr(4))}catch(e){}}static defaultHandleRetries(e,t,r){e>8?r(t):setTimeout(r,1e3*Math.pow(2,e))}},$={},K=class e extends H{constructor(e,t){if(super(e),this.storage=t,this.api=t.api,this.nodeId=e.h,this.timestamp=e.ts,this.type=e.t,this.directory=!!this.type,this.directory&&!this.children&&(this.children=[]),e.k){let r=e.k.split("/"),i=t.aes;for(let n of r){let r=n.split(":")[0];if(r===t.user){e.k=n;break}let o=t.shareKeys[r];if(o){e.k=n,(i=$[r])||(i=$[r]=new c(o));break}}this.loadMetadata(i,e)}}loadAttributes(){throw Error("This is not needed for files loaded from logged in sessions")}mkdir(t,r){if(!this.directory)throw Error("node isn't a directory");let[i,n]=d(r);if("string"==typeof t&&(t={name:t}),t.attributes||(t.attributes={}),t.name&&(t.attributes.n=t.name),!t.attributes.n)throw Error("file name is required");if(t.target||(t.target=this),t.key||(t.key=Buffer.from(globalThis.crypto.getRandomValues(new Uint8Array(16)))),16!==t.key.length)throw Error("wrong key length, must be 128bit");let o=t.key,s=e.packAttributes(t.attributes);w(o).encryptCBC(s);let a=Buffer.from(o);this.storage.aes.encryptECB(a);let l={a:"p",t:t.target.nodeId?t.target.nodeId:t.target,n:[{h:"xxxxxxxx",t:1,a:b(s),k:b(a)}]},h=z(this.storage.shareKeys,this);return h.length>0&&(l.cr=V(this.storage,[{nodeId:"xxxxxxxx",key:o}],h)),this.api.request(l,(e,t)=>{if(e)return i(e);let r=this.storage._importFile(t.f[0]);this.storage.emit("add",r),i(null,r)}),n}upload(t,r,i){let n;if(!this.directory)throw Error("node is not a directory");2==arguments.length&&"function"==typeof r&&([i,r]=[r,null]);let[o,s]=d(i);if("string"==typeof t&&(t={name:t}),t.attributes||(t.attributes={}),t.name&&(t.attributes.n=t.name),!t.attributes.n)throw Error("File name is required.");if(!("number"==typeof t.size&&t.size>=0)&&!(r&&"function"!=typeof r.pipe&&"number"==typeof r.length)&&!t.allowUploadBuffering)throw Error("Specify a file size or set allowUploadBuffering to true");t.target||(t.target=this);let a=g(t.key);a||(a=globalThis.crypto.getRandomValues(new Uint8Array(24))),a instanceof Buffer||(a=Buffer.from(a));let l=t.uploadCiphertext?32:24;if(a.length!==l)throw Error("Wrong key length. Key must be 192bit");t.uploadCiphertext&&(n=a,a=_(a).slice(0,24)),t.key=a;let h=[],u=(r,i,s,a)=>{if(r)return c(r);if(!s||0===s.length)return void c(Error("Server returned a invalid response while uploading"));let l=Number(s.toString());if(l<0)return void c(Error("Server returned error "+l+" while uploading"));if(h[i]=s,0!==i||n||(n=a.key),t.thumbnailImage&&!h[1]||t.previewImage&&!h[2]||!h[0])return;let u=e.packAttributes(t.attributes);w(n).encryptCBC(u);let d=Buffer.from(n);this.storage.aes.encryptECB(d);let p={h:b(h[0]),t:0,a:b(u),k:b(d)};1!==h.length&&(p.fa=h.slice(1).map((e,t)=>t+"*"+b(e)).filter(e=>e).join("/"));let y={a:"p",t:t.target.nodeId?t.target.nodeId:t.target,n:[p]},g=z(this.storage.shareKeys,this);g.length>0&&(y.cr=V(this.storage,[{nodeId:p.h,key:n}],g)),this.api.request(y,(e,t)=>{if(e)return c(e);let r=this.storage._importFile(t.f[0]);this.storage.emit("add",r),f.emit("complete",r),o&&o(null,r)})};t.thumbnailImage&&this._uploadAttribute(t,t.thumbnailImage,1,u),t.previewImage&&this._uploadAttribute(t,t.previewImage,2,u);let f=this._upload(t,r,0,u);function c(e){f.listenerCount("error")?f.emit("error",e):o(e)}return f.complete=s,f}_upload(e,t,r,o){let s=e.uploadCiphertext?new i.PassThrough:function(e,t={}){let r=t.start||0;if(0!==r)throw Error("Encryption cannot start midstream otherwise MAC verification will fail.");(e=g(e))||(e=globalThis.crypto.getRandomValues(new Uint8Array(24))),e instanceof Buffer||(e=Buffer.from(e));let o=new i.Transform({transform(e,t,r){l.update(e);let i=a.encrypt(e);r(null,Buffer.from(i))},flush(t){o.mac=l.condense(),o.key=function(e,t){let r=Buffer.alloc(32);e.copy(r),t.copy(r,24);for(let e=0;e<16;e++)r.writeUInt8(r.readUInt8(e)^r.readUInt8(16+e),e);return r}(e,o.mac),t()}});if(24!==e.length)throw Error("Wrong key length. Key must be 192bit.");let s=new c(e.slice(0,16)),a=new p(s,e.slice(16),r),l=new y(s,e.slice(16));return o=n(f(16),o)}(e.key),a=s,l=e.size;return t&&"function"!=typeof t.pipe&&(l=t.length,a.end(t)),null!=l?(0===l&&s.end(),this._uploadWithSize(a,l,s,r,e,o)):a=function(e,t){let r=[],n=0;return new i.Transform({transform(e,t,i){r.push(e),n+=e.length,i()},flush(i){t(n),!function t(){for(;r.length;)if(!e.write(r.shift()))return e.once("drain",t);e.end(),i()}()}})}(a,t=>{this._uploadWithSize(a,t,s,r,e,o)}),t&&"function"==typeof t.pipe&&t.pipe(a),a}_uploadAttribute(e,t,r,n){let o=(t,o)=>{if(t)return n(t);let s=o.length,a=16*Math.ceil(s/16)-s;0!==a&&(o=Buffer.concat([o,Buffer.alloc(a)])),(e.handle?w(e.key):new c(e.key.slice(0,16))).encryptCBC(o);let l=new i.PassThrough;l.end(o),this._uploadWithSize(l,o.length,l,r,e,n)};if(t instanceof Buffer)return void o(null,t);u(t,o)}_uploadWithSize(e,t,r,i,n,o){let s,a,l,h,u,f=2*!!U.handleForceHttps(n.forceHttps),d=0===i?{a:"u",ssl:f,s:t,ms:0,r:0,e:0,v:2}:{a:"ufa",ssl:f,s:t};n.handle&&(d.h=n.handle);let c=0===i?n.initialChunkSize||131072:t,p=n.chunkSizeIncrement||131072,y=n.maxChunkSize||1048576,g=n.maxConnections||4,b=n.handleRetries||H.defaultHandleRetries,m=c,w=0,_=!1,v=0,E=0,S=()=>{h=Math.min(m,t-v),a=Buffer.alloc(h),w++,m<y&&(m+=p),u=0,s&&(s.copy(a),u=Math.min(s.length,h),s=s.length>h?s.slice(h):null),u===h?k():(_=!0,A())},k=()=>{let n=v,s=a,u=0,f=()=>{u++,this.api.fetch(l+"/"+(0===i?n:i-1),{method:"POST",body:s,headers:{"content-length":s.length}}).then(e=>{if(200!==e.status)throw Error("MEGA returned a "+e.status+" status code");return e.arrayBuffer()}).then(n=>{E+=s.length,e.emit("progress",{bytesLoaded:R,bytesUploaded:E,bytesTotal:t});let a=Buffer.from(n);a.length>0?(r.end(),process.nextTick(()=>{o(null,i,a,r)})):v<t&&!_&&S()},t=>{b(u,t,t=>{t?e.emit("error",t):f()})})};f(),a=null,(v+=h)<t&&!_&&w<g&&S()},R=0,A=()=>{for(;;){let e=r.read();if(null===e){r.once("readable",A);break}if(R+=e.length,e.copy(a,u),(u+=e.length)>=h){_=!1,s=e.slice(e.length-(u-h)),k();break}}};r.on("end",()=>{t&&R!==t&&e.emit("error",Error("Specified data size does not match: "+t+" !== "+R))}),this.api.request(d,(e,t)=>{if(e)return o(e);l=t.p,S()})}uploadAttribute(e,t,r){let[i,n]=d(r);if("string"==typeof e&&(e=["thumbnail","preview"].indexOf(e)),0!==e&&1!==e)throw Error("Invalid attribute type");return this._uploadAttribute({key:this.key,handle:this.nodeId},t,e+1,(t,r,n,o)=>{if(t)return i(t);let s={a:"pfa",n:this.nodeId,fa:e+"*"+b(n)};this.api.request(s,(e,t)=>{if(e)return i(e);i(null,this)})}),n}delete(e,t){return("function"==typeof e&&(t=e,e=void 0),void 0===e&&(e=this.parent===this.storage.trash),e)?this.api.request({a:"d",n:this.nodeId},t):this.moveTo(this.storage.trash,t)}moveTo(e,t){if("string"==typeof e&&(e=this.storage.files[e]),!(e instanceof H))throw Error("target must be a folder or a nodeId");let r={a:"m",n:this.nodeId,t:e.nodeId},i=z(this.storage.shareKeys,e);return i.length>0&&(r.cr=V(this.storage,[this],i)),this.api.request(r,t)}setAttributes(t,r){let[i,n]=d(r);Object.assign(this.attributes,t);let o=e.packAttributes(this.attributes);return w(this.key).encryptCBC(o),this.api.request({a:"a",n:this.nodeId,at:b(o)},e=>{this.parseAttributes(this.attributes),i(e)}),n}rename(e,t){return this.setAttributes({n:e},t)}setLabel(e,t){if("string"==typeof e&&(e=W.indexOf(e)),"number"!=typeof e||Math.floor(e)!==e||e<0||e>7)throw Error("label must be a integer between 0 and 7 or a valid label name");return this.setAttributes({lbl:e},t)}setFavorite(e,t){return this.setAttributes({fav:+!!e},t)}link(e,t){1==arguments.length&&"function"==typeof e&&(t=e,e={noKey:!1}),"boolean"==typeof e&&(e={noKey:e}),e||(e={});let r=e.__folderKey;if(this.directory&&!r)return this.shareFolder(e,t);let[i,n]=d(t);return this.api.request({a:"l",n:this.nodeId},(t,n)=>{if(t)return i(t);let o=`https://mega.nz/${r?"folder":"file"}/${n}`;!e.noKey&&this.key&&(o+=`#${b(r||this.key)}`),i(null,o)}),n}shareFolder(e,t){if(!this.directory)throw Error("node isn't a folder");let r=this.nodeId,i=this.storage.shareKeys[r];if(i)return this.link(Object.assign({__folderKey:i},e),t);let n=g(e.key);n||(n=globalThis.crypto.getRandomValues(new Uint8Array(16))),n instanceof Buffer||(n=Buffer.from(n));let[o,s]=d(t);if(16!==n.length)return o(Error("share key must be 16 byte / 22 characters")),s;this.storage.shareKeys[r]=n;let a=Buffer.from(r+r);this.storage.aes.encryptECB(a);let l={a:"s2",n:r,s:[{u:"EXP",r:0}],ok:b(this.storage.aes.encryptECB(Buffer.from(n))),ha:b(a),cr:V(this.storage,this)};return this.api.request(l,t=>{if(t)return o(t);this.link(Object.assign({__folderKey:n},e),o)}),s}unshare(e){return this.directory?this.unshareFolder(e):this.api.request({a:"l",n:this.nodeId,d:1},e)}unshareFolder(e){if(!this.directory)throw Error("node isn't a folder");return delete this.storage.shareKeys[this.nodeId],this.api.request({a:"s2",n:this.nodeId,s:[{u:"EXP",r:""}]},e)}importFile(t,r){let[i,n]=d(r);if(!this.directory)throw Error("importFile can only be called on directories");if("string"==typeof t&&(t=H.fromURL(t)),!(t instanceof H))throw Error("First argument of importFile should be a File or a URL string");if(!t.key)return i(Error("Can't import files without encryption keys")),n;let o=(t,r)=>{if(t)return i(t);let n=e.packAttributes(r.attributes);w(r.key).encryptCBC(n);let o=Array.isArray(r.downloadId)?r.downloadId[1]:r.downloadId,s={a:"p",t:this.nodeId,n:[{ph:o,t:0,a:b(n),k:b(this.storage.aes.encryptECB(r.key))}]};this.api.request(s,(e,t)=>{if(e)return i(e);let r=this.storage._importFile(t.f[0]);this.storage.emit("add",r),i(null,r)})};return t.attributes?o(null,t):t.loadAttributes(o),n}static packAttributes(e){let t=JSON.stringify(e);t=Buffer.from(`MEGA${t}`);let r=Buffer.alloc(16*Math.ceil(t.length/16));return t.copy(r),r}};function V(e,t,r){let i=e.shareKeys;Array.isArray(t)||(t=function e(t){return[t].concat((t.children||[]).map(e).reduce((e,t)=>e.concat(t),[]))}(t)),r||(r=t.map(e=>z(i,e)).reduce((e,t)=>e.concat(t)).filter((e,t,r)=>t===r.indexOf(e)));let n=[r,t.map(e=>e.nodeId),[]];for(let e=r.length;e--;){let o=new c(i[r[e]]);for(let r=t.length;r--;){let i=Buffer.from(t[r].key);i&&(32===i.length||16===i.length)&&n[2].push(e,r,b(o.encryptECB(i)))}}return n}function z(e,t){let r=t.nodeId,i=t.parent,n=[];return e[r]&&n.push(r),i?n.concat(z(e,i)):n}var G=class e extends s.EventEmitter{constructor(e,t){super(),1==arguments.length&&"function"==typeof e&&(t=e,e={});let[r,i]=d(t);this.ready=i,e.keepalive=void 0===e.keepalive||!!e.keepalive,e.autoload=void 0===e.autoload||!!e.autoload,e.autologin=void 0===e.autologin||!!e.autologin,this.api=new U(e.keepalive,e),this.files={},this.options=e,this.status="closed",e.autologin?this.login(r):process.nextTick(()=>{r(null,this)})}login(e){let[t,r]=d(e);if("string"!=typeof this.options.email)return process.nextTick(()=>{t(Error("starting a session without credentials isn't supported"))}),r;let i=()=>{this.status="ready",t(null,this),this.emit("ready",this)},n=e=>{this.api.request({a:"ug"},(t,r)=>{if(t)return e(t);this.name=r.name,this.user=r.u,this.options.autoload?this.reload(!0,t=>{if(t)return e(t);i()}):i()})};this.email=this.options.email.toLowerCase();let s=()=>{let e=new c(function(e){let t,r,i,n=Buffer.from([147,196,103,227,125,176,199,164,209,190,63,129,1,82,203,86]);for(i=65536;i--;)for(r=0;r<e.length;r+=16){let i=Buffer.alloc(16);for(t=0;t<16;t+=4)t+r<e.length&&e.copy(i,t,t+r,t+r+4);n=o.createCipheriv("aes-128-ecb",i,Buffer.alloc(0)).setAutoPadding(!1).update(n)}return n}(Buffer.from(this.options.password))),t=b(e.stringhash(Buffer.from(this.email)));l({a:"us",user:this.email,uh:t},e)},a=e=>{!function(e,t,r){let i=Buffer.from(t.s,"base64");o.pbkdf2(e,i,1e5,32,"sha512",r)}(Buffer.from(this.options.password),e,(e,r)=>{if(e)return t(e);let i=new c(r.slice(0,16)),n=b(r.slice(16));l({a:"us",user:this.email,uh:n},i)})},l=(e,r)=>{delete this.options.password,this.options.secondFactorCode&&(e.mfa=this.options.secondFactorCode.toString()),this.api.request(e,(e,i)=>{if(e)return t(e);this.key=g(i.k),r.decryptECB(this.key),this.aes=new c(this.key);let o=g(i.csid),s=function(e){let t=[];for(let r=0;r<4;r++){let i=(256*e[0]+e[1]+7>>3)+2;if(t[r]=P(e.toString("binary").substr(0,i)),"number"==typeof t[r]){if(4!==r||e.length>=16)return!1;break}e=e.slice(i)}return t}(this.aes.decryptECB(g(i.privk)));if(!s)throw Error("invalid credentials");let a=b(L(o,s).slice(0,43));this.api.sid=this.sid=a,this.RSAPrivateKey=s,n(t)})};return this.api.request({a:"us0",user:this.email},(e,r)=>e?t(e):1===r.v?s():2===r.v?a(r):void t(Error("Account version not supported"))),this.status="connecting",r}reload(e,t){"function"==typeof e&&([e,t]=[t,e]);let[r,i]=d(t);return"connecting"!==this.status||e?(this.mounts=[],this.api.request({a:"f",c:1},(e,t)=>{if(e)return r(e);for(let e of(this.shareKeys=t.ok.reduce((e,t)=>{let r=t.h,i=this.aes.encryptECB(Buffer.from(r+r));return function(e,t){if(e.length!==t.length)return!1;let r=e.length,i=0;for(let n=0;n<r;n++)i|=e[n]^t[n];return 0===i}(g(t.ha),i)&&(e[r]=this.aes.decryptECB(g(t.k))),e},{}),t.f))if(e=this._importFile(e),void 0!==t.ph&&(e.shareId=t.ph.find(t=>t.h===e.nodeId)?.ph,e.shared=!!e.shareId,e.shared)){e.shareURL=`https://mega.nz/${e.directory?"folder":"file"}/${e.shareId}`;let t=e.directory?this.shareKeys[e.nodeId]:e.key;t&&(e.shareURL+="#"+b(t))}r(null,this.mounts)}),this.api.on("sc",e=>{let t={};e.forEach(e=>{if("u"===e.a){let t=this.files[e.n];t&&(t.timestamp=e.ts,t.decryptAttributes(e.at),t.emit("update"),this.emit("update",t))}else"d"===e.a?t[e.n]=!0:"t"===e.a&&e.t.f.forEach(e=>{let r=this.files[e.h];if(r){delete t[e.h];let i=r.parent;if(i.nodeId===e.p)return;i.children.splice(i.children.indexOf(r),1),r.parent=this.files[e.p],r.parent.children.push(r),r.emit("move",i),this.emit("move",r,i)}else this.emit("add",this._importFile(e))})}),Object.keys(t).forEach(e=>{let t=this.files[e],r=t.parent;r.children.splice(r.children.indexOf(t),1),this.emit("delete",t),t.emit("delete")})})):this.once("ready",()=>{this.reload(e,r)}),i}_importFile(e){if(!this.files[e.h]){let t=this.files[e.h]=new K(e,this);if(2===e.t&&(this.root=t,t.name="Cloud Drive"),4===e.t&&(this.trash=t,t.name="Rubbish Bin"),3===e.t&&(this.inbox=t,t.name="Inbox"),e.t>1&&this.mounts.push(t),e.p){let r=this.files[e.p];r&&(r.children.push(t),t.parent=r)}}return this.files[e.h]}mkdir(e,t){if("ready"!==this.status)throw Error("storage is not ready");return this.root.mkdir(e,t)}upload(e,t,r){if("ready"!==this.status)throw Error("storage is not ready");return this.root.upload(e,t,r)}find(e,t){if("ready"!==this.status)throw Error("storage is not ready");return this.root.find(e,t)}filter(e,t){if("ready"!==this.status)throw Error("storage is not ready");return this.root.filter(e,t)}navigate(e,t){if("ready"!==this.status)throw Error("storage is not ready");return this.root.navigate(e,t)}close(e){return this.status="closed",this.api.close(),this.api.request({a:"sml"},e)}getAccountInfo(e){let[t,r]=d(e);return this.api.request({a:"uq",strg:1,xfer:1,pro:1},(e,r)=>{e&&t(e);let i={};i.type=r.utype,i.spaceUsed=r.cstrg,i.spaceTotal=r.mstrg,i.downloadBandwidthTotal=r.mxfer||0x28000000000000,i.downloadBandwidthUsed=r.caxfer||0,i.sharedBandwidthUsed=r.csxfer||0,i.sharedBandwidthLimit=r.srvratio,t(null,i)}),r}toJSON(){return{key:b(this.key),sid:this.sid,name:this.name,user:this.user,options:this.options}}static fromJSON(t){let r=new e(Object.assign(t.options,{autoload:!1,autologin:!1}));return r.key=m(t.key),r.aes=new c(r.key),r.api.sid=r.sid=t.sid,r.name=t.name,r.user=t.user,r}decryptRsaKey(e){return L(e,this.RSAPrivateKey)}};H.fromURL},54735:(e,t,r)=>{var i=r(27910);"disable"===process.env.READABLE_STREAM&&i?(e.exports=i.Readable,Object.assign(e.exports,i),e.exports.Stream=i):((t=e.exports=r(7341)).Stream=i||t,t.Readable=t,t.Writable=r(20429),t.Duplex=r(28947),t.Transform=r(65225),t.PassThrough=r(47535),t.finished=r(97427),t.pipeline=r(67869))},59610:(e,t,r)=>{try{var i=r(28354);if("function"!=typeof i.inherits)throw"";e.exports=i.inherits}catch(t){e.exports=r(10365)}},65225:(e,t,r)=>{"use strict";e.exports=u;var i=r(83796).F,n=i.ERR_METHOD_NOT_IMPLEMENTED,o=i.ERR_MULTIPLE_CALLBACK,s=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,l=r(28947);function h(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);l.call(this,e),this._transformState={afterTransform:h.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",f)}function f(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?d(this,null,null):this._flush(function(t,r){d(e,t,r)})}function d(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}r(59610)(u,l),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,l.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,r){r(new n("_transform()"))},u.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},u.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},u.prototype._destroy=function(e,t){l.prototype._destroy.call(this,e,function(e){t(e)})}},67869:(e,t,r)=>{"use strict";var i,n=r(83796).F,o=n.ERR_MISSING_ARGS,s=n.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function l(e){e()}function h(e,t){return e.pipe(t)}e.exports=function(){for(var e,t,n=arguments.length,u=Array(n),f=0;f<n;f++)u[f]=arguments[f];var d=(e=u).length&&"function"==typeof e[e.length-1]?e.pop():a;if(Array.isArray(u[0])&&(u=u[0]),u.length<2)throw new o("streams");var c=u.map(function(e,n){var o,a,h,f,p,y,g=n<u.length-1;return o=n>0,h=a=function(e){t||(t=e),e&&c.forEach(l),g||(c.forEach(l),d(t))},f=!1,a=function(){f||(f=!0,h.apply(void 0,arguments))},p=!1,e.on("close",function(){p=!0}),void 0===i&&(i=r(97427)),i(e,{readable:g,writable:o},function(e){if(e)return a(e);p=!0,a()}),y=!1,function(t){if(!p&&!y){if(y=!0,e.setHeader&&"function"==typeof e.abort)return e.abort();if("function"==typeof e.destroy)return e.destroy();a(t||new s("pipe"))}}});return u.reduce(h)}},69656:(e,t,r)=>{"use strict";function i(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}function n(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach(function(t){var i,n,s;i=e,n=t,s=r[t],(n=o(n))in i?Object.defineProperty(i,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[n]=s}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(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)}var s=r(79428).Buffer,a=r(28354).inspect,l=a&&a.custom||"inspect";e.exports=function(){var e;function t(){if(!(this instanceof t))throw TypeError("Cannot call a class as a function");this.head=null,this.tail=null,this.length=0}return e=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t,r,i=s.allocUnsafe(e>>>0),n=this.head,o=0;n;)t=n.data,r=o,s.prototype.copy.call(t,i,r),o+=n.data.length,n=n.next;return i}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,i=t.data;for(e-=i.length;t=t.next;){var n=t.data,o=e>n.length?n.length:e;if(o===n.length?i+=n:i+=n.slice(0,e),0==(e-=o)){o===n.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(o));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,i=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var n=r.data,o=e>n.length?n.length:e;if(n.copy(t,t.length-e,0,o),0==(e-=o)){o===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(o));break}++i}return this.length-=i,t}},{key:l,value:function(e,t){return a(this,n(n({},t),{},{depth:0,customInspect:!1}))}}],function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}()},75161:e=>{"use strict";function t(e,t){i(e,t),r(e)}function r(e){(!e._writableState||e._writableState.emitClose)&&(!e._readableState||e._readableState.emitClose)&&e.emit("close")}function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,n){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?n?n(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(i,this,e)):process.nextTick(i,this,e)):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!n&&e?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(t,o,e)):process.nextTick(t,o,e):n?(process.nextTick(r,o),n(e)):process.nextTick(r,o)})),this},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}}},83796:e=>{"use strict";let t={};function r(e,r,i){i||(i=Error);class n extends i{constructor(e,t,i){super("string"==typeof r?r:r(e,t,i))}}n.prototype.name=i.name,n.prototype.code=e,t[e]=n}function i(e,t){if(!Array.isArray(e))return`of ${t} ${String(e)}`;{let r=e.length;return(e=e.map(e=>String(e)),r>2)?`one of ${t} ${e.slice(0,r-1).join(", ")}, or `+e[r-1]:2===r?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}}r("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(e,t,r){var n,o,s,a;let l,h;if("string"==typeof t&&(n="not ",t.substr(0,n.length)===n)?(l="must not be",t=t.replace(/^not /,"")):l="must be",o=" argument",(void 0===s||s>e.length)&&(s=e.length),e.substring(s-o.length,s)===o)h=`The ${e} ${l} ${i(t,"type")}`;else{let r=("number"!=typeof a&&(a=0),a+1>e.length||-1===e.indexOf(".",a))?"argument":"property";h=`The "${e}" ${r} ${l} ${i(t,"type")}`}return h+`. Received type ${typeof r}`},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.F=t},87464:(e,t,r)=>{e.exports=r(28354).deprecate},92815:(e,t,r)=>{e.exports=r(27910)},93724:(e,t,r)=>{"use strict";function i(e,t,r){var i;return(t="symbol"==typeof(i=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)}(t,"string"))?i:String(i))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var n,o=r(97427),s=Symbol("lastResolve"),a=Symbol("lastReject"),l=Symbol("error"),h=Symbol("ended"),u=Symbol("lastPromise"),f=Symbol("handlePromise"),d=Symbol("stream");function c(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var r=e[d].read();null!==r&&(e[u]=null,e[s]=null,e[a]=null,t(c(r,!1)))}}function y(e){process.nextTick(p,e)}var g=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((i(n={get stream(){return this[d]},next:function(){var e,t,r=this,i=this[l];if(null!==i)return Promise.reject(i);if(this[h])return Promise.resolve(c(void 0,!0));if(this[d].destroyed)return new Promise(function(e,t){process.nextTick(function(){r[l]?t(r[l]):e(c(void 0,!0))})});var n=this[u];if(n)t=new Promise((e=this,function(t,r){n.then(function(){if(e[h])return void t(c(void 0,!0));e[f](t,r)},r)}));else{var o=this[d].read();if(null!==o)return Promise.resolve(c(o,!1));t=new Promise(this[f])}return this[u]=t,t}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var e=this;return new Promise(function(t,r){e[d].destroy(null,function(e){if(e)return void r(e);t(c(void 0,!0))})})}),n),g);e.exports=function(e){var t,r=Object.create(b,(i(t={},d,{value:e,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,l,{value:null,writable:!0}),i(t,h,{value:e._readableState.endEmitted,writable:!0}),i(t,f,{value:function(e,t){var i=r[d].read();i?(r[u]=null,r[s]=null,r[a]=null,e(c(i,!1))):(r[s]=e,r[a]=t)},writable:!0}),t));return r[u]=null,o(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[a];null!==t&&(r[u]=null,r[s]=null,r[a]=null,t(e)),r[l]=e;return}var i=r[s];null!==i&&(r[u]=null,r[s]=null,r[a]=null,i(c(void 0,!0))),r[h]=!0}),e.on("readable",y.bind(null,r)),r}},96848:(e,t,r)=>{var i=r(64686),n=r(59610),o=r(32248),s=function(e){return e.length?Array.isArray(e[0])?e[0]:Array.prototype.slice.call(e):[]},a=function(e){var t=function(){var r=s(arguments);if(!(this instanceof t))return new t(r);o.call(this,null,null,e),r.length&&this.setPipeline(r)};return n(t,o),t.prototype.setPipeline=function(){var e=s(arguments),t=this,r=!1,n=e[0],o=e[e.length-1];o=o.readable?o:null,n=n.writable?n:null;var a=function(){e[0].emit("error",Error("stream was destroyed"))};if(this.on("close",a),this.on("prefinish",function(){r||t.cork()}),i(e,function(e){if(t.removeListener("close",a),e)return t.destroy("premature close"===e.message?null:e);r=!0,!1===t._autoDestroy&&(t._autoDestroy=!0),t.uncork()}),this.destroyed)return a();this.setWritable(n),this.setReadable(o)},t};e.exports=a({autoDestroy:!1,destroy:!1}),e.exports.obj=a({autoDestroy:!1,destroy:!1,objectMode:!0,highWaterMark:16}),e.exports.ctor=a},97427:(e,t,r)=>{"use strict";var i=r(83796).F.ERR_STREAM_PREMATURE_CLOSE;function n(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),s=o||n,a=!1,o=function(){if(!a){a=!0;for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];s.apply(this,t)}};var s,a,l=r.readable||!1!==r.readable&&t.readable,h=r.writable||!1!==r.writable&&t.writable,u=function(){t.writable||d()},f=t._writableState&&t._writableState.finished,d=function(){h=!1,f=!0,l||o.call(t)},c=t._readableState&&t._readableState.endEmitted,p=function(){l=!1,c=!0,h||o.call(t)},y=function(e){o.call(t,e)},g=function(){var e;return l&&!c?(t._readableState&&t._readableState.ended||(e=new i),o.call(t,e)):h&&!f?(t._writableState&&t._writableState.ended||(e=new i),o.call(t,e)):void 0},b=function(){t.req.on("finish",d)};return t.setHeader&&"function"==typeof t.abort?(t.on("complete",d),t.on("abort",g),t.req?b():t.on("request",b)):h&&!t._writableState&&(t.on("end",u),t.on("close",u)),t.on("end",p),t.on("finish",d),!1!==r.error&&t.on("error",y),t.on("close",g),function(){t.removeListener("complete",d),t.removeListener("abort",g),t.removeListener("request",b),t.req&&t.req.removeListener("finish",d),t.removeListener("end",u),t.removeListener("close",u),t.removeListener("finish",d),t.removeListener("end",p),t.removeListener("error",y),t.removeListener("close",g)}}}};