dsh-remote-go 0.0.1 → 0.2.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 (52) hide show
  1. package/README.md +87 -7
  2. package/client.js +8763 -0
  3. package/cordis.patch.yml +3 -0
  4. package/index.js +4 -0
  5. package/locale/en.json +6 -0
  6. package/locale/zh.json +6 -0
  7. package/package.json +77 -3
  8. package/src/admission.js +43 -0
  9. package/src/api.js +536 -0
  10. package/src/atomic-json.js +225 -0
  11. package/src/bootstrap.js +113 -0
  12. package/src/connect-log.js +176 -0
  13. package/src/connect-pipeline.js +1900 -0
  14. package/src/connect-progress.js +155 -0
  15. package/src/constants.js +93 -0
  16. package/src/diagnostics.js +160 -0
  17. package/src/download-jobs.js +234 -0
  18. package/src/errors.js +412 -0
  19. package/src/host-lifecycle.js +604 -0
  20. package/src/host-registry.js +217 -0
  21. package/src/host-runtime.js +127 -0
  22. package/src/host-view.js +75 -0
  23. package/src/index.js +206 -0
  24. package/src/key-files.js +54 -0
  25. package/src/known-hosts.js +133 -0
  26. package/src/layout.js +53 -0
  27. package/src/local-download.js +381 -0
  28. package/src/local-ssh.js +27 -0
  29. package/src/local-version.js +88 -0
  30. package/src/node-runtime.js +521 -0
  31. package/src/probe.js +101 -0
  32. package/src/prompts.js +229 -0
  33. package/src/redact.js +68 -0
  34. package/src/remote-files.js +71 -0
  35. package/src/remote-path.js +137 -0
  36. package/src/remote-proc.js +343 -0
  37. package/src/remote-proxy.js +815 -0
  38. package/src/remote-web.js +751 -0
  39. package/src/request-trust.js +89 -0
  40. package/src/secrets.js +109 -0
  41. package/src/service.js +459 -0
  42. package/src/settings.js +163 -0
  43. package/src/ssh-config.js +271 -0
  44. package/src/ssh.js +731 -0
  45. package/src/store.js +193 -0
  46. package/src/tools.js +386 -0
  47. package/src/tunnel.js +132 -0
  48. package/src/util.js +153 -0
  49. package/src/version.js +103 -0
  50. package/src/webapp.js +43 -0
  51. package/vendor/THIRD_PARTY_NOTICES.md +36 -0
  52. package/vendor/ssh2.bundle.cjs +25 -0
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * Bundled ssh2 (MIT) — https://github.com/mscdex/ssh2
3
+ * Generated by scripts/build-vendor.mjs (minified; --no-minify for a readable bundle); do not edit by hand.
4
+ * The optional native accelerator (cpu-features) is intentionally not bundled:
5
+ * ssh2 falls back to its pure-JavaScript implementation.
6
+ */
7
+
8
+ var uc=Object.create;var Fr=Object.defineProperty;var lc=Object.getOwnPropertyDescriptor;var dc=Object.getOwnPropertyNames;var Ac=Object.getPrototypeOf,gc=Object.prototype.hasOwnProperty;var Ze=(n,t)=>()=>{try{return t||n((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}},_c=(n,t)=>{for(var e in t)Fr(n,e,{get:t[e],enumerable:!0})},To=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of dc(t))!gc.call(n,i)&&i!==e&&Fr(n,i,{get:()=>t[i],enumerable:!(r=lc(t,i))||r.enumerable});return n};var Ec=(n,t,e)=>(e=n!=null?uc(Ac(n)):{},To(t||!n||!n.__esModule?Fr(e,"default",{value:n,enumerable:!0}):e,n)),pc=n=>To(Fr({},"__esModule",{value:!0}),n);var Mr=Ze((pd,vo)=>{vo.exports={newInvalidAsn1Error:function(n){var t=new Error;return t.name="InvalidAsn1Error",t.message=n||"",t}}});var qr=Ze((bd,Lo)=>{Lo.exports={EOC:0,Boolean:1,Integer:2,BitString:3,OctetString:4,Null:5,OID:6,ObjectDescriptor:7,External:8,Real:9,Enumeration:10,PDV:11,Utf8String:12,RelativeOID:13,Sequence:16,Set:17,NumericString:18,PrintableString:19,T61String:20,VideotexString:21,IA5String:22,UTCTime:23,GeneralizedTime:24,GraphicString:25,VisibleString:26,GeneralString:28,UniversalString:29,CharacterString:30,BMPString:31,Constructor:32,Context:128}});var Qi=Ze((Id,Uo)=>{"use strict";var Kr=require("buffer"),Pn=Kr.Buffer,Ft={},Mt;for(Mt in Kr)Kr.hasOwnProperty(Mt)&&(Mt==="SlowBuffer"||Mt==="Buffer"||(Ft[Mt]=Kr[Mt]));var Dn=Ft.Buffer={};for(Mt in Pn)Pn.hasOwnProperty(Mt)&&(Mt==="allocUnsafe"||Mt==="allocUnsafeSlow"||(Dn[Mt]=Pn[Mt]));Ft.Buffer.prototype=Pn.prototype;(!Dn.from||Dn.from===Uint8Array.from)&&(Dn.from=function(n,t,e){if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof n);if(n&&typeof n.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);return Pn(n,t,e)});Dn.alloc||(Dn.alloc=function(n,t,e){if(typeof n!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof n);if(n<0||n>=2*(1<<30))throw new RangeError('The value "'+n+'" is invalid for option "size"');var r=Pn(n);return!t||t.length===0?r.fill(0):typeof e=="string"?r.fill(t,e):r.fill(t),r});if(!Ft.kStringMaxLength)try{Ft.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}Ft.constants||(Ft.constants={MAX_LENGTH:Ft.kMaxLength},Ft.kStringMaxLength&&(Ft.constants.MAX_STRING_LENGTH=Ft.kStringMaxLength));Uo.exports=Ft});var Do=Ze((xd,Po)=>{var bc=require("assert"),Oo=Qi().Buffer,ar=qr(),Ic=Mr(),Qn=Ic.newInvalidAsn1Error;function Rt(n){if(!n||!Oo.isBuffer(n))throw new TypeError("data must be a node Buffer");this._buf=n,this._size=n.length,this._len=0,this._offset=0}Object.defineProperty(Rt.prototype,"length",{enumerable:!0,get:function(){return this._len}});Object.defineProperty(Rt.prototype,"offset",{enumerable:!0,get:function(){return this._offset}});Object.defineProperty(Rt.prototype,"remain",{get:function(){return this._size-this._offset}});Object.defineProperty(Rt.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}});Rt.prototype.readByte=function(n){if(this._size-this._offset<1)return null;var t=this._buf[this._offset]&255;return n||(this._offset+=1),t};Rt.prototype.peek=function(){return this.readByte(!0)};Rt.prototype.readLength=function(n){if(n===void 0&&(n=this._offset),n>=this._size)return null;var t=this._buf[n++]&255;if(t===null)return null;if((t&128)===128){if(t&=127,t===0)throw Qn("Indefinite length not supported");if(t>4)throw Qn("encoding too long");if(this._size-n<t)return null;this._len=0;for(var e=0;e<t;e++)this._len=(this._len<<8)+(this._buf[n++]&255)}else this._len=t;return n};Rt.prototype.readSequence=function(n){var t=this.peek();if(t===null)return null;if(n!==void 0&&n!==t)throw Qn("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);return e===null?null:(this._offset=e,t)};Rt.prototype.readInt=function(){return this._readTag(ar.Integer)};Rt.prototype.readBoolean=function(){return this._readTag(ar.Boolean)!==0};Rt.prototype.readEnumeration=function(){return this._readTag(ar.Enumeration)};Rt.prototype.readString=function(n,t){n||(n=ar.OctetString);var e=this.peek();if(e===null)return null;if(e!==n)throw Qn("Expected 0x"+n.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);if(r===null||this.length>this._size-r)return null;if(this._offset=r,this.length===0)return t?Oo.alloc(0):"";var i=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?i:i.toString("utf8")};Rt.prototype.readOID=function(n){n||(n=ar.OID);var t=this.readString(n,!0);if(t===null)return null;for(var e=[],r=0,i=0;i<t.length;i++){var s=t[i]&255;r<<=7,r+=s&127,(s&128)===0&&(e.push(r),r=0)}return r=e.shift(),e.unshift(r%40),e.unshift(r/40>>0),e.join(".")};Rt.prototype._readTag=function(n){bc.ok(n!==void 0);var t=this.peek();if(t===null)return null;if(t!==n)throw Qn("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);if(e===null)return null;if(this.length>4)throw Qn("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var r=this._buf[this._offset],i=0,s=0;s<this.length;s++)i<<=8,i|=this._buf[this._offset++]&255;return(r&128)===128&&s!==4&&(i-=1<<s*8),i>>0};Po.exports=Rt});var Ho=Ze((yd,Qo)=>{var an=require("assert"),Wr=Qi().Buffer,cn=qr(),xc=Mr(),Gr=xc.newInvalidAsn1Error,yc={size:1024,growthFactor:8};function Sc(n,t){an.ok(n),an.equal(typeof n,"object"),an.ok(t),an.equal(typeof t,"object");var e=Object.getOwnPropertyNames(n);return e.forEach(function(r){if(!t[r]){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i)}}),t}function Ct(n){n=Sc(yc,n||{}),this._buf=Wr.alloc(n.size||1024),this._size=this._buf.length,this._offset=0,this._options=n,this._seq=[]}Object.defineProperty(Ct.prototype,"buffer",{get:function(){if(this._seq.length)throw Gr(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}});Ct.prototype.writeByte=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=n};Ct.prototype.writeInt=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=cn.Integer);for(var e=4;((n&4286578688)===0||(n&4286578688)===-8388608)&&e>1;)e--,n<<=8;if(e>4)throw Gr("BER ints cannot be > 0xffffffff");for(this._ensure(2+e),this._buf[this._offset++]=t,this._buf[this._offset++]=e;e-- >0;)this._buf[this._offset++]=(n&4278190080)>>>24,n<<=8};Ct.prototype.writeNull=function(){this.writeByte(cn.Null),this.writeByte(0)};Ct.prototype.writeEnumeration=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=cn.Enumeration),this.writeInt(n,t)};Ct.prototype.writeBoolean=function(n,t){if(typeof n!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=cn.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=n?255:0};Ct.prototype.writeString=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string (was: "+typeof n+")");typeof t!="number"&&(t=cn.OctetString);var e=Wr.byteLength(n);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(n,this._offset),this._offset+=e)};Ct.prototype.writeBuffer=function(n,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!Wr.isBuffer(n))throw new TypeError("argument must be a buffer");this.writeByte(t),this.writeLength(n.length),this._ensure(n.length),n.copy(this._buf,this._offset,0,n.length),this._offset+=n.length};Ct.prototype.writeStringArray=function(n){if(!n instanceof Array)throw new TypeError("argument must be an Array[String]");var t=this;n.forEach(function(e){t.writeString(e)})};Ct.prototype.writeOID=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=cn.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(n))throw new Error("argument is not a valid OID string");function e(o,f){f<128?o.push(f):f<16384?(o.push(f>>>7|128),o.push(f&127)):f<2097152?(o.push(f>>>14|128),o.push((f>>>7|128)&255),o.push(f&127)):f<268435456?(o.push(f>>>21|128),o.push((f>>>14|128)&255),o.push((f>>>7|128)&255),o.push(f&127)):(o.push((f>>>28|128)&255),o.push((f>>>21|128)&255),o.push((f>>>14|128)&255),o.push((f>>>7|128)&255),o.push(f&127))}var r=n.split("."),i=[];i.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.slice(2).forEach(function(o){e(i,parseInt(o,10))});var s=this;this._ensure(2+i.length),this.writeByte(t),this.writeLength(i.length),i.forEach(function(o){s.writeByte(o)})};Ct.prototype.writeLength=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),n<=127)this._buf[this._offset++]=n;else if(n<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=n;else if(n<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else if(n<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=n>>16,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else throw Gr("Length too long (> 4 bytes)")};Ct.prototype.startSequence=function(n){typeof n!="number"&&(n=cn.Sequence|cn.Constructor),this.writeByte(n),this._seq.push(this._offset),this._ensure(3),this._offset+=3};Ct.prototype.endSequence=function(){var n=this._seq.pop(),t=n+3,e=this._offset-t;if(e<=127)this._shift(t,e,-2),this._buf[n]=e;else if(e<=255)this._shift(t,e,-1),this._buf[n]=129,this._buf[n+1]=e;else if(e<=65535)this._buf[n]=130,this._buf[n+1]=e>>8,this._buf[n+2]=e;else if(e<=16777215)this._shift(t,e,1),this._buf[n]=131,this._buf[n+1]=e>>16,this._buf[n+2]=e>>8,this._buf[n+3]=e;else throw Gr("Sequence too long")};Ct.prototype._shift=function(n,t,e){an.ok(n!==void 0),an.ok(t!==void 0),an.ok(e),this._buf.copy(this._buf,n+e,n,n+t),this._offset+=e};Ct.prototype._ensure=function(n){if(an.ok(n),this._size-this._offset<n){var t=this._size*this._options.growthFactor;t-this._offset<n&&(t+=n);var e=Wr.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};Qo.exports=Ct});var Fo=Ze((Sd,Xr)=>{var Hi=Mr(),Fi=qr(),wc=Do(),mc=Ho();Xr.exports={Reader:wc,Writer:mc};for(Yr in Fi)Fi.hasOwnProperty(Yr)&&(Xr.exports[Yr]=Fi[Yr]);var Yr;for($r in Hi)Hi.hasOwnProperty($r)&&(Xr.exports[$r]=Hi[$r]);var $r});var cr=Ze((wd,Mo)=>{var Mi=Fo();Mo.exports={Ber:Mi,BerReader:Mi.Reader,BerWriter:Mi.Writer}});var qo=Ze((md,jr)=>{(function(n){"use strict";var t=function(u){var g,A=new Float64Array(16);if(u)for(g=0;g<u.length;g++)A[g]=u[g];return A},e=function(){throw new Error("no PRNG")},r=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var s=t(),o=t([1]),f=t([56129,1]),a=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),l=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),_=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(u,g,A,c){u[g]=A>>24&255,u[g+1]=A>>16&255,u[g+2]=A>>8&255,u[g+3]=A&255,u[g+4]=c>>24&255,u[g+5]=c>>16&255,u[g+6]=c>>8&255,u[g+7]=c&255}function x(u,g,A,c,E){var m,R=0;for(m=0;m<E;m++)R|=u[g+m]^A[c+m];return(1&R-1>>>8)-1}function I(u,g,A,c){return x(u,g,A,c,16)}function k(u,g,A,c){return x(u,g,A,c,32)}function N(u,g,A,c){for(var E=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,m=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,R=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,W=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,ne=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,he=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,fe=g[0]&255|(g[1]&255)<<8|(g[2]&255)<<16|(g[3]&255)<<24,Xe=g[4]&255|(g[5]&255)<<8|(g[6]&255)<<16|(g[7]&255)<<24,ce=g[8]&255|(g[9]&255)<<8|(g[10]&255)<<16|(g[11]&255)<<24,ke=g[12]&255|(g[13]&255)<<8|(g[14]&255)<<16|(g[15]&255)<<24,Re=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,Ue=A[16]&255|(A[17]&255)<<8|(A[18]&255)<<16|(A[19]&255)<<24,Le=A[20]&255|(A[21]&255)<<8|(A[22]&255)<<16|(A[23]&255)<<24,Ne=A[24]&255|(A[25]&255)<<8|(A[26]&255)<<16|(A[27]&255)<<24,ve=A[28]&255|(A[29]&255)<<8|(A[30]&255)<<16|(A[31]&255)<<24,Te=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,ue=E,Ee=m,ae=R,de=W,ge=ne,oe=he,L=fe,U=Xe,Y=ce,K=ke,G=Re,z=Ue,ye=Le,Oe=Ne,De=ve,Pe=Te,b,He=0;He<20;He+=2)b=ue+ye|0,ge^=b<<7|b>>>25,b=ge+ue|0,Y^=b<<9|b>>>23,b=Y+ge|0,ye^=b<<13|b>>>19,b=ye+Y|0,ue^=b<<18|b>>>14,b=oe+Ee|0,K^=b<<7|b>>>25,b=K+oe|0,Oe^=b<<9|b>>>23,b=Oe+K|0,Ee^=b<<13|b>>>19,b=Ee+Oe|0,oe^=b<<18|b>>>14,b=G+L|0,De^=b<<7|b>>>25,b=De+G|0,ae^=b<<9|b>>>23,b=ae+De|0,L^=b<<13|b>>>19,b=L+ae|0,G^=b<<18|b>>>14,b=Pe+z|0,de^=b<<7|b>>>25,b=de+Pe|0,U^=b<<9|b>>>23,b=U+de|0,z^=b<<13|b>>>19,b=z+U|0,Pe^=b<<18|b>>>14,b=ue+de|0,Ee^=b<<7|b>>>25,b=Ee+ue|0,ae^=b<<9|b>>>23,b=ae+Ee|0,de^=b<<13|b>>>19,b=de+ae|0,ue^=b<<18|b>>>14,b=oe+ge|0,L^=b<<7|b>>>25,b=L+oe|0,U^=b<<9|b>>>23,b=U+L|0,ge^=b<<13|b>>>19,b=ge+U|0,oe^=b<<18|b>>>14,b=G+K|0,z^=b<<7|b>>>25,b=z+G|0,Y^=b<<9|b>>>23,b=Y+z|0,K^=b<<13|b>>>19,b=K+Y|0,G^=b<<18|b>>>14,b=Pe+De|0,ye^=b<<7|b>>>25,b=ye+Pe|0,Oe^=b<<9|b>>>23,b=Oe+ye|0,De^=b<<13|b>>>19,b=De+Oe|0,Pe^=b<<18|b>>>14;ue=ue+E|0,Ee=Ee+m|0,ae=ae+R|0,de=de+W|0,ge=ge+ne|0,oe=oe+he|0,L=L+fe|0,U=U+Xe|0,Y=Y+ce|0,K=K+ke|0,G=G+Re|0,z=z+Ue|0,ye=ye+Le|0,Oe=Oe+Ne|0,De=De+ve|0,Pe=Pe+Te|0,u[0]=ue>>>0&255,u[1]=ue>>>8&255,u[2]=ue>>>16&255,u[3]=ue>>>24&255,u[4]=Ee>>>0&255,u[5]=Ee>>>8&255,u[6]=Ee>>>16&255,u[7]=Ee>>>24&255,u[8]=ae>>>0&255,u[9]=ae>>>8&255,u[10]=ae>>>16&255,u[11]=ae>>>24&255,u[12]=de>>>0&255,u[13]=de>>>8&255,u[14]=de>>>16&255,u[15]=de>>>24&255,u[16]=ge>>>0&255,u[17]=ge>>>8&255,u[18]=ge>>>16&255,u[19]=ge>>>24&255,u[20]=oe>>>0&255,u[21]=oe>>>8&255,u[22]=oe>>>16&255,u[23]=oe>>>24&255,u[24]=L>>>0&255,u[25]=L>>>8&255,u[26]=L>>>16&255,u[27]=L>>>24&255,u[28]=U>>>0&255,u[29]=U>>>8&255,u[30]=U>>>16&255,u[31]=U>>>24&255,u[32]=Y>>>0&255,u[33]=Y>>>8&255,u[34]=Y>>>16&255,u[35]=Y>>>24&255,u[36]=K>>>0&255,u[37]=K>>>8&255,u[38]=K>>>16&255,u[39]=K>>>24&255,u[40]=G>>>0&255,u[41]=G>>>8&255,u[42]=G>>>16&255,u[43]=G>>>24&255,u[44]=z>>>0&255,u[45]=z>>>8&255,u[46]=z>>>16&255,u[47]=z>>>24&255,u[48]=ye>>>0&255,u[49]=ye>>>8&255,u[50]=ye>>>16&255,u[51]=ye>>>24&255,u[52]=Oe>>>0&255,u[53]=Oe>>>8&255,u[54]=Oe>>>16&255,u[55]=Oe>>>24&255,u[56]=De>>>0&255,u[57]=De>>>8&255,u[58]=De>>>16&255,u[59]=De>>>24&255,u[60]=Pe>>>0&255,u[61]=Pe>>>8&255,u[62]=Pe>>>16&255,u[63]=Pe>>>24&255}function D(u,g,A,c){for(var E=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,m=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,R=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,W=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,ne=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,he=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,fe=g[0]&255|(g[1]&255)<<8|(g[2]&255)<<16|(g[3]&255)<<24,Xe=g[4]&255|(g[5]&255)<<8|(g[6]&255)<<16|(g[7]&255)<<24,ce=g[8]&255|(g[9]&255)<<8|(g[10]&255)<<16|(g[11]&255)<<24,ke=g[12]&255|(g[13]&255)<<8|(g[14]&255)<<16|(g[15]&255)<<24,Re=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,Ue=A[16]&255|(A[17]&255)<<8|(A[18]&255)<<16|(A[19]&255)<<24,Le=A[20]&255|(A[21]&255)<<8|(A[22]&255)<<16|(A[23]&255)<<24,Ne=A[24]&255|(A[25]&255)<<8|(A[26]&255)<<16|(A[27]&255)<<24,ve=A[28]&255|(A[29]&255)<<8|(A[30]&255)<<16|(A[31]&255)<<24,Te=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,ue=E,Ee=m,ae=R,de=W,ge=ne,oe=he,L=fe,U=Xe,Y=ce,K=ke,G=Re,z=Ue,ye=Le,Oe=Ne,De=ve,Pe=Te,b,He=0;He<20;He+=2)b=ue+ye|0,ge^=b<<7|b>>>25,b=ge+ue|0,Y^=b<<9|b>>>23,b=Y+ge|0,ye^=b<<13|b>>>19,b=ye+Y|0,ue^=b<<18|b>>>14,b=oe+Ee|0,K^=b<<7|b>>>25,b=K+oe|0,Oe^=b<<9|b>>>23,b=Oe+K|0,Ee^=b<<13|b>>>19,b=Ee+Oe|0,oe^=b<<18|b>>>14,b=G+L|0,De^=b<<7|b>>>25,b=De+G|0,ae^=b<<9|b>>>23,b=ae+De|0,L^=b<<13|b>>>19,b=L+ae|0,G^=b<<18|b>>>14,b=Pe+z|0,de^=b<<7|b>>>25,b=de+Pe|0,U^=b<<9|b>>>23,b=U+de|0,z^=b<<13|b>>>19,b=z+U|0,Pe^=b<<18|b>>>14,b=ue+de|0,Ee^=b<<7|b>>>25,b=Ee+ue|0,ae^=b<<9|b>>>23,b=ae+Ee|0,de^=b<<13|b>>>19,b=de+ae|0,ue^=b<<18|b>>>14,b=oe+ge|0,L^=b<<7|b>>>25,b=L+oe|0,U^=b<<9|b>>>23,b=U+L|0,ge^=b<<13|b>>>19,b=ge+U|0,oe^=b<<18|b>>>14,b=G+K|0,z^=b<<7|b>>>25,b=z+G|0,Y^=b<<9|b>>>23,b=Y+z|0,K^=b<<13|b>>>19,b=K+Y|0,G^=b<<18|b>>>14,b=Pe+De|0,ye^=b<<7|b>>>25,b=ye+Pe|0,Oe^=b<<9|b>>>23,b=Oe+ye|0,De^=b<<13|b>>>19,b=De+Oe|0,Pe^=b<<18|b>>>14;u[0]=ue>>>0&255,u[1]=ue>>>8&255,u[2]=ue>>>16&255,u[3]=ue>>>24&255,u[4]=oe>>>0&255,u[5]=oe>>>8&255,u[6]=oe>>>16&255,u[7]=oe>>>24&255,u[8]=G>>>0&255,u[9]=G>>>8&255,u[10]=G>>>16&255,u[11]=G>>>24&255,u[12]=Pe>>>0&255,u[13]=Pe>>>8&255,u[14]=Pe>>>16&255,u[15]=Pe>>>24&255,u[16]=L>>>0&255,u[17]=L>>>8&255,u[18]=L>>>16&255,u[19]=L>>>24&255,u[20]=U>>>0&255,u[21]=U>>>8&255,u[22]=U>>>16&255,u[23]=U>>>24&255,u[24]=Y>>>0&255,u[25]=Y>>>8&255,u[26]=Y>>>16&255,u[27]=Y>>>24&255,u[28]=K>>>0&255,u[29]=K>>>8&255,u[30]=K>>>16&255,u[31]=K>>>24&255}function Z(u,g,A,c){N(u,g,A,c)}function O(u,g,A,c){D(u,g,A,c)}var V=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function ee(u,g,A,c,E,m,R){var W=new Uint8Array(16),ne=new Uint8Array(64),he,fe;for(fe=0;fe<16;fe++)W[fe]=0;for(fe=0;fe<8;fe++)W[fe]=m[fe];for(;E>=64;){for(Z(ne,W,R,V),fe=0;fe<64;fe++)u[g+fe]=A[c+fe]^ne[fe];for(he=1,fe=8;fe<16;fe++)he=he+(W[fe]&255)|0,W[fe]=he&255,he>>>=8;E-=64,g+=64,c+=64}if(E>0)for(Z(ne,W,R,V),fe=0;fe<E;fe++)u[g+fe]=A[c+fe]^ne[fe];return 0}function X(u,g,A,c,E){var m=new Uint8Array(16),R=new Uint8Array(64),W,ne;for(ne=0;ne<16;ne++)m[ne]=0;for(ne=0;ne<8;ne++)m[ne]=c[ne];for(;A>=64;){for(Z(R,m,E,V),ne=0;ne<64;ne++)u[g+ne]=R[ne];for(W=1,ne=8;ne<16;ne++)W=W+(m[ne]&255)|0,m[ne]=W&255,W>>>=8;A-=64,g+=64}if(A>0)for(Z(R,m,E,V),ne=0;ne<A;ne++)u[g+ne]=R[ne];return 0}function y(u,g,A,c,E){var m=new Uint8Array(32);O(m,c,E,V);for(var R=new Uint8Array(8),W=0;W<8;W++)R[W]=c[W+16];return X(u,g,A,R,m)}function S(u,g,A,c,E,m,R){var W=new Uint8Array(32);O(W,m,R,V);for(var ne=new Uint8Array(8),he=0;he<8;he++)ne[he]=m[he+16];return ee(u,g,A,c,E,ne,W)}var v=function(u){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var g,A,c,E,m,R,W,ne;g=u[0]&255|(u[1]&255)<<8,this.r[0]=g&8191,A=u[2]&255|(u[3]&255)<<8,this.r[1]=(g>>>13|A<<3)&8191,c=u[4]&255|(u[5]&255)<<8,this.r[2]=(A>>>10|c<<6)&7939,E=u[6]&255|(u[7]&255)<<8,this.r[3]=(c>>>7|E<<9)&8191,m=u[8]&255|(u[9]&255)<<8,this.r[4]=(E>>>4|m<<12)&255,this.r[5]=m>>>1&8190,R=u[10]&255|(u[11]&255)<<8,this.r[6]=(m>>>14|R<<2)&8191,W=u[12]&255|(u[13]&255)<<8,this.r[7]=(R>>>11|W<<5)&8065,ne=u[14]&255|(u[15]&255)<<8,this.r[8]=(W>>>8|ne<<8)&8191,this.r[9]=ne>>>5&127,this.pad[0]=u[16]&255|(u[17]&255)<<8,this.pad[1]=u[18]&255|(u[19]&255)<<8,this.pad[2]=u[20]&255|(u[21]&255)<<8,this.pad[3]=u[22]&255|(u[23]&255)<<8,this.pad[4]=u[24]&255|(u[25]&255)<<8,this.pad[5]=u[26]&255|(u[27]&255)<<8,this.pad[6]=u[28]&255|(u[29]&255)<<8,this.pad[7]=u[30]&255|(u[31]&255)<<8};v.prototype.blocks=function(u,g,A){for(var c=this.fin?0:2048,E,m,R,W,ne,he,fe,Xe,ce,ke,Re,Ue,Le,Ne,ve,Te,ue,Ee,ae,de=this.h[0],ge=this.h[1],oe=this.h[2],L=this.h[3],U=this.h[4],Y=this.h[5],K=this.h[6],G=this.h[7],z=this.h[8],ye=this.h[9],Oe=this.r[0],De=this.r[1],Pe=this.r[2],b=this.r[3],He=this.r[4],je=this.r[5],Ve=this.r[6],Qe=this.r[7],Ge=this.r[8],Ye=this.r[9];A>=16;)E=u[g+0]&255|(u[g+1]&255)<<8,de+=E&8191,m=u[g+2]&255|(u[g+3]&255)<<8,ge+=(E>>>13|m<<3)&8191,R=u[g+4]&255|(u[g+5]&255)<<8,oe+=(m>>>10|R<<6)&8191,W=u[g+6]&255|(u[g+7]&255)<<8,L+=(R>>>7|W<<9)&8191,ne=u[g+8]&255|(u[g+9]&255)<<8,U+=(W>>>4|ne<<12)&8191,Y+=ne>>>1&8191,he=u[g+10]&255|(u[g+11]&255)<<8,K+=(ne>>>14|he<<2)&8191,fe=u[g+12]&255|(u[g+13]&255)<<8,G+=(he>>>11|fe<<5)&8191,Xe=u[g+14]&255|(u[g+15]&255)<<8,z+=(fe>>>8|Xe<<8)&8191,ye+=Xe>>>5|c,ce=0,ke=ce,ke+=de*Oe,ke+=ge*(5*Ye),ke+=oe*(5*Ge),ke+=L*(5*Qe),ke+=U*(5*Ve),ce=ke>>>13,ke&=8191,ke+=Y*(5*je),ke+=K*(5*He),ke+=G*(5*b),ke+=z*(5*Pe),ke+=ye*(5*De),ce+=ke>>>13,ke&=8191,Re=ce,Re+=de*De,Re+=ge*Oe,Re+=oe*(5*Ye),Re+=L*(5*Ge),Re+=U*(5*Qe),ce=Re>>>13,Re&=8191,Re+=Y*(5*Ve),Re+=K*(5*je),Re+=G*(5*He),Re+=z*(5*b),Re+=ye*(5*Pe),ce+=Re>>>13,Re&=8191,Ue=ce,Ue+=de*Pe,Ue+=ge*De,Ue+=oe*Oe,Ue+=L*(5*Ye),Ue+=U*(5*Ge),ce=Ue>>>13,Ue&=8191,Ue+=Y*(5*Qe),Ue+=K*(5*Ve),Ue+=G*(5*je),Ue+=z*(5*He),Ue+=ye*(5*b),ce+=Ue>>>13,Ue&=8191,Le=ce,Le+=de*b,Le+=ge*Pe,Le+=oe*De,Le+=L*Oe,Le+=U*(5*Ye),ce=Le>>>13,Le&=8191,Le+=Y*(5*Ge),Le+=K*(5*Qe),Le+=G*(5*Ve),Le+=z*(5*je),Le+=ye*(5*He),ce+=Le>>>13,Le&=8191,Ne=ce,Ne+=de*He,Ne+=ge*b,Ne+=oe*Pe,Ne+=L*De,Ne+=U*Oe,ce=Ne>>>13,Ne&=8191,Ne+=Y*(5*Ye),Ne+=K*(5*Ge),Ne+=G*(5*Qe),Ne+=z*(5*Ve),Ne+=ye*(5*je),ce+=Ne>>>13,Ne&=8191,ve=ce,ve+=de*je,ve+=ge*He,ve+=oe*b,ve+=L*Pe,ve+=U*De,ce=ve>>>13,ve&=8191,ve+=Y*Oe,ve+=K*(5*Ye),ve+=G*(5*Ge),ve+=z*(5*Qe),ve+=ye*(5*Ve),ce+=ve>>>13,ve&=8191,Te=ce,Te+=de*Ve,Te+=ge*je,Te+=oe*He,Te+=L*b,Te+=U*Pe,ce=Te>>>13,Te&=8191,Te+=Y*De,Te+=K*Oe,Te+=G*(5*Ye),Te+=z*(5*Ge),Te+=ye*(5*Qe),ce+=Te>>>13,Te&=8191,ue=ce,ue+=de*Qe,ue+=ge*Ve,ue+=oe*je,ue+=L*He,ue+=U*b,ce=ue>>>13,ue&=8191,ue+=Y*Pe,ue+=K*De,ue+=G*Oe,ue+=z*(5*Ye),ue+=ye*(5*Ge),ce+=ue>>>13,ue&=8191,Ee=ce,Ee+=de*Ge,Ee+=ge*Qe,Ee+=oe*Ve,Ee+=L*je,Ee+=U*He,ce=Ee>>>13,Ee&=8191,Ee+=Y*b,Ee+=K*Pe,Ee+=G*De,Ee+=z*Oe,Ee+=ye*(5*Ye),ce+=Ee>>>13,Ee&=8191,ae=ce,ae+=de*Ye,ae+=ge*Ge,ae+=oe*Qe,ae+=L*Ve,ae+=U*je,ce=ae>>>13,ae&=8191,ae+=Y*He,ae+=K*b,ae+=G*Pe,ae+=z*De,ae+=ye*Oe,ce+=ae>>>13,ae&=8191,ce=(ce<<2)+ce|0,ce=ce+ke|0,ke=ce&8191,ce=ce>>>13,Re+=ce,de=ke,ge=Re,oe=Ue,L=Le,U=Ne,Y=ve,K=Te,G=ue,z=Ee,ye=ae,g+=16,A-=16;this.h[0]=de,this.h[1]=ge,this.h[2]=oe,this.h[3]=L,this.h[4]=U,this.h[5]=Y,this.h[6]=K,this.h[7]=G,this.h[8]=z,this.h[9]=ye},v.prototype.finish=function(u,g){var A=new Uint16Array(10),c,E,m,R;if(this.leftover){for(R=this.leftover,this.buffer[R++]=1;R<16;R++)this.buffer[R]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(c=this.h[1]>>>13,this.h[1]&=8191,R=2;R<10;R++)this.h[R]+=c,c=this.h[R]>>>13,this.h[R]&=8191;for(this.h[0]+=c*5,c=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=c,c=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=c,A[0]=this.h[0]+5,c=A[0]>>>13,A[0]&=8191,R=1;R<10;R++)A[R]=this.h[R]+c,c=A[R]>>>13,A[R]&=8191;for(A[9]-=8192,E=(c^1)-1,R=0;R<10;R++)A[R]&=E;for(E=~E,R=0;R<10;R++)this.h[R]=this.h[R]&E|A[R];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,m=this.h[0]+this.pad[0],this.h[0]=m&65535,R=1;R<8;R++)m=(this.h[R]+this.pad[R]|0)+(m>>>16)|0,this.h[R]=m&65535;u[g+0]=this.h[0]>>>0&255,u[g+1]=this.h[0]>>>8&255,u[g+2]=this.h[1]>>>0&255,u[g+3]=this.h[1]>>>8&255,u[g+4]=this.h[2]>>>0&255,u[g+5]=this.h[2]>>>8&255,u[g+6]=this.h[3]>>>0&255,u[g+7]=this.h[3]>>>8&255,u[g+8]=this.h[4]>>>0&255,u[g+9]=this.h[4]>>>8&255,u[g+10]=this.h[5]>>>0&255,u[g+11]=this.h[5]>>>8&255,u[g+12]=this.h[6]>>>0&255,u[g+13]=this.h[6]>>>8&255,u[g+14]=this.h[7]>>>0&255,u[g+15]=this.h[7]>>>8&255},v.prototype.update=function(u,g,A){var c,E;if(this.leftover){for(E=16-this.leftover,E>A&&(E=A),c=0;c<E;c++)this.buffer[this.leftover+c]=u[g+c];if(A-=E,g+=E,this.leftover+=E,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(A>=16&&(E=A-A%16,this.blocks(u,g,E),g+=E,A-=E),A){for(c=0;c<A;c++)this.buffer[this.leftover+c]=u[g+c];this.leftover+=A}};function M(u,g,A,c,E,m){var R=new v(m);return R.update(A,c,E),R.finish(u,g),0}function Q(u,g,A,c,E,m){var R=new Uint8Array(16);return M(R,0,A,c,E,m),I(u,g,R,0)}function re(u,g,A,c,E){var m;if(A<32)return-1;for(S(u,0,g,0,A,c,E),M(u,16,u,32,A-32,u),m=0;m<16;m++)u[m]=0;return 0}function J(u,g,A,c,E){var m,R=new Uint8Array(32);if(A<32||(y(R,0,32,c,E),Q(g,16,g,32,A-32,R)!==0))return-1;for(S(u,0,g,0,A,c,E),m=0;m<32;m++)u[m]=0;return 0}function j(u,g){var A;for(A=0;A<16;A++)u[A]=g[A]|0}function te(u){var g,A,c=1;for(g=0;g<16;g++)A=u[g]+c+65535,c=Math.floor(A/65536),u[g]=A-c*65536;u[0]+=c-1+37*(c-1)}function ie(u,g,A){for(var c,E=~(A-1),m=0;m<16;m++)c=E&(u[m]^g[m]),u[m]^=c,g[m]^=c}function T(u,g){var A,c,E,m=t(),R=t();for(A=0;A<16;A++)R[A]=g[A];for(te(R),te(R),te(R),c=0;c<2;c++){for(m[0]=R[0]-65517,A=1;A<15;A++)m[A]=R[A]-65535-(m[A-1]>>16&1),m[A-1]&=65535;m[15]=R[15]-32767-(m[14]>>16&1),E=m[15]>>16&1,m[14]&=65535,ie(R,m,1-E)}for(A=0;A<16;A++)u[2*A]=R[A]&255,u[2*A+1]=R[A]>>8}function F(u,g){var A=new Uint8Array(32),c=new Uint8Array(32);return T(A,u),T(c,g),k(A,0,c,0)}function H(u){var g=new Uint8Array(32);return T(g,u),g[0]&1}function $(u,g){var A;for(A=0;A<16;A++)u[A]=g[2*A]+(g[2*A+1]<<8);u[15]&=32767}function le(u,g,A){for(var c=0;c<16;c++)u[c]=g[c]+A[c]}function _e(u,g,A){for(var c=0;c<16;c++)u[c]=g[c]-A[c]}function Ae(u,g,A){var c,E,m=0,R=0,W=0,ne=0,he=0,fe=0,Xe=0,ce=0,ke=0,Re=0,Ue=0,Le=0,Ne=0,ve=0,Te=0,ue=0,Ee=0,ae=0,de=0,ge=0,oe=0,L=0,U=0,Y=0,K=0,G=0,z=0,ye=0,Oe=0,De=0,Pe=0,b=A[0],He=A[1],je=A[2],Ve=A[3],Qe=A[4],Ge=A[5],Ye=A[6],At=A[7],et=A[8],ut=A[9],lt=A[10],dt=A[11],pt=A[12],wt=A[13],mt=A[14],Bt=A[15];c=g[0],m+=c*b,R+=c*He,W+=c*je,ne+=c*Ve,he+=c*Qe,fe+=c*Ge,Xe+=c*Ye,ce+=c*At,ke+=c*et,Re+=c*ut,Ue+=c*lt,Le+=c*dt,Ne+=c*pt,ve+=c*wt,Te+=c*mt,ue+=c*Bt,c=g[1],R+=c*b,W+=c*He,ne+=c*je,he+=c*Ve,fe+=c*Qe,Xe+=c*Ge,ce+=c*Ye,ke+=c*At,Re+=c*et,Ue+=c*ut,Le+=c*lt,Ne+=c*dt,ve+=c*pt,Te+=c*wt,ue+=c*mt,Ee+=c*Bt,c=g[2],W+=c*b,ne+=c*He,he+=c*je,fe+=c*Ve,Xe+=c*Qe,ce+=c*Ge,ke+=c*Ye,Re+=c*At,Ue+=c*et,Le+=c*ut,Ne+=c*lt,ve+=c*dt,Te+=c*pt,ue+=c*wt,Ee+=c*mt,ae+=c*Bt,c=g[3],ne+=c*b,he+=c*He,fe+=c*je,Xe+=c*Ve,ce+=c*Qe,ke+=c*Ge,Re+=c*Ye,Ue+=c*At,Le+=c*et,Ne+=c*ut,ve+=c*lt,Te+=c*dt,ue+=c*pt,Ee+=c*wt,ae+=c*mt,de+=c*Bt,c=g[4],he+=c*b,fe+=c*He,Xe+=c*je,ce+=c*Ve,ke+=c*Qe,Re+=c*Ge,Ue+=c*Ye,Le+=c*At,Ne+=c*et,ve+=c*ut,Te+=c*lt,ue+=c*dt,Ee+=c*pt,ae+=c*wt,de+=c*mt,ge+=c*Bt,c=g[5],fe+=c*b,Xe+=c*He,ce+=c*je,ke+=c*Ve,Re+=c*Qe,Ue+=c*Ge,Le+=c*Ye,Ne+=c*At,ve+=c*et,Te+=c*ut,ue+=c*lt,Ee+=c*dt,ae+=c*pt,de+=c*wt,ge+=c*mt,oe+=c*Bt,c=g[6],Xe+=c*b,ce+=c*He,ke+=c*je,Re+=c*Ve,Ue+=c*Qe,Le+=c*Ge,Ne+=c*Ye,ve+=c*At,Te+=c*et,ue+=c*ut,Ee+=c*lt,ae+=c*dt,de+=c*pt,ge+=c*wt,oe+=c*mt,L+=c*Bt,c=g[7],ce+=c*b,ke+=c*He,Re+=c*je,Ue+=c*Ve,Le+=c*Qe,Ne+=c*Ge,ve+=c*Ye,Te+=c*At,ue+=c*et,Ee+=c*ut,ae+=c*lt,de+=c*dt,ge+=c*pt,oe+=c*wt,L+=c*mt,U+=c*Bt,c=g[8],ke+=c*b,Re+=c*He,Ue+=c*je,Le+=c*Ve,Ne+=c*Qe,ve+=c*Ge,Te+=c*Ye,ue+=c*At,Ee+=c*et,ae+=c*ut,de+=c*lt,ge+=c*dt,oe+=c*pt,L+=c*wt,U+=c*mt,Y+=c*Bt,c=g[9],Re+=c*b,Ue+=c*He,Le+=c*je,Ne+=c*Ve,ve+=c*Qe,Te+=c*Ge,ue+=c*Ye,Ee+=c*At,ae+=c*et,de+=c*ut,ge+=c*lt,oe+=c*dt,L+=c*pt,U+=c*wt,Y+=c*mt,K+=c*Bt,c=g[10],Ue+=c*b,Le+=c*He,Ne+=c*je,ve+=c*Ve,Te+=c*Qe,ue+=c*Ge,Ee+=c*Ye,ae+=c*At,de+=c*et,ge+=c*ut,oe+=c*lt,L+=c*dt,U+=c*pt,Y+=c*wt,K+=c*mt,G+=c*Bt,c=g[11],Le+=c*b,Ne+=c*He,ve+=c*je,Te+=c*Ve,ue+=c*Qe,Ee+=c*Ge,ae+=c*Ye,de+=c*At,ge+=c*et,oe+=c*ut,L+=c*lt,U+=c*dt,Y+=c*pt,K+=c*wt,G+=c*mt,z+=c*Bt,c=g[12],Ne+=c*b,ve+=c*He,Te+=c*je,ue+=c*Ve,Ee+=c*Qe,ae+=c*Ge,de+=c*Ye,ge+=c*At,oe+=c*et,L+=c*ut,U+=c*lt,Y+=c*dt,K+=c*pt,G+=c*wt,z+=c*mt,ye+=c*Bt,c=g[13],ve+=c*b,Te+=c*He,ue+=c*je,Ee+=c*Ve,ae+=c*Qe,de+=c*Ge,ge+=c*Ye,oe+=c*At,L+=c*et,U+=c*ut,Y+=c*lt,K+=c*dt,G+=c*pt,z+=c*wt,ye+=c*mt,Oe+=c*Bt,c=g[14],Te+=c*b,ue+=c*He,Ee+=c*je,ae+=c*Ve,de+=c*Qe,ge+=c*Ge,oe+=c*Ye,L+=c*At,U+=c*et,Y+=c*ut,K+=c*lt,G+=c*dt,z+=c*pt,ye+=c*wt,Oe+=c*mt,De+=c*Bt,c=g[15],ue+=c*b,Ee+=c*He,ae+=c*je,de+=c*Ve,ge+=c*Qe,oe+=c*Ge,L+=c*Ye,U+=c*At,Y+=c*et,K+=c*ut,G+=c*lt,z+=c*dt,ye+=c*pt,Oe+=c*wt,De+=c*mt,Pe+=c*Bt,m+=38*Ee,R+=38*ae,W+=38*de,ne+=38*ge,he+=38*oe,fe+=38*L,Xe+=38*U,ce+=38*Y,ke+=38*K,Re+=38*G,Ue+=38*z,Le+=38*ye,Ne+=38*Oe,ve+=38*De,Te+=38*Pe,E=1,c=m+E+65535,E=Math.floor(c/65536),m=c-E*65536,c=R+E+65535,E=Math.floor(c/65536),R=c-E*65536,c=W+E+65535,E=Math.floor(c/65536),W=c-E*65536,c=ne+E+65535,E=Math.floor(c/65536),ne=c-E*65536,c=he+E+65535,E=Math.floor(c/65536),he=c-E*65536,c=fe+E+65535,E=Math.floor(c/65536),fe=c-E*65536,c=Xe+E+65535,E=Math.floor(c/65536),Xe=c-E*65536,c=ce+E+65535,E=Math.floor(c/65536),ce=c-E*65536,c=ke+E+65535,E=Math.floor(c/65536),ke=c-E*65536,c=Re+E+65535,E=Math.floor(c/65536),Re=c-E*65536,c=Ue+E+65535,E=Math.floor(c/65536),Ue=c-E*65536,c=Le+E+65535,E=Math.floor(c/65536),Le=c-E*65536,c=Ne+E+65535,E=Math.floor(c/65536),Ne=c-E*65536,c=ve+E+65535,E=Math.floor(c/65536),ve=c-E*65536,c=Te+E+65535,E=Math.floor(c/65536),Te=c-E*65536,c=ue+E+65535,E=Math.floor(c/65536),ue=c-E*65536,m+=E-1+37*(E-1),E=1,c=m+E+65535,E=Math.floor(c/65536),m=c-E*65536,c=R+E+65535,E=Math.floor(c/65536),R=c-E*65536,c=W+E+65535,E=Math.floor(c/65536),W=c-E*65536,c=ne+E+65535,E=Math.floor(c/65536),ne=c-E*65536,c=he+E+65535,E=Math.floor(c/65536),he=c-E*65536,c=fe+E+65535,E=Math.floor(c/65536),fe=c-E*65536,c=Xe+E+65535,E=Math.floor(c/65536),Xe=c-E*65536,c=ce+E+65535,E=Math.floor(c/65536),ce=c-E*65536,c=ke+E+65535,E=Math.floor(c/65536),ke=c-E*65536,c=Re+E+65535,E=Math.floor(c/65536),Re=c-E*65536,c=Ue+E+65535,E=Math.floor(c/65536),Ue=c-E*65536,c=Le+E+65535,E=Math.floor(c/65536),Le=c-E*65536,c=Ne+E+65535,E=Math.floor(c/65536),Ne=c-E*65536,c=ve+E+65535,E=Math.floor(c/65536),ve=c-E*65536,c=Te+E+65535,E=Math.floor(c/65536),Te=c-E*65536,c=ue+E+65535,E=Math.floor(c/65536),ue=c-E*65536,m+=E-1+37*(E-1),u[0]=m,u[1]=R,u[2]=W,u[3]=ne,u[4]=he,u[5]=fe,u[6]=Xe,u[7]=ce,u[8]=ke,u[9]=Re,u[10]=Ue,u[11]=Le,u[12]=Ne,u[13]=ve,u[14]=Te,u[15]=ue}function st(u,g){Ae(u,g,g)}function St(u,g){var A=t(),c;for(c=0;c<16;c++)A[c]=g[c];for(c=253;c>=0;c--)st(A,A),c!==2&&c!==4&&Ae(A,A,g);for(c=0;c<16;c++)u[c]=A[c]}function nr(u,g){var A=t(),c;for(c=0;c<16;c++)A[c]=g[c];for(c=250;c>=0;c--)st(A,A),c!==1&&Ae(A,A,g);for(c=0;c<16;c++)u[c]=A[c]}function kn(u,g,A){var c=new Uint8Array(32),E=new Float64Array(80),m,R,W=t(),ne=t(),he=t(),fe=t(),Xe=t(),ce=t();for(R=0;R<31;R++)c[R]=g[R];for(c[31]=g[31]&127|64,c[0]&=248,$(E,A),R=0;R<16;R++)ne[R]=E[R],fe[R]=W[R]=he[R]=0;for(W[0]=fe[0]=1,R=254;R>=0;--R)m=c[R>>>3]>>>(R&7)&1,ie(W,ne,m),ie(he,fe,m),le(Xe,W,he),_e(W,W,he),le(he,ne,fe),_e(ne,ne,fe),st(fe,Xe),st(ce,W),Ae(W,he,W),Ae(he,ne,Xe),le(Xe,W,he),_e(W,W,he),st(ne,W),_e(he,fe,ce),Ae(W,he,f),le(W,W,fe),Ae(he,he,W),Ae(W,fe,ce),Ae(fe,ne,E),st(ne,Xe),ie(W,ne,m),ie(he,fe,m);for(R=0;R<16;R++)E[R+16]=W[R],E[R+32]=he[R],E[R+48]=ne[R],E[R+64]=fe[R];var ke=E.subarray(32),Re=E.subarray(16);return St(ke,ke),Ae(Re,Re,ke),T(u,Re),0}function Rn(u,g){return kn(u,g,i)}function Jt(u,g){return e(g,32),Rn(u,g)}function Nn(u,g,A){var c=new Uint8Array(32);return kn(c,A,g),O(u,r,c,V)}var rr=re,Qr=J;function ir(u,g,A,c,E,m){var R=new Uint8Array(32);return Nn(R,E,m),rr(u,g,A,c,R)}function Tn(u,g,A,c,E,m){var R=new Uint8Array(32);return Nn(R,E,m),Qr(u,g,A,c,R)}var vn=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function q(u,g,A,c){for(var E=new Int32Array(16),m=new Int32Array(16),R,W,ne,he,fe,Xe,ce,ke,Re,Ue,Le,Ne,ve,Te,ue,Ee,ae,de,ge,oe,L,U,Y,K,G,z,ye=u[0],Oe=u[1],De=u[2],Pe=u[3],b=u[4],He=u[5],je=u[6],Ve=u[7],Qe=g[0],Ge=g[1],Ye=g[2],At=g[3],et=g[4],ut=g[5],lt=g[6],dt=g[7],pt=0;c>=128;){for(ge=0;ge<16;ge++)oe=8*ge+pt,E[ge]=A[oe+0]<<24|A[oe+1]<<16|A[oe+2]<<8|A[oe+3],m[ge]=A[oe+4]<<24|A[oe+5]<<16|A[oe+6]<<8|A[oe+7];for(ge=0;ge<80;ge++)if(R=ye,W=Oe,ne=De,he=Pe,fe=b,Xe=He,ce=je,ke=Ve,Re=Qe,Ue=Ge,Le=Ye,Ne=At,ve=et,Te=ut,ue=lt,Ee=dt,L=Ve,U=dt,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=(b>>>14|et<<18)^(b>>>18|et<<14)^(et>>>9|b<<23),U=(et>>>14|b<<18)^(et>>>18|b<<14)^(b>>>9|et<<23),Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,L=b&He^~b&je,U=et&ut^~et&lt,Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,L=vn[ge*2],U=vn[ge*2+1],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,L=E[ge%16],U=m[ge%16],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,ae=G&65535|z<<16,de=Y&65535|K<<16,L=ae,U=de,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=(ye>>>28|Qe<<4)^(Qe>>>2|ye<<30)^(Qe>>>7|ye<<25),U=(Qe>>>28|ye<<4)^(ye>>>2|Qe<<30)^(ye>>>7|Qe<<25),Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,L=ye&Oe^ye&De^Oe&De,U=Qe&Ge^Qe&Ye^Ge&Ye,Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,ke=G&65535|z<<16,Ee=Y&65535|K<<16,L=he,U=Ne,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=ae,U=de,Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,he=G&65535|z<<16,Ne=Y&65535|K<<16,Oe=R,De=W,Pe=ne,b=he,He=fe,je=Xe,Ve=ce,ye=ke,Ge=Re,Ye=Ue,At=Le,et=Ne,ut=ve,lt=Te,dt=ue,Qe=Ee,ge%16===15)for(oe=0;oe<16;oe++)L=E[oe],U=m[oe],Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=E[(oe+9)%16],U=m[(oe+9)%16],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,ae=E[(oe+1)%16],de=m[(oe+1)%16],L=(ae>>>1|de<<31)^(ae>>>8|de<<24)^ae>>>7,U=(de>>>1|ae<<31)^(de>>>8|ae<<24)^(de>>>7|ae<<25),Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,ae=E[(oe+14)%16],de=m[(oe+14)%16],L=(ae>>>19|de<<13)^(de>>>29|ae<<3)^ae>>>6,U=(de>>>19|ae<<13)^(ae>>>29|de<<3)^(de>>>6|ae<<26),Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,E[oe]=G&65535|z<<16,m[oe]=Y&65535|K<<16;L=ye,U=Qe,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=u[0],U=g[0],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,u[0]=ye=G&65535|z<<16,g[0]=Qe=Y&65535|K<<16,L=Oe,U=Ge,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=u[1],U=g[1],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,u[1]=Oe=G&65535|z<<16,g[1]=Ge=Y&65535|K<<16,L=De,U=Ye,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=u[2],U=g[2],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,u[2]=De=G&65535|z<<16,g[2]=Ye=Y&65535|K<<16,L=Pe,U=At,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=u[3],U=g[3],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,u[3]=Pe=G&65535|z<<16,g[3]=At=Y&65535|K<<16,L=b,U=et,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=u[4],U=g[4],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,u[4]=b=G&65535|z<<16,g[4]=et=Y&65535|K<<16,L=He,U=ut,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=u[5],U=g[5],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,u[5]=He=G&65535|z<<16,g[5]=ut=Y&65535|K<<16,L=je,U=lt,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=u[6],U=g[6],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,u[6]=je=G&65535|z<<16,g[6]=lt=Y&65535|K<<16,L=Ve,U=dt,Y=U&65535,K=U>>>16,G=L&65535,z=L>>>16,L=u[7],U=g[7],Y+=U&65535,K+=U>>>16,G+=L&65535,z+=L>>>16,K+=Y>>>16,G+=K>>>16,z+=G>>>16,u[7]=Ve=G&65535|z<<16,g[7]=dt=Y&65535|K<<16,pt+=128,c-=128}return c}function se(u,g,A){var c=new Int32Array(8),E=new Int32Array(8),m=new Uint8Array(256),R,W=A;for(c[0]=1779033703,c[1]=3144134277,c[2]=1013904242,c[3]=2773480762,c[4]=1359893119,c[5]=2600822924,c[6]=528734635,c[7]=1541459225,E[0]=4089235720,E[1]=2227873595,E[2]=4271175723,E[3]=1595750129,E[4]=2917565137,E[5]=725511199,E[6]=4215389547,E[7]=327033209,q(c,E,g,A),A%=128,R=0;R<A;R++)m[R]=g[W-A+R];for(m[A]=128,A=256-128*(A<112?1:0),m[A-9]=0,p(m,A-8,W/536870912|0,W<<3),q(c,E,m,A),R=0;R<8;R++)p(u,8*R,c[R],E[R]);return 0}function pe(u,g){var A=t(),c=t(),E=t(),m=t(),R=t(),W=t(),ne=t(),he=t(),fe=t();_e(A,u[1],u[0]),_e(fe,g[1],g[0]),Ae(A,A,fe),le(c,u[0],u[1]),le(fe,g[0],g[1]),Ae(c,c,fe),Ae(E,u[3],g[3]),Ae(E,E,h),Ae(m,u[2],g[2]),le(m,m,m),_e(R,c,A),_e(W,m,E),le(ne,m,E),le(he,c,A),Ae(u[0],R,W),Ae(u[1],he,ne),Ae(u[2],ne,W),Ae(u[3],R,he)}function Ce(u,g,A){var c;for(c=0;c<4;c++)ie(u[c],g[c],A)}function Ke(u,g){var A=t(),c=t(),E=t();St(E,g[2]),Ae(A,g[0],E),Ae(c,g[1],E),T(u,c),u[31]^=H(A)<<7}function gt(u,g,A){var c,E;for(j(u[0],s),j(u[1],o),j(u[2],o),j(u[3],s),E=255;E>=0;--E)c=A[E/8|0]>>(E&7)&1,Ce(u,g,c),pe(g,u),pe(u,u),Ce(u,g,c)}function Xt(u,g){var A=[t(),t(),t(),t()];j(A[0],d),j(A[1],l),j(A[2],o),Ae(A[3],d,l),gt(u,A,g)}function Ot(u,g,A){var c=new Uint8Array(64),E=[t(),t(),t(),t()],m;for(A||e(g,32),se(c,g,32),c[0]&=248,c[31]&=127,c[31]|=64,Xt(E,c),Ke(u,E),m=0;m<32;m++)g[m+32]=u[m];return 0}var Ln=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Je(u,g){var A,c,E,m;for(c=63;c>=32;--c){for(A=0,E=c-32,m=c-12;E<m;++E)g[E]+=A-16*g[c]*Ln[E-(c-32)],A=g[E]+128>>8,g[E]-=A*256;g[E]+=A,g[c]=0}for(A=0,E=0;E<32;E++)g[E]+=A-(g[31]>>4)*Ln[E],A=g[E]>>8,g[E]&=255;for(E=0;E<32;E++)g[E]-=A*Ln[E];for(c=0;c<32;c++)g[c+1]+=g[c]>>8,u[c]=g[c]&255}function bt(u){var g=new Float64Array(64),A;for(A=0;A<64;A++)g[A]=u[A];for(A=0;A<64;A++)u[A]=0;Je(u,g)}function Et(u,g,A,c){var E=new Uint8Array(64),m=new Uint8Array(64),R=new Uint8Array(64),W,ne,he=new Float64Array(64),fe=[t(),t(),t(),t()];se(E,c,32),E[0]&=248,E[31]&=127,E[31]|=64;var Xe=A+64;for(W=0;W<A;W++)u[64+W]=g[W];for(W=0;W<32;W++)u[32+W]=E[32+W];for(se(R,u.subarray(32),A+32),bt(R),Xt(fe,R),Ke(u,fe),W=32;W<64;W++)u[W]=c[W];for(se(m,u,A+64),bt(m),W=0;W<64;W++)he[W]=0;for(W=0;W<32;W++)he[W]=R[W];for(W=0;W<32;W++)for(ne=0;ne<32;ne++)he[W+ne]+=m[W]*E[ne];return Je(u.subarray(32),he),Xe}function ct(u,g){var A=t(),c=t(),E=t(),m=t(),R=t(),W=t(),ne=t();return j(u[2],o),$(u[1],g),st(E,u[1]),Ae(m,E,a),_e(E,E,u[2]),le(m,u[2],m),st(R,m),st(W,R),Ae(ne,W,R),Ae(A,ne,E),Ae(A,A,m),nr(A,A),Ae(A,A,E),Ae(A,A,m),Ae(A,A,m),Ae(u[0],A,m),st(c,u[0]),Ae(c,c,m),F(c,E)&&Ae(u[0],u[0],_),st(c,u[0]),Ae(c,c,m),F(c,E)?-1:(H(u[0])===g[31]>>7&&_e(u[0],s,u[0]),Ae(u[3],u[0],u[1]),0)}function rt(u,g,A,c){var E,m,R=new Uint8Array(32),W=new Uint8Array(64),ne=[t(),t(),t(),t()],he=[t(),t(),t(),t()];if(m=-1,A<64||ct(he,c))return-1;for(E=0;E<A;E++)u[E]=g[E];for(E=0;E<32;E++)u[E+32]=c[E];if(se(W,u,A),bt(W),gt(ne,he,W),Xt(he,g.subarray(32)),pe(ne,he),Ke(R,ne),A-=64,k(g,0,R,0)){for(E=0;E<A;E++)u[E]=0;return-1}for(E=0;E<A;E++)u[E]=g[E+64];return m=A,m}var Ht=32,ht=24,In=32,Un=16,sr=32,Hr=32,or=32,fr=32,Oi=32,ko=ht,ac=In,cc=Un,Zt=64,xn=32,On=64,Pi=32,Di=64;n.lowlevel={crypto_core_hsalsa20:O,crypto_stream_xor:S,crypto_stream:y,crypto_stream_salsa20_xor:ee,crypto_stream_salsa20:X,crypto_onetimeauth:M,crypto_onetimeauth_verify:Q,crypto_verify_16:I,crypto_verify_32:k,crypto_secretbox:re,crypto_secretbox_open:J,crypto_scalarmult:kn,crypto_scalarmult_base:Rn,crypto_box_beforenm:Nn,crypto_box_afternm:rr,crypto_box:ir,crypto_box_open:Tn,crypto_box_keypair:Jt,crypto_hash:se,crypto_sign:Et,crypto_sign_keypair:Ot,crypto_sign_open:rt,crypto_secretbox_KEYBYTES:Ht,crypto_secretbox_NONCEBYTES:ht,crypto_secretbox_ZEROBYTES:In,crypto_secretbox_BOXZEROBYTES:Un,crypto_scalarmult_BYTES:sr,crypto_scalarmult_SCALARBYTES:Hr,crypto_box_PUBLICKEYBYTES:or,crypto_box_SECRETKEYBYTES:fr,crypto_box_BEFORENMBYTES:Oi,crypto_box_NONCEBYTES:ko,crypto_box_ZEROBYTES:ac,crypto_box_BOXZEROBYTES:cc,crypto_sign_BYTES:Zt,crypto_sign_PUBLICKEYBYTES:xn,crypto_sign_SECRETKEYBYTES:On,crypto_sign_SEEDBYTES:Pi,crypto_hash_BYTES:Di};function Ro(u,g){if(u.length!==Ht)throw new Error("bad key size");if(g.length!==ht)throw new Error("bad nonce size")}function hc(u,g){if(u.length!==or)throw new Error("bad public key size");if(g.length!==fr)throw new Error("bad secret key size")}function Pt(){var u,g;for(g=0;g<arguments.length;g++)if((u=Object.prototype.toString.call(arguments[g]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+u+", use Uint8Array")}function No(u){for(var g=0;g<u.length;g++)u[g]=0}n.util||(n.util={},n.util.decodeUTF8=n.util.encodeUTF8=n.util.encodeBase64=n.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),n.randomBytes=function(u){var g=new Uint8Array(u);return e(g,u),g},n.secretbox=function(u,g,A){Pt(u,g,A),Ro(A,g);for(var c=new Uint8Array(In+u.length),E=new Uint8Array(c.length),m=0;m<u.length;m++)c[m+In]=u[m];return re(E,c,c.length,g,A),E.subarray(Un)},n.secretbox.open=function(u,g,A){Pt(u,g,A),Ro(A,g);for(var c=new Uint8Array(Un+u.length),E=new Uint8Array(c.length),m=0;m<u.length;m++)c[m+Un]=u[m];return c.length<32||J(E,c,c.length,g,A)!==0?!1:E.subarray(In)},n.secretbox.keyLength=Ht,n.secretbox.nonceLength=ht,n.secretbox.overheadLength=Un,n.scalarMult=function(u,g){if(Pt(u,g),u.length!==Hr)throw new Error("bad n size");if(g.length!==sr)throw new Error("bad p size");var A=new Uint8Array(sr);return kn(A,u,g),A},n.scalarMult.base=function(u){if(Pt(u),u.length!==Hr)throw new Error("bad n size");var g=new Uint8Array(sr);return Rn(g,u),g},n.scalarMult.scalarLength=Hr,n.scalarMult.groupElementLength=sr,n.box=function(u,g,A,c){var E=n.box.before(A,c);return n.secretbox(u,g,E)},n.box.before=function(u,g){Pt(u,g),hc(u,g);var A=new Uint8Array(Oi);return Nn(A,u,g),A},n.box.after=n.secretbox,n.box.open=function(u,g,A,c){var E=n.box.before(A,c);return n.secretbox.open(u,g,E)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var u=new Uint8Array(or),g=new Uint8Array(fr);return Jt(u,g),{publicKey:u,secretKey:g}},n.box.keyPair.fromSecretKey=function(u){if(Pt(u),u.length!==fr)throw new Error("bad secret key size");var g=new Uint8Array(or);return Rn(g,u),{publicKey:g,secretKey:new Uint8Array(u)}},n.box.publicKeyLength=or,n.box.secretKeyLength=fr,n.box.sharedKeyLength=Oi,n.box.nonceLength=ko,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(u,g){if(Pt(u,g),g.length!==On)throw new Error("bad secret key size");var A=new Uint8Array(Zt+u.length);return Et(A,u,u.length,g),A},n.sign.open=function(u,g){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(Pt(u,g),g.length!==xn)throw new Error("bad public key size");var A=new Uint8Array(u.length),c=rt(A,u,u.length,g);if(c<0)return null;for(var E=new Uint8Array(c),m=0;m<E.length;m++)E[m]=A[m];return E},n.sign.detached=function(u,g){for(var A=n.sign(u,g),c=new Uint8Array(Zt),E=0;E<c.length;E++)c[E]=A[E];return c},n.sign.detached.verify=function(u,g,A){if(Pt(u,g,A),g.length!==Zt)throw new Error("bad signature size");if(A.length!==xn)throw new Error("bad public key size");var c=new Uint8Array(Zt+u.length),E=new Uint8Array(Zt+u.length),m;for(m=0;m<Zt;m++)c[m]=g[m];for(m=0;m<u.length;m++)c[m+Zt]=u[m];return rt(E,c,c.length,A)>=0},n.sign.keyPair=function(){var u=new Uint8Array(xn),g=new Uint8Array(On);return Ot(u,g),{publicKey:u,secretKey:g}},n.sign.keyPair.fromSecretKey=function(u){if(Pt(u),u.length!==On)throw new Error("bad secret key size");for(var g=new Uint8Array(xn),A=0;A<g.length;A++)g[A]=u[32+A];return{publicKey:g,secretKey:new Uint8Array(u)}},n.sign.keyPair.fromSeed=function(u){if(Pt(u),u.length!==Pi)throw new Error("bad seed size");for(var g=new Uint8Array(xn),A=new Uint8Array(On),c=0;c<32;c++)A[c]=u[c];return Ot(g,A,!0),{publicKey:g,secretKey:A}},n.sign.publicKeyLength=xn,n.sign.secretKeyLength=On,n.sign.seedLength=Pi,n.sign.signatureLength=Zt,n.hash=function(u){Pt(u);var g=new Uint8Array(Di);return se(g,u,u.length),g},n.hash.hashLength=Di,n.verify=function(u,g){return Pt(u,g),u.length===0||g.length===0||u.length!==g.length?!1:x(u,0,g,0,u.length)===0},n.setPRNG=function(u){e=u},(function(){var u=typeof self<"u"?self.crypto||self.msCrypto:null;if(u&&u.getRandomValues){var g=65536;n.setPRNG(function(A,c){var E,m=new Uint8Array(c);for(E=0;E<c;E+=g)u.getRandomValues(m.subarray(E,E+Math.min(c-E,g)));for(E=0;E<c;E++)A[E]=m[E];No(m)})}else typeof require<"u"&&(u=require("crypto"),u&&u.randomBytes&&n.setPRNG(function(A,c){var E,m=u.randomBytes(c);for(E=0;E<c;E++)A[E]=m[E];No(m)}))})()})(typeof jr<"u"&&jr.exports?jr.exports:self.nacl=self.nacl||{})});var Gi=Ze((Bd,Ko)=>{"use strict";var qi=qo().lowlevel.crypto_hash,en=0,Sn=function(){this.S=[new Uint32Array([3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946]),new Uint32Array([1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055]),new Uint32Array([3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504]),new Uint32Array([976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462])],this.P=new Uint32Array([608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731])};function zr(n,t,e){return(n[0][t[e+3]]+n[1][t[e+2]]^n[2][t[e+1]])+n[3][t[e]]}Sn.prototype.encipher=function(n,t){t===void 0&&(t=new Uint8Array(n.buffer),n.byteOffset!==0&&(t=t.subarray(n.byteOffset))),n[0]^=this.P[0];for(var e=1;e<16;e+=2)n[1]^=zr(this.S,t,0)^this.P[e],n[0]^=zr(this.S,t,4)^this.P[e+1];var r=n[0];n[0]=n[1]^this.P[17],n[1]=r};Sn.prototype.decipher=function(n){var t=new Uint8Array(n.buffer);n.byteOffset!==0&&(t=t.subarray(n.byteOffset)),n[0]^=this.P[17];for(var e=16;e>0;e-=2)n[1]^=zr(this.S,t,0)^this.P[e],n[0]^=zr(this.S,t,4)^this.P[e-1];var r=n[0];n[0]=n[1]^this.P[0],n[1]=r};function yn(n,t){var e,r=0;for(e=0;e<4;e++,en++)en>=t&&(en=0),r=r<<8|n[en];return r}Sn.prototype.expand0state=function(n,t){var e=new Uint32Array(2),r,i,s=new Uint8Array(e.buffer);for(r=0,en=0;r<18;r++)this.P[r]^=yn(n,t);for(en=0,r=0;r<18;r+=2)this.encipher(e,s),this.P[r]=e[0],this.P[r+1]=e[1];for(r=0;r<4;r++)for(i=0;i<256;i+=2)this.encipher(e,s),this.S[r][i]=e[0],this.S[r][i+1]=e[1]};Sn.prototype.expandstate=function(n,t,e,r){var i=new Uint32Array(2),s,o;for(s=0,en=0;s<18;s++)this.P[s]^=yn(e,r);for(s=0,en=0;s<18;s+=2)i[0]^=yn(n,t),i[1]^=yn(n,t),this.encipher(i),this.P[s]=i[0],this.P[s+1]=i[1];for(s=0;s<4;s++)for(o=0;o<256;o+=2)i[0]^=yn(n,t),i[1]^=yn(n,t),this.encipher(i),this.S[s][o]=i[0],this.S[s][o+1]=i[1];en=0};Sn.prototype.enc=function(n,t){for(var e=0;e<t;e++)this.encipher(n.subarray(e*2))};Sn.prototype.dec=function(n,t){for(var e=0;e<t;e++)this.decipher(n.subarray(e*2))};var Vr=8,Ki=32;function Wi(n,t,e){var r=new Sn,i=new Uint32Array(Vr),s,o=new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,105,116,101]);for(r.expandstate(t,64,n,64),s=0;s<64;s++)r.expand0state(t,64),r.expand0state(n,64);for(s=0;s<Vr;s++)i[s]=yn(o,o.byteLength);for(s=0;s<64;s++)r.enc(i,i.byteLength/8);for(s=0;s<Vr;s++)e[4*s+3]=i[s]>>>24,e[4*s+2]=i[s]>>>16,e[4*s+1]=i[s]>>>8,e[4*s+0]=i[s]}function Bc(n,t,e,r,i,s,o){var f=new Uint8Array(64),a=new Uint8Array(64),h=new Uint8Array(Ki),d=new Uint8Array(Ki),l=new Uint8Array(r+4),_,p,x,I,k,N,D=s;if(o<1||t===0||r===0||s===0||s>h.byteLength*h.byteLength||r>1<<20)return-1;for(I=Math.floor((s+h.byteLength-1)/h.byteLength),x=Math.floor((s+I-1)/I),_=0;_<r;_++)l[_]=e[_];for(qi(f,n,t),N=1;s>0;N++){for(l[r+0]=N>>>24,l[r+1]=N>>>16,l[r+2]=N>>>8,l[r+3]=N,qi(a,l,r+4),Wi(f,a,d),_=h.byteLength;_--;)h[_]=d[_];for(_=1;_<o;_++)for(qi(a,d,d.byteLength),Wi(f,a,d),p=0;p<h.byteLength;p++)h[p]^=d[p];for(x=Math.min(x,s),_=0;_<x&&(k=_*I+(N-1),!(k>=D));_++)i[k]=h[_];s-=_}return 0}Ko.exports={BLOCKS:Vr,HASHSIZE:Ki,hash:Wi,pbkdf:Bc}});var nn=Ze((Cd,Zr)=>{"use strict";var tn=require("crypto"),Fn;try{Fn=require("cpu-features")()}catch{}var{bindingAvailable:Wo,CIPHER_INFO:Cc,MAC_INFO:kc}=un(),Go=(()=>{if(typeof tn.sign=="function"&&typeof tn.verify=="function"){let n=`-----BEGIN PRIVATE KEY-----\r
9
+ MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
10
+ -----END PRIVATE KEY-----`,t=Buffer.from("a"),e,r;try{e=tn.sign(null,t,n),r=tn.verify(null,t,n,e)}catch{}return Buffer.isBuffer(e)&&e.length===64&&r===!0}return!1})(),Yo=typeof tn.diffieHellman=="function"&&typeof tn.generateKeyPairSync=="function"&&typeof tn.createPublicKey=="function",Jr=["ecdh-sha2-nistp256","ecdh-sha2-nistp384","ecdh-sha2-nistp521","diffie-hellman-group-exchange-sha256","diffie-hellman-group14-sha256","diffie-hellman-group15-sha512","diffie-hellman-group16-sha512","diffie-hellman-group17-sha512","diffie-hellman-group18-sha512"];Yo&&(Jr.unshift("curve25519-sha256"),Jr.unshift("curve25519-sha256@libssh.org"));var Rc=Jr.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),Yi=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];Go&&Yi.unshift("ssh-ed25519");var Nc=Yi.concat(["ssh-dss"]),$o=(()=>{let n=tn.getCiphers();return t=>n.includes(Cc[t].sslName)})(),hn=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Fn&&Fn.flags&&!Fn.flags.aes?Wo?hn.unshift("chacha20-poly1305@openssh.com"):hn.push("chacha20-poly1305@openssh.com"):Wo&&Fn&&Fn.arch==="x86"?hn.splice(4,0,"chacha20-poly1305@openssh.com"):hn.push("chacha20-poly1305@openssh.com");hn=hn.filter($o);var Tc=hn.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter($o)),Xo=(()=>{let n=tn.getHashes();return t=>n.includes(kc[t].sslName)})(),jo=["hmac-sha2-256-etm@openssh.com","hmac-sha2-512-etm@openssh.com","hmac-sha1-etm@openssh.com","hmac-sha2-256","hmac-sha2-512","hmac-sha1"].filter(Xo),vc=jo.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(Xo)),Vo=["none","zlib@openssh.com","zlib"],Lc=Vo.concat([]),Hn={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};Zr.exports={MESSAGE:{DISCONNECT:1,IGNORE:2,UNIMPLEMENTED:3,DEBUG:4,SERVICE_REQUEST:5,SERVICE_ACCEPT:6,EXT_INFO:7,KEXINIT:20,NEWKEYS:21,KEXDH_INIT:30,KEXDH_REPLY:31,KEXDH_GEX_GROUP:31,KEXDH_GEX_INIT:32,KEXDH_GEX_REPLY:33,KEXDH_GEX_REQUEST:34,KEXECDH_INIT:30,KEXECDH_REPLY:31,USERAUTH_REQUEST:50,USERAUTH_FAILURE:51,USERAUTH_SUCCESS:52,USERAUTH_BANNER:53,USERAUTH_PASSWD_CHANGEREQ:60,USERAUTH_PK_OK:60,USERAUTH_INFO_REQUEST:60,USERAUTH_INFO_RESPONSE:61,GLOBAL_REQUEST:80,REQUEST_SUCCESS:81,REQUEST_FAILURE:82,CHANNEL_OPEN:90,CHANNEL_OPEN_CONFIRMATION:91,CHANNEL_OPEN_FAILURE:92,CHANNEL_WINDOW_ADJUST:93,CHANNEL_DATA:94,CHANNEL_EXTENDED_DATA:95,CHANNEL_EOF:96,CHANNEL_CLOSE:97,CHANNEL_REQUEST:98,CHANNEL_SUCCESS:99,CHANNEL_FAILURE:100},DISCONNECT_REASON:{HOST_NOT_ALLOWED_TO_CONNECT:1,PROTOCOL_ERROR:2,KEY_EXCHANGE_FAILED:3,RESERVED:4,MAC_ERROR:5,COMPRESSION_ERROR:6,SERVICE_NOT_AVAILABLE:7,PROTOCOL_VERSION_NOT_SUPPORTED:8,HOST_KEY_NOT_VERIFIABLE:9,CONNECTION_LOST:10,BY_APPLICATION:11,TOO_MANY_CONNECTIONS:12,AUTH_CANCELED_BY_USER:13,NO_MORE_AUTH_METHODS_AVAILABLE:14,ILLEGAL_USER_NAME:15},DISCONNECT_REASON_STR:void 0,CHANNEL_OPEN_FAILURE:{ADMINISTRATIVELY_PROHIBITED:1,CONNECT_FAILED:2,UNKNOWN_CHANNEL_TYPE:3,RESOURCE_SHORTAGE:4},TERMINAL_MODE:{TTY_OP_END:0,VINTR:1,VQUIT:2,VERASE:3,VKILL:4,VEOF:5,VEOL:6,VEOL2:7,VSTART:8,VSTOP:9,VSUSP:10,VDSUSP:11,VREPRINT:12,VWERASE:13,VLNEXT:14,VFLUSH:15,VSWTCH:16,VSTATUS:17,VDISCARD:18,IGNPAR:30,PARMRK:31,INPCK:32,ISTRIP:33,INLCR:34,IGNCR:35,ICRNL:36,IUCLC:37,IXON:38,IXANY:39,IXOFF:40,IMAXBEL:41,ISIG:50,ICANON:51,XCASE:52,ECHO:53,ECHOE:54,ECHOK:55,ECHONL:56,NOFLSH:57,TOSTOP:58,IEXTEN:59,ECHOCTL:60,ECHOKE:61,PENDIN:62,OPOST:70,OLCUC:71,ONLCR:72,OCRNL:73,ONOCR:74,ONLRET:75,CS7:90,CS8:91,PARENB:92,PARODD:93,TTY_OP_ISPEED:128,TTY_OP_OSPEED:129},CHANNEL_EXTENDED_DATATYPE:{STDERR:1},SIGNALS:["ABRT","ALRM","FPE","HUP","ILL","INT","QUIT","SEGV","TERM","USR1","USR2","KILL","PIPE"].reduce((n,t)=>({...n,[t]:1}),{}),COMPAT:Hn,COMPAT_CHECKS:[["Cisco-1.25",Hn.BAD_DHGEX],[/^Cisco-1[.]/,Hn.BUG_DHGEX_LARGE],[/^[0-9.]+$/,Hn.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,Hn.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,Hn.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:Jr,SUPPORTED_KEX:Rc,DEFAULT_SERVER_HOST_KEY:Yi,SUPPORTED_SERVER_HOST_KEY:Nc,DEFAULT_CIPHER:hn,SUPPORTED_CIPHER:Tc,DEFAULT_MAC:jo,SUPPORTED_MAC:vc,DEFAULT_COMPRESSION:Vo,SUPPORTED_COMPRESSION:Lc,curve25519Supported:Yo,eddsaSupported:Go};Zr.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(Zr.exports.DISCONNECT_REASON)).reduce((n,[t,e])=>({...n,[e]:t}),{})});var Wt=Ze((kd,ef)=>{"use strict";var qt=cr().Ber,ei,Zo=Buffer[Symbol.species],Uc=Object.getPrototypeOf(Uint8Array.prototype).fill;function zo(n,t){return n[t++]*16777216+n[t++]*65536+n[t++]*256+n[t]}function hr(n,t,e,r,i){i||(i=0),r>n.length&&(r=n.length);let s=r-e,o=t.length-i;return s>o&&(s=o),t.set(new Uint8Array(n.buffer,n.byteOffset+e,s),i),s}function ur(n,t,e){return e===void 0&&(e=n.length),new Zo(n.buffer,n.byteOffset+t,e-t)}function Xi(){let n=0,t,e={init:(r,i)=>{t=r,n=typeof i=="number"?i:0},pos:()=>n,length:()=>t?t.length:0,avail:()=>t&&n<t.length?t.length-n:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||n+3>=t.length))return t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]},readUInt64BE:r=>{if(!(!t||n+7>=t.length))switch(r){case"always":return BigInt(`0x${t.hexSlice(n,n+=8)}`);case"maybe":if(t[n]>31)return BigInt(`0x${t.hexSlice(n,n+=8)}`);default:return t[n++]*72057594037927940+t[n++]*281474976710656+t[n++]*1099511627776+t[n++]*4294967296+t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]}},skip:r=>{t&&r>0&&(n+=r)},skipString:()=>{let r=e.readUInt32BE();if(r!==void 0)return n+=r,n<=t.length?r:void 0},readByte:()=>{if(t&&n<t.length)return t[n++]},readBool:()=>{if(t&&n<t.length)return!!t[n++]},readList:()=>{let r=e.readString(!0);if(r!==void 0)return r?r.split(","):[]},readString:(r,i)=>{typeof r=="number"&&(i=r,r=void 0);let s=e.readUInt32BE();if(s!==void 0&&!(t.length-n<s||typeof i=="number"&&s>i))return r?Buffer.isBuffer(r)?hr(t,r,n,n+=s):t.utf8Slice(n,n+=s):ur(t,n,n+=s)},readRaw:r=>{if(t){if(typeof r!="number")return ur(t,n,n+=t.length-n);if(t.length-n>=r)return ur(t,n,n+=r)}}};return e}function Jo(n,t,e){let r=new Error(n);return typeof t=="boolean"?(e=t,r.level="protocol"):r.level=t||"protocol",r.fatal=!!e,r}function $i(n,t,e){return n[e++]=t>>>24,n[e++]=t>>>16,n[e++]=t>>>8,n[e++]=t,e}var ti=Xi();ef.exports={bufferCopy:hr,bufferSlice:ur,FastBuffer:Zo,bufferFill:(n,t,e,r)=>Uc.call(n,t,e,r),makeError:Jo,doFatalError:(n,t,e,r)=>{let i;return ei===void 0&&({DISCONNECT_REASON:ei}=nn()),t instanceof Error?(i=t,typeof e!="number"?r=ei.PROTOCOL_ERROR:r=e):i=Jo(t,e,!0),typeof r!="number"&&(r=ei.PROTOCOL_ERROR),n.disconnect(r),n._destruct(),n._onError(i),1/0},readUInt32BE:zo,writeUInt32BE:$i,writeUInt32LE:(n,t,e)=>(n[e++]=t,n[e++]=t>>>8,n[e++]=t>>>16,n[e++]=t>>>24,e),makeBufferParser:Xi,bufferParser:Xi(),readString:(n,t,e,r)=>{typeof e=="number"&&(r=e,e=void 0),t===void 0&&(t=0);let i=n.length-t;if(t<0||t>=n.length||i<4)return;let s=zo(n,t);if(i<4+s||typeof r=="number"&&s>r)return;t+=4;let o=t+s;return n._pos=o,e?Buffer.isBuffer(e)?hr(n,e,t,o):n.utf8Slice(t,o):ur(n,t,o)},sigSSHToASN1:(n,t)=>{switch(t){case"ssh-dss":{if(n.length>40)return n;let e=new qt.Writer;e.startSequence();let r=n.slice(0,20),i=n.slice(20);if(r[0]&128){let s=Buffer.allocUnsafe(21);s[0]=0,r.copy(s,1),r=s}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(i[0]&128){let s=Buffer.allocUnsafe(21);s[0]=0,i.copy(s,1),i=s}else i[0]===0&&!(i[1]&128)&&(i=i.slice(1));return e.writeBuffer(r,qt.Integer),e.writeBuffer(i,qt.Integer),e.endSequence(),e.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{ti.init(n,0);let e=ti.readString(),r=ti.readString();if(ti.clear(),e===void 0||r===void 0)return;let i=new qt.Writer;return i.startSequence(),i.writeBuffer(e,qt.Integer),i.writeBuffer(r,qt.Integer),i.endSequence(),i.buffer}default:return n}},convertSignature:(n,t)=>{switch(t){case"ssh-dss":{if(n.length<=40)return n;let e=new qt.Reader(n);e.readSequence();let r=e.readString(qt.Integer,!0),i=e.readString(qt.Integer,!0),s=0,o=0;if(r.length<20){let a=Buffer.allocUnsafe(20);a.set(r,1),r=a,r[0]=0}if(i.length<20){let a=Buffer.allocUnsafe(20);a.set(i,1),i=a,i[0]=0}r.length>20&&r[0]===0&&(s=1),i.length>20&&i[0]===0&&(o=1);let f=Buffer.allocUnsafe(r.length-s+(i.length-o));return hr(r,f,s,r.length,0),hr(i,f,o,i.length,r.length-s),f}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(n[0]===0)return n;let e=new qt.Reader(n);e.readSequence();let r=e.readString(qt.Integer,!0),i=e.readString(qt.Integer,!0);if(r===null||i===null)return;let s=Buffer.allocUnsafe(4+r.length+4+i.length);return $i(s,r.length,0),s.set(r,4),$i(s,i.length,4+r.length),s.set(i,8+r.length),s}}return n},sendPacket:(n,t,e)=>!e&&n._kexinit!==void 0?(n._queue===void 0&&(n._queue=[]),n._queue.push(t),n._debug&&n._debug("Outbound: ... packet queued"),!1):(n._cipher.encrypt(t),!0)}});var tf=Ze((ni,Vi)=>{var ji=(function(){var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),(function(t){t=t||{};var e;e||(e=typeof t<"u"?t:{});var r,i;e.ready=new Promise(function(q,se){r=q,i=se});var s={},o;for(o in e)e.hasOwnProperty(o)&&(s[o]=e[o]);var f=typeof window=="object",a=typeof importScripts=="function",h=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",d="",l,_,p,x,I;h?(d=a?require("path").dirname(d)+"/":__dirname+"/",l=function(q,se){var pe=Jt(q);return pe?se?pe:pe.toString():(x||(x=require("fs")),I||(I=require("path")),q=I.normalize(q),x.readFileSync(q,se?null:"utf8"))},p=function(q){return q=l(q,!0),q.buffer||(q=new Uint8Array(q)),V(q.buffer),q},_=function(q,se,pe){var Ce=Jt(q);Ce&&se(Ce),x||(x=require("fs")),I||(I=require("path")),q=I.normalize(q),x.readFile(q,function(Ke,gt){Ke?pe(Ke):se(gt.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}):(f||a)&&(a?d=self.location.href:typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),n&&(d=n),d.indexOf("blob:")!==0?d=d.substr(0,d.lastIndexOf("/")+1):d="",l=function(q){try{var se=new XMLHttpRequest;return se.open("GET",q,!1),se.send(null),se.responseText}catch(Ke){if(q=Jt(q)){se=[];for(var pe=0;pe<q.length;pe++){var Ce=q[pe];255<Ce&&(kn&&V(!1,"Character code "+Ce+" ("+String.fromCharCode(Ce)+") at offset "+pe+" not in 0x00-0xFF."),Ce&=255),se.push(String.fromCharCode(Ce))}return se.join("")}throw Ke}},a&&(p=function(q){try{var se=new XMLHttpRequest;return se.open("GET",q,!1),se.responseType="arraybuffer",se.send(null),new Uint8Array(se.response)}catch(pe){if(q=Jt(q))return q;throw pe}}),_=function(q,se,pe){var Ce=new XMLHttpRequest;Ce.open("GET",q,!0),Ce.responseType="arraybuffer",Ce.onload=function(){if(Ce.status==200||Ce.status==0&&Ce.response)se(Ce.response);else{var Ke=Jt(q);Ke?se(Ke.buffer):pe()}},Ce.onerror=pe,Ce.send(null)}),e.print||console.log.bind(console);var k=e.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(e[o]=s[o]);s=null;var N;e.wasmBinary&&(N=e.wasmBinary);var D=e.noExitRuntime||!0;typeof WebAssembly!="object"&&$("no native wasm support detected");var Z,O=!1;function V(q,se){q||$("Assertion failed: "+se)}function ee(q){var se=e["_"+q];return V(se,"Cannot call unknown function "+q+", make sure it is exported"),se}function X(q,se,pe,Ce){var Ke={string:function(Je){var bt=0;if(Je!=null&&Je!==0){var Et=(Je.length<<2)+1;bt=ir(Et);var ct=bt,rt=M;if(0<Et){Et=ct+Et-1;for(var Ht=0;Ht<Je.length;++Ht){var ht=Je.charCodeAt(Ht);if(55296<=ht&&57343>=ht){var In=Je.charCodeAt(++Ht);ht=65536+((ht&1023)<<10)|In&1023}if(127>=ht){if(ct>=Et)break;rt[ct++]=ht}else{if(2047>=ht){if(ct+1>=Et)break;rt[ct++]=192|ht>>6}else{if(65535>=ht){if(ct+2>=Et)break;rt[ct++]=224|ht>>12}else{if(ct+3>=Et)break;rt[ct++]=240|ht>>18,rt[ct++]=128|ht>>12&63}rt[ct++]=128|ht>>6&63}rt[ct++]=128|ht&63}}rt[ct]=0}}return bt},array:function(Je){var bt=ir(Je.length);return v.set(Je,bt),bt}},gt=ee(q),Xt=[];if(q=0,Ce)for(var Ot=0;Ot<Ce.length;Ot++){var Ln=Ke[pe[Ot]];Ln?(q===0&&(q=rr()),Xt[Ot]=Ln(Ce[Ot])):Xt[Ot]=Ce[Ot]}return pe=gt.apply(null,Xt),pe=(function(Je){if(se==="string")if(Je){for(var bt=M,Et=Je+NaN,ct=Je;bt[ct]&&!(ct>=Et);)++ct;if(16<ct-Je&&bt.subarray&&y)Je=y.decode(bt.subarray(Je,ct));else{for(Et="";Je<ct;){var rt=bt[Je++];if(rt&128){var Ht=bt[Je++]&63;if((rt&224)==192)Et+=String.fromCharCode((rt&31)<<6|Ht);else{var ht=bt[Je++]&63;rt=(rt&240)==224?(rt&15)<<12|Ht<<6|ht:(rt&7)<<18|Ht<<12|ht<<6|bt[Je++]&63,65536>rt?Et+=String.fromCharCode(rt):(rt-=65536,Et+=String.fromCharCode(55296|rt>>10,56320|rt&1023))}}else Et+=String.fromCharCode(rt)}Je=Et}}else Je="";else Je=se==="boolean"?!!Je:Je;return Je})(pe),q!==0&&Qr(q),pe}var y=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,S,v,M;function Q(){var q=Z.buffer;S=q,e.HEAP8=v=new Int8Array(q),e.HEAP16=new Int16Array(q),e.HEAP32=new Int32Array(q),e.HEAPU8=M=new Uint8Array(q),e.HEAPU16=new Uint16Array(q),e.HEAPU32=new Uint32Array(q),e.HEAPF32=new Float32Array(q),e.HEAPF64=new Float64Array(q)}var re,J=[],j=[],te=[];function ie(){var q=e.preRun.shift();J.unshift(q)}var T=0,F=null,H=null;e.preloadedImages={},e.preloadedAudios={};function $(q){throw e.onAbort&&e.onAbort(q),k(q),O=!0,q=new WebAssembly.RuntimeError("abort("+q+"). Build with -s ASSERTIONS=1 for more info."),i(q),q}var le="data:application/octet-stream;base64,",_e;if(_e="data:application/octet-stream;base64,AGFzbQEAAAABIAZgAX8Bf2ADf39/AGABfwBgAABgAAF/YAZ/f39/f38AAgcBAWEBYQAAAwsKAAEDAQAAAgQFAgQFAXABAQEFBwEBgAKAgAIGCQF/AUGAjMACCwclCQFiAgABYwADAWQACQFlAAgBZgAHAWcABgFoAAUBaQAKAWoBAAqGTQpPAQJ/QYAIKAIAIgEgAEEDakF8cSICaiEAAkAgAkEAIAAgAU0bDQAgAD8AQRB0SwRAIAAQAEUNAQtBgAggADYCACABDwtBhAhBMDYCAEF/C4wFAg5+Cn8gACgCJCEUIAAoAiAhFSAAKAIcIREgACgCGCESIAAoAhQhEyACQRBPBEAgAC0ATEVBGHQhFyAAKAIEIhZBBWytIQ8gACgCCCIYQQVsrSENIAAoAgwiGUEFbK0hCyAAKAIQIhpBBWytIQkgADUCACEIIBqtIRAgGa0hDiAYrSEMIBatIQoDQCASIAEtAAMiEiABLQAEQQh0ciABLQAFQRB0ciABLQAGIhZBGHRyQQJ2Qf///x9xaq0iAyAOfiABLwAAIAEtAAJBEHRyIBNqIBJBGHRBgICAGHFqrSIEIBB+fCARIAEtAAdBCHQgFnIgAS0ACEEQdHIgAS0ACSIRQRh0ckEEdkH///8fcWqtIgUgDH58IAEtAApBCHQgEXIgAS0AC0EQdHIgAS0ADEEYdHJBBnYgFWqtIgYgCn58IBQgF2ogAS8ADSABLQAPQRB0cmqtIgcgCH58IAMgDH4gBCAOfnwgBSAKfnwgBiAIfnwgByAJfnwgAyAKfiAEIAx+fCAFIAh+fCAGIAl+fCAHIAt+fCADIAh+IAQgCn58IAUgCX58IAYgC358IAcgDX58IAMgCX4gBCAIfnwgBSALfnwgBiANfnwgByAPfnwiA0IaiEL/////D4N8IgRCGohC/////w+DfCIFQhqIQv////8Pg3wiBkIaiEL/////D4N8IgdCGoinQQVsIAOnQf///x9xaiITQRp2IASnQf///x9xaiESIAWnQf///x9xIREgBqdB////H3EhFSAHp0H///8fcSEUIBNB////H3EhEyABQRBqIQEgAkEQayICQQ9LDQALCyAAIBQ2AiQgACAVNgIgIAAgETYCHCAAIBI2AhggACATNgIUCwMAAQu2BAEGfwJAIAAoAjgiBARAIABBPGohBQJAIAJBECAEayIDIAIgA0kbIgZFDQAgBkEDcSEHAkAgBkEBa0EDSQRAQQAhAwwBCyAGQXxxIQhBACEDA0AgBSADIARqaiABIANqLQAAOgAAIAUgA0EBciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0ECciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0EDciIEIAAoAjhqaiABIARqLQAAOgAAIANBBGohAyAAKAI4IQQgCEEEayIIDQALCyAHRQ0AA0AgBSADIARqaiABIANqLQAAOgAAIANBAWohAyAAKAI4IQQgB0EBayIHDQALCyAAIAQgBmoiAzYCOCADQRBJDQEgACAFQRAQAiAAQQA2AjggAiAGayECIAEgBmohAQsgAkEQTwRAIAAgASACQXBxIgMQAiACQQ9xIQIgASADaiEBCyACRQ0AIAJBA3EhBCAAQTxqIQVBACEDIAJBAWtBA08EQCACQXxxIQcDQCAFIAAoAjggA2pqIAEgA2otAAA6AAAgBSADQQFyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQJyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQNyIgYgACgCOGpqIAEgBmotAAA6AAAgA0EEaiEDIAdBBGsiBw0ACwsgBARAA0AgBSAAKAI4IANqaiABIANqLQAAOgAAIANBAWohAyAEQQFrIgQNAAsLIAAgACgCOCACajYCOAsLoS0BDH8jAEEQayIMJAACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAEH0AU0EQEGICCgCACIFQRAgAEELakF4cSAAQQtJGyIIQQN2IgJ2IgFBA3EEQCABQX9zQQFxIAJqIgNBA3QiAUG4CGooAgAiBEEIaiEAAkAgBCgCCCICIAFBsAhqIgFGBEBBiAggBUF+IAN3cTYCAAwBCyACIAE2AgwgASACNgIICyAEIANBA3QiAUEDcjYCBCABIARqIgEgASgCBEEBcjYCBAwNCyAIQZAIKAIAIgpNDQEgAQRAAkBBAiACdCIAQQAgAGtyIAEgAnRxIgBBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2aiIDQQN0IgBBuAhqKAIAIgQoAggiASAAQbAIaiIARgRAQYgIIAVBfiADd3EiBTYCAAwBCyABIAA2AgwgACABNgIICyAEQQhqIQAgBCAIQQNyNgIEIAQgCGoiAiADQQN0IgEgCGsiA0EBcjYCBCABIARqIAM2AgAgCgRAIApBA3YiAUEDdEGwCGohB0GcCCgCACEEAn8gBUEBIAF0IgFxRQRAQYgIIAEgBXI2AgAgBwwBCyAHKAIICyEBIAcgBDYCCCABIAQ2AgwgBCAHNgIMIAQgATYCCAtBnAggAjYCAEGQCCADNgIADA0LQYwIKAIAIgZFDQEgBkEAIAZrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QbgKaigCACIBKAIEQXhxIAhrIQMgASECA0ACQCACKAIQIgBFBEAgAigCFCIARQ0BCyAAKAIEQXhxIAhrIgIgAyACIANJIgIbIQMgACABIAIbIQEgACECDAELCyABIAhqIgkgAU0NAiABKAIYIQsgASABKAIMIgRHBEAgASgCCCIAQZgIKAIASRogACAENgIMIAQgADYCCAwMCyABQRRqIgIoAgAiAEUEQCABKAIQIgBFDQQgAUEQaiECCwNAIAIhByAAIgRBFGoiAigCACIADQAgBEEQaiECIAQoAhAiAA0ACyAHQQA2AgAMCwtBfyEIIABBv39LDQAgAEELaiIAQXhxIQhBjAgoAgAiCUUNAEEAIAhrIQMCQAJAAkACf0EAIAhBgAJJDQAaQR8gCEH///8HSw0AGiAAQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgCCAAQRVqdkEBcXJBHGoLIgVBAnRBuApqKAIAIgJFBEBBACEADAELQQAhACAIQQBBGSAFQQF2ayAFQR9GG3QhAQNAAkAgAigCBEF4cSAIayIHIANPDQAgAiEEIAciAw0AQQAhAyACIQAMAwsgACACKAIUIgcgByACIAFBHXZBBHFqKAIQIgJGGyAAIAcbIQAgAUEBdCEBIAINAAsLIAAgBHJFBEBBACEEQQIgBXQiAEEAIABrciAJcSIARQ0DIABBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2akECdEG4CmooAgAhAAsgAEUNAQsDQCAAKAIEQXhxIAhrIgEgA0khAiABIAMgAhshAyAAIAQgAhshBCAAKAIQIgEEfyABBSAAKAIUCyIADQALCyAERQ0AIANBkAgoAgAgCGtPDQAgBCAIaiIGIARNDQEgBCgCGCEFIAQgBCgCDCIBRwRAIAQoAggiAEGYCCgCAEkaIAAgATYCDCABIAA2AggMCgsgBEEUaiICKAIAIgBFBEAgBCgCECIARQ0EIARBEGohAgsDQCACIQcgACIBQRRqIgIoAgAiAA0AIAFBEGohAiABKAIQIgANAAsgB0EANgIADAkLIAhBkAgoAgAiAk0EQEGcCCgCACEDAkAgAiAIayIBQRBPBEBBkAggATYCAEGcCCADIAhqIgA2AgAgACABQQFyNgIEIAIgA2ogATYCACADIAhBA3I2AgQMAQtBnAhBADYCAEGQCEEANgIAIAMgAkEDcjYCBCACIANqIgAgACgCBEEBcjYCBAsgA0EIaiEADAsLIAhBlAgoAgAiBkkEQEGUCCAGIAhrIgE2AgBBoAhBoAgoAgAiAiAIaiIANgIAIAAgAUEBcjYCBCACIAhBA3I2AgQgAkEIaiEADAsLQQAhACAIQS9qIgkCf0HgCygCAARAQegLKAIADAELQewLQn83AgBB5AtCgKCAgICABDcCAEHgCyAMQQxqQXBxQdiq1aoFczYCAEH0C0EANgIAQcQLQQA2AgBBgCALIgFqIgVBACABayIHcSICIAhNDQpBwAsoAgAiBARAQbgLKAIAIgMgAmoiASADTQ0LIAEgBEsNCwtBxAstAABBBHENBQJAAkBBoAgoAgAiAwRAQcgLIQADQCADIAAoAgAiAU8EQCABIAAoAgRqIANLDQMLIAAoAggiAA0ACwtBABABIgFBf0YNBiACIQVB5AsoAgAiA0EBayIAIAFxBEAgAiABayAAIAFqQQAgA2txaiEFCyAFIAhNDQYgBUH+////B0sNBkHACygCACIEBEBBuAsoAgAiAyAFaiIAIANNDQcgACAESw0HCyAFEAEiACABRw0BDAgLIAUgBmsgB3EiBUH+////B0sNBSAFEAEiASAAKAIAIAAoAgRqRg0EIAEhAAsCQCAAQX9GDQAgCEEwaiAFTQ0AQegLKAIAIgEgCSAFa2pBACABa3EiAUH+////B0sEQCAAIQEMCAsgARABQX9HBEAgASAFaiEFIAAhAQwIC0EAIAVrEAEaDAULIAAiAUF/Rw0GDAQLAAtBACEEDAcLQQAhAQwFCyABQX9HDQILQcQLQcQLKAIAQQRyNgIACyACQf7///8HSw0BIAIQASEBQQAQASEAIAFBf0YNASAAQX9GDQEgACABTQ0BIAAgAWsiBSAIQShqTQ0BC0G4C0G4CygCACAFaiIANgIAQbwLKAIAIABJBEBBvAsgADYCAAsCQAJAAkBBoAgoAgAiBwRAQcgLIQADQCABIAAoAgAiAyAAKAIEIgJqRg0CIAAoAggiAA0ACwwCC0GYCCgCACIAQQAgACABTRtFBEBBmAggATYCAAtBACEAQcwLIAU2AgBByAsgATYCAEGoCEF/NgIAQawIQeALKAIANgIAQdQLQQA2AgADQCAAQQN0IgNBuAhqIANBsAhqIgI2AgAgA0G8CGogAjYCACAAQQFqIgBBIEcNAAtBlAggBUEoayIDQXggAWtBB3FBACABQQhqQQdxGyIAayICNgIAQaAIIAAgAWoiADYCACAAIAJBAXI2AgQgASADakEoNgIEQaQIQfALKAIANgIADAILIAAtAAxBCHENACADIAdLDQAgASAHTQ0AIAAgAiAFajYCBEGgCCAHQXggB2tBB3FBACAHQQhqQQdxGyIAaiICNgIAQZQIQZQIKAIAIAVqIgEgAGsiADYCACACIABBAXI2AgQgASAHakEoNgIEQaQIQfALKAIANgIADAELQZgIKAIAIAFLBEBBmAggATYCAAsgASAFaiECQcgLIQACQAJAAkACQAJAAkADQCACIAAoAgBHBEAgACgCCCIADQEMAgsLIAAtAAxBCHFFDQELQcgLIQADQCAHIAAoAgAiAk8EQCACIAAoAgRqIgQgB0sNAwsgACgCCCEADAALAAsgACABNgIAIAAgACgCBCAFajYCBCABQXggAWtBB3FBACABQQhqQQdxG2oiCSAIQQNyNgIEIAJBeCACa0EHcUEAIAJBCGpBB3EbaiIFIAggCWoiBmshAiAFIAdGBEBBoAggBjYCAEGUCEGUCCgCACACaiIANgIAIAYgAEEBcjYCBAwDCyAFQZwIKAIARgRAQZwIIAY2AgBBkAhBkAgoAgAgAmoiADYCACAGIABBAXI2AgQgACAGaiAANgIADAMLIAUoAgQiAEEDcUEBRgRAIABBeHEhBwJAIABB/wFNBEAgBSgCCCIDIABBA3YiAEEDdEGwCGpGGiADIAUoAgwiAUYEQEGICEGICCgCAEF+IAB3cTYCAAwCCyADIAE2AgwgASADNgIIDAELIAUoAhghCAJAIAUgBSgCDCIBRwRAIAUoAggiACABNgIMIAEgADYCCAwBCwJAIAVBFGoiACgCACIDDQAgBUEQaiIAKAIAIgMNAEEAIQEMAQsDQCAAIQQgAyIBQRRqIgAoAgAiAw0AIAFBEGohACABKAIQIgMNAAsgBEEANgIACyAIRQ0AAkAgBSAFKAIcIgNBAnRBuApqIgAoAgBGBEAgACABNgIAIAENAUGMCEGMCCgCAEF+IAN3cTYCAAwCCyAIQRBBFCAIKAIQIAVGG2ogATYCACABRQ0BCyABIAg2AhggBSgCECIABEAgASAANgIQIAAgATYCGAsgBSgCFCIARQ0AIAEgADYCFCAAIAE2AhgLIAUgB2ohBSACIAdqIQILIAUgBSgCBEF+cTYCBCAGIAJBAXI2AgQgAiAGaiACNgIAIAJB/wFNBEAgAkEDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwDC0EfIQAgAkH///8HTQRAIAJBCHYiACAAQYD+P2pBEHZBCHEiA3QiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASADciAAcmsiAEEBdCACIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQQCQEGMCCgCACIDQQEgAHQiAXFFBEBBjAggASADcjYCACAEIAY2AgAgBiAENgIYDAELIAJBAEEZIABBAXZrIABBH0YbdCEAIAQoAgAhAQNAIAEiAygCBEF4cSACRg0DIABBHXYhASAAQQF0IQAgAyABQQRxaiIEKAIQIgENAAsgBCAGNgIQIAYgAzYCGAsgBiAGNgIMIAYgBjYCCAwCC0GUCCAFQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBBoAggACABaiIANgIAIAAgAkEBcjYCBCABIANqQSg2AgRBpAhB8AsoAgA2AgAgByAEQScgBGtBB3FBACAEQSdrQQdxG2pBL2siACAAIAdBEGpJGyICQRs2AgQgAkHQCykCADcCECACQcgLKQIANwIIQdALIAJBCGo2AgBBzAsgBTYCAEHICyABNgIAQdQLQQA2AgAgAkEYaiEAA0AgAEEHNgIEIABBCGohASAAQQRqIQAgASAESQ0ACyACIAdGDQMgAiACKAIEQX5xNgIEIAcgAiAHayIEQQFyNgIEIAIgBDYCACAEQf8BTQRAIARBA3YiAEEDdEGwCGohAgJ/QYgIKAIAIgFBASAAdCIAcUUEQEGICCAAIAFyNgIAIAIMAQsgAigCCAshACACIAc2AgggACAHNgIMIAcgAjYCDCAHIAA2AggMBAtBHyEAIAdCADcCECAEQf///wdNBEAgBEEIdiIAIABBgP4/akEQdkEIcSICdCIAIABBgOAfakEQdkEEcSIBdCIAIABBgIAPakEQdkECcSIAdEEPdiABIAJyIAByayIAQQF0IAQgAEEVanZBAXFyQRxqIQALIAcgADYCHCAAQQJ0QbgKaiEDAkBBjAgoAgAiAkEBIAB0IgFxRQRAQYwIIAEgAnI2AgAgAyAHNgIAIAcgAzYCGAwBCyAEQQBBGSAAQQF2ayAAQR9GG3QhACADKAIAIQEDQCABIgIoAgRBeHEgBEYNBCAAQR12IQEgAEEBdCEAIAIgAUEEcWoiAygCECIBDQALIAMgBzYCECAHIAI2AhgLIAcgBzYCDCAHIAc2AggMAwsgAygCCCIAIAY2AgwgAyAGNgIIIAZBADYCGCAGIAM2AgwgBiAANgIICyAJQQhqIQAMBQsgAigCCCIAIAc2AgwgAiAHNgIIIAdBADYCGCAHIAI2AgwgByAANgIIC0GUCCgCACIAIAhNDQBBlAggACAIayIBNgIAQaAIQaAIKAIAIgIgCGoiADYCACAAIAFBAXI2AgQgAiAIQQNyNgIEIAJBCGohAAwDC0GECEEwNgIAQQAhAAwCCwJAIAVFDQACQCAEKAIcIgJBAnRBuApqIgAoAgAgBEYEQCAAIAE2AgAgAQ0BQYwIIAlBfiACd3EiCTYCAAwCCyAFQRBBFCAFKAIQIARGG2ogATYCACABRQ0BCyABIAU2AhggBCgCECIABEAgASAANgIQIAAgATYCGAsgBCgCFCIARQ0AIAEgADYCFCAAIAE2AhgLAkAgA0EPTQRAIAQgAyAIaiIAQQNyNgIEIAAgBGoiACAAKAIEQQFyNgIEDAELIAQgCEEDcjYCBCAGIANBAXI2AgQgAyAGaiADNgIAIANB/wFNBEAgA0EDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwBC0EfIQAgA0H///8HTQRAIANBCHYiACAAQYD+P2pBEHZBCHEiAnQiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASACciAAcmsiAEEBdCADIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQICQAJAIAlBASAAdCIBcUUEQEGMCCABIAlyNgIAIAIgBjYCACAGIAI2AhgMAQsgA0EAQRkgAEEBdmsgAEEfRht0IQAgAigCACEIA0AgCCIBKAIEQXhxIANGDQIgAEEddiECIABBAXQhACABIAJBBHFqIgIoAhAiCA0ACyACIAY2AhAgBiABNgIYCyAGIAY2AgwgBiAGNgIIDAELIAEoAggiACAGNgIMIAEgBjYCCCAGQQA2AhggBiABNgIMIAYgADYCCAsgBEEIaiEADAELAkAgC0UNAAJAIAEoAhwiAkECdEG4CmoiACgCACABRgRAIAAgBDYCACAEDQFBjAggBkF+IAJ3cTYCAAwCCyALQRBBFCALKAIQIAFGG2ogBDYCACAERQ0BCyAEIAs2AhggASgCECIABEAgBCAANgIQIAAgBDYCGAsgASgCFCIARQ0AIAQgADYCFCAAIAQ2AhgLAkAgA0EPTQRAIAEgAyAIaiIAQQNyNgIEIAAgAWoiACAAKAIEQQFyNgIEDAELIAEgCEEDcjYCBCAJIANBAXI2AgQgAyAJaiADNgIAIAoEQCAKQQN2IgBBA3RBsAhqIQRBnAgoAgAhAgJ/QQEgAHQiACAFcUUEQEGICCAAIAVyNgIAIAQMAQsgBCgCCAshACAEIAI2AgggACACNgIMIAIgBDYCDCACIAA2AggLQZwIIAk2AgBBkAggAzYCAAsgAUEIaiEACyAMQRBqJAAgAAsQACMAIABrQXBxIgAkACAACwYAIAAkAAsEACMAC4AJAgh/BH4jAEGQAWsiBiQAIAYgBS0AA0EYdEGAgIAYcSAFLwAAIAUtAAJBEHRycjYCACAGIAUoAANBAnZBg/7/H3E2AgQgBiAFKAAGQQR2Qf+B/x9xNgIIIAYgBSgACUEGdkH//8AfcTYCDCAFLwANIQggBS0ADyEJIAZCADcCFCAGQgA3AhwgBkEANgIkIAYgCCAJQRB0QYCAPHFyNgIQIAYgBSgAEDYCKCAGIAUoABQ2AiwgBiAFKAAYNgIwIAUoABwhBSAGQQA6AEwgBkEANgI4IAYgBTYCNCAGIAEgAhAEIAQEQCAGIAMgBBAECyAGKAI4IgEEQCAGQTxqIgIgAWpBAToAACABQQFqQQ9NBEAgASAGakE9aiEEAkBBDyABayIDRQ0AIAMgBGoiAUEBa0EAOgAAIARBADoAACADQQNJDQAgAUECa0EAOgAAIARBADoAASABQQNrQQA6AAAgBEEAOgACIANBB0kNACABQQRrQQA6AAAgBEEAOgADIANBCUkNACAEQQAgBGtBA3EiAWoiBEEANgIAIAQgAyABa0F8cSIBaiIDQQRrQQA2AgAgAUEJSQ0AIARBADYCCCAEQQA2AgQgA0EIa0EANgIAIANBDGtBADYCACABQRlJDQAgBEEANgIYIARBADYCFCAEQQA2AhAgBEEANgIMIANBEGtBADYCACADQRRrQQA2AgAgA0EYa0EANgIAIANBHGtBADYCACABIARBBHFBGHIiAWsiA0EgSQ0AIAEgBGohAQNAIAFCADcDGCABQgA3AxAgAUIANwMIIAFCADcDACABQSBqIQEgA0EgayIDQR9LDQALCwsgBkEBOgBMIAYgAkEQEAILIAY1AjQhECAGNQIwIREgBjUCLCEOIAAgBjUCKCAGKAIkIAYoAiAgBigCHCAGKAIYIgNBGnZqIgJBGnZqIgFBGnZqIgtBgICAYHIgAUH///8fcSINIAJB////H3EiCCAGKAIUIAtBGnZBBWxqIgFB////H3EiCUEFaiIFQRp2IANB////H3EgAUEadmoiA2oiAUEadmoiAkEadmoiBEEadmoiDEEfdSIHIANxIAEgDEEfdkEBayIDQf///x9xIgpxciIBQRp0IAUgCnEgByAJcXJyrXwiDzwAACAAIA9CGIg8AAMgACAPQhCIPAACIAAgD0IIiDwAASAAIA4gByAIcSACIApxciICQRR0IAFBBnZyrXwgD0IgiHwiDjwABCAAIA5CGIg8AAcgACAOQhCIPAAGIAAgDkIIiDwABSAAIBEgByANcSAEIApxciIBQQ50IAJBDHZyrXwgDkIgiHwiDjwACCAAIA5CGIg8AAsgACAOQhCIPAAKIAAgDkIIiDwACSAAIBAgAyAMcSAHIAtxckEIdCABQRJ2cq18IA5CIIh8Ig48AAwgACAOQhiIPAAPIAAgDkIQiDwADiAAIA5CCIg8AA0gBkIANwIwIAZCADcCKCAGQgA3AiAgBkIANwIYIAZCADcCECAGQgA3AgggBkIANwIAIAZBkAFqJAALpwwBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAMgAygCACIBayIDQZgIKAIASQ0BIAAgAWohACADQZwIKAIARwRAIAFB/wFNBEAgAygCCCICIAFBA3YiBEEDdEGwCGpGGiACIAMoAgwiAUYEQEGICEGICCgCAEF+IAR3cTYCAAwDCyACIAE2AgwgASACNgIIDAILIAMoAhghBgJAIAMgAygCDCIBRwRAIAMoAggiAiABNgIMIAEgAjYCCAwBCwJAIANBFGoiAigCACIEDQAgA0EQaiICKAIAIgQNAEEAIQEMAQsDQCACIQcgBCIBQRRqIgIoAgAiBA0AIAFBEGohAiABKAIQIgQNAAsgB0EANgIACyAGRQ0BAkAgAyADKAIcIgJBAnRBuApqIgQoAgBGBEAgBCABNgIAIAENAUGMCEGMCCgCAEF+IAJ3cTYCAAwDCyAGQRBBFCAGKAIQIANGG2ogATYCACABRQ0CCyABIAY2AhggAygCECICBEAgASACNgIQIAIgATYCGAsgAygCFCICRQ0BIAEgAjYCFCACIAE2AhgMAQsgBSgCBCIBQQNxQQNHDQBBkAggADYCACAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAA8LIAMgBU8NACAFKAIEIgFBAXFFDQACQCABQQJxRQRAIAVBoAgoAgBGBEBBoAggAzYCAEGUCEGUCCgCACAAaiIANgIAIAMgAEEBcjYCBCADQZwIKAIARw0DQZAIQQA2AgBBnAhBADYCAA8LIAVBnAgoAgBGBEBBnAggAzYCAEGQCEGQCCgCACAAaiIANgIAIAMgAEEBcjYCBCAAIANqIAA2AgAPCyABQXhxIABqIQACQCABQf8BTQRAIAUoAggiAiABQQN2IgRBA3RBsAhqRhogAiAFKAIMIgFGBEBBiAhBiAgoAgBBfiAEd3E2AgAMAgsgAiABNgIMIAEgAjYCCAwBCyAFKAIYIQYCQCAFIAUoAgwiAUcEQCAFKAIIIgJBmAgoAgBJGiACIAE2AgwgASACNgIIDAELAkAgBUEUaiICKAIAIgQNACAFQRBqIgIoAgAiBA0AQQAhAQwBCwNAIAIhByAEIgFBFGoiAigCACIEDQAgAUEQaiECIAEoAhAiBA0ACyAHQQA2AgALIAZFDQACQCAFIAUoAhwiAkECdEG4CmoiBCgCAEYEQCAEIAE2AgAgAQ0BQYwIQYwIKAIAQX4gAndxNgIADAILIAZBEEEUIAYoAhAgBUYbaiABNgIAIAFFDQELIAEgBjYCGCAFKAIQIgIEQCABIAI2AhAgAiABNgIYCyAFKAIUIgJFDQAgASACNgIUIAIgATYCGAsgAyAAQQFyNgIEIAAgA2ogADYCACADQZwIKAIARw0BQZAIIAA2AgAPCyAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAAsgAEH/AU0EQCAAQQN2IgFBA3RBsAhqIQACf0GICCgCACICQQEgAXQiAXFFBEBBiAggASACcjYCACAADAELIAAoAggLIQIgACADNgIIIAIgAzYCDCADIAA2AgwgAyACNgIIDwtBHyECIANCADcCECAAQf///wdNBEAgAEEIdiIBIAFBgP4/akEQdkEIcSIBdCICIAJBgOAfakEQdkEEcSICdCIEIARBgIAPakEQdkECcSIEdEEPdiABIAJyIARyayIBQQF0IAAgAUEVanZBAXFyQRxqIQILIAMgAjYCHCACQQJ0QbgKaiEBAkACQAJAQYwIKAIAIgRBASACdCIHcUUEQEGMCCAEIAdyNgIAIAEgAzYCACADIAE2AhgMAQsgAEEAQRkgAkEBdmsgAkEfRht0IQIgASgCACEBA0AgASIEKAIEQXhxIABGDQIgAkEddiEBIAJBAXQhAiAEIAFBBHFqIgdBEGooAgAiAQ0ACyAHIAM2AhAgAyAENgIYCyADIAM2AgwgAyADNgIIDAELIAQoAggiACADNgIMIAQgAzYCCCADQQA2AhggAyAENgIMIAMgADYCCAtBqAhBqAgoAgBBAWsiAEF/IAAbNgIACwsLCQEAQYEICwIGUA==",!_e.startsWith(le)){var Ae=_e;_e=e.locateFile?e.locateFile(Ae,d):d+Ae}function st(){var q=_e;try{if(q==_e&&N)return new Uint8Array(N);var se=Jt(q);if(se)return se;if(p)return p(q);throw"both async and sync fetching of the wasm failed"}catch(pe){$(pe)}}function St(){if(!N&&(f||a)){if(typeof fetch=="function"&&!_e.startsWith("file://"))return fetch(_e,{credentials:"same-origin"}).then(function(q){if(!q.ok)throw"failed to load wasm binary file at '"+_e+"'";return q.arrayBuffer()}).catch(function(){return st()});if(_)return new Promise(function(q,se){_(_e,function(pe){q(new Uint8Array(pe))},se)})}return Promise.resolve().then(function(){return st()})}function nr(q){for(;0<q.length;){var se=q.shift();if(typeof se=="function")se(e);else{var pe=se.m;typeof pe=="number"?se.l===void 0?re.get(pe)():re.get(pe)(se.l):pe(se.l===void 0?null:se.l)}}}var kn=!1,Rn=typeof atob=="function"?atob:function(q){var se="",pe=0;q=q.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(q.charAt(pe++)),Ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(q.charAt(pe++)),gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(q.charAt(pe++)),Xt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(q.charAt(pe++));Ce=Ce<<2|Ke>>4,Ke=(Ke&15)<<4|gt>>2;var Ot=(gt&3)<<6|Xt;se+=String.fromCharCode(Ce),gt!==64&&(se+=String.fromCharCode(Ke)),Xt!==64&&(se+=String.fromCharCode(Ot))}while(pe<q.length);return se};function Jt(q){if(q.startsWith(le)){if(q=q.slice(le.length),typeof h=="boolean"&&h){var se=Buffer.from(q,"base64");se=new Uint8Array(se.buffer,se.byteOffset,se.byteLength)}else try{var pe=Rn(q),Ce=new Uint8Array(pe.length);for(q=0;q<pe.length;++q)Ce[q]=pe.charCodeAt(q);se=Ce}catch{throw Error("Converting base64 string to bytes failed.")}return se}}var Nn={a:function(q){var se=M.length;if(q>>>=0,2147483648<q)return!1;for(var pe=1;4>=pe;pe*=2){var Ce=se*(1+.2/pe);Ce=Math.min(Ce,q+100663296),Ce=Math.max(q,Ce),0<Ce%65536&&(Ce+=65536-Ce%65536);e:{try{Z.grow(Math.min(2147483648,Ce)-S.byteLength+65535>>>16),Q();var Ke=1;break e}catch{}Ke=void 0}if(Ke)return!0}return!1}};(function(){function q(Ke){e.asm=Ke.exports,Z=e.asm.b,Q(),re=e.asm.j,j.unshift(e.asm.c),T--,e.monitorRunDependencies&&e.monitorRunDependencies(T),T==0&&(F!==null&&(clearInterval(F),F=null),H&&(Ke=H,H=null,Ke()))}function se(Ke){q(Ke.instance)}function pe(Ke){return St().then(function(gt){return WebAssembly.instantiate(gt,Ce)}).then(Ke,function(gt){k("failed to asynchronously prepare wasm: "+gt),$(gt)})}var Ce={a:Nn};if(T++,e.monitorRunDependencies&&e.monitorRunDependencies(T),e.instantiateWasm)try{return e.instantiateWasm(Ce,q)}catch(Ke){return k("Module.instantiateWasm callback failed with error: "+Ke),!1}return(function(){return N||typeof WebAssembly.instantiateStreaming!="function"||_e.startsWith(le)||_e.startsWith("file://")||typeof fetch!="function"?pe(se):fetch(_e,{credentials:"same-origin"}).then(function(Ke){return WebAssembly.instantiateStreaming(Ke,Ce).then(se,function(gt){return k("wasm streaming compile failed: "+gt),k("falling back to ArrayBuffer instantiation"),pe(se)})})})().catch(i),{}})(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.c).apply(null,arguments)},e._poly1305_auth=function(){return(e._poly1305_auth=e.asm.d).apply(null,arguments)};var rr=e.stackSave=function(){return(rr=e.stackSave=e.asm.e).apply(null,arguments)},Qr=e.stackRestore=function(){return(Qr=e.stackRestore=e.asm.f).apply(null,arguments)},ir=e.stackAlloc=function(){return(ir=e.stackAlloc=e.asm.g).apply(null,arguments)};e._malloc=function(){return(e._malloc=e.asm.h).apply(null,arguments)},e._free=function(){return(e._free=e.asm.i).apply(null,arguments)},e.cwrap=function(q,se,pe,Ce){pe=pe||[];var Ke=pe.every(function(gt){return gt==="number"});return se!=="string"&&Ke&&!Ce?ee(q):function(){return X(q,se,pe,arguments)}};var Tn;H=function q(){Tn||vn(),Tn||(H=q)};function vn(){function q(){if(!Tn&&(Tn=!0,e.calledRun=!0,!O)){if(nr(j),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;){var se=e.postRun.shift();te.unshift(se)}nr(te)}}if(!(0<T)){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)ie();nr(J),0<T||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),q()},1)):q())}}if(e.run=vn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return vn(),t.ready})})();typeof ni=="object"&&typeof Vi=="object"?Vi.exports=ji:typeof define=="function"&&define.amd?define([],function(){return ji}):typeof ni=="object"&&(ni.createPoly1305=ji)});var un=Ze((Rd,ff)=>{"use strict";var{createCipheriv:qn,createDecipheriv:ri,createHmac:zi,randomFillSync:wn,timingSafeEqual:Ji}=require("crypto"),{readUInt32BE:dr,writeUInt32BE:Dt}=Wt(),ln=Buffer[Symbol.species],nf=2**32-1,rf=Buffer.alloc(0),Mn=Buffer.alloc(4),ii=new Map,mn=35e3,Zi,As,gs,_s,Es,ps,bs;try{Zi=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:As,ChaChaPolyCipher:gs,GenericCipher:_s,AESGCMDecipher:Es,ChaChaPolyDecipher:ps,GenericDecipher:bs}=Zi}catch{}var yt=1,Oc=(()=>{function n(t,e,r,i,s,o,f){return{sslName:t,blockLen:e,keyLen:r,ivLen:i!==0||f&yt?i:e,authLen:s,discardLen:o,stream:!!(f&yt)}}return{"chacha20-poly1305@openssh.com":n("chacha20",8,64,0,16,0,yt),"aes128-gcm":n("aes-128-gcm",16,16,12,16,0,yt),"aes256-gcm":n("aes-256-gcm",16,32,12,16,0,yt),"aes128-gcm@openssh.com":n("aes-128-gcm",16,16,12,16,0,yt),"aes256-gcm@openssh.com":n("aes-256-gcm",16,32,12,16,0,yt),"aes128-cbc":n("aes-128-cbc",16,16,0,0,0,0),"aes192-cbc":n("aes-192-cbc",16,24,0,0,0,0),"aes256-cbc":n("aes-256-cbc",16,32,0,0,0,0),"rijndael-cbc@lysator.liu.se":n("aes-256-cbc",16,32,0,0,0,0),"3des-cbc":n("des-ede3-cbc",8,24,0,0,0,0),"blowfish-cbc":n("bf-cbc",8,16,0,0,0,0),"idea-cbc":n("idea-cbc",8,16,0,0,0,0),"cast128-cbc":n("cast-cbc",8,16,0,0,0,0),"aes128-ctr":n("aes-128-ctr",16,16,16,0,0,yt),"aes192-ctr":n("aes-192-ctr",16,24,16,0,0,yt),"aes256-ctr":n("aes-256-ctr",16,32,16,0,0,yt),"3des-ctr":n("des-ede3",8,24,8,0,0,yt),"blowfish-ctr":n("bf-ecb",8,16,8,0,0,yt),"cast128-ctr":n("cast5-ecb",8,16,8,0,0,yt),arcfour:n("rc4",8,16,0,0,1536,yt),arcfour128:n("rc4",8,16,0,0,1536,yt),arcfour256:n("rc4",8,32,0,0,1536,yt),arcfour512:n("rc4",8,64,0,0,1536,yt)}})(),Pc=(()=>{function n(t,e,r,i){return{sslName:t,len:e,actualLen:r,isETM:i}}return{"hmac-md5":n("md5",16,16,!1),"hmac-md5-96":n("md5",16,12,!1),"hmac-ripemd160":n("ripemd160",20,20,!1),"hmac-sha1":n("sha1",20,20,!1),"hmac-sha1-etm@openssh.com":n("sha1",20,20,!0),"hmac-sha1-96":n("sha1",20,12,!1),"hmac-sha2-256":n("sha256",32,32,!1),"hmac-sha2-256-etm@openssh.com":n("sha256",32,32,!0),"hmac-sha2-256-96":n("sha256",32,12,!1),"hmac-sha2-512":n("sha512",64,64,!1),"hmac-sha2-512-etm@openssh.com":n("sha512",64,64,!0),"hmac-sha2-512-96":n("sha512",64,12,!1)}})(),es=class{constructor(t,e){this.outSeqno=t,this._onWrite=e,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e&7);r<4&&(r+=8),e+=r;let i=Buffer.allocUnsafe(e);return Dt(i,e-4,0),i[4]=r,wn(i,5+t,r),i}encrypt(t){this._dead||(this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},sf=Buffer.alloc(32),Tt=Buffer.alloc(16),lr,Ar,Is,ts=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encKeyMain=e.cipherKey.slice(0,32),this._encKeyPktLen=e.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let i=Buffer.allocUnsafe(e);return Dt(i,e-4,0),i[4]=r,wn(i,5+t,r),i}encrypt(t){if(this._dead)return;Tt[0]=0,Dt(Tt,this.outSeqno,12);let e=qn("chacha20",this._encKeyMain,Tt).update(sf),r=qn("chacha20",this._encKeyPktLen,Tt).update(t.slice(0,4));this._onWrite(r),Tt[0]=1;let i=qn("chacha20",this._encKeyMain,Tt).update(t.slice(4));this._onWrite(i),Is(Ar,r,r.length,i,i.length,e);let s=Buffer.allocUnsafe(16);s.set(new Uint8Array(lr.HEAPU8.buffer,Ar,16),0),this._onWrite(s),this.outSeqno=this.outSeqno+1>>>0}},ns=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new gs(e.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let i=Buffer.allocUnsafe(e+16);return Dt(i,e-4,0),i[4]=r,wn(i,5+t,r),i}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},rs=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encSSLName=e.cipherInfo.sslName,this._encKey=e.cipherKey,this._encIV=e.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let i=Buffer.allocUnsafe(e);return Dt(i,e-4,0),i[4]=r,wn(i,5+t,r),i}encrypt(t){if(this._dead)return;let e=qn(this._encSSLName,this._encKey,this._encIV);e.setAutoPadding(!1);let r=t.slice(0,4);e.setAAD(r),this._onWrite(r);let i=e.update(t.slice(4));this._onWrite(i);let s=e.final();s.length&&this._onWrite(s);let o=e.getAuthTag();this._onWrite(o),of(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},is=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new As(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let i=Buffer.allocUnsafe(e+16);return Dt(i,e-4,0),i[4]=r,wn(i,5+t,r),i}encrypt(t){this._dead||(this._instance.encrypt(t),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},ss=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._cipherInstance=qn(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=e.cipherInfo.discardLen;if(r){let i=ii.get(r);i===void 0&&(i=Buffer.alloc(r),ii.set(r,i)),this._cipherInstance.update(i)}}free(){this._dead=!0}allocPacket(t){let e=this._encBlockLen,r=5+t,i=e-(r-this._aadLen&e-1);i<4&&(i+=e),r+=i;let s=Buffer.allocUnsafe(r);return Dt(s,r-4,0),s[4]=i,wn(s,5+t,i),s}encrypt(t){if(this._dead)return;let e;if(this._macETM){let i=new Uint8Array(t.buffer,t.byteOffset,4),s=this._cipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+4,t.length-4));this._onWrite(i),this._onWrite(s),e=zi(this._macSSLName,this._macKey),Dt(Mn,this.outSeqno,0),e.update(Mn),e.update(i),e.update(s)}else{let i=this._cipherInstance.update(t);this._onWrite(i),e=zi(this._macSSLName,this._macKey),Dt(Mn,this.outSeqno,0),e.update(Mn),e.update(t)}let r=e.digest();r.length>this._macActualLen&&(r=r.slice(0,this._macActualLen)),this._onWrite(r),this.outSeqno=this.outSeqno+1>>>0}},os=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._macLen=e.macInfo.len,this._macActualLen=e.macInfo.actualLen,this._aadLen=e.macInfo.isETM?4:0,this._instance=new _s(e.cipherInfo.sslName,e.cipherKey,e.cipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=this._encBlockLen,r=5+t,i=e-(r-this._aadLen&e-1);i<4&&(i+=e),r+=i;let s=Buffer.allocUnsafe(r+this._macLen);return Dt(s,r-4,0),s[4]=i,wn(s,5+t,i),s}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._macActualLen<this._macLen&&(t=new ln(t.buffer,t.byteOffset,t.length-(this._macLen-this._macActualLen))),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},fs=class{constructor(t,e){this.inSeqno=t,this._onPayload=e,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let s=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=s;s--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len>mn||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._packetPos<this._len){let s=Math.min(this._len-this._packetPos,r-e),o;if(e!==0||s!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,s):o=t,s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),e+=s,this._packetPos+=s,this._packetPos<this._len)return}let i=this._packet?new ln(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):rf;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}},as=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decKeyMain=e.decipherKey.slice(0,32),this._decKeyPktLen=e.decipherKey.slice(32),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._calcMac=Buffer.allocUnsafe(16),this._macPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let f=Math.min(4-this._lenPos,r-e);for(;f--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;Tt[0]=0,Dt(Tt,this.inSeqno,12);let a=ri("chacha20",this._decKeyPktLen,Tt).update(this._lenBuf);if(this._len=dr(a,0),this._len>mn||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(e>=r)return;let f=Math.min(this._len-this._pktLen,r-e),a;if(e!==0||f!==r?a=new Uint8Array(t.buffer,t.byteOffset+e,f):a=t,f===this._len?this._packet=a:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(a,this._pktLen)),e+=f,this._pktLen+=f,this._pktLen<this._len||e>=r)return}{let f=Math.min(16-this._macPos,r-e);if(e!==0||f!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,f),this._macPos):this._mac.set(t,this._macPos),e+=f,this._macPos+=f,this._macPos<16)return}Tt[0]=0,Dt(Tt,this.inSeqno,12);let i=qn("chacha20",this._decKeyMain,Tt).update(sf);if(Is(Ar,this._lenBuf,4,this._packet,this._packet.length,i),this._calcMac.set(new Uint8Array(lr.HEAPU8.buffer,Ar,16),0),!Ji(this._calcMac,this._mac))throw new Error("Invalid MAC");Tt[0]=1;let s=ri("chacha20",this._decKeyMain,Tt).update(this._packet),o=new ln(s.buffer,s.byteOffset+1,s.length-s[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let f=this._onPayload(o);if(f!==void 0)return f===!1?e:f}}}},cs=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new ps(e.decipherKey),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._macPos=0}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let s=Math.min(4-this._lenPos,r-e);for(;s--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>mn||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._pktLen<this._len){let s=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||s!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,s):o=t,s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=s,this._pktLen+=s,this._pktLen<this._len||e>=r)return}{let s=Math.min(16-this._macPos,r-e);if(e!==0||s!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._macPos):this._mac.set(t,this._macPos),e+=s,this._macPos+=s,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let i=new ln(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}},hs=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=null,this._decipherSSLName=e.decipherInfo.sslName,this._decipherKey=e.decipherKey,this._decipherIV=e.decipherIV,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let s=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=s;s--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>mn||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=ri(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(Dc(this._len))}if(this._pktLen<this._len){if(e>=r)return;let s=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||s!==r?o=this._decipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+e,s)):o=this._decipherInstance.update(t),o.length&&(s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),this._packetPos+=o.length),e+=s,this._pktLen+=s,this._pktLen<this._len||e>=r)return}{let s=Math.min(16-this._tagPos,r-e);if(e!==0||s!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._tagPos):this._tag.set(t,this._tagPos),e+=s,this._tagPos+=s,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let s=this._decipherInstance.final();s.length&&(this._packet?this._packet.set(s,this._packetPos):this._packet=s)}let i=this._packet?new ln(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):rf;this.inSeqno=this.inSeqno+1>>>0,of(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}},us=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Es(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let s=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=s;s--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>mn||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(e>=r)return;let s=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||s!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,s):o=t,s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=s,this._pktLen+=s,this._pktLen<this._len||e>=r)return}{let s=Math.min(16-this._tagPos,r-e);if(e!==0||s!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._tagPos):this._tag.set(t,this._tagPos),e+=s,this._tagPos+=s,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let i=new ln(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tagPos=0;{let s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}},ls=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=ri(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(e.macInfo.isETM?4:e.decipherInfo.blockLen),this._blockSize=e.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._macInstance=null;let r=e.decipherInfo.discardLen;if(r){let i=ii.get(r);i===void 0&&(i=Buffer.alloc(r),ii.set(r,i)),this._decipherInstance.update(i)}}free(){}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||o!==r||o<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._blockPos):this._block.set(t,this._blockPos),e+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let f,a;if(this._macETM?this._len=a=dr(this._block,0):(f=this._decipherInstance.update(this._block),this._len=dr(f,0),a=4+this._len-this._blockSize),this._len>mn||this._len<5||(a&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=zi(this._macSSLName,this._macKey),Dt(Mn,this.inSeqno,0),this._macInstance.update(Mn),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(f.buffer,f.byteOffset,4)),this._pktLen=f.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(f.buffer,f.byteOffset+4,this._packetPos),0)),e>=r)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,r-e),f;e!==0||o!==r?f=new Uint8Array(t.buffer,t.byteOffset+e,o):f=t,this._macETM&&this._macInstance.update(f);let a=this._decipherInstance.update(f);if(a.length&&(o===this._len?this._packet=a:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(a,this._packetPos)),this._packetPos+=a.length),e+=o,this._pktLen+=o,this._pktLen<this._len||e>=r)return}{let o=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||o!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._macPos):this._mac.set(t,this._macPos),e+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let i=this._macInstance.digest();if(this._macActualLen<i.length&&(i=new Uint8Array(i.buffer,i.byteOffset,this._macActualLen)),!Qc(i,this._mac))throw new Error("Invalid MAC");let s=new ln(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._macPos=0,this._macInstance=null;{let o=this._onPayload(s);if(o!==void 0)return o===!1?e:o}}}},ds=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new bs(e.decipherInfo.sslName,e.decipherKey,e.decipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM,e.macInfo.actualLen),this._block=Buffer.allocUnsafe(e.macInfo.isETM||e.decipherInfo.stream?4:e.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let s=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||s!==r||s<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._blockPos):this._block.set(t,this._blockPos),e+=s,this._blockPos+=s,this._blockPos<this._block.length)return;let o;if(this._macETM?this._len=o=dr(this._block,0):(this._instance.decryptBlock(this._block),this._len=dr(this._block,0),o=4+this._len-this._block.length),this._len>mn||this._len<5||(o&this._block.length-1)!==0)throw new Error("Bad packet length");if(this._macETM||(this._pktLen=this._block.length-4,this._pktLen&&(this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(this._block.buffer,this._block.byteOffset+4,this._pktLen),0))),e>=r)return}if(this._pktLen<this._len){let s=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||s!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,s):o=t,s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=s,this._pktLen+=s,this._pktLen<this._len||e>=r)return}{let s=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||s!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._macPos):this._mac.set(t,this._macPos),e+=s,this._macPos+=s,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let i=new ln(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._macPos=0,this._macInstance=null;{let s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}};function of(n){++n[11]>>>8&&++n[10]>>>8&&++n[9]>>>8&&++n[8]>>>8&&++n[7]>>>8&&++n[6]>>>8&&++n[5]>>>8&&++n[4]>>>8}var Dc=(()=>{let n=Buffer.alloc(4);return t=>(n[0]=t>>>24,n[1]=t>>>16,n[2]=t>>>8,n[3]=t,n)})();function Qc(n,t){return n.length!==t.length?(Ji(n,n),!1):Ji(n,t)}function Hc(n){if(typeof n!="object"||n===null)throw new Error("Invalid config");if(typeof n.outbound!="object"||n.outbound===null)throw new Error("Invalid outbound");let t=n.outbound;if(typeof t.onWrite!="function")throw new Error("Invalid outbound.onWrite");if(typeof t.cipherInfo!="object"||t.cipherInfo===null)throw new Error("Invalid outbound.cipherInfo");if(!Buffer.isBuffer(t.cipherKey)||t.cipherKey.length!==t.cipherInfo.keyLen)throw new Error("Invalid outbound.cipherKey");if(t.cipherInfo.ivLen&&(!Buffer.isBuffer(t.cipherIV)||t.cipherIV.length!==t.cipherInfo.ivLen))throw new Error("Invalid outbound.cipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>nf)throw new Error("Invalid outbound.seqno");let e=!!t.forceNative;switch(t.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return As&&!e?new is(n):new rs(n);case"chacha20":return gs&&!e?new ns(n):new ts(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid outbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid outbound.macKey");return _s&&!e?new os(n):new ss(n)}}}function Fc(n){if(typeof n!="object"||n===null)throw new Error("Invalid config");if(typeof n.inbound!="object"||n.inbound===null)throw new Error("Invalid inbound");let t=n.inbound;if(typeof t.onPayload!="function")throw new Error("Invalid inbound.onPayload");if(typeof t.decipherInfo!="object"||t.decipherInfo===null)throw new Error("Invalid inbound.decipherInfo");if(!Buffer.isBuffer(t.decipherKey)||t.decipherKey.length!==t.decipherInfo.keyLen)throw new Error("Invalid inbound.decipherKey");if(t.decipherInfo.ivLen&&(!Buffer.isBuffer(t.decipherIV)||t.decipherIV.length!==t.decipherInfo.ivLen))throw new Error("Invalid inbound.decipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>nf)throw new Error("Invalid inbound.seqno");let e=!!t.forceNative;switch(t.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Es&&!e?new us(n):new hs(n);case"chacha20":return ps&&!e?new cs(n):new as(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid inbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid inbound.macKey");return bs&&!e?new ds(n):new ls(n)}}}ff.exports={CIPHER_INFO:Oc,MAC_INFO:Pc,bindingAvailable:!!Zi,init:new Promise(async(n,t)=>{try{lr=await tf()(),Ar=lr._malloc(16),Is=lr.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(e){return t(e)}n()}),NullCipher:es,createCipher:Hc,NullDecipher:fs,createDecipher:Fc}});var An=Ze((Nd,Ef)=>{"use strict";var{createDecipheriv:ys,createECDH:Mc,createHash:_r,createHmac:qc,createSign:Kc,createVerify:Wc,getCiphers:Gc,sign:af,verify:cf}=require("crypto"),Yc=Gc(),{Ber:me}=cr(),$c=Gi().pbkdf,{CIPHER_INFO:Er}=un(),{eddsaSupported:Ss,SUPPORTED_CIPHER:Xc}=nn(),{bufferSlice:Bn,makeBufferParser:jc,readString:Se,readUInt32BE:gr,writeUInt32BE:It}=Wt(),rn=Symbol("Hash Algorithm"),Gt=Symbol("Private key PEM"),jt=Symbol("Public key PEM"),dn=Symbol("Public key SSH"),Kn=Symbol("Decrypted Key"),xs=Object.create(null);{let n=Object.keys(Er);for(let t=0;t<n.length;++t){let e=Er[n[t]].sslName;!e||xs[e]||(xs[e]=Er[n[t]])}}var si=jc();function Yt(n,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
11
+ `);return t.length&63&&(e+=`
12
+ `),`-----BEGIN ${n} KEY-----
13
+ ${e}-----END ${n} KEY-----`}function pr(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return e.set(n,0),e.set(t,n.length),e}function ws(n,t){let e=n.length,r=n._pos||0;for(let i=0;i<t;++i){let s=e-r;if(r>=e||s<4)return!1;let o=gr(n,r);if(s<4+o)return!1;r+=4+o}return n._pos=r,!0}function br(n,t){let e=new me.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.113549.1.1.1"),e.writeNull(),e.endSequence(),e.startSequence(me.BitString),e.writeByte(0),e.startSequence(),e.writeBuffer(n,me.Integer),e.writeBuffer(t,me.Integer),e.endSequence(),e.endSequence(),e.endSequence(),Yt("PUBLIC",e.buffer)}function Ir(n,t){let e=Buffer.allocUnsafe(15+t.length+4+n.length);It(e,7,0),e.utf8Write("ssh-rsa",4,7);let r=11;return It(e,t.length,r),e.set(t,r+=4),It(e,n.length,r+=t.length),e.set(n,r+4),e}var hf=(()=>{function n(r,i,s,o,f,a,h,d){let l=new me.Writer;return l.startSequence(),l.writeInt(0,me.Integer),l.writeBuffer(r,me.Integer),l.writeBuffer(i,me.Integer),l.writeBuffer(s,me.Integer),l.writeBuffer(o,me.Integer),l.writeBuffer(f,me.Integer),l.writeBuffer(a,me.Integer),l.writeBuffer(h,me.Integer),l.writeBuffer(d,me.Integer),l.endSequence(),l.buffer}function t(r){return BigInt(`0x${r.hexSlice(0,r.length)}`)}function e(r){let i=r.toString(16);if((i.length&1)!==0)i=`0${i}`;else{let s=i.charCodeAt(0);(s===56||s===57||s>=97&&s<=102)&&(i=`00${i}`)}return Buffer.from(i,"hex")}return function(i,s,o,f,a,h){let d=t(o),l=e(d%(t(a)-1n)),_=e(d%(t(h)-1n));return Yt("RSA PRIVATE",n(i,s,o,a,h,l,_,f))}})();function xr(n,t,e,r){let i=new me.Writer;return i.startSequence(),i.startSequence(),i.writeOID("1.2.840.10040.4.1"),i.startSequence(),i.writeBuffer(n,me.Integer),i.writeBuffer(t,me.Integer),i.writeBuffer(e,me.Integer),i.endSequence(),i.endSequence(),i.startSequence(me.BitString),i.writeByte(0),i.writeBuffer(r,me.Integer),i.endSequence(),i.endSequence(),Yt("PUBLIC",i.buffer)}function yr(n,t,e,r){let i=Buffer.allocUnsafe(15+n.length+4+t.length+4+e.length+4+r.length);It(i,7,0),i.utf8Write("ssh-dss",4,7);let s=11;return It(i,n.length,s),i.set(n,s+=4),It(i,t.length,s+=n.length),i.set(t,s+=4),It(i,e.length,s+=t.length),i.set(e,s+=4),It(i,r.length,s+=e.length),i.set(r,s+4),i}function uf(n,t,e,r,i){let s=new me.Writer;return s.startSequence(),s.writeInt(0,me.Integer),s.writeBuffer(n,me.Integer),s.writeBuffer(t,me.Integer),s.writeBuffer(e,me.Integer),s.writeBuffer(r,me.Integer),s.writeBuffer(i,me.Integer),s.endSequence(),Yt("DSA PRIVATE",s.buffer)}function lf(n){let t=new me.Writer;return t.startSequence(),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(me.BitString),t.writeByte(0),t._ensure(n.length),t._buf.set(n,t._offset),t._offset+=n.length,t.endSequence(),t.endSequence(),Yt("PUBLIC",t.buffer)}function df(n){let t=Buffer.allocUnsafe(19+n.length);return It(t,11,0),t.utf8Write("ssh-ed25519",4,11),It(t,n.length,15),t.set(n,19),t}function Vc(n){let t=new me.Writer;return t.startSequence(),t.writeInt(0,me.Integer),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(me.OctetString),t.writeBuffer(n,me.OctetString),t.endSequence(),t.endSequence(),Yt("PRIVATE",t.buffer)}function ms(n,t){let e=new me.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.10045.2.1"),e.writeOID(n),e.endSequence(),e.startSequence(me.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),Yt("PUBLIC",e.buffer)}function Bs(n,t){let e;switch(n){case"1.2.840.10045.3.1.7":e="nistp256";break;case"1.3.132.0.34":e="nistp384";break;case"1.3.132.0.35":e="nistp521";break;default:return}let r=Buffer.allocUnsafe(39+t.length);return It(r,19,0),r.utf8Write(`ecdsa-sha2-${e}`,4,19),It(r,8,23),r.utf8Write(e,27,8),It(r,t.length,35),r.set(t,39),r}function zc(n,t,e){let r=new me.Writer;return r.startSequence(),r.writeInt(1,me.Integer),r.writeBuffer(e,me.OctetString),r.startSequence(160),r.writeOID(n),r.endSequence(),r.startSequence(161),r.startSequence(me.BitString),r.writeByte(0),r._ensure(t.length),r._buf.set(t,r._offset),r._offset+=t.length,r.endSequence(),r.endSequence(),r.endSequence(),Yt("EC PRIVATE",r.buffer)}function Jc(n,t){let e=Mc(n);return e.setPrivateKey(t),e.getPublicKey()}var Sr={sign:typeof af=="function"?function(t,e){let r=this[Gt];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[rn]);try{return af(e,t,r)}catch(i){return i}}:function(t,e){let r=this[Gt];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[rn]);let i=Kc(e);i.update(t);try{return i.sign(r)}catch(s){return s}},verify:typeof cf=="function"?function(t,e,r){let i=this[jt];if(i===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[rn]);try{return cf(r,t,i,e)}catch(s){return s}}:function(t,e,r){let i=this[jt];if(i===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[rn]);let s=Wc(r);s.update(t);try{return s.verify(i,e)}catch(o){return o}},isPrivateKey:function(){return this[Gt]!==null},getPrivatePEM:function(){return this[Gt]},getPublicPEM:function(){return this[jt]},getPublicSSH:function(){return this[dn]},equals:function(t){let e=_f(t);return e instanceof Error?!1:this.type===e.type&&this[Gt]===e[Gt]&&this[jt]===e[jt]&&this[dn].equals(e[dn])}};function oi(n,t,e,r,i,s,o){this.type=n,this.comment=t,this[Gt]=e,this[jt]=r,this[dn]=i,this[rn]=s,this[Kn]=o}oi.prototype=Sr;{let t=function(e,r,i){let s=[];if(e.length<8)return new Error("Malformed OpenSSH private key");let o=gr(e,0),f=gr(e,4);if(o!==f)return i?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");e._pos=8;let a,h;for(a=0;a<r;++a){let l,_,p,x,I=Se(e,e._pos,!0);if(I===void 0)return new Error("Malformed OpenSSH private key");switch(I){case"ssh-rsa":{let N=Se(e,e._pos);if(N===void 0)return new Error("Malformed OpenSSH private key");let D=Se(e,e._pos);if(D===void 0)return new Error("Malformed OpenSSH private key");let Z=Se(e,e._pos);if(Z===void 0)return new Error("Malformed OpenSSH private key");let O=Se(e,e._pos);if(O===void 0)return new Error("Malformed OpenSSH private key");let V=Se(e,e._pos);if(V===void 0)return new Error("Malformed OpenSSH private key");let ee=Se(e,e._pos);if(ee===void 0)return new Error("Malformed OpenSSH private key");p=br(N,D),x=Ir(N,D),_=hf(N,D,Z,O,V,ee),l="sha1";break}case"ssh-dss":{let N=Se(e,e._pos);if(N===void 0)return new Error("Malformed OpenSSH private key");let D=Se(e,e._pos);if(D===void 0)return new Error("Malformed OpenSSH private key");let Z=Se(e,e._pos);if(Z===void 0)return new Error("Malformed OpenSSH private key");let O=Se(e,e._pos);if(O===void 0)return new Error("Malformed OpenSSH private key");let V=Se(e,e._pos);if(V===void 0)return new Error("Malformed OpenSSH private key");p=xr(N,D,Z,O),x=yr(N,D,Z,O),_=uf(N,D,Z,O,V),l="sha1";break}case"ssh-ed25519":{if(!Ss)return new Error(`Unsupported OpenSSH private key type: ${I}`);let N=Se(e,e._pos);if(N===void 0||N.length!==32)return new Error("Malformed OpenSSH private key");let D=Se(e,e._pos);if(D===void 0||D.length!==64)return new Error("Malformed OpenSSH private key");p=lf(N),x=df(N),_=Vc(Bn(D,0,32)),l=null;break}case"ecdsa-sha2-nistp256":l="sha256",h="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":l===void 0&&(l="sha384",h="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(l===void 0&&(l="sha512",h="1.3.132.0.35"),!ws(e,1))return new Error("Malformed OpenSSH private key");let N=Se(e,e._pos);if(N===void 0)return new Error("Malformed OpenSSH private key");let D=Se(e,e._pos);if(D===void 0)return new Error("Malformed OpenSSH private key");p=ms(h,N),x=Bs(h,N),_=zc(h,N,D);break}default:return new Error(`Unsupported OpenSSH private key type: ${I}`)}let k=Se(e,e._pos,!0);if(k===void 0)return new Error("Malformed OpenSSH private key");s.push(new oi(I,k,_,p,x,l,i))}let d=0;for(a=e._pos;a<e.length;++a)if(e[a]!==++d%255)return new Error("Malformed OpenSSH private key");return s},n=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;oi.parse=(e,r)=>{let i=n.exec(e);if(i===null)return null;let s,o=Buffer.from(i[1],"base64");if(o.length<31)return new Error("Malformed OpenSSH private key");let f=o.utf8Slice(0,15);if(f!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${f}`);let a=Se(o,15,!0);if(a===void 0)return new Error("Malformed OpenSSH private key");if(a!=="none"&&Xc.indexOf(a)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${a}`);let h=Se(o,o._pos,!0);if(h===void 0)return new Error("Malformed OpenSSH private key");if(h!=="none"){if(a==="none")return new Error("Malformed OpenSSH private key");if(h!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${h}`);if(!r)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(a!=="none")return new Error("Malformed OpenSSH private key");let d,l,_;a!=="none"&&(d=Er[a]);let p=Se(o,o._pos);if(p===void 0)return new Error("Malformed OpenSSH private key");if(p.length)switch(h){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let I=Se(p,0);if(I===void 0||p._pos+4>p.length)return new Error("Malformed OpenSSH private key");let k=gr(p,p._pos),N=Buffer.allocUnsafe(d.keyLen+d.ivLen);if($c(r,r.length,I,I.length,N,N.length,k)!==0)return new Error("Failed to generate information to decrypt key");l=Bn(N,0,d.keyLen),_=Bn(N,d.keyLen,N.length);break}}else if(h!=="none")return new Error("Malformed OpenSSH private key");if(o._pos+3>=o.length)return new Error("Malformed OpenSSH private key");let x=gr(o,o._pos);if(o._pos+=4,x>0){for(let k=0;k<x;++k){let N=Se(o,o._pos);if(N===void 0)return new Error("Malformed OpenSSH private key");if(Se(N,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let I=Se(o,o._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");if(l!==void 0){if(I.length<d.blockLen||I.length%d.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let k={authTagLength:d.authLen},N=ys(d.sslName,l,_,k);if(N.setAutoPadding(!1),d.authLen>0){if(o.length-o._pos<d.authLen)return new Error("Malformed OpenSSH private key");N.setAuthTag(Bn(o,o._pos,o._pos+=d.authLen))}I=pr(N.update(I),N.final())}catch(k){return k}}if(o._pos!==o.length)return new Error("Malformed OpenSSH private key");s=t(I,x,l!==void 0)}else s=[];return s instanceof Error?s:s[0]}}function fi(n,t,e,r,i,s,o){this.type=n,this.comment=t,this[Gt]=e,this[jt]=r,this[dn]=i,this[rn]=s,this[Kn]=o}fi.prototype=Sr;{let n=/^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----(?:\r\n|\n)((?:[^:]+:\s*[\S].*(?:\r\n|\n))*)([\s\S]+)(?:\r\n|\n)-----END (RSA|DSA|EC) PRIVATE KEY-----$/;fi.parse=(t,e)=>{let r=n.exec(t);if(r===null)return null;let i=Buffer.from(r[3],"base64"),s=r[2],o=!1;if(s!==void 0){s=s.split(/\r\n|\n/g);for(let x=0;x<s.length;++x){let I=s[x],k=I.indexOf(":");if(I.slice(0,k)==="DEK-Info"){let N=I.slice(k+2);if(k=N.indexOf(","),k===-1)continue;let D=N.slice(0,k).toLowerCase();if(Yc.indexOf(D)===-1)return new Error(`Cipher (${D}) not supported for encrypted OpenSSH private key`);let Z=xs[D];if(!Z)return new Error(`Cipher (${D}) not supported for encrypted OpenSSH private key`);let O=Buffer.from(N.slice(k+1),"hex");if(O.length!==Z.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!e)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let V=Bn(O,0,8),ee=_r("md5").update(e).update(V).digest();for(;ee.length<Z.keyLen;)ee=pr(ee,_r("md5").update(ee).update(e).update(V).digest());ee.length>Z.keyLen&&(ee=Bn(ee,0,Z.keyLen));try{let X=ys(D,ee,O);X.setAutoPadding(!1),i=pr(X.update(i),X.final()),o=!0}catch(X){return X}}}}let f,a,h,d,l,_,p="Malformed OpenSSH private key";switch(o&&(p+=". Bad passphrase?"),r[1]){case"RSA":f="ssh-rsa",a=Yt("RSA PRIVATE",i);try{_=new me.Reader(i),_.readSequence(),_.readInt();let x=_.readString(me.Integer,!0);if(x===null)return new Error(p);let I=_.readString(me.Integer,!0);if(I===null)return new Error(p);h=br(x,I),d=Ir(x,I)}catch{return new Error(p)}l="sha1";break;case"DSA":f="ssh-dss",a=Yt("DSA PRIVATE",i);try{_=new me.Reader(i),_.readSequence(),_.readInt();let x=_.readString(me.Integer,!0);if(x===null)return new Error(p);let I=_.readString(me.Integer,!0);if(I===null)return new Error(p);let k=_.readString(me.Integer,!0);if(k===null)return new Error(p);let N=_.readString(me.Integer,!0);if(N===null)return new Error(p);h=xr(x,I,k,N),d=yr(x,I,k,N)}catch{return new Error(p)}l="sha1";break;case"EC":{let x,I,k;try{_=new me.Reader(i),_.readSequence(),_.readInt(),I=_.readString(me.OctetString,!0),_.readByte();let D=_.readLength();if(D!==null){if(_._offset=D,k=_.readOID(),k===null)return new Error(p);switch(k){case"1.2.840.10045.3.1.7":x="prime256v1",f="ecdsa-sha2-nistp256",l="sha256";break;case"1.3.132.0.34":x="secp384r1",f="ecdsa-sha2-nistp384",l="sha384";break;case"1.3.132.0.35":x="secp521r1",f="ecdsa-sha2-nistp521",l="sha512";break;default:return new Error(`Unsupported private key EC OID: ${k}`)}}else return new Error(p)}catch{return new Error(p)}a=Yt("EC PRIVATE",i);let N=Jc(x,I);h=ms(k,N),d=Bs(k,N);break}}return new fi(f,"",a,h,d,l,o)}}function ai(n,t,e,r,i,s,o){this.type=n,this.comment=t,this[Gt]=e,this[jt]=r,this[dn]=i,this[rn]=s,this[Kn]=o}ai.prototype=Sr;{let n=Buffer.alloc(0),t=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e=Buffer.from([0,0,0,0]),r=Buffer.from([0,0,0,1]),i=/^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\r?\nEncryption: (aes256-cbc|none)\r?\nComment: ([^\r\n]*)\r?\nPublic-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-MAC: ([^\r\n]+)/;ai.parse=(s,o)=>{let f=i.exec(s);if(f===null)return null;let a=f[2],h=a!=="none";if(h&&!o)return new Error("Encrypted PPK private key detected, but no passphrase given");let d=Buffer.from(f[5],"base64");if(h){let v=Er[a],M=pr(_r("sha1").update(e).update(o).digest(),_r("sha1").update(r).update(o).digest());M.length>v.keyLen&&(M=Bn(M,0,v.keyLen));try{let Q=ys(v.sslName,M,t);Q.setAutoPadding(!1),d=pr(Q.update(d),Q.final())}catch(Q){return Q}}let l=f[1],_=f[3],p=Buffer.from(f[4],"base64"),x=f[6],I=l.length,k=a.length,N=Buffer.byteLength(_),D=p.length,Z=d.length,O=Buffer.allocUnsafe(4+I+4+k+4+N+4+D+4+Z),V=0;if(It(O,I,V),O.utf8Write(l,V+=4,I),It(O,k,V+=I),O.utf8Write(a,V+=4,k),It(O,N,V+=k),O.utf8Write(_,V+=4,N),It(O,D,V+=N),O.set(p,V+=4),It(O,Z,V+=D),O.set(d,V+4),o||(o=n),qc("sha1",_r("sha1").update("putty-private-key-file-mac-key").update(o).digest()).update(O).digest("hex")!==x)return h?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let X,y,S;switch(p._pos=0,ws(p,1),l){case"ssh-rsa":{let v=Se(p,p._pos);if(v===void 0)return new Error("Malformed PPK public key");let M=Se(p,p._pos);if(M===void 0)return new Error("Malformed PPK public key");let Q=Se(d,0);if(Q===void 0)return new Error("Malformed PPK private key");let re=Se(d,d._pos);if(re===void 0)return new Error("Malformed PPK private key");let J=Se(d,d._pos);if(J===void 0)return new Error("Malformed PPK private key");let j=Se(d,d._pos);if(j===void 0)return new Error("Malformed PPK private key");X=br(M,v),y=Ir(M,v),S=hf(M,v,Q,j,re,J);break}case"ssh-dss":{let v=Se(p,p._pos);if(v===void 0)return new Error("Malformed PPK public key");let M=Se(p,p._pos);if(M===void 0)return new Error("Malformed PPK public key");let Q=Se(p,p._pos);if(Q===void 0)return new Error("Malformed PPK public key");let re=Se(p,p._pos);if(re===void 0)return new Error("Malformed PPK public key");let J=Se(d,0);if(J===void 0)return new Error("Malformed PPK private key");X=xr(v,M,Q,re),y=yr(v,M,Q,re),S=uf(v,M,Q,re,J);break}}return new ai(l,_,S,X,y,"sha1",h)}}function hi(n,t,e,r,i){this.type=n,this.comment=t,this[Gt]=null,this[jt]=e,this[dn]=r,this[rn]=i,this[Kn]=!1}hi.prototype=Sr;{let n;Ss?n=/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:n=/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,hi.parse=t=>{let e=n.exec(t);if(e===null)return null;let r=e[1],i=e[2],s=Buffer.from(e[3],"base64"),o=e[4]||"",f=Se(s,s._pos,!0);return f===void 0||f.indexOf(i)!==0?new Error("Malformed OpenSSH public key"):Cs(s,i,o,r)}}function ci(n,t,e,r,i){this.type=n,this.comment=t,this[Gt]=null,this[jt]=e,this[dn]=r,this[rn]=i,this[Kn]=!1}ci.prototype=Sr;{let n=/^---- BEGIN SSH2 PUBLIC KEY ----(?:\r?\n)((?:.{0,72}\r?\n)+)---- END SSH2 PUBLIC KEY ----$/,t=/^[A-Z0-9a-z/+=\r\n]+$/,e=/^([\x21-\x39\x3B-\x7E]{1,64}): ((?:[^\\]*\\\r?\n)*[^\r\n]+)\r?\n/gm,r=/\\\r?\n/g;ci.parse=i=>{let s=n.exec(i);if(s===null)return null;let o=s[1],f=0,a="";for(;s=e.exec(o);){let p=s[1],x=s[2].replace(r,"");if(x.length>1024)return e.lastIndex=0,new Error("Malformed RFC4716 public key");f=e.lastIndex,p.toLowerCase()==="comment"&&(a=x,a.length>1&&a.charCodeAt(0)===34&&a.charCodeAt(a.length-1)===34&&(a=a.slice(1,-1)))}let h=o.slice(f);if(!t.test(h))return new Error("Malformed RFC4716 public key");h=Buffer.from(h,"base64");let d=Se(h,0,!0);if(d===void 0)return new Error("Malformed RFC4716 public key");let l=null,_=null;switch(d){case"ssh-rsa":{let p=Se(h,h._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let x=Se(h,h._pos);if(x===void 0)return new Error("Malformed RFC4716 public key");l=br(x,p),_=Ir(x,p);break}case"ssh-dss":{let p=Se(h,h._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let x=Se(h,h._pos);if(x===void 0)return new Error("Malformed RFC4716 public key");let I=Se(h,h._pos);if(I===void 0)return new Error("Malformed RFC4716 public key");let k=Se(h,h._pos);if(k===void 0)return new Error("Malformed RFC4716 public key");l=xr(p,x,I,k),_=yr(p,x,I,k);break}default:return new Error("Malformed RFC4716 public key")}return new ci(d,a,l,_,"sha1")}}function Cs(n,t,e,r){if(!Af(t))return new Error(`Unsupported OpenSSH public key type: ${t}`);let i,s,o=null,f=null;switch(t){case"ssh-rsa":{let a=Se(n,n._pos||0);if(a===void 0)return new Error("Malformed OpenSSH public key");let h=Se(n,n._pos);if(h===void 0)return new Error("Malformed OpenSSH public key");o=br(h,a),f=Ir(h,a),i="sha1";break}case"ssh-dss":{let a=Se(n,n._pos||0);if(a===void 0)return new Error("Malformed OpenSSH public key");let h=Se(n,n._pos);if(h===void 0)return new Error("Malformed OpenSSH public key");let d=Se(n,n._pos);if(d===void 0)return new Error("Malformed OpenSSH public key");let l=Se(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");o=xr(a,h,d,l),f=yr(a,h,d,l),i="sha1";break}case"ssh-ed25519":{let a=Se(n,n._pos||0);if(a===void 0||a.length!==32)return new Error("Malformed OpenSSH public key");o=lf(a),f=df(a),i=null;break}case"ecdsa-sha2-nistp256":i="sha256",s="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":i===void 0&&(i="sha384",s="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(i===void 0&&(i="sha512",s="1.3.132.0.35"),!ws(n,1))return new Error("Malformed OpenSSH public key");let a=Se(n,n._pos||0);if(a===void 0)return new Error("Malformed OpenSSH public key");o=ms(s,a),f=Bs(s,a);break}default:return new Error(`Unsupported OpenSSH public key type: ${t}`)}return new hi(r,e,o,f,i)}function Af(n){switch(n){case"ssh-rsa":case"ssh-dss":case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":return!0;case"ssh-ed25519":if(Ss)return!0;default:return!1}}function gf(n){return n?typeof n[Kn]=="boolean":!1}function _f(n,t){if(gf(n))return n;let e;if(Buffer.isBuffer(n))e=n,n=n.utf8Slice(0,n.length).trim();else if(typeof n=="string")n=n.trim();else return new Error("Key data must be a Buffer or string");if(t!=null){if(typeof t=="string")t=Buffer.from(t);else if(!Buffer.isBuffer(t))return new Error("Passphrase must be a string or Buffer when supplied")}let r;if((r=oi.parse(n,t))!==null||(r=fi.parse(n,t))!==null||(r=ai.parse(n,t))!==null||(r=hi.parse(n))!==null||(r=ci.parse(n))!==null)return r;if(e){si.init(e,0);let i=si.readString(!0);i!==void 0&&(n=si.readRaw(),n!==void 0&&(r=Cs(n,i,"",i),r instanceof Error&&(r=null))),si.clear()}return r||new Error("Unsupported key format")}Ef.exports={isParsedKey:gf,isSupportedKeyType:Af,parseDERKey:(n,t)=>Cs(n,t,"",t),parseKey:_f}});var Ls=Ze((Ud,Cf)=>{"use strict";var{Socket:xf}=require("net"),{Duplex:yf}=require("stream"),{resolve:Zc}=require("path"),{readFile:pf}=require("fs"),{execFile:eh,spawn:th}=require("child_process"),{isParsedKey:bf,parseKey:wr}=An(),{makeBufferParser:nh,readUInt32BE:vs,writeUInt32BE:vt,writeUInt32LE:If}=Wt();function mr(n){let t=!1;return(...e)=>{t||(t=!0,n(...e))}}function rh(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return n.copy(e,0),t.copy(e,n.length),e}function Rs(){}var ih=Buffer.alloc(0),at=nh(),Br=class{getIdentities(t){t(new Error("Missing getIdentities() implementation"))}sign(t,e,r,i){typeof r=="function"&&(i=r),i(new Error("Missing sign() implementation"))}},Gn=class extends Br{constructor(t){super(),this.socketPath=t}getStream(t){t=mr(t);let e=new xf;e.on("connect",()=>{t(null,e)}),e.on("close",r).on("end",r).on("error",r),e.connect(this.socketPath);function r(){try{e.destroy()}catch{}t(new Error("Failed to connect to agent"))}}getIdentities(t){t=mr(t),this.getStream((e,r)=>{function i(o){if(r)try{r.destroy()}catch{}o||(o=new Error("Failed to retrieve identities from agent")),t(o)}if(e)return i(e);let s=new Ns(!0);s.on("error",i),s.pipe(r).pipe(s),r.on("close",i).on("end",i).on("error",i),s.getIdentities((o,f)=>{if(o)return i(o);try{r.destroy()}catch{}t(null,f)})})}sign(t,e,r,i){typeof r=="function"?(i=r,r=void 0):(typeof r!="object"||r===null)&&(r=void 0),i=mr(i),this.getStream((s,o)=>{function f(h){if(o)try{o.destroy()}catch{}h||(h=new Error("Failed to sign data with agent")),i(h)}if(s)return f(s);let a=new Ns(!0);a.on("error",f),a.pipe(o).pipe(a),o.on("close",f).on("end",f).on("error",f),a.sign(t,e,r,(h,d)=>{if(h)return f(h);try{o.destroy()}catch{}i(null,d)})})}},Sf=(()=>{let o=Zc(__dirname,"..","util/pagent.exe"),f={10:new Error("Invalid pagent.exe arguments"),11:new Error("Pageant is not running"),12:new Error("pagent.exe could not create an mmap"),13:new Error("pagent.exe could not set mode for stdin"),14:new Error("pagent.exe could not set mode for stdout"),15:new Error("pagent.exe did not get expected input payload")};function a(d){d.buffer=null,d.proc&&(d.proc.kill(),d.proc=void 0)}class h extends yf{constructor(){super(),this.proc=void 0,this.buffer=null}_read(l){}_write(l,_,p){if(this.buffer===null)this.buffer=l;else{let N=Buffer.allocUnsafe(this.buffer.length+l.length);this.buffer.copy(N,0),l.copy(N,this.buffer.length),this.buffer=N}if(this.buffer.length<4)return p();let x=vs(this.buffer,0);if(this.buffer.length-4<x)return p();if(l=this.buffer.slice(0,4+x),this.buffer.length>4+x)return p(new Error("Unexpected multiple agent requests"));this.buffer=null;let I,k=this.proc=th(o,[l.length]);k.stdout.on("data",N=>{this.push(N)}),k.on("error",N=>{I=N,p(I)}),k.on("close",N=>{if(this.proc=void 0,!I){if(I=f[N])return p(I);p()}}),k.stdin.end(l)}_final(l){a(this),l()}_destroy(l,_){a(this),_()}}return class extends Gn{getStream(l){l(null,new h)}}})(),wf=(()=>{let n=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Gn{getStream(e){e=mr(e);let r=this.socketPath,i=!1;pf(r,function s(o,f){if(o){if(i)return e(new Error("Invalid cygwin unix socket path"));eh("cygpath",["-w",r],(ee,X,y)=>{if(ee||X.length===0)return e(new Error("Invalid cygwin unix socket path"));i=!0,r=X.toString().replace(/[\r\n]/g,""),pf(r,s)});return}let a=n.exec(f.toString("ascii"));if(!a)return e(new Error("Malformed cygwin unix socket file"));let h,d=0,l=!1,_=[],p,x=Buffer.alloc(12),I=parseInt(a[1],10),k=a[2].replace(/-/g,""),N=Buffer.allocUnsafe(16);for(let ee=0,X=0;X<32;++ee,X+=2)N[ee]=parseInt(k.substring(X,X+2),16);for(let ee=0;ee<16;ee+=4)If(N,vs(N,ee),ee);V();function D(){d=0,h="secret",p.write(N)}function Z(ee){if(d+=ee.length,h==="secret"){d===16&&(d=0,h="creds",p.write(x));return}if(h==="creds"&&(l||_.push(ee),d===12)){if(p.removeListener("connect",D),p.removeListener("data",Z),p.removeListener("error",O),p.removeListener("end",O),p.removeListener("close",O),l)return e(null,p);l=!0,x=Buffer.concat(_),If(x,process.pid,0),p.on("error",()=>{}),p.destroy(),V()}}function O(){e(new Error("Problem negotiating cygwin unix socket security"))}function V(){p=new xf,p.on("connect",D),p.on("data",Z),p.on("error",O),p.on("end",O),p.on("close",O),p.connect(I)}})}}})(),sh=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function mf(n){return process.platform==="win32"&&!sh.test(n)?n==="pageant"?new Sf:new wf(n):new Gn(n)}var Ns=(()=>{function h(y){let S;for(;y[D].length;){let v=y[D][0][l];if(v===void 0)break;y[D].shift(),S=y.push(v)}return S}let d=Symbol("Inbound Request Type"),l=Symbol("Inbound Request Response"),_=Symbol("Inbound Request Context");class p{constructor(S,v){this[d]=S,this[l]=void 0,this[_]=v}hasResponded(){return this[l]!==void 0}getType(){return this[d]}getContext(){return this[_]}}function x(y,S,v){return S[l]=v,h(y)}function I(y){if(y[O]=null,y[Z]===0){let S=y[D];if(S&&S.length){y[D]=[];for(let v of S)v.cb(new Error("No reply from server"))}}try{y.end()}catch{}setImmediate(()=>{y[X]||y.emit("end"),y[ee]||y.emit("close")})}function k(){this[ee]=!0}function N(){this[X]=!0}let D=Symbol("Requests"),Z=Symbol("Agent Protocol Role"),O=Symbol("Agent Protocol Buffer"),V=Symbol("Agent Protocol Current Message Length"),ee=Symbol("Agent Protocol Closed"),X=Symbol("Agent Protocol Ended");return class extends yf{constructor(S){super({autoDestroy:!0,emitClose:!1}),this[Z]=S?0:1,this[D]=[],this[O]=null,this[V]=-1,this.once("end",N),this.once("close",k)}_read(S){}_write(S,v,M){this[O]===null?this[O]=S:this[O]=rh(this[O],S);let Q=this[O],re=Q.length,J=0;for(;J<re&&!(re<5||(this[V]===-1&&(this[V]=vs(Q,J)),re<4+this[V]));){let j=Q[J+=4];if(++J,this[Z]===0){if(this[D].length===0)return M(new Error("Received unexpected message from server"));let te=this[D].shift();switch(j){case 5:te.cb(new Error("Agent responded with failure"));break;case 12:{if(te.type!==11)return M(new Error("Agent responded with wrong message type"));at.init(Q,J);let ie=at.readUInt32BE();if(ie===void 0)return at.clear(),M(new Error("Malformed agent response"));let T=[];for(let F=0;F<ie;++F){let H=at.readString();if(H===void 0)return at.clear(),M(new Error("Malformed agent response"));let $=at.readString(!0);if($===void 0)return at.clear(),M(new Error("Malformed agent response"));H=wr(H),!(H instanceof Error)&&(H.comment=H.comment||$,T.push(H))}J=at.pos(),at.clear(),te.cb(null,T);break}case 14:{if(te.type!==13)return M(new Error("Agent responded with wrong message type"));at.init(Q,J);let ie=at.readString();if(J=at.pos(),at.clear(),ie===void 0)return M(new Error("Malformed agent response"));if(at.init(ie,0),at.readString(!0),ie=at.readString(),at.clear(),ie===void 0)return M(new Error("Malformed OpenSSH signature format"));te.cb(null,ie);break}default:return M(new Error("Agent responded with unsupported message type"))}}else switch(j){case 11:{let te=new p(j);this[D].push(te),this.emit("identities",te);break}case 13:{at.init(Q,J);let te=at.readString(),ie=at.readString(),T=at.readUInt32BE();if(J=at.pos(),at.clear(),T===void 0){let le=new p(j);return this[D].push(le),this.failureReply(le)}if(te=wr(te),te instanceof Error){let le=new p(j);return this[D].push(le),this.failureReply(le)}let F={hash:void 0},H;te.type==="ssh-rsa"&&(T&2?(H="rsa-sha2-256",F.hash="sha256"):T&4&&(H="rsa-sha2-512",F.hash="sha512")),H===void 0&&(H=te.type);let $=new p(j,H);this[D].push($),this.emit("sign",$,te,ie,F);break}default:{let te=new p(j);this[D].push(te),this.failureReply(te)}}if(this[V]=-1,J===re){this[O]=null;break}else this[O]=Q=Q.slice(J),re=Q.length,J=0}M()}_destroy(S,v){I(this),v()}_final(S){I(this),S()}sign(S,v,M,Q){if(this[Z]!==0)throw new Error("Client-only method called with server role");typeof M=="function"?(Q=M,M=void 0):(typeof M!="object"||M===null)&&(M=void 0);let re=0;if(S=wr(S),S instanceof Error)throw new Error("Invalid public key argument");if(S.type==="ssh-rsa"&&M)switch(M.hash){case"sha256":re=2;break;case"sha512":re=4;break}S=S.getPublicSSH();let J=13,j=S.length,te=v.length,ie=0,T=Buffer.allocUnsafe(9+j+4+te+4);return vt(T,T.length-4,ie),T[ie+=4]=J,vt(T,j,++ie),S.copy(T,ie+=4),vt(T,te,ie+=j),v.copy(T,ie+=4),vt(T,re,ie+=te),typeof Q!="function"&&(Q=Rs),this[D].push({type:J,cb:Q}),this.push(T)}getIdentities(S){if(this[Z]!==0)throw new Error("Client-only method called with server role");let v=11,M=0,Q=Buffer.allocUnsafe(5);return vt(Q,Q.length-4,M),Q[M+=4]=v,typeof S!="function"&&(S=Rs),this[D].push({type:v,cb:S}),this.push(Q)}failureReply(S){if(this[Z]!==1)throw new Error("Server-only method called with client role");if(!(S instanceof p))throw new Error("Wrong request argument");if(S.hasResponded())return!0;let v=0,M=Buffer.allocUnsafe(5);return vt(M,M.length-4,v),M[v+=4]=5,x(this,S,M)}getIdentitiesReply(S,v){if(this[Z]!==1)throw new Error("Server-only method called with client role");if(!(S instanceof p))throw new Error("Wrong request argument");if(S.hasResponded())return!0;if(S.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(v))throw new Error("Keys argument must be an array");let M=4,Q=[];for(let j=0;j<v.length;++j){let te=v[j];if(typeof te!="object"||te===null)throw new Error(`Invalid key entry: ${te}`);let ie,T;if(bf(te))ie=te;else if(bf(te.pubKey))ie=te.pubKey;else if(typeof te.pubKey!="object"||te.pubKey===null||({pubKey:ie,comment:T}=te.pubKey,ie=wr(ie),ie instanceof Error))continue;T=ie.comment||T,ie=ie.getPublicSSH(),M+=4+ie.length,T&&typeof T=="string"?T=Buffer.from(T):Buffer.isBuffer(T)||(T=ih),M+=4+T.length,Q.push({pubKey:ie,comment:T})}let re=0,J=Buffer.allocUnsafe(5+M);vt(J,J.length-4,re),J[re+=4]=12,vt(J,Q.length,++re),re+=4;for(let j=0;j<Q.length;++j){let{pubKey:te,comment:ie}=Q[j];vt(J,te.length,re),te.copy(J,re+=4),vt(J,ie.length,re+=te.length),re+=4,ie.length&&(ie.copy(J,re),re+=ie.length)}return x(this,S,J)}signReply(S,v){if(this[Z]!==1)throw new Error("Server-only method called with client role");if(!(S instanceof p))throw new Error("Wrong request argument");if(S.hasResponded())return!0;if(S.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(v))throw new Error("Signature argument must be a Buffer");if(v.length===0)throw new Error("Signature argument must be non-empty");let M=0,Q=S.getContext(),re=Buffer.byteLength(Q),J=Buffer.allocUnsafe(13+re+4+v.length);return vt(J,J.length-4,M),J[M+=4]=14,vt(J,4+re+4+v.length,++M),vt(J,re,M+=4),J.utf8Write(Q,M+=4,re),vt(J,v.length,M+=re),v.copy(J,M+=4),x(this,S,J)}}})(),ks=Symbol("Agent"),$t=Symbol("Agent Keys"),sn=Symbol("Agent Keys Index"),Wn=Symbol("Agent Init Callbacks"),Ts=class{constructor(t){if(typeof t=="string")t=mf(t);else if(!Bf(t))throw new Error("Invalid agent argument");this[ks]=t,this[$t]=null,this[sn]=-1,this[Wn]=null}init(t){if(typeof t!="function"&&(t=Rs),this[$t]===null)if(this[Wn]===null){this[Wn]=[t];let e=(...r)=>{process.nextTick(()=>{let i=this[Wn];this[Wn]=null;for(let s of i)s(...r)})};this[ks].getIdentities(mr((r,i)=>{if(r)return e(r);if(!Array.isArray(i))return e(new Error("Agent implementation failed to provide keys"));let s=[];for(let o of i)o=wr(o),!(o instanceof Error)&&s.push(o);this[$t]=s,this[sn]=-1,e()}))}else this[Wn].push(t);else process.nextTick(t)}nextKey(){return this[$t]===null||++this[sn]>=this[$t].length?!1:this[$t][this[sn]]}currentKey(){return this[$t]===null||this[sn]>=this[$t].length?null:this[$t][this[sn]]}pos(){return this[$t]===null||this[sn]>=this[$t].length?-1:this[sn]}reset(){this[sn]=-1}sign(...t){this[ks].sign(...t)}};function Bf(n){return n instanceof Br}Cf.exports={AgentContext:Ts,AgentProtocol:Ns,BaseAgent:Br,createAgent:mf,CygwinAgent:wf,isAgent:Bf,OpenSSHAgent:Gn,PageantAgent:Sf}});var Hs=Ze((Od,kf)=>{"use strict";var{kMaxLength:oh}=require("buffer"),{createInflate:fh,constants:{DEFLATE:ah,INFLATE:ch,Z_DEFAULT_CHUNK:hh,Z_DEFAULT_COMPRESSION:uh,Z_DEFAULT_MEMLEVEL:lh,Z_DEFAULT_STRATEGY:dh,Z_DEFAULT_WINDOWBITS:Ah,Z_PARTIAL_FLUSH:gh}}=require("zlib"),_h=fh()._handle.constructor;function Eh(){throw new Error("Should not get here")}function ph(n,t,e){let r=this._owner,i=new Error(n);i.errno=t,i.code=e,r._err=i}function Qs(n){n._handle&&(n._handle.close(),n._handle=null)}var ui=class{constructor(t){let e=Ah,r=uh,i=lh,s=dh,o=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=hh,this._maxOutputLength=oh,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new _h(t),this._handle._owner=this,this._handle.onerror=ph,this._handle.init(e,r,i,s,this._writeState,Eh,o)}writeSync(t,e){let r=this._handle;if(!r)throw new Error("Invalid Zlib instance");let i=t.length,s=this._chunkSize-this._outOffset,o=0,f,a,h,d=0,l=this._writeState,_=this._outBuffer,p=this._outOffset,x=this._chunkSize;for(;;){if(r.writeSync(gh,t,o,i,_,p,s),this._err)throw this._err;f=l[0],a=l[1];let k=i-a,N=s-f;if(N>0){let D=p===0&&N===_.length?_:_.slice(p,p+N);if(p+=N,h?h.push===void 0?h=[h,D]:h.push(D):h=D,d+=D.byteLength,d>this._maxOutputLength)throw Qs(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(N!==0)throw new Error("have should not go down");if((f===0||p>=x)&&(s=x,p=0,_=Buffer.allocUnsafe(x)),f===0)o+=k,i=a;else break}if(this._outBuffer=_,this._outOffset=p,d===0&&(h=Buffer.alloc(0)),e)return h.totalLen=d,h;if(h.push===void 0)return h;let I=Buffer.allocUnsafe(d);for(let k=0,N=0;k<h.length;++k){let D=h[k];I.set(D,N),N+=D.length}return I}},Us=class{constructor(t){this.allocStart=0,this.allocStartKEX=0,this._protocol=t,this._zlib=new ui(ah)}cleanup(){this._zlib&&Qs(this._zlib)}alloc(t,e){return Buffer.allocUnsafe(t)}finalize(t,e){if(this._protocol._kexinit===void 0||e){let r=this._zlib.writeSync(t,!0),i=this._protocol._cipher.allocPacket(r.totalLen);if(r.push===void 0)i.set(r,5);else for(let s=0,o=5;s<r.length;++s){let f=r[s];i.set(f,o),o+=f.length}return i}return t}},Os=class{constructor(t){this.allocStart=5,this.allocStartKEX=5,this._protocol=t}cleanup(){}alloc(t,e){return this._protocol._kexinit===void 0||e?this._protocol._cipher.allocPacket(t):Buffer.allocUnsafe(t)}finalize(t,e){return t}},Ps=class{constructor(){this._zlib=new ui(ch)}cleanup(){this._zlib&&Qs(this._zlib)}read(t){return this._zlib.writeSync(t,!1)}},Ds=class{cleanup(){}read(t){return t}};kf.exports={PacketReader:Ds,PacketWriter:Os,ZlibPacketReader:Ps,ZlibPacketWriter:Us}});var Lf=Ze((Pd,vf)=>{"use strict";var{bufferSlice:Fs,bufferParser:B,doFatalError:it,sigSSHToASN1:Rf,writeUInt32BE:Nf}=Wt(),{CHANNEL_OPEN_FAILURE:bh,COMPAT:Ih,MESSAGE:ot,TERMINAL_MODE:Tf}=nn(),{parseKey:xh}=An(),yh=Array.from(Object.entries(Tf)).reduce((n,[t,e])=>({...n,[t]:e}),{});vf.exports={[ot.DISCONNECT]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readString(!0),i=B.readString();if(B.clear(),i===void 0)return it(n,"Inbound: Malformed DISCONNECT packet");n._debug&&n._debug(`Inbound: Received DISCONNECT (${e}, "${r}")`);let s=n._handlers.DISCONNECT;s&&s(n,e,r)},[ot.IGNORE]:(n,t)=>{n._debug&&n._debug("Inbound: Received IGNORE")},[ot.UNIMPLEMENTED]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return it(n,"Inbound: Malformed UNIMPLEMENTED packet");n._debug&&n._debug(`Inbound: Received UNIMPLEMENTED (seqno ${e})`)},[ot.DEBUG]:(n,t)=>{B.init(t,1);let e=B.readBool(),r=B.readString(!0),i=B.readString();if(B.clear(),i===void 0)return it(n,"Inbound: Malformed DEBUG packet");n._debug&&n._debug("Inbound: Received DEBUG");let s=n._handlers.DEBUG;s&&s(n,e,r)},[ot.SERVICE_REQUEST]:(n,t)=>{B.init(t,1);let e=B.readString(!0);if(B.clear(),e===void 0)return it(n,"Inbound: Malformed SERVICE_REQUEST packet");n._debug&&n._debug(`Inbound: Received SERVICE_REQUEST (${e})`);let r=n._handlers.SERVICE_REQUEST;r&&r(n,e)},[ot.SERVICE_ACCEPT]:(n,t)=>{B.init(t,1);let e=B.readString(!0);if(B.clear(),e===void 0)return it(n,"Inbound: Malformed SERVICE_ACCEPT packet");n._debug&&n._debug(`Inbound: Received SERVICE_ACCEPT (${e})`);let r=n._handlers.SERVICE_ACCEPT;r&&r(n,e)},[ot.EXT_INFO]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r;if(e!==void 0){r=[];for(let s=0;s<e;++s){let o=B.readString(!0),f=B.readString();if(f!==void 0)if(o==="server-sig-algs"){let a=f.latin1Slice(0,f.length).split(",");r.push({name:o,algs:a});continue}else continue;r=void 0;break}}if(B.clear(),r===void 0)return it(n,"Inbound: Malformed EXT_INFO packet");n._debug&&n._debug("Inbound: Received EXT_INFO");let i=n._handlers.EXT_INFO;i&&i(n,r)},[ot.USERAUTH_REQUEST]:(n,t)=>{B.init(t,1);let e=B.readString(!0),r=B.readString(!0),i=B.readString(!0),s,o;switch(i){case"none":s=null;break;case"password":{let a=B.readBool();if(a!==void 0&&(s=B.readString(!0),s!==void 0&&a)){let h=B.readString(!0);h!==void 0?s={oldPassword:s,newPassword:h}:s=void 0}break}case"publickey":{let a=B.readBool();if(a!==void 0){let h=B.readString(!0),d=h,l=B.readString(),_;switch(h){case"rsa-sha2-256":d="ssh-rsa",_="sha256";break;case"rsa-sha2-512":d="ssh-rsa",_="sha512";break}if(a){let p=B.pos(),x=B.readString();if(x!==void 0&&(x.length>4+h.length+4&&x.utf8Slice(4,4+h.length)===h&&(x=Fs(x,4+h.length+4)),x=Rf(x,d),x)){let I=n._kex.sessionID,k=Buffer.allocUnsafe(4+I.length+p);Nf(k,I.length,0),k.set(I,4),k.set(new Uint8Array(t.buffer,t.byteOffset,p),4+I.length),s={keyAlgo:d,key:l,signature:x,blob:k,hashAlgo:_}}}else s={keyAlgo:d,key:l,hashAlgo:_},o="publickey -- check"}break}case"hostbased":{let a=B.readString(!0),h=a,d=B.readString(),l=B.readString(!0),_=B.readString(!0),p;switch(a){case"rsa-sha2-256":h="ssh-rsa",p="sha256";break;case"rsa-sha2-512":h="ssh-rsa",p="sha512";break}let x=B.pos(),I=B.readString();if(I!==void 0&&(I.length>4+a.length+4&&I.utf8Slice(4,4+a.length)===a&&(I=Fs(I,4+a.length+4)),I=Rf(I,h),I!==void 0)){let k=n._kex.sessionID,N=Buffer.allocUnsafe(4+k.length+x);Nf(N,k.length,0),N.set(k,4),N.set(new Uint8Array(t.buffer,t.byteOffset,x),4+k.length),s={keyAlgo:h,key:d,signature:I,blob:N,localHostname:l,localUsername:_,hashAlgo:p}}break}case"keyboard-interactive":B.skipString(),s=B.readList();break;default:i!==void 0&&(s=B.readRaw())}if(B.clear(),s===void 0)return it(n,"Inbound: Malformed USERAUTH_REQUEST packet");o===void 0&&(o=i),n._authsQueue.push(i),n._debug&&n._debug(`Inbound: Received USERAUTH_REQUEST (${o})`);let f=n._handlers.USERAUTH_REQUEST;f&&f(n,e,r,i,s)},[ot.USERAUTH_FAILURE]:(n,t)=>{B.init(t,1);let e=B.readList(),r=B.readBool();if(B.clear(),r===void 0)return it(n,"Inbound: Malformed USERAUTH_FAILURE packet");n._debug&&n._debug(`Inbound: Received USERAUTH_FAILURE (${e})`),n._authsQueue.shift();let i=n._handlers.USERAUTH_FAILURE;i&&i(n,e,r)},[ot.USERAUTH_SUCCESS]:(n,t)=>{n._debug&&n._debug("Inbound: Received USERAUTH_SUCCESS"),n._authsQueue.shift();let e=n._handlers.USERAUTH_SUCCESS;e&&e(n)},[ot.USERAUTH_BANNER]:(n,t)=>{B.init(t,1);let e=B.readString(!0),r=B.readString();if(B.clear(),r===void 0)return it(n,"Inbound: Malformed USERAUTH_BANNER packet");n._debug&&n._debug("Inbound: Received USERAUTH_BANNER");let i=n._handlers.USERAUTH_BANNER;i&&i(n,e)},60:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 60 without auth");return}switch(n._authsQueue[0]){case"password":{B.init(t,1);let e=B.readString(!0),r=B.readString();if(B.clear(),r===void 0)return it(n,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");n._debug&&n._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let i=n._handlers.USERAUTH_PASSWD_CHANGEREQ;i&&i(n,e);break}case"publickey":{B.init(t,1);let e=B.readString(!0),r=B.readString();if(B.clear(),r===void 0)return it(n,"Inbound: Malformed USERAUTH_PK_OK packet");n._debug&&n._debug("Inbound: Received USERAUTH_PK_OK"),n._authsQueue.shift();let i=n._handlers.USERAUTH_PK_OK;i&&i(n,e,r);break}case"keyboard-interactive":{B.init(t,1);let e=B.readString(!0),r=B.readString(!0);B.readString();let i=B.readUInt32BE(),s;if(i!==void 0){s=new Array(i);let f;for(f=0;f<i;++f){let a=B.readString(!0),h=B.readBool();if(h===void 0)break;s[f]={prompt:a,echo:h}}f!==i&&(s=void 0)}if(B.clear(),s===void 0)return it(n,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_REQUEST");let o=n._handlers.USERAUTH_INFO_REQUEST;o&&o(n,e,r,s);break}default:n._debug&&n._debug("Inbound: Received unexpected payload type 60")}},61:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 61 without auth");return}if(n._authsQueue[0]!=="keyboard-interactive")return it(n,"Inbound: Received unexpected payload type 61");B.init(t,1);let e=B.readUInt32BE(),r;if(e!==void 0){r=new Array(e);let s;for(s=0;s<e;++s){let o=B.readString(!0);if(o===void 0)break;r[s]=o}s!==e&&(r=void 0)}if(B.clear(),r===void 0)return it(n,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let i=n._handlers.USERAUTH_INFO_RESPONSE;i&&i(n,r)},[ot.GLOBAL_REQUEST]:(n,t)=>{B.init(t,1);let e=B.readString(!0),r=B.readBool(),i;if(r!==void 0)switch(e){case"tcpip-forward":case"cancel-tcpip-forward":{let o=B.readString(!0),f=B.readUInt32BE();f!==void 0&&(i={bindAddr:o,bindPort:f});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let o=B.readString(!0);o!==void 0&&(i={socketPath:o});break}case"no-more-sessions@openssh.com":i=null;break;case"hostkeys-00@openssh.com":{for(i=[];B.avail()>0;){let o=B.readString();if(o===void 0){i=void 0;break}let f=xh(o);f instanceof Error||i.push(f)}break}default:i=B.readRaw()}if(B.clear(),i===void 0)return it(n,"Inbound: Malformed GLOBAL_REQUEST packet");n._debug&&n._debug(`Inbound: GLOBAL_REQUEST (${e})`);let s=n._handlers.GLOBAL_REQUEST;s?s(n,e,r,i):n.requestFailure()},[ot.REQUEST_SUCCESS]:(n,t)=>{let e=t.length>1?Fs(t,1):null;n._debug&&n._debug("Inbound: REQUEST_SUCCESS");let r=n._handlers.REQUEST_SUCCESS;r&&r(n,e)},[ot.REQUEST_FAILURE]:(n,t)=>{n._debug&&n._debug("Inbound: Received REQUEST_FAILURE");let e=n._handlers.REQUEST_FAILURE;e&&e(n)},[ot.CHANNEL_OPEN]:(n,t)=>{B.init(t,1);let e=B.readString(!0),r=B.readUInt32BE(),i=B.readUInt32BE(),s=B.readUInt32BE(),o;switch(e){case"forwarded-tcpip":case"direct-tcpip":{let a=B.readString(!0),h=B.readUInt32BE(),d=B.readString(!0),l=B.readUInt32BE();l!==void 0&&(o={type:e,sender:r,window:i,packetSize:s,data:{destIP:a,destPort:h,srcIP:d,srcPort:l}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let a=B.readString(!0);a!==void 0&&(o={type:e,sender:r,window:i,packetSize:s,data:{socketPath:a}});break}case"x11":{let a=B.readString(!0),h=B.readUInt32BE();h!==void 0&&(o={type:e,sender:r,window:i,packetSize:s,data:{srcIP:a,srcPort:h}});break}default:o={type:e,sender:r,window:i,packetSize:s,data:{}}}if(B.clear(),o===void 0)return it(n,"Inbound: Malformed CHANNEL_OPEN packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN (s:${r}, ${e})`);let f=n._handlers.CHANNEL_OPEN;f?f(n,o):n.channelOpenFail(o.sender,bh.ADMINISTRATIVELY_PROHIBITED,"","")},[ot.CHANNEL_OPEN_CONFIRMATION]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readUInt32BE(),i=B.readUInt32BE(),s=B.readUInt32BE(),o=B.avail()?B.readRaw():void 0;if(B.clear(),s===void 0)return it(n,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${e}, s:${r})`);let f=n._handlers.CHANNEL_OPEN_CONFIRMATION;f&&f(n,{recipient:e,sender:r,window:i,packetSize:s,data:o})},[ot.CHANNEL_OPEN_FAILURE]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readUInt32BE(),i=B.readString(!0),s=B.readString();if(B.clear(),s===void 0)return it(n,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${e})`);let o=n._handlers.CHANNEL_OPEN_FAILURE;o&&o(n,e,r,i)},[ot.CHANNEL_WINDOW_ADJUST]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readUInt32BE();if(B.clear(),r===void 0)return it(n,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");n._debug&&n._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`);let i=n._handlers.CHANNEL_WINDOW_ADJUST;i&&i(n,e,r)},[ot.CHANNEL_DATA]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readString();if(B.clear(),r===void 0)return it(n,"Inbound: Malformed CHANNEL_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_DATA (r:${e}, ${r.length})`);let i=n._handlers.CHANNEL_DATA;i&&i(n,e,r)},[ot.CHANNEL_EXTENDED_DATA]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readUInt32BE(),i=B.readString();if(B.clear(),i===void 0)return it(n,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${e}, ${i.length})`);let s=n._handlers.CHANNEL_EXTENDED_DATA;s&&s(n,e,i,r)},[ot.CHANNEL_EOF]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return it(n,"Inbound: Malformed CHANNEL_EOF packet");n._debug&&n._debug(`Inbound: CHANNEL_EOF (r:${e})`);let r=n._handlers.CHANNEL_EOF;r&&r(n,e)},[ot.CHANNEL_CLOSE]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return it(n,"Inbound: Malformed CHANNEL_CLOSE packet");n._debug&&n._debug(`Inbound: CHANNEL_CLOSE (r:${e})`);let r=n._handlers.CHANNEL_CLOSE;r&&r(n,e)},[ot.CHANNEL_REQUEST]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readString(!0),i=B.readBool(),s;if(i!==void 0)switch(r){case"exit-status":s=B.readUInt32BE(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"exit-signal":{let f,a;if(n._compatFlags&Ih.OLD_EXIT){let d=B.readUInt32BE();switch(d){case 1:f="HUP";break;case 2:f="INT";break;case 3:f="QUIT";break;case 6:f="ABRT";break;case 9:f="KILL";break;case 14:f="ALRM";break;case 15:f="TERM";break;default:d!==void 0&&(f=`UNKNOWN (${d})`)}a=!1}else f=B.readString(!0),a=B.readBool(),a===void 0&&(f=void 0);let h=B.readString(!0);B.skipString()!==void 0&&(s={signal:f,coreDumped:a,errorMessage:h}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${f})`);break}case"pty-req":{let f=B.readString(!0),a=B.readUInt32BE(),h=B.readUInt32BE(),d=B.readUInt32BE(),l=B.readUInt32BE(),_=B.readString();if(_!==void 0){B.init(_,1);let p={};for(;B.avail();){let x=B.readByte();if(x===Tf.TTY_OP_END)break;let I=yh[x],k=B.readUInt32BE();if(x===void 0||I===void 0||k===void 0){p=void 0;break}p[I]=k}p!==void 0&&(s={term:f,cols:a,rows:h,width:d,height:l,modes:p})}n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"window-change":{let f=B.readUInt32BE(),a=B.readUInt32BE(),h=B.readUInt32BE(),d=B.readUInt32BE();d!==void 0&&(s={cols:f,rows:a,width:h,height:d}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"x11-req":{let f=B.readBool(),a=B.readString(!0),h=B.readString(),d=B.readUInt32BE();d!==void 0&&(s={single:f,protocol:a,cookie:h,screen:d}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"env":{let f=B.readString(!0),a=B.readString(!0);a!==void 0&&(s={name:f,value:a}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${f}=${a})`);break}case"shell":s=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;case"exec":s=B.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"subsystem":s=B.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"signal":s=B.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"xon-xoff":s=B.readBool(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"auth-agent-req@openssh.com":s=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;default:s=B.avail()?B.readRaw():null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`)}if(B.clear(),s===void 0)return it(n,"Inbound: Malformed CHANNEL_REQUEST packet");let o=n._handlers.CHANNEL_REQUEST;o&&o(n,e,r,i,s)},[ot.CHANNEL_SUCCESS]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return it(n,"Inbound: Malformed CHANNEL_SUCCESS packet");n._debug&&n._debug(`Inbound: CHANNEL_SUCCESS (r:${e})`);let r=n._handlers.CHANNEL_SUCCESS;r&&r(n,e)},[ot.CHANNEL_FAILURE]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return it(n,"Inbound: Malformed CHANNEL_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_FAILURE (r:${e})`);let r=n._handlers.CHANNEL_FAILURE;r&&r(n,e)}}});var li=Ze((Dd,Uf)=>{"use strict";var Ms=new Array(256);[di().HANDLERS,Lf()].forEach(n=>{for(let[t,e]of Object.entries(n))t=+t,isFinite(t)&&t>=0&&t<Ms.length&&(Ms[t]=e)});Uf.exports=Ms});var di=Ze((Hd,Wf)=>{"use strict";var{createDiffieHellman:Sh,createDiffieHellmanGroup:wh,createECDH:mh,createHash:Ks,createPublicKey:Bh,diffieHellman:Ch,generateKeyPairSync:kh,randomFillSync:Rh}=require("crypto"),{Ber:Of}=cr(),{COMPAT:Ws,curve25519Supported:Nh,DEFAULT_KEX:Pf,DEFAULT_SERVER_HOST_KEY:Df,DEFAULT_CIPHER:Ai,DEFAULT_MAC:gi,DEFAULT_COMPRESSION:_i,DISCONNECT_REASON:Me,MESSAGE:nt}=nn(),{CIPHER_INFO:Xn,createCipher:Th,createDecipher:vh,MAC_INFO:Qf}=un(),{parseDERKey:Lh}=An(),{bufferFill:Uh,bufferParser:Fe,convertSignature:Oh,doFatalError:qe,FastBuffer:Ph,sigSSHToASN1:Dh,writeUInt32BE:xt}=Wt(),{PacketReader:Hf,PacketWriter:Ff,ZlibPacketReader:Ei,ZlibPacketWriter:pi}=Hs(),Yn,Qh=2048,Hh=8192,Fh=Buffer.alloc(0);function Mf(n){let t;if(n._compatFlags&Ws.BAD_DHGEX){let e=n._offer.lists.kex,r=e.array,i=!1;for(let s=0;s<r.length;++s)r[s].includes("group-exchange")&&(i||(i=!0,r=r.slice()),r.splice(s--,1));if(i){let s=17+n._offer.totalSize+1+4,o=Buffer.from(r.join(","));s-=e.buffer.length-o.length;let f=n._offer.lists.all,a=new Uint8Array(f.buffer,f.byteOffset+4+e.buffer.length,f.length-(4+e.buffer.length));t=Buffer.allocUnsafe(s),xt(t,o.length,17),t.set(o,21),t.set(a,21+o.length)}}t===void 0&&(t=Buffer.allocUnsafe(17+n._offer.totalSize+1+4),n._offer.copyAllTo(t,17)),n._debug&&n._debug("Outbound: Sending KEXINIT"),t[0]=nt.KEXINIT,Rh(t,1,16),Uh(t,0,t.length-5),n._kexinit=t,n._packetRW.write.allocStart=0;{let e=n._packetRW.write.allocStartKEX,r=n._packetRW.write.alloc(t.length,!0);r.set(t,e),n._cipher.encrypt(n._packetRW.write.finalize(r,!0))}}function qf(n,t){let e={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0}};if(Fe.init(t,17),(e.kex=Fe.readList())===void 0||(e.serverHostKey=Fe.readList())===void 0||(e.cs.cipher=Fe.readList())===void 0||(e.sc.cipher=Fe.readList())===void 0||(e.cs.mac=Fe.readList())===void 0||(e.sc.mac=Fe.readList())===void 0||(e.cs.compress=Fe.readList())===void 0||(e.sc.compress=Fe.readList())===void 0||(e.cs.lang=Fe.readList())===void 0||(e.sc.lang=Fe.readList())===void 0)return Fe.clear(),qe(n,"Received malformed KEXINIT","handshake",Me.KEY_EXCHANGE_FAILED);let r=Fe.pos(),i=r<t.length&&t[r]===1;Fe.clear();let s=n._offer,o=e,f=s.lists.kex.array;if(n._compatFlags&Ws.BAD_DHGEX){let O=!1;for(let V=0;V<f.length;++V)f[V].indexOf("group-exchange")!==-1&&(O||(O=!0,f=f.slice()),f.splice(V--,1))}let a,h,d,l=n._debug;l&&l("Inbound: Handshake in progress"),l&&l(`Handshake: (local) KEX method: ${f}`),l&&l(`Handshake: (remote) KEX method: ${o.kex}`);let _;if(n._server?(h=f,a=o.kex,_=a.indexOf("ext-info-c")!==-1):(h=o.kex,a=f,_=h.indexOf("ext-info-s")!==-1),n._strictMode===void 0&&(n._server?n._strictMode=a.indexOf("kex-strict-c-v00@openssh.com")!==-1:n._strictMode=h.indexOf("kex-strict-s-v00@openssh.com")!==-1,n._strictMode&&(l&&l("Handshake: strict KEX mode enabled"),n._decipher.inSeqno!==1)))return l&&l("Handshake: KEXINIT not first packet in strict KEX mode"),qe(n,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",Me.KEY_EXCHANGE_FAILED);for(d=0;d<a.length&&h.indexOf(a[d])===-1;++d);if(d===a.length)return l&&l("Handshake: no matching key exchange algorithm"),qe(n,"Handshake failed: no matching key exchange algorithm","handshake",Me.KEY_EXCHANGE_FAILED);e.kex=a[d],l&&l(`Handshake: KEX algorithm: ${a[d]}`),i&&(!o.kex.length||a[d]!==o.kex[0])&&(n._skipNextInboundPacket=!0);let p=s.lists.serverHostKey.array;for(l&&l(`Handshake: (local) Host key format: ${p}`),l&&l(`Handshake: (remote) Host key format: ${o.serverHostKey}`),n._server?(h=p,a=o.serverHostKey):(h=o.serverHostKey,a=p),d=0;d<a.length&&h.indexOf(a[d])===-1;++d);if(d===a.length)return l&&l("Handshake: No matching host key format"),qe(n,"Handshake failed: no matching host key format","handshake",Me.KEY_EXCHANGE_FAILED);e.serverHostKey=a[d],l&&l(`Handshake: Host key format: ${a[d]}`);let x=s.lists.cs.cipher.array;for(l&&l(`Handshake: (local) C->S cipher: ${x}`),l&&l(`Handshake: (remote) C->S cipher: ${o.cs.cipher}`),n._server?(h=x,a=o.cs.cipher):(h=o.cs.cipher,a=x),d=0;d<a.length&&h.indexOf(a[d])===-1;++d);if(d===a.length)return l&&l("Handshake: No matching C->S cipher"),qe(n,"Handshake failed: no matching C->S cipher","handshake",Me.KEY_EXCHANGE_FAILED);e.cs.cipher=a[d],l&&l(`Handshake: C->S Cipher: ${a[d]}`);let I=s.lists.sc.cipher.array;for(l&&l(`Handshake: (local) S->C cipher: ${I}`),l&&l(`Handshake: (remote) S->C cipher: ${o.sc.cipher}`),n._server?(h=I,a=o.sc.cipher):(h=o.sc.cipher,a=I),d=0;d<a.length&&h.indexOf(a[d])===-1;++d);if(d===a.length)return l&&l("Handshake: No matching S->C cipher"),qe(n,"Handshake failed: no matching S->C cipher","handshake",Me.KEY_EXCHANGE_FAILED);e.sc.cipher=a[d],l&&l(`Handshake: S->C cipher: ${a[d]}`);let k=s.lists.cs.mac.array;if(l&&l(`Handshake: (local) C->S MAC: ${k}`),l&&l(`Handshake: (remote) C->S MAC: ${o.cs.mac}`),Xn[e.cs.cipher].authLen>0)e.cs.mac="",l&&l("Handshake: C->S MAC: <implicit>");else{for(n._server?(h=k,a=o.cs.mac):(h=o.cs.mac,a=k),d=0;d<a.length&&h.indexOf(a[d])===-1;++d);if(d===a.length)return l&&l("Handshake: No matching C->S MAC"),qe(n,"Handshake failed: no matching C->S MAC","handshake",Me.KEY_EXCHANGE_FAILED);e.cs.mac=a[d],l&&l(`Handshake: C->S MAC: ${a[d]}`)}let N=s.lists.sc.mac.array;if(l&&l(`Handshake: (local) S->C MAC: ${N}`),l&&l(`Handshake: (remote) S->C MAC: ${o.sc.mac}`),Xn[e.sc.cipher].authLen>0)e.sc.mac="",l&&l("Handshake: S->C MAC: <implicit>");else{for(n._server?(h=N,a=o.sc.mac):(h=o.sc.mac,a=N),d=0;d<a.length&&h.indexOf(a[d])===-1;++d);if(d===a.length)return l&&l("Handshake: No matching S->C MAC"),qe(n,"Handshake failed: no matching S->C MAC","handshake",Me.KEY_EXCHANGE_FAILED);e.sc.mac=a[d],l&&l(`Handshake: S->C MAC: ${a[d]}`)}let D=s.lists.cs.compress.array;for(l&&l(`Handshake: (local) C->S compression: ${D}`),l&&l(`Handshake: (remote) C->S compression: ${o.cs.compress}`),n._server?(h=D,a=o.cs.compress):(h=o.cs.compress,a=D),d=0;d<a.length&&h.indexOf(a[d])===-1;++d);if(d===a.length)return l&&l("Handshake: No matching C->S compression"),qe(n,"Handshake failed: no matching C->S compression","handshake",Me.KEY_EXCHANGE_FAILED);e.cs.compress=a[d],l&&l(`Handshake: C->S compression: ${a[d]}`);let Z=s.lists.sc.compress.array;for(l&&l(`Handshake: (local) S->C compression: ${Z}`),l&&l(`Handshake: (remote) S->C compression: ${o.sc.compress}`),n._server?(h=Z,a=o.sc.compress):(h=o.sc.compress,a=Z),d=0;d<a.length&&h.indexOf(a[d])===-1;++d);if(d===a.length)return l&&l("Handshake: No matching S->C compression"),qe(n,"Handshake failed: no matching S->C compression","handshake",Me.KEY_EXCHANGE_FAILED);e.sc.compress=a[d],l&&l(`Handshake: S->C compression: ${a[d]}`),e.cs.lang="",e.sc.lang="",n._kex&&(n._kexinit||Mf(n),n._decipher._onPayload=Kf.bind(n,{firstPacket:!1})),n._kex=Mh(e,n,t),n._kex.remoteExtInfoEnabled=_,n._kex.start()}var Mh=(()=>{function n(o){let f=0,a=o.length;for(;o[f]===0;)++f,--a;let h;return o[f]&128?(h=Buffer.allocUnsafe(1+a),h[0]=0,o.copy(h,1,f),o=h):a!==o.length&&(h=Buffer.allocUnsafe(a),o.copy(h,0,f),o=h),o}class t{constructor(f,a,h){this._protocol=a,this.sessionID=a._kex?a._kex.sessionID:void 0,this.negotiated=f,this.remoteExtInfoEnabled=!1,this._step=1,this._public=null,this._dh=null,this._sentNEWKEYS=!1,this._receivedNEWKEYS=!1,this._finished=!1,this._hostVerified=!1,this._kexinit=a._kexinit,this._remoteKexinit=h,this._identRaw=a._identRaw,this._remoteIdentRaw=a._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(f){if(this._finished)return!1;this._finished=!0;let a=this._protocol._server,h=this.negotiated,d=this.convertPublicKey(this._dhData),l=this.computeSecret(this._dhData);if(l instanceof Error)return l.message=`Error while computing DH secret (${this.type}): ${l.message}`,l.level="handshake",qe(this._protocol,l,Me.KEY_EXCHANGE_FAILED);let _=Ks(this.hashName);Vt(_,a?this._remoteIdentRaw:this._identRaw),Vt(_,a?this._identRaw:this._remoteIdentRaw),Vt(_,a?this._remoteKexinit:this._kexinit),Vt(_,a?this._kexinit:this._remoteKexinit);let p=a?this._hostKey.getPublicSSH():this._hostKey;if(Vt(_,p),this.type==="groupex"){let Z=this.getDHParams(),O=Buffer.allocUnsafe(4);xt(O,this._minBits,0),_.update(O),xt(O,this._prefBits,0),_.update(O),xt(O,this._maxBits,0),_.update(O),Vt(_,Z.prime),Vt(_,Z.generator)}Vt(_,a?d:this.getPublicKey());let x=a?this.getPublicKey():d;Vt(_,x),Vt(_,l);let I=_.digest();if(a){let Z;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":Z="sha256";break;case"rsa-sha2-512":Z="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let O=this._hostKey.sign(I,Z);if(O instanceof Error)return qe(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${O.message}`,"handshake",Me.KEY_EXCHANGE_FAILED);if(O=Oh(O,this._hostKey.type),O===!1)return qe(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",Me.KEY_EXCHANGE_FAILED);let V=this.negotiated.serverHostKey,ee=Buffer.byteLength(V),X=4+ee+4+O.length,y=this._protocol._packetRW.write.allocStartKEX,S=this._protocol._packetRW.write.alloc(5+p.length+4+x.length+4+X,!0);if(S[y]=nt.KEXDH_REPLY,xt(S,p.length,++y),S.set(p,y+=4),xt(S,x.length,y+=p.length),S.set(x,y+=4),xt(S,X,y+=x.length),xt(S,ee,y+=4),S.utf8Write(V,y+=4,ee),xt(S,O.length,y+=ee),S.set(O,y+=4),this._protocol._debug){let v;switch(this.type){case"group":v="KEXDH_REPLY";break;case"groupex":v="KEXDH_GEX_REPLY";break;default:v="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${v}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(S,!0))}else{Fe.init(this._sig,0);let Z=Fe.readString(!0);if(!Z)return qe(this._protocol,"Malformed packet while reading signature","handshake",Me.KEY_EXCHANGE_FAILED);if(Z!==h.serverHostKey)return qe(this._protocol,`Wrong signature type: ${Z}, expected: ${h.serverHostKey}`,"handshake",Me.KEY_EXCHANGE_FAILED);let O=Fe.readString();if(Fe.clear(),O===void 0)return qe(this._protocol,"Malformed packet while reading signature","handshake",Me.KEY_EXCHANGE_FAILED);if(!(O=Dh(O,Z)))return qe(this._protocol,"Malformed signature","handshake",Me.KEY_EXCHANGE_FAILED);let V;{Fe.init(this._hostKey,0);let y=Fe.readString(!0),S=this._hostKey.slice(Fe.pos());if(Fe.clear(),V=Lh(S,y),V instanceof Error)return V.level="handshake",qe(this._protocol,V,Me.KEY_EXCHANGE_FAILED)}let ee;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":ee="sha256";break;case"rsa-sha2-512":ee="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");let X=V.verify(I,O,ee);if(X!==!0)return X instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${X.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),qe(this._protocol,"Handshake failed: signature verification failed","handshake",Me.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(a||!f)&&bi(this);let k,N,D=Z=>{if(k)return bi(this),k.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=Th(k),this._protocol._packetRW.write=N,k=void 0,N=void 0,this._protocol._onHandshakeComplete(h),!1;this.sessionID||(this.sessionID=I);{let te=Buffer.allocUnsafe(4+l.length);xt(te,l.length,0),te.set(l,4),l=te}let O=Xn[h.cs.cipher],V=Xn[h.sc.cipher],ee=$n(O.ivLen,this.hashName,l,I,this.sessionID,"A"),X=$n(V.ivLen,this.hashName,l,I,this.sessionID,"B"),y=$n(O.keyLen,this.hashName,l,I,this.sessionID,"C"),S=$n(V.keyLen,this.hashName,l,I,this.sessionID,"D"),v,M;O.authLen||(v=Qf[h.cs.mac],M=$n(v.len,this.hashName,l,I,this.sessionID,"E"));let Q,re;V.authLen||(Q=Qf[h.sc.mac],re=$n(Q.len,this.hashName,l,I,this.sessionID,"F"));let J={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:a?O:V,decipherIV:a?ee:X,decipherKey:a?y:S,macInfo:a?v:Q,macKey:a?M:re},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:a?V:O,cipherIV:a?X:ee,cipherKey:a?S:y,macInfo:a?Q:v,macKey:a?re:M}};this._protocol._decipher.free(),k=J,this._protocol._decipher=vh(J);let j={read:void 0,write:void 0};switch(h.cs.compress){case"zlib":a?j.read=new Ei:j.write=new pi(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){a?j.read=new Ei:j.write=new pi(this._protocol);break}default:a?j.read=new Hf:j.write=new Ff(this._protocol)}switch(h.sc.compress){case"zlib":a?j.write=new pi(this._protocol):j.read=new Ei;break;case"zlib@openssh.com":if(this._protocol._authenticated){a?j.write=new pi(this._protocol):j.read=new Ei;break}default:a?j.write=new Ff(this._protocol):j.read=new Hf}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=j.read,N=j.write,this._public=null,this._dh=null,this._kexinit=this._protocol._kexinit=void 0,this._remoteKexinit=void 0,this._identRaw=void 0,this._remoteIdentRaw=void 0,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0,Z?!1:D()};if((a||f)&&(this.finish=D),!a)return D(f)}start(){if(!this._protocol._server){if(this._protocol._debug){let d;this.type==="group"?d="KEXDH_INIT":d="KEXECDH_INIT",this._protocol._debug(`Outbound: Sending ${d}`)}let f=this.getPublicKey(),a=this._protocol._packetRW.write.allocStartKEX,h=this._protocol._packetRW.write.alloc(5+f.length,!0);h[a]=nt.KEXDH_INIT,xt(h,f.length,++a),h.set(f,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(h,!0))}}getPublicKey(){this.generateKeys();let f=this._public;if(f)return this.convertPublicKey(f)}convertPublicKey(f){let a,h=0,d=f.length;for(;f[h]===0;)++h,--d;return f[h]&128?(a=Buffer.allocUnsafe(1+d),a[0]=0,f.copy(a,1,h),a):(d!==f.length&&(a=Buffer.allocUnsafe(d),f.copy(a,0,h),f=a),f)}computeSecret(f){this.generateKeys();try{return n(this._dh.computeSecret(f))}catch(a){return a}}parse(f){let a=f[0];switch(this._step){case 1:if(this._protocol._server){if(a!==nt.KEXDH_INIT)return qe(this._protocol,`Received packet ${a} instead of ${nt.KEXDH_INIT}`,"handshake",Me.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),Fe.init(f,1);let h=Fe.readString();if(Fe.clear(),h===void 0)return qe(this._protocol,"Received malformed KEX*_INIT","handshake",Me.KEY_EXCHANGE_FAILED);this._dhData=h;let d=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(d)&&(d=d[0]),this._hostKey=d,this.finish()}else{if(a!==nt.KEXDH_REPLY)return qe(this._protocol,`Received packet ${a} instead of ${nt.KEXDH_REPLY}`,"handshake",Me.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),Fe.init(f,1);let h,d,l;if((h=Fe.readString())===void 0||(d=Fe.readString())===void 0||(l=Fe.readString())===void 0)return Fe.clear(),qe(this._protocol,"Received malformed KEX*_REPLY","handshake",Me.KEY_EXCHANGE_FAILED);Fe.clear(),Fe.init(h,0);let _=Fe.readString(!0);if(Fe.clear(),_===void 0)return qe(this._protocol,"Received malformed host public key","handshake",Me.KEY_EXCHANGE_FAILED);if(_!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(_==="ssh-rsa")break;default:return qe(this._protocol,"Host key does not match negotiated type","handshake",Me.KEY_EXCHANGE_FAILED)}this._hostKey=h,this._dhData=d,this._sig=l;let p=!1,x;if(this._protocol._hostVerifier===void 0?(x=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):x=this._protocol._hostVerifier(h,I=>{if(!p){if(p=!0,I===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),qe(this._protocol,"Host denied (verification failed)","handshake",Me.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():bi(this)}}),x===void 0){++this._step;return}if(p=!0,x===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),qe(this._protocol,"Host denied (verification failed)","handshake",Me.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,bi(this)}++this._step;break;case 2:return a!==nt.NEWKEYS?qe(this._protocol,`Received packet ${a} instead of ${nt.NEWKEYS}`,"handshake",Me.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Inbound: NEWKEYS"),this._receivedNEWKEYS=!0,this._protocol._strictMode&&(this._protocol._decipher.inSeqno=0),++this._step,this.finish(!this._protocol._server&&!this._hostVerified));default:return qe(this._protocol,`Received unexpected packet ${a} after NEWKEYS`,"handshake",Me.KEY_EXCHANGE_FAILED)}}}class e extends t{constructor(f,...a){super(...a),this.type="25519",this.hashName=f,this._keys=null}generateKeys(){this._keys||(this._keys=kh("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(f){let a,h=0,d=f.length;for(;f[h]===0;)++h,--d;return f.length===32||d!==f.length&&(a=Buffer.allocUnsafe(d),f.copy(a,0,h),f=a),f}computeSecret(f){this.generateKeys();try{let a=new Of.Writer;return a.startSequence(),a.startSequence(),a.writeOID("1.3.101.110"),a.endSequence(),a.startSequence(Of.BitString),a.writeByte(0),a._ensure(f.length),f.copy(a._buf,a._offset,0,f.length),a._offset+=f.length,a.endSequence(),a.endSequence(),n(Ch({privateKey:this._keys.privateKey,publicKey:Bh({key:a.buffer,type:"spki",format:"der"})}))}catch(a){return a}}}class r extends t{constructor(f,a,...h){super(...h),this.type="ecdh",this.curveName=f,this.hashName=a}generateKeys(){this._dh||(this._dh=mh(this.curveName),this._public=this._dh.generateKeys())}}class i extends t{constructor(f,...a){super(...a),this.type="groupex",this.hashName=f,this._prime=null,this._generator=null,this._minBits=Qh,this._prefBits=qh(this.negotiated),this._protocol._compatFlags&Ws.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=Hh}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let f=this._protocol._packetRW.write.allocStartKEX,a=this._protocol._packetRW.write.alloc(13,!0);a[f]=nt.KEXDH_GEX_REQUEST,xt(a,this._minBits,++f),xt(a,this._prefBits,f+=4),xt(a,this._maxBits,f+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(a,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=Sh(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(f,a){if(!Buffer.isBuffer(f))throw new Error("Invalid prime value");if(!Buffer.isBuffer(a))throw new Error("Invalid generator value");this._prime=f,this._generator=a}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}parse(f){let a=f[0];switch(this._step){case 1:{if(this._protocol._server)return a!==nt.KEXDH_GEX_REQUEST?qe(this._protocol,`Received packet ${a} instead of `+nt.KEXDH_GEX_REQUEST,"handshake",Me.KEY_EXCHANGE_FAILED):qe(this._protocol,"Group exchange not implemented for server","handshake",Me.KEY_EXCHANGE_FAILED);if(a!==nt.KEXDH_GEX_GROUP)return qe(this._protocol,`Received packet ${a} instead of ${nt.KEXDH_GEX_GROUP}`,"handshake",Me.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),Fe.init(f,1);let h,d;if((h=Fe.readString())===void 0||(d=Fe.readString())===void 0)return Fe.clear(),qe(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",Me.KEY_EXCHANGE_FAILED);Fe.clear(),this.setDHParams(h,d),this.generateKeys();let l=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let _=this._protocol._packetRW.write.allocStartKEX,p=this._protocol._packetRW.write.alloc(5+l.length,!0);p[_]=nt.KEXDH_GEX_INIT,xt(p,l.length,++_),p.set(l,_+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(p,!0)),++this._step;break}case 2:if(this._protocol._server)return a!==nt.KEXDH_GEX_INIT?qe(this._protocol,`Received packet ${a} instead of ${nt.KEXDH_GEX_INIT}`,"handshake",Me.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),qe(this._protocol,"Group exchange not implemented for server","handshake",Me.KEY_EXCHANGE_FAILED));if(a!==nt.KEXDH_GEX_REPLY)return qe(this._protocol,`Received packet ${a} instead of ${nt.KEXDH_GEX_REPLY}`,"handshake",Me.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,f[0]=nt.KEXDH_REPLY,this.parse=t.prototype.parse,this.parse(f)}}}class s extends t{constructor(f,a,...h){super(...h),this.type="group",this.groupName=f,this.hashName=a}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let f=this.getPublicKey(),a=this._protocol._packetRW.write.allocStartKEX,h=this._protocol._packetRW.write.alloc(5+f.length,!0);h[a]=nt.KEXDH_INIT,xt(h,f.length,++a),h.set(f,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(h,!0))}}generateKeys(){this._dh||(this._dh=wh(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}}return(o,...f)=>{if(typeof o!="object"||o===null)throw new Error("Invalid negotiated argument");let a=o.kex;if(typeof a=="string"){switch(f=[o,...f],a){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!Nh)break;return new e("sha256",...f);case"ecdh-sha2-nistp256":return new r("prime256v1","sha256",...f);case"ecdh-sha2-nistp384":return new r("secp384r1","sha384",...f);case"ecdh-sha2-nistp521":return new r("secp521r1","sha512",...f);case"diffie-hellman-group1-sha1":return new s("modp2","sha1",...f);case"diffie-hellman-group14-sha1":return new s("modp14","sha1",...f);case"diffie-hellman-group14-sha256":return new s("modp14","sha256",...f);case"diffie-hellman-group15-sha512":return new s("modp15","sha512",...f);case"diffie-hellman-group16-sha512":return new s("modp16","sha512",...f);case"diffie-hellman-group17-sha512":return new s("modp17","sha512",...f);case"diffie-hellman-group18-sha512":return new s("modp18","sha512",...f);case"diffie-hellman-group-exchange-sha1":return new i("sha1",...f);case"diffie-hellman-group-exchange-sha256":return new i("sha256",...f)}throw new Error(`Unsupported key exchange algorithm: ${a}`)}throw new Error(`Invalid key exchange type: ${a}`)}})(),qs=(()=>{let n=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{constructor(e){if(typeof e!="object"||e===null)throw new TypeError("Argument must be an object");let r={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},all:void 0},i=0;for(let f of n){let a,h,d,l;if(typeof f=="string")a=r,h=e[f],d=l=f;else{let p=f[0];a=r[p],l=f[1],h=e[p][l],d=`${p}.${l}`}let _={array:void 0,buffer:void 0};if(Buffer.isBuffer(h))_.array=(""+h).split(","),_.buffer=h,i+=4+h.length;else{if(typeof h=="string"&&(h=h.split(",")),Array.isArray(h))_.array=h,_.buffer=Buffer.from(h.join(","));else throw new TypeError(`Invalid \`${d}\` type: ${typeof h}`);i+=4+_.buffer.length}a[l]=_}let s=Buffer.allocUnsafe(i);r.all=s;let o=0;for(let f of n){let a;typeof f=="string"?a=r[f].buffer:a=r[f[0]][f[1]].buffer,o=xt(s,a.length,o),s.set(a,o),o+=a.length}this.totalSize=i,this.lists=r}copyAllTo(e,r){let i=this.lists.all;if(typeof r!="number")throw new TypeError(`Invalid offset value: ${typeof r}`);if(e.length-r<i.length)throw new Error("Insufficient space to copy list");return e.set(i,r),i.length}}})(),Vt=(()=>{let n=Buffer.allocUnsafe(4);return(t,e)=>{xt(n,e.length,0),t.update(n),t.update(e)}})();function $n(n,t,e,r,i,s){let o;if(n){let f=Ks(t).update(e).update(r).update(s).update(i).digest();for(;f.length<n;){let a=Ks(t).update(e).update(r).update(f).digest(),h=Buffer.allocUnsafe(f.length+a.length);h.set(f,0),h.set(a,f.length),f=h}f.length===n?o=f:o=new Ph(f.buffer,f.byteOffset,n)}else o=Fh;return o}function Kf(n,t){if(t.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}t=this._packetRW.read.read(t);let e=t[0];if(!this._strictMode)switch(e){case nt.IGNORE:case nt.UNIMPLEMENTED:case nt.DEBUG:return Yn||(Yn=li()),Yn[e](this,t)}switch(e){case nt.DISCONNECT:return Yn||(Yn=li()),Yn[e](this,t);case nt.KEXINIT:return n.firstPacket?(n.firstPacket=!1,qf(this,t)):qe(this,"Received extra KEXINIT during handshake","handshake",Me.KEY_EXCHANGE_FAILED);default:if(e<20||e>49)return qe(this,`Received unexpected packet type ${e}`,"handshake",Me.KEY_EXCHANGE_FAILED)}return this._kex.parse(t)}function qh(n){let t=Xn[n.cs.cipher],e=Xn[n.sc.cipher],r=Math.max(0,t.sslName==="des-ede3-cbc"?14:t.keyLen,t.blockLen,t.ivLen,e.sslName==="des-ede3-cbc"?14:e.keyLen,e.blockLen,e.ivLen)*8;return r<=112?2048:r<=128?3072:r<=192?7680:8192}function bi(n){if(!n._sentNEWKEYS){n._protocol._debug&&n._protocol._debug("Outbound: Sending NEWKEYS");let t=n._protocol._packetRW.write.allocStartKEX,e=n._protocol._packetRW.write.alloc(1,!0);e[t]=nt.NEWKEYS,n._protocol._cipher.encrypt(n._protocol._packetRW.write.finalize(e,!0)),n._sentNEWKEYS=!0,n._protocol._strictMode&&(n._protocol._cipher.outSeqno=0)}}Wf.exports={KexInit:qs,kexinit:Mf,onKEXPayload:Kf,DEFAULT_KEXINIT_CLIENT:new qs({kex:Pf.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:Df,cs:{cipher:Ai,mac:gi,compress:_i,lang:[]},sc:{cipher:Ai,mac:gi,compress:_i,lang:[]}}),DEFAULT_KEXINIT_SERVER:new qs({kex:Pf.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:Df,cs:{cipher:Ai,mac:gi,compress:_i,lang:[]},sc:{cipher:Ai,mac:gi,compress:_i,lang:[]}}),HANDLERS:{[nt.KEXINIT]:qf}}});var Gf=Ze((Fd,Kh)=>{Kh.exports={name:"ssh2",version:"1.17.0",author:"Brian White <mscdex@mscdex.net>",description:"SSH2 client and server modules written in pure JavaScript for node.js",main:"./lib/index.js",engines:{node:">=10.16.0"},dependencies:{asn1:"^0.2.6","bcrypt-pbkdf":"^1.0.2"},devDependencies:{"@mscdex/eslint-config":"^1.1.0",eslint:"^7.32.0"},optionalDependencies:{"cpu-features":"~0.0.10",nan:"^2.23.0"},scripts:{install:"node install.js",rebuild:"node install.js",test:"node test/test.js",lint:"eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js examples lib test","lint:fix":"npm run lint -- --fix"},keywords:["ssh","ssh2","sftp","secure","shell","exec","remote","client"],licenses:[{type:"MIT",url:"http://github.com/mscdex/ssh2/raw/master/LICENSE"}],repository:{type:"git",url:"http://github.com/mscdex/ssh2.git"}}});var Xs=Ze((Md,ia)=>{"use strict";var{inspect:zf}=require("util"),{bindingAvailable:Wh,NullCipher:Gh,NullDecipher:Yh}=un(),{COMPAT_CHECKS:$h,DISCONNECT_REASON:Jf,eddsaSupported:Xh,MESSAGE:be,SIGNALS:Yf,TERMINAL_MODE:Ys}=nn(),{DEFAULT_KEXINIT_CLIENT:jh,DEFAULT_KEXINIT_SERVER:Vh,KexInit:$f,kexinit:Zf,onKEXPayload:zh}=di(),{parseKey:Xf}=An(),Jh=li(),{bufferCopy:Ii,bufferFill:Zh,bufferSlice:ea,convertSignature:jf,sendPacket:Ie,writeUInt32BE:w}=Wt(),{PacketReader:eu,PacketWriter:tu,ZlibPacketReader:ta,ZlibPacketWriter:na}=Hs(),nu=Gf().version,ru=new Map(Object.values(Jf).map(n=>[n,1])),ra=Buffer.from(`SSH-2.0-ssh2js${nu}`),iu=Buffer.from(`${ra}\r
14
+ `),su=8192,ou=1024,Vf=Buffer.from([be.GLOBAL_REQUEST,0,0,0,21,107,101,101,112,97,108,105,118,101,64,111,112,101,110,115,115,104,46,99,111,109,1]),fu=Buffer.from([Ys.TTY_OP_END]);function Gs(){}var $s=class{constructor(t){let e=t.onWrite;if(typeof e!="function")throw new Error("Missing onWrite function");this._onWrite=p=>{e(p)};let r=t.onError;if(typeof r!="function")throw new Error("Missing onError function");this._onError=p=>{r(p)};let i=t.debug;this._debug=typeof i=="function"?p=>{i(p)}:void 0;let s=t.onHeader;this._onHeader=typeof s=="function"?(...p)=>{s(...p)}:Gs;let o=t.onPacket;this._onPacket=typeof o=="function"?()=>{o()}:Gs;let f=t.onHandshakeComplete;typeof f!="function"&&(f=Gs);let a;this._onHandshakeComplete=(...p)=>{this._debug&&this._debug("Handshake completed"),a===void 0?a=!0:a=!1;let x=this._queue;if(x){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${x.length}) ...`);for(let I=0;I<x.length;++I){let k=x[I],N=this._packetRW.write.finalize(k);if(N===k){let D=this._cipher.allocPacket(k.length);D.set(k,5),N=D}Ie(this,N)}this._debug&&this._debug("... finished draining outbound queue")}a&&this._server&&this._kex.remoteExtInfoEnabled&&Au(this),f(...p)},this._queue=void 0;let h=t.messageHandlers;typeof h=="object"&&h!==null?this._handlers=h:this._handlers={},this._onPayload=uu.bind(this),this._server=!!t.server,this._banner=void 0;let d;if(this._server){if(typeof t.hostKeys!="object"||t.hostKeys===null)throw new Error("Missing server host key(s)");this._hostKeys=t.hostKeys,typeof t.greeting=="string"&&t.greeting.length&&(d=t.greeting.slice(-2)===`\r
15
+ `?t.greeting:`${t.greeting}\r
16
+ `),typeof t.banner=="string"&&t.banner.length&&(this._banner=t.banner.slice(-2)===`\r
17
+ `?t.banner:`${t.banner}\r
18
+ `)}else this._hostKeys=void 0;let l=t.offer;typeof l!="object"||l===null?l=this._server?Vh:jh:l.constructor!==$f&&(this._server?l.kex=l.kex.concat(["kex-strict-s-v00@openssh.com"]):l.kex=l.kex.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),l=new $f(l)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=l,this._cipher=new Gh(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new eu,write:new tu(this)},this._hostVerifier=!this._server&&typeof t.hostVerifier=="function"?t.hostVerifier:void 0,this._parse=cu,this._buffer=void 0,this._authsQueue=[],this._authenticated=!1,this._remoteIdentRaw=void 0;let _;if(typeof t.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${t.ident}`),_=Buffer.allocUnsafe(this._identRaw.length+2),_.set(this._identRaw,0),_[_.length-2]=13,_[_.length-1]=10;else if(Buffer.isBuffer(t.ident)){let p=Buffer.allocUnsafe(8+t.ident.length);p.latin1Write("SSH-2.0-",0,8),p.set(t.ident,8),this._identRaw=p,_=Buffer.allocUnsafe(p.length+2),_.set(p,0),_[_.length-2]=13,_[_.length-1]=10}else this._identRaw=ra,_=iu;this._compatFlags=0,this._debug&&(Wh?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${zf(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,d&&this._onWrite(d),this._onWrite(_)}}_destruct(t){this._packetRW.read.cleanup(),this._packetRW.write.cleanup(),this._cipher&&this._cipher.free(),this._decipher&&this._decipher.free(),(typeof t!="string"||t.length===0)&&(t="fatal error"),this.parse=()=>{throw new Error(`Instance unusable after ${t}`)},this._onWrite=()=>{throw new Error(`Instance unusable after ${t}`)},this._destruct=void 0}cleanup(){this._destruct&&this._destruct()}parse(t,e,r){for(;e<r;)e=this._parse(t,e,r)}disconnect(t){let r=this._packetRW.write.allocStartKEX,i=this._packetRW.write.alloc(13,!0),s=r+13;ru.has(t)||(t=Jf.PROTOCOL_ERROR),i[r]=be.DISCONNECT,w(i,t,++r),i.fill(0,r+=4,s),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${t})`),Ie(this,this._packetRW.write.finalize(i,!0),!0)}ping(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(Vf.length);e.set(Vf,t),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),Ie(this,this._packetRW.write.finalize(e))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],Zf(this)):this._debug&&this._debug("Outbound: Ignoring rekey during handshake")}requestSuccess(t){let e=this._packetRW.write.allocStart,r;Buffer.isBuffer(t)?(r=this._packetRW.write.alloc(1+t.length),r[e]=be.REQUEST_SUCCESS,r.set(t,++e)):(r=this._packetRW.write.alloc(1),r[e]=be.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),Ie(this,this._packetRW.write.finalize(r))}requestFailure(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=be.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),Ie(this,this._packetRW.write.finalize(e))}channelSuccess(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=be.CHANNEL_SUCCESS,w(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${t})`),Ie(this,this._packetRW.write.finalize(r))}channelFailure(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=be.CHANNEL_FAILURE,w(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${t})`),Ie(this,this._packetRW.write.finalize(r))}channelEOF(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=be.CHANNEL_EOF,w(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${t})`),Ie(this,this._packetRW.write.finalize(r))}channelClose(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=be.CHANNEL_CLOSE,w(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${t})`),Ie(this,this._packetRW.write.finalize(r))}channelWindowAdjust(t,e){let r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(9);i[r]=be.CHANNEL_WINDOW_ADJUST,w(i,t,++r),w(i,e,r+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${t}, ${e})`),Ie(this,this._packetRW.write.finalize(i))}channelData(t,e){let r=Buffer.isBuffer(e),i=r?e.length:Buffer.byteLength(e),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(9+i);o[s]=be.CHANNEL_DATA,w(o,t,++s),w(o,i,s+=4),r?o.set(e,s+=4):o.utf8Write(e,s+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${t}, ${i})`),Ie(this,this._packetRW.write.finalize(o))}channelExtData(t,e,r){let i=Buffer.isBuffer(e),s=i?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(13+s);f[o]=be.CHANNEL_EXTENDED_DATA,w(f,t,++o),w(f,r,o+=4),w(f,s,o+=4),i?f.set(e,o+=4):f.utf8Write(e,o+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${t})`),Ie(this,this._packetRW.write.finalize(f))}channelOpenConfirm(t,e,r,i){let s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(17);o[s]=be.CHANNEL_OPEN_CONFIRMATION,w(o,t,++s),w(o,e,s+=4),w(o,r,s+=4),w(o,i,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${t}, l:${e})`),Ie(this,this._packetRW.write.finalize(o))}channelOpenFail(t,e,r){typeof r!="string"&&(r="");let i=Buffer.byteLength(r),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(13+i+4);o[s]=be.CHANNEL_OPEN_FAILURE,w(o,t,++s),w(o,e,s+=4),w(o,i,s+=4),s+=4,i&&(o.utf8Write(r,s,i),s+=i),w(o,0,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${t})`),Ie(this,this._packetRW.write.finalize(o))}service(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e);i[r]=be.SERVICE_REQUEST,w(i,e,++r),i.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${t})`),Ie(this,this._packetRW.write.finalize(i))}authPassword(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(t),s=Buffer.byteLength(e),o=r?Buffer.byteLength(r):0,f=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(5+i+4+14+4+8+1+4+s+(r?4+o:0));a[f]=be.USERAUTH_REQUEST,w(a,i,++f),a.utf8Write(t,f+=4,i),w(a,14,f+=i),a.utf8Write("ssh-connection",f+=4,14),w(a,8,f+=14),a.utf8Write("password",f+=4,8),a[f+=8]=r?1:0,w(a,s,++f),Buffer.isBuffer(e)?Ii(e,a,0,s,f+=4):a.utf8Write(e,f+=4,s),r?(w(a,o,f+=s),Buffer.isBuffer(r)?Ii(r,a,0,o,f+=4):a.utf8Write(r,f+=4,o),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (changed password)")):this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (password)"),this._authsQueue.push("password"),Ie(this,this._packetRW.write.finalize(a))}authPK(t,e,r,i){if(this._server)throw new Error("Client-only method called in server mode");if(e=Xf(e),e instanceof Error)throw new Error("Invalid key");let s=e.type;e=e.getPublicSSH(),typeof r=="function"&&(i=r,r=void 0),r||(r=s);let o=Buffer.byteLength(t),f=Buffer.byteLength(r),a=e.length,h=this._kex.sessionID,d=h.length,l=(i?4+d:0)+1+4+o+4+14+4+9+1+4+f+4+a,_,p;if(i?(_=Buffer.allocUnsafe(l),p=0,w(_,d,p),_.set(h,p+=4),p+=d):(_=this._packetRW.write.alloc(l),p=this._packetRW.write.allocStart),_[p]=be.USERAUTH_REQUEST,w(_,o,++p),_.utf8Write(t,p+=4,o),w(_,14,p+=o),_.utf8Write("ssh-connection",p+=4,14),w(_,9,p+=14),_.utf8Write("publickey",p+=4,9),_[p+=9]=i?1:0,w(_,f,++p),_.utf8Write(r,p+=4,f),w(_,a,p+=f),_.set(e,p+=4),!i){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),Ie(this,this._packetRW.write.finalize(_));return}i(_,x=>{if(x=jf(x,s),x===!1)throw new Error("Error while converting handshake signature");let I=x.length;p=this._packetRW.write.allocStart,_=this._packetRW.write.alloc(5+o+4+14+4+9+1+4+f+4+a+4+4+f+4+I),_[p]=be.USERAUTH_REQUEST,w(_,o,++p),_.utf8Write(t,p+=4,o),w(_,14,p+=o),_.utf8Write("ssh-connection",p+=4,14),w(_,9,p+=14),_.utf8Write("publickey",p+=4,9),_[p+=9]=1,w(_,f,++p),_.utf8Write(r,p+=4,f),w(_,a,p+=f),_.set(e,p+=4),w(_,4+f+4+I,p+=a),w(_,f,p+=4),_.utf8Write(r,p+=4,f),w(_,I,p+=f),_.set(x,p+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),Ie(this,this._packetRW.write.finalize(_))})}authHostbased(t,e,r,i,s,o){if(this._server)throw new Error("Client-only method called in server mode");if(e=Xf(e),e instanceof Error)throw new Error("Invalid key");let f=e.type;e=e.getPublicSSH(),typeof s=="function"&&(o=s,s=void 0),s||(s=f);let a=Buffer.byteLength(t),h=Buffer.byteLength(s),d=e.length,l=this._kex.sessionID,_=l.length,p=Buffer.byteLength(r),x=Buffer.byteLength(i),I=Buffer.allocUnsafe(4+_+1+4+a+4+14+4+9+4+h+4+d+4+p+4+x),k=0;w(I,_,k),I.set(l,k+=4),I[k+=_]=be.USERAUTH_REQUEST,w(I,a,++k),I.utf8Write(t,k+=4,a),w(I,14,k+=a),I.utf8Write("ssh-connection",k+=4,14),w(I,9,k+=14),I.utf8Write("hostbased",k+=4,9),w(I,h,k+=9),I.utf8Write(s,k+=4,h),w(I,d,k+=h),I.set(e,k+=4),w(I,p,k+=d),I.utf8Write(r,k+=4,p),w(I,x,k+=p),I.utf8Write(i,k+=4,x),o(I,N=>{if(N=jf(N,f),!N)throw new Error("Error while converting handshake signature");let D=N.length,Z=I.length-_-4;k=this._packetRW.write.allocStart;let O=this._packetRW.write.alloc(Z+4+4+h+4+D);Ii(I,O,4+_,I.length,k),w(O,4+h+4+D,k+=Z),w(O,h,k+=4),O.utf8Write(s,k+=4,h),w(O,D,k+=h),O.set(N,k+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),Ie(this,this._packetRW.write.finalize(O))})}authKeyboard(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e+4+14+4+20+4+4);i[r]=be.USERAUTH_REQUEST,w(i,e,++r),i.utf8Write(t,r+=4,e),w(i,14,r+=e),i.utf8Write("ssh-connection",r+=4,14),w(i,20,r+=14),i.utf8Write("keyboard-interactive",r+=4,20),w(i,0,r+=20),w(i,0,r+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),Ie(this,this._packetRW.write.finalize(i))}authNone(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e+4+14+4+4);i[r]=be.USERAUTH_REQUEST,w(i,e,++r),i.utf8Write(t,r+=4,e),w(i,14,r+=e),i.utf8Write("ssh-connection",r+=4,14),w(i,4,r+=14),i.utf8Write("none",r+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),Ie(this,this._packetRW.write.finalize(i))}authInfoRes(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r;if(t){r=new Array(t.length);for(let o=0;o<t.length;++o){let f=Buffer.byteLength(t[o]);r[o]=f,e+=4+f}}let i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);if(s[i]=be.USERAUTH_INFO_RESPONSE,t){w(s,t.length,++i),i+=4;for(let o=0;o<t.length;++o){let f=r[o];w(s,f,i),i+=4,f&&(s.utf8Write(t[o],i,f),i+=f)}}else w(s,0,++i);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),Ie(this,this._packetRW.write.finalize(s))}tcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(t),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+i+4);o[s]=be.GLOBAL_REQUEST,w(o,13,++s),o.utf8Write("tcpip-forward",s+=4,13),o[s+=13]=r===void 0||r===!0?1:0,w(o,i,++s),o.utf8Write(t,s+=4,i),w(o,e,s+=i),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),Ie(this,this._packetRW.write.finalize(o))}cancelTcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(t),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(30+i+4);o[s]=be.GLOBAL_REQUEST,w(o,20,++s),o.utf8Write("cancel-tcpip-forward",s+=4,20),o[s+=20]=r===void 0||r===!0?1:0,w(o,i,++s),o.utf8Write(t,s+=4,i),w(o,e,s+=i),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),Ie(this,this._packetRW.write.finalize(o))}openssh_streamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(41+r);s[i]=be.GLOBAL_REQUEST,w(s,31,++i),s.utf8Write("streamlocal-forward@openssh.com",i+=4,31),s[i+=31]=e===void 0||e===!0?1:0,w(s,r,++i),s.utf8Write(t,i+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),Ie(this,this._packetRW.write.finalize(s))}openssh_cancelStreamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(48+r);s[i]=be.GLOBAL_REQUEST,w(s,38,++i),s.utf8Write("cancel-streamlocal-forward@openssh.com",i+=4,38),s[i+=38]=e===void 0||e===!0?1:0,w(s,r,++i),s.utf8Write(t,i+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),Ie(this,this._packetRW.write.finalize(s))}directTcpip(t,e,r,i){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(i.srcIP),o=Buffer.byteLength(i.dstIP),f=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(33+s+4+4+o+4);a[f]=be.CHANNEL_OPEN,w(a,12,++f),a.utf8Write("direct-tcpip",f+=4,12),w(a,t,f+=12),w(a,e,f+=4),w(a,r,f+=4),w(a,o,f+=4),a.utf8Write(i.dstIP,f+=4,o),w(a,i.dstPort,f+=o),w(a,s,f+=4),a.utf8Write(i.srcIP,f+=4,s),w(a,i.srcPort,f+=s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-tcpip)`),Ie(this,this._packetRW.write.finalize(a))}openssh_directStreamLocal(t,e,r,i){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(i.socketPath),o=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(51+s+4+4);f[o]=be.CHANNEL_OPEN,w(f,30,++o),f.utf8Write("direct-streamlocal@openssh.com",o+=4,30),w(f,t,o+=30),w(f,e,o+=4),w(f,r,o+=4),w(f,s,o+=4),f.utf8Write(i.socketPath,o+=4,s),Zh(f,0,o+=s,o+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-streamlocal@openssh.com)`),Ie(this,this._packetRW.write.finalize(f))}openssh_noMoreSessions(t){if(this._server)throw new Error("Client-only method called in server mode");let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(34);r[e]=be.GLOBAL_REQUEST,w(r,28,++e),r.utf8Write("no-more-sessions@openssh.com",e+=4,28),r[e+=28]=t===void 0||t===!0?1:0,this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)"),Ie(this,this._packetRW.write.finalize(r))}session(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(24);s[i]=be.CHANNEL_OPEN,w(s,7,++i),s.utf8Write("session",i+=4,7),w(s,t,i+=7),w(s,e,i+=4),w(s,r,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, session)`),Ie(this,this._packetRW.write.finalize(s))}windowChange(t,e,r,i,s){if(this._server)throw new Error("Client-only method called in server mode");let o=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(39);f[o]=be.CHANNEL_REQUEST,w(f,t,++o),w(f,13,o+=4),f.utf8Write("window-change",o+=4,13),f[o+=13]=0,w(f,r,++o),w(f,e,o+=4),w(f,s,o+=4),w(f,i,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, window-change)`),Ie(this,this._packetRW.write.finalize(f))}pty(t,e,r,i,s,o,f,a){if(this._server)throw new Error("Client-only method called in server mode");(!o||!o.length)&&(o="vt100"),f&&!Buffer.isBuffer(f)&&!Array.isArray(f)&&typeof f=="object"&&f!==null&&(f=du(f)),(!f||!f.length)&&(f=fu);let h=o.length,d=f.length,l=this._packetRW.write.allocStart,_=this._packetRW.write.alloc(21+h+4+4+4+4+4+d);if(_[l]=be.CHANNEL_REQUEST,w(_,t,++l),w(_,7,l+=4),_.utf8Write("pty-req",l+=4,7),_[l+=7]=a===void 0||a===!0?1:0,w(_,h,++l),_.utf8Write(o,l+=4,h),w(_,r,l+=h),w(_,e,l+=4),w(_,s,l+=4),w(_,i,l+=4),w(_,d,l+=4),l+=4,Array.isArray(f))for(let p=0;p<d;++p)_[l++]=f[p];else Buffer.isBuffer(f)&&_.set(f,l);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, pty-req)`),Ie(this,this._packetRW.write.finalize(_))}shell(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(15);i[r]=be.CHANNEL_REQUEST,w(i,t,++r),w(i,5,r+=4),i.utf8Write("shell",r+=4,5),i[r+=5]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, shell)`),Ie(this,this._packetRW.write.finalize(i))}exec(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.isBuffer(e),s=i?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(18+s);f[o]=be.CHANNEL_REQUEST,w(f,t,++o),w(f,4,o+=4),f.utf8Write("exec",o+=4,4),f[o+=4]=r===void 0||r===!0?1:0,w(f,s,++o),i?f.set(e,o+=4):f.utf8Write(e,o+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exec: ${e})`),Ie(this,this._packetRW.write.finalize(f))}signal(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=e;if(e=e.toUpperCase(),e.slice(0,3)==="SIG"&&(e=e.slice(3)),Yf[e]!==1)throw new Error(`Invalid signal: ${r}`);let i=e.length,s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(20+i);o[s]=be.CHANNEL_REQUEST,w(o,t,++s),w(o,6,s+=4),o.utf8Write("signal",s+=4,6),o[s+=6]=0,w(o,i,++s),o.utf8Write(e,s+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, signal: ${e})`),Ie(this,this._packetRW.write.finalize(o))}env(t,e,r,i){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),o=Buffer.isBuffer(r),f=o?r.length:Buffer.byteLength(r),a=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(17+s+4+f);h[a]=be.CHANNEL_REQUEST,w(h,t,++a),w(h,3,a+=4),h.utf8Write("env",a+=4,3),h[a+=3]=i===void 0||i===!0?1:0,w(h,s,++a),h.utf8Write(e,a+=4,s),w(h,f,a+=s),o?h.set(r,a+=4):h.utf8Write(r,a+=4,f),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, env: ${e}=${r})`),Ie(this,this._packetRW.write.finalize(h))}x11Forward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=e.protocol,s=e.cookie,o=Buffer.isBuffer(i),f=o?i.length:Buffer.byteLength(i),a=Buffer.isBuffer(s),h=a?s.length:Buffer.byteLength(s),d=this._packetRW.write.allocStart,l=this._packetRW.write.alloc(22+f+4+h+4);l[d]=be.CHANNEL_REQUEST,w(l,t,++d),w(l,7,d+=4),l.utf8Write("x11-req",d+=4,7),l[d+=7]=r===void 0||r===!0?1:0,l[++d]=e.single?1:0,w(l,f,++d),o?l.set(i,d+=4):l.utf8Write(i,d+=4,f),w(l,h,d+=f),a?l.set(s,d+=4):l.latin1Write(s,d+=4,h),w(l,e.screen||0,d+=h),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, x11-req)`),Ie(this,this._packetRW.write.finalize(l))}subsystem(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+i);o[s]=be.CHANNEL_REQUEST,w(o,t,++s),w(o,9,s+=4),o.utf8Write("subsystem",s+=4,9),o[s+=9]=r===void 0||r===!0?1:0,w(o,i,++s),o.utf8Write(e,s+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, subsystem: ${e})`),Ie(this,this._packetRW.write.finalize(o))}openssh_agentForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(36);i[r]=be.CHANNEL_REQUEST,w(i,t,++r),w(i,26,r+=4),i.utf8Write("auth-agent-req@openssh.com",r+=4,26),i[r+=26]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, auth-agent-req@openssh.com)`),Ie(this,this._packetRW.write.finalize(i))}openssh_hostKeysProve(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r=[];for(let o of t){let f=o.getPublicSSH();e+=4+f.length,r.push(f)}let i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(35+e);s[i]=be.GLOBAL_REQUEST,w(s,29,++i),s.utf8Write("hostkeys-prove-00@openssh.com",i+=4,29),s[i+=29]=1,++i;for(let o of r)w(s,o.length,i),Ii(o,s,0,o.length,i+=4),i+=o.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),Ie(this,this._packetRW.write.finalize(s))}serviceAccept(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e);if(i[r]=be.SERVICE_ACCEPT,w(i,e,++r),i.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${t})`),Ie(this,this._packetRW.write.finalize(i)),this._server&&this._banner&&t==="ssh-userauth"){let s=this._banner;this._banner=void 0;let o=Buffer.byteLength(s);r=this._packetRW.write.allocStart;let f=this._packetRW.write.alloc(5+o+4);f[r]=be.USERAUTH_BANNER,w(f,o,++r),f.utf8Write(s,r+=4,o),w(f,0,r+=o),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),Ie(this,this._packetRW.write.finalize(f))}}forwardedTcpip(t,e,r,i){if(!this._server)throw new Error("Server-only method called in client mode");let s=Buffer.byteLength(i.boundAddr),o=Buffer.byteLength(i.remoteAddr),f=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(36+s+4+4+o+4);a[f]=be.CHANNEL_OPEN,w(a,15,++f),a.utf8Write("forwarded-tcpip",f+=4,15),w(a,t,f+=15),w(a,e,f+=4),w(a,r,f+=4),w(a,s,f+=4),a.utf8Write(i.boundAddr,f+=4,s),w(a,i.boundPort,f+=s),w(a,o,f+=4),a.utf8Write(i.remoteAddr,f+=4,o),w(a,i.remotePort,f+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-tcpip)`),Ie(this,this._packetRW.write.finalize(a))}x11(t,e,r,i){if(!this._server)throw new Error("Server-only method called in client mode");let s=Buffer.byteLength(i.originAddr),o=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(24+s+4);f[o]=be.CHANNEL_OPEN,w(f,3,++o),f.utf8Write("x11",o+=4,3),w(f,t,o+=3),w(f,e,o+=4),w(f,r,o+=4),w(f,s,o+=4),f.utf8Write(i.originAddr,o+=4,s),w(f,i.originPort,o+=s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, x11)`),Ie(this,this._packetRW.write.finalize(f))}openssh_authAgent(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(39);s[i]=be.CHANNEL_OPEN,w(s,22,++i),s.utf8Write("auth-agent@openssh.com",i+=4,22),w(s,t,i+=22),w(s,e,i+=4),w(s,r,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, auth-agent@openssh.com)`),Ie(this,this._packetRW.write.finalize(s))}openssh_forwardedStreamLocal(t,e,r,i){if(!this._server)throw new Error("Server-only method called in client mode");let s=Buffer.byteLength(i.socketPath),o=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(54+s+4);f[o]=be.CHANNEL_OPEN,w(f,33,++o),f.utf8Write("forwarded-streamlocal@openssh.com",o+=4,33),w(f,t,o+=33),w(f,e,o+=4),w(f,r,o+=4),w(f,s,o+=4),f.utf8Write(i.socketPath,o+=4,s),w(f,0,o+=s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-streamlocal@openssh.com)`),Ie(this,this._packetRW.write.finalize(f))}exitStatus(t,e){if(!this._server)throw new Error("Server-only method called in client mode");let r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(25);i[r]=be.CHANNEL_REQUEST,w(i,t,++r),w(i,11,r+=4),i.utf8Write("exit-status",r+=4,11),i[r+=11]=0,w(i,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-status: ${e})`),Ie(this,this._packetRW.write.finalize(i))}exitSignal(t,e,r,i){if(!this._server)throw new Error("Server-only method called in client mode");let s=e;if(typeof s!="string"||!s)throw new Error(`Invalid signal: ${s}`);let o=e.toUpperCase();if(o.slice(0,3)==="SIG"&&(o=o.slice(3)),Yf[o]!==1)throw new Error(`Invalid signal: ${s}`);let f=Buffer.byteLength(o),a=i?Buffer.byteLength(i):0,h=this._packetRW.write.allocStart,d=this._packetRW.write.alloc(25+f+1+4+a+4);d[h]=be.CHANNEL_REQUEST,w(d,t,++h),w(d,11,h+=4),d.utf8Write("exit-signal",h+=4,11),d[h+=11]=0,w(d,f,++h),d.utf8Write(o,h+=4,f),d[h+=f]=r?1:0,w(d,a,++h),h+=4,a&&(d.utf8Write(i,h,a),h+=a),w(d,0,h),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-signal: ${e})`),Ie(this,this._packetRW.write.finalize(d))}authFailure(t,e){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0)throw new Error("No auth in progress");let r;if(typeof t=="boolean"&&(e=t,t=void 0),t){r=[];for(let f=0;f<t.length;++f)t[f].toLowerCase()!=="none"&&r.push(t[f]);r=r.join(",")}else r="";let i=r.length,s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+i+1);o[s]=be.USERAUTH_FAILURE,w(o,i,++s),o.utf8Write(r,s+=4,i),o[s+=i]=e===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),Ie(this,this._packetRW.write.finalize(o))}authSuccess(){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0)throw new Error("No auth in progress");let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=be.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),Ie(this,this._packetRW.write.finalize(e)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new ta),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new na(this))}authPKOK(t,e){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0||this._authsQueue[0]!=="publickey")throw new Error('"publickey" auth not in progress');let r=Buffer.byteLength(t),i=e.length,s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+r+4+i);o[s]=be.USERAUTH_PK_OK,w(o,r,++s),o.utf8Write(t,s+=4,r),w(o,i,s+=r),o.set(e,s+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),Ie(this,this._packetRW.write.finalize(o))}authPasswdChg(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e+4);i[r]=be.USERAUTH_PASSWD_CHANGEREQ,w(i,e,++r),i.utf8Write(t,r+=4,e),w(i,0,r+=e),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),Ie(this,this._packetRW.write.finalize(i))}authInfoReq(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let i=0,s=t?Buffer.byteLength(t):0,o=e?Buffer.byteLength(e):0;for(let h=0;h<r.length;++h)i+=4+Buffer.byteLength(r[h].prompt)+1;let f=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(5+s+4+o+4+4+i);a[f]=be.USERAUTH_INFO_REQUEST,w(a,s,++f),f+=4,t&&(a.utf8Write(t,f,s),f+=s),w(a,o,f),f+=4,e&&(a.utf8Write(e,f,o),f+=o),w(a,0,f),w(a,r.length,f+=4),f+=4;for(let h=0;h<r.length;++h){let d=r[h],l=Buffer.byteLength(d.prompt);w(a,l,f),f+=4,l&&(a.utf8Write(d.prompt,f,l),f+=l),a[f++]=d.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),Ie(this,this._packetRW.write.finalize(a))}},au=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function cu(n,t,e){let r,i;this._buffer?(r=Buffer.allocUnsafe(this._buffer.length+(e-t)),r.set(this._buffer,0),t===0?r.set(n,this._buffer.length):r.set(new Uint8Array(n.buffer,n.byteOffset+t,e-t),this._buffer.length),i=this._buffer.length,t=0):(r=n,i=0);let s=t,o=t,f=t,a=!1,h=0,d=0;for(;t<r.length;++t){let l=r[t];if(l===13){a=!0;continue}if(l===10){if(f>o&&f-o>4&&r[o]===83&&r[o+1]===83&&r[o+2]===72&&r[o+3]===45){let _=r.latin1Slice(s,f+1),p=o===s?_:_.slice(o-s),x=au.exec(p);if(!x)throw new Error("Invalid identification string");let I={greeting:o===s?"":_.slice(0,o-s),identRaw:p,versions:{protocol:x[1],software:x[2]},comments:x[3]};return this._remoteIdentRaw=Buffer.from(p),this._debug&&this._debug(`Remote ident: ${zf(p)}`),this._compatFlags=lu(I),this._buffer=void 0,this._decipher=new Yh(0,zh.bind(this,{firstPacket:!0})),this._parse=hu,this._onHeader(I),this._destruct?(Zf(this),t+1-i):e}if(this._server)throw new Error("Greetings from clients not permitted");if(++d>ou)throw new Error("Max greeting lines exceeded");a=!1,o=t+1,h=0}else{if(a)throw new Error("Invalid header: expected newline");if(++h>=su)throw new Error("Header line too long")}f=t}return this._buffer||(this._buffer=ea(r,s)),t-i}function hu(n,t,e){return this._decipher.decrypt(n,t,e)}function uu(n){if(this._onPacket(),n.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}n=this._packetRW.read.read(n);let t=n[0];t===be.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new na(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new ta));let e=Jh[t];if(e===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${t}`);return}return e(this,n)}function lu(n){let t=n.versions.software,e=0;for(let r of $h)typeof r[0]=="string"?t===r[0]&&(e|=r[1]):r[0].test(t)&&(e|=r[1]);return e}function du(n){let t=Object.keys(n),e=Buffer.allocUnsafe(5*t.length+1),r=0;for(let i=0;i<t.length;++i){let s=t[i];if(s==="TTY_OP_END")continue;let o=Ys[s];if(o===void 0)continue;let f=n[s];typeof f=="number"&&isFinite(f)&&(e[r++]=o,e[r++]=f>>>24,e[r++]=f>>>16,e[r++]=f>>>8,e[r++]=f)}return e[r++]=Ys.TTY_OP_END,r<e.length?ea(e,0,r):e}function Au(n){let t="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";Xh&&(t=`ssh-ed25519,${t}`);let e=Buffer.byteLength(t),r=n._packetRW.write.allocStart,i=n._packetRW.write.alloc(28+e);i[r]=be.EXT_INFO,w(i,1,++r),w(i,15,r+=4),i.utf8Write("server-sig-algs",r+=4,15),w(i,e,r+=15),i.utf8Write(t,r+=4,e),n._debug&&n._debug("Outbound: Sending EXT_INFO"),Ie(n,n._packetRW.write.finalize(i))}ia.exports=$s});var ha=Ze(Cr=>{"use strict";var xi=require("assert"),{inspect:gu}=require("util");function sa(n){let t="",e=n.length,r=n[0]==="-"?1:0;for(;e>=r+4;e-=3)t=`_${n.slice(e-3,e)}${t}`;return`${n.slice(0,e)}${t}`}function oa(n,t){if(xi(typeof t=="string","`thing` has to be of type string"),Array.isArray(n)){let e=n.length;return xi(e>0,"At least one expected value needs to be specified"),n=n.map(r=>String(r)),e>2?`one of ${t} ${n.slice(0,e-1).join(", ")}, or `+n[e-1]:e===2?`one of ${t} ${n[0]} or ${n[1]}`:`of ${t} ${n[0]}`}return`of ${t} ${String(n)}`}Cr.ERR_INTERNAL_ASSERTION=class aa extends Error{constructor(t){super(),Error.captureStackTrace(this,aa);let e=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
19
+ Please open an issue with this stack trace at https://github.com/mscdex/ssh2/issues
20
+ `;this.message=t===void 0?e:`${t}
21
+ ${e}`}};var _u=2**32,fa=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();Cr.ERR_OUT_OF_RANGE=class ca extends RangeError{constructor(t,e,r,i){super(),Error.captureStackTrace(this,ca),xi(e,'Missing "range" argument');let s=i?t:`The value of "${t}" is out of range.`,o;Number.isInteger(r)&&Math.abs(r)>_u?o=sa(String(r)):typeof r=="bigint"?(o=String(r),(r>fa||r<-fa)&&(o=sa(o)),o+="n"):o=gu(r),s+=` It must be ${e}. Received ${o}`,this.message=s}};var yi=class n extends TypeError{constructor(t,e,r){super(),Error.captureStackTrace(this,n),xi(typeof t=="string","'name' must be a string");let i;typeof e=="string"&&e.startsWith("not ")?(i="must not be",e=e.replace(/^not /,"")):i="must be";let s;if(t.endsWith(" argument"))s=`The ${t} ${i} ${oa(e,"type")}`;else{let o=t.includes(".")?"property":"argument";s=`The "${t}" ${o} ${i} ${oa(e,"type")}`}s+=`. Received type ${typeof r}`,this.message=s}};Cr.ERR_INVALID_ARG_TYPE=yi;Cr.validateNumber=function(t,e){if(typeof t!="number")throw new yi(e,"number",t)}});var kr=Ze((Kd,Sa)=>{"use strict";var Eu=require("events"),_n=require("fs"),{constants:Lt}=_n,{Readable:_a,Writable:ro}=require("stream"),{inherits:Ea,types:{isDate:zs}}=require("util"),pu=Buffer[Symbol.species],{bufferCopy:gn,bufferSlice:zn,makeBufferParser:bu,writeUInt32BE:P}=Wt(),on={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Be=Buffer.alloc(28),$e={OK:0,EOF:1,NO_SUCH_FILE:2,PERMISSION_DENIED:3,FAILURE:4,BAD_MESSAGE:5,NO_CONNECTION:6,CONNECTION_LOST:7,OP_UNSUPPORTED:8},Iu=new Map(Object.values($e).map(n=>[n,1])),xu={[$e.OK]:"No error",[$e.EOF]:"End of file",[$e.NO_SUCH_FILE]:"No such file or directory",[$e.PERMISSION_DENIED]:"Permission denied",[$e.FAILURE]:"Failure",[$e.BAD_MESSAGE]:"Bad message",[$e.NO_CONNECTION]:"No connection",[$e.CONNECTION_LOST]:"Connection lost",[$e.OP_UNSUPPORTED]:"Operation unsupported"},we={INIT:1,OPEN:3,CLOSE:4,READ:5,WRITE:6,LSTAT:7,FSTAT:8,SETSTAT:9,FSETSTAT:10,OPENDIR:11,READDIR:12,REMOVE:13,MKDIR:14,RMDIR:15,REALPATH:16,STAT:17,RENAME:18,READLINK:19,SYMLINK:20,EXTENDED:200},Ut={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},xe={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},ua=2*1024,tt=2**32-1,yu=Buffer.from([0,0,0,5,we.INIT,0,0,0,3]),Su=Buffer.from([0,0,0,5,Ut.VERSION,0,0,0,3]),wu=/^SSH-2.0-(?:OpenSSH|dropbear)/,js=256*1024,C=bu(),mu={readable:!1,writable:!1,push:n=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function pa(){}var Js=class extends Eu{constructor(t,e,r){super(),(typeof r!="object"||!r)&&(r={});let i=t._protocol._remoteIdentRaw;this.server=!!r.server,this._debug=typeof r.debug=="function"?r.debug:void 0,this._isOpenSSH=i&&wu.test(i),this._version=-1,this._extensions={},this._biOpt=r.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=js,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?js:34e3)-ua,this._maxWriteLen=(this._isOpenSSH?js:34e3)-ua,this.maxOpenHandles=void 0,this._client=t,this._protocol=t._protocol,this._callbacks=[],this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this._waitWindow=!1,this._chunkcb=void 0,this._buffer=[],this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this.stderr=mu,this.readable=!0}push(t){if(t===null){if(ya(this),!this.readable)return;this.readable=!1,this.emit("end");return}let e=0;for(;e<t.length;){if(this._pktLenBytes<4){let o=Math.min(4-this._pktLenBytes,t.length-e);for(this._pktLenBytes+=o;o--;)this._pktLen=(this._pktLen<<8)+t[e++];if(this._pktLenBytes<4)return;if(this._pktLen===0)return ze(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let f=this._maxInPktLen;return ze(this,`Packet length ${this._pktLen} exceeds max length of ${f}`)}if(e>=t.length)return}if(this._pktPos<this._pktLen){let o=Math.min(this._pktLen-this._pktPos,t.length-e);if(e!==0||o!==t.length?o===this._pktLen?this._pkt=new pu(t.buffer,t.byteOffset+e,o):(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._pktPos)):o===this._pktLen?this._pkt=t:(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(t,this._pktPos)),e+=o,this._pktPos+=o,this._pktPos<this._pktLen)return}let r=this._pkt[0],i=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let s=this.server?Nu[r]:Ru[r];if(!s)return ze(this,`Unknown packet type ${r}`);if(this._version===-1){if(this.server){if(r!==we.INIT)return ze(this,`Expected INIT packet, got ${r}`)}else if(r!==Ut.VERSION)return ze(this,`Expected VERSION packet, got ${r}`)}if(s(this,i)===!1)return}}end(){this.destroy()}destroy(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._protocol.channelClose(this.outgoing.id))}_init(){this._init=pa,this.server||We(this,yu)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new fn(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new Kt(this,t,e)}open(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(i=r,r=void 0);let s=typeof e=="number"?e:Ia(e);if(s===null)throw new Error(`Unknown flags string: ${e}`);let o=0,f=0;(typeof r=="string"||typeof r=="number")&&(r={mode:r}),typeof r=="object"&&r!==null&&(r=Cn(r),o=r.flags,f=r.nb);let a=Buffer.byteLength(t),h=9,d=Buffer.allocUnsafe(13+a+4+4+f);P(d,d.length-4,0),d[4]=we.OPEN;let l=this._writeReqid=this._writeReqid+1&tt;P(d,l,5),P(d,a,h),d.utf8Write(t,h+=4,a),P(d,s,h+=a),P(d,o,h+=4),f&&(h+=4,f===Be.length?d.set(Be,h):gn(Be,d,0,f,h),h+=f),this._requests[l]={cb:i};let _=We(this,d);this._debug&&this._debug(`SFTP: Outbound: ${_?"Buffered":"Sending"} OPEN`)}close(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.CLOSE;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.set(t,i+=4),this._requests[o]={cb:e};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} CLOSE`)}read(t,e,r,i,s,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>=e.length)throw new Error("offset is out of bounds");if(r+i>e.length)throw new Error("length extends beyond buffer");if(s===null)throw new Error("null position currently unsupported");ba(this,t,e,r,i,s,o)}readData(t,e,r,i,s,o){this.read(t,e,r,i,s,o)}write(t,e,r,i,s,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>e.length)throw new Error("offset is out of bounds");if(r+i>e.length)throw new Error("length extends beyond buffer");if(s===null)throw new Error("null position currently unsupported");if(!i){o&&process.nextTick(o,void 0,0);return}let f=this._maxWriteLen,a=Math.max(i-f,0),h=s;a&&(i=f);let d=t.length,l=9,_=Buffer.allocUnsafe(13+d+8+4+i);P(_,_.length-4,0),_[4]=we.WRITE;let p=this._writeReqid=this._writeReqid+1&tt;P(_,p,5),P(_,d,l),_.set(t,l+=4),l+=d;for(let I=7;I>=0;--I)_[l+I]=s&255,s/=256;P(_,i,l+=8),gn(e,_,r,r+i,l+=4),this._requests[p]={cb:I=>{I?typeof o=="function"&&o(I):a?this.write(t,e,r+i,a,h+i,o):typeof o=="function"&&o(void 0,r+i)}};let x=We(this,_);if(this._debug){let I=x?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${I} WRITE (id:${p})`)}}writeData(t,e,r,i,s,o){this.write(t,e,r,i,s,o)}fastGet(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");la(this,_n,t,e,r,i)}fastPut(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");la(_n,this,t,e,r,i)}readFile(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof r=="function"?i=r:typeof e=="function"&&(i=e,e=void 0),typeof e=="string")e={encoding:e,flag:"r"};else if(!e)e={encoding:null,flag:"r"};else if(typeof e!="object")throw new TypeError("Bad arguments");let s=e.encoding;if(s&&!Buffer.isEncoding(s))throw new Error(`Unknown encoding: ${s}`);let o,f,a,h=0,d,l=0,_=e.flag||"r",p=()=>{o===0?(f=Buffer.allocUnsafe(8192),this.read(d,f,0,8192,l,x)):this.read(d,f,h,o-h,l,x)},x=(k,N)=>{let D;if(k){if(D=k.code===$e.EOF,!D)return this.close(d,()=>i&&i(k))}else D=!1;if(D||o===0&&N===0)return I();l+=N,h+=N,o!==0?h===o?I():p():(a.push(zn(f,0,N)),p())};x._wantEOFError=!0;let I=()=>{this.close(d,k=>(o===0?f=Buffer.concat(a,h):h<o&&(f=zn(f,0,h)),s&&(f=f.toString(s)),i&&i(k,f)))};this.open(t,_,438,(k,N)=>{if(k)return i&&i(k);d=N;let D=(Z,O)=>{if(Z){this.stat(t,(V,ee)=>{if(V)return this.close(d,()=>{i&&i(Z)});D(null,ee)});return}if(o=O.size||0,o===0)return a=[],p();f=Buffer.allocUnsafe(o),p()};this.fstat(d,D)})}writeFile(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof i=="function"?s=i:typeof r=="function"&&(s=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"w"};else if(!r)r={encoding:"utf8",mode:438,flag:"w"};else if(typeof r!="object")throw new TypeError("Bad arguments");if(r.encoding&&!Buffer.isEncoding(r.encoding))throw new Error(`Unknown encoding: ${r.encoding}`);let o=r.flag||"w";this.open(t,o,r.mode,(f,a)=>{if(f)s&&s(f);else{let h=Buffer.isBuffer(e)?e:Buffer.from(""+e,r.encoding||"utf8"),d=/a/.test(o)?null:0;if(d===null){let l=(_,p)=>{if(_){this.stat(t,(x,I)=>{if(x)return this.close(a,()=>{s&&s(_)});l(null,I)});return}Zs(this,a,h,0,h.length,p.size,s)};this.fstat(a,l);return}Zs(this,a,h,0,h.length,d,s)}})}appendFile(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof i=="function"?s=i:typeof r=="function"&&(s=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"a"};else if(!r)r={encoding:"utf8",mode:438,flag:"a"};else if(typeof r!="object")throw new TypeError("Bad arguments");r.flag||(r=Object.assign({flag:"a"},r)),this.writeFile(t,e,r,s)}exists(t,e){if(this.server)throw new Error("Client-only method called in server mode");this.stat(t,r=>{e&&e(!r)})}unlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.REMOVE;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} REMOVE`)}rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(t),s=Buffer.byteLength(e),o=9,f=Buffer.allocUnsafe(13+i+4+s);P(f,f.length-4,0),f[4]=we.RENAME;let a=this._writeReqid=this._writeReqid+1&tt;P(f,a,5),P(f,i,o),f.utf8Write(t,o+=4,i),P(f,s,o+=i),f.utf8Write(e,o+=4,s),this._requests[a]={cb:r};let h=We(this,f);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} RENAME`)}mkdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let i=0,s=0;typeof e=="function"&&(r=e,e=void 0),typeof e=="object"&&e!==null&&(e=Cn(e),i=e.flags,s=e.nb);let o=Buffer.byteLength(t),f=9,a=Buffer.allocUnsafe(13+o+4+s);P(a,a.length-4,0),a[4]=we.MKDIR;let h=this._writeReqid=this._writeReqid+1&tt;P(a,h,5),P(a,o,f),a.utf8Write(t,f+=4,o),P(a,i,f+=o),s&&(f+=4,s===Be.length?a.set(Be,f):gn(Be,a,0,s,f),f+=s),this._requests[h]={cb:r};let d=We(this,a);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} MKDIR`)}rmdir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.RMDIR;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} RMDIR`)}readdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");typeof e=="function"&&(r=e,e={}),(typeof e!="object"||e===null)&&(e={});let i=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){let d=[],l=0,_=(p,x)=>{if(p)return r(p);this.readdir(x,e,(I,k)=>{let N=I&&I.code===$e.EOF;if(I&&!N)return this.close(x,()=>r(I));if(N)return this.close(x,D=>{if(D)return r(D);r(void 0,d)});for(let D=0;D<k.length;++D,++l)d[l]=k[D];_(void 0,x)})};return this.opendir(t,_)}let s=t.length,o=9,f=Buffer.allocUnsafe(13+s);P(f,f.length-4,0),f[4]=we.READDIR;let a=this._writeReqid=this._writeReqid+1&tt;P(f,a,5),P(f,s,o),f.set(t,o+=4),this._requests[a]={cb:i?(d,l)=>{if(typeof r=="function"){if(d)return r(d);for(let _=l.length-1;_>=0;--_)(l[_].filename==="."||l[_].filename==="..")&&l.splice(_,1);r(void 0,l)}}:r};let h=We(this,f);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} READDIR`)}fstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.FSTAT;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.set(t,i+=4),this._requests[o]={cb:e};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} FSTAT`)}stat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.STAT;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} STAT`)}lstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.LSTAT;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} LSTAT`)}opendir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.OPENDIR;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} OPENDIR`)}setstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let i=0,s=0;typeof e=="object"&&e!==null?(e=Cn(e),i=e.flags,s=e.nb):typeof e=="function"&&(r=e);let o=Buffer.byteLength(t),f=9,a=Buffer.allocUnsafe(13+o+4+s);P(a,a.length-4,0),a[4]=we.SETSTAT;let h=this._writeReqid=this._writeReqid+1&tt;P(a,h,5),P(a,o,f),a.utf8Write(t,f+=4,o),P(a,i,f+=o),s&&(f+=4,s===Be.length?a.set(Be,f):gn(Be,a,0,s,f),f+=s),this._requests[h]={cb:r};let d=We(this,a);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} SETSTAT`)}fsetstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let i=0,s=0;typeof e=="object"&&e!==null?(e=Cn(e),i=e.flags,s=e.nb):typeof e=="function"&&(r=e);let o=t.length,f=9,a=Buffer.allocUnsafe(13+o+4+s);P(a,a.length-4,0),a[4]=we.FSETSTAT;let h=this._writeReqid=this._writeReqid+1&tt;P(a,h,5),P(a,o,f),a.set(t,f+=4),P(a,i,f+=o),s&&(f+=4,s===Be.length?a.set(Be,f):gn(Be,a,0,s,f),f+=s),this._requests[h]={cb:r};let d=We(this,a);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,r,i){return this.fsetstat(t,{atime:jn(e),mtime:jn(r)},i)}utimes(t,e,r,i){return this.setstat(t,{atime:jn(e),mtime:jn(r)},i)}fchown(t,e,r,i){return this.fsetstat(t,{uid:e,gid:r},i)}chown(t,e,r,i){return this.setstat(t,{uid:e,gid:r},i)}fchmod(t,e,r){return this.fsetstat(t,{mode:e},r)}chmod(t,e,r){return this.setstat(t,{mode:e},r)}readlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.READLINK;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:(a,h)=>{if(typeof e=="function"){if(a)return e(a);if(!h||!h.length)return e(new Error("Response missing link info"));e(void 0,h[0].filename)}}};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} READLINK`)}symlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),s=Buffer.byteLength(t),o=9,f=Buffer.allocUnsafe(13+i+4+s);P(f,f.length-4,0),f[4]=we.SYMLINK;let a=this._writeReqid=this._writeReqid+1&tt;P(f,a,5),this._isOpenSSH?(P(f,s,o),f.utf8Write(t,o+=4,s),P(f,i,o+=s),f.utf8Write(e,o+=4,i)):(P(f,i,o),f.utf8Write(e,o+=4,i),P(f,s,o+=i),f.utf8Write(t,o+=4,s)),this._requests[a]={cb:r};let h=We(this,f);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=we.REALPATH;let o=this._writeReqid=this._writeReqid+1&tt;P(s,o,5),P(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:(a,h)=>{if(typeof e=="function"){if(a)return e(a);if(!h||!h.length)return e(new Error("Response missing path info"));e(void 0,h[0].filename)}}};let f=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let i=this._extensions["posix-rename@openssh.com"];if(!i||i!=="1")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),o=Buffer.byteLength(e),f=9,a=Buffer.allocUnsafe(41+s+4+o);P(a,a.length-4,0),a[4]=we.EXTENDED;let h=this._writeReqid=this._writeReqid+1&tt;P(a,h,5),P(a,24,f),a.utf8Write("posix-rename@openssh.com",f+=4,24),P(a,s,f+=24),a.utf8Write(t,f+=4,s),P(a,o,f+=s),a.utf8Write(e,f+=4,o),this._requests[h]={cb:r};let d=We(this,a);if(this._debug){let l=d?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} posix-rename@openssh.com`)}}ext_openssh_statvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["statvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),s=9,o=Buffer.allocUnsafe(36+i);P(o,o.length-4,0),o[4]=we.EXTENDED;let f=this._writeReqid=this._writeReqid+1&tt;P(o,f,5),P(o,19,s),o.utf8Write("statvfs@openssh.com",s+=4,19),P(o,i,s+=19),o.utf8Write(t,s+=4,i),this._requests[f]={extended:"statvfs@openssh.com",cb:e};let a=We(this,o);if(this._debug){let h=a?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} statvfs@openssh.com`)}}ext_openssh_fstatvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["fstatvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let i=t.length,s=9,o=Buffer.allocUnsafe(37+i);P(o,o.length-4,0),o[4]=we.EXTENDED;let f=this._writeReqid=this._writeReqid+1&tt;P(o,f,5),P(o,20,s),o.utf8Write("fstatvfs@openssh.com",s+=4,20),P(o,i,s+=20),o.set(t,s+=4),this._requests[f]={extended:"fstatvfs@openssh.com",cb:e};let a=We(this,o);if(this._debug){let h=a?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} fstatvfs@openssh.com`)}}ext_openssh_hardlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["hardlink@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),o=Buffer.byteLength(e),f=9,a=Buffer.allocUnsafe(37+s+4+o);P(a,a.length-4,0),a[4]=we.EXTENDED;let h=this._writeReqid=this._writeReqid+1&tt;P(a,h,5),P(a,20,f),a.utf8Write("hardlink@openssh.com",f+=4,20),P(a,s,f+=20),a.utf8Write(t,f+=4,s),P(a,o,f+=s),a.utf8Write(e,f+=4,o),this._requests[h]={cb:r};let d=We(this,a);if(this._debug){let l=d?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} hardlink@openssh.com`)}}ext_openssh_fsync(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["fsync@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let i=t.length,s=9,o=Buffer.allocUnsafe(34+i);P(o,o.length-4,0),o[4]=we.EXTENDED;let f=this._writeReqid=this._writeReqid+1&tt;P(o,f,5),P(o,17,s),o.utf8Write("fsync@openssh.com",s+=4,17),P(o,i,s+=17),o.set(t,s+=4),this._requests[f]={cb:e};let a=We(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["lsetstat@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let s=0,o=0;typeof e=="object"&&e!==null?(e=Cn(e),s=e.flags,o=e.nb):typeof e=="function"&&(r=e);let f=Buffer.byteLength(t),a=9,h=Buffer.allocUnsafe(37+f+4+o);P(h,h.length-4,0),h[4]=we.EXTENDED;let d=this._writeReqid=this._writeReqid+1&tt;P(h,d,5),P(h,20,a),h.utf8Write("lsetstat@openssh.com",a+=4,20),P(h,f,a+=20),h.utf8Write(t,a+=4,f),P(h,s,a+=f),o&&(a+=4,o===Be.length?h.set(Be,a):gn(Be,h,0,o,a),a+=o),this._requests[d]={cb:r};let l=We(this,h);if(this._debug){let _=l?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${_} lsetstat@openssh.com`)}}ext_openssh_expandPath(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["expand-path@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),s=9,o=Buffer.allocUnsafe(40+i);P(o,o.length-4,0),o[4]=we.EXTENDED;let f=this._writeReqid=this._writeReqid+1&tt;P(o,f,5),P(o,23,s),o.utf8Write("expand-path@openssh.com",s+=4,23),P(o,i,s+=20),o.utf8Write(t,s+=4,i),this._requests[f]={cb:(h,d)=>{if(typeof e=="function"){if(h)return e(h);if(!d||!d.length)return e(new Error("Response missing expanded path"));e(void 0,d[0].filename)}}};let a=We(this,o);if(this._debug){let h=a?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} expand-path@openssh.com`)}}ext_copy_data(t,e,r,i,s,o){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["copy-data"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("Source handle is not a Buffer");if(!Buffer.isBuffer(i))throw new Error("Destination handle is not a Buffer");let a=0,h=Buffer.allocUnsafe(26+t.length+8+8+4+i.length+8);P(h,h.length-4,a),a+=4,h[a]=we.EXTENDED,++a;let d=this._writeReqid=this._writeReqid+1&tt;P(h,d,a),a+=4,P(h,9,a),a+=4,h.utf8Write("copy-data",a,9),a+=9,P(h,t.length,a),a+=4,h.set(t,a),a+=t.length;for(let _=7;_>=0;--_)h[a+_]=e&255,e/=256;a+=8;for(let _=7;_>=0;--_)h[a+_]=r&255,r/=256;a+=8,P(h,i.length,a),a+=4,h.set(i,a),a+=i.length;for(let _=7;_>=0;--_)h[a+_]=s&255,s/=256;this._requests[d]={cb:o};let l=We(this,h);if(this._debug){let _=l?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${_} copy-data`)}}ext_home_dir(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["home-directory"]!=="1")throw new Error("Server does not support this extended request");if(typeof t!="string")throw new TypeError("username is not a string");let i=0,s=Buffer.byteLength(t),o=Buffer.allocUnsafe(31+s);P(o,o.length-4,i),i+=4,o[i]=we.EXTENDED,++i;let f=this._writeReqid=this._writeReqid+1&tt;P(o,f,i),i+=4,P(o,14,i),i+=4,o.utf8Write("home-directory",i,14),i+=14,P(o,s,i),i+=4,o.utf8Write(t,i,s),i+=s,this._requests[f]={cb:(h,d)=>{if(typeof e=="function"){if(h)return e(h);if(!d||!d.length)return e(new Error("Response missing home directory"));e(void 0,d[0].filename)}}};let a=We(this,o);if(this._debug){let h=a?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} home-directory`)}}ext_users_groups(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["users-groups-by-id@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Array.isArray(t))throw new TypeError("uids is not an array");for(let h of t)if(!Number.isInteger(h)||h<0||h>2**32-1)throw new Error("uid values must all be 32-bit unsigned integers");if(!Array.isArray(e))throw new TypeError("gids is not an array");for(let h of e)if(!Number.isInteger(h)||h<0||h>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let s=0,o=Buffer.allocUnsafe(47+4*t.length+4+4*e.length);P(o,o.length-4,s),s+=4,o[s]=we.EXTENDED,++s;let f=this._writeReqid=this._writeReqid+1&tt;P(o,f,s),s+=4,P(o,30,s),s+=4,o.utf8Write("users-groups-by-id@openssh.com",s,30),s+=30,P(o,4*t.length,s),s+=4;for(let h of t)P(o,h,s),s+=4;P(o,4*e.length,s),s+=4;for(let h of e)P(o,h,s),s+=4;this._requests[f]={extended:"users-groups-by-id@openssh.com",cb:r};let a=We(this,o);if(this._debug){let h=a?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} users-groups-by-id@openssh.com`)}}handle(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let r=e.length;if(r>256)throw new Error("handle too large (> 256 bytes)");let i=9,s=Buffer.allocUnsafe(13+r);P(s,s.length-4,0),s[4]=Ut.HANDLE,P(s,t,5),P(s,r,i),r&&s.set(e,i+=4);let o=We(this,s);this._debug&&this._debug(`SFTP: Outbound: ${o?"Buffered":"Sending"} HANDLE`)}status(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!Iu.has(e))throw new Error(`Bad status code: ${e}`);r||(r="");let i=Buffer.byteLength(r),s=9,o=Buffer.allocUnsafe(17+i+4);P(o,o.length-4,0),o[4]=Ut.STATUS,P(o,t,5),P(o,e,s),P(o,i,s+=4),s+=4,i&&(o.utf8Write(r,s,i),s+=i),P(o,0,s);let f=We(this,o);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} STATUS`)}data(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");let i=Buffer.isBuffer(e);if(!i&&typeof e!="string")throw new Error("data is not a Buffer or string");let s;!i&&!r&&(r=void 0,s=!0);let o=i?e.length:Buffer.byteLength(e,r),f=9,a=Buffer.allocUnsafe(13+o);P(a,a.length-4,0),a[4]=Ut.DATA,P(a,t,5),P(a,o,f),o&&(i?a.set(e,f+=4):s?a.utf8Write(e,f+=4,o):a.write(e,f+=4,o,r));let h=We(this,a);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} DATA`)}name(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Array.isArray(e)){if(typeof e!="object"||e===null)throw new Error("names is not an object or array");e=[e]}let r=e.length,i=0,s,o=[];for(let d=0;d<r;++d){let l=e[d],_=!l||!l.filename||typeof l.filename!="string"?"":l.filename;i+=4+Buffer.byteLength(_);let p=!l||!l.longname||typeof l.longname!="string"?"":l.longname;if(i+=4+Buffer.byteLength(p),typeof l.attrs=="object"&&l.attrs!==null){if(s=Cn(l.attrs),i+=4+s.nb,s.nb){let x;s.nb===Be.length?x=new Uint8Array(Be):(x=new Uint8Array(s.nb),gn(Be,x,0,s.nb,0)),s.bytes=x}o.push(s)}else i+=4,o.push(null)}let f=9,a=Buffer.allocUnsafe(13+i);P(a,a.length-4,0),a[4]=Ut.NAME,P(a,t,5),P(a,r,f),f+=4;for(let d=0;d<r;++d){let l=e[d];{let p=!l||!l.filename||typeof l.filename!="string"?"":l.filename,x=Buffer.byteLength(p);P(a,x,f),f+=4,x&&(a.utf8Write(p,f,x),f+=x)}{let p=!l||!l.longname||typeof l.longname!="string"?"":l.longname,x=Buffer.byteLength(p);P(a,x,f),f+=4,x&&(a.utf8Write(p,f,x),f+=x)}let _=o[d];_?(P(a,_.flags,f),f+=4,_.flags&&_.bytes&&(a.set(_.bytes,f),f+=_.nb)):(P(a,0,f),f+=4)}let h=We(this,a);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} NAME`)}attrs(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(typeof e!="object"||e===null)throw new Error("attrs is not an object");e=Cn(e);let r=e.flags,i=e.nb,s=9,o=Buffer.allocUnsafe(13+i);P(o,o.length-4,0),o[4]=Ut.ATTRS,P(o,t,5),P(o,r,s),i&&(s+=4,i===Be.length?o.set(Be,s):gn(Be,o,0,i,s),s+=i);let f=We(this,o);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} ATTRS`)}};function Bu(n){try{return Buffer.allocUnsafe(n)}catch(t){return t}}function ba(n,t,e,r,i,s,o,f){let a=n._maxReadLen,h=Math.max(i-a,0);h&&(i=a);let d=t.length,l=9,_=s,p=Buffer.allocUnsafe(13+d+8+4);P(p,p.length-4,0),p[4]=we.READ;let x=n._writeReqid=n._writeReqid+1&tt;P(p,x,5),P(p,d,l),p.set(t,l+=4),l+=d;for(let N=7;N>=0;--N)p[l+N]=_&255,_/=256;P(p,i,l+=8),typeof o!="function"&&(o=pa);let I=f||{nb:0,position:s,off:r,origOff:r,len:void 0,overflow:void 0,cb:(N,D,Z)=>{let O=I.len,V=I.overflow;if(N){if(o._wantEOFError||N.code!==$e.EOF)return o(N)}else{if(Z>O)return o(new Error("Received more data than requested"));if(Z===O&&V){I.nb+=Z,I.position+=Z,I.off+=Z,ba(n,t,e,I.off,V,I.position,o,I);return}}Z=Z||0,I.origOff===0&&e.length===I.nb?D=e:D=zn(e,I.origOff,I.origOff+I.nb+Z),o(void 0,I.nb+Z,D,I.position)},buffer:void 0};I.len=i,I.overflow=h,I.buffer=zn(e,r,r+i),n._requests[x]=I;let k=We(n,p);n._debug&&n._debug(`SFTP: Outbound: ${k?"Buffered":"Sending"} READ`)}function la(n,t,e,r,i,s){let o=64,f=32768,a,h,d;typeof i=="function"?s=i:typeof i=="object"&&i!==null&&(typeof i.concurrency=="number"&&i.concurrency>0&&!isNaN(i.concurrency)&&(o=i.concurrency),typeof i.chunkSize=="number"&&i.chunkSize>0&&!isNaN(i.chunkSize)&&(f=i.chunkSize),typeof i.fileSize=="number"&&i.fileSize>0&&!isNaN(i.fileSize)&&(d=i.fileSize),typeof i.step=="function"&&(a=i.step),(typeof i.mode=="string"||typeof i.mode=="number")&&(h=io(i.mode)));let l,_=0,p=0,x=!1,I,k,N,D=f*o;function Z(O){if(x)return;x=!0;let V=0,ee;I||k?(ee=()=>{--V===0&&s(O)},I&&(n===_n||n.outgoing.state==="open")&&++V,k&&(t===_n||t.outgoing.state==="open")&&++V,I&&(n===_n||n.outgoing.state==="open")&&n.close(I,ee),k&&(t===_n||t.outgoing.state==="open")&&t.close(k,ee)):s(O)}n.open(e,"r",(O,V)=>{if(O)return Z(O);I=V,d===void 0?n.fstat(I,ee):ee(null,{size:d});function ee(X,y){if(X){if(n!==_n){n.stat(e,(S,v)=>{if(S)return Z(X);ee(null,v)});return}return Z(X)}l=y.size,t.open(r,"w",(S,v)=>{if(S)return Z(S);if(k=v,l<=0)return Z();for(;D>l;){if(o===1){D=l;break}D-=f,--o}if(N=Bu(D),N instanceof Error)return Z(N);h!==void 0?t.fchmod(k,h,function j(te){if(te){t.chmod(r,h,ie=>j());return}J()}):J();function M(j,te,ie,T,F,H){if(j)return Z(j);F=F||0,t.write(k,N,F,te,T,$);function $(le){if(le)return Z(le);if(p+=te,a&&a(p,te,l),te<H)return re(F,T+te,H-te);if(p===l){t.close(k,Ae=>{if(k=void 0,Ae)return Z(Ae);n.close(I,st=>{if(I=void 0,st)return Z(st);s()})});return}if(_>=l)return;let _e=_+f>l?l-_:f;re(F,_,_e),_+=_e}}function Q(j,te,ie){return(T,F,H)=>{M(T,F,H,te,j,ie)}}function re(j,te,ie){n.read(I,N,j,ie,te,Q(j,te,ie))}function J(){let j=0,te=0;for(;_<l&&j<o;){let ie=_+f>l?l-_:f;re(te,_,ie),te+=ie,_+=ie,++j}}})}})}function Zs(n,t,e,r,i,s,o){let f=typeof o=="function"?o:void 0;n.write(t,e,r,i,s,(a,h)=>{if(a)return n.close(t,()=>{f&&f(a)});h===i?n.close(t,f):(r+=h,i-=h,s+=h,Zs(n,t,e,r,i,s,f))})}var wi=class{constructor(t){this.mode=t&&t.mode,this.uid=t&&t.uid,this.gid=t&&t.gid,this.size=t&&t.size,this.atime=t&&t.atime,this.mtime=t&&t.mtime,this.extended=t&&t.extended}isDirectory(){return(this.mode&Lt.S_IFMT)===Lt.S_IFDIR}isFile(){return(this.mode&Lt.S_IFMT)===Lt.S_IFREG}isBlockDevice(){return(this.mode&Lt.S_IFMT)===Lt.S_IFBLK}isCharacterDevice(){return(this.mode&Lt.S_IFMT)===Lt.S_IFCHR}isSymbolicLink(){return(this.mode&Lt.S_IFMT)===Lt.S_IFLNK}isFIFO(){return(this.mode&Lt.S_IFMT)===Lt.S_IFIFO}isSocket(){return(this.mode&Lt.S_IFMT)===Lt.S_IFSOCK}};function Cn(n){let t=0,e=0;if(typeof n=="object"&&n!==null){if(typeof n.size=="number"){t|=on.SIZE;let r=n.size;Be[e++]=r/72057594037927940,Be[e++]=r/281474976710656,Be[e++]=r/1099511627776,Be[e++]=r/4294967296,Be[e++]=r/16777216,Be[e++]=r/65536,Be[e++]=r/256,Be[e++]=r}if(typeof n.uid=="number"&&typeof n.gid=="number"){t|=on.UIDGID;let r=n.uid,i=n.gid;Be[e++]=r>>>24,Be[e++]=r>>>16,Be[e++]=r>>>8,Be[e++]=r,Be[e++]=i>>>24,Be[e++]=i>>>16,Be[e++]=i>>>8,Be[e++]=i}if(typeof n.mode=="number"||typeof n.mode=="string"){let r=io(n.mode);t|=on.PERMISSIONS,Be[e++]=r>>>24,Be[e++]=r>>>16,Be[e++]=r>>>8,Be[e++]=r}if((typeof n.atime=="number"||zs(n.atime))&&(typeof n.mtime=="number"||zs(n.mtime))){let r=jn(n.atime),i=jn(n.mtime);t|=on.ACMODTIME,Be[e++]=r>>>24,Be[e++]=r>>>16,Be[e++]=r>>>8,Be[e++]=r,Be[e++]=i>>>24,Be[e++]=i>>>16,Be[e++]=i>>>8,Be[e++]=i}}return{flags:t,nb:e}}function jn(n){if(typeof n=="number"&&n===n)return n;if(zs(n))return parseInt(n.getTime()/1e3,10);throw new Error(`Cannot parse time: ${n}`)}function io(n){if(typeof n=="number"&&n===n)return n;if(typeof n=="string")return io(parseInt(n,8));throw new Error(`Cannot parse mode: ${n}`)}var eo={r:xe.READ,"r+":xe.READ|xe.WRITE,w:xe.TRUNC|xe.CREAT|xe.WRITE,wx:xe.TRUNC|xe.CREAT|xe.WRITE|xe.EXCL,xw:xe.TRUNC|xe.CREAT|xe.WRITE|xe.EXCL,"w+":xe.TRUNC|xe.CREAT|xe.READ|xe.WRITE,"wx+":xe.TRUNC|xe.CREAT|xe.READ|xe.WRITE|xe.EXCL,"xw+":xe.TRUNC|xe.CREAT|xe.READ|xe.WRITE|xe.EXCL,a:xe.APPEND|xe.CREAT|xe.WRITE,ax:xe.APPEND|xe.CREAT|xe.WRITE|xe.EXCL,xa:xe.APPEND|xe.CREAT|xe.WRITE|xe.EXCL,"a+":xe.APPEND|xe.CREAT|xe.READ|xe.WRITE,"ax+":xe.APPEND|xe.CREAT|xe.READ|xe.WRITE|xe.EXCL,"xa+":xe.APPEND|xe.CREAT|xe.READ|xe.WRITE|xe.EXCL};function Ia(n){let t=eo[n];return t!==void 0?t:null}var Cu=(()=>{let n=Object.keys(eo);return t=>{for(let e=0;e<n.length;++e){let r=n[e];if(eo[r]===t)return r}return null}})();function Vn(n){let t=C.readUInt32BE();if(t===void 0)return;let e=new wi;if(t&on.SIZE){let r=C.readUInt64BE(n);if(r===void 0)return;e.size=r}if(t&on.UIDGID){let r=C.readUInt32BE(),i=C.readUInt32BE();if(i===void 0)return;e.uid=r,e.gid=i}if(t&on.PERMISSIONS){let r=C.readUInt32BE();if(r===void 0)return;e.mode=r}if(t&on.ACMODTIME){let r=C.readUInt32BE(),i=C.readUInt32BE();if(i===void 0)return;e.atime=r,e.mtime=i}if(t&on.EXTENDED){let r=C.readUInt32BE();if(r===void 0)return;let i={};for(let s=0;s<r;++s){let o=C.readString(!0),f=C.readString();if(f===void 0)return;i[o]=f}e.extended=i}return e}function We(n,t){let e=xa(n,t);return e!==void 0?(n._buffer.push(e),!1):!0}function xa(n,t){let e=n.outgoing;if(e.state!=="open")return;if(e.window===0)return n._waitWindow=!0,n._chunkcb=da,t;let r,i=t.length,s=0;for(;i-s>0&&e.window>0;){let o=Math.min(i-s,e.window,e.packetSize);e.window-=o,e.window===0&&(n._waitWindow=!0,n._chunkcb=da),s===0&&o===i?n._protocol.channelData(n.outgoing.id,t):n._protocol.channelData(n.outgoing.id,zn(t,s,s+o)),s+=o}return i-s>0&&(s>0?r=zn(t,s,i):r=t),r}function da(){this._chunkcb=void 0;let n=this._buffer,t=0;for(;t<n.length;){let e=n[t],r=xa(this,e);if(r!==void 0){r!==e&&(n[t]=r),t>0&&(this._buffer=n.slice(t));return}++t}t>0&&(this._buffer=[])}function ze(n,t,e){let r=new Error(t);return r.level="sftp-protocol",!e&&n._debug&&n._debug(`SFTP: Inbound: ${t}`),n.emit("error",r),n.destroy(),ya(n),!1}function ya(n){let t=Object.keys(n._requests);if(t.length===0)return;let e=n._requests;n._requests={};let r=new Error("No response from server");for(let i=0;i<t.length;++i){let s=e[t[i]];typeof s.cb=="function"&&s.cb(r)}}function ku(n,t){let e=9,r=Buffer.allocUnsafe(31);P(r,r.length-4,0),r[4]=we.EXTENDED;let i=n._writeReqid=n._writeReqid+1&tt;P(r,i,5),P(r,18,e),r.utf8Write("limits@openssh.com",e+=4,18),n._requests[i]={extended:"limits@openssh.com",cb:t};let s=We(n,r);if(n._debug){let o=s?"Buffered":"Sending";n._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}var Ru={[Ut.VERSION]:(n,t)=>{if(n._version!==-1)return ze(n,"Duplicate VERSION packet");let e={};C.init(t,1);let r=C.readUInt32BE();for(;C.avail();){let i=C.readString(!0),s=C.readString(!0);if(s===void 0){r=void 0;break}e[i]=s}if(C.clear(),r===void 0)return ze(n,"Malformed VERSION packet");if(n._debug){let i=Object.keys(e);i.length?n._debug(`SFTP: Inbound: Received VERSION (v${r}, exts:${i})`):n._debug(`SFTP: Inbound: Received VERSION (v${r})`)}if(n._version=r,n._extensions=e,e["limits@openssh.com"]==="1")return ku(n,(i,s)=>{i||(s.maxPktLen>0&&(n._maxOutPktLen=s.maxPktLen),s.maxReadLen>0&&(n._maxReadLen=s.maxReadLen),s.maxWriteLen>0&&(n._maxWriteLen=s.maxWriteLen),n.maxOpenHandles=s.maxOpenHandles>0?s.maxOpenHandles:1/0),n.emit("ready")});n.emit("ready")},[Ut.STATUS]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readUInt32BE(),i=C.readString(!0);if(C.clear(),n._debug){let o=JSON.stringify(i);n._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${r}, ${o})`)}let s=n._requests[e];if(delete n._requests[e],s&&typeof s.cb=="function"){if(r===$e.OK){s.cb();return}let o=new Error(i||xu[r]||"Unknown status");o.code=r,s.cb(o)}},[Ut.HANDLE]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString();if(C.clear(),r===void 0)return e!==void 0&&delete n._requests[e],ze(n,"Malformed HANDLE packet");n._debug&&n._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);let i=n._requests[e];delete n._requests[e],i&&typeof i.cb=="function"&&i.cb(void 0,r)},[Ut.DATA]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r;if(e!==void 0&&(r=n._requests[e],delete n._requests[e]),r&&typeof r.cb=="function")if(r.buffer){let i=C.readString(r.buffer);if(C.clear(),i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${i})`),r.cb(void 0,r.buffer,i);return}}else{let i=C.readString();if(C.clear(),i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${i.length})`),r.cb(void 0,i);return}}else{let i=C.skipString();if(C.clear(),i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${i})`);return}}return ze(n,"Malformed DATA packet")},[Ut.NAME]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let i=C.readUInt32BE();if(i!==void 0){let s=[];for(let o=0;o<i;++o){let f=C.readString(!0),a=C.readString(!0),h=Vn(n._biOpt);if(h===void 0){s=void 0;break}s.push({filename:f,longname:a,attrs:h})}if(s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received NAME (id:${e}, ${s.length})`),C.clear(),r&&typeof r.cb=="function"&&r.cb(void 0,s);return}}return C.clear(),ze(n,"Malformed NAME packet")},[Ut.ATTRS]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let i=Vn(n._biOpt);if(C.clear(),i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),r&&typeof r.cb=="function"&&r.cb(void 0,i);return}return ze(n,"Malformed ATTRS packet")},[Ut.EXTENDED]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE();if(e!==void 0){let r=n._requests[e];if(r)switch(delete n._requests[e],r.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let i=n._biOpt,s={f_bsize:C.readUInt64BE(i),f_frsize:C.readUInt64BE(i),f_blocks:C.readUInt64BE(i),f_bfree:C.readUInt64BE(i),f_bavail:C.readUInt64BE(i),f_files:C.readUInt64BE(i),f_ffree:C.readUInt64BE(i),f_favail:C.readUInt64BE(i),f_sid:C.readUInt64BE(i),f_flag:C.readUInt64BE(i),f_namemax:C.readUInt64BE(i)};if(s.f_namemax===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),C.clear(),typeof r.cb=="function"&&r.cb(void 0,s);return}case"limits@openssh.com":{let i={maxPktLen:C.readUInt64BE(),maxReadLen:C.readUInt64BE(),maxWriteLen:C.readUInt64BE(),maxOpenHandles:C.readUInt64BE()};if(i.maxOpenHandles===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),C.clear(),typeof r.cb=="function"&&r.cb(void 0,i);return}case"users-groups-by-id@openssh.com":{let i=C.readUInt32BE();if(i===void 0)break;let s=new Array(i);for(let a=0;a<s.length;++a)s[a]=C.readString(!0);let o=C.readUInt32BE();if(o===void 0)break;let f=new Array(o);for(let a=0;a<f.length;++a)f[a]=C.readString(!0);if(f.length>0&&f[f.length-1]===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),C.clear(),typeof r.cb=="function"&&r.cb(void 0,s,f);return}default:n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),C.clear(),typeof r.cb=="function"&&r.cb();return}else{n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),C.clear();return}}return C.clear(),ze(n,"Malformed EXTENDED_REPLY packet")}},Nu={[we.INIT]:(n,t)=>{if(n._version!==-1)return ze(n,"Duplicate INIT packet");let e={};C.init(t,1);let r=C.readUInt32BE();for(;C.avail();){let i=C.readString(!0),s=C.readString(!0);if(s===void 0){r=void 0;break}e[i]=s}if(C.clear(),r===void 0)return ze(n,"Malformed INIT packet");if(n._debug){let i=Object.keys(e);i.length?n._debug(`SFTP: Inbound: Received INIT (v${r}, exts:${i})`):n._debug(`SFTP: Inbound: Received INIT (v${r})`)}We(n,Su),n._version=r,n._extensions=e,n.emit("ready")},[we.OPEN]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0),i=C.readUInt32BE(),s=Vn(n._biOpt);if(C.clear(),s===void 0)return ze(n,"Malformed OPEN packet");n._debug&&n._debug(`SFTP: Inbound: Received OPEN (id:${e})`),n.emit("OPEN",e,r,i,s)||n.status(e,$e.OP_UNSUPPORTED)},[we.CLOSE]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString();if(C.clear(),r===void 0||r.length>256)return ze(n,"Malformed CLOSE packet");n._debug&&n._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),n.emit("CLOSE",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.READ]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(),i=C.readUInt64BE(n._biOpt),s=C.readUInt32BE();if(C.clear(),s===void 0||r.length>256)return ze(n,"Malformed READ packet");n._debug&&n._debug(`SFTP: Inbound: Received READ (id:${e})`),n.emit("READ",e,r,i,s)||n.status(e,$e.OP_UNSUPPORTED)},[we.WRITE]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(),i=C.readUInt64BE(n._biOpt),s=C.readString();if(C.clear(),s===void 0||r.length>256)return ze(n,"Malformed WRITE packet");n._debug&&n._debug(`SFTP: Inbound: Received WRITE (id:${e})`),n.emit("WRITE",e,r,i,s)||n.status(e,$e.OP_UNSUPPORTED)},[we.LSTAT]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0);if(C.clear(),r===void 0)return ze(n,"Malformed LSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),n.emit("LSTAT",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.FSTAT]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString();if(C.clear(),r===void 0||r.length>256)return ze(n,"Malformed FSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),n.emit("FSTAT",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.SETSTAT]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0),i=Vn(n._biOpt);if(C.clear(),i===void 0)return ze(n,"Malformed SETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),n.emit("SETSTAT",e,r,i)||n.status(e,$e.OP_UNSUPPORTED)},[we.FSETSTAT]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(),i=Vn(n._biOpt);if(C.clear(),i===void 0||r.length>256)return ze(n,"Malformed FSETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),n.emit("FSETSTAT",e,r,i)||n.status(e,$e.OP_UNSUPPORTED)},[we.OPENDIR]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0);if(C.clear(),r===void 0)return ze(n,"Malformed OPENDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),n.emit("OPENDIR",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.READDIR]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString();if(C.clear(),r===void 0||r.length>256)return ze(n,"Malformed READDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received READDIR (id:${e})`),n.emit("READDIR",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.REMOVE]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0);if(C.clear(),r===void 0)return ze(n,"Malformed REMOVE packet");n._debug&&n._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),n.emit("REMOVE",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.MKDIR]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0),i=Vn(n._biOpt);if(C.clear(),i===void 0)return ze(n,"Malformed MKDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),n.emit("MKDIR",e,r,i)||n.status(e,$e.OP_UNSUPPORTED)},[we.RMDIR]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0);if(C.clear(),r===void 0)return ze(n,"Malformed RMDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),n.emit("RMDIR",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.REALPATH]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0);if(C.clear(),r===void 0)return ze(n,"Malformed REALPATH packet");n._debug&&n._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),n.emit("REALPATH",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.STAT]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0);if(C.clear(),r===void 0)return ze(n,"Malformed STAT packet");n._debug&&n._debug(`SFTP: Inbound: Received STAT (id:${e})`),n.emit("STAT",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.RENAME]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0),i=C.readString(!0);if(C.clear(),i===void 0)return ze(n,"Malformed RENAME packet");n._debug&&n._debug(`SFTP: Inbound: Received RENAME (id:${e})`),n.emit("RENAME",e,r,i)||n.status(e,$e.OP_UNSUPPORTED)},[we.READLINK]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0);if(C.clear(),r===void 0)return ze(n,"Malformed READLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received READLINK (id:${e})`),n.emit("READLINK",e,r)||n.status(e,$e.OP_UNSUPPORTED)},[we.SYMLINK]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0),i=C.readString(!0);if(C.clear(),i===void 0)return ze(n,"Malformed SYMLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let s;n._isOpenSSH?s=n.emit("SYMLINK",e,i,r):s=n.emit("SYMLINK",e,r,i),s||n.status(e,$e.OP_UNSUPPORTED)},[we.EXTENDED]:(n,t)=>{C.init(t,1);let e=C.readUInt32BE(),r=C.readString(!0);if(r===void 0)return C.clear(),ze(n,"Malformed EXTENDED packet");let i;C.avail()&&(i=C.readRaw()),C.clear(),n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),n.emit("EXTENDED",e,r,i)||n.status(e,$e.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:Tu,ERR_OUT_OF_RANGE:Si,validateNumber:vu}=ha(),Aa=128,Nt,to=[];function Lu(n){to.length>0?Nt=to.pop():Nt=Buffer.allocUnsafe(n),Nt.used=0}function no(n,t){if(!Number.isSafeInteger(n))throw vu(n,t),Number.isInteger(n)?new Si(t,">= 0 and <= 2 ** 53 - 1",n):new Si(t,"an integer",n);if(n<0)throw new Si(t,">= 0 and <= 2 ** 53 - 1",n)}function Vs(n){return n+7&-8}function fn(n,t,e){if(e===void 0)e={};else if(typeof e=="string")e={encoding:e};else{if(e===null||typeof e!="object")throw new TypeError('"options" argument must be a string or an object');e=Object.create(e)}if(e.highWaterMark===void 0&&(e.highWaterMark=64*1024),e.emitClose=!1,e.autoDestroy=!1,_a.call(this,e),this.path=t,this.flags=e.flags===void 0?"r":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.end=e.end,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesRead=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=n,this._opening=!1,this.start!==void 0&&(no(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(no(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new Si("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}Ea(fn,_a);fn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t,this.emit("open",t),this.emit("ready"),this.read()}))};fn.prototype._read=function(n){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(n));if(this.destroyed)return;(!Nt||Nt.length-Nt.used<Aa)&&Lu(this.readableHighWaterMark||this._readableState.highWaterMark);let t=Nt,e=Math.min(Nt.length-Nt.used,n),r=Nt.used;if(this.end!==void 0&&(e=Math.min(this.end-this.pos+1,e)),e<=0)return this.push(null);this.sftp.read(this.handle,Nt,Nt.used,e,this.pos,(i,s)=>{if(i){this.emit("error",i),this.autoClose&&this.destroy();return}let o=null;if(r+e===t.used&&t===Nt)t.used=Vs(t.used+s-e);else{let f=r+e&-8,a=Vs(r+s);f-a>=Aa&&to.push(t.slice(a,f))}s>0&&(this.bytesRead+=s,o=t.slice(r,r+s)),this.pos+=s,this.push(o)}),Nt.used=Vs(Nt.used+e)};fn.prototype._destroy=function(n,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",ga.bind(null,this,t,n));return}ga(this,t,n),this.handle=null,this._opening=!1};function ga(n,t,e){if(!n.handle)return r();n.sftp.close(n.handle,r);function r(i){i=i||e,t(i),n.isClosed=!0,i||n.emit("close")}}fn.prototype.close=function(n){this.destroy(null,n)};Object.defineProperty(fn.prototype,"pending",{get(){return this.handle===null},configurable:!0});function Kt(n,t,e){if(e===void 0)e={};else if(typeof e=="string")e={encoding:e};else{if(e===null||typeof e!="object")throw new TypeError('"options" argument must be a string or an object');e=Object.create(e)}e.emitClose=!1,e.autoDestroy=!1,ro.call(this,e),this.path=t,this.flags=e.flags===void 0?"w":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesWritten=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=n,this._opening=!1,this.start!==void 0&&(no(this.start,"start"),this.pos=this.start),e.encoding&&this.setDefaultEncoding(e.encoding),this.on("finish",function(){this._writableState.finalCalled||this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}Ea(Kt,ro);Kt.prototype._final=function(n){this.autoClose&&this.destroy(),n()};Kt.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t;let e=r=>{if(r){this.sftp.chmod(this.path,this.mode,i=>e());return}if(this.flags[0]==="a"){let i=(s,o)=>{if(s){this.sftp.stat(this.path,(f,a)=>{if(f){this.destroy(),this.emit("error",s);return}i(null,a)});return}this.pos=o.size,this.emit("open",t),this.emit("ready")};this.sftp.fstat(t,i);return}this.emit("open",t),this.emit("ready")};this.sftp.fchmod(t,this.mode,e)}))};Kt.prototype._write=function(n,t,e){if(!Buffer.isBuffer(n)){let r=new Tu("data","Buffer",n);return this.emit("error",r)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(n,t,e)});this.sftp.write(this.handle,n,0,n.length,this.pos,(r,i)=>{if(r)return this.autoClose&&this.destroy(),e(r);this.bytesWritten+=i,e()}),this.pos+=n.length};Kt.prototype._writev=function(n,t){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(n,t)});let e=this.sftp,r=this.handle,i=n.length,s=(o,f)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=f,--i===0&&t()};for(let o=0;o<n.length;++o){let f=n[o].chunk;e.write(r,f,0,f.length,this.pos,s),this.pos+=f.length}};typeof ro.prototype.destroy!="function"&&(Kt.prototype.destroy=fn.prototype.destroy);Kt.prototype._destroy=fn.prototype._destroy;Kt.prototype.close=function(n){if(n){if(this.isClosed){process.nextTick(n);return}this.on("close",n)}this.autoClose||this.on("finish",this.destroy.bind(this)),this.end()};Kt.prototype.destroySoon=Kt.prototype.end;Object.defineProperty(Kt.prototype,"pending",{get(){return this.handle===null},configurable:!0});Sa.exports={flagsToString:Cu,OPEN_MODE:xe,SFTP:Js,Stats:wi,STATUS_CODE:$e,stringToFlags:Ia}});var ho=Ze((Wd,Ca)=>{"use strict";var{Duplex:Uu,Readable:Ou,Writable:Pu}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:wa}}=nn(),{bufferSlice:mi}=Wt(),Du=32*1024,Rr=2*1024*1024,ao=Rr/2,so=class extends Ou{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=ao&&co(this._channel))}},oo=class extends Pu{constructor(t){super({highWaterMark:Rr}),this._channel=t}_write(t,e,r){let i=this._channel,s=i._client._protocol,o=i.outgoing,f=o.packetSize,a=o.id,h=o.window,d=t.length,l=0;if(o.state==="open"){for(;d-l>0&&h>0;){let _=d-l;_>h&&(_=h),_>f&&(_=f),l===0&&_===d?s.channelExtData(a,t,wa):s.channelExtData(a,mi(t,l,l+_),wa),l+=_,h-=_}if(o.window=h,d-l>0){h===0&&(i._waitWindow=!0),l>0?i._chunkErr=mi(t,l,d):i._chunkErr=t,i._chunkcbErr=r;return}r()}}},fo=class extends Uu{constructor(t,e,r){let i={highWaterMark:Rr,allowHalfOpen:!r||r&&r.allowHalfOpen!==!1,emitClose:!1};super(i),this.allowHalfOpen=i.allowHalfOpen;let s=!!(r&&r.server);this.server=s,this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this._callbacks=[],this._client=t,this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this.stdin=this.stdout=this,s?this.stderr=new oo(this):this.stderr=new so(this,i),this._waitWindow=!1,this._waitChanDrain=!1,this._chunk=void 0,this._chunkcb=void 0,this._chunkErr=void 0,this._chunkcbErr=void 0,this.on("finish",ma).on("prefinish",ma),this.on("end",Ba).on("close",Ba)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=ao&&co(this))}_write(t,e,r){let i=this._client._protocol,s=this.outgoing,o=s.packetSize,f=s.id,a=s.window,h=t.length,d=0;if(s.state==="open"){for(;h-d>0&&a>0;){let l=h-d;l>a&&(l=a),l>o&&(l=o),d===0&&l===h?i.channelData(f,t):i.channelData(f,mi(t,d,d+l)),d+=l,a-=l}if(s.window=a,h-d>0){a===0&&(this._waitWindow=!0),d>0?this._chunk=mi(t,d,h):this._chunk=t,this._chunkcb=r;return}r()}}eof(){this.outgoing.state==="open"&&(this.outgoing.state="eof",this._client._protocol.channelEOF(this.outgoing.id))}close(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._client._protocol.channelClose(this.outgoing.id))}destroy(){return this.end(),this.close(),this}setWindow(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&(this.subtype==="shell"||this.subtype==="exec")&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.windowChange(this.outgoing.id,t,e,r,i)}signal(t){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.signal(this.outgoing.id,t)}exit(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&(typeof t=="number"?this._client._protocol.exitStatus(this.outgoing.id,t):this._client._protocol.exitSignal(this.outgoing.id,t,e,r))}};function ma(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function Ba(){this.readable=!1}function co(n){if(n.outgoing.state==="closed")return;let t=Rr-n.incoming.window;t<=0||(n.incoming.window+=t,n._client._protocol.channelWindowAdjust(n.outgoing.id,t))}Ca.exports={Channel:fo,MAX_WINDOW:Rr,PACKET_SIZE:Du,windowAdjust:co,WINDOW_THRESHOLD:ao}});var Ao=Ze((Gd,Na)=>{"use strict";var{SFTP:Qu}=kr(),Nr=2**32-1;function ka(n,t,e,r){if(n._chanMgr.remove(t),typeof r!="function")return;let i;e instanceof Error?i=e:typeof e=="object"&&e!==null?(i=new Error(`(SSH) Channel open failure: ${e.description}`),i.reason=e.reason):(i=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),i.reason=""),r(i)}function Ra(n,t,e,r,i){if(typeof e=="function"){ka(n,t,r,e);return}if(typeof e!="object"||e===null||e.incoming&&e.incoming.state==="closed"||(n._chanMgr.remove(t),e.server&&e.constructor.name==="Session"))return;e.incoming.state="closed",e.readable&&e.push(null),e.server?e.stderr.writable&&e.stderr.end():e.stderr.readable&&e.stderr.push(null),e.constructor!==Qu&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!i&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");let s=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!i&&e.end();let f=e._callbacks;e._callbacks=[];for(let a=0;a<f.length;++a)f[a](!0);if(e.server)!e.readable||e.destroyed||s&&s.endEmitted?e.emit("close"):e.once("end",()=>e.emit("close"));else{let a;switch(e.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":a=()=>e.emit("close");break;default:{let d=e._exit;a=()=>{d.code===null?e.emit("close",d.code,d.signal,d.dump,d.desc):e.emit("close",d.code)}}}!e.readable||e.destroyed||s&&s.endEmitted?a():e.once("end",a);let h=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||h&&h.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}var lo=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<Nr)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{let r=this._channels;for(let i=0;i<Nr;++i)if(r[i]===void 0){e=i;break}}return e===void 0?-1:(this._channels[e]=t||!0,++this._count,e)}update(t,e){if(typeof t!="number"||t<0||t>=Nr||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);e&&this._channels[t]&&(this._channels[t]=e)}get(t){if(typeof t!="number"||t<0||t>=Nr||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=Nr||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);this._channels[t]&&(delete this._channels[t],this._count&&--this._count)}cleanup(t){let e=this._channels;this._channels={},this._cur=-1,this._count=0;let r=Object.keys(e),i=this._client;for(let s=0;s<r.length;++s){let o=+r[s],f=e[o];Ra(i,o,f._channel||f,t,!0)}}},uo=(()=>{let n=Object.prototype.toString;return t=>n.call(t)==="[object RegExp]"})();function Hu(n,t,e){if(Array.isArray(n)&&n.length>0){for(let r=0;r<n.length;++r)if(e.indexOf(n[r])===-1)throw new Error(`Unsupported algorithm: ${n[r]}`);return n}if(typeof n=="object"&&n!==null){let r=Object.keys(n),i=t;for(let s=0;s<r.length;++s){let o=r[s],f=n[o];switch(o){case"append":if(Array.isArray(f)||(f=[f]),Array.isArray(f))for(let a=0;a<f.length;++a){let h=f[a];if(typeof h=="string"){if(!h||i.indexOf(h)!==-1)continue;if(e.indexOf(h)===-1)throw new Error(`Unsupported algorithm: ${h}`);i===t&&(i=i.slice()),i.push(h)}else if(uo(h))for(let d=0;d<e.length;++d){let l=e[d];if(h.test(l)){if(i.indexOf(l)!==-1)continue;i===t&&(i=i.slice()),i.push(l)}}}break;case"prepend":if(Array.isArray(f)||(f=[f]),Array.isArray(f))for(let a=f.length;a>=0;--a){let h=f[a];if(typeof h=="string"){if(!h||i.indexOf(h)!==-1)continue;if(e.indexOf(h)===-1)throw new Error(`Unsupported algorithm: ${h}`);i===t&&(i=i.slice()),i.unshift(h)}else if(uo(h))for(let d=e.length;d>=0;--d){let l=e[d];if(h.test(l)){if(i.indexOf(l)!==-1)continue;i===t&&(i=i.slice()),i.unshift(l)}}}break;case"remove":if(Array.isArray(f)||(f=[f]),Array.isArray(f))for(let a=0;a<f.length;++a){let h=f[a];if(typeof h=="string"){if(!h)continue;let d=i.indexOf(h);if(d===-1)continue;i===t&&(i=i.slice()),i.splice(d,1)}else if(uo(h))for(let d=0;d<i.length;++d)h.test(i[d])&&(i===t&&(i=i.slice()),i.splice(d,1),--d)}break}}return i}return t}Na.exports={ChannelManager:lo,generateAlgorithmList:Hu,onChannelOpenFailure:ka,onCHANNEL_CLOSE:Ra,isWritable:n=>n&&n.writable&&n._readableState&&n._readableState.ended===!1}});var xo=Ze((Yd,Va)=>{"use strict";var{createHash:Fu,getHashes:Mu,randomFillSync:qu}=require("crypto"),{Socket:Ku}=require("net"),{lookup:Wu}=require("dns"),Gu=require("events"),Yu=Mu(),{COMPAT:$a,CHANNEL_EXTENDED_DATATYPE:{STDERR:$u},CHANNEL_OPEN_FAILURE:Tr,DEFAULT_CIPHER:Ta,DEFAULT_COMPRESSION:va,DEFAULT_KEX:La,DEFAULT_MAC:Ua,DEFAULT_SERVER_HOST_KEY:Oa,DISCONNECT_REASON:Pa,DISCONNECT_REASON_BY_VALUE:Xu,SUPPORTED_CIPHER:ju,SUPPORTED_COMPRESSION:Vu,SUPPORTED_KEX:zu,SUPPORTED_MAC:Ju,SUPPORTED_SERVER_HOST_KEY:Zu}=nn(),{init:el}=un(),tl=Xs(),{parseKey:ki}=An(),{SFTP:nl}=kr(),{bufferCopy:Da,makeBufferParser:Xa,makeError:rl,readUInt32BE:il,sigSSHToASN1:sl,writeUInt32BE:go}=Wt(),{AgentContext:Qa,createAgent:Ha,isAgent:Fa}=Ls(),{Channel:ja,MAX_WINDOW:Ri,PACKET_SIZE:Ni,windowAdjust:Ma,WINDOW_THRESHOLD:qa}=ho(),{ChannelManager:ol,generateAlgorithmList:vr,isWritable:_t,onChannelOpenFailure:fl,onCHANNEL_CLOSE:al}=Ao(),Bi=Xa(),Ci=Xa(),Lr=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,bo=n=>{},Io=class extends Gu{constructor(){super(),this.config={host:void 0,port:void 0,localAddress:void 0,localPort:void 0,forceIPv4:void 0,forceIPv6:void 0,keepaliveCountMax:void 0,keepaliveInterval:void 0,readyTimeout:void 0,ident:void 0,username:void 0,password:void 0,privateKey:void 0,tryKeyboard:void 0,agent:void 0,allowAgentFwd:void 0,authHandler:void 0,hostHashAlgo:void 0,hostHashCb:void 0,strictVendor:void 0,debug:void 0},this._agent=void 0,this._readyTimeout=void 0,this._chanMgr=void 0,this._callbacks=void 0,this._forwarding=void 0,this._forwardingUnix=void 0,this._acceptX11=void 0,this._agentFwdEnabled=void 0,this._remoteVer=void 0,this._protocol=void 0,this._sock=void 0,this._resetKA=void 0}connect(t){if(this._sock&&_t(this._sock))return this.once("close",()=>{this.connect(t)}),this.end(),this;this.config.host=t.hostname||t.host||"localhost",this.config.port=t.port||22,this.config.localAddress=typeof t.localAddress=="string"?t.localAddress:void 0,this.config.localPort=typeof t.localPort=="string"||typeof t.localPort=="number"?t.localPort:void 0,this.config.forceIPv4=t.forceIPv4||!1,this.config.forceIPv6=t.forceIPv6||!1,this.config.keepaliveCountMax=typeof t.keepaliveCountMax=="number"&&t.keepaliveCountMax>=0?t.keepaliveCountMax:3,this.config.keepaliveInterval=typeof t.keepaliveInterval=="number"&&t.keepaliveInterval>0?t.keepaliveInterval:0,this.config.readyTimeout=typeof t.readyTimeout=="number"&&t.readyTimeout>=0?t.readyTimeout:2e4,this.config.ident=typeof t.ident=="string"||Buffer.isBuffer(t.ident)?t.ident:void 0;let e={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:[]},sc:void 0},r=!0;if(typeof t.algorithms=="object"&&t.algorithms!==null&&(e.kex=vr(t.algorithms.kex,La,zu),e.kex!==La&&(r=!1),e.serverHostKey=vr(t.algorithms.serverHostKey,Oa,Zu),e.serverHostKey!==Oa&&(r=!1),e.cs.cipher=vr(t.algorithms.cipher,Ta,ju),e.cs.cipher!==Ta&&(r=!1),e.cs.mac=vr(t.algorithms.hmac,Ua,Ju),e.cs.mac!==Ua&&(r=!1),e.cs.compress=vr(t.algorithms.compress,va,Vu),e.cs.compress!==va&&(r=!1),r||(e.sc=e.cs)),typeof t.username=="string")this.config.username=t.username;else if(typeof t.user=="string")this.config.username=t.user;else throw new Error("Invalid username");this.config.password=typeof t.password=="string"?t.password:void 0,this.config.privateKey=typeof t.privateKey=="string"||Buffer.isBuffer(t.privateKey)?t.privateKey:void 0,this.config.localHostname=typeof t.localHostname=="string"?t.localHostname:void 0,this.config.localUsername=typeof t.localUsername=="string"?t.localUsername:void 0,this.config.tryKeyboard=t.tryKeyboard===!0,typeof t.agent=="string"&&t.agent.length?this.config.agent=Ha(t.agent):Fa(t.agent)?this.config.agent=t.agent:this.config.agent=void 0,this.config.allowAgentFwd=t.agentForward===!0&&this.config.agent!==void 0;let i=this.config.authHandler=typeof t.authHandler=="function"||Array.isArray(t.authHandler)?t.authHandler:void 0;this.config.strictVendor=typeof t.strictVendor=="boolean"?t.strictVendor:!0;let s=this.config.debug=typeof t.debug=="function"?t.debug:void 0;if(t.agentForward===!0&&!this.config.allowAgentFwd)throw new Error("You must set a valid agent path to allow agent forwarding");let o=this._callbacks=[];this._chanMgr=new ol(this),this._forwarding={},this._forwardingUnix={},this._acceptX11=0,this._agentFwdEnabled=!1,this._agent=this.config.agent?this.config.agent:void 0,this._remoteVer=void 0;let f;if(this.config.privateKey){if(f=ki(this.config.privateKey,t.passphrase),f instanceof Error)throw new Error(`Cannot parse privateKey: ${f.message}`);if(Array.isArray(f)&&(f=f[0]),f.getPrivatePEM()===null)throw new Error("privateKey value does not contain a (valid) private key")}let a;if(typeof t.hostVerifier=="function"){let T=t.hostVerifier,F;Yu.indexOf(t.hostHash)!==-1&&(F=t.hostHash),a=(H,$)=>{F&&(H=Fu(F).update(H).digest("hex"));let le=T(H,$);le!==void 0&&$(le)}}let h=this._sock=t.sock||new Ku,d=!1,l=!1;this._protocol&&this._protocol.cleanup();let _=s?(T,F,H)=>{s(`Debug output from server: ${JSON.stringify(H)}`)}:void 0,p,x=this._protocol=new tl({ident:this.config.ident,offer:r?void 0:e,onWrite:T=>{_t(h)&&h.write(T)},onError:T=>{T.level==="handshake"&&clearTimeout(this._readyTimeout),x._destruct||h.removeAllListeners("data"),this.emit("error",T);try{h.end()}catch{}},onHeader:T=>{l=!0,this._remoteVer=T.versions.software,T.greeting&&this.emit("greeting",T.greeting)},onHandshakeComplete:T=>{this.emit("handshake",T),d||(d=!0,x.service("ssh-userauth"))},debug:s,hostVerifier:a,messageHandlers:{DEBUG:_,DISCONNECT:(T,F,H)=>{if(F!==Pa.BY_APPLICATION){H||(H=Xu[F],H===void 0&&(H=`Unexpected disconnection reason: ${F}`));let $=new Error(H);$.code=F,this.emit("error",$)}h.end()},SERVICE_ACCEPT:(T,F)=>{F==="ssh-userauth"&&j()},EXT_INFO:(T,F)=>{if(p===void 0){for(let H of F)if(H.name==="server-sig-algs"){p=H.algs;return}p=null}},USERAUTH_BANNER:(T,F)=>{this.emit("banner",F)},USERAUTH_SUCCESS:T=>{O(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:(T,F,H)=>{if(y.keyAlgos){let $=y.keyAlgos[0][0];if(s&&s(`Client: ${y.type} (${$}) auth failed`),y.keyAlgos.shift(),y.keyAlgos.length){let[le,_e]=y.keyAlgos[0];switch(y.type){case"agent":x.authPK(y.username,y.agentCtx.currentKey(),le);return;case"publickey":x.authPK(y.username,y.key,le);return;case"hostbased":x.authHostbased(y.username,y.key,y.localHostname,y.localUsername,le,(Ae,st)=>{let St=y.key.sign(Ae,_e);if(St instanceof Error)return St.message=`Error while signing with key: ${St.message}`,St.level="client-authentication",this.emit("error",St),j();st(St)});return}}else y.keyAlgos=void 0}if(y.type==="agent"){let $=y.agentCtx.pos();return s&&s(`Client: Agent key #${$+1} failed`),te()}s&&s(`Client: ${y.type} auth failed`),S=H,v=F,j()},USERAUTH_PASSWD_CHANGEREQ:(T,F)=>{y.type==="password"&&this.emit("change password",F,H=>{x.authPassword(this.config.username,this.config.password,H)})},USERAUTH_PK_OK:T=>{let F,H;if(y.keyAlgos&&([F,H]=y.keyAlgos[0]),y.type==="agent"){let $=y.agentCtx.currentKey();x.authPK(y.username,$,F,(le,_e)=>{let Ae={hash:H};y.agentCtx.sign($,le,Ae,(st,St)=>{if(st)st.level="agent",this.emit("error",st);else return _e(St);te()})})}else y.type==="publickey"&&x.authPK(y.username,y.key,F,($,le)=>{let _e=y.key.sign($,H);if(_e instanceof Error)return _e.message=`Error signing data with key: ${_e.message}`,_e.level="client-authentication",this.emit("error",_e),j();le(_e)})},USERAUTH_INFO_REQUEST:(T,F,H,$)=>{if(y.type==="keyboard-interactive"){if((Array.isArray($)?$.length:0)===0){s&&s("Client: Sending automatic USERAUTH_INFO_RESPONSE"),x.authInfoRes();return}y.prompt(F,H,"",$,_e=>{x.authInfoRes(_e)})}},REQUEST_SUCCESS:(T,F)=>{o.length&&o.shift()(!1,F)},REQUEST_FAILURE:T=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:(T,F,H,$)=>{F==="hostkeys-00@openssh.com"?(dl(this,$,(le,_e)=>{le||this.emit("hostkeys",_e)}),H&&x.requestSuccess()):H&&x.requestFailure()},CHANNEL_OPEN:(T,F)=>{ul(this,F)},CHANNEL_OPEN_CONFIRMATION:(T,F)=>{let H=this._chanMgr.get(F.recipient);if(typeof H!="function")return;let $=H.type==="sftp",_e={type:$?"session":H.type,incoming:{id:F.recipient,window:Ri,packetSize:Ni,state:"open"},outgoing:{id:F.sender,window:F.window,packetSize:F.packetSize,state:"open"}},Ae=$?new nl(this,_e,{debug:s}):new ja(this,_e);this._chanMgr.update(F.recipient,Ae),H(void 0,Ae)},CHANNEL_OPEN_FAILURE:(T,F,H,$)=>{let le=this._chanMgr.get(F);if(typeof le!="function")return;fl(this,F,{reason:H,description:$},le)},CHANNEL_DATA:(T,F,H)=>{let $=this._chanMgr.get(F);if(!(typeof $!="object"||$===null)&&$.incoming.window!==0){if($.incoming.window-=H.length,$.push(H)===!1){$._waitChanDrain=!0;return}$.incoming.window<=qa&&Ma($)}},CHANNEL_EXTENDED_DATA:(T,F,H,$)=>{if($!==$u)return;let le=this._chanMgr.get(F);if(!(typeof le!="object"||le===null)&&le.incoming.window!==0){if(le.incoming.window-=H.length,!le.stderr.push(H)){le._waitChanDrain=!0;return}le.incoming.window<=qa&&Ma(le)}},CHANNEL_WINDOW_ADJUST:(T,F,H)=>{let $=this._chanMgr.get(F);typeof $!="object"||$===null||($.outgoing.window+=H,$._waitWindow&&($._waitWindow=!1,$._chunk?$._write($._chunk,null,$._chunkcb):$._chunkcb?$._chunkcb():$._chunkErr?$.stderr._write($._chunkErr,null,$._chunkcbErr):$._chunkcbErr&&$._chunkcbErr()))},CHANNEL_SUCCESS:(T,F)=>{let H=this._chanMgr.get(F);typeof H!="object"||H===null||(this._resetKA(),H._callbacks.length&&H._callbacks.shift()(!1))},CHANNEL_FAILURE:(T,F)=>{let H=this._chanMgr.get(F);typeof H!="object"||H===null||(this._resetKA(),H._callbacks.length&&H._callbacks.shift()(!0))},CHANNEL_REQUEST:(T,F,H,$,le)=>{let _e=this._chanMgr.get(F);if(typeof _e!="object"||_e===null)return;let Ae=_e._exit;if(Ae.code===void 0){switch(H){case"exit-status":_e.emit("exit",Ae.code=le);return;case"exit-signal":_e.emit("exit",Ae.code=null,Ae.signal=`SIG${le.signal}`,Ae.dump=le.coreDumped,Ae.desc=le.errorMessage);return}$&&T.channelFailure(_e.outgoing.id)}},CHANNEL_EOF:(T,F)=>{let H=this._chanMgr.get(F);typeof H!="object"||H===null||H.incoming.state==="open"&&(H.incoming.state="eof",H.readable&&H.push(null),H.stderr.readable&&H.stderr.push(null))},CHANNEL_CLOSE:(T,F)=>{al(this,F,this._chanMgr.get(F))}}});h.pause();let I=this.config.keepaliveInterval,k=this.config.keepaliveCountMax,N=0,D,Z=()=>{if(++N>k){if(clearInterval(D),h.readable){let T=new Error("Keepalive timeout");T.level="client-timeout",this.emit("error",T),h.destroy()}return}_t(h)?(o.push(O),x.ping()):clearInterval(D)};function O(){I>0&&(N=0,clearInterval(D),_t(h)&&(D=setInterval(Z,I)))}this._resetKA=O;let V=(()=>{let T=!1;return()=>{if(!T&&(T=!0,X&&!l)){let F=rl("Connection lost before handshake","protocol",!0);this.emit("error",F)}}})(),ee=(()=>{let T=!1;return()=>{T||(T=!0,X=!0,s&&s("Socket connected"),this.emit("connect"),el.then(()=>{x.start(),h.on("data",F=>{try{x.parse(F,0,F.length)}catch(H){this.emit("error",H);try{_t(h)&&h.end()}catch{}}}),h.stderr&&typeof h.stderr.resume=="function"&&h.stderr.resume(),h.resume()}).catch(F=>{this.emit("error",F);try{_t(h)&&h.end()}catch{}}))}})(),X=!1;h.on("connect",ee).on("timeout",()=>{this.emit("timeout")}).on("error",T=>{s&&s(`Socket error: ${T.message}`),clearTimeout(this._readyTimeout),T.level="client-socket",this.emit("error",T)}).on("end",()=>{s&&s("Socket ended"),V(),x.cleanup(),clearTimeout(this._readyTimeout),clearInterval(D),this.emit("end")}).on("close",()=>{s&&s("Socket closed"),V(),x.cleanup(),clearTimeout(this._readyTimeout),clearInterval(D),this.emit("close");let T=o;o=this._callbacks=[];let F=new Error("No response from server");for(let H=0;H<T.length;++H)T[H](F);this._chanMgr.cleanup(F)});let y,S=null,v=null,M=["none"];this.config.password!==void 0&&M.push("password"),f!==void 0&&M.push("publickey"),this._agent!==void 0&&M.push("agent"),this.config.tryKeyboard&&M.push("keyboard-interactive"),f!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&M.push("hostbased"),Array.isArray(i)?i=Ya(i):typeof i!="function"&&(i=Ya(M));let Q=!1,re=T=>{if(!Q){if(Q=!0,T===!1){let F=new Error("All configured authentication methods failed");F.level="client-authentication",this.emit("error",F),this.end();return}if(typeof T=="string"){let F=T;if(M.indexOf(F)===-1)return J(`Authentication method not allowed: ${F}`);let H=this.config.username;switch(F){case"password":T={type:F,username:H,password:this.config.password};break;case"publickey":T={type:F,username:H,key:f};break;case"hostbased":T={type:F,username:H,key:f,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":T={type:F,username:H,agentCtx:new Qa(this._agent)};break;case"keyboard-interactive":T={type:F,username:H,prompt:(...$)=>this.emit("keyboard-interactive",...$)};break;case"none":T={type:F,username:H};break;default:return J(`Skipping unsupported authentication method: ${T}`)}}else{if(typeof T!="object"||T===null)return J(`Skipping invalid authentication attempt: ${T}`);{let F=T.username;if(typeof F!="string")return J(`Skipping invalid authentication attempt: ${T}`);let H=T.type;switch(H){case"password":{let{password:$}=T;if(typeof $!="string"&&!Buffer.isBuffer($))return J("Skipping invalid password auth attempt");T={type:H,username:F,password:$};break}case"publickey":{let $=ki(T.key,T.passphrase);if($ instanceof Error)return J("Skipping invalid key auth attempt");if(!$.isPrivateKey())return J("Skipping non-private key");T={type:H,username:F,key:$};break}case"hostbased":{let{localHostname:$,localUsername:le}=T,_e=ki(T.key,T.passphrase);if(_e instanceof Error||typeof $!="string"||typeof le!="string")return J("Skipping invalid hostbased auth attempt");if(!_e.isPrivateKey())return J("Skipping non-private key");T={type:H,username:F,key:_e,localHostname:$,localUsername:le};break}case"agent":{let $=T.agent;if(typeof $=="string"&&$.length)$=Ha($);else if(!Fa($))return J(`Skipping invalid agent: ${T.agent}`);T={type:H,username:F,agentCtx:new Qa($)};break}case"keyboard-interactive":{let{prompt:$}=T;if(typeof $!="function")return J("Skipping invalid keyboard-interactive auth attempt");T={type:H,username:F,prompt:$};break}case"none":T={type:H,username:F};break;default:return J(`Skipping unsupported authentication method: ${T}`)}}}y=T;try{let F=y.username;switch(y.type){case"password":x.authPassword(F,y.password);break;case"publickey":{let H;if(y.keyAlgos=po(this,y.key,p),y.keyAlgos)if(y.keyAlgos.length)H=y.keyAlgos[0][0];else return J("Skipping key authentication (no mutual hash algorithm)");x.authPK(F,y.key,H);break}case"hostbased":{let H,$;if(y.keyAlgos=po(this,y.key,p),y.keyAlgos)if(y.keyAlgos.length)[H,$]=y.keyAlgos[0];else return J("Skipping hostbased authentication (no mutual hash algorithm)");x.authHostbased(F,y.key,y.localHostname,y.localUsername,H,(le,_e)=>{let Ae=y.key.sign(le,$);if(Ae instanceof Error)return Ae.message=`Error while signing with key: ${Ae.message}`,Ae.level="client-authentication",this.emit("error",Ae),j();_e(Ae)});break}case"agent":y.agentCtx.init(H=>{if(H)return H.level="agent",this.emit("error",H),j();te()});break;case"keyboard-interactive":x.authKeyboard(F);break;case"none":x.authNone(F);break}}finally{Q=!1}}};function J(T){s&&s(T),process.nextTick(j)}function j(){Q=!1;let T=i(v,S,re);Q||T===void 0||re(T)}let te=()=>{if(y.type==="agent"){let T=y.agentCtx.nextKey();if(T===!1)s&&s("Agent: No more keys left to try"),s&&s("Client: agent auth failed"),j();else{let F=y.agentCtx.pos(),H;if(y.keyAlgos=po(this,T,p),y.keyAlgos)if(y.keyAlgos.length)H=y.keyAlgos[0][0];else{s&&s(`Agent: Skipping key #${F+1} (no mutual hash algorithm)`),te();return}s&&s(`Agent: Trying key #${F+1}`),x.authPK(y.username,T,H)}}},ie=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let T=new Error("Timed out while waiting for handshake");T.level="client-timeout",this.emit("error",T),h.destroy()},this.config.readyTimeout))};if(t.sock)ie(),typeof h.connecting=="boolean"&&h.connecting||ee();else{let T=this.config.host,F=this.config.forceIPv4,H=this.config.forceIPv6;s&&s(`Client: Trying ${T} on port ${this.config.port} ...`);let $=()=>{ie(),h.connect({host:T,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),h.setMaxListeners(0),h.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!F&&!H||F&&H?$():Wu(T,F?4:6,(le,_e,Ae)=>{if(le){let st=F?"IPv4":"IPv6",St=new Error(`Error while looking up ${st} address for '${T}': ${le}`);clearTimeout(this._readyTimeout),St.level="client-dns",this.emit("error",St),this.emit("close");return}T=_e,$()})}return this}end(){return this._sock&&_t(this._sock)&&(this._protocol.disconnect(Pa.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&_t(this._sock)&&this._sock.destroy(),this}exec(t,e,r){if(!this._sock||!_t(this._sock))throw new Error("Not connected");typeof e=="function"&&(r=e,e={});let i={allowHalfOpen:e.allowHalfOpen!==!1};return Jn(this,"session",i,(s,o)=>{if(s){r(s);return}let f=[];function a(h){if(h){o.close(),r(h);return}f.length&&f.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&f.push(()=>Ga(o,a)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&_o(o,e.env),(typeof e.pty=="object"&&e.pty!==null||e.pty===!0)&&f.push(()=>Wa(o,e.pty,a)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&f.push(()=>Ka(o,e.x11,a))),f.push(()=>hl(o,t,e,r)),f.shift()()}),this}shell(t,e,r){if(!this._sock||!_t(this._sock))throw new Error("Not connected");return typeof t=="function"?(r=t,t=e=void 0):typeof e=="function"&&(r=e,e=void 0),t&&(t.x11!==void 0||t.env!==void 0)&&(e=t,t=void 0),Jn(this,"session",(i,s)=>{if(i){r(i);return}let o=[];function f(a){if(a){s.close(),r(a);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>Ga(s,f)),t!==!1&&o.push(()=>Wa(s,t,f)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&_o(s,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>Ka(s,e.x11,f))),o.push(()=>cl(s,r)),o.shift()()}),this}subsys(t,e){if(!this._sock||!_t(this._sock))throw new Error("Not connected");return Jn(this,"session",(r,i)=>{if(r){e(r);return}Eo(i,t,(s,o)=>{if(s){e(s);return}e(void 0,o)})}),this}forwardIn(t,e,r){if(!this._sock||!_t(this._sock))throw new Error("Not connected");let i=typeof r=="function";return i&&this._callbacks.push((s,o)=>{if(s){r(s!==!0?s:new Error(`Unable to bind to ${t}:${e}`));return}let f=e;e===0&&o&&o.length>=4&&(f=il(o,0),this._protocol._compatFlags&$a.DYN_RPORT_BUG||(e=f)),this._forwarding[`${t}:${e}`]=f,r(void 0,f)}),this._protocol.tcpipForward(t,e,i),this}unforwardIn(t,e,r){if(!this._sock||!_t(this._sock))throw new Error("Not connected");let i=typeof r=="function";return i&&this._callbacks.push(s=>{if(s){r(s!==!0?s:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],r()}),this._protocol.cancelTcpipForward(t,e,i),this}forwardOut(t,e,r,i,s){if(!this._sock||!_t(this._sock))throw new Error("Not connected");let o={srcIP:t,srcPort:e,dstIP:r,dstPort:i};return typeof s!="function"&&(s=bo),Jn(this,"direct-tcpip",o,s),this}openssh_noMoreSessions(t){if(!this._sock||!_t(this._sock))throw new Error("Not connected");let e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&Lr.test(this._remoteVer)?(e&&this._callbacks.push(r=>{if(r){t(r!==!0?r:new Error("Unable to disable future sessions"));return}t()}),this._protocol.openssh_noMoreSessions(e),this):e?(process.nextTick(t,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardInStreamLocal(t,e){if(!this._sock||!_t(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Lr.test(this._remoteVer)?(r&&this._callbacks.push(i=>{if(i){e(i!==!0?i:new Error(`Unable to bind to ${t}`));return}this._forwardingUnix[t]=!0,e()}),this._protocol.openssh_streamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(t,e){if(!this._sock||!_t(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Lr.test(this._remoteVer)?(r&&this._callbacks.push(i=>{if(i){e(i!==!0?i:new Error(`Unable to unbind from ${t}`));return}delete this._forwardingUnix[t],e()}),this._protocol.openssh_cancelStreamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(t,e){if(!this._sock||!_t(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=bo),!this.config.strictVendor||this.config.strictVendor&&Lr.test(this._remoteVer)?(Jn(this,"direct-streamlocal@openssh.com",{socketPath:t},e),this):(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this)}sftp(t,e){if(!this._sock||!_t(this._sock))throw new Error("Not connected");return typeof t=="function"&&(e=t,t=void 0),Jn(this,"sftp",(r,i)=>{if(r){e(r);return}let s=(o,f)=>{if(o){e(o);return}function a(){i.removeListener("ready",h),i.removeListener("error",d),i.removeListener("exit",l),i.removeListener("close",l)}function h(){a(),e(void 0,i)}function d(_){a(),e(_)}function l(_,p){a();let x;typeof _=="number"?x=`Received exit code ${_} while establishing SFTP session`:p!==void 0?x=`Received signal ${p} while establishing SFTP session`:x="Received unexpected SFTP session termination";let I=new Error(x);I.code=_,I.signal=p,e(I)}i.on("ready",h).on("error",d).on("exit",l).on("close",l),i._init()};typeof t=="object"&&t!==null?_o(i,t,o=>{if(o){e(o);return}Eo(i,"sftp",s)}):Eo(i,"sftp",s)}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function Jn(n,t,e,r){let i=Ri,s=Ni;typeof e=="function"&&(r=e,e={});let o=(a,h)=>{r(a,h)};o.type=t;let f=n._chanMgr.add(o);if(f===-1){r(new Error("No free channels available"));return}switch(t){case"session":case"sftp":n._protocol.session(f,i,s);break;case"direct-tcpip":n._protocol.directTcpip(f,i,s,e);break;case"direct-streamlocal@openssh.com":n._protocol.openssh_directStreamLocal(f,i,s,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Ka(n,t,e){let r={single:!1,protocol:"MIT-MAGIC-COOKIE-1",cookie:void 0,screen:0};typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.single=="boolean"&&(r.single=t.single),typeof t.screen=="number"&&(r.screen=t.screen),typeof t.protocol=="string"&&(r.protocol=t.protocol),typeof t.cookie=="string"?r.cookie=t.cookie:Buffer.isBuffer(t.cookie)&&(r.cookie=t.cookie.hexSlice(0,t.cookie.length))),r.cookie===void 0&&(r.cookie=ll());let i=typeof e=="function";if(n.outgoing.state!=="open"){i&&e(new Error("Channel is not open"));return}i&&n._callbacks.push(s=>{if(s){e(s!==!0?s:new Error("Unable to request X11"));return}n._hasX11=!0,++n._client._acceptX11,n.once("close",()=>{n._client._acceptX11&&--n._client._acceptX11}),e()}),n._client._protocol.x11Forward(n.outgoing.id,r,i)}function Wa(n,t,e){let r=24,i=80,s=640,o=480,f="vt100",a=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(r=t.rows),typeof t.cols=="number"&&(i=t.cols),typeof t.width=="number"&&(s=t.width),typeof t.height=="number"&&(o=t.height),typeof t.term=="string"&&(f=t.term),typeof t.modes=="object"&&(a=t.modes));let h=typeof e=="function";if(n.outgoing.state!=="open"){h&&e(new Error("Channel is not open"));return}h&&n._callbacks.push(d=>{if(d){e(d!==!0?d:new Error("Unable to request a pseudo-terminal"));return}e()}),n._client._protocol.pty(n.outgoing.id,r,i,o,s,f,a,h)}function Ga(n,t){let e=typeof t=="function";if(n.outgoing.state!=="open"){e&&t(new Error("Channel is not open"));return}if(n._client._agentFwdEnabled){e&&t(!1);return}n._client._agentFwdEnabled=!0,n._callbacks.push(r=>{if(r){n._client._agentFwdEnabled=!1,e&&t(r!==!0?r:new Error("Unable to request agent forwarding"));return}e&&t()}),n._client._protocol.openssh_agentForward(n.outgoing.id,!0)}function cl(n,t){if(n.outgoing.state!=="open"){t(new Error("Channel is not open"));return}n._callbacks.push(e=>{if(e){t(e!==!0?e:new Error("Unable to open shell"));return}n.subtype="shell",t(void 0,n)}),n._client._protocol.shell(n.outgoing.id,!0)}function hl(n,t,e,r){if(n.outgoing.state!=="open"){r(new Error("Channel is not open"));return}n._callbacks.push(i=>{if(i){r(i!==!0?i:new Error("Unable to exec"));return}n.subtype="exec",n.allowHalfOpen=e.allowHalfOpen!==!1,r(void 0,n)}),n._client._protocol.exec(n.outgoing.id,t,!0)}function _o(n,t,e){let r=typeof e=="function";if(n.outgoing.state!=="open"){r&&e(new Error("Channel is not open"));return}r&&n._callbacks.push(s=>{if(s){e(s!==!0?s:new Error("Unable to set environment"));return}e()});let i=Object.keys(t||{});for(let s=0;s<i.length;++s){let o=i[s],f=t[o];n._client._protocol.env(n.outgoing.id,o,f,r)}}function Eo(n,t,e){if(n.outgoing.state!=="open"){e(new Error("Channel is not open"));return}n._callbacks.push(r=>{if(r){e(r!==!0?r:new Error(`Unable to start subsystem: ${t}`));return}n.subtype="subsystem",e(void 0,n)}),n._client._protocol.subsystem(n.outgoing.id,t,!0)}function ul(n,t){let e=-1,r,i=()=>{let a={type:t.type,incoming:{id:e,window:Ri,packetSize:Ni,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},h=new ja(n,a);return n._chanMgr.update(e,h),n._protocol.channelOpenConfirm(t.sender,e,Ri,Ni),h},s=()=>{r===void 0&&(e===-1?r=Tr.RESOURCE_SHORTAGE:r=Tr.CONNECT_FAILED),e!==-1&&n._chanMgr.remove(e),n._protocol.channelOpenFail(t.sender,r,"")},o=()=>(e=n._chanMgr.add(),e===-1&&(r=Tr.RESOURCE_SHORTAGE,n.config.debug&&n.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),e!==-1),f=t.data;switch(t.type){case"forwarded-tcpip":{let a=n._forwarding[`${f.destIP}:${f.destPort}`];if(a!==void 0&&o()){f.destPort===0&&(f.destPort=a),n.emit("tcp connection",f,i,s);return}break}case"forwarded-streamlocal@openssh.com":if(n._forwardingUnix[f.socketPath]!==void 0&&o()){n.emit("unix connection",f,i,s);return}break;case"auth-agent@openssh.com":if(n._agentFwdEnabled&&typeof n._agent.getStream=="function"&&o()){n._agent.getStream((a,h)=>{if(a)return s();let d=i();d.pipe(h).pipe(d)});return}break;case"x11":if(n._acceptX11!==0&&o()){n.emit("x11",f,i,s);return}break;default:r=Tr.UNKNOWN_CHANNEL_TYPE,n.config.debug&&n.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}r===void 0&&(r=Tr.ADMINISTRATIVELY_PROHIBITED,n.config.debug&&n.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),s()}var ll=(()=>{let n=Buffer.allocUnsafe(16);return()=>(qu(n,0,16),n.hexSlice(0,16))})();function Ya(n){if(!Array.isArray(n))throw new Error("authList must be an array");let t=0;return(e,r,i)=>t===n.length?!1:n[t++]}function dl(n,t,e){if(!n._sock||!_t(n._sock))return;if(typeof e!="function"&&(e=bo),!Array.isArray(t))throw new TypeError("Invalid keys argument type");let r=[];for(let i of t){let s=ki(i);if(s instanceof Error)throw s;r.push(s)}if(!n.config.strictVendor||n.config.strictVendor&&Lr.test(n._remoteVer)){n._callbacks.push((i,s)=>{if(i){e(i!==!0?i:new Error("Server failed to prove supplied keys"));return}let o=[],f=0;for(Bi.init(s,0);Bi.avail()&&f!==r.length;){let a=r[f++],h=a.getPublicSSH(),d=Bi.readString();Ci.init(d,0);let l=Ci.readString(!0),_=Ci.readString(),p;if(l!==a.type)if(a.type==="ssh-rsa")switch(l){case"rsa-sha2-256":p="sha256";break;case"rsa-sha2-512":p="sha512";break;default:continue}else continue;let x=n._protocol._kex.sessionID,I=Buffer.allocUnsafe(37+x.length+4+h.length),k=0;go(I,29,k),I.utf8Write("hostkeys-prove-00@openssh.com",k+=4,29),go(I,x.length,k+=29),Da(x,I,0,x.length,k+=4),go(I,h.length,k+=x.length),Da(h,I,0,h.length,k+=4),(_=sl(_,l))&&a.verify(I,_,p)===!0&&o.push(a)}Ci.clear(),Bi.clear(),e(null,o)}),n._protocol.openssh_hostKeysProve(r);return}process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}function po(n,t,e){switch(t.type){case"ssh-rsa":if(n._protocol._compatFlags&$a.IMPLY_RSA_SHA2_SIGALGS&&(Array.isArray(e)?e=["rsa-sha2-256","rsa-sha2-512",...e]:e=["rsa-sha2-256","rsa-sha2-512"]),Array.isArray(e)){if(e.indexOf("rsa-sha2-256")!==-1)return[["rsa-sha2-256","sha256"]];if(e.indexOf("rsa-sha2-512")!==-1)return[["rsa-sha2-512","sha512"]];if(e.indexOf("ssh-rsa")===-1)return[]}return[["ssh-rsa","sha1"]]}}Va.exports=Io});var Ja=Ze(za=>{"use strict";var{Agent:So}=require("http"),{Agent:Al}=require("https"),{connect:gl}=require("tls"),yo;for(let n of[So,Al]){class t extends n{constructor(r,i){super(i),this._connectCfg=r,this._defaultSrcIP=i&&i.srcIP||"localhost"}createConnection(r,i){let s=r&&r.localAddress||this._defaultSrcIP,o=r&&r.localPort||0,f=r.host,a=r.port;yo===void 0&&(yo=xo());let h=new yo,d=!1;h.on("ready",()=>{h.forwardOut(s,o,f,a,(l,_)=>{if(d=!0,l)return h.end(),i(l);_.once("close",()=>h.end()),i(null,_l(_,n,r))})}).on("error",i).on("close",()=>{d||i(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}za[n===So?"SSHTTPAgent":"SSHTTPSAgent"]=t}function Ur(){}function _l(n,t,e){if(t===So)return n.setKeepAlive=Ur,n.setNoDelay=Ur,n.setTimeout=Ur,n.ref=Ur,n.unref=Ur,n.destroySoon=n.destroy,n;e.socket=n;let r=gl(e),i=(()=>{let s=!1;return()=>{s||(s=!0,n.isPaused()&&n.resume())}})();return r.on("end",i).on("close",i),r}});var ec=Ze((Xd,Co)=>{"use strict";var{Server:El}=require("net"),Pr=require("events"),{listenerCount:kt}=Pr,{CHANNEL_OPEN_FAILURE:Zn,DEFAULT_CIPHER:pl,DEFAULT_COMPRESSION:bl,DEFAULT_KEX:Il,DEFAULT_MAC:xl,DEFAULT_SERVER_HOST_KEY:yl,DISCONNECT_REASON:er,DISCONNECT_REASON_BY_VALUE:Sl,SUPPORTED_CIPHER:wl,SUPPORTED_COMPRESSION:ml,SUPPORTED_KEX:Bl,SUPPORTED_MAC:Cl,SUPPORTED_SERVER_HOST_KEY:kl}=nn(),{init:Rl}=un(),{KexInit:Nl}=di(),{parseKey:Za}=An(),Tl=Xs(),{SFTP:vl}=kr(),{writeUInt32BE:Ll}=Wt(),{Channel:tr,MAX_WINDOW:En,PACKET_SIZE:pn,windowAdjust:Ul,WINDOW_THRESHOLD:Ol}=ho(),{ChannelManager:Pl,generateAlgorithmList:Or,isWritable:Ti,onChannelOpenFailure:Dl,onCHANNEL_CLOSE:Ql}=Ao(),Hl=10,bn=class extends Pr{constructor(t,e,r,i,s){super(),this.username=this.user=e,this.service=r,this.method=i,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,f,a)=>{this._finalResponse||(this._finalResponse=!0,s(this,o,f,a))},this._protocol=t}accept(){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!0)}reject(t,e){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!1,t,e)}},vi=class extends bn{constructor(t,e,r,i,s,o){super(t,e,r,i,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=f=>{let a=this._cb;a&&(this._cb=void 0,a(f))},this.submethods=s,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,r,i){Array.isArray(t)||(t=[t]),typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"?(i=r,r=void 0):typeof i!="function"&&(i=void 0);for(let s=0;s<t.length;++s)typeof t[s]=="string"&&(t[s]={prompt:t[s],echo:!0});this._cb=i,this._initialResponse=!0,this._protocol.authInfoReq(e,r,t)}},mo=class extends bn{constructor(t,e,r,i,s,o){super(t,e,r,i,o),this.key={algo:s.keyAlgo,data:s.key},this.hashAlgo=s.hashAlgo,this.signature=s.signature,this.blob=s.blob}accept(){this.signature?bn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},Bo=class extends bn{constructor(t,e,r,i,s,o){super(t,e,r,i,o),this.key={algo:s.keyAlgo,data:s.key},this.hashAlgo=s.hashAlgo,this.signature=s.signature,this.blob=s.blob,this.localHostname=s.localHostname,this.localUsername=s.localUsername}},Li=class extends bn{constructor(t,e,r,i,s,o){super(t,e,r,i,o),this.password=s,this._changeCb=void 0}requestChange(t,e){if(this._changeCb)throw new Error("Change request already in progress");if(typeof t!="string")throw new Error("prompt argument must be a string");if(typeof e!="function")throw new Error("Callback argument must be a function");this._changeCb=e,this._protocol.authPasswdChg(t)}},zt=class extends Pr{constructor(t,e,r){super(),this.type="session",this.subtype=void 0,this.server=!0,this._ending=!1,this._channel=void 0,this._chanInfo={type:"session",incoming:{id:r,window:En,packetSize:pn,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}},Qt=class extends Pr{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");let r=Object.create(null),i=[],s=t.hostKeys;if(!Array.isArray(s))throw new Error("hostKeys must be an array");let o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},f=Or(o.serverHostKey,yl,kl);for(let _=0;_<s.length;++_){let p;if(Buffer.isBuffer(s[_])||typeof s[_]=="string"?p=Za(s[_]):p=Za(s[_].key,s[_].passphrase),p instanceof Error)throw new Error(`Cannot parse privateKey: ${p.message}`);if(Array.isArray(p)&&(p=p[0]),p.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!i.includes(p.type))if(p.type==="ssh-rsa"){let x=f.indexOf("ssh-rsa"),I=f.indexOf("rsa-sha2-256"),k=f.indexOf("rsa-sha2-512");x===-1&&(x=1/0),[x,I,k].sort(Fl).forEach(N=>{if(N===-1)return;let D;switch(N){case x:D="ssh-rsa";break;case I:D="rsa-sha2-256";break;case k:D="rsa-sha2-512";break;default:return}r[D]=p,i.push(D)})}else r[p.type]=p,i.push(p.type)}let a={kex:Or(o.kex,Il,Bl).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:i,cs:{cipher:Or(o.cipher,pl,wl),mac:Or(o.hmac,xl,Cl),compress:Or(o.compress,bl,ml),lang:[]},sc:void 0};a.sc=a.cs,typeof e=="function"&&this.on("connection",e);let h=typeof t.debug=="function"?t.debug:void 0,d=t.ident?Buffer.from(t.ident):void 0,l=new Nl(a);this._srv=new El(_=>{if(this._connections>=this.maxConnections){_.destroy();return}++this._connections,_.once("close",()=>{--this._connections});let p;if(h){let x=`[${process.hrtime().join(".")}] `;p=I=>{h(`${x}${I}`)}}new Ui(_,r,d,l,p,this,t)}).on("error",_=>{this.emit("error",_)}).on("listening",()=>{this.emit("listening")}).on("close",()=>{this.emit("close")}),this._connections=0,this.maxConnections=1/0}injectSocket(t){this._srv.emit("connection",t)}listen(...t){return this._srv.listen(...t),this}address(){return this._srv.address()}getConnections(t){return this._srv.getConnections(t),this}close(t){return this._srv.close(t),this}ref(){return this._srv.ref(),this}unref(){return this._srv.unref(),this}};Qt.KEEPALIVE_CLIENT_INTERVAL=15e3;Qt.KEEPALIVE_CLIENT_COUNT_MAX=3;var Ui=class extends Pr{constructor(t,e,r,i,s,o,f){super();let a=0,h=!1,d=[],l,_,p,x=[];this._sock=t,this._chanMgr=new Pl(this),this._debug=s,this.noMoreSessions=!1,this.authenticated=!1;function I(X){}this.on("error",I);let k=s?(X,y,S)=>{s(`Debug output from client: ${JSON.stringify(S)}`)}:void 0,N=typeof f.keepaliveInterval=="number"&&isFinite(f.keepaliveInterval)&&f.keepaliveInterval>0?f.keepaliveInterval:typeof Qt.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(Qt.KEEPALIVE_CLIENT_INTERVAL)&&Qt.KEEPALIVE_CLIENT_INTERVAL>0?Qt.KEEPALIVE_CLIENT_INTERVAL:-1,D=typeof f.keepaliveCountMax=="number"&&isFinite(f.keepaliveCountMax)&&f.keepaliveCountMax>=0?f.keepaliveCountMax:typeof Qt.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(Qt.KEEPALIVE_CLIENT_COUNT_MAX)&&Qt.KEEPALIVE_CLIENT_COUNT_MAX>=0?Qt.KEEPALIVE_CLIENT_COUNT_MAX:-1,Z=0;N!==-1&&D!==-1&&(this.once("ready",()=>{let X=()=>{clearInterval(_)};this.on("close",X).on("end",X),_=setInterval(()=>{if(++Z>D){clearInterval(_);let y=new Error("Keepalive timeout");y.level="client-timeout",this.emit("error",y),this.end()}else O.ping()},N)}),p=()=>{_&&_.refresh(),Z=0});let O=this._protocol=new Tl({server:!0,hostKeys:e,ident:r,offer:i,onPacket:p,greeting:f.greeting,banner:f.banner,onWrite:X=>{Ti(t)&&t.write(X)},onError:X=>{O._destruct||t.removeAllListeners("data"),this.emit("error",X);try{t.end()}catch{}},onHeader:X=>{this.removeListener("error",I);let y={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:X};if(!o.emit("connection",this,y)){O.disconnect(er.BY_APPLICATION),t.end();return}X.greeting&&this.emit("greeting",X.greeting)},onHandshakeComplete:X=>{++a>1&&this.emit("rekey"),this.emit("handshake",X)},debug:s,messageHandlers:{DEBUG:k,DISCONNECT:(X,y,S)=>{if(y!==er.BY_APPLICATION){S||(S=Sl[y],S===void 0&&(S=`Unexpected disconnection reason: ${y}`));let v=new Error(S);v.code=y,this.emit("error",v)}t.end()},CHANNEL_OPEN:(X,y)=>{if(y.type==="session"&&this.noMoreSessions||!this.authenticated){let te=Zn.ADMINISTRATIVELY_PROHIBITED;return O.channelOpenFail(y.sender,te)}let S=-1,v,M=!1,Q,re=()=>{M||(M=!0,v===void 0&&(S===-1?v=Zn.RESOURCE_SHORTAGE:v=Zn.CONNECT_FAILED),S!==-1&&this._chanMgr.remove(S),O.channelOpenFail(y.sender,v,""))},J=()=>(S=this._chanMgr.add(),S===-1&&(v=Zn.RESOURCE_SHORTAGE,s&&s("Automatic rejection of incoming channel open: no channels available")),S!==-1),j=y.data;switch(y.type){case"session":if(kt(this,"session")&&J()){Q=()=>{if(M)return;M=!0;let te=new zt(this,y,S);return this._chanMgr.update(S,te),O.channelOpenConfirm(y.sender,S,En,pn),te},this.emit("session",Q,re);return}break;case"direct-tcpip":if(kt(this,"tcpip")&&J()){Q=()=>{if(M)return;M=!0;let te={type:void 0,incoming:{id:S,window:En,packetSize:pn,state:"open"},outgoing:{id:y.sender,window:y.window,packetSize:y.packetSize,state:"open"}},ie=new tr(this,te,{server:!0});return this._chanMgr.update(S,ie),O.channelOpenConfirm(y.sender,S,En,pn),ie},this.emit("tcpip",Q,re,j);return}break;case"direct-streamlocal@openssh.com":if(kt(this,"openssh.streamlocal")&&J()){Q=()=>{if(M)return;M=!0;let te={type:void 0,incoming:{id:S,window:En,packetSize:pn,state:"open"},outgoing:{id:y.sender,window:y.window,packetSize:y.packetSize,state:"open"}},ie=new tr(this,te,{server:!0});return this._chanMgr.update(S,ie),O.channelOpenConfirm(y.sender,S,En,pn),ie},this.emit("openssh.streamlocal",Q,re,j);return}break;default:v=Zn.UNKNOWN_CHANNEL_TYPE,s&&s(`Automatic rejection of unsupported incoming channel open type: ${y.type}`)}v===void 0&&(v=Zn.ADMINISTRATIVELY_PROHIBITED,s&&s(`Automatic rejection of unexpected incoming channel open for: ${y.type}`)),re()},CHANNEL_OPEN_CONFIRMATION:(X,y)=>{let S=this._chanMgr.get(y.recipient);if(typeof S!="function")return;let v={type:S.type,incoming:{id:y.recipient,window:En,packetSize:pn,state:"open"},outgoing:{id:y.sender,window:y.window,packetSize:y.packetSize,state:"open"}},M=new tr(this,v,{server:!0});this._chanMgr.update(y.recipient,M),S(void 0,M)},CHANNEL_OPEN_FAILURE:(X,y,S,v)=>{let M=this._chanMgr.get(y);if(typeof M!="function")return;Dl(this,y,{reason:S,description:v},M)},CHANNEL_DATA:(X,y,S)=>{let v=this._chanMgr.get(y);if(!(typeof v!="object"||v===null)&&!(v.constructor===zt&&(v=v._channel,!v))&&v.incoming.window!==0){if(v.incoming.window-=S.length,v.push(S)===!1){v._waitChanDrain=!0;return}v.incoming.window<=Ol&&Ul(v)}},CHANNEL_EXTENDED_DATA:(X,y,S,v)=>{},CHANNEL_WINDOW_ADJUST:(X,y,S)=>{let v=this._chanMgr.get(y);typeof v!="object"||v===null||v.constructor===zt&&(v=v._channel,!v)||(v.outgoing.window+=S,v._waitWindow&&(v._waitWindow=!1,v._chunk?v._write(v._chunk,null,v._chunkcb):v._chunkcb?v._chunkcb():v._chunkErr?v.stderr._write(v._chunkErr,null,v._chunkcbErr):v._chunkcbErr&&v._chunkcbErr()))},CHANNEL_SUCCESS:(X,y)=>{let S=this._chanMgr.get(y);typeof S!="object"||S===null||S.constructor===zt&&(S=S._channel,!S)||S._callbacks.length&&S._callbacks.shift()(!1)},CHANNEL_FAILURE:(X,y)=>{let S=this._chanMgr.get(y);typeof S!="object"||S===null||S.constructor===zt&&(S=S._channel,!S)||S._callbacks.length&&S._callbacks.shift()(!0)},CHANNEL_REQUEST:(X,y,S,v,M)=>{let Q=this._chanMgr.get(y);if(typeof Q!="object"||Q===null)return;let re=!1,J,j;if(Q.constructor!==zt){v&&O.channelFailure(Q.outgoing.id);return}if(v&&(S!=="shell"&&S!=="exec"&&S!=="subsystem"&&(J=()=>{re||Q._ending||Q._channel||(re=!0,O.channelSuccess(Q._chanInfo.outgoing.id))}),j=()=>{re||Q._ending||Q._channel||(re=!0,O.channelFailure(Q._chanInfo.outgoing.id))}),Q._ending){j&&j();return}switch(S){case"env":if(kt(Q,"env")){Q.emit("env",J,j,{key:M.name,val:M.value});return}break;case"pty-req":if(kt(Q,"pty")){Q.emit("pty",J,j,M);return}break;case"window-change":kt(Q,"window-change")?Q.emit("window-change",J,j,M):j&&j();break;case"x11-req":if(kt(Q,"x11")){Q.emit("x11",J,j,M);return}break;case"signal":if(kt(Q,"signal")){Q.emit("signal",J,j,{name:M});return}break;case"auth-agent-req@openssh.com":if(kt(Q,"auth-agent")){Q.emit("auth-agent",J,j);return}break;case"shell":if(kt(Q,"shell")){J=()=>{if(re||Q._ending||Q._channel)return;re=!0,v&&O.channelSuccess(Q._chanInfo.outgoing.id);let te=new tr(this,Q._chanInfo,{server:!0});return te.subtype=Q.subtype=S,Q._channel=te,te},Q.emit("shell",J,j);return}break;case"exec":if(kt(Q,"exec")){J=()=>{if(re||Q._ending||Q._channel)return;re=!0,v&&O.channelSuccess(Q._chanInfo.outgoing.id);let te=new tr(this,Q._chanInfo,{server:!0});return te.subtype=Q.subtype=S,Q._channel=te,te},Q.emit("exec",J,j,{command:M});return}break;case"subsystem":{let te=M==="sftp";if(J=()=>{if(re||Q._ending||Q._channel)return;re=!0,v&&O.channelSuccess(Q._chanInfo.outgoing.id);let ie;return te?ie=new vl(this,Q._chanInfo,{server:!0,debug:s}):(ie=new tr(this,Q._chanInfo,{server:!0}),ie.subtype=Q.subtype=`${S}:${M}`),Q._channel=ie,ie},M==="sftp"){if(kt(Q,"sftp")){Q.emit("sftp",J,j);return}te=!1}if(kt(Q,"subsystem")){Q.emit("subsystem",J,j,{name:M});return}break}}s&&s(`Automatic rejection of incoming channel request: ${S}`),j&&j()},CHANNEL_EOF:(X,y)=>{let S=this._chanMgr.get(y);typeof S!="object"||S===null||S.constructor===zt&&(S._ending||(S._ending=!0,S.emit("eof"),S.emit("end")),S=S._channel,!S)||S.incoming.state==="open"&&(S.incoming.state="eof",S.readable&&S.push(null))},CHANNEL_CLOSE:(X,y)=>{let S=this._chanMgr.get(y);typeof S!="object"||S===null||S.constructor===zt&&(S._ending=!0,S.emit("close"),S=S._channel,!S)||Ql(this,y,S)},SERVICE_REQUEST:(X,y)=>{if(a===0||h||this.authenticated||y!=="ssh-userauth"){O.disconnect(er.SERVICE_NOT_AVAILABLE),t.end();return}h=!0,O.serviceAccept(y)},USERAUTH_REQUEST:(X,y,S,v,M)=>{if(a===0||this.authenticated||l&&(l.username!==y||l.service!==S)||v!=="password"&&v!=="publickey"&&v!=="hostbased"&&v!=="keyboard-interactive"&&v!=="none"||d.length===Hl){O.disconnect(er.PROTOCOL_ERROR),t.end();return}else if(S!=="ssh-connection"){O.disconnect(er.SERVICE_NOT_AVAILABLE),t.end();return}let Q;switch(v){case"keyboard-interactive":Q=new vi(O,y,S,v,M,V);break;case"publickey":Q=new mo(O,y,S,v,M,V);break;case"hostbased":Q=new Bo(O,y,S,v,M,V);break;case"password":if(l&&l instanceof Li&&l._changeCb){let re=l._changeCb;l._changeCb=void 0,re(M.newPassword);return}Q=new Li(O,y,S,v,M,V);break;case"none":Q=new bn(O,y,S,v,V);break}if(l)if(l._initialResponse)l._multistep&&!l._finalResponse&&(l._cleanup&&l._cleanup(),l.emit("abort"));else return d.push(Q);l=Q,kt(this,"authentication")?this.emit("authentication",l):l.reject()},USERAUTH_INFO_RESPONSE:(X,y)=>{l&&l instanceof vi&&l._onInfoResponse(y)},GLOBAL_REQUEST:(X,y,S,v)=>{let M={type:null,buf:null};function Q(re,J){M.type=re,M.buf=J,ee()}if(S&&x.push(M),(y==="tcpip-forward"||y==="cancel-tcpip-forward"||y==="no-more-sessions@openssh.com"||y==="streamlocal-forward@openssh.com"||y==="cancel-streamlocal-forward@openssh.com")&&kt(this,"request")&&this.authenticated){let re,J;if(S){let j=!1;re=te=>{if(j)return;j=!0;let ie;y==="tcpip-forward"&&v.bindPort===0&&typeof te=="number"&&(ie=Buffer.allocUnsafe(4),Ll(ie,te,0)),Q("SUCCESS",ie)},J=()=>{j||(j=!0,Q("FAILURE"))}}if(y==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,re&&re();return}this.emit("request",re,J,y,v)}else S&&Q("FAILURE")}}});t.pause(),Rl.then(()=>{O.start(),t.on("data",X=>{try{O.parse(X,0,X.length)}catch(y){this.emit("error",y);try{Ti(t)&&t.end()}catch{}}}),t.resume()}).catch(X=>{this.emit("error",X);try{Ti(t)&&t.end()}catch{}}),t.on("error",X=>{X.level="socket",this.emit("error",X)}).once("end",()=>{s&&s("Socket ended"),O.cleanup(),this.emit("end")}).once("close",()=>{s&&s("Socket closed"),O.cleanup(),this.emit("close");let X=new Error("No response from server");this._chanMgr.cleanup(X)});let V=(X,y,S,v)=>{l===X&&!this.authenticated&&(y?(l=void 0,this.authenticated=!0,O.authSuccess(),d=[],this.emit("ready")):(O.authFailure(S,v),d.length&&(l=d.pop(),kt(this,"authentication")?this.emit("authentication",l):l.reject())))};function ee(){for(;x.length>0&&x[0].type;){let X=x.shift();X.type==="SUCCESS"&&O.requestSuccess(X.buf),X.type==="FAILURE"&&O.requestFailure()}}}end(){return this._sock&&Ti(this._sock)&&(this._protocol.disconnect(er.BY_APPLICATION),this._sock.end()),this}x11(t,e,r){return wo(this,"x11",{originAddr:t,originPort:e},r),this}forwardOut(t,e,r,i,s){return wo(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:r,remotePort:i},s),this}openssh_forwardOutStreamLocal(t,e){return wo(this,"forwarded-streamlocal@openssh.com",{socketPath:t},e),this}rekey(t){let e;try{this._protocol.rekey()}catch(r){e=r}typeof t=="function"&&(e?process.nextTick(t,e):this.once("rekey",t))}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function wo(n,t,e,r){let i=En,s=pn;typeof e=="function"&&(r=e,e={});let o=(a,h)=>{r(a,h)};o.type=t;let f=n._chanMgr.add(o);if(f===-1){r(new Error("No free channels available"));return}switch(t){case"forwarded-tcpip":n._protocol.forwardedTcpip(f,i,s,e);break;case"x11":n._protocol.x11(f,i,s,e);break;case"forwarded-streamlocal@openssh.com":n._protocol.openssh_forwardedStreamLocal(f,i,s,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Fl(n,t){return n-t}Co.exports=Qt;Co.exports.IncomingClient=Ui});var sc=Ze((jd,ic)=>{"use strict";var{createCipheriv:Ml,generateKeyPair:ql,generateKeyPairSync:Kl,getCurves:Wl,randomBytes:tc}=require("crypto"),{Ber:ft}=cr(),Gl=Gi().pbkdf,{CIPHER_INFO:Yl}=un(),$l=16,Xl=16,jl=Wl(),Vl=new Map(Object.entries(Yl));function nc(n,t){if(typeof n!="string")throw new TypeError("Key type must be a string");let e={type:"spki",format:"der"},r={type:"pkcs8",format:"der"};switch(n.toLowerCase()){case"rsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for RSA key");let i=t.bits;if(!Number.isInteger(i))throw new TypeError("RSA bits must be an integer");if(i<=0||i>16384)throw new RangeError("RSA bits must be non-zero and <= 16384");return["rsa",{modulusLength:i,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ecdsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for ECDSA key");if(!Number.isInteger(t.bits))throw new TypeError("ECDSA bits must be an integer");let i;switch(t.bits){case 256:i="prime256v1";break;case 384:i="secp384r1";break;case 521:i="secp521r1";break;default:throw new Error("ECDSA bits must be 256, 384, or 521")}if(!jl.includes(i))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:i,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:r}];default:throw new Error(`Unsupported key type: ${n}`)}}function zl(n,t,e){switch(n){case"rsa":{let r=new ft.Reader(e);if(r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.113549.1.1.1")throw new Error("Bad RSA private OID");if(r.readByte()!==ft.Null)throw new Error("Malformed RSA private key (expected null)");if(r.readByte()!==0)throw new Error("Malformed RSA private key (expected zero-length null)");if(r=new ft.Reader(r.readString(ft.OctetString,!0)),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");let i=r.readString(ft.Integer,!0),s=r.readString(ft.Integer,!0),o=r.readString(ft.Integer,!0),f=r.readString(ft.Integer,!0),a=r.readString(ft.Integer,!0);r.readString(ft.Integer,!0),r.readString(ft.Integer,!0);let h=r.readString(ft.Integer,!0),d=Buffer.from("ssh-rsa"),l=Buffer.allocUnsafe(4+d.length+4+i.length+4+s.length+4+o.length+4+h.length+4+f.length+4+a.length),_=0;l.writeUInt32BE(d.length,_+=0),l.set(d,_+=4),l.writeUInt32BE(i.length,_+=d.length),l.set(i,_+=4),l.writeUInt32BE(s.length,_+=i.length),l.set(s,_+=4),l.writeUInt32BE(o.length,_+=s.length),l.set(o,_+=4),l.writeUInt32BE(h.length,_+=o.length),l.set(h,_+=4),l.writeUInt32BE(f.length,_+=h.length),l.set(f,_+=4),l.writeUInt32BE(a.length,_+=f.length),l.set(a,_+=4);let p=Buffer.allocUnsafe(4+d.length+4+s.length+4+i.length);return _=0,p.writeUInt32BE(d.length,_+=0),p.set(d,_+=4),p.writeUInt32BE(s.length,_+=d.length),p.set(s,_+=4),p.writeUInt32BE(i.length,_+=s.length),p.set(i,_+=4),{sshName:d.toString(),priv:l,pub:p}}case"ec":{let r=new ft.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");r.readOID();let i=r.readString(ft.BitString,!0);{let _=0;for(;_<i.length&&i[_]===0;++_);_>0&&(i=i.slice(_))}if(r=new ft.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let s=r.readOID(),o;switch(s){case"1.2.840.10045.3.1.7":o="nistp256";break;case"1.3.132.0.34":o="nistp384";break;case"1.3.132.0.35":o="nistp521";break;default:throw new Error("Unsupported curve in ECDSA private key")}if(r=new ft.Reader(r.readString(ft.OctetString,!0)),r.readSequence(),r.readInt()!==1)throw new Error("Unsupported version in ECDSA private key");let f=Buffer.concat([Buffer.from([0]),r.readString(ft.OctetString,!0)]),a=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);let h=Buffer.allocUnsafe(4+a.length+4+o.length+4+i.length+4+f.length),d=0;h.writeUInt32BE(a.length,d+=0),h.set(a,d+=4),h.writeUInt32BE(o.length,d+=a.length),h.set(o,d+=4),h.writeUInt32BE(i.length,d+=o.length),h.set(i,d+=4),h.writeUInt32BE(f.length,d+=i.length),h.set(f,d+=4);let l=Buffer.allocUnsafe(4+a.length+4+o.length+4+i.length);return d=0,l.writeUInt32BE(a.length,d+=0),l.set(a,d+=4),l.writeUInt32BE(o.length,d+=a.length),l.set(o,d+=4),l.writeUInt32BE(i.length,d+=o.length),l.set(i,d+=4),{sshName:a.toString(),priv:h,pub:l}}case"ed25519":{let r=new ft.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let i=r.readString(ft.BitString,!0);{let d=0;for(;d<i.length&&i[d]===0;++d);d>0&&(i=i.slice(d))}if(r=new ft.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ED25519 private key");if(r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 private OID");r=new ft.Reader(r.readString(ft.OctetString,!0));let s=r.readString(ft.OctetString,!0),o=Buffer.from("ssh-ed25519"),f=Buffer.allocUnsafe(4+o.length+4+i.length+4+(s.length+i.length)),a=0;f.writeUInt32BE(o.length,a+=0),f.set(o,a+=4),f.writeUInt32BE(i.length,a+=o.length),f.set(i,a+=4),f.writeUInt32BE(s.length+i.length,a+=i.length),f.set(s,a+=4),f.set(i,a+=s.length);let h=Buffer.allocUnsafe(4+o.length+4+i.length);return a=0,h.writeUInt32BE(o.length,a+=0),h.set(o,a+=4),h.writeUInt32BE(i.length,a+=o.length),h.set(i,a+=4),{sshName:o.toString(),priv:f,pub:h}}}}function rc(n,t,e,r){let i="new",s,o="";if(typeof r=="object"&&r!==null&&(typeof r.comment=="string"&&r.comment&&(o=r.comment),typeof r.format=="string"&&r.format&&(i=r.format),r.passphrase)){let f;if(typeof r.passphrase=="string")f=Buffer.from(r.passphrase);else if(Buffer.isBuffer(r.passphrase))f=r.passphrase;else throw new Error("Invalid passphrase");if(r.cipher===void 0)throw new Error("Missing cipher name");let a=Vl.get(r.cipher);if(a===void 0)throw new Error("Invalid cipher name");if(i==="new"){let h=Xl;if(r.rounds!==void 0){if(!Number.isInteger(r.rounds))throw new TypeError("rounds must be an integer");r.rounds>0&&(h=r.rounds)}let d=Buffer.allocUnsafe(a.keyLen+a.ivLen),l=tc($l);if(Gl(f,f.length,l,l.length,d,d.length,h)!==0)return new Error("Failed to generate information to encrypt key");let p=Buffer.allocUnsafe(4+l.length+4);{let x=0;p.writeUInt32BE(l.length,x+=0),p.set(l,x+=4),p.writeUInt32BE(h,x+=l.length)}s={cipher:a,cipherName:r.cipher,kdfName:"bcrypt",kdfOptions:p,key:d.slice(0,a.keyLen),iv:d.slice(a.keyLen)}}}switch(i){case"new":{let f=`-----BEGIN OPENSSH PRIVATE KEY-----
22
+ `,a,h=Buffer.from(s?s.cipherName:"none"),d=Buffer.from(s?s.kdfName:"none"),l=s?s.kdfOptions:Buffer.alloc(0),_=s?s.cipher.blockLen:8,p=zl(n,t,e),x=tc(4),I=Buffer.from(o),k=8+p.priv.length+4+I.length,N=[];for(let ee=1;(k+N.length)%_;++ee)N.push(ee&255);N=Buffer.from(N);let D=Buffer.allocUnsafe(k+N.length),Z;{let ee=0;D.set(x,ee+=0),D.set(x,ee+=4),D.set(p.priv,ee+=4),D.writeUInt32BE(I.length,ee+=p.priv.length),D.set(I,ee+=4),D.set(N,ee+=I.length)}if(s){let ee={authTagLength:s.cipher.authLen},X=Ml(s.cipher.sslName,s.key,s.iv,ee);X.setAutoPadding(!1),D=Buffer.concat([X.update(D),X.final()]),s.cipher.authLen>0?Z=X.getAuthTag():Z=Buffer.alloc(0),s.key.fill(0),s.iv.fill(0)}else Z=Buffer.alloc(0);let O=Buffer.from("openssh-key-v1\0"),V=Buffer.allocUnsafe(O.length+4+h.length+4+d.length+4+l.length+4+4+p.pub.length+4+D.length+Z.length);{let ee=0;V.set(O,ee+=0),V.writeUInt32BE(h.length,ee+=O.length),V.set(h,ee+=4),V.writeUInt32BE(d.length,ee+=h.length),V.set(d,ee+=4),V.writeUInt32BE(l.length,ee+=d.length),V.set(l,ee+=4),V.writeUInt32BE(1,ee+=l.length),V.writeUInt32BE(p.pub.length,ee+=4),V.set(p.pub,ee+=4),V.writeUInt32BE(D.length,ee+=p.pub.length),V.set(D,ee+=4),V.set(Z,ee+=D.length)}{let ee=V.base64Slice(0,V.length),X=ee.replace(/.{64}/g,`$&
23
+ `);ee.length&63&&(X+=`
24
+ `),f+=X}{let ee=p.pub.base64Slice(0,p.pub.length);a=`${p.sshName} ${ee}${o?` ${o}`:""}`}return f+=`-----END OPENSSH PRIVATE KEY-----
25
+ `,{private:f,public:a}}default:throw new Error("Invalid output key format")}}function Jl(){}ic.exports={generateKeyPair:(n,t,e)=>{typeof t=="function"&&(e=t,t=void 0),typeof e!="function"&&(e=Jl);let r=nc(n,t);ql(...r,(i,s,o)=>{if(i)return e(i);let f;try{f=rc(r[0],s,o,t)}catch(a){return e(a)}e(null,f)})},generateKeyPairSync:(n,t)=>{let e=nc(n,t),{publicKey:r,privateKey:i}=Kl(...e);return rc(e[0],r,i,t)}}});var fc=Ze((Vd,oc)=>{"use strict";var{AgentProtocol:Zl,BaseAgent:ed,createAgent:td,CygwinAgent:nd,OpenSSHAgent:rd,PageantAgent:id}=Ls(),{SSHTTPAgent:sd,SSHTTPSAgent:od}=Ja(),{parseKey:fd}=An(),{flagsToString:ad,OPEN_MODE:cd,STATUS_CODE:hd,stringToFlags:ud}=kr();oc.exports={AgentProtocol:Zl,BaseAgent:ed,createAgent:td,Client:xo(),CygwinAgent:nd,HTTPAgent:sd,HTTPSAgent:od,OpenSSHAgent:rd,PageantAgent:id,Server:ec(),utils:{parseKey:fd,...sc(),sftp:{flagsToString:ad,OPEN_MODE:cd,STATUS_CODE:hd,stringToFlags:ud}}}});var _d={};_c(_d,{Client:()=>ld,Server:()=>Ad,default:()=>gd,utils:()=>dd});module.exports=pc(_d);var Dr=Ec(fc(),1),ld=Dr.default.Client,dd=Dr.default.utils,Ad=Dr.default.Server,gd=Dr.default;0&&(module.exports={Client,Server,utils});