@metamask/sdk-react
Version:
A react component and react hooks to connect and use MetaMask
1 lines • 501 kB
JavaScript
import e,{Buffer as t}from"buffer";import n from"node:crypto";import r,{EventEmitter as i}from"events";import o from"@react-native-async-storage/async-storage";import s,{useCallback as a,createContext as c,useState as l,useEffect as u,useRef as d,useMemo as h,useContext as f}from"react";var p="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},g=[],m=[],y="undefined"!=typeof Uint8Array?Uint8Array:Array,v=!1;function b(){v=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)g[t]=e[t],m[e.charCodeAt(t)]=t;m["-".charCodeAt(0)]=62,m["_".charCodeAt(0)]=63}function w(e,t,n){for(var r,i,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(g[(i=r)>>18&63]+g[i>>12&63]+g[i>>6&63]+g[63&i]);return o.join("")}function E(e){var t;v||b();for(var n=e.length,r=n%3,i="",o=[],s=16383,a=0,c=n-r;a<c;a+=s)o.push(w(e,a,a+s>c?c:a+s));return 1===r?(t=e[n-1],i+=g[t>>2],i+=g[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=g[t>>10],i+=g[t>>4&63],i+=g[t<<2&63],i+="="),o.push(i),o.join("")}function S(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,l=c>>1,u=-7,d=n?i-1:0,h=n?-1:1,f=e[t+d];for(d+=h,o=f&(1<<-u)-1,f>>=-u,u+=a;u>0;o=256*o+e[t+d],d+=h,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=r;u>0;s=256*s+e[t+d],d+=h,u-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=l}return(f?-1:1)*s*Math.pow(2,o-r)}function _(e,t,n,r,i,o){var s,a,c,l=8*o-i-1,u=(1<<l)-1,d=u>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=u?(a=0,s=u):s+d>=1?(a=(t*c-1)*Math.pow(2,i),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[n+f]=255&s,f+=p,s/=256,l-=8);e[n+f-p]|=128*g}var C={}.toString,A=Array.isArray||function(e){return"[object Array]"==C.call(e)};function k(){return R.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function M(e,t){if(k()<t)throw new RangeError("Invalid typed array length");return R.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=R.prototype:(null===e&&(e=new R(t)),e.length=t),e}function R(e,t,n){if(!(R.TYPED_ARRAY_SUPPORT||this instanceof R))return new R(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return T(this,e)}return x(this,e,t,n)}function x(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);R.TYPED_ARRAY_SUPPORT?(e=t).__proto__=R.prototype:e=I(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!R.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|L(t,n);e=M(e,r);var i=e.write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(N(t)){var n=0|O(t.length);return 0===(e=M(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?M(e,0):I(e,t);if("Buffer"===t.type&&A(t.data))return I(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function P(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function T(e,t){if(P(t),e=M(e,t<0?0:0|O(t)),!R.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function I(e,t){var n=t.length<0?0:0|O(t.length);e=M(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function O(e){if(e>=k())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+k().toString(16)+" bytes");return 0|e}function N(e){return!(null==e||!e._isBuffer)}function L(e,t){if(N(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return ce(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return le(e).length;default:if(r)return ce(e).length;t=(""+t).toLowerCase(),r=!0}}function B(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Z(this,t,n);case"utf8":case"utf-8":return V(this,t,n);case"ascii":return Y(this,t,n);case"latin1":case"binary":return J(this,t,n);case"base64":return W(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function D(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function K(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=R.from(t,r)),N(t))return 0===t.length?-1:j(e,t,n,r,i);if("number"==typeof t)return t&=255,R.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):j(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function j(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var u=-1;for(o=n;o<a;o++)if(l(e,o)===l(t,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===c)return u*s}else-1!==u&&(o-=o-u),u=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var d=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){d=!1;break}if(d)return o}return-1}function U(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function $(e,t,n,r){return ue(ce(t,e.length-n),e,n,r)}function F(e,t,n,r){return ue(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function H(e,t,n,r){return F(e,t,n,r)}function q(e,t,n,r){return ue(le(t),e,n,r)}function z(e,t,n,r){return ue(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function W(e,t,n){return 0===t&&n===e.length?E(e):E(e.slice(t,n))}function V(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,l=e[i],u=null,d=l>239?4:l>223?3:l>191?2:1;if(i+d<=n)switch(d){case 1:l<128&&(u=l);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&l)<<6|63&o)>127&&(u=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,d=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),i+=d}return function(e){var t=e.length;if(t<=G)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=G));return n}(r)}R.TYPED_ARRAY_SUPPORT=void 0===p.TYPED_ARRAY_SUPPORT||p.TYPED_ARRAY_SUPPORT,k(),R.poolSize=8192,R._augment=function(e){return e.__proto__=R.prototype,e},R.from=function(e,t,n){return x(null,e,t,n)},R.TYPED_ARRAY_SUPPORT&&(R.prototype.__proto__=Uint8Array.prototype,R.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&R[Symbol.species]),R.alloc=function(e,t,n){return function(e,t,n,r){return P(t),t<=0?M(e,t):void 0!==n?"string"==typeof r?M(e,t).fill(n,r):M(e,t).fill(n):M(e,t)}(null,e,t,n)},R.allocUnsafe=function(e){return T(null,e)},R.allocUnsafeSlow=function(e){return T(null,e)},R.isBuffer=function(e){return null!=e&&(!!e._isBuffer||de(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&de(e.slice(0,0))}(e))},R.compare=function(e,t){if(!N(e)||!N(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},R.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},R.concat=function(e,t){if(!A(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return R.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=R.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!N(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},R.byteLength=L,R.prototype._isBuffer=!0,R.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)D(this,t,t+1);return this},R.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)D(this,t,t+3),D(this,t+1,t+2);return this},R.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)D(this,t,t+7),D(this,t+1,t+6),D(this,t+2,t+5),D(this,t+3,t+4);return this},R.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?V(this,0,e):B.apply(this,arguments)},R.prototype.equals=function(e){if(!N(e))throw new TypeError("Argument must be a Buffer");return this===e||0===R.compare(this,e)},R.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},R.prototype.compare=function(e,t,n,r,i){if(!N(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(r,i),l=e.slice(t,n),u=0;u<a;++u)if(c[u]!==l[u]){o=c[u],s=l[u];break}return o<s?-1:s<o?1:0},R.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},R.prototype.indexOf=function(e,t,n){return K(this,e,t,n,!0)},R.prototype.lastIndexOf=function(e,t,n){return K(this,e,t,n,!1)},R.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return U(this,e,t,n);case"utf8":case"utf-8":return $(this,e,t,n);case"ascii":return F(this,e,t,n);case"latin1":case"binary":return H(this,e,t,n);case"base64":return q(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},R.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var G=4096;function Y(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function J(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function Z(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=ae(e[o]);return i}function Q(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function X(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function ee(e,t,n,r,i,o){if(!N(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function te(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function ne(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function re(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ie(e,t,n,r,i){return i||re(e,0,n,4),_(e,t,n,r,23,4),n+4}function oe(e,t,n,r,i){return i||re(e,0,n,8),_(e,t,n,r,52,8),n+8}R.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),R.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=R.prototype;else{var i=t-e;n=new R(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},R.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||X(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},R.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||X(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},R.prototype.readUInt8=function(e,t){return t||X(e,1,this.length),this[e]},R.prototype.readUInt16LE=function(e,t){return t||X(e,2,this.length),this[e]|this[e+1]<<8},R.prototype.readUInt16BE=function(e,t){return t||X(e,2,this.length),this[e]<<8|this[e+1]},R.prototype.readUInt32LE=function(e,t){return t||X(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},R.prototype.readUInt32BE=function(e,t){return t||X(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},R.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||X(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},R.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||X(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},R.prototype.readInt8=function(e,t){return t||X(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},R.prototype.readInt16LE=function(e,t){t||X(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},R.prototype.readInt16BE=function(e,t){t||X(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},R.prototype.readInt32LE=function(e,t){return t||X(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},R.prototype.readInt32BE=function(e,t){return t||X(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},R.prototype.readFloatLE=function(e,t){return t||X(e,4,this.length),S(this,e,!0,23,4)},R.prototype.readFloatBE=function(e,t){return t||X(e,4,this.length),S(this,e,!1,23,4)},R.prototype.readDoubleLE=function(e,t){return t||X(e,8,this.length),S(this,e,!0,52,8)},R.prototype.readDoubleBE=function(e,t){return t||X(e,8,this.length),S(this,e,!1,52,8)},R.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||ee(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},R.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||ee(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},R.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,1,255,0),R.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},R.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,65535,0),R.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):te(this,e,t,!0),t+2},R.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,65535,0),R.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):te(this,e,t,!1),t+2},R.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,4294967295,0),R.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ne(this,e,t,!0),t+4},R.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,4294967295,0),R.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},R.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);ee(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},R.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);ee(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},R.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,1,127,-128),R.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},R.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,32767,-32768),R.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):te(this,e,t,!0),t+2},R.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,2,32767,-32768),R.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):te(this,e,t,!1),t+2},R.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,2147483647,-2147483648),R.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ne(this,e,t,!0),t+4},R.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||ee(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),R.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ne(this,e,t,!1),t+4},R.prototype.writeFloatLE=function(e,t,n){return ie(this,e,t,!0,n)},R.prototype.writeFloatBE=function(e,t,n){return ie(this,e,t,!1,n)},R.prototype.writeDoubleLE=function(e,t,n){return oe(this,e,t,!0,n)},R.prototype.writeDoubleBE=function(e,t,n){return oe(this,e,t,!1,n)},R.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!R.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},R.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!R.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=N(e)?e:ce(new R(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var se=/[^+\/0-9A-Za-z-_]/g;function ae(e){return e<16?"0"+e.toString(16):e.toString(16)}function ce(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function le(e){return function(e){var t,n,r,i,o,s;v||b();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new y(3*a/4-o),r=o>0?a-4:a;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)i=m[e.charCodeAt(t)]<<18|m[e.charCodeAt(t+1)]<<12|m[e.charCodeAt(t+2)]<<6|m[e.charCodeAt(t+3)],s[c++]=i>>16&255,s[c++]=i>>8&255,s[c++]=255&i;return 2===o?(i=m[e.charCodeAt(t)]<<2|m[e.charCodeAt(t+1)]>>4,s[c++]=255&i):1===o&&(i=m[e.charCodeAt(t)]<<10|m[e.charCodeAt(t+1)]<<4|m[e.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(se,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function ue(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function de(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function he(){throw new Error("setTimeout has not been defined")}function fe(){throw new Error("clearTimeout has not been defined")}var pe=he,ge=fe;function me(e){if(pe===setTimeout)return setTimeout(e,0);if((pe===he||!pe)&&setTimeout)return pe=setTimeout,setTimeout(e,0);try{return pe(e,0)}catch(t){try{return pe.call(null,e,0)}catch(t){return pe.call(this,e,0)}}}"function"==typeof p.setTimeout&&(pe=setTimeout),"function"==typeof p.clearTimeout&&(ge=clearTimeout);var ye,ve=[],be=!1,we=-1;function Ee(){be&&ye&&(be=!1,ye.length?ve=ye.concat(ve):we=-1,ve.length&&Se())}function Se(){if(!be){var e=me(Ee);be=!0;for(var t=ve.length;t;){for(ye=ve,ve=[];++we<t;)ye&&ye[we].run();we=-1,t=ve.length}ye=null,be=!1,function(e){if(ge===clearTimeout)return clearTimeout(e);if((ge===fe||!ge)&&clearTimeout)return ge=clearTimeout,clearTimeout(e);try{return ge(e)}catch(t){try{return ge.call(null,e)}catch(t){return ge.call(this,e)}}}(e)}}function _e(e,t){this.fun=e,this.array=t}_e.prototype.run=function(){this.fun.apply(null,this.array)};function Ce(){}var Ae=Ce,ke=Ce,Me=Ce,Re=Ce,xe=Ce,Pe=Ce,Te=Ce;var Ie=p.performance||{},Oe=Ie.now||Ie.mozNow||Ie.msNow||Ie.oNow||Ie.webkitNow||function(){return(new Date).getTime()};var Ne=new Date;var Le={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];ve.push(new _e(e,t)),1!==ve.length||be||me(Se)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Ae,addListener:ke,once:Me,off:Re,removeListener:xe,removeAllListeners:Pe,emit:Te,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Oe.call(Ie),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Ne)/1e3}},Be="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},De={exports:{}};De.exports=Be.fetch,De.exports.default=Be.fetch,De.exports.fetch=Be.fetch,De.exports.Headers=Be.Headers,De.exports.Request=Be.Request,De.exports.Response=Be.Response;var Ke,je,Ue={exports:{}};function $e(){if(je)return Ke;je=1;var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,o=365.25*r;function s(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}return Ke=function(a,c){c=c||{};var l=typeof a;if("string"===l&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===l&&isFinite(a))return c.long?function(i){var o=Math.abs(i);if(o>=r)return s(i,o,r,"day");if(o>=n)return s(i,o,n,"hour");if(o>=t)return s(i,o,t,"minute");if(o>=e)return s(i,o,e,"second");return i+" ms"}(a):function(i){var o=Math.abs(i);if(o>=r)return Math.round(i/r)+"d";if(o>=n)return Math.round(i/n)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))},Ke}var Fe=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=$e(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==Le&&"env"in Le&&(e=Le.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Fe(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ue,Ue.exports);var He=Ue.exports,qe=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,We=Object.getOwnPropertyNames,Ve=Object.prototype.hasOwnProperty,Ge={};((e,t)=>{for(var n in t)qe(e,n,{get:t[n],enumerable:!0})})(Ge,{createFinalURL:()=>ut,createPathBasedClient:()=>rt,createQuerySerializer:()=>at,default:()=>et,defaultBodySerializer:()=>lt,defaultPathSerializer:()=>ct,mergeHeaders:()=>dt,randomID:()=>Xe,removeTrailingSlash:()=>ht,serializeArrayParam:()=>st,serializeObjectParam:()=>ot,serializePrimitiveParam:()=>it,wrapAsPathBasedClient:()=>nt});var Ye,Je=(Ye=Ge,((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of We(t))Ve.call(e,i)||i===n||qe(e,i,{get:()=>t[i],enumerable:!(r=ze(t,i))||r.enumerable});return e})(qe({},"__esModule",{value:!0}),Ye)),Ze=/\{[^{}]+\}/g,Qe=()=>"object"==typeof Le&&Number.parseInt(Le?.versions?.node?.substring(0,2))>=18&&Le.versions.undici;function Xe(){return Math.random().toString(36).slice(2,11)}function et(e){let{baseUrl:t="",Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:o,headers:s,requestInitExt:a,...c}={...e};a=Qe()?a:void 0,t=ht(t);const l=[];async function u(e,u){const{baseUrl:d,fetch:h=r,Request:f=n,headers:p,params:g={},parseAs:m="json",querySerializer:y,bodySerializer:v=o??lt,body:b,...w}=u||{};d&&(t=ht(d));let E="function"==typeof i?i:at(i);y&&(E="function"==typeof y?y:at({..."object"==typeof i?i:{},...y}));const S=void 0===b?void 0:v(b),_=void 0===S||S instanceof FormData?{}:{"Content-Type":"application/json"},C={redirect:"follow",...c,...w,body:S,headers:dt(_,s,p,g.header)};let A,k,M,R=new n(ut(e,{baseUrl:t,params:g,querySerializer:E}),C);for(const e in w)e in R||(R[e]=w[e]);if(l.length){A=Xe(),k=Object.freeze({baseUrl:t,fetch:h,parseAs:m,querySerializer:E,bodySerializer:v});for(const t of l)if(t&&"object"==typeof t&&"function"==typeof t.onRequest){const r=await t.onRequest({request:R,schemaPath:e,params:g,options:k,id:A});if(r){if(!(r instanceof n)){if(r instanceof Response){M=r;break}throw new Error("onRequest: must return new Request() or Response() when modifying the request")}R=r}}}if(!M){try{M=await h(R,a)}catch(t){let n=t;if(l.length)for(let t=l.length-1;t>=0;t--){const r=l[t];if(r&&"object"==typeof r&&"function"==typeof r.onError){const t=await r.onError({request:R,error:n,schemaPath:e,params:g,options:k,id:A});if(t){if(t instanceof Response){n=void 0,M=t;break}if(t instanceof Error){n=t;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(n)throw n}if(l.length)for(let t=l.length-1;t>=0;t--){const n=l[t];if(n&&"object"==typeof n&&"function"==typeof n.onResponse){const t=await n.onResponse({request:R,response:M,schemaPath:e,params:g,options:k,id:A});if(t){if(!(t instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");M=t}}}}if(204===M.status||"0"===M.headers.get("Content-Length"))return M.ok?{data:void 0,response:M}:{error:void 0,response:M};if(M.ok)return"stream"===m?{data:M.body,response:M}:{data:await M[m](),response:M};let x=await M.text();try{x=JSON.parse(x)}catch{}return{error:x,response:M}}return{request:(e,t,n)=>u(t,{...n,method:e.toUpperCase()}),GET:(e,t)=>u(e,{...t,method:"GET"}),PUT:(e,t)=>u(e,{...t,method:"PUT"}),POST:(e,t)=>u(e,{...t,method:"POST"}),DELETE:(e,t)=>u(e,{...t,method:"DELETE"}),OPTIONS:(e,t)=>u(e,{...t,method:"OPTIONS"}),HEAD:(e,t)=>u(e,{...t,method:"HEAD"}),PATCH:(e,t)=>u(e,{...t,method:"PATCH"}),TRACE:(e,t)=>u(e,{...t,method:"TRACE"}),use(...e){for(const t of e)if(t){if("object"!=typeof t||!("onRequest"in t||"onResponse"in t||"onError"in t))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");l.push(t)}},eject(...e){for(const t of e){const e=l.indexOf(t);-1!==e&&l.splice(e,1)}}}}var tt=class{constructor(){this.client=null}get(e,t){const n=new class{constructor(e,t){this.client=e,this.url=t}GET(e){return this.client.GET(this.url,e)}PUT(e){return this.client.PUT(this.url,e)}POST(e){return this.client.POST(this.url,e)}DELETE(e){return this.client.DELETE(this.url,e)}OPTIONS(e){return this.client.OPTIONS(this.url,e)}HEAD(e){return this.client.HEAD(this.url,e)}PATCH(e){return this.client.PATCH(this.url,e)}TRACE(e){return this.client.TRACE(this.url,e)}}(e,t);return this.client[t]=n,n}};function nt(e){const t=new tt,n=new Proxy(e,t);function r(){}r.prototype=n;const i=new r;return t.client=i,i}function rt(e){return nt(et(e))}function it(e,t,n){if(null==t)return"";if("object"==typeof t)throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${!0===n?.allowReserved?t:encodeURIComponent(t)}`}function ot(e,t,n){if(!t||"object"!=typeof t)return"";const r=[],i={simple:",",label:".",matrix:";"}[n.style]||"&";if("deepObject"!==n.style&&!1===n.explode){for(const e in t)r.push(e,!0===n.allowReserved?t[e]:encodeURIComponent(t[e]));const i=r.join(",");switch(n.style){case"form":return`${e}=${i}`;case"label":return`.${i}`;case"matrix":return`;${e}=${i}`;default:return i}}for(const i in t){const o="deepObject"===n.style?`${e}[${i}]`:i;r.push(it(o,t[i],n))}const o=r.join(i);return"label"===n.style||"matrix"===n.style?`${i}${o}`:o}function st(e,t,n){if(!Array.isArray(t))return"";if(!1===n.explode){const r={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",i=(!0===n.allowReserved?t:t.map((e=>encodeURIComponent(e)))).join(r);switch(n.style){case"simple":return i;case"label":return`.${i}`;case"matrix":return`;${e}=${i}`;default:return`${e}=${i}`}}const r={simple:",",label:".",matrix:";"}[n.style]||"&",i=[];for(const r of t)"simple"===n.style||"label"===n.style?i.push(!0===n.allowReserved?r:encodeURIComponent(r)):i.push(it(e,r,n));return"label"===n.style||"matrix"===n.style?`${r}${i.join(r)}`:i.join(r)}function at(e){return function(t){const n=[];if(t&&"object"==typeof t)for(const r in t){const i=t[r];if(null!=i)if(Array.isArray(i)){if(0===i.length)continue;n.push(st(r,i,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}))}else"object"!=typeof i?n.push(it(r,i,e)):n.push(ot(r,i,{style:"deepObject",explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}))}return n.join("&")}}function ct(e,t){let n=e;for(const r of e.match(Ze)??[]){let e=r.substring(1,r.length-1),i=!1,o="simple";if(e.endsWith("*")&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(".")?(o="label",e=e.substring(1)):e.startsWith(";")&&(o="matrix",e=e.substring(1)),!t||void 0===t[e]||null===t[e])continue;const s=t[e];Array.isArray(s)?n=n.replace(r,st(e,s,{style:o,explode:i})):n="object"!=typeof s?"matrix"!==o?n.replace(r,"label"===o?`.${encodeURIComponent(s)}`:encodeURIComponent(s)):n.replace(r,`;${it(e,s)}`):n.replace(r,ot(e,s,{style:o,explode:i}))}return n}function lt(e){return e instanceof FormData?e:JSON.stringify(e)}function ut(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=ct(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith("?")&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function dt(...e){const t=new Headers;for(const n of e){if(!n||"object"!=typeof n)continue;const e=n instanceof Headers?n.entries():Object.entries(n);for(const[n,r]of e)if(null===r)t.delete(n);else if(Array.isArray(r))for(const e of r)t.append(n,e);else void 0!==r&&t.set(n,r)}return t}function ht(e){return e.endsWith("/")?e.substring(0,e.length-1):e}var ft=Object.create,pt=Object.defineProperty,gt=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyNames,yt=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty,bt=(e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of mt(t))vt.call(e,i)||i===n||pt(e,i,{get:()=>t[i],enumerable:!(r=gt(t,i))||r.enumerable});return e},wt={};((e,t)=>{for(var n in t)pt(e,n,{get:t[n],enumerable:!0})})(wt,{analytics:()=>Rt});var Et,St,_t=(e=>bt(pt({},"__esModule",{value:!0}),e))(wt),Ct=((e,t,n)=>(n=null!=e?ft(yt(e)):{},bt(!t&&e&&e.__esModule?n:pt(n,"default",{value:e,enumerable:!0}),e)))(Je),At=class{constructor(e){this.batch=[],this.maxTimeoutMs=3e4,this.timeoutId=null,this.isSending=!1,this.batchSize=e.batchSize,this.baseTimeoutMs=e.baseTimeoutMs,this.currentTimeoutMs=e.baseTimeoutMs,this.sendFn=e.sendFn}enqueue(e){this.batch.push(e),this.schedule()}schedule(){this.batch.length>0&&!this.timeoutId&&(this.timeoutId=setTimeout((()=>{this.timeoutId=null,this.flush()}),this.currentTimeoutMs))}async flush(){if(this.isSending||0===this.batch.length)return;this.isSending=!0;const e=[...this.batch.slice(0,this.batchSize)];this.batch=this.batch.slice(this.batchSize);try{await this.sendFn(e),this.currentTimeoutMs=this.baseTimeoutMs}catch(t){console.error("Sender: Failed to send batch",t),this.batch=[...e,...this.batch],this.currentTimeoutMs=Math.min(2*this.currentTimeoutMs,this.maxTimeoutMs)}finally{this.isSending=!1,this.schedule()}}},kt=class{constructor(e){this.enabled=!1,this.properties={};const t=(0,Ct.default)({baseUrl:e});this.sender=new At({batchSize:100,baseTimeoutMs:200,sendFn:async e=>{const n=await t.POST("/v1/events",{body:e});if(200!==n.response.status)throw new Error(n.error)}})}enable(){this.enabled=!0}setGlobalProperty(e,t){this.properties[e]=t}track(e,t){if(!this.enabled)return;const n={name:e,...this.properties,...t};this.sender.enqueue(n)}};void 0!==Le&&Le.env&&(Et=null!=(St=Le.env.METAMASK_ANALYTICS_ENDPOINT)?St:Le.env.NEXT_PUBLIC_METAMASK_ANALYTICS_ENDPOINT);var Mt,Rt=new kt(null!=Et?Et:"https://mm-sdk-analytics.api.cx.metamask.io/"),xt={exports:{}};Mt=xt,function(e){var t=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r="object"==typeof Le&&"function"==typeof Le.nextTick,i="function"==typeof Symbol,o="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,a=i?o&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&l.call(this,this._conf)}function l(t){t&&(this._conf=t,t.delimiter&&(this.delimiter=t.delimiter),t.maxListeners!==e&&(this._maxListeners=t.maxListeners),t.wildcard&&(this.wildcard=t.wildcard),t.newListener&&(this._newListener=t.newListener),t.removeListener&&(this._removeListener=t.removeListener),t.verboseMemoryLeak&&(this.verboseMemoryLeak=t.verboseMemoryLeak),t.ignoreErrors&&(this.ignoreErrors=t.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function u(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),void 0!==Le&&Le.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,Le.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var d=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}};function h(t,n){for(var r={},i=t.length,o=n?n.length:0,s=0;s<i;s++)r[t[s]]=s<o?n[s]:e;return r}function f(e,t,n){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function p(n,r,i,o){var s=Object.assign({},r);if(!n)return s;if("object"!=typeof n)throw TypeError("options must be an object");var a,c,l,u=Object.keys(n),d=u.length;function h(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<d;f++){if(a=u[f],!o&&!t.call(r,a))throw Error('Unknown "'+a+'" option');(c=n[a])!==e&&(l=i[a],s[a]=l?l(c,h):c)}return s}function g(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function m(e){var t="value must be type of "+e.join("|"),n=e.length,r=e[0],i=e[1];return 1===n?function(e,n){if(typeof e===r)return e;n(t)}:2===n?function(e,n){var o=typeof e;if(o===r||o===i)return e;n(t)}:function(r,i){for(var o=typeof r,s=n;s-- >0;)if(o===e[s])return r;i(t)}}Object.assign(f.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,o=this._emitter,s=this._listeners,a=function(){var r=d.apply(null,arguments),s={data:r,name:t,original:e};n?!1!==n.call(i,s)&&o.emit.apply(o,[s.name].concat(r)):o.emit.apply(o,[t].concat(r))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===s[e]&&(s[e]=a,r._on.call(i,e,a))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===t&&!o.hasListeners(n)&&s[e]&&(s[e]=null,r._off.call(i,e,a))},s[e]=null,o.on("removeListener",this._onRemoveListener)):(s[e]=a,r._on.call(i,e,a))},unsubscribe:function(e){var t,n,r,i=this,o=this._listeners,s=this._emitter,c=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function u(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=w.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=o[e]))return;c.call(l,e,t),delete o[e],--this._listenersCount||u()}else{for(r=(n=a(o)).length;r-- >0;)e=n[r],c.call(l,e,o[e]);this._listeners={},this._listenersCount=0,u()}}});var y=m(["function"]),v=m(["object","function"]);function b(e,t,n){var r,i,o,s=0,a=new e((function(c,l,u){function d(){i&&(i=null),s&&(clearTimeout(s),s=0)}n=p(n,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),r=!n.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof u;var h=function(e){d(),c(e)},f=function(e){d(),l(e)};r?t(h,f,u):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),n.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,a.cancel(e),l(e)}),n.timeout))}));return r||(a.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),a}function w(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function E(e,t,n,r,i){if(!n)return null;if(0===r){var o=typeof t;if("string"===o){var s,c,l=0,u=0,d=this.delimiter,h=d.length;if(-1!==(c=t.indexOf(d))){s=new Array(5);do{s[l++]=t.slice(u,c),u=c+h}while(-1!==(c=t.indexOf(d,u)));s[l++]=t.slice(u),t=s,i=l}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var f,p,g,m,y,v,b,w=null,S=t[r],_=t[r+1];if(r===i)n._listeners&&("function"==typeof n._listeners?(e&&e.push(n._listeners),w=[n]):(e&&e.push.apply(e,n._listeners),w=[n]));else{if("*"===S){for(c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&(b=E(e,t,n[f],r+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===S){for((y=r+1===i||r+2===i&&"*"===_)&&n._listeners&&(w=E(e,t,n,i,i)),c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&("*"===f||"**"===f?(n[f]._listeners&&!y&&(b=E(e,t,n[f],i,i))&&(w?w.push.apply(w,b):w=b),b=E(e,t,n[f],r,i)):b=E(e,t,n[f],f===_?r+2:r,i),b&&(w?w.push.apply(w,b):w=b));return w}n[S]&&(w=E(e,t,n[S],r+1,i))}if((p=n["*"])&&E(e,t,p,r+1,i),g=n["**"])if(r<i)for(g._listeners&&E(e,t,g,i,i),c=(v=a(g)).length;c-- >0;)"_listeners"!==(f=v[c])&&(f===_?E(e,t,g[f],r+2,i):f===S?E(e,t,g[f],r+1,i):((m={})[f]=g[f],E(e,t,{"**":m},r+1,i)));else g._listeners?E(e,t,g,i,i):g["*"]&&g["*"]._listeners&&E(e,t,g["*"],i,i);return w}function S(e,t,n){var r,i,o=0,s=0,a=this.delimiter,c=a.length;if("string"==typeof e)if(-1!==(r=e.indexOf(a))){i=new Array(5);do{i[o++]=e.slice(s,r),s=r+c}while(-1!==(r=e.indexOf(a,s)));i[o++]=e.slice(s)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(r=0;r+1<o;r++)if("**"===i[r]&&"**"===i[r+1])return;var l,d=this.listenerTree;for(r=0;r<o;r++)if(d=d[l=i[r]]||(d[l]={}),r===o-1)return d._listeners?("function"==typeof d._listeners&&(d._listeners=[d._listeners]),n?d._listeners.unshift(t):d._listeners.push(t),!d._listeners.warned&&this._maxListeners>0&&d._listeners.length>this._maxListeners&&(d._listeners.warned=!0,u.call(this,d._listeners.length,l))):d._listeners=t,!0;return!0}function _(e,t,n,r){for(var i,o,s,c,l=a(e),u=l.length,d=e._listeners;u-- >0;)i=e[o=l[u]],s="_listeners"===o?n:n?n.concat(o):[o],c=r||"symbol"==typeof o,d&&t.push(c?s:s.join(this.delimiter)),"object"==typeof i&&_.call(this,i,t,s,c);return t}function C(e){for(var t,n,r,i=a(e),o=i.length;o-- >0;)(t=e[n=i[o]])&&(r=!0,"_listeners"===n||C(t)||delete e[n]);return r}function A(e,t,n){this.emitter=e,this.event=t,this.listener=n}function k(t,n,i){if(!0===i)a=!0;else if(!1===i)o=!0;else{if(!i||"object"!=typeof i)throw TypeError("options should be an object or true");var o=i.async,a=i.promisify,c=i.nextTick,l=i.objectify}if(o||c||a){var u=n,d=n._origin||n;if(c&&!r)throw Error("process.nextTick is not supported");a===e&&(a="AsyncFunction"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return a?c?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=n,u.apply(t,e)})):(c?Le.nextTick:s)((function(){t.event=n,u.apply(t,e)}))},n._async=!0,n._origin=d}return[n,l?new A(this,t,n):this]}function M(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,l.call(this,e)}A.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},M.EventEmitter2=M,M.prototype.listenTo=function(t,r,i){if("object"!=typeof t)throw TypeError("target musts be an object");var o=this;function s(e){if("object"!=typeof e)throw TypeError("events must be an object");var n,r=i.reducers,s=w.call(o,t);n=-1===s?new f(o,t,i):o._observers[s];for(var c,l=a(e),u=l.length,d="function"==typeof r,h=0;h<u;h++)c=l[h],n.subscribe(c,e[c]||c,d?r:r&&r[c])}return i=p(i,{on:e,off:e,reducers:e},{on:y,off:y,reducers:v}),n(r)?s(h(r)):s("string"==typeof r?h(r.split(/\s+/)):r),this},M.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r,i=n.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),o=!0);return o},M.prototype.delimiter=".",M.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},M.prototype.getMaxListeners=function(){return this._maxListeners},M.prototype.event="",M.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},M.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},M.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},M.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},M.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},M.prototype._many=function(e,t,n,r,i){var o=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&o.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,r,i)},M.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newL