@depay/walletconnect-v2
Version:
WalletConnect v2 browser pre-built usable in rollup bundles.
9 lines • 650 kB
JavaScript
var WalletConnectV2=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=128)}([function(t,e,r){"use strict";(function(t,n,i){r.d(e,"a",(function(){return io})),r.d(e,"b",(function(){return xs})),r.d(e,"c",(function(){return ao})),r.d(e,"d",(function(){return Co})),r.d(e,"e",(function(){return st})),r.d(e,"f",(function(){return tt})),r.d(e,"g",(function(){return Xi})),r.d(e,"h",(function(){return et})),r.d(e,"i",(function(){return po})),r.d(e,"j",(function(){return go})),r.d(e,"k",(function(){return fo})),r.d(e,"l",(function(){return yo})),r.d(e,"m",(function(){return vo})),r.d(e,"n",(function(){return ut})),r.d(e,"o",(function(){return it})),r.d(e,"p",(function(){return Vi})),r.d(e,"q",(function(){return Q})),r.d(e,"r",(function(){return nt})),r.d(e,"s",(function(){return To})),r.d(e,"t",(function(){return uo})),r.d(e,"u",(function(){return co})),r.d(e,"v",(function(){return J})),r.d(e,"w",(function(){return Y})),r.d(e,"x",(function(){return ro})),r.d(e,"y",(function(){return ht})),r.d(e,"z",(function(){return Hi})),r.d(e,"A",(function(){return Bo})),r.d(e,"B",(function(){return eo})),r.d(e,"C",(function(){return Ki})),r.d(e,"D",(function(){return no})),r.d(e,"E",(function(){return Eo})),r.d(e,"F",(function(){return xo})),r.d(e,"G",(function(){return qo})),r.d(e,"H",(function(){return ft})),r.d(e,"I",(function(){return ho})),r.d(e,"J",(function(){return lo})),r.d(e,"K",(function(){return G})),r.d(e,"L",(function(){return vs})),r.d(e,"M",(function(){return at})),r.d(e,"N",(function(){return K})),r.d(e,"O",(function(){return bs})),r.d(e,"P",(function(){return Wo})),r.d(e,"Q",(function(){return H})),r.d(e,"R",(function(){return Vo})),r.d(e,"S",(function(){return Qo})),r.d(e,"T",(function(){return wo})),r.d(e,"U",(function(){return Ko})),r.d(e,"V",(function(){return zo})),r.d(e,"W",(function(){return Xo})),r.d(e,"X",(function(){return us})),r.d(e,"Y",(function(){return hs})),r.d(e,"Z",(function(){return ss})),r.d(e,"ab",(function(){return ns})),r.d(e,"bb",(function(){return ls})),r.d(e,"cb",(function(){return ds})),r.d(e,"db",(function(){return ps})),r.d(e,"eb",(function(){return Fo})),r.d(e,"fb",(function(){return as})),r.d(e,"gb",(function(){return is})),r.d(e,"hb",(function(){return os})),r.d(e,"ib",(function(){return cs})),r.d(e,"jb",(function(){return ys})),r.d(e,"kb",(function(){return rs})),r.d(e,"lb",(function(){return fs})),r.d(e,"mb",(function(){return Ho})),r.d(e,"nb",(function(){return Jo})),r.d(e,"ob",(function(){return Z})),r.d(e,"pb",(function(){return $i})),r.d(e,"qb",(function(){return $})),r.d(e,"rb",(function(){return P})),r.d(e,"sb",(function(){return ot})),r.d(e,"tb",(function(){return Ro})),r.d(e,"ub",(function(){return ms})),r.d(e,"vb",(function(){return bo})),r.d(e,"wb",(function(){return mo})),r.d(e,"xb",(function(){return Gi}));var o=r(71),s=r(1),a=r(21),u=r(68),c=r(32),f=r(43),h=r(69),l=r(24),p=r(38),d=r(44),v=r(5),g=r(70);function y(t,e,r){return(e=x(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function b(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,x(n.key),n)}}function w(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function x(t){var e=function(t,e){if("object"!=_(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==_(e)?e:e+""}function E(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */E=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,s=Object.create(o.prototype),a=new M(n||[]);return i(s,"_invoke",{value:k(t,r,a)}),s}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var l="suspendedStart",p="executing",d="completed",v={};function g(){}function y(){}function b(){}var m={};c(m,s,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(R([])));x&&x!==r&&n.call(x,s)&&(m=x);var A=b.prototype=g.prototype=Object.create(m);function O(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(i,o,s,a){var u=h(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==_(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(f).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function k(e,r,n){var i=l;return function(o,s){if(i===p)throw Error("Generator is already running");if(i===d){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var u=I(a,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===l)throw i=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var c=h(e,r,n);if("normal"===c.type){if(i=n.done?d:"suspendedYield",c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=d,n.method="throw",n.arg=c.arg)}}}function I(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=h(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(_(e)+" is not iterable")}return y.prototype=b,i(A,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c(t,u,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},O(S.prototype),c(S.prototype,a,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new S(f(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},O(A),c(A,u,"Generator"),c(A,s,(function(){return this})),c(A,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,M.prototype={constructor:M,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var u=n.call(s,"catchLoc"),c=n.call(s,"finallyLoc");if(u&&c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function _(t){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function A(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=k(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function O(t){return function(t){if(Array.isArray(t))return I(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||k(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,s,a=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}(t,e)||k(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(t,e){if(t){if("string"==typeof t)return I(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(t,e):void 0}}function I(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var j=function(t,e,r){return new Promise((function(n,i){var o=function(t){try{a(r.next(t))}catch(t){i(t)}},s=function(t){try{a(r.throw(t))}catch(t){i(t)}},a=function(t){return t.done?n(t.value):Promise.resolve(t.value).then(o,s)};a((r=r.apply(t,e)).next())}))};function P(t){var e=S(t.split(":"),2);return{namespace:e[0],reference:e[1]}}function M(t,e){return t.includes(":")?[t]:e.chains||[]}var R=Object.defineProperty,N=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,C=function(t,e,r){return e in t?R(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},U=function(t,e){for(var r in e||(e={}))T.call(e,r)&&C(t,r,e[r]);if(N){var n,i=A(N(e));try{for(i.s();!(n=i.n()).done;){r=n.value;L.call(e,r)&&C(t,r,e[r])}}catch(t){i.e(t)}finally{i.f()}}return t},D="react-native",B="node",q="browser",z="unknown",F="js";function K(){return(void 0===t?"undefined":_(t))<"u"&&_(t.versions)<"u"&&_(t.versions.node)<"u"}function H(){return!Object(a.getDocument)()&&!!Object(a.getNavigator)()&&"ReactNative"===navigator.product}function G(){return!K()&&!!Object(a.getNavigator)()&&!!Object(a.getDocument)()}function V(){return H()?D:K()?B:G()?q:z}function Y(){var t;try{return H()&&(void 0===n?"undefined":_(n))<"u"&&_(null==n?void 0:n.Application)<"u"?null==(t=n.Application)?void 0:t.applicationId:void 0}catch(t){return}}function J(){return Object(u.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function W(t,e,r){var i=function(){if(V()===D&&(void 0===n?"undefined":_(n))<"u"&&_(null==n?void 0:n.Platform)<"u"){var t=n.Platform;return[t.OS,t.Version].join("-")}var e=Object(o.a)();if(null===e)return"unknown";var r=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[r,e.name,e.version].join("-"):[r,e.version].join("-")}(),s=function(){var t,e=V();return e===q?[e,(null==(t=Object(a.getLocation)())?void 0:t.host)||"unknown"].join(":"):e}();return[[t,e].join("-"),[F,r].join("-"),i,s].join("/")}function Q(t){var e=t.protocol,r=t.version,n=t.relayUrl,i=t.sdkVersion,o=t.auth,s=t.projectId,a=t.useOnCloseEvent,u=t.bundleId,f=n.split("?"),h={auth:o,ua:W(e,r,i),projectId:s,useOnCloseEvent:a||void 0,origin:u||void 0},l=function(t,e){var r=c.parse(t);return r=U(U({},r),e),t=c.stringify(r)}(f[1]||"",h);return f[0]+"?"+l}function X(t,e){return t.filter((function(t){return e.includes(t)})).length===t.length}function Z(t){return Object.fromEntries(t.entries())}function $(t){return new Map(Object.entries(t))}function tt(){var t,e,r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s.FIVE_MINUTES,i=arguments.length>1?arguments[1]:void 0,o=Object(s.toMiliseconds)(n||s.FIVE_MINUTES);return{resolve:function(e){r&&t&&(clearTimeout(r),t(e))},reject:function(t){r&&e&&(clearTimeout(r),e(t))},done:function(){return new Promise((function(n,s){r=setTimeout((function(){s(new Error(i))}),o),t=n,e=s}))}}}function et(t,e,r){var n=this;return new Promise((function(i,o){return j(n,null,E().mark((function n(){var s,a;return E().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=setTimeout((function(){return o(new Error(r))}),e),n.prev=1,n.next=4,t;case 4:a=n.sent,i(a),n.next=11;break;case 8:n.prev=8,n.t0=n.catch(1),o(n.t0);case 11:clearTimeout(s);case 12:case"end":return n.stop()}}),n,null,[[1,8]])})))}))}function rt(t,e){if("string"==typeof e&&e.startsWith("".concat(t,":")))return e;if("topic"===t.toLowerCase()){if("string"!=typeof e)throw new Error('Value must be "string" for expirer target type: topic');return"topic:".concat(e)}if("id"===t.toLowerCase()){if("number"!=typeof e)throw new Error('Value must be "number" for expirer target type: id');return"id:".concat(e)}throw new Error("Unknown expirer target type: ".concat(t))}function nt(t){return rt("topic",t)}function it(t){return rt("id",t)}function ot(t){var e=S(t.split(":"),2),r=e[0],n=e[1],i={id:void 0,topic:void 0};if("topic"===r&&"string"==typeof n)i.topic=n;else{if("id"!==r||!Number.isInteger(Number(n)))throw new Error("Invalid target, expected id:number or topic:string, got ".concat(r,":").concat(n));i.id=Number(n)}return i}function st(t,e){return Object(s.fromMiliseconds)((e||Date.now())+Object(s.toMiliseconds)(t))}function at(t){return Date.now()>=Object(s.toMiliseconds)(t)}function ut(t,e){return"".concat(t).concat(e?":".concat(e):"")}function ct(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return O(new Set([].concat(O(t),O(e))))}function ft(t){return j(this,arguments,(function(t){var e=t.id,r=t.topic,i=t.wcDeepLink;return E().mark((function t(){var o,s,a,u;return E().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,i){t.next=3;break}return t.abrupt("return");case 3:if(o="string"==typeof i?JSON.parse(i):i,"string"==typeof(s=null==o?void 0:o.href)){t.next=7;break}return t.abrupt("return");case 7:if(s.endsWith("/")&&(s=s.slice(0,-1)),a="".concat(s,"/wc?requestId=").concat(e,"&sessionTopic=").concat(r),(u=V())!==q){t.next=13;break}a.startsWith("https://")||a.startsWith("http://")?window.open(a,"_blank","noreferrer noopener"):window.open(a,"_self","noreferrer noopener"),t.next=17;break;case 13:if(t.t0=u===D&&_(null==n?void 0:n.Linking)<"u",!t.t0){t.next=17;break}return t.next=17,n.Linking.openURL(a);case 17:t.next=22;break;case 19:t.prev=19,t.t1=t.catch(0),console.error(t.t1);case 22:case"end":return t.stop()}}),t,null,[[0,19]])}))()}))}function ht(t,e){return j(this,null,E().mark((function r(){return E().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,t.getItem(e);case 3:if(r.t0=r.sent,r.t0){r.next=6;break}r.t0=G()?localStorage.getItem(e):void 0;case 6:return r.abrupt("return",r.t0);case 9:r.prev=9,r.t1=r.catch(0),console.error(r.t1);case 12:case"end":return r.stop()}}),r,null,[[0,9]])})))}var lt=("undefined"==typeof globalThis?"undefined":_(globalThis))<"u"?globalThis:("undefined"==typeof window?"undefined":_(window))<"u"?window:(void 0===n?"undefined":_(n))<"u"?n:("undefined"==typeof self?"undefined":_(self))<"u"?self:{};var pt={exports:{}};
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/!function(e){!function(){var r="input is invalid type",n="object"==("undefined"==typeof window?"undefined":_(window)),i=n?window:{};i.JS_SHA3_NO_WINDOW&&(n=!1);var o=!n&&"object"==("undefined"==typeof self?"undefined":_(self));!i.JS_SHA3_NO_NODE_JS&&"object"==(void 0===t?"undefined":_(t))&&t.versions&&t.versions.node?i=lt:o&&(i=self);var s=!i.JS_SHA3_NO_COMMON_JS&&e.exports,a=!i.JS_SHA3_NO_ARRAY_BUFFER&&("undefined"==typeof ArrayBuffer?"undefined":_(ArrayBuffer))<"u",u="0123456789abcdef".split(""),c=[4,1024,262144,67108864],f=[0,8,16,24],h=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],l=[224,256,384,512],p=[128,256],d=["hex","buffer","arrayBuffer","array","digest"],v={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),a&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(t){return"object"==_(t)&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var g=function(t,e,r){return function(n){return new R(t,e,t).update(n)[r]()}},y=function(t,e,r){return function(n,i){return new R(t,e,i).update(n)[r]()}},b=function(t,e,r){return function(e,n,i,o){return A["cshake"+t].update(e,n,i,o)[r]()}},m=function(t,e,r){return function(e,n,i,o){return A["kmac"+t].update(e,n,i,o)[r]()}},w=function(t,e,r,n){for(var i=0;i<d.length;++i){var o=d[i];t[o]=e(r,n,o)}return t},x=function(t,e){var r=g(t,e,"hex");return r.create=function(){return new R(t,e,t)},r.update=function(t){return r.create().update(t)},w(r,g,t,e)},E=[{name:"keccak",padding:[1,256,65536,16777216],bits:l,createMethod:x},{name:"sha3",padding:[6,1536,393216,100663296],bits:l,createMethod:x},{name:"shake",padding:[31,7936,2031616,520093696],bits:p,createMethod:function(t,e){var r=y(t,e,"hex");return r.create=function(r){return new R(t,e,r)},r.update=function(t,e){return r.create(e).update(t)},w(r,y,t,e)}},{name:"cshake",padding:c,bits:p,createMethod:function(t,e){var r=v[t],n=b(t,0,"hex");return n.create=function(n,i,o){return i||o?new R(t,e,n).bytepad([i,o],r):A["shake"+t].create(n)},n.update=function(t,e,r,i){return n.create(e,r,i).update(t)},w(n,b,t,e)}},{name:"kmac",padding:c,bits:p,createMethod:function(t,e){var r=v[t],n=m(t,0,"hex");return n.create=function(n,i,o){return new N(t,e,i).bytepad(["KMAC",o],r).bytepad([n],r)},n.update=function(t,e,r,i){return n.create(t,r,i).update(e)},w(n,m,t,e)}}],A={},O=[],S=0;S<E.length;++S)for(var k=E[S],I=k.bits,j=0;j<I.length;++j){var P=k.name+"_"+I[j];if(O.push(P),A[P]=k.createMethod(I[j],k.padding),"sha3"!==k.name){var M=k.name+I[j];O.push(M),A[M]=A[P]}}function R(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function N(t,e,r){R.call(this,t,e,r)}R.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var e,n=_(t);if("string"!==n){if("object"!==n)throw new Error(r);if(null===t)throw new Error(r);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(r);e=!0}for(var i,o,s=this.blocks,u=this.byteCount,c=t.length,h=this.blockCount,l=0,p=this.s;l<c;){if(this.reset)for(this.reset=!1,s[0]=this.block,i=1;i<h+1;++i)s[i]=0;if(e)for(i=this.start;l<c&&i<u;++l)s[i>>2]|=t[l]<<f[3&i++];else for(i=this.start;l<c&&i<u;++l)(o=t.charCodeAt(l))<128?s[i>>2]|=o<<f[3&i++]:o<2048?(s[i>>2]|=(192|o>>6)<<f[3&i++],s[i>>2]|=(128|63&o)<<f[3&i++]):o<55296||o>=57344?(s[i>>2]|=(224|o>>12)<<f[3&i++],s[i>>2]|=(128|o>>6&63)<<f[3&i++],s[i>>2]|=(128|63&o)<<f[3&i++]):(o=65536+((1023&o)<<10|1023&t.charCodeAt(++l)),s[i>>2]|=(240|o>>18)<<f[3&i++],s[i>>2]|=(128|o>>12&63)<<f[3&i++],s[i>>2]|=(128|o>>6&63)<<f[3&i++],s[i>>2]|=(128|63&o)<<f[3&i++]);if(this.lastByteIndex=i,i>=u){for(this.start=i-u,this.block=s[h],i=0;i<h;++i)p[i]^=s[i];T(p),this.reset=!0}else this.start=i}return this},R.prototype.encode=function(t,e){var r=255&t,n=1,i=[r];for(r=255&(t>>=8);r>0;)i.unshift(r),r=255&(t>>=8),++n;return e?i.push(n):i.unshift(n),this.update(i),i.length},R.prototype.encodeString=function(t){var e,n=_(t);if("string"!==n){if("object"!==n)throw new Error(r);if(null===t)throw new Error(r);if(a&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||a&&ArrayBuffer.isView(t)))throw new Error(r);e=!0}var i=0,o=t.length;if(e)i=o;else for(var s=0;s<t.length;++s){var u=t.charCodeAt(s);u<128?i+=1:u<2048?i+=2:u<55296||u>=57344?i+=3:(u=65536+((1023&u)<<10|1023&t.charCodeAt(++s)),i+=4)}return i+=this.encode(8*i),this.update(t),i},R.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var i=e-r%e,o=[];return o.length=i,this.update(o),this},R.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,n=this.s;if(t[e>>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)n[e]^=t[e];T(n)}},R.prototype.toString=R.prototype.hex=function(){this.finalize();for(var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a="";s<n;){for(o=0;o<e&&s<n;++o,++s)t=r[o],a+=u[t>>4&15]+u[15&t]+u[t>>12&15]+u[t>>8&15]+u[t>>20&15]+u[t>>16&15]+u[t>>28&15]+u[t>>24&15];s%e==0&&(T(r),o=0)}return i&&(t=r[o],a+=u[t>>4&15]+u[15&t],i>1&&(a+=u[t>>12&15]+u[t>>8&15]),i>2&&(a+=u[t>>20&15]+u[t>>16&15])),a},R.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var u=new Uint32Array(t);s<n;){for(o=0;o<e&&s<n;++o,++s)u[s]=r[o];s%e==0&&T(r)}return i&&(u[o]=r[o],t=t.slice(0,a)),t},R.prototype.buffer=R.prototype.arrayBuffer,R.prototype.digest=R.prototype.array=function(){this.finalize();for(var t,e,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,s=0,a=0,u=[];a<i;){for(s=0;s<r&&a<i;++s,++a)t=a<<2,e=n[s],u[t]=255&e,u[t+1]=e>>8&255,u[t+2]=e>>16&255,u[t+3]=e>>24&255;a%r==0&&T(n)}return o&&(t=a<<2,e=n[s],u[t]=255&e,o>1&&(u[t+1]=e>>8&255),o>2&&(u[t+2]=e>>16&255)),u},N.prototype=new R,N.prototype.finalize=function(){return this.encode(this.outputBits,!0),R.prototype.finalize.call(this)};var T=function(t){var e,r,n,i,o,s,a,u,c,f,l,p,d,v,g,y,b,m,w,x,E,_,A,O,S,k,I,j,P,M,R,N,T,L,C,U,D,B,q,z,F,K,H,G,V,Y,J,W,Q,X,Z,$,tt,et,rt,nt,it,ot,st,at,ut,ct,ft;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],s=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],u=t[4]^t[14]^t[24]^t[34]^t[44],c=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],l=t[7]^t[17]^t[27]^t[37]^t[47],e=(p=t[8]^t[18]^t[28]^t[38]^t[48])^(s<<1|a>>>31),r=(d=t[9]^t[19]^t[29]^t[39]^t[49])^(a<<1|s>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(u<<1|c>>>31),r=o^(c<<1|u>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=s^(f<<1|l>>>31),r=a^(l<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=u^(p<<1|d>>>31),r=c^(d<<1|p>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|o>>>31),r=l^(o<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,v=t[0],g=t[1],Y=t[11]<<4|t[10]>>>28,J=t[10]<<4|t[11]>>>28,j=t[20]<<3|t[21]>>>29,P=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ut=t[30]<<9|t[31]>>>23,K=t[40]<<18|t[41]>>>14,H=t[41]<<18|t[40]>>>14,L=t[2]<<1|t[3]>>>31,C=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,b=t[12]<<12|t[13]>>>20,W=t[22]<<10|t[23]>>>22,Q=t[23]<<10|t[22]>>>22,M=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,ct=t[42]<<2|t[43]>>>30,ft=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,U=t[14]<<6|t[15]>>>26,D=t[15]<<6|t[14]>>>26,m=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,X=t[34]<<15|t[35]>>>17,Z=t[35]<<15|t[34]>>>17,N=t[45]<<29|t[44]>>>3,T=t[44]<<29|t[45]>>>3,O=t[6]<<28|t[7]>>>4,S=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,B=t[26]<<25|t[27]>>>7,q=t[27]<<25|t[26]>>>7,x=t[36]<<21|t[37]>>>11,E=t[37]<<21|t[36]>>>11,$=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,G=t[8]<<27|t[9]>>>5,V=t[9]<<27|t[8]>>>5,k=t[18]<<20|t[19]>>>12,I=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,st=t[28]<<7|t[29]>>>25,z=t[38]<<8|t[39]>>>24,F=t[39]<<8|t[38]>>>24,_=t[48]<<14|t[49]>>>18,A=t[49]<<14|t[48]>>>18,t[0]=v^~y&m,t[1]=g^~b&w,t[10]=O^~k&j,t[11]=S^~I&P,t[20]=L^~U&B,t[21]=C^~D&q,t[30]=G^~Y&W,t[31]=V^~J&Q,t[40]=et^~nt&ot,t[41]=rt^~it&st,t[2]=y^~m&x,t[3]=b^~w&E,t[12]=k^~j&M,t[13]=I^~P&R,t[22]=U^~B&z,t[23]=D^~q&F,t[32]=Y^~W&X,t[33]=J^~Q&Z,t[42]=nt^~ot&at,t[43]=it^~st&ut,t[4]=m^~x&_,t[5]=w^~E&A,t[14]=j^~M&N,t[15]=P^~R&T,t[24]=B^~z&K,t[25]=q^~F&H,t[34]=W^~X&$,t[35]=Q^~Z&tt,t[44]=ot^~at&ct,t[45]=st^~ut&ft,t[6]=x^~_&v,t[7]=E^~A&g,t[16]=M^~N&O,t[17]=R^~T&S,t[26]=z^~K&L,t[27]=F^~H&C,t[36]=X^~$&G,t[37]=Z^~tt&V,t[46]=at^~ct&et,t[47]=ut^~ft&rt,t[8]=_^~v&y,t[9]=A^~g&b,t[18]=N^~O&k,t[19]=T^~S&I,t[28]=K^~L&U,t[29]=H^~C&D,t[38]=$^~G&Y,t[39]=tt^~V&J,t[48]=ct^~et&nt,t[49]=ft^~rt&it,t[0]^=h[n],t[1]^=h[n+1]};if(s)e.exports=A;else for(S=0;S<O.length;++S)i[O[S]]=A[O[S]]}()}(pt);var dt=pt.exports,vt=!1,gt=!1,yt={debug:1,default:2,info:2,warning:3,error:4,off:5},bt=yt.default,mt=null;var wt,xt,Et=function(){try{var t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((function(e){try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(wt||(wt={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(xt||(xt={}));var _t="0123456789abcdef",At=function(){function t(e){b(this,t),Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return w(t,[{key:"_log",value:function(t,e){var r=t.toLowerCase();null==yt[r]&&this.throwArgumentError("invalid log level name","logLevel",t),!(bt>yt[r])&&console.log.apply(console,e)}},{key:"debug",value:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];this._log(t.levels.DEBUG,r)}},{key:"info",value:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];this._log(t.levels.INFO,r)}},{key:"warn",value:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];this._log(t.levels.WARNING,r)}},{key:"makeError",value:function(e,r,n){if(gt)return this.makeError("censored error",r,{});r||(r=t.errors.UNKNOWN_ERROR),n||(n={});var i=[];Object.keys(n).forEach((function(t){var e=n[t];try{if(e instanceof Uint8Array){for(var r="",o=0;o<e.length;o++)r+=_t[e[o]>>4],r+=_t[15&e[o]];i.push(t+"=Uint8Array(0x"+r+")")}else i.push(t+"="+JSON.stringify(e))}catch(e){i.push(t+"="+JSON.stringify(n[t].toString()))}})),i.push("code=".concat(r)),i.push("version=".concat(this.version));var o=e,s="";switch(r){case xt.NUMERIC_FAULT:s="NUMERIC_FAULT";var a=e;switch(a){case"overflow":case"underflow":case"division-by-zero":s+="-"+a;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break;case xt.CALL_EXCEPTION:case xt.INSUFFICIENT_FUNDS:case xt.MISSING_NEW:case xt.NONCE_EXPIRED:case xt.REPLACEMENT_UNDERPRICED:case xt.TRANSACTION_REPLACED:case xt.UNPREDICTABLE_GAS_LIMIT:s=r}s&&(e+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),i.length&&(e+=" ("+i.join(", ")+")");var u=new Error(e);return u.reason=o,u.code=r,Object.keys(n).forEach((function(t){u[t]=n[t]})),u}},{key:"throwError",value:function(t,e,r){throw this.makeError(t,e,r)}},{key:"throwArgumentError",value:function(e,r,n){return this.throwError(e,t.errors.INVALID_ARGUMENT,{argument:r,value:n})}},{key:"assert",value:function(t,e,r,n){t||this.throwError(e,r,n)}},{key:"assertArgument",value:function(t,e,r,n){t||this.throwArgumentError(e,r,n)}},{key:"checkNormalize",value:function(e){Et&&this.throwError("platform missing String.prototype.normalize",t.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Et})}},{key:"checkSafeUint53",value:function(e,r){"number"==typeof e&&(null==r&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,t.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,t.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}},{key:"checkArgumentCount",value:function(e,r,n){n=n?": "+n:"",e<r&&this.throwError("missing argument"+n,t.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+n,t.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}},{key:"checkNew",value:function(e,r){(e===Object||null==e)&&this.throwError("missing new",t.errors.MISSING_NEW,{name:r.name})}},{key:"checkAbstract",value:function(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",t.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||null==e)&&this.throwError("missing new",t.errors.MISSING_NEW,{name:r.name})}}],[{key:"globalLogger",value:function(){return mt||(mt=new t("logger/5.7.0")),mt}},{key:"setCensorship",value:function(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",t.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),vt){if(!e)return;this.globalLogger().throwError("error censorship permanent",t.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}gt=!!e,vt=!!r}},{key:"setLogLevel",value:function(e){var r=yt[e.toLowerCase()];null!=r?bt=r:t.globalLogger().warn("invalid log level - "+e)}},{key:"from",value:function(e){return new t(e)}}])}();At.errors=xt,At.levels=wt;var Ot=new At("bytes/5.7.0");function St(t){return!!t.toHexString}function kt(t){return t.slice||(t.slice=function(){var e=Array.prototype.slice.call(arguments);return kt(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function It(t){return"number"==typeof t&&t==t&&t%1==0}function jt(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t||!It(t.length)||t.length<0)return!1;for(var e=0;e<t.length;e++){var r=t[e];if(!It(r)||r<0||r>=256)return!1}return!0}function Pt(t,e){if(e||(e={}),"number"==typeof t){Ot.checkSafeUint53(t,"invalid arrayify value");for(var r=[];t;)r.unshift(255&t),t=parseInt(String(t/256));return 0===r.length&&r.push(0),kt(new Uint8Array(r))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),St(t)&&(t=t.toHexString()),Mt(t)){var n=t.substring(2);n.length%2&&("left"===e.hexPad?n="0"+n:"right"===e.hexPad?n+="0":Ot.throwArgumentError("hex data is odd-length","value",t));for(var i=[],o=0;o<n.length;o+=2)i.push(parseInt(n.substring(o,o+2),16));return kt(new Uint8Array(i))}return jt(t)?kt(new Uint8Array(t)):Ot.throwArgumentError("invalid arrayify value","value",t)}function Mt(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}var Rt="0123456789abcdef";function Nt(t,e){if(e||(e={}),"number"==typeof t){Ot.checkSafeUint53(t,"invalid hexlify value");for(var r="";t;)r=Rt[15&t]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),St(t))return t.toHexString();if(Mt(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Ot.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(jt(t)){for(var n="0x",i=0;i<t.length;i++){var o=t[i];n+=Rt[(240&o)>>4]+Rt[15&o]}return n}return Ot.throwArgumentError("invalid hexlify value","value",t)}function Tt(t,e,r){return"string"!=typeof t?t=Nt(t):(!Mt(t)||t.length%2)&&Ot.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Lt(t,e){for("string"!=typeof t?t=Nt(t):Mt(t)||Ot.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Ot.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function Ct(t){var e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(function(t){return Mt(t)&&!(t.length%2)||jt(t)}(t)){var r=Pt(t);64===r.length?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Nt(r.slice(0,32)),e.s=Nt(r.slice(32,64))):65===r.length?(e.r=Nt(r.slice(0,32)),e.s=Nt(r.slice(32,64)),e.v=r[64]):Ot.throwArgumentError("invalid signature string","signature",t),e.v<27&&(0===e.v||1===e.v?e.v+=27:Ot.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Nt(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){var n=function(t,e){(t=Pt(t)).length>e&&Ot.throwArgumentError("value out of range","value",arguments[0]);var r=new Uint8Array(e);return r.set(t,e-t.length),kt(r)}(Pt(e._vs),32);e._vs=Nt(n);var i=n[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=i:e.recoveryParam!==i&&Ot.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;var o=Nt(n);null==e.s?e.s=o:e.s!==o&&Ot.throwArgumentError("signature v mismatch _vs","signature",t)}if(null==e.recoveryParam)null==e.v?Ot.throwArgumentError("signature missing v and recoveryParam","signature",t):0===e.v||1===e.v?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(null==e.v)e.v=27+e.recoveryParam;else{var s=0===e.v||1===e.v?e.v:1-e.v%2;e.recoveryParam!==s&&Ot.throwArgumentError("signature recoveryParam mismatch v","signature",t)}null!=e.r&&Mt(e.r)?e.r=Lt(e.r,32):Ot.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&Mt(e.s)?e.s=Lt(e.s,32):Ot.throwArgumentError("signature missing or invalid s","signature",t);var a=Pt(e.s);a[0]>=128&&Ot.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(a[0]|=128);var u=Nt(a);e._vs&&(Mt(e._vs)||Ot.throwArgumentError("signature invalid _vs","signature",t),e._vs=Lt(e._vs,32)),null==e._vs?e._vs=u:e._vs!==u&&Ot.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function Ut(t){return"0x"+dt.keccak_256(Pt(t))}var Dt={exports:{}},Bt=function(t){var e=t.default;if("function"==typeof e){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})})),r}(Object.freeze({__proto__:null,default:{}}));!function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(("le"===e||"be"===e)&&(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==_(t)?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o=("undefined"==typeof window?"undefined":_(window))<"u"&&_(window.Buffer)<"u"?window.Buffer:Bt.Buffer}catch(t){}function s(t,e){var n=t.charCodeAt(e);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,n,i){for(var o=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<i,"Invalid character"),o+=s}return o}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(i.isBN=function(t){return t instanceof i||null!==t&&"object"==_(t)&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==_(t))return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,f=r;f<a;f+=n)c=u(t,f,f+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var h=1;for(c=u(t,f,t.length,e),f=0;f<s;f++)h*=e;this.imuln(h),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype._move=function(t){c(t,this)},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},("undefined"==typeof Symbol?"undefined":_(Symbol))<"u"&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){i.prototype.inspect=f}else i.prototype.inspect=f;function f(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?h[6-u.length]+u+n:u+n}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],f=p[t];n="";var d=this.clone();for(d.negative=0;!d.isZero();){var v=d.modrn(f).toString(t);n=(d=d.idivn(f)).isZero()?v+n:h[c-v.length]+v+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function d(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<n;c++){for(var f=u>>>26,h=67108863&u,l=Math.min(c,e.length-1),p=Math.max(0,c-t.length+1);p<=l;p++){var d=c-p|0;f+=(s=(i=0|t.words[d])*(o=0|e.words[p])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}i.prototype.toArrayLike=function(t,e,n){this._strip();var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0},i.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 8191&e||(r+=13,e>>>=13),127&e||(r+=7,e>>>=7),15&e||(r+=4,e>>>=4),3&e||(r+=2,e>>>=2),1&e||r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];ret