UNPKG

@metamask/sdk-react

Version:

A react component and react hooks to connect and use MetaMask

1 lines 581 kB
"use strict";var e=require("react"),t="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(e,t){var r="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==n&&n,i=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var n=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==n&&n,r="URLSearchParams"in n,i="Symbol"in n&&"iterator"in Symbol,o="FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="FormData"in n,a="ArrayBuffer"in n;if(a)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(e){return e&&c.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function d(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function g(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function m(e){var t=new FileReader,n=g(t);return t.readAsArrayBuffer(e),n}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||l(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=p(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(m)}),this.text=function(){var e,t,n,r=p(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=g(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(E)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=u(e),t=d(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},f.prototype.delete=function(e){delete this.map[u(e)]},f.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},f.prototype.set=function(e,t){this.map[u(e)]=d(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),h(e)},f.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),h(e)},f.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),h(e)},i&&(f.prototype[Symbol.iterator]=f.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(e,t){if(!(this instanceof w))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,r,i=(t=t||{}).body;if(e instanceof w){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),b.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function _(e,t){if(!(this instanceof _))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},v.call(w.prototype),v.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var S=[301,302,303,307,308];_.redirect=function(e,t){if(-1===S.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=n.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function C(e,r){return new Promise((function(i,s){var c=new w(e,r);if(c.signal&&c.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var l=new XMLHttpRequest;function u(){l.abort()}l.onload=function(){var e,t,n={status:l.status,statusText:l.statusText,headers:(e=l.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};n.url="responseURL"in l?l.responseURL:n.headers.get("X-Request-URL");var r="response"in l?l.response:l.responseText;setTimeout((function(){i(new _(r,n))}),0)},l.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.onabort=function(){setTimeout((function(){s(new t.DOMException("Aborted","AbortError"))}),0)},l.open(c.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(c.url),!0),"include"===c.credentials?l.withCredentials=!0:"omit"===c.credentials&&(l.withCredentials=!1),"responseType"in l&&(o?l.responseType="blob":a&&c.headers.get("Content-Type")&&-1!==c.headers.get("Content-Type").indexOf("application/octet-stream")&&(l.responseType="arraybuffer")),!r||"object"!=typeof r.headers||r.headers instanceof f?c.headers.forEach((function(e,t){l.setRequestHeader(t,e)})):Object.getOwnPropertyNames(r.headers).forEach((function(e){l.setRequestHeader(e,d(r.headers[e]))})),c.signal&&(c.signal.addEventListener("abort",u),l.onreadystatechange=function(){4===l.readyState&&c.signal.removeEventListener("abort",u)}),l.send(void 0===c._bodyInit?null:c._bodyInit)}))}C.polyfill=!0,n.fetch||(n.fetch=C,n.Headers=f,n.Request=w,n.Response=_),t.Headers=f,t.Request=w,t.Response=_,t.fetch=C}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=r.fetch?r:i;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t}(r,r.exports);var i=r.exports;function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}var a=o,c=s;function l(e){if(a===setTimeout)return setTimeout(e,0);if((a===o||!a)&&setTimeout)return a=setTimeout,setTimeout(e,0);try{return a(e,0)}catch(t){try{return a.call(null,e,0)}catch(t){return a.call(this,e,0)}}}"function"==typeof t.setTimeout&&(a=setTimeout),"function"==typeof t.clearTimeout&&(c=clearTimeout);var u,d=[],h=!1,f=-1;function p(){h&&u&&(h=!1,u.length?d=u.concat(d):f=-1,d.length&&g())}function g(){if(!h){var e=l(p);h=!0;for(var t=d.length;t;){for(u=d,d=[];++f<t;)u&&u[f].run();f=-1,t=d.length}u=null,h=!1,function(e){if(c===clearTimeout)return clearTimeout(e);if((c===s||!c)&&clearTimeout)return c=clearTimeout,clearTimeout(e);try{return c(e)}catch(t){try{return c.call(null,e)}catch(t){return c.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}m.prototype.run=function(){this.fun.apply(null,this.array)};function y(){}var v=y,b=y,w=y,E=y,_=y,S=y,C=y;var x=t.performance||{},k=x.now||x.mozNow||x.msNow||x.oNow||x.webkitNow||function(){return(new Date).getTime()};var A=new Date;var T,M,P={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];d.push(new m(e,t)),1!==d.length||h||l(g)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:v,addListener:b,once:w,off:E,removeListener:_,removeAllListeners:S,emit:C,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*k.call(x),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-A)/1e3}},R={exports:{}};function I(){if(M)return T;M=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 T=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))},T}var O=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=I(),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!==P&&"env"in P&&(e=P.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=O(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(R,R.exports);var L=R.exports;const N=/\{[^{}]+\}/g;function D(e){let{baseUrl:t="",Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:o,headers:s,requestInitExt:a,...c}={...e};a="object"==typeof P&&Number.parseInt(P?.versions?.node?.substring(0,2))>=18&&P.versions.undici?a:void 0,t=H(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??U,body:b,...w}=u||{};d&&(t=H(d));let E="function"==typeof i?i:K(i);y&&(E="function"==typeof y?y:K({..."object"==typeof i?i:{},...y}));const _=void 0===b?void 0:v(b),S=void 0===_||_ instanceof FormData?{}:{"Content-Type":"application/json"},C={redirect:"follow",...c,...w,body:_,headers:F(S,s,p,g.header)};let x,k,A,T=new n(function(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=function(e,t){let n=e;for(const r of e.match(N)??[]){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,j(e,s,{style:o,explode:i})):n="object"!=typeof s?"matrix"!==o?n.replace(r,"label"===o?`.${encodeURIComponent(s)}`:encodeURIComponent(s)):n.replace(r,`;${$(e,s)}`):n.replace(r,B(e,s,{style:o,explode:i}))}return n}(n,t.params.path));let r=t.querySerializer(t.params.query??{});r.startsWith("?")&&(r=r.substring(1));r&&(n+=`?${r}`);return n}(e,{baseUrl:t,params:g,querySerializer:E}),C);for(const e in w)e in T||(T[e]=w[e]);if(l.length){x=Math.random().toString(36).slice(2,11),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:T,schemaPath:e,params:g,options:k,id:x});if(r){if(!(r instanceof n)){if(r instanceof Response){A=r;break}throw new Error("onRequest: must return new Request() or Response() when modifying the request")}T=r}}}if(!A){try{A=await h(T,a)}catch(M){let t=M;if(l.length)for(let n=l.length-1;n>=0;n--){const r=l[n];if(r&&"object"==typeof r&&"function"==typeof r.onError){const n=await r.onError({request:T,error:t,schemaPath:e,params:g,options:k,id:x});if(n){if(n instanceof Response){t=void 0,A=n;break}if(n instanceof Error){t=n;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(t)throw t}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:T,response:A,schemaPath:e,params:g,options:k,id:x});if(t){if(!(t instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");A=t}}}}if(204===A.status||"0"===A.headers.get("Content-Length"))return A.ok?{data:void 0,response:A}:{error:void 0,response:A};if(A.ok)return"stream"===m?{data:A.body,response:A}:{data:await A[m](),response:A};let M=await A.text();try{M=JSON.parse(M)}catch{}return{error:M,response:A}}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)}}}}function $(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 B(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($(o,t[i],n))}const o=r.join(i);return"label"===n.style||"matrix"===n.style?`${i}${o}`:o}function j(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($(e,r,n));return"label"===n.style||"matrix"===n.style?`${r}${i.join(r)}`:i.join(r)}function K(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(j(r,i,{style:"form",explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}))}else"object"!=typeof i?n.push($(r,i,e)):n.push(B(r,i,{style:"deepObject",explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}))}return n.join("&")}}function U(e){return e instanceof FormData?e:JSON.stringify(e)}function F(...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 H(e){return e.endsWith("/")?e.substring(0,e.length-1):e}var z,q,V=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()}}},W=class{constructor(e){this.enabled=!1,this.properties={};const t=D({baseUrl:e});this.sender=new V({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!==P&&P.env&&(z=null!=(q=P.env.METAMASK_ANALYTICS_ENDPOINT)?q:P.env.NEXT_PUBLIC_METAMASK_ANALYTICS_ENDPOINT);var G,Y=new W(null!=z?z:"https://mm-sdk-analytics.api.cx.metamask.io/"),Z={exports:{}};G=Z,function(e){var t=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r="object"==typeof P&&"function"==typeof P.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!==P&&P.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,P.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,_=t[r],S=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("*"===_){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("**"===_){for((y=r+1===i||r+2===i&&"*"===S)&&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===S?r+2:r,i),b&&(w?w.push.apply(w,b):w=b));return w}n[_]&&(w=E(e,t,n[_],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===S?E(e,t,g[f],r+2,i):f===_?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 _(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 S(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&&S.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 x(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?P.nextTick:s)((function(){t.event=n,u.apply(t,e)}))},n._async=!0,n._origin=d}return[n,l?new x(this,t,n):this]}function A(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,l.call(this,e)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},A.EventEmitter2=A,A.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},A.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},A.prototype.delimiter=".",A.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},A.prototype.getMaxListeners=function(){return this._maxListeners},A.prototype.event="",A.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},A.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},A.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},A.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},A.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},A.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)},A.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("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(n=a.length,i)for(r=0;r<n;r++)if("symbol"==typeof a[r]){s=!0;break}s||(a=a.join(this.delimiter))}var u,d=arguments.length;if(this._all&&this._all.length)for(r=0,n=(u=this._all.slice()).length;r<n;r++)switch(this.event=a,d){case 1:u[r].call(this,a);break;case 2:u[r].call(this,a,arguments[1]);break;case 3:u[r].call(this,a,arguments[1],arguments[2]);break;default:u[r].apply(this,arguments)}if(l)u=[],E.call(this,u,e,this.listenerTree,0,n);else{if("function"==typeof(u=this._events[a])){switch(this.event=a,d){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(d-1),o=1;o<d;o++)t[o-1]=arguments[o];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(d>3)for(t=new Array(d-1),o=1;o<d;o++)t[o-1]=arguments[o];for(r=0,n=u.length;r<n;r++)switch(this.event=a,d){case 1:u[r].call(this);break;case 2:u[r].call(this,arguments[1]);break;case 3:u[r].call(this,arguments[1],arguments[2]);break;default:u[r].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},A.prototype.emitAsync=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("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,i)for(o=0;o<r;o++)if("symbol"==typeof a[o]){t=!0;break}t||(a=a.join(this.delimiter))}var u,d=[],h=arguments.length;if(this._all)for(o=0,r=this._all.length;o<r;o++)switch(this.event=a,h){case 1:d.push(this._all[o].call(this,a));break;case 2:d.push(this._all[o].call(this,a,arguments[1]));break;case 3:d.push(this._all[o].call(this,a,arguments[1],arguments[2]));break;default:d.push(this._all[o].apply(this,arguments))}if(l?(u=[],E.call(this,u,e,this.listenerTree,0)):u=this._events[a],"function"==typeof u)switch(this.event=a,h){case 1:d.push(u.call(this));break;case 2:d.push(u.call(this,arguments[1]));break;case 3:d.push(u.call(this,arguments[1],arguments[2]));break;default:for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];d.push(u.apply(this,n))}else if(u&&u.length){if(u=u.slice(),h>3)for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];for(o=0,r=u.length;o<r;o++)switch(this.event=a,h){case 1:d.push(u[o].call(this));break;case 2:d.push(u[o].call(this,arguments[1]));break;case 3:d.push(u[o].call(this,arguments[1],arguments[2]));break;default:d.push(u[o].apply(this,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(d)},A.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},A.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},A.prototype.onAny=function(e){return this._onAny(e,!1)},A.prototype.prependAny=function(e){return this._onAny(e,!0)},A.prototype.addListener=A.prototype.on,A.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},A.prototype._on=function(t,n,r,i){if("function"==typeof t)return this._onAny(t,n),this;if("function"!=typeof n)throw new Error("on only accepts instances of Function");this._events||c.call(this);var o,s=this;return i!==e&&(n=(o=k.call(this,t,n,i))[0],s=o[1]),this._newListener&&this.emit("newListener",t,n),this.wildcard?(_.call(this,t,n,r),s):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),r?this._events[t].unshift(n):this._events[t].push(n),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,u.call(this,this._events[t].length,t))):this._events[t]=n,s)},A.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=E.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var a=i[s];if(r=a._listeners,n(r)){for(var c=-1,l=0,u=r.length;l<u;l++)if(r[l]===t||r[l].listener&&r[l].listener===t||r[l]._origin&&r[l]._origin===t){c=l;break}if(c<0)continue;return this.wildcard?a._listeners.splice(c,1):this._events[e].splice(c,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&C(this.listenerTree),this},A.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n<r;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,r=t.length;n<r;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},A.prototype.removeListener=A.prototype.off,A.prototype.removeAllListeners=function(t){if(t===e)return!this._events||c.call(this),this;if(this.wildcard){var n,r=E.call(this,null,t,this.listenerTree,0);if(!r)return this;for(n=0;n<r.length;n++)r[n]._listeners=null;this.listenerTree&&C(this.listenerTree)}else this._events&&(this._events[t]=null);return this},A.prototype.listeners=function(t){var n,r,i,o,s,c=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!c)return[];for(o=(n=a(c)).length,i=[];o-- >0;)"function"==typeof(r=c[n[o]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],u="string"==typeof t?t.split(this.delimiter):t.slice();return E.call(this,l,u,s,0),l}return c&&(r=c[t])?"function"==typeof r?[r]:r:[]},A.prototype.eventNames=function(e){var t=this._events;return this.wildcard?S.call(this,this.listenerTree,[],null,e):t?a(t):[]},A.prototype.listenerCount=function(e){return this.listeners(e).length},A.prototype.hasListeners=function(t){if(this.wildcard){var n=[],r="string"==typeof t?t.split(this.delimiter):t.slice();return E.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(t===e?a(i).length:i[t]))},A.prototype.listenersAny=function(){return this._all?this._all:[]},A.prototype.waitFor=function(t,n){var r=this,i=typeof n;return"number"===i?n={timeout:n}:"function"===i&&(n={filter:n}),b((n=p(n,{timeout:0,filter:e,handleError:!1,Promise:Promise,overload:!1},{filter:y,Promise:g})).Promise,(function(e,i,o){function s(){var o=n.filter;if(!o||o.apply(r,arguments))if(r.off(t,s),n.handleError){var a=arguments[0];a?i(a):e(d.apply(null,arguments).slice(1))}else e(d.apply(null,arguments))}o((function(){r.off(t,s)})),r._on(t,s,!1)}),{timeout:n.timeout,overload:n.overload})};var T=A.prototype;Object.defineProperties(A,{defaultMaxListeners:{get:function(){return T._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");T._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return b((n=p(n,{Promise:Promise,timeout:0,overload:!1},{Promise:g})).Promise,(function(n,r,i){var o;if("function"==typeof e.addEventListener)return o=function(){n(d.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var s,a=function(){s&&e.removeListener("error",s),n(d.apply(null,arguments))};"error"!==t&&(s=function(n){e.removeListener(t,a),r(n)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,a)})),e.once(t,a)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(T,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof e&&e.amd?e((function(){return A})):G.exports=A}();var J,X=Z.exports,Q=new Uint8Array(16);function ee(){if(!J&&!(J="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return J(Q)}var te=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ne(e){return"string"==typeof e&&te.test(e)}for(var re=[],ie=0;ie<256;++ie)re.push((ie+256).toString(16).substr(1));function oe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(re[e[t+0]]+re[e[t+1]]+re[e[t+2]]+re[e[t+3]]+"-"+re[e[t+4]]+re[e[t+5]]+"-"+re[e[t+6]]+re[e[t+7]]+"-"+re[e[t+8]]+re[e[t+9]]+"-"+re[e[t+10]]+re[e[t+11]]+re[e[t+12]]+re[e[t+13]]+re[e[t+14]]+re[e[t+15]]).toLowerCase();if(!ne(n))throw TypeError("Stringified UUID is invalid");return n}function se(e,t,n){function r(e,r,i,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=function(e){if(!ne(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+e.length);if(s.set(r),s.set(e,r.length),(s=n(s))[6]=15&s[6]|t,s[8]=63&s[8]|128,i){o=o||0;for(var a=0;a<16;++a)i[o+a]=s[a];return i}return oe(s)}try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function ae(e){return 14+(e+64>>>9<<4)+1}function ce(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function le(e,t,n,r,i,o){return ce((s=ce(ce(t,e),ce(r,o)))<<(a=i)|s>>>32-a,n);var s,a}function ue(e,t,n,r,i,o,s){return le(t&n|~t&r,e,t,i,o,s)}function de(e,t,n,r,i,o,s){return le(t&r|n&~r,e,t,i,o,s)}function he(e,t,n,r,i,o,s){return le(t^n^r,e,t,i,o,s)}function fe(e,t,n,r,i,o,s){return le(n^(t|~r),e,t,i,o,s)}function pe(e,t,n){var r=(e=e||{}).random||(e.rng||ee)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return oe(r)}function ge(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function me(e,t){return e<<t|e>>>32-t}se("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",i=0;i<n;i+=8){var o=e[i>>5]>>>i%32&255,s=parseInt(r.charAt(o>>>4&15)+r.charAt(15&o),16);t.push(s)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[ae(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,o=271733878,s=0;s<e.length;s+=16){var a=n,c=r,l=i,u=o;n=ue(n,r,i,o,e[s],7,-680876936),o=ue(o,n,r,i,e[s+1],12,-389564586),i=ue(i,o,n,r,e[s+2],17,606105819),r=ue(r,i,o,n,e[s+3],22,-1044525330),n=ue(n,r,i,o,e[s+4],7,-176418897),o=ue(o,n,r,i,e[s+5],12,1200080426),i=ue(i,o,n,r,e[s+6],17,-1473231341),r=ue(r,i,o,n,e[s+7],22,-45705983),n=ue(n,r,i,o,e[s+8],7,1770035416),o=ue(o,n,r,i,e[s+9],12,-1958414417),i=ue(i,o,n,r,e[s+10],17,-42063),r=ue(r,i,o,n,e[s+11],22,-1990404162),n=ue(n,r,i,o,e[s+12],7,1804603682),o=ue(o,n,r,i,e[s+13],12,-40341101),i=ue(i,o,n,r,e[s+14],17,-1502002290),n=de(n,r=ue(r,i,o,n,e[s+15],22,1236535329),i,o,e[s+1],5,-165796510),o=de(o,n,r,i,e[s+6],9,-1069501632),i=de(i,o,n,r,e[s+11],14,643717713),r=de(r,i,o,n,e[s],20,-373897302),n=de(n,r,i,o,e[s+5],5,-701558691),o=de(o,n,r,i,e[s+10],9,38016083),i=de(i,o,n,r,e[s+15],14,-660478335),r=de(r,i,o,n,e[s+4],20,-405537848),n=de(n,r,i,o,e[s+9],5,568446438),o=de(o,n,r,i,e[s+14],9,-1019803690),i=de(i,o,n,r,e[s+3],14,-187363961),r=de(r,i,o,n,e[s+8],20,1163531501),n=de(n,r,i,o,e[s+13],5,-1444681467),o=de(o,n,r,i,e[s+2],9,-51403784),i=de(i,o,n,r,e[s+7],14,1735328473),n=he(n,r=de(r,i,o,n,e[s+12],20,-1926607734),i,o,e[s+5],4,-378558),o=he(o,n,r,i,e[s+8],11,-2022574463),i=he(i,o,n,r,e[s+11],16,1839030562),r=he(r,i,o,n,e[s+14],23,-35309556),n=he(n,r,i,o,e[s+1],4,-1530992060),o=he(o,n,r,i,e[s+4],11,1272893353),i=he(i,o,n,r,e[s+7],16,-155497632),r=he(r,i,o,n,e[s+10],23,-1094730640),n=he(n,r,i,o,e[s+13],4,681279174),o=he(o,n,r,i,e[s],11,-358537222),i=he(i,o,n,r,e[s+3],16,-722521979),r=he(r,i,o,n,e[s+6],23,76029189),n=he(n,r,i,o,e[s+9],4,-640364487),o=he(o,n,r,i,e[s+12],11,-421815835),i=he(i,o,n,r,e[s+15],16,530742520),n=fe(n,r=he(r,i,o,n,e[s+2],23,-995338651),i,o,e[s],6,-198630844),o=fe(o,n,r,i,e[s+7],10,1126891415),i=fe(i,o,n,r,e[s+14],15,-1416354905),r=fe(r,i,o,n,e[s+5],21,-57434055),n=fe(n,r,i,o,e[s+12],6,1700485571),o=fe(o,n,r,i,e[s+3],10,-1894986606),i=fe(i,o,n,r,e[s+10],15,-1051523),r=fe(r,i,o,n,e[s+1],21,-2054922799),n=fe(n,r,i,o,e[s+8],6,1873313359),o=fe(o,n,r,i,e[s+15],10,-30611744),i=fe(i,o,n,r,e[s+6],15,-1560198380),r=fe(r,i,o,n,e[s+13],21,1309151649),n=fe(n,r,i,o,e[s+4],6,-145523070),o=fe(o,n,r,i,e[s+11],10,-1120210379),i=fe(i,o,n,r,e[s+2],15,718787259),r=fe(r,i,o,n,e[s+9],21,-343485551),n=ce(n,a),r=ce(r,c),i=ce(i,l),o=ce(o,u)}return[n,r,i,o]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(ae(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))})),se("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,s=Math.ceil(o/16),a=new Array(s),c=0;c<s;++c){for(var l=new Uint32Array(16),u=0;u<16;++u)l[u]=e[64*c+4*u]<<24|e[64*c+4*u+1]<<16|e[64*c+4*u+2]<<8|e[64*c+4*u+3];a[c]=l}a[s-1][14]=8*(e.length-1)/Math.pow(2,32),