@activepieces/piece-sftp 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +13 -13
package/src/index.js CHANGED
@@ -1,26 +1,26 @@
1
- "use strict";var LA=Object.create;var Ao=Object.defineProperty;var zA=Object.getOwnPropertyDescriptor;var MA=Object.getOwnPropertyNames;var FA=Object.getPrototypeOf,HA=Object.prototype.hasOwnProperty;var c=(t,e)=>Ao(t,"name",{value:e,configurable:!0});var le=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},ld=(t,e)=>{for(var r in e)Ao(t,r,{get:e[r],enumerable:!0})},fd=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of MA(e))!HA.call(t,i)&&i!==r&&Ao(t,i,{get:()=>e[i],enumerable:!(n=zA(e,i))||n.enumerable});return t};var Ar=(t,e,r)=>(r=t!=null?LA(FA(t)):{},fd(e||!t||!t.__esModule?Ao(r,"default",{value:t,enumerable:!0}):r,t)),jA=t=>fd(Ao({},"__esModule",{value:!0}),t);var $p=le((Op,ra)=>{(function(t){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",s="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${s})|(?:::)(?:${s})?)${e}\\.${e}\\.${e}\\.${e}(${o})?$`,"i")};function u(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let E=0,b=-1,I=(h.match(a.zoneIndex)||[])[0],w,H;for(I&&(I=I.substring(1),h=h.replace(/%.+$/,""));(b=h.indexOf(":",b+1))>=0;)E++;if(h.substr(0,2)==="::"&&E--,h.substr(-2,2)==="::"&&E--,E>_)return null;for(H=_-E,w=":";H--;)w+="0:";return h=h.replace("::",w),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=(function(){let $=h.split(":"),X=[];for(let Z=0;Z<$.length;Z++)X.push(parseInt($[Z],16));return X})(),{parts:_,zoneId:I}}c(u,"expandIPv6");function l(h,_,E,b){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let I=0,w;for(;b>0;){if(w=E-b,w<0&&(w=0),h[I]>>w!==_[I]>>w)return!1;b-=E,I+=1}return!0}c(l,"matchCIDR");function d(h){if(i.test(h))return parseInt(h,16);if(h[0]==="0"&&!isNaN(parseInt(h[1],10))){if(n.test(h))return parseInt(h,8);throw new Error(`ipaddr: cannot parse ${h} as octal`)}return parseInt(h,10)}c(d,"parseIntAuto");function p(h,_){for(;h.length<_;)h=`0${h}`;return h}c(p,"padPart");let g={};g.IPv4=(function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let E,b;for(E=0;E<_.length;E++)if(b=_[E],!(0<=b&&b<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return c(h,"IPv4"),h.prototype.SpecialRanges={unspecified:[[new h([0,0,0,0]),8]],broadcast:[[new h([255,255,255,255]),32]],multicast:[[new h([224,0,0,0]),4]],linkLocal:[[new h([169,254,0,0]),16]],loopback:[[new h([127,0,0,0]),8]],carrierGradeNat:[[new h([100,64,0,0]),10]],private:[[new h([10,0,0,0]),8],[new h([172,16,0,0]),12],[new h([192,168,0,0]),16]],reserved:[[new h([192,0,0,0]),24],[new h([192,0,2,0]),24],[new h([192,88,99,0]),24],[new h([198,18,0,0]),15],[new h([198,51,100,0]),24],[new h([203,0,113,0]),24],[new h([240,0,0,0]),4]],as112:[[new h([192,175,48,0]),24],[new h([192,31,196,0]),24]],amt:[[new h([192,52,193,0]),24]]},h.prototype.kind=function(){return"ipv4"},h.prototype.match=function(_,E){let b;if(E===void 0&&(b=_,_=b[0],E=b[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return l(this.octets,_.octets,8,E)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,E=!1,b={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},I,w,H;for(I=3;I>=0;I-=1)if(w=this.octets[I],w in b){if(H=b[w],E&&H!==0)return null;H!==8&&(E=!0),_+=H}else return null;return 32-_},h.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return g.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h})(),g.IPv4.broadcastAddressFromCIDR=function(h){try{let _=this.parseCIDR(h),E=_[0].toByteArray(),b=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],w=0;for(;w<4;)I.push(parseInt(E[w],10)|parseInt(b[w],10)^255),w++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},g.IPv4.isIPv4=function(h){return this.parser(h)!==null},g.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},g.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},g.IPv4.isValidFourPartDecimal=function(h){return!!(g.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},g.IPv4.isValidCIDRFourPartDecimal=function(h){let _=h.match(/^(.+)\/(\d+)$/);return!g.IPv4.isValidCIDR(h)||!_?!1:g.IPv4.isValidFourPartDecimal(_[1])},g.IPv4.networkAddressFromCIDR=function(h){let _,E,b,I,w;try{for(_=this.parseCIDR(h),b=_[0].toByteArray(),w=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],E=0;E<4;)I.push(parseInt(b[E],10)&parseInt(w[E],10)),E++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},g.IPv4.parse=function(h){let _=this.parser(h);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},g.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){let E=parseInt(_[2]);if(E>=0&&E<=32){let b=[this.parse(_[1]),E];return Object.defineProperty(b,"toString",{value:c(function(){return this.join("/")},"value")}),b}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},g.IPv4.parser=function(h){let _,E,b;if(_=h.match(r.fourOctet))return(function(){let I=_.slice(1,6),w=[];for(let H=0;H<I.length;H++)E=I[H],w.push(d(E));return w})();if(_=h.match(r.longValue)){if(b=d(_[1]),b>4294967295||b<0)throw new Error("ipaddr: address outside defined range");return(function(){let I=[],w;for(w=0;w<=24;w+=8)I.push(b>>w&255);return I})().reverse()}else return(_=h.match(r.twoOctet))?(function(){let I=_.slice(1,4),w=[];if(b=d(I[1]),b>16777215||b<0)throw new Error("ipaddr: address outside defined range");return w.push(d(I[0])),w.push(b>>16&255),w.push(b>>8&255),w.push(b&255),w})():(_=h.match(r.threeOctet))?(function(){let I=_.slice(1,5),w=[];if(b=d(I[2]),b>65535||b<0)throw new Error("ipaddr: address outside defined range");return w.push(d(I[0])),w.push(d(I[1])),w.push(b>>8&255),w.push(b&255),w})():null},g.IPv4.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>32)throw new Error("ipaddr: invalid IPv4 prefix length");let _=[0,0,0,0],E=0,b=Math.floor(h/8);for(;E<b;)_[E]=255,E++;return b<4&&(_[b]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},g.IPv6=(function(){function h(_,E){let b,I;if(_.length===16)for(this.parts=[],b=0;b<=14;b+=2)this.parts.push(_[b]<<8|_[b+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(b=0;b<this.parts.length;b++)if(I=this.parts[b],!(0<=I&&I<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");E&&(this.zoneId=E)}return c(h,"IPv6"),h.prototype.SpecialRanges={unspecified:[new h([0,0,0,0,0,0,0,0]),128],linkLocal:[new h([65152,0,0,0,0,0,0,0]),10],multicast:[new h([65280,0,0,0,0,0,0,0]),8],loopback:[new h([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new h([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new h([0,0,0,0,0,65535,0,0]),96],discard:[new h([256,0,0,0,0,0,0,0]),64],rfc6145:[new h([0,0,0,0,65535,0,0,0]),96],rfc6052:[new h([100,65435,0,0,0,0,0,0]),96],"6to4":[new h([8194,0,0,0,0,0,0,0]),16],teredo:[new h([8193,0,0,0,0,0,0,0]),32],benchmarking:[new h([8193,2,0,0,0,0,0,0]),48],amt:[new h([8193,3,0,0,0,0,0,0]),32],as112v6:[[new h([8193,4,274,0,0,0,0,0]),48],[new h([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new h([8193,16,0,0,0,0,0,0]),28],orchid2:[new h([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new h([8193,48,0,0,0,0,0,0]),28],reserved:[[new h([8193,0,0,0,0,0,0,0]),23],[new h([8193,3512,0,0,0,0,0,0]),32]]},h.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},h.prototype.kind=function(){return"ipv6"},h.prototype.match=function(_,E){let b;if(E===void 0&&(b=_,_=b[0],E=b[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return l(this.parts,_.parts,16,E)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,E=!1,b={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},I,w;for(let H=7;H>=0;H-=1)if(I=this.parts[H],I in b){if(w=b[I],E&&w!==0)return null;w!==16&&(E=!0),_+=w}else return null;return 128-_},h.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _,E=[],b=this.parts;for(let I=0;I<b.length;I++)_=b[I],E.push(_>>8),E.push(_&255);return E},h.prototype.toFixedLengthString=function(){let _=(function(){let b=[];for(let I=0;I<this.parts.length;I++)b.push(p(this.parts[I].toString(16),4));return b}).call(this).join(":"),E="";return this.zoneId&&(E=`%${this.zoneId}`),_+E},h.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let _=this.parts.slice(-2),E=_[0],b=_[1];return new g.IPv4([E>>8,E&255,b>>8,b&255])},h.prototype.toNormalizedString=function(){let _=(function(){let b=[];for(let I=0;I<this.parts.length;I++)b.push(this.parts[I].toString(16));return b}).call(this).join(":"),E="";return this.zoneId&&(E=`%${this.zoneId}`),_+E},h.prototype.toRFC5952String=function(){let _=/((^|:)(0(:|$)){2,})/g,E=this.toNormalizedString(),b=0,I=-1,w;for(;w=_.exec(E);)w[0].length>I&&(b=w.index,I=w[0].length);return I<0?E:`${E.substring(0,b)}::${E.substring(b+I)}`},h.prototype.toString=function(){return this.toRFC5952String()},h})(),g.IPv6.broadcastAddressFromCIDR=function(h){try{let _=this.parseCIDR(h),E=_[0].toByteArray(),b=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],w=0;for(;w<16;)I.push(parseInt(E[w],10)|parseInt(b[w],10)^255),w++;return new this(I)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},g.IPv6.isIPv6=function(h){return this.parser(h)!==null},g.IPv6.isValid=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{let _=this.parser(h);return new this(_.parts,_.zoneId),!0}catch{return!1}},g.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},g.IPv6.networkAddressFromCIDR=function(h){let _,E,b,I,w;try{for(_=this.parseCIDR(h),b=_[0].toByteArray(),w=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],E=0;E<16;)I.push(parseInt(b[E],10)&parseInt(w[E],10)),E++;return new this(I)}catch(H){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${H})`)}},g.IPv6.parse=function(h){let _=this.parser(h);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},g.IPv6.parseCIDR=function(h){let _,E,b;if((E=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(E[2]),_>=0&&_<=128))return b=[this.parse(E[1]),_],Object.defineProperty(b,"toString",{value:c(function(){return this.join("/")},"value")}),b;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},g.IPv6.parser=function(h){let _,E,b,I,w,H;if(b=h.match(a.deprecatedTransitional))return this.parser(`::ffff:${b[1]}`);if(a.native.test(h))return u(h,8);if((b=h.match(a.transitional))&&(H=b[6]||"",_=b[1],b[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+H,6),_.parts)){for(w=[parseInt(b[2]),parseInt(b[3]),parseInt(b[4]),parseInt(b[5])],E=0;E<w.length;E++)if(I=w[E],!(0<=I&&I<=255))return null;return _.parts.push(w[0]<<8|w[1]),_.parts.push(w[2]<<8|w[3]),{parts:_.parts,zoneId:_.zoneId}}return null},g.IPv6.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>128)throw new Error("ipaddr: invalid IPv6 prefix length");let _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],E=0,b=Math.floor(h/8);for(;E<b;)_[E]=255,E++;return b<16&&(_[b]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},g.fromByteArray=function(h){let _=h.length;if(_===4)return new g.IPv4(h);if(_===16)return new g.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},g.isValid=function(h){return g.IPv6.isValid(h)||g.IPv4.isValid(h)},g.isValidCIDR=function(h){return g.IPv6.isValidCIDR(h)||g.IPv4.isValidCIDR(h)},g.parse=function(h){if(g.IPv6.isValid(h))return g.IPv6.parse(h);if(g.IPv4.isValid(h))return g.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},g.parseCIDR=function(h){try{return g.IPv6.parseCIDR(h)}catch{try{return g.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},g.process=function(h){let _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},g.subnetMatch=function(h,_,E){let b,I,w,H;E==null&&(E="unicast");for(I in _)if(Object.prototype.hasOwnProperty.call(_,I)){for(w=_[I],w[0]&&!(w[0]instanceof Array)&&(w=[w]),b=0;b<w.length;b++)if(H=w[b],h.kind()===H[0].kind()&&h.match.apply(h,H))return I}return E},typeof ra<"u"&&ra.exports?ra.exports=g:t.ipaddr=g})(Op)});var ia=le(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.parseControlResponse=lb;ni.isSingleLine=Sh;ni.isMultiline=wh;ni.positiveCompletion=fb;ni.positiveIntermediate=db;var hu=`
2
- `;function lb(t){let e=t.split(/\r?\n/).filter(pb),r=[],n=0,i;for(let s=0;s<e.length;s++){let a=e[s];if(i)i.test(a)&&(i=void 0,r.push(e.slice(n,s+1).join(hu)));else if(wh(a)){let u=a.substr(0,3);i=new RegExp(`^${u}(?:$| )`),n=s}else Sh(a)&&r.push(a)}let o=i?e.slice(n).join(hu)+hu:"";return{messages:r,rest:o}}c(lb,"parseControlResponse");function Sh(t){return/^\d\d\d(?:$| )/.test(t)}c(Sh,"isSingleLine");function wh(t){return/^\d\d\d-/.test(t)}c(wh,"isMultiline");function fb(t){return t>=200&&t<300}c(fb,"positiveCompletion");function db(t){return t>=300&&t<400}c(db,"positiveIntermediate");function pb(t){return t.trim()!==""}c(pb,"isNotBlank")});var mu=le(Oi=>{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});Oi.FTPContext=Oi.FTPError=void 0;var hb=require("net"),gb=ia(),oa=class extends Error{static{c(this,"FTPError")}constructor(e){super(e.message),this.name=this.constructor.name,this.code=e.code}};Oi.FTPError=oa;function Ph(){}c(Ph,"doNothing");var mb=2**16,gu=class{static{c(this,"FTPContext")}constructor(e=0,r="utf8"){this.timeout=e,this.verbose=!1,this.ipFamily=void 0,this.tlsOptions={},this._partialResponse="",this._encoding=r,this._socket=this.socket=this._newSocket(),this._dataSocket=void 0}close(){let e=this._task?"User closed client during task":"User closed client",r=new Error(e);this.closeWithError(r)}closeWithError(e){this._closingError||(this._closingError=e,this._closeControlSocket(),this._closeSocket(this._dataSocket),this._passToHandler(e),this._stopTrackingTask())}get closed(){return this.socket.remoteAddress===void 0||this._closingError!==void 0}reset(){this.socket=this._newSocket()}get socket(){return this._socket}set socket(e){this.dataSocket=void 0,this.tlsOptions={},this._partialResponse="",this._socket&&(e.localPort===this._socket.localPort?this._removeSocketListeners(this.socket):this._closeControlSocket()),e&&(this._closingError=void 0,e.setTimeout(0),e.setEncoding(this._encoding),e.setKeepAlive(!0),e.on("data",r=>this._onControlSocketData(r)),e.on("end",()=>this.closeWithError(new Error("Server sent FIN packet unexpectedly, closing connection."))),e.on("close",r=>{r||this.closeWithError(new Error("Server closed connection unexpectedly."))}),this._setupDefaultErrorHandlers(e,"control socket")),this._socket=e}get dataSocket(){return this._dataSocket}set dataSocket(e){this._closeSocket(this._dataSocket),e&&(e.setTimeout(0),this._setupDefaultErrorHandlers(e,"data socket")),this._dataSocket=e}get encoding(){return this._encoding}set encoding(e){this._encoding=e,this.socket&&this.socket.setEncoding(e)}send(e){if(/[\r\n\0]/.test(e))throw new Error(`Invalid command: Contains control characters. (${e})`);let n=e.startsWith("PASS")?"> PASS ###":`> ${e}`;this.log(n),this._socket.write(e+`\r
1
+ "use strict";var jE=Object.create;var Ao=Object.defineProperty;var WE=Object.getOwnPropertyDescriptor;var qE=Object.getOwnPropertyNames;var QE=Object.getPrototypeOf,VE=Object.prototype.hasOwnProperty;var c=(t,e)=>Ao(t,"name",{value:e,configurable:!0});var le=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},fd=(t,e)=>{for(var r in e)Ao(t,r,{get:e[r],enumerable:!0})},dd=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qE(e))!VE.call(t,i)&&i!==r&&Ao(t,i,{get:()=>e[i],enumerable:!(n=WE(e,i))||n.enumerable});return t};var Er=(t,e,r)=>(r=t!=null?jE(QE(t)):{},dd(e||!t||!t.__esModule?Ao(r,"default",{value:t,enumerable:!0}):r,t)),KE=t=>dd(Ao({},"__esModule",{value:!0}),t);var Dp=le(($p,na)=>{(function(t){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",s="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${s})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${s})|(?:::)(?:${s})?)${e}\\.${e}\\.${e}\\.${e}(${o})?$`,"i")};function u(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let A=0,b=-1,I=(h.match(a.zoneIndex)||[])[0],w,H;for(I&&(I=I.substring(1),h=h.replace(/%.+$/,""));(b=h.indexOf(":",b+1))>=0;)A++;if(h.substr(0,2)==="::"&&A--,h.substr(-2,2)==="::"&&A--,A>_)return null;for(H=_-A,w=":";H--;)w+="0:";return h=h.replace("::",w),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=(function(){let $=h.split(":"),X=[];for(let Z=0;Z<$.length;Z++)X.push(parseInt($[Z],16));return X})(),{parts:_,zoneId:I}}c(u,"expandIPv6");function l(h,_,A,b){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let I=0,w;for(;b>0;){if(w=A-b,w<0&&(w=0),h[I]>>w!==_[I]>>w)return!1;b-=A,I+=1}return!0}c(l,"matchCIDR");function d(h){if(i.test(h))return parseInt(h,16);if(h[0]==="0"&&!isNaN(parseInt(h[1],10))){if(n.test(h))return parseInt(h,8);throw new Error(`ipaddr: cannot parse ${h} as octal`)}return parseInt(h,10)}c(d,"parseIntAuto");function p(h,_){for(;h.length<_;)h=`0${h}`;return h}c(p,"padPart");let g={};g.IPv4=(function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let A,b;for(A=0;A<_.length;A++)if(b=_[A],!(0<=b&&b<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return c(h,"IPv4"),h.prototype.SpecialRanges={unspecified:[[new h([0,0,0,0]),8]],broadcast:[[new h([255,255,255,255]),32]],multicast:[[new h([224,0,0,0]),4]],linkLocal:[[new h([169,254,0,0]),16]],loopback:[[new h([127,0,0,0]),8]],carrierGradeNat:[[new h([100,64,0,0]),10]],private:[[new h([10,0,0,0]),8],[new h([172,16,0,0]),12],[new h([192,168,0,0]),16]],reserved:[[new h([192,0,0,0]),24],[new h([192,0,2,0]),24],[new h([192,88,99,0]),24],[new h([198,18,0,0]),15],[new h([198,51,100,0]),24],[new h([203,0,113,0]),24],[new h([240,0,0,0]),4]],as112:[[new h([192,175,48,0]),24],[new h([192,31,196,0]),24]],amt:[[new h([192,52,193,0]),24]]},h.prototype.kind=function(){return"ipv4"},h.prototype.match=function(_,A){let b;if(A===void 0&&(b=_,_=b[0],A=b[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return l(this.octets,_.octets,8,A)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,A=!1,b={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},I,w,H;for(I=3;I>=0;I-=1)if(w=this.octets[I],w in b){if(H=b[w],A&&H!==0)return null;H!==8&&(A=!0),_+=H}else return null;return 32-_},h.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return g.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h})(),g.IPv4.broadcastAddressFromCIDR=function(h){try{let _=this.parseCIDR(h),A=_[0].toByteArray(),b=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],w=0;for(;w<4;)I.push(parseInt(A[w],10)|parseInt(b[w],10)^255),w++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},g.IPv4.isIPv4=function(h){return this.parser(h)!==null},g.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},g.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},g.IPv4.isValidFourPartDecimal=function(h){return!!(g.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},g.IPv4.isValidCIDRFourPartDecimal=function(h){let _=h.match(/^(.+)\/(\d+)$/);return!g.IPv4.isValidCIDR(h)||!_?!1:g.IPv4.isValidFourPartDecimal(_[1])},g.IPv4.networkAddressFromCIDR=function(h){let _,A,b,I,w;try{for(_=this.parseCIDR(h),b=_[0].toByteArray(),w=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],A=0;A<4;)I.push(parseInt(b[A],10)&parseInt(w[A],10)),A++;return new this(I)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},g.IPv4.parse=function(h){let _=this.parser(h);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},g.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){let A=parseInt(_[2]);if(A>=0&&A<=32){let b=[this.parse(_[1]),A];return Object.defineProperty(b,"toString",{value:c(function(){return this.join("/")},"value")}),b}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},g.IPv4.parser=function(h){let _,A,b;if(_=h.match(r.fourOctet))return(function(){let I=_.slice(1,6),w=[];for(let H=0;H<I.length;H++)A=I[H],w.push(d(A));return w})();if(_=h.match(r.longValue)){if(b=d(_[1]),b>4294967295||b<0)throw new Error("ipaddr: address outside defined range");return(function(){let I=[],w;for(w=0;w<=24;w+=8)I.push(b>>w&255);return I})().reverse()}else return(_=h.match(r.twoOctet))?(function(){let I=_.slice(1,4),w=[];if(b=d(I[1]),b>16777215||b<0)throw new Error("ipaddr: address outside defined range");return w.push(d(I[0])),w.push(b>>16&255),w.push(b>>8&255),w.push(b&255),w})():(_=h.match(r.threeOctet))?(function(){let I=_.slice(1,5),w=[];if(b=d(I[2]),b>65535||b<0)throw new Error("ipaddr: address outside defined range");return w.push(d(I[0])),w.push(d(I[1])),w.push(b>>8&255),w.push(b&255),w})():null},g.IPv4.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>32)throw new Error("ipaddr: invalid IPv4 prefix length");let _=[0,0,0,0],A=0,b=Math.floor(h/8);for(;A<b;)_[A]=255,A++;return b<4&&(_[b]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},g.IPv6=(function(){function h(_,A){let b,I;if(_.length===16)for(this.parts=[],b=0;b<=14;b+=2)this.parts.push(_[b]<<8|_[b+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(b=0;b<this.parts.length;b++)if(I=this.parts[b],!(0<=I&&I<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");A&&(this.zoneId=A)}return c(h,"IPv6"),h.prototype.SpecialRanges={unspecified:[new h([0,0,0,0,0,0,0,0]),128],linkLocal:[new h([65152,0,0,0,0,0,0,0]),10],multicast:[new h([65280,0,0,0,0,0,0,0]),8],loopback:[new h([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new h([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new h([0,0,0,0,0,65535,0,0]),96],discard:[new h([256,0,0,0,0,0,0,0]),64],rfc6145:[new h([0,0,0,0,65535,0,0,0]),96],rfc6052:[new h([100,65435,0,0,0,0,0,0]),96],"6to4":[new h([8194,0,0,0,0,0,0,0]),16],teredo:[new h([8193,0,0,0,0,0,0,0]),32],benchmarking:[new h([8193,2,0,0,0,0,0,0]),48],amt:[new h([8193,3,0,0,0,0,0,0]),32],as112v6:[[new h([8193,4,274,0,0,0,0,0]),48],[new h([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new h([8193,16,0,0,0,0,0,0]),28],orchid2:[new h([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new h([8193,48,0,0,0,0,0,0]),28],reserved:[[new h([8193,0,0,0,0,0,0,0]),23],[new h([8193,3512,0,0,0,0,0,0]),32]]},h.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},h.prototype.kind=function(){return"ipv6"},h.prototype.match=function(_,A){let b;if(A===void 0&&(b=_,_=b[0],A=b[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return l(this.parts,_.parts,16,A)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,A=!1,b={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},I,w;for(let H=7;H>=0;H-=1)if(I=this.parts[H],I in b){if(w=b[I],A&&w!==0)return null;w!==16&&(A=!0),_+=w}else return null;return 128-_},h.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _,A=[],b=this.parts;for(let I=0;I<b.length;I++)_=b[I],A.push(_>>8),A.push(_&255);return A},h.prototype.toFixedLengthString=function(){let _=(function(){let b=[];for(let I=0;I<this.parts.length;I++)b.push(p(this.parts[I].toString(16),4));return b}).call(this).join(":"),A="";return this.zoneId&&(A=`%${this.zoneId}`),_+A},h.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let _=this.parts.slice(-2),A=_[0],b=_[1];return new g.IPv4([A>>8,A&255,b>>8,b&255])},h.prototype.toNormalizedString=function(){let _=(function(){let b=[];for(let I=0;I<this.parts.length;I++)b.push(this.parts[I].toString(16));return b}).call(this).join(":"),A="";return this.zoneId&&(A=`%${this.zoneId}`),_+A},h.prototype.toRFC5952String=function(){let _=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString(),b=0,I=-1,w;for(;w=_.exec(A);)w[0].length>I&&(b=w.index,I=w[0].length);return I<0?A:`${A.substring(0,b)}::${A.substring(b+I)}`},h.prototype.toString=function(){return this.toRFC5952String()},h})(),g.IPv6.broadcastAddressFromCIDR=function(h){try{let _=this.parseCIDR(h),A=_[0].toByteArray(),b=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],w=0;for(;w<16;)I.push(parseInt(A[w],10)|parseInt(b[w],10)^255),w++;return new this(I)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},g.IPv6.isIPv6=function(h){return this.parser(h)!==null},g.IPv6.isValid=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{let _=this.parser(h);return new this(_.parts,_.zoneId),!0}catch{return!1}},g.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},g.IPv6.networkAddressFromCIDR=function(h){let _,A,b,I,w;try{for(_=this.parseCIDR(h),b=_[0].toByteArray(),w=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),I=[],A=0;A<16;)I.push(parseInt(b[A],10)&parseInt(w[A],10)),A++;return new this(I)}catch(H){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${H})`)}},g.IPv6.parse=function(h){let _=this.parser(h);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},g.IPv6.parseCIDR=function(h){let _,A,b;if((A=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(A[2]),_>=0&&_<=128))return b=[this.parse(A[1]),_],Object.defineProperty(b,"toString",{value:c(function(){return this.join("/")},"value")}),b;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},g.IPv6.parser=function(h){let _,A,b,I,w,H;if(b=h.match(a.deprecatedTransitional))return this.parser(`::ffff:${b[1]}`);if(a.native.test(h))return u(h,8);if((b=h.match(a.transitional))&&(H=b[6]||"",_=b[1],b[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+H,6),_.parts)){for(w=[parseInt(b[2]),parseInt(b[3]),parseInt(b[4]),parseInt(b[5])],A=0;A<w.length;A++)if(I=w[A],!(0<=I&&I<=255))return null;return _.parts.push(w[0]<<8|w[1]),_.parts.push(w[2]<<8|w[3]),{parts:_.parts,zoneId:_.zoneId}}return null},g.IPv6.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>128)throw new Error("ipaddr: invalid IPv6 prefix length");let _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],A=0,b=Math.floor(h/8);for(;A<b;)_[A]=255,A++;return b<16&&(_[b]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},g.fromByteArray=function(h){let _=h.length;if(_===4)return new g.IPv4(h);if(_===16)return new g.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},g.isValid=function(h){return g.IPv6.isValid(h)||g.IPv4.isValid(h)},g.isValidCIDR=function(h){return g.IPv6.isValidCIDR(h)||g.IPv4.isValidCIDR(h)},g.parse=function(h){if(g.IPv6.isValid(h))return g.IPv6.parse(h);if(g.IPv4.isValid(h))return g.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},g.parseCIDR=function(h){try{return g.IPv6.parseCIDR(h)}catch{try{return g.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},g.process=function(h){let _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},g.subnetMatch=function(h,_,A){let b,I,w,H;A==null&&(A="unicast");for(I in _)if(Object.prototype.hasOwnProperty.call(_,I)){for(w=_[I],w[0]&&!(w[0]instanceof Array)&&(w=[w]),b=0;b<w.length;b++)if(H=w[b],h.kind()===H[0].kind()&&h.match.apply(h,H))return I}return A},typeof na<"u"&&na.exports?na.exports=g:t.ipaddr=g})($p)});var oa=le(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.parseControlResponse=vb;ii.isSingleLine=Ch;ii.isMultiline=Rh;ii.positiveCompletion=Sb;ii.positiveIntermediate=wb;var gu=`
2
+ `;function vb(t){let e=t.split(/\r?\n/).filter(Pb),r=[],n=0,i;for(let s=0;s<e.length;s++){let a=e[s];if(i)i.test(a)&&(i=void 0,r.push(e.slice(n,s+1).join(gu)));else if(Rh(a)){let u=a.substr(0,3);i=new RegExp(`^${u}(?:$| )`),n=s}else Ch(a)&&r.push(a)}let o=i?e.slice(n).join(gu)+gu:"";return{messages:r,rest:o}}c(vb,"parseControlResponse");function Ch(t){return/^\d\d\d(?:$| )/.test(t)}c(Ch,"isSingleLine");function Rh(t){return/^\d\d\d-/.test(t)}c(Rh,"isMultiline");function Sb(t){return t>=200&&t<300}c(Sb,"positiveCompletion");function wb(t){return t>=300&&t<400}c(wb,"positiveIntermediate");function Pb(t){return t.trim()!==""}c(Pb,"isNotBlank")});var _u=le($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.FTPContext=$i.FTPError=void 0;var Tb=require("net"),kb=oa(),sa=class extends Error{static{c(this,"FTPError")}constructor(e){super(e.message),this.name=this.constructor.name,this.code=e.code}};$i.FTPError=sa;function Nh(){}c(Nh,"doNothing");var Cb=2**16,mu=class{static{c(this,"FTPContext")}constructor(e=0,r="utf8"){this.timeout=e,this.verbose=!1,this.ipFamily=void 0,this.tlsOptions={},this._partialResponse="",this._encoding=r,this._socket=this.socket=this._newSocket(),this._dataSocket=void 0}close(){let e=this._task?"User closed client during task":"User closed client",r=new Error(e);this.closeWithError(r)}closeWithError(e){this._closingError||(this._closingError=e,this._closeControlSocket(),this._closeSocket(this._dataSocket),this._passToHandler(e),this._stopTrackingTask())}get closed(){return this.socket.remoteAddress===void 0||this._closingError!==void 0}reset(){this.socket=this._newSocket()}get socket(){return this._socket}set socket(e){this.dataSocket=void 0,this.tlsOptions={},this._partialResponse="",this._socket&&(e.localPort===this._socket.localPort?this._removeSocketListeners(this.socket):this._closeControlSocket()),e&&(this._closingError=void 0,e.setTimeout(0),e.setEncoding(this._encoding),e.setKeepAlive(!0),e.on("data",r=>this._onControlSocketData(r)),e.on("end",()=>this.closeWithError(new Error("Server sent FIN packet unexpectedly, closing connection."))),e.on("close",r=>{r||this.closeWithError(new Error("Server closed connection unexpectedly."))}),this._setupDefaultErrorHandlers(e,"control socket")),this._socket=e}get dataSocket(){return this._dataSocket}set dataSocket(e){this._closeSocket(this._dataSocket),e&&(e.setTimeout(0),this._setupDefaultErrorHandlers(e,"data socket")),this._dataSocket=e}get encoding(){return this._encoding}set encoding(e){this._encoding=e,this.socket&&this.socket.setEncoding(e)}send(e){if(/[\r\n\0]/.test(e))throw new Error(`Invalid command: Contains control characters. (${e})`);let n=e.startsWith("PASS")?"> PASS ###":`> ${e}`;this.log(n),this._socket.write(e+`\r
3
3
  `,this.encoding)}request(e){return this.handle(e,(r,n)=>{r instanceof Error?n.reject(r):n.resolve(r)})}handle(e,r){if(this._task){let n=new Error("User launched a task while another one is still running. Forgot to use 'await' or '.then()'?");n.stack+=`
4
4
  Running task launched at: ${this._task.stack}`,this.closeWithError(n)}return new Promise((n,i)=>{if(this._task={stack:new Error().stack||"Unknown call stack",responseHandler:r,resolver:{resolve:c(o=>{this._stopTrackingTask(),n(o)},"resolve"),reject:c(o=>{this._stopTrackingTask(),i(o)},"reject")}},this._closingError){let o=new Error(`Client is closed because ${this._closingError.message}`);o.stack+=`
5
- Closing reason: ${this._closingError.stack}`,o.code=this._closingError.code!==void 0?this._closingError.code:"0",this._passToHandler(o);return}this.socket.setTimeout(this.timeout),e&&this.send(e)})}log(e){this.verbose&&console.log(e)}get hasTLS(){return"encrypted"in this._socket}_stopTrackingTask(){this.socket.setTimeout(0),this._task=void 0}_onControlSocketData(e){if(this.log(`< ${e}`),this._partialResponse.length+e.length>mb){this.closeWithError(new Error("FTP control response exceeded maximum allowed size"));return}let r=this._partialResponse+e,n=(0,gb.parseControlResponse)(r);this._partialResponse=n.rest;for(let i of n.messages){let o=parseInt(i.substr(0,3),10),s={code:o,message:i},a=o>=400?new oa(s):void 0;this._passToHandler(a||s)}}_passToHandler(e){this._task&&this._task.responseHandler(e,this._task.resolver)}_setupDefaultErrorHandlers(e,r){e.once("error",n=>{n.message+=` (${r})`,this.closeWithError(n)}),e.once("close",n=>{n&&this.closeWithError(new Error(`Socket closed due to transmission error (${r})`))}),e.once("timeout",()=>{e.destroy(),this.closeWithError(new Error(`Timeout (${r})`))})}_closeControlSocket(){this._removeSocketListeners(this._socket),this._socket.on("error",Ph),this.send("QUIT"),this._closeSocket(this._socket)}_closeSocket(e){e&&(this._removeSocketListeners(e),e.on("error",Ph),e.destroy())}_removeSocketListeners(e){e.removeAllListeners(),e.removeAllListeners("timeout"),e.removeAllListeners("data"),e.removeAllListeners("end"),e.removeAllListeners("error"),e.removeAllListeners("close"),e.removeAllListeners("connect")}_newSocket(){return new hb.Socket}};Oi.FTPContext=gu});var _u=le($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.describeTLS=_b;$i.describeAddress=yb;$i.upgradeSocket=Ab;$i.ipIsPrivateV4Address=Eb;var Th=require("tls");function _b(t){if(t instanceof Th.TLSSocket){let e=t.getProtocol();return e||"Server socket or disconnected client socket"}return"No encryption"}c(_b,"describeTLS");function yb(t){return t.remoteFamily==="IPv6"?`[${t.remoteAddress}]:${t.remotePort}`:`${t.remoteAddress}:${t.remotePort}`}c(yb,"describeAddress");function Ab(t,e){return new Promise((r,n)=>{let i=Object.assign({},e,{socket:t}),o=(0,Th.connect)(i,()=>{i.rejectUnauthorized!==!1&&!o.authorized?n(o.authorizationError):(o.removeAllListeners("error"),r(o))}).once("error",s=>{n(s)})})}c(Ab,"upgradeSocket");function Eb(t=""){t.startsWith("::ffff:")&&(t=t.substr(7));let e=t.split(".").map(r=>parseInt(r,10));return e[0]===10||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||t==="127.0.0.1"}c(Eb,"ipIsPrivateV4Address")});var Mo=le(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.FileInfo=Bi.FileType=void 0;var Di;(function(t){t[t.Unknown=0]="Unknown",t[t.File=1]="File",t[t.Directory=2]="Directory",t[t.SymbolicLink=3]="SymbolicLink"})(Di||(Bi.FileType=Di={}));var sa=class{static{c(this,"FileInfo")}constructor(e){this.name=e,this.type=Di.Unknown,this.size=0,this.rawModifiedAt="",this.modifiedAt=void 0,this.permissions=void 0,this.hardLinkCount=void 0,this.link=void 0,this.group=void 0,this.user=void 0,this.uniqueID=void 0,this.name=e}get isDirectory(){return this.type===Di.Directory}get isSymbolicLink(){return this.type===Di.SymbolicLink}get isFile(){return this.type===Di.File}get date(){return this.rawModifiedAt}set date(e){this.rawModifiedAt=e}};Bi.FileInfo=sa;sa.UnixPermission={Read:4,Write:2,Execute:1}});var Ch=le(Fo=>{"use strict";Object.defineProperty(Fo,"__esModule",{value:!0});Fo.testLine=bb;Fo.parseLine=xb;Fo.transformList=Ib;var yu=Mo(),kh=new RegExp("(\\S+)\\s+(\\S+)\\s+(?:(<DIR>)|([0-9]+))\\s+(\\S.*)");function bb(t){return/^\d{2}/.test(t)&&kh.test(t)}c(bb,"testLine");function xb(t){let e=t.match(kh);if(e===null)return;let r=e[5];if(r==="."||r==="..")return;let n=new yu.FileInfo(r);return e[3]==="<DIR>"?(n.type=yu.FileType.Directory,n.size=0):(n.type=yu.FileType.File,n.size=parseInt(e[4],10)),n.rawModifiedAt=e[1]+" "+e[2],n}c(xb,"parseLine");function Ib(t){return t}c(Ib,"transformList")});var Nh=le(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});Ho.testLine=Pb;Ho.parseLine=Tb;Ho.transformList=kb;var en=Mo(),vb="\u6708",Sb="\u65E5",wb="\u5E74",Rh=new RegExp("([bcdelfmpSs-])(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]?)))\\+?\\s*(\\d+)\\s+(?:(\\S+(?:\\s\\S+)*?)\\s+)?(?:(\\S+(?:\\s\\S+)*)\\s+)?(\\d+(?:,\\s*\\d+)?)\\s+((?:\\d+[-/]\\d+[-/]\\d+)|(?:\\S{3}\\s+\\d{1,2})|(?:\\d{1,2}\\s+\\S{3})|(?:\\d{1,2}"+vb+"\\s+\\d{1,2}"+Sb+"))\\s+((?:\\d+(?::\\d+)?)|(?:\\d{4}"+wb+"))\\s(.*)");function Pb(t){return Rh.test(t)}c(Pb,"testLine");function Tb(t){let e=t.match(Rh);if(e===null)return;let r=e[21];if(r==="."||r==="..")return;let n=new en.FileInfo(r);switch(n.size=parseInt(e[18],10),n.user=e[16],n.group=e[17],n.hardLinkCount=parseInt(e[15],10),n.rawModifiedAt=e[19]+" "+e[20],n.permissions={user:Au(e[4],e[5],e[6]),group:Au(e[8],e[9],e[10]),world:Au(e[12],e[13],e[14])},e[1].charAt(0)){case"d":n.type=en.FileType.Directory;break;case"e":n.type=en.FileType.SymbolicLink;break;case"l":n.type=en.FileType.SymbolicLink;break;case"b":case"c":n.type=en.FileType.File;break;case"f":case"-":n.type=en.FileType.File;break;default:n.type=en.FileType.Unknown}if(n.isSymbolicLink){let i=r.indexOf(" -> ");i!==-1&&(n.name=r.substring(0,i),n.link=r.substring(i+4))}return n}c(Tb,"parseLine");function kb(t){return t}c(kb,"transformList");function Au(t,e,r){let n=0;t!=="-"&&(n+=en.FileInfo.UnixPermission.Read),e!=="-"&&(n+=en.FileInfo.UnixPermission.Write);let i=r.charAt(0);return i!=="-"&&i.toUpperCase()!==i&&(n+=en.FileInfo.UnixPermission.Execute),n}c(Au,"parseMode")});var Eu=le(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Li.testLine=Rb;Li.parseLine=Nb;Li.transformList=Ob;Li.parseMLSxDate=Dh;var Ui=Mo();function Oh(t,e){e.size=parseInt(t,10)}c(Oh,"parseSize");var Cb={size:Oh,sizd:Oh,unique:c((t,e)=>{e.uniqueID=t},"unique"),modify:c((t,e)=>{e.modifiedAt=Dh(t),e.rawModifiedAt=e.modifiedAt.toISOString()},"modify"),type:c((t,e)=>{if(t.startsWith("OS.unix=slink"))return e.type=Ui.FileType.SymbolicLink,e.link=t.substr(t.indexOf(":")+1),1;switch(t){case"file":e.type=Ui.FileType.File;break;case"dir":e.type=Ui.FileType.Directory;break;case"OS.unix=symlink":e.type=Ui.FileType.SymbolicLink;break;case"cdir":case"pdir":return 2;default:e.type=Ui.FileType.Unknown}return 1},"type"),"unix.mode":c((t,e)=>{let r=t.substr(-3);e.permissions={user:parseInt(r[0],10),group:parseInt(r[1],10),world:parseInt(r[2],10)}},"unix.mode"),"unix.ownername":c((t,e)=>{e.user=t},"unix.ownername"),"unix.owner":c((t,e)=>{e.user===void 0&&(e.user=t)},"unix.owner"),get"unix.uid"(){return this["unix.owner"]},"unix.groupname":c((t,e)=>{e.group=t},"unix.groupname"),"unix.group":c((t,e)=>{e.group===void 0&&(e.group=t)},"unix.group"),get"unix.gid"(){return this["unix.group"]}};function $h(t,e){let r=t.indexOf(e),n=t.substr(0,r),i=t.substr(r+e.length);return[n,i]}c($h,"splitStringOnce");function Rb(t){return/^\S+=\S+;/.test(t)||t.startsWith(" ")}c(Rb,"testLine");function Nb(t){let[e,r]=$h(t," ");if(r===""||r==="."||r==="..")return;let n=new Ui.FileInfo(r),i=e.split(";");for(let o of i){let[s,a]=$h(o,"=");if(!a)continue;let u=Cb[s.toLowerCase()];if(!u)continue;if(u(a,n)===2)return}return n}c(Nb,"parseLine");function Ob(t){let e=new Map;for(let n of t)!n.isSymbolicLink&&n.uniqueID!==void 0&&e.set(n.uniqueID,n);let r=[];for(let n of t){if(n.isSymbolicLink&&n.uniqueID!==void 0&&n.link===void 0){let o=e.get(n.uniqueID);o!==void 0&&(n.link=o.name)}!n.name.includes("/")&&r.push(n)}return r}c(Ob,"transformList");function Dh(t){return new Date(Date.UTC(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),+t.slice(8,10),+t.slice(10,12),+t.slice(12,14),+t.slice(15,18)))}c(Dh,"parseMLSxDate")});var xu=le(mn=>{"use strict";var $b=mn&&mn.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:c(function(){return e[r]},"get")}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Db=mn&&mn.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),bu=mn&&mn.__importStar||(function(){var t=c(function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&$b(r,e,n[i]);return Db(r,e),r}})();Object.defineProperty(mn,"__esModule",{value:!0});mn.parseList=Wb;var Bb=bu(Ch()),Ub=bu(Nh()),Lb=bu(Eu()),zb=[Bb,Ub,Lb];function Mb(t,e){return e.find(r=>r.testLine(t)===!0)}c(Mb,"firstCompatibleParser");function Fb(t){return t.trim()!==""}c(Fb,"isNotBlank");function Hb(t){return!t.startsWith("total")}c(Hb,"isNotMeta");var jb=/\r?\n/;function Wb(t){let e=t.split(jb).filter(Fb).filter(Hb);if(e.length===0)return[];let r=e[e.length-1],n=Mb(r,zb);if(!n)throw new Error("This library only supports MLSD, Unix- or DOS-style directory listing. Your FTP server seems to be using another format. You can see the transmitted listing when setting `client.ftp.verbose = true`. You can then provide a custom parser to `client.parseList`, see the documentation for details.");let i=e.map(n.parseLine).filter(o=>o!==void 0);return n.transformList(i)}c(Wb,"parseList")});var Bh=le(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.ProgressTracker=void 0;var Iu=class{static{c(this,"ProgressTracker")}constructor(){this.bytesOverall=0,this.intervalMs=500,this.onStop=aa,this.onHandle=aa}reportTo(e=aa){this.onHandle=e}start(e,r,n){let i=0;this.onStop=qb(this.intervalMs,()=>{let o=e.bytesRead+e.bytesWritten;this.bytesOverall+=o-i,i=o,this.onHandle({name:r,type:n,bytes:o,bytesOverall:this.bytesOverall})})}stop(){this.onStop(!1)}updateAndStop(){this.onStop(!0)}};ca.ProgressTracker=Iu;function qb(t,e){let r=setInterval(e,t),n=c(i=>{clearInterval(r),i&&e(),e=aa},"stopFunc");return e(),n}c(qb,"poll");function aa(){}c(aa,"noop")});var Uh=le(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.StringWriter=void 0;var Qb=require("stream"),vu=class extends Qb.Writable{static{c(this,"StringWriter")}constructor(e=1*1024*1024){super(),this.maxByteLength=e,this.byteLength=0,this.bufs=[]}_write(e,r,n){if(!(e instanceof Buffer)){n(new Error("StringWriter: expects chunks of type 'Buffer'."));return}if(this.byteLength+e.byteLength>this.maxByteLength){n(new Error(`StringWriter: Maximum bytes exceeded, maxByteLength=${this.maxByteLength}.`));return}this.byteLength+=e.byteLength,this.bufs.push(e),n(null)}getText(e){return Buffer.concat(this.bufs).toString(e)}};ua.StringWriter=vu});var wu=le(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.enterPassiveModeIPv6=Kb;tn.parseEpsvResponse=Mh;tn.enterPassiveModeIPv4=Vb;tn.enterPassiveModeIPv4_forceControlHostIP=Gb;tn.parsePasvResponse=Su;tn.connectForPassiveTransfer=da;tn.uploadFrom=Zb;tn.downloadTo=Yb;var zi=_u(),zh=require("stream"),Lh=require("tls"),la=ia();async function Kb(t){let e=await t.request("EPSV"),r=Mh(e.message);if(!r)throw new Error("Can't parse EPSV response: "+e.message);let n=t.socket.remoteAddress;if(n===void 0)throw new Error("Control socket is disconnected, can't get remote address.");return await da(n,r,t),e}c(Kb,"enterPassiveModeIPv6");function Mh(t){let e=t.match(/[|!]{3}(.+)[|!]/);if(e===null||e[1]===void 0)throw new Error(`Can't parse response to 'EPSV': ${t}`);let r=parseInt(e[1],10);if(Number.isNaN(r))throw new Error(`Can't parse response to 'EPSV', port is not a number: ${t}`);return r}c(Mh,"parseEpsvResponse");async function Vb(t){let e=await t.request("PASV"),r=Su(e.message);if(!r)throw new Error("Can't parse PASV response: "+e.message);let n=t.socket.remoteAddress;return(0,zi.ipIsPrivateV4Address)(r.host)&&n&&!(0,zi.ipIsPrivateV4Address)(n)&&(r.host=n),await da(r.host,r.port,t),e}c(Vb,"enterPassiveModeIPv4");async function Gb(t){let e=await t.request("PASV"),r=Su(e.message);if(!r)throw new Error("Can't parse PASV response: "+e.message);let n=t.socket.remoteAddress;if(n===void 0)throw new Error("Control socket is disconnected, can't get remote address.");return await da(n,r.port,t),e}c(Gb,"enterPassiveModeIPv4_forceControlHostIP");function Su(t){let e=t.match(/([-\d]+,[-\d]+,[-\d]+,[-\d]+),([-\d]+),([-\d]+)/);if(e===null||e.length!==4)throw new Error(`Can't parse response to 'PASV': ${t}`);return{host:e[1].replace(/,/g,"."),port:(parseInt(e[2],10)&255)*256+(parseInt(e[3],10)&255)}}c(Su,"parsePasvResponse");function da(t,e,r){return new Promise((n,i)=>{let o=r._newSocket(),s=c(function(u){u.message="Can't open data connection in passive mode: "+u.message,i(u)},"handleConnErr"),a=c(function(){o.destroy(),i(new Error(`Timeout when trying to open data connection to ${t}:${e}`))},"handleTimeout");o.setTimeout(r.timeout),o.on("error",s),o.on("timeout",a),o.connect({port:e,host:t,family:r.ipFamily},()=>{r.socket instanceof Lh.TLSSocket&&(o=(0,Lh.connect)(Object.assign({},r.tlsOptions,{socket:o,session:r.socket.getSession()}))),o.removeListener("error",s),o.removeListener("timeout",a),r.dataSocket=o,n()})})}c(da,"connectForPassiveTransfer");var fa=class{static{c(this,"TransferResolver")}constructor(e,r){this.ftp=e,this.progress=r,this.response=void 0,this.dataTransferDone=!1}onDataStart(e,r){if(this.ftp.dataSocket===void 0)throw new Error("Data transfer should start but there is no data connection.");this.ftp.socket.setTimeout(0),this.ftp.dataSocket.setTimeout(this.ftp.timeout),this.progress.start(this.ftp.dataSocket,e,r)}onDataDone(e){this.progress.updateAndStop(),this.ftp.socket.setTimeout(this.ftp.timeout),this.ftp.dataSocket&&this.ftp.dataSocket.setTimeout(0),this.dataTransferDone=!0,this.tryResolve(e)}onControlDone(e,r){this.response=r,this.tryResolve(e)}onError(e,r){this.progress.updateAndStop(),this.ftp.socket.setTimeout(this.ftp.timeout),this.ftp.dataSocket=void 0,e.reject(r)}onUnexpectedRequest(e){let r=new Error(`Unexpected FTP response is requesting an answer: ${e.message}`);this.ftp.closeWithError(r)}tryResolve(e){this.dataTransferDone&&this.response!==void 0&&(this.ftp.dataSocket=void 0,e.resolve(this.response))}};function Zb(t,e){let r=new fa(e.ftp,e.tracker),n=`${e.command} ${e.remotePath}`;return e.ftp.handle(n,(i,o)=>{if(i instanceof Error)r.onError(o,i);else if(i.code===150||i.code===125){let s=e.ftp.dataSocket;if(!s){r.onError(o,new Error("Upload should begin but no data connection is available."));return}let a="getCipher"in s?s.getCipher()!==void 0:!0;Xb(a,s,"secureConnect",()=>{e.ftp.log(`Uploading to ${(0,zi.describeAddress)(s)} (${(0,zi.describeTLS)(s)})`),r.onDataStart(e.remotePath,e.type),(0,zh.pipeline)(t,s,u=>{u?r.onError(o,u):r.onDataDone(o)})})}else(0,la.positiveCompletion)(i.code)?r.onControlDone(o,i):(0,la.positiveIntermediate)(i.code)&&r.onUnexpectedRequest(i)})}c(Zb,"uploadFrom");function Yb(t,e){if(!e.ftp.dataSocket)throw new Error("Download will be initiated but no data connection is available.");let r=new fa(e.ftp,e.tracker);return e.ftp.handle(e.command,(n,i)=>{if(n instanceof Error)r.onError(i,n);else if(n.code===150||n.code===125){let o=e.ftp.dataSocket;if(!o){r.onError(i,new Error("Download should begin but no data connection is available."));return}e.ftp.log(`Downloading from ${(0,zi.describeAddress)(o)} (${(0,zi.describeTLS)(o)})`),r.onDataStart(e.remotePath,e.type),(0,zh.pipeline)(o,t,s=>{s?r.onError(i,s):r.onDataDone(i)})}else n.code===350?e.ftp.send("RETR "+e.remotePath):(0,la.positiveCompletion)(n.code)?r.onControlDone(i,n):(0,la.positiveIntermediate)(n.code)&&r.onUnexpectedRequest(n)})}c(Yb,"downloadTo");function Xb(t,e,r,n){t===!0?n():e.once(r,()=>n())}c(Xb,"onConditionOrEvent")});var qh=le(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.Client=void 0;var $n=require("fs"),Pu=require("path"),Jb=require("tls"),Fi=require("util"),jo=mu(),ii=_u(),Tu=ia(),ex=xu(),tx=Eu(),rx=Bh(),nx=Uh(),Mi=wu(),ix=(0,Fi.promisify)($n.readdir),ox=(0,Fi.promisify)($n.mkdir),ku=(0,Fi.promisify)($n.stat),Fh=(0,Fi.promisify)($n.open),Hh=(0,Fi.promisify)($n.close),sx=(0,Fi.promisify)($n.unlink),jh={allowSeparateTransferHost:!0,maxListingBytes:40*1024*1024},Wh=c(()=>["LIST -a","LIST"],"LIST_COMMANDS_DEFAULT"),ax=c(()=>["MLSD","LIST -a","LIST"],"LIST_COMMANDS_MLSD"),Cu=class{static{c(this,"Client")}constructor(e=3e4,r=jh){this.availableListCommands=Wh();let n={...jh,...r};this.ftp=new jo.FTPContext(e),this.prepareTransfer=this._enterFirstCompatibleMode([Mi.enterPassiveModeIPv6,n.allowSeparateTransferHost?Mi.enterPassiveModeIPv4:Mi.enterPassiveModeIPv4_forceControlHostIP]),this.options=n,this.parseList=ex.parseList,this._progressTracker=new rx.ProgressTracker}close(){this.ftp.close(),this._progressTracker.stop()}get closed(){return this.ftp.closed}connect(e="localhost",r=21){return this.ftp.reset(),this.ftp.socket.connect({host:e,port:r,family:this.ftp.ipFamily},()=>this.ftp.log(`Connected to ${(0,ii.describeAddress)(this.ftp.socket)} (${(0,ii.describeTLS)(this.ftp.socket)})`)),this._handleConnectResponse()}connectImplicitTLS(e="localhost",r=21,n={}){return this.ftp.reset(),this.ftp.socket=(0,Jb.connect)(r,e,n,()=>this.ftp.log(`Connected to ${(0,ii.describeAddress)(this.ftp.socket)} (${(0,ii.describeTLS)(this.ftp.socket)})`)),this.ftp.tlsOptions=n,this._handleConnectResponse()}_handleConnectResponse(){return this.ftp.handle(void 0,(e,r)=>{e instanceof Error?r.reject(e):(0,Tu.positiveCompletion)(e.code)?r.resolve(e):r.reject(new jo.FTPError(e))})}send(e,r=!1){return r?(this.ftp.log("Deprecated call using send(command, flag) with boolean flag to ignore errors. Use sendIgnoringError(command)."),this.sendIgnoringError(e)):this.ftp.request(e)}sendIgnoringError(e){return this.ftp.handle(e,(r,n)=>{r instanceof jo.FTPError?n.resolve({code:r.code,message:r.message}):r instanceof Error?n.reject(r):n.resolve(r)})}async useTLS(e={},r="AUTH TLS"){let n=await this.send(r);return this.ftp.socket=await(0,ii.upgradeSocket)(this.ftp.socket,e),this.ftp.tlsOptions=e,this.ftp.log(`Control socket is using: ${(0,ii.describeTLS)(this.ftp.socket)}`),n}login(e="anonymous",r="guest"){return this.ftp.log(`Login security: ${(0,ii.describeTLS)(this.ftp.socket)}`),this.ftp.handle("USER "+e,(n,i)=>{n instanceof Error?i.reject(n):(0,Tu.positiveCompletion)(n.code)?i.resolve(n):n.code===331?this.ftp.send("PASS "+r):i.reject(new jo.FTPError(n))})}async useDefaultSettings(){let r=(await this.features()).has("MLST");this.availableListCommands=r?ax():Wh(),await this.send("TYPE I"),await this.sendIgnoringError("STRU F"),await this.sendIgnoringError("OPTS UTF8 ON"),r&&await this.sendIgnoringError("OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;"),this.ftp.hasTLS&&(await this.sendIgnoringError("PBSZ 0"),await this.sendIgnoringError("PROT P"))}async access(e={}){var r,n;let i=e.secure===!0,o=e.secure==="implicit",s;if(o?s=await this.connectImplicitTLS(e.host,e.port,e.secureOptions):s=await this.connect(e.host,e.port),i){let a=(r=e.secureOptions)!==null&&r!==void 0?r:{};a.host=(n=a.host)!==null&&n!==void 0?n:e.host,await this.useTLS(a)}return await this.sendIgnoringError("OPTS UTF8 ON"),await this.login(e.user,e.password),await this.useDefaultSettings(),s}async pwd(){let e=await this.send("PWD"),r=e.message.match(/"(.+)"/);if(r===null||r[1]===void 0)throw new Error(`Can't parse response to command 'PWD': ${e.message}`);return r[1]}async features(){let e=await this.sendIgnoringError("FEAT"),r=new Map;return e.code<400&&(0,Tu.isMultiline)(e.message)&&e.message.split(`
6
- `).slice(1,-1).forEach(n=>{let i=n.trim().split(" ");r.set(i[0],i[1]||"")}),r}async cd(e){let r=await this.protectWhitespace(e);return this.send("CWD "+r)}async cdup(){return this.send("CDUP")}async lastMod(e){let r=await this.protectWhitespace(e),i=(await this.send(`MDTM ${r}`)).message.slice(4);return(0,tx.parseMLSxDate)(i)}async size(e){let n=`SIZE ${await this.protectWhitespace(e)}`,i=await this.send(n),o=parseInt(i.message.slice(4),10);if(Number.isNaN(o))throw new Error(`Can't parse response to command '${n}' as a numerical value: ${i.message}`);return o}async rename(e,r){let n=await this.protectWhitespace(e),i=await this.protectWhitespace(r);return await this.send("RNFR "+n),this.send("RNTO "+i)}async remove(e,r=!1){let n=await this.protectWhitespace(e);return r?this.sendIgnoringError(`DELE ${n}`):this.send(`DELE ${n}`)}trackProgress(e){this._progressTracker.bytesOverall=0,this._progressTracker.reportTo(e)}async uploadFrom(e,r,n={}){return this._uploadWithCommand(e,r,"STOR",n)}async appendFrom(e,r,n={}){return this._uploadWithCommand(e,r,"APPE",n)}async _uploadWithCommand(e,r,n,i){return typeof e=="string"?this._uploadLocalFile(e,r,n,i):this._uploadFromStream(e,r,n)}async _uploadLocalFile(e,r,n,i){let o=await Fh(e,"r"),s=(0,$n.createReadStream)("",{fd:o,start:i.localStart,end:i.localEndInclusive,autoClose:!1});try{return await this._uploadFromStream(s,r,n)}finally{await Wo(()=>Hh(o))}}async _uploadFromStream(e,r,n){let i=c(o=>this.ftp.closeWithError(o),"onError");e.once("error",i);try{let o=await this.protectWhitespace(r);return await this.prepareTransfer(this.ftp),await(0,Mi.uploadFrom)(e,{ftp:this.ftp,tracker:this._progressTracker,command:n,remotePath:o,type:"upload"})}finally{e.removeListener("error",i)}}async downloadTo(e,r,n=0){return typeof e=="string"?this._downloadToFile(e,r,n):this._downloadToStream(e,r,n)}async _downloadToFile(e,r,n){let i=n>0,s=await Fh(e,i?"r+":"w"),a=(0,$n.createWriteStream)("",{fd:s,start:n,autoClose:!1});try{return await this._downloadToStream(a,r,n)}catch(u){let l=await Wo(()=>ku(e)),d=l&&l.size>0;throw!i&&!d&&await Wo(()=>sx(e)),u}finally{await Wo(()=>Hh(s))}}async _downloadToStream(e,r,n){let i=c(o=>this.ftp.closeWithError(o),"onError");e.once("error",i);try{let o=await this.protectWhitespace(r);return await this.prepareTransfer(this.ftp),await(0,Mi.downloadTo)(e,{ftp:this.ftp,tracker:this._progressTracker,command:n>0?`REST ${n}`:`RETR ${o}`,remotePath:o,type:"download"})}finally{e.removeListener("error",i),e.end()}}async list(e=""){let r=await this.protectWhitespace(e),n;for(let i of this.availableListCommands){let o=r===""?i:`${i} ${r}`;await this.prepareTransfer(this.ftp);try{let s=await this._requestListWithCommand(o);return this.availableListCommands=[i],s}catch(s){if(!(s instanceof jo.FTPError))throw s;n=s}}throw n}async _requestListWithCommand(e){let r=new nx.StringWriter(this.options.maxListingBytes);await(0,Mi.downloadTo)(r,{ftp:this.ftp,tracker:this._progressTracker,command:e,remotePath:"",type:"list"});let n=r.getText(this.ftp.encoding);return this.ftp.log(n),this.parseList(n)}async removeDir(e){return this._exitAtCurrentDirectory(async()=>{await this.cd(e);let r=await this.pwd();await this.clearWorkingDir(),r==="/"||(await this.cdup(),await this.removeEmptyDir(r))})}async clearWorkingDir(){for(let e of await this.list())e.isDirectory?(await this.cd(e.name),await this.clearWorkingDir(),await this.cdup(),await this.removeEmptyDir(e.name)):await this.remove(e.name)}async uploadFromDir(e,r){return this._exitAtCurrentDirectory(async()=>(r&&await this.ensureDir(r),await this._uploadToWorkingDir(e)))}async _uploadToWorkingDir(e){let r=await ix(e);for(let n of r){let i=(0,Pu.join)(e,n),o=await ku(i);o.isFile()?await this.uploadFrom(i,n):o.isDirectory()&&(await this._openDir(n),await this._uploadToWorkingDir(i),await this.cdup())}}async downloadToDir(e,r){return this._exitAtCurrentDirectory(async()=>(r&&await this.cd(r),await this._downloadFromWorkingDir(e)))}async _downloadFromWorkingDir(e){await cx(e);for(let r of await this.list()){if(!r.name||(0,Pu.basename)(r.name)!==r.name){let o=JSON.stringify(r.name);this.ftp.log(`Invalid filename from server listing, will skip file. (${o})`);continue}let i=(0,Pu.join)(e,r.name);r.isDirectory?(await this.cd(r.name),await this._downloadFromWorkingDir(i),await this.cdup()):r.isFile&&await this.downloadTo(i,r.name)}}async ensureDir(e){e.startsWith("/")&&await this.cd("/");let r=e.split("/").filter(n=>n!=="");for(let n of r)await this._openDir(n)}async _openDir(e){await this.sendIgnoringError("MKD "+e),await this.cd(e)}async removeEmptyDir(e){let r=await this.protectWhitespace(e);return this.send(`RMD ${r}`)}async protectWhitespace(e){if(!e.startsWith(" "))return e;let r=await this.pwd();return(r.endsWith("/")?r:r+"/")+e}async _exitAtCurrentDirectory(e){let r=await this.pwd();try{return await e()}finally{this.closed||await Wo(()=>this.cd(r))}}_enterFirstCompatibleMode(e){return async r=>{r.log("Trying to find optimal transfer strategy...");let n;for(let i of e)try{let o=await i(r);return r.log("Optimal transfer strategy found."),this.prepareTransfer=i,o}catch(o){n=o}throw new Error(`None of the available transfer strategies work. Last error response was '${n}'.`)}}async upload(e,r,n={}){return this.ftp.log("Warning: upload() has been deprecated, use uploadFrom()."),this.uploadFrom(e,r,n)}async append(e,r,n={}){return this.ftp.log("Warning: append() has been deprecated, use appendFrom()."),this.appendFrom(e,r,n)}async download(e,r,n=0){return this.ftp.log("Warning: download() has been deprecated, use downloadTo()."),this.downloadTo(e,r,n)}async uploadDir(e,r){return this.ftp.log("Warning: uploadDir() has been deprecated, use uploadFromDir()."),this.uploadFromDir(e,r)}async downloadDir(e){return this.ftp.log("Warning: downloadDir() has been deprecated, use downloadToDir()."),this.downloadToDir(e)}};pa.Client=Cu;async function cx(t){try{await ku(t)}catch{await ox(t,{recursive:!0})}}c(cx,"ensureLocalDirectory");async function Wo(t){try{return await t()}catch{return}}c(Wo,"ignoreError")});var Kh=le(Qh=>{"use strict";Object.defineProperty(Qh,"__esModule",{value:!0})});var rn=le(br=>{"use strict";var ux=br&&br.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:c(function(){return e[r]},"get")}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),qo=br&&br.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&ux(e,t,r)};Object.defineProperty(br,"__esModule",{value:!0});br.enterPassiveModeIPv6=br.enterPassiveModeIPv4=void 0;qo(qh(),br);qo(mu(),br);qo(Mo(),br);qo(xu(),br);qo(Kh(),br);var Vh=wu();Object.defineProperty(br,"enterPassiveModeIPv4",{enumerable:!0,get:c(function(){return Vh.enterPassiveModeIPv4},"get")});Object.defineProperty(br,"enterPassiveModeIPv6",{enumerable:!0,get:c(function(){return Vh.enterPassiveModeIPv6},"get")})});var ha=le((h3,Gh)=>{Gh.exports={newInvalidAsn1Error:c(function(t){var e=new Error;return e.name="InvalidAsn1Error",e.message=t||"",e},"newInvalidAsn1Error")}});var ga=le((m3,Zh)=>{Zh.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 Ru=le((_3,Yh)=>{"use strict";var ma=require("buffer"),Hi=ma.Buffer,Lr={},zr;for(zr in ma)ma.hasOwnProperty(zr)&&(zr==="SlowBuffer"||zr==="Buffer"||(Lr[zr]=ma[zr]));var ji=Lr.Buffer={};for(zr in Hi)Hi.hasOwnProperty(zr)&&(zr==="allocUnsafe"||zr==="allocUnsafeSlow"||(ji[zr]=Hi[zr]));Lr.Buffer.prototype=Hi.prototype;(!ji.from||ji.from===Uint8Array.from)&&(ji.from=function(t,e,r){if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&typeof t.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Hi(t,e,r)});ji.alloc||(ji.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Hi(t);return!e||e.length===0?n.fill(0):typeof r=="string"?n.fill(e,r):n.fill(e),n});if(!Lr.kStringMaxLength)try{Lr.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}Lr.constants||(Lr.constants={MAX_LENGTH:Lr.kMaxLength},Lr.kStringMaxLength&&(Lr.constants.MAX_STRING_LENGTH=Lr.kStringMaxLength));Yh.exports=Lr});var eg=le((y3,Jh)=>{var lx=require("assert"),Xh=Ru().Buffer,Qo=ga(),fx=ha(),Wi=fx.newInvalidAsn1Error;function xr(t){if(!t||!Xh.isBuffer(t))throw new TypeError("data must be a node Buffer");this._buf=t,this._size=t.length,this._len=0,this._offset=0}c(xr,"Reader");Object.defineProperty(xr.prototype,"length",{enumerable:!0,get:c(function(){return this._len},"get")});Object.defineProperty(xr.prototype,"offset",{enumerable:!0,get:c(function(){return this._offset},"get")});Object.defineProperty(xr.prototype,"remain",{get:c(function(){return this._size-this._offset},"get")});Object.defineProperty(xr.prototype,"buffer",{get:c(function(){return this._buf.slice(this._offset)},"get")});xr.prototype.readByte=function(t){if(this._size-this._offset<1)return null;var e=this._buf[this._offset]&255;return t||(this._offset+=1),e};xr.prototype.peek=function(){return this.readByte(!0)};xr.prototype.readLength=function(t){if(t===void 0&&(t=this._offset),t>=this._size)return null;var e=this._buf[t++]&255;if(e===null)return null;if((e&128)===128){if(e&=127,e===0)throw Wi("Indefinite length not supported");if(e>4)throw Wi("encoding too long");if(this._size-t<e)return null;this._len=0;for(var r=0;r<e;r++)this._len=(this._len<<8)+(this._buf[t++]&255)}else this._len=e;return t};xr.prototype.readSequence=function(t){var e=this.peek();if(e===null)return null;if(t!==void 0&&t!==e)throw Wi("Expected 0x"+t.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);return r===null?null:(this._offset=r,e)};xr.prototype.readInt=function(){return this._readTag(Qo.Integer)};xr.prototype.readBoolean=function(){return this._readTag(Qo.Boolean)!==0};xr.prototype.readEnumeration=function(){return this._readTag(Qo.Enumeration)};xr.prototype.readString=function(t,e){t||(t=Qo.OctetString);var r=this.peek();if(r===null)return null;if(r!==t)throw Wi("Expected 0x"+t.toString(16)+": got 0x"+r.toString(16));var n=this.readLength(this._offset+1);if(n===null||this.length>this._size-n)return null;if(this._offset=n,this.length===0)return e?Xh.alloc(0):"";var i=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,e?i:i.toString("utf8")};xr.prototype.readOID=function(t){t||(t=Qo.OID);var e=this.readString(t,!0);if(e===null)return null;for(var r=[],n=0,i=0;i<e.length;i++){var o=e[i]&255;n<<=7,n+=o&127,(o&128)===0&&(r.push(n),n=0)}return n=r.shift(),r.unshift(n%40),r.unshift(n/40>>0),r.join(".")};xr.prototype._readTag=function(t){lx.ok(t!==void 0);var e=this.peek();if(e===null)return null;if(e!==t)throw Wi("Expected 0x"+t.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);if(r===null)return null;if(this.length>4)throw Wi("Integer too long: "+this.length);if(this.length>this._size-r)return null;this._offset=r;for(var n=this._buf[this._offset],i=0,o=0;o<this.length;o++)i<<=8,i|=this._buf[this._offset++]&255;return(n&128)===128&&o!==4&&(i-=1<<o*8),i>>0};Jh.exports=xr});var rg=le((E3,tg)=>{var Dn=require("assert"),_a=Ru().Buffer,Bn=ga(),dx=ha(),ya=dx.newInvalidAsn1Error,px={size:1024,growthFactor:8};function hx(t,e){Dn.ok(t),Dn.equal(typeof t,"object"),Dn.ok(e),Dn.equal(typeof e,"object");var r=Object.getOwnPropertyNames(t);return r.forEach(function(n){if(!e[n]){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i)}}),e}c(hx,"merge");function mr(t){t=hx(px,t||{}),this._buf=_a.alloc(t.size||1024),this._size=this._buf.length,this._offset=0,this._options=t,this._seq=[]}c(mr,"Writer");Object.defineProperty(mr.prototype,"buffer",{get:c(function(){if(this._seq.length)throw ya(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)},"get")});mr.prototype.writeByte=function(t){if(typeof t!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=t};mr.prototype.writeInt=function(t,e){if(typeof t!="number")throw new TypeError("argument must be a Number");typeof e!="number"&&(e=Bn.Integer);for(var r=4;((t&4286578688)===0||(t&4286578688)===-8388608)&&r>1;)r--,t<<=8;if(r>4)throw ya("BER ints cannot be > 0xffffffff");for(this._ensure(2+r),this._buf[this._offset++]=e,this._buf[this._offset++]=r;r-- >0;)this._buf[this._offset++]=(t&4278190080)>>>24,t<<=8};mr.prototype.writeNull=function(){this.writeByte(Bn.Null),this.writeByte(0)};mr.prototype.writeEnumeration=function(t,e){if(typeof t!="number")throw new TypeError("argument must be a Number");return typeof e!="number"&&(e=Bn.Enumeration),this.writeInt(t,e)};mr.prototype.writeBoolean=function(t,e){if(typeof t!="boolean")throw new TypeError("argument must be a Boolean");typeof e!="number"&&(e=Bn.Boolean),this._ensure(3),this._buf[this._offset++]=e,this._buf[this._offset++]=1,this._buf[this._offset++]=t?255:0};mr.prototype.writeString=function(t,e){if(typeof t!="string")throw new TypeError("argument must be a string (was: "+typeof t+")");typeof e!="number"&&(e=Bn.OctetString);var r=_a.byteLength(t);this.writeByte(e),this.writeLength(r),r&&(this._ensure(r),this._buf.write(t,this._offset),this._offset+=r)};mr.prototype.writeBuffer=function(t,e){if(typeof e!="number")throw new TypeError("tag must be a number");if(!_a.isBuffer(t))throw new TypeError("argument must be a buffer");this.writeByte(e),this.writeLength(t.length),this._ensure(t.length),t.copy(this._buf,this._offset,0,t.length),this._offset+=t.length};mr.prototype.writeStringArray=function(t){if(!t instanceof Array)throw new TypeError("argument must be an Array[String]");var e=this;t.forEach(function(r){e.writeString(r)})};mr.prototype.writeOID=function(t,e){if(typeof t!="string")throw new TypeError("argument must be a string");if(typeof e!="number"&&(e=Bn.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(t))throw new Error("argument is not a valid OID string");function r(s,a){a<128?s.push(a):a<16384?(s.push(a>>>7|128),s.push(a&127)):a<2097152?(s.push(a>>>14|128),s.push((a>>>7|128)&255),s.push(a&127)):a<268435456?(s.push(a>>>21|128),s.push((a>>>14|128)&255),s.push((a>>>7|128)&255),s.push(a&127)):(s.push((a>>>28|128)&255),s.push((a>>>21|128)&255),s.push((a>>>14|128)&255),s.push((a>>>7|128)&255),s.push(a&127))}c(r,"encodeOctet");var n=t.split("."),i=[];i.push(parseInt(n[0],10)*40+parseInt(n[1],10)),n.slice(2).forEach(function(s){r(i,parseInt(s,10))});var o=this;this._ensure(2+i.length),this.writeByte(e),this.writeLength(i.length),i.forEach(function(s){o.writeByte(s)})};mr.prototype.writeLength=function(t){if(typeof t!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),t<=127)this._buf[this._offset++]=t;else if(t<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=t;else if(t<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=t>>8,this._buf[this._offset++]=t;else if(t<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=t>>16,this._buf[this._offset++]=t>>8,this._buf[this._offset++]=t;else throw ya("Length too long (> 4 bytes)")};mr.prototype.startSequence=function(t){typeof t!="number"&&(t=Bn.Sequence|Bn.Constructor),this.writeByte(t),this._seq.push(this._offset),this._ensure(3),this._offset+=3};mr.prototype.endSequence=function(){var t=this._seq.pop(),e=t+3,r=this._offset-e;if(r<=127)this._shift(e,r,-2),this._buf[t]=r;else if(r<=255)this._shift(e,r,-1),this._buf[t]=129,this._buf[t+1]=r;else if(r<=65535)this._buf[t]=130,this._buf[t+1]=r>>8,this._buf[t+2]=r;else if(r<=16777215)this._shift(e,r,1),this._buf[t]=131,this._buf[t+1]=r>>16,this._buf[t+2]=r>>8,this._buf[t+3]=r;else throw ya("Sequence too long")};mr.prototype._shift=function(t,e,r){Dn.ok(t!==void 0),Dn.ok(e!==void 0),Dn.ok(r),this._buf.copy(this._buf,t+r,t,t+e),this._offset+=r};mr.prototype._ensure=function(t){if(Dn.ok(t),this._size-this._offset<t){var e=this._size*this._options.growthFactor;e-this._offset<t&&(e+=t);var r=_a.alloc(e);this._buf.copy(r,0,0,this._offset),this._buf=r,this._size=e}};tg.exports=mr});var ng=le((x3,ba)=>{var Nu=ha(),Ou=ga(),gx=eg(),mx=rg();ba.exports={Reader:gx,Writer:mx};for(Aa in Ou)Ou.hasOwnProperty(Aa)&&(ba.exports[Aa]=Ou[Aa]);var Aa;for(Ea in Nu)Nu.hasOwnProperty(Ea)&&(ba.exports[Ea]=Nu[Ea]);var Ea});var Ko=le((I3,ig)=>{var $u=ng();ig.exports={Ber:$u,BerReader:$u.Reader,BerWriter:$u.Writer}});var og=le((v3,xa)=>{(function(t){"use strict";var e=c(function(m){var A,y=new Float64Array(16);if(m)for(A=0;A<m.length;A++)y[A]=m[A];return y},"gf"),r=c(function(){throw new Error("no PRNG")},"randombytes"),n=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=e(),s=e([1]),a=e([56129,1]),u=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),p=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),g=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function h(m,A,y,f){m[A]=y>>24&255,m[A+1]=y>>16&255,m[A+2]=y>>8&255,m[A+3]=y&255,m[A+4]=f>>24&255,m[A+5]=f>>16&255,m[A+6]=f>>8&255,m[A+7]=f&255}c(h,"ts64");function _(m,A,y,f,x){var N,z=0;for(N=0;N<x;N++)z|=m[A+N]^y[f+N];return(1&z-1>>>8)-1}c(_,"vn");function E(m,A,y,f){return _(m,A,y,f,16)}c(E,"crypto_verify_16");function b(m,A,y,f){return _(m,A,y,f,32)}c(b,"crypto_verify_32");function I(m,A,y,f){for(var x=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,N=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,z=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,ne=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,ce=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,ye=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,pe=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,gt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,_e=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Ue=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Le=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Ge=y[16]&255|(y[17]&255)<<8|(y[18]&255)<<16|(y[19]&255)<<24,Ve=y[20]&255|(y[21]&255)<<8|(y[22]&255)<<16|(y[23]&255)<<24,ze=y[24]&255|(y[25]&255)<<8|(y[26]&255)<<16|(y[27]&255)<<24,Ke=y[28]&255|(y[29]&255)<<8|(y[30]&255)<<16|(y[31]&255)<<24,Me=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,Ae=x,Ie=N,ge=z,Ee=ne,be=ce,de=ye,Q=pe,K=gt,se=_e,re=Ue,ie=Le,ae=Ge,ke=Ve,Ze=ze,et=Ke,Ye=Me,S,nt=0;nt<20;nt+=2)S=Ae+ke|0,be^=S<<7|S>>>25,S=be+Ae|0,se^=S<<9|S>>>23,S=se+be|0,ke^=S<<13|S>>>19,S=ke+se|0,Ae^=S<<18|S>>>14,S=de+Ie|0,re^=S<<7|S>>>25,S=re+de|0,Ze^=S<<9|S>>>23,S=Ze+re|0,Ie^=S<<13|S>>>19,S=Ie+Ze|0,de^=S<<18|S>>>14,S=ie+Q|0,et^=S<<7|S>>>25,S=et+ie|0,ge^=S<<9|S>>>23,S=ge+et|0,Q^=S<<13|S>>>19,S=Q+ge|0,ie^=S<<18|S>>>14,S=Ye+ae|0,Ee^=S<<7|S>>>25,S=Ee+Ye|0,K^=S<<9|S>>>23,S=K+Ee|0,ae^=S<<13|S>>>19,S=ae+K|0,Ye^=S<<18|S>>>14,S=Ae+Ee|0,Ie^=S<<7|S>>>25,S=Ie+Ae|0,ge^=S<<9|S>>>23,S=ge+Ie|0,Ee^=S<<13|S>>>19,S=Ee+ge|0,Ae^=S<<18|S>>>14,S=de+be|0,Q^=S<<7|S>>>25,S=Q+de|0,K^=S<<9|S>>>23,S=K+Q|0,be^=S<<13|S>>>19,S=be+K|0,de^=S<<18|S>>>14,S=ie+re|0,ae^=S<<7|S>>>25,S=ae+ie|0,se^=S<<9|S>>>23,S=se+ae|0,re^=S<<13|S>>>19,S=re+se|0,ie^=S<<18|S>>>14,S=Ye+et|0,ke^=S<<7|S>>>25,S=ke+Ye|0,Ze^=S<<9|S>>>23,S=Ze+ke|0,et^=S<<13|S>>>19,S=et+Ze|0,Ye^=S<<18|S>>>14;Ae=Ae+x|0,Ie=Ie+N|0,ge=ge+z|0,Ee=Ee+ne|0,be=be+ce|0,de=de+ye|0,Q=Q+pe|0,K=K+gt|0,se=se+_e|0,re=re+Ue|0,ie=ie+Le|0,ae=ae+Ge|0,ke=ke+Ve|0,Ze=Ze+ze|0,et=et+Ke|0,Ye=Ye+Me|0,m[0]=Ae>>>0&255,m[1]=Ae>>>8&255,m[2]=Ae>>>16&255,m[3]=Ae>>>24&255,m[4]=Ie>>>0&255,m[5]=Ie>>>8&255,m[6]=Ie>>>16&255,m[7]=Ie>>>24&255,m[8]=ge>>>0&255,m[9]=ge>>>8&255,m[10]=ge>>>16&255,m[11]=ge>>>24&255,m[12]=Ee>>>0&255,m[13]=Ee>>>8&255,m[14]=Ee>>>16&255,m[15]=Ee>>>24&255,m[16]=be>>>0&255,m[17]=be>>>8&255,m[18]=be>>>16&255,m[19]=be>>>24&255,m[20]=de>>>0&255,m[21]=de>>>8&255,m[22]=de>>>16&255,m[23]=de>>>24&255,m[24]=Q>>>0&255,m[25]=Q>>>8&255,m[26]=Q>>>16&255,m[27]=Q>>>24&255,m[28]=K>>>0&255,m[29]=K>>>8&255,m[30]=K>>>16&255,m[31]=K>>>24&255,m[32]=se>>>0&255,m[33]=se>>>8&255,m[34]=se>>>16&255,m[35]=se>>>24&255,m[36]=re>>>0&255,m[37]=re>>>8&255,m[38]=re>>>16&255,m[39]=re>>>24&255,m[40]=ie>>>0&255,m[41]=ie>>>8&255,m[42]=ie>>>16&255,m[43]=ie>>>24&255,m[44]=ae>>>0&255,m[45]=ae>>>8&255,m[46]=ae>>>16&255,m[47]=ae>>>24&255,m[48]=ke>>>0&255,m[49]=ke>>>8&255,m[50]=ke>>>16&255,m[51]=ke>>>24&255,m[52]=Ze>>>0&255,m[53]=Ze>>>8&255,m[54]=Ze>>>16&255,m[55]=Ze>>>24&255,m[56]=et>>>0&255,m[57]=et>>>8&255,m[58]=et>>>16&255,m[59]=et>>>24&255,m[60]=Ye>>>0&255,m[61]=Ye>>>8&255,m[62]=Ye>>>16&255,m[63]=Ye>>>24&255}c(I,"core_salsa20");function w(m,A,y,f){for(var x=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,N=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,z=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,ne=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,ce=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,ye=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,pe=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,gt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,_e=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Ue=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Le=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Ge=y[16]&255|(y[17]&255)<<8|(y[18]&255)<<16|(y[19]&255)<<24,Ve=y[20]&255|(y[21]&255)<<8|(y[22]&255)<<16|(y[23]&255)<<24,ze=y[24]&255|(y[25]&255)<<8|(y[26]&255)<<16|(y[27]&255)<<24,Ke=y[28]&255|(y[29]&255)<<8|(y[30]&255)<<16|(y[31]&255)<<24,Me=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,Ae=x,Ie=N,ge=z,Ee=ne,be=ce,de=ye,Q=pe,K=gt,se=_e,re=Ue,ie=Le,ae=Ge,ke=Ve,Ze=ze,et=Ke,Ye=Me,S,nt=0;nt<20;nt+=2)S=Ae+ke|0,be^=S<<7|S>>>25,S=be+Ae|0,se^=S<<9|S>>>23,S=se+be|0,ke^=S<<13|S>>>19,S=ke+se|0,Ae^=S<<18|S>>>14,S=de+Ie|0,re^=S<<7|S>>>25,S=re+de|0,Ze^=S<<9|S>>>23,S=Ze+re|0,Ie^=S<<13|S>>>19,S=Ie+Ze|0,de^=S<<18|S>>>14,S=ie+Q|0,et^=S<<7|S>>>25,S=et+ie|0,ge^=S<<9|S>>>23,S=ge+et|0,Q^=S<<13|S>>>19,S=Q+ge|0,ie^=S<<18|S>>>14,S=Ye+ae|0,Ee^=S<<7|S>>>25,S=Ee+Ye|0,K^=S<<9|S>>>23,S=K+Ee|0,ae^=S<<13|S>>>19,S=ae+K|0,Ye^=S<<18|S>>>14,S=Ae+Ee|0,Ie^=S<<7|S>>>25,S=Ie+Ae|0,ge^=S<<9|S>>>23,S=ge+Ie|0,Ee^=S<<13|S>>>19,S=Ee+ge|0,Ae^=S<<18|S>>>14,S=de+be|0,Q^=S<<7|S>>>25,S=Q+de|0,K^=S<<9|S>>>23,S=K+Q|0,be^=S<<13|S>>>19,S=be+K|0,de^=S<<18|S>>>14,S=ie+re|0,ae^=S<<7|S>>>25,S=ae+ie|0,se^=S<<9|S>>>23,S=se+ae|0,re^=S<<13|S>>>19,S=re+se|0,ie^=S<<18|S>>>14,S=Ye+et|0,ke^=S<<7|S>>>25,S=ke+Ye|0,Ze^=S<<9|S>>>23,S=Ze+ke|0,et^=S<<13|S>>>19,S=et+Ze|0,Ye^=S<<18|S>>>14;m[0]=Ae>>>0&255,m[1]=Ae>>>8&255,m[2]=Ae>>>16&255,m[3]=Ae>>>24&255,m[4]=de>>>0&255,m[5]=de>>>8&255,m[6]=de>>>16&255,m[7]=de>>>24&255,m[8]=ie>>>0&255,m[9]=ie>>>8&255,m[10]=ie>>>16&255,m[11]=ie>>>24&255,m[12]=Ye>>>0&255,m[13]=Ye>>>8&255,m[14]=Ye>>>16&255,m[15]=Ye>>>24&255,m[16]=Q>>>0&255,m[17]=Q>>>8&255,m[18]=Q>>>16&255,m[19]=Q>>>24&255,m[20]=K>>>0&255,m[21]=K>>>8&255,m[22]=K>>>16&255,m[23]=K>>>24&255,m[24]=se>>>0&255,m[25]=se>>>8&255,m[26]=se>>>16&255,m[27]=se>>>24&255,m[28]=re>>>0&255,m[29]=re>>>8&255,m[30]=re>>>16&255,m[31]=re>>>24&255}c(w,"core_hsalsa20");function H(m,A,y,f){I(m,A,y,f)}c(H,"crypto_core_salsa20");function $(m,A,y,f){w(m,A,y,f)}c($,"crypto_core_hsalsa20");var X=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Z(m,A,y,f,x,N,z){var ne=new Uint8Array(16),ce=new Uint8Array(64),ye,pe;for(pe=0;pe<16;pe++)ne[pe]=0;for(pe=0;pe<8;pe++)ne[pe]=N[pe];for(;x>=64;){for(H(ce,ne,z,X),pe=0;pe<64;pe++)m[A+pe]=y[f+pe]^ce[pe];for(ye=1,pe=8;pe<16;pe++)ye=ye+(ne[pe]&255)|0,ne[pe]=ye&255,ye>>>=8;x-=64,A+=64,f+=64}if(x>0)for(H(ce,ne,z,X),pe=0;pe<x;pe++)m[A+pe]=y[f+pe]^ce[pe];return 0}c(Z,"crypto_stream_salsa20_xor");function Y(m,A,y,f,x){var N=new Uint8Array(16),z=new Uint8Array(64),ne,ce;for(ce=0;ce<16;ce++)N[ce]=0;for(ce=0;ce<8;ce++)N[ce]=f[ce];for(;y>=64;){for(H(z,N,x,X),ce=0;ce<64;ce++)m[A+ce]=z[ce];for(ne=1,ce=8;ce<16;ce++)ne=ne+(N[ce]&255)|0,N[ce]=ne&255,ne>>>=8;y-=64,A+=64}if(y>0)for(H(z,N,x,X),ce=0;ce<y;ce++)m[A+ce]=z[ce];return 0}c(Y,"crypto_stream_salsa20");function P(m,A,y,f,x){var N=new Uint8Array(32);$(N,f,x,X);for(var z=new Uint8Array(8),ne=0;ne<8;ne++)z[ne]=f[ne+16];return Y(m,A,y,z,N)}c(P,"crypto_stream");function k(m,A,y,f,x,N,z){var ne=new Uint8Array(32);$(ne,N,z,X);for(var ce=new Uint8Array(8),ye=0;ye<8;ye++)ce[ye]=N[ye+16];return Z(m,A,y,f,x,ce,ne)}c(k,"crypto_stream_xor");var M=c(function(m){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 A,y,f,x,N,z,ne,ce;A=m[0]&255|(m[1]&255)<<8,this.r[0]=A&8191,y=m[2]&255|(m[3]&255)<<8,this.r[1]=(A>>>13|y<<3)&8191,f=m[4]&255|(m[5]&255)<<8,this.r[2]=(y>>>10|f<<6)&7939,x=m[6]&255|(m[7]&255)<<8,this.r[3]=(f>>>7|x<<9)&8191,N=m[8]&255|(m[9]&255)<<8,this.r[4]=(x>>>4|N<<12)&255,this.r[5]=N>>>1&8190,z=m[10]&255|(m[11]&255)<<8,this.r[6]=(N>>>14|z<<2)&8191,ne=m[12]&255|(m[13]&255)<<8,this.r[7]=(z>>>11|ne<<5)&8065,ce=m[14]&255|(m[15]&255)<<8,this.r[8]=(ne>>>8|ce<<8)&8191,this.r[9]=ce>>>5&127,this.pad[0]=m[16]&255|(m[17]&255)<<8,this.pad[1]=m[18]&255|(m[19]&255)<<8,this.pad[2]=m[20]&255|(m[21]&255)<<8,this.pad[3]=m[22]&255|(m[23]&255)<<8,this.pad[4]=m[24]&255|(m[25]&255)<<8,this.pad[5]=m[26]&255|(m[27]&255)<<8,this.pad[6]=m[28]&255|(m[29]&255)<<8,this.pad[7]=m[30]&255|(m[31]&255)<<8},"poly1305");M.prototype.blocks=function(m,A,y){for(var f=this.fin?0:2048,x,N,z,ne,ce,ye,pe,gt,_e,Ue,Le,Ge,Ve,ze,Ke,Me,Ae,Ie,ge,Ee=this.h[0],be=this.h[1],de=this.h[2],Q=this.h[3],K=this.h[4],se=this.h[5],re=this.h[6],ie=this.h[7],ae=this.h[8],ke=this.h[9],Ze=this.r[0],et=this.r[1],Ye=this.r[2],S=this.r[3],nt=this.r[4],mt=this.r[5],_t=this.r[6],rt=this.r[7],ft=this.r[8],dt=this.r[9];y>=16;)x=m[A+0]&255|(m[A+1]&255)<<8,Ee+=x&8191,N=m[A+2]&255|(m[A+3]&255)<<8,be+=(x>>>13|N<<3)&8191,z=m[A+4]&255|(m[A+5]&255)<<8,de+=(N>>>10|z<<6)&8191,ne=m[A+6]&255|(m[A+7]&255)<<8,Q+=(z>>>7|ne<<9)&8191,ce=m[A+8]&255|(m[A+9]&255)<<8,K+=(ne>>>4|ce<<12)&8191,se+=ce>>>1&8191,ye=m[A+10]&255|(m[A+11]&255)<<8,re+=(ce>>>14|ye<<2)&8191,pe=m[A+12]&255|(m[A+13]&255)<<8,ie+=(ye>>>11|pe<<5)&8191,gt=m[A+14]&255|(m[A+15]&255)<<8,ae+=(pe>>>8|gt<<8)&8191,ke+=gt>>>5|f,_e=0,Ue=_e,Ue+=Ee*Ze,Ue+=be*(5*dt),Ue+=de*(5*ft),Ue+=Q*(5*rt),Ue+=K*(5*_t),_e=Ue>>>13,Ue&=8191,Ue+=se*(5*mt),Ue+=re*(5*nt),Ue+=ie*(5*S),Ue+=ae*(5*Ye),Ue+=ke*(5*et),_e+=Ue>>>13,Ue&=8191,Le=_e,Le+=Ee*et,Le+=be*Ze,Le+=de*(5*dt),Le+=Q*(5*ft),Le+=K*(5*rt),_e=Le>>>13,Le&=8191,Le+=se*(5*_t),Le+=re*(5*mt),Le+=ie*(5*nt),Le+=ae*(5*S),Le+=ke*(5*Ye),_e+=Le>>>13,Le&=8191,Ge=_e,Ge+=Ee*Ye,Ge+=be*et,Ge+=de*Ze,Ge+=Q*(5*dt),Ge+=K*(5*ft),_e=Ge>>>13,Ge&=8191,Ge+=se*(5*rt),Ge+=re*(5*_t),Ge+=ie*(5*mt),Ge+=ae*(5*nt),Ge+=ke*(5*S),_e+=Ge>>>13,Ge&=8191,Ve=_e,Ve+=Ee*S,Ve+=be*Ye,Ve+=de*et,Ve+=Q*Ze,Ve+=K*(5*dt),_e=Ve>>>13,Ve&=8191,Ve+=se*(5*ft),Ve+=re*(5*rt),Ve+=ie*(5*_t),Ve+=ae*(5*mt),Ve+=ke*(5*nt),_e+=Ve>>>13,Ve&=8191,ze=_e,ze+=Ee*nt,ze+=be*S,ze+=de*Ye,ze+=Q*et,ze+=K*Ze,_e=ze>>>13,ze&=8191,ze+=se*(5*dt),ze+=re*(5*ft),ze+=ie*(5*rt),ze+=ae*(5*_t),ze+=ke*(5*mt),_e+=ze>>>13,ze&=8191,Ke=_e,Ke+=Ee*mt,Ke+=be*nt,Ke+=de*S,Ke+=Q*Ye,Ke+=K*et,_e=Ke>>>13,Ke&=8191,Ke+=se*Ze,Ke+=re*(5*dt),Ke+=ie*(5*ft),Ke+=ae*(5*rt),Ke+=ke*(5*_t),_e+=Ke>>>13,Ke&=8191,Me=_e,Me+=Ee*_t,Me+=be*mt,Me+=de*nt,Me+=Q*S,Me+=K*Ye,_e=Me>>>13,Me&=8191,Me+=se*et,Me+=re*Ze,Me+=ie*(5*dt),Me+=ae*(5*ft),Me+=ke*(5*rt),_e+=Me>>>13,Me&=8191,Ae=_e,Ae+=Ee*rt,Ae+=be*_t,Ae+=de*mt,Ae+=Q*nt,Ae+=K*S,_e=Ae>>>13,Ae&=8191,Ae+=se*Ye,Ae+=re*et,Ae+=ie*Ze,Ae+=ae*(5*dt),Ae+=ke*(5*ft),_e+=Ae>>>13,Ae&=8191,Ie=_e,Ie+=Ee*ft,Ie+=be*rt,Ie+=de*_t,Ie+=Q*mt,Ie+=K*nt,_e=Ie>>>13,Ie&=8191,Ie+=se*S,Ie+=re*Ye,Ie+=ie*et,Ie+=ae*Ze,Ie+=ke*(5*dt),_e+=Ie>>>13,Ie&=8191,ge=_e,ge+=Ee*dt,ge+=be*ft,ge+=de*rt,ge+=Q*_t,ge+=K*mt,_e=ge>>>13,ge&=8191,ge+=se*nt,ge+=re*S,ge+=ie*Ye,ge+=ae*et,ge+=ke*Ze,_e+=ge>>>13,ge&=8191,_e=(_e<<2)+_e|0,_e=_e+Ue|0,Ue=_e&8191,_e=_e>>>13,Le+=_e,Ee=Ue,be=Le,de=Ge,Q=Ve,K=ze,se=Ke,re=Me,ie=Ae,ae=Ie,ke=ge,A+=16,y-=16;this.h[0]=Ee,this.h[1]=be,this.h[2]=de,this.h[3]=Q,this.h[4]=K,this.h[5]=se,this.h[6]=re,this.h[7]=ie,this.h[8]=ae,this.h[9]=ke},M.prototype.finish=function(m,A){var y=new Uint16Array(10),f,x,N,z;if(this.leftover){for(z=this.leftover,this.buffer[z++]=1;z<16;z++)this.buffer[z]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(f=this.h[1]>>>13,this.h[1]&=8191,z=2;z<10;z++)this.h[z]+=f,f=this.h[z]>>>13,this.h[z]&=8191;for(this.h[0]+=f*5,f=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=f,f=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=f,y[0]=this.h[0]+5,f=y[0]>>>13,y[0]&=8191,z=1;z<10;z++)y[z]=this.h[z]+f,f=y[z]>>>13,y[z]&=8191;for(y[9]-=8192,x=(f^1)-1,z=0;z<10;z++)y[z]&=x;for(x=~x,z=0;z<10;z++)this.h[z]=this.h[z]&x|y[z];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,N=this.h[0]+this.pad[0],this.h[0]=N&65535,z=1;z<8;z++)N=(this.h[z]+this.pad[z]|0)+(N>>>16)|0,this.h[z]=N&65535;m[A+0]=this.h[0]>>>0&255,m[A+1]=this.h[0]>>>8&255,m[A+2]=this.h[1]>>>0&255,m[A+3]=this.h[1]>>>8&255,m[A+4]=this.h[2]>>>0&255,m[A+5]=this.h[2]>>>8&255,m[A+6]=this.h[3]>>>0&255,m[A+7]=this.h[3]>>>8&255,m[A+8]=this.h[4]>>>0&255,m[A+9]=this.h[4]>>>8&255,m[A+10]=this.h[5]>>>0&255,m[A+11]=this.h[5]>>>8&255,m[A+12]=this.h[6]>>>0&255,m[A+13]=this.h[6]>>>8&255,m[A+14]=this.h[7]>>>0&255,m[A+15]=this.h[7]>>>8&255},M.prototype.update=function(m,A,y){var f,x;if(this.leftover){for(x=16-this.leftover,x>y&&(x=y),f=0;f<x;f++)this.buffer[this.leftover+f]=m[A+f];if(y-=x,A+=x,this.leftover+=x,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(y>=16&&(x=y-y%16,this.blocks(m,A,x),A+=x,y-=x),y){for(f=0;f<y;f++)this.buffer[this.leftover+f]=m[A+f];this.leftover+=y}};function L(m,A,y,f,x,N){var z=new M(N);return z.update(y,f,x),z.finish(m,A),0}c(L,"crypto_onetimeauth");function T(m,A,y,f,x,N){var z=new Uint8Array(16);return L(z,0,y,f,x,N),E(m,A,z,0)}c(T,"crypto_onetimeauth_verify");function F(m,A,y,f,x){var N;if(y<32)return-1;for(k(m,0,A,0,y,f,x),L(m,16,m,32,y-32,m),N=0;N<16;N++)m[N]=0;return 0}c(F,"crypto_secretbox");function j(m,A,y,f,x){var N,z=new Uint8Array(32);if(y<32||(P(z,0,32,f,x),T(A,16,A,32,y-32,z)!==0))return-1;for(k(m,0,A,0,y,f,x),N=0;N<32;N++)m[N]=0;return 0}c(j,"crypto_secretbox_open");function B(m,A){var y;for(y=0;y<16;y++)m[y]=A[y]|0}c(B,"set25519");function G(m){var A,y,f=1;for(A=0;A<16;A++)y=m[A]+f+65535,f=Math.floor(y/65536),m[A]=y-f*65536;m[0]+=f-1+37*(f-1)}c(G,"car25519");function ee(m,A,y){for(var f,x=~(y-1),N=0;N<16;N++)f=x&(m[N]^A[N]),m[N]^=f,A[N]^=f}c(ee,"sel25519");function C(m,A){var y,f,x,N=e(),z=e();for(y=0;y<16;y++)z[y]=A[y];for(G(z),G(z),G(z),f=0;f<2;f++){for(N[0]=z[0]-65517,y=1;y<15;y++)N[y]=z[y]-65535-(N[y-1]>>16&1),N[y-1]&=65535;N[15]=z[15]-32767-(N[14]>>16&1),x=N[15]>>16&1,N[14]&=65535,ee(z,N,1-x)}for(y=0;y<16;y++)m[2*y]=z[y]&255,m[2*y+1]=z[y]>>8}c(C,"pack25519");function W(m,A){var y=new Uint8Array(32),f=new Uint8Array(32);return C(y,m),C(f,A),b(y,0,f,0)}c(W,"neq25519");function q(m){var A=new Uint8Array(32);return C(A,m),A[0]&1}c(q,"par25519");function J(m,A){var y;for(y=0;y<16;y++)m[y]=A[2*y]+(A[2*y+1]<<8);m[15]&=32767}c(J,"unpack25519");function ue(m,A,y){for(var f=0;f<16;f++)m[f]=A[f]+y[f]}c(ue,"A");function me(m,A,y){for(var f=0;f<16;f++)m[f]=A[f]-y[f]}c(me,"Z");function he(m,A,y){var f,x,N=0,z=0,ne=0,ce=0,ye=0,pe=0,gt=0,_e=0,Ue=0,Le=0,Ge=0,Ve=0,ze=0,Ke=0,Me=0,Ae=0,Ie=0,ge=0,Ee=0,be=0,de=0,Q=0,K=0,se=0,re=0,ie=0,ae=0,ke=0,Ze=0,et=0,Ye=0,S=y[0],nt=y[1],mt=y[2],_t=y[3],rt=y[4],ft=y[5],dt=y[6],Yt=y[7],It=y[8],Wt=y[9],qt=y[10],Qt=y[11],or=y[12],fr=y[13],dr=y[14],pr=y[15];f=A[0],N+=f*S,z+=f*nt,ne+=f*mt,ce+=f*_t,ye+=f*rt,pe+=f*ft,gt+=f*dt,_e+=f*Yt,Ue+=f*It,Le+=f*Wt,Ge+=f*qt,Ve+=f*Qt,ze+=f*or,Ke+=f*fr,Me+=f*dr,Ae+=f*pr,f=A[1],z+=f*S,ne+=f*nt,ce+=f*mt,ye+=f*_t,pe+=f*rt,gt+=f*ft,_e+=f*dt,Ue+=f*Yt,Le+=f*It,Ge+=f*Wt,Ve+=f*qt,ze+=f*Qt,Ke+=f*or,Me+=f*fr,Ae+=f*dr,Ie+=f*pr,f=A[2],ne+=f*S,ce+=f*nt,ye+=f*mt,pe+=f*_t,gt+=f*rt,_e+=f*ft,Ue+=f*dt,Le+=f*Yt,Ge+=f*It,Ve+=f*Wt,ze+=f*qt,Ke+=f*Qt,Me+=f*or,Ae+=f*fr,Ie+=f*dr,ge+=f*pr,f=A[3],ce+=f*S,ye+=f*nt,pe+=f*mt,gt+=f*_t,_e+=f*rt,Ue+=f*ft,Le+=f*dt,Ge+=f*Yt,Ve+=f*It,ze+=f*Wt,Ke+=f*qt,Me+=f*Qt,Ae+=f*or,Ie+=f*fr,ge+=f*dr,Ee+=f*pr,f=A[4],ye+=f*S,pe+=f*nt,gt+=f*mt,_e+=f*_t,Ue+=f*rt,Le+=f*ft,Ge+=f*dt,Ve+=f*Yt,ze+=f*It,Ke+=f*Wt,Me+=f*qt,Ae+=f*Qt,Ie+=f*or,ge+=f*fr,Ee+=f*dr,be+=f*pr,f=A[5],pe+=f*S,gt+=f*nt,_e+=f*mt,Ue+=f*_t,Le+=f*rt,Ge+=f*ft,Ve+=f*dt,ze+=f*Yt,Ke+=f*It,Me+=f*Wt,Ae+=f*qt,Ie+=f*Qt,ge+=f*or,Ee+=f*fr,be+=f*dr,de+=f*pr,f=A[6],gt+=f*S,_e+=f*nt,Ue+=f*mt,Le+=f*_t,Ge+=f*rt,Ve+=f*ft,ze+=f*dt,Ke+=f*Yt,Me+=f*It,Ae+=f*Wt,Ie+=f*qt,ge+=f*Qt,Ee+=f*or,be+=f*fr,de+=f*dr,Q+=f*pr,f=A[7],_e+=f*S,Ue+=f*nt,Le+=f*mt,Ge+=f*_t,Ve+=f*rt,ze+=f*ft,Ke+=f*dt,Me+=f*Yt,Ae+=f*It,Ie+=f*Wt,ge+=f*qt,Ee+=f*Qt,be+=f*or,de+=f*fr,Q+=f*dr,K+=f*pr,f=A[8],Ue+=f*S,Le+=f*nt,Ge+=f*mt,Ve+=f*_t,ze+=f*rt,Ke+=f*ft,Me+=f*dt,Ae+=f*Yt,Ie+=f*It,ge+=f*Wt,Ee+=f*qt,be+=f*Qt,de+=f*or,Q+=f*fr,K+=f*dr,se+=f*pr,f=A[9],Le+=f*S,Ge+=f*nt,Ve+=f*mt,ze+=f*_t,Ke+=f*rt,Me+=f*ft,Ae+=f*dt,Ie+=f*Yt,ge+=f*It,Ee+=f*Wt,be+=f*qt,de+=f*Qt,Q+=f*or,K+=f*fr,se+=f*dr,re+=f*pr,f=A[10],Ge+=f*S,Ve+=f*nt,ze+=f*mt,Ke+=f*_t,Me+=f*rt,Ae+=f*ft,Ie+=f*dt,ge+=f*Yt,Ee+=f*It,be+=f*Wt,de+=f*qt,Q+=f*Qt,K+=f*or,se+=f*fr,re+=f*dr,ie+=f*pr,f=A[11],Ve+=f*S,ze+=f*nt,Ke+=f*mt,Me+=f*_t,Ae+=f*rt,Ie+=f*ft,ge+=f*dt,Ee+=f*Yt,be+=f*It,de+=f*Wt,Q+=f*qt,K+=f*Qt,se+=f*or,re+=f*fr,ie+=f*dr,ae+=f*pr,f=A[12],ze+=f*S,Ke+=f*nt,Me+=f*mt,Ae+=f*_t,Ie+=f*rt,ge+=f*ft,Ee+=f*dt,be+=f*Yt,de+=f*It,Q+=f*Wt,K+=f*qt,se+=f*Qt,re+=f*or,ie+=f*fr,ae+=f*dr,ke+=f*pr,f=A[13],Ke+=f*S,Me+=f*nt,Ae+=f*mt,Ie+=f*_t,ge+=f*rt,Ee+=f*ft,be+=f*dt,de+=f*Yt,Q+=f*It,K+=f*Wt,se+=f*qt,re+=f*Qt,ie+=f*or,ae+=f*fr,ke+=f*dr,Ze+=f*pr,f=A[14],Me+=f*S,Ae+=f*nt,Ie+=f*mt,ge+=f*_t,Ee+=f*rt,be+=f*ft,de+=f*dt,Q+=f*Yt,K+=f*It,se+=f*Wt,re+=f*qt,ie+=f*Qt,ae+=f*or,ke+=f*fr,Ze+=f*dr,et+=f*pr,f=A[15],Ae+=f*S,Ie+=f*nt,ge+=f*mt,Ee+=f*_t,be+=f*rt,de+=f*ft,Q+=f*dt,K+=f*Yt,se+=f*It,re+=f*Wt,ie+=f*qt,ae+=f*Qt,ke+=f*or,Ze+=f*fr,et+=f*dr,Ye+=f*pr,N+=38*Ie,z+=38*ge,ne+=38*Ee,ce+=38*be,ye+=38*de,pe+=38*Q,gt+=38*K,_e+=38*se,Ue+=38*re,Le+=38*ie,Ge+=38*ae,Ve+=38*ke,ze+=38*Ze,Ke+=38*et,Me+=38*Ye,x=1,f=N+x+65535,x=Math.floor(f/65536),N=f-x*65536,f=z+x+65535,x=Math.floor(f/65536),z=f-x*65536,f=ne+x+65535,x=Math.floor(f/65536),ne=f-x*65536,f=ce+x+65535,x=Math.floor(f/65536),ce=f-x*65536,f=ye+x+65535,x=Math.floor(f/65536),ye=f-x*65536,f=pe+x+65535,x=Math.floor(f/65536),pe=f-x*65536,f=gt+x+65535,x=Math.floor(f/65536),gt=f-x*65536,f=_e+x+65535,x=Math.floor(f/65536),_e=f-x*65536,f=Ue+x+65535,x=Math.floor(f/65536),Ue=f-x*65536,f=Le+x+65535,x=Math.floor(f/65536),Le=f-x*65536,f=Ge+x+65535,x=Math.floor(f/65536),Ge=f-x*65536,f=Ve+x+65535,x=Math.floor(f/65536),Ve=f-x*65536,f=ze+x+65535,x=Math.floor(f/65536),ze=f-x*65536,f=Ke+x+65535,x=Math.floor(f/65536),Ke=f-x*65536,f=Me+x+65535,x=Math.floor(f/65536),Me=f-x*65536,f=Ae+x+65535,x=Math.floor(f/65536),Ae=f-x*65536,N+=x-1+37*(x-1),x=1,f=N+x+65535,x=Math.floor(f/65536),N=f-x*65536,f=z+x+65535,x=Math.floor(f/65536),z=f-x*65536,f=ne+x+65535,x=Math.floor(f/65536),ne=f-x*65536,f=ce+x+65535,x=Math.floor(f/65536),ce=f-x*65536,f=ye+x+65535,x=Math.floor(f/65536),ye=f-x*65536,f=pe+x+65535,x=Math.floor(f/65536),pe=f-x*65536,f=gt+x+65535,x=Math.floor(f/65536),gt=f-x*65536,f=_e+x+65535,x=Math.floor(f/65536),_e=f-x*65536,f=Ue+x+65535,x=Math.floor(f/65536),Ue=f-x*65536,f=Le+x+65535,x=Math.floor(f/65536),Le=f-x*65536,f=Ge+x+65535,x=Math.floor(f/65536),Ge=f-x*65536,f=Ve+x+65535,x=Math.floor(f/65536),Ve=f-x*65536,f=ze+x+65535,x=Math.floor(f/65536),ze=f-x*65536,f=Ke+x+65535,x=Math.floor(f/65536),Ke=f-x*65536,f=Me+x+65535,x=Math.floor(f/65536),Me=f-x*65536,f=Ae+x+65535,x=Math.floor(f/65536),Ae=f-x*65536,N+=x-1+37*(x-1),m[0]=N,m[1]=z,m[2]=ne,m[3]=ce,m[4]=ye,m[5]=pe,m[6]=gt,m[7]=_e,m[8]=Ue,m[9]=Le,m[10]=Ge,m[11]=Ve,m[12]=ze,m[13]=Ke,m[14]=Me,m[15]=Ae}c(he,"M");function bt(m,A){he(m,A,A)}c(bt,"S");function Ct(m,A){var y=e(),f;for(f=0;f<16;f++)y[f]=A[f];for(f=253;f>=0;f--)bt(y,y),f!==2&&f!==4&&he(y,y,A);for(f=0;f<16;f++)m[f]=y[f]}c(Ct,"inv25519");function Xt(m,A){var y=e(),f;for(f=0;f<16;f++)y[f]=A[f];for(f=250;f>=0;f--)bt(y,y),f!==1&&he(y,y,A);for(f=0;f<16;f++)m[f]=y[f]}c(Xt,"pow2523");function yr(m,A,y){var f=new Uint8Array(32),x=new Float64Array(80),N,z,ne=e(),ce=e(),ye=e(),pe=e(),gt=e(),_e=e();for(z=0;z<31;z++)f[z]=A[z];for(f[31]=A[31]&127|64,f[0]&=248,J(x,y),z=0;z<16;z++)ce[z]=x[z],pe[z]=ne[z]=ye[z]=0;for(ne[0]=pe[0]=1,z=254;z>=0;--z)N=f[z>>>3]>>>(z&7)&1,ee(ne,ce,N),ee(ye,pe,N),ue(gt,ne,ye),me(ne,ne,ye),ue(ye,ce,pe),me(ce,ce,pe),bt(pe,gt),bt(_e,ne),he(ne,ye,ne),he(ye,ce,gt),ue(gt,ne,ye),me(ne,ne,ye),bt(ce,ne),me(ye,pe,_e),he(ne,ye,a),ue(ne,ne,pe),he(ye,ye,ne),he(ne,pe,_e),he(pe,ce,x),bt(ce,gt),ee(ne,ce,N),ee(ye,pe,N);for(z=0;z<16;z++)x[z+16]=ne[z],x[z+32]=ye[z],x[z+48]=ce[z],x[z+64]=pe[z];var Ue=x.subarray(32),Le=x.subarray(16);return Ct(Ue,Ue),he(Le,Le,Ue),C(m,Le),0}c(yr,"crypto_scalarmult");function Dr(m,A){return yr(m,A,i)}c(Dr,"crypto_scalarmult_base");function vr(m,A){return r(A,32),Dr(m,A)}c(vr,"crypto_box_keypair");function Ai(m,A,y){var f=new Uint8Array(32);return yr(f,y,A),$(m,n,f,X)}c(Ai,"crypto_box_beforenm");var ho=F,Ds=j;function go(m,A,y,f,x,N){var z=new Uint8Array(32);return Ai(z,x,N),ho(m,A,y,f,z)}c(go,"crypto_box");function Ei(m,A,y,f,x,N){var z=new Uint8Array(32);return Ai(z,x,N),Ds(m,A,y,f,z)}c(Ei,"crypto_box_open");var bi=[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 te(m,A,y,f){for(var x=new Int32Array(16),N=new Int32Array(16),z,ne,ce,ye,pe,gt,_e,Ue,Le,Ge,Ve,ze,Ke,Me,Ae,Ie,ge,Ee,be,de,Q,K,se,re,ie,ae,ke=m[0],Ze=m[1],et=m[2],Ye=m[3],S=m[4],nt=m[5],mt=m[6],_t=m[7],rt=A[0],ft=A[1],dt=A[2],Yt=A[3],It=A[4],Wt=A[5],qt=A[6],Qt=A[7],or=0;f>=128;){for(be=0;be<16;be++)de=8*be+or,x[be]=y[de+0]<<24|y[de+1]<<16|y[de+2]<<8|y[de+3],N[be]=y[de+4]<<24|y[de+5]<<16|y[de+6]<<8|y[de+7];for(be=0;be<80;be++)if(z=ke,ne=Ze,ce=et,ye=Ye,pe=S,gt=nt,_e=mt,Ue=_t,Le=rt,Ge=ft,Ve=dt,ze=Yt,Ke=It,Me=Wt,Ae=qt,Ie=Qt,Q=_t,K=Qt,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=(S>>>14|It<<18)^(S>>>18|It<<14)^(It>>>9|S<<23),K=(It>>>14|S<<18)^(It>>>18|S<<14)^(S>>>9|It<<23),se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,Q=S&nt^~S&mt,K=It&Wt^~It&qt,se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,Q=bi[be*2],K=bi[be*2+1],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,Q=x[be%16],K=N[be%16],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,ge=ie&65535|ae<<16,Ee=se&65535|re<<16,Q=ge,K=Ee,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=(ke>>>28|rt<<4)^(rt>>>2|ke<<30)^(rt>>>7|ke<<25),K=(rt>>>28|ke<<4)^(ke>>>2|rt<<30)^(ke>>>7|rt<<25),se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,Q=ke&Ze^ke&et^Ze&et,K=rt&ft^rt&dt^ft&dt,se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,Ue=ie&65535|ae<<16,Ie=se&65535|re<<16,Q=ye,K=ze,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=ge,K=Ee,se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,ye=ie&65535|ae<<16,ze=se&65535|re<<16,Ze=z,et=ne,Ye=ce,S=ye,nt=pe,mt=gt,_t=_e,ke=Ue,ft=Le,dt=Ge,Yt=Ve,It=ze,Wt=Ke,qt=Me,Qt=Ae,rt=Ie,be%16===15)for(de=0;de<16;de++)Q=x[de],K=N[de],se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=x[(de+9)%16],K=N[(de+9)%16],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,ge=x[(de+1)%16],Ee=N[(de+1)%16],Q=(ge>>>1|Ee<<31)^(ge>>>8|Ee<<24)^ge>>>7,K=(Ee>>>1|ge<<31)^(Ee>>>8|ge<<24)^(Ee>>>7|ge<<25),se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,ge=x[(de+14)%16],Ee=N[(de+14)%16],Q=(ge>>>19|Ee<<13)^(Ee>>>29|ge<<3)^ge>>>6,K=(Ee>>>19|ge<<13)^(ge>>>29|Ee<<3)^(Ee>>>6|ge<<26),se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,x[de]=ie&65535|ae<<16,N[de]=se&65535|re<<16;Q=ke,K=rt,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=m[0],K=A[0],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[0]=ke=ie&65535|ae<<16,A[0]=rt=se&65535|re<<16,Q=Ze,K=ft,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=m[1],K=A[1],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[1]=Ze=ie&65535|ae<<16,A[1]=ft=se&65535|re<<16,Q=et,K=dt,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=m[2],K=A[2],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[2]=et=ie&65535|ae<<16,A[2]=dt=se&65535|re<<16,Q=Ye,K=Yt,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=m[3],K=A[3],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[3]=Ye=ie&65535|ae<<16,A[3]=Yt=se&65535|re<<16,Q=S,K=It,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=m[4],K=A[4],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[4]=S=ie&65535|ae<<16,A[4]=It=se&65535|re<<16,Q=nt,K=Wt,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=m[5],K=A[5],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[5]=nt=ie&65535|ae<<16,A[5]=Wt=se&65535|re<<16,Q=mt,K=qt,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=m[6],K=A[6],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[6]=mt=ie&65535|ae<<16,A[6]=qt=se&65535|re<<16,Q=_t,K=Qt,se=K&65535,re=K>>>16,ie=Q&65535,ae=Q>>>16,Q=m[7],K=A[7],se+=K&65535,re+=K>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[7]=_t=ie&65535|ae<<16,A[7]=Qt=se&65535|re<<16,or+=128,f-=128}return f}c(te,"crypto_hashblocks_hl");function fe(m,A,y){var f=new Int32Array(8),x=new Int32Array(8),N=new Uint8Array(256),z,ne=y;for(f[0]=1779033703,f[1]=3144134277,f[2]=1013904242,f[3]=2773480762,f[4]=1359893119,f[5]=2600822924,f[6]=528734635,f[7]=1541459225,x[0]=4089235720,x[1]=2227873595,x[2]=4271175723,x[3]=1595750129,x[4]=2917565137,x[5]=725511199,x[6]=4215389547,x[7]=327033209,te(f,x,A,y),y%=128,z=0;z<y;z++)N[z]=A[ne-y+z];for(N[y]=128,y=256-128*(y<112?1:0),N[y-9]=0,h(N,y-8,ne/536870912|0,ne<<3),te(f,x,N,y),z=0;z<8;z++)h(m,8*z,f[z],x[z]);return 0}c(fe,"crypto_hash");function ve(m,A){var y=e(),f=e(),x=e(),N=e(),z=e(),ne=e(),ce=e(),ye=e(),pe=e();me(y,m[1],m[0]),me(pe,A[1],A[0]),he(y,y,pe),ue(f,m[0],m[1]),ue(pe,A[0],A[1]),he(f,f,pe),he(x,m[3],A[3]),he(x,x,l),he(N,m[2],A[2]),ue(N,N,N),me(z,f,y),me(ne,N,x),ue(ce,N,x),ue(ye,f,y),he(m[0],z,ne),he(m[1],ye,ce),he(m[2],ce,ne),he(m[3],z,ye)}c(ve,"add");function De(m,A,y){var f;for(f=0;f<4;f++)ee(m[f],A[f],y)}c(De,"cswap");function ut(m,A){var y=e(),f=e(),x=e();Ct(x,A[2]),he(y,A[0],x),he(f,A[1],x),C(m,f),m[31]^=q(y)<<7}c(ut,"pack");function Jt(m,A,y){var f,x;for(B(m[0],o),B(m[1],s),B(m[2],s),B(m[3],o),x=255;x>=0;--x)f=y[x/8|0]>>(x&7)&1,De(m,A,f),ve(A,m),ve(m,m),De(m,A,f)}c(Jt,"scalarmult");function Yr(m,A){var y=[e(),e(),e(),e()];B(y[0],d),B(y[1],p),B(y[2],s),he(y[3],d,p),Jt(m,y,A)}c(Yr,"scalarbase");function kr(m,A,y){var f=new Uint8Array(64),x=[e(),e(),e(),e()],N;for(y||r(A,32),fe(f,A,32),f[0]&=248,f[31]&=127,f[31]|=64,Yr(x,f),ut(m,x),N=0;N<32;N++)A[N+32]=m[N];return 0}c(kr,"crypto_sign_keypair");var xi=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 xt(m,A){var y,f,x,N;for(f=63;f>=32;--f){for(y=0,x=f-32,N=f-12;x<N;++x)A[x]+=y-16*A[f]*xi[x-(f-32)],y=A[x]+128>>8,A[x]-=y*256;A[x]+=y,A[f]=0}for(y=0,x=0;x<32;x++)A[x]+=y-(A[31]>>4)*xi[x],y=A[x]>>8,A[x]&=255;for(x=0;x<32;x++)A[x]-=y*xi[x];for(f=0;f<32;f++)A[f+1]+=A[f]>>8,m[f]=A[f]&255}c(xt,"modL");function sr(m){var A=new Float64Array(64),y;for(y=0;y<64;y++)A[y]=m[y];for(y=0;y<64;y++)m[y]=0;xt(m,A)}c(sr,"reduce");function ir(m,A,y,f){var x=new Uint8Array(64),N=new Uint8Array(64),z=new Uint8Array(64),ne,ce,ye=new Float64Array(64),pe=[e(),e(),e(),e()];fe(x,f,32),x[0]&=248,x[31]&=127,x[31]|=64;var gt=y+64;for(ne=0;ne<y;ne++)m[64+ne]=A[ne];for(ne=0;ne<32;ne++)m[32+ne]=x[32+ne];for(fe(z,m.subarray(32),y+32),sr(z),Yr(pe,z),ut(m,pe),ne=32;ne<64;ne++)m[ne]=f[ne];for(fe(N,m,y+64),sr(N),ne=0;ne<64;ne++)ye[ne]=0;for(ne=0;ne<32;ne++)ye[ne]=z[ne];for(ne=0;ne<32;ne++)for(ce=0;ce<32;ce++)ye[ne+ce]+=N[ne]*x[ce];return xt(m.subarray(32),ye),gt}c(ir,"crypto_sign");function Ht(m,A){var y=e(),f=e(),x=e(),N=e(),z=e(),ne=e(),ce=e();return B(m[2],s),J(m[1],A),bt(x,m[1]),he(N,x,u),me(x,x,m[2]),ue(N,m[2],N),bt(z,N),bt(ne,z),he(ce,ne,z),he(y,ce,x),he(y,y,N),Xt(y,y),he(y,y,x),he(y,y,N),he(y,y,N),he(m[0],y,N),bt(f,m[0]),he(f,f,N),W(f,x)&&he(m[0],m[0],g),bt(f,m[0]),he(f,f,N),W(f,x)?-1:(q(m[0])===A[31]>>7&&me(m[0],o,m[0]),he(m[3],m[0],m[1]),0)}c(Ht,"unpackneg");function Pt(m,A,y,f){var x,N,z=new Uint8Array(32),ne=new Uint8Array(64),ce=[e(),e(),e(),e()],ye=[e(),e(),e(),e()];if(N=-1,y<64||Ht(ye,f))return-1;for(x=0;x<y;x++)m[x]=A[x];for(x=0;x<32;x++)m[x+32]=f[x];if(fe(ne,m,y),sr(ne),Jt(ce,ye,ne),Yr(ye,A.subarray(32)),ve(ce,ye),ut(z,ce),y-=64,b(A,0,z,0)){for(x=0;x<y;x++)m[x]=0;return-1}for(x=0;x<y;x++)m[x]=A[x+64];return N=y,N}c(Pt,"crypto_sign_open");var Br=32,jt=24,Xn=32,Ii=16,mo=32,Bs=32,_o=32,yo=32,Tc=32,ad=jt,DA=Xn,BA=Ii,un=64,Jn=32,vi=64,kc=32,Cc=64;t.lowlevel={crypto_core_hsalsa20:$,crypto_stream_xor:k,crypto_stream:P,crypto_stream_salsa20_xor:Z,crypto_stream_salsa20:Y,crypto_onetimeauth:L,crypto_onetimeauth_verify:T,crypto_verify_16:E,crypto_verify_32:b,crypto_secretbox:F,crypto_secretbox_open:j,crypto_scalarmult:yr,crypto_scalarmult_base:Dr,crypto_box_beforenm:Ai,crypto_box_afternm:ho,crypto_box:go,crypto_box_open:Ei,crypto_box_keypair:vr,crypto_hash:fe,crypto_sign:ir,crypto_sign_keypair:kr,crypto_sign_open:Pt,crypto_secretbox_KEYBYTES:Br,crypto_secretbox_NONCEBYTES:jt,crypto_secretbox_ZEROBYTES:Xn,crypto_secretbox_BOXZEROBYTES:Ii,crypto_scalarmult_BYTES:mo,crypto_scalarmult_SCALARBYTES:Bs,crypto_box_PUBLICKEYBYTES:_o,crypto_box_SECRETKEYBYTES:yo,crypto_box_BEFORENMBYTES:Tc,crypto_box_NONCEBYTES:ad,crypto_box_ZEROBYTES:DA,crypto_box_BOXZEROBYTES:BA,crypto_sign_BYTES:un,crypto_sign_PUBLICKEYBYTES:Jn,crypto_sign_SECRETKEYBYTES:vi,crypto_sign_SEEDBYTES:kc,crypto_hash_BYTES:Cc};function cd(m,A){if(m.length!==Br)throw new Error("bad key size");if(A.length!==jt)throw new Error("bad nonce size")}c(cd,"checkLengths");function UA(m,A){if(m.length!==_o)throw new Error("bad public key size");if(A.length!==yo)throw new Error("bad secret key size")}c(UA,"checkBoxLengths");function Cr(){var m,A;for(A=0;A<arguments.length;A++)if((m=Object.prototype.toString.call(arguments[A]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+m+", use Uint8Array")}c(Cr,"checkArrayTypes");function ud(m){for(var A=0;A<m.length;A++)m[A]=0}c(ud,"cleanup"),t.util||(t.util={},t.util.decodeUTF8=t.util.encodeUTF8=t.util.encodeBase64=t.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),t.randomBytes=function(m){var A=new Uint8Array(m);return r(A,m),A},t.secretbox=function(m,A,y){Cr(m,A,y),cd(y,A);for(var f=new Uint8Array(Xn+m.length),x=new Uint8Array(f.length),N=0;N<m.length;N++)f[N+Xn]=m[N];return F(x,f,f.length,A,y),x.subarray(Ii)},t.secretbox.open=function(m,A,y){Cr(m,A,y),cd(y,A);for(var f=new Uint8Array(Ii+m.length),x=new Uint8Array(f.length),N=0;N<m.length;N++)f[N+Ii]=m[N];return f.length<32||j(x,f,f.length,A,y)!==0?!1:x.subarray(Xn)},t.secretbox.keyLength=Br,t.secretbox.nonceLength=jt,t.secretbox.overheadLength=Ii,t.scalarMult=function(m,A){if(Cr(m,A),m.length!==Bs)throw new Error("bad n size");if(A.length!==mo)throw new Error("bad p size");var y=new Uint8Array(mo);return yr(y,m,A),y},t.scalarMult.base=function(m){if(Cr(m),m.length!==Bs)throw new Error("bad n size");var A=new Uint8Array(mo);return Dr(A,m),A},t.scalarMult.scalarLength=Bs,t.scalarMult.groupElementLength=mo,t.box=function(m,A,y,f){var x=t.box.before(y,f);return t.secretbox(m,A,x)},t.box.before=function(m,A){Cr(m,A),UA(m,A);var y=new Uint8Array(Tc);return Ai(y,m,A),y},t.box.after=t.secretbox,t.box.open=function(m,A,y,f){var x=t.box.before(y,f);return t.secretbox.open(m,A,x)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var m=new Uint8Array(_o),A=new Uint8Array(yo);return vr(m,A),{publicKey:m,secretKey:A}},t.box.keyPair.fromSecretKey=function(m){if(Cr(m),m.length!==yo)throw new Error("bad secret key size");var A=new Uint8Array(_o);return Dr(A,m),{publicKey:A,secretKey:new Uint8Array(m)}},t.box.publicKeyLength=_o,t.box.secretKeyLength=yo,t.box.sharedKeyLength=Tc,t.box.nonceLength=ad,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(m,A){if(Cr(m,A),A.length!==vi)throw new Error("bad secret key size");var y=new Uint8Array(un+m.length);return ir(y,m,m.length,A),y},t.sign.open=function(m,A){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(Cr(m,A),A.length!==Jn)throw new Error("bad public key size");var y=new Uint8Array(m.length),f=Pt(y,m,m.length,A);if(f<0)return null;for(var x=new Uint8Array(f),N=0;N<x.length;N++)x[N]=y[N];return x},t.sign.detached=function(m,A){for(var y=t.sign(m,A),f=new Uint8Array(un),x=0;x<f.length;x++)f[x]=y[x];return f},t.sign.detached.verify=function(m,A,y){if(Cr(m,A,y),A.length!==un)throw new Error("bad signature size");if(y.length!==Jn)throw new Error("bad public key size");var f=new Uint8Array(un+m.length),x=new Uint8Array(un+m.length),N;for(N=0;N<un;N++)f[N]=A[N];for(N=0;N<m.length;N++)f[N+un]=m[N];return Pt(x,f,f.length,y)>=0},t.sign.keyPair=function(){var m=new Uint8Array(Jn),A=new Uint8Array(vi);return kr(m,A),{publicKey:m,secretKey:A}},t.sign.keyPair.fromSecretKey=function(m){if(Cr(m),m.length!==vi)throw new Error("bad secret key size");for(var A=new Uint8Array(Jn),y=0;y<A.length;y++)A[y]=m[32+y];return{publicKey:A,secretKey:new Uint8Array(m)}},t.sign.keyPair.fromSeed=function(m){if(Cr(m),m.length!==kc)throw new Error("bad seed size");for(var A=new Uint8Array(Jn),y=new Uint8Array(vi),f=0;f<32;f++)y[f]=m[f];return kr(A,y,!0),{publicKey:A,secretKey:y}},t.sign.publicKeyLength=Jn,t.sign.secretKeyLength=vi,t.sign.seedLength=kc,t.sign.signatureLength=un,t.hash=function(m){Cr(m);var A=new Uint8Array(Cc);return fe(A,m,m.length),A},t.hash.hashLength=Cc,t.verify=function(m,A){return Cr(m,A),m.length===0||A.length===0||m.length!==A.length?!1:_(m,0,A,0,m.length)===0},t.setPRNG=function(m){r=m},(function(){var m=typeof self<"u"?self.crypto||self.msCrypto:null;if(m&&m.getRandomValues){var A=65536;t.setPRNG(function(y,f){var x,N=new Uint8Array(f);for(x=0;x<f;x+=A)m.getRandomValues(N.subarray(x,x+Math.min(f-x,A)));for(x=0;x<f;x++)y[x]=N[x];ud(N)})}else typeof require<"u"&&(m=require("crypto"),m&&m.randomBytes&&t.setPRNG(function(y,f){var x,N=m.randomBytes(f);for(x=0;x<f;x++)y[x]=N[x];ud(N)}))})()})(typeof xa<"u"&&xa.exports?xa.exports:self.nacl=self.nacl||{})});var Lu=le((w3,sg)=>{"use strict";var Du=og().lowlevel.crypto_hash,_n=0,si=c(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])},"Blowfish");function va(t,e,r){return(t[0][e[r+3]]+t[1][e[r+2]]^t[2][e[r+1]])+t[3][e[r]]}c(va,"F");si.prototype.encipher=function(t,e){e===void 0&&(e=new Uint8Array(t.buffer),t.byteOffset!==0&&(e=e.subarray(t.byteOffset))),t[0]^=this.P[0];for(var r=1;r<16;r+=2)t[1]^=va(this.S,e,0)^this.P[r],t[0]^=va(this.S,e,4)^this.P[r+1];var n=t[0];t[0]=t[1]^this.P[17],t[1]=n};si.prototype.decipher=function(t){var e=new Uint8Array(t.buffer);t.byteOffset!==0&&(e=e.subarray(t.byteOffset)),t[0]^=this.P[17];for(var r=16;r>0;r-=2)t[1]^=va(this.S,e,0)^this.P[r],t[0]^=va(this.S,e,4)^this.P[r-1];var n=t[0];t[0]=t[1]^this.P[0],t[1]=n};function oi(t,e){var r,n=0;for(r=0;r<4;r++,_n++)_n>=e&&(_n=0),n=n<<8|t[_n];return n}c(oi,"stream2word");si.prototype.expand0state=function(t,e){var r=new Uint32Array(2),n,i,o=new Uint8Array(r.buffer);for(n=0,_n=0;n<18;n++)this.P[n]^=oi(t,e);for(_n=0,n=0;n<18;n+=2)this.encipher(r,o),this.P[n]=r[0],this.P[n+1]=r[1];for(n=0;n<4;n++)for(i=0;i<256;i+=2)this.encipher(r,o),this.S[n][i]=r[0],this.S[n][i+1]=r[1]};si.prototype.expandstate=function(t,e,r,n){var i=new Uint32Array(2),o,s;for(o=0,_n=0;o<18;o++)this.P[o]^=oi(r,n);for(o=0,_n=0;o<18;o+=2)i[0]^=oi(t,e),i[1]^=oi(t,e),this.encipher(i),this.P[o]=i[0],this.P[o+1]=i[1];for(o=0;o<4;o++)for(s=0;s<256;s+=2)i[0]^=oi(t,e),i[1]^=oi(t,e),this.encipher(i),this.S[o][s]=i[0],this.S[o][s+1]=i[1];_n=0};si.prototype.enc=function(t,e){for(var r=0;r<e;r++)this.encipher(t.subarray(r*2))};si.prototype.dec=function(t,e){for(var r=0;r<e;r++)this.decipher(t.subarray(r*2))};var Ia=8,Bu=32;function Uu(t,e,r){var n=new si,i=new Uint32Array(Ia),o,s=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(n.expandstate(e,64,t,64),o=0;o<64;o++)n.expand0state(e,64),n.expand0state(t,64);for(o=0;o<Ia;o++)i[o]=oi(s,s.byteLength);for(o=0;o<64;o++)n.enc(i,i.byteLength/8);for(o=0;o<Ia;o++)r[4*o+3]=i[o]>>>24,r[4*o+2]=i[o]>>>16,r[4*o+1]=i[o]>>>8,r[4*o+0]=i[o]}c(Uu,"bcrypt_hash");function _x(t,e,r,n,i,o,s){var a=new Uint8Array(64),u=new Uint8Array(64),l=new Uint8Array(Bu),d=new Uint8Array(Bu),p=new Uint8Array(n+4),g,h,_,E,b,I,w=o;if(s<1||e===0||n===0||o===0||o>l.byteLength*l.byteLength||n>1<<20)return-1;for(E=Math.floor((o+l.byteLength-1)/l.byteLength),_=Math.floor((o+E-1)/E),g=0;g<n;g++)p[g]=r[g];for(Du(a,t,e),I=1;o>0;I++){for(p[n+0]=I>>>24,p[n+1]=I>>>16,p[n+2]=I>>>8,p[n+3]=I,Du(u,p,n+4),Uu(a,u,d),g=l.byteLength;g--;)l[g]=d[g];for(g=1;g<s;g++)for(Du(u,d,d.byteLength),Uu(a,u,d),h=0;h<l.byteLength;h++)l[h]^=d[h];for(_=Math.min(_,o),g=0;g<_&&(b=g*E+(I-1),!(b>=w));g++)i[b]=l[g];o-=g}return 0}c(_x,"bcrypt_pbkdf");sg.exports={BLOCKS:Ia,HASHSIZE:Bu,hash:Uu,pbkdf:_x}});var An=le((T3,wa)=>{"use strict";var yn=require("crypto"),Qi;try{Qi=require("cpu-features")()}catch{}var{bindingAvailable:ag,CIPHER_INFO:yx,MAC_INFO:Ax}=Ln(),cg=(()=>{if(typeof yn.sign=="function"&&typeof yn.verify=="function"){let t=`-----BEGIN PRIVATE KEY-----\r
5
+ Closing reason: ${this._closingError.stack}`,o.code=this._closingError.code!==void 0?this._closingError.code:"0",this._passToHandler(o);return}this.socket.setTimeout(this.timeout),e&&this.send(e)})}log(e){this.verbose&&console.log(e)}get hasTLS(){return"encrypted"in this._socket}_stopTrackingTask(){this.socket.setTimeout(0),this._task=void 0}_onControlSocketData(e){if(this.log(`< ${e}`),this._partialResponse.length+e.length>Cb){this.closeWithError(new Error("FTP control response exceeded maximum allowed size"));return}let r=this._partialResponse+e,n=(0,kb.parseControlResponse)(r);this._partialResponse=n.rest;for(let i of n.messages){let o=parseInt(i.substr(0,3),10),s={code:o,message:i},a=o>=400?new sa(s):void 0;this._passToHandler(a||s)}}_passToHandler(e){this._task&&this._task.responseHandler(e,this._task.resolver)}_setupDefaultErrorHandlers(e,r){e.once("error",n=>{n.message+=` (${r})`,this.closeWithError(n)}),e.once("close",n=>{n&&this.closeWithError(new Error(`Socket closed due to transmission error (${r})`))}),e.once("timeout",()=>{e.destroy(),this.closeWithError(new Error(`Timeout (${r})`))})}_closeControlSocket(){this._removeSocketListeners(this._socket),this._socket.on("error",Nh),this.send("QUIT"),this._closeSocket(this._socket)}_closeSocket(e){e&&(this._removeSocketListeners(e),e.on("error",Nh),e.destroy())}_removeSocketListeners(e){e.removeAllListeners(),e.removeAllListeners("timeout"),e.removeAllListeners("data"),e.removeAllListeners("end"),e.removeAllListeners("error"),e.removeAllListeners("close"),e.removeAllListeners("connect")}_newSocket(){return new Tb.Socket}};$i.FTPContext=mu});var yu=le(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.describeTLS=Rb;Di.describeAddress=Nb;Di.upgradeSocket=Ob;Di.ipIsPrivateV4Address=$b;var Oh=require("tls");function Rb(t){if(t instanceof Oh.TLSSocket){let e=t.getProtocol();return e||"Server socket or disconnected client socket"}return"No encryption"}c(Rb,"describeTLS");function Nb(t){return t.remoteFamily==="IPv6"?`[${t.remoteAddress}]:${t.remotePort}`:`${t.remoteAddress}:${t.remotePort}`}c(Nb,"describeAddress");function Ob(t,e){return new Promise((r,n)=>{let i=Object.assign({},e,{socket:t}),o=(0,Oh.connect)(i,()=>{i.rejectUnauthorized!==!1&&!o.authorized?n(o.authorizationError):(o.removeAllListeners("error"),r(o))}).once("error",s=>{n(s)})})}c(Ob,"upgradeSocket");function $b(t=""){t.startsWith("::ffff:")&&(t=t.substr(7));let e=t.split(".").map(r=>parseInt(r,10));return e[0]===10||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||t==="127.0.0.1"}c($b,"ipIsPrivateV4Address")});var Fo=le(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.FileInfo=Ui.FileType=void 0;var Bi;(function(t){t[t.Unknown=0]="Unknown",t[t.File=1]="File",t[t.Directory=2]="Directory",t[t.SymbolicLink=3]="SymbolicLink"})(Bi||(Ui.FileType=Bi={}));var aa=class{static{c(this,"FileInfo")}constructor(e){this.name=e,this.type=Bi.Unknown,this.size=0,this.rawModifiedAt="",this.modifiedAt=void 0,this.permissions=void 0,this.hardLinkCount=void 0,this.link=void 0,this.group=void 0,this.user=void 0,this.uniqueID=void 0,this.name=e}get isDirectory(){return this.type===Bi.Directory}get isSymbolicLink(){return this.type===Bi.SymbolicLink}get isFile(){return this.type===Bi.File}get date(){return this.rawModifiedAt}set date(e){this.rawModifiedAt=e}};Ui.FileInfo=aa;aa.UnixPermission={Read:4,Write:2,Execute:1}});var Dh=le(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});Ho.testLine=Db;Ho.parseLine=Bb;Ho.transformList=Ub;var Eu=Fo(),$h=new RegExp("(\\S+)\\s+(\\S+)\\s+(?:(<DIR>)|([0-9]+))\\s+(\\S.*)");function Db(t){return/^\d{2}/.test(t)&&$h.test(t)}c(Db,"testLine");function Bb(t){let e=t.match($h);if(e===null)return;let r=e[5];if(r==="."||r==="..")return;let n=new Eu.FileInfo(r);return e[3]==="<DIR>"?(n.type=Eu.FileType.Directory,n.size=0):(n.type=Eu.FileType.File,n.size=parseInt(e[4],10)),n.rawModifiedAt=e[1]+" "+e[2],n}c(Bb,"parseLine");function Ub(t){return t}c(Ub,"transformList")});var Uh=le(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.testLine=Fb;jo.parseLine=Hb;jo.transformList=jb;var tn=Fo(),Lb="\u6708",zb="\u65E5",Mb="\u5E74",Bh=new RegExp("([bcdelfmpSs-])(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]?)))\\+?\\s*(\\d+)\\s+(?:(\\S+(?:\\s\\S+)*?)\\s+)?(?:(\\S+(?:\\s\\S+)*)\\s+)?(\\d+(?:,\\s*\\d+)?)\\s+((?:\\d+[-/]\\d+[-/]\\d+)|(?:\\S{3}\\s+\\d{1,2})|(?:\\d{1,2}\\s+\\S{3})|(?:\\d{1,2}"+Lb+"\\s+\\d{1,2}"+zb+"))\\s+((?:\\d+(?::\\d+)?)|(?:\\d{4}"+Mb+"))\\s(.*)");function Fb(t){return Bh.test(t)}c(Fb,"testLine");function Hb(t){let e=t.match(Bh);if(e===null)return;let r=e[21];if(r==="."||r==="..")return;let n=new tn.FileInfo(r);switch(n.size=parseInt(e[18],10),n.user=e[16],n.group=e[17],n.hardLinkCount=parseInt(e[15],10),n.rawModifiedAt=e[19]+" "+e[20],n.permissions={user:Au(e[4],e[5],e[6]),group:Au(e[8],e[9],e[10]),world:Au(e[12],e[13],e[14])},e[1].charAt(0)){case"d":n.type=tn.FileType.Directory;break;case"e":n.type=tn.FileType.SymbolicLink;break;case"l":n.type=tn.FileType.SymbolicLink;break;case"b":case"c":n.type=tn.FileType.File;break;case"f":case"-":n.type=tn.FileType.File;break;default:n.type=tn.FileType.Unknown}if(n.isSymbolicLink){let i=r.indexOf(" -> ");i!==-1&&(n.name=r.substring(0,i),n.link=r.substring(i+4))}return n}c(Hb,"parseLine");function jb(t){return t}c(jb,"transformList");function Au(t,e,r){let n=0;t!=="-"&&(n+=tn.FileInfo.UnixPermission.Read),e!=="-"&&(n+=tn.FileInfo.UnixPermission.Write);let i=r.charAt(0);return i!=="-"&&i.toUpperCase()!==i&&(n+=tn.FileInfo.UnixPermission.Execute),n}c(Au,"parseMode")});var bu=le(zi=>{"use strict";Object.defineProperty(zi,"__esModule",{value:!0});zi.testLine=qb;zi.parseLine=Qb;zi.transformList=Vb;zi.parseMLSxDate=Mh;var Li=Fo();function Lh(t,e){e.size=parseInt(t,10)}c(Lh,"parseSize");var Wb={size:Lh,sizd:Lh,unique:c((t,e)=>{e.uniqueID=t},"unique"),modify:c((t,e)=>{e.modifiedAt=Mh(t),e.rawModifiedAt=e.modifiedAt.toISOString()},"modify"),type:c((t,e)=>{if(t.startsWith("OS.unix=slink"))return e.type=Li.FileType.SymbolicLink,e.link=t.substr(t.indexOf(":")+1),1;switch(t){case"file":e.type=Li.FileType.File;break;case"dir":e.type=Li.FileType.Directory;break;case"OS.unix=symlink":e.type=Li.FileType.SymbolicLink;break;case"cdir":case"pdir":return 2;default:e.type=Li.FileType.Unknown}return 1},"type"),"unix.mode":c((t,e)=>{let r=t.substr(-3);e.permissions={user:parseInt(r[0],10),group:parseInt(r[1],10),world:parseInt(r[2],10)}},"unix.mode"),"unix.ownername":c((t,e)=>{e.user=t},"unix.ownername"),"unix.owner":c((t,e)=>{e.user===void 0&&(e.user=t)},"unix.owner"),get"unix.uid"(){return this["unix.owner"]},"unix.groupname":c((t,e)=>{e.group=t},"unix.groupname"),"unix.group":c((t,e)=>{e.group===void 0&&(e.group=t)},"unix.group"),get"unix.gid"(){return this["unix.group"]}};function zh(t,e){let r=t.indexOf(e),n=t.substr(0,r),i=t.substr(r+e.length);return[n,i]}c(zh,"splitStringOnce");function qb(t){return/^\S+=\S+;/.test(t)||t.startsWith(" ")}c(qb,"testLine");function Qb(t){let[e,r]=zh(t," ");if(r===""||r==="."||r==="..")return;let n=new Li.FileInfo(r),i=e.split(";");for(let o of i){let[s,a]=zh(o,"=");if(!a)continue;let u=Wb[s.toLowerCase()];if(!u)continue;if(u(a,n)===2)return}return n}c(Qb,"parseLine");function Vb(t){let e=new Map;for(let n of t)!n.isSymbolicLink&&n.uniqueID!==void 0&&e.set(n.uniqueID,n);let r=[];for(let n of t){if(n.isSymbolicLink&&n.uniqueID!==void 0&&n.link===void 0){let o=e.get(n.uniqueID);o!==void 0&&(n.link=o.name)}!n.name.includes("/")&&r.push(n)}return r}c(Vb,"transformList");function Mh(t){return new Date(Date.UTC(+t.slice(0,4),+t.slice(4,6)-1,+t.slice(6,8),+t.slice(8,10),+t.slice(10,12),+t.slice(12,14),+t.slice(15,18)))}c(Mh,"parseMLSxDate")});var Iu=le(_n=>{"use strict";var Kb=_n&&_n.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:c(function(){return e[r]},"get")}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Gb=_n&&_n.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),xu=_n&&_n.__importStar||(function(){var t=c(function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[n.length]=i);return n},t(e)},"ownKeys");return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),i=0;i<n.length;i++)n[i]!=="default"&&Kb(r,e,n[i]);return Gb(r,e),r}})();Object.defineProperty(_n,"__esModule",{value:!0});_n.parseList=ix;var Zb=xu(Dh()),Yb=xu(Uh()),Xb=xu(bu()),Jb=[Zb,Yb,Xb];function ex(t,e){return e.find(r=>r.testLine(t)===!0)}c(ex,"firstCompatibleParser");function tx(t){return t.trim()!==""}c(tx,"isNotBlank");function rx(t){return!t.startsWith("total")}c(rx,"isNotMeta");var nx=/\r?\n/;function ix(t){let e=t.split(nx).filter(tx).filter(rx);if(e.length===0)return[];let r=e[e.length-1],n=ex(r,Jb);if(!n)throw new Error("This library only supports MLSD, Unix- or DOS-style directory listing. Your FTP server seems to be using another format. You can see the transmitted listing when setting `client.ftp.verbose = true`. You can then provide a custom parser to `client.parseList`, see the documentation for details.");let i=e.map(n.parseLine).filter(o=>o!==void 0);return n.transformList(i)}c(ix,"parseList")});var Fh=le(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.ProgressTracker=void 0;var vu=class{static{c(this,"ProgressTracker")}constructor(){this.bytesOverall=0,this.intervalMs=500,this.onStop=ca,this.onHandle=ca}reportTo(e=ca){this.onHandle=e}start(e,r,n){let i=0;this.onStop=ox(this.intervalMs,()=>{let o=e.bytesRead+e.bytesWritten;this.bytesOverall+=o-i,i=o,this.onHandle({name:r,type:n,bytes:o,bytesOverall:this.bytesOverall})})}stop(){this.onStop(!1)}updateAndStop(){this.onStop(!0)}};ua.ProgressTracker=vu;function ox(t,e){let r=setInterval(e,t),n=c(i=>{clearInterval(r),i&&e(),e=ca},"stopFunc");return e(),n}c(ox,"poll");function ca(){}c(ca,"noop")});var Hh=le(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.StringWriter=void 0;var sx=require("stream"),Su=class extends sx.Writable{static{c(this,"StringWriter")}constructor(e=1*1024*1024){super(),this.maxByteLength=e,this.byteLength=0,this.bufs=[]}_write(e,r,n){if(!(e instanceof Buffer)){n(new Error("StringWriter: expects chunks of type 'Buffer'."));return}if(this.byteLength+e.byteLength>this.maxByteLength){n(new Error(`StringWriter: Maximum bytes exceeded, maxByteLength=${this.maxByteLength}.`));return}this.byteLength+=e.byteLength,this.bufs.push(e),n(null)}getText(e){return Buffer.concat(this.bufs).toString(e)}};la.StringWriter=Su});var Pu=le(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.enterPassiveModeIPv6=ax;rn.parseEpsvResponse=qh;rn.enterPassiveModeIPv4=cx;rn.enterPassiveModeIPv4_forceControlHostIP=ux;rn.parsePasvResponse=wu;rn.connectForPassiveTransfer=pa;rn.uploadFrom=lx;rn.downloadTo=fx;var Mi=yu(),Wh=require("stream"),jh=require("tls"),fa=oa();async function ax(t){let e=await t.request("EPSV"),r=qh(e.message);if(!r)throw new Error("Can't parse EPSV response: "+e.message);let n=t.socket.remoteAddress;if(n===void 0)throw new Error("Control socket is disconnected, can't get remote address.");return await pa(n,r,t),e}c(ax,"enterPassiveModeIPv6");function qh(t){let e=t.match(/[|!]{3}(.+)[|!]/);if(e===null||e[1]===void 0)throw new Error(`Can't parse response to 'EPSV': ${t}`);let r=parseInt(e[1],10);if(Number.isNaN(r))throw new Error(`Can't parse response to 'EPSV', port is not a number: ${t}`);return r}c(qh,"parseEpsvResponse");async function cx(t){let e=await t.request("PASV"),r=wu(e.message);if(!r)throw new Error("Can't parse PASV response: "+e.message);let n=t.socket.remoteAddress;return(0,Mi.ipIsPrivateV4Address)(r.host)&&n&&!(0,Mi.ipIsPrivateV4Address)(n)&&(r.host=n),await pa(r.host,r.port,t),e}c(cx,"enterPassiveModeIPv4");async function ux(t){let e=await t.request("PASV"),r=wu(e.message);if(!r)throw new Error("Can't parse PASV response: "+e.message);let n=t.socket.remoteAddress;if(n===void 0)throw new Error("Control socket is disconnected, can't get remote address.");return await pa(n,r.port,t),e}c(ux,"enterPassiveModeIPv4_forceControlHostIP");function wu(t){let e=t.match(/([-\d]+,[-\d]+,[-\d]+,[-\d]+),([-\d]+),([-\d]+)/);if(e===null||e.length!==4)throw new Error(`Can't parse response to 'PASV': ${t}`);return{host:e[1].replace(/,/g,"."),port:(parseInt(e[2],10)&255)*256+(parseInt(e[3],10)&255)}}c(wu,"parsePasvResponse");function pa(t,e,r){return new Promise((n,i)=>{let o=r._newSocket(),s=c(function(u){u.message="Can't open data connection in passive mode: "+u.message,i(u)},"handleConnErr"),a=c(function(){o.destroy(),i(new Error(`Timeout when trying to open data connection to ${t}:${e}`))},"handleTimeout");o.setTimeout(r.timeout),o.on("error",s),o.on("timeout",a),o.connect({port:e,host:t,family:r.ipFamily},()=>{r.socket instanceof jh.TLSSocket&&(o=(0,jh.connect)(Object.assign({},r.tlsOptions,{socket:o,session:r.socket.getSession()}))),o.removeListener("error",s),o.removeListener("timeout",a),r.dataSocket=o,n()})})}c(pa,"connectForPassiveTransfer");var da=class{static{c(this,"TransferResolver")}constructor(e,r){this.ftp=e,this.progress=r,this.response=void 0,this.dataTransferDone=!1}onDataStart(e,r){if(this.ftp.dataSocket===void 0)throw new Error("Data transfer should start but there is no data connection.");this.ftp.socket.setTimeout(0),this.ftp.dataSocket.setTimeout(this.ftp.timeout),this.progress.start(this.ftp.dataSocket,e,r)}onDataDone(e){this.progress.updateAndStop(),this.ftp.socket.setTimeout(this.ftp.timeout),this.ftp.dataSocket&&this.ftp.dataSocket.setTimeout(0),this.dataTransferDone=!0,this.tryResolve(e)}onControlDone(e,r){this.response=r,this.tryResolve(e)}onError(e,r){this.progress.updateAndStop(),this.ftp.socket.setTimeout(this.ftp.timeout),this.ftp.dataSocket=void 0,e.reject(r)}onUnexpectedRequest(e){let r=new Error(`Unexpected FTP response is requesting an answer: ${e.message}`);this.ftp.closeWithError(r)}tryResolve(e){this.dataTransferDone&&this.response!==void 0&&(this.ftp.dataSocket=void 0,e.resolve(this.response))}};function lx(t,e){let r=new da(e.ftp,e.tracker),n=`${e.command} ${e.remotePath}`;return e.ftp.handle(n,(i,o)=>{if(i instanceof Error)r.onError(o,i);else if(i.code===150||i.code===125){let s=e.ftp.dataSocket;if(!s){r.onError(o,new Error("Upload should begin but no data connection is available."));return}let a="getCipher"in s?s.getCipher()!==void 0:!0;dx(a,s,"secureConnect",()=>{e.ftp.log(`Uploading to ${(0,Mi.describeAddress)(s)} (${(0,Mi.describeTLS)(s)})`),r.onDataStart(e.remotePath,e.type),(0,Wh.pipeline)(t,s,u=>{u?r.onError(o,u):r.onDataDone(o)})})}else(0,fa.positiveCompletion)(i.code)?r.onControlDone(o,i):(0,fa.positiveIntermediate)(i.code)&&r.onUnexpectedRequest(i)})}c(lx,"uploadFrom");function fx(t,e){if(!e.ftp.dataSocket)throw new Error("Download will be initiated but no data connection is available.");let r=new da(e.ftp,e.tracker);return e.ftp.handle(e.command,(n,i)=>{if(n instanceof Error)r.onError(i,n);else if(n.code===150||n.code===125){let o=e.ftp.dataSocket;if(!o){r.onError(i,new Error("Download should begin but no data connection is available."));return}e.ftp.log(`Downloading from ${(0,Mi.describeAddress)(o)} (${(0,Mi.describeTLS)(o)})`),r.onDataStart(e.remotePath,e.type),(0,Wh.pipeline)(o,t,s=>{s?r.onError(i,s):r.onDataDone(i)})}else n.code===350?e.ftp.send("RETR "+e.remotePath):(0,fa.positiveCompletion)(n.code)?r.onControlDone(i,n):(0,fa.positiveIntermediate)(n.code)&&r.onUnexpectedRequest(n)})}c(fx,"downloadTo");function dx(t,e,r,n){t===!0?n():e.once(r,()=>n())}c(dx,"onConditionOrEvent")});var Zh=le(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.Client=void 0;var Dn=require("fs"),Tu=require("path"),px=require("tls"),Hi=require("util"),Wo=_u(),oi=yu(),ku=oa(),hx=Iu(),gx=bu(),mx=Fh(),_x=Hh(),Fi=Pu(),yx=(0,Hi.promisify)(Dn.readdir),Ex=(0,Hi.promisify)(Dn.mkdir),Cu=(0,Hi.promisify)(Dn.stat),Qh=(0,Hi.promisify)(Dn.open),Vh=(0,Hi.promisify)(Dn.close),Ax=(0,Hi.promisify)(Dn.unlink),Kh={allowSeparateTransferHost:!0,maxListingBytes:40*1024*1024},Gh=c(()=>["LIST -a","LIST"],"LIST_COMMANDS_DEFAULT"),bx=c(()=>["MLSD","LIST -a","LIST"],"LIST_COMMANDS_MLSD"),Ru=class{static{c(this,"Client")}constructor(e=3e4,r=Kh){this.availableListCommands=Gh();let n={...Kh,...r};this.ftp=new Wo.FTPContext(e),this.prepareTransfer=this._enterFirstCompatibleMode([Fi.enterPassiveModeIPv6,n.allowSeparateTransferHost?Fi.enterPassiveModeIPv4:Fi.enterPassiveModeIPv4_forceControlHostIP]),this.options=n,this.parseList=hx.parseList,this._progressTracker=new mx.ProgressTracker}close(){this.ftp.close(),this._progressTracker.stop()}get closed(){return this.ftp.closed}connect(e="localhost",r=21){return this.ftp.reset(),this.ftp.socket.connect({host:e,port:r,family:this.ftp.ipFamily},()=>this.ftp.log(`Connected to ${(0,oi.describeAddress)(this.ftp.socket)} (${(0,oi.describeTLS)(this.ftp.socket)})`)),this._handleConnectResponse()}connectImplicitTLS(e="localhost",r=21,n={}){return this.ftp.reset(),this.ftp.socket=(0,px.connect)(r,e,n,()=>this.ftp.log(`Connected to ${(0,oi.describeAddress)(this.ftp.socket)} (${(0,oi.describeTLS)(this.ftp.socket)})`)),this.ftp.tlsOptions=n,this._handleConnectResponse()}_handleConnectResponse(){return this.ftp.handle(void 0,(e,r)=>{e instanceof Error?r.reject(e):(0,ku.positiveCompletion)(e.code)?r.resolve(e):r.reject(new Wo.FTPError(e))})}send(e,r=!1){return r?(this.ftp.log("Deprecated call using send(command, flag) with boolean flag to ignore errors. Use sendIgnoringError(command)."),this.sendIgnoringError(e)):this.ftp.request(e)}sendIgnoringError(e){return this.ftp.handle(e,(r,n)=>{r instanceof Wo.FTPError?n.resolve({code:r.code,message:r.message}):r instanceof Error?n.reject(r):n.resolve(r)})}async useTLS(e={},r="AUTH TLS"){let n=await this.send(r);return this.ftp.socket=await(0,oi.upgradeSocket)(this.ftp.socket,e),this.ftp.tlsOptions=e,this.ftp.log(`Control socket is using: ${(0,oi.describeTLS)(this.ftp.socket)}`),n}login(e="anonymous",r="guest"){return this.ftp.log(`Login security: ${(0,oi.describeTLS)(this.ftp.socket)}`),this.ftp.handle("USER "+e,(n,i)=>{n instanceof Error?i.reject(n):(0,ku.positiveCompletion)(n.code)?i.resolve(n):n.code===331?this.ftp.send("PASS "+r):i.reject(new Wo.FTPError(n))})}async useDefaultSettings(){let r=(await this.features()).has("MLST");this.availableListCommands=r?bx():Gh(),await this.send("TYPE I"),await this.sendIgnoringError("STRU F"),await this.sendIgnoringError("OPTS UTF8 ON"),r&&await this.sendIgnoringError("OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;"),this.ftp.hasTLS&&(await this.sendIgnoringError("PBSZ 0"),await this.sendIgnoringError("PROT P"))}async access(e={}){var r,n;let i=e.secure===!0,o=e.secure==="implicit",s;if(o?s=await this.connectImplicitTLS(e.host,e.port,e.secureOptions):s=await this.connect(e.host,e.port),i){let a=(r=e.secureOptions)!==null&&r!==void 0?r:{};a.host=(n=a.host)!==null&&n!==void 0?n:e.host,await this.useTLS(a)}return await this.sendIgnoringError("OPTS UTF8 ON"),await this.login(e.user,e.password),await this.useDefaultSettings(),s}async pwd(){let e=await this.send("PWD"),r=e.message.match(/"(.+)"/);if(r===null||r[1]===void 0)throw new Error(`Can't parse response to command 'PWD': ${e.message}`);return r[1]}async features(){let e=await this.sendIgnoringError("FEAT"),r=new Map;return e.code<400&&(0,ku.isMultiline)(e.message)&&e.message.split(`
6
+ `).slice(1,-1).forEach(n=>{let i=n.trim().split(" ");r.set(i[0],i[1]||"")}),r}async cd(e){let r=await this.protectWhitespace(e);return this.send("CWD "+r)}async cdup(){return this.send("CDUP")}async lastMod(e){let r=await this.protectWhitespace(e),i=(await this.send(`MDTM ${r}`)).message.slice(4);return(0,gx.parseMLSxDate)(i)}async size(e){let n=`SIZE ${await this.protectWhitespace(e)}`,i=await this.send(n),o=parseInt(i.message.slice(4),10);if(Number.isNaN(o))throw new Error(`Can't parse response to command '${n}' as a numerical value: ${i.message}`);return o}async rename(e,r){let n=await this.protectWhitespace(e),i=await this.protectWhitespace(r);return await this.send("RNFR "+n),this.send("RNTO "+i)}async remove(e,r=!1){let n=await this.protectWhitespace(e);return r?this.sendIgnoringError(`DELE ${n}`):this.send(`DELE ${n}`)}trackProgress(e){this._progressTracker.bytesOverall=0,this._progressTracker.reportTo(e)}async uploadFrom(e,r,n={}){return this._uploadWithCommand(e,r,"STOR",n)}async appendFrom(e,r,n={}){return this._uploadWithCommand(e,r,"APPE",n)}async _uploadWithCommand(e,r,n,i){return typeof e=="string"?this._uploadLocalFile(e,r,n,i):this._uploadFromStream(e,r,n)}async _uploadLocalFile(e,r,n,i){let o=await Qh(e,"r"),s=(0,Dn.createReadStream)("",{fd:o,start:i.localStart,end:i.localEndInclusive,autoClose:!1});try{return await this._uploadFromStream(s,r,n)}finally{await qo(()=>Vh(o))}}async _uploadFromStream(e,r,n){let i=c(o=>this.ftp.closeWithError(o),"onError");e.once("error",i);try{let o=await this.protectWhitespace(r);return await this.prepareTransfer(this.ftp),await(0,Fi.uploadFrom)(e,{ftp:this.ftp,tracker:this._progressTracker,command:n,remotePath:o,type:"upload"})}finally{e.removeListener("error",i)}}async downloadTo(e,r,n=0){return typeof e=="string"?this._downloadToFile(e,r,n):this._downloadToStream(e,r,n)}async _downloadToFile(e,r,n){let i=n>0,s=await Qh(e,i?"r+":"w"),a=(0,Dn.createWriteStream)("",{fd:s,start:n,autoClose:!1});try{return await this._downloadToStream(a,r,n)}catch(u){let l=await qo(()=>Cu(e)),d=l&&l.size>0;throw!i&&!d&&await qo(()=>Ax(e)),u}finally{await qo(()=>Vh(s))}}async _downloadToStream(e,r,n){let i=c(o=>this.ftp.closeWithError(o),"onError");e.once("error",i);try{let o=await this.protectWhitespace(r);return await this.prepareTransfer(this.ftp),await(0,Fi.downloadTo)(e,{ftp:this.ftp,tracker:this._progressTracker,command:n>0?`REST ${n}`:`RETR ${o}`,remotePath:o,type:"download"})}finally{e.removeListener("error",i),e.end()}}async list(e=""){let r=await this.protectWhitespace(e),n;for(let i of this.availableListCommands){let o=r===""?i:`${i} ${r}`;await this.prepareTransfer(this.ftp);try{let s=await this._requestListWithCommand(o);return this.availableListCommands=[i],s}catch(s){if(!(s instanceof Wo.FTPError))throw s;n=s}}throw n}async _requestListWithCommand(e){let r=new _x.StringWriter(this.options.maxListingBytes);await(0,Fi.downloadTo)(r,{ftp:this.ftp,tracker:this._progressTracker,command:e,remotePath:"",type:"list"});let n=r.getText(this.ftp.encoding);return this.ftp.log(n),this.parseList(n)}async removeDir(e){return this._exitAtCurrentDirectory(async()=>{await this.cd(e);let r=await this.pwd();await this.clearWorkingDir(),r==="/"||(await this.cdup(),await this.removeEmptyDir(r))})}async clearWorkingDir(){for(let e of await this.list())e.isDirectory?(await this.cd(e.name),await this.clearWorkingDir(),await this.cdup(),await this.removeEmptyDir(e.name)):await this.remove(e.name)}async uploadFromDir(e,r){return this._exitAtCurrentDirectory(async()=>(r&&await this.ensureDir(r),await this._uploadToWorkingDir(e)))}async _uploadToWorkingDir(e){let r=await yx(e);for(let n of r){let i=(0,Tu.join)(e,n),o=await Cu(i);o.isFile()?await this.uploadFrom(i,n):o.isDirectory()&&(await this._openDir(n),await this._uploadToWorkingDir(i),await this.cdup())}}async downloadToDir(e,r){return this._exitAtCurrentDirectory(async()=>(r&&await this.cd(r),await this._downloadFromWorkingDir(e)))}async _downloadFromWorkingDir(e){await xx(e);for(let r of await this.list()){if(!r.name||(0,Tu.basename)(r.name)!==r.name){let o=JSON.stringify(r.name);this.ftp.log(`Invalid filename from server listing, will skip file. (${o})`);continue}let i=(0,Tu.join)(e,r.name);r.isDirectory?(await this.cd(r.name),await this._downloadFromWorkingDir(i),await this.cdup()):r.isFile&&await this.downloadTo(i,r.name)}}async ensureDir(e){e.startsWith("/")&&await this.cd("/");let r=e.split("/").filter(n=>n!=="");for(let n of r)await this._openDir(n)}async _openDir(e){await this.sendIgnoringError("MKD "+e),await this.cd(e)}async removeEmptyDir(e){let r=await this.protectWhitespace(e);return this.send(`RMD ${r}`)}async protectWhitespace(e){if(!e.startsWith(" "))return e;let r=await this.pwd();return(r.endsWith("/")?r:r+"/")+e}async _exitAtCurrentDirectory(e){let r=await this.pwd();try{return await e()}finally{this.closed||await qo(()=>this.cd(r))}}_enterFirstCompatibleMode(e){return async r=>{r.log("Trying to find optimal transfer strategy...");let n;for(let i of e)try{let o=await i(r);return r.log("Optimal transfer strategy found."),this.prepareTransfer=i,o}catch(o){n=o}throw new Error(`None of the available transfer strategies work. Last error response was '${n}'.`)}}async upload(e,r,n={}){return this.ftp.log("Warning: upload() has been deprecated, use uploadFrom()."),this.uploadFrom(e,r,n)}async append(e,r,n={}){return this.ftp.log("Warning: append() has been deprecated, use appendFrom()."),this.appendFrom(e,r,n)}async download(e,r,n=0){return this.ftp.log("Warning: download() has been deprecated, use downloadTo()."),this.downloadTo(e,r,n)}async uploadDir(e,r){return this.ftp.log("Warning: uploadDir() has been deprecated, use uploadFromDir()."),this.uploadFromDir(e,r)}async downloadDir(e){return this.ftp.log("Warning: downloadDir() has been deprecated, use downloadToDir()."),this.downloadToDir(e)}};ha.Client=Ru;async function xx(t){try{await Cu(t)}catch{await Ex(t,{recursive:!0})}}c(xx,"ensureLocalDirectory");async function qo(t){try{return await t()}catch{return}}c(qo,"ignoreError")});var Xh=le(Yh=>{"use strict";Object.defineProperty(Yh,"__esModule",{value:!0})});var nn=le(br=>{"use strict";var Ix=br&&br.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:c(function(){return e[r]},"get")}),Object.defineProperty(t,n,i)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Qo=br&&br.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ix(e,t,r)};Object.defineProperty(br,"__esModule",{value:!0});br.enterPassiveModeIPv6=br.enterPassiveModeIPv4=void 0;Qo(Zh(),br);Qo(_u(),br);Qo(Fo(),br);Qo(Iu(),br);Qo(Xh(),br);var Jh=Pu();Object.defineProperty(br,"enterPassiveModeIPv4",{enumerable:!0,get:c(function(){return Jh.enterPassiveModeIPv4},"get")});Object.defineProperty(br,"enterPassiveModeIPv6",{enumerable:!0,get:c(function(){return Jh.enterPassiveModeIPv6},"get")})});var ga=le((N3,eg)=>{eg.exports={newInvalidAsn1Error:c(function(t){var e=new Error;return e.name="InvalidAsn1Error",e.message=t||"",e},"newInvalidAsn1Error")}});var ma=le(($3,tg)=>{tg.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 Nu=le((D3,rg)=>{"use strict";var _a=require("buffer"),ji=_a.Buffer,Lr={},zr;for(zr in _a)_a.hasOwnProperty(zr)&&(zr==="SlowBuffer"||zr==="Buffer"||(Lr[zr]=_a[zr]));var Wi=Lr.Buffer={};for(zr in ji)ji.hasOwnProperty(zr)&&(zr==="allocUnsafe"||zr==="allocUnsafeSlow"||(Wi[zr]=ji[zr]));Lr.Buffer.prototype=ji.prototype;(!Wi.from||Wi.from===Uint8Array.from)&&(Wi.from=function(t,e,r){if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&typeof t.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return ji(t,e,r)});Wi.alloc||(Wi.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=ji(t);return!e||e.length===0?n.fill(0):typeof r=="string"?n.fill(e,r):n.fill(e),n});if(!Lr.kStringMaxLength)try{Lr.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}Lr.constants||(Lr.constants={MAX_LENGTH:Lr.kMaxLength},Lr.kStringMaxLength&&(Lr.constants.MAX_STRING_LENGTH=Lr.kStringMaxLength));rg.exports=Lr});var og=le((B3,ig)=>{var vx=require("assert"),ng=Nu().Buffer,Vo=ma(),Sx=ga(),qi=Sx.newInvalidAsn1Error;function xr(t){if(!t||!ng.isBuffer(t))throw new TypeError("data must be a node Buffer");this._buf=t,this._size=t.length,this._len=0,this._offset=0}c(xr,"Reader");Object.defineProperty(xr.prototype,"length",{enumerable:!0,get:c(function(){return this._len},"get")});Object.defineProperty(xr.prototype,"offset",{enumerable:!0,get:c(function(){return this._offset},"get")});Object.defineProperty(xr.prototype,"remain",{get:c(function(){return this._size-this._offset},"get")});Object.defineProperty(xr.prototype,"buffer",{get:c(function(){return this._buf.slice(this._offset)},"get")});xr.prototype.readByte=function(t){if(this._size-this._offset<1)return null;var e=this._buf[this._offset]&255;return t||(this._offset+=1),e};xr.prototype.peek=function(){return this.readByte(!0)};xr.prototype.readLength=function(t){if(t===void 0&&(t=this._offset),t>=this._size)return null;var e=this._buf[t++]&255;if(e===null)return null;if((e&128)===128){if(e&=127,e===0)throw qi("Indefinite length not supported");if(e>4)throw qi("encoding too long");if(this._size-t<e)return null;this._len=0;for(var r=0;r<e;r++)this._len=(this._len<<8)+(this._buf[t++]&255)}else this._len=e;return t};xr.prototype.readSequence=function(t){var e=this.peek();if(e===null)return null;if(t!==void 0&&t!==e)throw qi("Expected 0x"+t.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);return r===null?null:(this._offset=r,e)};xr.prototype.readInt=function(){return this._readTag(Vo.Integer)};xr.prototype.readBoolean=function(){return this._readTag(Vo.Boolean)!==0};xr.prototype.readEnumeration=function(){return this._readTag(Vo.Enumeration)};xr.prototype.readString=function(t,e){t||(t=Vo.OctetString);var r=this.peek();if(r===null)return null;if(r!==t)throw qi("Expected 0x"+t.toString(16)+": got 0x"+r.toString(16));var n=this.readLength(this._offset+1);if(n===null||this.length>this._size-n)return null;if(this._offset=n,this.length===0)return e?ng.alloc(0):"";var i=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,e?i:i.toString("utf8")};xr.prototype.readOID=function(t){t||(t=Vo.OID);var e=this.readString(t,!0);if(e===null)return null;for(var r=[],n=0,i=0;i<e.length;i++){var o=e[i]&255;n<<=7,n+=o&127,(o&128)===0&&(r.push(n),n=0)}return n=r.shift(),r.unshift(n%40),r.unshift(n/40>>0),r.join(".")};xr.prototype._readTag=function(t){vx.ok(t!==void 0);var e=this.peek();if(e===null)return null;if(e!==t)throw qi("Expected 0x"+t.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);if(r===null)return null;if(this.length>4)throw qi("Integer too long: "+this.length);if(this.length>this._size-r)return null;this._offset=r;for(var n=this._buf[this._offset],i=0,o=0;o<this.length;o++)i<<=8,i|=this._buf[this._offset++]&255;return(n&128)===128&&o!==4&&(i-=1<<o*8),i>>0};ig.exports=xr});var ag=le((L3,sg)=>{var Bn=require("assert"),ya=Nu().Buffer,Un=ma(),wx=ga(),Ea=wx.newInvalidAsn1Error,Px={size:1024,growthFactor:8};function Tx(t,e){Bn.ok(t),Bn.equal(typeof t,"object"),Bn.ok(e),Bn.equal(typeof e,"object");var r=Object.getOwnPropertyNames(t);return r.forEach(function(n){if(!e[n]){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i)}}),e}c(Tx,"merge");function mr(t){t=Tx(Px,t||{}),this._buf=ya.alloc(t.size||1024),this._size=this._buf.length,this._offset=0,this._options=t,this._seq=[]}c(mr,"Writer");Object.defineProperty(mr.prototype,"buffer",{get:c(function(){if(this._seq.length)throw Ea(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)},"get")});mr.prototype.writeByte=function(t){if(typeof t!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=t};mr.prototype.writeInt=function(t,e){if(typeof t!="number")throw new TypeError("argument must be a Number");typeof e!="number"&&(e=Un.Integer);for(var r=4;((t&4286578688)===0||(t&4286578688)===-8388608)&&r>1;)r--,t<<=8;if(r>4)throw Ea("BER ints cannot be > 0xffffffff");for(this._ensure(2+r),this._buf[this._offset++]=e,this._buf[this._offset++]=r;r-- >0;)this._buf[this._offset++]=(t&4278190080)>>>24,t<<=8};mr.prototype.writeNull=function(){this.writeByte(Un.Null),this.writeByte(0)};mr.prototype.writeEnumeration=function(t,e){if(typeof t!="number")throw new TypeError("argument must be a Number");return typeof e!="number"&&(e=Un.Enumeration),this.writeInt(t,e)};mr.prototype.writeBoolean=function(t,e){if(typeof t!="boolean")throw new TypeError("argument must be a Boolean");typeof e!="number"&&(e=Un.Boolean),this._ensure(3),this._buf[this._offset++]=e,this._buf[this._offset++]=1,this._buf[this._offset++]=t?255:0};mr.prototype.writeString=function(t,e){if(typeof t!="string")throw new TypeError("argument must be a string (was: "+typeof t+")");typeof e!="number"&&(e=Un.OctetString);var r=ya.byteLength(t);this.writeByte(e),this.writeLength(r),r&&(this._ensure(r),this._buf.write(t,this._offset),this._offset+=r)};mr.prototype.writeBuffer=function(t,e){if(typeof e!="number")throw new TypeError("tag must be a number");if(!ya.isBuffer(t))throw new TypeError("argument must be a buffer");this.writeByte(e),this.writeLength(t.length),this._ensure(t.length),t.copy(this._buf,this._offset,0,t.length),this._offset+=t.length};mr.prototype.writeStringArray=function(t){if(!t instanceof Array)throw new TypeError("argument must be an Array[String]");var e=this;t.forEach(function(r){e.writeString(r)})};mr.prototype.writeOID=function(t,e){if(typeof t!="string")throw new TypeError("argument must be a string");if(typeof e!="number"&&(e=Un.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(t))throw new Error("argument is not a valid OID string");function r(s,a){a<128?s.push(a):a<16384?(s.push(a>>>7|128),s.push(a&127)):a<2097152?(s.push(a>>>14|128),s.push((a>>>7|128)&255),s.push(a&127)):a<268435456?(s.push(a>>>21|128),s.push((a>>>14|128)&255),s.push((a>>>7|128)&255),s.push(a&127)):(s.push((a>>>28|128)&255),s.push((a>>>21|128)&255),s.push((a>>>14|128)&255),s.push((a>>>7|128)&255),s.push(a&127))}c(r,"encodeOctet");var n=t.split("."),i=[];i.push(parseInt(n[0],10)*40+parseInt(n[1],10)),n.slice(2).forEach(function(s){r(i,parseInt(s,10))});var o=this;this._ensure(2+i.length),this.writeByte(e),this.writeLength(i.length),i.forEach(function(s){o.writeByte(s)})};mr.prototype.writeLength=function(t){if(typeof t!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),t<=127)this._buf[this._offset++]=t;else if(t<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=t;else if(t<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=t>>8,this._buf[this._offset++]=t;else if(t<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=t>>16,this._buf[this._offset++]=t>>8,this._buf[this._offset++]=t;else throw Ea("Length too long (> 4 bytes)")};mr.prototype.startSequence=function(t){typeof t!="number"&&(t=Un.Sequence|Un.Constructor),this.writeByte(t),this._seq.push(this._offset),this._ensure(3),this._offset+=3};mr.prototype.endSequence=function(){var t=this._seq.pop(),e=t+3,r=this._offset-e;if(r<=127)this._shift(e,r,-2),this._buf[t]=r;else if(r<=255)this._shift(e,r,-1),this._buf[t]=129,this._buf[t+1]=r;else if(r<=65535)this._buf[t]=130,this._buf[t+1]=r>>8,this._buf[t+2]=r;else if(r<=16777215)this._shift(e,r,1),this._buf[t]=131,this._buf[t+1]=r>>16,this._buf[t+2]=r>>8,this._buf[t+3]=r;else throw Ea("Sequence too long")};mr.prototype._shift=function(t,e,r){Bn.ok(t!==void 0),Bn.ok(e!==void 0),Bn.ok(r),this._buf.copy(this._buf,t+r,t,t+e),this._offset+=r};mr.prototype._ensure=function(t){if(Bn.ok(t),this._size-this._offset<t){var e=this._size*this._options.growthFactor;e-this._offset<t&&(e+=t);var r=ya.alloc(e);this._buf.copy(r,0,0,this._offset),this._buf=r,this._size=e}};sg.exports=mr});var cg=le((M3,xa)=>{var Ou=ga(),$u=ma(),kx=og(),Cx=ag();xa.exports={Reader:kx,Writer:Cx};for(Aa in $u)$u.hasOwnProperty(Aa)&&(xa.exports[Aa]=$u[Aa]);var Aa;for(ba in Ou)Ou.hasOwnProperty(ba)&&(xa.exports[ba]=Ou[ba]);var ba});var Ko=le((F3,ug)=>{var Du=cg();ug.exports={Ber:Du,BerReader:Du.Reader,BerWriter:Du.Writer}});var lg=le((H3,Ia)=>{(function(t){"use strict";var e=c(function(m){var E,y=new Float64Array(16);if(m)for(E=0;E<m.length;E++)y[E]=m[E];return y},"gf"),r=c(function(){throw new Error("no PRNG")},"randombytes"),n=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=e(),s=e([1]),a=e([56129,1]),u=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),p=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),g=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function h(m,E,y,f){m[E]=y>>24&255,m[E+1]=y>>16&255,m[E+2]=y>>8&255,m[E+3]=y&255,m[E+4]=f>>24&255,m[E+5]=f>>16&255,m[E+6]=f>>8&255,m[E+7]=f&255}c(h,"ts64");function _(m,E,y,f,x){var N,z=0;for(N=0;N<x;N++)z|=m[E+N]^y[f+N];return(1&z-1>>>8)-1}c(_,"vn");function A(m,E,y,f){return _(m,E,y,f,16)}c(A,"crypto_verify_16");function b(m,E,y,f){return _(m,E,y,f,32)}c(b,"crypto_verify_32");function I(m,E,y,f){for(var x=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,N=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,z=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,ne=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,ce=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,ye=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,pe=E[0]&255|(E[1]&255)<<8|(E[2]&255)<<16|(E[3]&255)<<24,gt=E[4]&255|(E[5]&255)<<8|(E[6]&255)<<16|(E[7]&255)<<24,_e=E[8]&255|(E[9]&255)<<8|(E[10]&255)<<16|(E[11]&255)<<24,Ue=E[12]&255|(E[13]&255)<<8|(E[14]&255)<<16|(E[15]&255)<<24,Le=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Ge=y[16]&255|(y[17]&255)<<8|(y[18]&255)<<16|(y[19]&255)<<24,Ke=y[20]&255|(y[21]&255)<<8|(y[22]&255)<<16|(y[23]&255)<<24,ze=y[24]&255|(y[25]&255)<<8|(y[26]&255)<<16|(y[27]&255)<<24,Ve=y[28]&255|(y[29]&255)<<8|(y[30]&255)<<16|(y[31]&255)<<24,Me=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,Ee=x,Ie=N,ge=z,Ae=ne,be=ce,de=ye,Q=pe,V=gt,se=_e,re=Ue,ie=Le,ae=Ge,ke=Ke,Ze=ze,et=Ve,Ye=Me,S,nt=0;nt<20;nt+=2)S=Ee+ke|0,be^=S<<7|S>>>25,S=be+Ee|0,se^=S<<9|S>>>23,S=se+be|0,ke^=S<<13|S>>>19,S=ke+se|0,Ee^=S<<18|S>>>14,S=de+Ie|0,re^=S<<7|S>>>25,S=re+de|0,Ze^=S<<9|S>>>23,S=Ze+re|0,Ie^=S<<13|S>>>19,S=Ie+Ze|0,de^=S<<18|S>>>14,S=ie+Q|0,et^=S<<7|S>>>25,S=et+ie|0,ge^=S<<9|S>>>23,S=ge+et|0,Q^=S<<13|S>>>19,S=Q+ge|0,ie^=S<<18|S>>>14,S=Ye+ae|0,Ae^=S<<7|S>>>25,S=Ae+Ye|0,V^=S<<9|S>>>23,S=V+Ae|0,ae^=S<<13|S>>>19,S=ae+V|0,Ye^=S<<18|S>>>14,S=Ee+Ae|0,Ie^=S<<7|S>>>25,S=Ie+Ee|0,ge^=S<<9|S>>>23,S=ge+Ie|0,Ae^=S<<13|S>>>19,S=Ae+ge|0,Ee^=S<<18|S>>>14,S=de+be|0,Q^=S<<7|S>>>25,S=Q+de|0,V^=S<<9|S>>>23,S=V+Q|0,be^=S<<13|S>>>19,S=be+V|0,de^=S<<18|S>>>14,S=ie+re|0,ae^=S<<7|S>>>25,S=ae+ie|0,se^=S<<9|S>>>23,S=se+ae|0,re^=S<<13|S>>>19,S=re+se|0,ie^=S<<18|S>>>14,S=Ye+et|0,ke^=S<<7|S>>>25,S=ke+Ye|0,Ze^=S<<9|S>>>23,S=Ze+ke|0,et^=S<<13|S>>>19,S=et+Ze|0,Ye^=S<<18|S>>>14;Ee=Ee+x|0,Ie=Ie+N|0,ge=ge+z|0,Ae=Ae+ne|0,be=be+ce|0,de=de+ye|0,Q=Q+pe|0,V=V+gt|0,se=se+_e|0,re=re+Ue|0,ie=ie+Le|0,ae=ae+Ge|0,ke=ke+Ke|0,Ze=Ze+ze|0,et=et+Ve|0,Ye=Ye+Me|0,m[0]=Ee>>>0&255,m[1]=Ee>>>8&255,m[2]=Ee>>>16&255,m[3]=Ee>>>24&255,m[4]=Ie>>>0&255,m[5]=Ie>>>8&255,m[6]=Ie>>>16&255,m[7]=Ie>>>24&255,m[8]=ge>>>0&255,m[9]=ge>>>8&255,m[10]=ge>>>16&255,m[11]=ge>>>24&255,m[12]=Ae>>>0&255,m[13]=Ae>>>8&255,m[14]=Ae>>>16&255,m[15]=Ae>>>24&255,m[16]=be>>>0&255,m[17]=be>>>8&255,m[18]=be>>>16&255,m[19]=be>>>24&255,m[20]=de>>>0&255,m[21]=de>>>8&255,m[22]=de>>>16&255,m[23]=de>>>24&255,m[24]=Q>>>0&255,m[25]=Q>>>8&255,m[26]=Q>>>16&255,m[27]=Q>>>24&255,m[28]=V>>>0&255,m[29]=V>>>8&255,m[30]=V>>>16&255,m[31]=V>>>24&255,m[32]=se>>>0&255,m[33]=se>>>8&255,m[34]=se>>>16&255,m[35]=se>>>24&255,m[36]=re>>>0&255,m[37]=re>>>8&255,m[38]=re>>>16&255,m[39]=re>>>24&255,m[40]=ie>>>0&255,m[41]=ie>>>8&255,m[42]=ie>>>16&255,m[43]=ie>>>24&255,m[44]=ae>>>0&255,m[45]=ae>>>8&255,m[46]=ae>>>16&255,m[47]=ae>>>24&255,m[48]=ke>>>0&255,m[49]=ke>>>8&255,m[50]=ke>>>16&255,m[51]=ke>>>24&255,m[52]=Ze>>>0&255,m[53]=Ze>>>8&255,m[54]=Ze>>>16&255,m[55]=Ze>>>24&255,m[56]=et>>>0&255,m[57]=et>>>8&255,m[58]=et>>>16&255,m[59]=et>>>24&255,m[60]=Ye>>>0&255,m[61]=Ye>>>8&255,m[62]=Ye>>>16&255,m[63]=Ye>>>24&255}c(I,"core_salsa20");function w(m,E,y,f){for(var x=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,N=y[0]&255|(y[1]&255)<<8|(y[2]&255)<<16|(y[3]&255)<<24,z=y[4]&255|(y[5]&255)<<8|(y[6]&255)<<16|(y[7]&255)<<24,ne=y[8]&255|(y[9]&255)<<8|(y[10]&255)<<16|(y[11]&255)<<24,ce=y[12]&255|(y[13]&255)<<8|(y[14]&255)<<16|(y[15]&255)<<24,ye=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,pe=E[0]&255|(E[1]&255)<<8|(E[2]&255)<<16|(E[3]&255)<<24,gt=E[4]&255|(E[5]&255)<<8|(E[6]&255)<<16|(E[7]&255)<<24,_e=E[8]&255|(E[9]&255)<<8|(E[10]&255)<<16|(E[11]&255)<<24,Ue=E[12]&255|(E[13]&255)<<8|(E[14]&255)<<16|(E[15]&255)<<24,Le=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Ge=y[16]&255|(y[17]&255)<<8|(y[18]&255)<<16|(y[19]&255)<<24,Ke=y[20]&255|(y[21]&255)<<8|(y[22]&255)<<16|(y[23]&255)<<24,ze=y[24]&255|(y[25]&255)<<8|(y[26]&255)<<16|(y[27]&255)<<24,Ve=y[28]&255|(y[29]&255)<<8|(y[30]&255)<<16|(y[31]&255)<<24,Me=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,Ee=x,Ie=N,ge=z,Ae=ne,be=ce,de=ye,Q=pe,V=gt,se=_e,re=Ue,ie=Le,ae=Ge,ke=Ke,Ze=ze,et=Ve,Ye=Me,S,nt=0;nt<20;nt+=2)S=Ee+ke|0,be^=S<<7|S>>>25,S=be+Ee|0,se^=S<<9|S>>>23,S=se+be|0,ke^=S<<13|S>>>19,S=ke+se|0,Ee^=S<<18|S>>>14,S=de+Ie|0,re^=S<<7|S>>>25,S=re+de|0,Ze^=S<<9|S>>>23,S=Ze+re|0,Ie^=S<<13|S>>>19,S=Ie+Ze|0,de^=S<<18|S>>>14,S=ie+Q|0,et^=S<<7|S>>>25,S=et+ie|0,ge^=S<<9|S>>>23,S=ge+et|0,Q^=S<<13|S>>>19,S=Q+ge|0,ie^=S<<18|S>>>14,S=Ye+ae|0,Ae^=S<<7|S>>>25,S=Ae+Ye|0,V^=S<<9|S>>>23,S=V+Ae|0,ae^=S<<13|S>>>19,S=ae+V|0,Ye^=S<<18|S>>>14,S=Ee+Ae|0,Ie^=S<<7|S>>>25,S=Ie+Ee|0,ge^=S<<9|S>>>23,S=ge+Ie|0,Ae^=S<<13|S>>>19,S=Ae+ge|0,Ee^=S<<18|S>>>14,S=de+be|0,Q^=S<<7|S>>>25,S=Q+de|0,V^=S<<9|S>>>23,S=V+Q|0,be^=S<<13|S>>>19,S=be+V|0,de^=S<<18|S>>>14,S=ie+re|0,ae^=S<<7|S>>>25,S=ae+ie|0,se^=S<<9|S>>>23,S=se+ae|0,re^=S<<13|S>>>19,S=re+se|0,ie^=S<<18|S>>>14,S=Ye+et|0,ke^=S<<7|S>>>25,S=ke+Ye|0,Ze^=S<<9|S>>>23,S=Ze+ke|0,et^=S<<13|S>>>19,S=et+Ze|0,Ye^=S<<18|S>>>14;m[0]=Ee>>>0&255,m[1]=Ee>>>8&255,m[2]=Ee>>>16&255,m[3]=Ee>>>24&255,m[4]=de>>>0&255,m[5]=de>>>8&255,m[6]=de>>>16&255,m[7]=de>>>24&255,m[8]=ie>>>0&255,m[9]=ie>>>8&255,m[10]=ie>>>16&255,m[11]=ie>>>24&255,m[12]=Ye>>>0&255,m[13]=Ye>>>8&255,m[14]=Ye>>>16&255,m[15]=Ye>>>24&255,m[16]=Q>>>0&255,m[17]=Q>>>8&255,m[18]=Q>>>16&255,m[19]=Q>>>24&255,m[20]=V>>>0&255,m[21]=V>>>8&255,m[22]=V>>>16&255,m[23]=V>>>24&255,m[24]=se>>>0&255,m[25]=se>>>8&255,m[26]=se>>>16&255,m[27]=se>>>24&255,m[28]=re>>>0&255,m[29]=re>>>8&255,m[30]=re>>>16&255,m[31]=re>>>24&255}c(w,"core_hsalsa20");function H(m,E,y,f){I(m,E,y,f)}c(H,"crypto_core_salsa20");function $(m,E,y,f){w(m,E,y,f)}c($,"crypto_core_hsalsa20");var X=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Z(m,E,y,f,x,N,z){var ne=new Uint8Array(16),ce=new Uint8Array(64),ye,pe;for(pe=0;pe<16;pe++)ne[pe]=0;for(pe=0;pe<8;pe++)ne[pe]=N[pe];for(;x>=64;){for(H(ce,ne,z,X),pe=0;pe<64;pe++)m[E+pe]=y[f+pe]^ce[pe];for(ye=1,pe=8;pe<16;pe++)ye=ye+(ne[pe]&255)|0,ne[pe]=ye&255,ye>>>=8;x-=64,E+=64,f+=64}if(x>0)for(H(ce,ne,z,X),pe=0;pe<x;pe++)m[E+pe]=y[f+pe]^ce[pe];return 0}c(Z,"crypto_stream_salsa20_xor");function Y(m,E,y,f,x){var N=new Uint8Array(16),z=new Uint8Array(64),ne,ce;for(ce=0;ce<16;ce++)N[ce]=0;for(ce=0;ce<8;ce++)N[ce]=f[ce];for(;y>=64;){for(H(z,N,x,X),ce=0;ce<64;ce++)m[E+ce]=z[ce];for(ne=1,ce=8;ce<16;ce++)ne=ne+(N[ce]&255)|0,N[ce]=ne&255,ne>>>=8;y-=64,E+=64}if(y>0)for(H(z,N,x,X),ce=0;ce<y;ce++)m[E+ce]=z[ce];return 0}c(Y,"crypto_stream_salsa20");function P(m,E,y,f,x){var N=new Uint8Array(32);$(N,f,x,X);for(var z=new Uint8Array(8),ne=0;ne<8;ne++)z[ne]=f[ne+16];return Y(m,E,y,z,N)}c(P,"crypto_stream");function k(m,E,y,f,x,N,z){var ne=new Uint8Array(32);$(ne,N,z,X);for(var ce=new Uint8Array(8),ye=0;ye<8;ye++)ce[ye]=N[ye+16];return Z(m,E,y,f,x,ce,ne)}c(k,"crypto_stream_xor");var M=c(function(m){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 E,y,f,x,N,z,ne,ce;E=m[0]&255|(m[1]&255)<<8,this.r[0]=E&8191,y=m[2]&255|(m[3]&255)<<8,this.r[1]=(E>>>13|y<<3)&8191,f=m[4]&255|(m[5]&255)<<8,this.r[2]=(y>>>10|f<<6)&7939,x=m[6]&255|(m[7]&255)<<8,this.r[3]=(f>>>7|x<<9)&8191,N=m[8]&255|(m[9]&255)<<8,this.r[4]=(x>>>4|N<<12)&255,this.r[5]=N>>>1&8190,z=m[10]&255|(m[11]&255)<<8,this.r[6]=(N>>>14|z<<2)&8191,ne=m[12]&255|(m[13]&255)<<8,this.r[7]=(z>>>11|ne<<5)&8065,ce=m[14]&255|(m[15]&255)<<8,this.r[8]=(ne>>>8|ce<<8)&8191,this.r[9]=ce>>>5&127,this.pad[0]=m[16]&255|(m[17]&255)<<8,this.pad[1]=m[18]&255|(m[19]&255)<<8,this.pad[2]=m[20]&255|(m[21]&255)<<8,this.pad[3]=m[22]&255|(m[23]&255)<<8,this.pad[4]=m[24]&255|(m[25]&255)<<8,this.pad[5]=m[26]&255|(m[27]&255)<<8,this.pad[6]=m[28]&255|(m[29]&255)<<8,this.pad[7]=m[30]&255|(m[31]&255)<<8},"poly1305");M.prototype.blocks=function(m,E,y){for(var f=this.fin?0:2048,x,N,z,ne,ce,ye,pe,gt,_e,Ue,Le,Ge,Ke,ze,Ve,Me,Ee,Ie,ge,Ae=this.h[0],be=this.h[1],de=this.h[2],Q=this.h[3],V=this.h[4],se=this.h[5],re=this.h[6],ie=this.h[7],ae=this.h[8],ke=this.h[9],Ze=this.r[0],et=this.r[1],Ye=this.r[2],S=this.r[3],nt=this.r[4],mt=this.r[5],_t=this.r[6],rt=this.r[7],ft=this.r[8],dt=this.r[9];y>=16;)x=m[E+0]&255|(m[E+1]&255)<<8,Ae+=x&8191,N=m[E+2]&255|(m[E+3]&255)<<8,be+=(x>>>13|N<<3)&8191,z=m[E+4]&255|(m[E+5]&255)<<8,de+=(N>>>10|z<<6)&8191,ne=m[E+6]&255|(m[E+7]&255)<<8,Q+=(z>>>7|ne<<9)&8191,ce=m[E+8]&255|(m[E+9]&255)<<8,V+=(ne>>>4|ce<<12)&8191,se+=ce>>>1&8191,ye=m[E+10]&255|(m[E+11]&255)<<8,re+=(ce>>>14|ye<<2)&8191,pe=m[E+12]&255|(m[E+13]&255)<<8,ie+=(ye>>>11|pe<<5)&8191,gt=m[E+14]&255|(m[E+15]&255)<<8,ae+=(pe>>>8|gt<<8)&8191,ke+=gt>>>5|f,_e=0,Ue=_e,Ue+=Ae*Ze,Ue+=be*(5*dt),Ue+=de*(5*ft),Ue+=Q*(5*rt),Ue+=V*(5*_t),_e=Ue>>>13,Ue&=8191,Ue+=se*(5*mt),Ue+=re*(5*nt),Ue+=ie*(5*S),Ue+=ae*(5*Ye),Ue+=ke*(5*et),_e+=Ue>>>13,Ue&=8191,Le=_e,Le+=Ae*et,Le+=be*Ze,Le+=de*(5*dt),Le+=Q*(5*ft),Le+=V*(5*rt),_e=Le>>>13,Le&=8191,Le+=se*(5*_t),Le+=re*(5*mt),Le+=ie*(5*nt),Le+=ae*(5*S),Le+=ke*(5*Ye),_e+=Le>>>13,Le&=8191,Ge=_e,Ge+=Ae*Ye,Ge+=be*et,Ge+=de*Ze,Ge+=Q*(5*dt),Ge+=V*(5*ft),_e=Ge>>>13,Ge&=8191,Ge+=se*(5*rt),Ge+=re*(5*_t),Ge+=ie*(5*mt),Ge+=ae*(5*nt),Ge+=ke*(5*S),_e+=Ge>>>13,Ge&=8191,Ke=_e,Ke+=Ae*S,Ke+=be*Ye,Ke+=de*et,Ke+=Q*Ze,Ke+=V*(5*dt),_e=Ke>>>13,Ke&=8191,Ke+=se*(5*ft),Ke+=re*(5*rt),Ke+=ie*(5*_t),Ke+=ae*(5*mt),Ke+=ke*(5*nt),_e+=Ke>>>13,Ke&=8191,ze=_e,ze+=Ae*nt,ze+=be*S,ze+=de*Ye,ze+=Q*et,ze+=V*Ze,_e=ze>>>13,ze&=8191,ze+=se*(5*dt),ze+=re*(5*ft),ze+=ie*(5*rt),ze+=ae*(5*_t),ze+=ke*(5*mt),_e+=ze>>>13,ze&=8191,Ve=_e,Ve+=Ae*mt,Ve+=be*nt,Ve+=de*S,Ve+=Q*Ye,Ve+=V*et,_e=Ve>>>13,Ve&=8191,Ve+=se*Ze,Ve+=re*(5*dt),Ve+=ie*(5*ft),Ve+=ae*(5*rt),Ve+=ke*(5*_t),_e+=Ve>>>13,Ve&=8191,Me=_e,Me+=Ae*_t,Me+=be*mt,Me+=de*nt,Me+=Q*S,Me+=V*Ye,_e=Me>>>13,Me&=8191,Me+=se*et,Me+=re*Ze,Me+=ie*(5*dt),Me+=ae*(5*ft),Me+=ke*(5*rt),_e+=Me>>>13,Me&=8191,Ee=_e,Ee+=Ae*rt,Ee+=be*_t,Ee+=de*mt,Ee+=Q*nt,Ee+=V*S,_e=Ee>>>13,Ee&=8191,Ee+=se*Ye,Ee+=re*et,Ee+=ie*Ze,Ee+=ae*(5*dt),Ee+=ke*(5*ft),_e+=Ee>>>13,Ee&=8191,Ie=_e,Ie+=Ae*ft,Ie+=be*rt,Ie+=de*_t,Ie+=Q*mt,Ie+=V*nt,_e=Ie>>>13,Ie&=8191,Ie+=se*S,Ie+=re*Ye,Ie+=ie*et,Ie+=ae*Ze,Ie+=ke*(5*dt),_e+=Ie>>>13,Ie&=8191,ge=_e,ge+=Ae*dt,ge+=be*ft,ge+=de*rt,ge+=Q*_t,ge+=V*mt,_e=ge>>>13,ge&=8191,ge+=se*nt,ge+=re*S,ge+=ie*Ye,ge+=ae*et,ge+=ke*Ze,_e+=ge>>>13,ge&=8191,_e=(_e<<2)+_e|0,_e=_e+Ue|0,Ue=_e&8191,_e=_e>>>13,Le+=_e,Ae=Ue,be=Le,de=Ge,Q=Ke,V=ze,se=Ve,re=Me,ie=Ee,ae=Ie,ke=ge,E+=16,y-=16;this.h[0]=Ae,this.h[1]=be,this.h[2]=de,this.h[3]=Q,this.h[4]=V,this.h[5]=se,this.h[6]=re,this.h[7]=ie,this.h[8]=ae,this.h[9]=ke},M.prototype.finish=function(m,E){var y=new Uint16Array(10),f,x,N,z;if(this.leftover){for(z=this.leftover,this.buffer[z++]=1;z<16;z++)this.buffer[z]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(f=this.h[1]>>>13,this.h[1]&=8191,z=2;z<10;z++)this.h[z]+=f,f=this.h[z]>>>13,this.h[z]&=8191;for(this.h[0]+=f*5,f=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=f,f=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=f,y[0]=this.h[0]+5,f=y[0]>>>13,y[0]&=8191,z=1;z<10;z++)y[z]=this.h[z]+f,f=y[z]>>>13,y[z]&=8191;for(y[9]-=8192,x=(f^1)-1,z=0;z<10;z++)y[z]&=x;for(x=~x,z=0;z<10;z++)this.h[z]=this.h[z]&x|y[z];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,N=this.h[0]+this.pad[0],this.h[0]=N&65535,z=1;z<8;z++)N=(this.h[z]+this.pad[z]|0)+(N>>>16)|0,this.h[z]=N&65535;m[E+0]=this.h[0]>>>0&255,m[E+1]=this.h[0]>>>8&255,m[E+2]=this.h[1]>>>0&255,m[E+3]=this.h[1]>>>8&255,m[E+4]=this.h[2]>>>0&255,m[E+5]=this.h[2]>>>8&255,m[E+6]=this.h[3]>>>0&255,m[E+7]=this.h[3]>>>8&255,m[E+8]=this.h[4]>>>0&255,m[E+9]=this.h[4]>>>8&255,m[E+10]=this.h[5]>>>0&255,m[E+11]=this.h[5]>>>8&255,m[E+12]=this.h[6]>>>0&255,m[E+13]=this.h[6]>>>8&255,m[E+14]=this.h[7]>>>0&255,m[E+15]=this.h[7]>>>8&255},M.prototype.update=function(m,E,y){var f,x;if(this.leftover){for(x=16-this.leftover,x>y&&(x=y),f=0;f<x;f++)this.buffer[this.leftover+f]=m[E+f];if(y-=x,E+=x,this.leftover+=x,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(y>=16&&(x=y-y%16,this.blocks(m,E,x),E+=x,y-=x),y){for(f=0;f<y;f++)this.buffer[this.leftover+f]=m[E+f];this.leftover+=y}};function L(m,E,y,f,x,N){var z=new M(N);return z.update(y,f,x),z.finish(m,E),0}c(L,"crypto_onetimeauth");function T(m,E,y,f,x,N){var z=new Uint8Array(16);return L(z,0,y,f,x,N),A(m,E,z,0)}c(T,"crypto_onetimeauth_verify");function F(m,E,y,f,x){var N;if(y<32)return-1;for(k(m,0,E,0,y,f,x),L(m,16,m,32,y-32,m),N=0;N<16;N++)m[N]=0;return 0}c(F,"crypto_secretbox");function j(m,E,y,f,x){var N,z=new Uint8Array(32);if(y<32||(P(z,0,32,f,x),T(E,16,E,32,y-32,z)!==0))return-1;for(k(m,0,E,0,y,f,x),N=0;N<32;N++)m[N]=0;return 0}c(j,"crypto_secretbox_open");function B(m,E){var y;for(y=0;y<16;y++)m[y]=E[y]|0}c(B,"set25519");function G(m){var E,y,f=1;for(E=0;E<16;E++)y=m[E]+f+65535,f=Math.floor(y/65536),m[E]=y-f*65536;m[0]+=f-1+37*(f-1)}c(G,"car25519");function ee(m,E,y){for(var f,x=~(y-1),N=0;N<16;N++)f=x&(m[N]^E[N]),m[N]^=f,E[N]^=f}c(ee,"sel25519");function C(m,E){var y,f,x,N=e(),z=e();for(y=0;y<16;y++)z[y]=E[y];for(G(z),G(z),G(z),f=0;f<2;f++){for(N[0]=z[0]-65517,y=1;y<15;y++)N[y]=z[y]-65535-(N[y-1]>>16&1),N[y-1]&=65535;N[15]=z[15]-32767-(N[14]>>16&1),x=N[15]>>16&1,N[14]&=65535,ee(z,N,1-x)}for(y=0;y<16;y++)m[2*y]=z[y]&255,m[2*y+1]=z[y]>>8}c(C,"pack25519");function W(m,E){var y=new Uint8Array(32),f=new Uint8Array(32);return C(y,m),C(f,E),b(y,0,f,0)}c(W,"neq25519");function q(m){var E=new Uint8Array(32);return C(E,m),E[0]&1}c(q,"par25519");function J(m,E){var y;for(y=0;y<16;y++)m[y]=E[2*y]+(E[2*y+1]<<8);m[15]&=32767}c(J,"unpack25519");function ue(m,E,y){for(var f=0;f<16;f++)m[f]=E[f]+y[f]}c(ue,"A");function me(m,E,y){for(var f=0;f<16;f++)m[f]=E[f]-y[f]}c(me,"Z");function he(m,E,y){var f,x,N=0,z=0,ne=0,ce=0,ye=0,pe=0,gt=0,_e=0,Ue=0,Le=0,Ge=0,Ke=0,ze=0,Ve=0,Me=0,Ee=0,Ie=0,ge=0,Ae=0,be=0,de=0,Q=0,V=0,se=0,re=0,ie=0,ae=0,ke=0,Ze=0,et=0,Ye=0,S=y[0],nt=y[1],mt=y[2],_t=y[3],rt=y[4],ft=y[5],dt=y[6],Yt=y[7],vt=y[8],Wt=y[9],qt=y[10],Qt=y[11],or=y[12],dr=y[13],pr=y[14],hr=y[15];f=E[0],N+=f*S,z+=f*nt,ne+=f*mt,ce+=f*_t,ye+=f*rt,pe+=f*ft,gt+=f*dt,_e+=f*Yt,Ue+=f*vt,Le+=f*Wt,Ge+=f*qt,Ke+=f*Qt,ze+=f*or,Ve+=f*dr,Me+=f*pr,Ee+=f*hr,f=E[1],z+=f*S,ne+=f*nt,ce+=f*mt,ye+=f*_t,pe+=f*rt,gt+=f*ft,_e+=f*dt,Ue+=f*Yt,Le+=f*vt,Ge+=f*Wt,Ke+=f*qt,ze+=f*Qt,Ve+=f*or,Me+=f*dr,Ee+=f*pr,Ie+=f*hr,f=E[2],ne+=f*S,ce+=f*nt,ye+=f*mt,pe+=f*_t,gt+=f*rt,_e+=f*ft,Ue+=f*dt,Le+=f*Yt,Ge+=f*vt,Ke+=f*Wt,ze+=f*qt,Ve+=f*Qt,Me+=f*or,Ee+=f*dr,Ie+=f*pr,ge+=f*hr,f=E[3],ce+=f*S,ye+=f*nt,pe+=f*mt,gt+=f*_t,_e+=f*rt,Ue+=f*ft,Le+=f*dt,Ge+=f*Yt,Ke+=f*vt,ze+=f*Wt,Ve+=f*qt,Me+=f*Qt,Ee+=f*or,Ie+=f*dr,ge+=f*pr,Ae+=f*hr,f=E[4],ye+=f*S,pe+=f*nt,gt+=f*mt,_e+=f*_t,Ue+=f*rt,Le+=f*ft,Ge+=f*dt,Ke+=f*Yt,ze+=f*vt,Ve+=f*Wt,Me+=f*qt,Ee+=f*Qt,Ie+=f*or,ge+=f*dr,Ae+=f*pr,be+=f*hr,f=E[5],pe+=f*S,gt+=f*nt,_e+=f*mt,Ue+=f*_t,Le+=f*rt,Ge+=f*ft,Ke+=f*dt,ze+=f*Yt,Ve+=f*vt,Me+=f*Wt,Ee+=f*qt,Ie+=f*Qt,ge+=f*or,Ae+=f*dr,be+=f*pr,de+=f*hr,f=E[6],gt+=f*S,_e+=f*nt,Ue+=f*mt,Le+=f*_t,Ge+=f*rt,Ke+=f*ft,ze+=f*dt,Ve+=f*Yt,Me+=f*vt,Ee+=f*Wt,Ie+=f*qt,ge+=f*Qt,Ae+=f*or,be+=f*dr,de+=f*pr,Q+=f*hr,f=E[7],_e+=f*S,Ue+=f*nt,Le+=f*mt,Ge+=f*_t,Ke+=f*rt,ze+=f*ft,Ve+=f*dt,Me+=f*Yt,Ee+=f*vt,Ie+=f*Wt,ge+=f*qt,Ae+=f*Qt,be+=f*or,de+=f*dr,Q+=f*pr,V+=f*hr,f=E[8],Ue+=f*S,Le+=f*nt,Ge+=f*mt,Ke+=f*_t,ze+=f*rt,Ve+=f*ft,Me+=f*dt,Ee+=f*Yt,Ie+=f*vt,ge+=f*Wt,Ae+=f*qt,be+=f*Qt,de+=f*or,Q+=f*dr,V+=f*pr,se+=f*hr,f=E[9],Le+=f*S,Ge+=f*nt,Ke+=f*mt,ze+=f*_t,Ve+=f*rt,Me+=f*ft,Ee+=f*dt,Ie+=f*Yt,ge+=f*vt,Ae+=f*Wt,be+=f*qt,de+=f*Qt,Q+=f*or,V+=f*dr,se+=f*pr,re+=f*hr,f=E[10],Ge+=f*S,Ke+=f*nt,ze+=f*mt,Ve+=f*_t,Me+=f*rt,Ee+=f*ft,Ie+=f*dt,ge+=f*Yt,Ae+=f*vt,be+=f*Wt,de+=f*qt,Q+=f*Qt,V+=f*or,se+=f*dr,re+=f*pr,ie+=f*hr,f=E[11],Ke+=f*S,ze+=f*nt,Ve+=f*mt,Me+=f*_t,Ee+=f*rt,Ie+=f*ft,ge+=f*dt,Ae+=f*Yt,be+=f*vt,de+=f*Wt,Q+=f*qt,V+=f*Qt,se+=f*or,re+=f*dr,ie+=f*pr,ae+=f*hr,f=E[12],ze+=f*S,Ve+=f*nt,Me+=f*mt,Ee+=f*_t,Ie+=f*rt,ge+=f*ft,Ae+=f*dt,be+=f*Yt,de+=f*vt,Q+=f*Wt,V+=f*qt,se+=f*Qt,re+=f*or,ie+=f*dr,ae+=f*pr,ke+=f*hr,f=E[13],Ve+=f*S,Me+=f*nt,Ee+=f*mt,Ie+=f*_t,ge+=f*rt,Ae+=f*ft,be+=f*dt,de+=f*Yt,Q+=f*vt,V+=f*Wt,se+=f*qt,re+=f*Qt,ie+=f*or,ae+=f*dr,ke+=f*pr,Ze+=f*hr,f=E[14],Me+=f*S,Ee+=f*nt,Ie+=f*mt,ge+=f*_t,Ae+=f*rt,be+=f*ft,de+=f*dt,Q+=f*Yt,V+=f*vt,se+=f*Wt,re+=f*qt,ie+=f*Qt,ae+=f*or,ke+=f*dr,Ze+=f*pr,et+=f*hr,f=E[15],Ee+=f*S,Ie+=f*nt,ge+=f*mt,Ae+=f*_t,be+=f*rt,de+=f*ft,Q+=f*dt,V+=f*Yt,se+=f*vt,re+=f*Wt,ie+=f*qt,ae+=f*Qt,ke+=f*or,Ze+=f*dr,et+=f*pr,Ye+=f*hr,N+=38*Ie,z+=38*ge,ne+=38*Ae,ce+=38*be,ye+=38*de,pe+=38*Q,gt+=38*V,_e+=38*se,Ue+=38*re,Le+=38*ie,Ge+=38*ae,Ke+=38*ke,ze+=38*Ze,Ve+=38*et,Me+=38*Ye,x=1,f=N+x+65535,x=Math.floor(f/65536),N=f-x*65536,f=z+x+65535,x=Math.floor(f/65536),z=f-x*65536,f=ne+x+65535,x=Math.floor(f/65536),ne=f-x*65536,f=ce+x+65535,x=Math.floor(f/65536),ce=f-x*65536,f=ye+x+65535,x=Math.floor(f/65536),ye=f-x*65536,f=pe+x+65535,x=Math.floor(f/65536),pe=f-x*65536,f=gt+x+65535,x=Math.floor(f/65536),gt=f-x*65536,f=_e+x+65535,x=Math.floor(f/65536),_e=f-x*65536,f=Ue+x+65535,x=Math.floor(f/65536),Ue=f-x*65536,f=Le+x+65535,x=Math.floor(f/65536),Le=f-x*65536,f=Ge+x+65535,x=Math.floor(f/65536),Ge=f-x*65536,f=Ke+x+65535,x=Math.floor(f/65536),Ke=f-x*65536,f=ze+x+65535,x=Math.floor(f/65536),ze=f-x*65536,f=Ve+x+65535,x=Math.floor(f/65536),Ve=f-x*65536,f=Me+x+65535,x=Math.floor(f/65536),Me=f-x*65536,f=Ee+x+65535,x=Math.floor(f/65536),Ee=f-x*65536,N+=x-1+37*(x-1),x=1,f=N+x+65535,x=Math.floor(f/65536),N=f-x*65536,f=z+x+65535,x=Math.floor(f/65536),z=f-x*65536,f=ne+x+65535,x=Math.floor(f/65536),ne=f-x*65536,f=ce+x+65535,x=Math.floor(f/65536),ce=f-x*65536,f=ye+x+65535,x=Math.floor(f/65536),ye=f-x*65536,f=pe+x+65535,x=Math.floor(f/65536),pe=f-x*65536,f=gt+x+65535,x=Math.floor(f/65536),gt=f-x*65536,f=_e+x+65535,x=Math.floor(f/65536),_e=f-x*65536,f=Ue+x+65535,x=Math.floor(f/65536),Ue=f-x*65536,f=Le+x+65535,x=Math.floor(f/65536),Le=f-x*65536,f=Ge+x+65535,x=Math.floor(f/65536),Ge=f-x*65536,f=Ke+x+65535,x=Math.floor(f/65536),Ke=f-x*65536,f=ze+x+65535,x=Math.floor(f/65536),ze=f-x*65536,f=Ve+x+65535,x=Math.floor(f/65536),Ve=f-x*65536,f=Me+x+65535,x=Math.floor(f/65536),Me=f-x*65536,f=Ee+x+65535,x=Math.floor(f/65536),Ee=f-x*65536,N+=x-1+37*(x-1),m[0]=N,m[1]=z,m[2]=ne,m[3]=ce,m[4]=ye,m[5]=pe,m[6]=gt,m[7]=_e,m[8]=Ue,m[9]=Le,m[10]=Ge,m[11]=Ke,m[12]=ze,m[13]=Ve,m[14]=Me,m[15]=Ee}c(he,"M");function bt(m,E){he(m,E,E)}c(bt,"S");function Ct(m,E){var y=e(),f;for(f=0;f<16;f++)y[f]=E[f];for(f=253;f>=0;f--)bt(y,y),f!==2&&f!==4&&he(y,y,E);for(f=0;f<16;f++)m[f]=y[f]}c(Ct,"inv25519");function Xt(m,E){var y=e(),f;for(f=0;f<16;f++)y[f]=E[f];for(f=250;f>=0;f--)bt(y,y),f!==1&&he(y,y,E);for(f=0;f<16;f++)m[f]=y[f]}c(Xt,"pow2523");function yr(m,E,y){var f=new Uint8Array(32),x=new Float64Array(80),N,z,ne=e(),ce=e(),ye=e(),pe=e(),gt=e(),_e=e();for(z=0;z<31;z++)f[z]=E[z];for(f[31]=E[31]&127|64,f[0]&=248,J(x,y),z=0;z<16;z++)ce[z]=x[z],pe[z]=ne[z]=ye[z]=0;for(ne[0]=pe[0]=1,z=254;z>=0;--z)N=f[z>>>3]>>>(z&7)&1,ee(ne,ce,N),ee(ye,pe,N),ue(gt,ne,ye),me(ne,ne,ye),ue(ye,ce,pe),me(ce,ce,pe),bt(pe,gt),bt(_e,ne),he(ne,ye,ne),he(ye,ce,gt),ue(gt,ne,ye),me(ne,ne,ye),bt(ce,ne),me(ye,pe,_e),he(ne,ye,a),ue(ne,ne,pe),he(ye,ye,ne),he(ne,pe,_e),he(pe,ce,x),bt(ce,gt),ee(ne,ce,N),ee(ye,pe,N);for(z=0;z<16;z++)x[z+16]=ne[z],x[z+32]=ye[z],x[z+48]=ce[z],x[z+64]=pe[z];var Ue=x.subarray(32),Le=x.subarray(16);return Ct(Ue,Ue),he(Le,Le,Ue),C(m,Le),0}c(yr,"crypto_scalarmult");function Dr(m,E){return yr(m,E,i)}c(Dr,"crypto_scalarmult_base");function vr(m,E){return r(E,32),Dr(m,E)}c(vr,"crypto_box_keypair");function Ai(m,E,y){var f=new Uint8Array(32);return yr(f,y,E),$(m,n,f,X)}c(Ai,"crypto_box_beforenm");var go=F,Bs=j;function mo(m,E,y,f,x,N){var z=new Uint8Array(32);return Ai(z,x,N),go(m,E,y,f,z)}c(mo,"crypto_box");function bi(m,E,y,f,x,N){var z=new Uint8Array(32);return Ai(z,x,N),Bs(m,E,y,f,z)}c(bi,"crypto_box_open");var xi=[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 te(m,E,y,f){for(var x=new Int32Array(16),N=new Int32Array(16),z,ne,ce,ye,pe,gt,_e,Ue,Le,Ge,Ke,ze,Ve,Me,Ee,Ie,ge,Ae,be,de,Q,V,se,re,ie,ae,ke=m[0],Ze=m[1],et=m[2],Ye=m[3],S=m[4],nt=m[5],mt=m[6],_t=m[7],rt=E[0],ft=E[1],dt=E[2],Yt=E[3],vt=E[4],Wt=E[5],qt=E[6],Qt=E[7],or=0;f>=128;){for(be=0;be<16;be++)de=8*be+or,x[be]=y[de+0]<<24|y[de+1]<<16|y[de+2]<<8|y[de+3],N[be]=y[de+4]<<24|y[de+5]<<16|y[de+6]<<8|y[de+7];for(be=0;be<80;be++)if(z=ke,ne=Ze,ce=et,ye=Ye,pe=S,gt=nt,_e=mt,Ue=_t,Le=rt,Ge=ft,Ke=dt,ze=Yt,Ve=vt,Me=Wt,Ee=qt,Ie=Qt,Q=_t,V=Qt,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=(S>>>14|vt<<18)^(S>>>18|vt<<14)^(vt>>>9|S<<23),V=(vt>>>14|S<<18)^(vt>>>18|S<<14)^(S>>>9|vt<<23),se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,Q=S&nt^~S&mt,V=vt&Wt^~vt&qt,se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,Q=xi[be*2],V=xi[be*2+1],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,Q=x[be%16],V=N[be%16],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,ge=ie&65535|ae<<16,Ae=se&65535|re<<16,Q=ge,V=Ae,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=(ke>>>28|rt<<4)^(rt>>>2|ke<<30)^(rt>>>7|ke<<25),V=(rt>>>28|ke<<4)^(ke>>>2|rt<<30)^(ke>>>7|rt<<25),se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,Q=ke&Ze^ke&et^Ze&et,V=rt&ft^rt&dt^ft&dt,se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,Ue=ie&65535|ae<<16,Ie=se&65535|re<<16,Q=ye,V=ze,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=ge,V=Ae,se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,ye=ie&65535|ae<<16,ze=se&65535|re<<16,Ze=z,et=ne,Ye=ce,S=ye,nt=pe,mt=gt,_t=_e,ke=Ue,ft=Le,dt=Ge,Yt=Ke,vt=ze,Wt=Ve,qt=Me,Qt=Ee,rt=Ie,be%16===15)for(de=0;de<16;de++)Q=x[de],V=N[de],se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=x[(de+9)%16],V=N[(de+9)%16],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,ge=x[(de+1)%16],Ae=N[(de+1)%16],Q=(ge>>>1|Ae<<31)^(ge>>>8|Ae<<24)^ge>>>7,V=(Ae>>>1|ge<<31)^(Ae>>>8|ge<<24)^(Ae>>>7|ge<<25),se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,ge=x[(de+14)%16],Ae=N[(de+14)%16],Q=(ge>>>19|Ae<<13)^(Ae>>>29|ge<<3)^ge>>>6,V=(Ae>>>19|ge<<13)^(ge>>>29|Ae<<3)^(Ae>>>6|ge<<26),se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,x[de]=ie&65535|ae<<16,N[de]=se&65535|re<<16;Q=ke,V=rt,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=m[0],V=E[0],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[0]=ke=ie&65535|ae<<16,E[0]=rt=se&65535|re<<16,Q=Ze,V=ft,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=m[1],V=E[1],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[1]=Ze=ie&65535|ae<<16,E[1]=ft=se&65535|re<<16,Q=et,V=dt,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=m[2],V=E[2],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[2]=et=ie&65535|ae<<16,E[2]=dt=se&65535|re<<16,Q=Ye,V=Yt,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=m[3],V=E[3],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[3]=Ye=ie&65535|ae<<16,E[3]=Yt=se&65535|re<<16,Q=S,V=vt,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=m[4],V=E[4],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[4]=S=ie&65535|ae<<16,E[4]=vt=se&65535|re<<16,Q=nt,V=Wt,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=m[5],V=E[5],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[5]=nt=ie&65535|ae<<16,E[5]=Wt=se&65535|re<<16,Q=mt,V=qt,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=m[6],V=E[6],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[6]=mt=ie&65535|ae<<16,E[6]=qt=se&65535|re<<16,Q=_t,V=Qt,se=V&65535,re=V>>>16,ie=Q&65535,ae=Q>>>16,Q=m[7],V=E[7],se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,re+=se>>>16,ie+=re>>>16,ae+=ie>>>16,m[7]=_t=ie&65535|ae<<16,E[7]=Qt=se&65535|re<<16,or+=128,f-=128}return f}c(te,"crypto_hashblocks_hl");function fe(m,E,y){var f=new Int32Array(8),x=new Int32Array(8),N=new Uint8Array(256),z,ne=y;for(f[0]=1779033703,f[1]=3144134277,f[2]=1013904242,f[3]=2773480762,f[4]=1359893119,f[5]=2600822924,f[6]=528734635,f[7]=1541459225,x[0]=4089235720,x[1]=2227873595,x[2]=4271175723,x[3]=1595750129,x[4]=2917565137,x[5]=725511199,x[6]=4215389547,x[7]=327033209,te(f,x,E,y),y%=128,z=0;z<y;z++)N[z]=E[ne-y+z];for(N[y]=128,y=256-128*(y<112?1:0),N[y-9]=0,h(N,y-8,ne/536870912|0,ne<<3),te(f,x,N,y),z=0;z<8;z++)h(m,8*z,f[z],x[z]);return 0}c(fe,"crypto_hash");function ve(m,E){var y=e(),f=e(),x=e(),N=e(),z=e(),ne=e(),ce=e(),ye=e(),pe=e();me(y,m[1],m[0]),me(pe,E[1],E[0]),he(y,y,pe),ue(f,m[0],m[1]),ue(pe,E[0],E[1]),he(f,f,pe),he(x,m[3],E[3]),he(x,x,l),he(N,m[2],E[2]),ue(N,N,N),me(z,f,y),me(ne,N,x),ue(ce,N,x),ue(ye,f,y),he(m[0],z,ne),he(m[1],ye,ce),he(m[2],ce,ne),he(m[3],z,ye)}c(ve,"add");function De(m,E,y){var f;for(f=0;f<4;f++)ee(m[f],E[f],y)}c(De,"cswap");function ut(m,E){var y=e(),f=e(),x=e();Ct(x,E[2]),he(y,E[0],x),he(f,E[1],x),C(m,f),m[31]^=q(y)<<7}c(ut,"pack");function Jt(m,E,y){var f,x;for(B(m[0],o),B(m[1],s),B(m[2],s),B(m[3],o),x=255;x>=0;--x)f=y[x/8|0]>>(x&7)&1,De(m,E,f),ve(E,m),ve(m,m),De(m,E,f)}c(Jt,"scalarmult");function Yr(m,E){var y=[e(),e(),e(),e()];B(y[0],d),B(y[1],p),B(y[2],s),he(y[3],d,p),Jt(m,y,E)}c(Yr,"scalarbase");function kr(m,E,y){var f=new Uint8Array(64),x=[e(),e(),e(),e()],N;for(y||r(E,32),fe(f,E,32),f[0]&=248,f[31]&=127,f[31]|=64,Yr(x,f),ut(m,x),N=0;N<32;N++)E[N+32]=m[N];return 0}c(kr,"crypto_sign_keypair");var Ii=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 xt(m,E){var y,f,x,N;for(f=63;f>=32;--f){for(y=0,x=f-32,N=f-12;x<N;++x)E[x]+=y-16*E[f]*Ii[x-(f-32)],y=E[x]+128>>8,E[x]-=y*256;E[x]+=y,E[f]=0}for(y=0,x=0;x<32;x++)E[x]+=y-(E[31]>>4)*Ii[x],y=E[x]>>8,E[x]&=255;for(x=0;x<32;x++)E[x]-=y*Ii[x];for(f=0;f<32;f++)E[f+1]+=E[f]>>8,m[f]=E[f]&255}c(xt,"modL");function sr(m){var E=new Float64Array(64),y;for(y=0;y<64;y++)E[y]=m[y];for(y=0;y<64;y++)m[y]=0;xt(m,E)}c(sr,"reduce");function ir(m,E,y,f){var x=new Uint8Array(64),N=new Uint8Array(64),z=new Uint8Array(64),ne,ce,ye=new Float64Array(64),pe=[e(),e(),e(),e()];fe(x,f,32),x[0]&=248,x[31]&=127,x[31]|=64;var gt=y+64;for(ne=0;ne<y;ne++)m[64+ne]=E[ne];for(ne=0;ne<32;ne++)m[32+ne]=x[32+ne];for(fe(z,m.subarray(32),y+32),sr(z),Yr(pe,z),ut(m,pe),ne=32;ne<64;ne++)m[ne]=f[ne];for(fe(N,m,y+64),sr(N),ne=0;ne<64;ne++)ye[ne]=0;for(ne=0;ne<32;ne++)ye[ne]=z[ne];for(ne=0;ne<32;ne++)for(ce=0;ce<32;ce++)ye[ne+ce]+=N[ne]*x[ce];return xt(m.subarray(32),ye),gt}c(ir,"crypto_sign");function Ht(m,E){var y=e(),f=e(),x=e(),N=e(),z=e(),ne=e(),ce=e();return B(m[2],s),J(m[1],E),bt(x,m[1]),he(N,x,u),me(x,x,m[2]),ue(N,m[2],N),bt(z,N),bt(ne,z),he(ce,ne,z),he(y,ce,x),he(y,y,N),Xt(y,y),he(y,y,x),he(y,y,N),he(y,y,N),he(m[0],y,N),bt(f,m[0]),he(f,f,N),W(f,x)&&he(m[0],m[0],g),bt(f,m[0]),he(f,f,N),W(f,x)?-1:(q(m[0])===E[31]>>7&&me(m[0],o,m[0]),he(m[3],m[0],m[1]),0)}c(Ht,"unpackneg");function Pt(m,E,y,f){var x,N,z=new Uint8Array(32),ne=new Uint8Array(64),ce=[e(),e(),e(),e()],ye=[e(),e(),e(),e()];if(N=-1,y<64||Ht(ye,f))return-1;for(x=0;x<y;x++)m[x]=E[x];for(x=0;x<32;x++)m[x+32]=f[x];if(fe(ne,m,y),sr(ne),Jt(ce,ye,ne),Yr(ye,E.subarray(32)),ve(ce,ye),ut(z,ce),y-=64,b(E,0,z,0)){for(x=0;x<y;x++)m[x]=0;return-1}for(x=0;x<y;x++)m[x]=E[x+64];return N=y,N}c(Pt,"crypto_sign_open");var Br=32,jt=24,Jn=32,vi=16,_o=32,Us=32,yo=32,Eo=32,kc=32,cd=jt,ME=Jn,FE=vi,ln=64,ei=32,Si=64,Cc=32,Rc=64;t.lowlevel={crypto_core_hsalsa20:$,crypto_stream_xor:k,crypto_stream:P,crypto_stream_salsa20_xor:Z,crypto_stream_salsa20:Y,crypto_onetimeauth:L,crypto_onetimeauth_verify:T,crypto_verify_16:A,crypto_verify_32:b,crypto_secretbox:F,crypto_secretbox_open:j,crypto_scalarmult:yr,crypto_scalarmult_base:Dr,crypto_box_beforenm:Ai,crypto_box_afternm:go,crypto_box:mo,crypto_box_open:bi,crypto_box_keypair:vr,crypto_hash:fe,crypto_sign:ir,crypto_sign_keypair:kr,crypto_sign_open:Pt,crypto_secretbox_KEYBYTES:Br,crypto_secretbox_NONCEBYTES:jt,crypto_secretbox_ZEROBYTES:Jn,crypto_secretbox_BOXZEROBYTES:vi,crypto_scalarmult_BYTES:_o,crypto_scalarmult_SCALARBYTES:Us,crypto_box_PUBLICKEYBYTES:yo,crypto_box_SECRETKEYBYTES:Eo,crypto_box_BEFORENMBYTES:kc,crypto_box_NONCEBYTES:cd,crypto_box_ZEROBYTES:ME,crypto_box_BOXZEROBYTES:FE,crypto_sign_BYTES:ln,crypto_sign_PUBLICKEYBYTES:ei,crypto_sign_SECRETKEYBYTES:Si,crypto_sign_SEEDBYTES:Cc,crypto_hash_BYTES:Rc};function ud(m,E){if(m.length!==Br)throw new Error("bad key size");if(E.length!==jt)throw new Error("bad nonce size")}c(ud,"checkLengths");function HE(m,E){if(m.length!==yo)throw new Error("bad public key size");if(E.length!==Eo)throw new Error("bad secret key size")}c(HE,"checkBoxLengths");function Cr(){var m,E;for(E=0;E<arguments.length;E++)if((m=Object.prototype.toString.call(arguments[E]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+m+", use Uint8Array")}c(Cr,"checkArrayTypes");function ld(m){for(var E=0;E<m.length;E++)m[E]=0}c(ld,"cleanup"),t.util||(t.util={},t.util.decodeUTF8=t.util.encodeUTF8=t.util.encodeBase64=t.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),t.randomBytes=function(m){var E=new Uint8Array(m);return r(E,m),E},t.secretbox=function(m,E,y){Cr(m,E,y),ud(y,E);for(var f=new Uint8Array(Jn+m.length),x=new Uint8Array(f.length),N=0;N<m.length;N++)f[N+Jn]=m[N];return F(x,f,f.length,E,y),x.subarray(vi)},t.secretbox.open=function(m,E,y){Cr(m,E,y),ud(y,E);for(var f=new Uint8Array(vi+m.length),x=new Uint8Array(f.length),N=0;N<m.length;N++)f[N+vi]=m[N];return f.length<32||j(x,f,f.length,E,y)!==0?!1:x.subarray(Jn)},t.secretbox.keyLength=Br,t.secretbox.nonceLength=jt,t.secretbox.overheadLength=vi,t.scalarMult=function(m,E){if(Cr(m,E),m.length!==Us)throw new Error("bad n size");if(E.length!==_o)throw new Error("bad p size");var y=new Uint8Array(_o);return yr(y,m,E),y},t.scalarMult.base=function(m){if(Cr(m),m.length!==Us)throw new Error("bad n size");var E=new Uint8Array(_o);return Dr(E,m),E},t.scalarMult.scalarLength=Us,t.scalarMult.groupElementLength=_o,t.box=function(m,E,y,f){var x=t.box.before(y,f);return t.secretbox(m,E,x)},t.box.before=function(m,E){Cr(m,E),HE(m,E);var y=new Uint8Array(kc);return Ai(y,m,E),y},t.box.after=t.secretbox,t.box.open=function(m,E,y,f){var x=t.box.before(y,f);return t.secretbox.open(m,E,x)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var m=new Uint8Array(yo),E=new Uint8Array(Eo);return vr(m,E),{publicKey:m,secretKey:E}},t.box.keyPair.fromSecretKey=function(m){if(Cr(m),m.length!==Eo)throw new Error("bad secret key size");var E=new Uint8Array(yo);return Dr(E,m),{publicKey:E,secretKey:new Uint8Array(m)}},t.box.publicKeyLength=yo,t.box.secretKeyLength=Eo,t.box.sharedKeyLength=kc,t.box.nonceLength=cd,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(m,E){if(Cr(m,E),E.length!==Si)throw new Error("bad secret key size");var y=new Uint8Array(ln+m.length);return ir(y,m,m.length,E),y},t.sign.open=function(m,E){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(Cr(m,E),E.length!==ei)throw new Error("bad public key size");var y=new Uint8Array(m.length),f=Pt(y,m,m.length,E);if(f<0)return null;for(var x=new Uint8Array(f),N=0;N<x.length;N++)x[N]=y[N];return x},t.sign.detached=function(m,E){for(var y=t.sign(m,E),f=new Uint8Array(ln),x=0;x<f.length;x++)f[x]=y[x];return f},t.sign.detached.verify=function(m,E,y){if(Cr(m,E,y),E.length!==ln)throw new Error("bad signature size");if(y.length!==ei)throw new Error("bad public key size");var f=new Uint8Array(ln+m.length),x=new Uint8Array(ln+m.length),N;for(N=0;N<ln;N++)f[N]=E[N];for(N=0;N<m.length;N++)f[N+ln]=m[N];return Pt(x,f,f.length,y)>=0},t.sign.keyPair=function(){var m=new Uint8Array(ei),E=new Uint8Array(Si);return kr(m,E),{publicKey:m,secretKey:E}},t.sign.keyPair.fromSecretKey=function(m){if(Cr(m),m.length!==Si)throw new Error("bad secret key size");for(var E=new Uint8Array(ei),y=0;y<E.length;y++)E[y]=m[32+y];return{publicKey:E,secretKey:new Uint8Array(m)}},t.sign.keyPair.fromSeed=function(m){if(Cr(m),m.length!==Cc)throw new Error("bad seed size");for(var E=new Uint8Array(ei),y=new Uint8Array(Si),f=0;f<32;f++)y[f]=m[f];return kr(E,y,!0),{publicKey:E,secretKey:y}},t.sign.publicKeyLength=ei,t.sign.secretKeyLength=Si,t.sign.seedLength=Cc,t.sign.signatureLength=ln,t.hash=function(m){Cr(m);var E=new Uint8Array(Rc);return fe(E,m,m.length),E},t.hash.hashLength=Rc,t.verify=function(m,E){return Cr(m,E),m.length===0||E.length===0||m.length!==E.length?!1:_(m,0,E,0,m.length)===0},t.setPRNG=function(m){r=m},(function(){var m=typeof self<"u"?self.crypto||self.msCrypto:null;if(m&&m.getRandomValues){var E=65536;t.setPRNG(function(y,f){var x,N=new Uint8Array(f);for(x=0;x<f;x+=E)m.getRandomValues(N.subarray(x,x+Math.min(f-x,E)));for(x=0;x<f;x++)y[x]=N[x];ld(N)})}else typeof require<"u"&&(m=require("crypto"),m&&m.randomBytes&&t.setPRNG(function(y,f){var x,N=m.randomBytes(f);for(x=0;x<f;x++)y[x]=N[x];ld(N)}))})()})(typeof Ia<"u"&&Ia.exports?Ia.exports:self.nacl=self.nacl||{})});var zu=le((W3,fg)=>{"use strict";var Bu=lg().lowlevel.crypto_hash,yn=0,ai=c(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])},"Blowfish");function Sa(t,e,r){return(t[0][e[r+3]]+t[1][e[r+2]]^t[2][e[r+1]])+t[3][e[r]]}c(Sa,"F");ai.prototype.encipher=function(t,e){e===void 0&&(e=new Uint8Array(t.buffer),t.byteOffset!==0&&(e=e.subarray(t.byteOffset))),t[0]^=this.P[0];for(var r=1;r<16;r+=2)t[1]^=Sa(this.S,e,0)^this.P[r],t[0]^=Sa(this.S,e,4)^this.P[r+1];var n=t[0];t[0]=t[1]^this.P[17],t[1]=n};ai.prototype.decipher=function(t){var e=new Uint8Array(t.buffer);t.byteOffset!==0&&(e=e.subarray(t.byteOffset)),t[0]^=this.P[17];for(var r=16;r>0;r-=2)t[1]^=Sa(this.S,e,0)^this.P[r],t[0]^=Sa(this.S,e,4)^this.P[r-1];var n=t[0];t[0]=t[1]^this.P[0],t[1]=n};function si(t,e){var r,n=0;for(r=0;r<4;r++,yn++)yn>=e&&(yn=0),n=n<<8|t[yn];return n}c(si,"stream2word");ai.prototype.expand0state=function(t,e){var r=new Uint32Array(2),n,i,o=new Uint8Array(r.buffer);for(n=0,yn=0;n<18;n++)this.P[n]^=si(t,e);for(yn=0,n=0;n<18;n+=2)this.encipher(r,o),this.P[n]=r[0],this.P[n+1]=r[1];for(n=0;n<4;n++)for(i=0;i<256;i+=2)this.encipher(r,o),this.S[n][i]=r[0],this.S[n][i+1]=r[1]};ai.prototype.expandstate=function(t,e,r,n){var i=new Uint32Array(2),o,s;for(o=0,yn=0;o<18;o++)this.P[o]^=si(r,n);for(o=0,yn=0;o<18;o+=2)i[0]^=si(t,e),i[1]^=si(t,e),this.encipher(i),this.P[o]=i[0],this.P[o+1]=i[1];for(o=0;o<4;o++)for(s=0;s<256;s+=2)i[0]^=si(t,e),i[1]^=si(t,e),this.encipher(i),this.S[o][s]=i[0],this.S[o][s+1]=i[1];yn=0};ai.prototype.enc=function(t,e){for(var r=0;r<e;r++)this.encipher(t.subarray(r*2))};ai.prototype.dec=function(t,e){for(var r=0;r<e;r++)this.decipher(t.subarray(r*2))};var va=8,Uu=32;function Lu(t,e,r){var n=new ai,i=new Uint32Array(va),o,s=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(n.expandstate(e,64,t,64),o=0;o<64;o++)n.expand0state(e,64),n.expand0state(t,64);for(o=0;o<va;o++)i[o]=si(s,s.byteLength);for(o=0;o<64;o++)n.enc(i,i.byteLength/8);for(o=0;o<va;o++)r[4*o+3]=i[o]>>>24,r[4*o+2]=i[o]>>>16,r[4*o+1]=i[o]>>>8,r[4*o+0]=i[o]}c(Lu,"bcrypt_hash");function Rx(t,e,r,n,i,o,s){var a=new Uint8Array(64),u=new Uint8Array(64),l=new Uint8Array(Uu),d=new Uint8Array(Uu),p=new Uint8Array(n+4),g,h,_,A,b,I,w=o;if(s<1||e===0||n===0||o===0||o>l.byteLength*l.byteLength||n>1<<20)return-1;for(A=Math.floor((o+l.byteLength-1)/l.byteLength),_=Math.floor((o+A-1)/A),g=0;g<n;g++)p[g]=r[g];for(Bu(a,t,e),I=1;o>0;I++){for(p[n+0]=I>>>24,p[n+1]=I>>>16,p[n+2]=I>>>8,p[n+3]=I,Bu(u,p,n+4),Lu(a,u,d),g=l.byteLength;g--;)l[g]=d[g];for(g=1;g<s;g++)for(Bu(u,d,d.byteLength),Lu(a,u,d),h=0;h<l.byteLength;h++)l[h]^=d[h];for(_=Math.min(_,o),g=0;g<_&&(b=g*A+(I-1),!(b>=w));g++)i[b]=l[g];o-=g}return 0}c(Rx,"bcrypt_pbkdf");fg.exports={BLOCKS:va,HASHSIZE:Uu,hash:Lu,pbkdf:Rx}});var An=le((Q3,Pa)=>{"use strict";var En=require("crypto"),Vi;try{Vi=require("cpu-features")()}catch{}var{bindingAvailable:dg,CIPHER_INFO:Nx,MAC_INFO:Ox}=zn(),pg=(()=>{if(typeof En.sign=="function"&&typeof En.verify=="function"){let t=`-----BEGIN PRIVATE KEY-----\r
7
7
  MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
8
- -----END PRIVATE KEY-----`,e=Buffer.from("a"),r,n;try{r=yn.sign(null,e,t),n=yn.verify(null,e,t,r)}catch{}return Buffer.isBuffer(r)&&r.length===64&&n===!0}return!1})(),ug=typeof yn.diffieHellman=="function"&&typeof yn.generateKeyPairSync=="function"&&typeof yn.createPublicKey=="function",Sa=["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"];ug&&(Sa.unshift("curve25519-sha256"),Sa.unshift("curve25519-sha256@libssh.org"));var Ex=Sa.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),zu=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];cg&&zu.unshift("ssh-ed25519");var bx=zu.concat(["ssh-dss"]),lg=(()=>{let t=yn.getCiphers();return e=>t.includes(yx[e].sslName)})(),Un=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Qi&&Qi.flags&&!Qi.flags.aes?ag?Un.unshift("chacha20-poly1305@openssh.com"):Un.push("chacha20-poly1305@openssh.com"):ag&&Qi&&Qi.arch==="x86"?Un.splice(4,0,"chacha20-poly1305@openssh.com"):Un.push("chacha20-poly1305@openssh.com");Un=Un.filter(lg);var xx=Un.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(lg)),fg=(()=>{let t=yn.getHashes();return e=>t.includes(Ax[e].sslName)})(),dg=["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(fg),Ix=dg.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(fg)),pg=["none","zlib@openssh.com","zlib"],vx=pg.concat([]),qi={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};wa.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((t,e)=>({...t,[e]:1}),{}),COMPAT:qi,COMPAT_CHECKS:[["Cisco-1.25",qi.BAD_DHGEX],[/^Cisco-1[.]/,qi.BUG_DHGEX_LARGE],[/^[0-9.]+$/,qi.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,qi.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,qi.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:Sa,SUPPORTED_KEX:Ex,DEFAULT_SERVER_HOST_KEY:zu,SUPPORTED_SERVER_HOST_KEY:bx,DEFAULT_CIPHER:Un,SUPPORTED_CIPHER:xx,DEFAULT_MAC:dg,SUPPORTED_MAC:Ix,DEFAULT_COMPRESSION:pg,SUPPORTED_COMPRESSION:vx,curve25519Supported:ug,eddsaSupported:cg};wa.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(wa.exports.DISCONNECT_REASON)).reduce((t,[e,r])=>({...t,[r]:e}),{})});var Qr=le((k3,_g)=>{"use strict";var Mr=Ko().Ber,Pa,mg=Buffer[Symbol.species],Sx=Object.getPrototypeOf(Uint8Array.prototype).fill;function hg(t,e){return t[e++]*16777216+t[e++]*65536+t[e++]*256+t[e]}c(hg,"readUInt32BE");function Vo(t,e,r,n,i){i||(i=0),n>t.length&&(n=t.length);let o=n-r,s=e.length-i;return o>s&&(o=s),e.set(new Uint8Array(t.buffer,t.byteOffset+r,o),i),o}c(Vo,"bufferCopy");function Go(t,e,r){return r===void 0&&(r=t.length),new mg(t.buffer,t.byteOffset+e,r-e)}c(Go,"bufferSlice");function Fu(){let t=0,e,r={init:c((n,i)=>{e=n,t=typeof i=="number"?i:0},"init"),pos:c(()=>t,"pos"),length:c(()=>e?e.length:0,"length"),avail:c(()=>e&&t<e.length?e.length-t:0,"avail"),clear:c(()=>{e=void 0},"clear"),readUInt32BE:c(()=>{if(!(!e||t+3>=e.length))return e[t++]*16777216+e[t++]*65536+e[t++]*256+e[t++]},"readUInt32BE"),readUInt64BE:c(n=>{if(!(!e||t+7>=e.length))switch(n){case"always":return BigInt(`0x${e.hexSlice(t,t+=8)}`);case"maybe":if(e[t]>31)return BigInt(`0x${e.hexSlice(t,t+=8)}`);default:return e[t++]*72057594037927940+e[t++]*281474976710656+e[t++]*1099511627776+e[t++]*4294967296+e[t++]*16777216+e[t++]*65536+e[t++]*256+e[t++]}},"readUInt64BE"),skip:c(n=>{e&&n>0&&(t+=n)},"skip"),skipString:c(()=>{let n=r.readUInt32BE();if(n!==void 0)return t+=n,t<=e.length?n:void 0},"skipString"),readByte:c(()=>{if(e&&t<e.length)return e[t++]},"readByte"),readBool:c(()=>{if(e&&t<e.length)return!!e[t++]},"readBool"),readList:c(()=>{let n=r.readString(!0);if(n!==void 0)return n?n.split(","):[]},"readList"),readString:c((n,i)=>{typeof n=="number"&&(i=n,n=void 0);let o=r.readUInt32BE();if(o!==void 0&&!(e.length-t<o||typeof i=="number"&&o>i))return n?Buffer.isBuffer(n)?Vo(e,n,t,t+=o):e.utf8Slice(t,t+=o):Go(e,t,t+=o)},"readString"),readRaw:c(n=>{if(e){if(typeof n!="number")return Go(e,t,t+=e.length-t);if(e.length-t>=n)return Go(e,t,t+=n)}},"readRaw")};return r}c(Fu,"makeBufferParser");function gg(t,e,r){let n=new Error(t);return typeof e=="boolean"?(r=e,n.level="protocol"):n.level=e||"protocol",n.fatal=!!r,n}c(gg,"makeError");function Mu(t,e,r){return t[r++]=e>>>24,t[r++]=e>>>16,t[r++]=e>>>8,t[r++]=e,r}c(Mu,"writeUInt32BE");var Ta=Fu();_g.exports={bufferCopy:Vo,bufferSlice:Go,FastBuffer:mg,bufferFill:c((t,e,r,n)=>Sx.call(t,e,r,n),"bufferFill"),makeError:gg,doFatalError:c((t,e,r,n)=>{let i;return Pa===void 0&&({DISCONNECT_REASON:Pa}=An()),e instanceof Error?(i=e,typeof r!="number"?n=Pa.PROTOCOL_ERROR:n=r):i=gg(e,r,!0),typeof n!="number"&&(n=Pa.PROTOCOL_ERROR),t.disconnect(n),t._destruct(),t._onError(i),1/0},"doFatalError"),readUInt32BE:hg,writeUInt32BE:Mu,writeUInt32LE:c((t,e,r)=>(t[r++]=e,t[r++]=e>>>8,t[r++]=e>>>16,t[r++]=e>>>24,r),"writeUInt32LE"),makeBufferParser:Fu,bufferParser:Fu(),readString:c((t,e,r,n)=>{typeof r=="number"&&(n=r,r=void 0),e===void 0&&(e=0);let i=t.length-e;if(e<0||e>=t.length||i<4)return;let o=hg(t,e);if(i<4+o||typeof n=="number"&&o>n)return;e+=4;let s=e+o;return t._pos=s,r?Buffer.isBuffer(r)?Vo(t,r,e,s):t.utf8Slice(e,s):Go(t,e,s)},"readString"),sigSSHToASN1:c((t,e)=>{switch(e){case"ssh-dss":{if(t.length>40)return t;let r=new Mr.Writer;r.startSequence();let n=t.slice(0,20),i=t.slice(20);if(n[0]&128){let o=Buffer.allocUnsafe(21);o[0]=0,n.copy(o,1),n=o}else n[0]===0&&!(n[1]&128)&&(n=n.slice(1));if(i[0]&128){let o=Buffer.allocUnsafe(21);o[0]=0,i.copy(o,1),i=o}else i[0]===0&&!(i[1]&128)&&(i=i.slice(1));return r.writeBuffer(n,Mr.Integer),r.writeBuffer(i,Mr.Integer),r.endSequence(),r.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{Ta.init(t,0);let r=Ta.readString(),n=Ta.readString();if(Ta.clear(),r===void 0||n===void 0)return;let i=new Mr.Writer;return i.startSequence(),i.writeBuffer(r,Mr.Integer),i.writeBuffer(n,Mr.Integer),i.endSequence(),i.buffer}default:return t}},"sigSSHToASN1"),convertSignature:c((t,e)=>{switch(e){case"ssh-dss":{if(t.length<=40)return t;let r=new Mr.Reader(t);r.readSequence();let n=r.readString(Mr.Integer,!0),i=r.readString(Mr.Integer,!0),o=0,s=0;if(n.length<20){let u=Buffer.allocUnsafe(20);u.set(n,1),n=u,n[0]=0}if(i.length<20){let u=Buffer.allocUnsafe(20);u.set(i,1),i=u,i[0]=0}n.length>20&&n[0]===0&&(o=1),i.length>20&&i[0]===0&&(s=1);let a=Buffer.allocUnsafe(n.length-o+(i.length-s));return Vo(n,a,o,n.length,0),Vo(i,a,s,i.length,n.length-o),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(t[0]===0)return t;let r=new Mr.Reader(t);r.readSequence();let n=r.readString(Mr.Integer,!0),i=r.readString(Mr.Integer,!0);if(n===null||i===null)return;let o=Buffer.allocUnsafe(4+n.length+4+i.length);return Mu(o,n.length,0),o.set(n,4),Mu(o,i.length,4+n.length),o.set(i,8+n.length),o}}return t},"convertSignature"),sendPacket:c((t,e,r)=>!r&&t._kexinit!==void 0?(t._queue===void 0&&(t._queue=[]),t._queue.push(e),t._debug&&t._debug("Outbound: ... packet queued"),!1):(t._cipher.encrypt(e),!0),"sendPacket")}});var yg=le((ka,ju)=>{var Hu=(function(){var t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(t=t||__filename),(function(e){e=e||{};var r;r||(r=typeof e<"u"?e:{});var n,i;r.ready=new Promise(function(te,fe){n=te,i=fe});var o={},s;for(s in r)r.hasOwnProperty(s)&&(o[s]=r[s]);var a=typeof window=="object",u=typeof importScripts=="function",l=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",d="",p,g,h,_,E;l?(d=u?require("path").dirname(d)+"/":__dirname+"/",p=c(function(te,fe){var ve=vr(te);return ve?fe?ve:ve.toString():(_||(_=require("fs")),E||(E=require("path")),te=E.normalize(te),_.readFileSync(te,fe?null:"utf8"))},"C"),h=c(function(te){return te=p(te,!0),te.buffer||(te=new Uint8Array(te)),X(te.buffer),te},"E"),g=c(function(te,fe,ve){var De=vr(te);De&&fe(De),_||(_=require("fs")),E||(E=require("path")),te=E.normalize(te),_.readFile(te,function(ut,Jt){ut?ve(ut):fe(Jt.buffer)})},"D"),1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),r.inspect=function(){return"[Emscripten Module object]"}):(a||u)&&(u?d=self.location.href:typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),t&&(d=t),d.indexOf("blob:")!==0?d=d.substr(0,d.lastIndexOf("/")+1):d="",p=c(function(te){try{var fe=new XMLHttpRequest;return fe.open("GET",te,!1),fe.send(null),fe.responseText}catch(ut){if(te=vr(te)){fe=[];for(var ve=0;ve<te.length;ve++){var De=te[ve];255<De&&(yr&&X(!1,"Character code "+De+" ("+String.fromCharCode(De)+") at offset "+ve+" not in 0x00-0xFF."),De&=255),fe.push(String.fromCharCode(De))}return fe.join("")}throw ut}},"C"),u&&(h=c(function(te){try{var fe=new XMLHttpRequest;return fe.open("GET",te,!1),fe.responseType="arraybuffer",fe.send(null),new Uint8Array(fe.response)}catch(ve){if(te=vr(te))return te;throw ve}},"E")),g=c(function(te,fe,ve){var De=new XMLHttpRequest;De.open("GET",te,!0),De.responseType="arraybuffer",De.onload=function(){if(De.status==200||De.status==0&&De.response)fe(De.response);else{var ut=vr(te);ut?fe(ut.buffer):ve()}},De.onerror=ve,De.send(null)},"D")),r.print||console.log.bind(console);var b=r.printErr||console.warn.bind(console);for(s in o)o.hasOwnProperty(s)&&(r[s]=o[s]);o=null;var I;r.wasmBinary&&(I=r.wasmBinary);var w=r.noExitRuntime||!0;typeof WebAssembly!="object"&&J("no native wasm support detected");var H,$=!1;function X(te,fe){te||J("Assertion failed: "+fe)}c(X,"assert");function Z(te){var fe=r["_"+te];return X(fe,"Cannot call unknown function "+te+", make sure it is exported"),fe}c(Z,"N");function Y(te,fe,ve,De){var ut={string:c(function(xt){var sr=0;if(xt!=null&&xt!==0){var ir=(xt.length<<2)+1;sr=go(ir);var Ht=sr,Pt=L;if(0<ir){ir=Ht+ir-1;for(var Br=0;Br<xt.length;++Br){var jt=xt.charCodeAt(Br);if(55296<=jt&&57343>=jt){var Xn=xt.charCodeAt(++Br);jt=65536+((jt&1023)<<10)|Xn&1023}if(127>=jt){if(Ht>=ir)break;Pt[Ht++]=jt}else{if(2047>=jt){if(Ht+1>=ir)break;Pt[Ht++]=192|jt>>6}else{if(65535>=jt){if(Ht+2>=ir)break;Pt[Ht++]=224|jt>>12}else{if(Ht+3>=ir)break;Pt[Ht++]=240|jt>>18,Pt[Ht++]=128|jt>>12&63}Pt[Ht++]=128|jt>>6&63}Pt[Ht++]=128|jt&63}}Pt[Ht]=0}}return sr},"string"),array:c(function(xt){var sr=go(xt.length);return M.set(xt,sr),sr},"array")},Jt=Z(te),Yr=[];if(te=0,De)for(var kr=0;kr<De.length;kr++){var xi=ut[ve[kr]];xi?(te===0&&(te=ho()),Yr[kr]=xi(De[kr])):Yr[kr]=De[kr]}return ve=Jt.apply(null,Yr),ve=(function(xt){if(fe==="string")if(xt){for(var sr=L,ir=xt+NaN,Ht=xt;sr[Ht]&&!(Ht>=ir);)++Ht;if(16<Ht-xt&&sr.subarray&&P)xt=P.decode(sr.subarray(xt,Ht));else{for(ir="";xt<Ht;){var Pt=sr[xt++];if(Pt&128){var Br=sr[xt++]&63;if((Pt&224)==192)ir+=String.fromCharCode((Pt&31)<<6|Br);else{var jt=sr[xt++]&63;Pt=(Pt&240)==224?(Pt&15)<<12|Br<<6|jt:(Pt&7)<<18|Br<<12|jt<<6|sr[xt++]&63,65536>Pt?ir+=String.fromCharCode(Pt):(Pt-=65536,ir+=String.fromCharCode(55296|Pt>>10,56320|Pt&1023))}}else ir+=String.fromCharCode(Pt)}xt=ir}}else xt="";else xt=fe==="boolean"?!!xt:xt;return xt})(ve),te!==0&&Ds(te),ve}c(Y,"ca");var P=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,k,M,L;function T(){var te=H.buffer;k=te,r.HEAP8=M=new Int8Array(te),r.HEAP16=new Int16Array(te),r.HEAP32=new Int32Array(te),r.HEAPU8=L=new Uint8Array(te),r.HEAPU16=new Uint16Array(te),r.HEAPU32=new Uint32Array(te),r.HEAPF32=new Float32Array(te),r.HEAPF64=new Float64Array(te)}c(T,"ia");var F,j=[],B=[],G=[];function ee(){var te=r.preRun.shift();j.unshift(te)}c(ee,"ma");var C=0,W=null,q=null;r.preloadedImages={},r.preloadedAudios={};function J(te){throw r.onAbort&&r.onAbort(te),b(te),$=!0,te=new WebAssembly.RuntimeError("abort("+te+"). Build with -s ASSERTIONS=1 for more info."),i(te),te}c(J,"K");var ue="data:application/octet-stream;base64,",me;if(me="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==",!me.startsWith(ue)){var he=me;me=r.locateFile?r.locateFile(he,d):d+he}function bt(){var te=me;try{if(te==me&&I)return new Uint8Array(I);var fe=vr(te);if(fe)return fe;if(h)return h(te);throw"both async and sync fetching of the wasm failed"}catch(ve){J(ve)}}c(bt,"pa");function Ct(){if(!I&&(a||u)){if(typeof fetch=="function"&&!me.startsWith("file://"))return fetch(me,{credentials:"same-origin"}).then(function(te){if(!te.ok)throw"failed to load wasm binary file at '"+me+"'";return te.arrayBuffer()}).catch(function(){return bt()});if(g)return new Promise(function(te,fe){g(me,function(ve){te(new Uint8Array(ve))},fe)})}return Promise.resolve().then(function(){return bt()})}c(Ct,"qa");function Xt(te){for(;0<te.length;){var fe=te.shift();if(typeof fe=="function")fe(r);else{var ve=fe.m;typeof ve=="number"?fe.l===void 0?F.get(ve)():F.get(ve)(fe.l):ve(fe.l===void 0?null:fe.l)}}}c(Xt,"X");var yr=!1,Dr=typeof atob=="function"?atob:function(te){var fe="",ve=0;te=te.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var De="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(te.charAt(ve++)),ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(te.charAt(ve++)),Jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(te.charAt(ve++)),Yr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(te.charAt(ve++));De=De<<2|ut>>4,ut=(ut&15)<<4|Jt>>2;var kr=(Jt&3)<<6|Yr;fe+=String.fromCharCode(De),Jt!==64&&(fe+=String.fromCharCode(ut)),Yr!==64&&(fe+=String.fromCharCode(kr))}while(ve<te.length);return fe};function vr(te){if(te.startsWith(ue)){if(te=te.slice(ue.length),typeof l=="boolean"&&l){var fe=Buffer.from(te,"base64");fe=new Uint8Array(fe.buffer,fe.byteOffset,fe.byteLength)}else try{var ve=Dr(te),De=new Uint8Array(ve.length);for(te=0;te<ve.length;++te)De[te]=ve.charCodeAt(te);fe=De}catch{throw Error("Converting base64 string to bytes failed.")}return fe}}c(vr,"H");var Ai={a:c(function(te){var fe=L.length;if(te>>>=0,2147483648<te)return!1;for(var ve=1;4>=ve;ve*=2){var De=fe*(1+.2/ve);De=Math.min(De,te+100663296),De=Math.max(te,De),0<De%65536&&(De+=65536-De%65536);e:{try{H.grow(Math.min(2147483648,De)-k.byteLength+65535>>>16),T();var ut=1;break e}catch{}ut=void 0}if(ut)return!0}return!1},"a")};(function(){function te(ut){r.asm=ut.exports,H=r.asm.b,T(),F=r.asm.j,B.unshift(r.asm.c),C--,r.monitorRunDependencies&&r.monitorRunDependencies(C),C==0&&(W!==null&&(clearInterval(W),W=null),q&&(ut=q,q=null,ut()))}c(te,"a");function fe(ut){te(ut.instance)}c(fe,"c");function ve(ut){return Ct().then(function(Jt){return WebAssembly.instantiate(Jt,De)}).then(ut,function(Jt){b("failed to asynchronously prepare wasm: "+Jt),J(Jt)})}c(ve,"d");var De={a:Ai};if(C++,r.monitorRunDependencies&&r.monitorRunDependencies(C),r.instantiateWasm)try{return r.instantiateWasm(De,te)}catch(ut){return b("Module.instantiateWasm callback failed with error: "+ut),!1}return(function(){return I||typeof WebAssembly.instantiateStreaming!="function"||me.startsWith(ue)||me.startsWith("file://")||typeof fetch!="function"?ve(fe):fetch(me,{credentials:"same-origin"}).then(function(ut){return WebAssembly.instantiateStreaming(ut,De).then(fe,function(Jt){return b("wasm streaming compile failed: "+Jt),b("falling back to ArrayBuffer instantiation"),ve(fe)})})})().catch(i),{}})(),r.___wasm_call_ctors=function(){return(r.___wasm_call_ctors=r.asm.c).apply(null,arguments)},r._poly1305_auth=function(){return(r._poly1305_auth=r.asm.d).apply(null,arguments)};var ho=r.stackSave=function(){return(ho=r.stackSave=r.asm.e).apply(null,arguments)},Ds=r.stackRestore=function(){return(Ds=r.stackRestore=r.asm.f).apply(null,arguments)},go=r.stackAlloc=function(){return(go=r.stackAlloc=r.asm.g).apply(null,arguments)};r._malloc=function(){return(r._malloc=r.asm.h).apply(null,arguments)},r._free=function(){return(r._free=r.asm.i).apply(null,arguments)},r.cwrap=function(te,fe,ve,De){ve=ve||[];var ut=ve.every(function(Jt){return Jt==="number"});return fe!=="string"&&ut&&!De?Z(te):function(){return Y(te,fe,ve,arguments)}};var Ei;q=c(function te(){Ei||bi(),Ei||(q=te)},"ta");function bi(){function te(){if(!Ei&&(Ei=!0,r.calledRun=!0,!$)){if(Xt(B),n(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;){var fe=r.postRun.shift();G.unshift(fe)}Xt(G)}}if(c(te,"a"),!(0<C)){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)ee();Xt(j),0<C||(r.setStatus?(r.setStatus("Running..."),setTimeout(function(){setTimeout(function(){r.setStatus("")},1),te()},1)):te())}}if(c(bi,"Z"),r.run=bi,r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);0<r.preInit.length;)r.preInit.pop()();return bi(),e.ready})})();typeof ka=="object"&&typeof ju=="object"?ju.exports=Hu:typeof define=="function"&&define.amd?define([],function(){return Hu}):typeof ka=="object"&&(ka.createPoly1305=Hu)});var Ln=le((N3,Ig)=>{"use strict";var{createCipheriv:Vi,createDecipheriv:Ca,createHmac:Wu,randomFillSync:ai,timingSafeEqual:qu}=require("crypto"),{readUInt32BE:Yo,writeUInt32BE:Or}=Qr(),zn=Buffer[Symbol.species],Ag=2**32-1,Eg=Buffer.alloc(0),Ki=Buffer.alloc(4),Ra=new Map,ci=35e3,Qu,al,cl,ul,ll,fl,dl;try{Qu=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:al,ChaChaPolyCipher:cl,GenericCipher:ul,AESGCMDecipher:ll,ChaChaPolyDecipher:fl,GenericDecipher:dl}=Qu}catch{}var ur=1,wx=(()=>{function t(e,r,n,i,o,s,a){return{sslName:e,blockLen:r,keyLen:n,ivLen:i!==0||a&ur?i:r,authLen:o,discardLen:s,stream:!!(a&ur)}}return c(t,"info"),{"chacha20-poly1305@openssh.com":t("chacha20",8,64,0,16,0,ur),"aes128-gcm":t("aes-128-gcm",16,16,12,16,0,ur),"aes256-gcm":t("aes-256-gcm",16,32,12,16,0,ur),"aes128-gcm@openssh.com":t("aes-128-gcm",16,16,12,16,0,ur),"aes256-gcm@openssh.com":t("aes-256-gcm",16,32,12,16,0,ur),"aes128-cbc":t("aes-128-cbc",16,16,0,0,0,0),"aes192-cbc":t("aes-192-cbc",16,24,0,0,0,0),"aes256-cbc":t("aes-256-cbc",16,32,0,0,0,0),"rijndael-cbc@lysator.liu.se":t("aes-256-cbc",16,32,0,0,0,0),"3des-cbc":t("des-ede3-cbc",8,24,0,0,0,0),"blowfish-cbc":t("bf-cbc",8,16,0,0,0,0),"idea-cbc":t("idea-cbc",8,16,0,0,0,0),"cast128-cbc":t("cast-cbc",8,16,0,0,0,0),"aes128-ctr":t("aes-128-ctr",16,16,16,0,0,ur),"aes192-ctr":t("aes-192-ctr",16,24,16,0,0,ur),"aes256-ctr":t("aes-256-ctr",16,32,16,0,0,ur),"3des-ctr":t("des-ede3",8,24,8,0,0,ur),"blowfish-ctr":t("bf-ecb",8,16,8,0,0,ur),"cast128-ctr":t("cast5-ecb",8,16,8,0,0,ur),arcfour:t("rc4",8,16,0,0,1536,ur),arcfour128:t("rc4",8,16,0,0,1536,ur),arcfour256:t("rc4",8,32,0,0,1536,ur),arcfour512:t("rc4",8,64,0,0,1536,ur)}})(),Px=(()=>{function t(e,r,n,i){return{sslName:e,len:r,actualLen:n,isETM:i}}return c(t,"info"),{"hmac-md5":t("md5",16,16,!1),"hmac-md5-96":t("md5",16,12,!1),"hmac-ripemd160":t("ripemd160",20,20,!1),"hmac-sha1":t("sha1",20,20,!1),"hmac-sha1-etm@openssh.com":t("sha1",20,20,!0),"hmac-sha1-96":t("sha1",20,12,!1),"hmac-sha2-256":t("sha256",32,32,!1),"hmac-sha2-256-etm@openssh.com":t("sha256",32,32,!0),"hmac-sha2-256-96":t("sha256",32,12,!1),"hmac-sha2-512":t("sha512",64,64,!1),"hmac-sha2-512-etm@openssh.com":t("sha512",64,64,!0),"hmac-sha2-512-96":t("sha512",64,12,!1)}})(),Ku=class{static{c(this,"NullCipher")}constructor(e,r){this.outSeqno=e,this._onWrite=r,this._dead=!1}free(){this._dead=!0}allocPacket(e){let r=5+e,n=8-(r&7);n<4&&(n+=8),r+=n;let i=Buffer.allocUnsafe(r);return Or(i,r-4,0),i[4]=n,ai(i,5+e,n),i}encrypt(e){this._dead||(this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},bg=Buffer.alloc(32),Sr=Buffer.alloc(16),Zo,Xo,pl,Vu=class{static{c(this,"ChaChaPolyCipherNative")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._encKeyMain=r.cipherKey.slice(0,32),this._encKeyPktLen=r.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(e){let r=5+e,n=8-(r-4&7);n<4&&(n+=8),r+=n;let i=Buffer.allocUnsafe(r);return Or(i,r-4,0),i[4]=n,ai(i,5+e,n),i}encrypt(e){if(this._dead)return;Sr[0]=0,Or(Sr,this.outSeqno,12);let r=Vi("chacha20",this._encKeyMain,Sr).update(bg),n=Vi("chacha20",this._encKeyPktLen,Sr).update(e.slice(0,4));this._onWrite(n),Sr[0]=1;let i=Vi("chacha20",this._encKeyMain,Sr).update(e.slice(4));this._onWrite(i),pl(Xo,n,n.length,i,i.length,r);let o=Buffer.allocUnsafe(16);o.set(new Uint8Array(Zo.HEAPU8.buffer,Xo,16),0),this._onWrite(o),this.outSeqno=this.outSeqno+1>>>0}},Gu=class{static{c(this,"ChaChaPolyCipherBinding")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._instance=new cl(r.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let r=5+e,n=8-(r-4&7);n<4&&(n+=8),r+=n;let i=Buffer.allocUnsafe(r+16);return Or(i,r-4,0),i[4]=n,ai(i,5+e,n),i}encrypt(e){this._dead||(this._instance.encrypt(e,this.outSeqno),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},Zu=class{static{c(this,"AESGCMCipherNative")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._encSSLName=r.cipherInfo.sslName,this._encKey=r.cipherKey,this._encIV=r.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(e){let r=5+e,n=16-(r-4&15);n<4&&(n+=16),r+=n;let i=Buffer.allocUnsafe(r);return Or(i,r-4,0),i[4]=n,ai(i,5+e,n),i}encrypt(e){if(this._dead)return;let r=Vi(this._encSSLName,this._encKey,this._encIV);r.setAutoPadding(!1);let n=e.slice(0,4);r.setAAD(n),this._onWrite(n);let i=r.update(e.slice(4));this._onWrite(i);let o=r.final();o.length&&this._onWrite(o);let s=r.getAuthTag();this._onWrite(s),xg(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},Yu=class{static{c(this,"AESGCMCipherBinding")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._instance=new al(r.cipherInfo.sslName,r.cipherKey,r.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let r=5+e,n=16-(r-4&15);n<4&&(n+=16),r+=n;let i=Buffer.allocUnsafe(r+16);return Or(i,r-4,0),i[4]=n,ai(i,5+e,n),i}encrypt(e){this._dead||(this._instance.encrypt(e),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},Xu=class{static{c(this,"GenericCipherNative")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._encBlockLen=r.cipherInfo.blockLen,this._cipherInstance=Vi(r.cipherInfo.sslName,r.cipherKey,r.cipherIV),this._macSSLName=r.macInfo.sslName,this._macKey=r.macKey,this._macActualLen=r.macInfo.actualLen,this._macETM=r.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let n=r.cipherInfo.discardLen;if(n){let i=Ra.get(n);i===void 0&&(i=Buffer.alloc(n),Ra.set(n,i)),this._cipherInstance.update(i)}}free(){this._dead=!0}allocPacket(e){let r=this._encBlockLen,n=5+e,i=r-(n-this._aadLen&r-1);i<4&&(i+=r),n+=i;let o=Buffer.allocUnsafe(n);return Or(o,n-4,0),o[4]=i,ai(o,5+e,i),o}encrypt(e){if(this._dead)return;let r;if(this._macETM){let i=new Uint8Array(e.buffer,e.byteOffset,4),o=this._cipherInstance.update(new Uint8Array(e.buffer,e.byteOffset+4,e.length-4));this._onWrite(i),this._onWrite(o),r=Wu(this._macSSLName,this._macKey),Or(Ki,this.outSeqno,0),r.update(Ki),r.update(i),r.update(o)}else{let i=this._cipherInstance.update(e);this._onWrite(i),r=Wu(this._macSSLName,this._macKey),Or(Ki,this.outSeqno,0),r.update(Ki),r.update(e)}let n=r.digest();n.length>this._macActualLen&&(n=n.slice(0,this._macActualLen)),this._onWrite(n),this.outSeqno=this.outSeqno+1>>>0}},Ju=class{static{c(this,"GenericCipherBinding")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._encBlockLen=r.cipherInfo.blockLen,this._macLen=r.macInfo.len,this._macActualLen=r.macInfo.actualLen,this._aadLen=r.macInfo.isETM?4:0,this._instance=new ul(r.cipherInfo.sslName,r.cipherKey,r.cipherIV,r.macInfo.sslName,r.macKey,r.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let r=this._encBlockLen,n=5+e,i=r-(n-this._aadLen&r-1);i<4&&(i+=r),n+=i;let o=Buffer.allocUnsafe(n+this._macLen);return Or(o,n-4,0),o[4]=i,ai(o,5+e,i),o}encrypt(e){this._dead||(this._instance.encrypt(e,this.outSeqno),this._macActualLen<this._macLen&&(e=new zn(e.buffer,e.byteOffset,e.length-(this._macLen-this._macActualLen))),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},el=class{static{c(this,"NullDecipher")}constructor(e,r){this.inSeqno=e,this._onPayload=r,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(e,r,n){for(;r<n;){if(this._lenBytes<4){let o=Math.min(4-this._lenBytes,n-r);for(this._lenBytes+=o;o--;)this._len=(this._len<<8)+e[r++];if(this._lenBytes<4)return;if(this._len>ci||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(r>=n)return}if(this._packetPos<this._len){let o=Math.min(this._len-this._packetPos,n-r),s;if(r!==0||o!==n?s=new Uint8Array(e.buffer,e.byteOffset+r,o):s=e,o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._packetPos)),r+=o,this._packetPos+=o,this._packetPos<this._len)return}let i=this._packet?new zn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Eg;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}},tl=class{static{c(this,"ChaChaPolyDecipherNative")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._decKeyMain=r.decipherKey.slice(0,32),this._decKeyPktLen=r.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(e,r,n){for(;r<n;){if(this._lenPos<4){let a=Math.min(4-this._lenPos,n-r);for(;a--;)this._lenBuf[this._lenPos++]=e[r++];if(this._lenPos<4)return;Sr[0]=0,Or(Sr,this.inSeqno,12);let u=Ca("chacha20",this._decKeyPktLen,Sr).update(this._lenBuf);if(this._len=Yo(u,0),this._len>ci||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(r>=n)return;let a=Math.min(this._len-this._pktLen,n-r),u;if(r!==0||a!==n?u=new Uint8Array(e.buffer,e.byteOffset+r,a):u=e,a===this._len?this._packet=u:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(u,this._pktLen)),r+=a,this._pktLen+=a,this._pktLen<this._len||r>=n)return}{let a=Math.min(16-this._macPos,n-r);if(r!==0||a!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+r,a),this._macPos):this._mac.set(e,this._macPos),r+=a,this._macPos+=a,this._macPos<16)return}Sr[0]=0,Or(Sr,this.inSeqno,12);let i=Vi("chacha20",this._decKeyMain,Sr).update(bg);if(pl(Xo,this._lenBuf,4,this._packet,this._packet.length,i),this._calcMac.set(new Uint8Array(Zo.HEAPU8.buffer,Xo,16),0),!qu(this._calcMac,this._mac))throw new Error("Invalid MAC");Sr[0]=1;let o=Ca("chacha20",this._decKeyMain,Sr).update(this._packet),s=new zn(o.buffer,o.byteOffset+1,o.length-o[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let a=this._onPayload(s);if(a!==void 0)return a===!1?r:a}}}},rl=class{static{c(this,"ChaChaPolyDecipherBinding")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._instance=new fl(r.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(e,r,n){for(;r<n;){if(this._lenPos<4){let o=Math.min(4-this._lenPos,n-r);for(;o--;)this._lenBuf[this._lenPos++]=e[r++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>ci||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(r>=n)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,n-r),s;if(r!==0||o!==n?s=new Uint8Array(e.buffer,e.byteOffset+r,o):s=e,o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._pktLen)),r+=o,this._pktLen+=o,this._pktLen<this._len||r>=n)return}{let o=Math.min(16-this._macPos,n-r);if(r!==0||o!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._macPos):this._mac.set(e,this._macPos),r+=o,this._macPos+=o,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let i=new zn(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 o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}},nl=class{static{c(this,"AESGCMDecipherNative")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._decipherInstance=null,this._decipherSSLName=r.decipherInfo.sslName,this._decipherKey=r.decipherKey,this._decipherIV=r.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(e,r,n){for(;r<n;){if(this._lenBytes<4){let o=Math.min(4-this._lenBytes,n-r);for(this._lenBytes+=o;o--;)this._len=(this._len<<8)+e[r++];if(this._lenBytes<4)return;if(this._len+20>ci||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=Ca(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(Tx(this._len))}if(this._pktLen<this._len){if(r>=n)return;let o=Math.min(this._len-this._pktLen,n-r),s;if(r!==0||o!==n?s=this._decipherInstance.update(new Uint8Array(e.buffer,e.byteOffset+r,o)):s=this._decipherInstance.update(e),s.length&&(o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._packetPos)),this._packetPos+=s.length),r+=o,this._pktLen+=o,this._pktLen<this._len||r>=n)return}{let o=Math.min(16-this._tagPos,n-r);if(r!==0||o!==n?this._tag.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._tagPos):this._tag.set(e,this._tagPos),r+=o,this._tagPos+=o,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let o=this._decipherInstance.final();o.length&&(this._packet?this._packet.set(o,this._packetPos):this._packet=o)}let i=this._packet?new zn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Eg;this.inSeqno=this.inSeqno+1>>>0,xg(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}},il=class{static{c(this,"AESGCMDecipherBinding")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._instance=new ll(r.decipherInfo.sslName,r.decipherKey,r.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(e,r,n){for(;r<n;){if(this._lenBytes<4){let o=Math.min(4-this._lenBytes,n-r);for(this._lenBytes+=o;o--;)this._len=(this._len<<8)+e[r++];if(this._lenBytes<4)return;if(this._len+20>ci||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(r>=n)return;let o=Math.min(this._len-this._pktLen,n-r),s;if(r!==0||o!==n?s=new Uint8Array(e.buffer,e.byteOffset+r,o):s=e,o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._pktLen)),r+=o,this._pktLen+=o,this._pktLen<this._len||r>=n)return}{let o=Math.min(16-this._tagPos,n-r);if(r!==0||o!==n?this._tag.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._tagPos):this._tag.set(e,this._tagPos),r+=o,this._tagPos+=o,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let i=new zn(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 o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}},ol=class{static{c(this,"GenericDecipherNative")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._decipherInstance=Ca(r.decipherInfo.sslName,r.decipherKey,r.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(r.macInfo.isETM?4:r.decipherInfo.blockLen),this._blockSize=r.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(r.macInfo.actualLen),this._macPos=0,this._macSSLName=r.macInfo.sslName,this._macKey=r.macKey,this._macActualLen=r.macInfo.actualLen,this._macETM=r.macInfo.isETM,this._macInstance=null;let n=r.decipherInfo.discardLen;if(n){let i=Ra.get(n);i===void 0&&(i=Buffer.alloc(n),Ra.set(n,i)),this._decipherInstance.update(i)}}free(){}decrypt(e,r,n){for(;r<n;){if(this._blockPos<this._block.length){let s=Math.min(this._block.length-this._blockPos,n-r);if(r!==0||s!==n||s<e.length?this._block.set(new Uint8Array(e.buffer,e.byteOffset+r,s),this._blockPos):this._block.set(e,this._blockPos),r+=s,this._blockPos+=s,this._blockPos<this._block.length)return;let a,u;if(this._macETM?this._len=u=Yo(this._block,0):(a=this._decipherInstance.update(this._block),this._len=Yo(a,0),u=4+this._len-this._blockSize),this._len>ci||this._len<5||(u&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=Wu(this._macSSLName,this._macKey),Or(Ki,this.inSeqno,0),this._macInstance.update(Ki),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),r>=n)return}if(this._pktLen<this._len){let s=Math.min(this._len-this._pktLen,n-r),a;r!==0||s!==n?a=new Uint8Array(e.buffer,e.byteOffset+r,s):a=e,this._macETM&&this._macInstance.update(a);let u=this._decipherInstance.update(a);if(u.length&&(s===this._len?this._packet=u:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(u,this._packetPos)),this._packetPos+=u.length),r+=s,this._pktLen+=s,this._pktLen<this._len||r>=n)return}{let s=Math.min(this._macActualLen-this._macPos,n-r);if(r!==0||s!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+r,s),this._macPos):this._mac.set(e,this._macPos),r+=s,this._macPos+=s,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)),!kx(i,this._mac))throw new Error("Invalid MAC");let o=new zn(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 s=this._onPayload(o);if(s!==void 0)return s===!1?r:s}}}},sl=class{static{c(this,"GenericDecipherBinding")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._instance=new dl(r.decipherInfo.sslName,r.decipherKey,r.decipherIV,r.macInfo.sslName,r.macKey,r.macInfo.isETM,r.macInfo.actualLen),this._block=Buffer.allocUnsafe(r.macInfo.isETM||r.decipherInfo.stream?4:r.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(r.macInfo.actualLen),this._macPos=0,this._macActualLen=r.macInfo.actualLen,this._macETM=r.macInfo.isETM}free(){this._instance.free()}decrypt(e,r,n){for(;r<n;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,n-r);if(r!==0||o!==n||o<e.length?this._block.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._blockPos):this._block.set(e,this._blockPos),r+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let s;if(this._macETM?this._len=s=Yo(this._block,0):(this._instance.decryptBlock(this._block),this._len=Yo(this._block,0),s=4+this._len-this._block.length),this._len>ci||this._len<5||(s&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))),r>=n)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,n-r),s;if(r!==0||o!==n?s=new Uint8Array(e.buffer,e.byteOffset+r,o):s=e,o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._pktLen)),r+=o,this._pktLen+=o,this._pktLen<this._len||r>=n)return}{let o=Math.min(this._macActualLen-this._macPos,n-r);if(r!==0||o!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._macPos):this._mac.set(e,this._macPos),r+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let i=new zn(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 o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}};function xg(t){++t[11]>>>8&&++t[10]>>>8&&++t[9]>>>8&&++t[8]>>>8&&++t[7]>>>8&&++t[6]>>>8&&++t[5]>>>8&&++t[4]>>>8}c(xg,"ivIncrement");var Tx=(()=>{let t=Buffer.alloc(4);return e=>(t[0]=e>>>24,t[1]=e>>>16,t[2]=e>>>8,t[3]=e,t)})();function kx(t,e){return t.length!==e.length?(qu(t,t),!1):qu(t,e)}c(kx,"timingSafeEquals");function Cx(t){if(typeof t!="object"||t===null)throw new Error("Invalid config");if(typeof t.outbound!="object"||t.outbound===null)throw new Error("Invalid outbound");let e=t.outbound;if(typeof e.onWrite!="function")throw new Error("Invalid outbound.onWrite");if(typeof e.cipherInfo!="object"||e.cipherInfo===null)throw new Error("Invalid outbound.cipherInfo");if(!Buffer.isBuffer(e.cipherKey)||e.cipherKey.length!==e.cipherInfo.keyLen)throw new Error("Invalid outbound.cipherKey");if(e.cipherInfo.ivLen&&(!Buffer.isBuffer(e.cipherIV)||e.cipherIV.length!==e.cipherInfo.ivLen))throw new Error("Invalid outbound.cipherIV");if(typeof e.seqno!="number"||e.seqno<0||e.seqno>Ag)throw new Error("Invalid outbound.seqno");let r=!!e.forceNative;switch(e.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return al&&!r?new Yu(t):new Zu(t);case"chacha20":return cl&&!r?new Gu(t):new Vu(t);default:{if(typeof e.macInfo!="object"||e.macInfo===null)throw new Error("Invalid outbound.macInfo");if(!Buffer.isBuffer(e.macKey)||e.macKey.length!==e.macInfo.len)throw new Error("Invalid outbound.macKey");return ul&&!r?new Ju(t):new Xu(t)}}}c(Cx,"createCipher");function Rx(t){if(typeof t!="object"||t===null)throw new Error("Invalid config");if(typeof t.inbound!="object"||t.inbound===null)throw new Error("Invalid inbound");let e=t.inbound;if(typeof e.onPayload!="function")throw new Error("Invalid inbound.onPayload");if(typeof e.decipherInfo!="object"||e.decipherInfo===null)throw new Error("Invalid inbound.decipherInfo");if(!Buffer.isBuffer(e.decipherKey)||e.decipherKey.length!==e.decipherInfo.keyLen)throw new Error("Invalid inbound.decipherKey");if(e.decipherInfo.ivLen&&(!Buffer.isBuffer(e.decipherIV)||e.decipherIV.length!==e.decipherInfo.ivLen))throw new Error("Invalid inbound.decipherIV");if(typeof e.seqno!="number"||e.seqno<0||e.seqno>Ag)throw new Error("Invalid inbound.seqno");let r=!!e.forceNative;switch(e.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return ll&&!r?new il(t):new nl(t);case"chacha20":return fl&&!r?new rl(t):new tl(t);default:{if(typeof e.macInfo!="object"||e.macInfo===null)throw new Error("Invalid inbound.macInfo");if(!Buffer.isBuffer(e.macKey)||e.macKey.length!==e.macInfo.len)throw new Error("Invalid inbound.macKey");return dl&&!r?new sl(t):new ol(t)}}}c(Rx,"createDecipher");Ig.exports={CIPHER_INFO:wx,MAC_INFO:Px,bindingAvailable:!!Qu,init:new Promise(async(t,e)=>{try{Zo=await yg()(),Xo=Zo._malloc(16),pl=Zo.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(r){return e(r)}t()}),NullCipher:Ku,createCipher:Cx,NullDecipher:el,createDecipher:Rx}});var Fn=le(($3,Og)=>{"use strict";var{createDecipheriv:gl,createECDH:Nx,createHash:es,createHmac:Ox,createSign:$x,createVerify:Dx,getCiphers:Bx,sign:vg,verify:Sg}=require("crypto"),Ux=Bx(),{Ber:Oe}=Ko(),Lx=Lu().pbkdf,{CIPHER_INFO:ts}=Ln(),{eddsaSupported:ml,SUPPORTED_CIPHER:zx}=An(),{bufferSlice:ui,makeBufferParser:Mx,readString:Re,readUInt32BE:Jo,writeUInt32BE:ar}=Qr(),En=Symbol("Hash Algorithm"),Kr=Symbol("Private key PEM"),nn=Symbol("Public key PEM"),Mn=Symbol("Public key SSH"),Gi=Symbol("Decrypted Key"),hl=Object.create(null);{let t=Object.keys(ts);for(let e=0;e<t.length;++e){let r=ts[t[e]].sslName;!r||hl[r]||(hl[r]=ts[t[e]])}}var Na=Mx();function Vr(t,e){e=e.base64Slice(0,e.length);let r=e.replace(/.{64}/g,`$&
8
+ -----END PRIVATE KEY-----`,e=Buffer.from("a"),r,n;try{r=En.sign(null,e,t),n=En.verify(null,e,t,r)}catch{}return Buffer.isBuffer(r)&&r.length===64&&n===!0}return!1})(),hg=typeof En.diffieHellman=="function"&&typeof En.generateKeyPairSync=="function"&&typeof En.createPublicKey=="function",wa=["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"];hg&&(wa.unshift("curve25519-sha256"),wa.unshift("curve25519-sha256@libssh.org"));var $x=wa.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),Mu=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];pg&&Mu.unshift("ssh-ed25519");var Dx=Mu.concat(["ssh-dss"]),gg=(()=>{let t=En.getCiphers();return e=>t.includes(Nx[e].sslName)})(),Ln=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Vi&&Vi.flags&&!Vi.flags.aes?dg?Ln.unshift("chacha20-poly1305@openssh.com"):Ln.push("chacha20-poly1305@openssh.com"):dg&&Vi&&Vi.arch==="x86"?Ln.splice(4,0,"chacha20-poly1305@openssh.com"):Ln.push("chacha20-poly1305@openssh.com");Ln=Ln.filter(gg);var Bx=Ln.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(gg)),mg=(()=>{let t=En.getHashes();return e=>t.includes(Ox[e].sslName)})(),_g=["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(mg),Ux=_g.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(mg)),yg=["none","zlib@openssh.com","zlib"],Lx=yg.concat([]),Qi={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};Pa.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((t,e)=>({...t,[e]:1}),{}),COMPAT:Qi,COMPAT_CHECKS:[["Cisco-1.25",Qi.BAD_DHGEX],[/^Cisco-1[.]/,Qi.BUG_DHGEX_LARGE],[/^[0-9.]+$/,Qi.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,Qi.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,Qi.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:wa,SUPPORTED_KEX:$x,DEFAULT_SERVER_HOST_KEY:Mu,SUPPORTED_SERVER_HOST_KEY:Dx,DEFAULT_CIPHER:Ln,SUPPORTED_CIPHER:Bx,DEFAULT_MAC:_g,SUPPORTED_MAC:Ux,DEFAULT_COMPRESSION:yg,SUPPORTED_COMPRESSION:Lx,curve25519Supported:hg,eddsaSupported:pg};Pa.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(Pa.exports.DISCONNECT_REASON)).reduce((t,[e,r])=>({...t,[r]:e}),{})});var Qr=le((V3,xg)=>{"use strict";var Mr=Ko().Ber,Ta,bg=Buffer[Symbol.species],zx=Object.getPrototypeOf(Uint8Array.prototype).fill;function Eg(t,e){return t[e++]*16777216+t[e++]*65536+t[e++]*256+t[e]}c(Eg,"readUInt32BE");function Go(t,e,r,n,i){i||(i=0),n>t.length&&(n=t.length);let o=n-r,s=e.length-i;return o>s&&(o=s),e.set(new Uint8Array(t.buffer,t.byteOffset+r,o),i),o}c(Go,"bufferCopy");function Zo(t,e,r){return r===void 0&&(r=t.length),new bg(t.buffer,t.byteOffset+e,r-e)}c(Zo,"bufferSlice");function Hu(){let t=0,e,r={init:c((n,i)=>{e=n,t=typeof i=="number"?i:0},"init"),pos:c(()=>t,"pos"),length:c(()=>e?e.length:0,"length"),avail:c(()=>e&&t<e.length?e.length-t:0,"avail"),clear:c(()=>{e=void 0},"clear"),readUInt32BE:c(()=>{if(!(!e||t+3>=e.length))return e[t++]*16777216+e[t++]*65536+e[t++]*256+e[t++]},"readUInt32BE"),readUInt64BE:c(n=>{if(!(!e||t+7>=e.length))switch(n){case"always":return BigInt(`0x${e.hexSlice(t,t+=8)}`);case"maybe":if(e[t]>31)return BigInt(`0x${e.hexSlice(t,t+=8)}`);default:return e[t++]*72057594037927940+e[t++]*281474976710656+e[t++]*1099511627776+e[t++]*4294967296+e[t++]*16777216+e[t++]*65536+e[t++]*256+e[t++]}},"readUInt64BE"),skip:c(n=>{e&&n>0&&(t+=n)},"skip"),skipString:c(()=>{let n=r.readUInt32BE();if(n!==void 0)return t+=n,t<=e.length?n:void 0},"skipString"),readByte:c(()=>{if(e&&t<e.length)return e[t++]},"readByte"),readBool:c(()=>{if(e&&t<e.length)return!!e[t++]},"readBool"),readList:c(()=>{let n=r.readString(!0);if(n!==void 0)return n?n.split(","):[]},"readList"),readString:c((n,i)=>{typeof n=="number"&&(i=n,n=void 0);let o=r.readUInt32BE();if(o!==void 0&&!(e.length-t<o||typeof i=="number"&&o>i))return n?Buffer.isBuffer(n)?Go(e,n,t,t+=o):e.utf8Slice(t,t+=o):Zo(e,t,t+=o)},"readString"),readRaw:c(n=>{if(e){if(typeof n!="number")return Zo(e,t,t+=e.length-t);if(e.length-t>=n)return Zo(e,t,t+=n)}},"readRaw")};return r}c(Hu,"makeBufferParser");function Ag(t,e,r){let n=new Error(t);return typeof e=="boolean"?(r=e,n.level="protocol"):n.level=e||"protocol",n.fatal=!!r,n}c(Ag,"makeError");function Fu(t,e,r){return t[r++]=e>>>24,t[r++]=e>>>16,t[r++]=e>>>8,t[r++]=e,r}c(Fu,"writeUInt32BE");var ka=Hu();xg.exports={bufferCopy:Go,bufferSlice:Zo,FastBuffer:bg,bufferFill:c((t,e,r,n)=>zx.call(t,e,r,n),"bufferFill"),makeError:Ag,doFatalError:c((t,e,r,n)=>{let i;return Ta===void 0&&({DISCONNECT_REASON:Ta}=An()),e instanceof Error?(i=e,typeof r!="number"?n=Ta.PROTOCOL_ERROR:n=r):i=Ag(e,r,!0),typeof n!="number"&&(n=Ta.PROTOCOL_ERROR),t.disconnect(n),t._destruct(),t._onError(i),1/0},"doFatalError"),readUInt32BE:Eg,writeUInt32BE:Fu,writeUInt32LE:c((t,e,r)=>(t[r++]=e,t[r++]=e>>>8,t[r++]=e>>>16,t[r++]=e>>>24,r),"writeUInt32LE"),makeBufferParser:Hu,bufferParser:Hu(),readString:c((t,e,r,n)=>{typeof r=="number"&&(n=r,r=void 0),e===void 0&&(e=0);let i=t.length-e;if(e<0||e>=t.length||i<4)return;let o=Eg(t,e);if(i<4+o||typeof n=="number"&&o>n)return;e+=4;let s=e+o;return t._pos=s,r?Buffer.isBuffer(r)?Go(t,r,e,s):t.utf8Slice(e,s):Zo(t,e,s)},"readString"),sigSSHToASN1:c((t,e)=>{switch(e){case"ssh-dss":{if(t.length>40)return t;let r=new Mr.Writer;r.startSequence();let n=t.slice(0,20),i=t.slice(20);if(n[0]&128){let o=Buffer.allocUnsafe(21);o[0]=0,n.copy(o,1),n=o}else n[0]===0&&!(n[1]&128)&&(n=n.slice(1));if(i[0]&128){let o=Buffer.allocUnsafe(21);o[0]=0,i.copy(o,1),i=o}else i[0]===0&&!(i[1]&128)&&(i=i.slice(1));return r.writeBuffer(n,Mr.Integer),r.writeBuffer(i,Mr.Integer),r.endSequence(),r.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{ka.init(t,0);let r=ka.readString(),n=ka.readString();if(ka.clear(),r===void 0||n===void 0)return;let i=new Mr.Writer;return i.startSequence(),i.writeBuffer(r,Mr.Integer),i.writeBuffer(n,Mr.Integer),i.endSequence(),i.buffer}default:return t}},"sigSSHToASN1"),convertSignature:c((t,e)=>{switch(e){case"ssh-dss":{if(t.length<=40)return t;let r=new Mr.Reader(t);r.readSequence();let n=r.readString(Mr.Integer,!0),i=r.readString(Mr.Integer,!0),o=0,s=0;if(n.length<20){let u=Buffer.allocUnsafe(20);u.set(n,1),n=u,n[0]=0}if(i.length<20){let u=Buffer.allocUnsafe(20);u.set(i,1),i=u,i[0]=0}n.length>20&&n[0]===0&&(o=1),i.length>20&&i[0]===0&&(s=1);let a=Buffer.allocUnsafe(n.length-o+(i.length-s));return Go(n,a,o,n.length,0),Go(i,a,s,i.length,n.length-o),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(t[0]===0)return t;let r=new Mr.Reader(t);r.readSequence();let n=r.readString(Mr.Integer,!0),i=r.readString(Mr.Integer,!0);if(n===null||i===null)return;let o=Buffer.allocUnsafe(4+n.length+4+i.length);return Fu(o,n.length,0),o.set(n,4),Fu(o,i.length,4+n.length),o.set(i,8+n.length),o}}return t},"convertSignature"),sendPacket:c((t,e,r)=>!r&&t._kexinit!==void 0?(t._queue===void 0&&(t._queue=[]),t._queue.push(e),t._debug&&t._debug("Outbound: ... packet queued"),!1):(t._cipher.encrypt(e),!0),"sendPacket")}});var Ig=le((Ca,Wu)=>{var ju=(function(){var t=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(t=t||__filename),(function(e){e=e||{};var r;r||(r=typeof e<"u"?e:{});var n,i;r.ready=new Promise(function(te,fe){n=te,i=fe});var o={},s;for(s in r)r.hasOwnProperty(s)&&(o[s]=r[s]);var a=typeof window=="object",u=typeof importScripts=="function",l=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",d="",p,g,h,_,A;l?(d=u?require("path").dirname(d)+"/":__dirname+"/",p=c(function(te,fe){var ve=vr(te);return ve?fe?ve:ve.toString():(_||(_=require("fs")),A||(A=require("path")),te=A.normalize(te),_.readFileSync(te,fe?null:"utf8"))},"C"),h=c(function(te){return te=p(te,!0),te.buffer||(te=new Uint8Array(te)),X(te.buffer),te},"E"),g=c(function(te,fe,ve){var De=vr(te);De&&fe(De),_||(_=require("fs")),A||(A=require("path")),te=A.normalize(te),_.readFile(te,function(ut,Jt){ut?ve(ut):fe(Jt.buffer)})},"D"),1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),r.inspect=function(){return"[Emscripten Module object]"}):(a||u)&&(u?d=self.location.href:typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),t&&(d=t),d.indexOf("blob:")!==0?d=d.substr(0,d.lastIndexOf("/")+1):d="",p=c(function(te){try{var fe=new XMLHttpRequest;return fe.open("GET",te,!1),fe.send(null),fe.responseText}catch(ut){if(te=vr(te)){fe=[];for(var ve=0;ve<te.length;ve++){var De=te[ve];255<De&&(yr&&X(!1,"Character code "+De+" ("+String.fromCharCode(De)+") at offset "+ve+" not in 0x00-0xFF."),De&=255),fe.push(String.fromCharCode(De))}return fe.join("")}throw ut}},"C"),u&&(h=c(function(te){try{var fe=new XMLHttpRequest;return fe.open("GET",te,!1),fe.responseType="arraybuffer",fe.send(null),new Uint8Array(fe.response)}catch(ve){if(te=vr(te))return te;throw ve}},"E")),g=c(function(te,fe,ve){var De=new XMLHttpRequest;De.open("GET",te,!0),De.responseType="arraybuffer",De.onload=function(){if(De.status==200||De.status==0&&De.response)fe(De.response);else{var ut=vr(te);ut?fe(ut.buffer):ve()}},De.onerror=ve,De.send(null)},"D")),r.print||console.log.bind(console);var b=r.printErr||console.warn.bind(console);for(s in o)o.hasOwnProperty(s)&&(r[s]=o[s]);o=null;var I;r.wasmBinary&&(I=r.wasmBinary);var w=r.noExitRuntime||!0;typeof WebAssembly!="object"&&J("no native wasm support detected");var H,$=!1;function X(te,fe){te||J("Assertion failed: "+fe)}c(X,"assert");function Z(te){var fe=r["_"+te];return X(fe,"Cannot call unknown function "+te+", make sure it is exported"),fe}c(Z,"N");function Y(te,fe,ve,De){var ut={string:c(function(xt){var sr=0;if(xt!=null&&xt!==0){var ir=(xt.length<<2)+1;sr=mo(ir);var Ht=sr,Pt=L;if(0<ir){ir=Ht+ir-1;for(var Br=0;Br<xt.length;++Br){var jt=xt.charCodeAt(Br);if(55296<=jt&&57343>=jt){var Jn=xt.charCodeAt(++Br);jt=65536+((jt&1023)<<10)|Jn&1023}if(127>=jt){if(Ht>=ir)break;Pt[Ht++]=jt}else{if(2047>=jt){if(Ht+1>=ir)break;Pt[Ht++]=192|jt>>6}else{if(65535>=jt){if(Ht+2>=ir)break;Pt[Ht++]=224|jt>>12}else{if(Ht+3>=ir)break;Pt[Ht++]=240|jt>>18,Pt[Ht++]=128|jt>>12&63}Pt[Ht++]=128|jt>>6&63}Pt[Ht++]=128|jt&63}}Pt[Ht]=0}}return sr},"string"),array:c(function(xt){var sr=mo(xt.length);return M.set(xt,sr),sr},"array")},Jt=Z(te),Yr=[];if(te=0,De)for(var kr=0;kr<De.length;kr++){var Ii=ut[ve[kr]];Ii?(te===0&&(te=go()),Yr[kr]=Ii(De[kr])):Yr[kr]=De[kr]}return ve=Jt.apply(null,Yr),ve=(function(xt){if(fe==="string")if(xt){for(var sr=L,ir=xt+NaN,Ht=xt;sr[Ht]&&!(Ht>=ir);)++Ht;if(16<Ht-xt&&sr.subarray&&P)xt=P.decode(sr.subarray(xt,Ht));else{for(ir="";xt<Ht;){var Pt=sr[xt++];if(Pt&128){var Br=sr[xt++]&63;if((Pt&224)==192)ir+=String.fromCharCode((Pt&31)<<6|Br);else{var jt=sr[xt++]&63;Pt=(Pt&240)==224?(Pt&15)<<12|Br<<6|jt:(Pt&7)<<18|Br<<12|jt<<6|sr[xt++]&63,65536>Pt?ir+=String.fromCharCode(Pt):(Pt-=65536,ir+=String.fromCharCode(55296|Pt>>10,56320|Pt&1023))}}else ir+=String.fromCharCode(Pt)}xt=ir}}else xt="";else xt=fe==="boolean"?!!xt:xt;return xt})(ve),te!==0&&Bs(te),ve}c(Y,"ca");var P=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,k,M,L;function T(){var te=H.buffer;k=te,r.HEAP8=M=new Int8Array(te),r.HEAP16=new Int16Array(te),r.HEAP32=new Int32Array(te),r.HEAPU8=L=new Uint8Array(te),r.HEAPU16=new Uint16Array(te),r.HEAPU32=new Uint32Array(te),r.HEAPF32=new Float32Array(te),r.HEAPF64=new Float64Array(te)}c(T,"ia");var F,j=[],B=[],G=[];function ee(){var te=r.preRun.shift();j.unshift(te)}c(ee,"ma");var C=0,W=null,q=null;r.preloadedImages={},r.preloadedAudios={};function J(te){throw r.onAbort&&r.onAbort(te),b(te),$=!0,te=new WebAssembly.RuntimeError("abort("+te+"). Build with -s ASSERTIONS=1 for more info."),i(te),te}c(J,"K");var ue="data:application/octet-stream;base64,",me;if(me="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==",!me.startsWith(ue)){var he=me;me=r.locateFile?r.locateFile(he,d):d+he}function bt(){var te=me;try{if(te==me&&I)return new Uint8Array(I);var fe=vr(te);if(fe)return fe;if(h)return h(te);throw"both async and sync fetching of the wasm failed"}catch(ve){J(ve)}}c(bt,"pa");function Ct(){if(!I&&(a||u)){if(typeof fetch=="function"&&!me.startsWith("file://"))return fetch(me,{credentials:"same-origin"}).then(function(te){if(!te.ok)throw"failed to load wasm binary file at '"+me+"'";return te.arrayBuffer()}).catch(function(){return bt()});if(g)return new Promise(function(te,fe){g(me,function(ve){te(new Uint8Array(ve))},fe)})}return Promise.resolve().then(function(){return bt()})}c(Ct,"qa");function Xt(te){for(;0<te.length;){var fe=te.shift();if(typeof fe=="function")fe(r);else{var ve=fe.m;typeof ve=="number"?fe.l===void 0?F.get(ve)():F.get(ve)(fe.l):ve(fe.l===void 0?null:fe.l)}}}c(Xt,"X");var yr=!1,Dr=typeof atob=="function"?atob:function(te){var fe="",ve=0;te=te.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var De="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(te.charAt(ve++)),ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(te.charAt(ve++)),Jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(te.charAt(ve++)),Yr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(te.charAt(ve++));De=De<<2|ut>>4,ut=(ut&15)<<4|Jt>>2;var kr=(Jt&3)<<6|Yr;fe+=String.fromCharCode(De),Jt!==64&&(fe+=String.fromCharCode(ut)),Yr!==64&&(fe+=String.fromCharCode(kr))}while(ve<te.length);return fe};function vr(te){if(te.startsWith(ue)){if(te=te.slice(ue.length),typeof l=="boolean"&&l){var fe=Buffer.from(te,"base64");fe=new Uint8Array(fe.buffer,fe.byteOffset,fe.byteLength)}else try{var ve=Dr(te),De=new Uint8Array(ve.length);for(te=0;te<ve.length;++te)De[te]=ve.charCodeAt(te);fe=De}catch{throw Error("Converting base64 string to bytes failed.")}return fe}}c(vr,"H");var Ai={a:c(function(te){var fe=L.length;if(te>>>=0,2147483648<te)return!1;for(var ve=1;4>=ve;ve*=2){var De=fe*(1+.2/ve);De=Math.min(De,te+100663296),De=Math.max(te,De),0<De%65536&&(De+=65536-De%65536);e:{try{H.grow(Math.min(2147483648,De)-k.byteLength+65535>>>16),T();var ut=1;break e}catch{}ut=void 0}if(ut)return!0}return!1},"a")};(function(){function te(ut){r.asm=ut.exports,H=r.asm.b,T(),F=r.asm.j,B.unshift(r.asm.c),C--,r.monitorRunDependencies&&r.monitorRunDependencies(C),C==0&&(W!==null&&(clearInterval(W),W=null),q&&(ut=q,q=null,ut()))}c(te,"a");function fe(ut){te(ut.instance)}c(fe,"c");function ve(ut){return Ct().then(function(Jt){return WebAssembly.instantiate(Jt,De)}).then(ut,function(Jt){b("failed to asynchronously prepare wasm: "+Jt),J(Jt)})}c(ve,"d");var De={a:Ai};if(C++,r.monitorRunDependencies&&r.monitorRunDependencies(C),r.instantiateWasm)try{return r.instantiateWasm(De,te)}catch(ut){return b("Module.instantiateWasm callback failed with error: "+ut),!1}return(function(){return I||typeof WebAssembly.instantiateStreaming!="function"||me.startsWith(ue)||me.startsWith("file://")||typeof fetch!="function"?ve(fe):fetch(me,{credentials:"same-origin"}).then(function(ut){return WebAssembly.instantiateStreaming(ut,De).then(fe,function(Jt){return b("wasm streaming compile failed: "+Jt),b("falling back to ArrayBuffer instantiation"),ve(fe)})})})().catch(i),{}})(),r.___wasm_call_ctors=function(){return(r.___wasm_call_ctors=r.asm.c).apply(null,arguments)},r._poly1305_auth=function(){return(r._poly1305_auth=r.asm.d).apply(null,arguments)};var go=r.stackSave=function(){return(go=r.stackSave=r.asm.e).apply(null,arguments)},Bs=r.stackRestore=function(){return(Bs=r.stackRestore=r.asm.f).apply(null,arguments)},mo=r.stackAlloc=function(){return(mo=r.stackAlloc=r.asm.g).apply(null,arguments)};r._malloc=function(){return(r._malloc=r.asm.h).apply(null,arguments)},r._free=function(){return(r._free=r.asm.i).apply(null,arguments)},r.cwrap=function(te,fe,ve,De){ve=ve||[];var ut=ve.every(function(Jt){return Jt==="number"});return fe!=="string"&&ut&&!De?Z(te):function(){return Y(te,fe,ve,arguments)}};var bi;q=c(function te(){bi||xi(),bi||(q=te)},"ta");function xi(){function te(){if(!bi&&(bi=!0,r.calledRun=!0,!$)){if(Xt(B),n(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;){var fe=r.postRun.shift();G.unshift(fe)}Xt(G)}}if(c(te,"a"),!(0<C)){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)ee();Xt(j),0<C||(r.setStatus?(r.setStatus("Running..."),setTimeout(function(){setTimeout(function(){r.setStatus("")},1),te()},1)):te())}}if(c(xi,"Z"),r.run=xi,r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);0<r.preInit.length;)r.preInit.pop()();return xi(),e.ready})})();typeof Ca=="object"&&typeof Wu=="object"?Wu.exports=ju:typeof define=="function"&&define.amd?define([],function(){return ju}):typeof Ca=="object"&&(Ca.createPoly1305=ju)});var zn=le((Z3,Tg)=>{"use strict";var{createCipheriv:Gi,createDecipheriv:Ra,createHmac:qu,randomFillSync:ci,timingSafeEqual:Qu}=require("crypto"),{readUInt32BE:Xo,writeUInt32BE:Or}=Qr(),Mn=Buffer[Symbol.species],vg=2**32-1,Sg=Buffer.alloc(0),Ki=Buffer.alloc(4),Na=new Map,ui=35e3,Vu,cl,ul,ll,fl,dl,pl;try{Vu=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:cl,ChaChaPolyCipher:ul,GenericCipher:ll,AESGCMDecipher:fl,ChaChaPolyDecipher:dl,GenericDecipher:pl}=Vu}catch{}var lr=1,Mx=(()=>{function t(e,r,n,i,o,s,a){return{sslName:e,blockLen:r,keyLen:n,ivLen:i!==0||a&lr?i:r,authLen:o,discardLen:s,stream:!!(a&lr)}}return c(t,"info"),{"chacha20-poly1305@openssh.com":t("chacha20",8,64,0,16,0,lr),"aes128-gcm":t("aes-128-gcm",16,16,12,16,0,lr),"aes256-gcm":t("aes-256-gcm",16,32,12,16,0,lr),"aes128-gcm@openssh.com":t("aes-128-gcm",16,16,12,16,0,lr),"aes256-gcm@openssh.com":t("aes-256-gcm",16,32,12,16,0,lr),"aes128-cbc":t("aes-128-cbc",16,16,0,0,0,0),"aes192-cbc":t("aes-192-cbc",16,24,0,0,0,0),"aes256-cbc":t("aes-256-cbc",16,32,0,0,0,0),"rijndael-cbc@lysator.liu.se":t("aes-256-cbc",16,32,0,0,0,0),"3des-cbc":t("des-ede3-cbc",8,24,0,0,0,0),"blowfish-cbc":t("bf-cbc",8,16,0,0,0,0),"idea-cbc":t("idea-cbc",8,16,0,0,0,0),"cast128-cbc":t("cast-cbc",8,16,0,0,0,0),"aes128-ctr":t("aes-128-ctr",16,16,16,0,0,lr),"aes192-ctr":t("aes-192-ctr",16,24,16,0,0,lr),"aes256-ctr":t("aes-256-ctr",16,32,16,0,0,lr),"3des-ctr":t("des-ede3",8,24,8,0,0,lr),"blowfish-ctr":t("bf-ecb",8,16,8,0,0,lr),"cast128-ctr":t("cast5-ecb",8,16,8,0,0,lr),arcfour:t("rc4",8,16,0,0,1536,lr),arcfour128:t("rc4",8,16,0,0,1536,lr),arcfour256:t("rc4",8,32,0,0,1536,lr),arcfour512:t("rc4",8,64,0,0,1536,lr)}})(),Fx=(()=>{function t(e,r,n,i){return{sslName:e,len:r,actualLen:n,isETM:i}}return c(t,"info"),{"hmac-md5":t("md5",16,16,!1),"hmac-md5-96":t("md5",16,12,!1),"hmac-ripemd160":t("ripemd160",20,20,!1),"hmac-sha1":t("sha1",20,20,!1),"hmac-sha1-etm@openssh.com":t("sha1",20,20,!0),"hmac-sha1-96":t("sha1",20,12,!1),"hmac-sha2-256":t("sha256",32,32,!1),"hmac-sha2-256-etm@openssh.com":t("sha256",32,32,!0),"hmac-sha2-256-96":t("sha256",32,12,!1),"hmac-sha2-512":t("sha512",64,64,!1),"hmac-sha2-512-etm@openssh.com":t("sha512",64,64,!0),"hmac-sha2-512-96":t("sha512",64,12,!1)}})(),Ku=class{static{c(this,"NullCipher")}constructor(e,r){this.outSeqno=e,this._onWrite=r,this._dead=!1}free(){this._dead=!0}allocPacket(e){let r=5+e,n=8-(r&7);n<4&&(n+=8),r+=n;let i=Buffer.allocUnsafe(r);return Or(i,r-4,0),i[4]=n,ci(i,5+e,n),i}encrypt(e){this._dead||(this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},wg=Buffer.alloc(32),Sr=Buffer.alloc(16),Yo,Jo,hl,Gu=class{static{c(this,"ChaChaPolyCipherNative")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._encKeyMain=r.cipherKey.slice(0,32),this._encKeyPktLen=r.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(e){let r=5+e,n=8-(r-4&7);n<4&&(n+=8),r+=n;let i=Buffer.allocUnsafe(r);return Or(i,r-4,0),i[4]=n,ci(i,5+e,n),i}encrypt(e){if(this._dead)return;Sr[0]=0,Or(Sr,this.outSeqno,12);let r=Gi("chacha20",this._encKeyMain,Sr).update(wg),n=Gi("chacha20",this._encKeyPktLen,Sr).update(e.slice(0,4));this._onWrite(n),Sr[0]=1;let i=Gi("chacha20",this._encKeyMain,Sr).update(e.slice(4));this._onWrite(i),hl(Jo,n,n.length,i,i.length,r);let o=Buffer.allocUnsafe(16);o.set(new Uint8Array(Yo.HEAPU8.buffer,Jo,16),0),this._onWrite(o),this.outSeqno=this.outSeqno+1>>>0}},Zu=class{static{c(this,"ChaChaPolyCipherBinding")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._instance=new ul(r.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let r=5+e,n=8-(r-4&7);n<4&&(n+=8),r+=n;let i=Buffer.allocUnsafe(r+16);return Or(i,r-4,0),i[4]=n,ci(i,5+e,n),i}encrypt(e){this._dead||(this._instance.encrypt(e,this.outSeqno),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},Yu=class{static{c(this,"AESGCMCipherNative")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._encSSLName=r.cipherInfo.sslName,this._encKey=r.cipherKey,this._encIV=r.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(e){let r=5+e,n=16-(r-4&15);n<4&&(n+=16),r+=n;let i=Buffer.allocUnsafe(r);return Or(i,r-4,0),i[4]=n,ci(i,5+e,n),i}encrypt(e){if(this._dead)return;let r=Gi(this._encSSLName,this._encKey,this._encIV);r.setAutoPadding(!1);let n=e.slice(0,4);r.setAAD(n),this._onWrite(n);let i=r.update(e.slice(4));this._onWrite(i);let o=r.final();o.length&&this._onWrite(o);let s=r.getAuthTag();this._onWrite(s),Pg(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},Xu=class{static{c(this,"AESGCMCipherBinding")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._instance=new cl(r.cipherInfo.sslName,r.cipherKey,r.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let r=5+e,n=16-(r-4&15);n<4&&(n+=16),r+=n;let i=Buffer.allocUnsafe(r+16);return Or(i,r-4,0),i[4]=n,ci(i,5+e,n),i}encrypt(e){this._dead||(this._instance.encrypt(e),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},Ju=class{static{c(this,"GenericCipherNative")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._encBlockLen=r.cipherInfo.blockLen,this._cipherInstance=Gi(r.cipherInfo.sslName,r.cipherKey,r.cipherIV),this._macSSLName=r.macInfo.sslName,this._macKey=r.macKey,this._macActualLen=r.macInfo.actualLen,this._macETM=r.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let n=r.cipherInfo.discardLen;if(n){let i=Na.get(n);i===void 0&&(i=Buffer.alloc(n),Na.set(n,i)),this._cipherInstance.update(i)}}free(){this._dead=!0}allocPacket(e){let r=this._encBlockLen,n=5+e,i=r-(n-this._aadLen&r-1);i<4&&(i+=r),n+=i;let o=Buffer.allocUnsafe(n);return Or(o,n-4,0),o[4]=i,ci(o,5+e,i),o}encrypt(e){if(this._dead)return;let r;if(this._macETM){let i=new Uint8Array(e.buffer,e.byteOffset,4),o=this._cipherInstance.update(new Uint8Array(e.buffer,e.byteOffset+4,e.length-4));this._onWrite(i),this._onWrite(o),r=qu(this._macSSLName,this._macKey),Or(Ki,this.outSeqno,0),r.update(Ki),r.update(i),r.update(o)}else{let i=this._cipherInstance.update(e);this._onWrite(i),r=qu(this._macSSLName,this._macKey),Or(Ki,this.outSeqno,0),r.update(Ki),r.update(e)}let n=r.digest();n.length>this._macActualLen&&(n=n.slice(0,this._macActualLen)),this._onWrite(n),this.outSeqno=this.outSeqno+1>>>0}},el=class{static{c(this,"GenericCipherBinding")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._encBlockLen=r.cipherInfo.blockLen,this._macLen=r.macInfo.len,this._macActualLen=r.macInfo.actualLen,this._aadLen=r.macInfo.isETM?4:0,this._instance=new ll(r.cipherInfo.sslName,r.cipherKey,r.cipherIV,r.macInfo.sslName,r.macKey,r.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(e){let r=this._encBlockLen,n=5+e,i=r-(n-this._aadLen&r-1);i<4&&(i+=r),n+=i;let o=Buffer.allocUnsafe(n+this._macLen);return Or(o,n-4,0),o[4]=i,ci(o,5+e,i),o}encrypt(e){this._dead||(this._instance.encrypt(e,this.outSeqno),this._macActualLen<this._macLen&&(e=new Mn(e.buffer,e.byteOffset,e.length-(this._macLen-this._macActualLen))),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},tl=class{static{c(this,"NullDecipher")}constructor(e,r){this.inSeqno=e,this._onPayload=r,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(e,r,n){for(;r<n;){if(this._lenBytes<4){let o=Math.min(4-this._lenBytes,n-r);for(this._lenBytes+=o;o--;)this._len=(this._len<<8)+e[r++];if(this._lenBytes<4)return;if(this._len>ui||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(r>=n)return}if(this._packetPos<this._len){let o=Math.min(this._len-this._packetPos,n-r),s;if(r!==0||o!==n?s=new Uint8Array(e.buffer,e.byteOffset+r,o):s=e,o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._packetPos)),r+=o,this._packetPos+=o,this._packetPos<this._len)return}let i=this._packet?new Mn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Sg;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}},rl=class{static{c(this,"ChaChaPolyDecipherNative")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._decKeyMain=r.decipherKey.slice(0,32),this._decKeyPktLen=r.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(e,r,n){for(;r<n;){if(this._lenPos<4){let a=Math.min(4-this._lenPos,n-r);for(;a--;)this._lenBuf[this._lenPos++]=e[r++];if(this._lenPos<4)return;Sr[0]=0,Or(Sr,this.inSeqno,12);let u=Ra("chacha20",this._decKeyPktLen,Sr).update(this._lenBuf);if(this._len=Xo(u,0),this._len>ui||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(r>=n)return;let a=Math.min(this._len-this._pktLen,n-r),u;if(r!==0||a!==n?u=new Uint8Array(e.buffer,e.byteOffset+r,a):u=e,a===this._len?this._packet=u:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(u,this._pktLen)),r+=a,this._pktLen+=a,this._pktLen<this._len||r>=n)return}{let a=Math.min(16-this._macPos,n-r);if(r!==0||a!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+r,a),this._macPos):this._mac.set(e,this._macPos),r+=a,this._macPos+=a,this._macPos<16)return}Sr[0]=0,Or(Sr,this.inSeqno,12);let i=Gi("chacha20",this._decKeyMain,Sr).update(wg);if(hl(Jo,this._lenBuf,4,this._packet,this._packet.length,i),this._calcMac.set(new Uint8Array(Yo.HEAPU8.buffer,Jo,16),0),!Qu(this._calcMac,this._mac))throw new Error("Invalid MAC");Sr[0]=1;let o=Ra("chacha20",this._decKeyMain,Sr).update(this._packet),s=new Mn(o.buffer,o.byteOffset+1,o.length-o[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let a=this._onPayload(s);if(a!==void 0)return a===!1?r:a}}}},nl=class{static{c(this,"ChaChaPolyDecipherBinding")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._instance=new dl(r.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(e,r,n){for(;r<n;){if(this._lenPos<4){let o=Math.min(4-this._lenPos,n-r);for(;o--;)this._lenBuf[this._lenPos++]=e[r++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>ui||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(r>=n)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,n-r),s;if(r!==0||o!==n?s=new Uint8Array(e.buffer,e.byteOffset+r,o):s=e,o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._pktLen)),r+=o,this._pktLen+=o,this._pktLen<this._len||r>=n)return}{let o=Math.min(16-this._macPos,n-r);if(r!==0||o!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._macPos):this._mac.set(e,this._macPos),r+=o,this._macPos+=o,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let i=new Mn(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 o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}},il=class{static{c(this,"AESGCMDecipherNative")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._decipherInstance=null,this._decipherSSLName=r.decipherInfo.sslName,this._decipherKey=r.decipherKey,this._decipherIV=r.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(e,r,n){for(;r<n;){if(this._lenBytes<4){let o=Math.min(4-this._lenBytes,n-r);for(this._lenBytes+=o;o--;)this._len=(this._len<<8)+e[r++];if(this._lenBytes<4)return;if(this._len+20>ui||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=Ra(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(Hx(this._len))}if(this._pktLen<this._len){if(r>=n)return;let o=Math.min(this._len-this._pktLen,n-r),s;if(r!==0||o!==n?s=this._decipherInstance.update(new Uint8Array(e.buffer,e.byteOffset+r,o)):s=this._decipherInstance.update(e),s.length&&(o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._packetPos)),this._packetPos+=s.length),r+=o,this._pktLen+=o,this._pktLen<this._len||r>=n)return}{let o=Math.min(16-this._tagPos,n-r);if(r!==0||o!==n?this._tag.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._tagPos):this._tag.set(e,this._tagPos),r+=o,this._tagPos+=o,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let o=this._decipherInstance.final();o.length&&(this._packet?this._packet.set(o,this._packetPos):this._packet=o)}let i=this._packet?new Mn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Sg;this.inSeqno=this.inSeqno+1>>>0,Pg(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}},ol=class{static{c(this,"AESGCMDecipherBinding")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._instance=new fl(r.decipherInfo.sslName,r.decipherKey,r.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(e,r,n){for(;r<n;){if(this._lenBytes<4){let o=Math.min(4-this._lenBytes,n-r);for(this._lenBytes+=o;o--;)this._len=(this._len<<8)+e[r++];if(this._lenBytes<4)return;if(this._len+20>ui||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(r>=n)return;let o=Math.min(this._len-this._pktLen,n-r),s;if(r!==0||o!==n?s=new Uint8Array(e.buffer,e.byteOffset+r,o):s=e,o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._pktLen)),r+=o,this._pktLen+=o,this._pktLen<this._len||r>=n)return}{let o=Math.min(16-this._tagPos,n-r);if(r!==0||o!==n?this._tag.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._tagPos):this._tag.set(e,this._tagPos),r+=o,this._tagPos+=o,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let i=new Mn(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 o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}},sl=class{static{c(this,"GenericDecipherNative")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._decipherInstance=Ra(r.decipherInfo.sslName,r.decipherKey,r.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(r.macInfo.isETM?4:r.decipherInfo.blockLen),this._blockSize=r.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(r.macInfo.actualLen),this._macPos=0,this._macSSLName=r.macInfo.sslName,this._macKey=r.macKey,this._macActualLen=r.macInfo.actualLen,this._macETM=r.macInfo.isETM,this._macInstance=null;let n=r.decipherInfo.discardLen;if(n){let i=Na.get(n);i===void 0&&(i=Buffer.alloc(n),Na.set(n,i)),this._decipherInstance.update(i)}}free(){}decrypt(e,r,n){for(;r<n;){if(this._blockPos<this._block.length){let s=Math.min(this._block.length-this._blockPos,n-r);if(r!==0||s!==n||s<e.length?this._block.set(new Uint8Array(e.buffer,e.byteOffset+r,s),this._blockPos):this._block.set(e,this._blockPos),r+=s,this._blockPos+=s,this._blockPos<this._block.length)return;let a,u;if(this._macETM?this._len=u=Xo(this._block,0):(a=this._decipherInstance.update(this._block),this._len=Xo(a,0),u=4+this._len-this._blockSize),this._len>ui||this._len<5||(u&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=qu(this._macSSLName,this._macKey),Or(Ki,this.inSeqno,0),this._macInstance.update(Ki),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),r>=n)return}if(this._pktLen<this._len){let s=Math.min(this._len-this._pktLen,n-r),a;r!==0||s!==n?a=new Uint8Array(e.buffer,e.byteOffset+r,s):a=e,this._macETM&&this._macInstance.update(a);let u=this._decipherInstance.update(a);if(u.length&&(s===this._len?this._packet=u:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(u,this._packetPos)),this._packetPos+=u.length),r+=s,this._pktLen+=s,this._pktLen<this._len||r>=n)return}{let s=Math.min(this._macActualLen-this._macPos,n-r);if(r!==0||s!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+r,s),this._macPos):this._mac.set(e,this._macPos),r+=s,this._macPos+=s,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)),!jx(i,this._mac))throw new Error("Invalid MAC");let o=new Mn(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 s=this._onPayload(o);if(s!==void 0)return s===!1?r:s}}}},al=class{static{c(this,"GenericDecipherBinding")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._instance=new pl(r.decipherInfo.sslName,r.decipherKey,r.decipherIV,r.macInfo.sslName,r.macKey,r.macInfo.isETM,r.macInfo.actualLen),this._block=Buffer.allocUnsafe(r.macInfo.isETM||r.decipherInfo.stream?4:r.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(r.macInfo.actualLen),this._macPos=0,this._macActualLen=r.macInfo.actualLen,this._macETM=r.macInfo.isETM}free(){this._instance.free()}decrypt(e,r,n){for(;r<n;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,n-r);if(r!==0||o!==n||o<e.length?this._block.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._blockPos):this._block.set(e,this._blockPos),r+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let s;if(this._macETM?this._len=s=Xo(this._block,0):(this._instance.decryptBlock(this._block),this._len=Xo(this._block,0),s=4+this._len-this._block.length),this._len>ui||this._len<5||(s&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))),r>=n)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,n-r),s;if(r!==0||o!==n?s=new Uint8Array(e.buffer,e.byteOffset+r,o):s=e,o===this._len?this._packet=s:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(s,this._pktLen)),r+=o,this._pktLen+=o,this._pktLen<this._len||r>=n)return}{let o=Math.min(this._macActualLen-this._macPos,n-r);if(r!==0||o!==n?this._mac.set(new Uint8Array(e.buffer,e.byteOffset+r,o),this._macPos):this._mac.set(e,this._macPos),r+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let i=new Mn(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 o=this._onPayload(i);if(o!==void 0)return o===!1?r:o}}}};function Pg(t){++t[11]>>>8&&++t[10]>>>8&&++t[9]>>>8&&++t[8]>>>8&&++t[7]>>>8&&++t[6]>>>8&&++t[5]>>>8&&++t[4]>>>8}c(Pg,"ivIncrement");var Hx=(()=>{let t=Buffer.alloc(4);return e=>(t[0]=e>>>24,t[1]=e>>>16,t[2]=e>>>8,t[3]=e,t)})();function jx(t,e){return t.length!==e.length?(Qu(t,t),!1):Qu(t,e)}c(jx,"timingSafeEquals");function Wx(t){if(typeof t!="object"||t===null)throw new Error("Invalid config");if(typeof t.outbound!="object"||t.outbound===null)throw new Error("Invalid outbound");let e=t.outbound;if(typeof e.onWrite!="function")throw new Error("Invalid outbound.onWrite");if(typeof e.cipherInfo!="object"||e.cipherInfo===null)throw new Error("Invalid outbound.cipherInfo");if(!Buffer.isBuffer(e.cipherKey)||e.cipherKey.length!==e.cipherInfo.keyLen)throw new Error("Invalid outbound.cipherKey");if(e.cipherInfo.ivLen&&(!Buffer.isBuffer(e.cipherIV)||e.cipherIV.length!==e.cipherInfo.ivLen))throw new Error("Invalid outbound.cipherIV");if(typeof e.seqno!="number"||e.seqno<0||e.seqno>vg)throw new Error("Invalid outbound.seqno");let r=!!e.forceNative;switch(e.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return cl&&!r?new Xu(t):new Yu(t);case"chacha20":return ul&&!r?new Zu(t):new Gu(t);default:{if(typeof e.macInfo!="object"||e.macInfo===null)throw new Error("Invalid outbound.macInfo");if(!Buffer.isBuffer(e.macKey)||e.macKey.length!==e.macInfo.len)throw new Error("Invalid outbound.macKey");return ll&&!r?new el(t):new Ju(t)}}}c(Wx,"createCipher");function qx(t){if(typeof t!="object"||t===null)throw new Error("Invalid config");if(typeof t.inbound!="object"||t.inbound===null)throw new Error("Invalid inbound");let e=t.inbound;if(typeof e.onPayload!="function")throw new Error("Invalid inbound.onPayload");if(typeof e.decipherInfo!="object"||e.decipherInfo===null)throw new Error("Invalid inbound.decipherInfo");if(!Buffer.isBuffer(e.decipherKey)||e.decipherKey.length!==e.decipherInfo.keyLen)throw new Error("Invalid inbound.decipherKey");if(e.decipherInfo.ivLen&&(!Buffer.isBuffer(e.decipherIV)||e.decipherIV.length!==e.decipherInfo.ivLen))throw new Error("Invalid inbound.decipherIV");if(typeof e.seqno!="number"||e.seqno<0||e.seqno>vg)throw new Error("Invalid inbound.seqno");let r=!!e.forceNative;switch(e.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return fl&&!r?new ol(t):new il(t);case"chacha20":return dl&&!r?new nl(t):new rl(t);default:{if(typeof e.macInfo!="object"||e.macInfo===null)throw new Error("Invalid inbound.macInfo");if(!Buffer.isBuffer(e.macKey)||e.macKey.length!==e.macInfo.len)throw new Error("Invalid inbound.macKey");return pl&&!r?new al(t):new sl(t)}}}c(qx,"createDecipher");Tg.exports={CIPHER_INFO:Mx,MAC_INFO:Fx,bindingAvailable:!!Vu,init:new Promise(async(t,e)=>{try{Yo=await Ig()(),Jo=Yo._malloc(16),hl=Yo.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(r){return e(r)}t()}),NullCipher:Ku,createCipher:Wx,NullDecipher:tl,createDecipher:qx}});var Hn=le((X3,Lg)=>{"use strict";var{createDecipheriv:ml,createECDH:Qx,createHash:ts,createHmac:Vx,createSign:Kx,createVerify:Gx,getCiphers:Zx,sign:kg,verify:Cg}=require("crypto"),Yx=Zx(),{Ber:Oe}=Ko(),Xx=zu().pbkdf,{CIPHER_INFO:rs}=zn(),{eddsaSupported:_l,SUPPORTED_CIPHER:Jx}=An(),{bufferSlice:li,makeBufferParser:eI,readString:Re,readUInt32BE:es,writeUInt32BE:cr}=Qr(),bn=Symbol("Hash Algorithm"),Vr=Symbol("Private key PEM"),on=Symbol("Public key PEM"),Fn=Symbol("Public key SSH"),Zi=Symbol("Decrypted Key"),gl=Object.create(null);{let t=Object.keys(rs);for(let e=0;e<t.length;++e){let r=rs[t[e]].sslName;!r||gl[r]||(gl[r]=rs[t[e]])}}var Oa=eI();function Kr(t,e){e=e.base64Slice(0,e.length);let r=e.replace(/.{64}/g,`$&
9
9
  `);return e.length&63&&(r+=`
10
10
  `),`-----BEGIN ${t} KEY-----
11
- ${r}-----END ${t} KEY-----`}c(Vr,"makePEM");function rs(t,e){let r=Buffer.allocUnsafe(t.length+e.length);return r.set(t,0),r.set(e,t.length),r}c(rs,"combineBuffers");function _l(t,e){let r=t.length,n=t._pos||0;for(let i=0;i<e;++i){let o=r-n;if(n>=r||o<4)return!1;let s=Jo(t,n);if(o<4+s)return!1;n+=4+s}return t._pos=n,!0}c(_l,"skipFields");function ns(t,e){let r=new Oe.Writer;return r.startSequence(),r.startSequence(),r.writeOID("1.2.840.113549.1.1.1"),r.writeNull(),r.endSequence(),r.startSequence(Oe.BitString),r.writeByte(0),r.startSequence(),r.writeBuffer(t,Oe.Integer),r.writeBuffer(e,Oe.Integer),r.endSequence(),r.endSequence(),r.endSequence(),Vr("PUBLIC",r.buffer)}c(ns,"genOpenSSLRSAPub");function is(t,e){let r=Buffer.allocUnsafe(15+e.length+4+t.length);ar(r,7,0),r.utf8Write("ssh-rsa",4,7);let n=11;return ar(r,e.length,n),r.set(e,n+=4),ar(r,t.length,n+=e.length),r.set(t,n+4),r}c(is,"genOpenSSHRSAPub");var wg=(()=>{function t(n,i,o,s,a,u,l,d){let p=new Oe.Writer;return p.startSequence(),p.writeInt(0,Oe.Integer),p.writeBuffer(n,Oe.Integer),p.writeBuffer(i,Oe.Integer),p.writeBuffer(o,Oe.Integer),p.writeBuffer(s,Oe.Integer),p.writeBuffer(a,Oe.Integer),p.writeBuffer(u,Oe.Integer),p.writeBuffer(l,Oe.Integer),p.writeBuffer(d,Oe.Integer),p.endSequence(),p.buffer}c(t,"genRSAASN1Buf");function e(n){return BigInt(`0x${n.hexSlice(0,n.length)}`)}c(e,"bigIntFromBuffer");function r(n){let i=n.toString(16);if((i.length&1)!==0)i=`0${i}`;else{let o=i.charCodeAt(0);(o===56||o===57||o>=97&&o<=102)&&(i=`00${i}`)}return Buffer.from(i,"hex")}return c(r,"bigIntToBuffer"),c(function(i,o,s,a,u,l){let d=e(s),p=r(d%(e(u)-1n)),g=r(d%(e(l)-1n));return Vr("RSA PRIVATE",t(i,o,s,u,l,p,g,a))},"genOpenSSLRSAPriv")})();function os(t,e,r,n){let i=new Oe.Writer;return i.startSequence(),i.startSequence(),i.writeOID("1.2.840.10040.4.1"),i.startSequence(),i.writeBuffer(t,Oe.Integer),i.writeBuffer(e,Oe.Integer),i.writeBuffer(r,Oe.Integer),i.endSequence(),i.endSequence(),i.startSequence(Oe.BitString),i.writeByte(0),i.writeBuffer(n,Oe.Integer),i.endSequence(),i.endSequence(),Vr("PUBLIC",i.buffer)}c(os,"genOpenSSLDSAPub");function ss(t,e,r,n){let i=Buffer.allocUnsafe(15+t.length+4+e.length+4+r.length+4+n.length);ar(i,7,0),i.utf8Write("ssh-dss",4,7);let o=11;return ar(i,t.length,o),i.set(t,o+=4),ar(i,e.length,o+=t.length),i.set(e,o+=4),ar(i,r.length,o+=e.length),i.set(r,o+=4),ar(i,n.length,o+=r.length),i.set(n,o+4),i}c(ss,"genOpenSSHDSAPub");function Pg(t,e,r,n,i){let o=new Oe.Writer;return o.startSequence(),o.writeInt(0,Oe.Integer),o.writeBuffer(t,Oe.Integer),o.writeBuffer(e,Oe.Integer),o.writeBuffer(r,Oe.Integer),o.writeBuffer(n,Oe.Integer),o.writeBuffer(i,Oe.Integer),o.endSequence(),Vr("DSA PRIVATE",o.buffer)}c(Pg,"genOpenSSLDSAPriv");function Tg(t){let e=new Oe.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.3.101.112"),e.endSequence(),e.startSequence(Oe.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),Vr("PUBLIC",e.buffer)}c(Tg,"genOpenSSLEdPub");function kg(t){let e=Buffer.allocUnsafe(19+t.length);return ar(e,11,0),e.utf8Write("ssh-ed25519",4,11),ar(e,t.length,15),e.set(t,19),e}c(kg,"genOpenSSHEdPub");function Fx(t){let e=new Oe.Writer;return e.startSequence(),e.writeInt(0,Oe.Integer),e.startSequence(),e.writeOID("1.3.101.112"),e.endSequence(),e.startSequence(Oe.OctetString),e.writeBuffer(t,Oe.OctetString),e.endSequence(),e.endSequence(),Vr("PRIVATE",e.buffer)}c(Fx,"genOpenSSLEdPriv");function yl(t,e){let r=new Oe.Writer;return r.startSequence(),r.startSequence(),r.writeOID("1.2.840.10045.2.1"),r.writeOID(t),r.endSequence(),r.startSequence(Oe.BitString),r.writeByte(0),r._ensure(e.length),r._buf.set(e,r._offset),r._offset+=e.length,r.endSequence(),r.endSequence(),Vr("PUBLIC",r.buffer)}c(yl,"genOpenSSLECDSAPub");function Al(t,e){let r;switch(t){case"1.2.840.10045.3.1.7":r="nistp256";break;case"1.3.132.0.34":r="nistp384";break;case"1.3.132.0.35":r="nistp521";break;default:return}let n=Buffer.allocUnsafe(39+e.length);return ar(n,19,0),n.utf8Write(`ecdsa-sha2-${r}`,4,19),ar(n,8,23),n.utf8Write(r,27,8),ar(n,e.length,35),n.set(e,39),n}c(Al,"genOpenSSHECDSAPub");function Hx(t,e,r){let n=new Oe.Writer;return n.startSequence(),n.writeInt(1,Oe.Integer),n.writeBuffer(r,Oe.OctetString),n.startSequence(160),n.writeOID(t),n.endSequence(),n.startSequence(161),n.startSequence(Oe.BitString),n.writeByte(0),n._ensure(e.length),n._buf.set(e,n._offset),n._offset+=e.length,n.endSequence(),n.endSequence(),n.endSequence(),Vr("EC PRIVATE",n.buffer)}c(Hx,"genOpenSSLECDSAPriv");function jx(t,e){let r=Nx(t);return r.setPrivateKey(e),r.getPublicKey()}c(jx,"genOpenSSLECDSAPubFromPriv");var as={sign:c(typeof vg=="function"?function(e,r){let n=this[Kr];if(n===null)return new Error("No private key available");(!r||typeof r!="string")&&(r=this[En]);try{return vg(r,e,n)}catch(i){return i}}:function(e,r){let n=this[Kr];if(n===null)return new Error("No private key available");(!r||typeof r!="string")&&(r=this[En]);let i=$x(r);i.update(e);try{return i.sign(n)}catch(o){return o}},"sign"),verify:c(typeof Sg=="function"?function(e,r,n){let i=this[nn];if(i===null)return new Error("No public key available");(!n||typeof n!="string")&&(n=this[En]);try{return Sg(n,e,i,r)}catch(o){return o}}:function(e,r,n){let i=this[nn];if(i===null)return new Error("No public key available");(!n||typeof n!="string")&&(n=this[En]);let o=Dx(n);o.update(e);try{return o.verify(i,r)}catch(s){return s}},"verify"),isPrivateKey:c(function(){return this[Kr]!==null},"isPrivateKey"),getPrivatePEM:c(function(){return this[Kr]},"getPrivatePEM"),getPublicPEM:c(function(){return this[nn]},"getPublicPEM"),getPublicSSH:c(function(){return this[Mn]},"getPublicSSH"),equals:c(function(e){let r=Ng(e);return r instanceof Error?!1:this.type===r.type&&this[Kr]===r[Kr]&&this[nn]===r[nn]&&this[Mn].equals(r[Mn])},"equals")};function Oa(t,e,r,n,i,o,s){this.type=t,this.comment=e,this[Kr]=r,this[nn]=n,this[Mn]=i,this[En]=o,this[Gi]=s}c(Oa,"OpenSSH_Private");Oa.prototype=as;{let e=function(r,n,i){let o=[];if(r.length<8)return new Error("Malformed OpenSSH private key");let s=Jo(r,0),a=Jo(r,4);if(s!==a)return i?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");r._pos=8;let u,l;for(u=0;u<n;++u){let p,g,h,_,E=Re(r,r._pos,!0);if(E===void 0)return new Error("Malformed OpenSSH private key");switch(E){case"ssh-rsa":{let I=Re(r,r._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");let w=Re(r,r._pos);if(w===void 0)return new Error("Malformed OpenSSH private key");let H=Re(r,r._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let $=Re(r,r._pos);if($===void 0)return new Error("Malformed OpenSSH private key");let X=Re(r,r._pos);if(X===void 0)return new Error("Malformed OpenSSH private key");let Z=Re(r,r._pos);if(Z===void 0)return new Error("Malformed OpenSSH private key");h=ns(I,w),_=is(I,w),g=wg(I,w,H,$,X,Z),p="sha1";break}case"ssh-dss":{let I=Re(r,r._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");let w=Re(r,r._pos);if(w===void 0)return new Error("Malformed OpenSSH private key");let H=Re(r,r._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let $=Re(r,r._pos);if($===void 0)return new Error("Malformed OpenSSH private key");let X=Re(r,r._pos);if(X===void 0)return new Error("Malformed OpenSSH private key");h=os(I,w,H,$),_=ss(I,w,H,$),g=Pg(I,w,H,$,X),p="sha1";break}case"ssh-ed25519":{if(!ml)return new Error(`Unsupported OpenSSH private key type: ${E}`);let I=Re(r,r._pos);if(I===void 0||I.length!==32)return new Error("Malformed OpenSSH private key");let w=Re(r,r._pos);if(w===void 0||w.length!==64)return new Error("Malformed OpenSSH private key");h=Tg(I),_=kg(I),g=Fx(ui(w,0,32)),p=null;break}case"ecdsa-sha2-nistp256":p="sha256",l="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":p===void 0&&(p="sha384",l="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(p===void 0&&(p="sha512",l="1.3.132.0.35"),!_l(r,1))return new Error("Malformed OpenSSH private key");let I=Re(r,r._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");let w=Re(r,r._pos);if(w===void 0)return new Error("Malformed OpenSSH private key");h=yl(l,I),_=Al(l,I),g=Hx(l,I,w);break}default:return new Error(`Unsupported OpenSSH private key type: ${E}`)}let b=Re(r,r._pos,!0);if(b===void 0)return new Error("Malformed OpenSSH private key");o.push(new Oa(E,b,g,h,_,p,i))}let d=0;for(u=r._pos;u<r.length;++u)if(r[u]!==++d%255)return new Error("Malformed OpenSSH private key");return o};c(e,"parseOpenSSHPrivKeys");let t=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;Oa.parse=(r,n)=>{let i=t.exec(r);if(i===null)return null;let o,s=Buffer.from(i[1],"base64");if(s.length<31)return new Error("Malformed OpenSSH private key");let a=s.utf8Slice(0,15);if(a!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${a}`);let u=Re(s,15,!0);if(u===void 0)return new Error("Malformed OpenSSH private key");if(u!=="none"&&zx.indexOf(u)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${u}`);let l=Re(s,s._pos,!0);if(l===void 0)return new Error("Malformed OpenSSH private key");if(l!=="none"){if(u==="none")return new Error("Malformed OpenSSH private key");if(l!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${l}`);if(!n)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(u!=="none")return new Error("Malformed OpenSSH private key");let d,p,g;u!=="none"&&(d=ts[u]);let h=Re(s,s._pos);if(h===void 0)return new Error("Malformed OpenSSH private key");if(h.length)switch(l){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let E=Re(h,0);if(E===void 0||h._pos+4>h.length)return new Error("Malformed OpenSSH private key");let b=Jo(h,h._pos),I=Buffer.allocUnsafe(d.keyLen+d.ivLen);if(Lx(n,n.length,E,E.length,I,I.length,b)!==0)return new Error("Failed to generate information to decrypt key");p=ui(I,0,d.keyLen),g=ui(I,d.keyLen,I.length);break}}else if(l!=="none")return new Error("Malformed OpenSSH private key");if(s._pos+3>=s.length)return new Error("Malformed OpenSSH private key");let _=Jo(s,s._pos);if(s._pos+=4,_>0){for(let b=0;b<_;++b){let I=Re(s,s._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");if(Re(I,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let E=Re(s,s._pos);if(E===void 0)return new Error("Malformed OpenSSH private key");if(p!==void 0){if(E.length<d.blockLen||E.length%d.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let b={authTagLength:d.authLen},I=gl(d.sslName,p,g,b);if(I.setAutoPadding(!1),d.authLen>0){if(s.length-s._pos<d.authLen)return new Error("Malformed OpenSSH private key");I.setAuthTag(ui(s,s._pos,s._pos+=d.authLen))}E=rs(I.update(E),I.final())}catch(b){return b}}if(s._pos!==s.length)return new Error("Malformed OpenSSH private key");o=e(E,_,p!==void 0)}else o=[];return o instanceof Error?o:o[0]}}function $a(t,e,r,n,i,o,s){this.type=t,this.comment=e,this[Kr]=r,this[nn]=n,this[Mn]=i,this[En]=o,this[Gi]=s}c($a,"OpenSSH_Old_Private");$a.prototype=as;{let t=/^-----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-----$/;$a.parse=(e,r)=>{let n=t.exec(e);if(n===null)return null;let i=Buffer.from(n[3],"base64"),o=n[2],s=!1;if(o!==void 0){o=o.split(/\r\n|\n/g);for(let _=0;_<o.length;++_){let E=o[_],b=E.indexOf(":");if(E.slice(0,b)==="DEK-Info"){let I=E.slice(b+2);if(b=I.indexOf(","),b===-1)continue;let w=I.slice(0,b).toLowerCase();if(Ux.indexOf(w)===-1)return new Error(`Cipher (${w}) not supported for encrypted OpenSSH private key`);let H=hl[w];if(!H)return new Error(`Cipher (${w}) not supported for encrypted OpenSSH private key`);let $=Buffer.from(I.slice(b+1),"hex");if($.length!==H.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!r)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let X=ui($,0,8),Z=es("md5").update(r).update(X).digest();for(;Z.length<H.keyLen;)Z=rs(Z,es("md5").update(Z).update(r).update(X).digest());Z.length>H.keyLen&&(Z=ui(Z,0,H.keyLen));try{let Y=gl(w,Z,$);Y.setAutoPadding(!1),i=rs(Y.update(i),Y.final()),s=!0}catch(Y){return Y}}}}let a,u,l,d,p,g,h="Malformed OpenSSH private key";switch(s&&(h+=". Bad passphrase?"),n[1]){case"RSA":a="ssh-rsa",u=Vr("RSA PRIVATE",i);try{g=new Oe.Reader(i),g.readSequence(),g.readInt();let _=g.readString(Oe.Integer,!0);if(_===null)return new Error(h);let E=g.readString(Oe.Integer,!0);if(E===null)return new Error(h);l=ns(_,E),d=is(_,E)}catch{return new Error(h)}p="sha1";break;case"DSA":a="ssh-dss",u=Vr("DSA PRIVATE",i);try{g=new Oe.Reader(i),g.readSequence(),g.readInt();let _=g.readString(Oe.Integer,!0);if(_===null)return new Error(h);let E=g.readString(Oe.Integer,!0);if(E===null)return new Error(h);let b=g.readString(Oe.Integer,!0);if(b===null)return new Error(h);let I=g.readString(Oe.Integer,!0);if(I===null)return new Error(h);l=os(_,E,b,I),d=ss(_,E,b,I)}catch{return new Error(h)}p="sha1";break;case"EC":{let _,E,b;try{g=new Oe.Reader(i),g.readSequence(),g.readInt(),E=g.readString(Oe.OctetString,!0),g.readByte();let w=g.readLength();if(w!==null){if(g._offset=w,b=g.readOID(),b===null)return new Error(h);switch(b){case"1.2.840.10045.3.1.7":_="prime256v1",a="ecdsa-sha2-nistp256",p="sha256";break;case"1.3.132.0.34":_="secp384r1",a="ecdsa-sha2-nistp384",p="sha384";break;case"1.3.132.0.35":_="secp521r1",a="ecdsa-sha2-nistp521",p="sha512";break;default:return new Error(`Unsupported private key EC OID: ${b}`)}}else return new Error(h)}catch{return new Error(h)}u=Vr("EC PRIVATE",i);let I=jx(_,E);l=yl(b,I),d=Al(b,I);break}}return new $a(a,"",u,l,d,p,s)}}function Da(t,e,r,n,i,o,s){this.type=t,this.comment=e,this[Kr]=r,this[nn]=n,this[Mn]=i,this[En]=o,this[Gi]=s}c(Da,"PPK_Private");Da.prototype=as;{let t=Buffer.alloc(0),e=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),r=Buffer.from([0,0,0,0]),n=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]+)/;Da.parse=(o,s)=>{let a=i.exec(o);if(a===null)return null;let u=a[2],l=u!=="none";if(l&&!s)return new Error("Encrypted PPK private key detected, but no passphrase given");let d=Buffer.from(a[5],"base64");if(l){let M=ts[u],L=rs(es("sha1").update(r).update(s).digest(),es("sha1").update(n).update(s).digest());L.length>M.keyLen&&(L=ui(L,0,M.keyLen));try{let T=gl(M.sslName,L,e);T.setAutoPadding(!1),d=rs(T.update(d),T.final())}catch(T){return T}}let p=a[1],g=a[3],h=Buffer.from(a[4],"base64"),_=a[6],E=p.length,b=u.length,I=Buffer.byteLength(g),w=h.length,H=d.length,$=Buffer.allocUnsafe(4+E+4+b+4+I+4+w+4+H),X=0;if(ar($,E,X),$.utf8Write(p,X+=4,E),ar($,b,X+=E),$.utf8Write(u,X+=4,b),ar($,I,X+=b),$.utf8Write(g,X+=4,I),ar($,w,X+=I),$.set(h,X+=4),ar($,H,X+=w),$.set(d,X+4),s||(s=t),Ox("sha1",es("sha1").update("putty-private-key-file-mac-key").update(s).digest()).update($).digest("hex")!==_)return l?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let Y,P,k;switch(h._pos=0,_l(h,1),p){case"ssh-rsa":{let M=Re(h,h._pos);if(M===void 0)return new Error("Malformed PPK public key");let L=Re(h,h._pos);if(L===void 0)return new Error("Malformed PPK public key");let T=Re(d,0);if(T===void 0)return new Error("Malformed PPK private key");let F=Re(d,d._pos);if(F===void 0)return new Error("Malformed PPK private key");let j=Re(d,d._pos);if(j===void 0)return new Error("Malformed PPK private key");let B=Re(d,d._pos);if(B===void 0)return new Error("Malformed PPK private key");Y=ns(L,M),P=is(L,M),k=wg(L,M,T,B,F,j);break}case"ssh-dss":{let M=Re(h,h._pos);if(M===void 0)return new Error("Malformed PPK public key");let L=Re(h,h._pos);if(L===void 0)return new Error("Malformed PPK public key");let T=Re(h,h._pos);if(T===void 0)return new Error("Malformed PPK public key");let F=Re(h,h._pos);if(F===void 0)return new Error("Malformed PPK public key");let j=Re(d,0);if(j===void 0)return new Error("Malformed PPK private key");Y=os(M,L,T,F),P=ss(M,L,T,F),k=Pg(M,L,T,F,j);break}}return new Da(p,g,k,Y,P,"sha1",l)}}function Ua(t,e,r,n,i){this.type=t,this.comment=e,this[Kr]=null,this[nn]=r,this[Mn]=n,this[En]=i,this[Gi]=!1}c(Ua,"OpenSSH_Public");Ua.prototype=as;{let t;ml?t=/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:t=/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,Ua.parse=e=>{let r=t.exec(e);if(r===null)return null;let n=r[1],i=r[2],o=Buffer.from(r[3],"base64"),s=r[4]||"",a=Re(o,o._pos,!0);return a===void 0||a.indexOf(i)!==0?new Error("Malformed OpenSSH public key"):El(o,i,s,n)}}function Ba(t,e,r,n,i){this.type=t,this.comment=e,this[Kr]=null,this[nn]=r,this[Mn]=n,this[En]=i,this[Gi]=!1}c(Ba,"RFC4716_Public");Ba.prototype=as;{let t=/^---- BEGIN SSH2 PUBLIC KEY ----(?:\r?\n)((?:.{0,72}\r?\n)+)---- END SSH2 PUBLIC KEY ----$/,e=/^[A-Z0-9a-z/+=\r\n]+$/,r=/^([\x21-\x39\x3B-\x7E]{1,64}): ((?:[^\\]*\\\r?\n)*[^\r\n]+)\r?\n/gm,n=/\\\r?\n/g;Ba.parse=i=>{let o=t.exec(i);if(o===null)return null;let s=o[1],a=0,u="";for(;o=r.exec(s);){let h=o[1],_=o[2].replace(n,"");if(_.length>1024)return r.lastIndex=0,new Error("Malformed RFC4716 public key");a=r.lastIndex,h.toLowerCase()==="comment"&&(u=_,u.length>1&&u.charCodeAt(0)===34&&u.charCodeAt(u.length-1)===34&&(u=u.slice(1,-1)))}let l=s.slice(a);if(!e.test(l))return new Error("Malformed RFC4716 public key");l=Buffer.from(l,"base64");let d=Re(l,0,!0);if(d===void 0)return new Error("Malformed RFC4716 public key");let p=null,g=null;switch(d){case"ssh-rsa":{let h=Re(l,l._pos);if(h===void 0)return new Error("Malformed RFC4716 public key");let _=Re(l,l._pos);if(_===void 0)return new Error("Malformed RFC4716 public key");p=ns(_,h),g=is(_,h);break}case"ssh-dss":{let h=Re(l,l._pos);if(h===void 0)return new Error("Malformed RFC4716 public key");let _=Re(l,l._pos);if(_===void 0)return new Error("Malformed RFC4716 public key");let E=Re(l,l._pos);if(E===void 0)return new Error("Malformed RFC4716 public key");let b=Re(l,l._pos);if(b===void 0)return new Error("Malformed RFC4716 public key");p=os(h,_,E,b),g=ss(h,_,E,b);break}default:return new Error("Malformed RFC4716 public key")}return new Ba(d,u,p,g,"sha1")}}function El(t,e,r,n){if(!Cg(e))return new Error(`Unsupported OpenSSH public key type: ${e}`);let i,o,s=null,a=null;switch(e){case"ssh-rsa":{let u=Re(t,t._pos||0);if(u===void 0)return new Error("Malformed OpenSSH public key");let l=Re(t,t._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");s=ns(l,u),a=is(l,u),i="sha1";break}case"ssh-dss":{let u=Re(t,t._pos||0);if(u===void 0)return new Error("Malformed OpenSSH public key");let l=Re(t,t._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");let d=Re(t,t._pos);if(d===void 0)return new Error("Malformed OpenSSH public key");let p=Re(t,t._pos);if(p===void 0)return new Error("Malformed OpenSSH public key");s=os(u,l,d,p),a=ss(u,l,d,p),i="sha1";break}case"ssh-ed25519":{let u=Re(t,t._pos||0);if(u===void 0||u.length!==32)return new Error("Malformed OpenSSH public key");s=Tg(u),a=kg(u),i=null;break}case"ecdsa-sha2-nistp256":i="sha256",o="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":i===void 0&&(i="sha384",o="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(i===void 0&&(i="sha512",o="1.3.132.0.35"),!_l(t,1))return new Error("Malformed OpenSSH public key");let u=Re(t,t._pos||0);if(u===void 0)return new Error("Malformed OpenSSH public key");s=yl(o,u),a=Al(o,u);break}default:return new Error(`Unsupported OpenSSH public key type: ${e}`)}return new Ua(n,r,s,a,i)}c(El,"parseDER");function Cg(t){switch(t){case"ssh-rsa":case"ssh-dss":case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":return!0;case"ssh-ed25519":if(ml)return!0;default:return!1}}c(Cg,"isSupportedKeyType");function Rg(t){return t?typeof t[Gi]=="boolean":!1}c(Rg,"isParsedKey");function Ng(t,e){if(Rg(t))return t;let r;if(Buffer.isBuffer(t))r=t,t=t.utf8Slice(0,t.length).trim();else if(typeof t=="string")t=t.trim();else return new Error("Key data must be a Buffer or string");if(e!=null){if(typeof e=="string")e=Buffer.from(e);else if(!Buffer.isBuffer(e))return new Error("Passphrase must be a string or Buffer when supplied")}let n;if((n=Oa.parse(t,e))!==null||(n=$a.parse(t,e))!==null||(n=Da.parse(t,e))!==null||(n=Ua.parse(t))!==null||(n=Ba.parse(t))!==null)return n;if(r){Na.init(r,0);let i=Na.readString(!0);i!==void 0&&(t=Na.readRaw(),t!==void 0&&(n=El(t,i,"",i),n instanceof Error&&(n=null))),Na.clear()}return n||new Error("Unsupported key format")}c(Ng,"parseKey");Og.exports={isParsedKey:Rg,isSupportedKeyType:Cg,parseDERKey:c((t,e)=>El(t,e,"",e),"parseDERKey"),parseKey:Ng}});var wl=le((z3,jg)=>{"use strict";var{Socket:Ug}=require("net"),{Duplex:Lg}=require("stream"),{resolve:Wx}=require("path"),{readFile:$g}=require("fs"),{execFile:qx,spawn:Qx}=require("child_process"),{isParsedKey:Dg,parseKey:cs}=Fn(),{makeBufferParser:Kx,readUInt32BE:Sl,writeUInt32BE:wr,writeUInt32LE:Bg}=Qr();function us(t){let e=!1;return(...r)=>{e||(e=!0,t(...r))}}c(us,"once");function Vx(t,e){let r=Buffer.allocUnsafe(t.length+e.length);return t.copy(r,0),e.copy(r,t.length),r}c(Vx,"concat");function xl(){}c(xl,"noop");var Gx=Buffer.alloc(0),Lt=Kx(),ls=class{static{c(this,"BaseAgent")}getIdentities(e){e(new Error("Missing getIdentities() implementation"))}sign(e,r,n,i){typeof n=="function"&&(i=n),i(new Error("Missing sign() implementation"))}},Yi=class extends ls{static{c(this,"OpenSSHAgent")}constructor(e){super(),this.socketPath=e}getStream(e){e=us(e);let r=new Ug;r.on("connect",()=>{e(null,r)}),r.on("close",n).on("end",n).on("error",n),r.connect(this.socketPath);function n(){try{r.destroy()}catch{}e(new Error("Failed to connect to agent"))}c(n,"onFail")}getIdentities(e){e=us(e),this.getStream((r,n)=>{function i(s){if(n)try{n.destroy()}catch{}s||(s=new Error("Failed to retrieve identities from agent")),e(s)}if(c(i,"onFail"),r)return i(r);let o=new Il(!0);o.on("error",i),o.pipe(n).pipe(o),n.on("close",i).on("end",i).on("error",i),o.getIdentities((s,a)=>{if(s)return i(s);try{n.destroy()}catch{}e(null,a)})})}sign(e,r,n,i){typeof n=="function"?(i=n,n=void 0):(typeof n!="object"||n===null)&&(n=void 0),i=us(i),this.getStream((o,s)=>{function a(l){if(s)try{s.destroy()}catch{}l||(l=new Error("Failed to sign data with agent")),i(l)}if(c(a,"onFail"),o)return a(o);let u=new Il(!0);u.on("error",a),u.pipe(s).pipe(u),s.on("close",a).on("end",a).on("error",a),u.sign(e,r,n,(l,d)=>{if(l)return a(l);try{s.destroy()}catch{}i(null,d)})})}},zg=(()=>{let s=Wx(__dirname,"..","util/pagent.exe"),a={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 u(d){d.buffer=null,d.proc&&(d.proc.kill(),d.proc=void 0)}c(u,"destroy");class l extends Lg{static{c(this,"PageantSocket")}constructor(){super(),this.proc=void 0,this.buffer=null}_read(p){}_write(p,g,h){if(this.buffer===null)this.buffer=p;else{let I=Buffer.allocUnsafe(this.buffer.length+p.length);this.buffer.copy(I,0),p.copy(I,this.buffer.length),this.buffer=I}if(this.buffer.length<4)return h();let _=Sl(this.buffer,0);if(this.buffer.length-4<_)return h();if(p=this.buffer.slice(0,4+_),this.buffer.length>4+_)return h(new Error("Unexpected multiple agent requests"));this.buffer=null;let E,b=this.proc=Qx(s,[p.length]);b.stdout.on("data",I=>{this.push(I)}),b.on("error",I=>{E=I,h(E)}),b.on("close",I=>{if(this.proc=void 0,!E){if(E=a[I])return h(E);h()}}),b.stdin.end(p)}_final(p){u(this),p()}_destroy(p,g){u(this),g()}}return class extends Yi{static{c(this,"PageantAgent")}getStream(p){p(null,new l)}}})(),Mg=(()=>{let t=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Yi{static{c(this,"CygwinAgent")}getStream(r){r=us(r);let n=this.socketPath,i=!1;$g(n,c(function o(s,a){if(s){if(i)return r(new Error("Invalid cygwin unix socket path"));qx("cygpath",["-w",n],(Z,Y,P)=>{if(Z||Y.length===0)return r(new Error("Invalid cygwin unix socket path"));i=!0,n=Y.toString().replace(/[\r\n]/g,""),$g(n,o)});return}let u=t.exec(a.toString("ascii"));if(!u)return r(new Error("Malformed cygwin unix socket file"));let l,d=0,p=!1,g=[],h,_=Buffer.alloc(12),E=parseInt(u[1],10),b=u[2].replace(/-/g,""),I=Buffer.allocUnsafe(16);for(let Z=0,Y=0;Y<32;++Z,Y+=2)I[Z]=parseInt(b.substring(Y,Y+2),16);for(let Z=0;Z<16;Z+=4)Bg(I,Sl(I,Z),Z);X();function w(){d=0,l="secret",h.write(I)}c(w,"_onconnect");function H(Z){if(d+=Z.length,l==="secret"){d===16&&(d=0,l="creds",h.write(_));return}if(l==="creds"&&(p||g.push(Z),d===12)){if(h.removeListener("connect",w),h.removeListener("data",H),h.removeListener("error",$),h.removeListener("end",$),h.removeListener("close",$),p)return r(null,h);p=!0,_=Buffer.concat(g),Bg(_,process.pid,0),h.on("error",()=>{}),h.destroy(),X()}}c(H,"_ondata");function $(){r(new Error("Problem negotiating cygwin unix socket security"))}c($,"onFail");function X(){h=new Ug,h.on("connect",w),h.on("data",H),h.on("error",$),h.on("end",$),h.on("close",$),h.connect(E)}c(X,"tryConnect")},"readCygsocket"))}}})(),Zx=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function Fg(t){return process.platform==="win32"&&!Zx.test(t)?t==="pageant"?new zg:new Mg(t):new Yi(t)}c(Fg,"createAgent");var Il=(()=>{function l(P){let k;for(;P[w].length;){let M=P[w][0][p];if(M===void 0)break;P[w].shift(),k=P.push(M)}return k}c(l,"processResponses");let d=Symbol("Inbound Request Type"),p=Symbol("Inbound Request Response"),g=Symbol("Inbound Request Context");class h{static{c(this,"AgentInboundRequest")}constructor(k,M){this[d]=k,this[p]=void 0,this[g]=M}hasResponded(){return this[p]!==void 0}getType(){return this[d]}getContext(){return this[g]}}function _(P,k,M){return k[p]=M,l(P)}c(_,"respond");function E(P){if(P[$]=null,P[H]===0){let k=P[w];if(k&&k.length){P[w]=[];for(let M of k)M.cb(new Error("No reply from server"))}}try{P.end()}catch{}setImmediate(()=>{P[Y]||P.emit("end"),P[Z]||P.emit("close")})}c(E,"cleanup");function b(){this[Z]=!0}c(b,"onClose");function I(){this[Y]=!0}c(I,"onEnd");let w=Symbol("Requests"),H=Symbol("Agent Protocol Role"),$=Symbol("Agent Protocol Buffer"),X=Symbol("Agent Protocol Current Message Length"),Z=Symbol("Agent Protocol Closed"),Y=Symbol("Agent Protocol Ended");return class extends Lg{static{c(this,"AgentProtocol")}constructor(k){super({autoDestroy:!0,emitClose:!1}),this[H]=k?0:1,this[w]=[],this[$]=null,this[X]=-1,this.once("end",I),this.once("close",b)}_read(k){}_write(k,M,L){this[$]===null?this[$]=k:this[$]=Vx(this[$],k);let T=this[$],F=T.length,j=0;for(;j<F&&!(F<5||(this[X]===-1&&(this[X]=Sl(T,j)),F<4+this[X]));){let B=T[j+=4];if(++j,this[H]===0){if(this[w].length===0)return L(new Error("Received unexpected message from server"));let G=this[w].shift();switch(B){case 5:G.cb(new Error("Agent responded with failure"));break;case 12:{if(G.type!==11)return L(new Error("Agent responded with wrong message type"));Lt.init(T,j);let ee=Lt.readUInt32BE();if(ee===void 0)return Lt.clear(),L(new Error("Malformed agent response"));let C=[];for(let W=0;W<ee;++W){let q=Lt.readString();if(q===void 0)return Lt.clear(),L(new Error("Malformed agent response"));let J=Lt.readString(!0);if(J===void 0)return Lt.clear(),L(new Error("Malformed agent response"));q=cs(q),!(q instanceof Error)&&(q.comment=q.comment||J,C.push(q))}j=Lt.pos(),Lt.clear(),G.cb(null,C);break}case 14:{if(G.type!==13)return L(new Error("Agent responded with wrong message type"));Lt.init(T,j);let ee=Lt.readString();if(j=Lt.pos(),Lt.clear(),ee===void 0)return L(new Error("Malformed agent response"));if(Lt.init(ee,0),Lt.readString(!0),ee=Lt.readString(),Lt.clear(),ee===void 0)return L(new Error("Malformed OpenSSH signature format"));G.cb(null,ee);break}default:return L(new Error("Agent responded with unsupported message type"))}}else switch(B){case 11:{let G=new h(B);this[w].push(G),this.emit("identities",G);break}case 13:{Lt.init(T,j);let G=Lt.readString(),ee=Lt.readString(),C=Lt.readUInt32BE();if(j=Lt.pos(),Lt.clear(),C===void 0){let ue=new h(B);return this[w].push(ue),this.failureReply(ue)}if(G=cs(G),G instanceof Error){let ue=new h(B);return this[w].push(ue),this.failureReply(ue)}let W={hash:void 0},q;G.type==="ssh-rsa"&&(C&2?(q="rsa-sha2-256",W.hash="sha256"):C&4&&(q="rsa-sha2-512",W.hash="sha512")),q===void 0&&(q=G.type);let J=new h(B,q);this[w].push(J),this.emit("sign",J,G,ee,W);break}default:{let G=new h(B);this[w].push(G),this.failureReply(G)}}if(this[X]=-1,j===F){this[$]=null;break}else this[$]=T=T.slice(j),F=T.length,j=0}L()}_destroy(k,M){E(this),M()}_final(k){E(this),k()}sign(k,M,L,T){if(this[H]!==0)throw new Error("Client-only method called with server role");typeof L=="function"?(T=L,L=void 0):(typeof L!="object"||L===null)&&(L=void 0);let F=0;if(k=cs(k),k instanceof Error)throw new Error("Invalid public key argument");if(k.type==="ssh-rsa"&&L)switch(L.hash){case"sha256":F=2;break;case"sha512":F=4;break}k=k.getPublicSSH();let j=13,B=k.length,G=M.length,ee=0,C=Buffer.allocUnsafe(9+B+4+G+4);return wr(C,C.length-4,ee),C[ee+=4]=j,wr(C,B,++ee),k.copy(C,ee+=4),wr(C,G,ee+=B),M.copy(C,ee+=4),wr(C,F,ee+=G),typeof T!="function"&&(T=xl),this[w].push({type:j,cb:T}),this.push(C)}getIdentities(k){if(this[H]!==0)throw new Error("Client-only method called with server role");let M=11,L=0,T=Buffer.allocUnsafe(5);return wr(T,T.length-4,L),T[L+=4]=M,typeof k!="function"&&(k=xl),this[w].push({type:M,cb:k}),this.push(T)}failureReply(k){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(k instanceof h))throw new Error("Wrong request argument");if(k.hasResponded())return!0;let M=0,L=Buffer.allocUnsafe(5);return wr(L,L.length-4,M),L[M+=4]=5,_(this,k,L)}getIdentitiesReply(k,M){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(k instanceof h))throw new Error("Wrong request argument");if(k.hasResponded())return!0;if(k.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(M))throw new Error("Keys argument must be an array");let L=4,T=[];for(let B=0;B<M.length;++B){let G=M[B];if(typeof G!="object"||G===null)throw new Error(`Invalid key entry: ${G}`);let ee,C;if(Dg(G))ee=G;else if(Dg(G.pubKey))ee=G.pubKey;else if(typeof G.pubKey!="object"||G.pubKey===null||({pubKey:ee,comment:C}=G.pubKey,ee=cs(ee),ee instanceof Error))continue;C=ee.comment||C,ee=ee.getPublicSSH(),L+=4+ee.length,C&&typeof C=="string"?C=Buffer.from(C):Buffer.isBuffer(C)||(C=Gx),L+=4+C.length,T.push({pubKey:ee,comment:C})}let F=0,j=Buffer.allocUnsafe(5+L);wr(j,j.length-4,F),j[F+=4]=12,wr(j,T.length,++F),F+=4;for(let B=0;B<T.length;++B){let{pubKey:G,comment:ee}=T[B];wr(j,G.length,F),G.copy(j,F+=4),wr(j,ee.length,F+=G.length),F+=4,ee.length&&(ee.copy(j,F),F+=ee.length)}return _(this,k,j)}signReply(k,M){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(k instanceof h))throw new Error("Wrong request argument");if(k.hasResponded())return!0;if(k.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(M))throw new Error("Signature argument must be a Buffer");if(M.length===0)throw new Error("Signature argument must be non-empty");let L=0,T=k.getContext(),F=Buffer.byteLength(T),j=Buffer.allocUnsafe(13+F+4+M.length);return wr(j,j.length-4,L),j[L+=4]=14,wr(j,4+F+4+M.length,++L),wr(j,F,L+=4),j.utf8Write(T,L+=4,F),wr(j,M.length,L+=F),M.copy(j,L+=4),_(this,k,j)}}})(),bl=Symbol("Agent"),Gr=Symbol("Agent Keys"),bn=Symbol("Agent Keys Index"),Zi=Symbol("Agent Init Callbacks"),vl=class{static{c(this,"AgentContext")}constructor(e){if(typeof e=="string")e=Fg(e);else if(!Hg(e))throw new Error("Invalid agent argument");this[bl]=e,this[Gr]=null,this[bn]=-1,this[Zi]=null}init(e){if(typeof e!="function"&&(e=xl),this[Gr]===null)if(this[Zi]===null){this[Zi]=[e];let r=c((...n)=>{process.nextTick(()=>{let i=this[Zi];this[Zi]=null;for(let o of i)o(...n)})},"doCbs");this[bl].getIdentities(us((n,i)=>{if(n)return r(n);if(!Array.isArray(i))return r(new Error("Agent implementation failed to provide keys"));let o=[];for(let s of i)s=cs(s),!(s instanceof Error)&&o.push(s);this[Gr]=o,this[bn]=-1,r()}))}else this[Zi].push(e);else process.nextTick(e)}nextKey(){return this[Gr]===null||++this[bn]>=this[Gr].length?!1:this[Gr][this[bn]]}currentKey(){return this[Gr]===null||this[bn]>=this[Gr].length?null:this[Gr][this[bn]]}pos(){return this[Gr]===null||this[bn]>=this[Gr].length?-1:this[bn]}reset(){this[bn]=-1}sign(...e){this[bl].sign(...e)}};function Hg(t){return t instanceof ls}c(Hg,"isAgent");jg.exports={AgentContext:vl,AgentProtocol:Il,BaseAgent:ls,createAgent:Fg,CygwinAgent:Mg,isAgent:Hg,OpenSSHAgent:Yi,PageantAgent:zg}});var Nl=le((F3,Wg)=>{"use strict";var{kMaxLength:Yx}=require("buffer"),{createInflate:Xx,constants:{DEFLATE:Jx,INFLATE:eI,Z_DEFAULT_CHUNK:tI,Z_DEFAULT_COMPRESSION:rI,Z_DEFAULT_MEMLEVEL:nI,Z_DEFAULT_STRATEGY:iI,Z_DEFAULT_WINDOWBITS:oI,Z_PARTIAL_FLUSH:sI}}=require("zlib"),aI=Xx()._handle.constructor;function cI(){throw new Error("Should not get here")}c(cI,"processCallback");function uI(t,e,r){let n=this._owner,i=new Error(t);i.errno=e,i.code=r,n._err=i}c(uI,"zlibOnError");function Rl(t){t._handle&&(t._handle.close(),t._handle=null)}c(Rl,"_close");var La=class{static{c(this,"Zlib")}constructor(e){let r=oI,n=rI,i=nI,o=iI,s=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=tI,this._maxOutputLength=Yx,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new aI(e),this._handle._owner=this,this._handle.onerror=uI,this._handle.init(r,n,i,o,this._writeState,cI,s)}writeSync(e,r){let n=this._handle;if(!n)throw new Error("Invalid Zlib instance");let i=e.length,o=this._chunkSize-this._outOffset,s=0,a,u,l,d=0,p=this._writeState,g=this._outBuffer,h=this._outOffset,_=this._chunkSize;for(;;){if(n.writeSync(sI,e,s,i,g,h,o),this._err)throw this._err;a=p[0],u=p[1];let b=i-u,I=o-a;if(I>0){let w=h===0&&I===g.length?g:g.slice(h,h+I);if(h+=I,l?l.push===void 0?l=[l,w]:l.push(w):l=w,d+=w.byteLength,d>this._maxOutputLength)throw Rl(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(I!==0)throw new Error("have should not go down");if((a===0||h>=_)&&(o=_,h=0,g=Buffer.allocUnsafe(_)),a===0)s+=b,i=u;else break}if(this._outBuffer=g,this._outOffset=h,d===0&&(l=Buffer.alloc(0)),r)return l.totalLen=d,l;if(l.push===void 0)return l;let E=Buffer.allocUnsafe(d);for(let b=0,I=0;b<l.length;++b){let w=l[b];E.set(w,I),I+=w.length}return E}},Pl=class{static{c(this,"ZlibPacketWriter")}constructor(e){this.allocStart=0,this.allocStartKEX=0,this._protocol=e,this._zlib=new La(Jx)}cleanup(){this._zlib&&Rl(this._zlib)}alloc(e,r){return Buffer.allocUnsafe(e)}finalize(e,r){if(this._protocol._kexinit===void 0||r){let n=this._zlib.writeSync(e,!0),i=this._protocol._cipher.allocPacket(n.totalLen);if(n.push===void 0)i.set(n,5);else for(let o=0,s=5;o<n.length;++o){let a=n[o];i.set(a,s),s+=a.length}return i}return e}},Tl=class{static{c(this,"PacketWriter")}constructor(e){this.allocStart=5,this.allocStartKEX=5,this._protocol=e}cleanup(){}alloc(e,r){return this._protocol._kexinit===void 0||r?this._protocol._cipher.allocPacket(e):Buffer.allocUnsafe(e)}finalize(e,r){return e}},kl=class{static{c(this,"ZlibPacketReader")}constructor(){this._zlib=new La(eI)}cleanup(){this._zlib&&Rl(this._zlib)}read(e){return this._zlib.writeSync(e,!1)}},Cl=class{static{c(this,"PacketReader")}cleanup(){}read(e){return e}};Wg.exports={PacketReader:Cl,PacketWriter:Tl,ZlibPacketReader:kl,ZlibPacketWriter:Pl}});var Gg=le((j3,Vg)=>{"use strict";var{bufferSlice:Ol,bufferParser:O,doFatalError:Tt,sigSSHToASN1:qg,writeUInt32BE:Qg}=Qr(),{CHANNEL_OPEN_FAILURE:lI,COMPAT:fI,MESSAGE:kt,TERMINAL_MODE:Kg}=An(),{parseKey:dI}=Fn(),pI=Array.from(Object.entries(Kg)).reduce((t,[e,r])=>({...t,[e]:r}),{});Vg.exports={[kt.DISCONNECT]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readString(!0),i=O.readString();if(O.clear(),i===void 0)return Tt(t,"Inbound: Malformed DISCONNECT packet");t._debug&&t._debug(`Inbound: Received DISCONNECT (${r}, "${n}")`);let o=t._handlers.DISCONNECT;o&&o(t,r,n)},[kt.IGNORE]:(t,e)=>{t._debug&&t._debug("Inbound: Received IGNORE")},[kt.UNIMPLEMENTED]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed UNIMPLEMENTED packet");t._debug&&t._debug(`Inbound: Received UNIMPLEMENTED (seqno ${r})`)},[kt.DEBUG]:(t,e)=>{O.init(e,1);let r=O.readBool(),n=O.readString(!0),i=O.readString();if(O.clear(),i===void 0)return Tt(t,"Inbound: Malformed DEBUG packet");t._debug&&t._debug("Inbound: Received DEBUG");let o=t._handlers.DEBUG;o&&o(t,r,n)},[kt.SERVICE_REQUEST]:(t,e)=>{O.init(e,1);let r=O.readString(!0);if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed SERVICE_REQUEST packet");t._debug&&t._debug(`Inbound: Received SERVICE_REQUEST (${r})`);let n=t._handlers.SERVICE_REQUEST;n&&n(t,r)},[kt.SERVICE_ACCEPT]:(t,e)=>{O.init(e,1);let r=O.readString(!0);if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed SERVICE_ACCEPT packet");t._debug&&t._debug(`Inbound: Received SERVICE_ACCEPT (${r})`);let n=t._handlers.SERVICE_ACCEPT;n&&n(t,r)},[kt.EXT_INFO]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n;if(r!==void 0){n=[];for(let o=0;o<r;++o){let s=O.readString(!0),a=O.readString();if(a!==void 0)if(s==="server-sig-algs"){let u=a.latin1Slice(0,a.length).split(",");n.push({name:s,algs:u});continue}else continue;n=void 0;break}}if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed EXT_INFO packet");t._debug&&t._debug("Inbound: Received EXT_INFO");let i=t._handlers.EXT_INFO;i&&i(t,n)},[kt.USERAUTH_REQUEST]:(t,e)=>{O.init(e,1);let r=O.readString(!0),n=O.readString(!0),i=O.readString(!0),o,s;switch(i){case"none":o=null;break;case"password":{let u=O.readBool();if(u!==void 0&&(o=O.readString(!0),o!==void 0&&u)){let l=O.readString(!0);l!==void 0?o={oldPassword:o,newPassword:l}:o=void 0}break}case"publickey":{let u=O.readBool();if(u!==void 0){let l=O.readString(!0),d=l,p=O.readString(),g;switch(l){case"rsa-sha2-256":d="ssh-rsa",g="sha256";break;case"rsa-sha2-512":d="ssh-rsa",g="sha512";break}if(u){let h=O.pos(),_=O.readString();if(_!==void 0&&(_.length>4+l.length+4&&_.utf8Slice(4,4+l.length)===l&&(_=Ol(_,4+l.length+4)),_=qg(_,d),_)){let E=t._kex.sessionID,b=Buffer.allocUnsafe(4+E.length+h);Qg(b,E.length,0),b.set(E,4),b.set(new Uint8Array(e.buffer,e.byteOffset,h),4+E.length),o={keyAlgo:d,key:p,signature:_,blob:b,hashAlgo:g}}}else o={keyAlgo:d,key:p,hashAlgo:g},s="publickey -- check"}break}case"hostbased":{let u=O.readString(!0),l=u,d=O.readString(),p=O.readString(!0),g=O.readString(!0),h;switch(u){case"rsa-sha2-256":l="ssh-rsa",h="sha256";break;case"rsa-sha2-512":l="ssh-rsa",h="sha512";break}let _=O.pos(),E=O.readString();if(E!==void 0&&(E.length>4+u.length+4&&E.utf8Slice(4,4+u.length)===u&&(E=Ol(E,4+u.length+4)),E=qg(E,l),E!==void 0)){let b=t._kex.sessionID,I=Buffer.allocUnsafe(4+b.length+_);Qg(I,b.length,0),I.set(b,4),I.set(new Uint8Array(e.buffer,e.byteOffset,_),4+b.length),o={keyAlgo:l,key:d,signature:E,blob:I,localHostname:p,localUsername:g,hashAlgo:h}}break}case"keyboard-interactive":O.skipString(),o=O.readList();break;default:i!==void 0&&(o=O.readRaw())}if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed USERAUTH_REQUEST packet");s===void 0&&(s=i),t._authsQueue.push(i),t._debug&&t._debug(`Inbound: Received USERAUTH_REQUEST (${s})`);let a=t._handlers.USERAUTH_REQUEST;a&&a(t,r,n,i,o)},[kt.USERAUTH_FAILURE]:(t,e)=>{O.init(e,1);let r=O.readList(),n=O.readBool();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_FAILURE packet");t._debug&&t._debug(`Inbound: Received USERAUTH_FAILURE (${r})`),t._authsQueue.shift();let i=t._handlers.USERAUTH_FAILURE;i&&i(t,r,n)},[kt.USERAUTH_SUCCESS]:(t,e)=>{t._debug&&t._debug("Inbound: Received USERAUTH_SUCCESS"),t._authsQueue.shift();let r=t._handlers.USERAUTH_SUCCESS;r&&r(t)},[kt.USERAUTH_BANNER]:(t,e)=>{O.init(e,1);let r=O.readString(!0),n=O.readString();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_BANNER packet");t._debug&&t._debug("Inbound: Received USERAUTH_BANNER");let i=t._handlers.USERAUTH_BANNER;i&&i(t,r)},60:(t,e)=>{if(!t._authsQueue.length){t._debug&&t._debug("Inbound: Received payload type 60 without auth");return}switch(t._authsQueue[0]){case"password":{O.init(e,1);let r=O.readString(!0),n=O.readString();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");t._debug&&t._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let i=t._handlers.USERAUTH_PASSWD_CHANGEREQ;i&&i(t,r);break}case"publickey":{O.init(e,1);let r=O.readString(!0),n=O.readString();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_PK_OK packet");t._debug&&t._debug("Inbound: Received USERAUTH_PK_OK"),t._authsQueue.shift();let i=t._handlers.USERAUTH_PK_OK;i&&i(t,r,n);break}case"keyboard-interactive":{O.init(e,1);let r=O.readString(!0),n=O.readString(!0);O.readString();let i=O.readUInt32BE(),o;if(i!==void 0){o=new Array(i);let a;for(a=0;a<i;++a){let u=O.readString(!0),l=O.readBool();if(l===void 0)break;o[a]={prompt:u,echo:l}}a!==i&&(o=void 0)}if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");t._debug&&t._debug("Inbound: Received USERAUTH_INFO_REQUEST");let s=t._handlers.USERAUTH_INFO_REQUEST;s&&s(t,r,n,o);break}default:t._debug&&t._debug("Inbound: Received unexpected payload type 60")}},61:(t,e)=>{if(!t._authsQueue.length){t._debug&&t._debug("Inbound: Received payload type 61 without auth");return}if(t._authsQueue[0]!=="keyboard-interactive")return Tt(t,"Inbound: Received unexpected payload type 61");O.init(e,1);let r=O.readUInt32BE(),n;if(r!==void 0){n=new Array(r);let o;for(o=0;o<r;++o){let s=O.readString(!0);if(s===void 0)break;n[o]=s}o!==r&&(n=void 0)}if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");t._debug&&t._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let i=t._handlers.USERAUTH_INFO_RESPONSE;i&&i(t,n)},[kt.GLOBAL_REQUEST]:(t,e)=>{O.init(e,1);let r=O.readString(!0),n=O.readBool(),i;if(n!==void 0)switch(r){case"tcpip-forward":case"cancel-tcpip-forward":{let s=O.readString(!0),a=O.readUInt32BE();a!==void 0&&(i={bindAddr:s,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let s=O.readString(!0);s!==void 0&&(i={socketPath:s});break}case"no-more-sessions@openssh.com":i=null;break;case"hostkeys-00@openssh.com":{for(i=[];O.avail()>0;){let s=O.readString();if(s===void 0){i=void 0;break}let a=dI(s);a instanceof Error||i.push(a)}break}default:i=O.readRaw()}if(O.clear(),i===void 0)return Tt(t,"Inbound: Malformed GLOBAL_REQUEST packet");t._debug&&t._debug(`Inbound: GLOBAL_REQUEST (${r})`);let o=t._handlers.GLOBAL_REQUEST;o?o(t,r,n,i):t.requestFailure()},[kt.REQUEST_SUCCESS]:(t,e)=>{let r=e.length>1?Ol(e,1):null;t._debug&&t._debug("Inbound: REQUEST_SUCCESS");let n=t._handlers.REQUEST_SUCCESS;n&&n(t,r)},[kt.REQUEST_FAILURE]:(t,e)=>{t._debug&&t._debug("Inbound: Received REQUEST_FAILURE");let r=t._handlers.REQUEST_FAILURE;r&&r(t)},[kt.CHANNEL_OPEN]:(t,e)=>{O.init(e,1);let r=O.readString(!0),n=O.readUInt32BE(),i=O.readUInt32BE(),o=O.readUInt32BE(),s;switch(r){case"forwarded-tcpip":case"direct-tcpip":{let u=O.readString(!0),l=O.readUInt32BE(),d=O.readString(!0),p=O.readUInt32BE();p!==void 0&&(s={type:r,sender:n,window:i,packetSize:o,data:{destIP:u,destPort:l,srcIP:d,srcPort:p}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let u=O.readString(!0);u!==void 0&&(s={type:r,sender:n,window:i,packetSize:o,data:{socketPath:u}});break}case"x11":{let u=O.readString(!0),l=O.readUInt32BE();l!==void 0&&(s={type:r,sender:n,window:i,packetSize:o,data:{srcIP:u,srcPort:l}});break}default:s={type:r,sender:n,window:i,packetSize:o,data:{}}}if(O.clear(),s===void 0)return Tt(t,"Inbound: Malformed CHANNEL_OPEN packet");t._debug&&t._debug(`Inbound: CHANNEL_OPEN (s:${n}, ${r})`);let a=t._handlers.CHANNEL_OPEN;a?a(t,s):t.channelOpenFail(s.sender,lI.ADMINISTRATIVELY_PROHIBITED,"","")},[kt.CHANNEL_OPEN_CONFIRMATION]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readUInt32BE(),i=O.readUInt32BE(),o=O.readUInt32BE(),s=O.avail()?O.readRaw():void 0;if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");t._debug&&t._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${r}, s:${n})`);let a=t._handlers.CHANNEL_OPEN_CONFIRMATION;a&&a(t,{recipient:r,sender:n,window:i,packetSize:o,data:s})},[kt.CHANNEL_OPEN_FAILURE]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readUInt32BE(),i=O.readString(!0),o=O.readString();if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");t._debug&&t._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${r})`);let s=t._handlers.CHANNEL_OPEN_FAILURE;s&&s(t,r,n,i)},[kt.CHANNEL_WINDOW_ADJUST]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readUInt32BE();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");t._debug&&t._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${r}, ${n})`);let i=t._handlers.CHANNEL_WINDOW_ADJUST;i&&i(t,r,n)},[kt.CHANNEL_DATA]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readString();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed CHANNEL_DATA packet");t._debug&&t._debug(`Inbound: CHANNEL_DATA (r:${r}, ${n.length})`);let i=t._handlers.CHANNEL_DATA;i&&i(t,r,n)},[kt.CHANNEL_EXTENDED_DATA]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readUInt32BE(),i=O.readString();if(O.clear(),i===void 0)return Tt(t,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");t._debug&&t._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${r}, ${i.length})`);let o=t._handlers.CHANNEL_EXTENDED_DATA;o&&o(t,r,i,n)},[kt.CHANNEL_EOF]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed CHANNEL_EOF packet");t._debug&&t._debug(`Inbound: CHANNEL_EOF (r:${r})`);let n=t._handlers.CHANNEL_EOF;n&&n(t,r)},[kt.CHANNEL_CLOSE]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed CHANNEL_CLOSE packet");t._debug&&t._debug(`Inbound: CHANNEL_CLOSE (r:${r})`);let n=t._handlers.CHANNEL_CLOSE;n&&n(t,r)},[kt.CHANNEL_REQUEST]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readString(!0),i=O.readBool(),o;if(i!==void 0)switch(n){case"exit-status":o=O.readUInt32BE(),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"exit-signal":{let a,u;if(t._compatFlags&fI.OLD_EXIT){let d=O.readUInt32BE();switch(d){case 1:a="HUP";break;case 2:a="INT";break;case 3:a="QUIT";break;case 6:a="ABRT";break;case 9:a="KILL";break;case 14:a="ALRM";break;case 15:a="TERM";break;default:d!==void 0&&(a=`UNKNOWN (${d})`)}u=!1}else a=O.readString(!0),u=O.readBool(),u===void 0&&(a=void 0);let l=O.readString(!0);O.skipString()!==void 0&&(o={signal:a,coreDumped:u,errorMessage:l}),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${a})`);break}case"pty-req":{let a=O.readString(!0),u=O.readUInt32BE(),l=O.readUInt32BE(),d=O.readUInt32BE(),p=O.readUInt32BE(),g=O.readString();if(g!==void 0){O.init(g,1);let h={};for(;O.avail();){let _=O.readByte();if(_===Kg.TTY_OP_END)break;let E=pI[_],b=O.readUInt32BE();if(_===void 0||E===void 0||b===void 0){h=void 0;break}h[E]=b}h!==void 0&&(o={term:a,cols:u,rows:l,width:d,height:p,modes:h})}t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break}case"window-change":{let a=O.readUInt32BE(),u=O.readUInt32BE(),l=O.readUInt32BE(),d=O.readUInt32BE();d!==void 0&&(o={cols:a,rows:u,width:l,height:d}),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break}case"x11-req":{let a=O.readBool(),u=O.readString(!0),l=O.readString(),d=O.readUInt32BE();d!==void 0&&(o={single:a,protocol:u,cookie:l,screen:d}),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break}case"env":{let a=O.readString(!0),u=O.readString(!0);u!==void 0&&(o={name:a,value:u}),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${a}=${u})`);break}case"shell":o=null,t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break;case"exec":o=O.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"subsystem":o=O.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"signal":o=O.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"xon-xoff":o=O.readBool(),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"auth-agent-req@openssh.com":o=null,t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break;default:o=O.avail()?O.readRaw():null,t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`)}if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed CHANNEL_REQUEST packet");let s=t._handlers.CHANNEL_REQUEST;s&&s(t,r,n,i,o)},[kt.CHANNEL_SUCCESS]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed CHANNEL_SUCCESS packet");t._debug&&t._debug(`Inbound: CHANNEL_SUCCESS (r:${r})`);let n=t._handlers.CHANNEL_SUCCESS;n&&n(t,r)},[kt.CHANNEL_FAILURE]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed CHANNEL_FAILURE packet");t._debug&&t._debug(`Inbound: CHANNEL_FAILURE (r:${r})`);let n=t._handlers.CHANNEL_FAILURE;n&&n(t,r)}}});var za=le((W3,Zg)=>{"use strict";var $l=new Array(256);[Ma().HANDLERS,Gg()].forEach(t=>{for(let[e,r]of Object.entries(t))e=+e,isFinite(e)&&e>=0&&e<$l.length&&($l[e]=r)});Zg.exports=$l});var Ma=le((Q3,sm)=>{"use strict";var{createDiffieHellman:hI,createDiffieHellmanGroup:gI,createECDH:mI,createHash:Bl,createPublicKey:_I,diffieHellman:yI,generateKeyPairSync:AI,randomFillSync:EI}=require("crypto"),{Ber:Yg}=Ko(),{COMPAT:Ul,curve25519Supported:bI,DEFAULT_KEX:Xg,DEFAULT_SERVER_HOST_KEY:Jg,DEFAULT_CIPHER:Fa,DEFAULT_MAC:Ha,DEFAULT_COMPRESSION:ja,DISCONNECT_REASON:st,MESSAGE:wt}=An(),{CIPHER_INFO:eo,createCipher:xI,createDecipher:II,MAC_INFO:em}=Ln(),{parseDERKey:vI}=Fn(),{bufferFill:SI,bufferParser:it,convertSignature:wI,doFatalError:at,FastBuffer:PI,sigSSHToASN1:TI,writeUInt32BE:cr}=Qr(),{PacketReader:tm,PacketWriter:rm,ZlibPacketReader:Wa,ZlibPacketWriter:qa}=Nl(),Xi,kI=2048,CI=8192,RI=Buffer.alloc(0);function nm(t){let e;if(t._compatFlags&Ul.BAD_DHGEX){let r=t._offer.lists.kex,n=r.array,i=!1;for(let o=0;o<n.length;++o)n[o].includes("group-exchange")&&(i||(i=!0,n=n.slice()),n.splice(o--,1));if(i){let o=17+t._offer.totalSize+1+4,s=Buffer.from(n.join(","));o-=r.buffer.length-s.length;let a=t._offer.lists.all,u=new Uint8Array(a.buffer,a.byteOffset+4+r.buffer.length,a.length-(4+r.buffer.length));e=Buffer.allocUnsafe(o),cr(e,s.length,17),e.set(s,21),e.set(u,21+s.length)}}e===void 0&&(e=Buffer.allocUnsafe(17+t._offer.totalSize+1+4),t._offer.copyAllTo(e,17)),t._debug&&t._debug("Outbound: Sending KEXINIT"),e[0]=wt.KEXINIT,EI(e,1,16),SI(e,0,e.length-5),t._kexinit=e,t._packetRW.write.allocStart=0;{let r=t._packetRW.write.allocStartKEX,n=t._packetRW.write.alloc(e.length,!0);n.set(e,r),t._cipher.encrypt(t._packetRW.write.finalize(n,!0))}}c(nm,"kexinit");function im(t,e){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}};if(it.init(e,17),(r.kex=it.readList())===void 0||(r.serverHostKey=it.readList())===void 0||(r.cs.cipher=it.readList())===void 0||(r.sc.cipher=it.readList())===void 0||(r.cs.mac=it.readList())===void 0||(r.sc.mac=it.readList())===void 0||(r.cs.compress=it.readList())===void 0||(r.sc.compress=it.readList())===void 0||(r.cs.lang=it.readList())===void 0||(r.sc.lang=it.readList())===void 0)return it.clear(),at(t,"Received malformed KEXINIT","handshake",st.KEY_EXCHANGE_FAILED);let n=it.pos(),i=n<e.length&&e[n]===1;it.clear();let o=t._offer,s=r,a=o.lists.kex.array;if(t._compatFlags&Ul.BAD_DHGEX){let $=!1;for(let X=0;X<a.length;++X)a[X].indexOf("group-exchange")!==-1&&($||($=!0,a=a.slice()),a.splice(X--,1))}let u,l,d,p=t._debug;p&&p("Inbound: Handshake in progress"),p&&p(`Handshake: (local) KEX method: ${a}`),p&&p(`Handshake: (remote) KEX method: ${s.kex}`);let g;if(t._server?(l=a,u=s.kex,g=u.indexOf("ext-info-c")!==-1):(l=s.kex,u=a,g=l.indexOf("ext-info-s")!==-1),t._strictMode===void 0&&(t._server?t._strictMode=u.indexOf("kex-strict-c-v00@openssh.com")!==-1:t._strictMode=l.indexOf("kex-strict-s-v00@openssh.com")!==-1,t._strictMode&&(p&&p("Handshake: strict KEX mode enabled"),t._decipher.inSeqno!==1)))return p&&p("Handshake: KEXINIT not first packet in strict KEX mode"),at(t,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",st.KEY_EXCHANGE_FAILED);for(d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: no matching key exchange algorithm"),at(t,"Handshake failed: no matching key exchange algorithm","handshake",st.KEY_EXCHANGE_FAILED);r.kex=u[d],p&&p(`Handshake: KEX algorithm: ${u[d]}`),i&&(!s.kex.length||u[d]!==s.kex[0])&&(t._skipNextInboundPacket=!0);let h=o.lists.serverHostKey.array;for(p&&p(`Handshake: (local) Host key format: ${h}`),p&&p(`Handshake: (remote) Host key format: ${s.serverHostKey}`),t._server?(l=h,u=s.serverHostKey):(l=s.serverHostKey,u=h),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching host key format"),at(t,"Handshake failed: no matching host key format","handshake",st.KEY_EXCHANGE_FAILED);r.serverHostKey=u[d],p&&p(`Handshake: Host key format: ${u[d]}`);let _=o.lists.cs.cipher.array;for(p&&p(`Handshake: (local) C->S cipher: ${_}`),p&&p(`Handshake: (remote) C->S cipher: ${s.cs.cipher}`),t._server?(l=_,u=s.cs.cipher):(l=s.cs.cipher,u=_),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching C->S cipher"),at(t,"Handshake failed: no matching C->S cipher","handshake",st.KEY_EXCHANGE_FAILED);r.cs.cipher=u[d],p&&p(`Handshake: C->S Cipher: ${u[d]}`);let E=o.lists.sc.cipher.array;for(p&&p(`Handshake: (local) S->C cipher: ${E}`),p&&p(`Handshake: (remote) S->C cipher: ${s.sc.cipher}`),t._server?(l=E,u=s.sc.cipher):(l=s.sc.cipher,u=E),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching S->C cipher"),at(t,"Handshake failed: no matching S->C cipher","handshake",st.KEY_EXCHANGE_FAILED);r.sc.cipher=u[d],p&&p(`Handshake: S->C cipher: ${u[d]}`);let b=o.lists.cs.mac.array;if(p&&p(`Handshake: (local) C->S MAC: ${b}`),p&&p(`Handshake: (remote) C->S MAC: ${s.cs.mac}`),eo[r.cs.cipher].authLen>0)r.cs.mac="",p&&p("Handshake: C->S MAC: <implicit>");else{for(t._server?(l=b,u=s.cs.mac):(l=s.cs.mac,u=b),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching C->S MAC"),at(t,"Handshake failed: no matching C->S MAC","handshake",st.KEY_EXCHANGE_FAILED);r.cs.mac=u[d],p&&p(`Handshake: C->S MAC: ${u[d]}`)}let I=o.lists.sc.mac.array;if(p&&p(`Handshake: (local) S->C MAC: ${I}`),p&&p(`Handshake: (remote) S->C MAC: ${s.sc.mac}`),eo[r.sc.cipher].authLen>0)r.sc.mac="",p&&p("Handshake: S->C MAC: <implicit>");else{for(t._server?(l=I,u=s.sc.mac):(l=s.sc.mac,u=I),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching S->C MAC"),at(t,"Handshake failed: no matching S->C MAC","handshake",st.KEY_EXCHANGE_FAILED);r.sc.mac=u[d],p&&p(`Handshake: S->C MAC: ${u[d]}`)}let w=o.lists.cs.compress.array;for(p&&p(`Handshake: (local) C->S compression: ${w}`),p&&p(`Handshake: (remote) C->S compression: ${s.cs.compress}`),t._server?(l=w,u=s.cs.compress):(l=s.cs.compress,u=w),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching C->S compression"),at(t,"Handshake failed: no matching C->S compression","handshake",st.KEY_EXCHANGE_FAILED);r.cs.compress=u[d],p&&p(`Handshake: C->S compression: ${u[d]}`);let H=o.lists.sc.compress.array;for(p&&p(`Handshake: (local) S->C compression: ${H}`),p&&p(`Handshake: (remote) S->C compression: ${s.sc.compress}`),t._server?(l=H,u=s.sc.compress):(l=s.sc.compress,u=H),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching S->C compression"),at(t,"Handshake failed: no matching S->C compression","handshake",st.KEY_EXCHANGE_FAILED);r.sc.compress=u[d],p&&p(`Handshake: S->C compression: ${u[d]}`),r.cs.lang="",r.sc.lang="",t._kex&&(t._kexinit||nm(t),t._decipher._onPayload=om.bind(t,{firstPacket:!1})),t._kex=NI(r,t,e),t._kex.remoteExtInfoEnabled=g,t._kex.start()}c(im,"handleKexInit");var NI=(()=>{function t(s){let a=0,u=s.length;for(;s[a]===0;)++a,--u;let l;return s[a]&128?(l=Buffer.allocUnsafe(1+u),l[0]=0,s.copy(l,1,a),s=l):u!==s.length&&(l=Buffer.allocUnsafe(u),s.copy(l,0,a),s=l),s}c(t,"convertToMpint");class e{static{c(this,"KeyExchange")}constructor(a,u,l){this._protocol=u,this.sessionID=u._kex?u._kex.sessionID:void 0,this.negotiated=a,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=u._kexinit,this._remoteKexinit=l,this._identRaw=u._identRaw,this._remoteIdentRaw=u._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(a){if(this._finished)return!1;this._finished=!0;let u=this._protocol._server,l=this.negotiated,d=this.convertPublicKey(this._dhData),p=this.computeSecret(this._dhData);if(p instanceof Error)return p.message=`Error while computing DH secret (${this.type}): ${p.message}`,p.level="handshake",at(this._protocol,p,st.KEY_EXCHANGE_FAILED);let g=Bl(this.hashName);on(g,u?this._remoteIdentRaw:this._identRaw),on(g,u?this._identRaw:this._remoteIdentRaw),on(g,u?this._remoteKexinit:this._kexinit),on(g,u?this._kexinit:this._remoteKexinit);let h=u?this._hostKey.getPublicSSH():this._hostKey;if(on(g,h),this.type==="groupex"){let H=this.getDHParams(),$=Buffer.allocUnsafe(4);cr($,this._minBits,0),g.update($),cr($,this._prefBits,0),g.update($),cr($,this._maxBits,0),g.update($),on(g,H.prime),on(g,H.generator)}on(g,u?d:this.getPublicKey());let _=u?this.getPublicKey():d;on(g,_),on(g,p);let E=g.digest();if(u){let H;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":H="sha256";break;case"rsa-sha2-512":H="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let $=this._hostKey.sign(E,H);if($ instanceof Error)return at(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${$.message}`,"handshake",st.KEY_EXCHANGE_FAILED);if($=wI($,this._hostKey.type),$===!1)return at(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",st.KEY_EXCHANGE_FAILED);let X=this.negotiated.serverHostKey,Z=Buffer.byteLength(X),Y=4+Z+4+$.length,P=this._protocol._packetRW.write.allocStartKEX,k=this._protocol._packetRW.write.alloc(5+h.length+4+_.length+4+Y,!0);if(k[P]=wt.KEXDH_REPLY,cr(k,h.length,++P),k.set(h,P+=4),cr(k,_.length,P+=h.length),k.set(_,P+=4),cr(k,Y,P+=_.length),cr(k,Z,P+=4),k.utf8Write(X,P+=4,Z),cr(k,$.length,P+=Z),k.set($,P+=4),this._protocol._debug){let M;switch(this.type){case"group":M="KEXDH_REPLY";break;case"groupex":M="KEXDH_GEX_REPLY";break;default:M="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${M}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(k,!0))}else{it.init(this._sig,0);let H=it.readString(!0);if(!H)return at(this._protocol,"Malformed packet while reading signature","handshake",st.KEY_EXCHANGE_FAILED);if(H!==l.serverHostKey)return at(this._protocol,`Wrong signature type: ${H}, expected: ${l.serverHostKey}`,"handshake",st.KEY_EXCHANGE_FAILED);let $=it.readString();if(it.clear(),$===void 0)return at(this._protocol,"Malformed packet while reading signature","handshake",st.KEY_EXCHANGE_FAILED);if(!($=TI($,H)))return at(this._protocol,"Malformed signature","handshake",st.KEY_EXCHANGE_FAILED);let X;{it.init(this._hostKey,0);let P=it.readString(!0),k=this._hostKey.slice(it.pos());if(it.clear(),X=vI(k,P),X instanceof Error)return X.level="handshake",at(this._protocol,X,st.KEY_EXCHANGE_FAILED)}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("Verifying signature ...");let Y=X.verify(E,$,Z);if(Y!==!0)return Y instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${Y.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),at(this._protocol,"Handshake failed: signature verification failed","handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(u||!a)&&Qa(this);let b,I,w=c(H=>{if(b)return Qa(this),b.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=xI(b),this._protocol._packetRW.write=I,b=void 0,I=void 0,this._protocol._onHandshakeComplete(l),!1;this.sessionID||(this.sessionID=E);{let G=Buffer.allocUnsafe(4+p.length);cr(G,p.length,0),G.set(p,4),p=G}let $=eo[l.cs.cipher],X=eo[l.sc.cipher],Z=Ji($.ivLen,this.hashName,p,E,this.sessionID,"A"),Y=Ji(X.ivLen,this.hashName,p,E,this.sessionID,"B"),P=Ji($.keyLen,this.hashName,p,E,this.sessionID,"C"),k=Ji(X.keyLen,this.hashName,p,E,this.sessionID,"D"),M,L;$.authLen||(M=em[l.cs.mac],L=Ji(M.len,this.hashName,p,E,this.sessionID,"E"));let T,F;X.authLen||(T=em[l.sc.mac],F=Ji(T.len,this.hashName,p,E,this.sessionID,"F"));let j={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:u?$:X,decipherIV:u?Z:Y,decipherKey:u?P:k,macInfo:u?M:T,macKey:u?L:F},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:u?X:$,cipherIV:u?Y:Z,cipherKey:u?k:P,macInfo:u?T:M,macKey:u?F:L}};this._protocol._decipher.free(),b=j,this._protocol._decipher=II(j);let B={read:void 0,write:void 0};switch(l.cs.compress){case"zlib":u?B.read=new Wa:B.write=new qa(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){u?B.read=new Wa:B.write=new qa(this._protocol);break}default:u?B.read=new tm:B.write=new rm(this._protocol)}switch(l.sc.compress){case"zlib":u?B.write=new qa(this._protocol):B.read=new Wa;break;case"zlib@openssh.com":if(this._protocol._authenticated){u?B.write=new qa(this._protocol):B.read=new Wa;break}default:u?B.write=new rm(this._protocol):B.read=new tm}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=B.read,I=B.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,H?!1:w()},"completeHandshake");if((u||a)&&(this.finish=w),!u)return w(a)}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 a=this.getPublicKey(),u=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[u]=wt.KEXDH_INIT,cr(l,a.length,++u),l.set(a,u+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}getPublicKey(){this.generateKeys();let a=this._public;if(a)return this.convertPublicKey(a)}convertPublicKey(a){let u,l=0,d=a.length;for(;a[l]===0;)++l,--d;return a[l]&128?(u=Buffer.allocUnsafe(1+d),u[0]=0,a.copy(u,1,l),u):(d!==a.length&&(u=Buffer.allocUnsafe(d),a.copy(u,0,l),a=u),a)}computeSecret(a){this.generateKeys();try{return t(this._dh.computeSecret(a))}catch(u){return u}}parse(a){let u=a[0];switch(this._step){case 1:if(this._protocol._server){if(u!==wt.KEXDH_INIT)return at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_INIT}`,"handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),it.init(a,1);let l=it.readString();if(it.clear(),l===void 0)return at(this._protocol,"Received malformed KEX*_INIT","handshake",st.KEY_EXCHANGE_FAILED);this._dhData=l;let d=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(d)&&(d=d[0]),this._hostKey=d,this.finish()}else{if(u!==wt.KEXDH_REPLY)return at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_REPLY}`,"handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),it.init(a,1);let l,d,p;if((l=it.readString())===void 0||(d=it.readString())===void 0||(p=it.readString())===void 0)return it.clear(),at(this._protocol,"Received malformed KEX*_REPLY","handshake",st.KEY_EXCHANGE_FAILED);it.clear(),it.init(l,0);let g=it.readString(!0);if(it.clear(),g===void 0)return at(this._protocol,"Received malformed host public key","handshake",st.KEY_EXCHANGE_FAILED);if(g!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(g==="ssh-rsa")break;default:return at(this._protocol,"Host key does not match negotiated type","handshake",st.KEY_EXCHANGE_FAILED)}this._hostKey=l,this._dhData=d,this._sig=p;let h=!1,_;if(this._protocol._hostVerifier===void 0?(_=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):_=this._protocol._hostVerifier(l,E=>{if(!h){if(h=!0,E===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),at(this._protocol,"Host denied (verification failed)","handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():Qa(this)}}),_===void 0){++this._step;return}if(h=!0,_===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),at(this._protocol,"Host denied (verification failed)","handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,Qa(this)}++this._step;break;case 2:return u!==wt.NEWKEYS?at(this._protocol,`Received packet ${u} instead of ${wt.NEWKEYS}`,"handshake",st.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 at(this._protocol,`Received unexpected packet ${u} after NEWKEYS`,"handshake",st.KEY_EXCHANGE_FAILED)}}}class r extends e{static{c(this,"Curve25519Exchange")}constructor(a,...u){super(...u),this.type="25519",this.hashName=a,this._keys=null}generateKeys(){this._keys||(this._keys=AI("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(a){let u,l=0,d=a.length;for(;a[l]===0;)++l,--d;return a.length===32||d!==a.length&&(u=Buffer.allocUnsafe(d),a.copy(u,0,l),a=u),a}computeSecret(a){this.generateKeys();try{let u=new Yg.Writer;return u.startSequence(),u.startSequence(),u.writeOID("1.3.101.110"),u.endSequence(),u.startSequence(Yg.BitString),u.writeByte(0),u._ensure(a.length),a.copy(u._buf,u._offset,0,a.length),u._offset+=a.length,u.endSequence(),u.endSequence(),t(yI({privateKey:this._keys.privateKey,publicKey:_I({key:u.buffer,type:"spki",format:"der"})}))}catch(u){return u}}}class n extends e{static{c(this,"ECDHExchange")}constructor(a,u,...l){super(...l),this.type="ecdh",this.curveName=a,this.hashName=u}generateKeys(){this._dh||(this._dh=mI(this.curveName),this._public=this._dh.generateKeys())}}class i extends e{static{c(this,"DHGroupExchange")}constructor(a,...u){super(...u),this.type="groupex",this.hashName=a,this._prime=null,this._generator=null,this._minBits=kI,this._prefBits=OI(this.negotiated),this._protocol._compatFlags&Ul.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=CI}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let a=this._protocol._packetRW.write.allocStartKEX,u=this._protocol._packetRW.write.alloc(13,!0);u[a]=wt.KEXDH_GEX_REQUEST,cr(u,this._minBits,++a),cr(u,this._prefBits,a+=4),cr(u,this._maxBits,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(u,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=hI(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(a,u){if(!Buffer.isBuffer(a))throw new Error("Invalid prime value");if(!Buffer.isBuffer(u))throw new Error("Invalid generator value");this._prime=a,this._generator=u}getDHParams(){if(this._dh)return{prime:t(this._dh.getPrime()),generator:t(this._dh.getGenerator())}}parse(a){let u=a[0];switch(this._step){case 1:{if(this._protocol._server)return u!==wt.KEXDH_GEX_REQUEST?at(this._protocol,`Received packet ${u} instead of `+wt.KEXDH_GEX_REQUEST,"handshake",st.KEY_EXCHANGE_FAILED):at(this._protocol,"Group exchange not implemented for server","handshake",st.KEY_EXCHANGE_FAILED);if(u!==wt.KEXDH_GEX_GROUP)return at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_GEX_GROUP}`,"handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),it.init(a,1);let l,d;if((l=it.readString())===void 0||(d=it.readString())===void 0)return it.clear(),at(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",st.KEY_EXCHANGE_FAILED);it.clear(),this.setDHParams(l,d),this.generateKeys();let p=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let g=this._protocol._packetRW.write.allocStartKEX,h=this._protocol._packetRW.write.alloc(5+p.length,!0);h[g]=wt.KEXDH_GEX_INIT,cr(h,p.length,++g),h.set(p,g+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(h,!0)),++this._step;break}case 2:if(this._protocol._server)return u!==wt.KEXDH_GEX_INIT?at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_GEX_INIT}`,"handshake",st.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),at(this._protocol,"Group exchange not implemented for server","handshake",st.KEY_EXCHANGE_FAILED));if(u!==wt.KEXDH_GEX_REPLY)return at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_GEX_REPLY}`,"handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,a[0]=wt.KEXDH_REPLY,this.parse=e.prototype.parse,this.parse(a)}}}class o extends e{static{c(this,"DHExchange")}constructor(a,u,...l){super(...l),this.type="group",this.groupName=a,this.hashName=u}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let a=this.getPublicKey(),u=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[u]=wt.KEXDH_INIT,cr(l,a.length,++u),l.set(a,u+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}generateKeys(){this._dh||(this._dh=gI(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:t(this._dh.getPrime()),generator:t(this._dh.getGenerator())}}}return(s,...a)=>{if(typeof s!="object"||s===null)throw new Error("Invalid negotiated argument");let u=s.kex;if(typeof u=="string"){switch(a=[s,...a],u){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!bI)break;return new r("sha256",...a);case"ecdh-sha2-nistp256":return new n("prime256v1","sha256",...a);case"ecdh-sha2-nistp384":return new n("secp384r1","sha384",...a);case"ecdh-sha2-nistp521":return new n("secp521r1","sha512",...a);case"diffie-hellman-group1-sha1":return new o("modp2","sha1",...a);case"diffie-hellman-group14-sha1":return new o("modp14","sha1",...a);case"diffie-hellman-group14-sha256":return new o("modp14","sha256",...a);case"diffie-hellman-group15-sha512":return new o("modp15","sha512",...a);case"diffie-hellman-group16-sha512":return new o("modp16","sha512",...a);case"diffie-hellman-group17-sha512":return new o("modp17","sha512",...a);case"diffie-hellman-group18-sha512":return new o("modp18","sha512",...a);case"diffie-hellman-group-exchange-sha1":return new i("sha1",...a);case"diffie-hellman-group-exchange-sha256":return new i("sha256",...a)}throw new Error(`Unsupported key exchange algorithm: ${u}`)}throw new Error(`Invalid key exchange type: ${u}`)}})(),Dl=(()=>{let t=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{static{c(this,"KexInit")}constructor(r){if(typeof r!="object"||r===null)throw new TypeError("Argument must be an object");let n={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 a of t){let u,l,d,p;if(typeof a=="string")u=n,l=r[a],d=p=a;else{let h=a[0];u=n[h],p=a[1],l=r[h][p],d=`${h}.${p}`}let g={array:void 0,buffer:void 0};if(Buffer.isBuffer(l))g.array=(""+l).split(","),g.buffer=l,i+=4+l.length;else{if(typeof l=="string"&&(l=l.split(",")),Array.isArray(l))g.array=l,g.buffer=Buffer.from(l.join(","));else throw new TypeError(`Invalid \`${d}\` type: ${typeof l}`);i+=4+g.buffer.length}u[p]=g}let o=Buffer.allocUnsafe(i);n.all=o;let s=0;for(let a of t){let u;typeof a=="string"?u=n[a].buffer:u=n[a[0]][a[1]].buffer,s=cr(o,u.length,s),o.set(u,s),s+=u.length}this.totalSize=i,this.lists=n}copyAllTo(r,n){let i=this.lists.all;if(typeof n!="number")throw new TypeError(`Invalid offset value: ${typeof n}`);if(r.length-n<i.length)throw new Error("Insufficient space to copy list");return r.set(i,n),i.length}}})(),on=(()=>{let t=Buffer.allocUnsafe(4);return(e,r)=>{cr(t,r.length,0),e.update(t),e.update(r)}})();function Ji(t,e,r,n,i,o){let s;if(t){let a=Bl(e).update(r).update(n).update(o).update(i).digest();for(;a.length<t;){let u=Bl(e).update(r).update(n).update(a).digest(),l=Buffer.allocUnsafe(a.length+u.length);l.set(a,0),l.set(u,a.length),a=l}a.length===t?s=a:s=new PI(a.buffer,a.byteOffset,t)}else s=RI;return s}c(Ji,"generateKEXVal");function om(t,e){if(e.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}e=this._packetRW.read.read(e);let r=e[0];if(!this._strictMode)switch(r){case wt.IGNORE:case wt.UNIMPLEMENTED:case wt.DEBUG:return Xi||(Xi=za()),Xi[r](this,e)}switch(r){case wt.DISCONNECT:return Xi||(Xi=za()),Xi[r](this,e);case wt.KEXINIT:return t.firstPacket?(t.firstPacket=!1,im(this,e)):at(this,"Received extra KEXINIT during handshake","handshake",st.KEY_EXCHANGE_FAILED);default:if(r<20||r>49)return at(this,`Received unexpected packet type ${r}`,"handshake",st.KEY_EXCHANGE_FAILED)}return this._kex.parse(e)}c(om,"onKEXPayload");function OI(t){let e=eo[t.cs.cipher],r=eo[t.sc.cipher],n=Math.max(0,e.sslName==="des-ede3-cbc"?14:e.keyLen,e.blockLen,e.ivLen,r.sslName==="des-ede3-cbc"?14:r.keyLen,r.blockLen,r.ivLen)*8;return n<=112?2048:n<=128?3072:n<=192?7680:8192}c(OI,"dhEstimate");function Qa(t){if(!t._sentNEWKEYS){t._protocol._debug&&t._protocol._debug("Outbound: Sending NEWKEYS");let e=t._protocol._packetRW.write.allocStartKEX,r=t._protocol._packetRW.write.alloc(1,!0);r[e]=wt.NEWKEYS,t._protocol._cipher.encrypt(t._protocol._packetRW.write.finalize(r,!0)),t._sentNEWKEYS=!0,t._protocol._strictMode&&(t._protocol._cipher.outSeqno=0)}}c(Qa,"trySendNEWKEYS");sm.exports={KexInit:Dl,kexinit:nm,onKEXPayload:om,DEFAULT_KEXINIT_CLIENT:new Dl({kex:Xg.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:Jg,cs:{cipher:Fa,mac:Ha,compress:ja,lang:[]},sc:{cipher:Fa,mac:Ha,compress:ja,lang:[]}}),DEFAULT_KEXINIT_SERVER:new Dl({kex:Xg.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:Jg,cs:{cipher:Fa,mac:Ha,compress:ja,lang:[]},sc:{cipher:Fa,mac:Ha,compress:ja,lang:[]}}),HANDLERS:{[wt.KEXINIT]:im}}});var am=le((V3,$I)=>{$I.exports={name:"ssh2",version:"1.16.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.20.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 Fl=le((G3,Em)=>{"use strict";var{inspect:pm}=require("util"),{bindingAvailable:DI,NullCipher:BI,NullDecipher:UI}=Ln(),{COMPAT_CHECKS:LI,DISCONNECT_REASON:hm,eddsaSupported:zI,MESSAGE:we,SIGNALS:cm,TERMINAL_MODE:zl}=An(),{DEFAULT_KEXINIT_CLIENT:MI,DEFAULT_KEXINIT_SERVER:FI,KexInit:um,kexinit:gm,onKEXPayload:HI}=Ma(),{parseKey:lm}=Fn(),jI=za(),{bufferCopy:Ka,bufferFill:WI,bufferSlice:mm,convertSignature:fm,sendPacket:Pe,writeUInt32BE:R}=Qr(),{PacketReader:qI,PacketWriter:QI,ZlibPacketReader:_m,ZlibPacketWriter:ym}=Nl(),KI=am().version,VI=new Map(Object.values(hm).map(t=>[t,1])),Am=Buffer.from(`SSH-2.0-ssh2js${KI}`),GI=Buffer.from(`${Am}\r
12
- `),ZI=8192,YI=1024,dm=Buffer.from([we.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]),XI=Buffer.from([zl.TTY_OP_END]);function Ll(){}c(Ll,"noop");var Ml=class{static{c(this,"Protocol")}constructor(e){let r=e.onWrite;if(typeof r!="function")throw new Error("Missing onWrite function");this._onWrite=h=>{r(h)};let n=e.onError;if(typeof n!="function")throw new Error("Missing onError function");this._onError=h=>{n(h)};let i=e.debug;this._debug=typeof i=="function"?h=>{i(h)}:void 0;let o=e.onHeader;this._onHeader=typeof o=="function"?(...h)=>{o(...h)}:Ll;let s=e.onPacket;this._onPacket=typeof s=="function"?()=>{s()}:Ll;let a=e.onHandshakeComplete;typeof a!="function"&&(a=Ll);let u;this._onHandshakeComplete=(...h)=>{this._debug&&this._debug("Handshake completed"),u===void 0?u=!0:u=!1;let _=this._queue;if(_){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${_.length}) ...`);for(let E=0;E<_.length;++E){let b=_[E],I=this._packetRW.write.finalize(b);if(I===b){let w=this._cipher.allocPacket(b.length);w.set(b,5),I=w}Pe(this,I)}this._debug&&this._debug("... finished draining outbound queue")}u&&this._server&&this._kex.remoteExtInfoEnabled&&ov(this),a(...h)},this._queue=void 0;let l=e.messageHandlers;typeof l=="object"&&l!==null?this._handlers=l:this._handlers={},this._onPayload=rv.bind(this),this._server=!!e.server,this._banner=void 0;let d;if(this._server){if(typeof e.hostKeys!="object"||e.hostKeys===null)throw new Error("Missing server host key(s)");this._hostKeys=e.hostKeys,typeof e.greeting=="string"&&e.greeting.length&&(d=e.greeting.slice(-2)===`\r
11
+ ${r}-----END ${t} KEY-----`}c(Kr,"makePEM");function ns(t,e){let r=Buffer.allocUnsafe(t.length+e.length);return r.set(t,0),r.set(e,t.length),r}c(ns,"combineBuffers");function yl(t,e){let r=t.length,n=t._pos||0;for(let i=0;i<e;++i){let o=r-n;if(n>=r||o<4)return!1;let s=es(t,n);if(o<4+s)return!1;n+=4+s}return t._pos=n,!0}c(yl,"skipFields");function is(t,e){let r=new Oe.Writer;return r.startSequence(),r.startSequence(),r.writeOID("1.2.840.113549.1.1.1"),r.writeNull(),r.endSequence(),r.startSequence(Oe.BitString),r.writeByte(0),r.startSequence(),r.writeBuffer(t,Oe.Integer),r.writeBuffer(e,Oe.Integer),r.endSequence(),r.endSequence(),r.endSequence(),Kr("PUBLIC",r.buffer)}c(is,"genOpenSSLRSAPub");function os(t,e){let r=Buffer.allocUnsafe(15+e.length+4+t.length);cr(r,7,0),r.utf8Write("ssh-rsa",4,7);let n=11;return cr(r,e.length,n),r.set(e,n+=4),cr(r,t.length,n+=e.length),r.set(t,n+4),r}c(os,"genOpenSSHRSAPub");var Rg=(()=>{function t(n,i,o,s,a,u,l,d){let p=new Oe.Writer;return p.startSequence(),p.writeInt(0,Oe.Integer),p.writeBuffer(n,Oe.Integer),p.writeBuffer(i,Oe.Integer),p.writeBuffer(o,Oe.Integer),p.writeBuffer(s,Oe.Integer),p.writeBuffer(a,Oe.Integer),p.writeBuffer(u,Oe.Integer),p.writeBuffer(l,Oe.Integer),p.writeBuffer(d,Oe.Integer),p.endSequence(),p.buffer}c(t,"genRSAASN1Buf");function e(n){return BigInt(`0x${n.hexSlice(0,n.length)}`)}c(e,"bigIntFromBuffer");function r(n){let i=n.toString(16);if((i.length&1)!==0)i=`0${i}`;else{let o=i.charCodeAt(0);(o===56||o===57||o>=97&&o<=102)&&(i=`00${i}`)}return Buffer.from(i,"hex")}return c(r,"bigIntToBuffer"),c(function(i,o,s,a,u,l){let d=e(s),p=r(d%(e(u)-1n)),g=r(d%(e(l)-1n));return Kr("RSA PRIVATE",t(i,o,s,u,l,p,g,a))},"genOpenSSLRSAPriv")})();function ss(t,e,r,n){let i=new Oe.Writer;return i.startSequence(),i.startSequence(),i.writeOID("1.2.840.10040.4.1"),i.startSequence(),i.writeBuffer(t,Oe.Integer),i.writeBuffer(e,Oe.Integer),i.writeBuffer(r,Oe.Integer),i.endSequence(),i.endSequence(),i.startSequence(Oe.BitString),i.writeByte(0),i.writeBuffer(n,Oe.Integer),i.endSequence(),i.endSequence(),Kr("PUBLIC",i.buffer)}c(ss,"genOpenSSLDSAPub");function as(t,e,r,n){let i=Buffer.allocUnsafe(15+t.length+4+e.length+4+r.length+4+n.length);cr(i,7,0),i.utf8Write("ssh-dss",4,7);let o=11;return cr(i,t.length,o),i.set(t,o+=4),cr(i,e.length,o+=t.length),i.set(e,o+=4),cr(i,r.length,o+=e.length),i.set(r,o+=4),cr(i,n.length,o+=r.length),i.set(n,o+4),i}c(as,"genOpenSSHDSAPub");function Ng(t,e,r,n,i){let o=new Oe.Writer;return o.startSequence(),o.writeInt(0,Oe.Integer),o.writeBuffer(t,Oe.Integer),o.writeBuffer(e,Oe.Integer),o.writeBuffer(r,Oe.Integer),o.writeBuffer(n,Oe.Integer),o.writeBuffer(i,Oe.Integer),o.endSequence(),Kr("DSA PRIVATE",o.buffer)}c(Ng,"genOpenSSLDSAPriv");function Og(t){let e=new Oe.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.3.101.112"),e.endSequence(),e.startSequence(Oe.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),Kr("PUBLIC",e.buffer)}c(Og,"genOpenSSLEdPub");function $g(t){let e=Buffer.allocUnsafe(19+t.length);return cr(e,11,0),e.utf8Write("ssh-ed25519",4,11),cr(e,t.length,15),e.set(t,19),e}c($g,"genOpenSSHEdPub");function tI(t){let e=new Oe.Writer;return e.startSequence(),e.writeInt(0,Oe.Integer),e.startSequence(),e.writeOID("1.3.101.112"),e.endSequence(),e.startSequence(Oe.OctetString),e.writeBuffer(t,Oe.OctetString),e.endSequence(),e.endSequence(),Kr("PRIVATE",e.buffer)}c(tI,"genOpenSSLEdPriv");function El(t,e){let r=new Oe.Writer;return r.startSequence(),r.startSequence(),r.writeOID("1.2.840.10045.2.1"),r.writeOID(t),r.endSequence(),r.startSequence(Oe.BitString),r.writeByte(0),r._ensure(e.length),r._buf.set(e,r._offset),r._offset+=e.length,r.endSequence(),r.endSequence(),Kr("PUBLIC",r.buffer)}c(El,"genOpenSSLECDSAPub");function Al(t,e){let r;switch(t){case"1.2.840.10045.3.1.7":r="nistp256";break;case"1.3.132.0.34":r="nistp384";break;case"1.3.132.0.35":r="nistp521";break;default:return}let n=Buffer.allocUnsafe(39+e.length);return cr(n,19,0),n.utf8Write(`ecdsa-sha2-${r}`,4,19),cr(n,8,23),n.utf8Write(r,27,8),cr(n,e.length,35),n.set(e,39),n}c(Al,"genOpenSSHECDSAPub");function rI(t,e,r){let n=new Oe.Writer;return n.startSequence(),n.writeInt(1,Oe.Integer),n.writeBuffer(r,Oe.OctetString),n.startSequence(160),n.writeOID(t),n.endSequence(),n.startSequence(161),n.startSequence(Oe.BitString),n.writeByte(0),n._ensure(e.length),n._buf.set(e,n._offset),n._offset+=e.length,n.endSequence(),n.endSequence(),n.endSequence(),Kr("EC PRIVATE",n.buffer)}c(rI,"genOpenSSLECDSAPriv");function nI(t,e){let r=Qx(t);return r.setPrivateKey(e),r.getPublicKey()}c(nI,"genOpenSSLECDSAPubFromPriv");var cs={sign:c(typeof kg=="function"?function(e,r){let n=this[Vr];if(n===null)return new Error("No private key available");(!r||typeof r!="string")&&(r=this[bn]);try{return kg(r,e,n)}catch(i){return i}}:function(e,r){let n=this[Vr];if(n===null)return new Error("No private key available");(!r||typeof r!="string")&&(r=this[bn]);let i=Kx(r);i.update(e);try{return i.sign(n)}catch(o){return o}},"sign"),verify:c(typeof Cg=="function"?function(e,r,n){let i=this[on];if(i===null)return new Error("No public key available");(!n||typeof n!="string")&&(n=this[bn]);try{return Cg(n,e,i,r)}catch(o){return o}}:function(e,r,n){let i=this[on];if(i===null)return new Error("No public key available");(!n||typeof n!="string")&&(n=this[bn]);let o=Gx(n);o.update(e);try{return o.verify(i,r)}catch(s){return s}},"verify"),isPrivateKey:c(function(){return this[Vr]!==null},"isPrivateKey"),getPrivatePEM:c(function(){return this[Vr]},"getPrivatePEM"),getPublicPEM:c(function(){return this[on]},"getPublicPEM"),getPublicSSH:c(function(){return this[Fn]},"getPublicSSH"),equals:c(function(e){let r=Ug(e);return r instanceof Error?!1:this.type===r.type&&this[Vr]===r[Vr]&&this[on]===r[on]&&this[Fn].equals(r[Fn])},"equals")};function $a(t,e,r,n,i,o,s){this.type=t,this.comment=e,this[Vr]=r,this[on]=n,this[Fn]=i,this[bn]=o,this[Zi]=s}c($a,"OpenSSH_Private");$a.prototype=cs;{let e=function(r,n,i){let o=[];if(r.length<8)return new Error("Malformed OpenSSH private key");let s=es(r,0),a=es(r,4);if(s!==a)return i?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");r._pos=8;let u,l;for(u=0;u<n;++u){let p,g,h,_,A=Re(r,r._pos,!0);if(A===void 0)return new Error("Malformed OpenSSH private key");switch(A){case"ssh-rsa":{let I=Re(r,r._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");let w=Re(r,r._pos);if(w===void 0)return new Error("Malformed OpenSSH private key");let H=Re(r,r._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let $=Re(r,r._pos);if($===void 0)return new Error("Malformed OpenSSH private key");let X=Re(r,r._pos);if(X===void 0)return new Error("Malformed OpenSSH private key");let Z=Re(r,r._pos);if(Z===void 0)return new Error("Malformed OpenSSH private key");h=is(I,w),_=os(I,w),g=Rg(I,w,H,$,X,Z),p="sha1";break}case"ssh-dss":{let I=Re(r,r._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");let w=Re(r,r._pos);if(w===void 0)return new Error("Malformed OpenSSH private key");let H=Re(r,r._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let $=Re(r,r._pos);if($===void 0)return new Error("Malformed OpenSSH private key");let X=Re(r,r._pos);if(X===void 0)return new Error("Malformed OpenSSH private key");h=ss(I,w,H,$),_=as(I,w,H,$),g=Ng(I,w,H,$,X),p="sha1";break}case"ssh-ed25519":{if(!_l)return new Error(`Unsupported OpenSSH private key type: ${A}`);let I=Re(r,r._pos);if(I===void 0||I.length!==32)return new Error("Malformed OpenSSH private key");let w=Re(r,r._pos);if(w===void 0||w.length!==64)return new Error("Malformed OpenSSH private key");h=Og(I),_=$g(I),g=tI(li(w,0,32)),p=null;break}case"ecdsa-sha2-nistp256":p="sha256",l="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":p===void 0&&(p="sha384",l="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(p===void 0&&(p="sha512",l="1.3.132.0.35"),!yl(r,1))return new Error("Malformed OpenSSH private key");let I=Re(r,r._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");let w=Re(r,r._pos);if(w===void 0)return new Error("Malformed OpenSSH private key");h=El(l,I),_=Al(l,I),g=rI(l,I,w);break}default:return new Error(`Unsupported OpenSSH private key type: ${A}`)}let b=Re(r,r._pos,!0);if(b===void 0)return new Error("Malformed OpenSSH private key");o.push(new $a(A,b,g,h,_,p,i))}let d=0;for(u=r._pos;u<r.length;++u)if(r[u]!==++d%255)return new Error("Malformed OpenSSH private key");return o};c(e,"parseOpenSSHPrivKeys");let t=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;$a.parse=(r,n)=>{let i=t.exec(r);if(i===null)return null;let o,s=Buffer.from(i[1],"base64");if(s.length<31)return new Error("Malformed OpenSSH private key");let a=s.utf8Slice(0,15);if(a!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${a}`);let u=Re(s,15,!0);if(u===void 0)return new Error("Malformed OpenSSH private key");if(u!=="none"&&Jx.indexOf(u)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${u}`);let l=Re(s,s._pos,!0);if(l===void 0)return new Error("Malformed OpenSSH private key");if(l!=="none"){if(u==="none")return new Error("Malformed OpenSSH private key");if(l!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${l}`);if(!n)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(u!=="none")return new Error("Malformed OpenSSH private key");let d,p,g;u!=="none"&&(d=rs[u]);let h=Re(s,s._pos);if(h===void 0)return new Error("Malformed OpenSSH private key");if(h.length)switch(l){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let A=Re(h,0);if(A===void 0||h._pos+4>h.length)return new Error("Malformed OpenSSH private key");let b=es(h,h._pos),I=Buffer.allocUnsafe(d.keyLen+d.ivLen);if(Xx(n,n.length,A,A.length,I,I.length,b)!==0)return new Error("Failed to generate information to decrypt key");p=li(I,0,d.keyLen),g=li(I,d.keyLen,I.length);break}}else if(l!=="none")return new Error("Malformed OpenSSH private key");if(s._pos+3>=s.length)return new Error("Malformed OpenSSH private key");let _=es(s,s._pos);if(s._pos+=4,_>0){for(let b=0;b<_;++b){let I=Re(s,s._pos);if(I===void 0)return new Error("Malformed OpenSSH private key");if(Re(I,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let A=Re(s,s._pos);if(A===void 0)return new Error("Malformed OpenSSH private key");if(p!==void 0){if(A.length<d.blockLen||A.length%d.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let b={authTagLength:d.authLen},I=ml(d.sslName,p,g,b);if(I.setAutoPadding(!1),d.authLen>0){if(s.length-s._pos<d.authLen)return new Error("Malformed OpenSSH private key");I.setAuthTag(li(s,s._pos,s._pos+=d.authLen))}A=ns(I.update(A),I.final())}catch(b){return b}}if(s._pos!==s.length)return new Error("Malformed OpenSSH private key");o=e(A,_,p!==void 0)}else o=[];return o instanceof Error?o:o[0]}}function Da(t,e,r,n,i,o,s){this.type=t,this.comment=e,this[Vr]=r,this[on]=n,this[Fn]=i,this[bn]=o,this[Zi]=s}c(Da,"OpenSSH_Old_Private");Da.prototype=cs;{let t=/^-----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-----$/;Da.parse=(e,r)=>{let n=t.exec(e);if(n===null)return null;let i=Buffer.from(n[3],"base64"),o=n[2],s=!1;if(o!==void 0){o=o.split(/\r\n|\n/g);for(let _=0;_<o.length;++_){let A=o[_],b=A.indexOf(":");if(A.slice(0,b)==="DEK-Info"){let I=A.slice(b+2);if(b=I.indexOf(","),b===-1)continue;let w=I.slice(0,b).toLowerCase();if(Yx.indexOf(w)===-1)return new Error(`Cipher (${w}) not supported for encrypted OpenSSH private key`);let H=gl[w];if(!H)return new Error(`Cipher (${w}) not supported for encrypted OpenSSH private key`);let $=Buffer.from(I.slice(b+1),"hex");if($.length!==H.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!r)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let X=li($,0,8),Z=ts("md5").update(r).update(X).digest();for(;Z.length<H.keyLen;)Z=ns(Z,ts("md5").update(Z).update(r).update(X).digest());Z.length>H.keyLen&&(Z=li(Z,0,H.keyLen));try{let Y=ml(w,Z,$);Y.setAutoPadding(!1),i=ns(Y.update(i),Y.final()),s=!0}catch(Y){return Y}}}}let a,u,l,d,p,g,h="Malformed OpenSSH private key";switch(s&&(h+=". Bad passphrase?"),n[1]){case"RSA":a="ssh-rsa",u=Kr("RSA PRIVATE",i);try{g=new Oe.Reader(i),g.readSequence(),g.readInt();let _=g.readString(Oe.Integer,!0);if(_===null)return new Error(h);let A=g.readString(Oe.Integer,!0);if(A===null)return new Error(h);l=is(_,A),d=os(_,A)}catch{return new Error(h)}p="sha1";break;case"DSA":a="ssh-dss",u=Kr("DSA PRIVATE",i);try{g=new Oe.Reader(i),g.readSequence(),g.readInt();let _=g.readString(Oe.Integer,!0);if(_===null)return new Error(h);let A=g.readString(Oe.Integer,!0);if(A===null)return new Error(h);let b=g.readString(Oe.Integer,!0);if(b===null)return new Error(h);let I=g.readString(Oe.Integer,!0);if(I===null)return new Error(h);l=ss(_,A,b,I),d=as(_,A,b,I)}catch{return new Error(h)}p="sha1";break;case"EC":{let _,A,b;try{g=new Oe.Reader(i),g.readSequence(),g.readInt(),A=g.readString(Oe.OctetString,!0),g.readByte();let w=g.readLength();if(w!==null){if(g._offset=w,b=g.readOID(),b===null)return new Error(h);switch(b){case"1.2.840.10045.3.1.7":_="prime256v1",a="ecdsa-sha2-nistp256",p="sha256";break;case"1.3.132.0.34":_="secp384r1",a="ecdsa-sha2-nistp384",p="sha384";break;case"1.3.132.0.35":_="secp521r1",a="ecdsa-sha2-nistp521",p="sha512";break;default:return new Error(`Unsupported private key EC OID: ${b}`)}}else return new Error(h)}catch{return new Error(h)}u=Kr("EC PRIVATE",i);let I=nI(_,A);l=El(b,I),d=Al(b,I);break}}return new Da(a,"",u,l,d,p,s)}}function Ba(t,e,r,n,i,o,s){this.type=t,this.comment=e,this[Vr]=r,this[on]=n,this[Fn]=i,this[bn]=o,this[Zi]=s}c(Ba,"PPK_Private");Ba.prototype=cs;{let t=Buffer.alloc(0),e=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),r=Buffer.from([0,0,0,0]),n=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]+)/;Ba.parse=(o,s)=>{let a=i.exec(o);if(a===null)return null;let u=a[2],l=u!=="none";if(l&&!s)return new Error("Encrypted PPK private key detected, but no passphrase given");let d=Buffer.from(a[5],"base64");if(l){let M=rs[u],L=ns(ts("sha1").update(r).update(s).digest(),ts("sha1").update(n).update(s).digest());L.length>M.keyLen&&(L=li(L,0,M.keyLen));try{let T=ml(M.sslName,L,e);T.setAutoPadding(!1),d=ns(T.update(d),T.final())}catch(T){return T}}let p=a[1],g=a[3],h=Buffer.from(a[4],"base64"),_=a[6],A=p.length,b=u.length,I=Buffer.byteLength(g),w=h.length,H=d.length,$=Buffer.allocUnsafe(4+A+4+b+4+I+4+w+4+H),X=0;if(cr($,A,X),$.utf8Write(p,X+=4,A),cr($,b,X+=A),$.utf8Write(u,X+=4,b),cr($,I,X+=b),$.utf8Write(g,X+=4,I),cr($,w,X+=I),$.set(h,X+=4),cr($,H,X+=w),$.set(d,X+4),s||(s=t),Vx("sha1",ts("sha1").update("putty-private-key-file-mac-key").update(s).digest()).update($).digest("hex")!==_)return l?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let Y,P,k;switch(h._pos=0,yl(h,1),p){case"ssh-rsa":{let M=Re(h,h._pos);if(M===void 0)return new Error("Malformed PPK public key");let L=Re(h,h._pos);if(L===void 0)return new Error("Malformed PPK public key");let T=Re(d,0);if(T===void 0)return new Error("Malformed PPK private key");let F=Re(d,d._pos);if(F===void 0)return new Error("Malformed PPK private key");let j=Re(d,d._pos);if(j===void 0)return new Error("Malformed PPK private key");let B=Re(d,d._pos);if(B===void 0)return new Error("Malformed PPK private key");Y=is(L,M),P=os(L,M),k=Rg(L,M,T,B,F,j);break}case"ssh-dss":{let M=Re(h,h._pos);if(M===void 0)return new Error("Malformed PPK public key");let L=Re(h,h._pos);if(L===void 0)return new Error("Malformed PPK public key");let T=Re(h,h._pos);if(T===void 0)return new Error("Malformed PPK public key");let F=Re(h,h._pos);if(F===void 0)return new Error("Malformed PPK public key");let j=Re(d,0);if(j===void 0)return new Error("Malformed PPK private key");Y=ss(M,L,T,F),P=as(M,L,T,F),k=Ng(M,L,T,F,j);break}}return new Ba(p,g,k,Y,P,"sha1",l)}}function La(t,e,r,n,i){this.type=t,this.comment=e,this[Vr]=null,this[on]=r,this[Fn]=n,this[bn]=i,this[Zi]=!1}c(La,"OpenSSH_Public");La.prototype=cs;{let t;_l?t=/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:t=/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,La.parse=e=>{let r=t.exec(e);if(r===null)return null;let n=r[1],i=r[2],o=Buffer.from(r[3],"base64"),s=r[4]||"",a=Re(o,o._pos,!0);return a===void 0||a.indexOf(i)!==0?new Error("Malformed OpenSSH public key"):bl(o,i,s,n)}}function Ua(t,e,r,n,i){this.type=t,this.comment=e,this[Vr]=null,this[on]=r,this[Fn]=n,this[bn]=i,this[Zi]=!1}c(Ua,"RFC4716_Public");Ua.prototype=cs;{let t=/^---- BEGIN SSH2 PUBLIC KEY ----(?:\r?\n)((?:.{0,72}\r?\n)+)---- END SSH2 PUBLIC KEY ----$/,e=/^[A-Z0-9a-z/+=\r\n]+$/,r=/^([\x21-\x39\x3B-\x7E]{1,64}): ((?:[^\\]*\\\r?\n)*[^\r\n]+)\r?\n/gm,n=/\\\r?\n/g;Ua.parse=i=>{let o=t.exec(i);if(o===null)return null;let s=o[1],a=0,u="";for(;o=r.exec(s);){let h=o[1],_=o[2].replace(n,"");if(_.length>1024)return r.lastIndex=0,new Error("Malformed RFC4716 public key");a=r.lastIndex,h.toLowerCase()==="comment"&&(u=_,u.length>1&&u.charCodeAt(0)===34&&u.charCodeAt(u.length-1)===34&&(u=u.slice(1,-1)))}let l=s.slice(a);if(!e.test(l))return new Error("Malformed RFC4716 public key");l=Buffer.from(l,"base64");let d=Re(l,0,!0);if(d===void 0)return new Error("Malformed RFC4716 public key");let p=null,g=null;switch(d){case"ssh-rsa":{let h=Re(l,l._pos);if(h===void 0)return new Error("Malformed RFC4716 public key");let _=Re(l,l._pos);if(_===void 0)return new Error("Malformed RFC4716 public key");p=is(_,h),g=os(_,h);break}case"ssh-dss":{let h=Re(l,l._pos);if(h===void 0)return new Error("Malformed RFC4716 public key");let _=Re(l,l._pos);if(_===void 0)return new Error("Malformed RFC4716 public key");let A=Re(l,l._pos);if(A===void 0)return new Error("Malformed RFC4716 public key");let b=Re(l,l._pos);if(b===void 0)return new Error("Malformed RFC4716 public key");p=ss(h,_,A,b),g=as(h,_,A,b);break}default:return new Error("Malformed RFC4716 public key")}return new Ua(d,u,p,g,"sha1")}}function bl(t,e,r,n){if(!Dg(e))return new Error(`Unsupported OpenSSH public key type: ${e}`);let i,o,s=null,a=null;switch(e){case"ssh-rsa":{let u=Re(t,t._pos||0);if(u===void 0)return new Error("Malformed OpenSSH public key");let l=Re(t,t._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");s=is(l,u),a=os(l,u),i="sha1";break}case"ssh-dss":{let u=Re(t,t._pos||0);if(u===void 0)return new Error("Malformed OpenSSH public key");let l=Re(t,t._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");let d=Re(t,t._pos);if(d===void 0)return new Error("Malformed OpenSSH public key");let p=Re(t,t._pos);if(p===void 0)return new Error("Malformed OpenSSH public key");s=ss(u,l,d,p),a=as(u,l,d,p),i="sha1";break}case"ssh-ed25519":{let u=Re(t,t._pos||0);if(u===void 0||u.length!==32)return new Error("Malformed OpenSSH public key");s=Og(u),a=$g(u),i=null;break}case"ecdsa-sha2-nistp256":i="sha256",o="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":i===void 0&&(i="sha384",o="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(i===void 0&&(i="sha512",o="1.3.132.0.35"),!yl(t,1))return new Error("Malformed OpenSSH public key");let u=Re(t,t._pos||0);if(u===void 0)return new Error("Malformed OpenSSH public key");s=El(o,u),a=Al(o,u);break}default:return new Error(`Unsupported OpenSSH public key type: ${e}`)}return new La(n,r,s,a,i)}c(bl,"parseDER");function Dg(t){switch(t){case"ssh-rsa":case"ssh-dss":case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":return!0;case"ssh-ed25519":if(_l)return!0;default:return!1}}c(Dg,"isSupportedKeyType");function Bg(t){return t?typeof t[Zi]=="boolean":!1}c(Bg,"isParsedKey");function Ug(t,e){if(Bg(t))return t;let r;if(Buffer.isBuffer(t))r=t,t=t.utf8Slice(0,t.length).trim();else if(typeof t=="string")t=t.trim();else return new Error("Key data must be a Buffer or string");if(e!=null){if(typeof e=="string")e=Buffer.from(e);else if(!Buffer.isBuffer(e))return new Error("Passphrase must be a string or Buffer when supplied")}let n;if((n=$a.parse(t,e))!==null||(n=Da.parse(t,e))!==null||(n=Ba.parse(t,e))!==null||(n=La.parse(t))!==null||(n=Ua.parse(t))!==null)return n;if(r){Oa.init(r,0);let i=Oa.readString(!0);i!==void 0&&(t=Oa.readRaw(),t!==void 0&&(n=bl(t,i,"",i),n instanceof Error&&(n=null))),Oa.clear()}return n||new Error("Unsupported key format")}c(Ug,"parseKey");Lg.exports={isParsedKey:Bg,isSupportedKeyType:Dg,parseDERKey:c((t,e)=>bl(t,e,"",e),"parseDERKey"),parseKey:Ug}});var Pl=le((nF,Kg)=>{"use strict";var{Socket:Hg}=require("net"),{Duplex:jg}=require("stream"),{resolve:iI}=require("path"),{readFile:zg}=require("fs"),{execFile:oI,spawn:sI}=require("child_process"),{isParsedKey:Mg,parseKey:us}=Hn(),{makeBufferParser:aI,readUInt32BE:wl,writeUInt32BE:wr,writeUInt32LE:Fg}=Qr();function ls(t){let e=!1;return(...r)=>{e||(e=!0,t(...r))}}c(ls,"once");function cI(t,e){let r=Buffer.allocUnsafe(t.length+e.length);return t.copy(r,0),e.copy(r,t.length),r}c(cI,"concat");function Il(){}c(Il,"noop");var uI=Buffer.alloc(0),Lt=aI(),fs=class{static{c(this,"BaseAgent")}getIdentities(e){e(new Error("Missing getIdentities() implementation"))}sign(e,r,n,i){typeof n=="function"&&(i=n),i(new Error("Missing sign() implementation"))}},Xi=class extends fs{static{c(this,"OpenSSHAgent")}constructor(e){super(),this.socketPath=e}getStream(e){e=ls(e);let r=new Hg;r.on("connect",()=>{e(null,r)}),r.on("close",n).on("end",n).on("error",n),r.connect(this.socketPath);function n(){try{r.destroy()}catch{}e(new Error("Failed to connect to agent"))}c(n,"onFail")}getIdentities(e){e=ls(e),this.getStream((r,n)=>{function i(s){if(n)try{n.destroy()}catch{}s||(s=new Error("Failed to retrieve identities from agent")),e(s)}if(c(i,"onFail"),r)return i(r);let o=new vl(!0);o.on("error",i),o.pipe(n).pipe(o),n.on("close",i).on("end",i).on("error",i),o.getIdentities((s,a)=>{if(s)return i(s);try{n.destroy()}catch{}e(null,a)})})}sign(e,r,n,i){typeof n=="function"?(i=n,n=void 0):(typeof n!="object"||n===null)&&(n=void 0),i=ls(i),this.getStream((o,s)=>{function a(l){if(s)try{s.destroy()}catch{}l||(l=new Error("Failed to sign data with agent")),i(l)}if(c(a,"onFail"),o)return a(o);let u=new vl(!0);u.on("error",a),u.pipe(s).pipe(u),s.on("close",a).on("end",a).on("error",a),u.sign(e,r,n,(l,d)=>{if(l)return a(l);try{s.destroy()}catch{}i(null,d)})})}},Wg=(()=>{let s=iI(__dirname,"..","util/pagent.exe"),a={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 u(d){d.buffer=null,d.proc&&(d.proc.kill(),d.proc=void 0)}c(u,"destroy");class l extends jg{static{c(this,"PageantSocket")}constructor(){super(),this.proc=void 0,this.buffer=null}_read(p){}_write(p,g,h){if(this.buffer===null)this.buffer=p;else{let I=Buffer.allocUnsafe(this.buffer.length+p.length);this.buffer.copy(I,0),p.copy(I,this.buffer.length),this.buffer=I}if(this.buffer.length<4)return h();let _=wl(this.buffer,0);if(this.buffer.length-4<_)return h();if(p=this.buffer.slice(0,4+_),this.buffer.length>4+_)return h(new Error("Unexpected multiple agent requests"));this.buffer=null;let A,b=this.proc=sI(s,[p.length]);b.stdout.on("data",I=>{this.push(I)}),b.on("error",I=>{A=I,h(A)}),b.on("close",I=>{if(this.proc=void 0,!A){if(A=a[I])return h(A);h()}}),b.stdin.end(p)}_final(p){u(this),p()}_destroy(p,g){u(this),g()}}return class extends Xi{static{c(this,"PageantAgent")}getStream(p){p(null,new l)}}})(),qg=(()=>{let t=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Xi{static{c(this,"CygwinAgent")}getStream(r){r=ls(r);let n=this.socketPath,i=!1;zg(n,c(function o(s,a){if(s){if(i)return r(new Error("Invalid cygwin unix socket path"));oI("cygpath",["-w",n],(Z,Y,P)=>{if(Z||Y.length===0)return r(new Error("Invalid cygwin unix socket path"));i=!0,n=Y.toString().replace(/[\r\n]/g,""),zg(n,o)});return}let u=t.exec(a.toString("ascii"));if(!u)return r(new Error("Malformed cygwin unix socket file"));let l,d=0,p=!1,g=[],h,_=Buffer.alloc(12),A=parseInt(u[1],10),b=u[2].replace(/-/g,""),I=Buffer.allocUnsafe(16);for(let Z=0,Y=0;Y<32;++Z,Y+=2)I[Z]=parseInt(b.substring(Y,Y+2),16);for(let Z=0;Z<16;Z+=4)Fg(I,wl(I,Z),Z);X();function w(){d=0,l="secret",h.write(I)}c(w,"_onconnect");function H(Z){if(d+=Z.length,l==="secret"){d===16&&(d=0,l="creds",h.write(_));return}if(l==="creds"&&(p||g.push(Z),d===12)){if(h.removeListener("connect",w),h.removeListener("data",H),h.removeListener("error",$),h.removeListener("end",$),h.removeListener("close",$),p)return r(null,h);p=!0,_=Buffer.concat(g),Fg(_,process.pid,0),h.on("error",()=>{}),h.destroy(),X()}}c(H,"_ondata");function $(){r(new Error("Problem negotiating cygwin unix socket security"))}c($,"onFail");function X(){h=new Hg,h.on("connect",w),h.on("data",H),h.on("error",$),h.on("end",$),h.on("close",$),h.connect(A)}c(X,"tryConnect")},"readCygsocket"))}}})(),lI=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function Qg(t){return process.platform==="win32"&&!lI.test(t)?t==="pageant"?new Wg:new qg(t):new Xi(t)}c(Qg,"createAgent");var vl=(()=>{function l(P){let k;for(;P[w].length;){let M=P[w][0][p];if(M===void 0)break;P[w].shift(),k=P.push(M)}return k}c(l,"processResponses");let d=Symbol("Inbound Request Type"),p=Symbol("Inbound Request Response"),g=Symbol("Inbound Request Context");class h{static{c(this,"AgentInboundRequest")}constructor(k,M){this[d]=k,this[p]=void 0,this[g]=M}hasResponded(){return this[p]!==void 0}getType(){return this[d]}getContext(){return this[g]}}function _(P,k,M){return k[p]=M,l(P)}c(_,"respond");function A(P){if(P[$]=null,P[H]===0){let k=P[w];if(k&&k.length){P[w]=[];for(let M of k)M.cb(new Error("No reply from server"))}}try{P.end()}catch{}setImmediate(()=>{P[Y]||P.emit("end"),P[Z]||P.emit("close")})}c(A,"cleanup");function b(){this[Z]=!0}c(b,"onClose");function I(){this[Y]=!0}c(I,"onEnd");let w=Symbol("Requests"),H=Symbol("Agent Protocol Role"),$=Symbol("Agent Protocol Buffer"),X=Symbol("Agent Protocol Current Message Length"),Z=Symbol("Agent Protocol Closed"),Y=Symbol("Agent Protocol Ended");return class extends jg{static{c(this,"AgentProtocol")}constructor(k){super({autoDestroy:!0,emitClose:!1}),this[H]=k?0:1,this[w]=[],this[$]=null,this[X]=-1,this.once("end",I),this.once("close",b)}_read(k){}_write(k,M,L){this[$]===null?this[$]=k:this[$]=cI(this[$],k);let T=this[$],F=T.length,j=0;for(;j<F&&!(F<5||(this[X]===-1&&(this[X]=wl(T,j)),F<4+this[X]));){let B=T[j+=4];if(++j,this[H]===0){if(this[w].length===0)return L(new Error("Received unexpected message from server"));let G=this[w].shift();switch(B){case 5:G.cb(new Error("Agent responded with failure"));break;case 12:{if(G.type!==11)return L(new Error("Agent responded with wrong message type"));Lt.init(T,j);let ee=Lt.readUInt32BE();if(ee===void 0)return Lt.clear(),L(new Error("Malformed agent response"));let C=[];for(let W=0;W<ee;++W){let q=Lt.readString();if(q===void 0)return Lt.clear(),L(new Error("Malformed agent response"));let J=Lt.readString(!0);if(J===void 0)return Lt.clear(),L(new Error("Malformed agent response"));q=us(q),!(q instanceof Error)&&(q.comment=q.comment||J,C.push(q))}j=Lt.pos(),Lt.clear(),G.cb(null,C);break}case 14:{if(G.type!==13)return L(new Error("Agent responded with wrong message type"));Lt.init(T,j);let ee=Lt.readString();if(j=Lt.pos(),Lt.clear(),ee===void 0)return L(new Error("Malformed agent response"));if(Lt.init(ee,0),Lt.readString(!0),ee=Lt.readString(),Lt.clear(),ee===void 0)return L(new Error("Malformed OpenSSH signature format"));G.cb(null,ee);break}default:return L(new Error("Agent responded with unsupported message type"))}}else switch(B){case 11:{let G=new h(B);this[w].push(G),this.emit("identities",G);break}case 13:{Lt.init(T,j);let G=Lt.readString(),ee=Lt.readString(),C=Lt.readUInt32BE();if(j=Lt.pos(),Lt.clear(),C===void 0){let ue=new h(B);return this[w].push(ue),this.failureReply(ue)}if(G=us(G),G instanceof Error){let ue=new h(B);return this[w].push(ue),this.failureReply(ue)}let W={hash:void 0},q;G.type==="ssh-rsa"&&(C&2?(q="rsa-sha2-256",W.hash="sha256"):C&4&&(q="rsa-sha2-512",W.hash="sha512")),q===void 0&&(q=G.type);let J=new h(B,q);this[w].push(J),this.emit("sign",J,G,ee,W);break}default:{let G=new h(B);this[w].push(G),this.failureReply(G)}}if(this[X]=-1,j===F){this[$]=null;break}else this[$]=T=T.slice(j),F=T.length,j=0}L()}_destroy(k,M){A(this),M()}_final(k){A(this),k()}sign(k,M,L,T){if(this[H]!==0)throw new Error("Client-only method called with server role");typeof L=="function"?(T=L,L=void 0):(typeof L!="object"||L===null)&&(L=void 0);let F=0;if(k=us(k),k instanceof Error)throw new Error("Invalid public key argument");if(k.type==="ssh-rsa"&&L)switch(L.hash){case"sha256":F=2;break;case"sha512":F=4;break}k=k.getPublicSSH();let j=13,B=k.length,G=M.length,ee=0,C=Buffer.allocUnsafe(9+B+4+G+4);return wr(C,C.length-4,ee),C[ee+=4]=j,wr(C,B,++ee),k.copy(C,ee+=4),wr(C,G,ee+=B),M.copy(C,ee+=4),wr(C,F,ee+=G),typeof T!="function"&&(T=Il),this[w].push({type:j,cb:T}),this.push(C)}getIdentities(k){if(this[H]!==0)throw new Error("Client-only method called with server role");let M=11,L=0,T=Buffer.allocUnsafe(5);return wr(T,T.length-4,L),T[L+=4]=M,typeof k!="function"&&(k=Il),this[w].push({type:M,cb:k}),this.push(T)}failureReply(k){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(k instanceof h))throw new Error("Wrong request argument");if(k.hasResponded())return!0;let M=0,L=Buffer.allocUnsafe(5);return wr(L,L.length-4,M),L[M+=4]=5,_(this,k,L)}getIdentitiesReply(k,M){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(k instanceof h))throw new Error("Wrong request argument");if(k.hasResponded())return!0;if(k.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(M))throw new Error("Keys argument must be an array");let L=4,T=[];for(let B=0;B<M.length;++B){let G=M[B];if(typeof G!="object"||G===null)throw new Error(`Invalid key entry: ${G}`);let ee,C;if(Mg(G))ee=G;else if(Mg(G.pubKey))ee=G.pubKey;else if(typeof G.pubKey!="object"||G.pubKey===null||({pubKey:ee,comment:C}=G.pubKey,ee=us(ee),ee instanceof Error))continue;C=ee.comment||C,ee=ee.getPublicSSH(),L+=4+ee.length,C&&typeof C=="string"?C=Buffer.from(C):Buffer.isBuffer(C)||(C=uI),L+=4+C.length,T.push({pubKey:ee,comment:C})}let F=0,j=Buffer.allocUnsafe(5+L);wr(j,j.length-4,F),j[F+=4]=12,wr(j,T.length,++F),F+=4;for(let B=0;B<T.length;++B){let{pubKey:G,comment:ee}=T[B];wr(j,G.length,F),G.copy(j,F+=4),wr(j,ee.length,F+=G.length),F+=4,ee.length&&(ee.copy(j,F),F+=ee.length)}return _(this,k,j)}signReply(k,M){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(k instanceof h))throw new Error("Wrong request argument");if(k.hasResponded())return!0;if(k.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(M))throw new Error("Signature argument must be a Buffer");if(M.length===0)throw new Error("Signature argument must be non-empty");let L=0,T=k.getContext(),F=Buffer.byteLength(T),j=Buffer.allocUnsafe(13+F+4+M.length);return wr(j,j.length-4,L),j[L+=4]=14,wr(j,4+F+4+M.length,++L),wr(j,F,L+=4),j.utf8Write(T,L+=4,F),wr(j,M.length,L+=F),M.copy(j,L+=4),_(this,k,j)}}})(),xl=Symbol("Agent"),Gr=Symbol("Agent Keys"),xn=Symbol("Agent Keys Index"),Yi=Symbol("Agent Init Callbacks"),Sl=class{static{c(this,"AgentContext")}constructor(e){if(typeof e=="string")e=Qg(e);else if(!Vg(e))throw new Error("Invalid agent argument");this[xl]=e,this[Gr]=null,this[xn]=-1,this[Yi]=null}init(e){if(typeof e!="function"&&(e=Il),this[Gr]===null)if(this[Yi]===null){this[Yi]=[e];let r=c((...n)=>{process.nextTick(()=>{let i=this[Yi];this[Yi]=null;for(let o of i)o(...n)})},"doCbs");this[xl].getIdentities(ls((n,i)=>{if(n)return r(n);if(!Array.isArray(i))return r(new Error("Agent implementation failed to provide keys"));let o=[];for(let s of i)s=us(s),!(s instanceof Error)&&o.push(s);this[Gr]=o,this[xn]=-1,r()}))}else this[Yi].push(e);else process.nextTick(e)}nextKey(){return this[Gr]===null||++this[xn]>=this[Gr].length?!1:this[Gr][this[xn]]}currentKey(){return this[Gr]===null||this[xn]>=this[Gr].length?null:this[Gr][this[xn]]}pos(){return this[Gr]===null||this[xn]>=this[Gr].length?-1:this[xn]}reset(){this[xn]=-1}sign(...e){this[xl].sign(...e)}};function Vg(t){return t instanceof fs}c(Vg,"isAgent");Kg.exports={AgentContext:Sl,AgentProtocol:vl,BaseAgent:fs,createAgent:Qg,CygwinAgent:qg,isAgent:Vg,OpenSSHAgent:Xi,PageantAgent:Wg}});var Ol=le((oF,Gg)=>{"use strict";var{kMaxLength:fI}=require("buffer"),{createInflate:dI,constants:{DEFLATE:pI,INFLATE:hI,Z_DEFAULT_CHUNK:gI,Z_DEFAULT_COMPRESSION:mI,Z_DEFAULT_MEMLEVEL:_I,Z_DEFAULT_STRATEGY:yI,Z_DEFAULT_WINDOWBITS:EI,Z_PARTIAL_FLUSH:AI}}=require("zlib"),bI=dI()._handle.constructor;function xI(){throw new Error("Should not get here")}c(xI,"processCallback");function II(t,e,r){let n=this._owner,i=new Error(t);i.errno=e,i.code=r,n._err=i}c(II,"zlibOnError");function Nl(t){t._handle&&(t._handle.close(),t._handle=null)}c(Nl,"_close");var za=class{static{c(this,"Zlib")}constructor(e){let r=EI,n=mI,i=_I,o=yI,s=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=gI,this._maxOutputLength=fI,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new bI(e),this._handle._owner=this,this._handle.onerror=II,this._handle.init(r,n,i,o,this._writeState,xI,s)}writeSync(e,r){let n=this._handle;if(!n)throw new Error("Invalid Zlib instance");let i=e.length,o=this._chunkSize-this._outOffset,s=0,a,u,l,d=0,p=this._writeState,g=this._outBuffer,h=this._outOffset,_=this._chunkSize;for(;;){if(n.writeSync(AI,e,s,i,g,h,o),this._err)throw this._err;a=p[0],u=p[1];let b=i-u,I=o-a;if(I>0){let w=h===0&&I===g.length?g:g.slice(h,h+I);if(h+=I,l?l.push===void 0?l=[l,w]:l.push(w):l=w,d+=w.byteLength,d>this._maxOutputLength)throw Nl(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(I!==0)throw new Error("have should not go down");if((a===0||h>=_)&&(o=_,h=0,g=Buffer.allocUnsafe(_)),a===0)s+=b,i=u;else break}if(this._outBuffer=g,this._outOffset=h,d===0&&(l=Buffer.alloc(0)),r)return l.totalLen=d,l;if(l.push===void 0)return l;let A=Buffer.allocUnsafe(d);for(let b=0,I=0;b<l.length;++b){let w=l[b];A.set(w,I),I+=w.length}return A}},Tl=class{static{c(this,"ZlibPacketWriter")}constructor(e){this.allocStart=0,this.allocStartKEX=0,this._protocol=e,this._zlib=new za(pI)}cleanup(){this._zlib&&Nl(this._zlib)}alloc(e,r){return Buffer.allocUnsafe(e)}finalize(e,r){if(this._protocol._kexinit===void 0||r){let n=this._zlib.writeSync(e,!0),i=this._protocol._cipher.allocPacket(n.totalLen);if(n.push===void 0)i.set(n,5);else for(let o=0,s=5;o<n.length;++o){let a=n[o];i.set(a,s),s+=a.length}return i}return e}},kl=class{static{c(this,"PacketWriter")}constructor(e){this.allocStart=5,this.allocStartKEX=5,this._protocol=e}cleanup(){}alloc(e,r){return this._protocol._kexinit===void 0||r?this._protocol._cipher.allocPacket(e):Buffer.allocUnsafe(e)}finalize(e,r){return e}},Cl=class{static{c(this,"ZlibPacketReader")}constructor(){this._zlib=new za(hI)}cleanup(){this._zlib&&Nl(this._zlib)}read(e){return this._zlib.writeSync(e,!1)}},Rl=class{static{c(this,"PacketReader")}cleanup(){}read(e){return e}};Gg.exports={PacketReader:Rl,PacketWriter:kl,ZlibPacketReader:Cl,ZlibPacketWriter:Tl}});var em=le((aF,Jg)=>{"use strict";var{bufferSlice:$l,bufferParser:O,doFatalError:Tt,sigSSHToASN1:Zg,writeUInt32BE:Yg}=Qr(),{CHANNEL_OPEN_FAILURE:vI,COMPAT:SI,MESSAGE:kt,TERMINAL_MODE:Xg}=An(),{parseKey:wI}=Hn(),PI=Array.from(Object.entries(Xg)).reduce((t,[e,r])=>({...t,[e]:r}),{});Jg.exports={[kt.DISCONNECT]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readString(!0),i=O.readString();if(O.clear(),i===void 0)return Tt(t,"Inbound: Malformed DISCONNECT packet");t._debug&&t._debug(`Inbound: Received DISCONNECT (${r}, "${n}")`);let o=t._handlers.DISCONNECT;o&&o(t,r,n)},[kt.IGNORE]:(t,e)=>{t._debug&&t._debug("Inbound: Received IGNORE")},[kt.UNIMPLEMENTED]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed UNIMPLEMENTED packet");t._debug&&t._debug(`Inbound: Received UNIMPLEMENTED (seqno ${r})`)},[kt.DEBUG]:(t,e)=>{O.init(e,1);let r=O.readBool(),n=O.readString(!0),i=O.readString();if(O.clear(),i===void 0)return Tt(t,"Inbound: Malformed DEBUG packet");t._debug&&t._debug("Inbound: Received DEBUG");let o=t._handlers.DEBUG;o&&o(t,r,n)},[kt.SERVICE_REQUEST]:(t,e)=>{O.init(e,1);let r=O.readString(!0);if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed SERVICE_REQUEST packet");t._debug&&t._debug(`Inbound: Received SERVICE_REQUEST (${r})`);let n=t._handlers.SERVICE_REQUEST;n&&n(t,r)},[kt.SERVICE_ACCEPT]:(t,e)=>{O.init(e,1);let r=O.readString(!0);if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed SERVICE_ACCEPT packet");t._debug&&t._debug(`Inbound: Received SERVICE_ACCEPT (${r})`);let n=t._handlers.SERVICE_ACCEPT;n&&n(t,r)},[kt.EXT_INFO]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n;if(r!==void 0){n=[];for(let o=0;o<r;++o){let s=O.readString(!0),a=O.readString();if(a!==void 0)if(s==="server-sig-algs"){let u=a.latin1Slice(0,a.length).split(",");n.push({name:s,algs:u});continue}else continue;n=void 0;break}}if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed EXT_INFO packet");t._debug&&t._debug("Inbound: Received EXT_INFO");let i=t._handlers.EXT_INFO;i&&i(t,n)},[kt.USERAUTH_REQUEST]:(t,e)=>{O.init(e,1);let r=O.readString(!0),n=O.readString(!0),i=O.readString(!0),o,s;switch(i){case"none":o=null;break;case"password":{let u=O.readBool();if(u!==void 0&&(o=O.readString(!0),o!==void 0&&u)){let l=O.readString(!0);l!==void 0?o={oldPassword:o,newPassword:l}:o=void 0}break}case"publickey":{let u=O.readBool();if(u!==void 0){let l=O.readString(!0),d=l,p=O.readString(),g;switch(l){case"rsa-sha2-256":d="ssh-rsa",g="sha256";break;case"rsa-sha2-512":d="ssh-rsa",g="sha512";break}if(u){let h=O.pos(),_=O.readString();if(_!==void 0&&(_.length>4+l.length+4&&_.utf8Slice(4,4+l.length)===l&&(_=$l(_,4+l.length+4)),_=Zg(_,d),_)){let A=t._kex.sessionID,b=Buffer.allocUnsafe(4+A.length+h);Yg(b,A.length,0),b.set(A,4),b.set(new Uint8Array(e.buffer,e.byteOffset,h),4+A.length),o={keyAlgo:d,key:p,signature:_,blob:b,hashAlgo:g}}}else o={keyAlgo:d,key:p,hashAlgo:g},s="publickey -- check"}break}case"hostbased":{let u=O.readString(!0),l=u,d=O.readString(),p=O.readString(!0),g=O.readString(!0),h;switch(u){case"rsa-sha2-256":l="ssh-rsa",h="sha256";break;case"rsa-sha2-512":l="ssh-rsa",h="sha512";break}let _=O.pos(),A=O.readString();if(A!==void 0&&(A.length>4+u.length+4&&A.utf8Slice(4,4+u.length)===u&&(A=$l(A,4+u.length+4)),A=Zg(A,l),A!==void 0)){let b=t._kex.sessionID,I=Buffer.allocUnsafe(4+b.length+_);Yg(I,b.length,0),I.set(b,4),I.set(new Uint8Array(e.buffer,e.byteOffset,_),4+b.length),o={keyAlgo:l,key:d,signature:A,blob:I,localHostname:p,localUsername:g,hashAlgo:h}}break}case"keyboard-interactive":O.skipString(),o=O.readList();break;default:i!==void 0&&(o=O.readRaw())}if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed USERAUTH_REQUEST packet");s===void 0&&(s=i),t._authsQueue.push(i),t._debug&&t._debug(`Inbound: Received USERAUTH_REQUEST (${s})`);let a=t._handlers.USERAUTH_REQUEST;a&&a(t,r,n,i,o)},[kt.USERAUTH_FAILURE]:(t,e)=>{O.init(e,1);let r=O.readList(),n=O.readBool();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_FAILURE packet");t._debug&&t._debug(`Inbound: Received USERAUTH_FAILURE (${r})`),t._authsQueue.shift();let i=t._handlers.USERAUTH_FAILURE;i&&i(t,r,n)},[kt.USERAUTH_SUCCESS]:(t,e)=>{t._debug&&t._debug("Inbound: Received USERAUTH_SUCCESS"),t._authsQueue.shift();let r=t._handlers.USERAUTH_SUCCESS;r&&r(t)},[kt.USERAUTH_BANNER]:(t,e)=>{O.init(e,1);let r=O.readString(!0),n=O.readString();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_BANNER packet");t._debug&&t._debug("Inbound: Received USERAUTH_BANNER");let i=t._handlers.USERAUTH_BANNER;i&&i(t,r)},60:(t,e)=>{if(!t._authsQueue.length){t._debug&&t._debug("Inbound: Received payload type 60 without auth");return}switch(t._authsQueue[0]){case"password":{O.init(e,1);let r=O.readString(!0),n=O.readString();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");t._debug&&t._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let i=t._handlers.USERAUTH_PASSWD_CHANGEREQ;i&&i(t,r);break}case"publickey":{O.init(e,1);let r=O.readString(!0),n=O.readString();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_PK_OK packet");t._debug&&t._debug("Inbound: Received USERAUTH_PK_OK"),t._authsQueue.shift();let i=t._handlers.USERAUTH_PK_OK;i&&i(t,r,n);break}case"keyboard-interactive":{O.init(e,1);let r=O.readString(!0),n=O.readString(!0);O.readString();let i=O.readUInt32BE(),o;if(i!==void 0){o=new Array(i);let a;for(a=0;a<i;++a){let u=O.readString(!0),l=O.readBool();if(l===void 0)break;o[a]={prompt:u,echo:l}}a!==i&&(o=void 0)}if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");t._debug&&t._debug("Inbound: Received USERAUTH_INFO_REQUEST");let s=t._handlers.USERAUTH_INFO_REQUEST;s&&s(t,r,n,o);break}default:t._debug&&t._debug("Inbound: Received unexpected payload type 60")}},61:(t,e)=>{if(!t._authsQueue.length){t._debug&&t._debug("Inbound: Received payload type 61 without auth");return}if(t._authsQueue[0]!=="keyboard-interactive")return Tt(t,"Inbound: Received unexpected payload type 61");O.init(e,1);let r=O.readUInt32BE(),n;if(r!==void 0){n=new Array(r);let o;for(o=0;o<r;++o){let s=O.readString(!0);if(s===void 0)break;n[o]=s}o!==r&&(n=void 0)}if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");t._debug&&t._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let i=t._handlers.USERAUTH_INFO_RESPONSE;i&&i(t,n)},[kt.GLOBAL_REQUEST]:(t,e)=>{O.init(e,1);let r=O.readString(!0),n=O.readBool(),i;if(n!==void 0)switch(r){case"tcpip-forward":case"cancel-tcpip-forward":{let s=O.readString(!0),a=O.readUInt32BE();a!==void 0&&(i={bindAddr:s,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let s=O.readString(!0);s!==void 0&&(i={socketPath:s});break}case"no-more-sessions@openssh.com":i=null;break;case"hostkeys-00@openssh.com":{for(i=[];O.avail()>0;){let s=O.readString();if(s===void 0){i=void 0;break}let a=wI(s);a instanceof Error||i.push(a)}break}default:i=O.readRaw()}if(O.clear(),i===void 0)return Tt(t,"Inbound: Malformed GLOBAL_REQUEST packet");t._debug&&t._debug(`Inbound: GLOBAL_REQUEST (${r})`);let o=t._handlers.GLOBAL_REQUEST;o?o(t,r,n,i):t.requestFailure()},[kt.REQUEST_SUCCESS]:(t,e)=>{let r=e.length>1?$l(e,1):null;t._debug&&t._debug("Inbound: REQUEST_SUCCESS");let n=t._handlers.REQUEST_SUCCESS;n&&n(t,r)},[kt.REQUEST_FAILURE]:(t,e)=>{t._debug&&t._debug("Inbound: Received REQUEST_FAILURE");let r=t._handlers.REQUEST_FAILURE;r&&r(t)},[kt.CHANNEL_OPEN]:(t,e)=>{O.init(e,1);let r=O.readString(!0),n=O.readUInt32BE(),i=O.readUInt32BE(),o=O.readUInt32BE(),s;switch(r){case"forwarded-tcpip":case"direct-tcpip":{let u=O.readString(!0),l=O.readUInt32BE(),d=O.readString(!0),p=O.readUInt32BE();p!==void 0&&(s={type:r,sender:n,window:i,packetSize:o,data:{destIP:u,destPort:l,srcIP:d,srcPort:p}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let u=O.readString(!0);u!==void 0&&(s={type:r,sender:n,window:i,packetSize:o,data:{socketPath:u}});break}case"x11":{let u=O.readString(!0),l=O.readUInt32BE();l!==void 0&&(s={type:r,sender:n,window:i,packetSize:o,data:{srcIP:u,srcPort:l}});break}default:s={type:r,sender:n,window:i,packetSize:o,data:{}}}if(O.clear(),s===void 0)return Tt(t,"Inbound: Malformed CHANNEL_OPEN packet");t._debug&&t._debug(`Inbound: CHANNEL_OPEN (s:${n}, ${r})`);let a=t._handlers.CHANNEL_OPEN;a?a(t,s):t.channelOpenFail(s.sender,vI.ADMINISTRATIVELY_PROHIBITED,"","")},[kt.CHANNEL_OPEN_CONFIRMATION]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readUInt32BE(),i=O.readUInt32BE(),o=O.readUInt32BE(),s=O.avail()?O.readRaw():void 0;if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");t._debug&&t._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${r}, s:${n})`);let a=t._handlers.CHANNEL_OPEN_CONFIRMATION;a&&a(t,{recipient:r,sender:n,window:i,packetSize:o,data:s})},[kt.CHANNEL_OPEN_FAILURE]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readUInt32BE(),i=O.readString(!0),o=O.readString();if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");t._debug&&t._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${r})`);let s=t._handlers.CHANNEL_OPEN_FAILURE;s&&s(t,r,n,i)},[kt.CHANNEL_WINDOW_ADJUST]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readUInt32BE();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");t._debug&&t._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${r}, ${n})`);let i=t._handlers.CHANNEL_WINDOW_ADJUST;i&&i(t,r,n)},[kt.CHANNEL_DATA]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readString();if(O.clear(),n===void 0)return Tt(t,"Inbound: Malformed CHANNEL_DATA packet");t._debug&&t._debug(`Inbound: CHANNEL_DATA (r:${r}, ${n.length})`);let i=t._handlers.CHANNEL_DATA;i&&i(t,r,n)},[kt.CHANNEL_EXTENDED_DATA]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readUInt32BE(),i=O.readString();if(O.clear(),i===void 0)return Tt(t,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");t._debug&&t._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${r}, ${i.length})`);let o=t._handlers.CHANNEL_EXTENDED_DATA;o&&o(t,r,i,n)},[kt.CHANNEL_EOF]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed CHANNEL_EOF packet");t._debug&&t._debug(`Inbound: CHANNEL_EOF (r:${r})`);let n=t._handlers.CHANNEL_EOF;n&&n(t,r)},[kt.CHANNEL_CLOSE]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed CHANNEL_CLOSE packet");t._debug&&t._debug(`Inbound: CHANNEL_CLOSE (r:${r})`);let n=t._handlers.CHANNEL_CLOSE;n&&n(t,r)},[kt.CHANNEL_REQUEST]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE(),n=O.readString(!0),i=O.readBool(),o;if(i!==void 0)switch(n){case"exit-status":o=O.readUInt32BE(),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"exit-signal":{let a,u;if(t._compatFlags&SI.OLD_EXIT){let d=O.readUInt32BE();switch(d){case 1:a="HUP";break;case 2:a="INT";break;case 3:a="QUIT";break;case 6:a="ABRT";break;case 9:a="KILL";break;case 14:a="ALRM";break;case 15:a="TERM";break;default:d!==void 0&&(a=`UNKNOWN (${d})`)}u=!1}else a=O.readString(!0),u=O.readBool(),u===void 0&&(a=void 0);let l=O.readString(!0);O.skipString()!==void 0&&(o={signal:a,coreDumped:u,errorMessage:l}),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${a})`);break}case"pty-req":{let a=O.readString(!0),u=O.readUInt32BE(),l=O.readUInt32BE(),d=O.readUInt32BE(),p=O.readUInt32BE(),g=O.readString();if(g!==void 0){O.init(g,1);let h={};for(;O.avail();){let _=O.readByte();if(_===Xg.TTY_OP_END)break;let A=PI[_],b=O.readUInt32BE();if(_===void 0||A===void 0||b===void 0){h=void 0;break}h[A]=b}h!==void 0&&(o={term:a,cols:u,rows:l,width:d,height:p,modes:h})}t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break}case"window-change":{let a=O.readUInt32BE(),u=O.readUInt32BE(),l=O.readUInt32BE(),d=O.readUInt32BE();d!==void 0&&(o={cols:a,rows:u,width:l,height:d}),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break}case"x11-req":{let a=O.readBool(),u=O.readString(!0),l=O.readString(),d=O.readUInt32BE();d!==void 0&&(o={single:a,protocol:u,cookie:l,screen:d}),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break}case"env":{let a=O.readString(!0),u=O.readString(!0);u!==void 0&&(o={name:a,value:u}),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${a}=${u})`);break}case"shell":o=null,t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break;case"exec":o=O.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"subsystem":o=O.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"signal":o=O.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"xon-xoff":o=O.readBool(),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"auth-agent-req@openssh.com":o=null,t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`);break;default:o=O.avail()?O.readRaw():null,t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`)}if(O.clear(),o===void 0)return Tt(t,"Inbound: Malformed CHANNEL_REQUEST packet");let s=t._handlers.CHANNEL_REQUEST;s&&s(t,r,n,i,o)},[kt.CHANNEL_SUCCESS]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed CHANNEL_SUCCESS packet");t._debug&&t._debug(`Inbound: CHANNEL_SUCCESS (r:${r})`);let n=t._handlers.CHANNEL_SUCCESS;n&&n(t,r)},[kt.CHANNEL_FAILURE]:(t,e)=>{O.init(e,1);let r=O.readUInt32BE();if(O.clear(),r===void 0)return Tt(t,"Inbound: Malformed CHANNEL_FAILURE packet");t._debug&&t._debug(`Inbound: CHANNEL_FAILURE (r:${r})`);let n=t._handlers.CHANNEL_FAILURE;n&&n(t,r)}}});var Ma=le((cF,tm)=>{"use strict";var Dl=new Array(256);[Fa().HANDLERS,em()].forEach(t=>{for(let[e,r]of Object.entries(t))e=+e,isFinite(e)&&e>=0&&e<Dl.length&&(Dl[e]=r)});tm.exports=Dl});var Fa=le((lF,fm)=>{"use strict";var{createDiffieHellman:TI,createDiffieHellmanGroup:kI,createECDH:CI,createHash:Ul,createPublicKey:RI,diffieHellman:NI,generateKeyPairSync:OI,randomFillSync:$I}=require("crypto"),{Ber:rm}=Ko(),{COMPAT:Ll,curve25519Supported:DI,DEFAULT_KEX:nm,DEFAULT_SERVER_HOST_KEY:im,DEFAULT_CIPHER:Ha,DEFAULT_MAC:ja,DEFAULT_COMPRESSION:Wa,DISCONNECT_REASON:st,MESSAGE:wt}=An(),{CIPHER_INFO:to,createCipher:BI,createDecipher:UI,MAC_INFO:om}=zn(),{parseDERKey:LI}=Hn(),{bufferFill:zI,bufferParser:it,convertSignature:MI,doFatalError:at,FastBuffer:FI,sigSSHToASN1:HI,writeUInt32BE:ur}=Qr(),{PacketReader:sm,PacketWriter:am,ZlibPacketReader:qa,ZlibPacketWriter:Qa}=Ol(),Ji,jI=2048,WI=8192,qI=Buffer.alloc(0);function cm(t){let e;if(t._compatFlags&Ll.BAD_DHGEX){let r=t._offer.lists.kex,n=r.array,i=!1;for(let o=0;o<n.length;++o)n[o].includes("group-exchange")&&(i||(i=!0,n=n.slice()),n.splice(o--,1));if(i){let o=17+t._offer.totalSize+1+4,s=Buffer.from(n.join(","));o-=r.buffer.length-s.length;let a=t._offer.lists.all,u=new Uint8Array(a.buffer,a.byteOffset+4+r.buffer.length,a.length-(4+r.buffer.length));e=Buffer.allocUnsafe(o),ur(e,s.length,17),e.set(s,21),e.set(u,21+s.length)}}e===void 0&&(e=Buffer.allocUnsafe(17+t._offer.totalSize+1+4),t._offer.copyAllTo(e,17)),t._debug&&t._debug("Outbound: Sending KEXINIT"),e[0]=wt.KEXINIT,$I(e,1,16),zI(e,0,e.length-5),t._kexinit=e,t._packetRW.write.allocStart=0;{let r=t._packetRW.write.allocStartKEX,n=t._packetRW.write.alloc(e.length,!0);n.set(e,r),t._cipher.encrypt(t._packetRW.write.finalize(n,!0))}}c(cm,"kexinit");function um(t,e){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}};if(it.init(e,17),(r.kex=it.readList())===void 0||(r.serverHostKey=it.readList())===void 0||(r.cs.cipher=it.readList())===void 0||(r.sc.cipher=it.readList())===void 0||(r.cs.mac=it.readList())===void 0||(r.sc.mac=it.readList())===void 0||(r.cs.compress=it.readList())===void 0||(r.sc.compress=it.readList())===void 0||(r.cs.lang=it.readList())===void 0||(r.sc.lang=it.readList())===void 0)return it.clear(),at(t,"Received malformed KEXINIT","handshake",st.KEY_EXCHANGE_FAILED);let n=it.pos(),i=n<e.length&&e[n]===1;it.clear();let o=t._offer,s=r,a=o.lists.kex.array;if(t._compatFlags&Ll.BAD_DHGEX){let $=!1;for(let X=0;X<a.length;++X)a[X].indexOf("group-exchange")!==-1&&($||($=!0,a=a.slice()),a.splice(X--,1))}let u,l,d,p=t._debug;p&&p("Inbound: Handshake in progress"),p&&p(`Handshake: (local) KEX method: ${a}`),p&&p(`Handshake: (remote) KEX method: ${s.kex}`);let g;if(t._server?(l=a,u=s.kex,g=u.indexOf("ext-info-c")!==-1):(l=s.kex,u=a,g=l.indexOf("ext-info-s")!==-1),t._strictMode===void 0&&(t._server?t._strictMode=u.indexOf("kex-strict-c-v00@openssh.com")!==-1:t._strictMode=l.indexOf("kex-strict-s-v00@openssh.com")!==-1,t._strictMode&&(p&&p("Handshake: strict KEX mode enabled"),t._decipher.inSeqno!==1)))return p&&p("Handshake: KEXINIT not first packet in strict KEX mode"),at(t,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",st.KEY_EXCHANGE_FAILED);for(d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: no matching key exchange algorithm"),at(t,"Handshake failed: no matching key exchange algorithm","handshake",st.KEY_EXCHANGE_FAILED);r.kex=u[d],p&&p(`Handshake: KEX algorithm: ${u[d]}`),i&&(!s.kex.length||u[d]!==s.kex[0])&&(t._skipNextInboundPacket=!0);let h=o.lists.serverHostKey.array;for(p&&p(`Handshake: (local) Host key format: ${h}`),p&&p(`Handshake: (remote) Host key format: ${s.serverHostKey}`),t._server?(l=h,u=s.serverHostKey):(l=s.serverHostKey,u=h),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching host key format"),at(t,"Handshake failed: no matching host key format","handshake",st.KEY_EXCHANGE_FAILED);r.serverHostKey=u[d],p&&p(`Handshake: Host key format: ${u[d]}`);let _=o.lists.cs.cipher.array;for(p&&p(`Handshake: (local) C->S cipher: ${_}`),p&&p(`Handshake: (remote) C->S cipher: ${s.cs.cipher}`),t._server?(l=_,u=s.cs.cipher):(l=s.cs.cipher,u=_),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching C->S cipher"),at(t,"Handshake failed: no matching C->S cipher","handshake",st.KEY_EXCHANGE_FAILED);r.cs.cipher=u[d],p&&p(`Handshake: C->S Cipher: ${u[d]}`);let A=o.lists.sc.cipher.array;for(p&&p(`Handshake: (local) S->C cipher: ${A}`),p&&p(`Handshake: (remote) S->C cipher: ${s.sc.cipher}`),t._server?(l=A,u=s.sc.cipher):(l=s.sc.cipher,u=A),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching S->C cipher"),at(t,"Handshake failed: no matching S->C cipher","handshake",st.KEY_EXCHANGE_FAILED);r.sc.cipher=u[d],p&&p(`Handshake: S->C cipher: ${u[d]}`);let b=o.lists.cs.mac.array;if(p&&p(`Handshake: (local) C->S MAC: ${b}`),p&&p(`Handshake: (remote) C->S MAC: ${s.cs.mac}`),to[r.cs.cipher].authLen>0)r.cs.mac="",p&&p("Handshake: C->S MAC: <implicit>");else{for(t._server?(l=b,u=s.cs.mac):(l=s.cs.mac,u=b),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching C->S MAC"),at(t,"Handshake failed: no matching C->S MAC","handshake",st.KEY_EXCHANGE_FAILED);r.cs.mac=u[d],p&&p(`Handshake: C->S MAC: ${u[d]}`)}let I=o.lists.sc.mac.array;if(p&&p(`Handshake: (local) S->C MAC: ${I}`),p&&p(`Handshake: (remote) S->C MAC: ${s.sc.mac}`),to[r.sc.cipher].authLen>0)r.sc.mac="",p&&p("Handshake: S->C MAC: <implicit>");else{for(t._server?(l=I,u=s.sc.mac):(l=s.sc.mac,u=I),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching S->C MAC"),at(t,"Handshake failed: no matching S->C MAC","handshake",st.KEY_EXCHANGE_FAILED);r.sc.mac=u[d],p&&p(`Handshake: S->C MAC: ${u[d]}`)}let w=o.lists.cs.compress.array;for(p&&p(`Handshake: (local) C->S compression: ${w}`),p&&p(`Handshake: (remote) C->S compression: ${s.cs.compress}`),t._server?(l=w,u=s.cs.compress):(l=s.cs.compress,u=w),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching C->S compression"),at(t,"Handshake failed: no matching C->S compression","handshake",st.KEY_EXCHANGE_FAILED);r.cs.compress=u[d],p&&p(`Handshake: C->S compression: ${u[d]}`);let H=o.lists.sc.compress.array;for(p&&p(`Handshake: (local) S->C compression: ${H}`),p&&p(`Handshake: (remote) S->C compression: ${s.sc.compress}`),t._server?(l=H,u=s.sc.compress):(l=s.sc.compress,u=H),d=0;d<u.length&&l.indexOf(u[d])===-1;++d);if(d===u.length)return p&&p("Handshake: No matching S->C compression"),at(t,"Handshake failed: no matching S->C compression","handshake",st.KEY_EXCHANGE_FAILED);r.sc.compress=u[d],p&&p(`Handshake: S->C compression: ${u[d]}`),r.cs.lang="",r.sc.lang="",t._kex&&(t._kexinit||cm(t),t._decipher._onPayload=lm.bind(t,{firstPacket:!1})),t._kex=QI(r,t,e),t._kex.remoteExtInfoEnabled=g,t._kex.start()}c(um,"handleKexInit");var QI=(()=>{function t(s){let a=0,u=s.length;for(;s[a]===0;)++a,--u;let l;return s[a]&128?(l=Buffer.allocUnsafe(1+u),l[0]=0,s.copy(l,1,a),s=l):u!==s.length&&(l=Buffer.allocUnsafe(u),s.copy(l,0,a),s=l),s}c(t,"convertToMpint");class e{static{c(this,"KeyExchange")}constructor(a,u,l){this._protocol=u,this.sessionID=u._kex?u._kex.sessionID:void 0,this.negotiated=a,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=u._kexinit,this._remoteKexinit=l,this._identRaw=u._identRaw,this._remoteIdentRaw=u._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(a){if(this._finished)return!1;this._finished=!0;let u=this._protocol._server,l=this.negotiated,d=this.convertPublicKey(this._dhData),p=this.computeSecret(this._dhData);if(p instanceof Error)return p.message=`Error while computing DH secret (${this.type}): ${p.message}`,p.level="handshake",at(this._protocol,p,st.KEY_EXCHANGE_FAILED);let g=Ul(this.hashName);sn(g,u?this._remoteIdentRaw:this._identRaw),sn(g,u?this._identRaw:this._remoteIdentRaw),sn(g,u?this._remoteKexinit:this._kexinit),sn(g,u?this._kexinit:this._remoteKexinit);let h=u?this._hostKey.getPublicSSH():this._hostKey;if(sn(g,h),this.type==="groupex"){let H=this.getDHParams(),$=Buffer.allocUnsafe(4);ur($,this._minBits,0),g.update($),ur($,this._prefBits,0),g.update($),ur($,this._maxBits,0),g.update($),sn(g,H.prime),sn(g,H.generator)}sn(g,u?d:this.getPublicKey());let _=u?this.getPublicKey():d;sn(g,_),sn(g,p);let A=g.digest();if(u){let H;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":H="sha256";break;case"rsa-sha2-512":H="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let $=this._hostKey.sign(A,H);if($ instanceof Error)return at(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${$.message}`,"handshake",st.KEY_EXCHANGE_FAILED);if($=MI($,this._hostKey.type),$===!1)return at(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",st.KEY_EXCHANGE_FAILED);let X=this.negotiated.serverHostKey,Z=Buffer.byteLength(X),Y=4+Z+4+$.length,P=this._protocol._packetRW.write.allocStartKEX,k=this._protocol._packetRW.write.alloc(5+h.length+4+_.length+4+Y,!0);if(k[P]=wt.KEXDH_REPLY,ur(k,h.length,++P),k.set(h,P+=4),ur(k,_.length,P+=h.length),k.set(_,P+=4),ur(k,Y,P+=_.length),ur(k,Z,P+=4),k.utf8Write(X,P+=4,Z),ur(k,$.length,P+=Z),k.set($,P+=4),this._protocol._debug){let M;switch(this.type){case"group":M="KEXDH_REPLY";break;case"groupex":M="KEXDH_GEX_REPLY";break;default:M="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${M}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(k,!0))}else{it.init(this._sig,0);let H=it.readString(!0);if(!H)return at(this._protocol,"Malformed packet while reading signature","handshake",st.KEY_EXCHANGE_FAILED);if(H!==l.serverHostKey)return at(this._protocol,`Wrong signature type: ${H}, expected: ${l.serverHostKey}`,"handshake",st.KEY_EXCHANGE_FAILED);let $=it.readString();if(it.clear(),$===void 0)return at(this._protocol,"Malformed packet while reading signature","handshake",st.KEY_EXCHANGE_FAILED);if(!($=HI($,H)))return at(this._protocol,"Malformed signature","handshake",st.KEY_EXCHANGE_FAILED);let X;{it.init(this._hostKey,0);let P=it.readString(!0),k=this._hostKey.slice(it.pos());if(it.clear(),X=LI(k,P),X instanceof Error)return X.level="handshake",at(this._protocol,X,st.KEY_EXCHANGE_FAILED)}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("Verifying signature ...");let Y=X.verify(A,$,Z);if(Y!==!0)return Y instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${Y.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),at(this._protocol,"Handshake failed: signature verification failed","handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(u||!a)&&Va(this);let b,I,w=c(H=>{if(b)return Va(this),b.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=BI(b),this._protocol._packetRW.write=I,b=void 0,I=void 0,this._protocol._onHandshakeComplete(l),!1;this.sessionID||(this.sessionID=A);{let G=Buffer.allocUnsafe(4+p.length);ur(G,p.length,0),G.set(p,4),p=G}let $=to[l.cs.cipher],X=to[l.sc.cipher],Z=eo($.ivLen,this.hashName,p,A,this.sessionID,"A"),Y=eo(X.ivLen,this.hashName,p,A,this.sessionID,"B"),P=eo($.keyLen,this.hashName,p,A,this.sessionID,"C"),k=eo(X.keyLen,this.hashName,p,A,this.sessionID,"D"),M,L;$.authLen||(M=om[l.cs.mac],L=eo(M.len,this.hashName,p,A,this.sessionID,"E"));let T,F;X.authLen||(T=om[l.sc.mac],F=eo(T.len,this.hashName,p,A,this.sessionID,"F"));let j={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:u?$:X,decipherIV:u?Z:Y,decipherKey:u?P:k,macInfo:u?M:T,macKey:u?L:F},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:u?X:$,cipherIV:u?Y:Z,cipherKey:u?k:P,macInfo:u?T:M,macKey:u?F:L}};this._protocol._decipher.free(),b=j,this._protocol._decipher=UI(j);let B={read:void 0,write:void 0};switch(l.cs.compress){case"zlib":u?B.read=new qa:B.write=new Qa(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){u?B.read=new qa:B.write=new Qa(this._protocol);break}default:u?B.read=new sm:B.write=new am(this._protocol)}switch(l.sc.compress){case"zlib":u?B.write=new Qa(this._protocol):B.read=new qa;break;case"zlib@openssh.com":if(this._protocol._authenticated){u?B.write=new Qa(this._protocol):B.read=new qa;break}default:u?B.write=new am(this._protocol):B.read=new sm}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=B.read,I=B.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,H?!1:w()},"completeHandshake");if((u||a)&&(this.finish=w),!u)return w(a)}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 a=this.getPublicKey(),u=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[u]=wt.KEXDH_INIT,ur(l,a.length,++u),l.set(a,u+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}getPublicKey(){this.generateKeys();let a=this._public;if(a)return this.convertPublicKey(a)}convertPublicKey(a){let u,l=0,d=a.length;for(;a[l]===0;)++l,--d;return a[l]&128?(u=Buffer.allocUnsafe(1+d),u[0]=0,a.copy(u,1,l),u):(d!==a.length&&(u=Buffer.allocUnsafe(d),a.copy(u,0,l),a=u),a)}computeSecret(a){this.generateKeys();try{return t(this._dh.computeSecret(a))}catch(u){return u}}parse(a){let u=a[0];switch(this._step){case 1:if(this._protocol._server){if(u!==wt.KEXDH_INIT)return at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_INIT}`,"handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),it.init(a,1);let l=it.readString();if(it.clear(),l===void 0)return at(this._protocol,"Received malformed KEX*_INIT","handshake",st.KEY_EXCHANGE_FAILED);this._dhData=l;let d=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(d)&&(d=d[0]),this._hostKey=d,this.finish()}else{if(u!==wt.KEXDH_REPLY)return at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_REPLY}`,"handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),it.init(a,1);let l,d,p;if((l=it.readString())===void 0||(d=it.readString())===void 0||(p=it.readString())===void 0)return it.clear(),at(this._protocol,"Received malformed KEX*_REPLY","handshake",st.KEY_EXCHANGE_FAILED);it.clear(),it.init(l,0);let g=it.readString(!0);if(it.clear(),g===void 0)return at(this._protocol,"Received malformed host public key","handshake",st.KEY_EXCHANGE_FAILED);if(g!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(g==="ssh-rsa")break;default:return at(this._protocol,"Host key does not match negotiated type","handshake",st.KEY_EXCHANGE_FAILED)}this._hostKey=l,this._dhData=d,this._sig=p;let h=!1,_;if(this._protocol._hostVerifier===void 0?(_=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):_=this._protocol._hostVerifier(l,A=>{if(!h){if(h=!0,A===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),at(this._protocol,"Host denied (verification failed)","handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():Va(this)}}),_===void 0){++this._step;return}if(h=!0,_===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),at(this._protocol,"Host denied (verification failed)","handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,Va(this)}++this._step;break;case 2:return u!==wt.NEWKEYS?at(this._protocol,`Received packet ${u} instead of ${wt.NEWKEYS}`,"handshake",st.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 at(this._protocol,`Received unexpected packet ${u} after NEWKEYS`,"handshake",st.KEY_EXCHANGE_FAILED)}}}class r extends e{static{c(this,"Curve25519Exchange")}constructor(a,...u){super(...u),this.type="25519",this.hashName=a,this._keys=null}generateKeys(){this._keys||(this._keys=OI("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(a){let u,l=0,d=a.length;for(;a[l]===0;)++l,--d;return a.length===32||d!==a.length&&(u=Buffer.allocUnsafe(d),a.copy(u,0,l),a=u),a}computeSecret(a){this.generateKeys();try{let u=new rm.Writer;return u.startSequence(),u.startSequence(),u.writeOID("1.3.101.110"),u.endSequence(),u.startSequence(rm.BitString),u.writeByte(0),u._ensure(a.length),a.copy(u._buf,u._offset,0,a.length),u._offset+=a.length,u.endSequence(),u.endSequence(),t(NI({privateKey:this._keys.privateKey,publicKey:RI({key:u.buffer,type:"spki",format:"der"})}))}catch(u){return u}}}class n extends e{static{c(this,"ECDHExchange")}constructor(a,u,...l){super(...l),this.type="ecdh",this.curveName=a,this.hashName=u}generateKeys(){this._dh||(this._dh=CI(this.curveName),this._public=this._dh.generateKeys())}}class i extends e{static{c(this,"DHGroupExchange")}constructor(a,...u){super(...u),this.type="groupex",this.hashName=a,this._prime=null,this._generator=null,this._minBits=jI,this._prefBits=VI(this.negotiated),this._protocol._compatFlags&Ll.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=WI}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let a=this._protocol._packetRW.write.allocStartKEX,u=this._protocol._packetRW.write.alloc(13,!0);u[a]=wt.KEXDH_GEX_REQUEST,ur(u,this._minBits,++a),ur(u,this._prefBits,a+=4),ur(u,this._maxBits,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(u,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=TI(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(a,u){if(!Buffer.isBuffer(a))throw new Error("Invalid prime value");if(!Buffer.isBuffer(u))throw new Error("Invalid generator value");this._prime=a,this._generator=u}getDHParams(){if(this._dh)return{prime:t(this._dh.getPrime()),generator:t(this._dh.getGenerator())}}parse(a){let u=a[0];switch(this._step){case 1:{if(this._protocol._server)return u!==wt.KEXDH_GEX_REQUEST?at(this._protocol,`Received packet ${u} instead of `+wt.KEXDH_GEX_REQUEST,"handshake",st.KEY_EXCHANGE_FAILED):at(this._protocol,"Group exchange not implemented for server","handshake",st.KEY_EXCHANGE_FAILED);if(u!==wt.KEXDH_GEX_GROUP)return at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_GEX_GROUP}`,"handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),it.init(a,1);let l,d;if((l=it.readString())===void 0||(d=it.readString())===void 0)return it.clear(),at(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",st.KEY_EXCHANGE_FAILED);it.clear(),this.setDHParams(l,d),this.generateKeys();let p=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let g=this._protocol._packetRW.write.allocStartKEX,h=this._protocol._packetRW.write.alloc(5+p.length,!0);h[g]=wt.KEXDH_GEX_INIT,ur(h,p.length,++g),h.set(p,g+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(h,!0)),++this._step;break}case 2:if(this._protocol._server)return u!==wt.KEXDH_GEX_INIT?at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_GEX_INIT}`,"handshake",st.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),at(this._protocol,"Group exchange not implemented for server","handshake",st.KEY_EXCHANGE_FAILED));if(u!==wt.KEXDH_GEX_REPLY)return at(this._protocol,`Received packet ${u} instead of ${wt.KEXDH_GEX_REPLY}`,"handshake",st.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,a[0]=wt.KEXDH_REPLY,this.parse=e.prototype.parse,this.parse(a)}}}class o extends e{static{c(this,"DHExchange")}constructor(a,u,...l){super(...l),this.type="group",this.groupName=a,this.hashName=u}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let a=this.getPublicKey(),u=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[u]=wt.KEXDH_INIT,ur(l,a.length,++u),l.set(a,u+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}generateKeys(){this._dh||(this._dh=kI(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:t(this._dh.getPrime()),generator:t(this._dh.getGenerator())}}}return(s,...a)=>{if(typeof s!="object"||s===null)throw new Error("Invalid negotiated argument");let u=s.kex;if(typeof u=="string"){switch(a=[s,...a],u){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!DI)break;return new r("sha256",...a);case"ecdh-sha2-nistp256":return new n("prime256v1","sha256",...a);case"ecdh-sha2-nistp384":return new n("secp384r1","sha384",...a);case"ecdh-sha2-nistp521":return new n("secp521r1","sha512",...a);case"diffie-hellman-group1-sha1":return new o("modp2","sha1",...a);case"diffie-hellman-group14-sha1":return new o("modp14","sha1",...a);case"diffie-hellman-group14-sha256":return new o("modp14","sha256",...a);case"diffie-hellman-group15-sha512":return new o("modp15","sha512",...a);case"diffie-hellman-group16-sha512":return new o("modp16","sha512",...a);case"diffie-hellman-group17-sha512":return new o("modp17","sha512",...a);case"diffie-hellman-group18-sha512":return new o("modp18","sha512",...a);case"diffie-hellman-group-exchange-sha1":return new i("sha1",...a);case"diffie-hellman-group-exchange-sha256":return new i("sha256",...a)}throw new Error(`Unsupported key exchange algorithm: ${u}`)}throw new Error(`Invalid key exchange type: ${u}`)}})(),Bl=(()=>{let t=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{static{c(this,"KexInit")}constructor(r){if(typeof r!="object"||r===null)throw new TypeError("Argument must be an object");let n={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 a of t){let u,l,d,p;if(typeof a=="string")u=n,l=r[a],d=p=a;else{let h=a[0];u=n[h],p=a[1],l=r[h][p],d=`${h}.${p}`}let g={array:void 0,buffer:void 0};if(Buffer.isBuffer(l))g.array=(""+l).split(","),g.buffer=l,i+=4+l.length;else{if(typeof l=="string"&&(l=l.split(",")),Array.isArray(l))g.array=l,g.buffer=Buffer.from(l.join(","));else throw new TypeError(`Invalid \`${d}\` type: ${typeof l}`);i+=4+g.buffer.length}u[p]=g}let o=Buffer.allocUnsafe(i);n.all=o;let s=0;for(let a of t){let u;typeof a=="string"?u=n[a].buffer:u=n[a[0]][a[1]].buffer,s=ur(o,u.length,s),o.set(u,s),s+=u.length}this.totalSize=i,this.lists=n}copyAllTo(r,n){let i=this.lists.all;if(typeof n!="number")throw new TypeError(`Invalid offset value: ${typeof n}`);if(r.length-n<i.length)throw new Error("Insufficient space to copy list");return r.set(i,n),i.length}}})(),sn=(()=>{let t=Buffer.allocUnsafe(4);return(e,r)=>{ur(t,r.length,0),e.update(t),e.update(r)}})();function eo(t,e,r,n,i,o){let s;if(t){let a=Ul(e).update(r).update(n).update(o).update(i).digest();for(;a.length<t;){let u=Ul(e).update(r).update(n).update(a).digest(),l=Buffer.allocUnsafe(a.length+u.length);l.set(a,0),l.set(u,a.length),a=l}a.length===t?s=a:s=new FI(a.buffer,a.byteOffset,t)}else s=qI;return s}c(eo,"generateKEXVal");function lm(t,e){if(e.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}e=this._packetRW.read.read(e);let r=e[0];if(!this._strictMode)switch(r){case wt.IGNORE:case wt.UNIMPLEMENTED:case wt.DEBUG:return Ji||(Ji=Ma()),Ji[r](this,e)}switch(r){case wt.DISCONNECT:return Ji||(Ji=Ma()),Ji[r](this,e);case wt.KEXINIT:return t.firstPacket?(t.firstPacket=!1,um(this,e)):at(this,"Received extra KEXINIT during handshake","handshake",st.KEY_EXCHANGE_FAILED);default:if(r<20||r>49)return at(this,`Received unexpected packet type ${r}`,"handshake",st.KEY_EXCHANGE_FAILED)}return this._kex.parse(e)}c(lm,"onKEXPayload");function VI(t){let e=to[t.cs.cipher],r=to[t.sc.cipher],n=Math.max(0,e.sslName==="des-ede3-cbc"?14:e.keyLen,e.blockLen,e.ivLen,r.sslName==="des-ede3-cbc"?14:r.keyLen,r.blockLen,r.ivLen)*8;return n<=112?2048:n<=128?3072:n<=192?7680:8192}c(VI,"dhEstimate");function Va(t){if(!t._sentNEWKEYS){t._protocol._debug&&t._protocol._debug("Outbound: Sending NEWKEYS");let e=t._protocol._packetRW.write.allocStartKEX,r=t._protocol._packetRW.write.alloc(1,!0);r[e]=wt.NEWKEYS,t._protocol._cipher.encrypt(t._protocol._packetRW.write.finalize(r,!0)),t._sentNEWKEYS=!0,t._protocol._strictMode&&(t._protocol._cipher.outSeqno=0)}}c(Va,"trySendNEWKEYS");fm.exports={KexInit:Bl,kexinit:cm,onKEXPayload:lm,DEFAULT_KEXINIT_CLIENT:new Bl({kex:nm.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:im,cs:{cipher:Ha,mac:ja,compress:Wa,lang:[]},sc:{cipher:Ha,mac:ja,compress:Wa,lang:[]}}),DEFAULT_KEXINIT_SERVER:new Bl({kex:nm.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:im,cs:{cipher:Ha,mac:ja,compress:Wa,lang:[]},sc:{cipher:Ha,mac:ja,compress:Wa,lang:[]}}),HANDLERS:{[wt.KEXINIT]:um}}});var dm=le((dF,KI)=>{KI.exports={name:"ssh2",version:"1.16.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.20.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 Hl=le((pF,Sm)=>{"use strict";var{inspect:ym}=require("util"),{bindingAvailable:GI,NullCipher:ZI,NullDecipher:YI}=zn(),{COMPAT_CHECKS:XI,DISCONNECT_REASON:Em,eddsaSupported:JI,MESSAGE:we,SIGNALS:pm,TERMINAL_MODE:Ml}=An(),{DEFAULT_KEXINIT_CLIENT:ev,DEFAULT_KEXINIT_SERVER:tv,KexInit:hm,kexinit:Am,onKEXPayload:rv}=Fa(),{parseKey:gm}=Hn(),nv=Ma(),{bufferCopy:Ka,bufferFill:iv,bufferSlice:bm,convertSignature:mm,sendPacket:Pe,writeUInt32BE:R}=Qr(),{PacketReader:ov,PacketWriter:sv,ZlibPacketReader:xm,ZlibPacketWriter:Im}=Ol(),av=dm().version,cv=new Map(Object.values(Em).map(t=>[t,1])),vm=Buffer.from(`SSH-2.0-ssh2js${av}`),uv=Buffer.from(`${vm}\r
12
+ `),lv=8192,fv=1024,_m=Buffer.from([we.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]),dv=Buffer.from([Ml.TTY_OP_END]);function zl(){}c(zl,"noop");var Fl=class{static{c(this,"Protocol")}constructor(e){let r=e.onWrite;if(typeof r!="function")throw new Error("Missing onWrite function");this._onWrite=h=>{r(h)};let n=e.onError;if(typeof n!="function")throw new Error("Missing onError function");this._onError=h=>{n(h)};let i=e.debug;this._debug=typeof i=="function"?h=>{i(h)}:void 0;let o=e.onHeader;this._onHeader=typeof o=="function"?(...h)=>{o(...h)}:zl;let s=e.onPacket;this._onPacket=typeof s=="function"?()=>{s()}:zl;let a=e.onHandshakeComplete;typeof a!="function"&&(a=zl);let u;this._onHandshakeComplete=(...h)=>{this._debug&&this._debug("Handshake completed"),u===void 0?u=!0:u=!1;let _=this._queue;if(_){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${_.length}) ...`);for(let A=0;A<_.length;++A){let b=_[A],I=this._packetRW.write.finalize(b);if(I===b){let w=this._cipher.allocPacket(b.length);w.set(b,5),I=w}Pe(this,I)}this._debug&&this._debug("... finished draining outbound queue")}u&&this._server&&this._kex.remoteExtInfoEnabled&&Ev(this),a(...h)},this._queue=void 0;let l=e.messageHandlers;typeof l=="object"&&l!==null?this._handlers=l:this._handlers={},this._onPayload=mv.bind(this),this._server=!!e.server,this._banner=void 0;let d;if(this._server){if(typeof e.hostKeys!="object"||e.hostKeys===null)throw new Error("Missing server host key(s)");this._hostKeys=e.hostKeys,typeof e.greeting=="string"&&e.greeting.length&&(d=e.greeting.slice(-2)===`\r
13
13
  `?e.greeting:`${e.greeting}\r
14
14
  `),typeof e.banner=="string"&&e.banner.length&&(this._banner=e.banner.slice(-2)===`\r
15
15
  `?e.banner:`${e.banner}\r
16
- `)}else this._hostKeys=void 0;let p=e.offer;typeof p!="object"||p===null?p=this._server?FI:MI:p.constructor!==um&&(this._server?p.kex=p.kex.concat(["kex-strict-s-v00@openssh.com"]):p.kex=p.kex.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),p=new um(p)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=p,this._cipher=new BI(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new qI,write:new QI(this)},this._hostVerifier=!this._server&&typeof e.hostVerifier=="function"?e.hostVerifier:void 0,this._parse=ev,this._buffer=void 0,this._authsQueue=[],this._authenticated=!1,this._remoteIdentRaw=void 0;let g;if(typeof e.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${e.ident}`),g=Buffer.allocUnsafe(this._identRaw.length+2),g.set(this._identRaw,0),g[g.length-2]=13,g[g.length-1]=10;else if(Buffer.isBuffer(e.ident)){let h=Buffer.allocUnsafe(8+e.ident.length);h.latin1Write("SSH-2.0-",0,8),h.set(e.ident,8),this._identRaw=h,g=Buffer.allocUnsafe(h.length+2),g.set(h,0),g[g.length-2]=13,g[g.length-1]=10}else this._identRaw=Am,g=GI;this._compatFlags=0,this._debug&&(DI?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${pm(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,d&&this._onWrite(d),this._onWrite(g)}}_destruct(e){this._packetRW.read.cleanup(),this._packetRW.write.cleanup(),this._cipher&&this._cipher.free(),this._decipher&&this._decipher.free(),(typeof e!="string"||e.length===0)&&(e="fatal error"),this.parse=()=>{throw new Error(`Instance unusable after ${e}`)},this._onWrite=()=>{throw new Error(`Instance unusable after ${e}`)},this._destruct=void 0}cleanup(){this._destruct&&this._destruct()}parse(e,r,n){for(;r<n;)r=this._parse(e,r,n)}disconnect(e){let n=this._packetRW.write.allocStartKEX,i=this._packetRW.write.alloc(13,!0),o=n+13;VI.has(e)||(e=hm.PROTOCOL_ERROR),i[n]=we.DISCONNECT,R(i,e,++n),i.fill(0,n+=4,o),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${e})`),Pe(this,this._packetRW.write.finalize(i,!0),!0)}ping(){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(dm.length);r.set(dm,e),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),Pe(this,this._packetRW.write.finalize(r))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],gm(this)):this._debug&&this._debug("Outbound: Ignoring rekey during handshake")}requestSuccess(e){let r=this._packetRW.write.allocStart,n;Buffer.isBuffer(e)?(n=this._packetRW.write.alloc(1+e.length),n[r]=we.REQUEST_SUCCESS,n.set(e,++r)):(n=this._packetRW.write.alloc(1),n[r]=we.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),Pe(this,this._packetRW.write.finalize(n))}requestFailure(){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(1);r[e]=we.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),Pe(this,this._packetRW.write.finalize(r))}channelSuccess(e){let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(5);n[r]=we.CHANNEL_SUCCESS,R(n,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${e})`),Pe(this,this._packetRW.write.finalize(n))}channelFailure(e){let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(5);n[r]=we.CHANNEL_FAILURE,R(n,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${e})`),Pe(this,this._packetRW.write.finalize(n))}channelEOF(e){let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(5);n[r]=we.CHANNEL_EOF,R(n,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${e})`),Pe(this,this._packetRW.write.finalize(n))}channelClose(e){let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(5);n[r]=we.CHANNEL_CLOSE,R(n,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${e})`),Pe(this,this._packetRW.write.finalize(n))}channelWindowAdjust(e,r){let n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(9);i[n]=we.CHANNEL_WINDOW_ADJUST,R(i,e,++n),R(i,r,n+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`),Pe(this,this._packetRW.write.finalize(i))}channelData(e,r){let n=Buffer.isBuffer(r),i=n?r.length:Buffer.byteLength(r),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(9+i);s[o]=we.CHANNEL_DATA,R(s,e,++o),R(s,i,o+=4),n?s.set(r,o+=4):s.utf8Write(r,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${e}, ${i})`),Pe(this,this._packetRW.write.finalize(s))}channelExtData(e,r,n){let i=Buffer.isBuffer(r),o=i?r.length:Buffer.byteLength(r),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(13+o);a[s]=we.CHANNEL_EXTENDED_DATA,R(a,e,++s),R(a,n,s+=4),R(a,o,s+=4),i?a.set(r,s+=4):a.utf8Write(r,s+=4,o),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${e})`),Pe(this,this._packetRW.write.finalize(a))}channelOpenConfirm(e,r,n,i){let o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(17);s[o]=we.CHANNEL_OPEN_CONFIRMATION,R(s,e,++o),R(s,r,o+=4),R(s,n,o+=4),R(s,i,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${e}, l:${r})`),Pe(this,this._packetRW.write.finalize(s))}channelOpenFail(e,r,n){typeof n!="string"&&(n="");let i=Buffer.byteLength(n),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(13+i+4);s[o]=we.CHANNEL_OPEN_FAILURE,R(s,e,++o),R(s,r,o+=4),R(s,i,o+=4),o+=4,i&&(s.utf8Write(n,o,i),o+=i),R(s,0,o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${e})`),Pe(this,this._packetRW.write.finalize(s))}service(e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r);i[n]=we.SERVICE_REQUEST,R(i,r,++n),i.utf8Write(e,n+=4,r),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${e})`),Pe(this,this._packetRW.write.finalize(i))}authPassword(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=Buffer.byteLength(r),s=n?Buffer.byteLength(n):0,a=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(5+i+4+14+4+8+1+4+o+(n?4+s:0));u[a]=we.USERAUTH_REQUEST,R(u,i,++a),u.utf8Write(e,a+=4,i),R(u,14,a+=i),u.utf8Write("ssh-connection",a+=4,14),R(u,8,a+=14),u.utf8Write("password",a+=4,8),u[a+=8]=n?1:0,R(u,o,++a),Buffer.isBuffer(r)?Ka(r,u,0,o,a+=4):u.utf8Write(r,a+=4,o),n?(R(u,s,a+=o),Buffer.isBuffer(n)?Ka(n,u,0,s,a+=4):u.utf8Write(n,a+=4,s),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (changed password)")):this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (password)"),this._authsQueue.push("password"),Pe(this,this._packetRW.write.finalize(u))}authPK(e,r,n,i){if(this._server)throw new Error("Client-only method called in server mode");if(r=lm(r),r instanceof Error)throw new Error("Invalid key");let o=r.type;r=r.getPublicSSH(),typeof n=="function"&&(i=n,n=void 0),n||(n=o);let s=Buffer.byteLength(e),a=Buffer.byteLength(n),u=r.length,l=this._kex.sessionID,d=l.length,p=(i?4+d:0)+1+4+s+4+14+4+9+1+4+a+4+u,g,h;if(i?(g=Buffer.allocUnsafe(p),h=0,R(g,d,h),g.set(l,h+=4),h+=d):(g=this._packetRW.write.alloc(p),h=this._packetRW.write.allocStart),g[h]=we.USERAUTH_REQUEST,R(g,s,++h),g.utf8Write(e,h+=4,s),R(g,14,h+=s),g.utf8Write("ssh-connection",h+=4,14),R(g,9,h+=14),g.utf8Write("publickey",h+=4,9),g[h+=9]=i?1:0,R(g,a,++h),g.utf8Write(n,h+=4,a),R(g,u,h+=a),g.set(r,h+=4),!i){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),Pe(this,this._packetRW.write.finalize(g));return}i(g,_=>{if(_=fm(_,o),_===!1)throw new Error("Error while converting handshake signature");let E=_.length;h=this._packetRW.write.allocStart,g=this._packetRW.write.alloc(5+s+4+14+4+9+1+4+a+4+u+4+4+a+4+E),g[h]=we.USERAUTH_REQUEST,R(g,s,++h),g.utf8Write(e,h+=4,s),R(g,14,h+=s),g.utf8Write("ssh-connection",h+=4,14),R(g,9,h+=14),g.utf8Write("publickey",h+=4,9),g[h+=9]=1,R(g,a,++h),g.utf8Write(n,h+=4,a),R(g,u,h+=a),g.set(r,h+=4),R(g,4+a+4+E,h+=u),R(g,a,h+=4),g.utf8Write(n,h+=4,a),R(g,E,h+=a),g.set(_,h+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),Pe(this,this._packetRW.write.finalize(g))})}authHostbased(e,r,n,i,o,s){if(this._server)throw new Error("Client-only method called in server mode");if(r=lm(r),r instanceof Error)throw new Error("Invalid key");let a=r.type;r=r.getPublicSSH(),typeof o=="function"&&(s=o,o=void 0),o||(o=a);let u=Buffer.byteLength(e),l=Buffer.byteLength(o),d=r.length,p=this._kex.sessionID,g=p.length,h=Buffer.byteLength(n),_=Buffer.byteLength(i),E=Buffer.allocUnsafe(4+g+1+4+u+4+14+4+9+4+l+4+d+4+h+4+_),b=0;R(E,g,b),E.set(p,b+=4),E[b+=g]=we.USERAUTH_REQUEST,R(E,u,++b),E.utf8Write(e,b+=4,u),R(E,14,b+=u),E.utf8Write("ssh-connection",b+=4,14),R(E,9,b+=14),E.utf8Write("hostbased",b+=4,9),R(E,l,b+=9),E.utf8Write(o,b+=4,l),R(E,d,b+=l),E.set(r,b+=4),R(E,h,b+=d),E.utf8Write(n,b+=4,h),R(E,_,b+=h),E.utf8Write(i,b+=4,_),s(E,I=>{if(I=fm(I,a),!I)throw new Error("Error while converting handshake signature");let w=I.length,H=E.length-g-4;b=this._packetRW.write.allocStart;let $=this._packetRW.write.alloc(H+4+4+l+4+w);Ka(E,$,4+g,E.length,b),R($,4+l+4+w,b+=H),R($,l,b+=4),$.utf8Write(o,b+=4,l),R($,w,b+=l),$.set(I,b+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),Pe(this,this._packetRW.write.finalize($))})}authKeyboard(e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r+4+14+4+20+4+4);i[n]=we.USERAUTH_REQUEST,R(i,r,++n),i.utf8Write(e,n+=4,r),R(i,14,n+=r),i.utf8Write("ssh-connection",n+=4,14),R(i,20,n+=14),i.utf8Write("keyboard-interactive",n+=4,20),R(i,0,n+=20),R(i,0,n+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),Pe(this,this._packetRW.write.finalize(i))}authNone(e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r+4+14+4+4);i[n]=we.USERAUTH_REQUEST,R(i,r,++n),i.utf8Write(e,n+=4,r),R(i,14,n+=r),i.utf8Write("ssh-connection",n+=4,14),R(i,4,n+=14),i.utf8Write("none",n+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),Pe(this,this._packetRW.write.finalize(i))}authInfoRes(e){if(this._server)throw new Error("Client-only method called in server mode");let r=0,n;if(e){n=new Array(e.length);for(let s=0;s<e.length;++s){let a=Buffer.byteLength(e[s]);n[s]=a,r+=4+a}}let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+r);if(o[i]=we.USERAUTH_INFO_RESPONSE,e){R(o,e.length,++i),i+=4;for(let s=0;s<e.length;++s){let a=n[s];R(o,a,i),i+=4,a&&(o.utf8Write(e[s],i,a),i+=a)}}else R(o,0,++i);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),Pe(this,this._packetRW.write.finalize(o))}tcpipForward(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(23+i+4);s[o]=we.GLOBAL_REQUEST,R(s,13,++o),s.utf8Write("tcpip-forward",o+=4,13),s[o+=13]=n===void 0||n===!0?1:0,R(s,i,++o),s.utf8Write(e,o+=4,i),R(s,r,o+=i),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),Pe(this,this._packetRW.write.finalize(s))}cancelTcpipForward(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(30+i+4);s[o]=we.GLOBAL_REQUEST,R(s,20,++o),s.utf8Write("cancel-tcpip-forward",o+=4,20),s[o+=20]=n===void 0||n===!0?1:0,R(s,i,++o),s.utf8Write(e,o+=4,i),R(s,r,o+=i),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),Pe(this,this._packetRW.write.finalize(s))}openssh_streamLocalForward(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(41+n);o[i]=we.GLOBAL_REQUEST,R(o,31,++i),o.utf8Write("streamlocal-forward@openssh.com",i+=4,31),o[i+=31]=r===void 0||r===!0?1:0,R(o,n,++i),o.utf8Write(e,i+=4,n),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),Pe(this,this._packetRW.write.finalize(o))}openssh_cancelStreamLocalForward(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(48+n);o[i]=we.GLOBAL_REQUEST,R(o,38,++i),o.utf8Write("cancel-streamlocal-forward@openssh.com",i+=4,38),o[i+=38]=r===void 0||r===!0?1:0,R(o,n,++i),o.utf8Write(e,i+=4,n),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),Pe(this,this._packetRW.write.finalize(o))}directTcpip(e,r,n,i){if(this._server)throw new Error("Client-only method called in server mode");let o=Buffer.byteLength(i.srcIP),s=Buffer.byteLength(i.dstIP),a=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(33+o+4+4+s+4);u[a]=we.CHANNEL_OPEN,R(u,12,++a),u.utf8Write("direct-tcpip",a+=4,12),R(u,e,a+=12),R(u,r,a+=4),R(u,n,a+=4),R(u,s,a+=4),u.utf8Write(i.dstIP,a+=4,s),R(u,i.dstPort,a+=s),R(u,o,a+=4),u.utf8Write(i.srcIP,a+=4,o),R(u,i.srcPort,a+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, direct-tcpip)`),Pe(this,this._packetRW.write.finalize(u))}openssh_directStreamLocal(e,r,n,i){if(this._server)throw new Error("Client-only method called in server mode");let o=Buffer.byteLength(i.socketPath),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(51+o+4+4);a[s]=we.CHANNEL_OPEN,R(a,30,++s),a.utf8Write("direct-streamlocal@openssh.com",s+=4,30),R(a,e,s+=30),R(a,r,s+=4),R(a,n,s+=4),R(a,o,s+=4),a.utf8Write(i.socketPath,s+=4,o),WI(a,0,s+=o,s+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, direct-streamlocal@openssh.com)`),Pe(this,this._packetRW.write.finalize(a))}openssh_noMoreSessions(e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(34);n[r]=we.GLOBAL_REQUEST,R(n,28,++r),n.utf8Write("no-more-sessions@openssh.com",r+=4,28),n[r+=28]=e===void 0||e===!0?1:0,this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)"),Pe(this,this._packetRW.write.finalize(n))}session(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(24);o[i]=we.CHANNEL_OPEN,R(o,7,++i),o.utf8Write("session",i+=4,7),R(o,e,i+=7),R(o,r,i+=4),R(o,n,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, session)`),Pe(this,this._packetRW.write.finalize(o))}windowChange(e,r,n,i,o){if(this._server)throw new Error("Client-only method called in server mode");let s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(39);a[s]=we.CHANNEL_REQUEST,R(a,e,++s),R(a,13,s+=4),a.utf8Write("window-change",s+=4,13),a[s+=13]=0,R(a,n,++s),R(a,r,s+=4),R(a,o,s+=4),R(a,i,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, window-change)`),Pe(this,this._packetRW.write.finalize(a))}pty(e,r,n,i,o,s,a,u){if(this._server)throw new Error("Client-only method called in server mode");(!s||!s.length)&&(s="vt100"),a&&!Buffer.isBuffer(a)&&!Array.isArray(a)&&typeof a=="object"&&a!==null&&(a=iv(a)),(!a||!a.length)&&(a=XI);let l=s.length,d=a.length,p=this._packetRW.write.allocStart,g=this._packetRW.write.alloc(21+l+4+4+4+4+4+d);if(g[p]=we.CHANNEL_REQUEST,R(g,e,++p),R(g,7,p+=4),g.utf8Write("pty-req",p+=4,7),g[p+=7]=u===void 0||u===!0?1:0,R(g,l,++p),g.utf8Write(s,p+=4,l),R(g,n,p+=l),R(g,r,p+=4),R(g,o,p+=4),R(g,i,p+=4),R(g,d,p+=4),p+=4,Array.isArray(a))for(let h=0;h<d;++h)g[p++]=a[h];else Buffer.isBuffer(a)&&g.set(a,p);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, pty-req)`),Pe(this,this._packetRW.write.finalize(g))}shell(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(15);i[n]=we.CHANNEL_REQUEST,R(i,e,++n),R(i,5,n+=4),i.utf8Write("shell",n+=4,5),i[n+=5]=r===void 0||r===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, shell)`),Pe(this,this._packetRW.write.finalize(i))}exec(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.isBuffer(r),o=i?r.length:Buffer.byteLength(r),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(18+o);a[s]=we.CHANNEL_REQUEST,R(a,e,++s),R(a,4,s+=4),a.utf8Write("exec",s+=4,4),a[s+=4]=n===void 0||n===!0?1:0,R(a,o,++s),i?a.set(r,s+=4):a.utf8Write(r,s+=4,o),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, exec: ${r})`),Pe(this,this._packetRW.write.finalize(a))}signal(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=r;if(r=r.toUpperCase(),r.slice(0,3)==="SIG"&&(r=r.slice(3)),cm[r]!==1)throw new Error(`Invalid signal: ${n}`);let i=r.length,o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(20+i);s[o]=we.CHANNEL_REQUEST,R(s,e,++o),R(s,6,o+=4),s.utf8Write("signal",o+=4,6),s[o+=6]=0,R(s,i,++o),s.utf8Write(r,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, signal: ${r})`),Pe(this,this._packetRW.write.finalize(s))}env(e,r,n,i){if(this._server)throw new Error("Client-only method called in server mode");let o=Buffer.byteLength(r),s=Buffer.isBuffer(n),a=s?n.length:Buffer.byteLength(n),u=this._packetRW.write.allocStart,l=this._packetRW.write.alloc(17+o+4+a);l[u]=we.CHANNEL_REQUEST,R(l,e,++u),R(l,3,u+=4),l.utf8Write("env",u+=4,3),l[u+=3]=i===void 0||i===!0?1:0,R(l,o,++u),l.utf8Write(r,u+=4,o),R(l,a,u+=o),s?l.set(n,u+=4):l.utf8Write(n,u+=4,a),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, env: ${r}=${n})`),Pe(this,this._packetRW.write.finalize(l))}x11Forward(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=r.protocol,o=r.cookie,s=Buffer.isBuffer(i),a=s?i.length:Buffer.byteLength(i),u=Buffer.isBuffer(o),l=u?o.length:Buffer.byteLength(o),d=this._packetRW.write.allocStart,p=this._packetRW.write.alloc(22+a+4+l+4);p[d]=we.CHANNEL_REQUEST,R(p,e,++d),R(p,7,d+=4),p.utf8Write("x11-req",d+=4,7),p[d+=7]=n===void 0||n===!0?1:0,p[++d]=r.single?1:0,R(p,a,++d),s?p.set(i,d+=4):p.utf8Write(i,d+=4,a),R(p,l,d+=a),u?p.set(o,d+=4):p.latin1Write(o,d+=4,l),R(p,r.screen||0,d+=l),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, x11-req)`),Pe(this,this._packetRW.write.finalize(p))}subsystem(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(r),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(23+i);s[o]=we.CHANNEL_REQUEST,R(s,e,++o),R(s,9,o+=4),s.utf8Write("subsystem",o+=4,9),s[o+=9]=n===void 0||n===!0?1:0,R(s,i,++o),s.utf8Write(r,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, subsystem: ${r})`),Pe(this,this._packetRW.write.finalize(s))}openssh_agentForward(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(36);i[n]=we.CHANNEL_REQUEST,R(i,e,++n),R(i,26,n+=4),i.utf8Write("auth-agent-req@openssh.com",n+=4,26),i[n+=26]=r===void 0||r===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, auth-agent-req@openssh.com)`),Pe(this,this._packetRW.write.finalize(i))}openssh_hostKeysProve(e){if(this._server)throw new Error("Client-only method called in server mode");let r=0,n=[];for(let s of e){let a=s.getPublicSSH();r+=4+a.length,n.push(a)}let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(35+r);o[i]=we.GLOBAL_REQUEST,R(o,29,++i),o.utf8Write("hostkeys-prove-00@openssh.com",i+=4,29),o[i+=29]=1,++i;for(let s of n)R(o,s.length,i),Ka(s,o,0,s.length,i+=4),i+=s.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),Pe(this,this._packetRW.write.finalize(o))}serviceAccept(e){if(!this._server)throw new Error("Server-only method called in client mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r);if(i[n]=we.SERVICE_ACCEPT,R(i,r,++n),i.utf8Write(e,n+=4,r),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${e})`),Pe(this,this._packetRW.write.finalize(i)),this._server&&this._banner&&e==="ssh-userauth"){let o=this._banner;this._banner=void 0;let s=Buffer.byteLength(o);n=this._packetRW.write.allocStart;let a=this._packetRW.write.alloc(5+s+4);a[n]=we.USERAUTH_BANNER,R(a,s,++n),a.utf8Write(o,n+=4,s),R(a,0,n+=s),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),Pe(this,this._packetRW.write.finalize(a))}}forwardedTcpip(e,r,n,i){if(!this._server)throw new Error("Server-only method called in client mode");let o=Buffer.byteLength(i.boundAddr),s=Buffer.byteLength(i.remoteAddr),a=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(36+o+4+4+s+4);u[a]=we.CHANNEL_OPEN,R(u,15,++a),u.utf8Write("forwarded-tcpip",a+=4,15),R(u,e,a+=15),R(u,r,a+=4),R(u,n,a+=4),R(u,o,a+=4),u.utf8Write(i.boundAddr,a+=4,o),R(u,i.boundPort,a+=o),R(u,s,a+=4),u.utf8Write(i.remoteAddr,a+=4,s),R(u,i.remotePort,a+=s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, forwarded-tcpip)`),Pe(this,this._packetRW.write.finalize(u))}x11(e,r,n,i){if(!this._server)throw new Error("Server-only method called in client mode");let o=Buffer.byteLength(i.originAddr),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(24+o+4);a[s]=we.CHANNEL_OPEN,R(a,3,++s),a.utf8Write("x11",s+=4,3),R(a,e,s+=3),R(a,r,s+=4),R(a,n,s+=4),R(a,o,s+=4),a.utf8Write(i.originAddr,s+=4,o),R(a,i.originPort,s+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, x11)`),Pe(this,this._packetRW.write.finalize(a))}openssh_authAgent(e,r,n){if(!this._server)throw new Error("Server-only method called in client mode");let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(39);o[i]=we.CHANNEL_OPEN,R(o,22,++i),o.utf8Write("auth-agent@openssh.com",i+=4,22),R(o,e,i+=22),R(o,r,i+=4),R(o,n,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, auth-agent@openssh.com)`),Pe(this,this._packetRW.write.finalize(o))}openssh_forwardedStreamLocal(e,r,n,i){if(!this._server)throw new Error("Server-only method called in client mode");let o=Buffer.byteLength(i.socketPath),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(54+o+4);a[s]=we.CHANNEL_OPEN,R(a,33,++s),a.utf8Write("forwarded-streamlocal@openssh.com",s+=4,33),R(a,e,s+=33),R(a,r,s+=4),R(a,n,s+=4),R(a,o,s+=4),a.utf8Write(i.socketPath,s+=4,o),R(a,0,s+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, forwarded-streamlocal@openssh.com)`),Pe(this,this._packetRW.write.finalize(a))}exitStatus(e,r){if(!this._server)throw new Error("Server-only method called in client mode");let n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(25);i[n]=we.CHANNEL_REQUEST,R(i,e,++n),R(i,11,n+=4),i.utf8Write("exit-status",n+=4,11),i[n+=11]=0,R(i,r,++n),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, exit-status: ${r})`),Pe(this,this._packetRW.write.finalize(i))}exitSignal(e,r,n,i){if(!this._server)throw new Error("Server-only method called in client mode");let o=r;if(typeof o!="string"||!o)throw new Error(`Invalid signal: ${o}`);let s=r.toUpperCase();if(s.slice(0,3)==="SIG"&&(s=s.slice(3)),cm[s]!==1)throw new Error(`Invalid signal: ${o}`);let a=Buffer.byteLength(s),u=i?Buffer.byteLength(i):0,l=this._packetRW.write.allocStart,d=this._packetRW.write.alloc(25+a+1+4+u+4);d[l]=we.CHANNEL_REQUEST,R(d,e,++l),R(d,11,l+=4),d.utf8Write("exit-signal",l+=4,11),d[l+=11]=0,R(d,a,++l),d.utf8Write(s,l+=4,a),d[l+=a]=n?1:0,R(d,u,++l),l+=4,u&&(d.utf8Write(i,l,u),l+=u),R(d,0,l),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, exit-signal: ${r})`),Pe(this,this._packetRW.write.finalize(d))}authFailure(e,r){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 n;if(typeof e=="boolean"&&(r=e,e=void 0),e){n=[];for(let a=0;a<e.length;++a)e[a].toLowerCase()!=="none"&&n.push(e[a]);n=n.join(",")}else n="";let i=n.length,o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+i+1);s[o]=we.USERAUTH_FAILURE,R(s,i,++o),s.utf8Write(n,o+=4,i),s[o+=i]=r===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),Pe(this,this._packetRW.write.finalize(s))}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 e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(1);r[e]=we.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),Pe(this,this._packetRW.write.finalize(r)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new _m),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new ym(this))}authPKOK(e,r){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 n=Buffer.byteLength(e),i=r.length,o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+n+4+i);s[o]=we.USERAUTH_PK_OK,R(s,n,++o),s.utf8Write(e,o+=4,n),R(s,i,o+=n),s.set(r,o+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),Pe(this,this._packetRW.write.finalize(s))}authPasswdChg(e){if(!this._server)throw new Error("Server-only method called in client mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r+4);i[n]=we.USERAUTH_PASSWD_CHANGEREQ,R(i,r,++n),i.utf8Write(e,n+=4,r),R(i,0,n+=r),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),Pe(this,this._packetRW.write.finalize(i))}authInfoReq(e,r,n){if(!this._server)throw new Error("Server-only method called in client mode");let i=0,o=e?Buffer.byteLength(e):0,s=r?Buffer.byteLength(r):0;for(let l=0;l<n.length;++l)i+=4+Buffer.byteLength(n[l].prompt)+1;let a=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(5+o+4+s+4+4+i);u[a]=we.USERAUTH_INFO_REQUEST,R(u,o,++a),a+=4,e&&(u.utf8Write(e,a,o),a+=o),R(u,s,a),a+=4,r&&(u.utf8Write(r,a,s),a+=s),R(u,0,a),R(u,n.length,a+=4),a+=4;for(let l=0;l<n.length;++l){let d=n[l],p=Buffer.byteLength(d.prompt);R(u,p,a),a+=4,p&&(u.utf8Write(d.prompt,a,p),a+=p),u[a++]=d.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),Pe(this,this._packetRW.write.finalize(u))}},JI=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function ev(t,e,r){let n,i;this._buffer?(n=Buffer.allocUnsafe(this._buffer.length+(r-e)),n.set(this._buffer,0),e===0?n.set(t,this._buffer.length):n.set(new Uint8Array(t.buffer,t.byteOffset+e,r-e),this._buffer.length),i=this._buffer.length,e=0):(n=t,i=0);let o=e,s=e,a=e,u=!1,l=0,d=0;for(;e<n.length;++e){let p=n[e];if(p===13){u=!0;continue}if(p===10){if(a>s&&a-s>4&&n[s]===83&&n[s+1]===83&&n[s+2]===72&&n[s+3]===45){let g=n.latin1Slice(o,a+1),h=s===o?g:g.slice(s-o),_=JI.exec(h);if(!_)throw new Error("Invalid identification string");let E={greeting:s===o?"":g.slice(0,s-o),identRaw:h,versions:{protocol:_[1],software:_[2]},comments:_[3]};return this._remoteIdentRaw=Buffer.from(h),this._debug&&this._debug(`Remote ident: ${pm(h)}`),this._compatFlags=nv(E),this._buffer=void 0,this._decipher=new UI(0,HI.bind(this,{firstPacket:!0})),this._parse=tv,this._onHeader(E),this._destruct?(gm(this),e+1-i):r}if(this._server)throw new Error("Greetings from clients not permitted");if(++d>YI)throw new Error("Max greeting lines exceeded");u=!1,s=e+1,l=0}else{if(u)throw new Error("Invalid header: expected newline");if(++l>=ZI)throw new Error("Header line too long")}a=e}return this._buffer||(this._buffer=mm(n,o)),e-i}c(ev,"parseHeader");function tv(t,e,r){return this._decipher.decrypt(t,e,r)}c(tv,"parsePacket");function rv(t){if(this._onPacket(),t.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}t=this._packetRW.read.read(t);let e=t[0];e===we.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new ym(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new _m));let r=jI[e];if(r===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${e}`);return}return r(this,t)}c(rv,"onPayload");function nv(t){let e=t.versions.software,r=0;for(let n of LI)typeof n[0]=="string"?e===n[0]&&(r|=n[1]):n[0].test(e)&&(r|=n[1]);return r}c(nv,"getCompatFlags");function iv(t){let e=Object.keys(t),r=Buffer.allocUnsafe(5*e.length+1),n=0;for(let i=0;i<e.length;++i){let o=e[i];if(o==="TTY_OP_END")continue;let s=zl[o];if(s===void 0)continue;let a=t[o];typeof a=="number"&&isFinite(a)&&(r[n++]=s,r[n++]=a>>>24,r[n++]=a>>>16,r[n++]=a>>>8,r[n++]=a)}return r[n++]=zl.TTY_OP_END,n<r.length?mm(r,0,n):r}c(iv,"modesToBytes");function ov(t){let e="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";zI&&(e=`ssh-ed25519,${e}`);let r=Buffer.byteLength(e),n=t._packetRW.write.allocStart,i=t._packetRW.write.alloc(28+r);i[n]=we.EXT_INFO,R(i,1,++n),R(i,15,n+=4),i.utf8Write("server-sig-algs",n+=4,15),R(i,r,n+=15),i.utf8Write(e,n+=4,r),t._debug&&t._debug("Outbound: Sending EXT_INFO"),Pe(t,t._packetRW.write.finalize(i))}c(ov,"sendExtInfo");Em.exports=Ml});var wm=le(fs=>{"use strict";var Va=require("assert"),{inspect:sv}=require("util");function bm(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}c(bm,"addNumericalSeparator");function xm(t,e){if(Va(typeof e=="string","`thing` has to be of type string"),Array.isArray(t)){let r=t.length;return Va(r>0,"At least one expected value needs to be specified"),t=t.map(n=>String(n)),r>2?`one of ${e} ${t.slice(0,r-1).join(", ")}, or `+t[r-1]:r===2?`one of ${e} ${t[0]} or ${t[1]}`:`of ${e} ${t[0]}`}return`of ${e} ${String(t)}`}c(xm,"oneOf");fs.ERR_INTERNAL_ASSERTION=class vm extends Error{static{c(this,"ERR_INTERNAL_ASSERTION")}constructor(e){super(),Error.captureStackTrace(this,vm);let r=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
16
+ `)}else this._hostKeys=void 0;let p=e.offer;typeof p!="object"||p===null?p=this._server?tv:ev:p.constructor!==hm&&(this._server?p.kex=p.kex.concat(["kex-strict-s-v00@openssh.com"]):p.kex=p.kex.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),p=new hm(p)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=p,this._cipher=new ZI(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new ov,write:new sv(this)},this._hostVerifier=!this._server&&typeof e.hostVerifier=="function"?e.hostVerifier:void 0,this._parse=hv,this._buffer=void 0,this._authsQueue=[],this._authenticated=!1,this._remoteIdentRaw=void 0;let g;if(typeof e.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${e.ident}`),g=Buffer.allocUnsafe(this._identRaw.length+2),g.set(this._identRaw,0),g[g.length-2]=13,g[g.length-1]=10;else if(Buffer.isBuffer(e.ident)){let h=Buffer.allocUnsafe(8+e.ident.length);h.latin1Write("SSH-2.0-",0,8),h.set(e.ident,8),this._identRaw=h,g=Buffer.allocUnsafe(h.length+2),g.set(h,0),g[g.length-2]=13,g[g.length-1]=10}else this._identRaw=vm,g=uv;this._compatFlags=0,this._debug&&(GI?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${ym(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,d&&this._onWrite(d),this._onWrite(g)}}_destruct(e){this._packetRW.read.cleanup(),this._packetRW.write.cleanup(),this._cipher&&this._cipher.free(),this._decipher&&this._decipher.free(),(typeof e!="string"||e.length===0)&&(e="fatal error"),this.parse=()=>{throw new Error(`Instance unusable after ${e}`)},this._onWrite=()=>{throw new Error(`Instance unusable after ${e}`)},this._destruct=void 0}cleanup(){this._destruct&&this._destruct()}parse(e,r,n){for(;r<n;)r=this._parse(e,r,n)}disconnect(e){let n=this._packetRW.write.allocStartKEX,i=this._packetRW.write.alloc(13,!0),o=n+13;cv.has(e)||(e=Em.PROTOCOL_ERROR),i[n]=we.DISCONNECT,R(i,e,++n),i.fill(0,n+=4,o),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${e})`),Pe(this,this._packetRW.write.finalize(i,!0),!0)}ping(){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(_m.length);r.set(_m,e),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),Pe(this,this._packetRW.write.finalize(r))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],Am(this)):this._debug&&this._debug("Outbound: Ignoring rekey during handshake")}requestSuccess(e){let r=this._packetRW.write.allocStart,n;Buffer.isBuffer(e)?(n=this._packetRW.write.alloc(1+e.length),n[r]=we.REQUEST_SUCCESS,n.set(e,++r)):(n=this._packetRW.write.alloc(1),n[r]=we.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),Pe(this,this._packetRW.write.finalize(n))}requestFailure(){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(1);r[e]=we.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),Pe(this,this._packetRW.write.finalize(r))}channelSuccess(e){let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(5);n[r]=we.CHANNEL_SUCCESS,R(n,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${e})`),Pe(this,this._packetRW.write.finalize(n))}channelFailure(e){let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(5);n[r]=we.CHANNEL_FAILURE,R(n,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${e})`),Pe(this,this._packetRW.write.finalize(n))}channelEOF(e){let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(5);n[r]=we.CHANNEL_EOF,R(n,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${e})`),Pe(this,this._packetRW.write.finalize(n))}channelClose(e){let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(5);n[r]=we.CHANNEL_CLOSE,R(n,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${e})`),Pe(this,this._packetRW.write.finalize(n))}channelWindowAdjust(e,r){let n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(9);i[n]=we.CHANNEL_WINDOW_ADJUST,R(i,e,++n),R(i,r,n+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`),Pe(this,this._packetRW.write.finalize(i))}channelData(e,r){let n=Buffer.isBuffer(r),i=n?r.length:Buffer.byteLength(r),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(9+i);s[o]=we.CHANNEL_DATA,R(s,e,++o),R(s,i,o+=4),n?s.set(r,o+=4):s.utf8Write(r,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${e}, ${i})`),Pe(this,this._packetRW.write.finalize(s))}channelExtData(e,r,n){let i=Buffer.isBuffer(r),o=i?r.length:Buffer.byteLength(r),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(13+o);a[s]=we.CHANNEL_EXTENDED_DATA,R(a,e,++s),R(a,n,s+=4),R(a,o,s+=4),i?a.set(r,s+=4):a.utf8Write(r,s+=4,o),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${e})`),Pe(this,this._packetRW.write.finalize(a))}channelOpenConfirm(e,r,n,i){let o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(17);s[o]=we.CHANNEL_OPEN_CONFIRMATION,R(s,e,++o),R(s,r,o+=4),R(s,n,o+=4),R(s,i,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${e}, l:${r})`),Pe(this,this._packetRW.write.finalize(s))}channelOpenFail(e,r,n){typeof n!="string"&&(n="");let i=Buffer.byteLength(n),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(13+i+4);s[o]=we.CHANNEL_OPEN_FAILURE,R(s,e,++o),R(s,r,o+=4),R(s,i,o+=4),o+=4,i&&(s.utf8Write(n,o,i),o+=i),R(s,0,o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${e})`),Pe(this,this._packetRW.write.finalize(s))}service(e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r);i[n]=we.SERVICE_REQUEST,R(i,r,++n),i.utf8Write(e,n+=4,r),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${e})`),Pe(this,this._packetRW.write.finalize(i))}authPassword(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=Buffer.byteLength(r),s=n?Buffer.byteLength(n):0,a=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(5+i+4+14+4+8+1+4+o+(n?4+s:0));u[a]=we.USERAUTH_REQUEST,R(u,i,++a),u.utf8Write(e,a+=4,i),R(u,14,a+=i),u.utf8Write("ssh-connection",a+=4,14),R(u,8,a+=14),u.utf8Write("password",a+=4,8),u[a+=8]=n?1:0,R(u,o,++a),Buffer.isBuffer(r)?Ka(r,u,0,o,a+=4):u.utf8Write(r,a+=4,o),n?(R(u,s,a+=o),Buffer.isBuffer(n)?Ka(n,u,0,s,a+=4):u.utf8Write(n,a+=4,s),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (changed password)")):this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (password)"),this._authsQueue.push("password"),Pe(this,this._packetRW.write.finalize(u))}authPK(e,r,n,i){if(this._server)throw new Error("Client-only method called in server mode");if(r=gm(r),r instanceof Error)throw new Error("Invalid key");let o=r.type;r=r.getPublicSSH(),typeof n=="function"&&(i=n,n=void 0),n||(n=o);let s=Buffer.byteLength(e),a=Buffer.byteLength(n),u=r.length,l=this._kex.sessionID,d=l.length,p=(i?4+d:0)+1+4+s+4+14+4+9+1+4+a+4+u,g,h;if(i?(g=Buffer.allocUnsafe(p),h=0,R(g,d,h),g.set(l,h+=4),h+=d):(g=this._packetRW.write.alloc(p),h=this._packetRW.write.allocStart),g[h]=we.USERAUTH_REQUEST,R(g,s,++h),g.utf8Write(e,h+=4,s),R(g,14,h+=s),g.utf8Write("ssh-connection",h+=4,14),R(g,9,h+=14),g.utf8Write("publickey",h+=4,9),g[h+=9]=i?1:0,R(g,a,++h),g.utf8Write(n,h+=4,a),R(g,u,h+=a),g.set(r,h+=4),!i){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),Pe(this,this._packetRW.write.finalize(g));return}i(g,_=>{if(_=mm(_,o),_===!1)throw new Error("Error while converting handshake signature");let A=_.length;h=this._packetRW.write.allocStart,g=this._packetRW.write.alloc(5+s+4+14+4+9+1+4+a+4+u+4+4+a+4+A),g[h]=we.USERAUTH_REQUEST,R(g,s,++h),g.utf8Write(e,h+=4,s),R(g,14,h+=s),g.utf8Write("ssh-connection",h+=4,14),R(g,9,h+=14),g.utf8Write("publickey",h+=4,9),g[h+=9]=1,R(g,a,++h),g.utf8Write(n,h+=4,a),R(g,u,h+=a),g.set(r,h+=4),R(g,4+a+4+A,h+=u),R(g,a,h+=4),g.utf8Write(n,h+=4,a),R(g,A,h+=a),g.set(_,h+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),Pe(this,this._packetRW.write.finalize(g))})}authHostbased(e,r,n,i,o,s){if(this._server)throw new Error("Client-only method called in server mode");if(r=gm(r),r instanceof Error)throw new Error("Invalid key");let a=r.type;r=r.getPublicSSH(),typeof o=="function"&&(s=o,o=void 0),o||(o=a);let u=Buffer.byteLength(e),l=Buffer.byteLength(o),d=r.length,p=this._kex.sessionID,g=p.length,h=Buffer.byteLength(n),_=Buffer.byteLength(i),A=Buffer.allocUnsafe(4+g+1+4+u+4+14+4+9+4+l+4+d+4+h+4+_),b=0;R(A,g,b),A.set(p,b+=4),A[b+=g]=we.USERAUTH_REQUEST,R(A,u,++b),A.utf8Write(e,b+=4,u),R(A,14,b+=u),A.utf8Write("ssh-connection",b+=4,14),R(A,9,b+=14),A.utf8Write("hostbased",b+=4,9),R(A,l,b+=9),A.utf8Write(o,b+=4,l),R(A,d,b+=l),A.set(r,b+=4),R(A,h,b+=d),A.utf8Write(n,b+=4,h),R(A,_,b+=h),A.utf8Write(i,b+=4,_),s(A,I=>{if(I=mm(I,a),!I)throw new Error("Error while converting handshake signature");let w=I.length,H=A.length-g-4;b=this._packetRW.write.allocStart;let $=this._packetRW.write.alloc(H+4+4+l+4+w);Ka(A,$,4+g,A.length,b),R($,4+l+4+w,b+=H),R($,l,b+=4),$.utf8Write(o,b+=4,l),R($,w,b+=l),$.set(I,b+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),Pe(this,this._packetRW.write.finalize($))})}authKeyboard(e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r+4+14+4+20+4+4);i[n]=we.USERAUTH_REQUEST,R(i,r,++n),i.utf8Write(e,n+=4,r),R(i,14,n+=r),i.utf8Write("ssh-connection",n+=4,14),R(i,20,n+=14),i.utf8Write("keyboard-interactive",n+=4,20),R(i,0,n+=20),R(i,0,n+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),Pe(this,this._packetRW.write.finalize(i))}authNone(e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r+4+14+4+4);i[n]=we.USERAUTH_REQUEST,R(i,r,++n),i.utf8Write(e,n+=4,r),R(i,14,n+=r),i.utf8Write("ssh-connection",n+=4,14),R(i,4,n+=14),i.utf8Write("none",n+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),Pe(this,this._packetRW.write.finalize(i))}authInfoRes(e){if(this._server)throw new Error("Client-only method called in server mode");let r=0,n;if(e){n=new Array(e.length);for(let s=0;s<e.length;++s){let a=Buffer.byteLength(e[s]);n[s]=a,r+=4+a}}let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+r);if(o[i]=we.USERAUTH_INFO_RESPONSE,e){R(o,e.length,++i),i+=4;for(let s=0;s<e.length;++s){let a=n[s];R(o,a,i),i+=4,a&&(o.utf8Write(e[s],i,a),i+=a)}}else R(o,0,++i);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),Pe(this,this._packetRW.write.finalize(o))}tcpipForward(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(23+i+4);s[o]=we.GLOBAL_REQUEST,R(s,13,++o),s.utf8Write("tcpip-forward",o+=4,13),s[o+=13]=n===void 0||n===!0?1:0,R(s,i,++o),s.utf8Write(e,o+=4,i),R(s,r,o+=i),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),Pe(this,this._packetRW.write.finalize(s))}cancelTcpipForward(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(30+i+4);s[o]=we.GLOBAL_REQUEST,R(s,20,++o),s.utf8Write("cancel-tcpip-forward",o+=4,20),s[o+=20]=n===void 0||n===!0?1:0,R(s,i,++o),s.utf8Write(e,o+=4,i),R(s,r,o+=i),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),Pe(this,this._packetRW.write.finalize(s))}openssh_streamLocalForward(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(41+n);o[i]=we.GLOBAL_REQUEST,R(o,31,++i),o.utf8Write("streamlocal-forward@openssh.com",i+=4,31),o[i+=31]=r===void 0||r===!0?1:0,R(o,n,++i),o.utf8Write(e,i+=4,n),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),Pe(this,this._packetRW.write.finalize(o))}openssh_cancelStreamLocalForward(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(48+n);o[i]=we.GLOBAL_REQUEST,R(o,38,++i),o.utf8Write("cancel-streamlocal-forward@openssh.com",i+=4,38),o[i+=38]=r===void 0||r===!0?1:0,R(o,n,++i),o.utf8Write(e,i+=4,n),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),Pe(this,this._packetRW.write.finalize(o))}directTcpip(e,r,n,i){if(this._server)throw new Error("Client-only method called in server mode");let o=Buffer.byteLength(i.srcIP),s=Buffer.byteLength(i.dstIP),a=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(33+o+4+4+s+4);u[a]=we.CHANNEL_OPEN,R(u,12,++a),u.utf8Write("direct-tcpip",a+=4,12),R(u,e,a+=12),R(u,r,a+=4),R(u,n,a+=4),R(u,s,a+=4),u.utf8Write(i.dstIP,a+=4,s),R(u,i.dstPort,a+=s),R(u,o,a+=4),u.utf8Write(i.srcIP,a+=4,o),R(u,i.srcPort,a+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, direct-tcpip)`),Pe(this,this._packetRW.write.finalize(u))}openssh_directStreamLocal(e,r,n,i){if(this._server)throw new Error("Client-only method called in server mode");let o=Buffer.byteLength(i.socketPath),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(51+o+4+4);a[s]=we.CHANNEL_OPEN,R(a,30,++s),a.utf8Write("direct-streamlocal@openssh.com",s+=4,30),R(a,e,s+=30),R(a,r,s+=4),R(a,n,s+=4),R(a,o,s+=4),a.utf8Write(i.socketPath,s+=4,o),iv(a,0,s+=o,s+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, direct-streamlocal@openssh.com)`),Pe(this,this._packetRW.write.finalize(a))}openssh_noMoreSessions(e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,n=this._packetRW.write.alloc(34);n[r]=we.GLOBAL_REQUEST,R(n,28,++r),n.utf8Write("no-more-sessions@openssh.com",r+=4,28),n[r+=28]=e===void 0||e===!0?1:0,this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)"),Pe(this,this._packetRW.write.finalize(n))}session(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(24);o[i]=we.CHANNEL_OPEN,R(o,7,++i),o.utf8Write("session",i+=4,7),R(o,e,i+=7),R(o,r,i+=4),R(o,n,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, session)`),Pe(this,this._packetRW.write.finalize(o))}windowChange(e,r,n,i,o){if(this._server)throw new Error("Client-only method called in server mode");let s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(39);a[s]=we.CHANNEL_REQUEST,R(a,e,++s),R(a,13,s+=4),a.utf8Write("window-change",s+=4,13),a[s+=13]=0,R(a,n,++s),R(a,r,s+=4),R(a,o,s+=4),R(a,i,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, window-change)`),Pe(this,this._packetRW.write.finalize(a))}pty(e,r,n,i,o,s,a,u){if(this._server)throw new Error("Client-only method called in server mode");(!s||!s.length)&&(s="vt100"),a&&!Buffer.isBuffer(a)&&!Array.isArray(a)&&typeof a=="object"&&a!==null&&(a=yv(a)),(!a||!a.length)&&(a=dv);let l=s.length,d=a.length,p=this._packetRW.write.allocStart,g=this._packetRW.write.alloc(21+l+4+4+4+4+4+d);if(g[p]=we.CHANNEL_REQUEST,R(g,e,++p),R(g,7,p+=4),g.utf8Write("pty-req",p+=4,7),g[p+=7]=u===void 0||u===!0?1:0,R(g,l,++p),g.utf8Write(s,p+=4,l),R(g,n,p+=l),R(g,r,p+=4),R(g,o,p+=4),R(g,i,p+=4),R(g,d,p+=4),p+=4,Array.isArray(a))for(let h=0;h<d;++h)g[p++]=a[h];else Buffer.isBuffer(a)&&g.set(a,p);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, pty-req)`),Pe(this,this._packetRW.write.finalize(g))}shell(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(15);i[n]=we.CHANNEL_REQUEST,R(i,e,++n),R(i,5,n+=4),i.utf8Write("shell",n+=4,5),i[n+=5]=r===void 0||r===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, shell)`),Pe(this,this._packetRW.write.finalize(i))}exec(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.isBuffer(r),o=i?r.length:Buffer.byteLength(r),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(18+o);a[s]=we.CHANNEL_REQUEST,R(a,e,++s),R(a,4,s+=4),a.utf8Write("exec",s+=4,4),a[s+=4]=n===void 0||n===!0?1:0,R(a,o,++s),i?a.set(r,s+=4):a.utf8Write(r,s+=4,o),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, exec: ${r})`),Pe(this,this._packetRW.write.finalize(a))}signal(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=r;if(r=r.toUpperCase(),r.slice(0,3)==="SIG"&&(r=r.slice(3)),pm[r]!==1)throw new Error(`Invalid signal: ${n}`);let i=r.length,o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(20+i);s[o]=we.CHANNEL_REQUEST,R(s,e,++o),R(s,6,o+=4),s.utf8Write("signal",o+=4,6),s[o+=6]=0,R(s,i,++o),s.utf8Write(r,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, signal: ${r})`),Pe(this,this._packetRW.write.finalize(s))}env(e,r,n,i){if(this._server)throw new Error("Client-only method called in server mode");let o=Buffer.byteLength(r),s=Buffer.isBuffer(n),a=s?n.length:Buffer.byteLength(n),u=this._packetRW.write.allocStart,l=this._packetRW.write.alloc(17+o+4+a);l[u]=we.CHANNEL_REQUEST,R(l,e,++u),R(l,3,u+=4),l.utf8Write("env",u+=4,3),l[u+=3]=i===void 0||i===!0?1:0,R(l,o,++u),l.utf8Write(r,u+=4,o),R(l,a,u+=o),s?l.set(n,u+=4):l.utf8Write(n,u+=4,a),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, env: ${r}=${n})`),Pe(this,this._packetRW.write.finalize(l))}x11Forward(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=r.protocol,o=r.cookie,s=Buffer.isBuffer(i),a=s?i.length:Buffer.byteLength(i),u=Buffer.isBuffer(o),l=u?o.length:Buffer.byteLength(o),d=this._packetRW.write.allocStart,p=this._packetRW.write.alloc(22+a+4+l+4);p[d]=we.CHANNEL_REQUEST,R(p,e,++d),R(p,7,d+=4),p.utf8Write("x11-req",d+=4,7),p[d+=7]=n===void 0||n===!0?1:0,p[++d]=r.single?1:0,R(p,a,++d),s?p.set(i,d+=4):p.utf8Write(i,d+=4,a),R(p,l,d+=a),u?p.set(o,d+=4):p.latin1Write(o,d+=4,l),R(p,r.screen||0,d+=l),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, x11-req)`),Pe(this,this._packetRW.write.finalize(p))}subsystem(e,r,n){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(r),o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(23+i);s[o]=we.CHANNEL_REQUEST,R(s,e,++o),R(s,9,o+=4),s.utf8Write("subsystem",o+=4,9),s[o+=9]=n===void 0||n===!0?1:0,R(s,i,++o),s.utf8Write(r,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, subsystem: ${r})`),Pe(this,this._packetRW.write.finalize(s))}openssh_agentForward(e,r){if(this._server)throw new Error("Client-only method called in server mode");let n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(36);i[n]=we.CHANNEL_REQUEST,R(i,e,++n),R(i,26,n+=4),i.utf8Write("auth-agent-req@openssh.com",n+=4,26),i[n+=26]=r===void 0||r===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, auth-agent-req@openssh.com)`),Pe(this,this._packetRW.write.finalize(i))}openssh_hostKeysProve(e){if(this._server)throw new Error("Client-only method called in server mode");let r=0,n=[];for(let s of e){let a=s.getPublicSSH();r+=4+a.length,n.push(a)}let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(35+r);o[i]=we.GLOBAL_REQUEST,R(o,29,++i),o.utf8Write("hostkeys-prove-00@openssh.com",i+=4,29),o[i+=29]=1,++i;for(let s of n)R(o,s.length,i),Ka(s,o,0,s.length,i+=4),i+=s.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),Pe(this,this._packetRW.write.finalize(o))}serviceAccept(e){if(!this._server)throw new Error("Server-only method called in client mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r);if(i[n]=we.SERVICE_ACCEPT,R(i,r,++n),i.utf8Write(e,n+=4,r),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${e})`),Pe(this,this._packetRW.write.finalize(i)),this._server&&this._banner&&e==="ssh-userauth"){let o=this._banner;this._banner=void 0;let s=Buffer.byteLength(o);n=this._packetRW.write.allocStart;let a=this._packetRW.write.alloc(5+s+4);a[n]=we.USERAUTH_BANNER,R(a,s,++n),a.utf8Write(o,n+=4,s),R(a,0,n+=s),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),Pe(this,this._packetRW.write.finalize(a))}}forwardedTcpip(e,r,n,i){if(!this._server)throw new Error("Server-only method called in client mode");let o=Buffer.byteLength(i.boundAddr),s=Buffer.byteLength(i.remoteAddr),a=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(36+o+4+4+s+4);u[a]=we.CHANNEL_OPEN,R(u,15,++a),u.utf8Write("forwarded-tcpip",a+=4,15),R(u,e,a+=15),R(u,r,a+=4),R(u,n,a+=4),R(u,o,a+=4),u.utf8Write(i.boundAddr,a+=4,o),R(u,i.boundPort,a+=o),R(u,s,a+=4),u.utf8Write(i.remoteAddr,a+=4,s),R(u,i.remotePort,a+=s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, forwarded-tcpip)`),Pe(this,this._packetRW.write.finalize(u))}x11(e,r,n,i){if(!this._server)throw new Error("Server-only method called in client mode");let o=Buffer.byteLength(i.originAddr),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(24+o+4);a[s]=we.CHANNEL_OPEN,R(a,3,++s),a.utf8Write("x11",s+=4,3),R(a,e,s+=3),R(a,r,s+=4),R(a,n,s+=4),R(a,o,s+=4),a.utf8Write(i.originAddr,s+=4,o),R(a,i.originPort,s+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, x11)`),Pe(this,this._packetRW.write.finalize(a))}openssh_authAgent(e,r,n){if(!this._server)throw new Error("Server-only method called in client mode");let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(39);o[i]=we.CHANNEL_OPEN,R(o,22,++i),o.utf8Write("auth-agent@openssh.com",i+=4,22),R(o,e,i+=22),R(o,r,i+=4),R(o,n,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, auth-agent@openssh.com)`),Pe(this,this._packetRW.write.finalize(o))}openssh_forwardedStreamLocal(e,r,n,i){if(!this._server)throw new Error("Server-only method called in client mode");let o=Buffer.byteLength(i.socketPath),s=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(54+o+4);a[s]=we.CHANNEL_OPEN,R(a,33,++s),a.utf8Write("forwarded-streamlocal@openssh.com",s+=4,33),R(a,e,s+=33),R(a,r,s+=4),R(a,n,s+=4),R(a,o,s+=4),a.utf8Write(i.socketPath,s+=4,o),R(a,0,s+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${e}, forwarded-streamlocal@openssh.com)`),Pe(this,this._packetRW.write.finalize(a))}exitStatus(e,r){if(!this._server)throw new Error("Server-only method called in client mode");let n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(25);i[n]=we.CHANNEL_REQUEST,R(i,e,++n),R(i,11,n+=4),i.utf8Write("exit-status",n+=4,11),i[n+=11]=0,R(i,r,++n),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, exit-status: ${r})`),Pe(this,this._packetRW.write.finalize(i))}exitSignal(e,r,n,i){if(!this._server)throw new Error("Server-only method called in client mode");let o=r;if(typeof o!="string"||!o)throw new Error(`Invalid signal: ${o}`);let s=r.toUpperCase();if(s.slice(0,3)==="SIG"&&(s=s.slice(3)),pm[s]!==1)throw new Error(`Invalid signal: ${o}`);let a=Buffer.byteLength(s),u=i?Buffer.byteLength(i):0,l=this._packetRW.write.allocStart,d=this._packetRW.write.alloc(25+a+1+4+u+4);d[l]=we.CHANNEL_REQUEST,R(d,e,++l),R(d,11,l+=4),d.utf8Write("exit-signal",l+=4,11),d[l+=11]=0,R(d,a,++l),d.utf8Write(s,l+=4,a),d[l+=a]=n?1:0,R(d,u,++l),l+=4,u&&(d.utf8Write(i,l,u),l+=u),R(d,0,l),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${e}, exit-signal: ${r})`),Pe(this,this._packetRW.write.finalize(d))}authFailure(e,r){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 n;if(typeof e=="boolean"&&(r=e,e=void 0),e){n=[];for(let a=0;a<e.length;++a)e[a].toLowerCase()!=="none"&&n.push(e[a]);n=n.join(",")}else n="";let i=n.length,o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+i+1);s[o]=we.USERAUTH_FAILURE,R(s,i,++o),s.utf8Write(n,o+=4,i),s[o+=i]=r===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),Pe(this,this._packetRW.write.finalize(s))}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 e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(1);r[e]=we.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),Pe(this,this._packetRW.write.finalize(r)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new xm),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new Im(this))}authPKOK(e,r){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 n=Buffer.byteLength(e),i=r.length,o=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+n+4+i);s[o]=we.USERAUTH_PK_OK,R(s,n,++o),s.utf8Write(e,o+=4,n),R(s,i,o+=n),s.set(r,o+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),Pe(this,this._packetRW.write.finalize(s))}authPasswdChg(e){if(!this._server)throw new Error("Server-only method called in client mode");let r=Buffer.byteLength(e),n=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+r+4);i[n]=we.USERAUTH_PASSWD_CHANGEREQ,R(i,r,++n),i.utf8Write(e,n+=4,r),R(i,0,n+=r),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),Pe(this,this._packetRW.write.finalize(i))}authInfoReq(e,r,n){if(!this._server)throw new Error("Server-only method called in client mode");let i=0,o=e?Buffer.byteLength(e):0,s=r?Buffer.byteLength(r):0;for(let l=0;l<n.length;++l)i+=4+Buffer.byteLength(n[l].prompt)+1;let a=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(5+o+4+s+4+4+i);u[a]=we.USERAUTH_INFO_REQUEST,R(u,o,++a),a+=4,e&&(u.utf8Write(e,a,o),a+=o),R(u,s,a),a+=4,r&&(u.utf8Write(r,a,s),a+=s),R(u,0,a),R(u,n.length,a+=4),a+=4;for(let l=0;l<n.length;++l){let d=n[l],p=Buffer.byteLength(d.prompt);R(u,p,a),a+=4,p&&(u.utf8Write(d.prompt,a,p),a+=p),u[a++]=d.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),Pe(this,this._packetRW.write.finalize(u))}},pv=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function hv(t,e,r){let n,i;this._buffer?(n=Buffer.allocUnsafe(this._buffer.length+(r-e)),n.set(this._buffer,0),e===0?n.set(t,this._buffer.length):n.set(new Uint8Array(t.buffer,t.byteOffset+e,r-e),this._buffer.length),i=this._buffer.length,e=0):(n=t,i=0);let o=e,s=e,a=e,u=!1,l=0,d=0;for(;e<n.length;++e){let p=n[e];if(p===13){u=!0;continue}if(p===10){if(a>s&&a-s>4&&n[s]===83&&n[s+1]===83&&n[s+2]===72&&n[s+3]===45){let g=n.latin1Slice(o,a+1),h=s===o?g:g.slice(s-o),_=pv.exec(h);if(!_)throw new Error("Invalid identification string");let A={greeting:s===o?"":g.slice(0,s-o),identRaw:h,versions:{protocol:_[1],software:_[2]},comments:_[3]};return this._remoteIdentRaw=Buffer.from(h),this._debug&&this._debug(`Remote ident: ${ym(h)}`),this._compatFlags=_v(A),this._buffer=void 0,this._decipher=new YI(0,rv.bind(this,{firstPacket:!0})),this._parse=gv,this._onHeader(A),this._destruct?(Am(this),e+1-i):r}if(this._server)throw new Error("Greetings from clients not permitted");if(++d>fv)throw new Error("Max greeting lines exceeded");u=!1,s=e+1,l=0}else{if(u)throw new Error("Invalid header: expected newline");if(++l>=lv)throw new Error("Header line too long")}a=e}return this._buffer||(this._buffer=bm(n,o)),e-i}c(hv,"parseHeader");function gv(t,e,r){return this._decipher.decrypt(t,e,r)}c(gv,"parsePacket");function mv(t){if(this._onPacket(),t.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}t=this._packetRW.read.read(t);let e=t[0];e===we.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new Im(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new xm));let r=nv[e];if(r===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${e}`);return}return r(this,t)}c(mv,"onPayload");function _v(t){let e=t.versions.software,r=0;for(let n of XI)typeof n[0]=="string"?e===n[0]&&(r|=n[1]):n[0].test(e)&&(r|=n[1]);return r}c(_v,"getCompatFlags");function yv(t){let e=Object.keys(t),r=Buffer.allocUnsafe(5*e.length+1),n=0;for(let i=0;i<e.length;++i){let o=e[i];if(o==="TTY_OP_END")continue;let s=Ml[o];if(s===void 0)continue;let a=t[o];typeof a=="number"&&isFinite(a)&&(r[n++]=s,r[n++]=a>>>24,r[n++]=a>>>16,r[n++]=a>>>8,r[n++]=a)}return r[n++]=Ml.TTY_OP_END,n<r.length?bm(r,0,n):r}c(yv,"modesToBytes");function Ev(t){let e="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";JI&&(e=`ssh-ed25519,${e}`);let r=Buffer.byteLength(e),n=t._packetRW.write.allocStart,i=t._packetRW.write.alloc(28+r);i[n]=we.EXT_INFO,R(i,1,++n),R(i,15,n+=4),i.utf8Write("server-sig-algs",n+=4,15),R(i,r,n+=15),i.utf8Write(e,n+=4,r),t._debug&&t._debug("Outbound: Sending EXT_INFO"),Pe(t,t._packetRW.write.finalize(i))}c(Ev,"sendExtInfo");Sm.exports=Fl});var Rm=le(ds=>{"use strict";var Ga=require("assert"),{inspect:Av}=require("util");function wm(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}c(wm,"addNumericalSeparator");function Pm(t,e){if(Ga(typeof e=="string","`thing` has to be of type string"),Array.isArray(t)){let r=t.length;return Ga(r>0,"At least one expected value needs to be specified"),t=t.map(n=>String(n)),r>2?`one of ${e} ${t.slice(0,r-1).join(", ")}, or `+t[r-1]:r===2?`one of ${e} ${t[0]} or ${t[1]}`:`of ${e} ${t[0]}`}return`of ${e} ${String(t)}`}c(Pm,"oneOf");ds.ERR_INTERNAL_ASSERTION=class km extends Error{static{c(this,"ERR_INTERNAL_ASSERTION")}constructor(e){super(),Error.captureStackTrace(this,km);let r=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
17
17
  Please open an issue with this stack trace at https://github.com/mscdex/ssh2/issues
18
18
  `;this.message=e===void 0?r:`${e}
19
- ${r}`}};var av=2**32,Im=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();fs.ERR_OUT_OF_RANGE=class Sm extends RangeError{static{c(this,"ERR_OUT_OF_RANGE")}constructor(e,r,n,i){super(),Error.captureStackTrace(this,Sm),Va(r,'Missing "range" argument');let o=i?e:`The value of "${e}" is out of range.`,s;Number.isInteger(n)&&Math.abs(n)>av?s=bm(String(n)):typeof n=="bigint"?(s=String(n),(n>Im||n<-Im)&&(s=bm(s)),s+="n"):s=sv(n),o+=` It must be ${r}. Received ${s}`,this.message=o}};var Ga=class t extends TypeError{static{c(this,"ERR_INVALID_ARG_TYPE")}constructor(e,r,n){super(),Error.captureStackTrace(this,t),Va(typeof e=="string","'name' must be a string");let i;typeof r=="string"&&r.startsWith("not ")?(i="must not be",r=r.replace(/^not /,"")):i="must be";let o;if(e.endsWith(" argument"))o=`The ${e} ${i} ${xm(r,"type")}`;else{let s=e.includes(".")?"property":"argument";o=`The "${e}" ${s} ${i} ${xm(r,"type")}`}o+=`. Received type ${typeof n}`,this.message=o}};fs.ERR_INVALID_ARG_TYPE=Ga;fs.validateNumber=c(function(e,r){if(typeof e!="number")throw new Ga(r,"number",e)},"validateNumber")});var ds=le((J3,zm)=>{"use strict";var cv=require("events"),jn=require("fs"),{constants:Pr}=jn,{Readable:Nm,Writable:Zl}=require("stream"),{inherits:Om,types:{isDate:Wl}}=require("util"),uv=Buffer[Symbol.species],{bufferCopy:Hn,bufferSlice:no,makeBufferParser:lv,writeUInt32BE:V}=Qr(),xn={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},$e=Buffer.alloc(28),ht={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},fv=new Map(Object.values(ht).map(t=>[t,1])),dv={[ht.OK]:"No error",[ht.EOF]:"End of file",[ht.NO_SUCH_FILE]:"No such file or directory",[ht.PERMISSION_DENIED]:"Permission denied",[ht.FAILURE]:"Failure",[ht.BAD_MESSAGE]:"Bad message",[ht.NO_CONNECTION]:"No connection",[ht.CONNECTION_LOST]:"Connection lost",[ht.OP_UNSUPPORTED]:"Operation unsupported"},Ne={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},Tr={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},Te={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},Pm=2*1024,St=2**32-1,pv=Buffer.from([0,0,0,5,Ne.INIT,0,0,0,3]),hv=Buffer.from([0,0,0,5,Tr.VERSION,0,0,0,3]),gv=/^SSH-2.0-(?:OpenSSH|dropbear)/,Hl=256*1024,U=lv(),mv={readable:!1,writable:!1,push:c(t=>{},"push"),once:c(()=>{},"once"),on:c(()=>{},"on"),emit:c(()=>{},"emit"),end:c(()=>{},"end")};function $m(){}c($m,"noop");var ql=class extends cv{static{c(this,"SFTP")}constructor(e,r,n){super(),(typeof n!="object"||!n)&&(n={});let i=e._protocol._remoteIdentRaw;this.server=!!n.server,this._debug=typeof n.debug=="function"?n.debug:void 0,this._isOpenSSH=i&&gv.test(i),this._version=-1,this._extensions={},this._biOpt=n.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=Hl,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?Hl:34e3)-Pm,this._maxWriteLen=(this._isOpenSSH?Hl:34e3)-Pm,this.maxOpenHandles=void 0,this._client=e,this._protocol=e._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=r.type,this.subtype=void 0,this.incoming=r.incoming,this.outgoing=r.outgoing,this.stderr=mv,this.readable=!0}push(e){if(e===null){if(Lm(this),!this.readable)return;this.readable=!1,this.emit("end");return}let r=0;for(;r<e.length;){if(this._pktLenBytes<4){let s=Math.min(4-this._pktLenBytes,e.length-r);for(this._pktLenBytes+=s;s--;)this._pktLen=(this._pktLen<<8)+e[r++];if(this._pktLenBytes<4)return;if(this._pktLen===0)return yt(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return yt(this,`Packet length ${this._pktLen} exceeds max length of ${a}`)}if(r>=e.length)return}if(this._pktPos<this._pktLen){let s=Math.min(this._pktLen-this._pktPos,e.length-r);if(r!==0||s!==e.length?s===this._pktLen?this._pkt=new uv(e.buffer,e.byteOffset+r,s):(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(new Uint8Array(e.buffer,e.byteOffset+r,s),this._pktPos)):s===this._pktLen?this._pkt=e:(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(e,this._pktPos)),r+=s,this._pktPos+=s,this._pktPos<this._pktLen)return}let n=this._pkt[0],i=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let o=this.server?bv[n]:Ev[n];if(!o)return yt(this,`Unknown packet type ${n}`);if(this._version===-1){if(this.server){if(n!==Ne.INIT)return yt(this,`Expected INIT packet, got ${n}`)}else if(n!==Tr.VERSION)return yt(this,`Expected VERSION packet, got ${n}`)}if(o(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=$m,this.server||lt(this,pv)}createReadStream(e,r){if(this.server)throw new Error("Client-only method called in server mode");return new In(this,e,r)}createWriteStream(e,r){if(this.server)throw new Error("Client-only method called in server mode");return new Fr(this,e,r)}open(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");typeof n=="function"&&(i=n,n=void 0);let o=typeof r=="number"?r:Bm(r);if(o===null)throw new Error(`Unknown flags string: ${r}`);let s=0,a=0;(typeof n=="string"||typeof n=="number")&&(n={mode:n}),typeof n=="object"&&n!==null&&(n=li(n),s=n.flags,a=n.nb);let u=Buffer.byteLength(e),l=9,d=Buffer.allocUnsafe(13+u+4+4+a);V(d,d.length-4,0),d[4]=Ne.OPEN;let p=this._writeReqid=this._writeReqid+1&St;V(d,p,5),V(d,u,l),d.utf8Write(e,l+=4,u),V(d,o,l+=u),V(d,s,l+=4),a&&(l+=4,a===$e.length?d.set($e,l):Hn($e,d,0,a,l),l+=a),this._requests[p]={cb:i};let g=lt(this,d);this._debug&&this._debug(`SFTP: Outbound: ${g?"Buffered":"Sending"} OPEN`)}close(e,r){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let n=e.length,i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.CLOSE;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.set(e,i+=4),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(e,r,n,i,o,s){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(r))throw new Error("buffer is not a Buffer");if(n>=r.length)throw new Error("offset is out of bounds");if(n+i>r.length)throw new Error("length extends beyond buffer");if(o===null)throw new Error("null position currently unsupported");Dm(this,e,r,n,i,o,s)}readData(e,r,n,i,o,s){this.read(e,r,n,i,o,s)}write(e,r,n,i,o,s){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(r))throw new Error("buffer is not a Buffer");if(n>r.length)throw new Error("offset is out of bounds");if(n+i>r.length)throw new Error("length extends beyond buffer");if(o===null)throw new Error("null position currently unsupported");if(!i){s&&process.nextTick(s,void 0,0);return}let a=this._maxWriteLen,u=Math.max(i-a,0),l=o;u&&(i=a);let d=e.length,p=9,g=Buffer.allocUnsafe(13+d+8+4+i);V(g,g.length-4,0),g[4]=Ne.WRITE;let h=this._writeReqid=this._writeReqid+1&St;V(g,h,5),V(g,d,p),g.set(e,p+=4),p+=d;for(let E=7;E>=0;--E)g[p+E]=o&255,o/=256;V(g,i,p+=8),Hn(r,g,n,n+i,p+=4),this._requests[h]={cb:c(E=>{E?typeof s=="function"&&s(E):u?this.write(e,r,n+i,u,l+i,s):typeof s=="function"&&s(void 0,n+i)},"cb")};let _=lt(this,g);if(this._debug){let E=_?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${E} WRITE (id:${h})`)}}writeData(e,r,n,i,o,s){this.write(e,r,n,i,o,s)}fastGet(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");Tm(this,jn,e,r,n,i)}fastPut(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");Tm(jn,this,e,r,n,i)}readFile(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof n=="function"?i=n:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,flag:"r"};else if(!r)r={encoding:null,flag:"r"};else if(typeof r!="object")throw new TypeError("Bad arguments");let o=r.encoding;if(o&&!Buffer.isEncoding(o))throw new Error(`Unknown encoding: ${o}`);let s,a,u,l=0,d,p=0,g=r.flag||"r",h=c(()=>{s===0?(a=Buffer.allocUnsafe(8192),this.read(d,a,0,8192,p,_)):this.read(d,a,l,s-l,p,_)},"read"),_=c((b,I)=>{let w;if(b){if(w=b.code===ht.EOF,!w)return this.close(d,()=>i&&i(b))}else w=!1;if(w||s===0&&I===0)return E();p+=I,l+=I,s!==0?l===s?E():h():(u.push(no(a,0,I)),h())},"afterRead");_._wantEOFError=!0;let E=c(()=>{this.close(d,b=>(s===0?a=Buffer.concat(u,l):l<s&&(a=no(a,0,l)),o&&(a=a.toString(o)),i&&i(b,a)))},"close");this.open(e,g,438,(b,I)=>{if(b)return i&&i(b);d=I;let w=c((H,$)=>{if(H){this.stat(e,(X,Z)=>{if(X)return this.close(d,()=>{i&&i(H)});w(null,Z)});return}if(s=$.size||0,s===0)return u=[],h();a=Buffer.allocUnsafe(s),h()},"tryStat");this.fstat(d,w)})}writeFile(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");let o;if(typeof i=="function"?o=i:typeof n=="function"&&(o=n,n=void 0),typeof n=="string")n={encoding:n,mode:438,flag:"w"};else if(!n)n={encoding:"utf8",mode:438,flag:"w"};else if(typeof n!="object")throw new TypeError("Bad arguments");if(n.encoding&&!Buffer.isEncoding(n.encoding))throw new Error(`Unknown encoding: ${n.encoding}`);let s=n.flag||"w";this.open(e,s,n.mode,(a,u)=>{if(a)o&&o(a);else{let l=Buffer.isBuffer(r)?r:Buffer.from(""+r,n.encoding||"utf8"),d=/a/.test(s)?null:0;if(d===null){let p=c((g,h)=>{if(g){this.stat(e,(_,E)=>{if(_)return this.close(u,()=>{o&&o(g)});p(null,E)});return}Ql(this,u,l,0,l.length,h.size,o)},"tryStat");this.fstat(u,p);return}Ql(this,u,l,0,l.length,d,o)}})}appendFile(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");let o;if(typeof i=="function"?o=i:typeof n=="function"&&(o=n,n=void 0),typeof n=="string")n={encoding:n,mode:438,flag:"a"};else if(!n)n={encoding:"utf8",mode:438,flag:"a"};else if(typeof n!="object")throw new TypeError("Bad arguments");n.flag||(n=Object.assign({flag:"a"},n)),this.writeFile(e,r,n,o)}exists(e,r){if(this.server)throw new Error("Client-only method called in server mode");this.stat(e,n=>{r&&r(!n)})}unlink(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.REMOVE;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REMOVE`)}rename(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=Buffer.byteLength(r),s=9,a=Buffer.allocUnsafe(13+i+4+o);V(a,a.length-4,0),a[4]=Ne.RENAME;let u=this._writeReqid=this._writeReqid+1&St;V(a,u,5),V(a,i,s),a.utf8Write(e,s+=4,i),V(a,o,s+=i),a.utf8Write(r,s+=4,o),this._requests[u]={cb:n};let l=lt(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} RENAME`)}mkdir(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i=0,o=0;typeof r=="function"&&(n=r,r=void 0),typeof r=="object"&&r!==null&&(r=li(r),i=r.flags,o=r.nb);let s=Buffer.byteLength(e),a=9,u=Buffer.allocUnsafe(13+s+4+o);V(u,u.length-4,0),u[4]=Ne.MKDIR;let l=this._writeReqid=this._writeReqid+1&St;V(u,l,5),V(u,s,a),u.utf8Write(e,a+=4,s),V(u,i,a+=s),o&&(a+=4,o===$e.length?u.set($e,a):Hn($e,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} MKDIR`)}rmdir(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.RMDIR;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} RMDIR`)}readdir(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(n=r,r={}),(typeof r!="object"||r===null)&&(r={});let i=!(r&&r.full);if(!Buffer.isBuffer(e)&&typeof e!="string")throw new Error("missing directory handle or path");if(typeof e=="string"){let d=[],p=0,g=c((h,_)=>{if(h)return n(h);this.readdir(_,r,(E,b)=>{let I=E&&E.code===ht.EOF;if(E&&!I)return this.close(_,()=>n(E));if(I)return this.close(_,w=>{if(w)return n(w);n(void 0,d)});for(let w=0;w<b.length;++w,++p)d[p]=b[w];g(void 0,_)})},"reread");return this.opendir(e,g)}let o=e.length,s=9,a=Buffer.allocUnsafe(13+o);V(a,a.length-4,0),a[4]=Ne.READDIR;let u=this._writeReqid=this._writeReqid+1&St;V(a,u,5),V(a,o,s),a.set(e,s+=4),this._requests[u]={cb:i?(d,p)=>{if(typeof n=="function"){if(d)return n(d);for(let g=p.length-1;g>=0;--g)(p[g].filename==="."||p[g].filename==="..")&&p.splice(g,1);n(void 0,p)}}:n};let l=lt(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} READDIR`)}fstat(e,r){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let n=e.length,i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.FSTAT;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.set(e,i+=4),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} FSTAT`)}stat(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.STAT;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STAT`)}lstat(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.LSTAT;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} LSTAT`)}opendir(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.OPENDIR;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} OPENDIR`)}setstat(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i=0,o=0;typeof r=="object"&&r!==null?(r=li(r),i=r.flags,o=r.nb):typeof r=="function"&&(n=r);let s=Buffer.byteLength(e),a=9,u=Buffer.allocUnsafe(13+s+4+o);V(u,u.length-4,0),u[4]=Ne.SETSTAT;let l=this._writeReqid=this._writeReqid+1&St;V(u,l,5),V(u,s,a),u.utf8Write(e,a+=4,s),V(u,i,a+=s),o&&(a+=4,o===$e.length?u.set($e,a):Hn($e,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} SETSTAT`)}fsetstat(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let i=0,o=0;typeof r=="object"&&r!==null?(r=li(r),i=r.flags,o=r.nb):typeof r=="function"&&(n=r);let s=e.length,a=9,u=Buffer.allocUnsafe(13+s+4+o);V(u,u.length-4,0),u[4]=Ne.FSETSTAT;let l=this._writeReqid=this._writeReqid+1&St;V(u,l,5),V(u,s,a),u.set(e,a+=4),V(u,i,a+=s),o&&(a+=4,o===$e.length?u.set($e,a):Hn($e,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} FSETSTAT`)}futimes(e,r,n,i){return this.fsetstat(e,{atime:to(r),mtime:to(n)},i)}utimes(e,r,n,i){return this.setstat(e,{atime:to(r),mtime:to(n)},i)}fchown(e,r,n,i){return this.fsetstat(e,{uid:r,gid:n},i)}chown(e,r,n,i){return this.setstat(e,{uid:r,gid:n},i)}fchmod(e,r,n){return this.fsetstat(e,{mode:r},n)}chmod(e,r,n){return this.setstat(e,{mode:r},n)}readlink(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.READLINK;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:c((u,l)=>{if(typeof r=="function"){if(u)return r(u);if(!l||!l.length)return r(new Error("Response missing link info"));r(void 0,l[0].filename)}},"cb")};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} READLINK`)}symlink(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(r),o=Buffer.byteLength(e),s=9,a=Buffer.allocUnsafe(13+i+4+o);V(a,a.length-4,0),a[4]=Ne.SYMLINK;let u=this._writeReqid=this._writeReqid+1&St;V(a,u,5),this._isOpenSSH?(V(a,o,s),a.utf8Write(e,s+=4,o),V(a,i,s+=o),a.utf8Write(r,s+=4,i)):(V(a,i,s),a.utf8Write(r,s+=4,i),V(a,o,s+=i),a.utf8Write(e,s+=4,o)),this._requests[u]={cb:n};let l=lt(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} SYMLINK`)}realpath(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Ne.REALPATH;let s=this._writeReqid=this._writeReqid+1&St;V(o,s,5),V(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:c((u,l)=>{if(typeof r=="function"){if(u)return r(u);if(!l||!l.length)return r(new Error("Response missing path info"));r(void 0,l[0].filename)}},"cb")};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(e,r,n){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 o=Buffer.byteLength(e),s=Buffer.byteLength(r),a=9,u=Buffer.allocUnsafe(41+o+4+s);V(u,u.length-4,0),u[4]=Ne.EXTENDED;let l=this._writeReqid=this._writeReqid+1&St;V(u,l,5),V(u,24,a),u.utf8Write("posix-rename@openssh.com",a+=4,24),V(u,o,a+=24),u.utf8Write(e,a+=4,o),V(u,s,a+=o),u.utf8Write(r,a+=4,s),this._requests[l]={cb:n};let d=lt(this,u);if(this._debug){let p=d?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${p} posix-rename@openssh.com`)}}ext_openssh_statvfs(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=this._extensions["statvfs@openssh.com"];if(!n||n!=="2")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(e),o=9,s=Buffer.allocUnsafe(36+i);V(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;V(s,a,5),V(s,19,o),s.utf8Write("statvfs@openssh.com",o+=4,19),V(s,i,o+=19),s.utf8Write(e,o+=4,i),this._requests[a]={extended:"statvfs@openssh.com",cb:r};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} statvfs@openssh.com`)}}ext_openssh_fstatvfs(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=this._extensions["fstatvfs@openssh.com"];if(!n||n!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let i=e.length,o=9,s=Buffer.allocUnsafe(37+i);V(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;V(s,a,5),V(s,20,o),s.utf8Write("fstatvfs@openssh.com",o+=4,20),V(s,i,o+=20),s.set(e,o+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:r};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} fstatvfs@openssh.com`)}}ext_openssh_hardlink(e,r,n){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 o=Buffer.byteLength(e),s=Buffer.byteLength(r),a=9,u=Buffer.allocUnsafe(37+o+4+s);V(u,u.length-4,0),u[4]=Ne.EXTENDED;let l=this._writeReqid=this._writeReqid+1&St;V(u,l,5),V(u,20,a),u.utf8Write("hardlink@openssh.com",a+=4,20),V(u,o,a+=20),u.utf8Write(e,a+=4,o),V(u,s,a+=o),u.utf8Write(r,a+=4,s),this._requests[l]={cb:n};let d=lt(this,u);if(this._debug){let p=d?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${p} hardlink@openssh.com`)}}ext_openssh_fsync(e,r){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(e))throw new Error("handle is not a Buffer");let i=e.length,o=9,s=Buffer.allocUnsafe(34+i);V(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;V(s,a,5),V(s,17,o),s.utf8Write("fsync@openssh.com",o+=4,17),V(s,i,o+=17),s.set(e,o+=4),this._requests[a]={cb:r};let u=lt(this,s);this._debug&&this._debug(`SFTP: Outbound: ${u?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(e,r,n){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 o=0,s=0;typeof r=="object"&&r!==null?(r=li(r),o=r.flags,s=r.nb):typeof r=="function"&&(n=r);let a=Buffer.byteLength(e),u=9,l=Buffer.allocUnsafe(37+a+4+s);V(l,l.length-4,0),l[4]=Ne.EXTENDED;let d=this._writeReqid=this._writeReqid+1&St;V(l,d,5),V(l,20,u),l.utf8Write("lsetstat@openssh.com",u+=4,20),V(l,a,u+=20),l.utf8Write(e,u+=4,a),V(l,o,u+=a),s&&(u+=4,s===$e.length?l.set($e,u):Hn($e,l,0,s,u),u+=s),this._requests[d]={cb:n};let p=lt(this,l);if(this._debug){let g=p?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${g} lsetstat@openssh.com`)}}ext_openssh_expandPath(e,r){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(e),o=9,s=Buffer.allocUnsafe(40+i);V(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;V(s,a,5),V(s,23,o),s.utf8Write("expand-path@openssh.com",o+=4,23),V(s,i,o+=20),s.utf8Write(e,o+=4,i),this._requests[a]={cb:c((l,d)=>{if(typeof r=="function"){if(l)return r(l);if(!d||!d.length)return r(new Error("Response missing expanded path"));r(void 0,d[0].filename)}},"cb")};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} expand-path@openssh.com`)}}ext_copy_data(e,r,n,i,o,s){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(e))throw new Error("Source handle is not a Buffer");if(!Buffer.isBuffer(i))throw new Error("Destination handle is not a Buffer");let u=0,l=Buffer.allocUnsafe(26+e.length+8+8+4+i.length+8);V(l,l.length-4,u),u+=4,l[u]=Ne.EXTENDED,++u;let d=this._writeReqid=this._writeReqid+1&St;V(l,d,u),u+=4,V(l,9,u),u+=4,l.utf8Write("copy-data",u,9),u+=9,V(l,e.length,u),u+=4,l.set(e,u),u+=e.length;for(let g=7;g>=0;--g)l[u+g]=r&255,r/=256;u+=8;for(let g=7;g>=0;--g)l[u+g]=n&255,n/=256;u+=8,V(l,i.length,u),u+=4,l.set(i,u),u+=i.length;for(let g=7;g>=0;--g)l[u+g]=o&255,o/=256;this._requests[d]={cb:s};let p=lt(this,l);if(this._debug){let g=p?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${g} copy-data`)}}ext_home_dir(e,r){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 e!="string")throw new TypeError("username is not a string");let i=0,o=Buffer.byteLength(e),s=Buffer.allocUnsafe(31+o);V(s,s.length-4,i),i+=4,s[i]=Ne.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&St;V(s,a,i),i+=4,V(s,14,i),i+=4,s.utf8Write("home-directory",i,14),i+=14,V(s,o,i),i+=4,s.utf8Write(e,i,o),i+=o,this._requests[a]={cb:c((l,d)=>{if(typeof r=="function"){if(l)return r(l);if(!d||!d.length)return r(new Error("Response missing home directory"));r(void 0,d[0].filename)}},"cb")};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} home-directory`)}}ext_users_groups(e,r,n){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(e))throw new TypeError("uids is not an array");for(let l of e)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("uid values must all be 32-bit unsigned integers");if(!Array.isArray(r))throw new TypeError("gids is not an array");for(let l of r)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let o=0,s=Buffer.allocUnsafe(47+4*e.length+4+4*r.length);V(s,s.length-4,o),o+=4,s[o]=Ne.EXTENDED,++o;let a=this._writeReqid=this._writeReqid+1&St;V(s,a,o),o+=4,V(s,30,o),o+=4,s.utf8Write("users-groups-by-id@openssh.com",o,30),o+=30,V(s,4*e.length,o),o+=4;for(let l of e)V(s,l,o),o+=4;V(s,4*r.length,o),o+=4;for(let l of r)V(s,l,o),o+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:n};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} users-groups-by-id@openssh.com`)}}handle(e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!Buffer.isBuffer(r))throw new Error("handle is not a Buffer");let n=r.length;if(n>256)throw new Error("handle too large (> 256 bytes)");let i=9,o=Buffer.allocUnsafe(13+n);V(o,o.length-4,0),o[4]=Tr.HANDLE,V(o,e,5),V(o,n,i),n&&o.set(r,i+=4);let s=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${s?"Buffered":"Sending"} HANDLE`)}status(e,r,n){if(!this.server)throw new Error("Server-only method called in client mode");if(!fv.has(r))throw new Error(`Bad status code: ${r}`);n||(n="");let i=Buffer.byteLength(n),o=9,s=Buffer.allocUnsafe(17+i+4);V(s,s.length-4,0),s[4]=Tr.STATUS,V(s,e,5),V(s,r,o),V(s,i,o+=4),o+=4,i&&(s.utf8Write(n,o,i),o+=i),V(s,0,o);let a=lt(this,s);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STATUS`)}data(e,r,n){if(!this.server)throw new Error("Server-only method called in client mode");let i=Buffer.isBuffer(r);if(!i&&typeof r!="string")throw new Error("data is not a Buffer or string");let o;!i&&!n&&(n=void 0,o=!0);let s=i?r.length:Buffer.byteLength(r,n),a=9,u=Buffer.allocUnsafe(13+s);V(u,u.length-4,0),u[4]=Tr.DATA,V(u,e,5),V(u,s,a),s&&(i?u.set(r,a+=4):o?u.utf8Write(r,a+=4,s):u.write(r,a+=4,s,n));let l=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} DATA`)}name(e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!Array.isArray(r)){if(typeof r!="object"||r===null)throw new Error("names is not an object or array");r=[r]}let n=r.length,i=0,o,s=[];for(let d=0;d<n;++d){let p=r[d],g=!p||!p.filename||typeof p.filename!="string"?"":p.filename;i+=4+Buffer.byteLength(g);let h=!p||!p.longname||typeof p.longname!="string"?"":p.longname;if(i+=4+Buffer.byteLength(h),typeof p.attrs=="object"&&p.attrs!==null){if(o=li(p.attrs),i+=4+o.nb,o.nb){let _;o.nb===$e.length?_=new Uint8Array($e):(_=new Uint8Array(o.nb),Hn($e,_,0,o.nb,0)),o.bytes=_}s.push(o)}else i+=4,s.push(null)}let a=9,u=Buffer.allocUnsafe(13+i);V(u,u.length-4,0),u[4]=Tr.NAME,V(u,e,5),V(u,n,a),a+=4;for(let d=0;d<n;++d){let p=r[d];{let h=!p||!p.filename||typeof p.filename!="string"?"":p.filename,_=Buffer.byteLength(h);V(u,_,a),a+=4,_&&(u.utf8Write(h,a,_),a+=_)}{let h=!p||!p.longname||typeof p.longname!="string"?"":p.longname,_=Buffer.byteLength(h);V(u,_,a),a+=4,_&&(u.utf8Write(h,a,_),a+=_)}let g=s[d];g?(V(u,g.flags,a),a+=4,g.flags&&g.bytes&&(u.set(g.bytes,a),a+=g.nb)):(V(u,0,a),a+=4)}let l=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} NAME`)}attrs(e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(typeof r!="object"||r===null)throw new Error("attrs is not an object");r=li(r);let n=r.flags,i=r.nb,o=9,s=Buffer.allocUnsafe(13+i);V(s,s.length-4,0),s[4]=Tr.ATTRS,V(s,e,5),V(s,n,o),i&&(o+=4,i===$e.length?s.set($e,o):Hn($e,s,0,i,o),o+=i);let a=lt(this,s);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function _v(t){try{return Buffer.allocUnsafe(t)}catch(e){return e}}c(_v,"tryCreateBuffer");function Dm(t,e,r,n,i,o,s,a){let u=t._maxReadLen,l=Math.max(i-u,0);l&&(i=u);let d=e.length,p=9,g=o,h=Buffer.allocUnsafe(13+d+8+4);V(h,h.length-4,0),h[4]=Ne.READ;let _=t._writeReqid=t._writeReqid+1&St;V(h,_,5),V(h,d,p),h.set(e,p+=4),p+=d;for(let I=7;I>=0;--I)h[p+I]=g&255,g/=256;V(h,i,p+=8),typeof s!="function"&&(s=$m);let E=a||{nb:0,position:o,off:n,origOff:n,len:void 0,overflow:void 0,cb:c((I,w,H)=>{let $=E.len,X=E.overflow;if(I){if(s._wantEOFError||I.code!==ht.EOF)return s(I)}else{if(H>$)return s(new Error("Received more data than requested"));if(H===$&&X){E.nb+=H,E.position+=H,E.off+=H,Dm(t,e,r,E.off,X,E.position,s,E);return}}H=H||0,E.origOff===0&&r.length===E.nb?w=r:w=no(r,E.origOff,E.origOff+E.nb+H),s(void 0,E.nb+H,w,E.position)},"cb"),buffer:void 0};E.len=i,E.overflow=l,E.buffer=no(r,n,n+i),t._requests[_]=E;let b=lt(t,h);t._debug&&t._debug(`SFTP: Outbound: ${b?"Buffered":"Sending"} READ`)}c(Dm,"read_");function Tm(t,e,r,n,i,o){let s=64,a=32768,u,l,d;typeof i=="function"?o=i:typeof i=="object"&&i!==null&&(typeof i.concurrency=="number"&&i.concurrency>0&&!isNaN(i.concurrency)&&(s=i.concurrency),typeof i.chunkSize=="number"&&i.chunkSize>0&&!isNaN(i.chunkSize)&&(a=i.chunkSize),typeof i.fileSize=="number"&&i.fileSize>0&&!isNaN(i.fileSize)&&(d=i.fileSize),typeof i.step=="function"&&(u=i.step),(typeof i.mode=="string"||typeof i.mode=="number")&&(l=Yl(i.mode)));let p,g=0,h=0,_=!1,E,b,I,w=a*s;function H($){if(_)return;_=!0;let X=0,Z;E||b?(Z=c(()=>{--X===0&&o($)},"cbfinal"),E&&(t===jn||t.outgoing.state==="open")&&++X,b&&(e===jn||e.outgoing.state==="open")&&++X,E&&(t===jn||t.outgoing.state==="open")&&t.close(E,Z),b&&(e===jn||e.outgoing.state==="open")&&e.close(b,Z)):o($)}c(H,"onerror"),t.open(r,"r",($,X)=>{if($)return H($);E=X,d===void 0?t.fstat(E,Z):Z(null,{size:d});function Z(Y,P){if(Y){if(t!==jn){t.stat(r,(k,M)=>{if(k)return H(Y);Z(null,M)});return}return H(Y)}p=P.size,e.open(n,"w",(k,M)=>{if(k)return H(k);if(b=M,p<=0)return H();for(;w>p;){if(s===1){w=p;break}w-=a,--s}if(I=_v(w),I instanceof Error)return H(I);l!==void 0?e.fchmod(b,l,c(function B(G){if(G){e.chmod(n,l,ee=>B());return}j()},"tryAgain")):j();function L(B,G,ee,C,W,q){if(B)return H(B);W=W||0,e.write(b,I,W,G,C,J);function J(ue){if(ue)return H(ue);if(h+=G,u&&u(h,G,p),G<q)return F(W,C+G,q-G);if(h===p){e.close(b,he=>{if(b=void 0,he)return H(he);t.close(E,bt=>{if(E=void 0,bt)return H(bt);o()})});return}if(g>=p)return;let me=g+a>p?p-g:a;F(W,g,me),g+=me}c(J,"writeCb")}c(L,"onread");function T(B,G,ee){return(C,W,q)=>{L(C,W,q,G,B,ee)}}c(T,"makeCb");function F(B,G,ee){t.read(E,I,B,ee,G,T(B,G,ee))}c(F,"singleRead");function j(){let B=0,G=0;for(;g<p&&B<s;){let ee=g+a>p?p-g:a;F(G,g,ee),G+=ee,g+=ee,++B}}c(j,"startReads")})}c(Z,"tryStat")})}c(Tm,"fastXfer");function Ql(t,e,r,n,i,o,s){let a=typeof s=="function"?s:void 0;t.write(e,r,n,i,o,(u,l)=>{if(u)return t.close(e,()=>{a&&a(u)});l===i?t.close(e,a):(n+=l,i-=l,o+=l,Ql(t,e,r,n,i,o,a))})}c(Ql,"writeAll");var Ya=class{static{c(this,"Stats")}constructor(e){this.mode=e&&e.mode,this.uid=e&&e.uid,this.gid=e&&e.gid,this.size=e&&e.size,this.atime=e&&e.atime,this.mtime=e&&e.mtime,this.extended=e&&e.extended}isDirectory(){return(this.mode&Pr.S_IFMT)===Pr.S_IFDIR}isFile(){return(this.mode&Pr.S_IFMT)===Pr.S_IFREG}isBlockDevice(){return(this.mode&Pr.S_IFMT)===Pr.S_IFBLK}isCharacterDevice(){return(this.mode&Pr.S_IFMT)===Pr.S_IFCHR}isSymbolicLink(){return(this.mode&Pr.S_IFMT)===Pr.S_IFLNK}isFIFO(){return(this.mode&Pr.S_IFMT)===Pr.S_IFIFO}isSocket(){return(this.mode&Pr.S_IFMT)===Pr.S_IFSOCK}};function li(t){let e=0,r=0;if(typeof t=="object"&&t!==null){if(typeof t.size=="number"){e|=xn.SIZE;let n=t.size;$e[r++]=n/72057594037927940,$e[r++]=n/281474976710656,$e[r++]=n/1099511627776,$e[r++]=n/4294967296,$e[r++]=n/16777216,$e[r++]=n/65536,$e[r++]=n/256,$e[r++]=n}if(typeof t.uid=="number"&&typeof t.gid=="number"){e|=xn.UIDGID;let n=t.uid,i=t.gid;$e[r++]=n>>>24,$e[r++]=n>>>16,$e[r++]=n>>>8,$e[r++]=n,$e[r++]=i>>>24,$e[r++]=i>>>16,$e[r++]=i>>>8,$e[r++]=i}if(typeof t.mode=="number"||typeof t.mode=="string"){let n=Yl(t.mode);e|=xn.PERMISSIONS,$e[r++]=n>>>24,$e[r++]=n>>>16,$e[r++]=n>>>8,$e[r++]=n}if((typeof t.atime=="number"||Wl(t.atime))&&(typeof t.mtime=="number"||Wl(t.mtime))){let n=to(t.atime),i=to(t.mtime);e|=xn.ACMODTIME,$e[r++]=n>>>24,$e[r++]=n>>>16,$e[r++]=n>>>8,$e[r++]=n,$e[r++]=i>>>24,$e[r++]=i>>>16,$e[r++]=i>>>8,$e[r++]=i}}return{flags:e,nb:r}}c(li,"attrsToBytes");function to(t){if(typeof t=="number"&&t===t)return t;if(Wl(t))return parseInt(t.getTime()/1e3,10);throw new Error(`Cannot parse time: ${t}`)}c(to,"toUnixTimestamp");function Yl(t){if(typeof t=="number"&&t===t)return t;if(typeof t=="string")return Yl(parseInt(t,8));throw new Error(`Cannot parse mode: ${t}`)}c(Yl,"modeNum");var Kl={r:Te.READ,"r+":Te.READ|Te.WRITE,w:Te.TRUNC|Te.CREAT|Te.WRITE,wx:Te.TRUNC|Te.CREAT|Te.WRITE|Te.EXCL,xw:Te.TRUNC|Te.CREAT|Te.WRITE|Te.EXCL,"w+":Te.TRUNC|Te.CREAT|Te.READ|Te.WRITE,"wx+":Te.TRUNC|Te.CREAT|Te.READ|Te.WRITE|Te.EXCL,"xw+":Te.TRUNC|Te.CREAT|Te.READ|Te.WRITE|Te.EXCL,a:Te.APPEND|Te.CREAT|Te.WRITE,ax:Te.APPEND|Te.CREAT|Te.WRITE|Te.EXCL,xa:Te.APPEND|Te.CREAT|Te.WRITE|Te.EXCL,"a+":Te.APPEND|Te.CREAT|Te.READ|Te.WRITE,"ax+":Te.APPEND|Te.CREAT|Te.READ|Te.WRITE|Te.EXCL,"xa+":Te.APPEND|Te.CREAT|Te.READ|Te.WRITE|Te.EXCL};function Bm(t){let e=Kl[t];return e!==void 0?e:null}c(Bm,"stringToFlags");var yv=(()=>{let t=Object.keys(Kl);return e=>{for(let r=0;r<t.length;++r){let n=t[r];if(Kl[n]===e)return n}return null}})();function ro(t){let e=U.readUInt32BE();if(e===void 0)return;let r=new Ya;if(e&xn.SIZE){let n=U.readUInt64BE(t);if(n===void 0)return;r.size=n}if(e&xn.UIDGID){let n=U.readUInt32BE(),i=U.readUInt32BE();if(i===void 0)return;r.uid=n,r.gid=i}if(e&xn.PERMISSIONS){let n=U.readUInt32BE();if(n===void 0)return;r.mode=n}if(e&xn.ACMODTIME){let n=U.readUInt32BE(),i=U.readUInt32BE();if(i===void 0)return;r.atime=n,r.mtime=i}if(e&xn.EXTENDED){let n=U.readUInt32BE();if(n===void 0)return;let i={};for(let o=0;o<n;++o){let s=U.readString(!0),a=U.readString();if(a===void 0)return;i[s]=a}r.extended=i}return r}c(ro,"readAttrs");function lt(t,e){let r=Um(t,e);return r!==void 0?(t._buffer.push(r),!1):!0}c(lt,"sendOrBuffer");function Um(t,e){let r=t.outgoing;if(r.state!=="open")return;if(r.window===0)return t._waitWindow=!0,t._chunkcb=km,e;let n,i=e.length,o=0;for(;i-o>0&&r.window>0;){let s=Math.min(i-o,r.window,r.packetSize);r.window-=s,r.window===0&&(t._waitWindow=!0,t._chunkcb=km),o===0&&s===i?t._protocol.channelData(t.outgoing.id,e):t._protocol.channelData(t.outgoing.id,no(e,o,o+s)),o+=s}return i-o>0&&(o>0?n=no(e,o,i):n=e),n}c(Um,"tryWritePayload");function km(){this._chunkcb=void 0;let t=this._buffer,e=0;for(;e<t.length;){let r=t[e],n=Um(this,r);if(n!==void 0){n!==r&&(t[e]=n),e>0&&(this._buffer=t.slice(e));return}++e}e>0&&(this._buffer=[])}c(km,"drainBuffer");function yt(t,e,r){let n=new Error(e);return n.level="sftp-protocol",!r&&t._debug&&t._debug(`SFTP: Inbound: ${e}`),t.emit("error",n),t.destroy(),Lm(t),!1}c(yt,"doFatalSFTPError");function Lm(t){let e=Object.keys(t._requests);if(e.length===0)return;let r=t._requests;t._requests={};let n=new Error("No response from server");for(let i=0;i<e.length;++i){let o=r[e[i]];typeof o.cb=="function"&&o.cb(n)}}c(Lm,"cleanupRequests");function Av(t,e){let r=9,n=Buffer.allocUnsafe(31);V(n,n.length-4,0),n[4]=Ne.EXTENDED;let i=t._writeReqid=t._writeReqid+1&St;V(n,i,5),V(n,18,r),n.utf8Write("limits@openssh.com",r+=4,18),t._requests[i]={extended:"limits@openssh.com",cb:e};let o=lt(t,n);if(t._debug){let s=o?"Buffered":"Sending";t._debug(`SFTP: Outbound: ${s} limits@openssh.com`)}}c(Av,"requestLimits");var Ev={[Tr.VERSION]:(t,e)=>{if(t._version!==-1)return yt(t,"Duplicate VERSION packet");let r={};U.init(e,1);let n=U.readUInt32BE();for(;U.avail();){let i=U.readString(!0),o=U.readString(!0);if(o===void 0){n=void 0;break}r[i]=o}if(U.clear(),n===void 0)return yt(t,"Malformed VERSION packet");if(t._debug){let i=Object.keys(r);i.length?t._debug(`SFTP: Inbound: Received VERSION (v${n}, exts:${i})`):t._debug(`SFTP: Inbound: Received VERSION (v${n})`)}if(t._version=n,t._extensions=r,r["limits@openssh.com"]==="1")return Av(t,(i,o)=>{i||(o.maxPktLen>0&&(t._maxOutPktLen=o.maxPktLen),o.maxReadLen>0&&(t._maxReadLen=o.maxReadLen),o.maxWriteLen>0&&(t._maxWriteLen=o.maxWriteLen),t.maxOpenHandles=o.maxOpenHandles>0?o.maxOpenHandles:1/0),t.emit("ready")});t.emit("ready")},[Tr.STATUS]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readUInt32BE(),i=U.readString(!0);if(U.clear(),t._debug){let s=JSON.stringify(i);t._debug(`SFTP: Inbound: Received STATUS (id:${r}, ${n}, ${s})`)}let o=t._requests[r];if(delete t._requests[r],o&&typeof o.cb=="function"){if(n===ht.OK){o.cb();return}let s=new Error(i||dv[n]||"Unknown status");s.code=n,o.cb(s)}},[Tr.HANDLE]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0)return r!==void 0&&delete t._requests[r],yt(t,"Malformed HANDLE packet");t._debug&&t._debug(`SFTP: Inbound: Received HANDLE (id:${r})`);let i=t._requests[r];delete t._requests[r],i&&typeof i.cb=="function"&&i.cb(void 0,n)},[Tr.DATA]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n;if(r!==void 0&&(n=t._requests[r],delete t._requests[r]),n&&typeof n.cb=="function")if(n.buffer){let i=U.readString(n.buffer);if(U.clear(),i!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received DATA (id:${r}, ${i})`),n.cb(void 0,n.buffer,i);return}}else{let i=U.readString();if(U.clear(),i!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received DATA (id:${r}, ${i.length})`),n.cb(void 0,i);return}}else{let i=U.skipString();if(U.clear(),i!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received DATA (id:${r}, ${i})`);return}}return yt(t,"Malformed DATA packet")},[Tr.NAME]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n;r!==void 0&&(n=t._requests[r],delete t._requests[r]);let i=U.readUInt32BE();if(i!==void 0){let o=[];for(let s=0;s<i;++s){let a=U.readString(!0),u=U.readString(!0),l=ro(t._biOpt);if(l===void 0){o=void 0;break}o.push({filename:a,longname:u,attrs:l})}if(o!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received NAME (id:${r}, ${o.length})`),U.clear(),n&&typeof n.cb=="function"&&n.cb(void 0,o);return}}return U.clear(),yt(t,"Malformed NAME packet")},[Tr.ATTRS]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n;r!==void 0&&(n=t._requests[r],delete t._requests[r]);let i=ro(t._biOpt);if(U.clear(),i!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received ATTRS (id:${r})`),n&&typeof n.cb=="function"&&n.cb(void 0,i);return}return yt(t,"Malformed ATTRS packet")},[Tr.EXTENDED]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE();if(r!==void 0){let n=t._requests[r];if(n)switch(delete t._requests[r],n.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let i=t._biOpt,o={f_bsize:U.readUInt64BE(i),f_frsize:U.readUInt64BE(i),f_blocks:U.readUInt64BE(i),f_bfree:U.readUInt64BE(i),f_bavail:U.readUInt64BE(i),f_files:U.readUInt64BE(i),f_ffree:U.readUInt64BE(i),f_favail:U.readUInt64BE(i),f_sid:U.readUInt64BE(i),f_flag:U.readUInt64BE(i),f_namemax:U.readUInt64BE(i)};if(o.f_namemax===void 0)break;t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ${n.extended})`),U.clear(),typeof n.cb=="function"&&n.cb(void 0,o);return}case"limits@openssh.com":{let i={maxPktLen:U.readUInt64BE(),maxReadLen:U.readUInt64BE(),maxWriteLen:U.readUInt64BE(),maxOpenHandles:U.readUInt64BE()};if(i.maxOpenHandles===void 0)break;t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ${n.extended})`),U.clear(),typeof n.cb=="function"&&n.cb(void 0,i);return}case"users-groups-by-id@openssh.com":{let i=U.readUInt32BE();if(i===void 0)break;let o=new Array(i);for(let u=0;u<o.length;++u)o[u]=U.readString(!0);let s=U.readUInt32BE();if(s===void 0)break;let a=new Array(s);for(let u=0;u<a.length;++u)a[u]=U.readString(!0);if(a.length>0&&a[a.length-1]===void 0)break;t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ${n.extended})`),U.clear(),typeof n.cb=="function"&&n.cb(void 0,o,a);return}default:t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ???)`),U.clear(),typeof n.cb=="function"&&n.cb();return}else{t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ???)`),U.clear();return}}return U.clear(),yt(t,"Malformed EXTENDED_REPLY packet")}},bv={[Ne.INIT]:(t,e)=>{if(t._version!==-1)return yt(t,"Duplicate INIT packet");let r={};U.init(e,1);let n=U.readUInt32BE();for(;U.avail();){let i=U.readString(!0),o=U.readString(!0);if(o===void 0){n=void 0;break}r[i]=o}if(U.clear(),n===void 0)return yt(t,"Malformed INIT packet");if(t._debug){let i=Object.keys(r);i.length?t._debug(`SFTP: Inbound: Received INIT (v${n}, exts:${i})`):t._debug(`SFTP: Inbound: Received INIT (v${n})`)}lt(t,hv),t._version=n,t._extensions=r,t.emit("ready")},[Ne.OPEN]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=U.readUInt32BE(),o=ro(t._biOpt);if(U.clear(),o===void 0)return yt(t,"Malformed OPEN packet");t._debug&&t._debug(`SFTP: Inbound: Received OPEN (id:${r})`),t.emit("OPEN",r,n,i,o)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.CLOSE]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0||n.length>256)return yt(t,"Malformed CLOSE packet");t._debug&&t._debug(`SFTP: Inbound: Received CLOSE (id:${r})`),t.emit("CLOSE",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.READ]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(),i=U.readUInt64BE(t._biOpt),o=U.readUInt32BE();if(U.clear(),o===void 0||n.length>256)return yt(t,"Malformed READ packet");t._debug&&t._debug(`SFTP: Inbound: Received READ (id:${r})`),t.emit("READ",r,n,i,o)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.WRITE]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(),i=U.readUInt64BE(t._biOpt),o=U.readString();if(U.clear(),o===void 0||n.length>256)return yt(t,"Malformed WRITE packet");t._debug&&t._debug(`SFTP: Inbound: Received WRITE (id:${r})`),t.emit("WRITE",r,n,i,o)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.LSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed LSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received LSTAT (id:${r})`),t.emit("LSTAT",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.FSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0||n.length>256)return yt(t,"Malformed FSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received FSTAT (id:${r})`),t.emit("FSTAT",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.SETSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=ro(t._biOpt);if(U.clear(),i===void 0)return yt(t,"Malformed SETSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received SETSTAT (id:${r})`),t.emit("SETSTAT",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.FSETSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(),i=ro(t._biOpt);if(U.clear(),i===void 0||n.length>256)return yt(t,"Malformed FSETSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received FSETSTAT (id:${r})`),t.emit("FSETSTAT",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.OPENDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed OPENDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received OPENDIR (id:${r})`),t.emit("OPENDIR",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.READDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0||n.length>256)return yt(t,"Malformed READDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received READDIR (id:${r})`),t.emit("READDIR",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.REMOVE]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed REMOVE packet");t._debug&&t._debug(`SFTP: Inbound: Received REMOVE (id:${r})`),t.emit("REMOVE",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.MKDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=ro(t._biOpt);if(U.clear(),i===void 0)return yt(t,"Malformed MKDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received MKDIR (id:${r})`),t.emit("MKDIR",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.RMDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed RMDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received RMDIR (id:${r})`),t.emit("RMDIR",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.REALPATH]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed REALPATH packet");t._debug&&t._debug(`SFTP: Inbound: Received REALPATH (id:${r})`),t.emit("REALPATH",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.STAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed STAT packet");t._debug&&t._debug(`SFTP: Inbound: Received STAT (id:${r})`),t.emit("STAT",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.RENAME]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=U.readString(!0);if(U.clear(),i===void 0)return yt(t,"Malformed RENAME packet");t._debug&&t._debug(`SFTP: Inbound: Received RENAME (id:${r})`),t.emit("RENAME",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.READLINK]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed READLINK packet");t._debug&&t._debug(`SFTP: Inbound: Received READLINK (id:${r})`),t.emit("READLINK",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.SYMLINK]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=U.readString(!0);if(U.clear(),i===void 0)return yt(t,"Malformed SYMLINK packet");t._debug&&t._debug(`SFTP: Inbound: Received SYMLINK (id:${r})`);let o;t._isOpenSSH?o=t.emit("SYMLINK",r,i,n):o=t.emit("SYMLINK",r,n,i),o||t.status(r,ht.OP_UNSUPPORTED)},[Ne.EXTENDED]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(n===void 0)return U.clear(),yt(t,"Malformed EXTENDED packet");let i;U.avail()&&(i=U.readRaw()),U.clear(),t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED (id:${r})`),t.emit("EXTENDED",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:xv,ERR_OUT_OF_RANGE:Za,validateNumber:Iv}=wm(),Cm=128,Ir,Vl=[];function vv(t){Vl.length>0?Ir=Vl.pop():Ir=Buffer.allocUnsafe(t),Ir.used=0}c(vv,"allocNewPool");function Gl(t,e){if(!Number.isSafeInteger(t))throw Iv(t,e),Number.isInteger(t)?new Za(e,">= 0 and <= 2 ** 53 - 1",t):new Za(e,"an integer",t);if(t<0)throw new Za(e,">= 0 and <= 2 ** 53 - 1",t)}c(Gl,"checkPosition");function jl(t){return t+7&-8}c(jl,"roundUpToMultipleOf8");function In(t,e,r){if(r===void 0)r={};else if(typeof r=="string")r={encoding:r};else{if(r===null||typeof r!="object")throw new TypeError('"options" argument must be a string or an object');r=Object.create(r)}if(r.highWaterMark===void 0&&(r.highWaterMark=64*1024),r.emitClose=!1,r.autoDestroy=!1,Nm.call(this,r),this.path=e,this.flags=r.flags===void 0?"r":r.flags,this.mode=r.mode===void 0?438:r.mode,this.start=r.start,this.end=r.end,this.autoClose=r.autoClose===void 0?!0:r.autoClose,this.pos=0,this.bytesRead=0,this.isClosed=!1,this.handle=r.handle===void 0?null:r.handle,this.sftp=t,this._opening=!1,this.start!==void 0&&(Gl(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(Gl(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new Za("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}c(In,"ReadStream");Om(In,Nm);In.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(t,e)=>{if(this._opening=!1,t){this.emit("error",t),this.autoClose&&this.destroy();return}this.handle=e,this.emit("open",e),this.emit("ready"),this.read()}))};In.prototype._read=function(t){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(t));if(this.destroyed)return;(!Ir||Ir.length-Ir.used<Cm)&&vv(this.readableHighWaterMark||this._readableState.highWaterMark);let e=Ir,r=Math.min(Ir.length-Ir.used,t),n=Ir.used;if(this.end!==void 0&&(r=Math.min(this.end-this.pos+1,r)),r<=0)return this.push(null);this.sftp.read(this.handle,Ir,Ir.used,r,this.pos,(i,o)=>{if(i){this.emit("error",i),this.autoClose&&this.destroy();return}let s=null;if(n+r===e.used&&e===Ir)e.used=jl(e.used+o-r);else{let a=n+r&-8,u=jl(n+o);a-u>=Cm&&Vl.push(e.slice(u,a))}o>0&&(this.bytesRead+=o,s=e.slice(n,n+o)),this.pos+=o,this.push(s)}),Ir.used=jl(Ir.used+r)};In.prototype._destroy=function(t,e){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",Rm.bind(null,this,e,t));return}Rm(this,e,t),this.handle=null,this._opening=!1};function Rm(t,e,r){if(!t.handle)return n();t.sftp.close(t.handle,n);function n(i){i=i||r,e(i),t.isClosed=!0,i||t.emit("close")}c(n,"onclose")}c(Rm,"closeStream");In.prototype.close=function(t){this.destroy(null,t)};Object.defineProperty(In.prototype,"pending",{get(){return this.handle===null},configurable:!0});function Fr(t,e,r){if(r===void 0)r={};else if(typeof r=="string")r={encoding:r};else{if(r===null||typeof r!="object")throw new TypeError('"options" argument must be a string or an object');r=Object.create(r)}r.emitClose=!1,r.autoDestroy=!1,Zl.call(this,r),this.path=e,this.flags=r.flags===void 0?"w":r.flags,this.mode=r.mode===void 0?438:r.mode,this.start=r.start,this.autoClose=r.autoClose===void 0?!0:r.autoClose,this.pos=0,this.bytesWritten=0,this.isClosed=!1,this.handle=r.handle===void 0?null:r.handle,this.sftp=t,this._opening=!1,this.start!==void 0&&(Gl(this.start,"start"),this.pos=this.start),r.encoding&&this.setDefaultEncoding(r.encoding),this.on("finish",function(){this._writableState.finalCalled||this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}c(Fr,"WriteStream");Om(Fr,Zl);Fr.prototype._final=function(t){this.autoClose&&this.destroy(),t()};Fr.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(t,e)=>{if(this._opening=!1,t){this.emit("error",t),this.autoClose&&this.destroy();return}this.handle=e;let r=c(n=>{if(n){this.sftp.chmod(this.path,this.mode,i=>r());return}if(this.flags[0]==="a"){let i=c((o,s)=>{if(o){this.sftp.stat(this.path,(a,u)=>{if(a){this.destroy(),this.emit("error",o);return}i(null,u)});return}this.pos=s.size,this.emit("open",e),this.emit("ready")},"tryStat");this.sftp.fstat(e,i);return}this.emit("open",e),this.emit("ready")},"tryAgain");this.sftp.fchmod(e,this.mode,r)}))};Fr.prototype._write=function(t,e,r){if(!Buffer.isBuffer(t)){let n=new xv("data","Buffer",t);return this.emit("error",n)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(t,e,r)});this.sftp.write(this.handle,t,0,t.length,this.pos,(n,i)=>{if(n)return this.autoClose&&this.destroy(),r(n);this.bytesWritten+=i,r()}),this.pos+=t.length};Fr.prototype._writev=function(t,e){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(t,e)});let r=this.sftp,n=this.handle,i=t.length,o=c((s,a)=>{if(s)return this.destroy(),e(s);this.bytesWritten+=a,--i===0&&e()},"onwrite");for(let s=0;s<t.length;++s){let a=t[s].chunk;r.write(n,a,0,a.length,this.pos,o),this.pos+=a.length}};typeof Zl.prototype.destroy!="function"&&(Fr.prototype.destroy=In.prototype.destroy);Fr.prototype._destroy=In.prototype._destroy;Fr.prototype.close=function(t){if(t){if(this.isClosed){process.nextTick(t);return}this.on("close",t)}this.autoClose||this.on("finish",this.destroy.bind(this)),this.end()};Fr.prototype.destroySoon=Fr.prototype.end;Object.defineProperty(Fr.prototype,"pending",{get(){return this.handle===null},configurable:!0});zm.exports={flagsToString:yv,OPEN_MODE:Te,SFTP:ql,Stats:Ya,STATUS_CODE:ht,stringToFlags:Bm}});var nf=le((tF,jm)=>{"use strict";var{Duplex:Sv,Readable:wv,Writable:Pv}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:Mm}}=An(),{bufferSlice:Xa}=Qr(),Tv=32*1024,ps=2*1024*1024,tf=ps/2,Xl=class extends wv{static{c(this,"ClientStderr")}constructor(e,r){super(r),this._channel=e}_read(e){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=tf&&rf(this._channel))}},Jl=class extends Pv{static{c(this,"ServerStderr")}constructor(e){super({highWaterMark:ps}),this._channel=e}_write(e,r,n){let i=this._channel,o=i._client._protocol,s=i.outgoing,a=s.packetSize,u=s.id,l=s.window,d=e.length,p=0;if(s.state==="open"){for(;d-p>0&&l>0;){let g=d-p;g>l&&(g=l),g>a&&(g=a),p===0&&g===d?o.channelExtData(u,e,Mm):o.channelExtData(u,Xa(e,p,p+g),Mm),p+=g,l-=g}if(s.window=l,d-p>0){l===0&&(i._waitWindow=!0),p>0?i._chunkErr=Xa(e,p,d):i._chunkErr=e,i._chunkcbErr=n;return}n()}}},ef=class extends Sv{static{c(this,"Channel")}constructor(e,r,n){let i={highWaterMark:ps,allowHalfOpen:!n||n&&n.allowHalfOpen!==!1,emitClose:!1};super(i),this.allowHalfOpen=i.allowHalfOpen;let o=!!(n&&n.server);this.server=o,this.type=r.type,this.subtype=void 0,this.incoming=r.incoming,this.outgoing=r.outgoing,this._callbacks=[],this._client=e,this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this.stdin=this.stdout=this,o?this.stderr=new Jl(this):this.stderr=new Xl(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",Fm).on("prefinish",Fm),this.on("end",Hm).on("close",Hm)}_read(e){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=tf&&rf(this))}_write(e,r,n){let i=this._client._protocol,o=this.outgoing,s=o.packetSize,a=o.id,u=o.window,l=e.length,d=0;if(o.state==="open"){for(;l-d>0&&u>0;){let p=l-d;p>u&&(p=u),p>s&&(p=s),d===0&&p===l?i.channelData(a,e):i.channelData(a,Xa(e,d,d+p)),d+=p,u-=p}if(o.window=u,l-d>0){u===0&&(this._waitWindow=!0),d>0?this._chunk=Xa(e,d,l):this._chunk=e,this._chunkcb=n;return}n()}}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(e,r,n,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,e,r,n,i)}signal(e){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,e)}exit(e,r,n){if(!this.server)throw new Error("Server-only method called in client mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&(typeof e=="number"?this._client._protocol.exitStatus(this.outgoing.id,e):this._client._protocol.exitSignal(this.outgoing.id,e,r,n))}};function Fm(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}c(Fm,"onFinish");function Hm(){this.readable=!1}c(Hm,"onEnd");function rf(t){if(t.outgoing.state==="closed")return;let e=ps-t.incoming.window;e<=0||(t.incoming.window+=e,t._client._protocol.channelWindowAdjust(t.outgoing.id,e))}c(rf,"windowAdjust");jm.exports={Channel:ef,MAX_WINDOW:ps,PACKET_SIZE:Tv,windowAdjust:rf,WINDOW_THRESHOLD:tf}});var af=le((nF,Qm)=>{"use strict";var{SFTP:kv}=ds(),hs=2**32-1;function Wm(t,e,r,n){if(t._chanMgr.remove(e),typeof n!="function")return;let i;r instanceof Error?i=r:typeof r=="object"&&r!==null?(i=new Error(`(SSH) Channel open failure: ${r.description}`),i.reason=r.reason):(i=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),i.reason=""),n(i)}c(Wm,"onChannelOpenFailure");function qm(t,e,r,n,i){if(typeof r=="function"){Wm(t,e,n,r);return}if(typeof r!="object"||r===null||r.incoming&&r.incoming.state==="closed"||(t._chanMgr.remove(e),r.server&&r.constructor.name==="Session"))return;r.incoming.state="closed",r.readable&&r.push(null),r.server?r.stderr.writable&&r.stderr.end():r.stderr.readable&&r.stderr.push(null),r.constructor!==kv&&(r.outgoing.state==="open"||r.outgoing.state==="eof")&&!i&&r.close(),r.outgoing.state==="closing"&&(r.outgoing.state="closed");let o=r._readableState,s=r._writableState;s&&!s.ending&&!s.finished&&!i&&r.end();let a=r._callbacks;r._callbacks=[];for(let u=0;u<a.length;++u)a[u](!0);if(r.server)!r.readable||r.destroyed||o&&o.endEmitted?r.emit("close"):r.once("end",()=>r.emit("close"));else{let u;switch(r.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":u=c(()=>r.emit("close"),"doClose");break;default:{let d=r._exit;u=c(()=>{d.code===null?r.emit("close",d.code,d.signal,d.dump,d.desc):r.emit("close",d.code)},"doClose")}}!r.readable||r.destroyed||o&&o.endEmitted?u():r.once("end",u);let l=r.stderr._readableState;!r.stderr.readable||r.stderr.destroyed||l&&l.endEmitted?r.stderr.emit("close"):r.stderr.once("end",()=>r.stderr.emit("close"))}}c(qm,"onCHANNEL_CLOSE");var sf=class{static{c(this,"ChannelManager")}constructor(e){this._client=e,this._channels={},this._cur=-1,this._count=0}add(e){let r;if(this._cur<hs)r=++this._cur;else if(this._count===0)this._cur=0,r=0;else{let n=this._channels;for(let i=0;i<hs;++i)if(n[i]===void 0){r=i;break}}return r===void 0?-1:(this._channels[r]=e||!0,++this._count,r)}update(e,r){if(typeof e!="number"||e<0||e>=hs||!isFinite(e))throw new Error(`Invalid channel id: ${e}`);r&&this._channels[e]&&(this._channels[e]=r)}get(e){if(typeof e!="number"||e<0||e>=hs||!isFinite(e))throw new Error(`Invalid channel id: ${e}`);return this._channels[e]}remove(e){if(typeof e!="number"||e<0||e>=hs||!isFinite(e))throw new Error(`Invalid channel id: ${e}`);this._channels[e]&&(delete this._channels[e],this._count&&--this._count)}cleanup(e){let r=this._channels;this._channels={},this._cur=-1,this._count=0;let n=Object.keys(r),i=this._client;for(let o=0;o<n.length;++o){let s=+n[o],a=r[s];qm(i,s,a._channel||a,e,!0)}}},of=(()=>{let t=Object.prototype.toString;return e=>t.call(e)==="[object RegExp]"})();function Cv(t,e,r){if(Array.isArray(t)&&t.length>0){for(let n=0;n<t.length;++n)if(r.indexOf(t[n])===-1)throw new Error(`Unsupported algorithm: ${t[n]}`);return t}if(typeof t=="object"&&t!==null){let n=Object.keys(t),i=e;for(let o=0;o<n.length;++o){let s=n[o],a=t[s];switch(s){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let u=0;u<a.length;++u){let l=a[u];if(typeof l=="string"){if(!l||i.indexOf(l)!==-1)continue;if(r.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);i===e&&(i=i.slice()),i.push(l)}else if(of(l))for(let d=0;d<r.length;++d){let p=r[d];if(l.test(p)){if(i.indexOf(p)!==-1)continue;i===e&&(i=i.slice()),i.push(p)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let u=a.length;u>=0;--u){let l=a[u];if(typeof l=="string"){if(!l||i.indexOf(l)!==-1)continue;if(r.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);i===e&&(i=i.slice()),i.unshift(l)}else if(of(l))for(let d=r.length;d>=0;--d){let p=r[d];if(l.test(p)){if(i.indexOf(p)!==-1)continue;i===e&&(i=i.slice()),i.unshift(p)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let u=0;u<a.length;++u){let l=a[u];if(typeof l=="string"){if(!l)continue;let d=i.indexOf(l);if(d===-1)continue;i===e&&(i=i.slice()),i.splice(d,1)}else if(of(l))for(let d=0;d<i.length;++d)l.test(i[d])&&(i===e&&(i=i.slice()),i.splice(d,1),--d)}break}}return i}return e}c(Cv,"generateAlgorithmList");Qm.exports={ChannelManager:sf,generateAlgorithmList:Cv,onChannelOpenFailure:Wm,onCHANNEL_CLOSE:qm,isWritable:c(t=>t&&t.writable&&t._readableState&&t._readableState.ended===!1,"isWritable")}});var df=le((oF,h_)=>{"use strict";var{createHash:Rv,getHashes:Nv,randomFillSync:Ov}=require("crypto"),{Socket:$v}=require("net"),{lookup:Dv}=require("dns"),Bv=require("events"),Uv=Nv(),{COMPAT:f_,CHANNEL_EXTENDED_DATATYPE:{STDERR:Lv},CHANNEL_OPEN_FAILURE:gs,DEFAULT_CIPHER:Km,DEFAULT_COMPRESSION:Vm,DEFAULT_KEX:Gm,DEFAULT_MAC:Zm,DEFAULT_SERVER_HOST_KEY:Ym,DISCONNECT_REASON:Xm,DISCONNECT_REASON_BY_VALUE:zv,SUPPORTED_CIPHER:Mv,SUPPORTED_COMPRESSION:Fv,SUPPORTED_KEX:Hv,SUPPORTED_MAC:jv,SUPPORTED_SERVER_HOST_KEY:Wv}=An(),{init:qv}=Ln(),Qv=Fl(),{parseKey:tc}=Fn(),{SFTP:Kv}=ds(),{bufferCopy:Jm,makeBufferParser:d_,makeError:Vv,readUInt32BE:Gv,sigSSHToASN1:Zv,writeUInt32BE:cf}=Qr(),{AgentContext:e_,createAgent:t_,isAgent:r_}=wl(),{Channel:p_,MAX_WINDOW:rc,PACKET_SIZE:nc,windowAdjust:n_,WINDOW_THRESHOLD:i_}=nf(),{ChannelManager:Yv,generateAlgorithmList:ms,isWritable:rr,onChannelOpenFailure:Xv,onCHANNEL_CLOSE:Jv}=af(),Ja=d_(),ec=d_(),_s=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,lf=c(t=>{},"noop"),ff=class extends Bv{static{c(this,"Client")}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(e){if(this._sock&&rr(this._sock))return this.once("close",()=>{this.connect(e)}),this.end(),this;this.config.host=e.hostname||e.host||"localhost",this.config.port=e.port||22,this.config.localAddress=typeof e.localAddress=="string"?e.localAddress:void 0,this.config.localPort=typeof e.localPort=="string"||typeof e.localPort=="number"?e.localPort:void 0,this.config.forceIPv4=e.forceIPv4||!1,this.config.forceIPv6=e.forceIPv6||!1,this.config.keepaliveCountMax=typeof e.keepaliveCountMax=="number"&&e.keepaliveCountMax>=0?e.keepaliveCountMax:3,this.config.keepaliveInterval=typeof e.keepaliveInterval=="number"&&e.keepaliveInterval>0?e.keepaliveInterval:0,this.config.readyTimeout=typeof e.readyTimeout=="number"&&e.readyTimeout>=0?e.readyTimeout:2e4,this.config.ident=typeof e.ident=="string"||Buffer.isBuffer(e.ident)?e.ident:void 0;let r={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:[]},sc:void 0},n=!0;if(typeof e.algorithms=="object"&&e.algorithms!==null&&(r.kex=ms(e.algorithms.kex,Gm,Hv),r.kex!==Gm&&(n=!1),r.serverHostKey=ms(e.algorithms.serverHostKey,Ym,Wv),r.serverHostKey!==Ym&&(n=!1),r.cs.cipher=ms(e.algorithms.cipher,Km,Mv),r.cs.cipher!==Km&&(n=!1),r.cs.mac=ms(e.algorithms.hmac,Zm,jv),r.cs.mac!==Zm&&(n=!1),r.cs.compress=ms(e.algorithms.compress,Vm,Fv),r.cs.compress!==Vm&&(n=!1),n||(r.sc=r.cs)),typeof e.username=="string")this.config.username=e.username;else if(typeof e.user=="string")this.config.username=e.user;else throw new Error("Invalid username");this.config.password=typeof e.password=="string"?e.password:void 0,this.config.privateKey=typeof e.privateKey=="string"||Buffer.isBuffer(e.privateKey)?e.privateKey:void 0,this.config.localHostname=typeof e.localHostname=="string"?e.localHostname:void 0,this.config.localUsername=typeof e.localUsername=="string"?e.localUsername:void 0,this.config.tryKeyboard=e.tryKeyboard===!0,typeof e.agent=="string"&&e.agent.length?this.config.agent=t_(e.agent):r_(e.agent)?this.config.agent=e.agent:this.config.agent=void 0,this.config.allowAgentFwd=e.agentForward===!0&&this.config.agent!==void 0;let i=this.config.authHandler=typeof e.authHandler=="function"||Array.isArray(e.authHandler)?e.authHandler:void 0;this.config.strictVendor=typeof e.strictVendor=="boolean"?e.strictVendor:!0;let o=this.config.debug=typeof e.debug=="function"?e.debug:void 0;if(e.agentForward===!0&&!this.config.allowAgentFwd)throw new Error("You must set a valid agent path to allow agent forwarding");let s=this._callbacks=[];this._chanMgr=new Yv(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 a;if(this.config.privateKey){if(a=tc(this.config.privateKey,e.passphrase),a instanceof Error)throw new Error(`Cannot parse privateKey: ${a.message}`);if(Array.isArray(a)&&(a=a[0]),a.getPrivatePEM()===null)throw new Error("privateKey value does not contain a (valid) private key")}let u;if(typeof e.hostVerifier=="function"){let C=e.hostVerifier,W;Uv.indexOf(e.hostHash)!==-1&&(W=e.hostHash),u=c((q,J)=>{W&&(q=Rv(W).update(q).digest("hex"));let ue=C(q,J);ue!==void 0&&J(ue)},"hostVerifier")}let l=this._sock=e.sock||new $v,d=!1,p=!1;this._protocol&&this._protocol.cleanup();let g=o?(C,W,q)=>{o(`Debug output from server: ${JSON.stringify(q)}`)}:void 0,h,_=this._protocol=new Qv({ident:this.config.ident,offer:n?void 0:r,onWrite:c(C=>{rr(l)&&l.write(C)},"onWrite"),onError:c(C=>{C.level==="handshake"&&clearTimeout(this._readyTimeout),_._destruct||l.removeAllListeners("data"),this.emit("error",C);try{l.end()}catch{}},"onError"),onHeader:c(C=>{p=!0,this._remoteVer=C.versions.software,C.greeting&&this.emit("greeting",C.greeting)},"onHeader"),onHandshakeComplete:c(C=>{this.emit("handshake",C),d||(d=!0,_.service("ssh-userauth"))},"onHandshakeComplete"),debug:o,hostVerifier:u,messageHandlers:{DEBUG:g,DISCONNECT:c((C,W,q)=>{if(W!==Xm.BY_APPLICATION){q||(q=zv[W],q===void 0&&(q=`Unexpected disconnection reason: ${W}`));let J=new Error(q);J.code=W,this.emit("error",J)}l.end()},"DISCONNECT"),SERVICE_ACCEPT:c((C,W)=>{W==="ssh-userauth"&&B()},"SERVICE_ACCEPT"),EXT_INFO:c((C,W)=>{if(h===void 0){for(let q of W)if(q.name==="server-sig-algs"){h=q.algs;return}h=null}},"EXT_INFO"),USERAUTH_BANNER:c((C,W)=>{this.emit("banner",W)},"USERAUTH_BANNER"),USERAUTH_SUCCESS:c(C=>{$(),clearTimeout(this._readyTimeout),this.emit("ready")},"USERAUTH_SUCCESS"),USERAUTH_FAILURE:c((C,W,q)=>{if(P.keyAlgos){let J=P.keyAlgos[0][0];if(o&&o(`Client: ${P.type} (${J}) auth failed`),P.keyAlgos.shift(),P.keyAlgos.length){let[ue,me]=P.keyAlgos[0];switch(P.type){case"agent":_.authPK(P.username,P.agentCtx.currentKey(),ue);return;case"publickey":_.authPK(P.username,P.key,ue);return;case"hostbased":_.authHostbased(P.username,P.key,P.localHostname,P.localUsername,ue,(he,bt)=>{let Ct=P.key.sign(he,me);if(Ct instanceof Error)return Ct.message=`Error while signing with key: ${Ct.message}`,Ct.level="client-authentication",this.emit("error",Ct),B();bt(Ct)});return}}else P.keyAlgos=void 0}if(P.type==="agent"){let J=P.agentCtx.pos();return o&&o(`Client: Agent key #${J+1} failed`),G()}o&&o(`Client: ${P.type} auth failed`),k=q,M=W,B()},"USERAUTH_FAILURE"),USERAUTH_PASSWD_CHANGEREQ:c((C,W)=>{P.type==="password"&&this.emit("change password",W,q=>{_.authPassword(this.config.username,this.config.password,q)})},"USERAUTH_PASSWD_CHANGEREQ"),USERAUTH_PK_OK:c(C=>{let W,q;if(P.keyAlgos&&([W,q]=P.keyAlgos[0]),P.type==="agent"){let J=P.agentCtx.currentKey();_.authPK(P.username,J,W,(ue,me)=>{let he={hash:q};P.agentCtx.sign(J,ue,he,(bt,Ct)=>{if(bt)bt.level="agent",this.emit("error",bt);else return me(Ct);G()})})}else P.type==="publickey"&&_.authPK(P.username,P.key,W,(J,ue)=>{let me=P.key.sign(J,q);if(me instanceof Error)return me.message=`Error signing data with key: ${me.message}`,me.level="client-authentication",this.emit("error",me),B();ue(me)})},"USERAUTH_PK_OK"),USERAUTH_INFO_REQUEST:c((C,W,q,J)=>{if(P.type==="keyboard-interactive"){if((Array.isArray(J)?J.length:0)===0){o&&o("Client: Sending automatic USERAUTH_INFO_RESPONSE"),_.authInfoRes();return}P.prompt(W,q,"",J,me=>{_.authInfoRes(me)})}},"USERAUTH_INFO_REQUEST"),REQUEST_SUCCESS:c((C,W)=>{s.length&&s.shift()(!1,W)},"REQUEST_SUCCESS"),REQUEST_FAILURE:c(C=>{s.length&&s.shift()(!0)},"REQUEST_FAILURE"),GLOBAL_REQUEST:c((C,W,q,J)=>{W==="hostkeys-00@openssh.com"?(iS(this,J,(ue,me)=>{ue||this.emit("hostkeys",me)}),q&&_.requestSuccess()):q&&_.requestFailure()},"GLOBAL_REQUEST"),CHANNEL_OPEN:c((C,W)=>{rS(this,W)},"CHANNEL_OPEN"),CHANNEL_OPEN_CONFIRMATION:c((C,W)=>{let q=this._chanMgr.get(W.recipient);if(typeof q!="function")return;let J=q.type==="sftp",me={type:J?"session":q.type,incoming:{id:W.recipient,window:rc,packetSize:nc,state:"open"},outgoing:{id:W.sender,window:W.window,packetSize:W.packetSize,state:"open"}},he=J?new Kv(this,me,{debug:o}):new p_(this,me);this._chanMgr.update(W.recipient,he),q(void 0,he)},"CHANNEL_OPEN_CONFIRMATION"),CHANNEL_OPEN_FAILURE:c((C,W,q,J)=>{let ue=this._chanMgr.get(W);if(typeof ue!="function")return;Xv(this,W,{reason:q,description:J},ue)},"CHANNEL_OPEN_FAILURE"),CHANNEL_DATA:c((C,W,q)=>{let J=this._chanMgr.get(W);if(!(typeof J!="object"||J===null)&&J.incoming.window!==0){if(J.incoming.window-=q.length,J.push(q)===!1){J._waitChanDrain=!0;return}J.incoming.window<=i_&&n_(J)}},"CHANNEL_DATA"),CHANNEL_EXTENDED_DATA:c((C,W,q,J)=>{if(J!==Lv)return;let ue=this._chanMgr.get(W);if(!(typeof ue!="object"||ue===null)&&ue.incoming.window!==0){if(ue.incoming.window-=q.length,!ue.stderr.push(q)){ue._waitChanDrain=!0;return}ue.incoming.window<=i_&&n_(ue)}},"CHANNEL_EXTENDED_DATA"),CHANNEL_WINDOW_ADJUST:c((C,W,q)=>{let J=this._chanMgr.get(W);typeof J!="object"||J===null||(J.outgoing.window+=q,J._waitWindow&&(J._waitWindow=!1,J._chunk?J._write(J._chunk,null,J._chunkcb):J._chunkcb?J._chunkcb():J._chunkErr?J.stderr._write(J._chunkErr,null,J._chunkcbErr):J._chunkcbErr&&J._chunkcbErr()))},"CHANNEL_WINDOW_ADJUST"),CHANNEL_SUCCESS:c((C,W)=>{let q=this._chanMgr.get(W);typeof q!="object"||q===null||(this._resetKA(),q._callbacks.length&&q._callbacks.shift()(!1))},"CHANNEL_SUCCESS"),CHANNEL_FAILURE:c((C,W)=>{let q=this._chanMgr.get(W);typeof q!="object"||q===null||(this._resetKA(),q._callbacks.length&&q._callbacks.shift()(!0))},"CHANNEL_FAILURE"),CHANNEL_REQUEST:c((C,W,q,J,ue)=>{let me=this._chanMgr.get(W);if(typeof me!="object"||me===null)return;let he=me._exit;if(he.code===void 0){switch(q){case"exit-status":me.emit("exit",he.code=ue);return;case"exit-signal":me.emit("exit",he.code=null,he.signal=`SIG${ue.signal}`,he.dump=ue.coreDumped,he.desc=ue.errorMessage);return}J&&C.channelFailure(me.outgoing.id)}},"CHANNEL_REQUEST"),CHANNEL_EOF:c((C,W)=>{let q=this._chanMgr.get(W);typeof q!="object"||q===null||q.incoming.state==="open"&&(q.incoming.state="eof",q.readable&&q.push(null),q.stderr.readable&&q.stderr.push(null))},"CHANNEL_EOF"),CHANNEL_CLOSE:c((C,W)=>{Jv(this,W,this._chanMgr.get(W))},"CHANNEL_CLOSE")}});l.pause();let E=this.config.keepaliveInterval,b=this.config.keepaliveCountMax,I=0,w,H=c(()=>{if(++I>b){if(clearInterval(w),l.readable){let C=new Error("Keepalive timeout");C.level="client-timeout",this.emit("error",C),l.destroy()}return}rr(l)?(s.push($),_.ping()):clearInterval(w)},"sendKA");function $(){E>0&&(I=0,clearInterval(w),rr(l)&&(w=setInterval(H,E)))}c($,"resetKA"),this._resetKA=$;let X=(()=>{let C=!1;return()=>{if(!C&&(C=!0,Y&&!p)){let W=Vv("Connection lost before handshake","protocol",!0);this.emit("error",W)}}})(),Z=(()=>{let C=!1;return()=>{C||(C=!0,Y=!0,o&&o("Socket connected"),this.emit("connect"),qv.then(()=>{_.start(),l.on("data",W=>{try{_.parse(W,0,W.length)}catch(q){this.emit("error",q);try{rr(l)&&l.end()}catch{}}}),l.stderr&&typeof l.stderr.resume=="function"&&l.stderr.resume(),l.resume()}).catch(W=>{this.emit("error",W);try{rr(l)&&l.end()}catch{}}))}})(),Y=!1;l.on("connect",Z).on("timeout",()=>{this.emit("timeout")}).on("error",C=>{o&&o(`Socket error: ${C.message}`),clearTimeout(this._readyTimeout),C.level="client-socket",this.emit("error",C)}).on("end",()=>{o&&o("Socket ended"),X(),_.cleanup(),clearTimeout(this._readyTimeout),clearInterval(w),this.emit("end")}).on("close",()=>{o&&o("Socket closed"),X(),_.cleanup(),clearTimeout(this._readyTimeout),clearInterval(w),this.emit("close");let C=s;s=this._callbacks=[];let W=new Error("No response from server");for(let q=0;q<C.length;++q)C[q](W);this._chanMgr.cleanup(W)});let P,k=null,M=null,L=["none"];this.config.password!==void 0&&L.push("password"),a!==void 0&&L.push("publickey"),this._agent!==void 0&&L.push("agent"),this.config.tryKeyboard&&L.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&L.push("hostbased"),Array.isArray(i)?i=l_(i):typeof i!="function"&&(i=l_(L));let T=!1,F=c(C=>{if(!T){if(T=!0,C===!1){let W=new Error("All configured authentication methods failed");W.level="client-authentication",this.emit("error",W),this.end();return}if(typeof C=="string"){let W=C;if(L.indexOf(W)===-1)return j(`Authentication method not allowed: ${W}`);let q=this.config.username;switch(W){case"password":C={type:W,username:q,password:this.config.password};break;case"publickey":C={type:W,username:q,key:a};break;case"hostbased":C={type:W,username:q,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":C={type:W,username:q,agentCtx:new e_(this._agent)};break;case"keyboard-interactive":C={type:W,username:q,prompt:c((...J)=>this.emit("keyboard-interactive",...J),"prompt")};break;case"none":C={type:W,username:q};break;default:return j(`Skipping unsupported authentication method: ${C}`)}}else{if(typeof C!="object"||C===null)return j(`Skipping invalid authentication attempt: ${C}`);{let W=C.username;if(typeof W!="string")return j(`Skipping invalid authentication attempt: ${C}`);let q=C.type;switch(q){case"password":{let{password:J}=C;if(typeof J!="string"&&!Buffer.isBuffer(J))return j("Skipping invalid password auth attempt");C={type:q,username:W,password:J};break}case"publickey":{let J=tc(C.key,C.passphrase);if(J instanceof Error)return j("Skipping invalid key auth attempt");if(!J.isPrivateKey())return j("Skipping non-private key");C={type:q,username:W,key:J};break}case"hostbased":{let{localHostname:J,localUsername:ue}=C,me=tc(C.key,C.passphrase);if(me instanceof Error||typeof J!="string"||typeof ue!="string")return j("Skipping invalid hostbased auth attempt");if(!me.isPrivateKey())return j("Skipping non-private key");C={type:q,username:W,key:me,localHostname:J,localUsername:ue};break}case"agent":{let J=C.agent;if(typeof J=="string"&&J.length)J=t_(J);else if(!r_(J))return j(`Skipping invalid agent: ${C.agent}`);C={type:q,username:W,agentCtx:new e_(J)};break}case"keyboard-interactive":{let{prompt:J}=C;if(typeof J!="function")return j("Skipping invalid keyboard-interactive auth attempt");C={type:q,username:W,prompt:J};break}case"none":C={type:q,username:W};break;default:return j(`Skipping unsupported authentication method: ${C}`)}}}P=C;try{let W=P.username;switch(P.type){case"password":_.authPassword(W,P.password);break;case"publickey":{let q;if(P.keyAlgos=uf(this,P.key,h),P.keyAlgos)if(P.keyAlgos.length)q=P.keyAlgos[0][0];else return j("Skipping key authentication (no mutual hash algorithm)");_.authPK(W,P.key,q);break}case"hostbased":{let q,J;if(P.keyAlgos=uf(this,P.key,h),P.keyAlgos)if(P.keyAlgos.length)[q,J]=P.keyAlgos[0];else return j("Skipping hostbased authentication (no mutual hash algorithm)");_.authHostbased(W,P.key,P.localHostname,P.localUsername,q,(ue,me)=>{let he=P.key.sign(ue,J);if(he instanceof Error)return he.message=`Error while signing with key: ${he.message}`,he.level="client-authentication",this.emit("error",he),B();me(he)});break}case"agent":P.agentCtx.init(q=>{if(q)return q.level="agent",this.emit("error",q),B();G()});break;case"keyboard-interactive":_.authKeyboard(W);break;case"none":_.authNone(W);break}}finally{T=!1}}},"doNextAuth");function j(C){o&&o(C),process.nextTick(B)}c(j,"skipAuth");function B(){T=!1;let C=i(M,k,F);T||C===void 0||F(C)}c(B,"tryNextAuth");let G=c(()=>{if(P.type==="agent"){let C=P.agentCtx.nextKey();if(C===!1)o&&o("Agent: No more keys left to try"),o&&o("Client: agent auth failed"),B();else{let W=P.agentCtx.pos(),q;if(P.keyAlgos=uf(this,C,h),P.keyAlgos)if(P.keyAlgos.length)q=P.keyAlgos[0][0];else{o&&o(`Agent: Skipping key #${W+1} (no mutual hash algorithm)`),G();return}o&&o(`Agent: Trying key #${W+1}`),_.authPK(P.username,C,q)}}},"tryNextAgentKey"),ee=c(()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let C=new Error("Timed out while waiting for handshake");C.level="client-timeout",this.emit("error",C),l.destroy()},this.config.readyTimeout))},"startTimeout");if(e.sock)ee(),typeof l.connecting=="boolean"&&l.connecting||Z();else{let C=this.config.host,W=this.config.forceIPv4,q=this.config.forceIPv6;o&&o(`Client: Trying ${C} on port ${this.config.port} ...`);let J=c(()=>{ee(),l.connect({host:C,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),l.setMaxListeners(0),l.setTimeout(typeof e.timeout=="number"?e.timeout:0)},"doConnect");!W&&!q||W&&q?J():Dv(C,W?4:6,(ue,me,he)=>{if(ue){let bt=W?"IPv4":"IPv6",Ct=new Error(`Error while looking up ${bt} address for '${C}': ${ue}`);clearTimeout(this._readyTimeout),Ct.level="client-dns",this.emit("error",Ct),this.emit("close");return}C=me,J()})}return this}end(){return this._sock&&rr(this._sock)&&(this._protocol.disconnect(Xm.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&rr(this._sock)&&this._sock.destroy(),this}exec(e,r,n){if(!this._sock||!rr(this._sock))throw new Error("Not connected");typeof r=="function"&&(n=r,r={});let i={allowHalfOpen:r.allowHalfOpen!==!1};return io(this,"session",i,(o,s)=>{if(o){n(o);return}let a=[];function u(l){if(l){s.close(),n(l);return}a.length&&a.shift()()}c(u,"reqCb"),(this.config.allowAgentFwd===!0||r&&r.agentForward===!0&&this._agent!==void 0)&&a.push(()=>a_(s,u)),typeof r=="object"&&r!==null&&(typeof r.env=="object"&&r.env!==null&&c_(s,r.env),(typeof r.pty=="object"&&r.pty!==null||r.pty===!0)&&a.push(()=>s_(s,r.pty,u)),(typeof r.x11=="object"&&r.x11!==null||r.x11==="number"||r.x11===!0)&&a.push(()=>o_(s,r.x11,u))),a.push(()=>tS(s,e,r,n)),a.shift()()}),this}shell(e,r,n){if(!this._sock||!rr(this._sock))throw new Error("Not connected");return typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),e&&(e.x11!==void 0||e.env!==void 0)&&(r=e,e=void 0),io(this,"session",(i,o)=>{if(i){n(i);return}let s=[];function a(u){if(u){o.close(),n(u);return}s.length&&s.shift()()}c(a,"reqCb"),(this.config.allowAgentFwd===!0||r&&r.agentForward===!0&&this._agent!==void 0)&&s.push(()=>a_(o,a)),e!==!1&&s.push(()=>s_(o,e,a)),typeof r=="object"&&r!==null&&(typeof r.env=="object"&&r.env!==null&&c_(o,r.env),(typeof r.x11=="object"&&r.x11!==null||r.x11==="number"||r.x11===!0)&&s.push(()=>o_(o,r.x11,a))),s.push(()=>eS(o,n)),s.shift()()}),this}subsys(e,r){if(!this._sock||!rr(this._sock))throw new Error("Not connected");return io(this,"session",(n,i)=>{if(n){r(n);return}u_(i,e,(o,s)=>{if(o){r(o);return}r(void 0,s)})}),this}forwardIn(e,r,n){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let i=typeof n=="function";return i&&this._callbacks.push((o,s)=>{if(o){n(o!==!0?o:new Error(`Unable to bind to ${e}:${r}`));return}let a=r;r===0&&s&&s.length>=4&&(a=Gv(s,0),this._protocol._compatFlags&f_.DYN_RPORT_BUG||(r=a)),this._forwarding[`${e}:${r}`]=a,n(void 0,a)}),this._protocol.tcpipForward(e,r,i),this}unforwardIn(e,r,n){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let i=typeof n=="function";return i&&this._callbacks.push(o=>{if(o){n(o!==!0?o:new Error(`Unable to unbind from ${e}:${r}`));return}delete this._forwarding[`${e}:${r}`],n()}),this._protocol.cancelTcpipForward(e,r,i),this}forwardOut(e,r,n,i,o){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let s={srcIP:e,srcPort:r,dstIP:n,dstPort:i};return typeof o!="function"&&(o=lf),io(this,"direct-tcpip",s,o),this}openssh_noMoreSessions(e){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&_s.test(this._remoteVer)?(r&&this._callbacks.push(n=>{if(n){e(n!==!0?n:new Error("Unable to disable future sessions"));return}e()}),this._protocol.openssh_noMoreSessions(r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardInStreamLocal(e,r){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let n=typeof r=="function";return!this.config.strictVendor||this.config.strictVendor&&_s.test(this._remoteVer)?(n&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to bind to ${e}`));return}this._forwardingUnix[e]=!0,r()}),this._protocol.openssh_streamLocalForward(e,n),this):n?(process.nextTick(r,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(e,r){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let n=typeof r=="function";return!this.config.strictVendor||this.config.strictVendor&&_s.test(this._remoteVer)?(n&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to unbind from ${e}`));return}delete this._forwardingUnix[e],r()}),this._protocol.openssh_cancelStreamLocalForward(e,n),this):n?(process.nextTick(r,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(e,r){if(!this._sock||!rr(this._sock))throw new Error("Not connected");return typeof r!="function"&&(r=lf),!this.config.strictVendor||this.config.strictVendor&&_s.test(this._remoteVer)?(io(this,"direct-streamlocal@openssh.com",{socketPath:e},r),this):(process.nextTick(r,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this)}sftp(e){if(!this._sock||!rr(this._sock))throw new Error("Not connected");return io(this,"sftp",(r,n)=>{if(r){e(r);return}u_(n,"sftp",(i,o)=>{if(i){e(i);return}function s(){n.removeListener("ready",a),n.removeListener("error",u),n.removeListener("exit",l),n.removeListener("close",l)}c(s,"removeListeners");function a(){s(),e(void 0,n)}c(a,"onReady");function u(d){s(),e(d)}c(u,"onError");function l(d,p){s();let g;typeof d=="number"?g=`Received exit code ${d} while establishing SFTP session`:p!==void 0?g=`Received signal ${p} while establishing SFTP session`:g="Received unexpected SFTP session termination";let h=new Error(g);h.code=d,h.signal=p,e(h)}c(l,"onExit"),n.on("ready",a).on("error",u).on("exit",l).on("close",l),n._init()})}),this}setNoDelay(e){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(e),this}};function io(t,e,r,n){let i=rc,o=nc;typeof r=="function"&&(n=r,r={});let s=c((u,l)=>{n(u,l)},"wrapper");s.type=e;let a=t._chanMgr.add(s);if(a===-1){n(new Error("No free channels available"));return}switch(e){case"session":case"sftp":t._protocol.session(a,i,o);break;case"direct-tcpip":t._protocol.directTcpip(a,i,o,r);break;case"direct-streamlocal@openssh.com":t._protocol.openssh_directStreamLocal(a,i,o,r);break;default:throw new Error(`Unsupported channel type: ${e}`)}}c(io,"openChannel");function o_(t,e,r){let n={single:!1,protocol:"MIT-MAGIC-COOKIE-1",cookie:void 0,screen:0};typeof e=="function"?r=e:typeof e=="object"&&e!==null&&(typeof e.single=="boolean"&&(n.single=e.single),typeof e.screen=="number"&&(n.screen=e.screen),typeof e.protocol=="string"&&(n.protocol=e.protocol),typeof e.cookie=="string"?n.cookie=e.cookie:Buffer.isBuffer(e.cookie)&&(n.cookie=e.cookie.hexSlice(0,e.cookie.length))),n.cookie===void 0&&(n.cookie=nS());let i=typeof r=="function";if(t.outgoing.state!=="open"){i&&r(new Error("Channel is not open"));return}i&&t._callbacks.push(o=>{if(o){r(o!==!0?o:new Error("Unable to request X11"));return}t._hasX11=!0,++t._client._acceptX11,t.once("close",()=>{t._client._acceptX11&&--t._client._acceptX11}),r()}),t._client._protocol.x11Forward(t.outgoing.id,n,i)}c(o_,"reqX11");function s_(t,e,r){let n=24,i=80,o=640,s=480,a="vt100",u=null;typeof e=="function"?r=e:typeof e=="object"&&e!==null&&(typeof e.rows=="number"&&(n=e.rows),typeof e.cols=="number"&&(i=e.cols),typeof e.width=="number"&&(o=e.width),typeof e.height=="number"&&(s=e.height),typeof e.term=="string"&&(a=e.term),typeof e.modes=="object"&&(u=e.modes));let l=typeof r=="function";if(t.outgoing.state!=="open"){l&&r(new Error("Channel is not open"));return}l&&t._callbacks.push(d=>{if(d){r(d!==!0?d:new Error("Unable to request a pseudo-terminal"));return}r()}),t._client._protocol.pty(t.outgoing.id,n,i,s,o,a,u,l)}c(s_,"reqPty");function a_(t,e){let r=typeof e=="function";if(t.outgoing.state!=="open"){r&&e(new Error("Channel is not open"));return}if(t._client._agentFwdEnabled){r&&e(!1);return}t._client._agentFwdEnabled=!0,t._callbacks.push(n=>{if(n){t._client._agentFwdEnabled=!1,r&&e(n!==!0?n:new Error("Unable to request agent forwarding"));return}r&&e()}),t._client._protocol.openssh_agentForward(t.outgoing.id,!0)}c(a_,"reqAgentFwd");function eS(t,e){if(t.outgoing.state!=="open"){e(new Error("Channel is not open"));return}t._callbacks.push(r=>{if(r){e(r!==!0?r:new Error("Unable to open shell"));return}t.subtype="shell",e(void 0,t)}),t._client._protocol.shell(t.outgoing.id,!0)}c(eS,"reqShell");function tS(t,e,r,n){if(t.outgoing.state!=="open"){n(new Error("Channel is not open"));return}t._callbacks.push(i=>{if(i){n(i!==!0?i:new Error("Unable to exec"));return}t.subtype="exec",t.allowHalfOpen=r.allowHalfOpen!==!1,n(void 0,t)}),t._client._protocol.exec(t.outgoing.id,e,!0)}c(tS,"reqExec");function c_(t,e){if(t.outgoing.state!=="open")return;let r=Object.keys(e||{});for(let n=0;n<r.length;++n){let i=r[n],o=e[i];t._client._protocol.env(t.outgoing.id,i,o,!1)}}c(c_,"reqEnv");function u_(t,e,r){if(t.outgoing.state!=="open"){r(new Error("Channel is not open"));return}t._callbacks.push(n=>{if(n){r(n!==!0?n:new Error(`Unable to start subsystem: ${e}`));return}t.subtype="subsystem",r(void 0,t)}),t._client._protocol.subsystem(t.outgoing.id,e,!0)}c(u_,"reqSubsystem");function rS(t,e){let r=-1,n,i=c(()=>{let u={type:e.type,incoming:{id:r,window:rc,packetSize:nc,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}},l=new p_(t,u);return t._chanMgr.update(r,l),t._protocol.channelOpenConfirm(e.sender,r,rc,nc),l},"accept"),o=c(()=>{n===void 0&&(r===-1?n=gs.RESOURCE_SHORTAGE:n=gs.CONNECT_FAILED),r!==-1&&t._chanMgr.remove(r),t._protocol.channelOpenFail(e.sender,n,"")},"reject"),s=c(()=>(r=t._chanMgr.add(),r===-1&&(n=gs.RESOURCE_SHORTAGE,t.config.debug&&t.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),r!==-1),"reserveChannel"),a=e.data;switch(e.type){case"forwarded-tcpip":{let u=t._forwarding[`${a.destIP}:${a.destPort}`];if(u!==void 0&&s()){a.destPort===0&&(a.destPort=u),t.emit("tcp connection",a,i,o);return}break}case"forwarded-streamlocal@openssh.com":if(t._forwardingUnix[a.socketPath]!==void 0&&s()){t.emit("unix connection",a,i,o);return}break;case"auth-agent@openssh.com":if(t._agentFwdEnabled&&typeof t._agent.getStream=="function"&&s()){t._agent.getStream((u,l)=>{if(u)return o();let d=i();d.pipe(l).pipe(d)});return}break;case"x11":if(t._acceptX11!==0&&s()){t.emit("x11",a,i,o);return}break;default:n=gs.UNKNOWN_CHANNEL_TYPE,t.config.debug&&t.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${e.type}`)}n===void 0&&(n=gs.ADMINISTRATIVELY_PROHIBITED,t.config.debug&&t.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+e.type)),o()}c(rS,"onCHANNEL_OPEN");var nS=(()=>{let t=Buffer.allocUnsafe(16);return()=>(Ov(t,0,16),t.hexSlice(0,16))})();function l_(t){if(!Array.isArray(t))throw new Error("authList must be an array");let e=0;return(r,n,i)=>e===t.length?!1:t[e++]}c(l_,"makeSimpleAuthHandler");function iS(t,e,r){if(!t._sock||!rr(t._sock))return;if(typeof r!="function"&&(r=lf),!Array.isArray(e))throw new TypeError("Invalid keys argument type");let n=[];for(let i of e){let o=tc(i);if(o instanceof Error)throw o;n.push(o)}if(!t.config.strictVendor||t.config.strictVendor&&_s.test(t._remoteVer)){t._callbacks.push((i,o)=>{if(i){r(i!==!0?i:new Error("Server failed to prove supplied keys"));return}let s=[],a=0;for(Ja.init(o,0);Ja.avail()&&a!==n.length;){let u=n[a++],l=u.getPublicSSH(),d=Ja.readString();ec.init(d,0);let p=ec.readString(!0),g=ec.readString(),h;if(p!==u.type)if(u.type==="ssh-rsa")switch(p){case"rsa-sha2-256":h="sha256";break;case"rsa-sha2-512":h="sha512";break;default:continue}else continue;let _=t._protocol._kex.sessionID,E=Buffer.allocUnsafe(37+_.length+4+l.length),b=0;cf(E,29,b),E.utf8Write("hostkeys-prove-00@openssh.com",b+=4,29),cf(E,_.length,b+=29),Jm(_,E,0,_.length,b+=4),cf(E,l.length,b+=_.length),Jm(l,E,0,l.length,b+=4),(g=Zv(g,p))&&u.verify(E,g,h)===!0&&s.push(u)}ec.clear(),Ja.clear(),r(null,s)}),t._protocol.openssh_hostKeysProve(n);return}process.nextTick(r,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}c(iS,"hostKeysProve");function uf(t,e,r){switch(e.type){case"ssh-rsa":if(t._protocol._compatFlags&f_.IMPLY_RSA_SHA2_SIGALGS&&(Array.isArray(r)?r=["rsa-sha2-256","rsa-sha2-512",...r]:r=["rsa-sha2-256","rsa-sha2-512"]),Array.isArray(r)){if(r.indexOf("rsa-sha2-256")!==-1)return[["rsa-sha2-256","sha256"]];if(r.indexOf("rsa-sha2-512")!==-1)return[["rsa-sha2-512","sha512"]];if(r.indexOf("ssh-rsa")===-1)return[]}return[["ssh-rsa","sha1"]]}}c(uf,"getKeyAlgos");h_.exports=ff});var m_=le(g_=>{"use strict";var{Agent:hf}=require("http"),{Agent:oS}=require("https"),{connect:sS}=require("tls"),pf;for(let t of[hf,oS]){class e extends t{static{c(this,"SSHAgent")}constructor(n,i){super(i),this._connectCfg=n,this._defaultSrcIP=i&&i.srcIP||"localhost"}createConnection(n,i){let o=n&&n.localAddress||this._defaultSrcIP,s=n&&n.localPort||0,a=n.host,u=n.port;pf===void 0&&(pf=df());let l=new pf,d=!1;l.on("ready",()=>{l.forwardOut(o,s,a,u,(p,g)=>{if(d=!0,p)return l.end(),i(p);g.once("close",()=>l.end()),i(null,aS(g,t,n))})}).on("error",i).on("close",()=>{d||i(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}g_[t===hf?"SSHTTPAgent":"SSHTTPSAgent"]=e}function ys(){}c(ys,"noop");function aS(t,e,r){if(e===hf)return t.setKeepAlive=ys,t.setNoDelay=ys,t.setTimeout=ys,t.ref=ys,t.unref=ys,t.destroySoon=t.destroy,t;r.socket=t;let n=sS(r),i=(()=>{let o=!1;return()=>{o||(o=!0,t.isPaused()&&t.resume())}})();return n.on("end",i).on("close",i),n}c(aS,"decorateStream")});var y_=le((uF,yf)=>{"use strict";var{Server:cS}=require("net"),Es=require("events"),{listenerCount:_r}=Es,{CHANNEL_OPEN_FAILURE:oo,DEFAULT_CIPHER:uS,DEFAULT_COMPRESSION:lS,DEFAULT_KEX:fS,DEFAULT_MAC:dS,DEFAULT_SERVER_HOST_KEY:pS,DISCONNECT_REASON:so,DISCONNECT_REASON_BY_VALUE:hS,SUPPORTED_CIPHER:gS,SUPPORTED_COMPRESSION:mS,SUPPORTED_KEX:_S,SUPPORTED_MAC:yS,SUPPORTED_SERVER_HOST_KEY:AS}=An(),{init:ES}=Ln(),{KexInit:bS}=Ma(),{parseKey:__}=Fn(),xS=Fl(),{SFTP:IS}=ds(),{writeUInt32BE:vS}=Qr(),{Channel:ao,MAX_WINDOW:Wn,PACKET_SIZE:qn,windowAdjust:SS,WINDOW_THRESHOLD:wS}=nf(),{ChannelManager:PS,generateAlgorithmList:As,isWritable:ic,onChannelOpenFailure:TS,onCHANNEL_CLOSE:kS}=af(),CS=10,Qn=class extends Es{static{c(this,"AuthContext")}constructor(e,r,n,i,o){super(),this.username=this.user=r,this.service=n,this.method=i,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(s,a,u)=>{this._finalResponse||(this._finalResponse=!0,o(this,s,a,u))},this._protocol=e}accept(){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!0)}reject(e,r){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!1,e,r)}},oc=class extends Qn{static{c(this,"KeyboardAuthContext")}constructor(e,r,n,i,o,s){super(e,r,n,i,s),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let u=this._cb;u&&(this._cb=void 0,u(a))},this.submethods=o,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(e,r,n,i){Array.isArray(e)||(e=[e]),typeof r=="function"?(i=r,r=n=void 0):typeof n=="function"?(i=n,n=void 0):typeof i!="function"&&(i=void 0);for(let o=0;o<e.length;++o)typeof e[o]=="string"&&(e[o]={prompt:e[o],echo:!0});this._cb=i,this._initialResponse=!0,this._protocol.authInfoReq(r,n,e)}},mf=class extends Qn{static{c(this,"PKAuthContext")}constructor(e,r,n,i,o,s){super(e,r,n,i,s),this.key={algo:o.keyAlgo,data:o.key},this.hashAlgo=o.hashAlgo,this.signature=o.signature,this.blob=o.blob}accept(){this.signature?Qn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},_f=class extends Qn{static{c(this,"HostbasedAuthContext")}constructor(e,r,n,i,o,s){super(e,r,n,i,s),this.key={algo:o.keyAlgo,data:o.key},this.hashAlgo=o.hashAlgo,this.signature=o.signature,this.blob=o.blob,this.localHostname=o.localHostname,this.localUsername=o.localUsername}},sc=class extends Qn{static{c(this,"PwdAuthContext")}constructor(e,r,n,i,o,s){super(e,r,n,i,s),this.password=o,this._changeCb=void 0}requestChange(e,r){if(this._changeCb)throw new Error("Change request already in progress");if(typeof e!="string")throw new Error("prompt argument must be a string");if(typeof r!="function")throw new Error("Callback argument must be a function");this._changeCb=r,this._protocol.authPasswdChg(e)}},sn=class extends Es{static{c(this,"Session")}constructor(e,r,n){super(),this.type="session",this.subtype=void 0,this.server=!0,this._ending=!1,this._channel=void 0,this._chanInfo={type:"session",incoming:{id:n,window:Wn,packetSize:qn,state:"open"},outgoing:{id:r.sender,window:r.window,packetSize:r.packetSize,state:"open"}}}},$r=class extends Es{static{c(this,"Server")}constructor(e,r){if(super(),typeof e!="object"||e===null)throw new Error("Missing configuration object");let n=Object.create(null),i=[],o=e.hostKeys;if(!Array.isArray(o))throw new Error("hostKeys must be an array");let s=typeof e.algorithms=="object"&&e.algorithms!==null?e.algorithms:{},a=As(s.serverHostKey,pS,AS);for(let g=0;g<o.length;++g){let h;if(Buffer.isBuffer(o[g])||typeof o[g]=="string"?h=__(o[g]):h=__(o[g].key,o[g].passphrase),h instanceof Error)throw new Error(`Cannot parse privateKey: ${h.message}`);if(Array.isArray(h)&&(h=h[0]),h.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!i.includes(h.type))if(h.type==="ssh-rsa"){let _=a.indexOf("ssh-rsa"),E=a.indexOf("rsa-sha2-256"),b=a.indexOf("rsa-sha2-512");_===-1&&(_=1/0),[_,E,b].sort(RS).forEach(I=>{if(I===-1)return;let w;switch(I){case _:w="ssh-rsa";break;case E:w="rsa-sha2-256";break;case b:w="rsa-sha2-512";break;default:return}n[w]=h,i.push(w)})}else n[h.type]=h,i.push(h.type)}let u={kex:As(s.kex,fS,_S).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:i,cs:{cipher:As(s.cipher,uS,gS),mac:As(s.hmac,dS,yS),compress:As(s.compress,lS,mS),lang:[]},sc:void 0};u.sc=u.cs,typeof r=="function"&&this.on("connection",r);let l=typeof e.debug=="function"?e.debug:void 0,d=e.ident?Buffer.from(e.ident):void 0,p=new bS(u);this._srv=new cS(g=>{if(this._connections>=this.maxConnections){g.destroy();return}++this._connections,g.once("close",()=>{--this._connections});let h;if(l){let _=`[${process.hrtime().join(".")}] `;h=c(E=>{l(`${_}${E}`)},"debug")}new ac(g,n,d,p,h,this,e)}).on("error",g=>{this.emit("error",g)}).on("listening",()=>{this.emit("listening")}).on("close",()=>{this.emit("close")}),this._connections=0,this.maxConnections=1/0}injectSocket(e){this._srv.emit("connection",e)}listen(...e){return this._srv.listen(...e),this}address(){return this._srv.address()}getConnections(e){return this._srv.getConnections(e),this}close(e){return this._srv.close(e),this}ref(){return this._srv.ref(),this}unref(){return this._srv.unref(),this}};$r.KEEPALIVE_CLIENT_INTERVAL=15e3;$r.KEEPALIVE_CLIENT_COUNT_MAX=3;var ac=class extends Es{static{c(this,"Client")}constructor(e,r,n,i,o,s,a){super();let u=0,l=!1,d=[],p,g,h,_=[];this._sock=e,this._chanMgr=new PS(this),this._debug=o,this.noMoreSessions=!1,this.authenticated=!1;function E(Y){}c(E,"onClientPreHeaderError"),this.on("error",E);let b=o?(Y,P,k)=>{o(`Debug output from client: ${JSON.stringify(k)}`)}:void 0,I=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof $r.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite($r.KEEPALIVE_CLIENT_INTERVAL)&&$r.KEEPALIVE_CLIENT_INTERVAL>0?$r.KEEPALIVE_CLIENT_INTERVAL:-1,w=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof $r.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite($r.KEEPALIVE_CLIENT_COUNT_MAX)&&$r.KEEPALIVE_CLIENT_COUNT_MAX>=0?$r.KEEPALIVE_CLIENT_COUNT_MAX:-1,H=0;I!==-1&&w!==-1&&(this.once("ready",()=>{let Y=c(()=>{clearInterval(g)},"onClose");this.on("close",Y).on("end",Y),g=setInterval(()=>{if(++H>w){clearInterval(g);let P=new Error("Keepalive timeout");P.level="client-timeout",this.emit("error",P),this.end()}else $.ping()},I)}),h=c(()=>{g&&g.refresh(),H=0},"onPacket"));let $=this._protocol=new xS({server:!0,hostKeys:r,ident:n,offer:i,onPacket:h,greeting:a.greeting,banner:a.banner,onWrite:c(Y=>{ic(e)&&e.write(Y)},"onWrite"),onError:c(Y=>{$._destruct||e.removeAllListeners("data"),this.emit("error",Y);try{e.end()}catch{}},"onError"),onHeader:c(Y=>{this.removeListener("error",E);let P={ip:e.remoteAddress,family:e.remoteFamily,port:e.remotePort,header:Y};if(!s.emit("connection",this,P)){$.disconnect(so.BY_APPLICATION),e.end();return}Y.greeting&&this.emit("greeting",Y.greeting)},"onHeader"),onHandshakeComplete:c(Y=>{++u>1&&this.emit("rekey"),this.emit("handshake",Y)},"onHandshakeComplete"),debug:o,messageHandlers:{DEBUG:b,DISCONNECT:c((Y,P,k)=>{if(P!==so.BY_APPLICATION){k||(k=hS[P],k===void 0&&(k=`Unexpected disconnection reason: ${P}`));let M=new Error(k);M.code=P,this.emit("error",M)}e.end()},"DISCONNECT"),CHANNEL_OPEN:c((Y,P)=>{if(P.type==="session"&&this.noMoreSessions||!this.authenticated){let G=oo.ADMINISTRATIVELY_PROHIBITED;return $.channelOpenFail(P.sender,G)}let k=-1,M,L=!1,T,F=c(()=>{L||(L=!0,M===void 0&&(k===-1?M=oo.RESOURCE_SHORTAGE:M=oo.CONNECT_FAILED),k!==-1&&this._chanMgr.remove(k),$.channelOpenFail(P.sender,M,""))},"reject"),j=c(()=>(k=this._chanMgr.add(),k===-1&&(M=oo.RESOURCE_SHORTAGE,o&&o("Automatic rejection of incoming channel open: no channels available")),k!==-1),"reserveChannel"),B=P.data;switch(P.type){case"session":if(_r(this,"session")&&j()){T=c(()=>{if(L)return;L=!0;let G=new sn(this,P,k);return this._chanMgr.update(k,G),$.channelOpenConfirm(P.sender,k,Wn,qn),G},"accept"),this.emit("session",T,F);return}break;case"direct-tcpip":if(_r(this,"tcpip")&&j()){T=c(()=>{if(L)return;L=!0;let G={type:void 0,incoming:{id:k,window:Wn,packetSize:qn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},ee=new ao(this,G,{server:!0});return this._chanMgr.update(k,ee),$.channelOpenConfirm(P.sender,k,Wn,qn),ee},"accept"),this.emit("tcpip",T,F,B);return}break;case"direct-streamlocal@openssh.com":if(_r(this,"openssh.streamlocal")&&j()){T=c(()=>{if(L)return;L=!0;let G={type:void 0,incoming:{id:k,window:Wn,packetSize:qn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},ee=new ao(this,G,{server:!0});return this._chanMgr.update(k,ee),$.channelOpenConfirm(P.sender,k,Wn,qn),ee},"accept"),this.emit("openssh.streamlocal",T,F,B);return}break;default:M=oo.UNKNOWN_CHANNEL_TYPE,o&&o(`Automatic rejection of unsupported incoming channel open type: ${P.type}`)}M===void 0&&(M=oo.ADMINISTRATIVELY_PROHIBITED,o&&o(`Automatic rejection of unexpected incoming channel open for: ${P.type}`)),F()},"CHANNEL_OPEN"),CHANNEL_OPEN_CONFIRMATION:c((Y,P)=>{let k=this._chanMgr.get(P.recipient);if(typeof k!="function")return;let M={type:k.type,incoming:{id:P.recipient,window:Wn,packetSize:qn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},L=new ao(this,M,{server:!0});this._chanMgr.update(P.recipient,L),k(void 0,L)},"CHANNEL_OPEN_CONFIRMATION"),CHANNEL_OPEN_FAILURE:c((Y,P,k,M)=>{let L=this._chanMgr.get(P);if(typeof L!="function")return;TS(this,P,{reason:k,description:M},L)},"CHANNEL_OPEN_FAILURE"),CHANNEL_DATA:c((Y,P,k)=>{let M=this._chanMgr.get(P);if(!(typeof M!="object"||M===null)&&!(M.constructor===sn&&(M=M._channel,!M))&&M.incoming.window!==0){if(M.incoming.window-=k.length,M.push(k)===!1){M._waitChanDrain=!0;return}M.incoming.window<=wS&&SS(M)}},"CHANNEL_DATA"),CHANNEL_EXTENDED_DATA:c((Y,P,k,M)=>{},"CHANNEL_EXTENDED_DATA"),CHANNEL_WINDOW_ADJUST:c((Y,P,k)=>{let M=this._chanMgr.get(P);typeof M!="object"||M===null||M.constructor===sn&&(M=M._channel,!M)||(M.outgoing.window+=k,M._waitWindow&&(M._waitWindow=!1,M._chunk?M._write(M._chunk,null,M._chunkcb):M._chunkcb?M._chunkcb():M._chunkErr?M.stderr._write(M._chunkErr,null,M._chunkcbErr):M._chunkcbErr&&M._chunkcbErr()))},"CHANNEL_WINDOW_ADJUST"),CHANNEL_SUCCESS:c((Y,P)=>{let k=this._chanMgr.get(P);typeof k!="object"||k===null||k.constructor===sn&&(k=k._channel,!k)||k._callbacks.length&&k._callbacks.shift()(!1)},"CHANNEL_SUCCESS"),CHANNEL_FAILURE:c((Y,P)=>{let k=this._chanMgr.get(P);typeof k!="object"||k===null||k.constructor===sn&&(k=k._channel,!k)||k._callbacks.length&&k._callbacks.shift()(!0)},"CHANNEL_FAILURE"),CHANNEL_REQUEST:c((Y,P,k,M,L)=>{let T=this._chanMgr.get(P);if(typeof T!="object"||T===null)return;let F=!1,j,B;if(T.constructor!==sn){M&&$.channelFailure(T.outgoing.id);return}if(M&&(k!=="shell"&&k!=="exec"&&k!=="subsystem"&&(j=c(()=>{F||T._ending||T._channel||(F=!0,$.channelSuccess(T._chanInfo.outgoing.id))},"accept")),B=c(()=>{F||T._ending||T._channel||(F=!0,$.channelFailure(T._chanInfo.outgoing.id))},"reject")),T._ending){B&&B();return}switch(k){case"env":if(_r(T,"env")){T.emit("env",j,B,{key:L.name,val:L.value});return}break;case"pty-req":if(_r(T,"pty")){T.emit("pty",j,B,L);return}break;case"window-change":_r(T,"window-change")?T.emit("window-change",j,B,L):B&&B();break;case"x11-req":if(_r(T,"x11")){T.emit("x11",j,B,L);return}break;case"signal":if(_r(T,"signal")){T.emit("signal",j,B,{name:L});return}break;case"auth-agent-req@openssh.com":if(_r(T,"auth-agent")){T.emit("auth-agent",j,B);return}break;case"shell":if(_r(T,"shell")){j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&$.channelSuccess(T._chanInfo.outgoing.id);let G=new ao(this,T._chanInfo,{server:!0});return G.subtype=T.subtype=k,T._channel=G,G},"accept"),T.emit("shell",j,B);return}break;case"exec":if(_r(T,"exec")){j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&$.channelSuccess(T._chanInfo.outgoing.id);let G=new ao(this,T._chanInfo,{server:!0});return G.subtype=T.subtype=k,T._channel=G,G},"accept"),T.emit("exec",j,B,{command:L});return}break;case"subsystem":{let G=L==="sftp";if(j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&$.channelSuccess(T._chanInfo.outgoing.id);let ee;return G?ee=new IS(this,T._chanInfo,{server:!0,debug:o}):(ee=new ao(this,T._chanInfo,{server:!0}),ee.subtype=T.subtype=`${k}:${L}`),T._channel=ee,ee},"accept"),L==="sftp"){if(_r(T,"sftp")){T.emit("sftp",j,B);return}G=!1}if(_r(T,"subsystem")){T.emit("subsystem",j,B,{name:L});return}break}}o&&o(`Automatic rejection of incoming channel request: ${k}`),B&&B()},"CHANNEL_REQUEST"),CHANNEL_EOF:c((Y,P)=>{let k=this._chanMgr.get(P);typeof k!="object"||k===null||k.constructor===sn&&(k._ending||(k._ending=!0,k.emit("eof"),k.emit("end")),k=k._channel,!k)||k.incoming.state==="open"&&(k.incoming.state="eof",k.readable&&k.push(null))},"CHANNEL_EOF"),CHANNEL_CLOSE:c((Y,P)=>{let k=this._chanMgr.get(P);typeof k!="object"||k===null||k.constructor===sn&&(k._ending=!0,k.emit("close"),k=k._channel,!k)||kS(this,P,k)},"CHANNEL_CLOSE"),SERVICE_REQUEST:c((Y,P)=>{if(u===0||l||this.authenticated||P!=="ssh-userauth"){$.disconnect(so.SERVICE_NOT_AVAILABLE),e.end();return}l=!0,$.serviceAccept(P)},"SERVICE_REQUEST"),USERAUTH_REQUEST:c((Y,P,k,M,L)=>{if(u===0||this.authenticated||p&&(p.username!==P||p.service!==k)||M!=="password"&&M!=="publickey"&&M!=="hostbased"&&M!=="keyboard-interactive"&&M!=="none"||d.length===CS){$.disconnect(so.PROTOCOL_ERROR),e.end();return}else if(k!=="ssh-connection"){$.disconnect(so.SERVICE_NOT_AVAILABLE),e.end();return}let T;switch(M){case"keyboard-interactive":T=new oc($,P,k,M,L,X);break;case"publickey":T=new mf($,P,k,M,L,X);break;case"hostbased":T=new _f($,P,k,M,L,X);break;case"password":if(p&&p instanceof sc&&p._changeCb){let F=p._changeCb;p._changeCb=void 0,F(L.newPassword);return}T=new sc($,P,k,M,L,X);break;case"none":T=new Qn($,P,k,M,X);break}if(p)if(p._initialResponse)p._multistep&&!p._finalResponse&&(p._cleanup&&p._cleanup(),p.emit("abort"));else return d.push(T);p=T,_r(this,"authentication")?this.emit("authentication",p):p.reject()},"USERAUTH_REQUEST"),USERAUTH_INFO_RESPONSE:c((Y,P)=>{p&&p instanceof oc&&p._onInfoResponse(P)},"USERAUTH_INFO_RESPONSE"),GLOBAL_REQUEST:c((Y,P,k,M)=>{let L={type:null,buf:null};function T(F,j){L.type=F,L.buf=j,Z()}if(c(T,"setReply"),k&&_.push(L),(P==="tcpip-forward"||P==="cancel-tcpip-forward"||P==="no-more-sessions@openssh.com"||P==="streamlocal-forward@openssh.com"||P==="cancel-streamlocal-forward@openssh.com")&&_r(this,"request")&&this.authenticated){let F,j;if(k){let B=!1;F=c(G=>{if(B)return;B=!0;let ee;P==="tcpip-forward"&&M.bindPort===0&&typeof G=="number"&&(ee=Buffer.allocUnsafe(4),vS(ee,G,0)),T("SUCCESS",ee)},"accept"),j=c(()=>{B||(B=!0,T("FAILURE"))},"reject")}if(P==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,F&&F();return}this.emit("request",F,j,P,M)}else k&&T("FAILURE")},"GLOBAL_REQUEST")}});e.pause(),ES.then(()=>{$.start(),e.on("data",Y=>{try{$.parse(Y,0,Y.length)}catch(P){this.emit("error",P);try{ic(e)&&e.end()}catch{}}}),e.resume()}).catch(Y=>{this.emit("error",Y);try{ic(e)&&e.end()}catch{}}),e.on("error",Y=>{Y.level="socket",this.emit("error",Y)}).once("end",()=>{o&&o("Socket ended"),$.cleanup(),this.emit("end")}).once("close",()=>{o&&o("Socket closed"),$.cleanup(),this.emit("close");let Y=new Error("No response from server");this._chanMgr.cleanup(Y)});let X=c((Y,P,k,M)=>{p===Y&&!this.authenticated&&(P?(p=void 0,this.authenticated=!0,$.authSuccess(),d=[],this.emit("ready")):($.authFailure(k,M),d.length&&(p=d.pop(),_r(this,"authentication")?this.emit("authentication",p):p.reject())))},"onAuthDecide");function Z(){for(;_.length>0&&_[0].type;){let Y=_.shift();Y.type==="SUCCESS"&&$.requestSuccess(Y.buf),Y.type==="FAILURE"&&$.requestFailure()}}c(Z,"sendReplies")}end(){return this._sock&&ic(this._sock)&&(this._protocol.disconnect(so.BY_APPLICATION),this._sock.end()),this}x11(e,r,n){return gf(this,"x11",{originAddr:e,originPort:r},n),this}forwardOut(e,r,n,i,o){return gf(this,"forwarded-tcpip",{boundAddr:e,boundPort:r,remoteAddr:n,remotePort:i},o),this}openssh_forwardOutStreamLocal(e,r){return gf(this,"forwarded-streamlocal@openssh.com",{socketPath:e},r),this}rekey(e){let r;try{this._protocol.rekey()}catch(n){r=n}typeof e=="function"&&(r?process.nextTick(e,r):this.once("rekey",e))}setNoDelay(e){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(e),this}};function gf(t,e,r,n){let i=Wn,o=qn;typeof r=="function"&&(n=r,r={});let s=c((u,l)=>{n(u,l)},"wrapper");s.type=e;let a=t._chanMgr.add(s);if(a===-1){n(new Error("No free channels available"));return}switch(e){case"forwarded-tcpip":t._protocol.forwardedTcpip(a,i,o,r);break;case"x11":t._protocol.x11(a,i,o,r);break;case"forwarded-streamlocal@openssh.com":t._protocol.openssh_forwardedStreamLocal(a,i,o,r);break;default:throw new Error(`Unsupported channel type: ${e}`)}}c(gf,"openChannel");function RS(t,e){return t-e}c(RS,"compareNumbers");yf.exports=$r;yf.exports.IncomingClient=ac});var I_=le((fF,x_)=>{"use strict";var{createCipheriv:NS,generateKeyPair:OS,generateKeyPairSync:$S,getCurves:DS,randomBytes:A_}=require("crypto"),{Ber:Nt}=Ko(),BS=Lu().pbkdf,{CIPHER_INFO:US}=Ln(),LS=16,zS=16,MS=DS(),FS=new Map(Object.entries(US));function E_(t,e){if(typeof t!="string")throw new TypeError("Key type must be a string");let r={type:"spki",format:"der"},n={type:"pkcs8",format:"der"};switch(t.toLowerCase()){case"rsa":{if(typeof e!="object"||e===null)throw new TypeError("Missing options object for RSA key");let i=e.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:r,privateKeyEncoding:n}]}case"ecdsa":{if(typeof e!="object"||e===null)throw new TypeError("Missing options object for ECDSA key");if(!Number.isInteger(e.bits))throw new TypeError("ECDSA bits must be an integer");let i;switch(e.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(!MS.includes(i))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:i,publicKeyEncoding:r,privateKeyEncoding:n}]}case"ed25519":return["ed25519",{publicKeyEncoding:r,privateKeyEncoding:n}];default:throw new Error(`Unsupported key type: ${t}`)}}c(E_,"makeArgs");function HS(t,e,r){switch(t){case"rsa":{let n=new Nt.Reader(r);if(n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in RSA private key");if(n.readSequence(),n.readOID()!=="1.2.840.113549.1.1.1")throw new Error("Bad RSA private OID");if(n.readByte()!==Nt.Null)throw new Error("Malformed RSA private key (expected null)");if(n.readByte()!==0)throw new Error("Malformed RSA private key (expected zero-length null)");if(n=new Nt.Reader(n.readString(Nt.OctetString,!0)),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in RSA private key");let i=n.readString(Nt.Integer,!0),o=n.readString(Nt.Integer,!0),s=n.readString(Nt.Integer,!0),a=n.readString(Nt.Integer,!0),u=n.readString(Nt.Integer,!0);n.readString(Nt.Integer,!0),n.readString(Nt.Integer,!0);let l=n.readString(Nt.Integer,!0),d=Buffer.from("ssh-rsa"),p=Buffer.allocUnsafe(4+d.length+4+i.length+4+o.length+4+s.length+4+l.length+4+a.length+4+u.length),g=0;p.writeUInt32BE(d.length,g+=0),p.set(d,g+=4),p.writeUInt32BE(i.length,g+=d.length),p.set(i,g+=4),p.writeUInt32BE(o.length,g+=i.length),p.set(o,g+=4),p.writeUInt32BE(s.length,g+=o.length),p.set(s,g+=4),p.writeUInt32BE(l.length,g+=s.length),p.set(l,g+=4),p.writeUInt32BE(a.length,g+=l.length),p.set(a,g+=4),p.writeUInt32BE(u.length,g+=a.length),p.set(u,g+=4);let h=Buffer.allocUnsafe(4+d.length+4+o.length+4+i.length);return g=0,h.writeUInt32BE(d.length,g+=0),h.set(d,g+=4),h.writeUInt32BE(o.length,g+=d.length),h.set(o,g+=4),h.writeUInt32BE(i.length,g+=o.length),h.set(i,g+=4),{sshName:d.toString(),priv:p,pub:h}}case"ec":{let n=new Nt.Reader(e);if(n.readSequence(),n.readSequence(),n.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");n.readOID();let i=n.readString(Nt.BitString,!0);{let g=0;for(;g<i.length&&i[g]===0;++g);g>0&&(i=i.slice(g))}if(n=new Nt.Reader(r),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(n.readSequence(),n.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let o=n.readOID(),s;switch(o){case"1.2.840.10045.3.1.7":s="nistp256";break;case"1.3.132.0.34":s="nistp384";break;case"1.3.132.0.35":s="nistp521";break;default:throw new Error("Unsupported curve in ECDSA private key")}if(n=new Nt.Reader(n.readString(Nt.OctetString,!0)),n.readSequence(),n.readInt()!==1)throw new Error("Unsupported version in ECDSA private key");let a=Buffer.concat([Buffer.from([0]),n.readString(Nt.OctetString,!0)]),u=Buffer.from(`ecdsa-sha2-${s}`);s=Buffer.from(s);let l=Buffer.allocUnsafe(4+u.length+4+s.length+4+i.length+4+a.length),d=0;l.writeUInt32BE(u.length,d+=0),l.set(u,d+=4),l.writeUInt32BE(s.length,d+=u.length),l.set(s,d+=4),l.writeUInt32BE(i.length,d+=s.length),l.set(i,d+=4),l.writeUInt32BE(a.length,d+=i.length),l.set(a,d+=4);let p=Buffer.allocUnsafe(4+u.length+4+s.length+4+i.length);return d=0,p.writeUInt32BE(u.length,d+=0),p.set(u,d+=4),p.writeUInt32BE(s.length,d+=u.length),p.set(s,d+=4),p.writeUInt32BE(i.length,d+=s.length),p.set(i,d+=4),{sshName:u.toString(),priv:l,pub:p}}case"ed25519":{let n=new Nt.Reader(e);if(n.readSequence(),n.readSequence(),n.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let i=n.readString(Nt.BitString,!0);{let d=0;for(;d<i.length&&i[d]===0;++d);d>0&&(i=i.slice(d))}if(n=new Nt.Reader(r),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in ED25519 private key");if(n.readSequence(),n.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 private OID");n=new Nt.Reader(n.readString(Nt.OctetString,!0));let o=n.readString(Nt.OctetString,!0),s=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+s.length+4+i.length+4+(o.length+i.length)),u=0;a.writeUInt32BE(s.length,u+=0),a.set(s,u+=4),a.writeUInt32BE(i.length,u+=s.length),a.set(i,u+=4),a.writeUInt32BE(o.length+i.length,u+=i.length),a.set(o,u+=4),a.set(i,u+=o.length);let l=Buffer.allocUnsafe(4+s.length+4+i.length);return u=0,l.writeUInt32BE(s.length,u+=0),l.set(s,u+=4),l.writeUInt32BE(i.length,u+=s.length),l.set(i,u+=4),{sshName:s.toString(),priv:a,pub:l}}}}c(HS,"parseDERs");function b_(t,e,r,n){let i="new",o,s="";if(typeof n=="object"&&n!==null&&(typeof n.comment=="string"&&n.comment&&(s=n.comment),typeof n.format=="string"&&n.format&&(i=n.format),n.passphrase)){let a;if(typeof n.passphrase=="string")a=Buffer.from(n.passphrase);else if(Buffer.isBuffer(n.passphrase))a=n.passphrase;else throw new Error("Invalid passphrase");if(n.cipher===void 0)throw new Error("Missing cipher name");let u=FS.get(n.cipher);if(u===void 0)throw new Error("Invalid cipher name");if(i==="new"){let l=zS;if(n.rounds!==void 0){if(!Number.isInteger(n.rounds))throw new TypeError("rounds must be an integer");n.rounds>0&&(l=n.rounds)}let d=Buffer.allocUnsafe(u.keyLen+u.ivLen),p=A_(LS);if(BS(a,a.length,p,p.length,d,d.length,l)!==0)return new Error("Failed to generate information to encrypt key");let h=Buffer.allocUnsafe(4+p.length+4);{let _=0;h.writeUInt32BE(p.length,_+=0),h.set(p,_+=4),h.writeUInt32BE(l,_+=p.length)}o={cipher:u,cipherName:n.cipher,kdfName:"bcrypt",kdfOptions:h,key:d.slice(0,u.keyLen),iv:d.slice(u.keyLen)}}}switch(i){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
20
- `,u,l=Buffer.from(o?o.cipherName:"none"),d=Buffer.from(o?o.kdfName:"none"),p=o?o.kdfOptions:Buffer.alloc(0),g=o?o.cipher.blockLen:8,h=HS(t,e,r),_=A_(4),E=Buffer.from(s),b=8+h.priv.length+4+E.length,I=[];for(let Z=1;(b+I.length)%g;++Z)I.push(Z&255);I=Buffer.from(I);let w=Buffer.allocUnsafe(b+I.length),H;{let Z=0;w.set(_,Z+=0),w.set(_,Z+=4),w.set(h.priv,Z+=4),w.writeUInt32BE(E.length,Z+=h.priv.length),w.set(E,Z+=4),w.set(I,Z+=E.length)}if(o){let Z={authTagLength:o.cipher.authLen},Y=NS(o.cipher.sslName,o.key,o.iv,Z);Y.setAutoPadding(!1),w=Buffer.concat([Y.update(w),Y.final()]),o.cipher.authLen>0?H=Y.getAuthTag():H=Buffer.alloc(0),o.key.fill(0),o.iv.fill(0)}else H=Buffer.alloc(0);let $=Buffer.from("openssh-key-v1\0"),X=Buffer.allocUnsafe($.length+4+l.length+4+d.length+4+p.length+4+4+h.pub.length+4+w.length+H.length);{let Z=0;X.set($,Z+=0),X.writeUInt32BE(l.length,Z+=$.length),X.set(l,Z+=4),X.writeUInt32BE(d.length,Z+=l.length),X.set(d,Z+=4),X.writeUInt32BE(p.length,Z+=d.length),X.set(p,Z+=4),X.writeUInt32BE(1,Z+=p.length),X.writeUInt32BE(h.pub.length,Z+=4),X.set(h.pub,Z+=4),X.writeUInt32BE(w.length,Z+=h.pub.length),X.set(w,Z+=4),X.set(H,Z+=w.length)}{let Z=X.base64Slice(0,X.length),Y=Z.replace(/.{64}/g,`$&
19
+ ${r}`}};var bv=2**32,Tm=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();ds.ERR_OUT_OF_RANGE=class Cm extends RangeError{static{c(this,"ERR_OUT_OF_RANGE")}constructor(e,r,n,i){super(),Error.captureStackTrace(this,Cm),Ga(r,'Missing "range" argument');let o=i?e:`The value of "${e}" is out of range.`,s;Number.isInteger(n)&&Math.abs(n)>bv?s=wm(String(n)):typeof n=="bigint"?(s=String(n),(n>Tm||n<-Tm)&&(s=wm(s)),s+="n"):s=Av(n),o+=` It must be ${r}. Received ${s}`,this.message=o}};var Za=class t extends TypeError{static{c(this,"ERR_INVALID_ARG_TYPE")}constructor(e,r,n){super(),Error.captureStackTrace(this,t),Ga(typeof e=="string","'name' must be a string");let i;typeof r=="string"&&r.startsWith("not ")?(i="must not be",r=r.replace(/^not /,"")):i="must be";let o;if(e.endsWith(" argument"))o=`The ${e} ${i} ${Pm(r,"type")}`;else{let s=e.includes(".")?"property":"argument";o=`The "${e}" ${s} ${i} ${Pm(r,"type")}`}o+=`. Received type ${typeof n}`,this.message=o}};ds.ERR_INVALID_ARG_TYPE=Za;ds.validateNumber=c(function(e,r){if(typeof e!="number")throw new Za(r,"number",e)},"validateNumber")});var ps=le((_F,Wm)=>{"use strict";var xv=require("events"),Wn=require("fs"),{constants:Pr}=Wn,{Readable:Um,Writable:Yl}=require("stream"),{inherits:Lm,types:{isDate:ql}}=require("util"),Iv=Buffer[Symbol.species],{bufferCopy:jn,bufferSlice:io,makeBufferParser:vv,writeUInt32BE:K}=Qr(),In={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},$e=Buffer.alloc(28),ht={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},Sv=new Map(Object.values(ht).map(t=>[t,1])),wv={[ht.OK]:"No error",[ht.EOF]:"End of file",[ht.NO_SUCH_FILE]:"No such file or directory",[ht.PERMISSION_DENIED]:"Permission denied",[ht.FAILURE]:"Failure",[ht.BAD_MESSAGE]:"Bad message",[ht.NO_CONNECTION]:"No connection",[ht.CONNECTION_LOST]:"Connection lost",[ht.OP_UNSUPPORTED]:"Operation unsupported"},Ne={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},Tr={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},Te={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},Nm=2*1024,St=2**32-1,Pv=Buffer.from([0,0,0,5,Ne.INIT,0,0,0,3]),Tv=Buffer.from([0,0,0,5,Tr.VERSION,0,0,0,3]),kv=/^SSH-2.0-(?:OpenSSH|dropbear)/,jl=256*1024,U=vv(),Cv={readable:!1,writable:!1,push:c(t=>{},"push"),once:c(()=>{},"once"),on:c(()=>{},"on"),emit:c(()=>{},"emit"),end:c(()=>{},"end")};function zm(){}c(zm,"noop");var Ql=class extends xv{static{c(this,"SFTP")}constructor(e,r,n){super(),(typeof n!="object"||!n)&&(n={});let i=e._protocol._remoteIdentRaw;this.server=!!n.server,this._debug=typeof n.debug=="function"?n.debug:void 0,this._isOpenSSH=i&&kv.test(i),this._version=-1,this._extensions={},this._biOpt=n.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=jl,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?jl:34e3)-Nm,this._maxWriteLen=(this._isOpenSSH?jl:34e3)-Nm,this.maxOpenHandles=void 0,this._client=e,this._protocol=e._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=r.type,this.subtype=void 0,this.incoming=r.incoming,this.outgoing=r.outgoing,this.stderr=Cv,this.readable=!0}push(e){if(e===null){if(jm(this),!this.readable)return;this.readable=!1,this.emit("end");return}let r=0;for(;r<e.length;){if(this._pktLenBytes<4){let s=Math.min(4-this._pktLenBytes,e.length-r);for(this._pktLenBytes+=s;s--;)this._pktLen=(this._pktLen<<8)+e[r++];if(this._pktLenBytes<4)return;if(this._pktLen===0)return yt(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return yt(this,`Packet length ${this._pktLen} exceeds max length of ${a}`)}if(r>=e.length)return}if(this._pktPos<this._pktLen){let s=Math.min(this._pktLen-this._pktPos,e.length-r);if(r!==0||s!==e.length?s===this._pktLen?this._pkt=new Iv(e.buffer,e.byteOffset+r,s):(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(new Uint8Array(e.buffer,e.byteOffset+r,s),this._pktPos)):s===this._pktLen?this._pkt=e:(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(e,this._pktPos)),r+=s,this._pktPos+=s,this._pktPos<this._pktLen)return}let n=this._pkt[0],i=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let o=this.server?Dv[n]:$v[n];if(!o)return yt(this,`Unknown packet type ${n}`);if(this._version===-1){if(this.server){if(n!==Ne.INIT)return yt(this,`Expected INIT packet, got ${n}`)}else if(n!==Tr.VERSION)return yt(this,`Expected VERSION packet, got ${n}`)}if(o(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=zm,this.server||lt(this,Pv)}createReadStream(e,r){if(this.server)throw new Error("Client-only method called in server mode");return new vn(this,e,r)}createWriteStream(e,r){if(this.server)throw new Error("Client-only method called in server mode");return new Fr(this,e,r)}open(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");typeof n=="function"&&(i=n,n=void 0);let o=typeof r=="number"?r:Fm(r);if(o===null)throw new Error(`Unknown flags string: ${r}`);let s=0,a=0;(typeof n=="string"||typeof n=="number")&&(n={mode:n}),typeof n=="object"&&n!==null&&(n=fi(n),s=n.flags,a=n.nb);let u=Buffer.byteLength(e),l=9,d=Buffer.allocUnsafe(13+u+4+4+a);K(d,d.length-4,0),d[4]=Ne.OPEN;let p=this._writeReqid=this._writeReqid+1&St;K(d,p,5),K(d,u,l),d.utf8Write(e,l+=4,u),K(d,o,l+=u),K(d,s,l+=4),a&&(l+=4,a===$e.length?d.set($e,l):jn($e,d,0,a,l),l+=a),this._requests[p]={cb:i};let g=lt(this,d);this._debug&&this._debug(`SFTP: Outbound: ${g?"Buffered":"Sending"} OPEN`)}close(e,r){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let n=e.length,i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.CLOSE;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.set(e,i+=4),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(e,r,n,i,o,s){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(r))throw new Error("buffer is not a Buffer");if(n>=r.length)throw new Error("offset is out of bounds");if(n+i>r.length)throw new Error("length extends beyond buffer");if(o===null)throw new Error("null position currently unsupported");Mm(this,e,r,n,i,o,s)}readData(e,r,n,i,o,s){this.read(e,r,n,i,o,s)}write(e,r,n,i,o,s){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(r))throw new Error("buffer is not a Buffer");if(n>r.length)throw new Error("offset is out of bounds");if(n+i>r.length)throw new Error("length extends beyond buffer");if(o===null)throw new Error("null position currently unsupported");if(!i){s&&process.nextTick(s,void 0,0);return}let a=this._maxWriteLen,u=Math.max(i-a,0),l=o;u&&(i=a);let d=e.length,p=9,g=Buffer.allocUnsafe(13+d+8+4+i);K(g,g.length-4,0),g[4]=Ne.WRITE;let h=this._writeReqid=this._writeReqid+1&St;K(g,h,5),K(g,d,p),g.set(e,p+=4),p+=d;for(let A=7;A>=0;--A)g[p+A]=o&255,o/=256;K(g,i,p+=8),jn(r,g,n,n+i,p+=4),this._requests[h]={cb:c(A=>{A?typeof s=="function"&&s(A):u?this.write(e,r,n+i,u,l+i,s):typeof s=="function"&&s(void 0,n+i)},"cb")};let _=lt(this,g);if(this._debug){let A=_?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${A} WRITE (id:${h})`)}}writeData(e,r,n,i,o,s){this.write(e,r,n,i,o,s)}fastGet(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");Om(this,Wn,e,r,n,i)}fastPut(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");Om(Wn,this,e,r,n,i)}readFile(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof n=="function"?i=n:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,flag:"r"};else if(!r)r={encoding:null,flag:"r"};else if(typeof r!="object")throw new TypeError("Bad arguments");let o=r.encoding;if(o&&!Buffer.isEncoding(o))throw new Error(`Unknown encoding: ${o}`);let s,a,u,l=0,d,p=0,g=r.flag||"r",h=c(()=>{s===0?(a=Buffer.allocUnsafe(8192),this.read(d,a,0,8192,p,_)):this.read(d,a,l,s-l,p,_)},"read"),_=c((b,I)=>{let w;if(b){if(w=b.code===ht.EOF,!w)return this.close(d,()=>i&&i(b))}else w=!1;if(w||s===0&&I===0)return A();p+=I,l+=I,s!==0?l===s?A():h():(u.push(io(a,0,I)),h())},"afterRead");_._wantEOFError=!0;let A=c(()=>{this.close(d,b=>(s===0?a=Buffer.concat(u,l):l<s&&(a=io(a,0,l)),o&&(a=a.toString(o)),i&&i(b,a)))},"close");this.open(e,g,438,(b,I)=>{if(b)return i&&i(b);d=I;let w=c((H,$)=>{if(H){this.stat(e,(X,Z)=>{if(X)return this.close(d,()=>{i&&i(H)});w(null,Z)});return}if(s=$.size||0,s===0)return u=[],h();a=Buffer.allocUnsafe(s),h()},"tryStat");this.fstat(d,w)})}writeFile(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");let o;if(typeof i=="function"?o=i:typeof n=="function"&&(o=n,n=void 0),typeof n=="string")n={encoding:n,mode:438,flag:"w"};else if(!n)n={encoding:"utf8",mode:438,flag:"w"};else if(typeof n!="object")throw new TypeError("Bad arguments");if(n.encoding&&!Buffer.isEncoding(n.encoding))throw new Error(`Unknown encoding: ${n.encoding}`);let s=n.flag||"w";this.open(e,s,n.mode,(a,u)=>{if(a)o&&o(a);else{let l=Buffer.isBuffer(r)?r:Buffer.from(""+r,n.encoding||"utf8"),d=/a/.test(s)?null:0;if(d===null){let p=c((g,h)=>{if(g){this.stat(e,(_,A)=>{if(_)return this.close(u,()=>{o&&o(g)});p(null,A)});return}Vl(this,u,l,0,l.length,h.size,o)},"tryStat");this.fstat(u,p);return}Vl(this,u,l,0,l.length,d,o)}})}appendFile(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");let o;if(typeof i=="function"?o=i:typeof n=="function"&&(o=n,n=void 0),typeof n=="string")n={encoding:n,mode:438,flag:"a"};else if(!n)n={encoding:"utf8",mode:438,flag:"a"};else if(typeof n!="object")throw new TypeError("Bad arguments");n.flag||(n=Object.assign({flag:"a"},n)),this.writeFile(e,r,n,o)}exists(e,r){if(this.server)throw new Error("Client-only method called in server mode");this.stat(e,n=>{r&&r(!n)})}unlink(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.REMOVE;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REMOVE`)}rename(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=Buffer.byteLength(r),s=9,a=Buffer.allocUnsafe(13+i+4+o);K(a,a.length-4,0),a[4]=Ne.RENAME;let u=this._writeReqid=this._writeReqid+1&St;K(a,u,5),K(a,i,s),a.utf8Write(e,s+=4,i),K(a,o,s+=i),a.utf8Write(r,s+=4,o),this._requests[u]={cb:n};let l=lt(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} RENAME`)}mkdir(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i=0,o=0;typeof r=="function"&&(n=r,r=void 0),typeof r=="object"&&r!==null&&(r=fi(r),i=r.flags,o=r.nb);let s=Buffer.byteLength(e),a=9,u=Buffer.allocUnsafe(13+s+4+o);K(u,u.length-4,0),u[4]=Ne.MKDIR;let l=this._writeReqid=this._writeReqid+1&St;K(u,l,5),K(u,s,a),u.utf8Write(e,a+=4,s),K(u,i,a+=s),o&&(a+=4,o===$e.length?u.set($e,a):jn($e,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} MKDIR`)}rmdir(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.RMDIR;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} RMDIR`)}readdir(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(n=r,r={}),(typeof r!="object"||r===null)&&(r={});let i=!(r&&r.full);if(!Buffer.isBuffer(e)&&typeof e!="string")throw new Error("missing directory handle or path");if(typeof e=="string"){let d=[],p=0,g=c((h,_)=>{if(h)return n(h);this.readdir(_,r,(A,b)=>{let I=A&&A.code===ht.EOF;if(A&&!I)return this.close(_,()=>n(A));if(I)return this.close(_,w=>{if(w)return n(w);n(void 0,d)});for(let w=0;w<b.length;++w,++p)d[p]=b[w];g(void 0,_)})},"reread");return this.opendir(e,g)}let o=e.length,s=9,a=Buffer.allocUnsafe(13+o);K(a,a.length-4,0),a[4]=Ne.READDIR;let u=this._writeReqid=this._writeReqid+1&St;K(a,u,5),K(a,o,s),a.set(e,s+=4),this._requests[u]={cb:i?(d,p)=>{if(typeof n=="function"){if(d)return n(d);for(let g=p.length-1;g>=0;--g)(p[g].filename==="."||p[g].filename==="..")&&p.splice(g,1);n(void 0,p)}}:n};let l=lt(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} READDIR`)}fstat(e,r){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let n=e.length,i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.FSTAT;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.set(e,i+=4),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} FSTAT`)}stat(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.STAT;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STAT`)}lstat(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.LSTAT;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} LSTAT`)}opendir(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.OPENDIR;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} OPENDIR`)}setstat(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i=0,o=0;typeof r=="object"&&r!==null?(r=fi(r),i=r.flags,o=r.nb):typeof r=="function"&&(n=r);let s=Buffer.byteLength(e),a=9,u=Buffer.allocUnsafe(13+s+4+o);K(u,u.length-4,0),u[4]=Ne.SETSTAT;let l=this._writeReqid=this._writeReqid+1&St;K(u,l,5),K(u,s,a),u.utf8Write(e,a+=4,s),K(u,i,a+=s),o&&(a+=4,o===$e.length?u.set($e,a):jn($e,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} SETSTAT`)}fsetstat(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let i=0,o=0;typeof r=="object"&&r!==null?(r=fi(r),i=r.flags,o=r.nb):typeof r=="function"&&(n=r);let s=e.length,a=9,u=Buffer.allocUnsafe(13+s+4+o);K(u,u.length-4,0),u[4]=Ne.FSETSTAT;let l=this._writeReqid=this._writeReqid+1&St;K(u,l,5),K(u,s,a),u.set(e,a+=4),K(u,i,a+=s),o&&(a+=4,o===$e.length?u.set($e,a):jn($e,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} FSETSTAT`)}futimes(e,r,n,i){return this.fsetstat(e,{atime:ro(r),mtime:ro(n)},i)}utimes(e,r,n,i){return this.setstat(e,{atime:ro(r),mtime:ro(n)},i)}fchown(e,r,n,i){return this.fsetstat(e,{uid:r,gid:n},i)}chown(e,r,n,i){return this.setstat(e,{uid:r,gid:n},i)}fchmod(e,r,n){return this.fsetstat(e,{mode:r},n)}chmod(e,r,n){return this.setstat(e,{mode:r},n)}readlink(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.READLINK;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:c((u,l)=>{if(typeof r=="function"){if(u)return r(u);if(!l||!l.length)return r(new Error("Response missing link info"));r(void 0,l[0].filename)}},"cb")};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} READLINK`)}symlink(e,r,n){if(this.server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(r),o=Buffer.byteLength(e),s=9,a=Buffer.allocUnsafe(13+i+4+o);K(a,a.length-4,0),a[4]=Ne.SYMLINK;let u=this._writeReqid=this._writeReqid+1&St;K(a,u,5),this._isOpenSSH?(K(a,o,s),a.utf8Write(e,s+=4,o),K(a,i,s+=o),a.utf8Write(r,s+=4,i)):(K(a,i,s),a.utf8Write(r,s+=4,i),K(a,o,s+=i),a.utf8Write(e,s+=4,o)),this._requests[u]={cb:n};let l=lt(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} SYMLINK`)}realpath(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=Buffer.byteLength(e),i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Ne.REALPATH;let s=this._writeReqid=this._writeReqid+1&St;K(o,s,5),K(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:c((u,l)=>{if(typeof r=="function"){if(u)return r(u);if(!l||!l.length)return r(new Error("Response missing path info"));r(void 0,l[0].filename)}},"cb")};let a=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(e,r,n){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 o=Buffer.byteLength(e),s=Buffer.byteLength(r),a=9,u=Buffer.allocUnsafe(41+o+4+s);K(u,u.length-4,0),u[4]=Ne.EXTENDED;let l=this._writeReqid=this._writeReqid+1&St;K(u,l,5),K(u,24,a),u.utf8Write("posix-rename@openssh.com",a+=4,24),K(u,o,a+=24),u.utf8Write(e,a+=4,o),K(u,s,a+=o),u.utf8Write(r,a+=4,s),this._requests[l]={cb:n};let d=lt(this,u);if(this._debug){let p=d?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${p} posix-rename@openssh.com`)}}ext_openssh_statvfs(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=this._extensions["statvfs@openssh.com"];if(!n||n!=="2")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(e),o=9,s=Buffer.allocUnsafe(36+i);K(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;K(s,a,5),K(s,19,o),s.utf8Write("statvfs@openssh.com",o+=4,19),K(s,i,o+=19),s.utf8Write(e,o+=4,i),this._requests[a]={extended:"statvfs@openssh.com",cb:r};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} statvfs@openssh.com`)}}ext_openssh_fstatvfs(e,r){if(this.server)throw new Error("Client-only method called in server mode");let n=this._extensions["fstatvfs@openssh.com"];if(!n||n!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let i=e.length,o=9,s=Buffer.allocUnsafe(37+i);K(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;K(s,a,5),K(s,20,o),s.utf8Write("fstatvfs@openssh.com",o+=4,20),K(s,i,o+=20),s.set(e,o+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:r};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} fstatvfs@openssh.com`)}}ext_openssh_hardlink(e,r,n){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 o=Buffer.byteLength(e),s=Buffer.byteLength(r),a=9,u=Buffer.allocUnsafe(37+o+4+s);K(u,u.length-4,0),u[4]=Ne.EXTENDED;let l=this._writeReqid=this._writeReqid+1&St;K(u,l,5),K(u,20,a),u.utf8Write("hardlink@openssh.com",a+=4,20),K(u,o,a+=20),u.utf8Write(e,a+=4,o),K(u,s,a+=o),u.utf8Write(r,a+=4,s),this._requests[l]={cb:n};let d=lt(this,u);if(this._debug){let p=d?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${p} hardlink@openssh.com`)}}ext_openssh_fsync(e,r){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(e))throw new Error("handle is not a Buffer");let i=e.length,o=9,s=Buffer.allocUnsafe(34+i);K(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;K(s,a,5),K(s,17,o),s.utf8Write("fsync@openssh.com",o+=4,17),K(s,i,o+=17),s.set(e,o+=4),this._requests[a]={cb:r};let u=lt(this,s);this._debug&&this._debug(`SFTP: Outbound: ${u?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(e,r,n){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 o=0,s=0;typeof r=="object"&&r!==null?(r=fi(r),o=r.flags,s=r.nb):typeof r=="function"&&(n=r);let a=Buffer.byteLength(e),u=9,l=Buffer.allocUnsafe(37+a+4+s);K(l,l.length-4,0),l[4]=Ne.EXTENDED;let d=this._writeReqid=this._writeReqid+1&St;K(l,d,5),K(l,20,u),l.utf8Write("lsetstat@openssh.com",u+=4,20),K(l,a,u+=20),l.utf8Write(e,u+=4,a),K(l,o,u+=a),s&&(u+=4,s===$e.length?l.set($e,u):jn($e,l,0,s,u),u+=s),this._requests[d]={cb:n};let p=lt(this,l);if(this._debug){let g=p?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${g} lsetstat@openssh.com`)}}ext_openssh_expandPath(e,r){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(e),o=9,s=Buffer.allocUnsafe(40+i);K(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;K(s,a,5),K(s,23,o),s.utf8Write("expand-path@openssh.com",o+=4,23),K(s,i,o+=20),s.utf8Write(e,o+=4,i),this._requests[a]={cb:c((l,d)=>{if(typeof r=="function"){if(l)return r(l);if(!d||!d.length)return r(new Error("Response missing expanded path"));r(void 0,d[0].filename)}},"cb")};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} expand-path@openssh.com`)}}ext_copy_data(e,r,n,i,o,s){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(e))throw new Error("Source handle is not a Buffer");if(!Buffer.isBuffer(i))throw new Error("Destination handle is not a Buffer");let u=0,l=Buffer.allocUnsafe(26+e.length+8+8+4+i.length+8);K(l,l.length-4,u),u+=4,l[u]=Ne.EXTENDED,++u;let d=this._writeReqid=this._writeReqid+1&St;K(l,d,u),u+=4,K(l,9,u),u+=4,l.utf8Write("copy-data",u,9),u+=9,K(l,e.length,u),u+=4,l.set(e,u),u+=e.length;for(let g=7;g>=0;--g)l[u+g]=r&255,r/=256;u+=8;for(let g=7;g>=0;--g)l[u+g]=n&255,n/=256;u+=8,K(l,i.length,u),u+=4,l.set(i,u),u+=i.length;for(let g=7;g>=0;--g)l[u+g]=o&255,o/=256;this._requests[d]={cb:s};let p=lt(this,l);if(this._debug){let g=p?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${g} copy-data`)}}ext_home_dir(e,r){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 e!="string")throw new TypeError("username is not a string");let i=0,o=Buffer.byteLength(e),s=Buffer.allocUnsafe(31+o);K(s,s.length-4,i),i+=4,s[i]=Ne.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&St;K(s,a,i),i+=4,K(s,14,i),i+=4,s.utf8Write("home-directory",i,14),i+=14,K(s,o,i),i+=4,s.utf8Write(e,i,o),i+=o,this._requests[a]={cb:c((l,d)=>{if(typeof r=="function"){if(l)return r(l);if(!d||!d.length)return r(new Error("Response missing home directory"));r(void 0,d[0].filename)}},"cb")};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} home-directory`)}}ext_users_groups(e,r,n){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(e))throw new TypeError("uids is not an array");for(let l of e)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("uid values must all be 32-bit unsigned integers");if(!Array.isArray(r))throw new TypeError("gids is not an array");for(let l of r)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let o=0,s=Buffer.allocUnsafe(47+4*e.length+4+4*r.length);K(s,s.length-4,o),o+=4,s[o]=Ne.EXTENDED,++o;let a=this._writeReqid=this._writeReqid+1&St;K(s,a,o),o+=4,K(s,30,o),o+=4,s.utf8Write("users-groups-by-id@openssh.com",o,30),o+=30,K(s,4*e.length,o),o+=4;for(let l of e)K(s,l,o),o+=4;K(s,4*r.length,o),o+=4;for(let l of r)K(s,l,o),o+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:n};let u=lt(this,s);if(this._debug){let l=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} users-groups-by-id@openssh.com`)}}handle(e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!Buffer.isBuffer(r))throw new Error("handle is not a Buffer");let n=r.length;if(n>256)throw new Error("handle too large (> 256 bytes)");let i=9,o=Buffer.allocUnsafe(13+n);K(o,o.length-4,0),o[4]=Tr.HANDLE,K(o,e,5),K(o,n,i),n&&o.set(r,i+=4);let s=lt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${s?"Buffered":"Sending"} HANDLE`)}status(e,r,n){if(!this.server)throw new Error("Server-only method called in client mode");if(!Sv.has(r))throw new Error(`Bad status code: ${r}`);n||(n="");let i=Buffer.byteLength(n),o=9,s=Buffer.allocUnsafe(17+i+4);K(s,s.length-4,0),s[4]=Tr.STATUS,K(s,e,5),K(s,r,o),K(s,i,o+=4),o+=4,i&&(s.utf8Write(n,o,i),o+=i),K(s,0,o);let a=lt(this,s);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STATUS`)}data(e,r,n){if(!this.server)throw new Error("Server-only method called in client mode");let i=Buffer.isBuffer(r);if(!i&&typeof r!="string")throw new Error("data is not a Buffer or string");let o;!i&&!n&&(n=void 0,o=!0);let s=i?r.length:Buffer.byteLength(r,n),a=9,u=Buffer.allocUnsafe(13+s);K(u,u.length-4,0),u[4]=Tr.DATA,K(u,e,5),K(u,s,a),s&&(i?u.set(r,a+=4):o?u.utf8Write(r,a+=4,s):u.write(r,a+=4,s,n));let l=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} DATA`)}name(e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!Array.isArray(r)){if(typeof r!="object"||r===null)throw new Error("names is not an object or array");r=[r]}let n=r.length,i=0,o,s=[];for(let d=0;d<n;++d){let p=r[d],g=!p||!p.filename||typeof p.filename!="string"?"":p.filename;i+=4+Buffer.byteLength(g);let h=!p||!p.longname||typeof p.longname!="string"?"":p.longname;if(i+=4+Buffer.byteLength(h),typeof p.attrs=="object"&&p.attrs!==null){if(o=fi(p.attrs),i+=4+o.nb,o.nb){let _;o.nb===$e.length?_=new Uint8Array($e):(_=new Uint8Array(o.nb),jn($e,_,0,o.nb,0)),o.bytes=_}s.push(o)}else i+=4,s.push(null)}let a=9,u=Buffer.allocUnsafe(13+i);K(u,u.length-4,0),u[4]=Tr.NAME,K(u,e,5),K(u,n,a),a+=4;for(let d=0;d<n;++d){let p=r[d];{let h=!p||!p.filename||typeof p.filename!="string"?"":p.filename,_=Buffer.byteLength(h);K(u,_,a),a+=4,_&&(u.utf8Write(h,a,_),a+=_)}{let h=!p||!p.longname||typeof p.longname!="string"?"":p.longname,_=Buffer.byteLength(h);K(u,_,a),a+=4,_&&(u.utf8Write(h,a,_),a+=_)}let g=s[d];g?(K(u,g.flags,a),a+=4,g.flags&&g.bytes&&(u.set(g.bytes,a),a+=g.nb)):(K(u,0,a),a+=4)}let l=lt(this,u);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} NAME`)}attrs(e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(typeof r!="object"||r===null)throw new Error("attrs is not an object");r=fi(r);let n=r.flags,i=r.nb,o=9,s=Buffer.allocUnsafe(13+i);K(s,s.length-4,0),s[4]=Tr.ATTRS,K(s,e,5),K(s,n,o),i&&(o+=4,i===$e.length?s.set($e,o):jn($e,s,0,i,o),o+=i);let a=lt(this,s);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function Rv(t){try{return Buffer.allocUnsafe(t)}catch(e){return e}}c(Rv,"tryCreateBuffer");function Mm(t,e,r,n,i,o,s,a){let u=t._maxReadLen,l=Math.max(i-u,0);l&&(i=u);let d=e.length,p=9,g=o,h=Buffer.allocUnsafe(13+d+8+4);K(h,h.length-4,0),h[4]=Ne.READ;let _=t._writeReqid=t._writeReqid+1&St;K(h,_,5),K(h,d,p),h.set(e,p+=4),p+=d;for(let I=7;I>=0;--I)h[p+I]=g&255,g/=256;K(h,i,p+=8),typeof s!="function"&&(s=zm);let A=a||{nb:0,position:o,off:n,origOff:n,len:void 0,overflow:void 0,cb:c((I,w,H)=>{let $=A.len,X=A.overflow;if(I){if(s._wantEOFError||I.code!==ht.EOF)return s(I)}else{if(H>$)return s(new Error("Received more data than requested"));if(H===$&&X){A.nb+=H,A.position+=H,A.off+=H,Mm(t,e,r,A.off,X,A.position,s,A);return}}H=H||0,A.origOff===0&&r.length===A.nb?w=r:w=io(r,A.origOff,A.origOff+A.nb+H),s(void 0,A.nb+H,w,A.position)},"cb"),buffer:void 0};A.len=i,A.overflow=l,A.buffer=io(r,n,n+i),t._requests[_]=A;let b=lt(t,h);t._debug&&t._debug(`SFTP: Outbound: ${b?"Buffered":"Sending"} READ`)}c(Mm,"read_");function Om(t,e,r,n,i,o){let s=64,a=32768,u,l,d;typeof i=="function"?o=i:typeof i=="object"&&i!==null&&(typeof i.concurrency=="number"&&i.concurrency>0&&!isNaN(i.concurrency)&&(s=i.concurrency),typeof i.chunkSize=="number"&&i.chunkSize>0&&!isNaN(i.chunkSize)&&(a=i.chunkSize),typeof i.fileSize=="number"&&i.fileSize>0&&!isNaN(i.fileSize)&&(d=i.fileSize),typeof i.step=="function"&&(u=i.step),(typeof i.mode=="string"||typeof i.mode=="number")&&(l=Xl(i.mode)));let p,g=0,h=0,_=!1,A,b,I,w=a*s;function H($){if(_)return;_=!0;let X=0,Z;A||b?(Z=c(()=>{--X===0&&o($)},"cbfinal"),A&&(t===Wn||t.outgoing.state==="open")&&++X,b&&(e===Wn||e.outgoing.state==="open")&&++X,A&&(t===Wn||t.outgoing.state==="open")&&t.close(A,Z),b&&(e===Wn||e.outgoing.state==="open")&&e.close(b,Z)):o($)}c(H,"onerror"),t.open(r,"r",($,X)=>{if($)return H($);A=X,d===void 0?t.fstat(A,Z):Z(null,{size:d});function Z(Y,P){if(Y){if(t!==Wn){t.stat(r,(k,M)=>{if(k)return H(Y);Z(null,M)});return}return H(Y)}p=P.size,e.open(n,"w",(k,M)=>{if(k)return H(k);if(b=M,p<=0)return H();for(;w>p;){if(s===1){w=p;break}w-=a,--s}if(I=Rv(w),I instanceof Error)return H(I);l!==void 0?e.fchmod(b,l,c(function B(G){if(G){e.chmod(n,l,ee=>B());return}j()},"tryAgain")):j();function L(B,G,ee,C,W,q){if(B)return H(B);W=W||0,e.write(b,I,W,G,C,J);function J(ue){if(ue)return H(ue);if(h+=G,u&&u(h,G,p),G<q)return F(W,C+G,q-G);if(h===p){e.close(b,he=>{if(b=void 0,he)return H(he);t.close(A,bt=>{if(A=void 0,bt)return H(bt);o()})});return}if(g>=p)return;let me=g+a>p?p-g:a;F(W,g,me),g+=me}c(J,"writeCb")}c(L,"onread");function T(B,G,ee){return(C,W,q)=>{L(C,W,q,G,B,ee)}}c(T,"makeCb");function F(B,G,ee){t.read(A,I,B,ee,G,T(B,G,ee))}c(F,"singleRead");function j(){let B=0,G=0;for(;g<p&&B<s;){let ee=g+a>p?p-g:a;F(G,g,ee),G+=ee,g+=ee,++B}}c(j,"startReads")})}c(Z,"tryStat")})}c(Om,"fastXfer");function Vl(t,e,r,n,i,o,s){let a=typeof s=="function"?s:void 0;t.write(e,r,n,i,o,(u,l)=>{if(u)return t.close(e,()=>{a&&a(u)});l===i?t.close(e,a):(n+=l,i-=l,o+=l,Vl(t,e,r,n,i,o,a))})}c(Vl,"writeAll");var Xa=class{static{c(this,"Stats")}constructor(e){this.mode=e&&e.mode,this.uid=e&&e.uid,this.gid=e&&e.gid,this.size=e&&e.size,this.atime=e&&e.atime,this.mtime=e&&e.mtime,this.extended=e&&e.extended}isDirectory(){return(this.mode&Pr.S_IFMT)===Pr.S_IFDIR}isFile(){return(this.mode&Pr.S_IFMT)===Pr.S_IFREG}isBlockDevice(){return(this.mode&Pr.S_IFMT)===Pr.S_IFBLK}isCharacterDevice(){return(this.mode&Pr.S_IFMT)===Pr.S_IFCHR}isSymbolicLink(){return(this.mode&Pr.S_IFMT)===Pr.S_IFLNK}isFIFO(){return(this.mode&Pr.S_IFMT)===Pr.S_IFIFO}isSocket(){return(this.mode&Pr.S_IFMT)===Pr.S_IFSOCK}};function fi(t){let e=0,r=0;if(typeof t=="object"&&t!==null){if(typeof t.size=="number"){e|=In.SIZE;let n=t.size;$e[r++]=n/72057594037927940,$e[r++]=n/281474976710656,$e[r++]=n/1099511627776,$e[r++]=n/4294967296,$e[r++]=n/16777216,$e[r++]=n/65536,$e[r++]=n/256,$e[r++]=n}if(typeof t.uid=="number"&&typeof t.gid=="number"){e|=In.UIDGID;let n=t.uid,i=t.gid;$e[r++]=n>>>24,$e[r++]=n>>>16,$e[r++]=n>>>8,$e[r++]=n,$e[r++]=i>>>24,$e[r++]=i>>>16,$e[r++]=i>>>8,$e[r++]=i}if(typeof t.mode=="number"||typeof t.mode=="string"){let n=Xl(t.mode);e|=In.PERMISSIONS,$e[r++]=n>>>24,$e[r++]=n>>>16,$e[r++]=n>>>8,$e[r++]=n}if((typeof t.atime=="number"||ql(t.atime))&&(typeof t.mtime=="number"||ql(t.mtime))){let n=ro(t.atime),i=ro(t.mtime);e|=In.ACMODTIME,$e[r++]=n>>>24,$e[r++]=n>>>16,$e[r++]=n>>>8,$e[r++]=n,$e[r++]=i>>>24,$e[r++]=i>>>16,$e[r++]=i>>>8,$e[r++]=i}}return{flags:e,nb:r}}c(fi,"attrsToBytes");function ro(t){if(typeof t=="number"&&t===t)return t;if(ql(t))return parseInt(t.getTime()/1e3,10);throw new Error(`Cannot parse time: ${t}`)}c(ro,"toUnixTimestamp");function Xl(t){if(typeof t=="number"&&t===t)return t;if(typeof t=="string")return Xl(parseInt(t,8));throw new Error(`Cannot parse mode: ${t}`)}c(Xl,"modeNum");var Kl={r:Te.READ,"r+":Te.READ|Te.WRITE,w:Te.TRUNC|Te.CREAT|Te.WRITE,wx:Te.TRUNC|Te.CREAT|Te.WRITE|Te.EXCL,xw:Te.TRUNC|Te.CREAT|Te.WRITE|Te.EXCL,"w+":Te.TRUNC|Te.CREAT|Te.READ|Te.WRITE,"wx+":Te.TRUNC|Te.CREAT|Te.READ|Te.WRITE|Te.EXCL,"xw+":Te.TRUNC|Te.CREAT|Te.READ|Te.WRITE|Te.EXCL,a:Te.APPEND|Te.CREAT|Te.WRITE,ax:Te.APPEND|Te.CREAT|Te.WRITE|Te.EXCL,xa:Te.APPEND|Te.CREAT|Te.WRITE|Te.EXCL,"a+":Te.APPEND|Te.CREAT|Te.READ|Te.WRITE,"ax+":Te.APPEND|Te.CREAT|Te.READ|Te.WRITE|Te.EXCL,"xa+":Te.APPEND|Te.CREAT|Te.READ|Te.WRITE|Te.EXCL};function Fm(t){let e=Kl[t];return e!==void 0?e:null}c(Fm,"stringToFlags");var Nv=(()=>{let t=Object.keys(Kl);return e=>{for(let r=0;r<t.length;++r){let n=t[r];if(Kl[n]===e)return n}return null}})();function no(t){let e=U.readUInt32BE();if(e===void 0)return;let r=new Xa;if(e&In.SIZE){let n=U.readUInt64BE(t);if(n===void 0)return;r.size=n}if(e&In.UIDGID){let n=U.readUInt32BE(),i=U.readUInt32BE();if(i===void 0)return;r.uid=n,r.gid=i}if(e&In.PERMISSIONS){let n=U.readUInt32BE();if(n===void 0)return;r.mode=n}if(e&In.ACMODTIME){let n=U.readUInt32BE(),i=U.readUInt32BE();if(i===void 0)return;r.atime=n,r.mtime=i}if(e&In.EXTENDED){let n=U.readUInt32BE();if(n===void 0)return;let i={};for(let o=0;o<n;++o){let s=U.readString(!0),a=U.readString();if(a===void 0)return;i[s]=a}r.extended=i}return r}c(no,"readAttrs");function lt(t,e){let r=Hm(t,e);return r!==void 0?(t._buffer.push(r),!1):!0}c(lt,"sendOrBuffer");function Hm(t,e){let r=t.outgoing;if(r.state!=="open")return;if(r.window===0)return t._waitWindow=!0,t._chunkcb=$m,e;let n,i=e.length,o=0;for(;i-o>0&&r.window>0;){let s=Math.min(i-o,r.window,r.packetSize);r.window-=s,r.window===0&&(t._waitWindow=!0,t._chunkcb=$m),o===0&&s===i?t._protocol.channelData(t.outgoing.id,e):t._protocol.channelData(t.outgoing.id,io(e,o,o+s)),o+=s}return i-o>0&&(o>0?n=io(e,o,i):n=e),n}c(Hm,"tryWritePayload");function $m(){this._chunkcb=void 0;let t=this._buffer,e=0;for(;e<t.length;){let r=t[e],n=Hm(this,r);if(n!==void 0){n!==r&&(t[e]=n),e>0&&(this._buffer=t.slice(e));return}++e}e>0&&(this._buffer=[])}c($m,"drainBuffer");function yt(t,e,r){let n=new Error(e);return n.level="sftp-protocol",!r&&t._debug&&t._debug(`SFTP: Inbound: ${e}`),t.emit("error",n),t.destroy(),jm(t),!1}c(yt,"doFatalSFTPError");function jm(t){let e=Object.keys(t._requests);if(e.length===0)return;let r=t._requests;t._requests={};let n=new Error("No response from server");for(let i=0;i<e.length;++i){let o=r[e[i]];typeof o.cb=="function"&&o.cb(n)}}c(jm,"cleanupRequests");function Ov(t,e){let r=9,n=Buffer.allocUnsafe(31);K(n,n.length-4,0),n[4]=Ne.EXTENDED;let i=t._writeReqid=t._writeReqid+1&St;K(n,i,5),K(n,18,r),n.utf8Write("limits@openssh.com",r+=4,18),t._requests[i]={extended:"limits@openssh.com",cb:e};let o=lt(t,n);if(t._debug){let s=o?"Buffered":"Sending";t._debug(`SFTP: Outbound: ${s} limits@openssh.com`)}}c(Ov,"requestLimits");var $v={[Tr.VERSION]:(t,e)=>{if(t._version!==-1)return yt(t,"Duplicate VERSION packet");let r={};U.init(e,1);let n=U.readUInt32BE();for(;U.avail();){let i=U.readString(!0),o=U.readString(!0);if(o===void 0){n=void 0;break}r[i]=o}if(U.clear(),n===void 0)return yt(t,"Malformed VERSION packet");if(t._debug){let i=Object.keys(r);i.length?t._debug(`SFTP: Inbound: Received VERSION (v${n}, exts:${i})`):t._debug(`SFTP: Inbound: Received VERSION (v${n})`)}if(t._version=n,t._extensions=r,r["limits@openssh.com"]==="1")return Ov(t,(i,o)=>{i||(o.maxPktLen>0&&(t._maxOutPktLen=o.maxPktLen),o.maxReadLen>0&&(t._maxReadLen=o.maxReadLen),o.maxWriteLen>0&&(t._maxWriteLen=o.maxWriteLen),t.maxOpenHandles=o.maxOpenHandles>0?o.maxOpenHandles:1/0),t.emit("ready")});t.emit("ready")},[Tr.STATUS]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readUInt32BE(),i=U.readString(!0);if(U.clear(),t._debug){let s=JSON.stringify(i);t._debug(`SFTP: Inbound: Received STATUS (id:${r}, ${n}, ${s})`)}let o=t._requests[r];if(delete t._requests[r],o&&typeof o.cb=="function"){if(n===ht.OK){o.cb();return}let s=new Error(i||wv[n]||"Unknown status");s.code=n,o.cb(s)}},[Tr.HANDLE]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0)return r!==void 0&&delete t._requests[r],yt(t,"Malformed HANDLE packet");t._debug&&t._debug(`SFTP: Inbound: Received HANDLE (id:${r})`);let i=t._requests[r];delete t._requests[r],i&&typeof i.cb=="function"&&i.cb(void 0,n)},[Tr.DATA]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n;if(r!==void 0&&(n=t._requests[r],delete t._requests[r]),n&&typeof n.cb=="function")if(n.buffer){let i=U.readString(n.buffer);if(U.clear(),i!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received DATA (id:${r}, ${i})`),n.cb(void 0,n.buffer,i);return}}else{let i=U.readString();if(U.clear(),i!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received DATA (id:${r}, ${i.length})`),n.cb(void 0,i);return}}else{let i=U.skipString();if(U.clear(),i!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received DATA (id:${r}, ${i})`);return}}return yt(t,"Malformed DATA packet")},[Tr.NAME]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n;r!==void 0&&(n=t._requests[r],delete t._requests[r]);let i=U.readUInt32BE();if(i!==void 0){let o=[];for(let s=0;s<i;++s){let a=U.readString(!0),u=U.readString(!0),l=no(t._biOpt);if(l===void 0){o=void 0;break}o.push({filename:a,longname:u,attrs:l})}if(o!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received NAME (id:${r}, ${o.length})`),U.clear(),n&&typeof n.cb=="function"&&n.cb(void 0,o);return}}return U.clear(),yt(t,"Malformed NAME packet")},[Tr.ATTRS]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n;r!==void 0&&(n=t._requests[r],delete t._requests[r]);let i=no(t._biOpt);if(U.clear(),i!==void 0){t._debug&&t._debug(`SFTP: Inbound: Received ATTRS (id:${r})`),n&&typeof n.cb=="function"&&n.cb(void 0,i);return}return yt(t,"Malformed ATTRS packet")},[Tr.EXTENDED]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE();if(r!==void 0){let n=t._requests[r];if(n)switch(delete t._requests[r],n.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let i=t._biOpt,o={f_bsize:U.readUInt64BE(i),f_frsize:U.readUInt64BE(i),f_blocks:U.readUInt64BE(i),f_bfree:U.readUInt64BE(i),f_bavail:U.readUInt64BE(i),f_files:U.readUInt64BE(i),f_ffree:U.readUInt64BE(i),f_favail:U.readUInt64BE(i),f_sid:U.readUInt64BE(i),f_flag:U.readUInt64BE(i),f_namemax:U.readUInt64BE(i)};if(o.f_namemax===void 0)break;t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ${n.extended})`),U.clear(),typeof n.cb=="function"&&n.cb(void 0,o);return}case"limits@openssh.com":{let i={maxPktLen:U.readUInt64BE(),maxReadLen:U.readUInt64BE(),maxWriteLen:U.readUInt64BE(),maxOpenHandles:U.readUInt64BE()};if(i.maxOpenHandles===void 0)break;t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ${n.extended})`),U.clear(),typeof n.cb=="function"&&n.cb(void 0,i);return}case"users-groups-by-id@openssh.com":{let i=U.readUInt32BE();if(i===void 0)break;let o=new Array(i);for(let u=0;u<o.length;++u)o[u]=U.readString(!0);let s=U.readUInt32BE();if(s===void 0)break;let a=new Array(s);for(let u=0;u<a.length;++u)a[u]=U.readString(!0);if(a.length>0&&a[a.length-1]===void 0)break;t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ${n.extended})`),U.clear(),typeof n.cb=="function"&&n.cb(void 0,o,a);return}default:t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ???)`),U.clear(),typeof n.cb=="function"&&n.cb();return}else{t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${r}, ???)`),U.clear();return}}return U.clear(),yt(t,"Malformed EXTENDED_REPLY packet")}},Dv={[Ne.INIT]:(t,e)=>{if(t._version!==-1)return yt(t,"Duplicate INIT packet");let r={};U.init(e,1);let n=U.readUInt32BE();for(;U.avail();){let i=U.readString(!0),o=U.readString(!0);if(o===void 0){n=void 0;break}r[i]=o}if(U.clear(),n===void 0)return yt(t,"Malformed INIT packet");if(t._debug){let i=Object.keys(r);i.length?t._debug(`SFTP: Inbound: Received INIT (v${n}, exts:${i})`):t._debug(`SFTP: Inbound: Received INIT (v${n})`)}lt(t,Tv),t._version=n,t._extensions=r,t.emit("ready")},[Ne.OPEN]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=U.readUInt32BE(),o=no(t._biOpt);if(U.clear(),o===void 0)return yt(t,"Malformed OPEN packet");t._debug&&t._debug(`SFTP: Inbound: Received OPEN (id:${r})`),t.emit("OPEN",r,n,i,o)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.CLOSE]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0||n.length>256)return yt(t,"Malformed CLOSE packet");t._debug&&t._debug(`SFTP: Inbound: Received CLOSE (id:${r})`),t.emit("CLOSE",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.READ]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(),i=U.readUInt64BE(t._biOpt),o=U.readUInt32BE();if(U.clear(),o===void 0||n.length>256)return yt(t,"Malformed READ packet");t._debug&&t._debug(`SFTP: Inbound: Received READ (id:${r})`),t.emit("READ",r,n,i,o)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.WRITE]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(),i=U.readUInt64BE(t._biOpt),o=U.readString();if(U.clear(),o===void 0||n.length>256)return yt(t,"Malformed WRITE packet");t._debug&&t._debug(`SFTP: Inbound: Received WRITE (id:${r})`),t.emit("WRITE",r,n,i,o)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.LSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed LSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received LSTAT (id:${r})`),t.emit("LSTAT",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.FSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0||n.length>256)return yt(t,"Malformed FSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received FSTAT (id:${r})`),t.emit("FSTAT",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.SETSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=no(t._biOpt);if(U.clear(),i===void 0)return yt(t,"Malformed SETSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received SETSTAT (id:${r})`),t.emit("SETSTAT",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.FSETSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(),i=no(t._biOpt);if(U.clear(),i===void 0||n.length>256)return yt(t,"Malformed FSETSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received FSETSTAT (id:${r})`),t.emit("FSETSTAT",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.OPENDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed OPENDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received OPENDIR (id:${r})`),t.emit("OPENDIR",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.READDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0||n.length>256)return yt(t,"Malformed READDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received READDIR (id:${r})`),t.emit("READDIR",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.REMOVE]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed REMOVE packet");t._debug&&t._debug(`SFTP: Inbound: Received REMOVE (id:${r})`),t.emit("REMOVE",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.MKDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=no(t._biOpt);if(U.clear(),i===void 0)return yt(t,"Malformed MKDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received MKDIR (id:${r})`),t.emit("MKDIR",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.RMDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed RMDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received RMDIR (id:${r})`),t.emit("RMDIR",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.REALPATH]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed REALPATH packet");t._debug&&t._debug(`SFTP: Inbound: Received REALPATH (id:${r})`),t.emit("REALPATH",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.STAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed STAT packet");t._debug&&t._debug(`SFTP: Inbound: Received STAT (id:${r})`),t.emit("STAT",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.RENAME]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=U.readString(!0);if(U.clear(),i===void 0)return yt(t,"Malformed RENAME packet");t._debug&&t._debug(`SFTP: Inbound: Received RENAME (id:${r})`),t.emit("RENAME",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.READLINK]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(U.clear(),n===void 0)return yt(t,"Malformed READLINK packet");t._debug&&t._debug(`SFTP: Inbound: Received READLINK (id:${r})`),t.emit("READLINK",r,n)||t.status(r,ht.OP_UNSUPPORTED)},[Ne.SYMLINK]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=U.readString(!0);if(U.clear(),i===void 0)return yt(t,"Malformed SYMLINK packet");t._debug&&t._debug(`SFTP: Inbound: Received SYMLINK (id:${r})`);let o;t._isOpenSSH?o=t.emit("SYMLINK",r,i,n):o=t.emit("SYMLINK",r,n,i),o||t.status(r,ht.OP_UNSUPPORTED)},[Ne.EXTENDED]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0);if(n===void 0)return U.clear(),yt(t,"Malformed EXTENDED packet");let i;U.avail()&&(i=U.readRaw()),U.clear(),t._debug&&t._debug(`SFTP: Inbound: Received EXTENDED (id:${r})`),t.emit("EXTENDED",r,n,i)||t.status(r,ht.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:Bv,ERR_OUT_OF_RANGE:Ya,validateNumber:Uv}=Rm(),Dm=128,Ir,Gl=[];function Lv(t){Gl.length>0?Ir=Gl.pop():Ir=Buffer.allocUnsafe(t),Ir.used=0}c(Lv,"allocNewPool");function Zl(t,e){if(!Number.isSafeInteger(t))throw Uv(t,e),Number.isInteger(t)?new Ya(e,">= 0 and <= 2 ** 53 - 1",t):new Ya(e,"an integer",t);if(t<0)throw new Ya(e,">= 0 and <= 2 ** 53 - 1",t)}c(Zl,"checkPosition");function Wl(t){return t+7&-8}c(Wl,"roundUpToMultipleOf8");function vn(t,e,r){if(r===void 0)r={};else if(typeof r=="string")r={encoding:r};else{if(r===null||typeof r!="object")throw new TypeError('"options" argument must be a string or an object');r=Object.create(r)}if(r.highWaterMark===void 0&&(r.highWaterMark=64*1024),r.emitClose=!1,r.autoDestroy=!1,Um.call(this,r),this.path=e,this.flags=r.flags===void 0?"r":r.flags,this.mode=r.mode===void 0?438:r.mode,this.start=r.start,this.end=r.end,this.autoClose=r.autoClose===void 0?!0:r.autoClose,this.pos=0,this.bytesRead=0,this.isClosed=!1,this.handle=r.handle===void 0?null:r.handle,this.sftp=t,this._opening=!1,this.start!==void 0&&(Zl(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(Zl(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new Ya("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}c(vn,"ReadStream");Lm(vn,Um);vn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(t,e)=>{if(this._opening=!1,t){this.emit("error",t),this.autoClose&&this.destroy();return}this.handle=e,this.emit("open",e),this.emit("ready"),this.read()}))};vn.prototype._read=function(t){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(t));if(this.destroyed)return;(!Ir||Ir.length-Ir.used<Dm)&&Lv(this.readableHighWaterMark||this._readableState.highWaterMark);let e=Ir,r=Math.min(Ir.length-Ir.used,t),n=Ir.used;if(this.end!==void 0&&(r=Math.min(this.end-this.pos+1,r)),r<=0)return this.push(null);this.sftp.read(this.handle,Ir,Ir.used,r,this.pos,(i,o)=>{if(i){this.emit("error",i),this.autoClose&&this.destroy();return}let s=null;if(n+r===e.used&&e===Ir)e.used=Wl(e.used+o-r);else{let a=n+r&-8,u=Wl(n+o);a-u>=Dm&&Gl.push(e.slice(u,a))}o>0&&(this.bytesRead+=o,s=e.slice(n,n+o)),this.pos+=o,this.push(s)}),Ir.used=Wl(Ir.used+r)};vn.prototype._destroy=function(t,e){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",Bm.bind(null,this,e,t));return}Bm(this,e,t),this.handle=null,this._opening=!1};function Bm(t,e,r){if(!t.handle)return n();t.sftp.close(t.handle,n);function n(i){i=i||r,e(i),t.isClosed=!0,i||t.emit("close")}c(n,"onclose")}c(Bm,"closeStream");vn.prototype.close=function(t){this.destroy(null,t)};Object.defineProperty(vn.prototype,"pending",{get(){return this.handle===null},configurable:!0});function Fr(t,e,r){if(r===void 0)r={};else if(typeof r=="string")r={encoding:r};else{if(r===null||typeof r!="object")throw new TypeError('"options" argument must be a string or an object');r=Object.create(r)}r.emitClose=!1,r.autoDestroy=!1,Yl.call(this,r),this.path=e,this.flags=r.flags===void 0?"w":r.flags,this.mode=r.mode===void 0?438:r.mode,this.start=r.start,this.autoClose=r.autoClose===void 0?!0:r.autoClose,this.pos=0,this.bytesWritten=0,this.isClosed=!1,this.handle=r.handle===void 0?null:r.handle,this.sftp=t,this._opening=!1,this.start!==void 0&&(Zl(this.start,"start"),this.pos=this.start),r.encoding&&this.setDefaultEncoding(r.encoding),this.on("finish",function(){this._writableState.finalCalled||this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}c(Fr,"WriteStream");Lm(Fr,Yl);Fr.prototype._final=function(t){this.autoClose&&this.destroy(),t()};Fr.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(t,e)=>{if(this._opening=!1,t){this.emit("error",t),this.autoClose&&this.destroy();return}this.handle=e;let r=c(n=>{if(n){this.sftp.chmod(this.path,this.mode,i=>r());return}if(this.flags[0]==="a"){let i=c((o,s)=>{if(o){this.sftp.stat(this.path,(a,u)=>{if(a){this.destroy(),this.emit("error",o);return}i(null,u)});return}this.pos=s.size,this.emit("open",e),this.emit("ready")},"tryStat");this.sftp.fstat(e,i);return}this.emit("open",e),this.emit("ready")},"tryAgain");this.sftp.fchmod(e,this.mode,r)}))};Fr.prototype._write=function(t,e,r){if(!Buffer.isBuffer(t)){let n=new Bv("data","Buffer",t);return this.emit("error",n)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(t,e,r)});this.sftp.write(this.handle,t,0,t.length,this.pos,(n,i)=>{if(n)return this.autoClose&&this.destroy(),r(n);this.bytesWritten+=i,r()}),this.pos+=t.length};Fr.prototype._writev=function(t,e){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(t,e)});let r=this.sftp,n=this.handle,i=t.length,o=c((s,a)=>{if(s)return this.destroy(),e(s);this.bytesWritten+=a,--i===0&&e()},"onwrite");for(let s=0;s<t.length;++s){let a=t[s].chunk;r.write(n,a,0,a.length,this.pos,o),this.pos+=a.length}};typeof Yl.prototype.destroy!="function"&&(Fr.prototype.destroy=vn.prototype.destroy);Fr.prototype._destroy=vn.prototype._destroy;Fr.prototype.close=function(t){if(t){if(this.isClosed){process.nextTick(t);return}this.on("close",t)}this.autoClose||this.on("finish",this.destroy.bind(this)),this.end()};Fr.prototype.destroySoon=Fr.prototype.end;Object.defineProperty(Fr.prototype,"pending",{get(){return this.handle===null},configurable:!0});Wm.exports={flagsToString:Nv,OPEN_MODE:Te,SFTP:Ql,Stats:Xa,STATUS_CODE:ht,stringToFlags:Fm}});var of=le((EF,Km)=>{"use strict";var{Duplex:zv,Readable:Mv,Writable:Fv}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:qm}}=An(),{bufferSlice:Ja}=Qr(),Hv=32*1024,hs=2*1024*1024,rf=hs/2,Jl=class extends Mv{static{c(this,"ClientStderr")}constructor(e,r){super(r),this._channel=e}_read(e){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=rf&&nf(this._channel))}},ef=class extends Fv{static{c(this,"ServerStderr")}constructor(e){super({highWaterMark:hs}),this._channel=e}_write(e,r,n){let i=this._channel,o=i._client._protocol,s=i.outgoing,a=s.packetSize,u=s.id,l=s.window,d=e.length,p=0;if(s.state==="open"){for(;d-p>0&&l>0;){let g=d-p;g>l&&(g=l),g>a&&(g=a),p===0&&g===d?o.channelExtData(u,e,qm):o.channelExtData(u,Ja(e,p,p+g),qm),p+=g,l-=g}if(s.window=l,d-p>0){l===0&&(i._waitWindow=!0),p>0?i._chunkErr=Ja(e,p,d):i._chunkErr=e,i._chunkcbErr=n;return}n()}}},tf=class extends zv{static{c(this,"Channel")}constructor(e,r,n){let i={highWaterMark:hs,allowHalfOpen:!n||n&&n.allowHalfOpen!==!1,emitClose:!1};super(i),this.allowHalfOpen=i.allowHalfOpen;let o=!!(n&&n.server);this.server=o,this.type=r.type,this.subtype=void 0,this.incoming=r.incoming,this.outgoing=r.outgoing,this._callbacks=[],this._client=e,this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this.stdin=this.stdout=this,o?this.stderr=new ef(this):this.stderr=new Jl(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",Qm).on("prefinish",Qm),this.on("end",Vm).on("close",Vm)}_read(e){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=rf&&nf(this))}_write(e,r,n){let i=this._client._protocol,o=this.outgoing,s=o.packetSize,a=o.id,u=o.window,l=e.length,d=0;if(o.state==="open"){for(;l-d>0&&u>0;){let p=l-d;p>u&&(p=u),p>s&&(p=s),d===0&&p===l?i.channelData(a,e):i.channelData(a,Ja(e,d,d+p)),d+=p,u-=p}if(o.window=u,l-d>0){u===0&&(this._waitWindow=!0),d>0?this._chunk=Ja(e,d,l):this._chunk=e,this._chunkcb=n;return}n()}}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(e,r,n,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,e,r,n,i)}signal(e){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,e)}exit(e,r,n){if(!this.server)throw new Error("Server-only method called in client mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&(typeof e=="number"?this._client._protocol.exitStatus(this.outgoing.id,e):this._client._protocol.exitSignal(this.outgoing.id,e,r,n))}};function Qm(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}c(Qm,"onFinish");function Vm(){this.readable=!1}c(Vm,"onEnd");function nf(t){if(t.outgoing.state==="closed")return;let e=hs-t.incoming.window;e<=0||(t.incoming.window+=e,t._client._protocol.channelWindowAdjust(t.outgoing.id,e))}c(nf,"windowAdjust");Km.exports={Channel:tf,MAX_WINDOW:hs,PACKET_SIZE:Hv,windowAdjust:nf,WINDOW_THRESHOLD:rf}});var cf=le((bF,Ym)=>{"use strict";var{SFTP:jv}=ps(),gs=2**32-1;function Gm(t,e,r,n){if(t._chanMgr.remove(e),typeof n!="function")return;let i;r instanceof Error?i=r:typeof r=="object"&&r!==null?(i=new Error(`(SSH) Channel open failure: ${r.description}`),i.reason=r.reason):(i=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),i.reason=""),n(i)}c(Gm,"onChannelOpenFailure");function Zm(t,e,r,n,i){if(typeof r=="function"){Gm(t,e,n,r);return}if(typeof r!="object"||r===null||r.incoming&&r.incoming.state==="closed"||(t._chanMgr.remove(e),r.server&&r.constructor.name==="Session"))return;r.incoming.state="closed",r.readable&&r.push(null),r.server?r.stderr.writable&&r.stderr.end():r.stderr.readable&&r.stderr.push(null),r.constructor!==jv&&(r.outgoing.state==="open"||r.outgoing.state==="eof")&&!i&&r.close(),r.outgoing.state==="closing"&&(r.outgoing.state="closed");let o=r._readableState,s=r._writableState;s&&!s.ending&&!s.finished&&!i&&r.end();let a=r._callbacks;r._callbacks=[];for(let u=0;u<a.length;++u)a[u](!0);if(r.server)!r.readable||r.destroyed||o&&o.endEmitted?r.emit("close"):r.once("end",()=>r.emit("close"));else{let u;switch(r.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":u=c(()=>r.emit("close"),"doClose");break;default:{let d=r._exit;u=c(()=>{d.code===null?r.emit("close",d.code,d.signal,d.dump,d.desc):r.emit("close",d.code)},"doClose")}}!r.readable||r.destroyed||o&&o.endEmitted?u():r.once("end",u);let l=r.stderr._readableState;!r.stderr.readable||r.stderr.destroyed||l&&l.endEmitted?r.stderr.emit("close"):r.stderr.once("end",()=>r.stderr.emit("close"))}}c(Zm,"onCHANNEL_CLOSE");var af=class{static{c(this,"ChannelManager")}constructor(e){this._client=e,this._channels={},this._cur=-1,this._count=0}add(e){let r;if(this._cur<gs)r=++this._cur;else if(this._count===0)this._cur=0,r=0;else{let n=this._channels;for(let i=0;i<gs;++i)if(n[i]===void 0){r=i;break}}return r===void 0?-1:(this._channels[r]=e||!0,++this._count,r)}update(e,r){if(typeof e!="number"||e<0||e>=gs||!isFinite(e))throw new Error(`Invalid channel id: ${e}`);r&&this._channels[e]&&(this._channels[e]=r)}get(e){if(typeof e!="number"||e<0||e>=gs||!isFinite(e))throw new Error(`Invalid channel id: ${e}`);return this._channels[e]}remove(e){if(typeof e!="number"||e<0||e>=gs||!isFinite(e))throw new Error(`Invalid channel id: ${e}`);this._channels[e]&&(delete this._channels[e],this._count&&--this._count)}cleanup(e){let r=this._channels;this._channels={},this._cur=-1,this._count=0;let n=Object.keys(r),i=this._client;for(let o=0;o<n.length;++o){let s=+n[o],a=r[s];Zm(i,s,a._channel||a,e,!0)}}},sf=(()=>{let t=Object.prototype.toString;return e=>t.call(e)==="[object RegExp]"})();function Wv(t,e,r){if(Array.isArray(t)&&t.length>0){for(let n=0;n<t.length;++n)if(r.indexOf(t[n])===-1)throw new Error(`Unsupported algorithm: ${t[n]}`);return t}if(typeof t=="object"&&t!==null){let n=Object.keys(t),i=e;for(let o=0;o<n.length;++o){let s=n[o],a=t[s];switch(s){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let u=0;u<a.length;++u){let l=a[u];if(typeof l=="string"){if(!l||i.indexOf(l)!==-1)continue;if(r.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);i===e&&(i=i.slice()),i.push(l)}else if(sf(l))for(let d=0;d<r.length;++d){let p=r[d];if(l.test(p)){if(i.indexOf(p)!==-1)continue;i===e&&(i=i.slice()),i.push(p)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let u=a.length;u>=0;--u){let l=a[u];if(typeof l=="string"){if(!l||i.indexOf(l)!==-1)continue;if(r.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);i===e&&(i=i.slice()),i.unshift(l)}else if(sf(l))for(let d=r.length;d>=0;--d){let p=r[d];if(l.test(p)){if(i.indexOf(p)!==-1)continue;i===e&&(i=i.slice()),i.unshift(p)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let u=0;u<a.length;++u){let l=a[u];if(typeof l=="string"){if(!l)continue;let d=i.indexOf(l);if(d===-1)continue;i===e&&(i=i.slice()),i.splice(d,1)}else if(sf(l))for(let d=0;d<i.length;++d)l.test(i[d])&&(i===e&&(i=i.slice()),i.splice(d,1),--d)}break}}return i}return e}c(Wv,"generateAlgorithmList");Ym.exports={ChannelManager:af,generateAlgorithmList:Wv,onChannelOpenFailure:Gm,onCHANNEL_CLOSE:Zm,isWritable:c(t=>t&&t.writable&&t._readableState&&t._readableState.ended===!1,"isWritable")}});var pf=le((IF,E_)=>{"use strict";var{createHash:qv,getHashes:Qv,randomFillSync:Vv}=require("crypto"),{Socket:Kv}=require("net"),{lookup:Gv}=require("dns"),Zv=require("events"),Yv=Qv(),{COMPAT:m_,CHANNEL_EXTENDED_DATATYPE:{STDERR:Xv},CHANNEL_OPEN_FAILURE:ms,DEFAULT_CIPHER:Xm,DEFAULT_COMPRESSION:Jm,DEFAULT_KEX:e_,DEFAULT_MAC:t_,DEFAULT_SERVER_HOST_KEY:r_,DISCONNECT_REASON:n_,DISCONNECT_REASON_BY_VALUE:Jv,SUPPORTED_CIPHER:eS,SUPPORTED_COMPRESSION:tS,SUPPORTED_KEX:rS,SUPPORTED_MAC:nS,SUPPORTED_SERVER_HOST_KEY:iS}=An(),{init:oS}=zn(),sS=Hl(),{parseKey:rc}=Hn(),{SFTP:aS}=ps(),{bufferCopy:i_,makeBufferParser:__,makeError:cS,readUInt32BE:uS,sigSSHToASN1:lS,writeUInt32BE:uf}=Qr(),{AgentContext:o_,createAgent:s_,isAgent:a_}=Pl(),{Channel:y_,MAX_WINDOW:nc,PACKET_SIZE:ic,windowAdjust:c_,WINDOW_THRESHOLD:u_}=of(),{ChannelManager:fS,generateAlgorithmList:_s,isWritable:rr,onChannelOpenFailure:dS,onCHANNEL_CLOSE:pS}=cf(),ec=__(),tc=__(),ys=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,ff=c(t=>{},"noop"),df=class extends Zv{static{c(this,"Client")}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(e){if(this._sock&&rr(this._sock))return this.once("close",()=>{this.connect(e)}),this.end(),this;this.config.host=e.hostname||e.host||"localhost",this.config.port=e.port||22,this.config.localAddress=typeof e.localAddress=="string"?e.localAddress:void 0,this.config.localPort=typeof e.localPort=="string"||typeof e.localPort=="number"?e.localPort:void 0,this.config.forceIPv4=e.forceIPv4||!1,this.config.forceIPv6=e.forceIPv6||!1,this.config.keepaliveCountMax=typeof e.keepaliveCountMax=="number"&&e.keepaliveCountMax>=0?e.keepaliveCountMax:3,this.config.keepaliveInterval=typeof e.keepaliveInterval=="number"&&e.keepaliveInterval>0?e.keepaliveInterval:0,this.config.readyTimeout=typeof e.readyTimeout=="number"&&e.readyTimeout>=0?e.readyTimeout:2e4,this.config.ident=typeof e.ident=="string"||Buffer.isBuffer(e.ident)?e.ident:void 0;let r={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:[]},sc:void 0},n=!0;if(typeof e.algorithms=="object"&&e.algorithms!==null&&(r.kex=_s(e.algorithms.kex,e_,rS),r.kex!==e_&&(n=!1),r.serverHostKey=_s(e.algorithms.serverHostKey,r_,iS),r.serverHostKey!==r_&&(n=!1),r.cs.cipher=_s(e.algorithms.cipher,Xm,eS),r.cs.cipher!==Xm&&(n=!1),r.cs.mac=_s(e.algorithms.hmac,t_,nS),r.cs.mac!==t_&&(n=!1),r.cs.compress=_s(e.algorithms.compress,Jm,tS),r.cs.compress!==Jm&&(n=!1),n||(r.sc=r.cs)),typeof e.username=="string")this.config.username=e.username;else if(typeof e.user=="string")this.config.username=e.user;else throw new Error("Invalid username");this.config.password=typeof e.password=="string"?e.password:void 0,this.config.privateKey=typeof e.privateKey=="string"||Buffer.isBuffer(e.privateKey)?e.privateKey:void 0,this.config.localHostname=typeof e.localHostname=="string"?e.localHostname:void 0,this.config.localUsername=typeof e.localUsername=="string"?e.localUsername:void 0,this.config.tryKeyboard=e.tryKeyboard===!0,typeof e.agent=="string"&&e.agent.length?this.config.agent=s_(e.agent):a_(e.agent)?this.config.agent=e.agent:this.config.agent=void 0,this.config.allowAgentFwd=e.agentForward===!0&&this.config.agent!==void 0;let i=this.config.authHandler=typeof e.authHandler=="function"||Array.isArray(e.authHandler)?e.authHandler:void 0;this.config.strictVendor=typeof e.strictVendor=="boolean"?e.strictVendor:!0;let o=this.config.debug=typeof e.debug=="function"?e.debug:void 0;if(e.agentForward===!0&&!this.config.allowAgentFwd)throw new Error("You must set a valid agent path to allow agent forwarding");let s=this._callbacks=[];this._chanMgr=new fS(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 a;if(this.config.privateKey){if(a=rc(this.config.privateKey,e.passphrase),a instanceof Error)throw new Error(`Cannot parse privateKey: ${a.message}`);if(Array.isArray(a)&&(a=a[0]),a.getPrivatePEM()===null)throw new Error("privateKey value does not contain a (valid) private key")}let u;if(typeof e.hostVerifier=="function"){let C=e.hostVerifier,W;Yv.indexOf(e.hostHash)!==-1&&(W=e.hostHash),u=c((q,J)=>{W&&(q=qv(W).update(q).digest("hex"));let ue=C(q,J);ue!==void 0&&J(ue)},"hostVerifier")}let l=this._sock=e.sock||new Kv,d=!1,p=!1;this._protocol&&this._protocol.cleanup();let g=o?(C,W,q)=>{o(`Debug output from server: ${JSON.stringify(q)}`)}:void 0,h,_=this._protocol=new sS({ident:this.config.ident,offer:n?void 0:r,onWrite:c(C=>{rr(l)&&l.write(C)},"onWrite"),onError:c(C=>{C.level==="handshake"&&clearTimeout(this._readyTimeout),_._destruct||l.removeAllListeners("data"),this.emit("error",C);try{l.end()}catch{}},"onError"),onHeader:c(C=>{p=!0,this._remoteVer=C.versions.software,C.greeting&&this.emit("greeting",C.greeting)},"onHeader"),onHandshakeComplete:c(C=>{this.emit("handshake",C),d||(d=!0,_.service("ssh-userauth"))},"onHandshakeComplete"),debug:o,hostVerifier:u,messageHandlers:{DEBUG:g,DISCONNECT:c((C,W,q)=>{if(W!==n_.BY_APPLICATION){q||(q=Jv[W],q===void 0&&(q=`Unexpected disconnection reason: ${W}`));let J=new Error(q);J.code=W,this.emit("error",J)}l.end()},"DISCONNECT"),SERVICE_ACCEPT:c((C,W)=>{W==="ssh-userauth"&&B()},"SERVICE_ACCEPT"),EXT_INFO:c((C,W)=>{if(h===void 0){for(let q of W)if(q.name==="server-sig-algs"){h=q.algs;return}h=null}},"EXT_INFO"),USERAUTH_BANNER:c((C,W)=>{this.emit("banner",W)},"USERAUTH_BANNER"),USERAUTH_SUCCESS:c(C=>{$(),clearTimeout(this._readyTimeout),this.emit("ready")},"USERAUTH_SUCCESS"),USERAUTH_FAILURE:c((C,W,q)=>{if(P.keyAlgos){let J=P.keyAlgos[0][0];if(o&&o(`Client: ${P.type} (${J}) auth failed`),P.keyAlgos.shift(),P.keyAlgos.length){let[ue,me]=P.keyAlgos[0];switch(P.type){case"agent":_.authPK(P.username,P.agentCtx.currentKey(),ue);return;case"publickey":_.authPK(P.username,P.key,ue);return;case"hostbased":_.authHostbased(P.username,P.key,P.localHostname,P.localUsername,ue,(he,bt)=>{let Ct=P.key.sign(he,me);if(Ct instanceof Error)return Ct.message=`Error while signing with key: ${Ct.message}`,Ct.level="client-authentication",this.emit("error",Ct),B();bt(Ct)});return}}else P.keyAlgos=void 0}if(P.type==="agent"){let J=P.agentCtx.pos();return o&&o(`Client: Agent key #${J+1} failed`),G()}o&&o(`Client: ${P.type} auth failed`),k=q,M=W,B()},"USERAUTH_FAILURE"),USERAUTH_PASSWD_CHANGEREQ:c((C,W)=>{P.type==="password"&&this.emit("change password",W,q=>{_.authPassword(this.config.username,this.config.password,q)})},"USERAUTH_PASSWD_CHANGEREQ"),USERAUTH_PK_OK:c(C=>{let W,q;if(P.keyAlgos&&([W,q]=P.keyAlgos[0]),P.type==="agent"){let J=P.agentCtx.currentKey();_.authPK(P.username,J,W,(ue,me)=>{let he={hash:q};P.agentCtx.sign(J,ue,he,(bt,Ct)=>{if(bt)bt.level="agent",this.emit("error",bt);else return me(Ct);G()})})}else P.type==="publickey"&&_.authPK(P.username,P.key,W,(J,ue)=>{let me=P.key.sign(J,q);if(me instanceof Error)return me.message=`Error signing data with key: ${me.message}`,me.level="client-authentication",this.emit("error",me),B();ue(me)})},"USERAUTH_PK_OK"),USERAUTH_INFO_REQUEST:c((C,W,q,J)=>{if(P.type==="keyboard-interactive"){if((Array.isArray(J)?J.length:0)===0){o&&o("Client: Sending automatic USERAUTH_INFO_RESPONSE"),_.authInfoRes();return}P.prompt(W,q,"",J,me=>{_.authInfoRes(me)})}},"USERAUTH_INFO_REQUEST"),REQUEST_SUCCESS:c((C,W)=>{s.length&&s.shift()(!1,W)},"REQUEST_SUCCESS"),REQUEST_FAILURE:c(C=>{s.length&&s.shift()(!0)},"REQUEST_FAILURE"),GLOBAL_REQUEST:c((C,W,q,J)=>{W==="hostkeys-00@openssh.com"?(yS(this,J,(ue,me)=>{ue||this.emit("hostkeys",me)}),q&&_.requestSuccess()):q&&_.requestFailure()},"GLOBAL_REQUEST"),CHANNEL_OPEN:c((C,W)=>{mS(this,W)},"CHANNEL_OPEN"),CHANNEL_OPEN_CONFIRMATION:c((C,W)=>{let q=this._chanMgr.get(W.recipient);if(typeof q!="function")return;let J=q.type==="sftp",me={type:J?"session":q.type,incoming:{id:W.recipient,window:nc,packetSize:ic,state:"open"},outgoing:{id:W.sender,window:W.window,packetSize:W.packetSize,state:"open"}},he=J?new aS(this,me,{debug:o}):new y_(this,me);this._chanMgr.update(W.recipient,he),q(void 0,he)},"CHANNEL_OPEN_CONFIRMATION"),CHANNEL_OPEN_FAILURE:c((C,W,q,J)=>{let ue=this._chanMgr.get(W);if(typeof ue!="function")return;dS(this,W,{reason:q,description:J},ue)},"CHANNEL_OPEN_FAILURE"),CHANNEL_DATA:c((C,W,q)=>{let J=this._chanMgr.get(W);if(!(typeof J!="object"||J===null)&&J.incoming.window!==0){if(J.incoming.window-=q.length,J.push(q)===!1){J._waitChanDrain=!0;return}J.incoming.window<=u_&&c_(J)}},"CHANNEL_DATA"),CHANNEL_EXTENDED_DATA:c((C,W,q,J)=>{if(J!==Xv)return;let ue=this._chanMgr.get(W);if(!(typeof ue!="object"||ue===null)&&ue.incoming.window!==0){if(ue.incoming.window-=q.length,!ue.stderr.push(q)){ue._waitChanDrain=!0;return}ue.incoming.window<=u_&&c_(ue)}},"CHANNEL_EXTENDED_DATA"),CHANNEL_WINDOW_ADJUST:c((C,W,q)=>{let J=this._chanMgr.get(W);typeof J!="object"||J===null||(J.outgoing.window+=q,J._waitWindow&&(J._waitWindow=!1,J._chunk?J._write(J._chunk,null,J._chunkcb):J._chunkcb?J._chunkcb():J._chunkErr?J.stderr._write(J._chunkErr,null,J._chunkcbErr):J._chunkcbErr&&J._chunkcbErr()))},"CHANNEL_WINDOW_ADJUST"),CHANNEL_SUCCESS:c((C,W)=>{let q=this._chanMgr.get(W);typeof q!="object"||q===null||(this._resetKA(),q._callbacks.length&&q._callbacks.shift()(!1))},"CHANNEL_SUCCESS"),CHANNEL_FAILURE:c((C,W)=>{let q=this._chanMgr.get(W);typeof q!="object"||q===null||(this._resetKA(),q._callbacks.length&&q._callbacks.shift()(!0))},"CHANNEL_FAILURE"),CHANNEL_REQUEST:c((C,W,q,J,ue)=>{let me=this._chanMgr.get(W);if(typeof me!="object"||me===null)return;let he=me._exit;if(he.code===void 0){switch(q){case"exit-status":me.emit("exit",he.code=ue);return;case"exit-signal":me.emit("exit",he.code=null,he.signal=`SIG${ue.signal}`,he.dump=ue.coreDumped,he.desc=ue.errorMessage);return}J&&C.channelFailure(me.outgoing.id)}},"CHANNEL_REQUEST"),CHANNEL_EOF:c((C,W)=>{let q=this._chanMgr.get(W);typeof q!="object"||q===null||q.incoming.state==="open"&&(q.incoming.state="eof",q.readable&&q.push(null),q.stderr.readable&&q.stderr.push(null))},"CHANNEL_EOF"),CHANNEL_CLOSE:c((C,W)=>{pS(this,W,this._chanMgr.get(W))},"CHANNEL_CLOSE")}});l.pause();let A=this.config.keepaliveInterval,b=this.config.keepaliveCountMax,I=0,w,H=c(()=>{if(++I>b){if(clearInterval(w),l.readable){let C=new Error("Keepalive timeout");C.level="client-timeout",this.emit("error",C),l.destroy()}return}rr(l)?(s.push($),_.ping()):clearInterval(w)},"sendKA");function $(){A>0&&(I=0,clearInterval(w),rr(l)&&(w=setInterval(H,A)))}c($,"resetKA"),this._resetKA=$;let X=(()=>{let C=!1;return()=>{if(!C&&(C=!0,Y&&!p)){let W=cS("Connection lost before handshake","protocol",!0);this.emit("error",W)}}})(),Z=(()=>{let C=!1;return()=>{C||(C=!0,Y=!0,o&&o("Socket connected"),this.emit("connect"),oS.then(()=>{_.start(),l.on("data",W=>{try{_.parse(W,0,W.length)}catch(q){this.emit("error",q);try{rr(l)&&l.end()}catch{}}}),l.stderr&&typeof l.stderr.resume=="function"&&l.stderr.resume(),l.resume()}).catch(W=>{this.emit("error",W);try{rr(l)&&l.end()}catch{}}))}})(),Y=!1;l.on("connect",Z).on("timeout",()=>{this.emit("timeout")}).on("error",C=>{o&&o(`Socket error: ${C.message}`),clearTimeout(this._readyTimeout),C.level="client-socket",this.emit("error",C)}).on("end",()=>{o&&o("Socket ended"),X(),_.cleanup(),clearTimeout(this._readyTimeout),clearInterval(w),this.emit("end")}).on("close",()=>{o&&o("Socket closed"),X(),_.cleanup(),clearTimeout(this._readyTimeout),clearInterval(w),this.emit("close");let C=s;s=this._callbacks=[];let W=new Error("No response from server");for(let q=0;q<C.length;++q)C[q](W);this._chanMgr.cleanup(W)});let P,k=null,M=null,L=["none"];this.config.password!==void 0&&L.push("password"),a!==void 0&&L.push("publickey"),this._agent!==void 0&&L.push("agent"),this.config.tryKeyboard&&L.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&L.push("hostbased"),Array.isArray(i)?i=g_(i):typeof i!="function"&&(i=g_(L));let T=!1,F=c(C=>{if(!T){if(T=!0,C===!1){let W=new Error("All configured authentication methods failed");W.level="client-authentication",this.emit("error",W),this.end();return}if(typeof C=="string"){let W=C;if(L.indexOf(W)===-1)return j(`Authentication method not allowed: ${W}`);let q=this.config.username;switch(W){case"password":C={type:W,username:q,password:this.config.password};break;case"publickey":C={type:W,username:q,key:a};break;case"hostbased":C={type:W,username:q,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":C={type:W,username:q,agentCtx:new o_(this._agent)};break;case"keyboard-interactive":C={type:W,username:q,prompt:c((...J)=>this.emit("keyboard-interactive",...J),"prompt")};break;case"none":C={type:W,username:q};break;default:return j(`Skipping unsupported authentication method: ${C}`)}}else{if(typeof C!="object"||C===null)return j(`Skipping invalid authentication attempt: ${C}`);{let W=C.username;if(typeof W!="string")return j(`Skipping invalid authentication attempt: ${C}`);let q=C.type;switch(q){case"password":{let{password:J}=C;if(typeof J!="string"&&!Buffer.isBuffer(J))return j("Skipping invalid password auth attempt");C={type:q,username:W,password:J};break}case"publickey":{let J=rc(C.key,C.passphrase);if(J instanceof Error)return j("Skipping invalid key auth attempt");if(!J.isPrivateKey())return j("Skipping non-private key");C={type:q,username:W,key:J};break}case"hostbased":{let{localHostname:J,localUsername:ue}=C,me=rc(C.key,C.passphrase);if(me instanceof Error||typeof J!="string"||typeof ue!="string")return j("Skipping invalid hostbased auth attempt");if(!me.isPrivateKey())return j("Skipping non-private key");C={type:q,username:W,key:me,localHostname:J,localUsername:ue};break}case"agent":{let J=C.agent;if(typeof J=="string"&&J.length)J=s_(J);else if(!a_(J))return j(`Skipping invalid agent: ${C.agent}`);C={type:q,username:W,agentCtx:new o_(J)};break}case"keyboard-interactive":{let{prompt:J}=C;if(typeof J!="function")return j("Skipping invalid keyboard-interactive auth attempt");C={type:q,username:W,prompt:J};break}case"none":C={type:q,username:W};break;default:return j(`Skipping unsupported authentication method: ${C}`)}}}P=C;try{let W=P.username;switch(P.type){case"password":_.authPassword(W,P.password);break;case"publickey":{let q;if(P.keyAlgos=lf(this,P.key,h),P.keyAlgos)if(P.keyAlgos.length)q=P.keyAlgos[0][0];else return j("Skipping key authentication (no mutual hash algorithm)");_.authPK(W,P.key,q);break}case"hostbased":{let q,J;if(P.keyAlgos=lf(this,P.key,h),P.keyAlgos)if(P.keyAlgos.length)[q,J]=P.keyAlgos[0];else return j("Skipping hostbased authentication (no mutual hash algorithm)");_.authHostbased(W,P.key,P.localHostname,P.localUsername,q,(ue,me)=>{let he=P.key.sign(ue,J);if(he instanceof Error)return he.message=`Error while signing with key: ${he.message}`,he.level="client-authentication",this.emit("error",he),B();me(he)});break}case"agent":P.agentCtx.init(q=>{if(q)return q.level="agent",this.emit("error",q),B();G()});break;case"keyboard-interactive":_.authKeyboard(W);break;case"none":_.authNone(W);break}}finally{T=!1}}},"doNextAuth");function j(C){o&&o(C),process.nextTick(B)}c(j,"skipAuth");function B(){T=!1;let C=i(M,k,F);T||C===void 0||F(C)}c(B,"tryNextAuth");let G=c(()=>{if(P.type==="agent"){let C=P.agentCtx.nextKey();if(C===!1)o&&o("Agent: No more keys left to try"),o&&o("Client: agent auth failed"),B();else{let W=P.agentCtx.pos(),q;if(P.keyAlgos=lf(this,C,h),P.keyAlgos)if(P.keyAlgos.length)q=P.keyAlgos[0][0];else{o&&o(`Agent: Skipping key #${W+1} (no mutual hash algorithm)`),G();return}o&&o(`Agent: Trying key #${W+1}`),_.authPK(P.username,C,q)}}},"tryNextAgentKey"),ee=c(()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let C=new Error("Timed out while waiting for handshake");C.level="client-timeout",this.emit("error",C),l.destroy()},this.config.readyTimeout))},"startTimeout");if(e.sock)ee(),typeof l.connecting=="boolean"&&l.connecting||Z();else{let C=this.config.host,W=this.config.forceIPv4,q=this.config.forceIPv6;o&&o(`Client: Trying ${C} on port ${this.config.port} ...`);let J=c(()=>{ee(),l.connect({host:C,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),l.setMaxListeners(0),l.setTimeout(typeof e.timeout=="number"?e.timeout:0)},"doConnect");!W&&!q||W&&q?J():Gv(C,W?4:6,(ue,me,he)=>{if(ue){let bt=W?"IPv4":"IPv6",Ct=new Error(`Error while looking up ${bt} address for '${C}': ${ue}`);clearTimeout(this._readyTimeout),Ct.level="client-dns",this.emit("error",Ct),this.emit("close");return}C=me,J()})}return this}end(){return this._sock&&rr(this._sock)&&(this._protocol.disconnect(n_.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&rr(this._sock)&&this._sock.destroy(),this}exec(e,r,n){if(!this._sock||!rr(this._sock))throw new Error("Not connected");typeof r=="function"&&(n=r,r={});let i={allowHalfOpen:r.allowHalfOpen!==!1};return oo(this,"session",i,(o,s)=>{if(o){n(o);return}let a=[];function u(l){if(l){s.close(),n(l);return}a.length&&a.shift()()}c(u,"reqCb"),(this.config.allowAgentFwd===!0||r&&r.agentForward===!0&&this._agent!==void 0)&&a.push(()=>d_(s,u)),typeof r=="object"&&r!==null&&(typeof r.env=="object"&&r.env!==null&&p_(s,r.env),(typeof r.pty=="object"&&r.pty!==null||r.pty===!0)&&a.push(()=>f_(s,r.pty,u)),(typeof r.x11=="object"&&r.x11!==null||r.x11==="number"||r.x11===!0)&&a.push(()=>l_(s,r.x11,u))),a.push(()=>gS(s,e,r,n)),a.shift()()}),this}shell(e,r,n){if(!this._sock||!rr(this._sock))throw new Error("Not connected");return typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),e&&(e.x11!==void 0||e.env!==void 0)&&(r=e,e=void 0),oo(this,"session",(i,o)=>{if(i){n(i);return}let s=[];function a(u){if(u){o.close(),n(u);return}s.length&&s.shift()()}c(a,"reqCb"),(this.config.allowAgentFwd===!0||r&&r.agentForward===!0&&this._agent!==void 0)&&s.push(()=>d_(o,a)),e!==!1&&s.push(()=>f_(o,e,a)),typeof r=="object"&&r!==null&&(typeof r.env=="object"&&r.env!==null&&p_(o,r.env),(typeof r.x11=="object"&&r.x11!==null||r.x11==="number"||r.x11===!0)&&s.push(()=>l_(o,r.x11,a))),s.push(()=>hS(o,n)),s.shift()()}),this}subsys(e,r){if(!this._sock||!rr(this._sock))throw new Error("Not connected");return oo(this,"session",(n,i)=>{if(n){r(n);return}h_(i,e,(o,s)=>{if(o){r(o);return}r(void 0,s)})}),this}forwardIn(e,r,n){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let i=typeof n=="function";return i&&this._callbacks.push((o,s)=>{if(o){n(o!==!0?o:new Error(`Unable to bind to ${e}:${r}`));return}let a=r;r===0&&s&&s.length>=4&&(a=uS(s,0),this._protocol._compatFlags&m_.DYN_RPORT_BUG||(r=a)),this._forwarding[`${e}:${r}`]=a,n(void 0,a)}),this._protocol.tcpipForward(e,r,i),this}unforwardIn(e,r,n){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let i=typeof n=="function";return i&&this._callbacks.push(o=>{if(o){n(o!==!0?o:new Error(`Unable to unbind from ${e}:${r}`));return}delete this._forwarding[`${e}:${r}`],n()}),this._protocol.cancelTcpipForward(e,r,i),this}forwardOut(e,r,n,i,o){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let s={srcIP:e,srcPort:r,dstIP:n,dstPort:i};return typeof o!="function"&&(o=ff),oo(this,"direct-tcpip",s,o),this}openssh_noMoreSessions(e){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&ys.test(this._remoteVer)?(r&&this._callbacks.push(n=>{if(n){e(n!==!0?n:new Error("Unable to disable future sessions"));return}e()}),this._protocol.openssh_noMoreSessions(r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardInStreamLocal(e,r){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let n=typeof r=="function";return!this.config.strictVendor||this.config.strictVendor&&ys.test(this._remoteVer)?(n&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to bind to ${e}`));return}this._forwardingUnix[e]=!0,r()}),this._protocol.openssh_streamLocalForward(e,n),this):n?(process.nextTick(r,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(e,r){if(!this._sock||!rr(this._sock))throw new Error("Not connected");let n=typeof r=="function";return!this.config.strictVendor||this.config.strictVendor&&ys.test(this._remoteVer)?(n&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to unbind from ${e}`));return}delete this._forwardingUnix[e],r()}),this._protocol.openssh_cancelStreamLocalForward(e,n),this):n?(process.nextTick(r,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(e,r){if(!this._sock||!rr(this._sock))throw new Error("Not connected");return typeof r!="function"&&(r=ff),!this.config.strictVendor||this.config.strictVendor&&ys.test(this._remoteVer)?(oo(this,"direct-streamlocal@openssh.com",{socketPath:e},r),this):(process.nextTick(r,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this)}sftp(e){if(!this._sock||!rr(this._sock))throw new Error("Not connected");return oo(this,"sftp",(r,n)=>{if(r){e(r);return}h_(n,"sftp",(i,o)=>{if(i){e(i);return}function s(){n.removeListener("ready",a),n.removeListener("error",u),n.removeListener("exit",l),n.removeListener("close",l)}c(s,"removeListeners");function a(){s(),e(void 0,n)}c(a,"onReady");function u(d){s(),e(d)}c(u,"onError");function l(d,p){s();let g;typeof d=="number"?g=`Received exit code ${d} while establishing SFTP session`:p!==void 0?g=`Received signal ${p} while establishing SFTP session`:g="Received unexpected SFTP session termination";let h=new Error(g);h.code=d,h.signal=p,e(h)}c(l,"onExit"),n.on("ready",a).on("error",u).on("exit",l).on("close",l),n._init()})}),this}setNoDelay(e){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(e),this}};function oo(t,e,r,n){let i=nc,o=ic;typeof r=="function"&&(n=r,r={});let s=c((u,l)=>{n(u,l)},"wrapper");s.type=e;let a=t._chanMgr.add(s);if(a===-1){n(new Error("No free channels available"));return}switch(e){case"session":case"sftp":t._protocol.session(a,i,o);break;case"direct-tcpip":t._protocol.directTcpip(a,i,o,r);break;case"direct-streamlocal@openssh.com":t._protocol.openssh_directStreamLocal(a,i,o,r);break;default:throw new Error(`Unsupported channel type: ${e}`)}}c(oo,"openChannel");function l_(t,e,r){let n={single:!1,protocol:"MIT-MAGIC-COOKIE-1",cookie:void 0,screen:0};typeof e=="function"?r=e:typeof e=="object"&&e!==null&&(typeof e.single=="boolean"&&(n.single=e.single),typeof e.screen=="number"&&(n.screen=e.screen),typeof e.protocol=="string"&&(n.protocol=e.protocol),typeof e.cookie=="string"?n.cookie=e.cookie:Buffer.isBuffer(e.cookie)&&(n.cookie=e.cookie.hexSlice(0,e.cookie.length))),n.cookie===void 0&&(n.cookie=_S());let i=typeof r=="function";if(t.outgoing.state!=="open"){i&&r(new Error("Channel is not open"));return}i&&t._callbacks.push(o=>{if(o){r(o!==!0?o:new Error("Unable to request X11"));return}t._hasX11=!0,++t._client._acceptX11,t.once("close",()=>{t._client._acceptX11&&--t._client._acceptX11}),r()}),t._client._protocol.x11Forward(t.outgoing.id,n,i)}c(l_,"reqX11");function f_(t,e,r){let n=24,i=80,o=640,s=480,a="vt100",u=null;typeof e=="function"?r=e:typeof e=="object"&&e!==null&&(typeof e.rows=="number"&&(n=e.rows),typeof e.cols=="number"&&(i=e.cols),typeof e.width=="number"&&(o=e.width),typeof e.height=="number"&&(s=e.height),typeof e.term=="string"&&(a=e.term),typeof e.modes=="object"&&(u=e.modes));let l=typeof r=="function";if(t.outgoing.state!=="open"){l&&r(new Error("Channel is not open"));return}l&&t._callbacks.push(d=>{if(d){r(d!==!0?d:new Error("Unable to request a pseudo-terminal"));return}r()}),t._client._protocol.pty(t.outgoing.id,n,i,s,o,a,u,l)}c(f_,"reqPty");function d_(t,e){let r=typeof e=="function";if(t.outgoing.state!=="open"){r&&e(new Error("Channel is not open"));return}if(t._client._agentFwdEnabled){r&&e(!1);return}t._client._agentFwdEnabled=!0,t._callbacks.push(n=>{if(n){t._client._agentFwdEnabled=!1,r&&e(n!==!0?n:new Error("Unable to request agent forwarding"));return}r&&e()}),t._client._protocol.openssh_agentForward(t.outgoing.id,!0)}c(d_,"reqAgentFwd");function hS(t,e){if(t.outgoing.state!=="open"){e(new Error("Channel is not open"));return}t._callbacks.push(r=>{if(r){e(r!==!0?r:new Error("Unable to open shell"));return}t.subtype="shell",e(void 0,t)}),t._client._protocol.shell(t.outgoing.id,!0)}c(hS,"reqShell");function gS(t,e,r,n){if(t.outgoing.state!=="open"){n(new Error("Channel is not open"));return}t._callbacks.push(i=>{if(i){n(i!==!0?i:new Error("Unable to exec"));return}t.subtype="exec",t.allowHalfOpen=r.allowHalfOpen!==!1,n(void 0,t)}),t._client._protocol.exec(t.outgoing.id,e,!0)}c(gS,"reqExec");function p_(t,e){if(t.outgoing.state!=="open")return;let r=Object.keys(e||{});for(let n=0;n<r.length;++n){let i=r[n],o=e[i];t._client._protocol.env(t.outgoing.id,i,o,!1)}}c(p_,"reqEnv");function h_(t,e,r){if(t.outgoing.state!=="open"){r(new Error("Channel is not open"));return}t._callbacks.push(n=>{if(n){r(n!==!0?n:new Error(`Unable to start subsystem: ${e}`));return}t.subtype="subsystem",r(void 0,t)}),t._client._protocol.subsystem(t.outgoing.id,e,!0)}c(h_,"reqSubsystem");function mS(t,e){let r=-1,n,i=c(()=>{let u={type:e.type,incoming:{id:r,window:nc,packetSize:ic,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}},l=new y_(t,u);return t._chanMgr.update(r,l),t._protocol.channelOpenConfirm(e.sender,r,nc,ic),l},"accept"),o=c(()=>{n===void 0&&(r===-1?n=ms.RESOURCE_SHORTAGE:n=ms.CONNECT_FAILED),r!==-1&&t._chanMgr.remove(r),t._protocol.channelOpenFail(e.sender,n,"")},"reject"),s=c(()=>(r=t._chanMgr.add(),r===-1&&(n=ms.RESOURCE_SHORTAGE,t.config.debug&&t.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),r!==-1),"reserveChannel"),a=e.data;switch(e.type){case"forwarded-tcpip":{let u=t._forwarding[`${a.destIP}:${a.destPort}`];if(u!==void 0&&s()){a.destPort===0&&(a.destPort=u),t.emit("tcp connection",a,i,o);return}break}case"forwarded-streamlocal@openssh.com":if(t._forwardingUnix[a.socketPath]!==void 0&&s()){t.emit("unix connection",a,i,o);return}break;case"auth-agent@openssh.com":if(t._agentFwdEnabled&&typeof t._agent.getStream=="function"&&s()){t._agent.getStream((u,l)=>{if(u)return o();let d=i();d.pipe(l).pipe(d)});return}break;case"x11":if(t._acceptX11!==0&&s()){t.emit("x11",a,i,o);return}break;default:n=ms.UNKNOWN_CHANNEL_TYPE,t.config.debug&&t.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${e.type}`)}n===void 0&&(n=ms.ADMINISTRATIVELY_PROHIBITED,t.config.debug&&t.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+e.type)),o()}c(mS,"onCHANNEL_OPEN");var _S=(()=>{let t=Buffer.allocUnsafe(16);return()=>(Vv(t,0,16),t.hexSlice(0,16))})();function g_(t){if(!Array.isArray(t))throw new Error("authList must be an array");let e=0;return(r,n,i)=>e===t.length?!1:t[e++]}c(g_,"makeSimpleAuthHandler");function yS(t,e,r){if(!t._sock||!rr(t._sock))return;if(typeof r!="function"&&(r=ff),!Array.isArray(e))throw new TypeError("Invalid keys argument type");let n=[];for(let i of e){let o=rc(i);if(o instanceof Error)throw o;n.push(o)}if(!t.config.strictVendor||t.config.strictVendor&&ys.test(t._remoteVer)){t._callbacks.push((i,o)=>{if(i){r(i!==!0?i:new Error("Server failed to prove supplied keys"));return}let s=[],a=0;for(ec.init(o,0);ec.avail()&&a!==n.length;){let u=n[a++],l=u.getPublicSSH(),d=ec.readString();tc.init(d,0);let p=tc.readString(!0),g=tc.readString(),h;if(p!==u.type)if(u.type==="ssh-rsa")switch(p){case"rsa-sha2-256":h="sha256";break;case"rsa-sha2-512":h="sha512";break;default:continue}else continue;let _=t._protocol._kex.sessionID,A=Buffer.allocUnsafe(37+_.length+4+l.length),b=0;uf(A,29,b),A.utf8Write("hostkeys-prove-00@openssh.com",b+=4,29),uf(A,_.length,b+=29),i_(_,A,0,_.length,b+=4),uf(A,l.length,b+=_.length),i_(l,A,0,l.length,b+=4),(g=lS(g,p))&&u.verify(A,g,h)===!0&&s.push(u)}tc.clear(),ec.clear(),r(null,s)}),t._protocol.openssh_hostKeysProve(n);return}process.nextTick(r,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}c(yS,"hostKeysProve");function lf(t,e,r){switch(e.type){case"ssh-rsa":if(t._protocol._compatFlags&m_.IMPLY_RSA_SHA2_SIGALGS&&(Array.isArray(r)?r=["rsa-sha2-256","rsa-sha2-512",...r]:r=["rsa-sha2-256","rsa-sha2-512"]),Array.isArray(r)){if(r.indexOf("rsa-sha2-256")!==-1)return[["rsa-sha2-256","sha256"]];if(r.indexOf("rsa-sha2-512")!==-1)return[["rsa-sha2-512","sha512"]];if(r.indexOf("ssh-rsa")===-1)return[]}return[["ssh-rsa","sha1"]]}}c(lf,"getKeyAlgos");E_.exports=df});var b_=le(A_=>{"use strict";var{Agent:gf}=require("http"),{Agent:ES}=require("https"),{connect:AS}=require("tls"),hf;for(let t of[gf,ES]){class e extends t{static{c(this,"SSHAgent")}constructor(n,i){super(i),this._connectCfg=n,this._defaultSrcIP=i&&i.srcIP||"localhost"}createConnection(n,i){let o=n&&n.localAddress||this._defaultSrcIP,s=n&&n.localPort||0,a=n.host,u=n.port;hf===void 0&&(hf=pf());let l=new hf,d=!1;l.on("ready",()=>{l.forwardOut(o,s,a,u,(p,g)=>{if(d=!0,p)return l.end(),i(p);g.once("close",()=>l.end()),i(null,bS(g,t,n))})}).on("error",i).on("close",()=>{d||i(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}A_[t===gf?"SSHTTPAgent":"SSHTTPSAgent"]=e}function Es(){}c(Es,"noop");function bS(t,e,r){if(e===gf)return t.setKeepAlive=Es,t.setNoDelay=Es,t.setTimeout=Es,t.ref=Es,t.unref=Es,t.destroySoon=t.destroy,t;r.socket=t;let n=AS(r),i=(()=>{let o=!1;return()=>{o||(o=!0,t.isPaused()&&t.resume())}})();return n.on("end",i).on("close",i),n}c(bS,"decorateStream")});var I_=le((PF,Ef)=>{"use strict";var{Server:xS}=require("net"),bs=require("events"),{listenerCount:_r}=bs,{CHANNEL_OPEN_FAILURE:so,DEFAULT_CIPHER:IS,DEFAULT_COMPRESSION:vS,DEFAULT_KEX:SS,DEFAULT_MAC:wS,DEFAULT_SERVER_HOST_KEY:PS,DISCONNECT_REASON:ao,DISCONNECT_REASON_BY_VALUE:TS,SUPPORTED_CIPHER:kS,SUPPORTED_COMPRESSION:CS,SUPPORTED_KEX:RS,SUPPORTED_MAC:NS,SUPPORTED_SERVER_HOST_KEY:OS}=An(),{init:$S}=zn(),{KexInit:DS}=Fa(),{parseKey:x_}=Hn(),BS=Hl(),{SFTP:US}=ps(),{writeUInt32BE:LS}=Qr(),{Channel:co,MAX_WINDOW:qn,PACKET_SIZE:Qn,windowAdjust:zS,WINDOW_THRESHOLD:MS}=of(),{ChannelManager:FS,generateAlgorithmList:As,isWritable:oc,onChannelOpenFailure:HS,onCHANNEL_CLOSE:jS}=cf(),WS=10,Vn=class extends bs{static{c(this,"AuthContext")}constructor(e,r,n,i,o){super(),this.username=this.user=r,this.service=n,this.method=i,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(s,a,u)=>{this._finalResponse||(this._finalResponse=!0,o(this,s,a,u))},this._protocol=e}accept(){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!0)}reject(e,r){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!1,e,r)}},sc=class extends Vn{static{c(this,"KeyboardAuthContext")}constructor(e,r,n,i,o,s){super(e,r,n,i,s),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let u=this._cb;u&&(this._cb=void 0,u(a))},this.submethods=o,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(e,r,n,i){Array.isArray(e)||(e=[e]),typeof r=="function"?(i=r,r=n=void 0):typeof n=="function"?(i=n,n=void 0):typeof i!="function"&&(i=void 0);for(let o=0;o<e.length;++o)typeof e[o]=="string"&&(e[o]={prompt:e[o],echo:!0});this._cb=i,this._initialResponse=!0,this._protocol.authInfoReq(r,n,e)}},_f=class extends Vn{static{c(this,"PKAuthContext")}constructor(e,r,n,i,o,s){super(e,r,n,i,s),this.key={algo:o.keyAlgo,data:o.key},this.hashAlgo=o.hashAlgo,this.signature=o.signature,this.blob=o.blob}accept(){this.signature?Vn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},yf=class extends Vn{static{c(this,"HostbasedAuthContext")}constructor(e,r,n,i,o,s){super(e,r,n,i,s),this.key={algo:o.keyAlgo,data:o.key},this.hashAlgo=o.hashAlgo,this.signature=o.signature,this.blob=o.blob,this.localHostname=o.localHostname,this.localUsername=o.localUsername}},ac=class extends Vn{static{c(this,"PwdAuthContext")}constructor(e,r,n,i,o,s){super(e,r,n,i,s),this.password=o,this._changeCb=void 0}requestChange(e,r){if(this._changeCb)throw new Error("Change request already in progress");if(typeof e!="string")throw new Error("prompt argument must be a string");if(typeof r!="function")throw new Error("Callback argument must be a function");this._changeCb=r,this._protocol.authPasswdChg(e)}},an=class extends bs{static{c(this,"Session")}constructor(e,r,n){super(),this.type="session",this.subtype=void 0,this.server=!0,this._ending=!1,this._channel=void 0,this._chanInfo={type:"session",incoming:{id:n,window:qn,packetSize:Qn,state:"open"},outgoing:{id:r.sender,window:r.window,packetSize:r.packetSize,state:"open"}}}},$r=class extends bs{static{c(this,"Server")}constructor(e,r){if(super(),typeof e!="object"||e===null)throw new Error("Missing configuration object");let n=Object.create(null),i=[],o=e.hostKeys;if(!Array.isArray(o))throw new Error("hostKeys must be an array");let s=typeof e.algorithms=="object"&&e.algorithms!==null?e.algorithms:{},a=As(s.serverHostKey,PS,OS);for(let g=0;g<o.length;++g){let h;if(Buffer.isBuffer(o[g])||typeof o[g]=="string"?h=x_(o[g]):h=x_(o[g].key,o[g].passphrase),h instanceof Error)throw new Error(`Cannot parse privateKey: ${h.message}`);if(Array.isArray(h)&&(h=h[0]),h.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!i.includes(h.type))if(h.type==="ssh-rsa"){let _=a.indexOf("ssh-rsa"),A=a.indexOf("rsa-sha2-256"),b=a.indexOf("rsa-sha2-512");_===-1&&(_=1/0),[_,A,b].sort(qS).forEach(I=>{if(I===-1)return;let w;switch(I){case _:w="ssh-rsa";break;case A:w="rsa-sha2-256";break;case b:w="rsa-sha2-512";break;default:return}n[w]=h,i.push(w)})}else n[h.type]=h,i.push(h.type)}let u={kex:As(s.kex,SS,RS).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:i,cs:{cipher:As(s.cipher,IS,kS),mac:As(s.hmac,wS,NS),compress:As(s.compress,vS,CS),lang:[]},sc:void 0};u.sc=u.cs,typeof r=="function"&&this.on("connection",r);let l=typeof e.debug=="function"?e.debug:void 0,d=e.ident?Buffer.from(e.ident):void 0,p=new DS(u);this._srv=new xS(g=>{if(this._connections>=this.maxConnections){g.destroy();return}++this._connections,g.once("close",()=>{--this._connections});let h;if(l){let _=`[${process.hrtime().join(".")}] `;h=c(A=>{l(`${_}${A}`)},"debug")}new cc(g,n,d,p,h,this,e)}).on("error",g=>{this.emit("error",g)}).on("listening",()=>{this.emit("listening")}).on("close",()=>{this.emit("close")}),this._connections=0,this.maxConnections=1/0}injectSocket(e){this._srv.emit("connection",e)}listen(...e){return this._srv.listen(...e),this}address(){return this._srv.address()}getConnections(e){return this._srv.getConnections(e),this}close(e){return this._srv.close(e),this}ref(){return this._srv.ref(),this}unref(){return this._srv.unref(),this}};$r.KEEPALIVE_CLIENT_INTERVAL=15e3;$r.KEEPALIVE_CLIENT_COUNT_MAX=3;var cc=class extends bs{static{c(this,"Client")}constructor(e,r,n,i,o,s,a){super();let u=0,l=!1,d=[],p,g,h,_=[];this._sock=e,this._chanMgr=new FS(this),this._debug=o,this.noMoreSessions=!1,this.authenticated=!1;function A(Y){}c(A,"onClientPreHeaderError"),this.on("error",A);let b=o?(Y,P,k)=>{o(`Debug output from client: ${JSON.stringify(k)}`)}:void 0,I=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof $r.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite($r.KEEPALIVE_CLIENT_INTERVAL)&&$r.KEEPALIVE_CLIENT_INTERVAL>0?$r.KEEPALIVE_CLIENT_INTERVAL:-1,w=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof $r.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite($r.KEEPALIVE_CLIENT_COUNT_MAX)&&$r.KEEPALIVE_CLIENT_COUNT_MAX>=0?$r.KEEPALIVE_CLIENT_COUNT_MAX:-1,H=0;I!==-1&&w!==-1&&(this.once("ready",()=>{let Y=c(()=>{clearInterval(g)},"onClose");this.on("close",Y).on("end",Y),g=setInterval(()=>{if(++H>w){clearInterval(g);let P=new Error("Keepalive timeout");P.level="client-timeout",this.emit("error",P),this.end()}else $.ping()},I)}),h=c(()=>{g&&g.refresh(),H=0},"onPacket"));let $=this._protocol=new BS({server:!0,hostKeys:r,ident:n,offer:i,onPacket:h,greeting:a.greeting,banner:a.banner,onWrite:c(Y=>{oc(e)&&e.write(Y)},"onWrite"),onError:c(Y=>{$._destruct||e.removeAllListeners("data"),this.emit("error",Y);try{e.end()}catch{}},"onError"),onHeader:c(Y=>{this.removeListener("error",A);let P={ip:e.remoteAddress,family:e.remoteFamily,port:e.remotePort,header:Y};if(!s.emit("connection",this,P)){$.disconnect(ao.BY_APPLICATION),e.end();return}Y.greeting&&this.emit("greeting",Y.greeting)},"onHeader"),onHandshakeComplete:c(Y=>{++u>1&&this.emit("rekey"),this.emit("handshake",Y)},"onHandshakeComplete"),debug:o,messageHandlers:{DEBUG:b,DISCONNECT:c((Y,P,k)=>{if(P!==ao.BY_APPLICATION){k||(k=TS[P],k===void 0&&(k=`Unexpected disconnection reason: ${P}`));let M=new Error(k);M.code=P,this.emit("error",M)}e.end()},"DISCONNECT"),CHANNEL_OPEN:c((Y,P)=>{if(P.type==="session"&&this.noMoreSessions||!this.authenticated){let G=so.ADMINISTRATIVELY_PROHIBITED;return $.channelOpenFail(P.sender,G)}let k=-1,M,L=!1,T,F=c(()=>{L||(L=!0,M===void 0&&(k===-1?M=so.RESOURCE_SHORTAGE:M=so.CONNECT_FAILED),k!==-1&&this._chanMgr.remove(k),$.channelOpenFail(P.sender,M,""))},"reject"),j=c(()=>(k=this._chanMgr.add(),k===-1&&(M=so.RESOURCE_SHORTAGE,o&&o("Automatic rejection of incoming channel open: no channels available")),k!==-1),"reserveChannel"),B=P.data;switch(P.type){case"session":if(_r(this,"session")&&j()){T=c(()=>{if(L)return;L=!0;let G=new an(this,P,k);return this._chanMgr.update(k,G),$.channelOpenConfirm(P.sender,k,qn,Qn),G},"accept"),this.emit("session",T,F);return}break;case"direct-tcpip":if(_r(this,"tcpip")&&j()){T=c(()=>{if(L)return;L=!0;let G={type:void 0,incoming:{id:k,window:qn,packetSize:Qn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},ee=new co(this,G,{server:!0});return this._chanMgr.update(k,ee),$.channelOpenConfirm(P.sender,k,qn,Qn),ee},"accept"),this.emit("tcpip",T,F,B);return}break;case"direct-streamlocal@openssh.com":if(_r(this,"openssh.streamlocal")&&j()){T=c(()=>{if(L)return;L=!0;let G={type:void 0,incoming:{id:k,window:qn,packetSize:Qn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},ee=new co(this,G,{server:!0});return this._chanMgr.update(k,ee),$.channelOpenConfirm(P.sender,k,qn,Qn),ee},"accept"),this.emit("openssh.streamlocal",T,F,B);return}break;default:M=so.UNKNOWN_CHANNEL_TYPE,o&&o(`Automatic rejection of unsupported incoming channel open type: ${P.type}`)}M===void 0&&(M=so.ADMINISTRATIVELY_PROHIBITED,o&&o(`Automatic rejection of unexpected incoming channel open for: ${P.type}`)),F()},"CHANNEL_OPEN"),CHANNEL_OPEN_CONFIRMATION:c((Y,P)=>{let k=this._chanMgr.get(P.recipient);if(typeof k!="function")return;let M={type:k.type,incoming:{id:P.recipient,window:qn,packetSize:Qn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},L=new co(this,M,{server:!0});this._chanMgr.update(P.recipient,L),k(void 0,L)},"CHANNEL_OPEN_CONFIRMATION"),CHANNEL_OPEN_FAILURE:c((Y,P,k,M)=>{let L=this._chanMgr.get(P);if(typeof L!="function")return;HS(this,P,{reason:k,description:M},L)},"CHANNEL_OPEN_FAILURE"),CHANNEL_DATA:c((Y,P,k)=>{let M=this._chanMgr.get(P);if(!(typeof M!="object"||M===null)&&!(M.constructor===an&&(M=M._channel,!M))&&M.incoming.window!==0){if(M.incoming.window-=k.length,M.push(k)===!1){M._waitChanDrain=!0;return}M.incoming.window<=MS&&zS(M)}},"CHANNEL_DATA"),CHANNEL_EXTENDED_DATA:c((Y,P,k,M)=>{},"CHANNEL_EXTENDED_DATA"),CHANNEL_WINDOW_ADJUST:c((Y,P,k)=>{let M=this._chanMgr.get(P);typeof M!="object"||M===null||M.constructor===an&&(M=M._channel,!M)||(M.outgoing.window+=k,M._waitWindow&&(M._waitWindow=!1,M._chunk?M._write(M._chunk,null,M._chunkcb):M._chunkcb?M._chunkcb():M._chunkErr?M.stderr._write(M._chunkErr,null,M._chunkcbErr):M._chunkcbErr&&M._chunkcbErr()))},"CHANNEL_WINDOW_ADJUST"),CHANNEL_SUCCESS:c((Y,P)=>{let k=this._chanMgr.get(P);typeof k!="object"||k===null||k.constructor===an&&(k=k._channel,!k)||k._callbacks.length&&k._callbacks.shift()(!1)},"CHANNEL_SUCCESS"),CHANNEL_FAILURE:c((Y,P)=>{let k=this._chanMgr.get(P);typeof k!="object"||k===null||k.constructor===an&&(k=k._channel,!k)||k._callbacks.length&&k._callbacks.shift()(!0)},"CHANNEL_FAILURE"),CHANNEL_REQUEST:c((Y,P,k,M,L)=>{let T=this._chanMgr.get(P);if(typeof T!="object"||T===null)return;let F=!1,j,B;if(T.constructor!==an){M&&$.channelFailure(T.outgoing.id);return}if(M&&(k!=="shell"&&k!=="exec"&&k!=="subsystem"&&(j=c(()=>{F||T._ending||T._channel||(F=!0,$.channelSuccess(T._chanInfo.outgoing.id))},"accept")),B=c(()=>{F||T._ending||T._channel||(F=!0,$.channelFailure(T._chanInfo.outgoing.id))},"reject")),T._ending){B&&B();return}switch(k){case"env":if(_r(T,"env")){T.emit("env",j,B,{key:L.name,val:L.value});return}break;case"pty-req":if(_r(T,"pty")){T.emit("pty",j,B,L);return}break;case"window-change":_r(T,"window-change")?T.emit("window-change",j,B,L):B&&B();break;case"x11-req":if(_r(T,"x11")){T.emit("x11",j,B,L);return}break;case"signal":if(_r(T,"signal")){T.emit("signal",j,B,{name:L});return}break;case"auth-agent-req@openssh.com":if(_r(T,"auth-agent")){T.emit("auth-agent",j,B);return}break;case"shell":if(_r(T,"shell")){j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&$.channelSuccess(T._chanInfo.outgoing.id);let G=new co(this,T._chanInfo,{server:!0});return G.subtype=T.subtype=k,T._channel=G,G},"accept"),T.emit("shell",j,B);return}break;case"exec":if(_r(T,"exec")){j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&$.channelSuccess(T._chanInfo.outgoing.id);let G=new co(this,T._chanInfo,{server:!0});return G.subtype=T.subtype=k,T._channel=G,G},"accept"),T.emit("exec",j,B,{command:L});return}break;case"subsystem":{let G=L==="sftp";if(j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&$.channelSuccess(T._chanInfo.outgoing.id);let ee;return G?ee=new US(this,T._chanInfo,{server:!0,debug:o}):(ee=new co(this,T._chanInfo,{server:!0}),ee.subtype=T.subtype=`${k}:${L}`),T._channel=ee,ee},"accept"),L==="sftp"){if(_r(T,"sftp")){T.emit("sftp",j,B);return}G=!1}if(_r(T,"subsystem")){T.emit("subsystem",j,B,{name:L});return}break}}o&&o(`Automatic rejection of incoming channel request: ${k}`),B&&B()},"CHANNEL_REQUEST"),CHANNEL_EOF:c((Y,P)=>{let k=this._chanMgr.get(P);typeof k!="object"||k===null||k.constructor===an&&(k._ending||(k._ending=!0,k.emit("eof"),k.emit("end")),k=k._channel,!k)||k.incoming.state==="open"&&(k.incoming.state="eof",k.readable&&k.push(null))},"CHANNEL_EOF"),CHANNEL_CLOSE:c((Y,P)=>{let k=this._chanMgr.get(P);typeof k!="object"||k===null||k.constructor===an&&(k._ending=!0,k.emit("close"),k=k._channel,!k)||jS(this,P,k)},"CHANNEL_CLOSE"),SERVICE_REQUEST:c((Y,P)=>{if(u===0||l||this.authenticated||P!=="ssh-userauth"){$.disconnect(ao.SERVICE_NOT_AVAILABLE),e.end();return}l=!0,$.serviceAccept(P)},"SERVICE_REQUEST"),USERAUTH_REQUEST:c((Y,P,k,M,L)=>{if(u===0||this.authenticated||p&&(p.username!==P||p.service!==k)||M!=="password"&&M!=="publickey"&&M!=="hostbased"&&M!=="keyboard-interactive"&&M!=="none"||d.length===WS){$.disconnect(ao.PROTOCOL_ERROR),e.end();return}else if(k!=="ssh-connection"){$.disconnect(ao.SERVICE_NOT_AVAILABLE),e.end();return}let T;switch(M){case"keyboard-interactive":T=new sc($,P,k,M,L,X);break;case"publickey":T=new _f($,P,k,M,L,X);break;case"hostbased":T=new yf($,P,k,M,L,X);break;case"password":if(p&&p instanceof ac&&p._changeCb){let F=p._changeCb;p._changeCb=void 0,F(L.newPassword);return}T=new ac($,P,k,M,L,X);break;case"none":T=new Vn($,P,k,M,X);break}if(p)if(p._initialResponse)p._multistep&&!p._finalResponse&&(p._cleanup&&p._cleanup(),p.emit("abort"));else return d.push(T);p=T,_r(this,"authentication")?this.emit("authentication",p):p.reject()},"USERAUTH_REQUEST"),USERAUTH_INFO_RESPONSE:c((Y,P)=>{p&&p instanceof sc&&p._onInfoResponse(P)},"USERAUTH_INFO_RESPONSE"),GLOBAL_REQUEST:c((Y,P,k,M)=>{let L={type:null,buf:null};function T(F,j){L.type=F,L.buf=j,Z()}if(c(T,"setReply"),k&&_.push(L),(P==="tcpip-forward"||P==="cancel-tcpip-forward"||P==="no-more-sessions@openssh.com"||P==="streamlocal-forward@openssh.com"||P==="cancel-streamlocal-forward@openssh.com")&&_r(this,"request")&&this.authenticated){let F,j;if(k){let B=!1;F=c(G=>{if(B)return;B=!0;let ee;P==="tcpip-forward"&&M.bindPort===0&&typeof G=="number"&&(ee=Buffer.allocUnsafe(4),LS(ee,G,0)),T("SUCCESS",ee)},"accept"),j=c(()=>{B||(B=!0,T("FAILURE"))},"reject")}if(P==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,F&&F();return}this.emit("request",F,j,P,M)}else k&&T("FAILURE")},"GLOBAL_REQUEST")}});e.pause(),$S.then(()=>{$.start(),e.on("data",Y=>{try{$.parse(Y,0,Y.length)}catch(P){this.emit("error",P);try{oc(e)&&e.end()}catch{}}}),e.resume()}).catch(Y=>{this.emit("error",Y);try{oc(e)&&e.end()}catch{}}),e.on("error",Y=>{Y.level="socket",this.emit("error",Y)}).once("end",()=>{o&&o("Socket ended"),$.cleanup(),this.emit("end")}).once("close",()=>{o&&o("Socket closed"),$.cleanup(),this.emit("close");let Y=new Error("No response from server");this._chanMgr.cleanup(Y)});let X=c((Y,P,k,M)=>{p===Y&&!this.authenticated&&(P?(p=void 0,this.authenticated=!0,$.authSuccess(),d=[],this.emit("ready")):($.authFailure(k,M),d.length&&(p=d.pop(),_r(this,"authentication")?this.emit("authentication",p):p.reject())))},"onAuthDecide");function Z(){for(;_.length>0&&_[0].type;){let Y=_.shift();Y.type==="SUCCESS"&&$.requestSuccess(Y.buf),Y.type==="FAILURE"&&$.requestFailure()}}c(Z,"sendReplies")}end(){return this._sock&&oc(this._sock)&&(this._protocol.disconnect(ao.BY_APPLICATION),this._sock.end()),this}x11(e,r,n){return mf(this,"x11",{originAddr:e,originPort:r},n),this}forwardOut(e,r,n,i,o){return mf(this,"forwarded-tcpip",{boundAddr:e,boundPort:r,remoteAddr:n,remotePort:i},o),this}openssh_forwardOutStreamLocal(e,r){return mf(this,"forwarded-streamlocal@openssh.com",{socketPath:e},r),this}rekey(e){let r;try{this._protocol.rekey()}catch(n){r=n}typeof e=="function"&&(r?process.nextTick(e,r):this.once("rekey",e))}setNoDelay(e){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(e),this}};function mf(t,e,r,n){let i=qn,o=Qn;typeof r=="function"&&(n=r,r={});let s=c((u,l)=>{n(u,l)},"wrapper");s.type=e;let a=t._chanMgr.add(s);if(a===-1){n(new Error("No free channels available"));return}switch(e){case"forwarded-tcpip":t._protocol.forwardedTcpip(a,i,o,r);break;case"x11":t._protocol.x11(a,i,o,r);break;case"forwarded-streamlocal@openssh.com":t._protocol.openssh_forwardedStreamLocal(a,i,o,r);break;default:throw new Error(`Unsupported channel type: ${e}`)}}c(mf,"openChannel");function qS(t,e){return t-e}c(qS,"compareNumbers");Ef.exports=$r;Ef.exports.IncomingClient=cc});var T_=le((kF,P_)=>{"use strict";var{createCipheriv:QS,generateKeyPair:VS,generateKeyPairSync:KS,getCurves:GS,randomBytes:v_}=require("crypto"),{Ber:Nt}=Ko(),ZS=zu().pbkdf,{CIPHER_INFO:YS}=zn(),XS=16,JS=16,ew=GS(),tw=new Map(Object.entries(YS));function S_(t,e){if(typeof t!="string")throw new TypeError("Key type must be a string");let r={type:"spki",format:"der"},n={type:"pkcs8",format:"der"};switch(t.toLowerCase()){case"rsa":{if(typeof e!="object"||e===null)throw new TypeError("Missing options object for RSA key");let i=e.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:r,privateKeyEncoding:n}]}case"ecdsa":{if(typeof e!="object"||e===null)throw new TypeError("Missing options object for ECDSA key");if(!Number.isInteger(e.bits))throw new TypeError("ECDSA bits must be an integer");let i;switch(e.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(!ew.includes(i))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:i,publicKeyEncoding:r,privateKeyEncoding:n}]}case"ed25519":return["ed25519",{publicKeyEncoding:r,privateKeyEncoding:n}];default:throw new Error(`Unsupported key type: ${t}`)}}c(S_,"makeArgs");function rw(t,e,r){switch(t){case"rsa":{let n=new Nt.Reader(r);if(n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in RSA private key");if(n.readSequence(),n.readOID()!=="1.2.840.113549.1.1.1")throw new Error("Bad RSA private OID");if(n.readByte()!==Nt.Null)throw new Error("Malformed RSA private key (expected null)");if(n.readByte()!==0)throw new Error("Malformed RSA private key (expected zero-length null)");if(n=new Nt.Reader(n.readString(Nt.OctetString,!0)),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in RSA private key");let i=n.readString(Nt.Integer,!0),o=n.readString(Nt.Integer,!0),s=n.readString(Nt.Integer,!0),a=n.readString(Nt.Integer,!0),u=n.readString(Nt.Integer,!0);n.readString(Nt.Integer,!0),n.readString(Nt.Integer,!0);let l=n.readString(Nt.Integer,!0),d=Buffer.from("ssh-rsa"),p=Buffer.allocUnsafe(4+d.length+4+i.length+4+o.length+4+s.length+4+l.length+4+a.length+4+u.length),g=0;p.writeUInt32BE(d.length,g+=0),p.set(d,g+=4),p.writeUInt32BE(i.length,g+=d.length),p.set(i,g+=4),p.writeUInt32BE(o.length,g+=i.length),p.set(o,g+=4),p.writeUInt32BE(s.length,g+=o.length),p.set(s,g+=4),p.writeUInt32BE(l.length,g+=s.length),p.set(l,g+=4),p.writeUInt32BE(a.length,g+=l.length),p.set(a,g+=4),p.writeUInt32BE(u.length,g+=a.length),p.set(u,g+=4);let h=Buffer.allocUnsafe(4+d.length+4+o.length+4+i.length);return g=0,h.writeUInt32BE(d.length,g+=0),h.set(d,g+=4),h.writeUInt32BE(o.length,g+=d.length),h.set(o,g+=4),h.writeUInt32BE(i.length,g+=o.length),h.set(i,g+=4),{sshName:d.toString(),priv:p,pub:h}}case"ec":{let n=new Nt.Reader(e);if(n.readSequence(),n.readSequence(),n.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");n.readOID();let i=n.readString(Nt.BitString,!0);{let g=0;for(;g<i.length&&i[g]===0;++g);g>0&&(i=i.slice(g))}if(n=new Nt.Reader(r),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(n.readSequence(),n.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let o=n.readOID(),s;switch(o){case"1.2.840.10045.3.1.7":s="nistp256";break;case"1.3.132.0.34":s="nistp384";break;case"1.3.132.0.35":s="nistp521";break;default:throw new Error("Unsupported curve in ECDSA private key")}if(n=new Nt.Reader(n.readString(Nt.OctetString,!0)),n.readSequence(),n.readInt()!==1)throw new Error("Unsupported version in ECDSA private key");let a=Buffer.concat([Buffer.from([0]),n.readString(Nt.OctetString,!0)]),u=Buffer.from(`ecdsa-sha2-${s}`);s=Buffer.from(s);let l=Buffer.allocUnsafe(4+u.length+4+s.length+4+i.length+4+a.length),d=0;l.writeUInt32BE(u.length,d+=0),l.set(u,d+=4),l.writeUInt32BE(s.length,d+=u.length),l.set(s,d+=4),l.writeUInt32BE(i.length,d+=s.length),l.set(i,d+=4),l.writeUInt32BE(a.length,d+=i.length),l.set(a,d+=4);let p=Buffer.allocUnsafe(4+u.length+4+s.length+4+i.length);return d=0,p.writeUInt32BE(u.length,d+=0),p.set(u,d+=4),p.writeUInt32BE(s.length,d+=u.length),p.set(s,d+=4),p.writeUInt32BE(i.length,d+=s.length),p.set(i,d+=4),{sshName:u.toString(),priv:l,pub:p}}case"ed25519":{let n=new Nt.Reader(e);if(n.readSequence(),n.readSequence(),n.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let i=n.readString(Nt.BitString,!0);{let d=0;for(;d<i.length&&i[d]===0;++d);d>0&&(i=i.slice(d))}if(n=new Nt.Reader(r),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in ED25519 private key");if(n.readSequence(),n.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 private OID");n=new Nt.Reader(n.readString(Nt.OctetString,!0));let o=n.readString(Nt.OctetString,!0),s=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+s.length+4+i.length+4+(o.length+i.length)),u=0;a.writeUInt32BE(s.length,u+=0),a.set(s,u+=4),a.writeUInt32BE(i.length,u+=s.length),a.set(i,u+=4),a.writeUInt32BE(o.length+i.length,u+=i.length),a.set(o,u+=4),a.set(i,u+=o.length);let l=Buffer.allocUnsafe(4+s.length+4+i.length);return u=0,l.writeUInt32BE(s.length,u+=0),l.set(s,u+=4),l.writeUInt32BE(i.length,u+=s.length),l.set(i,u+=4),{sshName:s.toString(),priv:a,pub:l}}}}c(rw,"parseDERs");function w_(t,e,r,n){let i="new",o,s="";if(typeof n=="object"&&n!==null&&(typeof n.comment=="string"&&n.comment&&(s=n.comment),typeof n.format=="string"&&n.format&&(i=n.format),n.passphrase)){let a;if(typeof n.passphrase=="string")a=Buffer.from(n.passphrase);else if(Buffer.isBuffer(n.passphrase))a=n.passphrase;else throw new Error("Invalid passphrase");if(n.cipher===void 0)throw new Error("Missing cipher name");let u=tw.get(n.cipher);if(u===void 0)throw new Error("Invalid cipher name");if(i==="new"){let l=JS;if(n.rounds!==void 0){if(!Number.isInteger(n.rounds))throw new TypeError("rounds must be an integer");n.rounds>0&&(l=n.rounds)}let d=Buffer.allocUnsafe(u.keyLen+u.ivLen),p=v_(XS);if(ZS(a,a.length,p,p.length,d,d.length,l)!==0)return new Error("Failed to generate information to encrypt key");let h=Buffer.allocUnsafe(4+p.length+4);{let _=0;h.writeUInt32BE(p.length,_+=0),h.set(p,_+=4),h.writeUInt32BE(l,_+=p.length)}o={cipher:u,cipherName:n.cipher,kdfName:"bcrypt",kdfOptions:h,key:d.slice(0,u.keyLen),iv:d.slice(u.keyLen)}}}switch(i){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
20
+ `,u,l=Buffer.from(o?o.cipherName:"none"),d=Buffer.from(o?o.kdfName:"none"),p=o?o.kdfOptions:Buffer.alloc(0),g=o?o.cipher.blockLen:8,h=rw(t,e,r),_=v_(4),A=Buffer.from(s),b=8+h.priv.length+4+A.length,I=[];for(let Z=1;(b+I.length)%g;++Z)I.push(Z&255);I=Buffer.from(I);let w=Buffer.allocUnsafe(b+I.length),H;{let Z=0;w.set(_,Z+=0),w.set(_,Z+=4),w.set(h.priv,Z+=4),w.writeUInt32BE(A.length,Z+=h.priv.length),w.set(A,Z+=4),w.set(I,Z+=A.length)}if(o){let Z={authTagLength:o.cipher.authLen},Y=QS(o.cipher.sslName,o.key,o.iv,Z);Y.setAutoPadding(!1),w=Buffer.concat([Y.update(w),Y.final()]),o.cipher.authLen>0?H=Y.getAuthTag():H=Buffer.alloc(0),o.key.fill(0),o.iv.fill(0)}else H=Buffer.alloc(0);let $=Buffer.from("openssh-key-v1\0"),X=Buffer.allocUnsafe($.length+4+l.length+4+d.length+4+p.length+4+4+h.pub.length+4+w.length+H.length);{let Z=0;X.set($,Z+=0),X.writeUInt32BE(l.length,Z+=$.length),X.set(l,Z+=4),X.writeUInt32BE(d.length,Z+=l.length),X.set(d,Z+=4),X.writeUInt32BE(p.length,Z+=d.length),X.set(p,Z+=4),X.writeUInt32BE(1,Z+=p.length),X.writeUInt32BE(h.pub.length,Z+=4),X.set(h.pub,Z+=4),X.writeUInt32BE(w.length,Z+=h.pub.length),X.set(w,Z+=4),X.set(H,Z+=w.length)}{let Z=X.base64Slice(0,X.length),Y=Z.replace(/.{64}/g,`$&
21
21
  `);Z.length&63&&(Y+=`
22
22
  `),a+=Y}{let Z=h.pub.base64Slice(0,h.pub.length);u=`${h.sshName} ${Z}${s?` ${s}`:""}`}return a+=`-----END OPENSSH PRIVATE KEY-----
23
- `,{private:a,public:u}}default:throw new Error("Invalid output key format")}}c(b_,"convertKeys");function jS(){}c(jS,"noop");x_.exports={generateKeyPair:c((t,e,r)=>{typeof e=="function"&&(r=e,e=void 0),typeof r!="function"&&(r=jS);let n=E_(t,e);OS(...n,(i,o,s)=>{if(i)return r(i);let a;try{a=b_(n[0],o,s,e)}catch(u){return r(u)}r(null,a)})},"generateKeyPair"),generateKeyPairSync:c((t,e)=>{let r=E_(t,e),{publicKey:n,privateKey:i}=$S(...r);return b_(r[0],n,i,e)},"generateKeyPairSync")}});var S_=le((pF,v_)=>{"use strict";var{AgentProtocol:WS,BaseAgent:qS,createAgent:QS,CygwinAgent:KS,OpenSSHAgent:VS,PageantAgent:GS}=wl(),{SSHTTPAgent:ZS,SSHTTPSAgent:YS}=m_(),{parseKey:XS}=Fn(),{flagsToString:JS,OPEN_MODE:ew,STATUS_CODE:tw,stringToFlags:rw}=ds();v_.exports={AgentProtocol:WS,BaseAgent:qS,createAgent:QS,Client:df(),CygwinAgent:KS,HTTPAgent:ZS,HTTPSAgent:YS,OpenSSHAgent:VS,PageantAgent:GS,Server:y_(),utils:{parseKey:XS,...I_(),sftp:{flagsToString:JS,OPEN_MODE:ew,STATUS_CODE:tw,stringToFlags:rw}}}});var Af=le((hF,w_)=>{w_.exports=require("stream")});var N_=le((gF,R_)=>{"use strict";function P_(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}c(P_,"ownKeys");function T_(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?P_(Object(r),!0).forEach(function(n){nw(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):P_(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}c(T_,"_objectSpread");function nw(t,e,r){return e=C_(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(nw,"_defineProperty");function iw(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}c(iw,"_classCallCheck");function k_(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,C_(n.key),n)}}c(k_,"_defineProperties");function ow(t,e,r){return e&&k_(t.prototype,e),r&&k_(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}c(ow,"_createClass");function C_(t){var e=sw(t,"string");return typeof e=="symbol"?e:String(e)}c(C_,"_toPropertyKey");function sw(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}c(sw,"_toPrimitive");var aw=require("buffer"),cc=aw.Buffer,cw=require("util"),Ef=cw.inspect,uw=Ef&&Ef.custom||"inspect";function lw(t,e,r){cc.prototype.copy.call(t,e,r)}c(lw,"copyBuffer");R_.exports=(function(){function t(){iw(this,t),this.head=null,this.tail=null,this.length=0}return c(t,"BufferList"),ow(t,[{key:"push",value:c(function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},"push")},{key:"unshift",value:c(function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},"unshift")},{key:"shift",value:c(function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},"shift")},{key:"clear",value:c(function(){this.head=this.tail=null,this.length=0},"clear")},{key:"join",value:c(function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},"join")},{key:"concat",value:c(function(r){if(this.length===0)return cc.alloc(0);for(var n=cc.allocUnsafe(r>>>0),i=this.head,o=0;i;)lw(i.data,n,o),o+=i.data.length,i=i.next;return n},"concat")},{key:"consume",value:c(function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i},"consume")},{key:"first",value:c(function(){return this.head.data},"first")},{key:"_getString",value:c(function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o},"_getString")},{key:"_getBuffer",value:c(function(r){var n=cc.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n},"_getBuffer")},{key:uw,value:c(function(r,n){return Ef(this,T_(T_({},n),{},{depth:0,customInspect:!1}))},"value")}]),t})()});var xf=le((_F,$_)=>{"use strict";function fw(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(bf,this,t)):process.nextTick(bf,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?r._writableState?r._writableState.errorEmitted?process.nextTick(uc,r):(r._writableState.errorEmitted=!0,process.nextTick(O_,r,o)):process.nextTick(O_,r,o):e?(process.nextTick(uc,r),e(o)):process.nextTick(uc,r)}),this)}c(fw,"destroy");function O_(t,e){bf(t,e),uc(t)}c(O_,"emitErrorAndCloseNT");function uc(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}c(uc,"emitCloseNT");function dw(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}c(dw,"undestroy");function bf(t,e){t.emit("error",e)}c(bf,"emitErrorNT");function pw(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}c(pw,"errorOrDestroy");$_.exports={destroy:fw,undestroy:dw,errorOrDestroy:pw}});var Kn=le((AF,U_)=>{"use strict";var B_={};function Hr(t,e,r){r||(r=Error);function n(o,s,a){return typeof e=="string"?e:e(o,s,a)}c(n,"getMessage");class i extends r{static{c(this,"NodeError")}constructor(s,a,u){super(n(s,a,u))}}i.prototype.name=r.name,i.prototype.code=t,B_[t]=i}c(Hr,"createErrorType");function D_(t,e){if(Array.isArray(t)){let r=t.length;return t=t.map(n=>String(n)),r>2?`one of ${e} ${t.slice(0,r-1).join(", ")}, or `+t[r-1]:r===2?`one of ${e} ${t[0]} or ${t[1]}`:`of ${e} ${t[0]}`}else return`of ${e} ${String(t)}`}c(D_,"oneOf");function hw(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}c(hw,"startsWith");function gw(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}c(gw,"endsWith");function mw(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}c(mw,"includes");Hr("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);Hr("ERR_INVALID_ARG_TYPE",function(t,e,r){let n;typeof e=="string"&&hw(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";let i;if(gw(t," argument"))i=`The ${t} ${n} ${D_(e,"type")}`;else{let o=mw(t,".")?"property":"argument";i=`The "${t}" ${o} ${n} ${D_(e,"type")}`}return i+=`. Received type ${typeof r}`,i},TypeError);Hr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Hr("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});Hr("ERR_STREAM_PREMATURE_CLOSE","Premature close");Hr("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});Hr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Hr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Hr("ERR_STREAM_WRITE_AFTER_END","write after end");Hr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Hr("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);Hr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");U_.exports.codes=B_});var If=le((bF,L_)=>{"use strict";var _w=Kn().codes.ERR_INVALID_OPT_VALUE;function yw(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}c(yw,"highWaterMarkFrom");function Aw(t,e,r,n){var i=yw(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new _w(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}c(Aw,"getHighWaterMark");L_.exports={getHighWaterMark:Aw}});var z_=le((IF,vf)=>{typeof Object.create=="function"?vf.exports=c(function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))},"inherits"):vf.exports=c(function(e,r){if(r){e.super_=r;var n=c(function(){},"TempCtor");n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}},"inherits")});var fi=le((SF,wf)=>{try{if(Sf=require("util"),typeof Sf.inherits!="function")throw"";wf.exports=Sf.inherits}catch{wf.exports=z_()}var Sf});var F_=le((wF,M_)=>{M_.exports=require("util").deprecate});var kf=le((PF,K_)=>{"use strict";K_.exports=Gt;function j_(t){var e=this;this.next=null,this.entry=null,this.finish=function(){Qw(e,t)}}c(j_,"CorkedRequest");var co;Gt.WritableState=xs;var Ew={deprecate:F_()},W_=Af(),fc=require("buffer").Buffer,bw=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function xw(t){return fc.from(t)}c(xw,"_uint8ArrayToBuffer");function Iw(t){return fc.isBuffer(t)||t instanceof bw}c(Iw,"_isUint8Array");var Tf=xf(),vw=If(),Sw=vw.getHighWaterMark,Vn=Kn().codes,ww=Vn.ERR_INVALID_ARG_TYPE,Pw=Vn.ERR_METHOD_NOT_IMPLEMENTED,Tw=Vn.ERR_MULTIPLE_CALLBACK,kw=Vn.ERR_STREAM_CANNOT_PIPE,Cw=Vn.ERR_STREAM_DESTROYED,Rw=Vn.ERR_STREAM_NULL_VALUES,Nw=Vn.ERR_STREAM_WRITE_AFTER_END,Ow=Vn.ERR_UNKNOWN_ENCODING,uo=Tf.errorOrDestroy;fi()(Gt,W_);function $w(){}c($w,"nop");function xs(t,e,r){co=co||di(),t=t||{},typeof r!="boolean"&&(r=e instanceof co),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=Sw(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=t.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){Fw(e,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new j_(this)}c(xs,"WritableState");xs.prototype.getBuffer=c(function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r},"getBuffer");(function(){try{Object.defineProperty(xs.prototype,"buffer",{get:Ew.deprecate(c(function(){return this.getBuffer()},"writableStateBufferGetter"),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var lc;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(lc=Function.prototype[Symbol.hasInstance],Object.defineProperty(Gt,Symbol.hasInstance,{value:c(function(e){return lc.call(this,e)?!0:this!==Gt?!1:e&&e._writableState instanceof xs},"value")})):lc=c(function(e){return e instanceof this},"realHasInstance");function Gt(t){co=co||di();var e=this instanceof co;if(!e&&!lc.call(Gt,this))return new Gt(t);this._writableState=new xs(t,this,e),this.writable=!0,t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final)),W_.call(this)}c(Gt,"Writable");Gt.prototype.pipe=function(){uo(this,new kw)};function Dw(t,e){var r=new Nw;uo(t,r),process.nextTick(e,r)}c(Dw,"writeAfterEnd");function Bw(t,e,r,n){var i;return r===null?i=new Rw:typeof r!="string"&&!e.objectMode&&(i=new ww("chunk",["string","Buffer"],r)),i?(uo(t,i),process.nextTick(n,i),!1):!0}c(Bw,"validChunk");Gt.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&Iw(t);return o&&!fc.isBuffer(t)&&(t=xw(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=$w),n.ending?Dw(this,r):(o||Bw(this,n,t,r))&&(n.pendingcb++,i=Lw(this,n,o,t,e,r)),i};Gt.prototype.cork=function(){this._writableState.corked++};Gt.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&q_(this,t))};Gt.prototype.setDefaultEncoding=c(function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new Ow(e);return this._writableState.defaultEncoding=e,this},"setDefaultEncoding");Object.defineProperty(Gt.prototype,"writableBuffer",{enumerable:!1,get:c(function(){return this._writableState&&this._writableState.getBuffer()},"get")});function Uw(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=fc.from(e,r)),e}c(Uw,"decodeChunk");Object.defineProperty(Gt.prototype,"writableHighWaterMark",{enumerable:!1,get:c(function(){return this._writableState.highWaterMark},"get")});function Lw(t,e,r,n,i,o){if(!r){var s=Uw(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else Pf(t,e,!1,a,n,i,o);return u}c(Lw,"writeOrBuffer");function Pf(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new Cw("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}c(Pf,"doWrite");function zw(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(bs,t,e),t._writableState.errorEmitted=!0,uo(t,n)):(i(n),t._writableState.errorEmitted=!0,uo(t,n),bs(t,e))}c(zw,"onwriteError");function Mw(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}c(Mw,"onwriteStateUpdate");function Fw(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new Tw;if(Mw(r),e)zw(t,r,n,e,i);else{var o=Q_(r)||t.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&q_(t,r),n?process.nextTick(H_,t,r,o,i):H_(t,r,o,i)}}c(Fw,"onwrite");function H_(t,e,r,n){r||Hw(t,e),e.pendingcb--,n(),bs(t,e)}c(H_,"afterWrite");function Hw(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}c(Hw,"onwriteDrain");function q_(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Pf(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new j_(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,d=r.callback,p=e.objectMode?1:u.length;if(Pf(t,e,!1,p,u,l,d),r=r.next,e.bufferedRequestCount--,e.writing)break}r===null&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}c(q_,"clearBuffer");Gt.prototype._write=function(t,e,r){r(new Pw("_write()"))};Gt.prototype._writev=null;Gt.prototype.end=function(t,e,r){var n=this._writableState;return typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null),t!=null&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||qw(this,n,r),this};Object.defineProperty(Gt.prototype,"writableLength",{enumerable:!1,get:c(function(){return this._writableState.length},"get")});function Q_(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}c(Q_,"needFinish");function jw(t,e){t._final(function(r){e.pendingcb--,r&&uo(t,r),e.prefinished=!0,t.emit("prefinish"),bs(t,e)})}c(jw,"callFinal");function Ww(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(jw,t,e)):(e.prefinished=!0,t.emit("prefinish")))}c(Ww,"prefinish");function bs(t,e){var r=Q_(e);if(r&&(Ww(t,e),e.pendingcb===0&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}c(bs,"finishMaybe");function qw(t,e,r){e.ending=!0,bs(t,e),r&&(e.finished?process.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}c(qw,"endWritable");function Qw(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}c(Qw,"onCorkedFinish");Object.defineProperty(Gt.prototype,"destroyed",{enumerable:!1,get:c(function(){return this._writableState===void 0?!1:this._writableState.destroyed},"get"),set:c(function(e){this._writableState&&(this._writableState.destroyed=e)},"set")});Gt.prototype.destroy=Tf.destroy;Gt.prototype._undestroy=Tf.undestroy;Gt.prototype._destroy=function(t,e){e(t)}});var di=le((kF,G_)=>{"use strict";var Kw=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};G_.exports=an;var V_=Nf(),Rf=kf();fi()(an,V_);for(Cf=Kw(Rf.prototype),dc=0;dc<Cf.length;dc++)pc=Cf[dc],an.prototype[pc]||(an.prototype[pc]=Rf.prototype[pc]);var Cf,pc,dc;function an(t){if(!(this instanceof an))return new an(t);V_.call(this,t),Rf.call(this,t),this.allowHalfOpen=!0,t&&(t.readable===!1&&(this.readable=!1),t.writable===!1&&(this.writable=!1),t.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",Vw)))}c(an,"Duplex");Object.defineProperty(an.prototype,"writableHighWaterMark",{enumerable:!1,get:c(function(){return this._writableState.highWaterMark},"get")});Object.defineProperty(an.prototype,"writableBuffer",{enumerable:!1,get:c(function(){return this._writableState&&this._writableState.getBuffer()},"get")});Object.defineProperty(an.prototype,"writableLength",{enumerable:!1,get:c(function(){return this._writableState.length},"get")});function Vw(){this._writableState.ended||process.nextTick(Gw,this)}c(Vw,"onend");function Gw(t){t.end()}c(Gw,"onEndNT");Object.defineProperty(an.prototype,"destroyed",{enumerable:!1,get:c(function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},"get"),set:c(function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)},"set")})});var X_=le((Of,Y_)=>{var hc=require("buffer"),cn=hc.Buffer;function Z_(t,e){for(var r in t)e[r]=t[r]}c(Z_,"copyProps");cn.from&&cn.alloc&&cn.allocUnsafe&&cn.allocUnsafeSlow?Y_.exports=hc:(Z_(hc,Of),Of.Buffer=pi);function pi(t,e,r){return cn(t,e,r)}c(pi,"SafeBuffer");pi.prototype=Object.create(cn.prototype);Z_(cn,pi);pi.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return cn(t,e,r)};pi.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=cn(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};pi.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return cn(t)};pi.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return hc.SlowBuffer(t)}});var Bf=le(ey=>{"use strict";var Df=X_().Buffer,J_=Df.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Zw(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}c(Zw,"_normalizeEncoding");function Yw(t){var e=Zw(t);if(typeof e!="string"&&(Df.isEncoding===J_||!J_(t)))throw new Error("Unknown encoding: "+t);return e||t}c(Yw,"normalizeEncoding");ey.StringDecoder=Is;function Is(t){this.encoding=Yw(t);var e;switch(this.encoding){case"utf16le":this.text=nP,this.end=iP,e=4;break;case"utf8":this.fillLast=eP,e=4;break;case"base64":this.text=oP,this.end=sP,e=3;break;default:this.write=aP,this.end=cP;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Df.allocUnsafe(e)}c(Is,"StringDecoder");Is.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};Is.prototype.end=rP;Is.prototype.text=tP;Is.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function $f(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}c($f,"utf8CheckByte");function Xw(t,e,r){var n=e.length-1;if(n<r)return 0;var i=$f(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=$f(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=$f(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}c(Xw,"utf8CheckIncomplete");function Jw(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}c(Jw,"utf8CheckExtraBytes");function eP(t){var e=this.lastTotal-this.lastNeed,r=Jw(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}c(eP,"utf8FillLast");function tP(t,e){var r=Xw(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}c(tP,"utf8Text");function rP(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}c(rP,"utf8End");function nP(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}c(nP,"utf16Text");function iP(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}c(iP,"utf16End");function oP(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}c(oP,"base64Text");function sP(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}c(sP,"base64End");function aP(t){return t.toString(this.encoding)}c(aP,"simpleWrite");function cP(t){return t&&t.length?this.write(t):""}c(cP,"simpleEnd")});var gc=le(($F,ny)=>{"use strict";var ty=Kn().codes.ERR_STREAM_PREMATURE_CLOSE;function uP(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}c(uP,"once");function lP(){}c(lP,"noop");function fP(t){return t.setHeader&&typeof t.abort=="function"}c(fP,"isRequest");function ry(t,e,r){if(typeof e=="function")return ry(t,null,e);e||(e={}),r=uP(r||lP);var n=e.readable||e.readable!==!1&&t.readable,i=e.writable||e.writable!==!1&&t.writable,o=c(function(){t.writable||a()},"onlegacyfinish"),s=t._writableState&&t._writableState.finished,a=c(function(){i=!1,s=!0,n||r.call(t)},"onfinish"),u=t._readableState&&t._readableState.endEmitted,l=c(function(){n=!1,u=!0,i||r.call(t)},"onend"),d=c(function(_){r.call(t,_)},"onerror"),p=c(function(){var _;if(n&&!u)return(!t._readableState||!t._readableState.ended)&&(_=new ty),r.call(t,_);if(i&&!s)return(!t._writableState||!t._writableState.ended)&&(_=new ty),r.call(t,_)},"onclose"),g=c(function(){t.req.on("finish",a)},"onrequest");return fP(t)?(t.on("complete",a),t.on("abort",p),t.req?g():t.on("request",g)):i&&!t._writableState&&(t.on("end",o),t.on("close",o)),t.on("end",l),t.on("finish",a),e.error!==!1&&t.on("error",d),t.on("close",p),function(){t.removeListener("complete",a),t.removeListener("abort",p),t.removeListener("request",g),t.req&&t.req.removeListener("finish",a),t.removeListener("end",o),t.removeListener("close",o),t.removeListener("finish",a),t.removeListener("end",l),t.removeListener("error",d),t.removeListener("close",p)}}c(ry,"eos");ny.exports=ry});var oy=le((BF,iy)=>{"use strict";var mc;function Gn(t,e,r){return e=dP(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(Gn,"_defineProperty");function dP(t){var e=pP(t,"string");return typeof e=="symbol"?e:String(e)}c(dP,"_toPropertyKey");function pP(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}c(pP,"_toPrimitive");var hP=gc(),Zn=Symbol("lastResolve"),hi=Symbol("lastReject"),vs=Symbol("error"),_c=Symbol("ended"),gi=Symbol("lastPromise"),Uf=Symbol("handlePromise"),mi=Symbol("stream");function Yn(t,e){return{value:t,done:e}}c(Yn,"createIterResult");function gP(t){var e=t[Zn];if(e!==null){var r=t[mi].read();r!==null&&(t[gi]=null,t[Zn]=null,t[hi]=null,e(Yn(r,!1)))}}c(gP,"readAndResolve");function mP(t){process.nextTick(gP,t)}c(mP,"onReadable");function _P(t,e){return function(r,n){t.then(function(){if(e[_c]){r(Yn(void 0,!0));return}e[Uf](r,n)},n)}}c(_P,"wrapForNext");var yP=Object.getPrototypeOf(function(){}),AP=Object.setPrototypeOf((mc={get stream(){return this[mi]},next:c(function(){var e=this,r=this[vs];if(r!==null)return Promise.reject(r);if(this[_c])return Promise.resolve(Yn(void 0,!0));if(this[mi].destroyed)return new Promise(function(s,a){process.nextTick(function(){e[vs]?a(e[vs]):s(Yn(void 0,!0))})});var n=this[gi],i;if(n)i=new Promise(_P(n,this));else{var o=this[mi].read();if(o!==null)return Promise.resolve(Yn(o,!1));i=new Promise(this[Uf])}return this[gi]=i,i},"next")},Gn(mc,Symbol.asyncIterator,function(){return this}),Gn(mc,"return",c(function(){var e=this;return new Promise(function(r,n){e[mi].destroy(null,function(i){if(i){n(i);return}r(Yn(void 0,!0))})})},"_return")),mc),yP),EP=c(function(e){var r,n=Object.create(AP,(r={},Gn(r,mi,{value:e,writable:!0}),Gn(r,Zn,{value:null,writable:!0}),Gn(r,hi,{value:null,writable:!0}),Gn(r,vs,{value:null,writable:!0}),Gn(r,_c,{value:e._readableState.endEmitted,writable:!0}),Gn(r,Uf,{value:c(function(o,s){var a=n[mi].read();a?(n[gi]=null,n[Zn]=null,n[hi]=null,o(Yn(a,!1))):(n[Zn]=o,n[hi]=s)},"value"),writable:!0}),r));return n[gi]=null,hP(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[hi];o!==null&&(n[gi]=null,n[Zn]=null,n[hi]=null,o(i)),n[vs]=i;return}var s=n[Zn];s!==null&&(n[gi]=null,n[Zn]=null,n[hi]=null,s(Yn(void 0,!0))),n[_c]=!0}),e.on("readable",mP.bind(null,n)),n},"createReadableStreamAsyncIterator");iy.exports=EP});var uy=le((LF,cy)=>{"use strict";function sy(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(l){r(l);return}a.done?e(u):Promise.resolve(u).then(n,i)}c(sy,"asyncGeneratorStep");function bP(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function s(u){sy(o,n,i,s,a,"next",u)}c(s,"_next");function a(u){sy(o,n,i,s,a,"throw",u)}c(a,"_throw"),s(void 0)})}}c(bP,"_asyncToGenerator");function ay(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}c(ay,"ownKeys");function xP(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ay(Object(r),!0).forEach(function(n){IP(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ay(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}c(xP,"_objectSpread");function IP(t,e,r){return e=vP(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(IP,"_defineProperty");function vP(t){var e=SP(t,"string");return typeof e=="symbol"?e:String(e)}c(vP,"_toPropertyKey");function SP(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}c(SP,"_toPrimitive");var wP=Kn().codes.ERR_INVALID_ARG_TYPE;function PP(t,e,r){var n;if(e&&typeof e.next=="function")n=e;else if(e&&e[Symbol.asyncIterator])n=e[Symbol.asyncIterator]();else if(e&&e[Symbol.iterator])n=e[Symbol.iterator]();else throw new wP("iterable",["Iterable"],e);var i=new t(xP({objectMode:!0},r)),o=!1;i._read=function(){o||(o=!0,s())};function s(){return a.apply(this,arguments)}c(s,"next");function a(){return a=bP(function*(){try{var u=yield n.next(),l=u.value,d=u.done;d?i.push(null):i.push(yield l)?s():o=!1}catch(p){i.destroy(p)}}),a.apply(this,arguments)}return c(a,"_next2"),i}c(PP,"from");cy.exports=PP});var Nf=le((FF,Ay)=>{"use strict";Ay.exports=At;var lo;At.ReadableState=py;var MF=require("events").EventEmitter,dy=c(function(e,r){return e.listeners(r).length},"EElistenerCount"),ws=Af(),yc=require("buffer").Buffer,TP=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function kP(t){return yc.from(t)}c(kP,"_uint8ArrayToBuffer");function CP(t){return yc.isBuffer(t)||t instanceof TP}c(CP,"_isUint8Array");var Lf=require("util"),ct;Lf&&Lf.debuglog?ct=Lf.debuglog("stream"):ct=c(function(){},"debug");var RP=N_(),qf=xf(),NP=If(),OP=NP.getHighWaterMark,Ac=Kn().codes,$P=Ac.ERR_INVALID_ARG_TYPE,DP=Ac.ERR_STREAM_PUSH_AFTER_EOF,BP=Ac.ERR_METHOD_NOT_IMPLEMENTED,UP=Ac.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,fo,zf,Mf;fi()(At,ws);var Ss=qf.errorOrDestroy,Ff=["error","close","destroy","pause","resume"];function LP(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}c(LP,"prependListener");function py(t,e,r){lo=lo||di(),t=t||{},typeof r!="boolean"&&(r=e instanceof lo),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=OP(this,t,"readableHighWaterMark",r),this.buffer=new RP,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(fo||(fo=Bf().StringDecoder),this.decoder=new fo(t.encoding),this.encoding=t.encoding)}c(py,"ReadableState");function At(t){if(lo=lo||di(),!(this instanceof At))return new At(t);var e=this instanceof lo;this._readableState=new py(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),ws.call(this)}c(At,"Readable");Object.defineProperty(At.prototype,"destroyed",{enumerable:!1,get:c(function(){return this._readableState===void 0?!1:this._readableState.destroyed},"get"),set:c(function(e){this._readableState&&(this._readableState.destroyed=e)},"set")});At.prototype.destroy=qf.destroy;At.prototype._undestroy=qf.undestroy;At.prototype._destroy=function(t,e){e(t)};At.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=yc.from(t,e),e=""),n=!0),hy(this,t,e,!1,n)};At.prototype.unshift=function(t){return hy(this,t,null,!0,!1)};function hy(t,e,r,n,i){ct("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,FP(t,o);else{var s;if(i||(s=zP(o,e)),s)Ss(t,s);else if(o.objectMode||e&&e.length>0)if(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==yc.prototype&&(e=kP(e)),n)o.endEmitted?Ss(t,new UP):Hf(t,o,e,!0);else if(o.ended)Ss(t,new DP);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?Hf(t,o,e,!1):Wf(t,o)):Hf(t,o,e,!1)}else n||(o.reading=!1,Wf(t,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}c(hy,"readableAddChunk");function Hf(t,e,r,n){e.flowing&&e.length===0&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&Ec(t)),Wf(t,e)}c(Hf,"addChunk");function zP(t,e){var r;return!CP(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new $P("chunk",["string","Buffer","Uint8Array"],e)),r}c(zP,"chunkInvalid");At.prototype.isPaused=function(){return this._readableState.flowing===!1};At.prototype.setEncoding=function(t){fo||(fo=Bf().StringDecoder);var e=new fo(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var ly=1073741824;function MP(t){return t>=ly?t=ly:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}c(MP,"computeNewHighWaterMark");function fy(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=MP(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}c(fy,"howMuchToRead");At.prototype.read=function(t){ct("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return ct("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?jf(this):Ec(this),null;if(t=fy(t,e),t===0&&e.ended)return e.length===0&&jf(this),null;var n=e.needReadable;ct("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,ct("length less than watermark",n)),e.ended||e.reading?(n=!1,ct("reading or ended",n)):n&&(ct("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=fy(r,e)));var i;return t>0?i=_y(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&jf(this)),i!==null&&this.emit("data",i),i};function FP(t,e){if(ct("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?Ec(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,gy(t)))}}c(FP,"onEofChunk");function Ec(t){var e=t._readableState;ct("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(ct("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(gy,t))}c(Ec,"emitReadable");function gy(t){var e=t._readableState;ct("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Qf(t)}c(gy,"emitReadable_");function Wf(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(HP,t,e))}c(Wf,"maybeReadMore");function HP(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){var r=e.length;if(ct("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}c(HP,"maybeReadMore_");At.prototype._read=function(t){Ss(this,new BP("_read()"))};At.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t);break}n.pipesCount+=1,ct("pipe count=%d opts=%j",n.pipesCount,e);var i=(!e||e.end!==!1)&&t!==process.stdout&&t!==process.stderr,o=i?a:E;n.endEmitted?process.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(b,I){ct("onunpipe"),b===r&&I&&I.hasUnpiped===!1&&(I.hasUnpiped=!0,d())}c(s,"onunpipe");function a(){ct("onend"),t.end()}c(a,"onend");var u=jP(r);t.on("drain",u);var l=!1;function d(){ct("cleanup"),t.removeListener("close",h),t.removeListener("finish",_),t.removeListener("drain",u),t.removeListener("error",g),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",E),r.removeListener("data",p),l=!0,n.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&u()}c(d,"cleanup"),r.on("data",p);function p(b){ct("ondata");var I=t.write(b);ct("dest.write",I),I===!1&&((n.pipesCount===1&&n.pipes===t||n.pipesCount>1&&yy(n.pipes,t)!==-1)&&!l&&(ct("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}c(p,"ondata");function g(b){ct("onerror",b),E(),t.removeListener("error",g),dy(t,"error")===0&&Ss(t,b)}c(g,"onerror"),LP(t,"error",g);function h(){t.removeListener("finish",_),E()}c(h,"onclose"),t.once("close",h);function _(){ct("onfinish"),t.removeListener("close",h),E()}c(_,"onfinish"),t.once("finish",_);function E(){ct("unpipe"),r.unpipe(t)}return c(E,"unpipe"),t.emit("pipe",r),n.flowing||(ct("pipe resume"),r.resume()),t};function jP(t){return c(function(){var r=t._readableState;ct("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&dy(t,"data")&&(r.flowing=!0,Qf(t))},"pipeOnDrainFunctionResult")}c(jP,"pipeOnDrain");At.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=yy(e.pipes,t);return s===-1?this:(e.pipes.splice(s,1),e.pipesCount-=1,e.pipesCount===1&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r),this)};At.prototype.on=function(t,e){var r=ws.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,ct("on readable",n.length,n.reading),n.length?Ec(this):n.reading||process.nextTick(WP,this)),r};At.prototype.addListener=At.prototype.on;At.prototype.removeListener=function(t,e){var r=ws.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick(my,this),r};At.prototype.removeAllListeners=function(t){var e=ws.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick(my,this),e};function my(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}c(my,"updateReadableListening");function WP(t){ct("readable nexttick read 0"),t.read(0)}c(WP,"nReadingNextTick");At.prototype.resume=function(){var t=this._readableState;return t.flowing||(ct("resume"),t.flowing=!t.readableListening,qP(this,t)),t.paused=!1,this};function qP(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(QP,t,e))}c(qP,"resume");function QP(t,e){ct("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Qf(t),e.flowing&&!e.reading&&t.read(0)}c(QP,"resume_");At.prototype.pause=function(){return ct("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ct("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Qf(t){var e=t._readableState;for(ct("flow",e.flowing);e.flowing&&t.read()!==null;);}c(Qf,"flow");At.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;t.on("end",function(){if(ct("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&e.push(s)}e.push(null)}),t.on("data",function(s){if(ct("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=e.push(s);a||(n=!0,t.pause())}});for(var i in t)this[i]===void 0&&typeof t[i]=="function"&&(this[i]=c(function(a){return c(function(){return t[a].apply(t,arguments)},"methodWrapReturnFunction")},"methodWrap")(i));for(var o=0;o<Ff.length;o++)t.on(Ff[o],this.emit.bind(this,Ff[o]));return this._read=function(s){ct("wrapped _read",s),n&&(n=!1,t.resume())},this};typeof Symbol=="function"&&(At.prototype[Symbol.asyncIterator]=function(){return zf===void 0&&(zf=oy()),zf(this)});Object.defineProperty(At.prototype,"readableHighWaterMark",{enumerable:!1,get:c(function(){return this._readableState.highWaterMark},"get")});Object.defineProperty(At.prototype,"readableBuffer",{enumerable:!1,get:c(function(){return this._readableState&&this._readableState.buffer},"get")});Object.defineProperty(At.prototype,"readableFlowing",{enumerable:!1,get:c(function(){return this._readableState.flowing},"get"),set:c(function(e){this._readableState&&(this._readableState.flowing=e)},"set")});At._fromList=_y;Object.defineProperty(At.prototype,"readableLength",{enumerable:!1,get:c(function(){return this._readableState.length},"get")});function _y(t,e){if(e.length===0)return null;var r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}c(_y,"fromList");function jf(t){var e=t._readableState;ct("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(KP,e,t))}c(jf,"endReadable");function KP(t,e){if(ct("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}c(KP,"endReadableNT");typeof Symbol=="function"&&(At.from=function(t,e){return Mf===void 0&&(Mf=uy()),Mf(At,t,e)});function yy(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}c(yy,"indexOf")});var Kf=le((jF,by)=>{"use strict";by.exports=vn;var bc=Kn().codes,VP=bc.ERR_METHOD_NOT_IMPLEMENTED,GP=bc.ERR_MULTIPLE_CALLBACK,ZP=bc.ERR_TRANSFORM_ALREADY_TRANSFORMING,YP=bc.ERR_TRANSFORM_WITH_LENGTH_0,xc=di();fi()(vn,xc);function XP(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new GP);r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}c(XP,"afterTransform");function vn(t){if(!(this instanceof vn))return new vn(t);xc.call(this,t),this._transformState={afterTransform:XP.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",JP)}c(vn,"Transform");function JP(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){Ey(t,e,r)}):Ey(this,null,null)}c(JP,"prefinish");vn.prototype.push=function(t,e){return this._transformState.needTransform=!1,xc.prototype.push.call(this,t,e)};vn.prototype._transform=function(t,e,r){r(new VP("_transform()"))};vn.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};vn.prototype._read=function(t){var e=this._transformState;e.writechunk!==null&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0};vn.prototype._destroy=function(t,e){xc.prototype._destroy.call(this,t,function(r){e(r)})};function Ey(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new YP;if(t._transformState.transforming)throw new ZP;return t.push(null)}c(Ey,"done")});var vy=le((qF,Iy)=>{"use strict";Iy.exports=Ps;var xy=Kf();fi()(Ps,xy);function Ps(t){if(!(this instanceof Ps))return new Ps(t);xy.call(this,t)}c(Ps,"PassThrough");Ps.prototype._transform=function(t,e,r){r(null,t)}});var ky=le((KF,Ty)=>{"use strict";var Vf;function eT(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}c(eT,"once");var Py=Kn().codes,tT=Py.ERR_MISSING_ARGS,rT=Py.ERR_STREAM_DESTROYED;function Sy(t){if(t)throw t}c(Sy,"noop");function nT(t){return t.setHeader&&typeof t.abort=="function"}c(nT,"isRequest");function iT(t,e,r,n){n=eT(n);var i=!1;t.on("close",function(){i=!0}),Vf===void 0&&(Vf=gc()),Vf(t,{readable:e,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,nT(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new rT("pipe"))}}}c(iT,"destroyer");function wy(t){t()}c(wy,"call");function oT(t,e){return t.pipe(e)}c(oT,"pipe");function sT(t){return!t.length||typeof t[t.length-1]!="function"?Sy:t.pop()}c(sT,"popCallback");function aT(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=sT(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new tT("streams");var i,o=e.map(function(s,a){var u=a<e.length-1,l=a>0;return iT(s,u,l,function(d){i||(i=d),d&&o.forEach(wy),!u&&(o.forEach(wy),n(i))})});return e.reduce(oT)}c(aT,"pipeline");Ty.exports=aT});var Cy=le((jr,ks)=>{var Ts=require("stream");process.env.READABLE_STREAM==="disable"&&Ts?(ks.exports=Ts.Readable,Object.assign(ks.exports,Ts),ks.exports.Stream=Ts):(jr=ks.exports=Nf(),jr.Stream=Ts||jr,jr.Readable=jr,jr.Writable=kf(),jr.Duplex=di(),jr.Transform=Kf(),jr.PassThrough=vy(),jr.finished=gc(),jr.pipeline=ky())});var Ny=le((GF,Ry)=>{var cT=Object.prototype.toString,Gf=typeof Buffer<"u"&&typeof Buffer.alloc=="function"&&typeof Buffer.allocUnsafe=="function"&&typeof Buffer.from=="function";function uT(t){return cT.call(t).slice(8,-1)==="ArrayBuffer"}c(uT,"isArrayBuffer");function lT(t,e,r){e>>>=0;var n=t.byteLength-e;if(n<0)throw new RangeError("'offset' is out of bounds");if(r===void 0)r=n;else if(r>>>=0,r>n)throw new RangeError("'length' is out of bounds");return Gf?Buffer.from(t.slice(e,e+r)):new Buffer(new Uint8Array(t.slice(e,e+r)))}c(lT,"fromArrayBuffer");function fT(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Buffer.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');return Gf?Buffer.from(t,e):new Buffer(t,e)}c(fT,"fromString");function dT(t,e,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return uT(t)?lT(t,e,r):typeof t=="string"?fT(t,e):Gf?Buffer.from(t):new Buffer(t)}c(dT,"bufferFrom");Ry.exports=dT});var Ly=le(Be=>{var Oy=void 0,pT=1e5,Ot=(function(){var t=Object.prototype.toString,e=Object.prototype.hasOwnProperty;return{Class:c(function(r){return t.call(r).replace(/^\[object *|\]$/g,"")},"Class"),HasProperty:c(function(r,n){return n in r},"HasProperty"),HasOwnProperty:c(function(r,n){return e.call(r,n)},"HasOwnProperty"),IsCallable:c(function(r){return typeof r=="function"},"IsCallable"),ToInt32:c(function(r){return r>>0},"ToInt32"),ToUint32:c(function(r){return r>>>0},"ToUint32")}})(),hT=Math.LN2,gT=Math.abs,Ic=Math.floor,mT=Math.log,_T=Math.min,Zr=Math.pow,yT=Math.round;function Zf(t){if($y&&po){var e=$y(t),r;for(r=0;r<e.length;r+=1)po(t,e[r],{value:t[e[r]],writable:!1,enumerable:!1,configurable:!1})}}c(Zf,"configureProperties");var po;Object.defineProperty&&(function(){try{return Object.defineProperty({},"x",{}),!0}catch{return!1}})()?po=Object.defineProperty:po=c(function(t,e,r){if(!t===Object(t))throw new TypeError("Object.defineProperty called on non-object");return Ot.HasProperty(r,"get")&&Object.prototype.__defineGetter__&&Object.prototype.__defineGetter__.call(t,e,r.get),Ot.HasProperty(r,"set")&&Object.prototype.__defineSetter__&&Object.prototype.__defineSetter__.call(t,e,r.set),Ot.HasProperty(r,"value")&&(t[e]=r.value),t},"defineProp");var $y=Object.getOwnPropertyNames||function(t){if(t!==Object(t))throw new TypeError("Object.getOwnPropertyNames called on non-object");var e=[],r;for(r in t)Ot.HasOwnProperty(t,r)&&e.push(r);return e};function AT(t){if(!po)return;if(t.length>pT)throw new RangeError("Array too large for polyfill");function e(n){po(t,n,{get:c(function(){return t._getter(n)},"get"),set:c(function(i){t._setter(n,i)},"set"),enumerable:!0,configurable:!1})}c(e,"makeArrayAccessor");var r;for(r=0;r<t.length;r+=1)e(r)}c(AT,"makeArrayAccessors");function Yf(t,e){var r=32-e;return t<<r>>r}c(Yf,"as_signed");function Xf(t,e){var r=32-e;return t<<r>>>r}c(Xf,"as_unsigned");function ET(t){return[t&255]}c(ET,"packI8");function bT(t){return Yf(t[0],8)}c(bT,"unpackI8");function xT(t){return[t&255]}c(xT,"packU8");function Dy(t){return Xf(t[0],8)}c(Dy,"unpackU8");function IT(t){return t=yT(Number(t)),[t<0?0:t>255?255:t&255]}c(IT,"packU8Clamped");function vT(t){return[t>>8&255,t&255]}c(vT,"packI16");function ST(t){return Yf(t[0]<<8|t[1],16)}c(ST,"unpackI16");function wT(t){return[t>>8&255,t&255]}c(wT,"packU16");function PT(t){return Xf(t[0]<<8|t[1],16)}c(PT,"unpackU16");function TT(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}c(TT,"packI32");function kT(t){return Yf(t[0]<<24|t[1]<<16|t[2]<<8|t[3],32)}c(kT,"unpackI32");function CT(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}c(CT,"packU32");function RT(t){return Xf(t[0]<<24|t[1]<<16|t[2]<<8|t[3],32)}c(RT,"unpackU32");function By(t,e,r){var n=(1<<e-1)-1,i,o,s,a,u,l,d,p;function g(h){var _=Ic(h),E=h-_;return E<.5?_:E>.5||_%2?_+1:_}for(c(g,"roundToEven"),t!==t?(o=(1<<e)-1,s=Zr(2,r-1),i=0):t===1/0||t===-1/0?(o=(1<<e)-1,s=0,i=t<0?1:0):t===0?(o=0,s=0,i=1/t===-1/0?1:0):(i=t<0,t=gT(t),t>=Zr(2,1-n)?(o=_T(Ic(mT(t)/hT),1023),s=g(t/Zr(2,o)*Zr(2,r)),s/Zr(2,r)>=2&&(o=o+1,s=1),o>n?(o=(1<<e)-1,s=0):(o=o+n,s=s-Zr(2,r))):(o=0,s=g(t/Zr(2,1-n-r)))),l=[],u=r;u;u-=1)l.push(s%2?1:0),s=Ic(s/2);for(u=e;u;u-=1)l.push(o%2?1:0),o=Ic(o/2);for(l.push(i?1:0),l.reverse(),d=l.join(""),p=[];d.length;)p.push(parseInt(d.substring(0,8),2)),d=d.substring(8);return p}c(By,"packIEEE754");function Uy(t,e,r){var n=[],i,o,s,a,u,l,d,p;for(i=t.length;i;i-=1)for(s=t[i-1],o=8;o;o-=1)n.push(s%2?1:0),s=s>>1;return n.reverse(),a=n.join(""),u=(1<<e-1)-1,l=parseInt(a.substring(0,1),2)?-1:1,d=parseInt(a.substring(1,1+e),2),p=parseInt(a.substring(1+e),2),d===(1<<e)-1?p!==0?NaN:l*(1/0):d>0?l*Zr(2,d-u)*(1+p/Zr(2,r)):p!==0?l*Zr(2,-(u-1))*(p/Zr(2,r)):l<0?-0:0}c(Uy,"unpackIEEE754");function NT(t){return Uy(t,11,52)}c(NT,"unpackF64");function OT(t){return By(t,11,52)}c(OT,"packF64");function $T(t){return Uy(t,8,23)}c($T,"unpackF32");function DT(t){return By(t,8,23)}c(DT,"packF32");(function(){var t=c(function(h){if(h=Ot.ToInt32(h),h<0)throw new RangeError("ArrayBuffer size is not a small enough positive integer");this.byteLength=h,this._bytes=[],this._bytes.length=h;var _;for(_=0;_<this.byteLength;_+=1)this._bytes[_]=0;Zf(this)},"ArrayBuffer");Be.ArrayBuffer=Be.ArrayBuffer||t;var e=c(function(){},"ArrayBufferView");function r(g,h,_){var E;return E=c(function(b,I,w){var H,$,X,Z;if(!arguments.length||typeof arguments[0]=="number"){if(this.length=Ot.ToInt32(arguments[0]),w<0)throw new RangeError("ArrayBufferView size is not a small enough positive integer");this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new t(this.byteLength),this.byteOffset=0}else if(typeof arguments[0]=="object"&&arguments[0].constructor===E)for(H=arguments[0],this.length=H.length,this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new t(this.byteLength),this.byteOffset=0,X=0;X<this.length;X+=1)this._setter(X,H._getter(X));else if(typeof arguments[0]=="object"&&!(arguments[0]instanceof t||Ot.Class(arguments[0])==="ArrayBuffer"))for($=arguments[0],this.length=Ot.ToUint32($.length),this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new t(this.byteLength),this.byteOffset=0,X=0;X<this.length;X+=1)Z=$[X],this._setter(X,Number(Z));else if(typeof arguments[0]=="object"&&(arguments[0]instanceof t||Ot.Class(arguments[0])==="ArrayBuffer")){if(this.buffer=b,this.byteOffset=Ot.ToUint32(I),this.byteOffset>this.buffer.byteLength)throw new RangeError("byteOffset out of range");if(this.byteOffset%this.BYTES_PER_ELEMENT)throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.");if(arguments.length<3){if(this.byteLength=this.buffer.byteLength-this.byteOffset,this.byteLength%this.BYTES_PER_ELEMENT)throw new RangeError("length of buffer minus byteOffset not a multiple of the element size");this.length=this.byteLength/this.BYTES_PER_ELEMENT}else this.length=Ot.ToUint32(w),this.byteLength=this.length*this.BYTES_PER_ELEMENT;if(this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}else throw new TypeError("Unexpected argument type(s)");this.constructor=E,Zf(this),AT(this)},"ctor"),E.prototype=new e,E.prototype.BYTES_PER_ELEMENT=g,E.prototype._pack=h,E.prototype._unpack=_,E.BYTES_PER_ELEMENT=g,E.prototype._getter=function(b){if(arguments.length<1)throw new SyntaxError("Not enough arguments");if(b=Ot.ToUint32(b),b>=this.length)return Oy;var I=[],w,H;for(w=0,H=this.byteOffset+b*this.BYTES_PER_ELEMENT;w<this.BYTES_PER_ELEMENT;w+=1,H+=1)I.push(this.buffer._bytes[H]);return this._unpack(I)},E.prototype.get=E.prototype._getter,E.prototype._setter=function(b,I){if(arguments.length<2)throw new SyntaxError("Not enough arguments");if(b=Ot.ToUint32(b),b>=this.length)return Oy;var w=this._pack(I),H,$;for(H=0,$=this.byteOffset+b*this.BYTES_PER_ELEMENT;H<this.BYTES_PER_ELEMENT;H+=1,$+=1)this.buffer._bytes[$]=w[H]},E.prototype.set=function(b,I){if(arguments.length<1)throw new SyntaxError("Not enough arguments");var w,H,$,X,Z,Y,P,k,M,L;if(typeof arguments[0]=="object"&&arguments[0].constructor===this.constructor){if(w=arguments[0],$=Ot.ToUint32(arguments[1]),$+w.length>this.length)throw new RangeError("Offset plus length of array is out of range");if(k=this.byteOffset+$*this.BYTES_PER_ELEMENT,M=w.length*this.BYTES_PER_ELEMENT,w.buffer===this.buffer){for(L=[],Z=0,Y=w.byteOffset;Z<M;Z+=1,Y+=1)L[Z]=w.buffer._bytes[Y];for(Z=0,P=k;Z<M;Z+=1,P+=1)this.buffer._bytes[P]=L[Z]}else for(Z=0,Y=w.byteOffset,P=k;Z<M;Z+=1,Y+=1,P+=1)this.buffer._bytes[P]=w.buffer._bytes[Y]}else if(typeof arguments[0]=="object"&&typeof arguments[0].length<"u"){if(H=arguments[0],X=Ot.ToUint32(H.length),$=Ot.ToUint32(arguments[1]),$+X>this.length)throw new RangeError("Offset plus length of array is out of range");for(Z=0;Z<X;Z+=1)Y=H[Z],this._setter($+Z,Number(Y))}else throw new TypeError("Unexpected argument type(s)")},E.prototype.subarray=function(b,I){function w($,X,Z){return $<X?X:$>Z?Z:$}c(w,"clamp"),b=Ot.ToInt32(b),I=Ot.ToInt32(I),arguments.length<1&&(b=0),arguments.length<2&&(I=this.length),b<0&&(b=this.length+b),I<0&&(I=this.length+I),b=w(b,0,this.length),I=w(I,0,this.length);var H=I-b;return H<0&&(H=0),new this.constructor(this.buffer,this.byteOffset+b*this.BYTES_PER_ELEMENT,H)},E}c(r,"makeConstructor");var n=r(1,ET,bT),i=r(1,xT,Dy),o=r(1,IT,Dy),s=r(2,vT,ST),a=r(2,wT,PT),u=r(4,TT,kT),l=r(4,CT,RT),d=r(4,DT,$T),p=r(8,OT,NT);Be.Int8Array=Be.Int8Array||n,Be.Uint8Array=Be.Uint8Array||i,Be.Uint8ClampedArray=Be.Uint8ClampedArray||o,Be.Int16Array=Be.Int16Array||s,Be.Uint16Array=Be.Uint16Array||a,Be.Int32Array=Be.Int32Array||u,Be.Uint32Array=Be.Uint32Array||l,Be.Float32Array=Be.Float32Array||d,Be.Float64Array=Be.Float64Array||p})();(function(){function t(o,s){return Ot.IsCallable(o.get)?o.get(s):o[s]}c(t,"r");var e=(function(){var o=new Be.Uint16Array([4660]),s=new Be.Uint8Array(o.buffer);return t(s,0)===18})(),r=c(function(s,a,u){if(arguments.length===0)s=new Be.ArrayBuffer(0);else if(!(s instanceof Be.ArrayBuffer||Ot.Class(s)==="ArrayBuffer"))throw new TypeError("TypeError");if(this.buffer=s||new Be.ArrayBuffer(0),this.byteOffset=Ot.ToUint32(a),this.byteOffset>this.buffer.byteLength)throw new RangeError("byteOffset out of range");if(arguments.length<3?this.byteLength=this.buffer.byteLength-this.byteOffset:this.byteLength=Ot.ToUint32(u),this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");Zf(this)},"DataView");function n(o){return function(s,a){if(s=Ot.ToUint32(s),s+o.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");s+=this.byteOffset;var u=new Be.Uint8Array(this.buffer,s,o.BYTES_PER_ELEMENT),l=[],d;for(d=0;d<o.BYTES_PER_ELEMENT;d+=1)l.push(t(u,d));return!!a==!!e&&l.reverse(),t(new o(new Be.Uint8Array(l).buffer),0)}}c(n,"makeGetter"),r.prototype.getUint8=n(Be.Uint8Array),r.prototype.getInt8=n(Be.Int8Array),r.prototype.getUint16=n(Be.Uint16Array),r.prototype.getInt16=n(Be.Int16Array),r.prototype.getUint32=n(Be.Uint32Array),r.prototype.getInt32=n(Be.Int32Array),r.prototype.getFloat32=n(Be.Float32Array),r.prototype.getFloat64=n(Be.Float64Array);function i(o){return function(s,a,u){if(s=Ot.ToUint32(s),s+o.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");var l=new o([a]),d=new Be.Uint8Array(l.buffer),p=[],g,h;for(g=0;g<o.BYTES_PER_ELEMENT;g+=1)p.push(t(d,g));!!u==!!e&&p.reverse(),h=new Be.Uint8Array(this.buffer,s,o.BYTES_PER_ELEMENT),h.set(p)}}c(i,"makeSetter"),r.prototype.setUint8=i(Be.Uint8Array),r.prototype.setInt8=i(Be.Int8Array),r.prototype.setUint16=i(Be.Uint16Array),r.prototype.setInt16=i(Be.Int16Array),r.prototype.setUint32=i(Be.Uint32Array),r.prototype.setInt32=i(Be.Int32Array),r.prototype.setFloat32=i(Be.Float32Array),r.prototype.setFloat64=i(Be.Float64Array),Be.DataView=Be.DataView||r})()});var Hy=le((JF,Fy)=>{var zy=Cy().Writable,BT=fi(),Cs=Ny();typeof Uint8Array>"u"?vc=Ly().Uint8Array:vc=Uint8Array;var vc;function _i(t,e){if(!(this instanceof _i))return new _i(t,e);typeof t=="function"&&(e=t,t={}),t||(t={});var r=t.encoding,n=!1;r?(r=String(r).toLowerCase(),(r==="u8"||r==="uint8")&&(r="uint8array")):n=!0,zy.call(this,{objectMode:!0}),this.encoding=r,this.shouldInferEncoding=n,e&&this.on("finish",function(){e(this.getBody())}),this.body=[]}c(_i,"ConcatStream");Fy.exports=_i;BT(_i,zy);_i.prototype._write=function(t,e,r){this.body.push(t),r()};_i.prototype.inferEncoding=function(t){var e=t===void 0?this.body[0]:t;return Buffer.isBuffer(e)?"buffer":typeof Uint8Array<"u"&&e instanceof Uint8Array?"uint8array":Array.isArray(e)?"array":typeof e=="string"?"string":Object.prototype.toString.call(e)==="[object Object]"?"object":"buffer"};_i.prototype.getBody=function(){return!this.encoding&&this.body.length===0?[]:(this.shouldInferEncoding&&(this.encoding=this.inferEncoding()),this.encoding==="array"?MT(this.body):this.encoding==="string"?LT(this.body):this.encoding==="buffer"?zT(this.body):this.encoding==="uint8array"?FT(this.body):this.body)};function UT(t){return/Array\]$/.test(Object.prototype.toString.call(t))}c(UT,"isArrayish");function My(t){return typeof t=="string"||UT(t)||t&&typeof t.subarray=="function"}c(My,"isBufferish");function LT(t){for(var e=[],r=!1,n=0;n<t.length;n++){var i=t[n];typeof i=="string"||Buffer.isBuffer(i)?e.push(i):My(i)?e.push(Cs(i)):e.push(Cs(String(i)))}return Buffer.isBuffer(t[0])?(e=Buffer.concat(e),e=e.toString("utf8")):e=e.join(""),e}c(LT,"stringConcat");function zT(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];Buffer.isBuffer(n)?e.push(n):My(n)?e.push(Cs(n)):e.push(Cs(String(n)))}return Buffer.concat(e)}c(zT,"bufferConcat");function MT(t){for(var e=[],r=0;r<t.length;r++)e.push.apply(e,t[r]);return e}c(MT,"arrayConcat");function FT(t){for(var e=0,r=0;r<t.length;r++)typeof t[r]=="string"&&(t[r]=Cs(t[r])),e+=t[r].length;for(var n=new vc(e),r=0,i=0;r<t.length;r++)for(var o=t[r],s=0;s<o.length;s++)n[i++]=o[s];return n}c(FT,"u8Concat")});var qy=le((t5,Wy)=>{"use strict";function jy(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}c(jy,"assign");function HT(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=void 0),e!=null&&(r.code=e);try{return jy(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=c(function(){},"ErrClass");return i.prototype=Object.create(Object.getPrototypeOf(t)),jy(new i,r)}}c(HT,"createError");Wy.exports=HT});var Ky=le((n5,Qy)=>{function Wr(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}c(Wr,"RetryOperation");Qy.exports=Wr;Wr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Wr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Wr.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var n=this,i=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r);return this._options.unref&&i.unref(),!0};Wr.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Wr.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};Wr.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};Wr.prototype.start=Wr.prototype.try;Wr.prototype.errors=function(){return this._errors};Wr.prototype.attempts=function(){return this._attempts};Wr.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,s=(t[o]||0)+1;t[o]=s,s>=r&&(e=i,r=s)}return e}});var Vy=le(yi=>{var jT=Ky();yi.operation=function(t){var e=yi.timeouts(t);return new jT(e,{forever:t&&t.forever,unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};yi.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in t)e[r]=t[r];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<e.retries;i++)n.push(this.createTimeout(i,e));return t&&t.forever&&!n.length&&n.push(this.createTimeout(i,e)),n.sort(function(o,s){return o-s}),n};yi.createTimeout=function(t,e){var r=e.randomize?Math.random()+1:1,n=Math.round(r*e.minTimeout*Math.pow(e.factor,t));return n=Math.min(n,e.maxTimeout),n};yi.wrap=function(t,e,r){if(e instanceof Array&&(r=e,e=null),!r){r=[];for(var n in t)typeof t[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var o=r[i],s=t[o];t[o]=c(function(u){var l=yi.operation(e),d=Array.prototype.slice.call(arguments,1),p=d.pop();d.push(function(g){l.retry(g)||(g&&(arguments[0]=l.mainError()),p.apply(this,arguments))}),l.attempt(function(){u.apply(t,d)})},"retryWrapper").bind(t,s),t[o].options=e}}});var Zy=le((a5,Gy)=>{Gy.exports=Vy()});var Jy=le((c5,Xy)=>{"use strict";var WT=qy(),qT=Zy(),QT=Object.prototype.hasOwnProperty;function Yy(t){return t&&t.code==="EPROMISERETRY"&&QT.call(t,"retried")}c(Yy,"isRetryError");function KT(t,e){var r,n;return typeof t=="object"&&typeof e=="function"&&(r=e,e=t,t=r),n=qT.operation(e),new Promise(function(i,o){n.attempt(function(s){Promise.resolve().then(function(){return t(function(a){throw Yy(a)&&(a=a.retried),WT(new Error("Retrying"),"EPROMISERETRY",{retried:a})},s)}).then(i,function(a){Yy(a)&&(a=a.retried,n.retry(a||new Error))||o(a)})})})}c(KT,"promiseRetry");Xy.exports=KT});var Jf=le((l5,eA)=>{var VT={generic:"ERR_GENERIC_CLIENT",connect:"ERR_NOT_CONNECTED",badPath:"ERR_BAD_PATH",permission:"EACCES",notexist:"ENOENT",notdir:"ENOTDIR",badAuth:"ERR_BAD_AUTH"},GT={writeFile:1,readFile:2,writeDir:3,readDir:4,readObj:5,writeObj:6};eA.exports={errorCode:VT,targetType:GT}});var sA=le((f5,oA)=>{var Rs=require("fs"),ZT=require("path"),{errorCode:tA}=Jf();function rA(t,e,r){return c(i=>{if(t.endCalled||t.errorHandled){t.debugMsg(`${e} errorListener - ignoring handled error`);return}t.errorHandled=!0;let o=new Error(`${e}: ${i.message}`);if(o.code=i.code,r)r(o);else throw o},"fn")}c(rA,"errorListener");function YT(t,e){return()=>{t.endCalled||t.errorHandled||t.closeHandled?t.debugMsg(`Global ${e} event: Ignoring expected and handled event`):(t.debugMsg(`Global ${e} event: Handling unexpected event`),t.sftp=void 0)}}c(YT,"globalListener");function nA(t,e,r){return c(function(){if(t.sftp=void 0,t.endCalled||t.endHandled||t.errorHandled){t.debugMsg(`${e} endListener - ignoring handled error`);return}t.endHandled=!0,t.debugMsg(`${e} Unexpected end event - ignoring`)},"fn")}c(nA,"endListener");function iA(t,e,r){return c(function(){if(t.sftp=void 0,t.endCalled||t.closeHandled||t.errorHandled||t.endHandled){t.debugMsg(`${e} closeListener - ignoring handled error`);return}t.closeHandled=!0,t.debugMsg(`${e} Unexpected close event raised - ignoring`)},"fn")}c(iA,"closeListener");function XT(t,e,r){let n={end:nA(t,e,r),close:iA(t,e,r),error:rA(t,e,r)};return t.on("end",n.end),t.on("close",n.close),t.on("error",n.error),t._resetEventFlags(),n}c(XT,"addTempListeners");function JT(t,e,r){try{t.removeListener("end",e.end),t.removeListener("close",e.close),t.removeListener("error",e.error)}catch(n){throw new Error(`${r}: Error removing temp listeners: ${n.message}`)}}c(JT,"removeTempListeners");function ed(t){let e=Rs.statSync(t,{throwIfNoEntry:!1});if(e){if(e.isDirectory())return"d";if(e.isFile())return"-";{let r=new Error(`Bad path: ${t}: target must be a file or directory`);throw r.code=tA.badPath,r}}else return!1}c(ed,"localExists");function td(t,e="r"){let r=Rs.constants.F_OK|e==="w"?Rs.constants.W_OK:Rs.constants.R_OK;try{return Rs.accessSync(t,r),{status:!0,type:ed(t),details:"access OK",code:0}}catch(n){switch(n.errno){case-2:return{status:!1,type:null,details:"not exist",code:-2};case-13:return{status:!1,type:ed(t),details:"permission denied",code:-13};case-20:return{status:!1,type:null,details:"parent not a directory"};default:return{status:!1,type:null,details:n.message}}}}c(td,"haveLocalAccess");function e1(t){let{status:e,details:r,type:n}=td(t,"w");if(!e&&r==="permission denied")return{status:e,details:r,type:n};if(!e){let i=ZT.dirname(t),o=td(i,"w");return o.status&&o.type!=="d"?{status:!1,details:`${i}: not a directory`,type:null}:o.status?{status:!0,details:"access OK",type:null,code:0}:{status:o.status,details:`${i}: ${o.details}`,type:null}}return{status:e,details:r,type:n}}c(e1,"haveLocalCreate");async function t1(t,e){try{return e.startsWith("..")?`${await t.realPath("..")}/${e.slice(3)}`:e.startsWith(".")?`${await t.realPath(".")}/${e.slice(2)}`:e}catch(r){throw new Error(`normalizeRemotePath: ${r.message}`)}}c(t1,"normalizeRemotePath");function r1(t,e,r){if(!t.sftp){let n=new Error(`${e}: No SFTP connection available`);if(n.code=tA.connect,r)return r(n),!1;throw n}return!0}c(r1,"haveConnection");function n1(t){return new Promise((e,r)=>{try{isNaN(t)||t<0?r("Argument must be anumber >= 0"):setTimeout(()=>{e(!0)},t)}catch(n){r(n)}})}c(n1,"sleep");oA.exports={globalListener:YT,errorListener:rA,endListener:nA,closeListener:iA,addTempListeners:XT,removeTempListeners:JT,haveLocalAccess:td,haveLocalCreate:e1,normalizeRemotePath:t1,localExists:ed,haveConnection:r1,sleep:n1}});var lA=le((p5,uA)=>{"use strict";var{Client:i1}=S_(),Sc=require("fs"),o1=Hy(),s1=Jy(),{join:Ns,parse:a1}=require("path"),{globalListener:rd,addTempListeners:zt,removeTempListeners:Mt,haveConnection:lr,normalizeRemotePath:Os,localExists:aA,haveLocalAccess:cA,haveLocalCreate:nd}=sA(),{errorCode:$t}=Jf(),id=class{static{c(this,"SftpClient")}constructor(e){this.version="9.0.4",this.client=new i1,this.sftp=void 0,this.clientName=e||"sftp",this.endCalled=!1,this.errorHandled=!1,this.closeHandled=!1,this.endHandled=!1,this.remotePlatform="unix",this.debug=void 0,this.client.on("close",rd(this,"close")),this.client.on("end",rd(this,"end")),this.client.on("error",rd(this,"error"))}debugMsg(e,r){this.debug&&(r?this.debug(`CLIENT[${this.clientName}]: ${e} ${JSON.stringify(r,null," ")}`):this.debug(`CLIENT[${this.clientName}]: ${e}`))}fmtError(e,r="sftp",n,i){let o="",s="",a=i?` after ${i} ${i>1?"attempts":"attempt"}`:"";if(e===void 0)o=`${r}: Undefined error - probably a bug!`,s=$t.generic;else if(typeof e=="string")o=`${r}: ${e}${a}`,s=n||$t.generic;else if(e.custom)o=`${r}->${e.message}${a}`,s=e.code;else{switch(e.code){case"ENOTFOUND":o=`${r}: Address lookup failed for host${a}`;break;case"ECONNREFUSED":o=`${r}: Remote host refused connection${a}`;break;case"ECONNRESET":o=`${r}: Remote host has reset the connection: ${e.message}${a}`;break;default:o=`${r}: ${e.message}${a}`}s=e.code?e.code:$t.generic}let u=new Error(o);return u.code=s,u.custom=!0,this.debugMsg(`${u.message} (${u.code})`),u}on(e,r){this.client.prependListener(e,r)}removeListener(e,r){this.client.removeListener(e,r)}_resetEventFlags(){this.closeHandled=!1,this.endHandled=!1,this.errorHandled=!1}getConnection(e){let r,n;return new Promise((i,o)=>{n=zt(this,"getConnection",o),r=c(()=>{this.debugMsg("getConnection ready listener: got connection - promise resolved"),i(!0)},"doReady"),this.on("ready",r);try{this.client.connect(e)}catch(s){this.debugMsg(`getConnection: ${s.message}`),o(s)}}).finally(()=>{this.removeListener("ready",r),Mt(this,n,"getConnection")})}getSftpChannel(){return new Promise((e,r)=>{this.client.sftp((n,i)=>{n?r(this.fmtError(n,"getSftpChannel",n.code)):(this.sftp=i,e(i))})})}async connect(e){let r;try{if(r=zt(this,"connect"),e.debug&&(this.debug=e.debug,this.debugMsg("connect: Debugging turned on"),this.debugMsg(`ssh2-sftp-client Version: ${this.version} `,process.versions)),this.sftp)throw this.fmtError("An existing SFTP connection is already defined","connect",$t.connect);let n={retries:e.retries??1,factor:e.factor??2,minTimeout:e.retry_minTimeout??25e3};return await s1(n,async(o,s)=>{try{this.debugMsg(`connect: Connect attempt ${s}`),await this.getConnection(e)}catch(a){switch(a.code){case"ENOTFOUND":case"ECONNREFUSED":case"ERR_SOCKET_BAD_PORT":throw a;case void 0:{if(a.message.endsWith("All configured authentication methods failed")||a.message.startsWith("Cannot parse privateKey"))throw a;o(a);break}default:o(a)}}}),await this.getSftpChannel()}catch(n){throw this.end(),n.custom?n:this.fmtError(n,"connect")}finally{Mt(this,r,"connect")}}realPath(e,r=!0){let n;return new Promise((i,o)=>{r&&(n=zt(this,"realPath",o)),this.debugMsg(`realPath -> ${e}`),this.sftp.realpath(e,(s,a)=>{s&&(s.code===2?(this.debugMsg('realPath <- ""'),i("")):(this.debugMsg(`${s.message} ${e}`,"realPath"),o(this.fmtError(`${s.message} ${e}`,"realPath",s.code)))),this.debugMsg(`realPath <- ${a}`),i(a)})}).finally(()=>{r&&Mt(this,n,"realPath")})}cwd(){return this.realPath(".")}_xstat(e,r,n=!0){let i;return new Promise((o,s)=>{let a=c((u,l)=>{if(u)u.code===2||u.code===4?s(this.fmtError(`No such file: ${r}`,"_xstat",$t.notexist)):s(this.fmtError(`${u.message} ${r}`,"_xstat",u.code));else{let d={mode:l.mode,uid:l.uid,gid:l.gid,size:l.size,accessTime:l.atime*1e3,modifyTime:l.mtime*1e3,isDirectory:l.isDirectory(),isFile:l.isFile(),isBlockDevice:l.isBlockDevice(),isCharacterDevice:l.isCharacterDevice(),isSymbolicLink:l.isSymbolicLink(),isFIFO:l.isFIFO(),isSocket:l.isSocket()};this.debugMsg("_xstat: result = ",d),o(d)}},"cb");n&&(i=zt(this,"_xstat",s)),e==="stat"?this.sftp.stat(r,a):this.sftp.lstat(r,a)}).finally(()=>{n&&Mt(this,i,"_xstat")})}async stat(e){try{return lr(this,"stat"),await this._xstat("stat",e)}catch(r){throw r.custom?r:this.fmtError(r,"stat",r.code)}}async lstat(e){try{return lr(this,"lstat"),await this._xstat("lstat",e)}catch(r){throw r.custom?r:this.fmtError(r,"lstat",r.code)}}async exists(e){this.debugMsg(`exists: remotePath = ${e}`);try{if(e===".")return"d";let r=await this.lstat(e);return this.debugMsg("exists: <- ",r),r.isDirectory?"d":r.isSymbolicLink?"l":r.isFile?"-":!1}catch(r){if(r.code===$t.notexist)return!1;throw r.custom?r:this.fmtError(r.message,"exists",r.code)}}list(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"list",s)),lr(this,"list",s)&&this.sftp.readdir(e,(a,u)=>{if(a)s(this.fmtError(`${a.message} ${e}`,"list",a.code));else{let l=/-/gi,d=u.map(p=>({type:p.longname.slice(0,1),name:p.filename,size:p.attrs.size,modifyTime:p.attrs.mtime*1e3,accessTime:p.attrs.atime*1e3,rights:{user:p.longname.slice(1,4).replace(l,""),group:p.longname.slice(4,7).replace(l,""),other:p.longname.slice(7,10).replace(l,"")},owner:p.attrs.uid,group:p.attrs.gid,longname:p.longname}));o(r?d.filter(p=>r(p)):d)}})}).finally(()=>{n&&Mt(this,i,"list")})}get(e,r,n,i=!0){let o,s,a;return new Promise((u,l)=>{if(i&&(o=zt(this,"get",l)),lr(this,"get",l)){if(n={readStreamOptions:{...n?.readStreamOptions,autoClose:!0},writeStreamOptions:{...n?.writeStreamOptions,autoClose:!0},pipeOptions:{...n?.pipeOptions,end:!0}},s=this.sftp.createReadStream(e,n.readStreamOptions),s.once("error",d=>{r&&typeof r!="string"&&!r.destroyed&&r.destroy(),l(this.fmtError(`${d.message} ${e}`,"get",d.code))}),r===void 0)this.debugMsg("get resolving buffer of data"),a=o1(d=>{u(d)});else if(typeof r=="string"){this.debugMsg("get returning local file");let d=nd(r);if(d.status)a=Sc.createWriteStream(r,n.writeStreamOptions);else{l(this.fmtError(`Bad path: ${r}: ${d.details}`,"get",d.code));return}}else this.debugMsg("get: returning data into supplied stream"),a=r;a.once("error",d=>{l(this.fmtError(`${d.message} ${typeof r=="string"?r:"<stream>"}`,"get",d.code))}),s.once("end",()=>{typeof r=="string"?(this.debugMsg("get: resolving with dst filename"),u(r)):r!==void 0&&(this.debugMsg("get: resolving with writer stream object"),u(a))}),s.pipe(a,n.pipeOptions)}}).finally(()=>{i&&Mt(this,o,"get")})}_fastGet(e,r,n,i=!0){let o;return new Promise((s,a)=>{i&&(o=zt(this,"_fastGet",a)),lr(this,"_fastGet",a)&&this.sftp.fastGet(e,r,n,u=>{u&&a(this.fmtError(`${u.message} Remote: ${e} Local: ${r}`)),s(`${e} was successfully download to ${r}!`)})}).finally(()=>{i&&Mt(this,o,"_fastGet")})}async fastGet(e,r,n){try{let i=await this.exists(e);if(i!=="-"){let s=`${i?"Not a regular file":"No such file "} ${e}`;throw this.fmtError(s,"fastGet",$t.badPath)}let o=nd(r);if(!o.status)throw this.fmtError(`Bad path: ${r}: ${o.details}`,"fastGet",$t.badPath);return await this._fastGet(e,r,n)}catch(i){throw this.fmtError(i,"fastGet")}}_fastPut(e,r,n,i=!0){let o;return new Promise((s,a)=>{i&&(o=zt(this,"_fastPut",a)),lr(this,"_fastPut",a)&&this.sftp.fastPut(e,r,n,u=>{u&&a(this.fmtError(`${u.message} Local: ${e} Remote: ${r}`,"fastPut",u.code)),s(`${e} was successfully uploaded to ${r}!`)})}).finally(()=>{i&&Mt(this,o,"_fastPut")})}async fastPut(e,r,n){try{this.debugMsg(`fastPut -> local ${e} remote ${r}`);let i=cA(e);if(i.status){if(i.status&&aA(e)==="d")throw this.fmtError(`Bad path: ${e} not a regular file`,"fastgPut",$t.badPath)}else throw this.fmtError(`Bad path: ${e}: ${i.details}`,"fastPut",i.code);return await this._fastPut(e,r,n)}catch(i){throw i.custom?i:this.fmtError(i.message,"fastPut",i.code)}}_put(e,r,n,i=!0){let o,s,a;return new Promise((u,l)=>{i&&(o=zt(this,"_put",l)),n={readStreamOptions:{...n?.readStreamOptions,autoClose:!0},writeStreamOptions:{...n?.writeStreamOptions,autoClose:!0},pipeOptions:{...n?.pipeOptions,end:!0}},lr(this,"_put",l)&&(s=this.sftp.createWriteStream(r,n.writeStreamOptions),s.once("error",d=>{l(this.fmtError(`Write stream error: ${d.message} ${r}`,"_put",d.code))}),s.once("close",()=>{u(`Uploaded data stream to ${r}`)}),e instanceof Buffer?(this.debugMsg("put source is a buffer"),s.end(e)):(a=typeof e=="string"?Sc.createReadStream(e,n.readStreamOptions):e,a.once("error",d=>{l(this.fmtError(`Read stream error: ${d.message} ${typeof e=="string"?e:"<stream>"}`,"_put",d.code))}),a.pipe(s,n.pipeOptions)))}).finally(()=>{i&&Mt(this,o,"_put")})}async put(e,r,n){try{if(typeof e=="string"){let i=cA(e);if(!i.status)throw this.fmtError(`Bad path: ${e} ${i.details}`,"put",i.code)}return await this._put(e,r,n)}catch(i){throw i.custom?i:this.fmtError(`Re-thrown: ${i.message}`,"put",i.code)}}_append(e,r,n,i=!0){let o;return new Promise((s,a)=>{if(i&&(o=zt(this,"_append",a)),lr(this,"_append",a)){this.debugMsg(`append -> remote: ${r} `,n),n.flags="a";let u=this.sftp.createWriteStream(r,n);u.on("error",l=>{a(this.fmtError(`${l.message} ${r}`,"append",l.code))}),u.on("close",()=>{s(`Appended data to ${r}`)}),e instanceof Buffer?(u.write(e),u.end()):e.pipe(u)}}).finally(()=>{i&&Mt(this,o,"_append")})}async append(e,r,n={}){try{if(typeof e=="string")throw this.fmtError("Cannot append one file to another","append",$t.badPath);let i=await this.exists(r);if(i&&i==="d")throw this.fmtError(`Bad path: ${r}: cannot append to a directory`,"append",$t.badPath);await this._append(e,r,n)}catch(i){throw i.custom?i:this.fmtError(i.message,"append",i.code)}}_doMkdir(e,r=!0){let n;return new Promise((i,o)=>{r&&(n=zt(this,"_doMkdir",o)),this.sftp.mkdir(e,s=>{s?s.code===4?o(this.fmtError(`Bad path: ${e} permission denied`,"_doMkdir",$t.badPath)):s.code===2?o(this.fmtError(`Bad path: ${e} parent not a directory or not exist`,"_doMkdir",$t.badPath)):o(this.fmtError(`${s.message} ${e}`,"_doMkdir",s.code)):i(`${e} directory created`)})}).finally(()=>{r&&Mt(this,n,"_doMkdir")})}async _mkdir(e,r){try{let n=await Os(this,e),i=await this.exists(n);if(i&&i!=="d")throw this.fmtError(`Bad path: ${n} already exists as a file`,"_mkdir",$t.badPath);if(i)return`${n} already exists`;if(!r)return await this._doMkdir(n);let o=a1(n).dir;if(o){let s=await this.exists(o);if(!s)await this._mkdir(o,!0);else if(s!=="d")throw this.fmtError(`Bad path: ${o} not a directory`,"_mkdir",$t.badPath)}return await this._doMkdir(n)}catch(n){throw n.custom?n:this.fmtError(`${n.message} ${e}`,"_mkdir",n.code)}}async mkdir(e,r=!1){try{return lr(this,"mkdir"),await this._mkdir(e,r)}catch(n){throw this.fmtError(`${n.message}`,"mkdir",n.code)}}async rmdir(e,r=!1){let n=c(o=>{let s;return new Promise((a,u)=>{s=zt(this,"_rmdir",u),this.debugMsg(`_rmdir: dir = ${o}`),this.sftp.rmdir(o,l=>{l&&u(this.fmtError(`${l.message} ${o}`,"rmdir",l.code)),a("Successfully removed directory")})}).finally(()=>{Mt(this,s,"_rmdir")})},"_rmdir"),i=c((o,s)=>{let a;return new Promise((u,l)=>{a=zt(this,"_delFiles",l),this.debugMsg(`_delFiles: path = ${o} fileList = ${s}`);let d=[];for(let p of s)d.push(this.delete(`${o}/${p.name}`,!0,!1));u(d)}).then(u=>Promise.all(u)).finally(()=>{Mt(this,a,"_delFiles")})},"_delFiles");try{this.debugMsg(`rmdir: dir = ${e} recursive = ${r}`);let o=await Os(this,e),s=await this.exists(o);if(this.debugMsg(`rmdir: ${o} existStatus = ${s}`),!s)throw this.fmtError(`Bad Path: ${e}: No such directory`,"rmdir",$t.badPath);if(s!=="d")throw this.fmtError(`Bad Path: ${e}: Not a directory`,"rmdir",$t.badPath);if(!r)return this.debugMsg("rmdir: non-recursive - just try to remove it"),await n(o);let a=await this.list(o);if(this.debugMsg(`rmdir: listing count = ${a.length}`),!a.length)return this.debugMsg("rmdir: No sub dir or files, just rmdir"),await n(o);let u=a.filter(d=>d.type!=="d");this.debugMsg(`rmdir: dir content files to remove = ${u.length}`);let l=a.filter(d=>d.type==="d");this.debugMsg(`rmdir: sub-directories to remove = ${l.length}`),await i(o,u);for(let d of l)await this.rmdir(`${o}/${d.name}`,!0);return await n(o),"Successfully removed directory"}catch(o){throw o.custom?o:this.fmtError(`${o.message} ${e}`,"rmdir",o.code)}}delete(e,r=!1,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"delete",s)),this.sftp.unlink(e,a=>{a&&(r&&a.code===2?o(`Successfully deleted ${e}`):s(this.fmtError(`${a.message} ${e}`,"delete",a.code))),o(`Successfully deleted ${e}`)})}).finally(()=>{n&&Mt(this,i,"delete")})}rename(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"rename",s)),lr(this,"rename",s)&&this.sftp.rename(e,r,a=>{a&&s(this.fmtError(`${a.message} From: ${e} To: ${r}`,"_rename",a.code)),o(`Successfully renamed ${e} to ${r}`)})}).finally(()=>{n&&Mt(this,i,"rename")})}posixRename(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"posixRename",s)),lr(this,"posixRename",s)&&this.sftp.ext_openssh_rename(e,r,a=>{a&&s(this.fmtError(`${a.message} From: ${e} To: ${r}`,"_posixRename",a.code)),o(`Successful POSIX rename ${e} to ${r}`)})}).finally(()=>{Mt(this,i,"posixRename")})}chmod(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"chmod",s)),lr(this,"chmod",s)&&this.sftp.chmod(e,r,a=>{a&&s(this.fmtError(`${a.message} ${e}`,"_chmod",a.code)),o("Successfully change file mode")})}).finally(()=>{n&&Mt(this,i,"chmod")})}async uploadDir(e,r,n){let i=c(async a=>{let u=await Os(this,a),l=await this.exists(u);if(l&&l!=="d")throw this.fmtError(`Bad path ${u} Not a directory`,"getRemoteStatus",$t.badPath);return{remoteDir:u,remoteStatus:l}},"getRemoteStatus"),o=c(a=>{let u=aA(a);if(!u)throw this.fmtError(`Bad path: ${a} not exist`,"getLocalStatus",$t.badPath);if(u!=="d")throw this.fmtError(`Bad path: ${a}: not a directory`,"getLocalStatus",$t.badPath);return u},"checkLocalStatus"),s=c((a,u,l,d)=>{let p;return new Promise((g,h)=>{p=zt(this,"uploadFiles",h);let _=[];for(let E of l){let b=Ns(a,E.name),I=`${u}/${E.name}`;E.isFile()?(d?_.push(this._fastPut(b,I,null,!1)):_.push(this._put(b,I,null,!1)),this.client.emit("upload",{source:b,destination:I})):this.debugMsg(`uploadFiles: File ignored: ${E.name} not a regular file`)}g(Promise.all(_))}).then(g=>Promise.all(g)).finally(()=>{Mt(this,p,s)})},"uploadFiles");try{lr(this,"uploadDir"),this.debugMsg(`uploadDir: srcDir = ${e} dstDir = ${r} options = ${n}`);let{remoteDir:a,remoteStatus:u}=await i(r);this.debugMsg(`uploadDir: remoteDir = ${a} remoteStatus = ${u}`),o(e),u||await this._mkdir(a,!0);let l=Sc.readdirSync(e,{encoding:"utf8",withFileTypes:!0});this.debugMsg(`uploadDir: dirEntries = ${l}`),n?.filter&&(l=l.filter(g=>n.filter(Ns(e,g.name),g.isDirectory())));let d=l.filter(g=>g.isDirectory()),p=l.filter(g=>!g.isDirectory());this.debugMsg(`uploadDir: dirUploads = ${d}`),this.debugMsg(`uploadDir: fileUploads = ${p}`),await s(e,a,p,n?.useFastput);for(let g of d){let h=Ns(e,g.name),_=`${a}/${g.name}`;await this.uploadDir(h,_,n)}return`${e} uploaded to ${r}`}catch(a){throw a.custom?a:this.fmtError(`${a.message} ${e}`,"uploadDir",a.code)}}async downloadDir(e,r,n={filter:null,useFastget:!1}){let i=c(async(a,u)=>{try{let l=await this.list(a);return u?l.filter(d=>u(`${a}/${d.name}`,d.type==="d")):l}catch(l){throw l.custom?l:this.fmtError(l.message,"_getDownloadList",l.code)}},"_getDownloadList"),o=c(a=>{try{let u=nd(a);if(!u.status&&u.details==="permission denied")throw this.fmtError(`Bad path: ${a}: ${u.details}`,"prepareDestination",u.code);if(u.status&&!u.type)Sc.mkdirSync(a,{recursive:!0});else if(u.status&&u.type!=="d")throw this.fmtError(`Bad path: ${r}: not a directory`,"_prepareDestination",$t.badPath)}catch(u){throw u.custom?u:this.fmtError(u.message,"_prepareDestination",u.code)}},"_prepareDestination"),s=c((a,u,l,d)=>{let p;return new Promise((g,h)=>{p=zt(this,"_downloadFIles",h);let _=[];for(let E of l){let b=`${a}/${E.name}`,I=Ns(u,E.name);d?_.push(this.fastGet(b,I,!1)):_.push(this.get(b,I,!1)),this.client.emit("download",{source:b,destination:I})}return g(Promise.all(_))}).finally(()=>{Mt(this,p,"_downloadFiles")})},"_downloadFiles");try{lr(this,"downloadDir");let a=await i(e,n.filter);o(r);let u=a.filter(d=>d.type!=="d");u.length&&await s(e,r,u,n.useFastget);let l=a.filter(d=>d.type==="d");for(let d of l){let p=`${e}/${d.name}`,g=Ns(r,d.name);await this.downloadDir(p,g)}return`${e} downloaded to ${r}`}catch(a){throw a.custom?a:this.fmtError(`${a.message}: ${e}`,"downloadDir",a.code)}}createReadStream(e,r){let n;try{return n=zt(this,"createReadStream"),lr(this,"createReadStream"),this.sftp.createReadStream(e,r)}catch(i){throw i.custom?i:this.fmtError(i.message,"createReadStream",i.code)}finally{Mt(this,n,"createReadStreame")}}createWriteStream(e,r){let n;try{return n=zt(this,"createWriteStream"),lr(this,"createWriteStream"),this.sftp.createWriteStream(e,r)}catch(i){throw i.custom?i:this.fmtError(i.message,"createWriteStream",i.code)}finally{Mt(this,n,"createWriteStream")}}_rcopy(e,r){return new Promise((n,i)=>{let o=this.sftp.createWriteStream(r),s=this.sftp.createReadStream(e);o.on("error",a=>{i(this.fmtError(`${a.message} ${r}`,"_rcopy"))}),s.on("error",a=>{i(this.fmtError(`${a.message} ${e}`,"_rcopy"))}),o.on("close",()=>{n(`${e} copied to ${r}`)}),s.pipe(o)})}async rcopy(e,r){let n;try{n=zt(this,"rcopy"),lr(this,"rcopy");let i=await Os(this,e),o=await this.exists(i);if(!o)throw this.fmtError(`Source does not exist ${i}`,"rcopy",$t.badPath);if(o!=="-")throw this.fmtError(`Source not a file ${i}`,"rcopy",$t.badPath);let s=await Os(this,r);if(await this.exists(s))throw this.fmtError(`Destination already exists ${s}`,"rcopy",$t.badPath);return this._rcopy(i,s)}catch(i){throw i.custom?i:this.fmtError(i,"rcopy")}finally{Mt(this,n,"rcopy")}}end(){let e,r;return new Promise((n,i)=>{r=zt(this,"end",i),this.endCalled=!0,e=c(()=>{this.sftp=void 0,this.debugMsg("end: Connection closed"),n(!0)},"endCloseHandler"),this.on("close",e),this.sftp?this.client.end():(this.debugMsg("end: Called when no connection active"),n(!0))}).finally(()=>{Mt(this,r,"end"),this.removeListener("close",e),this.endCalled=!1})}};uA.exports=id});var xA=le((od,sd)=>{(function(t,e){typeof od=="object"&&typeof sd<"u"?sd.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self).dayjs=e()})(od,(function(){"use strict";var t=1e3,e=6e4,r=36e5,n="millisecond",i="second",o="minute",s="hour",a="day",u="week",l="month",d="quarter",p="year",g="date",h="Invalid Date",_=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,E=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:c(function(L){var T=["th","st","nd","rd"],F=L%100;return"["+L+(T[(F-20)%10]||T[F]||T[0])+"]"},"ordinal")},I=c(function(L,T,F){var j=String(L);return!j||j.length>=T?L:""+Array(T+1-j.length).join(F)+L},"m"),w={s:I,z:c(function(L){var T=-L.utcOffset(),F=Math.abs(T),j=Math.floor(F/60),B=F%60;return(T<=0?"+":"-")+I(j,2,"0")+":"+I(B,2,"0")},"z"),m:c(function L(T,F){if(T.date()<F.date())return-L(F,T);var j=12*(F.year()-T.year())+(F.month()-T.month()),B=T.clone().add(j,l),G=F-B<0,ee=T.clone().add(j+(G?-1:1),l);return+(-(j+(F-B)/(G?B-ee:ee-B))||0)},"t"),a:c(function(L){return L<0?Math.ceil(L)||0:Math.floor(L)},"a"),p:c(function(L){return{M:l,y:p,w:u,d:a,D:g,h:s,m:o,s:i,ms:n,Q:d}[L]||String(L||"").toLowerCase().replace(/s$/,"")},"p"),u:c(function(L){return L===void 0},"u")},H="en",$={};$[H]=b;var X=c(function(L){return L instanceof k},"p"),Z=c(function L(T,F,j){var B;if(!T)return H;if(typeof T=="string"){var G=T.toLowerCase();$[G]&&(B=G),F&&($[G]=F,B=G);var ee=T.split("-");if(!B&&ee.length>1)return L(ee[0])}else{var C=T.name;$[C]=T,B=C}return!j&&B&&(H=B),B||!j&&H},"t"),Y=c(function(L,T){if(X(L))return L.clone();var F=typeof T=="object"?T:{};return F.date=L,F.args=arguments,new k(F)},"w"),P=w;P.l=Z,P.i=X,P.w=function(L,T){return Y(L,{locale:T.$L,utc:T.$u,x:T.$x,$offset:T.$offset})};var k=(function(){function L(F){this.$L=Z(F.locale,null,!0),this.parse(F)}c(L,"M");var T=L.prototype;return T.parse=function(F){this.$d=(function(j){var B=j.date,G=j.utc;if(B===null)return new Date(NaN);if(P.u(B))return new Date;if(B instanceof Date)return new Date(B);if(typeof B=="string"&&!/Z$/i.test(B)){var ee=B.match(_);if(ee){var C=ee[2]-1||0,W=(ee[7]||"0").substring(0,3);return G?new Date(Date.UTC(ee[1],C,ee[3]||1,ee[4]||0,ee[5]||0,ee[6]||0,W)):new Date(ee[1],C,ee[3]||1,ee[4]||0,ee[5]||0,ee[6]||0,W)}}return new Date(B)})(F),this.$x=F.x||{},this.init()},T.init=function(){var F=this.$d;this.$y=F.getFullYear(),this.$M=F.getMonth(),this.$D=F.getDate(),this.$W=F.getDay(),this.$H=F.getHours(),this.$m=F.getMinutes(),this.$s=F.getSeconds(),this.$ms=F.getMilliseconds()},T.$utils=function(){return P},T.isValid=function(){return this.$d.toString()!==h},T.isSame=function(F,j){var B=Y(F);return this.startOf(j)<=B&&B<=this.endOf(j)},T.isAfter=function(F,j){return Y(F)<this.startOf(j)},T.isBefore=function(F,j){return this.endOf(j)<Y(F)},T.$g=function(F,j,B){return P.u(F)?this[j]:this.set(B,F)},T.unix=function(){return Math.floor(this.valueOf()/1e3)},T.valueOf=function(){return this.$d.getTime()},T.startOf=function(F,j){var B=this,G=!!P.u(j)||j,ee=P.p(F),C=c(function(Ct,Xt){var yr=P.w(B.$u?Date.UTC(B.$y,Xt,Ct):new Date(B.$y,Xt,Ct),B);return G?yr:yr.endOf(a)},"l"),W=c(function(Ct,Xt){return P.w(B.toDate()[Ct].apply(B.toDate("s"),(G?[0,0,0,0]:[23,59,59,999]).slice(Xt)),B)},"$"),q=this.$W,J=this.$M,ue=this.$D,me="set"+(this.$u?"UTC":"");switch(ee){case p:return G?C(1,0):C(31,11);case l:return G?C(1,J):C(0,J+1);case u:var he=this.$locale().weekStart||0,bt=(q<he?q+7:q)-he;return C(G?ue-bt:ue+(6-bt),J);case a:case g:return W(me+"Hours",0);case s:return W(me+"Minutes",1);case o:return W(me+"Seconds",2);case i:return W(me+"Milliseconds",3);default:return this.clone()}},T.endOf=function(F){return this.startOf(F,!1)},T.$set=function(F,j){var B,G=P.p(F),ee="set"+(this.$u?"UTC":""),C=(B={},B[a]=ee+"Date",B[g]=ee+"Date",B[l]=ee+"Month",B[p]=ee+"FullYear",B[s]=ee+"Hours",B[o]=ee+"Minutes",B[i]=ee+"Seconds",B[n]=ee+"Milliseconds",B)[G],W=G===a?this.$D+(j-this.$W):j;if(G===l||G===p){var q=this.clone().set(g,1);q.$d[C](W),q.init(),this.$d=q.set(g,Math.min(this.$D,q.daysInMonth())).$d}else C&&this.$d[C](W);return this.init(),this},T.set=function(F,j){return this.clone().$set(F,j)},T.get=function(F){return this[P.p(F)]()},T.add=function(F,j){var B,G=this;F=Number(F);var ee=P.p(j),C=c(function(J){var ue=Y(G);return P.w(ue.date(ue.date()+Math.round(J*F)),G)},"y");if(ee===l)return this.set(l,this.$M+F);if(ee===p)return this.set(p,this.$y+F);if(ee===a)return C(1);if(ee===u)return C(7);var W=(B={},B[o]=e,B[s]=r,B[i]=t,B)[ee]||1,q=this.$d.getTime()+F*W;return P.w(q,this)},T.subtract=function(F,j){return this.add(-1*F,j)},T.format=function(F){var j=this,B=this.$locale();if(!this.isValid())return B.invalidDate||h;var G=F||"YYYY-MM-DDTHH:mm:ssZ",ee=P.z(this),C=this.$H,W=this.$m,q=this.$M,J=B.weekdays,ue=B.months,me=B.meridiem,he=c(function(Xt,yr,Dr,vr){return Xt&&(Xt[yr]||Xt(j,G))||Dr[yr].slice(0,vr)},"h"),bt=c(function(Xt){return P.s(C%12||12,Xt,"0")},"d"),Ct=me||function(Xt,yr,Dr){var vr=Xt<12?"AM":"PM";return Dr?vr.toLowerCase():vr};return G.replace(E,(function(Xt,yr){return yr||(function(Dr){switch(Dr){case"YY":return String(j.$y).slice(-2);case"YYYY":return P.s(j.$y,4,"0");case"M":return q+1;case"MM":return P.s(q+1,2,"0");case"MMM":return he(B.monthsShort,q,ue,3);case"MMMM":return he(ue,q);case"D":return j.$D;case"DD":return P.s(j.$D,2,"0");case"d":return String(j.$W);case"dd":return he(B.weekdaysMin,j.$W,J,2);case"ddd":return he(B.weekdaysShort,j.$W,J,3);case"dddd":return J[j.$W];case"H":return String(C);case"HH":return P.s(C,2,"0");case"h":return bt(1);case"hh":return bt(2);case"a":return Ct(C,W,!0);case"A":return Ct(C,W,!1);case"m":return String(W);case"mm":return P.s(W,2,"0");case"s":return String(j.$s);case"ss":return P.s(j.$s,2,"0");case"SSS":return P.s(j.$ms,3,"0");case"Z":return ee}return null})(Xt)||ee.replace(":","")}))},T.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},T.diff=function(F,j,B){var G,ee=this,C=P.p(j),W=Y(F),q=(W.utcOffset()-this.utcOffset())*e,J=this-W,ue=c(function(){return P.m(ee,W)},"D");switch(C){case p:G=ue()/12;break;case l:G=ue();break;case d:G=ue()/3;break;case u:G=(J-q)/6048e5;break;case a:G=(J-q)/864e5;break;case s:G=J/r;break;case o:G=J/e;break;case i:G=J/t;break;default:G=J}return B?G:P.a(G)},T.daysInMonth=function(){return this.endOf(l).$D},T.$locale=function(){return $[this.$L]},T.locale=function(F,j){if(!F)return this.$L;var B=this.clone(),G=Z(F,j,!0);return G&&(B.$L=G),B},T.clone=function(){return P.w(this.$d,this)},T.toDate=function(){return new Date(this.valueOf())},T.toJSON=function(){return this.isValid()?this.toISOString():null},T.toISOString=function(){return this.$d.toISOString()},T.toString=function(){return this.$d.toUTCString()},L})(),M=k.prototype;return Y.prototype=M,[["$ms",n],["$s",i],["$m",o],["$H",s],["$W",a],["$M",l],["$y",p],["$D",g]].forEach((function(L){M[L[1]]=function(T){return this.$g(T,L[0],L[1])}})),Y.extend=function(L,T){return L.$i||(L(T,k,Y),L.$i=!0),Y},Y.locale=Z,Y.isDayjs=X,Y.unix=function(L){return Y(1e3*L)},Y.en=$[H],Y.Ls=$,Y.p={},Y}))});var S1={};ld(S1,{endClient:()=>Zt,ftpSftp:()=>v1,getClient:()=>Ft,getProtocolBackwardCompatibility:()=>Dt});module.exports=jA(S1);var WA=Object.freeze({status:"aborted"});function xe(t,e,r){function n(a,u){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,u);let l=s.prototype,d=Object.keys(l);for(let p=0;p<d.length;p++){let g=d[p];g in a||(a[g]=l[g].bind(a))}}c(n,"init");let i=r?.Parent??Object;class o extends i{static{c(this,"Definition")}}Object.defineProperty(o,"name",{value:t});function s(a){var u;let l=r?.Parent?new o:this;n(l,a),(u=l._zod).deferred??(u.deferred=[]);for(let d of l._zod.deferred)d();return l}return c(s,"_"),Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:c(a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t),"value")}),Object.defineProperty(s,"name",{value:t}),s}c(xe,"$constructor");var Xr=class extends Error{static{c(this,"$ZodAsyncError")}constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Us=class extends Error{static{c(this,"$ZodEncodeError")}constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}},Rc={};function ln(t){return t&&Object.assign(Rc,t),Rc}c(ln,"config");function Oc(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,i])=>e.indexOf(+n)===-1).map(([n,i])=>i)}c(Oc,"getEnumValues");function pd(t,e){return typeof e=="bigint"?e.toString():e}c(pd,"jsonStringifyReplacer");function zs(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}c(zs,"cached");function hd(t){return t==null}c(hd,"nullish");function Ms(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}c(Ms,"cleanRegex");var dd=Symbol("evaluating");function er(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==dd)return n===void 0&&(n=dd,n=r()),n},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}c(er,"defineLazy");var $c="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Eo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}c(Eo,"isObject");var qA=zs(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function gd(t){if(Eo(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Eo(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}c(gd,"isPlainObject");var md=new Set(["string","number","symbol"]);function Si(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c(Si,"escapeRegex");function Fs(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}c(Fs,"clone");function Rt(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:c(()=>e,"error")};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:c(()=>e.error,"error")}:e}c(Rt,"normalizeParams");function _d(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}c(_d,"optionalKeys");var yd={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function wi(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}c(wi,"aborted");function Sn(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}c(Sn,"prefixIssues");function Ls(t){return typeof t=="string"?t:t?.message}c(Ls,"unwrapMessage");function wn(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let i=Ls(t.inst?._zod.def?.error?.(t))??Ls(e?.error?.(t))??Ls(r.customError?.(t))??Ls(r.localeError?.(t))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}c(wn,"finalizeIssue");function Ad(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}c(Ad,"getLengthableOrigin");function Dc(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}c(Dc,"issue");var Ed=c((t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,pd,2),Object.defineProperty(t,"toString",{value:c(()=>t.message,"value"),enumerable:!1})},"initializer"),bd=xe("$ZodError",Ed),bo=xe("$ZodError",Ed,{Parent:Error});var KA=c(t=>(e,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Xr;if(s.issues.length){let a=new(i?.Err??t)(s.issues.map(u=>wn(u,o,ln())));throw $c(a,i?.callee),a}return s.value},"_parse"),Hs=KA(bo),VA=c(t=>async(e,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(i?.Err??t)(s.issues.map(u=>wn(u,o,ln())));throw $c(a,i?.callee),a}return s.value},"_parseAsync"),js=VA(bo),GA=c(t=>(e,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Xr;return o.issues.length?{success:!1,error:new(t??bd)(o.issues.map(s=>wn(s,i,ln())))}:{success:!0,data:o.value}},"_safeParse"),xo=GA(bo),ZA=c(t=>async(e,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=e._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(s=>wn(s,i,ln())))}:{success:!0,data:o.value}},"_safeParseAsync"),Io=ZA(bo);var YA="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",XA=new RegExp(`^${YA}$`);var xd=c(t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},"string"),Id=/^-?\d+n?$/,vd=/^-?\d+$/,Bc=/^-?\d+(?:\.\d+)?$/,Sd=/^(?:true|false)$/i;var Pn=xe("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),JA={number:"number",bigint:"bigint",object:"date"};var wd=xe("$ZodCheckGreaterThan",(t,e)=>{Pn.init(t,e);let r=JA[typeof e.value];t._zod.onattach.push(n=>{let i=n._zod.bag,o=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}});var Pd=xe("$ZodCheckNumberFormat",(t,e)=>{Pn.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[i,o]=yd[e.format];t._zod.onattach.push(s=>{let a=s._zod.bag;a.format=e.format,a.minimum=i,a.maximum=o,r&&(a.pattern=vd)}),t._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:t,continue:!e.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:t,continue:!e.abort})}});var Td=xe("$ZodCheckMinLength",(t,e)=>{var r;Pn.init(t,e),(r=t._zod.def).when??(r.when=n=>{let i=n.value;return!hd(i)&&i.length!==void 0}),t._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let i=n.value;if(i.length>=e.minimum)return;let s=Ad(i);n.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}});var Uc=xe("$ZodCheckStringFormat",(t,e)=>{var r,n;Pn.init(t,e),t._zod.onattach.push(i=>{let o=i._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),kd=xe("$ZodCheckRegex",(t,e)=>{Uc.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}});var Rd={major:4,minor:3,patch:6};var Kt=xe("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Rd;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let i of n)for(let o of i._zod.onattach)o(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let i=c((s,a,u)=>{let l=wi(s),d;for(let p of a){if(p._zod.def.when){if(!p._zod.def.when(s))continue}else if(l)continue;let g=s.issues.length,h=p._zod.check(s);if(h instanceof Promise&&u?.async===!1)throw new Xr;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,s.issues.length!==g&&(l||(l=wi(s,g)))});else{if(s.issues.length===g)continue;l||(l=wi(s,g))}}return d?d.then(()=>s):s},"runChecks"),o=c((s,a,u)=>{if(wi(s))return s.aborted=!0,s;let l=i(a,n,u);if(l instanceof Promise){if(u.async===!1)throw new Xr;return l.then(d=>t._zod.parse(d,u))}return t._zod.parse(l,u)},"handleCanaryResult");t._zod.run=(s,a)=>{if(a.skipChecks)return t._zod.parse(s,a);if(a.direction==="backward"){let l=t._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(d=>o(d,s,a)):o(l,s,a)}let u=t._zod.parse(s,a);if(u instanceof Promise){if(a.async===!1)throw new Xr;return u.then(l=>i(l,n,a))}return i(u,n,a)}}er(t,"~standard",()=>({validate:c(i=>{try{let o=xo(t,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Io(t,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},"validate"),vendor:"zod",version:1}))}),Qs=xe("$ZodString",(t,e)=>{Kt.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??xd(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),Lc=xe("$ZodStringFormat",(t,e)=>{Uc.init(t,e),Qs.init(t,e)});var Bd=xe("$ZodURL",(t,e)=>{Lc.init(t,e),t._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}});var zc=xe("$ZodNumber",(t,e)=>{Kt.init(t,e),t._zod.pattern=t._zod.bag.pattern??Bc,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...o?{received:o}:{}}),r}}),Ud=xe("$ZodNumberFormat",(t,e)=>{Pd.init(t,e),zc.init(t,e)}),Mc=xe("$ZodBoolean",(t,e)=>{Kt.init(t,e),t._zod.pattern=Sd,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),r}}),Ld=xe("$ZodBigInt",(t,e)=>{Kt.init(t,e),t._zod.pattern=Id,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:t}),r}});var zd=xe("$ZodAny",(t,e)=>{Kt.init(t,e),t._zod.parse=r=>r}),Md=xe("$ZodUnknown",(t,e)=>{Kt.init(t,e),t._zod.parse=r=>r});var Fd=xe("$ZodVoid",(t,e)=>{Kt.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"void",code:"invalid_type",input:i,inst:t}),r}}),Hd=xe("$ZodDate",(t,e)=>{Kt.init(t,e),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:t}),r}});function Nd(t,e,r){t.issues.length&&e.issues.push(...Sn(r,t.issues)),e.value[r]=t.value}c(Nd,"handleArrayResult");var jd=xe("$ZodArray",(t,e)=>{Kt.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let a=i[s],u=e.element._zod.run({value:a,issues:[]},n);u instanceof Promise?o.push(u.then(l=>Nd(l,r,s))):Nd(u,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function qs(t,e,r,n,i){if(t.issues.length){if(i&&!(r in n))return;e.issues.push(...Sn(r,t.issues))}t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}c(qs,"handlePropertyResult");function eE(t){let e=Object.keys(t.shape);for(let n of e)if(!t.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=_d(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}c(eE,"normalizeDef");function tE(t,e,r,n,i,o){let s=[],a=i.keySet,u=i.catchall._zod,l=u.def.type,d=u.optout==="optional";for(let p in e){if(a.has(p))continue;if(l==="never"){s.push(p);continue}let g=u.run({value:e[p],issues:[]},n);g instanceof Promise?t.push(g.then(h=>qs(h,r,p,e,d))):qs(g,r,p,e,d)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:e,inst:o}),t.length?Promise.all(t).then(()=>r):r}c(tE,"handleCatchall");var Wd=xe("$ZodObject",(t,e)=>{if(Kt.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let a=e.shape;Object.defineProperty(e,"shape",{get:c(()=>{let u={...a};return Object.defineProperty(e,"shape",{value:u}),u},"get")})}let n=zs(()=>eE(e));er(t._zod,"propValues",()=>{let a=e.shape,u={};for(let l in a){let d=a[l]._zod;if(d.values){u[l]??(u[l]=new Set);for(let p of d.values)u[l].add(p)}}return u});let i=Eo,o=e.catchall,s;t._zod.parse=(a,u)=>{s??(s=n.value);let l=a.value;if(!i(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:t}),a;a.value={};let d=[],p=s.shape;for(let g of s.keys){let h=p[g],_=h._zod.optout==="optional",E=h._zod.run({value:l[g],issues:[]},u);E instanceof Promise?d.push(E.then(b=>qs(b,a,g,l,_))):qs(E,a,g,l,_)}return o?tE(d,l,a,u,n.value,t):d.length?Promise.all(d).then(()=>a):a}});function Od(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;let i=t.filter(o=>!wi(o));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>wn(s,n,ln())))}),e)}c(Od,"handleUnionResults");var Fc=xe("$ZodUnion",(t,e)=>{Kt.init(t,e),er(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),er(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),er(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),er(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){let i=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Ms(o.source)).join("|")})$`)}});let r=e.options.length===1,n=e.options[0]._zod.run;t._zod.parse=(i,o)=>{if(r)return n(i,o);let s=!1,a=[];for(let u of e.options){let l=u._zod.run({value:i.value,issues:[]},o);if(l instanceof Promise)a.push(l),s=!0;else{if(l.issues.length===0)return l;a.push(l)}}return s?Promise.all(a).then(u=>Od(u,i,t,o)):Od(a,i,t,o)}});var qd=xe("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Fc.init(t,e);let r=t._zod.parse;er(t._zod,"propValues",()=>{let i={};for(let o of e.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let[a,u]of Object.entries(s)){i[a]||(i[a]=new Set);for(let l of u)i[a].add(l)}}return i});let n=zs(()=>{let i=e.options,o=new Map;for(let s of i){let a=s._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let u of a){if(o.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);o.set(u,s)}}return o});t._zod.parse=(i,o)=>{let s=i.value;if(!Eo(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:t}),i;let a=n.value.get(s?.[e.discriminator]);return a?a._zod.run(i,o):e.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:s,path:[e.discriminator],inst:t}),i)}});var Qd=xe("$ZodRecord",(t,e)=>{Kt.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!gd(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),r;let o=[],s=e.keyType._zod.values;if(s){r.value={};let a=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);let d=e.valueType._zod.run({value:i[l],issues:[]},n);d instanceof Promise?o.push(d.then(p=>{p.issues.length&&r.issues.push(...Sn(l,p.issues)),r.value[l]=p.value})):(d.issues.length&&r.issues.push(...Sn(l,d.issues)),r.value[l]=d.value)}let u;for(let l in i)a.has(l)||(u=u??[],u.push(l));u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:u})}else{r.value={};for(let a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let u=e.keyType._zod.run({value:a,issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Bc.test(a)&&u.issues.length){let p=e.keyType._zod.run({value:Number(a),issues:[]},n);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(u=p)}if(u.issues.length){e.mode==="loose"?r.value[a]=i[a]:r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>wn(p,n,ln())),input:a,path:[a],inst:t});continue}let d=e.valueType._zod.run({value:i[a],issues:[]},n);d instanceof Promise?o.push(d.then(p=>{p.issues.length&&r.issues.push(...Sn(a,p.issues)),r.value[u.value]=p.value})):(d.issues.length&&r.issues.push(...Sn(a,d.issues)),r.value[u.value]=d.value)}}return o.length?Promise.all(o).then(()=>r):r}});var Kd=xe("$ZodEnum",(t,e)=>{Kt.init(t,e);let r=Oc(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(i=>md.has(typeof i)).map(i=>typeof i=="string"?Si(i):i.toString()).join("|")})$`),t._zod.parse=(i,o)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:r,input:s,inst:t}),i}}),Vd=xe("$ZodLiteral",(t,e)=>{if(Kt.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Si(n):n?Si(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,i)=>{let o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),n}});var Gd=xe("$ZodTransform",(t,e)=>{Kt.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Us(t.constructor.name);let i=e.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r));if(i instanceof Promise)throw new Xr;return r.value=i,r}});function $d(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}c($d,"handleOptionalResult");var Zd=xe("$ZodOptional",(t,e)=>{Kt.init(t,e),t._zod.optin="optional",t._zod.optout="optional",er(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),er(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ms(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let i=e.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>$d(o,r.value)):$d(i,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}});var Yd=xe("$ZodNullable",(t,e)=>{Kt.init(t,e),er(t._zod,"optin",()=>e.innerType._zod.optin),er(t._zod,"optout",()=>e.innerType._zod.optout),er(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ms(r.source)}|null)$`):void 0}),er(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)});var Xd=xe("$ZodPipe",(t,e)=>{Kt.init(t,e),er(t._zod,"values",()=>e.in._zod.values),er(t._zod,"optin",()=>e.in._zod.optin),er(t._zod,"optout",()=>e.out._zod.optout),er(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let o=e.out._zod.run(r,n);return o instanceof Promise?o.then(s=>Ws(s,e.in,n)):Ws(o,e.in,n)}let i=e.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Ws(o,e.out,n)):Ws(i,e.out,n)}});function Ws(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},r)}c(Ws,"handlePipeResult");var Jd=xe("$ZodCustom",(t,e)=>{Pn.init(t,e),Kt.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,i=e.fn(n);if(i instanceof Promise)return i.then(o=>Dd(o,r,n,t));Dd(i,r,n,t)}});function Dd(t,e,r,n){if(!t){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),e.issues.push(Dc(i))}}c(Dd,"handleRefineResult");var tp;var Hc=class{static{c(this,"$ZodRegistry")}constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function rp(){return new Hc}c(rp,"registry");(tp=globalThis).__zod_globalRegistry??(tp.__zod_globalRegistry=rp());var jc=globalThis.__zod_globalRegistry;function np(t,e){return new t({type:"string",...Rt(e)})}c(np,"_string");function ip(t,e){return new t({type:"string",coerce:!0,...Rt(e)})}c(ip,"_coercedString");function op(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Rt(e)})}c(op,"_url");function sp(t,e){return new t({type:"number",checks:[],...Rt(e)})}c(sp,"_number");function ap(t,e){return new t({type:"number",coerce:!0,checks:[],...Rt(e)})}c(ap,"_coercedNumber");function cp(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Rt(e)})}c(cp,"_int");function up(t,e){return new t({type:"boolean",...Rt(e)})}c(up,"_boolean");function lp(t,e){return new t({type:"boolean",coerce:!0,...Rt(e)})}c(lp,"_coercedBoolean");function fp(t,e){return new t({type:"bigint",coerce:!0,...Rt(e)})}c(fp,"_coercedBigint");function dp(t){return new t({type:"any"})}c(dp,"_any");function pp(t){return new t({type:"unknown"})}c(pp,"_unknown");function hp(t,e){return new t({type:"void",...Rt(e)})}c(hp,"_void");function gp(t,e){return new t({type:"date",coerce:!0,...Rt(e)})}c(gp,"_coercedDate");function Ks(t,e){return new wd({check:"greater_than",...Rt(e),value:t,inclusive:!0})}c(Ks,"_gte");function qr(t,e){return new Td({check:"min_length",...Rt(e),minimum:t})}c(qr,"_minLength");function Tn(t,e){return new kd({check:"string_format",format:"regex",...Rt(e),pattern:t})}c(Tn,"_regex");function mp(t,e,r){let n=Rt(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}c(mp,"_custom");var tr=xe("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");Kt.init(t,e),t.def=e,t.type=e.type,t.parse=(r,n)=>Hs(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>xo(t,r,n),t.parseAsync=async(r,n)=>js(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Io(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),t.with=t.check,t.clone=(r,n)=>Fs(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.apply=r=>r(t)}),Gs=xe("ZodMiniString",(t,e)=>{Qs.init(t,e),tr.init(t,e)});function v(t){return np(Gs,t)}c(v,"string");var _p=xe("ZodMiniStringFormat",(t,e)=>{Lc.init(t,e),Gs.init(t,e)});var hE=xe("ZodMiniURL",(t,e)=>{Bd.init(t,e),_p.init(t,e)});function yp(t){return op(hE,t)}c(yp,"url");var Zs=xe("ZodMiniNumber",(t,e)=>{zc.init(t,e),tr.init(t,e)});function Er(t){return sp(Zs,t)}c(Er,"number");var gE=xe("ZodMiniNumberFormat",(t,e)=>{Ud.init(t,e),Zs.init(t,e)});function Ap(t){return cp(gE,t)}c(Ap,"int");var Wc=xe("ZodMiniBoolean",(t,e)=>{Mc.init(t,e),tr.init(t,e)});function vt(t){return up(Wc,t)}c(vt,"boolean");var Ep=xe("ZodMiniBigInt",(t,e)=>{Ld.init(t,e),tr.init(t,e)});var mE=xe("ZodMiniAny",(t,e)=>{zd.init(t,e),tr.init(t,e)});function So(){return dp(mE)}c(So,"any");var _E=xe("ZodMiniUnknown",(t,e)=>{Md.init(t,e),tr.init(t,e)});function We(){return pp(_E)}c(We,"unknown");var yE=xe("ZodMiniVoid",(t,e)=>{Fd.init(t,e),tr.init(t,e)});function bp(t){return hp(yE,t)}c(bp,"_void");var xp=xe("ZodMiniDate",(t,e)=>{Hd.init(t,e),tr.init(t,e)});var AE=xe("ZodMiniArray",(t,e)=>{jd.init(t,e),tr.init(t,e)});function Xe(t,e){return new AE({type:"array",element:t,...Rt(e)})}c(Xe,"array");var EE=xe("ZodMiniObject",(t,e)=>{Wd.init(t,e),tr.init(t,e),er(t,"shape",()=>e.shape)});function D(t,e){let r={type:"object",shape:t??{},...Rt(e)};return new EE(r)}c(D,"object");var bE=xe("ZodMiniUnion",(t,e)=>{Fc.init(t,e),tr.init(t,e)});function Je(t,e){return new bE({type:"union",options:t,...Rt(e)})}c(Je,"union");var xE=xe("ZodMiniDiscriminatedUnion",(t,e)=>{qd.init(t,e),tr.init(t,e)});function kn(t,e,r){return new xE({type:"union",options:e,discriminator:t,...Rt(r)})}c(kn,"discriminatedUnion");var IE=xe("ZodMiniRecord",(t,e)=>{Qd.init(t,e),tr.init(t,e)});function qe(t,e,r){return new IE({type:"record",keyType:t,valueType:e,...Rt(r)})}c(qe,"record");var vE=xe("ZodMiniEnum",(t,e)=>{Kd.init(t,e),tr.init(t,e),t.options=Object.values(e.entries)});function ot(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new vE({type:"enum",entries:r,...Rt(e)})}c(ot,"_enum");var SE=xe("ZodMiniLiteral",(t,e)=>{Vd.init(t,e),tr.init(t,e)});function Ce(t,e){return new SE({type:"literal",values:Array.isArray(t)?t:[t],...Rt(e)})}c(Ce,"literal");var wE=xe("ZodMiniTransform",(t,e)=>{Gd.init(t,e),tr.init(t,e)});function Cn(t){return new wE({type:"transform",transform:t})}c(Cn,"transform");var PE=xe("ZodMiniOptional",(t,e)=>{Zd.init(t,e),tr.init(t,e)});function oe(t){return new PE({type:"optional",innerType:t})}c(oe,"optional");var TE=xe("ZodMiniNullable",(t,e)=>{Yd.init(t,e),tr.init(t,e)});function wo(t){return new TE({type:"nullable",innerType:t})}c(wo,"nullable");var kE=xe("ZodMiniPipe",(t,e)=>{Xd.init(t,e),tr.init(t,e)});function Rn(t,e){return new kE({type:"pipe",in:t,out:e})}c(Rn,"pipe");var CE=xe("ZodMiniCustom",(t,e)=>{Jd.init(t,e),tr.init(t,e)});function Ys(t,e){return mp(CE,t??(()=>!0),e)}c(Ys,"custom");var Po={};ld(Po,{bigint:()=>BE,boolean:()=>DE,date:()=>UE,number:()=>$E,string:()=>OE});function OE(t){return ip(Gs,t)}c(OE,"string");function $E(t){return ap(Zs,t)}c($E,"number");function DE(t){return lp(Wc,t)}c(DE,"boolean");function BE(t){return fp(Ep,t)}c(BE,"bigint");function UE(t){return gp(xp,t)}c(UE,"date");var Qc=D({retryOnFailure:D({defaultValue:oe(vt()),hide:oe(vt())}),continueOnFailure:D({defaultValue:oe(vt()),hide:oe(vt())})}),qc=class{constructor(e,r,n,i,o,s,a,u,l,d,p){this.name=e;this.displayName=r;this.description=n;this.props=i;this.run=o;this.test=s;this.requireAuth=a;this.errorHandlingOptions=u;this.outputSchema=l;this.audience=d;this.aiMetadata=p}static{c(this,"IAction")}},hr=c(t=>new qc(t.name,t.displayName,t.description,t.props,t.run,t.test??t.run,t.requireAuth??!0,t.errorHandlingOptions??{continueOnFailure:{defaultValue:!1},retryOnFailure:{defaultValue:!1}},t.outputSchema,t.audience,t.aiMetadata),"createAction");var Et=D({displayName:v(),description:oe(v())}),tt=c((t,e)=>D({type:Ce(e),required:vt(),defaultValue:oe(So())}),"TPropertyValue");var Rr=D({...Et.shape,...tt(v(),"SHORT_TEXT").shape}),fn=D({...Et.shape,...tt(v(),"LONG_TEXT").shape});var vp=D({label:v(),value:We()}),Xs=D({disabled:oe(vt()),placeholder:oe(v()),options:Xe(vp)});var Nr=D({...Et.shape,options:Xs,...tt(We(),"STATIC_DROPDOWN").shape}),dn=D({...Et.shape,options:Xs,...tt(Xe(We()),"STATIC_MULTI_SELECT_DROPDOWN").shape});var Kc=D({...Et.shape,...tt(We(),"DROPDOWN").shape,refreshers:Xe(v())}),To=D({...Et.shape,...tt(Xe(We()),"MULTI_SELECT_DROPDOWN").shape,refreshers:Xe(v())});var pn=D({...Et.shape,...tt(vt(),"CHECKBOX").shape});var hn=D({...Et.shape,...tt(Er(),"NUMBER").shape});var ko=D({...Et.shape,...tt(We(),"FILE").shape});var Co=D({...Et.shape,...tt(v(),"DATE_TIME").shape});var Sp=qe(v(),Je([Rr,fn,Nr,To,dn,pn,hn,ko,Co])),Ro=D({...Et.shape,properties:Sp,...tt(Xe(We()),"ARRAY").shape});var No=D({...Et.shape,...tt(Je([qe(v(),We())]),"JSON").shape});var wp=Je([Rr,Nr,No,Ro,dn]),zE=qe(v(),wp),Vc=D({refreshers:Xe(v()),...Et.shape,...tt(We(),"DYNAMIC").shape});var Js=D({...Et.shape,...tt(bp(),"MARKDOWN").shape});var Oo=(r=>(r.ARCHIVE="ARCHIVE",r.REGISTRY="REGISTRY",r))(Oo||{}),Pi=(r=>(r.CUSTOM="CUSTOM",r.OFFICIAL="OFFICIAL",r))(Pi||{}),Ti=(I=>(I.ARTIFICIAL_INTELLIGENCE="ARTIFICIAL_INTELLIGENCE",I.COMMUNICATION="COMMUNICATION",I.COMMERCE="COMMERCE",I.CORE="CORE",I.UNIVERSAL_AI="UNIVERSAL_AI",I.FLOW_CONTROL="FLOW_CONTROL",I.BUSINESS_INTELLIGENCE="BUSINESS_INTELLIGENCE",I.ACCOUNTING="ACCOUNTING",I.PRODUCTIVITY="PRODUCTIVITY",I.CONTENT_AND_FILES="CONTENT_AND_FILES",I.DEVELOPER_TOOLS="DEVELOPER_TOOLS",I.CUSTOMER_SUPPORT="CUSTOMER_SUPPORT",I.FORMS_AND_SURVEYS="FORMS_AND_SURVEYS",I.HUMAN_RESOURCES="HUMAN_RESOURCES",I.PAYMENT_PROCESSING="PAYMENT_PROCESSING",I.MARKETING="MARKETING",I.SALES_AND_CRM="SALES_AND_CRM",I))(Ti||{});var $o=(r=>(r.AUTHORIZATION_CODE="authorization_code",r.CLIENT_CREDENTIALS="client_credentials",r))($o||{}),Gc="both_client_credentials_and_authorization_code";var Nn=(i=>(i.POLLING="POLLING",i.WEBHOOK="WEBHOOK",i.APP_WEBHOOK="APP_WEBHOOK",i.MANUAL="MANUAL",i))(Nn||{}),Do=(o=>(o.NONE="NONE",o.HEADER_PRESENT="HEADER_PRESENT",o.QUERY_PRESENT="QUERY_PRESENT",o.BODY_PARAM_PRESENT="BODY_PARAM_PRESENT",o.HEAD_REQUEST="HEAD_REQUEST",o))(Do||{}),ME=D({strategy:ot(Do),paramName:oe(v())}),Bo=(r=>(r.SIMULATION="SIMULATION",r.TEST_FUNCTION="TEST_FUNCTION",r))(Bo||{});var ea=(r=>(r.WEBSOCKET="WEBSOCKET",r.NONE="NONE",r))(ea||{}),Pp=D({status:oe(Er()),body:oe(We()),headers:oe(qe(v(),v()))}),Tp=D({type:Ce("DELAY"),resumeDateTime:v(),requestIdToReply:oe(v()),handlerId:oe(v()),streamStepProgress:oe(ot(ea))}),kp=D({type:Ce("WEBHOOK"),requestId:v(),requestIdToReply:oe(v()),response:Pp,handlerId:oe(v()),streamStepProgress:oe(ot(ea))}),FE=Je([Tp,kp]);var HE=D({body:We(),rawBody:oe(We()),headers:qe(v(),v()),queryParams:qe(v(),v())});function gr(t){return t==null}c(gr,"isNil");var Zc=Ar(require("crypto"),1);var jE=128,ei,ki,WE=c(t=>{!ei||ei.length<t?(ei=Buffer.allocUnsafe(t*jE),Zc.default.randomFillSync(ei),ki=0):ki+t>ei.length&&(Zc.default.randomFillSync(ei),ki=0),ki+=t},"fillPool"),qE=c(t=>(WE(t|=0),ei.subarray(ki-t,ki)),"random"),QE=c((t,e,r)=>{let n=(2<<31-Math.clz32(t.length-1|1))-1,i=Math.ceil(1.6*n*e/t.length);return(o=e)=>{let s="";for(;;){let a=r(i),u=i;for(;u--;)if(s+=t[a[u]&n]||"",s.length===o)return s}}},"customRandom"),Rp=c((t,e=21)=>QE(t,e,qE),"customAlphabet");var KE="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Np=21,o6=v().check(Tn(new RegExp(`^[0-9a-zA-Z]{${Np}}$`))),VE=Rp(KE,Np);var On=Rn(Cn(t=>t instanceof Date?t.toISOString():t),v()),Ur={id:v(),created:On,updated:On},Ut=c(t=>oe(wo(t)),"Nullable");function Yc(t){return oe(wo(ot(t)))}c(Yc,"NullableEnum");var c6=Rn(Cn(t=>t==="true"||t===!0?!0:t==="false"||t===!1?!1:void 0),oe(vt())),ta=c(t=>Rn(Cn(e=>Array.isArray(e)?e:e!==void 0?[e]:void 0),oe(Xe(t))),"OptionalArrayFromQuery");var f6=qe(v(),We());var Uo=(d=>(d.OPENAI="openai",d.OPENROUTER="openrouter",d.ANTHROPIC="anthropic",d.AZURE="azure",d.GOOGLE="google",d.ACTIVEPIECES="activepieces",d.CLOUDFLARE_GATEWAY="cloudflare-gateway",d.CUSTOM="custom",d.BEDROCK="bedrock",d.MISTRAL="mistral",d))(Uo||{});var I6=v().check(Tn(/^#[0-9A-Fa-f]{6}$/));var S6=D({filename:v(),data:We(),type:Ce("file"),mimetype:oe(v())});var GE=Ar($p());var N6=D({...Ur,name:v(),permissions:Xe(v()),platformId:Ut(v()),type:v(),userCount:oe(Er())});var Dp=(n=>(n.AGENT_DECIDE="agent-decide",n.CHOOSE_YOURSELF="choose-yourself",n.LEAVE_EMPTY="leave-empty",n))(Dp||{}),Xc=(r=>(r.FILE="FILE",r.TABLE="TABLE",r))(Xc||{}),Jc=(n=>(n.SSE="sse",n.STREAMABLE_HTTP="streamable-http",n.SIMPLE_HTTP="http",n))(Jc||{});var eu=(n=>(n.TEXT="text",n.NUMBER="number",n.BOOLEAN="boolean",n))(eu||{});var tu=(r=>(r.IN_PROGRESS="in-progress",r.COMPLETED="completed",r))(tu||{});var ZE=D({mode:ot(Dp),value:We()}),YE=D({auth:oe(v()),fields:qe(v(),ZE)}),XE=D({pieceName:v(),pieceVersion:v(),actionName:v(),predefinedInput:oe(YE)}),JE=D({type:Ce("PIECE"),toolName:v().check(qr(1)),pieceMetadata:XE}),e0=D({type:Ce("none")}),t0=D({type:Ce("access_token"),accessToken:v()}),r0=D({type:Ce("api_key"),apiKey:v(),apiKeyHeader:v()}),n0=D({type:Ce("headers"),headers:qe(v(),v())}),i0=kn("type",[e0,t0,r0,n0]),Bp=D({type:Ce("FLOW"),toolName:v().check(qr(1)),externalFlowId:v(),flowDisplayName:oe(v())}),Up=D({type:Ce("MCP"),toolName:v().check(qr(1)),serverUrl:yp(),protocol:ot(Jc),auth:i0}),Lp=D({type:Ce("KNOWLEDGE_BASE"),toolName:v().check(qr(1)),sourceType:ot(Xc),sourceId:v(),sourceName:v()}),o0=kn("type",[JE,Bp,Up,Lp]),s0=D({displayName:v(),description:oe(v()),type:ot(eu)}),zp=D({type:Ce("MARKDOWN"),markdown:v()}),Ci={type:Ce("TOOL_CALL"),input:Ut(qe(v(),We())),output:oe(We()),toolName:v(),status:ot(tu),toolCallId:v(),startTime:v(),endTime:oe(v())},oB=D(Ci),Mp=kn("toolCallType",[D({...Ci,toolCallType:Ce("PIECE"),pieceName:v(),pieceVersion:v(),actionName:v()}),D({...Ci,toolCallType:Ce("FLOW"),displayName:v(),externalFlowId:v()}),D({...Ci,toolCallType:Ce("MCP"),displayName:v(),serverUrl:v()}),D({...Ci,toolCallType:Ce("KNOWLEDGE_BASE"),displayName:v(),sourceType:v()}),D({...Ci,toolCallType:Ce("UNKNOWN"),displayName:v()})]),a0=Je([zp,Mp]);var ru=(r=>(r.IMAGE="image",r.TEXT="text",r))(ru||{}),gn=D({apiKey:v()}),c0=gn,u0=D({apiKey:v(),apiKeyHash:v()}),l0=gn,f0=gn,d0=gn,p0=gn,h0=gn,g0=gn,m0=gn,Fp=D({accessKeyId:v().check(qr(1)),secretAccessKey:v().check(qr(1))}),_0=D({}),y0=D({}),A0=D({}),E0=D({}),b0=D({}),x0=D({}),Hp=D({modelId:v(),modelName:v(),modelType:ot(ru)}),jp=D({apiKeyHeader:v(),baseUrl:v(),models:Xe(Hp),defaultHeaders:oe(qe(v(),v()))}),Wp=D({accountId:v(),gatewayId:v(),models:Xe(Hp),vertexProject:oe(v()),vertexRegion:oe(v())}),qp=D({resourceName:v(),apiVersion:Rn(Cn(t=>typeof t=="string"&&t.trim().length===0?void 0:t),oe(v()))}),Qp=D({region:v().check(qr(1))}),I0=Je([c0,d0,p0,h0,g0,f0,l0,u0,Fp,m0]),Kp=Je([jp,Wp,qp,Qp,_0,A0,E0,b0,y0,x0]),v0=D({id:v(),name:v(),type:ot(ru)}),S0=D({id:v(),name:v(),provider:ot(Uo),config:Kp,enabledForChat:vt()}),w0=D({provider:ot(Uo),config:Kp,auth:I0,platformId:v()});var uB={openai:"openai",anthropic:"anthropic","google-ai-studio":"google","google-vertex-ai":"google"};var P0=D({base64Url:v(),fileName:v(),extension:oe(v())}),T0=D({mimeType:v(),url:v(),fileName:oe(v())}),nu=Je([P0,T0]);var k0=Je([D({type:Ce("file"),value:nu}),D({type:Ce("markdown"),value:v(),files:oe(Xe(nu))})]),C0=D({sessionId:v(),message:v(),files:oe(Xe(v()))});var Gp=(r=>(r.ON_NEW_RECORD="ON_NEW_RECORD",r.ON_UPDATE_RECORD="ON_UPDATE_RECORD",r))(Gp||{}),Zp=(r=>(r.ENABLED="ENABLED",r.DISABLED="DISABLED",r))(Zp||{}),iu=(n=>(n.RECORD_CREATED="RECORD_CREATED",n.RECORD_UPDATED="RECORD_UPDATED",n.RECORD_DELETED="RECORD_DELETED",n))(iu||{});var R0=Je([D({...Ur,name:v(),externalId:v(),type:Ce("STATIC_DROPDOWN"),tableId:v(),projectId:v(),data:D({options:Xe(D({value:v()}))})}),D({...Ur,name:v(),externalId:v(),type:Je([Ce("TEXT"),Ce("NUMBER"),Ce("DATE")]),tableId:v(),projectId:v()})]),N0=D({...Ur,name:v(),folderId:Ut(v()),projectId:v(),externalId:v(),status:Yc(Zp),trigger:Yc(Gp)}),O0=D({...Ur,tableId:v(),projectId:v(),cells:qe(v(),D({updated:v(),created:v(),value:We(),fieldName:v()}))}),$0=D({events:Xe(ot(iu)),webhookUrl:v(),flowId:v()}),D0=D({fields:Xe(D({id:v(),name:v()})),rows:Xe(qe(v(),v())),name:v()}),B0=D({projectId:v(),limit:oe(Po.number()),cursor:oe(v()),name:oe(v()),externalIds:ta(v()),folderId:oe(v()),folderIds:ta(v())}),U0=D({records:Xe(Xe(D({fieldId:v(),value:Xp()}))),tableId:v()}),L0=D({cells:oe(Xe(D({fieldId:v(),value:Xp()}))),tableId:v(),agentUpdate:oe(vt())}),Yp=kn("operator",[ti("eq"),ti("neq"),ti("gt"),ti("gte"),ti("lt"),ti("lte"),ti("co"),Vp("exists"),Vp("not_exists")]),z0=D({tableId:v(),limit:oe(Po.number()),cursor:oe(v()),filters:ta(Yp)});function Xp(){return Rn(Cn(t=>t==null?t:String(t)),wo(v()))}c(Xp,"coerceToString");function ti(t){return D({fieldId:v(),operator:Ce(t),value:v()})}c(ti,"valueFilter");function Vp(t){return D({fieldId:v(),operator:Ce(t)})}c(Vp,"existenceFilter");var M0=D({status:oe(Er()),body:oe(We()),headers:oe(qe(v(),v()))}),F0=D({...Ur,deleted:Ut(On),ownerId:v(),displayName:v(),platformId:v(),externalId:Ut(v())});var Jp=D({name:v(),description:oe(v()),type:v(),required:vt()}),H0=D({pieceName:v(),triggerName:v(),input:D({toolName:v(),toolDescription:v(),inputSchema:Xe(Jp),returnsResponse:vt()})});var eh="^[0-9]+\\.[0-9]+\\.[0-9]+$",TB=new RegExp(eh),W0="^([~^])?[0-9]+\\.[0-9]+\\.[0-9]+$",kB=v().check(Tn(new RegExp(eh))),CB=v().check(Tn(new RegExp(W0))),q0=D({packageType:Ce("ARCHIVE"),pieceType:ot(Pi),pieceName:v(),pieceVersion:v(),archiveId:v(),platformId:v()}),th=D({packageType:Ce("REGISTRY"),pieceType:Ce("OFFICIAL"),pieceName:v(),pieceVersion:v()}),rh=D({packageType:Ce("REGISTRY"),pieceType:Ce("CUSTOM"),pieceName:v(),pieceVersion:v(),platformId:v()}),RB=Je([th,rh]),NB=Je([q0,th,rh]);var Q0=kn("type",[D({type:Ce("CRON_EXPRESSION"),cronExpression:v(),timezone:v()}),D({type:Ce("INTERVAL"),intervalMs:Ap().check(Ks(6e4))})]),OB=D({...Ur,type:ot(Nn),projectId:v(),flowId:v(),triggerName:v(),schedule:Ut(Q0),flowVersionId:v(),pieceName:v(),pieceVersion:v(),deleted:Ut(v()),simulate:vt()}),nh=(b=>(b.UNKNOWN="UNKNOWN",b.FLOW_RUN_LOG="FLOW_RUN_LOG",b.FLOW_RUN_LOG_SLICE="FLOW_RUN_LOG_SLICE",b.PACKAGE_ARCHIVE="PACKAGE_ARCHIVE",b.FLOW_STEP_FILE="FLOW_STEP_FILE",b.SAMPLE_DATA="SAMPLE_DATA",b.TRIGGER_PAYLOAD="TRIGGER_PAYLOAD",b.SAMPLE_DATA_INPUT="SAMPLE_DATA_INPUT",b.TRIGGER_EVENT_FILE="TRIGGER_EVENT_FILE",b.PROJECT_RELEASE="PROJECT_RELEASE",b.FLOW_VERSION_BACKUP="FLOW_VERSION_BACKUP",b.PLATFORM_ASSET="PLATFORM_ASSET",b.USER_PROFILE_PICTURE="USER_PROFILE_PICTURE",b.WEBHOOK_PAYLOAD="WEBHOOK_PAYLOAD",b.KNOWLEDGE_BASE="KNOWLEDGE_BASE",b.FLOW_BUNDLE="FLOW_BUNDLE",b))(nh||{}),ih=(r=>(r.NONE="NONE",r.ZSTD="ZSTD",r))(ih||{}),oh=(r=>(r.S3="S3",r.DB="DB",r))(oh||{}),$B=D({...Ur,projectId:Ut(v()),platformId:Ut(v()),type:ot(nh),compression:ot(ih),data:oe(We()),location:ot(oh),size:Ut(Er()),fileName:Ut(v()),s3Key:Ut(v()),metadata:Ut(qe(v(),v()))}),sh=(n=>(n.ADMIN="ADMIN",n.MEMBER="MEMBER",n.OPERATOR="OPERATOR",n))(sh||{}),ah=(r=>(r.ACTIVE="ACTIVE",r.INACTIVE="INACTIVE",r))(ah||{}),DB=D({id:v(),email:v(),firstName:v(),status:ot(ah),externalId:Ut(v()),platformId:Ut(v()),platformRole:ot(sh),lastName:v(),created:On,updated:On,lastActiveDate:Ut(On),imageUrl:Ut(v())});var su=D({...Et.shape,...tt(qe(v(),We()),"OBJECT").shape});var lh=D({...Et.shape,...tt(v(),"COLOR").shape});var au=Je([Rr,fn,Js,pn,Nr,dn,Kc,To,Vc,hn,Ro,su,No,Co,ko,lh]),pt={ShortText(t){return{...t,valueSchema:void 0,type:"SHORT_TEXT"}},Checkbox(t){return{...t,valueSchema:void 0,type:"CHECKBOX"}},LongText(t){return{...t,valueSchema:void 0,type:"LONG_TEXT"}},MarkDown(t){return{displayName:"Markdown",required:!1,description:t.value,type:"MARKDOWN",valueSchema:void 0,variant:t.variant??"INFO"}},Number(t){return{...t,valueSchema:void 0,type:"NUMBER"}},Json(t){return{...t,valueSchema:void 0,type:"JSON"}},Array(t){return{...t,valueSchema:void 0,type:"ARRAY"}},Object(t){return{...t,valueSchema:void 0,type:"OBJECT"}},Dropdown(t){return{...t,valueSchema:void 0,type:"DROPDOWN"}},StaticDropdown(t){return{...t,valueSchema:void 0,type:"STATIC_DROPDOWN"}},MultiSelectDropdown(t){return{...t,valueSchema:void 0,type:"MULTI_SELECT_DROPDOWN"}},DynamicProperties(t){return{...t,valueSchema:void 0,type:"DYNAMIC"}},StaticMultiSelectDropdown(t){return{...t,valueSchema:void 0,type:"STATIC_MULTI_SELECT_DROPDOWN"}},DateTime(t){return{...t,valueSchema:void 0,type:"DATE_TIME"}},File(t){return{...t,valueSchema:void 0,type:"FILE"}},Custom(t){let e=t.code.toString();return{...t,code:e,valueSchema:void 0,type:"CUSTOM"}},Color(t){return{...t,valueSchema:void 0,type:"COLOR"}}};var Jr=D({displayName:v(),description:oe(v())});var fh=D({username:v(),password:v()}),cu=D({...Jr.shape,username:D({displayName:v(),description:oe(v())}),password:D({displayName:v(),description:oe(v())}),...tt(fh,"BASIC_AUTH").shape});var Z0=qe(v(),Je([Rr,fn,hn,pn,Nr])),uu=D({...Jr.shape,props:Z0,...tt(We(),"CUSTOM_AUTH").shape});var ri=D({...Jr.shape,...tt(D({auth:v()}),"SECRET_TEXT").shape});var Y0=qe(v(),Je([Rr,fn,ri,hn,pn,Nr,dn,Js])),dh=D({...Jr.shape,props:Y0,...tt(We(),"OIDC").shape});var lu=(r=>(r.HEADER="HEADER",r.BODY="BODY",r))(lu||{}),ph=Je([Rr,ri,Nr]),hh=qe(v(),ph),X0=D({props:oe(qe(v(),ph)),authUrl:v(),tokenUrl:v(),scope:Xe(v()),prompt:oe(Je([Ce("none"),Ce("consent"),Ce("login"),Ce("omit")])),pkce:oe(vt()),pkceMethod:oe(Je([Ce("plain"),Ce("S256")])),authorizationMethod:oe(ot(lu)),grantType:oe(Je([ot($o),Ce(Gc)])),extra:oe(qe(v(),v()))}),gh=D({access_token:v(),props:oe(hh),data:qe(v(),So())}),fu=D({...Jr.shape,...X0.shape,...tt(gh,"OAUTH2").shape});var Ri=Je([cu,uu,dh,fu,ri]),Lo="Connection",zo={SecretText(t){return{...t,valueSchema:void 0,type:"SECRET_TEXT"}},OAuth2(t){return{...t,valueSchema:void 0,type:"OAUTH2",displayName:t.displayName||Lo}},BasicAuth(t){return{...t,valueSchema:void 0,type:"BASIC_AUTH",displayName:t.displayName||Lo,required:!0}},CustomAuth(t){return{...t,valueSchema:void 0,type:"CUSTOM_AUTH",displayName:t.displayName||Lo}},OIDC(t){return{...t,valueSchema:void 0,type:"OIDC",displayName:t.displayName||Lo}},None(){}};var pL={OAUTH2:"OAUTH2",CLOUD_OAUTH2:"OAUTH2",PLATFORM_OAUTH2:"OAUTH2",BASIC_AUTH:"BASIC_AUTH",CUSTOM_AUTH:"CUSTOM_AUTH",OIDC:"OIDC",SECRET_TEXT:"SECRET_TEXT",NO_AUTH:void 0};var J0=D({...Et.shape,...tt(We(),"CUSTOM").shape,code:v()});var tb=Je([au,Ri]),du=qe(v(),tb),OL=qe(v(),au);var mh=Je([D({strategy:Ce("CRON"),cronExpression:v()}),D({strategy:Ce("NONE")})]),Ni=class{constructor(e,r,n,i,o,s,a,u,l,d,p,g,h,_,E,b,I,w,H){this.name=e;this.displayName=r;this.description=n;this.requireAuth=i;this.props=o;this.type=s;this.handshakeConfiguration=a;this.onHandshake=u;this.renewConfiguration=l;this.onRenew=d;this.onEnable=p;this.onDisable=g;this.onStart=h;this.run=_;this.test=E;this.sampleData=b;this.testStrategy=I;this.outputSchema=w;this.aiMetadata=H}static{c(this,"ITrigger")}},_h=c(t=>{switch(t.type){case"WEBHOOK":return new Ni(t.name,t.displayName,t.description,t.requireAuth??!0,t.props,t.type,t.handshakeConfiguration??{strategy:"NONE"},t.onHandshake??(async()=>({status:200})),t.renewConfiguration??{strategy:"NONE"},t.onRenew??(async()=>Promise.resolve()),t.onEnable,t.onDisable,t.onStart??(async()=>Promise.resolve()),t.run,t.test??(()=>Promise.resolve([t.sampleData])),t.sampleData,t.test?"TEST_FUNCTION":"SIMULATION",t.outputSchema,t.aiMetadata);case"POLLING":return new Ni(t.name,t.displayName,t.description,t.requireAuth??!0,t.props,t.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),t.onEnable,t.onDisable,t.onStart??(async()=>Promise.resolve()),t.run,t.test??(()=>Promise.resolve([t.sampleData])),t.sampleData,"TEST_FUNCTION",t.outputSchema,t.aiMetadata);case"MANUAL":return new Ni(t.name,t.displayName,t.description,t.requireAuth??!0,t.props,t.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),t.onEnable,t.onDisable,t.onStart??(async()=>Promise.resolve()),t.run,t.test??(()=>Promise.resolve([t.sampleData])),t.sampleData,"TEST_FUNCTION",t.outputSchema,t.aiMetadata);case"APP_WEBHOOK":return new Ni(t.name,t.displayName,t.description,t.requireAuth??!0,t.props,t.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),t.onEnable,t.onDisable,t.onStart??(async()=>Promise.resolve()),t.run,t.test??(()=>Promise.resolve([t.sampleData])),t.sampleData,gr(t.sampleData)&&gr(t.test)?"SIMULATION":"TEST_FUNCTION",t.outputSchema,t.aiMetadata)}},"createTrigger");var yh="2",na="0.82.0";var pu=class{constructor(e,r,n,i,o,s,a,u,l=na,d,p="",g){this.displayName=e;this.logoUrl=r;this.authors=n;this.events=i;this.categories=a;this.auth=u;this.minimumSupportedRelease=l;this.maximumSupportedRelease=d;this.description=p;this.deprecated=g;this._actions={};this._triggers={};this.getContextInfo=c(()=>({version:yh}),"getContextInfo");(!rb(l)||nb(l,na))&&(this.minimumSupportedRelease=na),o.forEach(h=>this._actions[h.name]=h),s.forEach(h=>this._triggers[h.name]=h)}static{c(this,"Piece")}metadata(){return{displayName:this.displayName,logoUrl:this.logoUrl,actions:this._actions,triggers:this._triggers,categories:this.categories,description:this.description,authors:this.authors,auth:this.auth,minimumSupportedRelease:this.minimumSupportedRelease,maximumSupportedRelease:this.maximumSupportedRelease,deprecated:this.deprecated,contextInfo:this.getContextInfo?.()}}getAction(e){return this._actions[e]}getTrigger(e){return this._triggers[e]}actions(){return this._actions}triggers(){return this._triggers}},Ah=c(t=>{if(t.auth&&Array.isArray(t.auth)&&!t.auth.every((r,n,i)=>n===i.findIndex(o=>o.type===r.type)))throw new Error("Auth properties must be unique by type");return new pu(t.displayName,t.logoUrl,t.authors??[],t.events,t.actions,t.triggers,t.categories??[],t.auth,t.minimumSupportedRelease,t.maximumSupportedRelease,t.description,t.deprecated)},"createPiece");function rb(t){return/^\d+\.\d+\.\d+$/.test(t)}c(rb,"isValidSimpleSemver");function nb(t,e){let[r,n,i]=t.split(".").map(Number),[o,s,a]=e.split(".").map(Number);return r!==o?r<o:n!==s?n<s:i<a}c(nb,"isSemverLessThan");var ib=oe(qe(v(),qe(v(),v()))),Eh=D({id:oe(v()),name:v(),displayName:v(),logoUrl:v(),description:v(),authors:Xe(v()),platformId:oe(v()),directoryPath:oe(v()),auth:oe(Je([Ri,Xe(Ri)])),version:v(),categories:oe(Xe(ot(Ti))),minimumSupportedRelease:oe(v()),maximumSupportedRelease:oe(v()),deprecated:oe(vt()),i18n:ib}),ob=ot(["human","ai","both"]),bh=D({description:oe(v()),idempotent:oe(vt())}),xh=D({name:v(),displayName:v(),description:v(),props:du,requireAuth:vt(),errorHandlingOptions:oe(Qc),outputSchema:oe(Ys()),audience:oe(ob),aiMetadata:oe(bh)}),Ih=D({name:v(),displayName:v(),description:v(),props:du,errorHandlingOptions:oe(Qc),type:ot(Nn),sampleData:We(),handshakeConfiguration:oe(Ys()),renewConfiguration:oe(mh),testStrategy:ot(Bo),outputSchema:oe(Ys()),aiMetadata:oe(bh)}),sb=D({...Eh.shape,actions:qe(v(),xh),triggers:qe(v(),Ih)}),ab=D({...Eh.shape,actions:Er(),triggers:Er(),suggestedActions:oe(Xe(xh)),suggestedTriggers:oe(Xe(Ih))}),vh=D({projectUsage:Er(),pieceType:ot(Pi),packageType:ot(Oo),platformId:oe(v()),archiveId:oe(v())}),Oz=D({...sb.shape,...vh.shape}),$z=D({...ab.shape,...vh.shape}),Dz=D({name:v(),version:v()});var cb=Ar(require("path")),ub=Ar(require("fs/promises"));var pA=Ar(rn());var fA=Ar(lA()),dA=Ar(rn());async function Dt(t){return gr(t)?"sftp":t}c(Dt,"getProtocolBackwardCompatibility");async function Ft(t){let{protocol:e,host:r,port:n,allow_unauthorized_certificates:i,allow_anonymous_login:o,username:s,password:a,privateKey:u,algorithm:l}=t,d=await Dt(e);if(d==="sftp"){let p=new fA.default;if(u){let g=u.replace(/\\r\\n/g,`
23
+ `,{private:a,public:u}}default:throw new Error("Invalid output key format")}}c(w_,"convertKeys");function nw(){}c(nw,"noop");P_.exports={generateKeyPair:c((t,e,r)=>{typeof e=="function"&&(r=e,e=void 0),typeof r!="function"&&(r=nw);let n=S_(t,e);VS(...n,(i,o,s)=>{if(i)return r(i);let a;try{a=w_(n[0],o,s,e)}catch(u){return r(u)}r(null,a)})},"generateKeyPair"),generateKeyPairSync:c((t,e)=>{let r=S_(t,e),{publicKey:n,privateKey:i}=KS(...r);return w_(r[0],n,i,e)},"generateKeyPairSync")}});var C_=le((RF,k_)=>{"use strict";var{AgentProtocol:iw,BaseAgent:ow,createAgent:sw,CygwinAgent:aw,OpenSSHAgent:cw,PageantAgent:uw}=Pl(),{SSHTTPAgent:lw,SSHTTPSAgent:fw}=b_(),{parseKey:dw}=Hn(),{flagsToString:pw,OPEN_MODE:hw,STATUS_CODE:gw,stringToFlags:mw}=ps();k_.exports={AgentProtocol:iw,BaseAgent:ow,createAgent:sw,Client:pf(),CygwinAgent:aw,HTTPAgent:lw,HTTPSAgent:fw,OpenSSHAgent:cw,PageantAgent:uw,Server:I_(),utils:{parseKey:dw,...T_(),sftp:{flagsToString:pw,OPEN_MODE:hw,STATUS_CODE:gw,stringToFlags:mw}}}});var Af=le((NF,R_)=>{R_.exports=require("stream")});var U_=le((OF,B_)=>{"use strict";function N_(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}c(N_,"ownKeys");function O_(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?N_(Object(r),!0).forEach(function(n){_w(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):N_(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}c(O_,"_objectSpread");function _w(t,e,r){return e=D_(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(_w,"_defineProperty");function yw(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}c(yw,"_classCallCheck");function $_(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,D_(n.key),n)}}c($_,"_defineProperties");function Ew(t,e,r){return e&&$_(t.prototype,e),r&&$_(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}c(Ew,"_createClass");function D_(t){var e=Aw(t,"string");return typeof e=="symbol"?e:String(e)}c(D_,"_toPropertyKey");function Aw(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}c(Aw,"_toPrimitive");var bw=require("buffer"),uc=bw.Buffer,xw=require("util"),bf=xw.inspect,Iw=bf&&bf.custom||"inspect";function vw(t,e,r){uc.prototype.copy.call(t,e,r)}c(vw,"copyBuffer");B_.exports=(function(){function t(){yw(this,t),this.head=null,this.tail=null,this.length=0}return c(t,"BufferList"),Ew(t,[{key:"push",value:c(function(r){var n={data:r,next:null};this.length>0?this.tail.next=n:this.head=n,this.tail=n,++this.length},"push")},{key:"unshift",value:c(function(r){var n={data:r,next:this.head};this.length===0&&(this.tail=n),this.head=n,++this.length},"unshift")},{key:"shift",value:c(function(){if(this.length!==0){var r=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,r}},"shift")},{key:"clear",value:c(function(){this.head=this.tail=null,this.length=0},"clear")},{key:"join",value:c(function(r){if(this.length===0)return"";for(var n=this.head,i=""+n.data;n=n.next;)i+=r+n.data;return i},"join")},{key:"concat",value:c(function(r){if(this.length===0)return uc.alloc(0);for(var n=uc.allocUnsafe(r>>>0),i=this.head,o=0;i;)vw(i.data,n,o),o+=i.data.length,i=i.next;return n},"concat")},{key:"consume",value:c(function(r,n){var i;return r<this.head.data.length?(i=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):r===this.head.data.length?i=this.shift():i=n?this._getString(r):this._getBuffer(r),i},"consume")},{key:"first",value:c(function(){return this.head.data},"first")},{key:"_getString",value:c(function(r){var n=this.head,i=1,o=n.data;for(r-=o.length;n=n.next;){var s=n.data,a=r>s.length?s.length:r;if(a===s.length?o+=s:o+=s.slice(0,r),r-=a,r===0){a===s.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(a));break}++i}return this.length-=i,o},"_getString")},{key:"_getBuffer",value:c(function(r){var n=uc.allocUnsafe(r),i=this.head,o=1;for(i.data.copy(n),r-=i.data.length;i=i.next;){var s=i.data,a=r>s.length?s.length:r;if(s.copy(n,n.length-r,0,a),r-=a,r===0){a===s.length?(++o,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=s.slice(a));break}++o}return this.length-=o,n},"_getBuffer")},{key:Iw,value:c(function(r,n){return bf(this,O_(O_({},n),{},{depth:0,customInspect:!1}))},"value")}]),t})()});var If=le((DF,z_)=>{"use strict";function Sw(t,e){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(xf,this,t)):process.nextTick(xf,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(o){!e&&o?r._writableState?r._writableState.errorEmitted?process.nextTick(lc,r):(r._writableState.errorEmitted=!0,process.nextTick(L_,r,o)):process.nextTick(L_,r,o):e?(process.nextTick(lc,r),e(o)):process.nextTick(lc,r)}),this)}c(Sw,"destroy");function L_(t,e){xf(t,e),lc(t)}c(L_,"emitErrorAndCloseNT");function lc(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}c(lc,"emitCloseNT");function ww(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}c(ww,"undestroy");function xf(t,e){t.emit("error",e)}c(xf,"emitErrorNT");function Pw(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}c(Pw,"errorOrDestroy");z_.exports={destroy:Sw,undestroy:ww,errorOrDestroy:Pw}});var Kn=le((UF,H_)=>{"use strict";var F_={};function Hr(t,e,r){r||(r=Error);function n(o,s,a){return typeof e=="string"?e:e(o,s,a)}c(n,"getMessage");class i extends r{static{c(this,"NodeError")}constructor(s,a,u){super(n(s,a,u))}}i.prototype.name=r.name,i.prototype.code=t,F_[t]=i}c(Hr,"createErrorType");function M_(t,e){if(Array.isArray(t)){let r=t.length;return t=t.map(n=>String(n)),r>2?`one of ${e} ${t.slice(0,r-1).join(", ")}, or `+t[r-1]:r===2?`one of ${e} ${t[0]} or ${t[1]}`:`of ${e} ${t[0]}`}else return`of ${e} ${String(t)}`}c(M_,"oneOf");function Tw(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}c(Tw,"startsWith");function kw(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}c(kw,"endsWith");function Cw(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}c(Cw,"includes");Hr("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);Hr("ERR_INVALID_ARG_TYPE",function(t,e,r){let n;typeof e=="string"&&Tw(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";let i;if(kw(t," argument"))i=`The ${t} ${n} ${M_(e,"type")}`;else{let o=Cw(t,".")?"property":"argument";i=`The "${t}" ${o} ${n} ${M_(e,"type")}`}return i+=`. Received type ${typeof r}`,i},TypeError);Hr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Hr("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});Hr("ERR_STREAM_PREMATURE_CLOSE","Premature close");Hr("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});Hr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Hr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Hr("ERR_STREAM_WRITE_AFTER_END","write after end");Hr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Hr("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);Hr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");H_.exports.codes=F_});var vf=le((zF,j_)=>{"use strict";var Rw=Kn().codes.ERR_INVALID_OPT_VALUE;function Nw(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}c(Nw,"highWaterMarkFrom");function Ow(t,e,r,n){var i=Nw(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new Rw(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}c(Ow,"getHighWaterMark");j_.exports={getHighWaterMark:Ow}});var W_=le((FF,Sf)=>{typeof Object.create=="function"?Sf.exports=c(function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))},"inherits"):Sf.exports=c(function(e,r){if(r){e.super_=r;var n=c(function(){},"TempCtor");n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}},"inherits")});var di=le((jF,Pf)=>{try{if(wf=require("util"),typeof wf.inherits!="function")throw"";Pf.exports=wf.inherits}catch{Pf.exports=W_()}var wf});var Q_=le((WF,q_)=>{q_.exports=require("util").deprecate});var Cf=le((qF,X_)=>{"use strict";X_.exports=Gt;function K_(t){var e=this;this.next=null,this.entry=null,this.finish=function(){sP(e,t)}}c(K_,"CorkedRequest");var uo;Gt.WritableState=Is;var $w={deprecate:Q_()},G_=Af(),dc=require("buffer").Buffer,Dw=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function Bw(t){return dc.from(t)}c(Bw,"_uint8ArrayToBuffer");function Uw(t){return dc.isBuffer(t)||t instanceof Dw}c(Uw,"_isUint8Array");var kf=If(),Lw=vf(),zw=Lw.getHighWaterMark,Gn=Kn().codes,Mw=Gn.ERR_INVALID_ARG_TYPE,Fw=Gn.ERR_METHOD_NOT_IMPLEMENTED,Hw=Gn.ERR_MULTIPLE_CALLBACK,jw=Gn.ERR_STREAM_CANNOT_PIPE,Ww=Gn.ERR_STREAM_DESTROYED,qw=Gn.ERR_STREAM_NULL_VALUES,Qw=Gn.ERR_STREAM_WRITE_AFTER_END,Vw=Gn.ERR_UNKNOWN_ENCODING,lo=kf.errorOrDestroy;di()(Gt,G_);function Kw(){}c(Kw,"nop");function Is(t,e,r){uo=uo||pi(),t=t||{},typeof r!="boolean"&&(r=e instanceof uo),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=zw(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=t.decodeStrings===!1;this.decodeStrings=!n,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(i){tP(e,i)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new K_(this)}c(Is,"WritableState");Is.prototype.getBuffer=c(function(){for(var e=this.bufferedRequest,r=[];e;)r.push(e),e=e.next;return r},"getBuffer");(function(){try{Object.defineProperty(Is.prototype,"buffer",{get:$w.deprecate(c(function(){return this.getBuffer()},"writableStateBufferGetter"),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var fc;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(fc=Function.prototype[Symbol.hasInstance],Object.defineProperty(Gt,Symbol.hasInstance,{value:c(function(e){return fc.call(this,e)?!0:this!==Gt?!1:e&&e._writableState instanceof Is},"value")})):fc=c(function(e){return e instanceof this},"realHasInstance");function Gt(t){uo=uo||pi();var e=this instanceof uo;if(!e&&!fc.call(Gt,this))return new Gt(t);this._writableState=new Is(t,this,e),this.writable=!0,t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final)),G_.call(this)}c(Gt,"Writable");Gt.prototype.pipe=function(){lo(this,new jw)};function Gw(t,e){var r=new Qw;lo(t,r),process.nextTick(e,r)}c(Gw,"writeAfterEnd");function Zw(t,e,r,n){var i;return r===null?i=new qw:typeof r!="string"&&!e.objectMode&&(i=new Mw("chunk",["string","Buffer"],r)),i?(lo(t,i),process.nextTick(n,i),!1):!0}c(Zw,"validChunk");Gt.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&Uw(t);return o&&!dc.isBuffer(t)&&(t=Bw(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=Kw),n.ending?Gw(this,r):(o||Zw(this,n,t,r))&&(n.pendingcb++,i=Xw(this,n,o,t,e,r)),i};Gt.prototype.cork=function(){this._writableState.corked++};Gt.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,!t.writing&&!t.corked&&!t.bufferProcessing&&t.bufferedRequest&&Z_(this,t))};Gt.prototype.setDefaultEncoding=c(function(e){if(typeof e=="string"&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new Vw(e);return this._writableState.defaultEncoding=e,this},"setDefaultEncoding");Object.defineProperty(Gt.prototype,"writableBuffer",{enumerable:!1,get:c(function(){return this._writableState&&this._writableState.getBuffer()},"get")});function Yw(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=dc.from(e,r)),e}c(Yw,"decodeChunk");Object.defineProperty(Gt.prototype,"writableHighWaterMark",{enumerable:!1,get:c(function(){return this._writableState.highWaterMark},"get")});function Xw(t,e,r,n,i,o){if(!r){var s=Yw(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else Tf(t,e,!1,a,n,i,o);return u}c(Xw,"writeOrBuffer");function Tf(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new Ww("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}c(Tf,"doWrite");function Jw(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(xs,t,e),t._writableState.errorEmitted=!0,lo(t,n)):(i(n),t._writableState.errorEmitted=!0,lo(t,n),xs(t,e))}c(Jw,"onwriteError");function eP(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}c(eP,"onwriteStateUpdate");function tP(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new Hw;if(eP(r),e)Jw(t,r,n,e,i);else{var o=Y_(r)||t.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&Z_(t,r),n?process.nextTick(V_,t,r,o,i):V_(t,r,o,i)}}c(tP,"onwrite");function V_(t,e,r,n){r||rP(t,e),e.pendingcb--,n(),xs(t,e)}c(V_,"afterWrite");function rP(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}c(rP,"onwriteDrain");function Z_(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)i[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;i.allBuffers=a,Tf(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new K_(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,d=r.callback,p=e.objectMode?1:u.length;if(Tf(t,e,!1,p,u,l,d),r=r.next,e.bufferedRequestCount--,e.writing)break}r===null&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}c(Z_,"clearBuffer");Gt.prototype._write=function(t,e,r){r(new Fw("_write()"))};Gt.prototype._writev=null;Gt.prototype.end=function(t,e,r){var n=this._writableState;return typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null),t!=null&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||oP(this,n,r),this};Object.defineProperty(Gt.prototype,"writableLength",{enumerable:!1,get:c(function(){return this._writableState.length},"get")});function Y_(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}c(Y_,"needFinish");function nP(t,e){t._final(function(r){e.pendingcb--,r&&lo(t,r),e.prefinished=!0,t.emit("prefinish"),xs(t,e)})}c(nP,"callFinal");function iP(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(nP,t,e)):(e.prefinished=!0,t.emit("prefinish")))}c(iP,"prefinish");function xs(t,e){var r=Y_(e);if(r&&(iP(t,e),e.pendingcb===0&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}c(xs,"finishMaybe");function oP(t,e,r){e.ending=!0,xs(t,e),r&&(e.finished?process.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}c(oP,"endWritable");function sP(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}c(sP,"onCorkedFinish");Object.defineProperty(Gt.prototype,"destroyed",{enumerable:!1,get:c(function(){return this._writableState===void 0?!1:this._writableState.destroyed},"get"),set:c(function(e){this._writableState&&(this._writableState.destroyed=e)},"set")});Gt.prototype.destroy=kf.destroy;Gt.prototype._undestroy=kf.undestroy;Gt.prototype._destroy=function(t,e){e(t)}});var pi=le((VF,ey)=>{"use strict";var aP=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};ey.exports=cn;var J_=Of(),Nf=Cf();di()(cn,J_);for(Rf=aP(Nf.prototype),pc=0;pc<Rf.length;pc++)hc=Rf[pc],cn.prototype[hc]||(cn.prototype[hc]=Nf.prototype[hc]);var Rf,hc,pc;function cn(t){if(!(this instanceof cn))return new cn(t);J_.call(this,t),Nf.call(this,t),this.allowHalfOpen=!0,t&&(t.readable===!1&&(this.readable=!1),t.writable===!1&&(this.writable=!1),t.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",cP)))}c(cn,"Duplex");Object.defineProperty(cn.prototype,"writableHighWaterMark",{enumerable:!1,get:c(function(){return this._writableState.highWaterMark},"get")});Object.defineProperty(cn.prototype,"writableBuffer",{enumerable:!1,get:c(function(){return this._writableState&&this._writableState.getBuffer()},"get")});Object.defineProperty(cn.prototype,"writableLength",{enumerable:!1,get:c(function(){return this._writableState.length},"get")});function cP(){this._writableState.ended||process.nextTick(uP,this)}c(cP,"onend");function uP(t){t.end()}c(uP,"onEndNT");Object.defineProperty(cn.prototype,"destroyed",{enumerable:!1,get:c(function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},"get"),set:c(function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)},"set")})});var ny=le(($f,ry)=>{var gc=require("buffer"),un=gc.Buffer;function ty(t,e){for(var r in t)e[r]=t[r]}c(ty,"copyProps");un.from&&un.alloc&&un.allocUnsafe&&un.allocUnsafeSlow?ry.exports=gc:(ty(gc,$f),$f.Buffer=hi);function hi(t,e,r){return un(t,e,r)}c(hi,"SafeBuffer");hi.prototype=Object.create(un.prototype);ty(un,hi);hi.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return un(t,e,r)};hi.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=un(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};hi.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return un(t)};hi.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return gc.SlowBuffer(t)}});var Uf=le(oy=>{"use strict";var Bf=ny().Buffer,iy=Bf.isEncoding||function(t){switch(t=""+t,t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function lP(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}c(lP,"_normalizeEncoding");function fP(t){var e=lP(t);if(typeof e!="string"&&(Bf.isEncoding===iy||!iy(t)))throw new Error("Unknown encoding: "+t);return e||t}c(fP,"normalizeEncoding");oy.StringDecoder=vs;function vs(t){this.encoding=fP(t);var e;switch(this.encoding){case"utf16le":this.text=_P,this.end=yP,e=4;break;case"utf8":this.fillLast=hP,e=4;break;case"base64":this.text=EP,this.end=AP,e=3;break;default:this.write=bP,this.end=xP;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Bf.allocUnsafe(e)}c(vs,"StringDecoder");vs.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""};vs.prototype.end=mP;vs.prototype.text=gP;vs.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function Df(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}c(Df,"utf8CheckByte");function dP(t,e,r){var n=e.length-1;if(n<r)return 0;var i=Df(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=Df(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=Df(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}c(dP,"utf8CheckIncomplete");function pP(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}c(pP,"utf8CheckExtraBytes");function hP(t){var e=this.lastTotal-this.lastNeed,r=pP(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}c(hP,"utf8FillLast");function gP(t,e){var r=dP(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}c(gP,"utf8Text");function mP(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}c(mP,"utf8End");function _P(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}c(_P,"utf16Text");function yP(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}c(yP,"utf16End");function EP(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}c(EP,"base64Text");function AP(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}c(AP,"base64End");function bP(t){return t.toString(this.encoding)}c(bP,"simpleWrite");function xP(t){return t&&t.length?this.write(t):""}c(xP,"simpleEnd")});var mc=le((XF,cy)=>{"use strict";var sy=Kn().codes.ERR_STREAM_PREMATURE_CLOSE;function IP(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}c(IP,"once");function vP(){}c(vP,"noop");function SP(t){return t.setHeader&&typeof t.abort=="function"}c(SP,"isRequest");function ay(t,e,r){if(typeof e=="function")return ay(t,null,e);e||(e={}),r=IP(r||vP);var n=e.readable||e.readable!==!1&&t.readable,i=e.writable||e.writable!==!1&&t.writable,o=c(function(){t.writable||a()},"onlegacyfinish"),s=t._writableState&&t._writableState.finished,a=c(function(){i=!1,s=!0,n||r.call(t)},"onfinish"),u=t._readableState&&t._readableState.endEmitted,l=c(function(){n=!1,u=!0,i||r.call(t)},"onend"),d=c(function(_){r.call(t,_)},"onerror"),p=c(function(){var _;if(n&&!u)return(!t._readableState||!t._readableState.ended)&&(_=new sy),r.call(t,_);if(i&&!s)return(!t._writableState||!t._writableState.ended)&&(_=new sy),r.call(t,_)},"onclose"),g=c(function(){t.req.on("finish",a)},"onrequest");return SP(t)?(t.on("complete",a),t.on("abort",p),t.req?g():t.on("request",g)):i&&!t._writableState&&(t.on("end",o),t.on("close",o)),t.on("end",l),t.on("finish",a),e.error!==!1&&t.on("error",d),t.on("close",p),function(){t.removeListener("complete",a),t.removeListener("abort",p),t.removeListener("request",g),t.req&&t.req.removeListener("finish",a),t.removeListener("end",o),t.removeListener("close",o),t.removeListener("finish",a),t.removeListener("end",l),t.removeListener("error",d),t.removeListener("close",p)}}c(ay,"eos");cy.exports=ay});var ly=le((e5,uy)=>{"use strict";var _c;function Zn(t,e,r){return e=wP(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(Zn,"_defineProperty");function wP(t){var e=PP(t,"string");return typeof e=="symbol"?e:String(e)}c(wP,"_toPropertyKey");function PP(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}c(PP,"_toPrimitive");var TP=mc(),Yn=Symbol("lastResolve"),gi=Symbol("lastReject"),Ss=Symbol("error"),yc=Symbol("ended"),mi=Symbol("lastPromise"),Lf=Symbol("handlePromise"),_i=Symbol("stream");function Xn(t,e){return{value:t,done:e}}c(Xn,"createIterResult");function kP(t){var e=t[Yn];if(e!==null){var r=t[_i].read();r!==null&&(t[mi]=null,t[Yn]=null,t[gi]=null,e(Xn(r,!1)))}}c(kP,"readAndResolve");function CP(t){process.nextTick(kP,t)}c(CP,"onReadable");function RP(t,e){return function(r,n){t.then(function(){if(e[yc]){r(Xn(void 0,!0));return}e[Lf](r,n)},n)}}c(RP,"wrapForNext");var NP=Object.getPrototypeOf(function(){}),OP=Object.setPrototypeOf((_c={get stream(){return this[_i]},next:c(function(){var e=this,r=this[Ss];if(r!==null)return Promise.reject(r);if(this[yc])return Promise.resolve(Xn(void 0,!0));if(this[_i].destroyed)return new Promise(function(s,a){process.nextTick(function(){e[Ss]?a(e[Ss]):s(Xn(void 0,!0))})});var n=this[mi],i;if(n)i=new Promise(RP(n,this));else{var o=this[_i].read();if(o!==null)return Promise.resolve(Xn(o,!1));i=new Promise(this[Lf])}return this[mi]=i,i},"next")},Zn(_c,Symbol.asyncIterator,function(){return this}),Zn(_c,"return",c(function(){var e=this;return new Promise(function(r,n){e[_i].destroy(null,function(i){if(i){n(i);return}r(Xn(void 0,!0))})})},"_return")),_c),NP),$P=c(function(e){var r,n=Object.create(OP,(r={},Zn(r,_i,{value:e,writable:!0}),Zn(r,Yn,{value:null,writable:!0}),Zn(r,gi,{value:null,writable:!0}),Zn(r,Ss,{value:null,writable:!0}),Zn(r,yc,{value:e._readableState.endEmitted,writable:!0}),Zn(r,Lf,{value:c(function(o,s){var a=n[_i].read();a?(n[mi]=null,n[Yn]=null,n[gi]=null,o(Xn(a,!1))):(n[Yn]=o,n[gi]=s)},"value"),writable:!0}),r));return n[mi]=null,TP(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[gi];o!==null&&(n[mi]=null,n[Yn]=null,n[gi]=null,o(i)),n[Ss]=i;return}var s=n[Yn];s!==null&&(n[mi]=null,n[Yn]=null,n[gi]=null,s(Xn(void 0,!0))),n[yc]=!0}),e.on("readable",CP.bind(null,n)),n},"createReadableStreamAsyncIterator");uy.exports=$P});var hy=le((r5,py)=>{"use strict";function fy(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(l){r(l);return}a.done?e(u):Promise.resolve(u).then(n,i)}c(fy,"asyncGeneratorStep");function DP(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function s(u){fy(o,n,i,s,a,"next",u)}c(s,"_next");function a(u){fy(o,n,i,s,a,"throw",u)}c(a,"_throw"),s(void 0)})}}c(DP,"_asyncToGenerator");function dy(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}c(dy,"ownKeys");function BP(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?dy(Object(r),!0).forEach(function(n){UP(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):dy(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}c(BP,"_objectSpread");function UP(t,e,r){return e=LP(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(UP,"_defineProperty");function LP(t){var e=zP(t,"string");return typeof e=="symbol"?e:String(e)}c(LP,"_toPropertyKey");function zP(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}c(zP,"_toPrimitive");var MP=Kn().codes.ERR_INVALID_ARG_TYPE;function FP(t,e,r){var n;if(e&&typeof e.next=="function")n=e;else if(e&&e[Symbol.asyncIterator])n=e[Symbol.asyncIterator]();else if(e&&e[Symbol.iterator])n=e[Symbol.iterator]();else throw new MP("iterable",["Iterable"],e);var i=new t(BP({objectMode:!0},r)),o=!1;i._read=function(){o||(o=!0,s())};function s(){return a.apply(this,arguments)}c(s,"next");function a(){return a=DP(function*(){try{var u=yield n.next(),l=u.value,d=u.done;d?i.push(null):i.push(yield l)?s():o=!1}catch(p){i.destroy(p)}}),a.apply(this,arguments)}return c(a,"_next2"),i}c(FP,"from");py.exports=FP});var Of=le((o5,vy)=>{"use strict";vy.exports=Et;var fo;Et.ReadableState=yy;var i5=require("events").EventEmitter,_y=c(function(e,r){return e.listeners(r).length},"EElistenerCount"),Ps=Af(),Ec=require("buffer").Buffer,HP=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function jP(t){return Ec.from(t)}c(jP,"_uint8ArrayToBuffer");function WP(t){return Ec.isBuffer(t)||t instanceof HP}c(WP,"_isUint8Array");var zf=require("util"),ct;zf&&zf.debuglog?ct=zf.debuglog("stream"):ct=c(function(){},"debug");var qP=U_(),Qf=If(),QP=vf(),VP=QP.getHighWaterMark,Ac=Kn().codes,KP=Ac.ERR_INVALID_ARG_TYPE,GP=Ac.ERR_STREAM_PUSH_AFTER_EOF,ZP=Ac.ERR_METHOD_NOT_IMPLEMENTED,YP=Ac.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,po,Mf,Ff;di()(Et,Ps);var ws=Qf.errorOrDestroy,Hf=["error","close","destroy","pause","resume"];function XP(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}c(XP,"prependListener");function yy(t,e,r){fo=fo||pi(),t=t||{},typeof r!="boolean"&&(r=e instanceof fo),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=VP(this,t,"readableHighWaterMark",r),this.buffer=new qP,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=t.emitClose!==!1,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(po||(po=Uf().StringDecoder),this.decoder=new po(t.encoding),this.encoding=t.encoding)}c(yy,"ReadableState");function Et(t){if(fo=fo||pi(),!(this instanceof Et))return new Et(t);var e=this instanceof fo;this._readableState=new yy(t,this,e),this.readable=!0,t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy)),Ps.call(this)}c(Et,"Readable");Object.defineProperty(Et.prototype,"destroyed",{enumerable:!1,get:c(function(){return this._readableState===void 0?!1:this._readableState.destroyed},"get"),set:c(function(e){this._readableState&&(this._readableState.destroyed=e)},"set")});Et.prototype.destroy=Qf.destroy;Et.prototype._undestroy=Qf.undestroy;Et.prototype._destroy=function(t,e){e(t)};Et.prototype.push=function(t,e){var r=this._readableState,n;return r.objectMode?n=!0:typeof t=="string"&&(e=e||r.defaultEncoding,e!==r.encoding&&(t=Ec.from(t,e),e=""),n=!0),Ey(this,t,e,!1,n)};Et.prototype.unshift=function(t){return Ey(this,t,null,!0,!1)};function Ey(t,e,r,n,i){ct("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,tT(t,o);else{var s;if(i||(s=JP(o,e)),s)ws(t,s);else if(o.objectMode||e&&e.length>0)if(typeof e!="string"&&!o.objectMode&&Object.getPrototypeOf(e)!==Ec.prototype&&(e=jP(e)),n)o.endEmitted?ws(t,new YP):jf(t,o,e,!0);else if(o.ended)ws(t,new GP);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?jf(t,o,e,!1):qf(t,o)):jf(t,o,e,!1)}else n||(o.reading=!1,qf(t,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}c(Ey,"readableAddChunk");function jf(t,e,r,n){e.flowing&&e.length===0&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&bc(t)),qf(t,e)}c(jf,"addChunk");function JP(t,e){var r;return!WP(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new KP("chunk",["string","Buffer","Uint8Array"],e)),r}c(JP,"chunkInvalid");Et.prototype.isPaused=function(){return this._readableState.flowing===!1};Et.prototype.setEncoding=function(t){po||(po=Uf().StringDecoder);var e=new po(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";r!==null;)n+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),n!==""&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var gy=1073741824;function eT(t){return t>=gy?t=gy:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}c(eT,"computeNewHighWaterMark");function my(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=eT(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}c(my,"howMuchToRead");Et.prototype.read=function(t){ct("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return ct("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?Wf(this):bc(this),null;if(t=my(t,e),t===0&&e.ended)return e.length===0&&Wf(this),null;var n=e.needReadable;ct("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,ct("length less than watermark",n)),e.ended||e.reading?(n=!1,ct("reading or ended",n)):n&&(ct("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=my(r,e)));var i;return t>0?i=xy(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&Wf(this)),i!==null&&this.emit("data",i),i};function tT(t,e){if(ct("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?bc(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,Ay(t)))}}c(tT,"onEofChunk");function bc(t){var e=t._readableState;ct("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(ct("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(Ay,t))}c(bc,"emitReadable");function Ay(t){var e=t._readableState;ct("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Vf(t)}c(Ay,"emitReadable_");function qf(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(rT,t,e))}c(qf,"maybeReadMore");function rT(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){var r=e.length;if(ct("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}c(rT,"maybeReadMore_");Et.prototype._read=function(t){ws(this,new ZP("_read()"))};Et.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t);break}n.pipesCount+=1,ct("pipe count=%d opts=%j",n.pipesCount,e);var i=(!e||e.end!==!1)&&t!==process.stdout&&t!==process.stderr,o=i?a:A;n.endEmitted?process.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(b,I){ct("onunpipe"),b===r&&I&&I.hasUnpiped===!1&&(I.hasUnpiped=!0,d())}c(s,"onunpipe");function a(){ct("onend"),t.end()}c(a,"onend");var u=nT(r);t.on("drain",u);var l=!1;function d(){ct("cleanup"),t.removeListener("close",h),t.removeListener("finish",_),t.removeListener("drain",u),t.removeListener("error",g),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",A),r.removeListener("data",p),l=!0,n.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&u()}c(d,"cleanup"),r.on("data",p);function p(b){ct("ondata");var I=t.write(b);ct("dest.write",I),I===!1&&((n.pipesCount===1&&n.pipes===t||n.pipesCount>1&&Iy(n.pipes,t)!==-1)&&!l&&(ct("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}c(p,"ondata");function g(b){ct("onerror",b),A(),t.removeListener("error",g),_y(t,"error")===0&&ws(t,b)}c(g,"onerror"),XP(t,"error",g);function h(){t.removeListener("finish",_),A()}c(h,"onclose"),t.once("close",h);function _(){ct("onfinish"),t.removeListener("close",h),A()}c(_,"onfinish"),t.once("finish",_);function A(){ct("unpipe"),r.unpipe(t)}return c(A,"unpipe"),t.emit("pipe",r),n.flowing||(ct("pipe resume"),r.resume()),t};function nT(t){return c(function(){var r=t._readableState;ct("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&_y(t,"data")&&(r.flowing=!0,Vf(t))},"pipeOnDrainFunctionResult")}c(nT,"pipeOnDrain");Et.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(e.pipesCount===0)return this;if(e.pipesCount===1)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=Iy(e.pipes,t);return s===-1?this:(e.pipes.splice(s,1),e.pipesCount-=1,e.pipesCount===1&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r),this)};Et.prototype.on=function(t,e){var r=Ps.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,ct("on readable",n.length,n.reading),n.length?bc(this):n.reading||process.nextTick(iT,this)),r};Et.prototype.addListener=Et.prototype.on;Et.prototype.removeListener=function(t,e){var r=Ps.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick(by,this),r};Et.prototype.removeAllListeners=function(t){var e=Ps.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick(by,this),e};function by(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}c(by,"updateReadableListening");function iT(t){ct("readable nexttick read 0"),t.read(0)}c(iT,"nReadingNextTick");Et.prototype.resume=function(){var t=this._readableState;return t.flowing||(ct("resume"),t.flowing=!t.readableListening,oT(this,t)),t.paused=!1,this};function oT(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(sT,t,e))}c(oT,"resume");function sT(t,e){ct("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Vf(t),e.flowing&&!e.reading&&t.read(0)}c(sT,"resume_");Et.prototype.pause=function(){return ct("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ct("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Vf(t){var e=t._readableState;for(ct("flow",e.flowing);e.flowing&&t.read()!==null;);}c(Vf,"flow");Et.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;t.on("end",function(){if(ct("wrapped end"),r.decoder&&!r.ended){var s=r.decoder.end();s&&s.length&&e.push(s)}e.push(null)}),t.on("data",function(s){if(ct("wrapped data"),r.decoder&&(s=r.decoder.write(s)),!(r.objectMode&&s==null)&&!(!r.objectMode&&(!s||!s.length))){var a=e.push(s);a||(n=!0,t.pause())}});for(var i in t)this[i]===void 0&&typeof t[i]=="function"&&(this[i]=c(function(a){return c(function(){return t[a].apply(t,arguments)},"methodWrapReturnFunction")},"methodWrap")(i));for(var o=0;o<Hf.length;o++)t.on(Hf[o],this.emit.bind(this,Hf[o]));return this._read=function(s){ct("wrapped _read",s),n&&(n=!1,t.resume())},this};typeof Symbol=="function"&&(Et.prototype[Symbol.asyncIterator]=function(){return Mf===void 0&&(Mf=ly()),Mf(this)});Object.defineProperty(Et.prototype,"readableHighWaterMark",{enumerable:!1,get:c(function(){return this._readableState.highWaterMark},"get")});Object.defineProperty(Et.prototype,"readableBuffer",{enumerable:!1,get:c(function(){return this._readableState&&this._readableState.buffer},"get")});Object.defineProperty(Et.prototype,"readableFlowing",{enumerable:!1,get:c(function(){return this._readableState.flowing},"get"),set:c(function(e){this._readableState&&(this._readableState.flowing=e)},"set")});Et._fromList=xy;Object.defineProperty(Et.prototype,"readableLength",{enumerable:!1,get:c(function(){return this._readableState.length},"get")});function xy(t,e){if(e.length===0)return null;var r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}c(xy,"fromList");function Wf(t){var e=t._readableState;ct("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(aT,e,t))}c(Wf,"endReadable");function aT(t,e){if(ct("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&t.length===0&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}c(aT,"endReadableNT");typeof Symbol=="function"&&(Et.from=function(t,e){return Ff===void 0&&(Ff=hy()),Ff(Et,t,e)});function Iy(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}c(Iy,"indexOf")});var Kf=le((a5,wy)=>{"use strict";wy.exports=Sn;var xc=Kn().codes,cT=xc.ERR_METHOD_NOT_IMPLEMENTED,uT=xc.ERR_MULTIPLE_CALLBACK,lT=xc.ERR_TRANSFORM_ALREADY_TRANSFORMING,fT=xc.ERR_TRANSFORM_WITH_LENGTH_0,Ic=pi();di()(Sn,Ic);function dT(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new uT);r.writechunk=null,r.writecb=null,e!=null&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}c(dT,"afterTransform");function Sn(t){if(!(this instanceof Sn))return new Sn(t);Ic.call(this,t),this._transformState={afterTransform:dT.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",pT)}c(Sn,"Transform");function pT(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){Sy(t,e,r)}):Sy(this,null,null)}c(pT,"prefinish");Sn.prototype.push=function(t,e){return this._transformState.needTransform=!1,Ic.prototype.push.call(this,t,e)};Sn.prototype._transform=function(t,e,r){r(new cT("_transform()"))};Sn.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Sn.prototype._read=function(t){var e=this._transformState;e.writechunk!==null&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0};Sn.prototype._destroy=function(t,e){Ic.prototype._destroy.call(this,t,function(r){e(r)})};function Sy(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new fT;if(t._transformState.transforming)throw new lT;return t.push(null)}c(Sy,"done")});var ky=le((u5,Ty)=>{"use strict";Ty.exports=Ts;var Py=Kf();di()(Ts,Py);function Ts(t){if(!(this instanceof Ts))return new Ts(t);Py.call(this,t)}c(Ts,"PassThrough");Ts.prototype._transform=function(t,e,r){r(null,t)}});var $y=le((f5,Oy)=>{"use strict";var Gf;function hT(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}c(hT,"once");var Ny=Kn().codes,gT=Ny.ERR_MISSING_ARGS,mT=Ny.ERR_STREAM_DESTROYED;function Cy(t){if(t)throw t}c(Cy,"noop");function _T(t){return t.setHeader&&typeof t.abort=="function"}c(_T,"isRequest");function yT(t,e,r,n){n=hT(n);var i=!1;t.on("close",function(){i=!0}),Gf===void 0&&(Gf=mc()),Gf(t,{readable:e,writable:r},function(s){if(s)return n(s);i=!0,n()});var o=!1;return function(s){if(!i&&!o){if(o=!0,_T(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new mT("pipe"))}}}c(yT,"destroyer");function Ry(t){t()}c(Ry,"call");function ET(t,e){return t.pipe(e)}c(ET,"pipe");function AT(t){return!t.length||typeof t[t.length-1]!="function"?Cy:t.pop()}c(AT,"popCallback");function bT(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=AT(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new gT("streams");var i,o=e.map(function(s,a){var u=a<e.length-1,l=a>0;return yT(s,u,l,function(d){i||(i=d),d&&o.forEach(Ry),!u&&(o.forEach(Ry),n(i))})});return e.reduce(ET)}c(bT,"pipeline");Oy.exports=bT});var Dy=le((jr,Cs)=>{var ks=require("stream");process.env.READABLE_STREAM==="disable"&&ks?(Cs.exports=ks.Readable,Object.assign(Cs.exports,ks),Cs.exports.Stream=ks):(jr=Cs.exports=Of(),jr.Stream=ks||jr,jr.Readable=jr,jr.Writable=Cf(),jr.Duplex=pi(),jr.Transform=Kf(),jr.PassThrough=ky(),jr.finished=mc(),jr.pipeline=$y())});var Uy=le((p5,By)=>{var xT=Object.prototype.toString,Zf=typeof Buffer<"u"&&typeof Buffer.alloc=="function"&&typeof Buffer.allocUnsafe=="function"&&typeof Buffer.from=="function";function IT(t){return xT.call(t).slice(8,-1)==="ArrayBuffer"}c(IT,"isArrayBuffer");function vT(t,e,r){e>>>=0;var n=t.byteLength-e;if(n<0)throw new RangeError("'offset' is out of bounds");if(r===void 0)r=n;else if(r>>>=0,r>n)throw new RangeError("'length' is out of bounds");return Zf?Buffer.from(t.slice(e,e+r)):new Buffer(new Uint8Array(t.slice(e,e+r)))}c(vT,"fromArrayBuffer");function ST(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Buffer.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');return Zf?Buffer.from(t,e):new Buffer(t,e)}c(ST,"fromString");function wT(t,e,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return IT(t)?vT(t,e,r):typeof t=="string"?ST(t,e):Zf?Buffer.from(t):new Buffer(t)}c(wT,"bufferFrom");By.exports=wT});var jy=le(Be=>{var Ly=void 0,PT=1e5,Ot=(function(){var t=Object.prototype.toString,e=Object.prototype.hasOwnProperty;return{Class:c(function(r){return t.call(r).replace(/^\[object *|\]$/g,"")},"Class"),HasProperty:c(function(r,n){return n in r},"HasProperty"),HasOwnProperty:c(function(r,n){return e.call(r,n)},"HasOwnProperty"),IsCallable:c(function(r){return typeof r=="function"},"IsCallable"),ToInt32:c(function(r){return r>>0},"ToInt32"),ToUint32:c(function(r){return r>>>0},"ToUint32")}})(),TT=Math.LN2,kT=Math.abs,vc=Math.floor,CT=Math.log,RT=Math.min,Zr=Math.pow,NT=Math.round;function Yf(t){if(zy&&ho){var e=zy(t),r;for(r=0;r<e.length;r+=1)ho(t,e[r],{value:t[e[r]],writable:!1,enumerable:!1,configurable:!1})}}c(Yf,"configureProperties");var ho;Object.defineProperty&&(function(){try{return Object.defineProperty({},"x",{}),!0}catch{return!1}})()?ho=Object.defineProperty:ho=c(function(t,e,r){if(!t===Object(t))throw new TypeError("Object.defineProperty called on non-object");return Ot.HasProperty(r,"get")&&Object.prototype.__defineGetter__&&Object.prototype.__defineGetter__.call(t,e,r.get),Ot.HasProperty(r,"set")&&Object.prototype.__defineSetter__&&Object.prototype.__defineSetter__.call(t,e,r.set),Ot.HasProperty(r,"value")&&(t[e]=r.value),t},"defineProp");var zy=Object.getOwnPropertyNames||function(t){if(t!==Object(t))throw new TypeError("Object.getOwnPropertyNames called on non-object");var e=[],r;for(r in t)Ot.HasOwnProperty(t,r)&&e.push(r);return e};function OT(t){if(!ho)return;if(t.length>PT)throw new RangeError("Array too large for polyfill");function e(n){ho(t,n,{get:c(function(){return t._getter(n)},"get"),set:c(function(i){t._setter(n,i)},"set"),enumerable:!0,configurable:!1})}c(e,"makeArrayAccessor");var r;for(r=0;r<t.length;r+=1)e(r)}c(OT,"makeArrayAccessors");function Xf(t,e){var r=32-e;return t<<r>>r}c(Xf,"as_signed");function Jf(t,e){var r=32-e;return t<<r>>>r}c(Jf,"as_unsigned");function $T(t){return[t&255]}c($T,"packI8");function DT(t){return Xf(t[0],8)}c(DT,"unpackI8");function BT(t){return[t&255]}c(BT,"packU8");function My(t){return Jf(t[0],8)}c(My,"unpackU8");function UT(t){return t=NT(Number(t)),[t<0?0:t>255?255:t&255]}c(UT,"packU8Clamped");function LT(t){return[t>>8&255,t&255]}c(LT,"packI16");function zT(t){return Xf(t[0]<<8|t[1],16)}c(zT,"unpackI16");function MT(t){return[t>>8&255,t&255]}c(MT,"packU16");function FT(t){return Jf(t[0]<<8|t[1],16)}c(FT,"unpackU16");function HT(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}c(HT,"packI32");function jT(t){return Xf(t[0]<<24|t[1]<<16|t[2]<<8|t[3],32)}c(jT,"unpackI32");function WT(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}c(WT,"packU32");function qT(t){return Jf(t[0]<<24|t[1]<<16|t[2]<<8|t[3],32)}c(qT,"unpackU32");function Fy(t,e,r){var n=(1<<e-1)-1,i,o,s,a,u,l,d,p;function g(h){var _=vc(h),A=h-_;return A<.5?_:A>.5||_%2?_+1:_}for(c(g,"roundToEven"),t!==t?(o=(1<<e)-1,s=Zr(2,r-1),i=0):t===1/0||t===-1/0?(o=(1<<e)-1,s=0,i=t<0?1:0):t===0?(o=0,s=0,i=1/t===-1/0?1:0):(i=t<0,t=kT(t),t>=Zr(2,1-n)?(o=RT(vc(CT(t)/TT),1023),s=g(t/Zr(2,o)*Zr(2,r)),s/Zr(2,r)>=2&&(o=o+1,s=1),o>n?(o=(1<<e)-1,s=0):(o=o+n,s=s-Zr(2,r))):(o=0,s=g(t/Zr(2,1-n-r)))),l=[],u=r;u;u-=1)l.push(s%2?1:0),s=vc(s/2);for(u=e;u;u-=1)l.push(o%2?1:0),o=vc(o/2);for(l.push(i?1:0),l.reverse(),d=l.join(""),p=[];d.length;)p.push(parseInt(d.substring(0,8),2)),d=d.substring(8);return p}c(Fy,"packIEEE754");function Hy(t,e,r){var n=[],i,o,s,a,u,l,d,p;for(i=t.length;i;i-=1)for(s=t[i-1],o=8;o;o-=1)n.push(s%2?1:0),s=s>>1;return n.reverse(),a=n.join(""),u=(1<<e-1)-1,l=parseInt(a.substring(0,1),2)?-1:1,d=parseInt(a.substring(1,1+e),2),p=parseInt(a.substring(1+e),2),d===(1<<e)-1?p!==0?NaN:l*(1/0):d>0?l*Zr(2,d-u)*(1+p/Zr(2,r)):p!==0?l*Zr(2,-(u-1))*(p/Zr(2,r)):l<0?-0:0}c(Hy,"unpackIEEE754");function QT(t){return Hy(t,11,52)}c(QT,"unpackF64");function VT(t){return Fy(t,11,52)}c(VT,"packF64");function KT(t){return Hy(t,8,23)}c(KT,"unpackF32");function GT(t){return Fy(t,8,23)}c(GT,"packF32");(function(){var t=c(function(h){if(h=Ot.ToInt32(h),h<0)throw new RangeError("ArrayBuffer size is not a small enough positive integer");this.byteLength=h,this._bytes=[],this._bytes.length=h;var _;for(_=0;_<this.byteLength;_+=1)this._bytes[_]=0;Yf(this)},"ArrayBuffer");Be.ArrayBuffer=Be.ArrayBuffer||t;var e=c(function(){},"ArrayBufferView");function r(g,h,_){var A;return A=c(function(b,I,w){var H,$,X,Z;if(!arguments.length||typeof arguments[0]=="number"){if(this.length=Ot.ToInt32(arguments[0]),w<0)throw new RangeError("ArrayBufferView size is not a small enough positive integer");this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new t(this.byteLength),this.byteOffset=0}else if(typeof arguments[0]=="object"&&arguments[0].constructor===A)for(H=arguments[0],this.length=H.length,this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new t(this.byteLength),this.byteOffset=0,X=0;X<this.length;X+=1)this._setter(X,H._getter(X));else if(typeof arguments[0]=="object"&&!(arguments[0]instanceof t||Ot.Class(arguments[0])==="ArrayBuffer"))for($=arguments[0],this.length=Ot.ToUint32($.length),this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new t(this.byteLength),this.byteOffset=0,X=0;X<this.length;X+=1)Z=$[X],this._setter(X,Number(Z));else if(typeof arguments[0]=="object"&&(arguments[0]instanceof t||Ot.Class(arguments[0])==="ArrayBuffer")){if(this.buffer=b,this.byteOffset=Ot.ToUint32(I),this.byteOffset>this.buffer.byteLength)throw new RangeError("byteOffset out of range");if(this.byteOffset%this.BYTES_PER_ELEMENT)throw new RangeError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.");if(arguments.length<3){if(this.byteLength=this.buffer.byteLength-this.byteOffset,this.byteLength%this.BYTES_PER_ELEMENT)throw new RangeError("length of buffer minus byteOffset not a multiple of the element size");this.length=this.byteLength/this.BYTES_PER_ELEMENT}else this.length=Ot.ToUint32(w),this.byteLength=this.length*this.BYTES_PER_ELEMENT;if(this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer")}else throw new TypeError("Unexpected argument type(s)");this.constructor=A,Yf(this),OT(this)},"ctor"),A.prototype=new e,A.prototype.BYTES_PER_ELEMENT=g,A.prototype._pack=h,A.prototype._unpack=_,A.BYTES_PER_ELEMENT=g,A.prototype._getter=function(b){if(arguments.length<1)throw new SyntaxError("Not enough arguments");if(b=Ot.ToUint32(b),b>=this.length)return Ly;var I=[],w,H;for(w=0,H=this.byteOffset+b*this.BYTES_PER_ELEMENT;w<this.BYTES_PER_ELEMENT;w+=1,H+=1)I.push(this.buffer._bytes[H]);return this._unpack(I)},A.prototype.get=A.prototype._getter,A.prototype._setter=function(b,I){if(arguments.length<2)throw new SyntaxError("Not enough arguments");if(b=Ot.ToUint32(b),b>=this.length)return Ly;var w=this._pack(I),H,$;for(H=0,$=this.byteOffset+b*this.BYTES_PER_ELEMENT;H<this.BYTES_PER_ELEMENT;H+=1,$+=1)this.buffer._bytes[$]=w[H]},A.prototype.set=function(b,I){if(arguments.length<1)throw new SyntaxError("Not enough arguments");var w,H,$,X,Z,Y,P,k,M,L;if(typeof arguments[0]=="object"&&arguments[0].constructor===this.constructor){if(w=arguments[0],$=Ot.ToUint32(arguments[1]),$+w.length>this.length)throw new RangeError("Offset plus length of array is out of range");if(k=this.byteOffset+$*this.BYTES_PER_ELEMENT,M=w.length*this.BYTES_PER_ELEMENT,w.buffer===this.buffer){for(L=[],Z=0,Y=w.byteOffset;Z<M;Z+=1,Y+=1)L[Z]=w.buffer._bytes[Y];for(Z=0,P=k;Z<M;Z+=1,P+=1)this.buffer._bytes[P]=L[Z]}else for(Z=0,Y=w.byteOffset,P=k;Z<M;Z+=1,Y+=1,P+=1)this.buffer._bytes[P]=w.buffer._bytes[Y]}else if(typeof arguments[0]=="object"&&typeof arguments[0].length<"u"){if(H=arguments[0],X=Ot.ToUint32(H.length),$=Ot.ToUint32(arguments[1]),$+X>this.length)throw new RangeError("Offset plus length of array is out of range");for(Z=0;Z<X;Z+=1)Y=H[Z],this._setter($+Z,Number(Y))}else throw new TypeError("Unexpected argument type(s)")},A.prototype.subarray=function(b,I){function w($,X,Z){return $<X?X:$>Z?Z:$}c(w,"clamp"),b=Ot.ToInt32(b),I=Ot.ToInt32(I),arguments.length<1&&(b=0),arguments.length<2&&(I=this.length),b<0&&(b=this.length+b),I<0&&(I=this.length+I),b=w(b,0,this.length),I=w(I,0,this.length);var H=I-b;return H<0&&(H=0),new this.constructor(this.buffer,this.byteOffset+b*this.BYTES_PER_ELEMENT,H)},A}c(r,"makeConstructor");var n=r(1,$T,DT),i=r(1,BT,My),o=r(1,UT,My),s=r(2,LT,zT),a=r(2,MT,FT),u=r(4,HT,jT),l=r(4,WT,qT),d=r(4,GT,KT),p=r(8,VT,QT);Be.Int8Array=Be.Int8Array||n,Be.Uint8Array=Be.Uint8Array||i,Be.Uint8ClampedArray=Be.Uint8ClampedArray||o,Be.Int16Array=Be.Int16Array||s,Be.Uint16Array=Be.Uint16Array||a,Be.Int32Array=Be.Int32Array||u,Be.Uint32Array=Be.Uint32Array||l,Be.Float32Array=Be.Float32Array||d,Be.Float64Array=Be.Float64Array||p})();(function(){function t(o,s){return Ot.IsCallable(o.get)?o.get(s):o[s]}c(t,"r");var e=(function(){var o=new Be.Uint16Array([4660]),s=new Be.Uint8Array(o.buffer);return t(s,0)===18})(),r=c(function(s,a,u){if(arguments.length===0)s=new Be.ArrayBuffer(0);else if(!(s instanceof Be.ArrayBuffer||Ot.Class(s)==="ArrayBuffer"))throw new TypeError("TypeError");if(this.buffer=s||new Be.ArrayBuffer(0),this.byteOffset=Ot.ToUint32(a),this.byteOffset>this.buffer.byteLength)throw new RangeError("byteOffset out of range");if(arguments.length<3?this.byteLength=this.buffer.byteLength-this.byteOffset:this.byteLength=Ot.ToUint32(u),this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");Yf(this)},"DataView");function n(o){return function(s,a){if(s=Ot.ToUint32(s),s+o.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");s+=this.byteOffset;var u=new Be.Uint8Array(this.buffer,s,o.BYTES_PER_ELEMENT),l=[],d;for(d=0;d<o.BYTES_PER_ELEMENT;d+=1)l.push(t(u,d));return!!a==!!e&&l.reverse(),t(new o(new Be.Uint8Array(l).buffer),0)}}c(n,"makeGetter"),r.prototype.getUint8=n(Be.Uint8Array),r.prototype.getInt8=n(Be.Int8Array),r.prototype.getUint16=n(Be.Uint16Array),r.prototype.getInt16=n(Be.Int16Array),r.prototype.getUint32=n(Be.Uint32Array),r.prototype.getInt32=n(Be.Int32Array),r.prototype.getFloat32=n(Be.Float32Array),r.prototype.getFloat64=n(Be.Float64Array);function i(o){return function(s,a,u){if(s=Ot.ToUint32(s),s+o.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");var l=new o([a]),d=new Be.Uint8Array(l.buffer),p=[],g,h;for(g=0;g<o.BYTES_PER_ELEMENT;g+=1)p.push(t(d,g));!!u==!!e&&p.reverse(),h=new Be.Uint8Array(this.buffer,s,o.BYTES_PER_ELEMENT),h.set(p)}}c(i,"makeSetter"),r.prototype.setUint8=i(Be.Uint8Array),r.prototype.setInt8=i(Be.Int8Array),r.prototype.setUint16=i(Be.Uint16Array),r.prototype.setInt16=i(Be.Int16Array),r.prototype.setUint32=i(Be.Uint32Array),r.prototype.setInt32=i(Be.Int32Array),r.prototype.setFloat32=i(Be.Float32Array),r.prototype.setFloat64=i(Be.Float64Array),Be.DataView=Be.DataView||r})()});var Vy=le((_5,Qy)=>{var Wy=Dy().Writable,ZT=di(),Rs=Uy();typeof Uint8Array>"u"?Sc=jy().Uint8Array:Sc=Uint8Array;var Sc;function yi(t,e){if(!(this instanceof yi))return new yi(t,e);typeof t=="function"&&(e=t,t={}),t||(t={});var r=t.encoding,n=!1;r?(r=String(r).toLowerCase(),(r==="u8"||r==="uint8")&&(r="uint8array")):n=!0,Wy.call(this,{objectMode:!0}),this.encoding=r,this.shouldInferEncoding=n,e&&this.on("finish",function(){e(this.getBody())}),this.body=[]}c(yi,"ConcatStream");Qy.exports=yi;ZT(yi,Wy);yi.prototype._write=function(t,e,r){this.body.push(t),r()};yi.prototype.inferEncoding=function(t){var e=t===void 0?this.body[0]:t;return Buffer.isBuffer(e)?"buffer":typeof Uint8Array<"u"&&e instanceof Uint8Array?"uint8array":Array.isArray(e)?"array":typeof e=="string"?"string":Object.prototype.toString.call(e)==="[object Object]"?"object":"buffer"};yi.prototype.getBody=function(){return!this.encoding&&this.body.length===0?[]:(this.shouldInferEncoding&&(this.encoding=this.inferEncoding()),this.encoding==="array"?e1(this.body):this.encoding==="string"?XT(this.body):this.encoding==="buffer"?JT(this.body):this.encoding==="uint8array"?t1(this.body):this.body)};function YT(t){return/Array\]$/.test(Object.prototype.toString.call(t))}c(YT,"isArrayish");function qy(t){return typeof t=="string"||YT(t)||t&&typeof t.subarray=="function"}c(qy,"isBufferish");function XT(t){for(var e=[],r=!1,n=0;n<t.length;n++){var i=t[n];typeof i=="string"||Buffer.isBuffer(i)?e.push(i):qy(i)?e.push(Rs(i)):e.push(Rs(String(i)))}return Buffer.isBuffer(t[0])?(e=Buffer.concat(e),e=e.toString("utf8")):e=e.join(""),e}c(XT,"stringConcat");function JT(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];Buffer.isBuffer(n)?e.push(n):qy(n)?e.push(Rs(n)):e.push(Rs(String(n)))}return Buffer.concat(e)}c(JT,"bufferConcat");function e1(t){for(var e=[],r=0;r<t.length;r++)e.push.apply(e,t[r]);return e}c(e1,"arrayConcat");function t1(t){for(var e=0,r=0;r<t.length;r++)typeof t[r]=="string"&&(t[r]=Rs(t[r])),e+=t[r].length;for(var n=new Sc(e),r=0,i=0;r<t.length;r++)for(var o=t[r],s=0;s<o.length;s++)n[i++]=o[s];return n}c(t1,"u8Concat")});var Zy=le((E5,Gy)=>{"use strict";function Ky(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}c(Ky,"assign");function r1(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=void 0),e!=null&&(r.code=e);try{return Ky(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=c(function(){},"ErrClass");return i.prototype=Object.create(Object.getPrototypeOf(t)),Ky(new i,r)}}c(r1,"createError");Gy.exports=r1});var Xy=le((b5,Yy)=>{function Wr(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}c(Wr,"RetryOperation");Yy.exports=Wr;Wr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Wr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Wr.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var n=this,i=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r);return this._options.unref&&i.unref(),!0};Wr.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Wr.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};Wr.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};Wr.prototype.start=Wr.prototype.try;Wr.prototype.errors=function(){return this._errors};Wr.prototype.attempts=function(){return this._attempts};Wr.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],o=i.message,s=(t[o]||0)+1;t[o]=s,s>=r&&(e=i,r=s)}return e}});var Jy=le(Ei=>{var n1=Xy();Ei.operation=function(t){var e=Ei.timeouts(t);return new n1(e,{forever:t&&t.forever,unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};Ei.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in t)e[r]=t[r];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<e.retries;i++)n.push(this.createTimeout(i,e));return t&&t.forever&&!n.length&&n.push(this.createTimeout(i,e)),n.sort(function(o,s){return o-s}),n};Ei.createTimeout=function(t,e){var r=e.randomize?Math.random()+1:1,n=Math.round(r*e.minTimeout*Math.pow(e.factor,t));return n=Math.min(n,e.maxTimeout),n};Ei.wrap=function(t,e,r){if(e instanceof Array&&(r=e,e=null),!r){r=[];for(var n in t)typeof t[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var o=r[i],s=t[o];t[o]=c(function(u){var l=Ei.operation(e),d=Array.prototype.slice.call(arguments,1),p=d.pop();d.push(function(g){l.retry(g)||(g&&(arguments[0]=l.mainError()),p.apply(this,arguments))}),l.attempt(function(){u.apply(t,d)})},"retryWrapper").bind(t,s),t[o].options=e}}});var tE=le((S5,eE)=>{eE.exports=Jy()});var iE=le((w5,nE)=>{"use strict";var i1=Zy(),o1=tE(),s1=Object.prototype.hasOwnProperty;function rE(t){return t&&t.code==="EPROMISERETRY"&&s1.call(t,"retried")}c(rE,"isRetryError");function a1(t,e){var r,n;return typeof t=="object"&&typeof e=="function"&&(r=e,e=t,t=r),n=o1.operation(e),new Promise(function(i,o){n.attempt(function(s){Promise.resolve().then(function(){return t(function(a){throw rE(a)&&(a=a.retried),i1(new Error("Retrying"),"EPROMISERETRY",{retried:a})},s)}).then(i,function(a){rE(a)&&(a=a.retried,n.retry(a||new Error))||o(a)})})})}c(a1,"promiseRetry");nE.exports=a1});var ed=le((T5,oE)=>{var c1={generic:"ERR_GENERIC_CLIENT",connect:"ERR_NOT_CONNECTED",badPath:"ERR_BAD_PATH",permission:"EACCES",notexist:"ENOENT",notdir:"ENOTDIR",badAuth:"ERR_BAD_AUTH"},u1={writeFile:1,readFile:2,writeDir:3,readDir:4,readObj:5,writeObj:6};oE.exports={errorCode:c1,targetType:u1}});var fE=le((k5,lE)=>{var Ns=require("fs"),l1=require("path"),{errorCode:sE}=ed();function aE(t,e,r){return c(i=>{if(t.endCalled||t.errorHandled){t.debugMsg(`${e} errorListener - ignoring handled error`);return}t.errorHandled=!0;let o=new Error(`${e}: ${i.message}`);if(o.code=i.code,r)r(o);else throw o},"fn")}c(aE,"errorListener");function f1(t,e){return()=>{t.endCalled||t.errorHandled||t.closeHandled?t.debugMsg(`Global ${e} event: Ignoring expected and handled event`):(t.debugMsg(`Global ${e} event: Handling unexpected event`),t.sftp=void 0)}}c(f1,"globalListener");function cE(t,e,r){return c(function(){if(t.sftp=void 0,t.endCalled||t.endHandled||t.errorHandled){t.debugMsg(`${e} endListener - ignoring handled error`);return}t.endHandled=!0,t.debugMsg(`${e} Unexpected end event - ignoring`)},"fn")}c(cE,"endListener");function uE(t,e,r){return c(function(){if(t.sftp=void 0,t.endCalled||t.closeHandled||t.errorHandled||t.endHandled){t.debugMsg(`${e} closeListener - ignoring handled error`);return}t.closeHandled=!0,t.debugMsg(`${e} Unexpected close event raised - ignoring`)},"fn")}c(uE,"closeListener");function d1(t,e,r){let n={end:cE(t,e,r),close:uE(t,e,r),error:aE(t,e,r)};return t.on("end",n.end),t.on("close",n.close),t.on("error",n.error),t._resetEventFlags(),n}c(d1,"addTempListeners");function p1(t,e,r){try{t.removeListener("end",e.end),t.removeListener("close",e.close),t.removeListener("error",e.error)}catch(n){throw new Error(`${r}: Error removing temp listeners: ${n.message}`)}}c(p1,"removeTempListeners");function td(t){let e=Ns.statSync(t,{throwIfNoEntry:!1});if(e){if(e.isDirectory())return"d";if(e.isFile())return"-";{let r=new Error(`Bad path: ${t}: target must be a file or directory`);throw r.code=sE.badPath,r}}else return!1}c(td,"localExists");function rd(t,e="r"){let r=Ns.constants.F_OK|e==="w"?Ns.constants.W_OK:Ns.constants.R_OK;try{return Ns.accessSync(t,r),{status:!0,type:td(t),details:"access OK",code:0}}catch(n){switch(n.errno){case-2:return{status:!1,type:null,details:"not exist",code:-2};case-13:return{status:!1,type:td(t),details:"permission denied",code:-13};case-20:return{status:!1,type:null,details:"parent not a directory"};default:return{status:!1,type:null,details:n.message}}}}c(rd,"haveLocalAccess");function h1(t){let{status:e,details:r,type:n}=rd(t,"w");if(!e&&r==="permission denied")return{status:e,details:r,type:n};if(!e){let i=l1.dirname(t),o=rd(i,"w");return o.status&&o.type!=="d"?{status:!1,details:`${i}: not a directory`,type:null}:o.status?{status:!0,details:"access OK",type:null,code:0}:{status:o.status,details:`${i}: ${o.details}`,type:null}}return{status:e,details:r,type:n}}c(h1,"haveLocalCreate");async function g1(t,e){try{return e.startsWith("..")?`${await t.realPath("..")}/${e.slice(3)}`:e.startsWith(".")?`${await t.realPath(".")}/${e.slice(2)}`:e}catch(r){throw new Error(`normalizeRemotePath: ${r.message}`)}}c(g1,"normalizeRemotePath");function m1(t,e,r){if(!t.sftp){let n=new Error(`${e}: No SFTP connection available`);if(n.code=sE.connect,r)return r(n),!1;throw n}return!0}c(m1,"haveConnection");function _1(t){return new Promise((e,r)=>{try{isNaN(t)||t<0?r("Argument must be anumber >= 0"):setTimeout(()=>{e(!0)},t)}catch(n){r(n)}})}c(_1,"sleep");lE.exports={globalListener:f1,errorListener:aE,endListener:cE,closeListener:uE,addTempListeners:d1,removeTempListeners:p1,haveLocalAccess:rd,haveLocalCreate:h1,normalizeRemotePath:g1,localExists:td,haveConnection:m1,sleep:_1}});var gE=le((R5,hE)=>{"use strict";var{Client:y1}=C_(),wc=require("fs"),E1=Vy(),A1=iE(),{join:Os,parse:b1}=require("path"),{globalListener:nd,addTempListeners:zt,removeTempListeners:Mt,haveConnection:fr,normalizeRemotePath:$s,localExists:dE,haveLocalAccess:pE,haveLocalCreate:id}=fE(),{errorCode:$t}=ed(),od=class{static{c(this,"SftpClient")}constructor(e){this.version="9.0.4",this.client=new y1,this.sftp=void 0,this.clientName=e||"sftp",this.endCalled=!1,this.errorHandled=!1,this.closeHandled=!1,this.endHandled=!1,this.remotePlatform="unix",this.debug=void 0,this.client.on("close",nd(this,"close")),this.client.on("end",nd(this,"end")),this.client.on("error",nd(this,"error"))}debugMsg(e,r){this.debug&&(r?this.debug(`CLIENT[${this.clientName}]: ${e} ${JSON.stringify(r,null," ")}`):this.debug(`CLIENT[${this.clientName}]: ${e}`))}fmtError(e,r="sftp",n,i){let o="",s="",a=i?` after ${i} ${i>1?"attempts":"attempt"}`:"";if(e===void 0)o=`${r}: Undefined error - probably a bug!`,s=$t.generic;else if(typeof e=="string")o=`${r}: ${e}${a}`,s=n||$t.generic;else if(e.custom)o=`${r}->${e.message}${a}`,s=e.code;else{switch(e.code){case"ENOTFOUND":o=`${r}: Address lookup failed for host${a}`;break;case"ECONNREFUSED":o=`${r}: Remote host refused connection${a}`;break;case"ECONNRESET":o=`${r}: Remote host has reset the connection: ${e.message}${a}`;break;default:o=`${r}: ${e.message}${a}`}s=e.code?e.code:$t.generic}let u=new Error(o);return u.code=s,u.custom=!0,this.debugMsg(`${u.message} (${u.code})`),u}on(e,r){this.client.prependListener(e,r)}removeListener(e,r){this.client.removeListener(e,r)}_resetEventFlags(){this.closeHandled=!1,this.endHandled=!1,this.errorHandled=!1}getConnection(e){let r,n;return new Promise((i,o)=>{n=zt(this,"getConnection",o),r=c(()=>{this.debugMsg("getConnection ready listener: got connection - promise resolved"),i(!0)},"doReady"),this.on("ready",r);try{this.client.connect(e)}catch(s){this.debugMsg(`getConnection: ${s.message}`),o(s)}}).finally(()=>{this.removeListener("ready",r),Mt(this,n,"getConnection")})}getSftpChannel(){return new Promise((e,r)=>{this.client.sftp((n,i)=>{n?r(this.fmtError(n,"getSftpChannel",n.code)):(this.sftp=i,e(i))})})}async connect(e){let r;try{if(r=zt(this,"connect"),e.debug&&(this.debug=e.debug,this.debugMsg("connect: Debugging turned on"),this.debugMsg(`ssh2-sftp-client Version: ${this.version} `,process.versions)),this.sftp)throw this.fmtError("An existing SFTP connection is already defined","connect",$t.connect);let n={retries:e.retries??1,factor:e.factor??2,minTimeout:e.retry_minTimeout??25e3};return await A1(n,async(o,s)=>{try{this.debugMsg(`connect: Connect attempt ${s}`),await this.getConnection(e)}catch(a){switch(a.code){case"ENOTFOUND":case"ECONNREFUSED":case"ERR_SOCKET_BAD_PORT":throw a;case void 0:{if(a.message.endsWith("All configured authentication methods failed")||a.message.startsWith("Cannot parse privateKey"))throw a;o(a);break}default:o(a)}}}),await this.getSftpChannel()}catch(n){throw this.end(),n.custom?n:this.fmtError(n,"connect")}finally{Mt(this,r,"connect")}}realPath(e,r=!0){let n;return new Promise((i,o)=>{r&&(n=zt(this,"realPath",o)),this.debugMsg(`realPath -> ${e}`),this.sftp.realpath(e,(s,a)=>{s&&(s.code===2?(this.debugMsg('realPath <- ""'),i("")):(this.debugMsg(`${s.message} ${e}`,"realPath"),o(this.fmtError(`${s.message} ${e}`,"realPath",s.code)))),this.debugMsg(`realPath <- ${a}`),i(a)})}).finally(()=>{r&&Mt(this,n,"realPath")})}cwd(){return this.realPath(".")}_xstat(e,r,n=!0){let i;return new Promise((o,s)=>{let a=c((u,l)=>{if(u)u.code===2||u.code===4?s(this.fmtError(`No such file: ${r}`,"_xstat",$t.notexist)):s(this.fmtError(`${u.message} ${r}`,"_xstat",u.code));else{let d={mode:l.mode,uid:l.uid,gid:l.gid,size:l.size,accessTime:l.atime*1e3,modifyTime:l.mtime*1e3,isDirectory:l.isDirectory(),isFile:l.isFile(),isBlockDevice:l.isBlockDevice(),isCharacterDevice:l.isCharacterDevice(),isSymbolicLink:l.isSymbolicLink(),isFIFO:l.isFIFO(),isSocket:l.isSocket()};this.debugMsg("_xstat: result = ",d),o(d)}},"cb");n&&(i=zt(this,"_xstat",s)),e==="stat"?this.sftp.stat(r,a):this.sftp.lstat(r,a)}).finally(()=>{n&&Mt(this,i,"_xstat")})}async stat(e){try{return fr(this,"stat"),await this._xstat("stat",e)}catch(r){throw r.custom?r:this.fmtError(r,"stat",r.code)}}async lstat(e){try{return fr(this,"lstat"),await this._xstat("lstat",e)}catch(r){throw r.custom?r:this.fmtError(r,"lstat",r.code)}}async exists(e){this.debugMsg(`exists: remotePath = ${e}`);try{if(e===".")return"d";let r=await this.lstat(e);return this.debugMsg("exists: <- ",r),r.isDirectory?"d":r.isSymbolicLink?"l":r.isFile?"-":!1}catch(r){if(r.code===$t.notexist)return!1;throw r.custom?r:this.fmtError(r.message,"exists",r.code)}}list(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"list",s)),fr(this,"list",s)&&this.sftp.readdir(e,(a,u)=>{if(a)s(this.fmtError(`${a.message} ${e}`,"list",a.code));else{let l=/-/gi,d=u.map(p=>({type:p.longname.slice(0,1),name:p.filename,size:p.attrs.size,modifyTime:p.attrs.mtime*1e3,accessTime:p.attrs.atime*1e3,rights:{user:p.longname.slice(1,4).replace(l,""),group:p.longname.slice(4,7).replace(l,""),other:p.longname.slice(7,10).replace(l,"")},owner:p.attrs.uid,group:p.attrs.gid,longname:p.longname}));o(r?d.filter(p=>r(p)):d)}})}).finally(()=>{n&&Mt(this,i,"list")})}get(e,r,n,i=!0){let o,s,a;return new Promise((u,l)=>{if(i&&(o=zt(this,"get",l)),fr(this,"get",l)){if(n={readStreamOptions:{...n?.readStreamOptions,autoClose:!0},writeStreamOptions:{...n?.writeStreamOptions,autoClose:!0},pipeOptions:{...n?.pipeOptions,end:!0}},s=this.sftp.createReadStream(e,n.readStreamOptions),s.once("error",d=>{r&&typeof r!="string"&&!r.destroyed&&r.destroy(),l(this.fmtError(`${d.message} ${e}`,"get",d.code))}),r===void 0)this.debugMsg("get resolving buffer of data"),a=E1(d=>{u(d)});else if(typeof r=="string"){this.debugMsg("get returning local file");let d=id(r);if(d.status)a=wc.createWriteStream(r,n.writeStreamOptions);else{l(this.fmtError(`Bad path: ${r}: ${d.details}`,"get",d.code));return}}else this.debugMsg("get: returning data into supplied stream"),a=r;a.once("error",d=>{l(this.fmtError(`${d.message} ${typeof r=="string"?r:"<stream>"}`,"get",d.code))}),s.once("end",()=>{typeof r=="string"?(this.debugMsg("get: resolving with dst filename"),u(r)):r!==void 0&&(this.debugMsg("get: resolving with writer stream object"),u(a))}),s.pipe(a,n.pipeOptions)}}).finally(()=>{i&&Mt(this,o,"get")})}_fastGet(e,r,n,i=!0){let o;return new Promise((s,a)=>{i&&(o=zt(this,"_fastGet",a)),fr(this,"_fastGet",a)&&this.sftp.fastGet(e,r,n,u=>{u&&a(this.fmtError(`${u.message} Remote: ${e} Local: ${r}`)),s(`${e} was successfully download to ${r}!`)})}).finally(()=>{i&&Mt(this,o,"_fastGet")})}async fastGet(e,r,n){try{let i=await this.exists(e);if(i!=="-"){let s=`${i?"Not a regular file":"No such file "} ${e}`;throw this.fmtError(s,"fastGet",$t.badPath)}let o=id(r);if(!o.status)throw this.fmtError(`Bad path: ${r}: ${o.details}`,"fastGet",$t.badPath);return await this._fastGet(e,r,n)}catch(i){throw this.fmtError(i,"fastGet")}}_fastPut(e,r,n,i=!0){let o;return new Promise((s,a)=>{i&&(o=zt(this,"_fastPut",a)),fr(this,"_fastPut",a)&&this.sftp.fastPut(e,r,n,u=>{u&&a(this.fmtError(`${u.message} Local: ${e} Remote: ${r}`,"fastPut",u.code)),s(`${e} was successfully uploaded to ${r}!`)})}).finally(()=>{i&&Mt(this,o,"_fastPut")})}async fastPut(e,r,n){try{this.debugMsg(`fastPut -> local ${e} remote ${r}`);let i=pE(e);if(i.status){if(i.status&&dE(e)==="d")throw this.fmtError(`Bad path: ${e} not a regular file`,"fastgPut",$t.badPath)}else throw this.fmtError(`Bad path: ${e}: ${i.details}`,"fastPut",i.code);return await this._fastPut(e,r,n)}catch(i){throw i.custom?i:this.fmtError(i.message,"fastPut",i.code)}}_put(e,r,n,i=!0){let o,s,a;return new Promise((u,l)=>{i&&(o=zt(this,"_put",l)),n={readStreamOptions:{...n?.readStreamOptions,autoClose:!0},writeStreamOptions:{...n?.writeStreamOptions,autoClose:!0},pipeOptions:{...n?.pipeOptions,end:!0}},fr(this,"_put",l)&&(s=this.sftp.createWriteStream(r,n.writeStreamOptions),s.once("error",d=>{l(this.fmtError(`Write stream error: ${d.message} ${r}`,"_put",d.code))}),s.once("close",()=>{u(`Uploaded data stream to ${r}`)}),e instanceof Buffer?(this.debugMsg("put source is a buffer"),s.end(e)):(a=typeof e=="string"?wc.createReadStream(e,n.readStreamOptions):e,a.once("error",d=>{l(this.fmtError(`Read stream error: ${d.message} ${typeof e=="string"?e:"<stream>"}`,"_put",d.code))}),a.pipe(s,n.pipeOptions)))}).finally(()=>{i&&Mt(this,o,"_put")})}async put(e,r,n){try{if(typeof e=="string"){let i=pE(e);if(!i.status)throw this.fmtError(`Bad path: ${e} ${i.details}`,"put",i.code)}return await this._put(e,r,n)}catch(i){throw i.custom?i:this.fmtError(`Re-thrown: ${i.message}`,"put",i.code)}}_append(e,r,n,i=!0){let o;return new Promise((s,a)=>{if(i&&(o=zt(this,"_append",a)),fr(this,"_append",a)){this.debugMsg(`append -> remote: ${r} `,n),n.flags="a";let u=this.sftp.createWriteStream(r,n);u.on("error",l=>{a(this.fmtError(`${l.message} ${r}`,"append",l.code))}),u.on("close",()=>{s(`Appended data to ${r}`)}),e instanceof Buffer?(u.write(e),u.end()):e.pipe(u)}}).finally(()=>{i&&Mt(this,o,"_append")})}async append(e,r,n={}){try{if(typeof e=="string")throw this.fmtError("Cannot append one file to another","append",$t.badPath);let i=await this.exists(r);if(i&&i==="d")throw this.fmtError(`Bad path: ${r}: cannot append to a directory`,"append",$t.badPath);await this._append(e,r,n)}catch(i){throw i.custom?i:this.fmtError(i.message,"append",i.code)}}_doMkdir(e,r=!0){let n;return new Promise((i,o)=>{r&&(n=zt(this,"_doMkdir",o)),this.sftp.mkdir(e,s=>{s?s.code===4?o(this.fmtError(`Bad path: ${e} permission denied`,"_doMkdir",$t.badPath)):s.code===2?o(this.fmtError(`Bad path: ${e} parent not a directory or not exist`,"_doMkdir",$t.badPath)):o(this.fmtError(`${s.message} ${e}`,"_doMkdir",s.code)):i(`${e} directory created`)})}).finally(()=>{r&&Mt(this,n,"_doMkdir")})}async _mkdir(e,r){try{let n=await $s(this,e),i=await this.exists(n);if(i&&i!=="d")throw this.fmtError(`Bad path: ${n} already exists as a file`,"_mkdir",$t.badPath);if(i)return`${n} already exists`;if(!r)return await this._doMkdir(n);let o=b1(n).dir;if(o){let s=await this.exists(o);if(!s)await this._mkdir(o,!0);else if(s!=="d")throw this.fmtError(`Bad path: ${o} not a directory`,"_mkdir",$t.badPath)}return await this._doMkdir(n)}catch(n){throw n.custom?n:this.fmtError(`${n.message} ${e}`,"_mkdir",n.code)}}async mkdir(e,r=!1){try{return fr(this,"mkdir"),await this._mkdir(e,r)}catch(n){throw this.fmtError(`${n.message}`,"mkdir",n.code)}}async rmdir(e,r=!1){let n=c(o=>{let s;return new Promise((a,u)=>{s=zt(this,"_rmdir",u),this.debugMsg(`_rmdir: dir = ${o}`),this.sftp.rmdir(o,l=>{l&&u(this.fmtError(`${l.message} ${o}`,"rmdir",l.code)),a("Successfully removed directory")})}).finally(()=>{Mt(this,s,"_rmdir")})},"_rmdir"),i=c((o,s)=>{let a;return new Promise((u,l)=>{a=zt(this,"_delFiles",l),this.debugMsg(`_delFiles: path = ${o} fileList = ${s}`);let d=[];for(let p of s)d.push(this.delete(`${o}/${p.name}`,!0,!1));u(d)}).then(u=>Promise.all(u)).finally(()=>{Mt(this,a,"_delFiles")})},"_delFiles");try{this.debugMsg(`rmdir: dir = ${e} recursive = ${r}`);let o=await $s(this,e),s=await this.exists(o);if(this.debugMsg(`rmdir: ${o} existStatus = ${s}`),!s)throw this.fmtError(`Bad Path: ${e}: No such directory`,"rmdir",$t.badPath);if(s!=="d")throw this.fmtError(`Bad Path: ${e}: Not a directory`,"rmdir",$t.badPath);if(!r)return this.debugMsg("rmdir: non-recursive - just try to remove it"),await n(o);let a=await this.list(o);if(this.debugMsg(`rmdir: listing count = ${a.length}`),!a.length)return this.debugMsg("rmdir: No sub dir or files, just rmdir"),await n(o);let u=a.filter(d=>d.type!=="d");this.debugMsg(`rmdir: dir content files to remove = ${u.length}`);let l=a.filter(d=>d.type==="d");this.debugMsg(`rmdir: sub-directories to remove = ${l.length}`),await i(o,u);for(let d of l)await this.rmdir(`${o}/${d.name}`,!0);return await n(o),"Successfully removed directory"}catch(o){throw o.custom?o:this.fmtError(`${o.message} ${e}`,"rmdir",o.code)}}delete(e,r=!1,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"delete",s)),this.sftp.unlink(e,a=>{a&&(r&&a.code===2?o(`Successfully deleted ${e}`):s(this.fmtError(`${a.message} ${e}`,"delete",a.code))),o(`Successfully deleted ${e}`)})}).finally(()=>{n&&Mt(this,i,"delete")})}rename(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"rename",s)),fr(this,"rename",s)&&this.sftp.rename(e,r,a=>{a&&s(this.fmtError(`${a.message} From: ${e} To: ${r}`,"_rename",a.code)),o(`Successfully renamed ${e} to ${r}`)})}).finally(()=>{n&&Mt(this,i,"rename")})}posixRename(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"posixRename",s)),fr(this,"posixRename",s)&&this.sftp.ext_openssh_rename(e,r,a=>{a&&s(this.fmtError(`${a.message} From: ${e} To: ${r}`,"_posixRename",a.code)),o(`Successful POSIX rename ${e} to ${r}`)})}).finally(()=>{Mt(this,i,"posixRename")})}chmod(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=zt(this,"chmod",s)),fr(this,"chmod",s)&&this.sftp.chmod(e,r,a=>{a&&s(this.fmtError(`${a.message} ${e}`,"_chmod",a.code)),o("Successfully change file mode")})}).finally(()=>{n&&Mt(this,i,"chmod")})}async uploadDir(e,r,n){let i=c(async a=>{let u=await $s(this,a),l=await this.exists(u);if(l&&l!=="d")throw this.fmtError(`Bad path ${u} Not a directory`,"getRemoteStatus",$t.badPath);return{remoteDir:u,remoteStatus:l}},"getRemoteStatus"),o=c(a=>{let u=dE(a);if(!u)throw this.fmtError(`Bad path: ${a} not exist`,"getLocalStatus",$t.badPath);if(u!=="d")throw this.fmtError(`Bad path: ${a}: not a directory`,"getLocalStatus",$t.badPath);return u},"checkLocalStatus"),s=c((a,u,l,d)=>{let p;return new Promise((g,h)=>{p=zt(this,"uploadFiles",h);let _=[];for(let A of l){let b=Os(a,A.name),I=`${u}/${A.name}`;A.isFile()?(d?_.push(this._fastPut(b,I,null,!1)):_.push(this._put(b,I,null,!1)),this.client.emit("upload",{source:b,destination:I})):this.debugMsg(`uploadFiles: File ignored: ${A.name} not a regular file`)}g(Promise.all(_))}).then(g=>Promise.all(g)).finally(()=>{Mt(this,p,s)})},"uploadFiles");try{fr(this,"uploadDir"),this.debugMsg(`uploadDir: srcDir = ${e} dstDir = ${r} options = ${n}`);let{remoteDir:a,remoteStatus:u}=await i(r);this.debugMsg(`uploadDir: remoteDir = ${a} remoteStatus = ${u}`),o(e),u||await this._mkdir(a,!0);let l=wc.readdirSync(e,{encoding:"utf8",withFileTypes:!0});this.debugMsg(`uploadDir: dirEntries = ${l}`),n?.filter&&(l=l.filter(g=>n.filter(Os(e,g.name),g.isDirectory())));let d=l.filter(g=>g.isDirectory()),p=l.filter(g=>!g.isDirectory());this.debugMsg(`uploadDir: dirUploads = ${d}`),this.debugMsg(`uploadDir: fileUploads = ${p}`),await s(e,a,p,n?.useFastput);for(let g of d){let h=Os(e,g.name),_=`${a}/${g.name}`;await this.uploadDir(h,_,n)}return`${e} uploaded to ${r}`}catch(a){throw a.custom?a:this.fmtError(`${a.message} ${e}`,"uploadDir",a.code)}}async downloadDir(e,r,n={filter:null,useFastget:!1}){let i=c(async(a,u)=>{try{let l=await this.list(a);return u?l.filter(d=>u(`${a}/${d.name}`,d.type==="d")):l}catch(l){throw l.custom?l:this.fmtError(l.message,"_getDownloadList",l.code)}},"_getDownloadList"),o=c(a=>{try{let u=id(a);if(!u.status&&u.details==="permission denied")throw this.fmtError(`Bad path: ${a}: ${u.details}`,"prepareDestination",u.code);if(u.status&&!u.type)wc.mkdirSync(a,{recursive:!0});else if(u.status&&u.type!=="d")throw this.fmtError(`Bad path: ${r}: not a directory`,"_prepareDestination",$t.badPath)}catch(u){throw u.custom?u:this.fmtError(u.message,"_prepareDestination",u.code)}},"_prepareDestination"),s=c((a,u,l,d)=>{let p;return new Promise((g,h)=>{p=zt(this,"_downloadFIles",h);let _=[];for(let A of l){let b=`${a}/${A.name}`,I=Os(u,A.name);d?_.push(this.fastGet(b,I,!1)):_.push(this.get(b,I,!1)),this.client.emit("download",{source:b,destination:I})}return g(Promise.all(_))}).finally(()=>{Mt(this,p,"_downloadFiles")})},"_downloadFiles");try{fr(this,"downloadDir");let a=await i(e,n.filter);o(r);let u=a.filter(d=>d.type!=="d");u.length&&await s(e,r,u,n.useFastget);let l=a.filter(d=>d.type==="d");for(let d of l){let p=`${e}/${d.name}`,g=Os(r,d.name);await this.downloadDir(p,g)}return`${e} downloaded to ${r}`}catch(a){throw a.custom?a:this.fmtError(`${a.message}: ${e}`,"downloadDir",a.code)}}createReadStream(e,r){let n;try{return n=zt(this,"createReadStream"),fr(this,"createReadStream"),this.sftp.createReadStream(e,r)}catch(i){throw i.custom?i:this.fmtError(i.message,"createReadStream",i.code)}finally{Mt(this,n,"createReadStreame")}}createWriteStream(e,r){let n;try{return n=zt(this,"createWriteStream"),fr(this,"createWriteStream"),this.sftp.createWriteStream(e,r)}catch(i){throw i.custom?i:this.fmtError(i.message,"createWriteStream",i.code)}finally{Mt(this,n,"createWriteStream")}}_rcopy(e,r){return new Promise((n,i)=>{let o=this.sftp.createWriteStream(r),s=this.sftp.createReadStream(e);o.on("error",a=>{i(this.fmtError(`${a.message} ${r}`,"_rcopy"))}),s.on("error",a=>{i(this.fmtError(`${a.message} ${e}`,"_rcopy"))}),o.on("close",()=>{n(`${e} copied to ${r}`)}),s.pipe(o)})}async rcopy(e,r){let n;try{n=zt(this,"rcopy"),fr(this,"rcopy");let i=await $s(this,e),o=await this.exists(i);if(!o)throw this.fmtError(`Source does not exist ${i}`,"rcopy",$t.badPath);if(o!=="-")throw this.fmtError(`Source not a file ${i}`,"rcopy",$t.badPath);let s=await $s(this,r);if(await this.exists(s))throw this.fmtError(`Destination already exists ${s}`,"rcopy",$t.badPath);return this._rcopy(i,s)}catch(i){throw i.custom?i:this.fmtError(i,"rcopy")}finally{Mt(this,n,"rcopy")}}end(){let e,r;return new Promise((n,i)=>{r=zt(this,"end",i),this.endCalled=!0,e=c(()=>{this.sftp=void 0,this.debugMsg("end: Connection closed"),n(!0)},"endCloseHandler"),this.on("close",e),this.sftp?this.client.end():(this.debugMsg("end: Called when no connection active"),n(!0))}).finally(()=>{Mt(this,r,"end"),this.removeListener("close",e),this.endCalled=!1})}};hE.exports=od});var PE=le((sd,ad)=>{(function(t,e){typeof sd=="object"&&typeof ad<"u"?ad.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self).dayjs=e()})(sd,(function(){"use strict";var t=1e3,e=6e4,r=36e5,n="millisecond",i="second",o="minute",s="hour",a="day",u="week",l="month",d="quarter",p="year",g="date",h="Invalid Date",_=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,A=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,b={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:c(function(L){var T=["th","st","nd","rd"],F=L%100;return"["+L+(T[(F-20)%10]||T[F]||T[0])+"]"},"ordinal")},I=c(function(L,T,F){var j=String(L);return!j||j.length>=T?L:""+Array(T+1-j.length).join(F)+L},"m"),w={s:I,z:c(function(L){var T=-L.utcOffset(),F=Math.abs(T),j=Math.floor(F/60),B=F%60;return(T<=0?"+":"-")+I(j,2,"0")+":"+I(B,2,"0")},"z"),m:c(function L(T,F){if(T.date()<F.date())return-L(F,T);var j=12*(F.year()-T.year())+(F.month()-T.month()),B=T.clone().add(j,l),G=F-B<0,ee=T.clone().add(j+(G?-1:1),l);return+(-(j+(F-B)/(G?B-ee:ee-B))||0)},"t"),a:c(function(L){return L<0?Math.ceil(L)||0:Math.floor(L)},"a"),p:c(function(L){return{M:l,y:p,w:u,d:a,D:g,h:s,m:o,s:i,ms:n,Q:d}[L]||String(L||"").toLowerCase().replace(/s$/,"")},"p"),u:c(function(L){return L===void 0},"u")},H="en",$={};$[H]=b;var X=c(function(L){return L instanceof k},"p"),Z=c(function L(T,F,j){var B;if(!T)return H;if(typeof T=="string"){var G=T.toLowerCase();$[G]&&(B=G),F&&($[G]=F,B=G);var ee=T.split("-");if(!B&&ee.length>1)return L(ee[0])}else{var C=T.name;$[C]=T,B=C}return!j&&B&&(H=B),B||!j&&H},"t"),Y=c(function(L,T){if(X(L))return L.clone();var F=typeof T=="object"?T:{};return F.date=L,F.args=arguments,new k(F)},"w"),P=w;P.l=Z,P.i=X,P.w=function(L,T){return Y(L,{locale:T.$L,utc:T.$u,x:T.$x,$offset:T.$offset})};var k=(function(){function L(F){this.$L=Z(F.locale,null,!0),this.parse(F)}c(L,"M");var T=L.prototype;return T.parse=function(F){this.$d=(function(j){var B=j.date,G=j.utc;if(B===null)return new Date(NaN);if(P.u(B))return new Date;if(B instanceof Date)return new Date(B);if(typeof B=="string"&&!/Z$/i.test(B)){var ee=B.match(_);if(ee){var C=ee[2]-1||0,W=(ee[7]||"0").substring(0,3);return G?new Date(Date.UTC(ee[1],C,ee[3]||1,ee[4]||0,ee[5]||0,ee[6]||0,W)):new Date(ee[1],C,ee[3]||1,ee[4]||0,ee[5]||0,ee[6]||0,W)}}return new Date(B)})(F),this.$x=F.x||{},this.init()},T.init=function(){var F=this.$d;this.$y=F.getFullYear(),this.$M=F.getMonth(),this.$D=F.getDate(),this.$W=F.getDay(),this.$H=F.getHours(),this.$m=F.getMinutes(),this.$s=F.getSeconds(),this.$ms=F.getMilliseconds()},T.$utils=function(){return P},T.isValid=function(){return this.$d.toString()!==h},T.isSame=function(F,j){var B=Y(F);return this.startOf(j)<=B&&B<=this.endOf(j)},T.isAfter=function(F,j){return Y(F)<this.startOf(j)},T.isBefore=function(F,j){return this.endOf(j)<Y(F)},T.$g=function(F,j,B){return P.u(F)?this[j]:this.set(B,F)},T.unix=function(){return Math.floor(this.valueOf()/1e3)},T.valueOf=function(){return this.$d.getTime()},T.startOf=function(F,j){var B=this,G=!!P.u(j)||j,ee=P.p(F),C=c(function(Ct,Xt){var yr=P.w(B.$u?Date.UTC(B.$y,Xt,Ct):new Date(B.$y,Xt,Ct),B);return G?yr:yr.endOf(a)},"l"),W=c(function(Ct,Xt){return P.w(B.toDate()[Ct].apply(B.toDate("s"),(G?[0,0,0,0]:[23,59,59,999]).slice(Xt)),B)},"$"),q=this.$W,J=this.$M,ue=this.$D,me="set"+(this.$u?"UTC":"");switch(ee){case p:return G?C(1,0):C(31,11);case l:return G?C(1,J):C(0,J+1);case u:var he=this.$locale().weekStart||0,bt=(q<he?q+7:q)-he;return C(G?ue-bt:ue+(6-bt),J);case a:case g:return W(me+"Hours",0);case s:return W(me+"Minutes",1);case o:return W(me+"Seconds",2);case i:return W(me+"Milliseconds",3);default:return this.clone()}},T.endOf=function(F){return this.startOf(F,!1)},T.$set=function(F,j){var B,G=P.p(F),ee="set"+(this.$u?"UTC":""),C=(B={},B[a]=ee+"Date",B[g]=ee+"Date",B[l]=ee+"Month",B[p]=ee+"FullYear",B[s]=ee+"Hours",B[o]=ee+"Minutes",B[i]=ee+"Seconds",B[n]=ee+"Milliseconds",B)[G],W=G===a?this.$D+(j-this.$W):j;if(G===l||G===p){var q=this.clone().set(g,1);q.$d[C](W),q.init(),this.$d=q.set(g,Math.min(this.$D,q.daysInMonth())).$d}else C&&this.$d[C](W);return this.init(),this},T.set=function(F,j){return this.clone().$set(F,j)},T.get=function(F){return this[P.p(F)]()},T.add=function(F,j){var B,G=this;F=Number(F);var ee=P.p(j),C=c(function(J){var ue=Y(G);return P.w(ue.date(ue.date()+Math.round(J*F)),G)},"y");if(ee===l)return this.set(l,this.$M+F);if(ee===p)return this.set(p,this.$y+F);if(ee===a)return C(1);if(ee===u)return C(7);var W=(B={},B[o]=e,B[s]=r,B[i]=t,B)[ee]||1,q=this.$d.getTime()+F*W;return P.w(q,this)},T.subtract=function(F,j){return this.add(-1*F,j)},T.format=function(F){var j=this,B=this.$locale();if(!this.isValid())return B.invalidDate||h;var G=F||"YYYY-MM-DDTHH:mm:ssZ",ee=P.z(this),C=this.$H,W=this.$m,q=this.$M,J=B.weekdays,ue=B.months,me=B.meridiem,he=c(function(Xt,yr,Dr,vr){return Xt&&(Xt[yr]||Xt(j,G))||Dr[yr].slice(0,vr)},"h"),bt=c(function(Xt){return P.s(C%12||12,Xt,"0")},"d"),Ct=me||function(Xt,yr,Dr){var vr=Xt<12?"AM":"PM";return Dr?vr.toLowerCase():vr};return G.replace(A,(function(Xt,yr){return yr||(function(Dr){switch(Dr){case"YY":return String(j.$y).slice(-2);case"YYYY":return P.s(j.$y,4,"0");case"M":return q+1;case"MM":return P.s(q+1,2,"0");case"MMM":return he(B.monthsShort,q,ue,3);case"MMMM":return he(ue,q);case"D":return j.$D;case"DD":return P.s(j.$D,2,"0");case"d":return String(j.$W);case"dd":return he(B.weekdaysMin,j.$W,J,2);case"ddd":return he(B.weekdaysShort,j.$W,J,3);case"dddd":return J[j.$W];case"H":return String(C);case"HH":return P.s(C,2,"0");case"h":return bt(1);case"hh":return bt(2);case"a":return Ct(C,W,!0);case"A":return Ct(C,W,!1);case"m":return String(W);case"mm":return P.s(W,2,"0");case"s":return String(j.$s);case"ss":return P.s(j.$s,2,"0");case"SSS":return P.s(j.$ms,3,"0");case"Z":return ee}return null})(Xt)||ee.replace(":","")}))},T.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},T.diff=function(F,j,B){var G,ee=this,C=P.p(j),W=Y(F),q=(W.utcOffset()-this.utcOffset())*e,J=this-W,ue=c(function(){return P.m(ee,W)},"D");switch(C){case p:G=ue()/12;break;case l:G=ue();break;case d:G=ue()/3;break;case u:G=(J-q)/6048e5;break;case a:G=(J-q)/864e5;break;case s:G=J/r;break;case o:G=J/e;break;case i:G=J/t;break;default:G=J}return B?G:P.a(G)},T.daysInMonth=function(){return this.endOf(l).$D},T.$locale=function(){return $[this.$L]},T.locale=function(F,j){if(!F)return this.$L;var B=this.clone(),G=Z(F,j,!0);return G&&(B.$L=G),B},T.clone=function(){return P.w(this.$d,this)},T.toDate=function(){return new Date(this.valueOf())},T.toJSON=function(){return this.isValid()?this.toISOString():null},T.toISOString=function(){return this.$d.toISOString()},T.toString=function(){return this.$d.toUTCString()},L})(),M=k.prototype;return Y.prototype=M,[["$ms",n],["$s",i],["$m",o],["$H",s],["$W",a],["$M",l],["$y",p],["$D",g]].forEach((function(L){M[L[1]]=function(T){return this.$g(T,L[0],L[1])}})),Y.extend=function(L,T){return L.$i||(L(T,k,Y),L.$i=!0),Y},Y.locale=Z,Y.isDayjs=X,Y.unix=function(L){return Y(1e3*L)},Y.en=$[H],Y.Ls=$,Y.p={},Y}))});var z1={};fd(z1,{endClient:()=>Zt,ftpSftp:()=>L1,getClient:()=>Ft,getProtocolBackwardCompatibility:()=>Dt});module.exports=KE(z1);var GE=Object.freeze({status:"aborted"});function xe(t,e,r){function n(a,u){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,u);let l=s.prototype,d=Object.keys(l);for(let p=0;p<d.length;p++){let g=d[p];g in a||(a[g]=l[g].bind(a))}}c(n,"init");let i=r?.Parent??Object;class o extends i{static{c(this,"Definition")}}Object.defineProperty(o,"name",{value:t});function s(a){var u;let l=r?.Parent?new o:this;n(l,a),(u=l._zod).deferred??(u.deferred=[]);for(let d of l._zod.deferred)d();return l}return c(s,"_"),Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:c(a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t),"value")}),Object.defineProperty(s,"name",{value:t}),s}c(xe,"$constructor");var Xr=class extends Error{static{c(this,"$ZodAsyncError")}constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ls=class extends Error{static{c(this,"$ZodEncodeError")}constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}},Nc={};function fn(t){return t&&Object.assign(Nc,t),Nc}c(fn,"config");function $c(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,i])=>e.indexOf(+n)===-1).map(([n,i])=>i)}c($c,"getEnumValues");function hd(t,e){return typeof e=="bigint"?e.toString():e}c(hd,"jsonStringifyReplacer");function Ms(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}c(Ms,"cached");function gd(t){return t==null}c(gd,"nullish");function Fs(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}c(Fs,"cleanRegex");var pd=Symbol("evaluating");function er(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==pd)return n===void 0&&(n=pd,n=r()),n},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}c(er,"defineLazy");var Dc="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function bo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}c(bo,"isObject");var ZE=Ms(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function md(t){if(bo(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(bo(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}c(md,"isPlainObject");var _d=new Set(["string","number","symbol"]);function wi(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c(wi,"escapeRegex");function Hs(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}c(Hs,"clone");function Rt(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:c(()=>e,"error")};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:c(()=>e.error,"error")}:e}c(Rt,"normalizeParams");function yd(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}c(yd,"optionalKeys");var Ed={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Pi(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}c(Pi,"aborted");function wn(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}c(wn,"prefixIssues");function zs(t){return typeof t=="string"?t:t?.message}c(zs,"unwrapMessage");function Pn(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let i=zs(t.inst?._zod.def?.error?.(t))??zs(e?.error?.(t))??zs(r.customError?.(t))??zs(r.localeError?.(t))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}c(Pn,"finalizeIssue");function Ad(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}c(Ad,"getLengthableOrigin");function Bc(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}c(Bc,"issue");var bd=c((t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,hd,2),Object.defineProperty(t,"toString",{value:c(()=>t.message,"value"),enumerable:!1})},"initializer"),xd=xe("$ZodError",bd),xo=xe("$ZodError",bd,{Parent:Error});var XE=c(t=>(e,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Xr;if(s.issues.length){let a=new(i?.Err??t)(s.issues.map(u=>Pn(u,o,fn())));throw Dc(a,i?.callee),a}return s.value},"_parse"),js=XE(xo),JE=c(t=>async(e,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(i?.Err??t)(s.issues.map(u=>Pn(u,o,fn())));throw Dc(a,i?.callee),a}return s.value},"_parseAsync"),Ws=JE(xo),eA=c(t=>(e,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Xr;return o.issues.length?{success:!1,error:new(t??xd)(o.issues.map(s=>Pn(s,i,fn())))}:{success:!0,data:o.value}},"_safeParse"),Io=eA(xo),tA=c(t=>async(e,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=e._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(s=>Pn(s,i,fn())))}:{success:!0,data:o.value}},"_safeParseAsync"),vo=tA(xo);var rA="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",nA=new RegExp(`^${rA}$`);var Id=c(t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},"string"),vd=/^-?\d+n?$/,Sd=/^-?\d+$/,Uc=/^-?\d+(?:\.\d+)?$/,wd=/^(?:true|false)$/i;var Tn=xe("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),iA={number:"number",bigint:"bigint",object:"date"};var Pd=xe("$ZodCheckGreaterThan",(t,e)=>{Tn.init(t,e);let r=iA[typeof e.value];t._zod.onattach.push(n=>{let i=n._zod.bag,o=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}});var Td=xe("$ZodCheckNumberFormat",(t,e)=>{Tn.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[i,o]=Ed[e.format];t._zod.onattach.push(s=>{let a=s._zod.bag;a.format=e.format,a.minimum=i,a.maximum=o,r&&(a.pattern=Sd)}),t._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:t,continue:!e.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:t,continue:!e.abort})}});var kd=xe("$ZodCheckMinLength",(t,e)=>{var r;Tn.init(t,e),(r=t._zod.def).when??(r.when=n=>{let i=n.value;return!gd(i)&&i.length!==void 0}),t._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let i=n.value;if(i.length>=e.minimum)return;let s=Ad(i);n.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}});var Lc=xe("$ZodCheckStringFormat",(t,e)=>{var r,n;Tn.init(t,e),t._zod.onattach.push(i=>{let o=i._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Cd=xe("$ZodCheckRegex",(t,e)=>{Lc.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}});var Nd={major:4,minor:3,patch:6};var Vt=xe("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Nd;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let i of n)for(let o of i._zod.onattach)o(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let i=c((s,a,u)=>{let l=Pi(s),d;for(let p of a){if(p._zod.def.when){if(!p._zod.def.when(s))continue}else if(l)continue;let g=s.issues.length,h=p._zod.check(s);if(h instanceof Promise&&u?.async===!1)throw new Xr;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,s.issues.length!==g&&(l||(l=Pi(s,g)))});else{if(s.issues.length===g)continue;l||(l=Pi(s,g))}}return d?d.then(()=>s):s},"runChecks"),o=c((s,a,u)=>{if(Pi(s))return s.aborted=!0,s;let l=i(a,n,u);if(l instanceof Promise){if(u.async===!1)throw new Xr;return l.then(d=>t._zod.parse(d,u))}return t._zod.parse(l,u)},"handleCanaryResult");t._zod.run=(s,a)=>{if(a.skipChecks)return t._zod.parse(s,a);if(a.direction==="backward"){let l=t._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(d=>o(d,s,a)):o(l,s,a)}let u=t._zod.parse(s,a);if(u instanceof Promise){if(a.async===!1)throw new Xr;return u.then(l=>i(l,n,a))}return i(u,n,a)}}er(t,"~standard",()=>({validate:c(i=>{try{let o=Io(t,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return vo(t,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},"validate"),vendor:"zod",version:1}))}),Vs=xe("$ZodString",(t,e)=>{Vt.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Id(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),zc=xe("$ZodStringFormat",(t,e)=>{Lc.init(t,e),Vs.init(t,e)});var Ud=xe("$ZodURL",(t,e)=>{zc.init(t,e),t._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}});var Mc=xe("$ZodNumber",(t,e)=>{Vt.init(t,e),t._zod.pattern=t._zod.bag.pattern??Uc,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...o?{received:o}:{}}),r}}),Ld=xe("$ZodNumberFormat",(t,e)=>{Td.init(t,e),Mc.init(t,e)}),Fc=xe("$ZodBoolean",(t,e)=>{Vt.init(t,e),t._zod.pattern=wd,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:t}),r}}),zd=xe("$ZodBigInt",(t,e)=>{Vt.init(t,e),t._zod.pattern=vd,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:t}),r}});var Md=xe("$ZodAny",(t,e)=>{Vt.init(t,e),t._zod.parse=r=>r}),Fd=xe("$ZodUnknown",(t,e)=>{Vt.init(t,e),t._zod.parse=r=>r});var Hd=xe("$ZodVoid",(t,e)=>{Vt.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"void",code:"invalid_type",input:i,inst:t}),r}}),jd=xe("$ZodDate",(t,e)=>{Vt.init(t,e),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:t}),r}});function Od(t,e,r){t.issues.length&&e.issues.push(...wn(r,t.issues)),e.value[r]=t.value}c(Od,"handleArrayResult");var Wd=xe("$ZodArray",(t,e)=>{Vt.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let a=i[s],u=e.element._zod.run({value:a,issues:[]},n);u instanceof Promise?o.push(u.then(l=>Od(l,r,s))):Od(u,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function Qs(t,e,r,n,i){if(t.issues.length){if(i&&!(r in n))return;e.issues.push(...wn(r,t.issues))}t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}c(Qs,"handlePropertyResult");function oA(t){let e=Object.keys(t.shape);for(let n of e)if(!t.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=yd(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}c(oA,"normalizeDef");function sA(t,e,r,n,i,o){let s=[],a=i.keySet,u=i.catchall._zod,l=u.def.type,d=u.optout==="optional";for(let p in e){if(a.has(p))continue;if(l==="never"){s.push(p);continue}let g=u.run({value:e[p],issues:[]},n);g instanceof Promise?t.push(g.then(h=>Qs(h,r,p,e,d))):Qs(g,r,p,e,d)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:e,inst:o}),t.length?Promise.all(t).then(()=>r):r}c(sA,"handleCatchall");var qd=xe("$ZodObject",(t,e)=>{if(Vt.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let a=e.shape;Object.defineProperty(e,"shape",{get:c(()=>{let u={...a};return Object.defineProperty(e,"shape",{value:u}),u},"get")})}let n=Ms(()=>oA(e));er(t._zod,"propValues",()=>{let a=e.shape,u={};for(let l in a){let d=a[l]._zod;if(d.values){u[l]??(u[l]=new Set);for(let p of d.values)u[l].add(p)}}return u});let i=bo,o=e.catchall,s;t._zod.parse=(a,u)=>{s??(s=n.value);let l=a.value;if(!i(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:t}),a;a.value={};let d=[],p=s.shape;for(let g of s.keys){let h=p[g],_=h._zod.optout==="optional",A=h._zod.run({value:l[g],issues:[]},u);A instanceof Promise?d.push(A.then(b=>Qs(b,a,g,l,_))):Qs(A,a,g,l,_)}return o?sA(d,l,a,u,n.value,t):d.length?Promise.all(d).then(()=>a):a}});function $d(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;let i=t.filter(o=>!Pi(o));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>Pn(s,n,fn())))}),e)}c($d,"handleUnionResults");var Hc=xe("$ZodUnion",(t,e)=>{Vt.init(t,e),er(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),er(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),er(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),er(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){let i=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Fs(o.source)).join("|")})$`)}});let r=e.options.length===1,n=e.options[0]._zod.run;t._zod.parse=(i,o)=>{if(r)return n(i,o);let s=!1,a=[];for(let u of e.options){let l=u._zod.run({value:i.value,issues:[]},o);if(l instanceof Promise)a.push(l),s=!0;else{if(l.issues.length===0)return l;a.push(l)}}return s?Promise.all(a).then(u=>$d(u,i,t,o)):$d(a,i,t,o)}});var Qd=xe("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Hc.init(t,e);let r=t._zod.parse;er(t._zod,"propValues",()=>{let i={};for(let o of e.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let[a,u]of Object.entries(s)){i[a]||(i[a]=new Set);for(let l of u)i[a].add(l)}}return i});let n=Ms(()=>{let i=e.options,o=new Map;for(let s of i){let a=s._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let u of a){if(o.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);o.set(u,s)}}return o});t._zod.parse=(i,o)=>{let s=i.value;if(!bo(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:t}),i;let a=n.value.get(s?.[e.discriminator]);return a?a._zod.run(i,o):e.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:s,path:[e.discriminator],inst:t}),i)}});var Vd=xe("$ZodRecord",(t,e)=>{Vt.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!md(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:t}),r;let o=[],s=e.keyType._zod.values;if(s){r.value={};let a=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);let d=e.valueType._zod.run({value:i[l],issues:[]},n);d instanceof Promise?o.push(d.then(p=>{p.issues.length&&r.issues.push(...wn(l,p.issues)),r.value[l]=p.value})):(d.issues.length&&r.issues.push(...wn(l,d.issues)),r.value[l]=d.value)}let u;for(let l in i)a.has(l)||(u=u??[],u.push(l));u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:t,keys:u})}else{r.value={};for(let a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let u=e.keyType._zod.run({value:a,issues:[]},n);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Uc.test(a)&&u.issues.length){let p=e.keyType._zod.run({value:Number(a),issues:[]},n);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(u=p)}if(u.issues.length){e.mode==="loose"?r.value[a]=i[a]:r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>Pn(p,n,fn())),input:a,path:[a],inst:t});continue}let d=e.valueType._zod.run({value:i[a],issues:[]},n);d instanceof Promise?o.push(d.then(p=>{p.issues.length&&r.issues.push(...wn(a,p.issues)),r.value[u.value]=p.value})):(d.issues.length&&r.issues.push(...wn(a,d.issues)),r.value[u.value]=d.value)}}return o.length?Promise.all(o).then(()=>r):r}});var Kd=xe("$ZodEnum",(t,e)=>{Vt.init(t,e);let r=$c(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(i=>_d.has(typeof i)).map(i=>typeof i=="string"?wi(i):i.toString()).join("|")})$`),t._zod.parse=(i,o)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:r,input:s,inst:t}),i}}),Gd=xe("$ZodLiteral",(t,e)=>{if(Vt.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?wi(n):n?wi(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,i)=>{let o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),n}});var Zd=xe("$ZodTransform",(t,e)=>{Vt.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ls(t.constructor.name);let i=e.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(r.value=s,r));if(i instanceof Promise)throw new Xr;return r.value=i,r}});function Dd(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}c(Dd,"handleOptionalResult");var Yd=xe("$ZodOptional",(t,e)=>{Vt.init(t,e),t._zod.optin="optional",t._zod.optout="optional",er(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),er(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fs(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let i=e.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>Dd(o,r.value)):Dd(i,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}});var Xd=xe("$ZodNullable",(t,e)=>{Vt.init(t,e),er(t._zod,"optin",()=>e.innerType._zod.optin),er(t._zod,"optout",()=>e.innerType._zod.optout),er(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fs(r.source)}|null)$`):void 0}),er(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)});var Jd=xe("$ZodPipe",(t,e)=>{Vt.init(t,e),er(t._zod,"values",()=>e.in._zod.values),er(t._zod,"optin",()=>e.in._zod.optin),er(t._zod,"optout",()=>e.out._zod.optout),er(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let o=e.out._zod.run(r,n);return o instanceof Promise?o.then(s=>qs(s,e.in,n)):qs(o,e.in,n)}let i=e.in._zod.run(r,n);return i instanceof Promise?i.then(o=>qs(o,e.out,n)):qs(i,e.out,n)}});function qs(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},r)}c(qs,"handlePipeResult");var ep=xe("$ZodCustom",(t,e)=>{Tn.init(t,e),Vt.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,i=e.fn(n);if(i instanceof Promise)return i.then(o=>Bd(o,r,n,t));Bd(i,r,n,t)}});function Bd(t,e,r,n){if(!t){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),e.issues.push(Bc(i))}}c(Bd,"handleRefineResult");var rp;var jc=class{static{c(this,"$ZodRegistry")}constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function np(){return new jc}c(np,"registry");(rp=globalThis).__zod_globalRegistry??(rp.__zod_globalRegistry=np());var Wc=globalThis.__zod_globalRegistry;function ip(t,e){return new t({type:"string",...Rt(e)})}c(ip,"_string");function op(t,e){return new t({type:"string",coerce:!0,...Rt(e)})}c(op,"_coercedString");function sp(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Rt(e)})}c(sp,"_url");function ap(t,e){return new t({type:"number",checks:[],...Rt(e)})}c(ap,"_number");function cp(t,e){return new t({type:"number",coerce:!0,checks:[],...Rt(e)})}c(cp,"_coercedNumber");function up(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Rt(e)})}c(up,"_int");function lp(t,e){return new t({type:"boolean",...Rt(e)})}c(lp,"_boolean");function fp(t,e){return new t({type:"boolean",coerce:!0,...Rt(e)})}c(fp,"_coercedBoolean");function dp(t,e){return new t({type:"bigint",coerce:!0,...Rt(e)})}c(dp,"_coercedBigint");function pp(t){return new t({type:"any"})}c(pp,"_any");function hp(t){return new t({type:"unknown"})}c(hp,"_unknown");function gp(t,e){return new t({type:"void",...Rt(e)})}c(gp,"_void");function mp(t,e){return new t({type:"date",coerce:!0,...Rt(e)})}c(mp,"_coercedDate");function Ks(t,e){return new Pd({check:"greater_than",...Rt(e),value:t,inclusive:!0})}c(Ks,"_gte");function qr(t,e){return new kd({check:"min_length",...Rt(e),minimum:t})}c(qr,"_minLength");function kn(t,e){return new Cd({check:"string_format",format:"regex",...Rt(e),pattern:t})}c(kn,"_regex");function _p(t,e,r){let n=Rt(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}c(_p,"_custom");var tr=xe("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");Vt.init(t,e),t.def=e,t.type=e.type,t.parse=(r,n)=>js(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Io(t,r,n),t.parseAsync=async(r,n)=>Ws(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>vo(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),t.with=t.check,t.clone=(r,n)=>Hs(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.apply=r=>r(t)}),Zs=xe("ZodMiniString",(t,e)=>{Vs.init(t,e),tr.init(t,e)});function v(t){return ip(Zs,t)}c(v,"string");var yp=xe("ZodMiniStringFormat",(t,e)=>{zc.init(t,e),Zs.init(t,e)});var EA=xe("ZodMiniURL",(t,e)=>{Ud.init(t,e),yp.init(t,e)});function Ep(t){return sp(EA,t)}c(Ep,"url");var Ys=xe("ZodMiniNumber",(t,e)=>{Mc.init(t,e),tr.init(t,e)});function Ar(t){return ap(Ys,t)}c(Ar,"number");var AA=xe("ZodMiniNumberFormat",(t,e)=>{Ld.init(t,e),Ys.init(t,e)});function Ap(t){return up(AA,t)}c(Ap,"int");var qc=xe("ZodMiniBoolean",(t,e)=>{Fc.init(t,e),tr.init(t,e)});function It(t){return lp(qc,t)}c(It,"boolean");var bp=xe("ZodMiniBigInt",(t,e)=>{zd.init(t,e),tr.init(t,e)});var bA=xe("ZodMiniAny",(t,e)=>{Md.init(t,e),tr.init(t,e)});function wo(){return pp(bA)}c(wo,"any");var xA=xe("ZodMiniUnknown",(t,e)=>{Fd.init(t,e),tr.init(t,e)});function We(){return hp(xA)}c(We,"unknown");var IA=xe("ZodMiniVoid",(t,e)=>{Hd.init(t,e),tr.init(t,e)});function xp(t){return gp(IA,t)}c(xp,"_void");var Ip=xe("ZodMiniDate",(t,e)=>{jd.init(t,e),tr.init(t,e)});var vA=xe("ZodMiniArray",(t,e)=>{Wd.init(t,e),tr.init(t,e)});function Xe(t,e){return new vA({type:"array",element:t,...Rt(e)})}c(Xe,"array");var SA=xe("ZodMiniObject",(t,e)=>{qd.init(t,e),tr.init(t,e),er(t,"shape",()=>e.shape)});function D(t,e){let r={type:"object",shape:t??{},...Rt(e)};return new SA(r)}c(D,"object");var wA=xe("ZodMiniUnion",(t,e)=>{Hc.init(t,e),tr.init(t,e)});function Je(t,e){return new wA({type:"union",options:t,...Rt(e)})}c(Je,"union");var PA=xe("ZodMiniDiscriminatedUnion",(t,e)=>{Qd.init(t,e),tr.init(t,e)});function Cn(t,e,r){return new PA({type:"union",options:e,discriminator:t,...Rt(r)})}c(Cn,"discriminatedUnion");var TA=xe("ZodMiniRecord",(t,e)=>{Vd.init(t,e),tr.init(t,e)});function qe(t,e,r){return new TA({type:"record",keyType:t,valueType:e,...Rt(r)})}c(qe,"record");var kA=xe("ZodMiniEnum",(t,e)=>{Kd.init(t,e),tr.init(t,e),t.options=Object.values(e.entries)});function ot(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new kA({type:"enum",entries:r,...Rt(e)})}c(ot,"_enum");var CA=xe("ZodMiniLiteral",(t,e)=>{Gd.init(t,e),tr.init(t,e)});function Ce(t,e){return new CA({type:"literal",values:Array.isArray(t)?t:[t],...Rt(e)})}c(Ce,"literal");var RA=xe("ZodMiniTransform",(t,e)=>{Zd.init(t,e),tr.init(t,e)});function Rn(t){return new RA({type:"transform",transform:t})}c(Rn,"transform");var NA=xe("ZodMiniOptional",(t,e)=>{Yd.init(t,e),tr.init(t,e)});function oe(t){return new NA({type:"optional",innerType:t})}c(oe,"optional");var OA=xe("ZodMiniNullable",(t,e)=>{Xd.init(t,e),tr.init(t,e)});function Po(t){return new OA({type:"nullable",innerType:t})}c(Po,"nullable");var $A=xe("ZodMiniPipe",(t,e)=>{Jd.init(t,e),tr.init(t,e)});function Nn(t,e){return new $A({type:"pipe",in:t,out:e})}c(Nn,"pipe");var DA=xe("ZodMiniCustom",(t,e)=>{ep.init(t,e),tr.init(t,e)});function Xs(t,e){return _p(DA,t??(()=>!0),e)}c(Xs,"custom");var To={};fd(To,{bigint:()=>FA,boolean:()=>MA,date:()=>HA,number:()=>zA,string:()=>LA});function LA(t){return op(Zs,t)}c(LA,"string");function zA(t){return cp(Ys,t)}c(zA,"number");function MA(t){return fp(qc,t)}c(MA,"boolean");function FA(t){return dp(bp,t)}c(FA,"bigint");function HA(t){return mp(Ip,t)}c(HA,"date");var Vc=D({retryOnFailure:D({defaultValue:oe(It()),hide:oe(It())}),continueOnFailure:D({defaultValue:oe(It()),hide:oe(It())})}),Qc=class{constructor(e,r,n,i,o,s,a,u,l,d,p){this.name=e;this.displayName=r;this.description=n;this.props=i;this.run=o;this.test=s;this.requireAuth=a;this.errorHandlingOptions=u;this.outputSchema=l;this.audience=d;this.aiMetadata=p}static{c(this,"IAction")}},gr=c(t=>new Qc(t.name,t.displayName,t.description,t.props,t.run,t.test??t.run,t.requireAuth??!0,t.errorHandlingOptions??{continueOnFailure:{defaultValue:!1},retryOnFailure:{defaultValue:!1}},t.outputSchema,t.audience,t.aiMetadata),"createAction");var At=D({displayName:v(),description:oe(v())}),tt=c((t,e)=>D({type:Ce(e),required:It(),defaultValue:oe(wo())}),"TPropertyValue");var Rr=D({...At.shape,...tt(v(),"SHORT_TEXT").shape}),dn=D({...At.shape,...tt(v(),"LONG_TEXT").shape});var Sp=D({label:v(),value:We()}),Js=D({disabled:oe(It()),placeholder:oe(v()),options:Xe(Sp)});var Nr=D({...At.shape,options:Js,...tt(We(),"STATIC_DROPDOWN").shape}),pn=D({...At.shape,options:Js,...tt(Xe(We()),"STATIC_MULTI_SELECT_DROPDOWN").shape});var Kc=D({...At.shape,...tt(We(),"DROPDOWN").shape,refreshers:Xe(v())}),ko=D({...At.shape,...tt(Xe(We()),"MULTI_SELECT_DROPDOWN").shape,refreshers:Xe(v())});var hn=D({...At.shape,...tt(It(),"CHECKBOX").shape});var gn=D({...At.shape,...tt(Ar(),"NUMBER").shape});var Co=D({...At.shape,streaming:oe(It()),...tt(We(),"FILE").shape});var Ro=D({...At.shape,...tt(v(),"DATE_TIME").shape});var wp=qe(v(),Je([Rr,dn,Nr,ko,pn,hn,gn,Co,Ro])),No=D({...At.shape,properties:wp,...tt(Xe(We()),"ARRAY").shape});var Oo=D({...At.shape,...tt(Je([qe(v(),We())]),"JSON").shape});var Pp=Je([Rr,Nr,Oo,No,pn]),WA=qe(v(),Pp),Gc=D({refreshers:Xe(v()),...At.shape,...tt(We(),"DYNAMIC").shape});var ea=D({...At.shape,...tt(xp(),"MARKDOWN").shape});var $o=(r=>(r.ARCHIVE="ARCHIVE",r.REGISTRY="REGISTRY",r))($o||{}),Ti=(r=>(r.CUSTOM="CUSTOM",r.OFFICIAL="OFFICIAL",r))(Ti||{}),ki=(I=>(I.ARTIFICIAL_INTELLIGENCE="ARTIFICIAL_INTELLIGENCE",I.COMMUNICATION="COMMUNICATION",I.COMMERCE="COMMERCE",I.CORE="CORE",I.UNIVERSAL_AI="UNIVERSAL_AI",I.FLOW_CONTROL="FLOW_CONTROL",I.BUSINESS_INTELLIGENCE="BUSINESS_INTELLIGENCE",I.ACCOUNTING="ACCOUNTING",I.PRODUCTIVITY="PRODUCTIVITY",I.CONTENT_AND_FILES="CONTENT_AND_FILES",I.DEVELOPER_TOOLS="DEVELOPER_TOOLS",I.CUSTOMER_SUPPORT="CUSTOMER_SUPPORT",I.FORMS_AND_SURVEYS="FORMS_AND_SURVEYS",I.HUMAN_RESOURCES="HUMAN_RESOURCES",I.PAYMENT_PROCESSING="PAYMENT_PROCESSING",I.MARKETING="MARKETING",I.SALES_AND_CRM="SALES_AND_CRM",I))(ki||{});var Do=(r=>(r.AUTHORIZATION_CODE="authorization_code",r.CLIENT_CREDENTIALS="client_credentials",r))(Do||{}),Zc="both_client_credentials_and_authorization_code";var On=(i=>(i.POLLING="POLLING",i.WEBHOOK="WEBHOOK",i.APP_WEBHOOK="APP_WEBHOOK",i.MANUAL="MANUAL",i))(On||{}),Bo=(o=>(o.NONE="NONE",o.HEADER_PRESENT="HEADER_PRESENT",o.QUERY_PRESENT="QUERY_PRESENT",o.BODY_PARAM_PRESENT="BODY_PARAM_PRESENT",o.HEAD_REQUEST="HEAD_REQUEST",o))(Bo||{}),qA=D({strategy:ot(Bo),paramName:oe(v())}),Uo=(r=>(r.SIMULATION="SIMULATION",r.TEST_FUNCTION="TEST_FUNCTION",r))(Uo||{});var ta=(r=>(r.WEBSOCKET="WEBSOCKET",r.NONE="NONE",r))(ta||{}),Tp=D({status:oe(Ar()),body:oe(We()),headers:oe(qe(v(),v()))}),kp=D({type:Ce("DELAY"),resumeDateTime:v(),requestIdToReply:oe(v()),handlerId:oe(v()),streamStepProgress:oe(ot(ta))}),Cp=D({type:Ce("WEBHOOK"),requestId:v(),requestIdToReply:oe(v()),response:Tp,handlerId:oe(v()),streamStepProgress:oe(ot(ta))}),QA=Je([kp,Cp]);var VA=D({body:We(),rawBody:oe(We()),headers:qe(v(),v()),queryParams:qe(v(),v())});function ar(t){return t==null}c(ar,"isNil");var Yc=Er(require("crypto"),1);var KA=128,ti,Ci,GA=c(t=>{!ti||ti.length<t?(ti=Buffer.allocUnsafe(t*KA),Yc.default.randomFillSync(ti),Ci=0):Ci+t>ti.length&&(Yc.default.randomFillSync(ti),Ci=0),Ci+=t},"fillPool"),ZA=c(t=>(GA(t|=0),ti.subarray(Ci-t,Ci)),"random"),YA=c((t,e,r)=>{let n=(2<<31-Math.clz32(t.length-1|1))-1,i=Math.ceil(1.6*n*e/t.length);return(o=e)=>{let s="";for(;;){let a=r(i),u=i;for(;u--;)if(s+=t[a[u]&n]||"",s.length===o)return s}}},"customRandom"),Np=c((t,e=21)=>YA(t,e,ZA),"customAlphabet");var XA="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Op=21,E6=v().check(kn(new RegExp(`^[0-9a-zA-Z]{${Op}}$`))),JA=Np(XA,Op);var $n=Nn(Rn(t=>t instanceof Date?t.toISOString():t),v()),Ur={id:v(),created:$n,updated:$n},Ut=c(t=>oe(Po(t)),"Nullable");function Xc(t){return oe(Po(ot(t)))}c(Xc,"NullableEnum");var x6=Nn(Rn(t=>t==="true"||t===!0?!0:t==="false"||t===!1?!1:void 0),oe(It())),ra=c(t=>Nn(Rn(e=>Array.isArray(e)?e:e!==void 0?[e]:void 0),oe(Xe(t))),"OptionalArrayFromQuery");var S6=qe(v(),We());var Lo=(d=>(d.OPENAI="openai",d.OPENROUTER="openrouter",d.ANTHROPIC="anthropic",d.AZURE="azure",d.GOOGLE="google",d.ACTIVEPIECES="activepieces",d.CLOUDFLARE_GATEWAY="cloudflare-gateway",d.CUSTOM="custom",d.BEDROCK="bedrock",d.MISTRAL="mistral",d))(Lo||{});var U6=v().check(kn(/^#[0-9A-Fa-f]{6}$/));var z6=D({filename:v(),data:We(),type:Ce("file"),mimetype:oe(v())});var e0=Er(Dp());var Q6=D({...Ur,name:v(),permissions:Xe(v()),platformId:Ut(v()),type:v(),userCount:oe(Ar())});var Bp=(n=>(n.AGENT_DECIDE="agent-decide",n.CHOOSE_YOURSELF="choose-yourself",n.LEAVE_EMPTY="leave-empty",n))(Bp||{}),Jc=(r=>(r.FILE="FILE",r.TABLE="TABLE",r))(Jc||{}),eu=(n=>(n.SSE="sse",n.STREAMABLE_HTTP="streamable-http",n.SIMPLE_HTTP="http",n))(eu||{});var tu=(n=>(n.TEXT="text",n.NUMBER="number",n.BOOLEAN="boolean",n))(tu||{});var ru=(r=>(r.IN_PROGRESS="in-progress",r.COMPLETED="completed",r))(ru||{});var t0=D({mode:ot(Bp),value:We()}),r0=D({auth:oe(v()),fields:qe(v(),t0)}),n0=D({pieceName:v(),pieceVersion:v(),actionName:v(),predefinedInput:oe(r0)}),i0=D({type:Ce("PIECE"),toolName:v().check(qr(1)),pieceMetadata:n0}),o0=D({type:Ce("none")}),s0=D({type:Ce("access_token"),accessToken:v()}),a0=D({type:Ce("api_key"),apiKey:v(),apiKeyHeader:v()}),c0=D({type:Ce("headers"),headers:qe(v(),v())}),u0=Cn("type",[o0,s0,a0,c0]),Up=D({type:Ce("FLOW"),toolName:v().check(qr(1)),externalFlowId:v(),flowDisplayName:oe(v())}),Lp=D({type:Ce("MCP"),toolName:v().check(qr(1)),serverUrl:Ep(),protocol:ot(eu),auth:u0}),zp=D({type:Ce("KNOWLEDGE_BASE"),toolName:v().check(qr(1)),sourceType:ot(Jc),sourceId:v(),sourceName:v()}),l0=Cn("type",[i0,Up,Lp,zp]),f0=D({displayName:v(),description:oe(v()),type:ot(tu)}),Mp=D({type:Ce("MARKDOWN"),markdown:v()}),Ri={type:Ce("TOOL_CALL"),input:Ut(qe(v(),We())),output:oe(We()),toolName:v(),status:ot(ru),toolCallId:v(),startTime:v(),endTime:oe(v())},IB=D(Ri),Fp=Cn("toolCallType",[D({...Ri,toolCallType:Ce("PIECE"),pieceName:v(),pieceVersion:v(),actionName:v()}),D({...Ri,toolCallType:Ce("FLOW"),displayName:v(),externalFlowId:v()}),D({...Ri,toolCallType:Ce("MCP"),displayName:v(),serverUrl:v()}),D({...Ri,toolCallType:Ce("KNOWLEDGE_BASE"),displayName:v(),sourceType:v()}),D({...Ri,toolCallType:Ce("UNKNOWN"),displayName:v()})]),d0=Je([Mp,Fp]);var nu=(r=>(r.IMAGE="image",r.TEXT="text",r))(nu||{}),mn=D({apiKey:v()}),p0=mn,h0=D({apiKey:v(),apiKeyHash:v()}),g0=mn,m0=mn,_0=mn,y0=mn,E0=mn,A0=mn,b0=mn,Qp=D({accessKeyId:v().check(qr(1)),secretAccessKey:v().check(qr(1))}),x0=D({}),I0=D({}),v0=D({}),S0=D({}),w0=D({}),P0=D({}),Vp=D({modelId:v(),modelName:v(),modelType:ot(nu)}),Kp=D({apiKeyHeader:v(),baseUrl:v(),models:Xe(Vp),defaultHeaders:oe(qe(v(),v()))}),Gp=D({accountId:v(),gatewayId:v(),models:Xe(Vp),vertexProject:oe(v()),vertexRegion:oe(v())}),Zp=D({resourceName:v(),apiVersion:Nn(Rn(t=>typeof t=="string"&&t.trim().length===0?void 0:t),oe(v()))}),Yp=D({region:v().check(qr(1))}),T0=Je([p0,_0,y0,E0,A0,m0,g0,h0,Qp,b0]),Xp=Je([Kp,Gp,Zp,Yp,x0,v0,S0,w0,I0,P0]),k0=D({id:v(),name:v(),type:ot(nu)}),C0=D({id:v(),name:v(),provider:ot(Lo),config:Xp,enabledForChat:It()}),R0=D({provider:ot(Lo),config:Xp,auth:T0,platformId:v()});var PB={openai:"openai",anthropic:"anthropic","google-ai-studio":"google","google-vertex-ai":"google"},Hp=["gpt-5.5","gpt-5.4-mini","gpt-5.4-nano","gpt-4.1","gpt-4.1-mini"],N0=["claude-sonnet-4-6","claude-opus-4-7","claude-haiku-4-5"],O0=["claude-sonnet-4.6","claude-opus-4.7","claude-haiku-4.5"],jp=["gemini-2.5-pro","gemini-2.5-flash","gemini-3.1-pro-preview","gemini-3-flash-preview"],$0=["grok-4.20","grok-4.1-fast"],D0={openai:Hp,anthropic:N0,google:jp,activepieces:[...O0.map(t=>`anthropic/${t}`),...Hp.map(t=>`openai/${t}`),...jp.map(t=>`google/${t}`),...$0.map(t=>`x-ai/${t}`)]};var Wp=128e3,B0={openai:128e3,anthropic:2e5,google:1048576,bedrock:2e5,azure:128e3,openrouter:128e3,activepieces:2e5,mistral:128e3};function U0({provider:t}){return t?B0[t]??Wp:Wp}c(U0,"getMaxContextTokens");var qp={openai:"text-embedding-3-small",google:"text-embedding-004",azure:"text-embedding-3-small",activepieces:"text-embedding-3-small",openrouter:"openai/text-embedding-3-small"},L0={anthropic:"native",google:"native",openrouter:"plugin",activepieces:"plugin"},z0=new Set(["anthropic","mistral"]);function Jr(t){return{chatModels:D0[t],maxContextTokens:U0({provider:t}),defaultEmbeddingModel:qp[t],supportsEmbedding:qp[t]!==void 0,supportsImageGeneration:!z0.has(t),webSearch:L0[t]}}c(Jr,"buildProviderCapabilities");var M0={openai:Jr("openai"),anthropic:Jr("anthropic"),openrouter:Jr("openrouter"),azure:Jr("azure"),google:Jr("google"),"cloudflare-gateway":Jr("cloudflare-gateway"),custom:Jr("custom"),bedrock:Jr("bedrock"),mistral:Jr("mistral"),activepieces:Jr("activepieces")};var F0=D({base64Url:v(),fileName:v(),extension:oe(v())}),H0=D({mimeType:v(),url:v(),fileName:oe(v())}),iu=Je([F0,H0]);var j0=Je([D({type:Ce("file"),value:iu}),D({type:Ce("markdown"),value:v(),files:oe(Xe(iu))})]),W0=D({sessionId:v(),message:v(),files:oe(Xe(v()))});var eh=(r=>(r.ON_NEW_RECORD="ON_NEW_RECORD",r.ON_UPDATE_RECORD="ON_UPDATE_RECORD",r))(eh||{}),th=(r=>(r.ENABLED="ENABLED",r.DISABLED="DISABLED",r))(th||{}),ou=(n=>(n.RECORD_CREATED="RECORD_CREATED",n.RECORD_UPDATED="RECORD_UPDATED",n.RECORD_DELETED="RECORD_DELETED",n))(ou||{});var q0=Je([D({...Ur,name:v(),externalId:v(),type:Ce("STATIC_DROPDOWN"),tableId:v(),projectId:v(),data:D({options:Xe(D({value:v()}))})}),D({...Ur,name:v(),externalId:v(),type:Je([Ce("TEXT"),Ce("NUMBER"),Ce("DATE")]),tableId:v(),projectId:v()})]),Q0=D({...Ur,name:v(),folderId:Ut(v()),projectId:v(),externalId:v(),status:Xc(th),trigger:Xc(eh)}),V0=D({...Ur,tableId:v(),projectId:v(),cells:qe(v(),D({updated:v(),created:v(),value:We(),fieldName:v()}))}),K0=D({events:Xe(ot(ou)),webhookUrl:v(),flowId:v()}),G0=D({fields:Xe(D({id:v(),name:v()})),rows:Xe(qe(v(),v())),name:v()}),Z0=D({projectId:v(),limit:oe(To.number()),cursor:oe(v()),name:oe(v()),externalIds:ra(v()),folderId:oe(v()),folderIds:ra(v())}),Y0=D({records:Xe(Xe(D({fieldId:v(),value:nh()}))),tableId:v()}),X0=D({cells:oe(Xe(D({fieldId:v(),value:nh()}))),tableId:v(),agentUpdate:oe(It())}),rh=Cn("operator",[ri("eq"),ri("neq"),ri("gt"),ri("gte"),ri("lt"),ri("lte"),ri("co"),Jp("exists"),Jp("not_exists")]),J0=D({tableId:v(),limit:oe(To.number()),cursor:oe(v()),filters:ra(rh)});function nh(){return Nn(Rn(t=>t==null?t:String(t)),Po(v()))}c(nh,"coerceToString");function ri(t){return D({fieldId:v(),operator:Ce(t),value:v()})}c(ri,"valueFilter");function Jp(t){return D({fieldId:v(),operator:Ce(t)})}c(Jp,"existenceFilter");var eb=D({status:oe(Ar()),body:oe(We()),headers:oe(qe(v(),v()))}),tb=D({...Ur,deleted:Ut($n),ownerId:v(),displayName:v(),platformId:v(),externalId:Ut(v())});var ih=D({name:v(),description:oe(v()),type:v(),required:It()}),rb=D({pieceName:v(),triggerName:v(),input:D({toolName:v(),toolDescription:v(),inputSchema:Xe(ih),returnsResponse:It()})});var oh="^[0-9]+\\.[0-9]+\\.[0-9]+$",QB=new RegExp(oh),ib="^([~^])?[0-9]+\\.[0-9]+\\.[0-9]+$",VB=v().check(kn(new RegExp(oh))),KB=v().check(kn(new RegExp(ib))),ob=D({packageType:Ce("ARCHIVE"),pieceType:ot(Ti),pieceName:v(),pieceVersion:v(),archiveId:v(),platformId:v()}),sh=D({packageType:Ce("REGISTRY"),pieceType:Ce("OFFICIAL"),pieceName:v(),pieceVersion:v()}),ah=D({packageType:Ce("REGISTRY"),pieceType:Ce("CUSTOM"),pieceName:v(),pieceVersion:v(),platformId:v()}),GB=Je([sh,ah]),ZB=Je([ob,sh,ah]);var sb=Cn("type",[D({type:Ce("CRON_EXPRESSION"),cronExpression:v(),timezone:v()}),D({type:Ce("INTERVAL"),intervalMs:Ap().check(Ks(6e4))})]),YB=D({...Ur,type:ot(On),projectId:v(),flowId:v(),triggerName:v(),schedule:Ut(sb),flowVersionId:v(),pieceName:v(),pieceVersion:v(),deleted:Ut(v()),simulate:It()}),ch=(b=>(b.UNKNOWN="UNKNOWN",b.FLOW_RUN_LOG="FLOW_RUN_LOG",b.FLOW_RUN_LOG_SLICE="FLOW_RUN_LOG_SLICE",b.PACKAGE_ARCHIVE="PACKAGE_ARCHIVE",b.FLOW_STEP_FILE="FLOW_STEP_FILE",b.SAMPLE_DATA="SAMPLE_DATA",b.TRIGGER_PAYLOAD="TRIGGER_PAYLOAD",b.SAMPLE_DATA_INPUT="SAMPLE_DATA_INPUT",b.TRIGGER_EVENT_FILE="TRIGGER_EVENT_FILE",b.PROJECT_RELEASE="PROJECT_RELEASE",b.FLOW_VERSION_BACKUP="FLOW_VERSION_BACKUP",b.PLATFORM_ASSET="PLATFORM_ASSET",b.USER_PROFILE_PICTURE="USER_PROFILE_PICTURE",b.WEBHOOK_PAYLOAD="WEBHOOK_PAYLOAD",b.KNOWLEDGE_BASE="KNOWLEDGE_BASE",b.FLOW_BUNDLE="FLOW_BUNDLE",b))(ch||{}),uh=(r=>(r.NONE="NONE",r.ZSTD="ZSTD",r))(uh||{}),lh=(r=>(r.S3="S3",r.DB="DB",r))(lh||{}),XB=D({...Ur,projectId:Ut(v()),platformId:Ut(v()),type:ot(ch),compression:ot(uh),data:oe(We()),location:ot(lh),size:Ut(Ar()),fileName:Ut(v()),s3Key:Ut(v()),metadata:Ut(qe(v(),v()))}),fh=(n=>(n.ADMIN="ADMIN",n.MEMBER="MEMBER",n.OPERATOR="OPERATOR",n))(fh||{}),dh=(r=>(r.ACTIVE="ACTIVE",r.INACTIVE="INACTIVE",r))(dh||{}),JB=D({id:v(),email:v(),firstName:v(),status:ot(dh),externalId:Ut(v()),platformId:Ut(v()),platformRole:ot(fh),lastName:v(),created:$n,updated:$n,lastActiveDate:Ut($n),imageUrl:Ut(v())});var au=D({...At.shape,...tt(qe(v(),We()),"OBJECT").shape});var gh=D({...At.shape,...tt(v(),"COLOR").shape});var cu=Je([Rr,dn,ea,hn,Nr,pn,Kc,ko,Gc,gn,No,au,Oo,Ro,Co,gh]),pt={ShortText(t){return{...t,valueSchema:void 0,type:"SHORT_TEXT"}},Checkbox(t){return{...t,valueSchema:void 0,type:"CHECKBOX"}},LongText(t){return{...t,valueSchema:void 0,type:"LONG_TEXT"}},MarkDown(t){return{displayName:"Markdown",required:!1,description:t.value,type:"MARKDOWN",valueSchema:void 0,variant:t.variant??"INFO"}},Number(t){return{...t,valueSchema:void 0,type:"NUMBER"}},Json(t){return{...t,valueSchema:void 0,type:"JSON"}},Array(t){return{...t,valueSchema:void 0,type:"ARRAY"}},Object(t){return{...t,valueSchema:void 0,type:"OBJECT"}},Dropdown(t){return{...t,valueSchema:void 0,type:"DROPDOWN"}},StaticDropdown(t){return{...t,valueSchema:void 0,type:"STATIC_DROPDOWN"}},MultiSelectDropdown(t){return{...t,valueSchema:void 0,type:"MULTI_SELECT_DROPDOWN"}},DynamicProperties(t){return{...t,valueSchema:void 0,type:"DYNAMIC"}},StaticMultiSelectDropdown(t){return{...t,valueSchema:void 0,type:"STATIC_MULTI_SELECT_DROPDOWN"}},DateTime(t){return{...t,valueSchema:void 0,type:"DATE_TIME"}},File(t){return{...t,valueSchema:void 0,type:"FILE"}},Custom(t){let e=t.code.toString();return{...t,code:e,valueSchema:void 0,type:"CUSTOM"}},Color(t){return{...t,valueSchema:void 0,type:"COLOR"}}};var en=D({displayName:v(),description:oe(v())});var mh=D({username:v(),password:v()}),uu=D({...en.shape,username:D({displayName:v(),description:oe(v())}),password:D({displayName:v(),description:oe(v())}),...tt(mh,"BASIC_AUTH").shape});var lb=qe(v(),Je([Rr,dn,gn,hn,Nr])),lu=D({...en.shape,props:lb,...tt(We(),"CUSTOM_AUTH").shape});var ni=D({...en.shape,...tt(D({auth:v()}),"SECRET_TEXT").shape});var fb=qe(v(),Je([Rr,dn,ni,gn,hn,Nr,pn,ea])),_h=D({...en.shape,props:fb,...tt(We(),"OIDC").shape});var fu=(r=>(r.HEADER="HEADER",r.BODY="BODY",r))(fu||{}),yh=Je([Rr,ni,Nr]),Eh=qe(v(),yh),db=D({props:oe(qe(v(),yh)),authUrl:v(),tokenUrl:v(),scope:Xe(v()),prompt:oe(Je([Ce("none"),Ce("consent"),Ce("login"),Ce("omit")])),pkce:oe(It()),pkceMethod:oe(Je([Ce("plain"),Ce("S256")])),authorizationMethod:oe(ot(fu)),grantType:oe(Je([ot(Do),Ce(Zc)])),extra:oe(qe(v(),v()))}),Ah=D({access_token:v(),props:oe(Eh),data:qe(v(),wo())}),du=D({...en.shape,...db.shape,...tt(Ah,"OAUTH2").shape});var Ni=Je([uu,lu,_h,du,ni]),zo="Connection",Mo={SecretText(t){return{...t,valueSchema:void 0,type:"SECRET_TEXT"}},OAuth2(t){return{...t,valueSchema:void 0,type:"OAUTH2",displayName:t.displayName||zo}},BasicAuth(t){return{...t,valueSchema:void 0,type:"BASIC_AUTH",displayName:t.displayName||zo,required:!0}},CustomAuth(t){return{...t,valueSchema:void 0,type:"CUSTOM_AUTH",displayName:t.displayName||zo}},OIDC(t){return{...t,valueSchema:void 0,type:"OIDC",displayName:t.displayName||zo}},None(){}};var RL={OAUTH2:"OAUTH2",CLOUD_OAUTH2:"OAUTH2",PLATFORM_OAUTH2:"OAUTH2",BASIC_AUTH:"BASIC_AUTH",CUSTOM_AUTH:"CUSTOM_AUTH",OIDC:"OIDC",SECRET_TEXT:"SECRET_TEXT",NO_AUTH:void 0};var pb=D({...At.shape,...tt(We(),"CUSTOM").shape,code:v()});var gb=Je([cu,Ni]),pu=qe(v(),gb),YL=qe(v(),cu);var bh=Je([D({strategy:Ce("CRON"),cronExpression:v()}),D({strategy:Ce("NONE")})]),Oi=class{constructor(e,r,n,i,o,s,a,u,l,d,p,g,h,_,A,b,I,w,H){this.name=e;this.displayName=r;this.description=n;this.requireAuth=i;this.props=o;this.type=s;this.handshakeConfiguration=a;this.onHandshake=u;this.renewConfiguration=l;this.onRenew=d;this.onEnable=p;this.onDisable=g;this.onStart=h;this.run=_;this.test=A;this.sampleData=b;this.testStrategy=I;this.outputSchema=w;this.aiMetadata=H}static{c(this,"ITrigger")}},xh=c(t=>{switch(t.type){case"WEBHOOK":return new Oi(t.name,t.displayName,t.description,t.requireAuth??!0,t.props,t.type,t.handshakeConfiguration??{strategy:"NONE"},t.onHandshake??(async()=>({status:200})),t.renewConfiguration??{strategy:"NONE"},t.onRenew??(async()=>Promise.resolve()),t.onEnable,t.onDisable,t.onStart??(async()=>Promise.resolve()),t.run,t.test??(()=>Promise.resolve([t.sampleData])),t.sampleData,t.test?"TEST_FUNCTION":"SIMULATION",t.outputSchema,t.aiMetadata);case"POLLING":return new Oi(t.name,t.displayName,t.description,t.requireAuth??!0,t.props,t.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),t.onEnable,t.onDisable,t.onStart??(async()=>Promise.resolve()),t.run,t.test??(()=>Promise.resolve([t.sampleData])),t.sampleData,"TEST_FUNCTION",t.outputSchema,t.aiMetadata);case"MANUAL":return new Oi(t.name,t.displayName,t.description,t.requireAuth??!0,t.props,t.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),t.onEnable,t.onDisable,t.onStart??(async()=>Promise.resolve()),t.run,t.test??(()=>Promise.resolve([t.sampleData])),t.sampleData,"TEST_FUNCTION",t.outputSchema,t.aiMetadata);case"APP_WEBHOOK":return new Oi(t.name,t.displayName,t.description,t.requireAuth??!0,t.props,t.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),t.onEnable,t.onDisable,t.onStart??(async()=>Promise.resolve()),t.run,t.test??(()=>Promise.resolve([t.sampleData])),t.sampleData,ar(t.sampleData)&&ar(t.test)?"SIMULATION":"TEST_FUNCTION",t.outputSchema,t.aiMetadata)}},"createTrigger");var Ih="2",ia="0.82.0";var hu=class{constructor(e,r,n,i,o,s,a,u,l=ia,d,p="",g){this.displayName=e;this.logoUrl=r;this.authors=n;this.events=i;this.categories=a;this.auth=u;this.minimumSupportedRelease=l;this.maximumSupportedRelease=d;this.description=p;this.deprecated=g;this._actions={};this._triggers={};this.getContextInfo=c(()=>({version:Ih}),"getContextInfo");(!mb(l)||_b(l,ia))&&(this.minimumSupportedRelease=ia),o.forEach(h=>this._actions[h.name]=h),s.forEach(h=>this._triggers[h.name]=h)}static{c(this,"Piece")}metadata(){return{displayName:this.displayName,logoUrl:this.logoUrl,actions:this._actions,triggers:this._triggers,categories:this.categories,description:this.description,authors:this.authors,auth:this.auth,minimumSupportedRelease:this.minimumSupportedRelease,maximumSupportedRelease:this.maximumSupportedRelease,deprecated:this.deprecated,contextInfo:this.getContextInfo?.()}}getAction(e){return this._actions[e]}getTrigger(e){return this._triggers[e]}actions(){return this._actions}triggers(){return this._triggers}},vh=c(t=>{if(t.auth&&Array.isArray(t.auth)&&!t.auth.every((r,n,i)=>n===i.findIndex(o=>o.type===r.type)))throw new Error("Auth properties must be unique by type");return new hu(t.displayName,t.logoUrl,t.authors??[],t.events,t.actions,t.triggers,t.categories??[],t.auth,t.minimumSupportedRelease,t.maximumSupportedRelease,t.description,t.deprecated)},"createPiece");function mb(t){return/^\d+\.\d+\.\d+$/.test(t)}c(mb,"isValidSimpleSemver");function _b(t,e){let[r,n,i]=t.split(".").map(Number),[o,s,a]=e.split(".").map(Number);return r!==o?r<o:n!==s?n<s:i<a}c(_b,"isSemverLessThan");var yb=oe(qe(v(),qe(v(),v()))),Sh=D({id:oe(v()),name:v(),displayName:v(),logoUrl:v(),description:v(),authors:Xe(v()),platformId:oe(v()),directoryPath:oe(v()),auth:oe(Je([Ni,Xe(Ni)])),version:v(),categories:oe(Xe(ot(ki))),minimumSupportedRelease:oe(v()),maximumSupportedRelease:oe(v()),deprecated:oe(It()),i18n:yb}),Eb=ot(["human","ai","both"]),wh=D({description:oe(v()),idempotent:oe(It())}),Ph=D({name:v(),displayName:v(),description:v(),props:pu,requireAuth:It(),errorHandlingOptions:oe(Vc),outputSchema:oe(Xs()),audience:oe(Eb),aiMetadata:oe(wh)}),Th=D({name:v(),displayName:v(),description:v(),props:pu,errorHandlingOptions:oe(Vc),type:ot(On),sampleData:We(),handshakeConfiguration:oe(Xs()),renewConfiguration:oe(bh),testStrategy:ot(Uo),outputSchema:oe(Xs()),aiMetadata:oe(wh)}),Ab=D({...Sh.shape,actions:qe(v(),Ph),triggers:qe(v(),Th)}),bb=D({...Sh.shape,actions:Ar(),triggers:Ar(),suggestedActions:oe(Xe(Ph)),suggestedTriggers:oe(Xe(Th))}),kh=D({projectUsage:Ar(),pieceType:ot(Ti),packageType:ot($o),platformId:oe(v()),archiveId:oe(v())}),Yz=D({...Ab.shape,...kh.shape}),Xz=D({...bb.shape,...kh.shape}),Jz=D({name:v(),version:v()});var xb=Er(require("path")),Ib=Er(require("fs/promises"));var yE=Er(nn());var mE=Er(gE()),_E=Er(nn());async function Dt(t){return ar(t)?"sftp":t}c(Dt,"getProtocolBackwardCompatibility");async function Ft(t){let{protocol:e,host:r,port:n,allow_unauthorized_certificates:i,allow_anonymous_login:o,username:s,password:a,privateKey:u,algorithm:l}=t,d=await Dt(e);if(d==="sftp"){let p=new mE.default;if(u){let g=u.replace(/\\r\\n/g,`
24
24
  `).replace(/\\n/g,`
25
25
  `).replace(/\r\n/g,`
26
26
  `).replace(/\r/g,`
@@ -30,8 +30,8 @@ ${r}`}};var av=2**32,Im=(()=>{try{return new Function("return 2n ** 32n")()}catc
30
30
  `).replace(/(DEK-Info:\s*\S+)\s+/,`$1
31
31
 
32
32
  `).replace(/\s+(-----END [A-Z0-9 ]+ KEY-----)/,`
33
- $1`);let _=g.match(/(-----BEGIN [A-Z0-9 ]+ KEY-----\n(?:Proc-Type:[^\n]+\n)?(?:DEK-Info:[^\n]+\n\n)?)/),E=g.match(/(\n-----END [A-Z0-9 ]+ KEY-----)/);if(_&&E){let b=_[1],I=E[1],H=g.replace(b,"").replace(I,"").replace(/\s+/g,"").match(/.{1,64}/g)||[];g=b+H.join(`
34
- `)+I}}let h={host:r,port:n,username:s,privateKey:g,timeout:1e4};a&&(h.passphrase=a),l&&l.length>0&&(h.algorithms={serverHostKey:l}),await p.connect(h)}else a&&await p.connect({host:r,port:n,username:s,password:a,timeout:1e4});return p}else{let p=new dA.Client;return await p.access({host:r,port:n,user:s,password:a,secure:d==="ftps",secureOptions:{rejectUnauthorized:!(i??!1)}}),p}}c(Ft,"getClient");async function Zt(t,e){await Dt(e)==="sftp"?await t.end():t.close()}c(Zt,"endClient");var nr=zo.CustomAuth({props:{protocol:pt.StaticDropdown({displayName:"Protocol",description:"The protocol to use",required:!1,options:{options:[{value:"sftp",label:"SFTP"},{value:"ftp",label:"FTP"},{value:"ftps",label:"FTPS"}]}}),allow_unauthorized_certificates:pt.Checkbox({displayName:"Allow Unauthorized Certificates",description:"Allow connections to servers with self-signed certificates",defaultValue:!1,required:!1}),allow_anonymous_login:pt.Checkbox({displayName:"Allow Anonymous Login",description:"Allow anonymous login to FTP servers (only applicable for FTP/FTPS)",defaultValue:!1,required:!1}),host:pt.ShortText({displayName:"Host",description:"The host of the server",required:!0}),port:pt.Number({displayName:"Port",description:"The port of the server",required:!0,defaultValue:22}),username:pt.ShortText({displayName:"Username",description:"The username to authenticate with",required:!0}),password:zo.SecretText({displayName:"Password",description:"The password to authenticate with. Either this or private key is required. When using a private key, this field is used as the passphrase to decrypt the key.",required:!1}),privateKey:zo.SecretText({displayName:"Private Key",description:"The private key to authenticate with. Either this or password is required.",required:!1}),algorithm:pt.StaticMultiSelectDropdown({displayName:"Host Key Algorithm",description:"The host key algorithm to use for SFTP connection. Only needed if you want to override the default algorithms (e.g., to support ssh-dss).",required:!1,options:{options:[{value:"ssh-rsa",label:"ssh-rsa"},{value:"ssh-dss",label:"ssh-dss"},{value:"ecdsa-sha2-nistp256",label:"ecdsa-sha2-nistp256"},{value:"ecdsa-sha2-nistp384",label:"ecdsa-sha2-nistp384"},{value:"ecdsa-sha2-nistp521",label:"ecdsa-sha2-nistp521"},{value:"ssh-ed25519",label:"ssh-ed25519"},{value:"rsa-sha2-256",label:"rsa-sha2-256"},{value:"rsa-sha2-512",label:"rsa-sha2-512"}]}})},validate:c(async({auth:t})=>{let e=null,r=await Dt(t.protocol);try{if(!t.privateKey&&!t.password&&!t.allow_anonymous_login)return{valid:!1,error:"Either password or private key must be provided for non-anonymous authentication."};switch(r){case"sftp":{if(t.allow_anonymous_login)return{valid:!1,error:"Anonymous login is not supported for SFTP protocol."};e=await Ft(t);break}default:{e=await Ft(t);break}}return{valid:!0}}catch(n){return{valid:!1,error:n?.message}}finally{e&&await Zt(e,t.protocol)}},"validate"),required:!0});var hA=require("stream");var c1={0:{error:"OK",description:"Indicates successful completion of the operation."},1:{error:"EOF",description:"An attempt to read past the end-of-file was made; or, there are no more directory entries to return."},2:{error:"No such file",description:"A reference was made to a file which does not exist."},3:{error:"Permission denied",description:"The user does not have sufficient permissions to perform the operation."},4:{error:"Failure",description:"An error occurred, but no specific error code exists to describe the failure. This error message should always have meaningful text in the error message field."},5:{error:"Bad message",description:"A badly formatted packet or other SFTP protocol incompatibility was detected."},6:{error:"No connection",description:"There is no connection to the server. This error may be used locally, but must not be returned by a server."},7:{error:"Connection lost",description:"The connection to the server was lost. This error may be used locally, but must not be returned by a server."},8:{error:"Operation unsupported",description:"An attempted operation could not be completed by the server because the server does not support the operation."},9:{error:"Invalid handle",description:"The handle value was invalid."},10:{error:"No such path",description:"The file path does not exist or is invalid."},11:{error:"File already exists",description:"The file already exists."},12:{error:"Write protect",description:"The file is on read-only media, or the media is write protected."},13:{error:"No media",description:"The requested operation cannot be completed because there is no media available in the drive."},14:{error:"No space on file-system",description:"The requested operation cannot be completed because there is insufficient free space on the filesystem."},15:{error:"Quota exceeded",description:"The operation cannot be completed because it would exceed the user\u2019s storage quota."},16:{error:"Unknown principal",description:"A principal referenced by the request (either the owner, group, or who field of an ACL), was unknown."},17:{error:"Lock conflict",description:"The file could not be opened because it is locked by another process."},18:{error:"Directory not empty",description:"The directory is not empty."},19:{error:"Not a directory",description:"The specified file is not a directory."},20:{error:"Invalid filename",description:"The filename is not valid."},21:{error:"Link loop",description:"Too many symbolic links encountered or an SSH_FXF_NOFOLLOW encountered a symbolic link as the final component."},22:{error:"Cannot delete",description:"The file cannot be deleted. One possible reason is that the advisory read-only attribute-bit is set."},23:{error:"Invalid parameter",description:"One of the parameters was out of range or the parameters specified cannot be used together."},24:{error:"File is a directory",description:"The specified file was a directory in a context where a directory cannot be used."},25:{error:"Range lock conflict",description:"A read or write operation failed because another process\u2019s mandatory byte-range lock overlaps with the request."},26:{error:"Range lock refused",description:"A request for a byte range lock was refused."},27:{error:"Delete pending",description:"An operation was attempted on a file for which a delete operation is pending."},28:{error:"File corrupt",description:"The file is corrupt; a filesystem integrity check should be run."},29:{error:"Owner invalid",description:"The principal specified cannot be assigned as an owner of a file."},30:{error:"Group invalid",description:"The principal specified cannot be assigned as the primary group of a file."},31:{error:"No matching byte range lock",description:"The requested operation could not be completed because the specified byte range lock has not been granted."}};function Bt(t){return c1[t]??{error:"Unknown error code"}}c(Bt,"getSftpError");async function u1(t,e,r){if(!await t.exists(e)){let i=e.substring(0,e.lastIndexOf("/"));await t.mkdir(i,!0)}await t.put(Buffer.from(r),e)}c(u1,"createFileWithSFTP");async function l1(t,e,r){let n=e.substring(0,e.lastIndexOf("/"));await t.ensureDir(n);let i=Buffer.from(r);await t.uploadFrom(hA.Readable.from(i),e)}c(l1,"createFileWithFTP");var gA=hr({audience:"human",auth:nr,name:"create_file",displayName:"Create File from Text",description:"Create a new file in the given path",props:{fileName:pt.ShortText({displayName:"File Path",required:!0}),fileContent:pt.LongText({displayName:"File content",required:!0})},async run(t){let e=t.propsValue.fileName,r=t.propsValue.fileContent,n=await Dt(t.auth.props.protocol),i=await Ft(t.auth.props);try{switch(n){case"ftps":case"ftp":await l1(i,e,r);break;default:case"sftp":await u1(i,e,r);break}return{status:"success"}}catch(o){return o instanceof pA.FTPError?(console.error(Bt(o.code)),{status:"error",error:Bt(o.code)}):{status:"error",error:o}}finally{await Zt(i,t.auth.props.protocol)}}});var mA=Ar(rn());var _A=require("stream");async function f1(t,e,r){let n=e.substring(0,e.lastIndexOf("/"));await t.ensureDir(n),await t.uploadFrom(_A.Readable.from(r.data),e)}c(f1,"uploadFileToFTP");async function d1(t,e,r){if(!await t.exists(e)){let i=e.substring(0,e.lastIndexOf("/"));await t.mkdir(i,!0)}await t.put(r.data,e),await t.end()}c(d1,"uploadFileToSFTP");var yA=hr({audience:"human",auth:nr,name:"upload_file",displayName:"Upload File",description:"Upload a file to the given path.",props:{fileName:pt.ShortText({displayName:"File Path",required:!0,description:"The path on the sftp server to store the file. e.g. `./myfolder/test.mp3`"}),fileContent:pt.File({displayName:"File content",required:!0})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.fileName,n=t.propsValue.fileContent,i=await Dt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await f1(e,r,n);break;default:case"sftp":await d1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof mA.FTPError?(console.error(Bt(o.code)),{status:"error",content:null,error:Bt(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var AA=Ar(rn()),EA=require("stream");async function p1(t,e){let r=[],n=new EA.Writable({write(i,o,s){r.push(i),s()}});return await t.downloadTo(n,e),Buffer.concat(r)}c(p1,"readFTP");async function h1(t,e){let r=await t.get(e);return await t.end(),r}c(h1,"readSFTP");var bA=hr({audience:"human",auth:nr,name:"read_file_content",displayName:"Read File Content",description:"Read the content of a file.",props:{filePath:pt.ShortText({displayName:"File Path",required:!0})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.filePath,n=r.split("/").pop()??r,i=await Dt(t.auth.props.protocol);try{let o;switch(i){case"ftps":case"ftp":o=await p1(e,r);break;default:case"sftp":o=await h1(e,r);break}return{file:await t.files.write({fileName:n,data:o})}}catch(o){return o instanceof AA.FTPError?(console.error(Bt(o.code)),{status:"error",content:null,error:Bt(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var $s={async poll(t,{store:e,auth:r,propsValue:n,maxItemsToPoll:i,files:o,server:s}){switch(t.strategy){case 0:{let a=await e.get("lastPoll");if(gr(a))throw new Error("lastPoll doesn't exist in the store.");let u=await t.items({store:e,auth:r,propsValue:n,lastFetchEpochMS:a,server:s}),l=u.reduce((d,p)=>Math.max(d,p.epochMilliSeconds),a);return await e.put("lastPoll",l),u.filter(d=>d.epochMilliSeconds>a).map(d=>d.data)}case 1:{let a=await e.get("lastItem"),u=await t.items({store:e,auth:r,propsValue:n,lastItemId:a,files:o,server:s}),l=u.findIndex(g=>g.id===a),d=[];gr(a)||l==-1?d=u??[]:d=u?.slice(0,l)??[],gr(i)||(d=d.slice(-i));let p=d?.[0]?.id;return gr(p)||await e.put("lastItem",p),d.map(g=>g.data)}}},async onEnable(t,{store:e,auth:r,propsValue:n,server:i}){switch(t.strategy){case 0:{await e.put("lastPoll",Date.now());break}case 1:{let s=(await t.items({store:e,auth:r,propsValue:n,lastItemId:null,server:i}))?.[0]?.id;gr(s)?await e.delete("lastItem"):await e.put("lastItem",s);break}}},async onDisable(t,e){switch(t.strategy){case 0:case 1:return}},async test(t,{auth:e,propsValue:r,store:n,files:i,server:o}){let s=[];switch(t.strategy){case 0:{s=await t.items({store:n,auth:e,propsValue:r,lastFetchEpochMS:0,server:o});break}case 1:{s=await t.items({store:n,auth:e,propsValue:r,lastItemId:null,files:i,server:o});break}}return g1(s.map(a=>a.data))}};function g1(t){return t.length<=5?t:t.slice(0,5)}c(g1,"getFirstFiveOrAll");var Pc=Ar(xA());function IA(t,e){return e==="sftp"?t.modifyTime:(0,Pc.default)(t.modifiedAt).valueOf()}c(IA,"getModifyTime");var wc={strategy:0,items:c(async({auth:t,propsValue:e,lastFetchEpochMS:r})=>{let n=null;try{let i=await Dt(t.props.protocol);n=await Ft(t.props);let s=(await n.list(e.path)).filter(u=>{let l=IA(u,i);return(0,Pc.default)(l).valueOf()>r});return(e.ignoreHiddenFiles?s.filter(u=>!u.name.startsWith(".")):s).map(u=>{let l=IA(u,i);return{data:{...u,path:`${e.path}/${u.name}`},epochMilliSeconds:(0,Pc.default)(l).valueOf()}})}catch{return[]}finally{n&&await Zt(n,t.props.protocol)}},"items")},vA=_h({auth:nr,name:"new_file",displayName:"New File",description:"Trigger when a new file is created or modified.",props:{path:pt.ShortText({displayName:"Path",description:"The path to watch for new files",required:!0,defaultValue:"./"}),ignoreHiddenFiles:pt.Checkbox({displayName:"Ignore hidden files",description:"Ignore hidden files",required:!1,defaultValue:!1})},type:"POLLING",onEnable:c(async t=>{await $s.onEnable(wc,t)},"onEnable"),onDisable:c(async t=>{await $s.onDisable(wc,t)},"onDisable"),run:c(async t=>await $s.poll(wc,t),"run"),test:c(async t=>await $s.test(wc,t),"test"),sampleData:null});var SA=Ar(rn());async function m1(t,e,r){r?await t.removeDir(e):await t.removeEmptyDir(e)}c(m1,"deleteFolderFTP");async function _1(t,e,r){await t.rmdir(e,r)}c(_1,"deleteFolderSFTP");var wA=hr({audience:"human",auth:nr,name:"deleteFolder",displayName:"Delete Folder",description:"Deletes an existing folder at given path.",props:{folderPath:pt.ShortText({displayName:"Folder Path",required:!0,description:"The path of the folder to delete e.g. `./myfolder`"}),recursive:pt.Checkbox({displayName:"Recursive",defaultValue:!1,required:!1,description:"Enable this option to delete the folder and all its contents, including subfolders and files."})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.folderPath,n=t.propsValue.recursive??!1,i=await Dt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await m1(e,r,n);break;default:case"sftp":await _1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof SA.FTPError?(console.error(Bt(o.code)),{status:"error",error:Bt(o.code)}):{status:"error",error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var PA=Ar(rn());async function y1(t,e){await t.remove(e)}c(y1,"deleteFileFromFTP");async function A1(t,e){await t.delete(e)}c(A1,"deleteFileFromSFTP");var TA=hr({audience:"human",auth:nr,name:"deleteFile",displayName:"Delete file",description:"Deletes a file at given path.",props:{filePath:pt.ShortText({displayName:"File Path",required:!0,description:"The path of the file to delete e.g. `./myfolder/test.mp3`"})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.filePath,n=await Dt(t.auth.props.protocol);try{switch(n){case"ftps":case"ftp":await y1(e,r);break;default:case"sftp":await A1(e,r);break}return{status:"success"}}catch(i){return i instanceof PA.FTPError?(console.error(Bt(i.code)),{status:"error",error:Bt(i.code)}):{status:"error",error:i}}finally{await Zt(e,t.auth.props.protocol)}}});var kA=Ar(rn());async function E1(t,e){let r=await t.list(e);return await t.end(),r}c(E1,"listSFTP");async function b1(t,e){return(await t.list(e)).map(n=>({type:n.type===1?"d":"-",name:n.name,size:n.size,modifyTime:n.modifiedAt,accessTime:n.modifiedAt,rights:{user:n.permissions||"",group:"",other:""},owner:"",group:""}))}c(b1,"listFTP");var CA=hr({audience:"human",auth:nr,name:"listFolderContents",displayName:"List Folder Contents",description:"Lists the contents of a given folder.",props:{directoryPath:pt.ShortText({displayName:"Directory Path",required:!0,description:"The path of the folder to list e.g. `./myfolder`"})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.directoryPath,n=await Dt(t.auth.props.protocol);try{let i;switch(n){case"ftps":case"ftp":i=await b1(e,r);break;default:case"sftp":i=await E1(e,r);break}return{status:"success",contents:i}}catch(i){return i instanceof kA.FTPError?(console.error(Bt(i.code)),{status:"error",content:null,error:Bt(i.code)}):{status:"error",content:null,error:i}}finally{await Zt(e,t.auth.props.protocol)}}});var RA=Ar(rn());var NA=hr({audience:"human",auth:nr,name:"createFolder",displayName:"Create Folder",description:"Creates a folder at given path.",props:{folderPath:pt.ShortText({displayName:"Folder Path",required:!0,description:"The new folder path e.g. `./myfolder`. For FTP/FTPS, it will create nested folders if necessary."}),recursive:pt.Checkbox({displayName:"Recursive",defaultValue:!1,required:!1,description:"For SFTP only: Create parent directories if they do not exist"})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.folderPath,n=t.propsValue.recursive??!1,i=await Dt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await e.ensureDir(r);break;default:case"sftp":await e.mkdir(r,n);break}return{status:"success"}}catch(o){return o instanceof RA.FTPError?(console.error(Bt(o.code)),{status:"error",error:Bt(o.code)}):{status:"error",error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var OA=Ar(rn());async function x1(t,e,r){await t.rename(e,r)}c(x1,"renameFTP");async function I1(t,e,r){await t.rename(e,r),await t.end()}c(I1,"renameSFTP");var $A=hr({audience:"human",auth:nr,name:"renameFileOrFolder",displayName:"Rename File or Folder",description:"Renames a file or folder at given path.",props:{information:pt.MarkDown({value:"Depending on the server you can also use this to move a file to another directory, as long as the directory exists.",variant:"INFO"}),oldPath:pt.ShortText({displayName:"Old Path",required:!0,description:"The path of the file or folder to rename e.g. `./myfolder/test.mp3`"}),newPath:pt.ShortText({displayName:"New Path",required:!0,description:"The new path of the file or folder e.g. `./myfolder/new-name.mp3`"})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.oldPath,n=t.propsValue.newPath,i=await Dt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await x1(e,r,n);break;default:case"sftp":await I1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof OA.FTPError?(console.error(Bt(o.code)),{status:"error",content:null,error:Bt(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var v1=Ah({displayName:"FTP/SFTP",description:"Connect to FTP, FTPS or SFTP servers",minimumSupportedRelease:"0.30.0",logoUrl:"https://cdn.activepieces.com/pieces/new-core/sftp.svg",categories:["CORE","DEVELOPER_TOOLS"],authors:["Abdallah-Alwarawreh","kishanprmr","AbdulTheActivePiecer","khaledmashaly","abuaboud","prasanna2000-max"],auth:nr,actions:[gA,yA,bA,TA,NA,wA,CA,$A],triggers:[vA]});0&&(module.exports={endClient,ftpSftp,getClient,getProtocolBackwardCompatibility});
33
+ $1`);let _=g.match(/(-----BEGIN [A-Z0-9 ]+ KEY-----\n(?:Proc-Type:[^\n]+\n)?(?:DEK-Info:[^\n]+\n\n)?)/),A=g.match(/(\n-----END [A-Z0-9 ]+ KEY-----)/);if(_&&A){let b=_[1],I=A[1],H=g.replace(b,"").replace(I,"").replace(/\s+/g,"").match(/.{1,64}/g)||[];g=b+H.join(`
34
+ `)+I}}let h={host:r,port:n,username:s,privateKey:g,timeout:1e4};a&&(h.passphrase=a),l&&l.length>0&&(h.algorithms={serverHostKey:l}),await p.connect(h)}else a&&await p.connect({host:r,port:n,username:s,password:a,timeout:1e4});return p}else{let p=new _E.Client;return await p.access({host:r,port:n,user:s,password:a,secure:d==="ftps",secureOptions:{rejectUnauthorized:!(i??!1)}}),p}}c(Ft,"getClient");async function Zt(t,e){await Dt(e)==="sftp"?await t.end():t.close()}c(Zt,"endClient");var nr=Mo.CustomAuth({props:{protocol:pt.StaticDropdown({displayName:"Protocol",description:"The protocol to use",required:!1,options:{options:[{value:"sftp",label:"SFTP"},{value:"ftp",label:"FTP"},{value:"ftps",label:"FTPS"}]}}),allow_unauthorized_certificates:pt.Checkbox({displayName:"Allow Unauthorized Certificates",description:"Allow connections to servers with self-signed certificates",defaultValue:!1,required:!1}),allow_anonymous_login:pt.Checkbox({displayName:"Allow Anonymous Login",description:"Allow anonymous login to FTP servers (only applicable for FTP/FTPS)",defaultValue:!1,required:!1}),host:pt.ShortText({displayName:"Host",description:"The host of the server",required:!0}),port:pt.Number({displayName:"Port",description:"The port of the server",required:!0,defaultValue:22}),username:pt.ShortText({displayName:"Username",description:"The username to authenticate with",required:!0}),password:Mo.SecretText({displayName:"Password",description:"The password to authenticate with. Either this or private key is required. When using a private key, this field is used as the passphrase to decrypt the key.",required:!1}),privateKey:Mo.SecretText({displayName:"Private Key",description:"The private key to authenticate with. Either this or password is required.",required:!1}),algorithm:pt.StaticMultiSelectDropdown({displayName:"Host Key Algorithm",description:"The host key algorithm to use for SFTP connection. Only needed if you want to override the default algorithms (e.g., to support ssh-dss).",required:!1,options:{options:[{value:"ssh-rsa",label:"ssh-rsa"},{value:"ssh-dss",label:"ssh-dss"},{value:"ecdsa-sha2-nistp256",label:"ecdsa-sha2-nistp256"},{value:"ecdsa-sha2-nistp384",label:"ecdsa-sha2-nistp384"},{value:"ecdsa-sha2-nistp521",label:"ecdsa-sha2-nistp521"},{value:"ssh-ed25519",label:"ssh-ed25519"},{value:"rsa-sha2-256",label:"rsa-sha2-256"},{value:"rsa-sha2-512",label:"rsa-sha2-512"}]}})},validate:c(async({auth:t})=>{let e=null,r=await Dt(t.protocol);try{if(!t.privateKey&&!t.password&&!t.allow_anonymous_login)return{valid:!1,error:"Either password or private key must be provided for non-anonymous authentication."};switch(r){case"sftp":{if(t.allow_anonymous_login)return{valid:!1,error:"Anonymous login is not supported for SFTP protocol."};e=await Ft(t);break}default:{e=await Ft(t);break}}return{valid:!0}}catch(n){return{valid:!1,error:n?.message}}finally{e&&await Zt(e,t.protocol)}},"validate"),required:!0});var EE=require("stream");var x1={0:{error:"OK",description:"Indicates successful completion of the operation."},1:{error:"EOF",description:"An attempt to read past the end-of-file was made; or, there are no more directory entries to return."},2:{error:"No such file",description:"A reference was made to a file which does not exist."},3:{error:"Permission denied",description:"The user does not have sufficient permissions to perform the operation."},4:{error:"Failure",description:"An error occurred, but no specific error code exists to describe the failure. This error message should always have meaningful text in the error message field."},5:{error:"Bad message",description:"A badly formatted packet or other SFTP protocol incompatibility was detected."},6:{error:"No connection",description:"There is no connection to the server. This error may be used locally, but must not be returned by a server."},7:{error:"Connection lost",description:"The connection to the server was lost. This error may be used locally, but must not be returned by a server."},8:{error:"Operation unsupported",description:"An attempted operation could not be completed by the server because the server does not support the operation."},9:{error:"Invalid handle",description:"The handle value was invalid."},10:{error:"No such path",description:"The file path does not exist or is invalid."},11:{error:"File already exists",description:"The file already exists."},12:{error:"Write protect",description:"The file is on read-only media, or the media is write protected."},13:{error:"No media",description:"The requested operation cannot be completed because there is no media available in the drive."},14:{error:"No space on file-system",description:"The requested operation cannot be completed because there is insufficient free space on the filesystem."},15:{error:"Quota exceeded",description:"The operation cannot be completed because it would exceed the user\u2019s storage quota."},16:{error:"Unknown principal",description:"A principal referenced by the request (either the owner, group, or who field of an ACL), was unknown."},17:{error:"Lock conflict",description:"The file could not be opened because it is locked by another process."},18:{error:"Directory not empty",description:"The directory is not empty."},19:{error:"Not a directory",description:"The specified file is not a directory."},20:{error:"Invalid filename",description:"The filename is not valid."},21:{error:"Link loop",description:"Too many symbolic links encountered or an SSH_FXF_NOFOLLOW encountered a symbolic link as the final component."},22:{error:"Cannot delete",description:"The file cannot be deleted. One possible reason is that the advisory read-only attribute-bit is set."},23:{error:"Invalid parameter",description:"One of the parameters was out of range or the parameters specified cannot be used together."},24:{error:"File is a directory",description:"The specified file was a directory in a context where a directory cannot be used."},25:{error:"Range lock conflict",description:"A read or write operation failed because another process\u2019s mandatory byte-range lock overlaps with the request."},26:{error:"Range lock refused",description:"A request for a byte range lock was refused."},27:{error:"Delete pending",description:"An operation was attempted on a file for which a delete operation is pending."},28:{error:"File corrupt",description:"The file is corrupt; a filesystem integrity check should be run."},29:{error:"Owner invalid",description:"The principal specified cannot be assigned as an owner of a file."},30:{error:"Group invalid",description:"The principal specified cannot be assigned as the primary group of a file."},31:{error:"No matching byte range lock",description:"The requested operation could not be completed because the specified byte range lock has not been granted."}};function Bt(t){return x1[t]??{error:"Unknown error code"}}c(Bt,"getSftpError");async function I1(t,e,r){if(!await t.exists(e)){let i=e.substring(0,e.lastIndexOf("/"));await t.mkdir(i,!0)}await t.put(Buffer.from(r),e)}c(I1,"createFileWithSFTP");async function v1(t,e,r){let n=e.substring(0,e.lastIndexOf("/"));await t.ensureDir(n);let i=Buffer.from(r);await t.uploadFrom(EE.Readable.from(i),e)}c(v1,"createFileWithFTP");var AE=gr({audience:"both",auth:nr,name:"create_file",displayName:"Create File from Text",description:"Create a new file in the given path",aiMetadata:{description:"Writes a text string to a file at a given path on the connected FTP, FTPS or SFTP server, creating missing parent directories and overwriting any existing file at that path. Choose this when the content is plain text you already hold as a string; prefer Upload File when the content is a binary or file object produced by an earlier step. Requires the full remote path (e.g. ./myfolder/notes.txt); idempotent, since the same path and content always converge on the same stored file, but note it clobbers whatever was there before.",idempotent:!0},props:{fileName:pt.ShortText({displayName:"File Path",required:!0}),fileContent:pt.LongText({displayName:"File content",required:!0})},async run(t){let e=t.propsValue.fileName,r=t.propsValue.fileContent,n=await Dt(t.auth.props.protocol),i=await Ft(t.auth.props);try{switch(n){case"ftps":case"ftp":await v1(i,e,r);break;default:case"sftp":await I1(i,e,r);break}return{status:"success"}}catch(o){return o instanceof yE.FTPError?(console.error(Bt(o.code)),{status:"error",error:Bt(o.code)}):{status:"error",error:o}}finally{await Zt(i,t.auth.props.protocol)}}});var bE=Er(nn());var xE=require("stream");async function S1(t,e,r){let n=e.substring(0,e.lastIndexOf("/"));await t.ensureDir(n),await t.uploadFrom(xE.Readable.from(r.data),e)}c(S1,"uploadFileToFTP");async function w1(t,e,r){if(!await t.exists(e)){let i=e.substring(0,e.lastIndexOf("/"));await t.mkdir(i,!0)}await t.put(r.data,e),await t.end()}c(w1,"uploadFileToSFTP");var IE=gr({audience:"both",auth:nr,name:"upload_file",displayName:"Upload File",description:"Upload a file to the given path.",aiMetadata:{description:"Uploads a file object, typically one produced by an earlier step, to a given path on the connected FTP, FTPS or SFTP server, creating missing parent directories and overwriting any existing file at that path. Use this instead of Create File from Text whenever you have an actual file rather than a string of text. Requires both the file and the destination remote path (e.g. ./myfolder/test.mp3); idempotent, as repeating the upload converges on the same stored file.",idempotent:!0},props:{fileName:pt.ShortText({displayName:"File Path",required:!0,description:"The path on the sftp server to store the file. e.g. `./myfolder/test.mp3`"}),fileContent:pt.File({displayName:"File content",required:!0})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.fileName,n=t.propsValue.fileContent,i=await Dt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await S1(e,r,n);break;default:case"sftp":await w1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof bE.FTPError?(console.error(Bt(o.code)),{status:"error",content:null,error:Bt(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var vE=Er(nn()),SE=require("stream");async function P1(t,e){let r=[],n=new SE.Writable({write(i,o,s){r.push(i),s()}});return await t.downloadTo(n,e),Buffer.concat(r)}c(P1,"readFTP");async function T1(t,e){let r=await t.get(e);return await t.end(),r}c(T1,"readSFTP");var wE=gr({audience:"both",auth:nr,name:"read_file_content",displayName:"Read File Content",description:"Read the content of a file.",aiMetadata:{description:"Downloads one file from the connected FTP, FTPS or SFTP server by remote path and returns it as a file reference that later steps can consume. Use it to fetch the content of a file whose path you know; run List Folder Contents first when you still need to discover which paths exist. Requires an exact remote file path - it does not glob, search or recurse; read-only and idempotent.",idempotent:!0},props:{filePath:pt.ShortText({displayName:"File Path",required:!0})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.filePath,n=r.split("/").pop()??r,i=await Dt(t.auth.props.protocol);try{let o;switch(i){case"ftps":case"ftp":o=await P1(e,r);break;default:case"sftp":o=await T1(e,r);break}return{file:await t.files.write({fileName:n,data:o})}}catch(o){return o instanceof vE.FTPError?(console.error(Bt(o.code)),{status:"error",content:null,error:Bt(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var Ds={async poll(t,{store:e,auth:r,propsValue:n,maxItemsToPoll:i,files:o,server:s}){switch(t.strategy){case 0:{let a=await e.get("lastPoll");if(ar(a))throw new Error("lastPoll doesn't exist in the store.");let u=await t.items({store:e,auth:r,propsValue:n,lastFetchEpochMS:a,server:s}),l=u.reduce((d,p)=>Math.max(d,p.epochMilliSeconds),a);return await e.put("lastPoll",l),u.filter(d=>d.epochMilliSeconds>a).map(d=>d.data)}case 1:{let a=await e.get("lastItem"),u=await t.items({store:e,auth:r,propsValue:n,lastItemId:a,files:o,server:s}),l=u.findIndex(g=>g.id===a),d=[];ar(a)||l==-1?d=u??[]:d=u?.slice(0,l)??[],ar(i)||(d=d.slice(-i));let p=d?.[0]?.id;return ar(p)||await e.put("lastItem",p),d.map(g=>g.data)}}},async onEnable(t,{store:e,auth:r,propsValue:n,server:i}){switch(t.strategy){case 0:{await e.put("lastPoll",Date.now());break}case 1:{let s=(await t.items({store:e,auth:r,propsValue:n,lastItemId:null,server:i}))?.[0]?.id;ar(s)?await e.delete("lastItem"):await e.put("lastItem",s);break}}},async onDisable(t,e){switch(t.strategy){case 0:case 1:return}},async test(t,{auth:e,propsValue:r,store:n,files:i,server:o}){let s=[];switch(t.strategy){case 0:{s=await t.items({store:n,auth:e,propsValue:r,lastFetchEpochMS:0,server:o});break}case 1:{s=await t.items({store:n,auth:e,propsValue:r,lastItemId:null,files:i,server:o});break}}return k1(s.map(a=>a.data))}};function k1(t){return t.length<=5?t:t.slice(0,5)}c(k1,"getFirstFiveOrAll");var Tc=Er(PE());function TE(t,e){return e==="sftp"?t.modifyTime:(0,Tc.default)(t.modifiedAt).valueOf()}c(TE,"getModifyTime");var Pc={strategy:0,items:c(async({auth:t,propsValue:e,lastFetchEpochMS:r})=>{let n=null;try{let i=await Dt(t.props.protocol);n=await Ft(t.props);let s=(await n.list(e.path)).filter(u=>{let l=TE(u,i);return(0,Tc.default)(l).valueOf()>r});return(e.ignoreHiddenFiles?s.filter(u=>!u.name.startsWith(".")):s).map(u=>{let l=TE(u,i);return{data:{...u,path:`${e.path}/${u.name}`},epochMilliSeconds:(0,Tc.default)(l).valueOf()}})}catch{return[]}finally{n&&await Zt(n,t.props.protocol)}},"items")},kE=xh({auth:nr,name:"new_file",displayName:"New File",description:"Trigger when a new file is created or modified.",aiMetadata:{description:"Fires for each file in a watched directory on an FTP, FTPS or SFTP server whose modification time is newer than the previous poll, so it covers both newly added files and edits to existing ones. Each event represents one such file. Polls a single directory only, without recursing into subfolders, and can optionally skip hidden dotfiles."},props:{path:pt.ShortText({displayName:"Path",description:"The path to watch for new files",required:!0,defaultValue:"./"}),ignoreHiddenFiles:pt.Checkbox({displayName:"Ignore hidden files",description:"Ignore hidden files",required:!1,defaultValue:!1})},type:"POLLING",onEnable:c(async t=>{await Ds.onEnable(Pc,t)},"onEnable"),onDisable:c(async t=>{await Ds.onDisable(Pc,t)},"onDisable"),run:c(async t=>await Ds.poll(Pc,t),"run"),test:c(async t=>await Ds.test(Pc,t),"test"),sampleData:null});var CE=Er(nn());async function C1(t,e,r){r?await t.removeDir(e):await t.removeEmptyDir(e)}c(C1,"deleteFolderFTP");async function R1(t,e,r){await t.rmdir(e,r)}c(R1,"deleteFolderSFTP");var RE=gr({audience:"both",auth:nr,name:"deleteFolder",displayName:"Delete Folder",description:"Deletes an existing folder at given path.",aiMetadata:{description:"Deletes a directory at a given remote path on the connected FTP, FTPS or SFTP server, either only when it is empty or, with the recursive option enabled, together with every nested subfolder and file. Use this for directories; use Delete File to remove a single file. Recursive deletion is permanent and unrecoverable, so verify the path first; idempotent in that it converges on the folder being absent, and a repeat call on an already-missing path just reports an error.",idempotent:!0},props:{folderPath:pt.ShortText({displayName:"Folder Path",required:!0,description:"The path of the folder to delete e.g. `./myfolder`"}),recursive:pt.Checkbox({displayName:"Recursive",defaultValue:!1,required:!1,description:"Enable this option to delete the folder and all its contents, including subfolders and files."})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.folderPath,n=t.propsValue.recursive??!1,i=await Dt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await C1(e,r,n);break;default:case"sftp":await R1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof CE.FTPError?(console.error(Bt(o.code)),{status:"error",error:Bt(o.code)}):{status:"error",error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var NE=Er(nn());async function N1(t,e){await t.remove(e)}c(N1,"deleteFileFromFTP");async function O1(t,e){await t.delete(e)}c(O1,"deleteFileFromSFTP");var OE=gr({audience:"both",auth:nr,name:"deleteFile",displayName:"Delete file",description:"Deletes a file at given path.",aiMetadata:{description:"Permanently deletes a single file at a given remote path on the connected FTP, FTPS or SFTP server. Use this for one file; use Delete Folder to remove a directory, optionally with all of its contents. Requires the exact remote path (e.g. ./myfolder/test.mp3) and there is no recycle bin or undo; idempotent in that it converges on the file being absent, though a repeat call on an already-missing path reports an error.",idempotent:!0},props:{filePath:pt.ShortText({displayName:"File Path",required:!0,description:"The path of the file to delete e.g. `./myfolder/test.mp3`"})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.filePath,n=await Dt(t.auth.props.protocol);try{switch(n){case"ftps":case"ftp":await N1(e,r);break;default:case"sftp":await O1(e,r);break}return{status:"success"}}catch(i){return i instanceof NE.FTPError?(console.error(Bt(i.code)),{status:"error",error:Bt(i.code)}):{status:"error",error:i}}finally{await Zt(e,t.auth.props.protocol)}}});var $E=Er(nn());async function $1(t,e){let r=await t.list(e);return await t.end(),r}c($1,"listSFTP");async function D1(t,e){return(await t.list(e)).map(n=>({type:n.type===1?"d":"-",name:n.name,size:n.size,modifyTime:n.modifiedAt,accessTime:n.modifiedAt,rights:{user:n.permissions||"",group:"",other:""},owner:"",group:""}))}c(D1,"listFTP");var DE=gr({audience:"both",auth:nr,name:"listFolderContents",displayName:"List Folder Contents",description:"Lists the contents of a given folder.",aiMetadata:{description:"Lists the immediate entries of one directory on the connected FTP, FTPS or SFTP server. Use it to discover paths before reading, renaming or deleting, and to walk a tree one level at a time; it is not recursive and offers no filtering or search. Requires the directory path (e.g. ./myfolder); read-only and idempotent.",idempotent:!0},props:{directoryPath:pt.ShortText({displayName:"Directory Path",required:!0,description:"The path of the folder to list e.g. `./myfolder`"})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.directoryPath,n=await Dt(t.auth.props.protocol);try{let i;switch(n){case"ftps":case"ftp":i=await D1(e,r);break;default:case"sftp":i=await $1(e,r);break}return{status:"success",contents:i}}catch(i){return i instanceof $E.FTPError?(console.error(Bt(i.code)),{status:"error",content:null,error:Bt(i.code)}):{status:"error",content:null,error:i}}finally{await Zt(e,t.auth.props.protocol)}}});var BE=Er(nn());var UE=gr({audience:"both",auth:nr,name:"createFolder",displayName:"Create Folder",description:"Creates a folder at given path.",aiMetadata:{description:"Creates a directory at a given remote path on the connected FTP, FTPS or SFTP server; on SFTP an optional recursive mode also creates any missing parent directories, while FTP/FTPS always ensures the whole path. Use it to prepare a destination directory, for example before a rename or move, noting that Create File from Text and Upload File already create parent directories themselves. Requires the folder path (e.g. ./myfolder); idempotent because it converges on that directory existing.",idempotent:!0},props:{folderPath:pt.ShortText({displayName:"Folder Path",required:!0,description:"The new folder path e.g. `./myfolder`. For FTP/FTPS, it will create nested folders if necessary."}),recursive:pt.Checkbox({displayName:"Recursive",defaultValue:!1,required:!1,description:"For SFTP only: Create parent directories if they do not exist"})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.folderPath,n=t.propsValue.recursive??!1,i=await Dt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await e.ensureDir(r);break;default:case"sftp":await e.mkdir(r,n);break}return{status:"success"}}catch(o){return o instanceof BE.FTPError?(console.error(Bt(o.code)),{status:"error",error:Bt(o.code)}):{status:"error",error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var LE=Er(nn());async function B1(t,e,r){await t.rename(e,r)}c(B1,"renameFTP");async function U1(t,e,r){await t.rename(e,r),await t.end()}c(U1,"renameSFTP");var zE=gr({audience:"both",auth:nr,name:"renameFileOrFolder",displayName:"Rename File or Folder",description:"Renames a file or folder at given path.",aiMetadata:{description:"Moves a file or folder on the connected FTP, FTPS or SFTP server from an old remote path to a new one, which covers both renaming in place and, on most servers, relocating the entry into a different directory. Prefer it over reading and re-uploading content, and over a delete-then-create pair, when the bytes do not change. The parent directory of the new path must already exist, so create it with Create Folder first; idempotent in that the entry ends up at the new path, though a repeat call errors because the old path is gone.",idempotent:!0},props:{information:pt.MarkDown({value:"Depending on the server you can also use this to move a file to another directory, as long as the directory exists.",variant:"INFO"}),oldPath:pt.ShortText({displayName:"Old Path",required:!0,description:"The path of the file or folder to rename e.g. `./myfolder/test.mp3`"}),newPath:pt.ShortText({displayName:"New Path",required:!0,description:"The new path of the file or folder e.g. `./myfolder/new-name.mp3`"})},async run(t){let e=await Ft(t.auth.props),r=t.propsValue.oldPath,n=t.propsValue.newPath,i=await Dt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await B1(e,r,n);break;default:case"sftp":await U1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof LE.FTPError?(console.error(Bt(o.code)),{status:"error",content:null,error:Bt(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var L1=vh({displayName:"FTP/SFTP",description:"Connect to FTP, FTPS or SFTP servers",minimumSupportedRelease:"0.30.0",logoUrl:"https://cdn.activepieces.com/pieces/new-core/sftp.svg",categories:["CORE","DEVELOPER_TOOLS"],authors:["Abdallah-Alwarawreh","kishanprmr","AbdulTheActivePiecer","khaledmashaly","abuaboud","prasanna2000-max"],auth:nr,actions:[AE,IE,wE,OE,UE,RE,DE,zE],triggers:[kE]});0&&(module.exports={endClient,ftpSftp,getClient,getProtocolBackwardCompatibility});
35
35
  /*! Bundled license information:
36
36
 
37
37
  safe-buffer/index.js: