@activepieces/piece-sftp 0.5.6 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +15 -15
package/src/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
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}},dd=(t,e)=>{for(var r in e)Ao(t,r,{get:e[r],enumerable:!0})},pd=(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)):{},pd(e||!t||!t.__esModule?Ao(r,"default",{value:t,enumerable:!0}):r,t)),KE=t=>pd(Ao({},"__esModule",{value:!0}),t);var Bp=le((Dp,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})(Dp)});var oa=le(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.parseControlResponse=Sb;ii.isSingleLine=Nh;ii.isMultiline=Oh;ii.positiveCompletion=wb;ii.positiveIntermediate=Pb;var gu=`
|
|
2
|
-
`;function
|
|
1
|
+
"use strict";var XE=Object.create;var bo=Object.defineProperty;var JE=Object.getOwnPropertyDescriptor;var eA=Object.getOwnPropertyNames;var tA=Object.getPrototypeOf,rA=Object.prototype.hasOwnProperty;var c=(t,e)=>bo(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}},hd=(t,e)=>{for(var r in e)bo(t,r,{get:e[r],enumerable:!0})},gd=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of eA(e))!rA.call(t,i)&&i!==r&&bo(t,i,{get:()=>e[i],enumerable:!(n=JE(e,i))||n.enumerable});return t};var br=(t,e,r)=>(r=t!=null?XE(tA(t)):{},gd(e||!t||!t.__esModule?bo(r,"default",{value:t,enumerable:!0}):r,t)),nA=t=>gd(bo({},"__esModule",{value:!0}),t);var Mp=le((zp,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 b=0,E=-1,v=(h.match(a.zoneIndex)||[])[0],w,H;for(v&&(v=v.substring(1),h=h.replace(/%.+$/,""));(E=h.indexOf(":",E+1))>=0;)b++;if(h.substr(0,2)==="::"&&b--,h.substr(-2,2)==="::"&&b--,b>_)return null;for(H=_-b,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 D=h.split(":"),J=[];for(let Y=0;Y<D.length;Y++)J.push(parseInt(D[Y],16));return J})(),{parts:_,zoneId:v}}c(u,"expandIPv6");function l(h,_,b,E){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let v=0,w;for(;E>0;){if(w=b-E,w<0&&(w=0),h[v]>>w!==_[v]>>w)return!1;E-=b,v+=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 b,E;for(b=0;b<_.length;b++)if(E=_[b],!(0<=E&&E<=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(_,b){let E;if(b===void 0&&(E=_,_=E[0],b=E[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return l(this.octets,_.octets,8,b)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,b=!1,E={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},v,w,H;for(v=3;v>=0;v-=1)if(w=this.octets[v],w in E){if(H=E[w],b&&H!==0)return null;H!==8&&(b=!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),b=_[0].toByteArray(),E=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),v=[],w=0;for(;w<4;)v.push(parseInt(b[w],10)|parseInt(E[w],10)^255),w++;return new this(v)}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 _,b,E,v,w;try{for(_=this.parseCIDR(h),E=_[0].toByteArray(),w=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),v=[],b=0;b<4;)v.push(parseInt(E[b],10)&parseInt(w[b],10)),b++;return new this(v)}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 b=parseInt(_[2]);if(b>=0&&b<=32){let E=[this.parse(_[1]),b];return Object.defineProperty(E,"toString",{value:c(function(){return this.join("/")},"value")}),E}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},g.IPv4.parser=function(h){let _,b,E;if(_=h.match(r.fourOctet))return(function(){let v=_.slice(1,6),w=[];for(let H=0;H<v.length;H++)b=v[H],w.push(d(b));return w})();if(_=h.match(r.longValue)){if(E=d(_[1]),E>4294967295||E<0)throw new Error("ipaddr: address outside defined range");return(function(){let v=[],w;for(w=0;w<=24;w+=8)v.push(E>>w&255);return v})().reverse()}else return(_=h.match(r.twoOctet))?(function(){let v=_.slice(1,4),w=[];if(E=d(v[1]),E>16777215||E<0)throw new Error("ipaddr: address outside defined range");return w.push(d(v[0])),w.push(E>>16&255),w.push(E>>8&255),w.push(E&255),w})():(_=h.match(r.threeOctet))?(function(){let v=_.slice(1,5),w=[];if(E=d(v[2]),E>65535||E<0)throw new Error("ipaddr: address outside defined range");return w.push(d(v[0])),w.push(d(v[1])),w.push(E>>8&255),w.push(E&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],b=0,E=Math.floor(h/8);for(;b<E;)_[b]=255,b++;return E<4&&(_[E]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},g.IPv6=(function(){function h(_,b){let E,v;if(_.length===16)for(this.parts=[],E=0;E<=14;E+=2)this.parts.push(_[E]<<8|_[E+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(E=0;E<this.parts.length;E++)if(v=this.parts[E],!(0<=v&&v<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");b&&(this.zoneId=b)}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(_,b){let E;if(b===void 0&&(E=_,_=E[0],b=E[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return l(this.parts,_.parts,16,b)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,b=!1,E={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},v,w;for(let H=7;H>=0;H-=1)if(v=this.parts[H],v in E){if(w=E[v],b&&w!==0)return null;w!==16&&(b=!0),_+=w}else return null;return 128-_},h.prototype.range=function(){return g.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _,b=[],E=this.parts;for(let v=0;v<E.length;v++)_=E[v],b.push(_>>8),b.push(_&255);return b},h.prototype.toFixedLengthString=function(){let _=(function(){let E=[];for(let v=0;v<this.parts.length;v++)E.push(p(this.parts[v].toString(16),4));return E}).call(this).join(":"),b="";return this.zoneId&&(b=`%${this.zoneId}`),_+b},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),b=_[0],E=_[1];return new g.IPv4([b>>8,b&255,E>>8,E&255])},h.prototype.toNormalizedString=function(){let _=(function(){let E=[];for(let v=0;v<this.parts.length;v++)E.push(this.parts[v].toString(16));return E}).call(this).join(":"),b="";return this.zoneId&&(b=`%${this.zoneId}`),_+b},h.prototype.toRFC5952String=function(){let _=/((^|:)(0(:|$)){2,})/g,b=this.toNormalizedString(),E=0,v=-1,w;for(;w=_.exec(b);)w[0].length>v&&(E=w.index,v=w[0].length);return v<0?b:`${b.substring(0,E)}::${b.substring(E+v)}`},h.prototype.toString=function(){return this.toRFC5952String()},h})(),g.IPv6.broadcastAddressFromCIDR=function(h){try{let _=this.parseCIDR(h),b=_[0].toByteArray(),E=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),v=[],w=0;for(;w<16;)v.push(parseInt(b[w],10)|parseInt(E[w],10)^255),w++;return new this(v)}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 _,b,E,v,w;try{for(_=this.parseCIDR(h),E=_[0].toByteArray(),w=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),v=[],b=0;b<16;)v.push(parseInt(E[b],10)&parseInt(w[b],10)),b++;return new this(v)}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 _,b,E;if((b=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(b[2]),_>=0&&_<=128))return E=[this.parse(b[1]),_],Object.defineProperty(E,"toString",{value:c(function(){return this.join("/")},"value")}),E;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},g.IPv6.parser=function(h){let _,b,E,v,w,H;if(E=h.match(a.deprecatedTransitional))return this.parser(`::ffff:${E[1]}`);if(a.native.test(h))return u(h,8);if((E=h.match(a.transitional))&&(H=E[6]||"",_=E[1],E[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+H,6),_.parts)){for(w=[parseInt(E[2]),parseInt(E[3]),parseInt(E[4]),parseInt(E[5])],b=0;b<w.length;b++)if(v=w[b],!(0<=v&&v<=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],b=0,E=Math.floor(h/8);for(;b<E;)_[b]=255,b++;return E<16&&(_[E]=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,_,b){let E,v,w,H;b==null&&(b="unicast");for(v in _)if(Object.prototype.hasOwnProperty.call(_,v)){for(w=_[v],w[0]&&!(w[0]instanceof Array)&&(w=[w]),E=0;E<w.length;E++)if(H=w[E],h.kind()===H[0].kind()&&h.match.apply(h,H))return v}return b},typeof na<"u"&&na.exports?na.exports=g:t.ipaddr=g})(zp)});var oa=le(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.parseControlResponse=Lb;ii.isSingleLine=zh;ii.isMultiline=Mh;ii.positiveCompletion=zb;ii.positiveIntermediate=Mb;var _u=`
|
|
2
|
+
`;function Lb(t){let e=t.split(/\r?\n/).filter(Fb),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(_u)));else if(Mh(a)){let u=a.substr(0,3);i=new RegExp(`^${u}(?:$| )`),n=s}else zh(a)&&r.push(a)}let o=i?e.slice(n).join(_u)+_u:"";return{messages:r,rest:o}}c(Lb,"parseControlResponse");function zh(t){return/^\d\d\d(?:$| )/.test(t)}c(zh,"isSingleLine");function Mh(t){return/^\d\d\d-/.test(t)}c(Mh,"isMultiline");function zb(t){return t>=200&&t<300}c(zb,"positiveCompletion");function Mb(t){return t>=300&&t<400}c(Mb,"positiveIntermediate");function Fb(t){return t.trim()!==""}c(Fb,"isNotBlank")});var Eu=le(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.FTPContext=Di.FTPError=void 0;var Hb=require("net"),jb=oa(),sa=class extends Error{static{c(this,"FTPError")}constructor(e){super(e.message),this.name=this.constructor.name,this.code=e.code}};Di.FTPError=sa;function Fh(){}c(Fh,"doNothing");var Wb=2**16,yu=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>Rb){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",$h),this.send("QUIT"),this._closeSocket(this._socket)}_closeSocket(e){e&&(this._removeSocketListeners(e),e.on("error",$h),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 Cb.Socket}};$i.FTPContext=mu});var yu=le(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.describeTLS=Nb;Di.describeAddress=Ob;Di.upgradeSocket=$b;Di.ipIsPrivateV4Address=Db;var Dh=require("tls");function Nb(t){if(t instanceof Dh.TLSSocket){let e=t.getProtocol();return e||"Server socket or disconnected client socket"}return"No encryption"}c(Nb,"describeTLS");function Ob(t){return t.remoteFamily==="IPv6"?`[${t.remoteAddress}]:${t.remotePort}`:`${t.remoteAddress}:${t.remotePort}`}c(Ob,"describeAddress");function $b(t,e){return new Promise((r,n)=>{let i=Object.assign({},e,{socket:t}),o=(0,Dh.connect)(i,()=>{i.rejectUnauthorized!==!1&&!o.authorized?n(o.authorizationError):(o.removeAllListeners("error"),r(o))}).once("error",s=>{n(s)})})}c($b,"upgradeSocket");function Db(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(Db,"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 Uh=le(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});Ho.testLine=Bb;Ho.parseLine=Ub;Ho.transformList=Lb;var Eu=Fo(),Bh=new RegExp("(\\S+)\\s+(\\S+)\\s+(?:(<DIR>)|([0-9]+))\\s+(\\S.*)");function Bb(t){return/^\d{2}/.test(t)&&Bh.test(t)}c(Bb,"testLine");function Ub(t){let e=t.match(Bh);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(Ub,"parseLine");function Lb(t){return t}c(Lb,"transformList")});var zh=le(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.testLine=Hb;jo.parseLine=jb;jo.transformList=Wb;var tn=Fo(),zb="\u6708",Mb="\u65E5",Fb="\u5E74",Lh=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}"+zb+"\\s+\\d{1,2}"+Mb+"))\\s+((?:\\d+(?::\\d+)?)|(?:\\d{4}"+Fb+"))\\s(.*)");function Hb(t){return Lh.test(t)}c(Hb,"testLine");function jb(t){let e=t.match(Lh);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(jb,"parseLine");function Wb(t){return t}c(Wb,"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=Vb;zi.transformList=Kb;zi.parseMLSxDate=Hh;var Li=Fo();function Mh(t,e){e.size=parseInt(t,10)}c(Mh,"parseSize");var qb={size:Mh,sizd:Mh,unique:c((t,e)=>{e.uniqueID=t},"unique"),modify:c((t,e)=>{e.modifiedAt=Hh(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 Fh(t,e){let r=t.indexOf(e),n=t.substr(0,r),i=t.substr(r+e.length);return[n,i]}c(Fh,"splitStringOnce");function Qb(t){return/^\S+=\S+;/.test(t)||t.startsWith(" ")}c(Qb,"testLine");function Vb(t){let[e,r]=Fh(t," ");if(r===""||r==="."||r==="..")return;let n=new Li.FileInfo(r),i=e.split(";");for(let o of i){let[s,a]=Fh(o,"=");if(!a)continue;let u=qb[s.toLowerCase()];if(!u)continue;if(u(a,n)===2)return}return n}c(Vb,"parseLine");function Kb(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(Kb,"transformList");function Hh(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(Hh,"parseMLSxDate")});var Iu=le(_n=>{"use strict";var Gb=_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]})),Zb=_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"&&Gb(r,e,n[i]);return Zb(r,e),r}})();Object.defineProperty(_n,"__esModule",{value:!0});_n.parseList=ox;var Yb=xu(Uh()),Xb=xu(zh()),Jb=xu(bu()),ex=[Yb,Xb,Jb];function tx(t,e){return e.find(r=>r.testLine(t)===!0)}c(tx,"firstCompatibleParser");function rx(t){return t.trim()!==""}c(rx,"isNotBlank");function nx(t){return!t.startsWith("total")}c(nx,"isNotMeta");var ix=/\r?\n/;function ox(t){let e=t.split(ix).filter(rx).filter(nx);if(e.length===0)return[];let r=e[e.length-1],n=tx(r,ex);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(ox,"parseList")});var jh=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=sx(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 sx(t,e){let r=setInterval(e,t),n=c(i=>{clearInterval(r),i&&e(),e=ca},"stopFunc");return e(),n}c(sx,"poll");function ca(){}c(ca,"noop")});var Wh=le(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.StringWriter=void 0;var ax=require("stream"),Su=class extends ax.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=cx;rn.parseEpsvResponse=Vh;rn.enterPassiveModeIPv4=ux;rn.enterPassiveModeIPv4_forceControlHostIP=lx;rn.parsePasvResponse=wu;rn.connectForPassiveTransfer=pa;rn.uploadFrom=fx;rn.downloadTo=dx;var Mi=yu(),Qh=require("stream"),qh=require("tls"),fa=oa();async function cx(t){let e=await t.request("EPSV"),r=Vh(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(cx,"enterPassiveModeIPv6");function Vh(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(Vh,"parseEpsvResponse");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;return(0,Mi.ipIsPrivateV4Address)(r.host)&&n&&!(0,Mi.ipIsPrivateV4Address)(n)&&(r.host=n),await pa(r.host,r.port,t),e}c(ux,"enterPassiveModeIPv4");async function lx(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(lx,"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 qh.TLSSocket&&(o=(0,qh.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 fx(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;px(a,s,"secureConnect",()=>{e.ftp.log(`Uploading to ${(0,Mi.describeAddress)(s)} (${(0,Mi.describeTLS)(s)})`),r.onDataStart(e.remotePath,e.type),(0,Qh.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(fx,"uploadFrom");function dx(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,Qh.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(dx,"downloadTo");function px(t,e,r,n){t===!0?n():e.once(r,()=>n())}c(px,"onConditionOrEvent")});var Xh=le(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.Client=void 0;var Bn=require("fs"),Tu=require("path"),hx=require("tls"),Hi=require("util"),Wo=_u(),oi=yu(),Cu=oa(),gx=Iu(),mx=bu(),_x=jh(),yx=Wh(),Fi=Pu(),Ex=(0,Hi.promisify)(Bn.readdir),Ax=(0,Hi.promisify)(Bn.mkdir),ku=(0,Hi.promisify)(Bn.stat),Kh=(0,Hi.promisify)(Bn.open),Gh=(0,Hi.promisify)(Bn.close),bx=(0,Hi.promisify)(Bn.unlink),Zh={allowSeparateTransferHost:!0,maxListingBytes:40*1024*1024},Yh=c(()=>["LIST -a","LIST"],"LIST_COMMANDS_DEFAULT"),xx=c(()=>["MLSD","LIST -a","LIST"],"LIST_COMMANDS_MLSD"),Ru=class{static{c(this,"Client")}constructor(e=3e4,r=Zh){this.availableListCommands=Yh();let n={...Zh,...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=gx.parseList,this._progressTracker=new _x.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,hx.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,Cu.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,Cu.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?xx():Yh(),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,Cu.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,mx.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 Kh(e,"r"),s=(0,Bn.createReadStream)("",{fd:o,start:i.localStart,end:i.localEndInclusive,autoClose:!1});try{return await this._uploadFromStream(s,r,n)}finally{await qo(()=>Gh(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 Kh(e,i?"r+":"w"),a=(0,Bn.createWriteStream)("",{fd:s,start:n,autoClose:!1});try{return await this._downloadToStream(a,r,n)}catch(u){let l=await qo(()=>ku(e)),d=l&&l.size>0;throw!i&&!d&&await qo(()=>bx(e)),u}finally{await qo(()=>Gh(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 yx.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 Ex(e);for(let n of r){let i=(0,Tu.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 Ix(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 Ix(t){try{await ku(t)}catch{await Ax(t,{recursive:!0})}}c(Ix,"ensureLocalDirectory");async function qo(t){try{return await t()}catch{return}}c(qo,"ignoreError")});var eg=le(Jh=>{"use strict";Object.defineProperty(Jh,"__esModule",{value:!0})});var nn=le(br=>{"use strict";var vx=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)&&vx(e,t,r)};Object.defineProperty(br,"__esModule",{value:!0});br.enterPassiveModeIPv6=br.enterPassiveModeIPv4=void 0;Qo(Xh(),br);Qo(_u(),br);Qo(Fo(),br);Qo(Iu(),br);Qo(eg(),br);var tg=Pu();Object.defineProperty(br,"enterPassiveModeIPv4",{enumerable:!0,get:c(function(){return tg.enterPassiveModeIPv4},"get")});Object.defineProperty(br,"enterPassiveModeIPv6",{enumerable:!0,get:c(function(){return tg.enterPassiveModeIPv6},"get")})});var ga=le((D3,rg)=>{rg.exports={newInvalidAsn1Error:c(function(t){var e=new Error;return e.name="InvalidAsn1Error",e.message=t||"",e},"newInvalidAsn1Error")}});var ma=le((U3,ng)=>{ng.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((L3,ig)=>{"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));ig.exports=Lr});var ag=le((z3,sg)=>{var Sx=require("assert"),og=Nu().Buffer,Vo=ma(),wx=ga(),qi=wx.newInvalidAsn1Error;function xr(t){if(!t||!og.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?og.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){Sx.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};sg.exports=xr});var ug=le((F3,cg)=>{var Un=require("assert"),ya=Nu().Buffer,Ln=ma(),Px=ga(),Ea=Px.newInvalidAsn1Error,Tx={size:1024,growthFactor:8};function Cx(t,e){Un.ok(t),Un.equal(typeof t,"object"),Un.ok(e),Un.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(Cx,"merge");function mr(t){t=Cx(Tx,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=Ln.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(Ln.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=Ln.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=Ln.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=Ln.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=Ln.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=Ln.Sequence|Ln.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){Un.ok(t!==void 0),Un.ok(e!==void 0),Un.ok(r),this._buf.copy(this._buf,t+r,t,t+e),this._offset+=r};mr.prototype._ensure=function(t){if(Un.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}};cg.exports=mr});var lg=le((j3,xa)=>{var Ou=ga(),$u=ma(),kx=ag(),Rx=ug();xa.exports={Reader:kx,Writer:Rx};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((W3,fg)=>{var Du=lg();fg.exports={Ber:Du,BerReader:Du.Reader,BerWriter:Du.Writer}});var dg=le((q3,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,Ce=Ke,Ze=ze,et=Ve,Ye=Me,S,nt=0;nt<20;nt+=2)S=Ee+Ce|0,be^=S<<7|S>>>25,S=be+Ee|0,se^=S<<9|S>>>23,S=se+be|0,Ce^=S<<13|S>>>19,S=Ce+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,Ce^=S<<7|S>>>25,S=Ce+Ye|0,Ze^=S<<9|S>>>23,S=Ze+Ce|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,Ce=Ce+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]=Ce>>>0&255,m[49]=Ce>>>8&255,m[50]=Ce>>>16&255,m[51]=Ce>>>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,Ce=Ke,Ze=ze,et=Ve,Ye=Me,S,nt=0;nt<20;nt+=2)S=Ee+Ce|0,be^=S<<7|S>>>25,S=be+Ee|0,se^=S<<9|S>>>23,S=se+be|0,Ce^=S<<13|S>>>19,S=Ce+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,Ce^=S<<7|S>>>25,S=Ce+Ye|0,Ze^=S<<9|S>>>23,S=Ze+Ce|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 C(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(C,"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],Ce=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,Ce+=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+=Ce*(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+=Ce*(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+=Ce*(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+=Ce*(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+=Ce*(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+=Ce*(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+=Ce*(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+=Ce*(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+=Ce*(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+=Ce*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,Ce=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]=Ce},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(C(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(C(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 k(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(k,"pack25519");function W(m,E){var y=new Uint8Array(32),f=new Uint8Array(32);return k(y,m),k(f,E),b(y,0,f,0)}c(W,"neq25519");function q(m){var E=new Uint8Array(32);return k(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,Ce=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],sr=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*sr,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*sr,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*sr,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*sr,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*sr,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*sr,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*sr,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*sr,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*sr,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*sr,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*sr,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*sr,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*sr,ie+=f*dr,ae+=f*pr,Ce+=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*sr,ae+=f*dr,Ce+=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*sr,Ce+=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,Ce+=f*sr,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*Ce,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 xt(m,E){he(m,E,E)}c(xt,"S");function kt(m,E){var y=e(),f;for(f=0;f<16;f++)y[f]=E[f];for(f=253;f>=0;f--)xt(y,y),f!==2&&f!==4&&he(y,y,E);for(f=0;f<16;f++)m[f]=y[f]}c(kt,"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--)xt(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),xt(pe,gt),xt(_e,ne),he(ne,ye,ne),he(ye,ce,gt),ue(gt,ne,ye),me(ne,ne,ye),xt(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),xt(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 kt(Ue,Ue),he(Le,Le,Ue),k(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,Ce=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],sr=0;f>=128;){for(be=0;be<16;be++)de=8*be+sr,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=Ce,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=(Ce>>>28|rt<<4)^(rt>>>2|Ce<<30)^(rt>>>7|Ce<<25),V=(rt>>>28|Ce<<4)^(Ce>>>2|rt<<30)^(Ce>>>7|rt<<25),se+=V&65535,re+=V>>>16,ie+=Q&65535,ae+=Q>>>16,Q=Ce&Ze^Ce&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,Ce=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=Ce,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]=Ce=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,sr+=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();kt(x,E[2]),he(y,E[0],x),he(f,E[1],x),k(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 Cr(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(Cr,"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 It(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(It,"modL");function ar(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;It(m,E)}c(ar,"reduce");function or(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),ar(z),Yr(pe,z),ut(m,pe),ne=32;ne<64;ne++)m[ne]=f[ne];for(fe(N,m,y+64),ar(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 It(m.subarray(32),ye),gt}c(or,"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),xt(x,m[1]),he(N,x,u),me(x,x,m[2]),ue(N,m[2],N),xt(z,N),xt(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),xt(f,m[0]),he(f,f,N),W(f,x)&&he(m[0],m[0],g),xt(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),ar(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,ei=32,vi=16,_o=32,Us=32,yo=32,Eo=32,Cc=32,ud=jt,ME=ei,FE=vi,ln=64,ti=32,Si=64,kc=32,Rc=64;t.lowlevel={crypto_core_hsalsa20:$,crypto_stream_xor:C,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:or,crypto_sign_keypair:Cr,crypto_sign_open:Pt,crypto_secretbox_KEYBYTES:Br,crypto_secretbox_NONCEBYTES:jt,crypto_secretbox_ZEROBYTES:ei,crypto_secretbox_BOXZEROBYTES:vi,crypto_scalarmult_BYTES:_o,crypto_scalarmult_SCALARBYTES:Us,crypto_box_PUBLICKEYBYTES:yo,crypto_box_SECRETKEYBYTES:Eo,crypto_box_BEFORENMBYTES:Cc,crypto_box_NONCEBYTES:ud,crypto_box_ZEROBYTES:ME,crypto_box_BOXZEROBYTES:FE,crypto_sign_BYTES:ln,crypto_sign_PUBLICKEYBYTES:ti,crypto_sign_SECRETKEYBYTES:Si,crypto_sign_SEEDBYTES:kc,crypto_hash_BYTES:Rc};function ld(m,E){if(m.length!==Br)throw new Error("bad key size");if(E.length!==jt)throw new Error("bad nonce size")}c(ld,"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 kr(){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(kr,"checkArrayTypes");function fd(m){for(var E=0;E<m.length;E++)m[E]=0}c(fd,"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){kr(m,E,y),ld(y,E);for(var f=new Uint8Array(ei+m.length),x=new Uint8Array(f.length),N=0;N<m.length;N++)f[N+ei]=m[N];return F(x,f,f.length,E,y),x.subarray(vi)},t.secretbox.open=function(m,E,y){kr(m,E,y),ld(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(ei)},t.secretbox.keyLength=Br,t.secretbox.nonceLength=jt,t.secretbox.overheadLength=vi,t.scalarMult=function(m,E){if(kr(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(kr(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){kr(m,E),HE(m,E);var y=new Uint8Array(Cc);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(kr(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=Cc,t.box.nonceLength=ud,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(m,E){if(kr(m,E),E.length!==Si)throw new Error("bad secret key size");var y=new Uint8Array(ln+m.length);return or(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(kr(m,E),E.length!==ti)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(kr(m,E,y),E.length!==ln)throw new Error("bad signature size");if(y.length!==ti)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(ti),E=new Uint8Array(Si);return Cr(m,E),{publicKey:m,secretKey:E}},t.sign.keyPair.fromSecretKey=function(m){if(kr(m),m.length!==Si)throw new Error("bad secret key size");for(var E=new Uint8Array(ti),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(kr(m),m.length!==kc)throw new Error("bad seed size");for(var E=new Uint8Array(ti),y=new Uint8Array(Si),f=0;f<32;f++)y[f]=m[f];return Cr(E,y,!0),{publicKey:E,secretKey:y}},t.sign.publicKeyLength=ti,t.sign.secretKeyLength=Si,t.sign.seedLength=kc,t.sign.signatureLength=ln,t.hash=function(m){kr(m);var E=new Uint8Array(Rc);return fe(E,m,m.length),E},t.hash.hashLength=Rc,t.verify=function(m,E){return kr(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];fd(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];fd(N)}))})()})(typeof Ia<"u"&&Ia.exports?Ia.exports:self.nacl=self.nacl||{})});var zu=le((V3,pg)=>{"use strict";var Bu=dg().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 Nx(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(Nx,"bcrypt_pbkdf");pg.exports={BLOCKS:va,HASHSIZE:Uu,hash:Lu,pbkdf:Nx}});var An=le((G3,Pa)=>{"use strict";var En=require("crypto"),Vi;try{Vi=require("cpu-features")()}catch{}var{bindingAvailable:hg,CIPHER_INFO:Ox,MAC_INFO:$x}=Mn(),gg=(()=>{if(typeof En.sign=="function"&&typeof En.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>Wb){this.closeWithError(new Error("FTP control response exceeded maximum allowed size"));return}let r=this._partialResponse+e,n=(0,jb.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",Fh),this.send("QUIT"),this._closeSocket(this._socket)}_closeSocket(e){e&&(this._removeSocketListeners(e),e.on("error",Fh),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}};Di.FTPContext=yu});var Au=le(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.describeTLS=qb;Bi.describeAddress=Qb;Bi.upgradeSocket=Vb;Bi.ipIsPrivateV4Address=Kb;var Hh=require("tls");function qb(t){if(t instanceof Hh.TLSSocket){let e=t.getProtocol();return e||"Server socket or disconnected client socket"}return"No encryption"}c(qb,"describeTLS");function Qb(t){return t.remoteFamily==="IPv6"?`[${t.remoteAddress}]:${t.remotePort}`:`${t.remoteAddress}:${t.remotePort}`}c(Qb,"describeAddress");function Vb(t,e){return new Promise((r,n)=>{let i=Object.assign({},e,{socket:t}),o=(0,Hh.connect)(i,()=>{i.rejectUnauthorized!==!1&&!o.authorized?n(o.authorizationError):(o.removeAllListeners("error"),r(o))}).once("error",s=>{n(s)})})}c(Vb,"upgradeSocket");function Kb(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(Kb,"ipIsPrivateV4Address")});var Fo=le(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Li.FileInfo=Li.FileType=void 0;var Ui;(function(t){t[t.Unknown=0]="Unknown",t[t.File=1]="File",t[t.Directory=2]="Directory",t[t.SymbolicLink=3]="SymbolicLink"})(Ui||(Li.FileType=Ui={}));var aa=class{static{c(this,"FileInfo")}constructor(e){this.name=e,this.type=Ui.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===Ui.Directory}get isSymbolicLink(){return this.type===Ui.SymbolicLink}get isFile(){return this.type===Ui.File}get date(){return this.rawModifiedAt}set date(e){this.rawModifiedAt=e}};Li.FileInfo=aa;aa.UnixPermission={Read:4,Write:2,Execute:1}});var Wh=le(Ho=>{"use strict";Object.defineProperty(Ho,"__esModule",{value:!0});Ho.testLine=Gb;Ho.parseLine=Zb;Ho.transformList=Yb;var bu=Fo(),jh=new RegExp("(\\S+)\\s+(\\S+)\\s+(?:(<DIR>)|([0-9]+))\\s+(\\S.*)");function Gb(t){return/^\d{2}/.test(t)&&jh.test(t)}c(Gb,"testLine");function Zb(t){let e=t.match(jh);if(e===null)return;let r=e[5];if(r==="."||r==="..")return;let n=new bu.FileInfo(r);return e[3]==="<DIR>"?(n.type=bu.FileType.Directory,n.size=0):(n.type=bu.FileType.File,n.size=parseInt(e[4],10)),n.rawModifiedAt=e[1]+" "+e[2],n}c(Zb,"parseLine");function Yb(t){return t}c(Yb,"transformList")});var Qh=le(jo=>{"use strict";Object.defineProperty(jo,"__esModule",{value:!0});jo.testLine=tx;jo.parseLine=rx;jo.transformList=nx;var tn=Fo(),Xb="\u6708",Jb="\u65E5",ex="\u5E74",qh=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}"+Xb+"\\s+\\d{1,2}"+Jb+"))\\s+((?:\\d+(?::\\d+)?)|(?:\\d{4}"+ex+"))\\s(.*)");function tx(t){return qh.test(t)}c(tx,"testLine");function rx(t){let e=t.match(qh);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:xu(e[4],e[5],e[6]),group:xu(e[8],e[9],e[10]),world:xu(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(rx,"parseLine");function nx(t){return t}c(nx,"transformList");function xu(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(xu,"parseMode")});var Iu=le(Mi=>{"use strict";Object.defineProperty(Mi,"__esModule",{value:!0});Mi.testLine=ox;Mi.parseLine=sx;Mi.transformList=ax;Mi.parseMLSxDate=Gh;var zi=Fo();function Vh(t,e){e.size=parseInt(t,10)}c(Vh,"parseSize");var ix={size:Vh,sizd:Vh,unique:c((t,e)=>{e.uniqueID=t},"unique"),modify:c((t,e)=>{e.modifiedAt=Gh(t),e.rawModifiedAt=e.modifiedAt.toISOString()},"modify"),type:c((t,e)=>{if(t.startsWith("OS.unix=slink"))return e.type=zi.FileType.SymbolicLink,e.link=t.substr(t.indexOf(":")+1),1;switch(t){case"file":e.type=zi.FileType.File;break;case"dir":e.type=zi.FileType.Directory;break;case"OS.unix=symlink":e.type=zi.FileType.SymbolicLink;break;case"cdir":case"pdir":return 2;default:e.type=zi.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 Kh(t,e){let r=t.indexOf(e),n=t.substr(0,r),i=t.substr(r+e.length);return[n,i]}c(Kh,"splitStringOnce");function ox(t){return/^\S+=\S+;/.test(t)||t.startsWith(" ")}c(ox,"testLine");function sx(t){let[e,r]=Kh(t," ");if(r===""||r==="."||r==="..")return;let n=new zi.FileInfo(r),i=e.split(";");for(let o of i){let[s,a]=Kh(o,"=");if(!a)continue;let u=ix[s.toLowerCase()];if(!u)continue;if(u(a,n)===2)return}return n}c(sx,"parseLine");function ax(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(ax,"transformList");function Gh(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(Gh,"parseMLSxDate")});var Su=le(_n=>{"use strict";var cx=_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]})),ux=_n&&_n.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),vu=_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"&&cx(r,e,n[i]);return ux(r,e),r}})();Object.defineProperty(_n,"__esModule",{value:!0});_n.parseList=yx;var lx=vu(Wh()),fx=vu(Qh()),dx=vu(Iu()),px=[lx,fx,dx];function hx(t,e){return e.find(r=>r.testLine(t)===!0)}c(hx,"firstCompatibleParser");function gx(t){return t.trim()!==""}c(gx,"isNotBlank");function mx(t){return!t.startsWith("total")}c(mx,"isNotMeta");var _x=/\r?\n/;function yx(t){let e=t.split(_x).filter(gx).filter(mx);if(e.length===0)return[];let r=e[e.length-1],n=hx(r,px);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(yx,"parseList")});var Zh=le(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.ProgressTracker=void 0;var wu=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=Ex(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=wu;function Ex(t,e){let r=setInterval(e,t),n=c(i=>{clearInterval(r),i&&e(),e=ca},"stopFunc");return e(),n}c(Ex,"poll");function ca(){}c(ca,"noop")});var Yh=le(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.StringWriter=void 0;var Ax=require("stream"),Pu=class extends Ax.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=Pu});var Cu=le(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.enterPassiveModeIPv6=bx;rn.parseEpsvResponse=eg;rn.enterPassiveModeIPv4=xx;rn.enterPassiveModeIPv4_forceControlHostIP=Ix;rn.parsePasvResponse=Tu;rn.connectForPassiveTransfer=pa;rn.uploadFrom=vx;rn.downloadTo=Sx;var Fi=Au(),Jh=require("stream"),Xh=require("tls"),fa=oa();async function bx(t){let e=await t.request("EPSV"),r=eg(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(bx,"enterPassiveModeIPv6");function eg(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(eg,"parseEpsvResponse");async function xx(t){let e=await t.request("PASV"),r=Tu(e.message);if(!r)throw new Error("Can't parse PASV response: "+e.message);let n=t.socket.remoteAddress;return(0,Fi.ipIsPrivateV4Address)(r.host)&&n&&!(0,Fi.ipIsPrivateV4Address)(n)&&(r.host=n),await pa(r.host,r.port,t),e}c(xx,"enterPassiveModeIPv4");async function Ix(t){let e=await t.request("PASV"),r=Tu(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(Ix,"enterPassiveModeIPv4_forceControlHostIP");function Tu(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(Tu,"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 Xh.TLSSocket&&(o=(0,Xh.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 vx(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;wx(a,s,"secureConnect",()=>{e.ftp.log(`Uploading to ${(0,Fi.describeAddress)(s)} (${(0,Fi.describeTLS)(s)})`),r.onDataStart(e.remotePath,e.type),(0,Jh.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(vx,"uploadFrom");function Sx(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,Fi.describeAddress)(o)} (${(0,Fi.describeTLS)(o)})`),r.onDataStart(e.remotePath,e.type),(0,Jh.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(Sx,"downloadTo");function wx(t,e,r,n){t===!0?n():e.once(r,()=>n())}c(wx,"onConditionOrEvent")});var og=le(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.Client=void 0;var Bn=require("fs"),ku=require("path"),Px=require("tls"),ji=require("util"),Wo=Eu(),oi=Au(),Ru=oa(),Tx=Su(),Cx=Iu(),kx=Zh(),Rx=Yh(),Hi=Cu(),Nx=(0,ji.promisify)(Bn.readdir),Ox=(0,ji.promisify)(Bn.mkdir),Nu=(0,ji.promisify)(Bn.stat),tg=(0,ji.promisify)(Bn.open),rg=(0,ji.promisify)(Bn.close),$x=(0,ji.promisify)(Bn.unlink),ng={allowSeparateTransferHost:!0,maxListingBytes:40*1024*1024},ig=c(()=>["LIST -a","LIST"],"LIST_COMMANDS_DEFAULT"),Dx=c(()=>["MLSD","LIST -a","LIST"],"LIST_COMMANDS_MLSD"),Ou=class{static{c(this,"Client")}constructor(e=3e4,r=ng){this.availableListCommands=ig();let n={...ng,...r};this.ftp=new Wo.FTPContext(e),this.prepareTransfer=this._enterFirstCompatibleMode([Hi.enterPassiveModeIPv6,n.allowSeparateTransferHost?Hi.enterPassiveModeIPv4:Hi.enterPassiveModeIPv4_forceControlHostIP]),this.options=n,this.parseList=Tx.parseList,this._progressTracker=new kx.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,Ru.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,Ru.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?Dx():ig(),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,Ru.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,Cx.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 tg(e,"r"),s=(0,Bn.createReadStream)("",{fd:o,start:i.localStart,end:i.localEndInclusive,autoClose:!1});try{return await this._uploadFromStream(s,r,n)}finally{await qo(()=>rg(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,Hi.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 tg(e,i?"r+":"w"),a=(0,Bn.createWriteStream)("",{fd:s,start:n,autoClose:!1});try{return await this._downloadToStream(a,r,n)}catch(u){let l=await qo(()=>Nu(e)),d=l&&l.size>0;throw!i&&!d&&await qo(()=>$x(e)),u}finally{await qo(()=>rg(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,Hi.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 Rx.StringWriter(this.options.maxListingBytes);await(0,Hi.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 Nx(e);for(let n of r){let i=(0,ku.join)(e,n),o=await Nu(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 Bx(e);for(let r of await this.list()){if(!r.name||(0,ku.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,ku.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=Ou;async function Bx(t){try{await Nu(t)}catch{await Ox(t,{recursive:!0})}}c(Bx,"ensureLocalDirectory");async function qo(t){try{return await t()}catch{return}}c(qo,"ignoreError")});var ag=le(sg=>{"use strict";Object.defineProperty(sg,"__esModule",{value:!0})});var nn=le(xr=>{"use strict";var Ux=xr&&xr.__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=xr&&xr.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ux(e,t,r)};Object.defineProperty(xr,"__esModule",{value:!0});xr.enterPassiveModeIPv6=xr.enterPassiveModeIPv4=void 0;Qo(og(),xr);Qo(Eu(),xr);Qo(Fo(),xr);Qo(Su(),xr);Qo(ag(),xr);var cg=Cu();Object.defineProperty(xr,"enterPassiveModeIPv4",{enumerable:!0,get:c(function(){return cg.enterPassiveModeIPv4},"get")});Object.defineProperty(xr,"enterPassiveModeIPv6",{enumerable:!0,get:c(function(){return cg.enterPassiveModeIPv6},"get")})});var ga=le((uF,ug)=>{ug.exports={newInvalidAsn1Error:c(function(t){var e=new Error;return e.name="InvalidAsn1Error",e.message=t||"",e},"newInvalidAsn1Error")}});var ma=le((fF,lg)=>{lg.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 $u=le((dF,fg)=>{"use strict";var _a=require("buffer"),Wi=_a.Buffer,zr={},Mr;for(Mr in _a)_a.hasOwnProperty(Mr)&&(Mr==="SlowBuffer"||Mr==="Buffer"||(zr[Mr]=_a[Mr]));var qi=zr.Buffer={};for(Mr in Wi)Wi.hasOwnProperty(Mr)&&(Mr==="allocUnsafe"||Mr==="allocUnsafeSlow"||(qi[Mr]=Wi[Mr]));zr.Buffer.prototype=Wi.prototype;(!qi.from||qi.from===Uint8Array.from)&&(qi.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 Wi(t,e,r)});qi.alloc||(qi.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=Wi(t);return!e||e.length===0?n.fill(0):typeof r=="string"?n.fill(e,r):n.fill(e),n});if(!zr.kStringMaxLength)try{zr.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}zr.constants||(zr.constants={MAX_LENGTH:zr.kMaxLength},zr.kStringMaxLength&&(zr.constants.MAX_STRING_LENGTH=zr.kStringMaxLength));fg.exports=zr});var hg=le((pF,pg)=>{var Lx=require("assert"),dg=$u().Buffer,Vo=ma(),zx=ga(),Qi=zx.newInvalidAsn1Error;function Ir(t){if(!t||!dg.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(Ir,"Reader");Object.defineProperty(Ir.prototype,"length",{enumerable:!0,get:c(function(){return this._len},"get")});Object.defineProperty(Ir.prototype,"offset",{enumerable:!0,get:c(function(){return this._offset},"get")});Object.defineProperty(Ir.prototype,"remain",{get:c(function(){return this._size-this._offset},"get")});Object.defineProperty(Ir.prototype,"buffer",{get:c(function(){return this._buf.slice(this._offset)},"get")});Ir.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};Ir.prototype.peek=function(){return this.readByte(!0)};Ir.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};Ir.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)};Ir.prototype.readInt=function(){return this._readTag(Vo.Integer)};Ir.prototype.readBoolean=function(){return this._readTag(Vo.Boolean)!==0};Ir.prototype.readEnumeration=function(){return this._readTag(Vo.Enumeration)};Ir.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?dg.alloc(0):"";var i=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,e?i:i.toString("utf8")};Ir.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(".")};Ir.prototype._readTag=function(t){Lx.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};pg.exports=Ir});var mg=le((gF,gg)=>{var Un=require("assert"),ya=$u().Buffer,Ln=ma(),Mx=ga(),Ea=Mx.newInvalidAsn1Error,Fx={size:1024,growthFactor:8};function Hx(t,e){Un.ok(t),Un.equal(typeof t,"object"),Un.ok(e),Un.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 yr(t){t=Hx(Fx,t||{}),this._buf=ya.alloc(t.size||1024),this._size=this._buf.length,this._offset=0,this._options=t,this._seq=[]}c(yr,"Writer");Object.defineProperty(yr.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")});yr.prototype.writeByte=function(t){if(typeof t!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=t};yr.prototype.writeInt=function(t,e){if(typeof t!="number")throw new TypeError("argument must be a Number");typeof e!="number"&&(e=Ln.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};yr.prototype.writeNull=function(){this.writeByte(Ln.Null),this.writeByte(0)};yr.prototype.writeEnumeration=function(t,e){if(typeof t!="number")throw new TypeError("argument must be a Number");return typeof e!="number"&&(e=Ln.Enumeration),this.writeInt(t,e)};yr.prototype.writeBoolean=function(t,e){if(typeof t!="boolean")throw new TypeError("argument must be a Boolean");typeof e!="number"&&(e=Ln.Boolean),this._ensure(3),this._buf[this._offset++]=e,this._buf[this._offset++]=1,this._buf[this._offset++]=t?255:0};yr.prototype.writeString=function(t,e){if(typeof t!="string")throw new TypeError("argument must be a string (was: "+typeof t+")");typeof e!="number"&&(e=Ln.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)};yr.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};yr.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)})};yr.prototype.writeOID=function(t,e){if(typeof t!="string")throw new TypeError("argument must be a string");if(typeof e!="number"&&(e=Ln.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)})};yr.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)")};yr.prototype.startSequence=function(t){typeof t!="number"&&(t=Ln.Sequence|Ln.Constructor),this.writeByte(t),this._seq.push(this._offset),this._ensure(3),this._offset+=3};yr.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")};yr.prototype._shift=function(t,e,r){Un.ok(t!==void 0),Un.ok(e!==void 0),Un.ok(r),this._buf.copy(this._buf,t+r,t,t+e),this._offset+=r};yr.prototype._ensure=function(t){if(Un.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}};gg.exports=yr});var _g=le((_F,xa)=>{var Du=ga(),Bu=ma(),jx=hg(),Wx=mg();xa.exports={Reader:jx,Writer:Wx};for(Aa in Bu)Bu.hasOwnProperty(Aa)&&(xa.exports[Aa]=Bu[Aa]);var Aa;for(ba in Du)Du.hasOwnProperty(ba)&&(xa.exports[ba]=Du[ba]);var ba});var Ko=le((yF,yg)=>{var Uu=_g();yg.exports={Ber:Uu,BerReader:Uu.Reader,BerWriter:Uu.Writer}});var Eg=le((EF,Ia)=>{(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 O,z=0;for(O=0;O<x;O++)z|=m[A+O]^y[f+O];return(1&z-1>>>8)-1}c(_,"vn");function b(m,A,y,f){return _(m,A,y,f,16)}c(b,"crypto_verify_16");function E(m,A,y,f){return _(m,A,y,f,32)}c(E,"crypto_verify_32");function v(m,A,y,f){for(var x=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,O=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,ie=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,_t=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,Me=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Fe=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Xe=y[16]&255|(y[17]&255)<<8|(y[18]&255)<<16|(y[19]&255)<<24,Ye=y[20]&255|(y[21]&255)<<8|(y[22]&255)<<16|(y[23]&255)<<24,He=y[24]&255|(y[25]&255)<<8|(y[26]&255)<<16|(y[27]&255)<<24,Ge=y[28]&255|(y[29]&255)<<8|(y[30]&255)<<16|(y[31]&255)<<24,je=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,Ee=x,Ie=O,ge=z,Ae=ie,be=ce,de=ye,Q=pe,K=_t,se=_e,ne=Me,oe=Fe,ae=Xe,ke=Ye,Je=He,rt=Ge,et=je,S,it=0;it<20;it+=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,ne^=S<<7|S>>>25,S=ne+de|0,Je^=S<<9|S>>>23,S=Je+ne|0,Ie^=S<<13|S>>>19,S=Ie+Je|0,de^=S<<18|S>>>14,S=oe+Q|0,rt^=S<<7|S>>>25,S=rt+oe|0,ge^=S<<9|S>>>23,S=ge+rt|0,Q^=S<<13|S>>>19,S=Q+ge|0,oe^=S<<18|S>>>14,S=et+ae|0,Ae^=S<<7|S>>>25,S=Ae+et|0,K^=S<<9|S>>>23,S=K+Ae|0,ae^=S<<13|S>>>19,S=ae+K|0,et^=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,K^=S<<9|S>>>23,S=K+Q|0,be^=S<<13|S>>>19,S=be+K|0,de^=S<<18|S>>>14,S=oe+ne|0,ae^=S<<7|S>>>25,S=ae+oe|0,se^=S<<9|S>>>23,S=se+ae|0,ne^=S<<13|S>>>19,S=ne+se|0,oe^=S<<18|S>>>14,S=et+rt|0,ke^=S<<7|S>>>25,S=ke+et|0,Je^=S<<9|S>>>23,S=Je+ke|0,rt^=S<<13|S>>>19,S=rt+Je|0,et^=S<<18|S>>>14;Ee=Ee+x|0,Ie=Ie+O|0,ge=ge+z|0,Ae=Ae+ie|0,be=be+ce|0,de=de+ye|0,Q=Q+pe|0,K=K+_t|0,se=se+_e|0,ne=ne+Me|0,oe=oe+Fe|0,ae=ae+Xe|0,ke=ke+Ye|0,Je=Je+He|0,rt=rt+Ge|0,et=et+je|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]=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]=ne>>>0&255,m[37]=ne>>>8&255,m[38]=ne>>>16&255,m[39]=ne>>>24&255,m[40]=oe>>>0&255,m[41]=oe>>>8&255,m[42]=oe>>>16&255,m[43]=oe>>>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]=Je>>>0&255,m[53]=Je>>>8&255,m[54]=Je>>>16&255,m[55]=Je>>>24&255,m[56]=rt>>>0&255,m[57]=rt>>>8&255,m[58]=rt>>>16&255,m[59]=rt>>>24&255,m[60]=et>>>0&255,m[61]=et>>>8&255,m[62]=et>>>16&255,m[63]=et>>>24&255}c(v,"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,O=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,ie=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,_t=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,Me=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Fe=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,Xe=y[16]&255|(y[17]&255)<<8|(y[18]&255)<<16|(y[19]&255)<<24,Ye=y[20]&255|(y[21]&255)<<8|(y[22]&255)<<16|(y[23]&255)<<24,He=y[24]&255|(y[25]&255)<<8|(y[26]&255)<<16|(y[27]&255)<<24,Ge=y[28]&255|(y[29]&255)<<8|(y[30]&255)<<16|(y[31]&255)<<24,je=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,Ee=x,Ie=O,ge=z,Ae=ie,be=ce,de=ye,Q=pe,K=_t,se=_e,ne=Me,oe=Fe,ae=Xe,ke=Ye,Je=He,rt=Ge,et=je,S,it=0;it<20;it+=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,ne^=S<<7|S>>>25,S=ne+de|0,Je^=S<<9|S>>>23,S=Je+ne|0,Ie^=S<<13|S>>>19,S=Ie+Je|0,de^=S<<18|S>>>14,S=oe+Q|0,rt^=S<<7|S>>>25,S=rt+oe|0,ge^=S<<9|S>>>23,S=ge+rt|0,Q^=S<<13|S>>>19,S=Q+ge|0,oe^=S<<18|S>>>14,S=et+ae|0,Ae^=S<<7|S>>>25,S=Ae+et|0,K^=S<<9|S>>>23,S=K+Ae|0,ae^=S<<13|S>>>19,S=ae+K|0,et^=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,K^=S<<9|S>>>23,S=K+Q|0,be^=S<<13|S>>>19,S=be+K|0,de^=S<<18|S>>>14,S=oe+ne|0,ae^=S<<7|S>>>25,S=ae+oe|0,se^=S<<9|S>>>23,S=se+ae|0,ne^=S<<13|S>>>19,S=ne+se|0,oe^=S<<18|S>>>14,S=et+rt|0,ke^=S<<7|S>>>25,S=ke+et|0,Je^=S<<9|S>>>23,S=Je+ke|0,rt^=S<<13|S>>>19,S=rt+Je|0,et^=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]=oe>>>0&255,m[9]=oe>>>8&255,m[10]=oe>>>16&255,m[11]=oe>>>24&255,m[12]=et>>>0&255,m[13]=et>>>8&255,m[14]=et>>>16&255,m[15]=et>>>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]=ne>>>0&255,m[29]=ne>>>8&255,m[30]=ne>>>16&255,m[31]=ne>>>24&255}c(w,"core_hsalsa20");function H(m,A,y,f){v(m,A,y,f)}c(H,"crypto_core_salsa20");function D(m,A,y,f){w(m,A,y,f)}c(D,"crypto_core_hsalsa20");var J=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Y(m,A,y,f,x,O,z){var ie=new Uint8Array(16),ce=new Uint8Array(64),ye,pe;for(pe=0;pe<16;pe++)ie[pe]=0;for(pe=0;pe<8;pe++)ie[pe]=O[pe];for(;x>=64;){for(H(ce,ie,z,J),pe=0;pe<64;pe++)m[A+pe]=y[f+pe]^ce[pe];for(ye=1,pe=8;pe<16;pe++)ye=ye+(ie[pe]&255)|0,ie[pe]=ye&255,ye>>>=8;x-=64,A+=64,f+=64}if(x>0)for(H(ce,ie,z,J),pe=0;pe<x;pe++)m[A+pe]=y[f+pe]^ce[pe];return 0}c(Y,"crypto_stream_salsa20_xor");function X(m,A,y,f,x){var O=new Uint8Array(16),z=new Uint8Array(64),ie,ce;for(ce=0;ce<16;ce++)O[ce]=0;for(ce=0;ce<8;ce++)O[ce]=f[ce];for(;y>=64;){for(H(z,O,x,J),ce=0;ce<64;ce++)m[A+ce]=z[ce];for(ie=1,ce=8;ce<16;ce++)ie=ie+(O[ce]&255)|0,O[ce]=ie&255,ie>>>=8;y-=64,A+=64}if(y>0)for(H(z,O,x,J),ce=0;ce<y;ce++)m[A+ce]=z[ce];return 0}c(X,"crypto_stream_salsa20");function P(m,A,y,f,x){var O=new Uint8Array(32);D(O,f,x,J);for(var z=new Uint8Array(8),ie=0;ie<8;ie++)z[ie]=f[ie+16];return X(m,A,y,z,O)}c(P,"crypto_stream");function C(m,A,y,f,x,O,z){var ie=new Uint8Array(32);D(ie,O,z,J);for(var ce=new Uint8Array(8),ye=0;ye<8;ye++)ce[ye]=O[ye+16];return Y(m,A,y,f,x,ce,ie)}c(C,"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,O,z,ie,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,O=m[8]&255|(m[9]&255)<<8,this.r[4]=(x>>>4|O<<12)&255,this.r[5]=O>>>1&8190,z=m[10]&255|(m[11]&255)<<8,this.r[6]=(O>>>14|z<<2)&8191,ie=m[12]&255|(m[13]&255)<<8,this.r[7]=(z>>>11|ie<<5)&8065,ce=m[14]&255|(m[15]&255)<<8,this.r[8]=(ie>>>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,O,z,ie,ce,ye,pe,_t,_e,Me,Fe,Xe,Ye,He,Ge,je,Ee,Ie,ge,Ae=this.h[0],be=this.h[1],de=this.h[2],Q=this.h[3],K=this.h[4],se=this.h[5],ne=this.h[6],oe=this.h[7],ae=this.h[8],ke=this.h[9],Je=this.r[0],rt=this.r[1],et=this.r[2],S=this.r[3],it=this.r[4],yt=this.r[5],Et=this.r[6],nt=this.r[7],pt=this.r[8],ht=this.r[9];y>=16;)x=m[A+0]&255|(m[A+1]&255)<<8,Ae+=x&8191,O=m[A+2]&255|(m[A+3]&255)<<8,be+=(x>>>13|O<<3)&8191,z=m[A+4]&255|(m[A+5]&255)<<8,de+=(O>>>10|z<<6)&8191,ie=m[A+6]&255|(m[A+7]&255)<<8,Q+=(z>>>7|ie<<9)&8191,ce=m[A+8]&255|(m[A+9]&255)<<8,K+=(ie>>>4|ce<<12)&8191,se+=ce>>>1&8191,ye=m[A+10]&255|(m[A+11]&255)<<8,ne+=(ce>>>14|ye<<2)&8191,pe=m[A+12]&255|(m[A+13]&255)<<8,oe+=(ye>>>11|pe<<5)&8191,_t=m[A+14]&255|(m[A+15]&255)<<8,ae+=(pe>>>8|_t<<8)&8191,ke+=_t>>>5|f,_e=0,Me=_e,Me+=Ae*Je,Me+=be*(5*ht),Me+=de*(5*pt),Me+=Q*(5*nt),Me+=K*(5*Et),_e=Me>>>13,Me&=8191,Me+=se*(5*yt),Me+=ne*(5*it),Me+=oe*(5*S),Me+=ae*(5*et),Me+=ke*(5*rt),_e+=Me>>>13,Me&=8191,Fe=_e,Fe+=Ae*rt,Fe+=be*Je,Fe+=de*(5*ht),Fe+=Q*(5*pt),Fe+=K*(5*nt),_e=Fe>>>13,Fe&=8191,Fe+=se*(5*Et),Fe+=ne*(5*yt),Fe+=oe*(5*it),Fe+=ae*(5*S),Fe+=ke*(5*et),_e+=Fe>>>13,Fe&=8191,Xe=_e,Xe+=Ae*et,Xe+=be*rt,Xe+=de*Je,Xe+=Q*(5*ht),Xe+=K*(5*pt),_e=Xe>>>13,Xe&=8191,Xe+=se*(5*nt),Xe+=ne*(5*Et),Xe+=oe*(5*yt),Xe+=ae*(5*it),Xe+=ke*(5*S),_e+=Xe>>>13,Xe&=8191,Ye=_e,Ye+=Ae*S,Ye+=be*et,Ye+=de*rt,Ye+=Q*Je,Ye+=K*(5*ht),_e=Ye>>>13,Ye&=8191,Ye+=se*(5*pt),Ye+=ne*(5*nt),Ye+=oe*(5*Et),Ye+=ae*(5*yt),Ye+=ke*(5*it),_e+=Ye>>>13,Ye&=8191,He=_e,He+=Ae*it,He+=be*S,He+=de*et,He+=Q*rt,He+=K*Je,_e=He>>>13,He&=8191,He+=se*(5*ht),He+=ne*(5*pt),He+=oe*(5*nt),He+=ae*(5*Et),He+=ke*(5*yt),_e+=He>>>13,He&=8191,Ge=_e,Ge+=Ae*yt,Ge+=be*it,Ge+=de*S,Ge+=Q*et,Ge+=K*rt,_e=Ge>>>13,Ge&=8191,Ge+=se*Je,Ge+=ne*(5*ht),Ge+=oe*(5*pt),Ge+=ae*(5*nt),Ge+=ke*(5*Et),_e+=Ge>>>13,Ge&=8191,je=_e,je+=Ae*Et,je+=be*yt,je+=de*it,je+=Q*S,je+=K*et,_e=je>>>13,je&=8191,je+=se*rt,je+=ne*Je,je+=oe*(5*ht),je+=ae*(5*pt),je+=ke*(5*nt),_e+=je>>>13,je&=8191,Ee=_e,Ee+=Ae*nt,Ee+=be*Et,Ee+=de*yt,Ee+=Q*it,Ee+=K*S,_e=Ee>>>13,Ee&=8191,Ee+=se*et,Ee+=ne*rt,Ee+=oe*Je,Ee+=ae*(5*ht),Ee+=ke*(5*pt),_e+=Ee>>>13,Ee&=8191,Ie=_e,Ie+=Ae*pt,Ie+=be*nt,Ie+=de*Et,Ie+=Q*yt,Ie+=K*it,_e=Ie>>>13,Ie&=8191,Ie+=se*S,Ie+=ne*et,Ie+=oe*rt,Ie+=ae*Je,Ie+=ke*(5*ht),_e+=Ie>>>13,Ie&=8191,ge=_e,ge+=Ae*ht,ge+=be*pt,ge+=de*nt,ge+=Q*Et,ge+=K*yt,_e=ge>>>13,ge&=8191,ge+=se*it,ge+=ne*S,ge+=oe*et,ge+=ae*rt,ge+=ke*Je,_e+=ge>>>13,ge&=8191,_e=(_e<<2)+_e|0,_e=_e+Me|0,Me=_e&8191,_e=_e>>>13,Fe+=_e,Ae=Me,be=Fe,de=Xe,Q=Ye,K=He,se=Ge,ne=je,oe=Ee,ae=Ie,ke=ge,A+=16,y-=16;this.h[0]=Ae,this.h[1]=be,this.h[2]=de,this.h[3]=Q,this.h[4]=K,this.h[5]=se,this.h[6]=ne,this.h[7]=oe,this.h[8]=ae,this.h[9]=ke},M.prototype.finish=function(m,A){var y=new Uint16Array(10),f,x,O,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,O=this.h[0]+this.pad[0],this.h[0]=O&65535,z=1;z<8;z++)O=(this.h[z]+this.pad[z]|0)+(O>>>16)|0,this.h[z]=O&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,O){var z=new M(O);return z.update(y,f,x),z.finish(m,A),0}c(L,"crypto_onetimeauth");function T(m,A,y,f,x,O){var z=new Uint8Array(16);return L(z,0,y,f,x,O),b(m,A,z,0)}c(T,"crypto_onetimeauth_verify");function F(m,A,y,f,x){var O;if(y<32)return-1;for(C(m,0,A,0,y,f,x),L(m,16,m,32,y-32,m),O=0;O<16;O++)m[O]=0;return 0}c(F,"crypto_secretbox");function j(m,A,y,f,x){var O,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(C(m,0,A,0,y,f,x),O=0;O<32;O++)m[O]=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 Z(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(Z,"car25519");function te(m,A,y){for(var f,x=~(y-1),O=0;O<16;O++)f=x&(m[O]^A[O]),m[O]^=f,A[O]^=f}c(te,"sel25519");function k(m,A){var y,f,x,O=e(),z=e();for(y=0;y<16;y++)z[y]=A[y];for(Z(z),Z(z),Z(z),f=0;f<2;f++){for(O[0]=z[0]-65517,y=1;y<15;y++)O[y]=z[y]-65535-(O[y-1]>>16&1),O[y-1]&=65535;O[15]=z[15]-32767-(O[14]>>16&1),x=O[15]>>16&1,O[14]&=65535,te(z,O,1-x)}for(y=0;y<16;y++)m[2*y]=z[y]&255,m[2*y+1]=z[y]>>8}c(k,"pack25519");function W(m,A){var y=new Uint8Array(32),f=new Uint8Array(32);return k(y,m),k(f,A),E(y,0,f,0)}c(W,"neq25519");function q(m){var A=new Uint8Array(32);return k(A,m),A[0]&1}c(q,"par25519");function ee(m,A){var y;for(y=0;y<16;y++)m[y]=A[2*y]+(A[2*y+1]<<8);m[15]&=32767}c(ee,"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,O=0,z=0,ie=0,ce=0,ye=0,pe=0,_t=0,_e=0,Me=0,Fe=0,Xe=0,Ye=0,He=0,Ge=0,je=0,Ee=0,Ie=0,ge=0,Ae=0,be=0,de=0,Q=0,K=0,se=0,ne=0,oe=0,ae=0,ke=0,Je=0,rt=0,et=0,S=y[0],it=y[1],yt=y[2],Et=y[3],nt=y[4],pt=y[5],ht=y[6],Yt=y[7],vt=y[8],qt=y[9],Qt=y[10],Vt=y[11],sr=y[12],pr=y[13],hr=y[14],gr=y[15];f=A[0],O+=f*S,z+=f*it,ie+=f*yt,ce+=f*Et,ye+=f*nt,pe+=f*pt,_t+=f*ht,_e+=f*Yt,Me+=f*vt,Fe+=f*qt,Xe+=f*Qt,Ye+=f*Vt,He+=f*sr,Ge+=f*pr,je+=f*hr,Ee+=f*gr,f=A[1],z+=f*S,ie+=f*it,ce+=f*yt,ye+=f*Et,pe+=f*nt,_t+=f*pt,_e+=f*ht,Me+=f*Yt,Fe+=f*vt,Xe+=f*qt,Ye+=f*Qt,He+=f*Vt,Ge+=f*sr,je+=f*pr,Ee+=f*hr,Ie+=f*gr,f=A[2],ie+=f*S,ce+=f*it,ye+=f*yt,pe+=f*Et,_t+=f*nt,_e+=f*pt,Me+=f*ht,Fe+=f*Yt,Xe+=f*vt,Ye+=f*qt,He+=f*Qt,Ge+=f*Vt,je+=f*sr,Ee+=f*pr,Ie+=f*hr,ge+=f*gr,f=A[3],ce+=f*S,ye+=f*it,pe+=f*yt,_t+=f*Et,_e+=f*nt,Me+=f*pt,Fe+=f*ht,Xe+=f*Yt,Ye+=f*vt,He+=f*qt,Ge+=f*Qt,je+=f*Vt,Ee+=f*sr,Ie+=f*pr,ge+=f*hr,Ae+=f*gr,f=A[4],ye+=f*S,pe+=f*it,_t+=f*yt,_e+=f*Et,Me+=f*nt,Fe+=f*pt,Xe+=f*ht,Ye+=f*Yt,He+=f*vt,Ge+=f*qt,je+=f*Qt,Ee+=f*Vt,Ie+=f*sr,ge+=f*pr,Ae+=f*hr,be+=f*gr,f=A[5],pe+=f*S,_t+=f*it,_e+=f*yt,Me+=f*Et,Fe+=f*nt,Xe+=f*pt,Ye+=f*ht,He+=f*Yt,Ge+=f*vt,je+=f*qt,Ee+=f*Qt,Ie+=f*Vt,ge+=f*sr,Ae+=f*pr,be+=f*hr,de+=f*gr,f=A[6],_t+=f*S,_e+=f*it,Me+=f*yt,Fe+=f*Et,Xe+=f*nt,Ye+=f*pt,He+=f*ht,Ge+=f*Yt,je+=f*vt,Ee+=f*qt,Ie+=f*Qt,ge+=f*Vt,Ae+=f*sr,be+=f*pr,de+=f*hr,Q+=f*gr,f=A[7],_e+=f*S,Me+=f*it,Fe+=f*yt,Xe+=f*Et,Ye+=f*nt,He+=f*pt,Ge+=f*ht,je+=f*Yt,Ee+=f*vt,Ie+=f*qt,ge+=f*Qt,Ae+=f*Vt,be+=f*sr,de+=f*pr,Q+=f*hr,K+=f*gr,f=A[8],Me+=f*S,Fe+=f*it,Xe+=f*yt,Ye+=f*Et,He+=f*nt,Ge+=f*pt,je+=f*ht,Ee+=f*Yt,Ie+=f*vt,ge+=f*qt,Ae+=f*Qt,be+=f*Vt,de+=f*sr,Q+=f*pr,K+=f*hr,se+=f*gr,f=A[9],Fe+=f*S,Xe+=f*it,Ye+=f*yt,He+=f*Et,Ge+=f*nt,je+=f*pt,Ee+=f*ht,Ie+=f*Yt,ge+=f*vt,Ae+=f*qt,be+=f*Qt,de+=f*Vt,Q+=f*sr,K+=f*pr,se+=f*hr,ne+=f*gr,f=A[10],Xe+=f*S,Ye+=f*it,He+=f*yt,Ge+=f*Et,je+=f*nt,Ee+=f*pt,Ie+=f*ht,ge+=f*Yt,Ae+=f*vt,be+=f*qt,de+=f*Qt,Q+=f*Vt,K+=f*sr,se+=f*pr,ne+=f*hr,oe+=f*gr,f=A[11],Ye+=f*S,He+=f*it,Ge+=f*yt,je+=f*Et,Ee+=f*nt,Ie+=f*pt,ge+=f*ht,Ae+=f*Yt,be+=f*vt,de+=f*qt,Q+=f*Qt,K+=f*Vt,se+=f*sr,ne+=f*pr,oe+=f*hr,ae+=f*gr,f=A[12],He+=f*S,Ge+=f*it,je+=f*yt,Ee+=f*Et,Ie+=f*nt,ge+=f*pt,Ae+=f*ht,be+=f*Yt,de+=f*vt,Q+=f*qt,K+=f*Qt,se+=f*Vt,ne+=f*sr,oe+=f*pr,ae+=f*hr,ke+=f*gr,f=A[13],Ge+=f*S,je+=f*it,Ee+=f*yt,Ie+=f*Et,ge+=f*nt,Ae+=f*pt,be+=f*ht,de+=f*Yt,Q+=f*vt,K+=f*qt,se+=f*Qt,ne+=f*Vt,oe+=f*sr,ae+=f*pr,ke+=f*hr,Je+=f*gr,f=A[14],je+=f*S,Ee+=f*it,Ie+=f*yt,ge+=f*Et,Ae+=f*nt,be+=f*pt,de+=f*ht,Q+=f*Yt,K+=f*vt,se+=f*qt,ne+=f*Qt,oe+=f*Vt,ae+=f*sr,ke+=f*pr,Je+=f*hr,rt+=f*gr,f=A[15],Ee+=f*S,Ie+=f*it,ge+=f*yt,Ae+=f*Et,be+=f*nt,de+=f*pt,Q+=f*ht,K+=f*Yt,se+=f*vt,ne+=f*qt,oe+=f*Qt,ae+=f*Vt,ke+=f*sr,Je+=f*pr,rt+=f*hr,et+=f*gr,O+=38*Ie,z+=38*ge,ie+=38*Ae,ce+=38*be,ye+=38*de,pe+=38*Q,_t+=38*K,_e+=38*se,Me+=38*ne,Fe+=38*oe,Xe+=38*ae,Ye+=38*ke,He+=38*Je,Ge+=38*rt,je+=38*et,x=1,f=O+x+65535,x=Math.floor(f/65536),O=f-x*65536,f=z+x+65535,x=Math.floor(f/65536),z=f-x*65536,f=ie+x+65535,x=Math.floor(f/65536),ie=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=_t+x+65535,x=Math.floor(f/65536),_t=f-x*65536,f=_e+x+65535,x=Math.floor(f/65536),_e=f-x*65536,f=Me+x+65535,x=Math.floor(f/65536),Me=f-x*65536,f=Fe+x+65535,x=Math.floor(f/65536),Fe=f-x*65536,f=Xe+x+65535,x=Math.floor(f/65536),Xe=f-x*65536,f=Ye+x+65535,x=Math.floor(f/65536),Ye=f-x*65536,f=He+x+65535,x=Math.floor(f/65536),He=f-x*65536,f=Ge+x+65535,x=Math.floor(f/65536),Ge=f-x*65536,f=je+x+65535,x=Math.floor(f/65536),je=f-x*65536,f=Ee+x+65535,x=Math.floor(f/65536),Ee=f-x*65536,O+=x-1+37*(x-1),x=1,f=O+x+65535,x=Math.floor(f/65536),O=f-x*65536,f=z+x+65535,x=Math.floor(f/65536),z=f-x*65536,f=ie+x+65535,x=Math.floor(f/65536),ie=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=_t+x+65535,x=Math.floor(f/65536),_t=f-x*65536,f=_e+x+65535,x=Math.floor(f/65536),_e=f-x*65536,f=Me+x+65535,x=Math.floor(f/65536),Me=f-x*65536,f=Fe+x+65535,x=Math.floor(f/65536),Fe=f-x*65536,f=Xe+x+65535,x=Math.floor(f/65536),Xe=f-x*65536,f=Ye+x+65535,x=Math.floor(f/65536),Ye=f-x*65536,f=He+x+65535,x=Math.floor(f/65536),He=f-x*65536,f=Ge+x+65535,x=Math.floor(f/65536),Ge=f-x*65536,f=je+x+65535,x=Math.floor(f/65536),je=f-x*65536,f=Ee+x+65535,x=Math.floor(f/65536),Ee=f-x*65536,O+=x-1+37*(x-1),m[0]=O,m[1]=z,m[2]=ie,m[3]=ce,m[4]=ye,m[5]=pe,m[6]=_t,m[7]=_e,m[8]=Me,m[9]=Fe,m[10]=Xe,m[11]=Ye,m[12]=He,m[13]=Ge,m[14]=je,m[15]=Ee}c(he,"M");function xt(m,A){he(m,A,A)}c(xt,"S");function kt(m,A){var y=e(),f;for(f=0;f<16;f++)y[f]=A[f];for(f=253;f>=0;f--)xt(y,y),f!==2&&f!==4&&he(y,y,A);for(f=0;f<16;f++)m[f]=y[f]}c(kt,"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--)xt(y,y),f!==1&&he(y,y,A);for(f=0;f<16;f++)m[f]=y[f]}c(Xt,"pow2523");function Ar(m,A,y){var f=new Uint8Array(32),x=new Float64Array(80),O,z,ie=e(),ce=e(),ye=e(),pe=e(),_t=e(),_e=e();for(z=0;z<31;z++)f[z]=A[z];for(f[31]=A[31]&127|64,f[0]&=248,ee(x,y),z=0;z<16;z++)ce[z]=x[z],pe[z]=ie[z]=ye[z]=0;for(ie[0]=pe[0]=1,z=254;z>=0;--z)O=f[z>>>3]>>>(z&7)&1,te(ie,ce,O),te(ye,pe,O),ue(_t,ie,ye),me(ie,ie,ye),ue(ye,ce,pe),me(ce,ce,pe),xt(pe,_t),xt(_e,ie),he(ie,ye,ie),he(ye,ce,_t),ue(_t,ie,ye),me(ie,ie,ye),xt(ce,ie),me(ye,pe,_e),he(ie,ye,a),ue(ie,ie,pe),he(ye,ye,ie),he(ie,pe,_e),he(pe,ce,x),xt(ce,_t),te(ie,ce,O),te(ye,pe,O);for(z=0;z<16;z++)x[z+16]=ie[z],x[z+32]=ye[z],x[z+48]=ce[z],x[z+64]=pe[z];var Me=x.subarray(32),Fe=x.subarray(16);return kt(Me,Me),he(Fe,Fe,Me),k(m,Fe),0}c(Ar,"crypto_scalarmult");function Br(m,A){return Ar(m,A,i)}c(Br,"crypto_scalarmult_base");function Sr(m,A){return r(A,32),Br(m,A)}c(Sr,"crypto_box_keypair");function Ai(m,A,y){var f=new Uint8Array(32);return Ar(f,y,A),D(m,n,f,J)}c(Ai,"crypto_box_beforenm");var mo=F,Bs=j;function _o(m,A,y,f,x,O){var z=new Uint8Array(32);return Ai(z,x,O),mo(m,A,y,f,z)}c(_o,"crypto_box");function bi(m,A,y,f,x,O){var z=new Uint8Array(32);return Ai(z,x,O),Bs(m,A,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 re(m,A,y,f){for(var x=new Int32Array(16),O=new Int32Array(16),z,ie,ce,ye,pe,_t,_e,Me,Fe,Xe,Ye,He,Ge,je,Ee,Ie,ge,Ae,be,de,Q,K,se,ne,oe,ae,ke=m[0],Je=m[1],rt=m[2],et=m[3],S=m[4],it=m[5],yt=m[6],Et=m[7],nt=A[0],pt=A[1],ht=A[2],Yt=A[3],vt=A[4],qt=A[5],Qt=A[6],Vt=A[7],sr=0;f>=128;){for(be=0;be<16;be++)de=8*be+sr,x[be]=y[de+0]<<24|y[de+1]<<16|y[de+2]<<8|y[de+3],O[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,ie=Je,ce=rt,ye=et,pe=S,_t=it,_e=yt,Me=Et,Fe=nt,Xe=pt,Ye=ht,He=Yt,Ge=vt,je=qt,Ee=Qt,Ie=Vt,Q=Et,K=Vt,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=(S>>>14|vt<<18)^(S>>>18|vt<<14)^(vt>>>9|S<<23),K=(vt>>>14|S<<18)^(vt>>>18|S<<14)^(S>>>9|vt<<23),se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,Q=S&it^~S&yt,K=vt&qt^~vt&Qt,se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,Q=xi[be*2],K=xi[be*2+1],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,Q=x[be%16],K=O[be%16],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,ge=oe&65535|ae<<16,Ae=se&65535|ne<<16,Q=ge,K=Ae,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=(ke>>>28|nt<<4)^(nt>>>2|ke<<30)^(nt>>>7|ke<<25),K=(nt>>>28|ke<<4)^(ke>>>2|nt<<30)^(ke>>>7|nt<<25),se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,Q=ke&Je^ke&rt^Je&rt,K=nt&pt^nt&ht^pt&ht,se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,Me=oe&65535|ae<<16,Ie=se&65535|ne<<16,Q=ye,K=He,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=ge,K=Ae,se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,ye=oe&65535|ae<<16,He=se&65535|ne<<16,Je=z,rt=ie,et=ce,S=ye,it=pe,yt=_t,Et=_e,ke=Me,pt=Fe,ht=Xe,Yt=Ye,vt=He,qt=Ge,Qt=je,Vt=Ee,nt=Ie,be%16===15)for(de=0;de<16;de++)Q=x[de],K=O[de],se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=x[(de+9)%16],K=O[(de+9)%16],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ge=x[(de+1)%16],Ae=O[(de+1)%16],Q=(ge>>>1|Ae<<31)^(ge>>>8|Ae<<24)^ge>>>7,K=(Ae>>>1|ge<<31)^(Ae>>>8|ge<<24)^(Ae>>>7|ge<<25),se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ge=x[(de+14)%16],Ae=O[(de+14)%16],Q=(ge>>>19|Ae<<13)^(Ae>>>29|ge<<3)^ge>>>6,K=(Ae>>>19|ge<<13)^(ge>>>29|Ae<<3)^(Ae>>>6|ge<<26),se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,x[de]=oe&65535|ae<<16,O[de]=se&65535|ne<<16;Q=ke,K=nt,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=m[0],K=A[0],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,m[0]=ke=oe&65535|ae<<16,A[0]=nt=se&65535|ne<<16,Q=Je,K=pt,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=m[1],K=A[1],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,m[1]=Je=oe&65535|ae<<16,A[1]=pt=se&65535|ne<<16,Q=rt,K=ht,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=m[2],K=A[2],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,m[2]=rt=oe&65535|ae<<16,A[2]=ht=se&65535|ne<<16,Q=et,K=Yt,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=m[3],K=A[3],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,m[3]=et=oe&65535|ae<<16,A[3]=Yt=se&65535|ne<<16,Q=S,K=vt,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=m[4],K=A[4],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,m[4]=S=oe&65535|ae<<16,A[4]=vt=se&65535|ne<<16,Q=it,K=qt,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=m[5],K=A[5],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,m[5]=it=oe&65535|ae<<16,A[5]=qt=se&65535|ne<<16,Q=yt,K=Qt,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=m[6],K=A[6],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,m[6]=yt=oe&65535|ae<<16,A[6]=Qt=se&65535|ne<<16,Q=Et,K=Vt,se=K&65535,ne=K>>>16,oe=Q&65535,ae=Q>>>16,Q=m[7],K=A[7],se+=K&65535,ne+=K>>>16,oe+=Q&65535,ae+=Q>>>16,ne+=se>>>16,oe+=ne>>>16,ae+=oe>>>16,m[7]=Et=oe&65535|ae<<16,A[7]=Vt=se&65535|ne<<16,sr+=128,f-=128}return f}c(re,"crypto_hashblocks_hl");function fe(m,A,y){var f=new Int32Array(8),x=new Int32Array(8),O=new Uint8Array(256),z,ie=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,re(f,x,A,y),y%=128,z=0;z<y;z++)O[z]=A[ie-y+z];for(O[y]=128,y=256-128*(y<112?1:0),O[y-9]=0,h(O,y-8,ie/536870912|0,ie<<3),re(f,x,O,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(),O=e(),z=e(),ie=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(O,m[2],A[2]),ue(O,O,O),me(z,f,y),me(ie,O,x),ue(ce,O,x),ue(ye,f,y),he(m[0],z,ie),he(m[1],ye,ce),he(m[2],ce,ie),he(m[3],z,ye)}c(ve,"add");function Be(m,A,y){var f;for(f=0;f<4;f++)te(m[f],A[f],y)}c(Be,"cswap");function ut(m,A){var y=e(),f=e(),x=e();kt(x,A[2]),he(y,A[0],x),he(f,A[1],x),k(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,Be(m,A,f),ve(A,m),ve(m,m),Be(m,A,f)}c(Jt,"scalarmult");function Xr(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(Xr,"scalarbase");function kr(m,A,y){var f=new Uint8Array(64),x=[e(),e(),e(),e()],O;for(y||r(A,32),fe(f,A,32),f[0]&=248,f[31]&=127,f[31]|=64,Xr(x,f),ut(m,x),O=0;O<32;O++)A[O+32]=m[O];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 It(m,A){var y,f,x,O;for(f=63;f>=32;--f){for(y=0,x=f-32,O=f-12;x<O;++x)A[x]+=y-16*A[f]*Ii[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)*Ii[x],y=A[x]>>8,A[x]&=255;for(x=0;x<32;x++)A[x]-=y*Ii[x];for(f=0;f<32;f++)A[f+1]+=A[f]>>8,m[f]=A[f]&255}c(It,"modL");function ar(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;It(m,A)}c(ar,"reduce");function or(m,A,y,f){var x=new Uint8Array(64),O=new Uint8Array(64),z=new Uint8Array(64),ie,ce,ye=new Float64Array(64),pe=[e(),e(),e(),e()];fe(x,f,32),x[0]&=248,x[31]&=127,x[31]|=64;var _t=y+64;for(ie=0;ie<y;ie++)m[64+ie]=A[ie];for(ie=0;ie<32;ie++)m[32+ie]=x[32+ie];for(fe(z,m.subarray(32),y+32),ar(z),Xr(pe,z),ut(m,pe),ie=32;ie<64;ie++)m[ie]=f[ie];for(fe(O,m,y+64),ar(O),ie=0;ie<64;ie++)ye[ie]=0;for(ie=0;ie<32;ie++)ye[ie]=z[ie];for(ie=0;ie<32;ie++)for(ce=0;ce<32;ce++)ye[ie+ce]+=O[ie]*x[ce];return It(m.subarray(32),ye),_t}c(or,"crypto_sign");function jt(m,A){var y=e(),f=e(),x=e(),O=e(),z=e(),ie=e(),ce=e();return B(m[2],s),ee(m[1],A),xt(x,m[1]),he(O,x,u),me(x,x,m[2]),ue(O,m[2],O),xt(z,O),xt(ie,z),he(ce,ie,z),he(y,ce,x),he(y,y,O),Xt(y,y),he(y,y,x),he(y,y,O),he(y,y,O),he(m[0],y,O),xt(f,m[0]),he(f,f,O),W(f,x)&&he(m[0],m[0],g),xt(f,m[0]),he(f,f,O),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(jt,"unpackneg");function Pt(m,A,y,f){var x,O,z=new Uint8Array(32),ie=new Uint8Array(64),ce=[e(),e(),e(),e()],ye=[e(),e(),e(),e()];if(O=-1,y<64||jt(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(ie,m,y),ar(ie),Jt(ce,ye,ie),Xr(ye,A.subarray(32)),ve(ce,ye),ut(z,ce),y-=64,E(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 O=y,O}c(Pt,"crypto_sign_open");var Ur=32,Wt=24,ei=32,vi=16,yo=32,Us=32,Eo=32,Ao=32,Cc=32,fd=Wt,GE=ei,ZE=vi,ln=64,ti=32,Si=64,kc=32,Rc=64;t.lowlevel={crypto_core_hsalsa20:D,crypto_stream_xor:C,crypto_stream:P,crypto_stream_salsa20_xor:Y,crypto_stream_salsa20:X,crypto_onetimeauth:L,crypto_onetimeauth_verify:T,crypto_verify_16:b,crypto_verify_32:E,crypto_secretbox:F,crypto_secretbox_open:j,crypto_scalarmult:Ar,crypto_scalarmult_base:Br,crypto_box_beforenm:Ai,crypto_box_afternm:mo,crypto_box:_o,crypto_box_open:bi,crypto_box_keypair:Sr,crypto_hash:fe,crypto_sign:or,crypto_sign_keypair:kr,crypto_sign_open:Pt,crypto_secretbox_KEYBYTES:Ur,crypto_secretbox_NONCEBYTES:Wt,crypto_secretbox_ZEROBYTES:ei,crypto_secretbox_BOXZEROBYTES:vi,crypto_scalarmult_BYTES:yo,crypto_scalarmult_SCALARBYTES:Us,crypto_box_PUBLICKEYBYTES:Eo,crypto_box_SECRETKEYBYTES:Ao,crypto_box_BEFORENMBYTES:Cc,crypto_box_NONCEBYTES:fd,crypto_box_ZEROBYTES:GE,crypto_box_BOXZEROBYTES:ZE,crypto_sign_BYTES:ln,crypto_sign_PUBLICKEYBYTES:ti,crypto_sign_SECRETKEYBYTES:Si,crypto_sign_SEEDBYTES:kc,crypto_hash_BYTES:Rc};function dd(m,A){if(m.length!==Ur)throw new Error("bad key size");if(A.length!==Wt)throw new Error("bad nonce size")}c(dd,"checkLengths");function YE(m,A){if(m.length!==Eo)throw new Error("bad public key size");if(A.length!==Ao)throw new Error("bad secret key size")}c(YE,"checkBoxLengths");function Rr(){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(Rr,"checkArrayTypes");function pd(m){for(var A=0;A<m.length;A++)m[A]=0}c(pd,"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){Rr(m,A,y),dd(y,A);for(var f=new Uint8Array(ei+m.length),x=new Uint8Array(f.length),O=0;O<m.length;O++)f[O+ei]=m[O];return F(x,f,f.length,A,y),x.subarray(vi)},t.secretbox.open=function(m,A,y){Rr(m,A,y),dd(y,A);for(var f=new Uint8Array(vi+m.length),x=new Uint8Array(f.length),O=0;O<m.length;O++)f[O+vi]=m[O];return f.length<32||j(x,f,f.length,A,y)!==0?!1:x.subarray(ei)},t.secretbox.keyLength=Ur,t.secretbox.nonceLength=Wt,t.secretbox.overheadLength=vi,t.scalarMult=function(m,A){if(Rr(m,A),m.length!==Us)throw new Error("bad n size");if(A.length!==yo)throw new Error("bad p size");var y=new Uint8Array(yo);return Ar(y,m,A),y},t.scalarMult.base=function(m){if(Rr(m),m.length!==Us)throw new Error("bad n size");var A=new Uint8Array(yo);return Br(A,m),A},t.scalarMult.scalarLength=Us,t.scalarMult.groupElementLength=yo,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){Rr(m,A),YE(m,A);var y=new Uint8Array(Cc);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(Eo),A=new Uint8Array(Ao);return Sr(m,A),{publicKey:m,secretKey:A}},t.box.keyPair.fromSecretKey=function(m){if(Rr(m),m.length!==Ao)throw new Error("bad secret key size");var A=new Uint8Array(Eo);return Br(A,m),{publicKey:A,secretKey:new Uint8Array(m)}},t.box.publicKeyLength=Eo,t.box.secretKeyLength=Ao,t.box.sharedKeyLength=Cc,t.box.nonceLength=fd,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(m,A){if(Rr(m,A),A.length!==Si)throw new Error("bad secret key size");var y=new Uint8Array(ln+m.length);return or(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(Rr(m,A),A.length!==ti)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),O=0;O<x.length;O++)x[O]=y[O];return x},t.sign.detached=function(m,A){for(var y=t.sign(m,A),f=new Uint8Array(ln),x=0;x<f.length;x++)f[x]=y[x];return f},t.sign.detached.verify=function(m,A,y){if(Rr(m,A,y),A.length!==ln)throw new Error("bad signature size");if(y.length!==ti)throw new Error("bad public key size");var f=new Uint8Array(ln+m.length),x=new Uint8Array(ln+m.length),O;for(O=0;O<ln;O++)f[O]=A[O];for(O=0;O<m.length;O++)f[O+ln]=m[O];return Pt(x,f,f.length,y)>=0},t.sign.keyPair=function(){var m=new Uint8Array(ti),A=new Uint8Array(Si);return kr(m,A),{publicKey:m,secretKey:A}},t.sign.keyPair.fromSecretKey=function(m){if(Rr(m),m.length!==Si)throw new Error("bad secret key size");for(var A=new Uint8Array(ti),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(Rr(m),m.length!==kc)throw new Error("bad seed size");for(var A=new Uint8Array(ti),y=new Uint8Array(Si),f=0;f<32;f++)y[f]=m[f];return kr(A,y,!0),{publicKey:A,secretKey:y}},t.sign.publicKeyLength=ti,t.sign.secretKeyLength=Si,t.sign.seedLength=kc,t.sign.signatureLength=ln,t.hash=function(m){Rr(m);var A=new Uint8Array(Rc);return fe(A,m,m.length),A},t.hash.hashLength=Rc,t.verify=function(m,A){return Rr(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,O=new Uint8Array(f);for(x=0;x<f;x+=A)m.getRandomValues(O.subarray(x,x+Math.min(f-x,A)));for(x=0;x<f;x++)y[x]=O[x];pd(O)})}else typeof require<"u"&&(m=require("crypto"),m&&m.randomBytes&&t.setPRNG(function(y,f){var x,O=m.randomBytes(f);for(x=0;x<f;x++)y[x]=O[x];pd(O)}))})()})(typeof Ia<"u"&&Ia.exports?Ia.exports:self.nacl=self.nacl||{})});var Fu=le((bF,Ag)=>{"use strict";var Lu=Eg().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,zu=32;function Mu(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(Mu,"bcrypt_hash");function qx(t,e,r,n,i,o,s){var a=new Uint8Array(64),u=new Uint8Array(64),l=new Uint8Array(zu),d=new Uint8Array(zu),p=new Uint8Array(n+4),g,h,_,b,E,v,w=o;if(s<1||e===0||n===0||o===0||o>l.byteLength*l.byteLength||n>1<<20)return-1;for(b=Math.floor((o+l.byteLength-1)/l.byteLength),_=Math.floor((o+b-1)/b),g=0;g<n;g++)p[g]=r[g];for(Lu(a,t,e),v=1;o>0;v++){for(p[n+0]=v>>>24,p[n+1]=v>>>16,p[n+2]=v>>>8,p[n+3]=v,Lu(u,p,n+4),Mu(a,u,d),g=l.byteLength;g--;)l[g]=d[g];for(g=1;g<s;g++)for(Lu(u,d,d.byteLength),Mu(a,u,d),h=0;h<l.byteLength;h++)l[h]^=d[h];for(_=Math.min(_,o),g=0;g<_&&(E=g*b+(v-1),!(E>=w));g++)i[E]=l[g];o-=g}return 0}c(qx,"bcrypt_pbkdf");Ag.exports={BLOCKS:va,HASHSIZE:zu,hash:Mu,pbkdf:qx}});var An=le((IF,Pa)=>{"use strict";var En=require("crypto"),Ki;try{Ki=require("cpu-features")()}catch{}var{bindingAvailable:bg,CIPHER_INFO:Qx,MAC_INFO:Vx}=Mn(),xg=(()=>{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=En.sign(null,e,t),n=En.verify(null,e,t,r)}catch{}return Buffer.isBuffer(r)&&r.length===64&&n===!0}return!1})(),mg=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"];mg&&(wa.unshift("curve25519-sha256"),wa.unshift("curve25519-sha256@libssh.org"));var Dx=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"];gg&&Mu.unshift("ssh-ed25519");var Bx=Mu.concat(["ssh-dss"]),_g=(()=>{let t=En.getCiphers();return e=>t.includes(Ox[e].sslName)})(),zn=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Vi&&Vi.flags&&!Vi.flags.aes?hg?zn.unshift("chacha20-poly1305@openssh.com"):zn.push("chacha20-poly1305@openssh.com"):hg&&Vi&&Vi.arch==="x86"?zn.splice(4,0,"chacha20-poly1305@openssh.com"):zn.push("chacha20-poly1305@openssh.com");zn=zn.filter(_g);var Ux=zn.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(_g)),yg=(()=>{let t=En.getHashes();return e=>t.includes($x[e].sslName)})(),Eg=["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(yg),Lx=Eg.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(yg)),Ag=["none","zlib@openssh.com","zlib"],zx=Ag.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:Dx,DEFAULT_SERVER_HOST_KEY:Mu,SUPPORTED_SERVER_HOST_KEY:Bx,DEFAULT_CIPHER:zn,SUPPORTED_CIPHER:Ux,DEFAULT_MAC:Eg,SUPPORTED_MAC:Lx,DEFAULT_COMPRESSION:Ag,SUPPORTED_COMPRESSION:zx,curve25519Supported:mg,eddsaSupported:gg};Pa.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(Pa.exports.DISCONNECT_REASON)).reduce((t,[e,r])=>({...t,[r]:e}),{})});var Qr=le((Z3,vg)=>{"use strict";var Mr=Ko().Ber,Ta,Ig=Buffer[Symbol.species],Mx=Object.getPrototypeOf(Uint8Array.prototype).fill;function bg(t,e){return t[e++]*16777216+t[e++]*65536+t[e++]*256+t[e]}c(bg,"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 Ig(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 xg(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(xg,"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 Ca=Hu();vg.exports={bufferCopy:Go,bufferSlice:Zo,FastBuffer:Ig,bufferFill:c((t,e,r,n)=>Mx.call(t,e,r,n),"bufferFill"),makeError:xg,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=xg(e,r,!0),typeof n!="number"&&(n=Ta.PROTOCOL_ERROR),t.disconnect(n),t._destruct(),t._onError(i),1/0},"doFatalError"),readUInt32BE:bg,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=bg(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":{Ca.init(t,0);let r=Ca.readString(),n=Ca.readString();if(Ca.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 Sg=le((ka,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(It){var ar=0;if(It!=null&&It!==0){var or=(It.length<<2)+1;ar=mo(or);var Ht=ar,Pt=L;if(0<or){or=Ht+or-1;for(var Br=0;Br<It.length;++Br){var jt=It.charCodeAt(Br);if(55296<=jt&&57343>=jt){var ei=It.charCodeAt(++Br);jt=65536+((jt&1023)<<10)|ei&1023}if(127>=jt){if(Ht>=or)break;Pt[Ht++]=jt}else{if(2047>=jt){if(Ht+1>=or)break;Pt[Ht++]=192|jt>>6}else{if(65535>=jt){if(Ht+2>=or)break;Pt[Ht++]=224|jt>>12}else{if(Ht+3>=or)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 ar},"string"),array:c(function(It){var ar=mo(It.length);return M.set(It,ar),ar},"array")},Jt=Z(te),Yr=[];if(te=0,De)for(var Cr=0;Cr<De.length;Cr++){var Ii=ut[ve[Cr]];Ii?(te===0&&(te=go()),Yr[Cr]=Ii(De[Cr])):Yr[Cr]=De[Cr]}return ve=Jt.apply(null,Yr),ve=(function(It){if(fe==="string")if(It){for(var ar=L,or=It+NaN,Ht=It;ar[Ht]&&!(Ht>=or);)++Ht;if(16<Ht-It&&ar.subarray&&P)It=P.decode(ar.subarray(It,Ht));else{for(or="";It<Ht;){var Pt=ar[It++];if(Pt&128){var Br=ar[It++]&63;if((Pt&224)==192)or+=String.fromCharCode((Pt&31)<<6|Br);else{var jt=ar[It++]&63;Pt=(Pt&240)==224?(Pt&15)<<12|Br<<6|jt:(Pt&7)<<18|Br<<12|jt<<6|ar[It++]&63,65536>Pt?or+=String.fromCharCode(Pt):(Pt-=65536,or+=String.fromCharCode(55296|Pt>>10,56320|Pt&1023))}}else or+=String.fromCharCode(Pt)}It=or}}else It="";else It=fe==="boolean"?!!It:It;return It})(ve),te!==0&&Bs(te),ve}c(Y,"ca");var P=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,C,M,L;function T(){var te=H.buffer;C=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 k=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 xt(){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(xt,"pa");function kt(){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 xt()});if(g)return new Promise(function(te,fe){g(me,function(ve){te(new Uint8Array(ve))},fe)})}return Promise.resolve().then(function(){return xt()})}c(kt,"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 Cr=(Jt&3)<<6|Yr;fe+=String.fromCharCode(De),Jt!==64&&(fe+=String.fromCharCode(ut)),Yr!==64&&(fe+=String.fromCharCode(Cr))}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)-C.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),k--,r.monitorRunDependencies&&r.monitorRunDependencies(k),k==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 kt().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(k++,r.monitorRunDependencies&&r.monitorRunDependencies(k),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<k)){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)ee();Xt(j),0<k||(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 ka=="object"&&typeof Wu=="object"?Wu.exports=ju:typeof define=="function"&&define.amd?define([],function(){return ju}):typeof ka=="object"&&(ka.createPoly1305=ju)});var Mn=le((J3,kg)=>{"use strict";var{createCipheriv:Gi,createDecipheriv:Ra,createHmac:qu,randomFillSync:ci,timingSafeEqual:Qu}=require("crypto"),{readUInt32BE:Xo,writeUInt32BE:Or}=Qr(),Fn=Buffer[Symbol.species],wg=2**32-1,Pg=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,Fx=(()=>{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)}})(),Hx=(()=>{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)}},Tg=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(Tg),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),Cg(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 Fn(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 Fn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Pg;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(Tg);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 Fn(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 Fn(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(jx(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 Fn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Pg;this.inSeqno=this.inSeqno+1>>>0,Cg(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 Fn(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)),!Wx(i,this._mac))throw new Error("Invalid MAC");let o=new Fn(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 Fn(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 Cg(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(Cg,"ivIncrement");var jx=(()=>{let t=Buffer.alloc(4);return e=>(t[0]=e>>>24,t[1]=e>>>16,t[2]=e>>>8,t[3]=e,t)})();function Wx(t,e){return t.length!==e.length?(Qu(t,t),!1):Qu(t,e)}c(Wx,"timingSafeEquals");function qx(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>wg)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(qx,"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>wg)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");kg.exports={CIPHER_INFO:Fx,MAC_INFO:Hx,bindingAvailable:!!Vu,init:new Promise(async(t,e)=>{try{Yo=await Sg()(),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:qx,NullDecipher:tl,createDecipher:Qx}});var jn=le((tF,Mg)=>{"use strict";var{createDecipheriv:ml,createECDH:Vx,createHash:ts,createHmac:Kx,createSign:Gx,createVerify:Zx,getCiphers:Yx,sign:Rg,verify:Ng}=require("crypto"),Xx=Yx(),{Ber:Oe}=Ko(),Jx=zu().pbkdf,{CIPHER_INFO:rs}=Mn(),{eddsaSupported:_l,SUPPORTED_CIPHER:eI}=An(),{bufferSlice:li,makeBufferParser:tI,readString:Re,readUInt32BE:es,writeUInt32BE:cr}=Qr(),bn=Symbol("Hash Algorithm"),Vr=Symbol("Private key PEM"),on=Symbol("Public key PEM"),Hn=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=tI();function Kr(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})(),Ig=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"];Ig&&(wa.unshift("curve25519-sha256"),wa.unshift("curve25519-sha256@libssh.org"));var Kx=wa.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),Hu=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];xg&&Hu.unshift("ssh-ed25519");var Gx=Hu.concat(["ssh-dss"]),vg=(()=>{let t=En.getCiphers();return e=>t.includes(Qx[e].sslName)})(),zn=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Ki&&Ki.flags&&!Ki.flags.aes?bg?zn.unshift("chacha20-poly1305@openssh.com"):zn.push("chacha20-poly1305@openssh.com"):bg&&Ki&&Ki.arch==="x86"?zn.splice(4,0,"chacha20-poly1305@openssh.com"):zn.push("chacha20-poly1305@openssh.com");zn=zn.filter(vg);var Zx=zn.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(vg)),Sg=(()=>{let t=En.getHashes();return e=>t.includes(Vx[e].sslName)})(),wg=["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(Sg),Yx=wg.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(Sg)),Pg=["none","zlib@openssh.com","zlib"],Xx=Pg.concat([]),Vi={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:Vi,COMPAT_CHECKS:[["Cisco-1.25",Vi.BAD_DHGEX],[/^Cisco-1[.]/,Vi.BUG_DHGEX_LARGE],[/^[0-9.]+$/,Vi.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,Vi.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,Vi.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:wa,SUPPORTED_KEX:Kx,DEFAULT_SERVER_HOST_KEY:Hu,SUPPORTED_SERVER_HOST_KEY:Gx,DEFAULT_CIPHER:zn,SUPPORTED_CIPHER:Zx,DEFAULT_MAC:wg,SUPPORTED_MAC:Yx,DEFAULT_COMPRESSION:Pg,SUPPORTED_COMPRESSION:Xx,curve25519Supported:Ig,eddsaSupported:xg};Pa.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(Pa.exports.DISCONNECT_REASON)).reduce((t,[e,r])=>({...t,[r]:e}),{})});var Vr=le((vF,Rg)=>{"use strict";var Fr=Ko().Ber,Ta,kg=Buffer[Symbol.species],Jx=Object.getPrototypeOf(Uint8Array.prototype).fill;function Tg(t,e){return t[e++]*16777216+t[e++]*65536+t[e++]*256+t[e]}c(Tg,"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 kg(t.buffer,t.byteOffset+e,r-e)}c(Zo,"bufferSlice");function Wu(){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(Wu,"makeBufferParser");function Cg(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(Cg,"makeError");function ju(t,e,r){return t[r++]=e>>>24,t[r++]=e>>>16,t[r++]=e>>>8,t[r++]=e,r}c(ju,"writeUInt32BE");var Ca=Wu();Rg.exports={bufferCopy:Go,bufferSlice:Zo,FastBuffer:kg,bufferFill:c((t,e,r,n)=>Jx.call(t,e,r,n),"bufferFill"),makeError:Cg,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=Cg(e,r,!0),typeof n!="number"&&(n=Ta.PROTOCOL_ERROR),t.disconnect(n),t._destruct(),t._onError(i),1/0},"doFatalError"),readUInt32BE:Tg,writeUInt32BE:ju,writeUInt32LE:c((t,e,r)=>(t[r++]=e,t[r++]=e>>>8,t[r++]=e>>>16,t[r++]=e>>>24,r),"writeUInt32LE"),makeBufferParser:Wu,bufferParser:Wu(),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=Tg(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 Fr.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,Fr.Integer),r.writeBuffer(i,Fr.Integer),r.endSequence(),r.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{Ca.init(t,0);let r=Ca.readString(),n=Ca.readString();if(Ca.clear(),r===void 0||n===void 0)return;let i=new Fr.Writer;return i.startSequence(),i.writeBuffer(r,Fr.Integer),i.writeBuffer(n,Fr.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 Fr.Reader(t);r.readSequence();let n=r.readString(Fr.Integer,!0),i=r.readString(Fr.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 Fr.Reader(t);r.readSequence();let n=r.readString(Fr.Integer,!0),i=r.readString(Fr.Integer,!0);if(n===null||i===null)return;let o=Buffer.allocUnsafe(4+n.length+4+i.length);return ju(o,n.length,0),o.set(n,4),ju(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 Ng=le((ka,Qu)=>{var qu=(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(re,fe){n=re,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,_,b;l?(d=u?require("path").dirname(d)+"/":__dirname+"/",p=c(function(re,fe){var ve=Sr(re);return ve?fe?ve:ve.toString():(_||(_=require("fs")),b||(b=require("path")),re=b.normalize(re),_.readFileSync(re,fe?null:"utf8"))},"C"),h=c(function(re){return re=p(re,!0),re.buffer||(re=new Uint8Array(re)),J(re.buffer),re},"E"),g=c(function(re,fe,ve){var Be=Sr(re);Be&&fe(Be),_||(_=require("fs")),b||(b=require("path")),re=b.normalize(re),_.readFile(re,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(re){try{var fe=new XMLHttpRequest;return fe.open("GET",re,!1),fe.send(null),fe.responseText}catch(ut){if(re=Sr(re)){fe=[];for(var ve=0;ve<re.length;ve++){var Be=re[ve];255<Be&&(Ar&&J(!1,"Character code "+Be+" ("+String.fromCharCode(Be)+") at offset "+ve+" not in 0x00-0xFF."),Be&=255),fe.push(String.fromCharCode(Be))}return fe.join("")}throw ut}},"C"),u&&(h=c(function(re){try{var fe=new XMLHttpRequest;return fe.open("GET",re,!1),fe.responseType="arraybuffer",fe.send(null),new Uint8Array(fe.response)}catch(ve){if(re=Sr(re))return re;throw ve}},"E")),g=c(function(re,fe,ve){var Be=new XMLHttpRequest;Be.open("GET",re,!0),Be.responseType="arraybuffer",Be.onload=function(){if(Be.status==200||Be.status==0&&Be.response)fe(Be.response);else{var ut=Sr(re);ut?fe(ut.buffer):ve()}},Be.onerror=ve,Be.send(null)},"D")),r.print||console.log.bind(console);var E=r.printErr||console.warn.bind(console);for(s in o)o.hasOwnProperty(s)&&(r[s]=o[s]);o=null;var v;r.wasmBinary&&(v=r.wasmBinary);var w=r.noExitRuntime||!0;typeof WebAssembly!="object"&&ee("no native wasm support detected");var H,D=!1;function J(re,fe){re||ee("Assertion failed: "+fe)}c(J,"assert");function Y(re){var fe=r["_"+re];return J(fe,"Cannot call unknown function "+re+", make sure it is exported"),fe}c(Y,"N");function X(re,fe,ve,Be){var ut={string:c(function(It){var ar=0;if(It!=null&&It!==0){var or=(It.length<<2)+1;ar=_o(or);var jt=ar,Pt=L;if(0<or){or=jt+or-1;for(var Ur=0;Ur<It.length;++Ur){var Wt=It.charCodeAt(Ur);if(55296<=Wt&&57343>=Wt){var ei=It.charCodeAt(++Ur);Wt=65536+((Wt&1023)<<10)|ei&1023}if(127>=Wt){if(jt>=or)break;Pt[jt++]=Wt}else{if(2047>=Wt){if(jt+1>=or)break;Pt[jt++]=192|Wt>>6}else{if(65535>=Wt){if(jt+2>=or)break;Pt[jt++]=224|Wt>>12}else{if(jt+3>=or)break;Pt[jt++]=240|Wt>>18,Pt[jt++]=128|Wt>>12&63}Pt[jt++]=128|Wt>>6&63}Pt[jt++]=128|Wt&63}}Pt[jt]=0}}return ar},"string"),array:c(function(It){var ar=_o(It.length);return M.set(It,ar),ar},"array")},Jt=Y(re),Xr=[];if(re=0,Be)for(var kr=0;kr<Be.length;kr++){var Ii=ut[ve[kr]];Ii?(re===0&&(re=mo()),Xr[kr]=Ii(Be[kr])):Xr[kr]=Be[kr]}return ve=Jt.apply(null,Xr),ve=(function(It){if(fe==="string")if(It){for(var ar=L,or=It+NaN,jt=It;ar[jt]&&!(jt>=or);)++jt;if(16<jt-It&&ar.subarray&&P)It=P.decode(ar.subarray(It,jt));else{for(or="";It<jt;){var Pt=ar[It++];if(Pt&128){var Ur=ar[It++]&63;if((Pt&224)==192)or+=String.fromCharCode((Pt&31)<<6|Ur);else{var Wt=ar[It++]&63;Pt=(Pt&240)==224?(Pt&15)<<12|Ur<<6|Wt:(Pt&7)<<18|Ur<<12|Wt<<6|ar[It++]&63,65536>Pt?or+=String.fromCharCode(Pt):(Pt-=65536,or+=String.fromCharCode(55296|Pt>>10,56320|Pt&1023))}}else or+=String.fromCharCode(Pt)}It=or}}else It="";else It=fe==="boolean"?!!It:It;return It})(ve),re!==0&&Bs(re),ve}c(X,"ca");var P=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,C,M,L;function T(){var re=H.buffer;C=re,r.HEAP8=M=new Int8Array(re),r.HEAP16=new Int16Array(re),r.HEAP32=new Int32Array(re),r.HEAPU8=L=new Uint8Array(re),r.HEAPU16=new Uint16Array(re),r.HEAPU32=new Uint32Array(re),r.HEAPF32=new Float32Array(re),r.HEAPF64=new Float64Array(re)}c(T,"ia");var F,j=[],B=[],Z=[];function te(){var re=r.preRun.shift();j.unshift(re)}c(te,"ma");var k=0,W=null,q=null;r.preloadedImages={},r.preloadedAudios={};function ee(re){throw r.onAbort&&r.onAbort(re),E(re),D=!0,re=new WebAssembly.RuntimeError("abort("+re+"). Build with -s ASSERTIONS=1 for more info."),i(re),re}c(ee,"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 xt(){var re=me;try{if(re==me&&v)return new Uint8Array(v);var fe=Sr(re);if(fe)return fe;if(h)return h(re);throw"both async and sync fetching of the wasm failed"}catch(ve){ee(ve)}}c(xt,"pa");function kt(){if(!v&&(a||u)){if(typeof fetch=="function"&&!me.startsWith("file://"))return fetch(me,{credentials:"same-origin"}).then(function(re){if(!re.ok)throw"failed to load wasm binary file at '"+me+"'";return re.arrayBuffer()}).catch(function(){return xt()});if(g)return new Promise(function(re,fe){g(me,function(ve){re(new Uint8Array(ve))},fe)})}return Promise.resolve().then(function(){return xt()})}c(kt,"qa");function Xt(re){for(;0<re.length;){var fe=re.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 Ar=!1,Br=typeof atob=="function"?atob:function(re){var fe="",ve=0;re=re.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var Be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(re.charAt(ve++)),ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(re.charAt(ve++)),Jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(re.charAt(ve++)),Xr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(re.charAt(ve++));Be=Be<<2|ut>>4,ut=(ut&15)<<4|Jt>>2;var kr=(Jt&3)<<6|Xr;fe+=String.fromCharCode(Be),Jt!==64&&(fe+=String.fromCharCode(ut)),Xr!==64&&(fe+=String.fromCharCode(kr))}while(ve<re.length);return fe};function Sr(re){if(re.startsWith(ue)){if(re=re.slice(ue.length),typeof l=="boolean"&&l){var fe=Buffer.from(re,"base64");fe=new Uint8Array(fe.buffer,fe.byteOffset,fe.byteLength)}else try{var ve=Br(re),Be=new Uint8Array(ve.length);for(re=0;re<ve.length;++re)Be[re]=ve.charCodeAt(re);fe=Be}catch{throw Error("Converting base64 string to bytes failed.")}return fe}}c(Sr,"H");var Ai={a:c(function(re){var fe=L.length;if(re>>>=0,2147483648<re)return!1;for(var ve=1;4>=ve;ve*=2){var Be=fe*(1+.2/ve);Be=Math.min(Be,re+100663296),Be=Math.max(re,Be),0<Be%65536&&(Be+=65536-Be%65536);e:{try{H.grow(Math.min(2147483648,Be)-C.byteLength+65535>>>16),T();var ut=1;break e}catch{}ut=void 0}if(ut)return!0}return!1},"a")};(function(){function re(ut){r.asm=ut.exports,H=r.asm.b,T(),F=r.asm.j,B.unshift(r.asm.c),k--,r.monitorRunDependencies&&r.monitorRunDependencies(k),k==0&&(W!==null&&(clearInterval(W),W=null),q&&(ut=q,q=null,ut()))}c(re,"a");function fe(ut){re(ut.instance)}c(fe,"c");function ve(ut){return kt().then(function(Jt){return WebAssembly.instantiate(Jt,Be)}).then(ut,function(Jt){E("failed to asynchronously prepare wasm: "+Jt),ee(Jt)})}c(ve,"d");var Be={a:Ai};if(k++,r.monitorRunDependencies&&r.monitorRunDependencies(k),r.instantiateWasm)try{return r.instantiateWasm(Be,re)}catch(ut){return E("Module.instantiateWasm callback failed with error: "+ut),!1}return(function(){return v||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,Be).then(fe,function(Jt){return E("wasm streaming compile failed: "+Jt),E("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 mo=r.stackSave=function(){return(mo=r.stackSave=r.asm.e).apply(null,arguments)},Bs=r.stackRestore=function(){return(Bs=r.stackRestore=r.asm.f).apply(null,arguments)},_o=r.stackAlloc=function(){return(_o=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(re,fe,ve,Be){ve=ve||[];var ut=ve.every(function(Jt){return Jt==="number"});return fe!=="string"&&ut&&!Be?Y(re):function(){return X(re,fe,ve,arguments)}};var bi;q=c(function re(){bi||xi(),bi||(q=re)},"ta");function xi(){function re(){if(!bi&&(bi=!0,r.calledRun=!0,!D)){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();Z.unshift(fe)}Xt(Z)}}if(c(re,"a"),!(0<k)){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)te();Xt(j),0<k||(r.setStatus?(r.setStatus("Running..."),setTimeout(function(){setTimeout(function(){r.setStatus("")},1),re()},1)):re())}}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 ka=="object"&&typeof Qu=="object"?Qu.exports=qu:typeof define=="function"&&define.amd?define([],function(){return qu}):typeof ka=="object"&&(ka.createPoly1305=qu)});var Mn=le((PF,Ug)=>{"use strict";var{createCipheriv:Zi,createDecipheriv:Ra,createHmac:Vu,randomFillSync:ci,timingSafeEqual:Ku}=require("crypto"),{readUInt32BE:Xo,writeUInt32BE:$r}=Vr(),Fn=Buffer[Symbol.species],Og=2**32-1,$g=Buffer.alloc(0),Gi=Buffer.alloc(4),Na=new Map,ui=35e3,Gu,ll,fl,dl,pl,hl,gl;try{Gu=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:ll,ChaChaPolyCipher:fl,GenericCipher:dl,AESGCMDecipher:pl,ChaChaPolyDecipher:hl,GenericDecipher:gl}=Gu}catch{}var fr=1,eI=(()=>{function t(e,r,n,i,o,s,a){return{sslName:e,blockLen:r,keyLen:n,ivLen:i!==0||a&fr?i:r,authLen:o,discardLen:s,stream:!!(a&fr)}}return c(t,"info"),{"chacha20-poly1305@openssh.com":t("chacha20",8,64,0,16,0,fr),"aes128-gcm":t("aes-128-gcm",16,16,12,16,0,fr),"aes256-gcm":t("aes-256-gcm",16,32,12,16,0,fr),"aes128-gcm@openssh.com":t("aes-128-gcm",16,16,12,16,0,fr),"aes256-gcm@openssh.com":t("aes-256-gcm",16,32,12,16,0,fr),"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,fr),"aes192-ctr":t("aes-192-ctr",16,24,16,0,0,fr),"aes256-ctr":t("aes-256-ctr",16,32,16,0,0,fr),"3des-ctr":t("des-ede3",8,24,8,0,0,fr),"blowfish-ctr":t("bf-ecb",8,16,8,0,0,fr),"cast128-ctr":t("cast5-ecb",8,16,8,0,0,fr),arcfour:t("rc4",8,16,0,0,1536,fr),arcfour128:t("rc4",8,16,0,0,1536,fr),arcfour256:t("rc4",8,32,0,0,1536,fr),arcfour512:t("rc4",8,64,0,0,1536,fr)}})(),tI=(()=>{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)}})(),Zu=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 $r(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)}},Dg=Buffer.alloc(32),wr=Buffer.alloc(16),Yo,Jo,ml,Yu=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 $r(i,r-4,0),i[4]=n,ci(i,5+e,n),i}encrypt(e){if(this._dead)return;wr[0]=0,$r(wr,this.outSeqno,12);let r=Zi("chacha20",this._encKeyMain,wr).update(Dg),n=Zi("chacha20",this._encKeyPktLen,wr).update(e.slice(0,4));this._onWrite(n),wr[0]=1;let i=Zi("chacha20",this._encKeyMain,wr).update(e.slice(4));this._onWrite(i),ml(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}},Xu=class{static{c(this,"ChaChaPolyCipherBinding")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._instance=new fl(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 $r(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)}},Ju=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 $r(i,r-4,0),i[4]=n,ci(i,5+e,n),i}encrypt(e){if(this._dead)return;let r=Zi(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),Bg(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},el=class{static{c(this,"AESGCMCipherBinding")}constructor(e){let r=e.outbound;this.outSeqno=r.seqno,this._onWrite=r.onWrite,this._instance=new ll(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 $r(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)}},tl=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=Zi(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 $r(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=Vu(this._macSSLName,this._macKey),$r(Gi,this.outSeqno,0),r.update(Gi),r.update(i),r.update(o)}else{let i=this._cipherInstance.update(e);this._onWrite(i),r=Vu(this._macSSLName,this._macKey),$r(Gi,this.outSeqno,0),r.update(Gi),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}},rl=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 dl(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 $r(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 Fn(e.buffer,e.byteOffset,e.length-(this._macLen-this._macActualLen))),this._onWrite(e),this.outSeqno=this.outSeqno+1>>>0)}},nl=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 Fn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):$g;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}}}},il=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;wr[0]=0,$r(wr,this.inSeqno,12);let u=Ra("chacha20",this._decKeyPktLen,wr).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}wr[0]=0,$r(wr,this.inSeqno,12);let i=Zi("chacha20",this._decKeyMain,wr).update(Dg);if(ml(Jo,this._lenBuf,4,this._packet,this._packet.length,i),this._calcMac.set(new Uint8Array(Yo.HEAPU8.buffer,Jo,16),0),!Ku(this._calcMac,this._mac))throw new Error("Invalid MAC");wr[0]=1;let o=Ra("chacha20",this._decKeyMain,wr).update(this._packet),s=new Fn(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}}}},ol=class{static{c(this,"ChaChaPolyDecipherBinding")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._instance=new hl(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 Fn(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}}}},sl=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(rI(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 Fn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):$g;this.inSeqno=this.inSeqno+1>>>0,Bg(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}}}},al=class{static{c(this,"AESGCMDecipherBinding")}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),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 Fn(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}}}},cl=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=Vu(this._macSSLName,this._macKey),$r(Gi,this.inSeqno,0),this._macInstance.update(Gi),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)),!nI(i,this._mac))throw new Error("Invalid MAC");let o=new Fn(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}}}},ul=class{static{c(this,"GenericDecipherBinding")}constructor(e){let r=e.inbound;this.inSeqno=r.seqno,this._onPayload=r.onPayload,this._instance=new gl(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 Fn(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 Bg(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(Bg,"ivIncrement");var rI=(()=>{let t=Buffer.alloc(4);return e=>(t[0]=e>>>24,t[1]=e>>>16,t[2]=e>>>8,t[3]=e,t)})();function nI(t,e){return t.length!==e.length?(Ku(t,t),!1):Ku(t,e)}c(nI,"timingSafeEquals");function iI(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>Og)throw new Error("Invalid outbound.seqno");let r=!!e.forceNative;switch(e.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return ll&&!r?new el(t):new Ju(t);case"chacha20":return fl&&!r?new Xu(t):new Yu(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 dl&&!r?new rl(t):new tl(t)}}}c(iI,"createCipher");function oI(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>Og)throw new Error("Invalid inbound.seqno");let r=!!e.forceNative;switch(e.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return pl&&!r?new al(t):new sl(t);case"chacha20":return hl&&!r?new ol(t):new il(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 gl&&!r?new ul(t):new cl(t)}}}c(oI,"createDecipher");Ug.exports={CIPHER_INFO:eI,MAC_INFO:tI,bindingAvailable:!!Gu,init:new Promise(async(t,e)=>{try{Yo=await Ng()(),Jo=Yo._malloc(16),ml=Yo.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(r){return e(r)}t()}),NullCipher:Zu,createCipher:iI,NullDecipher:nl,createDecipher:oI}});var jn=le((CF,Vg)=>{"use strict";var{createDecipheriv:yl,createECDH:sI,createHash:ts,createHmac:aI,createSign:cI,createVerify:uI,getCiphers:lI,sign:Lg,verify:zg}=require("crypto"),fI=lI(),{Ber:$e}=Ko(),dI=Fu().pbkdf,{CIPHER_INFO:rs}=Mn(),{eddsaSupported:El,SUPPORTED_CIPHER:pI}=An(),{bufferSlice:li,makeBufferParser:hI,readString:Re,readUInt32BE:es,writeUInt32BE:ur}=Vr(),bn=Symbol("Hash Algorithm"),Kr=Symbol("Private key PEM"),on=Symbol("Public key PEM"),Hn=Symbol("Public key SSH"),Yi=Symbol("Decrypted Key"),_l=Object.create(null);{let t=Object.keys(rs);for(let e=0;e<t.length;++e){let r=rs[t[e]].sslName;!r||_l[r]||(_l[r]=rs[t[e]])}}var Oa=hI();function Gr(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(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 Og=(()=>{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 $g(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($g,"genOpenSSLDSAPriv");function Dg(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(Dg,"genOpenSSLEdPub");function Bg(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(Bg,"genOpenSSHEdPub");function rI(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(rI,"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 nI(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(nI,"genOpenSSLECDSAPriv");function iI(t,e){let r=Vx(t);return r.setPrivateKey(e),r.getPublicKey()}c(iI,"genOpenSSLECDSAPubFromPriv");var cs={sign:c(typeof Rg=="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 Rg(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=Gx(r);i.update(e);try{return i.sign(n)}catch(o){return o}},"sign"),verify:c(typeof Ng=="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 Ng(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=Zx(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[Hn]},"getPublicSSH"),equals:c(function(e){let r=zg(e);return r instanceof Error?!1:this.type===r.type&&this[Vr]===r[Vr]&&this[on]===r[on]&&this[Hn].equals(r[Hn])},"equals")};function $a(t,e,r,n,i,o,s){this.type=t,this.comment=e,this[Vr]=r,this[on]=n,this[Hn]=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=Og(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=$g(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=Dg(I),_=Bg(I),g=rI(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=nI(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"&&eI.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(Jx(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[Hn]=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(Xx.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=iI(_,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[Hn]=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),Kx("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,C;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),C=Og(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),C=$g(M,L,T,F,j);break}}return new Ba(p,g,C,Y,P,"sha1",l)}}function La(t,e,r,n,i){this.type=t,this.comment=e,this[Vr]=null,this[on]=r,this[Hn]=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[Hn]=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(!Ug(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=Dg(u),a=Bg(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 Ug(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(Ug,"isSupportedKeyType");function Lg(t){return t?typeof t[Zi]=="boolean":!1}c(Lg,"isParsedKey");function zg(t,e){if(Lg(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(zg,"parseKey");Mg.exports={isParsedKey:Lg,isSupportedKeyType:Ug,parseDERKey:c((t,e)=>bl(t,e,"",e),"parseDERKey"),parseKey:zg}});var Pl=le((sF,Zg)=>{"use strict";var{Socket:Wg}=require("net"),{Duplex:qg}=require("stream"),{resolve:oI}=require("path"),{readFile:Fg}=require("fs"),{execFile:sI,spawn:aI}=require("child_process"),{isParsedKey:Hg,parseKey:us}=jn(),{makeBufferParser:cI,readUInt32BE:wl,writeUInt32BE:wr,writeUInt32LE:jg}=Qr();function ls(t){let e=!1;return(...r)=>{e||(e=!0,t(...r))}}c(ls,"once");function uI(t,e){let r=Buffer.allocUnsafe(t.length+e.length);return t.copy(r,0),e.copy(r,t.length),r}c(uI,"concat");function Il(){}c(Il,"noop");var lI=Buffer.alloc(0),Lt=cI(),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 Wg;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)})})}},Qg=(()=>{let s=oI(__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 qg{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=aI(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)}}})(),Vg=(()=>{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;Fg(n,c(function o(s,a){if(s){if(i)return r(new Error("Invalid cygwin unix socket path"));sI("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,""),Fg(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)jg(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),jg(_,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 Wg,h.on("connect",w),h.on("data",H),h.on("error",$),h.on("end",$),h.on("close",$),h.connect(A)}c(X,"tryConnect")},"readCygsocket"))}}})(),fI=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function Kg(t){return process.platform==="win32"&&!fI.test(t)?t==="pageant"?new Qg:new Vg(t):new Xi(t)}c(Kg,"createAgent");var vl=(()=>{function l(P){let C;for(;P[w].length;){let M=P[w][0][p];if(M===void 0)break;P[w].shift(),C=P.push(M)}return C}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(C,M){this[d]=C,this[p]=void 0,this[g]=M}hasResponded(){return this[p]!==void 0}getType(){return this[d]}getContext(){return this[g]}}function _(P,C,M){return C[p]=M,l(P)}c(_,"respond");function A(P){if(P[$]=null,P[H]===0){let C=P[w];if(C&&C.length){P[w]=[];for(let M of C)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 qg{static{c(this,"AgentProtocol")}constructor(C){super({autoDestroy:!0,emitClose:!1}),this[H]=C?0:1,this[w]=[],this[$]=null,this[X]=-1,this.once("end",I),this.once("close",b)}_read(C){}_write(C,M,L){this[$]===null?this[$]=C:this[$]=uI(this[$],C);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 k=[];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,k.push(q))}j=Lt.pos(),Lt.clear(),G.cb(null,k);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(),k=Lt.readUInt32BE();if(j=Lt.pos(),Lt.clear(),k===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"&&(k&2?(q="rsa-sha2-256",W.hash="sha256"):k&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(C,M){A(this),M()}_final(C){A(this),C()}sign(C,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(C=us(C),C instanceof Error)throw new Error("Invalid public key argument");if(C.type==="ssh-rsa"&&L)switch(L.hash){case"sha256":F=2;break;case"sha512":F=4;break}C=C.getPublicSSH();let j=13,B=C.length,G=M.length,ee=0,k=Buffer.allocUnsafe(9+B+4+G+4);return wr(k,k.length-4,ee),k[ee+=4]=j,wr(k,B,++ee),C.copy(k,ee+=4),wr(k,G,ee+=B),M.copy(k,ee+=4),wr(k,F,ee+=G),typeof T!="function"&&(T=Il),this[w].push({type:j,cb:T}),this.push(k)}getIdentities(C){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 C!="function"&&(C=Il),this[w].push({type:M,cb:C}),this.push(T)}failureReply(C){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(C instanceof h))throw new Error("Wrong request argument");if(C.hasResponded())return!0;let M=0,L=Buffer.allocUnsafe(5);return wr(L,L.length-4,M),L[M+=4]=5,_(this,C,L)}getIdentitiesReply(C,M){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(C instanceof h))throw new Error("Wrong request argument");if(C.hasResponded())return!0;if(C.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,k;if(Hg(G))ee=G;else if(Hg(G.pubKey))ee=G.pubKey;else if(typeof G.pubKey!="object"||G.pubKey===null||({pubKey:ee,comment:k}=G.pubKey,ee=us(ee),ee instanceof Error))continue;k=ee.comment||k,ee=ee.getPublicSSH(),L+=4+ee.length,k&&typeof k=="string"?k=Buffer.from(k):Buffer.isBuffer(k)||(k=lI),L+=4+k.length,T.push({pubKey:ee,comment:k})}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,C,j)}signReply(C,M){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(C instanceof h))throw new Error("Wrong request argument");if(C.hasResponded())return!0;if(C.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=C.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,C,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=Kg(e);else if(!Gg(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 Gg(t){return t instanceof fs}c(Gg,"isAgent");Zg.exports={AgentContext:Sl,AgentProtocol:vl,BaseAgent:fs,createAgent:Kg,CygwinAgent:Vg,isAgent:Gg,OpenSSHAgent:Xi,PageantAgent:Qg}});var Ol=le((cF,Yg)=>{"use strict";var{kMaxLength:dI}=require("buffer"),{createInflate:pI,constants:{DEFLATE:hI,INFLATE:gI,Z_DEFAULT_CHUNK:mI,Z_DEFAULT_COMPRESSION:_I,Z_DEFAULT_MEMLEVEL:yI,Z_DEFAULT_STRATEGY:EI,Z_DEFAULT_WINDOWBITS:AI,Z_PARTIAL_FLUSH:bI}}=require("zlib"),xI=pI()._handle.constructor;function II(){throw new Error("Should not get here")}c(II,"processCallback");function vI(t,e,r){let n=this._owner,i=new Error(t);i.errno=e,i.code=r,n._err=i}c(vI,"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=AI,n=_I,i=yI,o=EI,s=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=mI,this._maxOutputLength=dI,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new xI(e),this._handle._owner=this,this._handle.onerror=vI,this._handle.init(r,n,i,o,this._writeState,II,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(bI,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(hI)}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}},Cl=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 za(gI)}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}};Yg.exports={PacketReader:Rl,PacketWriter:Cl,ZlibPacketReader:kl,ZlibPacketWriter:Tl}});var rm=le((lF,tm)=>{"use strict";var{bufferSlice:$l,bufferParser:O,doFatalError:Tt,sigSSHToASN1:Xg,writeUInt32BE:Jg}=Qr(),{CHANNEL_OPEN_FAILURE:SI,COMPAT:wI,MESSAGE:Ct,TERMINAL_MODE:em}=An(),{parseKey:PI}=jn(),TI=Array.from(Object.entries(em)).reduce((t,[e,r])=>({...t,[e]:r}),{});tm.exports={[Ct.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)},[Ct.IGNORE]:(t,e)=>{t._debug&&t._debug("Inbound: Received IGNORE")},[Ct.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})`)},[Ct.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)},[Ct.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)},[Ct.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)},[Ct.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)},[Ct.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)),_=Xg(_,d),_)){let A=t._kex.sessionID,b=Buffer.allocUnsafe(4+A.length+h);Jg(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=Xg(A,l),A!==void 0)){let b=t._kex.sessionID,I=Buffer.allocUnsafe(4+b.length+_);Jg(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)},[Ct.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)},[Ct.USERAUTH_SUCCESS]:(t,e)=>{t._debug&&t._debug("Inbound: Received USERAUTH_SUCCESS"),t._authsQueue.shift();let r=t._handlers.USERAUTH_SUCCESS;r&&r(t)},[Ct.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)},[Ct.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=PI(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()},[Ct.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)},[Ct.REQUEST_FAILURE]:(t,e)=>{t._debug&&t._debug("Inbound: Received REQUEST_FAILURE");let r=t._handlers.REQUEST_FAILURE;r&&r(t)},[Ct.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,SI.ADMINISTRATIVELY_PROHIBITED,"","")},[Ct.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})},[Ct.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)},[Ct.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)},[Ct.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)},[Ct.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)},[Ct.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)},[Ct.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)},[Ct.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&wI.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(_===em.TTY_OP_END)break;let A=TI[_],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)},[Ct.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)},[Ct.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((fF,nm)=>{"use strict";var Dl=new Array(256);[Fa().HANDLERS,rm()].forEach(t=>{for(let[e,r]of Object.entries(t))e=+e,isFinite(e)&&e>=0&&e<Dl.length&&(Dl[e]=r)});nm.exports=Dl});var Fa=le((pF,pm)=>{"use strict";var{createDiffieHellman:CI,createDiffieHellmanGroup:kI,createECDH:RI,createHash:Ul,createPublicKey:NI,diffieHellman:OI,generateKeyPairSync:$I,randomFillSync:DI}=require("crypto"),{Ber:im}=Ko(),{COMPAT:Ll,curve25519Supported:BI,DEFAULT_KEX:om,DEFAULT_SERVER_HOST_KEY:sm,DEFAULT_CIPHER:Ha,DEFAULT_MAC:ja,DEFAULT_COMPRESSION:Wa,DISCONNECT_REASON:st,MESSAGE:wt}=An(),{CIPHER_INFO:to,createCipher:UI,createDecipher:LI,MAC_INFO:am}=Mn(),{parseDERKey:zI}=jn(),{bufferFill:MI,bufferParser:it,convertSignature:FI,doFatalError:at,FastBuffer:HI,sigSSHToASN1:jI,writeUInt32BE:ur}=Qr(),{PacketReader:cm,PacketWriter:um,ZlibPacketReader:qa,ZlibPacketWriter:Qa}=Ol(),Ji,WI=2048,qI=8192,QI=Buffer.alloc(0);function lm(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,DI(e,1,16),MI(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(lm,"kexinit");function fm(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||lm(t),t._decipher._onPayload=dm.bind(t,{firstPacket:!1})),t._kex=VI(r,t,e),t._kex.remoteExtInfoEnabled=g,t._kex.start()}c(fm,"handleKexInit");var VI=(()=>{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($=FI($,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,C=this._protocol._packetRW.write.alloc(5+h.length+4+_.length+4+Y,!0);if(C[P]=wt.KEXDH_REPLY,ur(C,h.length,++P),C.set(h,P+=4),ur(C,_.length,P+=h.length),C.set(_,P+=4),ur(C,Y,P+=_.length),ur(C,Z,P+=4),C.utf8Write(X,P+=4,Z),ur(C,$.length,P+=Z),C.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(C,!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(!($=jI($,H)))return at(this._protocol,"Malformed signature","handshake",st.KEY_EXCHANGE_FAILED);let X;{it.init(this._hostKey,0);let P=it.readString(!0),C=this._hostKey.slice(it.pos());if(it.clear(),X=zI(C,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=UI(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"),C=eo(X.keyLen,this.hashName,p,A,this.sessionID,"D"),M,L;$.authLen||(M=am[l.cs.mac],L=eo(M.len,this.hashName,p,A,this.sessionID,"E"));let T,F;X.authLen||(T=am[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:C,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?C:P,macInfo:u?T:M,macKey:u?F:L}};this._protocol._decipher.free(),b=j,this._protocol._decipher=LI(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 cm:B.write=new um(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 um(this._protocol):B.read=new cm}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=$I("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 im.Writer;return u.startSequence(),u.startSequence(),u.writeOID("1.3.101.110"),u.endSequence(),u.startSequence(im.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(OI({privateKey:this._keys.privateKey,publicKey:NI({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=RI(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=WI,this._prefBits=KI(this.negotiated),this._protocol._compatFlags&Ll.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=qI}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=CI(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(!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}`)}})(),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 HI(a.buffer,a.byteOffset,t)}else s=QI;return s}c(eo,"generateKEXVal");function dm(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,fm(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(dm,"onKEXPayload");function KI(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(KI,"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");pm.exports={KexInit:Bl,kexinit:lm,onKEXPayload:dm,DEFAULT_KEXINIT_CLIENT:new Bl({kex:om.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:sm,cs:{cipher:Ha,mac:ja,compress:Wa,lang:[]},sc:{cipher:Ha,mac:ja,compress:Wa,lang:[]}}),DEFAULT_KEXINIT_SERVER:new Bl({kex:om.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:sm,cs:{cipher:Ha,mac:ja,compress:Wa,lang:[]},sc:{cipher:Ha,mac:ja,compress:Wa,lang:[]}}),HANDLERS:{[wt.KEXINIT]:fm}}});var hm=le((gF,GI)=>{GI.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((mF,Pm)=>{"use strict";var{inspect:Am}=require("util"),{bindingAvailable:ZI,NullCipher:YI,NullDecipher:XI}=Mn(),{COMPAT_CHECKS:JI,DISCONNECT_REASON:bm,eddsaSupported:ev,MESSAGE:we,SIGNALS:gm,TERMINAL_MODE:Ml}=An(),{DEFAULT_KEXINIT_CLIENT:tv,DEFAULT_KEXINIT_SERVER:rv,KexInit:mm,kexinit:xm,onKEXPayload:nv}=Fa(),{parseKey:_m}=jn(),iv=Ma(),{bufferCopy:Ka,bufferFill:ov,bufferSlice:Im,convertSignature:ym,sendPacket:Pe,writeUInt32BE:R}=Qr(),{PacketReader:sv,PacketWriter:av,ZlibPacketReader:vm,ZlibPacketWriter:Sm}=Ol(),cv=hm().version,uv=new Map(Object.values(bm).map(t=>[t,1])),wm=Buffer.from(`SSH-2.0-ssh2js${cv}`),lv=Buffer.from(`${wm}\r
|
|
12
|
-
`),
|
|
11
|
+
${r}-----END ${t} KEY-----`}c(Gr,"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 Al(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(Al,"skipFields");function is(t,e){let r=new $e.Writer;return r.startSequence(),r.startSequence(),r.writeOID("1.2.840.113549.1.1.1"),r.writeNull(),r.endSequence(),r.startSequence($e.BitString),r.writeByte(0),r.startSequence(),r.writeBuffer(t,$e.Integer),r.writeBuffer(e,$e.Integer),r.endSequence(),r.endSequence(),r.endSequence(),Gr("PUBLIC",r.buffer)}c(is,"genOpenSSLRSAPub");function os(t,e){let r=Buffer.allocUnsafe(15+e.length+4+t.length);ur(r,7,0),r.utf8Write("ssh-rsa",4,7);let n=11;return ur(r,e.length,n),r.set(e,n+=4),ur(r,t.length,n+=e.length),r.set(t,n+4),r}c(os,"genOpenSSHRSAPub");var Mg=(()=>{function t(n,i,o,s,a,u,l,d){let p=new $e.Writer;return p.startSequence(),p.writeInt(0,$e.Integer),p.writeBuffer(n,$e.Integer),p.writeBuffer(i,$e.Integer),p.writeBuffer(o,$e.Integer),p.writeBuffer(s,$e.Integer),p.writeBuffer(a,$e.Integer),p.writeBuffer(u,$e.Integer),p.writeBuffer(l,$e.Integer),p.writeBuffer(d,$e.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 Gr("RSA PRIVATE",t(i,o,s,u,l,p,g,a))},"genOpenSSLRSAPriv")})();function ss(t,e,r,n){let i=new $e.Writer;return i.startSequence(),i.startSequence(),i.writeOID("1.2.840.10040.4.1"),i.startSequence(),i.writeBuffer(t,$e.Integer),i.writeBuffer(e,$e.Integer),i.writeBuffer(r,$e.Integer),i.endSequence(),i.endSequence(),i.startSequence($e.BitString),i.writeByte(0),i.writeBuffer(n,$e.Integer),i.endSequence(),i.endSequence(),Gr("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);ur(i,7,0),i.utf8Write("ssh-dss",4,7);let o=11;return ur(i,t.length,o),i.set(t,o+=4),ur(i,e.length,o+=t.length),i.set(e,o+=4),ur(i,r.length,o+=e.length),i.set(r,o+=4),ur(i,n.length,o+=r.length),i.set(n,o+4),i}c(as,"genOpenSSHDSAPub");function Fg(t,e,r,n,i){let o=new $e.Writer;return o.startSequence(),o.writeInt(0,$e.Integer),o.writeBuffer(t,$e.Integer),o.writeBuffer(e,$e.Integer),o.writeBuffer(r,$e.Integer),o.writeBuffer(n,$e.Integer),o.writeBuffer(i,$e.Integer),o.endSequence(),Gr("DSA PRIVATE",o.buffer)}c(Fg,"genOpenSSLDSAPriv");function Hg(t){let e=new $e.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.3.101.112"),e.endSequence(),e.startSequence($e.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),Gr("PUBLIC",e.buffer)}c(Hg,"genOpenSSLEdPub");function jg(t){let e=Buffer.allocUnsafe(19+t.length);return ur(e,11,0),e.utf8Write("ssh-ed25519",4,11),ur(e,t.length,15),e.set(t,19),e}c(jg,"genOpenSSHEdPub");function gI(t){let e=new $e.Writer;return e.startSequence(),e.writeInt(0,$e.Integer),e.startSequence(),e.writeOID("1.3.101.112"),e.endSequence(),e.startSequence($e.OctetString),e.writeBuffer(t,$e.OctetString),e.endSequence(),e.endSequence(),Gr("PRIVATE",e.buffer)}c(gI,"genOpenSSLEdPriv");function bl(t,e){let r=new $e.Writer;return r.startSequence(),r.startSequence(),r.writeOID("1.2.840.10045.2.1"),r.writeOID(t),r.endSequence(),r.startSequence($e.BitString),r.writeByte(0),r._ensure(e.length),r._buf.set(e,r._offset),r._offset+=e.length,r.endSequence(),r.endSequence(),Gr("PUBLIC",r.buffer)}c(bl,"genOpenSSLECDSAPub");function xl(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 ur(n,19,0),n.utf8Write(`ecdsa-sha2-${r}`,4,19),ur(n,8,23),n.utf8Write(r,27,8),ur(n,e.length,35),n.set(e,39),n}c(xl,"genOpenSSHECDSAPub");function mI(t,e,r){let n=new $e.Writer;return n.startSequence(),n.writeInt(1,$e.Integer),n.writeBuffer(r,$e.OctetString),n.startSequence(160),n.writeOID(t),n.endSequence(),n.startSequence(161),n.startSequence($e.BitString),n.writeByte(0),n._ensure(e.length),n._buf.set(e,n._offset),n._offset+=e.length,n.endSequence(),n.endSequence(),n.endSequence(),Gr("EC PRIVATE",n.buffer)}c(mI,"genOpenSSLECDSAPriv");function _I(t,e){let r=sI(t);return r.setPrivateKey(e),r.getPublicKey()}c(_I,"genOpenSSLECDSAPubFromPriv");var cs={sign:c(typeof Lg=="function"?function(e,r){let n=this[Kr];if(n===null)return new Error("No private key available");(!r||typeof r!="string")&&(r=this[bn]);try{return Lg(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[bn]);let i=cI(r);i.update(e);try{return i.sign(n)}catch(o){return o}},"sign"),verify:c(typeof zg=="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 zg(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=uI(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[on]},"getPublicPEM"),getPublicSSH:c(function(){return this[Hn]},"getPublicSSH"),equals:c(function(e){let r=Qg(e);return r instanceof Error?!1:this.type===r.type&&this[Kr]===r[Kr]&&this[on]===r[on]&&this[Hn].equals(r[Hn])},"equals")};function $a(t,e,r,n,i,o,s){this.type=t,this.comment=e,this[Kr]=r,this[on]=n,this[Hn]=i,this[bn]=o,this[Yi]=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,_,b=Re(r,r._pos,!0);if(b===void 0)return new Error("Malformed OpenSSH private key");switch(b){case"ssh-rsa":{let v=Re(r,r._pos);if(v===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 D=Re(r,r._pos);if(D===void 0)return new Error("Malformed OpenSSH private key");let J=Re(r,r._pos);if(J===void 0)return new Error("Malformed OpenSSH private key");let Y=Re(r,r._pos);if(Y===void 0)return new Error("Malformed OpenSSH private key");h=is(v,w),_=os(v,w),g=Mg(v,w,H,D,J,Y),p="sha1";break}case"ssh-dss":{let v=Re(r,r._pos);if(v===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 D=Re(r,r._pos);if(D===void 0)return new Error("Malformed OpenSSH private key");let J=Re(r,r._pos);if(J===void 0)return new Error("Malformed OpenSSH private key");h=ss(v,w,H,D),_=as(v,w,H,D),g=Fg(v,w,H,D,J),p="sha1";break}case"ssh-ed25519":{if(!El)return new Error(`Unsupported OpenSSH private key type: ${b}`);let v=Re(r,r._pos);if(v===void 0||v.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=Hg(v),_=jg(v),g=gI(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"),!Al(r,1))return new Error("Malformed OpenSSH private key");let v=Re(r,r._pos);if(v===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=bl(l,v),_=xl(l,v),g=mI(l,v,w);break}default:return new Error(`Unsupported OpenSSH private key type: ${b}`)}let E=Re(r,r._pos,!0);if(E===void 0)return new Error("Malformed OpenSSH private key");o.push(new $a(b,E,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"&&pI.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 b=Re(h,0);if(b===void 0||h._pos+4>h.length)return new Error("Malformed OpenSSH private key");let E=es(h,h._pos),v=Buffer.allocUnsafe(d.keyLen+d.ivLen);if(dI(n,n.length,b,b.length,v,v.length,E)!==0)return new Error("Failed to generate information to decrypt key");p=li(v,0,d.keyLen),g=li(v,d.keyLen,v.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 E=0;E<_;++E){let v=Re(s,s._pos);if(v===void 0)return new Error("Malformed OpenSSH private key");if(Re(v,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let b=Re(s,s._pos);if(b===void 0)return new Error("Malformed OpenSSH private key");if(p!==void 0){if(b.length<d.blockLen||b.length%d.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let E={authTagLength:d.authLen},v=yl(d.sslName,p,g,E);if(v.setAutoPadding(!1),d.authLen>0){if(s.length-s._pos<d.authLen)return new Error("Malformed OpenSSH private key");v.setAuthTag(li(s,s._pos,s._pos+=d.authLen))}b=ns(v.update(b),v.final())}catch(E){return E}}if(s._pos!==s.length)return new Error("Malformed OpenSSH private key");o=e(b,_,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[Kr]=r,this[on]=n,this[Hn]=i,this[bn]=o,this[Yi]=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 b=o[_],E=b.indexOf(":");if(b.slice(0,E)==="DEK-Info"){let v=b.slice(E+2);if(E=v.indexOf(","),E===-1)continue;let w=v.slice(0,E).toLowerCase();if(fI.indexOf(w)===-1)return new Error(`Cipher (${w}) not supported for encrypted OpenSSH private key`);let H=_l[w];if(!H)return new Error(`Cipher (${w}) not supported for encrypted OpenSSH private key`);let D=Buffer.from(v.slice(E+1),"hex");if(D.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 J=li(D,0,8),Y=ts("md5").update(r).update(J).digest();for(;Y.length<H.keyLen;)Y=ns(Y,ts("md5").update(Y).update(r).update(J).digest());Y.length>H.keyLen&&(Y=li(Y,0,H.keyLen));try{let X=yl(w,Y,D);X.setAutoPadding(!1),i=ns(X.update(i),X.final()),s=!0}catch(X){return X}}}}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=Gr("RSA PRIVATE",i);try{g=new $e.Reader(i),g.readSequence(),g.readInt();let _=g.readString($e.Integer,!0);if(_===null)return new Error(h);let b=g.readString($e.Integer,!0);if(b===null)return new Error(h);l=is(_,b),d=os(_,b)}catch{return new Error(h)}p="sha1";break;case"DSA":a="ssh-dss",u=Gr("DSA PRIVATE",i);try{g=new $e.Reader(i),g.readSequence(),g.readInt();let _=g.readString($e.Integer,!0);if(_===null)return new Error(h);let b=g.readString($e.Integer,!0);if(b===null)return new Error(h);let E=g.readString($e.Integer,!0);if(E===null)return new Error(h);let v=g.readString($e.Integer,!0);if(v===null)return new Error(h);l=ss(_,b,E,v),d=as(_,b,E,v)}catch{return new Error(h)}p="sha1";break;case"EC":{let _,b,E;try{g=new $e.Reader(i),g.readSequence(),g.readInt(),b=g.readString($e.OctetString,!0),g.readByte();let w=g.readLength();if(w!==null){if(g._offset=w,E=g.readOID(),E===null)return new Error(h);switch(E){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: ${E}`)}}else return new Error(h)}catch{return new Error(h)}u=Gr("EC PRIVATE",i);let v=_I(_,b);l=bl(E,v),d=xl(E,v);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[Kr]=r,this[on]=n,this[Hn]=i,this[bn]=o,this[Yi]=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=yl(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],b=p.length,E=u.length,v=Buffer.byteLength(g),w=h.length,H=d.length,D=Buffer.allocUnsafe(4+b+4+E+4+v+4+w+4+H),J=0;if(ur(D,b,J),D.utf8Write(p,J+=4,b),ur(D,E,J+=b),D.utf8Write(u,J+=4,E),ur(D,v,J+=E),D.utf8Write(g,J+=4,v),ur(D,w,J+=v),D.set(h,J+=4),ur(D,H,J+=w),D.set(d,J+4),s||(s=t),aI("sha1",ts("sha1").update("putty-private-key-file-mac-key").update(s).digest()).update(D).digest("hex")!==_)return l?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let X,P,C;switch(h._pos=0,Al(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");X=is(L,M),P=os(L,M),C=Mg(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");X=ss(M,L,T,F),P=as(M,L,T,F),C=Fg(M,L,T,F,j);break}}return new Ba(p,g,C,X,P,"sha1",l)}}function La(t,e,r,n,i){this.type=t,this.comment=e,this[Kr]=null,this[on]=r,this[Hn]=n,this[bn]=i,this[Yi]=!1}c(La,"OpenSSH_Public");La.prototype=cs;{let t;El?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"):Il(o,i,s,n)}}function Ua(t,e,r,n,i){this.type=t,this.comment=e,this[Kr]=null,this[on]=r,this[Hn]=n,this[bn]=i,this[Yi]=!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 b=Re(l,l._pos);if(b===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");p=ss(h,_,b,E),g=as(h,_,b,E);break}default:return new Error("Malformed RFC4716 public key")}return new Ua(d,u,p,g,"sha1")}}function Il(t,e,r,n){if(!Wg(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=Hg(u),a=jg(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"),!Al(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=bl(o,u),a=xl(o,u);break}default:return new Error(`Unsupported OpenSSH public key type: ${e}`)}return new La(n,r,s,a,i)}c(Il,"parseDER");function Wg(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(El)return!0;default:return!1}}c(Wg,"isSupportedKeyType");function qg(t){return t?typeof t[Yi]=="boolean":!1}c(qg,"isParsedKey");function Qg(t,e){if(qg(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=Il(t,i,"",i),n instanceof Error&&(n=null))),Oa.clear()}return n||new Error("Unsupported key format")}c(Qg,"parseKey");Vg.exports={isParsedKey:qg,isSupportedKeyType:Wg,parseDERKey:c((t,e)=>Il(t,e,"",e),"parseDERKey"),parseKey:Qg}});var Cl=le(($F,nm)=>{"use strict";var{Socket:Yg}=require("net"),{Duplex:Xg}=require("stream"),{resolve:yI}=require("path"),{readFile:Kg}=require("fs"),{execFile:EI,spawn:AI}=require("child_process"),{isParsedKey:Gg,parseKey:us}=jn(),{makeBufferParser:bI,readUInt32BE:Tl,writeUInt32BE:Pr,writeUInt32LE:Zg}=Vr();function ls(t){let e=!1;return(...r)=>{e||(e=!0,t(...r))}}c(ls,"once");function xI(t,e){let r=Buffer.allocUnsafe(t.length+e.length);return t.copy(r,0),e.copy(r,t.length),r}c(xI,"concat");function Sl(){}c(Sl,"noop");var II=Buffer.alloc(0),zt=bI(),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"))}},Ji=class extends fs{static{c(this,"OpenSSHAgent")}constructor(e){super(),this.socketPath=e}getStream(e){e=ls(e);let r=new Yg;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 wl(!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 wl(!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)})})}},Jg=(()=>{let s=yI(__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 Xg{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 v=Buffer.allocUnsafe(this.buffer.length+p.length);this.buffer.copy(v,0),p.copy(v,this.buffer.length),this.buffer=v}if(this.buffer.length<4)return h();let _=Tl(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 b,E=this.proc=AI(s,[p.length]);E.stdout.on("data",v=>{this.push(v)}),E.on("error",v=>{b=v,h(b)}),E.on("close",v=>{if(this.proc=void 0,!b){if(b=a[v])return h(b);h()}}),E.stdin.end(p)}_final(p){u(this),p()}_destroy(p,g){u(this),g()}}return class extends Ji{static{c(this,"PageantAgent")}getStream(p){p(null,new l)}}})(),em=(()=>{let t=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Ji{static{c(this,"CygwinAgent")}getStream(r){r=ls(r);let n=this.socketPath,i=!1;Kg(n,c(function o(s,a){if(s){if(i)return r(new Error("Invalid cygwin unix socket path"));EI("cygpath",["-w",n],(Y,X,P)=>{if(Y||X.length===0)return r(new Error("Invalid cygwin unix socket path"));i=!0,n=X.toString().replace(/[\r\n]/g,""),Kg(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),b=parseInt(u[1],10),E=u[2].replace(/-/g,""),v=Buffer.allocUnsafe(16);for(let Y=0,X=0;X<32;++Y,X+=2)v[Y]=parseInt(E.substring(X,X+2),16);for(let Y=0;Y<16;Y+=4)Zg(v,Tl(v,Y),Y);J();function w(){d=0,l="secret",h.write(v)}c(w,"_onconnect");function H(Y){if(d+=Y.length,l==="secret"){d===16&&(d=0,l="creds",h.write(_));return}if(l==="creds"&&(p||g.push(Y),d===12)){if(h.removeListener("connect",w),h.removeListener("data",H),h.removeListener("error",D),h.removeListener("end",D),h.removeListener("close",D),p)return r(null,h);p=!0,_=Buffer.concat(g),Zg(_,process.pid,0),h.on("error",()=>{}),h.destroy(),J()}}c(H,"_ondata");function D(){r(new Error("Problem negotiating cygwin unix socket security"))}c(D,"onFail");function J(){h=new Yg,h.on("connect",w),h.on("data",H),h.on("error",D),h.on("end",D),h.on("close",D),h.connect(b)}c(J,"tryConnect")},"readCygsocket"))}}})(),vI=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function tm(t){return process.platform==="win32"&&!vI.test(t)?t==="pageant"?new Jg:new em(t):new Ji(t)}c(tm,"createAgent");var wl=(()=>{function l(P){let C;for(;P[w].length;){let M=P[w][0][p];if(M===void 0)break;P[w].shift(),C=P.push(M)}return C}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(C,M){this[d]=C,this[p]=void 0,this[g]=M}hasResponded(){return this[p]!==void 0}getType(){return this[d]}getContext(){return this[g]}}function _(P,C,M){return C[p]=M,l(P)}c(_,"respond");function b(P){if(P[D]=null,P[H]===0){let C=P[w];if(C&&C.length){P[w]=[];for(let M of C)M.cb(new Error("No reply from server"))}}try{P.end()}catch{}setImmediate(()=>{P[X]||P.emit("end"),P[Y]||P.emit("close")})}c(b,"cleanup");function E(){this[Y]=!0}c(E,"onClose");function v(){this[X]=!0}c(v,"onEnd");let w=Symbol("Requests"),H=Symbol("Agent Protocol Role"),D=Symbol("Agent Protocol Buffer"),J=Symbol("Agent Protocol Current Message Length"),Y=Symbol("Agent Protocol Closed"),X=Symbol("Agent Protocol Ended");return class extends Xg{static{c(this,"AgentProtocol")}constructor(C){super({autoDestroy:!0,emitClose:!1}),this[H]=C?0:1,this[w]=[],this[D]=null,this[J]=-1,this.once("end",v),this.once("close",E)}_read(C){}_write(C,M,L){this[D]===null?this[D]=C:this[D]=xI(this[D],C);let T=this[D],F=T.length,j=0;for(;j<F&&!(F<5||(this[J]===-1&&(this[J]=Tl(T,j)),F<4+this[J]));){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 Z=this[w].shift();switch(B){case 5:Z.cb(new Error("Agent responded with failure"));break;case 12:{if(Z.type!==11)return L(new Error("Agent responded with wrong message type"));zt.init(T,j);let te=zt.readUInt32BE();if(te===void 0)return zt.clear(),L(new Error("Malformed agent response"));let k=[];for(let W=0;W<te;++W){let q=zt.readString();if(q===void 0)return zt.clear(),L(new Error("Malformed agent response"));let ee=zt.readString(!0);if(ee===void 0)return zt.clear(),L(new Error("Malformed agent response"));q=us(q),!(q instanceof Error)&&(q.comment=q.comment||ee,k.push(q))}j=zt.pos(),zt.clear(),Z.cb(null,k);break}case 14:{if(Z.type!==13)return L(new Error("Agent responded with wrong message type"));zt.init(T,j);let te=zt.readString();if(j=zt.pos(),zt.clear(),te===void 0)return L(new Error("Malformed agent response"));if(zt.init(te,0),zt.readString(!0),te=zt.readString(),zt.clear(),te===void 0)return L(new Error("Malformed OpenSSH signature format"));Z.cb(null,te);break}default:return L(new Error("Agent responded with unsupported message type"))}}else switch(B){case 11:{let Z=new h(B);this[w].push(Z),this.emit("identities",Z);break}case 13:{zt.init(T,j);let Z=zt.readString(),te=zt.readString(),k=zt.readUInt32BE();if(j=zt.pos(),zt.clear(),k===void 0){let ue=new h(B);return this[w].push(ue),this.failureReply(ue)}if(Z=us(Z),Z instanceof Error){let ue=new h(B);return this[w].push(ue),this.failureReply(ue)}let W={hash:void 0},q;Z.type==="ssh-rsa"&&(k&2?(q="rsa-sha2-256",W.hash="sha256"):k&4&&(q="rsa-sha2-512",W.hash="sha512")),q===void 0&&(q=Z.type);let ee=new h(B,q);this[w].push(ee),this.emit("sign",ee,Z,te,W);break}default:{let Z=new h(B);this[w].push(Z),this.failureReply(Z)}}if(this[J]=-1,j===F){this[D]=null;break}else this[D]=T=T.slice(j),F=T.length,j=0}L()}_destroy(C,M){b(this),M()}_final(C){b(this),C()}sign(C,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(C=us(C),C instanceof Error)throw new Error("Invalid public key argument");if(C.type==="ssh-rsa"&&L)switch(L.hash){case"sha256":F=2;break;case"sha512":F=4;break}C=C.getPublicSSH();let j=13,B=C.length,Z=M.length,te=0,k=Buffer.allocUnsafe(9+B+4+Z+4);return Pr(k,k.length-4,te),k[te+=4]=j,Pr(k,B,++te),C.copy(k,te+=4),Pr(k,Z,te+=B),M.copy(k,te+=4),Pr(k,F,te+=Z),typeof T!="function"&&(T=Sl),this[w].push({type:j,cb:T}),this.push(k)}getIdentities(C){if(this[H]!==0)throw new Error("Client-only method called with server role");let M=11,L=0,T=Buffer.allocUnsafe(5);return Pr(T,T.length-4,L),T[L+=4]=M,typeof C!="function"&&(C=Sl),this[w].push({type:M,cb:C}),this.push(T)}failureReply(C){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(C instanceof h))throw new Error("Wrong request argument");if(C.hasResponded())return!0;let M=0,L=Buffer.allocUnsafe(5);return Pr(L,L.length-4,M),L[M+=4]=5,_(this,C,L)}getIdentitiesReply(C,M){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(C instanceof h))throw new Error("Wrong request argument");if(C.hasResponded())return!0;if(C.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 Z=M[B];if(typeof Z!="object"||Z===null)throw new Error(`Invalid key entry: ${Z}`);let te,k;if(Gg(Z))te=Z;else if(Gg(Z.pubKey))te=Z.pubKey;else if(typeof Z.pubKey!="object"||Z.pubKey===null||({pubKey:te,comment:k}=Z.pubKey,te=us(te),te instanceof Error))continue;k=te.comment||k,te=te.getPublicSSH(),L+=4+te.length,k&&typeof k=="string"?k=Buffer.from(k):Buffer.isBuffer(k)||(k=II),L+=4+k.length,T.push({pubKey:te,comment:k})}let F=0,j=Buffer.allocUnsafe(5+L);Pr(j,j.length-4,F),j[F+=4]=12,Pr(j,T.length,++F),F+=4;for(let B=0;B<T.length;++B){let{pubKey:Z,comment:te}=T[B];Pr(j,Z.length,F),Z.copy(j,F+=4),Pr(j,te.length,F+=Z.length),F+=4,te.length&&(te.copy(j,F),F+=te.length)}return _(this,C,j)}signReply(C,M){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(C instanceof h))throw new Error("Wrong request argument");if(C.hasResponded())return!0;if(C.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=C.getContext(),F=Buffer.byteLength(T),j=Buffer.allocUnsafe(13+F+4+M.length);return Pr(j,j.length-4,L),j[L+=4]=14,Pr(j,4+F+4+M.length,++L),Pr(j,F,L+=4),j.utf8Write(T,L+=4,F),Pr(j,M.length,L+=F),M.copy(j,L+=4),_(this,C,j)}}})(),vl=Symbol("Agent"),Zr=Symbol("Agent Keys"),xn=Symbol("Agent Keys Index"),Xi=Symbol("Agent Init Callbacks"),Pl=class{static{c(this,"AgentContext")}constructor(e){if(typeof e=="string")e=tm(e);else if(!rm(e))throw new Error("Invalid agent argument");this[vl]=e,this[Zr]=null,this[xn]=-1,this[Xi]=null}init(e){if(typeof e!="function"&&(e=Sl),this[Zr]===null)if(this[Xi]===null){this[Xi]=[e];let r=c((...n)=>{process.nextTick(()=>{let i=this[Xi];this[Xi]=null;for(let o of i)o(...n)})},"doCbs");this[vl].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[Zr]=o,this[xn]=-1,r()}))}else this[Xi].push(e);else process.nextTick(e)}nextKey(){return this[Zr]===null||++this[xn]>=this[Zr].length?!1:this[Zr][this[xn]]}currentKey(){return this[Zr]===null||this[xn]>=this[Zr].length?null:this[Zr][this[xn]]}pos(){return this[Zr]===null||this[xn]>=this[Zr].length?-1:this[xn]}reset(){this[xn]=-1}sign(...e){this[vl].sign(...e)}};function rm(t){return t instanceof fs}c(rm,"isAgent");nm.exports={AgentContext:Pl,AgentProtocol:wl,BaseAgent:fs,createAgent:tm,CygwinAgent:em,isAgent:rm,OpenSSHAgent:Ji,PageantAgent:Jg}});var Dl=le((BF,im)=>{"use strict";var{kMaxLength:SI}=require("buffer"),{createInflate:wI,constants:{DEFLATE:PI,INFLATE:TI,Z_DEFAULT_CHUNK:CI,Z_DEFAULT_COMPRESSION:kI,Z_DEFAULT_MEMLEVEL:RI,Z_DEFAULT_STRATEGY:NI,Z_DEFAULT_WINDOWBITS:OI,Z_PARTIAL_FLUSH:$I}}=require("zlib"),DI=wI()._handle.constructor;function BI(){throw new Error("Should not get here")}c(BI,"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 $l(t){t._handle&&(t._handle.close(),t._handle=null)}c($l,"_close");var za=class{static{c(this,"Zlib")}constructor(e){let r=OI,n=kI,i=RI,o=NI,s=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=CI,this._maxOutputLength=SI,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new DI(e),this._handle._owner=this,this._handle.onerror=UI,this._handle.init(r,n,i,o,this._writeState,BI,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($I,e,s,i,g,h,o),this._err)throw this._err;a=p[0],u=p[1];let E=i-u,v=o-a;if(v>0){let w=h===0&&v===g.length?g:g.slice(h,h+v);if(h+=v,l?l.push===void 0?l=[l,w]:l.push(w):l=w,d+=w.byteLength,d>this._maxOutputLength)throw $l(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(v!==0)throw new Error("have should not go down");if((a===0||h>=_)&&(o=_,h=0,g=Buffer.allocUnsafe(_)),a===0)s+=E,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 b=Buffer.allocUnsafe(d);for(let E=0,v=0;E<l.length;++E){let w=l[E];b.set(w,v),v+=w.length}return b}},kl=class{static{c(this,"ZlibPacketWriter")}constructor(e){this.allocStart=0,this.allocStartKEX=0,this._protocol=e,this._zlib=new za(PI)}cleanup(){this._zlib&&$l(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}},Rl=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}},Nl=class{static{c(this,"ZlibPacketReader")}constructor(){this._zlib=new za(TI)}cleanup(){this._zlib&&$l(this._zlib)}read(e){return this._zlib.writeSync(e,!1)}},Ol=class{static{c(this,"PacketReader")}cleanup(){}read(e){return e}};im.exports={PacketReader:Ol,PacketWriter:Rl,ZlibPacketReader:Nl,ZlibPacketWriter:kl}});var um=le((LF,cm)=>{"use strict";var{bufferSlice:Bl,bufferParser:$,doFatalError:Tt,sigSSHToASN1:om,writeUInt32BE:sm}=Vr(),{CHANNEL_OPEN_FAILURE:LI,COMPAT:zI,MESSAGE:Ct,TERMINAL_MODE:am}=An(),{parseKey:MI}=jn(),FI=Array.from(Object.entries(am)).reduce((t,[e,r])=>({...t,[e]:r}),{});cm.exports={[Ct.DISCONNECT]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE(),n=$.readString(!0),i=$.readString();if($.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)},[Ct.IGNORE]:(t,e)=>{t._debug&&t._debug("Inbound: Received IGNORE")},[Ct.UNIMPLEMENTED]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE();if($.clear(),r===void 0)return Tt(t,"Inbound: Malformed UNIMPLEMENTED packet");t._debug&&t._debug(`Inbound: Received UNIMPLEMENTED (seqno ${r})`)},[Ct.DEBUG]:(t,e)=>{$.init(e,1);let r=$.readBool(),n=$.readString(!0),i=$.readString();if($.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)},[Ct.SERVICE_REQUEST]:(t,e)=>{$.init(e,1);let r=$.readString(!0);if($.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)},[Ct.SERVICE_ACCEPT]:(t,e)=>{$.init(e,1);let r=$.readString(!0);if($.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)},[Ct.EXT_INFO]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE(),n;if(r!==void 0){n=[];for(let o=0;o<r;++o){let s=$.readString(!0),a=$.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($.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)},[Ct.USERAUTH_REQUEST]:(t,e)=>{$.init(e,1);let r=$.readString(!0),n=$.readString(!0),i=$.readString(!0),o,s;switch(i){case"none":o=null;break;case"password":{let u=$.readBool();if(u!==void 0&&(o=$.readString(!0),o!==void 0&&u)){let l=$.readString(!0);l!==void 0?o={oldPassword:o,newPassword:l}:o=void 0}break}case"publickey":{let u=$.readBool();if(u!==void 0){let l=$.readString(!0),d=l,p=$.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=$.pos(),_=$.readString();if(_!==void 0&&(_.length>4+l.length+4&&_.utf8Slice(4,4+l.length)===l&&(_=Bl(_,4+l.length+4)),_=om(_,d),_)){let b=t._kex.sessionID,E=Buffer.allocUnsafe(4+b.length+h);sm(E,b.length,0),E.set(b,4),E.set(new Uint8Array(e.buffer,e.byteOffset,h),4+b.length),o={keyAlgo:d,key:p,signature:_,blob:E,hashAlgo:g}}}else o={keyAlgo:d,key:p,hashAlgo:g},s="publickey -- check"}break}case"hostbased":{let u=$.readString(!0),l=u,d=$.readString(),p=$.readString(!0),g=$.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 _=$.pos(),b=$.readString();if(b!==void 0&&(b.length>4+u.length+4&&b.utf8Slice(4,4+u.length)===u&&(b=Bl(b,4+u.length+4)),b=om(b,l),b!==void 0)){let E=t._kex.sessionID,v=Buffer.allocUnsafe(4+E.length+_);sm(v,E.length,0),v.set(E,4),v.set(new Uint8Array(e.buffer,e.byteOffset,_),4+E.length),o={keyAlgo:l,key:d,signature:b,blob:v,localHostname:p,localUsername:g,hashAlgo:h}}break}case"keyboard-interactive":$.skipString(),o=$.readList();break;default:i!==void 0&&(o=$.readRaw())}if($.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)},[Ct.USERAUTH_FAILURE]:(t,e)=>{$.init(e,1);let r=$.readList(),n=$.readBool();if($.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)},[Ct.USERAUTH_SUCCESS]:(t,e)=>{t._debug&&t._debug("Inbound: Received USERAUTH_SUCCESS"),t._authsQueue.shift();let r=t._handlers.USERAUTH_SUCCESS;r&&r(t)},[Ct.USERAUTH_BANNER]:(t,e)=>{$.init(e,1);let r=$.readString(!0),n=$.readString();if($.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":{$.init(e,1);let r=$.readString(!0),n=$.readString();if($.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":{$.init(e,1);let r=$.readString(!0),n=$.readString();if($.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":{$.init(e,1);let r=$.readString(!0),n=$.readString(!0);$.readString();let i=$.readUInt32BE(),o;if(i!==void 0){o=new Array(i);let a;for(a=0;a<i;++a){let u=$.readString(!0),l=$.readBool();if(l===void 0)break;o[a]={prompt:u,echo:l}}a!==i&&(o=void 0)}if($.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");$.init(e,1);let r=$.readUInt32BE(),n;if(r!==void 0){n=new Array(r);let o;for(o=0;o<r;++o){let s=$.readString(!0);if(s===void 0)break;n[o]=s}o!==r&&(n=void 0)}if($.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)},[Ct.GLOBAL_REQUEST]:(t,e)=>{$.init(e,1);let r=$.readString(!0),n=$.readBool(),i;if(n!==void 0)switch(r){case"tcpip-forward":case"cancel-tcpip-forward":{let s=$.readString(!0),a=$.readUInt32BE();a!==void 0&&(i={bindAddr:s,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let s=$.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=[];$.avail()>0;){let s=$.readString();if(s===void 0){i=void 0;break}let a=MI(s);a instanceof Error||i.push(a)}break}default:i=$.readRaw()}if($.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()},[Ct.REQUEST_SUCCESS]:(t,e)=>{let r=e.length>1?Bl(e,1):null;t._debug&&t._debug("Inbound: REQUEST_SUCCESS");let n=t._handlers.REQUEST_SUCCESS;n&&n(t,r)},[Ct.REQUEST_FAILURE]:(t,e)=>{t._debug&&t._debug("Inbound: Received REQUEST_FAILURE");let r=t._handlers.REQUEST_FAILURE;r&&r(t)},[Ct.CHANNEL_OPEN]:(t,e)=>{$.init(e,1);let r=$.readString(!0),n=$.readUInt32BE(),i=$.readUInt32BE(),o=$.readUInt32BE(),s;switch(r){case"forwarded-tcpip":case"direct-tcpip":{let u=$.readString(!0),l=$.readUInt32BE(),d=$.readString(!0),p=$.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=$.readString(!0);u!==void 0&&(s={type:r,sender:n,window:i,packetSize:o,data:{socketPath:u}});break}case"x11":{let u=$.readString(!0),l=$.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($.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,"","")},[Ct.CHANNEL_OPEN_CONFIRMATION]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE(),n=$.readUInt32BE(),i=$.readUInt32BE(),o=$.readUInt32BE(),s=$.avail()?$.readRaw():void 0;if($.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})},[Ct.CHANNEL_OPEN_FAILURE]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE(),n=$.readUInt32BE(),i=$.readString(!0),o=$.readString();if($.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)},[Ct.CHANNEL_WINDOW_ADJUST]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE(),n=$.readUInt32BE();if($.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)},[Ct.CHANNEL_DATA]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE(),n=$.readString();if($.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)},[Ct.CHANNEL_EXTENDED_DATA]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE(),n=$.readUInt32BE(),i=$.readString();if($.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)},[Ct.CHANNEL_EOF]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE();if($.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)},[Ct.CHANNEL_CLOSE]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE();if($.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)},[Ct.CHANNEL_REQUEST]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE(),n=$.readString(!0),i=$.readBool(),o;if(i!==void 0)switch(n){case"exit-status":o=$.readUInt32BE(),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"exit-signal":{let a,u;if(t._compatFlags&zI.OLD_EXIT){let d=$.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=$.readString(!0),u=$.readBool(),u===void 0&&(a=void 0);let l=$.readString(!0);$.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=$.readString(!0),u=$.readUInt32BE(),l=$.readUInt32BE(),d=$.readUInt32BE(),p=$.readUInt32BE(),g=$.readString();if(g!==void 0){$.init(g,1);let h={};for(;$.avail();){let _=$.readByte();if(_===am.TTY_OP_END)break;let b=FI[_],E=$.readUInt32BE();if(_===void 0||b===void 0||E===void 0){h=void 0;break}h[b]=E}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=$.readUInt32BE(),u=$.readUInt32BE(),l=$.readUInt32BE(),d=$.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=$.readBool(),u=$.readString(!0),l=$.readString(),d=$.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=$.readString(!0),u=$.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=$.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"subsystem":o=$.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"signal":o=$.readString(!0),t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n}: ${o})`);break;case"xon-xoff":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=$.avail()?$.readRaw():null,t._debug&&t._debug(`Inbound: CHANNEL_REQUEST (r:${r}, ${n})`)}if($.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)},[Ct.CHANNEL_SUCCESS]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE();if($.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)},[Ct.CHANNEL_FAILURE]:(t,e)=>{$.init(e,1);let r=$.readUInt32BE();if($.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((zF,lm)=>{"use strict";var Ul=new Array(256);[Fa().HANDLERS,um()].forEach(t=>{for(let[e,r]of Object.entries(t))e=+e,isFinite(e)&&e>=0&&e<Ul.length&&(Ul[e]=r)});lm.exports=Ul});var Fa=le((FF,Am)=>{"use strict";var{createDiffieHellman:HI,createDiffieHellmanGroup:jI,createECDH:WI,createHash:zl,createPublicKey:qI,diffieHellman:QI,generateKeyPairSync:VI,randomFillSync:KI}=require("crypto"),{Ber:fm}=Ko(),{COMPAT:Ml,curve25519Supported:GI,DEFAULT_KEX:dm,DEFAULT_SERVER_HOST_KEY:pm,DEFAULT_CIPHER:Ha,DEFAULT_MAC:ja,DEFAULT_COMPRESSION:Wa,DISCONNECT_REASON:st,MESSAGE:wt}=An(),{CIPHER_INFO:ro,createCipher:ZI,createDecipher:YI,MAC_INFO:hm}=Mn(),{parseDERKey:XI}=jn(),{bufferFill:JI,bufferParser:ot,convertSignature:ev,doFatalError:at,FastBuffer:tv,sigSSHToASN1:rv,writeUInt32BE:lr}=Vr(),{PacketReader:gm,PacketWriter:mm,ZlibPacketReader:qa,ZlibPacketWriter:Qa}=Dl(),eo,nv=2048,iv=8192,ov=Buffer.alloc(0);function _m(t){let e;if(t._compatFlags&Ml.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),lr(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,KI(e,1,16),JI(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(_m,"kexinit");function ym(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(ot.init(e,17),(r.kex=ot.readList())===void 0||(r.serverHostKey=ot.readList())===void 0||(r.cs.cipher=ot.readList())===void 0||(r.sc.cipher=ot.readList())===void 0||(r.cs.mac=ot.readList())===void 0||(r.sc.mac=ot.readList())===void 0||(r.cs.compress=ot.readList())===void 0||(r.sc.compress=ot.readList())===void 0||(r.cs.lang=ot.readList())===void 0||(r.sc.lang=ot.readList())===void 0)return ot.clear(),at(t,"Received malformed KEXINIT","handshake",st.KEY_EXCHANGE_FAILED);let n=ot.pos(),i=n<e.length&&e[n]===1;ot.clear();let o=t._offer,s=r,a=o.lists.kex.array;if(t._compatFlags&Ml.BAD_DHGEX){let D=!1;for(let J=0;J<a.length;++J)a[J].indexOf("group-exchange")!==-1&&(D||(D=!0,a=a.slice()),a.splice(J--,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 b=o.lists.sc.cipher.array;for(p&&p(`Handshake: (local) S->C cipher: ${b}`),p&&p(`Handshake: (remote) S->C cipher: ${s.sc.cipher}`),t._server?(l=b,u=s.sc.cipher):(l=s.sc.cipher,u=b),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 E=o.lists.cs.mac.array;if(p&&p(`Handshake: (local) C->S MAC: ${E}`),p&&p(`Handshake: (remote) C->S MAC: ${s.cs.mac}`),ro[r.cs.cipher].authLen>0)r.cs.mac="",p&&p("Handshake: C->S MAC: <implicit>");else{for(t._server?(l=E,u=s.cs.mac):(l=s.cs.mac,u=E),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 v=o.lists.sc.mac.array;if(p&&p(`Handshake: (local) S->C MAC: ${v}`),p&&p(`Handshake: (remote) S->C MAC: ${s.sc.mac}`),ro[r.sc.cipher].authLen>0)r.sc.mac="",p&&p("Handshake: S->C MAC: <implicit>");else{for(t._server?(l=v,u=s.sc.mac):(l=s.sc.mac,u=v),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||_m(t),t._decipher._onPayload=Em.bind(t,{firstPacket:!1})),t._kex=sv(r,t,e),t._kex.remoteExtInfoEnabled=g,t._kex.start()}c(ym,"handleKexInit");var sv=(()=>{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=zl(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(),D=Buffer.allocUnsafe(4);lr(D,this._minBits,0),g.update(D),lr(D,this._prefBits,0),g.update(D),lr(D,this._maxBits,0),g.update(D),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 b=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 D=this._hostKey.sign(b,H);if(D instanceof Error)return at(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${D.message}`,"handshake",st.KEY_EXCHANGE_FAILED);if(D=ev(D,this._hostKey.type),D===!1)return at(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",st.KEY_EXCHANGE_FAILED);let J=this.negotiated.serverHostKey,Y=Buffer.byteLength(J),X=4+Y+4+D.length,P=this._protocol._packetRW.write.allocStartKEX,C=this._protocol._packetRW.write.alloc(5+h.length+4+_.length+4+X,!0);if(C[P]=wt.KEXDH_REPLY,lr(C,h.length,++P),C.set(h,P+=4),lr(C,_.length,P+=h.length),C.set(_,P+=4),lr(C,X,P+=_.length),lr(C,Y,P+=4),C.utf8Write(J,P+=4,Y),lr(C,D.length,P+=Y),C.set(D,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(C,!0))}else{ot.init(this._sig,0);let H=ot.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 D=ot.readString();if(ot.clear(),D===void 0)return at(this._protocol,"Malformed packet while reading signature","handshake",st.KEY_EXCHANGE_FAILED);if(!(D=rv(D,H)))return at(this._protocol,"Malformed signature","handshake",st.KEY_EXCHANGE_FAILED);let J;{ot.init(this._hostKey,0);let P=ot.readString(!0),C=this._hostKey.slice(ot.pos());if(ot.clear(),J=XI(C,P),J instanceof Error)return J.level="handshake",at(this._protocol,J,st.KEY_EXCHANGE_FAILED)}let Y;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":Y="sha256";break;case"rsa-sha2-512":Y="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");let X=J.verify(b,D,Y);if(X!==!0)return X instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${X.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),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 E,v,w=c(H=>{if(E)return Va(this),E.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=ZI(E),this._protocol._packetRW.write=v,E=void 0,v=void 0,this._protocol._onHandshakeComplete(l),!1;this.sessionID||(this.sessionID=b);{let Z=Buffer.allocUnsafe(4+p.length);lr(Z,p.length,0),Z.set(p,4),p=Z}let D=ro[l.cs.cipher],J=ro[l.sc.cipher],Y=to(D.ivLen,this.hashName,p,b,this.sessionID,"A"),X=to(J.ivLen,this.hashName,p,b,this.sessionID,"B"),P=to(D.keyLen,this.hashName,p,b,this.sessionID,"C"),C=to(J.keyLen,this.hashName,p,b,this.sessionID,"D"),M,L;D.authLen||(M=hm[l.cs.mac],L=to(M.len,this.hashName,p,b,this.sessionID,"E"));let T,F;J.authLen||(T=hm[l.sc.mac],F=to(T.len,this.hashName,p,b,this.sessionID,"F"));let j={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:u?D:J,decipherIV:u?Y:X,decipherKey:u?P:C,macInfo:u?M:T,macKey:u?L:F},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:u?J:D,cipherIV:u?X:Y,cipherKey:u?C:P,macInfo:u?T:M,macKey:u?F:L}};this._protocol._decipher.free(),E=j,this._protocol._decipher=YI(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 gm:B.write=new mm(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 mm(this._protocol):B.read=new gm}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=B.read,v=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,lr(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"),ot.init(a,1);let l=ot.readString();if(ot.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"),ot.init(a,1);let l,d,p;if((l=ot.readString())===void 0||(d=ot.readString())===void 0||(p=ot.readString())===void 0)return ot.clear(),at(this._protocol,"Received malformed KEX*_REPLY","handshake",st.KEY_EXCHANGE_FAILED);ot.clear(),ot.init(l,0);let g=ot.readString(!0);if(ot.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,b=>{if(!h){if(h=!0,b===!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=VI("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 fm.Writer;return u.startSequence(),u.startSequence(),u.writeOID("1.3.101.110"),u.endSequence(),u.startSequence(fm.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(QI({privateKey:this._keys.privateKey,publicKey:qI({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=WI(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=nv,this._prefBits=av(this.negotiated),this._protocol._compatFlags&Ml.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=iv}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,lr(u,this._minBits,++a),lr(u,this._prefBits,a+=4),lr(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"),ot.init(a,1);let l,d;if((l=ot.readString())===void 0||(d=ot.readString())===void 0)return ot.clear(),at(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",st.KEY_EXCHANGE_FAILED);ot.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,lr(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,lr(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=jI(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(!GI)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}`)}})(),Ll=(()=>{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=lr(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)=>{lr(t,r.length,0),e.update(t),e.update(r)}})();function to(t,e,r,n,i,o){let s;if(t){let a=zl(e).update(r).update(n).update(o).update(i).digest();for(;a.length<t;){let u=zl(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 tv(a.buffer,a.byteOffset,t)}else s=ov;return s}c(to,"generateKEXVal");function Em(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 eo||(eo=Ma()),eo[r](this,e)}switch(r){case wt.DISCONNECT:return eo||(eo=Ma()),eo[r](this,e);case wt.KEXINIT:return t.firstPacket?(t.firstPacket=!1,ym(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(Em,"onKEXPayload");function av(t){let e=ro[t.cs.cipher],r=ro[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(av,"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");Am.exports={KexInit:Ll,kexinit:_m,onKEXPayload:Em,DEFAULT_KEXINIT_CLIENT:new Ll({kex:dm.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:pm,cs:{cipher:Ha,mac:ja,compress:Wa,lang:[]},sc:{cipher:Ha,mac:ja,compress:Wa,lang:[]}}),DEFAULT_KEXINIT_SERVER:new Ll({kex:dm.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:pm,cs:{cipher:Ha,mac:ja,compress:Wa,lang:[]},sc:{cipher:Ha,mac:ja,compress:Wa,lang:[]}}),HANDLERS:{[wt.KEXINIT]:ym}}});var bm=le((jF,cv)=>{cv.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 Wl=le((WF,$m)=>{"use strict";var{inspect:Pm}=require("util"),{bindingAvailable:uv,NullCipher:lv,NullDecipher:fv}=Mn(),{COMPAT_CHECKS:dv,DISCONNECT_REASON:Tm,eddsaSupported:pv,MESSAGE:we,SIGNALS:xm,TERMINAL_MODE:Hl}=An(),{DEFAULT_KEXINIT_CLIENT:hv,DEFAULT_KEXINIT_SERVER:gv,KexInit:Im,kexinit:Cm,onKEXPayload:mv}=Fa(),{parseKey:vm}=jn(),_v=Ma(),{bufferCopy:Ka,bufferFill:yv,bufferSlice:km,convertSignature:Sm,sendPacket:Pe,writeUInt32BE:R}=Vr(),{PacketReader:Ev,PacketWriter:Av,ZlibPacketReader:Rm,ZlibPacketWriter:Nm}=Dl(),bv=bm().version,xv=new Map(Object.values(Tm).map(t=>[t,1])),Om=Buffer.from(`SSH-2.0-ssh2js${bv}`),Iv=Buffer.from(`${Om}\r
|
|
12
|
+
`),vv=8192,Sv=1024,wm=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]),wv=Buffer.from([Hl.TTY_OP_END]);function Fl(){}c(Fl,"noop");var jl=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)}:Fl;let s=e.onPacket;this._onPacket=typeof s=="function"?()=>{s()}:Fl;let a=e.onHandshakeComplete;typeof a!="function"&&(a=Fl);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 b=0;b<_.length;++b){let E=_[b],v=this._packetRW.write.finalize(E);if(v===E){let w=this._cipher.allocPacket(E.length);w.set(E,5),v=w}Pe(this,v)}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=kv.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?rv:tv:p.constructor!==mm&&(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 mm(p)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=p,this._cipher=new YI(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new sv,write:new av(this)},this._hostVerifier=!this._server&&typeof e.hostVerifier=="function"?e.hostVerifier:void 0,this._parse=gv,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=wm,g=lv;this._compatFlags=0,this._debug&&(ZI?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${Am(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;uv.has(e)||(e=bm.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(Em.length);r.set(Em,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=[],xm(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=_m(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(_=ym(_,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=_m(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=ym(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),ov(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=Ev(a)),(!a||!a.length)&&(a=pv);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)),gm[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)),gm[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 vm),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new Sm(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))}},hv=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function gv(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),_=hv.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: ${Am(h)}`),this._compatFlags=yv(A),this._buffer=void 0,this._decipher=new XI(0,nv.bind(this,{firstPacket:!0})),this._parse=mv,this._onHeader(A),this._destruct?(xm(this),e+1-i):r}if(this._server)throw new Error("Greetings from clients not permitted");if(++d>dv)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>=fv)throw new Error("Header line too long")}a=e}return this._buffer||(this._buffer=Im(n,o)),e-i}c(gv,"parseHeader");function mv(t,e,r){return this._decipher.decrypt(t,e,r)}c(mv,"parsePacket");function _v(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 Sm(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new vm));let r=iv[e];if(r===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${e}`);return}return r(this,t)}c(_v,"onPayload");function yv(t){let e=t.versions.software,r=0;for(let n of JI)typeof n[0]=="string"?e===n[0]&&(r|=n[1]):n[0].test(e)&&(r|=n[1]);return r}c(yv,"getCompatFlags");function Ev(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?Im(r,0,n):r}c(Ev,"modesToBytes");function Av(t){let e="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";ev&&(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(Av,"sendExtInfo");Pm.exports=Fl});var Om=le(ds=>{"use strict";var Ga=require("assert"),{inspect:bv}=require("util");function Tm(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(Tm,"addNumericalSeparator");function Cm(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(Cm,"oneOf");ds.ERR_INTERNAL_ASSERTION=class Rm extends Error{static{c(this,"ERR_INTERNAL_ASSERTION")}constructor(e){super(),Error.captureStackTrace(this,Rm);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?gv:hv:p.constructor!==Im&&(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 Im(p)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=p,this._cipher=new lv(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new Ev,write:new Av(this)},this._hostVerifier=!this._server&&typeof e.hostVerifier=="function"?e.hostVerifier:void 0,this._parse=Tv,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=Om,g=Iv;this._compatFlags=0,this._debug&&(uv?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;xv.has(e)||(e=Tm.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(wm.length);r.set(wm,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=[],Cm(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=vm(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(_=Sm(_,o),_===!1)throw new Error("Error while converting handshake signature");let b=_.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+b),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+b,h+=u),R(g,a,h+=4),g.utf8Write(n,h+=4,a),R(g,b,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=vm(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),b=Buffer.allocUnsafe(4+g+1+4+u+4+14+4+9+4+l+4+d+4+h+4+_),E=0;R(b,g,E),b.set(p,E+=4),b[E+=g]=we.USERAUTH_REQUEST,R(b,u,++E),b.utf8Write(e,E+=4,u),R(b,14,E+=u),b.utf8Write("ssh-connection",E+=4,14),R(b,9,E+=14),b.utf8Write("hostbased",E+=4,9),R(b,l,E+=9),b.utf8Write(o,E+=4,l),R(b,d,E+=l),b.set(r,E+=4),R(b,h,E+=d),b.utf8Write(n,E+=4,h),R(b,_,E+=h),b.utf8Write(i,E+=4,_),s(b,v=>{if(v=Sm(v,a),!v)throw new Error("Error while converting handshake signature");let w=v.length,H=b.length-g-4;E=this._packetRW.write.allocStart;let D=this._packetRW.write.alloc(H+4+4+l+4+w);Ka(b,D,4+g,b.length,E),R(D,4+l+4+w,E+=H),R(D,l,E+=4),D.utf8Write(o,E+=4,l),R(D,w,E+=l),D.set(v,E+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),Pe(this,this._packetRW.write.finalize(D))})}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),yv(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=Nv(a)),(!a||!a.length)&&(a=wv);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)),xm[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)),xm[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 Rm),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new Nm(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 Tv(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 b={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=Rv(b),this._buffer=void 0,this._decipher=new fv(0,mv.bind(this,{firstPacket:!0})),this._parse=Cv,this._onHeader(b),this._destruct?(Cm(this),e+1-i):r}if(this._server)throw new Error("Greetings from clients not permitted");if(++d>Sv)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>=vv)throw new Error("Header line too long")}a=e}return this._buffer||(this._buffer=km(n,o)),e-i}c(Tv,"parseHeader");function Cv(t,e,r){return this._decipher.decrypt(t,e,r)}c(Cv,"parsePacket");function kv(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 Nm(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new Rm));let r=_v[e];if(r===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${e}`);return}return r(this,t)}c(kv,"onPayload");function Rv(t){let e=t.versions.software,r=0;for(let n of dv)typeof n[0]=="string"?e===n[0]&&(r|=n[1]):n[0].test(e)&&(r|=n[1]);return r}c(Rv,"getCompatFlags");function Nv(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=Hl[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++]=Hl.TTY_OP_END,n<r.length?km(r,0,n):r}c(Nv,"modesToBytes");function Ov(t){let e="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";pv&&(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");$m.exports=jl});var Mm=le(ds=>{"use strict";var Ga=require("assert"),{inspect:$v}=require("util");function Dm(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(Dm,"addNumericalSeparator");function Bm(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(Bm,"oneOf");ds.ERR_INTERNAL_ASSERTION=class Lm extends Error{static{c(this,"ERR_INTERNAL_ASSERTION")}constructor(e){super(),Error.captureStackTrace(this,Lm);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 xv=2**32,km=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();ds.ERR_OUT_OF_RANGE=class Nm extends RangeError{static{c(this,"ERR_OUT_OF_RANGE")}constructor(e,r,n,i){super(),Error.captureStackTrace(this,Nm),Ga(r,'Missing "range" argument');let o=i?e:`The value of "${e}" is out of range.`,s;Number.isInteger(n)&&Math.abs(n)>xv?s=Tm(String(n)):typeof n=="bigint"?(s=String(n),(n>km||n<-km)&&(s=Tm(s)),s+="n"):s=bv(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} ${Cm(r,"type")}`;else{let s=e.includes(".")?"property":"argument";o=`The "${e}" ${s} ${i} ${Cm(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((AF,Qm)=>{"use strict";var Iv=require("events"),qn=require("fs"),{constants:Pr}=qn,{Readable:zm,Writable:Yl}=require("stream"),{inherits:Mm,types:{isDate:ql}}=require("util"),vv=Buffer[Symbol.species],{bufferCopy:Wn,bufferSlice:io,makeBufferParser:Sv,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},wv=new Map(Object.values(ht).map(t=>[t,1])),Pv={[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},$m=2*1024,St=2**32-1,Tv=Buffer.from([0,0,0,5,Ne.INIT,0,0,0,3]),Cv=Buffer.from([0,0,0,5,Tr.VERSION,0,0,0,3]),kv=/^SSH-2.0-(?:OpenSSH|dropbear)/,jl=256*1024,U=Sv(),Rv={readable:!1,writable:!1,push:c(t=>{},"push"),once:c(()=>{},"once"),on:c(()=>{},"on"),emit:c(()=>{},"emit"),end:c(()=>{},"end")};function Fm(){}c(Fm,"noop");var Ql=class extends Iv{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)-$m,this._maxWriteLen=(this._isOpenSSH?jl:34e3)-$m,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=Rv,this.readable=!0}push(e){if(e===null){if(qm(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 Et(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return Et(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 vv(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]:Dv[n];if(!o)return Et(this,`Unknown packet type ${n}`);if(this._version===-1){if(this.server){if(n!==Ne.INIT)return Et(this,`Expected INIT packet, got ${n}`)}else if(n!==Tr.VERSION)return Et(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=Fm,this.server||lt(this,Tv)}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:jm(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):Wn($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");Hm(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),Wn(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");Dm(this,qn,e,r,n,i)}fastPut(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");Dm(qn,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):Wn($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):Wn($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):Wn($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):Wn($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(!wv.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),Wn($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):Wn($e,s,0,i,o),o+=i);let a=lt(this,s);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function Nv(t){try{return Buffer.allocUnsafe(t)}catch(e){return e}}c(Nv,"tryCreateBuffer");function Hm(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=Fm);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,Hm(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(Hm,"read_");function Dm(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===qn||t.outgoing.state==="open")&&++X,b&&(e===qn||e.outgoing.state==="open")&&++X,A&&(t===qn||t.outgoing.state==="open")&&t.close(A,Z),b&&(e===qn||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!==qn){t.stat(r,(C,M)=>{if(C)return H(Y);Z(null,M)});return}return H(Y)}p=P.size,e.open(n,"w",(C,M)=>{if(C)return H(C);if(b=M,p<=0)return H();for(;w>p;){if(s===1){w=p;break}w-=a,--s}if(I=Nv(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,k,W,q){if(B)return H(B);W=W||0,e.write(b,I,W,G,k,J);function J(ue){if(ue)return H(ue);if(h+=G,u&&u(h,G,p),G<q)return F(W,k+G,q-G);if(h===p){e.close(b,he=>{if(b=void 0,he)return H(he);t.close(A,xt=>{if(A=void 0,xt)return H(xt);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(k,W,q)=>{L(k,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(Dm,"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 jm(t){let e=Kl[t];return e!==void 0?e:null}c(jm,"stringToFlags");var Ov=(()=>{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=Wm(t,e);return r!==void 0?(t._buffer.push(r),!1):!0}c(lt,"sendOrBuffer");function Wm(t,e){let r=t.outgoing;if(r.state!=="open")return;if(r.window===0)return t._waitWindow=!0,t._chunkcb=Bm,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=Bm),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(Wm,"tryWritePayload");function Bm(){this._chunkcb=void 0;let t=this._buffer,e=0;for(;e<t.length;){let r=t[e],n=Wm(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(Bm,"drainBuffer");function Et(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(),qm(t),!1}c(Et,"doFatalSFTPError");function qm(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(qm,"cleanupRequests");function $v(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($v,"requestLimits");var Dv={[Tr.VERSION]:(t,e)=>{if(t._version!==-1)return Et(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 Et(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 $v(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||Pv[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],Et(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 Et(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(),Et(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 Et(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(),Et(t,"Malformed EXTENDED_REPLY packet")}},Bv={[Ne.INIT]:(t,e)=>{if(t._version!==-1)return Et(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 Et(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,Cv),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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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 Et(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(),Et(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:Uv,ERR_OUT_OF_RANGE:Ya,validateNumber:Lv}=Om(),Um=128,Ir,Gl=[];function zv(t){Gl.length>0?Ir=Gl.pop():Ir=Buffer.allocUnsafe(t),Ir.used=0}c(zv,"allocNewPool");function Zl(t,e){if(!Number.isSafeInteger(t))throw Lv(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,zm.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");Mm(vn,zm);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<Um)&&zv(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>=Um&&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",Lm.bind(null,this,e,t));return}Lm(this,e,t),this.handle=null,this._opening=!1};function Lm(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(Lm,"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");Mm(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 Uv("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});Qm.exports={flagsToString:Ov,OPEN_MODE:Te,SFTP:Ql,Stats:Xa,STATUS_CODE:ht,stringToFlags:jm}});var of=le((xF,Zm)=>{"use strict";var{Duplex:Mv,Readable:Fv,Writable:Hv}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:Vm}}=An(),{bufferSlice:Ja}=Qr(),jv=32*1024,hs=2*1024*1024,rf=hs/2,Jl=class extends Fv{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 Hv{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,Vm):o.channelExtData(u,Ja(e,p,p+g),Vm),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 Mv{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",Km).on("prefinish",Km),this.on("end",Gm).on("close",Gm)}_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 Km(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}c(Km,"onFinish");function Gm(){this.readable=!1}c(Gm,"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");Zm.exports={Channel:tf,MAX_WINDOW:hs,PACKET_SIZE:jv,windowAdjust:nf,WINDOW_THRESHOLD:rf}});var cf=le((vF,Jm)=>{"use strict";var{SFTP:Wv}=ps(),gs=2**32-1;function Ym(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(Ym,"onChannelOpenFailure");function Xm(t,e,r,n,i){if(typeof r=="function"){Ym(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!==Wv&&(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(Xm,"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];Xm(i,s,a._channel||a,e,!0)}}},sf=(()=>{let t=Object.prototype.toString;return e=>t.call(e)==="[object RegExp]"})();function qv(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(qv,"generateAlgorithmList");Jm.exports={ChannelManager:af,generateAlgorithmList:qv,onChannelOpenFailure:Ym,onCHANNEL_CLOSE:Xm,isWritable:c(t=>t&&t.writable&&t._readableState&&t._readableState.ended===!1,"isWritable")}});var pf=le((wF,b_)=>{"use strict";var{createHash:Qv,getHashes:Vv,randomFillSync:Kv}=require("crypto"),{Socket:Gv}=require("net"),{lookup:Zv}=require("dns"),Yv=require("events"),Xv=Vv(),{COMPAT:y_,CHANNEL_EXTENDED_DATATYPE:{STDERR:Jv},CHANNEL_OPEN_FAILURE:ms,DEFAULT_CIPHER:e_,DEFAULT_COMPRESSION:t_,DEFAULT_KEX:r_,DEFAULT_MAC:n_,DEFAULT_SERVER_HOST_KEY:i_,DISCONNECT_REASON:o_,DISCONNECT_REASON_BY_VALUE:eS,SUPPORTED_CIPHER:tS,SUPPORTED_COMPRESSION:rS,SUPPORTED_KEX:nS,SUPPORTED_MAC:iS,SUPPORTED_SERVER_HOST_KEY:oS}=An(),{init:sS}=Mn(),aS=Hl(),{parseKey:rc}=jn(),{SFTP:cS}=ps(),{bufferCopy:s_,makeBufferParser:E_,makeError:uS,readUInt32BE:lS,sigSSHToASN1:fS,writeUInt32BE:uf}=Qr(),{AgentContext:a_,createAgent:c_,isAgent:u_}=Pl(),{Channel:A_,MAX_WINDOW:nc,PACKET_SIZE:ic,windowAdjust:l_,WINDOW_THRESHOLD:f_}=of(),{ChannelManager:dS,generateAlgorithmList:_s,isWritable:nr,onChannelOpenFailure:pS,onCHANNEL_CLOSE:hS}=cf(),ec=E_(),tc=E_(),ys=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,ff=c(t=>{},"noop"),df=class extends Yv{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&&nr(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,r_,nS),r.kex!==r_&&(n=!1),r.serverHostKey=_s(e.algorithms.serverHostKey,i_,oS),r.serverHostKey!==i_&&(n=!1),r.cs.cipher=_s(e.algorithms.cipher,e_,tS),r.cs.cipher!==e_&&(n=!1),r.cs.mac=_s(e.algorithms.hmac,n_,iS),r.cs.mac!==n_&&(n=!1),r.cs.compress=_s(e.algorithms.compress,t_,rS),r.cs.compress!==t_&&(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=c_(e.agent):u_(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 dS(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 k=e.hostVerifier,W;Xv.indexOf(e.hostHash)!==-1&&(W=e.hostHash),u=c((q,J)=>{W&&(q=Qv(W).update(q).digest("hex"));let ue=k(q,J);ue!==void 0&&J(ue)},"hostVerifier")}let l=this._sock=e.sock||new Gv,d=!1,p=!1;this._protocol&&this._protocol.cleanup();let g=o?(k,W,q)=>{o(`Debug output from server: ${JSON.stringify(q)}`)}:void 0,h,_=this._protocol=new aS({ident:this.config.ident,offer:n?void 0:r,onWrite:c(k=>{nr(l)&&l.write(k)},"onWrite"),onError:c(k=>{k.level==="handshake"&&clearTimeout(this._readyTimeout),_._destruct||l.removeAllListeners("data"),this.emit("error",k);try{l.end()}catch{}},"onError"),onHeader:c(k=>{p=!0,this._remoteVer=k.versions.software,k.greeting&&this.emit("greeting",k.greeting)},"onHeader"),onHandshakeComplete:c(k=>{this.emit("handshake",k),d||(d=!0,_.service("ssh-userauth"))},"onHandshakeComplete"),debug:o,hostVerifier:u,messageHandlers:{DEBUG:g,DISCONNECT:c((k,W,q)=>{if(W!==o_.BY_APPLICATION){q||(q=eS[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((k,W)=>{W==="ssh-userauth"&&B()},"SERVICE_ACCEPT"),EXT_INFO:c((k,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((k,W)=>{this.emit("banner",W)},"USERAUTH_BANNER"),USERAUTH_SUCCESS:c(k=>{$(),clearTimeout(this._readyTimeout),this.emit("ready")},"USERAUTH_SUCCESS"),USERAUTH_FAILURE:c((k,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,xt)=>{let kt=P.key.sign(he,me);if(kt instanceof Error)return kt.message=`Error while signing with key: ${kt.message}`,kt.level="client-authentication",this.emit("error",kt),B();xt(kt)});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`),C=q,M=W,B()},"USERAUTH_FAILURE"),USERAUTH_PASSWD_CHANGEREQ:c((k,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(k=>{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,(xt,kt)=>{if(xt)xt.level="agent",this.emit("error",xt);else return me(kt);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((k,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((k,W)=>{s.length&&s.shift()(!1,W)},"REQUEST_SUCCESS"),REQUEST_FAILURE:c(k=>{s.length&&s.shift()(!0)},"REQUEST_FAILURE"),GLOBAL_REQUEST:c((k,W,q,J)=>{W==="hostkeys-00@openssh.com"?(ES(this,J,(ue,me)=>{ue||this.emit("hostkeys",me)}),q&&_.requestSuccess()):q&&_.requestFailure()},"GLOBAL_REQUEST"),CHANNEL_OPEN:c((k,W)=>{_S(this,W)},"CHANNEL_OPEN"),CHANNEL_OPEN_CONFIRMATION:c((k,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 cS(this,me,{debug:o}):new A_(this,me);this._chanMgr.update(W.recipient,he),q(void 0,he)},"CHANNEL_OPEN_CONFIRMATION"),CHANNEL_OPEN_FAILURE:c((k,W,q,J)=>{let ue=this._chanMgr.get(W);if(typeof ue!="function")return;pS(this,W,{reason:q,description:J},ue)},"CHANNEL_OPEN_FAILURE"),CHANNEL_DATA:c((k,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<=f_&&l_(J)}},"CHANNEL_DATA"),CHANNEL_EXTENDED_DATA:c((k,W,q,J)=>{if(J!==Jv)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<=f_&&l_(ue)}},"CHANNEL_EXTENDED_DATA"),CHANNEL_WINDOW_ADJUST:c((k,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((k,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((k,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((k,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&&k.channelFailure(me.outgoing.id)}},"CHANNEL_REQUEST"),CHANNEL_EOF:c((k,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((k,W)=>{hS(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 k=new Error("Keepalive timeout");k.level="client-timeout",this.emit("error",k),l.destroy()}return}nr(l)?(s.push($),_.ping()):clearInterval(w)},"sendKA");function $(){A>0&&(I=0,clearInterval(w),nr(l)&&(w=setInterval(H,A)))}c($,"resetKA"),this._resetKA=$;let X=(()=>{let k=!1;return()=>{if(!k&&(k=!0,Y&&!p)){let W=uS("Connection lost before handshake","protocol",!0);this.emit("error",W)}}})(),Z=(()=>{let k=!1;return()=>{k||(k=!0,Y=!0,o&&o("Socket connected"),this.emit("connect"),sS.then(()=>{_.start(),l.on("data",W=>{try{_.parse(W,0,W.length)}catch(q){this.emit("error",q);try{nr(l)&&l.end()}catch{}}}),l.stderr&&typeof l.stderr.resume=="function"&&l.stderr.resume(),l.resume()}).catch(W=>{this.emit("error",W);try{nr(l)&&l.end()}catch{}}))}})(),Y=!1;l.on("connect",Z).on("timeout",()=>{this.emit("timeout")}).on("error",k=>{o&&o(`Socket error: ${k.message}`),clearTimeout(this._readyTimeout),k.level="client-socket",this.emit("error",k)}).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 k=s;s=this._callbacks=[];let W=new Error("No response from server");for(let q=0;q<k.length;++q)k[q](W);this._chanMgr.cleanup(W)});let P,C=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=__(i):typeof i!="function"&&(i=__(L));let T=!1,F=c(k=>{if(!T){if(T=!0,k===!1){let W=new Error("All configured authentication methods failed");W.level="client-authentication",this.emit("error",W),this.end();return}if(typeof k=="string"){let W=k;if(L.indexOf(W)===-1)return j(`Authentication method not allowed: ${W}`);let q=this.config.username;switch(W){case"password":k={type:W,username:q,password:this.config.password};break;case"publickey":k={type:W,username:q,key:a};break;case"hostbased":k={type:W,username:q,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":k={type:W,username:q,agentCtx:new a_(this._agent)};break;case"keyboard-interactive":k={type:W,username:q,prompt:c((...J)=>this.emit("keyboard-interactive",...J),"prompt")};break;case"none":k={type:W,username:q};break;default:return j(`Skipping unsupported authentication method: ${k}`)}}else{if(typeof k!="object"||k===null)return j(`Skipping invalid authentication attempt: ${k}`);{let W=k.username;if(typeof W!="string")return j(`Skipping invalid authentication attempt: ${k}`);let q=k.type;switch(q){case"password":{let{password:J}=k;if(typeof J!="string"&&!Buffer.isBuffer(J))return j("Skipping invalid password auth attempt");k={type:q,username:W,password:J};break}case"publickey":{let J=rc(k.key,k.passphrase);if(J instanceof Error)return j("Skipping invalid key auth attempt");if(!J.isPrivateKey())return j("Skipping non-private key");k={type:q,username:W,key:J};break}case"hostbased":{let{localHostname:J,localUsername:ue}=k,me=rc(k.key,k.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");k={type:q,username:W,key:me,localHostname:J,localUsername:ue};break}case"agent":{let J=k.agent;if(typeof J=="string"&&J.length)J=c_(J);else if(!u_(J))return j(`Skipping invalid agent: ${k.agent}`);k={type:q,username:W,agentCtx:new a_(J)};break}case"keyboard-interactive":{let{prompt:J}=k;if(typeof J!="function")return j("Skipping invalid keyboard-interactive auth attempt");k={type:q,username:W,prompt:J};break}case"none":k={type:q,username:W};break;default:return j(`Skipping unsupported authentication method: ${k}`)}}}P=k;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(k){o&&o(k),process.nextTick(B)}c(j,"skipAuth");function B(){T=!1;let k=i(M,C,F);T||k===void 0||F(k)}c(B,"tryNextAuth");let G=c(()=>{if(P.type==="agent"){let k=P.agentCtx.nextKey();if(k===!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,k,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,k,q)}}},"tryNextAgentKey"),ee=c(()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let k=new Error("Timed out while waiting for handshake");k.level="client-timeout",this.emit("error",k),l.destroy()},this.config.readyTimeout))},"startTimeout");if(e.sock)ee(),typeof l.connecting=="boolean"&&l.connecting||Z();else{let k=this.config.host,W=this.config.forceIPv4,q=this.config.forceIPv6;o&&o(`Client: Trying ${k} on port ${this.config.port} ...`);let J=c(()=>{ee(),l.connect({host:k,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():Zv(k,W?4:6,(ue,me,he)=>{if(ue){let xt=W?"IPv4":"IPv6",kt=new Error(`Error while looking up ${xt} address for '${k}': ${ue}`);clearTimeout(this._readyTimeout),kt.level="client-dns",this.emit("error",kt),this.emit("close");return}k=me,J()})}return this}end(){return this._sock&&nr(this._sock)&&(this._protocol.disconnect(o_.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&nr(this._sock)&&this._sock.destroy(),this}exec(e,r,n){if(!this._sock||!nr(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(()=>h_(s,u)),typeof r=="object"&&r!==null&&(typeof r.env=="object"&&r.env!==null&&g_(s,r.env),(typeof r.pty=="object"&&r.pty!==null||r.pty===!0)&&a.push(()=>p_(s,r.pty,u)),(typeof r.x11=="object"&&r.x11!==null||r.x11==="number"||r.x11===!0)&&a.push(()=>d_(s,r.x11,u))),a.push(()=>mS(s,e,r,n)),a.shift()()}),this}shell(e,r,n){if(!this._sock||!nr(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(()=>h_(o,a)),e!==!1&&s.push(()=>p_(o,e,a)),typeof r=="object"&&r!==null&&(typeof r.env=="object"&&r.env!==null&&g_(o,r.env),(typeof r.x11=="object"&&r.x11!==null||r.x11==="number"||r.x11===!0)&&s.push(()=>d_(o,r.x11,a))),s.push(()=>gS(o,n)),s.shift()()}),this}subsys(e,r){if(!this._sock||!nr(this._sock))throw new Error("Not connected");return oo(this,"session",(n,i)=>{if(n){r(n);return}m_(i,e,(o,s)=>{if(o){r(o);return}r(void 0,s)})}),this}forwardIn(e,r,n){if(!this._sock||!nr(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=lS(s,0),this._protocol._compatFlags&y_.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||!nr(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||!nr(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||!nr(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||!nr(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||!nr(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||!nr(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||!nr(this._sock))throw new Error("Not connected");return oo(this,"sftp",(r,n)=>{if(r){e(r);return}m_(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 d_(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=yS());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(d_,"reqX11");function p_(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(p_,"reqPty");function h_(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(h_,"reqAgentFwd");function gS(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(gS,"reqShell");function mS(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(mS,"reqExec");function g_(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(g_,"reqEnv");function m_(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(m_,"reqSubsystem");function _S(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 A_(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(_S,"onCHANNEL_OPEN");var yS=(()=>{let t=Buffer.allocUnsafe(16);return()=>(Kv(t,0,16),t.hexSlice(0,16))})();function __(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(__,"makeSimpleAuthHandler");function ES(t,e,r){if(!t._sock||!nr(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),s_(_,A,0,_.length,b+=4),uf(A,l.length,b+=_.length),s_(l,A,0,l.length,b+=4),(g=fS(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(ES,"hostKeysProve");function lf(t,e,r){switch(e.type){case"ssh-rsa":if(t._protocol._compatFlags&y_.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");b_.exports=df});var I_=le(x_=>{"use strict";var{Agent:gf}=require("http"),{Agent:AS}=require("https"),{connect:bS}=require("tls"),hf;for(let t of[gf,AS]){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,xS(g,t,n))})}).on("error",i).on("close",()=>{d||i(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}x_[t===gf?"SSHTTPAgent":"SSHTTPSAgent"]=e}function Es(){}c(Es,"noop");function xS(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=bS(r),i=(()=>{let o=!1;return()=>{o||(o=!0,t.isPaused()&&t.resume())}})();return n.on("end",i).on("close",i),n}c(xS,"decorateStream")});var S_=le((kF,Ef)=>{"use strict";var{Server:IS}=require("net"),bs=require("events"),{listenerCount:_r}=bs,{CHANNEL_OPEN_FAILURE:so,DEFAULT_CIPHER:vS,DEFAULT_COMPRESSION:SS,DEFAULT_KEX:wS,DEFAULT_MAC:PS,DEFAULT_SERVER_HOST_KEY:TS,DISCONNECT_REASON:ao,DISCONNECT_REASON_BY_VALUE:CS,SUPPORTED_CIPHER:kS,SUPPORTED_COMPRESSION:RS,SUPPORTED_KEX:NS,SUPPORTED_MAC:OS,SUPPORTED_SERVER_HOST_KEY:$S}=An(),{init:DS}=Mn(),{KexInit:BS}=Fa(),{parseKey:v_}=jn(),US=Hl(),{SFTP:LS}=ps(),{writeUInt32BE:zS}=Qr(),{Channel:co,MAX_WINDOW:Qn,PACKET_SIZE:Vn,windowAdjust:MS,WINDOW_THRESHOLD:FS}=of(),{ChannelManager:HS,generateAlgorithmList:As,isWritable:oc,onChannelOpenFailure:jS,onCHANNEL_CLOSE:WS}=cf(),qS=10,Kn=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 Kn{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 Kn{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?Kn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},yf=class extends Kn{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 Kn{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:Vn,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,TS,$S);for(let g=0;g<o.length;++g){let h;if(Buffer.isBuffer(o[g])||typeof o[g]=="string"?h=v_(o[g]):h=v_(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,wS,NS).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:i,cs:{cipher:As(s.cipher,vS,kS),mac:As(s.hmac,PS,OS),compress:As(s.compress,SS,RS),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 IS(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 HS(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,C)=>{o(`Debug output from client: ${JSON.stringify(C)}`)}: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 US({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,C)=>{if(P!==ao.BY_APPLICATION){C||(C=CS[P],C===void 0&&(C=`Unexpected disconnection reason: ${P}`));let M=new Error(C);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 C=-1,M,L=!1,T,F=c(()=>{L||(L=!0,M===void 0&&(C===-1?M=so.RESOURCE_SHORTAGE:M=so.CONNECT_FAILED),C!==-1&&this._chanMgr.remove(C),$.channelOpenFail(P.sender,M,""))},"reject"),j=c(()=>(C=this._chanMgr.add(),C===-1&&(M=so.RESOURCE_SHORTAGE,o&&o("Automatic rejection of incoming channel open: no channels available")),C!==-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,C);return this._chanMgr.update(C,G),$.channelOpenConfirm(P.sender,C,Qn,Vn),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:C,window:Qn,packetSize:Vn,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(C,ee),$.channelOpenConfirm(P.sender,C,Qn,Vn),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:C,window:Qn,packetSize:Vn,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(C,ee),$.channelOpenConfirm(P.sender,C,Qn,Vn),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 C=this._chanMgr.get(P.recipient);if(typeof C!="function")return;let M={type:C.type,incoming:{id:P.recipient,window:Qn,packetSize:Vn,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),C(void 0,L)},"CHANNEL_OPEN_CONFIRMATION"),CHANNEL_OPEN_FAILURE:c((Y,P,C,M)=>{let L=this._chanMgr.get(P);if(typeof L!="function")return;jS(this,P,{reason:C,description:M},L)},"CHANNEL_OPEN_FAILURE"),CHANNEL_DATA:c((Y,P,C)=>{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-=C.length,M.push(C)===!1){M._waitChanDrain=!0;return}M.incoming.window<=FS&&MS(M)}},"CHANNEL_DATA"),CHANNEL_EXTENDED_DATA:c((Y,P,C,M)=>{},"CHANNEL_EXTENDED_DATA"),CHANNEL_WINDOW_ADJUST:c((Y,P,C)=>{let M=this._chanMgr.get(P);typeof M!="object"||M===null||M.constructor===an&&(M=M._channel,!M)||(M.outgoing.window+=C,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 C=this._chanMgr.get(P);typeof C!="object"||C===null||C.constructor===an&&(C=C._channel,!C)||C._callbacks.length&&C._callbacks.shift()(!1)},"CHANNEL_SUCCESS"),CHANNEL_FAILURE:c((Y,P)=>{let C=this._chanMgr.get(P);typeof C!="object"||C===null||C.constructor===an&&(C=C._channel,!C)||C._callbacks.length&&C._callbacks.shift()(!0)},"CHANNEL_FAILURE"),CHANNEL_REQUEST:c((Y,P,C,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&&(C!=="shell"&&C!=="exec"&&C!=="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(C){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=C,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=C,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 LS(this,T._chanInfo,{server:!0,debug:o}):(ee=new co(this,T._chanInfo,{server:!0}),ee.subtype=T.subtype=`${C}:${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: ${C}`),B&&B()},"CHANNEL_REQUEST"),CHANNEL_EOF:c((Y,P)=>{let C=this._chanMgr.get(P);typeof C!="object"||C===null||C.constructor===an&&(C._ending||(C._ending=!0,C.emit("eof"),C.emit("end")),C=C._channel,!C)||C.incoming.state==="open"&&(C.incoming.state="eof",C.readable&&C.push(null))},"CHANNEL_EOF"),CHANNEL_CLOSE:c((Y,P)=>{let C=this._chanMgr.get(P);typeof C!="object"||C===null||C.constructor===an&&(C._ending=!0,C.emit("close"),C=C._channel,!C)||WS(this,P,C)},"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,C,M,L)=>{if(u===0||this.authenticated||p&&(p.username!==P||p.service!==C)||M!=="password"&&M!=="publickey"&&M!=="hostbased"&&M!=="keyboard-interactive"&&M!=="none"||d.length===qS){$.disconnect(ao.PROTOCOL_ERROR),e.end();return}else if(C!=="ssh-connection"){$.disconnect(ao.SERVICE_NOT_AVAILABLE),e.end();return}let T;switch(M){case"keyboard-interactive":T=new sc($,P,C,M,L,X);break;case"publickey":T=new _f($,P,C,M,L,X);break;case"hostbased":T=new yf($,P,C,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,C,M,L,X);break;case"none":T=new Kn($,P,C,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,C,M)=>{let L={type:null,buf:null};function T(F,j){L.type=F,L.buf=j,Z()}if(c(T,"setReply"),C&&_.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(C){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),zS(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 C&&T("FAILURE")},"GLOBAL_REQUEST")}});e.pause(),DS.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,C,M)=>{p===Y&&!this.authenticated&&(P?(p=void 0,this.authenticated=!0,$.authSuccess(),d=[],this.emit("ready")):($.authFailure(C,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=Vn;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 k_=le((NF,C_)=>{"use strict";var{createCipheriv:VS,generateKeyPair:KS,generateKeyPairSync:GS,getCurves:ZS,randomBytes:w_}=require("crypto"),{Ber:Nt}=Ko(),YS=zu().pbkdf,{CIPHER_INFO:XS}=Mn(),JS=16,ew=16,tw=ZS(),rw=new Map(Object.entries(XS));function P_(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(!tw.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(P_,"makeArgs");function nw(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(nw,"parseDERs");function T_(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=rw.get(n.cipher);if(u===void 0)throw new Error("Invalid cipher name");if(i==="new"){let l=ew;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=w_(JS);if(YS(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=
|
|
21
|
-
`);
|
|
22
|
-
`),a+=
|
|
23
|
-
`,{private:a,public:u}}default:throw new Error("Invalid output key format")}}c(T_,"convertKeys");function iw(){}c(iw,"noop");C_.exports={generateKeyPair:c((t,e,r)=>{typeof e=="function"&&(r=e,e=void 0),typeof r!="function"&&(r=iw);let n=P_(t,e);KS(...n,(i,o,s)=>{if(i)return r(i);let a;try{a=T_(n[0],o,s,e)}catch(u){return r(u)}r(null,a)})},"generateKeyPair"),generateKeyPairSync:c((t,e)=>{let r=P_(t,e),{publicKey:n,privateKey:i}=GS(...r);return T_(r[0],n,i,e)},"generateKeyPairSync")}});var N_=le(($F,R_)=>{"use strict";var{AgentProtocol:ow,BaseAgent:sw,createAgent:aw,CygwinAgent:cw,OpenSSHAgent:uw,PageantAgent:lw}=Pl(),{SSHTTPAgent:fw,SSHTTPSAgent:dw}=I_(),{parseKey:pw}=jn(),{flagsToString:hw,OPEN_MODE:gw,STATUS_CODE:mw,stringToFlags:_w}=ps();R_.exports={AgentProtocol:ow,BaseAgent:sw,createAgent:aw,Client:pf(),CygwinAgent:cw,HTTPAgent:fw,HTTPSAgent:dw,OpenSSHAgent:uw,PageantAgent:lw,Server:S_(),utils:{parseKey:pw,...k_(),sftp:{flagsToString:hw,OPEN_MODE:gw,STATUS_CODE:mw,stringToFlags:_w}}}});var Af=le((DF,O_)=>{O_.exports=require("stream")});var z_=le((BF,L_)=>{"use strict";function $_(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($_,"ownKeys");function D_(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?$_(Object(r),!0).forEach(function(n){yw(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$_(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}c(D_,"_objectSpread");function yw(t,e,r){return e=U_(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(yw,"_defineProperty");function Ew(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}c(Ew,"_classCallCheck");function B_(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,U_(n.key),n)}}c(B_,"_defineProperties");function Aw(t,e,r){return e&&B_(t.prototype,e),r&&B_(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}c(Aw,"_createClass");function U_(t){var e=bw(t,"string");return typeof e=="symbol"?e:String(e)}c(U_,"_toPropertyKey");function bw(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(bw,"_toPrimitive");var xw=require("buffer"),uc=xw.Buffer,Iw=require("util"),bf=Iw.inspect,vw=bf&&bf.custom||"inspect";function Sw(t,e,r){uc.prototype.copy.call(t,e,r)}c(Sw,"copyBuffer");L_.exports=(function(){function t(){Ew(this,t),this.head=null,this.tail=null,this.length=0}return c(t,"BufferList"),Aw(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;)Sw(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:vw,value:c(function(r,n){return bf(this,D_(D_({},n),{},{depth:0,customInspect:!1}))},"value")}]),t})()});var If=le((LF,F_)=>{"use strict";function ww(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(M_,r,o)):process.nextTick(M_,r,o):e?(process.nextTick(lc,r),e(o)):process.nextTick(lc,r)}),this)}c(ww,"destroy");function M_(t,e){xf(t,e),lc(t)}c(M_,"emitErrorAndCloseNT");function lc(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}c(lc,"emitCloseNT");function Pw(){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(Pw,"undestroy");function xf(t,e){t.emit("error",e)}c(xf,"emitErrorNT");function Tw(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}c(Tw,"errorOrDestroy");F_.exports={destroy:ww,undestroy:Pw,errorOrDestroy:Tw}});var Gn=le((MF,W_)=>{"use strict";var j_={};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,j_[t]=i}c(Hr,"createErrorType");function H_(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(H_,"oneOf");function Cw(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}c(Cw,"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 Rw(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}c(Rw,"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"&&Cw(e,"not ")?(n="must not be",e=e.replace(/^not /,"")):n="must be";let i;if(kw(t," argument"))i=`The ${t} ${n} ${H_(e,"type")}`;else{let o=Rw(t,".")?"property":"argument";i=`The "${t}" ${o} ${n} ${H_(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");W_.exports.codes=j_});var vf=le((HF,q_)=>{"use strict";var Nw=Gn().codes.ERR_INVALID_OPT_VALUE;function Ow(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}c(Ow,"highWaterMarkFrom");function $w(t,e,r,n){var i=Ow(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new Nw(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}c($w,"getHighWaterMark");q_.exports={getHighWaterMark:$w}});var Q_=le((WF,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((QF,Pf)=>{try{if(wf=require("util"),typeof wf.inherits!="function")throw"";Pf.exports=wf.inherits}catch{Pf.exports=Q_()}var wf});var K_=le((VF,V_)=>{V_.exports=require("util").deprecate});var kf=le((KF,ey)=>{"use strict";ey.exports=Gt;function Z_(t){var e=this;this.next=null,this.entry=null,this.finish=function(){aP(e,t)}}c(Z_,"CorkedRequest");var uo;Gt.WritableState=Is;var Dw={deprecate:K_()},Y_=Af(),dc=require("buffer").Buffer,Bw=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function Uw(t){return dc.from(t)}c(Uw,"_uint8ArrayToBuffer");function Lw(t){return dc.isBuffer(t)||t instanceof Bw}c(Lw,"_isUint8Array");var Cf=If(),zw=vf(),Mw=zw.getHighWaterMark,Zn=Gn().codes,Fw=Zn.ERR_INVALID_ARG_TYPE,Hw=Zn.ERR_METHOD_NOT_IMPLEMENTED,jw=Zn.ERR_MULTIPLE_CALLBACK,Ww=Zn.ERR_STREAM_CANNOT_PIPE,qw=Zn.ERR_STREAM_DESTROYED,Qw=Zn.ERR_STREAM_NULL_VALUES,Vw=Zn.ERR_STREAM_WRITE_AFTER_END,Kw=Zn.ERR_UNKNOWN_ENCODING,lo=Cf.errorOrDestroy;di()(Gt,Y_);function Gw(){}c(Gw,"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=Mw(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){rP(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 Z_(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:Dw.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)),Y_.call(this)}c(Gt,"Writable");Gt.prototype.pipe=function(){lo(this,new Ww)};function Zw(t,e){var r=new Vw;lo(t,r),process.nextTick(e,r)}c(Zw,"writeAfterEnd");function Yw(t,e,r,n){var i;return r===null?i=new Qw:typeof r!="string"&&!e.objectMode&&(i=new Fw("chunk",["string","Buffer"],r)),i?(lo(t,i),process.nextTick(n,i),!1):!0}c(Yw,"validChunk");Gt.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&Lw(t);return o&&!dc.isBuffer(t)&&(t=Uw(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=Gw),n.ending?Zw(this,r):(o||Yw(this,n,t,r))&&(n.pendingcb++,i=Jw(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&&X_(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 Kw(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 Xw(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=dc.from(e,r)),e}c(Xw,"decodeChunk");Object.defineProperty(Gt.prototype,"writableHighWaterMark",{enumerable:!1,get:c(function(){return this._writableState.highWaterMark},"get")});function Jw(t,e,r,n,i,o){if(!r){var s=Xw(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(Jw,"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 qw("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}c(Tf,"doWrite");function eP(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(eP,"onwriteError");function tP(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}c(tP,"onwriteStateUpdate");function rP(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new jw;if(tP(r),e)eP(t,r,n,e,i);else{var o=J_(r)||t.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&X_(t,r),n?process.nextTick(G_,t,r,o,i):G_(t,r,o,i)}}c(rP,"onwrite");function G_(t,e,r,n){r||nP(t,e),e.pendingcb--,n(),xs(t,e)}c(G_,"afterWrite");function nP(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}c(nP,"onwriteDrain");function X_(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 Z_(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(X_,"clearBuffer");Gt.prototype._write=function(t,e,r){r(new Hw("_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||sP(this,n,r),this};Object.defineProperty(Gt.prototype,"writableLength",{enumerable:!1,get:c(function(){return this._writableState.length},"get")});function J_(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}c(J_,"needFinish");function iP(t,e){t._final(function(r){e.pendingcb--,r&&lo(t,r),e.prefinished=!0,t.emit("prefinish"),xs(t,e)})}c(iP,"callFinal");function oP(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(iP,t,e)):(e.prefinished=!0,t.emit("prefinish")))}c(oP,"prefinish");function xs(t,e){var r=J_(e);if(r&&(oP(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 sP(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(sP,"endWritable");function aP(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(aP,"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=Cf.destroy;Gt.prototype._undestroy=Cf.undestroy;Gt.prototype._destroy=function(t,e){e(t)}});var pi=le((ZF,ry)=>{"use strict";var cP=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};ry.exports=cn;var ty=Of(),Nf=kf();di()(cn,ty);for(Rf=cP(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);ty.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",uP)))}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 uP(){this._writableState.ended||process.nextTick(lP,this)}c(uP,"onend");function lP(t){t.end()}c(lP,"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 oy=le(($f,iy)=>{var gc=require("buffer"),un=gc.Buffer;function ny(t,e){for(var r in t)e[r]=t[r]}c(ny,"copyProps");un.from&&un.alloc&&un.allocUnsafe&&un.allocUnsafeSlow?iy.exports=gc:(ny(gc,$f),$f.Buffer=hi);function hi(t,e,r){return un(t,e,r)}c(hi,"SafeBuffer");hi.prototype=Object.create(un.prototype);ny(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(ay=>{"use strict";var Bf=oy().Buffer,sy=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 fP(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(fP,"_normalizeEncoding");function dP(t){var e=fP(t);if(typeof e!="string"&&(Bf.isEncoding===sy||!sy(t)))throw new Error("Unknown encoding: "+t);return e||t}c(dP,"normalizeEncoding");ay.StringDecoder=vs;function vs(t){this.encoding=dP(t);var e;switch(this.encoding){case"utf16le":this.text=yP,this.end=EP,e=4;break;case"utf8":this.fillLast=gP,e=4;break;case"base64":this.text=AP,this.end=bP,e=3;break;default:this.write=xP,this.end=IP;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=_P;vs.prototype.text=mP;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 pP(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(pP,"utf8CheckIncomplete");function hP(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(hP,"utf8CheckExtraBytes");function gP(t){var e=this.lastTotal-this.lastNeed,r=hP(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(gP,"utf8FillLast");function mP(t,e){var r=pP(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(mP,"utf8Text");function _P(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}c(_P,"utf8End");function yP(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(yP,"utf16Text");function EP(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(EP,"utf16End");function AP(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(AP,"base64Text");function bP(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}c(bP,"base64End");function xP(t){return t.toString(this.encoding)}c(xP,"simpleWrite");function IP(t){return t&&t.length?this.write(t):""}c(IP,"simpleEnd")});var mc=le((t5,ly)=>{"use strict";var cy=Gn().codes.ERR_STREAM_PREMATURE_CLOSE;function vP(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(vP,"once");function SP(){}c(SP,"noop");function wP(t){return t.setHeader&&typeof t.abort=="function"}c(wP,"isRequest");function uy(t,e,r){if(typeof e=="function")return uy(t,null,e);e||(e={}),r=vP(r||SP);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 cy),r.call(t,_);if(i&&!s)return(!t._writableState||!t._writableState.ended)&&(_=new cy),r.call(t,_)},"onclose"),g=c(function(){t.req.on("finish",a)},"onrequest");return wP(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(uy,"eos");ly.exports=uy});var dy=le((n5,fy)=>{"use strict";var _c;function Yn(t,e,r){return e=PP(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(Yn,"_defineProperty");function PP(t){var e=TP(t,"string");return typeof e=="symbol"?e:String(e)}c(PP,"_toPropertyKey");function TP(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(TP,"_toPrimitive");var CP=mc(),Xn=Symbol("lastResolve"),gi=Symbol("lastReject"),Ss=Symbol("error"),yc=Symbol("ended"),mi=Symbol("lastPromise"),Lf=Symbol("handlePromise"),_i=Symbol("stream");function Jn(t,e){return{value:t,done:e}}c(Jn,"createIterResult");function kP(t){var e=t[Xn];if(e!==null){var r=t[_i].read();r!==null&&(t[mi]=null,t[Xn]=null,t[gi]=null,e(Jn(r,!1)))}}c(kP,"readAndResolve");function RP(t){process.nextTick(kP,t)}c(RP,"onReadable");function NP(t,e){return function(r,n){t.then(function(){if(e[yc]){r(Jn(void 0,!0));return}e[Lf](r,n)},n)}}c(NP,"wrapForNext");var OP=Object.getPrototypeOf(function(){}),$P=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(Jn(void 0,!0));if(this[_i].destroyed)return new Promise(function(s,a){process.nextTick(function(){e[Ss]?a(e[Ss]):s(Jn(void 0,!0))})});var n=this[mi],i;if(n)i=new Promise(NP(n,this));else{var o=this[_i].read();if(o!==null)return Promise.resolve(Jn(o,!1));i=new Promise(this[Lf])}return this[mi]=i,i},"next")},Yn(_c,Symbol.asyncIterator,function(){return this}),Yn(_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(Jn(void 0,!0))})})},"_return")),_c),OP),DP=c(function(e){var r,n=Object.create($P,(r={},Yn(r,_i,{value:e,writable:!0}),Yn(r,Xn,{value:null,writable:!0}),Yn(r,gi,{value:null,writable:!0}),Yn(r,Ss,{value:null,writable:!0}),Yn(r,yc,{value:e._readableState.endEmitted,writable:!0}),Yn(r,Lf,{value:c(function(o,s){var a=n[_i].read();a?(n[mi]=null,n[Xn]=null,n[gi]=null,o(Jn(a,!1))):(n[Xn]=o,n[gi]=s)},"value"),writable:!0}),r));return n[mi]=null,CP(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[gi];o!==null&&(n[mi]=null,n[Xn]=null,n[gi]=null,o(i)),n[Ss]=i;return}var s=n[Xn];s!==null&&(n[mi]=null,n[Xn]=null,n[gi]=null,s(Jn(void 0,!0))),n[yc]=!0}),e.on("readable",RP.bind(null,n)),n},"createReadableStreamAsyncIterator");fy.exports=DP});var my=le((o5,gy)=>{"use strict";function py(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(py,"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){py(o,n,i,s,a,"next",u)}c(s,"_next");function a(u){py(o,n,i,s,a,"throw",u)}c(a,"_throw"),s(void 0)})}}c(BP,"_asyncToGenerator");function hy(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(hy,"ownKeys");function UP(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?hy(Object(r),!0).forEach(function(n){LP(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):hy(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}c(UP,"_objectSpread");function LP(t,e,r){return e=zP(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(LP,"_defineProperty");function zP(t){var e=MP(t,"string");return typeof e=="symbol"?e:String(e)}c(zP,"_toPropertyKey");function MP(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(MP,"_toPrimitive");var FP=Gn().codes.ERR_INVALID_ARG_TYPE;function HP(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 FP("iterable",["Iterable"],e);var i=new t(UP({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(HP,"from");gy.exports=HP});var Of=le((c5,wy)=>{"use strict";wy.exports=At;var fo;At.ReadableState=Ay;var a5=require("events").EventEmitter,Ey=c(function(e,r){return e.listeners(r).length},"EElistenerCount"),Ps=Af(),Ec=require("buffer").Buffer,jP=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function WP(t){return Ec.from(t)}c(WP,"_uint8ArrayToBuffer");function qP(t){return Ec.isBuffer(t)||t instanceof jP}c(qP,"_isUint8Array");var zf=require("util"),ct;zf&&zf.debuglog?ct=zf.debuglog("stream"):ct=c(function(){},"debug");var QP=z_(),Qf=If(),VP=vf(),KP=VP.getHighWaterMark,Ac=Gn().codes,GP=Ac.ERR_INVALID_ARG_TYPE,ZP=Ac.ERR_STREAM_PUSH_AFTER_EOF,YP=Ac.ERR_METHOD_NOT_IMPLEMENTED,XP=Ac.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,po,Mf,Ff;di()(At,Ps);var ws=Qf.errorOrDestroy,Hf=["error","close","destroy","pause","resume"];function JP(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(JP,"prependListener");function Ay(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=KP(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(Ay,"ReadableState");function At(t){if(fo=fo||pi(),!(this instanceof At))return new At(t);var e=this instanceof fo;this._readableState=new Ay(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(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=Ec.from(t,e),e=""),n=!0),by(this,t,e,!1,n)};At.prototype.unshift=function(t){return by(this,t,null,!0,!1)};function by(t,e,r,n,i){ct("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,rT(t,o);else{var s;if(i||(s=eT(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=WP(e)),n)o.endEmitted?ws(t,new XP):jf(t,o,e,!0);else if(o.ended)ws(t,new ZP);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(by,"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 eT(t,e){var r;return!qP(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new GP("chunk",["string","Buffer","Uint8Array"],e)),r}c(eT,"chunkInvalid");At.prototype.isPaused=function(){return this._readableState.flowing===!1};At.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 _y=1073741824;function tT(t){return t>=_y?t=_y:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}c(tT,"computeNewHighWaterMark");function yy(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=tT(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}c(yy,"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?Wf(this):bc(this),null;if(t=yy(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=yy(r,e)));var i;return t>0?i=vy(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 rT(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,xy(t)))}}c(rT,"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(xy,t))}c(bc,"emitReadable");function xy(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(xy,"emitReadable_");function qf(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(nT,t,e))}c(qf,"maybeReadMore");function nT(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(nT,"maybeReadMore_");At.prototype._read=function(t){ws(this,new YP("_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: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=iT(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&&Sy(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),Ey(t,"error")===0&&ws(t,b)}c(g,"onerror"),JP(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 iT(t){return c(function(){var r=t._readableState;ct("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&Ey(t,"data")&&(r.flowing=!0,Vf(t))},"pipeOnDrainFunctionResult")}c(iT,"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=Sy(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=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(oT,this)),r};At.prototype.addListener=At.prototype.on;At.prototype.removeListener=function(t,e){var r=Ps.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick(Iy,this),r};At.prototype.removeAllListeners=function(t){var e=Ps.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick(Iy,this),e};function Iy(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(Iy,"updateReadableListening");function oT(t){ct("readable nexttick read 0"),t.read(0)}c(oT,"nReadingNextTick");At.prototype.resume=function(){var t=this._readableState;return t.flowing||(ct("resume"),t.flowing=!t.readableListening,sT(this,t)),t.paused=!1,this};function sT(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(aT,t,e))}c(sT,"resume");function aT(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(aT,"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 Vf(t){var e=t._readableState;for(ct("flow",e.flowing);e.flowing&&t.read()!==null;);}c(Vf,"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<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"&&(At.prototype[Symbol.asyncIterator]=function(){return Mf===void 0&&(Mf=dy()),Mf(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=vy;Object.defineProperty(At.prototype,"readableLength",{enumerable:!1,get:c(function(){return this._readableState.length},"get")});function vy(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(vy,"fromList");function Wf(t){var e=t._readableState;ct("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(cT,e,t))}c(Wf,"endReadable");function cT(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(cT,"endReadableNT");typeof Symbol=="function"&&(At.from=function(t,e){return Ff===void 0&&(Ff=my()),Ff(At,t,e)});function Sy(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}c(Sy,"indexOf")});var Kf=le((l5,Ty)=>{"use strict";Ty.exports=Sn;var xc=Gn().codes,uT=xc.ERR_METHOD_NOT_IMPLEMENTED,lT=xc.ERR_MULTIPLE_CALLBACK,fT=xc.ERR_TRANSFORM_ALREADY_TRANSFORMING,dT=xc.ERR_TRANSFORM_WITH_LENGTH_0,Ic=pi();di()(Sn,Ic);function pT(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new lT);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(pT,"afterTransform");function Sn(t){if(!(this instanceof Sn))return new Sn(t);Ic.call(this,t),this._transformState={afterTransform:pT.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",hT)}c(Sn,"Transform");function hT(){var t=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(e,r){Py(t,e,r)}):Py(this,null,null)}c(hT,"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 uT("_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 Py(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new dT;if(t._transformState.transforming)throw new fT;return t.push(null)}c(Py,"done")});var Ry=le((d5,ky)=>{"use strict";ky.exports=Ts;var Cy=Kf();di()(Ts,Cy);function Ts(t){if(!(this instanceof Ts))return new Ts(t);Cy.call(this,t)}c(Ts,"PassThrough");Ts.prototype._transform=function(t,e,r){r(null,t)}});var By=le((h5,Dy)=>{"use strict";var Gf;function gT(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}c(gT,"once");var $y=Gn().codes,mT=$y.ERR_MISSING_ARGS,_T=$y.ERR_STREAM_DESTROYED;function Ny(t){if(t)throw t}c(Ny,"noop");function yT(t){return t.setHeader&&typeof t.abort=="function"}c(yT,"isRequest");function ET(t,e,r,n){n=gT(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,yT(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new _T("pipe"))}}}c(ET,"destroyer");function Oy(t){t()}c(Oy,"call");function AT(t,e){return t.pipe(e)}c(AT,"pipe");function bT(t){return!t.length||typeof t[t.length-1]!="function"?Ny:t.pop()}c(bT,"popCallback");function xT(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=bT(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new mT("streams");var i,o=e.map(function(s,a){var u=a<e.length-1,l=a>0;return ET(s,u,l,function(d){i||(i=d),d&&o.forEach(Oy),!u&&(o.forEach(Oy),n(i))})});return e.reduce(AT)}c(xT,"pipeline");Dy.exports=xT});var Uy=le((jr,ks)=>{var Cs=require("stream");process.env.READABLE_STREAM==="disable"&&Cs?(ks.exports=Cs.Readable,Object.assign(ks.exports,Cs),ks.exports.Stream=Cs):(jr=ks.exports=Of(),jr.Stream=Cs||jr,jr.Readable=jr,jr.Writable=kf(),jr.Duplex=pi(),jr.Transform=Kf(),jr.PassThrough=Ry(),jr.finished=mc(),jr.pipeline=By())});var zy=le((m5,Ly)=>{var IT=Object.prototype.toString,Zf=typeof Buffer<"u"&&typeof Buffer.alloc=="function"&&typeof Buffer.allocUnsafe=="function"&&typeof Buffer.from=="function";function vT(t){return IT.call(t).slice(8,-1)==="ArrayBuffer"}c(vT,"isArrayBuffer");function ST(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(ST,"fromArrayBuffer");function wT(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(wT,"fromString");function PT(t,e,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return vT(t)?ST(t,e,r):typeof t=="string"?wT(t,e):Zf?Buffer.from(t):new Buffer(t)}c(PT,"bufferFrom");Ly.exports=PT});var qy=le(Be=>{var My=void 0,TT=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")}})(),CT=Math.LN2,kT=Math.abs,vc=Math.floor,RT=Math.log,NT=Math.min,Zr=Math.pow,OT=Math.round;function Yf(t){if(Fy&&ho){var e=Fy(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 Fy=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 $T(t){if(!ho)return;if(t.length>TT)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($T,"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 DT(t){return[t&255]}c(DT,"packI8");function BT(t){return Xf(t[0],8)}c(BT,"unpackI8");function UT(t){return[t&255]}c(UT,"packU8");function Hy(t){return Jf(t[0],8)}c(Hy,"unpackU8");function LT(t){return t=OT(Number(t)),[t<0?0:t>255?255:t&255]}c(LT,"packU8Clamped");function zT(t){return[t>>8&255,t&255]}c(zT,"packI16");function MT(t){return Xf(t[0]<<8|t[1],16)}c(MT,"unpackI16");function FT(t){return[t>>8&255,t&255]}c(FT,"packU16");function HT(t){return Jf(t[0]<<8|t[1],16)}c(HT,"unpackU16");function jT(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}c(jT,"packI32");function WT(t){return Xf(t[0]<<24|t[1]<<16|t[2]<<8|t[3],32)}c(WT,"unpackI32");function qT(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}c(qT,"packU32");function QT(t){return Jf(t[0]<<24|t[1]<<16|t[2]<<8|t[3],32)}c(QT,"unpackU32");function jy(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=NT(vc(RT(t)/CT),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(jy,"packIEEE754");function Wy(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(Wy,"unpackIEEE754");function VT(t){return Wy(t,11,52)}c(VT,"unpackF64");function KT(t){return jy(t,11,52)}c(KT,"packF64");function GT(t){return Wy(t,8,23)}c(GT,"unpackF32");function ZT(t){return jy(t,8,23)}c(ZT,"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),$T(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 My;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 My;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,C,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(C=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=C;Z<M;Z+=1,P+=1)this.buffer._bytes[P]=L[Z]}else for(Z=0,Y=w.byteOffset,P=C;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,DT,BT),i=r(1,UT,Hy),o=r(1,LT,Hy),s=r(2,zT,MT),a=r(2,FT,HT),u=r(4,jT,WT),l=r(4,qT,QT),d=r(4,ZT,GT),p=r(8,KT,VT);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 Gy=le((A5,Ky)=>{var Qy=Uy().Writable,YT=di(),Rs=zy();typeof Uint8Array>"u"?Sc=qy().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,Qy.call(this,{objectMode:!0}),this.encoding=r,this.shouldInferEncoding=n,e&&this.on("finish",function(){e(this.getBody())}),this.body=[]}c(yi,"ConcatStream");Ky.exports=yi;YT(yi,Qy);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"?t1(this.body):this.encoding==="string"?JT(this.body):this.encoding==="buffer"?e1(this.body):this.encoding==="uint8array"?r1(this.body):this.body)};function XT(t){return/Array\]$/.test(Object.prototype.toString.call(t))}c(XT,"isArrayish");function Vy(t){return typeof t=="string"||XT(t)||t&&typeof t.subarray=="function"}c(Vy,"isBufferish");function JT(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):Vy(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(JT,"stringConcat");function e1(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];Buffer.isBuffer(n)?e.push(n):Vy(n)?e.push(Rs(n)):e.push(Rs(String(n)))}return Buffer.concat(e)}c(e1,"bufferConcat");function t1(t){for(var e=[],r=0;r<t.length;r++)e.push.apply(e,t[r]);return e}c(t1,"arrayConcat");function r1(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(r1,"u8Concat")});var Xy=le((x5,Yy)=>{"use strict";function Zy(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}c(Zy,"assign");function n1(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 Zy(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=c(function(){},"ErrClass");return i.prototype=Object.create(Object.getPrototypeOf(t)),Zy(new i,r)}}c(n1,"createError");Yy.exports=n1});var eE=le((v5,Jy)=>{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");Jy.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 tE=le(Ei=>{var i1=eE();Ei.operation=function(t){var e=Ei.timeouts(t);return new i1(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 nE=le((T5,rE)=>{rE.exports=tE()});var sE=le((C5,oE)=>{"use strict";var o1=Xy(),s1=nE(),a1=Object.prototype.hasOwnProperty;function iE(t){return t&&t.code==="EPROMISERETRY"&&a1.call(t,"retried")}c(iE,"isRetryError");function c1(t,e){var r,n;return typeof t=="object"&&typeof e=="function"&&(r=e,e=t,t=r),n=s1.operation(e),new Promise(function(i,o){n.attempt(function(s){Promise.resolve().then(function(){return t(function(a){throw iE(a)&&(a=a.retried),o1(new Error("Retrying"),"EPROMISERETRY",{retried:a})},s)}).then(i,function(a){iE(a)&&(a=a.retried,n.retry(a||new Error))||o(a)})})})}c(c1,"promiseRetry");oE.exports=c1});var ed=le((R5,aE)=>{var u1={generic:"ERR_GENERIC_CLIENT",connect:"ERR_NOT_CONNECTED",badPath:"ERR_BAD_PATH",permission:"EACCES",notexist:"ENOENT",notdir:"ENOTDIR",badAuth:"ERR_BAD_AUTH"},l1={writeFile:1,readFile:2,writeDir:3,readDir:4,readObj:5,writeObj:6};aE.exports={errorCode:u1,targetType:l1}});var pE=le((N5,dE)=>{var Ns=require("fs"),f1=require("path"),{errorCode:cE}=ed();function uE(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(uE,"errorListener");function d1(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(d1,"globalListener");function lE(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(lE,"endListener");function fE(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(fE,"closeListener");function p1(t,e,r){let n={end:lE(t,e,r),close:fE(t,e,r),error:uE(t,e,r)};return t.on("end",n.end),t.on("close",n.close),t.on("error",n.error),t._resetEventFlags(),n}c(p1,"addTempListeners");function h1(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(h1,"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=cE.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 g1(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=f1.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(g1,"haveLocalCreate");async function m1(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(m1,"normalizeRemotePath");function _1(t,e,r){if(!t.sftp){let n=new Error(`${e}: No SFTP connection available`);if(n.code=cE.connect,r)return r(n),!1;throw n}return!0}c(_1,"haveConnection");function y1(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(y1,"sleep");dE.exports={globalListener:d1,errorListener:uE,endListener:lE,closeListener:fE,addTempListeners:p1,removeTempListeners:h1,haveLocalAccess:rd,haveLocalCreate:g1,normalizeRemotePath:m1,localExists:td,haveConnection:_1,sleep:y1}});var _E=le(($5,mE)=>{"use strict";var{Client:E1}=N_(),wc=require("fs"),A1=Gy(),b1=sE(),{join:Os,parse:x1}=require("path"),{globalListener:nd,addTempListeners:zt,removeTempListeners:Mt,haveConnection:fr,normalizeRemotePath:$s,localExists:hE,haveLocalAccess:gE,haveLocalCreate:id}=pE(),{errorCode:$t}=ed(),od=class{static{c(this,"SftpClient")}constructor(e){this.version="9.0.4",this.client=new E1,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 b1(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=A1(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=gE(e);if(i.status){if(i.status&&hE(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=gE(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=x1(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=hE(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})}};mE.exports=od});var PE=le((ad,cd)=>{(function(t,e){typeof ad=="object"&&typeof cd<"u"?cd.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self).dayjs=e()})(ad,(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 C},"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 k=T.name;$[k]=T,B=k}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 C(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 C=(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 k=ee[2]-1||0,W=(ee[7]||"0").substring(0,3);return G?new Date(Date.UTC(ee[1],k,ee[3]||1,ee[4]||0,ee[5]||0,ee[6]||0,W)):new Date(ee[1],k,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),k=c(function(kt,Xt){var yr=P.w(B.$u?Date.UTC(B.$y,Xt,kt):new Date(B.$y,Xt,kt),B);return G?yr:yr.endOf(a)},"l"),W=c(function(kt,Xt){return P.w(B.toDate()[kt].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?k(1,0):k(31,11);case l:return G?k(1,J):k(0,J+1);case u:var he=this.$locale().weekStart||0,xt=(q<he?q+7:q)-he;return k(G?ue-xt:ue+(6-xt),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":""),k=(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[k](W),q.init(),this.$d=q.set(g,Math.min(this.$D,q.daysInMonth())).$d}else k&&this.$d[k](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),k=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 k(1);if(ee===u)return k(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),k=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"),xt=c(function(Xt){return P.s(k%12||12,Xt,"0")},"d"),kt=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(k);case"HH":return P.s(k,2,"0");case"h":return xt(1);case"hh":return xt(2);case"a":return kt(k,W,!0);case"A":return kt(k,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,k=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(k){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=C.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,C,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 M1={};dd(M1,{endClient:()=>Zt,ftpSftp:()=>z1,getClient:()=>Ft,getProtocolBackwardCompatibility:()=>Dt});module.exports=KE(M1);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 gd(t,e){return typeof e=="bigint"?e.toString():e}c(gd,"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 md(t){return t==null}c(md,"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 hd=Symbol("evaluating");function er(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==hd)return n===void 0&&(n=hd,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 _d(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(_d,"isPlainObject");var yd=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 Ed(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}c(Ed,"optionalKeys");var Ad={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 bd(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}c(bd,"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 xd=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,gd,2),Object.defineProperty(t,"toString",{value:c(()=>t.message,"value"),enumerable:!1})},"initializer"),Id=xe("$ZodError",xd),xo=xe("$ZodError",xd,{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??Id)(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 vd=c(t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},"string"),Sd=/^-?\d+n?$/,wd=/^-?\d+$/,Uc=/^-?\d+(?:\.\d+)?$/,Pd=/^(?: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 Td=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 Cd=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]=Ad[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=wd)}),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!md(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=bd(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=()=>{})}),Rd=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 Od={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=Od;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()??vd(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 Ld=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}}),zd=xe("$ZodNumberFormat",(t,e)=>{Cd.init(t,e),Mc.init(t,e)}),Fc=xe("$ZodBoolean",(t,e)=>{Vt.init(t,e),t._zod.pattern=Pd,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}}),Md=xe("$ZodBigInt",(t,e)=>{Vt.init(t,e),t._zod.pattern=Sd,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 Fd=xe("$ZodAny",(t,e)=>{Vt.init(t,e),t._zod.parse=r=>r}),Hd=xe("$ZodUnknown",(t,e)=>{Vt.init(t,e),t._zod.parse=r=>r});var jd=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}}),Wd=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 $d(t,e,r){t.issues.length&&e.issues.push(...wn(r,t.issues)),e.value[r]=t.value}c($d,"handleArrayResult");var qd=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=>$d(l,r,s))):$d(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=Ed(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 Dd(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(Dd,"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=>Dd(u,i,t,o)):Dd(a,i,t,o)}});var Vd=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 Kd=xe("$ZodRecord",(t,e)=>{Vt.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!_d(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 Gd=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=>yd.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}}),Zd=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 Yd=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 Bd(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}c(Bd,"handleOptionalResult");var Xd=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=>Bd(o,r.value)):Bd(i,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}});var Jd=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 ep=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 tp=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=>Ud(o,r,n,t));Ud(i,r,n,t)}});function Ud(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(Ud,"handleRefineResult");var np;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 ip(){return new jc}c(ip,"registry");(np=globalThis).__zod_globalRegistry??(np.__zod_globalRegistry=ip());var Wc=globalThis.__zod_globalRegistry;function op(t,e){return new t({type:"string",...Rt(e)})}c(op,"_string");function sp(t,e){return new t({type:"string",coerce:!0,...Rt(e)})}c(sp,"_coercedString");function ap(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Rt(e)})}c(ap,"_url");function cp(t,e){return new t({type:"number",checks:[],...Rt(e)})}c(cp,"_number");function up(t,e){return new t({type:"number",coerce:!0,checks:[],...Rt(e)})}c(up,"_coercedNumber");function lp(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Rt(e)})}c(lp,"_int");function fp(t,e){return new t({type:"boolean",...Rt(e)})}c(fp,"_boolean");function dp(t,e){return new t({type:"boolean",coerce:!0,...Rt(e)})}c(dp,"_coercedBoolean");function pp(t,e){return new t({type:"bigint",coerce:!0,...Rt(e)})}c(pp,"_coercedBigint");function hp(t){return new t({type:"any"})}c(hp,"_any");function gp(t){return new t({type:"unknown"})}c(gp,"_unknown");function mp(t,e){return new t({type:"void",...Rt(e)})}c(mp,"_void");function _p(t,e){return new t({type:"date",coerce:!0,...Rt(e)})}c(_p,"_coercedDate");function Ks(t,e){return new Td({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 Cn(t,e){return new Rd({check:"string_format",format:"regex",...Rt(e),pattern:t})}c(Cn,"_regex");function yp(t,e,r){let n=Rt(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}c(yp,"_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 op(Zs,t)}c(v,"string");var Ep=xe("ZodMiniStringFormat",(t,e)=>{zc.init(t,e),Zs.init(t,e)});var EA=xe("ZodMiniURL",(t,e)=>{Ld.init(t,e),Ep.init(t,e)});function Ap(t){return ap(EA,t)}c(Ap,"url");var Ys=xe("ZodMiniNumber",(t,e)=>{Mc.init(t,e),tr.init(t,e)});function Ar(t){return cp(Ys,t)}c(Ar,"number");var AA=xe("ZodMiniNumberFormat",(t,e)=>{zd.init(t,e),Ys.init(t,e)});function bp(t){return lp(AA,t)}c(bp,"int");var qc=xe("ZodMiniBoolean",(t,e)=>{Fc.init(t,e),tr.init(t,e)});function yt(t){return fp(qc,t)}c(yt,"boolean");var xp=xe("ZodMiniBigInt",(t,e)=>{Md.init(t,e),tr.init(t,e)});var bA=xe("ZodMiniAny",(t,e)=>{Fd.init(t,e),tr.init(t,e)});function wo(){return hp(bA)}c(wo,"any");var xA=xe("ZodMiniUnknown",(t,e)=>{Hd.init(t,e),tr.init(t,e)});function We(){return gp(xA)}c(We,"unknown");var IA=xe("ZodMiniVoid",(t,e)=>{jd.init(t,e),tr.init(t,e)});function Ip(t){return mp(IA,t)}c(Ip,"_void");var vp=xe("ZodMiniDate",(t,e)=>{Wd.init(t,e),tr.init(t,e)});var vA=xe("ZodMiniArray",(t,e)=>{qd.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)=>{Vd.init(t,e),tr.init(t,e)});function kn(t,e,r){return new PA({type:"union",options:e,discriminator:t,...Rt(r)})}c(kn,"discriminatedUnion");var TA=xe("ZodMiniRecord",(t,e)=>{Kd.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 CA=xe("ZodMiniEnum",(t,e)=>{Gd.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 CA({type:"enum",entries:r,...Rt(e)})}c(ot,"_enum");var kA=xe("ZodMiniLiteral",(t,e)=>{Zd.init(t,e),tr.init(t,e)});function ke(t,e){return new kA({type:"literal",values:Array.isArray(t)?t:[t],...Rt(e)})}c(ke,"literal");var RA=xe("ZodMiniTransform",(t,e)=>{Yd.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)=>{Xd.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)=>{Jd.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)=>{ep.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)=>{tp.init(t,e),tr.init(t,e)});function Xs(t,e){return yp(DA,t??(()=>!0),e)}c(Xs,"custom");var To={};dd(To,{bigint:()=>FA,boolean:()=>MA,date:()=>HA,number:()=>zA,string:()=>LA});function LA(t){return sp(Zs,t)}c(LA,"string");function zA(t){return up(Ys,t)}c(zA,"number");function MA(t){return dp(qc,t)}c(MA,"boolean");function FA(t){return pp(xp,t)}c(FA,"bigint");function HA(t){return _p(vp,t)}c(HA,"date");var Vc=D({retryOnFailure:D({defaultValue:oe(yt()),hide:oe(yt())}),continueOnFailure:D({defaultValue:oe(yt()),hide:oe(yt())})}),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 bt=D({displayName:v(),description:oe(v())}),tt=c((t,e)=>D({type:ke(e),required:yt(),defaultValue:oe(wo())}),"TPropertyValue");var Rr=D({...bt.shape,...tt(v(),"SHORT_TEXT").shape}),dn=D({...bt.shape,...tt(v(),"LONG_TEXT").shape});var wp=D({label:v(),value:We()}),Js=D({disabled:oe(yt()),placeholder:oe(v()),options:Xe(wp)});var Nr=D({...bt.shape,options:Js,...tt(We(),"STATIC_DROPDOWN").shape}),pn=D({...bt.shape,options:Js,...tt(Xe(We()),"STATIC_MULTI_SELECT_DROPDOWN").shape});var Kc=D({...bt.shape,...tt(We(),"DROPDOWN").shape,refreshers:Xe(v())}),Co=D({...bt.shape,...tt(Xe(We()),"MULTI_SELECT_DROPDOWN").shape,refreshers:Xe(v())});var hn=D({...bt.shape,...tt(yt(),"CHECKBOX").shape});var gn=D({...bt.shape,...tt(Ar(),"NUMBER").shape});var ko=D({...bt.shape,streaming:oe(yt()),...tt(We(),"FILE").shape});var Ro=D({...bt.shape,...tt(v(),"DATE_TIME").shape});var Pp=qe(v(),Je([Rr,dn,Nr,Co,pn,hn,gn,ko,Ro])),No=D({...bt.shape,properties:Pp,...tt(Xe(We()),"ARRAY").shape});var Oo=D({...bt.shape,...tt(Je([qe(v(),We())]),"JSON").shape});var Tp=Je([Rr,Nr,Oo,No,pn]),WA=qe(v(),Tp),Gc=D({refreshers:Xe(v()),...bt.shape,...tt(We(),"DYNAMIC").shape});var ea=D({...bt.shape,...tt(Ip(),"MARKDOWN").shape});var $o=(r=>(r.ARCHIVE="ARCHIVE",r.REGISTRY="REGISTRY",r))($o||{}),Ti=(r=>(r.CUSTOM="CUSTOM",r.OFFICIAL="OFFICIAL",r))(Ti||{}),Ci=(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))(Ci||{});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||{}),Cp=D({status:oe(Ar()),body:oe(We()),headers:oe(qe(v(),v()))}),kp=D({type:ke("DELAY"),resumeDateTime:v(),requestIdToReply:oe(v()),handlerId:oe(v()),streamStepProgress:oe(ot(ta))}),Rp=D({type:ke("WEBHOOK"),requestId:v(),requestIdToReply:oe(v()),response:Cp,handlerId:oe(v()),streamStepProgress:oe(ot(ta))}),QA=Je([kp,Rp]);var VA=D({body:We(),rawBody:oe(We()),headers:qe(v(),v()),queryParams:qe(v(),v())});function rr(t){return t==null}c(rr,"isNil");var Yc=Er(require("crypto"),1);var KA=128,$n,ki,GA=c(t=>{if(t<0)throw new RangeError("Wrong ID size");try{!$n||$n.length<t?($n=Buffer.allocUnsafe(t*KA),Yc.default.randomFillSync($n),ki=0):ki+t>$n.length&&(Yc.default.randomFillSync($n),ki=0)}catch(e){throw $n=void 0,e}ki+=t},"fillPool"),ZA=c(t=>(GA(t|=0),$n.subarray(ki-t,ki)),"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)=>{if(o<=0)return"";let s="";for(;;){let a=r(i),u=i;for(;u--;)if(s+=t[a[u]&n]||"",s.length===o)return s}}},"customRandom"),Op=c((t,e=21)=>YA(t,e,ZA),"customAlphabet");var XA="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",$p=21,A6=v().check(Cn(new RegExp(`^[0-9a-zA-Z]{${$p}}$`))),JA=Op(XA,$p);var Dn=Nn(Rn(t=>t instanceof Date?t.toISOString():t),v()),Ur={id:v(),created:Dn,updated:Dn},Ut=c(t=>oe(Po(t)),"Nullable");function Xc(t){return oe(Po(ot(t)))}c(Xc,"NullableEnum");var I6=Nn(Rn(t=>t==="true"||t===!0?!0:t==="false"||t===!1?!1:void 0),oe(yt())),ra=c(t=>Nn(Rn(e=>Array.isArray(e)?e:e!==void 0?[e]:void 0),oe(Xe(t))),"OptionalArrayFromQuery");var w6=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 L6=v().check(Cn(/^#[0-9A-Fa-f]{6}$/));var M6=D({filename:v(),data:We(),type:ke("file"),mimetype:oe(v())});var e0=Er(Bp());var V6=D({...Ur,name:v(),permissions:Xe(v()),platformId:Ut(v()),type:v(),userCount:oe(Ar())});var Up=(n=>(n.AGENT_DECIDE="agent-decide",n.CHOOSE_YOURSELF="choose-yourself",n.LEAVE_EMPTY="leave-empty",n))(Up||{}),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(Up),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:ke("PIECE"),toolName:v().check(qr(1)),pieceMetadata:n0}),o0=D({type:ke("none")}),s0=D({type:ke("access_token"),accessToken:v()}),a0=D({type:ke("api_key"),apiKey:v(),apiKeyHeader:v()}),c0=D({type:ke("headers"),headers:qe(v(),v())}),u0=kn("type",[o0,s0,a0,c0]),Lp=D({type:ke("FLOW"),toolName:v().check(qr(1)),externalFlowId:v(),flowDisplayName:oe(v())}),zp=D({type:ke("MCP"),toolName:v().check(qr(1)),serverUrl:Ap(),protocol:ot(eu),auth:u0}),Mp=D({type:ke("KNOWLEDGE_BASE"),toolName:v().check(qr(1)),sourceType:ot(Jc),sourceId:v(),sourceName:v()}),l0=kn("type",[i0,Lp,zp,Mp]),f0=D({displayName:v(),description:oe(v()),type:ot(tu)}),Fp=D({type:ke("MARKDOWN"),markdown:v()}),Ri={type:ke("TOOL_CALL"),input:Ut(qe(v(),We())),output:oe(We()),toolName:v(),status:ot(ru),toolCallId:v(),startTime:v(),endTime:oe(v())},vB=D(Ri),Hp=kn("toolCallType",[D({...Ri,toolCallType:ke("PIECE"),pieceName:v(),pieceVersion:v(),actionName:v()}),D({...Ri,toolCallType:ke("FLOW"),displayName:v(),externalFlowId:v()}),D({...Ri,toolCallType:ke("MCP"),displayName:v(),serverUrl:v()}),D({...Ri,toolCallType:ke("KNOWLEDGE_BASE"),displayName:v(),sourceType:v()}),D({...Ri,toolCallType:ke("UNKNOWN"),displayName:v()})]),d0=Je([Fp,Hp]);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,Vp=D({accessKeyId:v().check(qr(1)),secretAccessKey:v().check(qr(1))}),x0=D({}),I0=D({}),v0=D({}),S0=D({}),w0=D({}),P0=D({}),Kp=D({modelId:v(),modelName:v(),modelType:ot(nu)}),Gp=D({apiKeyHeader:v(),baseUrl:v(),models:Xe(Kp),defaultHeaders:oe(qe(v(),v()))}),Zp=D({accountId:v(),gatewayId:v(),models:Xe(Kp),vertexProject:oe(v()),vertexRegion:oe(v())}),Yp=D({resourceName:v(),apiVersion:Nn(Rn(t=>typeof t=="string"&&t.trim().length===0?void 0:t),oe(v()))}),Xp=D({region:v().check(qr(1))}),T0=Je([p0,_0,y0,E0,A0,m0,g0,h0,Vp,b0]),Jp=Je([Gp,Zp,Yp,Xp,x0,v0,S0,w0,I0,P0]),C0=D({id:v(),name:v(),type:ot(nu)}),k0=D({id:v(),name:v(),provider:ot(Lo),config:Jp,enabledForChat:yt()}),R0=D({provider:ot(Lo),config:Jp,auth:T0,platformId:v()});var TB={openai:"openai",anthropic:"anthropic","google-ai-studio":"google","google-vertex-ai":"google"},jp=["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"],Wp=["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:jp,anthropic:N0,google:Wp,activepieces:[...O0.map(t=>`anthropic/${t}`),...jp.map(t=>`openai/${t}`),...Wp.map(t=>`google/${t}`),...$0.map(t=>`x-ai/${t}`)]};var qp=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]??qp:qp}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:ke("file"),value:iu}),D({type:ke("markdown"),value:v(),files:oe(Xe(iu))})]),W0=D({sessionId:v(),message:v(),files:oe(Xe(v()))});var th=(r=>(r.ON_NEW_RECORD="ON_NEW_RECORD",r.ON_UPDATE_RECORD="ON_UPDATE_RECORD",r))(th||{}),rh=(r=>(r.ENABLED="ENABLED",r.DISABLED="DISABLED",r))(rh||{}),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:ke("STATIC_DROPDOWN"),tableId:v(),projectId:v(),data:D({options:Xe(D({value:v()}))})}),D({...Ur,name:v(),externalId:v(),type:Je([ke("TEXT"),ke("NUMBER"),ke("DATE")]),tableId:v(),projectId:v()})]),Q0=D({...Ur,name:v(),folderId:Ut(v()),projectId:v(),externalId:v(),status:Xc(rh),trigger:Xc(th)}),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:ih()}))),tableId:v()}),X0=D({cells:oe(Xe(D({fieldId:v(),value:ih()}))),tableId:v(),agentUpdate:oe(yt())}),nh=kn("operator",[ri("eq"),ri("neq"),ri("gt"),ri("gte"),ri("lt"),ri("lte"),ri("co"),eh("exists"),eh("not_exists")]),J0=D({tableId:v(),limit:oe(To.number()),cursor:oe(v()),filters:ra(nh)});function ih(){return Nn(Rn(t=>t==null?t:String(t)),Po(v()))}c(ih,"coerceToString");function ri(t){return D({fieldId:v(),operator:ke(t),value:v()})}c(ri,"valueFilter");function eh(t){return D({fieldId:v(),operator:ke(t)})}c(eh,"existenceFilter");var eb=D({status:oe(Ar()),body:oe(We()),headers:oe(qe(v(),v()))}),tb=D({...Ur,deleted:Ut(Dn),ownerId:v(),displayName:v(),platformId:v(),externalId:Ut(v())});var oh=D({name:v(),description:oe(v()),type:v(),required:yt()}),rb=D({pieceName:v(),triggerName:v(),input:D({toolName:v(),toolDescription:v(),inputSchema:Xe(oh),returnsResponse:yt()})});var sh="^[0-9]+\\.[0-9]+\\.[0-9]+$",VB=new RegExp(sh),ib="^([~^])?[0-9]+\\.[0-9]+\\.[0-9]+$",KB=v().check(Cn(new RegExp(sh))),GB=v().check(Cn(new RegExp(ib))),ob=D({packageType:ke("ARCHIVE"),pieceType:ot(Ti),pieceName:v(),pieceVersion:v(),archiveId:v(),platformId:v()}),ah=D({packageType:ke("REGISTRY"),pieceType:ke("OFFICIAL"),pieceName:v(),pieceVersion:v()}),ch=D({packageType:ke("REGISTRY"),pieceType:ke("CUSTOM"),pieceName:v(),pieceVersion:v(),platformId:v()}),ZB=Je([ah,ch]),YB=Je([ob,ah,ch]);var sb=kn("type",[D({type:ke("CRON_EXPRESSION"),cronExpression:v(),timezone:v()}),D({type:ke("INTERVAL"),intervalMs:bp().check(Ks(6e4))})]),XB=D({...Ur,type:ot(On),projectId:v(),flowId:v(),triggerName:v(),schedule:Ut(sb),flowVersionId:v(),pieceName:v(),pieceVersion:v(),deleted:Ut(v()),simulate:yt()}),uh=(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))(uh||{}),lh=(r=>(r.NONE="NONE",r.ZSTD="ZSTD",r))(lh||{}),fh=(r=>(r.S3="S3",r.DB="DB",r))(fh||{}),JB=D({...Ur,projectId:Ut(v()),platformId:Ut(v()),type:ot(uh),compression:ot(lh),data:oe(We()),location:ot(fh),size:Ut(Ar()),fileName:Ut(v()),s3Key:Ut(v()),metadata:Ut(qe(v(),v()))}),dh=(n=>(n.ADMIN="ADMIN",n.MEMBER="MEMBER",n.OPERATOR="OPERATOR",n))(dh||{}),ph=(r=>(r.ACTIVE="ACTIVE",r.INACTIVE="INACTIVE",r))(ph||{}),eU=D({id:v(),email:v(),firstName:v(),status:ot(ph),externalId:Ut(v()),platformId:Ut(v()),platformRole:ot(dh),lastName:v(),created:Dn,updated:Dn,lastActiveDate:Ut(Dn),imageUrl:Ut(v())});var au=D({...bt.shape,...tt(qe(v(),We()),"OBJECT").shape});var mh=D({...bt.shape,...tt(v(),"COLOR").shape});var cu=Je([Rr,dn,ea,hn,Nr,pn,Kc,Co,Gc,gn,No,au,Oo,Ro,ko,mh]),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()),hasConnectionIdentifier:oe(yt())});var _h=D({username:v(),password:v()}),uu=D({...en.shape,username:D({displayName:v(),description:oe(v())}),password:D({displayName:v(),description:oe(v())}),...tt(_h,"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])),yh=D({...en.shape,props:fb,...tt(We(),"OIDC").shape});var fu=(r=>(r.HEADER="HEADER",r.BODY="BODY",r))(fu||{}),Eh=Je([Rr,ni,Nr]),Ah=qe(v(),Eh),db=D({props:oe(qe(v(),Eh)),authUrl:v(),tokenUrl:v(),scope:Xe(v()),prompt:oe(Je([ke("none"),ke("consent"),ke("login"),ke("omit")])),pkce:oe(yt()),pkceMethod:oe(Je([ke("plain"),ke("S256")])),authorizationMethod:oe(ot(fu)),grantType:oe(Je([ot(Do),ke(Zc)])),extra:oe(qe(v(),v()))}),bh=D({access_token:v(),props:oe(Ah),data:qe(v(),wo())}),du=D({...en.shape,...db.shape,...tt(bh,"OAUTH2").shape});var Ni=Je([uu,lu,yh,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 NL={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({...bt.shape,...tt(We(),"CUSTOM").shape,code:v()});var gb=Je([cu,Ni]),pu=qe(v(),gb),XL=qe(v(),cu);var xh=Je([D({strategy:ke("CRON"),cronExpression:v()}),D({strategy:ke("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")}},Ih=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,rr(t.sampleData)&&rr(t.test)?"SIMULATION":"TEST_FUNCTION",t.outputSchema,t.aiMetadata)}},"createTrigger");var vh="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:vh}),"getContextInfo");(!_b(l)||yb(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:mb(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}},wh=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){if(t!==void 0)return Array.isArray(t)?t.map(Sh):Sh(t)}c(mb,"withConnectionIdentifierFlag");function Sh(t){return{...t,hasConnectionIdentifier:t.getConnectionIdentifier!==void 0}}c(Sh,"flagConnectionIdentifier");function _b(t){return/^\d+\.\d+\.\d+$/.test(t)}c(_b,"isValidSimpleSemver");function yb(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(yb,"isSemverLessThan");var Eb=oe(qe(v(),qe(v(),v()))),Ph=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(Ci))),minimumSupportedRelease:oe(v()),maximumSupportedRelease:oe(v()),deprecated:oe(yt()),i18n:Eb}),Ab=ot(["human","ai","both"]),Th=D({description:oe(v()),idempotent:oe(yt())}),Ch=D({name:v(),displayName:v(),description:v(),props:pu,requireAuth:yt(),errorHandlingOptions:oe(Vc),outputSchema:oe(Xs()),audience:oe(Ab),aiMetadata:oe(Th)}),kh=D({name:v(),displayName:v(),description:v(),props:pu,errorHandlingOptions:oe(Vc),type:ot(On),sampleData:We(),handshakeConfiguration:oe(Xs()),renewConfiguration:oe(xh),testStrategy:ot(Uo),outputSchema:oe(Xs()),aiMetadata:oe(Th)}),bb=D({...Ph.shape,actions:qe(v(),Ch),triggers:qe(v(),kh)}),xb=D({...Ph.shape,actions:Ar(),triggers:Ar(),suggestedActions:oe(Xe(Ch)),suggestedTriggers:oe(Xe(kh))}),Rh=D({projectUsage:Ar(),pieceType:ot(Ti),packageType:ot($o),platformId:oe(v()),archiveId:oe(v())}),Xz=D({...bb.shape,...Rh.shape}),Jz=D({...xb.shape,...Rh.shape}),eM=D({name:v(),version:v()});var Ib=Er(require("path")),vb=Er(require("fs/promises"));var AE=Er(nn());var yE=Er(_E()),EE=Er(nn());async function Dt(t){return rr(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 yE.default;if(u){let g=u.replace(/\\r\\n/g,`
|
|
19
|
+
${r}`}};var Dv=2**32,Um=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();ds.ERR_OUT_OF_RANGE=class zm extends RangeError{static{c(this,"ERR_OUT_OF_RANGE")}constructor(e,r,n,i){super(),Error.captureStackTrace(this,zm),Ga(r,'Missing "range" argument');let o=i?e:`The value of "${e}" is out of range.`,s;Number.isInteger(n)&&Math.abs(n)>Dv?s=Dm(String(n)):typeof n=="bigint"?(s=String(n),(n>Um||n<-Um)&&(s=Dm(s)),s+="n"):s=$v(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} ${Bm(r,"type")}`;else{let s=e.includes(".")?"property":"argument";o=`The "${e}" ${s} ${i} ${Bm(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((KF,Jm)=>{"use strict";var Bv=require("events"),qn=require("fs"),{constants:Tr}=qn,{Readable:Qm,Writable:Jl}=require("stream"),{inherits:Vm,types:{isDate:Vl}}=require("util"),Uv=Buffer[Symbol.species],{bufferCopy:Wn,bufferSlice:oo,makeBufferParser:Lv,writeUInt32BE:G}=Vr(),In={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},De=Buffer.alloc(28),mt={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},zv=new Map(Object.values(mt).map(t=>[t,1])),Mv={[mt.OK]:"No error",[mt.EOF]:"End of file",[mt.NO_SUCH_FILE]:"No such file or directory",[mt.PERMISSION_DENIED]:"Permission denied",[mt.FAILURE]:"Failure",[mt.BAD_MESSAGE]:"Bad message",[mt.NO_CONNECTION]:"No connection",[mt.CONNECTION_LOST]:"Connection lost",[mt.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},Cr={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},Fm=2*1024,St=2**32-1,Fv=Buffer.from([0,0,0,5,Ne.INIT,0,0,0,3]),Hv=Buffer.from([0,0,0,5,Cr.VERSION,0,0,0,3]),jv=/^SSH-2.0-(?:OpenSSH|dropbear)/,ql=256*1024,U=Lv(),Wv={readable:!1,writable:!1,push:c(t=>{},"push"),once:c(()=>{},"once"),on:c(()=>{},"on"),emit:c(()=>{},"emit"),end:c(()=>{},"end")};function Km(){}c(Km,"noop");var Kl=class extends Bv{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&&jv.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=ql,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?ql:34e3)-Fm,this._maxWriteLen=(this._isOpenSSH?ql:34e3)-Fm,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=Wv,this.readable=!0}push(e){if(e===null){if(Xm(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 At(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return At(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?Gv[n]:Kv[n];if(!o)return At(this,`Unknown packet type ${n}`);if(this._version===-1){if(this.server){if(n!==Ne.INIT)return At(this,`Expected INIT packet, got ${n}`)}else if(n!==Cr.VERSION)return At(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=Km,this.server||ft(this,Fv)}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 Hr(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:Zm(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);G(d,d.length-4,0),d[4]=Ne.OPEN;let p=this._writeReqid=this._writeReqid+1&St;G(d,p,5),G(d,u,l),d.utf8Write(e,l+=4,u),G(d,o,l+=u),G(d,s,l+=4),a&&(l+=4,a===De.length?d.set(De,l):Wn(De,d,0,a,l),l+=a),this._requests[p]={cb:i};let g=ft(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);G(o,o.length-4,0),o[4]=Ne.CLOSE;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(o,n,i),o.set(e,i+=4),this._requests[s]={cb:r};let a=ft(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");Gm(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);G(g,g.length-4,0),g[4]=Ne.WRITE;let h=this._writeReqid=this._writeReqid+1&St;G(g,h,5),G(g,d,p),g.set(e,p+=4),p+=d;for(let b=7;b>=0;--b)g[p+b]=o&255,o/=256;G(g,i,p+=8),Wn(r,g,n,n+i,p+=4),this._requests[h]={cb:c(b=>{b?typeof s=="function"&&s(b):u?this.write(e,r,n+i,u,l+i,s):typeof s=="function"&&s(void 0,n+i)},"cb")};let _=ft(this,g);if(this._debug){let b=_?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${b} 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");Hm(this,qn,e,r,n,i)}fastPut(e,r,n,i){if(this.server)throw new Error("Client-only method called in server mode");Hm(qn,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((E,v)=>{let w;if(E){if(w=E.code===mt.EOF,!w)return this.close(d,()=>i&&i(E))}else w=!1;if(w||s===0&&v===0)return b();p+=v,l+=v,s!==0?l===s?b():h():(u.push(oo(a,0,v)),h())},"afterRead");_._wantEOFError=!0;let b=c(()=>{this.close(d,E=>(s===0?a=Buffer.concat(u,l):l<s&&(a=oo(a,0,l)),o&&(a=a.toString(o)),i&&i(E,a)))},"close");this.open(e,g,438,(E,v)=>{if(E)return i&&i(E);d=v;let w=c((H,D)=>{if(H){this.stat(e,(J,Y)=>{if(J)return this.close(d,()=>{i&&i(H)});w(null,Y)});return}if(s=D.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,(_,b)=>{if(_)return this.close(u,()=>{o&&o(g)});p(null,b)});return}Gl(this,u,l,0,l.length,h.size,o)},"tryStat");this.fstat(u,p);return}Gl(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);G(o,o.length-4,0),o[4]=Ne.REMOVE;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=ft(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);G(a,a.length-4,0),a[4]=Ne.RENAME;let u=this._writeReqid=this._writeReqid+1&St;G(a,u,5),G(a,i,s),a.utf8Write(e,s+=4,i),G(a,o,s+=i),a.utf8Write(r,s+=4,o),this._requests[u]={cb:n};let l=ft(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);G(u,u.length-4,0),u[4]=Ne.MKDIR;let l=this._writeReqid=this._writeReqid+1&St;G(u,l,5),G(u,s,a),u.utf8Write(e,a+=4,s),G(u,i,a+=s),o&&(a+=4,o===De.length?u.set(De,a):Wn(De,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=ft(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);G(o,o.length-4,0),o[4]=Ne.RMDIR;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=ft(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,(b,E)=>{let v=b&&b.code===mt.EOF;if(b&&!v)return this.close(_,()=>n(b));if(v)return this.close(_,w=>{if(w)return n(w);n(void 0,d)});for(let w=0;w<E.length;++w,++p)d[p]=E[w];g(void 0,_)})},"reread");return this.opendir(e,g)}let o=e.length,s=9,a=Buffer.allocUnsafe(13+o);G(a,a.length-4,0),a[4]=Ne.READDIR;let u=this._writeReqid=this._writeReqid+1&St;G(a,u,5),G(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=ft(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);G(o,o.length-4,0),o[4]=Ne.FSTAT;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(o,n,i),o.set(e,i+=4),this._requests[s]={cb:r};let a=ft(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);G(o,o.length-4,0),o[4]=Ne.STAT;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=ft(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);G(o,o.length-4,0),o[4]=Ne.LSTAT;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=ft(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);G(o,o.length-4,0),o[4]=Ne.OPENDIR;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(o,n,i),o.utf8Write(e,i+=4,n),this._requests[s]={cb:r};let a=ft(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);G(u,u.length-4,0),u[4]=Ne.SETSTAT;let l=this._writeReqid=this._writeReqid+1&St;G(u,l,5),G(u,s,a),u.utf8Write(e,a+=4,s),G(u,i,a+=s),o&&(a+=4,o===De.length?u.set(De,a):Wn(De,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=ft(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);G(u,u.length-4,0),u[4]=Ne.FSETSTAT;let l=this._writeReqid=this._writeReqid+1&St;G(u,l,5),G(u,s,a),u.set(e,a+=4),G(u,i,a+=s),o&&(a+=4,o===De.length?u.set(De,a):Wn(De,u,0,o,a),a+=o),this._requests[l]={cb:n};let d=ft(this,u);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} FSETSTAT`)}futimes(e,r,n,i){return this.fsetstat(e,{atime:no(r),mtime:no(n)},i)}utimes(e,r,n,i){return this.setstat(e,{atime:no(r),mtime:no(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);G(o,o.length-4,0),o[4]=Ne.READLINK;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(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=ft(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);G(a,a.length-4,0),a[4]=Ne.SYMLINK;let u=this._writeReqid=this._writeReqid+1&St;G(a,u,5),this._isOpenSSH?(G(a,o,s),a.utf8Write(e,s+=4,o),G(a,i,s+=o),a.utf8Write(r,s+=4,i)):(G(a,i,s),a.utf8Write(r,s+=4,i),G(a,o,s+=i),a.utf8Write(e,s+=4,o)),this._requests[u]={cb:n};let l=ft(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);G(o,o.length-4,0),o[4]=Ne.REALPATH;let s=this._writeReqid=this._writeReqid+1&St;G(o,s,5),G(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=ft(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);G(u,u.length-4,0),u[4]=Ne.EXTENDED;let l=this._writeReqid=this._writeReqid+1&St;G(u,l,5),G(u,24,a),u.utf8Write("posix-rename@openssh.com",a+=4,24),G(u,o,a+=24),u.utf8Write(e,a+=4,o),G(u,s,a+=o),u.utf8Write(r,a+=4,s),this._requests[l]={cb:n};let d=ft(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);G(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;G(s,a,5),G(s,19,o),s.utf8Write("statvfs@openssh.com",o+=4,19),G(s,i,o+=19),s.utf8Write(e,o+=4,i),this._requests[a]={extended:"statvfs@openssh.com",cb:r};let u=ft(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);G(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;G(s,a,5),G(s,20,o),s.utf8Write("fstatvfs@openssh.com",o+=4,20),G(s,i,o+=20),s.set(e,o+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:r};let u=ft(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);G(u,u.length-4,0),u[4]=Ne.EXTENDED;let l=this._writeReqid=this._writeReqid+1&St;G(u,l,5),G(u,20,a),u.utf8Write("hardlink@openssh.com",a+=4,20),G(u,o,a+=20),u.utf8Write(e,a+=4,o),G(u,s,a+=o),u.utf8Write(r,a+=4,s),this._requests[l]={cb:n};let d=ft(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);G(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;G(s,a,5),G(s,17,o),s.utf8Write("fsync@openssh.com",o+=4,17),G(s,i,o+=17),s.set(e,o+=4),this._requests[a]={cb:r};let u=ft(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);G(l,l.length-4,0),l[4]=Ne.EXTENDED;let d=this._writeReqid=this._writeReqid+1&St;G(l,d,5),G(l,20,u),l.utf8Write("lsetstat@openssh.com",u+=4,20),G(l,a,u+=20),l.utf8Write(e,u+=4,a),G(l,o,u+=a),s&&(u+=4,s===De.length?l.set(De,u):Wn(De,l,0,s,u),u+=s),this._requests[d]={cb:n};let p=ft(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);G(s,s.length-4,0),s[4]=Ne.EXTENDED;let a=this._writeReqid=this._writeReqid+1&St;G(s,a,5),G(s,23,o),s.utf8Write("expand-path@openssh.com",o+=4,23),G(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=ft(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);G(l,l.length-4,u),u+=4,l[u]=Ne.EXTENDED,++u;let d=this._writeReqid=this._writeReqid+1&St;G(l,d,u),u+=4,G(l,9,u),u+=4,l.utf8Write("copy-data",u,9),u+=9,G(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,G(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=ft(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);G(s,s.length-4,i),i+=4,s[i]=Ne.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&St;G(s,a,i),i+=4,G(s,14,i),i+=4,s.utf8Write("home-directory",i,14),i+=14,G(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=ft(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);G(s,s.length-4,o),o+=4,s[o]=Ne.EXTENDED,++o;let a=this._writeReqid=this._writeReqid+1&St;G(s,a,o),o+=4,G(s,30,o),o+=4,s.utf8Write("users-groups-by-id@openssh.com",o,30),o+=30,G(s,4*e.length,o),o+=4;for(let l of e)G(s,l,o),o+=4;G(s,4*r.length,o),o+=4;for(let l of r)G(s,l,o),o+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:n};let u=ft(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);G(o,o.length-4,0),o[4]=Cr.HANDLE,G(o,e,5),G(o,n,i),n&&o.set(r,i+=4);let s=ft(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(!zv.has(r))throw new Error(`Bad status code: ${r}`);n||(n="");let i=Buffer.byteLength(n),o=9,s=Buffer.allocUnsafe(17+i+4);G(s,s.length-4,0),s[4]=Cr.STATUS,G(s,e,5),G(s,r,o),G(s,i,o+=4),o+=4,i&&(s.utf8Write(n,o,i),o+=i),G(s,0,o);let a=ft(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);G(u,u.length-4,0),u[4]=Cr.DATA,G(u,e,5),G(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=ft(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===De.length?_=new Uint8Array(De):(_=new Uint8Array(o.nb),Wn(De,_,0,o.nb,0)),o.bytes=_}s.push(o)}else i+=4,s.push(null)}let a=9,u=Buffer.allocUnsafe(13+i);G(u,u.length-4,0),u[4]=Cr.NAME,G(u,e,5),G(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);G(u,_,a),a+=4,_&&(u.utf8Write(h,a,_),a+=_)}{let h=!p||!p.longname||typeof p.longname!="string"?"":p.longname,_=Buffer.byteLength(h);G(u,_,a),a+=4,_&&(u.utf8Write(h,a,_),a+=_)}let g=s[d];g?(G(u,g.flags,a),a+=4,g.flags&&g.bytes&&(u.set(g.bytes,a),a+=g.nb)):(G(u,0,a),a+=4)}let l=ft(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);G(s,s.length-4,0),s[4]=Cr.ATTRS,G(s,e,5),G(s,n,o),i&&(o+=4,i===De.length?s.set(De,o):Wn(De,s,0,i,o),o+=i);let a=ft(this,s);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function qv(t){try{return Buffer.allocUnsafe(t)}catch(e){return e}}c(qv,"tryCreateBuffer");function Gm(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);G(h,h.length-4,0),h[4]=Ne.READ;let _=t._writeReqid=t._writeReqid+1&St;G(h,_,5),G(h,d,p),h.set(e,p+=4),p+=d;for(let v=7;v>=0;--v)h[p+v]=g&255,g/=256;G(h,i,p+=8),typeof s!="function"&&(s=Km);let b=a||{nb:0,position:o,off:n,origOff:n,len:void 0,overflow:void 0,cb:c((v,w,H)=>{let D=b.len,J=b.overflow;if(v){if(s._wantEOFError||v.code!==mt.EOF)return s(v)}else{if(H>D)return s(new Error("Received more data than requested"));if(H===D&&J){b.nb+=H,b.position+=H,b.off+=H,Gm(t,e,r,b.off,J,b.position,s,b);return}}H=H||0,b.origOff===0&&r.length===b.nb?w=r:w=oo(r,b.origOff,b.origOff+b.nb+H),s(void 0,b.nb+H,w,b.position)},"cb"),buffer:void 0};b.len=i,b.overflow=l,b.buffer=oo(r,n,n+i),t._requests[_]=b;let E=ft(t,h);t._debug&&t._debug(`SFTP: Outbound: ${E?"Buffered":"Sending"} READ`)}c(Gm,"read_");function Hm(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=ef(i.mode)));let p,g=0,h=0,_=!1,b,E,v,w=a*s;function H(D){if(_)return;_=!0;let J=0,Y;b||E?(Y=c(()=>{--J===0&&o(D)},"cbfinal"),b&&(t===qn||t.outgoing.state==="open")&&++J,E&&(e===qn||e.outgoing.state==="open")&&++J,b&&(t===qn||t.outgoing.state==="open")&&t.close(b,Y),E&&(e===qn||e.outgoing.state==="open")&&e.close(E,Y)):o(D)}c(H,"onerror"),t.open(r,"r",(D,J)=>{if(D)return H(D);b=J,d===void 0?t.fstat(b,Y):Y(null,{size:d});function Y(X,P){if(X){if(t!==qn){t.stat(r,(C,M)=>{if(C)return H(X);Y(null,M)});return}return H(X)}p=P.size,e.open(n,"w",(C,M)=>{if(C)return H(C);if(E=M,p<=0)return H();for(;w>p;){if(s===1){w=p;break}w-=a,--s}if(v=qv(w),v instanceof Error)return H(v);l!==void 0?e.fchmod(E,l,c(function B(Z){if(Z){e.chmod(n,l,te=>B());return}j()},"tryAgain")):j();function L(B,Z,te,k,W,q){if(B)return H(B);W=W||0,e.write(E,v,W,Z,k,ee);function ee(ue){if(ue)return H(ue);if(h+=Z,u&&u(h,Z,p),Z<q)return F(W,k+Z,q-Z);if(h===p){e.close(E,he=>{if(E=void 0,he)return H(he);t.close(b,xt=>{if(b=void 0,xt)return H(xt);o()})});return}if(g>=p)return;let me=g+a>p?p-g:a;F(W,g,me),g+=me}c(ee,"writeCb")}c(L,"onread");function T(B,Z,te){return(k,W,q)=>{L(k,W,q,Z,B,te)}}c(T,"makeCb");function F(B,Z,te){t.read(b,v,B,te,Z,T(B,Z,te))}c(F,"singleRead");function j(){let B=0,Z=0;for(;g<p&&B<s;){let te=g+a>p?p-g:a;F(Z,g,te),Z+=te,g+=te,++B}}c(j,"startReads")})}c(Y,"tryStat")})}c(Hm,"fastXfer");function Gl(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,Gl(t,e,r,n,i,o,a))})}c(Gl,"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&Tr.S_IFMT)===Tr.S_IFDIR}isFile(){return(this.mode&Tr.S_IFMT)===Tr.S_IFREG}isBlockDevice(){return(this.mode&Tr.S_IFMT)===Tr.S_IFBLK}isCharacterDevice(){return(this.mode&Tr.S_IFMT)===Tr.S_IFCHR}isSymbolicLink(){return(this.mode&Tr.S_IFMT)===Tr.S_IFLNK}isFIFO(){return(this.mode&Tr.S_IFMT)===Tr.S_IFIFO}isSocket(){return(this.mode&Tr.S_IFMT)===Tr.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;De[r++]=n/72057594037927940,De[r++]=n/281474976710656,De[r++]=n/1099511627776,De[r++]=n/4294967296,De[r++]=n/16777216,De[r++]=n/65536,De[r++]=n/256,De[r++]=n}if(typeof t.uid=="number"&&typeof t.gid=="number"){e|=In.UIDGID;let n=t.uid,i=t.gid;De[r++]=n>>>24,De[r++]=n>>>16,De[r++]=n>>>8,De[r++]=n,De[r++]=i>>>24,De[r++]=i>>>16,De[r++]=i>>>8,De[r++]=i}if(typeof t.mode=="number"||typeof t.mode=="string"){let n=ef(t.mode);e|=In.PERMISSIONS,De[r++]=n>>>24,De[r++]=n>>>16,De[r++]=n>>>8,De[r++]=n}if((typeof t.atime=="number"||Vl(t.atime))&&(typeof t.mtime=="number"||Vl(t.mtime))){let n=no(t.atime),i=no(t.mtime);e|=In.ACMODTIME,De[r++]=n>>>24,De[r++]=n>>>16,De[r++]=n>>>8,De[r++]=n,De[r++]=i>>>24,De[r++]=i>>>16,De[r++]=i>>>8,De[r++]=i}}return{flags:e,nb:r}}c(fi,"attrsToBytes");function no(t){if(typeof t=="number"&&t===t)return t;if(Vl(t))return parseInt(t.getTime()/1e3,10);throw new Error(`Cannot parse time: ${t}`)}c(no,"toUnixTimestamp");function ef(t){if(typeof t=="number"&&t===t)return t;if(typeof t=="string")return ef(parseInt(t,8));throw new Error(`Cannot parse mode: ${t}`)}c(ef,"modeNum");var Zl={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 Zm(t){let e=Zl[t];return e!==void 0?e:null}c(Zm,"stringToFlags");var Qv=(()=>{let t=Object.keys(Zl);return e=>{for(let r=0;r<t.length;++r){let n=t[r];if(Zl[n]===e)return n}return null}})();function io(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(io,"readAttrs");function ft(t,e){let r=Ym(t,e);return r!==void 0?(t._buffer.push(r),!1):!0}c(ft,"sendOrBuffer");function Ym(t,e){let r=t.outgoing;if(r.state!=="open")return;if(r.window===0)return t._waitWindow=!0,t._chunkcb=jm,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=jm),o===0&&s===i?t._protocol.channelData(t.outgoing.id,e):t._protocol.channelData(t.outgoing.id,oo(e,o,o+s)),o+=s}return i-o>0&&(o>0?n=oo(e,o,i):n=e),n}c(Ym,"tryWritePayload");function jm(){this._chunkcb=void 0;let t=this._buffer,e=0;for(;e<t.length;){let r=t[e],n=Ym(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(jm,"drainBuffer");function At(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(),Xm(t),!1}c(At,"doFatalSFTPError");function Xm(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(Xm,"cleanupRequests");function Vv(t,e){let r=9,n=Buffer.allocUnsafe(31);G(n,n.length-4,0),n[4]=Ne.EXTENDED;let i=t._writeReqid=t._writeReqid+1&St;G(n,i,5),G(n,18,r),n.utf8Write("limits@openssh.com",r+=4,18),t._requests[i]={extended:"limits@openssh.com",cb:e};let o=ft(t,n);if(t._debug){let s=o?"Buffered":"Sending";t._debug(`SFTP: Outbound: ${s} limits@openssh.com`)}}c(Vv,"requestLimits");var Kv={[Cr.VERSION]:(t,e)=>{if(t._version!==-1)return At(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 At(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 Vv(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")},[Cr.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===mt.OK){o.cb();return}let s=new Error(i||Mv[n]||"Unknown status");s.code=n,o.cb(s)}},[Cr.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],At(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)},[Cr.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 At(t,"Malformed DATA packet")},[Cr.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=io(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(),At(t,"Malformed NAME packet")},[Cr.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=io(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 At(t,"Malformed ATTRS packet")},[Cr.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(),At(t,"Malformed EXTENDED_REPLY packet")}},Gv={[Ne.INIT]:(t,e)=>{if(t._version!==-1)return At(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 At(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})`)}ft(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=io(t._biOpt);if(U.clear(),o===void 0)return At(t,"Malformed OPEN packet");t._debug&&t._debug(`SFTP: Inbound: Received OPEN (id:${r})`),t.emit("OPEN",r,n,i,o)||t.status(r,mt.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 At(t,"Malformed CLOSE packet");t._debug&&t._debug(`SFTP: Inbound: Received CLOSE (id:${r})`),t.emit("CLOSE",r,n)||t.status(r,mt.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 At(t,"Malformed READ packet");t._debug&&t._debug(`SFTP: Inbound: Received READ (id:${r})`),t.emit("READ",r,n,i,o)||t.status(r,mt.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 At(t,"Malformed WRITE packet");t._debug&&t._debug(`SFTP: Inbound: Received WRITE (id:${r})`),t.emit("WRITE",r,n,i,o)||t.status(r,mt.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 At(t,"Malformed LSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received LSTAT (id:${r})`),t.emit("LSTAT",r,n)||t.status(r,mt.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 At(t,"Malformed FSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received FSTAT (id:${r})`),t.emit("FSTAT",r,n)||t.status(r,mt.OP_UNSUPPORTED)},[Ne.SETSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=io(t._biOpt);if(U.clear(),i===void 0)return At(t,"Malformed SETSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received SETSTAT (id:${r})`),t.emit("SETSTAT",r,n,i)||t.status(r,mt.OP_UNSUPPORTED)},[Ne.FSETSTAT]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(),i=io(t._biOpt);if(U.clear(),i===void 0||n.length>256)return At(t,"Malformed FSETSTAT packet");t._debug&&t._debug(`SFTP: Inbound: Received FSETSTAT (id:${r})`),t.emit("FSETSTAT",r,n,i)||t.status(r,mt.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 At(t,"Malformed OPENDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received OPENDIR (id:${r})`),t.emit("OPENDIR",r,n)||t.status(r,mt.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 At(t,"Malformed READDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received READDIR (id:${r})`),t.emit("READDIR",r,n)||t.status(r,mt.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 At(t,"Malformed REMOVE packet");t._debug&&t._debug(`SFTP: Inbound: Received REMOVE (id:${r})`),t.emit("REMOVE",r,n)||t.status(r,mt.OP_UNSUPPORTED)},[Ne.MKDIR]:(t,e)=>{U.init(e,1);let r=U.readUInt32BE(),n=U.readString(!0),i=io(t._biOpt);if(U.clear(),i===void 0)return At(t,"Malformed MKDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received MKDIR (id:${r})`),t.emit("MKDIR",r,n,i)||t.status(r,mt.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 At(t,"Malformed RMDIR packet");t._debug&&t._debug(`SFTP: Inbound: Received RMDIR (id:${r})`),t.emit("RMDIR",r,n)||t.status(r,mt.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 At(t,"Malformed REALPATH packet");t._debug&&t._debug(`SFTP: Inbound: Received REALPATH (id:${r})`),t.emit("REALPATH",r,n)||t.status(r,mt.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 At(t,"Malformed STAT packet");t._debug&&t._debug(`SFTP: Inbound: Received STAT (id:${r})`),t.emit("STAT",r,n)||t.status(r,mt.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 At(t,"Malformed RENAME packet");t._debug&&t._debug(`SFTP: Inbound: Received RENAME (id:${r})`),t.emit("RENAME",r,n,i)||t.status(r,mt.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 At(t,"Malformed READLINK packet");t._debug&&t._debug(`SFTP: Inbound: Received READLINK (id:${r})`),t.emit("READLINK",r,n)||t.status(r,mt.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 At(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,mt.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(),At(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,mt.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:Zv,ERR_OUT_OF_RANGE:Ya,validateNumber:Yv}=Mm(),Wm=128,vr,Yl=[];function Xv(t){Yl.length>0?vr=Yl.pop():vr=Buffer.allocUnsafe(t),vr.used=0}c(Xv,"allocNewPool");function Xl(t,e){if(!Number.isSafeInteger(t))throw Yv(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(Xl,"checkPosition");function Ql(t){return t+7&-8}c(Ql,"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,Qm.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&&(Xl(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(Xl(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");Vm(vn,Qm);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;(!vr||vr.length-vr.used<Wm)&&Xv(this.readableHighWaterMark||this._readableState.highWaterMark);let e=vr,r=Math.min(vr.length-vr.used,t),n=vr.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,vr,vr.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===vr)e.used=Ql(e.used+o-r);else{let a=n+r&-8,u=Ql(n+o);a-u>=Wm&&Yl.push(e.slice(u,a))}o>0&&(this.bytesRead+=o,s=e.slice(n,n+o)),this.pos+=o,this.push(s)}),vr.used=Ql(vr.used+r)};vn.prototype._destroy=function(t,e){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",qm.bind(null,this,e,t));return}qm(this,e,t),this.handle=null,this._opening=!1};function qm(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(qm,"closeStream");vn.prototype.close=function(t){this.destroy(null,t)};Object.defineProperty(vn.prototype,"pending",{get(){return this.handle===null},configurable:!0});function Hr(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,Jl.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&&(Xl(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(Hr,"WriteStream");Vm(Hr,Jl);Hr.prototype._final=function(t){this.autoClose&&this.destroy(),t()};Hr.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)}))};Hr.prototype._write=function(t,e,r){if(!Buffer.isBuffer(t)){let n=new Zv("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};Hr.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 Jl.prototype.destroy!="function"&&(Hr.prototype.destroy=vn.prototype.destroy);Hr.prototype._destroy=vn.prototype._destroy;Hr.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()};Hr.prototype.destroySoon=Hr.prototype.end;Object.defineProperty(Hr.prototype,"pending",{get(){return this.handle===null},configurable:!0});Jm.exports={flagsToString:Qv,OPEN_MODE:Te,SFTP:Kl,Stats:Xa,STATUS_CODE:mt,stringToFlags:Zm}});var af=le((ZF,n_)=>{"use strict";var{Duplex:Jv,Readable:eS,Writable:tS}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:e_}}=An(),{bufferSlice:Ja}=Vr(),rS=32*1024,hs=2*1024*1024,of=hs/2,tf=class extends eS{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<=of&&sf(this._channel))}},rf=class extends tS{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,e_):o.channelExtData(u,Ja(e,p,p+g),e_),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()}}},nf=class extends Jv{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 rf(this):this.stderr=new tf(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",t_).on("prefinish",t_),this.on("end",r_).on("close",r_)}_read(e){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=of&&sf(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 t_(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}c(t_,"onFinish");function r_(){this.readable=!1}c(r_,"onEnd");function sf(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(sf,"windowAdjust");n_.exports={Channel:nf,MAX_WINDOW:hs,PACKET_SIZE:rS,windowAdjust:sf,WINDOW_THRESHOLD:of}});var lf=le((XF,s_)=>{"use strict";var{SFTP:nS}=ps(),gs=2**32-1;function i_(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(i_,"onChannelOpenFailure");function o_(t,e,r,n,i){if(typeof r=="function"){i_(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!==nS&&(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(o_,"onCHANNEL_CLOSE");var uf=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];o_(i,s,a._channel||a,e,!0)}}},cf=(()=>{let t=Object.prototype.toString;return e=>t.call(e)==="[object RegExp]"})();function iS(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(cf(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(cf(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(cf(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(iS,"generateAlgorithmList");s_.exports={ChannelManager:uf,generateAlgorithmList:iS,onChannelOpenFailure:i_,onCHANNEL_CLOSE:o_,isWritable:c(t=>t&&t.writable&&t._readableState&&t._readableState.ended===!1,"isWritable")}});var gf=le((e5,T_)=>{"use strict";var{createHash:oS,getHashes:sS,randomFillSync:aS}=require("crypto"),{Socket:cS}=require("net"),{lookup:uS}=require("dns"),lS=require("events"),fS=sS(),{COMPAT:S_,CHANNEL_EXTENDED_DATATYPE:{STDERR:dS},CHANNEL_OPEN_FAILURE:ms,DEFAULT_CIPHER:a_,DEFAULT_COMPRESSION:c_,DEFAULT_KEX:u_,DEFAULT_MAC:l_,DEFAULT_SERVER_HOST_KEY:f_,DISCONNECT_REASON:d_,DISCONNECT_REASON_BY_VALUE:pS,SUPPORTED_CIPHER:hS,SUPPORTED_COMPRESSION:gS,SUPPORTED_KEX:mS,SUPPORTED_MAC:_S,SUPPORTED_SERVER_HOST_KEY:yS}=An(),{init:ES}=Mn(),AS=Wl(),{parseKey:rc}=jn(),{SFTP:bS}=ps(),{bufferCopy:p_,makeBufferParser:w_,makeError:xS,readUInt32BE:IS,sigSSHToASN1:vS,writeUInt32BE:ff}=Vr(),{AgentContext:h_,createAgent:g_,isAgent:m_}=Cl(),{Channel:P_,MAX_WINDOW:nc,PACKET_SIZE:ic,windowAdjust:__,WINDOW_THRESHOLD:y_}=af(),{ChannelManager:SS,generateAlgorithmList:_s,isWritable:nr,onChannelOpenFailure:wS,onCHANNEL_CLOSE:PS}=lf(),ec=w_(),tc=w_(),ys=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,pf=c(t=>{},"noop"),hf=class extends lS{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&&nr(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,u_,mS),r.kex!==u_&&(n=!1),r.serverHostKey=_s(e.algorithms.serverHostKey,f_,yS),r.serverHostKey!==f_&&(n=!1),r.cs.cipher=_s(e.algorithms.cipher,a_,hS),r.cs.cipher!==a_&&(n=!1),r.cs.mac=_s(e.algorithms.hmac,l_,_S),r.cs.mac!==l_&&(n=!1),r.cs.compress=_s(e.algorithms.compress,c_,gS),r.cs.compress!==c_&&(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=g_(e.agent):m_(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 SS(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 k=e.hostVerifier,W;fS.indexOf(e.hostHash)!==-1&&(W=e.hostHash),u=c((q,ee)=>{W&&(q=oS(W).update(q).digest("hex"));let ue=k(q,ee);ue!==void 0&&ee(ue)},"hostVerifier")}let l=this._sock=e.sock||new cS,d=!1,p=!1;this._protocol&&this._protocol.cleanup();let g=o?(k,W,q)=>{o(`Debug output from server: ${JSON.stringify(q)}`)}:void 0,h,_=this._protocol=new AS({ident:this.config.ident,offer:n?void 0:r,onWrite:c(k=>{nr(l)&&l.write(k)},"onWrite"),onError:c(k=>{k.level==="handshake"&&clearTimeout(this._readyTimeout),_._destruct||l.removeAllListeners("data"),this.emit("error",k);try{l.end()}catch{}},"onError"),onHeader:c(k=>{p=!0,this._remoteVer=k.versions.software,k.greeting&&this.emit("greeting",k.greeting)},"onHeader"),onHandshakeComplete:c(k=>{this.emit("handshake",k),d||(d=!0,_.service("ssh-userauth"))},"onHandshakeComplete"),debug:o,hostVerifier:u,messageHandlers:{DEBUG:g,DISCONNECT:c((k,W,q)=>{if(W!==d_.BY_APPLICATION){q||(q=pS[W],q===void 0&&(q=`Unexpected disconnection reason: ${W}`));let ee=new Error(q);ee.code=W,this.emit("error",ee)}l.end()},"DISCONNECT"),SERVICE_ACCEPT:c((k,W)=>{W==="ssh-userauth"&&B()},"SERVICE_ACCEPT"),EXT_INFO:c((k,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((k,W)=>{this.emit("banner",W)},"USERAUTH_BANNER"),USERAUTH_SUCCESS:c(k=>{D(),clearTimeout(this._readyTimeout),this.emit("ready")},"USERAUTH_SUCCESS"),USERAUTH_FAILURE:c((k,W,q)=>{if(P.keyAlgos){let ee=P.keyAlgos[0][0];if(o&&o(`Client: ${P.type} (${ee}) 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,xt)=>{let kt=P.key.sign(he,me);if(kt instanceof Error)return kt.message=`Error while signing with key: ${kt.message}`,kt.level="client-authentication",this.emit("error",kt),B();xt(kt)});return}}else P.keyAlgos=void 0}if(P.type==="agent"){let ee=P.agentCtx.pos();return o&&o(`Client: Agent key #${ee+1} failed`),Z()}o&&o(`Client: ${P.type} auth failed`),C=q,M=W,B()},"USERAUTH_FAILURE"),USERAUTH_PASSWD_CHANGEREQ:c((k,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(k=>{let W,q;if(P.keyAlgos&&([W,q]=P.keyAlgos[0]),P.type==="agent"){let ee=P.agentCtx.currentKey();_.authPK(P.username,ee,W,(ue,me)=>{let he={hash:q};P.agentCtx.sign(ee,ue,he,(xt,kt)=>{if(xt)xt.level="agent",this.emit("error",xt);else return me(kt);Z()})})}else P.type==="publickey"&&_.authPK(P.username,P.key,W,(ee,ue)=>{let me=P.key.sign(ee,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((k,W,q,ee)=>{if(P.type==="keyboard-interactive"){if((Array.isArray(ee)?ee.length:0)===0){o&&o("Client: Sending automatic USERAUTH_INFO_RESPONSE"),_.authInfoRes();return}P.prompt(W,q,"",ee,me=>{_.authInfoRes(me)})}},"USERAUTH_INFO_REQUEST"),REQUEST_SUCCESS:c((k,W)=>{s.length&&s.shift()(!1,W)},"REQUEST_SUCCESS"),REQUEST_FAILURE:c(k=>{s.length&&s.shift()(!0)},"REQUEST_FAILURE"),GLOBAL_REQUEST:c((k,W,q,ee)=>{W==="hostkeys-00@openssh.com"?(NS(this,ee,(ue,me)=>{ue||this.emit("hostkeys",me)}),q&&_.requestSuccess()):q&&_.requestFailure()},"GLOBAL_REQUEST"),CHANNEL_OPEN:c((k,W)=>{kS(this,W)},"CHANNEL_OPEN"),CHANNEL_OPEN_CONFIRMATION:c((k,W)=>{let q=this._chanMgr.get(W.recipient);if(typeof q!="function")return;let ee=q.type==="sftp",me={type:ee?"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=ee?new bS(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((k,W,q,ee)=>{let ue=this._chanMgr.get(W);if(typeof ue!="function")return;wS(this,W,{reason:q,description:ee},ue)},"CHANNEL_OPEN_FAILURE"),CHANNEL_DATA:c((k,W,q)=>{let ee=this._chanMgr.get(W);if(!(typeof ee!="object"||ee===null)&&ee.incoming.window!==0){if(ee.incoming.window-=q.length,ee.push(q)===!1){ee._waitChanDrain=!0;return}ee.incoming.window<=y_&&__(ee)}},"CHANNEL_DATA"),CHANNEL_EXTENDED_DATA:c((k,W,q,ee)=>{if(ee!==dS)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<=y_&&__(ue)}},"CHANNEL_EXTENDED_DATA"),CHANNEL_WINDOW_ADJUST:c((k,W,q)=>{let ee=this._chanMgr.get(W);typeof ee!="object"||ee===null||(ee.outgoing.window+=q,ee._waitWindow&&(ee._waitWindow=!1,ee._chunk?ee._write(ee._chunk,null,ee._chunkcb):ee._chunkcb?ee._chunkcb():ee._chunkErr?ee.stderr._write(ee._chunkErr,null,ee._chunkcbErr):ee._chunkcbErr&&ee._chunkcbErr()))},"CHANNEL_WINDOW_ADJUST"),CHANNEL_SUCCESS:c((k,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((k,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((k,W,q,ee,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}ee&&k.channelFailure(me.outgoing.id)}},"CHANNEL_REQUEST"),CHANNEL_EOF:c((k,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((k,W)=>{PS(this,W,this._chanMgr.get(W))},"CHANNEL_CLOSE")}});l.pause();let b=this.config.keepaliveInterval,E=this.config.keepaliveCountMax,v=0,w,H=c(()=>{if(++v>E){if(clearInterval(w),l.readable){let k=new Error("Keepalive timeout");k.level="client-timeout",this.emit("error",k),l.destroy()}return}nr(l)?(s.push(D),_.ping()):clearInterval(w)},"sendKA");function D(){b>0&&(v=0,clearInterval(w),nr(l)&&(w=setInterval(H,b)))}c(D,"resetKA"),this._resetKA=D;let J=(()=>{let k=!1;return()=>{if(!k&&(k=!0,X&&!p)){let W=xS("Connection lost before handshake","protocol",!0);this.emit("error",W)}}})(),Y=(()=>{let k=!1;return()=>{k||(k=!0,X=!0,o&&o("Socket connected"),this.emit("connect"),ES.then(()=>{_.start(),l.on("data",W=>{try{_.parse(W,0,W.length)}catch(q){this.emit("error",q);try{nr(l)&&l.end()}catch{}}}),l.stderr&&typeof l.stderr.resume=="function"&&l.stderr.resume(),l.resume()}).catch(W=>{this.emit("error",W);try{nr(l)&&l.end()}catch{}}))}})(),X=!1;l.on("connect",Y).on("timeout",()=>{this.emit("timeout")}).on("error",k=>{o&&o(`Socket error: ${k.message}`),clearTimeout(this._readyTimeout),k.level="client-socket",this.emit("error",k)}).on("end",()=>{o&&o("Socket ended"),J(),_.cleanup(),clearTimeout(this._readyTimeout),clearInterval(w),this.emit("end")}).on("close",()=>{o&&o("Socket closed"),J(),_.cleanup(),clearTimeout(this._readyTimeout),clearInterval(w),this.emit("close");let k=s;s=this._callbacks=[];let W=new Error("No response from server");for(let q=0;q<k.length;++q)k[q](W);this._chanMgr.cleanup(W)});let P,C=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=v_(i):typeof i!="function"&&(i=v_(L));let T=!1,F=c(k=>{if(!T){if(T=!0,k===!1){let W=new Error("All configured authentication methods failed");W.level="client-authentication",this.emit("error",W),this.end();return}if(typeof k=="string"){let W=k;if(L.indexOf(W)===-1)return j(`Authentication method not allowed: ${W}`);let q=this.config.username;switch(W){case"password":k={type:W,username:q,password:this.config.password};break;case"publickey":k={type:W,username:q,key:a};break;case"hostbased":k={type:W,username:q,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":k={type:W,username:q,agentCtx:new h_(this._agent)};break;case"keyboard-interactive":k={type:W,username:q,prompt:c((...ee)=>this.emit("keyboard-interactive",...ee),"prompt")};break;case"none":k={type:W,username:q};break;default:return j(`Skipping unsupported authentication method: ${k}`)}}else{if(typeof k!="object"||k===null)return j(`Skipping invalid authentication attempt: ${k}`);{let W=k.username;if(typeof W!="string")return j(`Skipping invalid authentication attempt: ${k}`);let q=k.type;switch(q){case"password":{let{password:ee}=k;if(typeof ee!="string"&&!Buffer.isBuffer(ee))return j("Skipping invalid password auth attempt");k={type:q,username:W,password:ee};break}case"publickey":{let ee=rc(k.key,k.passphrase);if(ee instanceof Error)return j("Skipping invalid key auth attempt");if(!ee.isPrivateKey())return j("Skipping non-private key");k={type:q,username:W,key:ee};break}case"hostbased":{let{localHostname:ee,localUsername:ue}=k,me=rc(k.key,k.passphrase);if(me instanceof Error||typeof ee!="string"||typeof ue!="string")return j("Skipping invalid hostbased auth attempt");if(!me.isPrivateKey())return j("Skipping non-private key");k={type:q,username:W,key:me,localHostname:ee,localUsername:ue};break}case"agent":{let ee=k.agent;if(typeof ee=="string"&&ee.length)ee=g_(ee);else if(!m_(ee))return j(`Skipping invalid agent: ${k.agent}`);k={type:q,username:W,agentCtx:new h_(ee)};break}case"keyboard-interactive":{let{prompt:ee}=k;if(typeof ee!="function")return j("Skipping invalid keyboard-interactive auth attempt");k={type:q,username:W,prompt:ee};break}case"none":k={type:q,username:W};break;default:return j(`Skipping unsupported authentication method: ${k}`)}}}P=k;try{let W=P.username;switch(P.type){case"password":_.authPassword(W,P.password);break;case"publickey":{let q;if(P.keyAlgos=df(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,ee;if(P.keyAlgos=df(this,P.key,h),P.keyAlgos)if(P.keyAlgos.length)[q,ee]=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,ee);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();Z()});break;case"keyboard-interactive":_.authKeyboard(W);break;case"none":_.authNone(W);break}}finally{T=!1}}},"doNextAuth");function j(k){o&&o(k),process.nextTick(B)}c(j,"skipAuth");function B(){T=!1;let k=i(M,C,F);T||k===void 0||F(k)}c(B,"tryNextAuth");let Z=c(()=>{if(P.type==="agent"){let k=P.agentCtx.nextKey();if(k===!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=df(this,k,h),P.keyAlgos)if(P.keyAlgos.length)q=P.keyAlgos[0][0];else{o&&o(`Agent: Skipping key #${W+1} (no mutual hash algorithm)`),Z();return}o&&o(`Agent: Trying key #${W+1}`),_.authPK(P.username,k,q)}}},"tryNextAgentKey"),te=c(()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let k=new Error("Timed out while waiting for handshake");k.level="client-timeout",this.emit("error",k),l.destroy()},this.config.readyTimeout))},"startTimeout");if(e.sock)te(),typeof l.connecting=="boolean"&&l.connecting||Y();else{let k=this.config.host,W=this.config.forceIPv4,q=this.config.forceIPv6;o&&o(`Client: Trying ${k} on port ${this.config.port} ...`);let ee=c(()=>{te(),l.connect({host:k,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?ee():uS(k,W?4:6,(ue,me,he)=>{if(ue){let xt=W?"IPv4":"IPv6",kt=new Error(`Error while looking up ${xt} address for '${k}': ${ue}`);clearTimeout(this._readyTimeout),kt.level="client-dns",this.emit("error",kt),this.emit("close");return}k=me,ee()})}return this}end(){return this._sock&&nr(this._sock)&&(this._protocol.disconnect(d_.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&nr(this._sock)&&this._sock.destroy(),this}exec(e,r,n){if(!this._sock||!nr(this._sock))throw new Error("Not connected");typeof r=="function"&&(n=r,r={});let i={allowHalfOpen:r.allowHalfOpen!==!1};return so(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(()=>b_(s,u)),typeof r=="object"&&r!==null&&(typeof r.env=="object"&&r.env!==null&&x_(s,r.env),(typeof r.pty=="object"&&r.pty!==null||r.pty===!0)&&a.push(()=>A_(s,r.pty,u)),(typeof r.x11=="object"&&r.x11!==null||r.x11==="number"||r.x11===!0)&&a.push(()=>E_(s,r.x11,u))),a.push(()=>CS(s,e,r,n)),a.shift()()}),this}shell(e,r,n){if(!this._sock||!nr(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),so(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(()=>b_(o,a)),e!==!1&&s.push(()=>A_(o,e,a)),typeof r=="object"&&r!==null&&(typeof r.env=="object"&&r.env!==null&&x_(o,r.env),(typeof r.x11=="object"&&r.x11!==null||r.x11==="number"||r.x11===!0)&&s.push(()=>E_(o,r.x11,a))),s.push(()=>TS(o,n)),s.shift()()}),this}subsys(e,r){if(!this._sock||!nr(this._sock))throw new Error("Not connected");return so(this,"session",(n,i)=>{if(n){r(n);return}I_(i,e,(o,s)=>{if(o){r(o);return}r(void 0,s)})}),this}forwardIn(e,r,n){if(!this._sock||!nr(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=IS(s,0),this._protocol._compatFlags&S_.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||!nr(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||!nr(this._sock))throw new Error("Not connected");let s={srcIP:e,srcPort:r,dstIP:n,dstPort:i};return typeof o!="function"&&(o=pf),so(this,"direct-tcpip",s,o),this}openssh_noMoreSessions(e){if(!this._sock||!nr(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||!nr(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||!nr(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||!nr(this._sock))throw new Error("Not connected");return typeof r!="function"&&(r=pf),!this.config.strictVendor||this.config.strictVendor&&ys.test(this._remoteVer)?(so(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||!nr(this._sock))throw new Error("Not connected");return so(this,"sftp",(r,n)=>{if(r){e(r);return}I_(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 so(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(so,"openChannel");function E_(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=RS());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(E_,"reqX11");function A_(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(A_,"reqPty");function b_(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(b_,"reqAgentFwd");function TS(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(TS,"reqShell");function CS(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(CS,"reqExec");function x_(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(x_,"reqEnv");function I_(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(I_,"reqSubsystem");function kS(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 P_(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(kS,"onCHANNEL_OPEN");var RS=(()=>{let t=Buffer.allocUnsafe(16);return()=>(aS(t,0,16),t.hexSlice(0,16))})();function v_(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(v_,"makeSimpleAuthHandler");function NS(t,e,r){if(!t._sock||!nr(t._sock))return;if(typeof r!="function"&&(r=pf),!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,b=Buffer.allocUnsafe(37+_.length+4+l.length),E=0;ff(b,29,E),b.utf8Write("hostkeys-prove-00@openssh.com",E+=4,29),ff(b,_.length,E+=29),p_(_,b,0,_.length,E+=4),ff(b,l.length,E+=_.length),p_(l,b,0,l.length,E+=4),(g=vS(g,p))&&u.verify(b,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(NS,"hostKeysProve");function df(t,e,r){switch(e.type){case"ssh-rsa":if(t._protocol._compatFlags&S_.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(df,"getKeyAlgos");T_.exports=hf});var k_=le(C_=>{"use strict";var{Agent:_f}=require("http"),{Agent:OS}=require("https"),{connect:$S}=require("tls"),mf;for(let t of[_f,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;mf===void 0&&(mf=gf());let l=new mf,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,DS(g,t,n))})}).on("error",i).on("close",()=>{d||i(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}C_[t===_f?"SSHTTPAgent":"SSHTTPSAgent"]=e}function Es(){}c(Es,"noop");function DS(t,e,r){if(e===_f)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=$S(r),i=(()=>{let o=!1;return()=>{o||(o=!0,t.isPaused()&&t.resume())}})();return n.on("end",i).on("close",i),n}c(DS,"decorateStream")});var N_=le((i5,bf)=>{"use strict";var{Server:BS}=require("net"),bs=require("events"),{listenerCount:Er}=bs,{CHANNEL_OPEN_FAILURE:ao,DEFAULT_CIPHER:US,DEFAULT_COMPRESSION:LS,DEFAULT_KEX:zS,DEFAULT_MAC:MS,DEFAULT_SERVER_HOST_KEY:FS,DISCONNECT_REASON:co,DISCONNECT_REASON_BY_VALUE:HS,SUPPORTED_CIPHER:jS,SUPPORTED_COMPRESSION:WS,SUPPORTED_KEX:qS,SUPPORTED_MAC:QS,SUPPORTED_SERVER_HOST_KEY:VS}=An(),{init:KS}=Mn(),{KexInit:GS}=Fa(),{parseKey:R_}=jn(),ZS=Wl(),{SFTP:YS}=ps(),{writeUInt32BE:XS}=Vr(),{Channel:uo,MAX_WINDOW:Qn,PACKET_SIZE:Vn,windowAdjust:JS,WINDOW_THRESHOLD:ew}=af(),{ChannelManager:tw,generateAlgorithmList:As,isWritable:oc,onChannelOpenFailure:rw,onCHANNEL_CLOSE:nw}=lf(),iw=10,Kn=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 Kn{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)}},Ef=class extends Kn{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?Kn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},Af=class extends Kn{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 Kn{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:Vn,state:"open"},outgoing:{id:r.sender,window:r.window,packetSize:r.packetSize,state:"open"}}}},Dr=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,FS,VS);for(let g=0;g<o.length;++g){let h;if(Buffer.isBuffer(o[g])||typeof o[g]=="string"?h=R_(o[g]):h=R_(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"),b=a.indexOf("rsa-sha2-256"),E=a.indexOf("rsa-sha2-512");_===-1&&(_=1/0),[_,b,E].sort(ow).forEach(v=>{if(v===-1)return;let w;switch(v){case _:w="ssh-rsa";break;case b:w="rsa-sha2-256";break;case E: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,zS,qS).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:i,cs:{cipher:As(s.cipher,US,jS),mac:As(s.hmac,MS,QS),compress:As(s.compress,LS,WS),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 GS(u);this._srv=new BS(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(b=>{l(`${_}${b}`)},"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}};Dr.KEEPALIVE_CLIENT_INTERVAL=15e3;Dr.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 tw(this),this._debug=o,this.noMoreSessions=!1,this.authenticated=!1;function b(X){}c(b,"onClientPreHeaderError"),this.on("error",b);let E=o?(X,P,C)=>{o(`Debug output from client: ${JSON.stringify(C)}`)}:void 0,v=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof Dr.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(Dr.KEEPALIVE_CLIENT_INTERVAL)&&Dr.KEEPALIVE_CLIENT_INTERVAL>0?Dr.KEEPALIVE_CLIENT_INTERVAL:-1,w=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof Dr.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(Dr.KEEPALIVE_CLIENT_COUNT_MAX)&&Dr.KEEPALIVE_CLIENT_COUNT_MAX>=0?Dr.KEEPALIVE_CLIENT_COUNT_MAX:-1,H=0;v!==-1&&w!==-1&&(this.once("ready",()=>{let X=c(()=>{clearInterval(g)},"onClose");this.on("close",X).on("end",X),g=setInterval(()=>{if(++H>w){clearInterval(g);let P=new Error("Keepalive timeout");P.level="client-timeout",this.emit("error",P),this.end()}else D.ping()},v)}),h=c(()=>{g&&g.refresh(),H=0},"onPacket"));let D=this._protocol=new ZS({server:!0,hostKeys:r,ident:n,offer:i,onPacket:h,greeting:a.greeting,banner:a.banner,onWrite:c(X=>{oc(e)&&e.write(X)},"onWrite"),onError:c(X=>{D._destruct||e.removeAllListeners("data"),this.emit("error",X);try{e.end()}catch{}},"onError"),onHeader:c(X=>{this.removeListener("error",b);let P={ip:e.remoteAddress,family:e.remoteFamily,port:e.remotePort,header:X};if(!s.emit("connection",this,P)){D.disconnect(co.BY_APPLICATION),e.end();return}X.greeting&&this.emit("greeting",X.greeting)},"onHeader"),onHandshakeComplete:c(X=>{++u>1&&this.emit("rekey"),this.emit("handshake",X)},"onHandshakeComplete"),debug:o,messageHandlers:{DEBUG:E,DISCONNECT:c((X,P,C)=>{if(P!==co.BY_APPLICATION){C||(C=HS[P],C===void 0&&(C=`Unexpected disconnection reason: ${P}`));let M=new Error(C);M.code=P,this.emit("error",M)}e.end()},"DISCONNECT"),CHANNEL_OPEN:c((X,P)=>{if(P.type==="session"&&this.noMoreSessions||!this.authenticated){let Z=ao.ADMINISTRATIVELY_PROHIBITED;return D.channelOpenFail(P.sender,Z)}let C=-1,M,L=!1,T,F=c(()=>{L||(L=!0,M===void 0&&(C===-1?M=ao.RESOURCE_SHORTAGE:M=ao.CONNECT_FAILED),C!==-1&&this._chanMgr.remove(C),D.channelOpenFail(P.sender,M,""))},"reject"),j=c(()=>(C=this._chanMgr.add(),C===-1&&(M=ao.RESOURCE_SHORTAGE,o&&o("Automatic rejection of incoming channel open: no channels available")),C!==-1),"reserveChannel"),B=P.data;switch(P.type){case"session":if(Er(this,"session")&&j()){T=c(()=>{if(L)return;L=!0;let Z=new an(this,P,C);return this._chanMgr.update(C,Z),D.channelOpenConfirm(P.sender,C,Qn,Vn),Z},"accept"),this.emit("session",T,F);return}break;case"direct-tcpip":if(Er(this,"tcpip")&&j()){T=c(()=>{if(L)return;L=!0;let Z={type:void 0,incoming:{id:C,window:Qn,packetSize:Vn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},te=new uo(this,Z,{server:!0});return this._chanMgr.update(C,te),D.channelOpenConfirm(P.sender,C,Qn,Vn),te},"accept"),this.emit("tcpip",T,F,B);return}break;case"direct-streamlocal@openssh.com":if(Er(this,"openssh.streamlocal")&&j()){T=c(()=>{if(L)return;L=!0;let Z={type:void 0,incoming:{id:C,window:Qn,packetSize:Vn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},te=new uo(this,Z,{server:!0});return this._chanMgr.update(C,te),D.channelOpenConfirm(P.sender,C,Qn,Vn),te},"accept"),this.emit("openssh.streamlocal",T,F,B);return}break;default:M=ao.UNKNOWN_CHANNEL_TYPE,o&&o(`Automatic rejection of unsupported incoming channel open type: ${P.type}`)}M===void 0&&(M=ao.ADMINISTRATIVELY_PROHIBITED,o&&o(`Automatic rejection of unexpected incoming channel open for: ${P.type}`)),F()},"CHANNEL_OPEN"),CHANNEL_OPEN_CONFIRMATION:c((X,P)=>{let C=this._chanMgr.get(P.recipient);if(typeof C!="function")return;let M={type:C.type,incoming:{id:P.recipient,window:Qn,packetSize:Vn,state:"open"},outgoing:{id:P.sender,window:P.window,packetSize:P.packetSize,state:"open"}},L=new uo(this,M,{server:!0});this._chanMgr.update(P.recipient,L),C(void 0,L)},"CHANNEL_OPEN_CONFIRMATION"),CHANNEL_OPEN_FAILURE:c((X,P,C,M)=>{let L=this._chanMgr.get(P);if(typeof L!="function")return;rw(this,P,{reason:C,description:M},L)},"CHANNEL_OPEN_FAILURE"),CHANNEL_DATA:c((X,P,C)=>{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-=C.length,M.push(C)===!1){M._waitChanDrain=!0;return}M.incoming.window<=ew&&JS(M)}},"CHANNEL_DATA"),CHANNEL_EXTENDED_DATA:c((X,P,C,M)=>{},"CHANNEL_EXTENDED_DATA"),CHANNEL_WINDOW_ADJUST:c((X,P,C)=>{let M=this._chanMgr.get(P);typeof M!="object"||M===null||M.constructor===an&&(M=M._channel,!M)||(M.outgoing.window+=C,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((X,P)=>{let C=this._chanMgr.get(P);typeof C!="object"||C===null||C.constructor===an&&(C=C._channel,!C)||C._callbacks.length&&C._callbacks.shift()(!1)},"CHANNEL_SUCCESS"),CHANNEL_FAILURE:c((X,P)=>{let C=this._chanMgr.get(P);typeof C!="object"||C===null||C.constructor===an&&(C=C._channel,!C)||C._callbacks.length&&C._callbacks.shift()(!0)},"CHANNEL_FAILURE"),CHANNEL_REQUEST:c((X,P,C,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&&D.channelFailure(T.outgoing.id);return}if(M&&(C!=="shell"&&C!=="exec"&&C!=="subsystem"&&(j=c(()=>{F||T._ending||T._channel||(F=!0,D.channelSuccess(T._chanInfo.outgoing.id))},"accept")),B=c(()=>{F||T._ending||T._channel||(F=!0,D.channelFailure(T._chanInfo.outgoing.id))},"reject")),T._ending){B&&B();return}switch(C){case"env":if(Er(T,"env")){T.emit("env",j,B,{key:L.name,val:L.value});return}break;case"pty-req":if(Er(T,"pty")){T.emit("pty",j,B,L);return}break;case"window-change":Er(T,"window-change")?T.emit("window-change",j,B,L):B&&B();break;case"x11-req":if(Er(T,"x11")){T.emit("x11",j,B,L);return}break;case"signal":if(Er(T,"signal")){T.emit("signal",j,B,{name:L});return}break;case"auth-agent-req@openssh.com":if(Er(T,"auth-agent")){T.emit("auth-agent",j,B);return}break;case"shell":if(Er(T,"shell")){j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&D.channelSuccess(T._chanInfo.outgoing.id);let Z=new uo(this,T._chanInfo,{server:!0});return Z.subtype=T.subtype=C,T._channel=Z,Z},"accept"),T.emit("shell",j,B);return}break;case"exec":if(Er(T,"exec")){j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&D.channelSuccess(T._chanInfo.outgoing.id);let Z=new uo(this,T._chanInfo,{server:!0});return Z.subtype=T.subtype=C,T._channel=Z,Z},"accept"),T.emit("exec",j,B,{command:L});return}break;case"subsystem":{let Z=L==="sftp";if(j=c(()=>{if(F||T._ending||T._channel)return;F=!0,M&&D.channelSuccess(T._chanInfo.outgoing.id);let te;return Z?te=new YS(this,T._chanInfo,{server:!0,debug:o}):(te=new uo(this,T._chanInfo,{server:!0}),te.subtype=T.subtype=`${C}:${L}`),T._channel=te,te},"accept"),L==="sftp"){if(Er(T,"sftp")){T.emit("sftp",j,B);return}Z=!1}if(Er(T,"subsystem")){T.emit("subsystem",j,B,{name:L});return}break}}o&&o(`Automatic rejection of incoming channel request: ${C}`),B&&B()},"CHANNEL_REQUEST"),CHANNEL_EOF:c((X,P)=>{let C=this._chanMgr.get(P);typeof C!="object"||C===null||C.constructor===an&&(C._ending||(C._ending=!0,C.emit("eof"),C.emit("end")),C=C._channel,!C)||C.incoming.state==="open"&&(C.incoming.state="eof",C.readable&&C.push(null))},"CHANNEL_EOF"),CHANNEL_CLOSE:c((X,P)=>{let C=this._chanMgr.get(P);typeof C!="object"||C===null||C.constructor===an&&(C._ending=!0,C.emit("close"),C=C._channel,!C)||nw(this,P,C)},"CHANNEL_CLOSE"),SERVICE_REQUEST:c((X,P)=>{if(u===0||l||this.authenticated||P!=="ssh-userauth"){D.disconnect(co.SERVICE_NOT_AVAILABLE),e.end();return}l=!0,D.serviceAccept(P)},"SERVICE_REQUEST"),USERAUTH_REQUEST:c((X,P,C,M,L)=>{if(u===0||this.authenticated||p&&(p.username!==P||p.service!==C)||M!=="password"&&M!=="publickey"&&M!=="hostbased"&&M!=="keyboard-interactive"&&M!=="none"||d.length===iw){D.disconnect(co.PROTOCOL_ERROR),e.end();return}else if(C!=="ssh-connection"){D.disconnect(co.SERVICE_NOT_AVAILABLE),e.end();return}let T;switch(M){case"keyboard-interactive":T=new sc(D,P,C,M,L,J);break;case"publickey":T=new Ef(D,P,C,M,L,J);break;case"hostbased":T=new Af(D,P,C,M,L,J);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(D,P,C,M,L,J);break;case"none":T=new Kn(D,P,C,M,J);break}if(p)if(p._initialResponse)p._multistep&&!p._finalResponse&&(p._cleanup&&p._cleanup(),p.emit("abort"));else return d.push(T);p=T,Er(this,"authentication")?this.emit("authentication",p):p.reject()},"USERAUTH_REQUEST"),USERAUTH_INFO_RESPONSE:c((X,P)=>{p&&p instanceof sc&&p._onInfoResponse(P)},"USERAUTH_INFO_RESPONSE"),GLOBAL_REQUEST:c((X,P,C,M)=>{let L={type:null,buf:null};function T(F,j){L.type=F,L.buf=j,Y()}if(c(T,"setReply"),C&&_.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")&&Er(this,"request")&&this.authenticated){let F,j;if(C){let B=!1;F=c(Z=>{if(B)return;B=!0;let te;P==="tcpip-forward"&&M.bindPort===0&&typeof Z=="number"&&(te=Buffer.allocUnsafe(4),XS(te,Z,0)),T("SUCCESS",te)},"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 C&&T("FAILURE")},"GLOBAL_REQUEST")}});e.pause(),KS.then(()=>{D.start(),e.on("data",X=>{try{D.parse(X,0,X.length)}catch(P){this.emit("error",P);try{oc(e)&&e.end()}catch{}}}),e.resume()}).catch(X=>{this.emit("error",X);try{oc(e)&&e.end()}catch{}}),e.on("error",X=>{X.level="socket",this.emit("error",X)}).once("end",()=>{o&&o("Socket ended"),D.cleanup(),this.emit("end")}).once("close",()=>{o&&o("Socket closed"),D.cleanup(),this.emit("close");let X=new Error("No response from server");this._chanMgr.cleanup(X)});let J=c((X,P,C,M)=>{p===X&&!this.authenticated&&(P?(p=void 0,this.authenticated=!0,D.authSuccess(),d=[],this.emit("ready")):(D.authFailure(C,M),d.length&&(p=d.pop(),Er(this,"authentication")?this.emit("authentication",p):p.reject())))},"onAuthDecide");function Y(){for(;_.length>0&&_[0].type;){let X=_.shift();X.type==="SUCCESS"&&D.requestSuccess(X.buf),X.type==="FAILURE"&&D.requestFailure()}}c(Y,"sendReplies")}end(){return this._sock&&oc(this._sock)&&(this._protocol.disconnect(co.BY_APPLICATION),this._sock.end()),this}x11(e,r,n){return yf(this,"x11",{originAddr:e,originPort:r},n),this}forwardOut(e,r,n,i,o){return yf(this,"forwarded-tcpip",{boundAddr:e,boundPort:r,remoteAddr:n,remotePort:i},o),this}openssh_forwardOutStreamLocal(e,r){return yf(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 yf(t,e,r,n){let i=Qn,o=Vn;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(yf,"openChannel");function ow(t,e){return t-e}c(ow,"compareNumbers");bf.exports=Dr;bf.exports.IncomingClient=cc});var U_=le((s5,B_)=>{"use strict";var{createCipheriv:sw,generateKeyPair:aw,generateKeyPairSync:cw,getCurves:uw,randomBytes:O_}=require("crypto"),{Ber:Ot}=Ko(),lw=Fu().pbkdf,{CIPHER_INFO:fw}=Mn(),dw=16,pw=16,hw=uw(),gw=new Map(Object.entries(fw));function $_(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(!hw.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($_,"makeArgs");function mw(t,e,r){switch(t){case"rsa":{let n=new Ot.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()!==Ot.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 Ot.Reader(n.readString(Ot.OctetString,!0)),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in RSA private key");let i=n.readString(Ot.Integer,!0),o=n.readString(Ot.Integer,!0),s=n.readString(Ot.Integer,!0),a=n.readString(Ot.Integer,!0),u=n.readString(Ot.Integer,!0);n.readString(Ot.Integer,!0),n.readString(Ot.Integer,!0);let l=n.readString(Ot.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 Ot.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(Ot.BitString,!0);{let g=0;for(;g<i.length&&i[g]===0;++g);g>0&&(i=i.slice(g))}if(n=new Ot.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 Ot.Reader(n.readString(Ot.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(Ot.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 Ot.Reader(e);if(n.readSequence(),n.readSequence(),n.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let i=n.readString(Ot.BitString,!0);{let d=0;for(;d<i.length&&i[d]===0;++d);d>0&&(i=i.slice(d))}if(n=new Ot.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 Ot.Reader(n.readString(Ot.OctetString,!0));let o=n.readString(Ot.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(mw,"parseDERs");function D_(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=gw.get(n.cipher);if(u===void 0)throw new Error("Invalid cipher name");if(i==="new"){let l=pw;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=O_(dw);if(lw(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=mw(t,e,r),_=O_(4),b=Buffer.from(s),E=8+h.priv.length+4+b.length,v=[];for(let Y=1;(E+v.length)%g;++Y)v.push(Y&255);v=Buffer.from(v);let w=Buffer.allocUnsafe(E+v.length),H;{let Y=0;w.set(_,Y+=0),w.set(_,Y+=4),w.set(h.priv,Y+=4),w.writeUInt32BE(b.length,Y+=h.priv.length),w.set(b,Y+=4),w.set(v,Y+=b.length)}if(o){let Y={authTagLength:o.cipher.authLen},X=sw(o.cipher.sslName,o.key,o.iv,Y);X.setAutoPadding(!1),w=Buffer.concat([X.update(w),X.final()]),o.cipher.authLen>0?H=X.getAuthTag():H=Buffer.alloc(0),o.key.fill(0),o.iv.fill(0)}else H=Buffer.alloc(0);let D=Buffer.from("openssh-key-v1\0"),J=Buffer.allocUnsafe(D.length+4+l.length+4+d.length+4+p.length+4+4+h.pub.length+4+w.length+H.length);{let Y=0;J.set(D,Y+=0),J.writeUInt32BE(l.length,Y+=D.length),J.set(l,Y+=4),J.writeUInt32BE(d.length,Y+=l.length),J.set(d,Y+=4),J.writeUInt32BE(p.length,Y+=d.length),J.set(p,Y+=4),J.writeUInt32BE(1,Y+=p.length),J.writeUInt32BE(h.pub.length,Y+=4),J.set(h.pub,Y+=4),J.writeUInt32BE(w.length,Y+=h.pub.length),J.set(w,Y+=4),J.set(H,Y+=w.length)}{let Y=J.base64Slice(0,J.length),X=Y.replace(/.{64}/g,`$&
|
|
21
|
+
`);Y.length&63&&(X+=`
|
|
22
|
+
`),a+=X}{let Y=h.pub.base64Slice(0,h.pub.length);u=`${h.sshName} ${Y}${s?` ${s}`:""}`}return a+=`-----END OPENSSH PRIVATE KEY-----
|
|
23
|
+
`,{private:a,public:u}}default:throw new Error("Invalid output key format")}}c(D_,"convertKeys");function _w(){}c(_w,"noop");B_.exports={generateKeyPair:c((t,e,r)=>{typeof e=="function"&&(r=e,e=void 0),typeof r!="function"&&(r=_w);let n=$_(t,e);aw(...n,(i,o,s)=>{if(i)return r(i);let a;try{a=D_(n[0],o,s,e)}catch(u){return r(u)}r(null,a)})},"generateKeyPair"),generateKeyPairSync:c((t,e)=>{let r=$_(t,e),{publicKey:n,privateKey:i}=cw(...r);return D_(r[0],n,i,e)},"generateKeyPairSync")}});var z_=le((c5,L_)=>{"use strict";var{AgentProtocol:yw,BaseAgent:Ew,createAgent:Aw,CygwinAgent:bw,OpenSSHAgent:xw,PageantAgent:Iw}=Cl(),{SSHTTPAgent:vw,SSHTTPSAgent:Sw}=k_(),{parseKey:ww}=jn(),{flagsToString:Pw,OPEN_MODE:Tw,STATUS_CODE:Cw,stringToFlags:kw}=ps();L_.exports={AgentProtocol:yw,BaseAgent:Ew,createAgent:Aw,Client:gf(),CygwinAgent:bw,HTTPAgent:vw,HTTPSAgent:Sw,OpenSSHAgent:xw,PageantAgent:Iw,Server:N_(),utils:{parseKey:ww,...U_(),sftp:{flagsToString:Pw,OPEN_MODE:Tw,STATUS_CODE:Cw,stringToFlags:kw}}}});var xf=le((u5,M_)=>{M_.exports=require("stream")});var Q_=le((l5,q_)=>{"use strict";function F_(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(F_,"ownKeys");function H_(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?F_(Object(r),!0).forEach(function(n){Rw(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):F_(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}c(H_,"_objectSpread");function Rw(t,e,r){return e=W_(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(Rw,"_defineProperty");function Nw(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}c(Nw,"_classCallCheck");function j_(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,W_(n.key),n)}}c(j_,"_defineProperties");function Ow(t,e,r){return e&&j_(t.prototype,e),r&&j_(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}c(Ow,"_createClass");function W_(t){var e=$w(t,"string");return typeof e=="symbol"?e:String(e)}c(W_,"_toPropertyKey");function $w(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($w,"_toPrimitive");var Dw=require("buffer"),uc=Dw.Buffer,Bw=require("util"),If=Bw.inspect,Uw=If&&If.custom||"inspect";function Lw(t,e,r){uc.prototype.copy.call(t,e,r)}c(Lw,"copyBuffer");q_.exports=(function(){function t(){Nw(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 uc.alloc(0);for(var n=uc.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=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:Uw,value:c(function(r,n){return If(this,H_(H_({},n),{},{depth:0,customInspect:!1}))},"value")}]),t})()});var Sf=le((d5,K_)=>{"use strict";function zw(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(vf,this,t)):process.nextTick(vf,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(V_,r,o)):process.nextTick(V_,r,o):e?(process.nextTick(lc,r),e(o)):process.nextTick(lc,r)}),this)}c(zw,"destroy");function V_(t,e){vf(t,e),lc(t)}c(V_,"emitErrorAndCloseNT");function lc(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}c(lc,"emitCloseNT");function Mw(){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(Mw,"undestroy");function vf(t,e){t.emit("error",e)}c(vf,"emitErrorNT");function Fw(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}c(Fw,"errorOrDestroy");K_.exports={destroy:zw,undestroy:Mw,errorOrDestroy:Fw}});var Gn=le((h5,Y_)=>{"use strict";var Z_={};function jr(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,Z_[t]=i}c(jr,"createErrorType");function G_(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(G_,"oneOf");function Hw(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}c(Hw,"startsWith");function jw(t,e,r){return(r===void 0||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}c(jw,"endsWith");function Ww(t,e,r){return typeof r!="number"&&(r=0),r+e.length>t.length?!1:t.indexOf(e,r)!==-1}c(Ww,"includes");jr("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError);jr("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(jw(t," argument"))i=`The ${t} ${n} ${G_(e,"type")}`;else{let o=Ww(t,".")?"property":"argument";i=`The "${t}" ${o} ${n} ${G_(e,"type")}`}return i+=`. Received type ${typeof r}`,i},TypeError);jr("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");jr("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"});jr("ERR_STREAM_PREMATURE_CLOSE","Premature close");jr("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"});jr("ERR_MULTIPLE_CALLBACK","Callback called multiple times");jr("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");jr("ERR_STREAM_WRITE_AFTER_END","write after end");jr("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);jr("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError);jr("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Y_.exports.codes=Z_});var wf=le((m5,X_)=>{"use strict";var qw=Gn().codes.ERR_INVALID_OPT_VALUE;function Qw(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}c(Qw,"highWaterMarkFrom");function Vw(t,e,r,n){var i=Qw(e,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var o=n?r:"highWaterMark";throw new qw(o,i)}return Math.floor(i)}return t.objectMode?16:16*1024}c(Vw,"getHighWaterMark");X_.exports={getHighWaterMark:Vw}});var J_=le((y5,Pf)=>{typeof Object.create=="function"?Pf.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"):Pf.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((A5,Cf)=>{try{if(Tf=require("util"),typeof Tf.inherits!="function")throw"";Cf.exports=Tf.inherits}catch{Cf.exports=J_()}var Tf});var ty=le((b5,ey)=>{ey.exports=require("util").deprecate});var Nf=le((x5,ay)=>{"use strict";ay.exports=Gt;function ny(t){var e=this;this.next=null,this.entry=null,this.finish=function(){AP(e,t)}}c(ny,"CorkedRequest");var lo;Gt.WritableState=Is;var Kw={deprecate:ty()},iy=xf(),dc=require("buffer").Buffer,Gw=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function Zw(t){return dc.from(t)}c(Zw,"_uint8ArrayToBuffer");function Yw(t){return dc.isBuffer(t)||t instanceof Gw}c(Yw,"_isUint8Array");var Rf=Sf(),Xw=wf(),Jw=Xw.getHighWaterMark,Zn=Gn().codes,eP=Zn.ERR_INVALID_ARG_TYPE,tP=Zn.ERR_METHOD_NOT_IMPLEMENTED,rP=Zn.ERR_MULTIPLE_CALLBACK,nP=Zn.ERR_STREAM_CANNOT_PIPE,iP=Zn.ERR_STREAM_DESTROYED,oP=Zn.ERR_STREAM_NULL_VALUES,sP=Zn.ERR_STREAM_WRITE_AFTER_END,aP=Zn.ERR_UNKNOWN_ENCODING,fo=Rf.errorOrDestroy;di()(Gt,iy);function cP(){}c(cP,"nop");function Is(t,e,r){lo=lo||pi(),t=t||{},typeof r!="boolean"&&(r=e instanceof lo),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=Jw(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){gP(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 ny(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:Kw.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){lo=lo||pi();var e=this instanceof lo;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)),iy.call(this)}c(Gt,"Writable");Gt.prototype.pipe=function(){fo(this,new nP)};function uP(t,e){var r=new sP;fo(t,r),process.nextTick(e,r)}c(uP,"writeAfterEnd");function lP(t,e,r,n){var i;return r===null?i=new oP:typeof r!="string"&&!e.objectMode&&(i=new eP("chunk",["string","Buffer"],r)),i?(fo(t,i),process.nextTick(n,i),!1):!0}c(lP,"validChunk");Gt.prototype.write=function(t,e,r){var n=this._writableState,i=!1,o=!n.objectMode&&Yw(t);return o&&!dc.isBuffer(t)&&(t=Zw(t)),typeof e=="function"&&(r=e,e=null),o?e="buffer":e||(e=n.defaultEncoding),typeof r!="function"&&(r=cP),n.ending?uP(this,r):(o||lP(this,n,t,r))&&(n.pendingcb++,i=dP(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&&oy(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 aP(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 fP(t,e,r){return!t.objectMode&&t.decodeStrings!==!1&&typeof e=="string"&&(e=dc.from(e,r)),e}c(fP,"decodeChunk");Object.defineProperty(Gt.prototype,"writableHighWaterMark",{enumerable:!1,get:c(function(){return this._writableState.highWaterMark},"get")});function dP(t,e,r,n,i,o){if(!r){var s=fP(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 kf(t,e,!1,a,n,i,o);return u}c(dP,"writeOrBuffer");function kf(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new iP("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}c(kf,"doWrite");function pP(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(xs,t,e),t._writableState.errorEmitted=!0,fo(t,n)):(i(n),t._writableState.errorEmitted=!0,fo(t,n),xs(t,e))}c(pP,"onwriteError");function hP(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}c(hP,"onwriteStateUpdate");function gP(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function")throw new rP;if(hP(r),e)pP(t,r,n,e,i);else{var o=sy(r)||t.destroyed;!o&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&oy(t,r),n?process.nextTick(ry,t,r,o,i):ry(t,r,o,i)}}c(gP,"onwrite");function ry(t,e,r,n){r||mP(t,e),e.pendingcb--,n(),xs(t,e)}c(ry,"afterWrite");function mP(t,e){e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}c(mP,"onwriteDrain");function oy(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,kf(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 ny(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,d=r.callback,p=e.objectMode?1:u.length;if(kf(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(oy,"clearBuffer");Gt.prototype._write=function(t,e,r){r(new tP("_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||EP(this,n,r),this};Object.defineProperty(Gt.prototype,"writableLength",{enumerable:!1,get:c(function(){return this._writableState.length},"get")});function sy(t){return t.ending&&t.length===0&&t.bufferedRequest===null&&!t.finished&&!t.writing}c(sy,"needFinish");function _P(t,e){t._final(function(r){e.pendingcb--,r&&fo(t,r),e.prefinished=!0,t.emit("prefinish"),xs(t,e)})}c(_P,"callFinal");function yP(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.pendingcb++,e.finalCalled=!0,process.nextTick(_P,t,e)):(e.prefinished=!0,t.emit("prefinish")))}c(yP,"prefinish");function xs(t,e){var r=sy(e);if(r&&(yP(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 EP(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(EP,"endWritable");function AP(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(AP,"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=Rf.destroy;Gt.prototype._undestroy=Rf.undestroy;Gt.prototype._destroy=function(t,e){e(t)}});var pi=le((v5,uy)=>{"use strict";var bP=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};uy.exports=cn;var cy=Df(),$f=Nf();di()(cn,cy);for(Of=bP($f.prototype),pc=0;pc<Of.length;pc++)hc=Of[pc],cn.prototype[hc]||(cn.prototype[hc]=$f.prototype[hc]);var Of,hc,pc;function cn(t){if(!(this instanceof cn))return new cn(t);cy.call(this,t),$f.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",xP)))}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 xP(){this._writableState.ended||process.nextTick(IP,this)}c(xP,"onend");function IP(t){t.end()}c(IP,"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 dy=le((Bf,fy)=>{var gc=require("buffer"),un=gc.Buffer;function ly(t,e){for(var r in t)e[r]=t[r]}c(ly,"copyProps");un.from&&un.alloc&&un.allocUnsafe&&un.allocUnsafeSlow?fy.exports=gc:(ly(gc,Bf),Bf.Buffer=hi);function hi(t,e,r){return un(t,e,r)}c(hi,"SafeBuffer");hi.prototype=Object.create(un.prototype);ly(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 zf=le(hy=>{"use strict";var Lf=dy().Buffer,py=Lf.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 vP(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(vP,"_normalizeEncoding");function SP(t){var e=vP(t);if(typeof e!="string"&&(Lf.isEncoding===py||!py(t)))throw new Error("Unknown encoding: "+t);return e||t}c(SP,"normalizeEncoding");hy.StringDecoder=vs;function vs(t){this.encoding=SP(t);var e;switch(this.encoding){case"utf16le":this.text=RP,this.end=NP,e=4;break;case"utf8":this.fillLast=TP,e=4;break;case"base64":this.text=OP,this.end=$P,e=3;break;default:this.write=DP,this.end=BP;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Lf.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=kP;vs.prototype.text=CP;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 Uf(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}c(Uf,"utf8CheckByte");function wP(t,e,r){var n=e.length-1;if(n<r)return 0;var i=Uf(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=Uf(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=Uf(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}c(wP,"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 TP(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(TP,"utf8FillLast");function CP(t,e){var r=wP(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(CP,"utf8Text");function kP(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}c(kP,"utf8End");function RP(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(RP,"utf16Text");function NP(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(NP,"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 $P(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}c($P,"base64End");function DP(t){return t.toString(this.encoding)}c(DP,"simpleWrite");function BP(t){return t&&t.length?this.write(t):""}c(BP,"simpleEnd")});var mc=le((C5,_y)=>{"use strict";var gy=Gn().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 zP(t){return t.setHeader&&typeof t.abort=="function"}c(zP,"isRequest");function my(t,e,r){if(typeof e=="function")return my(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 gy),r.call(t,_);if(i&&!s)return(!t._writableState||!t._writableState.ended)&&(_=new gy),r.call(t,_)},"onclose"),g=c(function(){t.req.on("finish",a)},"onrequest");return zP(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(my,"eos");_y.exports=my});var Ey=le((R5,yy)=>{"use strict";var _c;function Yn(t,e,r){return e=MP(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(Yn,"_defineProperty");function MP(t){var e=FP(t,"string");return typeof e=="symbol"?e:String(e)}c(MP,"_toPropertyKey");function FP(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(FP,"_toPrimitive");var HP=mc(),Xn=Symbol("lastResolve"),gi=Symbol("lastReject"),Ss=Symbol("error"),yc=Symbol("ended"),mi=Symbol("lastPromise"),Mf=Symbol("handlePromise"),_i=Symbol("stream");function Jn(t,e){return{value:t,done:e}}c(Jn,"createIterResult");function jP(t){var e=t[Xn];if(e!==null){var r=t[_i].read();r!==null&&(t[mi]=null,t[Xn]=null,t[gi]=null,e(Jn(r,!1)))}}c(jP,"readAndResolve");function WP(t){process.nextTick(jP,t)}c(WP,"onReadable");function qP(t,e){return function(r,n){t.then(function(){if(e[yc]){r(Jn(void 0,!0));return}e[Mf](r,n)},n)}}c(qP,"wrapForNext");var QP=Object.getPrototypeOf(function(){}),VP=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(Jn(void 0,!0));if(this[_i].destroyed)return new Promise(function(s,a){process.nextTick(function(){e[Ss]?a(e[Ss]):s(Jn(void 0,!0))})});var n=this[mi],i;if(n)i=new Promise(qP(n,this));else{var o=this[_i].read();if(o!==null)return Promise.resolve(Jn(o,!1));i=new Promise(this[Mf])}return this[mi]=i,i},"next")},Yn(_c,Symbol.asyncIterator,function(){return this}),Yn(_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(Jn(void 0,!0))})})},"_return")),_c),QP),KP=c(function(e){var r,n=Object.create(VP,(r={},Yn(r,_i,{value:e,writable:!0}),Yn(r,Xn,{value:null,writable:!0}),Yn(r,gi,{value:null,writable:!0}),Yn(r,Ss,{value:null,writable:!0}),Yn(r,yc,{value:e._readableState.endEmitted,writable:!0}),Yn(r,Mf,{value:c(function(o,s){var a=n[_i].read();a?(n[mi]=null,n[Xn]=null,n[gi]=null,o(Jn(a,!1))):(n[Xn]=o,n[gi]=s)},"value"),writable:!0}),r));return n[mi]=null,HP(e,function(i){if(i&&i.code!=="ERR_STREAM_PREMATURE_CLOSE"){var o=n[gi];o!==null&&(n[mi]=null,n[Xn]=null,n[gi]=null,o(i)),n[Ss]=i;return}var s=n[Xn];s!==null&&(n[mi]=null,n[Xn]=null,n[gi]=null,s(Jn(void 0,!0))),n[yc]=!0}),e.on("readable",WP.bind(null,n)),n},"createReadableStreamAsyncIterator");yy.exports=KP});var Iy=le((O5,xy)=>{"use strict";function Ay(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(Ay,"asyncGeneratorStep");function GP(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function s(u){Ay(o,n,i,s,a,"next",u)}c(s,"_next");function a(u){Ay(o,n,i,s,a,"throw",u)}c(a,"_throw"),s(void 0)})}}c(GP,"_asyncToGenerator");function by(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(by,"ownKeys");function ZP(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?by(Object(r),!0).forEach(function(n){YP(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):by(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}c(ZP,"_objectSpread");function YP(t,e,r){return e=XP(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}c(YP,"_defineProperty");function XP(t){var e=JP(t,"string");return typeof e=="symbol"?e:String(e)}c(XP,"_toPropertyKey");function JP(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(JP,"_toPrimitive");var eT=Gn().codes.ERR_INVALID_ARG_TYPE;function tT(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 eT("iterable",["Iterable"],e);var i=new t(ZP({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=GP(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(tT,"from");xy.exports=tT});var Df=le((B5,Oy)=>{"use strict";Oy.exports=bt;var po;bt.ReadableState=Py;var D5=require("events").EventEmitter,wy=c(function(e,r){return e.listeners(r).length},"EElistenerCount"),Ps=xf(),Ec=require("buffer").Buffer,rT=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function nT(t){return Ec.from(t)}c(nT,"_uint8ArrayToBuffer");function iT(t){return Ec.isBuffer(t)||t instanceof rT}c(iT,"_isUint8Array");var Ff=require("util"),ct;Ff&&Ff.debuglog?ct=Ff.debuglog("stream"):ct=c(function(){},"debug");var oT=Q_(),Kf=Sf(),sT=wf(),aT=sT.getHighWaterMark,Ac=Gn().codes,cT=Ac.ERR_INVALID_ARG_TYPE,uT=Ac.ERR_STREAM_PUSH_AFTER_EOF,lT=Ac.ERR_METHOD_NOT_IMPLEMENTED,fT=Ac.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,ho,Hf,jf;di()(bt,Ps);var ws=Kf.errorOrDestroy,Wf=["error","close","destroy","pause","resume"];function dT(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(dT,"prependListener");function Py(t,e,r){po=po||pi(),t=t||{},typeof r!="boolean"&&(r=e instanceof po),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=aT(this,t,"readableHighWaterMark",r),this.buffer=new oT,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&&(ho||(ho=zf().StringDecoder),this.decoder=new ho(t.encoding),this.encoding=t.encoding)}c(Py,"ReadableState");function bt(t){if(po=po||pi(),!(this instanceof bt))return new bt(t);var e=this instanceof po;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)),Ps.call(this)}c(bt,"Readable");Object.defineProperty(bt.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")});bt.prototype.destroy=Kf.destroy;bt.prototype._undestroy=Kf.undestroy;bt.prototype._destroy=function(t,e){e(t)};bt.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),Ty(this,t,e,!1,n)};bt.prototype.unshift=function(t){return Ty(this,t,null,!0,!1)};function Ty(t,e,r,n,i){ct("readableAddChunk",e);var o=t._readableState;if(e===null)o.reading=!1,gT(t,o);else{var s;if(i||(s=pT(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=nT(e)),n)o.endEmitted?ws(t,new fT):qf(t,o,e,!0);else if(o.ended)ws(t,new uT);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||e.length!==0?qf(t,o,e,!1):Vf(t,o)):qf(t,o,e,!1)}else n||(o.reading=!1,Vf(t,o))}return!o.ended&&(o.length<o.highWaterMark||o.length===0)}c(Ty,"readableAddChunk");function qf(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)),Vf(t,e)}c(qf,"addChunk");function pT(t,e){var r;return!iT(e)&&typeof e!="string"&&e!==void 0&&!t.objectMode&&(r=new cT("chunk",["string","Buffer","Uint8Array"],e)),r}c(pT,"chunkInvalid");bt.prototype.isPaused=function(){return this._readableState.flowing===!1};bt.prototype.setEncoding=function(t){ho||(ho=zf().StringDecoder);var e=new ho(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 vy=1073741824;function hT(t){return t>=vy?t=vy:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}c(hT,"computeNewHighWaterMark");function Sy(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=hT(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}c(Sy,"howMuchToRead");bt.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?Qf(this):bc(this),null;if(t=Sy(t,e),t===0&&e.ended)return e.length===0&&Qf(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=Sy(r,e)));var i;return t>0?i=Ry(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&&Qf(this)),i!==null&&this.emit("data",i),i};function gT(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,Cy(t)))}}c(gT,"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(Cy,t))}c(bc,"emitReadable");function Cy(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,Gf(t)}c(Cy,"emitReadable_");function Vf(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(mT,t,e))}c(Vf,"maybeReadMore");function mT(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(mT,"maybeReadMore_");bt.prototype._read=function(t){ws(this,new lT("_read()"))};bt.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:b;n.endEmitted?process.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(E,v){ct("onunpipe"),E===r&&v&&v.hasUnpiped===!1&&(v.hasUnpiped=!0,d())}c(s,"onunpipe");function a(){ct("onend"),t.end()}c(a,"onend");var u=_T(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",b),r.removeListener("data",p),l=!0,n.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&u()}c(d,"cleanup"),r.on("data",p);function p(E){ct("ondata");var v=t.write(E);ct("dest.write",v),v===!1&&((n.pipesCount===1&&n.pipes===t||n.pipesCount>1&&Ny(n.pipes,t)!==-1)&&!l&&(ct("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}c(p,"ondata");function g(E){ct("onerror",E),b(),t.removeListener("error",g),wy(t,"error")===0&&ws(t,E)}c(g,"onerror"),dT(t,"error",g);function h(){t.removeListener("finish",_),b()}c(h,"onclose"),t.once("close",h);function _(){ct("onfinish"),t.removeListener("close",h),b()}c(_,"onfinish"),t.once("finish",_);function b(){ct("unpipe"),r.unpipe(t)}return c(b,"unpipe"),t.emit("pipe",r),n.flowing||(ct("pipe resume"),r.resume()),t};function _T(t){return c(function(){var r=t._readableState;ct("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,r.awaitDrain===0&&wy(t,"data")&&(r.flowing=!0,Gf(t))},"pipeOnDrainFunctionResult")}c(_T,"pipeOnDrain");bt.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=Ny(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)};bt.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(yT,this)),r};bt.prototype.addListener=bt.prototype.on;bt.prototype.removeListener=function(t,e){var r=Ps.prototype.removeListener.call(this,t,e);return t==="readable"&&process.nextTick(ky,this),r};bt.prototype.removeAllListeners=function(t){var e=Ps.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&process.nextTick(ky,this),e};function ky(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(ky,"updateReadableListening");function yT(t){ct("readable nexttick read 0"),t.read(0)}c(yT,"nReadingNextTick");bt.prototype.resume=function(){var t=this._readableState;return t.flowing||(ct("resume"),t.flowing=!t.readableListening,ET(this,t)),t.paused=!1,this};function ET(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(AT,t,e))}c(ET,"resume");function AT(t,e){ct("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Gf(t),e.flowing&&!e.reading&&t.read(0)}c(AT,"resume_");bt.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 Gf(t){var e=t._readableState;for(ct("flow",e.flowing);e.flowing&&t.read()!==null;);}c(Gf,"flow");bt.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<Wf.length;o++)t.on(Wf[o],this.emit.bind(this,Wf[o]));return this._read=function(s){ct("wrapped _read",s),n&&(n=!1,t.resume())},this};typeof Symbol=="function"&&(bt.prototype[Symbol.asyncIterator]=function(){return Hf===void 0&&(Hf=Ey()),Hf(this)});Object.defineProperty(bt.prototype,"readableHighWaterMark",{enumerable:!1,get:c(function(){return this._readableState.highWaterMark},"get")});Object.defineProperty(bt.prototype,"readableBuffer",{enumerable:!1,get:c(function(){return this._readableState&&this._readableState.buffer},"get")});Object.defineProperty(bt.prototype,"readableFlowing",{enumerable:!1,get:c(function(){return this._readableState.flowing},"get"),set:c(function(e){this._readableState&&(this._readableState.flowing=e)},"set")});bt._fromList=Ry;Object.defineProperty(bt.prototype,"readableLength",{enumerable:!1,get:c(function(){return this._readableState.length},"get")});function Ry(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(Ry,"fromList");function Qf(t){var e=t._readableState;ct("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(bT,e,t))}c(Qf,"endReadable");function bT(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(bT,"endReadableNT");typeof Symbol=="function"&&(bt.from=function(t,e){return jf===void 0&&(jf=Iy()),jf(bt,t,e)});function Ny(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}c(Ny,"indexOf")});var Zf=le((L5,Dy)=>{"use strict";Dy.exports=Sn;var xc=Gn().codes,xT=xc.ERR_METHOD_NOT_IMPLEMENTED,IT=xc.ERR_MULTIPLE_CALLBACK,vT=xc.ERR_TRANSFORM_ALREADY_TRANSFORMING,ST=xc.ERR_TRANSFORM_WITH_LENGTH_0,Ic=pi();di()(Sn,Ic);function wT(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new IT);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(wT,"afterTransform");function Sn(t){if(!(this instanceof Sn))return new Sn(t);Ic.call(this,t),this._transformState={afterTransform:wT.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){$y(t,e,r)}):$y(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 xT("_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 $y(t,e,r){if(e)return t.emit("error",e);if(r!=null&&t.push(r),t._writableState.length)throw new ST;if(t._transformState.transforming)throw new vT;return t.push(null)}c($y,"done")});var Ly=le((M5,Uy)=>{"use strict";Uy.exports=Ts;var By=Zf();di()(Ts,By);function Ts(t){if(!(this instanceof Ts))return new Ts(t);By.call(this,t)}c(Ts,"PassThrough");Ts.prototype._transform=function(t,e,r){r(null,t)}});var jy=le((H5,Hy)=>{"use strict";var Yf;function TT(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}c(TT,"once");var Fy=Gn().codes,CT=Fy.ERR_MISSING_ARGS,kT=Fy.ERR_STREAM_DESTROYED;function zy(t){if(t)throw t}c(zy,"noop");function RT(t){return t.setHeader&&typeof t.abort=="function"}c(RT,"isRequest");function NT(t,e,r,n){n=TT(n);var i=!1;t.on("close",function(){i=!0}),Yf===void 0&&(Yf=mc()),Yf(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,RT(t))return t.abort();if(typeof t.destroy=="function")return t.destroy();n(s||new kT("pipe"))}}}c(NT,"destroyer");function My(t){t()}c(My,"call");function OT(t,e){return t.pipe(e)}c(OT,"pipe");function $T(t){return!t.length||typeof t[t.length-1]!="function"?zy:t.pop()}c($T,"popCallback");function DT(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n=$T(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new CT("streams");var i,o=e.map(function(s,a){var u=a<e.length-1,l=a>0;return NT(s,u,l,function(d){i||(i=d),d&&o.forEach(My),!u&&(o.forEach(My),n(i))})});return e.reduce(OT)}c(DT,"pipeline");Hy.exports=DT});var Wy=le((Wr,ks)=>{var Cs=require("stream");process.env.READABLE_STREAM==="disable"&&Cs?(ks.exports=Cs.Readable,Object.assign(ks.exports,Cs),ks.exports.Stream=Cs):(Wr=ks.exports=Df(),Wr.Stream=Cs||Wr,Wr.Readable=Wr,Wr.Writable=Nf(),Wr.Duplex=pi(),Wr.Transform=Zf(),Wr.PassThrough=Ly(),Wr.finished=mc(),Wr.pipeline=jy())});var Qy=le((W5,qy)=>{var BT=Object.prototype.toString,Xf=typeof Buffer<"u"&&typeof Buffer.alloc=="function"&&typeof Buffer.allocUnsafe=="function"&&typeof Buffer.from=="function";function UT(t){return BT.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 Xf?Buffer.from(t.slice(e,e+r)):new Buffer(new Uint8Array(t.slice(e,e+r)))}c(LT,"fromArrayBuffer");function zT(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Buffer.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');return Xf?Buffer.from(t,e):new Buffer(t,e)}c(zT,"fromString");function MT(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"?zT(t,e):Xf?Buffer.from(t):new Buffer(t)}c(MT,"bufferFrom");qy.exports=MT});var Xy=le(ze=>{var Vy=void 0,FT=1e5,$t=(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,jT=Math.abs,vc=Math.floor,WT=Math.log,qT=Math.min,Yr=Math.pow,QT=Math.round;function Jf(t){if(Ky&&go){var e=Ky(t),r;for(r=0;r<e.length;r+=1)go(t,e[r],{value:t[e[r]],writable:!1,enumerable:!1,configurable:!1})}}c(Jf,"configureProperties");var go;Object.defineProperty&&(function(){try{return Object.defineProperty({},"x",{}),!0}catch{return!1}})()?go=Object.defineProperty:go=c(function(t,e,r){if(!t===Object(t))throw new TypeError("Object.defineProperty called on non-object");return $t.HasProperty(r,"get")&&Object.prototype.__defineGetter__&&Object.prototype.__defineGetter__.call(t,e,r.get),$t.HasProperty(r,"set")&&Object.prototype.__defineSetter__&&Object.prototype.__defineSetter__.call(t,e,r.set),$t.HasProperty(r,"value")&&(t[e]=r.value),t},"defineProp");var Ky=Object.getOwnPropertyNames||function(t){if(t!==Object(t))throw new TypeError("Object.getOwnPropertyNames called on non-object");var e=[],r;for(r in t)$t.HasOwnProperty(t,r)&&e.push(r);return e};function VT(t){if(!go)return;if(t.length>FT)throw new RangeError("Array too large for polyfill");function e(n){go(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(VT,"makeArrayAccessors");function ed(t,e){var r=32-e;return t<<r>>r}c(ed,"as_signed");function td(t,e){var r=32-e;return t<<r>>>r}c(td,"as_unsigned");function KT(t){return[t&255]}c(KT,"packI8");function GT(t){return ed(t[0],8)}c(GT,"unpackI8");function ZT(t){return[t&255]}c(ZT,"packU8");function Gy(t){return td(t[0],8)}c(Gy,"unpackU8");function YT(t){return t=QT(Number(t)),[t<0?0:t>255?255:t&255]}c(YT,"packU8Clamped");function XT(t){return[t>>8&255,t&255]}c(XT,"packI16");function JT(t){return ed(t[0]<<8|t[1],16)}c(JT,"unpackI16");function e1(t){return[t>>8&255,t&255]}c(e1,"packU16");function t1(t){return td(t[0]<<8|t[1],16)}c(t1,"unpackU16");function r1(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}c(r1,"packI32");function n1(t){return ed(t[0]<<24|t[1]<<16|t[2]<<8|t[3],32)}c(n1,"unpackI32");function i1(t){return[t>>24&255,t>>16&255,t>>8&255,t&255]}c(i1,"packU32");function o1(t){return td(t[0]<<24|t[1]<<16|t[2]<<8|t[3],32)}c(o1,"unpackU32");function Zy(t,e,r){var n=(1<<e-1)-1,i,o,s,a,u,l,d,p;function g(h){var _=vc(h),b=h-_;return b<.5?_:b>.5||_%2?_+1:_}for(c(g,"roundToEven"),t!==t?(o=(1<<e)-1,s=Yr(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=jT(t),t>=Yr(2,1-n)?(o=qT(vc(WT(t)/HT),1023),s=g(t/Yr(2,o)*Yr(2,r)),s/Yr(2,r)>=2&&(o=o+1,s=1),o>n?(o=(1<<e)-1,s=0):(o=o+n,s=s-Yr(2,r))):(o=0,s=g(t/Yr(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(Zy,"packIEEE754");function Yy(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*Yr(2,d-u)*(1+p/Yr(2,r)):p!==0?l*Yr(2,-(u-1))*(p/Yr(2,r)):l<0?-0:0}c(Yy,"unpackIEEE754");function s1(t){return Yy(t,11,52)}c(s1,"unpackF64");function a1(t){return Zy(t,11,52)}c(a1,"packF64");function c1(t){return Yy(t,8,23)}c(c1,"unpackF32");function u1(t){return Zy(t,8,23)}c(u1,"packF32");(function(){var t=c(function(h){if(h=$t.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;Jf(this)},"ArrayBuffer");ze.ArrayBuffer=ze.ArrayBuffer||t;var e=c(function(){},"ArrayBufferView");function r(g,h,_){var b;return b=c(function(E,v,w){var H,D,J,Y;if(!arguments.length||typeof arguments[0]=="number"){if(this.length=$t.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===b)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,J=0;J<this.length;J+=1)this._setter(J,H._getter(J));else if(typeof arguments[0]=="object"&&!(arguments[0]instanceof t||$t.Class(arguments[0])==="ArrayBuffer"))for(D=arguments[0],this.length=$t.ToUint32(D.length),this.byteLength=this.length*this.BYTES_PER_ELEMENT,this.buffer=new t(this.byteLength),this.byteOffset=0,J=0;J<this.length;J+=1)Y=D[J],this._setter(J,Number(Y));else if(typeof arguments[0]=="object"&&(arguments[0]instanceof t||$t.Class(arguments[0])==="ArrayBuffer")){if(this.buffer=E,this.byteOffset=$t.ToUint32(v),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=$t.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=b,Jf(this),VT(this)},"ctor"),b.prototype=new e,b.prototype.BYTES_PER_ELEMENT=g,b.prototype._pack=h,b.prototype._unpack=_,b.BYTES_PER_ELEMENT=g,b.prototype._getter=function(E){if(arguments.length<1)throw new SyntaxError("Not enough arguments");if(E=$t.ToUint32(E),E>=this.length)return Vy;var v=[],w,H;for(w=0,H=this.byteOffset+E*this.BYTES_PER_ELEMENT;w<this.BYTES_PER_ELEMENT;w+=1,H+=1)v.push(this.buffer._bytes[H]);return this._unpack(v)},b.prototype.get=b.prototype._getter,b.prototype._setter=function(E,v){if(arguments.length<2)throw new SyntaxError("Not enough arguments");if(E=$t.ToUint32(E),E>=this.length)return Vy;var w=this._pack(v),H,D;for(H=0,D=this.byteOffset+E*this.BYTES_PER_ELEMENT;H<this.BYTES_PER_ELEMENT;H+=1,D+=1)this.buffer._bytes[D]=w[H]},b.prototype.set=function(E,v){if(arguments.length<1)throw new SyntaxError("Not enough arguments");var w,H,D,J,Y,X,P,C,M,L;if(typeof arguments[0]=="object"&&arguments[0].constructor===this.constructor){if(w=arguments[0],D=$t.ToUint32(arguments[1]),D+w.length>this.length)throw new RangeError("Offset plus length of array is out of range");if(C=this.byteOffset+D*this.BYTES_PER_ELEMENT,M=w.length*this.BYTES_PER_ELEMENT,w.buffer===this.buffer){for(L=[],Y=0,X=w.byteOffset;Y<M;Y+=1,X+=1)L[Y]=w.buffer._bytes[X];for(Y=0,P=C;Y<M;Y+=1,P+=1)this.buffer._bytes[P]=L[Y]}else for(Y=0,X=w.byteOffset,P=C;Y<M;Y+=1,X+=1,P+=1)this.buffer._bytes[P]=w.buffer._bytes[X]}else if(typeof arguments[0]=="object"&&typeof arguments[0].length<"u"){if(H=arguments[0],J=$t.ToUint32(H.length),D=$t.ToUint32(arguments[1]),D+J>this.length)throw new RangeError("Offset plus length of array is out of range");for(Y=0;Y<J;Y+=1)X=H[Y],this._setter(D+Y,Number(X))}else throw new TypeError("Unexpected argument type(s)")},b.prototype.subarray=function(E,v){function w(D,J,Y){return D<J?J:D>Y?Y:D}c(w,"clamp"),E=$t.ToInt32(E),v=$t.ToInt32(v),arguments.length<1&&(E=0),arguments.length<2&&(v=this.length),E<0&&(E=this.length+E),v<0&&(v=this.length+v),E=w(E,0,this.length),v=w(v,0,this.length);var H=v-E;return H<0&&(H=0),new this.constructor(this.buffer,this.byteOffset+E*this.BYTES_PER_ELEMENT,H)},b}c(r,"makeConstructor");var n=r(1,KT,GT),i=r(1,ZT,Gy),o=r(1,YT,Gy),s=r(2,XT,JT),a=r(2,e1,t1),u=r(4,r1,n1),l=r(4,i1,o1),d=r(4,u1,c1),p=r(8,a1,s1);ze.Int8Array=ze.Int8Array||n,ze.Uint8Array=ze.Uint8Array||i,ze.Uint8ClampedArray=ze.Uint8ClampedArray||o,ze.Int16Array=ze.Int16Array||s,ze.Uint16Array=ze.Uint16Array||a,ze.Int32Array=ze.Int32Array||u,ze.Uint32Array=ze.Uint32Array||l,ze.Float32Array=ze.Float32Array||d,ze.Float64Array=ze.Float64Array||p})();(function(){function t(o,s){return $t.IsCallable(o.get)?o.get(s):o[s]}c(t,"r");var e=(function(){var o=new ze.Uint16Array([4660]),s=new ze.Uint8Array(o.buffer);return t(s,0)===18})(),r=c(function(s,a,u){if(arguments.length===0)s=new ze.ArrayBuffer(0);else if(!(s instanceof ze.ArrayBuffer||$t.Class(s)==="ArrayBuffer"))throw new TypeError("TypeError");if(this.buffer=s||new ze.ArrayBuffer(0),this.byteOffset=$t.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=$t.ToUint32(u),this.byteOffset+this.byteLength>this.buffer.byteLength)throw new RangeError("byteOffset and length reference an area beyond the end of the buffer");Jf(this)},"DataView");function n(o){return function(s,a){if(s=$t.ToUint32(s),s+o.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");s+=this.byteOffset;var u=new ze.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 ze.Uint8Array(l).buffer),0)}}c(n,"makeGetter"),r.prototype.getUint8=n(ze.Uint8Array),r.prototype.getInt8=n(ze.Int8Array),r.prototype.getUint16=n(ze.Uint16Array),r.prototype.getInt16=n(ze.Int16Array),r.prototype.getUint32=n(ze.Uint32Array),r.prototype.getInt32=n(ze.Int32Array),r.prototype.getFloat32=n(ze.Float32Array),r.prototype.getFloat64=n(ze.Float64Array);function i(o){return function(s,a,u){if(s=$t.ToUint32(s),s+o.BYTES_PER_ELEMENT>this.byteLength)throw new RangeError("Array index out of range");var l=new o([a]),d=new ze.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 ze.Uint8Array(this.buffer,s,o.BYTES_PER_ELEMENT),h.set(p)}}c(i,"makeSetter"),r.prototype.setUint8=i(ze.Uint8Array),r.prototype.setInt8=i(ze.Int8Array),r.prototype.setUint16=i(ze.Uint16Array),r.prototype.setInt16=i(ze.Int16Array),r.prototype.setUint32=i(ze.Uint32Array),r.prototype.setInt32=i(ze.Int32Array),r.prototype.setFloat32=i(ze.Float32Array),r.prototype.setFloat64=i(ze.Float64Array),ze.DataView=ze.DataView||r})()});var rE=le((K5,tE)=>{var Jy=Wy().Writable,l1=di(),Rs=Qy();typeof Uint8Array>"u"?Sc=Xy().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,Jy.call(this,{objectMode:!0}),this.encoding=r,this.shouldInferEncoding=n,e&&this.on("finish",function(){e(this.getBody())}),this.body=[]}c(yi,"ConcatStream");tE.exports=yi;l1(yi,Jy);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"?h1(this.body):this.encoding==="string"?d1(this.body):this.encoding==="buffer"?p1(this.body):this.encoding==="uint8array"?g1(this.body):this.body)};function f1(t){return/Array\]$/.test(Object.prototype.toString.call(t))}c(f1,"isArrayish");function eE(t){return typeof t=="string"||f1(t)||t&&typeof t.subarray=="function"}c(eE,"isBufferish");function d1(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):eE(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(d1,"stringConcat");function p1(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];Buffer.isBuffer(n)?e.push(n):eE(n)?e.push(Rs(n)):e.push(Rs(String(n)))}return Buffer.concat(e)}c(p1,"bufferConcat");function h1(t){for(var e=[],r=0;r<t.length;r++)e.push.apply(e,t[r]);return e}c(h1,"arrayConcat");function g1(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(g1,"u8Concat")});var oE=le((Z5,iE)=>{"use strict";function nE(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}c(nE,"assign");function m1(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 nE(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=c(function(){},"ErrClass");return i.prototype=Object.create(Object.getPrototypeOf(t)),nE(new i,r)}}c(m1,"createError");iE.exports=m1});var aE=le((X5,sE)=>{function qr(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(qr,"RetryOperation");sE.exports=qr;qr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};qr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};qr.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};qr.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)};qr.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};qr.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};qr.prototype.start=qr.prototype.try;qr.prototype.errors=function(){return this._errors};qr.prototype.attempts=function(){return this._attempts};qr.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 cE=le(Ei=>{var _1=aE();Ei.operation=function(t){var e=Ei.timeouts(t);return new _1(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 lE=le((r8,uE)=>{uE.exports=cE()});var pE=le((n8,dE)=>{"use strict";var y1=oE(),E1=lE(),A1=Object.prototype.hasOwnProperty;function fE(t){return t&&t.code==="EPROMISERETRY"&&A1.call(t,"retried")}c(fE,"isRetryError");function b1(t,e){var r,n;return typeof t=="object"&&typeof e=="function"&&(r=e,e=t,t=r),n=E1.operation(e),new Promise(function(i,o){n.attempt(function(s){Promise.resolve().then(function(){return t(function(a){throw fE(a)&&(a=a.retried),y1(new Error("Retrying"),"EPROMISERETRY",{retried:a})},s)}).then(i,function(a){fE(a)&&(a=a.retried,n.retry(a||new Error))||o(a)})})})}c(b1,"promiseRetry");dE.exports=b1});var rd=le((o8,hE)=>{var x1={generic:"ERR_GENERIC_CLIENT",connect:"ERR_NOT_CONNECTED",badPath:"ERR_BAD_PATH",permission:"EACCES",notexist:"ENOENT",notdir:"ENOTDIR",badAuth:"ERR_BAD_AUTH"},I1={writeFile:1,readFile:2,writeDir:3,readDir:4,readObj:5,writeObj:6};hE.exports={errorCode:x1,targetType:I1}});var AE=le((s8,EE)=>{var Ns=require("fs"),v1=require("path"),{errorCode:gE}=rd();function mE(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(mE,"errorListener");function S1(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(S1,"globalListener");function _E(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(_E,"endListener");function yE(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(yE,"closeListener");function w1(t,e,r){let n={end:_E(t,e,r),close:yE(t,e,r),error:mE(t,e,r)};return t.on("end",n.end),t.on("close",n.close),t.on("error",n.error),t._resetEventFlags(),n}c(w1,"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 nd(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=gE.badPath,r}}else return!1}c(nd,"localExists");function id(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:nd(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:nd(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(id,"haveLocalAccess");function T1(t){let{status:e,details:r,type:n}=id(t,"w");if(!e&&r==="permission denied")return{status:e,details:r,type:n};if(!e){let i=v1.dirname(t),o=id(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(T1,"haveLocalCreate");async function C1(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(C1,"normalizeRemotePath");function k1(t,e,r){if(!t.sftp){let n=new Error(`${e}: No SFTP connection available`);if(n.code=gE.connect,r)return r(n),!1;throw n}return!0}c(k1,"haveConnection");function R1(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(R1,"sleep");EE.exports={globalListener:S1,errorListener:mE,endListener:_E,closeListener:yE,addTempListeners:w1,removeTempListeners:P1,haveLocalAccess:id,haveLocalCreate:T1,normalizeRemotePath:C1,localExists:nd,haveConnection:k1,sleep:R1}});var vE=le((c8,IE)=>{"use strict";var{Client:N1}=z_(),wc=require("fs"),O1=rE(),$1=pE(),{join:Os,parse:D1}=require("path"),{globalListener:od,addTempListeners:Mt,removeTempListeners:Ft,haveConnection:dr,normalizeRemotePath:$s,localExists:bE,haveLocalAccess:xE,haveLocalCreate:sd}=AE(),{errorCode:Dt}=rd(),ad=class{static{c(this,"SftpClient")}constructor(e){this.version="9.0.4",this.client=new N1,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",od(this,"close")),this.client.on("end",od(this,"end")),this.client.on("error",od(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=Dt.generic;else if(typeof e=="string")o=`${r}: ${e}${a}`,s=n||Dt.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:Dt.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=Mt(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),Ft(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=Mt(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",Dt.connect);let n={retries:e.retries??1,factor:e.factor??2,minTimeout:e.retry_minTimeout??25e3};return await $1(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{Ft(this,r,"connect")}}realPath(e,r=!0){let n;return new Promise((i,o)=>{r&&(n=Mt(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&&Ft(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",Dt.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=Mt(this,"_xstat",s)),e==="stat"?this.sftp.stat(r,a):this.sftp.lstat(r,a)}).finally(()=>{n&&Ft(this,i,"_xstat")})}async stat(e){try{return dr(this,"stat"),await this._xstat("stat",e)}catch(r){throw r.custom?r:this.fmtError(r,"stat",r.code)}}async lstat(e){try{return dr(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===Dt.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=Mt(this,"list",s)),dr(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&&Ft(this,i,"list")})}get(e,r,n,i=!0){let o,s,a;return new Promise((u,l)=>{if(i&&(o=Mt(this,"get",l)),dr(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=sd(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&&Ft(this,o,"get")})}_fastGet(e,r,n,i=!0){let o;return new Promise((s,a)=>{i&&(o=Mt(this,"_fastGet",a)),dr(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&&Ft(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",Dt.badPath)}let o=sd(r);if(!o.status)throw this.fmtError(`Bad path: ${r}: ${o.details}`,"fastGet",Dt.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=Mt(this,"_fastPut",a)),dr(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&&Ft(this,o,"_fastPut")})}async fastPut(e,r,n){try{this.debugMsg(`fastPut -> local ${e} remote ${r}`);let i=xE(e);if(i.status){if(i.status&&bE(e)==="d")throw this.fmtError(`Bad path: ${e} not a regular file`,"fastgPut",Dt.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=Mt(this,"_put",l)),n={readStreamOptions:{...n?.readStreamOptions,autoClose:!0},writeStreamOptions:{...n?.writeStreamOptions,autoClose:!0},pipeOptions:{...n?.pipeOptions,end:!0}},dr(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&&Ft(this,o,"_put")})}async put(e,r,n){try{if(typeof e=="string"){let i=xE(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=Mt(this,"_append",a)),dr(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&&Ft(this,o,"_append")})}async append(e,r,n={}){try{if(typeof e=="string")throw this.fmtError("Cannot append one file to another","append",Dt.badPath);let i=await this.exists(r);if(i&&i==="d")throw this.fmtError(`Bad path: ${r}: cannot append to a directory`,"append",Dt.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=Mt(this,"_doMkdir",o)),this.sftp.mkdir(e,s=>{s?s.code===4?o(this.fmtError(`Bad path: ${e} permission denied`,"_doMkdir",Dt.badPath)):s.code===2?o(this.fmtError(`Bad path: ${e} parent not a directory or not exist`,"_doMkdir",Dt.badPath)):o(this.fmtError(`${s.message} ${e}`,"_doMkdir",s.code)):i(`${e} directory created`)})}).finally(()=>{r&&Ft(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",Dt.badPath);if(i)return`${n} already exists`;if(!r)return await this._doMkdir(n);let o=D1(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",Dt.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 dr(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=Mt(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(()=>{Ft(this,s,"_rmdir")})},"_rmdir"),i=c((o,s)=>{let a;return new Promise((u,l)=>{a=Mt(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(()=>{Ft(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",Dt.badPath);if(s!=="d")throw this.fmtError(`Bad Path: ${e}: Not a directory`,"rmdir",Dt.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=Mt(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&&Ft(this,i,"delete")})}rename(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=Mt(this,"rename",s)),dr(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&&Ft(this,i,"rename")})}posixRename(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=Mt(this,"posixRename",s)),dr(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(()=>{Ft(this,i,"posixRename")})}chmod(e,r,n=!0){let i;return new Promise((o,s)=>{n&&(i=Mt(this,"chmod",s)),dr(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&&Ft(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",Dt.badPath);return{remoteDir:u,remoteStatus:l}},"getRemoteStatus"),o=c(a=>{let u=bE(a);if(!u)throw this.fmtError(`Bad path: ${a} not exist`,"getLocalStatus",Dt.badPath);if(u!=="d")throw this.fmtError(`Bad path: ${a}: not a directory`,"getLocalStatus",Dt.badPath);return u},"checkLocalStatus"),s=c((a,u,l,d)=>{let p;return new Promise((g,h)=>{p=Mt(this,"uploadFiles",h);let _=[];for(let b of l){let E=Os(a,b.name),v=`${u}/${b.name}`;b.isFile()?(d?_.push(this._fastPut(E,v,null,!1)):_.push(this._put(E,v,null,!1)),this.client.emit("upload",{source:E,destination:v})):this.debugMsg(`uploadFiles: File ignored: ${b.name} not a regular file`)}g(Promise.all(_))}).then(g=>Promise.all(g)).finally(()=>{Ft(this,p,s)})},"uploadFiles");try{dr(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=sd(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",Dt.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=Mt(this,"_downloadFIles",h);let _=[];for(let b of l){let E=`${a}/${b.name}`,v=Os(u,b.name);d?_.push(this.fastGet(E,v,!1)):_.push(this.get(E,v,!1)),this.client.emit("download",{source:E,destination:v})}return g(Promise.all(_))}).finally(()=>{Ft(this,p,"_downloadFiles")})},"_downloadFiles");try{dr(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=Mt(this,"createReadStream"),dr(this,"createReadStream"),this.sftp.createReadStream(e,r)}catch(i){throw i.custom?i:this.fmtError(i.message,"createReadStream",i.code)}finally{Ft(this,n,"createReadStreame")}}createWriteStream(e,r){let n;try{return n=Mt(this,"createWriteStream"),dr(this,"createWriteStream"),this.sftp.createWriteStream(e,r)}catch(i){throw i.custom?i:this.fmtError(i.message,"createWriteStream",i.code)}finally{Ft(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=Mt(this,"rcopy"),dr(this,"rcopy");let i=await $s(this,e),o=await this.exists(i);if(!o)throw this.fmtError(`Source does not exist ${i}`,"rcopy",Dt.badPath);if(o!=="-")throw this.fmtError(`Source not a file ${i}`,"rcopy",Dt.badPath);let s=await $s(this,r);if(await this.exists(s))throw this.fmtError(`Destination already exists ${s}`,"rcopy",Dt.badPath);return this._rcopy(i,s)}catch(i){throw i.custom?i:this.fmtError(i,"rcopy")}finally{Ft(this,n,"rcopy")}}end(){let e,r;return new Promise((n,i)=>{r=Mt(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(()=>{Ft(this,r,"end"),this.removeListener("close",e),this.endCalled=!1})}};IE.exports=ad});var BE=le((ud,ld)=>{(function(t,e){typeof ud=="object"&&typeof ld<"u"?ld.exports=e():typeof define=="function"&&define.amd?define(e):(t=typeof globalThis<"u"?globalThis:t||self).dayjs=e()})(ud,(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+)?$/,b=/\[([^\]]+)]|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,E={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")},v=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:v,z:c(function(L){var T=-L.utcOffset(),F=Math.abs(T),j=Math.floor(F/60),B=F%60;return(T<=0?"+":"-")+v(j,2,"0")+":"+v(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),Z=F-B<0,te=T.clone().add(j+(Z?-1:1),l);return+(-(j+(F-B)/(Z?B-te:te-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",D={};D[H]=E;var J=c(function(L){return L instanceof C},"p"),Y=c(function L(T,F,j){var B;if(!T)return H;if(typeof T=="string"){var Z=T.toLowerCase();D[Z]&&(B=Z),F&&(D[Z]=F,B=Z);var te=T.split("-");if(!B&&te.length>1)return L(te[0])}else{var k=T.name;D[k]=T,B=k}return!j&&B&&(H=B),B||!j&&H},"t"),X=c(function(L,T){if(J(L))return L.clone();var F=typeof T=="object"?T:{};return F.date=L,F.args=arguments,new C(F)},"w"),P=w;P.l=Y,P.i=J,P.w=function(L,T){return X(L,{locale:T.$L,utc:T.$u,x:T.$x,$offset:T.$offset})};var C=(function(){function L(F){this.$L=Y(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,Z=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 te=B.match(_);if(te){var k=te[2]-1||0,W=(te[7]||"0").substring(0,3);return Z?new Date(Date.UTC(te[1],k,te[3]||1,te[4]||0,te[5]||0,te[6]||0,W)):new Date(te[1],k,te[3]||1,te[4]||0,te[5]||0,te[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=X(F);return this.startOf(j)<=B&&B<=this.endOf(j)},T.isAfter=function(F,j){return X(F)<this.startOf(j)},T.isBefore=function(F,j){return this.endOf(j)<X(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,Z=!!P.u(j)||j,te=P.p(F),k=c(function(kt,Xt){var Ar=P.w(B.$u?Date.UTC(B.$y,Xt,kt):new Date(B.$y,Xt,kt),B);return Z?Ar:Ar.endOf(a)},"l"),W=c(function(kt,Xt){return P.w(B.toDate()[kt].apply(B.toDate("s"),(Z?[0,0,0,0]:[23,59,59,999]).slice(Xt)),B)},"$"),q=this.$W,ee=this.$M,ue=this.$D,me="set"+(this.$u?"UTC":"");switch(te){case p:return Z?k(1,0):k(31,11);case l:return Z?k(1,ee):k(0,ee+1);case u:var he=this.$locale().weekStart||0,xt=(q<he?q+7:q)-he;return k(Z?ue-xt:ue+(6-xt),ee);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,Z=P.p(F),te="set"+(this.$u?"UTC":""),k=(B={},B[a]=te+"Date",B[g]=te+"Date",B[l]=te+"Month",B[p]=te+"FullYear",B[s]=te+"Hours",B[o]=te+"Minutes",B[i]=te+"Seconds",B[n]=te+"Milliseconds",B)[Z],W=Z===a?this.$D+(j-this.$W):j;if(Z===l||Z===p){var q=this.clone().set(g,1);q.$d[k](W),q.init(),this.$d=q.set(g,Math.min(this.$D,q.daysInMonth())).$d}else k&&this.$d[k](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,Z=this;F=Number(F);var te=P.p(j),k=c(function(ee){var ue=X(Z);return P.w(ue.date(ue.date()+Math.round(ee*F)),Z)},"y");if(te===l)return this.set(l,this.$M+F);if(te===p)return this.set(p,this.$y+F);if(te===a)return k(1);if(te===u)return k(7);var W=(B={},B[o]=e,B[s]=r,B[i]=t,B)[te]||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 Z=F||"YYYY-MM-DDTHH:mm:ssZ",te=P.z(this),k=this.$H,W=this.$m,q=this.$M,ee=B.weekdays,ue=B.months,me=B.meridiem,he=c(function(Xt,Ar,Br,Sr){return Xt&&(Xt[Ar]||Xt(j,Z))||Br[Ar].slice(0,Sr)},"h"),xt=c(function(Xt){return P.s(k%12||12,Xt,"0")},"d"),kt=me||function(Xt,Ar,Br){var Sr=Xt<12?"AM":"PM";return Br?Sr.toLowerCase():Sr};return Z.replace(b,(function(Xt,Ar){return Ar||(function(Br){switch(Br){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,ee,2);case"ddd":return he(B.weekdaysShort,j.$W,ee,3);case"dddd":return ee[j.$W];case"H":return String(k);case"HH":return P.s(k,2,"0");case"h":return xt(1);case"hh":return xt(2);case"a":return kt(k,W,!0);case"A":return kt(k,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 te}return null})(Xt)||te.replace(":","")}))},T.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},T.diff=function(F,j,B){var Z,te=this,k=P.p(j),W=X(F),q=(W.utcOffset()-this.utcOffset())*e,ee=this-W,ue=c(function(){return P.m(te,W)},"D");switch(k){case p:Z=ue()/12;break;case l:Z=ue();break;case d:Z=ue()/3;break;case u:Z=(ee-q)/6048e5;break;case a:Z=(ee-q)/864e5;break;case s:Z=ee/r;break;case o:Z=ee/e;break;case i:Z=ee/t;break;default:Z=ee}return B?Z:P.a(Z)},T.daysInMonth=function(){return this.endOf(l).$D},T.$locale=function(){return D[this.$L]},T.locale=function(F,j){if(!F)return this.$L;var B=this.clone(),Z=Y(F,j,!0);return Z&&(B.$L=Z),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=C.prototype;return X.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])}})),X.extend=function(L,T){return L.$i||(L(T,C,X),L.$i=!0),X},X.locale=Y,X.isDayjs=J,X.unix=function(L){return X(1e3*L)},X.en=D[H],X.Ls=D,X.p={},X}))});var tC={};hd(tC,{endClient:()=>Zt,ftpSftp:()=>eC,getClient:()=>Ht,getProtocolBackwardCompatibility:()=>Bt});module.exports=nA(tC);var iA=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 Jr=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 _d(t,e){return typeof e=="bigint"?e.toString():e}c(_d,"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 yd(t){return t==null}c(yd,"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 md=Symbol("evaluating");function er(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==md)return n===void 0&&(n=md,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 xo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}c(xo,"isObject");var oA=Ms(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Ed(t){if(xo(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(xo(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}c(Ed,"isPlainObject");var Ad=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 bd(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}c(bd,"optionalKeys");var xd={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 Id(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}c(Id,"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 vd=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,_d,2),Object.defineProperty(t,"toString",{value:c(()=>t.message,"value"),enumerable:!1})},"initializer"),Sd=xe("$ZodError",vd),Io=xe("$ZodError",vd,{Parent:Error});var aA=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 Jr;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=aA(Io),cA=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=cA(Io),uA=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 Jr;return o.issues.length?{success:!1,error:new(t??Sd)(o.issues.map(s=>Pn(s,i,fn())))}:{success:!0,data:o.value}},"_safeParse"),vo=uA(Io),lA=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"),So=lA(Io);var fA="(?:(?:\\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])))",dA=new RegExp(`^${fA}$`);var wd=c(t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},"string"),Pd=/^-?\d+n?$/,Td=/^-?\d+$/,Uc=/^-?\d+(?:\.\d+)?$/,Cd=/^(?: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=[])}),pA={number:"number",bigint:"bigint",object:"date"};var kd=xe("$ZodCheckGreaterThan",(t,e)=>{Tn.init(t,e);let r=pA[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 Rd=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]=xd[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=Td)}),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 Nd=xe("$ZodCheckMinLength",(t,e)=>{var r;Tn.init(t,e),(r=t._zod.def).when??(r.when=n=>{let i=n.value;return!yd(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=Id(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=()=>{})}),Od=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 Dd={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=Dd;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 Jr;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 Jr;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 Jr;return u.then(l=>i(l,n,a))}return i(u,n,a)}}er(t,"~standard",()=>({validate:c(i=>{try{let o=vo(t,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return So(t,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},"validate"),vendor:"zod",version:1}))}),Vs=xe("$ZodString",(t,e)=>{Kt.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??wd(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 Md=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)=>{Kt.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}}),Fd=xe("$ZodNumberFormat",(t,e)=>{Rd.init(t,e),Mc.init(t,e)}),Fc=xe("$ZodBoolean",(t,e)=>{Kt.init(t,e),t._zod.pattern=Cd,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}}),Hd=xe("$ZodBigInt",(t,e)=>{Kt.init(t,e),t._zod.pattern=Pd,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 jd=xe("$ZodAny",(t,e)=>{Kt.init(t,e),t._zod.parse=r=>r}),Wd=xe("$ZodUnknown",(t,e)=>{Kt.init(t,e),t._zod.parse=r=>r});var qd=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}}),Qd=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 Bd(t,e,r){t.issues.length&&e.issues.push(...wn(r,t.issues)),e.value[r]=t.value}c(Bd,"handleArrayResult");var Vd=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=>Bd(l,r,s))):Bd(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 hA(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=bd(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}c(hA,"normalizeDef");function gA(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(gA,"handleCatchall");var Kd=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=Ms(()=>hA(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=xo,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",b=h._zod.run({value:l[g],issues:[]},u);b instanceof Promise?d.push(b.then(E=>Qs(E,a,g,l,_))):Qs(b,a,g,l,_)}return o?gA(d,l,a,u,n.value,t):d.length?Promise.all(d).then(()=>a):a}});function Ud(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(Ud,"handleUnionResults");var Hc=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=>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=>Ud(u,i,t,o)):Ud(a,i,t,o)}});var Gd=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(!xo(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 Zd=xe("$ZodRecord",(t,e)=>{Kt.init(t,e),t._zod.parse=(r,n)=>{let i=r.value;if(!Ed(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 Yd=xe("$ZodEnum",(t,e)=>{Kt.init(t,e);let r=$c(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(i=>Ad.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}}),Xd=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"?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 Jd=xe("$ZodTransform",(t,e)=>{Kt.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 Jr;return r.value=i,r}});function Ld(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}c(Ld,"handleOptionalResult");var ep=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(`^(${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=>Ld(o,r.value)):Ld(i,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}});var tp=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(`^(${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 rp=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=>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 np=xe("$ZodCustom",(t,e)=>{Tn.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=>zd(o,r,n,t));zd(i,r,n,t)}});function zd(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(zd,"handleRefineResult");var op;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 sp(){return new jc}c(sp,"registry");(op=globalThis).__zod_globalRegistry??(op.__zod_globalRegistry=sp());var Wc=globalThis.__zod_globalRegistry;function ap(t,e){return new t({type:"string",...Rt(e)})}c(ap,"_string");function cp(t,e){return new t({type:"string",coerce:!0,...Rt(e)})}c(cp,"_coercedString");function up(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Rt(e)})}c(up,"_url");function lp(t,e){return new t({type:"number",checks:[],...Rt(e)})}c(lp,"_number");function fp(t,e){return new t({type:"number",coerce:!0,checks:[],...Rt(e)})}c(fp,"_coercedNumber");function dp(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Rt(e)})}c(dp,"_int");function pp(t,e){return new t({type:"boolean",...Rt(e)})}c(pp,"_boolean");function hp(t,e){return new t({type:"boolean",coerce:!0,...Rt(e)})}c(hp,"_coercedBoolean");function gp(t,e){return new t({type:"bigint",coerce:!0,...Rt(e)})}c(gp,"_coercedBigint");function mp(t){return new t({type:"any"})}c(mp,"_any");function _p(t){return new t({type:"unknown"})}c(_p,"_unknown");function yp(t,e){return new t({type:"void",...Rt(e)})}c(yp,"_void");function Ep(t,e){return new t({type:"date",coerce:!0,...Rt(e)})}c(Ep,"_coercedDate");function Ks(t,e){return new kd({check:"greater_than",...Rt(e),value:t,inclusive:!0})}c(Ks,"_gte");function Qr(t,e){return new Nd({check:"min_length",...Rt(e),minimum:t})}c(Qr,"_minLength");function Cn(t,e){return new Od({check:"string_format",format:"regex",...Rt(e),pattern:t})}c(Cn,"_regex");function Ap(t,e,r){let n=Rt(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}c(Ap,"_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)=>js(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>vo(t,r,n),t.parseAsync=async(r,n)=>Ws(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>So(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 I(t){return ap(Zs,t)}c(I,"string");var bp=xe("ZodMiniStringFormat",(t,e)=>{zc.init(t,e),Zs.init(t,e)});var TA=xe("ZodMiniURL",(t,e)=>{Md.init(t,e),bp.init(t,e)});function xp(t){return up(TA,t)}c(xp,"url");var Ys=xe("ZodMiniNumber",(t,e)=>{Mc.init(t,e),tr.init(t,e)});function cr(t){return lp(Ys,t)}c(cr,"number");var CA=xe("ZodMiniNumberFormat",(t,e)=>{Fd.init(t,e),Ys.init(t,e)});function Ip(t){return dp(CA,t)}c(Ip,"int");var qc=xe("ZodMiniBoolean",(t,e)=>{Fc.init(t,e),tr.init(t,e)});function dt(t){return pp(qc,t)}c(dt,"boolean");var vp=xe("ZodMiniBigInt",(t,e)=>{Hd.init(t,e),tr.init(t,e)});var kA=xe("ZodMiniAny",(t,e)=>{jd.init(t,e),tr.init(t,e)});function Po(){return mp(kA)}c(Po,"any");var RA=xe("ZodMiniUnknown",(t,e)=>{Wd.init(t,e),tr.init(t,e)});function Ve(){return _p(RA)}c(Ve,"unknown");var NA=xe("ZodMiniVoid",(t,e)=>{qd.init(t,e),tr.init(t,e)});function Sp(t){return yp(NA,t)}c(Sp,"_void");var wp=xe("ZodMiniDate",(t,e)=>{Qd.init(t,e),tr.init(t,e)});var OA=xe("ZodMiniArray",(t,e)=>{Vd.init(t,e),tr.init(t,e)});function Ue(t,e){return new OA({type:"array",element:t,...Rt(e)})}c(Ue,"array");var $A=xe("ZodMiniObject",(t,e)=>{Kd.init(t,e),tr.init(t,e),er(t,"shape",()=>e.shape)});function N(t,e){let r={type:"object",shape:t??{},...Rt(e)};return new $A(r)}c(N,"object");var DA=xe("ZodMiniUnion",(t,e)=>{Hc.init(t,e),tr.init(t,e)});function tt(t,e){return new DA({type:"union",options:t,...Rt(e)})}c(tt,"union");var BA=xe("ZodMiniDiscriminatedUnion",(t,e)=>{Gd.init(t,e),tr.init(t,e)});function kn(t,e,r){return new BA({type:"union",options:e,discriminator:t,...Rt(r)})}c(kn,"discriminatedUnion");var UA=xe("ZodMiniRecord",(t,e)=>{Zd.init(t,e),tr.init(t,e)});function Ke(t,e,r){return new UA({type:"record",keyType:t,valueType:e,...Rt(r)})}c(Ke,"record");var LA=xe("ZodMiniEnum",(t,e)=>{Yd.init(t,e),tr.init(t,e),t.options=Object.values(e.entries)});function Oe(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new LA({type:"enum",entries:r,...Rt(e)})}c(Oe,"_enum");var zA=xe("ZodMiniLiteral",(t,e)=>{Xd.init(t,e),tr.init(t,e)});function Ce(t,e){return new zA({type:"literal",values:Array.isArray(t)?t:[t],...Rt(e)})}c(Ce,"literal");var MA=xe("ZodMiniTransform",(t,e)=>{Jd.init(t,e),tr.init(t,e)});function Rn(t){return new MA({type:"transform",transform:t})}c(Rn,"transform");var FA=xe("ZodMiniOptional",(t,e)=>{ep.init(t,e),tr.init(t,e)});function V(t){return new FA({type:"optional",innerType:t})}c(V,"optional");var HA=xe("ZodMiniNullable",(t,e)=>{tp.init(t,e),tr.init(t,e)});function To(t){return new HA({type:"nullable",innerType:t})}c(To,"nullable");var jA=xe("ZodMiniPipe",(t,e)=>{rp.init(t,e),tr.init(t,e)});function Nn(t,e){return new jA({type:"pipe",in:t,out:e})}c(Nn,"pipe");var WA=xe("ZodMiniCustom",(t,e)=>{np.init(t,e),tr.init(t,e)});function Xs(t,e){return Ap(WA,t??(()=>!0),e)}c(Xs,"custom");var Co={};hd(Co,{bigint:()=>ZA,boolean:()=>GA,date:()=>YA,number:()=>KA,string:()=>VA});function VA(t){return cp(Zs,t)}c(VA,"string");function KA(t){return fp(Ys,t)}c(KA,"number");function GA(t){return hp(qc,t)}c(GA,"boolean");function ZA(t){return gp(vp,t)}c(ZA,"bigint");function YA(t){return Ep(wp,t)}c(YA,"date");var Vc=N({retryOnFailure:N({defaultValue:V(dt()),hide:V(dt())}),continueOnFailure:N({defaultValue:V(dt()),hide:V(dt())})}),Qc=class{constructor(e,r,n,i,o,s,a,u,l,d,p,g,h){this.name=e;this.displayName=r;this.description=n;this.props=i;this.propertyGroups=o;this.run=s;this.test=a;this.requireAuth=u;this.errorHandlingOptions=l;this.outputSchema=d;this.audience=p;this.aiMetadata=g;this.classification=h}static{c(this,"IAction")}},mr=c(t=>new Qc(t.name,t.displayName,t.description,t.props,t.propertyGroups,t.run,t.test??t.run,t.requireAuth??!0,t.errorHandlingOptions??{continueOnFailure:{defaultValue:!1},retryOnFailure:{defaultValue:!1}},t.outputSchema,t.audience,t.aiMetadata,t.classification),"createAction");var lt=N({displayName:I(),description:V(I()),advanced:V(dt()),width:V(Oe(["half","full"])),icon:V(I()),placeholder:V(I())}),Ze=c((t,e)=>N({type:Ce(e),required:dt(),defaultValue:V(Po())}),"TPropertyValue");var Nr=N({...lt.shape,...Ze(I(),"SHORT_TEXT").shape}),dn=N({...lt.shape,...Ze(I(),"LONG_TEXT").shape});var Tp=N({label:I(),value:Ve(),description:V(I()),icon:V(I())}),Js=N({disabled:V(dt()),placeholder:V(I()),options:Ue(Tp)});var JA=Oe(["cards"]),Or=N({...lt.shape,options:Js,display:V(JA),...Ze(Ve(),"STATIC_DROPDOWN").shape}),pn=N({...lt.shape,options:Js,...Ze(Ue(Ve()),"STATIC_MULTI_SELECT_DROPDOWN").shape});var Kc=N({...lt.shape,...Ze(Ve(),"DROPDOWN").shape,refreshers:Ue(I())}),ko=N({...lt.shape,...Ze(Ue(Ve()),"MULTI_SELECT_DROPDOWN").shape,refreshers:Ue(I())});var hn=N({...lt.shape,reveals:V(Ue(I())),...Ze(dt(),"CHECKBOX").shape});var gn=N({...lt.shape,display:V(Oe(["stepper"])),min:V(cr()),max:V(cr()),step:V(cr()),...Ze(cr(),"NUMBER").shape});var Ro=N({...lt.shape,streaming:V(dt()),...Ze(Ve(),"FILE").shape});var No=N({...lt.shape,...Ze(I(),"DATE_TIME").shape});var Cp=Ke(I(),tt([Nr,dn,Or,ko,pn,hn,gn,Ro,No])),Oo=N({...lt.shape,properties:Cp,...Ze(Ue(Ve()),"ARRAY").shape});var kp=Oe(["any_time","last_24_hours","last_7_days","last_30_days","last_90_days","this_month","custom"]),Rp=N({preset:V(kp),after:V(I()),before:V(I())}),Gc=N({...lt.shape,display:V(Oe(["dropdown"])),...Ze(Rp,"DATE_RANGE").shape});var $o=N({...lt.shape,...Ze(tt([Ke(I(),Ve())]),"JSON").shape});var Np=tt([Nr,Or,$o,Oo,pn]),e0=Ke(I(),Np),Zc=N({refreshers:Ue(I()),...lt.shape,...Ze(Ve(),"DYNAMIC").shape});var ea=N({...lt.shape,...Ze(Sp(),"MARKDOWN").shape});var Do=(r=>(r.ARCHIVE="ARCHIVE",r.REGISTRY="REGISTRY",r))(Do||{}),Ti=(r=>(r.CUSTOM="CUSTOM",r.OFFICIAL="OFFICIAL",r))(Ti||{}),Ci=(v=>(v.ARTIFICIAL_INTELLIGENCE="ARTIFICIAL_INTELLIGENCE",v.COMMUNICATION="COMMUNICATION",v.COMMERCE="COMMERCE",v.CORE="CORE",v.UNIVERSAL_AI="UNIVERSAL_AI",v.FLOW_CONTROL="FLOW_CONTROL",v.BUSINESS_INTELLIGENCE="BUSINESS_INTELLIGENCE",v.ACCOUNTING="ACCOUNTING",v.PRODUCTIVITY="PRODUCTIVITY",v.CONTENT_AND_FILES="CONTENT_AND_FILES",v.DEVELOPER_TOOLS="DEVELOPER_TOOLS",v.CUSTOMER_SUPPORT="CUSTOMER_SUPPORT",v.FORMS_AND_SURVEYS="FORMS_AND_SURVEYS",v.HUMAN_RESOURCES="HUMAN_RESOURCES",v.PAYMENT_PROCESSING="PAYMENT_PROCESSING",v.MARKETING="MARKETING",v.SALES_AND_CRM="SALES_AND_CRM",v))(Ci||{});var Bo=(r=>(r.AUTHORIZATION_CODE="authorization_code",r.CLIENT_CREDENTIALS="client_credentials",r))(Bo||{}),Yc="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||{}),Uo=(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))(Uo||{}),t0=N({strategy:Oe(Uo),paramName:V(I())}),Lo=(r=>(r.SIMULATION="SIMULATION",r.TEST_FUNCTION="TEST_FUNCTION",r))(Lo||{});var ta=(r=>(r.WEBSOCKET="WEBSOCKET",r.NONE="NONE",r))(ta||{}),Op=N({status:V(cr()),body:V(Ve()),headers:V(Ke(I(),I()))}),$p=N({type:Ce("DELAY"),resumeDateTime:I(),requestIdToReply:V(I()),handlerId:V(I()),streamStepProgress:V(Oe(ta))}),Dp=N({type:Ce("WEBHOOK"),requestId:I(),requestIdToReply:V(I()),response:Op,handlerId:V(I()),streamStepProgress:V(Oe(ta))}),r0=tt([$p,Dp]);var n0=N({body:Ve(),rawBody:V(Ve()),headers:Ke(I(),I()),queryParams:Ke(I(),I())});function rr(t){return t==null}c(rr,"isNil");var Xc=br(require("crypto"),1);var i0=128,$n,ki,o0=c(t=>{if(t<0)throw new RangeError("Wrong ID size");try{!$n||$n.length<t?($n=Buffer.allocUnsafe(t*i0),Xc.default.randomFillSync($n),ki=0):ki+t>$n.length&&(Xc.default.randomFillSync($n),ki=0)}catch(e){throw $n=void 0,e}ki+=t},"fillPool"),s0=c(t=>(o0(t|=0),$n.subarray(ki-t,ki)),"random"),a0=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)=>{if(o<=0)return"";let s="";for(;;){let a=r(i),u=i;for(;u--;)if(s+=t[a[u]&n]||"",s.length===o)return s}}},"customRandom"),Up=c((t,e=21)=>a0(t,e,s0),"customAlphabet");var c0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Lp=21,z6=I().check(Cn(new RegExp(`^[0-9a-zA-Z]{${Lp}}$`))),u0=Up(c0,Lp);var Dn=Nn(Rn(t=>t instanceof Date?t.toISOString():t),I()),Lr={id:I(),created:Dn,updated:Dn},Lt=c(t=>V(To(t)),"Nullable");function Jc(t){return V(To(Oe(t)))}c(Jc,"NullableEnum");var H6=Nn(Rn(t=>t==="true"||t===!0?!0:t==="false"||t===!1?!1:void 0),V(dt())),ra=c(t=>Nn(Rn(e=>Array.isArray(e)?e:e!==void 0?[e]:void 0),V(Ue(t))),"OptionalArrayFromQuery");var q6=Ke(I(),Ve());var Ri=(E=>(E.OPENAI="openai",E.OPENROUTER="openrouter",E.ANTHROPIC="anthropic",E.AZURE="azure",E.GOOGLE="google",E.ACTIVEPIECES="activepieces",E.CLOUDFLARE_GATEWAY="cloudflare-gateway",E.CUSTOM="custom",E.BEDROCK="bedrock",E.MISTRAL="mistral",E.XAI="xai",E.DEEPSEEK="deepseek",E.ZAI="zai",E.QWEN="qwen",E.MINIMAX="minimax",E.MOONSHOT="moonshot",E))(Ri||{});var nB=I().check(Cn(/^#[0-9A-Fa-f]{6}$/));var oB=N({filename:I(),data:Ve(),type:Ce("file"),mimetype:V(I())});var l0=br(Mp());var dB=N({...Lr,name:I(),permissions:Ue(I()),platformId:Lt(I()),type:I(),userCount:V(cr())});var Fp=(n=>(n.AGENT_DECIDE="agent-decide",n.CHOOSE_YOURSELF="choose-yourself",n.LEAVE_EMPTY="leave-empty",n))(Fp||{}),eu=(r=>(r.FILE="FILE",r.TABLE="TABLE",r))(eu||{}),tu=(n=>(n.SSE="sse",n.STREAMABLE_HTTP="streamable-http",n.SIMPLE_HTTP="http",n))(tu||{});var ru=(n=>(n.TEXT="text",n.NUMBER="number",n.BOOLEAN="boolean",n))(ru||{});var nu=(r=>(r.IN_PROGRESS="in-progress",r.COMPLETED="completed",r))(nu||{});var f0=N({mode:Oe(Fp),value:Ve()}),d0=N({auth:V(I()),fields:Ke(I(),f0)}),p0=N({pieceName:I(),pieceVersion:I(),actionName:I(),predefinedInput:V(d0)}),h0=N({type:Ce("PIECE"),toolName:I().check(Qr(1)),pieceMetadata:p0}),g0=N({type:Ce("none")}),m0=N({type:Ce("access_token"),accessToken:I()}),_0=N({type:Ce("api_key"),apiKey:I(),apiKeyHeader:I()}),y0=N({type:Ce("headers"),headers:Ke(I(),I())}),E0=kn("type",[g0,m0,_0,y0]),Hp=N({type:Ce("FLOW"),toolName:I().check(Qr(1)),externalFlowId:I(),flowDisplayName:V(I())}),jp=N({type:Ce("MCP"),toolName:I().check(Qr(1)),serverUrl:xp(),protocol:Oe(tu),auth:E0}),Wp=N({type:Ce("KNOWLEDGE_BASE"),toolName:I().check(Qr(1)),sourceType:Oe(eu),sourceId:I(),sourceName:I()}),A0=kn("type",[h0,Hp,jp,Wp]),b0=N({displayName:I(),description:V(I()),type:Oe(ru)}),qp=N({type:Ce("MARKDOWN"),markdown:I()}),Ni={type:Ce("TOOL_CALL"),input:Lt(Ke(I(),Ve())),output:V(Ve()),toolName:I(),status:Oe(nu),toolCallId:I(),startTime:I(),endTime:V(I())},jB=N(Ni),Qp=kn("toolCallType",[N({...Ni,toolCallType:Ce("PIECE"),pieceName:I(),pieceVersion:I(),actionName:I()}),N({...Ni,toolCallType:Ce("FLOW"),displayName:I(),externalFlowId:I()}),N({...Ni,toolCallType:Ce("MCP"),displayName:I(),serverUrl:I()}),N({...Ni,toolCallType:Ce("KNOWLEDGE_BASE"),displayName:I(),sourceType:I()}),N({...Ni,toolCallType:Ce("UNKNOWN"),displayName:I()})]),x0=tt([qp,Qp]);var iu=(r=>(r.IMAGE="image",r.TEXT="text",r))(iu||{}),mn=N({apiKey:I()}),I0=mn,v0=N({apiKey:I(),apiKeyHash:I()}),S0=mn,w0=mn,P0=mn,T0=mn,C0=mn,k0=mn,R0=mn,Yp=N({accessKeyId:I().check(Qr(1)),secretAccessKey:I().check(Qr(1))}),N0=N({}),O0=N({}),$0=N({}),D0=N({}),B0=N({}),U0=N({}),Xp=N({modelId:I(),modelName:I(),modelType:Oe(iu)}),Jp=N({apiKeyHeader:I(),baseUrl:I(),models:Ue(Xp),defaultHeaders:V(Ke(I(),I()))}),eh=N({accountId:I(),gatewayId:I(),models:Ue(Xp),vertexProject:V(I()),vertexRegion:V(I())}),th=N({resourceName:I(),apiVersion:Nn(Rn(t=>typeof t=="string"&&t.trim().length===0?void 0:t),V(I()))}),rh=N({region:I().check(Qr(1))}),nh=N({}),L0=tt([I0,P0,T0,C0,k0,w0,S0,v0,Yp,R0]),ih=tt([Jp,eh,th,rh,N0,$0,D0,B0,O0,U0,nh]),z0=N({id:I(),name:I(),type:Oe(iu)}),M0=N({id:I(),name:I(),provider:Oe(Ri),config:ih,enabledForChat:dt()}),F0=N({provider:Oe(Ri),name:I(),enabledForChat:dt(),keys:Ue(N({id:I(),name:I()}))}),H0=N({provider:Oe(Ri),configId:I(),config:ih,auth:L0,platformId:I()});var VB={openai:"openai",anthropic:"anthropic","google-ai-studio":"google","google-vertex-ai":"google"},Vp=["gpt-5.5","gpt-5.4-mini","gpt-5.4-nano","gpt-4.1","gpt-4.1-mini"],j0=["claude-sonnet-4-6","claude-opus-4-7","claude-haiku-4-5"],W0=["claude-sonnet-4.6","claude-opus-4.7","claude-haiku-4.5"],Kp=["gemini-2.5-pro","gemini-2.5-flash","gemini-3.1-pro-preview","gemini-3-flash-preview"],q0=["grok-4.20","grok-4.1-fast"],Q0={openai:Vp,anthropic:j0,google:Kp,activepieces:[...W0.map(t=>`anthropic/${t}`),...Vp.map(t=>`openai/${t}`),...Kp.map(t=>`google/${t}`),...q0.map(t=>`x-ai/${t}`)]};var Gp=128e3,V0={openai:128e3,anthropic:2e5,google:1048576,bedrock:2e5,azure:128e3,openrouter:128e3,activepieces:2e5,mistral:128e3};function K0({provider:t}){return t?V0[t]??Gp:Gp}c(K0,"getMaxContextTokens");var Zp={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"},G0={anthropic:"native",google:"native",openrouter:"plugin",activepieces:"plugin"},Z0=new Set(["anthropic","mistral","xai","deepseek","zai","qwen","minimax","moonshot"]),Y0={xai:"https://api.x.ai/v1",deepseek:"https://api.deepseek.com/v1",zai:"https://api.z.ai/api/paas/v4",qwen:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1",minimax:"https://api.minimax.io/v1",moonshot:"https://api.moonshot.ai/v1"};function _r(t){return{chatModels:Q0[t],maxContextTokens:K0({provider:t}),defaultEmbeddingModel:Zp[t],supportsEmbedding:Zp[t]!==void 0,supportsImageGeneration:!Z0.has(t),webSearch:G0[t]}}c(_r,"buildProviderCapabilities");var X0={openai:_r("openai"),anthropic:_r("anthropic"),openrouter:_r("openrouter"),azure:_r("azure"),google:_r("google"),"cloudflare-gateway":_r("cloudflare-gateway"),custom:_r("custom"),bedrock:_r("bedrock"),mistral:_r("mistral"),activepieces:_r("activepieces"),xai:_r("xai"),deepseek:_r("deepseek"),zai:_r("zai"),qwen:_r("qwen"),minimax:_r("minimax"),moonshot:_r("moonshot")};var J0=N({base64Url:I(),fileName:I(),extension:V(I())}),eb=N({mimeType:I(),url:I(),fileName:V(I())}),ou=tt([J0,eb]);var tb=tt([N({type:Ce("file"),value:ou}),N({type:Ce("markdown"),value:I(),files:V(Ue(ou))})]),rb=N({sessionId:I(),message:I(),files:V(Ue(I()))});var sh=(r=>(r.ON_NEW_RECORD="ON_NEW_RECORD",r.ON_UPDATE_RECORD="ON_UPDATE_RECORD",r))(sh||{}),ah=(r=>(r.ENABLED="ENABLED",r.DISABLED="DISABLED",r))(ah||{}),su=(n=>(n.RECORD_CREATED="RECORD_CREATED",n.RECORD_UPDATED="RECORD_UPDATED",n.RECORD_DELETED="RECORD_DELETED",n))(su||{});var nb=tt([N({...Lr,name:I(),externalId:I(),type:Ce("STATIC_DROPDOWN"),tableId:I(),projectId:I(),data:N({options:Ue(N({value:I()}))})}),N({...Lr,name:I(),externalId:I(),type:tt([Ce("TEXT"),Ce("NUMBER"),Ce("DATE"),Ce("DATETIME")]),tableId:I(),projectId:I()})]),ib=N({...Lr,name:I(),folderId:Lt(I()),projectId:I(),externalId:I(),status:Jc(ah),trigger:Jc(sh)}),ob=N({...Lr,tableId:I(),projectId:I(),cells:Ke(I(),N({updated:I(),created:I(),value:Ve(),fieldName:I()}))}),sb=N({events:Ue(Oe(su)),webhookUrl:I(),flowId:I()}),ab=N({fields:Ue(N({id:I(),name:I()})),rows:Ue(Ke(I(),I())),name:I()}),cb=N({projectId:I(),limit:V(Co.number()),cursor:V(I()),name:V(I()),externalIds:ra(I()),folderId:V(I()),folderIds:ra(I())}),ub=N({records:Ue(Ue(N({fieldId:I(),value:uh()}))),tableId:I()}),lb=N({cells:V(Ue(N({fieldId:I(),value:uh()}))),tableId:I(),agentUpdate:V(dt())}),ch=kn("operator",[ri("eq"),ri("neq"),ri("gt"),ri("gte"),ri("lt"),ri("lte"),ri("co"),oh("exists"),oh("not_exists")]),fb=N({tableId:I(),limit:V(Co.number()),cursor:V(I()),filters:ra(ch)});function uh(){return Nn(Rn(t=>t==null?t:String(t)),To(I()))}c(uh,"coerceToString");function ri(t){return N({fieldId:I(),operator:Ce(t),value:I()})}c(ri,"valueFilter");function oh(t){return N({fieldId:I(),operator:Ce(t)})}c(oh,"existenceFilter");var db=N({status:V(cr()),body:V(Ve()),headers:V(Ke(I(),I()))}),pb=N({...Lr,deleted:Lt(Dn),ownerId:I(),displayName:I(),platformId:I(),externalId:Lt(I())});var lh=N({name:I(),description:V(I()),type:I(),required:dt()}),hb=N({pieceName:I(),triggerName:I(),input:N({toolName:I(),toolDescription:I(),inputSchema:Ue(lh),returnsResponse:dt()})});var fh="^[0-9]+\\.[0-9]+\\.[0-9]+$",dU=new RegExp(fh),mb="^([~^])?[0-9]+\\.[0-9]+\\.[0-9]+$",pU=I().check(Cn(new RegExp(fh))),hU=I().check(Cn(new RegExp(mb))),_b=N({packageType:Ce("ARCHIVE"),pieceType:Oe(Ti),pieceName:I(),pieceVersion:I(),archiveId:I(),platformId:I()}),dh=N({packageType:Ce("REGISTRY"),pieceType:Ce("OFFICIAL"),pieceName:I(),pieceVersion:I()}),ph=N({packageType:Ce("REGISTRY"),pieceType:Ce("CUSTOM"),pieceName:I(),pieceVersion:I(),platformId:I()}),gU=tt([dh,ph]),mU=tt([_b,dh,ph]);var yb=kn("type",[N({type:Ce("CRON_EXPRESSION"),cronExpression:I(),timezone:I()}),N({type:Ce("INTERVAL"),intervalMs:Ip().check(Ks(6e4))})]),_U=N({...Lr,type:Oe(On),projectId:I(),flowId:I(),triggerName:I(),schedule:Lt(yb),flowVersionId:I(),pieceName:I(),pieceVersion:I(),deleted:Lt(I()),simulate:dt()}),hh=(E=>(E.UNKNOWN="UNKNOWN",E.FLOW_RUN_LOG="FLOW_RUN_LOG",E.FLOW_RUN_LOG_SLICE="FLOW_RUN_LOG_SLICE",E.PACKAGE_ARCHIVE="PACKAGE_ARCHIVE",E.FLOW_STEP_FILE="FLOW_STEP_FILE",E.SAMPLE_DATA="SAMPLE_DATA",E.TRIGGER_PAYLOAD="TRIGGER_PAYLOAD",E.SAMPLE_DATA_INPUT="SAMPLE_DATA_INPUT",E.TRIGGER_EVENT_FILE="TRIGGER_EVENT_FILE",E.PROJECT_RELEASE="PROJECT_RELEASE",E.FLOW_VERSION_BACKUP="FLOW_VERSION_BACKUP",E.PLATFORM_ASSET="PLATFORM_ASSET",E.USER_PROFILE_PICTURE="USER_PROFILE_PICTURE",E.WEBHOOK_PAYLOAD="WEBHOOK_PAYLOAD",E.KNOWLEDGE_BASE="KNOWLEDGE_BASE",E.FLOW_BUNDLE="FLOW_BUNDLE",E))(hh||{}),gh=(r=>(r.NONE="NONE",r.ZSTD="ZSTD",r))(gh||{}),mh=(r=>(r.S3="S3",r.DB="DB",r))(mh||{}),yU=N({...Lr,projectId:Lt(I()),platformId:Lt(I()),type:Oe(hh),compression:Oe(gh),data:V(Ve()),location:Oe(mh),size:Lt(cr()),fileName:Lt(I()),s3Key:Lt(I()),metadata:Lt(Ke(I(),I()))}),_h=(n=>(n.ADMIN="ADMIN",n.MEMBER="MEMBER",n.OPERATOR="OPERATOR",n))(_h||{}),yh=(r=>(r.ACTIVE="ACTIVE",r.INACTIVE="INACTIVE",r))(yh||{}),EU=N({id:I(),email:I(),firstName:I(),status:Oe(yh),externalId:Lt(I()),platformId:Lt(I()),platformRole:Oe(_h),lastName:I(),created:Dn,updated:Dn,lastActiveDate:Lt(Dn),imageUrl:Lt(I())});var cu=N({...lt.shape,...Ze(Ke(I(),Ve()),"OBJECT").shape});var uu=N({...lt.shape,formatProperty:V(I()),...Ze(I(),"RICH_TEXT").shape});var bh=N({...lt.shape,...Ze(I(),"COLOR").shape});var lu=tt([Nr,dn,uu,ea,hn,Or,pn,Kc,ko,Zc,gn,Oo,cu,$o,No,Gc,Ro,bh]),gt={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"}},RichText(t){return{...t,valueSchema:void 0,type:"RICH_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"}},DateRange(t){return{...t,valueSchema:void 0,type:"DATE_RANGE"}},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=N({displayName:I(),description:V(I()),hasConnectionIdentifier:V(dt())});var xh=N({username:I(),password:I()}),fu=N({...en.shape,username:N({displayName:I(),description:V(I())}),password:N({displayName:I(),description:V(I())}),...Ze(xh,"BASIC_AUTH").shape});var xb=Ke(I(),tt([Nr,dn,gn,hn,Or])),du=N({...en.shape,props:xb,...Ze(Ve(),"CUSTOM_AUTH").shape});var ni=N({...en.shape,...Ze(N({auth:I()}),"SECRET_TEXT").shape});var Ib=Ke(I(),tt([Nr,dn,ni,gn,hn,Or,pn,ea])),Ih=N({...en.shape,props:Ib,...Ze(Ve(),"OIDC").shape});var pu=(r=>(r.HEADER="HEADER",r.BODY="BODY",r))(pu||{}),vh=tt([Nr,ni,Or]),Sh=Ke(I(),vh),vb=N({props:V(Ke(I(),vh)),authUrl:I(),tokenUrl:I(),scope:Ue(I()),prompt:V(tt([Ce("none"),Ce("consent"),Ce("login"),Ce("omit")])),pkce:V(dt()),pkceMethod:V(tt([Ce("plain"),Ce("S256")])),authorizationMethod:V(Oe(pu)),grantType:V(tt([Oe(Bo),Ce(Yc)])),extra:V(Ke(I(),I()))}),wh=N({access_token:I(),props:V(Sh),data:Ke(I(),Po())}),hu=N({...en.shape,...vb.shape,...Ze(wh,"OAUTH2").shape});var Oi=tt([fu,du,Ih,hu,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 rz={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 Sb=N({...lt.shape,...Ze(Ve(),"CUSTOM").shape,code:I()});var Pb=tt([lu,Oi]),gu=Ke(I(),Pb),Iz=Ke(I(),lu);var Ph=tt([N({strategy:Ce("CRON"),cronExpression:I()}),N({strategy:Ce("NONE")})]),$i=class{constructor(e,r,n,i,o,s,a,u,l,d,p,g,h,_,b,E,v,w,H,D,J){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=b;this.sampleData=E;this.testStrategy=v;this.outputSchema=w;this.aiMetadata=H;this.classification=D;this.propertyGroups=J}static{c(this,"ITrigger")}},Th=c(t=>{switch(t.type){case"WEBHOOK":return new $i(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,t.classification,t.propertyGroups);case"POLLING":return new $i(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,t.classification,t.propertyGroups);case"MANUAL":return new $i(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,t.classification,t.propertyGroups);case"APP_WEBHOOK":return new $i(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,rr(t.sampleData)&&rr(t.test)?"SIMULATION":"TEST_FUNCTION",t.outputSchema,t.aiMetadata,t.classification,t.propertyGroups)}},"createTrigger");var Ch="2",ia="0.82.0";var mu=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:Ch}),"getContextInfo");(!Cb(l)||kb(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:Tb(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}},Rh=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 mu(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 Tb(t){if(t!==void 0)return Array.isArray(t)?t.map(kh):kh(t)}c(Tb,"withConnectionIdentifierFlag");function kh(t){return{...t,hasConnectionIdentifier:t.getConnectionIdentifier!==void 0}}c(kh,"flagConnectionIdentifier");function Cb(t){return/^\d+\.\d+\.\d+$/.test(t)}c(Cb,"isValidSimpleSemver");function kb(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(kb,"isSemverLessThan");var Rb=V(Ke(I(),Ke(I(),I()))),Nh=N({id:V(I()),name:I(),displayName:I(),logoUrl:I(),description:I(),authors:Ue(I()),platformId:V(I()),directoryPath:V(I()),auth:V(tt([Oi,Ue(Oi)])),version:I(),categories:V(Ue(Oe(Ci))),minimumSupportedRelease:V(I()),maximumSupportedRelease:V(I()),deprecated:V(dt()),i18n:Rb}),Nb=Oe(["human","ai","both"]),Oh=N({description:V(I()),idempotent:V(dt())}),$h=Oe(["READ","SEARCH","WRITE","DESTRUCTIVE"]);var Ob=Oe(["tabs","section","summary","builder","footer"]),Dh=N({key:I(),display:Ob,label:V(I()),description:V(I()),icon:V(I()),props:Ue(I())}),Bh=N({name:I(),displayName:I(),description:I(),props:gu,propertyGroups:V(Ue(Dh)),requireAuth:dt(),errorHandlingOptions:V(Vc),outputSchema:V(Xs()),audience:V(Nb),aiMetadata:V(Oh),classification:V($h)}),Uh=N({name:I(),displayName:I(),description:I(),props:gu,propertyGroups:V(Ue(Dh)),errorHandlingOptions:V(Vc),type:Oe(On),sampleData:Ve(),handshakeConfiguration:V(Xs()),renewConfiguration:V(Ph),testStrategy:Oe(Lo),outputSchema:V(Xs()),aiMetadata:V(Oh),classification:V($h)}),$b=N({...Nh.shape,actions:Ke(I(),Bh),triggers:Ke(I(),Uh)}),Db=N({...Nh.shape,actions:cr(),triggers:cr(),suggestedActions:V(Ue(Bh)),suggestedTriggers:V(Ue(Uh))}),Lh=N({projectUsage:cr(),pieceType:Oe(Ti),packageType:Oe(Do),platformId:V(I()),archiveId:V(I())}),SM=N({...$b.shape,...Lh.shape}),wM=N({...Db.shape,...Lh.shape}),PM=N({name:I(),version:I()});var Bb=br(require("path")),Ub=br(require("fs/promises"));var PE=br(nn());var SE=br(vE()),wE=br(nn());async function Bt(t){return rr(t)?"sftp":t}c(Bt,"getProtocolBackwardCompatibility");async function Ht(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 Bt(e);if(d==="sftp"){let p=new SE.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 xv=2**32,km=(()=>{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)?)/),
|
|
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 EE.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 ir=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 bE=require("stream");var I1={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 I1[t]??{error:"Unknown error code"}}c(Bt,"getSftpError");async function v1(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(v1,"createFileWithSFTP");async function S1(t,e,r){let n=e.substring(0,e.lastIndexOf("/"));await t.ensureDir(n);let i=Buffer.from(r);await t.uploadFrom(bE.Readable.from(i),e)}c(S1,"createFileWithFTP");var xE=gr({audience:"both",auth:ir,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 S1(i,e,r);break;default:case"sftp":await v1(i,e,r);break}return{status:"success"}}catch(o){return o instanceof AE.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 IE=Er(nn());async function w1(t,e,r){let n=e.substring(0,e.lastIndexOf("/"));await t.ensureDir(n),await t.uploadFrom(r,e)}c(w1,"uploadFileToFTP");async function P1(t,e,r){if(!await t.exists(e)){let i=e.substring(0,e.lastIndexOf("/"));await t.mkdir(i,!0)}await t.put(r,e),await t.end()}c(P1,"uploadFileToSFTP");var vE=gr({audience:"both",auth:ir,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,streaming:!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 w1(e,r,n.body);break;default:case"sftp":await P1(e,r,n.body);break}return{status:"success"}}catch(o){return o instanceof IE.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 SE=Er(nn()),sd=require("stream");function T1(t,e){let r=new sd.PassThrough;return t.downloadTo(r,e).catch(n=>r.destroy(n)),r}c(T1,"readFTP");function C1(t,e){let r=new sd.PassThrough;return t.get(e,r).catch(n=>r.destroy(n)),r}c(C1,"readSFTP");var wE=gr({audience:"both",auth:ir,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=T1(e,r);break;default:case"sftp":o=C1(e,r);break}return{file:await t.files.write({fileName:n,data:o})}}catch(o){return o instanceof SE.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(rr(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=[];rr(a)||l==-1?d=u??[]:d=u?.slice(0,l)??[],rr(i)||(d=d.slice(-i));let p=d?.[0]?.id;return rr(p)||await e.put("lastItem",p),d.map(g=>g.data)}}},async onEnable(t,{store:e,auth:r,propsValue:n,server:i,isRepublish:o}){switch(t.strategy){case 0:{if(o&&!rr(await e.get("lastPoll")))break;await e.put("lastPoll",Date.now());break}case 1:{if(o&&!rr(await e.get("lastItem")))break;let a=(await t.items({store:e,auth:r,propsValue:n,lastItemId:null,server:i}))?.[0]?.id;rr(a)?await e.delete("lastItem"):await e.put("lastItem",a);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")},CE=Ih({auth:ir,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 kE=Er(nn());async function R1(t,e,r){r?await t.removeDir(e):await t.removeEmptyDir(e)}c(R1,"deleteFolderFTP");async function N1(t,e,r){await t.rmdir(e,r)}c(N1,"deleteFolderSFTP");var RE=gr({audience:"both",auth:ir,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 R1(e,r,n);break;default:case"sftp":await N1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof kE.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 O1(t,e){await t.remove(e)}c(O1,"deleteFileFromFTP");async function $1(t,e){await t.delete(e)}c($1,"deleteFileFromSFTP");var OE=gr({audience:"both",auth:ir,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 O1(e,r);break;default:case"sftp":await $1(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 D1(t,e){let r=await t.list(e);return await t.end(),r}c(D1,"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 DE=gr({audience:"both",auth:ir,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 B1(e,r);break;default:case"sftp":i=await D1(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:ir,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 U1(t,e,r){await t.rename(e,r)}c(U1,"renameFTP");async function L1(t,e,r){await t.rename(e,r),await t.end()}c(L1,"renameSFTP");var zE=gr({audience:"both",auth:ir,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 U1(e,r,n);break;default:case"sftp":await L1(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 z1=wh({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:ir,actions:[xE,vE,wE,OE,UE,RE,DE,zE],triggers:[CE]});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)?)/),b=g.match(/(\n-----END [A-Z0-9 ]+ KEY-----)/);if(_&&b){let E=_[1],v=b[1],H=g.replace(E,"").replace(v,"").replace(/\s+/g,"").match(/.{1,64}/g)||[];g=E+H.join(`
|
|
34
|
+
`)+v}}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 wE.Client;return await p.access({host:r,port:n,user:s,password:a,secure:d==="ftps",secureOptions:{rejectUnauthorized:!(i??!1)}}),p}}c(Ht,"getClient");async function Zt(t,e){await Bt(e)==="sftp"?await t.end():t.close()}c(Zt,"endClient");var ir=Mo.CustomAuth({props:{protocol:gt.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:gt.Checkbox({displayName:"Allow Unauthorized Certificates",description:"Allow connections to servers with self-signed certificates",defaultValue:!1,required:!1}),allow_anonymous_login:gt.Checkbox({displayName:"Allow Anonymous Login",description:"Allow anonymous login to FTP servers (only applicable for FTP/FTPS)",defaultValue:!1,required:!1}),host:gt.ShortText({displayName:"Host",description:"The host of the server",required:!0}),port:gt.Number({displayName:"Port",description:"The port of the server",required:!0,defaultValue:22}),username:gt.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:gt.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 Bt(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 Ht(t);break}default:{e=await Ht(t);break}}return{valid:!0}}catch(n){return{valid:!1,error:n?.message}}finally{e&&await Zt(e,t.protocol)}},"validate"),required:!0});var TE=require("stream");var B1={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 Ut(t){return B1[t]??{error:"Unknown error code"}}c(Ut,"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(TE.Readable.from(i),e)}c(L1,"createFileWithFTP");var CE=mr({audience:"both",auth:ir,name:"create_file",classification:"WRITE",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:gt.ShortText({displayName:"File Path",required:!0}),fileContent:gt.LongText({displayName:"File content",required:!0})},async run(t){let e=t.propsValue.fileName,r=t.propsValue.fileContent,n=await Bt(t.auth.props.protocol),i=await Ht(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 PE.FTPError?(console.error(Ut(o.code)),{status:"error",error:Ut(o.code)}):{status:"error",error:o}}finally{await Zt(i,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(rr(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=[];rr(a)||l==-1?d=u??[]:d=u?.slice(0,l)??[],rr(i)||(d=d.slice(-i));let p=d?.[0]?.id;return rr(p)||await e.put("lastItem",p),d.map(g=>g.data)}}},async onEnable(t,{store:e,auth:r,propsValue:n,server:i,isRepublish:o}){switch(t.strategy){case 0:{if(o&&!rr(await e.get("lastPoll")))break;await e.put("lastPoll",Date.now());break}case 1:{if(o&&!rr(await e.get("lastItem")))break;let a=(await t.items({store:e,auth:r,propsValue:n,lastItemId:null,server:i}))?.[0]?.id;rr(a)?await e.delete("lastItem"):await e.put("lastItem",a);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 z1(s.map(a=>a.data))}};function z1(t){return t.length<=5?t:t.slice(0,5)}c(z1,"getFirstFiveOrAll");var kE=require("node:stream");function M1(t){return"body"in t?{body:t.body,size:t.size}:{body:kE.Readable.from(t.data),size:t.data.length}}c(M1,"toStreamingBody");async function*F1({readable:t,chunkSize:e}){let r=[],n=0;for await(let i of t)for(r.push(Buffer.isBuffer(i)?i:Buffer.from(i)),n+=r[r.length-1].length;n>=e;){let o=r.length===1?r[0]:Buffer.concat(r);yield o.subarray(0,e);let s=o.subarray(e);r=s.length>0?[s]:[],n=s.length}n>0&&(yield r.length===1?r[0]:Buffer.concat(r))}c(F1,"readChunks");var RE={readChunks:F1,toStreamingBody:M1};var NE=br(nn());async function H1(t,e,r){let n=e.substring(0,e.lastIndexOf("/"));await t.ensureDir(n),await t.uploadFrom(r,e)}c(H1,"uploadFileToFTP");async function j1(t,e,r){if(!await t.exists(e)){let i=e.substring(0,e.lastIndexOf("/"));await t.mkdir(i,!0)}await t.put(r,e),await t.end()}c(j1,"uploadFileToSFTP");var OE=mr({audience:"both",auth:ir,name:"upload_file",classification:"WRITE",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:gt.ShortText({displayName:"File Path",required:!0,description:"The path on the sftp server to store the file. e.g. `./myfolder/test.mp3`"}),fileContent:gt.File({displayName:"File content",required:!0,streaming:!0})},async run(t){let e=await Ht(t.auth.props),r=t.propsValue.fileName,{body:n}=RE.toStreamingBody(t.propsValue.fileContent),i=await Bt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await H1(e,r,n);break;default:case"sftp":await j1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof NE.FTPError?(console.error(Ut(o.code)),{status:"error",content:null,error:Ut(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var $E=br(nn()),cd=require("stream");function W1(t,e){let r=new cd.PassThrough;return t.downloadTo(r,e).catch(n=>r.destroy(n)),r}c(W1,"readFTP");function q1(t,e){let r=new cd.PassThrough;return t.get(e,r).catch(n=>r.destroy(n)),r}c(q1,"readSFTP");var DE=mr({audience:"both",auth:ir,name:"read_file_content",classification:"READ",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:gt.ShortText({displayName:"File Path",required:!0})},async run(t){let e=await Ht(t.auth.props),r=t.propsValue.filePath,n=r.split("/").pop()??r,i=await Bt(t.auth.props.protocol);try{let o;switch(i){case"ftps":case"ftp":o=W1(e,r);break;default:case"sftp":o=q1(e,r);break}return{file:await t.files.write({fileName:n,data:o})}}catch(o){return o instanceof $E.FTPError?(console.error(Ut(o.code)),{status:"error",content:null,error:Ut(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var Tc=br(BE());function UE(t,e){return e==="sftp"?t.modifyTime:(0,Tc.default)(t.modifiedAt).valueOf()}c(UE,"getModifyTime");var Pc={strategy:0,items:c(async({auth:t,propsValue:e,lastFetchEpochMS:r})=>{let n=null;try{let i=await Bt(t.props.protocol);n=await Ht(t.props);let s=(await n.list(e.path)).filter(u=>{let l=UE(u,i);return(0,Tc.default)(l).valueOf()>r});return(e.ignoreHiddenFiles?s.filter(u=>!u.name.startsWith(".")):s).map(u=>{let l=UE(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")},LE=Th({auth:ir,name:"new_file",classification:"READ",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:gt.ShortText({displayName:"Path",description:"The path to watch for new files",required:!0,defaultValue:"./"}),ignoreHiddenFiles:gt.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 zE=br(nn());async function Q1(t,e,r){r?await t.removeDir(e):await t.removeEmptyDir(e)}c(Q1,"deleteFolderFTP");async function V1(t,e,r){await t.rmdir(e,r)}c(V1,"deleteFolderSFTP");var ME=mr({audience:"both",auth:ir,name:"deleteFolder",classification:"DESTRUCTIVE",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:gt.ShortText({displayName:"Folder Path",required:!0,description:"The path of the folder to delete e.g. `./myfolder`"}),recursive:gt.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 Ht(t.auth.props),r=t.propsValue.folderPath,n=t.propsValue.recursive??!1,i=await Bt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await Q1(e,r,n);break;default:case"sftp":await V1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof zE.FTPError?(console.error(Ut(o.code)),{status:"error",error:Ut(o.code)}):{status:"error",error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var FE=br(nn());async function K1(t,e){await t.remove(e)}c(K1,"deleteFileFromFTP");async function G1(t,e){await t.delete(e)}c(G1,"deleteFileFromSFTP");var HE=mr({audience:"both",auth:ir,name:"deleteFile",classification:"DESTRUCTIVE",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:gt.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 Ht(t.auth.props),r=t.propsValue.filePath,n=await Bt(t.auth.props.protocol);try{switch(n){case"ftps":case"ftp":await K1(e,r);break;default:case"sftp":await G1(e,r);break}return{status:"success"}}catch(i){return i instanceof FE.FTPError?(console.error(Ut(i.code)),{status:"error",error:Ut(i.code)}):{status:"error",error:i}}finally{await Zt(e,t.auth.props.protocol)}}});var jE=br(nn());async function Z1(t,e){let r=await t.list(e);return await t.end(),r}c(Z1,"listSFTP");async function Y1(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(Y1,"listFTP");var WE=mr({audience:"both",auth:ir,name:"listFolderContents",classification:"SEARCH",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:gt.ShortText({displayName:"Directory Path",required:!0,description:"The path of the folder to list e.g. `./myfolder`"})},async run(t){let e=await Ht(t.auth.props),r=t.propsValue.directoryPath,n=await Bt(t.auth.props.protocol);try{let i;switch(n){case"ftps":case"ftp":i=await Y1(e,r);break;default:case"sftp":i=await Z1(e,r);break}return{status:"success",contents:i}}catch(i){return i instanceof jE.FTPError?(console.error(Ut(i.code)),{status:"error",content:null,error:Ut(i.code)}):{status:"error",content:null,error:i}}finally{await Zt(e,t.auth.props.protocol)}}});var qE=br(nn());var QE=mr({audience:"both",auth:ir,name:"createFolder",classification:"WRITE",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:gt.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:gt.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 Ht(t.auth.props),r=t.propsValue.folderPath,n=t.propsValue.recursive??!1,i=await Bt(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 qE.FTPError?(console.error(Ut(o.code)),{status:"error",error:Ut(o.code)}):{status:"error",error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var VE=br(nn());async function X1(t,e,r){await t.rename(e,r)}c(X1,"renameFTP");async function J1(t,e,r){await t.rename(e,r),await t.end()}c(J1,"renameSFTP");var KE=mr({audience:"both",auth:ir,name:"renameFileOrFolder",classification:"WRITE",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:gt.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:gt.ShortText({displayName:"Old Path",required:!0,description:"The path of the file or folder to rename e.g. `./myfolder/test.mp3`"}),newPath:gt.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 Ht(t.auth.props),r=t.propsValue.oldPath,n=t.propsValue.newPath,i=await Bt(t.auth.props.protocol);try{switch(i){case"ftps":case"ftp":await X1(e,r,n);break;default:case"sftp":await J1(e,r,n);break}return{status:"success"}}catch(o){return o instanceof VE.FTPError?(console.error(Ut(o.code)),{status:"error",content:null,error:Ut(o.code)}):{status:"error",content:null,error:o}}finally{await Zt(e,t.auth.props.protocol)}}});var eC=Rh({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:ir,actions:[CE,OE,DE,HE,QE,ME,WE,KE],triggers:[LE]});0&&(module.exports={endClient,ftpSftp,getClient,getProtocolBackwardCompatibility});
|
|
35
35
|
/*! Bundled license information:
|
|
36
36
|
|
|
37
37
|
safe-buffer/index.js:
|