@libp2p/autonat 1.0.7 → 1.0.8-092861e23

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/dist/index.min.js CHANGED
@@ -1,31 +1,49 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PAutonat = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PAutonat=(()=>{var Hc=Object.create;var An=Object.defineProperty;var $c=Object.getOwnPropertyDescriptor;var Gc=Object.getOwnPropertyNames;var Wc=Object.getPrototypeOf,Yc=Object.prototype.hasOwnProperty;var ft=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),_t=(t,e)=>{for(var r in e)An(t,r,{get:e[r],enumerable:!0})},Gs=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gc(e))!Yc.call(t,i)&&i!==r&&An(t,i,{get:()=>e[i],enumerable:!(n=$c(e,i))||n.enumerable});return t};var Mt=(t,e,r)=>(r=t!=null?Hc(Wc(t)):{},Gs(e||!t||!t.__esModule?An(r,"default",{value:t,enumerable:!0}):r,t)),Zc=t=>Gs(An({},"__esModule",{value:!0}),t);var ct=ft((hg,xa)=>{xa.exports={options:{usePureJavaScript:!1}}});var ba=ft((dg,va)=>{var ji={};va.exports=ji;var ma={};ji.encode=function(t,e,r){if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(r!==void 0&&typeof r!="number")throw new TypeError('"maxline" must be a number.');var n="";if(!(t instanceof Uint8Array))n=nl(t,e);else{var i=0,o=e.length,s=e.charAt(0),a=[0];for(i=0;i<t.length;++i){for(var c=0,f=t[i];c<a.length;++c)f+=a[c]<<8,a[c]=f%o,f=f/o|0;for(;f>0;)a.push(f%o),f=f/o|0}for(i=0;t[i]===0&&i<t.length-1;++i)n+=s;for(i=a.length-1;i>=0;--i)n+=e[a[i]]}if(r){var u=new RegExp(".{1,"+r+"}","g");n=n.match(u).join(`\r
3
- `)}return n};ji.decode=function(t,e){if(typeof t!="string")throw new TypeError('"input" must be a string.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');var r=ma[e];if(!r){r=ma[e]=[];for(var n=0;n<e.length;++n)r[e.charCodeAt(n)]=n}t=t.replace(/\s/g,"");for(var i=e.length,o=e.charAt(0),s=[0],n=0;n<t.length;n++){var a=r[t.charCodeAt(n)];if(a===void 0)return;for(var c=0,f=a;c<s.length;++c)f+=s[c]*i,s[c]=f&255,f>>=8;for(;f>0;)s.push(f&255),f>>=8}for(var u=0;t[u]===o&&u<t.length-1;++u)s.push(0);return typeof Buffer<"u"?Buffer.from(s.reverse()):new Uint8Array(s.reverse())};function nl(t,e){var r=0,n=e.length,i=e.charAt(0),o=[0];for(r=0;r<t.length();++r){for(var s=0,a=t.at(r);s<o.length;++s)a+=o[s]<<8,o[s]=a%n,a=a/n|0;for(;a>0;)o.push(a%n),a=a/n|0}var c="";for(r=0;t.at(r)===0&&r<t.length()-1;++r)c+=i;for(r=o.length-1;r>=0;--r)c+=e[o[r]];return c}});var Et=ft((pg,Ba)=>{var wa=ct(),Ea=ba(),v=Ba.exports=wa.util=wa.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){v.nextTick=process.nextTick,typeof setImmediate=="function"?v.setImmediate=setImmediate:v.setImmediate=v.nextTick;return}if(typeof setImmediate=="function"){v.setImmediate=function(){return setImmediate.apply(void 0,arguments)},v.nextTick=function(a){return setImmediate(a)};return}if(v.setImmediate=function(a){setTimeout(a,0)},typeof window<"u"&&typeof window.postMessage=="function"){let a=function(c){if(c.source===window&&c.data===t){c.stopPropagation();var f=e.slice();e.length=0,f.forEach(function(u){u()})}};var s=a,t="forge.setImmediate",e=[];v.setImmediate=function(c){e.push(c),e.length===1&&window.postMessage(t,"*")},window.addEventListener("message",a,!0)}if(typeof MutationObserver<"u"){var r=Date.now(),n=!0,i=document.createElement("div"),e=[];new MutationObserver(function(){var c=e.slice();e.length=0,c.forEach(function(f){f()})}).observe(i,{attributes:!0});var o=v.setImmediate;v.setImmediate=function(c){Date.now()-r>15?(r=Date.now(),o(c)):(e.push(c),e.length===1&&i.setAttribute("a",n=!n))}}v.nextTick=v.setImmediate})();v.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;v.globalScope=function(){return v.isNodejs?globalThis:typeof self>"u"?window:self}();v.isArray=Array.isArray||function(t){return Object.prototype.toString.call(t)==="[object Array]"};v.isArrayBuffer=function(t){return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer};v.isArrayBufferView=function(t){return t&&v.isArrayBuffer(t.buffer)&&t.byteLength!==void 0};function nn(t){if(!(t===8||t===16||t===24||t===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+t)}v.ByteBuffer=to;function to(t){if(this.data="",this.read=0,typeof t=="string")this.data=t;else if(v.isArrayBuffer(t)||v.isArrayBufferView(t))if(typeof Buffer<"u"&&t instanceof Buffer)this.data=t.toString("binary");else{var e=new Uint8Array(t);try{this.data=String.fromCharCode.apply(null,e)}catch{for(var r=0;r<e.length;++r)this.putByte(e[r])}}else(t instanceof to||typeof t=="object"&&typeof t.data=="string"&&typeof t.read=="number")&&(this.data=t.data,this.read=t.read);this._constructedStringLength=0}v.ByteStringBuffer=to;var il=4096;v.ByteStringBuffer.prototype._optimizeConstructedString=function(t){this._constructedStringLength+=t,this._constructedStringLength>il&&(this.data.substr(0,1),this._constructedStringLength=0)};v.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};v.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};v.ByteStringBuffer.prototype.putByte=function(t){return this.putBytes(String.fromCharCode(t))};v.ByteStringBuffer.prototype.fillWithByte=function(t,e){t=String.fromCharCode(t);for(var r=this.data;e>0;)e&1&&(r+=t),e>>>=1,e>0&&(t+=t);return this.data=r,this._optimizeConstructedString(e),this};v.ByteStringBuffer.prototype.putBytes=function(t){return this.data+=t,this._optimizeConstructedString(t.length),this};v.ByteStringBuffer.prototype.putString=function(t){return this.putBytes(v.encodeUtf8(t))};v.ByteStringBuffer.prototype.putInt16=function(t){return this.putBytes(String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};v.ByteStringBuffer.prototype.putInt24=function(t){return this.putBytes(String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};v.ByteStringBuffer.prototype.putInt32=function(t){return this.putBytes(String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};v.ByteStringBuffer.prototype.putInt16Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255))};v.ByteStringBuffer.prototype.putInt24Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255))};v.ByteStringBuffer.prototype.putInt32Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>24&255))};v.ByteStringBuffer.prototype.putInt=function(t,e){nn(e);var r="";do e-=8,r+=String.fromCharCode(t>>e&255);while(e>0);return this.putBytes(r)};v.ByteStringBuffer.prototype.putSignedInt=function(t,e){return t<0&&(t+=2<<e-1),this.putInt(t,e)};v.ByteStringBuffer.prototype.putBuffer=function(t){return this.putBytes(t.getBytes())};v.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};v.ByteStringBuffer.prototype.getInt16=function(){var t=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,t};v.ByteStringBuffer.prototype.getInt24=function(){var t=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,t};v.ByteStringBuffer.prototype.getInt32=function(){var t=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,t};v.ByteStringBuffer.prototype.getInt16Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,t};v.ByteStringBuffer.prototype.getInt24Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,t};v.ByteStringBuffer.prototype.getInt32Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,t};v.ByteStringBuffer.prototype.getInt=function(t){nn(t);var e=0;do e=(e<<8)+this.data.charCodeAt(this.read++),t-=8;while(t>0);return e};v.ByteStringBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<<t-2;return e>=r&&(e-=r<<1),e};v.ByteStringBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):t===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};v.ByteStringBuffer.prototype.bytes=function(t){return typeof t>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+t)};v.ByteStringBuffer.prototype.at=function(t){return this.data.charCodeAt(this.read+t)};v.ByteStringBuffer.prototype.setAt=function(t,e){return this.data=this.data.substr(0,this.read+t)+String.fromCharCode(e)+this.data.substr(this.read+t+1),this};v.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};v.ByteStringBuffer.prototype.copy=function(){var t=v.createBuffer(this.data);return t.read=this.read,t};v.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};v.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};v.ByteStringBuffer.prototype.truncate=function(t){var e=Math.max(0,this.length()-t);return this.data=this.data.substr(this.read,e),this.read=0,this};v.ByteStringBuffer.prototype.toHex=function(){for(var t="",e=this.read;e<this.data.length;++e){var r=this.data.charCodeAt(e);r<16&&(t+="0"),t+=r.toString(16)}return t};v.ByteStringBuffer.prototype.toString=function(){return v.decodeUtf8(this.bytes())};function ol(t,e){e=e||{},this.read=e.readOffset||0,this.growSize=e.growSize||1024;var r=v.isArrayBuffer(t),n=v.isArrayBufferView(t);if(r||n){r?this.data=new DataView(t):this.data=new DataView(t.buffer,t.byteOffset,t.byteLength),this.write="writeOffset"in e?e.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,t!=null&&this.putBytes(t),"writeOffset"in e&&(this.write=e.writeOffset)}v.DataBuffer=ol;v.DataBuffer.prototype.length=function(){return this.write-this.read};v.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};v.DataBuffer.prototype.accommodate=function(t,e){if(this.length()>=t)return this;e=Math.max(e||this.growSize,t);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+e);return n.set(r),this.data=new DataView(n.buffer),this};v.DataBuffer.prototype.putByte=function(t){return this.accommodate(1),this.data.setUint8(this.write++,t),this};v.DataBuffer.prototype.fillWithByte=function(t,e){this.accommodate(e);for(var r=0;r<e;++r)this.data.setUint8(t);return this};v.DataBuffer.prototype.putBytes=function(t,e){if(v.isArrayBufferView(t)){var r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-r.byteOffset;this.accommodate(n);var i=new Uint8Array(this.data.buffer,this.write);return i.set(r),this.write+=n,this}if(v.isArrayBuffer(t)){var r=new Uint8Array(t);this.accommodate(r.byteLength);var i=new Uint8Array(this.data.buffer);return i.set(r,this.write),this.write+=r.byteLength,this}if(t instanceof v.DataBuffer||typeof t=="object"&&typeof t.read=="number"&&typeof t.write=="number"&&v.isArrayBufferView(t.data)){var r=new Uint8Array(t.data.byteLength,t.read,t.length());this.accommodate(r.byteLength);var i=new Uint8Array(t.data.byteLength,this.write);return i.set(r),this.write+=r.byteLength,this}if(t instanceof v.ByteStringBuffer&&(t=t.data,e="binary"),e=e||"binary",typeof t=="string"){var o;if(e==="hex")return this.accommodate(Math.ceil(t.length/2)),o=new Uint8Array(this.data.buffer,this.write),this.write+=v.binary.hex.decode(t,o,this.write),this;if(e==="base64")return this.accommodate(Math.ceil(t.length/4)*3),o=new Uint8Array(this.data.buffer,this.write),this.write+=v.binary.base64.decode(t,o,this.write),this;if(e==="utf8"&&(t=v.encodeUtf8(t),e="binary"),e==="binary"||e==="raw")return this.accommodate(t.length),o=new Uint8Array(this.data.buffer,this.write),this.write+=v.binary.raw.decode(o),this;if(e==="utf16")return this.accommodate(t.length*2),o=new Uint16Array(this.data.buffer,this.write),this.write+=v.text.utf16.encode(o),this;throw new Error("Invalid encoding: "+e)}throw Error("Invalid parameter: "+t)};v.DataBuffer.prototype.putBuffer=function(t){return this.putBytes(t),t.clear(),this};v.DataBuffer.prototype.putString=function(t){return this.putBytes(t,"utf16")};v.DataBuffer.prototype.putInt16=function(t){return this.accommodate(2),this.data.setInt16(this.write,t),this.write+=2,this};v.DataBuffer.prototype.putInt24=function(t){return this.accommodate(3),this.data.setInt16(this.write,t>>8&65535),this.data.setInt8(this.write,t>>16&255),this.write+=3,this};v.DataBuffer.prototype.putInt32=function(t){return this.accommodate(4),this.data.setInt32(this.write,t),this.write+=4,this};v.DataBuffer.prototype.putInt16Le=function(t){return this.accommodate(2),this.data.setInt16(this.write,t,!0),this.write+=2,this};v.DataBuffer.prototype.putInt24Le=function(t){return this.accommodate(3),this.data.setInt8(this.write,t>>16&255),this.data.setInt16(this.write,t>>8&65535,!0),this.write+=3,this};v.DataBuffer.prototype.putInt32Le=function(t){return this.accommodate(4),this.data.setInt32(this.write,t,!0),this.write+=4,this};v.DataBuffer.prototype.putInt=function(t,e){nn(e),this.accommodate(e/8);do e-=8,this.data.setInt8(this.write++,t>>e&255);while(e>0);return this};v.DataBuffer.prototype.putSignedInt=function(t,e){return nn(e),this.accommodate(e/8),t<0&&(t+=2<<e-1),this.putInt(t,e)};v.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};v.DataBuffer.prototype.getInt16=function(){var t=this.data.getInt16(this.read);return this.read+=2,t};v.DataBuffer.prototype.getInt24=function(){var t=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,t};v.DataBuffer.prototype.getInt32=function(){var t=this.data.getInt32(this.read);return this.read+=4,t};v.DataBuffer.prototype.getInt16Le=function(){var t=this.data.getInt16(this.read,!0);return this.read+=2,t};v.DataBuffer.prototype.getInt24Le=function(){var t=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,t};v.DataBuffer.prototype.getInt32Le=function(){var t=this.data.getInt32(this.read,!0);return this.read+=4,t};v.DataBuffer.prototype.getInt=function(t){nn(t);var e=0;do e=(e<<8)+this.data.getInt8(this.read++),t-=8;while(t>0);return e};v.DataBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<<t-2;return e>=r&&(e-=r<<1),e};v.DataBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):t===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};v.DataBuffer.prototype.bytes=function(t){return typeof t>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+t)};v.DataBuffer.prototype.at=function(t){return this.data.getUint8(this.read+t)};v.DataBuffer.prototype.setAt=function(t,e){return this.data.setUint8(t,e),this};v.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};v.DataBuffer.prototype.copy=function(){return new v.DataBuffer(this)};v.DataBuffer.prototype.compact=function(){if(this.read>0){var t=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(t.byteLength);e.set(t),this.data=new DataView(e),this.write-=this.read,this.read=0}return this};v.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};v.DataBuffer.prototype.truncate=function(t){return this.write=Math.max(0,this.length()-t),this.read=Math.min(this.read,this.write),this};v.DataBuffer.prototype.toHex=function(){for(var t="",e=this.read;e<this.data.byteLength;++e){var r=this.data.getUint8(e);r<16&&(t+="0"),t+=r.toString(16)}return t};v.DataBuffer.prototype.toString=function(t){var e=new Uint8Array(this.data,this.read,this.length());if(t=t||"utf8",t==="binary"||t==="raw")return v.binary.raw.encode(e);if(t==="hex")return v.binary.hex.encode(e);if(t==="base64")return v.binary.base64.encode(e);if(t==="utf8")return v.text.utf8.decode(e);if(t==="utf16")return v.text.utf16.decode(e);throw new Error("Invalid encoding: "+t)};v.createBuffer=function(t,e){return e=e||"raw",t!==void 0&&e==="utf8"&&(t=v.encodeUtf8(t)),new v.ByteBuffer(t)};v.fillString=function(t,e){for(var r="";e>0;)e&1&&(r+=t),e>>>=1,e>0&&(t+=t);return r};v.xorBytes=function(t,e,r){for(var n="",i="",o="",s=0,a=0;r>0;--r,++s)i=t.charCodeAt(s)^e.charCodeAt(s),a>=10&&(n+=o,o="",a=0),o+=String.fromCharCode(i),++a;return n+=o,n};v.hexToBytes=function(t){var e="",r=0;for(t.length&!0&&(r=1,e+=String.fromCharCode(parseInt(t[0],16)));r<t.length;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e};v.bytesToHex=function(t){return v.createBuffer(t).toHex()};v.int32ToBytes=function(t){return String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255)};var $e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Ge=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],Sa="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";v.encode64=function(t,e){for(var r="",n="",i,o,s,a=0;a<t.length;)i=t.charCodeAt(a++),o=t.charCodeAt(a++),s=t.charCodeAt(a++),r+=$e.charAt(i>>2),r+=$e.charAt((i&3)<<4|o>>4),isNaN(o)?r+="==":(r+=$e.charAt((o&15)<<2|s>>6),r+=isNaN(s)?"=":$e.charAt(s&63)),e&&r.length>e&&(n+=r.substr(0,e)+`\r
4
- `,r=r.substr(e));return n+=r,n};v.decode64=function(t){t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var e="",r,n,i,o,s=0;s<t.length;)r=Ge[t.charCodeAt(s++)-43],n=Ge[t.charCodeAt(s++)-43],i=Ge[t.charCodeAt(s++)-43],o=Ge[t.charCodeAt(s++)-43],e+=String.fromCharCode(r<<2|n>>4),i!==64&&(e+=String.fromCharCode((n&15)<<4|i>>2),o!==64&&(e+=String.fromCharCode((i&3)<<6|o)));return e};v.encodeUtf8=function(t){return unescape(encodeURIComponent(t))};v.decodeUtf8=function(t){return decodeURIComponent(escape(t))};v.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:Ea.encode,decode:Ea.decode}};v.binary.raw.encode=function(t){return String.fromCharCode.apply(null,t)};v.binary.raw.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(t.length)),r=r||0;for(var i=r,o=0;o<t.length;++o)n[i++]=t.charCodeAt(o);return e?i-r:n};v.binary.hex.encode=v.bytesToHex;v.binary.hex.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(Math.ceil(t.length/2))),r=r||0;var i=0,o=r;for(t.length&1&&(i=1,n[o++]=parseInt(t[0],16));i<t.length;i+=2)n[o++]=parseInt(t.substr(i,2),16);return e?o-r:n};v.binary.base64.encode=function(t,e){for(var r="",n="",i,o,s,a=0;a<t.byteLength;)i=t[a++],o=t[a++],s=t[a++],r+=$e.charAt(i>>2),r+=$e.charAt((i&3)<<4|o>>4),isNaN(o)?r+="==":(r+=$e.charAt((o&15)<<2|s>>6),r+=isNaN(s)?"=":$e.charAt(s&63)),e&&r.length>e&&(n+=r.substr(0,e)+`\r
5
- `,r=r.substr(e));return n+=r,n};v.binary.base64.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(Math.ceil(t.length/4)*3)),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),r=r||0;for(var i,o,s,a,c=0,f=r;c<t.length;)i=Ge[t.charCodeAt(c++)-43],o=Ge[t.charCodeAt(c++)-43],s=Ge[t.charCodeAt(c++)-43],a=Ge[t.charCodeAt(c++)-43],n[f++]=i<<2|o>>4,s!==64&&(n[f++]=(o&15)<<4|s>>2,a!==64&&(n[f++]=(s&3)<<6|a));return e?f-r:n.subarray(0,f)};v.binary.base58.encode=function(t,e){return v.binary.baseN.encode(t,Sa,e)};v.binary.base58.decode=function(t,e){return v.binary.baseN.decode(t,Sa,e)};v.text={utf8:{},utf16:{}};v.text.utf8.encode=function(t,e,r){t=v.encodeUtf8(t);var n=e;n||(n=new Uint8Array(t.length)),r=r||0;for(var i=r,o=0;o<t.length;++o)n[i++]=t.charCodeAt(o);return e?i-r:n};v.text.utf8.decode=function(t){return v.decodeUtf8(String.fromCharCode.apply(null,t))};v.text.utf16.encode=function(t,e,r){var n=e;n||(n=new Uint8Array(t.length*2));var i=new Uint16Array(n.buffer);r=r||0;for(var o=r,s=r,a=0;a<t.length;++a)i[s++]=t.charCodeAt(a),o+=2;return e?o-r:n};v.text.utf16.decode=function(t){return String.fromCharCode.apply(null,new Uint16Array(t.buffer))};v.deflate=function(t,e,r){if(e=v.decode64(t.deflate(v.encode64(e)).rval),r){var n=2,i=e.charCodeAt(1);i&32&&(n=6),e=e.substring(n,e.length-4)}return e};v.inflate=function(t,e,r){var n=t.inflate(v.encode64(e)).rval;return n===null?null:v.decode64(n)};var eo=function(t,e,r){if(!t)throw new Error("WebStorage not available.");var n;if(r===null?n=t.removeItem(e):(r=v.encode64(JSON.stringify(r)),n=t.setItem(e,r)),typeof n<"u"&&n.rval!==!0){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}},ro=function(t,e){if(!t)throw new Error("WebStorage not available.");var r=t.getItem(e);if(t.init)if(r.rval===null){if(r.error){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}r=null}else r=r.rval;return r!==null&&(r=JSON.parse(v.decode64(r))),r},sl=function(t,e,r,n){var i=ro(t,e);i===null&&(i={}),i[r]=n,eo(t,e,i)},al=function(t,e,r){var n=ro(t,e);return n!==null&&(n=r in n?n[r]:null),n},fl=function(t,e,r){var n=ro(t,e);if(n!==null&&r in n){delete n[r];var i=!0;for(var o in n){i=!1;break}i&&(n=null),eo(t,e,n)}},cl=function(t,e){eo(t,e,null)},_n=function(t,e,r){var n=null;typeof r>"u"&&(r=["web","flash"]);var i,o=!1,s=null;for(var a in r){i=r[a];try{if(i==="flash"||i==="both"){if(e[0]===null)throw new Error("Flash local storage not available.");n=t.apply(this,e),o=i==="flash"}(i==="web"||i==="both")&&(e[0]=localStorage,n=t.apply(this,e),o=!0)}catch(c){s=c}if(o)break}if(!o)throw s;return n};v.setItem=function(t,e,r,n,i){_n(sl,arguments,i)};v.getItem=function(t,e,r,n){return _n(al,arguments,n)};v.removeItem=function(t,e,r,n){_n(fl,arguments,n)};v.clearItems=function(t,e,r){_n(cl,arguments,r)};v.isEmpty=function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0};v.format=function(t){for(var e=/%./g,r,n,i=0,o=[],s=0;r=e.exec(t);){n=t.substring(s,e.lastIndex-2),n.length>0&&o.push(n),s=e.lastIndex;var a=r[0][1];switch(a){case"s":case"o":i<arguments.length?o.push(arguments[i+++1]):o.push("<?>");break;case"%":o.push("%");break;default:o.push("<%"+a+"?>")}}return o.push(t.substring(s)),o.join("")};v.formatNumber=function(t,e,r,n){var i=t,o=isNaN(e=Math.abs(e))?2:e,s=r===void 0?",":r,a=n===void 0?".":n,c=i<0?"-":"",f=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",u=f.length>3?f.length%3:0;return c+(u?f.substr(0,u)+a:"")+f.substr(u).replace(/(\d{3})(?=\d)/g,"$1"+a)+(o?s+Math.abs(i-f).toFixed(o).slice(2):"")};v.formatSize=function(t){return t>=1073741824?t=v.formatNumber(t/1073741824,2,".","")+" GiB":t>=1048576?t=v.formatNumber(t/1048576,2,".","")+" MiB":t>=1024?t=v.formatNumber(t/1024,0)+" KiB":t=v.formatNumber(t,0)+" bytes",t};v.bytesFromIP=function(t){return t.indexOf(".")!==-1?v.bytesFromIPv4(t):t.indexOf(":")!==-1?v.bytesFromIPv6(t):null};v.bytesFromIPv4=function(t){if(t=t.split("."),t.length!==4)return null;for(var e=v.createBuffer(),r=0;r<t.length;++r){var n=parseInt(t[r],10);if(isNaN(n))return null;e.putByte(n)}return e.getBytes()};v.bytesFromIPv6=function(t){var e=0;t=t.split(":").filter(function(s){return s.length===0&&++e,!0});for(var r=(8-t.length+e)*2,n=v.createBuffer(),i=0;i<8;++i){if(!t[i]||t[i].length===0){n.fillWithByte(0,r),r=0;continue}var o=v.hexToBytes(t[i]);o.length<2&&n.putByte(0),n.putBytes(o)}return n.getBytes()};v.bytesToIP=function(t){return t.length===4?v.bytesToIPv4(t):t.length===16?v.bytesToIPv6(t):null};v.bytesToIPv4=function(t){if(t.length!==4)return null;for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e.join(".")};v.bytesToIPv6=function(t){if(t.length!==16)return null;for(var e=[],r=[],n=0,i=0;i<t.length;i+=2){for(var o=v.bytesToHex(t[i]+t[i+1]);o[0]==="0"&&o!=="0";)o=o.substr(1);if(o==="0"){var s=r[r.length-1],a=e.length;!s||a!==s.end+1?r.push({start:a,end:a}):(s.end=a,s.end-s.start>r[n].end-r[n].start&&(n=r.length-1))}e.push(o)}if(r.length>0){var c=r[n];c.end-c.start>0&&(e.splice(c.start,c.end-c.start+1,""),c.start===0&&e.unshift(""),c.end===7&&e.push(""))}return e.join(":")};v.estimateCores=function(t,e){if(typeof t=="function"&&(e=t,t={}),t=t||{},"cores"in v&&!t.update)return e(null,v.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return v.cores=navigator.hardwareConcurrency,e(null,v.cores);if(typeof Worker>"u")return v.cores=1,e(null,v.cores);if(typeof Blob>"u")return v.cores=2,e(null,v.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(s){for(var a=Date.now(),c=a+4;Date.now()<c;);self.postMessage({st:a,et:c})})}.toString(),")()"],{type:"application/javascript"}));n([],5,16);function n(s,a,c){if(a===0){var f=Math.floor(s.reduce(function(u,l){return u+l},0)/s.length);return v.cores=Math.max(1,f),URL.revokeObjectURL(r),e(null,v.cores)}i(c,function(u,l){s.push(o(c,l)),n(s,a-1,c)})}function i(s,a){for(var c=[],f=[],u=0;u<s;++u){var l=new Worker(r);l.addEventListener("message",function(p){if(f.push(p.data),f.length===s){for(var d=0;d<s;++d)c[d].terminate();a(null,f)}}),c.push(l)}for(var u=0;u<s;++u)c[u].postMessage(u)}function o(s,a){for(var c=[],f=0;f<s;++f)for(var u=a[f],l=c[f]=[],p=0;p<s;++p)if(f!==p){var d=a[p];(u.st>d.st&&u.st<d.et||d.st>u.st&&d.st<u.et)&&l.push(p)}return c.reduce(function(h,y){return Math.max(h,y.length)},0)}}});var Rn=ft((yg,Aa)=>{var on=ct();on.pki=on.pki||{};var no=Aa.exports=on.pki.oids=on.oids=on.oids||{};function C(t,e){no[t]=e,no[e]=t}function nt(t,e){no[t]=e}C("1.2.840.113549.1.1.1","rsaEncryption");C("1.2.840.113549.1.1.4","md5WithRSAEncryption");C("1.2.840.113549.1.1.5","sha1WithRSAEncryption");C("1.2.840.113549.1.1.7","RSAES-OAEP");C("1.2.840.113549.1.1.8","mgf1");C("1.2.840.113549.1.1.9","pSpecified");C("1.2.840.113549.1.1.10","RSASSA-PSS");C("1.2.840.113549.1.1.11","sha256WithRSAEncryption");C("1.2.840.113549.1.1.12","sha384WithRSAEncryption");C("1.2.840.113549.1.1.13","sha512WithRSAEncryption");C("1.3.101.112","EdDSA25519");C("1.2.840.10040.4.3","dsa-with-sha1");C("1.3.14.3.2.7","desCBC");C("1.3.14.3.2.26","sha1");C("1.3.14.3.2.29","sha1WithRSASignature");C("2.16.840.1.101.3.4.2.1","sha256");C("2.16.840.1.101.3.4.2.2","sha384");C("2.16.840.1.101.3.4.2.3","sha512");C("2.16.840.1.101.3.4.2.4","sha224");C("2.16.840.1.101.3.4.2.5","sha512-224");C("2.16.840.1.101.3.4.2.6","sha512-256");C("1.2.840.113549.2.2","md2");C("1.2.840.113549.2.5","md5");C("1.2.840.113549.1.7.1","data");C("1.2.840.113549.1.7.2","signedData");C("1.2.840.113549.1.7.3","envelopedData");C("1.2.840.113549.1.7.4","signedAndEnvelopedData");C("1.2.840.113549.1.7.5","digestedData");C("1.2.840.113549.1.7.6","encryptedData");C("1.2.840.113549.1.9.1","emailAddress");C("1.2.840.113549.1.9.2","unstructuredName");C("1.2.840.113549.1.9.3","contentType");C("1.2.840.113549.1.9.4","messageDigest");C("1.2.840.113549.1.9.5","signingTime");C("1.2.840.113549.1.9.6","counterSignature");C("1.2.840.113549.1.9.7","challengePassword");C("1.2.840.113549.1.9.8","unstructuredAddress");C("1.2.840.113549.1.9.14","extensionRequest");C("1.2.840.113549.1.9.20","friendlyName");C("1.2.840.113549.1.9.21","localKeyId");C("1.2.840.113549.1.9.22.1","x509Certificate");C("1.2.840.113549.1.12.10.1.1","keyBag");C("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");C("1.2.840.113549.1.12.10.1.3","certBag");C("1.2.840.113549.1.12.10.1.4","crlBag");C("1.2.840.113549.1.12.10.1.5","secretBag");C("1.2.840.113549.1.12.10.1.6","safeContentsBag");C("1.2.840.113549.1.5.13","pkcs5PBES2");C("1.2.840.113549.1.5.12","pkcs5PBKDF2");C("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");C("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");C("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");C("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");C("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");C("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");C("1.2.840.113549.2.7","hmacWithSHA1");C("1.2.840.113549.2.8","hmacWithSHA224");C("1.2.840.113549.2.9","hmacWithSHA256");C("1.2.840.113549.2.10","hmacWithSHA384");C("1.2.840.113549.2.11","hmacWithSHA512");C("1.2.840.113549.3.7","des-EDE3-CBC");C("2.16.840.1.101.3.4.1.2","aes128-CBC");C("2.16.840.1.101.3.4.1.22","aes192-CBC");C("2.16.840.1.101.3.4.1.42","aes256-CBC");C("2.5.4.3","commonName");C("2.5.4.4","surname");C("2.5.4.5","serialNumber");C("2.5.4.6","countryName");C("2.5.4.7","localityName");C("2.5.4.8","stateOrProvinceName");C("2.5.4.9","streetAddress");C("2.5.4.10","organizationName");C("2.5.4.11","organizationalUnitName");C("2.5.4.12","title");C("2.5.4.13","description");C("2.5.4.15","businessCategory");C("2.5.4.17","postalCode");C("2.5.4.42","givenName");C("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");C("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");C("2.16.840.1.113730.1.1","nsCertType");C("2.16.840.1.113730.1.13","nsComment");nt("2.5.29.1","authorityKeyIdentifier");nt("2.5.29.2","keyAttributes");nt("2.5.29.3","certificatePolicies");nt("2.5.29.4","keyUsageRestriction");nt("2.5.29.5","policyMapping");nt("2.5.29.6","subtreesConstraint");nt("2.5.29.7","subjectAltName");nt("2.5.29.8","issuerAltName");nt("2.5.29.9","subjectDirectoryAttributes");nt("2.5.29.10","basicConstraints");nt("2.5.29.11","nameConstraints");nt("2.5.29.12","policyConstraints");nt("2.5.29.13","basicConstraints");C("2.5.29.14","subjectKeyIdentifier");C("2.5.29.15","keyUsage");nt("2.5.29.16","privateKeyUsagePeriod");C("2.5.29.17","subjectAltName");C("2.5.29.18","issuerAltName");C("2.5.29.19","basicConstraints");nt("2.5.29.20","cRLNumber");nt("2.5.29.21","cRLReason");nt("2.5.29.22","expirationDate");nt("2.5.29.23","instructionCode");nt("2.5.29.24","invalidityDate");nt("2.5.29.25","cRLDistributionPoints");nt("2.5.29.26","issuingDistributionPoint");nt("2.5.29.27","deltaCRLIndicator");nt("2.5.29.28","issuingDistributionPoint");nt("2.5.29.29","certificateIssuer");nt("2.5.29.30","nameConstraints");C("2.5.29.31","cRLDistributionPoints");C("2.5.29.32","certificatePolicies");nt("2.5.29.33","policyMappings");nt("2.5.29.34","policyConstraints");C("2.5.29.35","authorityKeyIdentifier");nt("2.5.29.36","policyConstraints");C("2.5.29.37","extKeyUsage");nt("2.5.29.46","freshestCRL");nt("2.5.29.54","inhibitAnyPolicy");C("1.3.6.1.4.1.11129.2.4.2","timestampList");C("1.3.6.1.5.5.7.1.1","authorityInfoAccess");C("1.3.6.1.5.5.7.3.1","serverAuth");C("1.3.6.1.5.5.7.3.2","clientAuth");C("1.3.6.1.5.5.7.3.3","codeSigning");C("1.3.6.1.5.5.7.3.4","emailProtection");C("1.3.6.1.5.5.7.3.8","timeStamping")});var an=ft((gg,Ta)=>{var dt=ct();Et();Rn();var N=Ta.exports=dt.asn1=dt.asn1||{};N.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};N.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30};N.create=function(t,e,r,n,i){if(dt.util.isArray(n)){for(var o=[],s=0;s<n.length;++s)n[s]!==void 0&&o.push(n[s]);n=o}var a={tagClass:t,type:e,constructed:r,composed:r||dt.util.isArray(n),value:n};return i&&"bitStringContents"in i&&(a.bitStringContents=i.bitStringContents,a.original=N.copy(a)),a};N.copy=function(t,e){var r;if(dt.util.isArray(t)){r=[];for(var n=0;n<t.length;++n)r.push(N.copy(t[n],e));return r}return typeof t=="string"?t:(r={tagClass:t.tagClass,type:t.type,constructed:t.constructed,composed:t.composed,value:N.copy(t.value,e)},e&&!e.excludeBitStringContents&&(r.bitStringContents=t.bitStringContents),r)};N.equals=function(t,e,r){if(dt.util.isArray(t)){if(!dt.util.isArray(e)||t.length!==e.length)return!1;for(var n=0;n<t.length;++n)if(!N.equals(t[n],e[n]))return!1;return!0}if(typeof t!=typeof e)return!1;if(typeof t=="string")return t===e;var i=t.tagClass===e.tagClass&&t.type===e.type&&t.constructed===e.constructed&&t.composed===e.composed&&N.equals(t.value,e.value);return r&&r.includeBitStringContents&&(i=i&&t.bitStringContents===e.bitStringContents),i};N.getBerValueLength=function(t){var e=t.getByte();if(e!==128){var r,n=e&128;return n?r=t.getInt((e&127)<<3):r=e,r}};function sn(t,e,r){if(r>e){var n=new Error("Too few bytes to parse DER.");throw n.available=t.length(),n.remaining=e,n.requested=r,n}}var ul=function(t,e){var r=t.getByte();if(e--,r!==128){var n,i=r&128;if(!i)n=r;else{var o=r&127;sn(t,e,o),n=t.getInt(o<<3)}if(n<0)throw new Error("Negative length: "+n);return n}};N.fromDer=function(t,e){e===void 0&&(e={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof e=="boolean"&&(e={strict:e,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in e||(e.strict=!0),"parseAllBytes"in e||(e.parseAllBytes=!0),"decodeBitStrings"in e||(e.decodeBitStrings=!0),typeof t=="string"&&(t=dt.util.createBuffer(t));var r=t.length(),n=Ln(t,t.length(),0,e);if(e.parseAllBytes&&t.length()!==0){var i=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw i.byteCount=r,i.remaining=t.length(),i}return n};function Ln(t,e,r,n){var i;sn(t,e,2);var o=t.getByte();e--;var s=o&192,a=o&31;i=t.length();var c=ul(t,e);if(e-=i-t.length(),c!==void 0&&c>e){if(n.strict){var f=new Error("Too few bytes to read ASN.1 value.");throw f.available=t.length(),f.remaining=e,f.requested=c,f}c=e}var u,l,p=(o&32)===32;if(p)if(u=[],c===void 0)for(;;){if(sn(t,e,2),t.bytes(2)==="\0\0"){t.getBytes(2),e-=2;break}i=t.length(),u.push(Ln(t,e,r+1,n)),e-=i-t.length()}else for(;c>0;)i=t.length(),u.push(Ln(t,c,r+1,n)),e-=i-t.length(),c-=i-t.length();if(u===void 0&&s===N.Class.UNIVERSAL&&a===N.Type.BITSTRING&&(l=t.bytes(c)),u===void 0&&n.decodeBitStrings&&s===N.Class.UNIVERSAL&&a===N.Type.BITSTRING&&c>1){var d=t.read,h=e,y=0;if(a===N.Type.BITSTRING&&(sn(t,e,1),y=t.getByte(),e--),y===0)try{i=t.length();var g={strict:!0,decodeBitStrings:!0},x=Ln(t,e,r+1,g),m=i-t.length();e-=m,a==N.Type.BITSTRING&&m++;var b=x.tagClass;m===c&&(b===N.Class.UNIVERSAL||b===N.Class.CONTEXT_SPECIFIC)&&(u=[x])}catch{}u===void 0&&(t.read=d,e=h)}if(u===void 0){if(c===void 0){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");c=e}if(a===N.Type.BMPSTRING)for(u="";c>0;c-=2)sn(t,e,2),u+=String.fromCharCode(t.getInt16()),e-=2;else u=t.getBytes(c),e-=c}var _=l===void 0?null:{bitStringContents:l};return N.create(s,a,p,u,_)}N.toDer=function(t){var e=dt.util.createBuffer(),r=t.tagClass|t.type,n=dt.util.createBuffer(),i=!1;if("bitStringContents"in t&&(i=!0,t.original&&(i=N.equals(t,t.original))),i)n.putBytes(t.bitStringContents);else if(t.composed){t.constructed?r|=32:n.putByte(0);for(var o=0;o<t.value.length;++o)t.value[o]!==void 0&&n.putBuffer(N.toDer(t.value[o]))}else if(t.type===N.Type.BMPSTRING)for(var o=0;o<t.value.length;++o)n.putInt16(t.value.charCodeAt(o));else t.type===N.Type.INTEGER&&t.value.length>1&&(t.value.charCodeAt(0)===0&&!(t.value.charCodeAt(1)&128)||t.value.charCodeAt(0)===255&&(t.value.charCodeAt(1)&128)===128)?n.putBytes(t.value.substr(1)):n.putBytes(t.value);if(e.putByte(r),n.length()<=127)e.putByte(n.length()&127);else{var s=n.length(),a="";do a+=String.fromCharCode(s&255),s=s>>>8;while(s>0);e.putByte(a.length|128);for(var o=a.length-1;o>=0;--o)e.putByte(a.charCodeAt(o))}return e.putBuffer(n),e};N.oidToDer=function(t){var e=t.split("."),r=dt.util.createBuffer();r.putByte(40*parseInt(e[0],10)+parseInt(e[1],10));for(var n,i,o,s,a=2;a<e.length;++a){n=!0,i=[],o=parseInt(e[a],10);do s=o&127,o=o>>>7,n||(s|=128),i.push(s),n=!1;while(o>0);for(var c=i.length-1;c>=0;--c)r.putByte(i[c])}return r};N.derToOid=function(t){var e;typeof t=="string"&&(t=dt.util.createBuffer(t));var r=t.getByte();e=Math.floor(r/40)+"."+r%40;for(var n=0;t.length()>0;)r=t.getByte(),n=n<<7,r&128?n+=r&127:(e+="."+(n+r),n=0);return e};N.utcTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(t.substr(2,2),10)-1,i=parseInt(t.substr(4,2),10),o=parseInt(t.substr(6,2),10),s=parseInt(t.substr(8,2),10),a=0;if(t.length>11){var c=t.charAt(10),f=10;c!=="+"&&c!=="-"&&(a=parseInt(t.substr(10,2),10),f+=2)}if(e.setUTCFullYear(r,n,i),e.setUTCHours(o,s,a,0),f&&(c=t.charAt(f),c==="+"||c==="-")){var u=parseInt(t.substr(f+1,2),10),l=parseInt(t.substr(f+4,2),10),p=u*60+l;p*=6e4,c==="+"?e.setTime(+e-p):e.setTime(+e+p)}return e};N.generalizedTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,4),10),n=parseInt(t.substr(4,2),10)-1,i=parseInt(t.substr(6,2),10),o=parseInt(t.substr(8,2),10),s=parseInt(t.substr(10,2),10),a=parseInt(t.substr(12,2),10),c=0,f=0,u=!1;t.charAt(t.length-1)==="Z"&&(u=!0);var l=t.length-5,p=t.charAt(l);if(p==="+"||p==="-"){var d=parseInt(t.substr(l+1,2),10),h=parseInt(t.substr(l+4,2),10);f=d*60+h,f*=6e4,p==="+"&&(f*=-1),u=!0}return t.charAt(14)==="."&&(c=parseFloat(t.substr(14),10)*1e3),u?(e.setUTCFullYear(r,n,i),e.setUTCHours(o,s,a,c),e.setTime(+e+f)):(e.setFullYear(r,n,i),e.setHours(o,s,a,c)),e};N.dateToUtcTime=function(t){if(typeof t=="string")return t;var e="",r=[];r.push((""+t.getUTCFullYear()).substr(2)),r.push(""+(t.getUTCMonth()+1)),r.push(""+t.getUTCDate()),r.push(""+t.getUTCHours()),r.push(""+t.getUTCMinutes()),r.push(""+t.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(e+="0"),e+=r[n];return e+="Z",e};N.dateToGeneralizedTime=function(t){if(typeof t=="string")return t;var e="",r=[];r.push(""+t.getUTCFullYear()),r.push(""+(t.getUTCMonth()+1)),r.push(""+t.getUTCDate()),r.push(""+t.getUTCHours()),r.push(""+t.getUTCMinutes()),r.push(""+t.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(e+="0"),e+=r[n];return e+="Z",e};N.integerToDer=function(t){var e=dt.util.createBuffer();if(t>=-128&&t<128)return e.putSignedInt(t,8);if(t>=-32768&&t<32768)return e.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return e.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return e.putSignedInt(t,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=t,r};N.derToInteger=function(t){typeof t=="string"&&(t=dt.util.createBuffer(t));var e=t.length()*8;if(e>32)throw new Error("Integer too large; max is 32-bits.");return t.getSignedInt(e)};N.validate=function(t,e,r,n){var i=!1;if((t.tagClass===e.tagClass||typeof e.tagClass>"u")&&(t.type===e.type||typeof e.type>"u"))if(t.constructed===e.constructed||typeof e.constructed>"u"){if(i=!0,e.value&&dt.util.isArray(e.value))for(var o=0,s=0;i&&s<e.value.length;++s)i=e.value[s].optional||!1,t.value[o]&&(i=N.validate(t.value[o],e.value[s],r,n),i?++o:e.value[s].optional&&(i=!0)),!i&&n&&n.push("["+e.name+'] Tag class "'+e.tagClass+'", type "'+e.type+'" expected value length "'+e.value.length+'", got "'+t.value.length+'"');if(i&&r&&(e.capture&&(r[e.capture]=t.value),e.captureAsn1&&(r[e.captureAsn1]=t),e.captureBitStringContents&&"bitStringContents"in t&&(r[e.captureBitStringContents]=t.bitStringContents),e.captureBitStringValue&&"bitStringContents"in t)){var a;if(t.bitStringContents.length<2)r[e.captureBitStringValue]="";else{var c=t.bitStringContents.charCodeAt(0);if(c!==0)throw new Error("captureBitStringValue only supported for zero unused bits");r[e.captureBitStringValue]=t.bitStringContents.slice(1)}}}else n&&n.push("["+e.name+'] Expected constructed "'+e.constructed+'", got "'+t.constructed+'"');else n&&(t.tagClass!==e.tagClass&&n.push("["+e.name+'] Expected tag class "'+e.tagClass+'", got "'+t.tagClass+'"'),t.type!==e.type&&n.push("["+e.name+'] Expected type "'+e.type+'", got "'+t.type+'"'));return i};var Ia=/[^\\u0000-\\u00ff]/;N.prettyPrint=function(t,e,r){var n="";e=e||0,r=r||2,e>0&&(n+=`
6
- `);for(var i="",o=0;o<e*r;++o)i+=" ";switch(n+=i+"Tag: ",t.tagClass){case N.Class.UNIVERSAL:n+="Universal:";break;case N.Class.APPLICATION:n+="Application:";break;case N.Class.CONTEXT_SPECIFIC:n+="Context-Specific:";break;case N.Class.PRIVATE:n+="Private:";break}if(t.tagClass===N.Class.UNIVERSAL)switch(n+=t.type,t.type){case N.Type.NONE:n+=" (None)";break;case N.Type.BOOLEAN:n+=" (Boolean)";break;case N.Type.INTEGER:n+=" (Integer)";break;case N.Type.BITSTRING:n+=" (Bit string)";break;case N.Type.OCTETSTRING:n+=" (Octet string)";break;case N.Type.NULL:n+=" (Null)";break;case N.Type.OID:n+=" (Object Identifier)";break;case N.Type.ODESC:n+=" (Object Descriptor)";break;case N.Type.EXTERNAL:n+=" (External or Instance of)";break;case N.Type.REAL:n+=" (Real)";break;case N.Type.ENUMERATED:n+=" (Enumerated)";break;case N.Type.EMBEDDED:n+=" (Embedded PDV)";break;case N.Type.UTF8:n+=" (UTF8)";break;case N.Type.ROID:n+=" (Relative Object Identifier)";break;case N.Type.SEQUENCE:n+=" (Sequence)";break;case N.Type.SET:n+=" (Set)";break;case N.Type.PRINTABLESTRING:n+=" (Printable String)";break;case N.Type.IA5String:n+=" (IA5String (ASCII))";break;case N.Type.UTCTIME:n+=" (UTC time)";break;case N.Type.GENERALIZEDTIME:n+=" (Generalized time)";break;case N.Type.BMPSTRING:n+=" (BMP String)";break}else n+=t.type;if(n+=`
7
- `,n+=i+"Constructed: "+t.constructed+`
8
- `,t.composed){for(var s=0,a="",o=0;o<t.value.length;++o)t.value[o]!==void 0&&(s+=1,a+=N.prettyPrint(t.value[o],e+1,r),o+1<t.value.length&&(a+=","));n+=i+"Sub values: "+s+a}else{if(n+=i+"Value: ",t.type===N.Type.OID){var c=N.derToOid(t.value);n+=c,dt.pki&&dt.pki.oids&&c in dt.pki.oids&&(n+=" ("+dt.pki.oids[c]+") ")}if(t.type===N.Type.INTEGER)try{n+=N.derToInteger(t.value)}catch{n+="0x"+dt.util.bytesToHex(t.value)}else if(t.type===N.Type.BITSTRING){if(t.value.length>1?n+="0x"+dt.util.bytesToHex(t.value.slice(1)):n+="(none)",t.value.length>0){var f=t.value.charCodeAt(0);f==1?n+=" (1 unused bit shown)":f>1&&(n+=" ("+f+" unused bits shown)")}}else if(t.type===N.Type.OCTETSTRING)Ia.test(t.value)||(n+="("+t.value+") "),n+="0x"+dt.util.bytesToHex(t.value);else if(t.type===N.Type.UTF8)try{n+=dt.util.decodeUtf8(t.value)}catch(u){if(u.message==="URI malformed")n+="0x"+dt.util.bytesToHex(t.value)+" (malformed UTF8)";else throw u}else t.type===N.Type.PRINTABLESTRING||t.type===N.Type.IA5String?n+=t.value:Ia.test(t.value)?n+="0x"+dt.util.bytesToHex(t.value):t.value.length===0?n+="[null]":n+=t.value}return n}});var oo=ft((xg,Ca)=>{var Rt=ct();Et();Ca.exports=Rt.cipher=Rt.cipher||{};Rt.cipher.algorithms=Rt.cipher.algorithms||{};Rt.cipher.createCipher=function(t,e){var r=t;if(typeof r=="string"&&(r=Rt.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new Rt.cipher.BlockCipher({algorithm:r,key:e,decrypt:!1})};Rt.cipher.createDecipher=function(t,e){var r=t;if(typeof r=="string"&&(r=Rt.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new Rt.cipher.BlockCipher({algorithm:r,key:e,decrypt:!0})};Rt.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),Rt.cipher.algorithms[t]=e};Rt.cipher.getAlgorithm=function(t){return t=t.toUpperCase(),t in Rt.cipher.algorithms?Rt.cipher.algorithms[t]:null};var io=Rt.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};io.prototype.start=function(t){t=t||{};var e={};for(var r in t)e[r]=t[r];e.decrypt=this._decrypt,this._finish=!1,this._input=Rt.util.createBuffer(),this.output=t.output||Rt.util.createBuffer(),this.mode.start(e)};io.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};io.prototype.finish=function(t){t&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(r){return t(this.blockSize,r,!1)},this.mode.unpad=function(r){return t(this.blockSize,r,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,e))}});var ao=ft((mg,_a)=>{var Lt=ct();Et();Lt.cipher=Lt.cipher||{};var Q=_a.exports=Lt.cipher.modes=Lt.cipher.modes||{};Q.ecb=function(t){t=t||{},this.name="ECB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};Q.ecb.prototype.start=function(t){};Q.ecb.prototype.encrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n])};Q.ecb.prototype.decrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n])};Q.ecb.prototype.pad=function(t,e){var r=t.length()===this.blockSize?this.blockSize:this.blockSize-t.length();return t.fillWithByte(r,r),!0};Q.ecb.prototype.unpad=function(t,e){if(e.overflow>0)return!1;var r=t.length(),n=t.at(r-1);return n>this.blockSize<<2?!1:(t.truncate(n),!0)};Q.cbc=function(t){t=t||{},this.name="CBC",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};Q.cbc.prototype.start=function(t){if(t.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in t)this._iv=Dn(t.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};Q.cbc.prototype.encrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^t.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n]);this._prev=this._outBlock};Q.cbc.prototype.decrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)};Q.cbc.prototype.pad=function(t,e){var r=t.length()===this.blockSize?this.blockSize:this.blockSize-t.length();return t.fillWithByte(r,r),!0};Q.cbc.prototype.unpad=function(t,e){if(e.overflow>0)return!1;var r=t.length(),n=t.at(r-1);return n>this.blockSize<<2?!1:(t.truncate(n),!0)};Q.cfb=function(t){t=t||{},this.name="CFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=Lt.util.createBuffer(),this._partialBytes=0};Q.cfb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=Dn(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};Q.cfb.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32()^this._outBlock[i],e.putInt32(this._inBlock[i]);return}var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=t.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(o>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};Q.cfb.prototype.decrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32(),e.putInt32(this._inBlock[i]^this._outBlock[i]);return}var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=t.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(o>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};Q.ofb=function(t){t=t||{},this.name="OFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Lt.util.createBuffer(),this._partialBytes=0};Q.ofb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=Dn(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};Q.ofb.prototype.encrypt=function(t,e,r){var n=t.length();if(t.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)e.putInt32(t.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];return}var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(o>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};Q.ofb.prototype.decrypt=Q.ofb.prototype.encrypt;Q.ctr=function(t){t=t||{},this.name="CTR",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Lt.util.createBuffer(),this._partialBytes=0};Q.ctr.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=Dn(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};Q.ctr.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize)for(var i=0;i<this._ints;++i)e.putInt32(t.getInt32()^this._outBlock[i]);else{var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(o>0&&(t.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}Pn(this._inBlock)};Q.ctr.prototype.decrypt=Q.ctr.prototype.encrypt;Q.gcm=function(t){t=t||{},this.name="GCM",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=Lt.util.createBuffer(),this._partialBytes=0,this._R=3774873600};Q.gcm.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");var e=Lt.util.createBuffer(t.iv);this._cipherLength=0;var r;if("additionalData"in t?r=Lt.util.createBuffer(t.additionalData):r=Lt.util.createBuffer(),"tagLength"in t?this._tagLength=t.tagLength:this._tagLength=128,this._tag=null,t.decrypt&&(this._tag=Lt.util.createBuffer(t.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var n=e.length();if(n===12)this._j0=[e.getInt32(),e.getInt32(),e.getInt32(),1];else{for(this._j0=[0,0,0,0];e.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(so(n*8)))}this._inBlock=this._j0.slice(0),Pn(this._inBlock),this._partialBytes=0,r=Lt.util.createBuffer(r),this._aDataLength=so(r.length()*8);var i=r.length()%this.blockSize;for(i&&r.fillWithByte(0,this.blockSize-i),this._s=[0,0,0,0];r.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])};Q.gcm.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]^=t.getInt32());this._cipherLength+=this.blockSize}else{var o=(this.blockSize-n)%this.blockSize;o>0&&(o=this.blockSize-o),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(o<=0||r){if(r){var s=n%this.blockSize;this._cipherLength+=s,this._partialOutput.truncate(this.blockSize-s)}else this._cipherLength+=this.blockSize;for(var i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),Pn(this._inBlock)};Q.gcm.prototype.decrypt=function(t,e,r){var n=t.length();if(n<this.blockSize&&!(r&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),Pn(this._inBlock),this._hashBlock[0]=t.getInt32(),this._hashBlock[1]=t.getInt32(),this._hashBlock[2]=t.getInt32(),this._hashBlock[3]=t.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]^this._hashBlock[i]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize};Q.gcm.prototype.afterFinish=function(t,e){var r=!0;e.decrypt&&e.overflow&&t.truncate(this.blockSize-e.overflow),this.tag=Lt.util.createBuffer();var n=this._aDataLength.concat(so(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,n);var i=[];this.cipher.encrypt(this._j0,i);for(var o=0;o<this._ints;++o)this.tag.putInt32(this._s[o]^i[o]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),e.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r};Q.gcm.prototype.multiply=function(t,e){for(var r=[0,0,0,0],n=e.slice(0),i=0;i<128;++i){var o=t[i/32|0]&1<<31-i%32;o&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r};Q.gcm.prototype.pow=function(t,e){for(var r=t[3]&1,n=3;n>0;--n)e[n]=t[n]>>>1|(t[n-1]&1)<<31;e[0]=t[0]>>>1,r&&(e[0]^=this._R)};Q.gcm.prototype.tableMultiply=function(t){for(var e=[0,0,0,0],r=0;r<32;++r){var n=r/8|0,i=t[n]>>>(7-r%8)*4&15,o=this._m[r][i];e[0]^=o[0],e[1]^=o[1],e[2]^=o[2],e[3]^=o[3]}return e};Q.gcm.prototype.ghash=function(t,e,r){return e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3],this.tableMultiply(e)};Q.gcm.prototype.generateHashTable=function(t,e){for(var r=8/e,n=4*r,i=16*r,o=new Array(i),s=0;s<i;++s){var a=[0,0,0,0],c=s/n|0,f=(n-1-s%n)*e;a[c]=1<<e-1<<f,o[s]=this.generateSubHashTable(this.multiply(a,t),e)}return o};Q.gcm.prototype.generateSubHashTable=function(t,e){var r=1<<e,n=r>>>1,i=new Array(r);i[n]=t.slice(0);for(var o=n>>>1;o>0;)this.pow(i[2*o],i[o]=[]),o>>=1;for(o=2;o<n;){for(var s=1;s<o;++s){var a=i[o],c=i[s];i[o+s]=[a[0]^c[0],a[1]^c[1],a[2]^c[2],a[3]^c[3]]}o*=2}for(i[0]=[0,0,0,0],o=n+1;o<r;++o){var f=i[o^n];i[o]=[t[0]^f[0],t[1]^f[1],t[2]^f[2],t[3]^f[3]]}return i};function Dn(t,e){if(typeof t=="string"&&(t=Lt.util.createBuffer(t)),Lt.util.isArray(t)&&t.length>4){var r=t;t=Lt.util.createBuffer();for(var n=0;n<r.length;++n)t.putByte(r[n])}if(t.length()<e)throw new Error("Invalid IV length; got "+t.length()+" bytes and expected "+e+" bytes.");if(!Lt.util.isArray(t)){for(var i=[],o=e/4,n=0;n<o;++n)i.push(t.getInt32());t=i}return t}function Pn(t){t[t.length-1]=t[t.length-1]+1&4294967295}function so(t){return[t/4294967296|0,t&4294967295]}});var lo=ft((vg,Pa)=>{var ht=ct();oo();ao();Et();Pa.exports=ht.aes=ht.aes||{};ht.aes.startEncrypting=function(t,e,r,n){var i=kn({key:t,output:r,decrypt:!1,mode:n});return i.start(e),i};ht.aes.createEncryptionCipher=function(t,e){return kn({key:t,output:null,decrypt:!1,mode:e})};ht.aes.startDecrypting=function(t,e,r,n){var i=kn({key:t,output:r,decrypt:!0,mode:n});return i.start(e),i};ht.aes.createDecryptionCipher=function(t,e){return kn({key:t,output:null,decrypt:!0,mode:e})};ht.aes.Algorithm=function(t,e){uo||La();var r=this;r.name=t,r.mode=new e({blockSize:16,cipher:{encrypt:function(n,i){return co(r._w,n,i,!1)},decrypt:function(n,i){return co(r._w,n,i,!0)}}}),r._init=!1};ht.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var e=t.key,r;if(typeof e=="string"&&(e.length===16||e.length===24||e.length===32))e=ht.util.createBuffer(e);else if(ht.util.isArray(e)&&(e.length===16||e.length===24||e.length===32)){r=e,e=ht.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(!ht.util.isArray(e)){r=e,e=[];var i=r.length();if(i===16||i===24||i===32){i=i>>>2;for(var n=0;n<i;++n)e.push(r.getInt32())}}if(!ht.util.isArray(e)||!(e.length===4||e.length===6||e.length===8))throw new Error("Invalid key parameter.");var o=this.mode.name,s=["CFB","OFB","CTR","GCM"].indexOf(o)!==-1;this._w=Da(e,t.decrypt&&!s),this._init=!0}};ht.aes._expandKey=function(t,e){return uo||La(),Da(t,e)};ht.aes._updateBlock=co;Lr("AES-ECB",ht.cipher.modes.ecb);Lr("AES-CBC",ht.cipher.modes.cbc);Lr("AES-CFB",ht.cipher.modes.cfb);Lr("AES-OFB",ht.cipher.modes.ofb);Lr("AES-CTR",ht.cipher.modes.ctr);Lr("AES-GCM",ht.cipher.modes.gcm);function Lr(t,e){var r=function(){return new ht.aes.Algorithm(t,e)};ht.cipher.registerAlgorithm(t,r)}var uo=!1,Rr=4,Ht,fo,Ra,fr,ne;function La(){uo=!0,Ra=[0,1,2,4,8,16,32,64,128,27,54];for(var t=new Array(256),e=0;e<128;++e)t[e]=e<<1,t[e+128]=e+128<<1^283;Ht=new Array(256),fo=new Array(256),fr=new Array(4),ne=new Array(4);for(var e=0;e<4;++e)fr[e]=new Array(256),ne[e]=new Array(256);for(var r=0,n=0,i,o,s,a,c,f,u,e=0;e<256;++e){a=n^n<<1^n<<2^n<<3^n<<4,a=a>>8^a&255^99,Ht[r]=a,fo[a]=r,c=t[a],i=t[r],o=t[i],s=t[o],f=c<<24^a<<16^a<<8^(a^c),u=(i^o^s)<<24^(r^s)<<16^(r^o^s)<<8^(r^i^s);for(var l=0;l<4;++l)fr[l][r]=f,ne[l][a]=u,f=f<<24|f>>>8,u=u<<24|u>>>8;r===0?r=n=1:(r=i^t[t[t[i^s]]],n^=t[t[n]])}}function Da(t,e){for(var r=t.slice(0),n,i=1,o=r.length,s=o+6+1,a=Rr*s,c=o;c<a;++c)n=r[c-1],c%o===0?(n=Ht[n>>>16&255]<<24^Ht[n>>>8&255]<<16^Ht[n&255]<<8^Ht[n>>>24]^Ra[i]<<24,i++):o>6&&c%o===4&&(n=Ht[n>>>24]<<24^Ht[n>>>16&255]<<16^Ht[n>>>8&255]<<8^Ht[n&255]),r[c]=r[c-o]^n;if(e){var f,u=ne[0],l=ne[1],p=ne[2],d=ne[3],h=r.slice(0);a=r.length;for(var c=0,y=a-Rr;c<a;c+=Rr,y-=Rr)if(c===0||c===a-Rr)h[c]=r[y],h[c+1]=r[y+3],h[c+2]=r[y+2],h[c+3]=r[y+1];else for(var g=0;g<Rr;++g)f=r[y+g],h[c+(3&-g)]=u[Ht[f>>>24]]^l[Ht[f>>>16&255]]^p[Ht[f>>>8&255]]^d[Ht[f&255]];r=h}return r}function co(t,e,r,n){var i=t.length/4-1,o,s,a,c,f;n?(o=ne[0],s=ne[1],a=ne[2],c=ne[3],f=fo):(o=fr[0],s=fr[1],a=fr[2],c=fr[3],f=Ht);var u,l,p,d,h,y,g;u=e[0]^t[0],l=e[n?3:1]^t[1],p=e[2]^t[2],d=e[n?1:3]^t[3];for(var x=3,m=1;m<i;++m)h=o[u>>>24]^s[l>>>16&255]^a[p>>>8&255]^c[d&255]^t[++x],y=o[l>>>24]^s[p>>>16&255]^a[d>>>8&255]^c[u&255]^t[++x],g=o[p>>>24]^s[d>>>16&255]^a[u>>>8&255]^c[l&255]^t[++x],d=o[d>>>24]^s[u>>>16&255]^a[l>>>8&255]^c[p&255]^t[++x],u=h,l=y,p=g;r[0]=f[u>>>24]<<24^f[l>>>16&255]<<16^f[p>>>8&255]<<8^f[d&255]^t[++x],r[n?3:1]=f[l>>>24]<<24^f[p>>>16&255]<<16^f[d>>>8&255]<<8^f[u&255]^t[++x],r[2]=f[p>>>24]<<24^f[d>>>16&255]<<16^f[u>>>8&255]<<8^f[l&255]^t[++x],r[n?1:3]=f[d>>>24]<<24^f[u>>>16&255]<<16^f[l>>>8&255]<<8^f[p&255]^t[++x]}function kn(t){t=t||{};var e=(t.mode||"CBC").toUpperCase(),r="AES-"+e,n;t.decrypt?n=ht.cipher.createDecipher(r,t.key):n=ht.cipher.createCipher(r,t.key);var i=n.start;return n.start=function(o,s){var a=null;s instanceof ht.util.ByteBuffer&&(a=s,s={}),s=s||{},s.output=a,s.iv=o,i.call(n,s)},n}});var Ua=ft((bg,Na)=>{var yt=ct();oo();ao();Et();Na.exports=yt.des=yt.des||{};yt.des.startEncrypting=function(t,e,r,n){var i=Nn({key:t,output:r,decrypt:!1,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};yt.des.createEncryptionCipher=function(t,e){return Nn({key:t,output:null,decrypt:!1,mode:e})};yt.des.startDecrypting=function(t,e,r,n){var i=Nn({key:t,output:r,decrypt:!0,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};yt.des.createDecryptionCipher=function(t,e){return Nn({key:t,output:null,decrypt:!0,mode:e})};yt.des.Algorithm=function(t,e){var r=this;r.name=t,r.mode=new e({blockSize:8,cipher:{encrypt:function(n,i){return ka(r._keys,n,i,!1)},decrypt:function(n,i){return ka(r._keys,n,i,!0)}}}),r._init=!1};yt.des.Algorithm.prototype.initialize=function(t){if(!this._init){var e=yt.util.createBuffer(t.key);if(this.name.indexOf("3DES")===0&&e.length()!==24)throw new Error("Invalid Triple-DES key size: "+e.length()*8);this._keys=vl(e),this._init=!0}};ge("DES-ECB",yt.cipher.modes.ecb);ge("DES-CBC",yt.cipher.modes.cbc);ge("DES-CFB",yt.cipher.modes.cfb);ge("DES-OFB",yt.cipher.modes.ofb);ge("DES-CTR",yt.cipher.modes.ctr);ge("3DES-ECB",yt.cipher.modes.ecb);ge("3DES-CBC",yt.cipher.modes.cbc);ge("3DES-CFB",yt.cipher.modes.cfb);ge("3DES-OFB",yt.cipher.modes.ofb);ge("3DES-CTR",yt.cipher.modes.ctr);function ge(t,e){var r=function(){return new yt.des.Algorithm(t,e)};yt.cipher.registerAlgorithm(t,r)}var ll=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],hl=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],dl=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],pl=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],yl=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],gl=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],xl=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],ml=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function vl(t){for(var e=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],r=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],a=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],f=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],u=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],l=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],p=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],d=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],h=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],y=t.length()>8?3:1,g=[],x=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],m=0,b,_=0;_<y;_++){var E=t.getInt32(),S=t.getInt32();b=(E>>>4^S)&252645135,S^=b,E^=b<<4,b=(S>>>-16^E)&65535,E^=b,S^=b<<-16,b=(E>>>2^S)&858993459,S^=b,E^=b<<2,b=(S>>>-16^E)&65535,E^=b,S^=b<<-16,b=(E>>>1^S)&1431655765,S^=b,E^=b<<1,b=(S>>>8^E)&16711935,E^=b,S^=b<<8,b=(E>>>1^S)&1431655765,S^=b,E^=b<<1,b=E<<8|S>>>20&240,E=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=b;for(var L=0;L<x.length;++L){x[L]?(E=E<<2|E>>>26,S=S<<2|S>>>26):(E=E<<1|E>>>27,S=S<<1|S>>>27),E&=-15,S&=-15;var D=e[E>>>28]|r[E>>>24&15]|n[E>>>20&15]|i[E>>>16&15]|o[E>>>12&15]|s[E>>>8&15]|a[E>>>4&15],z=c[S>>>28]|f[S>>>24&15]|u[S>>>20&15]|l[S>>>16&15]|p[S>>>12&15]|d[S>>>8&15]|h[S>>>4&15];b=(z>>>16^D)&65535,g[m++]=D^b,g[m++]=z^b<<16}}return g}function ka(t,e,r,n){var i=t.length===32?3:9,o;i===3?o=n?[30,-2,-2]:[0,32,2]:o=n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var s,a=e[0],c=e[1];s=(a>>>4^c)&252645135,c^=s,a^=s<<4,s=(a>>>16^c)&65535,c^=s,a^=s<<16,s=(c>>>2^a)&858993459,a^=s,c^=s<<2,s=(c>>>8^a)&16711935,a^=s,c^=s<<8,s=(a>>>1^c)&1431655765,c^=s,a^=s<<1,a=a<<1|a>>>31,c=c<<1|c>>>31;for(var f=0;f<i;f+=3){for(var u=o[f+1],l=o[f+2],p=o[f];p!=u;p+=l){var d=c^t[p],h=(c>>>4|c<<28)^t[p+1];s=a,a=c,c=s^(hl[d>>>24&63]|pl[d>>>16&63]|gl[d>>>8&63]|ml[d&63]|ll[h>>>24&63]|dl[h>>>16&63]|yl[h>>>8&63]|xl[h&63])}s=a,a=c,c=s}a=a>>>1|a<<31,c=c>>>1|c<<31,s=(a>>>1^c)&1431655765,c^=s,a^=s<<1,s=(c>>>8^a)&16711935,a^=s,c^=s<<8,s=(c>>>2^a)&858993459,a^=s,c^=s<<2,s=(a>>>16^c)&65535,c^=s,a^=s<<16,s=(a>>>4^c)&252645135,c^=s,a^=s<<4,r[0]=a,r[1]=c}function Nn(t){t=t||{};var e=(t.mode||"CBC").toUpperCase(),r="DES-"+e,n;t.decrypt?n=yt.cipher.createDecipher(r,t.key):n=yt.cipher.createCipher(r,t.key);var i=n.start;return n.start=function(o,s){var a=null;s instanceof yt.util.ByteBuffer&&(a=s,s={}),s=s||{},s.output=a,s.iv=o,i.call(n,s)},n}});var cr=ft((wg,Oa)=>{var Un=ct();Oa.exports=Un.md=Un.md||{};Un.md.algorithms=Un.md.algorithms||{}});var Fa=ft((Eg,Ka)=>{var Ie=ct();cr();Et();var bl=Ka.exports=Ie.hmac=Ie.hmac||{};bl.create=function(){var t=null,e=null,r=null,n=null,i={};return i.start=function(o,s){if(o!==null)if(typeof o=="string")if(o=o.toLowerCase(),o in Ie.md.algorithms)e=Ie.md.algorithms[o].create();else throw new Error('Unknown hash algorithm "'+o+'"');else e=o;if(s===null)s=t;else{if(typeof s=="string")s=Ie.util.createBuffer(s);else if(Ie.util.isArray(s)){var a=s;s=Ie.util.createBuffer();for(var c=0;c<a.length;++c)s.putByte(a[c])}var f=s.length();f>e.blockLength&&(e.start(),e.update(s.bytes()),s=e.digest()),r=Ie.util.createBuffer(),n=Ie.util.createBuffer(),f=s.length();for(var c=0;c<f;++c){var a=s.at(c);r.putByte(54^a),n.putByte(92^a)}if(f<e.blockLength)for(var a=e.blockLength-f,c=0;c<a;++c)r.putByte(54),n.putByte(92);t=s,r=r.bytes(),n=n.bytes()}e.start(),e.update(r)},i.update=function(o){e.update(o)},i.getMac=function(){var o=e.digest().bytes();return e.start(),e.update(n),e.update(o),e.digest()},i.digest=i.getMac,i}});var On=ft(()=>{});var Va=ft((Ag,Ma)=>{var $t=ct();Fa();cr();Et();var wl=$t.pkcs5=$t.pkcs5||{},Te;$t.util.isNodejs&&!$t.options.usePureJavaScript&&(Te=On());Ma.exports=$t.pbkdf2=wl.pbkdf2=function(t,e,r,n,i,o){if(typeof i=="function"&&(o=i,i=null),$t.util.isNodejs&&!$t.options.usePureJavaScript&&Te.pbkdf2&&(i===null||typeof i!="object")&&(Te.pbkdf2Sync.length>4||!i||i==="sha1"))return typeof i!="string"&&(i="sha1"),t=Buffer.from(t,"binary"),e=Buffer.from(e,"binary"),o?Te.pbkdf2Sync.length===4?Te.pbkdf2(t,e,r,n,function(b,_){if(b)return o(b);o(null,_.toString("binary"))}):Te.pbkdf2(t,e,r,n,i,function(b,_){if(b)return o(b);o(null,_.toString("binary"))}):Te.pbkdf2Sync.length===4?Te.pbkdf2Sync(t,e,r,n).toString("binary"):Te.pbkdf2Sync(t,e,r,n,i).toString("binary");if((typeof i>"u"||i===null)&&(i="sha1"),typeof i=="string"){if(!(i in $t.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=$t.md[i].create()}var s=i.digestLength;if(n>4294967295*s){var a=new Error("Derived key is too long.");if(o)return o(a);throw a}var c=Math.ceil(n/s),f=n-(c-1)*s,u=$t.hmac.create();u.start(i,t);var l="",p,d,h;if(!o){for(var y=1;y<=c;++y){u.start(null,null),u.update(e),u.update($t.util.int32ToBytes(y)),p=h=u.digest().getBytes();for(var g=2;g<=r;++g)u.start(null,null),u.update(h),d=u.digest().getBytes(),p=$t.util.xorBytes(p,d,s),h=d;l+=y<c?p:p.substr(0,f)}return l}var y=1,g;function x(){if(y>c)return o(null,l);u.start(null,null),u.update(e),u.update($t.util.int32ToBytes(y)),p=h=u.digest().getBytes(),g=2,m()}function m(){if(g<=r)return u.start(null,null),u.update(h),d=u.digest().getBytes(),p=$t.util.xorBytes(p,d,s),h=d,++g,$t.util.setImmediate(m);l+=y<c?p:p.substr(0,f),++y,x()}x()}});var Ha=ft((Ig,za)=>{var Fn=ct();Et();var qa=za.exports=Fn.pem=Fn.pem||{};qa.encode=function(t,e){e=e||{};var r="-----BEGIN "+t.type+`-----\r
9
- `,n;if(t.procType&&(n={name:"Proc-Type",values:[String(t.procType.version),t.procType.type]},r+=Kn(n)),t.contentDomain&&(n={name:"Content-Domain",values:[t.contentDomain]},r+=Kn(n)),t.dekInfo&&(n={name:"DEK-Info",values:[t.dekInfo.algorithm]},t.dekInfo.parameters&&n.values.push(t.dekInfo.parameters),r+=Kn(n)),t.headers)for(var i=0;i<t.headers.length;++i)r+=Kn(t.headers[i]);return t.procType&&(r+=`\r
10
- `),r+=Fn.util.encode64(t.body,e.maxline||64)+`\r
11
- `,r+="-----END "+t.type+`-----\r
12
- `,r};qa.decode=function(t){for(var e=[],r=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,n=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,i=/\r?\n/,o;o=r.exec(t),!!o;){var s=o[1];s==="NEW CERTIFICATE REQUEST"&&(s="CERTIFICATE REQUEST");var a={type:s,procType:null,contentDomain:null,dekInfo:null,headers:[],body:Fn.util.decode64(o[3])};if(e.push(a),!!o[2]){for(var c=o[2].split(i),f=0;o&&f<c.length;){for(var u=c[f].replace(/\s+$/,""),l=f+1;l<c.length;++l){var p=c[l];if(!/\s/.test(p[0]))break;u+=p,f=l}if(o=u.match(n),o){for(var d={name:o[1],values:[]},h=o[2].split(","),y=0;y<h.length;++y)d.values.push(El(h[y]));if(a.procType)if(!a.contentDomain&&d.name==="Content-Domain")a.contentDomain=h[0]||"";else if(!a.dekInfo&&d.name==="DEK-Info"){if(d.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');a.dekInfo={algorithm:h[0],parameters:h[1]||null}}else a.headers.push(d);else{if(d.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(d.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');a.procType={version:h[0],type:h[1]}}}++f}if(a.procType==="ENCRYPTED"&&!a.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(e.length===0)throw new Error("Invalid PEM formatted message.");return e};function Kn(t){for(var e=t.name+": ",r=[],n=function(c,f){return" "+f},i=0;i<t.values.length;++i)r.push(t.values[i].replace(/^(\S+\r\n)/,n));e+=r.join(",")+`\r
13
- `;for(var o=0,s=-1,i=0;i<e.length;++i,++o)if(o>65&&s!==-1){var a=e[s];a===","?(++s,e=e.substr(0,s)+`\r
14
- `+e.substr(s)):e=e.substr(0,s)+`\r
15
- `+a+e.substr(s+1),o=i-s-1,s=-1,++i}else(e[i]===" "||e[i]===" "||e[i]===",")&&(s=i);return e}function El(t){return t.replace(/^\s+/,"")}});var Qa=ft((Tg,Za)=>{var xe=ct();cr();Et();var Ga=Za.exports=xe.sha256=xe.sha256||{};xe.md.sha256=xe.md.algorithms.sha256=Ga;Ga.create=function(){Wa||Sl();var t=null,e=xe.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,o=0;o<i;++o)n.fullMessageLength.push(0);return e=xe.util.createBuffer(),t={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n},n.start(),n.update=function(i,o){o==="utf8"&&(i=xe.util.encodeUtf8(i));var s=i.length;n.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=s[1],s[1]=s[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,s[0]=s[1]/4294967296>>>0;return e.putBytes(i),$a(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=xe.util.createBuffer();i.putBytes(e.bytes());var o=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,s=o&n.blockLength-1;i.putBytes(ho.substr(0,n.blockLength-s));for(var a,c,f=n.fullMessageLength[0]*8,u=0;u<n.fullMessageLength.length-1;++u)a=n.fullMessageLength[u+1]*8,c=a/4294967296>>>0,f+=c,i.putInt32(f>>>0),f=a>>>0;i.putInt32(f);var l={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};$a(l,r,i);var p=xe.util.createBuffer();return p.putInt32(l.h0),p.putInt32(l.h1),p.putInt32(l.h2),p.putInt32(l.h3),p.putInt32(l.h4),p.putInt32(l.h5),p.putInt32(l.h6),p.putInt32(l.h7),p},n};var ho=null,Wa=!1,Ya=null;function Sl(){ho="\x80",ho+=xe.util.fillString("\0",64),Ya=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Wa=!0}function $a(t,e,r){for(var n,i,o,s,a,c,f,u,l,p,d,h,y,g,x,m=r.length();m>=64;){for(f=0;f<16;++f)e[f]=r.getInt32();for(;f<64;++f)n=e[f-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=e[f-15],i=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,e[f]=n+e[f-7]+i+e[f-16]|0;for(u=t.h0,l=t.h1,p=t.h2,d=t.h3,h=t.h4,y=t.h5,g=t.h6,x=t.h7,f=0;f<64;++f)s=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),a=g^h&(y^g),o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),c=u&l|p&(u^l),n=x+s+a+Ya[f]+e[f],i=o+c,x=g,g=y,y=h,h=d+n>>>0,d=p,p=l,l=u,u=n+i>>>0;t.h0=t.h0+u|0,t.h1=t.h1+l|0,t.h2=t.h2+p|0,t.h3=t.h3+d|0,t.h4=t.h4+h|0,t.h5=t.h5+y|0,t.h6=t.h6+g|0,t.h7=t.h7+x|0,m-=64}}});var Ja=ft((Cg,Xa)=>{var me=ct();Et();var Mn=null;me.util.isNodejs&&!me.options.usePureJavaScript&&!process.versions["node-webkit"]&&(Mn=On());var Bl=Xa.exports=me.prng=me.prng||{};Bl.create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=t.md,n=new Array(32),i=0;i<32;++i)n[i]=r.create();e.pools=n,e.pool=0,e.generate=function(f,u){if(!u)return e.generateSync(f);var l=e.plugin.cipher,p=e.plugin.increment,d=e.plugin.formatKey,h=e.plugin.formatSeed,y=me.util.createBuffer();e.key=null,g();function g(x){if(x)return u(x);if(y.length()>=f)return u(null,y.getBytes(f));if(e.generated>1048575&&(e.key=null),e.key===null)return me.util.nextTick(function(){o(g)});var m=l(e.key,e.seed);e.generated+=m.length,y.putBytes(m),e.key=d(l(e.key,p(e.seed))),e.seed=h(l(e.key,e.seed)),me.util.setImmediate(g)}},e.generateSync=function(f){var u=e.plugin.cipher,l=e.plugin.increment,p=e.plugin.formatKey,d=e.plugin.formatSeed;e.key=null;for(var h=me.util.createBuffer();h.length()<f;){e.generated>1048575&&(e.key=null),e.key===null&&s();var y=u(e.key,e.seed);e.generated+=y.length,h.putBytes(y),e.key=p(u(e.key,l(e.seed))),e.seed=d(u(e.key,e.seed))}return h.getBytes(f)};function o(f){if(e.pools[0].messageLength>=32)return a(),f();var u=32-e.pools[0].messageLength<<5;e.seedFile(u,function(l,p){if(l)return f(l);e.collect(p),a(),f()})}function s(){if(e.pools[0].messageLength>=32)return a();var f=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(f)),a()}function a(){e.reseeds=e.reseeds===4294967295?0:e.reseeds+1;var f=e.plugin.md.create();f.update(e.keyBytes);for(var u=1,l=0;l<32;++l)e.reseeds%u===0&&(f.update(e.pools[l].digest().getBytes()),e.pools[l].start()),u=u<<1;e.keyBytes=f.digest().getBytes(),f.start(),f.update(e.keyBytes);var p=f.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(p),e.generated=0}function c(f){var u=null,l=me.util.globalScope,p=l.crypto||l.msCrypto;p&&p.getRandomValues&&(u=function(E){return p.getRandomValues(E)});var d=me.util.createBuffer();if(u)for(;d.length()<f;){var h=Math.max(1,Math.min(f-d.length(),65536)/4),y=new Uint32Array(Math.floor(h));try{u(y);for(var g=0;g<y.length;++g)d.putInt32(y[g])}catch(E){if(!(typeof QuotaExceededError<"u"&&E instanceof QuotaExceededError))throw E}}if(d.length()<f)for(var x,m,b,_=Math.floor(Math.random()*65536);d.length()<f;){m=16807*(_&65535),x=16807*(_>>16),m+=(x&32767)<<16,m+=x>>15,m=(m&2147483647)+(m>>31),_=m&4294967295;for(var g=0;g<3;++g)b=_>>>(g<<3),b^=Math.floor(Math.random()*256),d.putByte(b&255)}return d.getBytes(f)}return Mn?(e.seedFile=function(f,u){Mn.randomBytes(f,function(l,p){if(l)return u(l);u(null,p.toString())})},e.seedFileSync=function(f){return Mn.randomBytes(f).toString()}):(e.seedFile=function(f,u){try{u(null,c(f))}catch(l){u(l)}},e.seedFileSync=c),e.collect=function(f){for(var u=f.length,l=0;l<u;++l)e.pools[e.pool].update(f.substr(l,1)),e.pool=e.pool===31?0:e.pool+1},e.collectInt=function(f,u){for(var l="",p=0;p<u;p+=8)l+=String.fromCharCode(f>>p&255);e.collect(l)},e.registerWorker=function(f){if(f===self)e.seedFile=function(l,p){function d(h){var y=h.data;y.forge&&y.forge.prng&&(self.removeEventListener("message",d),p(y.forge.prng.err,y.forge.prng.bytes))}self.addEventListener("message",d),self.postMessage({forge:{prng:{needed:l}}})};else{var u=function(l){var p=l.data;p.forge&&p.forge.prng&&e.seedFile(p.forge.prng.needed,function(d,h){f.postMessage({forge:{prng:{err:d,bytes:h}}})})};f.addEventListener("message",u)}},e}});var fn=ft((_g,po)=>{var Dt=ct();lo();Qa();Ja();Et();(function(){if(Dt.random&&Dt.random.getBytes){po.exports=Dt.random;return}(function(t){var e={},r=new Array(4),n=Dt.util.createBuffer();e.formatKey=function(l){var p=Dt.util.createBuffer(l);return l=new Array(4),l[0]=p.getInt32(),l[1]=p.getInt32(),l[2]=p.getInt32(),l[3]=p.getInt32(),Dt.aes._expandKey(l,!1)},e.formatSeed=function(l){var p=Dt.util.createBuffer(l);return l=new Array(4),l[0]=p.getInt32(),l[1]=p.getInt32(),l[2]=p.getInt32(),l[3]=p.getInt32(),l},e.cipher=function(l,p){return Dt.aes._updateBlock(l,p,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},e.increment=function(l){return++l[3],l},e.md=Dt.md.sha256;function i(){var l=Dt.prng.create(e);return l.getBytes=function(p,d){return l.generate(p,d)},l.getBytesSync=function(p){return l.generate(p)},l}var o=i(),s=null,a=Dt.util.globalScope,c=a.crypto||a.msCrypto;if(c&&c.getRandomValues&&(s=function(l){return c.getRandomValues(l)}),Dt.options.usePureJavaScript||!Dt.util.isNodejs&&!s){if(typeof window>"u"||window.document,o.collectInt(+new Date,32),typeof navigator<"u"){var f="";for(var u in navigator)try{typeof navigator[u]=="string"&&(f+=navigator[u])}catch{}o.collect(f),f=null}t&&(t().mousemove(function(l){o.collectInt(l.clientX,16),o.collectInt(l.clientY,16)}),t().keypress(function(l){o.collectInt(l.charCode,8)}))}if(!Dt.random)Dt.random=o;else for(var u in o)Dt.random[u]=o[u];Dt.random.createInstance=i,po.exports=Dt.random})(typeof jQuery<"u"?jQuery:null)})()});var r0=ft((Rg,e0)=>{var Gt=ct();Et();var yo=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],ja=[1,2,3,5],Al=function(t,e){return t<<e&65535|(t&65535)>>16-e},Il=function(t,e){return(t&65535)>>e|t<<16-e&65535};e0.exports=Gt.rc2=Gt.rc2||{};Gt.rc2.expandKey=function(t,e){typeof t=="string"&&(t=Gt.util.createBuffer(t)),e=e||128;var r=t,n=t.length(),i=e,o=Math.ceil(i/8),s=255>>(i&7),a;for(a=n;a<128;a++)r.putByte(yo[r.at(a-1)+r.at(a-n)&255]);for(r.setAt(128-o,yo[r.at(128-o)&s]),a=127-o;a>=0;a--)r.setAt(a,yo[r.at(a+1)^r.at(a+o)]);return r};var t0=function(t,e,r){var n=!1,i=null,o=null,s=null,a,c,f,u,l=[];for(t=Gt.rc2.expandKey(t,e),f=0;f<64;f++)l.push(t.getInt16Le());r?(a=function(h){for(f=0;f<4;f++)h[f]+=l[u]+(h[(f+3)%4]&h[(f+2)%4])+(~h[(f+3)%4]&h[(f+1)%4]),h[f]=Al(h[f],ja[f]),u++},c=function(h){for(f=0;f<4;f++)h[f]+=l[h[(f+3)%4]&63]}):(a=function(h){for(f=3;f>=0;f--)h[f]=Il(h[f],ja[f]),h[f]-=l[u]+(h[(f+3)%4]&h[(f+2)%4])+(~h[(f+3)%4]&h[(f+1)%4]),u--},c=function(h){for(f=3;f>=0;f--)h[f]-=l[h[(f+3)%4]&63]});var p=function(h){var y=[];for(f=0;f<4;f++){var g=i.getInt16Le();s!==null&&(r?g^=s.getInt16Le():s.putInt16Le(g)),y.push(g&65535)}u=r?0:63;for(var x=0;x<h.length;x++)for(var m=0;m<h[x][0];m++)h[x][1](y);for(f=0;f<4;f++)s!==null&&(r?s.putInt16Le(y[f]):y[f]^=s.getInt16Le()),o.putInt16Le(y[f])},d=null;return d={start:function(h,y){h&&typeof h=="string"&&(h=Gt.util.createBuffer(h)),n=!1,i=Gt.util.createBuffer(),o=y||new Gt.util.createBuffer,s=h,d.output=o},update:function(h){for(n||i.putBuffer(h);i.length()>=8;)p([[5,a],[1,c],[6,a],[1,c],[5,a]])},finish:function(h){var y=!0;if(r)if(h)y=h(8,i,!r);else{var g=i.length()===8?8:8-i.length();i.fillWithByte(g,g)}if(y&&(n=!0,d.update()),!r&&(y=i.length()===0,y))if(h)y=h(8,o,!r);else{var x=o.length(),m=o.at(x-1);m>x?y=!1:o.truncate(m)}return y}},d};Gt.rc2.startEncrypting=function(t,e,r){var n=Gt.rc2.createEncryptionCipher(t,128);return n.start(e,r),n};Gt.rc2.createEncryptionCipher=function(t,e){return t0(t,e,!0)};Gt.rc2.startDecrypting=function(t,e,r){var n=Gt.rc2.createDecryptionCipher(t,128);return n.start(e,r),n};Gt.rc2.createDecryptionCipher=function(t,e){return t0(t,e,!1)}});var zn=ft((Lg,u0)=>{var go=ct();u0.exports=go.jsbn=go.jsbn||{};var Ce,Tl=0xdeadbeefcafe,n0=(Tl&16777215)==15715070;function I(t,e,r){this.data=[],t!=null&&(typeof t=="number"?this.fromNumber(t,e,r):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}go.jsbn.BigInteger=I;function et(){return new I(null)}function Cl(t,e,r,n,i,o){for(;--o>=0;){var s=e*this.data[t++]+r.data[n]+i;i=Math.floor(s/67108864),r.data[n++]=s&67108863}return i}function _l(t,e,r,n,i,o){for(var s=e&32767,a=e>>15;--o>=0;){var c=this.data[t]&32767,f=this.data[t++]>>15,u=a*c+f*s;c=s*c+((u&32767)<<15)+r.data[n]+(i&1073741823),i=(c>>>30)+(u>>>15)+a*f+(i>>>30),r.data[n++]=c&1073741823}return i}function i0(t,e,r,n,i,o){for(var s=e&16383,a=e>>14;--o>=0;){var c=this.data[t]&16383,f=this.data[t++]>>14,u=a*c+f*s;c=s*c+((u&16383)<<14)+r.data[n]+i,i=(c>>28)+(u>>14)+a*f,r.data[n++]=c&268435455}return i}typeof navigator>"u"?(I.prototype.am=i0,Ce=28):n0&&navigator.appName=="Microsoft Internet Explorer"?(I.prototype.am=_l,Ce=30):n0&&navigator.appName!="Netscape"?(I.prototype.am=Cl,Ce=26):(I.prototype.am=i0,Ce=28);I.prototype.DB=Ce;I.prototype.DM=(1<<Ce)-1;I.prototype.DV=1<<Ce;var xo=52;I.prototype.FV=Math.pow(2,xo);I.prototype.F1=xo-Ce;I.prototype.F2=2*Ce-xo;var Rl="0123456789abcdefghijklmnopqrstuvwxyz",Vn=new Array,Dr,Jt;Dr=48;for(Jt=0;Jt<=9;++Jt)Vn[Dr++]=Jt;Dr=97;for(Jt=10;Jt<36;++Jt)Vn[Dr++]=Jt;Dr=65;for(Jt=10;Jt<36;++Jt)Vn[Dr++]=Jt;function o0(t){return Rl.charAt(t)}function s0(t,e){var r=Vn[t.charCodeAt(e)];return r??-1}function Ll(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s}function Dl(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0}function We(t){var e=et();return e.fromInt(t),e}function Pl(t,e){var r;if(e==16)r=4;else if(e==8)r=3;else if(e==256)r=8;else if(e==2)r=1;else if(e==32)r=5;else if(e==4)r=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=r==8?t[n]&255:s0(t,n);if(s<0){t.charAt(n)=="-"&&(i=!0);continue}i=!1,o==0?this.data[this.t++]=s:o+r>this.DB?(this.data[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this.data[this.t++]=s>>this.DB-o):this.data[this.t-1]|=s<<o,o+=r,o>=this.DB&&(o-=this.DB)}r==8&&t[0]&128&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&I.ZERO.subTo(this,this)}function kl(){for(var t=this.s&this.DM;this.t>0&&this.data[this.t-1]==t;)--this.t}function Nl(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var r=(1<<e)-1,n,i=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(n=this.data[s]>>a)>0&&(i=!0,o=o0(n));s>=0;)a<e?(n=(this.data[s]&(1<<a)-1)<<e-a,n|=this.data[--s]>>(a+=this.DB-e)):(n=this.data[s]>>(a-=e)&r,a<=0&&(a+=this.DB,--s)),n>0&&(i=!0),i&&(o+=o0(n));return i?o:"0"}function Ul(){var t=et();return I.ZERO.subTo(this,t),t}function Ol(){return this.s<0?this.negate():this}function Kl(t){var e=this.s-t.s;if(e!=0)return e;var r=this.t;if(e=r-t.t,e!=0)return this.s<0?-e:e;for(;--r>=0;)if((e=this.data[r]-t.data[r])!=0)return e;return 0}function qn(t){var e=1,r;return(r=t>>>16)!=0&&(t=r,e+=16),(r=t>>8)!=0&&(t=r,e+=8),(r=t>>4)!=0&&(t=r,e+=4),(r=t>>2)!=0&&(t=r,e+=2),(r=t>>1)!=0&&(t=r,e+=1),e}function Fl(){return this.t<=0?0:this.DB*(this.t-1)+qn(this.data[this.t-1]^this.s&this.DM)}function Ml(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s}function Vl(t,e){for(var r=t;r<this.t;++r)e.data[r-t]=this.data[r];e.t=Math.max(this.t-t,0),e.s=this.s}function ql(t,e){var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,o=Math.floor(t/this.DB),s=this.s<<r&this.DM,a;for(a=this.t-1;a>=0;--a)e.data[a+o+1]=this.data[a]>>n|s,s=(this.data[a]&i)<<r;for(a=o-1;a>=0;--a)e.data[a]=0;e.data[o]=s,e.t=this.t+o+1,e.s=this.s,e.clamp()}function zl(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t){e.t=0;return}var n=t%this.DB,i=this.DB-n,o=(1<<n)-1;e.data[0]=this.data[r]>>n;for(var s=r+1;s<this.t;++s)e.data[s-r-1]|=(this.data[s]&o)<<i,e.data[s-r]=this.data[s]>>n;n>0&&(e.data[this.t-r-1]|=(this.s&o)<<i),e.t=this.t-r,e.clamp()}function Hl(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]-t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e.data[r++]=this.DV+n:n>0&&(e.data[r++]=n),e.t=r,e.clamp()}function $l(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e.data[i]=0;for(i=0;i<n.t;++i)e.data[i+r.t]=r.am(0,n.data[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&I.ZERO.subTo(e,e)}function Gl(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t.data[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e.data[r],t,2*r,0,1);(t.data[r+e.t]+=e.am(r+1,2*e.data[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()}function Wl(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t){e?.fromInt(0),r!=null&&this.copyTo(r);return}r==null&&(r=et());var o=et(),s=this.s,a=t.s,c=this.DB-qn(n.data[n.t-1]);c>0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var f=o.t,u=o.data[f-1];if(u!=0){var l=u*(1<<this.F1)+(f>1?o.data[f-2]>>this.F2:0),p=this.FV/l,d=(1<<this.F1)/l,h=1<<this.F2,y=r.t,g=y-f,x=e??et();for(o.dlShiftTo(g,x),r.compareTo(x)>=0&&(r.data[r.t++]=1,r.subTo(x,r)),I.ONE.dlShiftTo(f,x),x.subTo(o,o);o.t<f;)o.data[o.t++]=0;for(;--g>=0;){var m=r.data[--y]==u?this.DM:Math.floor(r.data[y]*p+(r.data[y-1]+h)*d);if((r.data[y]+=o.am(0,m,r,g,0,f))<m)for(o.dlShiftTo(g,x),r.subTo(x,r);r.data[y]<--m;)r.subTo(x,r)}e!=null&&(r.drShiftTo(f,e),s!=a&&I.ZERO.subTo(e,e)),r.t=f,r.clamp(),c>0&&r.rShiftTo(c,r),s<0&&I.ZERO.subTo(r,r)}}}function Yl(t){var e=et();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(I.ZERO)>0&&t.subTo(e,e),e}function ur(t){this.m=t}function Zl(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function Ql(t){return t}function Xl(t){t.divRemTo(this.m,null,t)}function Jl(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function jl(t,e){t.squareTo(e),this.reduce(e)}ur.prototype.convert=Zl;ur.prototype.revert=Ql;ur.prototype.reduce=Xl;ur.prototype.mulTo=Jl;ur.prototype.sqrTo=jl;function th(){if(this.t<1)return 0;var t=this.data[0];if(!(t&1))return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function lr(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function eh(t){var e=et();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(I.ZERO)>0&&this.m.subTo(e,e),e}function rh(t){var e=et();return t.copyTo(e),this.reduce(e),e}function nh(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=t.data[e]&32767,n=r*this.mpl+((r*this.mph+(t.data[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,n,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function ih(t,e){t.squareTo(e),this.reduce(e)}function oh(t,e,r){t.multiplyTo(e,r),this.reduce(r)}lr.prototype.convert=eh;lr.prototype.revert=rh;lr.prototype.reduce=nh;lr.prototype.mulTo=oh;lr.prototype.sqrTo=ih;function sh(){return(this.t>0?this.data[0]&1:this.s)==0}function ah(t,e){if(t>4294967295||t<1)return I.ONE;var r=et(),n=et(),i=e.convert(this),o=qn(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<<o)>0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)}function fh(t,e){var r;return t<256||e.isEven()?r=new ur(e):r=new lr(e),this.exp(t,r)}I.prototype.copyTo=Ll;I.prototype.fromInt=Dl;I.prototype.fromString=Pl;I.prototype.clamp=kl;I.prototype.dlShiftTo=Ml;I.prototype.drShiftTo=Vl;I.prototype.lShiftTo=ql;I.prototype.rShiftTo=zl;I.prototype.subTo=Hl;I.prototype.multiplyTo=$l;I.prototype.squareTo=Gl;I.prototype.divRemTo=Wl;I.prototype.invDigit=th;I.prototype.isEven=sh;I.prototype.exp=ah;I.prototype.toString=Nl;I.prototype.negate=Ul;I.prototype.abs=Ol;I.prototype.compareTo=Kl;I.prototype.bitLength=Fl;I.prototype.mod=Yl;I.prototype.modPowInt=fh;I.ZERO=We(0);I.ONE=We(1);function ch(){var t=et();return this.copyTo(t),t}function uh(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function lh(){return this.t==0?this.s:this.data[0]<<24>>24}function hh(){return this.t==0?this.s:this.data[0]<<16>>16}function dh(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function ph(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function yh(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=We(r),i=et(),o=et(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s}function gh(t,e){this.fromInt(0),e==null&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a<t.length;++a){var c=s0(t,a);if(c<0){t.charAt(a)=="-"&&this.signum()==0&&(i=!0);continue}s=e*s+c,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0)}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&I.ZERO.subTo(this,this)}function xh(t,e,r){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(I.ONE.shiftLeft(t-1),mo,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(I.ONE.shiftLeft(t-1),this);else{var n=new Array,i=t&7;n.length=(t>>3)+1,e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}function mh(){var t=this.t,e=new Array;e[0]=this.s;var r=this.DB-t*this.DB%8,n,i=0;if(t-- >0)for(r<this.DB&&(n=this.data[t]>>r)!=(this.s&this.DM)>>r&&(e[i++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this.data[t]&(1<<r)-1)<<8-r,n|=this.data[--t]>>(r+=this.DB-8)):(n=this.data[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),n&128&&(n|=-256),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(e[i++]=n);return e}function vh(t){return this.compareTo(t)==0}function bh(t){return this.compareTo(t)<0?this:t}function wh(t){return this.compareTo(t)>0?this:t}function Eh(t,e,r){var n,i,o=Math.min(t.t,this.t);for(n=0;n<o;++n)r.data[n]=e(this.data[n],t.data[n]);if(t.t<this.t){for(i=t.s&this.DM,n=o;n<this.t;++n)r.data[n]=e(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<t.t;++n)r.data[n]=e(i,t.data[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}function Sh(t,e){return t&e}function Bh(t){var e=et();return this.bitwiseTo(t,Sh,e),e}function mo(t,e){return t|e}function Ah(t){var e=et();return this.bitwiseTo(t,mo,e),e}function a0(t,e){return t^e}function Ih(t){var e=et();return this.bitwiseTo(t,a0,e),e}function f0(t,e){return t&~e}function Th(t){var e=et();return this.bitwiseTo(t,f0,e),e}function Ch(){for(var t=et(),e=0;e<this.t;++e)t.data[e]=this.DM&~this.data[e];return t.t=this.t,t.s=~this.s,t}function _h(t){var e=et();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function Rh(t){var e=et();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function Lh(t){if(t==0)return-1;var e=0;return t&65535||(t>>=16,e+=16),t&255||(t>>=8,e+=8),t&15||(t>>=4,e+=4),t&3||(t>>=2,e+=2),t&1||++e,e}function Dh(){for(var t=0;t<this.t;++t)if(this.data[t]!=0)return t*this.DB+Lh(this.data[t]);return this.s<0?this.t*this.DB:-1}function Ph(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function kh(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=Ph(this.data[r]^e);return t}function Nh(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this.data[e]&1<<t%this.DB)!=0}function Uh(t,e){var r=I.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}function Oh(t){return this.changeBit(t,mo)}function Kh(t){return this.changeBit(t,f0)}function Fh(t){return this.changeBit(t,a0)}function Mh(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]+t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e.data[r++]=n:n<-1&&(e.data[r++]=this.DV+n),e.t=r,e.clamp()}function Vh(t){var e=et();return this.addTo(t,e),e}function qh(t){var e=et();return this.subTo(t,e),e}function zh(t){var e=et();return this.multiplyTo(t,e),e}function Hh(t){var e=et();return this.divRemTo(t,e,null),e}function $h(t){var e=et();return this.divRemTo(t,null,e),e}function Gh(t){var e=et(),r=et();return this.divRemTo(t,e,r),new Array(e,r)}function Wh(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Yh(t,e){if(t!=0){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}}function cn(){}function c0(t){return t}function Zh(t,e,r){t.multiplyTo(e,r)}function Qh(t,e){t.squareTo(e)}cn.prototype.convert=c0;cn.prototype.revert=c0;cn.prototype.mulTo=Zh;cn.prototype.sqrTo=Qh;function Xh(t){return this.exp(t,new cn)}function Jh(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;var i;for(i=r.t-this.t;n<i;++n)r.data[n+this.t]=this.am(0,t.data[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t.data[n],r,n,0,e-n);r.clamp()}function jh(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r.data[this.t+n-e]=this.am(e-n,t.data[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}function Pr(t){this.r2=et(),this.q3=et(),I.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function td(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=et();return t.copyTo(e),this.reduce(e),e}function ed(t){return t}function rd(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function nd(t,e){t.squareTo(e),this.reduce(e)}function id(t,e,r){t.multiplyTo(e,r),this.reduce(r)}Pr.prototype.convert=td;Pr.prototype.revert=ed;Pr.prototype.reduce=rd;Pr.prototype.mulTo=id;Pr.prototype.sqrTo=nd;function od(t,e){var r=t.bitLength(),n,i=We(1),o;if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?o=new ur(e):e.isEven()?o=new Pr(e):o=new lr(e);var s=new Array,a=3,c=n-1,f=(1<<n)-1;if(s[1]=o.convert(this),n>1){var u=et();for(o.sqrTo(s[1],u);a<=f;)s[a]=et(),o.mulTo(u,s[a-2],s[a]),a+=2}var l=t.t-1,p,d=!0,h=et(),y;for(r=qn(t.data[l])-1;l>=0;){for(r>=c?p=t.data[l]>>r-c&f:(p=(t.data[l]&(1<<r+1)-1)<<c-r,l>0&&(p|=t.data[l-1]>>this.DB+r-c)),a=n;!(p&1);)p>>=1,--a;if((r-=a)<0&&(r+=this.DB,--l),d)s[p].copyTo(i),d=!1;else{for(;a>1;)o.sqrTo(i,h),o.sqrTo(h,i),a-=2;a>0?o.sqrTo(i,h):(y=i,i=h,h=y),o.mulTo(h,s[p],i)}for(;l>=0&&!(t.data[l]&1<<r);)o.sqrTo(i,h),y=i,i=h,h=y,--r<0&&(r=this.DB-1,--l)}return o.revert(i)}function sd(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i<o&&(o=i),o>0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}function ad(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(e==0)r=this.data[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this.data[n])%t;return r}function fd(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return I.ZERO;for(var r=t.clone(),n=this.clone(),i=We(1),o=We(0),s=We(0),a=We(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),e?((!i.isEven()||!o.isEven())&&(i.addTo(this,i),o.subTo(t,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),e?((!s.isEven()||!a.isEven())&&(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(n.compareTo(I.ONE)!=0)return I.ZERO;if(a.compareTo(t)>=0)return a.subtract(t);if(a.signum()<0)a.addTo(t,a);else return a;return a.signum()<0?a.add(t):a}var ie=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],cd=(1<<26)/ie[ie.length-1];function ud(t){var e,r=this.abs();if(r.t==1&&r.data[0]<=ie[ie.length-1]){for(e=0;e<ie.length;++e)if(r.data[0]==ie[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<ie.length;){for(var n=ie[e],i=e+1;i<ie.length&&n<cd;)n*=ie[i++];for(n=r.modInt(n);e<i;)if(n%ie[e++]==0)return!1}return r.millerRabin(t)}function ld(t){var e=this.subtract(I.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n=e.shiftRight(r),i=hd(),o,s=0;s<t;++s){do o=new I(this.bitLength(),i);while(o.compareTo(I.ONE)<=0||o.compareTo(e)>=0);var a=o.modPow(n,this);if(a.compareTo(I.ONE)!=0&&a.compareTo(e)!=0){for(var c=1;c++<r&&a.compareTo(e)!=0;)if(a=a.modPowInt(2,this),a.compareTo(I.ONE)==0)return!1;if(a.compareTo(e)!=0)return!1}}return!0}function hd(){return{nextBytes:function(t){for(var e=0;e<t.length;++e)t[e]=Math.floor(Math.random()*256)}}}I.prototype.chunkSize=dh;I.prototype.toRadix=yh;I.prototype.fromRadix=gh;I.prototype.fromNumber=xh;I.prototype.bitwiseTo=Eh;I.prototype.changeBit=Uh;I.prototype.addTo=Mh;I.prototype.dMultiply=Wh;I.prototype.dAddOffset=Yh;I.prototype.multiplyLowerTo=Jh;I.prototype.multiplyUpperTo=jh;I.prototype.modInt=ad;I.prototype.millerRabin=ld;I.prototype.clone=ch;I.prototype.intValue=uh;I.prototype.byteValue=lh;I.prototype.shortValue=hh;I.prototype.signum=ph;I.prototype.toByteArray=mh;I.prototype.equals=vh;I.prototype.min=bh;I.prototype.max=wh;I.prototype.and=Bh;I.prototype.or=Ah;I.prototype.xor=Ih;I.prototype.andNot=Th;I.prototype.not=Ch;I.prototype.shiftLeft=_h;I.prototype.shiftRight=Rh;I.prototype.getLowestSetBit=Dh;I.prototype.bitCount=kh;I.prototype.testBit=Nh;I.prototype.setBit=Oh;I.prototype.clearBit=Kh;I.prototype.flipBit=Fh;I.prototype.add=Vh;I.prototype.subtract=qh;I.prototype.multiply=zh;I.prototype.divide=Hh;I.prototype.remainder=$h;I.prototype.divideAndRemainder=Gh;I.prototype.modPow=od;I.prototype.modInverse=fd;I.prototype.pow=Xh;I.prototype.gcd=sd;I.prototype.isProbablePrime=ud});var y0=ft((Dg,p0)=>{var ve=ct();cr();Et();var h0=p0.exports=ve.sha1=ve.sha1||{};ve.md.sha1=ve.md.algorithms.sha1=h0;h0.create=function(){d0||dd();var t=null,e=ve.util.createBuffer(),r=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,o=0;o<i;++o)n.fullMessageLength.push(0);return e=ve.util.createBuffer(),t={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n},n.start(),n.update=function(i,o){o==="utf8"&&(i=ve.util.encodeUtf8(i));var s=i.length;n.messageLength+=s,s=[s/4294967296>>>0,s>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=s[1],s[1]=s[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,s[0]=s[1]/4294967296>>>0;return e.putBytes(i),l0(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=ve.util.createBuffer();i.putBytes(e.bytes());var o=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,s=o&n.blockLength-1;i.putBytes(vo.substr(0,n.blockLength-s));for(var a,c,f=n.fullMessageLength[0]*8,u=0;u<n.fullMessageLength.length-1;++u)a=n.fullMessageLength[u+1]*8,c=a/4294967296>>>0,f+=c,i.putInt32(f>>>0),f=a>>>0;i.putInt32(f);var l={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};l0(l,r,i);var p=ve.util.createBuffer();return p.putInt32(l.h0),p.putInt32(l.h1),p.putInt32(l.h2),p.putInt32(l.h3),p.putInt32(l.h4),p},n};var vo=null,d0=!1;function dd(){vo="\x80",vo+=ve.util.fillString("\0",64),d0=!0}function l0(t,e,r){for(var n,i,o,s,a,c,f,u,l=r.length();l>=64;){for(i=t.h0,o=t.h1,s=t.h2,a=t.h3,c=t.h4,u=0;u<16;++u)n=r.getInt32(),e[u]=n,f=a^o&(s^a),n=(i<<5|i>>>27)+f+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<20;++u)n=e[u-3]^e[u-8]^e[u-14]^e[u-16],n=n<<1|n>>>31,e[u]=n,f=a^o&(s^a),n=(i<<5|i>>>27)+f+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<32;++u)n=e[u-3]^e[u-8]^e[u-14]^e[u-16],n=n<<1|n>>>31,e[u]=n,f=o^s^a,n=(i<<5|i>>>27)+f+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<40;++u)n=e[u-6]^e[u-16]^e[u-28]^e[u-32],n=n<<2|n>>>30,e[u]=n,f=o^s^a,n=(i<<5|i>>>27)+f+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<60;++u)n=e[u-6]^e[u-16]^e[u-28]^e[u-32],n=n<<2|n>>>30,e[u]=n,f=o&s|a&(o^s),n=(i<<5|i>>>27)+f+c+2400959708+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<80;++u)n=e[u-6]^e[u-16]^e[u-28]^e[u-32],n=n<<2|n>>>30,e[u]=n,f=o^s^a,n=(i<<5|i>>>27)+f+c+3395469782+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;t.h0=t.h0+i|0,t.h1=t.h1+o|0,t.h2=t.h2+s|0,t.h3=t.h3+a|0,t.h4=t.h4+c|0,l-=64}}});var m0=ft((Pg,x0)=>{var be=ct();Et();fn();y0();var g0=x0.exports=be.pkcs1=be.pkcs1||{};g0.encode_rsa_oaep=function(t,e,r){var n,i,o,s;typeof r=="string"?(n=r,i=arguments[3]||void 0,o=arguments[4]||void 0):r&&(n=r.label||void 0,i=r.seed||void 0,o=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md)),o?o.start():o=be.md.sha1.create(),s||(s=o);var a=Math.ceil(t.n.bitLength()/8),c=a-2*o.digestLength-2;if(e.length>c){var f=new Error("RSAES-OAEP input message length is too long.");throw f.length=e.length,f.maxLength=c,f}n||(n=""),o.update(n,"raw");for(var u=o.digest(),l="",p=c-e.length,d=0;d<p;d++)l+="\0";var h=u.getBytes()+l+""+e;if(!i)i=be.random.getBytes(o.digestLength);else if(i.length!==o.digestLength){var f=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw f.seedLength=i.length,f.digestLength=o.digestLength,f}var y=Hn(i,a-o.digestLength-1,s),g=be.util.xorBytes(h,y,h.length),x=Hn(g,o.digestLength,s),m=be.util.xorBytes(i,x,i.length);return"\0"+m+g};g0.decode_rsa_oaep=function(t,e,r){var n,i,o;typeof r=="string"?(n=r,i=arguments[3]||void 0):r&&(n=r.label||void 0,i=r.md||void 0,r.mgf1&&r.mgf1.md&&(o=r.mgf1.md));var s=Math.ceil(t.n.bitLength()/8);if(e.length!==s){var g=new Error("RSAES-OAEP encoded message length is invalid.");throw g.length=e.length,g.expectedLength=s,g}if(i===void 0?i=be.md.sha1.create():i.start(),o||(o=i),s<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),i.update(n,"raw");for(var a=i.digest().getBytes(),c=e.charAt(0),f=e.substring(1,i.digestLength+1),u=e.substring(1+i.digestLength),l=Hn(u,i.digestLength,o),p=be.util.xorBytes(f,l,f.length),d=Hn(p,s-i.digestLength-1,o),h=be.util.xorBytes(u,d,u.length),y=h.substring(0,i.digestLength),g=c!=="\0",x=0;x<i.digestLength;++x)g|=a.charAt(x)!==y.charAt(x);for(var m=1,b=i.digestLength,_=i.digestLength;_<h.length;_++){var E=h.charCodeAt(_),S=E&1^1,L=m?65534:0;g|=E&L,m=m&S,b+=m}if(g||h.charCodeAt(b)!==1)throw new Error("Invalid RSAES-OAEP padding.");return h.substring(b+1)};function Hn(t,e,r){r||(r=be.md.sha1.create());for(var n="",i=Math.ceil(e/r.digestLength),o=0;o<i;++o){var s=String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,o&255);r.start(),r.update(t+s),n+=r.digest().getBytes()}return n.substring(0,e)}});var v0=ft((kg,bo)=>{var Ye=ct();Et();zn();fn();(function(){if(Ye.prime){bo.exports=Ye.prime;return}var t=bo.exports=Ye.prime=Ye.prime||{},e=Ye.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new e(null);n.fromInt(30);var i=function(l,p){return l|p};t.generateProbablePrime=function(l,p,d){typeof p=="function"&&(d=p,p={}),p=p||{};var h=p.algorithm||"PRIMEINC";typeof h=="string"&&(h={name:h}),h.options=h.options||{};var y=p.prng||Ye.random,g={nextBytes:function(x){for(var m=y.getBytesSync(x.length),b=0;b<x.length;++b)x[b]=m.charCodeAt(b)}};if(h.name==="PRIMEINC")return o(l,g,h.options,d);throw new Error("Invalid prime generation algorithm: "+h.name)};function o(l,p,d,h){return"workers"in d?c(l,p,d,h):s(l,p,d,h)}function s(l,p,d,h){var y=f(l,p),g=0,x=u(y.bitLength());"millerRabinTests"in d&&(x=d.millerRabinTests);var m=10;"maxBlockTime"in d&&(m=d.maxBlockTime),a(y,l,p,g,x,m,h)}function a(l,p,d,h,y,g,x){var m=+new Date;do{if(l.bitLength()>p&&(l=f(p,d)),l.isProbablePrime(y))return x(null,l);l.dAddOffset(r[h++%8],0)}while(g<0||+new Date-m<g);Ye.util.setImmediate(function(){a(l,p,d,h,y,g,x)})}function c(l,p,d,h){if(typeof Worker>"u")return s(l,p,d,h);var y=f(l,p),g=d.workers,x=d.workLoad||100,m=x*30/8,b=d.workerScript||"forge/prime.worker.js";if(g===-1)return Ye.util.estimateCores(function(E,S){E&&(S=2),g=S-1,_()});_();function _(){g=Math.max(1,g);for(var E=[],S=0;S<g;++S)E[S]=new Worker(b);for(var L=g,S=0;S<g;++S)E[S].addEventListener("message",z);var D=!1;function z(q){if(!D){--L;var M=q.data;if(M.found){for(var X=0;X<E.length;++X)E[X].terminate();return D=!0,h(null,new e(M.prime,16))}y.bitLength()>l&&(y=f(l,p));var at=y.toString(16);q.target.postMessage({hex:at,workLoad:x}),y.dAddOffset(m,0)}}}}function f(l,p){var d=new e(l,p),h=l-1;return d.testBit(h)||d.bitwiseTo(e.ONE.shiftLeft(h),i,d),d.dAddOffset(31-d.mod(n).byteValue(),0),d}function u(l){return l<=100?27:l<=150?18:l<=200?15:l<=250?12:l<=300?9:l<=350?8:l<=400?7:l<=500?6:l<=600?5:l<=800?4:l<=1250?3:2}})()});var Gn=ft((Ng,I0)=>{var F=ct();an();zn();Rn();m0();v0();fn();Et();typeof tt>"u"&&(tt=F.jsbn.BigInteger);var tt,wo=F.util.isNodejs?On():null,w=F.asn1,jt=F.util;F.pki=F.pki||{};I0.exports=F.pki.rsa=F.rsa=F.rsa||{};var H=F.pki,pd=[6,4,2,4,2,4,6,2],yd={name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},gd={name:"RSAPrivateKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},xd={name:"RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},md=F.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},vd={name:"DigestInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:w.Class.UNIVERSAL,type:w.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},bd=function(t){var e;if(t.algorithm in H.oids)e=H.oids[t.algorithm];else{var r=new Error("Unknown message digest algorithm.");throw r.algorithm=t.algorithm,r}var n=w.oidToDer(e).getBytes(),i=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]),o=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]);o.value.push(w.create(w.Class.UNIVERSAL,w.Type.OID,!1,n)),o.value.push(w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,""));var s=w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,t.digest().getBytes());return i.value.push(o),i.value.push(s),w.toDer(i).getBytes()},B0=function(t,e,r){if(r)return t.modPow(e.e,e.n);if(!e.p||!e.q)return t.modPow(e.d,e.n);e.dP||(e.dP=e.d.mod(e.p.subtract(tt.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(tt.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));var n;do n=new tt(F.util.bytesToHex(F.random.getBytes(e.n.bitLength()/8)),16);while(n.compareTo(e.n)>=0||!n.gcd(e.n).equals(tt.ONE));t=t.multiply(n.modPow(e.e,e.n)).mod(e.n);for(var i=t.mod(e.p).modPow(e.dP,e.p),o=t.mod(e.q).modPow(e.dQ,e.q);i.compareTo(o)<0;)i=i.add(e.p);var s=i.subtract(o).multiply(e.qInv).mod(e.p).multiply(e.q).add(o);return s=s.multiply(n.modInverse(e.n)).mod(e.n),s};H.rsa.encrypt=function(t,e,r){var n=r,i,o=Math.ceil(e.n.bitLength()/8);r!==!1&&r!==!0?(n=r===2,i=A0(t,e,r)):(i=F.util.createBuffer(),i.putBytes(t));for(var s=new tt(i.toHex(),16),a=B0(s,e,n),c=a.toString(16),f=F.util.createBuffer(),u=o-Math.ceil(c.length/2);u>0;)f.putByte(0),--u;return f.putBytes(F.util.hexToBytes(c)),f.getBytes()};H.rsa.decrypt=function(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var o=new Error("Encrypted message length is invalid.");throw o.length=t.length,o.expected=i,o}var s=new tt(F.util.createBuffer(t).toHex(),16);if(s.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var a=B0(s,e,r),c=a.toString(16),f=F.util.createBuffer(),u=i-Math.ceil(c.length/2);u>0;)f.putByte(0),--u;return f.putBytes(F.util.hexToBytes(c)),n!==!1?$n(f.getBytes(),e,r):f.getBytes()};H.rsa.createKeyPairGenerationState=function(t,e,r){typeof t=="string"&&(t=parseInt(t,10)),t=t||2048,r=r||{};var n=r.prng||F.random,i={nextBytes:function(a){for(var c=n.getBytesSync(a.length),f=0;f<a.length;++f)a[f]=c.charCodeAt(f)}},o=r.algorithm||"PRIMEINC",s;if(o==="PRIMEINC")s={algorithm:o,state:0,bits:t,rng:i,eInt:e||65537,e:new tt(null),p:null,q:null,qBits:t>>1,pBits:t-(t>>1),pqState:0,num:null,keys:null},s.e.fromInt(s.eInt);else throw new Error("Invalid key generation algorithm: "+o);return s};H.rsa.stepKeyPairGenerationState=function(t,e){"algorithm"in t||(t.algorithm="PRIMEINC");var r=new tt(null);r.fromInt(30);for(var n=0,i=function(l,p){return l|p},o=+new Date,s,a=0;t.keys===null&&(e<=0||a<e);){if(t.state===0){var c=t.p===null?t.pBits:t.qBits,f=c-1;t.pqState===0?(t.num=new tt(c,t.rng),t.num.testBit(f)||t.num.bitwiseTo(tt.ONE.shiftLeft(f),i,t.num),t.num.dAddOffset(31-t.num.mod(r).byteValue(),0),n=0,++t.pqState):t.pqState===1?t.num.bitLength()>c?t.pqState=0:t.num.isProbablePrime(Ed(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(pd[n++%8],0):t.pqState===2?t.pqState=t.num.subtract(tt.ONE).gcd(t.e).compareTo(tt.ONE)===0?3:0:t.pqState===3&&(t.pqState=0,t.p===null?t.p=t.num:t.q=t.num,t.p!==null&&t.q!==null&&++t.state,t.num=null)}else if(t.state===1)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(t.state===2)t.p1=t.p.subtract(tt.ONE),t.q1=t.q.subtract(tt.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(t.state===3)t.phi.gcd(t.e).compareTo(tt.ONE)===0?++t.state:(t.p=null,t.q=null,t.state=0);else if(t.state===4)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(t.state===5){var u=t.e.modInverse(t.phi);t.keys={privateKey:H.rsa.setPrivateKey(t.n,t.e,u,t.p,t.q,u.mod(t.p1),u.mod(t.q1),t.q.modInverse(t.p)),publicKey:H.rsa.setPublicKey(t.n,t.e)}}s=+new Date,a+=s-o,o=s}return t.keys!==null};H.rsa.generateKeyPair=function(t,e,r,n){if(arguments.length===1?typeof t=="object"?(r=t,t=void 0):typeof t=="function"&&(n=t,t=void 0):arguments.length===2?typeof t=="number"?typeof e=="function"?(n=e,e=void 0):typeof e!="number"&&(r=e,e=void 0):(r=t,n=e,t=void 0,e=void 0):arguments.length===3&&(typeof e=="number"?typeof r=="function"&&(n=r,r=void 0):(n=r,r=e,e=void 0)),r=r||{},t===void 0&&(t=r.bits||2048),e===void 0&&(e=r.e||65537),!F.options.usePureJavaScript&&!r.prng&&t>=256&&t<=16384&&(e===65537||e===3)){if(n){if(b0("generateKeyPair"))return wo.generateKeyPair("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(a,c,f){if(a)return n(a);n(null,{privateKey:H.privateKeyFromPem(f),publicKey:H.publicKeyFromPem(c)})});if(w0("generateKey")&&w0("exportKey"))return jt.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:S0(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(a){return jt.globalScope.crypto.subtle.exportKey("pkcs8",a.privateKey)}).then(void 0,function(a){n(a)}).then(function(a){if(a){var c=H.privateKeyFromAsn1(w.fromDer(F.util.createBuffer(a)));n(null,{privateKey:c,publicKey:H.setRsaPublicKey(c.n,c.e)})}});if(E0("generateKey")&&E0("exportKey")){var i=jt.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:S0(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);i.oncomplete=function(a){var c=a.target.result,f=jt.globalScope.msCrypto.subtle.exportKey("pkcs8",c.privateKey);f.oncomplete=function(u){var l=u.target.result,p=H.privateKeyFromAsn1(w.fromDer(F.util.createBuffer(l)));n(null,{privateKey:p,publicKey:H.setRsaPublicKey(p.n,p.e)})},f.onerror=function(u){n(u)}},i.onerror=function(a){n(a)};return}}else if(b0("generateKeyPairSync")){var o=wo.generateKeyPairSync("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:H.privateKeyFromPem(o.privateKey),publicKey:H.publicKeyFromPem(o.publicKey)}}}var s=H.rsa.createKeyPairGenerationState(t,e,r);if(!n)return H.rsa.stepKeyPairGenerationState(s,0),s.keys;wd(s,r,n)};H.setRsaPublicKey=H.rsa.setPublicKey=function(t,e){var r={n:t,e};return r.encrypt=function(n,i,o){if(typeof i=="string"?i=i.toUpperCase():i===void 0&&(i="RSAES-PKCS1-V1_5"),i==="RSAES-PKCS1-V1_5")i={encode:function(a,c,f){return A0(a,c,2).getBytes()}};else if(i==="RSA-OAEP"||i==="RSAES-OAEP")i={encode:function(a,c){return F.pkcs1.encode_rsa_oaep(c,a,o)}};else if(["RAW","NONE","NULL",null].indexOf(i)!==-1)i={encode:function(a){return a}};else if(typeof i=="string")throw new Error('Unsupported encryption scheme: "'+i+'".');var s=i.encode(n,r,!0);return H.rsa.encrypt(s,r,!0)},r.verify=function(n,i,o,s){typeof o=="string"?o=o.toUpperCase():o===void 0&&(o="RSASSA-PKCS1-V1_5"),s===void 0&&(s={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in s||(s._parseAllDigestBytes=!0),o==="RSASSA-PKCS1-V1_5"?o={verify:function(c,f){f=$n(f,r,!0);var u=w.fromDer(f,{parseAllBytes:s._parseAllDigestBytes}),l={},p=[];if(!w.validate(u,vd,l,p)){var d=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw d.errors=p,d}var h=w.derToOid(l.algorithmIdentifier);if(!(h===F.oids.md2||h===F.oids.md5||h===F.oids.sha1||h===F.oids.sha224||h===F.oids.sha256||h===F.oids.sha384||h===F.oids.sha512||h===F.oids["sha512-224"]||h===F.oids["sha512-256"])){var d=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw d.oid=h,d}if((h===F.oids.md2||h===F.oids.md5)&&!("parameters"in l))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return c===l.digest}}:(o==="NONE"||o==="NULL"||o===null)&&(o={verify:function(c,f){return f=$n(f,r,!0),c===f}});var a=H.rsa.decrypt(i,r,!0,!1);return o.verify(n,a,r.n.bitLength())},r};H.setRsaPrivateKey=H.rsa.setPrivateKey=function(t,e,r,n,i,o,s,a){var c={n:t,e,d:r,p:n,q:i,dP:o,dQ:s,qInv:a};return c.decrypt=function(f,u,l){typeof u=="string"?u=u.toUpperCase():u===void 0&&(u="RSAES-PKCS1-V1_5");var p=H.rsa.decrypt(f,c,!1,!1);if(u==="RSAES-PKCS1-V1_5")u={decode:$n};else if(u==="RSA-OAEP"||u==="RSAES-OAEP")u={decode:function(d,h){return F.pkcs1.decode_rsa_oaep(h,d,l)}};else if(["RAW","NONE","NULL",null].indexOf(u)!==-1)u={decode:function(d){return d}};else throw new Error('Unsupported encryption scheme: "'+u+'".');return u.decode(p,c,!1)},c.sign=function(f,u){var l=!1;typeof u=="string"&&(u=u.toUpperCase()),u===void 0||u==="RSASSA-PKCS1-V1_5"?(u={encode:bd},l=1):(u==="NONE"||u==="NULL"||u===null)&&(u={encode:function(){return f}},l=1);var p=u.encode(f,c.n.bitLength());return H.rsa.encrypt(p,c,l)},c};H.wrapRsaPrivateKey=function(t){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(H.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,w.toDer(t).getBytes())])};H.privateKeyFromAsn1=function(t){var e={},r=[];if(w.validate(t,yd,e,r)&&(t=w.fromDer(F.util.createBuffer(e.privateKey))),e={},r=[],!w.validate(t,gd,e,r)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=r,n}var i,o,s,a,c,f,u,l;return i=F.util.createBuffer(e.privateKeyModulus).toHex(),o=F.util.createBuffer(e.privateKeyPublicExponent).toHex(),s=F.util.createBuffer(e.privateKeyPrivateExponent).toHex(),a=F.util.createBuffer(e.privateKeyPrime1).toHex(),c=F.util.createBuffer(e.privateKeyPrime2).toHex(),f=F.util.createBuffer(e.privateKeyExponent1).toHex(),u=F.util.createBuffer(e.privateKeyExponent2).toHex(),l=F.util.createBuffer(e.privateKeyCoefficient).toHex(),H.setRsaPrivateKey(new tt(i,16),new tt(o,16),new tt(s,16),new tt(a,16),new tt(c,16),new tt(f,16),new tt(u,16),new tt(l,16))};H.privateKeyToAsn1=H.privateKeyToRSAPrivateKey=function(t){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.e)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.d)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.p)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.q)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.dP)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.dQ)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.qInv))])};H.publicKeyFromAsn1=function(t){var e={},r=[];if(w.validate(t,md,e,r)){var n=w.derToOid(e.publicKeyOid);if(n!==H.oids.rsaEncryption){var i=new Error("Cannot read public key. Unknown OID.");throw i.oid=n,i}t=e.rsaPublicKey}if(r=[],!w.validate(t,xd,e,r)){var i=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw i.errors=r,i}var o=F.util.createBuffer(e.publicKeyModulus).toHex(),s=F.util.createBuffer(e.publicKeyExponent).toHex();return H.setRsaPublicKey(new tt(o,16),new tt(s,16))};H.publicKeyToAsn1=H.publicKeyToSubjectPublicKeyInfo=function(t){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(H.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.BITSTRING,!1,[H.publicKeyToRSAPublicKey(t)])])};H.publicKeyToRSAPublicKey=function(t){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,we(t.e))])};function A0(t,e,r){var n=F.util.createBuffer(),i=Math.ceil(e.n.bitLength()/8);if(t.length>i-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=t.length,o.max=i-11,o}n.putByte(0),n.putByte(r);var s=i-3-t.length,a;if(r===0||r===1){a=r===0?0:255;for(var c=0;c<s;++c)n.putByte(a)}else for(;s>0;){for(var f=0,u=F.random.getBytes(s),c=0;c<s;++c)a=u.charCodeAt(c),a===0?++f:n.putByte(a);s=f}return n.putByte(0),n.putBytes(t),n}function $n(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8),o=F.util.createBuffer(t),s=o.getByte(),a=o.getByte();if(s!==0||r&&a!==0&&a!==1||!r&&a!=2||r&&a===0&&typeof n>"u")throw new Error("Encryption block is invalid.");var c=0;if(a===0){c=i-3-n;for(var f=0;f<c;++f)if(o.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(a===1)for(c=0;o.length()>1;){if(o.getByte()!==255){--o.read;break}++c}else if(a===2)for(c=0;o.length()>1;){if(o.getByte()===0){--o.read;break}++c}var u=o.getByte();if(u!==0||c!==i-3-o.length())throw new Error("Encryption block is invalid.");return o.getBytes()}function wd(t,e,r){typeof e=="function"&&(r=e,e={}),e=e||{};var n={algorithm:{name:e.algorithm||"PRIMEINC",options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};"prng"in e&&(n.prng=e.prng),i();function i(){o(t.pBits,function(a,c){if(a)return r(a);if(t.p=c,t.q!==null)return s(a,t.q);o(t.qBits,s)})}function o(a,c){F.prime.generateProbablePrime(a,n,c)}function s(a,c){if(a)return r(a);if(t.q=c,t.p.compareTo(t.q)<0){var f=t.p;t.p=t.q,t.q=f}if(t.p.subtract(tt.ONE).gcd(t.e).compareTo(tt.ONE)!==0){t.p=null,i();return}if(t.q.subtract(tt.ONE).gcd(t.e).compareTo(tt.ONE)!==0){t.q=null,o(t.qBits,s);return}if(t.p1=t.p.subtract(tt.ONE),t.q1=t.q.subtract(tt.ONE),t.phi=t.p1.multiply(t.q1),t.phi.gcd(t.e).compareTo(tt.ONE)!==0){t.p=t.q=null,i();return}if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits){t.q=null,o(t.qBits,s);return}var u=t.e.modInverse(t.phi);t.keys={privateKey:H.rsa.setPrivateKey(t.n,t.e,u,t.p,t.q,u.mod(t.p1),u.mod(t.q1),t.q.modInverse(t.p)),publicKey:H.rsa.setPublicKey(t.n,t.e)},r(null,t.keys)}}function we(t){var e=t.toString(16);e[0]>="8"&&(e="00"+e);var r=F.util.hexToBytes(e);return r.length>1&&(r.charCodeAt(0)===0&&!(r.charCodeAt(1)&128)||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)===128)?r.substr(1):r}function Ed(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}function b0(t){return F.util.isNodejs&&typeof wo[t]=="function"}function w0(t){return typeof jt.globalScope<"u"&&typeof jt.globalScope.crypto=="object"&&typeof jt.globalScope.crypto.subtle=="object"&&typeof jt.globalScope.crypto.subtle[t]=="function"}function E0(t){return typeof jt.globalScope<"u"&&typeof jt.globalScope.msCrypto=="object"&&typeof jt.globalScope.msCrypto.subtle=="object"&&typeof jt.globalScope.msCrypto.subtle[t]=="function"}function S0(t){for(var e=F.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}});var D0=ft((Ug,L0)=>{var U=ct();lo();an();Ua();cr();Rn();Va();Ha();fn();r0();Gn();Et();typeof T0>"u"&&(T0=U.jsbn.BigInteger);var T0,B=U.asn1,G=U.pki=U.pki||{};L0.exports=G.pbe=U.pbe=U.pbe||{};var hr=G.oids,Sd={name:"EncryptedPrivateKeyInfo",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:B.Class.UNIVERSAL,type:B.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:B.Class.UNIVERSAL,type:B.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},Bd={name:"PBES2Algorithms",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:B.Class.UNIVERSAL,type:B.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:B.Class.UNIVERSAL,type:B.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:B.Class.UNIVERSAL,type:B.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:B.Class.UNIVERSAL,type:B.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:B.Class.UNIVERSAL,type:B.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:B.Class.UNIVERSAL,type:B.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:B.Class.UNIVERSAL,type:B.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},Ad={name:"pkcs-12PbeParams",tagClass:B.Class.UNIVERSAL,type:B.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:B.Class.UNIVERSAL,type:B.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:B.Class.UNIVERSAL,type:B.Type.INTEGER,constructed:!1,capture:"iterations"}]};G.encryptPrivateKeyInfo=function(t,e,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n=U.random.getBytesSync(r.saltSize),i=r.count,o=B.integerToDer(i),s,a,c;if(r.algorithm.indexOf("aes")===0||r.algorithm==="des"){var f,u,l;switch(r.algorithm){case"aes128":s=16,f=16,u=hr["aes128-CBC"],l=U.aes.createEncryptionCipher;break;case"aes192":s=24,f=16,u=hr["aes192-CBC"],l=U.aes.createEncryptionCipher;break;case"aes256":s=32,f=16,u=hr["aes256-CBC"],l=U.aes.createEncryptionCipher;break;case"des":s=8,f=8,u=hr.desCBC,l=U.des.createEncryptionCipher;break;default:var p=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw p.algorithm=r.algorithm,p}var d="hmacWith"+r.prfAlgorithm.toUpperCase(),h=R0(d),y=U.pkcs5.pbkdf2(e,n,i,s,h),g=U.random.getBytesSync(f),x=l(y);x.start(g),x.update(B.toDer(t)),x.finish(),c=x.output.getBytes();var m=Id(n,o,s,d);a=B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(hr.pkcs5PBES2).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(hr.pkcs5PBKDF2).getBytes()),m]),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(u).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,g)])])])}else if(r.algorithm==="3des"){s=24;var b=new U.util.ByteBuffer(n),y=G.pbe.generatePkcs12Key(e,b,1,i,s),g=G.pbe.generatePkcs12Key(e,b,2,i,s),x=U.des.createEncryptionCipher(y);x.start(g),x.update(B.toDer(t)),x.finish(),c=x.output.getBytes(),a=B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(hr["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,n),B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,o.getBytes())])])}else{var p=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw p.algorithm=r.algorithm,p}var _=B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[a,B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,c)]);return _};G.decryptPrivateKeyInfo=function(t,e){var r=null,n={},i=[];if(!B.validate(t,Sd,n,i)){var o=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=i,o}var s=B.derToOid(n.encryptionOid),a=G.pbe.getCipher(s,n.encryptionParams,e),c=U.util.createBuffer(n.encryptedData);return a.update(c),a.finish()&&(r=B.fromDer(a.output)),r};G.encryptedPrivateKeyToPem=function(t,e){var r={type:"ENCRYPTED PRIVATE KEY",body:B.toDer(t).getBytes()};return U.pem.encode(r,{maxline:e})};G.encryptedPrivateKeyFromPem=function(t){var e=U.pem.decode(t)[0];if(e.type!=="ENCRYPTED PRIVATE KEY"){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return B.fromDer(e.body)};G.encryptRsaPrivateKey=function(t,e,r){if(r=r||{},!r.legacy){var n=G.wrapRsaPrivateKey(G.privateKeyToAsn1(t));return n=G.encryptPrivateKeyInfo(n,e,r),G.encryptedPrivateKeyToPem(n)}var i,o,s,a;switch(r.algorithm){case"aes128":i="AES-128-CBC",s=16,o=U.random.getBytesSync(16),a=U.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",s=24,o=U.random.getBytesSync(16),a=U.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",s=32,o=U.random.getBytesSync(16),a=U.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",s=24,o=U.random.getBytesSync(8),a=U.des.createEncryptionCipher;break;case"des":i="DES-CBC",s=8,o=U.random.getBytesSync(8),a=U.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var f=U.pbe.opensslDeriveBytes(e,o.substr(0,8),s),u=a(f);u.start(o),u.update(B.toDer(G.privateKeyToAsn1(t))),u.finish();var l={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:U.util.bytesToHex(o).toUpperCase()},body:u.output.getBytes()};return U.pem.encode(l)};G.decryptRsaPrivateKey=function(t,e){var r=null,n=U.pem.decode(t)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var i=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw i.headerType=i,i}if(n.procType&&n.procType.type==="ENCRYPTED"){var o,s;switch(n.dekInfo.algorithm){case"DES-CBC":o=8,s=U.des.createDecryptionCipher;break;case"DES-EDE3-CBC":o=24,s=U.des.createDecryptionCipher;break;case"AES-128-CBC":o=16,s=U.aes.createDecryptionCipher;break;case"AES-192-CBC":o=24,s=U.aes.createDecryptionCipher;break;case"AES-256-CBC":o=32,s=U.aes.createDecryptionCipher;break;case"RC2-40-CBC":o=5,s=function(l){return U.rc2.createDecryptionCipher(l,40)};break;case"RC2-64-CBC":o=8,s=function(l){return U.rc2.createDecryptionCipher(l,64)};break;case"RC2-128-CBC":o=16,s=function(l){return U.rc2.createDecryptionCipher(l,128)};break;default:var i=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw i.algorithm=n.dekInfo.algorithm,i}var a=U.util.hexToBytes(n.dekInfo.parameters),c=U.pbe.opensslDeriveBytes(e,a.substr(0,8),o),f=s(c);if(f.start(a),f.update(U.util.createBuffer(n.body)),f.finish())r=f.output.getBytes();else return r}else r=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?r=G.decryptPrivateKeyInfo(B.fromDer(r),e):r=B.fromDer(r),r!==null&&(r=G.privateKeyFromAsn1(r)),r};G.pbe.generatePkcs12Key=function(t,e,r,n,i,o){var s,a;if(typeof o>"u"||o===null){if(!("sha1"in U.md))throw new Error('"sha1" hash algorithm unavailable.');o=U.md.sha1.create()}var c=o.digestLength,f=o.blockLength,u=new U.util.ByteBuffer,l=new U.util.ByteBuffer;if(t!=null){for(a=0;a<t.length;a++)l.putInt16(t.charCodeAt(a));l.putInt16(0)}var p=l.length(),d=e.length(),h=new U.util.ByteBuffer;h.fillWithByte(r,f);var y=f*Math.ceil(d/f),g=new U.util.ByteBuffer;for(a=0;a<y;a++)g.putByte(e.at(a%d));var x=f*Math.ceil(p/f),m=new U.util.ByteBuffer;for(a=0;a<x;a++)m.putByte(l.at(a%p));var b=g;b.putBuffer(m);for(var _=Math.ceil(i/c),E=1;E<=_;E++){var S=new U.util.ByteBuffer;S.putBytes(h.bytes()),S.putBytes(b.bytes());for(var L=0;L<n;L++)o.start(),o.update(S.getBytes()),S=o.digest();var D=new U.util.ByteBuffer;for(a=0;a<f;a++)D.putByte(S.at(a%c));var z=Math.ceil(d/f)+Math.ceil(p/f),q=new U.util.ByteBuffer;for(s=0;s<z;s++){var M=new U.util.ByteBuffer(b.getBytes(f)),X=511;for(a=D.length()-1;a>=0;a--)X=X>>8,X+=D.at(a)+M.at(a),M.setAt(a,X&255);q.putBuffer(M)}b=q,u.putBuffer(S)}return u.truncate(u.length()-i),u};G.pbe.getCipher=function(t,e,r){switch(t){case G.oids.pkcs5PBES2:return G.pbe.getCipherForPBES2(t,e,r);case G.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case G.oids["pbewithSHAAnd40BitRC2-CBC"]:return G.pbe.getCipherForPKCS12PBE(t,e,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=t,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};G.pbe.getCipherForPBES2=function(t,e,r){var n={},i=[];if(!B.validate(e,Bd,n,i)){var o=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=i,o}if(t=B.derToOid(n.kdfOid),t!==G.oids.pkcs5PBKDF2){var o=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw o.oid=t,o.supportedOids=["pkcs5PBKDF2"],o}if(t=B.derToOid(n.encOid),t!==G.oids["aes128-CBC"]&&t!==G.oids["aes192-CBC"]&&t!==G.oids["aes256-CBC"]&&t!==G.oids["des-EDE3-CBC"]&&t!==G.oids.desCBC){var o=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw o.oid=t,o.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],o}var s=n.kdfSalt,a=U.util.createBuffer(n.kdfIterationCount);a=a.getInt(a.length()<<3);var c,f;switch(G.oids[t]){case"aes128-CBC":c=16,f=U.aes.createDecryptionCipher;break;case"aes192-CBC":c=24,f=U.aes.createDecryptionCipher;break;case"aes256-CBC":c=32,f=U.aes.createDecryptionCipher;break;case"des-EDE3-CBC":c=24,f=U.des.createDecryptionCipher;break;case"desCBC":c=8,f=U.des.createDecryptionCipher;break}var u=_0(n.prfOid),l=U.pkcs5.pbkdf2(r,s,a,c,u),p=n.encIv,d=f(l);return d.start(p),d};G.pbe.getCipherForPKCS12PBE=function(t,e,r){var n={},i=[];if(!B.validate(e,Ad,n,i)){var o=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw o.errors=i,o}var s=U.util.createBuffer(n.salt),a=U.util.createBuffer(n.iterations);a=a.getInt(a.length()<<3);var c,f,u;switch(t){case G.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,f=8,u=U.des.startDecrypting;break;case G.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,f=8,u=function(y,g){var x=U.rc2.createDecryptionCipher(y,40);return x.start(g,null),x};break;default:var o=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw o.oid=t,o}var l=_0(n.prfOid),p=G.pbe.generatePkcs12Key(r,s,1,a,c,l);l.start();var d=G.pbe.generatePkcs12Key(r,s,2,a,f,l);return u(p,d)};G.pbe.opensslDeriveBytes=function(t,e,r,n){if(typeof n>"u"||n===null){if(!("md5"in U.md))throw new Error('"md5" hash algorithm unavailable.');n=U.md.md5.create()}e===null&&(e="");for(var i=[C0(n,t+e)],o=16,s=1;o<r;++s,o+=16)i.push(C0(n,i[s-1]+t+e));return i.join("").substr(0,r)};function C0(t,e){return t.start().update(e).digest().getBytes()}function _0(t){var e;if(!t)e="hmacWithSHA1";else if(e=G.oids[B.derToOid(t)],!e){var r=new Error("Unsupported PRF OID.");throw r.oid=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}return R0(e)}function R0(t){var e=U.md;switch(t){case"hmacWithSHA224":e=U.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":t=t.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!e||!(t in e))throw new Error("Unknown hash algorithm: "+t);return e[t].create()}function Id(t,e,r,n){var i=B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OCTETSTRING,!1,t),B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,e.getBytes())]);return n!=="hmacWithSHA1"&&i.value.push(B.create(B.Class.UNIVERSAL,B.Type.INTEGER,!1,U.util.hexToBytes(r.toString(16))),B.create(B.Class.UNIVERSAL,B.Type.SEQUENCE,!0,[B.create(B.Class.UNIVERSAL,B.Type.OID,!1,B.oidToDer(G.oids[n]).getBytes()),B.create(B.Class.UNIVERSAL,B.Type.NULL,!1,"")])),i}});var Ef=ft((tv,wf)=>{var pt=ct();cr();Et();var xn=wf.exports=pt.sha512=pt.sha512||{};pt.md.sha512=pt.md.algorithms.sha512=xn;var vf=pt.sha384=pt.sha512.sha384=pt.sha512.sha384||{};vf.create=function(){return xn.create("SHA-384")};pt.md.sha384=pt.md.algorithms.sha384=vf;pt.sha512.sha256=pt.sha512.sha256||{create:function(){return xn.create("SHA-512/256")}};pt.md["sha512/256"]=pt.md.algorithms["sha512/256"]=pt.sha512.sha256;pt.sha512.sha224=pt.sha512.sha224||{create:function(){return xn.create("SHA-512/224")}};pt.md["sha512/224"]=pt.md.algorithms["sha512/224"]=pt.sha512.sha224;xn.create=function(t){if(bf||Wp(),typeof t>"u"&&(t="SHA-512"),!(t in vr))throw new Error("Invalid SHA-512 algorithm: "+t);for(var e=vr[t],r=null,n=pt.util.createBuffer(),i=new Array(80),o=0;o<80;++o)i[o]=new Array(2);var s=64;switch(t){case"SHA-384":s=48;break;case"SHA-512/256":s=32;break;case"SHA-512/224":s=28;break}var a={algorithm:t.replace("-","").toLowerCase(),blockLength:128,digestLength:s,messageLength:0,fullMessageLength:null,messageLengthSize:16};return a.start=function(){a.messageLength=0,a.fullMessageLength=a.messageLength128=[];for(var c=a.messageLengthSize/4,f=0;f<c;++f)a.fullMessageLength.push(0);n=pt.util.createBuffer(),r=new Array(e.length);for(var f=0;f<e.length;++f)r[f]=e[f].slice(0);return a},a.start(),a.update=function(c,f){f==="utf8"&&(c=pt.util.encodeUtf8(c));var u=c.length;a.messageLength+=u,u=[u/4294967296>>>0,u>>>0];for(var l=a.fullMessageLength.length-1;l>=0;--l)a.fullMessageLength[l]+=u[1],u[1]=u[0]+(a.fullMessageLength[l]/4294967296>>>0),a.fullMessageLength[l]=a.fullMessageLength[l]>>>0,u[0]=u[1]/4294967296>>>0;return n.putBytes(c),mf(r,i,n),(n.read>2048||n.length()===0)&&n.compact(),a},a.digest=function(){var c=pt.util.createBuffer();c.putBytes(n.bytes());var f=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize,u=f&a.blockLength-1;c.putBytes(ts.substr(0,a.blockLength-u));for(var l,p,d=a.fullMessageLength[0]*8,h=0;h<a.fullMessageLength.length-1;++h)l=a.fullMessageLength[h+1]*8,p=l/4294967296>>>0,d+=p,c.putInt32(d>>>0),d=l>>>0;c.putInt32(d);for(var y=new Array(r.length),h=0;h<r.length;++h)y[h]=r[h].slice(0);mf(y,i,c);var g=pt.util.createBuffer(),x;t==="SHA-512"?x=y.length:t==="SHA-384"?x=y.length-2:x=y.length-4;for(var h=0;h<x;++h)g.putInt32(y[h][0]),(h!==x-1||t!=="SHA-512/224")&&g.putInt32(y[h][1]);return g},a};var ts=null,bf=!1,es=null,vr=null;function Wp(){ts="\x80",ts+=pt.util.fillString("\0",128),es=[[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]],vr={},vr["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],vr["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],vr["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],vr["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],bf=!0}function mf(t,e,r){for(var n,i,o,s,a,c,f,u,l,p,d,h,y,g,x,m,b,_,E,S,L,D,z,q,M,X,at,kt,T,k,R,P,A,O,K,V=r.length();V>=128;){for(T=0;T<16;++T)e[T][0]=r.getInt32()>>>0,e[T][1]=r.getInt32()>>>0;for(;T<80;++T)P=e[T-2],k=P[0],R=P[1],n=((k>>>19|R<<13)^(R>>>29|k<<3)^k>>>6)>>>0,i=((k<<13|R>>>19)^(R<<3|k>>>29)^(k<<26|R>>>6))>>>0,O=e[T-15],k=O[0],R=O[1],o=((k>>>1|R<<31)^(k>>>8|R<<24)^k>>>7)>>>0,s=((k<<31|R>>>1)^(k<<24|R>>>8)^(k<<25|R>>>7))>>>0,A=e[T-7],K=e[T-16],R=i+A[1]+s+K[1],e[T][0]=n+A[0]+o+K[0]+(R/4294967296>>>0)>>>0,e[T][1]=R>>>0;for(y=t[0][0],g=t[0][1],x=t[1][0],m=t[1][1],b=t[2][0],_=t[2][1],E=t[3][0],S=t[3][1],L=t[4][0],D=t[4][1],z=t[5][0],q=t[5][1],M=t[6][0],X=t[6][1],at=t[7][0],kt=t[7][1],T=0;T<80;++T)f=((L>>>14|D<<18)^(L>>>18|D<<14)^(D>>>9|L<<23))>>>0,u=((L<<18|D>>>14)^(L<<14|D>>>18)^(D<<23|L>>>9))>>>0,l=(M^L&(z^M))>>>0,p=(X^D&(q^X))>>>0,a=((y>>>28|g<<4)^(g>>>2|y<<30)^(g>>>7|y<<25))>>>0,c=((y<<4|g>>>28)^(g<<30|y>>>2)^(g<<25|y>>>7))>>>0,d=(y&x|b&(y^x))>>>0,h=(g&m|_&(g^m))>>>0,R=kt+u+p+es[T][1]+e[T][1],n=at+f+l+es[T][0]+e[T][0]+(R/4294967296>>>0)>>>0,i=R>>>0,R=c+h,o=a+d+(R/4294967296>>>0)>>>0,s=R>>>0,at=M,kt=X,M=z,X=q,z=L,q=D,R=S+i,L=E+n+(R/4294967296>>>0)>>>0,D=R>>>0,E=b,S=_,b=x,_=m,x=y,m=g,R=i+s,y=n+o+(R/4294967296>>>0)>>>0,g=R>>>0;R=t[0][1]+g,t[0][0]=t[0][0]+y+(R/4294967296>>>0)>>>0,t[0][1]=R>>>0,R=t[1][1]+m,t[1][0]=t[1][0]+x+(R/4294967296>>>0)>>>0,t[1][1]=R>>>0,R=t[2][1]+_,t[2][0]=t[2][0]+b+(R/4294967296>>>0)>>>0,t[2][1]=R>>>0,R=t[3][1]+S,t[3][0]=t[3][0]+E+(R/4294967296>>>0)>>>0,t[3][1]=R>>>0,R=t[4][1]+D,t[4][0]=t[4][0]+L+(R/4294967296>>>0)>>>0,t[4][1]=R>>>0,R=t[5][1]+q,t[5][0]=t[5][0]+z+(R/4294967296>>>0)>>>0,t[5][1]=R>>>0,R=t[6][1]+X,t[6][0]=t[6][0]+M+(R/4294967296>>>0)>>>0,t[6][1]=R>>>0,R=t[7][1]+kt,t[7][0]=t[7][0]+at+(R/4294967296>>>0)>>>0,t[7][1]=R>>>0,V-=128}}});var mc=ft((ew,xc)=>{"use strict";function gc(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function X1(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=""),e&&(r.code=e);try{return gc(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(t)),gc(new i,r)}}xc.exports=X1});var Bc=ft(Bn=>{(function(){var t,e,r,n,i,o,s,a;a=function(c){var f,u,l,p;return f=(c&255<<24)>>>24,u=(c&255<<16)>>>16,l=(c&65280)>>>8,p=c&255,[f,u,l,p].join(".")},s=function(c){var f,u,l,p,d,h;for(f=[],l=p=0;p<=3&&c.length!==0;l=++p){if(l>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}h=e(c),d=h[0],u=h[1],c=c.substring(u),f.push(d)}if(c.length!==0)throw new Error("Invalid IP");switch(f.length){case 1:if(f[0]>4294967295)throw new Error("Invalid IP");return f[0]>>>0;case 2:if(f[0]>255||f[1]>16777215)throw new Error("Invalid IP");return(f[0]<<24|f[1])>>>0;case 3:if(f[0]>255||f[1]>255||f[2]>65535)throw new Error("Invalid IP");return(f[0]<<24|f[1]<<16|f[2])>>>0;case 4:if(f[0]>255||f[1]>255||f[2]>255||f[3]>255)throw new Error("Invalid IP");return(f[0]<<24|f[1]<<16|f[2]<<8|f[3])>>>0;default:throw new Error("Invalid IP")}},r=function(c){return c.charCodeAt(0)},n=r("0"),o=r("a"),i=r("A"),e=function(c){var f,u,l,p,d;for(p=0,f=10,u="9",l=0,c.length>1&&c[l]==="0"&&(c[l+1]==="x"||c[l+1]==="X"?(l+=2,f=16):"0"<=c[l+1]&&c[l+1]<="9"&&(l++,f=8,u="7")),d=l;l<c.length;){if("0"<=c[l]&&c[l]<=u)p=p*f+(r(c[l])-n)>>>0;else if(f===16)if("a"<=c[l]&&c[l]<="f")p=p*f+(10+r(c[l])-o)>>>0;else if("A"<=c[l]&&c[l]<="F")p=p*f+(10+r(c[l])-i)>>>0;else break;else break;if(p>4294967295)throw new Error("too large");l++}if(l===d)throw new Error("empty octet");return[p,l]},t=function(){function c(f,u){var l,p,d,h;if(typeof f!="string")throw new Error("Missing `net' parameter");if(u||(h=f.split("/",2),f=h[0],u=h[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=s(u)}catch(y){throw l=y,new Error("Invalid mask: "+u)}for(p=d=32;d>=0;p=--d)if(this.maskLong===4294967295<<32-p>>>0){this.bitmask=p;break}}else if(u||u===0)this.bitmask=parseInt(u,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(f)&this.maskLong)>>>0}catch(y){throw l=y,new Error("Invalid net address: "+f)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(f){return typeof f=="string"&&(f.indexOf("/")>0||f.split(".").length!==4)&&(f=new c(f)),f instanceof c?this.contains(f.base)&&this.contains(f.broadcast||f.last):(s(f)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(f){return f==null&&(f=1),new c(a(this.netLong+this.size*f),this.mask)},c.prototype.forEach=function(f){var u,l,p;for(p=s(this.first),l=s(this.last),u=0;p<=l;)f(a(p),p,u),u++,p++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),Bn.ip2long=s,Bn.long2ip=a,Bn.Netmask=t}).call(Bn)});var Cc=ft((Tc,Ai)=>{(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 c(d,h){if(d.indexOf("::")!==d.lastIndexOf("::"))return null;let y=0,g=-1,x=(d.match(a.zoneIndex)||[])[0],m,b;for(x&&(x=x.substring(1),d=d.replace(/%.+$/,""));(g=d.indexOf(":",g+1))>=0;)y++;if(d.substr(0,2)==="::"&&y--,d.substr(-2,2)==="::"&&y--,y>h)return null;for(b=h-y,m=":";b--;)m+="0:";return d=d.replace("::",m),d[0]===":"&&(d=d.slice(1)),d[d.length-1]===":"&&(d=d.slice(0,-1)),h=function(){let _=d.split(":"),E=[];for(let S=0;S<_.length;S++)E.push(parseInt(_[S],16));return E}(),{parts:h,zoneId:x}}function f(d,h,y,g){if(d.length!==h.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let x=0,m;for(;g>0;){if(m=y-g,m<0&&(m=0),d[x]>>m!==h[x]>>m)return!1;g-=y,x+=1}return!0}function u(d){if(i.test(d))return parseInt(d,16);if(d[0]==="0"&&!isNaN(parseInt(d[1],10))){if(n.test(d))return parseInt(d,8);throw new Error(`ipaddr: cannot parse ${d} as octal`)}return parseInt(d,10)}function l(d,h){for(;d.length<h;)d=`0${d}`;return d}let p={};p.IPv4=function(){function d(h){if(h.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let y,g;for(y=0;y<h.length;y++)if(g=h[y],!(0<=g&&g<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=h}return d.prototype.SpecialRanges={unspecified:[[new d([0,0,0,0]),8]],broadcast:[[new d([255,255,255,255]),32]],multicast:[[new d([224,0,0,0]),4]],linkLocal:[[new d([169,254,0,0]),16]],loopback:[[new d([127,0,0,0]),8]],carrierGradeNat:[[new d([100,64,0,0]),10]],private:[[new d([10,0,0,0]),8],[new d([172,16,0,0]),12],[new d([192,168,0,0]),16]],reserved:[[new d([192,0,0,0]),24],[new d([192,0,2,0]),24],[new d([192,88,99,0]),24],[new d([198,18,0,0]),15],[new d([198,51,100,0]),24],[new d([203,0,113,0]),24],[new d([240,0,0,0]),4]]},d.prototype.kind=function(){return"ipv4"},d.prototype.match=function(h,y){let g;if(y===void 0&&(g=h,h=g[0],y=g[1]),h.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,h.octets,8,y)},d.prototype.prefixLengthFromSubnetMask=function(){let h=0,y=!1,g={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},x,m,b;for(x=3;x>=0;x-=1)if(m=this.octets[x],m in g){if(b=g[m],y&&b!==0)return null;b!==8&&(y=!0),h+=b}else return null;return 32-h},d.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},d.prototype.toByteArray=function(){return this.octets.slice(0)},d.prototype.toIPv4MappedAddress=function(){return p.IPv6.parse(`::ffff:${this.toString()}`)},d.prototype.toNormalizedString=function(){return this.toString()},d.prototype.toString=function(){return this.octets.join(".")},d}(),p.IPv4.broadcastAddressFromCIDR=function(d){try{let h=this.parseCIDR(d),y=h[0].toByteArray(),g=this.subnetMaskFromPrefixLength(h[1]).toByteArray(),x=[],m=0;for(;m<4;)x.push(parseInt(y[m],10)|parseInt(g[m],10)^255),m++;return new this(x)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},p.IPv4.isIPv4=function(d){return this.parser(d)!==null},p.IPv4.isValid=function(d){try{return new this(this.parser(d)),!0}catch{return!1}},p.IPv4.isValidFourPartDecimal=function(d){return!!(p.IPv4.isValid(d)&&d.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},p.IPv4.networkAddressFromCIDR=function(d){let h,y,g,x,m;try{for(h=this.parseCIDR(d),g=h[0].toByteArray(),m=this.subnetMaskFromPrefixLength(h[1]).toByteArray(),x=[],y=0;y<4;)x.push(parseInt(g[y],10)&parseInt(m[y],10)),y++;return new this(x)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},p.IPv4.parse=function(d){let h=this.parser(d);if(h===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(h)},p.IPv4.parseCIDR=function(d){let h;if(h=d.match(/^(.+)\/(\d+)$/)){let y=parseInt(h[2]);if(y>=0&&y<=32){let g=[this.parse(h[1]),y];return Object.defineProperty(g,"toString",{value:function(){return this.join("/")}}),g}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},p.IPv4.parser=function(d){let h,y,g;if(h=d.match(r.fourOctet))return function(){let x=h.slice(1,6),m=[];for(let b=0;b<x.length;b++)y=x[b],m.push(u(y));return m}();if(h=d.match(r.longValue)){if(g=u(h[1]),g>4294967295||g<0)throw new Error("ipaddr: address outside defined range");return function(){let x=[],m;for(m=0;m<=24;m+=8)x.push(g>>m&255);return x}().reverse()}else return(h=d.match(r.twoOctet))?function(){let x=h.slice(1,4),m=[];if(g=u(x[1]),g>16777215||g<0)throw new Error("ipaddr: address outside defined range");return m.push(u(x[0])),m.push(g>>16&255),m.push(g>>8&255),m.push(g&255),m}():(h=d.match(r.threeOctet))?function(){let x=h.slice(1,5),m=[];if(g=u(x[2]),g>65535||g<0)throw new Error("ipaddr: address outside defined range");return m.push(u(x[0])),m.push(u(x[1])),m.push(g>>8&255),m.push(g&255),m}():null},p.IPv4.subnetMaskFromPrefixLength=function(d){if(d=parseInt(d),d<0||d>32)throw new Error("ipaddr: invalid IPv4 prefix length");let h=[0,0,0,0],y=0,g=Math.floor(d/8);for(;y<g;)h[y]=255,y++;return g<4&&(h[g]=Math.pow(2,d%8)-1<<8-d%8),new this(h)},p.IPv6=function(){function d(h,y){let g,x;if(h.length===16)for(this.parts=[],g=0;g<=14;g+=2)this.parts.push(h[g]<<8|h[g+1]);else if(h.length===8)this.parts=h;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(g=0;g<this.parts.length;g++)if(x=this.parts[g],!(0<=x&&x<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");y&&(this.zoneId=y)}return d.prototype.SpecialRanges={unspecified:[new d([0,0,0,0,0,0,0,0]),128],linkLocal:[new d([65152,0,0,0,0,0,0,0]),10],multicast:[new d([65280,0,0,0,0,0,0,0]),8],loopback:[new d([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new d([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new d([0,0,0,0,0,65535,0,0]),96],rfc6145:[new d([0,0,0,0,65535,0,0,0]),96],rfc6052:[new d([100,65435,0,0,0,0,0,0]),96],"6to4":[new d([8194,0,0,0,0,0,0,0]),16],teredo:[new d([8193,0,0,0,0,0,0,0]),32],reserved:[[new d([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new d([8193,2,0,0,0,0,0,0]),48],amt:[new d([8193,3,0,0,0,0,0,0]),32],as112v6:[new d([8193,4,274,0,0,0,0,0]),48],deprecated:[new d([8193,16,0,0,0,0,0,0]),28],orchid2:[new d([8193,32,0,0,0,0,0,0]),28]},d.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},d.prototype.kind=function(){return"ipv6"},d.prototype.match=function(h,y){let g;if(y===void 0&&(g=h,h=g[0],y=g[1]),h.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,h.parts,16,y)},d.prototype.prefixLengthFromSubnetMask=function(){let h=0,y=!1,g={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},x,m;for(let b=7;b>=0;b-=1)if(x=this.parts[b],x in g){if(m=g[x],y&&m!==0)return null;m!==16&&(y=!0),h+=m}else return null;return 128-h},d.prototype.range=function(){return p.subnetMatch(this,this.SpecialRanges)},d.prototype.toByteArray=function(){let h,y=[],g=this.parts;for(let x=0;x<g.length;x++)h=g[x],y.push(h>>8),y.push(h&255);return y},d.prototype.toFixedLengthString=function(){let h=function(){let g=[];for(let x=0;x<this.parts.length;x++)g.push(l(this.parts[x].toString(16),4));return g}.call(this).join(":"),y="";return this.zoneId&&(y=`%${this.zoneId}`),h+y},d.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let h=this.parts.slice(-2),y=h[0],g=h[1];return new p.IPv4([y>>8,y&255,g>>8,g&255])},d.prototype.toNormalizedString=function(){let h=function(){let g=[];for(let x=0;x<this.parts.length;x++)g.push(this.parts[x].toString(16));return g}.call(this).join(":"),y="";return this.zoneId&&(y=`%${this.zoneId}`),h+y},d.prototype.toRFC5952String=function(){let h=/((^|:)(0(:|$)){2,})/g,y=this.toNormalizedString(),g=0,x=-1,m;for(;m=h.exec(y);)m[0].length>x&&(g=m.index,x=m[0].length);return x<0?y:`${y.substring(0,g)}::${y.substring(g+x)}`},d.prototype.toString=function(){return this.toRFC5952String()},d}(),p.IPv6.broadcastAddressFromCIDR=function(d){try{let h=this.parseCIDR(d),y=h[0].toByteArray(),g=this.subnetMaskFromPrefixLength(h[1]).toByteArray(),x=[],m=0;for(;m<16;)x.push(parseInt(y[m],10)|parseInt(g[m],10)^255),m++;return new this(x)}catch(h){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${h})`)}},p.IPv6.isIPv6=function(d){return this.parser(d)!==null},p.IPv6.isValid=function(d){if(typeof d=="string"&&d.indexOf(":")===-1)return!1;try{let h=this.parser(d);return new this(h.parts,h.zoneId),!0}catch{return!1}},p.IPv6.networkAddressFromCIDR=function(d){let h,y,g,x,m;try{for(h=this.parseCIDR(d),g=h[0].toByteArray(),m=this.subnetMaskFromPrefixLength(h[1]).toByteArray(),x=[],y=0;y<16;)x.push(parseInt(g[y],10)&parseInt(m[y],10)),y++;return new this(x)}catch(b){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${b})`)}},p.IPv6.parse=function(d){let h=this.parser(d);if(h.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(h.parts,h.zoneId)},p.IPv6.parseCIDR=function(d){let h,y,g;if((y=d.match(/^(.+)\/(\d+)$/))&&(h=parseInt(y[2]),h>=0&&h<=128))return g=[this.parse(y[1]),h],Object.defineProperty(g,"toString",{value:function(){return this.join("/")}}),g;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},p.IPv6.parser=function(d){let h,y,g,x,m,b;if(g=d.match(a.deprecatedTransitional))return this.parser(`::ffff:${g[1]}`);if(a.native.test(d))return c(d,8);if((g=d.match(a.transitional))&&(b=g[6]||"",h=c(g[1].slice(0,-1)+b,6),h.parts)){for(m=[parseInt(g[2]),parseInt(g[3]),parseInt(g[4]),parseInt(g[5])],y=0;y<m.length;y++)if(x=m[y],!(0<=x&&x<=255))return null;return h.parts.push(m[0]<<8|m[1]),h.parts.push(m[2]<<8|m[3]),{parts:h.parts,zoneId:h.zoneId}}return null},p.IPv6.subnetMaskFromPrefixLength=function(d){if(d=parseInt(d),d<0||d>128)throw new Error("ipaddr: invalid IPv6 prefix length");let h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],y=0,g=Math.floor(d/8);for(;y<g;)h[y]=255,y++;return g<16&&(h[g]=Math.pow(2,d%8)-1<<8-d%8),new this(h)},p.fromByteArray=function(d){let h=d.length;if(h===4)return new p.IPv4(d);if(h===16)return new p.IPv6(d);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},p.isValid=function(d){return p.IPv6.isValid(d)||p.IPv4.isValid(d)},p.parse=function(d){if(p.IPv6.isValid(d))return p.IPv6.parse(d);if(p.IPv4.isValid(d))return p.IPv4.parse(d);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},p.parseCIDR=function(d){try{return p.IPv6.parseCIDR(d)}catch{try{return p.IPv4.parseCIDR(d)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},p.process=function(d){let h=this.parse(d);return h.kind()==="ipv6"&&h.isIPv4MappedAddress()?h.toIPv4Address():h},p.subnetMatch=function(d,h,y){let g,x,m,b;y==null&&(y="unicast");for(x in h)if(Object.prototype.hasOwnProperty.call(h,x)){for(m=h[x],m[0]&&!(m[0]instanceof Array)&&(m=[m]),g=0;g<m.length;g++)if(b=m[g],d.kind()===b[0].kind()&&d.match.apply(d,b))return x}return y},typeof Ai<"u"&&Ai.exports?Ai.exports=p:t.ipaddr=p})(Tc)});var Sy={};_t(Sy,{autoNAT:()=>Ey});var Ay=Symbol.for("@libp2p/connection");var Ty=Symbol.for("@libp2p/content-routing");var Ry=Symbol.for("@libp2p/peer-discovery");var Ws=Symbol.for("@libp2p/peer-id");var Py=Symbol.for("@libp2p/peer-routing");var Ys;(function(t){t.Accept="accept",t.Ignore="ignore",t.Reject="reject"})(Ys||(Ys={}));var Oy=Symbol.for("@libp2p/transport");var Zs;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Zs||(Zs={}));var $=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var Ci="ERR_TIMEOUT";var _i=class extends Event{detail;constructor(e,r){super(e,r),this.detail=r?.detail}},My=globalThis.CustomEvent??_i;var Ri=(t,...e)=>{try{[...e]}catch{}};var Ni={};_t(Ni,{base58btc:()=>At,base58flickr:()=>eu});var g2=new Uint8Array(0);function Qs(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Be(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function Xs(t){return new TextEncoder().encode(t)}function Js(t){return new TextDecoder().decode(t)}function Qc(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var y=0,g=0,x=0,m=h.length;x!==m&&h[x]===0;)x++,y++;for(var b=(m-x)*u+1>>>0,_=new Uint8Array(b);x!==m;){for(var E=h[x],S=0,L=b-1;(E!==0||S<g)&&L!==-1;L--,S++)E+=256*_[L]>>>0,_[L]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");g=S,x++}for(var D=b-g;D!==b&&_[D]===0;)D++;for(var z=c.repeat(y);D<b;++D)z+=t.charAt(_[D]);return z}function p(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var y=0;if(h[y]!==" "){for(var g=0,x=0;h[y]===c;)g++,y++;for(var m=(h.length-y)*f+1>>>0,b=new Uint8Array(m);h[y];){var _=r[h.charCodeAt(y)];if(_===255)return;for(var E=0,S=m-1;(_!==0||E<x)&&S!==-1;S--,E++)_+=a*b[S]>>>0,b[S]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");x=E,y++}if(h[y]!==" "){for(var L=m-x;L!==m&&b[L]===0;)L++;for(var D=new Uint8Array(g+(m-L)),z=g;L!==m;)D[z++]=b[L++];return D}}}function d(h){var y=p(h);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:d}}var Xc=Qc,Jc=Xc,ta=Jc;var Li=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Di=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ea(this,e)}},Pi=class{decoders;constructor(e){this.decoders=e}or(e){return ea(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ea(t,e){return new Pi({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var ki=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Li(e,r,n),this.decoder=new Di(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Sr({name:t,prefix:e,encode:r,decode:n}){return new ki(t,e,r,n)}function qe({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=ta(r,t);return Sr({prefix:e,name:t,encode:n,decode:o=>Be(i(o))})}function jc(t,e,r,n){let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,c=0,f=0;for(let u=0;u<o;++u){let l=i[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function tu(t,e,r){let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function vt({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return Sr({prefix:e,name:t,encode(i){return tu(i,n,r)},decode(i){return jc(i,n,r,t)}})}var At=qe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),eu=qe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ui={};_t(Ui,{base10:()=>ru});var ru=qe({prefix:"9",name:"base10",alphabet:"0123456789"});var Oi={};_t(Oi,{base16:()=>nu,base16upper:()=>iu});var nu=vt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),iu=vt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ki={};_t(Ki,{base2:()=>ou});var ou=vt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Fi={};_t(Fi,{base256emoji:()=>uu});var ra=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),su=ra.reduce((t,e,r)=>(t[r]=e,t),[]),au=ra.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function fu(t){return t.reduce((e,r)=>(e+=su[r],e),"")}function cu(t){let e=[];for(let r of t){let n=au[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var uu=Sr({prefix:"\u{1F680}",name:"base256emoji",encode:fu,decode:cu});var Mi={};_t(Mi,{base32:()=>Ae,base32hex:()=>pu,base32hexpad:()=>gu,base32hexpadupper:()=>xu,base32hexupper:()=>yu,base32pad:()=>hu,base32padupper:()=>du,base32upper:()=>lu,base32z:()=>mu});var Ae=vt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),lu=vt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),hu=vt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),du=vt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pu=vt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yu=vt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gu=vt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xu=vt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),mu=vt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vi={};_t(Vi,{base36:()=>vu,base36upper:()=>bu});var vu=qe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bu=qe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var qi={};_t(qi,{base64:()=>In,base64pad:()=>wu,base64url:()=>Eu,base64urlpad:()=>Su});var In=vt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wu=vt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Eu=vt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Su=vt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zi={};_t(zi,{base8:()=>Bu});var Bu=vt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hi={};_t(Hi,{identity:()=>Au});var Au=Sr({prefix:"\0",name:"identity",encode:t=>Js(t),decode:t=>Xs(t)});var D2=new TextEncoder,P2=new TextDecoder;var Gi={};_t(Gi,{identity:()=>ze});var Cu=oa,na=128,_u=127,Ru=~_u,Lu=Math.pow(2,31);function oa(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Lu;)e[r++]=t&255|na,t/=128;for(;t&Ru;)e[r++]=t&255|na,t>>>=7;return e[r]=t|0,oa.bytes=r-n+1,e}var Du=$i,Pu=128,ia=127;function $i(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw $i.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&ia)<<i:(s&ia)*Math.pow(2,i),i+=7}while(s>=Pu);return $i.bytes=o-n,r}var ku=Math.pow(2,7),Nu=Math.pow(2,14),Uu=Math.pow(2,21),Ou=Math.pow(2,28),Ku=Math.pow(2,35),Fu=Math.pow(2,42),Mu=Math.pow(2,49),Vu=Math.pow(2,56),qu=Math.pow(2,63),zu=function(t){return t<ku?1:t<Nu?2:t<Uu?3:t<Ou?4:t<Ku?5:t<Fu?6:t<Mu?7:t<Vu?8:t<qu?9:10},Hu={encode:Cu,decode:Du,encodingLength:zu},$u=Hu,jr=$u;function tn(t,e=0){return[jr.decode(t,e),jr.decode.bytes]}function Br(t,e,r=0){return jr.encode(t,e,r),e}function Ar(t){return jr.encodingLength(t)}function ye(t,e){let r=e.byteLength,n=Ar(t),i=n+Ar(r),o=new Uint8Array(i+r);return Br(t,o,0),Br(r,o,n),o.set(e,i),new Ir(t,r,e,o)}function sr(t){let e=Be(t),[r,n]=tn(e),[i,o]=tn(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Ir(r,i,s,e)}function sa(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Qs(t.bytes,r.bytes)}}var Ir=class{code;size;digest;bytes;constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var aa=0,Gu="identity",fa=Be;function Wu(t){return ye(aa,fa(t))}var ze={code:aa,name:Gu,encode:fa,digest:Wu};var Zi={};_t(Zi,{sha256:()=>Ot,sha512:()=>Yu});function Yi({name:t,code:e,encode:r}){return new Wi(t,e,r)}var Wi=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?ye(this.code,r):r.then(n=>ye(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ua(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Ot=Yi({name:"sha2-256",code:18,encode:ua("SHA-256")}),Yu=Yi({name:"sha2-512",code:19,encode:ua("SHA-512")});function la(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Qu(r,Qi(t),e??At.encoder);default:return Xu(r,Qi(t),e??Ae.encoder)}}var ha=new WeakMap;function Qi(t){let e=ha.get(t);if(e==null){let r=new Map;return ha.set(t,r),r}return e}var re=class t{code;version;multihash;bytes;"/";constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==en)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ju)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=ye(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&sa(e.multihash,n.multihash)}toString(e){return la(this,e)}toJSON(){return{"/":la(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new t(n,i,o,s??da(n,i,o.bytes))}else if(r[ju]===!0){let{version:n,multihash:i,code:o}=r,s=sr(i);return t.create(n,o,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==en)throw new Error(`Version 0 CID must use dag-pb (code: ${en}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=da(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,en,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=Be(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new Ir(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=tn(e.subarray(r));return r+=p,l},i=n(),o=en;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),c=n(),f=r+c,u=f-s;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,r){let[n,i]=Zu(e,r),o=t.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Qi(o).set(n,e),o}};function Zu(t,e){switch(t[0]){case"Q":{let r=e??At;return[At.prefix,r.decode(`${At.prefix}${t}`)]}case At.prefix:{let r=e??At;return[At.prefix,r.decode(t)]}case Ae.prefix:{let r=e??Ae;return[Ae.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Qu(t,e,r){let{prefix:n}=r;if(n!==At.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let o=r.encode(t).slice(1);return e.set(n,o),o}else return i}function Xu(t,e,r){let{prefix:n}=r,i=e.get(n);if(i==null){let o=r.encode(t);return e.set(n,o),o}else return i}var en=112,Ju=18;function da(t,e,r){let n=Ar(t),i=n+Ar(e),o=new Uint8Array(i+r.byteLength);return Br(t,o,0),Br(e,o,n),o.set(r,i),o}var ju=Symbol.for("@ipld/js-cid/CID");var He={...Hi,...Ki,...zi,...Ui,...Oi,...Mi,...Vi,...Ni,...qi,...Fi},tg={...Zi,...Gi};function Kt(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var tl=Symbol.for("nodejs.util.inspect.custom"),pa=Object.values(He).map(t=>t.decoder).reduce((t,e)=>t.or(e),He.identity.decoder),ya=114,Xi=36,Ji=37,rn=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ws]=!0;toString(){return this.string==null&&(this.string=At.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return re.createV1(ya,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Kt(this.multihash.bytes,e);if(typeof e=="string")return el(e).equals(this);if(e?.multihash?.bytes!=null)return Kt(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[tl](){return`PeerId(${this.toString()})`}},Tr=class extends rn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Cr=class extends rn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},_r=class extends rn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function el(t,e){if(e=e??pa,t.charAt(0)==="1"||t.charAt(0)==="Q"){let r=sr(At.decode(`z${t}`));return t.startsWith("12D")?new Cr({multihash:r}):t.startsWith("16U")?new _r({multihash:r}):new Tr({multihash:r})}return Cn(pa.decode(t))}function Cn(t){try{let e=sr(t);if(e.code===ze.code){if(e.digest.length===Xi)return new Cr({multihash:e});if(e.digest.length===Ji)return new _r({multihash:e})}if(e.code===Ot.code)return new Tr({multihash:e})}catch{return rl(re.decode(t))}throw new Error("Supplied PeerID CID is invalid")}function rl(t){if(t==null||t.multihash==null||t.version==null||t.version===1&&t.code!==ya)throw new Error("Supplied PeerID CID is invalid");let e=t.multihash;if(e.code===Ot.code)return new Tr({multihash:t.multihash});if(e.code===ze.code){if(e.digest.length===Xi)return new Cr({multihash:t.multihash});if(e.digest.length===Ji)return new _r({multihash:t.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function ga(t,e){return t.length===Xi?new Cr({multihash:ye(ze.code,t),privateKey:e}):t.length===Ji?new _r({multihash:ye(ze.code,t),privateKey:e}):new Tr({multihash:await Ot.digest(t),publicKey:t,privateKey:e})}var ab=Mt(an(),1),fb=Mt(D0(),1);var v1=Mt(ct(),1);function Ze(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function _e(t=0){return globalThis.Buffer?.alloc!=null?Ze(globalThis.Buffer.alloc(t)):new Uint8Array(t)}function Vt(t=0){return globalThis.Buffer?.allocUnsafe!=null?Ze(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function k0(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var P0=k0("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Eo=k0("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Vt(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Td={utf8:P0,"utf-8":P0,hex:He.base16,latin1:Eo,ascii:Eo,binary:Eo,...He},Wn=Td;function It(t,e="utf8"){let r=Wn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ze(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var jo={};_t(jo,{Ed25519PrivateKey:()=>mr,Ed25519PublicKey:()=>gn,generateKeyPair:()=>zp,generateKeyPairFromSeed:()=>xf,unmarshalEd25519PrivateKey:()=>Vp,unmarshalEd25519PublicKey:()=>qp});var Xg=Mt(Et(),1),Jg=Mt(zn(),1),N0=Mt(ct(),1);function Tt(t,e){if(globalThis.Buffer!=null)return Ze(globalThis.Buffer.concat(t,e));e==null&&(e=t.reduce((i,o)=>i+o.length,0));let r=Vt(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return Ze(r)}function lt(t,e="utf8"){let r=Wn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function oe(t,e){let r=Uint8Array.from(t.abs().toByteArray());if(r=r[0]===0?r.subarray(1):r,e!=null){if(r.length>e)throw new Error("byte array longer than desired length");r=Tt([new Uint8Array(e-r.length),r])}return lt(r,"base64url")}function Qt(t){let e=U0(t);return new N0.default.jsbn.BigInteger(lt(e,"base16"),16)}function U0(t,e){let r=It(t,"base64urlpad");if(e!=null){if(r.length>e)throw new Error("byte array longer than desired length");r=Tt([new Uint8Array(e-r.length),r])}return r}function te(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}function O0(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Cd(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function So(t,...e){if(!Cd(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function K0(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");O0(t.outputLen),O0(t.blockLen)}function kr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function F0(t,e){So(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Yn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function M0(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Zn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),se=(t,e)=>t<<32-e|t>>>e,_d=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!_d)throw new Error("Non little-endian hardware is not supported");function Bo(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function un(t){if(typeof t=="string"&&(t=Bo(t)),!M0(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Qn(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];if(!M0(i))throw new Error("Uint8Array expected");e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}var Nr=class{clone(){return this._cloneInto()}},sx={}.toString;function Xn(t){let e=n=>t().update(un(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ur(t=32){if(Yn&&typeof Yn.getRandomValues=="function")return Yn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Rd(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Or=class extends Nr{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Zn(this.buffer)}update(e){kr(this);let{view:r,buffer:n,blockLen:i}=this;e=un(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Zn(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){kr(this),F0(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;Rd(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=Zn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};var Jn=BigInt(4294967295),Ao=BigInt(32);function V0(t,e=!1){return e?{h:Number(t&Jn),l:Number(t>>Ao&Jn)}:{h:Number(t>>Ao&Jn)|0,l:Number(t&Jn)|0}}function Ld(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=V0(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var Dd=(t,e)=>BigInt(t>>>0)<<Ao|BigInt(e>>>0),Pd=(t,e,r)=>t>>>r,kd=(t,e,r)=>t<<32-r|e>>>r,Nd=(t,e,r)=>t>>>r|e<<32-r,Ud=(t,e,r)=>t<<32-r|e>>>r,Od=(t,e,r)=>t<<64-r|e>>>r-32,Kd=(t,e,r)=>t>>>r-32|e<<64-r,Fd=(t,e)=>e,Md=(t,e)=>t,Vd=(t,e,r)=>t<<r|e>>>32-r,qd=(t,e,r)=>e<<r|t>>>32-r,zd=(t,e,r)=>e<<r-32|t>>>64-r,Hd=(t,e,r)=>t<<r-32|e>>>64-r;function $d(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Gd=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Wd=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,Yd=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Zd=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,Qd=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),Xd=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var Jd={fromBig:V0,split:Ld,toBig:Dd,shrSH:Pd,shrSL:kd,rotrSH:Nd,rotrSL:Ud,rotrBH:Od,rotrBL:Kd,rotr32H:Fd,rotr32L:Md,rotlSH:Vd,rotlSL:qd,rotlBH:zd,rotlBL:Hd,add:$d,add3L:Gd,add3H:Wd,add4L:Yd,add4H:Zd,add5H:Xd,add5L:Qd},W=Jd;var[jd,tp]=W.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Qe=new Uint32Array(80),Xe=new Uint32Array(80),Io=class extends Or{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:d,Gl:h,Hh:y,Hl:g}=this;return[e,r,n,i,o,s,a,c,f,u,l,p,d,h,y,g]}set(e,r,n,i,o,s,a,c,f,u,l,p,d,h,y,g){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=d|0,this.Gl=h|0,this.Hh=y|0,this.Hl=g|0}process(e,r){for(let b=0;b<16;b++,r+=4)Qe[b]=e.getUint32(r),Xe[b]=e.getUint32(r+=4);for(let b=16;b<80;b++){let _=Qe[b-15]|0,E=Xe[b-15]|0,S=W.rotrSH(_,E,1)^W.rotrSH(_,E,8)^W.shrSH(_,E,7),L=W.rotrSL(_,E,1)^W.rotrSL(_,E,8)^W.shrSL(_,E,7),D=Qe[b-2]|0,z=Xe[b-2]|0,q=W.rotrSH(D,z,19)^W.rotrBH(D,z,61)^W.shrSH(D,z,6),M=W.rotrSL(D,z,19)^W.rotrBL(D,z,61)^W.shrSL(D,z,6),X=W.add4L(L,M,Xe[b-7],Xe[b-16]),at=W.add4H(X,S,q,Qe[b-7],Qe[b-16]);Qe[b]=at|0,Xe[b]=X|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:d,Fl:h,Gh:y,Gl:g,Hh:x,Hl:m}=this;for(let b=0;b<80;b++){let _=W.rotrSH(l,p,14)^W.rotrSH(l,p,18)^W.rotrBH(l,p,41),E=W.rotrSL(l,p,14)^W.rotrSL(l,p,18)^W.rotrBL(l,p,41),S=l&d^~l&y,L=p&h^~p&g,D=W.add5L(m,E,L,tp[b],Xe[b]),z=W.add5H(D,x,_,S,jd[b],Qe[b]),q=D|0,M=W.rotrSH(n,i,28)^W.rotrBH(n,i,34)^W.rotrBH(n,i,39),X=W.rotrSL(n,i,28)^W.rotrBL(n,i,34)^W.rotrBL(n,i,39),at=n&o^n&a^o&a,kt=i&s^i&c^s&c;x=y|0,m=g|0,y=d|0,g=h|0,d=l|0,h=p|0,{h:l,l:p}=W.add(f|0,u|0,z|0,q|0),f=a|0,u=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let T=W.add3L(q,X,kt);n=W.add3H(T,z,M,at),i=T|0}({h:n,l:i}=W.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=W.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=W.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=W.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=W.add(this.Eh|0,this.El|0,l|0,p|0),{h:d,l:h}=W.add(this.Fh|0,this.Fl|0,d|0,h|0),{h:y,l:g}=W.add(this.Gh|0,this.Gl|0,y|0,g|0),{h:x,l:m}=W.add(this.Hh|0,this.Hl|0,x|0,m|0),this.set(n,i,o,s,a,c,f,u,l,p,d,h,y,g,x,m)}roundClean(){Qe.fill(0),Xe.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var To=Xn(()=>new Io);var ti={};_t(ti,{bitGet:()=>ap,bitLen:()=>sp,bitMask:()=>ln,bitSet:()=>fp,bytesToHex:()=>Le,bytesToNumberBE:()=>De,bytesToNumberLE:()=>Je,concatBytes:()=>Pe,createHmacDrbg:()=>Ro,ensureBytes:()=>bt,equalBytes:()=>ip,hexToBytes:()=>dr,hexToNumber:()=>_o,isBytes:()=>ae,numberToBytesBE:()=>je,numberToBytesLE:()=>pr,numberToHexUnpadded:()=>$0,numberToVarBytesBE:()=>np,utf8ToBytes:()=>op,validateObject:()=>Ee});var H0=BigInt(0),jn=BigInt(1),ep=BigInt(2);function ae(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var rp=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Le(t){if(!ae(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=rp[t[r]];return e}function $0(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function _o(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Re={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function q0(t){if(t>=Re._0&&t<=Re._9)return t-Re._0;if(t>=Re._A&&t<=Re._F)return t-(Re._A-10);if(t>=Re._a&&t<=Re._f)return t-(Re._a-10)}function dr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;i<r;i++,o+=2){let s=q0(t.charCodeAt(o)),a=q0(t.charCodeAt(o+1));if(s===void 0||a===void 0){let c=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function De(t){return _o(Le(t))}function Je(t){if(!ae(t))throw new Error("Uint8Array expected");return _o(Le(Uint8Array.from(t).reverse()))}function je(t,e){return dr(t.toString(16).padStart(e*2,"0"))}function pr(t,e){return je(t,e).reverse()}function np(t){return dr($0(t))}function bt(t,e,r){let n;if(typeof e=="string")try{n=dr(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(ae(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Pe(...t){let e=0;for(let i=0;i<t.length;i++){let o=t[i];if(!ae(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let o=t[i];r.set(o,n),n+=o.length}return r}function ip(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function op(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function sp(t){let e;for(e=0;t>H0;t>>=jn,e+=1);return e}function ap(t,e){return t>>BigInt(e)&jn}var fp=(t,e,r)=>t|(r?jn:H0)<<BigInt(e),ln=t=>(ep<<BigInt(t-1))-jn,Co=t=>new Uint8Array(t),z0=t=>Uint8Array.from(t);function Ro(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Co(t),i=Co(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),c=(l=Co())=>{i=a(z0([0]),l),n=a(),l.length!==0&&(i=a(z0([1]),l),n=a())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let d=n.slice();p.push(d),l+=n.length}return Pe(...p)};return(l,p)=>{s(),c(l);let d;for(;!(d=p(f()));)c();return s(),d}}var cp={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||ae(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ee(t,e,r={}){let n=(i,o,s)=>{let a=cp[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var Ct=BigInt(0),gt=BigInt(1),yr=BigInt(2),up=BigInt(3),Lo=BigInt(4),G0=BigInt(5),W0=BigInt(8),lp=BigInt(9),hp=BigInt(16);function ut(t,e){let r=t%e;return r>=Ct?r:e+r}function dp(t,e,r){if(r<=Ct||e<Ct)throw new Error("Expected power/modulo > 0");if(r===gt)return Ct;let n=gt;for(;e>Ct;)e&gt&&(n=n*t%r),t=t*t%r,e>>=gt;return n}function xt(t,e,r){let n=t;for(;e-- >Ct;)n*=n,n%=r;return n}function ei(t,e){if(t===Ct||e<=Ct)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ut(t,e),n=e,i=Ct,o=gt,s=gt,a=Ct;for(;r!==Ct;){let f=n/r,u=n%r,l=i-s*f,p=o-a*f;n=r,r=u,i=s,o=a,s=l,a=p}if(n!==gt)throw new Error("invert: does not exist");return ut(i,e)}function pp(t){let e=(t-gt)/yr,r,n,i;for(r=t-gt,n=0;r%yr===Ct;r/=yr,n++);for(i=yr;i<t&&dp(i,e,t)!==t-gt;i++);if(n===1){let s=(t+gt)/Lo;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let o=(r+gt)/yr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,i),r),l=a.pow(c,o),p=a.pow(c,r);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let d=1;for(let y=a.sqr(p);d<f&&!a.eql(y,a.ONE);d++)y=a.sqr(y);let h=a.pow(u,gt<<BigInt(f-d-1));u=a.sqr(h),l=a.mul(l,h),p=a.mul(p,u),f=d}return l}}function yp(t){if(t%Lo===up){let e=(t+gt)/Lo;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%W0===G0){let e=(t-G0)/W0;return function(n,i){let o=n.mul(i,yr),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,yr),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%hp,pp(t)}var Y0=(t,e)=>(ut(t,e)&gt)===gt,gp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Do(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=gp.reduce((n,i)=>(n[i]="function",n),e);return Ee(t,r)}function xp(t,e,r){if(r<Ct)throw new Error("Expected power > 0");if(r===Ct)return t.ONE;if(r===gt)return e;let n=t.ONE,i=e;for(;r>Ct;)r&gt&&(n=t.mul(n,i)),i=t.sqr(i),r>>=gt;return n}function mp(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function Po(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ri(t,e,r=!1,n={}){if(t<=Ct)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=Po(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=yp(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:ln(i),ZERO:Ct,ONE:gt,create:c=>ut(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Ct<=c&&c<t},is0:c=>c===Ct,isOdd:c=>(c&gt)===gt,neg:c=>ut(-c,t),eql:(c,f)=>c===f,sqr:c=>ut(c*c,t),add:(c,f)=>ut(c+f,t),sub:(c,f)=>ut(c-f,t),mul:(c,f)=>ut(c*f,t),pow:(c,f)=>xp(a,c,f),div:(c,f)=>ut(c*ei(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>ei(c,t),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>mp(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?pr(c,o):je(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return r?Je(c):De(c)}});return Object.freeze(a)}function Z0(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function Q0(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function ko(t){let e=Q0(t);return e+Math.ceil(e/2)}function X0(t,e,r=!1){let n=t.length,i=Q0(e),o=ko(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?De(t):Je(t),a=ut(s,e-gt)+gt;return r?pr(a,i):je(a,i)}var bp=BigInt(0),No=BigInt(1);function ni(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>bp;)o&No&&(s=s.add(a)),a=a.double(),o>>=No;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),c=[],f=i,u=f;for(let l=0;l<s;l++){u=f,c.push(u);for(let p=1;p<a;p++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(i,o,s){let{windows:a,windowSize:c}=n(i),f=t.ZERO,u=t.BASE,l=BigInt(2**i-1),p=2**i,d=BigInt(i);for(let h=0;h<a;h++){let y=h*c,g=Number(s&l);s>>=d,g>c&&(g-=p,s+=No);let x=y,m=y+Math.abs(g)-1,b=h%2!==0,_=g<0;g===0?u=u.add(r(b,o[x])):f=f.add(r(_,o[m]))}return{p:f,f:u}},wNAFCached(i,o,s,a){let c=i._WINDOW_SIZE||1,f=o.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&o.set(i,a(f))),this.wNAF(c,f,s)}}}function hn(t){return Do(t.Fp),Ee(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Po(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var fe=BigInt(0),Xt=BigInt(1),ii=BigInt(2),wp=BigInt(8),Ep={zip215:!0};function Sp(t){let e=hn(t);return Ee(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function oi(t){let e=Sp(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=e,f=ii<<BigInt(a*8)-Xt,u=r.create,l=e.uvRatio||((P,A)=>{try{return{isValid:!0,value:r.sqrt(P*r.inv(A))}}catch{return{isValid:!1,value:fe}}}),p=e.adjustScalarBytes||(P=>P),d=e.domain||((P,A,O)=>{if(A.length||O)throw new Error("Contexts/pre-hash are not supported");return P}),h=P=>typeof P=="bigint"&&fe<P,y=(P,A)=>h(P)&&h(A)&&P<A,g=P=>P===fe||y(P,f);function x(P,A){if(y(P,A))return P;throw new Error(`Expected valid scalar < ${A}, got ${typeof P} ${P}`)}function m(P){return P===fe?P:x(P,n)}let b=new Map;function _(P){if(!(P instanceof E))throw new Error("ExtendedPoint expected")}class E{constructor(A,O,K,V){if(this.ex=A,this.ey=O,this.ez=K,this.et=V,!g(A))throw new Error("x required");if(!g(O))throw new Error("y required");if(!g(K))throw new Error("z required");if(!g(V))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof E)throw new Error("extended point not allowed");let{x:O,y:K}=A||{};if(!g(O)||!g(K))throw new Error("invalid affine point");return new E(O,K,Xt,u(O*K))}static normalizeZ(A){let O=r.invertBatch(A.map(K=>K.ez));return A.map((K,V)=>K.toAffine(O[V])).map(E.fromAffine)}_setWindowSize(A){this._WINDOW_SIZE=A,b.delete(this)}assertValidity(){let{a:A,d:O}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:K,ey:V,ez:Z,et:J}=this,ot=u(K*K),j=u(V*V),rt=u(Z*Z),wt=u(rt*rt),mt=u(ot*A),Nt=u(rt*u(mt+j)),Ut=u(wt+u(O*u(ot*j)));if(Nt!==Ut)throw new Error("bad point: equation left != right (1)");let Bt=u(K*V),Ft=u(Z*J);if(Bt!==Ft)throw new Error("bad point: equation left != right (2)")}equals(A){_(A);let{ex:O,ey:K,ez:V}=this,{ex:Z,ey:J,ez:ot}=A,j=u(O*ot),rt=u(Z*V),wt=u(K*ot),mt=u(J*V);return j===rt&&wt===mt}is0(){return this.equals(E.ZERO)}negate(){return new E(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:A}=e,{ex:O,ey:K,ez:V}=this,Z=u(O*O),J=u(K*K),ot=u(ii*u(V*V)),j=u(A*Z),rt=O+K,wt=u(u(rt*rt)-Z-J),mt=j+J,Nt=mt-ot,Ut=j-J,Bt=u(wt*Nt),Ft=u(mt*Ut),Se=u(wt*Ut),or=u(Nt*mt);return new E(Bt,Ft,or,Se)}add(A){_(A);let{a:O,d:K}=e,{ex:V,ey:Z,ez:J,et:ot}=this,{ex:j,ey:rt,ez:wt,et:mt}=A;if(O===BigInt(-1)){let Fs=u((Z-V)*(rt+j)),Ms=u((Z+V)*(rt-j)),Ti=u(Ms-Fs);if(Ti===fe)return this.double();let Vs=u(J*ii*mt),qs=u(ot*ii*wt),zs=qs+Vs,Hs=Ms+Fs,$s=qs-Vs,Mc=u(zs*Ti),Vc=u(Hs*$s),qc=u(zs*$s),zc=u(Ti*Hs);return new E(Mc,Vc,zc,qc)}let Nt=u(V*j),Ut=u(Z*rt),Bt=u(ot*K*mt),Ft=u(J*wt),Se=u((V+Z)*(j+rt)-Nt-Ut),or=Ft-Bt,Jr=Ft+Bt,Ks=u(Ut-O*Nt),Uc=u(Se*or),Oc=u(Jr*Ks),Kc=u(Se*Ks),Fc=u(or*Jr);return new E(Uc,Oc,Fc,Kc)}subtract(A){return this.add(A.negate())}wNAF(A){return D.wNAFCached(this,b,A,E.normalizeZ)}multiply(A){let{p:O,f:K}=this.wNAF(x(A,n));return E.normalizeZ([O,K])[0]}multiplyUnsafe(A){let O=m(A);return O===fe?L:this.equals(L)||O===Xt?this:this.equals(S)?this.wNAF(O).p:D.unsafeLadder(this,O)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return D.unsafeLadder(this,n).is0()}toAffine(A){let{ex:O,ey:K,ez:V}=this,Z=this.is0();A==null&&(A=Z?wp:r.inv(V));let J=u(O*A),ot=u(K*A),j=u(V*A);if(Z)return{x:fe,y:Xt};if(j!==Xt)throw new Error("invZ was invalid");return{x:J,y:ot}}clearCofactor(){let{h:A}=e;return A===Xt?this:this.multiplyUnsafe(A)}static fromHex(A,O=!1){let{d:K,a:V}=e,Z=r.BYTES;A=bt("pointHex",A,Z);let J=A.slice(),ot=A[Z-1];J[Z-1]=ot&-129;let j=Je(J);j===fe||(O?x(j,f):x(j,r.ORDER));let rt=u(j*j),wt=u(rt-Xt),mt=u(K*rt-V),{isValid:Nt,value:Ut}=l(wt,mt);if(!Nt)throw new Error("Point.fromHex: invalid y coordinate");let Bt=(Ut&Xt)===Xt,Ft=(ot&128)!==0;if(!O&&Ut===fe&&Ft)throw new Error("Point.fromHex: x=0 and x_0=1");return Ft!==Bt&&(Ut=u(-Ut)),E.fromAffine({x:Ut,y:j})}static fromPrivateKey(A){return M(A).point}toRawBytes(){let{x:A,y:O}=this.toAffine(),K=pr(O,r.BYTES);return K[K.length-1]|=A&Xt?128:0,K}toHex(){return Le(this.toRawBytes())}}E.BASE=new E(e.Gx,e.Gy,Xt,u(e.Gx*e.Gy)),E.ZERO=new E(fe,Xt,Xt,fe);let{BASE:S,ZERO:L}=E,D=ni(E,a*8);function z(P){return ut(P,n)}function q(P){return z(Je(P))}function M(P){let A=a;P=bt("private key",P,A);let O=bt("hashed private key",o(P),2*A),K=p(O.slice(0,A)),V=O.slice(A,2*A),Z=q(K),J=S.multiply(Z),ot=J.toRawBytes();return{head:K,prefix:V,scalar:Z,point:J,pointBytes:ot}}function X(P){return M(P).pointBytes}function at(P=new Uint8Array,...A){let O=Pe(...A);return q(o(d(O,bt("context",P),!!i)))}function kt(P,A,O={}){P=bt("message",P),i&&(P=i(P));let{prefix:K,scalar:V,pointBytes:Z}=M(A),J=at(O.context,K,P),ot=S.multiply(J).toRawBytes(),j=at(O.context,ot,Z,P),rt=z(J+j*V);m(rt);let wt=Pe(ot,pr(rt,r.BYTES));return bt("result",wt,a*2)}let T=Ep;function k(P,A,O,K=T){let{context:V,zip215:Z}=K,J=r.BYTES;P=bt("signature",P,2*J),A=bt("message",A),i&&(A=i(A));let ot=Je(P.slice(J,2*J)),j,rt,wt;try{j=E.fromHex(O,Z),rt=E.fromHex(P.slice(0,J),Z),wt=S.multiplyUnsafe(ot)}catch{return!1}if(!Z&&j.isSmallOrder())return!1;let mt=at(V,rt.toRawBytes(),j.toRawBytes(),A);return rt.add(j.multiplyUnsafe(mt)).subtract(wt).clearCofactor().equals(E.ZERO)}return S._setWindowSize(8),{CURVE:e,getPublicKey:X,sign:kt,verify:k,ExtendedPoint:E,utils:{getExtendedPublicKey:M,randomPrivateKey:()=>s(r.BYTES),precompute(P=8,A=E.BASE){return A._setWindowSize(P),A.multiply(BigInt(3)),A}}}}var Oo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),J0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Cx=BigInt(0),Bp=BigInt(1),Uo=BigInt(2),Ap=BigInt(5),j0=BigInt(10),Ip=BigInt(20),Tp=BigInt(40),tf=BigInt(80);function Cp(t){let e=Oo,n=t*t%e*t%e,i=xt(n,Uo,e)*n%e,o=xt(i,Bp,e)*t%e,s=xt(o,Ap,e)*o%e,a=xt(s,j0,e)*s%e,c=xt(a,Ip,e)*a%e,f=xt(c,Tp,e)*c%e,u=xt(f,tf,e)*f%e,l=xt(u,tf,e)*f%e,p=xt(l,j0,e)*s%e;return{pow_p_5_8:xt(p,Uo,e)*t%e,b2:n}}function _p(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function Rp(t,e){let r=Oo,n=ut(e*e*e,r),i=ut(n*n*e,r),o=Cp(t*i).pow_p_5_8,s=ut(t*n*o,r),a=ut(e*s*s,r),c=s,f=ut(s*J0,r),u=a===t,l=a===ut(-t,r),p=a===ut(-t*J0,r);return u&&(s=c),(l||p)&&(s=f),Y0(s,r)&&(s=ut(-s,r)),{isValid:u||l,value:s}}var ke=ri(Oo,void 0,!0),Ko={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ke,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:To,randomBytes:Ur,adjustScalarBytes:_p,uvRatio:Rp},Kr=oi(Ko);function ef(t,e,r){if(e.length>255)throw new Error("Context is too big");return Qn(Bo("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var _x=oi({...Ko,domain:ef}),Rx=oi({...Ko,domain:ef,prehash:To});var Lp=(ke.ORDER+BigInt(3))/BigInt(8),Lx=ke.pow(Uo,Lp),Dx=ke.sqrt(ke.neg(ke.ONE)),Px=(ke.ORDER-BigInt(5))/BigInt(8),kx=BigInt(486662);var Nx=Z0(ke,ke.neg(BigInt(486664)));var Ux=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Ox=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Kx=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Fx=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Mx=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Fr=32,Ne=64,si=32;function rf(){let t=Kr.utils.randomPrivateKey(),e=Kr.getPublicKey(t);return{privateKey:af(t,e),publicKey:e}}function nf(t){if(t.length!==si)throw new TypeError('"seed" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=t,r=Kr.getPublicKey(e);return{privateKey:af(e,r),publicKey:r}}function of(t,e){let r=t.subarray(0,si);return Kr.sign(e instanceof Uint8Array?e:e.subarray(),r)}function sf(t,e,r){return Kr.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}function af(t,e){let r=new Uint8Array(Ne);for(let n=0;n<si;n++)r[n]=t[n],r[si+n]=e[n];return r}var Wt={get(t=globalThis){let e=t.crypto;if(e==null||e.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var Fo={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function Mo(t){let e=t?.algorithm??"AES-GCM",r=t?.keyLength??16,n=t?.nonceLength??12,i=t?.digest??"SHA-256",o=t?.saltLength??16,s=t?.iterations??32767,a=Wt.get();r*=8;async function c(l,p){let d=a.getRandomValues(new Uint8Array(o)),h=a.getRandomValues(new Uint8Array(n)),y={name:e,iv:h};typeof p=="string"&&(p=It(p));let g;if(p.length===0){g=await a.subtle.importKey("jwk",Fo,{name:"AES-GCM"},!0,["encrypt"]);try{let m={name:"PBKDF2",salt:d,iterations:s,hash:{name:i}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(m,b,{name:e,length:r},!0,["encrypt"])}catch{g=await a.subtle.importKey("jwk",Fo,{name:"AES-GCM"},!0,["encrypt"])}}else{let m={name:"PBKDF2",salt:d,iterations:s,hash:{name:i}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(m,b,{name:e,length:r},!0,["encrypt"])}let x=await a.subtle.encrypt(y,g,l);return Tt([d,y.iv,new Uint8Array(x)])}async function f(l,p){let d=l.subarray(0,o),h=l.subarray(o,o+n),y=l.subarray(o+n),g={name:e,iv:h};typeof p=="string"&&(p=It(p));let x;if(p.length===0)try{let b={name:"PBKDF2",salt:d,iterations:s,hash:{name:i}},_=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);x=await a.subtle.deriveKey(b,_,{name:e,length:r},!0,["decrypt"])}catch{x=await a.subtle.importKey("jwk",Fo,{name:"AES-GCM"},!0,["decrypt"])}else{let b={name:"PBKDF2",salt:d,iterations:s,hash:{name:i}},_=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);x=await a.subtle.deriveKey(b,_,{name:e,length:r},!0,["decrypt"])}let m=await a.subtle.decrypt(g,x,y);return new Uint8Array(m)}return{encrypt:c,decrypt:f}}async function Mr(t,e){let n=await Mo().encrypt(t,e);return In.encode(n)}var Vo=new Float32Array([-0]),tr=new Uint8Array(Vo.buffer);function cf(t,e,r){Vo[0]=t,e[r]=tr[0],e[r+1]=tr[1],e[r+2]=tr[2],e[r+3]=tr[3]}function uf(t,e){return tr[0]=t[e],tr[1]=t[e+1],tr[2]=t[e+2],tr[3]=t[e+3],Vo[0]}var qo=new Float64Array([-0]),qt=new Uint8Array(qo.buffer);function lf(t,e,r){qo[0]=t,e[r]=qt[0],e[r+1]=qt[1],e[r+2]=qt[2],e[r+3]=qt[3],e[r+4]=qt[4],e[r+5]=qt[5],e[r+6]=qt[6],e[r+7]=qt[7]}function hf(t,e){return qt[0]=t[e],qt[1]=t[e+1],qt[2]=t[e+2],qt[3]=t[e+3],qt[4]=t[e+4],qt[5]=t[e+5],qt[6]=t[e+6],qt[7]=t[e+7],qo[0]}var Pp=BigInt(Number.MAX_SAFE_INTEGER),kp=BigInt(Number.MIN_SAFE_INTEGER),Yt=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return gr;if(e<Pp&&e>kp)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,i=e-(n<<32n);return r&&(n=~n|0n,i=~i|0n,++i>df&&(i=0n,++n>df&&(n=0n))),new t(Number(i),Number(n))}static fromNumber(e){if(e===0)return gr;let r=e<0;r&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new t(n,i)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):gr}},gr=new Yt(0,0);gr.toBigInt=function(){return 0n};gr.zzEncode=gr.zzDecode=function(){return this};gr.length=function(){return 1};var df=4294967296n;function pf(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function yf(t,e,r){if(r-e<1)return"";let i,o=[],s=0,a;for(;e<r;)a=t[e++],a<128?o[s++]=a:a>191&&a<224?o[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,o[s++]=55296+(a>>10),o[s++]=56320+(a&1023)):o[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function zo(t,e,r){let n=r,i,o;for(let s=0;s<t.length;++s)i=t.charCodeAt(s),i<128?e[r++]=i:i<2048?(e[r++]=i>>6|192,e[r++]=i&63|128):(i&64512)===55296&&((o=t.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128);return r-n}function ce(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function ai(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Ho=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ce(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ce(this,4);return ai(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ce(this,4);return ai(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ce(this,4);let e=uf(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ce(this,4);let e=hf(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw ce(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return yf(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ce(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ce(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Yt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw ce(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw ce(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ce(this,8);let e=ai(this.buf,this.pos+=4),r=ai(this.buf,this.pos+=4);return new Yt(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function $o(t){return new Ho(t instanceof Uint8Array?t:t.subarray())}function ue(t,e){let r=$o(t);return e.decode(r)}function Go(t){let e=t??8192,r=e>>>1,n,i=e;return function(s){if(s<1||s>r)return Vt(s);i+s>e&&(n=Vt(e),i=0);let a=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),a}}var xr=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Wo(){}var Zo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Np=Go();function Up(t){return globalThis.Buffer!=null?Vt(t):Np(t)}var yn=class{len;head;tail;states;constructor(){this.len=0,this.head=new xr(Wo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new xr(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Qo((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(dn,10,Yt.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Yt.fromBigInt(e);return this._push(dn,r.length(),r)}uint64Number(e){let r=Yt.fromNumber(e);return this._push(dn,r.length(),r)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Yt.fromBigInt(e).zzEncode();return this._push(dn,r.length(),r)}sint64Number(e){let r=Yt.fromNumber(e).zzEncode();return this._push(dn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Yo,1,e?1:0)}fixed32(e){return this._push(pn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Yt.fromBigInt(e);return this._push(pn,4,r.lo)._push(pn,4,r.hi)}fixed64Number(e){let r=Yt.fromNumber(e);return this._push(pn,4,r.lo)._push(pn,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(cf,4,e)}double(e){return this._push(lf,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Yo,1,0):this.uint32(r)._push(Kp,r,e)}string(e){let r=pf(e);return r!==0?this.uint32(r)._push(zo,r,e):this._push(Yo,1,0)}fork(){return this.states=new Zo(this),this.head=this.tail=new xr(Wo,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new xr(Wo,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=Up(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Yo(t,e,r){e[r]=t&255}function Op(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Qo=class extends xr{next;constructor(e,r){super(Op,e,r),this.next=void 0}};function dn(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function pn(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Kp(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(yn.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Fp,e,t),this},yn.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Mp,e,t),this});function Fp(t,e,r){e.set(t,r)}function Mp(t,e,r){t.length<40?zo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(It(t),r)}function Xo(){return new yn}function le(t,e){let r=Xo();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var Vr;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(Vr||(Vr={}));function fi(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function qr(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(o,s){let a=e(o);s.int32(a)},n=function(o){let s=o.int32();return e(s)};return fi("enum",Vr.VARINT,r,n)}function he(t,e){return fi("message",Vr.LENGTH_DELIMITED,t,e)}var Pt;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.Secp256k1="Secp256k1"})(Pt||(Pt={}));var Jo;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.Secp256k1=2]="Secp256k1"})(Jo||(Jo={}));(function(t){t.codec=()=>qr(Jo)})(Pt||(Pt={}));var Ue;(function(t){let e;t.codec=()=>(e==null&&(e=he((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),Pt.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos<o;){let s=r.uint32();switch(s>>>3){case 1:i.Type=Pt.codec().decode(r);break;case 2:i.Data=r.bytes();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>le(r,t.codec()),t.decode=r=>ue(r,t.codec())})(Ue||(Ue={}));var Oe;(function(t){let e;t.codec=()=>(e==null&&(e=he((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),Pt.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos<o;){let s=r.uint32();switch(s>>>3){case 1:i.Type=Pt.codec().decode(r);break;case 2:i.Data=r.bytes();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>le(r,t.codec()),t.decode=r=>ue(r,t.codec())})(Oe||(Oe={}));var gn=class{_key;constructor(e){this._key=zr(e,Fr)}verify(e,r){return sf(this._key,r,e)}marshal(){return this._key}get bytes(){return Ue.encode({Type:Pt.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Kt(this.bytes,e.bytes)}hash(){let e=Ot.digest(this.bytes);return te(e)?e.then(({bytes:r})=>r):e.bytes}},mr=class{_key;_publicKey;constructor(e,r){this._key=zr(e,Ne),this._publicKey=zr(r,Fr)}sign(e){return of(this._key,e)}get public(){return new gn(this._publicKey)}marshal(){return this._key}get bytes(){return Oe.encode({Type:Pt.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Kt(this.bytes,e.bytes)}async hash(){let e=Ot.digest(this.bytes),r;return te(e)?{bytes:r}=await e:r=e.bytes,r}async id(){let e=ze.digest(this.public.bytes);return At.encode(e.bytes).substring(1)}async export(e,r="libp2p-key"){if(r==="libp2p-key")return Mr(this.bytes,e);throw new $(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Vp(t){if(t.length>Ne){t=zr(t,Ne+Fr);let n=t.subarray(0,Ne),i=t.subarray(Ne,t.length);return new mr(n,i)}t=zr(t,Ne);let e=t.subarray(0,Ne),r=t.subarray(Fr);return new mr(e,r)}function qp(t){return t=zr(t,Fr),new gn(t)}async function zp(){let{privateKey:t,publicKey:e}=rf();return new mr(t,e)}async function xf(t){let{privateKey:e,publicKey:r}=nf(t);return new mr(e,r)}function zr(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new $(`Key must be a Uint8Array of length ${e}, got ${t.length}`,"ERR_INVALID_KEY_TYPE");return t}var Hp={"P-256":256,"P-384":384,"P-521":521},$p=Object.keys(Hp),Km=$p.join(" / ");var is={};_t(is,{MAX_KEY_SIZE:()=>bn,RsaPrivateKey:()=>Hr,RsaPublicKey:()=>vn,fromJwk:()=>r1,generateKeyPair:()=>n1,unmarshalRsaPrivateKey:()=>t1,unmarshalRsaPublicKey:()=>e1});var mn=Mt(ct(),1);var Ev=Mt(Ef(),1);function ui(t){if(isNaN(t)||t<=0)throw new $("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Ur(t)}var iv=Mt(Gn(),1),rs=Mt(ct(),1);function Sf(t,e){return e.map(r=>Qt(t[r]))}function Bf(t){return rs.default.pki.setRsaPrivateKey(...Sf(t,["n","e","d","p","q","dp","dq","qi"]))}function Af(t){return rs.default.pki.setRsaPublicKey(...Sf(t,["n","e"]))}var br={};_t(br,{jwkToPkcs1:()=>Zp,jwkToPkix:()=>Xp,pkcs1ToJwk:()=>Yp,pkixToJwk:()=>Qp});var av=Mt(an(),1),fv=Mt(Gn(),1);var Ke=Mt(ct(),1);function Yp(t){let e=Ke.default.asn1.fromDer(lt(t,"ascii")),r=Ke.default.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:oe(r.n),e:oe(r.e),d:oe(r.d),p:oe(r.p),q:oe(r.q),dp:oe(r.dP),dq:oe(r.dQ),qi:oe(r.qInv),alg:"RS256"}}function Zp(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new $("JWK was missing components","ERR_INVALID_PARAMETERS");let e=Ke.default.pki.privateKeyToAsn1({n:Qt(t.n),e:Qt(t.e),d:Qt(t.d),p:Qt(t.p),q:Qt(t.q),dP:Qt(t.dp),dQ:Qt(t.dq),qInv:Qt(t.qi)});return It(Ke.default.asn1.toDer(e).getBytes(),"ascii")}function Qp(t){let e=Ke.default.asn1.fromDer(lt(t,"ascii")),r=Ke.default.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:oe(r.n),e:oe(r.e)}}function Xp(t){if(t.n==null||t.e==null)throw new $("JWK was missing components","ERR_INVALID_PARAMETERS");let e=Ke.default.pki.publicKeyToAsn1({n:Qt(t.n),e:Qt(t.e)});return It(Ke.default.asn1.toDer(e).getBytes(),"ascii")}async function If(t){let e=await Wt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await _f(e);return{privateKey:r[0],publicKey:r[1]}}async function ns(t){let r=[await Wt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Jp(t)],n=await _f({privateKey:r[0],publicKey:r[1]});return{privateKey:n[0],publicKey:n[1]}}async function Tf(t,e){let r=await Wt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Wt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Cf(t,e,r){let n=await Wt.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Wt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r instanceof Uint8Array?r:r.subarray())}async function _f(t){if(t.privateKey==null||t.publicKey==null)throw new $("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Wt.get().subtle.exportKey("jwk",t.privateKey),Wt.get().subtle.exportKey("jwk",t.publicKey)])}async function Jp(t){return Wt.get().subtle.importKey("jwk",{kty:t.kty,n:t.n,e:t.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function Rf(t,e,r,n){let i=e?Af(t):Bf(t),o=lt(r instanceof Uint8Array?r:r.subarray(),"ascii"),s=n(o,i);return It(s,"ascii")}function Lf(t,e){return Rf(t,!0,e,(r,n)=>n.encrypt(r))}function Df(t,e){return Rf(t,!1,e,(r,n)=>n.decrypt(r))}function li(t){if(t.kty!=="RSA")throw new $("invalid key type","ERR_INVALID_KEY_TYPE");if(t.n==null)throw new $("invalid key modulus","ERR_INVALID_KEY_MODULUS");return It(t.n,"base64url").length*8}var bn=8192,vn=class{_key;constructor(e){this._key=e}verify(e,r){return Cf(this._key,r,e)}marshal(){return br.jwkToPkix(this._key)}get bytes(){return Ue.encode({Type:Pt.RSA,Data:this.marshal()}).subarray()}encrypt(e){return Lf(this._key,e)}equals(e){return Kt(this.bytes,e.bytes)}hash(){let e=Ot.digest(this.bytes);return te(e)?e.then(({bytes:r})=>r):e.bytes}},Hr=class{_key;_publicKey;constructor(e,r){this._key=e,this._publicKey=r}genSecret(){return ui(16)}sign(e){return Tf(this._key,e)}get public(){if(this._publicKey==null)throw new $("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new vn(this._publicKey)}decrypt(e){return Df(this._key,e)}marshal(){return br.jwkToPkcs1(this._key)}get bytes(){return Oe.encode({Type:Pt.RSA,Data:this.marshal()}).subarray()}equals(e){return Kt(this.bytes,e.bytes)}hash(){let e=Ot.digest(this.bytes);return te(e)?e.then(({bytes:r})=>r):e.bytes}async id(){let e=await this.public.hash();return lt(e,"base58btc")}async export(e,r="pkcs-8"){if(r==="pkcs-8"){let n=new mn.default.util.ByteBuffer(this.marshal()),i=mn.default.asn1.fromDer(n),o=mn.default.pki.privateKeyFromAsn1(i),s={algorithm:"aes256",count:1e4,saltSize:128/8,prfAlgorithm:"sha512"};return mn.default.pki.encryptRsaPrivateKey(o,e,s)}else{if(r==="libp2p-key")return Mr(this.bytes,e);throw new $(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}};async function t1(t){let e=br.pkcs1ToJwk(t);if(li(e)>bn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let r=await ns(e);return new Hr(r.privateKey,r.publicKey)}function e1(t){let e=br.pkixToJwk(t);if(li(e)>bn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new vn(e)}async function r1(t){if(li(t)>bn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ns(t);return new Hr(e.privateKey,e.publicKey)}async function n1(t){if(t>bn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await If(t);return new Hr(e.privateKey,e.publicKey)}var us={};_t(us,{Secp256k1PrivateKey:()=>En,Secp256k1PublicKey:()=>wn,generateKeyPair:()=>m1,unmarshalSecp256k1PrivateKey:()=>g1,unmarshalSecp256k1PublicKey:()=>x1});var i1=(t,e,r)=>t&e^~t&r,o1=(t,e,r)=>t&e^t&r^e&r,s1=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),er=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rr=new Uint32Array(64),os=class extends Or{constructor(){super(64,32,8,!1),this.A=er[0]|0,this.B=er[1]|0,this.C=er[2]|0,this.D=er[3]|0,this.E=er[4]|0,this.F=er[5]|0,this.G=er[6]|0,this.H=er[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,r,n,i,o,s,a,c]}set(e,r,n,i,o,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)rr[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=rr[l-15],d=rr[l-2],h=se(p,7)^se(p,18)^p>>>3,y=se(d,17)^se(d,19)^d>>>10;rr[l]=y+rr[l-7]+h+rr[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=se(a,6)^se(a,11)^se(a,25),d=u+p+i1(a,c,f)+s1[l]+rr[l]|0,y=(se(n,2)^se(n,13)^se(n,22))+o1(n,i,o)|0;u=f,f=c,c=a,a=s+d|0,s=o,o=i,i=n,n=d+y|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,i,o,s,a,c,f,u)}roundClean(){rr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Pf=Xn(()=>new os);function a1(t){let e=hn(t);Ee(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:f1,hexToBytes:c1}=ti,wr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=wr;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:f1(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=wr,r=typeof t=="string"?c1(t):t;if(!ae(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=wr._parseInt(r.subarray(2)),{d:s,l:a}=wr._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,r=f=>{let u=f.toString(16);return u.length&1?`0${u}`:u},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),c=r(s);return`30${r(s+o+4)}02${c}${i}02${a}${n}`}},Fe=BigInt(0),ee=BigInt(1),Dv=BigInt(2),kf=BigInt(3),Pv=BigInt(4);function u1(t){let e=a1(t),{Fp:r}=e,n=e.toBytes||((h,y,g)=>{let x=y.toAffine();return Pe(Uint8Array.from([4]),r.toBytes(x.x),r.toBytes(x.y))}),i=e.fromBytes||(h=>{let y=h.subarray(1),g=r.fromBytes(y.subarray(0,r.BYTES)),x=r.fromBytes(y.subarray(r.BYTES,2*r.BYTES));return{x:g,y:x}});function o(h){let{a:y,b:g}=e,x=r.sqr(h),m=r.mul(x,h);return r.add(r.add(m,r.mul(h,y)),g)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(h){return typeof h=="bigint"&&Fe<h&&h<e.n}function a(h){if(!s(h))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(h){let{allowedPrivateKeyLengths:y,nByteLength:g,wrapPrivateKey:x,n:m}=e;if(y&&typeof h!="bigint"){if(ae(h)&&(h=Le(h)),typeof h!="string"||!y.includes(h.length))throw new Error("Invalid key");h=h.padStart(g*2,"0")}let b;try{b=typeof h=="bigint"?h:De(bt("private key",h,g))}catch{throw new Error(`private key must be ${g} bytes, hex or bigint, not ${typeof h}`)}return x&&(b=ut(b,m)),a(b),b}let f=new Map;function u(h){if(!(h instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(y,g,x){if(this.px=y,this.py=g,this.pz=x,y==null||!r.isValid(y))throw new Error("x required");if(g==null||!r.isValid(g))throw new Error("y required");if(x==null||!r.isValid(x))throw new Error("z required")}static fromAffine(y){let{x:g,y:x}=y||{};if(!y||!r.isValid(g)||!r.isValid(x))throw new Error("invalid affine point");if(y instanceof l)throw new Error("projective point not allowed");let m=b=>r.eql(b,r.ZERO);return m(g)&&m(x)?l.ZERO:new l(g,x,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(y){let g=r.invertBatch(y.map(x=>x.pz));return y.map((x,m)=>x.toAffine(g[m])).map(l.fromAffine)}static fromHex(y){let g=l.fromAffine(i(bt("pointHex",y)));return g.assertValidity(),g}static fromPrivateKey(y){return l.BASE.multiply(c(y))}_setWindowSize(y){this._WINDOW_SIZE=y,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:y,y:g}=this.toAffine();if(!r.isValid(y)||!r.isValid(g))throw new Error("bad point: x or y not FE");let x=r.sqr(g),m=o(y);if(!r.eql(x,m))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y}=this.toAffine();if(r.isOdd)return!r.isOdd(y);throw new Error("Field doesn't support isOdd")}equals(y){u(y);let{px:g,py:x,pz:m}=this,{px:b,py:_,pz:E}=y,S=r.eql(r.mul(g,E),r.mul(b,m)),L=r.eql(r.mul(x,E),r.mul(_,m));return S&&L}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:y,b:g}=e,x=r.mul(g,kf),{px:m,py:b,pz:_}=this,E=r.ZERO,S=r.ZERO,L=r.ZERO,D=r.mul(m,m),z=r.mul(b,b),q=r.mul(_,_),M=r.mul(m,b);return M=r.add(M,M),L=r.mul(m,_),L=r.add(L,L),E=r.mul(y,L),S=r.mul(x,q),S=r.add(E,S),E=r.sub(z,S),S=r.add(z,S),S=r.mul(E,S),E=r.mul(M,E),L=r.mul(x,L),q=r.mul(y,q),M=r.sub(D,q),M=r.mul(y,M),M=r.add(M,L),L=r.add(D,D),D=r.add(L,D),D=r.add(D,q),D=r.mul(D,M),S=r.add(S,D),q=r.mul(b,_),q=r.add(q,q),D=r.mul(q,M),E=r.sub(E,D),L=r.mul(q,z),L=r.add(L,L),L=r.add(L,L),new l(E,S,L)}add(y){u(y);let{px:g,py:x,pz:m}=this,{px:b,py:_,pz:E}=y,S=r.ZERO,L=r.ZERO,D=r.ZERO,z=e.a,q=r.mul(e.b,kf),M=r.mul(g,b),X=r.mul(x,_),at=r.mul(m,E),kt=r.add(g,x),T=r.add(b,_);kt=r.mul(kt,T),T=r.add(M,X),kt=r.sub(kt,T),T=r.add(g,m);let k=r.add(b,E);return T=r.mul(T,k),k=r.add(M,at),T=r.sub(T,k),k=r.add(x,m),S=r.add(_,E),k=r.mul(k,S),S=r.add(X,at),k=r.sub(k,S),D=r.mul(z,T),S=r.mul(q,at),D=r.add(S,D),S=r.sub(X,D),D=r.add(X,D),L=r.mul(S,D),X=r.add(M,M),X=r.add(X,M),at=r.mul(z,at),T=r.mul(q,T),X=r.add(X,at),at=r.sub(M,at),at=r.mul(z,at),T=r.add(T,at),M=r.mul(X,T),L=r.add(L,M),M=r.mul(k,T),S=r.mul(kt,S),S=r.sub(S,M),M=r.mul(kt,X),D=r.mul(k,D),D=r.add(D,M),new l(S,L,D)}subtract(y){return this.add(y.negate())}is0(){return this.equals(l.ZERO)}wNAF(y){return d.wNAFCached(this,f,y,g=>{let x=r.invertBatch(g.map(m=>m.pz));return g.map((m,b)=>m.toAffine(x[b])).map(l.fromAffine)})}multiplyUnsafe(y){let g=l.ZERO;if(y===Fe)return g;if(a(y),y===ee)return this;let{endo:x}=e;if(!x)return d.unsafeLadder(this,y);let{k1neg:m,k1:b,k2neg:_,k2:E}=x.splitScalar(y),S=g,L=g,D=this;for(;b>Fe||E>Fe;)b&ee&&(S=S.add(D)),E&ee&&(L=L.add(D)),D=D.double(),b>>=ee,E>>=ee;return m&&(S=S.negate()),_&&(L=L.negate()),L=new l(r.mul(L.px,x.beta),L.py,L.pz),S.add(L)}multiply(y){a(y);let g=y,x,m,{endo:b}=e;if(b){let{k1neg:_,k1:E,k2neg:S,k2:L}=b.splitScalar(g),{p:D,f:z}=this.wNAF(E),{p:q,f:M}=this.wNAF(L);D=d.constTimeNegate(_,D),q=d.constTimeNegate(S,q),q=new l(r.mul(q.px,b.beta),q.py,q.pz),x=D.add(q),m=z.add(M)}else{let{p:_,f:E}=this.wNAF(g);x=_,m=E}return l.normalizeZ([x,m])[0]}multiplyAndAddUnsafe(y,g,x){let m=l.BASE,b=(E,S)=>S===Fe||S===ee||!E.equals(m)?E.multiplyUnsafe(S):E.multiply(S),_=b(this,g).add(b(y,x));return _.is0()?void 0:_}toAffine(y){let{px:g,py:x,pz:m}=this,b=this.is0();y==null&&(y=b?r.ONE:r.inv(m));let _=r.mul(g,y),E=r.mul(x,y),S=r.mul(m,y);if(b)return{x:r.ZERO,y:r.ZERO};if(!r.eql(S,r.ONE))throw new Error("invZ was invalid");return{x:_,y:E}}isTorsionFree(){let{h:y,isTorsionFree:g}=e;if(y===ee)return!0;if(g)return g(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:y,clearCofactor:g}=e;return y===ee?this:g?g(l,this):this.multiplyUnsafe(e.h)}toRawBytes(y=!0){return this.assertValidity(),n(l,this,y)}toHex(y=!0){return Le(this.toRawBytes(y))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,d=ni(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function l1(t){let e=hn(t);return Ee(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Nf(t){let e=l1(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(T){return Fe<T&&T<r.ORDER}function a(T){return ut(T,n)}function c(T){return ei(T,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:p}=u1({...e,toBytes(T,k,R){let P=k.toAffine(),A=r.toBytes(P.x),O=Pe;return R?O(Uint8Array.from([k.hasEvenY()?2:3]),A):O(Uint8Array.from([4]),A,r.toBytes(P.y))},fromBytes(T){let k=T.length,R=T[0],P=T.subarray(1);if(k===i&&(R===2||R===3)){let A=De(P);if(!s(A))throw new Error("Point is not on curve");let O=l(A),K=r.sqrt(O),V=(K&ee)===ee;return(R&1)===1!==V&&(K=r.neg(K)),{x:A,y:K}}else if(k===o&&R===4){let A=r.fromBytes(P.subarray(0,r.BYTES)),O=r.fromBytes(P.subarray(r.BYTES,2*r.BYTES));return{x:A,y:O}}else throw new Error(`Point of length ${k} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),d=T=>Le(je(T,e.nByteLength));function h(T){let k=n>>ee;return T>k}function y(T){return h(T)?a(-T):T}let g=(T,k,R)=>De(T.slice(k,R));class x{constructor(k,R,P){this.r=k,this.s=R,this.recovery=P,this.assertValidity()}static fromCompact(k){let R=e.nByteLength;return k=bt("compactSignature",k,R*2),new x(g(k,0,R),g(k,R,2*R))}static fromDER(k){let{r:R,s:P}=wr.toSig(bt("DER",k));return new x(R,P)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(k){return new x(this.r,this.s,k)}recoverPublicKey(k){let{r:R,s:P,recovery:A}=this,O=L(bt("msgHash",k));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");let K=A===2||A===3?R+e.n:R;if(K>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let V=A&1?"03":"02",Z=f.fromHex(V+d(K)),J=c(K),ot=a(-O*J),j=a(P*J),rt=f.BASE.multiplyAndAddUnsafe(Z,ot,j);if(!rt)throw new Error("point at infinify");return rt.assertValidity(),rt}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return dr(this.toDERHex())}toDERHex(){return wr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return dr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let m={isValidPrivateKey(T){try{return u(T),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let T=ko(e.n);return X0(e.randomBytes(T),e.n)},precompute(T=8,k=f.BASE){return k._setWindowSize(T),k.multiply(BigInt(3)),k}};function b(T,k=!0){return f.fromPrivateKey(T).toRawBytes(k)}function _(T){let k=ae(T),R=typeof T=="string",P=(k||R)&&T.length;return k?P===i||P===o:R?P===2*i||P===2*o:T instanceof f}function E(T,k,R=!0){if(_(T))throw new Error("first arg must be private key");if(!_(k))throw new Error("second arg must be public key");return f.fromHex(k).multiply(u(T)).toRawBytes(R)}let S=e.bits2int||function(T){let k=De(T),R=T.length*8-e.nBitLength;return R>0?k>>BigInt(R):k},L=e.bits2int_modN||function(T){return a(S(T))},D=ln(e.nBitLength);function z(T){if(typeof T!="bigint")throw new Error("bigint expected");if(!(Fe<=T&&T<D))throw new Error(`bigint expected < 2^${e.nBitLength}`);return je(T,e.nByteLength)}function q(T,k,R=M){if(["recovered","canonical"].some(mt=>mt in R))throw new Error("sign() legacy options not supported");let{hash:P,randomBytes:A}=e,{lowS:O,prehash:K,extraEntropy:V}=R;O==null&&(O=!0),T=bt("msgHash",T),K&&(T=bt("prehashed msgHash",P(T)));let Z=L(T),J=u(k),ot=[z(J),z(Z)];if(V!=null){let mt=V===!0?A(r.BYTES):V;ot.push(bt("extraEntropy",mt))}let j=Pe(...ot),rt=Z;function wt(mt){let Nt=S(mt);if(!p(Nt))return;let Ut=c(Nt),Bt=f.BASE.multiply(Nt).toAffine(),Ft=a(Bt.x);if(Ft===Fe)return;let Se=a(Ut*a(rt+Ft*J));if(Se===Fe)return;let or=(Bt.x===Ft?0:2)|Number(Bt.y&ee),Jr=Se;return O&&h(Se)&&(Jr=y(Se),or^=1),new x(Ft,Jr,or)}return{seed:j,k2sig:wt}}let M={lowS:e.lowS,prehash:!1},X={lowS:e.lowS,prehash:!1};function at(T,k,R=M){let{seed:P,k2sig:A}=q(T,k,R),O=e;return Ro(O.hash.outputLen,O.nByteLength,O.hmac)(P,A)}f.BASE._setWindowSize(8);function kt(T,k,R,P=X){let A=T;if(k=bt("msgHash",k),R=bt("publicKey",R),"strict"in P)throw new Error("options.strict was renamed to lowS");let{lowS:O,prehash:K}=P,V,Z;try{if(typeof A=="string"||ae(A))try{V=x.fromDER(A)}catch(Bt){if(!(Bt instanceof wr.Err))throw Bt;V=x.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){let{r:Bt,s:Ft}=A;V=new x(Bt,Ft)}else throw new Error("PARSE");Z=f.fromHex(R)}catch(Bt){if(Bt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(O&&V.hasHighS())return!1;K&&(k=e.hash(k));let{r:J,s:ot}=V,j=L(k),rt=c(ot),wt=a(j*rt),mt=a(J*rt),Nt=f.BASE.multiplyAndAddUnsafe(Z,wt,mt)?.toAffine();return Nt?a(Nt.x)===J:!1}return{CURVE:e,getPublicKey:b,getSharedSecret:E,sign:at,verify:kt,ProjectivePoint:f,Signature:x,utils:m}}var hi=class extends Nr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,K0(e);let n=un(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return kr(this),this.iHash.update(e),this}digestInto(e){kr(this),So(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ss=(t,e,r)=>new hi(t,e).update(r).digest();ss.create=(t,e)=>new hi(t,e);function h1(t){return{hash:t,hmac:(e,...r)=>ss(t,e,Qn(...r)),randomBytes:Ur}}function Uf(t,e){let r=n=>Nf({...t,...h1(n)});return Object.freeze({...r(e),create:r})}var Ff=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Of=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d1=BigInt(1),as=BigInt(2),Kf=(t,e)=>(t+e/as)/e;function p1(t){let e=Ff,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=xt(u,r,e)*u%e,p=xt(l,r,e)*u%e,d=xt(p,as,e)*f%e,h=xt(d,i,e)*d%e,y=xt(h,o,e)*h%e,g=xt(y,a,e)*y%e,x=xt(g,c,e)*g%e,m=xt(x,a,e)*y%e,b=xt(m,r,e)*u%e,_=xt(b,s,e)*h%e,E=xt(_,n,e)*f%e,S=xt(E,as,e);if(!fs.eql(fs.sqr(S),t))throw new Error("Cannot find square root");return S}var fs=ri(Ff,void 0,void 0,{sqrt:p1}),de=Uf({a:BigInt(0),b:BigInt(7),Fp:fs,n:Of,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=Of,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-d1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=Kf(o*t,e),c=Kf(-n*t,e),f=ut(t-a*r-c*i,e),u=ut(-a*n-c*o,e),l=f>s,p=u>s;if(l&&(f=e-f),p&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},Pf),$v=BigInt(0);var Gv=de.ProjectivePoint;function Mf(){return de.utils.randomPrivateKey()}function Vf(t,e){let r=Ot.digest(e instanceof Uint8Array?e:e.subarray());if(te(r))return r.then(({digest:n})=>de.sign(n,t).toDERRawBytes()).catch(n=>{throw new $(String(n),"ERR_INVALID_INPUT")});try{return de.sign(r.digest,t).toDERRawBytes()}catch(n){throw new $(String(n),"ERR_INVALID_INPUT")}}function qf(t,e,r){let n=Ot.digest(r instanceof Uint8Array?r:r.subarray());if(te(n))return n.then(({digest:i})=>de.verify(e,i,t)).catch(i=>{throw new $(String(i),"ERR_INVALID_INPUT")});try{return de.verify(e,n.digest,t)}catch(i){throw new $(String(i),"ERR_INVALID_INPUT")}}function zf(t){return de.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Hf(t){try{de.getPublicKey(t,!0)}catch(e){throw new $(String(e),"ERR_INVALID_PRIVATE_KEY")}}function cs(t){try{de.ProjectivePoint.fromHex(t)}catch(e){throw new $(String(e),"ERR_INVALID_PUBLIC_KEY")}}function $f(t){try{return de.getPublicKey(t,!0)}catch(e){throw new $(String(e),"ERR_INVALID_PRIVATE_KEY")}}var wn=class{_key;constructor(e){cs(e),this._key=e}verify(e,r){return qf(this._key,r,e)}marshal(){return zf(this._key)}get bytes(){return Ue.encode({Type:Pt.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Kt(this.bytes,e.bytes)}async hash(){let e=Ot.digest(this.bytes),r;return te(e)?{bytes:r}=await e:r=e.bytes,r}},En=class{_key;_publicKey;constructor(e,r){this._key=e,this._publicKey=r??$f(e),Hf(this._key),cs(this._publicKey)}sign(e){return Vf(this._key,e)}get public(){return new wn(this._publicKey)}marshal(){return this._key}get bytes(){return Oe.encode({Type:Pt.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Kt(this.bytes,e.bytes)}hash(){let e=Ot.digest(this.bytes);return te(e)?e.then(({bytes:r})=>r):e.bytes}async id(){let e=await this.public.hash();return lt(e,"base58btc")}async export(e,r="libp2p-key"){if(r==="libp2p-key")return Mr(this.bytes,e);throw new $(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function g1(t){return new En(t)}function x1(t){return new wn(t)}async function m1(){let t=Mf();return new En(t)}var Gf={rsa:is,ed25519:jo,secp256k1:us};function b1(t){let e=Object.keys(Gf).join(" / ");return new $(`invalid or unsupported key type ${t}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function ls(t){if(t=t.toLowerCase(),t==="rsa"||t==="ed25519"||t==="secp256k1")return Gf[t];throw b1(t)}async function Wf(t,e){return ls(t).generateKeyPair(e??2048)}function Yf(t,e){return e=(e??"rsa").toLowerCase(),ls(e),t.bytes}function Zf(t,e){return e=(e??"rsa").toLowerCase(),ls(e),t.bytes}var hs;(function(t){let e;t.codec=()=>(e==null&&(e=he((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.id!=null&&(n.uint32(10),n.bytes(r.id)),r.pubKey!=null&&(n.uint32(18),n.bytes(r.pubKey)),r.privKey!=null&&(n.uint32(26),n.bytes(r.privKey)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos<o;){let s=r.uint32();switch(s>>>3){case 1:i.id=r.bytes();break;case 2:i.pubKey=r.bytes();break;case 3:i.privKey=r.bytes();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>le(r,t.codec()),t.decode=r=>ue(r,t.codec())})(hs||(hs={}));var Qf=async()=>{let t=await Wf("Ed25519"),e=await w1(t);if(e.type==="Ed25519")return e;throw new Error(`Generated unexpected PeerId type "${e.type}"`)};async function w1(t){return ga(Yf(t.public),Zf(t))}var E1=Math.pow(2,7),S1=Math.pow(2,14),B1=Math.pow(2,21),ds=Math.pow(2,28),ps=Math.pow(2,35),ys=Math.pow(2,42),gs=Math.pow(2,49),it=128,zt=127;function Zt(t){if(t<E1)return 1;if(t<S1)return 2;if(t<B1)return 3;if(t<ds)return 4;if(t<ps)return 5;if(t<ys)return 6;if(t<gs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function A1(t,e,r=0){switch(Zt(t)){case 8:e[r++]=t&255|it,t/=128;case 7:e[r++]=t&255|it,t/=128;case 6:e[r++]=t&255|it,t/=128;case 5:e[r++]=t&255|it,t/=128;case 4:e[r++]=t&255|it,t>>>=7;case 3:e[r++]=t&255|it,t>>>=7;case 2:e[r++]=t&255|it,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function I1(t,e,r=0){switch(Zt(t)){case 8:e.set(r++,t&255|it),t/=128;case 7:e.set(r++,t&255|it),t/=128;case 6:e.set(r++,t&255|it),t/=128;case 5:e.set(r++,t&255|it),t/=128;case 4:e.set(r++,t&255|it),t>>>=7;case 3:e.set(r++,t&255|it),t>>>=7;case 2:e.set(r++,t&255|it),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function T1(t,e){let r=t[e],n=0;if(n+=r&zt,r<it||(r=t[e+1],n+=(r&zt)<<7,r<it)||(r=t[e+2],n+=(r&zt)<<14,r<it)||(r=t[e+3],n+=(r&zt)<<21,r<it)||(r=t[e+4],n+=(r&zt)*ds,r<it)||(r=t[e+5],n+=(r&zt)*ps,r<it)||(r=t[e+6],n+=(r&zt)*ys,r<it)||(r=t[e+7],n+=(r&zt)*gs,r<it))return n;throw new RangeError("Could not decode varint")}function C1(t,e){let r=t.get(e),n=0;if(n+=r&zt,r<it||(r=t.get(e+1),n+=(r&zt)<<7,r<it)||(r=t.get(e+2),n+=(r&zt)<<14,r<it)||(r=t.get(e+3),n+=(r&zt)<<21,r<it)||(r=t.get(e+4),n+=(r&zt)*ds,r<it)||(r=t.get(e+5),n+=(r&zt)*ps,r<it)||(r=t.get(e+6),n+=(r&zt)*ys,r<it)||(r=t.get(e+7),n+=(r&zt)*gs,r<it))return n;throw new RangeError("Could not decode varint")}function nr(t,e,r=0){return e==null&&(e=Vt(Zt(t))),e instanceof Uint8Array?A1(t,e,r):I1(t,e,r)}function Me(t,e=0){return t instanceof Uint8Array?T1(t,e):C1(t,e)}var pi=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,i){return this.readAtomically(()=>{let o=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*i)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let p=Number.parseInt(l,e);if(!Number.isNaN(p))return p});if(u===void 0)break;if(o*=e,o+=u,o>f||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let i=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[i]=s[0],r[i+1]=s[1],r[i+2]=s[2],r[i+3]=s[3],[i+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];r[i]=o>>8,r[i+1]=o&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,i]=e(r);if(n===16)return r;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),s=16-(n+2),[a]=e(o.subarray(0,s));return r.set(o.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Xf=45,_1=15,$r=new pi;function xs(t){if(!(t.length>_1))return $r.new(t).parseWith(()=>$r.readIPv4Addr())}function ms(t){if(t.includes("%")&&(t=t.split("%")[0]),!(t.length>Xf))return $r.new(t).parseWith(()=>$r.readIPv6Addr())}function yi(t){if(t.includes("%")&&(t=t.split("%")[0]),!(t.length>Xf))return $r.new(t).parseWith(()=>$r.readIPAddr())}var kb=parseInt("0xFFFF",16),Nb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function tc(t){return!!xs(t)}function ec(t){return!!ms(t)}function Gr(t){return!!yi(t)}var rc=tc,k1=ec,vs=function(t){let e=0;if(t=t.toString().trim(),rc(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(k1(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let o=rc(r[n]),s;o&&(s=vs(r[n]),r[n]=lt(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,lt(s.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let o=[n,1];for(n=9-r.length;n>0;n--)o.push("0");r.splice.apply(r,o)}let i=new Uint8Array(e+16);for(n=0;n<r.length;n++){let o=parseInt(r[n],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},nc=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let i=[];for(let o=0;o<r;o++)i.push(t[e+o]);return i.join(".")}if(r===16){let i=[];for(let o=0;o<r;o+=2)i.push(n.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Wr={},bs={},U1=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];U1.forEach(t=>{let e=O1(...t);bs[e.code]=e,Wr[e.name]=e});function O1(t,e,r,n,i){return{code:t,size:e,name:r,resolvable:!!n,path:!!i}}function st(t){if(typeof t=="number"){if(bs[t]!=null)return bs[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Wr[t]!=null)return Wr[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var m4=st("ip4"),v4=st("ip6"),b4=st("ipcidr");function Es(t,e){switch(st(t).code){case 4:case 41:return F1(e);case 42:return sc(e);case 6:case 273:case 33:case 132:return fc(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return sc(e);case 421:return z1(e);case 444:return ac(e);case 445:return ac(e);case 466:return q1(e);default:return lt(e,"base16")}}function Ss(t,e){switch(st(t).code){case 4:return ic(e);case 41:return ic(e);case 42:return oc(e);case 6:case 273:case 33:case 132:return Bs(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return oc(e);case 421:return M1(e);case 444:return H1(e);case 445:return $1(e);case 466:return V1(e);default:return It(e,"base16")}}var ws=Object.values(He).map(t=>t.decoder),K1=function(){let t=ws[0].or(ws[1]);return ws.slice(2).forEach(e=>t=t.or(e)),t}();function ic(t){if(!Gr(t))throw new Error("invalid ip address");return vs(t)}function F1(t){let e=nc(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Gr(e))throw new Error("invalid ip address");return e}function Bs(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function fc(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function oc(t){let e=It(t),r=Uint8Array.from(nr(e.length));return Tt([r,e],r.length+e.length)}function sc(t){let e=Me(t);if(t=t.slice(Zt(e)),t.length!==e)throw new Error("inconsistent lengths");return lt(t)}function M1(t){let e;t[0]==="Q"||t[0]==="1"?e=sr(At.decode(`z${t}`)).bytes:e=re.parse(t).multihash.bytes;let r=Uint8Array.from(nr(e.length));return Tt([r,e],r.length+e.length)}function V1(t){let e=K1.decode(t),r=Uint8Array.from(nr(e.length));return Tt([r,e],r.length+e.length)}function q1(t){let e=Me(t),r=t.slice(Zt(e));if(r.length!==e)throw new Error("inconsistent lengths");return"u"+lt(r,"base64url")}function z1(t){let e=Me(t),r=t.slice(Zt(e));if(r.length!==e)throw new Error("inconsistent lengths");return lt(r,"base58btc")}function H1(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=Ae.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Bs(n);return Tt([r,i],r.length+i.length)}function $1(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=Ae.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Bs(n);return Tt([r,i],r.length+i.length)}function ac(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=lt(e,"base32"),i=fc(r);return`${n}:${i}`}function cc(t){t=As(t);let e=[],r=[],n=null,i=t.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){let s=i[o],a=st(s);if(a.size===0){e.push([a.code]),r.push([a.code]);continue}if(o++,o>=i.length)throw lc("invalid address: "+t);if(a.path===!0){n=As(i.slice(o).join("/")),e.push([a.code,Ss(a.code,n)]),r.push([a.code,n]);break}let c=Ss(a.code,i[o]);e.push([a.code,c]),r.push([a.code,Es(a.code,c)])}return{string:uc(r),bytes:Ts(e),tuples:e,stringTuples:r,path:n}}function Is(t){let e=[],r=[],n=null,i=0;for(;i<t.length;){let o=Me(t,i),s=Zt(o),a=st(o),c=G1(a,t.slice(i+s));if(c===0){e.push([o]),r.push([o]),i+=s;continue}let f=t.slice(i+s,i+s+c);if(i+=c+s,i>t.length)throw lc("Invalid address Uint8Array: "+lt(t,"base16"));e.push([o,f]);let u=Es(o,f);if(r.push([o,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(t),string:uc(r),tuples:e,stringTuples:r,path:n}}function uc(t){let e=[];return t.map(r=>{let n=st(r[0]);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),As(e.join("/"))}function Ts(t){return Tt(t.map(e=>{let r=st(e[0]),n=Uint8Array.from(nr(r.code));return e.length>1&&e[1]!=null&&(n=Tt([n,e[1]])),n}))}function G1(t,e){if(t.size>0)return t.size/8;if(t.size===0)return 0;{let r=Me(e instanceof Uint8Array?e:Uint8Array.from(e));return r+Zt(r)}}function As(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function lc(t){return new Error("Error parsing address: "+t)}var W1=Symbol.for("nodejs.util.inspect.custom"),Cs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Y1=[st("dns").code,st("dns4").code,st("dns6").code,st("dnsaddr").code],gi=class t{bytes;#e;#t;#r;#n;[Cs]=!0;constructor(e){e==null&&(e="");let r;if(e instanceof Uint8Array)r=Is(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);r=cc(e)}else if(dc(e))r=Is(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#e=r.string,this.#t=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,r,n,i,o="",s=st("tcp"),a=st("udp"),c=st("ip4"),f=st("ip6"),u=st("dns6"),l=st("ip6zone");for(let[d,h]of this.stringTuples())d===l.code&&(o=`%${h??""}`),Y1.includes(d)&&(r=s.name,i=443,n=`${h??""}${o}`,e=d===u.code?6:4),(d===s.code||d===a.code)&&(r=st(d).name,i=parseInt(h??"")),(d===c.code||d===f.code)&&(r=st(d).name,n=`${h??""}${o}`,e=d===f.code?6:4);if(e==null||r==null||n==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:i}}protos(){return this.#t.map(([e])=>Object.assign({},st(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>st(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),i=n.lastIndexOf(r);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,i))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(Ts(r.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===Wr.p2p.code&&e.push([n,i]),n===Wr["p2p-circuit"].code&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?lt(At.decode(`z${n}`),"base58btc"):lt(re.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Kt(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(o=>o.resolvable);if(r==null)return[this];let n=hc.get(r.name);if(n==null)throw new $(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(o=>new t(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[W1](){return`Multiaddr(${this.#e})`}};var hc=new Map;function dc(t){return!!t?.[Cs]}function xi(t){return new gi(t)}function Z1(t){return t[Symbol.asyncIterator]!=null}function Q1(t){if(Z1(t))return(async()=>{for await(let e of t)return e})();for(let e of t)return e}var _s=Q1;var yc=Symbol.for("@achingbrain/uint8arraylist");function pc(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let i=r+n.byteLength;if(e<i)return{buf:n,index:e-r};r=i}throw new RangeError("index is out of bounds")}function mi(t){return!!t?.[yc]}var Yr=class t{bufs;length;[yc]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(mi(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(mi(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=pc(this.bufs,e);return r.buf[r.index]}set(e,r){let n=pc(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(mi(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:i}=this._subList(e,r);return Tt(n,i)}subarray(e,r){let{bufs:n,length:i}=this._subList(e,r);return n.length===1?n[0]:Tt(n,i)}sublist(e,r){let{bufs:n,length:i}=this._subList(e,r),o=new t;return o.length=i,o.bufs=[...n],o}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],i=0;for(let o=0;o<this.bufs.length;o++){let s=this.bufs[o],a=i,c=a+s.byteLength;if(i=c,e>=c)continue;let f=e>=a&&e<c,u=r>a&&r<=c;if(f&&u){if(e===a&&r===c){n.push(s);break}let l=e-a;n.push(s.subarray(l,l+(r-e)));break}if(f){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!mi(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let o=256,s=new Int32Array(o);for(let l=0;l<o;l++)s[l]=-1;for(let l=0;l<i;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=c;l+=u){u=0;for(let p=f;p>=0;p--){let d=this.get(l+p);if(n[p]!==d){u=Math.max(1,p-a[d]);break}}if(u===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let i=_e(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,r,n),this.write(i,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let i=_e(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,r,n),this.write(i,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let i=_e(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,r,n),this.write(i,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let i=_e(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,r,n),this.write(i,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let i=_e(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,r,n),this.write(i,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let i=_e(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,r,n),this.write(i,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let i=_e(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,r,n),this.write(i,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let i=_e(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,r,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!Kt(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((i,o)=>i+o.byteLength,0)),n.length=r,n}};function vi(t){return t[Symbol.asyncIterator]!=null}var bi=t=>{let e=Zt(t),r=Vt(e);return nr(t,r),bi.bytes=e,r};bi.bytes=0;function Sn(t,e){e=e??{};let r=e.lengthEncoder??bi;function*n(i){let o=r(i.byteLength);o instanceof Uint8Array?yield o:yield*o,i instanceof Uint8Array?yield i:yield*i}return vi(t)?async function*(){for await(let i of t)yield*n(i)}():function*(){for(let i of t)yield*n(i)}()}Sn.single=(t,e)=>{e=e??{};let r=e.lengthEncoder??bi;return new Yr(r(t.byteLength),t)};var Zr=Mt(mc(),1);var J1=8,j1=1024*1024*4,Er;(function(t){t[t.LENGTH=0]="LENGTH",t[t.DATA=1]="DATA"})(Er||(Er={}));var Rs=t=>{let e=Me(t);return Rs.bytes=Zt(e),e};Rs.bytes=0;function Qr(t,e){let r=new Yr,n=Er.LENGTH,i=-1,o=e?.lengthDecoder??Rs,s=e?.maxLengthLength??J1,a=e?.maxDataLength??j1;function*c(){for(;r.byteLength>0;){if(n===Er.LENGTH)try{if(i=o(r),i<0)throw(0,Zr.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(i>a)throw(0,Zr.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let f=o.bytes;r.consume(f),e?.onLength!=null&&e.onLength(i),n=Er.DATA}catch(f){if(f instanceof RangeError){if(r.byteLength>s)throw(0,Zr.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw f}if(n===Er.DATA){if(r.byteLength<i)break;let f=r.sublist(0,i);r.consume(i),e?.onData!=null&&e.onData(f),yield f,n=Er.LENGTH}}}return vi(t)?async function*(){for await(let f of t)r.append(f),yield*c();if(r.byteLength>0)throw(0,Zr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let f of t)r.append(f),yield*c();if(r.byteLength>0)throw(0,Zr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}Qr.fromReader=(t,e)=>{let r=1,n=async function*(){for(;;)try{let{done:o,value:s}=await t.next(r);if(o===!0)return;s!=null&&(yield s)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{r=1}}();return Qr(n,{...e??{},onLength:o=>{r=o}})};function ey(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var vc=ey;function ry(t){return t[Symbol.asyncIterator]!=null}function ny(t,e){if(ry(t))return async function*(){for await(let a of t)yield e(a)}();let r=vc(t),{value:n,done:i}=r.next();if(i===!0)return function*(){}();let o=e(n);if(typeof o.then=="function")return async function*(){yield await o;for await(let a of r)yield e(a)}();let s=e;return function*(){yield o;for(let a of r)yield s(a)}()}var bc=ny;function Ve(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var wi=globalThis.CustomEvent??Event;async function*Ls(t,e={}){let r=e.concurrency??1/0;r<1&&(r=1/0);let n=e.ordered==null?!1:e.ordered,i=new EventTarget,o=[],s=Ve(),a=Ve(),c=!1,f,u=!1;i.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let h of t){if(o.length===r&&(s=Ve(),await s.promise),u)break;let y={done:!1};o.push(y),h().then(g=>{y.done=!0,y.ok=!0,y.value=g,i.dispatchEvent(new wi("task-complete"))},g=>{y.done=!0,y.err=g,i.dispatchEvent(new wi("task-complete"))})}c=!0,i.dispatchEvent(new wi("task-complete"))}catch(h){f=h,i.dispatchEvent(new wi("task-complete"))}});function l(){return n?o[0]?.done:!!o.find(h=>h.done)}function*p(){for(;o.length>0&&o[0].done;){let h=o[0];if(o.shift(),h.ok)yield h.value;else throw u=!0,s.resolve(),h.err;s.resolve()}}function*d(){for(;l();)for(let h=0;h<o.length;h++)if(o[h].done){let y=o[h];if(o.splice(h,1),h--,y.ok)yield y.value;else throw u=!0,s.resolve(),y.err;s.resolve()}}for(;;){if(l()||(a=Ve(),await a.promise),f!=null)throw f;if(n?yield*p():yield*d(),c&&o.length===0)break}}var Ei=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Xr=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ei(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new Ei(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Ds=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function Si(t={}){return iy(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function iy(t,e){e=e??{};let r=e.onEnd,n=new Xr,i,o,s,a=Ve(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((g,x)=>{o=m=>{o=null,n.push(m);try{g(t(n))}catch(b){x(b)}return i}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=Ve()})}},f=g=>o!=null?o(g):(n.push(g),i),u=g=>(n=new Xr,o!=null?o({error:g}):(n.push({error:g}),i)),l=g=>{if(s)return i;if(e?.objectMode!==!0&&g?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:g})},p=g=>s?i:(s=!0,g!=null?u(g):f({done:!0})),d=()=>(n=new Xr,p(),{done:!0}),h=g=>(p(g),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:c,return:d,throw:h,push:l,end:p,get readableLength(){return n.size},onEmpty:async g=>{let x=g?.signal;if(x?.throwIfAborted(),n.isEmpty())return;let m,b;x!=null&&(m=new Promise((_,E)=>{b=()=>{E(new Ds)},x.addEventListener("abort",b)}));try{await Promise.race([a.promise,m])}finally{b!=null&&x!=null&&x?.removeEventListener("abort",b)}}},r==null)return i;let y=i;return i={[Symbol.asyncIterator](){return this},next(){return y.next()},throw(g){return y.throw(g),r!=null&&(r(g),r=void 0),{done:!0}},return(){return y.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(g){return y.end(g),r!=null&&(r(g),r=void 0),i},get readableLength(){return y.readableLength},onEmpty:g=>y.onEmpty(g)},i}function oy(t){return t[Symbol.asyncIterator]!=null}function sy(...t){let e=[];for(let r of t)oy(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=Si({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async n=>{for await(let i of n)r.push(i)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var wc=sy;function ks(t,...e){if(t==null)throw new Error("Empty pipeline");if(Ps(t)){let n=t;t=()=>n.source}else if(Sc(t)||Ec(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&Ps(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)Ps(r[n])&&(r[n]=fy(r[n]));return ay(...r)}var ay=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},Ec=t=>t?.[Symbol.asyncIterator]!=null,Sc=t=>t?.[Symbol.iterator]!=null,Ps=t=>t==null?!1:t.sink!=null&&t.source!=null,fy=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=Si({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let i,o=t.source;if(Ec(o))i=async function*(){yield*o,n.end()};else if(Sc(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return wc(n,i())}return t.source};var Rc=Mt(Bc(),1);var Ac="[a-fA-F\\d:]",ir=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${Ac})|(?<=${Ac})(?=\\s|$))`:"",pe="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",St="[a-fA-F\\d]{1,4}",Bi=`
2
+ "use strict";var Libp2PAutonat=(()=>{var Cl=Object.create;var tn=Object.defineProperty;var Ul=Object.getOwnPropertyDescriptor;var Pl=Object.getOwnPropertyNames;var Dl=Object.getPrototypeOf,Ol=Object.prototype.hasOwnProperty;var en=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ut=(r,t)=>{for(var e in t)tn(r,e,{get:t[e],enumerable:!0})},Ii=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pl(t))!Ol.call(r,s)&&s!==e&&tn(r,s,{get:()=>t[s],enumerable:!(n=Ul(t,s))||n.enumerable});return r};var rn=(r,t,e)=>(e=r!=null?Cl(Dl(r)):{},Ii(t||!r||!r.__esModule?tn(e,"default",{value:r,enumerable:!0}):e,r)),Vl=r=>Ii(tn({},"__esModule",{value:!0}),r);var Ta=en(gr=>{"use strict";var gh="[object ArrayBuffer]",ae=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===gh}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){let n=r.toUint8Array(t),s=r.toUint8Array(e);if(n.length!==s.byteLength)return!1;for(let o=0;o<n.length;o++)if(n[o]!==s[o])return!1;return!0}static concat(...t){let e;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?e=t[0]:t[t.length-1]instanceof Function?e=t.slice(0,t.length-1):e=t;let n=0;for(let i of e)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of e){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return t[t.length-1]instanceof Function?this.toView(s,t[t.length-1]):s.buffer}},Lo="string",mh=/^[0-9a-f]+$/i,yh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,bh=/^[a-zA-Z0-9-_]+$/,Bn=class{static fromString(t){let e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n.buffer}static toString(t){let e=ae.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return decodeURIComponent(escape(n))}},_t=class{static toString(t,e=!1){let n=ae.toArrayBuffer(t),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,e);o+=String.fromCharCode(a)}return o}static fromString(t,e=!1){let n=new ArrayBuffer(t.length*2),s=new DataView(n);for(let o=0;o<t.length;o++)s.setUint16(o*2,t.charCodeAt(o),e);return n}},An=class r{static isHex(t){return typeof t===Lo&&mh.test(t)}static isBase64(t){return typeof t===Lo&&yh.test(t)}static isBase64Url(t){return typeof t===Lo&&bh.test(t)}static ToString(t,e="utf8"){let n=ae.toUint8Array(t);switch(e.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return _t.toString(n,!0);case"utf16":case"utf16be":return _t.toString(n);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return _t.fromString(t,!0);case"utf16":case"utf16be":return _t.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=ae.toUint8Array(t);if(typeof btoa<"u"){let n=this.ToString(e,"binary");return btoa(n)}else return Buffer.from(e).toString("base64")}static FromBase64(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return Bn.fromString(t);case"utf16":case"utf16be":return _t.fromString(t);case"utf16le":case"usc2":return _t.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return Bn.toString(t);case"utf16":case"utf16be":return _t.toString(t);case"utf16le":case"usc2":return _t.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){let e=t.length,n=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);return n.buffer}static ToBinary(t){let e=ae.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=ae.toUint8Array(t),n="",s=e.length;for(let o=0;o<s;o++){let i=e[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);let n=new Uint8Array(e.length/2);for(let s=0;s<e.length;s=s+2){let o=e.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(t,e=!1){return _t.toString(t,e)}static FromUtf16String(t,e=!1){return _t.fromString(t,e)}static Base64Padding(t){let e=4-t.length%4;if(e<4)for(let n=0;n<e;n++)t+="=";return t}static formatString(t){return t?.replace(/[\n\r\t ]/g,"")||""}};An.DEFAULT_UTF8_ENCODING="utf8";function wh(r,...t){let e=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)e[o]=s[o]}return e}function xh(...r){let t=r.map(s=>s.byteLength).reduce((s,o)=>s+o),e=new Uint8Array(t),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)e[n++]=o}),e.buffer}function vh(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<r.byteLength;s++)if(e[s]!==n[s])return!1;return!0}gr.BufferSourceConverter=ae;gr.Convert=An;gr.assign=wh;gr.combine=xh;gr.isEqual=vh});var al=en((Mb,il)=>{"use strict";function ol(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Cd(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return ol(r,e)}catch{e.message=r.message,e.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),ol(new s,e)}}il.exports=Cd});var dl=en(Qr=>{(function(){var r,t,e,n,s,o,i,a;a=function(c){var l,h,u,m;return l=(c&255<<24)>>>24,h=(c&255<<16)>>>16,u=(c&65280)>>>8,m=c&255,[l,h,u,m].join(".")},i=function(c){var l,h,u,m,f,p;for(l=[],u=m=0;m<=3&&c.length!==0;u=++m){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}p=t(c),f=p[0],h=p[1],c=c.substring(h),l.push(f)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},e=function(c){return c.charCodeAt(0)},n=e("0"),o=e("a"),s=e("A"),t=function(c){var l,h,u,m,f;for(m=0,l=10,h="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,l=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,l=8,h="7")),f=u;u<c.length;){if("0"<=c[u]&&c[u]<=h)m=m*l+(e(c[u])-n)>>>0;else if(l===16)if("a"<=c[u]&&c[u]<="f")m=m*l+(10+e(c[u])-o)>>>0;else if("A"<=c[u]&&c[u]<="F")m=m*l+(10+e(c[u])-s)>>>0;else break;else break;if(m>4294967295)throw new Error("too large");u++}if(u===f)throw new Error("empty octet");return[m,u]},r=function(){function c(l,h){var u,m,f,p;if(typeof l!="string")throw new Error("Missing `net' parameter");if(h||(p=l.split("/",2),l=p[0],h=p[1]),h||(h=32),typeof h=="string"&&h.indexOf(".")>-1){try{this.maskLong=i(h)}catch(d){throw u=d,new Error("Invalid mask: "+h)}for(m=f=32;f>=0;m=--f)if(this.maskLong===4294967295<<32-m>>>0){this.bitmask=m;break}}else if(h||h===0)this.bitmask=parseInt(h,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(l)&this.maskLong)>>>0}catch(d){throw u=d,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+h);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(i(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var h,u,m;for(m=i(this.first),u=i(this.last),h=0;m<=u;)l(a(m),m,h),h++,m++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),Qr.ip2long=i,Qr.long2ip=a,Qr.Netmask=r}).call(Qr)});var yl=en((ml,As)=>{(function(r){"use strict";let t="(0?\\d+|0x[a-f0-9]+)",e={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},n=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",i="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${i})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${i})|(?:::)(?:${i})?)${t}\\.${t}\\.${t}\\.${t}(${o})?$`,"i")};function c(f,p){if(f.indexOf("::")!==f.lastIndexOf("::"))return null;let d=0,g=-1,y=(f.match(a.zoneIndex)||[])[0],b,w;for(y&&(y=y.substring(1),f=f.replace(/%.+$/,""));(g=f.indexOf(":",g+1))>=0;)d++;if(f.substr(0,2)==="::"&&d--,f.substr(-2,2)==="::"&&d--,d>p)return null;for(w=p-d,b=":";w--;)b+="0:";return f=f.replace("::",b),f[0]===":"&&(f=f.slice(1)),f[f.length-1]===":"&&(f=f.slice(0,-1)),p=function(){let k=f.split(":"),v=[];for(let A=0;A<k.length;A++)v.push(parseInt(k[A],16));return v}(),{parts:p,zoneId:y}}function l(f,p,d,g){if(f.length!==p.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let y=0,b;for(;g>0;){if(b=d-g,b<0&&(b=0),f[y]>>b!==p[y]>>b)return!1;g-=d,y+=1}return!0}function h(f){if(s.test(f))return parseInt(f,16);if(f[0]==="0"&&!isNaN(parseInt(f[1],10))){if(n.test(f))return parseInt(f,8);throw new Error(`ipaddr: cannot parse ${f} as octal`)}return parseInt(f,10)}function u(f,p){for(;f.length<p;)f=`0${f}`;return f}let m={};m.IPv4=function(){function f(p){if(p.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let d,g;for(d=0;d<p.length;d++)if(g=p[d],!(0<=g&&g<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=p}return f.prototype.SpecialRanges={unspecified:[[new f([0,0,0,0]),8]],broadcast:[[new f([255,255,255,255]),32]],multicast:[[new f([224,0,0,0]),4]],linkLocal:[[new f([169,254,0,0]),16]],loopback:[[new f([127,0,0,0]),8]],carrierGradeNat:[[new f([100,64,0,0]),10]],private:[[new f([10,0,0,0]),8],[new f([172,16,0,0]),12],[new f([192,168,0,0]),16]],reserved:[[new f([192,0,0,0]),24],[new f([192,0,2,0]),24],[new f([192,88,99,0]),24],[new f([198,18,0,0]),15],[new f([198,51,100,0]),24],[new f([203,0,113,0]),24],[new f([240,0,0,0]),4]]},f.prototype.kind=function(){return"ipv4"},f.prototype.match=function(p,d){let g;if(d===void 0&&(g=p,p=g[0],d=g[1]),p.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return l(this.octets,p.octets,8,d)},f.prototype.prefixLengthFromSubnetMask=function(){let p=0,d=!1,g={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},y,b,w;for(y=3;y>=0;y-=1)if(b=this.octets[y],b in g){if(w=g[b],d&&w!==0)return null;w!==8&&(d=!0),p+=w}else return null;return 32-p},f.prototype.range=function(){return m.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){return this.octets.slice(0)},f.prototype.toIPv4MappedAddress=function(){return m.IPv6.parse(`::ffff:${this.toString()}`)},f.prototype.toNormalizedString=function(){return this.toString()},f.prototype.toString=function(){return this.octets.join(".")},f}(),m.IPv4.broadcastAddressFromCIDR=function(f){try{let p=this.parseCIDR(f),d=p[0].toByteArray(),g=this.subnetMaskFromPrefixLength(p[1]).toByteArray(),y=[],b=0;for(;b<4;)y.push(parseInt(d[b],10)|parseInt(g[b],10)^255),b++;return new this(y)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},m.IPv4.isIPv4=function(f){return this.parser(f)!==null},m.IPv4.isValid=function(f){try{return new this(this.parser(f)),!0}catch{return!1}},m.IPv4.isValidFourPartDecimal=function(f){return!!(m.IPv4.isValid(f)&&f.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},m.IPv4.networkAddressFromCIDR=function(f){let p,d,g,y,b;try{for(p=this.parseCIDR(f),g=p[0].toByteArray(),b=this.subnetMaskFromPrefixLength(p[1]).toByteArray(),y=[],d=0;d<4;)y.push(parseInt(g[d],10)&parseInt(b[d],10)),d++;return new this(y)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},m.IPv4.parse=function(f){let p=this.parser(f);if(p===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(p)},m.IPv4.parseCIDR=function(f){let p;if(p=f.match(/^(.+)\/(\d+)$/)){let d=parseInt(p[2]);if(d>=0&&d<=32){let g=[this.parse(p[1]),d];return Object.defineProperty(g,"toString",{value:function(){return this.join("/")}}),g}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},m.IPv4.parser=function(f){let p,d,g;if(p=f.match(e.fourOctet))return function(){let y=p.slice(1,6),b=[];for(let w=0;w<y.length;w++)d=y[w],b.push(h(d));return b}();if(p=f.match(e.longValue)){if(g=h(p[1]),g>4294967295||g<0)throw new Error("ipaddr: address outside defined range");return function(){let y=[],b;for(b=0;b<=24;b+=8)y.push(g>>b&255);return y}().reverse()}else return(p=f.match(e.twoOctet))?function(){let y=p.slice(1,4),b=[];if(g=h(y[1]),g>16777215||g<0)throw new Error("ipaddr: address outside defined range");return b.push(h(y[0])),b.push(g>>16&255),b.push(g>>8&255),b.push(g&255),b}():(p=f.match(e.threeOctet))?function(){let y=p.slice(1,5),b=[];if(g=h(y[2]),g>65535||g<0)throw new Error("ipaddr: address outside defined range");return b.push(h(y[0])),b.push(h(y[1])),b.push(g>>8&255),b.push(g&255),b}():null},m.IPv4.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>32)throw new Error("ipaddr: invalid IPv4 prefix length");let p=[0,0,0,0],d=0,g=Math.floor(f/8);for(;d<g;)p[d]=255,d++;return g<4&&(p[g]=Math.pow(2,f%8)-1<<8-f%8),new this(p)},m.IPv6=function(){function f(p,d){let g,y;if(p.length===16)for(this.parts=[],g=0;g<=14;g+=2)this.parts.push(p[g]<<8|p[g+1]);else if(p.length===8)this.parts=p;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(g=0;g<this.parts.length;g++)if(y=this.parts[g],!(0<=y&&y<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");d&&(this.zoneId=d)}return f.prototype.SpecialRanges={unspecified:[new f([0,0,0,0,0,0,0,0]),128],linkLocal:[new f([65152,0,0,0,0,0,0,0]),10],multicast:[new f([65280,0,0,0,0,0,0,0]),8],loopback:[new f([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new f([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new f([0,0,0,0,0,65535,0,0]),96],rfc6145:[new f([0,0,0,0,65535,0,0,0]),96],rfc6052:[new f([100,65435,0,0,0,0,0,0]),96],"6to4":[new f([8194,0,0,0,0,0,0,0]),16],teredo:[new f([8193,0,0,0,0,0,0,0]),32],reserved:[[new f([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new f([8193,2,0,0,0,0,0,0]),48],amt:[new f([8193,3,0,0,0,0,0,0]),32],as112v6:[new f([8193,4,274,0,0,0,0,0]),48],deprecated:[new f([8193,16,0,0,0,0,0,0]),28],orchid2:[new f([8193,32,0,0,0,0,0,0]),28]},f.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},f.prototype.kind=function(){return"ipv6"},f.prototype.match=function(p,d){let g;if(d===void 0&&(g=p,p=g[0],d=g[1]),p.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return l(this.parts,p.parts,16,d)},f.prototype.prefixLengthFromSubnetMask=function(){let p=0,d=!1,g={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},y,b;for(let w=7;w>=0;w-=1)if(y=this.parts[w],y in g){if(b=g[y],d&&b!==0)return null;b!==16&&(d=!0),p+=b}else return null;return 128-p},f.prototype.range=function(){return m.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){let p,d=[],g=this.parts;for(let y=0;y<g.length;y++)p=g[y],d.push(p>>8),d.push(p&255);return d},f.prototype.toFixedLengthString=function(){let p=function(){let g=[];for(let y=0;y<this.parts.length;y++)g.push(u(this.parts[y].toString(16),4));return g}.call(this).join(":"),d="";return this.zoneId&&(d=`%${this.zoneId}`),p+d},f.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let p=this.parts.slice(-2),d=p[0],g=p[1];return new m.IPv4([d>>8,d&255,g>>8,g&255])},f.prototype.toNormalizedString=function(){let p=function(){let g=[];for(let y=0;y<this.parts.length;y++)g.push(this.parts[y].toString(16));return g}.call(this).join(":"),d="";return this.zoneId&&(d=`%${this.zoneId}`),p+d},f.prototype.toRFC5952String=function(){let p=/((^|:)(0(:|$)){2,})/g,d=this.toNormalizedString(),g=0,y=-1,b;for(;b=p.exec(d);)b[0].length>y&&(g=b.index,y=b[0].length);return y<0?d:`${d.substring(0,g)}::${d.substring(g+y)}`},f.prototype.toString=function(){return this.toRFC5952String()},f}(),m.IPv6.broadcastAddressFromCIDR=function(f){try{let p=this.parseCIDR(f),d=p[0].toByteArray(),g=this.subnetMaskFromPrefixLength(p[1]).toByteArray(),y=[],b=0;for(;b<16;)y.push(parseInt(d[b],10)|parseInt(g[b],10)^255),b++;return new this(y)}catch(p){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${p})`)}},m.IPv6.isIPv6=function(f){return this.parser(f)!==null},m.IPv6.isValid=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{let p=this.parser(f);return new this(p.parts,p.zoneId),!0}catch{return!1}},m.IPv6.networkAddressFromCIDR=function(f){let p,d,g,y,b;try{for(p=this.parseCIDR(f),g=p[0].toByteArray(),b=this.subnetMaskFromPrefixLength(p[1]).toByteArray(),y=[],d=0;d<16;)y.push(parseInt(g[d],10)&parseInt(b[d],10)),d++;return new this(y)}catch(w){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${w})`)}},m.IPv6.parse=function(f){let p=this.parser(f);if(p.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(p.parts,p.zoneId)},m.IPv6.parseCIDR=function(f){let p,d,g;if((d=f.match(/^(.+)\/(\d+)$/))&&(p=parseInt(d[2]),p>=0&&p<=128))return g=[this.parse(d[1]),p],Object.defineProperty(g,"toString",{value:function(){return this.join("/")}}),g;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},m.IPv6.parser=function(f){let p,d,g,y,b,w;if(g=f.match(a.deprecatedTransitional))return this.parser(`::ffff:${g[1]}`);if(a.native.test(f))return c(f,8);if((g=f.match(a.transitional))&&(w=g[6]||"",p=c(g[1].slice(0,-1)+w,6),p.parts)){for(b=[parseInt(g[2]),parseInt(g[3]),parseInt(g[4]),parseInt(g[5])],d=0;d<b.length;d++)if(y=b[d],!(0<=y&&y<=255))return null;return p.parts.push(b[0]<<8|b[1]),p.parts.push(b[2]<<8|b[3]),{parts:p.parts,zoneId:p.zoneId}}return null},m.IPv6.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>128)throw new Error("ipaddr: invalid IPv6 prefix length");let p=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=0,g=Math.floor(f/8);for(;d<g;)p[d]=255,d++;return g<16&&(p[g]=Math.pow(2,f%8)-1<<8-f%8),new this(p)},m.fromByteArray=function(f){let p=f.length;if(p===4)return new m.IPv4(f);if(p===16)return new m.IPv6(f);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},m.isValid=function(f){return m.IPv6.isValid(f)||m.IPv4.isValid(f)},m.parse=function(f){if(m.IPv6.isValid(f))return m.IPv6.parse(f);if(m.IPv4.isValid(f))return m.IPv4.parse(f);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},m.parseCIDR=function(f){try{return m.IPv6.parseCIDR(f)}catch{try{return m.IPv4.parseCIDR(f)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},m.process=function(f){let p=this.parse(f);return p.kind()==="ipv6"&&p.isIPv4MappedAddress()?p.toIPv4Address():p},m.subnetMatch=function(f,p,d){let g,y,b,w;d==null&&(d="unicast");for(y in p)if(Object.prototype.hasOwnProperty.call(p,y)){for(b=p[y],b[0]&&!(b[0]instanceof Array)&&(b=[b]),g=0;g<b.length;g++)if(w=b[g],f.kind()===w[0].kind()&&f.match.apply(f,w))return y}return d},typeof As<"u"&&As.exports?As.exports=m:r.ipaddr=m})(ml)});var o0={};ut(o0,{autoNAT:()=>s0});var Si=Symbol.for("@libp2p/peer-id");var C=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var ks="ERR_TIMEOUT";var Rs=(r,...t)=>{try{[...t]}catch{}};var Cs={};ut(Cs,{base58btc:()=>ct,base58flickr:()=>ql});var u0=new Uint8Array(0);function ki(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Zt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Ri(r){return new TextEncoder().encode(r)}function Ni(r){return new TextDecoder().decode(r)}function Fl(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(e[i]!==255)throw new TypeError(o+" is ambiguous");e[i]=s}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var d=0,g=0,y=0,b=p.length;y!==b&&p[y]===0;)y++,d++;for(var w=(b-y)*h+1>>>0,k=new Uint8Array(w);y!==b;){for(var v=p[y],A=0,N=w-1;(v!==0||A<g)&&N!==-1;N--,A++)v+=256*k[N]>>>0,k[N]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");g=A,y++}for(var T=w-g;T!==w&&k[T]===0;)T++;for(var q=c.repeat(d);T<w;++T)q+=r.charAt(k[T]);return q}function m(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var d=0;if(p[d]!==" "){for(var g=0,y=0;p[d]===c;)g++,d++;for(var b=(p.length-d)*l+1>>>0,w=new Uint8Array(b);p[d];){var k=e[p.charCodeAt(d)];if(k===255)return;for(var v=0,A=b-1;(k!==0||v<y)&&A!==-1;A--,v++)k+=a*w[A]>>>0,w[A]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");y=v,d++}if(p[d]!==" "){for(var N=b-y;N!==b&&w[N]===0;)N++;for(var T=new Uint8Array(g+(b-N)),q=g;N!==b;)T[q++]=w[N++];return T}}}function f(p){var d=m(p);if(d)return d;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:m,decode:f}}var Hl=Fl,Ml=Hl,Li=Ml;var Ns=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Ts=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return _i(this,t)}},Ls=class{decoders;constructor(t){this.decoders=t}or(t){return _i(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function _i(r,t){return new Ls({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var _s=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new Ns(t,e,n),this.decoder=new Ts(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ze({name:r,prefix:t,encode:e,decode:n}){return new _s(r,t,e,n)}function me({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=Li(e,r);return Ze({prefix:t,name:r,encode:n,decode:o=>Zt(s(o))})}function $l(r,t,e,n){let s={};for(let h=0;h<t.length;++h)s[t[h]]=h;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*e/8|0),a=0,c=0,l=0;for(let h=0;h<o;++h){let u=s[r[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,a+=e,a>=8&&(a-=8,i[l++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Kl(r,t,e){let n=t[t.length-1]==="=",s=(1<<e)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,o+=t[s&a>>i];if(i!==0&&(o+=t[s&a<<e-i]),n)for(;o.length*e&7;)o+="=";return o}function tt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Ze({prefix:t,name:r,encode(s){return Kl(s,n,e)},decode(s){return $l(s,n,e,r)}})}var ct=me({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ql=me({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Us={};ut(Us,{base10:()=>zl});var zl=me({prefix:"9",name:"base10",alphabet:"0123456789"});var Ps={};ut(Ps,{base16:()=>jl,base16upper:()=>Gl});var jl=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Gl=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ds={};ut(Ds,{base2:()=>Wl});var Wl=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Os={};ut(Os,{base256emoji:()=>Ql});var Ci=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Zl=Ci.reduce((r,t,e)=>(r[e]=t,r),[]),Yl=Ci.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Jl(r){return r.reduce((t,e)=>(t+=Zl[e],t),"")}function Xl(r){let t=[];for(let e of r){let n=Yl[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Ql=Ze({prefix:"\u{1F680}",name:"base256emoji",encode:Jl,decode:Xl});var Vs={};ut(Vs,{base32:()=>Yt,base32hex:()=>nu,base32hexpad:()=>ou,base32hexpadupper:()=>iu,base32hexupper:()=>su,base32pad:()=>eu,base32padupper:()=>ru,base32upper:()=>tu,base32z:()=>au});var Yt=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),eu=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ru=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),su=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ou=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),iu=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),au=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fs={};ut(Fs,{base36:()=>cu,base36upper:()=>lu});var cu=me({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),lu=me({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ms={};ut(Ms,{base64:()=>Hs,base64pad:()=>uu,base64url:()=>fu,base64urlpad:()=>hu});var Hs=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),uu=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fu=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),hu=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $s={};ut($s,{base8:()=>du});var du=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ks={};ut(Ks,{identity:()=>pu});var pu=Ze({prefix:"\0",name:"identity",encode:r=>Ni(r),decode:r=>Ri(r)});var S0=new TextEncoder,k0=new TextDecoder;var zs={};ut(zs,{identity:()=>ye});var yu=Di,Ui=128,bu=127,wu=~bu,xu=Math.pow(2,31);function Di(r,t,e){t=t||[],e=e||0;for(var n=e;r>=xu;)t[e++]=r&255|Ui,r/=128;for(;r&wu;)t[e++]=r&255|Ui,r>>>=7;return t[e]=r|0,Di.bytes=e-n+1,t}var vu=qs,Eu=128,Pi=127;function qs(r,n){var e=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw qs.bytes=0,new RangeError("Could not decode varint");i=r[o++],e+=s<28?(i&Pi)<<s:(i&Pi)*Math.pow(2,s),s+=7}while(i>=Eu);return qs.bytes=o-n,e}var Bu=Math.pow(2,7),Au=Math.pow(2,14),Iu=Math.pow(2,21),Su=Math.pow(2,28),ku=Math.pow(2,35),Ru=Math.pow(2,42),Nu=Math.pow(2,49),Tu=Math.pow(2,56),Lu=Math.pow(2,63),_u=function(r){return r<Bu?1:r<Au?2:r<Iu?3:r<Su?4:r<ku?5:r<Ru?6:r<Nu?7:r<Tu?8:r<Lu?9:10},Cu={encode:yu,decode:vu,encodingLength:_u},Uu=Cu,Rr=Uu;function Nr(r,t=0){return[Rr.decode(r,t),Rr.decode.bytes]}function Ye(r,t,e=0){return Rr.encode(r,t,e),t}function Je(r){return Rr.encodingLength(r)}function Kt(r,t){let e=t.byteLength,n=Je(r),s=n+Je(e),o=new Uint8Array(s+e);return Ye(r,o,0),Ye(e,o,n),o.set(t,s),new Xe(r,e,t,o)}function Oe(r){let t=Zt(r),[e,n]=Nr(t),[s,o]=Nr(t.subarray(n)),i=t.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new Xe(e,s,i,t)}function Oi(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ki(r.bytes,e.bytes)}}var Xe=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};var Vi=0,Pu="identity",Fi=Zt;function Du(r){return Kt(Vi,Fi(r))}var ye={code:Vi,name:Pu,encode:Fi,digest:Du};var Ws={};ut(Ws,{sha256:()=>pt,sha512:()=>Ou});function Gs({name:r,code:t,encode:e}){return new js(r,t,e)}var js=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Kt(this.code,e):e.then(n=>Kt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Mi(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var pt=Gs({name:"sha2-256",code:18,encode:Mi("SHA-256")}),Ou=Gs({name:"sha2-512",code:19,encode:Mi("SHA-512")});function $i(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Fu(e,Zs(r),t??ct.encoder);default:return Hu(e,Zs(r),t??Yt.encoder)}}var Ki=new WeakMap;function Zs(r){let t=Ki.get(r);if(t==null){let e=new Map;return Ki.set(r,e),e}return t}var Ut=class r{code;version;multihash;bytes;"/";constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Tr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Mu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Kt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Oi(t.multihash,n.multihash)}toString(t){return $i(this,t)}toJSON(){return{"/":$i(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:s,multihash:o,bytes:i}=e;return new r(n,s,o,i??qi(n,s,o.bytes))}else if(e[$u]===!0){let{version:n,multihash:s,code:o}=e,i=Oe(s);return r.create(n,o,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Tr)throw new Error(`Version 0 CID must use dag-pb (code: ${Tr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=qi(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Tr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,s=Zt(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=s.subarray(e.multihashSize-e.digestSize),i=new Xe(e.multihashCode,e.digestSize,o,s);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[u,m]=Nr(t.subarray(e));return e+=m,u},s=n(),o=Tr;if(s===18?(s=0,e=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=e,a=n(),c=n(),l=e+c,h=l-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:h,size:l}}static parse(t,e){let[n,s]=Vu(t,e),o=r.decode(s);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Zs(o).set(n,t),o}};function Vu(r,t){switch(r[0]){case"Q":{let e=t??ct;return[ct.prefix,e.decode(`${ct.prefix}${r}`)]}case ct.prefix:{let e=t??ct;return[ct.prefix,e.decode(r)]}case Yt.prefix:{let e=t??Yt;return[Yt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Fu(r,t,e){let{prefix:n}=e;if(n!==ct.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return s}function Hu(r,t,e){let{prefix:n}=e,s=t.get(n);if(s==null){let o=e.encode(r);return t.set(n,o),o}else return s}var Tr=112,Mu=18;function qi(r,t,e){let n=Je(r),s=n+Je(t),o=new Uint8Array(s+e.byteLength);return Ye(r,o,0),Ye(t,o,n),o.set(e,s),o}var $u=Symbol.for("@ipld/js-cid/CID");var be={...Ks,...Ds,...$s,...Us,...Ps,...Vs,...Fs,...Cs,...Ms,...Os},W0={...Ws,...zs};function bt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Ku=Symbol.for("nodejs.util.inspect.custom"),zi=Object.values(be).map(r=>r.decoder).reduce((r,t)=>r.or(t),be.identity.decoder),ji=114,Ys=36,Js=37,Lr=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Si]=!0;toString(){return this.string==null&&(this.string=ct.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Ut.createV1(ji,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return bt(this.multihash.bytes,t);if(typeof t=="string")return qu(t).equals(this);if(t?.multihash?.bytes!=null)return bt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Ku](){return`PeerId(${this.toString()})`}},Qe=class extends Lr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},tr=class extends Lr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},er=class extends Lr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function qu(r,t){if(t=t??zi,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Oe(ct.decode(`z${r}`));return r.startsWith("12D")?new tr({multihash:e}):r.startsWith("16U")?new er({multihash:e}):new Qe({multihash:e})}return sn(zi.decode(r))}function sn(r){try{let t=Oe(r);if(t.code===ye.code){if(t.digest.length===Ys)return new tr({multihash:t});if(t.digest.length===Js)return new er({multihash:t})}if(t.code===pt.code)return new Qe({multihash:t})}catch{return zu(Ut.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function zu(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==ji)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===pt.code)return new Qe({multihash:r.multihash});if(t.code===ye.code){if(t.digest.length===Ys)return new tr({multihash:r.multihash});if(t.digest.length===Js)return new er({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Gi(r,t){return r.length===Ys?new tr({multihash:Kt(ye.code,r),privateKey:t}):r.length===Js?new er({multihash:Kt(ye.code,r),privateKey:t}):new Qe({multihash:await pt.digest(r),publicKey:r,privateKey:t})}var No={};ut(No,{Ed25519PrivateKey:()=>qe,Ed25519PublicKey:()=>Or,generateKeyPair:()=>hh,generateKeyPairFromSeed:()=>Na,unmarshalEd25519PrivateKey:()=>uh,unmarshalEd25519PublicKey:()=>fh});function we(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Jt(r=0){return globalThis.Buffer?.alloc!=null?we(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function wt(r=0){return globalThis.Buffer?.allocUnsafe!=null?we(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Bt(r,t){if(globalThis.Buffer!=null)return we(globalThis.Buffer.concat(r,t));t==null&&(t=r.reduce((s,o)=>s+o.length,0));let e=wt(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return we(e)}function Zi(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Wi=Zi("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Xs=Zi("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=wt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ju={utf8:Wi,"utf-8":Wi,hex:be.base16,latin1:Xs,ascii:Xs,binary:Xs,...be},on=ju;function Y(r,t="utf8"){let e=on[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?we(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Lt(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function rr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Gu(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Qs(r,...t){if(!Gu(r))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function an(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rr(r.outputLen),rr(r.blockLen)}function nr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Yi(r,t){Qs(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var cn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Ji(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var or=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Pt=(r,t)=>r<<32-t|r>>>t,Wu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Wu)throw new Error("Non little-endian hardware is not supported");var Zu=async()=>{};async function Xi(r,t,e){let n=Date.now();for(let s=0;s<r;s++){e(s);let o=Date.now()-n;o>=0&&o<t||(await Zu(),n+=o)}}function to(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function xe(r){if(typeof r=="string"&&(r=to(r)),!Ji(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function ln(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];if(!Ji(s))throw new Error("Uint8Array expected");t+=s.length}let e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){let o=r[n];e.set(o,s),s+=o.length}return e}var sr=class{clone(){return this._cloneInto()}},Yu={}.toString;function Qi(r,t){if(t!==void 0&&Yu.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,t)}function un(r){let t=n=>r().update(xe(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ir(r=32){if(cn&&typeof cn.getRandomValues=="function")return cn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Ju(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(e>>s&o),a=Number(e&o),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}var ar=class extends sr{constructor(t,e,n,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=or(this.buffer)}update(t){nr(this);let{view:e,buffer:n,blockLen:s}=this;t=xe(t);let o=t.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=or(t);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){nr(this),Yi(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let u=i;u<s;u++)e[u]=0;Ju(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=or(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,h[u],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return t.length=s,t.pos=a,t.finished=o,t.destroyed=i,s%e&&t.buffer.set(n),t}};var fn=BigInt(4294967295),eo=BigInt(32);function ta(r,t=!1){return t?{h:Number(r&fn),l:Number(r>>eo&fn)}:{h:Number(r>>eo&fn)|0,l:Number(r&fn)|0}}function Xu(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=ta(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var Qu=(r,t)=>BigInt(r>>>0)<<eo|BigInt(t>>>0),tf=(r,t,e)=>r>>>e,ef=(r,t,e)=>r<<32-e|t>>>e,rf=(r,t,e)=>r>>>e|t<<32-e,nf=(r,t,e)=>r<<32-e|t>>>e,sf=(r,t,e)=>r<<64-e|t>>>e-32,of=(r,t,e)=>r>>>e-32|t<<64-e,af=(r,t)=>t,cf=(r,t)=>r,lf=(r,t,e)=>r<<e|t>>>32-e,uf=(r,t,e)=>t<<e|r>>>32-e,ff=(r,t,e)=>t<<e-32|r>>>64-e,hf=(r,t,e)=>r<<e-32|t>>>64-e;function df(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var pf=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),gf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,mf=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),yf=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,bf=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),wf=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var xf={fromBig:ta,split:Xu,toBig:Qu,shrSH:tf,shrSL:ef,rotrSH:rf,rotrSL:nf,rotrBH:sf,rotrBL:of,rotr32H:af,rotr32L:cf,rotlSH:lf,rotlSL:uf,rotlBH:ff,rotlBL:hf,add:df,add3L:pf,add3H:gf,add4L:mf,add4H:yf,add5H:wf,add5L:bf},U=xf;var[vf,Ef]=U.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),ve=new Uint32Array(80),Ee=new Uint32Array(80),ro=class extends ar{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:l,El:h,Fh:u,Fl:m,Gh:f,Gl:p,Hh:d,Hl:g}=this;return[t,e,n,s,o,i,a,c,l,h,u,m,f,p,d,g]}set(t,e,n,s,o,i,a,c,l,h,u,m,f,p,d,g){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=u|0,this.Fl=m|0,this.Gh=f|0,this.Gl=p|0,this.Hh=d|0,this.Hl=g|0}process(t,e){for(let w=0;w<16;w++,e+=4)ve[w]=t.getUint32(e),Ee[w]=t.getUint32(e+=4);for(let w=16;w<80;w++){let k=ve[w-15]|0,v=Ee[w-15]|0,A=U.rotrSH(k,v,1)^U.rotrSH(k,v,8)^U.shrSH(k,v,7),N=U.rotrSL(k,v,1)^U.rotrSL(k,v,8)^U.shrSL(k,v,7),T=ve[w-2]|0,q=Ee[w-2]|0,$=U.rotrSH(T,q,19)^U.rotrBH(T,q,61)^U.shrSH(T,q,6),D=U.rotrSL(T,q,19)^U.rotrBL(T,q,61)^U.shrSL(T,q,6),nt=U.add4L(N,D,Ee[w-7],Ee[w-16]),rt=U.add4H(nt,A,$,ve[w-7],ve[w-16]);ve[w]=rt|0,Ee[w]=nt|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:l,Dl:h,Eh:u,El:m,Fh:f,Fl:p,Gh:d,Gl:g,Hh:y,Hl:b}=this;for(let w=0;w<80;w++){let k=U.rotrSH(u,m,14)^U.rotrSH(u,m,18)^U.rotrBH(u,m,41),v=U.rotrSL(u,m,14)^U.rotrSL(u,m,18)^U.rotrBL(u,m,41),A=u&f^~u&d,N=m&p^~m&g,T=U.add5L(b,v,N,Ef[w],Ee[w]),q=U.add5H(T,y,k,A,vf[w],ve[w]),$=T|0,D=U.rotrSH(n,s,28)^U.rotrBH(n,s,34)^U.rotrBH(n,s,39),nt=U.rotrSL(n,s,28)^U.rotrBL(n,s,34)^U.rotrBL(n,s,39),rt=n&o^n&a^o&a,Tt=s&i^s&c^i&c;y=d|0,b=g|0,d=f|0,g=p|0,f=u|0,p=m|0,{h:u,l:m}=U.add(l|0,h|0,q|0,$|0),l=a|0,h=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let E=U.add3L($,nt,Tt);n=U.add3H(E,q,D,rt),s=E|0}({h:n,l:s}=U.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=U.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=U.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=U.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:u,l:m}=U.add(this.Eh|0,this.El|0,u|0,m|0),{h:f,l:p}=U.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:d,l:g}=U.add(this.Gh|0,this.Gl|0,d|0,g|0),{h:y,l:b}=U.add(this.Hh|0,this.Hl|0,y|0,b|0),this.set(n,s,o,i,a,c,l,h,u,m,f,p,d,g,y,b)}roundClean(){ve.fill(0),Ee.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var cr=un(()=>new ro);var dn={};ut(dn,{bitGet:()=>Nf,bitLen:()=>Rf,bitMask:()=>_r,bitSet:()=>Tf,bytesToHex:()=>Qt,bytesToNumberBE:()=>te,bytesToNumberLE:()=>Be,concatBytes:()=>ee,createHmacDrbg:()=>oo,ensureBytes:()=>et,equalBytes:()=>Sf,hexToBytes:()=>Fe,hexToNumber:()=>so,isBytes:()=>Dt,numberToBytesBE:()=>Ae,numberToBytesLE:()=>He,numberToHexUnpadded:()=>sa,numberToVarBytesBE:()=>If,utf8ToBytes:()=>kf,validateObject:()=>qt});var na=BigInt(0),hn=BigInt(1),Bf=BigInt(2);function Dt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Af=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Qt(r){if(!Dt(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Af[r[e]];return t}function sa(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function so(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Xt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ea(r){if(r>=Xt._0&&r<=Xt._9)return r-Xt._0;if(r>=Xt._A&&r<=Xt._F)return r-(Xt._A-10);if(r>=Xt._a&&r<=Xt._f)return r-(Xt._a-10)}function Fe(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let s=0,o=0;s<e;s++,o+=2){let i=ea(r.charCodeAt(o)),a=ea(r.charCodeAt(o+1));if(i===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[s]=i*16+a}return n}function te(r){return so(Qt(r))}function Be(r){if(!Dt(r))throw new Error("Uint8Array expected");return so(Qt(Uint8Array.from(r).reverse()))}function Ae(r,t){return Fe(r.toString(16).padStart(t*2,"0"))}function He(r,t){return Ae(r,t).reverse()}function If(r){return Fe(sa(r))}function et(r,t,e){let n;if(typeof t=="string")try{n=Fe(t)}catch(o){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${o}`)}else if(Dt(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof e=="number"&&s!==e)throw new Error(`${r} expected ${e} bytes, got ${s}`);return n}function ee(...r){let t=0;for(let s=0;s<r.length;s++){let o=r[s];if(!Dt(o))throw new Error("Uint8Array expected");t+=o.length}let e=new Uint8Array(t),n=0;for(let s=0;s<r.length;s++){let o=r[s];e.set(o,n),n+=o.length}return e}function Sf(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function kf(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Rf(r){let t;for(t=0;r>na;r>>=hn,t+=1);return t}function Nf(r,t){return r>>BigInt(t)&hn}var Tf=(r,t,e)=>r|(e?hn:na)<<BigInt(t),_r=r=>(Bf<<BigInt(r-1))-hn,no=r=>new Uint8Array(r),ra=r=>Uint8Array.from(r);function oo(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=no(r),s=no(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...u)=>e(s,n,...u),c=(u=no())=>{s=a(ra([0]),u),n=a(),u.length!==0&&(s=a(ra([1]),u),n=a())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,m=[];for(;u<t;){n=a();let f=n.slice();m.push(f),u+=n.length}return ee(...m)};return(u,m)=>{i(),c(u);let f;for(;!(f=m(l()));)c();return i(),f}}var Lf={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Dt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function qt(r,t,e={}){let n=(s,o,i)=>{let a=Lf[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=r[s];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(let[s,o]of Object.entries(t))n(s,o,!1);for(let[s,o]of Object.entries(e))n(s,o,!0);return r}var lt=BigInt(0),J=BigInt(1),Me=BigInt(2),_f=BigInt(3),io=BigInt(4),oa=BigInt(5),ia=BigInt(8),Cf=BigInt(9),Uf=BigInt(16);function Z(r,t){let e=r%t;return e>=lt?e:t+e}function Pf(r,t,e){if(e<=lt||t<lt)throw new Error("Expected power/modulo > 0");if(e===J)return lt;let n=J;for(;t>lt;)t&J&&(n=n*r%e),r=r*r%e,t>>=J;return n}function X(r,t,e){let n=r;for(;t-- >lt;)n*=n,n%=e;return n}function pn(r,t){if(r===lt||t<=lt)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=Z(r,t),n=t,s=lt,o=J,i=J,a=lt;for(;e!==lt;){let l=n/e,h=n%e,u=s-i*l,m=o-a*l;n=e,e=h,s=i,o=a,i=u,a=m}if(n!==J)throw new Error("invert: does not exist");return Z(s,t)}function Df(r){let t=(r-J)/Me,e,n,s;for(e=r-J,n=0;e%Me===lt;e/=Me,n++);for(s=Me;s<r&&Pf(s,t,r)!==r-J;s++);if(n===1){let i=(r+J)/io;return function(c,l){let h=c.pow(l,i);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}let o=(e+J)/Me;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,s),e),u=a.pow(c,o),m=a.pow(c,e);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let f=1;for(let d=a.sqr(m);f<l&&!a.eql(d,a.ONE);f++)d=a.sqr(d);let p=a.pow(h,J<<BigInt(l-f-1));h=a.sqr(p),u=a.mul(u,p),m=a.mul(m,h),l=f}return u}}function Of(r){if(r%io===_f){let t=(r+J)/io;return function(n,s){let o=n.pow(s,t);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%ia===oa){let t=(r-oa)/ia;return function(n,s){let o=n.mul(s,Me),i=n.pow(o,t),a=n.mul(s,i),c=n.mul(n.mul(a,Me),i),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%Uf,Df(r)}var aa=(r,t)=>(Z(r,t)&J)===J,Vf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ao(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Vf.reduce((n,s)=>(n[s]="function",n),t);return qt(r,e)}function Ff(r,t,e){if(e<lt)throw new Error("Expected power > 0");if(e===lt)return r.ONE;if(e===J)return t;let n=r.ONE,s=t;for(;e>lt;)e&J&&(n=r.mul(n,s)),s=r.sqr(s),e>>=J;return n}function Hf(r,t){let e=new Array(t.length),n=t.reduce((o,i,a)=>r.is0(i)?o:(e[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return t.reduceRight((o,i,a)=>r.is0(i)?o:(e[a]=r.mul(o,e[a]),r.mul(o,i)),s),e}function co(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function gn(r,t,e=!1,n={}){if(r<=lt)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=co(r,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Of(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:_r(s),ZERO:lt,ONE:J,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return lt<=c&&c<r},is0:c=>c===lt,isOdd:c=>(c&J)===J,neg:c=>Z(-c,r),eql:(c,l)=>c===l,sqr:c=>Z(c*c,r),add:(c,l)=>Z(c+l,r),sub:(c,l)=>Z(c-l,r),mul:(c,l)=>Z(c*l,r),pow:(c,l)=>Ff(a,c,l),div:(c,l)=>Z(c*pn(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>pn(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>Hf(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>e?He(c,o):Ae(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return e?Be(c):te(c)}});return Object.freeze(a)}function ca(r,t){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let e=r.sqrt(t);return r.isOdd(e)?r.neg(e):e}function la(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function lo(r){let t=la(r);return t+Math.ceil(t/2)}function ua(r,t,e=!1){let n=r.length,s=la(t),o=lo(t);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=e?te(r):Be(r),a=Z(i,t-J)+J;return e?He(a,s):Ae(a,s)}var $f=BigInt(0),uo=BigInt(1);function mn(r,t){let e=(s,o)=>{let i=o.negate();return s?i:o},n=s=>{let o=Math.ceil(t/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:e,unsafeLadder(s,o){let i=r.ZERO,a=s;for(;o>$f;)o&uo&&(i=i.add(a)),a=a.double(),o>>=uo;return i},precomputeWindow(s,o){let{windows:i,windowSize:a}=n(o),c=[],l=s,h=l;for(let u=0;u<i;u++){h=l,c.push(h);for(let m=1;m<a;m++)h=h.add(l),c.push(h);l=h.double()}return c},wNAF(s,o,i){let{windows:a,windowSize:c}=n(s),l=r.ZERO,h=r.BASE,u=BigInt(2**s-1),m=2**s,f=BigInt(s);for(let p=0;p<a;p++){let d=p*c,g=Number(i&u);i>>=f,g>c&&(g-=m,i+=uo);let y=d,b=d+Math.abs(g)-1,w=p%2!==0,k=g<0;g===0?h=h.add(e(w,o[y])):l=l.add(e(k,o[b]))}return{p:l,f:h}},wNAFCached(s,o,i,a){let c=s._WINDOW_SIZE||1,l=o.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&o.set(s,a(l))),this.wNAF(c,l,i)}}}function Cr(r){return ao(r.Fp),qt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...co(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ot=BigInt(0),Nt=BigInt(1),yn=BigInt(2),Kf=BigInt(8),qf={zip215:!0};function zf(r){let t=Cr(r);return qt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function bn(r){let t=zf(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=t,l=yn<<BigInt(a*8)-Nt,h=e.create,u=t.uvRatio||((B,x)=>{try{return{isValid:!0,value:e.sqrt(B*e.inv(x))}}catch{return{isValid:!1,value:Ot}}}),m=t.adjustScalarBytes||(B=>B),f=t.domain||((B,x,S)=>{if(x.length||S)throw new Error("Contexts/pre-hash are not supported");return B}),p=B=>typeof B=="bigint"&&Ot<B,d=(B,x)=>p(B)&&p(x)&&B<x,g=B=>B===Ot||d(B,l);function y(B,x){if(d(B,x))return B;throw new Error(`Expected valid scalar < ${x}, got ${typeof B} ${B}`)}function b(B){return B===Ot?B:y(B,n)}let w=new Map;function k(B){if(!(B instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(x,S,L,_){if(this.ex=x,this.ey=S,this.ez=L,this.et=_,!g(x))throw new Error("x required");if(!g(S))throw new Error("y required");if(!g(L))throw new Error("z required");if(!g(_))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(x){if(x instanceof v)throw new Error("extended point not allowed");let{x:S,y:L}=x||{};if(!g(S)||!g(L))throw new Error("invalid affine point");return new v(S,L,Nt,h(S*L))}static normalizeZ(x){let S=e.invertBatch(x.map(L=>L.ez));return x.map((L,_)=>L.toAffine(S[_])).map(v.fromAffine)}_setWindowSize(x){this._WINDOW_SIZE=x,w.delete(this)}assertValidity(){let{a:x,d:S}=t;if(this.is0())throw new Error("bad point: ZERO");let{ex:L,ey:_,ez:V,et:F}=this,G=h(L*L),M=h(_*_),K=h(V*V),st=h(K*K),Q=h(G*x),ht=h(K*h(Q+M)),dt=h(st+h(S*h(G*M)));if(ht!==dt)throw new Error("bad point: equation left != right (1)");let at=h(L*_),yt=h(V*F);if(at!==yt)throw new Error("bad point: equation left != right (2)")}equals(x){k(x);let{ex:S,ey:L,ez:_}=this,{ex:V,ey:F,ez:G}=x,M=h(S*G),K=h(V*_),st=h(L*G),Q=h(F*_);return M===K&&st===Q}is0(){return this.equals(v.ZERO)}negate(){return new v(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){let{a:x}=t,{ex:S,ey:L,ez:_}=this,V=h(S*S),F=h(L*L),G=h(yn*h(_*_)),M=h(x*V),K=S+L,st=h(h(K*K)-V-F),Q=M+F,ht=Q-G,dt=M-F,at=h(st*ht),yt=h(Q*dt),Wt=h(st*dt),De=h(ht*Q);return new v(at,yt,De,Wt)}add(x){k(x);let{a:S,d:L}=t,{ex:_,ey:V,ez:F,et:G}=this,{ex:M,ey:K,ez:st,et:Q}=x;if(S===BigInt(-1)){let bi=h((V-_)*(K+M)),wi=h((V+_)*(K-M)),Ss=h(wi-bi);if(Ss===Ot)return this.double();let xi=h(F*yn*Q),vi=h(G*yn*st),Ei=vi+xi,Bi=wi+bi,Ai=vi-xi,Nl=h(Ei*Ss),Tl=h(Bi*Ai),Ll=h(Ei*Ai),_l=h(Ss*Bi);return new v(Nl,Tl,_l,Ll)}let ht=h(_*M),dt=h(V*K),at=h(G*L*Q),yt=h(F*st),Wt=h((_+V)*(M+K)-ht-dt),De=yt-at,kr=yt+at,yi=h(dt-S*ht),Il=h(Wt*De),Sl=h(kr*yi),kl=h(Wt*yi),Rl=h(De*kr);return new v(Il,Sl,Rl,kl)}subtract(x){return this.add(x.negate())}wNAF(x){return T.wNAFCached(this,w,x,v.normalizeZ)}multiply(x){let{p:S,f:L}=this.wNAF(y(x,n));return v.normalizeZ([S,L])[0]}multiplyUnsafe(x){let S=b(x);return S===Ot?N:this.equals(N)||S===Nt?this:this.equals(A)?this.wNAF(S).p:T.unsafeLadder(this,S)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(x){let{ex:S,ey:L,ez:_}=this,V=this.is0();x==null&&(x=V?Kf:e.inv(_));let F=h(S*x),G=h(L*x),M=h(_*x);if(V)return{x:Ot,y:Nt};if(M!==Nt)throw new Error("invZ was invalid");return{x:F,y:G}}clearCofactor(){let{h:x}=t;return x===Nt?this:this.multiplyUnsafe(x)}static fromHex(x,S=!1){let{d:L,a:_}=t,V=e.BYTES;x=et("pointHex",x,V);let F=x.slice(),G=x[V-1];F[V-1]=G&-129;let M=Be(F);M===Ot||(S?y(M,l):y(M,e.ORDER));let K=h(M*M),st=h(K-Nt),Q=h(L*K-_),{isValid:ht,value:dt}=u(st,Q);if(!ht)throw new Error("Point.fromHex: invalid y coordinate");let at=(dt&Nt)===Nt,yt=(G&128)!==0;if(!S&&dt===Ot&&yt)throw new Error("Point.fromHex: x=0 and x_0=1");return yt!==at&&(dt=h(-dt)),v.fromAffine({x:dt,y:M})}static fromPrivateKey(x){return D(x).point}toRawBytes(){let{x,y:S}=this.toAffine(),L=He(S,e.BYTES);return L[L.length-1]|=x&Nt?128:0,L}toHex(){return Qt(this.toRawBytes())}}v.BASE=new v(t.Gx,t.Gy,Nt,h(t.Gx*t.Gy)),v.ZERO=new v(Ot,Nt,Nt,Ot);let{BASE:A,ZERO:N}=v,T=mn(v,a*8);function q(B){return Z(B,n)}function $(B){return q(Be(B))}function D(B){let x=a;B=et("private key",B,x);let S=et("hashed private key",o(B),2*x),L=m(S.slice(0,x)),_=S.slice(x,2*x),V=$(L),F=A.multiply(V),G=F.toRawBytes();return{head:L,prefix:_,scalar:V,point:F,pointBytes:G}}function nt(B){return D(B).pointBytes}function rt(B=new Uint8Array,...x){let S=ee(...x);return $(o(f(S,et("context",B),!!s)))}function Tt(B,x,S={}){B=et("message",B),s&&(B=s(B));let{prefix:L,scalar:_,pointBytes:V}=D(x),F=rt(S.context,L,B),G=A.multiply(F).toRawBytes(),M=rt(S.context,G,V,B),K=q(F+M*_);b(K);let st=ee(G,He(K,e.BYTES));return et("result",st,a*2)}let E=qf;function R(B,x,S,L=E){let{context:_,zip215:V}=L,F=e.BYTES;B=et("signature",B,2*F),x=et("message",x),s&&(x=s(x));let G=Be(B.slice(F,2*F)),M,K,st;try{M=v.fromHex(S,V),K=v.fromHex(B.slice(0,F),V),st=A.multiplyUnsafe(G)}catch{return!1}if(!V&&M.isSmallOrder())return!1;let Q=rt(_,K.toRawBytes(),M.toRawBytes(),x);return K.add(M.multiplyUnsafe(Q)).subtract(st).clearCofactor().equals(v.ZERO)}return A._setWindowSize(8),{CURVE:t,getPublicKey:nt,sign:Tt,verify:R,ExtendedPoint:v,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>i(e.BYTES),precompute(B=8,x=v.BASE){return x._setWindowSize(B),x.multiply(BigInt(3)),x}}}}var ho=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),fa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),qp=BigInt(0),jf=BigInt(1),fo=BigInt(2),Gf=BigInt(5),ha=BigInt(10),Wf=BigInt(20),Zf=BigInt(40),da=BigInt(80);function Yf(r){let t=ho,n=r*r%t*r%t,s=X(n,fo,t)*n%t,o=X(s,jf,t)*r%t,i=X(o,Gf,t)*o%t,a=X(i,ha,t)*i%t,c=X(a,Wf,t)*a%t,l=X(c,Zf,t)*c%t,h=X(l,da,t)*l%t,u=X(h,da,t)*l%t,m=X(u,ha,t)*i%t;return{pow_p_5_8:X(m,fo,t)*r%t,b2:n}}function Jf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Xf(r,t){let e=ho,n=Z(t*t*t,e),s=Z(n*n*t,e),o=Yf(r*s).pow_p_5_8,i=Z(r*n*o,e),a=Z(t*i*i,e),c=i,l=Z(i*fa,e),h=a===r,u=a===Z(-r,e),m=a===Z(-r*fa,e);return h&&(i=c),(u||m)&&(i=l),aa(i,e)&&(i=Z(-i,e)),{isValid:h||u,value:i}}var re=gn(ho,void 0,!0),po={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:re,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:cr,randomBytes:ir,adjustScalarBytes:Jf,uvRatio:Xf},lr=bn(po);function pa(r,t,e){if(t.length>255)throw new Error("Context is too big");return ln(to("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var zp=bn({...po,domain:pa}),jp=bn({...po,domain:pa,prehash:cr});var Qf=(re.ORDER+BigInt(3))/BigInt(8),Gp=re.pow(fo,Qf),Wp=re.sqrt(re.neg(re.ONE)),Zp=(re.ORDER-BigInt(5))/BigInt(8),Yp=BigInt(486662);var Jp=ca(re,re.neg(BigInt(486664)));var Xp=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Qp=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),tg=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),eg=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var rg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var ur=32,ne=64,wn=32;function ga(){let r=lr.utils.randomPrivateKey(),t=lr.getPublicKey(r);return{privateKey:wa(r,t),publicKey:t}}function ma(r){if(r.length!==wn)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let t=r,e=lr.getPublicKey(t);return{privateKey:wa(t,e),publicKey:e}}function ya(r,t){let e=r.subarray(0,wn);return lr.sign(t instanceof Uint8Array?t:t.subarray(),e)}function ba(r,t,e){return lr.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}function wa(r,t){let e=new Uint8Array(ne);for(let n=0;n<wn;n++)e[n]=r[n],e[wn+n]=t[n];return e}var At={get(r=globalThis){let t=r.crypto;if(t==null||t.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return t}};var go={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function xa(r){let t=r?.algorithm??"AES-GCM",e=r?.keyLength??16,n=r?.nonceLength??12,s=r?.digest??"SHA-256",o=r?.saltLength??16,i=r?.iterations??32767,a=At.get();e*=8;async function c(u,m){let f=a.getRandomValues(new Uint8Array(o)),p=a.getRandomValues(new Uint8Array(n)),d={name:t,iv:p};typeof m=="string"&&(m=Y(m));let g;if(m.length===0){g=await a.subtle.importKey("jwk",go,{name:"AES-GCM"},!0,["encrypt"]);try{let b={name:"PBKDF2",salt:f,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",m,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,w,{name:t,length:e},!0,["encrypt"])}catch{g=await a.subtle.importKey("jwk",go,{name:"AES-GCM"},!0,["encrypt"])}}else{let b={name:"PBKDF2",salt:f,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",m,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,w,{name:t,length:e},!0,["encrypt"])}let y=await a.subtle.encrypt(d,g,u);return Bt([f,d.iv,new Uint8Array(y)])}async function l(u,m){let f=u.subarray(0,o),p=u.subarray(o,o+n),d=u.subarray(o+n),g={name:t,iv:p};typeof m=="string"&&(m=Y(m));let y;if(m.length===0)try{let w={name:"PBKDF2",salt:f,iterations:i,hash:{name:s}},k=await a.subtle.importKey("raw",m,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,k,{name:t,length:e},!0,["decrypt"])}catch{y=await a.subtle.importKey("jwk",go,{name:"AES-GCM"},!0,["decrypt"])}else{let w={name:"PBKDF2",salt:f,iterations:i,hash:{name:s}},k=await a.subtle.importKey("raw",m,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,k,{name:t,length:e},!0,["decrypt"])}let b=await a.subtle.decrypt(g,y,d);return new Uint8Array(b)}return{encrypt:c,decrypt:l}}async function fr(r,t){let n=await xa().encrypt(r,t);return Hs.encode(n)}var mo=new Float32Array([-0]),Ie=new Uint8Array(mo.buffer);function va(r,t,e){mo[0]=r,t[e]=Ie[0],t[e+1]=Ie[1],t[e+2]=Ie[2],t[e+3]=Ie[3]}function Ea(r,t){return Ie[0]=r[t],Ie[1]=r[t+1],Ie[2]=r[t+2],Ie[3]=r[t+3],mo[0]}var yo=new Float64Array([-0]),xt=new Uint8Array(yo.buffer);function Ba(r,t,e){yo[0]=r,t[e]=xt[0],t[e+1]=xt[1],t[e+2]=xt[2],t[e+3]=xt[3],t[e+4]=xt[4],t[e+5]=xt[5],t[e+6]=xt[6],t[e+7]=xt[7]}function Aa(r,t){return xt[0]=r[t],xt[1]=r[t+1],xt[2]=r[t+2],xt[3]=r[t+3],xt[4]=r[t+4],xt[5]=r[t+5],xt[6]=r[t+6],xt[7]=r[t+7],yo[0]}var rh=BigInt(Number.MAX_SAFE_INTEGER),nh=BigInt(Number.MIN_SAFE_INTEGER),St=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return $e;if(t<rh&&t>nh)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,s=t-(n<<32n);return e&&(n=~n|0n,s=~s|0n,++s>Ia&&(s=0n,++n>Ia&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return $e;let e=t<0;e&&(t=-t);let n=t>>>0,s=(t-n)/4294967296>>>0;return e&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):$e}},$e=new St(0,0);$e.toBigInt=function(){return 0n};$e.zzEncode=$e.zzDecode=function(){return this};$e.length=function(){return 1};var Ia=4294967296n;function Sa(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function ka(r,t,e){if(e-t<1)return"";let s,o=[],i=0,a;for(;t<e;)a=r[t++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((s??(s=[])).push(String.fromCharCode.apply(String,o)),i=0);return s!=null?(i>0&&s.push(String.fromCharCode.apply(String,o.slice(0,i))),s.join("")):String.fromCharCode.apply(String,o.slice(0,i))}function bo(r,t,e){let n=e,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?t[e++]=s:s<2048?(t[e++]=s>>6|192,t[e++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,t[e++]=s>>18|240,t[e++]=s>>12&63|128,t[e++]=s>>6&63|128,t[e++]=s&63|128):(t[e++]=s>>12|224,t[e++]=s>>6&63|128,t[e++]=s&63|128);return e-n}function Vt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function xn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var wo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Vt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Vt(this,4);return xn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Vt(this,4);return xn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Vt(this,4);let t=Ea(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Vt(this,4);let t=Aa(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Vt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return ka(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Vt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Vt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new St(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Vt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Vt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Vt(this,8);let t=xn(this.buf,this.pos+=4),e=xn(this.buf,this.pos+=4);return new St(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function xo(r){return new wo(r instanceof Uint8Array?r:r.subarray())}function se(r,t){let e=xo(r);return t.decode(e)}function vo(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return wt(i);s+i>t&&(n=wt(t),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var Ke=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Eo(){}var Ao=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},sh=vo();function oh(r){return globalThis.Buffer!=null?wt(r):sh(r)}var Dr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ke(Eo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Ke(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Io((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Ur,10,St.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=St.fromBigInt(t);return this._push(Ur,e.length(),e)}uint64Number(t){let e=St.fromNumber(t);return this._push(Ur,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=St.fromBigInt(t).zzEncode();return this._push(Ur,e.length(),e)}sint64Number(t){let e=St.fromNumber(t).zzEncode();return this._push(Ur,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Bo,1,t?1:0)}fixed32(t){return this._push(Pr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=St.fromBigInt(t);return this._push(Pr,4,e.lo)._push(Pr,4,e.hi)}fixed64Number(t){let e=St.fromNumber(t);return this._push(Pr,4,e.lo)._push(Pr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(va,4,t)}double(t){return this._push(Ba,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Bo,1,0):this.uint32(e)._push(ah,e,t)}string(t){let e=Sa(t);return e!==0?this.uint32(e)._push(bo,e,t):this._push(Bo,1,0)}fork(){return this.states=new Ao(this),this.head=this.tail=new Ke(Eo,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Ke(Eo,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=oh(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Bo(r,t,e){t[e]=r&255}function ih(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Io=class extends Ke{next;constructor(t,e){super(ih,t,e),this.next=void 0}};function Ur(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Pr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function ah(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Dr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ch,t,r),this},Dr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(lh,t,r),this});function ch(r,t,e){t.set(r,e)}function lh(r,t,e){r.length<40?bo(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Y(r),e)}function So(){return new Dr}function oe(r,t){let e=So();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var hr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(hr||(hr={}));function vn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function dr(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(o,i){let a=t(o);i.int32(a)},n=function(o){let i=o.int32();return t(i)};return vn("enum",hr.VARINT,e,n)}function ie(r,t){return vn("message",hr.LENGTH_DELIMITED,r,t)}var gt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(gt||(gt={}));var ko;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(ko||(ko={}));(function(r){r.codec=()=>dr(ko)})(gt||(gt={}));var Se;(function(r){let t;r.codec=()=>(t==null&&(t=ie((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),gt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let s={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let i=e.uint32();switch(i>>>3){case 1:s.Type=gt.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>oe(e,r.codec()),r.decode=e=>se(e,r.codec())})(Se||(Se={}));var ke;(function(r){let t;r.codec=()=>(t==null&&(t=ie((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),gt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let s={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let i=e.uint32();switch(i>>>3){case 1:s.Type=gt.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>oe(e,r.codec()),r.decode=e=>se(e,r.codec())})(ke||(ke={}));var Or=class{_key;constructor(t){this._key=pr(t,ur)}verify(t,e){return ba(this._key,e,t)}marshal(){return this._key}get bytes(){return Se.encode({Type:gt.Ed25519,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}},qe=class{_key;_publicKey;constructor(t,e){this._key=pr(t,ne),this._publicKey=pr(e,ur)}sign(t){return ya(this._key,t)}get public(){return new Or(this._publicKey)}marshal(){return this._key}get bytes(){return ke.encode({Type:gt.Ed25519,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}async hash(){let t=pt.digest(this.bytes),e;return Lt(t)?{bytes:e}=await t:e=t.bytes,e}async id(){let t=ye.digest(this.public.bytes);return ct.encode(t.bytes).substring(1)}async export(t,e="libp2p-key"){if(e==="libp2p-key")return fr(this.bytes,t);throw new C(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function uh(r){if(r.length>ne){r=pr(r,ne+ur);let n=r.subarray(0,ne),s=r.subarray(ne,r.length);return new qe(n,s)}r=pr(r,ne);let t=r.subarray(0,ne),e=r.subarray(ur);return new qe(t,e)}function fh(r){return r=pr(r,ur),new Or(r)}async function hh(){let{privateKey:r,publicKey:t}=ga();return new qe(r,t)}async function Na(r){let{privateKey:t,publicKey:e}=ma(r);return new qe(t,e)}function pr(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new C(`Key must be a Uint8Array of length ${t}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function z(r,t="utf8"){let e=on[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var Fo={};ut(Fo,{MAX_RSA_KEY_SIZE:()=>Zr,RsaPrivateKey:()=>wr,RsaPublicKey:()=>Wr,fromJwk:()=>Fh,generateKeyPair:()=>Hh,unmarshalRsaPrivateKey:()=>Oo,unmarshalRsaPublicKey:()=>Vh});function ze(r){if(isNaN(r)||r<=0)throw new C("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return ir(r)}var Le={};ut(Le,{exportToPem:()=>Ch,importFromPem:()=>Uh,jwkToPkcs1:()=>Nh,jwkToPkix:()=>Lh,pkcs1ToJwk:()=>Rh,pkixToJwk:()=>Th});var En=class extends sr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,an(t);let n=xe(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?t.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(t){return nr(this),this.iHash.update(t),this}digestInto(t){nr(this),Qs(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Vr=(r,t,e)=>new En(r,t).update(e).digest();Vr.create=(r,t)=>new En(r,t);function dh(r,t,e,n){an(r);let s=Qi({dkLen:32,asyncTick:10},n),{c:o,dkLen:i,asyncTick:a}=s;if(rr(o),rr(i),rr(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=xe(t),l=xe(e),h=new Uint8Array(i),u=Vr.create(r,c),m=u._cloneInto().update(l);return{c:o,dkLen:i,asyncTick:a,DK:h,PRF:u,PRFSalt:m}}function ph(r,t,e,n,s){return r.destroy(),t.destroy(),n&&n.destroy(),s.fill(0),e}async function To(r,t,e,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:l}=dh(r,t,e,n),h,u=new Uint8Array(4),m=or(u),f=new Uint8Array(c.outputLen);for(let p=1,d=0;d<o;p++,d+=c.outputLen){let g=a.subarray(d,d+c.outputLen);m.setInt32(0,p,!1),(h=l._cloneInto(h)).update(u).digestInto(f),g.set(f.subarray(0,g.length)),await Xi(s-1,i,()=>{c._cloneInto(h).update(f).digestInto(f);for(let y=0;y<g.length;y++)g[y]^=f[y]})}return ph(c,l,a,h,f)}var H=rn(Ta());function je(r,t){let e=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)e+=r[r.length-1-n]*Math.pow(2,t*n);return e}function Re(r,t,e=-1){let n=e,s=r,o=0,i=Math.pow(2,t);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let l=new Uint8Array(c);for(let h=a-1;h>=0;h--){let u=Math.pow(2,h*t);l[o-h-1]=Math.floor(s/u),s-=l[o-h-1]*u}return c}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function In(...r){let t=0,e=0;for(let o of r)t+=o.length;let n=new ArrayBuffer(t),s=new Uint8Array(n);for(let o of r)s.set(o,e),e+=o.length;return s}function _o(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let a=0;a<this.valueHex.byteLength;a++)e[a]=0;e[0]=r[0]&128;let n=je(e,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)o[a]=r[a];return o[0]&=127,je(o,8)-n}function La(r){let t=r<0?r*-1:r,e=128;for(let n=1;n<8;n++){if(t<=e){if(r<0){let i=e-t,a=Re(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Re(t,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),a=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let c=0;c<i.byteLength;c++)o[c+1]=a[c];o[0]=0}return s}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function _a(r,t){if(r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<e.length;s++)if(e[s]!==n[s])return!1;return!0}function kt(r,t){let e=r.toString(10);if(t<e.length)return"";let n=t-e.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(e)}var am=Math.log(2);function Sn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Co(r){let t=0,e=0;for(let s=0;s<r.length;s++){let o=r[s];t+=o.byteLength}let n=new Uint8Array(t);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),e),e+=o.byteLength}return n.buffer}function fe(r,t,e,n){return t instanceof Uint8Array?t.byteLength?e<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-e-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Hr=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return Co(this.items)}},Fr=[new Uint8Array([1])],Ca="0123456789";var yr="",Ht=new ArrayBuffer(0),Uo=new Uint8Array(0),Mr="EndOfContent",Pa="OCTET STRING",Da="BIT STRING";function he(r){var t;return t=class extends r{constructor(...n){var s;super(...n);let o=n[0]||{};this.isHexOnly=(s=o.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=o.valueHex?H.BufferSourceConverter.toUint8Array(o.valueHex):Uo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,o){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!fe(this,i,s,o))return-1;let a=s+o;return this.valueHexView=i.subarray(s,a),this.valueHexView.length?(this.blockLength=o,a):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Ht)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var ce=class{constructor({blockLength:t=0,error:e=yr,warnings:n=[],valueBeforeDecode:s=Uo}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=H.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:H.Convert.ToHex(this.valueBeforeDecodeView)}}};ce.NAME="baseBlock";var vt=class extends ce{fromBER(t,e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,e){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};vt.NAME="valueBlock";var kn=class extends he(ce){constructor({idBlock:t={}}={}){var e,n,s,o;super(),t?(this.isHexOnly=(e=t.isHexOnly)!==null&&e!==void 0?e:!1,this.valueHexView=t.valueHex?H.BufferSourceConverter.toUint8Array(t.valueHex):Uo,this.tagClass=(n=t.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=t.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=t.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let e=0;switch(this.tagClass){case 1:e|=0;break;case 2:e|=64;break;case 3:e|=128;break;case 4:e|=192;break;default:return this.error="Unknown tag class",Ht}if(this.isConstructed&&(e|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!t){let o=this.tagNumber;o&=31,e|=o,s[0]=e}return s.buffer}if(!this.isHexOnly){let s=Re(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=e|31,!t){for(let c=0;c<i-1;c++)a[c+1]=o[c]|128;a[i]=o[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=e|31,!t){let s=this.valueHexView;for(let o=0;o<s.length-1;o++)n[o+1]=s[o]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!fe(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(o[0]&32)===32,this.isHexOnly=!1;let a=o[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),h=255;for(;o[c]&128;){if(l[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===h){h+=255;let m=new Uint8Array(h);for(let f=0;f<l.length;f++)m[f]=l[f];l=this.valueHexView=new Uint8Array(h)}}this.blockLength=c+1,l[c-1]=o[c]&127;let u=new Uint8Array(c);for(let m=0;m<c;m++)u[m]=l[m];l=this.valueHexView=new Uint8Array(c),l.set(u),this.blockLength<=9?this.tagNumber=je(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return e+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};kn.NAME="identificationBlock";var Rn=class extends ce{constructor({lenBlock:t={}}={}){var e,n,s;super(),this.isIndefiniteForm=(e=t.isIndefiniteForm)!==null&&e!==void 0?e:!1,this.longFormUsed=(n=t.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=t.length)!==null&&s!==void 0?s:0}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!fe(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;if(o[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,e+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,e+this.blockLength;let i=o[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;let a=e+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=je(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,e+this.blockLength}toBER(t=!1){let e,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=128),e;if(this.longFormUsed){let s=Re(this.length,8);if(s.byteLength>127)return this.error="Too big length",Ht;if(e=new ArrayBuffer(s.byteLength+1),t)return e;let o=new Uint8Array(s);n=new Uint8Array(e),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return e}return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Rn.NAME="lengthBlock";var I={},mt=class extends ce{constructor({name:t=yr,optional:e=!1,primitiveSchema:n,...s}={},o){super(s),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new kn(s),this.lenBlock=new Rn(s),this.valueBlock=o?new o(s):new vt(s)}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(t,e){let n=e||new Hr;e||Oa(this);let s=this.idBlock.toBER(t);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(t);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(t);n.write(i),n.write(o)}return e?Ht:n.final()}toJSON(){let t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;let e=this.toBER(),n=t.toBER();return _a(e,n)}};mt.NAME="BaseBlock";function Oa(r){if(r instanceof I.Constructed)for(let t of r.valueBlock.value)Oa(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Nn=class extends mt{constructor({value:t=yr,...e}={},n){super(e,n),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Nn.NAME="BaseStringBlock";var Tn=class extends he(vt){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};Tn.NAME="PrimitiveValueBlock";var Va,Ln=class extends mt{constructor(t={}){super(t,Tn),this.idBlock.isConstructed=!1}};Va=Ln;I.Primitive=Va;Ln.NAME="PRIMITIVE";function Bh(r,t){if(r instanceof t)return r;let e=new t;return e.idBlock=r.idBlock,e.lenBlock=r.lenBlock,e.warnings=r.warnings,e.valueBeforeDecodeView=r.valueBeforeDecodeView,e}function us(r,t=0,e=r.length){let n=t,s=new mt({},vt),o=new ce;if(!fe(o,r,t,e))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(t,t+e).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,t,e);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=a,e-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,t,e),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=a,e-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=mt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=I.EndOfContent;break;case 1:c=I.Boolean;break;case 2:c=I.Integer;break;case 3:c=I.BitString;break;case 4:c=I.OctetString;break;case 5:c=I.Null;break;case 6:c=I.ObjectIdentifier;break;case 10:c=I.Enumerated;break;case 12:c=I.Utf8String;break;case 13:c=I.RelativeObjectIdentifier;break;case 14:c=I.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=I.Sequence;break;case 17:c=I.Set;break;case 18:c=I.NumericString;break;case 19:c=I.PrintableString;break;case 20:c=I.TeletexString;break;case 21:c=I.VideotexString;break;case 22:c=I.IA5String;break;case 23:c=I.UTCTime;break;case 24:c=I.GeneralizedTime;break;case 25:c=I.GraphicString;break;case 26:c=I.VisibleString;break;case 27:c=I.GeneralString;break;case 28:c=I.UniversalString;break;case 29:c=I.CharacterString;break;case 30:c=I.BmpString;break;case 31:c=I.DATE;break;case 32:c=I.TimeOfDay;break;case 33:c=I.DateTime;break;case 34:c=I.Duration;break;default:{let l=s.idBlock.isConstructed?new I.Constructed:new I.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?I.Constructed:I.Primitive}return s=Bh(s,c),a=s.fromBER(r,t,s.lenBlock.isIndefiniteForm?e:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function br(r){if(!r.byteLength){let t=new mt({},vt);return t.error="Input buffer has zero length",{offset:-1,result:t}}return us(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Ah(r,t){return r?1:t}var zt=class extends vt{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!fe(this,s,e,n))return-1;if(this.valueBeforeDecodeView=s.subarray(e,e+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),e;let o=e;for(;Ah(this.isIndefiniteForm,n)>0;){let i=us(s,o,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Mr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Mr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new Hr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(t,n);return e?Ht:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};zt.NAME="ConstructedValueBlock";var Fa,Ne=class extends mt{constructor(t={}){super(t,zt),this.idBlock.isConstructed=!0}fromBER(t,e,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let t=[];for(let n of this.valueBlock.value)t.push(n.toString("ascii").split(`
3
+ `).map(s=>` ${s}`).join(`
4
+ `));let e=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return t.length?`${e} :
5
+ ${t.join(`
6
+ `)}`:`${e} :`}};Fa=Ne;I.Constructed=Fa;Ne.NAME="CONSTRUCTED";var _n=class extends vt{fromBER(t,e,n){return e}toBER(t){return Ht}};_n.override="EndOfContentValueBlock";var Ha,Cn=class extends mt{constructor(t={}){super(t,_n),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Ha=Cn;I.EndOfContent=Ha;Cn.NAME=Mr;var Ma,Te=class extends mt{constructor(t={}){super(t,vt),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,e,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,e+n>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):e+n}toBER(t,e){let n=new ArrayBuffer(2);if(!t){let s=new Uint8Array(n);s[0]=5,s[1]=0}return e&&e.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Ma=Te;I.Null=Ma;Te.NAME="NULL";var Un=class extends he(vt){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=H.BufferSourceConverter.toUint8Array(e.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(let t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);return fe(this,s,e,n)?(this.valueHexView=s.subarray(e,e+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,_o.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Un.NAME="BooleanValueBlock";var $a,Pn=class extends mt{constructor(t={}){super(t,Un),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};$a=Pn;I.Boolean=$a;Pn.NAME="BOOLEAN";var Dn=class extends he(zt){constructor({isConstructed:t=!1,...e}={}){super(e),this.isConstructed=t}fromBER(t,e,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=zt.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==Pa)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(t,e,n),this.blockLength=n;return s}toBER(t,e){return this.isConstructed?zt.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Dn.NAME="OctetStringValueBlock";var Ka,le=class r extends mt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Dn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,e,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),e;if(!this.valueBlock.isConstructed){let o=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(e,e+n);try{if(o.byteLength){let i=us(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(t,e,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ne.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let t=[];for(let e of this.valueBlock.value)e instanceof r&&t.push(e.valueBlock.valueHexView);return H.BufferSourceConverter.concat(t)}};Ka=le;I.OctetString=Ka;le.NAME=Pa;var On=class extends he(zt){constructor({unusedBits:t=0,isConstructed:e=!1,...n}={}){super(n),this.unusedBits=t,this.isConstructed=e,this.blockLength=this.valueHexView.byteLength}fromBER(t,e,n){if(!n)return e;let s=-1;if(this.isConstructed){if(s=zt.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Da)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return s}let o=H.BufferSourceConverter.toUint8Array(t);if(!fe(this,o,e,n))return-1;let i=o.subarray(e,e+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=us(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,e+n}toBER(t,e){if(this.isConstructed)return zt.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ht;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};On.NAME="BitStringValueBlock";var qa,mr=class extends mt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},On),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,e,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,e,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ne.prototype.onAsciiEncoding.call(this);{let t=[],e=this.valueBlock.valueHexView;for(let s of e)t.push(s.toString(2).padStart(8,"0"));let n=t.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};qa=mr;I.BitString=qa;mr.NAME=Da;var za;function Ih(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l=0,h=c<i?i:c,u=0;for(let m=h;m>=0;m--,u++){switch(!0){case u<a.length:l=o[i-u]+a[c-u]+e[0];break;default:l=o[i-u]+e[0]}switch(e[0]=l/10,!0){case u>=o.length:o=In(new Uint8Array([l%10]),o);break;default:o[i-u]=l%10}}return e[0]>0&&(o=In(e,o)),o}function Ua(r){if(r>=Fr.length)for(let t=Fr.length;t<=r;t++){let e=new Uint8Array([0]),n=Fr[t-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+e[0]]);e[0]=o[0]/10,n[s]=o[0]%10}e[0]>0&&(n=In(e,n)),Fr.push(n)}return Fr[r]}function Sh(r,t){let e=0,n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l,h=0;for(let u=c;u>=0;u--,h++)switch(l=o[i-h]-a[c-h]-e,!0){case l<0:e=1,o[i-h]=l+10;break;default:e=0,o[i-h]=l}if(e>0)for(let u=i-c+1;u>=0;u--,h++)if(l=o[i-h]-e,l<0)e=1,o[i-h]=l+10;else{e=0,o[i-h]=l;break}return o.slice()}var $r=class extends he(vt){constructor({value:t,...e}={}){super(e),this._valueDec=0,e.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=_o.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(La(t))}get valueDec(){return this._valueDec}fromDER(t,e,n,s=0){let o=this.fromBER(t,e,n);if(o===-1)return o;let i=this.valueHexView;return i[0]===0&&i[1]&128?this.valueHexView=i.subarray(1):s!==0&&i.length<s&&(s-i.length>1&&(s=i.length+1),this.valueHexView=i.subarray(s-i.length)),o}toDER(t=!1){let e=this.valueHexView;switch(!0){case(e[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(e,1),this.valueHexView=n}break;case(e[0]===0&&(e[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,e,n){let s=super.fromBER(t,e,n);return s===-1||this.setValueHex(),s}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let t=this.valueHexView.length*8-1,e=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let l=0;l<8;l++){if((s&1)===1)switch(n){case t:e=Sh(Ua(n),e),i="-";break;default:e=Ih(e,Ua(n))}n++,s>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(i+=Ca.charAt(e[c]));return a===!1&&(i+=Ca.charAt(0)),i}};za=$r;$r.NAME="IntegerValueBlock";Object.defineProperty(za.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var ja,ot=class r extends mt{constructor(t={}){super(t,$r),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Sn(),BigInt(this.valueBlock.toString())}static fromBigInt(t){Sn();let e=BigInt(t),n=new Hr,s=e.toString(16).replace(/^-/,""),o=new Uint8Array(H.Convert.FromHex(s));if(e<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${H.Convert.ToHex(a)}`)+e,h=H.BufferSourceConverter.toUint8Array(H.Convert.FromHex(l.toString(16)));h[0]|=128,n.write(h)}else o[0]&128&&n.write(new Uint8Array([0])),n.write(o);return new r({valueHex:n.final()})}convertToDER(){let t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};ja=ot;I.Integer=ja;ot.NAME="INTEGER";var Ga,Vn=class extends ot{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Ga=Vn;I.Enumerated=Ga;Vn.NAME="ENUMERATED";var Kr=class extends he(vt){constructor({valueDec:t=-1,isFirstSid:e=!1,...n}={}){super(n),this.valueDec=t,this.isFirstSid=e}fromBER(t,e,n){if(!n)return e;let s=H.BufferSourceConverter.toUint8Array(t);if(!fe(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=je(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){Sn();let e=BigInt(t).toString(2);for(;e.length%7;)e="0"+e;let n=new Uint8Array(e.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(e.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=Re(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Ht;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let t="";if(this.isHexOnly)t=H.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let e=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",e-=40):(t="2.",e-=80),t+=e.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Kr.NAME="sidBlock";var Fn=class extends vt{constructor({value:t=yr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Kr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.value.length===0&&(o.isFirstSid=!0),this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t){let e=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(t);if(s.byteLength===0)return this.error=this.value[n].error,Ht;e.push(s)}return Co(e)}fromString(t){this.value=[];let e=0,n=0,s="",o=!1;do if(n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1,o){let i=this.value[0],a=0;switch(i.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(s,10);if(isNaN(c))return;i.valueDec=c+a,o=!1}else{let i=new Kr;if(s>Number.MAX_SAFE_INTEGER){Sn();let a=BigInt(s);i.valueBigInt=a}else if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,o=!0),this.value.push(i)}while(n!==-1)}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e?(s=`{${s}}`,this.value[n].isFirstSid?t=`2.{${s} - 80}`:t+=s):t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};Fn.NAME="ObjectIdentifierValueBlock";var Wa,Ft=class extends mt{constructor(t={}){super(t,Fn),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Wa=Ft;I.ObjectIdentifier=Wa;Ft.NAME="OBJECT IDENTIFIER";var qr=class extends he(ce){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let s=H.BufferSourceConverter.toUint8Array(t);if(!fe(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=je(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=Re(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Ht;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let t="";return this.isHexOnly?t=H.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};qr.NAME="relativeSidBlock";var Hn=class extends vt{constructor({value:t=yr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new qr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t,e){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(t);if(o.byteLength===0)return this.error=this.value[s].error,Ht;n.push(o)}return Co(n)}fromString(t){this.value=[];let e=0,n=0,s="";do{n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1;let o=new qr;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e&&(s=`{${s}}`),t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};Hn.NAME="RelativeObjectIdentifierValueBlock";var Za,Mn=class extends mt{constructor(t={}){super(t,Hn),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Za=Mn;I.RelativeObjectIdentifier=Za;Mn.NAME="RelativeObjectIdentifier";var Ya,ft=class extends Ne{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Ya=ft;I.Sequence=Ya;ft.NAME="SEQUENCE";var Ja,$n=class extends Ne{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Ja=$n;I.Set=Ja;$n.NAME="SET";var Kn=class extends he(vt){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=yr}toJSON(){return{...super.toJSON(),value:this.value}}};Kn.NAME="StringValueBlock";var qn=class extends Kn{};qn.NAME="SimpleStringValueBlock";var It=class extends Nn{constructor({...t}={}){super(t,qn)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,H.BufferSourceConverter.toUint8Array(t))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);this.valueBlock.value=t}};It.NAME="SIMPLE STRING";var zn=class extends It{fromBuffer(t){this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=H.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=H.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf8String(t)),this.valueBlock.value=t}};zn.NAME="Utf8StringValueBlock";var Xa,ue=class extends zn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Xa=ue;I.Utf8String=Xa;ue.NAME="UTF8String";var jn=class extends It{fromBuffer(t){this.valueBlock.value=H.Convert.ToUtf16String(t),this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf16String(t))}};jn.NAME="BmpStringValueBlock";var Qa,Gn=class extends jn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Qa=Gn;I.BmpString=Qa;Gn.NAME="BMPString";var Wn=class extends It{fromBuffer(t){let e=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),n=new Uint8Array(e);for(let s=0;s<n.length;s+=4)n[s]=n[s+3],n[s+1]=n[s+2],n[s+2]=0,n[s+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(e))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e*4);for(let s=0;s<e;s++){let o=Re(t.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[s*4+c+a]=i[c]}this.valueBlock.value=t}};Wn.NAME="UniversalStringValueBlock";var tc,Zn=class extends Wn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};tc=Zn;I.UniversalString=tc;Zn.NAME="UniversalString";var ec,Yn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};ec=Yn;I.NumericString=ec;Yn.NAME="NumericString";var rc,Jn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};rc=Jn;I.PrintableString=rc;Jn.NAME="PrintableString";var nc,Xn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};nc=Xn;I.TeletexString=nc;Xn.NAME="TeletexString";var sc,Qn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};sc=Qn;I.VideotexString=sc;Qn.NAME="VideotexString";var oc,ts=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};oc=ts;I.IA5String=oc;ts.NAME="IA5String";var ic,es=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};ic=es;I.GraphicString=ic;es.NAME="GraphicString";var ac,zr=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};ac=zr;I.VisibleString=ac;zr.NAME="VisibleString";var cc,rs=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};cc=rs;I.GeneralString=cc;rs.NAME="GeneralString";var lc,ns=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};lc=ns;I.CharacterString=lc;ns.NAME="CharacterString";var uc,jr=class extends zr{constructor({value:t,valueDate:e,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let s=0;s<t.length;s++)this.valueBlock.valueHexView[s]=t.charCodeAt(s)}e&&(this.fromDate(e),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,H.BufferSourceConverter.toUint8Array(t)))}toBuffer(){let t=this.toString(),e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return e}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);if(n===null){this.error="Wrong input string for conversion";return}let s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(t="iso"){if(t==="iso"){let e=new Array(7);return e[0]=kt(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=kt(this.month,2),e[2]=kt(this.day,2),e[3]=kt(this.hour,2),e[4]=kt(this.minute,2),e[5]=kt(this.second,2),e[6]="Z",e.join("")}return super.toString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};uc=jr;I.UTCTime=uc;jr.NAME="UTCTime";var fc,ss=class extends jr{constructor(t={}){var e;super(t),(e=this.millisecond)!==null&&e!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let e=!1,n="",s="",o=0,i,a=0,c=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let u=new Number(t[t.length-1]);if(isNaN(u.valueOf()))throw new Error("Wrong input string for conversion");n=t}if(e){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let u=1,m=n.indexOf("+"),f="";if(m===-1&&(m=n.indexOf("-"),u=-1),m!==-1){if(f=n.substring(m+1),n=n.substring(0,m),f.length!==2&&f.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(f.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(a=u*p,f.length===4){if(p=parseInt(f.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=u*p}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let u=new Number(`0${n.substring(l)}`);if(isNaN(u.valueOf()))throw new Error("Wrong input string for conversion");o=u.valueOf(),s=n.substring(0,l)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=60*o;this.minute=Math.floor(u),u=60*(u-this.minute),this.second=Math.floor(u),u=1e3*(u-this.second),this.millisecond=Math.floor(u)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=60*o;this.second=Math.floor(u),u=1e3*(u-this.second),this.millisecond=Math.floor(u)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=1e3*o;this.millisecond=Math.floor(u)}break;default:throw new Error("Wrong input string for conversion")}let h=i.exec(s);if(h===null)throw new Error("Wrong input string for conversion");for(let u=1;u<h.length;u++)switch(u){case 1:this.year=parseInt(h[u],10);break;case 2:this.month=parseInt(h[u],10);break;case 3:this.day=parseInt(h[u],10);break;case 4:this.hour=parseInt(h[u],10)+a;break;case 5:this.minute=parseInt(h[u],10)+c;break;case 6:this.second=parseInt(h[u],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let u=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=u.getUTCFullYear(),this.month=u.getUTCMonth(),this.day=u.getUTCDay(),this.hour=u.getUTCHours(),this.minute=u.getUTCMinutes(),this.second=u.getUTCSeconds(),this.millisecond=u.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(kt(this.year,4)),e.push(kt(this.month,2)),e.push(kt(this.day,2)),e.push(kt(this.hour,2)),e.push(kt(this.minute,2)),e.push(kt(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(kt(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};fc=ss;I.GeneralizedTime=fc;ss.NAME="GeneralizedTime";var hc,os=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};hc=os;I.DATE=hc;os.NAME="DATE";var dc,is=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};dc=is;I.TimeOfDay=dc;is.NAME="TimeOfDay";var pc,as=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};pc=as;I.DateTime=pc;as.NAME="DateTime";var gc,cs=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};gc=cs;I.Duration=gc;cs.NAME="Duration";var mc,ls=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};mc=ls;I.TIME=mc;ls.NAME="TIME";function Rh(r){let{result:t}=br(r),e=t.valueBlock.value;return{n:z(jt(e[1].toBigInt()),"base64url"),e:z(jt(e[2].toBigInt()),"base64url"),d:z(jt(e[3].toBigInt()),"base64url"),p:z(jt(e[4].toBigInt()),"base64url"),q:z(jt(e[5].toBigInt()),"base64url"),dp:z(jt(e[6].toBigInt()),"base64url"),dq:z(jt(e[7].toBigInt()),"base64url"),qi:z(jt(e[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Nh(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new C("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ft({value:[new ot({value:0}),ot.fromBigInt(Gt(Y(r.n,"base64url"))),ot.fromBigInt(Gt(Y(r.e,"base64url"))),ot.fromBigInt(Gt(Y(r.d,"base64url"))),ot.fromBigInt(Gt(Y(r.p,"base64url"))),ot.fromBigInt(Gt(Y(r.q,"base64url"))),ot.fromBigInt(Gt(Y(r.dp,"base64url"))),ot.fromBigInt(Gt(Y(r.dq,"base64url"))),ot.fromBigInt(Gt(Y(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Th(r){let{result:t}=br(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:z(jt(e[0].toBigInt()),"base64url"),e:z(jt(e[1].toBigInt()),"base64url")}}function Lh(r){if(r.n==null||r.e==null)throw new C("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ft({value:[new ft({value:[new Ft({value:"1.2.840.113549.1.1.1"}),new Te]}),new mr({valueHex:new ft({value:[ot.fromBigInt(Gt(Y(r.n,"base64url"))),ot.fromBigInt(Gt(Y(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function jt(r){let t=r.toString(16);t.length%2>0&&(t=`0${t}`);let e=t.length/2,n=new Uint8Array(e),s=0,o=0;for(;s<e;)n[s]=parseInt(t.slice(o,o+2),16),s+=1,o+=2;return n}function Gt(r){let t=[];return r.forEach(function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)}),BigInt("0x"+t.join(""))}var _h=16,Po=32,Do=1e4;async function Ch(r,t){let e=At.get(),s=new ft({value:[new ot({value:0}),new ft({value:[new Ft({value:"1.2.840.113549.1.1.1"}),new Te]}),new le({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=ze(_h),a=await To(cr,t,i,{c:Do,dkLen:Po}),c=ze(16),l=await e.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),h=await e.subtle.encrypt({name:"AES-CBC",iv:c},l,o),u=new ft({value:[new le({valueHex:i}),new ot({value:Do}),new ot({value:Po}),new ft({value:[new Ft({value:"1.2.840.113549.2.11"}),new Te]})]}),m=new ft({value:[new Ft({value:"1.2.840.113549.1.5.13"}),new ft({value:[new ft({value:[new Ft({value:"1.2.840.113549.1.5.12"}),u]}),new ft({value:[new Ft({value:"2.16.840.1.101.3.4.1.42"}),new le({valueHex:c})]})]})]}),p=new ft({value:[m,new le({valueHex:h})]}).toBER(),d=new Uint8Array(p,0,p.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...z(d,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
7
+ `)}async function Uh(r,t){let e=At.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let s=Y(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=br(s),{iv:i,salt:a,iterations:c,keySize:l,cipherText:h}=Ph(o),u=await To(cr,t,a,{c,dkLen:l}),m=await e.subtle.importKey("raw",u,"AES-CBC",!1,["decrypt"]),f=Gr(await e.subtle.decrypt({name:"AES-CBC",iv:i},m,h)),{result:p}=br(f);n=yc(p)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let s=Y(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=br(s);n=yc(o)}else throw new C("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Oo(n)}function Ph(r){let t=r.valueBlock.value[0];if(t.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new C("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=t.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new C("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let o=n.valueBlock.value[1],i=Gr(o.valueBlock.value[0].getValue()),a=Do,c=Po;if(o.valueBlock.value.length===3)a=Number(o.valueBlock.value[1].toBigInt()),c=Number(o.valueBlock.value[2].toBigInt());else if(o.valueBlock.value.length===2)throw new C("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let l=t.valueBlock.value[1].valueBlock.value[1],h=l.valueBlock.value[0].toString();if(h!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(h!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(h!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(h!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(h!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new C("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let u=Gr(l.valueBlock.value[1].getValue());return{cipherText:Gr(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:u}}function yc(r){return Gr(r.valueBlock.value[2].getValue())}function Gr(r){return new Uint8Array(r,0,r.byteLength)}async function bc(r){let t=await At.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await vc(t);return{privateKey:e[0],publicKey:e[1]}}async function Vo(r){let e=[await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Dh(r)],n=await vc({privateKey:e[0],publicKey:e[1]});return{privateKey:n[0],publicKey:n[1]}}async function wc(r,t){let e=await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await At.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function xc(r,t,e){let n=await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return At.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function vc(r){if(r.privateKey==null||r.publicKey==null)throw new C("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([At.get().subtle.exportKey("jwk",r.privateKey),At.get().subtle.exportKey("jwk",r.publicKey)])}async function Dh(r){return At.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function fs(r){if(r.kty!=="RSA")throw new C("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new C("invalid key modulus","ERR_INVALID_KEY_MODULUS");return Y(r.n,"base64url").length*8}var Zr=8192,Wr=class{_key;constructor(t){this._key=t}verify(t,e){return xc(this._key,e,t)}marshal(){return Le.jwkToPkix(this._key)}get bytes(){return Se.encode({Type:gt.RSA,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}},wr=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e}genSecret(){return ze(16)}sign(t){return wc(this._key,t)}get public(){if(this._publicKey==null)throw new C("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Wr(this._publicKey)}marshal(){return Le.jwkToPkcs1(this._key)}get bytes(){return ke.encode({Type:gt.RSA,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return z(t,"base58btc")}async export(t,e="pkcs-8"){if(e==="pkcs-8")return Le.exportToPem(this,t);if(e==="libp2p-key")return fr(this.bytes,t);throw new C(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Oo(r){let t=Le.pkcs1ToJwk(r);if(fs(t)>Zr)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Vo(t);return new wr(e.privateKey,e.publicKey)}function Vh(r){let t=Le.pkixToJwk(r);if(fs(t)>Zr)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Wr(t)}async function Fh(r){if(fs(r)>Zr)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Vo(r);return new wr(t.privateKey,t.publicKey)}async function Hh(r){if(r>Zr)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await bc(r);return new wr(t.privateKey,t.publicKey)}var qo={};ut(qo,{Secp256k1PrivateKey:()=>Jr,Secp256k1PublicKey:()=>Yr,generateKeyPair:()=>ed,unmarshalSecp256k1PrivateKey:()=>Qh,unmarshalSecp256k1PublicKey:()=>td});var Mh=(r,t,e)=>r&t^~r&e,$h=(r,t,e)=>r&t^r&e^t&e,Kh=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ce=new Uint32Array(64),Ho=class extends ar{constructor(){super(64,32,8,!1),this.A=_e[0]|0,this.B=_e[1]|0,this.C=_e[2]|0,this.D=_e[3]|0,this.E=_e[4]|0,this.F=_e[5]|0,this.G=_e[6]|0,this.H=_e[7]|0}get(){let{A:t,B:e,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[t,e,n,s,o,i,a,c]}set(t,e,n,s,o,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let u=0;u<16;u++,e+=4)Ce[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let m=Ce[u-15],f=Ce[u-2],p=Pt(m,7)^Pt(m,18)^m>>>3,d=Pt(f,17)^Pt(f,19)^f>>>10;Ce[u]=d+Ce[u-7]+p+Ce[u-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){let m=Pt(a,6)^Pt(a,11)^Pt(a,25),f=h+m+Mh(a,c,l)+Kh[u]+Ce[u]|0,d=(Pt(n,2)^Pt(n,13)^Pt(n,22))+$h(n,s,o)|0;h=l,l=c,c=a,a=i+f|0,i=o,o=s,s=n,n=f+d|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,s,o,i,a,c,l,h)}roundClean(){Ce.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ec=un(()=>new Ho);function qh(r){let t=Cr(r);qt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:s}=t;if(e){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:zh,hexToBytes:jh}=dn,Ge={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Ge;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:zh(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Ge,e=typeof r=="string"?jh(r):r;if(!Dt(e))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:s,l:o}=Ge._parseInt(e.subarray(2)),{d:i,l:a}=Ge._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(r){let t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,e=l=>{let h=l.toString(16);return h.length&1?`0${h}`:h},n=t(e(r.s)),s=t(e(r.r)),o=n.length/2,i=s.length/2,a=e(o),c=e(i);return`30${e(i+o+4)}02${c}${s}02${a}${n}`}},de=BigInt(0),Ct=BigInt(1),Cm=BigInt(2),Bc=BigInt(3),Um=BigInt(4);function Gh(r){let t=qh(r),{Fp:e}=t,n=t.toBytes||((p,d,g)=>{let y=d.toAffine();return ee(Uint8Array.from([4]),e.toBytes(y.x),e.toBytes(y.y))}),s=t.fromBytes||(p=>{let d=p.subarray(1),g=e.fromBytes(d.subarray(0,e.BYTES)),y=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:g,y}});function o(p){let{a:d,b:g}=t,y=e.sqr(p),b=e.mul(y,p);return e.add(e.add(b,e.mul(p,d)),g)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function i(p){return typeof p=="bigint"&&de<p&&p<t.n}function a(p){if(!i(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(p){let{allowedPrivateKeyLengths:d,nByteLength:g,wrapPrivateKey:y,n:b}=t;if(d&&typeof p!="bigint"){if(Dt(p)&&(p=Qt(p)),typeof p!="string"||!d.includes(p.length))throw new Error("Invalid key");p=p.padStart(g*2,"0")}let w;try{w=typeof p=="bigint"?p:te(et("private key",p,g))}catch{throw new Error(`private key must be ${g} bytes, hex or bigint, not ${typeof p}`)}return y&&(w=Z(w,b)),a(w),w}let l=new Map;function h(p){if(!(p instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,g,y){if(this.px=d,this.py=g,this.pz=y,d==null||!e.isValid(d))throw new Error("x required");if(g==null||!e.isValid(g))throw new Error("y required");if(y==null||!e.isValid(y))throw new Error("z required")}static fromAffine(d){let{x:g,y}=d||{};if(!d||!e.isValid(g)||!e.isValid(y))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");let b=w=>e.eql(w,e.ZERO);return b(g)&&b(y)?u.ZERO:new u(g,y,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let g=e.invertBatch(d.map(y=>y.pz));return d.map((y,b)=>y.toAffine(g[b])).map(u.fromAffine)}static fromHex(d){let g=u.fromAffine(s(et("pointHex",d)));return g.assertValidity(),g}static fromPrivateKey(d){return u.BASE.multiply(c(d))}_setWindowSize(d){this._WINDOW_SIZE=d,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:d,y:g}=this.toAffine();if(!e.isValid(d)||!e.isValid(g))throw new Error("bad point: x or y not FE");let y=e.sqr(g),b=o(d);if(!e.eql(y,b))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){h(d);let{px:g,py:y,pz:b}=this,{px:w,py:k,pz:v}=d,A=e.eql(e.mul(g,v),e.mul(w,b)),N=e.eql(e.mul(y,v),e.mul(k,b));return A&&N}negate(){return new u(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:g}=t,y=e.mul(g,Bc),{px:b,py:w,pz:k}=this,v=e.ZERO,A=e.ZERO,N=e.ZERO,T=e.mul(b,b),q=e.mul(w,w),$=e.mul(k,k),D=e.mul(b,w);return D=e.add(D,D),N=e.mul(b,k),N=e.add(N,N),v=e.mul(d,N),A=e.mul(y,$),A=e.add(v,A),v=e.sub(q,A),A=e.add(q,A),A=e.mul(v,A),v=e.mul(D,v),N=e.mul(y,N),$=e.mul(d,$),D=e.sub(T,$),D=e.mul(d,D),D=e.add(D,N),N=e.add(T,T),T=e.add(N,T),T=e.add(T,$),T=e.mul(T,D),A=e.add(A,T),$=e.mul(w,k),$=e.add($,$),T=e.mul($,D),v=e.sub(v,T),N=e.mul($,q),N=e.add(N,N),N=e.add(N,N),new u(v,A,N)}add(d){h(d);let{px:g,py:y,pz:b}=this,{px:w,py:k,pz:v}=d,A=e.ZERO,N=e.ZERO,T=e.ZERO,q=t.a,$=e.mul(t.b,Bc),D=e.mul(g,w),nt=e.mul(y,k),rt=e.mul(b,v),Tt=e.add(g,y),E=e.add(w,k);Tt=e.mul(Tt,E),E=e.add(D,nt),Tt=e.sub(Tt,E),E=e.add(g,b);let R=e.add(w,v);return E=e.mul(E,R),R=e.add(D,rt),E=e.sub(E,R),R=e.add(y,b),A=e.add(k,v),R=e.mul(R,A),A=e.add(nt,rt),R=e.sub(R,A),T=e.mul(q,E),A=e.mul($,rt),T=e.add(A,T),A=e.sub(nt,T),T=e.add(nt,T),N=e.mul(A,T),nt=e.add(D,D),nt=e.add(nt,D),rt=e.mul(q,rt),E=e.mul($,E),nt=e.add(nt,rt),rt=e.sub(D,rt),rt=e.mul(q,rt),E=e.add(E,rt),D=e.mul(nt,E),N=e.add(N,D),D=e.mul(R,E),A=e.mul(Tt,A),A=e.sub(A,D),D=e.mul(Tt,nt),T=e.mul(R,T),T=e.add(T,D),new u(A,N,T)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return f.wNAFCached(this,l,d,g=>{let y=e.invertBatch(g.map(b=>b.pz));return g.map((b,w)=>b.toAffine(y[w])).map(u.fromAffine)})}multiplyUnsafe(d){let g=u.ZERO;if(d===de)return g;if(a(d),d===Ct)return this;let{endo:y}=t;if(!y)return f.unsafeLadder(this,d);let{k1neg:b,k1:w,k2neg:k,k2:v}=y.splitScalar(d),A=g,N=g,T=this;for(;w>de||v>de;)w&Ct&&(A=A.add(T)),v&Ct&&(N=N.add(T)),T=T.double(),w>>=Ct,v>>=Ct;return b&&(A=A.negate()),k&&(N=N.negate()),N=new u(e.mul(N.px,y.beta),N.py,N.pz),A.add(N)}multiply(d){a(d);let g=d,y,b,{endo:w}=t;if(w){let{k1neg:k,k1:v,k2neg:A,k2:N}=w.splitScalar(g),{p:T,f:q}=this.wNAF(v),{p:$,f:D}=this.wNAF(N);T=f.constTimeNegate(k,T),$=f.constTimeNegate(A,$),$=new u(e.mul($.px,w.beta),$.py,$.pz),y=T.add($),b=q.add(D)}else{let{p:k,f:v}=this.wNAF(g);y=k,b=v}return u.normalizeZ([y,b])[0]}multiplyAndAddUnsafe(d,g,y){let b=u.BASE,w=(v,A)=>A===de||A===Ct||!v.equals(b)?v.multiplyUnsafe(A):v.multiply(A),k=w(this,g).add(w(d,y));return k.is0()?void 0:k}toAffine(d){let{px:g,py:y,pz:b}=this,w=this.is0();d==null&&(d=w?e.ONE:e.inv(b));let k=e.mul(g,d),v=e.mul(y,d),A=e.mul(b,d);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(A,e.ONE))throw new Error("invZ was invalid");return{x:k,y:v}}isTorsionFree(){let{h:d,isTorsionFree:g}=t;if(d===Ct)return!0;if(g)return g(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:g}=t;return d===Ct?this:g?g(u,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return this.assertValidity(),n(u,this,d)}toHex(d=!0){return Qt(this.toRawBytes(d))}}u.BASE=new u(t.Gx,t.Gy,e.ONE),u.ZERO=new u(e.ZERO,e.ONE,e.ZERO);let m=t.nBitLength,f=mn(u,t.endo?Math.ceil(m/2):m);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function Wh(r){let t=Cr(r);return qt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ac(r){let t=Wh(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return de<E&&E<e.ORDER}function a(E){return Z(E,n)}function c(E){return pn(E,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:m}=Gh({...t,toBytes(E,R,O){let B=R.toAffine(),x=e.toBytes(B.x),S=ee;return O?S(Uint8Array.from([R.hasEvenY()?2:3]),x):S(Uint8Array.from([4]),x,e.toBytes(B.y))},fromBytes(E){let R=E.length,O=E[0],B=E.subarray(1);if(R===s&&(O===2||O===3)){let x=te(B);if(!i(x))throw new Error("Point is not on curve");let S=u(x),L=e.sqrt(S),_=(L&Ct)===Ct;return(O&1)===1!==_&&(L=e.neg(L)),{x,y:L}}else if(R===o&&O===4){let x=e.fromBytes(B.subarray(0,e.BYTES)),S=e.fromBytes(B.subarray(e.BYTES,2*e.BYTES));return{x,y:S}}else throw new Error(`Point of length ${R} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),f=E=>Qt(Ae(E,t.nByteLength));function p(E){let R=n>>Ct;return E>R}function d(E){return p(E)?a(-E):E}let g=(E,R,O)=>te(E.slice(R,O));class y{constructor(R,O,B){this.r=R,this.s=O,this.recovery=B,this.assertValidity()}static fromCompact(R){let O=t.nByteLength;return R=et("compactSignature",R,O*2),new y(g(R,0,O),g(R,O,2*O))}static fromDER(R){let{r:O,s:B}=Ge.toSig(et("DER",R));return new y(O,B)}assertValidity(){if(!m(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!m(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(R){return new y(this.r,this.s,R)}recoverPublicKey(R){let{r:O,s:B,recovery:x}=this,S=N(et("msgHash",R));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let L=x===2||x===3?O+t.n:O;if(L>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=x&1?"03":"02",V=l.fromHex(_+f(L)),F=c(L),G=a(-S*F),M=a(B*F),K=l.BASE.multiplyAndAddUnsafe(V,G,M);if(!K)throw new Error("point at infinify");return K.assertValidity(),K}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Fe(this.toDERHex())}toDERHex(){return Ge.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Fe(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}let b={isValidPrivateKey(E){try{return h(E),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let E=lo(t.n);return ua(t.randomBytes(E),t.n)},precompute(E=8,R=l.BASE){return R._setWindowSize(E),R.multiply(BigInt(3)),R}};function w(E,R=!0){return l.fromPrivateKey(E).toRawBytes(R)}function k(E){let R=Dt(E),O=typeof E=="string",B=(R||O)&&E.length;return R?B===s||B===o:O?B===2*s||B===2*o:E instanceof l}function v(E,R,O=!0){if(k(E))throw new Error("first arg must be private key");if(!k(R))throw new Error("second arg must be public key");return l.fromHex(R).multiply(h(E)).toRawBytes(O)}let A=t.bits2int||function(E){let R=te(E),O=E.length*8-t.nBitLength;return O>0?R>>BigInt(O):R},N=t.bits2int_modN||function(E){return a(A(E))},T=_r(t.nBitLength);function q(E){if(typeof E!="bigint")throw new Error("bigint expected");if(!(de<=E&&E<T))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Ae(E,t.nByteLength)}function $(E,R,O=D){if(["recovered","canonical"].some(Q=>Q in O))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:x}=t,{lowS:S,prehash:L,extraEntropy:_}=O;S==null&&(S=!0),E=et("msgHash",E),L&&(E=et("prehashed msgHash",B(E)));let V=N(E),F=h(R),G=[q(F),q(V)];if(_!=null){let Q=_===!0?x(e.BYTES):_;G.push(et("extraEntropy",Q))}let M=ee(...G),K=V;function st(Q){let ht=A(Q);if(!m(ht))return;let dt=c(ht),at=l.BASE.multiply(ht).toAffine(),yt=a(at.x);if(yt===de)return;let Wt=a(dt*a(K+yt*F));if(Wt===de)return;let De=(at.x===yt?0:2)|Number(at.y&Ct),kr=Wt;return S&&p(Wt)&&(kr=d(Wt),De^=1),new y(yt,kr,De)}return{seed:M,k2sig:st}}let D={lowS:t.lowS,prehash:!1},nt={lowS:t.lowS,prehash:!1};function rt(E,R,O=D){let{seed:B,k2sig:x}=$(E,R,O),S=t;return oo(S.hash.outputLen,S.nByteLength,S.hmac)(B,x)}l.BASE._setWindowSize(8);function Tt(E,R,O,B=nt){let x=E;if(R=et("msgHash",R),O=et("publicKey",O),"strict"in B)throw new Error("options.strict was renamed to lowS");let{lowS:S,prehash:L}=B,_,V;try{if(typeof x=="string"||Dt(x))try{_=y.fromDER(x)}catch(at){if(!(at instanceof Ge.Err))throw at;_=y.fromCompact(x)}else if(typeof x=="object"&&typeof x.r=="bigint"&&typeof x.s=="bigint"){let{r:at,s:yt}=x;_=new y(at,yt)}else throw new Error("PARSE");V=l.fromHex(O)}catch(at){if(at.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(S&&_.hasHighS())return!1;L&&(R=t.hash(R));let{r:F,s:G}=_,M=N(R),K=c(G),st=a(M*K),Q=a(F*K),ht=l.BASE.multiplyAndAddUnsafe(V,st,Q)?.toAffine();return ht?a(ht.x)===F:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:v,sign:rt,verify:Tt,ProjectivePoint:l,Signature:y,utils:b}}function Zh(r){return{hash:r,hmac:(t,...e)=>Vr(r,t,ln(...e)),randomBytes:ir}}function Ic(r,t){let e=n=>Ac({...r,...Zh(n)});return Object.freeze({...e(t),create:e})}var Rc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Sc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Yh=BigInt(1),Mo=BigInt(2),kc=(r,t)=>(r+t/Mo)/t;function Jh(r){let t=Rc,e=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,h=l*l*r%t,u=X(h,e,t)*h%t,m=X(u,e,t)*h%t,f=X(m,Mo,t)*l%t,p=X(f,s,t)*f%t,d=X(p,o,t)*p%t,g=X(d,a,t)*d%t,y=X(g,c,t)*g%t,b=X(y,a,t)*d%t,w=X(b,e,t)*h%t,k=X(w,i,t)*p%t,v=X(k,n,t)*l%t,A=X(v,Mo,t);if(!$o.eql($o.sqr(A),r))throw new Error("Cannot find square root");return A}var $o=gn(Rc,void 0,void 0,{sqrt:Jh}),Mt=Ic({a:BigInt(0),b:BigInt(7),Fp:$o,n:Sc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Sc,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Yh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),a=kc(o*r,t),c=kc(-n*r,t),l=Z(r-a*e-c*s,t),h=Z(-a*n-c*o,t),u=l>i,m=h>i;if(u&&(l=t-l),m&&(h=t-h),l>i||h>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:l,k2neg:m,k2:h}}}},Ec),Km=BigInt(0);var qm=Mt.ProjectivePoint;function Nc(){return Mt.utils.randomPrivateKey()}function Tc(r,t){let e=pt.digest(t instanceof Uint8Array?t:t.subarray());if(Lt(e))return e.then(({digest:n})=>Mt.sign(n,r).toDERRawBytes()).catch(n=>{throw new C(String(n),"ERR_INVALID_INPUT")});try{return Mt.sign(e.digest,r).toDERRawBytes()}catch(n){throw new C(String(n),"ERR_INVALID_INPUT")}}function Lc(r,t,e){let n=pt.digest(e instanceof Uint8Array?e:e.subarray());if(Lt(n))return n.then(({digest:s})=>Mt.verify(t,s,r)).catch(s=>{throw new C(String(s),"ERR_INVALID_INPUT")});try{return Mt.verify(t,n.digest,r)}catch(s){throw new C(String(s),"ERR_INVALID_INPUT")}}function _c(r){return Mt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Cc(r){try{Mt.getPublicKey(r,!0)}catch(t){throw new C(String(t),"ERR_INVALID_PRIVATE_KEY")}}function Ko(r){try{Mt.ProjectivePoint.fromHex(r)}catch(t){throw new C(String(t),"ERR_INVALID_PUBLIC_KEY")}}function Uc(r){try{return Mt.getPublicKey(r,!0)}catch(t){throw new C(String(t),"ERR_INVALID_PRIVATE_KEY")}}var Yr=class{_key;constructor(t){Ko(t),this._key=t}verify(t,e){return Lc(this._key,e,t)}marshal(){return _c(this._key)}get bytes(){return Se.encode({Type:gt.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}async hash(){let t=pt.digest(this.bytes),e;return Lt(t)?{bytes:e}=await t:e=t.bytes,e}},Jr=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e??Uc(t),Cc(this._key),Ko(this._publicKey)}sign(t){return Tc(this._key,t)}get public(){return new Yr(this._publicKey)}marshal(){return this._key}get bytes(){return ke.encode({Type:gt.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return z(t,"base58btc")}async export(t,e="libp2p-key"){if(e==="libp2p-key")return fr(this.bytes,t);throw new C(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Qh(r){return new Jr(r)}function td(r){return new Yr(r)}async function ed(){let r=Nc();return new Jr(r)}var Pc={rsa:Fo,ed25519:No,secp256k1:qo};function rd(r){let t=Object.keys(Pc).join(" / ");return new C(`invalid or unsupported key type ${r}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function zo(r){if(r=r.toLowerCase(),r==="rsa"||r==="ed25519"||r==="secp256k1")return Pc[r];throw rd(r)}async function Dc(r,t){return zo(r).generateKeyPair(t??2048)}function Oc(r,t){return t=(t??"rsa").toLowerCase(),zo(t),r.bytes}function Vc(r,t){return t=(t??"rsa").toLowerCase(),zo(t),r.bytes}var Fc=async()=>{let r=await Dc("Ed25519"),t=await nd(r);if(t.type==="Ed25519")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function nd(r){return Gi(Oc(r.public),Vc(r))}var sd=Math.pow(2,7),od=Math.pow(2,14),id=Math.pow(2,21),jo=Math.pow(2,28),Go=Math.pow(2,35),Wo=Math.pow(2,42),Zo=Math.pow(2,49),j=128,Et=127;function Rt(r){if(r<sd)return 1;if(r<od)return 2;if(r<id)return 3;if(r<jo)return 4;if(r<Go)return 5;if(r<Wo)return 6;if(r<Zo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ad(r,t,e=0){switch(Rt(r)){case 8:t[e++]=r&255|j,r/=128;case 7:t[e++]=r&255|j,r/=128;case 6:t[e++]=r&255|j,r/=128;case 5:t[e++]=r&255|j,r/=128;case 4:t[e++]=r&255|j,r>>>=7;case 3:t[e++]=r&255|j,r>>>=7;case 2:t[e++]=r&255|j,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function cd(r,t,e=0){switch(Rt(r)){case 8:t.set(e++,r&255|j),r/=128;case 7:t.set(e++,r&255|j),r/=128;case 6:t.set(e++,r&255|j),r/=128;case 5:t.set(e++,r&255|j),r/=128;case 4:t.set(e++,r&255|j),r>>>=7;case 3:t.set(e++,r&255|j),r>>>=7;case 2:t.set(e++,r&255|j),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function ld(r,t){let e=r[t],n=0;if(n+=e&Et,e<j||(e=r[t+1],n+=(e&Et)<<7,e<j)||(e=r[t+2],n+=(e&Et)<<14,e<j)||(e=r[t+3],n+=(e&Et)<<21,e<j)||(e=r[t+4],n+=(e&Et)*jo,e<j)||(e=r[t+5],n+=(e&Et)*Go,e<j)||(e=r[t+6],n+=(e&Et)*Wo,e<j)||(e=r[t+7],n+=(e&Et)*Zo,e<j))return n;throw new RangeError("Could not decode varint")}function ud(r,t){let e=r.get(t),n=0;if(n+=e&Et,e<j||(e=r.get(t+1),n+=(e&Et)<<7,e<j)||(e=r.get(t+2),n+=(e&Et)<<14,e<j)||(e=r.get(t+3),n+=(e&Et)<<21,e<j)||(e=r.get(t+4),n+=(e&Et)*jo,e<j)||(e=r.get(t+5),n+=(e&Et)*Go,e<j)||(e=r.get(t+6),n+=(e&Et)*Wo,e<j)||(e=r.get(t+7),n+=(e&Et)*Zo,e<j))return n;throw new RangeError("Could not decode varint")}function Ue(r,t,e=0){return t==null&&(t=wt(Rt(r))),t instanceof Uint8Array?ad(r,t,e):cd(r,t,e)}function pe(r,t=0){return r instanceof Uint8Array?ld(r,t):ud(r,t)}var ds=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*s)-1;for(;;){let h=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let m=Number.parseInt(u,t);if(!Number.isNaN(m))return m});if(h===void 0)break;if(o*=t,o+=h,o>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let s=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],[s+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[s,!1];e[s]=o>>8,e[s+1]=o&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,s]=t(e);if(n===16)return e;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=t(o.subarray(0,i));return e.set(o.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Hc=45,fd=15,xr=new ds;function Yo(r){if(!(r.length>fd))return xr.new(r).parseWith(()=>xr.readIPv4Addr())}function Jo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Hc))return xr.new(r).parseWith(()=>xr.readIPv6Addr())}function ps(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Hc))return xr.new(r).parseWith(()=>xr.readIPAddr())}var xy=parseInt("0xFFFF",16),vy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Kc(r){return!!Yo(r)}function qc(r){return!!Jo(r)}function vr(r){return!!ps(r)}var zc=Kc,md=qc,Xo=function(r){let t=0;if(r=r.toString().trim(),zc(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(md(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=zc(e[n]),i;o&&(i=Xo(e[n]),e[n]=z(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,z(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);s[t++]=o>>8&255,s[t++]=o&255}return s}throw new Error("invalid ip address")},jc=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let s=[];for(let o=0;o<e;o++)s.push(r[t+o]);return s.join(".")}if(e===16){let s=[];for(let o=0;o<e;o+=2)s.push(n.getUint16(t+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Er={},Qo={},bd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];bd.forEach(r=>{let t=wd(...r);Qo[t.code]=t,Er[t.name]=t});function wd(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function W(r){if(typeof r=="number"){if(Qo[r]!=null)return Qo[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Er[r]!=null)return Er[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var sb=W("ip4"),ob=W("ip6"),ib=W("ipcidr");function ei(r,t){switch(W(r).code){case 4:case 41:return vd(t);case 42:return Zc(t);case 6:case 273:case 33:case 132:return Jc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Zc(t);case 421:return Id(t);case 444:return Yc(t);case 445:return Yc(t);case 466:return Ad(t);default:return z(t,"base16")}}function ri(r,t){switch(W(r).code){case 4:return Gc(t);case 41:return Gc(t);case 42:return Wc(t);case 6:case 273:case 33:case 132:return ni(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Wc(t);case 421:return Ed(t);case 444:return Sd(t);case 445:return kd(t);case 466:return Bd(t);default:return Y(t,"base16")}}var ti=Object.values(be).map(r=>r.decoder),xd=function(){let r=ti[0].or(ti[1]);return ti.slice(2).forEach(t=>r=r.or(t)),r}();function Gc(r){if(!vr(r))throw new Error("invalid ip address");return Xo(r)}function vd(r){let t=jc(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!vr(t))throw new Error("invalid ip address");return t}function ni(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Jc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Wc(r){let t=Y(r),e=Uint8Array.from(Ue(t.length));return Bt([e,t],e.length+t.length)}function Zc(r){let t=pe(r);if(r=r.slice(Rt(t)),r.length!==t)throw new Error("inconsistent lengths");return z(r)}function Ed(r){let t;r[0]==="Q"||r[0]==="1"?t=Oe(ct.decode(`z${r}`)).bytes:t=Ut.parse(r).multihash.bytes;let e=Uint8Array.from(Ue(t.length));return Bt([e,t],e.length+t.length)}function Bd(r){let t=xd.decode(r),e=Uint8Array.from(Ue(t.length));return Bt([e,t],e.length+t.length)}function Ad(r){let t=pe(r),e=r.slice(Rt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+z(e,"base64url")}function Id(r){let t=pe(r),e=r.slice(Rt(t));if(e.length!==t)throw new Error("inconsistent lengths");return z(e,"base58btc")}function Sd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Yt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ni(n);return Bt([e,s],e.length+s.length)}function kd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Yt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ni(n);return Bt([e,s],e.length+s.length)}function Yc(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=z(t,"base32"),s=Jc(e);return`${n}:${s}`}function Xc(r){r=si(r);let t=[],e=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<s.length;o++){let i=s[o],a=W(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(o++,o>=s.length)throw tl("invalid address: "+r);if(a.path===!0){n=si(s.slice(o).join("/")),t.push([a.code,ri(a.code,n)]),e.push([a.code,n]);break}let c=ri(a.code,s[o]);t.push([a.code,c]),e.push([a.code,ei(a.code,c)])}return{string:Qc(e),bytes:ii(t),tuples:t,stringTuples:e,path:n}}function oi(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=pe(r,s),i=Rt(o),a=W(o),c=Rd(a,r.slice(s+i));if(c===0){t.push([o]),e.push([o]),s+=i;continue}let l=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw tl("Invalid address Uint8Array: "+z(r,"base16"));t.push([o,l]);let h=ei(o,l);if(e.push([o,h]),a.path===!0){n=h;break}}return{bytes:Uint8Array.from(r),string:Qc(e),tuples:t,stringTuples:e,path:n}}function Qc(r){let t=[];return r.map(e=>{let n=W(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),si(t.join("/"))}function ii(r){return Bt(r.map(t=>{let e=W(t[0]),n=Uint8Array.from(Ue(e.code));return t.length>1&&t[1]!=null&&(n=Bt([n,t[1]])),n}))}function Rd(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=pe(t instanceof Uint8Array?t:Uint8Array.from(t));return e+Rt(e)}}function si(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function tl(r){return new Error("Error parsing address: "+r)}var Nd=Symbol.for("nodejs.util.inspect.custom"),ai=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Td=[W("dns").code,W("dns4").code,W("dns6").code,W("dnsaddr").code],gs=class r{bytes;#e;#t;#r;#n;[ai]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=oi(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Xc(t)}else if(rl(t))e=oi(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,s,o="",i=W("tcp"),a=W("udp"),c=W("ip4"),l=W("ip6"),h=W("dns6"),u=W("ip6zone");for(let[f,p]of this.stringTuples())f===u.code&&(o=`%${p??""}`),Td.includes(f)&&(e=i.name,s=443,n=`${p??""}${o}`,t=f===h.code?6:4),(f===i.code||f===a.code)&&(e=W(f).name,s=parseInt(p??"")),(f===c.code||f===l.code)&&(e=W(f).name,n=`${p??""}${o}`,t=f===l.code?6:4);if(t==null||e==null||n==null||s==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:s}}protos(){return this.#t.map(([t])=>Object.assign({},W(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>W(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),s=n.lastIndexOf(e);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,s))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(ii(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,s])=>{n===Er.p2p.code&&t.push([n,s]),n===Er["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?z(ct.decode(`z${n}`),"base58btc"):z(Ut.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return bt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=el.get(e.name);if(n==null)throw new C(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(o=>new r(o))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Nd](){return`Multiaddr(${this.#e})`}};var el=new Map;function rl(r){return!!r?.[ai]}function ms(r){return new gs(r)}function Ld(r){return r[Symbol.asyncIterator]!=null}function _d(r){if(Ld(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var ci=_d;var sl=Symbol.for("@achingbrain/uint8arraylist");function nl(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let s=e+n.byteLength;if(t<s)return{buf:n,index:t-e};e=s}throw new RangeError("index is out of bounds")}function ys(r){return!!r?.[sl]}var Br=class r{bufs;length;[sl]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ys(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ys(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=nl(this.bufs,t);return e.buf[e.index]}set(t,e){let n=nl(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ys(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:s}=this._subList(t,e);return Bt(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:Bt(n,s)}sublist(t,e){let{bufs:n,length:s}=this._subList(t,e),o=new r;return o.length=s,o.bufs=[...n],o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let o=0;o<this.bufs.length;o++){let i=this.bufs[o],a=s,c=a+i.byteLength;if(s=c,t>=c)continue;let l=t>=a&&t<c,h=e>a&&e<=c;if(l&&h){if(t===a&&e===c){n.push(i);break}let u=t-a;n.push(i.subarray(u,u+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(h){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ys(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let s=n.byteLength;if(s===0)throw new TypeError("search must be at least 1 byte long");let o=256,i=new Int32Array(o);for(let u=0;u<o;u++)i[u]=-1;for(let u=0;u<s;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,h;for(let u=e;u<=c;u+=h){h=0;for(let m=l;m>=0;m--){let f=this.get(u+m);if(n[m]!==f){h=Math.max(1,m-a[f]);break}}if(h===0)return u}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=wt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let s=Jt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,e,n),this.write(s,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let s=Jt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,e,n),this.write(s,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let s=Jt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,e,n),this.write(s,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=wt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let s=Jt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,e,n),this.write(s,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let s=Jt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,e,n),this.write(s,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let s=Jt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,e,n),this.write(s,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let s=Jt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,e,n),this.write(s,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let s=Jt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,e,n),this.write(s,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!bt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((s,o)=>s+o.byteLength,0)),n.length=e,n}};function bs(r){return r[Symbol.asyncIterator]!=null}var ws=r=>{let t=Rt(r),e=wt(t);return Ue(r,e),ws.bytes=t,e};ws.bytes=0;function Xr(r,t){t=t??{};let e=t.lengthEncoder??ws;function*n(s){let o=e(s.byteLength);o instanceof Uint8Array?yield o:yield*o,s instanceof Uint8Array?yield s:yield*s}return bs(r)?async function*(){for await(let s of r)yield*n(s)}():function*(){for(let s of r)yield*n(s)}()}Xr.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??ws;return new Br(e(r.byteLength),r)};var Ar=rn(al(),1);var Ud=8,Pd=1024*1024*4,We;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(We||(We={}));var li=r=>{let t=pe(r);return li.bytes=Rt(t),t};li.bytes=0;function Ir(r,t){let e=new Br,n=We.LENGTH,s=-1,o=t?.lengthDecoder??li,i=t?.maxLengthLength??Ud,a=t?.maxDataLength??Pd;function*c(){for(;e.byteLength>0;){if(n===We.LENGTH)try{if(s=o(e),s<0)throw(0,Ar.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>a)throw(0,Ar.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let l=o.bytes;e.consume(l),t?.onLength!=null&&t.onLength(s),n=We.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>i)throw(0,Ar.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw l}if(n===We.DATA){if(e.byteLength<s)break;let l=e.sublist(0,s);e.consume(s),t?.onData!=null&&t.onData(l),yield l,n=We.LENGTH}}}return bs(r)?async function*(){for await(let l of r)e.append(l),yield*c();if(e.byteLength>0)throw(0,Ar.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let l of r)e.append(l),yield*c();if(e.byteLength>0)throw(0,Ar.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}Ir.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:o,value:i}=await r.next(e);if(o===!0)return;i!=null&&(yield i)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{e=1}}();return Ir(n,{...t??{},onLength:o=>{e=o}})};function Od(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:s=>{n.push(s)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var cl=Od;function Vd(r){return r[Symbol.asyncIterator]!=null}function Fd(r,t){if(Vd(r))return async function*(){for await(let a of r)yield t(a)}();let e=cl(r),{value:n,done:s}=e.next();if(s===!0)return function*(){}();let o=t(n);if(typeof o.then=="function")return async function*(){yield await o;for await(let a of e)yield t(a)}();let i=t;return function*(){yield o;for(let a of e)yield i(a)}()}var ll=Fd;function ge(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var xs=globalThis.CustomEvent??Event;async function*ui(r,t={}){let e=t.concurrency??1/0;e<1&&(e=1/0);let n=t.ordered==null?!1:t.ordered,s=new EventTarget,o=[],i=ge(),a=ge(),c=!1,l,h=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let p of r){if(o.length===e&&(i=ge(),await i.promise),h)break;let d={done:!1};o.push(d),p().then(g=>{d.done=!0,d.ok=!0,d.value=g,s.dispatchEvent(new xs("task-complete"))},g=>{d.done=!0,d.err=g,s.dispatchEvent(new xs("task-complete"))})}c=!0,s.dispatchEvent(new xs("task-complete"))}catch(p){l=p,s.dispatchEvent(new xs("task-complete"))}});function u(){return n?o[0]?.done:!!o.find(p=>p.done)}function*m(){for(;o.length>0&&o[0].done;){let p=o[0];if(o.shift(),p.ok)yield p.value;else throw h=!0,i.resolve(),p.err;i.resolve()}}function*f(){for(;u();)for(let p=0;p<o.length;p++)if(o[p].done){let d=o[p];if(o.splice(p,1),p--,d.ok)yield d.value;else throw h=!0,i.resolve(),d.err;i.resolve()}}for(;;){if(u()||(a=ge(),await a.promise),l!=null)throw l;if(n?yield*m():yield*f(),c&&o.length===0)break}}var vs=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Sr=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new vs(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new vs(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var fi=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function Es(r={}){return Hd(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Hd(r,t){t=t??{};let e=t.onEnd,n=new Sr,s,o,i,a=ge(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((g,y)=>{o=b=>{o=null,n.push(b);try{g(r(n))}catch(w){y(w)}return s}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=ge()})}},l=g=>o!=null?o(g):(n.push(g),s),h=g=>(n=new Sr,o!=null?o({error:g}):(n.push({error:g}),s)),u=g=>{if(i)return s;if(t?.objectMode!==!0&&g?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:g})},m=g=>i?s:(i=!0,g!=null?h(g):l({done:!0})),f=()=>(n=new Sr,m(),{done:!0}),p=g=>(m(g),{done:!0});if(s={[Symbol.asyncIterator](){return this},next:c,return:f,throw:p,push:u,end:m,get readableLength(){return n.size},onEmpty:async g=>{let y=g?.signal;if(y?.throwIfAborted(),n.isEmpty())return;let b,w;y!=null&&(b=new Promise((k,v)=>{w=()=>{v(new fi)},y.addEventListener("abort",w)}));try{await Promise.race([a.promise,b])}finally{w!=null&&y!=null&&y?.removeEventListener("abort",w)}}},e==null)return s;let d=s;return s={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(g){return d.throw(g),e!=null&&(e(g),e=void 0),{done:!0}},return(){return d.return(),e!=null&&(e(),e=void 0),{done:!0}},push:u,end(g){return d.end(g),e!=null&&(e(g),e=void 0),s},get readableLength(){return d.readableLength},onEmpty:g=>d.onEmpty(g)},s}function Md(r){return r[Symbol.asyncIterator]!=null}function $d(...r){let t=[];for(let e of r)Md(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=Es({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let s of n)e.push(s)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var ul=$d;function di(r,...t){if(r==null)throw new Error("Empty pipeline");if(hi(r)){let n=r;r=()=>n.source}else if(hl(r)||fl(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&hi(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)hi(e[n])&&(e[n]=qd(e[n]));return Kd(...e)}var Kd=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},fl=r=>r?.[Symbol.asyncIterator]!=null,hl=r=>r?.[Symbol.iterator]!=null,hi=r=>r==null?!1:r.sink!=null&&r.source!=null,qd=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=Es({objectMode:!0});e.then(()=>{n.end()},i=>{n.end(i)});let s,o=r.source;if(fl(o))s=async function*(){yield*o,n.end()};else if(hl(o))s=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return ul(n,s())}return r.source};var wl=rn(dl(),1);var pl="[a-fA-F\\d:]",Pe=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${pl})|(?<=${pl})(?=\\s|$))`:"",$t="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",it="[a-fA-F\\d]{1,4}",Bs=`
16
8
  (?:
17
- (?:${St}:){7}(?:${St}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
18
- (?:${St}:){6}(?:${pe}|:${St}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
19
- (?:${St}:){5}(?::${pe}|(?::${St}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
20
- (?:${St}:){4}(?:(?::${St}){0,1}:${pe}|(?::${St}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
21
- (?:${St}:){3}(?:(?::${St}){0,2}:${pe}|(?::${St}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
22
- (?:${St}:){2}(?:(?::${St}){0,3}:${pe}|(?::${St}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
23
- (?:${St}:){1}(?:(?::${St}){0,4}:${pe}|(?::${St}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
24
- (?::(?:(?::${St}){0,5}:${pe}|(?::${St}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
9
+ (?:${it}:){7}(?:${it}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
10
+ (?:${it}:){6}(?:${$t}|:${it}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
11
+ (?:${it}:){5}(?::${$t}|(?::${it}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
12
+ (?:${it}:){4}(?:(?::${it}){0,1}:${$t}|(?::${it}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
13
+ (?:${it}:){3}(?:(?::${it}){0,2}:${$t}|(?::${it}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
14
+ (?:${it}:){2}(?:(?::${it}){0,3}:${$t}|(?::${it}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
15
+ (?:${it}:){1}(?:(?::${it}){0,4}:${$t}|(?::${it}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
16
+ (?::(?:(?::${it}){0,5}:${$t}|(?::${it}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
25
17
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
26
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),cy=new RegExp(`(?:^${pe}$)|(?:^${Bi}$)`),uy=new RegExp(`^${pe}$`),ly=new RegExp(`^${Bi}$`),Ns=t=>t&&t.exact?cy:new RegExp(`(?:${ir(t)}${pe}${ir(t)})|(?:${ir(t)}${Bi}${ir(t)})`,"g");Ns.v4=t=>t&&t.exact?uy:new RegExp(`${ir(t)}${pe}${ir(t)}`,"g");Ns.v6=t=>t&&t.exact?ly:new RegExp(`${ir(t)}${Bi}${ir(t)}`,"g");var Ic=Ns;var Lc=Mt(Cc(),1),{isValid:hy,parse:dy}=Lc.default,py=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],yy=py.map(t=>new Rc.Netmask(t));function gy(t){for(let e of yy)if(e.contains(t))return!0;return!1}function _c(t){return/^::$/.test(t)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}var Dc=t=>{if(hy(t)){let e=dy(t);if(e.kind()==="ipv4")return gy(e.toNormalizedString());if(e.kind()==="ipv6")return _c(t)}else if(Gr(t)&&Ic.v6().test(t))return _c(t)};var Us=Dc;var Pc="libp2p",kc="autonat",Nc="1.0.0";var Y;(function(t){let e;(function(f){f.DIAL="DIAL",f.DIAL_RESPONSE="DIAL_RESPONSE"})(e=t.MessageType||(t.MessageType={}));let r;(function(f){f[f.DIAL=0]="DIAL",f[f.DIAL_RESPONSE=1]="DIAL_RESPONSE"})(r||(r={})),function(f){f.codec=()=>qr(r)}(e=t.MessageType||(t.MessageType={}));let n;(function(f){f.OK="OK",f.E_DIAL_ERROR="E_DIAL_ERROR",f.E_DIAL_REFUSED="E_DIAL_REFUSED",f.E_BAD_REQUEST="E_BAD_REQUEST",f.E_INTERNAL_ERROR="E_INTERNAL_ERROR"})(n=t.ResponseStatus||(t.ResponseStatus={}));let i;(function(f){f[f.OK=0]="OK",f[f.E_DIAL_ERROR=100]="E_DIAL_ERROR",f[f.E_DIAL_REFUSED=101]="E_DIAL_REFUSED",f[f.E_BAD_REQUEST=200]="E_BAD_REQUEST",f[f.E_INTERNAL_ERROR=300]="E_INTERNAL_ERROR"})(i||(i={})),function(f){f.codec=()=>qr(i)}(n=t.ResponseStatus||(t.ResponseStatus={}));let o;(function(f){let u;f.codec=()=>(u==null&&(u=he((l,p,d={})=>{if(d.lengthDelimited!==!1&&p.fork(),l.id!=null&&(p.uint32(10),p.bytes(l.id)),l.addrs!=null)for(let h of l.addrs)p.uint32(18),p.bytes(h);d.lengthDelimited!==!1&&p.ldelim()},(l,p)=>{let d={addrs:[]},h=p==null?l.len:l.pos+p;for(;l.pos<h;){let y=l.uint32();switch(y>>>3){case 1:d.id=l.bytes();break;case 2:d.addrs.push(l.bytes());break;default:l.skipType(y&7);break}}return d})),u),f.encode=l=>le(l,f.codec()),f.decode=l=>ue(l,f.codec())})(o=t.PeerInfo||(t.PeerInfo={}));let s;(function(f){let u;f.codec=()=>(u==null&&(u=he((l,p,d={})=>{d.lengthDelimited!==!1&&p.fork(),l.peer!=null&&(p.uint32(10),t.PeerInfo.codec().encode(l.peer,p)),d.lengthDelimited!==!1&&p.ldelim()},(l,p)=>{let d={},h=p==null?l.len:l.pos+p;for(;l.pos<h;){let y=l.uint32();switch(y>>>3){case 1:d.peer=t.PeerInfo.codec().decode(l,l.uint32());break;default:l.skipType(y&7);break}}return d})),u),f.encode=l=>le(l,f.codec()),f.decode=l=>ue(l,f.codec())})(s=t.Dial||(t.Dial={}));let a;(function(f){let u;f.codec=()=>(u==null&&(u=he((l,p,d={})=>{d.lengthDelimited!==!1&&p.fork(),l.status!=null&&(p.uint32(8),t.ResponseStatus.codec().encode(l.status,p)),l.statusText!=null&&(p.uint32(18),p.string(l.statusText)),l.addr!=null&&(p.uint32(26),p.bytes(l.addr)),d.lengthDelimited!==!1&&p.ldelim()},(l,p)=>{let d={},h=p==null?l.len:l.pos+p;for(;l.pos<h;){let y=l.uint32();switch(y>>>3){case 1:d.status=t.ResponseStatus.codec().decode(l);break;case 2:d.statusText=l.string();break;case 3:d.addr=l.bytes();break;default:l.skipType(y&7);break}}return d})),u),f.encode=l=>le(l,f.codec()),f.decode=l=>ue(l,f.codec())})(a=t.DialResponse||(t.DialResponse={}));let c;t.codec=()=>(c==null&&(c=he((f,u,l={})=>{l.lengthDelimited!==!1&&u.fork(),f.type!=null&&(u.uint32(8),t.MessageType.codec().encode(f.type,u)),f.dial!=null&&(u.uint32(18),t.Dial.codec().encode(f.dial,u)),f.dialResponse!=null&&(u.uint32(26),t.DialResponse.codec().encode(f.dialResponse,u)),l.lengthDelimited!==!1&&u.ldelim()},(f,u)=>{let l={},p=u==null?f.len:f.pos+u;for(;f.pos<p;){let d=f.uint32();switch(d>>>3){case 1:l.type=t.MessageType.codec().decode(f);break;case 2:l.dial=t.Dial.codec().decode(f,f.uint32());break;case 3:l.dialResponse=t.DialResponse.codec().decode(f,f.uint32());break;default:f.skipType(d&7);break}}return l})),c),t.encode=f=>le(f,t.codec()),t.decode=f=>ue(f,t.codec())})(Y||(Y={}));var Os=4,Ii=class{components;startupDelay;refreshInterval;protocol;timeout;maxInboundStreams;maxOutboundStreams;verifyAddressTimeout;started;log;constructor(e,r){this.components=e,this.log=e.logger.forComponent("libp2p:autonat"),this.started=!1,this.protocol=`/${r.protocolPrefix??Pc}/${kc}/${Nc}`,this.timeout=r.timeout??3e4,this.maxInboundStreams=r.maxInboundStreams??1,this.maxOutboundStreams=r.maxOutboundStreams??1,this.startupDelay=r.startupDelay??5e3,this.refreshInterval=r.refreshInterval??6e4,this._verifyExternalAddresses=this._verifyExternalAddresses.bind(this)}isStarted(){return this.started}async start(){this.started||(await this.components.registrar.handle(this.protocol,e=>{this.handleIncomingAutonatStream(e).catch(r=>{this.log.error("error handling incoming autonat stream",r)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams}),this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.startupDelay),this.started=!0)}async stop(){await this.components.registrar.unhandle(this.protocol),clearTimeout(this.verifyAddressTimeout),this.started=!1}async handleIncomingAutonatStream(e){let r=AbortSignal.timeout(this.timeout),n=()=>{e.stream.abort(new $("handleIncomingAutonatStream timeout",Ci))};r.addEventListener("abort",n,{once:!0}),Ri(1/0,r);let i=this.components.addressManager.getAddresses().map(o=>o.toOptions().host);try{let o=this;await ks(e.stream,s=>Qr(s),async function*(s){let a=await _s(s);if(a==null){o.log("no message received"),yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.E_BAD_REQUEST,statusText:"No message was sent"}});return}let c;try{c=Y.decode(a)}catch(y){o.log.error("could not decode message",y),yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.E_BAD_REQUEST,statusText:"Could not decode message"}});return}let f=c.dial;if(f==null){o.log.error("dial was missing from message"),yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.E_BAD_REQUEST,statusText:"No Dial message found in message"}});return}let u,l=f.peer;if(l==null||l.id==null){o.log.error("PeerId missing from message"),yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.E_BAD_REQUEST,statusText:"missing peer info"}});return}try{u=Cn(l.id)}catch(y){o.log.error("invalid PeerId",y),yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.E_BAD_REQUEST,statusText:"bad peer id"}});return}if(o.log("incoming request from %p",u),!e.connection.remotePeer.equals(u)){o.log("target peer %p did not equal sending peer %p",u,e.connection.remotePeer),yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.E_BAD_REQUEST,statusText:"peer id mismatch"}});return}let p=l.addrs.map(y=>xi(y)).filter(y=>{let g=y.toOptions().host===e.connection.remoteAddr.toOptions().host;return o.log.trace("request to dial %a was sent from %a is same host %s",y,e.connection.remoteAddr,g),g}).filter(y=>{let g=y.toOptions().host,x=!(Us(g)??!1);return o.log.trace("host %s was public %s",g,x),x}).filter(y=>{let g=y.toOptions().host,x=!i.includes(g);return o.log.trace("host %s was not our host %s",g,x),x}).filter(y=>{let g=!!o.components.transportManager.transportForMultiaddr(y);return o.log.trace("transport for %a is supported %s",y,g),g}).map(y=>(y.getPeerId()==null&&(y=y.encapsulate(`/p2p/${u.toString()}`)),y));if(p.length===0){o.log("no valid multiaddrs for %p in message",u),yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.E_DIAL_REFUSED,statusText:"no dialable addresses"}});return}o.log("dial multiaddrs %s for peer %p",p.map(y=>y.toString()).join(", "),u);let d="",h=p[0];for await(let y of p){let g;h=y;try{if(g=await o.components.connectionManager.openConnection(y,{signal:r}),!g.remoteAddr.equals(y))throw o.log.error("tried to dial %a but dialed %a",y,g.remoteAddr),new Error("Unexpected remote address");o.log("Success %p",u),yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.OK,addr:g.remoteAddr.decapsulateCode(st("p2p").code).bytes}});return}catch(x){o.log("could not dial %p",u,x),d=x.message}finally{g!=null&&await g.close()}}yield Y.encode({type:Y.MessageType.DIAL_RESPONSE,dialResponse:{status:Y.ResponseStatus.E_DIAL_ERROR,statusText:d,addr:h.bytes}})},s=>Sn(s),e.stream)}catch(o){this.log.error("error handling incoming autonat stream",o)}finally{r.removeEventListener("abort",n)}}_verifyExternalAddresses(){this.verifyExternalAddresses().catch(e=>{this.log.error("error verifying external address",e)})}async verifyExternalAddresses(){if(clearTimeout(this.verifyAddressTimeout),!this.isStarted())return;let e=this.components.addressManager,r=e.getObservedAddrs().filter(o=>{let s=o.toOptions();return!(Us(s.host)??!1)});if(r.length===0){this.log("no public addresses found, not requesting verification"),this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.refreshInterval);return}let n=AbortSignal.timeout(this.timeout);Ri(1/0,n);let i=this;try{this.log("verify multiaddrs %s",r.map(l=>l.toString()).join(", "));let o=Y.encode({type:Y.MessageType.DIAL,dial:{peer:{id:this.components.peerId.toBytes(),addrs:r.map(l=>l.bytes)}}}),a=(await Qf()).toBytes(),c={},f=[],u=async l=>{let p=()=>{};try{this.log("asking %p to verify multiaddr",l.id);let d=await i.components.connectionManager.openConnection(l.id,{signal:n}),h=await d.newStream(this.protocol,{signal:n});p=()=>{h.abort(new $("verifyAddress timeout",Ci))},n.addEventListener("abort",p,{once:!0});let y=await ks([o],x=>Sn(x),h,x=>Qr(x),async x=>_s(x));if(y==null){this.log("no response received from %p",d.remotePeer);return}let g=Y.decode(y);if(g.type!==Y.MessageType.DIAL_RESPONSE||g.dialResponse==null){this.log("invalid autonat response from %p",d.remotePeer);return}if(g.dialResponse.status===Y.ResponseStatus.OK){let x=d.remoteAddr.toOptions(),m;if(x.family===4)m=x.host.split(".")[0];else if(x.family===6)m=x.host.split(":")[0];else{this.log('remote address "%s" was not IP4 or IP6?',x.host);return}if(f.includes(m)){this.log("already have response from network segment %d - %s",m,x.host);return}f.push(m)}return g.dialResponse}catch(d){this.log.error("error asking remote to verify multiaddr",d)}finally{n.removeEventListener("abort",p)}};for await(let l of Ls(bc(this.components.peerRouting.getClosestPeers(a,{signal:n}),p=>async()=>u(p)),{concurrency:Os}))try{if(l==null)continue;let p=l.addr==null?r[0]:xi(l.addr);if(this.log("autonat response for %a is %s",p,l.status),l.status===Y.ResponseStatus.E_BAD_REQUEST||l.status===Y.ResponseStatus.E_DIAL_REFUSED||l.addr==null&&r.length>1)continue;if(!r.some(h=>h.equals(p))){this.log("peer reported %a as %s but it was not in our observed address list",p,l.status);continue}let d=p.toString();if(c[d]==null&&(c[d]={success:0,failure:0}),l.status===Y.ResponseStatus.OK?c[d].success++:l.status===Y.ResponseStatus.E_DIAL_ERROR&&c[d].failure++,c[d].success===Os){this.log("%a is externally dialable",p),e.confirmObservedAddr(p);return}if(c[d].failure===Os){this.log("%a is not externally dialable",p),e.removeObservedAddr(p);return}}catch(p){this.log.error("could not verify external address",p)}}finally{this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.refreshInterval)}}};function Ey(t={}){return e=>new Ii(e,t)}return Zc(Sy);})();
18
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),zd=new RegExp(`(?:^${$t}$)|(?:^${Bs}$)`),jd=new RegExp(`^${$t}$`),Gd=new RegExp(`^${Bs}$`),pi=r=>r&&r.exact?zd:new RegExp(`(?:${Pe(r)}${$t}${Pe(r)})|(?:${Pe(r)}${Bs}${Pe(r)})`,"g");pi.v4=r=>r&&r.exact?jd:new RegExp(`${Pe(r)}${$t}${Pe(r)}`,"g");pi.v6=r=>r&&r.exact?Gd:new RegExp(`${Pe(r)}${Bs}${Pe(r)}`,"g");var gl=pi;var xl=rn(yl(),1),{isValid:Wd,parse:Zd}=xl.default,Yd=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Jd=Yd.map(r=>new wl.Netmask(r));function Xd(r){for(let t of Jd)if(t.contains(r))return!0;return!1}function bl(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}var vl=r=>{if(Wd(r)){let t=Zd(r);if(t.kind()==="ipv4")return Xd(t.toNormalizedString());if(t.kind()==="ipv6")return bl(r)}else if(vr(r)&&gl.v6().test(r))return bl(r)};var gi=vl;var El="libp2p",Bl="autonat",Al="1.0.0";var P;(function(r){let t;(function(l){l.DIAL="DIAL",l.DIAL_RESPONSE="DIAL_RESPONSE"})(t=r.MessageType||(r.MessageType={}));let e;(function(l){l[l.DIAL=0]="DIAL",l[l.DIAL_RESPONSE=1]="DIAL_RESPONSE"})(e||(e={})),function(l){l.codec=()=>dr(e)}(t=r.MessageType||(r.MessageType={}));let n;(function(l){l.OK="OK",l.E_DIAL_ERROR="E_DIAL_ERROR",l.E_DIAL_REFUSED="E_DIAL_REFUSED",l.E_BAD_REQUEST="E_BAD_REQUEST",l.E_INTERNAL_ERROR="E_INTERNAL_ERROR"})(n=r.ResponseStatus||(r.ResponseStatus={}));let s;(function(l){l[l.OK=0]="OK",l[l.E_DIAL_ERROR=100]="E_DIAL_ERROR",l[l.E_DIAL_REFUSED=101]="E_DIAL_REFUSED",l[l.E_BAD_REQUEST=200]="E_BAD_REQUEST",l[l.E_INTERNAL_ERROR=300]="E_INTERNAL_ERROR"})(s||(s={})),function(l){l.codec=()=>dr(s)}(n=r.ResponseStatus||(r.ResponseStatus={}));let o;(function(l){let h;l.codec=()=>(h==null&&(h=ie((u,m,f={})=>{if(f.lengthDelimited!==!1&&m.fork(),u.id!=null&&(m.uint32(10),m.bytes(u.id)),u.addrs!=null)for(let p of u.addrs)m.uint32(18),m.bytes(p);f.lengthDelimited!==!1&&m.ldelim()},(u,m)=>{let f={addrs:[]},p=m==null?u.len:u.pos+m;for(;u.pos<p;){let d=u.uint32();switch(d>>>3){case 1:f.id=u.bytes();break;case 2:f.addrs.push(u.bytes());break;default:u.skipType(d&7);break}}return f})),h),l.encode=u=>oe(u,l.codec()),l.decode=u=>se(u,l.codec())})(o=r.PeerInfo||(r.PeerInfo={}));let i;(function(l){let h;l.codec=()=>(h==null&&(h=ie((u,m,f={})=>{f.lengthDelimited!==!1&&m.fork(),u.peer!=null&&(m.uint32(10),r.PeerInfo.codec().encode(u.peer,m)),f.lengthDelimited!==!1&&m.ldelim()},(u,m)=>{let f={},p=m==null?u.len:u.pos+m;for(;u.pos<p;){let d=u.uint32();switch(d>>>3){case 1:f.peer=r.PeerInfo.codec().decode(u,u.uint32());break;default:u.skipType(d&7);break}}return f})),h),l.encode=u=>oe(u,l.codec()),l.decode=u=>se(u,l.codec())})(i=r.Dial||(r.Dial={}));let a;(function(l){let h;l.codec=()=>(h==null&&(h=ie((u,m,f={})=>{f.lengthDelimited!==!1&&m.fork(),u.status!=null&&(m.uint32(8),r.ResponseStatus.codec().encode(u.status,m)),u.statusText!=null&&(m.uint32(18),m.string(u.statusText)),u.addr!=null&&(m.uint32(26),m.bytes(u.addr)),f.lengthDelimited!==!1&&m.ldelim()},(u,m)=>{let f={},p=m==null?u.len:u.pos+m;for(;u.pos<p;){let d=u.uint32();switch(d>>>3){case 1:f.status=r.ResponseStatus.codec().decode(u);break;case 2:f.statusText=u.string();break;case 3:f.addr=u.bytes();break;default:u.skipType(d&7);break}}return f})),h),l.encode=u=>oe(u,l.codec()),l.decode=u=>se(u,l.codec())})(a=r.DialResponse||(r.DialResponse={}));let c;r.codec=()=>(c==null&&(c=ie((l,h,u={})=>{u.lengthDelimited!==!1&&h.fork(),l.type!=null&&(h.uint32(8),r.MessageType.codec().encode(l.type,h)),l.dial!=null&&(h.uint32(18),r.Dial.codec().encode(l.dial,h)),l.dialResponse!=null&&(h.uint32(26),r.DialResponse.codec().encode(l.dialResponse,h)),u.lengthDelimited!==!1&&h.ldelim()},(l,h)=>{let u={},m=h==null?l.len:l.pos+h;for(;l.pos<m;){let f=l.uint32();switch(f>>>3){case 1:u.type=r.MessageType.codec().decode(l);break;case 2:u.dial=r.Dial.codec().decode(l,l.uint32());break;case 3:u.dialResponse=r.DialResponse.codec().decode(l,l.uint32());break;default:l.skipType(f&7);break}}return u})),c),r.encode=l=>oe(l,r.codec()),r.decode=l=>se(l,r.codec())})(P||(P={}));var mi=4,Is=class{components;startupDelay;refreshInterval;protocol;timeout;maxInboundStreams;maxOutboundStreams;verifyAddressTimeout;started;log;constructor(t,e){this.components=t,this.log=t.logger.forComponent("libp2p:autonat"),this.started=!1,this.protocol=`/${e.protocolPrefix??El}/${Bl}/${Al}`,this.timeout=e.timeout??3e4,this.maxInboundStreams=e.maxInboundStreams??1,this.maxOutboundStreams=e.maxOutboundStreams??1,this.startupDelay=e.startupDelay??5e3,this.refreshInterval=e.refreshInterval??6e4,this._verifyExternalAddresses=this._verifyExternalAddresses.bind(this)}isStarted(){return this.started}async start(){this.started||(await this.components.registrar.handle(this.protocol,t=>{this.handleIncomingAutonatStream(t).catch(e=>{this.log.error("error handling incoming autonat stream",e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams}),this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.startupDelay),this.started=!0)}async stop(){await this.components.registrar.unhandle(this.protocol),clearTimeout(this.verifyAddressTimeout),this.started=!1}async handleIncomingAutonatStream(t){let e=AbortSignal.timeout(this.timeout),n=()=>{t.stream.abort(new C("handleIncomingAutonatStream timeout",ks))};e.addEventListener("abort",n,{once:!0}),Rs(1/0,e);let s=this.components.addressManager.getAddresses().map(o=>o.toOptions().host);try{let o=this;await di(t.stream,i=>Ir(i),async function*(i){let a=await ci(i);if(a==null){o.log("no message received"),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"No message was sent"}});return}let c;try{c=P.decode(a)}catch(d){o.log.error("could not decode message",d),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"Could not decode message"}});return}let l=c.dial;if(l==null){o.log.error("dial was missing from message"),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"No Dial message found in message"}});return}let h,u=l.peer;if(u==null||u.id==null){o.log.error("PeerId missing from message"),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"missing peer info"}});return}try{h=sn(u.id)}catch(d){o.log.error("invalid PeerId",d),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"bad peer id"}});return}if(o.log("incoming request from %p",h),!t.connection.remotePeer.equals(h)){o.log("target peer %p did not equal sending peer %p",h,t.connection.remotePeer),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"peer id mismatch"}});return}let m=u.addrs.map(d=>ms(d)).filter(d=>{let g=d.toOptions().host===t.connection.remoteAddr.toOptions().host;return o.log.trace("request to dial %a was sent from %a is same host %s",d,t.connection.remoteAddr,g),g}).filter(d=>{let g=d.toOptions().host,y=!(gi(g)??!1);return o.log.trace("host %s was public %s",g,y),y}).filter(d=>{let g=d.toOptions().host,y=!s.includes(g);return o.log.trace("host %s was not our host %s",g,y),y}).filter(d=>{let g=!!o.components.transportManager.transportForMultiaddr(d);return o.log.trace("transport for %a is supported %s",d,g),g}).map(d=>(d.getPeerId()==null&&(d=d.encapsulate(`/p2p/${h.toString()}`)),d));if(m.length===0){o.log("no valid multiaddrs for %p in message",h),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_DIAL_REFUSED,statusText:"no dialable addresses"}});return}o.log("dial multiaddrs %s for peer %p",m.map(d=>d.toString()).join(", "),h);let f="",p=m[0];for await(let d of m){let g;p=d;try{if(g=await o.components.connectionManager.openConnection(d,{signal:e}),!g.remoteAddr.equals(d))throw o.log.error("tried to dial %a but dialed %a",d,g.remoteAddr),new Error("Unexpected remote address");o.log("Success %p",h),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.OK,addr:g.remoteAddr.decapsulateCode(W("p2p").code).bytes}});return}catch(y){o.log("could not dial %p",h,y),f=y.message}finally{g!=null&&await g.close()}}yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_DIAL_ERROR,statusText:f,addr:p.bytes}})},i=>Xr(i),t.stream)}catch(o){this.log.error("error handling incoming autonat stream",o)}finally{e.removeEventListener("abort",n)}}_verifyExternalAddresses(){this.verifyExternalAddresses().catch(t=>{this.log.error("error verifying external address",t)})}async verifyExternalAddresses(){if(clearTimeout(this.verifyAddressTimeout),!this.isStarted())return;let t=this.components.addressManager,e=t.getObservedAddrs().filter(o=>{let i=o.toOptions();return!(gi(i.host)??!1)});if(e.length===0){this.log("no public addresses found, not requesting verification"),this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.refreshInterval);return}let n=AbortSignal.timeout(this.timeout);Rs(1/0,n);let s=this;try{this.log("verify multiaddrs %s",e.map(u=>u.toString()).join(", "));let o=P.encode({type:P.MessageType.DIAL,dial:{peer:{id:this.components.peerId.toBytes(),addrs:e.map(u=>u.bytes)}}}),a=(await Fc()).toBytes(),c={},l=[],h=async u=>{let m=()=>{};try{this.log("asking %p to verify multiaddr",u.id);let f=await s.components.connectionManager.openConnection(u.id,{signal:n}),p=await f.newStream(this.protocol,{signal:n});m=()=>{p.abort(new C("verifyAddress timeout",ks))},n.addEventListener("abort",m,{once:!0});let d=await di([o],y=>Xr(y),p,y=>Ir(y),async y=>ci(y));if(d==null){this.log("no response received from %p",f.remotePeer);return}let g=P.decode(d);if(g.type!==P.MessageType.DIAL_RESPONSE||g.dialResponse==null){this.log("invalid autonat response from %p",f.remotePeer);return}if(g.dialResponse.status===P.ResponseStatus.OK){let y=f.remoteAddr.toOptions(),b;if(y.family===4)b=y.host.split(".")[0];else if(y.family===6)b=y.host.split(":")[0];else{this.log('remote address "%s" was not IP4 or IP6?',y.host);return}if(l.includes(b)){this.log("already have response from network segment %d - %s",b,y.host);return}l.push(b)}return g.dialResponse}catch(f){this.log.error("error asking remote to verify multiaddr",f)}finally{n.removeEventListener("abort",m)}};for await(let u of ui(ll(this.components.peerRouting.getClosestPeers(a,{signal:n}),m=>async()=>h(m)),{concurrency:mi}))try{if(u==null)continue;let m=u.addr==null?e[0]:ms(u.addr);if(this.log("autonat response for %a is %s",m,u.status),u.status===P.ResponseStatus.E_BAD_REQUEST||u.status===P.ResponseStatus.E_DIAL_REFUSED||u.addr==null&&e.length>1)continue;if(!e.some(p=>p.equals(m))){this.log("peer reported %a as %s but it was not in our observed address list",m,u.status);continue}let f=m.toString();if(c[f]==null&&(c[f]={success:0,failure:0}),u.status===P.ResponseStatus.OK?c[f].success++:u.status===P.ResponseStatus.E_DIAL_ERROR&&c[f].failure++,c[f].success===mi){this.log("%a is externally dialable",m),t.confirmObservedAddr(m);return}if(c[f].failure===mi){this.log("%a is not externally dialable",m),t.removeObservedAddr(m);return}}catch(m){this.log.error("could not verify external address",m)}}finally{this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.refreshInterval)}}};function s0(r={}){return t=>new Is(t,r)}return Vl(o0);})();
27
19
  /*! Bundled license information:
28
20
 
21
+ pvtsutils/build/index.js:
22
+ (*!
23
+ * MIT License
24
+ *
25
+ * Copyright (c) 2017-2022 Peculiar Ventures, LLC
26
+ *
27
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ * of this software and associated documentation files (the "Software"), to deal
29
+ * in the Software without restriction, including without limitation the rights
30
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ * copies of the Software, and to permit persons to whom the Software is
32
+ * furnished to do so, subject to the following conditions:
33
+ *
34
+ * The above copyright notice and this permission notice shall be included in all
35
+ * copies or substantial portions of the Software.
36
+ *
37
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
+ * SOFTWARE.
44
+ *
45
+ *)
46
+
29
47
  @noble/hashes/esm/utils.js:
30
48
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
31
49
 
@@ -44,6 +62,46 @@
44
62
  @noble/curves/esm/ed25519.js:
45
63
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
46
64
 
65
+ pvutils/build/utils.es.js:
66
+ (*!
67
+ Copyright (c) Peculiar Ventures, LLC
68
+ *)
69
+
70
+ asn1js/build/index.es.js:
71
+ (*!
72
+ * Copyright (c) 2014, GMO GlobalSign
73
+ * Copyright (c) 2015-2022, Peculiar Ventures
74
+ * All rights reserved.
75
+ *
76
+ * Author 2014-2019, Yury Strozhevsky
77
+ *
78
+ * Redistribution and use in source and binary forms, with or without modification,
79
+ * are permitted provided that the following conditions are met:
80
+ *
81
+ * * Redistributions of source code must retain the above copyright notice, this
82
+ * list of conditions and the following disclaimer.
83
+ *
84
+ * * Redistributions in binary form must reproduce the above copyright notice, this
85
+ * list of conditions and the following disclaimer in the documentation and/or
86
+ * other materials provided with the distribution.
87
+ *
88
+ * * Neither the name of the copyright holder nor the names of its
89
+ * contributors may be used to endorse or promote products derived from
90
+ * this software without specific prior written permission.
91
+ *
92
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
93
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
94
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
95
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
96
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
97
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
98
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
99
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
100
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
101
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102
+ *
103
+ *)
104
+
47
105
  @noble/curves/esm/abstract/weierstrass.js:
48
106
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
49
107